openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
62 lines (61 loc) • 2.42 kB
JavaScript
import { a as getCommandArgsWithRootOptions, l as isValueToken, n as consumeKnownOptionToken, o as getCommandPositionalsWithRootOptions, r as consumeRootCommandOptionToken } from "./cli-root-options-xlQx6o4R.mjs";
import { n as GATEWAY_RUN_VALUE_FLAGS, t as GATEWAY_RUN_BOOLEAN_FLAGS } from "./gateway-run-argv-DfcBAs2-.mjs";
import { i as WINDOWS_TASK_SUPERVISOR_FLAG, r as WINDOWS_TASK_SUPERVISOR_CHILD_FLAG } from "./windows-task-supervisor-contract-DV_hv_so.mjs";
//#region src/cli/gateway-run-argv.ts
function consumeGatewayRunOptionToken(e, t) {
return consumeKnownOptionToken(e, t, GATEWAY_RUN_BOOLEAN_FLAGS, GATEWAY_RUN_VALUE_FLAGS);
}
function consumeGatewayFastPathRootOptionToken(e, t) {
const n = e[t];
if (!n || n === "--") return 0;
if (n === "--no-color") return 1;
if (n.startsWith("--profile=")) return n.slice(10).trim() ? 1 : 0;
if (n === "--profile") return isValueToken(e[t + 1]) ? 2 : 0;
return 0;
}
function resolveGatewayCommandPath(e, t = 2) {
const n = getCommandPositionalsWithRootOptions(e, {
commandPath: ["gateway"],
booleanFlags: [...GATEWAY_RUN_BOOLEAN_FLAGS, WINDOWS_TASK_SUPERVISOR_FLAG],
valueFlags: [...GATEWAY_RUN_VALUE_FLAGS, WINDOWS_TASK_SUPERVISOR_CHILD_FLAG],
maxPositionals: t - 1,
mode: "command-path"
});
return n ? ["gateway", ...n] : null;
}
function isGatewayRunInvocationArgv(e) {
const t = resolveGatewayCommandPath(e);
return t?.length === 1 || t?.length === 2 && t[0] === "gateway" && t[1] === "run";
}
function resolveGatewayRunPreBootstrapOptions(e) {
const t = getCommandArgsWithRootOptions(e, {
commandPath: ["gateway"],
mode: "command-path"
});
if (!t) return null;
let n = false;
let r = false;
let i = false;
for (let e = 0; e < t.length; e += 1) {
const a = t[e];
if (!a || a === "--") break;
if (!i && a === "run") {
i = true;
continue;
}
const o = consumeRootCommandOptionToken(t, e) || consumeGatewayRunOptionToken(t, e) || (a && GATEWAY_RUN_VALUE_FLAGS.has(a) && t[e + 1] !== void 0 ? 2 : 0);
if (o > 0) {
if (a === "--force") n = true;
else if (a === "--reset") r = true;
e += o - 1;
continue;
}
if (!a.startsWith("-")) return null;
}
return {
force: n,
reset: r
};
}
//#endregion
export { resolveGatewayRunPreBootstrapOptions as a, resolveGatewayCommandPath as i, consumeGatewayRunOptionToken as n, isGatewayRunInvocationArgv as r, consumeGatewayFastPathRootOptionToken as t };