@microsoft/agents-hosting 1.0.0 → 1.0.7-g73d3d58001
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 +3 -3
- 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/adaptiveCards/index.d.ts +2 -0
- package/dist/src/app/adaptiveCards/index.js +2 -0
- package/dist/src/app/adaptiveCards/index.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/agentApplicationOptions.d.ts +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/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/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/cloudAdapter.js +1 -0
- package/dist/src/cloudAdapter.js.map +1 -1
- package/dist/src/headerPropagation.d.ts +18 -6
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/oauth/userTokenClient.d.ts +2 -2
- package/dist/src/oauth/userTokenClient.js +2 -2
- package/dist/src/oauth/userTokenClient.js.map +1 -1
- 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 -25
- package/dist/src/turnContext.js +31 -20
- package/dist/src/turnContext.js.map +1 -1
- package/package.json +3 -3
- 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/adaptiveCards/index.ts +2 -0
- package/src/app/agentApplication.ts +24 -7
- package/src/app/agentApplicationOptions.ts +1 -1
- package/src/app/appRoute.ts +8 -4
- package/src/app/attachmentDownloader.ts +3 -1
- package/src/app/authorization.ts +26 -18
- package/src/app/index.ts +2 -0
- 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/cloudAdapter.ts +2 -0
- package/src/headerPropagation.ts +18 -6
- package/src/index.ts +1 -0
- package/src/oauth/userTokenClient.ts +2 -2
- 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 -25
|
@@ -37,10 +37,12 @@ class MemoryStorage {
|
|
|
37
37
|
/**
|
|
38
38
|
* Gets a single shared instance of the MemoryStorage class.
|
|
39
39
|
*
|
|
40
|
+
* @returns The singleton instance of MemoryStorage
|
|
41
|
+
*
|
|
42
|
+
* @remarks
|
|
40
43
|
* Using this method ensures that the same storage instance is used across
|
|
41
44
|
* the application, allowing for shared state without passing references.
|
|
42
45
|
*
|
|
43
|
-
* @returns The singleton instance of MemoryStorage
|
|
44
46
|
*/
|
|
45
47
|
static getSingleInstance() {
|
|
46
48
|
if (!MemoryStorage.instance) {
|
|
@@ -72,14 +74,15 @@ class MemoryStorage {
|
|
|
72
74
|
/**
|
|
73
75
|
* Writes storage items to memory.
|
|
74
76
|
*
|
|
77
|
+
* @param changes The items to write, indexed by key
|
|
78
|
+
* @returns A promise that resolves when the write operation is complete
|
|
79
|
+
* @throws Will throw an error if changes are not provided or if there's an eTag conflict
|
|
80
|
+
*
|
|
81
|
+
* @remarks
|
|
75
82
|
* This method supports optimistic concurrency control through eTags.
|
|
76
83
|
* If an item has an eTag, it will only be updated if the existing item
|
|
77
84
|
* has the same eTag. If an item has an eTag of '*' or no eTag, it will
|
|
78
85
|
* always be written regardless of the current state.
|
|
79
|
-
*
|
|
80
|
-
* @param changes The items to write, indexed by key
|
|
81
|
-
* @returns A promise that resolves when the write operation is complete
|
|
82
|
-
* @throws Will throw an error if changes are not provided or if there's an eTag conflict
|
|
83
86
|
*/
|
|
84
87
|
async write(changes) {
|
|
85
88
|
if (!changes || changes.length === 0) {
|
|
@@ -117,13 +120,15 @@ class MemoryStorage {
|
|
|
117
120
|
/**
|
|
118
121
|
* Saves an item to memory with a new eTag.
|
|
119
122
|
*
|
|
123
|
+
* @param key The key of the item to save
|
|
124
|
+
* @param item The item to save
|
|
125
|
+
*
|
|
126
|
+
* @remarks
|
|
120
127
|
* This private method handles the details of:
|
|
121
128
|
* - Creating a clone of the item to prevent modification of the original
|
|
122
129
|
* - Generating a new eTag for optimistic concurrency control
|
|
123
130
|
* - Converting the item to a JSON string for storage
|
|
124
131
|
*
|
|
125
|
-
* @param key The key of the item to save
|
|
126
|
-
* @param item The item to save
|
|
127
132
|
* @private
|
|
128
133
|
*/
|
|
129
134
|
saveItem(key, item) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memoryStorage.js","sourceRoot":"","sources":["../../../src/storage/memoryStorage.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,8DAAyD;AAEzD,MAAM,MAAM,GAAG,IAAA,cAAK,EAAC,uBAAuB,CAAC,CAAA;AAE7C;;;;;;;;;;;;;GAaG;AACH,MAAa,aAAa;IAOxB;;;;OAIG;IACH,YAAqB,SAAkC,EAAE;QAApC,WAAM,GAAN,MAAM,CAA8B;QAVzD;;WAEG;QACK,SAAI,GAAW,CAAC,CAAA;IAOqC,CAAC;IAE9D
|
|
1
|
+
{"version":3,"file":"memoryStorage.js","sourceRoot":"","sources":["../../../src/storage/memoryStorage.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,8DAAyD;AAEzD,MAAM,MAAM,GAAG,IAAA,cAAK,EAAC,uBAAuB,CAAC,CAAA;AAE7C;;;;;;;;;;;;;GAaG;AACH,MAAa,aAAa;IAOxB;;;;OAIG;IACH,YAAqB,SAAkC,EAAE;QAApC,WAAM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
|
5
5
|
import { TurnContext } from '../turnContext';
|
|
6
6
|
/**
|
|
7
7
|
* Represents an item to be stored in a storage provider.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
8
10
|
* Each item can contain arbitrary data along with an optional eTag for optimistic concurrency control.
|
|
9
11
|
*/
|
|
10
12
|
export interface StoreItem {
|
|
11
13
|
/**
|
|
12
14
|
* Optional eTag used for optimistic concurrency control.
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
13
17
|
* When set to '*', it indicates that the write should proceed regardless of existing data.
|
|
14
18
|
* When comparing eTags, exact string matching is used to determine if data has changed.
|
|
19
|
+
*
|
|
15
20
|
*/
|
|
16
21
|
eTag?: string;
|
|
17
22
|
/**
|
|
18
23
|
* Additional properties can be stored in the item.
|
|
24
|
+
*
|
|
25
|
+
* @remarks
|
|
19
26
|
* Each storage provider may have specific requirements or limitations on property names and values.
|
|
27
|
+
*
|
|
20
28
|
*/
|
|
21
29
|
[key: string]: any;
|
|
22
30
|
}
|
|
23
31
|
/**
|
|
24
32
|
* Represents a collection of store items indexed by key.
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
25
35
|
* Used as the return type for storage read operations.
|
|
36
|
+
*
|
|
26
37
|
*/
|
|
27
38
|
export interface StoreItems {
|
|
28
39
|
/**
|
|
29
40
|
* Keys are the storage item identifiers, and values are the stored items.
|
|
41
|
+
*
|
|
42
|
+
* @remarks
|
|
30
43
|
* If a requested key is not found during a read operation, it will not appear in this collection.
|
|
44
|
+
*
|
|
31
45
|
*/
|
|
32
46
|
[key: string]: any;
|
|
33
47
|
}
|
|
34
48
|
/**
|
|
35
49
|
* A factory function to generate storage keys based on the conversation context.
|
|
36
|
-
* Allows different storage strategies based on the conversation state.
|
|
37
50
|
*
|
|
38
51
|
* @param context The TurnContext for the current turn of conversation
|
|
39
52
|
* @returns A string key for storage that uniquely identifies where to store the data
|
|
53
|
+
*
|
|
54
|
+
* @remarks
|
|
55
|
+
* Allows different storage strategies based on the conversation state.
|
|
56
|
+
*
|
|
40
57
|
*/
|
|
41
58
|
export type StorageKeyFactory = (context: TurnContext) => string | Promise<string>;
|
|
42
59
|
/**
|
|
@@ -36,11 +36,6 @@ export type DeleteActivityHandler = (context: TurnContext, reference: Conversati
|
|
|
36
36
|
* Key for the agent callback handler in TurnState collection.
|
|
37
37
|
*/
|
|
38
38
|
export declare const AgentCallbackHandlerKey = "agentCallbackHandler";
|
|
39
|
-
/**
|
|
40
|
-
* Interface for TurnContext.
|
|
41
|
-
*/
|
|
42
|
-
export interface TurnContext {
|
|
43
|
-
}
|
|
44
39
|
/**
|
|
45
40
|
* Represents the context for a single turn in a conversation between a user and an agent.
|
|
46
41
|
*
|
|
@@ -87,48 +82,52 @@ export declare class TurnContext {
|
|
|
87
82
|
/**
|
|
88
83
|
* Sends a trace activity for debugging purposes.
|
|
89
84
|
*
|
|
90
|
-
* Trace activities are typically used for debugging and are only visible in
|
|
91
|
-
* channels that support them, like the Bot Framework Emulator.
|
|
92
|
-
*
|
|
93
85
|
* @param name The name/category of the trace
|
|
94
86
|
* @param value The value/data to include in the trace
|
|
95
87
|
* @param valueType Optional type name for the value
|
|
96
88
|
* @param label Optional descriptive label for the trace
|
|
97
89
|
* @returns A promise that resolves to the resource response or undefined
|
|
90
|
+
*
|
|
91
|
+
* @remarks
|
|
92
|
+
* Trace activities are typically used for debugging and are only visible in
|
|
93
|
+
* channels that support them, like the Bot Framework Emulator.
|
|
98
94
|
*/
|
|
99
95
|
sendTraceActivity(name: string, value?: any, valueType?: string, label?: string): Promise<ResourceResponse | undefined>;
|
|
100
96
|
/**
|
|
101
97
|
* Sends an activity to the sender of the incoming activity.
|
|
102
98
|
*
|
|
103
|
-
* This is the primary method used to respond to the user. It automatically
|
|
104
|
-
* addresses the response to the correct conversation and recipient using
|
|
105
|
-
* information from the incoming activity.
|
|
106
|
-
*
|
|
107
99
|
* @param activityOrText The activity to send or a string for a simple message
|
|
108
100
|
* @param speak Optional text to be spoken by the agent
|
|
109
101
|
* @param inputHint Optional input hint to indicate if the agent is expecting input
|
|
110
102
|
* @returns A promise that resolves to the resource response or undefined
|
|
103
|
+
*
|
|
104
|
+
* @remarks
|
|
105
|
+
* This is the primary method used to respond to the user. It automatically
|
|
106
|
+
* addresses the response to the correct conversation and recipient using
|
|
107
|
+
* information from the incoming activity.
|
|
111
108
|
*/
|
|
112
109
|
sendActivity(activityOrText: string | Activity, speak?: string, inputHint?: string): Promise<ResourceResponse | undefined>;
|
|
113
110
|
/**
|
|
114
111
|
* Sends multiple activities to the sender of the incoming activity.
|
|
115
112
|
*
|
|
113
|
+
* @param activities The array of activities to send
|
|
114
|
+
* @returns A promise that resolves to an array of resource responses
|
|
115
|
+
*
|
|
116
|
+
* @remarks
|
|
116
117
|
* This method applies conversation references to each activity and
|
|
117
118
|
* emits them through the middleware chain before sending them to
|
|
118
119
|
* the adapter.
|
|
119
|
-
*
|
|
120
|
-
* @param activities The array of activities to send
|
|
121
|
-
* @returns A promise that resolves to an array of resource responses
|
|
122
120
|
*/
|
|
123
121
|
sendActivities(activities: Activity[]): Promise<ResourceResponse[]>;
|
|
124
122
|
/**
|
|
125
123
|
* Updates an existing activity in the conversation.
|
|
126
124
|
*
|
|
127
|
-
* This can be used to edit previously sent activities, for example to
|
|
128
|
-
* update the content of an adaptive card or change a message.
|
|
129
|
-
*
|
|
130
125
|
* @param activity The activity to update with its ID specified
|
|
131
126
|
* @returns A promise that resolves when the activity has been updated
|
|
127
|
+
*
|
|
128
|
+
* @remarks
|
|
129
|
+
* This can be used to edit previously sent activities, for example to
|
|
130
|
+
* update the content of an adaptive card or change a message.
|
|
132
131
|
*/
|
|
133
132
|
updateActivity(activity: Activity): Promise<void>;
|
|
134
133
|
/**
|
|
@@ -164,11 +163,12 @@ export declare class TurnContext {
|
|
|
164
163
|
/**
|
|
165
164
|
* Registers a handler for intercepting and processing activities being sent.
|
|
166
165
|
*
|
|
167
|
-
* This method follows a middleware pattern, allowing multiple handlers to
|
|
168
|
-
* be chained together. Handlers can modify activities or inject new ones.
|
|
169
|
-
*
|
|
170
166
|
* @param handler The handler to register
|
|
171
167
|
* @returns The current TurnContext instance for chaining
|
|
168
|
+
*
|
|
169
|
+
* @remarks
|
|
170
|
+
* This method follows a middleware pattern, allowing multiple handlers to
|
|
171
|
+
* be chained together. Handlers can modify activities or inject new ones.
|
|
172
172
|
*/
|
|
173
173
|
onSendActivities(handler: SendActivitiesHandler): this;
|
|
174
174
|
/**
|
|
@@ -197,6 +197,7 @@ export declare class TurnContext {
|
|
|
197
197
|
/**
|
|
198
198
|
* Gets the adapter that created this context.
|
|
199
199
|
*
|
|
200
|
+
* @remarks
|
|
200
201
|
* The adapter is responsible for sending and receiving activities
|
|
201
202
|
* to and from the user's channel.
|
|
202
203
|
*/
|
|
@@ -204,6 +205,7 @@ export declare class TurnContext {
|
|
|
204
205
|
/**
|
|
205
206
|
* Gets the incoming activity that started this turn.
|
|
206
207
|
*
|
|
208
|
+
* @remarks
|
|
207
209
|
* This is the activity that was received from the user or channel
|
|
208
210
|
* and triggered the creation of this context.
|
|
209
211
|
*/
|
|
@@ -211,6 +213,7 @@ export declare class TurnContext {
|
|
|
211
213
|
/**
|
|
212
214
|
* Gets or sets whether the turn has sent a response to the user.
|
|
213
215
|
*
|
|
216
|
+
* @remarks
|
|
214
217
|
* This is used to track whether the agent has responded to the user's
|
|
215
218
|
* activity. Once set to true, it cannot be set back to false.
|
|
216
219
|
*/
|
|
@@ -219,6 +222,7 @@ export declare class TurnContext {
|
|
|
219
222
|
/**
|
|
220
223
|
* Gets or sets the locale for the turn.
|
|
221
224
|
*
|
|
225
|
+
* @remarks
|
|
222
226
|
* The locale affects language-dependent operations like
|
|
223
227
|
* formatting dates or numbers.
|
|
224
228
|
*/
|
|
@@ -227,6 +231,7 @@ export declare class TurnContext {
|
|
|
227
231
|
/**
|
|
228
232
|
* Gets the turn state collection for storing data during the turn.
|
|
229
233
|
*
|
|
234
|
+
* @remarks
|
|
230
235
|
* The turn state collection provides a dictionary-like interface
|
|
231
236
|
* for storing arbitrary data that needs to be accessible during
|
|
232
237
|
* the processing of the current turn.
|
|
@@ -236,15 +241,16 @@ export declare class TurnContext {
|
|
|
236
241
|
/**
|
|
237
242
|
* Emits events to registered middleware handlers.
|
|
238
243
|
*
|
|
239
|
-
* This internal method implements the middleware pattern, allowing
|
|
240
|
-
* handlers to be chained together with each having the option to
|
|
241
|
-
* short-circuit the chain.
|
|
242
|
-
*
|
|
243
244
|
* @param handlers Array of handlers to execute
|
|
244
245
|
* @param arg The argument to pass to each handler
|
|
245
246
|
* @param next The function to execute at the end of the middleware chain
|
|
246
247
|
* @returns A promise that resolves to the result from the handlers or next function
|
|
247
248
|
* @private
|
|
249
|
+
*
|
|
250
|
+
* @remarks
|
|
251
|
+
* This internal method implements the middleware pattern, allowing
|
|
252
|
+
* handlers to be chained together with each having the option to
|
|
253
|
+
* short-circuit the chain.
|
|
248
254
|
*/
|
|
249
255
|
private emit;
|
|
250
256
|
}
|
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;
|
|
1
|
+
{"version":3,"file":"turnContext.js","sourceRoot":"","sources":["../../src/turnContext.ts"],"names":[],"mappings":";;;AAAA,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,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAA;IACxB,CAAC;IAED,IAAI,iBAAiB;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.7-g73d3d58001",
|
|
5
5
|
"homepage": "https://github.com/microsoft/Agents-for-js",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -21,8 +21,8 @@
|
|
|
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.
|
|
25
|
-
"axios": "^1.
|
|
24
|
+
"@microsoft/agents-activity": "1.0.7-g73d3d58001",
|
|
25
|
+
"axios": "^1.11.0",
|
|
26
26
|
"jsonwebtoken": "^9.0.2",
|
|
27
27
|
"jwks-rsa": "^3.2.0"
|
|
28
28
|
},
|
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.
|