@openclaw/msteams 2026.8.1-beta.3 → 2026.8.2

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 (28) hide show
  1. package/dist/{adapter.runtime-8g-MOPfb.cjs → adapter.runtime-DDuc7sKJ.cjs} +1 -1
  2. package/dist/api.cjs +2 -2
  3. package/dist/approval-card-BEblaIto.cjs +303 -0
  4. package/dist/approval-handler.runtime-C0AWNWXk.cjs +107 -0
  5. package/dist/{channel-KpWENcgK.cjs → channel-DLn4b6Qi.cjs} +168 -53
  6. package/dist/channel-config-api.cjs +1 -1
  7. package/dist/channel-plugin-api.cjs +1 -1
  8. package/dist/{channel.runtime-Bkzj8jZ0.cjs → channel.runtime-1mH99ZAm.cjs} +49 -608
  9. package/dist/{channel.setup-mOFtsfYz.cjs → channel.setup-BRbhaigB.cjs} +29 -18
  10. package/dist/{config-schema-C4CszdDi.cjs → config-schema-MyN2lamA.cjs} +12 -11
  11. package/dist/configured-state.cjs +20 -0
  12. package/dist/directory-contract-api.cjs +1 -1
  13. package/dist/doctor-contract-api.cjs +79 -42
  14. package/dist/{messenger-IISPSOvj.cjs → messenger-flkiAkkB.cjs} +29 -171
  15. package/dist/{oauth-C9So7uld.cjs → oauth-Bctn-WPI.cjs} +4 -3
  16. package/dist/{polls-DvuJvaDG.cjs → polls-P86qBpeV.cjs} +5 -4
  17. package/dist/qa-runner-api.cjs +1 -1
  18. package/dist/reaction-types-CL79V_5D.cjs +150 -0
  19. package/dist/{resolve-allowlist-CIfWUwuc.cjs → resolve-allowlist-BrdWKHE-.cjs} +26 -51
  20. package/dist/{rolldown-runtime-D6vf50IK.cjs → rolldown-runtime-VH7oDXx4.cjs} +1 -1
  21. package/dist/runtime-api.cjs +2 -1
  22. package/dist/secret-input-C65t6kjM.cjs +1 -0
  23. package/dist/send-C4BjzS1F.cjs +631 -0
  24. package/dist/setup-plugin-api.cjs +1 -1
  25. package/dist/{src-C127-DcQ.cjs → src-RSjkJRjI.cjs} +237 -99
  26. package/dist/{sso-token-store-ChhO1f4i.cjs → sso-token-store-CNbRhz-A.cjs} +1 -1
  27. package/dist/thread-session-DxOri69r.cjs +63 -0
  28. package/package.json +13 -11
@@ -0,0 +1,631 @@
1
+ const require_runtime = require("./runtime-gZTAuFux.cjs");
2
+ require("./runtime-api.cjs");
3
+ const require_resolve_allowlist = require("./resolve-allowlist-BrdWKHE-.cjs");
4
+ const require_channel = require("./channel-DLn4b6Qi.cjs");
5
+ const require_channel_setup = require("./channel.setup-BRbhaigB.cjs");
6
+ const require_polls = require("./polls-P86qBpeV.cjs");
7
+ const require_messenger = require("./messenger-flkiAkkB.cjs");
8
+ let openclaw_plugin_sdk_channel_outbound = require("openclaw/plugin-sdk/channel-outbound");
9
+ let openclaw_plugin_sdk_string_coerce_runtime = require("openclaw/plugin-sdk/string-coerce-runtime");
10
+ let openclaw_plugin_sdk_markdown_table_runtime = require("openclaw/plugin-sdk/markdown-table-runtime");
11
+ let openclaw_plugin_sdk_account_helpers = require("openclaw/plugin-sdk/account-helpers");
12
+ let openclaw_plugin_sdk_outbound_media = require("openclaw/plugin-sdk/outbound-media");
13
+ //#region extensions/msteams/src/send-context.ts
14
+ function resolveMSTeamsProactiveReplyTarget(params) {
15
+ const threadRootId = params.ref.threadId ?? params.ref.activityId;
16
+ if (params.conversationType !== "channel" || !threadRootId) return { replyStyle: "top-level" };
17
+ const routeConfig = require_channel.resolveMSTeamsRouteConfig({
18
+ cfg: params.cfg,
19
+ teamId: params.ref.teamId,
20
+ conversationId: params.conversationId,
21
+ allowNameMatching: false
22
+ });
23
+ const { replyStyle } = require_channel.resolveMSTeamsReplyPolicy({
24
+ isDirectMessage: false,
25
+ globalConfig: params.cfg,
26
+ teamConfig: routeConfig.teamConfig,
27
+ channelConfig: routeConfig.channelConfig
28
+ });
29
+ return replyStyle === "thread" ? {
30
+ replyStyle,
31
+ threadActivityId: threadRootId
32
+ } : { replyStyle };
33
+ }
34
+ /**
35
+ * Parse the target value into a conversation reference lookup key.
36
+ * Supported formats:
37
+ * - conversation:19:abc@thread.tacv2 → lookup by conversation ID
38
+ * - conversation:19:abc@thread.tacv2;messageid=root → lookup base ID, use root
39
+ * - user:aad-object-id → lookup by user AAD object ID
40
+ * - 19:abc@thread.tacv2 → direct conversation ID
41
+ */
42
+ function parseRecipient(to) {
43
+ const trimmed = to.trim();
44
+ const finalize = (type, id) => {
45
+ const normalized = id.trim();
46
+ if (!normalized) throw new Error(`Invalid target value: missing ${type} id`);
47
+ if (type === "conversation") {
48
+ const threadId = require_resolve_allowlist.extractMSTeamsConversationMessageId(normalized);
49
+ const normalizedConversationId = require_resolve_allowlist.normalizeMSTeamsConversationId(normalized);
50
+ const slashIndex = normalizedConversationId.indexOf("/");
51
+ const graphChannelId = slashIndex > 0 ? normalizedConversationId.slice(slashIndex + 1) : void 0;
52
+ return {
53
+ type,
54
+ id: graphChannelId && (graphChannelId.startsWith("19:") || graphChannelId.includes("@thread")) ? graphChannelId : normalizedConversationId,
55
+ ...threadId ? { threadId } : {}
56
+ };
57
+ }
58
+ return {
59
+ type,
60
+ id: normalized
61
+ };
62
+ };
63
+ if (trimmed.startsWith("conversation:")) return finalize("conversation", trimmed.slice(13));
64
+ if (trimmed.startsWith("user:")) return finalize("user", trimmed.slice(5));
65
+ if (trimmed.startsWith("19:") || trimmed.includes("@thread")) return finalize("conversation", trimmed);
66
+ return finalize("user", trimmed);
67
+ }
68
+ /**
69
+ * Find a stored conversation reference for the given recipient.
70
+ */
71
+ async function findConversationReference(recipient) {
72
+ if (recipient.type === "conversation") {
73
+ const ref = await recipient.store.get(recipient.id);
74
+ if (ref) return {
75
+ conversationId: recipient.id,
76
+ ref
77
+ };
78
+ return null;
79
+ }
80
+ const found = await recipient.store.findPreferredDmByUserId(recipient.id);
81
+ if (!found) return null;
82
+ return {
83
+ conversationId: found.conversationId,
84
+ ref: found.reference
85
+ };
86
+ }
87
+ async function resolveMSTeamsSendContext(params) {
88
+ const msteamsCfg = params.cfg.channels?.msteams;
89
+ if (!msteamsCfg?.enabled) throw new Error("msteams provider is not enabled");
90
+ const account = require_channel_setup.resolveMSTeamsAccount(params.cfg);
91
+ if (account.tokenStatus === "configured_unavailable") throw new Error("msteams credential file is configured but unavailable");
92
+ if (!account.configured) throw new Error("msteams credentials not configured");
93
+ const creds = require_resolve_allowlist.resolveMSTeamsCredentials(msteamsCfg);
94
+ if (!creds) throw new Error("msteams credentials not configured");
95
+ const store = require_polls.createMSTeamsConversationStoreState();
96
+ const recipient = parseRecipient(params.to);
97
+ const found = await findConversationReference({
98
+ ...recipient,
99
+ store
100
+ });
101
+ if (!found) throw new Error(`No conversation reference found for ${recipient.type}:${recipient.id}. The bot must receive a message from this conversation before it can send proactively.`);
102
+ const conversationId = found.conversationId;
103
+ const ref = recipient.threadId ? {
104
+ ...found.ref,
105
+ threadId: recipient.threadId
106
+ } : found.ref;
107
+ const log = require_runtime.getMSTeamsRuntime().logging.getChildLogger({ name: "msteams:send" });
108
+ if (ref.serviceUrl && !require_resolve_allowlist.isAllowedBotFrameworkServiceUrl(ref.serviceUrl)) {
109
+ try {
110
+ await store.remove(conversationId);
111
+ } catch (err) {
112
+ log.warn?.("failed to remove blocked msteams conversation reference", {
113
+ conversationId,
114
+ error: require_channel_setup.formatUnknownError(err)
115
+ });
116
+ }
117
+ throw new Error(`Stored Microsoft Teams conversation reference has blocked serviceUrl host: ${require_resolve_allowlist.describeBotFrameworkServiceUrlHost(ref.serviceUrl)}. The bot must receive a new message from this conversation before it can send proactively.`);
118
+ }
119
+ const safeRef = ref.serviceUrl ? {
120
+ ...ref,
121
+ serviceUrl: require_resolve_allowlist.normalizeBotFrameworkServiceUrl(ref.serviceUrl)
122
+ } : ref;
123
+ if (recipient.type === "user") {
124
+ const resolvedType = (0, openclaw_plugin_sdk_string_coerce_runtime.normalizeLowercaseStringOrEmpty)(safeRef.conversation?.conversationType ?? "");
125
+ if (resolvedType && resolvedType !== "personal") throw new Error(`Conversation reference for user:${recipient.id} resolved to a ${resolvedType} conversation (${conversationId}) instead of a personal DM. The bot must receive a DM from this user before it can send proactively.`);
126
+ }
127
+ const sdkCloudOptions = require_resolve_allowlist.resolveMSTeamsSdkCloudOptions(msteamsCfg);
128
+ const { app } = await require_resolve_allowlist.loadMSTeamsSdkWithAuth(creds, sdkCloudOptions);
129
+ require_resolve_allowlist.validateMSTeamsProactiveServiceUrlBoundary({
130
+ cloud: sdkCloudOptions.cloud,
131
+ conversationId,
132
+ storedServiceUrl: safeRef.serviceUrl,
133
+ configuredServiceUrl: sdkCloudOptions.serviceUrl
134
+ });
135
+ const tokenProvider = require_resolve_allowlist.createMSTeamsTokenProvider(app);
136
+ const storedConversationType = (0, openclaw_plugin_sdk_string_coerce_runtime.normalizeLowercaseStringOrEmpty)(safeRef.conversation?.conversationType ?? "");
137
+ let conversationType;
138
+ if (storedConversationType === "personal") conversationType = "personal";
139
+ else if (storedConversationType === "channel") conversationType = "channel";
140
+ else conversationType = "groupChat";
141
+ const replyTarget = recipient.threadId && conversationType === "channel" ? {
142
+ replyStyle: "thread",
143
+ threadActivityId: recipient.threadId
144
+ } : resolveMSTeamsProactiveReplyTarget({
145
+ cfg: msteamsCfg,
146
+ conversationId,
147
+ ref: safeRef,
148
+ conversationType
149
+ });
150
+ const sharePointSiteId = msteamsCfg.sharePointSiteId;
151
+ const mediaMaxBytes = (0, openclaw_plugin_sdk_account_helpers.resolveChannelMediaMaxBytes)({
152
+ cfg: params.cfg,
153
+ resolveChannelLimitMb: ({ cfg }) => cfg.channels?.msteams?.mediaMaxMb
154
+ });
155
+ return {
156
+ appId: creds.appId,
157
+ conversationId,
158
+ ref: safeRef,
159
+ app,
160
+ log,
161
+ conversationType,
162
+ ...replyTarget,
163
+ sdkCloudOptions,
164
+ tokenProvider,
165
+ sharePointSiteId,
166
+ mediaMaxBytes
167
+ };
168
+ }
169
+ //#endregion
170
+ //#region extensions/msteams/src/send.ts
171
+ /** Threshold for large files that require FileConsentCard flow in personal chats */
172
+ const FILE_CONSENT_THRESHOLD_BYTES = 4194304;
173
+ /**
174
+ * MSTeams-specific media size limit (100MB).
175
+ * Higher than the default to support Teams file-consent and SharePoint uploads.
176
+ */
177
+ const MSTEAMS_MAX_MEDIA_BYTES = 104857600;
178
+ function createMSTeamsSendError(errorPrefix, error) {
179
+ const classification = require_channel_setup.classifyMSTeamsSendError(error);
180
+ const hint = require_channel_setup.formatMSTeamsSendErrorHint(classification);
181
+ const status = classification.statusCode ? ` (HTTP ${classification.statusCode})` : "";
182
+ return new Error(`${errorPrefix} failed${status}: ${require_channel_setup.formatUnknownError(error)}${hint ? ` (${hint})` : ""}`, { cause: error });
183
+ }
184
+ function createMSTeamsSendReceipt(params) {
185
+ const receipt = (0, openclaw_plugin_sdk_channel_outbound.createMessageReceiptFromOutboundResults)({
186
+ kind: params.kind,
187
+ results: params.platformMessageIds.map((messageId) => ({
188
+ channel: "msteams",
189
+ messageId,
190
+ conversationId: params.conversationId
191
+ }))
192
+ });
193
+ if (!params.kinds) return receipt;
194
+ const kinds = params.kinds;
195
+ return {
196
+ ...receipt,
197
+ parts: receipt.parts.map((part, index) => {
198
+ const nextPart = {
199
+ platformMessageId: part.platformMessageId,
200
+ kind: kinds[index] ?? params.kind,
201
+ index: part.index
202
+ };
203
+ if (part.threadId) nextPart.threadId = part.threadId;
204
+ if (part.replyToId) nextPart.replyToId = part.replyToId;
205
+ if (part.raw) nextPart.raw = part.raw;
206
+ return nextPart;
207
+ })
208
+ };
209
+ }
210
+ function createMSTeamsSendResult(params) {
211
+ const platformMessageIds = (params.platformMessageIds?.length ? [...params.platformMessageIds] : [params.messageId]).map((messageId) => messageId.trim()).filter((messageId) => messageId && messageId !== "unknown");
212
+ return {
213
+ messageId: params.messageId,
214
+ conversationId: params.conversationId,
215
+ receipt: createMSTeamsSendReceipt({
216
+ conversationId: params.conversationId,
217
+ platformMessageIds,
218
+ kind: params.kind
219
+ }),
220
+ ...params.pendingUploadId ? { pendingUploadId: params.pendingUploadId } : {}
221
+ };
222
+ }
223
+ /**
224
+ * Send a message to a Teams conversation or user.
225
+ *
226
+ * Uses the stored ConversationReference from previous interactions.
227
+ * The bot must have received at least one message from the conversation
228
+ * before proactive messaging works.
229
+ *
230
+ * File handling by conversation type:
231
+ * - Personal (1:1) chats: small images (<4MB) use base64, large files and non-images use FileConsentCard
232
+ * - Group chats / channels: files require configured SharePoint storage
233
+ */
234
+ async function sendMessageMSTeams(params) {
235
+ const { cfg, to, text, mediaUrl, filename, mediaAccess, mediaLocalRoots, mediaReadFile } = params;
236
+ const tableMode = (0, openclaw_plugin_sdk_markdown_table_runtime.resolveMarkdownTableMode)({
237
+ cfg,
238
+ channel: "msteams"
239
+ });
240
+ const messageText = require_messenger.formatMSTeamsMarkdown(text ?? "", tableMode);
241
+ const ctx = await resolveMSTeamsSendContext({
242
+ cfg,
243
+ to
244
+ });
245
+ const { conversationId, log, conversationType, tokenProvider, sharePointSiteId } = ctx;
246
+ log.debug?.("sending proactive message", {
247
+ conversationId,
248
+ conversationType,
249
+ textLength: messageText.length,
250
+ hasMedia: Boolean(mediaUrl)
251
+ });
252
+ if (mediaUrl) {
253
+ const mediaMaxBytes = ctx.mediaMaxBytes ?? MSTEAMS_MAX_MEDIA_BYTES;
254
+ const media = await (0, openclaw_plugin_sdk_outbound_media.loadOutboundMediaFromUrl)(mediaUrl, {
255
+ maxBytes: mediaMaxBytes,
256
+ mediaAccess,
257
+ mediaLocalRoots,
258
+ mediaReadFile
259
+ });
260
+ const isLargeFile = media.buffer.length >= FILE_CONSENT_THRESHOLD_BYTES;
261
+ const isImage = media.contentType?.startsWith("image/") ?? false;
262
+ const fallbackFileName = await require_messenger.extractFilename(mediaUrl);
263
+ const fileName = filename?.trim() || media.fileName || fallbackFileName;
264
+ log.debug?.("processing media", {
265
+ fileName,
266
+ contentType: media.contentType,
267
+ size: media.buffer.length,
268
+ isLargeFile,
269
+ isImage,
270
+ conversationType
271
+ });
272
+ if (require_messenger.requiresFileConsent({
273
+ conversationType,
274
+ contentType: media.contentType,
275
+ bufferSize: media.buffer.length,
276
+ thresholdBytes: FILE_CONSENT_THRESHOLD_BYTES
277
+ })) {
278
+ const { activity, uploadId } = await require_messenger.prepareFileConsentActivityFs({
279
+ media: {
280
+ buffer: media.buffer,
281
+ filename: fileName,
282
+ contentType: media.contentType
283
+ },
284
+ conversationId,
285
+ description: messageText || void 0
286
+ });
287
+ log.debug?.("sending file consent card", {
288
+ uploadId,
289
+ fileName,
290
+ size: media.buffer.length
291
+ });
292
+ const messageId = await sendProactiveActivity({
293
+ ctx,
294
+ activity,
295
+ errorPrefix: "msteams consent card send"
296
+ });
297
+ require_messenger.setPendingUploadActivityId(uploadId, messageId);
298
+ await require_messenger.setPendingUploadActivityIdFs(uploadId, messageId);
299
+ log.info("sent file consent card", {
300
+ conversationId,
301
+ messageId,
302
+ uploadId
303
+ });
304
+ return createMSTeamsSendResult({
305
+ messageId,
306
+ conversationId,
307
+ kind: "card",
308
+ pendingUploadId: uploadId
309
+ });
310
+ }
311
+ if (conversationType === "personal") {
312
+ const base64 = media.buffer.toString("base64");
313
+ return sendTextWithMedia(ctx, messageText, `data:${media.contentType};base64,${base64}`);
314
+ }
315
+ if (isImage && !sharePointSiteId) {
316
+ const base64 = media.buffer.toString("base64");
317
+ return sendTextWithMedia(ctx, messageText, `data:${media.contentType};base64,${base64}`);
318
+ }
319
+ try {
320
+ const siteId = require_messenger.requireMSTeamsSharePointSiteId(sharePointSiteId);
321
+ log.debug?.("uploading to SharePoint for native file card", {
322
+ fileName,
323
+ conversationType,
324
+ siteId
325
+ });
326
+ const uploaded = await require_messenger.uploadAndShareSharePoint({
327
+ buffer: media.buffer,
328
+ filename: fileName,
329
+ contentType: media.contentType,
330
+ tokenProvider,
331
+ siteId,
332
+ chatId: conversationId,
333
+ usePerUserSharing: conversationType === "groupChat"
334
+ });
335
+ log.debug?.("SharePoint upload complete", {
336
+ itemId: uploaded.itemId,
337
+ shareUrl: uploaded.shareUrl
338
+ });
339
+ const driveItem = await require_messenger.getDriveItemProperties({
340
+ siteId,
341
+ itemId: uploaded.itemId,
342
+ tokenProvider
343
+ });
344
+ log.debug?.("driveItem properties retrieved", {
345
+ eTag: driveItem.eTag,
346
+ webDavUrl: driveItem.webDavUrl
347
+ });
348
+ const fileCardAttachment = require_messenger.buildTeamsFileInfoCard(driveItem);
349
+ const messageId = await sendProactiveActivityRaw({
350
+ ctx,
351
+ activity: {
352
+ type: "message",
353
+ text: messageText || void 0,
354
+ attachments: [fileCardAttachment]
355
+ }
356
+ });
357
+ log.info("sent native file card", {
358
+ conversationId,
359
+ messageId,
360
+ fileName: driveItem.name
361
+ });
362
+ return createMSTeamsSendResult({
363
+ messageId,
364
+ conversationId,
365
+ kind: "media"
366
+ });
367
+ } catch (err) {
368
+ throw createMSTeamsSendError("msteams file send", err);
369
+ }
370
+ }
371
+ return sendTextWithMedia(ctx, messageText, void 0);
372
+ }
373
+ /**
374
+ * Send a text message with optional base64 media URL.
375
+ */
376
+ async function sendTextWithMedia(ctx, text, mediaUrl) {
377
+ const { app, appId, conversationId, ref, log, tokenProvider, sharePointSiteId, mediaMaxBytes, replyStyle } = ctx;
378
+ const messages = text && mediaUrl ? [{ text }, { mediaUrl }] : [{
379
+ text: text || void 0,
380
+ mediaUrl
381
+ }];
382
+ let platformMessageIds;
383
+ try {
384
+ platformMessageIds = await require_messenger.sendMSTeamsMessages({
385
+ replyStyle,
386
+ app,
387
+ appId,
388
+ conversationRef: ref,
389
+ messages,
390
+ retry: {},
391
+ onRetry: (event) => {
392
+ log.debug?.("retrying send", {
393
+ conversationId,
394
+ ...event
395
+ });
396
+ },
397
+ tokenProvider,
398
+ sharePointSiteId,
399
+ mediaMaxBytes,
400
+ serviceUrlBoundary: ctx.sdkCloudOptions
401
+ });
402
+ } catch (err) {
403
+ throw createMSTeamsSendError("msteams send", err);
404
+ }
405
+ const messageId = platformMessageIds[0] ?? "unknown";
406
+ log.info("sent proactive message", {
407
+ conversationId,
408
+ messageId
409
+ });
410
+ return {
411
+ messageId,
412
+ conversationId,
413
+ receipt: createMSTeamsSendReceipt({
414
+ conversationId,
415
+ platformMessageIds,
416
+ kind: mediaUrl ? "media" : "text",
417
+ ...text && mediaUrl ? { kinds: ["text", "media"] } : {}
418
+ })
419
+ };
420
+ }
421
+ async function sendProactiveActivityRaw({ ctx, activity }) {
422
+ const baseRef = require_messenger.buildConversationReference(ctx.ref);
423
+ const response = await require_messenger.sendMSTeamsActivityWithReference(ctx.app, baseRef, activity, {
424
+ ...ctx.threadActivityId ? { threadActivityId: ctx.threadActivityId } : {},
425
+ serviceUrlBoundary: ctx.sdkCloudOptions
426
+ });
427
+ return require_messenger.extractMessageId(response) ?? "unknown";
428
+ }
429
+ async function sendProactiveActivity({ ctx, activity, errorPrefix }) {
430
+ try {
431
+ return await sendProactiveActivityRaw({
432
+ ctx,
433
+ activity
434
+ });
435
+ } catch (err) {
436
+ throw createMSTeamsSendError(errorPrefix, err);
437
+ }
438
+ }
439
+ /**
440
+ * Send a poll (Adaptive Card) to a Teams conversation or user.
441
+ */
442
+ async function sendPollMSTeams(params) {
443
+ const { cfg, to, question, options, maxSelections } = params;
444
+ const ctx = await resolveMSTeamsSendContext({
445
+ cfg,
446
+ to
447
+ });
448
+ const { conversationId, log } = ctx;
449
+ const pollCard = require_polls.buildMSTeamsPollCard({
450
+ question,
451
+ options,
452
+ maxSelections
453
+ });
454
+ log.debug?.("sending poll", {
455
+ conversationId,
456
+ pollId: pollCard.pollId,
457
+ optionCount: pollCard.options.length
458
+ });
459
+ const messageId = await sendProactiveActivity({
460
+ ctx,
461
+ activity: {
462
+ type: "message",
463
+ attachments: [{
464
+ contentType: "application/vnd.microsoft.card.adaptive",
465
+ content: pollCard.card
466
+ }]
467
+ },
468
+ errorPrefix: "msteams poll send"
469
+ });
470
+ log.info("sent poll", {
471
+ conversationId,
472
+ pollId: pollCard.pollId,
473
+ messageId
474
+ });
475
+ return {
476
+ pollId: pollCard.pollId,
477
+ messageId,
478
+ conversationId
479
+ };
480
+ }
481
+ /**
482
+ * Send an arbitrary Adaptive Card to a Teams conversation or user.
483
+ */
484
+ async function sendAdaptiveCardMSTeams(params) {
485
+ const { cfg, to, card } = params;
486
+ const ctx = await resolveMSTeamsSendContext({
487
+ cfg,
488
+ to
489
+ });
490
+ const { conversationId, log } = ctx;
491
+ log.debug?.("sending adaptive card", {
492
+ conversationId,
493
+ cardType: card.type,
494
+ cardVersion: card.version
495
+ });
496
+ const messageId = await sendProactiveActivity({
497
+ ctx,
498
+ activity: {
499
+ type: "message",
500
+ attachments: [{
501
+ contentType: "application/vnd.microsoft.card.adaptive",
502
+ content: card
503
+ }]
504
+ },
505
+ errorPrefix: "msteams card send"
506
+ });
507
+ log.info("sent adaptive card", {
508
+ conversationId,
509
+ messageId
510
+ });
511
+ return {
512
+ messageId,
513
+ conversationId
514
+ };
515
+ }
516
+ /**
517
+ * Edit (update) a previously sent message in a Teams conversation.
518
+ *
519
+ * Uses the Bot Framework REST API for proactive edits outside of the
520
+ * original turn context.
521
+ */
522
+ async function editMessageMSTeams(params) {
523
+ return updateMSTeamsMessageActivity({
524
+ ...params,
525
+ activity: {
526
+ type: "message",
527
+ id: params.activityId,
528
+ text: params.text
529
+ }
530
+ });
531
+ }
532
+ async function editAdaptiveCardMSTeams(params) {
533
+ return updateMSTeamsMessageActivity({
534
+ ...params,
535
+ activity: {
536
+ type: "message",
537
+ id: params.activityId,
538
+ attachments: [{
539
+ contentType: "application/vnd.microsoft.card.adaptive",
540
+ content: params.card
541
+ }]
542
+ }
543
+ });
544
+ }
545
+ async function updateMSTeamsMessageActivity(params) {
546
+ const { cfg, to, activityId, activity } = params;
547
+ const { app, conversationId, ref, log, sdkCloudOptions } = await resolveMSTeamsSendContext({
548
+ cfg,
549
+ to
550
+ });
551
+ log.debug?.("editing proactive message", {
552
+ conversationId,
553
+ activityId
554
+ });
555
+ try {
556
+ const baseRef = require_messenger.buildConversationReference(ref);
557
+ await require_messenger.updateMSTeamsActivityWithReference(app, baseRef, activityId, activity, { serviceUrlBoundary: sdkCloudOptions });
558
+ } catch (err) {
559
+ throw createMSTeamsSendError("msteams edit", err);
560
+ }
561
+ log.info("edited proactive message", {
562
+ conversationId,
563
+ activityId
564
+ });
565
+ return { conversationId };
566
+ }
567
+ /**
568
+ * Delete a previously sent message in a Teams conversation.
569
+ *
570
+ * Uses the Bot Framework REST API for proactive deletes outside of the
571
+ * original turn context.
572
+ */
573
+ async function deleteMessageMSTeams(params) {
574
+ const { cfg, to, activityId } = params;
575
+ const { app, conversationId, ref, log, sdkCloudOptions } = await resolveMSTeamsSendContext({
576
+ cfg,
577
+ to
578
+ });
579
+ log.debug?.("deleting proactive message", {
580
+ conversationId,
581
+ activityId
582
+ });
583
+ try {
584
+ const baseRef = require_messenger.buildConversationReference(ref);
585
+ await require_messenger.deleteMSTeamsActivityWithReference(app, baseRef, activityId, { serviceUrlBoundary: sdkCloudOptions });
586
+ } catch (err) {
587
+ throw createMSTeamsSendError("msteams delete", err);
588
+ }
589
+ log.info("deleted proactive message", {
590
+ conversationId,
591
+ activityId
592
+ });
593
+ return { conversationId };
594
+ }
595
+ //#endregion
596
+ Object.defineProperty(exports, "deleteMessageMSTeams", {
597
+ enumerable: true,
598
+ get: function() {
599
+ return deleteMessageMSTeams;
600
+ }
601
+ });
602
+ Object.defineProperty(exports, "editAdaptiveCardMSTeams", {
603
+ enumerable: true,
604
+ get: function() {
605
+ return editAdaptiveCardMSTeams;
606
+ }
607
+ });
608
+ Object.defineProperty(exports, "editMessageMSTeams", {
609
+ enumerable: true,
610
+ get: function() {
611
+ return editMessageMSTeams;
612
+ }
613
+ });
614
+ Object.defineProperty(exports, "sendAdaptiveCardMSTeams", {
615
+ enumerable: true,
616
+ get: function() {
617
+ return sendAdaptiveCardMSTeams;
618
+ }
619
+ });
620
+ Object.defineProperty(exports, "sendMessageMSTeams", {
621
+ enumerable: true,
622
+ get: function() {
623
+ return sendMessageMSTeams;
624
+ }
625
+ });
626
+ Object.defineProperty(exports, "sendPollMSTeams", {
627
+ enumerable: true,
628
+ get: function() {
629
+ return sendPollMSTeams;
630
+ }
631
+ });
@@ -1,3 +1,3 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_channel_setup = require("./channel.setup-mOFtsfYz.cjs");
2
+ const require_channel_setup = require("./channel.setup-BRbhaigB.cjs");
3
3
  exports.msteamsSetupPlugin = require_channel_setup.msteamsSetupPlugin;