|
| 1 | +import * as NodeURL from "node:url"; |
1 | 2 | import * as NodeServices from "@effect/platform-node/NodeServices"; |
2 | 3 | import { describe, expect, it } from "@effect/vitest"; |
3 | 4 | import { |
@@ -96,9 +97,7 @@ const readDelegatedTaskStatusTranscript = Effect.fn("readDelegatedTaskStatusTran |
96 | 97 | followupResult: string, |
97 | 98 | ) { |
98 | 99 | const fs = yield* FileSystem.FileSystem; |
99 | | - const text = yield* fs.readFileString( |
100 | | - decodeURIComponent(delegatedTaskStatusTranscriptFile.pathname), |
101 | | - ); |
| 100 | + const text = yield* fs.readFileString(NodeURL.fileURLToPath(delegatedTaskStatusTranscriptFile)); |
102 | 101 | const transcript = yield* decodeProviderReplayNdjson( |
103 | 102 | text.replaceAll(queuedFollowupResult, followupResult), |
104 | 103 | ); |
@@ -315,11 +314,11 @@ describe("orchestrator MCP toolkit", () => { |
315 | 314 | capabilities: new Set(["orchestration"]), |
316 | 315 | issuedAt: 1, |
317 | 316 | }; |
318 | | - const invoke = (name: string, args: Record<string, unknown>) => |
| 317 | + const invoke = (name: string, args: Record<string, unknown>, scope = invocation) => |
319 | 318 | server |
320 | 319 | .callTool({ name, arguments: args }) |
321 | 320 | .pipe( |
322 | | - Effect.provideService(McpInvocationContext.McpInvocationContext, invocation), |
| 321 | + Effect.provideService(McpInvocationContext.McpInvocationContext, scope), |
323 | 322 | Effect.provideService(McpSchema.McpServerClient, client), |
324 | 323 | ); |
325 | 324 |
|
@@ -596,11 +595,24 @@ describe("orchestrator MCP toolkit", () => { |
596 | 595 | expect(finalStatus.latestTerminalResultContextTransferId).not.toBe( |
597 | 596 | delegated.resultContextTransferId, |
598 | 597 | ); |
| 598 | + const parentlessRead = yield* invoke( |
| 599 | + "t3_thread_read", |
| 600 | + { threadId: delegated.childThreadId, limit: 100 }, |
| 601 | + { ...invocation, thread: undefined }, |
| 602 | + ); |
| 603 | + expect(parentlessRead.isError).not.toBe(true); |
| 604 | + const afterParentlessRead = yield* orchestrator.getThreadProjection(parentThreadId); |
| 605 | + expect( |
| 606 | + afterParentlessRead.subagents.find((task) => task.id === queuedFollowup.taskId) |
| 607 | + ?.completionDelivery?.state, |
| 608 | + ).toBe("claimed"); |
| 609 | + |
599 | 610 | const read = yield* invoke("t3_thread_read", { |
600 | 611 | threadId: delegated.childThreadId, |
601 | 612 | limit: 100, |
602 | 613 | }); |
603 | 614 | expect(read.isError).not.toBe(true); |
| 615 | + expect(read.structuredContent).toEqual(parentlessRead.structuredContent); |
604 | 616 | const afterRead = yield* orchestrator.getThreadProjection(parentThreadId); |
605 | 617 | expect( |
606 | 618 | afterRead.subagents.find((task) => task.id === queuedFollowup.taskId) |
|
0 commit comments