@copilotkit/channels-core 0.4.1-canary.1785375021 → 0.4.1-canary.narrowinstall1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@copilotkit/channels-core",
3
- "version": "0.4.1-canary.1785375021",
3
+ "version": "0.4.1-canary.narrowinstall1",
4
4
  "description": "Platform-agnostic JSX channel engine for CopilotKit (createChannel, Thread, PlatformAdapter, ActionStore).",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -51,9 +51,9 @@
51
51
  "@ag-ui/client": "0.0.57",
52
52
  "@ag-ui/core": "0.0.57",
53
53
  "zod-to-json-schema": "^3.24.1",
54
- "@copilotkit/channels-ui": "~0.4.1-canary.1785375021",
55
- "@copilotkit/core": "^1.64.2-canary.1785375021",
56
- "@copilotkit/shared": "^1.64.2-canary.1785375021"
54
+ "@copilotkit/channels-ui": "~0.4.1-canary.narrowinstall1",
55
+ "@copilotkit/core": "^1.64.2-canary.narrowinstall1",
56
+ "@copilotkit/shared": "^1.64.2-canary.narrowinstall1"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@types/node": "^22.10.0",
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=canonical-run-loop.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"canonical-run-loop.test.d.ts","sourceRoot":"","sources":["../src/canonical-run-loop.test.ts"],"names":[],"mappings":""}
@@ -1,393 +0,0 @@
1
- import { EventType } from "@ag-ui/client";
2
- import { expect, test } from "vitest";
3
- import { z } from "zod";
4
- import { runAgentLoop } from "./run-loop.js";
5
- import { FakeAgent } from "./testing/fake-agent.js";
6
- const canonicalRun = {
7
- threadId: "canonical-thread",
8
- runId: "canonical-run",
9
- };
10
- function lifecycleBatch(runId, middle) {
11
- return [
12
- {
13
- type: EventType.RUN_STARTED,
14
- threadId: "inner-thread",
15
- runId,
16
- },
17
- ...middle,
18
- {
19
- type: EventType.RUN_FINISHED,
20
- threadId: "inner-thread",
21
- runId,
22
- },
23
- ];
24
- }
25
- function textEvent(messageId, text) {
26
- return {
27
- type: EventType.TEXT_MESSAGE_CONTENT,
28
- messageId,
29
- delta: text,
30
- };
31
- }
32
- async function emitBatch(subscriber, agent, runId, middle) {
33
- const input = {
34
- threadId: agent.threadId,
35
- runId,
36
- messages: agent.messages,
37
- state: agent.state,
38
- tools: [],
39
- context: [],
40
- forwardedProps: {},
41
- };
42
- const params = {
43
- messages: agent.messages,
44
- state: agent.state,
45
- agent,
46
- input,
47
- };
48
- for (const event of lifecycleBatch(runId, middle)) {
49
- await subscriber.onEvent?.({ ...params, event });
50
- switch (event.type) {
51
- case EventType.RUN_STARTED:
52
- await subscriber.onRunStartedEvent?.({ ...params, event });
53
- break;
54
- case EventType.RUN_FINISHED:
55
- await subscriber.onRunFinishedEvent?.({
56
- ...params,
57
- event,
58
- outcome: "success",
59
- });
60
- break;
61
- case EventType.RUN_ERROR:
62
- await subscriber.onRunErrorEvent?.({ ...params, event });
63
- break;
64
- case EventType.TEXT_MESSAGE_CONTENT:
65
- await subscriber.onTextMessageContentEvent?.({
66
- ...params,
67
- event,
68
- textMessageBuffer: event.delta,
69
- });
70
- break;
71
- case EventType.TOOL_CALL_END:
72
- await subscriber.onToolCallEndEvent?.({
73
- ...params,
74
- event,
75
- toolCallName: "echo",
76
- toolCallArgs: { value: "ok" },
77
- });
78
- break;
79
- }
80
- }
81
- }
82
- function setupRenderer(options = {}) {
83
- const renderedEvents = [];
84
- const renderedFinishMetadata = [];
85
- const toolCalls = [];
86
- const subscriber = {
87
- onRunStartedEvent: ({ event }) => {
88
- renderedEvents.push(event);
89
- },
90
- onRunFinishedEvent: ({ event }) => {
91
- renderedEvents.push(event);
92
- renderedFinishMetadata.push(event.metadata);
93
- if (options.failOnFinish) {
94
- throw new Error("renderer finalization failed");
95
- }
96
- },
97
- onRunErrorEvent: ({ event }) => {
98
- renderedEvents.push(event);
99
- },
100
- onTextMessageContentEvent: ({ event }) => {
101
- renderedEvents.push(event);
102
- if (options.failOnContent) {
103
- throw new Error("renderer failed");
104
- }
105
- },
106
- onToolCallEndEvent: ({ event, toolCallName, toolCallArgs }) => {
107
- toolCalls.push({
108
- toolCallId: event.toolCallId,
109
- toolCallName,
110
- toolCallArgs,
111
- });
112
- },
113
- };
114
- return {
115
- renderer: {
116
- subscriber,
117
- markInterrupted: async () => { },
118
- getCapturedToolCalls: () => toolCalls,
119
- getPendingInterrupt: () => undefined,
120
- clearPendingInterrupt: () => { },
121
- },
122
- renderedEvents,
123
- renderedFinishMetadata,
124
- };
125
- }
126
- test("managed runAgentLoop emits one canonical lifecycle and shares stamped events with ingestion and rendering", async () => {
127
- let agent;
128
- agent = new FakeAgent([
129
- (subscriber) => emitBatch(subscriber, agent, "inner-run-1", [
130
- textEvent("message-1", "first"),
131
- {
132
- type: EventType.TOOL_CALL_END,
133
- toolCallId: "tool-call-1",
134
- },
135
- ]),
136
- (subscriber) => emitBatch(subscriber, agent, "inner-run-2", [
137
- textEvent("message-2", "second"),
138
- ]),
139
- ]);
140
- const { renderer, renderedEvents } = setupRenderer();
141
- const ingestedEvents = [];
142
- const echo = {
143
- name: "echo",
144
- description: "Return the value.",
145
- parameters: z.object({ value: z.string() }),
146
- handler: ({ value }) => value,
147
- };
148
- const result = await runAgentLoop({
149
- agent,
150
- renderer,
151
- tools: new Map([["echo", echo]]),
152
- toolDescriptors: [],
153
- context: [],
154
- makeToolCtx: () => {
155
- throw new Error("tool context is not used by this test");
156
- },
157
- subscriber: {
158
- onEvent: ({ event }) => {
159
- ingestedEvents.push(event);
160
- },
161
- },
162
- canonicalRun,
163
- });
164
- const lifecycleTypes = ingestedEvents
165
- .filter(({ type }) => type === EventType.RUN_STARTED ||
166
- type === EventType.RUN_FINISHED ||
167
- type === EventType.RUN_ERROR)
168
- .map(({ type }) => type);
169
- const ingestedContent = ingestedEvents.filter(({ type }) => type === EventType.TEXT_MESSAGE_CONTENT);
170
- const renderedContent = renderedEvents.filter(({ type }) => type === EventType.TEXT_MESSAGE_CONTENT);
171
- expect(result).toEqual({ iterations: 2, interrupted: false });
172
- expect(lifecycleTypes).toEqual([
173
- EventType.RUN_STARTED,
174
- EventType.RUN_FINISHED,
175
- ]);
176
- expect(renderedEvents
177
- .filter(({ type }) => type === EventType.RUN_STARTED ||
178
- type === EventType.RUN_FINISHED ||
179
- type === EventType.RUN_ERROR)
180
- .map(({ type }) => type)).toEqual([EventType.RUN_STARTED, EventType.RUN_FINISHED]);
181
- expect(ingestedContent).toHaveLength(2);
182
- expect(renderedContent).toHaveLength(2);
183
- expect(renderedContent[0]).toBe(ingestedContent[0]);
184
- expect(renderedContent[1]).toBe(ingestedContent[1]);
185
- expect(ingestedEvents).toEqual(expect.arrayContaining([
186
- expect.objectContaining(canonicalRun),
187
- expect.objectContaining({
188
- ...canonicalRun,
189
- type: EventType.TEXT_MESSAGE_CONTENT,
190
- messageId: "message-1",
191
- }),
192
- expect.objectContaining({
193
- ...canonicalRun,
194
- type: EventType.TEXT_MESSAGE_CONTENT,
195
- messageId: "message-2",
196
- }),
197
- ]));
198
- });
199
- test("managed renderer failure is deferred until canonical RUN_FINISHED reaches ingestion", async () => {
200
- let agent;
201
- agent = new FakeAgent([
202
- (subscriber) => emitBatch(subscriber, agent, "inner-run", [
203
- textEvent("message-1", "hello"),
204
- ]),
205
- ]);
206
- const { renderer } = setupRenderer({ failOnContent: true });
207
- const ingestedByTypedCallback = [];
208
- const ingestedLifecycle = [];
209
- const result = await runAgentLoop({
210
- agent,
211
- renderer,
212
- tools: new Map(),
213
- toolDescriptors: [],
214
- context: [],
215
- makeToolCtx: () => {
216
- throw new Error("no tool calls are expected");
217
- },
218
- subscriber: {
219
- onEvent: ({ event }) => {
220
- if (event.type === EventType.RUN_STARTED ||
221
- event.type === EventType.RUN_FINISHED ||
222
- event.type === EventType.RUN_ERROR) {
223
- ingestedLifecycle.push(event);
224
- }
225
- },
226
- onTextMessageContentEvent: ({ event }) => {
227
- ingestedByTypedCallback.push(event);
228
- },
229
- },
230
- canonicalRun,
231
- });
232
- expect(result).toMatchObject({
233
- iterations: 1,
234
- interrupted: false,
235
- deliveryError: { message: "renderer failed" },
236
- });
237
- expect(ingestedByTypedCallback).toEqual([
238
- expect.objectContaining({
239
- ...canonicalRun,
240
- type: EventType.TEXT_MESSAGE_CONTENT,
241
- messageId: "message-1",
242
- }),
243
- ]);
244
- expect(ingestedLifecycle.map(({ type }) => type)).toEqual([
245
- EventType.RUN_STARTED,
246
- EventType.RUN_FINISHED,
247
- ]);
248
- });
249
- test("managed renderer failure freezes later rendering while canonical ingestion finishes", async () => {
250
- let agent;
251
- agent = new FakeAgent([
252
- (subscriber) => emitBatch(subscriber, agent, "inner-run", [
253
- textEvent("message-1", "first"),
254
- textEvent("message-2", "second"),
255
- ]),
256
- ]);
257
- const { renderer, renderedEvents } = setupRenderer({
258
- failOnContent: true,
259
- });
260
- const ingestedEvents = [];
261
- const result = await runAgentLoop({
262
- agent,
263
- renderer,
264
- tools: new Map(),
265
- toolDescriptors: [],
266
- context: [],
267
- makeToolCtx: () => {
268
- throw new Error("no tool calls are expected");
269
- },
270
- subscriber: {
271
- onEvent: ({ event }) => {
272
- ingestedEvents.push(event);
273
- },
274
- },
275
- canonicalRun,
276
- });
277
- expect(result).toMatchObject({
278
- deliveryError: { message: "renderer failed" },
279
- });
280
- expect(renderedEvents.map(({ type, ...event }) => ({
281
- type,
282
- messageId: "messageId" in event ? event.messageId : undefined,
283
- }))).toEqual([
284
- { type: EventType.RUN_STARTED, messageId: undefined },
285
- { type: EventType.TEXT_MESSAGE_CONTENT, messageId: "message-1" },
286
- ]);
287
- expect(ingestedEvents
288
- .filter(({ type }) => type === EventType.TEXT_MESSAGE_CONTENT ||
289
- type === EventType.RUN_FINISHED)
290
- .map(({ type, ...event }) => ({
291
- type,
292
- messageId: "messageId" in event ? event.messageId : undefined,
293
- }))).toEqual([
294
- { type: EventType.TEXT_MESSAGE_CONTENT, messageId: "message-1" },
295
- { type: EventType.TEXT_MESSAGE_CONTENT, messageId: "message-2" },
296
- { type: EventType.RUN_FINISHED, messageId: undefined },
297
- ]);
298
- });
299
- test("inner RUN_ERROR becomes one canonical outer RUN_ERROR", async () => {
300
- let agent;
301
- agent = new FakeAgent([
302
- (subscriber) => emitBatch(subscriber, agent, "inner-run", [
303
- {
304
- type: EventType.RUN_ERROR,
305
- message: "inner agent failed",
306
- code: "INNER_FAILED",
307
- },
308
- ]),
309
- ]);
310
- const { renderer, renderedEvents } = setupRenderer();
311
- const ingestedEvents = [];
312
- await expect(runAgentLoop({
313
- agent,
314
- renderer,
315
- tools: new Map(),
316
- toolDescriptors: [],
317
- context: [],
318
- makeToolCtx: () => {
319
- throw new Error("no tool calls are expected");
320
- },
321
- subscriber: {
322
- onEvent: ({ event }) => {
323
- ingestedEvents.push(event);
324
- },
325
- },
326
- canonicalRun,
327
- })).rejects.toMatchObject({
328
- message: "inner agent failed",
329
- code: "INNER_FAILED",
330
- });
331
- const expectedLifecycle = [
332
- expect.objectContaining({
333
- ...canonicalRun,
334
- type: EventType.RUN_STARTED,
335
- }),
336
- expect.objectContaining({
337
- ...canonicalRun,
338
- type: EventType.RUN_ERROR,
339
- message: "inner agent failed",
340
- code: "INNER_FAILED",
341
- }),
342
- ];
343
- expect(ingestedEvents.filter(({ type }) => type === EventType.RUN_STARTED ||
344
- type === EventType.RUN_FINISHED ||
345
- type === EventType.RUN_ERROR)).toEqual(expectedLifecycle);
346
- expect(renderedEvents.filter(({ type }) => type === EventType.RUN_STARTED ||
347
- type === EventType.RUN_FINISHED ||
348
- type === EventType.RUN_ERROR)).toEqual(expectedLifecycle);
349
- });
350
- test("managed renderer finalization sees runner metadata without replacing canonical RUN_FINISHED", async () => {
351
- let agent;
352
- agent = new FakeAgent([
353
- (subscriber) => emitBatch(subscriber, agent, "inner-run", []),
354
- ]);
355
- const { renderer, renderedFinishMetadata } = setupRenderer({
356
- failOnFinish: true,
357
- });
358
- const ingestedEvents = [];
359
- const runnerMetadata = {
360
- cpki_event_id: "runner-event-finished",
361
- cpki_event_seq: 1,
362
- };
363
- const result = await runAgentLoop({
364
- agent,
365
- renderer,
366
- tools: new Map(),
367
- toolDescriptors: [],
368
- context: [],
369
- makeToolCtx: () => {
370
- throw new Error("no tool calls are expected");
371
- },
372
- subscriber: {
373
- onEvent: ({ event }) => {
374
- if (event.type === EventType.RUN_FINISHED) {
375
- event.metadata = runnerMetadata;
376
- }
377
- ingestedEvents.push(event);
378
- },
379
- },
380
- canonicalRun,
381
- });
382
- expect(result).toMatchObject({
383
- iterations: 1,
384
- interrupted: false,
385
- deliveryError: { message: "renderer finalization failed" },
386
- });
387
- expect(ingestedEvents
388
- .filter(({ type }) => type === EventType.RUN_STARTED ||
389
- type === EventType.RUN_FINISHED ||
390
- type === EventType.RUN_ERROR)
391
- .map(({ type }) => type)).toEqual([EventType.RUN_STARTED, EventType.RUN_FINISHED]);
392
- expect(renderedFinishMetadata).toEqual([runnerMetadata]);
393
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=managed-v1-await-choice-guard.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"managed-v1-await-choice-guard.test.d.ts","sourceRoot":"","sources":["../src/managed-v1-await-choice-guard.test.ts"],"names":[],"mappings":""}
@@ -1,52 +0,0 @@
1
- import { expect, test } from "vitest";
2
- import { Section } from "@copilotkit/channels-ui";
3
- import { createChannel } from "./create-channel.js";
4
- import { FakeAdapter } from "./testing/fake-adapter.js";
5
- class NonBlockingManagedAdapter extends FakeAdapter {
6
- __intelligenceChannel = true;
7
- constructor() {
8
- super({ platform: "intelligence" });
9
- this.capabilities.supportsBlockingChoice = false;
10
- }
11
- }
12
- async function setupNonBlockingManagedThread() {
13
- const adapter = new NonBlockingManagedAdapter();
14
- const channel = createChannel({ adapters: [adapter] });
15
- let thread;
16
- channel.onThreadStarted(({ thread: activeThread }) => {
17
- thread = activeThread;
18
- });
19
- await channel.ɵruntime.start();
20
- await adapter.emitThreadStarted();
21
- if (!thread) {
22
- throw new Error("Managed thread was not created");
23
- }
24
- return {
25
- adapter,
26
- thread,
27
- teardown: () => channel.ɵruntime.stop(),
28
- };
29
- }
30
- test("managed awaitChoice fails fast before registering or posting a picker", async () => {
31
- const { adapter, thread, teardown } = await setupNonBlockingManagedThread();
32
- try {
33
- const outcome = await Promise.race([
34
- thread.awaitChoice(Section({ children: "Choose" })).then(() => ({ status: "resolved" }), (error) => ({ status: "rejected", error })),
35
- new Promise((resolve) => {
36
- setTimeout(() => resolve({ status: "pending" }), 0);
37
- }),
38
- ]);
39
- expect(outcome).toMatchObject({
40
- status: "rejected",
41
- error: {
42
- name: "ChannelAwaitChoiceNotSupportedError",
43
- code: "channel_await_choice_not_supported",
44
- message: expect.stringContaining("Thread.resume()"),
45
- },
46
- });
47
- expect(adapter.posted).toHaveLength(0);
48
- }
49
- finally {
50
- await teardown();
51
- }
52
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=source-platform.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"source-platform.test.d.ts","sourceRoot":"","sources":["../src/source-platform.test.ts"],"names":[],"mappings":""}
@@ -1,149 +0,0 @@
1
- import { z } from "zod";
2
- import { expect, test, vi } from "vitest";
3
- import { createChannel } from "./create-channel.js";
4
- import { MemoryStore } from "./state/memory-store.js";
5
- import { FakeAdapter } from "./testing/fake-adapter.js";
6
- import { FakeAgent } from "./testing/fake-agent.js";
7
- test("an ingress source platform reaches the text thread and its tool context", async () => {
8
- const observed = {};
9
- const adapter = new FakeAdapter({ platform: "intelligence" });
10
- const agent = new FakeAgent([
11
- (subscriber) => {
12
- subscriber.onToolCallEndEvent?.({
13
- event: { toolCallId: "tool-call-1" },
14
- toolCallName: "capture_platform",
15
- toolCallArgs: {},
16
- });
17
- subscriber.onRunFinishedEvent?.({ event: {} });
18
- },
19
- (subscriber) => {
20
- subscriber.onRunFinishedEvent?.({ event: {} });
21
- },
22
- ]);
23
- const channel = createChannel({
24
- adapters: [adapter],
25
- agent: () => agent,
26
- tools: [
27
- {
28
- name: "capture_platform",
29
- description: "Capture the handler platform",
30
- parameters: z.object({}),
31
- handler: (_args, ctx) => {
32
- observed.toolPlatform = ctx.platform;
33
- observed.toolThreadPlatform = ctx.thread.platform;
34
- return "captured";
35
- },
36
- },
37
- ],
38
- });
39
- channel.onMessage(async ({ message, thread }) => {
40
- observed.messagePlatform = message.platform;
41
- observed.threadPlatform = thread.platform;
42
- await thread.runAgent();
43
- });
44
- await channel.ɵruntime.start();
45
- await adapter.getSink().onTurn({
46
- conversationKey: "conversation-1",
47
- replyTarget: {},
48
- userText: "hello",
49
- platform: "slack",
50
- });
51
- expect(observed).toEqual({
52
- messagePlatform: "slack",
53
- threadPlatform: "slack",
54
- toolPlatform: "slack",
55
- toolThreadPlatform: "slack",
56
- });
57
- });
58
- test("an ingress source platform scopes identity resolution and event dedupe", async () => {
59
- const state = new MemoryStore();
60
- const dedupeSeen = vi.spyOn(state.dedup, "seen").mockResolvedValue(false);
61
- const identity = vi.fn(() => "person-1");
62
- const adapter = new FakeAdapter({ platform: "intelligence" });
63
- const channel = createChannel({
64
- adapters: [adapter],
65
- store: {
66
- adapter: state,
67
- identity,
68
- transcripts: {},
69
- },
70
- });
71
- let userKey;
72
- channel.onMessage(({ message }) => {
73
- userKey = message.userKey;
74
- });
75
- await channel.ɵruntime.start();
76
- await adapter.getSink().onTurn({
77
- conversationKey: "conversation-1",
78
- replyTarget: {},
79
- userText: "hello",
80
- platform: "teams",
81
- eventId: "event-1",
82
- user: { id: "user-1" },
83
- });
84
- expect(dedupeSeen).toHaveBeenCalledWith("evt:teams:event-1", 300_000);
85
- expect(identity).toHaveBeenCalledWith(expect.objectContaining({
86
- adapter: "teams",
87
- message: expect.objectContaining({ platform: "teams" }),
88
- }));
89
- expect(userKey).toBe("person-1");
90
- });
91
- test("non-text ingress keeps source platform in handler contexts and dedupe keys", async () => {
92
- const state = new MemoryStore();
93
- const dedupeSeen = vi.spyOn(state.dedup, "seen").mockResolvedValue(false);
94
- const adapter = new FakeAdapter({ platform: "intelligence" });
95
- const observed = {};
96
- const channel = createChannel({
97
- adapters: [adapter],
98
- store: { adapter: state },
99
- });
100
- channel.onCommand("triage", ({ platform, thread }) => {
101
- observed.commandPlatform = platform;
102
- observed.commandThreadPlatform = thread.platform;
103
- });
104
- channel.onInteraction("approve", ({ message, platform, thread }) => {
105
- observed.interactionMessagePlatform = message.platform;
106
- observed.interactionPlatform = platform;
107
- observed.interactionThreadPlatform = thread.platform;
108
- });
109
- channel.onReaction(({ thread }) => {
110
- observed.reactionThreadPlatform = thread.platform;
111
- });
112
- await channel.ɵruntime.start();
113
- const sink = adapter.getSink();
114
- await sink.onCommand({
115
- command: "triage",
116
- conversationKey: "command-conversation",
117
- eventId: "command-event",
118
- platform: "teams",
119
- replyTarget: {},
120
- text: "",
121
- });
122
- const interaction = {
123
- id: "approve",
124
- conversationKey: "interaction-conversation",
125
- eventId: "interaction-event",
126
- platform: "slack",
127
- replyTarget: {},
128
- };
129
- await sink.onInteraction(interaction);
130
- await sink.onReaction({
131
- added: true,
132
- conversationKey: "reaction-conversation",
133
- messageId: "message-1",
134
- platform: "teams",
135
- raw: {},
136
- rawEmoji: "👍",
137
- replyTarget: {},
138
- });
139
- expect(observed).toEqual({
140
- commandPlatform: "teams",
141
- commandThreadPlatform: "teams",
142
- interactionMessagePlatform: "slack",
143
- interactionPlatform: "slack",
144
- interactionThreadPlatform: "slack",
145
- reactionThreadPlatform: "teams",
146
- });
147
- expect(dedupeSeen).toHaveBeenCalledWith("evt:teams:command-event", 300_000);
148
- expect(dedupeSeen).toHaveBeenCalledWith("evt:slack:interaction-event", 300_000);
149
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=thread-promise-contract.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"thread-promise-contract.test.d.ts","sourceRoot":"","sources":["../src/thread-promise-contract.test.ts"],"names":[],"mappings":""}
@@ -1,37 +0,0 @@
1
- import { expect, test } from "vitest";
2
- import { ActionRegistry } from "./action-registry.js";
3
- import { InMemoryActionStore } from "./action-store.js";
4
- import { MemoryStore } from "./state/memory-store.js";
5
- import { FakeAdapter } from "./testing/fake-adapter.js";
6
- import { Thread } from "./thread.js";
7
- function setupThreadWithSyncDeleteFailure(failure) {
8
- const adapter = new FakeAdapter();
9
- adapter.delete = () => {
10
- throw failure;
11
- };
12
- const deps = {
13
- adapter,
14
- replyTarget: {},
15
- conversationKey: "thread-promise-contract",
16
- registry: new ActionRegistry({ store: new InMemoryActionStore() }),
17
- agentFactory: (threadId) => {
18
- throw new Error(`agentFactory not needed in this test: ${threadId}`);
19
- },
20
- tools: new Map(),
21
- toolDescriptors: [],
22
- context: [],
23
- registerWaiter: () => undefined,
24
- interruptHandlers: new Map(),
25
- state: new MemoryStore(),
26
- };
27
- return new Thread(deps);
28
- }
29
- test("a synchronous non-managed adapter failure returns a rejected Promise", async () => {
30
- const failure = new Error("adapter delete failed synchronously");
31
- const thread = setupThreadWithSyncDeleteFailure(failure);
32
- let deletion;
33
- expect(() => {
34
- deletion = thread.delete({ id: "message-1" });
35
- }).not.toThrow();
36
- await expect(deletion).rejects.toBe(failure);
37
- });