@openclaw/msteams 2026.5.12 → 2026.5.14-beta.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.
@@ -1,134 +0,0 @@
1
- import { O as resolveNestedAllowlistDecision, S as normalizeChannelSlug, T as resolveChannelEntryMatchWithFallback, _ as isDangerousNameMatchingEnabled, i as buildChannelKeyCandidates, k as resolveToolsBySender, w as resolveAllowlistMatchSimple } from "./runtime-api-C3EIaIpt.js";
2
- //#region extensions/msteams/src/policy.ts
3
- function resolveMSTeamsRouteConfig(params) {
4
- const teamId = params.teamId?.trim();
5
- const teamName = params.teamName?.trim();
6
- const conversationId = params.conversationId?.trim();
7
- const channelName = params.channelName?.trim();
8
- const teams = params.cfg?.teams ?? {};
9
- const allowlistConfigured = Object.keys(teams).length > 0;
10
- const teamMatch = resolveChannelEntryMatchWithFallback({
11
- entries: teams,
12
- keys: buildChannelKeyCandidates(teamId, params.allowNameMatching ? teamName : void 0, params.allowNameMatching && teamName ? normalizeChannelSlug(teamName) : void 0),
13
- wildcardKey: "*",
14
- normalizeKey: normalizeChannelSlug
15
- });
16
- const teamConfig = teamMatch.entry;
17
- const channels = teamConfig?.channels ?? {};
18
- const channelAllowlistConfigured = Object.keys(channels).length > 0;
19
- const channelMatch = resolveChannelEntryMatchWithFallback({
20
- entries: channels,
21
- keys: buildChannelKeyCandidates(conversationId, params.allowNameMatching ? channelName : void 0, params.allowNameMatching && channelName ? normalizeChannelSlug(channelName) : void 0),
22
- wildcardKey: "*",
23
- normalizeKey: normalizeChannelSlug
24
- });
25
- const channelConfig = channelMatch.entry;
26
- return {
27
- teamConfig,
28
- channelConfig,
29
- allowlistConfigured,
30
- allowed: resolveNestedAllowlistDecision({
31
- outerConfigured: allowlistConfigured,
32
- outerMatched: Boolean(teamConfig),
33
- innerConfigured: channelAllowlistConfigured,
34
- innerMatched: Boolean(channelConfig)
35
- }),
36
- teamKey: teamMatch.matchKey ?? teamMatch.key,
37
- channelKey: channelMatch.matchKey ?? channelMatch.key,
38
- channelMatchKey: channelMatch.matchKey,
39
- channelMatchSource: channelMatch.matchSource === "direct" || channelMatch.matchSource === "wildcard" ? channelMatch.matchSource : void 0
40
- };
41
- }
42
- function resolveMSTeamsGroupToolPolicy(params) {
43
- const cfg = params.cfg.channels?.msteams;
44
- if (!cfg) return;
45
- const groupId = params.groupId?.trim();
46
- const groupChannel = params.groupChannel?.trim();
47
- const groupSpace = params.groupSpace?.trim();
48
- const allowNameMatching = isDangerousNameMatchingEnabled(cfg);
49
- const resolved = resolveMSTeamsRouteConfig({
50
- cfg,
51
- teamId: groupSpace,
52
- teamName: groupSpace,
53
- conversationId: groupId,
54
- channelName: groupChannel,
55
- allowNameMatching
56
- });
57
- if (resolved.channelConfig) {
58
- const senderPolicy = resolveToolsBySender({
59
- toolsBySender: resolved.channelConfig.toolsBySender,
60
- senderId: params.senderId,
61
- senderName: params.senderName,
62
- senderUsername: params.senderUsername,
63
- senderE164: params.senderE164
64
- });
65
- if (senderPolicy) return senderPolicy;
66
- if (resolved.channelConfig.tools) return resolved.channelConfig.tools;
67
- const teamSenderPolicy = resolveToolsBySender({
68
- toolsBySender: resolved.teamConfig?.toolsBySender,
69
- senderId: params.senderId,
70
- senderName: params.senderName,
71
- senderUsername: params.senderUsername,
72
- senderE164: params.senderE164
73
- });
74
- if (teamSenderPolicy) return teamSenderPolicy;
75
- return resolved.teamConfig?.tools;
76
- }
77
- if (resolved.teamConfig) {
78
- const teamSenderPolicy = resolveToolsBySender({
79
- toolsBySender: resolved.teamConfig.toolsBySender,
80
- senderId: params.senderId,
81
- senderName: params.senderName,
82
- senderUsername: params.senderUsername,
83
- senderE164: params.senderE164
84
- });
85
- if (teamSenderPolicy) return teamSenderPolicy;
86
- if (resolved.teamConfig.tools) return resolved.teamConfig.tools;
87
- }
88
- if (!groupId) return;
89
- const channelCandidates = buildChannelKeyCandidates(groupId, allowNameMatching ? groupChannel : void 0, allowNameMatching && groupChannel ? normalizeChannelSlug(groupChannel) : void 0);
90
- for (const teamConfig of Object.values(cfg.teams ?? {})) {
91
- const match = resolveChannelEntryMatchWithFallback({
92
- entries: teamConfig?.channels ?? {},
93
- keys: channelCandidates,
94
- wildcardKey: "*",
95
- normalizeKey: normalizeChannelSlug
96
- });
97
- if (match.entry) {
98
- const senderPolicy = resolveToolsBySender({
99
- toolsBySender: match.entry.toolsBySender,
100
- senderId: params.senderId,
101
- senderName: params.senderName,
102
- senderUsername: params.senderUsername,
103
- senderE164: params.senderE164
104
- });
105
- if (senderPolicy) return senderPolicy;
106
- if (match.entry.tools) return match.entry.tools;
107
- const teamSenderPolicy = resolveToolsBySender({
108
- toolsBySender: teamConfig?.toolsBySender,
109
- senderId: params.senderId,
110
- senderName: params.senderName,
111
- senderUsername: params.senderUsername,
112
- senderE164: params.senderE164
113
- });
114
- if (teamSenderPolicy) return teamSenderPolicy;
115
- return teamConfig?.tools;
116
- }
117
- }
118
- }
119
- function resolveMSTeamsAllowlistMatch(params) {
120
- return resolveAllowlistMatchSimple(params);
121
- }
122
- function resolveMSTeamsReplyPolicy(params) {
123
- if (params.isDirectMessage) return {
124
- requireMention: false,
125
- replyStyle: "thread"
126
- };
127
- const requireMention = params.channelConfig?.requireMention ?? params.teamConfig?.requireMention ?? params.globalConfig?.requireMention ?? true;
128
- return {
129
- requireMention,
130
- replyStyle: params.channelConfig?.replyStyle ?? params.teamConfig?.replyStyle ?? params.globalConfig?.replyStyle ?? (requireMention ? "thread" : "top-level")
131
- };
132
- }
133
- //#endregion
134
- export { resolveMSTeamsRouteConfig as i, resolveMSTeamsGroupToolPolicy as n, resolveMSTeamsReplyPolicy as r, resolveMSTeamsAllowlistMatch as t };
@@ -1,219 +0,0 @@
1
- import { c as normalizeQuery, f as resolveGraphToken, o as listChannelsForTeam, s as listTeamsByName, t as searchGraphUsers } from "./graph-users-BQJvcsX8.js";
2
- import { mapAllowlistResolutionInputs } from "openclaw/plugin-sdk/allow-from";
3
- import { normalizeLowercaseStringOrEmpty, normalizeOptionalLowercaseString } from "openclaw/plugin-sdk/string-coerce-runtime";
4
- //#region extensions/msteams/src/resolve-allowlist.ts
5
- function stripProviderPrefix(raw) {
6
- return raw.replace(/^(msteams|teams):/i, "");
7
- }
8
- function normalizeMSTeamsMessagingTarget(raw) {
9
- let trimmed = raw.trim();
10
- if (!trimmed) return;
11
- trimmed = stripProviderPrefix(trimmed).trim();
12
- if (/^conversation:/i.test(trimmed)) {
13
- const id = trimmed.slice(13).trim();
14
- return id ? `conversation:${id}` : void 0;
15
- }
16
- if (/^user:/i.test(trimmed)) {
17
- const id = trimmed.slice(5).trim();
18
- return id ? `user:${id}` : void 0;
19
- }
20
- return trimmed || void 0;
21
- }
22
- function normalizeMSTeamsUserInput(raw) {
23
- return stripProviderPrefix(raw).replace(/^(user|conversation):/i, "").trim();
24
- }
25
- function parseMSTeamsConversationId(raw) {
26
- const trimmed = stripProviderPrefix(raw).trim();
27
- if (!/^conversation:/i.test(trimmed)) return null;
28
- return trimmed.slice(13).trim();
29
- }
30
- /**
31
- * Detect whether a raw target string looks like a Microsoft Teams conversation
32
- * or user id that cron announce delivery and other explicit-target paths can
33
- * forward verbatim to the channel adapter.
34
- *
35
- * Accepts both prefixed and bare formats:
36
- * - `conversation:<id>` — explicit conversation prefix
37
- * - `user:<aad-guid>` — user id (16+ hex chars, UUID-like)
38
- * - `19:abc@thread.tacv2` / `19:abc@thread.skype` — channel / legacy group
39
- * - `19:{userId}_{appId}@unq.gbl.spaces` — Graph 1:1 chat thread format
40
- * - `a:1xxx` — Bot Framework personal (1:1) chat id
41
- * - `8:orgid:xxx` — Bot Framework org-scoped personal chat id
42
- * - `29:xxx` — Bot Framework user id
43
- *
44
- * Display-name user targets such as `user:John Smith` intentionally return
45
- * false so that the Graph API directory lookup still runs for them.
46
- */
47
- function looksLikeMSTeamsTargetId(raw) {
48
- const trimmed = raw.trim();
49
- if (!trimmed) return false;
50
- if (/^conversation:/i.test(trimmed)) return true;
51
- if (/^user:/i.test(trimmed)) {
52
- const id = trimmed.slice(5).trim();
53
- return /^[0-9a-fA-F-]{16,}$/.test(id);
54
- }
55
- if (/^19:.+@thread\.(tacv2|skype)$/i.test(trimmed)) return true;
56
- if (/^19:.+@unq\.gbl\.spaces$/i.test(trimmed)) return true;
57
- if (/^a:1[A-Za-z0-9_-]+$/i.test(trimmed)) return true;
58
- if (/^8:orgid:[A-Za-z0-9-]+$/i.test(trimmed)) return true;
59
- if (/^29:[A-Za-z0-9_-]+$/i.test(trimmed)) return true;
60
- return /@thread\b/i.test(trimmed);
61
- }
62
- function normalizeMSTeamsTeamKey(raw) {
63
- return stripProviderPrefix(raw).replace(/^team:/i, "").trim() || void 0;
64
- }
65
- function normalizeMSTeamsChannelKey(raw) {
66
- return (raw?.trim().replace(/^#/, "").trim() ?? "") || void 0;
67
- }
68
- function normalizeMSTeamsConversationTargetId(raw) {
69
- const trimmed = stripProviderPrefix(raw).trim();
70
- return parseMSTeamsConversationId(trimmed) ?? trimmed;
71
- }
72
- function looksLikeMSTeamsThreadConversationId(raw) {
73
- const normalized = normalizeMSTeamsConversationTargetId(raw);
74
- return /^19:.+@thread\./i.test(normalized);
75
- }
76
- function parseMSTeamsTeamChannelInput(raw) {
77
- const trimmed = stripProviderPrefix(raw).trim();
78
- if (!trimmed) return {};
79
- const parts = trimmed.split("/");
80
- const team = normalizeMSTeamsTeamKey(parts[0] ?? "");
81
- const channel = parts.length > 1 ? normalizeMSTeamsChannelKey(parts.slice(1).join("/")) : void 0;
82
- return {
83
- ...team ? { team } : {},
84
- ...channel ? { channel } : {}
85
- };
86
- }
87
- function parseMSTeamsTeamEntry(raw) {
88
- const { team, channel } = parseMSTeamsTeamChannelInput(raw);
89
- if (!team) return null;
90
- return {
91
- teamKey: team,
92
- ...channel ? { channelKey: channel } : {}
93
- };
94
- }
95
- async function resolveMSTeamsChannelAllowlist(params) {
96
- let tokenPromise;
97
- const getToken = () => {
98
- tokenPromise ??= resolveGraphToken(params.cfg);
99
- return tokenPromise;
100
- };
101
- return await mapAllowlistResolutionInputs({
102
- inputs: params.entries,
103
- mapInput: async (input) => {
104
- const { team, channel } = parseMSTeamsTeamChannelInput(input);
105
- if (!team) return {
106
- input,
107
- resolved: false
108
- };
109
- if (looksLikeMSTeamsThreadConversationId(team)) {
110
- const teamId = normalizeMSTeamsConversationTargetId(team);
111
- if (!channel) return {
112
- input,
113
- resolved: true,
114
- teamId,
115
- teamName: teamId
116
- };
117
- if (!looksLikeMSTeamsThreadConversationId(channel)) return {
118
- input,
119
- resolved: false,
120
- teamId,
121
- teamName: teamId,
122
- note: "channel id required for conversation-id team"
123
- };
124
- const channelId = normalizeMSTeamsConversationTargetId(channel);
125
- return {
126
- input,
127
- resolved: true,
128
- teamId,
129
- teamName: teamId,
130
- channelId,
131
- channelName: channelId
132
- };
133
- }
134
- const token = await getToken();
135
- const teams = /^[0-9a-fA-F-]{16,}$/.test(team) ? [{
136
- id: team,
137
- displayName: team
138
- }] : await listTeamsByName(token, team);
139
- if (teams.length === 0) return {
140
- input,
141
- resolved: false,
142
- note: "team not found"
143
- };
144
- const teamMatch = teams[0];
145
- const graphTeamId = teamMatch.id?.trim();
146
- const teamName = teamMatch.displayName?.trim() || team;
147
- if (!graphTeamId) return {
148
- input,
149
- resolved: false,
150
- note: "team id missing"
151
- };
152
- let teamChannels = [];
153
- try {
154
- teamChannels = await listChannelsForTeam(token, graphTeamId);
155
- } catch {}
156
- const teamId = teamChannels.find((ch) => normalizeOptionalLowercaseString(ch.displayName) === "general")?.id?.trim() || graphTeamId;
157
- if (!channel) return {
158
- input,
159
- resolved: true,
160
- teamId,
161
- teamName,
162
- note: teams.length > 1 ? "multiple teams; chose first" : void 0
163
- };
164
- const normalizedChannel = normalizeOptionalLowercaseString(channel);
165
- const channelMatch = teamChannels.find((item) => item.id === channel) ?? teamChannels.find((item) => normalizeOptionalLowercaseString(item.displayName) === normalizedChannel) ?? teamChannels.find((item) => normalizeLowercaseStringOrEmpty(item.displayName ?? "").includes(normalizedChannel ?? ""));
166
- if (!channelMatch?.id) return {
167
- input,
168
- resolved: false,
169
- note: "channel not found"
170
- };
171
- return {
172
- input,
173
- resolved: true,
174
- teamId,
175
- teamName,
176
- channelId: channelMatch.id,
177
- channelName: channelMatch.displayName ?? channel,
178
- note: teamChannels.length > 1 ? "multiple channels; chose first" : void 0
179
- };
180
- }
181
- });
182
- }
183
- async function resolveMSTeamsUserAllowlist(params) {
184
- const token = await resolveGraphToken(params.cfg);
185
- return await mapAllowlistResolutionInputs({
186
- inputs: params.entries,
187
- mapInput: async (input) => {
188
- const query = normalizeQuery(normalizeMSTeamsUserInput(input));
189
- if (!query) return {
190
- input,
191
- resolved: false
192
- };
193
- if (/^[0-9a-fA-F-]{16,}$/.test(query)) return {
194
- input,
195
- resolved: true,
196
- id: query
197
- };
198
- const users = await searchGraphUsers({
199
- token,
200
- query,
201
- top: 10
202
- });
203
- const match = users[0];
204
- if (!match?.id) return {
205
- input,
206
- resolved: false
207
- };
208
- return {
209
- input,
210
- resolved: true,
211
- id: match.id,
212
- name: match.displayName ?? void 0,
213
- note: users.length > 1 ? "multiple matches; chose first" : void 0
214
- };
215
- }
216
- });
217
- }
218
- //#endregion
219
- export { parseMSTeamsTeamChannelInput as a, resolveMSTeamsUserAllowlist as c, parseMSTeamsConversationId as i, normalizeMSTeamsMessagingTarget as n, parseMSTeamsTeamEntry as o, normalizeMSTeamsUserInput as r, resolveMSTeamsChannelAllowlist as s, looksLikeMSTeamsTargetId as t };