Onboarding: add MiniMax hosted API key option

This commit is contained in:
Tobias Bischoff
2026-01-08 15:10:18 +01:00
committed by Peter Steinberger
parent 7b79823b24
commit a0bb2bccaf
11 changed files with 293 additions and 522 deletions

View File

@@ -93,6 +93,7 @@ export function buildAuthChoiceOptions(params: {
options.push({ value: "gemini-api-key", label: "Google Gemini API key" });
options.push({ value: "apiKey", label: "Anthropic API key" });
// Token flow is currently Anthropic-only; use CLI for advanced providers.
options.push({ value: "minimax-cloud", label: "MiniMax M2.1 (minimax.io)" });
options.push({ value: "minimax", label: "Minimax M2.1 (LM Studio)" });
if (params.includeSkip) {
options.push({ value: "skip", label: "Skip for now" });

View File

@@ -37,9 +37,13 @@ import {
import {
applyAuthProfileConfig,
applyMinimaxConfig,
applyMinimaxHostedConfig,
applyMinimaxHostedProviderConfig,
applyMinimaxProviderConfig,
MINIMAX_HOSTED_MODEL_REF,
setAnthropicApiKey,
setGeminiApiKey,
setMinimaxApiKey,
writeOAuthCredentials,
} from "./onboard-auth.js";
import { openUrl } from "./onboard-helpers.js";
@@ -529,6 +533,24 @@ export async function applyAuthChoice(params: {
provider: "anthropic",
mode: "api_key",
});
} else if (params.authChoice === "minimax-cloud") {
const key = await params.prompter.text({
message: "Enter MiniMax API key",
validate: (value) => (value?.trim() ? undefined : "Required"),
});
await setMinimaxApiKey(String(key).trim(), params.agentDir);
nextConfig = applyAuthProfileConfig(nextConfig, {
profileId: "minimax:default",
provider: "minimax",
mode: "api_key",
});
if (params.setDefaultModel) {
nextConfig = applyMinimaxHostedConfig(nextConfig);
} else {
nextConfig = applyMinimaxHostedProviderConfig(nextConfig);
agentModelOverride = MINIMAX_HOSTED_MODEL_REF;
await noteAgentModel(MINIMAX_HOSTED_MODEL_REF);
}
} else if (params.authChoice === "minimax") {
if (params.setDefaultModel) {
nextConfig = applyMinimaxConfig(nextConfig);

View File

@@ -69,8 +69,10 @@ import { healthCommand } from "./health.js";
import {
applyAuthProfileConfig,
applyMinimaxConfig,
applyMinimaxHostedConfig,
setAnthropicApiKey,
setGeminiApiKey,
setMinimaxApiKey,
writeOAuthCredentials,
} from "./onboard-auth.js";
import {
@@ -357,6 +359,7 @@ async function promptAuthConfig(
| "antigravity"
| "gemini-api-key"
| "apiKey"
| "minimax-cloud"
| "minimax"
| "skip";
@@ -691,6 +694,21 @@ async function promptAuthConfig(
provider: "anthropic",
mode: "api_key",
});
} else if (authChoice === "minimax-cloud") {
const key = guardCancel(
await text({
message: "Enter MiniMax API key",
validate: (value) => (value?.trim() ? undefined : "Required"),
}),
runtime,
);
await setMinimaxApiKey(String(key).trim());
next = applyAuthProfileConfig(next, {
profileId: "minimax:default",
provider: "minimax",
mode: "api_key",
});
next = applyMinimaxHostedConfig(next);
} else if (authChoice === "minimax") {
next = applyMinimaxConfig(next);
}

View File

@@ -3,6 +3,12 @@ import { resolveDefaultAgentDir } from "../agents/agent-scope.js";
import { upsertAuthProfile } from "../agents/auth-profiles.js";
import type { ClawdbotConfig } from "../config/config.js";
const DEFAULT_MINIMAX_BASE_URL = "https://api.minimax.io/v1";
export const MINIMAX_HOSTED_MODEL_ID = "MiniMax-M2.1";
const DEFAULT_MINIMAX_CONTEXT_WINDOW = 200000;
const DEFAULT_MINIMAX_MAX_TOKENS = 8192;
export const MINIMAX_HOSTED_MODEL_REF = `minimax/${MINIMAX_HOSTED_MODEL_ID}`;
export async function writeOAuthCredentials(
provider: OAuthProvider,
creds: OAuthCredentials,
@@ -46,6 +52,19 @@ export async function setGeminiApiKey(key: string, agentDir?: string) {
});
}
export async function setMinimaxApiKey(key: string, agentDir?: string) {
// Write to the multi-agent path so gateway finds credentials on startup
upsertAuthProfile({
profileId: "minimax:default",
credential: {
type: "api_key",
provider: "minimax",
key,
},
agentDir: agentDir ?? resolveDefaultAgentDir(),
});
}
export function applyAuthProfileConfig(
cfg: ClawdbotConfig,
params: {
@@ -143,6 +162,57 @@ export function applyMinimaxProviderConfig(
};
}
export function applyMinimaxHostedProviderConfig(
cfg: ClawdbotConfig,
params?: { baseUrl?: string },
): ClawdbotConfig {
const models = { ...cfg.agent?.models };
models[MINIMAX_HOSTED_MODEL_REF] = {
...models[MINIMAX_HOSTED_MODEL_REF],
alias: models[MINIMAX_HOSTED_MODEL_REF]?.alias ?? "Minimax",
};
const providers = { ...cfg.models?.providers };
const hostedModel = {
id: MINIMAX_HOSTED_MODEL_ID,
name: "MiniMax M2.1",
reasoning: false,
input: ["text"],
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
contextWindow: DEFAULT_MINIMAX_CONTEXT_WINDOW,
maxTokens: DEFAULT_MINIMAX_MAX_TOKENS,
};
const existingProvider = providers.minimax;
const existingModels = Array.isArray(existingProvider?.models)
? existingProvider.models
: [];
const hasHostedModel = existingModels.some(
(model) => model.id === MINIMAX_HOSTED_MODEL_ID,
);
const mergedModels = hasHostedModel
? existingModels
: [...existingModels, hostedModel];
providers.minimax = {
...existingProvider,
baseUrl: params?.baseUrl?.trim() || DEFAULT_MINIMAX_BASE_URL,
apiKey: "minimax",
api: "openai-completions",
models: mergedModels.length > 0 ? mergedModels : [hostedModel],
};
return {
...cfg,
agent: {
...cfg.agent,
models,
},
models: {
mode: cfg.models?.mode ?? "merge",
providers,
},
};
}
export function applyMinimaxConfig(cfg: ClawdbotConfig): ClawdbotConfig {
const next = applyMinimaxProviderConfig(cfg);
return {
@@ -162,3 +232,26 @@ export function applyMinimaxConfig(cfg: ClawdbotConfig): ClawdbotConfig {
},
};
}
export function applyMinimaxHostedConfig(
cfg: ClawdbotConfig,
params?: { baseUrl?: string },
): ClawdbotConfig {
const next = applyMinimaxHostedProviderConfig(cfg, params);
return {
...next,
agent: {
...next.agent,
model: {
...(next.agent?.model &&
"fallbacks" in (next.agent.model as Record<string, unknown>)
? {
fallbacks: (next.agent.model as { fallbacks?: string[] })
.fallbacks,
}
: undefined),
primary: MINIMAX_HOSTED_MODEL_REF,
},
},
};
}

View File

@@ -30,8 +30,10 @@ import { healthCommand } from "./health.js";
import {
applyAuthProfileConfig,
applyMinimaxConfig,
applyMinimaxHostedConfig,
setAnthropicApiKey,
setGeminiApiKey,
setMinimaxApiKey,
} from "./onboard-auth.js";
import {
applyWizardMetadata,
@@ -150,6 +152,20 @@ export async function runNonInteractiveOnboarding(
});
process.env.OPENAI_API_KEY = key;
runtime.log(`Saved OPENAI_API_KEY to ${result.path}`);
} else if (authChoice === "minimax-cloud") {
const key = opts.minimaxApiKey?.trim();
if (!key) {
runtime.error("Missing --minimax-api-key");
runtime.exit(1);
return;
}
await setMinimaxApiKey(key);
nextConfig = applyAuthProfileConfig(nextConfig, {
profileId: "minimax:default",
provider: "minimax",
mode: "api_key",
});
nextConfig = applyMinimaxHostedConfig(nextConfig);
} else if (authChoice === "claude-cli") {
const store = ensureAuthProfileStore(undefined, {
allowKeychainPrompt: false,

View File

@@ -12,6 +12,7 @@ export type AuthChoice =
| "antigravity"
| "apiKey"
| "gemini-api-key"
| "minimax-cloud"
| "minimax"
| "skip";
export type GatewayAuthChoice = "off" | "token" | "password";
@@ -29,6 +30,7 @@ export type OnboardOptions = {
anthropicApiKey?: string;
openaiApiKey?: string;
geminiApiKey?: string;
minimaxApiKey?: string;
gatewayPort?: number;
gatewayBind?: GatewayBind;
gatewayAuth?: GatewayAuthChoice;