mirror of
https://github.com/hanzoai/bot.git
synced 2026-11-02 00:42:49 +00:00
The automated rebrand sed script replaced "OpenClaw" with "Hanzo Bot" (with space) instead of "HanzoBot" in 8,315 TypeScript identifier occurrences across 1,632 files. This fixes all broken class names, type names, function names, and variable names. Co-authored-by: Hanzo Dev <[email protected]>
105 lines
3.1 KiB
TypeScript
105 lines
3.1 KiB
TypeScript
import {
|
|
applyAgentDefaultModelPrimary,
|
|
applyOnboardAuthAgentModelsAndProviders,
|
|
type ModelProviderConfig,
|
|
type HanzoBotConfig,
|
|
} from "openclaw/plugin-sdk/provider-onboard";
|
|
import {
|
|
buildMinimaxApiModelDefinition,
|
|
MINIMAX_API_BASE_URL,
|
|
MINIMAX_CN_API_BASE_URL,
|
|
} from "./model-definitions.js";
|
|
|
|
type MinimaxApiProviderConfigParams = {
|
|
providerId: string;
|
|
modelId: string;
|
|
baseUrl: string;
|
|
};
|
|
|
|
function applyMinimaxApiProviderConfigWithBaseUrl(
|
|
cfg: HanzoBotConfig,
|
|
params: MinimaxApiProviderConfigParams,
|
|
): HanzoBotConfig {
|
|
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: HanzoBotConfig,
|
|
params: MinimaxApiProviderConfigParams,
|
|
): HanzoBotConfig {
|
|
const next = applyMinimaxApiProviderConfigWithBaseUrl(cfg, params);
|
|
return applyAgentDefaultModelPrimary(next, `${params.providerId}/${params.modelId}`);
|
|
}
|
|
|
|
export function applyMinimaxApiProviderConfig(
|
|
cfg: HanzoBotConfig,
|
|
modelId: string = "MiniMax-M2.7",
|
|
): HanzoBotConfig {
|
|
return applyMinimaxApiProviderConfigWithBaseUrl(cfg, {
|
|
providerId: "minimax",
|
|
modelId,
|
|
baseUrl: MINIMAX_API_BASE_URL,
|
|
});
|
|
}
|
|
|
|
export function applyMinimaxApiConfig(
|
|
cfg: HanzoBotConfig,
|
|
modelId: string = "MiniMax-M2.7",
|
|
): HanzoBotConfig {
|
|
return applyMinimaxApiConfigWithBaseUrl(cfg, {
|
|
providerId: "minimax",
|
|
modelId,
|
|
baseUrl: MINIMAX_API_BASE_URL,
|
|
});
|
|
}
|
|
|
|
export function applyMinimaxApiProviderConfigCn(
|
|
cfg: HanzoBotConfig,
|
|
modelId: string = "MiniMax-M2.7",
|
|
): HanzoBotConfig {
|
|
return applyMinimaxApiProviderConfigWithBaseUrl(cfg, {
|
|
providerId: "minimax",
|
|
modelId,
|
|
baseUrl: MINIMAX_CN_API_BASE_URL,
|
|
});
|
|
}
|
|
|
|
export function applyMinimaxApiConfigCn(
|
|
cfg: HanzoBotConfig,
|
|
modelId: string = "MiniMax-M2.7",
|
|
): HanzoBotConfig {
|
|
return applyMinimaxApiConfigWithBaseUrl(cfg, {
|
|
providerId: "minimax",
|
|
modelId,
|
|
baseUrl: MINIMAX_CN_API_BASE_URL,
|
|
});
|
|
}
|