openclaw/src/commands/auth-choice.apply.ts

66 lines
2.3 KiB
TypeScript
Raw Normal View History

2026-01-30 03:15:10 +01:00
import type { OpenClawConfig } from "../config/config.js";
2026-01-14 05:39:47 +00:00
import type { RuntimeEnv } from "../runtime.js";
import type { WizardPrompter } from "../wizard/prompts.js";
import type { AuthChoice } from "./onboard-types.js";
2026-01-14 05:39:47 +00:00
import { applyAuthChoiceAnthropic } from "./auth-choice.apply.anthropic.js";
import { applyAuthChoiceApiProviders } from "./auth-choice.apply.api-providers.js";
import { applyAuthChoiceCopilotProxy } from "./auth-choice.apply.copilot-proxy.js";
2026-01-14 05:39:47 +00:00
import { applyAuthChoiceGitHubCopilot } from "./auth-choice.apply.github-copilot.js";
import { applyAuthChoiceGoogleAntigravity } from "./auth-choice.apply.google-antigravity.js";
import { applyAuthChoiceGoogleGeminiCli } from "./auth-choice.apply.google-gemini-cli.js";
2026-01-14 05:39:47 +00:00
import { applyAuthChoiceMiniMax } from "./auth-choice.apply.minimax.js";
import { applyAuthChoiceOAuth } from "./auth-choice.apply.oauth.js";
import { applyAuthChoiceOpenAI } from "./auth-choice.apply.openai.js";
2026-01-17 20:20:20 +00:00
import { applyAuthChoiceQwenPortal } from "./auth-choice.apply.qwen-portal.js";
2026-02-05 12:25:34 -08:00
import { applyAuthChoiceXAI } from "./auth-choice.apply.xai.js";
2026-01-14 05:39:47 +00:00
export type ApplyAuthChoiceParams = {
authChoice: AuthChoice;
2026-01-30 03:15:10 +01:00
config: OpenClawConfig;
2026-01-14 05:39:47 +00:00
prompter: WizardPrompter;
runtime: RuntimeEnv;
agentDir?: string;
setDefaultModel: boolean;
agentId?: string;
opts?: {
tokenProvider?: string;
token?: string;
cloudflareAiGatewayAccountId?: string;
cloudflareAiGatewayGatewayId?: string;
cloudflareAiGatewayApiKey?: string;
2026-02-05 12:25:34 -08:00
xaiApiKey?: string;
};
2026-01-14 05:39:47 +00:00
};
export type ApplyAuthChoiceResult = {
2026-01-30 03:15:10 +01:00
config: OpenClawConfig;
2026-01-14 05:39:47 +00:00
agentModelOverride?: string;
};
export async function applyAuthChoice(
params: ApplyAuthChoiceParams,
): Promise<ApplyAuthChoiceResult> {
const handlers: Array<(p: ApplyAuthChoiceParams) => Promise<ApplyAuthChoiceResult | null>> = [
2026-01-14 05:39:47 +00:00
applyAuthChoiceAnthropic,
applyAuthChoiceOpenAI,
applyAuthChoiceOAuth,
applyAuthChoiceApiProviders,
applyAuthChoiceMiniMax,
applyAuthChoiceGitHubCopilot,
applyAuthChoiceGoogleAntigravity,
applyAuthChoiceGoogleGeminiCli,
applyAuthChoiceCopilotProxy,
2026-01-17 20:20:20 +00:00
applyAuthChoiceQwenPortal,
2026-02-05 12:25:34 -08:00
applyAuthChoiceXAI,
2026-01-14 05:39:47 +00:00
];
for (const handler of handlers) {
const result = await handler(params);
if (result) {
return result;
}
2026-01-14 05:39:47 +00:00
}
return { config: params.config };
}