From d0861670bdfafabca8957efb07c1ed049e826013 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 12 Jan 2026 05:48:53 +0000 Subject: [PATCH] feat: simplify minimax auth choice --- src/cli/program.ts | 2 +- src/commands/auth-choice-options.test.ts | 12 ++++++++++++ src/commands/auth-choice-options.ts | 10 +++------- src/commands/auth-choice.test.ts | 5 ++--- src/commands/auth-choice.ts | 10 ++++++---- src/commands/onboard-non-interactive.ts | 25 ++++++++++++++++++++++-- 6 files changed, 47 insertions(+), 17 deletions(-) diff --git a/src/cli/program.ts b/src/cli/program.ts index 0f8da8c73..63038b4a6 100644 --- a/src/cli/program.ts +++ b/src/cli/program.ts @@ -262,7 +262,7 @@ export function buildProgram() { .option("--mode ", "Wizard mode: local|remote") .option( "--auth-choice ", - "Auth: setup-token|claude-cli|token|openai-codex|openai-api-key|openrouter-api-key|codex-cli|antigravity|gemini-api-key|zai-api-key|apiKey|minimax-cloud|minimax-api|minimax|opencode-zen|skip", + "Auth: setup-token|claude-cli|token|openai-codex|openai-api-key|openrouter-api-key|codex-cli|antigravity|gemini-api-key|zai-api-key|apiKey|minimax-api|opencode-zen|skip", ) .option( "--token-provider ", diff --git a/src/commands/auth-choice-options.test.ts b/src/commands/auth-choice-options.test.ts index 41f04428e..e5da827a0 100644 --- a/src/commands/auth-choice-options.test.ts +++ b/src/commands/auth-choice-options.test.ts @@ -68,4 +68,16 @@ describe("buildAuthChoiceOptions", () => { expect(options.some((opt) => opt.value === "zai-api-key")).toBe(true); }); + + it("includes MiniMax auth choice", () => { + const store: AuthProfileStore = { version: 1, profiles: {} }; + const options = buildAuthChoiceOptions({ + store, + includeSkip: false, + includeClaudeCliIfMissing: true, + platform: "darwin", + }); + + expect(options.some((opt) => opt.value === "minimax-api")).toBe(true); + }); }); diff --git a/src/commands/auth-choice-options.ts b/src/commands/auth-choice-options.ts index dffc8e69a..fc6c48acb 100644 --- a/src/commands/auth-choice-options.ts +++ b/src/commands/auth-choice-options.ts @@ -73,8 +73,8 @@ const AUTH_CHOICE_GROUP_DEFS: { { value: "minimax", label: "MiniMax", - hint: "Hosted + LM Studio + API", - choices: ["minimax-cloud", "minimax", "minimax-api"], + hint: "M2.1 (recommended)", + choices: ["minimax-api"], }, ]; @@ -172,11 +172,7 @@ export function buildAuthChoiceOptions(params: { label: "OpenCode Zen (multi-model proxy)", hint: "Claude, GPT, Gemini via opencode.ai/zen", }); - options.push({ - value: "minimax-cloud", - label: "MiniMax M2.1 (minimax.io) — Anthropic-compatible", - }); - options.push({ value: "minimax", label: "Minimax M2.1 (LM Studio)" }); + options.push({ value: "minimax-api", label: "MiniMax M2.1" }); if (params.includeSkip) { options.push({ value: "skip", label: "Skip for now" }); } diff --git a/src/commands/auth-choice.test.ts b/src/commands/auth-choice.test.ts index d85d5d2ad..a9888a635 100644 --- a/src/commands/auth-choice.test.ts +++ b/src/commands/auth-choice.test.ts @@ -111,7 +111,7 @@ describe("applyAuthChoice", () => { expect(parsed.profiles?.["minimax:default"]?.key).toBe("sk-minimax-test"); }); - it("configures MiniMax (minimax-cloud) via the Anthropic-compatible endpoint", async () => { + it("configures MiniMax M2.1 via the Anthropic-compatible endpoint", async () => { tempStateDir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-auth-")); process.env.CLAWDBOT_STATE_DIR = tempStateDir; process.env.CLAWDBOT_AGENT_DIR = path.join(tempStateDir, "agent"); @@ -141,7 +141,7 @@ describe("applyAuthChoice", () => { }; const result = await applyAuthChoice({ - authChoice: "minimax-cloud", + authChoice: "minimax-api", config: {}, prompter, runtime, @@ -172,7 +172,6 @@ describe("applyAuthChoice", () => { }; expect(parsed.profiles?.["minimax:default"]?.key).toBe("sk-minimax-test"); }); - it("does not override the default model when selecting opencode-zen without setDefaultModel", async () => { tempStateDir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-auth-")); process.env.CLAWDBOT_STATE_DIR = tempStateDir; diff --git a/src/commands/auth-choice.ts b/src/commands/auth-choice.ts index 7a1f57535..5f33095ab 100644 --- a/src/commands/auth-choice.ts +++ b/src/commands/auth-choice.ts @@ -728,6 +728,7 @@ export async function applyAuthChoice(params: { params.authChoice === "minimax-cloud" || params.authChoice === "minimax-api" ) { + const modelId = "MiniMax-M2.1"; const key = await params.prompter.text({ message: "Enter MiniMax API key", validate: (value) => (value?.trim() ? undefined : "Required"), @@ -739,11 +740,12 @@ export async function applyAuthChoice(params: { mode: "api_key", }); if (params.setDefaultModel) { - nextConfig = applyMinimaxApiConfig(nextConfig); + nextConfig = applyMinimaxApiConfig(nextConfig, modelId); } else { - nextConfig = applyMinimaxApiProviderConfig(nextConfig); - agentModelOverride = "minimax/MiniMax-M2.1"; - await noteAgentModel("minimax/MiniMax-M2.1"); + const modelRef = `minimax/${modelId}`; + nextConfig = applyMinimaxApiProviderConfig(nextConfig, modelId); + agentModelOverride = modelRef; + await noteAgentModel(modelRef); } } else if (params.authChoice === "minimax") { if (params.setDefaultModel) { diff --git a/src/commands/onboard-non-interactive.ts b/src/commands/onboard-non-interactive.ts index a11c0dc47..ff6ed6a92 100644 --- a/src/commands/onboard-non-interactive.ts +++ b/src/commands/onboard-non-interactive.ts @@ -284,7 +284,10 @@ export async function runNonInteractiveOnboarding( mode: "api_key", }); nextConfig = applyOpenrouterConfig(nextConfig); - } else if (authChoice === "minimax-cloud" || authChoice === "minimax-api") { + } else if ( + authChoice === "minimax-cloud" || + authChoice === "minimax-api" + ) { const resolved = await resolveNonInteractiveApiKey({ provider: "minimax", cfg: baseConfig, @@ -302,7 +305,25 @@ export async function runNonInteractiveOnboarding( provider: "minimax", mode: "api_key", }); - nextConfig = applyMinimaxApiConfig(nextConfig); + const modelId = "MiniMax-M2.1"; + const resolved = await resolveNonInteractiveApiKey({ + provider: "minimax", + cfg: baseConfig, + flagValue: opts.minimaxApiKey, + flagName: "--minimax-api-key", + envVar: "MINIMAX_API_KEY", + runtime, + }); + if (!resolved) return; + if (resolved.source !== "profile") { + await setMinimaxApiKey(resolved.key); + } + nextConfig = applyAuthProfileConfig(nextConfig, { + profileId: "minimax:default", + provider: "minimax", + mode: "api_key", + }); + nextConfig = applyMinimaxApiConfig(nextConfig, modelId); } else if (authChoice === "claude-cli") { const store = ensureAuthProfileStore(undefined, { allowKeychainPrompt: false,