mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 07:00:43 +00:00
* fix(tui): prevent orphaned terminal sessions * fix(doctor): repair heartbeat-poisoned main sessions * fix(tui): preserve startup tls respawn * fix: harden tui and doctor recovery paths
59 lines
1.6 KiB
TypeScript
59 lines
1.6 KiB
TypeScript
import { resolveCliArgvInvocation } from "./argv-invocation.js";
|
|
import { getCommandPositionalsWithRootOptions } from "./argv.js";
|
|
|
|
const GATEWAY_RUN_BOOLEAN_FLAGS = [
|
|
"--allow-unconfigured",
|
|
"--claude-cli-logs",
|
|
"--cli-backend-logs",
|
|
"--compact",
|
|
"--dev",
|
|
"--force",
|
|
"--raw-stream",
|
|
"--reset",
|
|
"--tailscale-reset-on-exit",
|
|
"--verbose",
|
|
] as const;
|
|
|
|
const GATEWAY_RUN_VALUE_FLAGS = [
|
|
"--auth",
|
|
"--bind",
|
|
"--password",
|
|
"--password-file",
|
|
"--port",
|
|
"--raw-stream-path",
|
|
"--tailscale",
|
|
"--token",
|
|
"--ws-log",
|
|
] as const;
|
|
|
|
const INTERACTIVE_TTY_COMMANDS = new Set(["tui", "terminal", "chat"]);
|
|
|
|
function isForegroundGatewayRunArgv(argv: string[]): boolean {
|
|
const positionals = getCommandPositionalsWithRootOptions(argv, {
|
|
commandPath: ["gateway"],
|
|
booleanFlags: GATEWAY_RUN_BOOLEAN_FLAGS,
|
|
valueFlags: GATEWAY_RUN_VALUE_FLAGS,
|
|
});
|
|
if (!positionals) {
|
|
return false;
|
|
}
|
|
return positionals.length === 0 || (positionals.length === 1 && positionals[0] === "run");
|
|
}
|
|
|
|
export function shouldSkipRespawnForArgv(argv: string[]): boolean {
|
|
const invocation = resolveCliArgvInvocation(argv);
|
|
return (
|
|
invocation.hasHelpOrVersion ||
|
|
(invocation.primary !== null && INTERACTIVE_TTY_COMMANDS.has(invocation.primary)) ||
|
|
(invocation.primary === "gateway" && isForegroundGatewayRunArgv(argv))
|
|
);
|
|
}
|
|
|
|
export function shouldSkipStartupEnvironmentRespawnForArgv(argv: string[]): boolean {
|
|
const invocation = resolveCliArgvInvocation(argv);
|
|
return (
|
|
invocation.hasHelpOrVersion ||
|
|
(invocation.primary === "gateway" && isForegroundGatewayRunArgv(argv))
|
|
);
|
|
}
|