@kodelyth/msteams 2026.5.42 → 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.
Files changed (177) hide show
  1. package/klaw.plugin.json +726 -2
  2. package/package.json +16 -4
  3. package/api.ts +0 -3
  4. package/channel-config-api.ts +0 -1
  5. package/channel-plugin-api.ts +0 -2
  6. package/config-api.ts +0 -4
  7. package/contract-api.ts +0 -4
  8. package/index.ts +0 -20
  9. package/runtime-api.ts +0 -66
  10. package/secret-contract-api.ts +0 -5
  11. package/setup-entry.ts +0 -13
  12. package/setup-plugin-api.ts +0 -3
  13. package/src/ai-entity.ts +0 -7
  14. package/src/approval-auth.ts +0 -44
  15. package/src/attachments/bot-framework.test.ts +0 -506
  16. package/src/attachments/bot-framework.ts +0 -348
  17. package/src/attachments/download.ts +0 -328
  18. package/src/attachments/graph.test.ts +0 -441
  19. package/src/attachments/graph.ts +0 -489
  20. package/src/attachments/html.ts +0 -122
  21. package/src/attachments/payload.ts +0 -14
  22. package/src/attachments/remote-media.test.ts +0 -187
  23. package/src/attachments/remote-media.ts +0 -86
  24. package/src/attachments/shared.test.ts +0 -547
  25. package/src/attachments/shared.ts +0 -655
  26. package/src/attachments/types.ts +0 -47
  27. package/src/attachments.graph.test.ts +0 -414
  28. package/src/attachments.helpers.test.ts +0 -245
  29. package/src/attachments.test-helpers.ts +0 -17
  30. package/src/attachments.test.ts +0 -754
  31. package/src/attachments.ts +0 -18
  32. package/src/block-streaming-config.test.ts +0 -61
  33. package/src/channel-api.ts +0 -1
  34. package/src/channel.actions.test.ts +0 -797
  35. package/src/channel.directory.test.ts +0 -176
  36. package/src/channel.message-adapter.test.ts +0 -227
  37. package/src/channel.runtime.ts +0 -56
  38. package/src/channel.setup.ts +0 -77
  39. package/src/channel.test.ts +0 -136
  40. package/src/channel.ts +0 -1176
  41. package/src/config-schema.ts +0 -6
  42. package/src/config-ui-hints.ts +0 -40
  43. package/src/conversation-store-fs.test.ts +0 -81
  44. package/src/conversation-store-fs.ts +0 -149
  45. package/src/conversation-store-helpers.test.ts +0 -202
  46. package/src/conversation-store-helpers.ts +0 -105
  47. package/src/conversation-store-memory.ts +0 -51
  48. package/src/conversation-store.shared.test.ts +0 -260
  49. package/src/conversation-store.ts +0 -71
  50. package/src/directory-live.test.ts +0 -156
  51. package/src/directory-live.ts +0 -111
  52. package/src/doctor.ts +0 -27
  53. package/src/errors.test.ts +0 -154
  54. package/src/errors.ts +0 -270
  55. package/src/feedback-reflection-prompt.ts +0 -117
  56. package/src/feedback-reflection-store.ts +0 -113
  57. package/src/feedback-reflection.test.ts +0 -237
  58. package/src/feedback-reflection.ts +0 -268
  59. package/src/file-consent-helpers.test.ts +0 -328
  60. package/src/file-consent-helpers.ts +0 -115
  61. package/src/file-consent-invoke.ts +0 -150
  62. package/src/file-consent.test.ts +0 -378
  63. package/src/file-consent.ts +0 -223
  64. package/src/graph-chat.ts +0 -36
  65. package/src/graph-group-management.test.ts +0 -332
  66. package/src/graph-group-management.ts +0 -168
  67. package/src/graph-members.test.ts +0 -89
  68. package/src/graph-members.ts +0 -48
  69. package/src/graph-messages.actions.test.ts +0 -253
  70. package/src/graph-messages.read.test.ts +0 -391
  71. package/src/graph-messages.search.test.ts +0 -227
  72. package/src/graph-messages.test-helpers.ts +0 -50
  73. package/src/graph-messages.ts +0 -534
  74. package/src/graph-teams.test.ts +0 -222
  75. package/src/graph-teams.ts +0 -114
  76. package/src/graph-thread.test.ts +0 -252
  77. package/src/graph-thread.ts +0 -146
  78. package/src/graph-upload.test.ts +0 -253
  79. package/src/graph-upload.ts +0 -531
  80. package/src/graph-users.ts +0 -29
  81. package/src/graph.test.ts +0 -540
  82. package/src/graph.ts +0 -308
  83. package/src/inbound.test.ts +0 -221
  84. package/src/inbound.ts +0 -148
  85. package/src/index.ts +0 -4
  86. package/src/media-helpers.test.ts +0 -220
  87. package/src/media-helpers.ts +0 -105
  88. package/src/mentions.test.ts +0 -254
  89. package/src/mentions.ts +0 -114
  90. package/src/messenger.test.ts +0 -961
  91. package/src/messenger.ts +0 -608
  92. package/src/monitor-handler/access.ts +0 -136
  93. package/src/monitor-handler/inbound-media.test.ts +0 -314
  94. package/src/monitor-handler/inbound-media.ts +0 -180
  95. package/src/monitor-handler/message-handler-mock-support.test-support.ts +0 -28
  96. package/src/monitor-handler/message-handler.authz.test.ts +0 -739
  97. package/src/monitor-handler/message-handler.dm-media.test.ts +0 -54
  98. package/src/monitor-handler/message-handler.test-support.ts +0 -99
  99. package/src/monitor-handler/message-handler.thread-parent.test.ts +0 -225
  100. package/src/monitor-handler/message-handler.thread-session.test.ts +0 -132
  101. package/src/monitor-handler/message-handler.ts +0 -1003
  102. package/src/monitor-handler/reaction-handler.test.ts +0 -325
  103. package/src/monitor-handler/reaction-handler.ts +0 -122
  104. package/src/monitor-handler/thread-session.ts +0 -30
  105. package/src/monitor-handler.adaptive-card.test.ts +0 -158
  106. package/src/monitor-handler.feedback-authz.test.ts +0 -357
  107. package/src/monitor-handler.file-consent.test.ts +0 -443
  108. package/src/monitor-handler.sso.test.ts +0 -576
  109. package/src/monitor-handler.test-helpers.ts +0 -181
  110. package/src/monitor-handler.ts +0 -538
  111. package/src/monitor-handler.types.ts +0 -27
  112. package/src/monitor-types.ts +0 -6
  113. package/src/monitor.lifecycle.test.ts +0 -457
  114. package/src/monitor.test.ts +0 -119
  115. package/src/monitor.ts +0 -476
  116. package/src/oauth.flow.ts +0 -77
  117. package/src/oauth.shared.ts +0 -37
  118. package/src/oauth.test.ts +0 -350
  119. package/src/oauth.token.ts +0 -162
  120. package/src/oauth.ts +0 -130
  121. package/src/outbound.test.ts +0 -400
  122. package/src/outbound.ts +0 -198
  123. package/src/pending-uploads-fs.test.ts +0 -261
  124. package/src/pending-uploads-fs.ts +0 -235
  125. package/src/pending-uploads.test.ts +0 -186
  126. package/src/pending-uploads.ts +0 -121
  127. package/src/policy.test.ts +0 -156
  128. package/src/policy.ts +0 -245
  129. package/src/polls-store-memory.ts +0 -32
  130. package/src/polls.test.ts +0 -169
  131. package/src/polls.ts +0 -312
  132. package/src/presentation.ts +0 -93
  133. package/src/probe.test.ts +0 -79
  134. package/src/probe.ts +0 -132
  135. package/src/reply-dispatcher.test.ts +0 -543
  136. package/src/reply-dispatcher.ts +0 -523
  137. package/src/reply-stream-controller.test.ts +0 -424
  138. package/src/reply-stream-controller.ts +0 -334
  139. package/src/resolve-allowlist.test.ts +0 -253
  140. package/src/resolve-allowlist.ts +0 -309
  141. package/src/revoked-context.ts +0 -17
  142. package/src/runtime.ts +0 -12
  143. package/src/sdk-types.ts +0 -59
  144. package/src/sdk.test.ts +0 -727
  145. package/src/sdk.ts +0 -916
  146. package/src/secret-contract.ts +0 -49
  147. package/src/secret-input.ts +0 -7
  148. package/src/send-context.test.ts +0 -93
  149. package/src/send-context.ts +0 -269
  150. package/src/send.test.ts +0 -588
  151. package/src/send.ts +0 -697
  152. package/src/sent-message-cache.test.ts +0 -106
  153. package/src/sent-message-cache.ts +0 -174
  154. package/src/session-route.ts +0 -40
  155. package/src/setup-core.ts +0 -162
  156. package/src/setup-surface.test.ts +0 -175
  157. package/src/setup-surface.ts +0 -319
  158. package/src/sso-token-store.test.ts +0 -74
  159. package/src/sso-token-store.ts +0 -166
  160. package/src/sso.ts +0 -300
  161. package/src/storage.ts +0 -25
  162. package/src/store-fs.ts +0 -42
  163. package/src/streaming-message.test.ts +0 -323
  164. package/src/streaming-message.ts +0 -327
  165. package/src/test-runtime.ts +0 -16
  166. package/src/thread-parent-context.test.ts +0 -224
  167. package/src/thread-parent-context.ts +0 -159
  168. package/src/token-response.ts +0 -11
  169. package/src/token.test.ts +0 -268
  170. package/src/token.ts +0 -194
  171. package/src/user-agent.test.ts +0 -121
  172. package/src/user-agent.ts +0 -53
  173. package/src/webhook-timeouts.ts +0 -27
  174. package/src/welcome-card.test.ts +0 -104
  175. package/src/welcome-card.ts +0 -57
  176. package/test-api.ts +0 -1
  177. package/tsconfig.json +0 -16
@@ -1,523 +0,0 @@
1
- import {
2
- buildChannelProgressDraftLine,
3
- buildChannelProgressDraftLineForEntry,
4
- resolveChannelPreviewStreamMode,
5
- resolveChannelStreamingBlockEnabled,
6
- } from "klaw/plugin-sdk/channel-streaming";
7
- import { normalizeOptionalLowercaseString } from "klaw/plugin-sdk/string-coerce-runtime";
8
- import {
9
- createChannelMessageReplyPipeline,
10
- logTypingFailure,
11
- resolveChannelMediaMaxBytes,
12
- type KlawConfig,
13
- type MSTeamsReplyStyle,
14
- type RuntimeEnv,
15
- } from "../runtime-api.js";
16
- import type { MSTeamsAccessTokenProvider } from "./attachments/types.js";
17
- import type { StoredConversationReference } from "./conversation-store.js";
18
- import {
19
- classifyMSTeamsSendError,
20
- formatMSTeamsSendErrorHint,
21
- formatUnknownError,
22
- } from "./errors.js";
23
- import {
24
- buildConversationReference,
25
- type MSTeamsAdapter,
26
- type MSTeamsRenderedMessage,
27
- renderReplyPayloadsToMessages,
28
- sendMSTeamsMessages,
29
- } from "./messenger.js";
30
- import type { MSTeamsMonitorLogger } from "./monitor-types.js";
31
- import { createTeamsReplyStreamController } from "./reply-stream-controller.js";
32
- import { withRevokedProxyFallback } from "./revoked-context.js";
33
- import { getMSTeamsRuntime } from "./runtime.js";
34
- import type { MSTeamsTurnContext } from "./sdk-types.js";
35
-
36
- export { pickInformativeStatusText } from "./reply-stream-controller.js";
37
-
38
- export function createMSTeamsReplyDispatcher(params: {
39
- cfg: KlawConfig;
40
- agentId: string;
41
- sessionKey: string;
42
- accountId?: string;
43
- runtime: RuntimeEnv;
44
- log: MSTeamsMonitorLogger;
45
- adapter: MSTeamsAdapter;
46
- appId: string;
47
- conversationRef: StoredConversationReference;
48
- context: MSTeamsTurnContext;
49
- replyStyle: MSTeamsReplyStyle;
50
- textLimit: number;
51
- onSentMessageIds?: (ids: string[]) => void;
52
- tokenProvider?: MSTeamsAccessTokenProvider;
53
- sharePointSiteId?: string;
54
- }) {
55
- const core = getMSTeamsRuntime();
56
- const msteamsCfg = params.cfg.channels?.msteams;
57
- const conversationType = normalizeOptionalLowercaseString(
58
- params.conversationRef.conversation?.conversationType,
59
- );
60
- const isTypingSupported = conversationType === "personal" || conversationType === "groupchat";
61
-
62
- /**
63
- * Keepalive cadence for the typing indicator while the bot is running
64
- * (including long tool chains). Bot Framework 1:1 TurnContext proxies
65
- * expire after ~30s of inactivity; sending a typing activity every 8s
66
- * keeps the proxy alive so the post-tool reply can still land via the
67
- * turn context. Sits in the middle of the 5-10s range recommended in
68
- * #59731.
69
- */
70
- const TYPING_KEEPALIVE_INTERVAL_MS = 8_000;
71
-
72
- /**
73
- * TTL ceiling for the typing keepalive loop. The default in
74
- * createTypingCallbacks is 60s, which is too short for the Teams long tool
75
- * chains described in #59731 (60s+ total runs are common). Give tool
76
- * chains up to 10 minutes before auto-stopping the keepalive.
77
- */
78
- const TYPING_KEEPALIVE_MAX_DURATION_MS = 10 * 60_000;
79
-
80
- // Forward reference: sendTypingIndicator is built before the stream
81
- // controller exists, but the keepalive tick needs to check stream state so
82
- // we don't overlay "..." typing on the visible streaming card. The ref is
83
- // wired once the stream controller is constructed below.
84
- const streamActiveRef: { current: () => boolean } = { current: () => false };
85
-
86
- const rawSendTypingIndicator = async () => {
87
- await withRevokedProxyFallback({
88
- run: async () => {
89
- await params.context.sendActivity({ type: "typing" });
90
- },
91
- onRevoked: async () => {
92
- const baseRef = buildConversationReference(params.conversationRef);
93
- await params.adapter.continueConversation(
94
- params.appId,
95
- { ...baseRef, activityId: undefined },
96
- async (ctx) => {
97
- await ctx.sendActivity({ type: "typing" });
98
- },
99
- );
100
- },
101
- onRevokedLog: () => {
102
- params.log.debug?.("turn context revoked, sending typing via proactive messaging");
103
- },
104
- });
105
- };
106
-
107
- const sendTypingIndicator = isTypingSupported
108
- ? async () => {
109
- // While the streaming card is actively being updated the user
110
- // already sees a live indicator in the stream — don't overlay a
111
- // plain "..." typing on top of it. Between segments (tool chain)
112
- // the stream is finalized, so typing indicators are appropriate
113
- // and they are what keep the TurnContext alive. See #59731.
114
- if (streamActiveRef.current()) {
115
- return;
116
- }
117
- await rawSendTypingIndicator();
118
- }
119
- : async () => {};
120
-
121
- const { onModelSelected, typingCallbacks, ...replyPipeline } = createChannelMessageReplyPipeline({
122
- cfg: params.cfg,
123
- agentId: params.agentId,
124
- channel: "msteams",
125
- accountId: params.accountId,
126
- typing: {
127
- start: sendTypingIndicator,
128
- keepaliveIntervalMs: TYPING_KEEPALIVE_INTERVAL_MS,
129
- maxDurationMs: TYPING_KEEPALIVE_MAX_DURATION_MS,
130
- onStartError: (err) => {
131
- logTypingFailure({
132
- log: (message) => params.log.debug?.(message),
133
- channel: "msteams",
134
- action: "start",
135
- error: err,
136
- });
137
- },
138
- },
139
- });
140
-
141
- const chunkMode = core.channel.text.resolveChunkMode(params.cfg, "msteams");
142
- const tableMode = core.channel.text.resolveMarkdownTableMode({
143
- cfg: params.cfg,
144
- channel: "msteams",
145
- });
146
- const mediaMaxBytes = resolveChannelMediaMaxBytes({
147
- cfg: params.cfg,
148
- resolveChannelLimitMb: ({ cfg }) => cfg.channels?.msteams?.mediaMaxMb,
149
- });
150
- const feedbackLoopEnabled = params.cfg.channels?.msteams?.feedbackEnabled !== false;
151
- const streamController = createTeamsReplyStreamController({
152
- conversationType,
153
- context: params.context,
154
- feedbackLoopEnabled,
155
- log: params.log,
156
- msteamsConfig: msteamsCfg,
157
- progressSeed: `${params.accountId ?? "default"}:${params.conversationRef.conversation?.id ?? ""}`,
158
- });
159
- // Wire the forward-declared gate used by sendTypingIndicator.
160
- streamActiveRef.current = () => streamController.isStreamActive();
161
-
162
- const teamsStreamMode = resolveChannelPreviewStreamMode(msteamsCfg, "partial");
163
- const resolvedBlockStreamingEnabled =
164
- teamsStreamMode === "block" ? true : resolveChannelStreamingBlockEnabled(msteamsCfg);
165
- const blockStreamingEnabled = resolvedBlockStreamingEnabled ?? false;
166
- const typingIndicatorEnabled =
167
- typeof msteamsCfg?.typingIndicator === "boolean" ? msteamsCfg.typingIndicator : true;
168
-
169
- const pendingMessages: MSTeamsRenderedMessage[] = [];
170
-
171
- const sendMessages = async (messages: MSTeamsRenderedMessage[]): Promise<string[]> => {
172
- return sendMSTeamsMessages({
173
- replyStyle: params.replyStyle,
174
- adapter: params.adapter,
175
- appId: params.appId,
176
- conversationRef: params.conversationRef,
177
- context: params.context,
178
- messages,
179
- retry: {},
180
- onRetry: (event) => {
181
- params.log.debug?.("retrying send", {
182
- replyStyle: params.replyStyle,
183
- ...event,
184
- });
185
- },
186
- tokenProvider: params.tokenProvider,
187
- sharePointSiteId: params.sharePointSiteId,
188
- mediaMaxBytes,
189
- feedbackLoopEnabled,
190
- });
191
- };
192
-
193
- const queueDeliveryFailureSystemEvent = (failure: {
194
- failed: number;
195
- total: number;
196
- error: unknown;
197
- }) => {
198
- const classification = classifyMSTeamsSendError(failure.error);
199
- const errorText = formatUnknownError(failure.error);
200
- const failedAll = failure.failed >= failure.total;
201
- const summary = failedAll
202
- ? "the previous reply was not delivered"
203
- : `${failure.failed} of ${failure.total} message blocks were not delivered`;
204
- const sentences = [
205
- `Microsoft Teams delivery failed: ${summary}.`,
206
- `The user may not have received ${failedAll ? "that reply" : "the full reply"}.`,
207
- `Error: ${errorText}.`,
208
- classification.statusCode != null ? `Status: ${classification.statusCode}.` : undefined,
209
- classification.kind === "transient" || classification.kind === "throttled"
210
- ? "Retrying later may succeed."
211
- : undefined,
212
- ].filter(Boolean);
213
- core.system.enqueueSystemEvent(sentences.join(" "), {
214
- sessionKey: params.sessionKey,
215
- contextKey: `msteams:delivery-failure:${params.conversationRef.conversation?.id ?? "unknown"}`,
216
- });
217
- };
218
-
219
- const flushPendingMessages = async () => {
220
- if (pendingMessages.length === 0) {
221
- return;
222
- }
223
- const toSend = pendingMessages.splice(0);
224
- const total = toSend.length;
225
- let ids: string[];
226
- try {
227
- ids = await sendMessages(toSend);
228
- } catch (batchError) {
229
- ids = [];
230
- let failed = 0;
231
- let lastFailedError: unknown = batchError;
232
- for (const msg of toSend) {
233
- try {
234
- const msgIds = await sendMessages([msg]);
235
- ids.push(...msgIds);
236
- } catch (msgError) {
237
- failed += 1;
238
- lastFailedError = msgError;
239
- params.log.debug?.("individual message send failed, continuing with remaining blocks");
240
- }
241
- }
242
- if (failed > 0) {
243
- params.log.warn?.(`failed to deliver ${failed} of ${total} message blocks`, {
244
- failed,
245
- total,
246
- });
247
- queueDeliveryFailureSystemEvent({
248
- failed,
249
- total,
250
- error: lastFailedError,
251
- });
252
- }
253
- }
254
- if (ids.length > 0) {
255
- params.onSentMessageIds?.(ids);
256
- }
257
- };
258
-
259
- const {
260
- dispatcher,
261
- replyOptions,
262
- markDispatchIdle: baseMarkDispatchIdle,
263
- } = core.channel.reply.createReplyDispatcherWithTyping({
264
- ...replyPipeline,
265
- humanDelay: core.channel.reply.resolveHumanDelayConfig(params.cfg, params.agentId),
266
- onReplyStart: async () => {
267
- await streamController.onReplyStart();
268
- // Always start the typing keepalive loop when typing is enabled and
269
- // supported by this conversation type. The sendTypingIndicator gate
270
- // skips actual sends while the stream card is visually active, so
271
- // during the first text segment the user only sees the streaming UI.
272
- // Once the stream finalizes (between segments / during tool chains),
273
- // the loop starts sending typing activities and keeps the Bot Framework
274
- // TurnContext alive so the post-tool reply can still land. See #59731.
275
- if (typingIndicatorEnabled) {
276
- await typingCallbacks?.onReplyStart?.();
277
- }
278
- },
279
- typingCallbacks,
280
- deliver: async (payload) => {
281
- const preparedPayload = await streamController.preparePayload(payload);
282
- if (!preparedPayload) {
283
- return;
284
- }
285
-
286
- const messages = renderReplyPayloadsToMessages([preparedPayload], {
287
- textChunkLimit: params.textLimit,
288
- chunkText: true,
289
- mediaMode: "split",
290
- tableMode,
291
- chunkMode,
292
- });
293
- pendingMessages.push(...messages);
294
-
295
- // When block streaming is enabled, flush immediately so blocks are
296
- // delivered progressively instead of batching until markDispatchIdle.
297
- if (blockStreamingEnabled) {
298
- await flushPendingMessages();
299
- }
300
- },
301
- onError: (err, info) => {
302
- const errMsg = formatUnknownError(err);
303
- const classification = classifyMSTeamsSendError(err);
304
- const hint = formatMSTeamsSendErrorHint(classification);
305
- params.runtime.error?.(
306
- `msteams ${info.kind} reply failed: ${errMsg}${hint ? ` (${hint})` : ""}`,
307
- );
308
- params.log.error("reply failed", {
309
- kind: info.kind,
310
- error: errMsg,
311
- classification,
312
- hint,
313
- });
314
- },
315
- });
316
-
317
- const markDispatchIdle = (): Promise<void> => {
318
- return flushPendingMessages()
319
- .catch((err) => {
320
- const errMsg = formatUnknownError(err);
321
- const classification = classifyMSTeamsSendError(err);
322
- const hint = formatMSTeamsSendErrorHint(classification);
323
- params.runtime.error?.(`msteams flush reply failed: ${errMsg}${hint ? ` (${hint})` : ""}`);
324
- params.log.error("flush reply failed", {
325
- error: errMsg,
326
- classification,
327
- hint,
328
- });
329
- })
330
- .then(() => {
331
- return streamController.finalize().catch((err) => {
332
- params.log.debug?.("stream finalize failed", { error: formatUnknownError(err) });
333
- });
334
- })
335
- .finally(() => {
336
- baseMarkDispatchIdle();
337
- });
338
- };
339
-
340
- return {
341
- dispatcher,
342
- replyOptions: {
343
- ...replyOptions,
344
- ...(streamController.hasStream()
345
- ? {
346
- onPartialReply: (payload: { text?: string }) =>
347
- streamController.onPartialReply(payload),
348
- onToolStart: async (payload: { name?: string }) => {
349
- await streamController.noteProgressWork({ toolName: payload.name });
350
- },
351
- onItemEvent: async () => {
352
- await streamController.noteProgressWork();
353
- },
354
- onPlanUpdate: async (payload: { phase?: string }) => {
355
- if (payload.phase === "update") {
356
- await streamController.noteProgressWork();
357
- }
358
- },
359
- onApprovalEvent: async (payload: { phase?: string }) => {
360
- if (payload.phase === "requested") {
361
- await streamController.noteProgressWork();
362
- }
363
- },
364
- onCommandOutput: async (payload: { phase?: string }) => {
365
- if (payload.phase === "end") {
366
- await streamController.noteProgressWork();
367
- }
368
- },
369
- onPatchSummary: async (payload: { phase?: string }) => {
370
- if (payload.phase === "end") {
371
- await streamController.noteProgressWork();
372
- }
373
- },
374
- }
375
- : {}),
376
- ...(streamController.shouldSuppressDefaultToolProgressMessages()
377
- ? { suppressDefaultToolProgressMessages: true }
378
- : {}),
379
- ...(streamController.shouldStreamPreviewToolProgress()
380
- ? {
381
- onToolStart: async (payload: {
382
- name?: string;
383
- phase?: string;
384
- args?: Record<string, unknown>;
385
- detailMode?: "explain" | "raw";
386
- }) => {
387
- await streamController.pushProgressLine(
388
- buildChannelProgressDraftLineForEntry(
389
- msteamsCfg,
390
- {
391
- event: "tool",
392
- name: payload.name,
393
- phase: payload.phase,
394
- args: payload.args,
395
- },
396
- payload.detailMode ? { detailMode: payload.detailMode } : undefined,
397
- ),
398
- { toolName: payload.name },
399
- );
400
- },
401
- onItemEvent: async (payload: {
402
- itemId?: string;
403
- kind?: string;
404
- progressText?: string;
405
- meta?: string;
406
- summary?: string;
407
- title?: string;
408
- name?: string;
409
- phase?: string;
410
- status?: string;
411
- }) => {
412
- await streamController.pushProgressLine(
413
- buildChannelProgressDraftLineForEntry(msteamsCfg, {
414
- event: "item",
415
- itemId: payload.itemId,
416
- itemKind: payload.kind,
417
- title: payload.title,
418
- name: payload.name,
419
- phase: payload.phase,
420
- status: payload.status,
421
- summary: payload.summary,
422
- progressText: payload.progressText,
423
- meta: payload.meta,
424
- }),
425
- );
426
- },
427
- onPlanUpdate: async (payload: {
428
- phase?: string;
429
- title?: string;
430
- explanation?: string;
431
- steps?: string[];
432
- }) => {
433
- if (payload.phase !== "update") {
434
- return;
435
- }
436
- await streamController.pushProgressLine(
437
- buildChannelProgressDraftLine({
438
- event: "plan",
439
- phase: payload.phase,
440
- title: payload.title,
441
- explanation: payload.explanation,
442
- steps: payload.steps,
443
- }),
444
- );
445
- },
446
- onApprovalEvent: async (payload: {
447
- phase?: string;
448
- title?: string;
449
- command?: string;
450
- reason?: string;
451
- message?: string;
452
- }) => {
453
- if (payload.phase !== "requested") {
454
- return;
455
- }
456
- await streamController.pushProgressLine(
457
- buildChannelProgressDraftLine({
458
- event: "approval",
459
- phase: payload.phase,
460
- title: payload.title,
461
- command: payload.command,
462
- reason: payload.reason,
463
- message: payload.message,
464
- }),
465
- );
466
- },
467
- onCommandOutput: async (payload: {
468
- phase?: string;
469
- title?: string;
470
- name?: string;
471
- status?: string;
472
- exitCode?: number | null;
473
- }) => {
474
- if (payload.phase !== "end") {
475
- return;
476
- }
477
- await streamController.pushProgressLine(
478
- buildChannelProgressDraftLine({
479
- event: "command-output",
480
- phase: payload.phase,
481
- title: payload.title,
482
- name: payload.name,
483
- status: payload.status,
484
- exitCode: payload.exitCode,
485
- }),
486
- );
487
- },
488
- onPatchSummary: async (payload: {
489
- phase?: string;
490
- summary?: string;
491
- title?: string;
492
- name?: string;
493
- added?: string[];
494
- modified?: string[];
495
- deleted?: string[];
496
- }) => {
497
- if (payload.phase !== "end") {
498
- return;
499
- }
500
- await streamController.pushProgressLine(
501
- buildChannelProgressDraftLine({
502
- event: "patch",
503
- phase: payload.phase,
504
- title: payload.title,
505
- name: payload.name,
506
- added: payload.added,
507
- modified: payload.modified,
508
- deleted: payload.deleted,
509
- summary: payload.summary,
510
- }),
511
- );
512
- },
513
- }
514
- : {}),
515
- disableBlockStreaming:
516
- typeof resolvedBlockStreamingEnabled === "boolean"
517
- ? !resolvedBlockStreamingEnabled
518
- : undefined,
519
- onModelSelected,
520
- },
521
- markDispatchIdle,
522
- };
523
- }