openclaw/src/commands/onboard.ts

37 lines
1.2 KiB
TypeScript
Raw Normal View History

2026-01-01 17:57:57 +01:00
import { assertSupportedRuntime } from "../infra/runtime-guard.js";
import type { RuntimeEnv } from "../runtime.js";
import { defaultRuntime } from "../runtime.js";
2026-01-01 18:23:16 +01:00
import { runInteractiveOnboarding } from "./onboard-interactive.js";
import { runNonInteractiveOnboarding } from "./onboard-non-interactive.js";
import type { OnboardOptions } from "./onboard-types.js";
2026-01-01 17:57:57 +01:00
export async function onboardCommand(
opts: OnboardOptions,
runtime: RuntimeEnv = defaultRuntime,
) {
assertSupportedRuntime(runtime);
2026-01-09 17:50:34 +01:00
const authChoice =
opts.authChoice === "oauth" ? ("setup-token" as const) : opts.authChoice;
const normalizedOpts =
authChoice === opts.authChoice ? opts : { ...opts, authChoice };
if (process.platform === "win32") {
runtime.log(
[
"Windows detected.",
"WSL2 is strongly recommended; native Windows is untested and more problematic.",
"Guide: https://docs.clawd.bot/windows",
].join("\n"),
);
}
2026-01-01 17:57:57 +01:00
2026-01-09 17:50:34 +01:00
if (normalizedOpts.nonInteractive) {
await runNonInteractiveOnboarding(normalizedOpts, runtime);
2026-01-01 17:57:57 +01:00
return;
}
2026-01-09 17:50:34 +01:00
await runInteractiveOnboarding(normalizedOpts, runtime);
2026-01-01 17:57:57 +01:00
}
2026-01-01 18:23:16 +01:00
export type { OnboardOptions } from "./onboard-types.js";