mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-16 23:52:40 -06:00
250e636ffd
* fix(onboard): validate setup options before mutation * fix(onboard): keep flow helper type local
113 lines
4.1 KiB
TypeScript
113 lines
4.1 KiB
TypeScript
/**
|
|
* Shared onboarding option and choice types.
|
|
*
|
|
* These types model CLI flags plus plugin-defined dynamic auth options used by
|
|
* interactive and non-interactive setup.
|
|
*/
|
|
import type { ChannelId } from "../channels/plugins/types.public.js";
|
|
import type { SecretInputMode } from "../plugins/provider-auth-types.js";
|
|
import type { GatewayDaemonRuntime } from "./daemon-runtime.js";
|
|
|
|
export type OnboardMode = "local" | "remote";
|
|
|
|
/**
|
|
* Auth choices are plugin-owned contract ids plus a few legacy aliases that
|
|
* are normalized elsewhere (for example `oauth` -> `setup-token`).
|
|
*/
|
|
type BuiltInAuthChoice =
|
|
/** @deprecated Use `setup-token`. */
|
|
"oauth" | "setup-token" | "token" | "apiKey" | "custom-api-key" | "skip";
|
|
export type AuthChoice = BuiltInAuthChoice | (string & {});
|
|
|
|
/** Auth choice groups are plugin-owned ids plus the core `custom` bucket. */
|
|
export type AuthChoiceGroupId = "custom" | (string & {});
|
|
export type GatewayAuthChoice = "token" | "password";
|
|
export type ResetScope = "config" | "config+creds+sessions" | "full";
|
|
export type GatewayBind = "loopback" | "lan" | "auto" | "custom" | "tailnet";
|
|
export type TailscaleMode = "off" | "serve" | "funnel";
|
|
const NODE_MANAGER_CHOICES = ["npm", "pnpm", "bun"] as const;
|
|
export type NodeManagerChoice = (typeof NODE_MANAGER_CHOICES)[number];
|
|
const ONBOARD_FLOWS = ["quickstart", "advanced", "manual", "import"] as const;
|
|
type OnboardFlow = (typeof ONBOARD_FLOWS)[number];
|
|
export type ChannelChoice = ChannelId;
|
|
export type { SecretInputMode } from "../plugins/provider-auth-types.js";
|
|
|
|
export function isNodeManagerChoice(value: unknown): value is NodeManagerChoice {
|
|
return NODE_MANAGER_CHOICES.some((choice) => choice === value);
|
|
}
|
|
|
|
export function isOnboardFlow(value: unknown): value is OnboardFlow {
|
|
return ONBOARD_FLOWS.some((flow) => flow === value);
|
|
}
|
|
|
|
type OnboardDynamicProviderOptions = {
|
|
/**
|
|
* Provider-specific non-interactive auth flags are plugin-owned and keyed by
|
|
* manifest `providerAuthChoices[].optionKey` values.
|
|
*/
|
|
[optionKey: string]: unknown;
|
|
};
|
|
|
|
/** Parsed options accepted by `openclaw onboard`. */
|
|
export type OnboardOptions = OnboardDynamicProviderOptions & {
|
|
mode?: OnboardMode;
|
|
/** "manual" is an alias for "advanced". */
|
|
flow?: OnboardFlow;
|
|
/** Force the classic multi-step interactive wizard instead of guided setup. */
|
|
classic?: boolean;
|
|
/** Force the terminal hatch instead of the guided browser handoff. */
|
|
tui?: boolean;
|
|
workspace?: string;
|
|
nonInteractive?: boolean;
|
|
/** Required for non-interactive setup; skips the interactive risk prompt when true. */
|
|
acceptRisk?: boolean;
|
|
reset?: boolean;
|
|
resetScope?: ResetScope;
|
|
authChoice?: AuthChoice;
|
|
/** Used when `authChoice=token` in non-interactive mode. */
|
|
tokenProvider?: string;
|
|
/** Used when `authChoice=token` in non-interactive mode. */
|
|
token?: string;
|
|
/** Used when `authChoice=token` in non-interactive mode. */
|
|
tokenProfileId?: string;
|
|
/** Used when `authChoice=token` in non-interactive mode. */
|
|
tokenExpiresIn?: string;
|
|
/** API key persistence mode for setup flows (default: plaintext). */
|
|
secretInputMode?: SecretInputMode;
|
|
arceeaiApiKey?: string;
|
|
cloudflareAiGatewayAccountId?: string;
|
|
cloudflareAiGatewayGatewayId?: string;
|
|
customBaseUrl?: string;
|
|
customApiKey?: string;
|
|
lmstudioApiKey?: string;
|
|
customModelId?: string;
|
|
customProviderId?: string;
|
|
customCompatibility?: "openai" | "openai-responses" | "anthropic";
|
|
customImageInput?: boolean;
|
|
gatewayPort?: number;
|
|
gatewayBind?: GatewayBind;
|
|
gatewayAuth?: GatewayAuthChoice;
|
|
gatewayToken?: string;
|
|
gatewayTokenRefEnv?: string;
|
|
gatewayPassword?: string;
|
|
tailscale?: TailscaleMode;
|
|
tailscaleResetOnExit?: boolean;
|
|
installDaemon?: boolean;
|
|
daemonRuntime?: GatewayDaemonRuntime;
|
|
skipChannels?: boolean;
|
|
skipSkills?: boolean;
|
|
skipBootstrap?: boolean;
|
|
skipSearch?: boolean;
|
|
skipHealth?: boolean;
|
|
skipUi?: boolean;
|
|
suppressGatewayTokenOutput?: boolean;
|
|
skipHooks?: boolean;
|
|
nodeManager?: NodeManagerChoice;
|
|
remoteUrl?: string;
|
|
remoteToken?: string;
|
|
importFrom?: string;
|
|
importSource?: string;
|
|
importSecrets?: boolean;
|
|
json?: boolean;
|
|
};
|