@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.
- package/dist/package.json +2 -2
- package/dist/src/activityHandler.d.ts +0 -1
- package/dist/src/activityHandler.js +0 -1
- package/dist/src/activityHandler.js.map +1 -1
- package/dist/src/agent-client/agentResponseHandler.d.ts +6 -6
- package/dist/src/agent-client/agentResponseHandler.js +6 -6
- package/dist/src/app/adaptiveCards/adaptiveCardsActions.d.ts +12 -4
- package/dist/src/app/adaptiveCards/adaptiveCardsActions.js +5 -1
- package/dist/src/app/adaptiveCards/adaptiveCardsActions.js.map +1 -1
- package/dist/src/app/agentApplication.d.ts +24 -7
- package/dist/src/app/agentApplication.js +24 -7
- package/dist/src/app/agentApplication.js.map +1 -1
- package/dist/src/app/appRoute.d.ts +8 -4
- package/dist/src/app/attachmentDownloader.d.ts +3 -1
- package/dist/src/app/attachmentDownloader.js +3 -1
- package/dist/src/app/attachmentDownloader.js.map +1 -1
- package/dist/src/app/authorization.d.ts +26 -18
- package/dist/src/app/authorization.js +26 -18
- package/dist/src/app/authorization.js.map +1 -1
- package/dist/src/app/routeRank.d.ts +10 -3
- package/dist/src/app/routeRank.js +10 -3
- package/dist/src/app/routeRank.js.map +1 -1
- package/dist/src/app/streaming/streamingResponse.d.ts +23 -2
- package/dist/src/app/streaming/streamingResponse.js +23 -2
- package/dist/src/app/streaming/streamingResponse.js.map +1 -1
- package/dist/src/app/turnState.d.ts +69 -19
- package/dist/src/app/turnState.js +69 -19
- package/dist/src/app/turnState.js.map +1 -1
- package/dist/src/auth/authConfiguration.d.ts +16 -9
- package/dist/src/auth/authConfiguration.js +11 -6
- package/dist/src/auth/authConfiguration.js.map +1 -1
- package/dist/src/auth/jwt-middleware.js +26 -18
- package/dist/src/auth/jwt-middleware.js.map +1 -1
- package/dist/src/cards/adaptiveCard.d.ts +1 -1
- package/dist/src/headerPropagation.d.ts +18 -6
- package/dist/src/state/agentState.d.ts +23 -7
- package/dist/src/state/agentState.js +19 -7
- package/dist/src/state/agentState.js.map +1 -1
- package/dist/src/state/agentStatePropertyAccesor.d.ts +63 -41
- package/dist/src/state/agentStatePropertyAccesor.js +43 -32
- package/dist/src/state/agentStatePropertyAccesor.js.map +1 -1
- package/dist/src/storage/fileStorage.d.ts +8 -6
- package/dist/src/storage/fileStorage.js +8 -6
- package/dist/src/storage/fileStorage.js.map +1 -1
- package/dist/src/storage/memoryStorage.d.ts +12 -7
- package/dist/src/storage/memoryStorage.js +12 -7
- package/dist/src/storage/memoryStorage.js.map +1 -1
- package/dist/src/storage/storage.d.ts +18 -1
- package/dist/src/turnContext.d.ts +31 -20
- package/dist/src/turnContext.js +31 -20
- package/dist/src/turnContext.js.map +1 -1
- package/package.json +2 -2
- package/src/activityHandler.ts +0 -1
- package/src/agent-client/agentResponseHandler.ts +6 -6
- package/src/app/adaptiveCards/adaptiveCardsActions.ts +12 -4
- package/src/app/agentApplication.ts +24 -7
- package/src/app/appRoute.ts +8 -4
- package/src/app/attachmentDownloader.ts +3 -1
- package/src/app/authorization.ts +26 -18
- package/src/app/routeRank.ts +10 -3
- package/src/app/streaming/streamingResponse.ts +23 -2
- package/src/app/turnState.ts +69 -19
- package/src/auth/authConfiguration.ts +16 -9
- package/src/auth/jwt-middleware.ts +24 -17
- package/src/cards/adaptiveCard.ts +1 -1
- package/src/headerPropagation.ts +18 -6
- package/src/state/agentState.ts +23 -7
- package/src/state/agentStatePropertyAccesor.ts +63 -41
- package/src/storage/fileStorage.ts +8 -6
- package/src/storage/memoryStorage.ts +12 -7
- package/src/storage/storage.ts +18 -1
- package/src/turnContext.ts +31 -20
package/dist/src/turnContext.js
CHANGED
|
@@ -55,14 +55,15 @@ class TurnContext {
|
|
|
55
55
|
/**
|
|
56
56
|
* Sends a trace activity for debugging purposes.
|
|
57
57
|
*
|
|
58
|
-
* Trace activities are typically used for debugging and are only visible in
|
|
59
|
-
* channels that support them, like the Bot Framework Emulator.
|
|
60
|
-
*
|
|
61
58
|
* @param name The name/category of the trace
|
|
62
59
|
* @param value The value/data to include in the trace
|
|
63
60
|
* @param valueType Optional type name for the value
|
|
64
61
|
* @param label Optional descriptive label for the trace
|
|
65
62
|
* @returns A promise that resolves to the resource response or undefined
|
|
63
|
+
*
|
|
64
|
+
* @remarks
|
|
65
|
+
* Trace activities are typically used for debugging and are only visible in
|
|
66
|
+
* channels that support them, like the Bot Framework Emulator.
|
|
66
67
|
*/
|
|
67
68
|
async sendTraceActivity(name, value, valueType, label) {
|
|
68
69
|
const traceActivityObj = {
|
|
@@ -79,14 +80,15 @@ class TurnContext {
|
|
|
79
80
|
/**
|
|
80
81
|
* Sends an activity to the sender of the incoming activity.
|
|
81
82
|
*
|
|
82
|
-
* This is the primary method used to respond to the user. It automatically
|
|
83
|
-
* addresses the response to the correct conversation and recipient using
|
|
84
|
-
* information from the incoming activity.
|
|
85
|
-
*
|
|
86
83
|
* @param activityOrText The activity to send or a string for a simple message
|
|
87
84
|
* @param speak Optional text to be spoken by the agent
|
|
88
85
|
* @param inputHint Optional input hint to indicate if the agent is expecting input
|
|
89
86
|
* @returns A promise that resolves to the resource response or undefined
|
|
87
|
+
*
|
|
88
|
+
* @remarks
|
|
89
|
+
* This is the primary method used to respond to the user. It automatically
|
|
90
|
+
* addresses the response to the correct conversation and recipient using
|
|
91
|
+
* information from the incoming activity.
|
|
90
92
|
*/
|
|
91
93
|
async sendActivity(activityOrText, speak, inputHint) {
|
|
92
94
|
let activityObject;
|
|
@@ -106,12 +108,13 @@ class TurnContext {
|
|
|
106
108
|
/**
|
|
107
109
|
* Sends multiple activities to the sender of the incoming activity.
|
|
108
110
|
*
|
|
111
|
+
* @param activities The array of activities to send
|
|
112
|
+
* @returns A promise that resolves to an array of resource responses
|
|
113
|
+
*
|
|
114
|
+
* @remarks
|
|
109
115
|
* This method applies conversation references to each activity and
|
|
110
116
|
* emits them through the middleware chain before sending them to
|
|
111
117
|
* the adapter.
|
|
112
|
-
*
|
|
113
|
-
* @param activities The array of activities to send
|
|
114
|
-
* @returns A promise that resolves to an array of resource responses
|
|
115
118
|
*/
|
|
116
119
|
async sendActivities(activities) {
|
|
117
120
|
let sentNonTraceActivity = false;
|
|
@@ -163,11 +166,12 @@ class TurnContext {
|
|
|
163
166
|
/**
|
|
164
167
|
* Updates an existing activity in the conversation.
|
|
165
168
|
*
|
|
166
|
-
* This can be used to edit previously sent activities, for example to
|
|
167
|
-
* update the content of an adaptive card or change a message.
|
|
168
|
-
*
|
|
169
169
|
* @param activity The activity to update with its ID specified
|
|
170
170
|
* @returns A promise that resolves when the activity has been updated
|
|
171
|
+
*
|
|
172
|
+
* @remarks
|
|
173
|
+
* This can be used to edit previously sent activities, for example to
|
|
174
|
+
* update the content of an adaptive card or change a message.
|
|
171
175
|
*/
|
|
172
176
|
async updateActivity(activity) {
|
|
173
177
|
const ref = this.activity.getConversationReference();
|
|
@@ -223,11 +227,12 @@ class TurnContext {
|
|
|
223
227
|
/**
|
|
224
228
|
* Registers a handler for intercepting and processing activities being sent.
|
|
225
229
|
*
|
|
226
|
-
* This method follows a middleware pattern, allowing multiple handlers to
|
|
227
|
-
* be chained together. Handlers can modify activities or inject new ones.
|
|
228
|
-
*
|
|
229
230
|
* @param handler The handler to register
|
|
230
231
|
* @returns The current TurnContext instance for chaining
|
|
232
|
+
*
|
|
233
|
+
* @remarks
|
|
234
|
+
* This method follows a middleware pattern, allowing multiple handlers to
|
|
235
|
+
* be chained together. Handlers can modify activities or inject new ones.
|
|
231
236
|
*/
|
|
232
237
|
onSendActivities(handler) {
|
|
233
238
|
this._onSendActivities.push(handler);
|
|
@@ -267,6 +272,7 @@ class TurnContext {
|
|
|
267
272
|
/**
|
|
268
273
|
* Gets the adapter that created this context.
|
|
269
274
|
*
|
|
275
|
+
* @remarks
|
|
270
276
|
* The adapter is responsible for sending and receiving activities
|
|
271
277
|
* to and from the user's channel.
|
|
272
278
|
*/
|
|
@@ -276,6 +282,7 @@ class TurnContext {
|
|
|
276
282
|
/**
|
|
277
283
|
* Gets the incoming activity that started this turn.
|
|
278
284
|
*
|
|
285
|
+
* @remarks
|
|
279
286
|
* This is the activity that was received from the user or channel
|
|
280
287
|
* and triggered the creation of this context.
|
|
281
288
|
*/
|
|
@@ -285,6 +292,7 @@ class TurnContext {
|
|
|
285
292
|
/**
|
|
286
293
|
* Gets or sets whether the turn has sent a response to the user.
|
|
287
294
|
*
|
|
295
|
+
* @remarks
|
|
288
296
|
* This is used to track whether the agent has responded to the user's
|
|
289
297
|
* activity. Once set to true, it cannot be set back to false.
|
|
290
298
|
*/
|
|
@@ -300,6 +308,7 @@ class TurnContext {
|
|
|
300
308
|
/**
|
|
301
309
|
* Gets or sets the locale for the turn.
|
|
302
310
|
*
|
|
311
|
+
* @remarks
|
|
303
312
|
* The locale affects language-dependent operations like
|
|
304
313
|
* formatting dates or numbers.
|
|
305
314
|
*/
|
|
@@ -323,6 +332,7 @@ class TurnContext {
|
|
|
323
332
|
/**
|
|
324
333
|
* Gets the turn state collection for storing data during the turn.
|
|
325
334
|
*
|
|
335
|
+
* @remarks
|
|
326
336
|
* The turn state collection provides a dictionary-like interface
|
|
327
337
|
* for storing arbitrary data that needs to be accessible during
|
|
328
338
|
* the processing of the current turn.
|
|
@@ -336,15 +346,16 @@ class TurnContext {
|
|
|
336
346
|
/**
|
|
337
347
|
* Emits events to registered middleware handlers.
|
|
338
348
|
*
|
|
339
|
-
* This internal method implements the middleware pattern, allowing
|
|
340
|
-
* handlers to be chained together with each having the option to
|
|
341
|
-
* short-circuit the chain.
|
|
342
|
-
*
|
|
343
349
|
* @param handlers Array of handlers to execute
|
|
344
350
|
* @param arg The argument to pass to each handler
|
|
345
351
|
* @param next The function to execute at the end of the middleware chain
|
|
346
352
|
* @returns A promise that resolves to the result from the handlers or next function
|
|
347
353
|
* @private
|
|
354
|
+
*
|
|
355
|
+
* @remarks
|
|
356
|
+
* This internal method implements the middleware pattern, allowing
|
|
357
|
+
* handlers to be chained together with each having the option to
|
|
358
|
+
* short-circuit the chain.
|
|
348
359
|
*/
|
|
349
360
|
async emit(handlers, arg, next) {
|
|
350
361
|
const runHandlers = async ([handler, ...remaining]) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"turnContext.js","sourceRoot":"","sources":["../../src/turnContext.ts"],"names":[],"mappings":";;;AAAA,oGAAoG;AACpG,uDAAuD;AAEvD,gEAAsH;AAEtH,6EAAyE;AAGzE,yEAAqE;AAgCrE;;GAEG;AACU,QAAA,uBAAuB,GAAG,sBAAsB,CAAA;AAO7D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,WAAW;IAmBtB,YAAa,gBAA2C,EAAE,OAAkB;QAhB3D,kBAAa,GAA2B,EAAE,SAAS,EAAE,KAAK,EAAE,CAAA;QAC5D,eAAU,GAAG,IAAI,uDAA0B,EAAE,CAAA;QAC7C,sBAAiB,GAA4B,EAAE,CAAA;QAC/C,sBAAiB,GAA4B,EAAE,CAAA;QAC/C,sBAAiB,GAA4B,EAAE,CAAA;QAC/C,UAAK,GAAG,MAAM,CAAA;QACd,YAAO,GAAG,QAAQ,CAAA;QAoBnC;;;;;WAKG;QACM,4BAAuB,GAAe,EAAE,CAAA;QAf/C,IAAI,gBAAgB,YAAY,WAAW,EAAE,CAAC;YAC5C,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAC/B,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAA;YAChC,IAAI,CAAC,SAAS,GAAG,OAAmB,CAAA;QACtC,CAAC;QACD,IAAI,CAAC,kBAAkB,GAAG,IAAI,qCAAiB,CAAC,IAAI,CAAC,CAAA;IACvD,CAAC;IAUD
|
|
1
|
+
{"version":3,"file":"turnContext.js","sourceRoot":"","sources":["../../src/turnContext.ts"],"names":[],"mappings":";;;AAAA,oGAAoG;AACpG,uDAAuD;AAEvD,gEAAsH;AAEtH,6EAAyE;AAGzE,yEAAqE;AA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BAAiB;QACnB,OAAO,IAAI,CAAC,kBAAkB,CAAA;IAChC,CAAC;IAED;;;;;;;;;;;;;OAaG;IACK,KAAK,CAAC,IAAI,CAAO,QAAqF,EAAE,GAAM,EAAE,IAAsB;QAC5I,MAAM,WAAW,GAAG,KAAK,EAAE,CAAC,OAAO,EAAE,GAAG,SAAS,CAAkB,EAAc,EAAE;YACjF,IAAI,CAAC;gBACH,OAAO,OAAO,CAAC,CAAC,CAAC,MAAM,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,MAAM,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAA;YACrH,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;YAClC,CAAC;QACH,CAAC,CAAA;QACD,OAAO,MAAM,WAAW,CAAC,QAAQ,CAAC,CAAA;IACpC,CAAC;CACF;AAnXD,kCAmXC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@microsoft/agents-hosting",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.3-g444d99f704",
|
|
5
5
|
"homepage": "https://github.com/microsoft/Agents-for-js",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@azure/core-auth": "^1.10.0",
|
|
23
23
|
"@azure/msal-node": "^3.6.0",
|
|
24
|
-
"@microsoft/agents-activity": "1.0.
|
|
24
|
+
"@microsoft/agents-activity": "1.0.3-g444d99f704",
|
|
25
25
|
"axios": "^1.10.0",
|
|
26
26
|
"jsonwebtoken": "^9.0.2",
|
|
27
27
|
"jwks-rsa": "^3.2.0"
|
package/src/activityHandler.ts
CHANGED
|
@@ -31,7 +31,6 @@ const logger = debug('agents:activity-handler')
|
|
|
31
31
|
* Handles incoming activities from channels and dispatches them to the appropriate handlers.
|
|
32
32
|
*
|
|
33
33
|
* @remarks
|
|
34
|
-
*
|
|
35
34
|
* This class is provided to simplify the migration from Bot Framework SDK v4 to the Agents Hosting framework.
|
|
36
35
|
*
|
|
37
36
|
* The ActivityHandler serves as the central hub for processing incoming activities in conversational AI applications.
|
|
@@ -17,17 +17,12 @@ interface ConversationReferenceState {
|
|
|
17
17
|
/**
|
|
18
18
|
* To enable Agent to Agent communication, configures the agent response controller endpoint for handling incoming activities from external services.
|
|
19
19
|
*
|
|
20
|
+
* @remarks
|
|
20
21
|
* This function sets up a POST endpoint that receives activities (messages, events, etc.) from external
|
|
21
22
|
* services and processes them through the bot framework's activity handling pipeline. It's typically used
|
|
22
23
|
* when the agent needs to receive and respond to activities from channels or services that send activities
|
|
23
24
|
* to a specific webhook endpoint.
|
|
24
25
|
*
|
|
25
|
-
* @param app - The Express application instance to configure the route on
|
|
26
|
-
* @param adapter - The CloudAdapter instance used for processing bot framework activities and managing conversations
|
|
27
|
-
* @param agent - The ActivityHandler instance that contains the bot's logic for processing different types of activities
|
|
28
|
-
* @param conversationState - The ConversationState instance used for managing conversation-specific state and conversation references
|
|
29
|
-
*
|
|
30
|
-
* @remarks
|
|
31
26
|
* The endpoint expects activities to be sent to:
|
|
32
27
|
* `POST /api/agentresponse/v3/conversations/{conversationId}/activities/{activityId}`
|
|
33
28
|
*
|
|
@@ -38,6 +33,11 @@ interface ConversationReferenceState {
|
|
|
38
33
|
* - Processing EndOfConversation activities by cleaning up conversation state
|
|
39
34
|
* - Sending activities through the turn context and returning responses
|
|
40
35
|
*
|
|
36
|
+
* @param app - The Express application instance to configure the route on
|
|
37
|
+
* @param adapter - The CloudAdapter instance used for processing bot framework activities and managing conversations
|
|
38
|
+
* @param agent - The ActivityHandler instance that contains the bot's logic for processing different types of activities
|
|
39
|
+
* @param conversationState - The ConversationState instance used for managing conversation-specific state and conversation references
|
|
40
|
+
*
|
|
41
41
|
* @example
|
|
42
42
|
* ```typescript
|
|
43
43
|
* const app = express();
|
|
@@ -34,7 +34,8 @@ enum AdaptiveCardInvokeResponseType {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* Represents a single search result item returned from an Adaptive Card search operation.
|
|
38
|
+
*
|
|
38
39
|
* @remarks
|
|
39
40
|
* This interface defines the structure for search results that are displayed to users
|
|
40
41
|
* when they perform searches within Adaptive Cards, such as typeahead or dropdown searches.
|
|
@@ -46,10 +47,12 @@ enum AdaptiveCardInvokeResponseType {
|
|
|
46
47
|
* value: "john.doe@company.com"
|
|
47
48
|
* };
|
|
48
49
|
* ```
|
|
50
|
+
*
|
|
49
51
|
*/
|
|
50
52
|
export interface AdaptiveCardSearchResult {
|
|
51
53
|
/**
|
|
52
|
-
*
|
|
54
|
+
* The display text shown to the user in the search results.
|
|
55
|
+
*
|
|
53
56
|
* @remarks
|
|
54
57
|
* This is typically the human-readable label that appears in dropdowns,
|
|
55
58
|
* typeahead suggestions, or search result lists.
|
|
@@ -59,7 +62,8 @@ export interface AdaptiveCardSearchResult {
|
|
|
59
62
|
title: string;
|
|
60
63
|
|
|
61
64
|
/**
|
|
62
|
-
*
|
|
65
|
+
* The underlying value associated with this search result.
|
|
66
|
+
*
|
|
63
67
|
* @remarks
|
|
64
68
|
* This is usually the actual data value that gets selected when the user
|
|
65
69
|
* chooses this result, such as an ID, email address, or other identifier.
|
|
@@ -71,6 +75,7 @@ export interface AdaptiveCardSearchResult {
|
|
|
71
75
|
|
|
72
76
|
/**
|
|
73
77
|
* A class to handle Adaptive Card actions such as executing actions, submitting actions, and performing searches.
|
|
78
|
+
*
|
|
74
79
|
* @typeParam TState - The type of the TurnState used in the application.
|
|
75
80
|
*/
|
|
76
81
|
export class AdaptiveCardsActions<TState extends TurnState> {
|
|
@@ -88,7 +93,8 @@ export class AdaptiveCardsActions<TState extends TurnState> {
|
|
|
88
93
|
}
|
|
89
94
|
|
|
90
95
|
/**
|
|
91
|
-
* Registers a handler for the Action.Execute event.
|
|
96
|
+
* Registers a handler for the `Action.Execute` event.
|
|
97
|
+
*
|
|
92
98
|
* @typeParam TData - The type of the data passed to the handler.
|
|
93
99
|
* @param verb - A string, RegExp, RouteSelector, or an array of these to match the action verb.
|
|
94
100
|
* @param handler - A function to handle the action execution.
|
|
@@ -174,6 +180,7 @@ export class AdaptiveCardsActions<TState extends TurnState> {
|
|
|
174
180
|
|
|
175
181
|
/**
|
|
176
182
|
* Registers a handler for the Action.Submit event.
|
|
183
|
+
*
|
|
177
184
|
* @typeParam TData - The type of the data passed to the handler.
|
|
178
185
|
* @param verb - A string, RegExp, RouteSelector, or an array of these to match the action verb.
|
|
179
186
|
* @param handler - A function to handle the action submission.
|
|
@@ -200,6 +207,7 @@ export class AdaptiveCardsActions<TState extends TurnState> {
|
|
|
200
207
|
|
|
201
208
|
/**
|
|
202
209
|
* Registers a handler for the search event.
|
|
210
|
+
*
|
|
203
211
|
* @param dataset - A string, RegExp, RouteSelector, or an array of these to match the dataset.
|
|
204
212
|
* @param handler - A function to handle the search query.
|
|
205
213
|
* @returns The Teams application instance.
|
|
@@ -36,7 +36,9 @@ const TYPING_TIMER_DELAY = 1000
|
|
|
36
36
|
export type ApplicationEventHandler<TState extends TurnState> = (context: TurnContext, state: TState) => Promise<boolean>
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
39
|
+
* Main application class for handling agent conversations and routing.
|
|
40
|
+
*
|
|
41
|
+
* @typeParam TState - The state type extending TurnState.
|
|
40
42
|
*
|
|
41
43
|
* @remarks
|
|
42
44
|
* The AgentApplication class provides a framework for building conversational agents.
|
|
@@ -65,7 +67,6 @@ export type ApplicationEventHandler<TState extends TurnState> = (context: TurnCo
|
|
|
65
67
|
* await app.run(turnContext);
|
|
66
68
|
* ```
|
|
67
69
|
*
|
|
68
|
-
* @typeParam TState - The state type extending TurnState.
|
|
69
70
|
*/
|
|
70
71
|
export class AgentApplication<TState extends TurnState> {
|
|
71
72
|
protected readonly _options: AgentApplicationOptions<TState>
|
|
@@ -79,7 +80,7 @@ export class AgentApplication<TState extends TurnState> {
|
|
|
79
80
|
private readonly _adaptiveCards: AdaptiveCardsActions<TState>
|
|
80
81
|
|
|
81
82
|
/**
|
|
82
|
-
*
|
|
83
|
+
* Creates a new instance of AgentApplication.
|
|
83
84
|
*
|
|
84
85
|
* @param options - Optional configuration options for the application.
|
|
85
86
|
*
|
|
@@ -142,7 +143,7 @@ export class AgentApplication<TState extends TurnState> {
|
|
|
142
143
|
}
|
|
143
144
|
|
|
144
145
|
/**
|
|
145
|
-
*
|
|
146
|
+
* Gets the authorization instance for the application.
|
|
146
147
|
*
|
|
147
148
|
* @returns The authorization instance.
|
|
148
149
|
* @throws Error if no authentication options were configured.
|
|
@@ -155,7 +156,7 @@ export class AgentApplication<TState extends TurnState> {
|
|
|
155
156
|
}
|
|
156
157
|
|
|
157
158
|
/**
|
|
158
|
-
*
|
|
159
|
+
* Gets the options used to configure the application.
|
|
159
160
|
*
|
|
160
161
|
* @returns The application options.
|
|
161
162
|
*/
|
|
@@ -164,7 +165,7 @@ export class AgentApplication<TState extends TurnState> {
|
|
|
164
165
|
}
|
|
165
166
|
|
|
166
167
|
/**
|
|
167
|
-
*
|
|
168
|
+
* Gets the adapter used by the application.
|
|
168
169
|
*
|
|
169
170
|
* @returns The adapter instance.
|
|
170
171
|
*/
|
|
@@ -173,7 +174,7 @@ export class AgentApplication<TState extends TurnState> {
|
|
|
173
174
|
}
|
|
174
175
|
|
|
175
176
|
/**
|
|
176
|
-
*
|
|
177
|
+
* Gets the adaptive cards actions handler for the application.
|
|
177
178
|
*
|
|
178
179
|
* @returns The adaptive cards actions instance.
|
|
179
180
|
*
|
|
@@ -209,6 +210,7 @@ export class AgentApplication<TState extends TurnState> {
|
|
|
209
210
|
* await context.sendActivity('Sorry, something went wrong!');
|
|
210
211
|
* });
|
|
211
212
|
* ```
|
|
213
|
+
*
|
|
212
214
|
*/
|
|
213
215
|
public onError (handler: (context: TurnContext, error: Error) => Promise<void>): this {
|
|
214
216
|
if (this._adapter) {
|
|
@@ -243,6 +245,7 @@ export class AgentApplication<TState extends TurnState> {
|
|
|
243
245
|
* RouteRank.First // rank
|
|
244
246
|
* );
|
|
245
247
|
* ```
|
|
248
|
+
*
|
|
246
249
|
*/
|
|
247
250
|
public addRoute (selector: RouteSelector, handler: RouteHandler<TState>, isInvokeRoute: boolean = false, rank: number = RouteRank.Unspecified, authHandlers: string[] = []): this {
|
|
248
251
|
this._routes.addRoute(selector, handler, isInvokeRoute, rank, authHandlers)
|
|
@@ -268,6 +271,7 @@ export class AgentApplication<TState extends TurnState> {
|
|
|
268
271
|
* await context.sendActivity('I received your message');
|
|
269
272
|
* });
|
|
270
273
|
* ```
|
|
274
|
+
*
|
|
271
275
|
*/
|
|
272
276
|
public onActivity (
|
|
273
277
|
type: string | RegExp | RouteSelector | (string | RegExp | RouteSelector)[],
|
|
@@ -306,6 +310,7 @@ export class AgentApplication<TState extends TurnState> {
|
|
|
306
310
|
* }
|
|
307
311
|
* });
|
|
308
312
|
* ```
|
|
313
|
+
*
|
|
309
314
|
*/
|
|
310
315
|
public onConversationUpdate (
|
|
311
316
|
event: ConversationUpdateEvents,
|
|
@@ -383,6 +388,7 @@ export class AgentApplication<TState extends TurnState> {
|
|
|
383
388
|
* await context.sendActivity('How can I help you?');
|
|
384
389
|
* });
|
|
385
390
|
* ```
|
|
391
|
+
*
|
|
386
392
|
*/
|
|
387
393
|
public onMessage (
|
|
388
394
|
keyword: string | RegExp | RouteSelector | (string | RegExp | RouteSelector)[],
|
|
@@ -414,6 +420,7 @@ export class AgentApplication<TState extends TurnState> {
|
|
|
414
420
|
* await context.sendActivity('You have successfully signed in!');
|
|
415
421
|
* });
|
|
416
422
|
* ```
|
|
423
|
+
*
|
|
417
424
|
*/
|
|
418
425
|
public onSignInSuccess (handler: (context: TurnContext, state: TurnState, id?: string) => Promise<void>): this {
|
|
419
426
|
if (this.options.authorization) {
|
|
@@ -443,6 +450,7 @@ export class AgentApplication<TState extends TurnState> {
|
|
|
443
450
|
* await context.sendActivity('Sign-in failed. Please try again.');
|
|
444
451
|
* });
|
|
445
452
|
* ```
|
|
453
|
+
*
|
|
446
454
|
*/
|
|
447
455
|
public onSignInFailure (handler: (context: TurnContext, state: TurnState, id?: string) => Promise<void>): this {
|
|
448
456
|
if (this.options.authorization) {
|
|
@@ -475,6 +483,7 @@ export class AgentApplication<TState extends TurnState> {
|
|
|
475
483
|
* }
|
|
476
484
|
* });
|
|
477
485
|
* ```
|
|
486
|
+
*
|
|
478
487
|
*/
|
|
479
488
|
public onMessageReactionAdded (
|
|
480
489
|
handler: (context: TurnContext, state: TState) => Promise<void>,
|
|
@@ -509,6 +518,7 @@ export class AgentApplication<TState extends TurnState> {
|
|
|
509
518
|
* }
|
|
510
519
|
* });
|
|
511
520
|
* ```
|
|
521
|
+
*
|
|
512
522
|
*/
|
|
513
523
|
public onMessageReactionRemoved (
|
|
514
524
|
handler: (context: TurnContext, state: TState) => Promise<void>,
|
|
@@ -539,6 +549,7 @@ export class AgentApplication<TState extends TurnState> {
|
|
|
539
549
|
* const app = new AgentApplication();
|
|
540
550
|
* await app.run(turnContext);
|
|
541
551
|
* ```
|
|
552
|
+
*
|
|
542
553
|
*/
|
|
543
554
|
public async run (turnContext:TurnContext): Promise<void> {
|
|
544
555
|
await this.runInternal(turnContext)
|
|
@@ -573,6 +584,7 @@ export class AgentApplication<TState extends TurnState> {
|
|
|
573
584
|
* console.log('No handler matched the activity');
|
|
574
585
|
* }
|
|
575
586
|
* ```
|
|
587
|
+
*
|
|
576
588
|
*/
|
|
577
589
|
public async runInternal (turnContext: TurnContext): Promise<boolean> {
|
|
578
590
|
logger.info('Running application with activity:', turnContext.activity.id!)
|
|
@@ -688,6 +700,7 @@ export class AgentApplication<TState extends TurnState> {
|
|
|
688
700
|
* // From an existing context
|
|
689
701
|
* await app.sendProactiveActivity(turnContext, 'Important notification!');
|
|
690
702
|
* ```
|
|
703
|
+
*
|
|
691
704
|
*/
|
|
692
705
|
public async sendProactiveActivity (
|
|
693
706
|
context: TurnContext | ConversationReference,
|
|
@@ -724,6 +737,7 @@ export class AgentApplication<TState extends TurnState> {
|
|
|
724
737
|
* await turnContext.sendActivity('Response after processing');
|
|
725
738
|
* // Typing timer automatically stops when sending a message
|
|
726
739
|
* ```
|
|
740
|
+
*
|
|
727
741
|
*/
|
|
728
742
|
public startTypingTimer (context: TurnContext): void {
|
|
729
743
|
if (context.activity.type === ActivityTypes.Message && !this._typingTimer) {
|
|
@@ -782,6 +796,7 @@ export class AgentApplication<TState extends TurnState> {
|
|
|
782
796
|
* console.log('Extension registered:', ext.name);
|
|
783
797
|
* });
|
|
784
798
|
* ```
|
|
799
|
+
*
|
|
785
800
|
*/
|
|
786
801
|
public registerExtension<T extends AgentExtension<TState>> (extension: T, regcb : (ext:T) => void): void {
|
|
787
802
|
if (this._extensions.includes(extension)) {
|
|
@@ -807,6 +822,7 @@ export class AgentApplication<TState extends TurnState> {
|
|
|
807
822
|
* // Do some processing...
|
|
808
823
|
* app.stopTypingTimer(); // Manually stop the typing indicator
|
|
809
824
|
* ```
|
|
825
|
+
*
|
|
810
826
|
*/
|
|
811
827
|
public stopTypingTimer (): void {
|
|
812
828
|
if (this._typingTimer) {
|
|
@@ -834,6 +850,7 @@ export class AgentApplication<TState extends TurnState> {
|
|
|
834
850
|
* return true; // Continue execution
|
|
835
851
|
* });
|
|
836
852
|
* ```
|
|
853
|
+
*
|
|
837
854
|
*/
|
|
838
855
|
public onTurn (
|
|
839
856
|
event: TurnEvents | TurnEvents[],
|
package/src/app/appRoute.ts
CHANGED
|
@@ -10,14 +10,14 @@ import { TurnState } from './turnState'
|
|
|
10
10
|
/**
|
|
11
11
|
* Represents a route configuration for handling bot activities within an application.
|
|
12
12
|
*
|
|
13
|
+
* @typeParam TState - The type of turn state that extends TurnState, allowing for
|
|
14
|
+
* type-safe access to custom state properties within route handlers
|
|
15
|
+
*
|
|
13
16
|
* @remarks
|
|
14
17
|
* An AppRoute defines how incoming activities are matched and processed by combining
|
|
15
18
|
* a selector function that determines when the route should be activated with a handler
|
|
16
19
|
* function that processes the matched activities.
|
|
17
20
|
*
|
|
18
|
-
* @typeParam TState - The type of turn state that extends TurnState, allowing for
|
|
19
|
-
* type-safe access to custom state properties within route handlers
|
|
20
|
-
*
|
|
21
21
|
* @example
|
|
22
22
|
* ```typescript
|
|
23
23
|
* const echoRoute: AppRoute<MyTurnState> = {
|
|
@@ -27,6 +27,7 @@ import { TurnState } from './turnState'
|
|
|
27
27
|
* }
|
|
28
28
|
* };
|
|
29
29
|
* ```
|
|
30
|
+
*
|
|
30
31
|
*/
|
|
31
32
|
export interface AppRoute<TState extends TurnState> {
|
|
32
33
|
/**
|
|
@@ -53,18 +54,20 @@ export interface AppRoute<TState extends TurnState> {
|
|
|
53
54
|
/**
|
|
54
55
|
* Indicates whether this route is an invoke route.
|
|
55
56
|
*
|
|
57
|
+
* @default false
|
|
58
|
+
*
|
|
56
59
|
* @remarks
|
|
57
60
|
* Invoke routes are used for specific types of activities, such as messaging extensions,
|
|
58
61
|
* adaptive card actions, or other invoke-based interactions. When set to true, this route
|
|
59
62
|
* will be processed differently than regular message routes, typically with special
|
|
60
63
|
* handling for invoke responses.
|
|
61
64
|
*
|
|
62
|
-
* @default false
|
|
63
65
|
*/
|
|
64
66
|
isInvokeRoute?: boolean;
|
|
65
67
|
|
|
66
68
|
/**
|
|
67
69
|
* Optional rank of the route, used to determine the order in which routes are evaluated.
|
|
70
|
+
*
|
|
68
71
|
* 0 - number.MAX_VALUE. Ranks of the same value are evaluated in order of addition.
|
|
69
72
|
*/
|
|
70
73
|
rank?: number;
|
|
@@ -82,6 +85,7 @@ export interface AppRoute<TState extends TurnState> {
|
|
|
82
85
|
* ```typescript
|
|
83
86
|
* authHandlers: ['oauth', 'admin-only']
|
|
84
87
|
* ```
|
|
88
|
+
*
|
|
85
89
|
*/
|
|
86
90
|
authHandlers?: string[]
|
|
87
91
|
}
|
|
@@ -17,11 +17,12 @@ const logger = debug('agents:attachmentDownloader')
|
|
|
17
17
|
/**
|
|
18
18
|
* A utility class for downloading input files from activity attachments.
|
|
19
19
|
*
|
|
20
|
+
* @typeParam TState - The type of the turn state used in the application.
|
|
21
|
+
*
|
|
20
22
|
* @remarks
|
|
21
23
|
* This class provides functionality to filter and download attachments from a turn context,
|
|
22
24
|
* supporting various content types and handling authentication for secure URLs.
|
|
23
25
|
*
|
|
24
|
-
* @typeParam TState - The type of the turn state used in the application.
|
|
25
26
|
*/
|
|
26
27
|
export class AttachmentDownloader<TState extends TurnState = TurnState> implements InputFileDownloader<TState> {
|
|
27
28
|
private _httpClient: AxiosInstance
|
|
@@ -36,6 +37,7 @@ export class AttachmentDownloader<TState extends TurnState = TurnState> implemen
|
|
|
36
37
|
|
|
37
38
|
/**
|
|
38
39
|
* Downloads files from the attachments in the current turn context.
|
|
40
|
+
*
|
|
39
41
|
* @param context The turn context containing the activity with attachments.
|
|
40
42
|
* @param state The turn state for the current conversation.
|
|
41
43
|
* @returns A promise that resolves to an array of downloaded input files.
|