@microsoft/agents-hosting 0.2.10-g3ac88ff25e → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/README.md +17 -1
  2. package/dist/src/activityHandler.d.ts +304 -46
  3. package/dist/src/activityHandler.js +298 -45
  4. package/dist/src/activityHandler.js.map +1 -1
  5. package/dist/src/agent-client/agentClient.d.ts +50 -0
  6. package/dist/src/agent-client/agentClient.js +28 -0
  7. package/dist/src/agent-client/agentClient.js.map +1 -1
  8. package/dist/src/app/agentApplication.d.ts +272 -7
  9. package/dist/src/app/agentApplication.js +278 -12
  10. package/dist/src/app/agentApplication.js.map +1 -1
  11. package/dist/src/app/agentApplicationBuilder.d.ts +34 -3
  12. package/dist/src/app/agentApplicationBuilder.js +38 -6
  13. package/dist/src/app/agentApplicationBuilder.js.map +1 -1
  14. package/dist/src/app/agentApplicationOptions.d.ts +26 -2
  15. package/dist/src/app/appMemory.d.ts +34 -0
  16. package/dist/src/app/{memory.js → appMemory.js} +1 -1
  17. package/dist/src/app/appMemory.js.map +1 -0
  18. package/dist/src/app/appRoute.d.ts +6 -0
  19. package/dist/src/app/attachmentDownloader.d.ts +18 -0
  20. package/dist/src/app/attachmentDownloader.js +18 -0
  21. package/dist/src/app/attachmentDownloader.js.map +1 -1
  22. package/dist/src/app/conversationUpdateEvents.d.ts +6 -0
  23. package/dist/src/app/index.d.ts +4 -1
  24. package/dist/src/app/index.js +4 -1
  25. package/dist/src/app/index.js.map +1 -1
  26. package/dist/src/app/inputFileDownloader.d.ts +22 -0
  27. package/dist/src/app/oauth/authorization.d.ts +87 -0
  28. package/dist/src/app/oauth/authorization.js +135 -0
  29. package/dist/src/app/oauth/authorization.js.map +1 -0
  30. package/dist/src/app/routeHandler.d.ts +8 -0
  31. package/dist/src/app/routeSelector.d.ts +9 -0
  32. package/dist/src/app/turnEvents.d.ts +6 -0
  33. package/dist/src/app/turnState.d.ts +152 -2
  34. package/dist/src/app/turnState.js +125 -0
  35. package/dist/src/app/turnState.js.map +1 -1
  36. package/dist/src/app/turnStateEntry.d.ts +32 -0
  37. package/dist/src/app/turnStateEntry.js +32 -0
  38. package/dist/src/app/turnStateEntry.js.map +1 -1
  39. package/dist/src/auth/authConfiguration.d.ts +24 -0
  40. package/dist/src/auth/authConfiguration.js.map +1 -1
  41. package/dist/src/auth/request.d.ts +12 -0
  42. package/dist/src/baseAdapter.d.ts +17 -0
  43. package/dist/src/baseAdapter.js +17 -0
  44. package/dist/src/baseAdapter.js.map +1 -1
  45. package/dist/src/cards/cardFactory.d.ts +3 -0
  46. package/dist/src/cards/cardFactory.js +3 -0
  47. package/dist/src/cards/cardFactory.js.map +1 -1
  48. package/dist/src/cards/index.d.ts +1 -0
  49. package/dist/src/cards/index.js +1 -0
  50. package/dist/src/cards/index.js.map +1 -1
  51. package/dist/src/cards/o365ConnectorCardActionBase.d.ts +8 -0
  52. package/dist/src/cloudAdapter.d.ts +25 -3
  53. package/dist/src/cloudAdapter.js +25 -3
  54. package/dist/src/cloudAdapter.js.map +1 -1
  55. package/dist/src/getProductInfo.d.ts +6 -0
  56. package/dist/src/getProductInfo.js +6 -0
  57. package/dist/src/getProductInfo.js.map +1 -1
  58. package/dist/src/logger.d.ts +34 -2
  59. package/dist/src/logger.js +35 -0
  60. package/dist/src/logger.js.map +1 -1
  61. package/dist/src/oauth/oAuthFlow.d.ts +32 -3
  62. package/dist/src/oauth/oAuthFlow.js +38 -14
  63. package/dist/src/oauth/oAuthFlow.js.map +1 -1
  64. package/dist/src/oauth/userTokenClient.d.ts +2 -2
  65. package/dist/src/oauth/userTokenClient.js +3 -3
  66. package/dist/src/oauth/userTokenClient.js.map +1 -1
  67. package/dist/src/state/agentState.d.ts +79 -27
  68. package/dist/src/state/agentState.js +58 -27
  69. package/dist/src/state/agentState.js.map +1 -1
  70. package/dist/src/state/agentStatePropertyAccesor.d.ts +67 -11
  71. package/dist/src/state/agentStatePropertyAccesor.js +58 -11
  72. package/dist/src/state/agentStatePropertyAccesor.js.map +1 -1
  73. package/dist/src/statusCodes.d.ts +39 -0
  74. package/dist/src/statusCodes.js +39 -0
  75. package/dist/src/statusCodes.js.map +1 -1
  76. package/dist/src/storage/memoryStorage.d.ts +48 -14
  77. package/dist/src/storage/memoryStorage.js +48 -14
  78. package/dist/src/storage/memoryStorage.js.map +1 -1
  79. package/dist/src/storage/storage.d.ts +43 -13
  80. package/dist/src/tokenResponseEventName.d.ts +3 -0
  81. package/dist/src/tokenResponseEventName.js +3 -0
  82. package/dist/src/tokenResponseEventName.js.map +1 -1
  83. package/dist/src/turnContext.d.ts +142 -56
  84. package/dist/src/turnContext.js +123 -53
  85. package/dist/src/turnContext.js.map +1 -1
  86. package/package.json +6 -6
  87. package/src/activityHandler.ts +304 -46
  88. package/src/agent-client/agentClient.ts +55 -5
  89. package/src/app/agentApplication.ts +283 -15
  90. package/src/app/agentApplicationBuilder.ts +39 -7
  91. package/src/app/agentApplicationOptions.ts +33 -2
  92. package/src/app/appMemory.ts +38 -0
  93. package/src/app/appRoute.ts +7 -0
  94. package/src/app/attachmentDownloader.ts +18 -0
  95. package/src/app/conversationUpdateEvents.ts +6 -0
  96. package/src/app/index.ts +4 -1
  97. package/src/app/inputFileDownloader.ts +24 -0
  98. package/src/app/oauth/authorization.ts +162 -0
  99. package/src/app/routeHandler.ts +8 -0
  100. package/src/app/routeSelector.ts +9 -0
  101. package/src/app/turnEvents.ts +6 -0
  102. package/src/app/turnState.ts +153 -3
  103. package/src/app/turnStateEntry.ts +32 -0
  104. package/src/auth/authConfiguration.ts +32 -1
  105. package/src/auth/request.ts +15 -0
  106. package/src/baseAdapter.ts +18 -0
  107. package/src/cards/cardFactory.ts +3 -0
  108. package/src/cards/index.ts +1 -0
  109. package/src/cards/o365ConnectorCardActionBase.ts +8 -0
  110. package/src/cloudAdapter.ts +28 -3
  111. package/src/getProductInfo.ts +7 -0
  112. package/src/logger.ts +34 -1
  113. package/src/oauth/oAuthFlow.ts +59 -18
  114. package/src/oauth/userTokenClient.ts +4 -4
  115. package/src/state/agentState.ts +81 -29
  116. package/src/state/agentStatePropertyAccesor.ts +67 -11
  117. package/src/statusCodes.ts +51 -0
  118. package/src/storage/memoryStorage.ts +48 -14
  119. package/src/storage/storage.ts +51 -18
  120. package/src/tokenResponseEventName.ts +3 -0
  121. package/src/turnContext.ts +142 -56
  122. package/dist/src/app/memory.d.ts +0 -10
  123. package/dist/src/app/memory.js.map +0 -1
  124. package/dist/src/app/oauth/userIdentity.d.ts +0 -43
  125. package/dist/src/app/oauth/userIdentity.js +0 -54
  126. package/dist/src/app/oauth/userIdentity.js.map +0 -1
  127. package/src/app/memory.ts +0 -14
  128. package/src/app/oauth/userIdentity.ts +0 -78
@@ -6,6 +6,12 @@ import { RouteHandler } from './routeHandler';
6
6
  import { RouteSelector } from './routeSelector';
7
7
  import { TurnState } from './turnState';
8
8
  export interface AppRoute<TState extends TurnState> {
9
+ /**
10
+ * The selector function used to determine if this route should handle the current activity.
11
+ */
9
12
  selector: RouteSelector;
13
+ /**
14
+ * The handler function that processes the activity if the selector matches.
15
+ */
10
16
  handler: RouteHandler<TState>;
11
17
  }
@@ -5,9 +5,27 @@
5
5
  import { InputFile, InputFileDownloader } from './inputFileDownloader';
6
6
  import { TurnState } from './turnState';
7
7
  import { TurnContext } from '../turnContext';
8
+ /**
9
+ * A utility class for downloading input files from activity attachments.
10
+ *
11
+ * This class provides functionality to filter and download attachments from a turn context,
12
+ * supporting various content types and handling authentication for secure URLs.
13
+ *
14
+ * @typeParam TState - The type of the turn state used in the application.
15
+ */
8
16
  export declare class AttachmentDownloader<TState extends TurnState = TurnState> implements InputFileDownloader<TState> {
9
17
  private _httpClient;
18
+ /**
19
+ * Creates an instance of AttachmentDownloader.
20
+ * This class is responsible for downloading input files from attachments.
21
+ */
10
22
  constructor();
23
+ /**
24
+ * Downloads files from the attachments in the current turn context.
25
+ * @param context The turn context containing the activity with attachments.
26
+ * @param state The turn state for the current conversation.
27
+ * @returns A promise that resolves to an array of downloaded input files.
28
+ */
11
29
  downloadFiles(context: TurnContext, state: TState): Promise<InputFile[]>;
12
30
  private downloadFile;
13
31
  }
@@ -12,10 +12,28 @@ const axios_1 = __importDefault(require("axios"));
12
12
  const logger_1 = require("../logger");
13
13
  const auth_1 = require("../auth");
14
14
  const logger = (0, logger_1.debug)('agents:attachmentDownloader');
15
+ /**
16
+ * A utility class for downloading input files from activity attachments.
17
+ *
18
+ * This class provides functionality to filter and download attachments from a turn context,
19
+ * supporting various content types and handling authentication for secure URLs.
20
+ *
21
+ * @typeParam TState - The type of the turn state used in the application.
22
+ */
15
23
  class AttachmentDownloader {
24
+ /**
25
+ * Creates an instance of AttachmentDownloader.
26
+ * This class is responsible for downloading input files from attachments.
27
+ */
16
28
  constructor() {
17
29
  this._httpClient = axios_1.default.create();
18
30
  }
31
+ /**
32
+ * Downloads files from the attachments in the current turn context.
33
+ * @param context The turn context containing the activity with attachments.
34
+ * @param state The turn state for the current conversation.
35
+ * @returns A promise that resolves to an array of downloaded input files.
36
+ */
19
37
  async downloadFiles(context, state) {
20
38
  var _a;
21
39
  const attachments = (_a = context.activity.attachments) === null || _a === void 0 ? void 0 : _a.filter((a) => !a.contentType.startsWith('text/html'));
@@ -1 +1 @@
1
- {"version":3,"file":"attachmentDownloader.js","sourceRoot":"","sources":["../../../src/app/attachmentDownloader.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,kDAA4C;AAM5C,sCAAiC;AACjC,kCAAkE;AAElE,MAAM,MAAM,GAAG,IAAA,cAAK,EAAC,6BAA6B,CAAC,CAAA;AAEnD,MAAa,oBAAoB;IAG/B;QACE,IAAI,CAAC,WAAW,GAAG,eAAK,CAAC,MAAM,EAAE,CAAA;IACnC,CAAC;IAEM,KAAK,CAAC,aAAa,CAAE,OAAoB,EAAE,KAAa;;QAC7D,MAAM,WAAW,GAAG,MAAA,OAAO,CAAC,QAAQ,CAAC,WAAW,0CAAE,MAAM,CA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;gBACP,YAAY,EAAE,aAAa;aAC5B,CAAC,CAAA;YAEF,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;YAEpD,IAAI,WAAW,GAAG,UAAU,CAAC,WAAW,CAAA;YACxC,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;gBAC9B,WAAW,GAAG,WAAW,CAAA;YAC3B,CAAC;YAED,OAAO;gBACL,OAAO;gBACP,WAAW;gBACX,UAAU,EAAE,UAAU,CAAC,UAAU;aAClC,CAAA;QACH,CAAC;aAAM,CAAC;YACN,OAAO;gBACL,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,OAAc,CAAC;gBAC/C,WAAW,EAAE,UAAU,CAAC,WAAW;gBACnC,UAAU,EAAE,UAAU,CAAC,UAAU;aAClC,CAAA;QACH,CAAC;IACH,CAAC;CACF;AA5ED,oDA4EC"}
@@ -2,4 +2,10 @@
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
+ /**
6
+ * Represents the types of conversation update events that can occur.
7
+ *
8
+ * - `membersAdded`: Triggered when new members are added to the conversation.
9
+ * - `membersRemoved`: Triggered when members are removed from the conversation.
10
+ */
5
11
  export type ConversationUpdateEvents = 'membersAdded' | 'membersRemoved';
@@ -3,9 +3,12 @@ export * from './agentApplicationBuilder';
3
3
  export * from './agentApplicationOptions';
4
4
  export * from './appRoute';
5
5
  export * from './attachmentDownloader';
6
- export * from './oauth/userIdentity';
6
+ export * from './oauth/authorization';
7
7
  export * from './conversationUpdateEvents';
8
8
  export * from './routeHandler';
9
9
  export * from './routeSelector';
10
10
  export * from './turnState';
11
+ export * from './turnEvents';
12
+ export * from './turnStateEntry';
11
13
  export * from './inputFileDownloader';
14
+ export * from './appMemory';
@@ -19,10 +19,13 @@ __exportStar(require("./agentApplicationBuilder"), exports);
19
19
  __exportStar(require("./agentApplicationOptions"), exports);
20
20
  __exportStar(require("./appRoute"), exports);
21
21
  __exportStar(require("./attachmentDownloader"), exports);
22
- __exportStar(require("./oauth/userIdentity"), exports);
22
+ __exportStar(require("./oauth/authorization"), exports);
23
23
  __exportStar(require("./conversationUpdateEvents"), exports);
24
24
  __exportStar(require("./routeHandler"), exports);
25
25
  __exportStar(require("./routeSelector"), exports);
26
26
  __exportStar(require("./turnState"), exports);
27
+ __exportStar(require("./turnEvents"), exports);
28
+ __exportStar(require("./turnStateEntry"), exports);
27
29
  __exportStar(require("./inputFileDownloader"), exports);
30
+ __exportStar(require("./appMemory"), exports);
28
31
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/app/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAkC;AAClC,4DAAyC;AACzC,4DAAyC;AACzC,6CAA0B;AAC1B,yDAAsC;AACtC,uDAAoC;AACpC,6DAA0C;AAC1C,iDAA8B;AAC9B,kDAA+B;AAC/B,8CAA2B;AAC3B,wDAAqC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/app/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAkC;AAClC,4DAAyC;AACzC,4DAAyC;AACzC,6CAA0B;AAC1B,yDAAsC;AACtC,wDAAqC;AACrC,6DAA0C;AAC1C,iDAA8B;AAC9B,kDAA+B;AAC/B,8CAA2B;AAC3B,+CAA4B;AAC5B,mDAAgC;AAChC,wDAAqC;AACrC,8CAA2B"}
@@ -4,11 +4,33 @@
4
4
  */
5
5
  import { TurnContext } from '../turnContext';
6
6
  import { TurnState } from './turnState';
7
+ /**
8
+ * Represents a file input with its content, type, and optional URL.
9
+ */
7
10
  export interface InputFile {
11
+ /**
12
+ * The content of the file as a Buffer.
13
+ */
8
14
  content: Buffer;
15
+ /**
16
+ * The MIME type of the file content.
17
+ */
9
18
  contentType: string;
19
+ /**
20
+ * An optional URL pointing to the file content.
21
+ */
10
22
  contentUrl?: string;
11
23
  }
24
+ /**
25
+ * Interface for downloading input files in a specific turn context and state.
26
+ */
12
27
  export interface InputFileDownloader<TState extends TurnState = TurnState> {
28
+ /**
29
+ * Downloads files based on the provided turn context and state.
30
+ *
31
+ * @param context - The turn context for the current operation.
32
+ * @param state - The state associated with the current turn.
33
+ * @returns A promise that resolves to an array of input files.
34
+ */
13
35
  downloadFiles(context: TurnContext, state: TState): Promise<InputFile[]>;
14
36
  }
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { TurnContext } from '../../turnContext';
6
+ import { TurnState } from '../turnState';
7
+ import { Storage } from '../../storage';
8
+ import { OAuthFlow, TokenResponse } from '../../oauth';
9
+ /**
10
+ * Interface defining an authorization handler for OAuth flows
11
+ * @interface AuthHandler
12
+ */
13
+ export interface AuthHandler {
14
+ /** Connection name for the auth provider */
15
+ name?: string;
16
+ /** Whether authorization should be triggered automatically */
17
+ auto?: boolean;
18
+ /** The OAuth flow implementation */
19
+ flow?: OAuthFlow;
20
+ /** Title to display on auth cards/UI */
21
+ title?: string;
22
+ /** Text to display on auth cards/UI */
23
+ text?: string;
24
+ }
25
+ /**
26
+ * Options for configuring user authorization.
27
+ * Contains settings to configure OAuth connections.
28
+ */
29
+ export interface AuthorizationHandlers extends Record<string, AuthHandler> {
30
+ }
31
+ /**
32
+ * Class responsible for managing authorization and OAuth flows
33
+ * @class Authorization
34
+ */
35
+ export declare class Authorization {
36
+ _authHandlers: AuthorizationHandlers;
37
+ /**
38
+ * Creates a new instance of UserAuthorization.
39
+ * @param {Storage} storage - The storage system to use for state management.
40
+ * @param {AuthorizationHandlers} authHandlers - Configuration for OAuth providers
41
+ * @throws {Error} If storage is null/undefined or no auth handlers are provided
42
+ */
43
+ constructor(storage: Storage, authHandlers: AuthorizationHandlers);
44
+ /**
45
+ * Gets the token for a specific auth handler
46
+ * @param {TurnContext} context - The context object for the current turn
47
+ * @param {string} [authHandlerId] - Optional ID of the auth handler to use, defaults to first handler
48
+ * @returns {Promise<TokenResponse>} The token response from the OAuth provider
49
+ */
50
+ getToken(context: TurnContext, authHandlerId?: string): Promise<TokenResponse>;
51
+ /**
52
+ * Begins or continues an OAuth flow
53
+ * @param {TurnContext} context - The context object for the current turn
54
+ * @param {TurnState} state - The state object for the current turn
55
+ * @param {string} [authHandlerId] - Optional ID of the auth handler to use, defaults to first handler
56
+ * @returns {Promise<TokenResponse>} The token response from the OAuth provider
57
+ */
58
+ beginOrContinueFlow(context: TurnContext, state: TurnState, authHandlerId?: string): Promise<TokenResponse>;
59
+ /**
60
+ * Gets the current state of the OAuth flow
61
+ * @param {string} [authHandlerId] - Optional ID of the auth handler to check, defaults to first handler
62
+ * @returns {boolean} Whether the flow has started
63
+ */
64
+ getFlowState(authHandlerId?: string): boolean;
65
+ /**
66
+ * Resolves the auth handler to use based on the provided ID
67
+ * @param {string} [authHandlerId] - Optional ID of the auth handler to resolve, defaults to first handler
68
+ * @returns {AuthHandler} The resolved auth handler
69
+ */
70
+ resolverHandler: (authHandlerId?: string) => AuthHandler;
71
+ /**
72
+ * Signs out the current user.
73
+ * This method clears the user's token and resets the SSO state.
74
+ *
75
+ * @param {TurnContext} context - The context object for the current turn.
76
+ * @param {TurnState} state - The state object for the current turn.
77
+ * @param {string} [authHandlerId] - Optional ID of the auth handler to use for sign out
78
+ * @returns {Promise<void>}
79
+ */
80
+ signOut(context: TurnContext, state: TurnState, authHandlerId?: string): Promise<void>;
81
+ _signInHandler: ((context: TurnContext, state: TurnState, authHandlerId?: string) => void) | null;
82
+ /**
83
+ * Sets a handler to be called when sign-in is successfully completed
84
+ * @param {Function} handler - The handler function to call on successful sign-in
85
+ */
86
+ onSignInSuccess(handler: (context: TurnContext, state: TurnState, authHandlerId?: string) => void): void;
87
+ }
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.Authorization = void 0;
8
+ const logger_1 = require("../../logger");
9
+ const oauth_1 = require("../../oauth");
10
+ const state_1 = require("../../state");
11
+ const logger = (0, logger_1.debug)('agents:authorization');
12
+ /**
13
+ * Class responsible for managing authorization and OAuth flows
14
+ * @class Authorization
15
+ */
16
+ class Authorization {
17
+ /**
18
+ * Creates a new instance of UserAuthorization.
19
+ * @param {Storage} storage - The storage system to use for state management.
20
+ * @param {AuthorizationHandlers} authHandlers - Configuration for OAuth providers
21
+ * @throws {Error} If storage is null/undefined or no auth handlers are provided
22
+ */
23
+ constructor(storage, authHandlers) {
24
+ var _a, _b, _c, _d;
25
+ /**
26
+ * Resolves the auth handler to use based on the provided ID
27
+ * @param {string} [authHandlerId] - Optional ID of the auth handler to resolve, defaults to first handler
28
+ * @returns {AuthHandler} The resolved auth handler
29
+ */
30
+ this.resolverHandler = (authHandlerId) => {
31
+ if (authHandlerId) {
32
+ return this._authHandlers[authHandlerId];
33
+ }
34
+ return this._authHandlers[Object.keys(this._authHandlers)[0]];
35
+ };
36
+ this._signInHandler = null;
37
+ if (storage === undefined || storage === null) {
38
+ throw new Error('Storage is required for UserAuthorization');
39
+ }
40
+ const userState = new state_1.UserState(storage);
41
+ if (authHandlers === undefined || Object.keys(authHandlers).length === 0) {
42
+ throw new Error('The authorization does not have any auth handlers');
43
+ }
44
+ this._authHandlers = authHandlers;
45
+ for (const ah in this._authHandlers) {
46
+ if (this._authHandlers[ah].name === undefined && process.env[ah + '_connectionName'] === undefined) {
47
+ throw new Error(`AuthHandler name ${ah}_connectionName not set in autorization and not found in env vars.`);
48
+ }
49
+ const currentAuthHandler = this._authHandlers[ah];
50
+ currentAuthHandler.name = (_a = currentAuthHandler.name) !== null && _a !== void 0 ? _a : process.env[ah + '_connectionName'];
51
+ currentAuthHandler.title = (_b = currentAuthHandler.title) !== null && _b !== void 0 ? _b : process.env[ah + '_connectionTitle'];
52
+ currentAuthHandler.text = (_c = currentAuthHandler.text) !== null && _c !== void 0 ? _c : process.env[ah + '_connectionText'];
53
+ currentAuthHandler.auto = (_d = currentAuthHandler.auto) !== null && _d !== void 0 ? _d : process.env[ah + '_connectionAuto'] === 'true';
54
+ currentAuthHandler.flow = new oauth_1.OAuthFlow(userState, currentAuthHandler.name, null, currentAuthHandler.title, currentAuthHandler.text);
55
+ }
56
+ logger.info('Authorization handlers configured with', this._authHandlers.length, 'handlers');
57
+ }
58
+ /**
59
+ * Gets the token for a specific auth handler
60
+ * @param {TurnContext} context - The context object for the current turn
61
+ * @param {string} [authHandlerId] - Optional ID of the auth handler to use, defaults to first handler
62
+ * @returns {Promise<TokenResponse>} The token response from the OAuth provider
63
+ */
64
+ async getToken(context, authHandlerId) {
65
+ var _a;
66
+ logger.info('getToken from user token service for authHandlerId:', authHandlerId);
67
+ const authHandler = this.resolverHandler(authHandlerId);
68
+ return await ((_a = authHandler.flow) === null || _a === void 0 ? void 0 : _a.getUserToken(context));
69
+ }
70
+ /**
71
+ * Begins or continues an OAuth flow
72
+ * @param {TurnContext} context - The context object for the current turn
73
+ * @param {TurnState} state - The state object for the current turn
74
+ * @param {string} [authHandlerId] - Optional ID of the auth handler to use, defaults to first handler
75
+ * @returns {Promise<TokenResponse>} The token response from the OAuth provider
76
+ */
77
+ async beginOrContinueFlow(context, state, authHandlerId) {
78
+ logger.info('beginOrContinueFlow for authHandlerId:', authHandlerId);
79
+ const flow = this.resolverHandler(authHandlerId).flow;
80
+ let tokenResponse;
81
+ if (flow.state.flowStarted === false) {
82
+ tokenResponse = await flow.beginFlow(context);
83
+ }
84
+ else {
85
+ tokenResponse = await flow.continueFlow(context);
86
+ if (tokenResponse.status === oauth_1.TokenRequestStatus.Success) {
87
+ if (this._signInHandler) {
88
+ await this._signInHandler(context, state, authHandlerId);
89
+ }
90
+ }
91
+ }
92
+ return tokenResponse;
93
+ }
94
+ /**
95
+ * Gets the current state of the OAuth flow
96
+ * @param {string} [authHandlerId] - Optional ID of the auth handler to check, defaults to first handler
97
+ * @returns {boolean} Whether the flow has started
98
+ */
99
+ getFlowState(authHandlerId) {
100
+ var _a;
101
+ const flow = this.resolverHandler(authHandlerId).flow;
102
+ return (_a = flow.state) === null || _a === void 0 ? void 0 : _a.flowStarted;
103
+ }
104
+ /**
105
+ * Signs out the current user.
106
+ * This method clears the user's token and resets the SSO state.
107
+ *
108
+ * @param {TurnContext} context - The context object for the current turn.
109
+ * @param {TurnState} state - The state object for the current turn.
110
+ * @param {string} [authHandlerId] - Optional ID of the auth handler to use for sign out
111
+ * @returns {Promise<void>}
112
+ */
113
+ async signOut(context, state, authHandlerId) {
114
+ var _a;
115
+ logger.info('signOut for authHandlerId:', authHandlerId);
116
+ if (authHandlerId === undefined) { // aw
117
+ for (const ah in this._authHandlers) {
118
+ const flow = this._authHandlers[ah].flow;
119
+ await (flow === null || flow === void 0 ? void 0 : flow.signOut(context));
120
+ }
121
+ }
122
+ else {
123
+ await ((_a = this.resolverHandler(authHandlerId).flow) === null || _a === void 0 ? void 0 : _a.signOut(context));
124
+ }
125
+ }
126
+ /**
127
+ * Sets a handler to be called when sign-in is successfully completed
128
+ * @param {Function} handler - The handler function to call on successful sign-in
129
+ */
130
+ onSignInSuccess(handler) {
131
+ this._signInHandler = handler;
132
+ }
133
+ }
134
+ exports.Authorization = Authorization;
135
+ //# sourceMappingURL=authorization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorization.js","sourceRoot":"","sources":["../../../../src/app/oauth/authorization.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,yCAAoC;AAGpC,uCAA0E;AAC1E,uCAAuC;AAEvC,MAAM,MAAM,GAAG,IAAA,cAAK,EAAC,sBAAsB,CAAC,CAAA;AAyB5C;;;GAGG;AACH,MAAa,aAAa;IAGxB;;;;;OAKG;IACH,YAAa,OAAgB,EAAE,YAAmC;;QAqElE;;;;WAIG;QACH,oBAAe,GAAG,CAAC,aAAsB,E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G,IAAI,CAAC,cAAc,GAAG,OAAO,CAAA;IAC/B,CAAC;CACF;AAxHD,sCAwHC"}
@@ -4,4 +4,12 @@
4
4
  */
5
5
  import { TurnContext } from '../turnContext';
6
6
  import { TurnState } from './turnState';
7
+ /**
8
+ * A handler function for routing operations in a specific turn context and state.
9
+ *
10
+ * @typeParam TState - The type of the turn state.
11
+ * @param context - The turn context for the current operation.
12
+ * @param state - The state associated with the current turn.
13
+ * @returns A promise that resolves when the routing operation is complete.
14
+ */
7
15
  export type RouteHandler<TState extends TurnState> = (context: TurnContext, state: TState) => Promise<void>;
@@ -3,5 +3,14 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { TurnContext } from '../turnContext';
6
+ /**
7
+ * A function that determines whether a specific condition is met in the given turn context.
8
+ *
9
+ * @param context - The turn context for the current operation.
10
+ * @returns A promise that resolves to a boolean indicating whether the condition is met.
11
+ */
6
12
  export type Selector = (context: TurnContext) => Promise<boolean>;
13
+ /**
14
+ * A specialized selector for routing operations.
15
+ */
7
16
  export type RouteSelector = Selector;
@@ -2,4 +2,10 @@
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
+ /**
6
+ * Represents the types of events that can occur during a turn in the application.
7
+ *
8
+ * - `beforeTurn`: Triggered before the turn starts.
9
+ * - `afterTurn`: Triggered after the turn ends.
10
+ */
5
11
  export type TurnEvents = 'beforeTurn' | 'afterTurn';
@@ -3,27 +3,52 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { Storage } from '../storage';
6
- import { Memory } from './memory';
6
+ import { AppMemory } from './appMemory';
7
7
  import { InputFile } from './inputFileDownloader';
8
8
  import { TurnStateEntry } from './turnStateEntry';
9
9
  import { TurnContext } from '../turnContext';
10
+ /**
11
+ * Default interface for conversation state.
12
+ * Extend this interface to define custom conversation state properties.
13
+ */
10
14
  export interface DefaultConversationState {
11
15
  }
16
+ /**
17
+ * Default interface for user state.
18
+ * Extend this interface to define custom user state properties.
19
+ */
12
20
  export interface DefaultUserState {
13
21
  }
22
+ /**
23
+ * Default interface for temporary state that persists only during the current turn.
24
+ * Contains properties used for handling user input, file attachments, and OAuth flows.
25
+ */
14
26
  export interface DefaultTempState {
27
+ /** Current user input text */
15
28
  input: string;
29
+ /** Collection of files attached to the current message */
16
30
  inputFiles: InputFile[];
31
+ /** Last output text generated by the agent */
17
32
  lastOutput: string;
33
+ /** Results from actions performed by the agent */
18
34
  actionOutputs: Record<string, string>;
35
+ /** OAuth tokens keyed by provider ID */
19
36
  authTokens: {
20
37
  [key: string]: string;
21
38
  };
39
+ /** Flag to prevent duplicate token exchanges */
22
40
  duplicateTokenExchange?: boolean;
23
41
  }
42
+ /**
43
+ * Default interface for Single Sign-On (SSO) state.
44
+ * Contains properties used for managing OAuth authentication flows.
45
+ */
24
46
  export interface DefaultSSOState {
47
+ /** Whether an OAuth flow has been started */
25
48
  flowStarted: boolean;
49
+ /** The user's access token */
26
50
  userToken: string;
51
+ /** Expiration timestamp for the current flow */
27
52
  flowExpires: number;
28
53
  }
29
54
  /**
@@ -55,31 +80,156 @@ export interface DefaultSSOState {
55
80
  * }
56
81
  * }
57
82
  * ```
83
+ * @template TConversationState - Type for conversation-scoped state
84
+ * @template TUserState - Type for user-scoped state
85
+ * @template TTempState - Type for temporary state that exists only for the current turn
86
+ * @template TSSOState - Type for Single Sign-On (SSO) state
58
87
  */
59
- export declare class TurnState<TConversationState = DefaultConversationState, TUserState = DefaultUserState, TTempState = DefaultTempState, TSSOState = DefaultSSOState> implements Memory {
88
+ export declare class TurnState<TConversationState = DefaultConversationState, TUserState = DefaultUserState, TTempState = DefaultTempState, TSSOState = DefaultSSOState> implements AppMemory {
60
89
  private _scopes;
61
90
  private _isLoaded;
62
91
  private _loadingPromise?;
63
92
  private _stateNotLoadedString;
93
+ /**
94
+ * Gets the conversation-scoped state.
95
+ * This state is shared by all users in the same conversation.
96
+ * @returns The conversation state object
97
+ * @throws Error if state hasn't been loaded
98
+ */
64
99
  get conversation(): TConversationState;
100
+ /**
101
+ * Sets the conversation-scoped state.
102
+ * @param value - The new conversation state object
103
+ * @throws Error if state hasn't been loaded
104
+ */
65
105
  set conversation(value: TConversationState);
106
+ /**
107
+ * Gets whether the state has been loaded from storage
108
+ * @returns True if the state has been loaded, false otherwise
109
+ */
66
110
  get isLoaded(): boolean;
111
+ /**
112
+ * Gets the temporary state for the current turn.
113
+ * This state is not persisted between turns.
114
+ * @returns The temporary state object
115
+ * @throws Error if state hasn't been loaded
116
+ */
67
117
  get temp(): TTempState;
118
+ /**
119
+ * Sets the temporary state for the current turn.
120
+ * @param value - The new temporary state object
121
+ * @throws Error if state hasn't been loaded
122
+ */
68
123
  set temp(value: TTempState);
124
+ /**
125
+ * Gets the user-scoped state.
126
+ * This state is unique to each user and persists across conversations.
127
+ * @returns The user state object
128
+ * @throws Error if state hasn't been loaded
129
+ */
69
130
  get user(): TUserState;
131
+ /**
132
+ * Sets the user-scoped state.
133
+ * @param value - The new user state object
134
+ * @throws Error if state hasn't been loaded
135
+ */
70
136
  set user(value: TUserState);
137
+ /**
138
+ * Gets the Single Sign-On (SSO) state.
139
+ * This state is used to manage OAuth authentication flows.
140
+ * @returns The SSO state object
141
+ * @throws Error if state hasn't been loaded
142
+ */
71
143
  get sso(): TSSOState;
144
+ /**
145
+ * Sets the Single Sign-On (SSO) state.
146
+ * @param value - The new SSO state object
147
+ * @throws Error if state hasn't been loaded
148
+ */
72
149
  set sso(value: TSSOState);
150
+ /**
151
+ * Marks the conversation state for deletion.
152
+ * The state will be deleted from storage on the next call to save().
153
+ * @throws Error if state hasn't been loaded
154
+ */
73
155
  deleteConversationState(): void;
156
+ /**
157
+ * Marks the temporary state for deletion.
158
+ * Since temporary state is not persisted, this just clears the in-memory object.
159
+ * @throws Error if state hasn't been loaded
160
+ */
74
161
  deleteTempState(): void;
162
+ /**
163
+ * Marks the user state for deletion.
164
+ * The state will be deleted from storage on the next call to save().
165
+ * @throws Error if state hasn't been loaded
166
+ */
75
167
  deleteUserState(): void;
168
+ /**
169
+ * Gets a specific state scope by name.
170
+ * @param scope - The name of the scope to retrieve
171
+ * @returns The state entry for the scope, or undefined if not found
172
+ */
76
173
  getScope(scope: string): TurnStateEntry | undefined;
174
+ /**
175
+ * Deletes a value from state by dot-notation path.
176
+ * Format: "scope.property" or just "property" (defaults to temp scope)
177
+ * @param path - The path to the value to delete
178
+ */
77
179
  deleteValue(path: string): void;
180
+ /**
181
+ * Checks if a value exists in state by dot-notation path.
182
+ * Format: "scope.property" or just "property" (defaults to temp scope)
183
+ * @param path - The path to check
184
+ * @returns True if the value exists, false otherwise
185
+ */
78
186
  hasValue(path: string): boolean;
187
+ /**
188
+ * Gets a value from state by dot-notation path.
189
+ * Format: "scope.property" or just "property" (defaults to temp scope)
190
+ * @template TValue - The type of the value to retrieve
191
+ * @param path - The path to the value
192
+ * @returns The value at the specified path
193
+ */
79
194
  getValue<TValue = unknown>(path: string): TValue;
195
+ /**
196
+ * Sets a value in state by dot-notation path.
197
+ * Format: "scope.property" or just "property" (defaults to temp scope)
198
+ * @param path - The path to set
199
+ * @param value - The value to set
200
+ */
80
201
  setValue(path: string, value: unknown): void;
202
+ /**
203
+ * Loads state from storage into memory.
204
+ * @param context - The turn context
205
+ * @param storage - Optional storage provider (if not provided, state will be in-memory only)
206
+ * @param force - If true, forces a reload from storage even if state is already loaded
207
+ * @returns Promise that resolves to true if state was loaded, false if it was already loaded
208
+ */
81
209
  load(context: TurnContext, storage?: Storage, force?: boolean): Promise<boolean>;
210
+ /**
211
+ * Saves state changes to storage.
212
+ * Only changed scopes will be persisted.
213
+ * @param context - The turn context
214
+ * @param storage - Optional storage provider (if not provided, state changes won't be persisted)
215
+ * @returns Promise that resolves when the save operation is complete
216
+ * @throws Error if state hasn't been loaded
217
+ */
82
218
  save(context: TurnContext, storage?: Storage): Promise<void>;
219
+ /**
220
+ * Computes the storage keys for each scope based on the turn context.
221
+ * Override this method in derived classes to add or modify storage keys.
222
+ * @param context - The turn context
223
+ * @returns Promise that resolves to a dictionary of scope names to storage keys
224
+ * @protected
225
+ */
83
226
  protected onComputeStorageKeys(context: TurnContext): Promise<Record<string, string>>;
227
+ /**
228
+ * Parses a dot-notation path into scope and property name.
229
+ * If no scope is specified, defaults to the temp scope.
230
+ * @param path - The path to parse (format: "scope.property" or just "property")
231
+ * @returns Object containing the scope entry and property name
232
+ * @private
233
+ */
84
234
  private getScopeAndName;
85
235
  }