@microsoft/agents-hosting 0.2.10-g3ac88ff25e → 0.3.5
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 +17 -1
- package/dist/src/activityHandler.d.ts +304 -46
- package/dist/src/activityHandler.js +298 -45
- package/dist/src/activityHandler.js.map +1 -1
- package/dist/src/agent-client/agentClient.d.ts +50 -0
- package/dist/src/agent-client/agentClient.js +28 -0
- package/dist/src/agent-client/agentClient.js.map +1 -1
- package/dist/src/app/agentApplication.d.ts +272 -7
- package/dist/src/app/agentApplication.js +278 -12
- package/dist/src/app/agentApplication.js.map +1 -1
- package/dist/src/app/agentApplicationBuilder.d.ts +34 -3
- package/dist/src/app/agentApplicationBuilder.js +38 -6
- package/dist/src/app/agentApplicationBuilder.js.map +1 -1
- package/dist/src/app/agentApplicationOptions.d.ts +26 -2
- package/dist/src/app/appMemory.d.ts +34 -0
- package/dist/src/app/{memory.js → appMemory.js} +1 -1
- package/dist/src/app/appMemory.js.map +1 -0
- package/dist/src/app/appRoute.d.ts +6 -0
- package/dist/src/app/attachmentDownloader.d.ts +18 -0
- package/dist/src/app/attachmentDownloader.js +18 -0
- package/dist/src/app/attachmentDownloader.js.map +1 -1
- package/dist/src/app/conversationUpdateEvents.d.ts +6 -0
- package/dist/src/app/index.d.ts +4 -1
- package/dist/src/app/index.js +4 -1
- package/dist/src/app/index.js.map +1 -1
- package/dist/src/app/inputFileDownloader.d.ts +22 -0
- package/dist/src/app/oauth/authorization.d.ts +87 -0
- package/dist/src/app/oauth/authorization.js +135 -0
- package/dist/src/app/oauth/authorization.js.map +1 -0
- package/dist/src/app/routeHandler.d.ts +8 -0
- package/dist/src/app/routeSelector.d.ts +9 -0
- package/dist/src/app/turnEvents.d.ts +6 -0
- package/dist/src/app/turnState.d.ts +152 -2
- package/dist/src/app/turnState.js +125 -0
- package/dist/src/app/turnState.js.map +1 -1
- package/dist/src/app/turnStateEntry.d.ts +32 -0
- package/dist/src/app/turnStateEntry.js +32 -0
- package/dist/src/app/turnStateEntry.js.map +1 -1
- package/dist/src/auth/authConfiguration.d.ts +24 -0
- package/dist/src/auth/authConfiguration.js.map +1 -1
- package/dist/src/auth/request.d.ts +12 -0
- package/dist/src/baseAdapter.d.ts +17 -0
- package/dist/src/baseAdapter.js +17 -0
- package/dist/src/baseAdapter.js.map +1 -1
- package/dist/src/cards/cardFactory.d.ts +3 -0
- package/dist/src/cards/cardFactory.js +3 -0
- package/dist/src/cards/cardFactory.js.map +1 -1
- package/dist/src/cards/index.d.ts +1 -0
- package/dist/src/cards/index.js +1 -0
- package/dist/src/cards/index.js.map +1 -1
- package/dist/src/cards/o365ConnectorCardActionBase.d.ts +8 -0
- package/dist/src/cloudAdapter.d.ts +25 -3
- package/dist/src/cloudAdapter.js +25 -3
- package/dist/src/cloudAdapter.js.map +1 -1
- package/dist/src/getProductInfo.d.ts +6 -0
- package/dist/src/getProductInfo.js +6 -0
- package/dist/src/getProductInfo.js.map +1 -1
- package/dist/src/logger.d.ts +34 -2
- package/dist/src/logger.js +35 -0
- package/dist/src/logger.js.map +1 -1
- package/dist/src/oauth/oAuthFlow.d.ts +32 -3
- package/dist/src/oauth/oAuthFlow.js +38 -14
- package/dist/src/oauth/oAuthFlow.js.map +1 -1
- package/dist/src/oauth/userTokenClient.d.ts +2 -2
- package/dist/src/oauth/userTokenClient.js +3 -3
- package/dist/src/oauth/userTokenClient.js.map +1 -1
- package/dist/src/state/agentState.d.ts +79 -27
- package/dist/src/state/agentState.js +58 -27
- package/dist/src/state/agentState.js.map +1 -1
- package/dist/src/state/agentStatePropertyAccesor.d.ts +67 -11
- package/dist/src/state/agentStatePropertyAccesor.js +58 -11
- package/dist/src/state/agentStatePropertyAccesor.js.map +1 -1
- package/dist/src/statusCodes.d.ts +39 -0
- package/dist/src/statusCodes.js +39 -0
- package/dist/src/statusCodes.js.map +1 -1
- package/dist/src/storage/memoryStorage.d.ts +48 -14
- package/dist/src/storage/memoryStorage.js +48 -14
- package/dist/src/storage/memoryStorage.js.map +1 -1
- package/dist/src/storage/storage.d.ts +43 -13
- package/dist/src/tokenResponseEventName.d.ts +3 -0
- package/dist/src/tokenResponseEventName.js +3 -0
- package/dist/src/tokenResponseEventName.js.map +1 -1
- package/dist/src/turnContext.d.ts +142 -56
- package/dist/src/turnContext.js +123 -53
- package/dist/src/turnContext.js.map +1 -1
- package/package.json +6 -6
- package/src/activityHandler.ts +304 -46
- package/src/agent-client/agentClient.ts +55 -5
- package/src/app/agentApplication.ts +283 -15
- package/src/app/agentApplicationBuilder.ts +39 -7
- package/src/app/agentApplicationOptions.ts +33 -2
- package/src/app/appMemory.ts +38 -0
- package/src/app/appRoute.ts +7 -0
- package/src/app/attachmentDownloader.ts +18 -0
- package/src/app/conversationUpdateEvents.ts +6 -0
- package/src/app/index.ts +4 -1
- package/src/app/inputFileDownloader.ts +24 -0
- package/src/app/oauth/authorization.ts +162 -0
- package/src/app/routeHandler.ts +8 -0
- package/src/app/routeSelector.ts +9 -0
- package/src/app/turnEvents.ts +6 -0
- package/src/app/turnState.ts +153 -3
- package/src/app/turnStateEntry.ts +32 -0
- package/src/auth/authConfiguration.ts +32 -1
- package/src/auth/request.ts +15 -0
- package/src/baseAdapter.ts +18 -0
- package/src/cards/cardFactory.ts +3 -0
- package/src/cards/index.ts +1 -0
- package/src/cards/o365ConnectorCardActionBase.ts +8 -0
- package/src/cloudAdapter.ts +28 -3
- package/src/getProductInfo.ts +7 -0
- package/src/logger.ts +34 -1
- package/src/oauth/oAuthFlow.ts +59 -18
- package/src/oauth/userTokenClient.ts +4 -4
- package/src/state/agentState.ts +81 -29
- package/src/state/agentStatePropertyAccesor.ts +67 -11
- package/src/statusCodes.ts +51 -0
- package/src/storage/memoryStorage.ts +48 -14
- package/src/storage/storage.ts +51 -18
- package/src/tokenResponseEventName.ts +3 -0
- package/src/turnContext.ts +142 -56
- package/dist/src/app/memory.d.ts +0 -10
- package/dist/src/app/memory.js.map +0 -1
- package/dist/src/app/oauth/userIdentity.d.ts +0 -43
- package/dist/src/app/oauth/userIdentity.js +0 -54
- package/dist/src/app/oauth/userIdentity.js.map +0 -1
- package/src/app/memory.ts +0 -14
- package/src/app/oauth/userIdentity.ts +0 -78
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statusCodes.js","sourceRoot":"","sources":["../../src/statusCodes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,IAAY,
|
|
1
|
+
{"version":3,"file":"statusCodes.js","sourceRoot":"","sources":["../../src/statusCodes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,IAAY,WAiEX;AAjED,WAAY,WAAW;IACrB;;OAEG;IACH,2CAAQ,CAAA;IAER;;OAEG;IACH,qDAAa,CAAA;IAEb;;OAEG;IACH,uEAAsB,CAAA;IAEtB;;OAEG;IACH,6DAAiB,CAAA;IAEjB;;OAEG;IACH,+DAAkB,CAAA;IAElB;;OAEG;IACH,yDAAe,CAAA;IAEf;;OAEG;IACH,2EAAwB,CAAA;IAExB;;OAEG;IACH,uDAAc,CAAA;IAEd;;OAEG;IACH,6EAAyB,CAAA;IAEzB;;OAEG;IACH,uEAAsB,CAAA;IAEtB;;OAEG;IACH,iFAA2B,CAAA;IAE3B;;OAEG;IACH,qEAAqB,CAAA;IAErB;;OAEG;IACH,6DAAiB,CAAA;AACnB,CAAC,EAjEW,WAAW,2BAAX,WAAW,QAiEtB"}
|
|
@@ -4,47 +4,81 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { Storage, StoreItem } from './storage';
|
|
6
6
|
/**
|
|
7
|
-
* A simple in-memory storage provider.
|
|
7
|
+
* A simple in-memory storage provider that implements the Storage interface.
|
|
8
|
+
*
|
|
9
|
+
* This class provides a volatile storage solution that keeps data in memory,
|
|
10
|
+
* which means data is lost when the process terminates. It's primarily useful for:
|
|
11
|
+
* - Development and testing scenarios
|
|
12
|
+
* - Simple applications that don't require data persistence across restarts
|
|
13
|
+
* - Stateless environments where external storage isn't available
|
|
14
|
+
*
|
|
15
|
+
* MemoryStorage supports optimistic concurrency control through eTags and
|
|
16
|
+
* can be used as a singleton through the getSingleInstance() method to
|
|
17
|
+
* share state across different parts of an application.
|
|
8
18
|
*/
|
|
9
19
|
export declare class MemoryStorage implements Storage {
|
|
10
20
|
private memory;
|
|
11
21
|
private static instance;
|
|
22
|
+
/**
|
|
23
|
+
* Counter used to generate unique eTags for stored items
|
|
24
|
+
*/
|
|
12
25
|
private etag;
|
|
13
26
|
/**
|
|
14
27
|
* Creates a new instance of the MemoryStorage class.
|
|
15
|
-
*
|
|
28
|
+
*
|
|
29
|
+
* @param memory An optional initial memory store to seed the storage with data
|
|
16
30
|
*/
|
|
17
31
|
constructor(memory?: {
|
|
18
32
|
[k: string]: string;
|
|
19
33
|
});
|
|
20
34
|
/**
|
|
21
|
-
* Gets a single instance of the MemoryStorage class.
|
|
35
|
+
* Gets a single shared instance of the MemoryStorage class.
|
|
36
|
+
*
|
|
37
|
+
* Using this method ensures that the same storage instance is used across
|
|
38
|
+
* the application, allowing for shared state without passing references.
|
|
39
|
+
*
|
|
40
|
+
* @returns The singleton instance of MemoryStorage
|
|
22
41
|
*/
|
|
23
42
|
static getSingleInstance(): MemoryStorage;
|
|
24
43
|
/**
|
|
25
44
|
* Reads storage items from memory.
|
|
26
|
-
*
|
|
27
|
-
* @
|
|
28
|
-
* @
|
|
45
|
+
*
|
|
46
|
+
* @param keys The keys of the items to read
|
|
47
|
+
* @returns A promise that resolves to the read items
|
|
48
|
+
* @throws Will throw an error if keys are not provided or the array is empty
|
|
29
49
|
*/
|
|
30
50
|
read(keys: string[]): Promise<StoreItem>;
|
|
31
51
|
/**
|
|
32
52
|
* Writes storage items to memory.
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
53
|
+
*
|
|
54
|
+
* This method supports optimistic concurrency control through eTags.
|
|
55
|
+
* If an item has an eTag, it will only be updated if the existing item
|
|
56
|
+
* has the same eTag. If an item has an eTag of '*' or no eTag, it will
|
|
57
|
+
* always be written regardless of the current state.
|
|
58
|
+
*
|
|
59
|
+
* @param changes The items to write, indexed by key
|
|
60
|
+
* @returns A promise that resolves when the write operation is complete
|
|
61
|
+
* @throws Will throw an error if changes are not provided or if there's an eTag conflict
|
|
36
62
|
*/
|
|
37
63
|
write(changes: StoreItem): Promise<void>;
|
|
38
64
|
/**
|
|
39
65
|
* Deletes storage items from memory.
|
|
40
|
-
*
|
|
41
|
-
* @
|
|
66
|
+
*
|
|
67
|
+
* @param keys The keys of the items to delete
|
|
68
|
+
* @returns A promise that resolves when the delete operation is complete
|
|
42
69
|
*/
|
|
43
70
|
delete(keys: string[]): Promise<void>;
|
|
44
71
|
/**
|
|
45
|
-
* Saves an item to memory.
|
|
46
|
-
*
|
|
47
|
-
*
|
|
72
|
+
* Saves an item to memory with a new eTag.
|
|
73
|
+
*
|
|
74
|
+
* This private method handles the details of:
|
|
75
|
+
* - Creating a clone of the item to prevent modification of the original
|
|
76
|
+
* - Generating a new eTag for optimistic concurrency control
|
|
77
|
+
* - Converting the item to a JSON string for storage
|
|
78
|
+
*
|
|
79
|
+
* @param key The key of the item to save
|
|
80
|
+
* @param item The item to save
|
|
81
|
+
* @private
|
|
48
82
|
*/
|
|
49
83
|
private saveItem;
|
|
50
84
|
}
|
|
@@ -8,19 +8,38 @@ exports.MemoryStorage = void 0;
|
|
|
8
8
|
const logger_1 = require("../logger");
|
|
9
9
|
const logger = (0, logger_1.debug)('agents:memory-storage');
|
|
10
10
|
/**
|
|
11
|
-
* A simple in-memory storage provider.
|
|
11
|
+
* A simple in-memory storage provider that implements the Storage interface.
|
|
12
|
+
*
|
|
13
|
+
* This class provides a volatile storage solution that keeps data in memory,
|
|
14
|
+
* which means data is lost when the process terminates. It's primarily useful for:
|
|
15
|
+
* - Development and testing scenarios
|
|
16
|
+
* - Simple applications that don't require data persistence across restarts
|
|
17
|
+
* - Stateless environments where external storage isn't available
|
|
18
|
+
*
|
|
19
|
+
* MemoryStorage supports optimistic concurrency control through eTags and
|
|
20
|
+
* can be used as a singleton through the getSingleInstance() method to
|
|
21
|
+
* share state across different parts of an application.
|
|
12
22
|
*/
|
|
13
23
|
class MemoryStorage {
|
|
14
24
|
/**
|
|
15
25
|
* Creates a new instance of the MemoryStorage class.
|
|
16
|
-
*
|
|
26
|
+
*
|
|
27
|
+
* @param memory An optional initial memory store to seed the storage with data
|
|
17
28
|
*/
|
|
18
29
|
constructor(memory = {}) {
|
|
19
30
|
this.memory = memory;
|
|
31
|
+
/**
|
|
32
|
+
* Counter used to generate unique eTags for stored items
|
|
33
|
+
*/
|
|
20
34
|
this.etag = 1;
|
|
21
35
|
}
|
|
22
36
|
/**
|
|
23
|
-
* Gets a single instance of the MemoryStorage class.
|
|
37
|
+
* Gets a single shared instance of the MemoryStorage class.
|
|
38
|
+
*
|
|
39
|
+
* Using this method ensures that the same storage instance is used across
|
|
40
|
+
* the application, allowing for shared state without passing references.
|
|
41
|
+
*
|
|
42
|
+
* @returns The singleton instance of MemoryStorage
|
|
24
43
|
*/
|
|
25
44
|
static getSingleInstance() {
|
|
26
45
|
if (!MemoryStorage.instance) {
|
|
@@ -30,9 +49,10 @@ class MemoryStorage {
|
|
|
30
49
|
}
|
|
31
50
|
/**
|
|
32
51
|
* Reads storage items from memory.
|
|
33
|
-
*
|
|
34
|
-
* @
|
|
35
|
-
* @
|
|
52
|
+
*
|
|
53
|
+
* @param keys The keys of the items to read
|
|
54
|
+
* @returns A promise that resolves to the read items
|
|
55
|
+
* @throws Will throw an error if keys are not provided or the array is empty
|
|
36
56
|
*/
|
|
37
57
|
async read(keys) {
|
|
38
58
|
if (!keys || keys.length === 0) {
|
|
@@ -50,9 +70,15 @@ class MemoryStorage {
|
|
|
50
70
|
}
|
|
51
71
|
/**
|
|
52
72
|
* Writes storage items to memory.
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
73
|
+
*
|
|
74
|
+
* This method supports optimistic concurrency control through eTags.
|
|
75
|
+
* If an item has an eTag, it will only be updated if the existing item
|
|
76
|
+
* has the same eTag. If an item has an eTag of '*' or no eTag, it will
|
|
77
|
+
* always be written regardless of the current state.
|
|
78
|
+
*
|
|
79
|
+
* @param changes The items to write, indexed by key
|
|
80
|
+
* @returns A promise that resolves when the write operation is complete
|
|
81
|
+
* @throws Will throw an error if changes are not provided or if there's an eTag conflict
|
|
56
82
|
*/
|
|
57
83
|
async write(changes) {
|
|
58
84
|
if (!changes || changes.length === 0) {
|
|
@@ -77,8 +103,9 @@ class MemoryStorage {
|
|
|
77
103
|
}
|
|
78
104
|
/**
|
|
79
105
|
* Deletes storage items from memory.
|
|
80
|
-
*
|
|
81
|
-
* @
|
|
106
|
+
*
|
|
107
|
+
* @param keys The keys of the items to delete
|
|
108
|
+
* @returns A promise that resolves when the delete operation is complete
|
|
82
109
|
*/
|
|
83
110
|
async delete(keys) {
|
|
84
111
|
logger.info(`Deleting keys: ${keys.join(', ')}`);
|
|
@@ -87,9 +114,16 @@ class MemoryStorage {
|
|
|
87
114
|
}
|
|
88
115
|
}
|
|
89
116
|
/**
|
|
90
|
-
* Saves an item to memory.
|
|
91
|
-
*
|
|
92
|
-
*
|
|
117
|
+
* Saves an item to memory with a new eTag.
|
|
118
|
+
*
|
|
119
|
+
* This private method handles the details of:
|
|
120
|
+
* - Creating a clone of the item to prevent modification of the original
|
|
121
|
+
* - Generating a new eTag for optimistic concurrency control
|
|
122
|
+
* - Converting the item to a JSON string for storage
|
|
123
|
+
*
|
|
124
|
+
* @param key The key of the item to save
|
|
125
|
+
* @param item The item to save
|
|
126
|
+
* @private
|
|
93
127
|
*/
|
|
94
128
|
saveItem(key, item) {
|
|
95
129
|
const clone = Object.assign({}, item, { eTag: (this.etag++).toString() });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memoryStorage.js","sourceRoot":"","sources":["../../../src/storage/memoryStorage.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,sCAAiC;AAEjC,MAAM,MAAM,GA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Aa;QAC1C,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;QACzE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IAC1C,CAAC;CACF;AAnHD,sCAmHC"}
|
|
@@ -4,44 +4,74 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { TurnContext } from '../turnContext';
|
|
6
6
|
/**
|
|
7
|
-
* Represents an item to be stored.
|
|
7
|
+
* Represents an item to be stored in a storage provider.
|
|
8
|
+
* Each item can contain arbitrary data along with an optional eTag for optimistic concurrency control.
|
|
8
9
|
*/
|
|
9
10
|
export interface StoreItem {
|
|
11
|
+
/**
|
|
12
|
+
* Optional eTag used for optimistic concurrency control.
|
|
13
|
+
* When set to '*', it indicates that the write should proceed regardless of existing data.
|
|
14
|
+
* When comparing eTags, exact string matching is used to determine if data has changed.
|
|
15
|
+
*/
|
|
10
16
|
eTag?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Additional properties can be stored in the item.
|
|
19
|
+
* Each storage provider may have specific requirements or limitations on property names and values.
|
|
20
|
+
*/
|
|
11
21
|
[key: string]: any;
|
|
12
22
|
}
|
|
13
23
|
/**
|
|
14
|
-
* Represents a collection of store items.
|
|
24
|
+
* Represents a collection of store items indexed by key.
|
|
25
|
+
* Used as the return type for storage read operations.
|
|
15
26
|
*/
|
|
16
27
|
export interface StoreItems {
|
|
28
|
+
/**
|
|
29
|
+
* Keys are the storage item identifiers, and values are the stored items.
|
|
30
|
+
* If a requested key is not found during a read operation, it will not appear in this collection.
|
|
31
|
+
*/
|
|
17
32
|
[key: string]: any;
|
|
18
33
|
}
|
|
19
34
|
/**
|
|
20
|
-
* A factory function to generate storage keys based on the context.
|
|
21
|
-
*
|
|
22
|
-
*
|
|
35
|
+
* A factory function to generate storage keys based on the conversation context.
|
|
36
|
+
* Allows different storage strategies based on the conversation state.
|
|
37
|
+
*
|
|
38
|
+
* @param context The TurnContext for the current turn of conversation
|
|
39
|
+
* @returns A string key for storage that uniquely identifies where to store the data
|
|
23
40
|
*/
|
|
24
|
-
export type StorageKeyFactory = (context: TurnContext) => string
|
|
41
|
+
export type StorageKeyFactory = (context: TurnContext) => string | Promise<string>;
|
|
25
42
|
/**
|
|
26
|
-
* Defines the interface for storage operations.
|
|
43
|
+
* Defines the interface for storage operations in the Agents platform.
|
|
44
|
+
*
|
|
45
|
+
* Storage providers persist state data across conversation turns, enabling
|
|
46
|
+
* agents to maintain context over time. Different implementations may store
|
|
47
|
+
* data in memory, databases, blob storage, or other persistence mechanisms.
|
|
48
|
+
*
|
|
49
|
+
* The interface is designed to be simple with just three core operations:
|
|
50
|
+
* read, write, and delete. All operations are asynchronous to support both
|
|
51
|
+
* in-memory and remote storage providers.
|
|
27
52
|
*/
|
|
28
53
|
export interface Storage {
|
|
29
54
|
/**
|
|
30
55
|
* Reads store items from storage.
|
|
31
|
-
*
|
|
32
|
-
* @
|
|
56
|
+
*
|
|
57
|
+
* @param keys The keys of the items to read
|
|
58
|
+
* @returns A promise that resolves to the store items. Items that don't exist in storage will not be included in the result.
|
|
59
|
+
* @throws If the keys array is empty or undefined
|
|
33
60
|
*/
|
|
34
61
|
read: (keys: string[]) => Promise<StoreItem>;
|
|
35
62
|
/**
|
|
36
63
|
* Writes store items to storage.
|
|
37
|
-
*
|
|
38
|
-
* @
|
|
64
|
+
*
|
|
65
|
+
* @param changes The items to write to storage, indexed by key
|
|
66
|
+
* @returns A promise that resolves when the write operation is complete
|
|
67
|
+
* @throws If the changes object is empty or undefined, or if an eTag conflict occurs and optimistic concurrency is enabled
|
|
39
68
|
*/
|
|
40
69
|
write: (changes: StoreItem) => Promise<void>;
|
|
41
70
|
/**
|
|
42
71
|
* Deletes store items from storage.
|
|
43
|
-
*
|
|
44
|
-
* @
|
|
72
|
+
*
|
|
73
|
+
* @param keys The keys of the items to delete
|
|
74
|
+
* @returns A promise that resolves when the delete operation is complete
|
|
45
75
|
*/
|
|
46
76
|
delete: (keys: string[]) => Promise<void>;
|
|
47
77
|
}
|
|
@@ -5,5 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.tokenResponseEventName = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* The event name used for token response activities.
|
|
10
|
+
*/
|
|
8
11
|
exports.tokenResponseEventName = 'tokens/response';
|
|
9
12
|
//# sourceMappingURL=tokenResponseEventName.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokenResponseEventName.js","sourceRoot":"","sources":["../../src/tokenResponseEventName.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;
|
|
1
|
+
{"version":3,"file":"tokenResponseEventName.js","sourceRoot":"","sources":["../../src/tokenResponseEventName.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;GAEG;AACU,QAAA,sBAAsB,GAAG,iBAAiB,CAAA"}
|
|
@@ -5,19 +5,34 @@ import { TurnContextStateCollection } from './turnContextStateCollection';
|
|
|
5
5
|
import { AttachmentInfo } from './connector-client/attachmentInfo';
|
|
6
6
|
import { AttachmentData } from './connector-client/attachmentData';
|
|
7
7
|
/**
|
|
8
|
-
* Defines a handler for sending activities.
|
|
8
|
+
* Defines a handler for processing and sending activities.
|
|
9
|
+
* Used for middleware that needs to intercept or modify activities being sent.
|
|
10
|
+
*
|
|
11
|
+
* @param context The current turn context
|
|
12
|
+
* @param activities The activities being sent
|
|
13
|
+
* @param next Function to call to continue the middleware chain
|
|
9
14
|
*/
|
|
10
15
|
export type SendActivitiesHandler = (context: TurnContext, activities: Activity[], next: () => Promise<ResourceResponse[]>) => Promise<ResourceResponse[]>;
|
|
11
16
|
/**
|
|
12
17
|
* Defines a handler for updating an activity.
|
|
18
|
+
* Used for middleware that needs to intercept or modify activity updates.
|
|
19
|
+
*
|
|
20
|
+
* @param context The current turn context
|
|
21
|
+
* @param activity The activity being updated
|
|
22
|
+
* @param next Function to call to continue the middleware chain
|
|
13
23
|
*/
|
|
14
24
|
export type UpdateActivityHandler = (context: TurnContext, activity: Activity, next: () => Promise<void>) => Promise<void>;
|
|
15
25
|
/**
|
|
16
26
|
* Defines a handler for deleting an activity.
|
|
27
|
+
* Used for middleware that needs to intercept or handle activity deletions.
|
|
28
|
+
*
|
|
29
|
+
* @param context The current turn context
|
|
30
|
+
* @param reference Reference to the activity being deleted
|
|
31
|
+
* @param next Function to call to continue the middleware chain
|
|
17
32
|
*/
|
|
18
33
|
export type DeleteActivityHandler = (context: TurnContext, reference: ConversationReference, next: () => Promise<void>) => Promise<void>;
|
|
19
34
|
/**
|
|
20
|
-
* Key for the agent callback handler.
|
|
35
|
+
* Key for the agent callback handler in TurnState collection.
|
|
21
36
|
*/
|
|
22
37
|
export declare const AgentCallbackHandlerKey = "agentCallbackHandler";
|
|
23
38
|
/**
|
|
@@ -26,7 +41,20 @@ export declare const AgentCallbackHandlerKey = "agentCallbackHandler";
|
|
|
26
41
|
export interface TurnContext {
|
|
27
42
|
}
|
|
28
43
|
/**
|
|
29
|
-
* Represents the context
|
|
44
|
+
* Represents the context for a single turn in a conversation between a user and an agent.
|
|
45
|
+
*
|
|
46
|
+
* TurnContext is a central concept in the Agents framework - it contains:
|
|
47
|
+
* - The incoming activity that started the turn
|
|
48
|
+
* - Access to the adapter that can be used to send responses
|
|
49
|
+
* - A state collection for storing information during the turn
|
|
50
|
+
* - Methods for sending, updating, and deleting activities
|
|
51
|
+
* - Middleware hooks for intercepting activity operations
|
|
52
|
+
*
|
|
53
|
+
* The TurnContext object is created by the adapter when an activity is received
|
|
54
|
+
* and is passed to the agent's logic to process the turn. It maintains information
|
|
55
|
+
* about the conversation and provides methods to send responses.
|
|
56
|
+
*
|
|
57
|
+
* This class follows the builder pattern for registering middleware handlers.
|
|
30
58
|
*/
|
|
31
59
|
export declare class TurnContext {
|
|
32
60
|
private readonly _adapter?;
|
|
@@ -40,121 +68,179 @@ export declare class TurnContext {
|
|
|
40
68
|
private readonly _locale;
|
|
41
69
|
/**
|
|
42
70
|
* Initializes a new instance of the TurnContext class.
|
|
43
|
-
*
|
|
44
|
-
* @param
|
|
71
|
+
*
|
|
72
|
+
* @param adapterOrContext The adapter that created this context, or another TurnContext to clone
|
|
73
|
+
* @param request The activity for the turn (required when first parameter is an adapter)
|
|
45
74
|
*/
|
|
46
75
|
constructor(adapterOrContext: BaseAdapter, request: Activity);
|
|
47
76
|
constructor(adapterOrContext: TurnContext);
|
|
48
77
|
/**
|
|
49
|
-
* A list of buffered
|
|
78
|
+
* A list of reply activities that are buffered until the end of the turn.
|
|
79
|
+
*
|
|
80
|
+
* This is primarily used with the 'expectReplies' delivery mode where all
|
|
81
|
+
* activities during a turn are collected and returned as a single response.
|
|
50
82
|
*/
|
|
51
83
|
readonly bufferedReplyActivities: Activity[];
|
|
52
84
|
/**
|
|
53
|
-
* Sends a trace activity.
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* @
|
|
85
|
+
* Sends a trace activity for debugging purposes.
|
|
86
|
+
*
|
|
87
|
+
* Trace activities are typically used for debugging and are only visible in
|
|
88
|
+
* channels that support them, like the Bot Framework Emulator.
|
|
89
|
+
*
|
|
90
|
+
* @param name The name/category of the trace
|
|
91
|
+
* @param value The value/data to include in the trace
|
|
92
|
+
* @param valueType Optional type name for the value
|
|
93
|
+
* @param label Optional descriptive label for the trace
|
|
94
|
+
* @returns A promise that resolves to the resource response or undefined
|
|
59
95
|
*/
|
|
60
96
|
sendTraceActivity(name: string, value?: any, valueType?: string, label?: string): Promise<ResourceResponse | undefined>;
|
|
61
97
|
/**
|
|
62
|
-
* Sends an activity.
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
98
|
+
* Sends an activity to the sender of the incoming activity.
|
|
99
|
+
*
|
|
100
|
+
* This is the primary method used to respond to the user. It automatically
|
|
101
|
+
* addresses the response to the correct conversation and recipient using
|
|
102
|
+
* information from the incoming activity.
|
|
103
|
+
*
|
|
104
|
+
* @param activityOrText The activity to send or a string for a simple message
|
|
105
|
+
* @param speak Optional text to be spoken by the agent
|
|
106
|
+
* @param inputHint Optional input hint to indicate if the agent is expecting input
|
|
107
|
+
* @returns A promise that resolves to the resource response or undefined
|
|
67
108
|
*/
|
|
68
109
|
sendActivity(activityOrText: string | Activity, speak?: string, inputHint?: string): Promise<ResourceResponse | undefined>;
|
|
69
110
|
/**
|
|
70
|
-
* Sends multiple activities.
|
|
71
|
-
*
|
|
72
|
-
*
|
|
111
|
+
* Sends multiple activities to the sender of the incoming activity.
|
|
112
|
+
*
|
|
113
|
+
* This method applies conversation references to each activity and
|
|
114
|
+
* emits them through the middleware chain before sending them to
|
|
115
|
+
* the adapter.
|
|
116
|
+
*
|
|
117
|
+
* @param activities The array of activities to send
|
|
118
|
+
* @returns A promise that resolves to an array of resource responses
|
|
73
119
|
*/
|
|
74
120
|
sendActivities(activities: Activity[]): Promise<ResourceResponse[]>;
|
|
75
121
|
/**
|
|
76
|
-
* Updates an activity.
|
|
77
|
-
*
|
|
78
|
-
*
|
|
122
|
+
* Updates an existing activity in the conversation.
|
|
123
|
+
*
|
|
124
|
+
* This can be used to edit previously sent activities, for example to
|
|
125
|
+
* update the content of an adaptive card or change a message.
|
|
126
|
+
*
|
|
127
|
+
* @param activity The activity to update with its ID specified
|
|
128
|
+
* @returns A promise that resolves when the activity has been updated
|
|
79
129
|
*/
|
|
80
130
|
updateActivity(activity: Activity): Promise<void>;
|
|
81
131
|
/**
|
|
82
|
-
* Deletes an activity.
|
|
83
|
-
*
|
|
84
|
-
* @
|
|
132
|
+
* Deletes an activity from the conversation.
|
|
133
|
+
*
|
|
134
|
+
* @param idOrReference The ID of the activity to delete or a conversation reference
|
|
135
|
+
* @returns A promise that resolves when the activity has been deleted
|
|
85
136
|
*/
|
|
86
137
|
deleteActivity(idOrReference: string | ConversationReference): Promise<void>;
|
|
87
138
|
/**
|
|
88
|
-
* Uploads an attachment.
|
|
89
|
-
*
|
|
90
|
-
* @param
|
|
91
|
-
* @
|
|
139
|
+
* Uploads an attachment to the conversation.
|
|
140
|
+
*
|
|
141
|
+
* @param conversationId The ID of the conversation
|
|
142
|
+
* @param attachmentData The attachment data to upload
|
|
143
|
+
* @returns A promise that resolves to the resource response
|
|
92
144
|
*/
|
|
93
145
|
uploadAttachment(conversationId: string, attachmentData: AttachmentData): Promise<ResourceResponse>;
|
|
94
146
|
/**
|
|
95
|
-
* Gets attachment
|
|
96
|
-
*
|
|
97
|
-
* @
|
|
147
|
+
* Gets information about an attachment.
|
|
148
|
+
*
|
|
149
|
+
* @param attachmentId The ID of the attachment
|
|
150
|
+
* @returns A promise that resolves to the attachment information
|
|
98
151
|
*/
|
|
99
152
|
getAttachmentInfo(attachmentId: string): Promise<AttachmentInfo>;
|
|
100
153
|
/**
|
|
101
|
-
* Gets an attachment.
|
|
102
|
-
*
|
|
103
|
-
* @param
|
|
104
|
-
* @
|
|
154
|
+
* Gets the content of an attachment.
|
|
155
|
+
*
|
|
156
|
+
* @param attachmentId The ID of the attachment
|
|
157
|
+
* @param viewId The view to get
|
|
158
|
+
* @returns A promise that resolves to a readable stream of the attachment content
|
|
105
159
|
*/
|
|
106
160
|
getAttachment(attachmentId: string, viewId: string): Promise<NodeJS.ReadableStream>;
|
|
107
161
|
/**
|
|
108
|
-
* Registers a handler for
|
|
109
|
-
*
|
|
110
|
-
*
|
|
162
|
+
* Registers a handler for intercepting and processing activities being sent.
|
|
163
|
+
*
|
|
164
|
+
* This method follows a middleware pattern, allowing multiple handlers to
|
|
165
|
+
* be chained together. Handlers can modify activities or inject new ones.
|
|
166
|
+
*
|
|
167
|
+
* @param handler The handler to register
|
|
168
|
+
* @returns The current TurnContext instance for chaining
|
|
111
169
|
*/
|
|
112
170
|
onSendActivities(handler: SendActivitiesHandler): this;
|
|
113
171
|
/**
|
|
114
|
-
* Registers a handler for
|
|
115
|
-
*
|
|
116
|
-
* @
|
|
172
|
+
* Registers a handler for intercepting activity updates.
|
|
173
|
+
*
|
|
174
|
+
* @param handler The handler to register
|
|
175
|
+
* @returns The current TurnContext instance for chaining
|
|
117
176
|
*/
|
|
118
177
|
onUpdateActivity(handler: UpdateActivityHandler): this;
|
|
119
178
|
/**
|
|
120
|
-
* Registers a handler for
|
|
121
|
-
*
|
|
122
|
-
* @
|
|
179
|
+
* Registers a handler for intercepting activity deletions.
|
|
180
|
+
*
|
|
181
|
+
* @param handler The handler to register
|
|
182
|
+
* @returns The current TurnContext instance for chaining
|
|
123
183
|
*/
|
|
124
184
|
onDeleteActivity(handler: DeleteActivityHandler): this;
|
|
125
185
|
/**
|
|
126
186
|
* Copies the properties of this TurnContext to another TurnContext.
|
|
127
|
-
*
|
|
187
|
+
*
|
|
188
|
+
* Used internally when cloning contexts.
|
|
189
|
+
*
|
|
190
|
+
* @param context The context to copy to
|
|
191
|
+
* @protected
|
|
128
192
|
*/
|
|
129
193
|
protected copyTo(context: TurnContext): void;
|
|
130
194
|
/**
|
|
131
|
-
* Gets the adapter
|
|
195
|
+
* Gets the adapter that created this context.
|
|
196
|
+
*
|
|
197
|
+
* The adapter is responsible for sending and receiving activities
|
|
198
|
+
* to and from the user's channel.
|
|
132
199
|
*/
|
|
133
200
|
get adapter(): BaseAdapter;
|
|
134
201
|
/**
|
|
135
|
-
* Gets the activity
|
|
202
|
+
* Gets the incoming activity that started this turn.
|
|
203
|
+
*
|
|
204
|
+
* This is the activity that was received from the user or channel
|
|
205
|
+
* and triggered the creation of this context.
|
|
136
206
|
*/
|
|
137
207
|
get activity(): Activity;
|
|
138
208
|
/**
|
|
139
|
-
* Gets or sets whether the turn has
|
|
209
|
+
* Gets or sets whether the turn has sent a response to the user.
|
|
210
|
+
*
|
|
211
|
+
* This is used to track whether the agent has responded to the user's
|
|
212
|
+
* activity. Once set to true, it cannot be set back to false.
|
|
140
213
|
*/
|
|
141
214
|
get responded(): boolean;
|
|
142
215
|
set responded(value: boolean);
|
|
143
216
|
/**
|
|
144
217
|
* Gets or sets the locale for the turn.
|
|
218
|
+
*
|
|
219
|
+
* The locale affects language-dependent operations like
|
|
220
|
+
* formatting dates or numbers.
|
|
145
221
|
*/
|
|
146
222
|
get locale(): string | undefined;
|
|
147
223
|
set locale(value: string | undefined);
|
|
148
224
|
/**
|
|
149
|
-
* Gets the turn state collection.
|
|
225
|
+
* Gets the turn state collection for storing data during the turn.
|
|
226
|
+
*
|
|
227
|
+
* The turn state collection provides a dictionary-like interface
|
|
228
|
+
* for storing arbitrary data that needs to be accessible during
|
|
229
|
+
* the processing of the current turn.
|
|
150
230
|
*/
|
|
151
231
|
get turnState(): TurnContextStateCollection;
|
|
152
232
|
/**
|
|
153
|
-
* Emits events to
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
233
|
+
* Emits events to registered middleware handlers.
|
|
234
|
+
*
|
|
235
|
+
* This internal method implements the middleware pattern, allowing
|
|
236
|
+
* handlers to be chained together with each having the option to
|
|
237
|
+
* short-circuit the chain.
|
|
238
|
+
*
|
|
239
|
+
* @param handlers Array of handlers to execute
|
|
240
|
+
* @param arg The argument to pass to each handler
|
|
241
|
+
* @param next The function to execute at the end of the middleware chain
|
|
242
|
+
* @returns A promise that resolves to the result from the handlers or next function
|
|
243
|
+
* @private
|
|
158
244
|
*/
|
|
159
245
|
private emit;
|
|
160
246
|
}
|