@kodelyth/msteams 2026.5.39 → 2026.6.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,2 @@
1
+ import { t as MSTeamsChannelConfigSchema } from "./config-schema-Btk-XCOd.js";
2
+ export { MSTeamsChannelConfigSchema };
@@ -0,0 +1,2 @@
1
+ import { t as msteamsPlugin } from "./channel-BvTXHuGs.js";
2
+ export { msteamsPlugin };
@@ -0,0 +1,650 @@
1
+ import { s as chunkTextForOutbound } from "./runtime-api-BL4DOWXD.js";
2
+ import { a as fetchGraphJson, c as normalizeQuery, d as postGraphJson, f as resolveGraphToken, i as fetchGraphAbsoluteUrl, l as patchGraphJson, n as deleteGraphRequest, o as listChannelsForTeam, r as escapeOData, s as listTeamsByName, t as searchGraphUsers, u as postGraphBetaJson } from "./graph-users-D-gKCguI.js";
3
+ import { n as MSTEAMS_PRESENTATION_CAPABILITIES, r as buildMSTeamsPresentationCard } from "./channel-BvTXHuGs.js";
4
+ import { S as createMSTeamsConversationStoreFs, a as sendMessageMSTeams, b as createMSTeamsPollStoreFs, i as sendAdaptiveCardMSTeams, n as deleteMessageMSTeams, o as sendPollMSTeams, r as editMessageMSTeams, t as probeMSTeams } from "./probe-Cj2KsAGF.js";
5
+ import { normalizeLowercaseStringOrEmpty } from "klaw/plugin-sdk/string-coerce-runtime";
6
+ import { resolvePayloadMediaUrls, resolveTextChunksWithFallback, sendPayloadMediaSequence } from "klaw/plugin-sdk/reply-payload";
7
+ import { attachChannelToResult, createAttachedChannelResultAdapter } from "klaw/plugin-sdk/channel-send-result";
8
+ import { resolveOutboundSendDep } from "klaw/plugin-sdk/outbound-send-deps";
9
+ //#region extensions/msteams/src/directory-live.ts
10
+ async function listMSTeamsDirectoryPeersLive(params) {
11
+ const query = normalizeQuery(params.query);
12
+ if (!query) return [];
13
+ return (await searchGraphUsers({
14
+ token: await resolveGraphToken(params.cfg),
15
+ query,
16
+ top: typeof params.limit === "number" && params.limit > 0 ? params.limit : 20
17
+ })).map((user) => {
18
+ const id = user.id?.trim();
19
+ if (!id) return null;
20
+ const name = user.displayName?.trim();
21
+ const handle = user.userPrincipalName?.trim() || user.mail?.trim();
22
+ return {
23
+ kind: "user",
24
+ id: `user:${id}`,
25
+ name: name || void 0,
26
+ handle: handle ? `@${handle}` : void 0,
27
+ raw: user
28
+ };
29
+ }).filter(Boolean);
30
+ }
31
+ async function listMSTeamsDirectoryGroupsLive(params) {
32
+ const rawQuery = normalizeQuery(params.query);
33
+ if (!rawQuery) return [];
34
+ const token = await resolveGraphToken(params.cfg);
35
+ const limit = typeof params.limit === "number" && params.limit > 0 ? params.limit : 20;
36
+ const [teamQuery, channelQuery] = rawQuery.includes("/") ? rawQuery.split("/", 2).map((part) => part.trim()).filter(Boolean) : [rawQuery, null];
37
+ const teams = await listTeamsByName(token, teamQuery);
38
+ const results = [];
39
+ for (const team of teams) {
40
+ const teamId = team.id?.trim();
41
+ if (!teamId) continue;
42
+ const teamName = team.displayName?.trim() || teamQuery;
43
+ if (!channelQuery) {
44
+ results.push({
45
+ kind: "group",
46
+ id: `team:${teamId}`,
47
+ name: teamName,
48
+ handle: teamName ? `#${teamName}` : void 0,
49
+ raw: team
50
+ });
51
+ if (results.length >= limit) return results;
52
+ continue;
53
+ }
54
+ const channels = await listChannelsForTeam(token, teamId);
55
+ for (const channel of channels) {
56
+ const name = channel.displayName?.trim();
57
+ if (!name) continue;
58
+ if (!normalizeLowercaseStringOrEmpty(name).includes(normalizeLowercaseStringOrEmpty(channelQuery))) continue;
59
+ results.push({
60
+ kind: "group",
61
+ id: `conversation:${channel.id}`,
62
+ name: `${teamName}/${name}`,
63
+ handle: `#${name}`,
64
+ raw: channel
65
+ });
66
+ if (results.length >= limit) return results;
67
+ }
68
+ }
69
+ return results;
70
+ }
71
+ //#endregion
72
+ //#region extensions/msteams/src/graph-messages.ts
73
+ /**
74
+ * Resolve the Graph API path prefix for a conversation.
75
+ * If `to` contains "/" it's a `teamId/channelId` (channel path),
76
+ * otherwise it's a chat ID.
77
+ */
78
+ /**
79
+ * Strip common target prefixes (`conversation:`, `user:`) so raw
80
+ * conversation IDs can be used directly in Graph paths.
81
+ */
82
+ function stripTargetPrefix(raw) {
83
+ const trimmed = raw.trim();
84
+ if (/^conversation:/i.test(trimmed)) return trimmed.slice(13).trim();
85
+ if (/^user:/i.test(trimmed)) return trimmed.slice(5).trim();
86
+ return trimmed;
87
+ }
88
+ /**
89
+ * Resolve a target to a Graph-compatible conversation ID.
90
+ * `user:<aadId>` targets are looked up in the conversation store to find the
91
+ * actual `19:xxx@thread.*` chat ID that Graph API requires.
92
+ * Conversation IDs and `teamId/channelId` pairs pass through unchanged.
93
+ */
94
+ async function resolveGraphConversationId(to) {
95
+ const trimmed = to.trim();
96
+ const isUserTarget = /^user:/i.test(trimmed);
97
+ const cleaned = stripTargetPrefix(trimmed);
98
+ if (!isUserTarget) return cleaned;
99
+ const found = await createMSTeamsConversationStoreFs().findPreferredDmByUserId(cleaned);
100
+ if (!found) throw new Error(`No conversation found for user:${cleaned}. The bot must receive a message from this user before Graph API operations work.`);
101
+ if (found.reference.graphChatId) return found.reference.graphChatId;
102
+ if (found.conversationId.startsWith("19:")) return found.conversationId;
103
+ throw new Error(`Conversation for user:${cleaned} uses a Bot Framework ID (${found.conversationId}) that Graph API does not accept. Send a message to this user first so the Graph chat ID is cached.`);
104
+ }
105
+ function resolveConversationPath(to) {
106
+ const cleaned = stripTargetPrefix(to);
107
+ if (cleaned.includes("/")) {
108
+ const [teamId, channelId] = cleaned.split("/", 2);
109
+ return {
110
+ kind: "channel",
111
+ basePath: `/teams/${encodeURIComponent(teamId)}/channels/${encodeURIComponent(channelId)}`,
112
+ teamId,
113
+ channelId
114
+ };
115
+ }
116
+ return {
117
+ kind: "chat",
118
+ basePath: `/chats/${encodeURIComponent(cleaned)}`,
119
+ chatId: cleaned
120
+ };
121
+ }
122
+ /**
123
+ * Retrieve a single message by ID from a chat or channel via Graph API.
124
+ */
125
+ async function getMessageMSTeams(params) {
126
+ const token = await resolveGraphToken(params.cfg);
127
+ const { basePath } = resolveConversationPath(await resolveGraphConversationId(params.to));
128
+ const msg = await fetchGraphJson({
129
+ token,
130
+ path: `${basePath}/messages/${encodeURIComponent(params.messageId)}`
131
+ });
132
+ return {
133
+ id: msg.id ?? params.messageId,
134
+ text: msg.body?.content,
135
+ from: msg.from,
136
+ createdAt: msg.createdDateTime
137
+ };
138
+ }
139
+ /**
140
+ * Pin a message in a chat conversation via Graph API.
141
+ *
142
+ * Chat pinning uses the v1.0 endpoint: `POST /chats/{chatId}/pinnedMessages`.
143
+ *
144
+ * Channel pinning uses `POST /teams/{teamId}/channels/{channelId}/pinnedMessages`.
145
+ * **Note:** The channel pin endpoint may require the Graph beta API or specific
146
+ * tenant-level permissions. As of March 2026, general availability is not
147
+ * confirmed for all tenants. If the call returns 404 or 403, the endpoint may
148
+ * not be enabled for the target tenant.
149
+ */
150
+ async function pinMessageMSTeams(params) {
151
+ const token = await resolveGraphToken(params.cfg);
152
+ const conversationId = await resolveGraphConversationId(params.to);
153
+ const conv = resolveConversationPath(conversationId);
154
+ if (conv.kind === "channel") throw new Error("Pin/unpin is not supported for channel messages on Graph v1.0. Only chat conversations support pinned messages.");
155
+ const body = { "message@odata.bind": `https://graph.microsoft.com/v1.0/chats/${encodeURIComponent(conversationId)}/messages/${encodeURIComponent(params.messageId)}` };
156
+ return {
157
+ ok: true,
158
+ pinnedMessageId: (await postGraphJson({
159
+ token,
160
+ path: `${conv.basePath}/pinnedMessages`,
161
+ body
162
+ })).id
163
+ };
164
+ }
165
+ /**
166
+ * Unpin a message in a chat conversation via Graph API.
167
+ * `pinnedMessageId` is the pinned-message resource ID (from pin or list-pins),
168
+ * not the underlying chat message ID.
169
+ *
170
+ * Channel unpin uses `DELETE /teams/{teamId}/channels/{channelId}/pinnedMessages/{id}`.
171
+ * See the note on {@link pinMessageMSTeams} regarding beta/GA status.
172
+ */
173
+ async function unpinMessageMSTeams(params) {
174
+ const token = await resolveGraphToken(params.cfg);
175
+ const conv = resolveConversationPath(await resolveGraphConversationId(params.to));
176
+ if (conv.kind === "channel") throw new Error("Pin/unpin is not supported for channel messages on Graph v1.0. Only chat conversations support pinned messages.");
177
+ await deleteGraphRequest({
178
+ token,
179
+ path: `${conv.basePath}/pinnedMessages/${encodeURIComponent(params.pinnedMessageId)}`
180
+ });
181
+ return { ok: true };
182
+ }
183
+ /** Maximum number of pagination pages to follow to avoid unbounded loops. */
184
+ const LIST_PINS_MAX_PAGES = 10;
185
+ /**
186
+ * List all pinned messages in a chat conversation via Graph API.
187
+ * Follows `@odata.nextLink` pagination to collect the full pin set.
188
+ *
189
+ * Channel list-pins uses the same endpoint pattern as channel pin/unpin.
190
+ * See the note on {@link pinMessageMSTeams} regarding beta/GA status.
191
+ */
192
+ async function listPinsMSTeams(params) {
193
+ const token = await resolveGraphToken(params.cfg);
194
+ const conv = resolveConversationPath(await resolveGraphConversationId(params.to));
195
+ if (conv.kind === "channel") throw new Error("Listing pinned messages is not supported for channels on Graph v1.0. Only chat conversations support pinned messages.");
196
+ const path = `${conv.basePath}/pinnedMessages?$expand=message`;
197
+ const allPins = [];
198
+ let res = await fetchGraphJson({
199
+ token,
200
+ path
201
+ });
202
+ let pages = 1;
203
+ while (true) {
204
+ for (const pin of res.value ?? []) allPins.push({
205
+ id: pin.id ?? "",
206
+ pinnedMessageId: pin.id ?? "",
207
+ messageId: pin.message?.id,
208
+ text: pin.message?.body?.content
209
+ });
210
+ const nextLink = res["@odata.nextLink"];
211
+ if (!nextLink || pages >= LIST_PINS_MAX_PAGES) break;
212
+ res = await fetchGraphAbsoluteUrl({
213
+ token,
214
+ url: nextLink
215
+ });
216
+ pages++;
217
+ }
218
+ return { pins: allPins };
219
+ }
220
+ const TEAMS_REACTION_TYPES = [
221
+ "like",
222
+ "heart",
223
+ "laugh",
224
+ "surprised",
225
+ "sad",
226
+ "angry"
227
+ ];
228
+ /** Map well-known reaction type names to representative emoji for CLI display. */
229
+ const REACTION_TYPE_EMOJI = {
230
+ like: "👍",
231
+ heart: "❤️",
232
+ laugh: "😆",
233
+ surprised: "😮",
234
+ sad: "😢",
235
+ angry: "😡"
236
+ };
237
+ /**
238
+ * Normalize a reaction type string. Graph setReaction/unsetReaction accepts
239
+ * the well-known legacy names (like, heart, laugh, surprised, sad, angry)
240
+ * as well as Unicode emoji values — so we pass unknown types through rather
241
+ * than rejecting them.
242
+ */
243
+ function normalizeReactionType(raw) {
244
+ const normalized = raw.trim();
245
+ if (!normalized) throw new Error(`Reaction type is required. Common types: ${TEAMS_REACTION_TYPES.join(", ")}`);
246
+ const lowered = normalized.toLowerCase();
247
+ if (TEAMS_REACTION_TYPES.includes(lowered)) return lowered;
248
+ return normalized;
249
+ }
250
+ /**
251
+ * Add an emoji reaction to a message via Graph API (beta).
252
+ *
253
+ * Writes (setReaction) require a Delegated token, so we pass
254
+ * `preferDelegated: true`. The resolver falls back to the app-only token when
255
+ * delegated auth is not configured, preserving today's behavior while letting
256
+ * delegated-auth-enabled deployments hit the user-scoped endpoint.
257
+ */
258
+ async function reactMessageMSTeams(params) {
259
+ const reactionType = normalizeReactionType(params.reactionType);
260
+ const token = await resolveGraphToken(params.cfg, { preferDelegated: true });
261
+ const { basePath } = resolveConversationPath(await resolveGraphConversationId(params.to));
262
+ await postGraphBetaJson({
263
+ token,
264
+ path: `${basePath}/messages/${encodeURIComponent(params.messageId)}/setReaction`,
265
+ body: { reactionType }
266
+ });
267
+ return { ok: true };
268
+ }
269
+ /**
270
+ * Remove an emoji reaction from a message via Graph API (beta).
271
+ *
272
+ * Writes (unsetReaction) require a Delegated token, so we pass
273
+ * `preferDelegated: true`. See `reactMessageMSTeams` for fallback rules.
274
+ */
275
+ async function unreactMessageMSTeams(params) {
276
+ const reactionType = normalizeReactionType(params.reactionType);
277
+ const token = await resolveGraphToken(params.cfg, { preferDelegated: true });
278
+ const { basePath } = resolveConversationPath(await resolveGraphConversationId(params.to));
279
+ await postGraphBetaJson({
280
+ token,
281
+ path: `${basePath}/messages/${encodeURIComponent(params.messageId)}/unsetReaction`,
282
+ body: { reactionType }
283
+ });
284
+ return { ok: true };
285
+ }
286
+ /**
287
+ * List reactions on a message, grouped by type.
288
+ * Uses Graph v1.0 (reactions are included in the message resource).
289
+ */
290
+ async function listReactionsMSTeams(params) {
291
+ const token = await resolveGraphToken(params.cfg);
292
+ const { basePath } = resolveConversationPath(await resolveGraphConversationId(params.to));
293
+ const msg = await fetchGraphJson({
294
+ token,
295
+ path: `${basePath}/messages/${encodeURIComponent(params.messageId)}`
296
+ });
297
+ const grouped = /* @__PURE__ */ new Map();
298
+ for (const reaction of msg.reactions ?? []) {
299
+ const type = reaction.reactionType ?? "unknown";
300
+ if (!grouped.has(type)) grouped.set(type, {
301
+ count: 0,
302
+ users: []
303
+ });
304
+ const group = grouped.get(type);
305
+ group.count++;
306
+ if (reaction.user?.id) group.users.push({
307
+ id: reaction.user.id,
308
+ displayName: reaction.user.displayName
309
+ });
310
+ }
311
+ return { reactions: Array.from(grouped.entries()).map(([type, group]) => ({
312
+ reactionType: type,
313
+ name: type,
314
+ emoji: REACTION_TYPE_EMOJI[type],
315
+ count: group.count,
316
+ users: group.users
317
+ })) };
318
+ }
319
+ const SEARCH_DEFAULT_LIMIT = 25;
320
+ const SEARCH_MAX_LIMIT = 50;
321
+ /**
322
+ * Search messages in a chat or channel by content via Graph API.
323
+ * Uses `$search` for full-text body search and optional `$filter` for sender.
324
+ */
325
+ async function searchMessagesMSTeams(params) {
326
+ const token = await resolveGraphToken(params.cfg);
327
+ const { basePath } = resolveConversationPath(await resolveGraphConversationId(params.to));
328
+ const rawLimit = params.limit ?? SEARCH_DEFAULT_LIMIT;
329
+ const top = Number.isFinite(rawLimit) ? Math.min(Math.max(Math.floor(rawLimit), 1), SEARCH_MAX_LIMIT) : SEARCH_DEFAULT_LIMIT;
330
+ const sanitizedQuery = params.query.replace(/"/g, "");
331
+ const parts = [`$search=${encodeURIComponent(`"${sanitizedQuery}"`)}`];
332
+ parts.push(`$top=${top}`);
333
+ if (params.from) parts.push(`$filter=${encodeURIComponent(`from/user/displayName eq '${escapeOData(params.from)}'`)}`);
334
+ return { messages: ((await fetchGraphJson({
335
+ token,
336
+ path: `${basePath}/messages?${parts.join("&")}`,
337
+ headers: { ConsistencyLevel: "eventual" }
338
+ })).value ?? []).map((msg) => ({
339
+ id: msg.id ?? "",
340
+ text: msg.body?.content,
341
+ from: msg.from,
342
+ createdAt: msg.createdDateTime
343
+ })) };
344
+ }
345
+ //#endregion
346
+ //#region extensions/msteams/src/graph-group-management.ts
347
+ function normalizeConversationMemberRole(role) {
348
+ const normalized = role?.trim().toLowerCase() ?? "";
349
+ if (!normalized) return "member";
350
+ if (normalized === "member" || normalized === "owner") return normalized;
351
+ throw new Error("MS Teams participant role must be \"member\" or \"owner\".");
352
+ }
353
+ /**
354
+ * Add a user to a chat or channel via Graph API.
355
+ */
356
+ async function addParticipantMSTeams(params) {
357
+ const token = await resolveGraphToken(params.cfg);
358
+ const conversationId = await resolveGraphConversationId(params.to);
359
+ const conv = resolveConversationPath(conversationId);
360
+ const body = {
361
+ "@odata.type": "#microsoft.graph.aadUserConversationMember",
362
+ roles: [normalizeConversationMemberRole(params.role)],
363
+ "user@odata.bind": `https://graph.microsoft.com/v1.0/users('${escapeOData(params.userId)}')`
364
+ };
365
+ await postGraphJson({
366
+ token,
367
+ path: `${conv.basePath}/members`,
368
+ body
369
+ });
370
+ return { added: {
371
+ userId: params.userId,
372
+ chatId: conversationId
373
+ } };
374
+ }
375
+ /**
376
+ * Remove a user from a chat or channel via Graph API.
377
+ * Lists members first to resolve the membership ID, then deletes.
378
+ */
379
+ async function removeParticipantMSTeams(params) {
380
+ const token = await resolveGraphToken(params.cfg);
381
+ const conversationId = await resolveGraphConversationId(params.to);
382
+ const conv = resolveConversationPath(conversationId);
383
+ const MAX_PAGES = 10;
384
+ let nextPath = `${conv.basePath}/members`;
385
+ let page = 0;
386
+ let member;
387
+ while (nextPath && page < MAX_PAGES && !member) {
388
+ const membersRes = await fetchGraphJson({
389
+ token,
390
+ path: nextPath
391
+ });
392
+ member = (membersRes.value ?? []).find((candidate) => candidate.userId === params.userId);
393
+ if (member) break;
394
+ const nextLink = membersRes["@odata.nextLink"];
395
+ nextPath = nextLink ? nextLink.replace("https://graph.microsoft.com/v1.0", "") : void 0;
396
+ page++;
397
+ }
398
+ if (!member?.id) throw new Error(`User ${params.userId} is not a member of this conversation`);
399
+ await deleteGraphRequest({
400
+ token,
401
+ path: `${conv.basePath}/members/${encodeURIComponent(member.id)}`
402
+ });
403
+ return { removed: {
404
+ userId: params.userId,
405
+ chatId: conversationId
406
+ } };
407
+ }
408
+ /**
409
+ * Rename a chat (topic) or channel (displayName) via Graph API.
410
+ */
411
+ async function renameGroupMSTeams(params) {
412
+ const token = await resolveGraphToken(params.cfg);
413
+ const conversationId = await resolveGraphConversationId(params.to);
414
+ const conv = resolveConversationPath(conversationId);
415
+ const body = conv.kind === "chat" ? { topic: params.name } : { displayName: params.name };
416
+ await patchGraphJson({
417
+ token,
418
+ path: conv.basePath,
419
+ body
420
+ });
421
+ return { renamed: {
422
+ chatId: conversationId,
423
+ newName: params.name
424
+ } };
425
+ }
426
+ //#endregion
427
+ //#region extensions/msteams/src/graph-members.ts
428
+ /**
429
+ * Fetch a user profile from Microsoft Graph by user ID.
430
+ */
431
+ async function getMemberInfoMSTeams(params) {
432
+ const user = await fetchGraphJson({
433
+ token: await resolveGraphToken(params.cfg),
434
+ path: `/users/${encodeURIComponent(params.userId)}?$select=id,displayName,mail,jobTitle,userPrincipalName,officeLocation`
435
+ });
436
+ return { user: {
437
+ id: user.id,
438
+ displayName: user.displayName,
439
+ mail: user.mail,
440
+ jobTitle: user.jobTitle,
441
+ userPrincipalName: user.userPrincipalName,
442
+ officeLocation: user.officeLocation
443
+ } };
444
+ }
445
+ //#endregion
446
+ //#region extensions/msteams/src/graph-teams.ts
447
+ /**
448
+ * List channels in a team via Graph API.
449
+ * Returns id, displayName, description, and membershipType for each channel.
450
+ * Follows @odata.nextLink for paginated results (up to 10 pages).
451
+ */
452
+ async function listChannelsMSTeams(params) {
453
+ const token = await resolveGraphToken(params.cfg);
454
+ const firstPath = `/teams/${encodeURIComponent(params.teamId)}/channels?$select=id,displayName,description,membershipType`;
455
+ const collected = [];
456
+ let nextPath = firstPath;
457
+ const MAX_PAGES = 10;
458
+ let page = 0;
459
+ while (nextPath && page < MAX_PAGES) {
460
+ const res = await fetchGraphJson({
461
+ token,
462
+ path: nextPath
463
+ });
464
+ collected.push(...res.value ?? []);
465
+ const nextLink = res["@odata.nextLink"];
466
+ nextPath = nextLink ? nextLink.replace("https://graph.microsoft.com/v1.0", "") : void 0;
467
+ page++;
468
+ }
469
+ return {
470
+ channels: collected.map((ch) => ({
471
+ id: ch.id,
472
+ displayName: ch.displayName,
473
+ description: ch.description,
474
+ membershipType: ch.membershipType
475
+ })),
476
+ truncated: !!nextPath
477
+ };
478
+ }
479
+ /**
480
+ * Get detailed information about a single channel in a team via Graph API.
481
+ * Returns id, displayName, description, membershipType, webUrl, and createdDateTime.
482
+ */
483
+ async function getChannelInfoMSTeams(params) {
484
+ const ch = await fetchGraphJson({
485
+ token: await resolveGraphToken(params.cfg),
486
+ path: `/teams/${encodeURIComponent(params.teamId)}/channels/${encodeURIComponent(params.channelId)}?$select=id,displayName,description,membershipType,webUrl,createdDateTime`
487
+ });
488
+ return { channel: {
489
+ id: ch.id,
490
+ displayName: ch.displayName,
491
+ description: ch.description,
492
+ membershipType: ch.membershipType,
493
+ webUrl: ch.webUrl,
494
+ createdDateTime: ch.createdDateTime
495
+ } };
496
+ }
497
+ //#endregion
498
+ //#region extensions/msteams/src/outbound.ts
499
+ function asObjectRecord(value) {
500
+ return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
501
+ }
502
+ const MSTEAMS_TEXT_CHUNK_LIMIT = 4e3;
503
+ //#endregion
504
+ //#region extensions/msteams/src/channel.runtime.ts
505
+ const msTeamsChannelRuntime = {
506
+ addParticipantMSTeams,
507
+ deleteMessageMSTeams,
508
+ editMessageMSTeams,
509
+ getChannelInfoMSTeams,
510
+ getMemberInfoMSTeams,
511
+ getMessageMSTeams,
512
+ listChannelsMSTeams,
513
+ listPinsMSTeams,
514
+ listReactionsMSTeams,
515
+ pinMessageMSTeams,
516
+ reactMessageMSTeams,
517
+ removeParticipantMSTeams,
518
+ renameGroupMSTeams,
519
+ searchMessagesMSTeams,
520
+ unpinMessageMSTeams,
521
+ unreactMessageMSTeams,
522
+ listMSTeamsDirectoryGroupsLive,
523
+ listMSTeamsDirectoryPeersLive,
524
+ msteamsOutbound: {
525
+ deliveryMode: "direct",
526
+ chunker: chunkTextForOutbound,
527
+ chunkerMode: "markdown",
528
+ textChunkLimit: MSTEAMS_TEXT_CHUNK_LIMIT,
529
+ pollMaxOptions: 12,
530
+ deliveryCapabilities: { durableFinal: {
531
+ text: true,
532
+ media: true,
533
+ payload: true,
534
+ messageSendingHooks: true
535
+ } },
536
+ presentationCapabilities: MSTEAMS_PRESENTATION_CAPABILITIES,
537
+ renderPresentation: ({ payload, presentation }) => {
538
+ if (payload.mediaUrl || payload.mediaUrls?.length) return null;
539
+ const card = buildMSTeamsPresentationCard({
540
+ presentation,
541
+ text: payload.text
542
+ });
543
+ const msteamsData = asObjectRecord(payload.channelData?.msteams) ?? {};
544
+ return {
545
+ ...payload,
546
+ channelData: {
547
+ ...payload.channelData,
548
+ msteams: {
549
+ ...msteamsData,
550
+ presentationCard: card
551
+ }
552
+ }
553
+ };
554
+ },
555
+ sendPayload: async ({ cfg, to, text, mediaUrl, mediaLocalRoots, mediaReadFile, payload, deps }) => {
556
+ const presentationCard = asObjectRecord(payload.channelData?.msteams)?.presentationCard;
557
+ if (presentationCard && typeof presentationCard === "object" && !Array.isArray(presentationCard)) return attachChannelToResult("msteams", await sendAdaptiveCardMSTeams({
558
+ cfg,
559
+ to,
560
+ card: presentationCard
561
+ }));
562
+ const mediaUrls = resolvePayloadMediaUrls({
563
+ ...payload,
564
+ mediaUrl: payload.mediaUrl ?? mediaUrl
565
+ }).map((url) => url.trim()).filter(Boolean);
566
+ if (mediaUrls.length > 0) {
567
+ const send = resolveOutboundSendDep(deps, "msteams") ?? ((to, text, opts) => sendMessageMSTeams({
568
+ cfg,
569
+ to,
570
+ text,
571
+ mediaUrl: opts?.mediaUrl,
572
+ mediaLocalRoots: opts?.mediaLocalRoots,
573
+ mediaReadFile: opts?.mediaReadFile
574
+ }));
575
+ const result = await sendPayloadMediaSequence({
576
+ text,
577
+ mediaUrls,
578
+ send: async ({ text, mediaUrl }) => await send(to, text, {
579
+ mediaUrl,
580
+ mediaLocalRoots,
581
+ mediaReadFile
582
+ })
583
+ });
584
+ if (result) return attachChannelToResult("msteams", result);
585
+ }
586
+ if (text.trim()) {
587
+ const send = resolveOutboundSendDep(deps, "msteams") ?? ((to, text) => sendMessageMSTeams({
588
+ cfg,
589
+ to,
590
+ text
591
+ }));
592
+ const chunks = resolveTextChunksWithFallback(text, chunkTextForOutbound(text, MSTEAMS_TEXT_CHUNK_LIMIT));
593
+ let result;
594
+ for (const chunk of chunks) result = await send(to, chunk);
595
+ return attachChannelToResult("msteams", result);
596
+ }
597
+ throw new Error("MS Teams payload send requires text, media, or a presentation card.");
598
+ },
599
+ ...createAttachedChannelResultAdapter({
600
+ channel: "msteams",
601
+ sendText: async ({ cfg, to, text, deps }) => {
602
+ return await (resolveOutboundSendDep(deps, "msteams") ?? ((to, text) => sendMessageMSTeams({
603
+ cfg,
604
+ to,
605
+ text
606
+ })))(to, text);
607
+ },
608
+ sendMedia: async ({ cfg, to, text, mediaUrl, mediaLocalRoots, mediaReadFile, deps }) => {
609
+ return await (resolveOutboundSendDep(deps, "msteams") ?? ((to, text, opts) => sendMessageMSTeams({
610
+ cfg,
611
+ to,
612
+ text,
613
+ mediaUrl: opts?.mediaUrl,
614
+ mediaLocalRoots: opts?.mediaLocalRoots,
615
+ mediaReadFile: opts?.mediaReadFile
616
+ })))(to, text, {
617
+ mediaUrl,
618
+ mediaLocalRoots,
619
+ mediaReadFile
620
+ });
621
+ },
622
+ sendPoll: async ({ cfg, to, poll }) => {
623
+ const maxSelections = poll.maxSelections ?? 1;
624
+ const result = await sendPollMSTeams({
625
+ cfg,
626
+ to,
627
+ question: poll.question,
628
+ options: poll.options,
629
+ maxSelections
630
+ });
631
+ await createMSTeamsPollStoreFs().createPoll({
632
+ id: result.pollId,
633
+ question: poll.question,
634
+ options: poll.options,
635
+ maxSelections,
636
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
637
+ conversationId: result.conversationId,
638
+ messageId: result.messageId,
639
+ votes: {}
640
+ });
641
+ return result;
642
+ }
643
+ })
644
+ },
645
+ probeMSTeams,
646
+ sendAdaptiveCardMSTeams,
647
+ sendMessageMSTeams
648
+ };
649
+ //#endregion
650
+ export { msTeamsChannelRuntime };
@@ -0,0 +1,43 @@
1
+ import { MSTeamsConfigSchema, buildChannelConfigSchema } from "klaw/plugin-sdk/bundled-channel-config-schema";
2
+ //#endregion
3
+ //#region extensions/msteams/src/config-schema.ts
4
+ const MSTeamsChannelConfigSchema = buildChannelConfigSchema(MSTeamsConfigSchema, { uiHints: {
5
+ "": {
6
+ label: "MS Teams",
7
+ help: "Microsoft Teams channel provider configuration and provider-specific policy toggles. Use this section to isolate Teams behavior from other enterprise chat providers."
8
+ },
9
+ configWrites: {
10
+ label: "MS Teams Config Writes",
11
+ help: "Allow Microsoft Teams to write config in response to channel events/commands (default: true)."
12
+ },
13
+ streaming: {
14
+ label: "MS Teams Streaming",
15
+ help: "Microsoft Teams preview/progress streaming mode: \"off\" | \"partial\" | \"block\" | \"progress\". Personal chats use Teams native streaminfo progress when available."
16
+ },
17
+ "streaming.progress.label": {
18
+ label: "MS Teams Progress Label",
19
+ help: "Initial progress title. Use \"auto\" for built-in single-word labels, a custom string, or false to hide the title."
20
+ },
21
+ "streaming.progress.labels": {
22
+ label: "MS Teams Progress Label Pool",
23
+ help: "Candidate labels for streaming.progress.label=\"auto\". Leave unset to use Klaw built-in progress labels."
24
+ },
25
+ "streaming.progress.maxLines": {
26
+ label: "MS Teams Progress Max Lines",
27
+ help: "Maximum number of compact progress lines to keep below the progress title (default: 8)."
28
+ },
29
+ "streaming.progress.maxLineChars": {
30
+ label: "MS Teams Progress Max Line Chars",
31
+ help: "Maximum characters per compact progress line before truncation (default: 120). Prose cuts at word boundaries; commands and paths keep useful suffixes."
32
+ },
33
+ "streaming.progress.toolProgress": {
34
+ label: "MS Teams Progress Tool Lines",
35
+ help: "Show compact tool/progress lines in progress mode (default: true). Set false to keep only the title until final delivery."
36
+ },
37
+ "streaming.progress.commandText": {
38
+ label: "MS Teams Progress Command Text",
39
+ help: "Command/exec detail in progress lines: \"raw\" preserves released behavior; \"status\" shows only the tool label."
40
+ }
41
+ } });
42
+ //#endregion
43
+ export { MSTeamsChannelConfigSchema as t };