@openclaw/msteams 2026.8.1-beta.2 → 2026.8.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.
@@ -1,18 +1,15 @@
1
- const require_runtime = require("./runtime-gZTAuFux.cjs");
2
1
  require("./runtime-api.cjs");
3
- const require_resolve_allowlist = require("./resolve-allowlist-C6YcNC9a.cjs");
4
- const require_channel = require("./channel-DfCbi0d_.cjs");
5
- const require_setup_surface = require("./setup-surface-DAhGL2h8.cjs");
2
+ const require_resolve_allowlist = require("./resolve-allowlist-CWbvAW4v.cjs");
3
+ const require_channel = require("./channel-ChmCvkuA.cjs");
4
+ const require_channel_setup = require("./channel.setup-CKb8aKCV.cjs");
6
5
  const require_polls = require("./polls-DvuJvaDG.cjs");
7
- const require_messenger = require("./messenger-BqA8G3pY.cjs");
6
+ const require_send = require("./send-Bym7IH-v.cjs");
7
+ const require_reaction_types = require("./reaction-types-DtWOWuDN.cjs");
8
8
  let openclaw_plugin_sdk_channel_outbound = require("openclaw/plugin-sdk/channel-outbound");
9
9
  let openclaw_plugin_sdk_string_coerce_runtime = require("openclaw/plugin-sdk/string-coerce-runtime");
10
10
  let openclaw_plugin_sdk_reply_payload = require("openclaw/plugin-sdk/reply-payload");
11
11
  let openclaw_plugin_sdk_number_runtime = require("openclaw/plugin-sdk/number-runtime");
12
12
  let openclaw_plugin_sdk_channel_send_result = require("openclaw/plugin-sdk/channel-send-result");
13
- let openclaw_plugin_sdk_markdown_table_runtime = require("openclaw/plugin-sdk/markdown-table-runtime");
14
- let openclaw_plugin_sdk_media_runtime = require("openclaw/plugin-sdk/media-runtime");
15
- let openclaw_plugin_sdk_outbound_media = require("openclaw/plugin-sdk/outbound-media");
16
13
  let openclaw_plugin_sdk_text_chunking = require("openclaw/plugin-sdk/text-chunking");
17
14
  let openclaw_plugin_sdk_string_normalization_runtime = require("openclaw/plugin-sdk/string-normalization-runtime");
18
15
  //#region extensions/msteams/src/directory-live.ts
@@ -237,7 +234,7 @@ async function listPinsMSTeams(params) {
237
234
  * delegated-auth-enabled deployments hit the user-scoped endpoint.
238
235
  */
239
236
  async function reactMessageMSTeams(params) {
240
- const reactionType = require_messenger.resolveMSTeamsReactionEmoji(params.reactionType);
237
+ const reactionType = require_reaction_types.resolveMSTeamsReactionEmoji(params.reactionType);
241
238
  const token = await require_resolve_allowlist.resolveGraphToken(params.cfg, { preferDelegated: true });
242
239
  const { basePath } = resolveConversationPath(await resolveGraphConversationId(params.to));
243
240
  await require_resolve_allowlist.mutateGraphJson({
@@ -256,7 +253,7 @@ async function reactMessageMSTeams(params) {
256
253
  * `preferDelegated: true`. See `reactMessageMSTeams` for fallback rules.
257
254
  */
258
255
  async function unreactMessageMSTeams(params) {
259
- const reactionType = require_messenger.resolveMSTeamsReactionEmoji(params.reactionType);
256
+ const reactionType = require_reaction_types.resolveMSTeamsReactionEmoji(params.reactionType);
260
257
  const token = await require_resolve_allowlist.resolveGraphToken(params.cfg, { preferDelegated: true });
261
258
  const { basePath } = resolveConversationPath(await resolveGraphConversationId(params.to));
262
259
  await require_resolve_allowlist.mutateGraphJson({
@@ -296,7 +293,7 @@ async function listReactionsMSTeams(params) {
296
293
  return { reactions: Array.from(grouped.entries()).map(([type, group]) => ({
297
294
  reactionType: type,
298
295
  name: type,
299
- emoji: require_messenger.getMSTeamsReactionEmoji(type),
296
+ emoji: require_reaction_types.getMSTeamsReactionEmoji(type),
300
297
  count: group.count,
301
298
  users: group.users
302
299
  })) };
@@ -307,7 +304,7 @@ const SEARCH_PAGE_SIZE = 50;
307
304
  const SEARCH_MAX_PAGES = 10;
308
305
  function normalizeSearchText(message) {
309
306
  const content = message.body?.content ?? "";
310
- return message.body?.contentType?.toLowerCase() === "html" ? require_messenger.stripHtmlFromTeamsMessage(content) : content.trim();
307
+ return message.body?.contentType?.toLowerCase() === "html" ? require_reaction_types.stripHtmlFromTeamsMessage(content) : content.trim();
311
308
  }
312
309
  function matchesSearchSender(message, from) {
313
310
  const normalized = from?.trim().toLowerCase();
@@ -577,578 +574,21 @@ async function getChannelInfoMSTeams(params) {
577
574
  } };
578
575
  }
579
576
  //#endregion
580
- //#region extensions/msteams/src/send-context.ts
581
- function resolveMSTeamsProactiveReplyTarget(params) {
582
- const threadRootId = params.ref.threadId ?? params.ref.activityId;
583
- if (params.conversationType !== "channel" || !threadRootId) return { replyStyle: "top-level" };
584
- const routeConfig = require_channel.resolveMSTeamsRouteConfig({
585
- cfg: params.cfg,
586
- teamId: params.ref.teamId,
587
- conversationId: params.conversationId,
588
- allowNameMatching: false
589
- });
590
- const { replyStyle } = require_channel.resolveMSTeamsReplyPolicy({
591
- isDirectMessage: false,
592
- globalConfig: params.cfg,
593
- teamConfig: routeConfig.teamConfig,
594
- channelConfig: routeConfig.channelConfig
595
- });
596
- return replyStyle === "thread" ? {
597
- replyStyle,
598
- threadActivityId: threadRootId
599
- } : { replyStyle };
600
- }
601
- /**
602
- * Parse the target value into a conversation reference lookup key.
603
- * Supported formats:
604
- * - conversation:19:abc@thread.tacv2 → lookup by conversation ID
605
- * - conversation:19:abc@thread.tacv2;messageid=root → lookup base ID, use root
606
- * - user:aad-object-id → lookup by user AAD object ID
607
- * - 19:abc@thread.tacv2 → direct conversation ID
608
- */
609
- function parseRecipient(to) {
610
- const trimmed = to.trim();
611
- const finalize = (type, id) => {
612
- const normalized = id.trim();
613
- if (!normalized) throw new Error(`Invalid target value: missing ${type} id`);
614
- if (type === "conversation") {
615
- const threadId = require_resolve_allowlist.extractMSTeamsConversationMessageId(normalized);
616
- const normalizedConversationId = require_resolve_allowlist.normalizeMSTeamsConversationId(normalized);
617
- const slashIndex = normalizedConversationId.indexOf("/");
618
- const graphChannelId = slashIndex > 0 ? normalizedConversationId.slice(slashIndex + 1) : void 0;
619
- return {
620
- type,
621
- id: graphChannelId && (graphChannelId.startsWith("19:") || graphChannelId.includes("@thread")) ? graphChannelId : normalizedConversationId,
622
- ...threadId ? { threadId } : {}
623
- };
624
- }
625
- return {
626
- type,
627
- id: normalized
628
- };
629
- };
630
- if (trimmed.startsWith("conversation:")) return finalize("conversation", trimmed.slice(13));
631
- if (trimmed.startsWith("user:")) return finalize("user", trimmed.slice(5));
632
- if (trimmed.startsWith("19:") || trimmed.includes("@thread")) return finalize("conversation", trimmed);
633
- return finalize("user", trimmed);
634
- }
635
- /**
636
- * Find a stored conversation reference for the given recipient.
637
- */
638
- async function findConversationReference(recipient) {
639
- if (recipient.type === "conversation") {
640
- const ref = await recipient.store.get(recipient.id);
641
- if (ref) return {
642
- conversationId: recipient.id,
643
- ref
644
- };
645
- return null;
646
- }
647
- const found = await recipient.store.findPreferredDmByUserId(recipient.id);
648
- if (!found) return null;
649
- return {
650
- conversationId: found.conversationId,
651
- ref: found.reference
652
- };
653
- }
654
- async function resolveMSTeamsSendContext(params) {
655
- const msteamsCfg = params.cfg.channels?.msteams;
656
- if (!msteamsCfg?.enabled) throw new Error("msteams provider is not enabled");
657
- const creds = require_resolve_allowlist.resolveMSTeamsCredentials(msteamsCfg);
658
- if (!creds) throw new Error("msteams credentials not configured");
659
- const store = require_polls.createMSTeamsConversationStoreState();
660
- const recipient = parseRecipient(params.to);
661
- const found = await findConversationReference({
662
- ...recipient,
663
- store
664
- });
665
- 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.`);
666
- const conversationId = found.conversationId;
667
- const ref = recipient.threadId ? {
668
- ...found.ref,
669
- threadId: recipient.threadId
670
- } : found.ref;
671
- const log = require_runtime.getMSTeamsRuntime().logging.getChildLogger({ name: "msteams:send" });
672
- if (ref.serviceUrl && !require_resolve_allowlist.isAllowedBotFrameworkServiceUrl(ref.serviceUrl)) {
673
- try {
674
- await store.remove(conversationId);
675
- } catch (err) {
676
- log.warn?.("failed to remove blocked msteams conversation reference", {
677
- conversationId,
678
- error: require_setup_surface.formatUnknownError(err)
679
- });
680
- }
681
- 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.`);
682
- }
683
- const safeRef = ref.serviceUrl ? {
684
- ...ref,
685
- serviceUrl: require_resolve_allowlist.normalizeBotFrameworkServiceUrl(ref.serviceUrl)
686
- } : ref;
687
- if (recipient.type === "user") {
688
- const resolvedType = (0, openclaw_plugin_sdk_string_coerce_runtime.normalizeLowercaseStringOrEmpty)(safeRef.conversation?.conversationType ?? "");
689
- 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.`);
690
- }
691
- const sdkCloudOptions = require_resolve_allowlist.resolveMSTeamsSdkCloudOptions(msteamsCfg);
692
- const { app } = await require_resolve_allowlist.loadMSTeamsSdkWithAuth(creds, sdkCloudOptions);
693
- require_resolve_allowlist.validateMSTeamsProactiveServiceUrlBoundary({
694
- cloud: sdkCloudOptions.cloud,
695
- conversationId,
696
- storedServiceUrl: safeRef.serviceUrl,
697
- configuredServiceUrl: sdkCloudOptions.serviceUrl
698
- });
699
- const tokenProvider = require_resolve_allowlist.createMSTeamsTokenProvider(app);
700
- const storedConversationType = (0, openclaw_plugin_sdk_string_coerce_runtime.normalizeLowercaseStringOrEmpty)(safeRef.conversation?.conversationType ?? "");
701
- let conversationType;
702
- if (storedConversationType === "personal") conversationType = "personal";
703
- else if (storedConversationType === "channel") conversationType = "channel";
704
- else conversationType = "groupChat";
705
- const replyTarget = recipient.threadId && conversationType === "channel" ? {
706
- replyStyle: "thread",
707
- threadActivityId: recipient.threadId
708
- } : resolveMSTeamsProactiveReplyTarget({
709
- cfg: msteamsCfg,
710
- conversationId,
711
- ref: safeRef,
712
- conversationType
713
- });
714
- const sharePointSiteId = msteamsCfg.sharePointSiteId;
715
- const mediaMaxBytes = (0, openclaw_plugin_sdk_media_runtime.resolveChannelMediaMaxBytes)({
716
- cfg: params.cfg,
717
- resolveChannelLimitMb: ({ cfg }) => cfg.channels?.msteams?.mediaMaxMb
718
- });
719
- return {
720
- appId: creds.appId,
721
- conversationId,
722
- ref: safeRef,
723
- app,
724
- log,
725
- conversationType,
726
- ...replyTarget,
727
- sdkCloudOptions,
728
- tokenProvider,
729
- sharePointSiteId,
730
- mediaMaxBytes
731
- };
732
- }
733
- //#endregion
734
- //#region extensions/msteams/src/send.ts
735
- /** Threshold for large files that require FileConsentCard flow in personal chats */
736
- const FILE_CONSENT_THRESHOLD_BYTES = 4 * 1024 * 1024;
737
- /**
738
- * MSTeams-specific media size limit (100MB).
739
- * Higher than the default to support Teams file-consent and SharePoint uploads.
740
- */
741
- const MSTEAMS_MAX_MEDIA_BYTES = 100 * 1024 * 1024;
742
- function createMSTeamsSendReceipt(params) {
743
- const receipt = (0, openclaw_plugin_sdk_channel_outbound.createMessageReceiptFromOutboundResults)({
744
- kind: params.kind,
745
- results: params.platformMessageIds.map((messageId) => ({
746
- channel: "msteams",
747
- messageId,
748
- conversationId: params.conversationId
749
- }))
750
- });
751
- if (!params.kinds) return receipt;
752
- const kinds = params.kinds;
753
- return {
754
- ...receipt,
755
- parts: receipt.parts.map((part, index) => {
756
- const nextPart = {
757
- platformMessageId: part.platformMessageId,
758
- kind: kinds[index] ?? params.kind,
759
- index: part.index
760
- };
761
- if (part.threadId) nextPart.threadId = part.threadId;
762
- if (part.replyToId) nextPart.replyToId = part.replyToId;
763
- if (part.raw) nextPart.raw = part.raw;
764
- return nextPart;
765
- })
766
- };
767
- }
768
- function createMSTeamsSendResult(params) {
769
- const platformMessageIds = (params.platformMessageIds?.length ? [...params.platformMessageIds] : [params.messageId]).map((messageId) => messageId.trim()).filter((messageId) => messageId && messageId !== "unknown");
770
- return {
771
- messageId: params.messageId,
772
- conversationId: params.conversationId,
773
- receipt: createMSTeamsSendReceipt({
774
- conversationId: params.conversationId,
775
- platformMessageIds,
776
- kind: params.kind
777
- }),
778
- ...params.pendingUploadId ? { pendingUploadId: params.pendingUploadId } : {}
779
- };
780
- }
781
- /**
782
- * Send a message to a Teams conversation or user.
783
- *
784
- * Uses the stored ConversationReference from previous interactions.
785
- * The bot must have received at least one message from the conversation
786
- * before proactive messaging works.
787
- *
788
- * File handling by conversation type:
789
- * - Personal (1:1) chats: small images (<4MB) use base64, large files and non-images use FileConsentCard
790
- * - Group chats / channels: files require configured SharePoint storage
791
- */
792
- async function sendMessageMSTeams(params) {
793
- const { cfg, to, text, mediaUrl, filename, mediaAccess, mediaLocalRoots, mediaReadFile } = params;
794
- const tableMode = (0, openclaw_plugin_sdk_markdown_table_runtime.resolveMarkdownTableMode)({
795
- cfg,
796
- channel: "msteams"
797
- });
798
- const messageText = require_messenger.formatMSTeamsMarkdown(text ?? "", tableMode);
799
- const ctx = await resolveMSTeamsSendContext({
800
- cfg,
801
- to
802
- });
803
- const { conversationId, log, conversationType, tokenProvider, sharePointSiteId } = ctx;
804
- log.debug?.("sending proactive message", {
805
- conversationId,
806
- conversationType,
807
- textLength: messageText.length,
808
- hasMedia: Boolean(mediaUrl)
809
- });
810
- if (mediaUrl) {
811
- const media = await (0, openclaw_plugin_sdk_outbound_media.loadOutboundMediaFromUrl)(mediaUrl, {
812
- maxBytes: ctx.mediaMaxBytes ?? MSTEAMS_MAX_MEDIA_BYTES,
813
- mediaAccess,
814
- mediaLocalRoots,
815
- mediaReadFile
816
- });
817
- const isLargeFile = media.buffer.length >= FILE_CONSENT_THRESHOLD_BYTES;
818
- const isImage = media.contentType?.startsWith("image/") ?? false;
819
- const fallbackFileName = await require_messenger.extractFilename(mediaUrl);
820
- const fileName = filename?.trim() || media.fileName || fallbackFileName;
821
- log.debug?.("processing media", {
822
- fileName,
823
- contentType: media.contentType,
824
- size: media.buffer.length,
825
- isLargeFile,
826
- isImage,
827
- conversationType
828
- });
829
- if (require_messenger.requiresFileConsent({
830
- conversationType,
831
- contentType: media.contentType,
832
- bufferSize: media.buffer.length,
833
- thresholdBytes: FILE_CONSENT_THRESHOLD_BYTES
834
- })) {
835
- const { activity, uploadId } = await require_messenger.prepareFileConsentActivityFs({
836
- media: {
837
- buffer: media.buffer,
838
- filename: fileName,
839
- contentType: media.contentType
840
- },
841
- conversationId,
842
- description: messageText || void 0
843
- });
844
- log.debug?.("sending file consent card", {
845
- uploadId,
846
- fileName,
847
- size: media.buffer.length
848
- });
849
- const messageId = await sendProactiveActivity({
850
- ctx,
851
- activity,
852
- errorPrefix: "msteams consent card send"
853
- });
854
- require_messenger.setPendingUploadActivityId(uploadId, messageId);
855
- await require_messenger.setPendingUploadActivityIdFs(uploadId, messageId);
856
- log.info("sent file consent card", {
857
- conversationId,
858
- messageId,
859
- uploadId
860
- });
861
- return createMSTeamsSendResult({
862
- messageId,
863
- conversationId,
864
- kind: "card",
865
- pendingUploadId: uploadId
866
- });
867
- }
868
- if (conversationType === "personal") {
869
- const base64 = media.buffer.toString("base64");
870
- return sendTextWithMedia(ctx, messageText, `data:${media.contentType};base64,${base64}`);
871
- }
872
- if (isImage && !sharePointSiteId) {
873
- const base64 = media.buffer.toString("base64");
874
- return sendTextWithMedia(ctx, messageText, `data:${media.contentType};base64,${base64}`);
875
- }
876
- try {
877
- const siteId = require_messenger.requireMSTeamsSharePointSiteId(sharePointSiteId);
878
- log.debug?.("uploading to SharePoint for native file card", {
879
- fileName,
880
- conversationType,
881
- siteId
882
- });
883
- const uploaded = await require_messenger.uploadAndShareSharePoint({
884
- buffer: media.buffer,
885
- filename: fileName,
886
- contentType: media.contentType,
887
- tokenProvider,
888
- siteId,
889
- chatId: conversationId,
890
- usePerUserSharing: conversationType === "groupChat"
891
- });
892
- log.debug?.("SharePoint upload complete", {
893
- itemId: uploaded.itemId,
894
- shareUrl: uploaded.shareUrl
895
- });
896
- const driveItem = await require_messenger.getDriveItemProperties({
897
- siteId,
898
- itemId: uploaded.itemId,
899
- tokenProvider
900
- });
901
- log.debug?.("driveItem properties retrieved", {
902
- eTag: driveItem.eTag,
903
- webDavUrl: driveItem.webDavUrl
904
- });
905
- const fileCardAttachment = require_messenger.buildTeamsFileInfoCard(driveItem);
906
- const messageId = await sendProactiveActivityRaw({
907
- ctx,
908
- activity: {
909
- type: "message",
910
- text: messageText || void 0,
911
- attachments: [fileCardAttachment]
912
- }
913
- });
914
- log.info("sent native file card", {
915
- conversationId,
916
- messageId,
917
- fileName: driveItem.name
918
- });
919
- return createMSTeamsSendResult({
920
- messageId,
921
- conversationId,
922
- kind: "media"
923
- });
924
- } catch (err) {
925
- const classification = require_setup_surface.classifyMSTeamsSendError(err);
926
- const hint = require_setup_surface.formatMSTeamsSendErrorHint(classification);
927
- const status = classification.statusCode ? ` (HTTP ${classification.statusCode})` : "";
928
- throw new Error(`msteams file send failed${status}: ${require_setup_surface.formatUnknownError(err)}${hint ? ` (${hint})` : ""}`, { cause: err });
929
- }
930
- }
931
- return sendTextWithMedia(ctx, messageText, void 0);
932
- }
933
- /**
934
- * Send a text message with optional base64 media URL.
935
- */
936
- async function sendTextWithMedia(ctx, text, mediaUrl) {
937
- const { app, appId, conversationId, ref, log, tokenProvider, sharePointSiteId, mediaMaxBytes, replyStyle } = ctx;
938
- const messages = text && mediaUrl ? [{ text }, { mediaUrl }] : [{
939
- text: text || void 0,
940
- mediaUrl
941
- }];
942
- let platformMessageIds;
943
- try {
944
- platformMessageIds = await require_messenger.sendMSTeamsMessages({
945
- replyStyle,
946
- app,
947
- appId,
948
- conversationRef: ref,
949
- messages,
950
- retry: {},
951
- onRetry: (event) => {
952
- log.debug?.("retrying send", {
953
- conversationId,
954
- ...event
955
- });
956
- },
957
- tokenProvider,
958
- sharePointSiteId,
959
- mediaMaxBytes,
960
- serviceUrlBoundary: ctx.sdkCloudOptions
961
- });
962
- } catch (err) {
963
- const classification = require_setup_surface.classifyMSTeamsSendError(err);
964
- const hint = require_setup_surface.formatMSTeamsSendErrorHint(classification);
965
- const status = classification.statusCode ? ` (HTTP ${classification.statusCode})` : "";
966
- throw new Error(`msteams send failed${status}: ${require_setup_surface.formatUnknownError(err)}${hint ? ` (${hint})` : ""}`, { cause: err });
967
- }
968
- const messageId = platformMessageIds[0] ?? "unknown";
969
- log.info("sent proactive message", {
970
- conversationId,
971
- messageId
972
- });
973
- return {
974
- messageId,
975
- conversationId,
976
- receipt: createMSTeamsSendReceipt({
977
- conversationId,
978
- platformMessageIds,
979
- kind: mediaUrl ? "media" : "text",
980
- ...text && mediaUrl ? { kinds: ["text", "media"] } : {}
981
- })
982
- };
983
- }
984
- async function sendProactiveActivityRaw({ ctx, activity }) {
985
- const baseRef = require_messenger.buildConversationReference(ctx.ref);
986
- return require_messenger.extractMessageId(await require_messenger.sendMSTeamsActivityWithReference(ctx.app, baseRef, activity, {
987
- ...ctx.threadActivityId ? { threadActivityId: ctx.threadActivityId } : {},
988
- serviceUrlBoundary: ctx.sdkCloudOptions
989
- })) ?? "unknown";
990
- }
991
- async function sendProactiveActivity({ ctx, activity, errorPrefix }) {
992
- try {
993
- return await sendProactiveActivityRaw({
994
- ctx,
995
- activity
996
- });
997
- } catch (err) {
998
- const classification = require_setup_surface.classifyMSTeamsSendError(err);
999
- const hint = require_setup_surface.formatMSTeamsSendErrorHint(classification);
1000
- const status = classification.statusCode ? ` (HTTP ${classification.statusCode})` : "";
1001
- throw new Error(`${errorPrefix} failed${status}: ${require_setup_surface.formatUnknownError(err)}${hint ? ` (${hint})` : ""}`, { cause: err });
1002
- }
1003
- }
1004
- /**
1005
- * Send a poll (Adaptive Card) to a Teams conversation or user.
1006
- */
1007
- async function sendPollMSTeams(params) {
1008
- const { cfg, to, question, options, maxSelections } = params;
1009
- const ctx = await resolveMSTeamsSendContext({
1010
- cfg,
1011
- to
1012
- });
1013
- const { conversationId, log } = ctx;
1014
- const pollCard = require_polls.buildMSTeamsPollCard({
1015
- question,
1016
- options,
1017
- maxSelections
1018
- });
1019
- log.debug?.("sending poll", {
1020
- conversationId,
1021
- pollId: pollCard.pollId,
1022
- optionCount: pollCard.options.length
1023
- });
1024
- const messageId = await sendProactiveActivity({
1025
- ctx,
1026
- activity: {
1027
- type: "message",
1028
- attachments: [{
1029
- contentType: "application/vnd.microsoft.card.adaptive",
1030
- content: pollCard.card
1031
- }]
1032
- },
1033
- errorPrefix: "msteams poll send"
1034
- });
1035
- log.info("sent poll", {
1036
- conversationId,
1037
- pollId: pollCard.pollId,
1038
- messageId
1039
- });
1040
- return {
1041
- pollId: pollCard.pollId,
1042
- messageId,
1043
- conversationId
1044
- };
1045
- }
1046
- /**
1047
- * Send an arbitrary Adaptive Card to a Teams conversation or user.
1048
- */
1049
- async function sendAdaptiveCardMSTeams(params) {
1050
- const { cfg, to, card } = params;
1051
- const ctx = await resolveMSTeamsSendContext({
1052
- cfg,
1053
- to
1054
- });
1055
- const { conversationId, log } = ctx;
1056
- log.debug?.("sending adaptive card", {
1057
- conversationId,
1058
- cardType: card.type,
1059
- cardVersion: card.version
1060
- });
1061
- const messageId = await sendProactiveActivity({
1062
- ctx,
1063
- activity: {
1064
- type: "message",
1065
- attachments: [{
1066
- contentType: "application/vnd.microsoft.card.adaptive",
1067
- content: card
1068
- }]
1069
- },
1070
- errorPrefix: "msteams card send"
1071
- });
1072
- log.info("sent adaptive card", {
1073
- conversationId,
1074
- messageId
1075
- });
1076
- return {
1077
- messageId,
1078
- conversationId
1079
- };
1080
- }
1081
- /**
1082
- * Edit (update) a previously sent message in a Teams conversation.
1083
- *
1084
- * Uses the Bot Framework REST API for proactive edits outside of the
1085
- * original turn context.
1086
- */
1087
- async function editMessageMSTeams(params) {
1088
- const { cfg, to, activityId, text } = params;
1089
- const { app, conversationId, ref, log, sdkCloudOptions } = await resolveMSTeamsSendContext({
1090
- cfg,
1091
- to
1092
- });
1093
- log.debug?.("editing proactive message", {
1094
- conversationId,
1095
- activityId,
1096
- textLength: text.length
1097
- });
1098
- try {
1099
- await require_messenger.updateMSTeamsActivityWithReference(app, require_messenger.buildConversationReference(ref), activityId, {
1100
- type: "message",
1101
- id: activityId,
1102
- text
1103
- }, { serviceUrlBoundary: sdkCloudOptions });
1104
- } catch (err) {
1105
- const classification = require_setup_surface.classifyMSTeamsSendError(err);
1106
- const hint = require_setup_surface.formatMSTeamsSendErrorHint(classification);
1107
- const status = classification.statusCode ? ` (HTTP ${classification.statusCode})` : "";
1108
- throw new Error(`msteams edit failed${status}: ${require_setup_surface.formatUnknownError(err)}${hint ? ` (${hint})` : ""}`, { cause: err });
1109
- }
1110
- log.info("edited proactive message", {
1111
- conversationId,
1112
- activityId
1113
- });
1114
- return { conversationId };
1115
- }
1116
- /**
1117
- * Delete a previously sent message in a Teams conversation.
1118
- *
1119
- * Uses the Bot Framework REST API for proactive deletes outside of the
1120
- * original turn context.
1121
- */
1122
- async function deleteMessageMSTeams(params) {
1123
- const { cfg, to, activityId } = params;
1124
- const { app, conversationId, ref, log, sdkCloudOptions } = await resolveMSTeamsSendContext({
1125
- cfg,
1126
- to
1127
- });
1128
- log.debug?.("deleting proactive message", {
1129
- conversationId,
1130
- activityId
1131
- });
1132
- try {
1133
- await require_messenger.deleteMSTeamsActivityWithReference(app, require_messenger.buildConversationReference(ref), activityId, { serviceUrlBoundary: sdkCloudOptions });
1134
- } catch (err) {
1135
- const classification = require_setup_surface.classifyMSTeamsSendError(err);
1136
- const hint = require_setup_surface.formatMSTeamsSendErrorHint(classification);
1137
- const status = classification.statusCode ? ` (HTTP ${classification.statusCode})` : "";
1138
- throw new Error(`msteams delete failed${status}: ${require_setup_surface.formatUnknownError(err)}${hint ? ` (${hint})` : ""}`, { cause: err });
1139
- }
1140
- log.info("deleted proactive message", {
1141
- conversationId,
1142
- activityId
1143
- });
1144
- return { conversationId };
1145
- }
1146
- //#endregion
1147
577
  //#region extensions/msteams/src/outbound.ts
1148
578
  const MSTEAMS_TEXT_CHUNK_LIMIT = 4e3;
1149
579
  function resolveMSTeamsEffectiveTextChunkLimit(configuredLimit) {
1150
580
  return typeof configuredLimit === "number" && configuredLimit > 0 ? Math.min(configuredLimit, MSTEAMS_TEXT_CHUNK_LIMIT) : MSTEAMS_TEXT_CHUNK_LIMIT;
1151
581
  }
582
+ function toMSTeamsOutboundResult(result) {
583
+ const { conversationId, ...delivery } = result;
584
+ return {
585
+ ...delivery,
586
+ target: {
587
+ kind: "conversation",
588
+ id: conversationId
589
+ }
590
+ };
591
+ }
1152
592
  function resolveMSTeamsThreadTarget(to, threadId) {
1153
593
  const normalizedThreadId = threadId == null ? "" : String(threadId).trim();
1154
594
  const graphChannelId = to.includes("/") ? to.slice(to.indexOf("/") + 1) : "";
@@ -1157,14 +597,14 @@ function resolveMSTeamsThreadTarget(to, threadId) {
1157
597
  return `${to};messageid=${normalizedThreadId}`;
1158
598
  }
1159
599
  function resolveMSTeamsTextSend(params) {
1160
- return (0, openclaw_plugin_sdk_channel_outbound.resolveOutboundSendDep)(params.deps, "msteams") ?? ((to, text) => sendMessageMSTeams({
600
+ return (0, openclaw_plugin_sdk_channel_outbound.resolveOutboundSendDep)(params.deps, "msteams") ?? ((to, text) => require_send.sendMessageMSTeams({
1161
601
  cfg: params.cfg,
1162
602
  to,
1163
603
  text
1164
604
  }));
1165
605
  }
1166
606
  function resolveMSTeamsMediaSend(params) {
1167
- return (0, openclaw_plugin_sdk_channel_outbound.resolveOutboundSendDep)(params.deps, "msteams") ?? ((to, text, opts) => sendMessageMSTeams({
607
+ return (0, openclaw_plugin_sdk_channel_outbound.resolveOutboundSendDep)(params.deps, "msteams") ?? ((to, text, opts) => require_send.sendMessageMSTeams({
1168
608
  cfg: params.cfg,
1169
609
  to,
1170
610
  text,
@@ -1206,11 +646,11 @@ const msteamsOutbound = {
1206
646
  sendPayload: async ({ cfg, to, text, mediaUrl, mediaAccess, mediaLocalRoots, mediaReadFile, payload, deps, onDeliveryResult, threadId }) => {
1207
647
  const deliveryTarget = resolveMSTeamsThreadTarget(to, threadId);
1208
648
  const presentationCard = (0, openclaw_plugin_sdk_string_coerce_runtime.asOptionalRecord)(payload.channelData?.msteams)?.presentationCard;
1209
- if (presentationCard && typeof presentationCard === "object" && !Array.isArray(presentationCard)) return (0, openclaw_plugin_sdk_channel_send_result.attachChannelToResult)("msteams", await sendAdaptiveCardMSTeams({
649
+ if (presentationCard && typeof presentationCard === "object" && !Array.isArray(presentationCard)) return (0, openclaw_plugin_sdk_channel_send_result.attachChannelToResult)("msteams", toMSTeamsOutboundResult(await require_send.sendAdaptiveCardMSTeams({
1210
650
  cfg,
1211
651
  to: deliveryTarget,
1212
652
  card: presentationCard
1213
- }));
653
+ })));
1214
654
  const mediaUrls = (0, openclaw_plugin_sdk_string_normalization_runtime.normalizeStringEntries)((0, openclaw_plugin_sdk_reply_payload.resolvePayloadMediaUrls)({
1215
655
  ...payload,
1216
656
  mediaUrl: payload.mediaUrl ?? mediaUrl
@@ -1224,7 +664,7 @@ const msteamsOutbound = {
1224
664
  text,
1225
665
  mediaUrls,
1226
666
  onResult: async (deliveryResult) => {
1227
- await onDeliveryResult?.((0, openclaw_plugin_sdk_channel_send_result.attachChannelToResult)("msteams", deliveryResult));
667
+ await onDeliveryResult?.((0, openclaw_plugin_sdk_channel_send_result.attachChannelToResult)("msteams", toMSTeamsOutboundResult(deliveryResult)));
1228
668
  },
1229
669
  send: async ({ text: textLocal, mediaUrl: mediaUrlLocal }) => await send(deliveryTarget, textLocal, {
1230
670
  mediaUrl: mediaUrlLocal,
@@ -1233,7 +673,7 @@ const msteamsOutbound = {
1233
673
  mediaReadFile
1234
674
  })
1235
675
  });
1236
- if (result) return (0, openclaw_plugin_sdk_channel_send_result.attachChannelToResult)("msteams", result);
676
+ if (result) return (0, openclaw_plugin_sdk_channel_send_result.attachChannelToResult)("msteams", toMSTeamsOutboundResult(result));
1237
677
  }
1238
678
  if (text.trim()) {
1239
679
  const send = resolveMSTeamsTextSend({
@@ -1244,22 +684,22 @@ const msteamsOutbound = {
1244
684
  let result;
1245
685
  for (const chunk of chunks) {
1246
686
  result = await send(deliveryTarget, chunk);
1247
- await onDeliveryResult?.((0, openclaw_plugin_sdk_channel_send_result.attachChannelToResult)("msteams", result));
687
+ await onDeliveryResult?.((0, openclaw_plugin_sdk_channel_send_result.attachChannelToResult)("msteams", toMSTeamsOutboundResult(result)));
1248
688
  }
1249
- return (0, openclaw_plugin_sdk_channel_send_result.attachChannelToResult)("msteams", result);
689
+ return (0, openclaw_plugin_sdk_channel_send_result.attachChannelToResult)("msteams", toMSTeamsOutboundResult(result));
1250
690
  }
1251
691
  throw new Error("MS Teams payload send requires text, media, or a presentation card.");
1252
692
  },
1253
693
  ...(0, openclaw_plugin_sdk_channel_send_result.createAttachedChannelResultAdapter)({
1254
694
  channel: "msteams",
1255
695
  sendText: async ({ cfg, to, text, deps, threadId }) => {
1256
- return await resolveMSTeamsTextSend({
696
+ return toMSTeamsOutboundResult(await resolveMSTeamsTextSend({
1257
697
  cfg,
1258
698
  deps
1259
- })(resolveMSTeamsThreadTarget(to, threadId), text);
699
+ })(resolveMSTeamsThreadTarget(to, threadId), text));
1260
700
  },
1261
701
  sendMedia: async ({ cfg, to, text, mediaUrl, mediaAccess, mediaLocalRoots, mediaReadFile, deps, threadId }) => {
1262
- return await resolveMSTeamsMediaSend({
702
+ return toMSTeamsOutboundResult(await resolveMSTeamsMediaSend({
1263
703
  cfg,
1264
704
  deps
1265
705
  })(resolveMSTeamsThreadTarget(to, threadId), text, {
@@ -1267,11 +707,11 @@ const msteamsOutbound = {
1267
707
  mediaAccess,
1268
708
  mediaLocalRoots,
1269
709
  mediaReadFile
1270
- });
710
+ }));
1271
711
  },
1272
712
  sendPoll: async ({ cfg, to, poll, threadId }) => {
1273
713
  const maxSelections = poll.maxSelections ?? 1;
1274
- const result = await sendPollMSTeams({
714
+ const result = await require_send.sendPollMSTeams({
1275
715
  cfg,
1276
716
  to: resolveMSTeamsThreadTarget(to, threadId),
1277
717
  question: poll.question,
@@ -1345,7 +785,7 @@ async function probeMSTeams(cfg) {
1345
785
  } catch (err) {
1346
786
  graph = {
1347
787
  ok: false,
1348
- error: require_setup_surface.formatUnknownError(err)
788
+ error: require_channel_setup.formatUnknownError(err)
1349
789
  };
1350
790
  }
1351
791
  let delegatedAuth;
@@ -1379,7 +819,7 @@ async function probeMSTeams(cfg) {
1379
819
  return {
1380
820
  ok: false,
1381
821
  appId: creds.appId,
1382
- error: require_setup_surface.formatUnknownError(err)
822
+ error: require_channel_setup.formatUnknownError(err)
1383
823
  };
1384
824
  }
1385
825
  }
@@ -1387,8 +827,8 @@ async function probeMSTeams(cfg) {
1387
827
  //#region extensions/msteams/src/channel.runtime.ts
1388
828
  const msTeamsChannelRuntime = {
1389
829
  addParticipantMSTeams,
1390
- deleteMessageMSTeams,
1391
- editMessageMSTeams,
830
+ deleteMessageMSTeams: require_send.deleteMessageMSTeams,
831
+ editMessageMSTeams: require_send.editMessageMSTeams,
1392
832
  getChannelInfoMSTeams,
1393
833
  getMemberInfoMSTeams,
1394
834
  getMessageMSTeams,
@@ -1406,8 +846,8 @@ const msTeamsChannelRuntime = {
1406
846
  listMSTeamsDirectoryPeersLive,
1407
847
  msteamsOutbound: { ...msteamsOutbound },
1408
848
  probeMSTeams,
1409
- sendAdaptiveCardMSTeams,
1410
- sendMessageMSTeams
849
+ sendAdaptiveCardMSTeams: require_send.sendAdaptiveCardMSTeams,
850
+ sendMessageMSTeams: require_send.sendMessageMSTeams
1411
851
  };
1412
852
  //#endregion
1413
853
  exports.msTeamsChannelRuntime = msTeamsChannelRuntime;