feat: simplify minimax auth choice
This commit is contained in:
@@ -262,7 +262,7 @@ export function buildProgram() {
|
|||||||
.option("--mode <mode>", "Wizard mode: local|remote")
|
.option("--mode <mode>", "Wizard mode: local|remote")
|
||||||
.option(
|
.option(
|
||||||
"--auth-choice <choice>",
|
"--auth-choice <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(
|
.option(
|
||||||
"--token-provider <id>",
|
"--token-provider <id>",
|
||||||
|
|||||||
@@ -68,4 +68,16 @@ describe("buildAuthChoiceOptions", () => {
|
|||||||
|
|
||||||
expect(options.some((opt) => opt.value === "zai-api-key")).toBe(true);
|
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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -73,8 +73,8 @@ const AUTH_CHOICE_GROUP_DEFS: {
|
|||||||
{
|
{
|
||||||
value: "minimax",
|
value: "minimax",
|
||||||
label: "MiniMax",
|
label: "MiniMax",
|
||||||
hint: "Hosted + LM Studio + API",
|
hint: "M2.1 (recommended)",
|
||||||
choices: ["minimax-cloud", "minimax", "minimax-api"],
|
choices: ["minimax-api"],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -172,11 +172,7 @@ export function buildAuthChoiceOptions(params: {
|
|||||||
label: "OpenCode Zen (multi-model proxy)",
|
label: "OpenCode Zen (multi-model proxy)",
|
||||||
hint: "Claude, GPT, Gemini via opencode.ai/zen",
|
hint: "Claude, GPT, Gemini via opencode.ai/zen",
|
||||||
});
|
});
|
||||||
options.push({
|
options.push({ value: "minimax-api", label: "MiniMax M2.1" });
|
||||||
value: "minimax-cloud",
|
|
||||||
label: "MiniMax M2.1 (minimax.io) — Anthropic-compatible",
|
|
||||||
});
|
|
||||||
options.push({ value: "minimax", label: "Minimax M2.1 (LM Studio)" });
|
|
||||||
if (params.includeSkip) {
|
if (params.includeSkip) {
|
||||||
options.push({ value: "skip", label: "Skip for now" });
|
options.push({ value: "skip", label: "Skip for now" });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ describe("applyAuthChoice", () => {
|
|||||||
expect(parsed.profiles?.["minimax:default"]?.key).toBe("sk-minimax-test");
|
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-"));
|
tempStateDir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-auth-"));
|
||||||
process.env.CLAWDBOT_STATE_DIR = tempStateDir;
|
process.env.CLAWDBOT_STATE_DIR = tempStateDir;
|
||||||
process.env.CLAWDBOT_AGENT_DIR = path.join(tempStateDir, "agent");
|
process.env.CLAWDBOT_AGENT_DIR = path.join(tempStateDir, "agent");
|
||||||
@@ -141,7 +141,7 @@ describe("applyAuthChoice", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const result = await applyAuthChoice({
|
const result = await applyAuthChoice({
|
||||||
authChoice: "minimax-cloud",
|
authChoice: "minimax-api",
|
||||||
config: {},
|
config: {},
|
||||||
prompter,
|
prompter,
|
||||||
runtime,
|
runtime,
|
||||||
@@ -172,7 +172,6 @@ describe("applyAuthChoice", () => {
|
|||||||
};
|
};
|
||||||
expect(parsed.profiles?.["minimax:default"]?.key).toBe("sk-minimax-test");
|
expect(parsed.profiles?.["minimax:default"]?.key).toBe("sk-minimax-test");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not override the default model when selecting opencode-zen without setDefaultModel", async () => {
|
it("does not override the default model when selecting opencode-zen without setDefaultModel", async () => {
|
||||||
tempStateDir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-auth-"));
|
tempStateDir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-auth-"));
|
||||||
process.env.CLAWDBOT_STATE_DIR = tempStateDir;
|
process.env.CLAWDBOT_STATE_DIR = tempStateDir;
|
||||||
|
|||||||
@@ -728,6 +728,7 @@ export async function applyAuthChoice(params: {
|
|||||||
params.authChoice === "minimax-cloud" ||
|
params.authChoice === "minimax-cloud" ||
|
||||||
params.authChoice === "minimax-api"
|
params.authChoice === "minimax-api"
|
||||||
) {
|
) {
|
||||||
|
const modelId = "MiniMax-M2.1";
|
||||||
const key = await params.prompter.text({
|
const key = await params.prompter.text({
|
||||||
message: "Enter MiniMax API key",
|
message: "Enter MiniMax API key",
|
||||||
validate: (value) => (value?.trim() ? undefined : "Required"),
|
validate: (value) => (value?.trim() ? undefined : "Required"),
|
||||||
@@ -739,11 +740,12 @@ export async function applyAuthChoice(params: {
|
|||||||
mode: "api_key",
|
mode: "api_key",
|
||||||
});
|
});
|
||||||
if (params.setDefaultModel) {
|
if (params.setDefaultModel) {
|
||||||
nextConfig = applyMinimaxApiConfig(nextConfig);
|
nextConfig = applyMinimaxApiConfig(nextConfig, modelId);
|
||||||
} else {
|
} else {
|
||||||
nextConfig = applyMinimaxApiProviderConfig(nextConfig);
|
const modelRef = `minimax/${modelId}`;
|
||||||
agentModelOverride = "minimax/MiniMax-M2.1";
|
nextConfig = applyMinimaxApiProviderConfig(nextConfig, modelId);
|
||||||
await noteAgentModel("minimax/MiniMax-M2.1");
|
agentModelOverride = modelRef;
|
||||||
|
await noteAgentModel(modelRef);
|
||||||
}
|
}
|
||||||
} else if (params.authChoice === "minimax") {
|
} else if (params.authChoice === "minimax") {
|
||||||
if (params.setDefaultModel) {
|
if (params.setDefaultModel) {
|
||||||
|
|||||||
@@ -284,7 +284,10 @@ export async function runNonInteractiveOnboarding(
|
|||||||
mode: "api_key",
|
mode: "api_key",
|
||||||
});
|
});
|
||||||
nextConfig = applyOpenrouterConfig(nextConfig);
|
nextConfig = applyOpenrouterConfig(nextConfig);
|
||||||
} else if (authChoice === "minimax-cloud" || authChoice === "minimax-api") {
|
} else if (
|
||||||
|
authChoice === "minimax-cloud" ||
|
||||||
|
authChoice === "minimax-api"
|
||||||
|
) {
|
||||||
const resolved = await resolveNonInteractiveApiKey({
|
const resolved = await resolveNonInteractiveApiKey({
|
||||||
provider: "minimax",
|
provider: "minimax",
|
||||||
cfg: baseConfig,
|
cfg: baseConfig,
|
||||||
@@ -302,7 +305,25 @@ export async function runNonInteractiveOnboarding(
|
|||||||
provider: "minimax",
|
provider: "minimax",
|
||||||
mode: "api_key",
|
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") {
|
} else if (authChoice === "claude-cli") {
|
||||||
const store = ensureAuthProfileStore(undefined, {
|
const store = ensureAuthProfileStore(undefined, {
|
||||||
allowKeychainPrompt: false,
|
allowKeychainPrompt: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user