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";
|
2026-02-01 10:03:47 +09:00
|
|
|
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";
|
2026-01-18 16:22:56 +00:00
|
|
|
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";
|
2026-01-18 16:22:56 +00:00
|
|
|
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;
|
2026-01-23 01:27:52 -06:00
|
|
|
opts?: {
|
|
|
|
|
tokenProvider?: string;
|
|
|
|
|
token?: string;
|
2026-02-04 04:10:13 -08:00
|
|
|
cloudflareAiGatewayAccountId?: string;
|
|
|
|
|
cloudflareAiGatewayGatewayId?: string;
|
|
|
|
|
cloudflareAiGatewayApiKey?: string;
|
2026-02-05 12:25:34 -08:00
|
|
|
xaiApiKey?: string;
|
2026-01-23 01:27:52 -06:00
|
|
|
};
|
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> {
|
2026-01-14 14:31:43 +00:00
|
|
|
const handlers: Array<(p: ApplyAuthChoiceParams) => Promise<ApplyAuthChoiceResult | null>> = [
|
2026-01-14 05:39:47 +00:00
|
|
|
applyAuthChoiceAnthropic,
|
|
|
|
|
applyAuthChoiceOpenAI,
|
|
|
|
|
applyAuthChoiceOAuth,
|
|
|
|
|
applyAuthChoiceApiProviders,
|
|
|
|
|
applyAuthChoiceMiniMax,
|
|
|
|
|
applyAuthChoiceGitHubCopilot,
|
2026-01-18 16:22:56 +00:00
|
|
|
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);
|
2026-01-31 16:19:20 +09:00
|
|
|
if (result) {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2026-01-14 05:39:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return { config: params.config };
|
|
|
|
|
}
|