The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { |
| 2 | ProviderDriverKind, |
| 3 | ThreadId, |
| 4 | TurnItemId, |
| 5 | type OrchestrationV2TurnItem, |
| 6 | } from "@t3tools/contracts"; |
| 7 | import * as DateTime from "effect/DateTime"; |
| 8 | import { describe, expect, it } from "vite-plus/test"; |
| 9 | |
| 10 | import { commandItemOutput } from "./commandOutput.ts"; |
| 11 | |
| 12 | const envelope = |
| 13 | '{"stdout":"line 1\\n行 2 🚀","stderr":"é warning","interrupted":false,"requestId":"keep-me"}\n'; |
| 14 | |
| 15 | const commandItem = (driver: string, startedAt: string) => |
| 16 | ({ |
| 17 | id: TurnItemId.make("command"), |
| 18 | threadId: ThreadId.make("thread"), |
| 19 | runId: null, |
| 20 | nodeId: null, |
| 21 | providerThreadId: null, |
| 22 | providerTurnId: null, |
| 23 | nativeItemRef: { |
| 24 | driver: ProviderDriverKind.make(driver), |
| 25 | nativeId: "tool-1", |
| 26 | strength: "strong", |
| 27 | }, |
| 28 | parentItemId: null, |
| 29 | ordinal: 1, |
| 30 | status: "completed", |
| 31 | title: null, |
| 32 | startedAt: DateTime.makeUnsafe(startedAt), |
| 33 | completedAt: null, |
| 34 | updatedAt: DateTime.makeUnsafe(startedAt), |
| 35 | type: "command_execution", |
| 36 | input: "node print-json.js", |
| 37 | output: envelope, |
| 38 | }) satisfies OrchestrationV2TurnItem; |
| 39 | |
| 40 | describe("commandItemOutput", () => { |
| 41 | it("unwraps an early Claude row's raw Bash result into stdout and stderr", () => { |
| 42 | expect(commandItemOutput(commandItem("claudeAgent", "2026-10-03T12:00:00Z"))).toBe( |
| 43 | "line 1\n行 2 🚀\né warning", |
| 44 | ); |
| 45 | }); |
| 46 | |
| 47 | it.each([ |
| 48 | ["codex", "2026-10-03T12:00:00Z"], |
| 49 | ["claudeAgent", "2026-11-01T12:00:00Z"], |
| 50 | ])("keeps literal JSON a %s command printed at %s", (driver, startedAt) => { |
| 51 | expect(commandItemOutput(commandItem(driver, startedAt))).toBe(envelope); |
| 52 | }); |
| 53 | }); |