Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import { tokenizeCliArgs } from "@t3tools/shared/cliArgs";
|
|
|
|
const T3CODE_CODEX_LAUNCH_ARGS_ENV = "T3CODE_CODEX_LAUNCH_ARGS";
|
|
|
|
export const resolveCodexLaunchArgs = (
|
|
launchArgs?: string,
|
|
environment: NodeJS.ProcessEnv = process.env,
|
|
) => environment[T3CODE_CODEX_LAUNCH_ARGS_ENV]?.trim() || launchArgs?.trim() || "";
|
|
|
|
const codexLaunchArgv = (launchArgs?: string): ReadonlyArray<string> => tokenizeCliArgs(launchArgs);
|
|
|
|
export const codexAppServerArgs = (launchArgs?: string) => [
|
|
"app-server",
|
|
...codexLaunchArgv(launchArgs),
|
|
];
|
|
|
|
export const codexExecLaunchArgs = (launchArgs?: string) => {
|
|
const args = codexLaunchArgv(launchArgs);
|
|
const execArgs: Array<string> = [];
|
|
|
|
for (let index = 0; index < args.length; index++) {
|
|
const arg = args[index];
|
|
if (arg === undefined) continue;
|
|
|
|
if (arg === "--strict-config" || arg.startsWith("--config=") || arg.startsWith("-c=")) {
|
|
execArgs.push(arg);
|
|
} else if (arg === "--config" || arg === "-c" || arg === "--enable" || arg === "--disable") {
|
|
const value = args[index + 1];
|
|
if (value !== undefined && !value.startsWith("-")) {
|
|
execArgs.push(arg, value);
|
|
index++;
|
|
}
|
|
} else if (arg.startsWith("--enable=") || arg.startsWith("--disable=")) {
|
|
execArgs.push(arg);
|
|
}
|
|
}
|
|
|
|
return execArgs;
|
|
};
|