The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as NodeAssert from "node:assert/strict"; |
| 2 | |
| 3 | import { describe, it } from "vite-plus/test"; |
| 4 | |
| 5 | import { |
| 6 | codexAppServerArgs, |
| 7 | codexExecLaunchArgs, |
| 8 | codexMcpListLaunchArgs, |
| 9 | resolveCodexLaunchArgs, |
| 10 | } from "./codexLaunchArgs.ts"; |
| 11 | |
| 12 | describe("codexAppServerArgs", () => { |
| 13 | it.each([ |
| 14 | { |
| 15 | name: "preserves escaped TOML quotes in config values", |
| 16 | launchArgs: String.raw`--config model=\"gpt-6.1-sol\" --strict-config`, |
| 17 | expected: ["--config", 'model="gpt-6.1-sol"', "--strict-config"], |
| 18 | }, |
| 19 | { |
| 20 | name: "lets launch args override the unload delay", |
| 21 | launchArgs: "-c thread_unload_delay_secs=1800", |
| 22 | expected: ["-c", "thread_unload_delay_secs=1800"], |
| 23 | }, |
| 24 | { |
| 25 | name: "preserves an escaped trailing space in the environment override", |
| 26 | launchArgs: "--strict-config", |
| 27 | environment: { T3CODE_CODEX_LAUNCH_ARGS: "--cloud-skills-snapshot skills.json\\ " }, |
| 28 | expected: ["--cloud-skills-snapshot", "skills.json "], |
| 29 | }, |
| 30 | { |
| 31 | name: "uses configured arguments when the environment override is blank", |
| 32 | launchArgs: "--strict-config", |
| 33 | environment: { T3CODE_CODEX_LAUNCH_ARGS: " \t " }, |
| 34 | expected: ["--strict-config"], |
| 35 | }, |
| 36 | ])("asks Codex to unload unsubscribed threads immediately and $name", (row) => { |
| 37 | const launchArgs = resolveCodexLaunchArgs(row.launchArgs, row.environment ?? {}); |
| 38 | NodeAssert.deepStrictEqual(codexAppServerArgs(launchArgs), [ |
| 39 | "app-server", |
| 40 | "-c", |
| 41 | "thread_unload_delay_secs=0", |
| 42 | ...row.expected, |
| 43 | ]); |
| 44 | }); |
| 45 | }); |
| 46 | |
| 47 | describe("codexExecLaunchArgs", () => { |
| 48 | it("keeps shared codex flags and omits app-server-only flags", () => { |
| 49 | NodeAssert.deepStrictEqual( |
| 50 | codexExecLaunchArgs('--strict-config --enable foo --listen off --config model="gpt 5"'), |
| 51 | ["--strict-config", "--enable", "foo", "--config", "model=gpt 5"], |
| 52 | ); |
| 53 | }); |
| 54 | |
| 55 | it("keeps user hooks, apps, and plugins off during text generation", () => { |
| 56 | const launchArgs = |
| 57 | "--enable hooks --enable=hooks --enable codex_hooks --enable=codex_hooks --enable apps --enable=apps --enable connectors --enable=connectors --enable plugins --enable=plugins --enable foo --disable hooks"; |
| 58 | NodeAssert.deepStrictEqual(codexExecLaunchArgs(launchArgs), [ |
| 59 | "--enable", |
| 60 | "foo", |
| 61 | "--disable", |
| 62 | "hooks", |
| 63 | ]); |
| 64 | NodeAssert.deepStrictEqual(codexMcpListLaunchArgs(launchArgs), [ |
| 65 | "--enable", |
| 66 | "hooks", |
| 67 | "--enable=hooks", |
| 68 | "--enable", |
| 69 | "codex_hooks", |
| 70 | "--enable=codex_hooks", |
| 71 | "--enable", |
| 72 | "foo", |
| 73 | "--disable", |
| 74 | "hooks", |
| 75 | ]); |
| 76 | }); |
| 77 | |
| 78 | it("does not pair value-taking flags with adjacent flags", () => { |
| 79 | NodeAssert.deepStrictEqual(codexExecLaunchArgs("--config --strict-config --enable --disable"), [ |
| 80 | "--strict-config", |
| 81 | ]); |
| 82 | }); |
| 83 | }); |
| 84 | |
| 85 | describe.each(["", "="])("codex exec and mcp list launch args with -p%swork", (separator) => { |
| 86 | const launchArgs = `--strict-config --oss --local-provider ollama --profile local -p${separator}work -c${separator}model_provider=ollama --listen off --enable foo`; |
| 87 | |
| 88 | it("keeps the local model provider flags for codex exec", () => { |
| 89 | NodeAssert.deepStrictEqual(codexExecLaunchArgs(launchArgs), [ |
| 90 | "--strict-config", |
| 91 | "--oss", |
| 92 | "--local-provider", |
| 93 | "ollama", |
| 94 | "--profile", |
| 95 | "local", |
| 96 | "-p=work", |
| 97 | "-c=model_provider=ollama", |
| 98 | "--enable", |
| 99 | "foo", |
| 100 | ]); |
| 101 | }); |
| 102 | |
| 103 | it("keeps the selected profile and drops exec-only flags for codex mcp list", () => { |
| 104 | NodeAssert.deepStrictEqual(codexMcpListLaunchArgs(launchArgs), [ |
| 105 | "--profile", |
| 106 | "local", |
| 107 | "-p=work", |
| 108 | "-c=model_provider=ollama", |
| 109 | "--enable", |
| 110 | "foo", |
| 111 | ]); |
| 112 | }); |
| 113 | }); |