├── .nvmrc ├── test-agents ├── agentic-ai │ ├── .npmrc │ ├── Dockerfile │ ├── tsconfig.json │ ├── env.TEMPLATE │ └── package.json ├── empty-agent │ ├── .npmrc │ ├── Dockerfile │ ├── README.md │ ├── tsconfig.json │ ├── env.TEMPLATE │ └── package.json ├── root-agent │ ├── .npmrc │ ├── README.md │ ├── Dockerfile │ ├── tsconfig.json │ ├── env.TEMPLATE │ ├── src │ │ └── state.ts │ └── package.json ├── state-agent │ ├── .npmrc │ ├── README.md │ ├── tsconfig.json │ ├── env.TEMPLATE │ └── package.json ├── web-chat │ ├── .npmrc │ ├── Dockerfile │ ├── env.TEMPLATE │ ├── tsconfig.json │ ├── README.md │ ├── cards │ │ ├── SuggestedActions.json │ │ └── ToggleVisibleCard.json │ ├── resources │ │ ├── SuggestedActions.json │ │ └── ToggleVisibleCard.json │ └── package.json ├── custom-dialogs │ ├── .npmrc │ ├── Dockerfile │ ├── env.TEMPLATE │ ├── tsconfig.json │ ├── README.md │ ├── src │ │ └── dialogs │ │ │ └── slotDetails.ts │ └── package.json ├── application-style │ ├── .npmrc │ ├── Dockerfile │ ├── tsconfig.json │ └── env.TEMPLATE ├── copilotstudio-console │ ├── .npmrc │ ├── tsconfig.json │ └── package.json ├── multi-turn-prompt │ ├── .npmrc │ ├── Dockerfile │ ├── env.TEMPLATE │ ├── tsconfig.json │ ├── README.md │ ├── src │ │ └── userProfile.ts │ └── package.json ├── copilotstudio-webchat │ ├── index.css │ ├── .gitignore │ └── index.html └── README.md ├── packages ├── agents-hosting-express │ ├── src │ │ └── index.ts │ ├── tsconfig.json │ ├── README.md │ └── package.json ├── agents-hosting │ ├── src │ │ ├── agent-client │ │ │ └── index.ts │ │ ├── app │ │ │ ├── auth │ │ │ │ ├── index.ts │ │ │ │ └── handlers │ │ │ │ │ └── index.ts │ │ │ ├── adaptiveCards │ │ │ │ ├── index.ts │ │ │ │ ├── query.ts │ │ │ │ ├── adaptiveCardActionExecuteResponseType.ts │ │ │ │ ├── adaptiveCardsSearchParams.ts │ │ │ │ └── adaptiveCardsOptions.ts │ │ │ ├── turnEvents.ts │ │ │ ├── conversationUpdateEvents.ts │ │ │ ├── streaming │ │ │ │ └── citation.ts │ │ │ ├── routeSelector.ts │ │ │ ├── routeHandler.ts │ │ │ └── index.ts │ │ ├── oauth │ │ │ ├── index.ts │ │ │ └── customUserTokenAPI.ts │ │ ├── storage │ │ │ └── index.ts │ │ ├── state │ │ │ └── index.ts │ │ ├── transcript │ │ │ ├── index.ts │ │ │ ├── consoleTranscriptLogger.ts │ │ │ └── transcriptLogger.ts │ │ ├── auth │ │ │ ├── index.ts │ │ │ ├── authConstants.ts │ │ │ └── request.ts │ │ ├── tokenResponseEventName.ts │ │ ├── cards │ │ │ ├── fact.ts │ │ │ ├── mediaUrl.ts │ │ │ ├── thumbnailUrl.ts │ │ │ ├── o365ConnectorCardFact.ts │ │ │ ├── o365ConnectorCardImage.ts │ │ │ ├── signinCard.ts │ │ │ ├── cardImage.ts │ │ │ ├── adaptiveCard.ts │ │ │ ├── index.ts │ │ │ ├── heroCard.ts │ │ │ ├── thumbnailCard.ts │ │ │ ├── receiptItem.ts │ │ │ ├── o365ConnectorCard.ts │ │ │ ├── o365ConnectorCardActionBase.ts │ │ │ ├── receiptCard.ts │ │ │ ├── audioCard.ts │ │ │ └── animationCard.ts │ │ ├── connector-client │ │ │ ├── index.ts │ │ │ ├── resourceResponse.ts │ │ │ ├── attachmentView.ts │ │ │ ├── conversationMembers.ts │ │ │ ├── conversationResourceResponse.ts │ │ │ ├── conversationsResult.ts │ │ │ ├── attachmentInfo.ts │ │ │ └── attachmentData.ts │ │ ├── invoke │ │ │ ├── searchInvokeResponse.ts │ │ │ ├── index.ts │ │ │ ├── invokeResponse.ts │ │ │ ├── searchInvokeOptions.ts │ │ │ ├── tokenExchangeInvokeRequest.ts │ │ │ ├── adaptiveCardInvokeResponse.ts │ │ │ ├── adaptiveCardAuthentication.ts │ │ │ ├── searchInvokeValue.ts │ │ │ ├── adaptiveCardInvokeValue.ts │ │ │ └── invokeException.ts │ │ ├── getProductInfo.ts │ │ └── index.ts │ ├── tsconfig.json │ └── test │ │ ├── cases │ │ └── scenarios.md │ │ └── activity-value-parsers │ │ ├── parseValueQuery.test.ts │ │ ├── parseValueAction.test.ts │ │ ├── parseValueDataset.test.ts │ │ ├── parseValueActionName.test.ts │ │ ├── parseValueCommandId.test.ts │ │ ├── parseValueContinuation.test.ts │ │ ├── parseValueBotMessagePreviewAction.test.ts │ │ └── parseValueActionExecuteSelector.test.ts ├── agents-hosting-extensions-teams │ ├── src │ │ ├── client │ │ │ └── index.ts │ │ ├── file │ │ │ ├── index.ts │ │ │ ├── fileUploadInfo.ts │ │ │ └── fileConsentCardResponse.ts │ │ ├── activity-extensions │ │ │ ├── teamsMessageEvents.ts │ │ │ ├── tenantInfo.ts │ │ │ ├── teamsMeetingInfo.ts │ │ │ ├── teamsChannelDataParser.ts │ │ │ ├── channelTypes.ts │ │ │ ├── teamsChannelAccount.ts │ │ │ ├── teamsChannelDataSettings.ts │ │ │ ├── index.ts │ │ │ ├── channelInfo.ts │ │ │ ├── notificationInfo.ts │ │ │ ├── teamInfo.ts │ │ │ └── onBehalfOf.ts │ │ ├── meeting │ │ │ ├── meetingNotification.ts │ │ │ ├── meetingEventDetails.ts │ │ │ ├── meetingEndEventDetails.ts │ │ │ ├── meetingDetailsBase.ts │ │ │ ├── meetingStartEventDetails.ts │ │ │ ├── meetingTabIconSurface.ts │ │ │ ├── meetingParticipantsEventDetails.ts │ │ │ ├── userMeetingDetails.ts │ │ │ ├── meetingNotificationBase.ts │ │ │ ├── meetingSurface.ts │ │ │ ├── meetingNotificationChannelData.ts │ │ │ ├── meetingNotificationResponse.ts │ │ │ ├── meetingStageSurface.ts │ │ │ ├── meetingNotificationRecipientFailureInfo.ts │ │ │ ├── targetedMeetingNotificationValue.ts │ │ │ ├── teamsMeetingMember.ts │ │ │ ├── meetingDetails.ts │ │ │ ├── meetingInfo.ts │ │ │ ├── targetedMeetingNotification.ts │ │ │ ├── teamsMeetingParticipant.ts │ │ │ └── index.ts │ │ ├── taskModule │ │ │ ├── taskModuleRequestContext.ts │ │ │ ├── index.ts │ │ │ ├── taskModuleMessageResponse.ts │ │ │ ├── taskModuleResponseBase.ts │ │ │ ├── taskModuleContinueResponse.ts │ │ │ ├── taskModuleRequest.ts │ │ │ ├── taskModuleResponse.ts │ │ │ └── taskModuleTaskInfo.ts │ │ ├── messageExtension │ │ │ ├── messagingExtensionSuggestedAction.ts │ │ │ ├── messagingExtensionAttachment.ts │ │ │ ├── appBasedLinkQuery.ts │ │ │ ├── messagingExtensionResponse.ts │ │ │ ├── index.ts │ │ │ ├── messagingExtensionParameter.ts │ │ │ ├── messagingExtensionQueryOptions.ts │ │ │ └── messagingExtensionActionResponse.ts │ │ ├── index.ts │ │ ├── teamsAttachmentDownloader.ts │ │ ├── message-actions-payload │ │ │ ├── index.ts │ │ │ ├── messageActionsPayloadMention.ts │ │ │ ├── messageActionsPayloadBody.ts │ │ │ ├── messageActionsPayloadConversation.ts │ │ │ ├── messageActionsPayloadApp.ts │ │ │ ├── messageActionsPayloadReaction.ts │ │ │ ├── messageActionsPayloadAttachment.ts │ │ │ ├── messageActionsPayloadFrom.ts │ │ │ └── messageActionsPayloadUser.ts │ │ └── feedbackLoopData.ts │ ├── tsconfig.json │ └── package.json ├── agents-copilotstudio-client │ ├── src │ │ ├── browser │ │ │ └── os.ts │ │ ├── index.ts │ │ ├── agentType.ts │ │ ├── strategies │ │ │ └── strategy.ts │ │ └── executeTurnRequest.ts │ └── tsconfig.json ├── agents-activity │ ├── tsconfig.json │ ├── src │ │ ├── entity │ │ │ ├── thing.ts │ │ │ ├── mention.ts │ │ │ ├── entity.ts │ │ │ ├── place.ts │ │ │ ├── geoCoordinates.ts │ │ │ └── productInfo.ts │ │ ├── expectedReplies.ts │ │ ├── callerIdConstants.ts │ │ ├── activityTreatments.ts │ │ ├── textHighlight.ts │ │ ├── messageReactionTypes.ts │ │ ├── attachment │ │ │ ├── attachmentLayoutTypes.ts │ │ │ └── attachment.ts │ │ ├── conversation │ │ │ ├── membershipTypes.ts │ │ │ ├── membershipSourceTypes.ts │ │ │ ├── roleTypes.ts │ │ │ └── conversationParameters.ts │ │ ├── messageReaction.ts │ │ ├── activityImportance.ts │ │ ├── action │ │ │ ├── suggestedActions.ts │ │ │ ├── semanticActionStateTypes.ts │ │ │ └── semanticAction.ts │ │ ├── activityEventNames.ts │ │ ├── textFormatTypes.ts │ │ ├── inputHints.ts │ │ ├── deliveryModes.ts │ │ └── invoke │ │ │ └── adaptiveCardInvokeAction.ts │ ├── README.md │ └── test │ │ └── activity │ │ ├── activity.value.test.ts │ │ ├── activity.treatment.tests.ts │ │ └── activityType.test.ts ├── agents-hosting-storage-blob │ ├── tsconfig.json │ ├── src │ │ ├── index.ts │ │ └── ignoreError.ts │ ├── README.md │ └── package.json ├── agents-hosting-storage-cosmos │ ├── tsconfig.json │ ├── src │ │ ├── index.ts │ │ └── cosmosDbPartitionedStorageOptions.ts │ ├── README.md │ └── package.json └── agents-hosting-dialogs │ ├── tsconfig.json │ ├── vendor │ └── cldr-data │ │ └── README.md │ └── src │ ├── choices │ ├── index.ts │ ├── choice.ts │ └── modelResult.ts │ ├── prompts │ └── index.ts │ ├── memory │ ├── pathResolvers │ │ ├── index.ts │ │ ├── pathResolver.ts │ │ ├── dollarPathResolver.ts │ │ ├── percentPathResolver.ts │ │ ├── atAtPathResolver.ts │ │ └── hashPathResolver.ts │ ├── index.ts │ ├── scopes │ │ ├── index.ts │ │ ├── userMemoryScope.ts │ │ └── conversationMemoryScope.ts │ ├── componentMemoryScopes.ts │ └── componentPathResolvers.ts │ ├── intentScore.ts │ ├── configuration.ts │ ├── template.ts │ ├── converter.ts │ ├── dialogTurnStateConstants.ts │ ├── i18n.ts │ ├── dialogInstance.ts │ ├── dialogEvent.ts │ ├── dialogTurnStatus.ts │ ├── componentRegistration.ts │ └── dialogEvents.ts ├── .gitignore ├── samples ├── _resources │ ├── multi-agents.jpg │ ├── SuggestedActions.json │ ├── PullRequestCard.json │ └── ToggleVisibleCard.json ├── basic │ ├── echo.ts │ ├── attachments.ts │ └── traceActivities.ts ├── teams │ ├── teamsAttachments.ts │ └── compat │ │ └── echo.ts ├── state │ ├── blob2Cnx.ts │ └── userState.ts └── auth │ └── noAuthDemo.ts ├── eslint.config.js ├── .vscode ├── extensions.json └── settings.json ├── .github ├── scripts │ ├── docfx.sh │ └── updatelock.sh ├── dependabot.yml └── ISSUE_TEMPLATE │ └── bug_report.md ├── CODEOWNERS ├── tsconfig.samples.json ├── typedoc.json ├── version.json ├── CODE_OF_CONDUCT.md ├── tsconfig.json ├── compat └── baseline │ ├── agents-hosting-express.api.md │ └── agents-hosting-storage-cosmos.api.md └── LICENSE /.nvmrc: -------------------------------------------------------------------------------- 1 | v24.3.0 2 | -------------------------------------------------------------------------------- /test-agents/agentic-ai/.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false -------------------------------------------------------------------------------- /test-agents/empty-agent/.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false -------------------------------------------------------------------------------- /test-agents/root-agent/.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false -------------------------------------------------------------------------------- /test-agents/state-agent/.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false -------------------------------------------------------------------------------- /test-agents/web-chat/.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false -------------------------------------------------------------------------------- /test-agents/custom-dialogs/.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false -------------------------------------------------------------------------------- /test-agents/application-style/.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false -------------------------------------------------------------------------------- /test-agents/copilotstudio-console/.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false -------------------------------------------------------------------------------- /test-agents/multi-turn-prompt/.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false -------------------------------------------------------------------------------- /packages/agents-hosting-express/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './startServer' 2 | -------------------------------------------------------------------------------- /test-agents/root-agent/README.md: -------------------------------------------------------------------------------- 1 | # root-agent 2 | 3 | An agent to call other agents -------------------------------------------------------------------------------- /test-agents/agentic-ai/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:alpine 2 | WORKDIR /app 3 | COPY dist/bundle.js . 4 | CMD ["node", "bundle.js"] -------------------------------------------------------------------------------- /test-agents/root-agent/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:alpine 2 | WORKDIR /app 3 | COPY dist/bundle.js . 4 | CMD ["node", "bundle.js"] -------------------------------------------------------------------------------- /test-agents/web-chat/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:alpine 2 | WORKDIR /app 3 | COPY dist/bundle.js . 4 | CMD ["node", "bundle.js"] -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | dist/ 3 | *.env 4 | *.key 5 | *.pem 6 | test-report.xml 7 | tsconfig.tsbuildinfo 8 | devTools/ 9 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/agent-client/index.ts: -------------------------------------------------------------------------------- 1 | export * from './agentClient' 2 | export * from './agentResponseHandler' 3 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/app/auth/index.ts: -------------------------------------------------------------------------------- 1 | export * from './authorization' 2 | export * from './authorizationManager' 3 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/oauth/index.ts: -------------------------------------------------------------------------------- 1 | export * from './userTokenClient' 2 | export * from './userTokenClient.types' 3 | -------------------------------------------------------------------------------- /test-agents/custom-dialogs/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:alpine 2 | WORKDIR /app 3 | COPY dist/bundle.js . 4 | CMD ["node", "bundle.js"] -------------------------------------------------------------------------------- /test-agents/empty-agent/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:alpine 2 | WORKDIR /app 3 | COPY dist/bundle.js . 4 | CMD ["node", "bundle.js"] -------------------------------------------------------------------------------- /test-agents/empty-agent/README.md: -------------------------------------------------------------------------------- 1 | # emtpy-agent 2 | 3 | The simplest agent, used to validate different authentication options -------------------------------------------------------------------------------- /samples/_resources/multi-agents.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Agents-for-js/HEAD/samples/_resources/multi-agents.jpg -------------------------------------------------------------------------------- /test-agents/application-style/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:alpine 2 | WORKDIR /app 3 | COPY dist/bundle.cjs . 4 | CMD ["node", "bundle.cjs"] -------------------------------------------------------------------------------- /test-agents/multi-turn-prompt/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:alpine 2 | WORKDIR /app 3 | COPY dist/bundle.js . 4 | CMD ["node", "bundle.js"] -------------------------------------------------------------------------------- /packages/agents-hosting/src/app/auth/handlers/index.ts: -------------------------------------------------------------------------------- 1 | export * from './azureBotAuthorization' 2 | export * from './agenticAuthorization' 3 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/storage/index.ts: -------------------------------------------------------------------------------- 1 | export * from './storage' 2 | export * from './memoryStorage' 3 | export * from './fileStorage' 4 | -------------------------------------------------------------------------------- /eslint.config.js: -------------------------------------------------------------------------------- 1 | import neostandard from 'neostandard' 2 | 3 | export default neostandard({ ts: true, ignores: ['node_modules', '**/dist/**'] }) 4 | -------------------------------------------------------------------------------- /test-agents/root-agent/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "src", 5 | "outDir": "dist" 6 | } 7 | } -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "github.copilot", 4 | "connor4312.nodejs-testing", 5 | "dbaeumer.vscode-eslint" 6 | ] 7 | } -------------------------------------------------------------------------------- /.github/scripts/docfx.sh: -------------------------------------------------------------------------------- 1 | for dir in ./packages/*; do 2 | echo "typedocfx for $dir" 3 | (cd "$dir" && npx type2docfx . "./../../docs/yaml/${PWD##*/}" && cd ../..) 4 | done 5 | -------------------------------------------------------------------------------- /test-agents/application-style/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "src", 5 | "outDir": "dist" 6 | } 7 | } -------------------------------------------------------------------------------- /test-agents/custom-dialogs/env.TEMPLATE: -------------------------------------------------------------------------------- 1 | # rename to .env 2 | tenantId=0000000000000000000 3 | clientId=0000000000000000000 4 | clientSecret=ssshhhhhhhhhhhh 5 | agentName=CustomDialogs 6 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/state/index.ts: -------------------------------------------------------------------------------- 1 | export * from './userState' 2 | export * from './conversationState' 3 | export * from './agentStatePropertyAccesor' 4 | export * from './agentState' 5 | -------------------------------------------------------------------------------- /test-agents/copilotstudio-webchat/index.css: -------------------------------------------------------------------------------- 1 | html, 2 | body { 3 | height: 100%; 4 | } 5 | body { 6 | margin: 0; 7 | } 8 | #webchat { 9 | height: 100%; 10 | width: 100%; 11 | } 12 | -------------------------------------------------------------------------------- /test-agents/multi-turn-prompt/env.TEMPLATE: -------------------------------------------------------------------------------- 1 | # rename to .env 2 | tenantId=0000000000000000000 3 | clientId=0000000000000000000 4 | clientSecret=ssshhhhhhhhhhhh 5 | botName=MultiTurnPromptsBot 6 | -------------------------------------------------------------------------------- /test-agents/state-agent/README.md: -------------------------------------------------------------------------------- 1 | # state-agent 2 | 3 | Agent used to validate different storage providers: Memory, Blobs or Cosmos. 4 | 5 | Require to pass the connection string for each service -------------------------------------------------------------------------------- /test-agents/web-chat/env.TEMPLATE: -------------------------------------------------------------------------------- 1 | # rename to .env 2 | tenantId=0000000000000000000 3 | clientId=0000000000000000000 4 | clientSecret=ssshhhhhhhhhhhh 5 | connectionName="name" 6 | agentName=MultiFeatureAgent 7 | -------------------------------------------------------------------------------- /test-agents/agentic-ai/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "src", 5 | "outDir": "dist", 6 | "tsBuildInfoFile": "dist/.tsbuildinfo" 7 | } 8 | } -------------------------------------------------------------------------------- /test-agents/copilotstudio-webchat/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore settings.js to avoid committing sensitive information. 2 | # To start tracking changes again, use: git update-index --no-skip-worktree settings.js. 3 | settings.js -------------------------------------------------------------------------------- /test-agents/empty-agent/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "src", 5 | "outDir": "dist", 6 | "tsBuildInfoFile": "dist/.tsbuildinfo" 7 | } 8 | } -------------------------------------------------------------------------------- /test-agents/state-agent/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "src", 5 | "outDir": "dist", 6 | "tsBuildInfoFile": "dist/.tsbuildinfo" 7 | } 8 | } -------------------------------------------------------------------------------- /test-agents/web-chat/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "src", 5 | "outDir": "dist", 6 | "tsBuildInfoFile": "dist/.tsbuildinfo" 7 | } 8 | } -------------------------------------------------------------------------------- /packages/agents-hosting/src/transcript/index.ts: -------------------------------------------------------------------------------- 1 | export * from './transcriptLogger' 2 | export * from './transcriptStore' 3 | export * from './transcriptLoggerMiddleware' 4 | export * from './consoleTranscriptLogger' 5 | -------------------------------------------------------------------------------- /test-agents/custom-dialogs/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "src", 5 | "outDir": "dist", 6 | "tsBuildInfoFile": "dist/.tsbuildinfo" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test-agents/empty-agent/env.TEMPLATE: -------------------------------------------------------------------------------- 1 | # rename to .env 2 | tenantId=0000000000000000000 3 | clientId=0000000000000000000 4 | clientSecret=ssshhhhhhhhhhhh 5 | authorityEndpoint= 6 | FICClientId= 7 | -------------------------------------------------------------------------------- /test-agents/multi-turn-prompt/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "src", 5 | "outDir": "dist", 6 | "tsBuildInfoFile": "dist/.tsbuildinfo" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/client/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | export * from './teamsConnectorClient.types' 7 | -------------------------------------------------------------------------------- /packages/agents-copilotstudio-client/src/browser/os.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import type * as osTypes from 'os' 7 | 8 | export default {} as typeof osTypes 9 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | # CODEOWNERS for Microsoft 365 Agents SDK for JS 2 | 3 | # Global ownership - fallback for any files not covered by more specific rules 4 | * @microsoft/agents-sdk 5 | # Team is found here: 6 | # https://github.com/orgs/microsoft/teams/agents-sdk 7 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/file/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | export * from './fileConsentCardResponse' 7 | export * from './fileUploadInfo' 8 | -------------------------------------------------------------------------------- /packages/agents-activity/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDirs": [ "src/", "test/"], 5 | "outDir": "dist", 6 | "paths": { 7 | "@microsoft/*": ["./packages/*"] 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/app/adaptiveCards/index.ts: -------------------------------------------------------------------------------- 1 | export * from './adaptiveCardsActions' 2 | export * from './adaptiveCardsOptions' 3 | export * from './adaptiveCardActionExecuteResponseType' 4 | export * from './adaptiveCardsSearchParams' 5 | export * from './query' 6 | -------------------------------------------------------------------------------- /tsconfig.samples.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./dist/samples/", 5 | "rootDir": "./samples" 6 | }, 7 | "include": ["samples/**/*.ts", "samples/_resources/*.json"], 8 | "exclude": ["node_modules", "dist"] 9 | } -------------------------------------------------------------------------------- /packages/agents-hosting-storage-blob/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDirs": [ "src/", "test/"], 5 | "outDir": "dist", 6 | "paths": { 7 | "@microsoft/*": ["./packages/*"] 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/agents-hosting-storage-cosmos/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDirs": [ "src/", "test/"], 5 | "outDir": "dist", 6 | "paths": { 7 | "@microsoft/*": ["./packages/*"] 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test-agents/README.md: -------------------------------------------------------------------------------- 1 | # @microsoft/agents-for-js test-agents 2 | 3 | This folder contains some samples we use for testing the packages (we call those _tamples_ 😋) 4 | 5 | If you are looking for samples to learn how to use these packages see the samples in https://github.com/Microsoft/Agents 6 | -------------------------------------------------------------------------------- /test-agents/root-agent/env.TEMPLATE: -------------------------------------------------------------------------------- 1 | tenantId=0000000000000000000 2 | clientId=0000000000000000000 3 | clientSecret=ssshhhhhhhhhhhh 4 | 5 | Agent1_endpoint=http://localhost:39783/api/messages 6 | Agent1_clientId= 7 | Agent1_serviceUrl=http://localhost:3978/api/agentresponse 8 | -------------------------------------------------------------------------------- /test-agents/copilotstudio-console/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "module": "ESNext", 5 | "moduleResolution": "node", 6 | "rootDir": "src", 7 | "outDir": "dist", 8 | "tsBuildInfoFile": "dist/.tsbuildinfo" 9 | } 10 | } -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/activity-extensions/teamsMessageEvents.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | export type TeamsMessageEvents = 'undeleteMessage' | 'softDeleteMessage' | 'editMessage' 7 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDirs": [ "src/", "test/"], 5 | "outDir": "dist", 6 | "paths": { 7 | "@microsoft/*": ["./packages/*"] 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/auth/index.ts: -------------------------------------------------------------------------------- 1 | export * from './authConfiguration' 2 | export * from './authConstants' 3 | export * from './authProvider' 4 | export * from './msalTokenProvider' 5 | export * from './request' 6 | export * from './msalTokenCredential' 7 | export * from './msalConnectionManager' 8 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/oauth/customUserTokenAPI.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | export const getTokenServiceEndpoint = (): string => { 4 | return process.env.TOKEN_SERVICE_ENDPOINT ?? 'https://api.botframework.com' 5 | } 6 | -------------------------------------------------------------------------------- /.github/scripts/updatelock.sh: -------------------------------------------------------------------------------- 1 | rm -rf node_modules/ 2 | rm package-lock.json 3 | npm install 4 | 5 | cp package-lock.json package-lock.json.bak 6 | jq 'walk(if type == "object" and .link != true then del(.resolved, .integrity) else . end)' package-lock.json.bak > package-lock.json 7 | rm package-lock.json.bak -------------------------------------------------------------------------------- /test-agents/root-agent/src/state.ts: -------------------------------------------------------------------------------- 1 | import { ConversationReference } from '@microsoft/agents-activity' 2 | 3 | export interface ConversationData { 4 | nameRequested: boolean 5 | conversationReference: ConversationReference 6 | } 7 | 8 | export interface UserProfile { 9 | name?: string 10 | } 11 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/tokenResponseEventName.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * The event name used for token response activities. 8 | */ 9 | export const tokenResponseEventName = 'tokens/response' 10 | -------------------------------------------------------------------------------- /test-agents/web-chat/README.md: -------------------------------------------------------------------------------- 1 | # web-chat agent 2 | 3 | Agent to validate features available in all channels, primary for WebChat. 4 | 5 | There are different agents in the same project: AdaptiveCardAgent, cardFactoryAgent, cardMessages, MultiFeatureAgent, webChatSSOAgent Configure which one to use with the agentName variable in the .env file -------------------------------------------------------------------------------- /packages/agents-hosting-dialogs/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDirs": [ "src/", "test/"], 5 | "outDir": "dist", 6 | "paths": { 7 | "@microsoft/*": ["./packages/*"] 8 | }, 9 | "noImplicitAny": false, 10 | "strictNullChecks": false 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/cards/fact.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Represents a Fact. 8 | */ 9 | export interface Fact { 10 | /** The key of the fact. */ 11 | key: string; 12 | /** The value of the fact. */ 13 | value: string; 14 | } 15 | -------------------------------------------------------------------------------- /test-agents/custom-dialogs/README.md: -------------------------------------------------------------------------------- 1 | # Custom Dialogs 2 | 3 | This agent shows how to sub-class the `Dialog` class to create different agent control mechanism like simple slot filling. 4 | 5 | BotFramework provides a built-in base class called `Dialog`. By subclassing `Dialog`, developers can create new ways to define and control dialog flows used by the agent. 6 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/connector-client/index.ts: -------------------------------------------------------------------------------- 1 | export * from './attachmentData' 2 | export * from './attachmentInfo' 3 | export * from './attachmentView' 4 | export * from './connectorClient' 5 | export * from './conversationMembers' 6 | export * from './conversationResourceResponse' 7 | export * from './conversationsResult' 8 | export * from './resourceResponse' 9 | -------------------------------------------------------------------------------- /packages/agents-hosting/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": [ 4 | "src/**/*", 5 | "package.json" 6 | ], 7 | "compilerOptions": { 8 | "rootDirs": [ "src/", "test/"], 9 | "outDir": "dist", 10 | "paths": { 11 | "@microsoft/*": ["./packages/*"] 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test-agents/multi-turn-prompt/README.md: -------------------------------------------------------------------------------- 1 | # Multi-turn prompt 2 | 3 | This Agent has been created to show how to use the prompts classes included in `agents-hosting`. This agent will ask for the user's name and age, then store the responses. It demonstrates a multi-turn dialog flow using a text prompt, a number prompt, and state accessors to store and retrieve values. 4 | -------------------------------------------------------------------------------- /packages/agents-copilotstudio-client/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": [ 4 | "src/**/*", 5 | "package.json" 6 | ], 7 | "compilerOptions": { 8 | "rootDirs": [ "src/", "test/"], 9 | "outDir": "dist", 10 | "paths": { 11 | "@microsoft/*": ["./packages/*"] 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/agents-hosting-express/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": [ 4 | "src/**/*", 5 | "package.json" 6 | ], 7 | "compilerOptions": { 8 | "rootDirs": [ 9 | "src/" 10 | ], 11 | "outDir": "dist", 12 | "paths": { 13 | "@microsoft/*": [ 14 | "./packages/*" 15 | ] 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /packages/agents-hosting-dialogs/vendor/cldr-data/README.md: -------------------------------------------------------------------------------- 1 | All content in this directory (with the exception of this README.md) is derived from the [cldr-data](https://www.npmjs.com/package/cldr-data) package. 2 | 3 | See the [NOTICE](../../NOTICE) file for further attribution details. 4 | 5 | We are bundling a subset of the output of this dependency to reduce the install time and size. 6 | -------------------------------------------------------------------------------- /packages/agents-hosting-storage-blob/src/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | export * from './blobsStorage' 5 | export { BlobsTranscriptStore } from './blobsTranscriptStore' 6 | export { BlobsTranscriptStoreOptions } from './blobsTranscriptStore' 7 | export { Errors as BlobStorageErrors } from './errorHelper' 8 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/connector-client/resourceResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Represents a response containing a resource ID. 8 | */ 9 | export interface ResourceResponse { 10 | /** 11 | * Unique identifier of the resource. 12 | */ 13 | id: string; 14 | } 15 | -------------------------------------------------------------------------------- /packages/agents-activity/src/entity/thing.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Represents a Thing entity. 8 | */ 9 | export interface Thing { 10 | /** 11 | * The type of the thing. 12 | */ 13 | type: string 14 | /** 15 | * The name of the thing. 16 | */ 17 | name: string 18 | } 19 | -------------------------------------------------------------------------------- /packages/agents-copilotstudio-client/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './agentType.js' 2 | export * from './connectionSettings.js' 3 | export * from './copilotStudioClient.js' 4 | export * from './copilotStudioConnectionSettings.js' 5 | export * from './copilotStudioWebChat.js' 6 | export * from './executeTurnRequest.js' 7 | export * from './powerPlatformCloud.js' 8 | export * from './powerPlatformEnvironment.js' 9 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/meeting/meetingNotification.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { TargetedMeetingNotification } from './targetedMeetingNotification' 7 | 8 | /** 9 | * Represents a meeting notification. 10 | */ 11 | export type MeetingNotification = TargetedMeetingNotification 12 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/cards/mediaUrl.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Represents a media URL. 8 | */ 9 | export interface MediaUrl { 10 | /** 11 | * The URL of the media. 12 | */ 13 | url: string; 14 | /** 15 | * The profile of the media. 16 | */ 17 | profile?: string; 18 | } 19 | -------------------------------------------------------------------------------- /test-agents/agentic-ai/env.TEMPLATE: -------------------------------------------------------------------------------- 1 | # rename to .env 2 | 3 | connections__serviceConnection__settings__clientId= 4 | connections__serviceConnection__settings__clientSecret= 5 | connections__serviceConnection__settings__tenantId= 6 | 7 | connectionsMap__0__connection=serviceConnection 8 | connectionsMap__0__serviceUrl=* 9 | 10 | agentic_type=agentic 11 | agentic_scopes=https://graph.microsoft.com/.default 12 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/invoke/searchInvokeResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { AdaptiveCardInvokeResponse } from './adaptiveCardInvokeResponse' 7 | 8 | /** 9 | * Represents the response of a search invoke request. 10 | */ 11 | export interface SearchInvokeResponse extends AdaptiveCardInvokeResponse {} 12 | -------------------------------------------------------------------------------- /packages/agents-hosting-storage-cosmos/src/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | export { CosmosDbPartitionedStorage } from './cosmosDbPartitionedStorage' 5 | export * from './cosmosDbPartitionedStorageOptions' 6 | export { Errors } from './errorHelper' 7 | export { AgentErrorDefinition, AgentError, ExceptionHelper } from '@microsoft/agents-activity' 8 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/taskModule/taskModuleRequestContext.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Interface representing the context of a task module request. 8 | */ 9 | export interface TaskModuleRequestContext { 10 | /** 11 | * The theme of the task module request. 12 | */ 13 | theme?: string 14 | } 15 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/cards/thumbnailUrl.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Represents a thumbnail URL. 8 | */ 9 | export interface ThumbnailUrl { 10 | /** 11 | * The URL of the thumbnail. 12 | */ 13 | url: string; 14 | /** 15 | * The alternative text for the thumbnail. 16 | */ 17 | alt?: string; 18 | } 19 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/invoke/index.ts: -------------------------------------------------------------------------------- 1 | export * from './adaptiveCardAuthentication' 2 | export * from './adaptiveCardInvokeResponse' 3 | export * from './adaptiveCardInvokeValue' 4 | export * from './invokeException' 5 | export * from './invokeResponse' 6 | export * from './searchInvokeOptions' 7 | export * from './searchInvokeResponse' 8 | export * from './searchInvokeValue' 9 | export * from './tokenExchangeInvokeRequest' 10 | -------------------------------------------------------------------------------- /packages/agents-hosting/test/cases/scenarios.md: -------------------------------------------------------------------------------- 1 | # Authentication Scenarios 2 | 3 | This document serves as an index for authentication test scenarios. Each scenario covers a different bot configuration or platform. Click the links below to view detailed steps for each case: 4 | 5 | ## Test Cases Index 6 | 7 | - Authentication 8 | - [Web Chat](./authentication/webchat.md) 9 | - [Microsoft Teams](./authentication/msteams.md) 10 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/connector-client/attachmentView.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Represents a view of an attachment. 8 | */ 9 | export interface AttachmentView { 10 | /** 11 | * The ID of the view. 12 | */ 13 | viewId: string; 14 | /** 15 | * The size of the view. 16 | */ 17 | size: number; 18 | } 19 | -------------------------------------------------------------------------------- /packages/agents-hosting-dialogs/src/choices/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | export * from './choice' 6 | export * from './choiceFactory' 7 | export * from './findChoices' 8 | export { FindValuesOptions } from './findValues' 9 | export { FoundValue } from './findValues' 10 | export * from './modelResult' 11 | export * from './recognizeChoices' 12 | -------------------------------------------------------------------------------- /packages/agents-activity/src/expectedReplies.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { Activity } from './activity' 7 | 8 | /** 9 | * Represents expected replies in a conversation. 10 | */ 11 | export interface ExpectedReplies { 12 | /** 13 | * List of activities representing the expected replies. 14 | */ 15 | activities: Activity[] 16 | } 17 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/app/turnEvents.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Represents the types of events that can occur during a turn in the application. 8 | * 9 | * - `beforeTurn`: Triggered before the turn starts. 10 | * - `afterTurn`: Triggered after the turn ends. 11 | */ 12 | export type TurnEvents = 'beforeTurn' | 'afterTurn' 13 | -------------------------------------------------------------------------------- /packages/agents-copilotstudio-client/src/agentType.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Enum representing the type of agent. 8 | */ 9 | export enum AgentType { 10 | /** 11 | * Represents a published agent. 12 | */ 13 | Published = 'Published', 14 | /** 15 | * Represents a prebuilt agent. 16 | */ 17 | Prebuilt = 'Prebuilt', 18 | } 19 | -------------------------------------------------------------------------------- /packages/agents-hosting-dialogs/src/prompts/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | export * from './activityPrompt' 6 | export * from './attachmentPrompt' 7 | export * from './choicePrompt' 8 | export * from './confirmPrompt' 9 | export * from './datetimePrompt' 10 | export * from './numberPrompt' 11 | export * from './prompt' 12 | export * from './textPrompt' 13 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/cards/o365ConnectorCardFact.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Represents a fact in an O365 connector card. 8 | */ 9 | export interface O365ConnectorCardFact { 10 | /** 11 | * The name of the fact. 12 | */ 13 | name?: string; 14 | /** 15 | * The value of the fact. 16 | */ 17 | value?: string; 18 | } 19 | -------------------------------------------------------------------------------- /packages/agents-hosting-dialogs/src/memory/pathResolvers/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | export * from './aliasPathResolver' 6 | export * from './atAtPathResolver' 7 | export * from './atPathResolver' 8 | export * from './dollarPathResolver' 9 | export * from './hashPathResolver' 10 | export * from './pathResolver' 11 | export * from './percentPathResolver' 12 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/cards/o365ConnectorCardImage.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Represents an image in an O365 connector card. 8 | */ 9 | export interface O365ConnectorCardImage { 10 | /** 11 | * The URL of the image. 12 | */ 13 | image?: string; 14 | /** 15 | * The title of the image. 16 | */ 17 | title?: string; 18 | } 19 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.codeActionsOnSave": { 3 | "source.fixAll.eslint": "explicit" 4 | }, 5 | "nodejs-testing.extensions": [ 6 | { 7 | "extensions": [ 8 | "ts" 9 | ], 10 | "parameters": [ 11 | "--import", 12 | "tsx" 13 | ] 14 | } 15 | ], 16 | "nodejs-testing.include": [ 17 | "packages/*/test/" 18 | ] 19 | } -------------------------------------------------------------------------------- /packages/agents-hosting/src/invoke/invokeResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Represents the response of an invoke request. 8 | */ 9 | export interface InvokeResponse { 10 | /** 11 | * The status code of the response. 12 | */ 13 | status: number 14 | /** 15 | * The optional body of the response. 16 | */ 17 | body?: T 18 | } 19 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/invoke/searchInvokeOptions.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Represents the options for a search invoke request. 8 | */ 9 | export interface SearchInvokeOptions { 10 | /** 11 | * The number of items to skip. 12 | */ 13 | skip: number 14 | /** 15 | * The number of items to retrieve. 16 | */ 17 | top: number 18 | } 19 | -------------------------------------------------------------------------------- /typedoc.json: -------------------------------------------------------------------------------- 1 | { 2 | "entryPointStrategy": "packages", 3 | "entryPoints": ["packages/*"], 4 | "packageOptions": { 5 | "entryPoints": ["src/index.ts"] 6 | }, 7 | "out": "docs", 8 | "exclude": ["**/node_modules/**", "**/test/**"], 9 | "excludeExternals": true, 10 | "excludePrivate": true, 11 | "excludeProtected": false, 12 | "excludeNotDocumented": false, 13 | "includeVersion": true, 14 | "readme": "README.md", 15 | } -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/meeting/meetingEventDetails.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { MeetingDetailsBase } from './meetingDetailsBase' 7 | 8 | /** 9 | * Interface representing the details of a meeting event. 10 | */ 11 | export interface MeetingEventDetails extends MeetingDetailsBase { 12 | /** The type of the meeting. */ 13 | meetingType: string 14 | } 15 | -------------------------------------------------------------------------------- /version.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json", 3 | "version": "1.2.0-alpha.{height}", 4 | "publicReleaseRefSpec": [ 5 | "^refs/heads/main$", 6 | "^refs/heads/release/v\\d+\\.\\d+", 7 | "^refs/heads/prerelease/v\\d+\\.\\d+", 8 | "^refs/tags/v\\d+\\.\\d+" 9 | ], 10 | "cloudBuild": { 11 | "buildNumber": { 12 | "enabled": true 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Microsoft Open Source Code of Conduct 2 | 3 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 4 | 5 | Resources: 6 | 7 | - [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) 8 | - [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) 9 | - Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns 10 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/meeting/meetingEndEventDetails.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { MeetingEventDetails } from './meetingEventDetails' 7 | 8 | /** 9 | * Interface representing the details of a meeting end event. 10 | */ 11 | export interface MeetingEndEventDetails extends MeetingEventDetails { 12 | /** The end time of the meeting. */ 13 | endTime: Date 14 | } 15 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/taskModule/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | export * from './taskModuleContinueResponse' 7 | export * from './taskModuleMessageResponse' 8 | export * from './taskModuleRequest' 9 | export * from './taskModuleRequestContext' 10 | export * from './taskModuleResponse' 11 | export * from './taskModuleResponseBase' 12 | export * from './taskModuleTaskInfo' 13 | -------------------------------------------------------------------------------- /test-agents/application-style/env.TEMPLATE: -------------------------------------------------------------------------------- 1 | # rename to .env 2 | tenantId= 3 | clientId= 4 | clientSecret=ssshhhhhhhhhhhh 5 | BLOB_STORAGE_CONNECTION_STRING= 6 | BLOB_CONTAINER_ID= 7 | COSMOS_ENDPOINT= # e.g., https://your-account.documents.azure.com:443/ 8 | COSMOS_KEY= # Primary or Secondary key from Azure Portal 9 | COSMOS_DATABASE_ID= # database name 10 | COSMOS_CONTAINER_ID= # container name 11 | agentName= -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "incremental": true, 4 | "lib": ["ES2022"], 5 | "target": "es2019", 6 | "module": "node16", 7 | "declaration": true, 8 | "sourceMap": true, 9 | "composite": true, 10 | "strict": true, 11 | "moduleResolution": "node16", 12 | "esModuleInterop": true, 13 | "skipLibCheck": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "resolveJsonModule": true 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/cards/signinCard.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | import { CardAction } from '@microsoft/agents-activity' 5 | 6 | /** 7 | * Represents a sign-in card. 8 | */ 9 | export interface SigninCard { 10 | /** 11 | * The text to display on the sign-in card. 12 | */ 13 | text?: string 14 | /** 15 | * The buttons to include on the sign-in card. 16 | */ 17 | buttons: CardAction[] 18 | } 19 | -------------------------------------------------------------------------------- /packages/agents-hosting-dialogs/src/memory/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | export { ComponentMemoryScopes } from './componentMemoryScopes' 6 | export { ComponentPathResolvers } from './componentPathResolvers' 7 | export * from './dialogPath' 8 | export * from './dialogStateManager' 9 | export * from './pathResolvers' 10 | export * from './scopePath' 11 | export * from './scopes' 12 | export * from './turnPath' 13 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/messageExtension/messagingExtensionSuggestedAction.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { CardAction } from '@microsoft/agents-activity' 7 | 8 | /** 9 | * Represents suggested actions for a messaging extension. 10 | */ 11 | export interface MessagingExtensionSuggestedAction { 12 | /** 13 | * A list of card actions. 14 | */ 15 | actions?: CardAction[] 16 | } 17 | -------------------------------------------------------------------------------- /packages/agents-hosting-dialogs/src/intentScore.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | /** 6 | * Score plus any extra information about an intent. 7 | */ 8 | export interface IntentScore { 9 | /** 10 | * Optional. The confidence score of the intent, ranging from 0.0 to 1.0. 11 | */ 12 | score?: number 13 | 14 | /** 15 | * Additional properties related to the intent. 16 | */ 17 | [key: string]: unknown 18 | } 19 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/meeting/meetingDetailsBase.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Interface representing the base details of a meeting. 8 | */ 9 | export interface MeetingDetailsBase { 10 | /** The unique identifier of the meeting. */ 11 | id: string 12 | /** The URL to join the meeting. */ 13 | joinUrl: string 14 | /** The title of the meeting. */ 15 | title: string 16 | } 17 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/meeting/meetingStartEventDetails.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { MeetingEventDetails } from './meetingEventDetails' 7 | 8 | /** 9 | * Interface representing the details of a meeting start event. 10 | */ 11 | export interface MeetingStartEventDetails extends MeetingEventDetails { 12 | /** 13 | * The start time of the meeting. 14 | */ 15 | startTime: Date 16 | } 17 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/meeting/meetingTabIconSurface.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Interface representing a meeting tab icon surface. 8 | */ 9 | export interface MeetingTabIconSurface { 10 | /** 11 | * The type of surface. 12 | */ 13 | surface: 'meetingTabIcon'; 14 | 15 | /** 16 | * The tab entity ID associated with the surface. 17 | */ 18 | tabEntityId?: string; 19 | } 20 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/messageExtension/messagingExtensionAttachment.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { Attachment } from '@microsoft/agents-activity' 7 | 8 | /** 9 | * Represents an attachment for a messaging extension. 10 | */ 11 | export interface MessagingExtensionAttachment extends Attachment { 12 | /** 13 | * A preview of the attachment. 14 | */ 15 | preview?: Attachment 16 | } 17 | -------------------------------------------------------------------------------- /test-agents/state-agent/env.TEMPLATE: -------------------------------------------------------------------------------- 1 | # rename to .env 2 | tenantId=0000000000000000000 3 | clientId=0000000000000000000 4 | clientSecret=ssshhhhhhhhhhhh 5 | BLOB_STORAGE_CONNECTION_STRING= 6 | BLOB_CONTAINER_ID= 7 | COSMOS_ENDPOINT= # e.g., https://your-account.documents.azure.com:443/ 8 | COSMOS_KEY= # Primary or Secondary key from Azure Portal 9 | COSMOS_DATABASE_ID= # database name 10 | COSMOS_CONTAINER_ID= # container name 11 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/meeting/meetingParticipantsEventDetails.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { TeamsMeetingMember } from './teamsMeetingMember' 7 | 8 | /** 9 | * Interface representing the details of a meeting participants event. 10 | */ 11 | export interface MeetingParticipantsEventDetails { 12 | /** The list of members participating in the meeting. */ 13 | members: TeamsMeetingMember[] 14 | } 15 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/meeting/userMeetingDetails.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Interface representing the details of a user's meeting. 8 | */ 9 | export interface UserMeetingDetails { 10 | /** 11 | * Indicates if the user is currently in a meeting. 12 | */ 13 | inMeeting: boolean; 14 | 15 | /** 16 | * The role of the user in the meeting. 17 | */ 18 | role: string; 19 | } 20 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/messageExtension/appBasedLinkQuery.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Represents a query for an app-based link. 8 | */ 9 | export interface AppBasedLinkQuery { 10 | /** 11 | * The URL of the link. 12 | * @type {string} 13 | */ 14 | url?: string 15 | /** 16 | * The state associated with the link. 17 | * @type {string} 18 | */ 19 | state?: string 20 | } 21 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/meeting/meetingNotificationBase.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Interface representing the base structure of a meeting notification. 8 | * @template T - The type of the value. 9 | */ 10 | export interface MeetingNotificationBase { 11 | /** The type of the notification. */ 12 | type: string; 13 | /** The value associated with the notification. */ 14 | value: T; 15 | } 16 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/meeting/meetingSurface.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { MeetingStageSurface } from './meetingStageSurface' 7 | import { MeetingTabIconSurface } from './meetingTabIconSurface' 8 | 9 | /** 10 | * Type representing a meeting surface, which can be either a stage surface or a tab icon surface. 11 | */ 12 | export type MeetingSurface = MeetingStageSurface | MeetingTabIconSurface 13 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/cards/cardImage.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { CardAction } from '@microsoft/agents-activity' 7 | 8 | /** 9 | * Represents a Card Image. 10 | */ 11 | export interface CardImage { 12 | /** The URL of the image. */ 13 | url: string 14 | /** The alternative text for the image. */ 15 | alt?: string 16 | /** The action to be performed when the image is tapped. */ 17 | tap?: CardAction 18 | } 19 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './activity-extensions' 2 | export * from './client' 3 | export * from './compat/teamsActivityHandler' 4 | export { Errors as TeamsExtensionErrors } from './errorHelper' 5 | export * from './feedbackLoopData' 6 | export * from './meeting' 7 | export * from './meeting/meeting' 8 | export * from './messageExtension' 9 | export * from './taskModule' 10 | export * from './teamsAgentExtension' 11 | export * from './teamsAttachmentDownloader' 12 | export * from './teamsInfo' 13 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/meeting/meetingNotificationChannelData.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { OnBehalfOf } from '../activity-extensions/onBehalfOf' 7 | 8 | /** 9 | * Interface representing the channel data for a meeting notification. 10 | */ 11 | export interface MeetingNotificationChannelData { 12 | /** Optional list of entities on behalf of whom the notification is sent. */ 13 | onBehalfOf?: OnBehalfOf[]; 14 | } 15 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/app/conversationUpdateEvents.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Represents the types of conversation update events that can occur. 8 | * 9 | * - `membersAdded`: Triggered when new members are added to the conversation. 10 | * - `membersRemoved`: Triggered when members are removed from the conversation. 11 | */ 12 | export type ConversationUpdateEvents = 13 | | 'membersAdded' 14 | | 'membersRemoved' 15 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/taskModule/taskModuleMessageResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { TaskModuleResponseBase } from './taskModuleResponseBase' 7 | 8 | /** 9 | * Interface representing the message response of a task module. 10 | */ 11 | export interface TaskModuleMessageResponse extends TaskModuleResponseBase { 12 | /** 13 | * The value of the task module message response. 14 | */ 15 | value?: string 16 | } 17 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/getProductInfo.ts: -------------------------------------------------------------------------------- 1 | import { version } from '../package.json' 2 | import os from 'os' 3 | 4 | /** 5 | * Generates a string containing information about the SDK version and runtime environment. 6 | * This is used for telemetry and User-Agent headers in HTTP requests. 7 | * 8 | * @returns A formatted string containing the SDK version, Node.js version, and OS details 9 | */ 10 | export const getProductInfo = () : string => `agents-sdk-js/${version} nodejs/${process.version} ${os.platform()}-${os.arch()}/${os.release()}` 11 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/connector-client/conversationMembers.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { ChannelAccount } from '@microsoft/agents-activity' 7 | 8 | /** 9 | * Represents the members of a conversation. 10 | */ 11 | export interface ConversationMembers { 12 | /** 13 | * The ID of the conversation. 14 | */ 15 | id: string; 16 | /** 17 | * The list of members in the conversation. 18 | */ 19 | members: ChannelAccount[]; 20 | } 21 | -------------------------------------------------------------------------------- /test-agents/multi-turn-prompt/src/userProfile.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | import { Attachment } from '@microsoft/agents-activity' 5 | 6 | export class UserProfile { 7 | constructor ( 8 | public transport: string = '', 9 | public name: string = '', 10 | public age: number = 0, 11 | public picture?: Attachment 12 | ) { 13 | this.transport = transport 14 | this.name = name 15 | this.age = age 16 | this.picture = picture 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/invoke/tokenExchangeInvokeRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Represents a token exchange invoke request. 8 | */ 9 | export interface TokenExchangeInvokeRequest { 10 | /** 11 | * The unique identifier for the request. 12 | */ 13 | id: string 14 | /** 15 | * The name of the connection. 16 | */ 17 | connectionName: string 18 | /** 19 | * The token to be exchanged. 20 | */ 21 | token: string 22 | } 23 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/taskModule/taskModuleResponseBase.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Type representing the message preview type. 8 | */ 9 | export type MessagePreviewType = 'message' | 'continue' 10 | 11 | /** 12 | * Interface representing the base response of a task module. 13 | */ 14 | export interface TaskModuleResponseBase { 15 | /** 16 | * The type of the message preview. 17 | */ 18 | type?: MessagePreviewType 19 | } 20 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/teamsAttachmentDownloader.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { TeamsAttachmentDownloader as AppTeamsAttachmentDownloader } from '@microsoft/agents-hosting' 7 | 8 | /** 9 | * @deprecated Use {@link TeamsAttachmentDownloader} from @microsoft/agents-hosting instead. 10 | * Downloads attachments from Teams using the bots access token. 11 | */ 12 | export class TeamsAttachmentDownloader extends AppTeamsAttachmentDownloader { 13 | } 14 | -------------------------------------------------------------------------------- /packages/agents-activity/src/entity/mention.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { ChannelAccount } from '../conversation/channelAccount' 7 | 8 | /** 9 | * Represents a Mention entity. 10 | */ 11 | export interface Mention { 12 | /** 13 | * The account that is mentioned. 14 | */ 15 | mentioned: ChannelAccount 16 | /** 17 | * The text of the mention. 18 | */ 19 | text: string 20 | /** 21 | * The type of the mention. 22 | */ 23 | type: string 24 | } 25 | -------------------------------------------------------------------------------- /packages/agents-hosting-express/README.md: -------------------------------------------------------------------------------- 1 | # microsoft/agents-hosting-express 2 | 3 | ## Overview 4 | 5 | Provides integration to host the agent in Express using `startServer` 6 | 7 | ## Usage 8 | 9 | ```ts 10 | import { AgentApplication, TurnState } from '@microsoft/agents-hosting'; 11 | import { startServer } from '@microsoft/agents-hosting-express'; 12 | 13 | const app = new AgentApplication(); 14 | app.onMessage('hello', async (context, state) => { 15 | await context.sendActivity('Hello, world!'); 16 | }); 17 | startServer(app); 18 | ``` -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/activity-extensions/tenantInfo.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { z } from 'zod' 7 | 8 | /** 9 | * Represents information about a tenant. 10 | */ 11 | export interface TenantInfo { 12 | /** 13 | * The ID of the tenant. 14 | */ 15 | id?: string 16 | } 17 | 18 | /** 19 | * Zod schema for validating TenantInfo objects. 20 | */ 21 | export const tenantInfoZodSchema = z.object({ 22 | id: z.string().min(1).optional() 23 | }) 24 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/connector-client/conversationResourceResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Represents the response from a conversation resource operation. 8 | */ 9 | export interface ConversationResourceResponse { 10 | /** 11 | * The ID of the activity. 12 | */ 13 | activityId: string; 14 | /** 15 | * The service URL. 16 | */ 17 | serviceUrl: string; 18 | /** 19 | * The ID of the conversation resource. 20 | */ 21 | id: string; 22 | } 23 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/invoke/adaptiveCardInvokeResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Represents the response of an adaptive card invoke request. 8 | */ 9 | export interface AdaptiveCardInvokeResponse { 10 | /** 11 | * The status code of the response. 12 | */ 13 | statusCode: number 14 | /** 15 | * The type of the response. 16 | */ 17 | type: string 18 | /** 19 | * The value of the response. 20 | */ 21 | value: Record 22 | } 23 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/connector-client/conversationsResult.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { ConversationMembers } from './conversationMembers' 7 | 8 | /** 9 | * Represents the result of a conversation query. 10 | */ 11 | export interface ConversationsResult { 12 | /** 13 | * A token to retrieve the next page of results. 14 | */ 15 | continuationToken: string; 16 | /** 17 | * A list of conversation members. 18 | */ 19 | conversations: ConversationMembers[]; 20 | } 21 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/invoke/adaptiveCardAuthentication.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { TokenExchangeInvokeRequest } from './tokenExchangeInvokeRequest' 7 | 8 | /** 9 | * Represents the authentication information for an adaptive card. 10 | */ 11 | export interface AdaptiveCardAuthentication extends TokenExchangeInvokeRequest { 12 | // No-op. This interface was accidentally created as a duplicate of TokenExchangeInvokeRequest but must remain for backwards-compatibility. 13 | } 14 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/connector-client/attachmentInfo.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { AttachmentView } from './attachmentView' 7 | 8 | /** 9 | * Represents information about an attachment. 10 | */ 11 | export interface AttachmentInfo { 12 | /** 13 | * The name of the attachment. 14 | */ 15 | name: string; 16 | /** 17 | * The type of the attachment. 18 | */ 19 | type: string; 20 | /** 21 | * The views of the attachment. 22 | */ 23 | views: AttachmentView[]; 24 | } 25 | -------------------------------------------------------------------------------- /samples/_resources/SuggestedActions.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", 3 | "type": "AdaptiveCard", 4 | "version": "1.0", 5 | "body": [ 6 | { 7 | "type": "TextBlock", 8 | "text": "**Welcome to the Multi Feature sample**" 9 | }, 10 | { 11 | "type": "TextBlock", 12 | "text": "Please choose wich feature you would like to try out" 13 | }, 14 | { 15 | "type": "TextBlock", 16 | "text": "- Adaptive Card \r- Card Factory \r - State \r - SSO \r - Attachments", 17 | "wrap": true 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /packages/agents-activity/src/callerIdConstants.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Constants representing caller IDs. 8 | */ 9 | export const CallerIdConstants = { 10 | /** 11 | * Public Azure channel caller ID. 12 | */ 13 | PublicAzureChannel: 'urn:botframework:azure', 14 | /** 15 | * US Government channel caller ID. 16 | */ 17 | USGovChannel: 'urn:botframework:azureusgov', 18 | /** 19 | * Agent prefix for caller ID. 20 | */ 21 | AgentPrefix: 'urn:botframework:aadappid:' 22 | } 23 | -------------------------------------------------------------------------------- /packages/agents-copilotstudio-client/src/strategies/strategy.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | export interface Strategy { 7 | getConversationUrl(conversationId?: string): string; 8 | } 9 | 10 | /** 11 | * Settings required to configure the Strategy. 12 | */ 13 | export interface StrategySettings { 14 | /** 15 | * The host URL of the Copilot Studio service. 16 | */ 17 | readonly host: URL; 18 | 19 | /** 20 | * The schema identifier for the agent. 21 | */ 22 | readonly schema: string; 23 | } 24 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/activity-extensions/teamsMeetingInfo.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { z } from 'zod' 7 | 8 | /** 9 | * Represents information about a Teams meeting. 10 | */ 11 | export interface TeamsMeetingInfo { 12 | /** 13 | * The ID of the meeting. 14 | */ 15 | id?: string 16 | } 17 | 18 | /** 19 | * Zod schema for validating TeamsMeetingInfo objects. 20 | */ 21 | export const teamsMeetingInfoZodSchema = z.object({ 22 | id: z.string().min(1).optional() 23 | }) 24 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/meeting/meetingNotificationResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { MeetingNotificationRecipientFailureInfo } from './meetingNotificationRecipientFailureInfo' 7 | 8 | /** 9 | * Represents a response to a meeting notification. 10 | */ 11 | export interface MeetingNotificationResponse { 12 | /** 13 | * Information about recipients who failed to receive the notification. 14 | */ 15 | recipientsFailureInfo?: MeetingNotificationRecipientFailureInfo[]; 16 | } 17 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/meeting/meetingStageSurface.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Interface representing the surface of a meeting stage. 8 | * @template T - The type of the content. 9 | */ 10 | export interface MeetingStageSurface { 11 | /** The surface type, which is always 'meetingStage'. */ 12 | surface: 'meetingStage'; 13 | /** The content type, which is always 'task'. */ 14 | contentType: 'task'; 15 | /** The content of the meeting stage. */ 16 | content: T; 17 | } 18 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/taskModule/taskModuleContinueResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { TaskModuleResponseBase } from './taskModuleResponseBase' 7 | import { TaskModuleTaskInfo } from './taskModuleTaskInfo' 8 | 9 | /** 10 | * Interface representing the continue response of a task module. 11 | */ 12 | export interface TaskModuleContinueResponse extends TaskModuleResponseBase { 13 | /** 14 | * The task module task information. 15 | */ 16 | value?: TaskModuleTaskInfo 17 | } 18 | -------------------------------------------------------------------------------- /test-agents/web-chat/cards/SuggestedActions.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", 3 | "type": "AdaptiveCard", 4 | "version": "1.0", 5 | "body": [ 6 | { 7 | "type": "TextBlock", 8 | "text": "**Welcome to the Multi Feature sample**" 9 | }, 10 | { 11 | "type": "TextBlock", 12 | "text": "Please choose wich feature you would like to try out" 13 | }, 14 | { 15 | "type": "TextBlock", 16 | "text": "- Adaptive Card \r- Card Factory \r - State \r - SSO \r - Attachments", 17 | "wrap": true 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /test-agents/web-chat/resources/SuggestedActions.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", 3 | "type": "AdaptiveCard", 4 | "version": "1.0", 5 | "body": [ 6 | { 7 | "type": "TextBlock", 8 | "text": "**Welcome to the Multi Feature sample**" 9 | }, 10 | { 11 | "type": "TextBlock", 12 | "text": "Please choose wich feature you would like to try out" 13 | }, 14 | { 15 | "type": "TextBlock", 16 | "text": "- Adaptive Card \r- Card Factory \r - State \r - SSO \r - Attachments", 17 | "wrap": true 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /packages/agents-hosting-dialogs/src/memory/scopes/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | export * from './agentStateMemoryScope' 6 | export * from './classMemoryScope' 7 | export * from './conversationMemoryScope' 8 | export * from './dialogClassMemoryScope' 9 | export * from './dialogContextMemoryScope' 10 | export * from './dialogMemoryScope' 11 | export * from './memoryScope' 12 | export * from './settingsMemoryScope' 13 | export * from './thisMemoryScope' 14 | export * from './turnMemoryScope' 15 | export * from './userMemoryScope' 16 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for more information: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | # https://containers.dev/guide/dependabot 6 | 7 | version: 2 8 | updates: 9 | - package-ecosystem: "devcontainers" 10 | directory: "/" 11 | schedule: 12 | interval: weekly 13 | - package-ecosystem: "npm" 14 | directory: "/" 15 | schedule: 16 | interval: daily 17 | -------------------------------------------------------------------------------- /packages/agents-activity/src/entity/entity.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { z } from 'zod' 7 | 8 | /** 9 | * Represents a generic Entity. 10 | */ 11 | export interface Entity { 12 | /** 13 | * The type of the entity. 14 | */ 15 | type: string 16 | /** 17 | * Additional properties of the entity. 18 | */ 19 | [key: string]: unknown 20 | } 21 | 22 | /** 23 | * Zod schema for validating Entity objects. 24 | */ 25 | export const entityZodSchema = z.object({ 26 | type: z.string().min(1) 27 | }).passthrough() 28 | -------------------------------------------------------------------------------- /packages/agents-hosting-dialogs/src/memory/scopes/userMemoryScope.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | import { AgentStateMemoryScope } from './agentStateMemoryScope' 6 | import { ScopePath } from '../scopePath' 7 | 8 | /** 9 | * Memory that's scoped to the current user. 10 | */ 11 | export class UserMemoryScope extends AgentStateMemoryScope { 12 | protected stateKey = 'UserState' 13 | /** 14 | * Initializes a new instance of the UserMemoryScope class. 15 | */ 16 | constructor () { 17 | super(ScopePath.user) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/cards/adaptiveCard.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Represents an Adaptive Card, which is a card framework that enables developers to exchange UI content in a common and consistent way. 8 | * 9 | * @remarks 10 | * @see {@link https://learn.microsoft.com/adaptive-cards/ | Adaptive Cards Documentation} 11 | */ 12 | export interface AdaptiveCard { 13 | /** 14 | * The type of the card, which must always be `AdaptiveCard`. 15 | */ 16 | type: 'AdaptiveCard' 17 | [key: string]: any 18 | } 19 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/meeting/meetingNotificationRecipientFailureInfo.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Interface representing the failure information of a meeting notification recipient. 8 | */ 9 | export interface MeetingNotificationRecipientFailureInfo { 10 | /** The recipient's MRI (Microsoft Resource Identifier). */ 11 | recipientMri: string; 12 | /** The reason for the failure. */ 13 | failureReason: string; 14 | /** The error code associated with the failure. */ 15 | errorCode: string; 16 | } 17 | -------------------------------------------------------------------------------- /packages/agents-hosting-dialogs/src/configuration.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | /** 5 | * Configuration is an interface that is used to obtain configurable values 6 | */ 7 | export interface Configuration { 8 | get(path?: string[]): T | undefined; 9 | set(path: string[], value: unknown): void; 10 | } 11 | 12 | /** 13 | * Useful for shimming Components into ComponentRegistrations 14 | */ 15 | export const noOpConfiguration: Configuration = { 16 | get (_path) { 17 | return undefined 18 | }, 19 | set (_path, _value) { 20 | // no-op 21 | }, 22 | } 23 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/activity-extensions/teamsChannelDataParser.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { TeamsChannelData, teamsChannelDataZodSchema } from './teamsChannelData' 7 | 8 | /** 9 | * Parses the given object as TeamsChannelData. 10 | * 11 | * @param {object} o - The object to parse. 12 | * @returns {TeamsChannelData} - The parsed TeamsChannelData. 13 | */ 14 | export function parseTeamsChannelData (o: object): TeamsChannelData { 15 | teamsChannelDataZodSchema.passthrough().parse(o) 16 | return o 17 | } 18 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/meeting/targetedMeetingNotificationValue.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { MeetingSurface } from './meetingSurface' 7 | 8 | /** 9 | * Interface representing the value of a targeted meeting notification. 10 | */ 11 | export interface TargetedMeetingNotificationValue { 12 | /** 13 | * The recipients of the notification. 14 | */ 15 | recipients: string[]; 16 | 17 | /** 18 | * The surfaces where the notification will be displayed. 19 | */ 20 | surfaces: MeetingSurface[]; 21 | } 22 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/message-actions-payload/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | export * from './messageActionsPayload' 7 | export * from './messageActionsPayloadApp' 8 | export * from './messageActionsPayloadAttachment' 9 | export * from './messageActionsPayloadBody' 10 | export * from './messageActionsPayloadConversation' 11 | export * from './messageActionsPayloadFrom' 12 | export * from './messageActionsPayloadMention' 13 | export * from './messageActionsPayloadReaction' 14 | export * from './messageActionsPayloadUser' 15 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/app/streaming/citation.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Citations returned by the model. 8 | */ 9 | export interface Citation { 10 | /** 11 | * The content of the citation. 12 | */ 13 | content: string; 14 | 15 | /** 16 | * The title of the citation. 17 | */ 18 | title: string | null; 19 | 20 | /** 21 | * The URL of the citation. 22 | */ 23 | url: string | null; 24 | 25 | /** 26 | * The filepath of the document. 27 | */ 28 | filepath: string | null; 29 | } 30 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/app/adaptiveCards/query.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Represents a query with pagination and parameters. 8 | * @typeParam TParams - The type of the query parameters. 9 | */ 10 | export interface Query> { 11 | /** 12 | * The number of items to retrieve. 13 | */ 14 | count: number; 15 | 16 | /** 17 | * The number of items to skip. 18 | */ 19 | skip: number; 20 | 21 | /** 22 | * The parameters for the query. 23 | */ 24 | parameters: TParams; 25 | } 26 | -------------------------------------------------------------------------------- /test-agents/custom-dialogs/src/dialogs/slotDetails.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | export class SlotDetails { 5 | public readonly options: object | string 6 | 7 | constructor (public name: string, public promptId: string, public prompt: string = '', public reprompt: string = '') { 8 | this.name = name 9 | this.promptId = promptId 10 | if (prompt.length > 0 && reprompt.length > 0) { 11 | this.options = { 12 | prompt, 13 | retryPrompt: reprompt 14 | } 15 | } else { 16 | this.options = prompt 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/agents-activity/README.md: -------------------------------------------------------------------------------- 1 | # @microsoft/agents-activity 2 | 3 | ## Overview 4 | 5 | The `@microsoft/agents-activity` implements the Activity Protocol Specification https://github.com/microsoft/Agents/blob/main/specs/activity/protocol-activity.md. 6 | 7 | It provides declaration files defined with TypeScript and validators based on `zod`. 8 | 9 | ## Installation 10 | 11 | To install the package, use npm: 12 | 13 | ```sh 14 | npm install @microsoft/agents-activity 15 | ``` 16 | 17 | ## Usage 18 | 19 | ```ts 20 | const activity = Activity.fromObject({ type: ActivityTypes.Message, text: 'Hello World' }) 21 | ``` 22 | 23 | -------------------------------------------------------------------------------- /packages/agents-activity/src/entity/place.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Represents a Place entity. 8 | */ 9 | export interface Place { 10 | /** 11 | * The address of the place. 12 | */ 13 | address: unknown 14 | /** 15 | * The geographical coordinates of the place. 16 | */ 17 | geo: unknown 18 | /** 19 | * A map that shows the place. 20 | */ 21 | hasMap: unknown 22 | /** 23 | * The type of the place. 24 | */ 25 | type: string 26 | /** 27 | * The name of the place. 28 | */ 29 | name: string 30 | } 31 | -------------------------------------------------------------------------------- /samples/_resources/PullRequestCard.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", 3 | "type": "AdaptiveCard", 4 | "version": "1.4", 5 | "body": [ 6 | { 7 | "type": "TextBlock", 8 | "text": "${title}", 9 | "weight": "Bolder", 10 | "size": "Medium" 11 | }, 12 | { 13 | "type": "TextBlock", 14 | "text": "${url}" 15 | } 16 | ], 17 | "actions": [ 18 | { 19 | "type": "Action.OpenUrl", 20 | "title": "View Pull Request", 21 | "url": "${url}" 22 | } 23 | ] 24 | } -------------------------------------------------------------------------------- /packages/agents-hosting-dialogs/src/template.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { DialogContext } from './dialogContext' 7 | 8 | /** 9 | * Defines Template interface for binding data to T. 10 | */ 11 | export interface TemplateInterface> { 12 | /** 13 | * Given the turn context bind to the data to create the object 14 | * 15 | * @param dialogContext DialogContext. 16 | * @param data Data to bind to. 17 | * @returns Instance of T. 18 | */ 19 | bind(dialogContext: DialogContext, data?: D): Promise; 20 | } 21 | -------------------------------------------------------------------------------- /packages/agents-activity/src/activityTreatments.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { z } from 'zod' 7 | 8 | /** 9 | * Enum representing treatment types for the activity. 10 | */ 11 | export enum ActivityTreatments { 12 | /** 13 | * Indicates that only the recipient should be able to see the message even if the activity 14 | * is being sent to a group of people. 15 | */ 16 | Targeted = 'targeted', 17 | } 18 | 19 | /** 20 | * Zod schema for validating an ActivityTreatments enum. 21 | */ 22 | export const activityTreatments = z.nativeEnum(ActivityTreatments) 23 | -------------------------------------------------------------------------------- /packages/agents-activity/src/textHighlight.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { z } from 'zod' 7 | 8 | /** 9 | * Represents a text highlight. 10 | */ 11 | export interface TextHighlight { 12 | /** 13 | * The highlighted text. 14 | */ 15 | text: string 16 | /** 17 | * The occurrence count of the highlighted text. 18 | */ 19 | occurrence: number 20 | } 21 | 22 | /** 23 | * Zod schema for validating TextHighlight objects. 24 | */ 25 | export const textHighlightZodSchema = z.object({ 26 | text: z.string().min(1), 27 | occurrence: z.number() 28 | }) 29 | -------------------------------------------------------------------------------- /packages/agents-hosting-dialogs/src/memory/scopes/conversationMemoryScope.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | import { AgentStateMemoryScope } from './agentStateMemoryScope' 6 | import { ScopePath } from '../scopePath' 7 | 8 | /** 9 | * Memory that's scoped to the current conversation. 10 | */ 11 | export class ConversationMemoryScope extends AgentStateMemoryScope { 12 | protected stateKey = 'ConversationState' 13 | /** 14 | * Initializes a new instance of the ConversationMemoryScope class. 15 | */ 16 | constructor () { 17 | super(ScopePath.conversation) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/meeting/teamsMeetingMember.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { TeamsChannelAccount } from '../activity-extensions/teamsChannelAccount' 7 | import { UserMeetingDetails } from './userMeetingDetails' 8 | 9 | /** 10 | * Interface representing a member of a Teams meeting. 11 | */ 12 | export interface TeamsMeetingMember { 13 | /** 14 | * The user who is a member of the meeting. 15 | */ 16 | user: TeamsChannelAccount; 17 | 18 | /** 19 | * The meeting details for the user. 20 | */ 21 | meeting: UserMeetingDetails; 22 | } 23 | -------------------------------------------------------------------------------- /packages/agents-activity/src/messageReactionTypes.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { z } from 'zod' 7 | 8 | /** 9 | * Enum representing message reaction types. 10 | */ 11 | export enum MessageReactionTypes { 12 | /** 13 | * Represents a 'like' reaction to a message. 14 | */ 15 | Like = 'like', 16 | 17 | /** 18 | * Represents a '+1' reaction to a message. 19 | */ 20 | PlusOne = 'plusOne', 21 | } 22 | 23 | /** 24 | * Zod schema for validating MessageReactionTypes enum values. 25 | */ 26 | export const messageReactionTypesZodSchema = z.enum(['like', 'plusOne']) 27 | -------------------------------------------------------------------------------- /packages/agents-hosting-dialogs/src/memory/pathResolvers/pathResolver.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Interface for resolving and transforming paths. 8 | * Implementations of this interface define how specific path patterns 9 | * should be transformed into other formats or namespaces. 10 | */ 11 | export interface PathResolver { 12 | /** 13 | * Transforms the given path into a new format or namespace. 14 | * 15 | * @param path - The path to inspect and transform. 16 | * @returns The transformed path. 17 | */ 18 | transformPath(path: string): string; 19 | } 20 | -------------------------------------------------------------------------------- /packages/agents-hosting-dialogs/src/memory/pathResolvers/dollarPathResolver.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | import { AliasPathResolver } from './aliasPathResolver' 6 | 7 | /** 8 | * A path resolver that resolves paths starting with a dollar sign ('$') 9 | * to the 'dialog.' namespace. 10 | */ 11 | export class DollarPathResolver extends AliasPathResolver { 12 | /** 13 | * Initializes a new instance of the DollarPathResolver class. 14 | * This resolver maps paths starting with '$' to the 'dialog.' namespace. 15 | */ 16 | constructor () { 17 | super('$', 'dialog.') 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/agents-hosting-dialogs/src/memory/pathResolvers/percentPathResolver.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | import { AliasPathResolver } from './aliasPathResolver' 6 | 7 | /** 8 | * A path resolver that resolves paths starting with a percent sign ('%') 9 | * to the 'class.' namespace. 10 | */ 11 | export class PercentPathResolver extends AliasPathResolver { 12 | /** 13 | * Initializes a new instance of the PercentPathResolver class. 14 | * This resolver maps paths starting with '%' to the 'class.' namespace. 15 | */ 16 | constructor () { 17 | super('%', 'class.') 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/connector-client/attachmentData.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Represents the data of an attachment. 8 | */ 9 | export interface AttachmentData { 10 | /** 11 | * The type of the attachment. 12 | */ 13 | type: string; 14 | /** 15 | * The name of the attachment. 16 | */ 17 | name: string; 18 | /** 19 | * The original data of the attachment in Base64 format. 20 | */ 21 | originalBase64: Uint8Array; 22 | /** 23 | * The thumbnail data of the attachment in Base64 format. 24 | */ 25 | thumbnailBase64: Uint8Array; 26 | } 27 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/app/routeSelector.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { TurnContext } from '../turnContext' 7 | 8 | /** 9 | * A function that determines whether a specific condition is met in the given turn context. 10 | * 11 | * @param context - The turn context for the current operation. 12 | * @returns A promise that resolves to a boolean indicating whether the condition is met. 13 | */ 14 | export type Selector = (context: TurnContext) => Promise 15 | 16 | /** 17 | * A specialized selector for routing operations. 18 | */ 19 | export type RouteSelector = Selector 20 | -------------------------------------------------------------------------------- /packages/agents-activity/src/attachment/attachmentLayoutTypes.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { z } from 'zod' 7 | 8 | /** 9 | * Enum representing the layout types for attachments. 10 | */ 11 | export enum AttachmentLayoutTypes { 12 | /** 13 | * Displays attachments in a list format. 14 | */ 15 | List = 'list', 16 | 17 | /** 18 | * Displays attachments in a carousel format. 19 | */ 20 | Carousel = 'carousel', 21 | } 22 | 23 | /** 24 | * Zod schema for validating attachment layout types. 25 | */ 26 | export const attachmentLayoutTypesZodSchema = z.enum(['list', 'carousel']) 27 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/invoke/searchInvokeValue.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { SearchInvokeOptions } from './searchInvokeOptions' 7 | 8 | /** 9 | * Represents the value of a search invoke request. 10 | */ 11 | export interface SearchInvokeValue { 12 | /** 13 | * The kind of search. 14 | */ 15 | kind: string 16 | /** 17 | * The text of the query. 18 | */ 19 | queryText: string 20 | /** 21 | * The options for the search query. 22 | */ 23 | queryOptions: SearchInvokeOptions 24 | /** 25 | * The context of the search. 26 | */ 27 | context: any 28 | } 29 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/message-actions-payload/messageActionsPayloadMention.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { MessageActionsPayloadFrom } from './messageActionsPayloadFrom' 7 | 8 | /** 9 | * Represents a mention in the message actions payload. 10 | */ 11 | export interface MessageActionsPayloadMention { 12 | /** 13 | * The unique identifier of the mention. 14 | */ 15 | id?: number 16 | /** 17 | * The text of the mention. 18 | */ 19 | mentionText?: string 20 | /** 21 | * The entity that was mentioned. 22 | */ 23 | mentioned?: MessageActionsPayloadFrom 24 | } 25 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/messageExtension/messagingExtensionResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | // import { CacheInfo } from '../agent-config/cacheInfo' 7 | import { MessagingExtensionResult } from './messagingExtensionResult' 8 | 9 | /** 10 | * Represents the response of a messaging extension. 11 | */ 12 | export interface MessagingExtensionResponse { 13 | /** 14 | * The result of the compose extension. 15 | */ 16 | composeExtension?: MessagingExtensionResult 17 | /** 18 | * Cache information for the response. 19 | */ 20 | cacheInfo?: unknown // TODO: CacheInfo 21 | } 22 | -------------------------------------------------------------------------------- /samples/_resources/ToggleVisibleCard.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", 3 | "type": "AdaptiveCard", 4 | "version": "1.0", 5 | "body": [ 6 | { 7 | "type": "TextBlock", 8 | "text": "**Action.ToggleVisibility example**: click the button to show or hide a welcome message" 9 | }, 10 | { 11 | "type": "TextBlock", 12 | "id": "helloWorld", 13 | "isVisible": false, 14 | "text": "**Hello World!**", 15 | "size": "extraLarge" 16 | } 17 | ], 18 | "actions": [ 19 | { 20 | "type": "Action.ToggleVisibility", 21 | "title": "Click me!", 22 | "targetElements": [ "helloWorld" ] 23 | } 24 | ] 25 | } -------------------------------------------------------------------------------- /packages/agents-activity/src/conversation/membershipTypes.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { z } from 'zod' 7 | 8 | /** 9 | * Enum expressing the users relationship to the current channel. 10 | */ 11 | export enum MembershipTypes { 12 | /** 13 | * The user is a direct member of a channel. 14 | */ 15 | Direct = 'direct', 16 | 17 | /** 18 | * The user is a member of a channel through a group. 19 | */ 20 | Transitive = 'transitive', 21 | } 22 | 23 | /** 24 | * Zod schema for validating membership source types. 25 | */ 26 | export const membershipTypeZodSchema = z.enum(['direct', 'transitive']) 27 | -------------------------------------------------------------------------------- /packages/agents-activity/src/messageReaction.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { z } from 'zod' 7 | import { MessageReactionTypes, messageReactionTypesZodSchema } from './messageReactionTypes' 8 | 9 | /** 10 | * Represents a message reaction. 11 | */ 12 | export interface MessageReaction { 13 | /** 14 | * The type of the reaction. 15 | */ 16 | type: MessageReactionTypes | string 17 | } 18 | 19 | /** 20 | * Zod schema for validating a MessageReaction object. 21 | */ 22 | export const messageReactionZodSchema = z.object({ 23 | type: z.union([messageReactionTypesZodSchema, z.string().min(1)]) 24 | }) 25 | -------------------------------------------------------------------------------- /packages/agents-hosting-dialogs/src/memory/pathResolvers/atAtPathResolver.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | import { AliasPathResolver } from './aliasPathResolver' 6 | 7 | /** 8 | * A specialized path resolver that replaces the '@@' alias with the prefix 'turn.recognized.entities.'. 9 | * This is used to resolve paths related to recognized entities in a conversational turn. 10 | */ 11 | export class AtAtPathResolver extends AliasPathResolver { 12 | /** 13 | * Initializes a new instance of the AtAtPathResolver class. 14 | */ 15 | constructor () { 16 | super('@@', 'turn.recognized.entities.') 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/agents-activity/src/entity/geoCoordinates.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Represents geographical coordinates. 8 | */ 9 | export interface GeoCoordinates { 10 | /** 11 | * The elevation of the location. 12 | */ 13 | elevation: number 14 | /** 15 | * The latitude of the location. 16 | */ 17 | latitude: number 18 | /** 19 | * The longitude of the location. 20 | */ 21 | longitude: number 22 | /** 23 | * The type of the geographical coordinates. 24 | */ 25 | type: string 26 | /** 27 | * The name of the geographical coordinates. 28 | */ 29 | name: string 30 | } 31 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/message-actions-payload/messageActionsPayloadBody.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * The type of content. 8 | */ 9 | export type ContentType = 'html' | 'text' 10 | 11 | /** 12 | * Represents the body of the message in the message actions payload. 13 | */ 14 | export interface MessageActionsPayloadBody { 15 | /** 16 | * The type of content. 17 | */ 18 | contentType?: ContentType 19 | /** 20 | * The content of the message. 21 | */ 22 | content?: string 23 | /** 24 | * The text content of the message. 25 | */ 26 | textContent?: string 27 | } 28 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/taskModule/taskModuleRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { TaskModuleRequestContext } from './taskModuleRequestContext' 7 | 8 | /** 9 | * Interface representing the request of a task module. 10 | */ 11 | export interface TaskModuleRequest { 12 | /** 13 | * The data of the task module request. 14 | */ 15 | data?: any 16 | /** 17 | * The context of the task module request. 18 | */ 19 | context?: TaskModuleRequestContext 20 | /** 21 | * The tab context of the task module request. 22 | */ 23 | tabContext?: any // TODO TabEntityContext 24 | } 25 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/taskModule/taskModuleResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { TaskModuleContinueResponse } from './taskModuleContinueResponse' 7 | import { TaskModuleMessageResponse } from './taskModuleMessageResponse' 8 | 9 | /** 10 | * Interface representing the response of a task module. 11 | */ 12 | export interface TaskModuleResponse { 13 | /** 14 | * The task module continue or message response. 15 | */ 16 | task?: TaskModuleContinueResponse | TaskModuleMessageResponse 17 | /** 18 | * The cache information. 19 | */ 20 | cacheInfo?: any // TODO CacheInfo 21 | } 22 | -------------------------------------------------------------------------------- /test-agents/web-chat/cards/ToggleVisibleCard.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", 3 | "type": "AdaptiveCard", 4 | "version": "1.0", 5 | "body": [ 6 | { 7 | "type": "TextBlock", 8 | "text": "**Action.ToggleVisibility example**: click the button to show or hide a welcome message" 9 | }, 10 | { 11 | "type": "TextBlock", 12 | "id": "helloWorld", 13 | "isVisible": false, 14 | "text": "**Hello World!**", 15 | "size": "extraLarge" 16 | } 17 | ], 18 | "actions": [ 19 | { 20 | "type": "Action.ToggleVisibility", 21 | "title": "Click me!", 22 | "targetElements": [ "helloWorld" ] 23 | } 24 | ] 25 | } -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/meeting/meetingDetails.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { MeetingDetailsBase } from './meetingDetailsBase' 7 | 8 | /** 9 | * Interface representing the details of a meeting. 10 | */ 11 | export interface MeetingDetails extends MeetingDetailsBase { 12 | /** The Microsoft Graph resource ID of the meeting. */ 13 | msGraphResourceId: string; 14 | /** The scheduled start time of the meeting. */ 15 | scheduledStartTime?: Date; 16 | /** The scheduled end time of the meeting. */ 17 | scheduledEndTime?: Date; 18 | /** The type of the meeting. */ 19 | type: string; 20 | } 21 | -------------------------------------------------------------------------------- /test-agents/web-chat/resources/ToggleVisibleCard.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", 3 | "type": "AdaptiveCard", 4 | "version": "1.0", 5 | "body": [ 6 | { 7 | "type": "TextBlock", 8 | "text": "**Action.ToggleVisibility example**: click the button to show or hide a welcome message" 9 | }, 10 | { 11 | "type": "TextBlock", 12 | "id": "helloWorld", 13 | "isVisible": false, 14 | "text": "**Hello World!**", 15 | "size": "extraLarge" 16 | } 17 | ], 18 | "actions": [ 19 | { 20 | "type": "Action.ToggleVisibility", 21 | "title": "Click me!", 22 | "targetElements": [ "helloWorld" ] 23 | } 24 | ] 25 | } -------------------------------------------------------------------------------- /packages/agents-hosting/src/auth/authConstants.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | export const ApxLocalScope = 'c16e153d-5d2b-4c21-b7f4-b05ee5d516f1/.default' 6 | export const ApxDevScope = '0d94caae-b412-4943-8a68-83135ad6d35f/.default' 7 | export const ApxProductionScope = '5a807f24-c9de-44ee-a3a7-329e88a00ffc/.default' 8 | export const ApxGCCScope = 'c9475445-9789-4fef-9ec5-cde4a9bcd446/.default' 9 | export const ApxGCCHScope = '6f669b9e-7701-4e2b-b624-82c9207fde26/.default' 10 | export const ApxDoDScope = '0a069c81-8c7c-4712-886b-9c542d673ffb/.default' 11 | export const ApxGallatinScope = 'bd004c8e-5acf-4c48-8570-4e7d46b2f63b/.default' 12 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/transcript/consoleTranscriptLogger.ts: -------------------------------------------------------------------------------- 1 | import { Activity } from '@microsoft/agents-activity' 2 | import { TranscriptLogger } from './transcriptLogger' 3 | 4 | /** 5 | * A transcript logger that logs activities to the console. 6 | */ 7 | export class ConsoleTranscriptLogger implements TranscriptLogger { 8 | /** 9 | * Logs an activity to the console. 10 | * @param activity The activity to log. 11 | * @throws Will throw an error if the activity is not provided. 12 | */ 13 | logActivity (activity: Activity): void | Promise { 14 | if (!activity) { 15 | throw new Error('Activity is required.') 16 | } 17 | 18 | console.log('Activity Log:', activity) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /packages/agents-activity/src/activityImportance.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { z } from 'zod' 7 | 8 | /** 9 | * Enum representing activity importance levels. 10 | */ 11 | export enum ActivityImportance { 12 | /** 13 | * Indicates low importance. 14 | */ 15 | Low = 'low', 16 | 17 | /** 18 | * Indicates normal importance. 19 | */ 20 | Normal = 'normal', 21 | 22 | /** 23 | * Indicates high importance. 24 | */ 25 | High = 'high', 26 | } 27 | 28 | /** 29 | * Zod schema for validating an ActivityImportance enum. 30 | */ 31 | export const activityImportanceZodSchema = z.enum(['low', 'normal', 'high']) 32 | -------------------------------------------------------------------------------- /packages/agents-copilotstudio-client/src/executeTurnRequest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { Activity } from '@microsoft/agents-activity' 7 | 8 | /** 9 | * Represents a request to execute a turn in a conversation. 10 | * This class encapsulates the activity to be executed during the turn. 11 | */ 12 | export class ExecuteTurnRequest { 13 | /** The activity to be executed. */ 14 | activity?: Activity 15 | 16 | /** 17 | * Creates an instance of ExecuteTurnRequest. 18 | * @param activity The activity to be executed. 19 | */ 20 | constructor (activity?: Activity) { 21 | this.activity = activity 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /packages/agents-hosting-dialogs/src/memory/pathResolvers/hashPathResolver.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | import { AliasPathResolver } from './aliasPathResolver' 6 | 7 | /** 8 | * A path resolver that resolves paths starting with a hash sign ('#') 9 | * to the 'turn.recognized.intents.' namespace. 10 | */ 11 | export class HashPathResolver extends AliasPathResolver { 12 | /** 13 | * Initializes a new instance of the HashPathResolver class. 14 | * This resolver maps paths starting with '#' to the 'turn.recognized.intents.' namespace. 15 | */ 16 | constructor () { 17 | super('#', 'turn.recognized.intents.') 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/cards/index.ts: -------------------------------------------------------------------------------- 1 | export * from './animationCard' 2 | export * from './audioCard' 3 | export * from './cardFactory' 4 | export * from './cardImage' 5 | export * from './fact' 6 | export * from './heroCard' 7 | export * from './mediaUrl' 8 | export * from './o365ConnectorCard' 9 | export * from './o365ConnectorCardActionBase' 10 | export * from './o365ConnectorCardFact' 11 | export * from './o365ConnectorCardImage' 12 | export * from './o365ConnectorCardSection' 13 | export * from './receiptCard' 14 | export * from './receiptItem' 15 | export * from './taskModuleAction' 16 | export * from './thumbnailCard' 17 | export * from './videoCard' 18 | export * from './thumbnailUrl' 19 | export * from './adaptiveCard' 20 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/app/adaptiveCards/adaptiveCardActionExecuteResponseType.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Defines the types of responses that can be returned after executing an Adaptive Card action. 8 | */ 9 | export enum AdaptiveCardActionExecuteResponseType { 10 | /** 11 | * Replaces the Adaptive Card only for the user who interacted with it. 12 | */ 13 | REPLACE_FOR_INTERACTOR, 14 | 15 | /** 16 | * Replaces the Adaptive Card for all users. 17 | */ 18 | REPLACE_FOR_ALL, 19 | 20 | /** 21 | * Sends a new message containing an Adaptive Card to all users. 22 | */ 23 | NEW_MESSAGE_FOR_ALL 24 | } 25 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/messageExtension/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | export { MessagingExtensionParameter } from './messagingExtensionParameter' 7 | export * from './messagingExtensionQuery' 8 | export { MessagingExtensionQueryOptions } from './messagingExtensionQueryOptions' 9 | export * from './messagingExtensionAction' 10 | export * from './messagingExtensionActionResponse' 11 | export * from './messagingExtensionAttachment' 12 | export * from './messagingExtensionResponse' 13 | export * from './messagingExtensionResult' 14 | export * from './messagingExtensionSuggestedAction' 15 | export * from './appBasedLinkQuery' 16 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/app/adaptiveCards/adaptiveCardsSearchParams.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { z } from 'zod' 7 | 8 | /** 9 | * Represents the search parameters for adaptive cards. 10 | */ 11 | export interface AdaptiveCardsSearchParams { 12 | /** 13 | * The text query for the search. 14 | */ 15 | queryText: string; 16 | /** 17 | * The dataset to search within. 18 | */ 19 | dataset: string; 20 | } 21 | 22 | /** 23 | * Zod schema for validating AdaptiveCardsSearchParams. 24 | */ 25 | export const adaptiveCardsSearchParamsZodSchema = z.object({ 26 | queryText: z.string(), 27 | dataset: z.string(), 28 | }) 29 | -------------------------------------------------------------------------------- /packages/agents-activity/src/action/suggestedActions.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { z } from 'zod' 7 | import { CardAction, cardActionZodSchema } from './cardAction' 8 | 9 | /** 10 | * Represents suggested actions. 11 | */ 12 | export interface SuggestedActions { 13 | /** 14 | * Array of recipient IDs. 15 | */ 16 | to: string[] 17 | /** 18 | * Array of card actions. 19 | */ 20 | actions: CardAction[] 21 | } 22 | 23 | /** 24 | * Zod schema for validating SuggestedActions. 25 | */ 26 | export const suggestedActionsZodSchema = z.object({ 27 | to: z.array(z.string().min(1)), 28 | actions: z.array(cardActionZodSchema) 29 | }) 30 | -------------------------------------------------------------------------------- /packages/agents-activity/src/activityEventNames.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { z } from 'zod' 7 | 8 | /** 9 | * Enum representing activity event names. 10 | */ 11 | export enum ActivityEventNames { 12 | /** 13 | * Event name for continuing a conversation. 14 | */ 15 | ContinueConversation = 'ContinueConversation', 16 | 17 | /** 18 | * Event name for creating a new conversation. 19 | */ 20 | CreateConversation = 'CreateConversation', 21 | } 22 | 23 | /** 24 | * Zod schema for validating an ActivityEventNames enum. 25 | */ 26 | export const activityEventNamesZodSchema = z.enum(['ContinueConversation', 'CreateConversation']) 27 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/app/routeHandler.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { TurnContext } from '../turnContext' 7 | import { TurnState } from './turnState' 8 | 9 | /** 10 | * A handler function for routing operations in a specific turn context and state. 11 | * 12 | * @typeParam TState - The type of the turn state. 13 | * @param context - The turn context for the current operation. 14 | * @param state - The state associated with the current turn. 15 | * @returns A promise that resolves when the routing operation is complete. 16 | */ 17 | export type RouteHandler = (context: TurnContext, state: TState) => Promise 18 | -------------------------------------------------------------------------------- /packages/agents-activity/src/conversation/membershipSourceTypes.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { z } from 'zod' 7 | 8 | /** 9 | * Enum defining the type of roster the user is a member of. 10 | */ 11 | export enum MembershipSourceTypes { 12 | /** 13 | * The source is that of a channel and the user is a member of that channel. 14 | */ 15 | Channel = 'channel', 16 | 17 | /** 18 | * The source is that of a team and the user is a member of that team. 19 | */ 20 | Team = 'team', 21 | } 22 | 23 | /** 24 | * Zod schema for validating membership source types. 25 | */ 26 | export const membershipSourceTypeZodSchema = z.enum(['channel', 'team']) 27 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/file/fileUploadInfo.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Interface representing information required for file upload. 8 | */ 9 | export interface FileUploadInfo { 10 | /** 11 | * The name of the file. 12 | */ 13 | name?: string; 14 | 15 | /** 16 | * The URL to upload the file. 17 | */ 18 | uploadUrl?: string; 19 | 20 | /** 21 | * The URL to access the uploaded file. 22 | */ 23 | contentUrl?: string; 24 | 25 | /** 26 | * A unique identifier for the file. 27 | */ 28 | uniqueId?: string; 29 | 30 | /** 31 | * The type of the file. 32 | */ 33 | fileType?: string; 34 | } 35 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/invoke/adaptiveCardInvokeValue.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { AdaptiveCardInvokeAction } from '@microsoft/agents-activity' 7 | import { AdaptiveCardAuthentication } from './adaptiveCardAuthentication' 8 | 9 | /** 10 | * Represents the value of an adaptive card invoke request. 11 | */ 12 | export interface AdaptiveCardInvokeValue { 13 | /** 14 | * The action to be performed. 15 | */ 16 | action: AdaptiveCardInvokeAction 17 | /** 18 | * The authentication information. 19 | */ 20 | authentication: AdaptiveCardAuthentication 21 | /** 22 | * The state of the adaptive card. 23 | */ 24 | state: string 25 | } 26 | -------------------------------------------------------------------------------- /packages/agents-hosting/test/activity-value-parsers/parseValueQuery.test.ts: -------------------------------------------------------------------------------- 1 | import assert from 'assert' 2 | import { describe, it } from 'node:test' 3 | import { ZodError } from 'zod' 4 | import { parseValueQuery } from '../../src/app/adaptiveCards/activityValueParsers' 5 | 6 | describe('parseValueQuery test', () => { 7 | it('Parse with all properties', () => { 8 | const valueObject = { 9 | url: 'url' 10 | } 11 | const parsedValue = parseValueQuery(valueObject) 12 | assert.deepEqual(parsedValue, valueObject) 13 | }) 14 | 15 | it('Should throw with not string url', () => { 16 | const valueObject = { 17 | url: 1 18 | } 19 | assert.throws(() => { 20 | parseValueQuery(valueObject) 21 | }, ZodError) 22 | }) 23 | }) 24 | -------------------------------------------------------------------------------- /test-agents/state-agent/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "stateagent", 3 | "version": "1.0.0", 4 | "private": true, 5 | "description": "AgentsSDK state sample", 6 | "author": "Microsoft", 7 | "license": "MIT", 8 | "main": "./dist/index.js", 9 | "scripts": { 10 | "build": "tsc --build", 11 | "prestart": "npm run build", 12 | "start": "node --env-file .env ./dist/index.js" 13 | }, 14 | "repository": { 15 | "type": "git", 16 | "url": "https://github.com" 17 | }, 18 | "dependencies": { 19 | "@microsoft/agents-hosting-storage-blob": "file:../../packages/agents-hosting-storage-blob", 20 | "@microsoft/agents-hosting-storage-cosmos": "file:../../packages/agents-hosting-storage-cosmos", 21 | "express": "^5.2.1" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /compat/baseline/agents-hosting-express.api.md: -------------------------------------------------------------------------------- 1 | ## API Report File for "@microsoft/agents-hosting-express" 2 | 3 | > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). 4 | 5 | ```ts 6 | 7 | import { ActivityHandler } from '@microsoft/agents-hosting'; 8 | import { AgentApplication } from '@microsoft/agents-hosting'; 9 | import { AuthConfiguration } from '@microsoft/agents-hosting'; 10 | import express from 'express'; 11 | import { TurnState } from '@microsoft/agents-hosting'; 12 | 13 | // @public 14 | export const startServer: (agent: AgentApplication> | ActivityHandler, authConfiguration?: AuthConfiguration) => express.Express; 15 | 16 | // (No @packageDocumentation comment for this package) 17 | 18 | ``` 19 | -------------------------------------------------------------------------------- /packages/agents-activity/src/textFormatTypes.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { z } from 'zod' 7 | 8 | /** 9 | * Enum representing text format types. 10 | */ 11 | export enum TextFormatTypes { 12 | /** 13 | * Represents text formatted using Markdown. 14 | */ 15 | Markdown = 'markdown', 16 | 17 | /** 18 | * Represents plain text without any formatting. 19 | */ 20 | Plain = 'plain', 21 | 22 | /** 23 | * Represents text formatted using XML. 24 | */ 25 | Xml = 'xml', 26 | } 27 | 28 | /** 29 | * Zod schema for validating TextFormatTypes enum values. 30 | */ 31 | export const textFormatTypesZodSchema = z.enum(['markdown', 'plain', 'xml']) 32 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/messageExtension/messagingExtensionParameter.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { z } from 'zod' 7 | 8 | /** 9 | * Represents a parameter for a messaging extension query. 10 | */ 11 | export interface MessagingExtensionParameter { 12 | /** 13 | * The name of the parameter. 14 | */ 15 | name?: string 16 | /** 17 | * The value of the parameter. 18 | */ 19 | value?: any 20 | } 21 | 22 | /** 23 | * Zod schema for validating MessagingExtensionParameter. 24 | */ 25 | export const messagingExtensionParameterZodSchema = z.object({ 26 | name: z.string().min(1).optional(), 27 | value: z.any().optional() 28 | }) 29 | -------------------------------------------------------------------------------- /packages/agents-hosting-dialogs/src/choices/choice.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { CardAction } from '@microsoft/agents-activity' 7 | 8 | /** 9 | * An instance of a choice that can be used to render a choice to a user or recognize something a 10 | * user picked. 11 | */ 12 | export interface Choice { 13 | /** 14 | * The value of the choice, which is used to identify the choice. 15 | */ 16 | value: string; 17 | 18 | /** 19 | * An optional action associated with the choice, such as a button click. 20 | */ 21 | action?: CardAction; 22 | 23 | /** 24 | * Optional synonyms that can be used to recognize the choice. 25 | */ 26 | synonyms?: string[]; 27 | } 28 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/messageExtension/messagingExtensionQueryOptions.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { z } from 'zod' 7 | 8 | /** 9 | * Represents query options for a messaging extension. 10 | */ 11 | export interface MessagingExtensionQueryOptions { 12 | /** 13 | * The number of items to skip. 14 | */ 15 | skip?: number 16 | /** 17 | * The number of items to retrieve. 18 | */ 19 | count?: number 20 | } 21 | 22 | /** 23 | * Zod schema for validating MessagingExtensionQueryOptions. 24 | */ 25 | export const messagingExtensionQueryOptionsZodSchema = z.object({ 26 | skip: z.number().optional(), 27 | count: z.number().optional() 28 | }) 29 | -------------------------------------------------------------------------------- /packages/agents-hosting/test/activity-value-parsers/parseValueAction.test.ts: -------------------------------------------------------------------------------- 1 | import assert from 'assert' 2 | import { describe, it } from 'node:test' 3 | import { ZodError } from 'zod' 4 | import { parseValueAction } from '../../src/app/adaptiveCards/activityValueParsers' 5 | 6 | describe('parseValueAction test', () => { 7 | it('Parse with all properties', () => { 8 | const valueObject = { 9 | action: 'action' 10 | } 11 | const parsedValue = parseValueAction(valueObject) 12 | assert.deepEqual(parsedValue, valueObject) 13 | }) 14 | 15 | it('Should throw with not string action', () => { 16 | const valueObject = { 17 | action: 1 18 | } 19 | assert.throws(() => { 20 | parseValueAction(valueObject) 21 | }, ZodError) 22 | }) 23 | }) 24 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/activity-extensions/channelTypes.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { z } from 'zod' 7 | 8 | /** 9 | * Enum representing the different Teams channel types. 10 | */ 11 | export enum ChannelTypes { 12 | /** 13 | * Represents a private Teams channel. 14 | */ 15 | Private = 'private', 16 | 17 | /** 18 | * Represents a shared Teams channel. 19 | */ 20 | Shared = 'shared', 21 | 22 | /** 23 | * Represents a standard Teams channel. 24 | */ 25 | Standard = 'standard', 26 | } 27 | 28 | /** 29 | * Zod schema for validating channel types. 30 | */ 31 | export const channelTypeZodSchema = z.enum(['standard', 'private', 'shared']) 32 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/cards/heroCard.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { CardAction } from '@microsoft/agents-activity' 7 | import { CardImage } from './cardImage' 8 | 9 | /** 10 | * Represents a Hero Card. 11 | */ 12 | export interface HeroCard { 13 | /** The title of the card. */ 14 | title: string 15 | /** The subtitle of the card. */ 16 | subtitle: string 17 | /** The text content of the card. */ 18 | text: string 19 | /** The images to be displayed on the card. */ 20 | images: CardImage[] 21 | /** The buttons to be displayed on the card. */ 22 | buttons: CardAction[] 23 | /** The action to be performed when the card is tapped. */ 24 | tap: CardAction 25 | } 26 | -------------------------------------------------------------------------------- /packages/agents-hosting/test/activity-value-parsers/parseValueDataset.test.ts: -------------------------------------------------------------------------------- 1 | import assert from 'assert' 2 | import { describe, it } from 'node:test' 3 | import { ZodError } from 'zod' 4 | import { parseValueDataset } from '../../src/app/adaptiveCards/activityValueParsers' 5 | 6 | describe('parseValueDataset test', () => { 7 | it('Parse with all properties', () => { 8 | const valueObject = { 9 | dataset: 'dataset' 10 | } 11 | const parsedValue = parseValueDataset(valueObject) 12 | assert.deepEqual(parsedValue, valueObject) 13 | }) 14 | 15 | it('Should throw with not string dataset', () => { 16 | const valueObject = { 17 | dataset: 1 18 | } 19 | assert.throws(() => { 20 | parseValueDataset(valueObject) 21 | }, ZodError) 22 | }) 23 | }) 24 | -------------------------------------------------------------------------------- /test-agents/agentic-ai/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "agentic-ai-agent", 3 | "version": "1.0.0", 4 | "private": true, 5 | "author": "Microsoft", 6 | "license": "MIT", 7 | "main": "./dist/index.js", 8 | "scripts": { 9 | "build": "tsc --build", 10 | "prestart": "npm run build", 11 | "start": "node --env-file .env ./dist/index.js", 12 | "prebundle": "npm run build", 13 | "bundle": "esbuild dist/index.js --bundle --platform=node --metafile=dist/meta.json --outfile=dist/bundle.js --tree-shaking=true --keep-names", 14 | "predocker": "npm run bundle", 15 | "docker": "docker build -t \"$npm_package_name:$npm_package_version\" ." 16 | }, 17 | "dependencies": { 18 | "@microsoft/agents-hosting-express": "file:../../packages/agents-hosting-express" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test-agents/empty-agent/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "empty-agent", 3 | "version": "1.0.0", 4 | "private": true, 5 | "author": "Microsoft", 6 | "license": "MIT", 7 | "main": "./dist/agent.js", 8 | "scripts": { 9 | "build": "tsc --build", 10 | "prestart": "npm run build", 11 | "start": "node --env-file .env ./dist/agent.js", 12 | "prebundle": "npm run build", 13 | "bundle": "esbuild dist/agent.js --bundle --platform=node --metafile=dist/meta.json --outfile=dist/bundle.js --tree-shaking=true --keep-names", 14 | "predocker": "npm run bundle", 15 | "docker": "docker build -t \"$npm_package_name:$npm_package_version\" ." 16 | }, 17 | "dependencies": { 18 | "@microsoft/agents-hosting-express": "file:../../packages/agents-hosting-express" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /samples/basic/echo.ts: -------------------------------------------------------------------------------- 1 | import { startServer } from '@microsoft/agents-hosting-express' 2 | import { AgentApplication, MemoryStorage, TurnContext, TurnState } from '@microsoft/agents-hosting' 3 | 4 | const echo = new AgentApplication({ storage: new MemoryStorage() }) 5 | echo.onConversationUpdate('membersAdded', async (context: TurnContext) => { 6 | await context.sendActivity('Welcome to the Echo sample, send a message to see the echo feature in action.') 7 | }) 8 | echo.onActivity('message', async (context: TurnContext, state: TurnState) => { 9 | let counter: number = state.getValue('conversation.counter') || 0 10 | await context.sendActivity(`[${counter++}]You said: ${context.activity.text}`) 11 | state.setValue('conversation.counter', counter) 12 | }) 13 | 14 | startServer(echo) 15 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/message-actions-payload/messageActionsPayloadConversation.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * The type of conversation identity. 8 | */ 9 | export type ConversationIdentityType = 'team' | 'channel' 10 | 11 | /** 12 | * Represents a conversation in the message actions payload. 13 | */ 14 | export interface MessageActionsPayloadConversation { 15 | /** 16 | * The type of conversation identity. 17 | */ 18 | conversationIdentityType?: ConversationIdentityType 19 | /** 20 | * The unique identifier of the conversation. 21 | */ 22 | id?: string 23 | /** 24 | * The display name of the conversation. 25 | */ 26 | displayName?: string 27 | } 28 | -------------------------------------------------------------------------------- /test-agents/root-agent/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "root-agent", 3 | "version": "1.0.0", 4 | "private": true, 5 | "author": "Microsoft", 6 | "license": "MIT", 7 | "main": "./dist/index.js", 8 | "scripts": { 9 | "build": "tsc --build", 10 | "prestart": "npm run build", 11 | "start": "node --env-file .env ./dist/index.js", 12 | "prebundle": "npm run build", 13 | "bundle": "esbuild dist/index.js --bundle --platform=node --metafile=dist/meta.json --outfile=dist/bundle.js --tree-shaking=true --keep-names", 14 | "predocker": "npm run bundle", 15 | "docker": "docker build -t \"$npm_package_name:$npm_package_version\" ." 16 | }, 17 | "dependencies": { 18 | "@microsoft/agents-hosting": "file:../../packages/agents-hosting", 19 | "express": "^5.2.1" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/agents-hosting-storage-cosmos/README.md: -------------------------------------------------------------------------------- 1 | # @microsoft/agents-hosting-storage-cosmos 2 | 3 | ## Overview 4 | 5 | This package allows to configure Azure CosmosDB Storage as the backend for Agents conversation State 6 | 7 | ## Usage 8 | 9 | ```ts 10 | const cosmosDbStorageOptions = { 11 | databaseId: process.env.COSMOS_DATABASE_ID || 'agentsDB', 12 | containerId: process.env.COSMOS_CONTAINER_ID || 'agentsState', 13 | cosmosClientOptions: { 14 | endpoint: process.env.COSMOS_ENDPOINT!, 15 | key: process.env.COSMOS_KEY!, 16 | } 17 | } as CosmosDbPartitionedStorageOptions 18 | const cosmosStorage = new CosmosDbPartitionedStorage(cosmosDbStorageOptions) 19 | const conversationState = new ConversationState(cosmosStorage) 20 | const userState = new UserState(cosmosStorage) 21 | ``` -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/meeting/meetingInfo.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { ConversationAccount } from '@microsoft/agents-activity' 7 | import { MeetingDetails } from '../meeting/meetingDetails' 8 | import { TeamsChannelAccount } from '../activity-extensions/teamsChannelAccount' 9 | 10 | /** 11 | * Represents information about a meeting. 12 | */ 13 | export interface MeetingInfo { 14 | /** 15 | * Details of the meeting. 16 | */ 17 | details: MeetingDetails; 18 | /** 19 | * Conversation account associated with the meeting. 20 | */ 21 | conversation: ConversationAccount; 22 | /** 23 | * Organizer of the meeting. 24 | */ 25 | organizer: TeamsChannelAccount; 26 | } 27 | -------------------------------------------------------------------------------- /packages/agents-hosting/test/activity-value-parsers/parseValueActionName.test.ts: -------------------------------------------------------------------------------- 1 | import assert from 'assert' 2 | import { describe, it } from 'node:test' 3 | import { ZodError } from 'zod' 4 | import { parseValueActionName } from '../../src/app/adaptiveCards/activityValueParsers' 5 | 6 | describe('parseValueActionName test', () => { 7 | it('Parse with all properties', () => { 8 | const valueObject = { 9 | actionName: 'actionName' 10 | } 11 | const parsedValue = parseValueActionName(valueObject) 12 | assert.deepEqual(parsedValue, valueObject) 13 | }) 14 | 15 | it('Should throw with not string actionName', () => { 16 | const valueObject = { 17 | actionName: 1 18 | } 19 | assert.throws(() => { 20 | parseValueActionName(valueObject) 21 | }, ZodError) 22 | }) 23 | }) 24 | -------------------------------------------------------------------------------- /samples/basic/attachments.ts: -------------------------------------------------------------------------------- 1 | import { startServer } from '@microsoft/agents-hosting-express' 2 | import { AgentApplication, AttachmentDownloader } from '@microsoft/agents-hosting' 3 | 4 | const storedFilesKey = 'storedFiles' as const 5 | 6 | const agent = new AgentApplication({ 7 | fileDownloaders: [new AttachmentDownloader(storedFilesKey)], 8 | }) 9 | 10 | agent.onConversationUpdate('membersAdded', async (context) => { 11 | await context.sendActivity('Welcome to the Attachment sample. Send a message with an attachment to see the feature in action.') 12 | }) 13 | 14 | agent.onActivity('message', async (context, state) => { 15 | const files = (state.getValue(storedFilesKey) as unknown[] | undefined) ?? [] 16 | await context.sendActivity(`You sent ${files.length} file(s)`) 17 | }) 18 | 19 | startServer(agent) 20 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/activity-extensions/teamsChannelAccount.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { ChannelAccount } from '@microsoft/agents-activity' 7 | 8 | /** 9 | * Represents a Teams channel account. 10 | */ 11 | export interface TeamsChannelAccount extends ChannelAccount { 12 | /** 13 | * Given name of the user. 14 | */ 15 | givenName?: string 16 | /** 17 | * Surname of the user. 18 | */ 19 | surname?: string 20 | /** 21 | * Email address of the user. 22 | */ 23 | email?: string 24 | /** 25 | * User principal name of the user. 26 | */ 27 | userPrincipalName?: string 28 | /** 29 | * Role of the user in the team. 30 | */ 31 | userRole?: string 32 | } 33 | -------------------------------------------------------------------------------- /packages/agents-hosting/test/activity-value-parsers/parseValueCommandId.test.ts: -------------------------------------------------------------------------------- 1 | import assert from 'assert' 2 | import { describe, it } from 'node:test' 3 | import { ZodError } from 'zod' 4 | import { parseValueCommandId } from '../../src/app/adaptiveCards/activityValueParsers' 5 | 6 | describe('parseValueCommandId test', () => { 7 | it('Parse with all properties', () => { 8 | const valueObject = { 9 | commandId: 'botMessagePreviewAction' 10 | } 11 | const parsedValue = parseValueCommandId(valueObject) 12 | assert.deepEqual(parsedValue, valueObject) 13 | }) 14 | 15 | it('Should throw with not string commandId', () => { 16 | const valueObject = { 17 | commandId: 1 18 | } 19 | assert.throws(() => { 20 | parseValueCommandId(valueObject) 21 | }, ZodError) 22 | }) 23 | }) 24 | -------------------------------------------------------------------------------- /packages/agents-activity/src/action/semanticActionStateTypes.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { z } from 'zod' 7 | 8 | /** 9 | * Enum representing the state types of a semantic action. 10 | */ 11 | export enum SemanticActionStateTypes { 12 | /** 13 | * Indicates the start of a semantic action. 14 | */ 15 | Start = 'start', 16 | 17 | /** 18 | * Indicates the continuation of a semantic action. 19 | */ 20 | Continue = 'continue', 21 | 22 | /** 23 | * Indicates the completion of a semantic action. 24 | */ 25 | Done = 'done', 26 | } 27 | 28 | /** 29 | * Zod schema for validating SemanticActionStateTypes. 30 | */ 31 | export const semanticActionStateTypesZodSchema = z.enum(['start', 'continue', 'done']) 32 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/app/adaptiveCards/adaptiveCardsOptions.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { AdaptiveCardActionExecuteResponseType } from './adaptiveCardActionExecuteResponseType' 7 | 8 | /** 9 | * Configuration options for Adaptive Cards. 10 | */ 11 | export interface AdaptiveCardsOptions { 12 | /** 13 | * Specifies the filter key used for Action.Submit events. 14 | * If not provided, a default filter key will be used. 15 | */ 16 | actionSubmitFilter?: string; 17 | 18 | /** 19 | * Specifies the response type for Action.Execute events. 20 | * Determines how the response is handled after an action is executed. 21 | */ 22 | actionExecuteResponseType?: AdaptiveCardActionExecuteResponseType; 23 | } 24 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/message-actions-payload/messageActionsPayloadApp.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * The type of application identity. 8 | */ 9 | export type ApplicationIdentityType = 'aadApplication' | 'bot' | 'tenantBot' | 'office365Connector' | 'webhook' 10 | 11 | /** 12 | * Represents an application in the message actions payload. 13 | */ 14 | export interface MessageActionsPayloadApp { 15 | /** 16 | * The type of application identity. 17 | */ 18 | applicationIdentityType?: ApplicationIdentityType 19 | /** 20 | * The unique identifier of the application. 21 | */ 22 | id?: string 23 | /** 24 | * The display name of the application. 25 | */ 26 | displayName?: string 27 | } 28 | -------------------------------------------------------------------------------- /samples/teams/teamsAttachments.ts: -------------------------------------------------------------------------------- 1 | import { startServer } from '@microsoft/agents-hosting-express' 2 | import { AgentApplication, TeamsAttachmentDownloader } from '@microsoft/agents-hosting' 3 | 4 | const storedFilesKey = 'storedFiles' as const 5 | 6 | const agent = new AgentApplication({ 7 | fileDownloaders: [new TeamsAttachmentDownloader(storedFilesKey)] 8 | }) 9 | 10 | agent.onConversationUpdate('membersAdded', async (context) => { 11 | await context.sendActivity('Welcome to the Attachment sample, send a message with an attachment to see the feature in action.') 12 | }) 13 | 14 | agent.onActivity('message', async (context, state) => { 15 | const files = (state.getValue(storedFilesKey) as unknown[] | undefined) ?? [] 16 | await context.sendActivity(`You sent ${files.length} file(s)`) 17 | }) 18 | 19 | startServer(agent) 20 | -------------------------------------------------------------------------------- /test-agents/copilotstudio-webchat/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Agents Copilot Studio Client integration with Web Chat 5 | 6 | 7 | 8 | 9 | 16 | 17 | 18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/file/fileConsentCardResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { FileUploadInfo } from './fileUploadInfo' 7 | 8 | /** 9 | * Type representing possible actions for file consent. 10 | */ 11 | export type Action = 'accept' | 'decline' 12 | 13 | /** 14 | * Interface representing the response to a file consent card. 15 | */ 16 | export interface FileConsentCardResponse { 17 | /** 18 | * The action taken by the user, either 'accept' or 'decline'. 19 | */ 20 | action?: Action; 21 | 22 | /** 23 | * Additional context information. 24 | */ 25 | context?: any; 26 | 27 | /** 28 | * Information about the file to be uploaded. 29 | */ 30 | uploadInfo?: FileUploadInfo; 31 | } 32 | -------------------------------------------------------------------------------- /packages/agents-hosting/test/activity-value-parsers/parseValueContinuation.test.ts: -------------------------------------------------------------------------------- 1 | import assert from 'assert' 2 | import { describe, it } from 'node:test' 3 | import { ZodError } from 'zod' 4 | import { parseValueContinuation } from '../../src/app/adaptiveCards/activityValueParsers' 5 | 6 | describe('parseValueContinuation test', () => { 7 | it('Parse with all properties', () => { 8 | const valueObject = { 9 | continuation: 'continuation' 10 | } 11 | const parsedValue = parseValueContinuation(valueObject) 12 | assert.deepEqual(parsedValue, valueObject) 13 | }) 14 | 15 | it('Should throw with not string continuation', () => { 16 | const valueObject = { 17 | continuation: 1 18 | } 19 | assert.throws(() => { 20 | parseValueContinuation(valueObject) 21 | }, ZodError) 22 | }) 23 | }) 24 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/activity-extensions/teamsChannelDataSettings.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { z } from 'zod' 7 | import { ChannelInfo, channelInfoZodSchema } from './channelInfo' 8 | 9 | /** 10 | * Represents settings for Teams channel data. 11 | */ 12 | export interface TeamsChannelDataSettings { 13 | /** 14 | * The selected channel information. 15 | */ 16 | selectedChannel?: ChannelInfo 17 | /** 18 | * Additional properties. 19 | */ 20 | [properties: string]: unknown 21 | } 22 | 23 | /** 24 | * Zod schema for validating TeamsChannelDataSettings objects. 25 | */ 26 | export const teamsChannelDataSettingsZodSchema = z.object({ 27 | selectedChannel: channelInfoZodSchema.optional() 28 | }) 29 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/activity-extensions/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | export { ChannelInfo } from './channelInfo' 7 | export { ChannelTypes } from './channelTypes' 8 | export { NotificationInfo } from './notificationInfo' 9 | export { OnBehalfOf } from './onBehalfOf' 10 | export { TeamInfo } from './teamInfo' 11 | export { TeamsChannelAccount } from './teamsChannelAccount' 12 | export { TeamsChannelData, parseTeamsChannelData } from './teamsChannelData' 13 | export { TeamsChannelDataSettings } from './teamsChannelDataSettings' 14 | export * from './teamsConversationUpdateEvents' 15 | export { TeamsMeetingInfo } from './teamsMeetingInfo' 16 | export * from './teamsMessageEvents' 17 | export { TenantInfo } from './tenantInfo' 18 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/cards/thumbnailCard.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { CardAction } from '@microsoft/agents-activity' 7 | import { CardImage } from './cardImage' 8 | 9 | /** 10 | * Represents a thumbnail card. 11 | */ 12 | export interface ThumbnailCard { 13 | /** 14 | * The title of the card. 15 | */ 16 | title: string 17 | /** 18 | * The subtitle of the card. 19 | */ 20 | subtitle: string 21 | /** 22 | * The text of the card. 23 | */ 24 | text: string 25 | /** 26 | * The images of the card. 27 | */ 28 | images: CardImage[] 29 | /** 30 | * The buttons of the card. 31 | */ 32 | buttons: CardAction[] 33 | /** 34 | * The tap action of the card. 35 | */ 36 | tap: CardAction 37 | } 38 | -------------------------------------------------------------------------------- /samples/teams/compat/echo.ts: -------------------------------------------------------------------------------- 1 | import { startServer } from '@microsoft/agents-hosting-express' 2 | import { TeamsActivityHandler } from '@microsoft/agents-hosting-extensions-teams' 3 | 4 | class TeamsEchoBot extends TeamsActivityHandler { 5 | constructor () { 6 | super() 7 | this.onMembersAdded(async (context, next) => { 8 | const membersAdded = context.activity.membersAdded 9 | for (const member of membersAdded!) { 10 | if (member.id !== context.activity.recipient!.id) { 11 | await context.sendActivity('Welcome to the Teams bot!') 12 | } 13 | } 14 | await next() 15 | }) 16 | 17 | this.onMessage(async (context, next) => { 18 | await context.sendActivity(`You said: ${context.activity.text}`) 19 | await next() 20 | }) 21 | } 22 | } 23 | startServer(new TeamsEchoBot()) 24 | -------------------------------------------------------------------------------- /packages/agents-activity/test/activity/activity.value.test.ts: -------------------------------------------------------------------------------- 1 | import { strict as assert } from 'assert' 2 | import { describe, it } from 'node:test' 3 | import { Activity } from '../../src' 4 | 5 | describe('value any roundtrip', () => { 6 | it('should roundtrip a json string', () => { 7 | const jsonWithString = { type: 'type', value: '{"a": "b"}' } 8 | const act = Activity.fromObject(jsonWithString) 9 | assert.strictEqual(act.value, '{"a": "b"}') 10 | const parsedValue = JSON.parse(act.value) 11 | assert.strictEqual(parsedValue.a, 'b') 12 | }) 13 | 14 | it('should roundtrip an object', () => { 15 | const jsonWithString = { type: 'type', value: { a: 'b' } } 16 | const act = Activity.fromObject(jsonWithString) 17 | assert.deepEqual(act.value, { a: 'b' }) 18 | assert.strictEqual(act.value.a, 'b') 19 | }) 20 | }) 21 | -------------------------------------------------------------------------------- /packages/agents-hosting-dialogs/src/converter.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * The converter converts objects from one type to another. 8 | * 9 | * @typeParam From - The type of the input value to be converted. 10 | * @typeParam To - The type of the output value after conversion. 11 | */ 12 | export interface Converter { 13 | convert(value: From | To): To; 14 | } 15 | 16 | /** 17 | * A factory type for creating instances of a `Converter`. 18 | * 19 | * @typeParam From - The type of the input value to be converted. 20 | * @typeParam To - The type of the output value after conversion. 21 | */ 22 | export type ConverterFactory = { 23 | new (...args: unknown[]): Converter; 24 | } 25 | -------------------------------------------------------------------------------- /packages/agents-activity/src/inputHints.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { z } from 'zod' 7 | 8 | /** 9 | * Enum representing input hints. 10 | */ 11 | export enum InputHints { 12 | /** 13 | * Indicates that the bot is ready to accept input from the user. 14 | */ 15 | AcceptingInput = 'acceptingInput', 16 | 17 | /** 18 | * Indicates that the bot is ignoring input from the user. 19 | */ 20 | IgnoringInput = 'ignoringInput', 21 | 22 | /** 23 | * Indicates that the bot is expecting input from the user. 24 | */ 25 | ExpectingInput = 'expectingInput', 26 | } 27 | 28 | /** 29 | * Zod schema for validating an InputHints enum. 30 | */ 31 | export const inputHintsZodSchema = z.enum(['acceptingInput', 'ignoringInput', 'expectingInput']) 32 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/app/index.ts: -------------------------------------------------------------------------------- 1 | export * from './agentApplication' 2 | export * from './agentApplicationBuilder' 3 | export * from './agentApplicationOptions' 4 | export * from './appRoute' 5 | export { Authorization } from './auth/authorization' 6 | export * from './routeHandler' 7 | export * from './routeList' 8 | export * from './routeRank' 9 | export * from './routeSelector' 10 | export * from './attachmentDownloader' 11 | export * from './conversationUpdateEvents' 12 | export * from './turnState' 13 | export * from './turnEvents' 14 | export * from './turnStateEntry' 15 | export * from './inputFileDownloader' 16 | export * from './appMemory' 17 | export * from './extensions' 18 | export * from './adaptiveCards' 19 | export * from './streaming/streamingResponse' 20 | export * from './streaming/citation' 21 | export * from './teamsAttachmentDownloader' 22 | -------------------------------------------------------------------------------- /test-agents/copilotstudio-console/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "copilotstudio-console", 3 | "version": "1.0.0", 4 | "private": true, 5 | "author": "Microsoft", 6 | "license": "MIT", 7 | "main": "./dist/index.js", 8 | "type": "module", 9 | "scripts": { 10 | "build": "tsc --build", 11 | "prestart": "npm run build", 12 | "start": "node --env-file .env ./dist/index.js", 13 | "prebundle": "npm run build", 14 | "bundle": "esbuild dist/index.js --bundle --platform=node --metafile=dist/meta.json --outfile=dist/bundle.js --tree-shaking=true --keep-names" 15 | }, 16 | "dependencies": { 17 | "@microsoft/agents-activity": "file:../../packages/agents-activity", 18 | "@microsoft/agents-copilot-studio": "file:../../packages/agents-copilotstudio-client", 19 | "@azure/msal-node": "^3.8.4", 20 | "open": "^11.0.0" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/message-actions-payload/messageActionsPayloadReaction.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { MessageActionsPayloadFrom } from './messageActionsPayloadFrom' 7 | 8 | /** 9 | * The type of reaction. 10 | */ 11 | export type ReactionType = 'like' | 'heart' | 'laugh' | 'surprised' | 'sad' | 'angry' 12 | 13 | /** 14 | * Represents a reaction in the message actions payload. 15 | */ 16 | export interface MessageActionsPayloadReaction { 17 | /** 18 | * The type of reaction. 19 | */ 20 | reactionType?: ReactionType 21 | /** 22 | * The date and time when the reaction was created. 23 | */ 24 | createdDateTime?: string 25 | /** 26 | * The user who reacted. 27 | */ 28 | user?: MessageActionsPayloadFrom 29 | } 30 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/message-actions-payload/messageActionsPayloadAttachment.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Represents an attachment in the message actions payload. 8 | */ 9 | export interface MessageActionsPayloadAttachment { 10 | /** 11 | * The unique identifier of the attachment. 12 | */ 13 | id?: string 14 | /** 15 | * The content type of the attachment. 16 | */ 17 | contentType?: string 18 | /** 19 | * The URL of the attachment content. 20 | */ 21 | contentUrl?: string 22 | /** 23 | * The content of the attachment. 24 | */ 25 | content?: any 26 | /** 27 | * The name of the attachment. 28 | */ 29 | name?: string 30 | /** 31 | * The URL of the attachment thumbnail. 32 | */ 33 | thumbnailUrl?: string 34 | } 35 | -------------------------------------------------------------------------------- /test-agents/multi-turn-prompt/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "multiturn-prompts-agent", 3 | "version": "1.0.0", 4 | "private": true, 5 | "author": "Microsoft", 6 | "license": "MIT", 7 | "main": "./dist/index.js", 8 | "scripts": { 9 | "build": "tsc --build", 10 | "prestart": "npm run build", 11 | "start": "node --env-file .env ./dist/index.js", 12 | "prebundle": "npm run build", 13 | "bundle": "esbuild dist/index.js --bundle --platform=node --metafile=dist/meta.json --outfile=dist/bundle.js --tree-shaking=true --keep-names", 14 | "predocker": "npm run bundle", 15 | "docker": "docker build -t \"$npm_package_name:$npm_package_version\" ." 16 | }, 17 | "dependencies": { 18 | "@microsoft/agents-hosting-dialogs": "file:../../packages/agents-hosting-dialogs", 19 | "express": "^5.2.1" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/meeting/targetedMeetingNotification.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { MeetingNotificationBase } from './meetingNotificationBase' 7 | import { MeetingNotificationChannelData } from './meetingNotificationChannelData' 8 | import { TargetedMeetingNotificationValue } from './targetedMeetingNotificationValue' 9 | 10 | /** 11 | * Interface representing a targeted meeting notification. 12 | */ 13 | export interface TargetedMeetingNotification extends MeetingNotificationBase { 14 | /** 15 | * The type of the notification. 16 | */ 17 | type: 'targetedMeetingNotification'; 18 | 19 | /** 20 | * The channel data associated with the notification. 21 | */ 22 | channelData?: MeetingNotificationChannelData; 23 | } 24 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/activity-extensions/channelInfo.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { z } from 'zod' 7 | import { ChannelTypes, channelTypeZodSchema } from './channelTypes' 8 | 9 | /** 10 | * Represents information about a channel. 11 | */ 12 | export interface ChannelInfo { 13 | /** 14 | * The ID of the channel. 15 | */ 16 | id?: string 17 | /** 18 | * The name of the channel. 19 | */ 20 | name?: string 21 | /** 22 | * The type of the channel. 23 | */ 24 | type?: ChannelTypes 25 | } 26 | 27 | /** 28 | * Zod schema for validating ChannelInfo objects. 29 | */ 30 | export const channelInfoZodSchema = z.object({ 31 | id: z.string().min(1).optional(), 32 | name: z.string().min(1).optional(), 33 | type: channelTypeZodSchema.optional() 34 | }) 35 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/messageExtension/messagingExtensionActionResponse.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { TaskModuleContinueResponse, TaskModuleMessageResponse } from '../taskModule' 7 | import { MessagingExtensionResult } from './messagingExtensionResult' 8 | 9 | /** 10 | * Represents the response of a messaging extension action. 11 | */ 12 | export interface MessagingExtensionActionResponse { 13 | /** 14 | * The task module response. 15 | */ 16 | task?: TaskModuleContinueResponse | TaskModuleMessageResponse 17 | /** 18 | * The result of the compose extension. 19 | */ 20 | composeExtension?: MessagingExtensionResult 21 | /** 22 | * Cache information for the response. 23 | */ 24 | cacheInfo?: unknown // CacheInfo TODO: Define the type for CacheInfo 25 | } 26 | -------------------------------------------------------------------------------- /test-agents/web-chat/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "webchat-agents", 3 | "version": "1.0.0", 4 | "private": true, 5 | "author": "Microsoft", 6 | "license": "MIT", 7 | "main": "./dist/index.js", 8 | "scripts": { 9 | "build": "tsc --build", 10 | "prestart": "npm run build", 11 | "start": "node --env-file .env ./dist/index.js", 12 | "prebundle": "npm run build", 13 | "bundle": "esbuild dist/index.js --bundle --platform=node --metafile=dist/meta.json --outfile=dist/bundle.js --tree-shaking=true --keep-names", 14 | "predocker": "npm run bundle", 15 | "docker": "docker build -t \"$npm_package_name:$npm_package_version\" ." 16 | }, 17 | "dependencies": { 18 | "@microsoft/agents-hosting": "file:../../packages/agents-hosting", 19 | "@microsoft/microsoft-graph-client": "^3.0.7", 20 | "adaptivecards-templating": "^2.3.1", 21 | "express": "^5.2.1" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /packages/agents-hosting-dialogs/src/dialogTurnStateConstants.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Provides constants used to manage the state of a dialog turn. 8 | * 9 | * @remarks 10 | * These constants are used as keys to store and retrieve specific state information 11 | * during the execution of a dialog turn. 12 | * 13 | */ 14 | export class DialogTurnStateConstants { 15 | /** 16 | * Symbol representing the configuration for the dialog turn. 17 | */ 18 | static configuration = Symbol('configuration') 19 | 20 | /** 21 | * Symbol representing the dialog manager instance. 22 | */ 23 | static dialogManager = Symbol('dialogManager') 24 | 25 | /** 26 | * Symbol representing the queue storage for the dialog turn. 27 | */ 28 | static queueStorage = Symbol('queueStorage') 29 | } 30 | -------------------------------------------------------------------------------- /packages/agents-activity/src/deliveryModes.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { z } from 'zod' 7 | 8 | /** 9 | * Enum representing delivery modes. 10 | */ 11 | export enum DeliveryModes { 12 | /** 13 | * Represents the normal delivery mode. 14 | */ 15 | Normal = 'normal', 16 | 17 | /** 18 | * Represents a notification delivery mode. 19 | */ 20 | Notification = 'notification', 21 | 22 | /** 23 | * Represents a delivery mode where replies are expected. 24 | */ 25 | ExpectReplies = 'expectReplies', 26 | 27 | /** 28 | * Represents an ephemeral delivery mode. 29 | */ 30 | Ephemeral = 'ephemeral', 31 | } 32 | 33 | /** 34 | * Zod schema for validating a DeliveryModes enum. 35 | */ 36 | export const deliveryModesZodSchema = z.enum(['normal', 'notification', 'expectReplies', 'ephemeral']) 37 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/cards/receiptItem.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { CardAction } from '@microsoft/agents-activity' 7 | import { CardImage } from './cardImage' 8 | 9 | /** 10 | * Represents an item in a receipt card. 11 | */ 12 | export interface ReceiptItem { 13 | /** 14 | * The title of the item. 15 | */ 16 | title: string 17 | /** 18 | * The subtitle of the item. 19 | */ 20 | subtitle?: string 21 | /** 22 | * The text of the item. 23 | */ 24 | text?: string 25 | /** 26 | * The image of the item. 27 | */ 28 | image: CardImage 29 | /** 30 | * The price of the item. 31 | */ 32 | price: string 33 | /** 34 | * The quantity of the item. 35 | */ 36 | quantity: number 37 | /** 38 | * The tap action of the item. 39 | */ 40 | tap?: CardAction 41 | } 42 | -------------------------------------------------------------------------------- /packages/agents-hosting-storage-blob/README.md: -------------------------------------------------------------------------------- 1 | # @microsoft/agents-hosting-storage-blob 2 | 3 | ## Overview 4 | 5 | This package allows to configure Azure Blob Storage as the backend for Agents conversation State 6 | 7 | ## Usage with connectionStrings 8 | 9 | ```ts 10 | const blobStorage = new BlobStorage(process.env.BLOB_STORAGE_CONNECTION_STRING!, process.env.BLOB_CONTAINER_ID!) 11 | const conversationState = new ConversationState(blobStorage) 12 | const userState = new UserState(blobStorage) 13 | ``` 14 | 15 | 16 | ## Usage with EntraID authentication 17 | 18 | >note: you must assign RBAC permissions to your storage account 19 | 20 | ```ts 21 | const echo = new AgentApplication({ 22 | storage: new BlobsStorage('', undefined, undefined, 23 | 'https://agentsstate.blob.core.windows.net/nodejs-conversations', 24 | new MsalTokenCredential(loadAuthConfigFromEnv())) 25 | }) 26 | ``` -------------------------------------------------------------------------------- /test-agents/custom-dialogs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "custom-dialogs", 3 | "version": "1.0.0", 4 | "private": true, 5 | "description": "Agents SKD custom-dialogs agent for testing and development", 6 | "author": "Microsoft", 7 | "license": "MIT", 8 | "main": "./dist/index.js", 9 | "scripts": { 10 | "build": "tsc --build", 11 | "prestart": "npm run build", 12 | "start": "node --env-file .env ./dist/index.js", 13 | "prebundle": "npm run build", 14 | "bundle": "esbuild dist/index.js --bundle --platform=node --metafile=dist/meta.json --outfile=dist/bundle.js --tree-shaking=true --keep-names", 15 | "docker": "docker build -t \"$npm_package_name:$npm_package_version\" ." 16 | }, 17 | "dependencies": { 18 | "@microsoft/agents-hosting-dialogs": "file:../../packages/agents-hosting-dialogs", 19 | "express": "^5.2.1" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/meeting/teamsMeetingParticipant.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { ConversationAccount } from '@microsoft/agents-activity' 7 | import { Meeting } from './meeting' 8 | import { TeamsChannelAccount } from '../activity-extensions/teamsChannelAccount' 9 | import { TurnState } from '@microsoft/agents-hosting' 10 | 11 | /** 12 | * Interface representing a participant in a Teams meeting. 13 | */ 14 | export interface TeamsMeetingParticipant { 15 | /** 16 | * The user participating in the meeting. 17 | */ 18 | user?: TeamsChannelAccount; 19 | 20 | /** 21 | * The meeting details. 22 | */ 23 | meeting?: Meeting; 24 | 25 | /** 26 | * The conversation account associated with the meeting. 27 | */ 28 | conversation?: ConversationAccount; 29 | } 30 | -------------------------------------------------------------------------------- /packages/agents-hosting-dialogs/src/choices/modelResult.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Represents the result of a model recognition process. 8 | * 9 | * @typeParam T - The type of the resolution containing additional details about the match. 10 | */ 11 | export interface ModelResult = {}> { 12 | /** 13 | * The text that was matched. 14 | */ 15 | text: string; 16 | 17 | /** 18 | * The start index of the match in the input text. 19 | */ 20 | start: number; 21 | 22 | /** 23 | * The end index of the match in the input text. 24 | */ 25 | end: number; 26 | 27 | /** 28 | * The type of the recognized model result. 29 | */ 30 | typeName: string; 31 | 32 | /** 33 | * The resolution containing additional details about the match. 34 | */ 35 | resolution: T; 36 | } 37 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/activity-extensions/notificationInfo.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { z } from 'zod' 7 | 8 | /** 9 | * Represents information about a notification. 10 | */ 11 | export interface NotificationInfo { 12 | /** 13 | * Indicates whether the notification is an alert. 14 | */ 15 | alert?: boolean 16 | /** 17 | * Indicates whether the alert is in a meeting. 18 | */ 19 | alertInMeeting?: boolean 20 | /** 21 | * The URL of the external resource. 22 | */ 23 | externalResourceUrl?: string 24 | } 25 | 26 | /** 27 | * Zod schema for validating NotificationInfo objects. 28 | */ 29 | export const notificationInfoZodSchema = z.object({ 30 | alert: z.boolean().optional(), 31 | alertInMeeting: z.boolean().optional(), 32 | externalResourceUrl: z.string().min(1).optional() 33 | }) 34 | -------------------------------------------------------------------------------- /packages/agents-hosting/test/activity-value-parsers/parseValueBotMessagePreviewAction.test.ts: -------------------------------------------------------------------------------- 1 | import assert from 'assert' 2 | import { describe, it } from 'node:test' 3 | import { ZodError } from 'zod' 4 | import { parseValueAgentMessagePreviewAction } from '../../src/app/adaptiveCards/activityValueParsers' 5 | 6 | describe('parseValueBotMessagePreviewAction test', () => { 7 | it('Parse with all properties', () => { 8 | const valueObject = { 9 | botMessagePreviewAction: 'botMessagePreviewAction' 10 | } 11 | const parsedValue = parseValueAgentMessagePreviewAction(valueObject) 12 | assert.deepEqual(parsedValue, valueObject) 13 | }) 14 | 15 | it('Should throw with not string botMessagePreviewAction', () => { 16 | const valueObject = { 17 | botMessagePreviewAction: 1 18 | } 19 | assert.throws(() => { 20 | parseValueAgentMessagePreviewAction(valueObject) 21 | }, ZodError) 22 | }) 23 | }) 24 | -------------------------------------------------------------------------------- /samples/basic/traceActivities.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | import { startServer } from '@microsoft/agents-hosting-express' 5 | import { AgentApplication, MemoryStorage, TurnContext, TurnState } from '@microsoft/agents-hosting' 6 | 7 | const agent = new AgentApplication({ storage: new MemoryStorage() }) 8 | 9 | agent.onConversationUpdate('membersAdded', async (context: TurnContext) => { 10 | await context.sendActivity('Welcome to the Trace Activities sample, send a message to see the feature in action.\nTrace activities are only shown in the Emulator channel.') 11 | }) 12 | 13 | agent.onActivity('message', async (context: TurnContext) => { 14 | await context.sendTraceActivity('Testing Trace', 'This is a trace activity') 15 | await context.sendActivity('I sent you a Trace activity. Check the inspection panel') 16 | }) 17 | 18 | startServer(agent) 19 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/message-actions-payload/messageActionsPayloadFrom.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { MessageActionsPayloadApp } from './messageActionsPayloadApp' 7 | import { MessageActionsPayloadConversation } from './messageActionsPayloadConversation' 8 | import { MessageActionsPayloadUser } from './messageActionsPayloadUser' 9 | 10 | /** 11 | * Represents the sender of the message in the message actions payload. 12 | */ 13 | export interface MessageActionsPayloadFrom { 14 | /** 15 | * The user who sent the message. 16 | */ 17 | user?: MessageActionsPayloadUser 18 | /** 19 | * The application that sent the message. 20 | */ 21 | application?: MessageActionsPayloadApp 22 | /** 23 | * The conversation in which the message was sent. 24 | */ 25 | conversation?: MessageActionsPayloadConversation 26 | } 27 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/feedbackLoopData.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Data returned when feedback has been enabled and a messages thumbs-up or thumbs-down button 3 | * is clicked. 4 | */ 5 | export interface FeedbackLoopData { 6 | /** 7 | * The name of the action, which is always 'feedback' for feedback loop data. 8 | */ 9 | actionName: 'feedback'; 10 | 11 | /** 12 | * The value of the action, which contains the reaction and feedback provided by the user. 13 | */ 14 | actionValue: { 15 | /** 16 | * 'like' or 'dislike' 17 | */ 18 | reaction: 'like' | 'dislike'; 19 | 20 | /** 21 | * The response the user provides when prompted with "What did you like/dislike?" after pressing 22 | * one of the feedback buttons. 23 | */ 24 | feedback: string | Record; 25 | }; 26 | 27 | /** 28 | * The activity ID that the feedback was provided on. 29 | */ 30 | replyToId: string; 31 | } 32 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/activity-extensions/teamInfo.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { z } from 'zod' 7 | 8 | /** 9 | * Represents information about a team. 10 | */ 11 | export interface TeamInfo { 12 | /** 13 | * The ID of the team. 14 | */ 15 | id?: string 16 | /** 17 | * The name of the team. 18 | */ 19 | name?: string 20 | /** 21 | * The Azure Active Directory group ID of the team. 22 | */ 23 | aadGroupId?: string 24 | 25 | /** 26 | * The tenant ID of the team. 27 | */ 28 | tenantId?: string 29 | } 30 | 31 | /** 32 | * Zod schema for validating TeamInfo objects. 33 | */ 34 | export const teamInfoZodSchema = z.object({ 35 | id: z.string().min(1).optional(), 36 | name: z.string().min(1).optional(), 37 | aadGroupId: z.string().min(1).optional(), 38 | tenantId: z.string().min(1).optional() 39 | }) 40 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | export * from './auth/' 7 | export { authorizeJWT } from './auth/jwt-middleware' 8 | 9 | export * from './app' 10 | export * from './cards' 11 | export * from './connector-client' 12 | export { Errors as HostingErrors } from './errorHelper' 13 | export * from './invoke' 14 | export * from './oauth' 15 | export * from './state' 16 | export * from './storage' 17 | export * from './transcript' 18 | 19 | export * from './activityHandler' 20 | export * from './baseAdapter' 21 | export * from './cloudAdapter' 22 | export * from './middlewareSet' 23 | export * from './messageFactory' 24 | export * from './statusCodes' 25 | export * from './turnContext' 26 | export * from './turnContextStateCollection' 27 | export * from './storage/storage' 28 | export * from './headerPropagation' 29 | 30 | export * from './agent-client' 31 | -------------------------------------------------------------------------------- /packages/agents-hosting-dialogs/src/memory/componentMemoryScopes.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import * as z from 'zod' 7 | import { MemoryScope } from './scopes' 8 | 9 | /** 10 | * Interface for enumerating memory scopes. 11 | */ 12 | export interface ComponentMemoryScopes { 13 | getMemoryScopes(): MemoryScope[]; 14 | } 15 | 16 | const componentMemoryScopes = z.custom((val: any) => typeof val.getMemoryScopes === 'function', { 17 | message: 'ComponentMemoryScopes', 18 | }) 19 | 20 | /** 21 | * Check if a ComponentRegistration is ComponentMemoryScopes or not. 22 | * 23 | * @param {any} component The component registration. 24 | * @returns {boolean} Type check result. 25 | */ 26 | export function isComponentMemoryScopes (component: unknown): component is ComponentMemoryScopes { 27 | return componentMemoryScopes.safeParse(component).success 28 | } 29 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/cards/o365ConnectorCard.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { O365ConnectorCardActionBase } from './o365ConnectorCardActionBase' 7 | import { O365ConnectorCardSection } from './o365ConnectorCardSection' 8 | 9 | /** 10 | * Represents an O365 connector card. 11 | */ 12 | export interface O365ConnectorCard { 13 | /** 14 | * The title of the card. 15 | */ 16 | title?: string; 17 | /** 18 | * The text of the card. 19 | */ 20 | text?: string; 21 | /** 22 | * The summary of the card. 23 | */ 24 | summary?: string; 25 | /** 26 | * The theme color of the card. 27 | */ 28 | themeColor?: string; 29 | /** 30 | * The sections of the card. 31 | */ 32 | sections?: O365ConnectorCardSection[]; 33 | /** 34 | * The potential actions of the card. 35 | */ 36 | potentialAction?: O365ConnectorCardActionBase[]; 37 | } 38 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/meeting/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | export * from './meetingDetailsBase' 7 | export * from './meetingEndEventDetails' 8 | export * from './meetingEventDetails' 9 | export * from './meetingParticipantsEventDetails' 10 | export * from './meetingStartEventDetails' 11 | export * from './teamsMeetingMember' 12 | export * from './userMeetingDetails' 13 | export * from './targetedMeetingNotification' 14 | export * from './meetingDetails' 15 | export * from './meetingNotificationRecipientFailureInfo' 16 | export * from './teamsMeetingParticipant' 17 | export * from './meetingNotificationChannelData' 18 | export * from './meeting' 19 | export * from './targetedMeetingNotificationValue' 20 | export * from './meetingSurface' 21 | export * from './meetingStageSurface' 22 | export * from './meetingTabIconSurface' 23 | export * from './meetingNotification' 24 | -------------------------------------------------------------------------------- /packages/agents-activity/src/conversation/roleTypes.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { z } from 'zod' 7 | 8 | /** 9 | * Enum representing the different role types in a conversation. 10 | */ 11 | export enum RoleTypes { 12 | /** 13 | * Represents a user in the conversation. 14 | */ 15 | User = 'user', 16 | 17 | /** 18 | * Represents an agent or bot in the conversation. 19 | */ 20 | Agent = 'bot', 21 | 22 | /** 23 | * Represents a skill in the conversation. 24 | */ 25 | Skill = 'skill', 26 | 27 | /** 28 | * Agentic AI - AAI role 29 | */ 30 | AgenticIdentity = 'agenticAppInstance', 31 | 32 | /** 33 | * Agentic AI - AAI role. 34 | */ 35 | AgenticUser = 'agenticUser' 36 | } 37 | 38 | /** 39 | * Zod schema for validating role types. 40 | */ 41 | export const roleTypeZodSchema = z.enum(['user', 'bot', 'skill', 'agenticAppInstance', 'agenticUser']) 42 | -------------------------------------------------------------------------------- /packages/agents-activity/src/invoke/adaptiveCardInvokeAction.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { z } from 'zod' 7 | 8 | /** 9 | * Represents an adaptive card invoke action. 10 | */ 11 | export interface AdaptiveCardInvokeAction { 12 | /** 13 | * The type of the action. 14 | */ 15 | type: string 16 | /** 17 | * The unique identifier of the action. 18 | */ 19 | id?: string 20 | /** 21 | * The verb associated with the action. 22 | */ 23 | verb: string 24 | /** 25 | * Additional data associated with the action. 26 | */ 27 | data: Record 28 | } 29 | 30 | /** 31 | * Zod schema for validating an adaptive card invoke action. 32 | */ 33 | export const adaptiveCardInvokeActionZodSchema = z.object({ 34 | type: z.string().min(1), 35 | id: z.string().optional(), 36 | verb: z.string().min(1), 37 | data: z.record(z.string().min(1), z.any()) 38 | }) 39 | -------------------------------------------------------------------------------- /packages/agents-hosting-dialogs/src/memory/componentPathResolvers.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import * as z from 'zod' 7 | import { PathResolver } from './pathResolvers' 8 | 9 | /** 10 | * Interface for declaring path resolvers. 11 | */ 12 | export interface ComponentPathResolvers { 13 | getPathResolvers(): PathResolver[]; 14 | } 15 | 16 | const componentPathResolvers = z.custom( 17 | (val: any) => typeof val.getPathResolvers === 'function', 18 | { message: 'ComponentPathResolvers' } 19 | ) 20 | 21 | /** 22 | * Check if a ComponentRegistration is ComponentPathResolvers or not. 23 | * 24 | * @param {any} component The component registration. 25 | * @returns {boolean} Type check result. 26 | */ 27 | export function isComponentPathResolvers (component: unknown): component is ComponentPathResolvers { 28 | return componentPathResolvers.safeParse(component).success 29 | } 30 | -------------------------------------------------------------------------------- /packages/agents-hosting-storage-cosmos/src/cosmosDbPartitionedStorageOptions.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | import { CosmosClientOptions } from '@azure/cosmos' 5 | 6 | /** 7 | * Options for configuring Cosmos DB partitioned storage. 8 | */ 9 | export interface CosmosDbPartitionedStorageOptions { 10 | /** 11 | * The ID of the database. 12 | */ 13 | databaseId: string; 14 | /** 15 | * The ID of the container. 16 | */ 17 | containerId: string; 18 | /** 19 | * The throughput of the container. 20 | */ 21 | containerThroughput?: number; 22 | /** 23 | * The suffix to append to keys. 24 | */ 25 | keySuffix?: string; 26 | /** 27 | * Indicates whether compatibility mode is enabled. 28 | */ 29 | compatibilityMode?: boolean; 30 | 31 | /** 32 | * The options for the Cosmos client. 33 | */ 34 | cosmosClientOptions?: CosmosClientOptions; 35 | // tokenCredential?: TokenCredential; 36 | } 37 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/invoke/invokeException.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { StatusCodes } from '../statusCodes' 7 | import { InvokeResponse } from './invokeResponse' 8 | 9 | /** 10 | * Represents an exception that occurs during an invoke operation. 11 | */ 12 | export class InvokeException extends Error { 13 | /** 14 | * Creates a new instance of InvokeException. 15 | * @param status The status code of the exception. 16 | * @param response The optional response body. 17 | */ 18 | constructor (private readonly status: StatusCodes, private readonly response?: T) { 19 | super() 20 | this.name = 'InvokeException' 21 | } 22 | 23 | /** 24 | * Creates an invoke response from the exception. 25 | * @returns The invoke response. 26 | */ 27 | createInvokeResponse (): InvokeResponse { 28 | return { 29 | status: this.status, 30 | body: this.response 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /samples/state/blob2Cnx.ts: -------------------------------------------------------------------------------- 1 | import { startServer } from '@microsoft/agents-hosting-express' 2 | import { AgentApplication, loadAuthConfigFromEnv, TurnContext, TurnState, MsalTokenCredential } from '@microsoft/agents-hosting' 3 | import { BlobsStorage } from '@microsoft/agents-hosting-storage-blob' 4 | 5 | const echo = new AgentApplication({ 6 | storage: new BlobsStorage('testing', 'UseDevelopmentStorage=true;', undefined, undefined, 7 | new MsalTokenCredential(loadAuthConfigFromEnv('blob'))) 8 | }) 9 | echo.onConversationUpdate('membersAdded', async (context: TurnContext) => { 10 | await context.sendActivity('Welcome to the Blob2Cnx sample, send a message to see the echo feature in action.') 11 | }) 12 | echo.onActivity('message', async (context: TurnContext, state: TurnState) => { 13 | let counter: number = state.getValue('conversation.counter') || 0 14 | await context.sendActivity(`[${counter++}]You said: ${context.activity.text}`) 15 | state.setValue('conversation.counter', counter) 16 | }) 17 | 18 | startServer(echo) 19 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/cards/o365ConnectorCardActionBase.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Defines the possible types of actions in an O365 connector card. 8 | * 9 | * - `ViewAction`: Represents an action to view content. 10 | * - `OpenUri`: Represents an action to open a URI. 11 | * - `HttpPOST`: Represents an action to make an HTTP POST request. 12 | * - `ActionCard`: Represents an action that opens a card with additional actions or inputs. 13 | */ 14 | export type O365ConnectorCardActionType = 'ViewAction' | 'OpenUri' | 'HttpPOST' | 'ActionCard' 15 | 16 | /** 17 | * Represents a base action in an O365 connector card. 18 | */ 19 | export interface O365ConnectorCardActionBase { 20 | /** 21 | * The type of the action. 22 | */ 23 | '@type'?: O365ConnectorCardActionType; 24 | /** 25 | * The name of the action. 26 | */ 27 | name?: string; 28 | /** 29 | * The ID of the action. 30 | */ 31 | '@id'?: string; 32 | } 33 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/cards/receiptCard.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { CardAction } from '@microsoft/agents-activity' 7 | import { Fact } from './fact' 8 | import { ReceiptItem } from './receiptItem' 9 | 10 | /** 11 | * Represents a receipt card. 12 | */ 13 | export interface ReceiptCard { 14 | /** 15 | * The title of the card. 16 | */ 17 | title: string; 18 | /** 19 | * The facts of the card. 20 | */ 21 | facts: Fact[]; 22 | /** 23 | * The items of the card. 24 | */ 25 | items: ReceiptItem[]; 26 | /** 27 | * The tap action of the card. 28 | */ 29 | tap?: CardAction; 30 | /** 31 | * The total amount of the receipt. 32 | */ 33 | total: string; 34 | /** 35 | * The tax amount of the receipt. 36 | */ 37 | tax: string; 38 | /** 39 | * The VAT amount of the receipt. 40 | */ 41 | vat?: string; 42 | /** 43 | * The buttons of the card. 44 | */ 45 | buttons: CardAction[]; 46 | } 47 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/activity-extensions/onBehalfOf.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { z } from 'zod' 7 | 8 | /** 9 | * Represents information about a user on behalf of whom an action is performed. 10 | */ 11 | export interface OnBehalfOf { 12 | /** 13 | * The ID of the item. 14 | */ 15 | itemid: 0 | number 16 | /** 17 | * The type of mention. 18 | */ 19 | mentionType: 'person' | string 20 | /** 21 | * The Microsoft Resource Identifier (MRI) of the user. 22 | */ 23 | mri: string 24 | /** 25 | * The display name of the user. 26 | */ 27 | displayName?: string 28 | } 29 | 30 | /** 31 | * Zod schema for validating OnBehalfOf objects. 32 | */ 33 | export const onBehalfOfZodSchema = z.object({ 34 | itemid: z.union([z.literal(0), z.number()]), 35 | mentionType: z.union([z.string().min(1), z.literal('person')]), 36 | mri: z.string().min(1), 37 | displayName: z.string().min(1).optional() 38 | }) 39 | -------------------------------------------------------------------------------- /packages/agents-hosting-dialogs/src/i18n.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | const Chinese = require('../../vendor/cldr-data/main/zh/numbers.json') 7 | const English = require('../../vendor/cldr-data/main/en/numbers.json') 8 | const French = require('../../vendor/cldr-data/main/fr/numbers.json') 9 | const German = require('../../vendor/cldr-data/main/de/numbers.json') 10 | const Dutch = require('../../vendor/cldr-data/main/nl/numbers.json') 11 | const Japanese = require('../../vendor/cldr-data/main/ja/numbers.json') 12 | const LikelySubtags = require('../../vendor/cldr-data/supplemental/likelySubtags.json') 13 | const NumberingSystem = require('../../vendor/cldr-data/supplemental/numberingSystems.json') 14 | const Portuguese = require('../../vendor/cldr-data/main/pt/numbers.json') 15 | const Spanish = require('../../vendor/cldr-data/main/es/numbers.json') 16 | 17 | export { Chinese, English, French, German, Dutch, Japanese, LikelySubtags, NumberingSystem, Portuguese, Spanish } 18 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/message-actions-payload/messageActionsPayloadUser.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Defines the type of user identity in the message actions payload. 8 | * - `aadUser`: Represents an Azure Active Directory user. 9 | * - `onPremiseAadUser`: Represents an on-premises Azure Active Directory user. 10 | * - `anonymousGuest`: Represents an anonymous guest user. 11 | * - `federatedUser`: Represents a federated user. 12 | */ 13 | export type UserIdentityType = 'aadUser' | 'onPremiseAadUser' | 'anonymousGuest' | 'federatedUser' 14 | 15 | /** 16 | * Represents a user in the message actions payload. 17 | */ 18 | export interface MessageActionsPayloadUser { 19 | /** 20 | * The type of user identity. 21 | */ 22 | userIdentityType?: UserIdentityType 23 | /** 24 | * The unique identifier of the user. 25 | */ 26 | id?: string 27 | /** 28 | * The display name of the user. 29 | */ 30 | displayName?: string 31 | } 32 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/src/taskModule/taskModuleTaskInfo.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { Attachment } from '@microsoft/agents-activity' 7 | 8 | /** 9 | * Interface representing the task module task information. 10 | */ 11 | export interface TaskModuleTaskInfo { 12 | /** 13 | * The title of the task module. 14 | */ 15 | title?: string 16 | /** 17 | * The height of the task module. 18 | */ 19 | height?: number | 'small' | 'medium' | 'large' 20 | /** 21 | * The width of the task module. 22 | */ 23 | width?: number | 'small' | 'medium' | 'large' 24 | /** 25 | * The URL of the task module. 26 | */ 27 | url?: string 28 | /** 29 | * The card attachment of the task module. 30 | */ 31 | card?: Attachment 32 | /** 33 | * The fallback URL of the task module. 34 | */ 35 | fallbackUrl?: string 36 | /** 37 | * The completion agent ID of the task module. 38 | */ 39 | completionAgentId?: string 40 | } 41 | -------------------------------------------------------------------------------- /packages/agents-activity/src/action/semanticAction.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { z } from 'zod' 7 | import { Entity, entityZodSchema } from '../entity/entity' 8 | import { SemanticActionStateTypes, semanticActionStateTypesZodSchema } from './semanticActionStateTypes' 9 | 10 | /** 11 | * Represents a semantic action. 12 | */ 13 | export interface SemanticAction { 14 | /** 15 | * Unique identifier for the semantic action. 16 | */ 17 | id: string 18 | /** 19 | * State of the semantic action. 20 | */ 21 | state: SemanticActionStateTypes | string 22 | /** 23 | * Entities associated with the semantic action. 24 | */ 25 | entities: { [propertyName: string]: Entity } 26 | } 27 | 28 | /** 29 | * Zod schema for validating SemanticAction. 30 | */ 31 | export const semanticActionZodSchema = z.object({ 32 | id: z.string().min(1), 33 | state: z.union([semanticActionStateTypesZodSchema, z.string().min(1)]), 34 | entities: z.record(entityZodSchema) 35 | }) 36 | -------------------------------------------------------------------------------- /packages/agents-activity/test/activity/activity.treatment.tests.ts: -------------------------------------------------------------------------------- 1 | import { strict as assert } from 'assert' 2 | import { describe, it } from 'node:test' 3 | import { Activity, ActivityTreatments, ActivityTypes, Entity } from '../../src' 4 | 5 | describe('activity treatment roundtrip', () => { 6 | it('should roundtrip from object to json and back', () => { 7 | const activity = new Activity(ActivityTypes.Message) 8 | activity.text = 'Hello' 9 | activity.entities = [ 10 | { 11 | type: 'activityTreatment', 12 | treatment: ActivityTreatments.Targeted, 13 | } as unknown as Entity 14 | ] 15 | 16 | const parsedValue = JSON.parse(JSON.stringify(activity)) 17 | const act = Activity.fromObject(parsedValue) 18 | 19 | assert.strictEqual(act.type, ActivityTypes.Message) 20 | assert.strictEqual(act.text, 'Hello') 21 | assert.strictEqual(act.entities?.length, 1) 22 | assert.strictEqual(act.entities[0].type, 'activityTreatment') 23 | assert.strictEqual(act.entities[0].treatment, ActivityTreatments.Targeted) 24 | }) 25 | }) 26 | -------------------------------------------------------------------------------- /packages/agents-activity/src/conversation/conversationParameters.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { Activity, ChannelAccount } from '../' 7 | 8 | /** 9 | * Represents the parameters for creating a conversation. 10 | */ 11 | export interface ConversationParameters { 12 | /** 13 | * Indicates whether the conversation is a group conversation. 14 | */ 15 | isGroup: boolean 16 | /** 17 | * The bot account initiating the conversation. 18 | */ 19 | agent?: ChannelAccount 20 | /** 21 | * The members to include in the conversation. 22 | */ 23 | members?: ChannelAccount[] 24 | /** 25 | * The topic name of the conversation. 26 | */ 27 | topicName?: string 28 | /** 29 | * The tenant ID of the conversation. 30 | */ 31 | tenantId?: string 32 | /** 33 | * The initial activity to send to the conversation. 34 | */ 35 | activity: Activity 36 | /** 37 | * Channel-specific data for the conversation. 38 | */ 39 | channelData: unknown 40 | } 41 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/auth/request.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { JwtPayload } from 'jsonwebtoken' 7 | 8 | /** 9 | * Represents a Node.js HTTP Request, including the minimal set of use properties. 10 | * Compatible with Restify, Express, and Node.js core http. 11 | */ 12 | export interface Request< 13 | Body extends Record = Record, 14 | Headers extends Record = Record 15 | > { 16 | /** 17 | * The body of the HTTP request, containing parsed data. 18 | */ 19 | body?: Body 20 | 21 | /** 22 | * The headers of the HTTP request, represented as key-value pairs. 23 | */ 24 | headers: Headers 25 | 26 | /** 27 | * The HTTP method of the request (e.g., GET, POST, PUT, DELETE). 28 | */ 29 | method?: string 30 | 31 | /** 32 | * The user information extracted from a JWT payload, if available. 33 | */ 34 | user?: JwtPayload 35 | } 36 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/transcript/transcriptLogger.ts: -------------------------------------------------------------------------------- 1 | import { Activity } from '@microsoft/agents-activity' 2 | 3 | /** 4 | * Interface for logging activities to a transcript. 5 | */ 6 | export interface TranscriptLogger { 7 | /** 8 | * Logs an activity. 9 | * @param activity - The activity to log. 10 | */ 11 | logActivity(activity: Activity): void | Promise; 12 | } 13 | 14 | /** 15 | * Information about a transcript. 16 | */ 17 | export interface TranscriptInfo { 18 | /** 19 | * The ID of the channel. 20 | */ 21 | channelId: string; 22 | /** 23 | * The ID of the transcript. 24 | */ 25 | id: string; 26 | /** 27 | * The creation date of the transcript. 28 | */ 29 | created: Date; 30 | } 31 | 32 | /** 33 | * Paged result of items. 34 | * @typeParam T - The type of items in the paged result. 35 | */ 36 | export interface PagedResult { 37 | /** 38 | * The items in the paged result. 39 | */ 40 | items: T[]; 41 | /** 42 | * The continuation token for pagination. 43 | */ 44 | continuationToken?: string; 45 | } 46 | -------------------------------------------------------------------------------- /packages/agents-hosting-dialogs/src/dialogInstance.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains state information for an instance of a dialog on the stack. 3 | * 4 | * @typeParam T Optional. The type that represents state information for the dialog. 5 | * 6 | * @remarks 7 | * This contains information for a specific instance of a dialog on a dialog stack. 8 | * The dialog stack is associated with a specific dialog context and dialog set. 9 | * Information about the dialog stack as a whole is persisted to storage using a dialog state object. 10 | * 11 | */ 12 | export interface DialogInstance { 13 | /** 14 | * ID of this dialog 15 | * 16 | * @remarks 17 | * Dialog state is associated with a specific dialog set. 18 | * This ID is the the dialog's Dialog.id within that dialog set. 19 | * 20 | */ 21 | id: string; 22 | 23 | /** 24 | * The state information for this instance of this dialog. 25 | */ 26 | state: T; 27 | 28 | /** 29 | * Hash code used to detect that a dialog has changed since the current instance was started. 30 | */ 31 | version?: string; 32 | } 33 | -------------------------------------------------------------------------------- /packages/agents-hosting-storage-blob/src/ignoreError.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * A function type that determines whether an error should be ignored. 3 | * @param err - The error to check. 4 | * @returns A boolean indicating whether the error should be ignored. 5 | */ 6 | export type IgnoreError = (err: Error) => boolean 7 | 8 | export async function ignoreError (promise: Promise, ignore: IgnoreError): Promise { 9 | try { 10 | return await promise 11 | } catch (err: any) { 12 | if (!ignore(err)) { 13 | throw err 14 | } else { 15 | return null 16 | } 17 | } 18 | } 19 | 20 | /** 21 | * An interface representing an error with an optional status code. 22 | */ 23 | interface ErrorWithStatusCode { 24 | statusCode?: number; 25 | } 26 | 27 | export function isStatusCodeError (...codes: number[]): IgnoreError { 28 | const ignoredCodes = new Set(codes) 29 | return function (err) { 30 | return ( 31 | typeof (err as ErrorWithStatusCode).statusCode === 'number' && 32 | ignoredCodes.has((err as ErrorWithStatusCode).statusCode!) 33 | ) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /packages/agents-activity/src/attachment/attachment.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { z } from 'zod' 7 | 8 | /** 9 | * Represents an attachment. 10 | */ 11 | export interface Attachment { 12 | /** 13 | * The MIME type of the attachment content. 14 | */ 15 | contentType: string 16 | 17 | /** 18 | * The URL of the attachment content. 19 | */ 20 | contentUrl?: string 21 | 22 | /** 23 | * The content of the attachment. 24 | */ 25 | content?: unknown 26 | 27 | /** 28 | * The name of the attachment. 29 | */ 30 | name?: string 31 | 32 | /** 33 | * The URL of the thumbnail for the attachment. 34 | */ 35 | thumbnailUrl?: string 36 | } 37 | 38 | /** 39 | * Zod schema for validating attachments. 40 | */ 41 | export const attachmentZodSchema = z.object({ 42 | contentType: z.string().min(1), 43 | contentUrl: z.string().min(1).optional(), 44 | content: z.unknown().optional(), 45 | name: z.string().min(1).optional(), 46 | thumbnailUrl: z.string().min(1).optional() 47 | }) 48 | -------------------------------------------------------------------------------- /packages/agents-hosting-dialogs/src/dialogEvent.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Represents an event that occurs within a dialog, providing details such as its name, whether it should bubble to parent contexts, and any associated value. 3 | */ 4 | export interface DialogEvent { 5 | /** 6 | * Flag indicating whether the event will be bubbled to the parent `DialogContext`. 7 | */ 8 | bubble: boolean; 9 | 10 | /** 11 | * Name of the event being raised. 12 | */ 13 | name: string; 14 | 15 | /** 16 | * Optional. Value associated with the event. 17 | */ 18 | value?: any; 19 | } 20 | 21 | /** 22 | * Configuration options for dialog initialization and behavior. 23 | * This interface defines the settings that can be applied when creating or configuring a dialog instance. 24 | */ 25 | export interface DialogConfiguration { 26 | /** 27 | * Optional static identifier for the dialog. 28 | * When provided, this unique identifier can be used to reference and manage the dialog instance 29 | * throughout its lifecycle. If not specified, the dialog will operate without a persistent identifier. 30 | */ 31 | id?: string; 32 | } 33 | -------------------------------------------------------------------------------- /packages/agents-activity/src/entity/productInfo.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { Activity } from '../activity' 7 | import { Entity } from './entity' 8 | 9 | export interface ProductInfo extends Entity { 10 | type: 'ProductInfo'; 11 | id: string; 12 | } 13 | 14 | /** 15 | * Remove any ProductInfo entities from the activity 16 | * @param activity 17 | */ 18 | export const clearProductInfoFromActivity = (activity: Activity): void => { 19 | if (activity && activity.entities && activity.entities.length) { 20 | activity.entities = activity.entities.filter(e => e.type !== 'ProductInfo') 21 | } 22 | } 23 | 24 | /** 25 | * Add a new ProductInfo entity to the activity and ensure only one exists 26 | * @param activity 27 | * @param id 28 | */ 29 | export const addProductInfoToActivity = (activity: Activity, id: string) : void => { 30 | const productInfo: ProductInfo = { 31 | type: 'ProductInfo', 32 | id 33 | } 34 | activity.entities ??= [] 35 | clearProductInfoFromActivity(activity) 36 | activity.entities?.push(productInfo) 37 | } 38 | -------------------------------------------------------------------------------- /packages/agents-hosting-dialogs/src/dialogTurnStatus.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Represents the state of the dialog stack after a dialog context attempts to begin, continue, 3 | * or otherwise manipulate one or more dialogs. 4 | * 5 | */ 6 | export enum DialogTurnStatus { 7 | /** 8 | * The dialog stack is empty. 9 | * 10 | * @remarks 11 | * Indicates that the dialog stack was initially empty when the operation was attempted. 12 | * 13 | */ 14 | empty = 'empty', 15 | 16 | /** 17 | * The active dialog on top of the stack is waiting for a response from the user. 18 | */ 19 | waiting = 'waiting', 20 | 21 | /** 22 | * The last dialog on the stack completed successfully. 23 | * 24 | * @remarks 25 | * Indicates that a result might be available and the stack is now empty. 26 | * 27 | */ 28 | complete = 'complete', 29 | 30 | /** 31 | * All dialogs on the stack were cancelled and the stack is empty. 32 | */ 33 | cancelled = 'cancelled', 34 | 35 | /** 36 | * Current dialog completed successfully, but turn should end. 37 | */ 38 | completeAndWait = 'completeAndWait', 39 | } 40 | -------------------------------------------------------------------------------- /packages/agents-hosting-dialogs/src/componentRegistration.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * ComponentRegistration is a signature class for discovering assets from components. 8 | */ 9 | export class ComponentRegistration { 10 | private static readonly _components: Map = new Map() 11 | 12 | /** 13 | * Gets list of all ComponentRegistration objects registered. 14 | * 15 | * @returns A list of ComponentRegistration objects. 16 | */ 17 | static get components (): ComponentRegistration[] { 18 | return Array.from(ComponentRegistration._components.values()) 19 | } 20 | 21 | /** 22 | * Add a component, only one instance per type is allowed for components. 23 | * 24 | * @param componentRegistration The component to be registered. 25 | */ 26 | static add (componentRegistration: ComponentRegistration): void { 27 | const name = componentRegistration.constructor.name 28 | ComponentRegistration._components.set(name, componentRegistration) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/agents-activity/test/activity/activityType.test.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/no-unused-vars */ 2 | import assert from 'assert' 3 | import { describe, it } from 'node:test' 4 | import { ZodError } from 'zod' 5 | import { Activity, ActivityTypes } from '../../src' 6 | 7 | describe('ActivityType enum validation', () => { 8 | Object.values(ActivityTypes).forEach(type => { 9 | it(`should create an Activity with type ${type}`, () => { 10 | const a: Activity = new Activity(type) 11 | assert.strictEqual(a.type, type) 12 | }) 13 | }) 14 | 15 | it('should fail to create an Activity with type null', () => { 16 | assert.throws(() => { 17 | const a: Activity = Activity.fromObject({ type: null }) 18 | }, ZodError) 19 | }) 20 | 21 | it('should fail to create an Activity with type empty', () => { 22 | assert.throws(() => { 23 | const a: Activity = Activity.fromObject({ type: '' }) 24 | }, ZodError) 25 | }) 26 | 27 | it('should fail to create an Activity with type undefined', () => { 28 | assert.throws(() => { 29 | const a: Activity = Activity.fromObject({ }) 30 | }, ZodError) 31 | }) 32 | }) 33 | -------------------------------------------------------------------------------- /packages/agents-hosting-dialogs/src/dialogEvents.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | /** 7 | * Represents the events related to the "lifecycle" of the dialog. 8 | * 9 | * These events are used to signal various stages or actions within a dialog's lifecycle. 10 | */ 11 | export class DialogEvents { 12 | /** 13 | * Event triggered when a dialog begins. 14 | */ 15 | static readonly beginDialog = 'beginDialog' 16 | 17 | /** 18 | * Event triggered to reprompt a dialog. 19 | */ 20 | static readonly repromptDialog = 'repromptDialog' 21 | 22 | /** 23 | * Event triggered when a dialog is canceled. 24 | */ 25 | static readonly cancelDialog = 'cancelDialog' 26 | 27 | /** 28 | * Event triggered when an activity is received. 29 | */ 30 | static readonly activityReceived = 'activityReceived' 31 | 32 | /** 33 | * Event triggered when the dialog version changes. 34 | */ 35 | static readonly versionChanged = 'versionChanged' 36 | 37 | /** 38 | * Event triggered when an error occurs. 39 | */ 40 | static readonly error = 'error' 41 | } 42 | -------------------------------------------------------------------------------- /packages/agents-hosting-extensions-teams/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/package.json", 3 | "name": "@microsoft/agents-hosting-extensions-teams", 4 | "version": "0.1.0", 5 | "homepage": "https://github.com/microsoft/Agents-for-js", 6 | "repository": { 7 | "type": "git", 8 | "url": "git+https://github.com/microsoft/Agents-for-js.git" 9 | }, 10 | "author": { 11 | "name": "Microsoft", 12 | "email": "agentssdk@microsoft.com", 13 | "url": "https://aka.ms/Agents" 14 | }, 15 | "description": "Microsoft 365 Agents SDK for JavaScript. Teams extensions", 16 | "keywords": [ 17 | "Agents" 18 | ], 19 | "main": "dist/src/index.js", 20 | "types": "dist/src/index.d.ts", 21 | "dependencies": { 22 | "@microsoft/agents-hosting": "file:../agents-hosting" 23 | }, 24 | "license": "MIT", 25 | "files": [ 26 | "README.md", 27 | "dist/src", 28 | "src" 29 | ], 30 | "exports": { 31 | ".": { 32 | "import": "./dist/src/index.js", 33 | "require": "./dist/src/index.js" 34 | }, 35 | "./package.json": "./package.json" 36 | }, 37 | "engines": { 38 | "node": ">=20.0.0" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /samples/auth/noAuthDemo.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | import { startServer } from '@microsoft/agents-hosting-express' 5 | import { AgentApplication, MessageFactory, TurnContext, TurnState } from '@microsoft/agents-hosting' 6 | 7 | class NoAuthDemo extends AgentApplication { 8 | constructor () { 9 | super() 10 | this.onConversationUpdate('membersAdded', this._status) 11 | this.onActivity('invoke', this._invoke) 12 | this.onActivity('message', this._message) 13 | } 14 | 15 | private _status = async (context: TurnContext, state: TurnState): Promise => { 16 | await context.sendActivity(MessageFactory.text('Welcome to the Basic App demo!')) 17 | } 18 | 19 | private _invoke = async (context: TurnContext, state: TurnState): Promise => { 20 | await context.sendActivity(MessageFactory.text('Invoke received.')) 21 | } 22 | 23 | private _message = async (context: TurnContext, state: TurnState): Promise => { 24 | await context.sendActivity(MessageFactory.text('You said.' + context.activity.text)) 25 | } 26 | } 27 | 28 | startServer(new NoAuthDemo()) 29 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "[BUG]" 5 | labels: Triage 6 | assignees: '' 7 | 8 | --- 9 | 10 | ## Version 11 | What npm version of the SDK are you using? 12 | 13 | **Describe the bug** 14 | A clear and concise description of what the bug is. 15 | - Please include any stack trace information you can share. 16 | 17 | **To Reproduce** 18 | How can we reproduce this error? 19 | 20 | Please provide Code Snippets, Channel type, and any special configuration we will need to reproduce this problem. 21 | 22 | **Expected behavior** 23 | A clear and concise description of what you expected to happen. 24 | 25 | **Screenshots** 26 | If applicable, add screenshots to help explain your problem. 27 | 28 | **Hosting Information (please complete the following information):** 29 | - How are you Hosting this: [e.g. Azure, Desktop, Other] 30 | - Are you deploying: [e.g. AppServices, Containers(type?)] 31 | - Are you using Azure Bot Services: 32 | - What Client are you using: [e.g. MSTeams, WebChat, other] 33 | - What Node version are you using: 34 | 35 | **Additional context** 36 | Add any other context about the problem here. 37 | -------------------------------------------------------------------------------- /compat/baseline/agents-hosting-storage-cosmos.api.md: -------------------------------------------------------------------------------- 1 | ## API Report File for "@microsoft/agents-hosting-storage-cosmos" 2 | 3 | > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). 4 | 5 | ```ts 6 | 7 | import { CosmosClientOptions } from '@azure/cosmos'; 8 | import { Storage as Storage_2 } from '@microsoft/agents-hosting'; 9 | import { StoreItems } from '@microsoft/agents-hosting'; 10 | 11 | // @public 12 | export class CosmosDbPartitionedStorage implements Storage_2 { 13 | constructor(cosmosDbStorageOptions: CosmosDbPartitionedStorageOptions); 14 | // (undocumented) 15 | [key: string]: any; 16 | delete(keys: string[]): Promise; 17 | length: number; 18 | read(keys: string[]): Promise; 19 | write(changes: StoreItems): Promise; 20 | } 21 | 22 | // @public 23 | export interface CosmosDbPartitionedStorageOptions { 24 | compatibilityMode?: boolean; 25 | containerId: string; 26 | containerThroughput?: number; 27 | cosmosClientOptions?: CosmosClientOptions; 28 | databaseId: string; 29 | keySuffix?: string; 30 | } 31 | 32 | // (No @packageDocumentation comment for this package) 33 | 34 | ``` 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /packages/agents-hosting/test/activity-value-parsers/parseValueActionExecuteSelector.test.ts: -------------------------------------------------------------------------------- 1 | import assert from 'assert' 2 | import { describe, it } from 'node:test' 3 | import { parseValueActionExecuteSelector } from '../../src/app/adaptiveCards/activityValueParsers' 4 | 5 | describe('parseValueActionExecuteSelector test', () => { 6 | it('Parse with all properties', () => { 7 | const valueObject = { 8 | action: { 9 | type: 'type', 10 | verb: 'verb' 11 | } 12 | } 13 | const parsedValue = parseValueActionExecuteSelector(valueObject) 14 | assert.deepEqual(parsedValue, valueObject) 15 | }) 16 | 17 | it('Should throw with wrong type', () => { 18 | const valueObject = { 19 | action: { 20 | type: 1, 21 | verb: 'verb' 22 | } 23 | } 24 | assert.throws(() => { 25 | parseValueActionExecuteSelector(valueObject) 26 | }, Error) 27 | }) 28 | 29 | it('Should throw with wrong verb', () => { 30 | const valueObject = { 31 | action: { 32 | type: 'type', 33 | verb: 1 34 | } 35 | } 36 | assert.throws(() => { 37 | parseValueActionExecuteSelector(valueObject) 38 | }, Error) 39 | }) 40 | }) 41 | -------------------------------------------------------------------------------- /packages/agents-hosting-storage-blob/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/package.json", 3 | "name": "@microsoft/agents-hosting-storage-blob", 4 | "version": "0.1.0", 5 | "homepage": "https://github.com/microsoft/Agents-for-js", 6 | "repository": { 7 | "type": "git", 8 | "url": "git+https://github.com/microsoft/Agents-for-js.git" 9 | }, 10 | "author": { 11 | "name": "Microsoft", 12 | "email": "agentssdk@microsoft.com", 13 | "url": "https://aka.ms/Agents" 14 | }, 15 | "description": "Microsoft 365 Agents SDK State Blob Storage support.", 16 | "main": "dist/index.js", 17 | "types": "dist/src/index.d.ts", 18 | "dependencies": { 19 | "@azure/storage-blob": "^12.29.1", 20 | "@microsoft/agents-hosting": "file:../../packages/agents-hosting" 21 | }, 22 | "license": "MIT", 23 | "files": [ 24 | "README.md", 25 | "dist/src", 26 | "src", 27 | "package.json" 28 | ], 29 | "exports": { 30 | ".": { 31 | "types": "./dist/src/index.d.ts", 32 | "import": "./dist/src/index.js", 33 | "require": "./dist/src/index.js" 34 | }, 35 | "./package.json": "./package.json" 36 | }, 37 | "engines": { 38 | "node": ">=20.0.0" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /packages/agents-hosting-storage-cosmos/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/package.json", 3 | "name": "@microsoft/agents-hosting-storage-cosmos", 4 | "version": "0.1.0", 5 | "homepage": "https://github.com/microsoft/Agents-for-js", 6 | "repository": { 7 | "type": "git", 8 | "url": "git+https://github.com/microsoft/Agents-for-js.git" 9 | }, 10 | "author": { 11 | "name": "Microsoft", 12 | "email": "agentssdk@microsoft.com", 13 | "url": "https://aka.ms/Agents" 14 | }, 15 | "description": "Microsoft 365 Agents SDK State Cosmos Storage support.", 16 | "main": "dist/index.js", 17 | "types": "dist/src/index.d.ts", 18 | "dependencies": { 19 | "@azure/cosmos": "^4.9.0", 20 | "@microsoft/agents-hosting": "file:../../packages/agents-hosting" 21 | }, 22 | "license": "MIT", 23 | "files": [ 24 | "README.md", 25 | "dist/src", 26 | "src", 27 | "package.json" 28 | ], 29 | "exports": { 30 | ".": { 31 | "types": "./dist/src/index.d.ts", 32 | "import": "./dist/src/index.js", 33 | "require": "./dist/src/index.js" 34 | }, 35 | "./package.json": "./package.json" 36 | }, 37 | "engines": { 38 | "node": ">=20.0.0" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /samples/state/userState.ts: -------------------------------------------------------------------------------- 1 | import { startServer } from '@microsoft/agents-hosting-express' 2 | import { AgentApplication, FileStorage, TurnContext, TurnState } from '@microsoft/agents-hosting' 3 | 4 | const echo = new AgentApplication({ storage: new FileStorage('__state') }) 5 | type MyState = { 6 | name: string 7 | age: number 8 | } 9 | const myState: MyState = { 10 | name: 'rido', 11 | age: 30, 12 | } 13 | 14 | echo.onConversationUpdate('membersAdded', async (context: TurnContext, state: TurnState) => { 15 | const myState1 = state.getValue('user.myState') || myState 16 | await context.sendActivity('Current State: ' + JSON.stringify(myState1, null, 2)) 17 | }) 18 | 19 | echo.onActivity('message', async (context: TurnContext, state: TurnState) => { 20 | const myState1: MyState = state.getValue('user.myState') || myState 21 | myState1.age++ 22 | let counter: number = state.getValue('conversation.counter') || 0 23 | await context.sendActivity(`[${counter++}]You said: ${context.activity.text}`) 24 | state.setValue('conversation.counter', counter) 25 | state.setValue('user.myState', myState1) 26 | await context.sendActivity(`state: ${JSON.stringify(myState1, null, 2)}`) 27 | }) 28 | 29 | startServer(echo) 30 | -------------------------------------------------------------------------------- /packages/agents-hosting-express/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/package.json", 3 | "name": "@microsoft/agents-hosting-express", 4 | "version": "0.1.0", 5 | "homepage": "https://github.com/microsoft/Agents-for-js", 6 | "repository": { 7 | "type": "git", 8 | "url": "git+https://github.com/microsoft/Agents-for-js.git" 9 | }, 10 | "author": { 11 | "name": "Microsoft", 12 | "email": "agentssdk@microsoft.com", 13 | "url": "https://aka.ms/Agents" 14 | }, 15 | "description": "Microsoft 365 Agents SDK for JavaScript", 16 | "keywords": [ 17 | "Agents" 18 | ], 19 | "main": "dist/src/index.js", 20 | "types": "dist/src/index.d.ts", 21 | "dependencies": { 22 | "@microsoft/agents-hosting": "file:../agents-hosting", 23 | "express": "^5.2.1" 24 | }, 25 | "license": "MIT", 26 | "files": [ 27 | "README.md", 28 | "dist/src", 29 | "src", 30 | "package.json" 31 | ], 32 | "exports": { 33 | ".": { 34 | "types": "./dist/src/index.d.ts", 35 | "import": "./dist/src/index.js", 36 | "require": "./dist/src/index.js" 37 | }, 38 | "./package.json": "./package.json" 39 | }, 40 | "engines": { 41 | "node": ">=20.0.0" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/cards/audioCard.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { CardAction } from '@microsoft/agents-activity' 7 | import { MediaUrl } from './mediaUrl' 8 | import { ThumbnailUrl } from './thumbnailUrl' 9 | 10 | /** 11 | * Represents an Audio Card. 12 | */ 13 | export interface AudioCard { 14 | /** The title of the card. */ 15 | title: string 16 | /** The subtitle of the card. */ 17 | subtitle: string 18 | /** The text content of the card. */ 19 | text: string 20 | /** The image to be displayed on the card. */ 21 | image: ThumbnailUrl 22 | /** The media URLs or objects. */ 23 | media: MediaUrl[] 24 | /** The buttons to be displayed on the card. */ 25 | buttons: CardAction[] 26 | /** Indicates whether the card is shareable. */ 27 | shareable: boolean 28 | /** Indicates whether the card should auto-loop. */ 29 | autoloop: boolean 30 | /** Indicates whether the card should auto-start. */ 31 | autostart: boolean 32 | /** The aspect ratio of the card. */ 33 | aspect: string 34 | /** The duration of the audio. */ 35 | duration: string 36 | /** Additional value for the card. */ 37 | value: any 38 | } 39 | -------------------------------------------------------------------------------- /packages/agents-hosting/src/cards/animationCard.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) Microsoft Corporation.All rights reserved. 3 | * Licensed under the MIT License. 4 | */ 5 | 6 | import { CardAction } from '@microsoft/agents-activity' 7 | import { MediaUrl } from './mediaUrl' 8 | import { ThumbnailUrl } from './thumbnailUrl' 9 | 10 | /** 11 | * Represents an Animation Card. 12 | */ 13 | export interface AnimationCard { 14 | /** The title of the card. */ 15 | title: string 16 | /** The subtitle of the card. */ 17 | subtitle: string 18 | /** The text content of the card. */ 19 | text: string 20 | /** The image to be displayed on the card. */ 21 | image: ThumbnailUrl 22 | /** The media URLs or objects. */ 23 | media: MediaUrl[] 24 | /** The buttons to be displayed on the card. */ 25 | buttons: CardAction[] 26 | /** Indicates whether the card is shareable. */ 27 | shareable: boolean 28 | /** Indicates whether the card should auto-loop. */ 29 | autoloop: boolean 30 | /** Indicates whether the card should auto-start. */ 31 | autostart: boolean 32 | /** The aspect ratio of the card. */ 33 | aspect: string 34 | /** The duration of the animation. */ 35 | duration: string 36 | /** Additional value for the card. */ 37 | value: any 38 | } 39 | --------------------------------------------------------------------------------