@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,424 +0,0 @@
1
- import { describe, expect, it, vi } from "vitest";
2
-
3
- const streamInstances = vi.hoisted(
4
- () =>
5
- [] as Array<{
6
- hasContent: boolean;
7
- isFinalized: boolean;
8
- isFailed: boolean;
9
- streamedLength: number;
10
- messageId?: string;
11
- previewStreamId?: string;
12
- sendInformativeUpdate: ReturnType<typeof vi.fn>;
13
- update: ReturnType<typeof vi.fn>;
14
- replaceInformativeWithFinal: ReturnType<typeof vi.fn>;
15
- finalize: ReturnType<typeof vi.fn>;
16
- }>,
17
- );
18
-
19
- vi.mock("./streaming-message.js", () => ({
20
- TeamsHttpStream: class {
21
- hasContent = false;
22
- isFinalized = false;
23
- isFailed = false;
24
- streamedLength = 0;
25
- messageId: string | undefined;
26
- previewStreamId = "preview-stream";
27
- sendInformativeUpdate = vi.fn(async () => {});
28
- update = vi.fn(function (
29
- this: { hasContent: boolean; isFailed: boolean; streamedLength: number },
30
- payloadText?: string,
31
- ) {
32
- if ((payloadText?.length ?? 0) > 4000) {
33
- this.hasContent = false;
34
- this.isFailed = true;
35
- this.streamedLength = 0;
36
- return;
37
- }
38
- this.hasContent = true;
39
- this.streamedLength = payloadText?.length ?? 0;
40
- });
41
- replaceInformativeWithFinal = vi.fn(async function (
42
- this: {
43
- hasContent: boolean;
44
- isFailed: boolean;
45
- isFinalized: boolean;
46
- streamedLength: number;
47
- messageId?: string;
48
- update: (payloadText?: string) => void;
49
- },
50
- payloadText: string,
51
- ) {
52
- this.update(payloadText);
53
- if (this.isFailed) {
54
- return false;
55
- }
56
- this.isFinalized = true;
57
- this.messageId = "final-message";
58
- return this.hasContent;
59
- });
60
- finalize = vi.fn(async function (this: { isFinalized: boolean; messageId?: string }) {
61
- this.isFinalized = true;
62
- this.messageId = "final-message";
63
- });
64
-
65
- constructor() {
66
- streamInstances.push(this as never);
67
- }
68
- },
69
- }));
70
-
71
- import { createTeamsReplyStreamController } from "./reply-stream-controller.js";
72
-
73
- describe("createTeamsReplyStreamController", () => {
74
- function createController() {
75
- streamInstances.length = 0;
76
- return createTeamsReplyStreamController({
77
- conversationType: "personal",
78
- context: { sendActivity: vi.fn(async () => ({ id: "a" })) } as never,
79
- feedbackLoopEnabled: false,
80
- log: { debug: vi.fn() } as never,
81
- });
82
- }
83
-
84
- it("suppresses fallback for first text segment that was streamed", async () => {
85
- const ctrl = createController();
86
- ctrl.onPartialReply({ text: "Hello world" });
87
-
88
- const result = await ctrl.preparePayload({ text: "Hello world" });
89
- expect(result).toBeUndefined();
90
- });
91
-
92
- it("when stream fails after partial delivery, fallback sends only remaining text", async () => {
93
- const ctrl = createController();
94
- const fullText = "a".repeat(4000) + "b".repeat(200);
95
-
96
- ctrl.onPartialReply({ text: fullText });
97
- streamInstances[0].hasContent = false;
98
- streamInstances[0].isFailed = true;
99
- streamInstances[0].isFinalized = true;
100
- streamInstances[0].streamedLength = 4000;
101
-
102
- const result = await ctrl.preparePayload({ text: fullText });
103
- expect(result).toEqual({ text: "b".repeat(200) });
104
- });
105
-
106
- it("when stream fails before sending content, fallback sends full text", async () => {
107
- const ctrl = createController();
108
- const fullText = "Failure at first chunk";
109
-
110
- ctrl.onPartialReply({ text: fullText });
111
- streamInstances[0].hasContent = false;
112
- streamInstances[0].isFailed = true;
113
- streamInstances[0].isFinalized = true;
114
- streamInstances[0].streamedLength = 0;
115
-
116
- const result = await ctrl.preparePayload({ text: fullText });
117
- expect(result).toEqual({ text: fullText });
118
- });
119
-
120
- it("allows fallback delivery for second text segment after tool calls", async () => {
121
- const ctrl = createController();
122
-
123
- // First text segment: streaming tokens arrive
124
- ctrl.onPartialReply({ text: "First segment" });
125
-
126
- // First segment complete: preparePayload suppresses (stream handled it)
127
- const result1 = await ctrl.preparePayload({ text: "First segment" });
128
- expect(result1).toBeUndefined();
129
-
130
- // Tool calls happen... then second text segment arrives via deliver()
131
- // preparePayload should allow fallback delivery for this segment
132
- const result2 = await ctrl.preparePayload({ text: "Second segment after tools" });
133
- expect(result2).toEqual({ text: "Second segment after tools" });
134
- });
135
-
136
- it("finalizes the stream when suppressing first segment", async () => {
137
- const ctrl = createController();
138
- ctrl.onPartialReply({ text: "Streamed text" });
139
-
140
- await ctrl.preparePayload({ text: "Streamed text" });
141
- await ctrl.finalize();
142
-
143
- expect(streamInstances[0]?.finalize).toHaveBeenCalled();
144
- expect(ctrl.liveState().phase).toBe("finalized");
145
- expect(ctrl.liveState().receipt?.primaryPlatformMessageId).toBe("final-message");
146
- });
147
-
148
- it("uses fallback even when onPartialReply fires after stream finalized", async () => {
149
- const ctrl = createController();
150
-
151
- // First text segment: streaming tokens arrive
152
- ctrl.onPartialReply({ text: "First segment" });
153
-
154
- // First segment complete: preparePayload suppresses and finalizes stream
155
- const result1 = await ctrl.preparePayload({ text: "First segment" });
156
- expect(result1).toBeUndefined();
157
- expect(streamInstances[0]?.isFinalized).toBe(true);
158
-
159
- // Post-tool partial replies fire again (stream.update is a no-op since finalized)
160
- ctrl.onPartialReply({ text: "Second segment" });
161
-
162
- // Must still use fallback because stream is finalized and can't deliver
163
- const result2 = await ctrl.preparePayload({ text: "Second segment" });
164
- expect(result2).toEqual({ text: "Second segment" });
165
- });
166
-
167
- it("delivers all segments across 3+ tool call rounds", async () => {
168
- const ctrl = createController();
169
-
170
- // Round 1: text → tool
171
- ctrl.onPartialReply({ text: "Segment 1" });
172
- await expect(ctrl.preparePayload({ text: "Segment 1" })).resolves.toBeUndefined();
173
-
174
- // Round 2: text → tool
175
- ctrl.onPartialReply({ text: "Segment 2" });
176
- const r2 = await ctrl.preparePayload({ text: "Segment 2" });
177
- expect(r2).toEqual({ text: "Segment 2" });
178
-
179
- // Round 3: final text
180
- ctrl.onPartialReply({ text: "Segment 3" });
181
- const r3 = await ctrl.preparePayload({ text: "Segment 3" });
182
- expect(r3).toEqual({ text: "Segment 3" });
183
- });
184
-
185
- it("passes media+text payload through fully after stream finalized", async () => {
186
- const ctrl = createController();
187
-
188
- // First segment streamed and finalized
189
- ctrl.onPartialReply({ text: "Streamed text" });
190
- await ctrl.preparePayload({ text: "Streamed text" });
191
-
192
- // Second segment has both text and media — should pass through fully
193
- const result = await ctrl.preparePayload({
194
- text: "Post-tool text with image",
195
- mediaUrl: "https://example.com/tool-output.png",
196
- });
197
- expect(result).toEqual({
198
- text: "Post-tool text with image",
199
- mediaUrl: "https://example.com/tool-output.png",
200
- });
201
- });
202
-
203
- it("still strips text from media payloads when stream handled text", async () => {
204
- const ctrl = createController();
205
- ctrl.onPartialReply({ text: "Some text" });
206
-
207
- const result = await ctrl.preparePayload({
208
- text: "Some text",
209
- mediaUrl: "https://example.com/image.png",
210
- });
211
- expect(result).toEqual({
212
- text: undefined,
213
- mediaUrl: "https://example.com/image.png",
214
- });
215
- });
216
-
217
- it("falls back to normal delivery when progress final streaming fails", async () => {
218
- streamInstances.length = 0;
219
- const ctrl = createTeamsReplyStreamController({
220
- conversationType: "personal",
221
- context: { sendActivity: vi.fn(async () => ({ id: "a" })) } as never,
222
- feedbackLoopEnabled: false,
223
- log: { debug: vi.fn() } as never,
224
- msteamsConfig: { streaming: { mode: "progress" } } as never,
225
- });
226
- await ctrl.noteProgressWork({ toolName: "exec" });
227
- await ctrl.noteProgressWork();
228
- const fullText = "x".repeat(4200);
229
-
230
- const result = await ctrl.preparePayload({ text: fullText });
231
-
232
- expect(result).toEqual({ text: fullText });
233
- expect(streamInstances[0]?.replaceInformativeWithFinal).toHaveBeenCalledWith(fullText);
234
- });
235
-
236
- it("records lifecycle receipt when progress final streaming succeeds", async () => {
237
- streamInstances.length = 0;
238
- const ctrl = createTeamsReplyStreamController({
239
- conversationType: "personal",
240
- context: { sendActivity: vi.fn(async () => ({ id: "a" })) } as never,
241
- feedbackLoopEnabled: false,
242
- log: { debug: vi.fn() } as never,
243
- msteamsConfig: { streaming: { mode: "progress" } } as never,
244
- });
245
- await ctrl.noteProgressWork({ toolName: "exec" });
246
- await ctrl.noteProgressWork();
247
-
248
- await expect(ctrl.preparePayload({ text: "complete final answer" })).resolves.toBeUndefined();
249
-
250
- expect(ctrl.liveState().phase).toBe("finalized");
251
- expect(ctrl.liveState().receipt?.primaryPlatformMessageId).toBe("final-message");
252
- });
253
-
254
- it("falls back with full text when progress final send fails after streaming text", async () => {
255
- streamInstances.length = 0;
256
- const ctrl = createTeamsReplyStreamController({
257
- conversationType: "personal",
258
- context: { sendActivity: vi.fn(async () => ({ id: "a" })) } as never,
259
- feedbackLoopEnabled: false,
260
- log: { debug: vi.fn() } as never,
261
- msteamsConfig: { streaming: { mode: "progress" } } as never,
262
- });
263
- await ctrl.onReplyStart();
264
- streamInstances[0].replaceInformativeWithFinal.mockImplementationOnce(
265
- async function (this: {
266
- hasContent: boolean;
267
- isFailed: boolean;
268
- isFinalized: boolean;
269
- streamedLength: number;
270
- }) {
271
- this.hasContent = true;
272
- this.isFailed = true;
273
- this.isFinalized = true;
274
- this.streamedLength = 12;
275
- return false;
276
- },
277
- );
278
-
279
- const result = await ctrl.preparePayload({ text: "complete final answer" });
280
-
281
- expect(result).toEqual({ text: "complete final answer" });
282
- });
283
-
284
- it("honors disabled Teams progress labels", async () => {
285
- streamInstances.length = 0;
286
- const ctrl = createTeamsReplyStreamController({
287
- conversationType: "personal",
288
- context: { sendActivity: vi.fn(async () => ({ id: "a" })) } as never,
289
- feedbackLoopEnabled: false,
290
- log: { debug: vi.fn() } as never,
291
- msteamsConfig: { streaming: { mode: "progress", progress: { label: false } } } as never,
292
- });
293
-
294
- await ctrl.onReplyStart();
295
-
296
- expect(streamInstances).toHaveLength(1);
297
- expect(streamInstances[0]?.sendInformativeUpdate).not.toHaveBeenCalled();
298
- });
299
-
300
- it("streams compact Teams progress lines when tool progress is enabled", async () => {
301
- streamInstances.length = 0;
302
- const ctrl = createTeamsReplyStreamController({
303
- conversationType: "personal",
304
- context: { sendActivity: vi.fn(async () => ({ id: "a" })) } as never,
305
- feedbackLoopEnabled: false,
306
- log: { debug: vi.fn() } as never,
307
- msteamsConfig: {
308
- streaming: {
309
- mode: "progress",
310
- progress: {
311
- label: "Working",
312
- maxLines: 3,
313
- },
314
- },
315
- } as never,
316
- });
317
-
318
- await ctrl.pushProgressLine("tool: search");
319
- await ctrl.pushProgressLine("tool: exec");
320
-
321
- expect(ctrl.shouldSuppressDefaultToolProgressMessages()).toBe(true);
322
- expect(ctrl.shouldStreamPreviewToolProgress()).toBe(true);
323
- expect(streamInstances[0]?.sendInformativeUpdate).toHaveBeenLastCalledWith(
324
- "Working\n- tool: search\n- tool: exec",
325
- );
326
- });
327
-
328
- it("suppresses Teams default progress messages without stream lines when tool progress is disabled", async () => {
329
- streamInstances.length = 0;
330
- const ctrl = createTeamsReplyStreamController({
331
- conversationType: "personal",
332
- context: { sendActivity: vi.fn(async () => ({ id: "a" })) } as never,
333
- feedbackLoopEnabled: false,
334
- log: { debug: vi.fn() } as never,
335
- msteamsConfig: {
336
- streaming: {
337
- mode: "progress",
338
- progress: {
339
- toolProgress: false,
340
- },
341
- },
342
- } as never,
343
- });
344
-
345
- await ctrl.pushProgressLine("tool: search");
346
-
347
- expect(ctrl.shouldSuppressDefaultToolProgressMessages()).toBe(true);
348
- expect(ctrl.shouldStreamPreviewToolProgress()).toBe(false);
349
- expect(streamInstances[0]?.sendInformativeUpdate).not.toHaveBeenCalled();
350
- });
351
-
352
- it("does not start native streaming for Teams block mode", async () => {
353
- streamInstances.length = 0;
354
- const ctrl = createTeamsReplyStreamController({
355
- conversationType: "personal",
356
- context: { sendActivity: vi.fn(async () => ({ id: "a" })) } as never,
357
- feedbackLoopEnabled: false,
358
- log: { debug: vi.fn() } as never,
359
- msteamsConfig: { streaming: { mode: "block" } } as never,
360
- });
361
-
362
- await ctrl.onReplyStart();
363
- ctrl.onPartialReply({ text: "block partial" });
364
-
365
- expect(streamInstances).toHaveLength(0);
366
- await expect(ctrl.preparePayload({ text: "block final" })).resolves.toEqual({
367
- text: "block final",
368
- });
369
- expect(ctrl.hasStream()).toBe(false);
370
- });
371
-
372
- describe("isStreamActive", () => {
373
- it("returns false before any tokens arrive so typing keepalive can warm up", () => {
374
- const ctrl = createController();
375
- expect(ctrl.isStreamActive()).toBe(false);
376
- });
377
-
378
- it("returns false after the informative update but before tokens arrive", async () => {
379
- const ctrl = createController();
380
- await ctrl.onReplyStart();
381
- expect(ctrl.isStreamActive()).toBe(false);
382
- });
383
-
384
- it("returns true while the stream is actively receiving tokens", () => {
385
- const ctrl = createController();
386
- ctrl.onPartialReply({ text: "Streaming tokens" });
387
- expect(ctrl.isStreamActive()).toBe(true);
388
- });
389
-
390
- it("returns false after the stream is finalized between tool rounds", async () => {
391
- const ctrl = createController();
392
-
393
- ctrl.onPartialReply({ text: "First segment" });
394
- expect(ctrl.isStreamActive()).toBe(true);
395
-
396
- // First segment complete: stream is finalized so the typing keepalive
397
- // can resume during the tool chain that follows.
398
- await ctrl.preparePayload({ text: "First segment" });
399
- expect(ctrl.isStreamActive()).toBe(false);
400
- });
401
-
402
- it("returns false when the stream has failed", () => {
403
- const ctrl = createController();
404
-
405
- ctrl.onPartialReply({ text: "First segment" });
406
- expect(ctrl.isStreamActive()).toBe(true);
407
-
408
- streamInstances[0].isFailed = true;
409
- expect(ctrl.isStreamActive()).toBe(false);
410
- });
411
-
412
- it("returns false when conversationType is not personal", () => {
413
- streamInstances.length = 0;
414
- const ctrl = createTeamsReplyStreamController({
415
- conversationType: "channel",
416
- context: { sendActivity: vi.fn() } as never,
417
- feedbackLoopEnabled: false,
418
- log: { debug: vi.fn() } as never,
419
- });
420
- ctrl.onPartialReply({ text: "anything" });
421
- expect(ctrl.isStreamActive()).toBe(false);
422
- });
423
- });
424
- });