@microsoft/agents-hosting 1.5.0-beta.10.gc9dfbe84d2 → 1.5.0-beta.12.ga9a2b23c19

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 (51) hide show
  1. package/dist/package.json +2 -2
  2. package/dist/src/app/agentApplication.d.ts +14 -0
  3. package/dist/src/app/agentApplication.js +31 -2
  4. package/dist/src/app/agentApplication.js.map +1 -1
  5. package/dist/src/app/agentApplicationBuilder.d.ts +7 -0
  6. package/dist/src/app/agentApplicationBuilder.js +9 -0
  7. package/dist/src/app/agentApplicationBuilder.js.map +1 -1
  8. package/dist/src/app/agentApplicationOptions.d.ts +6 -0
  9. package/dist/src/app/index.d.ts +1 -0
  10. package/dist/src/app/index.js +1 -0
  11. package/dist/src/app/index.js.map +1 -1
  12. package/dist/src/app/proactive/conversation.d.ts +43 -0
  13. package/dist/src/app/proactive/conversation.js +67 -0
  14. package/dist/src/app/proactive/conversation.js.map +1 -0
  15. package/dist/src/app/proactive/conversationBuilder.d.ts +54 -0
  16. package/dist/src/app/proactive/conversationBuilder.js +110 -0
  17. package/dist/src/app/proactive/conversationBuilder.js.map +1 -0
  18. package/dist/src/app/proactive/conversationReferenceBuilder.d.ts +68 -0
  19. package/dist/src/app/proactive/conversationReferenceBuilder.js +125 -0
  20. package/dist/src/app/proactive/conversationReferenceBuilder.js.map +1 -0
  21. package/dist/src/app/proactive/createConversationOptions.d.ts +30 -0
  22. package/dist/src/app/proactive/createConversationOptions.js +10 -0
  23. package/dist/src/app/proactive/createConversationOptions.js.map +1 -0
  24. package/dist/src/app/proactive/createConversationOptionsBuilder.d.ts +69 -0
  25. package/dist/src/app/proactive/createConversationOptionsBuilder.js +141 -0
  26. package/dist/src/app/proactive/createConversationOptionsBuilder.js.map +1 -0
  27. package/dist/src/app/proactive/index.d.ts +7 -0
  28. package/dist/src/app/proactive/index.js +26 -0
  29. package/dist/src/app/proactive/index.js.map +1 -0
  30. package/dist/src/app/proactive/proactive.d.ts +248 -0
  31. package/dist/src/app/proactive/proactive.js +271 -0
  32. package/dist/src/app/proactive/proactive.js.map +1 -0
  33. package/dist/src/app/proactive/proactiveOptions.d.ts +19 -0
  34. package/dist/src/app/proactive/proactiveOptions.js +5 -0
  35. package/dist/src/app/proactive/proactiveOptions.js.map +1 -0
  36. package/dist/src/errorHelper.js +94 -0
  37. package/dist/src/errorHelper.js.map +1 -1
  38. package/package.json +2 -2
  39. package/src/app/agentApplication.ts +33 -0
  40. package/src/app/agentApplicationBuilder.ts +11 -0
  41. package/src/app/agentApplicationOptions.ts +7 -0
  42. package/src/app/index.ts +1 -0
  43. package/src/app/proactive/conversation.ts +87 -0
  44. package/src/app/proactive/conversationBuilder.ts +139 -0
  45. package/src/app/proactive/conversationReferenceBuilder.ts +161 -0
  46. package/src/app/proactive/createConversationOptions.ts +35 -0
  47. package/src/app/proactive/createConversationOptionsBuilder.ts +181 -0
  48. package/src/app/proactive/index.ts +10 -0
  49. package/src/app/proactive/proactive.ts +481 -0
  50. package/src/app/proactive/proactiveOptions.ts +24 -0
  51. package/src/errorHelper.ts +108 -0
@@ -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,271 @@
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 logger_1 = require("@microsoft/agents-activity/logger");
9
+ const errorHelper_1 = require("../../errorHelper");
10
+ const logger = (0, logger_1.debug)('agents:proactive');
11
+ const STORAGE_KEY_PREFIX = 'proactive/conversations/';
12
+ /**
13
+ * Provides methods for storing, retrieving, and managing conversation references to enable
14
+ * proactive messaging scenarios. Supports sending activities and continuing conversations outside
15
+ * the standard request/response flow using stored conversation references.
16
+ *
17
+ * @remarks
18
+ * Use the `Proactive` class to implement scenarios where an agent needs to initiate conversations
19
+ * or send messages to users without an incoming activity, such as notifications or scheduled alerts.
20
+ * Some operations require that conversation references be stored using {@link storeConversation}
21
+ * before they can be used.
22
+ *
23
+ * Access via `app.proactive` after configuring `proactive` in {@link AgentApplicationOptions}.
24
+ */
25
+ class Proactive {
26
+ constructor(app, options) {
27
+ this._app = app;
28
+ this._options = options;
29
+ this._storage = options.storage;
30
+ }
31
+ requireStorage() {
32
+ if (!this._storage) {
33
+ throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.ProactiveStorageRequired);
34
+ }
35
+ return this._storage;
36
+ }
37
+ requireAppStorage() {
38
+ const storage = this._app.options.storage;
39
+ if (!storage) {
40
+ throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.ProactiveAppStorageRequired);
41
+ }
42
+ return storage;
43
+ }
44
+ async storeConversation(contextOrConversation) {
45
+ const conv = contextOrConversation instanceof conversation_1.Conversation
46
+ ? contextOrConversation
47
+ : new conversation_1.Conversation(contextOrConversation);
48
+ conv.validate();
49
+ const id = conv.reference.conversation.id;
50
+ await this.requireStorage().write({ [`${STORAGE_KEY_PREFIX}${id}`]: { reference: conv.reference, claims: conv.claims } });
51
+ return id;
52
+ }
53
+ /**
54
+ * Retrieves the stored {@link Conversation} associated with the given conversation ID.
55
+ *
56
+ * @param conversationId - The unique identifier of the conversation to retrieve.
57
+ * @returns The stored `Conversation`, or `undefined` if no record exists for that ID.
58
+ * @example
59
+ * ```typescript
60
+ * const conv = await app.proactive.getConversation(convId)
61
+ * if (conv) {
62
+ * await app.proactive.sendActivity(adapter, conv, { text: 'Hello!' })
63
+ * }
64
+ * ```
65
+ */
66
+ async getConversation(conversationId) {
67
+ const result = await this.requireStorage().read([`${STORAGE_KEY_PREFIX}${conversationId}`]);
68
+ const stored = result[`${STORAGE_KEY_PREFIX}${conversationId}`];
69
+ if (!stored)
70
+ return undefined;
71
+ return new conversation_1.Conversation(stored.claims, stored.reference);
72
+ }
73
+ /**
74
+ * Retrieves the stored {@link Conversation} for the given ID, throwing if no record is found.
75
+ *
76
+ * @param conversationId - The unique identifier of the conversation to retrieve.
77
+ * @returns The stored `Conversation`.
78
+ * @throws `Error` if no conversation reference is found for the specified ID.
79
+ * @example
80
+ * ```typescript
81
+ * // Use when absence of the conversation should be treated as an error
82
+ * const conv = await app.proactive.getConversationOrThrow(convId)
83
+ * await app.proactive.sendActivity(adapter, conv, { text: 'Alert: your report is ready.' })
84
+ * ```
85
+ */
86
+ async getConversationOrThrow(conversationId) {
87
+ const conv = await this.getConversation(conversationId);
88
+ if (!conv) {
89
+ throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.ProactiveConversationNotFound, undefined, { conversationId });
90
+ }
91
+ return conv;
92
+ }
93
+ /**
94
+ * Deletes the stored conversation reference for the given conversation ID.
95
+ *
96
+ * @param conversationId - The unique identifier of the conversation whose reference should be
97
+ * deleted.
98
+ * @remarks If no record exists for the given ID, no action is taken.
99
+ * @example
100
+ * ```typescript
101
+ * // Clean up after a conversation has ended
102
+ * app.onActivity('endOfConversation', async (ctx, state) => {
103
+ * await app.proactive.deleteConversation(ctx.activity.conversation.id)
104
+ * })
105
+ * ```
106
+ */
107
+ async deleteConversation(conversationId) {
108
+ await this.requireStorage().delete([`${STORAGE_KEY_PREFIX}${conversationId}`]);
109
+ }
110
+ async sendActivity(adapter, conversationOrId, activity) {
111
+ const conv = typeof conversationOrId === 'string'
112
+ ? await this.getConversationOrThrow(conversationOrId)
113
+ : conversationOrId;
114
+ const activityToSend = { type: 'message', ...activity };
115
+ logger.info('sendActivity: conversation=%s channel=%s serviceUrl=%s', conv.reference.conversation.id, conv.reference.channelId, conv.reference.serviceUrl);
116
+ let response;
117
+ let caughtError;
118
+ await adapter.continueConversation(conv.identity, conv.reference, async (ctx) => {
119
+ try {
120
+ const result = await ctx.sendActivity(activityToSend);
121
+ response = result;
122
+ }
123
+ catch (err) {
124
+ caughtError = err;
125
+ }
126
+ });
127
+ if (caughtError !== undefined) {
128
+ logger.warn('sendActivity: failed for conversation=%s: %s', conv.reference.conversation.id, caughtError);
129
+ throw caughtError;
130
+ }
131
+ if (response === undefined)
132
+ throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.ProactiveSendActivityNoResponse);
133
+ logger.debug('sendActivity: sent activity id=%s', response.id);
134
+ return response;
135
+ }
136
+ async continueConversation(adapter, conversationOrId, handler, autoSignInHandlers, continuationActivity) {
137
+ const conv = typeof conversationOrId === 'string'
138
+ ? await this.getConversationOrThrow(conversationOrId)
139
+ : conversationOrId;
140
+ logger.info('continueConversation: conversation=%s channel=%s serviceUrl=%s', conv.reference.conversation.id, conv.reference.channelId, conv.reference.serviceUrl);
141
+ let caughtError;
142
+ await adapter.continueConversation(conv.identity, conv.reference, async (ctx) => {
143
+ var _a, _b;
144
+ try {
145
+ // Merge caller-supplied activity fields (e.g. value, valueType) into the
146
+ // continuation activity so the handler can read request-time parameters.
147
+ if (continuationActivity) {
148
+ Object.assign(ctx.activity, continuationActivity);
149
+ }
150
+ const state = this._app.options.turnStateFactory();
151
+ await state.load(ctx, this.requireAppStorage());
152
+ // Token acquisition (optional — only when auth is configured)
153
+ if ((autoSignInHandlers === null || autoSignInHandlers === void 0 ? void 0 : autoSignInHandlers.length) && this._app.hasUserAuthorization) {
154
+ logger.debug('continueConversation: acquiring tokens for handlers: %o', autoSignInHandlers);
155
+ const results = await Promise.all(autoSignInHandlers.map((handlerId) => this._app.authorization.getToken(ctx, handlerId).catch(() => ({ token: undefined }))));
156
+ const allAcquired = results.every((r) => !!r.token);
157
+ if (!allAcquired) {
158
+ logger.warn('continueConversation: not all tokens acquired for conversation=%s handlers=%o', conv.reference.conversation.id, autoSignInHandlers);
159
+ if (this._options.failOnUnsignedInConnections !== false) {
160
+ throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.ProactiveNotAllTokensAcquired);
161
+ }
162
+ }
163
+ }
164
+ await handler(ctx, state);
165
+ await state.save(ctx, this.requireAppStorage());
166
+ }
167
+ catch (err) {
168
+ caughtError = err;
169
+ }
170
+ finally {
171
+ if ((_b = (_a = ctx.streamingResponse) === null || _a === void 0 ? void 0 : _a.isStreamStarted) === null || _b === void 0 ? void 0 : _b.call(_a)) {
172
+ await ctx.streamingResponse.endStream();
173
+ }
174
+ }
175
+ });
176
+ if (caughtError !== undefined) {
177
+ logger.warn('continueConversation: failed for conversation=%s: %s', conv.reference.conversation.id, caughtError);
178
+ throw caughtError;
179
+ }
180
+ logger.debug('continueConversation: complete for conversation=%s', conv.reference.conversation.id);
181
+ }
182
+ // ---------------------------------------------------------------------------
183
+ // Create new conversation
184
+ // ---------------------------------------------------------------------------
185
+ /**
186
+ * Creates a new conversation using the specified channel adapter and conversation options.
187
+ *
188
+ * @remarks
189
+ * This wraps `CloudAdapter.createConversationAsync()`, which requires real network connectivity
190
+ * and authentication. The provided adapter must implement
191
+ * `createConversationAsync()`; a `TypeError` is thrown if it does not.
192
+ *
193
+ * If `createOptions.storeConversation` is `true`, the resulting {@link Conversation} is
194
+ * automatically stored via {@link storeConversation} so it can be retrieved by ID later.
195
+ *
196
+ * If a `handler` is provided it is executed within the newly created conversation, giving the
197
+ * agent a chance to send an initial message or load state.
198
+ *
199
+ * @param adapter - The channel adapter used to create the conversation. Must implement
200
+ * `createConversationAsync()` (i.e. a `CloudAdapter` instance).
201
+ * @param createOptions - Details required to create the conversation, including identity, channel,
202
+ * service URL, OAuth scope, and `ConversationParameters`. Build with
203
+ * {@link CreateConversationOptionsBuilder}.
204
+ * @param handler - Optional route handler executed immediately after the conversation is created.
205
+ * @returns The newly created {@link Conversation}.
206
+ * @throws `TypeError` if the adapter does not implement `createConversationAsync()`.
207
+ * @example
208
+ * ```typescript
209
+ * // Initiate a new 1:1 conversation with a Teams user and send a welcome message
210
+ * const opts = CreateConversationOptionsBuilder
211
+ * .create(process.env.APP_ID!, 'msteams')
212
+ * .withUser('user-aad-object-id')
213
+ * .withTenantId('tenant-id')
214
+ * .storeConversation(true)
215
+ * .build()
216
+ *
217
+ * const conv = await app.proactive.createConversation(adapter, opts, async (ctx, state) => {
218
+ * await ctx.sendActivity('Hi! I have an update for you.')
219
+ * })
220
+ * console.log('New conversation ID:', conv.reference.conversation.id)
221
+ * ```
222
+ */
223
+ async createConversation(adapter, createOptions, handler) {
224
+ var _a, _b, _c;
225
+ if (!((_a = createOptions.parameters.members) === null || _a === void 0 ? void 0 : _a.length)) {
226
+ throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.ProactiveMembersRequired);
227
+ }
228
+ // CloudAdapter.createConversationAsync(agentAppId, channelId, serviceUrl, audience, params, logic)
229
+ // The logic callback IS the handler — context is created internally by the adapter.
230
+ const cloudAdapter = adapter;
231
+ if (typeof cloudAdapter.createConversationAsync !== 'function') {
232
+ throw agents_activity_1.ExceptionHelper.generateException(TypeError, errorHelper_1.Errors.ProactiveCloudAdapterRequired);
233
+ }
234
+ 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);
235
+ let capturedConv;
236
+ let caughtError;
237
+ await cloudAdapter.createConversationAsync(createOptions.identity.aud, createOptions.channelId, createOptions.serviceUrl, createOptions.scope, createOptions.parameters, async (ctx) => {
238
+ try {
239
+ const conv = new conversation_1.Conversation(createOptions.identity, ctx.activity.getConversationReference());
240
+ capturedConv = conv;
241
+ logger.debug('createConversation: created conversation=%s', conv.reference.conversation.id);
242
+ if (createOptions.storeConversation) {
243
+ await this.storeConversation(conv);
244
+ }
245
+ if (handler) {
246
+ const state = this._app.options.turnStateFactory();
247
+ await state.load(ctx, this.requireAppStorage());
248
+ await handler(ctx, state);
249
+ await state.save(ctx, this.requireAppStorage());
250
+ }
251
+ }
252
+ catch (err) {
253
+ caughtError = err;
254
+ }
255
+ });
256
+ if (caughtError !== undefined) {
257
+ logger.warn('createConversation: failed for channel=%s: %s', createOptions.channelId, caughtError);
258
+ throw caughtError;
259
+ }
260
+ if (!capturedConv) {
261
+ throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.ProactiveCallbackNotInvoked);
262
+ }
263
+ return capturedConv;
264
+ }
265
+ }
266
+ exports.Proactive = Proactive;
267
+ /**
268
+ * `activity.valueType` that indicates additional key/values for the ContinueConversation event.
269
+ */
270
+ Proactive.ContinueConversationValueType = 'application/vnd.microsoft.activity.continueconversation+json';
271
+ //# 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,8DAAyD;AACzD,mDAA0C;AAE1C,MAAM,MAAM,GAAG,IAAA,cAAK,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;Q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AAC;gBACb,WAAW,GAAG,GAAG,CAAA;YACnB,CAAC;QACH,CAAC,CACF,CAAA;QAED,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC9B,MAAM,CAAC,IAAI,CAAC,+CAA+C,EAAE,aAAa,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;YAClG,MAAM,WAAW,CAAA;QACnB,CAAC;QAED,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,MAAM,iCAAe,CAAC,iBAAiB,CAAC,KAAK,EAAE,oBAAM,CAAC,2BAA2B,CAAC,CAAA;QACpF,CAAC;QACD,OAAO,YAAY,CAAA;IACrB,CAAC;;AA7bH,8BA8bC;AA7bC;;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"}
@@ -575,6 +575,100 @@ exports.Errors = {
575
575
  description: 'Invalid action value: {error}'
576
576
  },
577
577
  // ============================================================================
578
+ // Proactive Messaging Errors (-120740 to -120799)
579
+ // ============================================================================
580
+ /**
581
+ * Error thrown when Application.proactive is accessed but no storage was configured.
582
+ */
583
+ ProactivePropertyUnavailable: {
584
+ code: -120740,
585
+ description: 'The Application.proactive property is unavailable because no storage was configured. Set options.storage or options.proactive.storage.'
586
+ },
587
+ /**
588
+ * Error thrown when a proactive storage operation is attempted without a storage backend.
589
+ */
590
+ ProactiveStorageRequired: {
591
+ code: -120741,
592
+ description: 'This proactive operation requires a storage backend. Set options.storage or options.proactive.storage.'
593
+ },
594
+ /**
595
+ * Error thrown when a conversation is not found in proactive storage.
596
+ */
597
+ ProactiveConversationNotFound: {
598
+ code: -120742,
599
+ description: "Conversation '{conversationId}' was not found in proactive storage."
600
+ },
601
+ /**
602
+ * Error thrown when sendActivity does not receive a ResourceResponse from the adapter.
603
+ */
604
+ ProactiveSendActivityNoResponse: {
605
+ code: -120743,
606
+ description: 'sendActivity: adapter did not return a ResourceResponse.'
607
+ },
608
+ /**
609
+ * Error thrown when not all token handlers have a signed-in user for proactive continuation.
610
+ */
611
+ ProactiveNotAllTokensAcquired: {
612
+ code: -120744,
613
+ description: 'Not all token handlers have a signed-in user.'
614
+ },
615
+ /**
616
+ * Error thrown when createConversation is called without any members.
617
+ */
618
+ ProactiveMembersRequired: {
619
+ code: -120745,
620
+ description: 'createConversation: at least one member must be specified in parameters.members.'
621
+ },
622
+ /**
623
+ * Error thrown when the adapter passed to createConversation does not support createConversationAsync.
624
+ */
625
+ ProactiveCloudAdapterRequired: {
626
+ code: -120746,
627
+ description: 'createConversation requires a CloudAdapter. The provided adapter does not implement createConversationAsync().'
628
+ },
629
+ /**
630
+ * Error thrown when createConversationAsync completes without invoking its callback.
631
+ */
632
+ ProactiveCallbackNotInvoked: {
633
+ code: -120747,
634
+ description: 'createConversation: createConversationAsync completed without invoking its callback.'
635
+ },
636
+ /**
637
+ * Error thrown when a Conversation reference is missing conversation.id.
638
+ */
639
+ ConversationInvalidId: {
640
+ code: -120748,
641
+ description: 'Conversation is invalid: reference.conversation.id is required.'
642
+ },
643
+ /**
644
+ * Error thrown when a Conversation reference is missing serviceUrl.
645
+ */
646
+ ConversationInvalidServiceUrl: {
647
+ code: -120749,
648
+ description: 'Conversation is invalid: reference.serviceUrl is required.'
649
+ },
650
+ /**
651
+ * Error thrown when a Conversation reference is missing claims.aud.
652
+ */
653
+ ConversationInvalidAud: {
654
+ code: -120750,
655
+ description: 'Conversation is invalid: claims.aud (agent client ID) is required.'
656
+ },
657
+ /**
658
+ * Error thrown when CreateConversationOptionsBuilder.build() is called without any members.
659
+ */
660
+ CreateConversationBuilderMembersRequired: {
661
+ code: -120751,
662
+ description: 'CreateConversationOptionsBuilder: at least one members entry must be added via withUser().'
663
+ },
664
+ /**
665
+ * Error thrown when a proactive operation that requires TurnState load/save is called without app storage.
666
+ */
667
+ ProactiveAppStorageRequired: {
668
+ code: -120752,
669
+ description: 'This proactive operation requires app storage to load and save TurnState. Set options.storage on AgentApplication.'
670
+ },
671
+ // ============================================================================
578
672
  // General Errors (-120990)
579
673
  // ============================================================================
580
674
  /**