(command: string[], env: NodeJS.ProcessEnv)
| 93 | } |
| 94 | |
| 95 | function codexAppServerFromEnvOrFlags(command: string[], env: NodeJS.ProcessEnv): RuntimeNodeCodexAppServerConfig | undefined { |
| 96 | const websocketUrl = flagValue(command, "--codex-server-url") ?? env.RUNTIME_NODE_CODEX_SERVER_URL |
| 97 | if (!websocketUrl) return undefined |
| 98 | |
| 99 | const commandPath = flagValue(command, "--codex-server-command") ?? env.RUNTIME_NODE_CODEX_SERVER_COMMAND |
| 100 | const args = stringArrayValue(flagValue(command, "--codex-server-args") ?? env.RUNTIME_NODE_CODEX_SERVER_ARGS) |
| 101 | const cwd = flagValue(command, "--codex-server-cwd") ?? env.RUNTIME_NODE_CODEX_SERVER_CWD |
| 102 | |
| 103 | return { |
| 104 | providerId: flagValue(command, "--codex-server-provider-id") ?? env.RUNTIME_NODE_CODEX_SERVER_PROVIDER_ID, |
| 105 | label: flagValue(command, "--codex-server-label") ?? env.RUNTIME_NODE_CODEX_SERVER_LABEL, |
| 106 | websocketUrl, |
| 107 | authToken: flagValue(command, "--codex-server-token") ?? env.RUNTIME_NODE_CODEX_SERVER_TOKEN, |
| 108 | clientName: flagValue(command, "--codex-server-client-name") ?? env.RUNTIME_NODE_CODEX_SERVER_CLIENT_NAME, |
| 109 | clientVersion: flagValue(command, "--codex-server-client-version") ?? env.RUNTIME_NODE_CODEX_SERVER_CLIENT_VERSION, |
| 110 | experimentalApi: booleanValue(flagValue(command, "--codex-server-experimental-api") ?? env.RUNTIME_NODE_CODEX_SERVER_EXPERIMENTAL_API), |
| 111 | managedProcess: commandPath |
| 112 | ? { |
| 113 | command: commandPath, |
| 114 | args: args ?? [], |
| 115 | cwd, |
| 116 | readyProbeUrl: flagValue(command, "--codex-server-ready-url") ?? env.RUNTIME_NODE_CODEX_SERVER_READY_URL, |
| 117 | readyTimeoutMs: numberValue(flagValue(command, "--codex-server-ready-timeout-ms") ?? env.RUNTIME_NODE_CODEX_SERVER_READY_TIMEOUT_MS), |
| 118 | killOnDisconnect: booleanValue(flagValue(command, "--codex-server-kill-on-disconnect") ?? env.RUNTIME_NODE_CODEX_SERVER_KILL_ON_DISCONNECT), |
| 119 | } |
| 120 | : undefined, |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | export function parseRuntimeNodeServeConfig(args: string[] = process.argv.slice(2), env: NodeJS.ProcessEnv = process.env): RuntimeNodeServeConfig { |
| 125 | const command = args[0] === "serve" ? args.slice(1) : args |
no test coverage detected