@microsoft/agents-hosting 1.5.0-beta.6.ga236d9a19c → 1.5.1

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 (157) hide show
  1. package/dist/package.json +10 -9
  2. package/dist/src/activityHandler.js +2 -2
  3. package/dist/src/activityHandler.js.map +1 -1
  4. package/dist/src/agent-client/agentClient.js +49 -40
  5. package/dist/src/agent-client/agentClient.js.map +1 -1
  6. package/dist/src/agent-client/agentResponseHandler.js +2 -2
  7. package/dist/src/agent-client/agentResponseHandler.js.map +1 -1
  8. package/dist/src/app/agentApplication.d.ts +36 -10
  9. package/dist/src/app/agentApplication.js +169 -99
  10. package/dist/src/app/agentApplication.js.map +1 -1
  11. package/dist/src/app/agentApplicationBuilder.d.ts +15 -0
  12. package/dist/src/app/agentApplicationBuilder.js +22 -4
  13. package/dist/src/app/agentApplicationBuilder.js.map +1 -1
  14. package/dist/src/app/agentApplicationOptions.d.ts +38 -0
  15. package/dist/src/app/attachmentDownloader.js +2 -2
  16. package/dist/src/app/attachmentDownloader.js.map +1 -1
  17. package/dist/src/app/auth/authorization.js +12 -9
  18. package/dist/src/app/auth/authorization.js.map +1 -1
  19. package/dist/src/app/auth/authorizationManager.d.ts +18 -5
  20. package/dist/src/app/auth/authorizationManager.js +258 -45
  21. package/dist/src/app/auth/authorizationManager.js.map +1 -1
  22. package/dist/src/app/auth/handlerStorage.js +3 -1
  23. package/dist/src/app/auth/handlerStorage.js.map +1 -1
  24. package/dist/src/app/auth/handlers/agenticAuthorization.d.ts +19 -16
  25. package/dist/src/app/auth/handlers/agenticAuthorization.js +46 -52
  26. package/dist/src/app/auth/handlers/agenticAuthorization.js.map +1 -1
  27. package/dist/src/app/auth/handlers/azureBotAuthorization.d.ts +51 -75
  28. package/dist/src/app/auth/handlers/azureBotAuthorization.js +217 -192
  29. package/dist/src/app/auth/handlers/azureBotAuthorization.js.map +1 -1
  30. package/dist/src/app/auth/types.d.ts +100 -1
  31. package/dist/src/app/auth/utils.d.ts +10 -0
  32. package/dist/src/app/auth/utils.js +21 -0
  33. package/dist/src/app/auth/utils.js.map +1 -0
  34. package/dist/src/app/index.d.ts +1 -0
  35. package/dist/src/app/index.js +1 -0
  36. package/dist/src/app/index.js.map +1 -1
  37. package/dist/src/app/proactive/conversation.d.ts +43 -0
  38. package/dist/src/app/proactive/conversation.js +67 -0
  39. package/dist/src/app/proactive/conversation.js.map +1 -0
  40. package/dist/src/app/proactive/conversationBuilder.d.ts +54 -0
  41. package/dist/src/app/proactive/conversationBuilder.js +110 -0
  42. package/dist/src/app/proactive/conversationBuilder.js.map +1 -0
  43. package/dist/src/app/proactive/conversationReferenceBuilder.d.ts +68 -0
  44. package/dist/src/app/proactive/conversationReferenceBuilder.js +125 -0
  45. package/dist/src/app/proactive/conversationReferenceBuilder.js.map +1 -0
  46. package/dist/src/app/proactive/createConversationOptions.d.ts +30 -0
  47. package/dist/src/app/proactive/createConversationOptions.js +10 -0
  48. package/dist/src/app/proactive/createConversationOptions.js.map +1 -0
  49. package/dist/src/app/proactive/createConversationOptionsBuilder.d.ts +69 -0
  50. package/dist/src/app/proactive/createConversationOptionsBuilder.js +141 -0
  51. package/dist/src/app/proactive/createConversationOptionsBuilder.js.map +1 -0
  52. package/dist/src/app/proactive/index.d.ts +7 -0
  53. package/dist/src/app/proactive/index.js +26 -0
  54. package/dist/src/app/proactive/index.js.map +1 -0
  55. package/dist/src/app/proactive/proactive.d.ts +248 -0
  56. package/dist/src/app/proactive/proactive.js +310 -0
  57. package/dist/src/app/proactive/proactive.js.map +1 -0
  58. package/dist/src/app/proactive/proactiveOptions.d.ts +19 -0
  59. package/dist/src/app/proactive/proactiveOptions.js +5 -0
  60. package/dist/src/app/proactive/proactiveOptions.js.map +1 -0
  61. package/dist/src/app/streaming/streamingResponse.js +2 -2
  62. package/dist/src/app/streaming/streamingResponse.js.map +1 -1
  63. package/dist/src/app/teamsAttachmentDownloader.js +2 -2
  64. package/dist/src/app/teamsAttachmentDownloader.js.map +1 -1
  65. package/dist/src/app/turnState.js +2 -2
  66. package/dist/src/app/turnState.js.map +1 -1
  67. package/dist/src/auth/authConfiguration.d.ts +61 -0
  68. package/dist/src/auth/authConfiguration.js +52 -3
  69. package/dist/src/auth/authConfiguration.js.map +1 -1
  70. package/dist/src/auth/jwt-middleware.js +2 -2
  71. package/dist/src/auth/jwt-middleware.js.map +1 -1
  72. package/dist/src/auth/msalConnectionManager.js +20 -0
  73. package/dist/src/auth/msalConnectionManager.js.map +1 -1
  74. package/dist/src/auth/msalTokenCredential.js +3 -0
  75. package/dist/src/auth/msalTokenCredential.js.map +1 -1
  76. package/dist/src/auth/msalTokenProvider.js +136 -110
  77. package/dist/src/auth/msalTokenProvider.js.map +1 -1
  78. package/dist/src/baseAdapter.js +2 -2
  79. package/dist/src/baseAdapter.js.map +1 -1
  80. package/dist/src/cloudAdapter.js +201 -154
  81. package/dist/src/cloudAdapter.js.map +1 -1
  82. package/dist/src/connector-client/connectorClient.js +176 -127
  83. package/dist/src/connector-client/connectorClient.js.map +1 -1
  84. package/dist/src/errorHelper.js +108 -0
  85. package/dist/src/errorHelper.js.map +1 -1
  86. package/dist/src/middlewareSet.js +2 -2
  87. package/dist/src/middlewareSet.js.map +1 -1
  88. package/dist/src/oauth/userTokenClient.js +78 -48
  89. package/dist/src/oauth/userTokenClient.js.map +1 -1
  90. package/dist/src/observability/index.d.ts +2 -0
  91. package/dist/src/observability/index.js +21 -0
  92. package/dist/src/observability/index.js.map +1 -0
  93. package/dist/src/observability/metrics.d.ts +21 -0
  94. package/dist/src/observability/metrics.js +87 -0
  95. package/dist/src/observability/metrics.js.map +1 -0
  96. package/dist/src/observability/traces.d.ts +234 -0
  97. package/dist/src/observability/traces.js +962 -0
  98. package/dist/src/observability/traces.js.map +1 -0
  99. package/dist/src/state/agentState.js +2 -2
  100. package/dist/src/state/agentState.js.map +1 -1
  101. package/dist/src/storage/fileStorage.js +38 -28
  102. package/dist/src/storage/fileStorage.js.map +1 -1
  103. package/dist/src/storage/memoryStorage.js +41 -30
  104. package/dist/src/storage/memoryStorage.js.map +1 -1
  105. package/dist/src/transcript/fileTranscriptLogger.js +2 -2
  106. package/dist/src/transcript/fileTranscriptLogger.js.map +1 -1
  107. package/dist/src/transcript/transcriptLoggerMiddleware.js +2 -2
  108. package/dist/src/transcript/transcriptLoggerMiddleware.js.map +1 -1
  109. package/dist/src/turnContext.js +48 -42
  110. package/dist/src/turnContext.js.map +1 -1
  111. package/package.json +10 -9
  112. package/src/activityHandler.ts +1 -1
  113. package/src/agent-client/agentClient.ts +53 -42
  114. package/src/agent-client/agentResponseHandler.ts +1 -1
  115. package/src/app/agentApplication.ts +212 -86
  116. package/src/app/agentApplicationBuilder.ts +26 -4
  117. package/src/app/agentApplicationOptions.ts +43 -0
  118. package/src/app/attachmentDownloader.ts +1 -1
  119. package/src/app/auth/authorization.ts +11 -8
  120. package/src/app/auth/authorizationManager.ts +297 -45
  121. package/src/app/auth/handlerStorage.ts +3 -1
  122. package/src/app/auth/handlers/agenticAuthorization.ts +68 -72
  123. package/src/app/auth/handlers/azureBotAuthorization.ts +260 -264
  124. package/src/app/auth/types.ts +102 -1
  125. package/src/app/auth/utils.ts +22 -0
  126. package/src/app/index.ts +1 -0
  127. package/src/app/proactive/conversation.ts +87 -0
  128. package/src/app/proactive/conversationBuilder.ts +139 -0
  129. package/src/app/proactive/conversationReferenceBuilder.ts +161 -0
  130. package/src/app/proactive/createConversationOptions.ts +35 -0
  131. package/src/app/proactive/createConversationOptionsBuilder.ts +181 -0
  132. package/src/app/proactive/index.ts +10 -0
  133. package/src/app/proactive/proactive.ts +524 -0
  134. package/src/app/proactive/proactiveOptions.ts +24 -0
  135. package/src/app/streaming/streamingResponse.ts +1 -1
  136. package/src/app/teamsAttachmentDownloader.ts +1 -1
  137. package/src/app/turnState.ts +1 -1
  138. package/src/auth/authConfiguration.ts +58 -1
  139. package/src/auth/jwt-middleware.ts +1 -1
  140. package/src/auth/msalConnectionManager.ts +22 -0
  141. package/src/auth/msalTokenCredential.ts +4 -0
  142. package/src/auth/msalTokenProvider.ts +138 -107
  143. package/src/baseAdapter.ts +1 -1
  144. package/src/cloudAdapter.ts +239 -184
  145. package/src/connector-client/connectorClient.ts +169 -126
  146. package/src/errorHelper.ts +124 -0
  147. package/src/middlewareSet.ts +1 -1
  148. package/src/oauth/userTokenClient.ts +70 -46
  149. package/src/observability/index.ts +5 -0
  150. package/src/observability/metrics.ts +103 -0
  151. package/src/observability/traces.ts +988 -0
  152. package/src/state/agentState.ts +1 -1
  153. package/src/storage/fileStorage.ts +36 -26
  154. package/src/storage/memoryStorage.ts +40 -29
  155. package/src/transcript/fileTranscriptLogger.ts +1 -1
  156. package/src/transcript/transcriptLoggerMiddleware.ts +1 -1
  157. package/src/turnContext.ts +47 -41
@@ -0,0 +1,248 @@
1
+ import type { Activity } from '@microsoft/agents-activity';
2
+ import type { ResourceResponse } from '../../connector-client';
3
+ import type { BaseAdapter } from '../../baseAdapter';
4
+ import type { TurnContext } from '../../turnContext';
5
+ import type { TurnState } from '../turnState';
6
+ import type { RouteHandler } from '../routeHandler';
7
+ import type { AgentApplication } from '../agentApplication';
8
+ import type { ProactiveOptions } from './proactiveOptions';
9
+ import type { CreateConversationOptions } from './createConversationOptions';
10
+ import { Conversation } from './conversation';
11
+ /**
12
+ * Provides methods for storing, retrieving, and managing conversation references to enable
13
+ * proactive messaging scenarios. Supports sending activities and continuing conversations outside
14
+ * the standard request/response flow using stored conversation references.
15
+ *
16
+ * @remarks
17
+ * Use the `Proactive` class to implement scenarios where an agent needs to initiate conversations
18
+ * or send messages to users without an incoming activity, such as notifications or scheduled alerts.
19
+ * Some operations require that conversation references be stored using {@link storeConversation}
20
+ * before they can be used.
21
+ *
22
+ * Access via `app.proactive` after configuring `proactive` in {@link AgentApplicationOptions}.
23
+ */
24
+ export declare class Proactive<TState extends TurnState> {
25
+ /**
26
+ * `activity.valueType` that indicates additional key/values for the ContinueConversation event.
27
+ */
28
+ static readonly ContinueConversationValueType = "application/vnd.microsoft.activity.continueconversation+json";
29
+ private readonly _app;
30
+ private readonly _options;
31
+ private readonly _storage?;
32
+ constructor(app: AgentApplication<TState>, options: ProactiveOptions);
33
+ private requireStorage;
34
+ private requireAppStorage;
35
+ /**
36
+ * Stores the current conversation reference from a live {@link TurnContext} in proactive storage.
37
+ *
38
+ * @param context - The context object for the current turn, containing activity and conversation
39
+ * information.
40
+ * @returns The conversation ID that can be used to retrieve the reference in future operations.
41
+ * @example
42
+ * ```typescript
43
+ * // Inside an onMessage handler — save the conversation so we can message later
44
+ * app.onActivity('message', async (ctx, state) => {
45
+ * const convId = await app.proactive.storeConversation(ctx)
46
+ * await ctx.sendActivity(`Conversation stored. ID: ${convId}`)
47
+ * })
48
+ * ```
49
+ */
50
+ storeConversation(context: TurnContext): Promise<string>;
51
+ /**
52
+ * Stores an explicit {@link Conversation} object in proactive storage.
53
+ *
54
+ * @param conversation - The conversation reference record to store.
55
+ * @returns The conversation ID that can be used to retrieve the reference in future operations.
56
+ * @throws If the conversation fails validation (missing `conversation.id`, `serviceUrl`, or
57
+ * `claims.aud`).
58
+ * @example
59
+ * ```typescript
60
+ * // Build a Conversation manually and store it
61
+ * const conv = ConversationBuilder
62
+ * .create('my-app-id', 'msteams')
63
+ * .withUser('user-aad-id')
64
+ * .withConversationId('19:existing-thread-id@thread.tacv2')
65
+ * .build()
66
+ * const convId = await app.proactive.storeConversation(conv)
67
+ * ```
68
+ */
69
+ storeConversation(conversation: Conversation): Promise<string>;
70
+ /**
71
+ * Retrieves the stored {@link Conversation} associated with the given conversation ID.
72
+ *
73
+ * @param conversationId - The unique identifier of the conversation to retrieve.
74
+ * @returns The stored `Conversation`, or `undefined` if no record exists for that ID.
75
+ * @example
76
+ * ```typescript
77
+ * const conv = await app.proactive.getConversation(convId)
78
+ * if (conv) {
79
+ * await app.proactive.sendActivity(adapter, conv, { text: 'Hello!' })
80
+ * }
81
+ * ```
82
+ */
83
+ getConversation(conversationId: string): Promise<Conversation | undefined>;
84
+ /**
85
+ * Retrieves the stored {@link Conversation} for the given ID, throwing if no record is found.
86
+ *
87
+ * @param conversationId - The unique identifier of the conversation to retrieve.
88
+ * @returns The stored `Conversation`.
89
+ * @throws `Error` if no conversation reference is found for the specified ID.
90
+ * @example
91
+ * ```typescript
92
+ * // Use when absence of the conversation should be treated as an error
93
+ * const conv = await app.proactive.getConversationOrThrow(convId)
94
+ * await app.proactive.sendActivity(adapter, conv, { text: 'Alert: your report is ready.' })
95
+ * ```
96
+ */
97
+ getConversationOrThrow(conversationId: string): Promise<Conversation>;
98
+ /**
99
+ * Deletes the stored conversation reference for the given conversation ID.
100
+ *
101
+ * @param conversationId - The unique identifier of the conversation whose reference should be
102
+ * deleted.
103
+ * @remarks If no record exists for the given ID, no action is taken.
104
+ * @example
105
+ * ```typescript
106
+ * // Clean up after a conversation has ended
107
+ * app.onActivity('endOfConversation', async (ctx, state) => {
108
+ * await app.proactive.deleteConversation(ctx.activity.conversation.id)
109
+ * })
110
+ * ```
111
+ */
112
+ deleteConversation(conversationId: string): Promise<void>;
113
+ /**
114
+ * Sends an activity to a stored conversation, looking it up by ID.
115
+ *
116
+ * @param adapter - The channel adapter used to send the activity.
117
+ * @param conversationId - The ID of a conversation previously stored via {@link storeConversation}.
118
+ * @param activity - The activity to send. If `type` is not set it defaults to `'message'`.
119
+ * @returns A {@link ResourceResponse} with the ID of the sent activity.
120
+ * @throws `Error` if no conversation reference is found for the specified ID.
121
+ * @example
122
+ * ```typescript
123
+ * // Send a notification using a previously stored conversation ID
124
+ * await app.proactive.sendActivity(adapter, storedConvId, { text: 'Your order has shipped!' })
125
+ * ```
126
+ */
127
+ sendActivity(adapter: BaseAdapter, conversationId: string, activity: Partial<Activity>): Promise<ResourceResponse>;
128
+ /**
129
+ * Sends an activity to an existing conversation using the provided {@link Conversation} reference.
130
+ *
131
+ * @param adapter - The channel adapter used to send the activity.
132
+ * @param conversation - A `Conversation` instance created via its constructor or
133
+ * {@link ConversationBuilder}.
134
+ * @param activity - The activity to send. If `type` is not set it defaults to `'message'`.
135
+ * @returns A {@link ResourceResponse} with the ID of the sent activity.
136
+ * @example
137
+ * ```typescript
138
+ * // Build a Conversation from a stored reference and send a message
139
+ * const conv = await app.proactive.getConversationOrThrow(convId)
140
+ * const response = await app.proactive.sendActivity(adapter, conv, { text: 'Hello from the agent!' })
141
+ * console.log('Sent activity ID:', response.id)
142
+ * ```
143
+ */
144
+ sendActivity(adapter: BaseAdapter, conversation: Conversation, activity: Partial<Activity>): Promise<ResourceResponse>;
145
+ /**
146
+ * Continues a stored conversation by executing the given handler within the context of that
147
+ * conversation, looking it up by ID.
148
+ *
149
+ * See the {@link Conversation} overload for full details.
150
+ *
151
+ * @param adapter - The channel adapter used to continue the conversation.
152
+ * @param conversationId - The ID of a conversation previously stored via {@link storeConversation}.
153
+ * @param handler - The route handler to execute within the continued conversation context.
154
+ * @param autoSignInHandlers - Optional list of OAuth connection names whose tokens should be
155
+ * acquired before invoking the handler.
156
+ * @param continuationActivity - Optional activity fields merged into the continuation activity,
157
+ * making them available on `ctx.activity` inside the handler (e.g. `value`, `valueType`).
158
+ * @throws `Error` if no conversation reference is found for the specified ID.
159
+ * @example
160
+ * ```typescript
161
+ * // Scheduled job: send a daily digest to all stored conversations
162
+ * for (const convId of storedIds) {
163
+ * await app.proactive.continueConversation(adapter, convId, async (ctx, state) => {
164
+ * await ctx.sendActivity('Here is your daily digest...')
165
+ * })
166
+ * }
167
+ * ```
168
+ */
169
+ continueConversation(adapter: BaseAdapter, conversationId: string, handler: RouteHandler<TState>, autoSignInHandlers?: string[], continuationActivity?: Partial<Activity>): Promise<void>;
170
+ /**
171
+ * Continues an existing conversation by executing the given handler within the context of the
172
+ * provided {@link Conversation} reference. The handler receives a {@link TurnContext} and a
173
+ * freshly loaded {@link TurnState} scoped to the original conversation, enabling the agent to
174
+ * respond as if replying to an incoming activity.
175
+ *
176
+ * @remarks
177
+ * Exceptions thrown inside the handler are captured and re-thrown after the adapter callback
178
+ * completes, since the adapter would otherwise silently swallow them.
179
+ *
180
+ * If `autoSignInHandlers` are supplied and the application has user authorization configured,
181
+ * tokens are acquired before the handler is called. If not all tokens are available and
182
+ * `proactiveOptions.failOnUnsignedInConnections` is not `false`, an error is thrown.
183
+ *
184
+ * @param adapter - The channel adapter used to continue the conversation.
185
+ * @param conversation - A `Conversation` instance created via its constructor or
186
+ * {@link ConversationBuilder}.
187
+ * @param handler - The route handler to execute within the continued conversation context.
188
+ * @param autoSignInHandlers - Optional list of OAuth connection names whose tokens should be
189
+ * acquired before invoking the handler.
190
+ * @param continuationActivity - Optional activity fields merged into the continuation activity,
191
+ * making them available on `ctx.activity` inside the handler (e.g. `value`, `valueType`).
192
+ * @example
193
+ * ```typescript
194
+ * // Continue a conversation with a custom value payload
195
+ * const conv = await app.proactive.getConversationOrThrow(convId)
196
+ * await app.proactive.continueConversation(
197
+ * adapter,
198
+ * conv,
199
+ * async (ctx, state) => {
200
+ * const payload = ctx.activity.value as { alertType: string }
201
+ * await ctx.sendActivity(`Alert triggered: ${payload.alertType}`)
202
+ * },
203
+ * undefined,
204
+ * { value: { alertType: 'threshold-exceeded' }, valueType: Proactive.ContinueConversationValueType }
205
+ * )
206
+ * ```
207
+ */
208
+ continueConversation(adapter: BaseAdapter, conversation: Conversation, handler: RouteHandler<TState>, autoSignInHandlers?: string[], continuationActivity?: Partial<Activity>): Promise<void>;
209
+ /**
210
+ * Creates a new conversation using the specified channel adapter and conversation options.
211
+ *
212
+ * @remarks
213
+ * This wraps `CloudAdapter.createConversationAsync()`, which requires real network connectivity
214
+ * and authentication. The provided adapter must implement
215
+ * `createConversationAsync()`; a `TypeError` is thrown if it does not.
216
+ *
217
+ * If `createOptions.storeConversation` is `true`, the resulting {@link Conversation} is
218
+ * automatically stored via {@link storeConversation} so it can be retrieved by ID later.
219
+ *
220
+ * If a `handler` is provided it is executed within the newly created conversation, giving the
221
+ * agent a chance to send an initial message or load state.
222
+ *
223
+ * @param adapter - The channel adapter used to create the conversation. Must implement
224
+ * `createConversationAsync()` (i.e. a `CloudAdapter` instance).
225
+ * @param createOptions - Details required to create the conversation, including identity, channel,
226
+ * service URL, OAuth scope, and `ConversationParameters`. Build with
227
+ * {@link CreateConversationOptionsBuilder}.
228
+ * @param handler - Optional route handler executed immediately after the conversation is created.
229
+ * @returns The newly created {@link Conversation}.
230
+ * @throws `TypeError` if the adapter does not implement `createConversationAsync()`.
231
+ * @example
232
+ * ```typescript
233
+ * // Initiate a new 1:1 conversation with a Teams user and send a welcome message
234
+ * const opts = CreateConversationOptionsBuilder
235
+ * .create(process.env.APP_ID!, 'msteams')
236
+ * .withUser('user-aad-object-id')
237
+ * .withTenantId('tenant-id')
238
+ * .storeConversation(true)
239
+ * .build()
240
+ *
241
+ * const conv = await app.proactive.createConversation(adapter, opts, async (ctx, state) => {
242
+ * await ctx.sendActivity('Hi! I have an update for you.')
243
+ * })
244
+ * console.log('New conversation ID:', conv.reference.conversation.id)
245
+ * ```
246
+ */
247
+ createConversation(adapter: BaseAdapter, createOptions: CreateConversationOptions, handler?: RouteHandler<TState>): Promise<Conversation>;
248
+ }
@@ -0,0 +1,310 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation. All rights reserved.
3
+ // Licensed under the MIT License.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.Proactive = void 0;
6
+ const agents_activity_1 = require("@microsoft/agents-activity");
7
+ const conversation_1 = require("./conversation");
8
+ const agents_telemetry_1 = require("@microsoft/agents-telemetry");
9
+ const errorHelper_1 = require("../../errorHelper");
10
+ const traces_1 = require("../../observability/traces");
11
+ const logger = (0, agents_telemetry_1.debug)('agents:proactive');
12
+ const STORAGE_KEY_PREFIX = 'proactive/conversations/';
13
+ /**
14
+ * Provides methods for storing, retrieving, and managing conversation references to enable
15
+ * proactive messaging scenarios. Supports sending activities and continuing conversations outside
16
+ * the standard request/response flow using stored conversation references.
17
+ *
18
+ * @remarks
19
+ * Use the `Proactive` class to implement scenarios where an agent needs to initiate conversations
20
+ * or send messages to users without an incoming activity, such as notifications or scheduled alerts.
21
+ * Some operations require that conversation references be stored using {@link storeConversation}
22
+ * before they can be used.
23
+ *
24
+ * Access via `app.proactive` after configuring `proactive` in {@link AgentApplicationOptions}.
25
+ */
26
+ class Proactive {
27
+ constructor(app, options) {
28
+ this._app = app;
29
+ this._options = options;
30
+ this._storage = options.storage;
31
+ }
32
+ requireStorage() {
33
+ if (!this._storage) {
34
+ throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.ProactiveStorageRequired);
35
+ }
36
+ return this._storage;
37
+ }
38
+ requireAppStorage() {
39
+ const storage = this._app.options.storage;
40
+ if (!storage) {
41
+ throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.ProactiveAppStorageRequired);
42
+ }
43
+ return storage;
44
+ }
45
+ async storeConversation(contextOrConversation) {
46
+ return (0, agents_telemetry_1.trace)(traces_1.ProactiveTraceDefinitions.storeConversation, async ({ record }) => {
47
+ const conv = contextOrConversation instanceof conversation_1.Conversation
48
+ ? contextOrConversation
49
+ : new conversation_1.Conversation(contextOrConversation);
50
+ conv.validate();
51
+ const id = conv.reference.conversation.id;
52
+ record({ conversationId: id });
53
+ await this.requireStorage().write({ [`${STORAGE_KEY_PREFIX}${id}`]: { reference: conv.reference, claims: conv.claims } });
54
+ return id;
55
+ });
56
+ }
57
+ /**
58
+ * Retrieves the stored {@link Conversation} associated with the given conversation ID.
59
+ *
60
+ * @param conversationId - The unique identifier of the conversation to retrieve.
61
+ * @returns The stored `Conversation`, or `undefined` if no record exists for that ID.
62
+ * @example
63
+ * ```typescript
64
+ * const conv = await app.proactive.getConversation(convId)
65
+ * if (conv) {
66
+ * await app.proactive.sendActivity(adapter, conv, { text: 'Hello!' })
67
+ * }
68
+ * ```
69
+ */
70
+ async getConversation(conversationId) {
71
+ return (0, agents_telemetry_1.trace)(traces_1.ProactiveTraceDefinitions.getConversation, async ({ record }) => {
72
+ record({ conversationId });
73
+ const result = await this.requireStorage().read([`${STORAGE_KEY_PREFIX}${conversationId}`]);
74
+ const stored = result[`${STORAGE_KEY_PREFIX}${conversationId}`];
75
+ if (!stored) {
76
+ record({ found: false });
77
+ return undefined;
78
+ }
79
+ record({ found: true });
80
+ return new conversation_1.Conversation(stored.claims, stored.reference);
81
+ });
82
+ }
83
+ /**
84
+ * Retrieves the stored {@link Conversation} for the given ID, throwing if no record is found.
85
+ *
86
+ * @param conversationId - The unique identifier of the conversation to retrieve.
87
+ * @returns The stored `Conversation`.
88
+ * @throws `Error` if no conversation reference is found for the specified ID.
89
+ * @example
90
+ * ```typescript
91
+ * // Use when absence of the conversation should be treated as an error
92
+ * const conv = await app.proactive.getConversationOrThrow(convId)
93
+ * await app.proactive.sendActivity(adapter, conv, { text: 'Alert: your report is ready.' })
94
+ * ```
95
+ */
96
+ async getConversationOrThrow(conversationId) {
97
+ return (0, agents_telemetry_1.trace)(traces_1.ProactiveTraceDefinitions.getConversationOrThrow, async ({ record }) => {
98
+ record({ conversationId });
99
+ const conv = await this.getConversation(conversationId);
100
+ if (!conv) {
101
+ throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.ProactiveConversationNotFound, undefined, { conversationId });
102
+ }
103
+ return conv;
104
+ });
105
+ }
106
+ /**
107
+ * Deletes the stored conversation reference for the given conversation ID.
108
+ *
109
+ * @param conversationId - The unique identifier of the conversation whose reference should be
110
+ * deleted.
111
+ * @remarks If no record exists for the given ID, no action is taken.
112
+ * @example
113
+ * ```typescript
114
+ * // Clean up after a conversation has ended
115
+ * app.onActivity('endOfConversation', async (ctx, state) => {
116
+ * await app.proactive.deleteConversation(ctx.activity.conversation.id)
117
+ * })
118
+ * ```
119
+ */
120
+ async deleteConversation(conversationId) {
121
+ return (0, agents_telemetry_1.trace)(traces_1.ProactiveTraceDefinitions.deleteConversation, async ({ record }) => {
122
+ record({ conversationId });
123
+ await this.requireStorage().delete([`${STORAGE_KEY_PREFIX}${conversationId}`]);
124
+ });
125
+ }
126
+ async sendActivity(adapter, conversationOrId, activity) {
127
+ return (0, agents_telemetry_1.trace)(traces_1.ProactiveTraceDefinitions.sendActivity, async ({ record }) => {
128
+ var _a;
129
+ const conv = typeof conversationOrId === 'string'
130
+ ? await this.getConversationOrThrow(conversationOrId)
131
+ : conversationOrId;
132
+ const activityToSend = { type: 'message', ...activity };
133
+ record({
134
+ conversationId: conv.reference.conversation.id,
135
+ channelId: conv.reference.channelId,
136
+ activityType: (_a = activityToSend.type) !== null && _a !== void 0 ? _a : 'message',
137
+ });
138
+ logger.info('sendActivity: conversation=%s channel=%s serviceUrl=%s', conv.reference.conversation.id, conv.reference.channelId, conv.reference.serviceUrl);
139
+ let response;
140
+ let caughtError;
141
+ await adapter.continueConversation(conv.identity, conv.reference, async (ctx) => {
142
+ try {
143
+ const result = await ctx.sendActivity(activityToSend);
144
+ response = result;
145
+ }
146
+ catch (err) {
147
+ caughtError = err;
148
+ }
149
+ });
150
+ if (caughtError !== undefined) {
151
+ logger.warn('sendActivity: failed for conversation=%s: %s', conv.reference.conversation.id, caughtError);
152
+ throw caughtError;
153
+ }
154
+ if (response === undefined)
155
+ throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.ProactiveSendActivityNoResponse);
156
+ logger.debug('sendActivity: sent activity id=%s', response.id);
157
+ return response;
158
+ });
159
+ }
160
+ async continueConversation(adapter, conversationOrId, handler, autoSignInHandlers, continuationActivity) {
161
+ return (0, agents_telemetry_1.trace)(traces_1.ProactiveTraceDefinitions.continueConversation, async ({ record }) => {
162
+ const conv = typeof conversationOrId === 'string'
163
+ ? await this.getConversationOrThrow(conversationOrId)
164
+ : conversationOrId;
165
+ record({
166
+ conversationId: conv.reference.conversation.id,
167
+ channelId: conv.reference.channelId,
168
+ hasAutoSignIn: !!(autoSignInHandlers === null || autoSignInHandlers === void 0 ? void 0 : autoSignInHandlers.length),
169
+ });
170
+ logger.info('continueConversation: conversation=%s channel=%s serviceUrl=%s', conv.reference.conversation.id, conv.reference.channelId, conv.reference.serviceUrl);
171
+ let caughtError;
172
+ await adapter.continueConversation(conv.identity, conv.reference, async (ctx) => {
173
+ var _a, _b;
174
+ try {
175
+ // Merge caller-supplied activity fields (e.g. value, valueType) into the
176
+ // continuation activity so the handler can read request-time parameters.
177
+ if (continuationActivity) {
178
+ Object.assign(ctx.activity, continuationActivity);
179
+ }
180
+ const state = this._app.options.turnStateFactory();
181
+ await state.load(ctx, this.requireAppStorage());
182
+ // Token acquisition (optional — only when auth is configured)
183
+ if ((autoSignInHandlers === null || autoSignInHandlers === void 0 ? void 0 : autoSignInHandlers.length) && this._app.hasUserAuthorization) {
184
+ logger.debug('continueConversation: acquiring tokens for handlers: %o', autoSignInHandlers);
185
+ const results = await Promise.all(autoSignInHandlers.map((handlerId) => this._app.authorization.getToken(ctx, handlerId).catch(() => ({ token: undefined }))));
186
+ const allAcquired = results.every((r) => !!r.token);
187
+ if (!allAcquired) {
188
+ logger.warn('continueConversation: not all tokens acquired for conversation=%s handlers=%o', conv.reference.conversation.id, autoSignInHandlers);
189
+ if (this._options.failOnUnsignedInConnections !== false) {
190
+ throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.ProactiveNotAllTokensAcquired);
191
+ }
192
+ }
193
+ }
194
+ await handler(ctx, state);
195
+ await state.save(ctx, this.requireAppStorage());
196
+ }
197
+ catch (err) {
198
+ caughtError = err;
199
+ }
200
+ finally {
201
+ if ((_b = (_a = ctx.streamingResponse) === null || _a === void 0 ? void 0 : _a.isStreamStarted) === null || _b === void 0 ? void 0 : _b.call(_a)) {
202
+ await ctx.streamingResponse.endStream();
203
+ }
204
+ }
205
+ });
206
+ if (caughtError !== undefined) {
207
+ logger.warn('continueConversation: failed for conversation=%s: %s', conv.reference.conversation.id, caughtError);
208
+ throw caughtError;
209
+ }
210
+ logger.debug('continueConversation: complete for conversation=%s', conv.reference.conversation.id);
211
+ });
212
+ }
213
+ // ---------------------------------------------------------------------------
214
+ // Create new conversation
215
+ // ---------------------------------------------------------------------------
216
+ /**
217
+ * Creates a new conversation using the specified channel adapter and conversation options.
218
+ *
219
+ * @remarks
220
+ * This wraps `CloudAdapter.createConversationAsync()`, which requires real network connectivity
221
+ * and authentication. The provided adapter must implement
222
+ * `createConversationAsync()`; a `TypeError` is thrown if it does not.
223
+ *
224
+ * If `createOptions.storeConversation` is `true`, the resulting {@link Conversation} is
225
+ * automatically stored via {@link storeConversation} so it can be retrieved by ID later.
226
+ *
227
+ * If a `handler` is provided it is executed within the newly created conversation, giving the
228
+ * agent a chance to send an initial message or load state.
229
+ *
230
+ * @param adapter - The channel adapter used to create the conversation. Must implement
231
+ * `createConversationAsync()` (i.e. a `CloudAdapter` instance).
232
+ * @param createOptions - Details required to create the conversation, including identity, channel,
233
+ * service URL, OAuth scope, and `ConversationParameters`. Build with
234
+ * {@link CreateConversationOptionsBuilder}.
235
+ * @param handler - Optional route handler executed immediately after the conversation is created.
236
+ * @returns The newly created {@link Conversation}.
237
+ * @throws `TypeError` if the adapter does not implement `createConversationAsync()`.
238
+ * @example
239
+ * ```typescript
240
+ * // Initiate a new 1:1 conversation with a Teams user and send a welcome message
241
+ * const opts = CreateConversationOptionsBuilder
242
+ * .create(process.env.APP_ID!, 'msteams')
243
+ * .withUser('user-aad-object-id')
244
+ * .withTenantId('tenant-id')
245
+ * .storeConversation(true)
246
+ * .build()
247
+ *
248
+ * const conv = await app.proactive.createConversation(adapter, opts, async (ctx, state) => {
249
+ * await ctx.sendActivity('Hi! I have an update for you.')
250
+ * })
251
+ * console.log('New conversation ID:', conv.reference.conversation.id)
252
+ * ```
253
+ */
254
+ async createConversation(adapter, createOptions, handler) {
255
+ return (0, agents_telemetry_1.trace)(traces_1.ProactiveTraceDefinitions.createConversation, async ({ record }) => {
256
+ var _a, _b, _c;
257
+ record({
258
+ channelId: createOptions.channelId,
259
+ storeConversation: !!createOptions.storeConversation,
260
+ hasHandler: !!handler,
261
+ });
262
+ if (!((_a = createOptions.parameters.members) === null || _a === void 0 ? void 0 : _a.length)) {
263
+ throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.ProactiveMembersRequired);
264
+ }
265
+ record({ membersCount: createOptions.parameters.members.length });
266
+ // CloudAdapter.createConversationAsync(agentAppId, channelId, serviceUrl, audience, params, logic)
267
+ // The logic callback IS the handler — context is created internally by the adapter.
268
+ const cloudAdapter = adapter;
269
+ if (typeof cloudAdapter.createConversationAsync !== 'function') {
270
+ throw agents_activity_1.ExceptionHelper.generateException(TypeError, errorHelper_1.Errors.ProactiveCloudAdapterRequired);
271
+ }
272
+ logger.info('createConversation: channel=%s serviceUrl=%s members=%d', createOptions.channelId, createOptions.serviceUrl, (_c = (_b = createOptions.parameters.members) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0);
273
+ let capturedConv;
274
+ let caughtError;
275
+ await cloudAdapter.createConversationAsync(createOptions.identity.aud, createOptions.channelId, createOptions.serviceUrl, createOptions.scope, createOptions.parameters, async (ctx) => {
276
+ try {
277
+ const conv = new conversation_1.Conversation(createOptions.identity, ctx.activity.getConversationReference());
278
+ capturedConv = conv;
279
+ logger.debug('createConversation: created conversation=%s', conv.reference.conversation.id);
280
+ if (createOptions.storeConversation) {
281
+ await this.storeConversation(conv);
282
+ }
283
+ if (handler) {
284
+ const state = this._app.options.turnStateFactory();
285
+ await state.load(ctx, this.requireAppStorage());
286
+ await handler(ctx, state);
287
+ await state.save(ctx, this.requireAppStorage());
288
+ }
289
+ }
290
+ catch (err) {
291
+ caughtError = err;
292
+ }
293
+ });
294
+ if (caughtError !== undefined) {
295
+ logger.warn('createConversation: failed for channel=%s: %s', createOptions.channelId, caughtError);
296
+ throw caughtError;
297
+ }
298
+ if (!capturedConv) {
299
+ throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.ProactiveCallbackNotInvoked);
300
+ }
301
+ return capturedConv;
302
+ });
303
+ }
304
+ }
305
+ exports.Proactive = Proactive;
306
+ /**
307
+ * `activity.valueType` that indicates additional key/values for the ContinueConversation event.
308
+ */
309
+ Proactive.ContinueConversationValueType = 'application/vnd.microsoft.activity.continueconversation+json';
310
+ //# sourceMappingURL=proactive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proactive.js","sourceRoot":"","sources":["../../../../src/app/proactive/proactive.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;AAYlC,gEAA4D;AAC5D,iDAA6C;AAC7C,kEAA0D;AAC1D,mDAA0C;AAC1C,uDAAsE;AAEtE,MAAM,MAAM,GAAG,IAAA,wBAAK,EAAC,kBAAkB,CAAC,CAAA;AACxC,MAAM,kBAAkB,GAAG,0BAA0B,CAAA;AAErD;;;;;;;;;;;;GAYG;AACH,MAAa,SAAS;IAUpB,YAAa,GAA6B,EAAE,OAAyB;QACnE,IAAI,CAAC,IAAI,GAAG,GAAG,CAAA;QACf,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;QACvB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAA;IACjC,CAAC;IAEO,cAAc;QACpB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,MAAM,iCAAe,CAAC,iBAAiB,CAAC,KAAK,EAAE,oBAAM,CAAC,wBAAwB,CAAC,CAAA;QACjF,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAA;IACtB,CAAC;IAEO,iBAAiB;QACvB,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAA;QACzC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,iCAAe,CAAC,iBAAiB,CAAC,KAAK,EAAE,oBAAM,CAAC,2BAA2B,CAAC,CAAA;QACpF,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;IAyCD,KAAK,CAAC,iBAAiB,CAAE,qBAAiD;QACxE,OAAO,IAAA,wBAAK,EAAC,kCAAyB,CAAC,iBAAiB,EAAE,KAAK,E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AAE,CAAC;wBACZ,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAA;wBAClD,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAA;wBAC/C,MAAM,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;wBACzB,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAA;oBACjD,CAAC;gBACH,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACb,WAAW,GAAG,GAAG,CAAA;gBACnB,CAAC;YACH,CAAC,CACF,CAAA;YAED,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;gBAC9B,MAAM,CAAC,IAAI,CAAC,+CAA+C,EAAE,aAAa,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;gBAClG,MAAM,WAAW,CAAA;YACnB,CAAC;YAED,IAAI,CAAC,YAAY,EAAE,CAAC;gBAClB,MAAM,iCAAe,CAAC,iBAAiB,CAAC,KAAK,EAAE,oBAAM,CAAC,2BAA2B,CAAC,CAAA;YACpF,CAAC;YACD,OAAO,YAAY,CAAA;QACrB,CAAC,CAAC,CAAA;IACJ,CAAC;;AAveH,8BAweC;AAveC;;GAEG;AACa,uCAA6B,GAAG,8DAA8D,CAAA"}
@@ -0,0 +1,19 @@
1
+ import type { Storage } from '../../storage/storage';
2
+ /**
3
+ * Configuration for the proactive messaging subsystem.
4
+ */
5
+ export interface ProactiveOptions {
6
+ /**
7
+ * Storage backend for persisting conversation references.
8
+ *
9
+ * If omitted, falls back to `AgentApplicationOptions.storage`.
10
+ * A warning is logged when the fallback is used.
11
+ * Throws at initialization time if neither is configured.
12
+ */
13
+ storage?: Storage;
14
+ /**
15
+ * When `true` (default), `continueConversation()` throws if any requested
16
+ * token handler's user has not previously signed in.
17
+ */
18
+ failOnUnsignedInConnections?: boolean;
19
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation. All rights reserved.
3
+ // Licensed under the MIT License.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ //# sourceMappingURL=proactiveOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proactiveOptions.js","sourceRoot":"","sources":["../../../../src/app/proactive/proactiveOptions.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC"}
@@ -7,8 +7,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.StreamingResponse = exports.StreamingResponseResult = void 0;
8
8
  const agents_activity_1 = require("@microsoft/agents-activity");
9
9
  const citationUtil_1 = require("./citationUtil");
10
- const logger_1 = require("@microsoft/agents-activity/logger");
11
- const logger = (0, logger_1.debug)('agents:streamingResponse');
10
+ const agents_telemetry_1 = require("@microsoft/agents-telemetry");
11
+ const logger = (0, agents_telemetry_1.debug)('agents:streamingResponse');
12
12
  /**
13
13
  * Results for streaming response operations.
14
14
  */