@openclaw/msteams 2026.5.2 → 2026.5.3-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.
Files changed (197) hide show
  1. package/dist/api.js +3 -0
  2. package/dist/channel-D7hdreTh.js +984 -0
  3. package/dist/channel-config-api.js +2 -0
  4. package/dist/channel-plugin-api.js +2 -0
  5. package/dist/channel.runtime-BC1ruIfN.js +573 -0
  6. package/dist/config-schema-B8QezH6t.js +15 -0
  7. package/dist/contract-api.js +2 -0
  8. package/dist/graph-users-9uQJepqr.js +1354 -0
  9. package/dist/index.js +22 -0
  10. package/dist/oauth-BWJyilR1.js +114 -0
  11. package/dist/oauth.token-xxpoLWy5.js +115 -0
  12. package/dist/policy-DTnU2GR7.js +142 -0
  13. package/dist/probe-D_H8yFps.js +2194 -0
  14. package/dist/resolve-allowlist-D41JSziq.js +219 -0
  15. package/dist/runtime-api-DV1iVMn1.js +28 -0
  16. package/dist/runtime-api.js +2 -0
  17. package/dist/secret-contract-BuoEXmPS.js +35 -0
  18. package/dist/secret-contract-api.js +2 -0
  19. package/dist/setup-entry.js +15 -0
  20. package/dist/setup-plugin-api.js +64 -0
  21. package/dist/setup-surface-BLkFQYIQ.js +313 -0
  22. package/dist/src-CFp1QpFd.js +4064 -0
  23. package/dist/test-api.js +2 -0
  24. package/package.json +14 -6
  25. package/api.ts +0 -3
  26. package/channel-config-api.ts +0 -1
  27. package/channel-plugin-api.ts +0 -2
  28. package/config-api.ts +0 -4
  29. package/contract-api.ts +0 -4
  30. package/index.ts +0 -20
  31. package/runtime-api.ts +0 -73
  32. package/secret-contract-api.ts +0 -5
  33. package/setup-entry.ts +0 -13
  34. package/setup-plugin-api.ts +0 -3
  35. package/src/ai-entity.ts +0 -7
  36. package/src/approval-auth.ts +0 -44
  37. package/src/attachments/bot-framework.test.ts +0 -461
  38. package/src/attachments/bot-framework.ts +0 -362
  39. package/src/attachments/download.ts +0 -311
  40. package/src/attachments/graph.test.ts +0 -416
  41. package/src/attachments/graph.ts +0 -484
  42. package/src/attachments/html.ts +0 -122
  43. package/src/attachments/payload.ts +0 -14
  44. package/src/attachments/remote-media.test.ts +0 -137
  45. package/src/attachments/remote-media.ts +0 -112
  46. package/src/attachments/shared.test.ts +0 -530
  47. package/src/attachments/shared.ts +0 -626
  48. package/src/attachments/types.ts +0 -47
  49. package/src/attachments.graph.test.ts +0 -342
  50. package/src/attachments.helpers.test.ts +0 -246
  51. package/src/attachments.test-helpers.ts +0 -17
  52. package/src/attachments.test.ts +0 -687
  53. package/src/attachments.ts +0 -18
  54. package/src/block-streaming-config.test.ts +0 -61
  55. package/src/channel-api.ts +0 -1
  56. package/src/channel.actions.test.ts +0 -742
  57. package/src/channel.directory.test.ts +0 -200
  58. package/src/channel.runtime.ts +0 -56
  59. package/src/channel.setup.ts +0 -77
  60. package/src/channel.test.ts +0 -128
  61. package/src/channel.ts +0 -1136
  62. package/src/config-schema.ts +0 -6
  63. package/src/config-ui-hints.ts +0 -12
  64. package/src/conversation-store-fs.test.ts +0 -74
  65. package/src/conversation-store-fs.ts +0 -149
  66. package/src/conversation-store-helpers.test.ts +0 -202
  67. package/src/conversation-store-helpers.ts +0 -105
  68. package/src/conversation-store-memory.ts +0 -51
  69. package/src/conversation-store.shared.test.ts +0 -225
  70. package/src/conversation-store.ts +0 -71
  71. package/src/directory-live.test.ts +0 -156
  72. package/src/directory-live.ts +0 -111
  73. package/src/doctor.ts +0 -27
  74. package/src/errors.test.ts +0 -133
  75. package/src/errors.ts +0 -246
  76. package/src/feedback-reflection-prompt.ts +0 -117
  77. package/src/feedback-reflection-store.ts +0 -114
  78. package/src/feedback-reflection.test.ts +0 -237
  79. package/src/feedback-reflection.ts +0 -283
  80. package/src/file-consent-helpers.test.ts +0 -326
  81. package/src/file-consent-helpers.ts +0 -126
  82. package/src/file-consent-invoke.ts +0 -150
  83. package/src/file-consent.test.ts +0 -363
  84. package/src/file-consent.ts +0 -287
  85. package/src/graph-chat.ts +0 -55
  86. package/src/graph-group-management.test.ts +0 -318
  87. package/src/graph-group-management.ts +0 -168
  88. package/src/graph-members.test.ts +0 -89
  89. package/src/graph-members.ts +0 -48
  90. package/src/graph-messages.actions.test.ts +0 -243
  91. package/src/graph-messages.read.test.ts +0 -391
  92. package/src/graph-messages.search.test.ts +0 -213
  93. package/src/graph-messages.test-helpers.ts +0 -50
  94. package/src/graph-messages.ts +0 -534
  95. package/src/graph-teams.test.ts +0 -215
  96. package/src/graph-teams.ts +0 -114
  97. package/src/graph-thread.test.ts +0 -246
  98. package/src/graph-thread.ts +0 -146
  99. package/src/graph-upload.test.ts +0 -258
  100. package/src/graph-upload.ts +0 -531
  101. package/src/graph-users.ts +0 -29
  102. package/src/graph.test.ts +0 -516
  103. package/src/graph.ts +0 -293
  104. package/src/inbound.test.ts +0 -221
  105. package/src/inbound.ts +0 -148
  106. package/src/index.ts +0 -4
  107. package/src/media-helpers.test.ts +0 -202
  108. package/src/media-helpers.ts +0 -105
  109. package/src/mentions.test.ts +0 -244
  110. package/src/mentions.ts +0 -114
  111. package/src/messenger.test.ts +0 -865
  112. package/src/messenger.ts +0 -605
  113. package/src/monitor-handler/access.ts +0 -125
  114. package/src/monitor-handler/inbound-media.test.ts +0 -289
  115. package/src/monitor-handler/inbound-media.ts +0 -180
  116. package/src/monitor-handler/message-handler-mock-support.test-support.ts +0 -28
  117. package/src/monitor-handler/message-handler.authz.test.ts +0 -669
  118. package/src/monitor-handler/message-handler.dm-media.test.ts +0 -54
  119. package/src/monitor-handler/message-handler.test-support.ts +0 -100
  120. package/src/monitor-handler/message-handler.thread-parent.test.ts +0 -223
  121. package/src/monitor-handler/message-handler.thread-session.test.ts +0 -77
  122. package/src/monitor-handler/message-handler.ts +0 -1000
  123. package/src/monitor-handler/reaction-handler.test.ts +0 -267
  124. package/src/monitor-handler/reaction-handler.ts +0 -210
  125. package/src/monitor-handler/thread-session.ts +0 -17
  126. package/src/monitor-handler.adaptive-card.test.ts +0 -162
  127. package/src/monitor-handler.feedback-authz.test.ts +0 -314
  128. package/src/monitor-handler.file-consent.test.ts +0 -423
  129. package/src/monitor-handler.sso.test.ts +0 -563
  130. package/src/monitor-handler.test-helpers.ts +0 -180
  131. package/src/monitor-handler.ts +0 -534
  132. package/src/monitor-handler.types.ts +0 -27
  133. package/src/monitor-types.ts +0 -6
  134. package/src/monitor.lifecycle.test.ts +0 -278
  135. package/src/monitor.test.ts +0 -119
  136. package/src/monitor.ts +0 -442
  137. package/src/oauth.flow.ts +0 -77
  138. package/src/oauth.shared.ts +0 -37
  139. package/src/oauth.test.ts +0 -305
  140. package/src/oauth.token.ts +0 -158
  141. package/src/oauth.ts +0 -130
  142. package/src/outbound.test.ts +0 -130
  143. package/src/outbound.ts +0 -71
  144. package/src/pending-uploads-fs.test.ts +0 -246
  145. package/src/pending-uploads-fs.ts +0 -235
  146. package/src/pending-uploads.test.ts +0 -173
  147. package/src/pending-uploads.ts +0 -121
  148. package/src/policy.test.ts +0 -240
  149. package/src/policy.ts +0 -262
  150. package/src/polls-store-memory.ts +0 -32
  151. package/src/polls.test.ts +0 -160
  152. package/src/polls.ts +0 -323
  153. package/src/presentation.ts +0 -68
  154. package/src/probe.test.ts +0 -77
  155. package/src/probe.ts +0 -132
  156. package/src/reply-dispatcher.test.ts +0 -437
  157. package/src/reply-dispatcher.ts +0 -346
  158. package/src/reply-stream-controller.test.ts +0 -235
  159. package/src/reply-stream-controller.ts +0 -147
  160. package/src/resolve-allowlist.test.ts +0 -250
  161. package/src/resolve-allowlist.ts +0 -309
  162. package/src/revoked-context.ts +0 -17
  163. package/src/runtime.ts +0 -9
  164. package/src/sdk-types.ts +0 -59
  165. package/src/sdk.test.ts +0 -666
  166. package/src/sdk.ts +0 -884
  167. package/src/secret-contract.ts +0 -49
  168. package/src/secret-input.ts +0 -7
  169. package/src/send-context.ts +0 -231
  170. package/src/send.test.ts +0 -493
  171. package/src/send.ts +0 -637
  172. package/src/sent-message-cache.test.ts +0 -15
  173. package/src/sent-message-cache.ts +0 -56
  174. package/src/session-route.ts +0 -40
  175. package/src/setup-core.ts +0 -160
  176. package/src/setup-surface.test.ts +0 -202
  177. package/src/setup-surface.ts +0 -320
  178. package/src/sso-token-store.test.ts +0 -72
  179. package/src/sso-token-store.ts +0 -166
  180. package/src/sso.ts +0 -300
  181. package/src/storage.ts +0 -25
  182. package/src/store-fs.ts +0 -44
  183. package/src/streaming-message.test.ts +0 -262
  184. package/src/streaming-message.ts +0 -297
  185. package/src/test-runtime.ts +0 -16
  186. package/src/thread-parent-context.test.ts +0 -224
  187. package/src/thread-parent-context.ts +0 -159
  188. package/src/token-response.ts +0 -11
  189. package/src/token.test.ts +0 -259
  190. package/src/token.ts +0 -195
  191. package/src/user-agent.test.ts +0 -86
  192. package/src/user-agent.ts +0 -53
  193. package/src/webhook-timeouts.ts +0 -27
  194. package/src/welcome-card.test.ts +0 -81
  195. package/src/welcome-card.ts +0 -57
  196. package/test-api.ts +0 -1
  197. package/tsconfig.json +0 -16
@@ -0,0 +1,313 @@
1
+ import { O as formatUnknownError, g as saveDelegatedTokens, h as resolveMSTeamsCredentials, p as hasConfiguredMSTeamsCredentials, v as normalizeSecretInputString } from "./graph-users-9uQJepqr.js";
2
+ import { c as resolveMSTeamsUserAllowlist, o as parseMSTeamsTeamEntry, s as resolveMSTeamsChannelAllowlist } from "./resolve-allowlist-D41JSziq.js";
3
+ import { DEFAULT_ACCOUNT_ID, createStandardChannelSetupStatus, createTopLevelChannelAllowFromSetter, createTopLevelChannelDmPolicy, createTopLevelChannelGroupPolicySetter, mergeAllowFromEntries, splitSetupEntries } from "openclaw/plugin-sdk/setup";
4
+ import { formatDocsLink } from "openclaw/plugin-sdk/setup-tools";
5
+ //#region extensions/msteams/src/setup-core.ts
6
+ const msteamsSetupAdapter = {
7
+ resolveAccountId: () => DEFAULT_ACCOUNT_ID,
8
+ applyAccountConfig: ({ cfg }) => ({
9
+ ...cfg,
10
+ channels: {
11
+ ...cfg.channels,
12
+ msteams: {
13
+ ...cfg.channels?.msteams,
14
+ enabled: true
15
+ }
16
+ }
17
+ })
18
+ };
19
+ const channel$1 = "msteams";
20
+ async function promptMSTeamsCredentials(prompter) {
21
+ return {
22
+ appId: (await prompter.text({
23
+ message: "Enter MS Teams App ID",
24
+ validate: (value) => value?.trim() ? void 0 : "Required"
25
+ })).trim(),
26
+ appPassword: (await prompter.text({
27
+ message: "Enter MS Teams App Password",
28
+ validate: (value) => value?.trim() ? void 0 : "Required"
29
+ })).trim(),
30
+ tenantId: (await prompter.text({
31
+ message: "Enter MS Teams Tenant ID",
32
+ validate: (value) => value?.trim() ? void 0 : "Required"
33
+ })).trim()
34
+ };
35
+ }
36
+ async function noteMSTeamsCredentialHelp(prompter) {
37
+ await prompter.note([
38
+ "1) Azure Bot registration -> get App ID + Tenant ID",
39
+ "2) Add a client secret (App Password)",
40
+ "3) Set webhook URL + messaging endpoint",
41
+ "Tip: you can also set MSTEAMS_APP_ID / MSTEAMS_APP_PASSWORD / MSTEAMS_TENANT_ID.",
42
+ `Docs: ${formatDocsLink("/channels/msteams", "msteams")}`
43
+ ].join("\n"), "MS Teams credentials");
44
+ }
45
+ function createMSTeamsSetupWizardBase() {
46
+ return {
47
+ channel: channel$1,
48
+ resolveAccountIdForConfigure: () => DEFAULT_ACCOUNT_ID,
49
+ resolveShouldPromptAccountIds: () => false,
50
+ status: createStandardChannelSetupStatus({
51
+ channelLabel: "MS Teams",
52
+ configuredLabel: "configured",
53
+ unconfiguredLabel: "needs app credentials",
54
+ configuredHint: "configured",
55
+ unconfiguredHint: "needs app creds",
56
+ configuredScore: 2,
57
+ unconfiguredScore: 0,
58
+ includeStatusLine: true,
59
+ resolveConfigured: ({ cfg }) => Boolean(resolveMSTeamsCredentials(cfg.channels?.msteams)) || hasConfiguredMSTeamsCredentials(cfg.channels?.msteams)
60
+ }),
61
+ credentials: [],
62
+ finalize: async ({ cfg, prompter }) => {
63
+ const resolved = resolveMSTeamsCredentials(cfg.channels?.msteams);
64
+ const hasConfigCreds = hasConfiguredMSTeamsCredentials(cfg.channels?.msteams);
65
+ const canUseEnv = Boolean(!hasConfigCreds && normalizeSecretInputString(process.env.MSTEAMS_APP_ID) && normalizeSecretInputString(process.env.MSTEAMS_APP_PASSWORD) && normalizeSecretInputString(process.env.MSTEAMS_TENANT_ID));
66
+ let next = cfg;
67
+ let appId = null;
68
+ let appPassword = null;
69
+ let tenantId = null;
70
+ if (!resolved && !hasConfigCreds) await noteMSTeamsCredentialHelp(prompter);
71
+ if (canUseEnv) if (await prompter.confirm({
72
+ message: "MSTEAMS_APP_ID + MSTEAMS_APP_PASSWORD + MSTEAMS_TENANT_ID detected. Use env vars?",
73
+ initialValue: true
74
+ })) next = msteamsSetupAdapter.applyAccountConfig({
75
+ cfg: next,
76
+ accountId: DEFAULT_ACCOUNT_ID,
77
+ input: {}
78
+ });
79
+ else ({appId, appPassword, tenantId} = await promptMSTeamsCredentials(prompter));
80
+ else if (hasConfigCreds) {
81
+ if (!await prompter.confirm({
82
+ message: "MS Teams credentials already configured. Keep them?",
83
+ initialValue: true
84
+ })) ({appId, appPassword, tenantId} = await promptMSTeamsCredentials(prompter));
85
+ } else ({appId, appPassword, tenantId} = await promptMSTeamsCredentials(prompter));
86
+ if (appId && appPassword && tenantId) next = {
87
+ ...next,
88
+ channels: {
89
+ ...next.channels,
90
+ msteams: {
91
+ ...next.channels?.msteams,
92
+ enabled: true,
93
+ appId,
94
+ appPassword,
95
+ tenantId
96
+ }
97
+ }
98
+ };
99
+ return {
100
+ cfg: next,
101
+ accountId: DEFAULT_ACCOUNT_ID
102
+ };
103
+ }
104
+ };
105
+ }
106
+ //#endregion
107
+ //#region extensions/msteams/src/setup-surface.ts
108
+ const channel = "msteams";
109
+ const setMSTeamsAllowFrom = createTopLevelChannelAllowFromSetter({ channel });
110
+ const setMSTeamsGroupPolicy = createTopLevelChannelGroupPolicySetter({
111
+ channel,
112
+ enabled: true
113
+ });
114
+ function openDelegatedOAuthUrl(url) {
115
+ return Promise.reject(/* @__PURE__ */ new Error(`Automatic browser launch is not available. Open this URL manually: ${url}`));
116
+ }
117
+ function looksLikeGuid(value) {
118
+ return /^[0-9a-fA-F-]{16,}$/.test(value);
119
+ }
120
+ async function promptMSTeamsAllowFrom(params) {
121
+ const existing = params.cfg.channels?.msteams?.allowFrom ?? [];
122
+ await params.prompter.note([
123
+ "Allowlist MS Teams DMs by display name, UPN/email, or user id.",
124
+ "We resolve names to user IDs via Microsoft Graph when credentials allow.",
125
+ "Examples:",
126
+ "- alex@example.com",
127
+ "- Alex Johnson",
128
+ "- 00000000-0000-0000-0000-000000000000"
129
+ ].join("\n"), "MS Teams allowlist");
130
+ while (true) {
131
+ const parts = splitSetupEntries(await params.prompter.text({
132
+ message: "MS Teams allowFrom (usernames or ids)",
133
+ placeholder: "alex@example.com, Alex Johnson",
134
+ initialValue: existing[0] ? existing[0] : void 0,
135
+ validate: (value) => value.trim() ? void 0 : "Required"
136
+ }));
137
+ if (parts.length === 0) {
138
+ await params.prompter.note("Enter at least one user.", "MS Teams allowlist");
139
+ continue;
140
+ }
141
+ const resolved = await resolveMSTeamsUserAllowlist({
142
+ cfg: params.cfg,
143
+ entries: parts
144
+ }).catch(() => null);
145
+ if (!resolved) {
146
+ const ids = parts.filter((part) => looksLikeGuid(part));
147
+ if (ids.length !== parts.length) {
148
+ await params.prompter.note("Graph lookup unavailable. Use user IDs only.", "MS Teams allowlist");
149
+ continue;
150
+ }
151
+ const unique = mergeAllowFromEntries(existing, ids);
152
+ return setMSTeamsAllowFrom(params.cfg, unique);
153
+ }
154
+ const unresolved = resolved.filter((item) => !item.resolved || !item.id);
155
+ if (unresolved.length > 0) {
156
+ await params.prompter.note(`Could not resolve: ${unresolved.map((item) => item.input).join(", ")}`, "MS Teams allowlist");
157
+ continue;
158
+ }
159
+ const unique = mergeAllowFromEntries(existing, resolved.map((item) => item.id));
160
+ return setMSTeamsAllowFrom(params.cfg, unique);
161
+ }
162
+ }
163
+ function setMSTeamsTeamsAllowlist(cfg, entries) {
164
+ const teams = { ...cfg.channels?.msteams?.teams ?? {} };
165
+ for (const entry of entries) {
166
+ const teamKey = entry.teamKey;
167
+ if (!teamKey) continue;
168
+ const existing = teams[teamKey] ?? {};
169
+ if (entry.channelKey) {
170
+ const channels = { ...existing.channels };
171
+ channels[entry.channelKey] = channels[entry.channelKey] ?? {};
172
+ teams[teamKey] = {
173
+ ...existing,
174
+ channels
175
+ };
176
+ } else teams[teamKey] = existing;
177
+ }
178
+ return {
179
+ ...cfg,
180
+ channels: {
181
+ ...cfg.channels,
182
+ msteams: {
183
+ ...cfg.channels?.msteams,
184
+ enabled: true,
185
+ teams
186
+ }
187
+ }
188
+ };
189
+ }
190
+ function listMSTeamsGroupEntries(cfg) {
191
+ return Object.entries(cfg.channels?.msteams?.teams ?? {}).flatMap(([teamKey, value]) => {
192
+ const channels = value?.channels ?? {};
193
+ const channelKeys = Object.keys(channels);
194
+ if (channelKeys.length === 0) return [teamKey];
195
+ return channelKeys.map((channelKey) => `${teamKey}/${channelKey}`);
196
+ });
197
+ }
198
+ async function resolveMSTeamsGroupAllowlist(params) {
199
+ let resolvedEntries = params.entries.map((entry) => parseMSTeamsTeamEntry(entry)).filter(Boolean);
200
+ if (params.entries.length === 0 || !resolveMSTeamsCredentials(params.cfg.channels?.msteams)) return resolvedEntries;
201
+ try {
202
+ const lookups = await resolveMSTeamsChannelAllowlist({
203
+ cfg: params.cfg,
204
+ entries: params.entries
205
+ });
206
+ const resolvedChannels = lookups.filter((entry) => entry.resolved && entry.teamId && entry.channelId);
207
+ const resolvedTeams = lookups.filter((entry) => entry.resolved && entry.teamId && !entry.channelId);
208
+ const unresolved = lookups.filter((entry) => !entry.resolved).map((entry) => entry.input);
209
+ resolvedEntries = [
210
+ ...resolvedChannels.map((entry) => ({
211
+ teamKey: entry.teamId,
212
+ channelKey: entry.channelId
213
+ })),
214
+ ...resolvedTeams.map((entry) => ({ teamKey: entry.teamId })),
215
+ ...unresolved.map((entry) => parseMSTeamsTeamEntry(entry)).filter(Boolean)
216
+ ];
217
+ const summary = [];
218
+ if (resolvedChannels.length > 0) summary.push(`Resolved channels: ${resolvedChannels.map((entry) => entry.channelId).filter(Boolean).join(", ")}`);
219
+ if (resolvedTeams.length > 0) summary.push(`Resolved teams: ${resolvedTeams.map((entry) => entry.teamId).filter(Boolean).join(", ")}`);
220
+ if (unresolved.length > 0) summary.push(`Unresolved (kept as typed): ${unresolved.join(", ")}`);
221
+ if (summary.length > 0) await params.prompter.note(summary.join("\n"), "MS Teams channels");
222
+ return resolvedEntries;
223
+ } catch (err) {
224
+ await params.prompter.note(`Channel lookup failed; keeping entries as typed. ${formatUnknownError(err)}`, "MS Teams channels");
225
+ return resolvedEntries;
226
+ }
227
+ }
228
+ const msteamsGroupAccess = {
229
+ label: "MS Teams channels",
230
+ placeholder: "Team Name/Channel Name, teamId/conversationId",
231
+ currentPolicy: ({ cfg }) => cfg.channels?.msteams?.groupPolicy ?? "allowlist",
232
+ currentEntries: ({ cfg }) => listMSTeamsGroupEntries(cfg),
233
+ updatePrompt: ({ cfg }) => Boolean(cfg.channels?.msteams?.teams),
234
+ setPolicy: ({ cfg, policy }) => setMSTeamsGroupPolicy(cfg, policy),
235
+ resolveAllowlist: async ({ cfg, entries, prompter }) => await resolveMSTeamsGroupAllowlist({
236
+ cfg,
237
+ entries,
238
+ prompter
239
+ }),
240
+ applyAllowlist: ({ cfg, resolved }) => setMSTeamsTeamsAllowlist(cfg, resolved)
241
+ };
242
+ const msteamsDmPolicy = createTopLevelChannelDmPolicy({
243
+ label: "MS Teams",
244
+ channel,
245
+ policyKey: "channels.msteams.dmPolicy",
246
+ allowFromKey: "channels.msteams.allowFrom",
247
+ getCurrent: (cfg) => cfg.channels?.msteams?.dmPolicy ?? "pairing",
248
+ promptAllowFrom: promptMSTeamsAllowFrom
249
+ });
250
+ const msteamsSetupWizardBase = createMSTeamsSetupWizardBase();
251
+ const msteamsSetupWizard = {
252
+ ...msteamsSetupWizardBase,
253
+ finalize: async (params) => {
254
+ const baseFinalize = msteamsSetupWizardBase.finalize;
255
+ const baseResult = baseFinalize ? await baseFinalize(params) : void 0;
256
+ let next = baseResult?.cfg ?? params.cfg;
257
+ const finalCreds = resolveMSTeamsCredentials(next.channels?.msteams);
258
+ if (finalCreds?.type === "secret") {
259
+ if (await params.prompter.confirm({
260
+ message: "Enable delegated auth? (required for reactions and write operations)",
261
+ initialValue: false
262
+ })) {
263
+ next = {
264
+ ...next,
265
+ channels: {
266
+ ...next.channels,
267
+ msteams: {
268
+ ...next.channels?.msteams,
269
+ delegatedAuth: { enabled: true }
270
+ }
271
+ }
272
+ };
273
+ try {
274
+ const { loginMSTeamsDelegated } = await import("./oauth-BWJyilR1.js");
275
+ const progress = params.prompter.progress("MSTeams Delegated OAuth");
276
+ saveDelegatedTokens(await loginMSTeamsDelegated({
277
+ isRemote: true,
278
+ openUrl: openDelegatedOAuthUrl,
279
+ log: (msg) => params.prompter.note(msg),
280
+ note: (msg, title) => params.prompter.note(msg, title),
281
+ prompt: (msg) => params.prompter.text({ message: msg }),
282
+ progress
283
+ }, {
284
+ tenantId: finalCreds.tenantId,
285
+ clientId: finalCreds.appId,
286
+ clientSecret: finalCreds.appPassword
287
+ }));
288
+ progress.stop("Delegated auth configured");
289
+ } catch (err) {
290
+ await params.prompter.note(`Delegated auth setup failed: ${formatUnknownError(err)}\nYou can retry later via the setup wizard.`, "MS Teams delegated auth");
291
+ }
292
+ }
293
+ }
294
+ return {
295
+ ...baseResult,
296
+ cfg: next
297
+ };
298
+ },
299
+ dmPolicy: msteamsDmPolicy,
300
+ groupAccess: msteamsGroupAccess,
301
+ disable: (cfg) => ({
302
+ ...cfg,
303
+ channels: {
304
+ ...cfg.channels,
305
+ msteams: {
306
+ ...cfg.channels?.msteams,
307
+ enabled: false
308
+ }
309
+ }
310
+ })
311
+ };
312
+ //#endregion
313
+ export { msteamsSetupAdapter as i, openDelegatedOAuthUrl as n, createMSTeamsSetupWizardBase as r, msteamsSetupWizard as t };