Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

adapter.test.ts

1,487 lines50.7 KB

1import * as NodeServices from "@effect/platform-node/NodeServices";
2import { assert, describe, it } from "@effect/vitest";
3import type { InteractionUpdate } from "@cursor/sdk";
4import {
5 EnvironmentId,
6 MessageId,
7 NodeId,
8 ProjectId,
9 ProviderInstanceId,
10 ProviderSessionId,
11 RunAttemptId,
12 RunId,
13 ThreadId,
14} from "@t3tools/contracts";
15import * as DateTime from "effect/DateTime";
16import * as Effect from "effect/Effect";
17import * as FileSystem from "effect/FileSystem";
18import * as Layer from "effect/Layer";
19import * as Option from "effect/Option";
20import * as Path from "effect/Path";
21import * as Stream from "effect/Stream";
22​
23import * as TestProviderHost from "@t3tools/provider-testing/TestProviderHost";
24import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
25import * as McpProviderSessions from "@t3tools/provider-core/server/McpProviderSessions";
26import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
27import { makeProviderFailure } from "@t3tools/provider-core/server/failure";
28import {
29 cursorMcpServers,
30 cursorRuntimeAgentPolicy,
31 makeCursorAgentOptions,
32 makeCursorAdapterV2,
33 nestedToolCallFromEnvelope,
34} from "./adapter.ts";
35import * as CursorAgentSdk from "./CursorAgentSdk.ts";
36import { ConfigurationError } from "./sdk.ts";
37​
38describe("CursorAdapterV2", () => {
39 it.effect.each([
40 { status: "finished", model: undefined, lateModel: undefined },
41 { status: "cancelled", model: "claude-opus-4-6", lateModel: undefined },
42 { status: "error", model: "custom-fable", lateModel: undefined },
43 { status: "finished", model: undefined, lateModel: "gpt-6-sol" },
44 { status: "finished", model: "gpt-6-sol", lateModel: null },
45 ] as const)(
46 "projects Cursor tasks: $status, late model $lateModel",
47 ({ status, model, lateModel }) =>
48 Effect.gen(function* () {
49 const fileSystem = yield* FileSystem.FileSystem;
50 const workspace = yield* fileSystem.makeTempDirectoryScoped({
51 prefix: "cursor-v2-lifecycle-",
52 });
53 const instanceId = ProviderInstanceId.make("cursor");
54 const threadId = ThreadId.make("cursor-lifecycle-thread");
55 const mcpSessions = yield* McpProviderSessions.McpProviderSessions;
56 yield* mcpSessions.set({
57 environmentId: EnvironmentId.make("cursor-lifecycle-environment"),
58 threadId,
59 providerSessionId: "cursor-lifecycle-session",
60 providerInstanceId: instanceId,
61 endpoint: "http://127.0.0.1:43123/mcp",
62 authorizationHeader: "Bearer synthetic-cursor-token",
63 browserToolsAvailable: true,
64 });
65 let sentWithMcpOverride = true;
66 const modelSelection = { instanceId, model: "composer-2.5" };
67 const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
68 runtimeMode: "full-access",
69 interactionMode: "default",
70 cwd: workspace,
71 });
72 const adapter = yield* makeCursorAdapterV2({
73 instanceId,
74 environment: { HOME: workspace },
75 }).pipe(
76 Effect.provideService(CursorAgentSdk.CursorAgentSdkRunner, {
77 assertComplete: Effect.void,
78 open: () =>
79 Effect.succeed({
80 agentId: "native-cursor-lifecycle",
81 listMessages: Effect.succeed([]),
82 close: Effect.void,
83 send: (input) =>
84 Effect.gen(function* () {
85 sentWithMcpOverride = Object.hasOwn(input.options ?? {}, "mcpServers");
86 // Recorded tasks stream partial args before start, then end without completion; live runs cannot force this.
87 const taskToolCall = {
88 type: "task" as const,
89 args: {
90 description: "Review",
91 prompt: "Review the code.",
92 subagentType: { kind: "unspecified" },
93 ...(model === undefined ? {} : { model }),
94 agentId: "cursor-task-agent",
95 mode: "unspecified" as const,
96 },
97 };
98 const updates =
99 lateModel !== undefined
100 ? (["tool-call-started", "tool-call-completed"] as const)
101 : (["partial-tool-call", "tool-call-started"] as const);
102 for (const type of updates) {
103 yield* input.onDelta!({
104 type,
105 modelCallId: "model-call",
106 callId: "task-call",
107 toolCall: {
108 ...taskToolCall,
109 args: {
110 ...taskToolCall.args,
111 ...(type === "tool-call-completed"
112 ? { model: lateModel ?? undefined }
113 : {}),
114 },
115 },
116 }).pipe(Effect.orDie);
117 }
118 return {
119 agentId: "native-cursor-lifecycle",
120 runId: "native-cursor-run",
121 wait: Effect.succeed({
122 id: "native-cursor-run",
123 requestId: "native-request",
124 status,
125 model: { id: "composer-2.5" },
126 durationMs: 1,
127 }),
128 cancel: Effect.void,
129 };
130 }),
131 }),
132 }),
133 Effect.provide(TestProviderHost.layer({ cwd: workspace })),
134 );
135 const runtime = yield* adapter.openSession({
136 threadId,
137 providerSessionId: ProviderSessionId.make("cursor-lifecycle-session"),
138 modelSelection,
139 runtimePolicy,
140 });
141 const providerThread = yield* runtime.ensureThread({
142 threadId,
143 modelSelection,
144 runtimePolicy,
145 });
146 const now = yield* DateTime.now;
147 yield* runtime.startTurn({
148 threadId,
149 providerThread,
150 modelSelection,
151 runtimePolicy,
152 runId: RunId.make("cursor-lifecycle-run"),
153 runOrdinal: 1,
154 providerTurnOrdinal: 1,
155 attemptId: RunAttemptId.make("cursor-lifecycle-attempt"),
156 rootNodeId: NodeId.make("cursor-lifecycle-root"),
157 appThread: {
158 id: threadId,
159 projectId: ProjectId.make("cursor-lifecycle-project"),
160 createdBy: "user",
161 creationSource: "web",
162 title: "Cursor lifecycle",
163 providerInstanceId: instanceId,
164 modelSelection,
165 runtimeMode: "full-access",
166 interactionMode: "default",
167 branch: null,
168 worktreePath: null,
169 activeProviderThreadId: providerThread.id,
170 lineage: { parentThreadId: null, relationshipToParent: null, rootThreadId: threadId },
171 forkedFrom: null,
172 createdAt: now,
173 updatedAt: now,
174 archivedAt: null,
175 settledOverride: null,
176 settledAt: null,
177 lastVisitedAt: null,
178 deletedAt: null,
179 },
180 message: {
181 messageId: MessageId.make("cursor-lifecycle-message"),
182 createdBy: "user",
183 creationSource: "web",
184 text: "Review the code.",
185 attachments: [],
186 },
187 });
188 const events = yield* runtime.events.pipe(
189 Stream.takeUntil((event) => event.type === "turn.terminal"),
190 Stream.runCollect,
191 );
192 assert.isFalse(sentWithMcpOverride);
193 const rows = events.filter((event) => event.type === "subagent.updated");
194 assert.equal(rows[0]?.subagent.status, "running");
195 assert.equal(rows[0]?.subagent.model, model ?? null);
196 assert.equal(rows.at(-1)?.subagent.model, lateModel ?? model ?? null);
197 assert.equal(
198 rows.at(-1)?.subagent.status,
199 lateModel !== undefined
200 ? "completed"
201 : status === "finished"
202 ? "idle"
203 : status === "cancelled"
204 ? "cancelled"
205 : "failed",
206 );
207 assert.isNotNull(rows.at(-1)?.subagent.completedAt);
208 }).pipe(
209 Effect.scoped,
210 Effect.provide(
211 Layer.mergeAll(NodeServices.layer, IdAllocator.layer, McpProviderSessions.layer),
212 ),
213 ),
214 );
215​
216 it.effect.each([
217 {
218 reason: "the error Cursor's run ended with",
219 wait: Effect.succeed({
220 id: "native-cursor-run",
221 requestId: "native-request",
222 status: "error" as const,
223 error: {
224 message: "Model Blocked Please ask your admin to enable access to Claude Fable 5.",
225 },
226 model: { id: "claude-fable-5" },
227 durationMs: 1,
228 }),
229 failure: {
230 class: "provider_error",
231 message: "Model Blocked Please ask your admin to enable access to Claude Fable 5.",
232 },
233 },
234 {
235 reason: "the SDK error that broke the run",
236 wait: Effect.fail(
237 new CursorAgentSdk.CursorAgentSdkRunnerError({
238 method: "run.wait",
239 cause: Object.assign(new Error("Too many requests"), {
240 code: "resource_exhausted",
241 status: 429,
242 }),
243 }),
244 ),
245 failure: {
246 class: "transport_error",
247 message:
248 "Cursor Agent SDK run.wait failed: Too many requests (resource_exhausted, HTTP 429)",
249 },
250 },
251 {
252 reason: "a transport dump sent after earlier commentary",
253 updates: [
254 { type: "text-delta", text: "Checking the build first." },
255 { type: "step-completed", stepId: 1, stepDurationMs: 1 },
256 { type: "text-delta", text: "Error: RetriableError: WritableIterable is closed" },
257 ] satisfies ReadonlyArray<InteractionUpdate>,
258 wait: Effect.succeed({
259 id: "native-cursor-run",
260 requestId: "native-request",
261 status: "finished" as const,
262 model: { id: "claude-fable-5" },
263 durationMs: 1,
264 }),
265 failure: { class: "transport_error", message: "Provider turn failed." },
266 },
267 {
268 reason: "no failure when Cursor's resume after the turn ended made no progress",
269 // Cursor's SDK resumed from an older checkpoint after the answer was
270 // delivered, regenerated the closing, then gave up on the run.
271 updates: [
272 { type: "text-delta", text: "The answer." },
273 { type: "turn-ended" },
274 { type: "text-delta", text: "A regenerated closing." },
275 { type: "turn-ended" },
276 ] satisfies ReadonlyArray<InteractionUpdate>,
277 wait: Effect.succeed({
278 id: "native-cursor-run",
279 requestId: "native-request",
280 status: "error" as const,
281 error: { message: "Agent turn stopped after repeated resume attempts made no progress" },
282 model: { id: "claude-fable-5" },
283 durationMs: 1,
284 }),
285 failure: null,
286 },
287 {
288 reason: "the error a continuation after the turn ended stopped with",
289 updates: [
290 { type: "text-delta", text: "The answer." },
291 { type: "turn-ended" },
292 { type: "text-delta", text: "Following up on the stop hook." },
293 ] satisfies ReadonlyArray<InteractionUpdate>,
294 wait: Effect.succeed({
295 id: "native-cursor-run",
296 requestId: "native-request",
297 status: "error" as const,
298 error: { message: "Agent turn stopped after repeated resume attempts made no progress" },
299 model: { id: "claude-fable-5" },
300 durationMs: 1,
301 }),
302 failure: {
303 class: "provider_error",
304 message: "Agent turn stopped after repeated resume attempts made no progress",
305 },
306 },
307 {
308 reason: "no answer from a resume after the turn ended that made no progress",
309 updates: [{ type: "turn-ended" }] satisfies ReadonlyArray<InteractionUpdate>,
310 wait: Effect.succeed({
311 id: "native-cursor-run",
312 requestId: "native-request",
313 status: "error" as const,
314 error: { message: "Agent turn stopped after repeated resume attempts made no progress" },
315 result: "A regenerated closing.",
316 model: { id: "claude-fable-5" },
317 durationMs: 1,
318 }),
319 failure: null,
320 answers: [],
321 },
322 ])("ends the turn with $reason", ({ updates = [], wait, failure, answers }) =>
323 Effect.gen(function* () {
324 const fileSystem = yield* FileSystem.FileSystem;
325 const workspace = yield* fileSystem.makeTempDirectoryScoped({ prefix: "cursor-v2-failure-" });
326 const instanceId = ProviderInstanceId.make("cursor");
327 const threadId = ThreadId.make("cursor-failure-thread");
328 const modelSelection = { instanceId, model: "claude-fable-5" };
329 const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
330 runtimeMode: "full-access",
331 interactionMode: "default",
332 cwd: workspace,
333 });
334 const adapter = yield* makeCursorAdapterV2({
335 instanceId,
336 environment: { HOME: workspace },
337 }).pipe(
338 Effect.provideService(CursorAgentSdk.CursorAgentSdkRunner, {
339 assertComplete: Effect.void,
340 open: () =>
341 Effect.succeed({
342 agentId: "native-cursor-failure",
343 listMessages: Effect.succeed([]),
344 close: Effect.void,
345 send: (input) =>
346 Effect.gen(function* () {
347 for (const update of updates) {
348 yield* input.onDelta!(update).pipe(Effect.orDie);
349 }
350 return {
351 agentId: "native-cursor-failure",
352 runId: "native-cursor-run",
353 wait,
354 cancel: Effect.void,
355 };
356 }),
357 }),
358 }),
359 Effect.provide(TestProviderHost.layer({ cwd: workspace })),
360 );
361 const runtime = yield* adapter.openSession({
362 threadId,
363 providerSessionId: ProviderSessionId.make("cursor-failure-session"),
364 modelSelection,
365 runtimePolicy,
366 });
367 const providerThread = yield* runtime.ensureThread({
368 threadId,
369 modelSelection,
370 runtimePolicy,
371 });
372 const now = yield* DateTime.now;
373 yield* runtime.startTurn({
374 threadId,
375 providerThread,
376 modelSelection,
377 runtimePolicy,
378 runId: RunId.make("cursor-failure-run"),
379 runOrdinal: 1,
380 providerTurnOrdinal: 1,
381 attemptId: RunAttemptId.make("cursor-failure-attempt"),
382 rootNodeId: NodeId.make("cursor-failure-root"),
383 appThread: {
384 id: threadId,
385 projectId: ProjectId.make("cursor-failure-project"),
386 createdBy: "user",
387 creationSource: "web",
388 title: "Cursor failure",
389 providerInstanceId: instanceId,
390 modelSelection,
391 runtimeMode: "full-access",
392 interactionMode: "default",
393 branch: null,
394 worktreePath: null,
395 activeProviderThreadId: providerThread.id,
396 lineage: { parentThreadId: null, relationshipToParent: null, rootThreadId: threadId },
397 forkedFrom: null,
398 createdAt: now,
399 updatedAt: now,
400 archivedAt: null,
401 settledOverride: null,
402 settledAt: null,
403 lastVisitedAt: null,
404 deletedAt: null,
405 },
406 message: {
407 messageId: MessageId.make("cursor-failure-message"),
408 createdBy: "user",
409 creationSource: "web",
410 text: "hi",
411 attachments: [],
412 },
413 });
414 const events = yield* runtime.events.pipe(
415 Stream.takeUntil((event) => event.type === "turn.terminal"),
416 Stream.runCollect,
417 );
418 const terminal = events.find((event) => event.type === "turn.terminal");
419 assert.equal(terminal?.status, failure === null ? "completed" : "failed");
420 assert.equal(terminal?.failure?.class, failure?.class);
421 assert.equal(terminal?.failure?.message, failure?.message);
422 if (answers !== undefined) {
423 assert.deepEqual(
424 events.flatMap((event) =>
425 event.type === "message.updated" && event.message.role === "assistant"
426 ? [event.message.text]
427 : [],
428 ),
429 answers,
430 );
431 }
432 }).pipe(
433 Effect.scoped,
434 Effect.provide(
435 Layer.mergeAll(NodeServices.layer, IdAllocator.layer, McpProviderSessions.layer),
436 ),
437 ),
438 );
439​
440 it.effect("fails standalone SDK transport diagnostics and sends compaction as /compress", () =>
441 Effect.gen(function* () {
442 const fileSystem = yield* FileSystem.FileSystem;
443 const workspace = yield* fileSystem.makeTempDirectoryScoped({ prefix: "cursor-v2-errors-" });
444 const sentMessages: Array<string> = [];
445 let sendCalls = 0;
446 const instanceId = ProviderInstanceId.make("cursor");
447 const threadId = ThreadId.make("cursor-transport-error-thread");
448 const modelSelection = { instanceId, model: "composer-2.5" };
449 const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
450 runtimeMode: "full-access",
451 interactionMode: "default",
452 cwd: workspace,
453 });
454 const adapter = yield* makeCursorAdapterV2({
455 instanceId,
456 environment: { HOME: workspace },
457 }).pipe(
458 Effect.provideService(CursorAgentSdk.CursorAgentSdkRunner, {
459 assertComplete: Effect.void,
460 open: () =>
461 Effect.succeed({
462 agentId: "native-cursor-error",
463 listMessages: Effect.succeed([]),
464 close: Effect.void,
465 send: (input) =>
466 Effect.sync(() => {
467 sendCalls += 1;
468 sentMessages.push(
469 typeof input.message === "string" ? input.message : input.message.text,
470 );
471 const runId = `native-cursor-run-${sendCalls}`;
472 return {
473 agentId: "native-cursor-error",
474 runId,
475 wait: Effect.succeed({
476 id: runId,
477 requestId: `native-request-${sendCalls}`,
478 status: "finished" as const,
479 model: { id: "composer-2.5" },
480 durationMs: 1,
481 ...(sendCalls === 1
482 ? { result: "Error: RetriableError: WritableIterable is closed" }
483 : {}),
484 }),
485 cancel: Effect.void,
486 };
487 }),
488 }),
489 }),
490 Effect.provide(TestProviderHost.layer({ cwd: workspace })),
491 );
492 const runtime = yield* adapter.openSession({
493 threadId,
494 providerSessionId: ProviderSessionId.make("cursor-error-session"),
495 modelSelection,
496 runtimePolicy,
497 });
498 const providerThread = yield* runtime.ensureThread({
499 threadId,
500 modelSelection,
501 runtimePolicy,
502 });
503 const now = yield* DateTime.now;
504 const appThread = {
505 id: threadId,
506 projectId: ProjectId.make("cursor-error-project"),
507 createdBy: "user" as const,
508 creationSource: "web" as const,
509 title: "Cursor transport failure",
510 providerInstanceId: instanceId,
511 modelSelection,
512 runtimeMode: "full-access" as const,
513 interactionMode: "default" as const,
514 branch: null,
515 worktreePath: null,
516 activeProviderThreadId: providerThread.id,
517 lineage: { parentThreadId: null, relationshipToParent: null, rootThreadId: threadId },
518 forkedFrom: null,
519 createdAt: now,
520 updatedAt: now,
521 archivedAt: null,
522 settledOverride: null,
523 settledAt: null,
524 lastVisitedAt: null,
525 deletedAt: null,
526 };
527 yield* runtime.startTurn({
528 threadId,
529 providerThread,
530 modelSelection,
531 runtimePolicy,
532 runId: RunId.make("cursor-error-run"),
533 runOrdinal: 1,
534 providerTurnOrdinal: 1,
535 attemptId: RunAttemptId.make("cursor-error-attempt"),
536 rootNodeId: NodeId.make("cursor-error-root"),
537 appThread,
538 message: {
539 messageId: MessageId.make("cursor-error-message"),
540 createdBy: "user",
541 creationSource: "web",
542 text: "continue",
543 attachments: [],
544 },
545 });
546 const first = yield* runtime.events.pipe(
547 Stream.filter((event) => event.type === "turn.terminal"),
548 Stream.runHead,
549 );
550 assert.isTrue(Option.isSome(first));
551 if (Option.isSome(first)) {
552 assert.equal(first.value.status, "failed");
553 assert.equal(first.value.failure?.class, "transport_error");
554 }
555​
556 assert.isDefined(runtime.compactThread);
557 yield* runtime.compactThread!({
558 threadId,
559 providerThread,
560 modelSelection,
561 runtimePolicy,
562 runId: RunId.make("cursor-compact-run"),
563 runOrdinal: 2,
564 providerTurnOrdinal: 2,
565 attemptId: RunAttemptId.make("cursor-compact-attempt"),
566 rootNodeId: NodeId.make("cursor-compact-root"),
567 appThread,
568 message: {
569 messageId: MessageId.make("cursor-compact-message"),
570 createdBy: "user",
571 creationSource: "web",
572 text: "ignored by compactThread",
573 attachments: [],
574 },
575 });
576 yield* runtime.events.pipe(
577 Stream.filter((event) => event.type === "turn.terminal"),
578 Stream.runHead,
579 );
580 assert.equal(sentMessages[1], "/compress");
581 }).pipe(
582 Effect.scoped,
583 Effect.provide(
584 Layer.mergeAll(NodeServices.layer, IdAllocator.layer, McpProviderSessions.layer),
585 ),
586 ),
587 );
588​
589 it.effect("sends T3 instructions to each Cursor conversation that lacks them", () =>
590 Effect.gen(function* () {
591 const fileSystem = yield* FileSystem.FileSystem;
592 const workspace = yield* fileSystem.makeTempDirectoryScoped({ prefix: "cursor-v2-device-" });
593 const sentMessages: Array<string> = [];
594 const instanceId = ProviderInstanceId.make("cursor");
595 const threadId = ThreadId.make("cursor-device-thread");
596 const mcpSessions = yield* McpProviderSessions.McpProviderSessions;
597 const setDeviceAccess = (device: boolean) =>
598 mcpSessions.set({
599 environmentId: EnvironmentId.make("cursor-device-environment"),
600 threadId,
601 providerSessionId: "cursor-device-session",
602 providerInstanceId: instanceId,
603 endpoint: "http://127.0.0.1:43123/mcp",
604 authorizationHeader: "Bearer synthetic-cursor-token",
605 browserToolsAvailable: true,
606 capabilities: new Set(device ? ["device"] : []),
607 });
608 const modelSelection = { instanceId, model: "composer-2.5" };
609 const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
610 runtimeMode: "full-access",
611 interactionMode: "default",
612 cwd: workspace,
613 });
614 const adapter = yield* makeCursorAdapterV2({
615 instanceId,
616 environment: { HOME: workspace },
617 }).pipe(
618 Effect.provideService(CursorAgentSdk.CursorAgentSdkRunner, {
619 assertComplete: Effect.void,
620 open: () =>
621 Effect.succeed({
622 agentId: "native-cursor-device",
623 listMessages: Effect.succeed([]),
624 close: Effect.void,
625 send: (input) =>
626 Effect.sync(() => {
627 sentMessages.push(
628 typeof input.message === "string" ? input.message : input.message.text,
629 );
630 const runId = `native-cursor-run-${sentMessages.length}`;
631 return {
632 agentId: "native-cursor-device",
633 runId,
634 wait: Effect.succeed({
635 id: runId,
636 requestId: `native-request-${sentMessages.length}`,
637 status: "finished" as const,
638 model: { id: "composer-2.5" },
639 durationMs: 1,
640 }),
641 cancel: Effect.void,
642 };
643 }),
644 }),
645 }),
646 Effect.provide(TestProviderHost.layer({ cwd: workspace })),
647 );
648 const runtime = yield* adapter.openSession({
649 threadId,
650 providerSessionId: ProviderSessionId.make("cursor-device-session"),
651 modelSelection,
652 runtimePolicy,
653 });
654 const providerThread = yield* runtime.ensureThread({
655 threadId,
656 modelSelection,
657 runtimePolicy,
658 });
659 const now = yield* DateTime.now;
660 const appThread = {
661 id: threadId,
662 projectId: ProjectId.make("cursor-device-project"),
663 createdBy: "user" as const,
664 creationSource: "web" as const,
665 title: "Cursor devices",
666 providerInstanceId: instanceId,
667 modelSelection,
668 runtimeMode: "full-access" as const,
669 interactionMode: "default" as const,
670 branch: null,
671 worktreePath: null,
672 activeProviderThreadId: providerThread.id,
673 lineage: { parentThreadId: null, relationshipToParent: null, rootThreadId: threadId },
674 forkedFrom: null,
675 createdAt: now,
676 updatedAt: now,
677 archivedAt: null,
678 settledOverride: null,
679 settledAt: null,
680 lastVisitedAt: null,
681 deletedAt: null,
682 };
683 // Starts at run 5: a conversation from before device instructions existed, now resumed.
684 let runOrdinal = 4;
685 const send = Effect.fnUntraced(function* (compact = false) {
686 runOrdinal += 1;
687 const turnInput = {
688 threadId,
689 providerThread,
690 modelSelection,
691 runtimePolicy,
692 runId: RunId.make(`cursor-device-run-${runOrdinal}`),
693 runOrdinal,
694 providerTurnOrdinal: runOrdinal,
695 attemptId: RunAttemptId.make(`cursor-device-attempt-${runOrdinal}`),
696 rootNodeId: NodeId.make(`cursor-device-root-${runOrdinal}`),
697 appThread,
698 message: {
699 messageId: MessageId.make(`cursor-device-message-${runOrdinal}`),
700 createdBy: "user" as const,
701 creationSource: "web" as const,
702 text: "Open the app.",
703 attachments: [],
704 },
705 };
706 yield* compact ? runtime.compactThread!(turnInput) : runtime.startTurn(turnInput);
707 yield* runtime.events.pipe(
708 Stream.filter((event) => event.type === "turn.terminal"),
709 Stream.runHead,
710 );
711 const sent = sentMessages.at(-1)!;
712 return {
713 orchestration: sent.includes("## T3 Code orchestration"),
714 devices: sent.includes("## T3 Code devices"),
715 };
716 });
717 const told = (orchestration: boolean, devices: boolean) => ({ orchestration, devices });
718​
719 yield* setDeviceAccess(true);
720 assert.deepEqual(yield* send(), told(false, true));
721 assert.deepEqual(yield* send(), told(false, false));
722 yield* send(true);
723 assert.deepEqual(
724 yield* send(),
725 told(true, true),
726 "compaction drops what the conversation was told",
727 );
728 yield* setDeviceAccess(false);
729 assert.deepEqual(yield* send(), told(false, false));
730 yield* setDeviceAccess(true);
731 assert.deepEqual(yield* send(), told(false, true), "device access turned on later");
732 assert.deepEqual(yield* send(), told(false, false));
733 }).pipe(
734 Effect.scoped,
735 Effect.provide(
736 Layer.mergeAll(NodeServices.layer, IdAllocator.layer, McpProviderSessions.layer),
737 ),
738 ),
739 );
740​
741 it.effect("projects Cursor directory trees and lint diagnostics as file search results", () =>
742 Effect.gen(function* () {
743 const fileSystem = yield* FileSystem.FileSystem;
744 const path = yield* Path.Path;
745 const workspace = yield* fileSystem.makeTempDirectoryScoped({ prefix: "cursor-v2-search-" });
746 const instanceId = ProviderInstanceId.make("cursor");
747 const threadId = ThreadId.make("cursor-search-thread");
748 const modelSelection = { instanceId, model: "composer-2.5" };
749 const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
750 runtimeMode: "full-access",
751 interactionMode: "default",
752 cwd: workspace,
753 });
754 const emptyLsNode = {
755 childrenDirs: [],
756 childrenFiles: [],
757 childrenWereProcessed: true,
758 fullSubtreeExtensionCounts: {},
759 numFiles: 0,
760 };
761 const updates: ReadonlyArray<InteractionUpdate> = [
762 ...(["tool-call-started", "tool-call-completed"] as const).map((type) => ({
763 type,
764 modelCallId: "native-model-call",
765 callId: "mcp-weather",
766 toolCall: {
767 type: "mcp" as const,
768 args: {
769 providerIdentifier: "weather",
770 toolName: "get_weather",
771 args: { city: "Berlin" },
772 },
773 ...(type === "tool-call-completed"
774 ? { result: { status: "success" as const, value: { content: [], isError: false } } }
775 : {}),
776 },
777 })),
778 {
779 type: "tool-call-completed",
780 modelCallId: "native-model-call",
781 callId: "read-file",
782 toolCall: {
783 type: "read",
784 args: { path: "src/env.ts" },
785 result: {
786 status: "success",
787 value: { fileSize: 12, content: "---\nfile body", totalLines: 2 },
788 },
789 },
790 },
791 {
792 type: "tool-call-completed",
793 modelCallId: "native-model-call",
794 callId: "ls-nested",
795 toolCall: {
796 type: "ls",
797 args: { path: workspace },
798 result: {
799 status: "success",
800 value: {
801 directoryTreeRoot: {
802 ...emptyLsNode,
803 absPath: workspace,
804 childrenFiles: [{ name: "README.md" }],
805 childrenDirs: [
806 {
807 ...emptyLsNode,
808 absPath: path.join(workspace, "src"),
809 childrenFiles: [{ name: "index.ts" }],
810 childrenDirs: [
811 {
812 ...emptyLsNode,
813 absPath: path.join(workspace, "src", "nested"),
814 childrenFiles: [{ name: "util.ts" }],
815 },
816 ],
817 },
818 ],
819 },
820 },
821 },
822 },
823 },
824 {
825 type: "tool-call-completed",
826 modelCallId: "native-model-call",
827 callId: "ls-empty",
828 toolCall: {
829 type: "ls",
830 args: { path: path.join(workspace, "empty") },
831 result: {
832 status: "success",
833 value: {
834 directoryTreeRoot: { ...emptyLsNode, absPath: path.join(workspace, "empty") },
835 },
836 },
837 },
838 },
839 {
840 type: "tool-call-completed",
841 modelCallId: "native-model-call",
842 callId: "ls-failed",
843 toolCall: {
844 type: "ls",
845 args: { path: path.join(workspace, "missing") },
846 result: { status: "error", error: "ENOENT" },
847 },
848 },
849 {
850 type: "tool-call-completed",
851 modelCallId: "native-model-call",
852 callId: "grep-failed",
853 toolCall: {
854 type: "grep",
855 args: { pattern: "TODO", path: "src" },
856 result: { status: "error", error: "search failed" },
857 },
858 },
859 {
860 type: "tool-call-completed",
861 modelCallId: "native-model-call",
862 callId: "glob-failed",
863 toolCall: {
864 type: "glob",
865 args: { globPattern: "*.ts" },
866 result: { status: "error", error: "search failed" },
867 },
868 },
869 {
870 type: "tool-call-completed",
871 modelCallId: "native-model-call",
872 callId: "lints",
873 toolCall: {
874 type: "readLints",
875 args: { paths: ["src/a.ts", "src/b.ts"] },
876 result: {
877 status: "success",
878 value: {
879 totalFiles: 2,
880 totalDiagnostics: 3,
881 fileDiagnostics: [
882 {
883 path: "src/a.ts",
884 diagnosticsCount: 2,
885 diagnostics: [
886 {
887 message: "Unused variable",
888 code: "TS6133",
889 source: "ts",
890 severity: "warning",
891 range: { start: { line: 0, character: 4 } },
892 },
893 {
894 message: "Cannot find name",
895 code: "TS2304",
896 source: "ts",
897 severity: "error",
898 range: { start: { line: 11 } },
899 },
900 ],
901 },
902 {
903 path: "src/b.ts",
904 diagnosticsCount: 1,
905 diagnostics: [
906 {
907 message: "File-level diagnostic",
908 code: "TS0",
909 source: "ts",
910 severity: "information",
911 },
912 ],
913 },
914 ],
915 },
916 },
917 },
918 },
919 {
920 type: "tool-call-completed",
921 modelCallId: "native-model-call",
922 callId: "lints-empty",
923 toolCall: {
924 type: "readLints",
925 args: { paths: ["src/clean.ts"] },
926 result: {
927 status: "success",
928 value: {
929 totalFiles: 1,
930 totalDiagnostics: 0,
931 fileDiagnostics: [{ path: "src/clean.ts", diagnosticsCount: 0, diagnostics: [] }],
932 },
933 },
934 },
935 },
936 {
937 type: "tool-call-completed",
938 modelCallId: "native-model-call",
939 callId: "lints-failed",
940 toolCall: {
941 type: "readLints",
942 args: { paths: ["src/a.ts"] },
943 result: { status: "error", error: "lint failed" },
944 },
945 },
946 ];
947 const adapter = yield* makeCursorAdapterV2({
948 instanceId,
949 environment: { HOME: workspace },
950 }).pipe(
951 Effect.provideService(CursorAgentSdk.CursorAgentSdkRunner, {
952 assertComplete: Effect.void,
953 open: () =>
954 Effect.succeed({
955 agentId: "native-cursor-search",
956 listMessages: Effect.succeed([]),
957 close: Effect.void,
958 send: (input) =>
959 Effect.gen(function* () {
960 for (const update of updates) {
961 if (input.onDelta !== undefined) {
962 yield* input.onDelta(update).pipe(Effect.orDie);
963 }
964 }
965 return {
966 agentId: "native-cursor-search",
967 runId: "native-cursor-run",
968 wait: Effect.succeed({
969 id: "native-cursor-run",
970 requestId: "native-request",
971 status: "finished" as const,
972 model: { id: "composer-2.5" },
973 durationMs: 1,
974 }),
975 cancel: Effect.void,
976 };
977 }),
978 }),
979 }),
980 Effect.provide(TestProviderHost.layer({ cwd: workspace })),
981 );
982 const runtime = yield* adapter.openSession({
983 threadId,
984 providerSessionId: ProviderSessionId.make("cursor-search-session"),
985 modelSelection,
986 runtimePolicy,
987 });
988 const providerThread = yield* runtime.ensureThread({
989 threadId,
990 modelSelection,
991 runtimePolicy,
992 });
993 const now = yield* DateTime.now;
994 yield* runtime.startTurn({
995 threadId,
996 providerThread,
997 modelSelection,
998 runtimePolicy,
999 runId: RunId.make("cursor-search-run"),
1000 runOrdinal: 1,
1001 providerTurnOrdinal: 1,
1002 attemptId: RunAttemptId.make("cursor-search-attempt"),
1003 rootNodeId: NodeId.make("cursor-search-root"),
1004 appThread: {
1005 id: threadId,
1006 projectId: ProjectId.make("cursor-search-project"),
1007 createdBy: "user",
1008 creationSource: "web",
1009 title: "Cursor search results",
1010 providerInstanceId: instanceId,
1011 modelSelection,
1012 runtimeMode: "full-access",
1013 interactionMode: "default",
1014 branch: null,
1015 worktreePath: null,
1016 activeProviderThreadId: providerThread.id,
1017 lineage: { parentThreadId: null, relationshipToParent: null, rootThreadId: threadId },
1018 forkedFrom: null,
1019 createdAt: now,
1020 updatedAt: now,
1021 archivedAt: null,
1022 settledOverride: null,
1023 settledAt: null,
1024 lastVisitedAt: null,
1025 deletedAt: null,
1026 },
1027 message: {
1028 messageId: MessageId.make("cursor-search-message"),
1029 createdBy: "user",
1030 creationSource: "web",
1031 text: "inspect the workspace",
1032 attachments: [],
1033 },
1034 });
1035 const events = yield* runtime.events.pipe(
1036 Stream.takeUntil((event) => event.type === "turn.terminal"),
1037 Stream.runCollect,
1038 );
1039 const mcpItems = events.flatMap((event) =>
1040 event.type === "turn_item.updated" &&
1041 event.turnItem.type === "dynamic_tool" &&
1042 event.turnItem.toolName === "mcp__weather__get_weather"
1043 ? [event.turnItem]
1044 : [],
1045 );
1046 assert.deepEqual(
1047 mcpItems.map((item) => item.status),
1048 ["running", "completed"],
1049 );
1050 for (const item of mcpItems) {
1051 assert.equal(item.title, "get weather");
1052 assert.deepEqual(item.toolSource, {
1053 key: "mcp:weather",
1054 name: "weather",
1055 kind: "integration",
1056 });
1057 assert.deepEqual(item.input, { city: "Berlin" });
1059 const fileSearchItems = events.flatMap((event) =>
1060 event.type === "turn_item.updated" &&
1061 event.turnItem.type === "file_search" &&
1062 event.turnItem.status !== "running"
1063 ? [event.turnItem]
1064 : [],
1065 );
1066 const readItems = events.flatMap((event) =>
1067 event.type === "turn_item.updated" &&
1068 event.turnItem.type === "dynamic_tool" &&
1069 event.turnItem.toolName === "Read" &&
1070 event.turnItem.status === "completed"
1071 ? [event.turnItem]
1072 : [],
1073 );
1074 assert.deepEqual(
1075 readItems.map((item) => ({ title: item.title, input: item.input })),
1076 [{ title: "Read src/env.ts", input: { path: "src/env.ts" } }],
1077 );
1078 assert.deepEqual(
1079 fileSearchItems.map((item) => ({
1080 pattern: item.pattern,
1081 status: item.status,
1082 results: item.results,
1083 })),
1086 pattern: workspace,
1087 status: "completed",
1088 results: [
1089 { fileName: path.join(workspace, "README.md") },
1090 { fileName: path.join(workspace, "src", "index.ts") },
1091 { fileName: path.join(workspace, "src", "nested", "util.ts") },
1092 ],
1093 },
1095 pattern: path.join(workspace, "empty"),
1096 status: "completed",
1097 results: undefined,
1098 },
1100 pattern: path.join(workspace, "missing"),
1101 status: "failed",
1102 results: [{ fileName: path.join(workspace, "missing"), preview: "ENOENT" }],
1103 },
1105 pattern: "TODO",
1106 status: "failed",
1107 results: [{ fileName: "src", preview: "search failed" }],
1108 },
1110 pattern: "*.ts",
1111 status: "failed",
1112 results: [{ fileName: ".", preview: "search failed" }],
1113 },
1115 pattern: "src/a.ts, src/b.ts",
1116 status: "completed",
1117 results: [
1118 { fileName: "src/a.ts", line: 1, column: 5, preview: "Unused variable" },
1119 { fileName: "src/a.ts", line: 12, preview: "Cannot find name" },
1120 { fileName: "src/b.ts", preview: "File-level diagnostic" },
1121 ],
1122 },
1124 pattern: "src/clean.ts",
1125 status: "completed",
1126 results: undefined,
1127 },
1129 pattern: "src/a.ts",
1130 status: "failed",
1131 results: [{ fileName: "src/a.ts", preview: "lint failed" }],
1132 },
1133 ],
1134 );
1135 }).pipe(
1136 Effect.scoped,
1137 Effect.provide(
1138 Layer.mergeAll(NodeServices.layer, IdAllocator.layer, McpProviderSessions.layer),
1139 ),
1140 ),
1141 );
1142​
1143 it.effect("names a custom model Cursor's account catalog rejects", () =>
1144 Effect.gen(function* () {
1145 const fileSystem = yield* FileSystem.FileSystem;
1146 const workspace = yield* fileSystem.makeTempDirectoryScoped({ prefix: "cursor-v2-model-" });
1147 const instanceId = ProviderInstanceId.make("cursor");
1148 const threadId = ThreadId.make("cursor-custom-model-thread");
1149 const catalogModel = { instanceId, model: "composer-2.5" };
1150 const customModel = { instanceId, model: "deepseek/deepseek-v4.1-flash" };
1151 const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
1152 runtimeMode: "full-access",
1153 interactionMode: "default",
1154 cwd: workspace,
1155 });
1156 // The SDK checks every create, resume, and send model against the account catalog.
1157 const checkModel = (method: string, model: { readonly id: string } | undefined) =>
1158 model === undefined || model.id === "composer-2.5"
1159 ? Effect.void
1160 : Effect.fail(
1161 new CursorAgentSdk.CursorAgentSdkRunnerError({
1162 method,
1163 cause: new ConfigurationError(
1164 `Cannot use this model: ${model.id}. Available models: default, composer-2.5. Use Cursor.models.list() to discover valid selections.`,
1165 { isRetryable: false },
1166 ),
1167 }),
1168 );
1169 const adapter = yield* makeCursorAdapterV2({
1170 instanceId,
1171 environment: { HOME: workspace },
1172 }).pipe(
1173 Effect.provideService(CursorAgentSdk.CursorAgentSdkRunner, {
1174 assertComplete: Effect.void,
1175 open: (input) =>
1176 checkModel(`agent.${input.operation}`, input.options.model).pipe(
1177 Effect.as({
1178 agentId: "native-cursor-custom-model",
1179 listMessages: Effect.succeed([]),
1180 close: Effect.void,
1181 send: (sendInput) =>
1182 checkModel("run.start", sendInput.options?.model).pipe(
1183 Effect.andThen(Effect.die("unexpected Cursor run")),
1184 ),
1185 }),
1186 ),
1187 }),
1188 Effect.provide(TestProviderHost.layer({ cwd: workspace })),
1189 );
1190 const runtime = yield* adapter.openSession({
1191 threadId,
1192 providerSessionId: ProviderSessionId.make("cursor-custom-model-session"),
1193 modelSelection: catalogModel,
1194 runtimePolicy,
1195 });
1196 const expected =
1197 'Cursor cannot run the model "deepseek/deepseek-v4.1-flash". Cursor only runs models from your Cursor account. Choose one of those, or use OpenCode for OpenRouter and other API-key models.';
1198​
1199 const createFailure = yield* runtime
1200 .ensureThread({ threadId, modelSelection: customModel, runtimePolicy })
1201 .pipe(Effect.flip);
1202 assert.equal(makeProviderFailure({ cause: createFailure }).message, expected);
1203​
1204 const providerThread = yield* runtime.ensureThread({
1205 threadId,
1206 modelSelection: catalogModel,
1207 runtimePolicy,
1208 });
1209 const now = yield* DateTime.now;
1210 const sendFailure = yield* runtime
1211 .startTurn({
1212 threadId,
1213 providerThread,
1214 modelSelection: customModel,
1215 runtimePolicy,
1216 runId: RunId.make("cursor-custom-model-run"),
1217 runOrdinal: 1,
1218 providerTurnOrdinal: 1,
1219 attemptId: RunAttemptId.make("cursor-custom-model-attempt"),
1220 rootNodeId: NodeId.make("cursor-custom-model-root"),
1221 appThread: {
1222 id: threadId,
1223 projectId: ProjectId.make("cursor-custom-model-project"),
1224 createdBy: "user",
1225 creationSource: "web",
1226 title: "Cursor custom model",
1227 providerInstanceId: instanceId,
1228 modelSelection: customModel,
1229 runtimeMode: "full-access",
1230 interactionMode: "default",
1231 branch: null,
1232 worktreePath: null,
1233 activeProviderThreadId: providerThread.id,
1234 lineage: { parentThreadId: null, relationshipToParent: null, rootThreadId: threadId },
1235 forkedFrom: null,
1236 createdAt: now,
1237 updatedAt: now,
1238 archivedAt: null,
1239 settledOverride: null,
1240 settledAt: null,
1241 lastVisitedAt: null,
1242 deletedAt: null,
1243 },
1244 message: {
1245 messageId: MessageId.make("cursor-custom-model-message"),
1246 createdBy: "user",
1247 creationSource: "web",
1248 text: "Hello.",
1249 attachments: [],
1250 },
1251 })
1252 .pipe(Effect.flip);
1253 assert.equal(makeProviderFailure({ cause: sendFailure }).message, expected);
1254 }).pipe(
1255 Effect.scoped,
1256 Effect.provide(
1257 Layer.mergeAll(NodeServices.layer, IdAllocator.layer, McpProviderSessions.layer),
1258 ),
1259 ),
1260 );
1261​
1262 it("maps runtime modes to the SDK sandbox and auto-review controls", () => {
1263 const base = {
1264 interactionMode: "default" as const,
1265 cwd: "/tmp/cursor-adapter",
1266 };
1267 assert.deepEqual(
1268 cursorRuntimeAgentPolicy(
1270 ...base,
1271 runtimeMode: "full-access",
1272 },
1273 "linux",
1274 ),
1276 autoReview: false,
1277 sandboxEnabled: false,
1278 },
1279 );
1280 assert.deepEqual(
1281 cursorRuntimeAgentPolicy(
1283 ...base,
1284 runtimeMode: "auto-accept-edits",
1285 },
1286 "linux",
1287 ),
1289 autoReview: false,
1290 sandboxEnabled: true,
1291 },
1292 );
1293 assert.deepEqual(
1294 cursorRuntimeAgentPolicy(
1296 ...base,
1297 runtimeMode: "auto",
1298 },
1299 "linux",
1300 ),
1302 autoReview: true,
1303 sandboxEnabled: true,
1304 },
1305 );
1306 assert.deepEqual(
1307 cursorRuntimeAgentPolicy(
1309 ...base,
1310 runtimeMode: "approval-required",
1311 },
1312 "linux",
1313 ),
1315 autoReview: true,
1316 sandboxEnabled: true,
1317 },
1318 );
1319 assert.deepEqual(
1320 cursorRuntimeAgentPolicy(
1322 ...base,
1323 runtimeMode: "full-access",
1324 approvalPolicy: "never",
1325 sandboxPolicy: { type: "readOnly" },
1326 },
1327 "linux",
1328 ),
1330 autoReview: false,
1331 sandboxEnabled: true,
1332 },
1333 );
1334 assert.deepEqual(
1335 cursorRuntimeAgentPolicy(
1337 ...base,
1338 runtimeMode: "approval-required",
1339 approvalPolicy: "never",
1340 sandboxPolicy: { type: "dangerFullAccess" },
1341 },
1342 "linux",
1343 ),
1345 autoReview: false,
1346 sandboxEnabled: false,
1347 },
1348 );
1349 assert.deepEqual(
1350 cursorRuntimeAgentPolicy(
1352 ...base,
1353 runtimeMode: "auto-accept-edits",
1354 },
1355 "win32",
1356 ),
1358 autoReview: false,
1359 sandboxEnabled: true,
1360 },
1361 );
1362 assert.deepEqual(
1363 cursorRuntimeAgentPolicy(
1365 ...base,
1366 runtimeMode: "auto",
1367 approvalPolicy: "never",
1368 },
1369 "win32",
1370 ),
1372 autoReview: false,
1373 sandboxEnabled: true,
1374 },
1375 );
1376 // Auto-review can gate Windows execution without the unsupported SDK sandbox.
1377 assert.deepEqual(
1378 cursorRuntimeAgentPolicy(
1380 ...base,
1381 runtimeMode: "auto",
1382 },
1383 "win32",
1384 ),
1386 autoReview: true,
1387 sandboxEnabled: false,
1388 },
1389 );
1390 assert.deepEqual(
1391 cursorRuntimeAgentPolicy(
1393 ...base,
1394 runtimeMode: "auto",
1395 sandboxPolicy: { type: "workspaceWrite" },
1396 },
1397 "win32",
1398 ),
1400 autoReview: true,
1401 sandboxEnabled: true,
1402 },
1403 );
1404 });
1405​
1406 it("injects thread-scoped MCP credentials without logging them", () => {
1407 const threadId = ThreadId.make("thread-cursor-mcp");
1408 const mcpSession = {
1409 environmentId: EnvironmentId.make("environment-cursor-mcp"),
1410 threadId,
1411 providerSessionId: "mcp-session-cursor",
1412 providerInstanceId: ProviderInstanceId.make("cursor"),
1413 endpoint: "http://127.0.0.1:43123/mcp",
1414 authorizationHeader: "Bearer secret-cursor-mcp-token",
1415 browserToolsAvailable: true,
1416 };
1417​
1418 assert.deepEqual(cursorMcpServers(mcpSession), {
1419 "t3-code": {
1420 type: "http",
1421 url: "http://127.0.0.1:43123/mcp",
1422 headers: {
1423 Authorization: "Bearer secret-cursor-mcp-token",
1424 },
1425 },
1426 });
1427​
1428 const options = makeCursorAgentOptions({
1429 apiKey: "secret-cursor-api-key",
1430 modelSelection: {
1431 instanceId: ProviderInstanceId.make("cursor"),
1432 model: "composer-2.5",
1433 },
1434 runtimePolicy: {
1435 runtimeMode: "full-access",
1436 interactionMode: "default",
1437 cwd: "/workspace",
1438 },
1439 threadId,
1440 mcpSession,
1441 platform: "linux",
1442 });
1443 assert.deepEqual(options.mcpServers, cursorMcpServers(mcpSession));
1444​
1445 const logged = JSON.stringify(CursorAgentSdk.loggedCursorAgentOptions(options));
1446 assert.notInclude(logged, "secret-cursor-api-key");
1447 assert.notInclude(logged, "secret-cursor-mcp-token");
1448 });
1449​
1450 it("recognizes direct and SDK-wrapped abort failures as cancellation", () => {
1451 assert.isTrue(CursorAgentSdk.isCursorCancellationError({ name: "AbortError" }));
1452 assert.isTrue(
1453 CursorAgentSdk.isCursorCancellationError({
1454 name: "ConnectError",
1455 cause: {
1456 name: "ConnectError",
1457 cause: { name: "AbortError" },
1458 },
1459 }),
1460 );
1461 assert.isFalse(CursorAgentSdk.isCursorCancellationError(new Error("request failed")));
1462 assert.isFalse(CursorAgentSdk.isCursorCancellationError(null));
1463 });
1464​
1465 it("preserves failed nested read calls when Cursor omits their path", () => {
1466 assert.deepEqual(
1467 nestedToolCallFromEnvelope({
1468 toolCallId: "tool:failed-read",
1469 readToolCall: {
1470 args: {},
1471 result: { error: "File path was not provided." },
1472 },
1473 }),
1475 callId: "tool:failed-read",
1476 toolCall: {
1477 type: "read",
1478 args: { path: "<unknown path>" },
1479 result: {
1480 status: "error",
1481 error: "File path was not provided.",
1482 },
1483 },
1484 },
1485 );
1486 });
1487});