@microsoft/agents-hosting 0.2.10-g3ac88ff25e → 0.2.14

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.
Files changed (70) hide show
  1. package/dist/src/activityHandler.d.ts +304 -46
  2. package/dist/src/activityHandler.js +298 -45
  3. package/dist/src/activityHandler.js.map +1 -1
  4. package/dist/src/agent-client/agentClient.d.ts +50 -0
  5. package/dist/src/agent-client/agentClient.js +28 -0
  6. package/dist/src/agent-client/agentClient.js.map +1 -1
  7. package/dist/src/app/agentApplication.d.ts +256 -3
  8. package/dist/src/app/agentApplication.js +256 -0
  9. package/dist/src/app/agentApplication.js.map +1 -1
  10. package/dist/src/app/agentApplicationBuilder.d.ts +32 -0
  11. package/dist/src/app/agentApplicationBuilder.js +32 -0
  12. package/dist/src/app/agentApplicationBuilder.js.map +1 -1
  13. package/dist/src/app/appMemory.d.ts +34 -0
  14. package/dist/src/app/{memory.js → appMemory.js} +1 -1
  15. package/dist/src/app/appMemory.js.map +1 -0
  16. package/dist/src/app/index.d.ts +3 -0
  17. package/dist/src/app/index.js +3 -0
  18. package/dist/src/app/index.js.map +1 -1
  19. package/dist/src/app/turnEvents.d.ts +6 -0
  20. package/dist/src/app/turnState.d.ts +2 -2
  21. package/dist/src/app/turnStateEntry.d.ts +32 -0
  22. package/dist/src/app/turnStateEntry.js +32 -0
  23. package/dist/src/app/turnStateEntry.js.map +1 -1
  24. package/dist/src/cards/index.d.ts +1 -0
  25. package/dist/src/cards/index.js +1 -0
  26. package/dist/src/cards/index.js.map +1 -1
  27. package/dist/src/cloudAdapter.d.ts +25 -3
  28. package/dist/src/cloudAdapter.js +25 -3
  29. package/dist/src/cloudAdapter.js.map +1 -1
  30. package/dist/src/getProductInfo.d.ts +6 -0
  31. package/dist/src/getProductInfo.js +6 -0
  32. package/dist/src/getProductInfo.js.map +1 -1
  33. package/dist/src/logger.d.ts +34 -2
  34. package/dist/src/logger.js +35 -0
  35. package/dist/src/logger.js.map +1 -1
  36. package/dist/src/state/agentState.d.ts +79 -27
  37. package/dist/src/state/agentState.js +58 -27
  38. package/dist/src/state/agentState.js.map +1 -1
  39. package/dist/src/state/agentStatePropertyAccesor.d.ts +67 -11
  40. package/dist/src/state/agentStatePropertyAccesor.js +58 -11
  41. package/dist/src/state/agentStatePropertyAccesor.js.map +1 -1
  42. package/dist/src/storage/memoryStorage.d.ts +48 -14
  43. package/dist/src/storage/memoryStorage.js +48 -14
  44. package/dist/src/storage/memoryStorage.js.map +1 -1
  45. package/dist/src/storage/storage.d.ts +43 -13
  46. package/dist/src/turnContext.d.ts +142 -56
  47. package/dist/src/turnContext.js +123 -53
  48. package/dist/src/turnContext.js.map +1 -1
  49. package/package.json +5 -5
  50. package/src/activityHandler.ts +304 -46
  51. package/src/agent-client/agentClient.ts +55 -5
  52. package/src/app/agentApplication.ts +259 -2
  53. package/src/app/agentApplicationBuilder.ts +32 -0
  54. package/src/app/appMemory.ts +38 -0
  55. package/src/app/index.ts +3 -0
  56. package/src/app/turnEvents.ts +6 -0
  57. package/src/app/turnState.ts +2 -2
  58. package/src/app/turnStateEntry.ts +32 -0
  59. package/src/cards/index.ts +1 -0
  60. package/src/cloudAdapter.ts +28 -3
  61. package/src/getProductInfo.ts +7 -0
  62. package/src/logger.ts +34 -1
  63. package/src/state/agentState.ts +81 -29
  64. package/src/state/agentStatePropertyAccesor.ts +67 -11
  65. package/src/storage/memoryStorage.ts +48 -14
  66. package/src/storage/storage.ts +51 -18
  67. package/src/turnContext.ts +142 -56
  68. package/dist/src/app/memory.d.ts +0 -10
  69. package/dist/src/app/memory.js.map +0 -1
  70. package/src/app/memory.ts +0 -14
@@ -6,103 +6,361 @@ import { SearchInvokeResponse } from './invoke/searchInvokeResponse';
6
6
  import { AdaptiveCardInvokeResponse } from './invoke/adaptiveCardInvokeResponse';
7
7
  /** Symbol key for invoke response */
8
8
  export declare const INVOKE_RESPONSE_KEY: unique symbol;
9
- /** Type definition for agent handler function */
9
+ /**
10
+ * Type definition for agent handler function
11
+ * @param context - The turn context for the current turn of conversation
12
+ * @param next - The function to call to continue to the next middleware or handler
13
+ * @returns A promise representing the asynchronous operation
14
+ */
10
15
  export type AgentHandler = (context: TurnContext, next: () => Promise<void>) => Promise<any>;
11
- /** * Handles various activity types and dispatches them to the appropriate handlers. */
16
+ /**
17
+ * Handles incoming activities from channels and dispatches them to the appropriate handlers.
18
+ *
19
+ * The ActivityHandler provides a foundation for handling different types of activities
20
+ * in an agent application. It processes various activity types such as messages, conversation updates,
21
+ * message reactions, etc., and routes them to the appropriate handler methods.
22
+ *
23
+ * Developers can extend this class to implement custom handlers for specific activity types
24
+ * or override existing ones to customize the behavior.
25
+ */
12
26
  export declare class ActivityHandler {
27
+ /**
28
+ * Collection of handlers registered for different activity types
29
+ * @protected
30
+ */
13
31
  protected readonly handlers: {
14
32
  [type: string]: AgentHandler[];
15
33
  };
16
- /** * Registers a handler for the Turn activity type. */
34
+ /**
35
+ * Registers a handler for the Turn activity type.
36
+ * This is called for all activities regardless of type.
37
+ * @param handler - The handler to register
38
+ * @returns The current instance for method chaining
39
+ */
17
40
  onTurn(handler: AgentHandler): this;
18
- /** * Registers a handler for the MembersAdded activity type. */
41
+ /**
42
+ * Registers a handler for the MembersAdded activity type.
43
+ * This is called when new members are added to the conversation.
44
+ * @param handler - The handler to register
45
+ * @returns The current instance for method chaining
46
+ */
19
47
  onMembersAdded(handler: AgentHandler): this;
20
- /** * Registers a handler for the MembersRemoved activity type. */
48
+ /**
49
+ * Registers a handler for the MembersRemoved activity type.
50
+ * This is called when members are removed from the conversation.
51
+ * @param handler - The handler to register
52
+ * @returns The current instance for method chaining
53
+ */
21
54
  onMembersRemoved(handler: AgentHandler): this;
22
- /** * Registers a handler for the Message activity type. */
55
+ /**
56
+ * Registers a handler for the Message activity type.
57
+ * This is called when a message is received from the user.
58
+ * @param handler - The handler to register
59
+ * @returns The current instance for method chaining
60
+ */
23
61
  onMessage(handler: AgentHandler): this;
24
- /** * Registers a handler for the MessageUpdate activity type. */
62
+ /**
63
+ * Registers a handler for the MessageUpdate activity type.
64
+ * This is called when a message is updated.
65
+ * @param handler - The handler to register
66
+ * @returns The current instance for method chaining
67
+ */
25
68
  onMessageUpdate(handler: AgentHandler): this;
26
- /** * Registers a handler for the MessageDelete activity type. */
69
+ /**
70
+ * Registers a handler for the MessageDelete activity type.
71
+ * This is called when a message is deleted.
72
+ * @param handler - The handler to register
73
+ * @returns The current instance for method chaining
74
+ */
27
75
  onMessageDelete(handler: AgentHandler): this;
28
- /** * Registers a handler for the ConversationUpdate activity type. */
76
+ /**
77
+ * Registers a handler for the ConversationUpdate activity type.
78
+ * This is called when the conversation is updated, such as when members are added or removed.
79
+ * @param handler - The handler to register
80
+ * @returns The current instance for method chaining
81
+ */
29
82
  onConversationUpdate(handler: AgentHandler): this;
30
- /** * Registers a handler for the MessageReaction activity type. */
83
+ /**
84
+ * Registers a handler for the MessageReaction activity type.
85
+ * This is called when reactions are added or removed from messages.
86
+ * @param handler - The handler to register
87
+ * @returns The current instance for method chaining
88
+ */
31
89
  onMessageReaction(handler: AgentHandler): this;
32
- /** * Registers a handler for the ReactionsAdded activity type. */
90
+ /**
91
+ * Registers a handler for the ReactionsAdded activity type.
92
+ * This is called when reactions are added to messages.
93
+ * @param handler - The handler to register
94
+ * @returns The current instance for method chaining
95
+ */
33
96
  onReactionsAdded(handler: AgentHandler): this;
34
- /** * Registers a handler for the ReactionsRemoved activity type. */
97
+ /**
98
+ * Registers a handler for the ReactionsRemoved activity type.
99
+ * This is called when reactions are removed from messages.
100
+ * @param handler - The handler to register
101
+ * @returns The current instance for method chaining
102
+ */
35
103
  onReactionsRemoved(handler: AgentHandler): this;
36
- /** * Registers a handler for the Typing activity type. */
104
+ /**
105
+ * Registers a handler for the Typing activity type.
106
+ * This is called when a typing indicator is received.
107
+ * @param handler - The handler to register
108
+ * @returns The current instance for method chaining
109
+ */
37
110
  onTyping(handler: AgentHandler): this;
38
- /** * Registers a handler for the InstallationUpdate activity type. */
111
+ /**
112
+ * Registers a handler for the InstallationUpdate activity type.
113
+ * This is called when an agent is installed or uninstalled.
114
+ * @param handler - The handler to register
115
+ * @returns The current instance for method chaining
116
+ */
39
117
  onInstallationUpdate(handler: AgentHandler): this;
40
- /** * Registers a handler for the InstallationUpdateAdd activity type. */
118
+ /**
119
+ * Registers a handler for the InstallationUpdateAdd activity type.
120
+ * This is called when an agent is installed or upgraded.
121
+ * @param handler - The handler to register
122
+ * @returns The current instance for method chaining
123
+ */
41
124
  onInstallationUpdateAdd(handler: AgentHandler): this;
42
- /** * Registers a handler for the InstallationUpdateRemove activity type. */
125
+ /**
126
+ * Registers a handler for the InstallationUpdateRemove activity type.
127
+ * This is called when an agent is uninstalled or downgraded.
128
+ * @param handler - The handler to register
129
+ * @returns The current instance for method chaining
130
+ */
43
131
  onInstallationUpdateRemove(handler: AgentHandler): this;
44
- /** * Registers a handler for the EndOfConversation activity type. */
132
+ /**
133
+ * Registers a handler for the EndOfConversation activity type.
134
+ * This is called when the conversation ends.
135
+ * @param handler - The handler to register
136
+ * @returns The current instance for method chaining
137
+ */
45
138
  onEndOfConversation(handler: AgentHandler): this;
46
- /** * Registers a handler for the SignInInvoke activity type. */
139
+ /**
140
+ * Registers a handler for the SignInInvoke activity type.
141
+ * This is called when a sign-in is requested.
142
+ * @param handler - The handler to register
143
+ * @returns The current instance for method chaining
144
+ */
47
145
  onSignInInvoke(handler: AgentHandler): this;
48
- /** * Registers a handler for unrecognized activity types. */
146
+ /**
147
+ * Registers a handler for unrecognized activity types.
148
+ * This is called when an activity type is not recognized.
149
+ * @param handler - The handler to register
150
+ * @returns The current instance for method chaining
151
+ */
49
152
  onUnrecognizedActivityType(handler: AgentHandler): this;
50
- /** * Registers an activity event handler for the _dialog_ event, emitted as the last event for an incoming activity. */
153
+ /**
154
+ * Registers an activity event handler for the _dialog_ event, emitted as the last event for an incoming activity.
155
+ * This handler is called after all other handlers have been processed.
156
+ * @param handler - The handler to register
157
+ * @returns The current instance for method chaining
158
+ */
51
159
  onDialog(handler: AgentHandler): this;
52
- /** * Runs the activity handler pipeline. */
160
+ /**
161
+ * Runs the activity handler pipeline.
162
+ * This method is called to process an incoming activity through the registered handlers.
163
+ * @param context - The turn context for the current turn of conversation
164
+ * @throws Error if context is missing, activity is missing, or activity type is missing
165
+ */
53
166
  run(context: TurnContext): Promise<void>;
54
- /** * Handles the Turn activity. */
167
+ /**
168
+ * Handles the Turn activity.
169
+ * This method is called for every activity type and dispatches to the appropriate handler.
170
+ * @param context - The turn context for the current turn of conversation
171
+ * @protected
172
+ */
55
173
  protected onTurnActivity(context: TurnContext): Promise<void>;
56
- /** * Handles the Message activity. */
174
+ /**
175
+ * Handles the Message activity.
176
+ * This method processes incoming message activities.
177
+ * @param context - The turn context for the current turn of conversation
178
+ * @protected
179
+ */
57
180
  protected onMessageActivity(context: TurnContext): Promise<void>;
58
- /** * Handles the MessageUpdate activity. */
181
+ /**
182
+ * Handles the MessageUpdate activity.
183
+ * This method processes message update activities.
184
+ * @param context - The turn context for the current turn of conversation
185
+ * @protected
186
+ */
59
187
  protected onMessageUpdateActivity(context: TurnContext): Promise<void>;
60
- /** * Handles the MessageDelete activity. */
188
+ /**
189
+ * Handles the MessageDelete activity.
190
+ * This method processes message deletion activities.
191
+ * @param context - The turn context for the current turn of conversation
192
+ * @protected
193
+ */
61
194
  protected onMessageDeleteActivity(context: TurnContext): Promise<void>;
62
- /** * Handles the ConversationUpdate activity. */
195
+ /**
196
+ * Handles the ConversationUpdate activity.
197
+ * This method processes conversation update activities.
198
+ * @param context - The turn context for the current turn of conversation
199
+ * @protected
200
+ */
63
201
  protected onConversationUpdateActivity(context: TurnContext): Promise<void>;
64
- /** * Handles the SignInInvoke activity. */
202
+ /**
203
+ * Handles the SignInInvoke activity.
204
+ * This method processes sign-in invoke activities.
205
+ * @param context - The turn context for the current turn of conversation
206
+ * @protected
207
+ */
65
208
  protected onSigninInvokeActivity(context: TurnContext): Promise<void>;
66
- /** * Handles the Invoke activity. */
209
+ /**
210
+ * Handles the Invoke activity.
211
+ * This method processes various invoke activities based on their name.
212
+ * @param context - The turn context for the current turn of conversation
213
+ * @returns An invoke response object with status and body
214
+ * @protected
215
+ */
67
216
  protected onInvokeActivity(context: TurnContext): Promise<InvokeResponse>;
68
- /** * Handles the AdaptiveCardInvoke activity. */
217
+ /**
218
+ * Handles the AdaptiveCardInvoke activity.
219
+ * This method processes adaptive card invoke activities.
220
+ * @param _context - The turn context for the current turn of conversation
221
+ * @param _invokeValue - The adaptive card invoke value
222
+ * @returns A promise that resolves to an adaptive card invoke response
223
+ * @protected
224
+ */
69
225
  protected onAdaptiveCardInvoke(_context: TurnContext, _invokeValue: AdaptiveCardInvokeValue): Promise<AdaptiveCardInvokeResponse>;
70
- /** * Handles the SearchInvoke activity. */
226
+ /**
227
+ * Handles the SearchInvoke activity.
228
+ * This method processes search invoke activities.
229
+ * @param _context - The turn context for the current turn of conversation
230
+ * @param _invokeValue - The search invoke value
231
+ * @returns A promise that resolves to a search invoke response
232
+ * @protected
233
+ */
71
234
  protected onSearchInvoke(_context: TurnContext, _invokeValue: SearchInvokeValue): Promise<SearchInvokeResponse>;
72
- /** * Retrieves the SearchInvoke value from the activity. */
235
+ /**
236
+ * Retrieves the SearchInvoke value from the activity.
237
+ * This method extracts and validates the search invoke value from an activity.
238
+ * @param activity - The activity to extract the search invoke value from
239
+ * @returns The validated search invoke value
240
+ * @private
241
+ */
73
242
  private getSearchInvokeValue;
74
- /** * Retrieves the AdaptiveCardInvoke value from the activity. */
243
+ /**
244
+ * Retrieves the AdaptiveCardInvoke value from the activity.
245
+ * This method extracts and validates the adaptive card invoke value from an activity.
246
+ * @param activity - The activity to extract the adaptive card invoke value from
247
+ * @returns The validated adaptive card invoke value
248
+ * @private
249
+ */
75
250
  private getAdaptiveCardInvokeValue;
76
- /** * Creates an error response for AdaptiveCardInvoke. */
251
+ /**
252
+ * Creates an error response for AdaptiveCardInvoke.
253
+ * This method creates an error response for adaptive card invoke activities.
254
+ * @param statusCode - The HTTP status code for the response
255
+ * @param code - The error code
256
+ * @param message - The error message
257
+ * @returns An adaptive card invoke error response
258
+ * @private
259
+ */
77
260
  private createAdaptiveCardInvokeErrorResponse;
78
- /** * Handles the MessageReaction activity. */
261
+ /**
262
+ * Handles the MessageReaction activity.
263
+ * This method processes message reaction activities.
264
+ * @param context - The turn context for the current turn of conversation
265
+ * @protected
266
+ */
79
267
  protected onMessageReactionActivity(context: TurnContext): Promise<void>;
80
- /** * Handles the EndOfConversation activity. */
268
+ /**
269
+ * Handles the EndOfConversation activity.
270
+ * This method processes end of conversation activities.
271
+ * @param context - The turn context for the current turn of conversation
272
+ * @protected
273
+ */
81
274
  protected onEndOfConversationActivity(context: TurnContext): Promise<void>;
82
- /** * Handles the Typing activity. */
275
+ /**
276
+ * Handles the Typing activity.
277
+ * This method processes typing indicator activities.
278
+ * @param context - The turn context for the current turn of conversation
279
+ * @protected
280
+ */
83
281
  protected onTypingActivity(context: TurnContext): Promise<void>;
84
- /** * Handles the InstallationUpdate activity. */
282
+ /**
283
+ * Handles the InstallationUpdate activity.
284
+ * This method processes installation update activities.
285
+ * @param context - The turn context for the current turn of conversation
286
+ * @protected
287
+ */
85
288
  protected onInstallationUpdateActivity(context: TurnContext): Promise<void>;
86
- /** * Handles unrecognized activity types. */
289
+ /**
290
+ * Handles unrecognized activity types.
291
+ * This method processes activities with unrecognized types.
292
+ * @param context - The turn context for the current turn of conversation
293
+ * @protected
294
+ */
87
295
  protected onUnrecognizedActivity(context: TurnContext): Promise<void>;
88
- /** * Dispatches the ConversationUpdate activity. */
296
+ /**
297
+ * Dispatches the ConversationUpdate activity.
298
+ * This method dispatches conversation update activities to the appropriate handlers.
299
+ * @param context - The turn context for the current turn of conversation
300
+ * @protected
301
+ */
89
302
  protected dispatchConversationUpdateActivity(context: TurnContext): Promise<void>;
90
- /** * Dispatches the MessageReaction activity. */
303
+ /**
304
+ * Dispatches the MessageReaction activity.
305
+ * This method dispatches message reaction activities to the appropriate handlers.
306
+ * @param context - The turn context for the current turn of conversation
307
+ * @protected
308
+ */
91
309
  protected dispatchMessageReactionActivity(context: TurnContext): Promise<void>;
92
- /** * Dispatches the MessageUpdate activity. */
310
+ /**
311
+ * Dispatches the MessageUpdate activity.
312
+ * This method dispatches message update activities to the appropriate handlers.
313
+ * @param context - The turn context for the current turn of conversation
314
+ * @protected
315
+ */
93
316
  protected dispatchMessageUpdateActivity(context: TurnContext): Promise<void>;
94
- /** * Dispatches the MessageDelete activity. */
317
+ /**
318
+ * Dispatches the MessageDelete activity.
319
+ * This method dispatches message delete activities to the appropriate handlers.
320
+ * @param context - The turn context for the current turn of conversation
321
+ * @protected
322
+ */
95
323
  protected dispatchMessageDeleteActivity(context: TurnContext): Promise<void>;
96
324
  /**
97
325
  * Returns the default next event handler.
326
+ * This method creates a function that calls the default handler.
327
+ * @param context - The turn context for the current turn of conversation
328
+ * @returns A function that calls the default handler
329
+ * @protected
98
330
  */
99
331
  protected defaultNextEvent(context: TurnContext): () => Promise<void>;
100
- /** * Registers a handler for a specific activity type. */
332
+ /**
333
+ * Registers a handler for a specific activity type.
334
+ * This method adds a handler to the list of handlers for a specific activity type.
335
+ * @param type - The activity type to register the handler for
336
+ * @param handler - The handler to register
337
+ * @returns The current instance for method chaining
338
+ * @protected
339
+ */
101
340
  protected on(type: string, handler: AgentHandler): this;
102
- /** * Executes the handlers for a specific activity type. */
341
+ /**
342
+ * Executes the handlers for a specific activity type.
343
+ * This method calls each registered handler for the specified activity type.
344
+ * @param context - The turn context for the current turn of conversation
345
+ * @param type - The activity type to handle
346
+ * @param onNext - The function to call when all handlers have been executed
347
+ * @returns The value returned by the last handler
348
+ * @protected
349
+ */
103
350
  protected handle(context: TurnContext, type: string, onNext: () => Promise<void>): Promise<any>;
104
- /** * Creates an InvokeResponse object. */
351
+ /**
352
+ * Creates an InvokeResponse object.
353
+ * This static method creates an invoke response with the specified body.
354
+ * @param body - The body of the response
355
+ * @returns An invoke response object with status and body
356
+ * @protected
357
+ */
105
358
  protected static createInvokeResponse(body?: any): InvokeResponse;
106
- /** * Dispatches the Event activity. */
359
+ /**
360
+ * Dispatches the Event activity.
361
+ * This method dispatches event activities to the appropriate handlers.
362
+ * @param context - The turn context for the current turn of conversation
363
+ * @protected
364
+ */
107
365
  protected dispatchEventActivity(context: TurnContext): Promise<void>;
108
366
  }