2026-03-16 19:51:55 -07:00
|
|
|
import {
|
2026-03-18 23:58:49 +00:00
|
|
|
applyProviderConfigWithDefaultModelPreset,
|
2026-03-16 21:13:56 -07:00
|
|
|
type OpenClawConfig,
|
|
|
|
|
} from "openclaw/plugin-sdk/provider-onboard";
|
2026-03-16 19:51:55 -07:00
|
|
|
import {
|
|
|
|
|
buildKimiCodingProvider,
|
2026-03-16 21:13:56 -07:00
|
|
|
KIMI_CODING_BASE_URL,
|
|
|
|
|
KIMI_CODING_DEFAULT_MODEL_ID,
|
2026-03-16 19:51:55 -07:00
|
|
|
} from "./provider-catalog.js";
|
|
|
|
|
|
2026-03-16 21:33:35 -07:00
|
|
|
export const KIMI_MODEL_REF = `kimi/${KIMI_CODING_DEFAULT_MODEL_ID}`;
|
|
|
|
|
export const KIMI_CODING_MODEL_REF = KIMI_MODEL_REF;
|
2026-03-16 19:51:55 -07:00
|
|
|
|
2026-03-18 23:58:49 +00:00
|
|
|
function resolveKimiCodingDefaultModel() {
|
|
|
|
|
return buildKimiCodingProvider().models[0];
|
|
|
|
|
}
|
2026-03-16 19:51:55 -07:00
|
|
|
|
2026-03-18 23:58:49 +00:00
|
|
|
function applyKimiCodingPreset(cfg: OpenClawConfig, primaryModelRef?: string): OpenClawConfig {
|
|
|
|
|
const defaultModel = resolveKimiCodingDefaultModel();
|
2026-03-16 21:13:56 -07:00
|
|
|
if (!defaultModel) {
|
2026-03-16 19:51:55 -07:00
|
|
|
return cfg;
|
|
|
|
|
}
|
2026-03-18 23:58:49 +00:00
|
|
|
return applyProviderConfigWithDefaultModelPreset(cfg, {
|
2026-03-16 21:33:35 -07:00
|
|
|
providerId: "kimi",
|
2026-03-16 19:51:55 -07:00
|
|
|
api: "anthropic-messages",
|
2026-03-16 21:13:56 -07:00
|
|
|
baseUrl: KIMI_CODING_BASE_URL,
|
|
|
|
|
defaultModel,
|
|
|
|
|
defaultModelId: KIMI_CODING_DEFAULT_MODEL_ID,
|
2026-03-18 23:58:49 +00:00
|
|
|
aliases: [{ modelRef: KIMI_MODEL_REF, alias: "Kimi" }],
|
|
|
|
|
primaryModelRef,
|
2026-03-16 19:51:55 -07:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-18 23:58:49 +00:00
|
|
|
export function applyKimiCodeProviderConfig(cfg: OpenClawConfig): OpenClawConfig {
|
|
|
|
|
return applyKimiCodingPreset(cfg);
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-16 19:51:55 -07:00
|
|
|
export function applyKimiCodeConfig(cfg: OpenClawConfig): OpenClawConfig {
|
2026-03-18 23:58:49 +00:00
|
|
|
return applyKimiCodingPreset(cfg, KIMI_MODEL_REF);
|
2026-03-16 19:51:55 -07:00
|
|
|
}
|