(args: string[] = process.argv.slice(2), env: NodeJS.ProcessEnv = process.env)
| 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 |
| 126 | const configPath = flagValue(command, "--config") ?? env.RUNTIME_NODE_CONFIG |
| 127 | const fileConfig = readConfigFile(configPath) |
| 128 | const codexAppServer = codexAppServerFromEnvOrFlags(command, env) |
| 129 | |
| 130 | return { |
| 131 | ...fileConfig, |
| 132 | host: flagValue(command, "--host") ?? env.RUNTIME_NODE_HOST ?? fileConfig.host, |
| 133 | port: numberValue(flagValue(command, "--port") ?? env.RUNTIME_NODE_PORT) ?? fileConfig.port, |
| 134 | path: flagValue(command, "--path") ?? env.RUNTIME_NODE_PATH ?? fileConfig.path, |
| 135 | token: flagValue(command, "--token") ?? env.RUNTIME_NODE_TOKEN ?? fileConfig.token, |
| 136 | checkpointFile: flagValue(command, "--checkpoint-file") ?? env.RUNTIME_NODE_CHECKPOINT_FILE ?? fileConfig.checkpointFile, |
| 137 | allowUnauthenticatedLoopback: |
| 138 | booleanValue(flagValue(command, "--allow-unauthenticated-loopback") ?? env.RUNTIME_NODE_ALLOW_UNAUTHENTICATED_LOOPBACK) ?? |
| 139 | fileConfig.allowUnauthenticatedLoopback, |
| 140 | codexAppServers: codexAppServer ? [...(fileConfig.codexAppServers ?? []), codexAppServer] : fileConfig.codexAppServers, |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | export async function startRuntimeNodeServe(config: RuntimeNodeServeConfig): Promise<RuntimeNodeHttpServer> { |
| 145 | const agentExecutor = createRuntimeNodeHarnessAgentExecutor() |
no test coverage detected