Replace the multi-step MiniMax onboarding wizard with 4 flat options: - MiniMax Global — OAuth (minimax.io) - MiniMax Global — API Key (minimax.io) - MiniMax CN — OAuth (minimaxi.com) - MiniMax CN — API Key (minimaxi.com) Storage changes: - Unify CN and Global under provider "minimax" (baseUrl distinguishes region) - Profiles: minimax:global / minimax:cn (both regions can coexist) - Model ref: minimax/MiniMax-M2.5 (no more minimax-cn/ prefix) - Remove LM Studio local mode and Lightning/Highspeed choice Backward compatibility: - Keep minimax-cn in provider-env-vars for existing configs - Accept minimax-cn as legacy tokenProvider in CI pipelines - Error with migration hint for removed auth choices in non-interactive mode - Warn when dual-profile overwrites shared provider baseUrl Made-with: Cursor
107 lines
3.3 KiB
TypeScript
107 lines
3.3 KiB
TypeScript
import type { OpenClawConfig } from "../config/config.js";
|
|
import type { ModelProviderConfig } from "../config/types.models.js";
|
|
import {
|
|
applyAgentDefaultModelPrimary,
|
|
applyOnboardAuthAgentModelsAndProviders,
|
|
} from "./onboard-auth.config-shared.js";
|
|
import {
|
|
buildMinimaxApiModelDefinition,
|
|
MINIMAX_API_BASE_URL,
|
|
MINIMAX_CN_API_BASE_URL,
|
|
} from "./onboard-auth.models.js";
|
|
|
|
type MinimaxApiProviderConfigParams = {
|
|
providerId: string;
|
|
modelId: string;
|
|
baseUrl: string;
|
|
};
|
|
|
|
function applyMinimaxApiProviderConfigWithBaseUrl(
|
|
cfg: OpenClawConfig,
|
|
params: MinimaxApiProviderConfigParams,
|
|
): OpenClawConfig {
|
|
const providers = { ...cfg.models?.providers } as Record<string, ModelProviderConfig>;
|
|
const existingProvider = providers[params.providerId];
|
|
const existingModels = existingProvider?.models ?? [];
|
|
const apiModel = buildMinimaxApiModelDefinition(params.modelId);
|
|
const hasApiModel = existingModels.some((model) => model.id === params.modelId);
|
|
const mergedModels = hasApiModel ? existingModels : [...existingModels, apiModel];
|
|
const { apiKey: existingApiKey, ...existingProviderRest } = existingProvider ?? {
|
|
baseUrl: params.baseUrl,
|
|
models: [],
|
|
};
|
|
const resolvedApiKey = typeof existingApiKey === "string" ? existingApiKey : undefined;
|
|
const normalizedApiKey = resolvedApiKey?.trim() === "minimax" ? "" : resolvedApiKey;
|
|
providers[params.providerId] = {
|
|
...existingProviderRest,
|
|
baseUrl: params.baseUrl,
|
|
api: "anthropic-messages",
|
|
authHeader: true,
|
|
...(normalizedApiKey?.trim() ? { apiKey: normalizedApiKey } : {}),
|
|
models: mergedModels.length > 0 ? mergedModels : [apiModel],
|
|
};
|
|
|
|
const models = { ...cfg.agents?.defaults?.models };
|
|
const modelRef = `${params.providerId}/${params.modelId}`;
|
|
models[modelRef] = {
|
|
...models[modelRef],
|
|
alias: "Minimax",
|
|
};
|
|
|
|
return applyOnboardAuthAgentModelsAndProviders(cfg, { agentModels: models, providers });
|
|
}
|
|
|
|
function applyMinimaxApiConfigWithBaseUrl(
|
|
cfg: OpenClawConfig,
|
|
params: MinimaxApiProviderConfigParams,
|
|
): OpenClawConfig {
|
|
const next = applyMinimaxApiProviderConfigWithBaseUrl(cfg, params);
|
|
return applyAgentDefaultModelPrimary(next, `${params.providerId}/${params.modelId}`);
|
|
}
|
|
|
|
// MiniMax Global API (platform.minimax.io/anthropic)
|
|
export function applyMinimaxApiProviderConfig(
|
|
cfg: OpenClawConfig,
|
|
modelId: string = "MiniMax-M2.5",
|
|
): OpenClawConfig {
|
|
return applyMinimaxApiProviderConfigWithBaseUrl(cfg, {
|
|
providerId: "minimax",
|
|
modelId,
|
|
baseUrl: MINIMAX_API_BASE_URL,
|
|
});
|
|
}
|
|
|
|
export function applyMinimaxApiConfig(
|
|
cfg: OpenClawConfig,
|
|
modelId: string = "MiniMax-M2.5",
|
|
): OpenClawConfig {
|
|
return applyMinimaxApiConfigWithBaseUrl(cfg, {
|
|
providerId: "minimax",
|
|
modelId,
|
|
baseUrl: MINIMAX_API_BASE_URL,
|
|
});
|
|
}
|
|
|
|
// MiniMax CN API (api.minimaxi.com/anthropic) — same provider id, different baseUrl
|
|
export function applyMinimaxApiProviderConfigCn(
|
|
cfg: OpenClawConfig,
|
|
modelId: string = "MiniMax-M2.5",
|
|
): OpenClawConfig {
|
|
return applyMinimaxApiProviderConfigWithBaseUrl(cfg, {
|
|
providerId: "minimax",
|
|
modelId,
|
|
baseUrl: MINIMAX_CN_API_BASE_URL,
|
|
});
|
|
}
|
|
|
|
export function applyMinimaxApiConfigCn(
|
|
cfg: OpenClawConfig,
|
|
modelId: string = "MiniMax-M2.5",
|
|
): OpenClawConfig {
|
|
return applyMinimaxApiConfigWithBaseUrl(cfg, {
|
|
providerId: "minimax",
|
|
modelId,
|
|
baseUrl: MINIMAX_CN_API_BASE_URL,
|
|
});
|
|
}
|