openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
89 lines (88 loc) • 2.65 kB
JavaScript
import { o as writeRuntimeJson } from "./runtime-B-SLYP-m.mjs";
import { r as formatCliJsonFailure } from "./failure-output-DVVDqwuu.mjs";
import { n as formatInvalidPortOption } from "./error-format-O7EzXfiI.mjs";
import { r as isGatewayDaemonRuntime } from "./daemon-runtime-agdJw6fb.mjs";
//#region src/commands/onboard-types.ts
const NODE_MANAGER_CHOICES = [
"npm",
"pnpm",
"bun"
];
const ONBOARD_FLOWS = [
"quickstart",
"advanced",
"manual",
"import"
];
function isNodeManagerChoice(e) {
return NODE_MANAGER_CHOICES.some((t) => t === e);
}
function isOnboardFlow(e) {
return ONBOARD_FLOWS.some((t) => t === e);
}
//#endregion
//#region src/commands/onboard-options.ts
/**
* Shared choice validation and rejection for `openclaw onboard` options.
*
* Lives above the local/remote split because both the outer command and the
* non-interactive handlers reject options, and every one of them must honor --json.
*/
/** Reports an invalid option and exits; returns false so validators can `return` it directly. */
function rejectOnboardingOption(e, t, n) {
if (e.json) writeRuntimeJson(t, {
...formatCliJsonFailure(n),
phase: "options",
message: n
});
t.error(n);
t.exit(1);
return false;
}
function validateOnboardingChoiceOptions(e, t) {
const reject = (n) => rejectOnboardingOption(e, t, n);
const n = [
[
"--gateway-bind",
e.gatewayBind,
[
"loopback",
"tailnet",
"lan",
"auto",
"custom"
]
],
[
"--gateway-auth",
e.gatewayAuth,
["token", "password"]
],
[
"--tailscale",
e.tailscale,
[
"off",
"serve",
"funnel"
]
],
[
"--custom-compatibility",
e.customCompatibility,
[
"openai",
"openai-responses",
"anthropic"
]
]
];
for (const [e, t, r] of n) if (t !== void 0 && !r.includes(t)) return reject(`Invalid ${e} ${JSON.stringify(t)}. Use ${r.map((e) => JSON.stringify(e)).join(", ")}.`);
if (e.flow !== void 0 && !isOnboardFlow(e.flow)) return reject("Invalid --flow. Use \"quickstart\", \"advanced\", \"manual\", or \"import\".");
if (e.daemonRuntime !== void 0 && !isGatewayDaemonRuntime(e.daemonRuntime)) return reject("Invalid --daemon-runtime. Use \"node\", \"bun\", or \"standalone\".");
if (e.nodeManager !== void 0 && !isNodeManagerChoice(e.nodeManager)) return reject("Invalid --node-manager. Use \"npm\", \"pnpm\", or \"bun\".");
if (e.gatewayPort !== void 0 && (!Number.isFinite(e.gatewayPort) || e.gatewayPort <= 0 || e.gatewayPort > 65535)) return reject(formatInvalidPortOption("--gateway-port"));
return true;
}
//#endregion
export { validateOnboardingChoiceOptions as n, rejectOnboardingOption as t };