Something went wrong. Try again.
fork of prime agent with changes i want but are not upstreamable probqbly (and some fixes)
Something went wrong. Try again.
2.4 kB · 51 lines
TypeScript
at main
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152import { describe, expect, it } from "vitest";import { PUBLIC_COMMAND_NAMES } from "../src/cli/command-registry.js";import { classifyOwnedSessionWorkerInvocation, createOwnedWorkerLaunchSpec, createRpcRecoveryArgs, isOwnedSessionWorkerProcess,} from "../src/cli/owned-session-worker.js";
describe("owned session worker CLI routing", () => { it("leaves resident interactive and non-session operations in the frontend", () => { expect(classifyOwnedSessionWorkerInvocation([], true, {})).toBeUndefined(); expect(classifyOwnedSessionWorkerInvocation(["--mode", "daemon"], false, {})).toBeUndefined(); expect(classifyOwnedSessionWorkerInvocation(["--help"], false, {})).toBeUndefined(); expect(classifyOwnedSessionWorkerInvocation(["--version"], false, {})).toBeUndefined(); expect(classifyOwnedSessionWorkerInvocation(["--list-models"], false, {})).toBeUndefined(); expect(classifyOwnedSessionWorkerInvocation(["--export", "session.jsonl"], false, {})).toBeUndefined(); expect(classifyOwnedSessionWorkerInvocation(["help"], false, {})).toBeUndefined(); expect(classifyOwnedSessionWorkerInvocation(["help", "me", "fix", "this"], false, {})).toBe("print"); expect(classifyOwnedSessionWorkerInvocation(["daemon", "list"], false, {})).toBeUndefined(); for (const command of PUBLIC_COMMAND_NAMES) { expect(classifyOwnedSessionWorkerInvocation([command], false, {})).toBeUndefined(); } });
it("does not recursively route an owned worker", () => { expect(isOwnedSessionWorkerProcess({ PRIME_AGENT_INTERNAL_OWNED_WORKER: "1" })).toBe(true); expect(isOwnedSessionWorkerProcess({})).toBe(false); expect( classifyOwnedSessionWorkerInvocation(["--mode", "rpc"], true, { PRIME_AGENT_INTERNAL_OWNED_WORKER: "1", }), ).toBeUndefined(); });
it("preserves the current runtime flags and CLI entrypoint", () => { expect(createOwnedWorkerLaunchSpec(["--mode", "rpc"], "/node", ["--loader", "tsx"], "/cli.ts")).toEqual({ command: "/node", args: ["--loader", "tsx", "/cli.ts", "--mode", "rpc"], }); });
it("restarts RPC against the exact persisted session without changing public flags", () => { expect( createRpcRecoveryArgs( ["--mode", "rpc", "--continue", "--resume", "/old.jsonl", "--model", "openai/gpt-5"], "/current.jsonl", ), ).toEqual(["--mode", "rpc", "--model", "openai/gpt-5", "--resume", "/current.jsonl"]); });});