Onboarding: add MiniMax hosted API key option
This commit is contained in:
@@ -166,8 +166,9 @@ Options:
|
|||||||
- `--workspace <dir>`
|
- `--workspace <dir>`
|
||||||
- `--non-interactive`
|
- `--non-interactive`
|
||||||
- `--mode <local|remote>`
|
- `--mode <local|remote>`
|
||||||
- `--auth-choice <oauth|claude-cli|openai-codex|codex-cli|antigravity|apiKey|minimax|skip>`
|
- `--auth-choice <oauth|claude-cli|openai-codex|codex-cli|antigravity|apiKey|minimax-cloud|minimax|skip>`
|
||||||
- `--anthropic-api-key <key>`
|
- `--anthropic-api-key <key>`
|
||||||
|
- `--minimax-api-key <key>`
|
||||||
- `--gateway-port <port>`
|
- `--gateway-port <port>`
|
||||||
- `--gateway-bind <loopback|lan|tailnet|auto>`
|
- `--gateway-bind <loopback|lan|tailnet|auto>`
|
||||||
- `--gateway-auth <off|token|password>`
|
- `--gateway-auth <off|token|password>`
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ async function main(): Promise<void> {
|
|||||||
const minimaxBaseUrl =
|
const minimaxBaseUrl =
|
||||||
process.env.MINIMAX_BASE_URL?.trim() || "https://api.minimax.io/v1";
|
process.env.MINIMAX_BASE_URL?.trim() || "https://api.minimax.io/v1";
|
||||||
const minimaxModelId =
|
const minimaxModelId =
|
||||||
process.env.MINIMAX_MODEL?.trim() || "minimax-m2.1";
|
process.env.MINIMAX_MODEL?.trim() || "MiniMax-M2.1";
|
||||||
|
|
||||||
const minimaxModel: Model<"openai-completions"> = {
|
const minimaxModel: Model<"openai-completions"> = {
|
||||||
id: minimaxModelId,
|
id: minimaxModelId,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { describe, expect, it } from "vitest";
|
|||||||
const MINIMAX_KEY = process.env.MINIMAX_API_KEY ?? "";
|
const MINIMAX_KEY = process.env.MINIMAX_API_KEY ?? "";
|
||||||
const MINIMAX_BASE_URL =
|
const MINIMAX_BASE_URL =
|
||||||
process.env.MINIMAX_BASE_URL?.trim() || "https://api.minimax.io/v1";
|
process.env.MINIMAX_BASE_URL?.trim() || "https://api.minimax.io/v1";
|
||||||
const MINIMAX_MODEL = process.env.MINIMAX_MODEL?.trim() || "minimax-m2.1";
|
const MINIMAX_MODEL = process.env.MINIMAX_MODEL?.trim() || "MiniMax-M2.1";
|
||||||
const LIVE = process.env.MINIMAX_LIVE_TEST === "1" || process.env.LIVE === "1";
|
const LIVE = process.env.MINIMAX_LIVE_TEST === "1" || process.env.LIVE === "1";
|
||||||
|
|
||||||
const describeLive = LIVE && MINIMAX_KEY ? describe : describe.skip;
|
const describeLive = LIVE && MINIMAX_KEY ? describe : describe.skip;
|
||||||
|
|||||||
@@ -135,6 +135,7 @@ export function resolveEnvApiKey(provider: string): EnvApiKeyResult | null {
|
|||||||
cerebras: "CEREBRAS_API_KEY",
|
cerebras: "CEREBRAS_API_KEY",
|
||||||
xai: "XAI_API_KEY",
|
xai: "XAI_API_KEY",
|
||||||
openrouter: "OPENROUTER_API_KEY",
|
openrouter: "OPENROUTER_API_KEY",
|
||||||
|
minimax: "MINIMAX_API_KEY",
|
||||||
zai: "ZAI_API_KEY",
|
zai: "ZAI_API_KEY",
|
||||||
mistral: "MISTRAL_API_KEY",
|
mistral: "MISTRAL_API_KEY",
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -232,9 +232,10 @@ 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: oauth|claude-cli|openai-codex|codex-cli|antigravity|apiKey|minimax|skip",
|
"Auth: oauth|claude-cli|openai-codex|codex-cli|antigravity|apiKey|minimax-cloud|minimax|skip",
|
||||||
)
|
)
|
||||||
.option("--anthropic-api-key <key>", "Anthropic API key")
|
.option("--anthropic-api-key <key>", "Anthropic API key")
|
||||||
|
.option("--minimax-api-key <key>", "MiniMax API key")
|
||||||
.option("--gateway-port <port>", "Gateway port")
|
.option("--gateway-port <port>", "Gateway port")
|
||||||
.option("--gateway-bind <mode>", "Gateway bind: loopback|lan|tailnet|auto")
|
.option("--gateway-bind <mode>", "Gateway bind: loopback|lan|tailnet|auto")
|
||||||
.option("--gateway-auth <mode>", "Gateway auth: off|token|password")
|
.option("--gateway-auth <mode>", "Gateway auth: off|token|password")
|
||||||
@@ -264,10 +265,12 @@ export function buildProgram() {
|
|||||||
| "codex-cli"
|
| "codex-cli"
|
||||||
| "antigravity"
|
| "antigravity"
|
||||||
| "apiKey"
|
| "apiKey"
|
||||||
|
| "minimax-cloud"
|
||||||
| "minimax"
|
| "minimax"
|
||||||
| "skip"
|
| "skip"
|
||||||
| undefined,
|
| undefined,
|
||||||
anthropicApiKey: opts.anthropicApiKey as string | undefined,
|
anthropicApiKey: opts.anthropicApiKey as string | undefined,
|
||||||
|
minimaxApiKey: opts.minimaxApiKey as string | undefined,
|
||||||
gatewayPort:
|
gatewayPort:
|
||||||
typeof opts.gatewayPort === "string"
|
typeof opts.gatewayPort === "string"
|
||||||
? Number.parseInt(opts.gatewayPort, 10)
|
? Number.parseInt(opts.gatewayPort, 10)
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ export function buildAuthChoiceOptions(params: {
|
|||||||
label: "Google Antigravity (Claude Opus 4.5, Gemini 3, etc.)",
|
label: "Google Antigravity (Claude Opus 4.5, Gemini 3, etc.)",
|
||||||
});
|
});
|
||||||
options.push({ value: "apiKey", label: "Anthropic API key" });
|
options.push({ value: "apiKey", label: "Anthropic API key" });
|
||||||
|
options.push({ value: "minimax-cloud", label: "MiniMax M2.1 (minimax.io)" });
|
||||||
options.push({ value: "minimax", label: "Minimax M2.1 (LM Studio)" });
|
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" });
|
||||||
|
|||||||
@@ -28,8 +28,12 @@ import {
|
|||||||
import {
|
import {
|
||||||
applyAuthProfileConfig,
|
applyAuthProfileConfig,
|
||||||
applyMinimaxConfig,
|
applyMinimaxConfig,
|
||||||
|
applyMinimaxHostedConfig,
|
||||||
|
applyMinimaxHostedProviderConfig,
|
||||||
applyMinimaxProviderConfig,
|
applyMinimaxProviderConfig,
|
||||||
|
MINIMAX_HOSTED_MODEL_REF,
|
||||||
setAnthropicApiKey,
|
setAnthropicApiKey,
|
||||||
|
setMinimaxApiKey,
|
||||||
writeOAuthCredentials,
|
writeOAuthCredentials,
|
||||||
} from "./onboard-auth.js";
|
} from "./onboard-auth.js";
|
||||||
import { openUrl } from "./onboard-helpers.js";
|
import { openUrl } from "./onboard-helpers.js";
|
||||||
@@ -397,6 +401,24 @@ export async function applyAuthChoice(params: {
|
|||||||
provider: "anthropic",
|
provider: "anthropic",
|
||||||
mode: "api_key",
|
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") {
|
} else if (params.authChoice === "minimax") {
|
||||||
if (params.setDefaultModel) {
|
if (params.setDefaultModel) {
|
||||||
nextConfig = applyMinimaxConfig(nextConfig);
|
nextConfig = applyMinimaxConfig(nextConfig);
|
||||||
|
|||||||
@@ -52,7 +52,9 @@ import { healthCommand } from "./health.js";
|
|||||||
import {
|
import {
|
||||||
applyAuthProfileConfig,
|
applyAuthProfileConfig,
|
||||||
applyMinimaxConfig,
|
applyMinimaxConfig,
|
||||||
|
applyMinimaxHostedConfig,
|
||||||
setAnthropicApiKey,
|
setAnthropicApiKey,
|
||||||
|
setMinimaxApiKey,
|
||||||
writeOAuthCredentials,
|
writeOAuthCredentials,
|
||||||
} from "./onboard-auth.js";
|
} from "./onboard-auth.js";
|
||||||
import {
|
import {
|
||||||
@@ -296,6 +298,7 @@ async function promptAuthConfig(
|
|||||||
| "codex-cli"
|
| "codex-cli"
|
||||||
| "antigravity"
|
| "antigravity"
|
||||||
| "apiKey"
|
| "apiKey"
|
||||||
|
| "minimax-cloud"
|
||||||
| "minimax"
|
| "minimax"
|
||||||
| "skip";
|
| "skip";
|
||||||
|
|
||||||
@@ -522,6 +525,21 @@ async function promptAuthConfig(
|
|||||||
provider: "anthropic",
|
provider: "anthropic",
|
||||||
mode: "api_key",
|
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") {
|
} else if (authChoice === "minimax") {
|
||||||
next = applyMinimaxConfig(next);
|
next = applyMinimaxConfig(next);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,12 @@ import { resolveDefaultAgentDir } from "../agents/agent-scope.js";
|
|||||||
import { upsertAuthProfile } from "../agents/auth-profiles.js";
|
import { upsertAuthProfile } from "../agents/auth-profiles.js";
|
||||||
import type { ClawdbotConfig } from "../config/config.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(
|
export async function writeOAuthCredentials(
|
||||||
provider: OAuthProvider,
|
provider: OAuthProvider,
|
||||||
creds: OAuthCredentials,
|
creds: OAuthCredentials,
|
||||||
@@ -33,6 +39,19 @@ export async function setAnthropicApiKey(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(
|
export function applyAuthProfileConfig(
|
||||||
cfg: ClawdbotConfig,
|
cfg: ClawdbotConfig,
|
||||||
params: {
|
params: {
|
||||||
@@ -119,6 +138,49 @@ 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 };
|
||||||
|
if (!providers.minimax) {
|
||||||
|
providers.minimax = {
|
||||||
|
baseUrl: params?.baseUrl?.trim() || DEFAULT_MINIMAX_BASE_URL,
|
||||||
|
apiKey: "minimax",
|
||||||
|
api: "openai-completions",
|
||||||
|
models: [
|
||||||
|
{
|
||||||
|
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,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
...cfg,
|
||||||
|
agent: {
|
||||||
|
...cfg.agent,
|
||||||
|
models,
|
||||||
|
},
|
||||||
|
models: {
|
||||||
|
mode: cfg.models?.mode ?? "merge",
|
||||||
|
providers,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function applyMinimaxConfig(cfg: ClawdbotConfig): ClawdbotConfig {
|
export function applyMinimaxConfig(cfg: ClawdbotConfig): ClawdbotConfig {
|
||||||
const next = applyMinimaxProviderConfig(cfg);
|
const next = applyMinimaxProviderConfig(cfg);
|
||||||
return {
|
return {
|
||||||
@@ -138,3 +200,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,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
@@ -25,7 +25,9 @@ import { healthCommand } from "./health.js";
|
|||||||
import {
|
import {
|
||||||
applyAuthProfileConfig,
|
applyAuthProfileConfig,
|
||||||
applyMinimaxConfig,
|
applyMinimaxConfig,
|
||||||
|
applyMinimaxHostedConfig,
|
||||||
setAnthropicApiKey,
|
setAnthropicApiKey,
|
||||||
|
setMinimaxApiKey,
|
||||||
} from "./onboard-auth.js";
|
} from "./onboard-auth.js";
|
||||||
import {
|
import {
|
||||||
applyWizardMetadata,
|
applyWizardMetadata,
|
||||||
@@ -117,6 +119,20 @@ export async function runNonInteractiveOnboarding(
|
|||||||
provider: "anthropic",
|
provider: "anthropic",
|
||||||
mode: "api_key",
|
mode: "api_key",
|
||||||
});
|
});
|
||||||
|
} 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") {
|
} else if (authChoice === "claude-cli") {
|
||||||
const store = ensureAuthProfileStore();
|
const store = ensureAuthProfileStore();
|
||||||
if (!store.profiles[CLAUDE_CLI_PROFILE_ID]) {
|
if (!store.profiles[CLAUDE_CLI_PROFILE_ID]) {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ export type AuthChoice =
|
|||||||
| "codex-cli"
|
| "codex-cli"
|
||||||
| "antigravity"
|
| "antigravity"
|
||||||
| "apiKey"
|
| "apiKey"
|
||||||
|
| "minimax-cloud"
|
||||||
| "minimax"
|
| "minimax"
|
||||||
| "skip";
|
| "skip";
|
||||||
export type GatewayAuthChoice = "off" | "token" | "password";
|
export type GatewayAuthChoice = "off" | "token" | "password";
|
||||||
@@ -24,6 +25,7 @@ export type OnboardOptions = {
|
|||||||
nonInteractive?: boolean;
|
nonInteractive?: boolean;
|
||||||
authChoice?: AuthChoice;
|
authChoice?: AuthChoice;
|
||||||
anthropicApiKey?: string;
|
anthropicApiKey?: string;
|
||||||
|
minimaxApiKey?: string;
|
||||||
gatewayPort?: number;
|
gatewayPort?: number;
|
||||||
gatewayBind?: GatewayBind;
|
gatewayBind?: GatewayBind;
|
||||||
gatewayAuth?: GatewayAuthChoice;
|
gatewayAuth?: GatewayAuthChoice;
|
||||||
|
|||||||
Reference in New Issue
Block a user