@microsoft/agents-hosting 1.9.0-beta.18.g6b8111bba5 → 1.9.0-beta.20.g0c48a31a21
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/README.md +18 -10
- package/dist/package.json +3 -3
- package/dist/src/app/agentApplication.d.ts +1 -0
- package/dist/src/app/agentApplication.js +18 -5
- package/dist/src/app/agentApplication.js.map +1 -1
- package/dist/src/app/agentApplicationBuilder.d.ts +9 -2
- package/dist/src/app/agentApplicationBuilder.js +9 -0
- package/dist/src/app/agentApplicationBuilder.js.map +1 -1
- package/dist/src/app/agentApplicationOptions.d.ts +10 -4
- package/dist/src/app/auth/handlerStorage.d.ts +5 -3
- package/dist/src/app/auth/handlerStorage.js +36 -10
- package/dist/src/app/auth/handlerStorage.js.map +1 -1
- package/dist/src/app/auth/types.d.ts +2 -2
- package/dist/src/app/index.d.ts +1 -0
- package/dist/src/app/proactive/proactive.js +10 -6
- package/dist/src/app/proactive/proactive.js.map +1 -1
- package/dist/src/app/proactive/proactiveOptions.d.ts +2 -2
- package/dist/src/app/rateLimit.d.ts +315 -0
- package/dist/src/app/rateLimit.js +333 -0
- package/dist/src/app/rateLimit.js.map +1 -0
- package/dist/src/app/turnState.d.ts +6 -3
- package/dist/src/app/turnState.js +43 -4
- package/dist/src/app/turnState.js.map +1 -1
- package/dist/src/errorHelper.js +40 -9
- package/dist/src/errorHelper.js.map +1 -1
- package/dist/src/observability/traces.d.ts +6 -4
- package/dist/src/observability/traces.js +10 -9
- package/dist/src/observability/traces.js.map +1 -1
- package/dist/src/state/agentState.d.ts +8 -3
- package/dist/src/state/agentState.js +26 -8
- package/dist/src/state/agentState.js.map +1 -1
- package/dist/src/state/conversationState.d.ts +2 -2
- package/dist/src/state/conversationState.js.map +1 -1
- package/dist/src/state/userState.d.ts +2 -2
- package/dist/src/state/userState.js.map +1 -1
- package/dist/src/statusCodes.d.ts +5 -0
- package/dist/src/statusCodes.js +5 -0
- package/dist/src/statusCodes.js.map +1 -1
- package/dist/src/storage/fileStorage.d.ts +83 -71
- package/dist/src/storage/fileStorage.js +272 -136
- package/dist/src/storage/fileStorage.js.map +1 -1
- package/dist/src/storage/memoryStorage.d.ts +85 -62
- package/dist/src/storage/memoryStorage.js +240 -109
- package/dist/src/storage/memoryStorage.js.map +1 -1
- package/dist/src/storage/storage.d.ts +101 -16
- package/dist/src/storage/storage.js +25 -0
- package/dist/src/storage/storage.js.map +1 -1
- package/dist/src/storage/storageCompatibility.d.ts +17 -0
- package/dist/src/storage/storageCompatibility.js +157 -0
- package/dist/src/storage/storageCompatibility.js.map +1 -0
- package/package.json +3 -3
- package/src/app/agentApplication.ts +16 -0
- package/src/app/agentApplicationBuilder.ts +13 -2
- package/src/app/agentApplicationOptions.ts +11 -4
- package/src/app/auth/handlerStorage.ts +51 -7
- package/src/app/auth/types.ts +2 -2
- package/src/app/index.ts +7 -0
- package/src/app/proactive/proactive.ts +19 -9
- package/src/app/proactive/proactiveOptions.ts +2 -2
- package/src/app/rateLimit.ts +659 -0
- package/src/app/turnState.ts +50 -7
- package/src/errorHelper.ts +46 -8
- package/src/observability/traces.ts +8 -7
- package/src/state/agentState.ts +39 -13
- package/src/state/conversationState.ts +2 -2
- package/src/state/userState.ts +2 -2
- package/src/statusCodes.ts +6 -0
- package/src/storage/fileStorage.ts +289 -134
- package/src/storage/memoryStorage.ts +266 -109
- package/src/storage/storage.ts +115 -17
- package/src/storage/storageCompatibility.ts +185 -0
|
@@ -7,7 +7,13 @@ import type { BaseAdapter } from '../../baseAdapter'
|
|
|
7
7
|
import type { TurnContext } from '../../turnContext'
|
|
8
8
|
import type { TurnState } from '../turnState'
|
|
9
9
|
import type { RouteHandler } from '../routeHandler'
|
|
10
|
-
import type {
|
|
10
|
+
import type { StorageV2 } from '../../storage/storage'
|
|
11
|
+
import {
|
|
12
|
+
asStorageV2,
|
|
13
|
+
assertStorageDeleteSucceeded,
|
|
14
|
+
assertStorageWriteSucceeded,
|
|
15
|
+
getStorageReadValue,
|
|
16
|
+
} from '../../storage/storageCompatibility'
|
|
11
17
|
import type { AgentApplication } from '../agentApplication'
|
|
12
18
|
import type { ProactiveOptions } from './proactiveOptions'
|
|
13
19
|
import type { CreateConversationOptions } from './createConversationOptions'
|
|
@@ -41,31 +47,31 @@ export class Proactive<TState extends TurnState> {
|
|
|
41
47
|
|
|
42
48
|
private readonly _app: AgentApplication<TState>
|
|
43
49
|
private readonly _options: ProactiveOptions
|
|
44
|
-
private readonly _storage?:
|
|
50
|
+
private readonly _storage?: StorageV2
|
|
45
51
|
|
|
46
52
|
constructor (app: AgentApplication<TState>, options: ProactiveOptions) {
|
|
47
53
|
this._app = app
|
|
48
54
|
this._options = options
|
|
49
|
-
this._storage = options.storage
|
|
55
|
+
this._storage = options.storage ? asStorageV2(options.storage) : undefined
|
|
50
56
|
}
|
|
51
57
|
|
|
52
58
|
private _storageKey (conversationId: string): string {
|
|
53
59
|
return `${STORAGE_KEY_PREFIX}${conversationId}`
|
|
54
60
|
}
|
|
55
61
|
|
|
56
|
-
private requireStorage ():
|
|
62
|
+
private requireStorage (): StorageV2 {
|
|
57
63
|
if (!this._storage) {
|
|
58
64
|
throw ExceptionHelper.generateException(Error, Errors.ProactiveStorageRequired)
|
|
59
65
|
}
|
|
60
66
|
return this._storage
|
|
61
67
|
}
|
|
62
68
|
|
|
63
|
-
private requireAppStorage ():
|
|
69
|
+
private requireAppStorage (): StorageV2 {
|
|
64
70
|
const storage = this._app.options.storage
|
|
65
71
|
if (!storage) {
|
|
66
72
|
throw ExceptionHelper.generateException(Error, Errors.ProactiveAppStorageRequired)
|
|
67
73
|
}
|
|
68
|
-
return storage
|
|
74
|
+
return asStorageV2(storage)
|
|
69
75
|
}
|
|
70
76
|
|
|
71
77
|
// ---------------------------------------------------------------------------
|
|
@@ -120,7 +126,8 @@ export class Proactive<TState extends TurnState> {
|
|
|
120
126
|
const key = this._storageKey(id)
|
|
121
127
|
record({ conversationId: id })
|
|
122
128
|
const linkedItem = await actions.link(storage, key)
|
|
123
|
-
await storage.write({ [key]: { ...linkedItem, reference: conv.reference, claims: conv.claims } })
|
|
129
|
+
const results = await storage.write({ [key]: { ...linkedItem, reference: conv.reference, claims: conv.claims } })
|
|
130
|
+
assertStorageWriteSucceeded(results, [key])
|
|
124
131
|
return id
|
|
125
132
|
})
|
|
126
133
|
}
|
|
@@ -142,7 +149,8 @@ export class Proactive<TState extends TurnState> {
|
|
|
142
149
|
return trace(ProactiveTraceDefinitions.getConversation, async ({ record }) => {
|
|
143
150
|
record({ conversationId })
|
|
144
151
|
const storageKey = this._storageKey(conversationId)
|
|
145
|
-
const
|
|
152
|
+
const results = await this.requireStorage().read<Conversation>([storageKey])
|
|
153
|
+
const stored = getStorageReadValue(results, storageKey)
|
|
146
154
|
if (!stored) {
|
|
147
155
|
record({ found: false })
|
|
148
156
|
return undefined
|
|
@@ -193,7 +201,9 @@ export class Proactive<TState extends TurnState> {
|
|
|
193
201
|
async deleteConversation (conversationId: string): Promise<void> {
|
|
194
202
|
return trace(ProactiveTraceDefinitions.deleteConversation, async ({ record }) => {
|
|
195
203
|
record({ conversationId })
|
|
196
|
-
|
|
204
|
+
const key = this._storageKey(conversationId)
|
|
205
|
+
const results = await this.requireStorage().delete([key])
|
|
206
|
+
assertStorageDeleteSucceeded(results, [key])
|
|
197
207
|
})
|
|
198
208
|
}
|
|
199
209
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
|
|
4
|
-
import type {
|
|
4
|
+
import type { StorageProvider } from '../../storage/storage'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Configuration for the proactive messaging subsystem.
|
|
@@ -14,7 +14,7 @@ export interface ProactiveOptions {
|
|
|
14
14
|
* A warning is logged when the fallback is used.
|
|
15
15
|
* Throws at initialization time if neither is configured.
|
|
16
16
|
*/
|
|
17
|
-
storage?:
|
|
17
|
+
storage?: StorageProvider
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* When `true` (default), `continueConversation()` throws if any requested
|