@microsoft/agents-hosting 0.5.12-g2d752e9b13 → 0.5.19-gc1e2ea1096

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 (58) hide show
  1. package/dist/src/app/agentApplication.d.ts +186 -20
  2. package/dist/src/app/agentApplication.js +234 -32
  3. package/dist/src/app/agentApplication.js.map +1 -1
  4. package/dist/src/app/agentApplicationBuilder.d.ts +1 -1
  5. package/dist/src/app/agentApplicationOptions.d.ts +1 -1
  6. package/dist/src/app/appRoute.d.ts +5 -0
  7. package/dist/src/app/authorization.d.ts +294 -0
  8. package/dist/src/app/authorization.js +379 -0
  9. package/dist/src/app/authorization.js.map +1 -0
  10. package/dist/src/app/index.d.ts +1 -1
  11. package/dist/src/app/index.js +1 -1
  12. package/dist/src/app/index.js.map +1 -1
  13. package/dist/src/app/streaming/streamingResponse.js +1 -1
  14. package/dist/src/app/streaming/streamingResponse.js.map +1 -1
  15. package/dist/src/auth/authConfiguration.d.ts +2 -2
  16. package/dist/src/auth/authConfiguration.js +36 -17
  17. package/dist/src/auth/authConfiguration.js.map +1 -1
  18. package/dist/src/auth/index.d.ts +1 -0
  19. package/dist/src/auth/index.js +1 -0
  20. package/dist/src/auth/index.js.map +1 -1
  21. package/dist/src/auth/jwt-middleware.js.map +1 -1
  22. package/dist/src/auth/msalTokenCredential.d.ts +10 -0
  23. package/dist/src/auth/msalTokenCredential.js +19 -0
  24. package/dist/src/auth/msalTokenCredential.js.map +1 -0
  25. package/dist/src/auth/msalTokenProvider.d.ts +1 -0
  26. package/dist/src/auth/msalTokenProvider.js +15 -0
  27. package/dist/src/auth/msalTokenProvider.js.map +1 -1
  28. package/dist/src/baseAdapter.d.ts +1 -1
  29. package/dist/src/baseAdapter.js +0 -4
  30. package/dist/src/baseAdapter.js.map +1 -1
  31. package/dist/src/cloudAdapter.d.ts +1 -0
  32. package/dist/src/cloudAdapter.js.map +1 -1
  33. package/dist/src/oauth/oAuthFlow.d.ts +53 -9
  34. package/dist/src/oauth/oAuthFlow.js +164 -35
  35. package/dist/src/oauth/oAuthFlow.js.map +1 -1
  36. package/dist/src/oauth/userTokenClient.js +4 -0
  37. package/dist/src/oauth/userTokenClient.js.map +1 -1
  38. package/package.json +4 -3
  39. package/src/app/agentApplication.ts +247 -32
  40. package/src/app/agentApplicationBuilder.ts +1 -1
  41. package/src/app/agentApplicationOptions.ts +1 -1
  42. package/src/app/appRoute.ts +6 -0
  43. package/src/app/authorization.ts +424 -0
  44. package/src/app/index.ts +1 -1
  45. package/src/app/streaming/streamingResponse.ts +1 -1
  46. package/src/auth/authConfiguration.ts +36 -19
  47. package/src/auth/index.ts +1 -0
  48. package/src/auth/jwt-middleware.ts +1 -1
  49. package/src/auth/msalTokenCredential.ts +14 -0
  50. package/src/auth/msalTokenProvider.ts +17 -1
  51. package/src/baseAdapter.ts +1 -1
  52. package/src/cloudAdapter.ts +2 -2
  53. package/src/oauth/oAuthFlow.ts +197 -35
  54. package/src/oauth/userTokenClient.ts +3 -0
  55. package/dist/src/app/oauth/authorization.d.ts +0 -88
  56. package/dist/src/app/oauth/authorization.js +0 -134
  57. package/dist/src/app/oauth/authorization.js.map +0 -1
  58. package/src/app/oauth/authorization.ts +0 -160
@@ -13,31 +13,54 @@ import { AgentApplicationOptions } from './agentApplicationOptions'
13
13
  import { AppRoute } from './appRoute'
14
14
  import { ConversationUpdateEvents } from './conversationUpdateEvents'
15
15
  import { AgentExtension } from './extensions'
16
- import { Authorization } from './oauth/authorization'
16
+ import { Authorization, SignInState } from './authorization'
17
17
  import { RouteHandler } from './routeHandler'
18
18
  import { RouteSelector } from './routeSelector'
19
19
  import { TurnEvents } from './turnEvents'
20
20
  import { TurnState } from './turnState'
21
21
 
22
- const logger = debug('agents:agent-application')
22
+ const logger = debug('agents:app')
23
23
 
24
24
  const TYPING_TIMER_DELAY = 1000
25
+
26
+ /**
27
+ * Event handler function type for application events.
28
+ * @template TState - The state type extending TurnState.
29
+ * @param context - The turn context containing activity information.
30
+ * @param state - The current turn state.
31
+ * @returns A promise that resolves to a boolean indicating whether to continue execution.
32
+ */
25
33
  export type ApplicationEventHandler<TState extends TurnState> = (context: TurnContext, state: TState) => Promise<boolean>
26
34
 
27
35
  /**
28
- * Executes the application logic for a given turn context.
36
+ * Main application class for handling agent conversations and routing.
29
37
  *
30
- * @param turnContext - The context for the current turn of the conversation.
31
- * @returns A promise that resolves when the application logic has completed.
38
+ * @template TState - The state type extending TurnState.
32
39
  *
33
40
  * @remarks
34
- * This method is the entry point for processing a turn in the conversation.
35
- * It delegates the actual processing to the `runInternal` method, which handles
36
- * the core logic for routing and executing handlers.
41
+ * The AgentApplication class provides a framework for building conversational agents.
42
+ * It handles routing activities to appropriate handlers, manages conversation state,
43
+ * supports authentication flows, and provides various event handling capabilities.
44
+ *
45
+ * Key features:
46
+ * - Activity routing based on type, content, or custom selectors
47
+ * - State management with automatic load/save
48
+ * - OAuth authentication support
49
+ * - Typing indicators and long-running message support
50
+ * - Extensible architecture with custom extensions
51
+ * - Event handlers for before/after turn processing
37
52
  *
38
53
  * Example usage:
39
54
  * ```typescript
40
- * const app = new AgentApplication();
55
+ * const app = new AgentApplication<MyState>({
56
+ * storage: myStorage,
57
+ * adapter: myAdapter
58
+ * });
59
+ *
60
+ * app.onMessage('hello', async (context, state) => {
61
+ * await context.sendActivity('Hello there!');
62
+ * });
63
+ *
41
64
  * await app.run(turnContext);
42
65
  * ```
43
66
  */
@@ -52,6 +75,32 @@ export class AgentApplication<TState extends TurnState> {
52
75
  protected readonly _extensions: AgentExtension<TState>[] = []
53
76
  private readonly _adaptiveCards: AdaptiveCardsActions<TState>
54
77
 
78
+ /**
79
+ * Creates a new instance of AgentApplication.
80
+ *
81
+ * @param options - Optional configuration options for the application.
82
+ *
83
+ * @remarks
84
+ * The constructor initializes the application with default settings and applies
85
+ * any provided options. It sets up the adapter, authorization, and other core
86
+ * components based on the configuration.
87
+ *
88
+ * Default options:
89
+ * - startTypingTimer: false
90
+ * - longRunningMessages: false
91
+ * - removeRecipientMention: true
92
+ * - turnStateFactory: Creates a new TurnState instance
93
+ *
94
+ * Example usage:
95
+ * ```typescript
96
+ * const app = new AgentApplication({
97
+ * storage: myStorage,
98
+ * adapter: myAdapter,
99
+ * startTypingTimer: true,
100
+ * authorization: { connectionName: 'oauth' }
101
+ * });
102
+ * ```
103
+ */
55
104
  public constructor (options?: Partial<AgentApplicationOptions<TState>>) {
56
105
  this._options = {
57
106
  ...options,
@@ -74,18 +123,13 @@ export class AgentApplication<TState extends TurnState> {
74
123
  if (this._options.longRunningMessages && !this._adapter && !this._options.agentAppId) {
75
124
  throw new Error('The Application.longRunningMessages property is unavailable because no adapter was configured in the app.')
76
125
  }
77
- }
78
-
79
- /**
80
- * Gets the adapter associated with the application.
81
- * @throws Error if the adapter is not configured.
82
- */
83
- public get adapter (): BaseAdapter {
84
- return this._adapter!
126
+ logger.debug('AgentApplication created with options:', this._options)
85
127
  }
86
128
 
87
129
  /**
88
130
  * Gets the authorization instance for the application.
131
+ *
132
+ * @returns The authorization instance.
89
133
  * @throws Error if no authentication options were configured.
90
134
  */
91
135
  public get authorization (): Authorization {
@@ -97,12 +141,38 @@ export class AgentApplication<TState extends TurnState> {
97
141
 
98
142
  /**
99
143
  * Gets the options used to configure the application.
144
+ *
100
145
  * @returns The application options.
101
146
  */
102
147
  public get options (): AgentApplicationOptions<TState> {
103
148
  return this._options
104
149
  }
105
150
 
151
+ /**
152
+ * Gets the adapter used by the application.
153
+ *
154
+ * @returns The adapter instance.
155
+ */
156
+ public get adapter (): BaseAdapter {
157
+ return this._adapter!
158
+ }
159
+
160
+ /**
161
+ * Gets the adaptive cards actions handler for the application.
162
+ *
163
+ * @returns The adaptive cards actions instance.
164
+ *
165
+ * @remarks
166
+ * The adaptive cards actions handler provides functionality for handling
167
+ * adaptive card interactions, such as submit actions and other card-based events.
168
+ *
169
+ * Example usage:
170
+ * ```typescript
171
+ * app.adaptiveCards.onSubmit('myCardId', async (context, state, data) => {
172
+ * await context.sendActivity(`Received data: ${JSON.stringify(data)}`);
173
+ * });
174
+ * ```
175
+ */
106
176
  public get adaptiveCards (): AdaptiveCardsActions<TState> {
107
177
  return this._adaptiveCards
108
178
  }
@@ -137,6 +207,8 @@ export class AgentApplication<TState extends TurnState> {
137
207
  *
138
208
  * @param selector - The selector function that determines if a route should handle the current activity.
139
209
  * @param handler - The handler function that will be called if the selector returns true.
210
+ * @param isInvokeRoute - Whether this route is for invoke activities. Defaults to false.
211
+ * @param authHandlers - Array of authentication handler names for this route. Defaults to empty array.
140
212
  * @returns The current instance of the application.
141
213
  *
142
214
  * @remarks
@@ -152,8 +224,8 @@ export class AgentApplication<TState extends TurnState> {
152
224
  * );
153
225
  * ```
154
226
  */
155
- public addRoute (selector: RouteSelector, handler: RouteHandler<TState>, isInvokeRoute: boolean = false): this {
156
- this._routes.push({ selector, handler, isInvokeRoute })
227
+ public addRoute (selector: RouteSelector, handler: RouteHandler<TState>, isInvokeRoute: boolean = false, authHandlers: string[] = []): this {
228
+ this._routes.push({ selector, handler, isInvokeRoute, authHandlers })
157
229
  return this
158
230
  }
159
231
 
@@ -162,6 +234,7 @@ export class AgentApplication<TState extends TurnState> {
162
234
  *
163
235
  * @param type - The activity type(s) to handle. Can be a string, RegExp, RouteSelector, or array of these types.
164
236
  * @param handler - The handler function that will be called when the specified activity type is received.
237
+ * @param authHandlers - Array of authentication handler names for this activity. Defaults to empty array.
165
238
  * @returns The current instance of the application.
166
239
  *
167
240
  * @remarks
@@ -177,11 +250,12 @@ export class AgentApplication<TState extends TurnState> {
177
250
  */
178
251
  public onActivity (
179
252
  type: string | RegExp | RouteSelector | (string | RegExp | RouteSelector)[],
180
- handler: (context: TurnContext, state: TState) => Promise<void>
253
+ handler: (context: TurnContext, state: TState) => Promise<void>,
254
+ authHandlers: string[] = []
181
255
  ): this {
182
256
  (Array.isArray(type) ? type : [type]).forEach((t) => {
183
257
  const selector = this.createActivitySelector(t)
184
- this.addRoute(selector, handler)
258
+ this.addRoute(selector, handler, false, authHandlers)
185
259
  })
186
260
  return this
187
261
  }
@@ -191,6 +265,7 @@ export class AgentApplication<TState extends TurnState> {
191
265
  *
192
266
  * @param event - The conversation update event to handle (e.g., 'membersAdded', 'membersRemoved').
193
267
  * @param handler - The handler function that will be called when the specified event occurs.
268
+ * @param authHandlers - Array of authentication handler names for this event. Defaults to empty array.
194
269
  * @returns The current instance of the application.
195
270
  * @throws Error if the handler is not a function.
196
271
  *
@@ -211,7 +286,8 @@ export class AgentApplication<TState extends TurnState> {
211
286
  */
212
287
  public onConversationUpdate (
213
288
  event: ConversationUpdateEvents,
214
- handler: (context: TurnContext, state: TState) => Promise<void>
289
+ handler: (context: TurnContext, state: TState) => Promise<void>,
290
+ authHandlers: string[] = []
215
291
  ): this {
216
292
  if (typeof handler !== 'function') {
217
293
  throw new Error(
@@ -220,12 +296,13 @@ export class AgentApplication<TState extends TurnState> {
220
296
  }
221
297
 
222
298
  const selector = this.createConversationUpdateSelector(event)
223
- this.addRoute(selector, handler)
299
+ this.addRoute(selector, handler, false, authHandlers)
224
300
  return this
225
301
  }
226
302
 
227
303
  /**
228
304
  * Continues a conversation asynchronously.
305
+ *
229
306
  * @param conversationReferenceOrContext - The conversation reference or turn context.
230
307
  * @param logic - The logic to execute during the conversation.
231
308
  * @returns A promise that resolves when the conversation logic has completed.
@@ -262,6 +339,7 @@ export class AgentApplication<TState extends TurnState> {
262
339
  * @param keyword - The keyword, pattern, or selector function to match against message text.
263
340
  * Can be a string, RegExp, RouteSelector, or array of these types.
264
341
  * @param handler - The handler function that will be called when a matching message is received.
342
+ * @param authHandlers - Array of authentication handler names for this message handler. Defaults to empty array.
265
343
  * @returns The current instance of the application.
266
344
  *
267
345
  * @remarks
@@ -276,18 +354,19 @@ export class AgentApplication<TState extends TurnState> {
276
354
  * await context.sendActivity('Hello there!');
277
355
  * });
278
356
  *
279
- * app.onMessage(/help., async (context, state) => {
357
+ * app.onMessage(/help/, async (context, state) => {
280
358
  * await context.sendActivity('How can I help you?');
281
359
  * });
282
360
  * ```
283
361
  */
284
362
  public onMessage (
285
363
  keyword: string | RegExp | RouteSelector | (string | RegExp | RouteSelector)[],
286
- handler: (context: TurnContext, state: TState) => Promise<void>
364
+ handler: (context: TurnContext, state: TState) => Promise<void>,
365
+ authHandlers: string[] = []
287
366
  ): this {
288
367
  (Array.isArray(keyword) ? keyword : [keyword]).forEach((k) => {
289
368
  const selector = this.createMessageSelector(k)
290
- this.addRoute(selector, handler)
369
+ this.addRoute(selector, handler, false, authHandlers)
291
370
  })
292
371
  return this
293
372
  }
@@ -310,7 +389,7 @@ export class AgentApplication<TState extends TurnState> {
310
389
  * });
311
390
  * ```
312
391
  */
313
- public onSignInSuccess (handler: (context: TurnContext, state: TurnState, id?: string) => void): this {
392
+ public onSignInSuccess (handler: (context: TurnContext, state: TurnState, id?: string) => Promise<void>): this {
314
393
  if (this.options.authorization) {
315
394
  this.authorization.onSignInSuccess(handler)
316
395
  } else {
@@ -321,6 +400,35 @@ export class AgentApplication<TState extends TurnState> {
321
400
  return this
322
401
  }
323
402
 
403
+ /**
404
+ * Sets a handler to be called when a sign-in attempt fails.
405
+ *
406
+ * @param handler - The handler function to be called after a failed sign-in attempt.
407
+ * @returns The current instance of the application.
408
+ * @throws Error if authentication options were not configured.
409
+ *
410
+ * @remarks
411
+ * This method allows you to handle cases where a user fails to authenticate,
412
+ * such as when they cancel the sign-in process or an error occurs.
413
+ *
414
+ * Example usage:
415
+ * ```typescript
416
+ * app.onSignInFailure(async (context, state) => {
417
+ * await context.sendActivity('Sign-in failed. Please try again.');
418
+ * });
419
+ * ```
420
+ */
421
+ public onSignInFailure (handler: (context: TurnContext, state: TurnState, id?: string) => Promise<void>): this {
422
+ if (this.options.authorization) {
423
+ this.authorization.onSignInFailure(handler)
424
+ } else {
425
+ throw new Error(
426
+ 'The Application.authorization property is unavailable because no authorization options were configured.'
427
+ )
428
+ }
429
+ return this
430
+ }
431
+
324
432
  /**
325
433
  * Adds a handler for message reaction added events.
326
434
  *
@@ -406,15 +514,36 @@ export class AgentApplication<TState extends TurnState> {
406
514
 
407
515
  /**
408
516
  * Executes the application logic for a given turn context.
409
- * @private
517
+ *
410
518
  * @param turnContext - The context for the current turn of the conversation.
411
519
  * @returns A promise that resolves to true if a handler was executed, false otherwise.
412
520
  *
413
521
  * @remarks
414
- * This method is the core logic for processing a turn in the conversation.
522
+ * This is the core internal method that processes a turn in the conversation.
415
523
  * It handles routing and executing handlers based on the activity type and content.
524
+ * While this method is public, it's typically called internally by the `run` method.
525
+ *
526
+ * The method performs the following operations:
527
+ * 1. Starts typing timer if configured
528
+ * 2. Processes mentions if configured
529
+ * 3. Loads turn state
530
+ * 4. Handles authentication flows
531
+ * 5. Executes before-turn event handlers
532
+ * 6. Downloads files if file downloaders are configured
533
+ * 7. Routes to appropriate handlers
534
+ * 8. Executes after-turn event handlers
535
+ * 9. Saves turn state
536
+ *
537
+ * Example usage:
538
+ * ```typescript
539
+ * const handled = await app.runInternal(turnContext);
540
+ * if (!handled) {
541
+ * console.log('No handler matched the activity');
542
+ * }
543
+ * ```
416
544
  */
417
545
  public async runInternal (turnContext: TurnContext): Promise<boolean> {
546
+ logger.info('Running application with activity:', turnContext.activity.id!)
418
547
  return await this.startLongRunningCall(turnContext, async (context) => {
419
548
  try {
420
549
  if (this._options.startTypingTimer) {
@@ -433,6 +562,25 @@ export class AgentApplication<TState extends TurnState> {
433
562
  const state = turnStateFactory()
434
563
  await state.load(context, storage)
435
564
 
565
+ const signInState : SignInState = state.getValue('user.__SIGNIN_STATE_')
566
+ logger.debug('SignIn State:', signInState)
567
+ if (this._authorization && signInState && signInState.completed === false) {
568
+ const flowState = await this._authorization.authHandlers[signInState.handlerId!]?.flow?.getFlowState(context)
569
+ logger.debug('Flow State:', flowState)
570
+ if (flowState && flowState.flowStarted === true) {
571
+ const tokenResponse = await this._authorization.beginOrContinueFlow(turnContext, state, signInState?.handlerId!)
572
+ const savedAct = Activity.fromObject(signInState?.continuationActivity!)
573
+ if (tokenResponse?.token && tokenResponse.token.length > 0) {
574
+ logger.info('resending continuation activity:', savedAct.text)
575
+ await this.run(new TurnContext(context.adapter, savedAct))
576
+ await state.deleteValue('user.__SIGNIN_STATE_')
577
+ return true
578
+ }
579
+ }
580
+
581
+ // return true
582
+ }
583
+
436
584
  if (!(await this.callEventHandlers(context, state, this._beforeTurn))) {
437
585
  await state.save(context, storage)
438
586
  return false
@@ -447,10 +595,24 @@ export class AgentApplication<TState extends TurnState> {
447
595
  state.temp.inputFiles = inputFiles
448
596
  }
449
597
 
450
- for (let i = 0; i < this._routes.length; i++) {
451
- const route = this._routes[i]
598
+ for (const route of this._routes) {
452
599
  if (await route.selector(context)) {
453
- await route.handler(context, state)
600
+ if (route.authHandlers === undefined || route.authHandlers.length === 0) {
601
+ await route.handler(context, state)
602
+ } else {
603
+ let signInComplete = false
604
+ for (const authHandlerId of route.authHandlers) {
605
+ logger.info(`Executing route handler for authHandlerId: ${authHandlerId}`)
606
+ const tokenResponse = await this._authorization?.beginOrContinueFlow(turnContext, state, authHandlerId)
607
+ signInComplete = (tokenResponse?.token !== undefined && tokenResponse?.token.length > 0)
608
+ if (!signInComplete) {
609
+ break
610
+ }
611
+ }
612
+ if (signInComplete) {
613
+ await route.handler(context, state)
614
+ }
615
+ }
454
616
 
455
617
  if (await this.callEventHandlers(context, state, this._afterTurn)) {
456
618
  await state.save(context, storage)
@@ -569,6 +731,26 @@ export class AgentApplication<TState extends TurnState> {
569
731
  }
570
732
  }
571
733
 
734
+ /**
735
+ * Registers an extension with the application.
736
+ *
737
+ * @template T - The extension type extending AgentExtension.
738
+ * @param extension - The extension instance to register.
739
+ * @param regcb - Callback function called after successful registration.
740
+ * @throws Error if the extension is already registered.
741
+ *
742
+ * @remarks
743
+ * Extensions provide a way to add custom functionality to the application.
744
+ * Each extension can only be registered once to prevent conflicts.
745
+ *
746
+ * Example usage:
747
+ * ```typescript
748
+ * const myExtension = new MyCustomExtension();
749
+ * app.registerExtension(myExtension, (ext) => {
750
+ * console.log('Extension registered:', ext.name);
751
+ * });
752
+ * ```
753
+ */
572
754
  public registerExtension<T extends AgentExtension<TState>> (extension: T, regcb : (ext:T) => void): void {
573
755
  if (this._extensions.includes(extension)) {
574
756
  throw new Error('Extension already registered')
@@ -641,6 +823,14 @@ export class AgentApplication<TState extends TurnState> {
641
823
  return this
642
824
  }
643
825
 
826
+ /**
827
+ * Calls a series of event handlers in sequence.
828
+ *
829
+ * @param context - The turn context for the current conversation.
830
+ * @param state - The current turn state.
831
+ * @param handlers - Array of event handlers to call.
832
+ * @returns A promise that resolves to true if all handlers returned true, false otherwise.
833
+ */
644
834
  protected async callEventHandlers (
645
835
  context: TurnContext,
646
836
  state: TState,
@@ -656,6 +846,13 @@ export class AgentApplication<TState extends TurnState> {
656
846
  return true
657
847
  }
658
848
 
849
+ /**
850
+ * Starts a long-running call, potentially in a new conversation context.
851
+ *
852
+ * @param context - The turn context for the current conversation.
853
+ * @param handler - The handler function to execute.
854
+ * @returns A promise that resolves to the result of the handler.
855
+ */
659
856
  protected startLongRunningCall (
660
857
  context: TurnContext,
661
858
  handler: (context: TurnContext) => Promise<boolean>
@@ -681,6 +878,12 @@ export class AgentApplication<TState extends TurnState> {
681
878
  }
682
879
  }
683
880
 
881
+ /**
882
+ * Creates a selector function for activity types.
883
+ *
884
+ * @param type - The activity type to match. Can be a string, RegExp, or RouteSelector function.
885
+ * @returns A RouteSelector function that matches the specified activity type.
886
+ */
684
887
  private createActivitySelector (type: string | RegExp | RouteSelector): RouteSelector {
685
888
  if (typeof type === 'function') {
686
889
  return type
@@ -698,6 +901,12 @@ export class AgentApplication<TState extends TurnState> {
698
901
  }
699
902
  }
700
903
 
904
+ /**
905
+ * Creates a selector function for conversation update events.
906
+ *
907
+ * @param event - The conversation update event to match.
908
+ * @returns A RouteSelector function that matches the specified conversation update event.
909
+ */
701
910
  private createConversationUpdateSelector (event: ConversationUpdateEvents): RouteSelector {
702
911
  switch (event) {
703
912
  case 'membersAdded':
@@ -726,6 +935,12 @@ export class AgentApplication<TState extends TurnState> {
726
935
  }
727
936
  }
728
937
 
938
+ /**
939
+ * Creates a selector function for message content matching.
940
+ *
941
+ * @param keyword - The keyword, pattern, or selector function to match against message text.
942
+ * @returns A RouteSelector function that matches messages based on the specified keyword.
943
+ */
729
944
  private createMessageSelector (keyword: string | RegExp | RouteSelector): RouteSelector {
730
945
  if (typeof keyword === 'function') {
731
946
  return keyword
@@ -6,7 +6,7 @@
6
6
  import { Storage } from '../storage'
7
7
  import { AgentApplication } from './agentApplication'
8
8
  import { AgentApplicationOptions } from './agentApplicationOptions'
9
- import { AuthorizationHandlers } from './oauth/authorization'
9
+ import { AuthorizationHandlers } from './authorization'
10
10
  import { TurnState } from './turnState'
11
11
 
12
12
  /**
@@ -7,7 +7,7 @@ import { CloudAdapter } from '../cloudAdapter'
7
7
  import { Storage } from '../storage'
8
8
  import { AdaptiveCardsOptions } from './adaptiveCards'
9
9
  import { InputFileDownloader } from './inputFileDownloader'
10
- import { AuthorizationHandlers } from './oauth/authorization'
10
+ import { AuthorizationHandlers } from './authorization'
11
11
  import { TurnState } from './turnState'
12
12
 
13
13
  export interface AgentApplicationOptions<TState extends TurnState> {
@@ -23,4 +23,10 @@ export interface AppRoute<TState extends TurnState> {
23
23
  * Invoke routes are used for specific types of activities, such as messaging extensions.
24
24
  */
25
25
  isInvokeRoute?: boolean;
26
+
27
+ /**
28
+ * Optional list of authorization handlers that this route requires.
29
+ * If provided, the route will check for these handlers before processing.
30
+ */
31
+ authHandlers?: string[]
26
32
  }