@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
|
@@ -7,28 +7,35 @@ import { AgentState, CustomKey } from './agentState';
|
|
|
7
7
|
/**
|
|
8
8
|
* Interface for accessing a property in state storage with type safety.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
10
|
+
* @typeParam T The type of the property being accessed
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* This interface defines standard methods for working with persisted state properties,
|
|
11
14
|
* allowing property access with strong typing to reduce errors when working with
|
|
12
15
|
* complex state objects.
|
|
13
16
|
*
|
|
14
|
-
* @typeParam T The type of the property being accessed
|
|
15
17
|
*/
|
|
16
18
|
export interface StatePropertyAccessor<T = any> {
|
|
17
19
|
/**
|
|
18
20
|
* Deletes the persisted property from its backing storage object.
|
|
19
21
|
*
|
|
22
|
+
* @param context Context for the current turn of conversation with the user.
|
|
23
|
+
*
|
|
20
24
|
* @remarks
|
|
21
25
|
* The properties backing storage object SHOULD be loaded into memory on first access.
|
|
22
26
|
*
|
|
23
|
-
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```javascript
|
|
24
29
|
* await myProperty.delete(context);
|
|
25
30
|
* ```
|
|
26
|
-
*
|
|
31
|
+
*
|
|
27
32
|
*/
|
|
28
33
|
delete(context: TurnContext): Promise<void>;
|
|
29
34
|
/**
|
|
30
35
|
* Reads a persisted property from its backing storage object.
|
|
31
36
|
*
|
|
37
|
+
* @param context Context for the current turn of conversation with the user.
|
|
38
|
+
*
|
|
32
39
|
* @remarks
|
|
33
40
|
* The properties backing storage object SHOULD be loaded into memory on first access.
|
|
34
41
|
*
|
|
@@ -36,10 +43,11 @@ export interface StatePropertyAccessor<T = any> {
|
|
|
36
43
|
* specified, a clone of the `defaultValue` SHOULD be copied to the storage object. If a
|
|
37
44
|
* `defaultValue` has not been specified then a value of `undefined` SHOULD be returned.
|
|
38
45
|
*
|
|
39
|
-
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```javascript
|
|
40
48
|
* const value = await myProperty.get(context, { count: 0 });
|
|
41
49
|
* ```
|
|
42
|
-
*
|
|
50
|
+
*
|
|
43
51
|
*/
|
|
44
52
|
get(context: TurnContext): Promise<T | undefined>;
|
|
45
53
|
/**
|
|
@@ -52,25 +60,30 @@ export interface StatePropertyAccessor<T = any> {
|
|
|
52
60
|
/**
|
|
53
61
|
* Assigns a new value to the properties backing storage object.
|
|
54
62
|
*
|
|
63
|
+
* @param context Context for the current turn of conversation with the user.
|
|
64
|
+
* @param value Value to assign.
|
|
65
|
+
*
|
|
55
66
|
* @remarks
|
|
56
67
|
* The properties backing storage object SHOULD be loaded into memory on first access.
|
|
57
68
|
*
|
|
58
69
|
* Depending on the state systems implementation, an additional step may be required to
|
|
59
70
|
* persist the actual changes to disk.
|
|
60
71
|
*
|
|
61
|
-
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```javascript
|
|
62
74
|
* await myProperty.set(context, value);
|
|
63
75
|
* ```
|
|
64
|
-
*
|
|
65
|
-
* @param value Value to assign.
|
|
76
|
+
*
|
|
66
77
|
*/
|
|
67
78
|
set(context: TurnContext, value: T): Promise<void>;
|
|
68
79
|
}
|
|
69
80
|
/**
|
|
70
|
-
*
|
|
81
|
+
* Provides typed access to an Agent state property with automatic state loading and persistence management.
|
|
82
|
+
*
|
|
83
|
+
* @typeParam T The type of the property being accessed. Can be any serializable type.
|
|
71
84
|
*
|
|
72
85
|
* @remarks
|
|
73
|
-
* AgentStatePropertyAccessor simplifies working with persisted state by abstracting
|
|
86
|
+
* `AgentStatePropertyAccessor` simplifies working with persisted state by abstracting
|
|
74
87
|
* the complexity of loading state from storage and manipulating specific properties.
|
|
75
88
|
* It provides a type-safe interface for state management with automatic handling of:
|
|
76
89
|
*
|
|
@@ -82,6 +95,11 @@ export interface StatePropertyAccessor<T = any> {
|
|
|
82
95
|
*
|
|
83
96
|
* ### Key Features
|
|
84
97
|
*
|
|
98
|
+
* Key features of `AgentStatePropertyAccessor` include:
|
|
99
|
+
* - [Type Safety](#type-safety)
|
|
100
|
+
* - [Automatic Default Value Handling](#automatic-default-value-handling)
|
|
101
|
+
* - [Explicit Persistence Control](#explicit-persistence-control)
|
|
102
|
+
*
|
|
85
103
|
* #### Type Safety
|
|
86
104
|
* The accessor provides compile-time type checking when using TypeScript:
|
|
87
105
|
* ```typescript
|
|
@@ -172,8 +190,6 @@ export interface StatePropertyAccessor<T = any> {
|
|
|
172
190
|
* - **Persistence**: Always call `state.saveChanges(context)` to persist changes to storage.
|
|
173
191
|
* - **Deep Cloning**: Default values are deep cloned using JSON serialization, which may not work with complex objects containing functions or circular references.
|
|
174
192
|
*
|
|
175
|
-
* @typeParam T The type of the property being accessed. Can be any serializable type.
|
|
176
|
-
*
|
|
177
193
|
* @see {@link AgentState.createProperty} for creating property accessors
|
|
178
194
|
* @see {@link StatePropertyAccessor} for the interface definition
|
|
179
195
|
*/
|
|
@@ -183,13 +199,13 @@ export declare class AgentStatePropertyAccessor<T = any> implements StatePropert
|
|
|
183
199
|
/**
|
|
184
200
|
* Creates a new instance of AgentStatePropertyAccessor.
|
|
185
201
|
*
|
|
202
|
+
* @param state The agent state object that manages the backing storage for this property
|
|
203
|
+
* @param name The unique name of the property within the state object. This name is used as the key in the state storage.
|
|
204
|
+
*
|
|
186
205
|
* @remarks
|
|
187
206
|
* This constructor is typically not called directly. Instead, use {@link AgentState.createProperty}
|
|
188
207
|
* to create property accessors, which ensures proper integration with the state management system.
|
|
189
208
|
*
|
|
190
|
-
* @param state The agent state object that manages the backing storage for this property
|
|
191
|
-
* @param name The unique name of the property within the state object. This name is used as the key in the state storage.
|
|
192
|
-
*
|
|
193
209
|
* @example
|
|
194
210
|
* ```typescript
|
|
195
211
|
* // Recommended way - use AgentState.createProperty
|
|
@@ -198,10 +214,17 @@ export declare class AgentStatePropertyAccessor<T = any> implements StatePropert
|
|
|
198
214
|
* // Direct construction (not recommended)
|
|
199
215
|
* const accessor = new AgentStatePropertyAccessor<UserProfile>(userState, "userProfile");
|
|
200
216
|
* ```
|
|
217
|
+
*
|
|
201
218
|
*/
|
|
202
219
|
constructor(state: AgentState, name: string);
|
|
203
220
|
/**
|
|
204
|
-
*
|
|
221
|
+
* Deletes the property from the state storage.
|
|
222
|
+
*
|
|
223
|
+
* @param context The turn context for the current conversation turn
|
|
224
|
+
* @param customKey Optional custom key for accessing state in a specific storage location.
|
|
225
|
+
* Useful for multi-tenant scenarios or when state needs to be partitioned.
|
|
226
|
+
* @returns A promise that resolves when the delete operation is complete
|
|
227
|
+
*
|
|
205
228
|
* @remarks
|
|
206
229
|
* This operation removes the property from the in-memory state object but does not
|
|
207
230
|
* automatically persist the change to the underlying storage. You must call
|
|
@@ -211,13 +234,7 @@ export declare class AgentStatePropertyAccessor<T = any> implements StatePropert
|
|
|
211
234
|
* - The deletion only affects the in-memory state until `saveChanges()` is called
|
|
212
235
|
* - After deletion, subsequent `get()` calls will return `undefined` (or the default value if provided)
|
|
213
236
|
*
|
|
214
|
-
* @
|
|
215
|
-
* @param customKey Optional custom key for accessing state in a specific storage location.
|
|
216
|
-
* Useful for multi-tenant scenarios or when state needs to be partitioned.
|
|
217
|
-
*
|
|
218
|
-
* @returns A promise that resolves when the delete operation is complete
|
|
219
|
-
*
|
|
220
|
-
* @example
|
|
237
|
+
* @example Basic usage
|
|
221
238
|
* ```typescript
|
|
222
239
|
* const userSettings = userState.createProperty<UserSettings>("settings");
|
|
223
240
|
*
|
|
@@ -237,10 +254,20 @@ export declare class AgentStatePropertyAccessor<T = any> implements StatePropert
|
|
|
237
254
|
* await userSettings.delete(context, tenantKey);
|
|
238
255
|
* await userState.saveChanges(context);
|
|
239
256
|
* ```
|
|
257
|
+
*
|
|
240
258
|
*/
|
|
241
259
|
delete(context: TurnContext, customKey?: CustomKey): Promise<void>;
|
|
242
260
|
/**
|
|
243
|
-
*
|
|
261
|
+
* Retrieves the value of the property from state storage.
|
|
262
|
+
*
|
|
263
|
+
* @param context The turn context for the current conversation turn
|
|
264
|
+
* @param defaultValue Optional default value to use if the property doesn't exist.
|
|
265
|
+
* When provided, this value is deep cloned and stored in state.
|
|
266
|
+
* @param customKey Optional custom key for accessing state in a specific storage location.
|
|
267
|
+
* Useful for multi-tenant scenarios or when state needs to be partitioned.
|
|
268
|
+
*
|
|
269
|
+
* @returns A promise that resolves to the property value, the cloned default value, or `undefined`
|
|
270
|
+
*
|
|
244
271
|
* @remarks
|
|
245
272
|
* This method provides intelligent default value handling:
|
|
246
273
|
* - If the property exists, its value is returned
|
|
@@ -257,14 +284,6 @@ export declare class AgentStatePropertyAccessor<T = any> implements StatePropert
|
|
|
257
284
|
* **Performance**: The first access loads state from storage; subsequent accesses use
|
|
258
285
|
* the in-memory cached version until the context is disposed.
|
|
259
286
|
*
|
|
260
|
-
* @param context The turn context for the current conversation turn
|
|
261
|
-
* @param defaultValue Optional default value to use if the property doesn't exist.
|
|
262
|
-
* When provided, this value is deep cloned and stored in state.
|
|
263
|
-
* @param customKey Optional custom key for accessing state in a specific storage location.
|
|
264
|
-
* Useful for multi-tenant scenarios or when state needs to be partitioned.
|
|
265
|
-
*
|
|
266
|
-
* @returns A promise that resolves to the property value, the cloned default value, or `undefined`
|
|
267
|
-
*
|
|
268
287
|
* @example Basic usage
|
|
269
288
|
* ```typescript
|
|
270
289
|
* const counterProperty = userState.createProperty<number>("counter");
|
|
@@ -303,10 +322,19 @@ export declare class AgentStatePropertyAccessor<T = any> implements StatePropert
|
|
|
303
322
|
* const tenantKey = { key: `tenant_${tenantId}` };
|
|
304
323
|
* const tenantData = await dataProperty.get(context, defaultData, tenantKey);
|
|
305
324
|
* ```
|
|
325
|
+
*
|
|
306
326
|
*/
|
|
307
327
|
get(context: TurnContext, defaultValue?: T, customKey?: CustomKey): Promise<T>;
|
|
308
328
|
/**
|
|
309
|
-
*
|
|
329
|
+
* Sets the value of the property in state storage.
|
|
330
|
+
*
|
|
331
|
+
* @param context The turn context for the current conversation turn
|
|
332
|
+
* @param value The value to assign to the property. Can be any serializable value.
|
|
333
|
+
* @param customKey Optional custom key for accessing state in a specific storage location.
|
|
334
|
+
* Useful for multi-tenant scenarios or when state needs to be partitioned.
|
|
335
|
+
*
|
|
336
|
+
* @returns A promise that resolves when the set operation is complete
|
|
337
|
+
*
|
|
310
338
|
* @remarks
|
|
311
339
|
* This operation updates the property in the in-memory state object but does not
|
|
312
340
|
* automatically persist the change to the underlying storage. You must call
|
|
@@ -323,13 +351,6 @@ export declare class AgentStatePropertyAccessor<T = any> implements StatePropert
|
|
|
323
351
|
* **Type Safety**: When using TypeScript, the value must match the property's
|
|
324
352
|
* declared type parameter.
|
|
325
353
|
*
|
|
326
|
-
* @param context The turn context for the current conversation turn
|
|
327
|
-
* @param value The value to assign to the property. Can be any serializable value.
|
|
328
|
-
* @param customKey Optional custom key for accessing state in a specific storage location.
|
|
329
|
-
* Useful for multi-tenant scenarios or when state needs to be partitioned.
|
|
330
|
-
*
|
|
331
|
-
* @returns A promise that resolves when the set operation is complete
|
|
332
|
-
*
|
|
333
354
|
* @example Basic usage
|
|
334
355
|
* ```typescript
|
|
335
356
|
* const counterProperty = userState.createProperty<number>("counter");
|
|
@@ -371,6 +392,7 @@ export declare class AgentStatePropertyAccessor<T = any> implements StatePropert
|
|
|
371
392
|
* await dataProperty.set(context, updatedData, tenantKey);
|
|
372
393
|
* await userState.saveChanges(context);
|
|
373
394
|
* ```
|
|
395
|
+
*
|
|
374
396
|
*/
|
|
375
397
|
set(context: TurnContext, value: T, customKey?: CustomKey): Promise<void>;
|
|
376
398
|
}
|
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkEG;IACH,KAAK,CAAC,GAAG,CAAE,OAAoB,EAAE,YAAgB,EAAE,SAAqB;QACtE,MAAM,GAAG,GAAQ,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,CAAA;QACjE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;YACxF,MAAM,KAAK,GACT,OAAO,YAAY,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC;gBAC7D,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;gBAC1C,CAAC,CAAC,YAAY,CAAA;YAClB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,CAAA;QACxB,CAAC;QAED,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACvB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoEG;IACH,KAAK,CAAC,GAAG,CAAE,OAAoB,EAAE,KAAQ,EAAE,SAAqB;QAC9D,MAAM,GAAG,GAAQ,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,CAAA;QACjE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,CAAA;IACxB,CAAC;CACF;AA9ND,gEA8NC"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { Storage, StoreItem } from './storage';
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* A file-based storage implementation that persists data to the local filesystem.
|
|
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":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,gDAAuB;AACvB,4CAAmB;AAGnB
|
|
1
|
+
{"version":3,"file":"fileStorage.js","sourceRoot":"","sources":["../../../src/storage/fileStorage.ts"],"names":[],"mappings":"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"}
|
|
@@ -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;
|