@openclaw/msteams 2026.8.1-beta.2 → 2026.9.1-beta.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.
@@ -0,0 +1,149 @@
1
+ const require_resolve_allowlist = require("./resolve-allowlist-B6FQAa3r.cjs");
2
+ let openclaw_plugin_sdk_html_entity_runtime = require("openclaw/plugin-sdk/html-entity-runtime");
3
+ //#region extensions/msteams/src/graph-thread.ts
4
+ /**
5
+ * Strip HTML tags from Teams message content, preserving @mention display names.
6
+ * Teams wraps mentions in <at>Name</at> tags.
7
+ */
8
+ function stripHtmlFromTeamsMessage(html) {
9
+ let text = html.replace(/<at[^>]*>(.*?)<\/at>/gi, "@$1");
10
+ text = text.replace(/<[^>]*>/g, " ");
11
+ text = (0, openclaw_plugin_sdk_html_entity_runtime.decodeHtmlEntities)(text).replaceAll("\xA0", " ");
12
+ return text.replace(/\s+/g, " ").trim();
13
+ }
14
+ /**
15
+ * Fetch a single channel message (the parent/root of a thread).
16
+ * Returns undefined on error so callers can degrade gracefully.
17
+ */
18
+ async function fetchChannelMessage(token, groupId, channelId, messageId, deadline) {
19
+ const path = `/teams/${encodeURIComponent(groupId)}/channels/${encodeURIComponent(channelId)}/messages/${encodeURIComponent(messageId)}`;
20
+ try {
21
+ return await require_resolve_allowlist.fetchGraphJson({
22
+ token,
23
+ path,
24
+ ...deadline ? { deadline } : {}
25
+ });
26
+ } catch {
27
+ return;
28
+ }
29
+ }
30
+ /**
31
+ * Fetch a single chat message's full text via Graph and return plain text.
32
+ *
33
+ * Used to recover the complete quoted message for Teams quote replies: the
34
+ * inbound blockquote only carries a Teams-truncated `preview` snippet. The
35
+ * app-only `GET /chats/{chatId}/messages/{messageId}` endpoint IS permitted
36
+ * with the `Chat.Read.All` application permission.
37
+ *
38
+ * Returns undefined on any failure so callers degrade to the truncated preview.
39
+ */
40
+ async function fetchChatMessageText(token, chatId, messageId, deadline) {
41
+ const path = `/chats/${encodeURIComponent(chatId)}/messages/${encodeURIComponent(messageId)}`;
42
+ try {
43
+ const msg = await require_resolve_allowlist.fetchGraphJson({
44
+ token,
45
+ path,
46
+ ...deadline ? { deadline } : {}
47
+ });
48
+ const raw = msg.body?.content ?? "";
49
+ return (msg.body?.contentType === "html" ? stripHtmlFromTeamsMessage(raw) : raw.trim()) || void 0;
50
+ } catch {
51
+ return;
52
+ }
53
+ }
54
+ /**
55
+ * Fetch thread replies for a channel message, ordered chronologically.
56
+ *
57
+ * **Limitation:** The Graph API replies endpoint (`/messages/{id}/replies`) does not
58
+ * support `$orderby`, so results are always returned in ascending (oldest-first) order.
59
+ * Combined with the `$top` cap of 50, this means only the **oldest 50 replies** are
60
+ * returned for long threads — newer replies are silently omitted. There is currently no
61
+ * Graph API workaround for this; pagination via `@odata.nextLink` can retrieve more
62
+ * replies but still in ascending order only.
63
+ */
64
+ async function fetchThreadReplies(token, groupId, channelId, messageId, limit = 50, deadline) {
65
+ return (await require_resolve_allowlist.fetchGraphJson({
66
+ token,
67
+ path: `/teams/${encodeURIComponent(groupId)}/channels/${encodeURIComponent(channelId)}/messages/${encodeURIComponent(messageId)}/replies?$top=${Math.min(Math.max(limit, 1), 50)}`,
68
+ ...deadline ? { deadline } : {}
69
+ })).value ?? [];
70
+ }
71
+ /**
72
+ * Format thread messages into a context string for the agent.
73
+ * Skips the current message (by id) and blank messages.
74
+ */
75
+ function formatThreadContext(messages, currentMessageId) {
76
+ const lines = [];
77
+ for (const msg of messages) {
78
+ if (msg.id && msg.id === currentMessageId) continue;
79
+ const sender = msg.from?.user?.displayName ?? msg.from?.application?.displayName ?? "unknown";
80
+ const contentType = msg.body?.contentType ?? "text";
81
+ const rawContent = msg.body?.content ?? "";
82
+ const content = contentType === "html" ? stripHtmlFromTeamsMessage(rawContent) : rawContent.trim();
83
+ if (!content) continue;
84
+ lines.push(`${sender}: ${content}`);
85
+ }
86
+ return lines.join("\n");
87
+ }
88
+ //#endregion
89
+ //#region extensions/msteams/src/reaction-types.ts
90
+ const TEAMS_REACTION_EMOJI = {
91
+ like: "👍",
92
+ heart: "❤️",
93
+ laugh: "😆",
94
+ surprised: "😮",
95
+ sad: "😢",
96
+ angry: "😡"
97
+ };
98
+ const TEAMS_REACTION_TYPES = Object.keys(TEAMS_REACTION_EMOJI);
99
+ function getMSTeamsReactionEmoji(raw) {
100
+ return TEAMS_REACTION_EMOJI[raw.trim().toLowerCase()];
101
+ }
102
+ function resolveMSTeamsReactionEmoji(raw) {
103
+ const normalized = raw.trim();
104
+ if (!normalized) throw new Error(`Reaction type is required. Common types: ${TEAMS_REACTION_TYPES.join(", ")}`);
105
+ return getMSTeamsReactionEmoji(normalized) ?? normalized;
106
+ }
107
+ //#endregion
108
+ Object.defineProperty(exports, "fetchChannelMessage", {
109
+ enumerable: true,
110
+ get: function() {
111
+ return fetchChannelMessage;
112
+ }
113
+ });
114
+ Object.defineProperty(exports, "fetchChatMessageText", {
115
+ enumerable: true,
116
+ get: function() {
117
+ return fetchChatMessageText;
118
+ }
119
+ });
120
+ Object.defineProperty(exports, "fetchThreadReplies", {
121
+ enumerable: true,
122
+ get: function() {
123
+ return fetchThreadReplies;
124
+ }
125
+ });
126
+ Object.defineProperty(exports, "formatThreadContext", {
127
+ enumerable: true,
128
+ get: function() {
129
+ return formatThreadContext;
130
+ }
131
+ });
132
+ Object.defineProperty(exports, "getMSTeamsReactionEmoji", {
133
+ enumerable: true,
134
+ get: function() {
135
+ return getMSTeamsReactionEmoji;
136
+ }
137
+ });
138
+ Object.defineProperty(exports, "resolveMSTeamsReactionEmoji", {
139
+ enumerable: true,
140
+ get: function() {
141
+ return resolveMSTeamsReactionEmoji;
142
+ }
143
+ });
144
+ Object.defineProperty(exports, "stripHtmlFromTeamsMessage", {
145
+ enumerable: true,
146
+ get: function() {
147
+ return stripHtmlFromTeamsMessage;
148
+ }
149
+ });
@@ -1,78 +1,22 @@
1
1
  const require_runtime = require("./runtime-gZTAuFux.cjs");
2
2
  require("./runtime-api.cjs");
3
3
  const require_delegated_state = require("./delegated-state-DiEz9JIa.cjs");
4
+ require("./secret-input-C65t6kjM.cjs");
4
5
  let openclaw_plugin_sdk_lazy_runtime = require("openclaw/plugin-sdk/lazy-runtime");
5
6
  let openclaw_plugin_sdk_string_coerce_runtime = require("openclaw/plugin-sdk/string-coerce-runtime");
6
7
  let openclaw_plugin_sdk_allow_from = require("openclaw/plugin-sdk/allow-from");
7
- let openclaw_plugin_sdk_ssrf_runtime = require("openclaw/plugin-sdk/ssrf-runtime");
8
- let openclaw_plugin_sdk_html_entity_runtime = require("openclaw/plugin-sdk/html-entity-runtime");
9
8
  let openclaw_plugin_sdk_fetch_runtime = require("openclaw/plugin-sdk/fetch-runtime");
10
9
  let openclaw_plugin_sdk_provider_http = require("openclaw/plugin-sdk/provider-http");
10
+ let openclaw_plugin_sdk_ssrf_runtime = require("openclaw/plugin-sdk/ssrf-runtime");
11
11
  let node_buffer = require("node:buffer");
12
12
  let node_dns_promises = require("node:dns/promises");
13
13
  let openclaw_plugin_sdk_ssrf_policy = require("openclaw/plugin-sdk/ssrf-policy");
14
14
  let openclaw_plugin_sdk_number_runtime = require("openclaw/plugin-sdk/number-runtime");
15
15
  let openclaw_plugin_sdk_text_utility_runtime = require("openclaw/plugin-sdk/text-utility-runtime");
16
- let openclaw_plugin_sdk_error_runtime = require("openclaw/plugin-sdk/error-runtime");
17
16
  let openclaw_plugin_sdk_secret_file = require("openclaw/plugin-sdk/secret-file");
18
17
  let node_module = require("node:module");
18
+ let openclaw_plugin_sdk_html_entity_runtime = require("openclaw/plugin-sdk/html-entity-runtime");
19
19
  let openclaw_plugin_sdk_secret_input = require("openclaw/plugin-sdk/secret-input");
20
- //#region extensions/msteams/src/inbound.ts
21
- /**
22
- * Strip HTML tags, preserving text content.
23
- */
24
- function htmlToPlainText(html) {
25
- return (0, openclaw_plugin_sdk_html_entity_runtime.decodeHtmlEntities)(html.replace(/<[^>]*>/g, " ")).replaceAll("\xA0", " ").replace(/\s+/g, " ").trim();
26
- }
27
- /**
28
- * Extract quote info from MS Teams HTML reply attachments.
29
- * Teams wraps quoted content in a blockquote with itemtype="http://schema.skype.com/Reply".
30
- */
31
- function extractMSTeamsQuoteInfo(attachments) {
32
- for (const att of attachments) {
33
- let content = "";
34
- if (typeof att.content === "string") content = att.content;
35
- else if (typeof att.content === "object" && att.content !== null) {
36
- const record = att.content;
37
- content = typeof record.text === "string" ? record.text : typeof record.body === "string" ? record.body : "";
38
- }
39
- if (!content) continue;
40
- if (!content.includes("http://schema.skype.com/Reply")) continue;
41
- const senderMatch = /<strong[^>]*itemprop=["']mri["'][^>]*>(.*?)<\/strong>/i.exec(content);
42
- const sender = senderMatch?.[1] ? htmlToPlainText(senderMatch[1]) : void 0;
43
- const bodyMatch = /<p[^>]*itemprop=["']copy["'][^>]*>(.*?)<\/p>/is.exec(content) ?? /<p[^>]*itemprop=["']preview["'][^>]*>(.*?)<\/p>/is.exec(content);
44
- const body = bodyMatch?.[1] ? htmlToPlainText(bodyMatch[1]) : void 0;
45
- const id = /<blockquote[^>]*\bitemid=["']([^"']+)["'][^>]*>/is.exec(content)?.[1]?.trim() || void 0;
46
- if (body) return {
47
- sender: sender ?? "unknown",
48
- body,
49
- ...id ? { id } : {}
50
- };
51
- }
52
- }
53
- function normalizeMSTeamsConversationId(raw) {
54
- return raw.split(";")[0] ?? raw;
55
- }
56
- function extractMSTeamsConversationMessageId(raw) {
57
- if (!raw) return;
58
- return (/(?:^|;)messageid=([^;]+)/i.exec(raw)?.[1]?.trim() ?? "") || void 0;
59
- }
60
- function parseMSTeamsActivityTimestamp(value) {
61
- if (!value) return;
62
- if (value instanceof Date) return value;
63
- if (typeof value !== "string") return;
64
- const date = new Date(value);
65
- return Number.isNaN(date.getTime()) ? void 0 : date;
66
- }
67
- function stripMSTeamsMentionTags(text) {
68
- return text.replace(/<at[^>]*>.*?<\/at>/gi, "").trim();
69
- }
70
- function wasMSTeamsBotMentioned(activity) {
71
- const botId = activity.recipient?.id;
72
- if (!botId) return false;
73
- return (activity.entities ?? []).some((e) => e.type === "mention" && e.mentioned?.id === botId);
74
- }
75
- //#endregion
76
20
  //#region extensions/msteams/src/request-timeout.ts
77
21
  const MSTEAMS_REQUEST_TIMEOUT_MS = 3e4;
78
22
  const MSTEAMS_SHAREPOINT_UPLOAD_BASE_TIMEOUT_MS = 5 * 6e4;
@@ -210,14 +154,15 @@ const GRAPH_SHARED_LINK_HOST_SUFFIXES = [
210
154
  * than directly.
211
155
  */
212
156
  function isGraphSharedLinkUrl(url) {
213
- let host;
157
+ let parsed;
214
158
  try {
215
- host = (0, openclaw_plugin_sdk_string_coerce_runtime.normalizeLowercaseStringOrEmpty)(new URL(url).hostname);
159
+ parsed = new URL(url);
216
160
  } catch {
217
161
  return false;
218
162
  }
219
- if (!host) return false;
220
- return GRAPH_SHARED_LINK_HOST_SUFFIXES.some((suffix) => host === suffix || host.endsWith(suffix));
163
+ const host = (0, openclaw_plugin_sdk_string_coerce_runtime.normalizeLowercaseStringOrEmpty)(parsed.hostname);
164
+ if (parsed.protocol !== "https:" || !host) return false;
165
+ return GRAPH_SHARED_LINK_HOST_SUFFIXES.some((suffix) => host === suffix || host.endsWith(suffix.startsWith(".") ? suffix : `.${suffix}`));
221
166
  }
222
167
  /**
223
168
  * Encode a SharePoint/OneDrive URL as a Graph shareId using the documented
@@ -715,7 +660,7 @@ var PrivateQaHttpClient = class PrivateQaHttpClient {
715
660
  try {
716
661
  const text = await response.text();
717
662
  const data = text ? JSON.parse(text) : void 0;
718
- if (!response.ok) throw new Error(`Microsoft Teams private QA connector returned HTTP ${response.status}`);
663
+ if (!response.ok) throw Object.assign(/* @__PURE__ */ new Error(`Microsoft Teams private QA connector returned HTTP ${response.status}`), { statusCode: response.status });
719
664
  return {
720
665
  data,
721
666
  status: response.status,
@@ -879,7 +824,10 @@ async function createMSTeamsApp(creds, options) {
879
824
  ...serviceUrl ? { serviceUrl } : {},
880
825
  ...options?.oauthDefaultConnectionName ? { oauth: { defaultConnectionName: options.oauthDefaultConnectionName } } : {}
881
826
  };
882
- if (creds.type === "federated") return await createFederatedApp(creds, App, appOptions);
827
+ if (creds.type === "federated") return await createFederatedApp(creds, App, {
828
+ clientSecret: "",
829
+ ...appOptions
830
+ });
883
831
  return new App({
884
832
  clientId: creds.appId,
885
833
  clientSecret: creds.appPassword,
@@ -898,9 +846,8 @@ async function createFederatedApp(creds, App, appOptions) {
898
846
  let privateKey;
899
847
  try {
900
848
  privateKey = await (0, openclaw_plugin_sdk_secret_file.readSecretFile)(creds.certificatePath, "Microsoft Teams certificate");
901
- } catch (err) {
902
- const msg = (0, openclaw_plugin_sdk_error_runtime.coerceErrorMessage)(err);
903
- throw new Error(`Failed to read certificate file at '${creds.certificatePath}': ${msg}`, { cause: err });
849
+ } catch {
850
+ throw new Error("Failed to read certificate file: the configured credential is unavailable.");
904
851
  }
905
852
  return createCertificateApp(creds, privateKey, App, appOptions);
906
853
  }
@@ -1359,6 +1306,62 @@ async function findGraphUsersByExactIdentity(params) {
1359
1306
  });
1360
1307
  }
1361
1308
  //#endregion
1309
+ //#region extensions/msteams/src/inbound.ts
1310
+ /**
1311
+ * Strip HTML tags, preserving text content.
1312
+ */
1313
+ function htmlToPlainText(html) {
1314
+ return (0, openclaw_plugin_sdk_html_entity_runtime.decodeHtmlEntities)(html.replace(/<[^>]*>/g, " ")).replaceAll("\xA0", " ").replace(/\s+/g, " ").trim();
1315
+ }
1316
+ /**
1317
+ * Extract quote info from MS Teams HTML reply attachments.
1318
+ * Teams wraps quoted content in a blockquote with itemtype="http://schema.skype.com/Reply".
1319
+ */
1320
+ function extractMSTeamsQuoteInfo(attachments) {
1321
+ for (const att of attachments) {
1322
+ let content = "";
1323
+ if (typeof att.content === "string") content = att.content;
1324
+ else if (typeof att.content === "object" && att.content !== null) {
1325
+ const record = att.content;
1326
+ content = typeof record.text === "string" ? record.text : typeof record.body === "string" ? record.body : "";
1327
+ }
1328
+ if (!content) continue;
1329
+ if (!content.includes("http://schema.skype.com/Reply")) continue;
1330
+ const senderMatch = /<strong[^>]*itemprop=["']mri["'][^>]*>(.*?)<\/strong>/i.exec(content);
1331
+ const sender = senderMatch?.[1] ? htmlToPlainText(senderMatch[1]) : void 0;
1332
+ const bodyMatch = /<p[^>]*itemprop=["']copy["'][^>]*>(.*?)<\/p>/is.exec(content) ?? /<p[^>]*itemprop=["']preview["'][^>]*>(.*?)<\/p>/is.exec(content);
1333
+ const body = bodyMatch?.[1] ? htmlToPlainText(bodyMatch[1]) : void 0;
1334
+ const id = /<blockquote[^>]*\bitemid=["']([^"']+)["'][^>]*>/is.exec(content)?.[1]?.trim() || void 0;
1335
+ if (body) return {
1336
+ sender: sender ?? "unknown",
1337
+ body,
1338
+ ...id ? { id } : {}
1339
+ };
1340
+ }
1341
+ }
1342
+ function normalizeMSTeamsConversationId(raw) {
1343
+ return raw.split(";")[0] ?? raw;
1344
+ }
1345
+ function extractMSTeamsConversationMessageId(raw) {
1346
+ if (!raw) return;
1347
+ return (/(?:^|;)messageid=([^;]+)/i.exec(raw)?.[1]?.trim() ?? "") || void 0;
1348
+ }
1349
+ function parseMSTeamsActivityTimestamp(value) {
1350
+ if (!value) return;
1351
+ if (value instanceof Date) return value;
1352
+ if (typeof value !== "string") return;
1353
+ const date = new Date(value);
1354
+ return Number.isNaN(date.getTime()) ? void 0 : date;
1355
+ }
1356
+ function stripMSTeamsMentionTags(text) {
1357
+ return text.replace(/<at[^>]*>.*?<\/at>/gi, "").trim();
1358
+ }
1359
+ function wasMSTeamsBotMentioned(activity) {
1360
+ const botId = activity.recipient?.id;
1361
+ if (!botId) return false;
1362
+ return (activity.entities ?? []).some((e) => e.type === "mention" && e.mentioned?.id === botId);
1363
+ }
1364
+ //#endregion
1362
1365
  //#region extensions/msteams/src/resolve-allowlist.ts
1363
1366
  const MSTEAMS_GROUP_CONVERSATION_ID = /^19:.+@thread\.(?:tacv2|skype|v2)$/i;
1364
1367
  function normalizeExactMatch(value) {
@@ -3,8 +3,8 @@ const require_runtime = require("./runtime-gZTAuFux.cjs");
3
3
  let openclaw_plugin_sdk_channel_outbound = require("openclaw/plugin-sdk/channel-outbound");
4
4
  let openclaw_plugin_sdk_channel_pairing = require("openclaw/plugin-sdk/channel-pairing");
5
5
  let openclaw_plugin_sdk_channel_policy = require("openclaw/plugin-sdk/channel-policy");
6
- let openclaw_plugin_sdk_account_id = require("openclaw/plugin-sdk/account-id");
7
6
  let openclaw_plugin_sdk_allow_from = require("openclaw/plugin-sdk/allow-from");
7
+ let openclaw_plugin_sdk_account_id = require("openclaw/plugin-sdk/account-id");
8
8
  let openclaw_plugin_sdk_channel_status = require("openclaw/plugin-sdk/channel-status");
9
9
  let openclaw_plugin_sdk_channel_targets = require("openclaw/plugin-sdk/channel-targets");
10
10
  let openclaw_plugin_sdk_dangerous_name_runtime = require("openclaw/plugin-sdk/dangerous-name-runtime");
@@ -0,0 +1 @@
1
+ require("openclaw/plugin-sdk/secret-input");