@microsoft/agents-hosting 1.0.0 → 1.0.3-g444d99f704

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 (72) hide show
  1. package/dist/package.json +2 -2
  2. package/dist/src/activityHandler.d.ts +0 -1
  3. package/dist/src/activityHandler.js +0 -1
  4. package/dist/src/activityHandler.js.map +1 -1
  5. package/dist/src/agent-client/agentResponseHandler.d.ts +6 -6
  6. package/dist/src/agent-client/agentResponseHandler.js +6 -6
  7. package/dist/src/app/adaptiveCards/adaptiveCardsActions.d.ts +12 -4
  8. package/dist/src/app/adaptiveCards/adaptiveCardsActions.js +5 -1
  9. package/dist/src/app/adaptiveCards/adaptiveCardsActions.js.map +1 -1
  10. package/dist/src/app/agentApplication.d.ts +24 -7
  11. package/dist/src/app/agentApplication.js +24 -7
  12. package/dist/src/app/agentApplication.js.map +1 -1
  13. package/dist/src/app/appRoute.d.ts +8 -4
  14. package/dist/src/app/attachmentDownloader.d.ts +3 -1
  15. package/dist/src/app/attachmentDownloader.js +3 -1
  16. package/dist/src/app/attachmentDownloader.js.map +1 -1
  17. package/dist/src/app/authorization.d.ts +26 -18
  18. package/dist/src/app/authorization.js +26 -18
  19. package/dist/src/app/authorization.js.map +1 -1
  20. package/dist/src/app/routeRank.d.ts +10 -3
  21. package/dist/src/app/routeRank.js +10 -3
  22. package/dist/src/app/routeRank.js.map +1 -1
  23. package/dist/src/app/streaming/streamingResponse.d.ts +23 -2
  24. package/dist/src/app/streaming/streamingResponse.js +23 -2
  25. package/dist/src/app/streaming/streamingResponse.js.map +1 -1
  26. package/dist/src/app/turnState.d.ts +69 -19
  27. package/dist/src/app/turnState.js +69 -19
  28. package/dist/src/app/turnState.js.map +1 -1
  29. package/dist/src/auth/authConfiguration.d.ts +16 -9
  30. package/dist/src/auth/authConfiguration.js +11 -6
  31. package/dist/src/auth/authConfiguration.js.map +1 -1
  32. package/dist/src/auth/jwt-middleware.js +26 -18
  33. package/dist/src/auth/jwt-middleware.js.map +1 -1
  34. package/dist/src/cards/adaptiveCard.d.ts +1 -1
  35. package/dist/src/headerPropagation.d.ts +18 -6
  36. package/dist/src/state/agentState.d.ts +23 -7
  37. package/dist/src/state/agentState.js +19 -7
  38. package/dist/src/state/agentState.js.map +1 -1
  39. package/dist/src/state/agentStatePropertyAccesor.d.ts +63 -41
  40. package/dist/src/state/agentStatePropertyAccesor.js +43 -32
  41. package/dist/src/state/agentStatePropertyAccesor.js.map +1 -1
  42. package/dist/src/storage/fileStorage.d.ts +8 -6
  43. package/dist/src/storage/fileStorage.js +8 -6
  44. package/dist/src/storage/fileStorage.js.map +1 -1
  45. package/dist/src/storage/memoryStorage.d.ts +12 -7
  46. package/dist/src/storage/memoryStorage.js +12 -7
  47. package/dist/src/storage/memoryStorage.js.map +1 -1
  48. package/dist/src/storage/storage.d.ts +18 -1
  49. package/dist/src/turnContext.d.ts +31 -20
  50. package/dist/src/turnContext.js +31 -20
  51. package/dist/src/turnContext.js.map +1 -1
  52. package/package.json +2 -2
  53. package/src/activityHandler.ts +0 -1
  54. package/src/agent-client/agentResponseHandler.ts +6 -6
  55. package/src/app/adaptiveCards/adaptiveCardsActions.ts +12 -4
  56. package/src/app/agentApplication.ts +24 -7
  57. package/src/app/appRoute.ts +8 -4
  58. package/src/app/attachmentDownloader.ts +3 -1
  59. package/src/app/authorization.ts +26 -18
  60. package/src/app/routeRank.ts +10 -3
  61. package/src/app/streaming/streamingResponse.ts +23 -2
  62. package/src/app/turnState.ts +69 -19
  63. package/src/auth/authConfiguration.ts +16 -9
  64. package/src/auth/jwt-middleware.ts +24 -17
  65. package/src/cards/adaptiveCard.ts +1 -1
  66. package/src/headerPropagation.ts +18 -6
  67. package/src/state/agentState.ts +23 -7
  68. package/src/state/agentStatePropertyAccesor.ts +63 -41
  69. package/src/storage/fileStorage.ts +8 -6
  70. package/src/storage/memoryStorage.ts +12 -7
  71. package/src/storage/storage.ts +18 -1
  72. package/src/turnContext.ts +31 -20
@@ -67,7 +67,7 @@ export interface AuthorizationHandlers extends Record<string, AuthHandler> {}
67
67
  * - Sign-in success/failure event handling
68
68
  * - Automatic configuration from environment variables
69
69
  *
70
- * Example usage:
70
+ * @example
71
71
  * ```typescript
72
72
  * const auth = new Authorization(storage, {
73
73
  * 'microsoft': {
@@ -81,6 +81,7 @@ export interface AuthorizationHandlers extends Record<string, AuthHandler> {}
81
81
  * await context.sendActivity('Welcome! You are now signed in.');
82
82
  * });
83
83
  * ```
84
+ *
84
85
  */
85
86
  export class Authorization {
86
87
  /**
@@ -92,10 +93,6 @@ export class Authorization {
92
93
  /**
93
94
  * Creates a new instance of Authorization.
94
95
  *
95
- * @param storage - The storage system to use for state management.
96
- * @param authHandlers - Configuration for OAuth providers.
97
- * @throws {Error} If storage is null/undefined or no auth handlers are provided.
98
- *
99
96
  * @remarks
100
97
  * The constructor initializes all configured auth handlers and sets up OAuth flows.
101
98
  * It automatically configures handler properties from environment variables if not provided:
@@ -103,7 +100,7 @@ export class Authorization {
103
100
  * - Connection title: {handlerId}_connectionTitle
104
101
  * - Connection text: {handlerId}_connectionText
105
102
  *
106
- * Example usage:
103
+ * @example
107
104
  * ```typescript
108
105
  * const auth = new Authorization(storage, {
109
106
  * 'microsoft': {
@@ -115,6 +112,11 @@ export class Authorization {
115
112
  * }
116
113
  * });
117
114
  * ```
115
+ *
116
+ * @param storage - The storage system to use for state management.
117
+ * @param authHandlers - Configuration for OAuth providers.
118
+ * @throws {Error} If storage is null/undefined or no auth handlers are provided.
119
+ *
118
120
  */
119
121
  constructor (private storage: Storage, authHandlers: AuthorizationHandlers, userTokenClient: UserTokenClient) {
120
122
  if (storage === undefined || storage === null) {
@@ -145,19 +147,20 @@ export class Authorization {
145
147
  * @param authHandlerId - ID of the auth handler to use.
146
148
  * @returns A promise that resolves to the token response from the OAuth provider.
147
149
  * @throws {Error} If the auth handler is not configured.
148
- * @public
149
150
  *
150
151
  * @remarks
151
152
  * This method retrieves an existing token for the specified auth handler.
152
153
  * The token may be cached and will be retrieved from the OAuth provider if needed.
153
154
  *
154
- * Example usage:
155
+ * @example
155
156
  * ```typescript
156
157
  * const tokenResponse = await auth.getToken(context, 'microsoft');
157
158
  * if (tokenResponse.token) {
158
159
  * console.log('User is authenticated');
159
160
  * }
160
161
  * ```
162
+ *
163
+ * @public
161
164
  */
162
165
  public async getToken (context: TurnContext, authHandlerId: string): Promise<TokenResponse> {
163
166
  logger.info('getToken from user token service for authHandlerId:', authHandlerId)
@@ -188,14 +191,13 @@ export class Authorization {
188
191
  * @param authHandlerId - ID of the auth handler to use.
189
192
  * @returns A promise that resolves to the exchanged token response.
190
193
  * @throws {Error} If the auth handler is not configured.
191
- * @public
192
194
  *
193
195
  * @remarks
194
196
  * This method handles token exchange scenarios, particularly for on-behalf-of (OBO) flows.
195
197
  * It checks if the current token is exchangeable (e.g., has audience starting with 'api://')
196
198
  * and performs the appropriate token exchange using MSAL.
197
199
  *
198
- * Example usage:
200
+ * @example
199
201
  * ```typescript
200
202
  * const exchangedToken = await auth.exchangeToken(
201
203
  * context,
@@ -203,6 +205,8 @@ export class Authorization {
203
205
  * 'microsoft'
204
206
  * );
205
207
  * ```
208
+ *
209
+ * @public
206
210
  */
207
211
  public async exchangeToken (context: TurnContext, scopes: string[], authHandlerId: string): Promise<TokenResponse> {
208
212
  logger.info('exchangeToken from user token service for authHandlerId:', authHandlerId)
@@ -256,7 +260,6 @@ export class Authorization {
256
260
  * @param authHandlerId - ID of the auth handler to use.
257
261
  * @returns A promise that resolves to the token response from the OAuth provider.
258
262
  * @throws {Error} If the auth handler is not configured.
259
- * @public
260
263
  *
261
264
  * @remarks
262
265
  * This method manages the complete OAuth authentication flow:
@@ -267,7 +270,7 @@ export class Authorization {
267
270
  * The method automatically manages the sign-in state and continuation activities,
268
271
  * allowing the conversation to resume after successful authentication.
269
272
  *
270
- * Example usage:
273
+ * @example
271
274
  * ```typescript
272
275
  * const tokenResponse = await auth.beginOrContinueFlow(context, state, 'microsoft');
273
276
  * if (tokenResponse && tokenResponse.token) {
@@ -275,6 +278,8 @@ export class Authorization {
275
278
  * await context.sendActivity('Authentication successful!');
276
279
  * }
277
280
  * ```
281
+ *
282
+ * @public
278
283
  */
279
284
  public async beginOrContinueFlow (context: TurnContext, state: TurnState, authHandlerId: string, secRoute: boolean = true) : Promise<TokenResponse> {
280
285
  const authHandler = this.getAuthHandlerOrThrow(authHandlerId)
@@ -329,14 +334,13 @@ export class Authorization {
329
334
  * @param authHandlerId - Optional ID of the auth handler to use for sign out. If not provided, signs out from all handlers.
330
335
  * @returns A promise that resolves when sign out is complete.
331
336
  * @throws {Error} If the specified auth handler is not configured.
332
- * @public
333
337
  *
334
338
  * @remarks
335
339
  * This method clears the user's token and resets the authentication state.
336
340
  * If no specific authHandlerId is provided, it signs out from all configured handlers.
337
341
  * This ensures complete cleanup of authentication state across all providers.
338
342
  *
339
- * Example usage:
343
+ * @example
340
344
  * ```typescript
341
345
  * // Sign out from specific handler
342
346
  * await auth.signOut(context, state, 'microsoft');
@@ -344,6 +348,8 @@ export class Authorization {
344
348
  * // Sign out from all handlers
345
349
  * await auth.signOut(context, state);
346
350
  * ```
351
+ *
352
+ * @public
347
353
  */
348
354
  async signOut (context: TurnContext, state: TurnState, authHandlerId?: string) : Promise<void> {
349
355
  logger.info('signOut for authHandlerId:', authHandlerId)
@@ -368,20 +374,21 @@ export class Authorization {
368
374
  * Sets a handler to be called when sign-in is successfully completed.
369
375
  *
370
376
  * @param handler - The handler function to call on successful sign-in.
371
- * @public
372
377
  *
373
378
  * @remarks
374
379
  * This method allows you to register a callback that will be invoked whenever
375
380
  * a user successfully completes the authentication process. The handler receives
376
381
  * the turn context, state, and the ID of the auth handler that was used.
377
382
  *
378
- * Example usage:
383
+ * @example
379
384
  * ```typescript
380
385
  * auth.onSignInSuccess(async (context, state, authHandlerId) => {
381
386
  * await context.sendActivity(`Welcome! You signed in using ${authHandlerId}.`);
382
387
  * // Perform any post-authentication setup
383
388
  * });
384
389
  * ```
390
+ *
391
+ * @public
385
392
  */
386
393
  public onSignInSuccess (handler: (context: TurnContext, state: TurnState, authHandlerId?: string) => Promise<void>) {
387
394
  this._signInSuccessHandler = handler
@@ -397,7 +404,6 @@ export class Authorization {
397
404
  * Sets a handler to be called when sign-in fails.
398
405
  *
399
406
  * @param handler - The handler function to call on sign-in failure.
400
- * @public
401
407
  *
402
408
  * @remarks
403
409
  * This method allows you to register a callback that will be invoked whenever
@@ -410,13 +416,15 @@ export class Authorization {
410
416
  * - Network connectivity issues
411
417
  * - OAuth provider errors
412
418
  *
413
- * Example usage:
419
+ * @example
414
420
  * ```typescript
415
421
  * auth.onSignInFailure(async (context, state, authHandlerId, errorMessage) => {
416
422
  * await context.sendActivity(`Sign-in failed: ${errorMessage || 'Unknown error'}`);
417
423
  * await context.sendActivity('Please try signing in again.');
418
424
  * });
419
425
  * ```
426
+ *
427
+ * @public
420
428
  */
421
429
  public onSignInFailure (handler: (context: TurnContext, state: TurnState, authHandlerId?: string, errorMessage?: string) => Promise<void>) {
422
430
  this._signInFailureHandler = handler
@@ -26,10 +26,13 @@
26
26
  * this.onMessage('dupText', handler1, undefined, RouteRank.Last);
27
27
  * this.onMessage('dupText', handler2, undefined, RouteRank.First); // This executes first
28
28
  * ```
29
+ *
29
30
  */
30
31
  export enum RouteRank {
31
32
  /**
32
- * Highest priority rank (value: 0). Routes with this rank are evaluated first
33
+ * Highest priority rank (value: 0).
34
+ *
35
+ * Routes with this rank are evaluated
33
36
  * before any other routes. Use this for critical routes that must take precedence
34
37
  * over all others, such as high-priority message handlers or override handlers
35
38
  * that should execute before any other matching routes.
@@ -37,7 +40,9 @@ export enum RouteRank {
37
40
  First = 0,
38
41
 
39
42
  /**
40
- * Lowest priority rank (value: Number.MAX_VALUE). Routes with this rank are
43
+ * Lowest priority rank (value: Number.MAX_VALUE).
44
+ *
45
+ * Routes with this rank are
41
46
  * evaluated last, after all other routes have been considered. Ideal for
42
47
  * catch-all message handlers, fallback activity handlers, or default responses
43
48
  * that should only match when no other routes apply.
@@ -45,7 +50,9 @@ export enum RouteRank {
45
50
  Last = Number.MAX_VALUE,
46
51
 
47
52
  /**
48
- * Default priority rank (value: Number.MAX_VALUE / 2). This is the standard
53
+ * Default priority rank (value: Number.MAX_VALUE / 2).
54
+ *
55
+ * This is the standard
49
56
  * rank for most routes that don't require special ordering. Routes with this
50
57
  * rank are evaluated after high-priority routes but before low-priority ones.
51
58
  * Use this when you don't need to specify a particular evaluation order.
@@ -13,6 +13,7 @@ const logger = debug('agents:streamingResponse')
13
13
 
14
14
  /**
15
15
  * A helper class for streaming responses to the client.
16
+ *
16
17
  * @remarks
17
18
  * This class is used to send a series of updates to the client in a single response. The expected
18
19
  * sequence of calls is:
@@ -43,6 +44,7 @@ export class StreamingResponse {
43
44
 
44
45
  /**
45
46
  * Creates a new StreamingResponse instance.
47
+ *
46
48
  * @param {TurnContext} context - Context for the current turn of conversation with the user.
47
49
  * @returns {TurnContext} - The context for the current turn of conversation with the user.
48
50
  */
@@ -52,7 +54,9 @@ export class StreamingResponse {
52
54
 
53
55
  /**
54
56
  * Gets the stream ID of the current response.
57
+ *
55
58
  * @returns {string | undefined} - The stream ID of the current response.
59
+ *
56
60
  * @remarks
57
61
  * Assigned after the initial update is sent.
58
62
  */
@@ -69,6 +73,7 @@ export class StreamingResponse {
69
73
 
70
74
  /**
71
75
  * Gets the number of updates sent for the stream.
76
+ *
72
77
  * @returns {number} - The number of updates sent for the stream.
73
78
  */
74
79
  public get updatesSent (): number {
@@ -77,6 +82,7 @@ export class StreamingResponse {
77
82
 
78
83
  /**
79
84
  * Queues an informative update to be sent to the client.
85
+ *
80
86
  * @param {string} text Text of the update to send.
81
87
  */
82
88
  public queueInformativeUpdate (text: string): void {
@@ -98,11 +104,14 @@ export class StreamingResponse {
98
104
 
99
105
  /**
100
106
  * Queues a chunk of partial message text to be sent to the client
107
+ *
108
+ * @param {string} text Partial text of the message to send.
109
+ * @param {Citation[]} citations Citations to be included in the message.
110
+ *
101
111
  * @remarks
102
112
  * The text we be sent as quickly as possible to the client. Chunks may be combined before
103
113
  * delivery to the client.
104
- * @param {string} text Partial text of the message to send.
105
- * @param {Citation[]} citations Citations to be included in the message.
114
+ *
106
115
  */
107
116
  public queueTextChunk (text: string, citations?: Citation[]): void {
108
117
  if (this._ended) {
@@ -121,6 +130,7 @@ export class StreamingResponse {
121
130
 
122
131
  /**
123
132
  * Ends the stream by sending the final message to the client.
133
+ *
124
134
  * @returns {Promise<void>} - A promise representing the async operation
125
135
  */
126
136
  public endStream (): Promise<void> {
@@ -138,6 +148,7 @@ export class StreamingResponse {
138
148
 
139
149
  /**
140
150
  * Sets the attachments to attach to the final chunk.
151
+ *
141
152
  * @param attachments List of attachments.
142
153
  */
143
154
  public setAttachments (attachments: Attachment[]): void {
@@ -146,6 +157,7 @@ export class StreamingResponse {
146
157
 
147
158
  /**
148
159
  * Sets the sensitivity label to attach to the final chunk.
160
+ *
149
161
  * @param sensitivityLabel The sensitivty label.
150
162
  */
151
163
  public setSensitivityLabel (sensitivityLabel: SensitivityUsageInfo): void {
@@ -154,6 +166,7 @@ export class StreamingResponse {
154
166
 
155
167
  /**
156
168
  * Sets the citations for the full message.
169
+ *
157
170
  * @param {Citation[]} citations Citations to be included in the message.
158
171
  */
159
172
  public setCitations (citations: Citation[]): void {
@@ -183,6 +196,7 @@ export class StreamingResponse {
183
196
  * Sets the Feedback Loop in Teams that allows a user to
184
197
  * give thumbs up or down to a response.
185
198
  * Default is `false`.
199
+ *
186
200
  * @param enableFeedbackLoop If true, the feedback loop is enabled.
187
201
  */
188
202
  public setFeedbackLoop (enableFeedbackLoop: boolean): void {
@@ -191,6 +205,7 @@ export class StreamingResponse {
191
205
 
192
206
  /**
193
207
  * Sets the type of UI to use for the feedback loop.
208
+ *
194
209
  * @param feedbackLoopType The type of the feedback loop.
195
210
  */
196
211
  public setFeedbackLoopType (feedbackLoopType: 'default' | 'custom'): void {
@@ -200,6 +215,7 @@ export class StreamingResponse {
200
215
  /**
201
216
  * Sets the the Generated by AI label in Teams
202
217
  * Default is `false`.
218
+ *
203
219
  * @param enableGeneratedByAILabel If true, the label is added.
204
220
  */
205
221
  public setGeneratedByAILabel (enableGeneratedByAILabel: boolean): void {
@@ -208,6 +224,7 @@ export class StreamingResponse {
208
224
 
209
225
  /**
210
226
  * Returns the most recently streamed message.
227
+ *
211
228
  * @returns The streamed message.
212
229
  */
213
230
  public getMessage (): string {
@@ -216,6 +233,7 @@ export class StreamingResponse {
216
233
 
217
234
  /**
218
235
  * Waits for the outgoing activity queue to be empty.
236
+ *
219
237
  * @returns {Promise<void>} - A promise representing the async operation.
220
238
  */
221
239
  public waitForQueue (): Promise<void> {
@@ -224,6 +242,7 @@ export class StreamingResponse {
224
242
 
225
243
  /**
226
244
  * Queues the next chunk of text to be sent to the client.
245
+ *
227
246
  * @private
228
247
  */
229
248
  private queueNextChunk (): void {
@@ -280,6 +299,7 @@ export class StreamingResponse {
280
299
 
281
300
  /**
282
301
  * Sends any queued activities to the client until the queue is empty.
302
+ *
283
303
  * @returns {Promise<void>} - A promise that will be resolved once the queue is empty.
284
304
  * @private
285
305
  */
@@ -305,6 +325,7 @@ export class StreamingResponse {
305
325
 
306
326
  /**
307
327
  * Sends an activity to the client and saves the stream ID returned.
328
+ *
308
329
  * @param {Activity} activity - The activity to send.
309
330
  * @returns {Promise<void>} - A promise representing the async operation.
310
331
  * @private
@@ -40,12 +40,18 @@ export interface DefaultTempState {
40
40
  }
41
41
 
42
42
  /**
43
- * @summary Base class defining a collection of turn state scopes.
43
+ * Base class defining a collection of turn state scopes.
44
+ *
45
+ * @typeParam TConversationState - Type for conversation-scoped state
46
+ * @typeParam TUserState - Type for user-scoped state
47
+ * @typeParam TTempState - Type for temporary state that exists only for the current turn
48
+ * @typeParam TSSOState - Type for Single Sign-On (SSO) state
49
+ *
44
50
  * @remarks
45
51
  * Developers can create a derived class that extends `TurnState` to add additional state scopes.
46
52
  *
47
53
  * @example
48
- * ```JavaScript
54
+ * ```javascript
49
55
  * class MyTurnState extends TurnState {
50
56
  * protected async onComputeStorageKeys(context) {
51
57
  * const keys = await super.onComputeStorageKeys(context);
@@ -70,10 +76,7 @@ export interface DefaultTempState {
70
76
  * }
71
77
  * }
72
78
  * ```
73
- * @typeParam TConversationState - Type for conversation-scoped state
74
- * @typeParam TUserState - Type for user-scoped state
75
- * @typeParam TTempState - Type for temporary state that exists only for the current turn
76
- * @typeParam TSSOState - Type for Single Sign-On (SSO) state
79
+ *
77
80
  */
78
81
  export class TurnState<
79
82
  TConversationState = DefaultConversationState,
@@ -87,9 +90,12 @@ export class TurnState<
87
90
 
88
91
  /**
89
92
  * Gets the conversation-scoped state.
90
- * This state is shared by all users in the same conversation.
93
+ *
91
94
  * @returns The conversation state object
92
95
  * @throws Error if state hasn't been loaded
96
+ *
97
+ * @remarks
98
+ * This state is shared by all users in the same conversation.
93
99
  */
94
100
  public get conversation (): TConversationState {
95
101
  const scope = this.getScope(CONVERSATION_SCOPE)
@@ -101,6 +107,7 @@ export class TurnState<
101
107
 
102
108
  /**
103
109
  * Sets the conversation-scoped state.
110
+ *
104
111
  * @param value - The new conversation state object
105
112
  * @throws Error if state hasn't been loaded
106
113
  */
@@ -114,6 +121,7 @@ export class TurnState<
114
121
 
115
122
  /**
116
123
  * Gets whether the state has been loaded from storage
124
+ *
117
125
  * @returns True if the state has been loaded, false otherwise
118
126
  */
119
127
  public get isLoaded (): boolean {
@@ -122,9 +130,12 @@ export class TurnState<
122
130
 
123
131
  /**
124
132
  * Gets the temporary state for the current turn.
125
- * This state is not persisted between turns.
133
+ *
126
134
  * @returns The temporary state object
127
135
  * @throws Error if state hasn't been loaded
136
+ *
137
+ * @remarks
138
+ * This state is not persisted between turns.
128
139
  */
129
140
  public get temp (): TTempState {
130
141
  const scope = this.getScope(TEMP_SCOPE)
@@ -136,6 +147,7 @@ export class TurnState<
136
147
 
137
148
  /**
138
149
  * Sets the temporary state for the current turn.
150
+ *
139
151
  * @param value - The new temporary state object
140
152
  * @throws Error if state hasn't been loaded
141
153
  */
@@ -149,9 +161,12 @@ export class TurnState<
149
161
 
150
162
  /**
151
163
  * Gets the user-scoped state.
152
- * This state is unique to each user and persists across conversations.
164
+ *
153
165
  * @returns The user state object
154
166
  * @throws Error if state hasn't been loaded
167
+ *
168
+ * @remarks
169
+ * This state is unique to each user and persists across conversations.
155
170
  */
156
171
  public get user (): TUserState {
157
172
  const scope = this.getScope(USER_SCOPE)
@@ -163,6 +178,7 @@ export class TurnState<
163
178
 
164
179
  /**
165
180
  * Sets the user-scoped state.
181
+ *
166
182
  * @param value - The new user state object
167
183
  * @throws Error if state hasn't been loaded
168
184
  */
@@ -176,8 +192,11 @@ export class TurnState<
176
192
 
177
193
  /**
178
194
  * Marks the conversation state for deletion.
179
- * The state will be deleted from storage on the next call to save().
195
+ *
180
196
  * @throws Error if state hasn't been loaded
197
+ *
198
+ * @remarks
199
+ * The state will be deleted from storage on the next call to save().
181
200
  */
182
201
  public deleteConversationState (): void {
183
202
  const scope = this.getScope(CONVERSATION_SCOPE)
@@ -189,8 +208,11 @@ export class TurnState<
189
208
 
190
209
  /**
191
210
  * Marks the temporary state for deletion.
192
- * Since temporary state is not persisted, this just clears the in-memory object.
211
+ *
193
212
  * @throws Error if state hasn't been loaded
213
+ *
214
+ * @remarks
215
+ * Since temporary state is not persisted, this just clears the in-memory object.
194
216
  */
195
217
  public deleteTempState (): void {
196
218
  const scope = this.getScope(TEMP_SCOPE)
@@ -202,8 +224,11 @@ export class TurnState<
202
224
 
203
225
  /**
204
226
  * Marks the user state for deletion.
205
- * The state will be deleted from storage on the next call to save().
227
+ *
206
228
  * @throws Error if state hasn't been loaded
229
+ *
230
+ * @remarks
231
+ * The state will be deleted from storage on the next call to save().
207
232
  */
208
233
  public deleteUserState (): void {
209
234
  const scope = this.getScope(USER_SCOPE)
@@ -215,6 +240,7 @@ export class TurnState<
215
240
 
216
241
  /**
217
242
  * Gets a specific state scope by name.
243
+ *
218
244
  * @param scope - The name of the scope to retrieve
219
245
  * @returns The state entry for the scope, or undefined if not found
220
246
  */
@@ -224,8 +250,11 @@ export class TurnState<
224
250
 
225
251
  /**
226
252
  * Deletes a value from state by dot-notation path.
227
- * Format: "scope.property" or just "property" (defaults to temp scope)
253
+ *
228
254
  * @param path - The path to the value to delete
255
+ *
256
+ * @remarks
257
+ * Format: "scope.property" or just "property" (defaults to temp scope)
229
258
  */
230
259
  public deleteValue (path: string): void {
231
260
  const { scope, name } = this.getScopeAndName(path)
@@ -236,9 +265,12 @@ export class TurnState<
236
265
 
237
266
  /**
238
267
  * Checks if a value exists in state by dot-notation path.
239
- * Format: "scope.property" or just "property" (defaults to temp scope)
268
+ *
240
269
  * @param path - The path to check
241
270
  * @returns True if the value exists, false otherwise
271
+ *
272
+ * @remarks
273
+ * Format: "scope.property" or just "property" (defaults to temp scope)
242
274
  */
243
275
  public hasValue (path: string): boolean {
244
276
  const { scope, name } = this.getScopeAndName(path)
@@ -247,10 +279,13 @@ export class TurnState<
247
279
 
248
280
  /**
249
281
  * Gets a value from state by dot-notation path.
250
- * Format: "scope.property" or just "property" (defaults to temp scope)
282
+ *
251
283
  * @typeParam TValue - The type of the value to retrieve
252
284
  * @param path - The path to the value
253
285
  * @returns The value at the specified path
286
+ *
287
+ * @remarks
288
+ * Format: "scope.property" or just "property" (defaults to temp scope)
254
289
  */
255
290
  public getValue<TValue = unknown>(path: string): TValue {
256
291
  const { scope, name } = this.getScopeAndName(path)
@@ -259,9 +294,12 @@ export class TurnState<
259
294
 
260
295
  /**
261
296
  * Sets a value in state by dot-notation path.
262
- * Format: "scope.property" or just "property" (defaults to temp scope)
297
+ *
263
298
  * @param path - The path to set
264
299
  * @param value - The value to set
300
+ *
301
+ * @remarks
302
+ * Format: "scope.property" or just "property" (defaults to temp scope)
265
303
  */
266
304
  public setValue (path: string, value: unknown): void {
267
305
  const { scope, name } = this.getScopeAndName(path)
@@ -270,6 +308,7 @@ export class TurnState<
270
308
 
271
309
  /**
272
310
  * Loads state from storage into memory.
311
+ *
273
312
  * @param context - The turn context
274
313
  * @param storage - Optional storage provider (if not provided, state will be in-memory only)
275
314
  * @param force - If true, forces a reload from storage even if state is already loaded
@@ -321,11 +360,14 @@ export class TurnState<
321
360
 
322
361
  /**
323
362
  * Saves state changes to storage.
324
- * Only changed scopes will be persisted.
363
+ *
325
364
  * @param context - The turn context
326
365
  * @param storage - Optional storage provider (if not provided, state changes won't be persisted)
327
366
  * @returns Promise that resolves when the save operation is complete
328
367
  * @throws Error if state hasn't been loaded
368
+ *
369
+ * @remarks
370
+ * Only changed scopes will be persisted.
329
371
  */
330
372
  public async save (context: TurnContext, storage?: Storage): Promise<void> {
331
373
  if (!this._isLoaded && this._loadingPromise) {
@@ -378,9 +420,13 @@ export class TurnState<
378
420
 
379
421
  /**
380
422
  * Computes the storage keys for each scope based on the turn context.
381
- * Override this method in derived classes to add or modify storage keys.
423
+ *
382
424
  * @param context - The turn context
383
425
  * @returns Promise that resolves to a dictionary of scope names to storage keys
426
+ *
427
+ * @remarks
428
+ * Override this method in derived classes to add or modify storage keys.
429
+ *
384
430
  * @protected
385
431
  */
386
432
  protected onComputeStorageKeys (context: TurnContext): Promise<Record<string, string>> {
@@ -414,9 +460,13 @@ export class TurnState<
414
460
 
415
461
  /**
416
462
  * Parses a dot-notation path into scope and property name.
417
- * If no scope is specified, defaults to the temp scope.
463
+ *
418
464
  * @param path - The path to parse (format: "scope.property" or just "property")
419
465
  * @returns Object containing the scope entry and property name
466
+ *
467
+ * @remarks
468
+ * If no scope is specified, defaults to the temp scope.
469
+ *
420
470
  * @private
421
471
  */
422
472
  private getScopeAndName (path: string): { scope: TurnStateEntry; name: string } {
@@ -48,10 +48,12 @@ export interface AuthConfiguration {
48
48
  FICClientId?: string,
49
49
 
50
50
  /**
51
- * Entra Authentication Endpoint to use, If not populated the Entra Public Cloud endpoint is assumed.
51
+ * Entra Authentication Endpoint to use.
52
+ *
53
+ * @remarks
54
+ * If not populated the Entra Public Cloud endpoint is assumed.
52
55
  * This example of Public Cloud Endpoint is https://login.microsoftonline.com
53
- @remarks
54
- see also https://learn.microsoft.com/entra/identity-platform/authentication-national-cloud
56
+ * see also https://learn.microsoft.com/entra/identity-platform/authentication-national-cloud
55
57
  */
56
58
  authority?: string
57
59
  }
@@ -59,6 +61,12 @@ export interface AuthConfiguration {
59
61
  /**
60
62
  * Loads the authentication configuration from environment variables.
61
63
  *
64
+ * @returns The authentication configuration.
65
+ * @throws Will throw an error if clientId is not provided in production.
66
+ *
67
+ * @remarks
68
+ * - `clientId` is required
69
+ *
62
70
  * @example
63
71
  * ```
64
72
  * tenantId=your-tenant-id
@@ -73,10 +81,7 @@ export interface AuthConfiguration {
73
81
  * connectionName=your-connection-name
74
82
  * authority=your-authority-endpoint
75
83
  * ```
76
- * @remarks
77
- * - `clientId` is required
78
- * @returns The authentication configuration.
79
- * @throws Will throw an error if clientId is not provided in production.
84
+ *
80
85
  */
81
86
  export const loadAuthConfigFromEnv: (cnxName?: string) => AuthConfiguration = (cnxName?: string) => {
82
87
  if (cnxName === undefined) {
@@ -122,14 +127,16 @@ export const loadAuthConfigFromEnv: (cnxName?: string) => AuthConfiguration = (c
122
127
  /**
123
128
  * Loads the agent authentication configuration from previous version environment variables.
124
129
  *
130
+ * @returns The agent authentication configuration.
131
+ * @throws Will throw an error if MicrosoftAppId is not provided in production.
132
+ *
125
133
  * @example
126
134
  * ```
127
135
  * MicrosoftAppId=your-client-id
128
136
  * MicrosoftAppPassword=your-client-secret
129
137
  * MicrosoftAppTenantId=your-tenant-id
130
138
  * ```
131
- * @returns The agent authentication configuration.
132
- * @throws Will throw an error if MicrosoftAppId is not provided in production.
139
+ *
133
140
  */
134
141
  export const loadPrevAuthConfigFromEnv: () => AuthConfiguration = () => {
135
142
  if (process.env.MicrosoftAppId === undefined && process.env.NODE_ENV === 'production') {