@microsoft/agents-hosting 0.5.19-gc1e2ea1096 → 0.6.11
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.
- package/dist/src/activityHandler.d.ts +29 -5
- package/dist/src/activityHandler.js +30 -6
- package/dist/src/activityHandler.js.map +1 -1
- package/dist/src/agent-client/agentClient.js +1 -1
- package/dist/src/agent-client/agentClient.js.map +1 -1
- package/dist/src/agent-client/agentResponseHandler.d.ts +34 -0
- package/dist/src/agent-client/agentResponseHandler.js +35 -1
- package/dist/src/agent-client/agentResponseHandler.js.map +1 -1
- package/dist/src/app/adaptiveCards/adaptiveCardsActions.d.ts +23 -2
- package/dist/src/app/adaptiveCards/adaptiveCardsActions.js.map +1 -1
- package/dist/src/app/adaptiveCards/adaptiveCardsSearchParams.d.ts +1 -1
- package/dist/src/app/agentApplication.d.ts +46 -34
- package/dist/src/app/agentApplication.js +64 -40
- package/dist/src/app/agentApplication.js.map +1 -1
- package/dist/src/app/agentApplicationOptions.d.ts +74 -13
- package/dist/src/app/appRoute.d.ts +56 -2
- package/dist/src/app/attachmentDownloader.d.ts +1 -0
- package/dist/src/app/attachmentDownloader.js +2 -1
- package/dist/src/app/attachmentDownloader.js.map +1 -1
- package/dist/src/app/authorization.d.ts +1 -1
- package/dist/src/app/authorization.js +1 -1
- package/dist/src/app/authorization.js.map +1 -1
- package/dist/src/app/extensions.d.ts +37 -1
- package/dist/src/app/extensions.js +38 -2
- package/dist/src/app/extensions.js.map +1 -1
- package/dist/src/app/index.d.ts +2 -0
- package/dist/src/app/index.js +2 -0
- package/dist/src/app/index.js.map +1 -1
- package/dist/src/app/routeList.d.ts +13 -0
- package/dist/src/app/routeList.js +30 -0
- package/dist/src/app/routeList.js.map +1 -0
- package/dist/src/app/routeRank.d.ts +51 -0
- package/dist/src/app/routeRank.js +56 -0
- package/dist/src/app/routeRank.js.map +1 -0
- package/dist/src/app/streaming/streamingResponse.js +29 -41
- package/dist/src/app/streaming/streamingResponse.js.map +1 -1
- package/dist/src/app/turnState.d.ts +2 -0
- package/dist/src/app/turnState.js +3 -1
- package/dist/src/app/turnState.js.map +1 -1
- package/dist/src/auth/authConfiguration.d.ts +4 -0
- package/dist/src/auth/authConfiguration.js +4 -0
- package/dist/src/auth/authConfiguration.js.map +1 -1
- package/dist/src/auth/authProvider.d.ts +1 -1
- package/dist/src/auth/jwt-middleware.js +1 -1
- package/dist/src/auth/jwt-middleware.js.map +1 -1
- package/dist/src/auth/msalTokenCredential.d.ts +14 -0
- package/dist/src/auth/msalTokenCredential.js +14 -0
- package/dist/src/auth/msalTokenCredential.js.map +1 -1
- package/dist/src/auth/msalTokenProvider.js +4 -2
- package/dist/src/auth/msalTokenProvider.js.map +1 -1
- package/dist/src/baseAdapter.d.ts +22 -1
- package/dist/src/baseAdapter.js +23 -2
- package/dist/src/baseAdapter.js.map +1 -1
- package/dist/src/cards/adaptiveCard.d.ts +2 -0
- package/dist/src/cards/animationCard.d.ts +1 -1
- package/dist/src/cards/audioCard.d.ts +1 -1
- package/dist/src/cards/cardImage.d.ts +1 -1
- package/dist/src/cards/fact.d.ts +1 -1
- package/dist/src/cards/heroCard.d.ts +1 -1
- package/dist/src/cards/o365ConnectorCardSection.d.ts +5 -0
- package/dist/src/cloudAdapter.d.ts +11 -0
- package/dist/src/cloudAdapter.js +33 -4
- package/dist/src/cloudAdapter.js.map +1 -1
- package/dist/src/connector-client/connectorClient.js +1 -1
- package/dist/src/connector-client/connectorClient.js.map +1 -1
- package/dist/src/index.d.ts +0 -2
- package/dist/src/index.js +0 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/middlewareSet.js +1 -1
- package/dist/src/middlewareSet.js.map +1 -1
- package/dist/src/oauth/oAuthFlow.js +1 -1
- package/dist/src/oauth/oAuthFlow.js.map +1 -1
- package/dist/src/oauth/userTokenClient.js +1 -1
- package/dist/src/oauth/userTokenClient.js.map +1 -1
- package/dist/src/state/agentState.js +1 -1
- package/dist/src/state/agentState.js.map +1 -1
- package/dist/src/state/agentStatePropertyAccesor.d.ts +269 -38
- package/dist/src/state/agentStatePropertyAccesor.js +269 -38
- package/dist/src/state/agentStatePropertyAccesor.js.map +1 -1
- package/dist/src/statusCodes.d.ts +30 -0
- package/dist/src/statusCodes.js +30 -0
- package/dist/src/statusCodes.js.map +1 -1
- package/dist/src/storage/fileStorage.d.ts +97 -0
- package/dist/src/storage/fileStorage.js +97 -0
- package/dist/src/storage/fileStorage.js.map +1 -1
- package/dist/src/storage/memoryStorage.d.ts +2 -1
- package/dist/src/storage/memoryStorage.js +3 -2
- package/dist/src/storage/memoryStorage.js.map +1 -1
- package/dist/src/storage/storage.d.ts +1 -0
- package/dist/src/transcript/transcriptLoggerMiddleware.js +1 -1
- package/dist/src/transcript/transcriptLoggerMiddleware.js.map +1 -1
- package/dist/src/turnContext.d.ts +1 -0
- package/dist/src/turnContext.js +1 -0
- package/dist/src/turnContext.js.map +1 -1
- package/package.json +4 -5
- package/src/activityHandler.ts +30 -6
- package/src/agent-client/agentClient.ts +1 -1
- package/src/agent-client/agentResponseHandler.ts +35 -1
- package/src/app/adaptiveCards/adaptiveCardsActions.ts +23 -2
- package/src/app/adaptiveCards/adaptiveCardsSearchParams.ts +1 -1
- package/src/app/agentApplication.ts +70 -41
- package/src/app/agentApplicationOptions.ts +75 -13
- package/src/app/appRoute.ts +57 -2
- package/src/app/attachmentDownloader.ts +2 -1
- package/src/app/authorization.ts +2 -2
- package/src/app/extensions.ts +45 -2
- package/src/app/index.ts +2 -0
- package/src/app/routeList.ts +37 -0
- package/src/app/routeRank.ts +54 -0
- package/src/app/streaming/streamingResponse.ts +22 -69
- package/src/app/turnState.ts +3 -1
- package/src/auth/authConfiguration.ts +4 -0
- package/src/auth/authProvider.ts +1 -1
- package/src/auth/jwt-middleware.ts +1 -1
- package/src/auth/msalTokenCredential.ts +15 -0
- package/src/auth/msalTokenProvider.ts +4 -2
- package/src/baseAdapter.ts +25 -2
- package/src/cards/adaptiveCard.ts +2 -0
- package/src/cards/animationCard.ts +1 -1
- package/src/cards/audioCard.ts +1 -1
- package/src/cards/cardImage.ts +1 -1
- package/src/cards/fact.ts +1 -1
- package/src/cards/heroCard.ts +1 -1
- package/src/cards/o365ConnectorCardSection.ts +5 -0
- package/src/cloudAdapter.ts +36 -4
- package/src/connector-client/connectorClient.ts +1 -1
- package/src/index.ts +0 -2
- package/src/middlewareSet.ts +1 -1
- package/src/oauth/oAuthFlow.ts +1 -1
- package/src/oauth/userTokenClient.ts +1 -1
- package/src/state/agentState.ts +1 -1
- package/src/state/agentStatePropertyAccesor.ts +269 -38
- package/src/statusCodes.ts +30 -0
- package/src/storage/fileStorage.ts +99 -0
- package/src/storage/memoryStorage.ts +3 -2
- package/src/storage/storage.ts +1 -0
- package/src/transcript/transcriptLoggerMiddleware.ts +1 -1
- package/src/turnContext.ts +1 -0
- package/dist/src/logger.d.ts +0 -44
- package/dist/src/logger.js +0 -77
- package/dist/src/logger.js.map +0 -1
- package/src/logger.ts +0 -76
|
@@ -8,7 +8,6 @@ import { ResourceResponse } from '../connector-client';
|
|
|
8
8
|
import { TurnContext } from '../turnContext';
|
|
9
9
|
import { AdaptiveCardsActions } from './adaptiveCards';
|
|
10
10
|
import { AgentApplicationOptions } from './agentApplicationOptions';
|
|
11
|
-
import { AppRoute } from './appRoute';
|
|
12
11
|
import { ConversationUpdateEvents } from './conversationUpdateEvents';
|
|
13
12
|
import { AgentExtension } from './extensions';
|
|
14
13
|
import { Authorization } from './authorization';
|
|
@@ -16,6 +15,8 @@ import { RouteHandler } from './routeHandler';
|
|
|
16
15
|
import { RouteSelector } from './routeSelector';
|
|
17
16
|
import { TurnEvents } from './turnEvents';
|
|
18
17
|
import { TurnState } from './turnState';
|
|
18
|
+
import { RouteRank } from './routeRank';
|
|
19
|
+
import { RouteList } from './routeList';
|
|
19
20
|
/**
|
|
20
21
|
* Event handler function type for application events.
|
|
21
22
|
* @template TState - The state type extending TurnState.
|
|
@@ -42,10 +43,10 @@ export type ApplicationEventHandler<TState extends TurnState> = (context: TurnCo
|
|
|
42
43
|
* - Extensible architecture with custom extensions
|
|
43
44
|
* - Event handlers for before/after turn processing
|
|
44
45
|
*
|
|
45
|
-
*
|
|
46
|
+
* @example
|
|
46
47
|
* ```typescript
|
|
47
48
|
* const app = new AgentApplication<MyState>({
|
|
48
|
-
* storage:
|
|
49
|
+
* storage: new MemoryStorage(),
|
|
49
50
|
* adapter: myAdapter
|
|
50
51
|
* });
|
|
51
52
|
*
|
|
@@ -58,7 +59,7 @@ export type ApplicationEventHandler<TState extends TurnState> = (context: TurnCo
|
|
|
58
59
|
*/
|
|
59
60
|
export declare class AgentApplication<TState extends TurnState> {
|
|
60
61
|
protected readonly _options: AgentApplicationOptions<TState>;
|
|
61
|
-
protected readonly _routes:
|
|
62
|
+
protected readonly _routes: RouteList<TState>;
|
|
62
63
|
protected readonly _beforeTurn: ApplicationEventHandler<TState>[];
|
|
63
64
|
protected readonly _afterTurn: ApplicationEventHandler<TState>[];
|
|
64
65
|
private readonly _adapter?;
|
|
@@ -82,13 +83,14 @@ export declare class AgentApplication<TState extends TurnState> {
|
|
|
82
83
|
* - removeRecipientMention: true
|
|
83
84
|
* - turnStateFactory: Creates a new TurnState instance
|
|
84
85
|
*
|
|
85
|
-
*
|
|
86
|
+
* @example
|
|
86
87
|
* ```typescript
|
|
87
88
|
* const app = new AgentApplication({
|
|
88
|
-
* storage:
|
|
89
|
+
* storage: new MemoryStorage(),
|
|
89
90
|
* adapter: myAdapter,
|
|
90
91
|
* startTypingTimer: true,
|
|
91
|
-
* authorization: { connectionName: 'oauth' }
|
|
92
|
+
* authorization: { connectionName: 'oauth' },
|
|
93
|
+
* transcriptLogger: myTranscriptLogger,
|
|
92
94
|
* });
|
|
93
95
|
* ```
|
|
94
96
|
*/
|
|
@@ -121,9 +123,9 @@ export declare class AgentApplication<TState extends TurnState> {
|
|
|
121
123
|
* The adaptive cards actions handler provides functionality for handling
|
|
122
124
|
* adaptive card interactions, such as submit actions and other card-based events.
|
|
123
125
|
*
|
|
124
|
-
*
|
|
126
|
+
* @example
|
|
125
127
|
* ```typescript
|
|
126
|
-
* app.adaptiveCards.
|
|
128
|
+
* app.adaptiveCards.actionSubmit('doStuff', async (context, state, data) => {
|
|
127
129
|
* await context.sendActivity(`Received data: ${JSON.stringify(data)}`);
|
|
128
130
|
* });
|
|
129
131
|
* ```
|
|
@@ -139,7 +141,7 @@ export declare class AgentApplication<TState extends TurnState> {
|
|
|
139
141
|
* This method allows you to handle any errors that occur during turn processing.
|
|
140
142
|
* The handler will receive the turn context and the error that occurred.
|
|
141
143
|
*
|
|
142
|
-
*
|
|
144
|
+
* @example
|
|
143
145
|
* ```typescript
|
|
144
146
|
* app.onError(async (context, error) => {
|
|
145
147
|
* console.error(`An error occurred: ${error.message}`);
|
|
@@ -154,56 +156,63 @@ export declare class AgentApplication<TState extends TurnState> {
|
|
|
154
156
|
* @param selector - The selector function that determines if a route should handle the current activity.
|
|
155
157
|
* @param handler - The handler function that will be called if the selector returns true.
|
|
156
158
|
* @param isInvokeRoute - Whether this route is for invoke activities. Defaults to false.
|
|
159
|
+
* @param rank - The rank of the route, used to determine the order of evaluation. Defaults to RouteRank.Unspecified.
|
|
157
160
|
* @param authHandlers - Array of authentication handler names for this route. Defaults to empty array.
|
|
158
161
|
* @returns The current instance of the application.
|
|
159
162
|
*
|
|
160
163
|
* @remarks
|
|
161
|
-
* Routes are evaluated
|
|
164
|
+
* Routes are evaluated by rank order (if provided), otherwise, in the order they are added.
|
|
165
|
+
* Invoke-based activities receive special treatment and are matched separately as they typically
|
|
166
|
+
* have shorter execution timeouts.
|
|
162
167
|
*
|
|
163
|
-
*
|
|
168
|
+
* @example
|
|
164
169
|
* ```typescript
|
|
165
170
|
* app.addRoute(
|
|
166
171
|
* async (context) => context.activity.type === ActivityTypes.Message,
|
|
167
172
|
* async (context, state) => {
|
|
168
173
|
* await context.sendActivity('I received your message');
|
|
169
|
-
* }
|
|
174
|
+
* },
|
|
175
|
+
* false, // isInvokeRoute
|
|
176
|
+
* RouteRank.First // rank
|
|
170
177
|
* );
|
|
171
178
|
* ```
|
|
172
179
|
*/
|
|
173
|
-
addRoute(selector: RouteSelector, handler: RouteHandler<TState>, isInvokeRoute?: boolean, authHandlers?: string[]): this;
|
|
180
|
+
addRoute(selector: RouteSelector, handler: RouteHandler<TState>, isInvokeRoute?: boolean, rank?: number, authHandlers?: string[]): this;
|
|
174
181
|
/**
|
|
175
182
|
* Adds a handler for specific activity types.
|
|
176
183
|
*
|
|
177
184
|
* @param type - The activity type(s) to handle. Can be a string, RegExp, RouteSelector, or array of these types.
|
|
178
185
|
* @param handler - The handler function that will be called when the specified activity type is received.
|
|
179
186
|
* @param authHandlers - Array of authentication handler names for this activity. Defaults to empty array.
|
|
187
|
+
* @param rank - The rank of the route, used to determine the order of evaluation. Defaults to RouteRank.Unspecified.
|
|
180
188
|
* @returns The current instance of the application.
|
|
181
189
|
*
|
|
182
190
|
* @remarks
|
|
183
191
|
* This method allows you to register handlers for specific activity types such as 'message', 'conversationUpdate', etc.
|
|
184
192
|
* You can specify multiple activity types by passing an array.
|
|
185
193
|
*
|
|
186
|
-
*
|
|
194
|
+
* @example
|
|
187
195
|
* ```typescript
|
|
188
196
|
* app.onActivity(ActivityTypes.Message, async (context, state) => {
|
|
189
197
|
* await context.sendActivity('I received your message');
|
|
190
198
|
* });
|
|
191
199
|
* ```
|
|
192
200
|
*/
|
|
193
|
-
onActivity(type: string | RegExp | RouteSelector | (string | RegExp | RouteSelector)[], handler: (context: TurnContext, state: TState) => Promise<void>, authHandlers?: string[]): this;
|
|
201
|
+
onActivity(type: string | RegExp | RouteSelector | (string | RegExp | RouteSelector)[], handler: (context: TurnContext, state: TState) => Promise<void>, authHandlers?: string[], rank?: RouteRank): this;
|
|
194
202
|
/**
|
|
195
203
|
* Adds a handler for conversation update events.
|
|
196
204
|
*
|
|
197
205
|
* @param event - The conversation update event to handle (e.g., 'membersAdded', 'membersRemoved').
|
|
198
206
|
* @param handler - The handler function that will be called when the specified event occurs.
|
|
199
207
|
* @param authHandlers - Array of authentication handler names for this event. Defaults to empty array.
|
|
208
|
+
* @param rank - The rank of the route, used to determine the order of evaluation. Defaults to RouteRank.Unspecified.
|
|
200
209
|
* @returns The current instance of the application.
|
|
201
210
|
* @throws Error if the handler is not a function.
|
|
202
211
|
*
|
|
203
212
|
* @remarks
|
|
204
213
|
* Conversation update events occur when the state of a conversation changes, such as when members join or leave.
|
|
205
214
|
*
|
|
206
|
-
*
|
|
215
|
+
* @example
|
|
207
216
|
* ```typescript
|
|
208
217
|
* app.onConversationUpdate('membersAdded', async (context, state) => {
|
|
209
218
|
* const membersAdded = context.activity.membersAdded;
|
|
@@ -215,7 +224,7 @@ export declare class AgentApplication<TState extends TurnState> {
|
|
|
215
224
|
* });
|
|
216
225
|
* ```
|
|
217
226
|
*/
|
|
218
|
-
onConversationUpdate(event: ConversationUpdateEvents, handler: (context: TurnContext, state: TState) => Promise<void>, authHandlers?: string[]): this;
|
|
227
|
+
onConversationUpdate(event: ConversationUpdateEvents, handler: (context: TurnContext, state: TState) => Promise<void>, authHandlers?: string[], rank?: RouteRank): this;
|
|
219
228
|
/**
|
|
220
229
|
* Continues a conversation asynchronously.
|
|
221
230
|
*
|
|
@@ -232,6 +241,7 @@ export declare class AgentApplication<TState extends TurnState> {
|
|
|
232
241
|
* Can be a string, RegExp, RouteSelector, or array of these types.
|
|
233
242
|
* @param handler - The handler function that will be called when a matching message is received.
|
|
234
243
|
* @param authHandlers - Array of authentication handler names for this message handler. Defaults to empty array.
|
|
244
|
+
* @param rank - The rank of the route, used to determine the order of evaluation. Defaults to RouteRank.Unspecified.
|
|
235
245
|
* @returns The current instance of the application.
|
|
236
246
|
*
|
|
237
247
|
* @remarks
|
|
@@ -240,18 +250,18 @@ export declare class AgentApplication<TState extends TurnState> {
|
|
|
240
250
|
* If keyword is a RegExp, it tests the message text against the regular expression.
|
|
241
251
|
* If keyword is a function, it calls the function with the context to determine if the message matches.
|
|
242
252
|
*
|
|
243
|
-
*
|
|
253
|
+
* @example
|
|
244
254
|
* ```typescript
|
|
245
255
|
* app.onMessage('hello', async (context, state) => {
|
|
246
256
|
* await context.sendActivity('Hello there!');
|
|
247
257
|
* });
|
|
248
258
|
*
|
|
249
|
-
* app.onMessage(/help
|
|
259
|
+
* app.onMessage(/help/i, async (context, state) => {
|
|
250
260
|
* await context.sendActivity('How can I help you?');
|
|
251
261
|
* });
|
|
252
262
|
* ```
|
|
253
263
|
*/
|
|
254
|
-
onMessage(keyword: string | RegExp | RouteSelector | (string | RegExp | RouteSelector)[], handler: (context: TurnContext, state: TState) => Promise<void>, authHandlers?: string[]): this;
|
|
264
|
+
onMessage(keyword: string | RegExp | RouteSelector | (string | RegExp | RouteSelector)[], handler: (context: TurnContext, state: TState) => Promise<void>, authHandlers?: string[], rank?: RouteRank): this;
|
|
255
265
|
/**
|
|
256
266
|
* Sets a handler to be called when a user successfully signs in.
|
|
257
267
|
*
|
|
@@ -263,7 +273,7 @@ export declare class AgentApplication<TState extends TurnState> {
|
|
|
263
273
|
* This method allows you to perform actions after a user has successfully authenticated.
|
|
264
274
|
* The handler will receive the turn context and state.
|
|
265
275
|
*
|
|
266
|
-
*
|
|
276
|
+
* @example
|
|
267
277
|
* ```typescript
|
|
268
278
|
* app.onSignInSuccess(async (context, state) => {
|
|
269
279
|
* await context.sendActivity('You have successfully signed in!');
|
|
@@ -282,7 +292,7 @@ export declare class AgentApplication<TState extends TurnState> {
|
|
|
282
292
|
* This method allows you to handle cases where a user fails to authenticate,
|
|
283
293
|
* such as when they cancel the sign-in process or an error occurs.
|
|
284
294
|
*
|
|
285
|
-
*
|
|
295
|
+
* @example
|
|
286
296
|
* ```typescript
|
|
287
297
|
* app.onSignInFailure(async (context, state) => {
|
|
288
298
|
* await context.sendActivity('Sign-in failed. Please try again.');
|
|
@@ -294,13 +304,14 @@ export declare class AgentApplication<TState extends TurnState> {
|
|
|
294
304
|
* Adds a handler for message reaction added events.
|
|
295
305
|
*
|
|
296
306
|
* @param handler - The handler function that will be called when a message reaction is added.
|
|
307
|
+
* @param rank - The rank of the route, used to determine the order of evaluation. Defaults to RouteRank.Unspecified.
|
|
297
308
|
* @returns The current instance of the application.
|
|
298
309
|
*
|
|
299
310
|
* @remarks
|
|
300
311
|
* This method registers a handler that will be invoked when a user adds a reaction to a message,
|
|
301
312
|
* such as a like, heart, or other emoji reaction.
|
|
302
313
|
*
|
|
303
|
-
*
|
|
314
|
+
* @example
|
|
304
315
|
* ```typescript
|
|
305
316
|
* app.onMessageReactionAdded(async (context, state) => {
|
|
306
317
|
* const reactionsAdded = context.activity.reactionsAdded;
|
|
@@ -310,18 +321,19 @@ export declare class AgentApplication<TState extends TurnState> {
|
|
|
310
321
|
* });
|
|
311
322
|
* ```
|
|
312
323
|
*/
|
|
313
|
-
onMessageReactionAdded(handler: (context: TurnContext, state: TState) => Promise<void
|
|
324
|
+
onMessageReactionAdded(handler: (context: TurnContext, state: TState) => Promise<void>, rank?: RouteRank): this;
|
|
314
325
|
/**
|
|
315
326
|
* Adds a handler for message reaction removed events.
|
|
316
327
|
*
|
|
317
328
|
* @param handler - The handler function that will be called when a message reaction is removed.
|
|
329
|
+
* @param rank - The rank of the route, used to determine the order of evaluation. Defaults to RouteRank.Unspecified.
|
|
318
330
|
* @returns The current instance of the application.
|
|
319
331
|
*
|
|
320
332
|
* @remarks
|
|
321
333
|
* This method registers a handler that will be invoked when a user removes a reaction from a message,
|
|
322
334
|
* such as unliking or removing an emoji reaction.
|
|
323
335
|
*
|
|
324
|
-
*
|
|
336
|
+
* @example
|
|
325
337
|
* ```typescript
|
|
326
338
|
* app.onMessageReactionRemoved(async (context, state) => {
|
|
327
339
|
* const reactionsRemoved = context.activity.reactionsRemoved;
|
|
@@ -331,7 +343,7 @@ export declare class AgentApplication<TState extends TurnState> {
|
|
|
331
343
|
* });
|
|
332
344
|
* ```
|
|
333
345
|
*/
|
|
334
|
-
onMessageReactionRemoved(handler: (context: TurnContext, state: TState) => Promise<void
|
|
346
|
+
onMessageReactionRemoved(handler: (context: TurnContext, state: TState) => Promise<void>, rank?: RouteRank): this;
|
|
335
347
|
/**
|
|
336
348
|
* Executes the application logic for a given turn context.
|
|
337
349
|
*
|
|
@@ -343,7 +355,7 @@ export declare class AgentApplication<TState extends TurnState> {
|
|
|
343
355
|
* It delegates the actual processing to the `runInternal` method, which handles
|
|
344
356
|
* the core logic for routing and executing handlers.
|
|
345
357
|
*
|
|
346
|
-
*
|
|
358
|
+
* @example
|
|
347
359
|
* ```typescript
|
|
348
360
|
* const app = new AgentApplication();
|
|
349
361
|
* await app.run(turnContext);
|
|
@@ -372,7 +384,7 @@ export declare class AgentApplication<TState extends TurnState> {
|
|
|
372
384
|
* 8. Executes after-turn event handlers
|
|
373
385
|
* 9. Saves turn state
|
|
374
386
|
*
|
|
375
|
-
*
|
|
387
|
+
* @example
|
|
376
388
|
* ```typescript
|
|
377
389
|
* const handled = await app.runInternal(turnContext);
|
|
378
390
|
* if (!handled) {
|
|
@@ -393,7 +405,7 @@ export declare class AgentApplication<TState extends TurnState> {
|
|
|
393
405
|
* @remarks
|
|
394
406
|
* This method allows you to send messages proactively to a conversation, outside the normal turn flow.
|
|
395
407
|
*
|
|
396
|
-
*
|
|
408
|
+
* @example
|
|
397
409
|
* ```typescript
|
|
398
410
|
* // With conversation reference
|
|
399
411
|
* await app.sendProactiveActivity(conversationReference, 'Important notification!');
|
|
@@ -417,7 +429,7 @@ export declare class AgentApplication<TState extends TurnState> {
|
|
|
417
429
|
* The typing indicator helps provide feedback to users that the agent is processing
|
|
418
430
|
* their message, especially when responses might take time to generate.
|
|
419
431
|
*
|
|
420
|
-
*
|
|
432
|
+
* @example
|
|
421
433
|
* ```typescript
|
|
422
434
|
* app.startTypingTimer(turnContext);
|
|
423
435
|
* // Do some processing...
|
|
@@ -438,7 +450,7 @@ export declare class AgentApplication<TState extends TurnState> {
|
|
|
438
450
|
* Extensions provide a way to add custom functionality to the application.
|
|
439
451
|
* Each extension can only be registered once to prevent conflicts.
|
|
440
452
|
*
|
|
441
|
-
*
|
|
453
|
+
* @example
|
|
442
454
|
* ```typescript
|
|
443
455
|
* const myExtension = new MyCustomExtension();
|
|
444
456
|
* app.registerExtension(myExtension, (ext) => {
|
|
@@ -457,7 +469,7 @@ export declare class AgentApplication<TState extends TurnState> {
|
|
|
457
469
|
* from being sent. It's typically called automatically when a message is sent, but
|
|
458
470
|
* can also be called manually to stop the typing indicator.
|
|
459
471
|
*
|
|
460
|
-
*
|
|
472
|
+
* @example
|
|
461
473
|
* ```typescript
|
|
462
474
|
* app.startTypingTimer(turnContext);
|
|
463
475
|
* // Do some processing...
|
|
@@ -477,7 +489,7 @@ export declare class AgentApplication<TState extends TurnState> {
|
|
|
477
489
|
* Handlers added for 'beforeTurn' are executed before routing logic.
|
|
478
490
|
* Handlers added for 'afterTurn' are executed after routing logic.
|
|
479
491
|
*
|
|
480
|
-
*
|
|
492
|
+
* @example
|
|
481
493
|
* ```typescript
|
|
482
494
|
* app.onTurn('beforeTurn', async (context, state) => {
|
|
483
495
|
* console.log('Processing before turn');
|
|
@@ -6,11 +6,14 @@
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.AgentApplication = void 0;
|
|
8
8
|
const agents_activity_1 = require("@microsoft/agents-activity");
|
|
9
|
-
const logger_1 = require("
|
|
9
|
+
const logger_1 = require("@microsoft/agents-activity/src/logger");
|
|
10
10
|
const turnContext_1 = require("../turnContext");
|
|
11
11
|
const adaptiveCards_1 = require("./adaptiveCards");
|
|
12
12
|
const authorization_1 = require("./authorization");
|
|
13
13
|
const turnState_1 = require("./turnState");
|
|
14
|
+
const routeRank_1 = require("./routeRank");
|
|
15
|
+
const routeList_1 = require("./routeList");
|
|
16
|
+
const transcript_1 = require("../transcript");
|
|
14
17
|
const logger = (0, logger_1.debug)('agents:app');
|
|
15
18
|
const TYPING_TIMER_DELAY = 1000;
|
|
16
19
|
/**
|
|
@@ -31,10 +34,10 @@ const TYPING_TIMER_DELAY = 1000;
|
|
|
31
34
|
* - Extensible architecture with custom extensions
|
|
32
35
|
* - Event handlers for before/after turn processing
|
|
33
36
|
*
|
|
34
|
-
*
|
|
37
|
+
* @example
|
|
35
38
|
* ```typescript
|
|
36
39
|
* const app = new AgentApplication<MyState>({
|
|
37
|
-
* storage:
|
|
40
|
+
* storage: new MemoryStorage(),
|
|
38
41
|
* adapter: myAdapter
|
|
39
42
|
* });
|
|
40
43
|
*
|
|
@@ -62,18 +65,20 @@ class AgentApplication {
|
|
|
62
65
|
* - removeRecipientMention: true
|
|
63
66
|
* - turnStateFactory: Creates a new TurnState instance
|
|
64
67
|
*
|
|
65
|
-
*
|
|
68
|
+
* @example
|
|
66
69
|
* ```typescript
|
|
67
70
|
* const app = new AgentApplication({
|
|
68
|
-
* storage:
|
|
71
|
+
* storage: new MemoryStorage(),
|
|
69
72
|
* adapter: myAdapter,
|
|
70
73
|
* startTypingTimer: true,
|
|
71
|
-
* authorization: { connectionName: 'oauth' }
|
|
74
|
+
* authorization: { connectionName: 'oauth' },
|
|
75
|
+
* transcriptLogger: myTranscriptLogger,
|
|
72
76
|
* });
|
|
73
77
|
* ```
|
|
74
78
|
*/
|
|
75
79
|
constructor(options) {
|
|
76
|
-
|
|
80
|
+
var _a;
|
|
81
|
+
this._routes = new routeList_1.RouteList();
|
|
77
82
|
this._beforeTurn = [];
|
|
78
83
|
this._afterTurn = [];
|
|
79
84
|
this._extensions = [];
|
|
@@ -83,6 +88,7 @@ class AgentApplication {
|
|
|
83
88
|
startTypingTimer: (options === null || options === void 0 ? void 0 : options.startTypingTimer) !== undefined ? options.startTypingTimer : false,
|
|
84
89
|
longRunningMessages: (options === null || options === void 0 ? void 0 : options.longRunningMessages) !== undefined ? options.longRunningMessages : false,
|
|
85
90
|
removeRecipientMention: (options === null || options === void 0 ? void 0 : options.removeRecipientMention) !== undefined ? options.removeRecipientMention : true,
|
|
91
|
+
transcriptLogger: (options === null || options === void 0 ? void 0 : options.transcriptLogger) || undefined,
|
|
86
92
|
};
|
|
87
93
|
this._adaptiveCards = new adaptiveCards_1.AdaptiveCardsActions(this);
|
|
88
94
|
if (this._options.adapter) {
|
|
@@ -94,6 +100,14 @@ class AgentApplication {
|
|
|
94
100
|
if (this._options.longRunningMessages && !this._adapter && !this._options.agentAppId) {
|
|
95
101
|
throw new Error('The Application.longRunningMessages property is unavailable because no adapter was configured in the app.');
|
|
96
102
|
}
|
|
103
|
+
if (this._options.transcriptLogger) {
|
|
104
|
+
if (!this._options.adapter) {
|
|
105
|
+
throw new Error('The Application.transcriptLogger property is unavailable because no adapter was configured in the app.');
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
(_a = this._adapter) === null || _a === void 0 ? void 0 : _a.use(new transcript_1.TranscriptLoggerMiddleware(this._options.transcriptLogger));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
97
111
|
logger.debug('AgentApplication created with options:', this._options);
|
|
98
112
|
}
|
|
99
113
|
/**
|
|
@@ -133,9 +147,9 @@ class AgentApplication {
|
|
|
133
147
|
* The adaptive cards actions handler provides functionality for handling
|
|
134
148
|
* adaptive card interactions, such as submit actions and other card-based events.
|
|
135
149
|
*
|
|
136
|
-
*
|
|
150
|
+
* @example
|
|
137
151
|
* ```typescript
|
|
138
|
-
* app.adaptiveCards.
|
|
152
|
+
* app.adaptiveCards.actionSubmit('doStuff', async (context, state, data) => {
|
|
139
153
|
* await context.sendActivity(`Received data: ${JSON.stringify(data)}`);
|
|
140
154
|
* });
|
|
141
155
|
* ```
|
|
@@ -153,7 +167,7 @@ class AgentApplication {
|
|
|
153
167
|
* This method allows you to handle any errors that occur during turn processing.
|
|
154
168
|
* The handler will receive the turn context and the error that occurred.
|
|
155
169
|
*
|
|
156
|
-
*
|
|
170
|
+
* @example
|
|
157
171
|
* ```typescript
|
|
158
172
|
* app.onError(async (context, error) => {
|
|
159
173
|
* console.error(`An error occurred: ${error.message}`);
|
|
@@ -173,24 +187,29 @@ class AgentApplication {
|
|
|
173
187
|
* @param selector - The selector function that determines if a route should handle the current activity.
|
|
174
188
|
* @param handler - The handler function that will be called if the selector returns true.
|
|
175
189
|
* @param isInvokeRoute - Whether this route is for invoke activities. Defaults to false.
|
|
190
|
+
* @param rank - The rank of the route, used to determine the order of evaluation. Defaults to RouteRank.Unspecified.
|
|
176
191
|
* @param authHandlers - Array of authentication handler names for this route. Defaults to empty array.
|
|
177
192
|
* @returns The current instance of the application.
|
|
178
193
|
*
|
|
179
194
|
* @remarks
|
|
180
|
-
* Routes are evaluated
|
|
195
|
+
* Routes are evaluated by rank order (if provided), otherwise, in the order they are added.
|
|
196
|
+
* Invoke-based activities receive special treatment and are matched separately as they typically
|
|
197
|
+
* have shorter execution timeouts.
|
|
181
198
|
*
|
|
182
|
-
*
|
|
199
|
+
* @example
|
|
183
200
|
* ```typescript
|
|
184
201
|
* app.addRoute(
|
|
185
202
|
* async (context) => context.activity.type === ActivityTypes.Message,
|
|
186
203
|
* async (context, state) => {
|
|
187
204
|
* await context.sendActivity('I received your message');
|
|
188
|
-
* }
|
|
205
|
+
* },
|
|
206
|
+
* false, // isInvokeRoute
|
|
207
|
+
* RouteRank.First // rank
|
|
189
208
|
* );
|
|
190
209
|
* ```
|
|
191
210
|
*/
|
|
192
|
-
addRoute(selector, handler, isInvokeRoute = false, authHandlers = []) {
|
|
193
|
-
this._routes.
|
|
211
|
+
addRoute(selector, handler, isInvokeRoute = false, rank = routeRank_1.RouteRank.Unspecified, authHandlers = []) {
|
|
212
|
+
this._routes.addRoute(selector, handler, isInvokeRoute, rank, authHandlers);
|
|
194
213
|
return this;
|
|
195
214
|
}
|
|
196
215
|
/**
|
|
@@ -199,23 +218,24 @@ class AgentApplication {
|
|
|
199
218
|
* @param type - The activity type(s) to handle. Can be a string, RegExp, RouteSelector, or array of these types.
|
|
200
219
|
* @param handler - The handler function that will be called when the specified activity type is received.
|
|
201
220
|
* @param authHandlers - Array of authentication handler names for this activity. Defaults to empty array.
|
|
221
|
+
* @param rank - The rank of the route, used to determine the order of evaluation. Defaults to RouteRank.Unspecified.
|
|
202
222
|
* @returns The current instance of the application.
|
|
203
223
|
*
|
|
204
224
|
* @remarks
|
|
205
225
|
* This method allows you to register handlers for specific activity types such as 'message', 'conversationUpdate', etc.
|
|
206
226
|
* You can specify multiple activity types by passing an array.
|
|
207
227
|
*
|
|
208
|
-
*
|
|
228
|
+
* @example
|
|
209
229
|
* ```typescript
|
|
210
230
|
* app.onActivity(ActivityTypes.Message, async (context, state) => {
|
|
211
231
|
* await context.sendActivity('I received your message');
|
|
212
232
|
* });
|
|
213
233
|
* ```
|
|
214
234
|
*/
|
|
215
|
-
onActivity(type, handler, authHandlers = []) {
|
|
235
|
+
onActivity(type, handler, authHandlers = [], rank = routeRank_1.RouteRank.Unspecified) {
|
|
216
236
|
(Array.isArray(type) ? type : [type]).forEach((t) => {
|
|
217
237
|
const selector = this.createActivitySelector(t);
|
|
218
|
-
this.addRoute(selector, handler, false, authHandlers);
|
|
238
|
+
this.addRoute(selector, handler, false, rank, authHandlers);
|
|
219
239
|
});
|
|
220
240
|
return this;
|
|
221
241
|
}
|
|
@@ -225,13 +245,14 @@ class AgentApplication {
|
|
|
225
245
|
* @param event - The conversation update event to handle (e.g., 'membersAdded', 'membersRemoved').
|
|
226
246
|
* @param handler - The handler function that will be called when the specified event occurs.
|
|
227
247
|
* @param authHandlers - Array of authentication handler names for this event. Defaults to empty array.
|
|
248
|
+
* @param rank - The rank of the route, used to determine the order of evaluation. Defaults to RouteRank.Unspecified.
|
|
228
249
|
* @returns The current instance of the application.
|
|
229
250
|
* @throws Error if the handler is not a function.
|
|
230
251
|
*
|
|
231
252
|
* @remarks
|
|
232
253
|
* Conversation update events occur when the state of a conversation changes, such as when members join or leave.
|
|
233
254
|
*
|
|
234
|
-
*
|
|
255
|
+
* @example
|
|
235
256
|
* ```typescript
|
|
236
257
|
* app.onConversationUpdate('membersAdded', async (context, state) => {
|
|
237
258
|
* const membersAdded = context.activity.membersAdded;
|
|
@@ -243,12 +264,12 @@ class AgentApplication {
|
|
|
243
264
|
* });
|
|
244
265
|
* ```
|
|
245
266
|
*/
|
|
246
|
-
onConversationUpdate(event, handler, authHandlers = []) {
|
|
267
|
+
onConversationUpdate(event, handler, authHandlers = [], rank = routeRank_1.RouteRank.Unspecified) {
|
|
247
268
|
if (typeof handler !== 'function') {
|
|
248
269
|
throw new Error(`ConversationUpdate 'handler' for ${event} is ${typeof handler}. Type of 'handler' must be a function.`);
|
|
249
270
|
}
|
|
250
271
|
const selector = this.createConversationUpdateSelector(event);
|
|
251
|
-
this.addRoute(selector, handler, false, authHandlers);
|
|
272
|
+
this.addRoute(selector, handler, false, rank, authHandlers);
|
|
252
273
|
return this;
|
|
253
274
|
}
|
|
254
275
|
/**
|
|
@@ -282,6 +303,7 @@ class AgentApplication {
|
|
|
282
303
|
* Can be a string, RegExp, RouteSelector, or array of these types.
|
|
283
304
|
* @param handler - The handler function that will be called when a matching message is received.
|
|
284
305
|
* @param authHandlers - Array of authentication handler names for this message handler. Defaults to empty array.
|
|
306
|
+
* @param rank - The rank of the route, used to determine the order of evaluation. Defaults to RouteRank.Unspecified.
|
|
285
307
|
* @returns The current instance of the application.
|
|
286
308
|
*
|
|
287
309
|
* @remarks
|
|
@@ -290,21 +312,21 @@ class AgentApplication {
|
|
|
290
312
|
* If keyword is a RegExp, it tests the message text against the regular expression.
|
|
291
313
|
* If keyword is a function, it calls the function with the context to determine if the message matches.
|
|
292
314
|
*
|
|
293
|
-
*
|
|
315
|
+
* @example
|
|
294
316
|
* ```typescript
|
|
295
317
|
* app.onMessage('hello', async (context, state) => {
|
|
296
318
|
* await context.sendActivity('Hello there!');
|
|
297
319
|
* });
|
|
298
320
|
*
|
|
299
|
-
* app.onMessage(/help
|
|
321
|
+
* app.onMessage(/help/i, async (context, state) => {
|
|
300
322
|
* await context.sendActivity('How can I help you?');
|
|
301
323
|
* });
|
|
302
324
|
* ```
|
|
303
325
|
*/
|
|
304
|
-
onMessage(keyword, handler, authHandlers = []) {
|
|
326
|
+
onMessage(keyword, handler, authHandlers = [], rank = routeRank_1.RouteRank.Unspecified) {
|
|
305
327
|
(Array.isArray(keyword) ? keyword : [keyword]).forEach((k) => {
|
|
306
328
|
const selector = this.createMessageSelector(k);
|
|
307
|
-
this.addRoute(selector, handler, false, authHandlers);
|
|
329
|
+
this.addRoute(selector, handler, false, rank, authHandlers);
|
|
308
330
|
});
|
|
309
331
|
return this;
|
|
310
332
|
}
|
|
@@ -319,7 +341,7 @@ class AgentApplication {
|
|
|
319
341
|
* This method allows you to perform actions after a user has successfully authenticated.
|
|
320
342
|
* The handler will receive the turn context and state.
|
|
321
343
|
*
|
|
322
|
-
*
|
|
344
|
+
* @example
|
|
323
345
|
* ```typescript
|
|
324
346
|
* app.onSignInSuccess(async (context, state) => {
|
|
325
347
|
* await context.sendActivity('You have successfully signed in!');
|
|
@@ -346,7 +368,7 @@ class AgentApplication {
|
|
|
346
368
|
* This method allows you to handle cases where a user fails to authenticate,
|
|
347
369
|
* such as when they cancel the sign-in process or an error occurs.
|
|
348
370
|
*
|
|
349
|
-
*
|
|
371
|
+
* @example
|
|
350
372
|
* ```typescript
|
|
351
373
|
* app.onSignInFailure(async (context, state) => {
|
|
352
374
|
* await context.sendActivity('Sign-in failed. Please try again.');
|
|
@@ -366,13 +388,14 @@ class AgentApplication {
|
|
|
366
388
|
* Adds a handler for message reaction added events.
|
|
367
389
|
*
|
|
368
390
|
* @param handler - The handler function that will be called when a message reaction is added.
|
|
391
|
+
* @param rank - The rank of the route, used to determine the order of evaluation. Defaults to RouteRank.Unspecified.
|
|
369
392
|
* @returns The current instance of the application.
|
|
370
393
|
*
|
|
371
394
|
* @remarks
|
|
372
395
|
* This method registers a handler that will be invoked when a user adds a reaction to a message,
|
|
373
396
|
* such as a like, heart, or other emoji reaction.
|
|
374
397
|
*
|
|
375
|
-
*
|
|
398
|
+
* @example
|
|
376
399
|
* ```typescript
|
|
377
400
|
* app.onMessageReactionAdded(async (context, state) => {
|
|
378
401
|
* const reactionsAdded = context.activity.reactionsAdded;
|
|
@@ -382,26 +405,27 @@ class AgentApplication {
|
|
|
382
405
|
* });
|
|
383
406
|
* ```
|
|
384
407
|
*/
|
|
385
|
-
onMessageReactionAdded(handler) {
|
|
408
|
+
onMessageReactionAdded(handler, rank = routeRank_1.RouteRank.Unspecified) {
|
|
386
409
|
const selector = async (context) => {
|
|
387
410
|
return context.activity.type === agents_activity_1.ActivityTypes.MessageReaction &&
|
|
388
411
|
Array.isArray(context.activity.reactionsAdded) &&
|
|
389
412
|
context.activity.reactionsAdded.length > 0;
|
|
390
413
|
};
|
|
391
|
-
this.addRoute(selector, handler);
|
|
414
|
+
this.addRoute(selector, handler, false, rank);
|
|
392
415
|
return this;
|
|
393
416
|
}
|
|
394
417
|
/**
|
|
395
418
|
* Adds a handler for message reaction removed events.
|
|
396
419
|
*
|
|
397
420
|
* @param handler - The handler function that will be called when a message reaction is removed.
|
|
421
|
+
* @param rank - The rank of the route, used to determine the order of evaluation. Defaults to RouteRank.Unspecified.
|
|
398
422
|
* @returns The current instance of the application.
|
|
399
423
|
*
|
|
400
424
|
* @remarks
|
|
401
425
|
* This method registers a handler that will be invoked when a user removes a reaction from a message,
|
|
402
426
|
* such as unliking or removing an emoji reaction.
|
|
403
427
|
*
|
|
404
|
-
*
|
|
428
|
+
* @example
|
|
405
429
|
* ```typescript
|
|
406
430
|
* app.onMessageReactionRemoved(async (context, state) => {
|
|
407
431
|
* const reactionsRemoved = context.activity.reactionsRemoved;
|
|
@@ -411,13 +435,13 @@ class AgentApplication {
|
|
|
411
435
|
* });
|
|
412
436
|
* ```
|
|
413
437
|
*/
|
|
414
|
-
onMessageReactionRemoved(handler) {
|
|
438
|
+
onMessageReactionRemoved(handler, rank = routeRank_1.RouteRank.Unspecified) {
|
|
415
439
|
const selector = async (context) => {
|
|
416
440
|
return context.activity.type === agents_activity_1.ActivityTypes.MessageReaction &&
|
|
417
441
|
Array.isArray(context.activity.reactionsRemoved) &&
|
|
418
442
|
context.activity.reactionsRemoved.length > 0;
|
|
419
443
|
};
|
|
420
|
-
this.addRoute(selector, handler);
|
|
444
|
+
this.addRoute(selector, handler, false, rank);
|
|
421
445
|
return this;
|
|
422
446
|
}
|
|
423
447
|
/**
|
|
@@ -431,7 +455,7 @@ class AgentApplication {
|
|
|
431
455
|
* It delegates the actual processing to the `runInternal` method, which handles
|
|
432
456
|
* the core logic for routing and executing handlers.
|
|
433
457
|
*
|
|
434
|
-
*
|
|
458
|
+
* @example
|
|
435
459
|
* ```typescript
|
|
436
460
|
* const app = new AgentApplication();
|
|
437
461
|
* await app.run(turnContext);
|
|
@@ -462,7 +486,7 @@ class AgentApplication {
|
|
|
462
486
|
* 8. Executes after-turn event handlers
|
|
463
487
|
* 9. Saves turn state
|
|
464
488
|
*
|
|
465
|
-
*
|
|
489
|
+
* @example
|
|
466
490
|
* ```typescript
|
|
467
491
|
* const handled = await app.runInternal(turnContext);
|
|
468
492
|
* if (!handled) {
|
|
@@ -567,7 +591,7 @@ class AgentApplication {
|
|
|
567
591
|
* @remarks
|
|
568
592
|
* This method allows you to send messages proactively to a conversation, outside the normal turn flow.
|
|
569
593
|
*
|
|
570
|
-
*
|
|
594
|
+
* @example
|
|
571
595
|
* ```typescript
|
|
572
596
|
* // With conversation reference
|
|
573
597
|
* await app.sendProactiveActivity(conversationReference, 'Important notification!');
|
|
@@ -597,7 +621,7 @@ class AgentApplication {
|
|
|
597
621
|
* The typing indicator helps provide feedback to users that the agent is processing
|
|
598
622
|
* their message, especially when responses might take time to generate.
|
|
599
623
|
*
|
|
600
|
-
*
|
|
624
|
+
* @example
|
|
601
625
|
* ```typescript
|
|
602
626
|
* app.startTypingTimer(turnContext);
|
|
603
627
|
* // Do some processing...
|
|
@@ -653,7 +677,7 @@ class AgentApplication {
|
|
|
653
677
|
* Extensions provide a way to add custom functionality to the application.
|
|
654
678
|
* Each extension can only be registered once to prevent conflicts.
|
|
655
679
|
*
|
|
656
|
-
*
|
|
680
|
+
* @example
|
|
657
681
|
* ```typescript
|
|
658
682
|
* const myExtension = new MyCustomExtension();
|
|
659
683
|
* app.registerExtension(myExtension, (ext) => {
|
|
@@ -678,7 +702,7 @@ class AgentApplication {
|
|
|
678
702
|
* from being sent. It's typically called automatically when a message is sent, but
|
|
679
703
|
* can also be called manually to stop the typing indicator.
|
|
680
704
|
*
|
|
681
|
-
*
|
|
705
|
+
* @example
|
|
682
706
|
* ```typescript
|
|
683
707
|
* app.startTypingTimer(turnContext);
|
|
684
708
|
* // Do some processing...
|
|
@@ -703,7 +727,7 @@ class AgentApplication {
|
|
|
703
727
|
* Handlers added for 'beforeTurn' are executed before routing logic.
|
|
704
728
|
* Handlers added for 'afterTurn' are executed after routing logic.
|
|
705
729
|
*
|
|
706
|
-
*
|
|
730
|
+
* @example
|
|
707
731
|
* ```typescript
|
|
708
732
|
* app.onTurn('beforeTurn', async (context, state) => {
|
|
709
733
|
* console.log('Processing before turn');
|