mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 03:28:29 +00:00
refactor(commands): split CLI commands
This commit is contained in:
47
src/commands/auth-choice.apply.ts
Normal file
47
src/commands/auth-choice.apply.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import type { ClawdbotConfig } from "../config/config.js";
|
||||
import type { RuntimeEnv } from "../runtime.js";
|
||||
import type { WizardPrompter } from "../wizard/prompts.js";
|
||||
import { applyAuthChoiceAnthropic } from "./auth-choice.apply.anthropic.js";
|
||||
import { applyAuthChoiceApiProviders } from "./auth-choice.apply.api-providers.js";
|
||||
import { applyAuthChoiceGitHubCopilot } from "./auth-choice.apply.github-copilot.js";
|
||||
import { applyAuthChoiceMiniMax } from "./auth-choice.apply.minimax.js";
|
||||
import { applyAuthChoiceOAuth } from "./auth-choice.apply.oauth.js";
|
||||
import { applyAuthChoiceOpenAI } from "./auth-choice.apply.openai.js";
|
||||
import type { AuthChoice } from "./onboard-types.js";
|
||||
|
||||
export type ApplyAuthChoiceParams = {
|
||||
authChoice: AuthChoice;
|
||||
config: ClawdbotConfig;
|
||||
prompter: WizardPrompter;
|
||||
runtime: RuntimeEnv;
|
||||
agentDir?: string;
|
||||
setDefaultModel: boolean;
|
||||
agentId?: string;
|
||||
};
|
||||
|
||||
export type ApplyAuthChoiceResult = {
|
||||
config: ClawdbotConfig;
|
||||
agentModelOverride?: string;
|
||||
};
|
||||
|
||||
export async function applyAuthChoice(
|
||||
params: ApplyAuthChoiceParams,
|
||||
): Promise<ApplyAuthChoiceResult> {
|
||||
const handlers: Array<
|
||||
(p: ApplyAuthChoiceParams) => Promise<ApplyAuthChoiceResult | null>
|
||||
> = [
|
||||
applyAuthChoiceAnthropic,
|
||||
applyAuthChoiceOpenAI,
|
||||
applyAuthChoiceOAuth,
|
||||
applyAuthChoiceApiProviders,
|
||||
applyAuthChoiceMiniMax,
|
||||
applyAuthChoiceGitHubCopilot,
|
||||
];
|
||||
|
||||
for (const handler of handlers) {
|
||||
const result = await handler(params);
|
||||
if (result) return result;
|
||||
}
|
||||
|
||||
return { config: params.config };
|
||||
}
|
||||
Reference in New Issue
Block a user