@microsoft/agents-hosting 1.0.0-ge4831811bf → 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
|
@@ -6,10 +6,12 @@
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.AgentStatePropertyAccessor = void 0;
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Provides typed access to an Agent state property with automatic state loading and persistence management.
|
|
10
|
+
*
|
|
11
|
+
* @typeParam T The type of the property being accessed. Can be any serializable type.
|
|
10
12
|
*
|
|
11
13
|
* @remarks
|
|
12
|
-
* AgentStatePropertyAccessor simplifies working with persisted state by abstracting
|
|
14
|
+
* `AgentStatePropertyAccessor` simplifies working with persisted state by abstracting
|
|
13
15
|
* the complexity of loading state from storage and manipulating specific properties.
|
|
14
16
|
* It provides a type-safe interface for state management with automatic handling of:
|
|
15
17
|
*
|
|
@@ -21,6 +23,11 @@ exports.AgentStatePropertyAccessor = void 0;
|
|
|
21
23
|
*
|
|
22
24
|
* ### Key Features
|
|
23
25
|
*
|
|
26
|
+
* Key features of `AgentStatePropertyAccessor` include:
|
|
27
|
+
* - [Type Safety](#type-safety)
|
|
28
|
+
* - [Automatic Default Value Handling](#automatic-default-value-handling)
|
|
29
|
+
* - [Explicit Persistence Control](#explicit-persistence-control)
|
|
30
|
+
*
|
|
24
31
|
* #### Type Safety
|
|
25
32
|
* The accessor provides compile-time type checking when using TypeScript:
|
|
26
33
|
* ```typescript
|
|
@@ -111,8 +118,6 @@ exports.AgentStatePropertyAccessor = void 0;
|
|
|
111
118
|
* - **Persistence**: Always call `state.saveChanges(context)` to persist changes to storage.
|
|
112
119
|
* - **Deep Cloning**: Default values are deep cloned using JSON serialization, which may not work with complex objects containing functions or circular references.
|
|
113
120
|
*
|
|
114
|
-
* @typeParam T The type of the property being accessed. Can be any serializable type.
|
|
115
|
-
*
|
|
116
121
|
* @see {@link AgentState.createProperty} for creating property accessors
|
|
117
122
|
* @see {@link StatePropertyAccessor} for the interface definition
|
|
118
123
|
*/
|
|
@@ -120,13 +125,13 @@ class AgentStatePropertyAccessor {
|
|
|
120
125
|
/**
|
|
121
126
|
* Creates a new instance of AgentStatePropertyAccessor.
|
|
122
127
|
*
|
|
128
|
+
* @param state The agent state object that manages the backing storage for this property
|
|
129
|
+
* @param name The unique name of the property within the state object. This name is used as the key in the state storage.
|
|
130
|
+
*
|
|
123
131
|
* @remarks
|
|
124
132
|
* This constructor is typically not called directly. Instead, use {@link AgentState.createProperty}
|
|
125
133
|
* to create property accessors, which ensures proper integration with the state management system.
|
|
126
134
|
*
|
|
127
|
-
* @param state The agent state object that manages the backing storage for this property
|
|
128
|
-
* @param name The unique name of the property within the state object. This name is used as the key in the state storage.
|
|
129
|
-
*
|
|
130
135
|
* @example
|
|
131
136
|
* ```typescript
|
|
132
137
|
* // Recommended way - use AgentState.createProperty
|
|
@@ -135,13 +140,20 @@ class AgentStatePropertyAccessor {
|
|
|
135
140
|
* // Direct construction (not recommended)
|
|
136
141
|
* const accessor = new AgentStatePropertyAccessor<UserProfile>(userState, "userProfile");
|
|
137
142
|
* ```
|
|
143
|
+
*
|
|
138
144
|
*/
|
|
139
145
|
constructor(state, name) {
|
|
140
146
|
this.state = state;
|
|
141
147
|
this.name = name;
|
|
142
148
|
}
|
|
143
149
|
/**
|
|
144
|
-
*
|
|
150
|
+
* Deletes the property from the state storage.
|
|
151
|
+
*
|
|
152
|
+
* @param context The turn context for the current conversation turn
|
|
153
|
+
* @param customKey Optional custom key for accessing state in a specific storage location.
|
|
154
|
+
* Useful for multi-tenant scenarios or when state needs to be partitioned.
|
|
155
|
+
* @returns A promise that resolves when the delete operation is complete
|
|
156
|
+
*
|
|
145
157
|
* @remarks
|
|
146
158
|
* This operation removes the property from the in-memory state object but does not
|
|
147
159
|
* automatically persist the change to the underlying storage. You must call
|
|
@@ -151,13 +163,7 @@ class AgentStatePropertyAccessor {
|
|
|
151
163
|
* - The deletion only affects the in-memory state until `saveChanges()` is called
|
|
152
164
|
* - After deletion, subsequent `get()` calls will return `undefined` (or the default value if provided)
|
|
153
165
|
*
|
|
154
|
-
* @
|
|
155
|
-
* @param customKey Optional custom key for accessing state in a specific storage location.
|
|
156
|
-
* Useful for multi-tenant scenarios or when state needs to be partitioned.
|
|
157
|
-
*
|
|
158
|
-
* @returns A promise that resolves when the delete operation is complete
|
|
159
|
-
*
|
|
160
|
-
* @example
|
|
166
|
+
* @example Basic usage
|
|
161
167
|
* ```typescript
|
|
162
168
|
* const userSettings = userState.createProperty<UserSettings>("settings");
|
|
163
169
|
*
|
|
@@ -177,6 +183,7 @@ class AgentStatePropertyAccessor {
|
|
|
177
183
|
* await userSettings.delete(context, tenantKey);
|
|
178
184
|
* await userState.saveChanges(context);
|
|
179
185
|
* ```
|
|
186
|
+
*
|
|
180
187
|
*/
|
|
181
188
|
async delete(context, customKey) {
|
|
182
189
|
const obj = await this.state.load(context, false, customKey);
|
|
@@ -185,7 +192,16 @@ class AgentStatePropertyAccessor {
|
|
|
185
192
|
}
|
|
186
193
|
}
|
|
187
194
|
/**
|
|
188
|
-
*
|
|
195
|
+
* Retrieves the value of the property from state storage.
|
|
196
|
+
*
|
|
197
|
+
* @param context The turn context for the current conversation turn
|
|
198
|
+
* @param defaultValue Optional default value to use if the property doesn't exist.
|
|
199
|
+
* When provided, this value is deep cloned and stored in state.
|
|
200
|
+
* @param customKey Optional custom key for accessing state in a specific storage location.
|
|
201
|
+
* Useful for multi-tenant scenarios or when state needs to be partitioned.
|
|
202
|
+
*
|
|
203
|
+
* @returns A promise that resolves to the property value, the cloned default value, or `undefined`
|
|
204
|
+
*
|
|
189
205
|
* @remarks
|
|
190
206
|
* This method provides intelligent default value handling:
|
|
191
207
|
* - If the property exists, its value is returned
|
|
@@ -202,14 +218,6 @@ class AgentStatePropertyAccessor {
|
|
|
202
218
|
* **Performance**: The first access loads state from storage; subsequent accesses use
|
|
203
219
|
* the in-memory cached version until the context is disposed.
|
|
204
220
|
*
|
|
205
|
-
* @param context The turn context for the current conversation turn
|
|
206
|
-
* @param defaultValue Optional default value to use if the property doesn't exist.
|
|
207
|
-
* When provided, this value is deep cloned and stored in state.
|
|
208
|
-
* @param customKey Optional custom key for accessing state in a specific storage location.
|
|
209
|
-
* Useful for multi-tenant scenarios or when state needs to be partitioned.
|
|
210
|
-
*
|
|
211
|
-
* @returns A promise that resolves to the property value, the cloned default value, or `undefined`
|
|
212
|
-
*
|
|
213
221
|
* @example Basic usage
|
|
214
222
|
* ```typescript
|
|
215
223
|
* const counterProperty = userState.createProperty<number>("counter");
|
|
@@ -248,6 +256,7 @@ class AgentStatePropertyAccessor {
|
|
|
248
256
|
* const tenantKey = { key: `tenant_${tenantId}` };
|
|
249
257
|
* const tenantData = await dataProperty.get(context, defaultData, tenantKey);
|
|
250
258
|
* ```
|
|
259
|
+
*
|
|
251
260
|
*/
|
|
252
261
|
async get(context, defaultValue, customKey) {
|
|
253
262
|
const obj = await this.state.load(context, false, customKey);
|
|
@@ -260,7 +269,15 @@ class AgentStatePropertyAccessor {
|
|
|
260
269
|
return obj[this.name];
|
|
261
270
|
}
|
|
262
271
|
/**
|
|
263
|
-
*
|
|
272
|
+
* Sets the value of the property in state storage.
|
|
273
|
+
*
|
|
274
|
+
* @param context The turn context for the current conversation turn
|
|
275
|
+
* @param value The value to assign to the property. Can be any serializable value.
|
|
276
|
+
* @param customKey Optional custom key for accessing state in a specific storage location.
|
|
277
|
+
* Useful for multi-tenant scenarios or when state needs to be partitioned.
|
|
278
|
+
*
|
|
279
|
+
* @returns A promise that resolves when the set operation is complete
|
|
280
|
+
*
|
|
264
281
|
* @remarks
|
|
265
282
|
* This operation updates the property in the in-memory state object but does not
|
|
266
283
|
* automatically persist the change to the underlying storage. You must call
|
|
@@ -277,13 +294,6 @@ class AgentStatePropertyAccessor {
|
|
|
277
294
|
* **Type Safety**: When using TypeScript, the value must match the property's
|
|
278
295
|
* declared type parameter.
|
|
279
296
|
*
|
|
280
|
-
* @param context The turn context for the current conversation turn
|
|
281
|
-
* @param value The value to assign to the property. Can be any serializable value.
|
|
282
|
-
* @param customKey Optional custom key for accessing state in a specific storage location.
|
|
283
|
-
* Useful for multi-tenant scenarios or when state needs to be partitioned.
|
|
284
|
-
*
|
|
285
|
-
* @returns A promise that resolves when the set operation is complete
|
|
286
|
-
*
|
|
287
297
|
* @example Basic usage
|
|
288
298
|
* ```typescript
|
|
289
299
|
* const counterProperty = userState.createProperty<number>("counter");
|
|
@@ -325,6 +335,7 @@ class AgentStatePropertyAccessor {
|
|
|
325
335
|
* await dataProperty.set(context, updatedData, tenantKey);
|
|
326
336
|
* await userState.saveChanges(context);
|
|
327
337
|
* ```
|
|
338
|
+
*
|
|
328
339
|
*/
|
|
329
340
|
async set(context, value, customKey) {
|
|
330
341
|
const obj = await this.state.load(context, false, customKey);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentStatePropertyAccesor.js","sourceRoot":"","sources":["../../../src/state/agentStatePropertyAccesor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;
|
|
1
|
+
{"version":3,"file":"agentStatePropertyAccesor.js","sourceRoot":"","sources":["../../../src/state/agentStatePropertyAccesor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAkFH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmHG;AACH,MAAa,0BAA0B;IACrC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,YAAgC,KAAiB,EAAkB,IAAY;QAA/C,UAAK,GAAL,KAAK,CAAY;QAAkB,SAAI,GAAJ,IAAI,CAAQ;IAAI,CAAC;IAEpF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAsCG;IACH,KAAK,CAAC,MAAM,CAAE,OAAoB,EAAE,SAAqB;QACvD,MAAM,GAAG,GAAQ,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,CAAA;QACjE,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACzD,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACvB,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;;;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
|
|
8
8
|
*
|
|
9
9
|
* @remarks
|
|
10
10
|
* FileStorage stores all data in a single JSON file named 'state.json' within a specified folder.
|
|
@@ -43,7 +43,6 @@ import { Storage, StoreItem } from './storage';
|
|
|
43
43
|
* await storage.delete(['conversation456']);
|
|
44
44
|
* ```
|
|
45
45
|
*
|
|
46
|
-
|
|
47
46
|
*/
|
|
48
47
|
export declare class FileStorage implements Storage {
|
|
49
48
|
private _folder;
|
|
@@ -52,6 +51,7 @@ export declare class FileStorage implements Storage {
|
|
|
52
51
|
* Creates a new FileStorage instance that stores data in the specified folder.
|
|
53
52
|
*
|
|
54
53
|
* @param folder The absolute or relative path to the folder where the state.json file will be stored
|
|
54
|
+
* @throws May throw filesystem errors if the folder cannot be created or accessed
|
|
55
55
|
*
|
|
56
56
|
* @remarks
|
|
57
57
|
* The constructor performs the following initialization steps:
|
|
@@ -59,7 +59,6 @@ export declare class FileStorage implements Storage {
|
|
|
59
59
|
* 2. Creates an empty state.json file if it doesn't exist
|
|
60
60
|
* 3. Loads existing data from state.json into memory for fast access
|
|
61
61
|
*
|
|
62
|
-
* @throws May throw filesystem errors if the folder cannot be created or accessed
|
|
63
62
|
*/
|
|
64
63
|
constructor(folder: string);
|
|
65
64
|
/**
|
|
@@ -67,13 +66,13 @@ export declare class FileStorage implements Storage {
|
|
|
67
66
|
*
|
|
68
67
|
* @param keys Array of keys to read from storage
|
|
69
68
|
* @returns Promise resolving to an object containing the requested items (keys that don't exist are omitted)
|
|
70
|
-
*
|
|
71
69
|
* @throws ReferenceError if keys array is empty or undefined
|
|
72
70
|
*
|
|
73
71
|
* @remarks
|
|
74
72
|
* This method reads from the in-memory cache that was loaded during construction,
|
|
75
73
|
* making it very fast but potentially returning stale data if the file was
|
|
76
74
|
* modified by external processes.
|
|
75
|
+
*
|
|
77
76
|
*/
|
|
78
77
|
read(keys: string[]): Promise<StoreItem>;
|
|
79
78
|
/**
|
|
@@ -87,8 +86,10 @@ export declare class FileStorage implements Storage {
|
|
|
87
86
|
* to the state.json file. The file is written with pretty-printing (2-space indentation)
|
|
88
87
|
* for better readability during development and debugging.
|
|
89
88
|
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
89
|
+
* > [!NOTE]
|
|
90
|
+
* > This implementation does not support eTag-based optimistic concurrency control.
|
|
91
|
+
* > Any eTag values in the changes object are ignored.
|
|
92
|
+
*
|
|
92
93
|
*/
|
|
93
94
|
write(changes: StoreItem): Promise<void>;
|
|
94
95
|
/**
|
|
@@ -103,6 +104,7 @@ export declare class FileStorage implements Storage {
|
|
|
103
104
|
* This method removes the specified keys from both the in-memory cache
|
|
104
105
|
* and writes the updated state to the state.json file. Keys that don't
|
|
105
106
|
* exist in storage are silently ignored.
|
|
107
|
+
*
|
|
106
108
|
*/
|
|
107
109
|
delete(keys: string[]): Promise<void>;
|
|
108
110
|
}
|
|
@@ -11,7 +11,7 @@ exports.FileStorage = void 0;
|
|
|
11
11
|
const path_1 = __importDefault(require("path"));
|
|
12
12
|
const fs_1 = __importDefault(require("fs"));
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* A file-based storage implementation that persists data to the local filesystem.
|
|
15
15
|
*
|
|
16
16
|
* @remarks
|
|
17
17
|
* FileStorage stores all data in a single JSON file named 'state.json' within a specified folder.
|
|
@@ -50,13 +50,13 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
50
50
|
* await storage.delete(['conversation456']);
|
|
51
51
|
* ```
|
|
52
52
|
*
|
|
53
|
-
|
|
54
53
|
*/
|
|
55
54
|
class FileStorage {
|
|
56
55
|
/**
|
|
57
56
|
* Creates a new FileStorage instance that stores data in the specified folder.
|
|
58
57
|
*
|
|
59
58
|
* @param folder The absolute or relative path to the folder where the state.json file will be stored
|
|
59
|
+
* @throws May throw filesystem errors if the folder cannot be created or accessed
|
|
60
60
|
*
|
|
61
61
|
* @remarks
|
|
62
62
|
* The constructor performs the following initialization steps:
|
|
@@ -64,7 +64,6 @@ class FileStorage {
|
|
|
64
64
|
* 2. Creates an empty state.json file if it doesn't exist
|
|
65
65
|
* 3. Loads existing data from state.json into memory for fast access
|
|
66
66
|
*
|
|
67
|
-
* @throws May throw filesystem errors if the folder cannot be created or accessed
|
|
68
67
|
*/
|
|
69
68
|
constructor(folder) {
|
|
70
69
|
this._folder = folder;
|
|
@@ -82,13 +81,13 @@ class FileStorage {
|
|
|
82
81
|
*
|
|
83
82
|
* @param keys Array of keys to read from storage
|
|
84
83
|
* @returns Promise resolving to an object containing the requested items (keys that don't exist are omitted)
|
|
85
|
-
*
|
|
86
84
|
* @throws ReferenceError if keys array is empty or undefined
|
|
87
85
|
*
|
|
88
86
|
* @remarks
|
|
89
87
|
* This method reads from the in-memory cache that was loaded during construction,
|
|
90
88
|
* making it very fast but potentially returning stale data if the file was
|
|
91
89
|
* modified by external processes.
|
|
90
|
+
*
|
|
92
91
|
*/
|
|
93
92
|
read(keys) {
|
|
94
93
|
return new Promise((resolve, reject) => {
|
|
@@ -118,8 +117,10 @@ class FileStorage {
|
|
|
118
117
|
* to the state.json file. The file is written with pretty-printing (2-space indentation)
|
|
119
118
|
* for better readability during development and debugging.
|
|
120
119
|
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
120
|
+
* > [!NOTE]
|
|
121
|
+
* > This implementation does not support eTag-based optimistic concurrency control.
|
|
122
|
+
* > Any eTag values in the changes object are ignored.
|
|
123
|
+
*
|
|
123
124
|
*/
|
|
124
125
|
write(changes) {
|
|
125
126
|
const keys = Object.keys(changes);
|
|
@@ -141,6 +142,7 @@ class FileStorage {
|
|
|
141
142
|
* This method removes the specified keys from both the in-memory cache
|
|
142
143
|
* and writes the updated state to the state.json file. Keys that don't
|
|
143
144
|
* exist in storage are silently ignored.
|
|
145
|
+
*
|
|
144
146
|
*/
|
|
145
147
|
delete(keys) {
|
|
146
148
|
return new Promise((resolve, reject) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileStorage.js","sourceRoot":"","sources":["../../../src/storage/fileStorage.ts"],"names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AC,OAAO,GAAG,aAAa,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;YAC1F,CAAC;YACD,OAAO,EAAE,CAAA;QACX,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AA/GD,kCA+GC"}
|
|
@@ -35,10 +35,12 @@ export declare class MemoryStorage implements Storage {
|
|
|
35
35
|
/**
|
|
36
36
|
* Gets a single shared instance of the MemoryStorage class.
|
|
37
37
|
*
|
|
38
|
+
* @returns The singleton instance of MemoryStorage
|
|
39
|
+
*
|
|
40
|
+
* @remarks
|
|
38
41
|
* Using this method ensures that the same storage instance is used across
|
|
39
42
|
* the application, allowing for shared state without passing references.
|
|
40
43
|
*
|
|
41
|
-
* @returns The singleton instance of MemoryStorage
|
|
42
44
|
*/
|
|
43
45
|
static getSingleInstance(): MemoryStorage;
|
|
44
46
|
/**
|
|
@@ -52,14 +54,15 @@ export declare class MemoryStorage implements Storage {
|
|
|
52
54
|
/**
|
|
53
55
|
* Writes storage items to memory.
|
|
54
56
|
*
|
|
57
|
+
* @param changes The items to write, indexed by key
|
|
58
|
+
* @returns A promise that resolves when the write operation is complete
|
|
59
|
+
* @throws Will throw an error if changes are not provided or if there's an eTag conflict
|
|
60
|
+
*
|
|
61
|
+
* @remarks
|
|
55
62
|
* This method supports optimistic concurrency control through eTags.
|
|
56
63
|
* If an item has an eTag, it will only be updated if the existing item
|
|
57
64
|
* has the same eTag. If an item has an eTag of '*' or no eTag, it will
|
|
58
65
|
* always be written regardless of the current state.
|
|
59
|
-
*
|
|
60
|
-
* @param changes The items to write, indexed by key
|
|
61
|
-
* @returns A promise that resolves when the write operation is complete
|
|
62
|
-
* @throws Will throw an error if changes are not provided or if there's an eTag conflict
|
|
63
66
|
*/
|
|
64
67
|
write(changes: StoreItem): Promise<void>;
|
|
65
68
|
/**
|
|
@@ -72,13 +75,15 @@ export declare class MemoryStorage implements Storage {
|
|
|
72
75
|
/**
|
|
73
76
|
* Saves an item to memory with a new eTag.
|
|
74
77
|
*
|
|
78
|
+
* @param key The key of the item to save
|
|
79
|
+
* @param item The item to save
|
|
80
|
+
*
|
|
81
|
+
* @remarks
|
|
75
82
|
* This private method handles the details of:
|
|
76
83
|
* - Creating a clone of the item to prevent modification of the original
|
|
77
84
|
* - Generating a new eTag for optimistic concurrency control
|
|
78
85
|
* - Converting the item to a JSON string for storage
|
|
79
86
|
*
|
|
80
|
-
* @param key The key of the item to save
|
|
81
|
-
* @param item The item to save
|
|
82
87
|
* @private
|
|
83
88
|
*/
|
|
84
89
|
private saveItem;
|
|
@@ -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,GAAN,MAAM,CAA8B;QAVzD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Context';
|
|
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
|
/**
|
|
@@ -87,48 +87,52 @@ export declare class TurnContext {
|
|
|
87
87
|
/**
|
|
88
88
|
* Sends a trace activity for debugging purposes.
|
|
89
89
|
*
|
|
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
90
|
* @param name The name/category of the trace
|
|
94
91
|
* @param value The value/data to include in the trace
|
|
95
92
|
* @param valueType Optional type name for the value
|
|
96
93
|
* @param label Optional descriptive label for the trace
|
|
97
94
|
* @returns A promise that resolves to the resource response or undefined
|
|
95
|
+
*
|
|
96
|
+
* @remarks
|
|
97
|
+
* Trace activities are typically used for debugging and are only visible in
|
|
98
|
+
* channels that support them, like the Bot Framework Emulator.
|
|
98
99
|
*/
|
|
99
100
|
sendTraceActivity(name: string, value?: any, valueType?: string, label?: string): Promise<ResourceResponse | undefined>;
|
|
100
101
|
/**
|
|
101
102
|
* Sends an activity to the sender of the incoming activity.
|
|
102
103
|
*
|
|
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
104
|
* @param activityOrText The activity to send or a string for a simple message
|
|
108
105
|
* @param speak Optional text to be spoken by the agent
|
|
109
106
|
* @param inputHint Optional input hint to indicate if the agent is expecting input
|
|
110
107
|
* @returns A promise that resolves to the resource response or undefined
|
|
108
|
+
*
|
|
109
|
+
* @remarks
|
|
110
|
+
* This is the primary method used to respond to the user. It automatically
|
|
111
|
+
* addresses the response to the correct conversation and recipient using
|
|
112
|
+
* information from the incoming activity.
|
|
111
113
|
*/
|
|
112
114
|
sendActivity(activityOrText: string | Activity, speak?: string, inputHint?: string): Promise<ResourceResponse | undefined>;
|
|
113
115
|
/**
|
|
114
116
|
* Sends multiple activities to the sender of the incoming activity.
|
|
115
117
|
*
|
|
118
|
+
* @param activities The array of activities to send
|
|
119
|
+
* @returns A promise that resolves to an array of resource responses
|
|
120
|
+
*
|
|
121
|
+
* @remarks
|
|
116
122
|
* This method applies conversation references to each activity and
|
|
117
123
|
* emits them through the middleware chain before sending them to
|
|
118
124
|
* 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
125
|
*/
|
|
123
126
|
sendActivities(activities: Activity[]): Promise<ResourceResponse[]>;
|
|
124
127
|
/**
|
|
125
128
|
* Updates an existing activity in the conversation.
|
|
126
129
|
*
|
|
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
130
|
* @param activity The activity to update with its ID specified
|
|
131
131
|
* @returns A promise that resolves when the activity has been updated
|
|
132
|
+
*
|
|
133
|
+
* @remarks
|
|
134
|
+
* This can be used to edit previously sent activities, for example to
|
|
135
|
+
* update the content of an adaptive card or change a message.
|
|
132
136
|
*/
|
|
133
137
|
updateActivity(activity: Activity): Promise<void>;
|
|
134
138
|
/**
|
|
@@ -164,11 +168,12 @@ export declare class TurnContext {
|
|
|
164
168
|
/**
|
|
165
169
|
* Registers a handler for intercepting and processing activities being sent.
|
|
166
170
|
*
|
|
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
171
|
* @param handler The handler to register
|
|
171
172
|
* @returns The current TurnContext instance for chaining
|
|
173
|
+
*
|
|
174
|
+
* @remarks
|
|
175
|
+
* This method follows a middleware pattern, allowing multiple handlers to
|
|
176
|
+
* be chained together. Handlers can modify activities or inject new ones.
|
|
172
177
|
*/
|
|
173
178
|
onSendActivities(handler: SendActivitiesHandler): this;
|
|
174
179
|
/**
|
|
@@ -197,6 +202,7 @@ export declare class TurnContext {
|
|
|
197
202
|
/**
|
|
198
203
|
* Gets the adapter that created this context.
|
|
199
204
|
*
|
|
205
|
+
* @remarks
|
|
200
206
|
* The adapter is responsible for sending and receiving activities
|
|
201
207
|
* to and from the user's channel.
|
|
202
208
|
*/
|
|
@@ -204,6 +210,7 @@ export declare class TurnContext {
|
|
|
204
210
|
/**
|
|
205
211
|
* Gets the incoming activity that started this turn.
|
|
206
212
|
*
|
|
213
|
+
* @remarks
|
|
207
214
|
* This is the activity that was received from the user or channel
|
|
208
215
|
* and triggered the creation of this context.
|
|
209
216
|
*/
|
|
@@ -211,6 +218,7 @@ export declare class TurnContext {
|
|
|
211
218
|
/**
|
|
212
219
|
* Gets or sets whether the turn has sent a response to the user.
|
|
213
220
|
*
|
|
221
|
+
* @remarks
|
|
214
222
|
* This is used to track whether the agent has responded to the user's
|
|
215
223
|
* activity. Once set to true, it cannot be set back to false.
|
|
216
224
|
*/
|
|
@@ -219,6 +227,7 @@ export declare class TurnContext {
|
|
|
219
227
|
/**
|
|
220
228
|
* Gets or sets the locale for the turn.
|
|
221
229
|
*
|
|
230
|
+
* @remarks
|
|
222
231
|
* The locale affects language-dependent operations like
|
|
223
232
|
* formatting dates or numbers.
|
|
224
233
|
*/
|
|
@@ -227,6 +236,7 @@ export declare class TurnContext {
|
|
|
227
236
|
/**
|
|
228
237
|
* Gets the turn state collection for storing data during the turn.
|
|
229
238
|
*
|
|
239
|
+
* @remarks
|
|
230
240
|
* The turn state collection provides a dictionary-like interface
|
|
231
241
|
* for storing arbitrary data that needs to be accessible during
|
|
232
242
|
* the processing of the current turn.
|
|
@@ -236,15 +246,16 @@ export declare class TurnContext {
|
|
|
236
246
|
/**
|
|
237
247
|
* Emits events to registered middleware handlers.
|
|
238
248
|
*
|
|
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
249
|
* @param handlers Array of handlers to execute
|
|
244
250
|
* @param arg The argument to pass to each handler
|
|
245
251
|
* @param next The function to execute at the end of the middleware chain
|
|
246
252
|
* @returns A promise that resolves to the result from the handlers or next function
|
|
247
253
|
* @private
|
|
254
|
+
*
|
|
255
|
+
* @remarks
|
|
256
|
+
* This internal method implements the middleware pattern, allowing
|
|
257
|
+
* handlers to be chained together with each having the option to
|
|
258
|
+
* short-circuit the chain.
|
|
248
259
|
*/
|
|
249
260
|
private emit;
|
|
250
261
|
}
|