@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 03:37 UTC

main
ts 84 lines 2.82 KB
Raw
1 import { describe, expect, it } from "@effect/vitest";
2 import * as Schema from "effect/Schema";
3
4 import {
5 OrchestratorMcpDelegateTaskInput,
6 OrchestratorMcpDelegateTaskResult,
7 OrchestratorMcpThreadWaitResult,
8 } from "./orchestratorMcp.ts";
9
10 const decodeDelegateTaskInput = Schema.decodeUnknownSync(OrchestratorMcpDelegateTaskInput);
11 const decodeDelegateTaskResult = Schema.decodeUnknownSync(OrchestratorMcpDelegateTaskResult);
12 const decodeThreadWaitResult = Schema.decodeUnknownSync(OrchestratorMcpThreadWaitResult);
13
14 describe("orchestrator MCP contracts", () => {
15 it("decodes cross-provider delegated task requests and durable results", () => {
16 const request = decodeDelegateTaskInput({
17 task: "Inspect the workspace and report the result.",
18 target: {
19 providerInstanceId: "claudeAgent",
20 model: "claude-sonnet-4-6",
21 },
22 mode: "wait",
23 timeoutMs: 5_000,
24 clientRequestId: "delegate-1",
25 runtimeMode: "inherit",
26 interactionMode: "inherit",
27 });
28 const result = decodeDelegateTaskResult({
29 taskId: "node-task-1",
30 childThreadId: "thread-child-1",
31 childRunId: "run-child-1",
32 childNodeId: "node-task-1",
33 status: "completed",
34 workState: "result_available",
35 hasPendingChildRuns: false,
36 providerInstanceId: "claudeAgent",
37 model: "claude-sonnet-4-6",
38 summary: "Workspace inspected.",
39 resultContextTransferId: "context-transfer-result-1",
40 latestTerminalRunId: "run-child-1",
41 latestTerminalStatus: "completed",
42 latestTerminalSummary: "Workspace inspected.",
43 latestTerminalResultContextTransferId: "context-transfer-result-1",
44 hasPendingQuestion: false,
45 pendingApproval: null,
46 waitTimedOut: false,
47 });
48
49 expect(request.target?.providerInstanceId).toBe("claudeAgent");
50 expect(result.status).toBe("completed");
51 expect(result.summary).toBe("Workspace inspected.");
52 expect(result.pendingApproval).toBeNull();
53 const pendingApproval = {
54 requestId: "request-approval-1",
55 kind: "command",
56 runId: "run-child-1",
57 };
58 expect(
59 decodeDelegateTaskResult({
60 ...result,
61 pendingApproval: { ...pendingApproval, input: { command: "private command" } },
62 }).pendingApproval,
63 ).toEqual(pendingApproval);
64 expect(() =>
65 decodeDelegateTaskResult({
66 ...result,
67 pendingApproval: { ...pendingApproval, kind: "user_input" },
68 }),
69 ).toThrow();
70 });
71
72 it("decodes a running-task next written by another version", () => {
73 const next = "Completion wakes this thread, so end your turn. Do not wait on it or poll it.";
74 expect(
75 decodeThreadWaitResult({
76 threadId: "thread-child-1",
77 runId: "run-child-1",
78 status: "running",
79 timedOut: true,
80 next,
81 }).next,
82 ).toBe(next);
83 });
84 });