openclaw/extensions/kimi-coding/provider-catalog.ts
Peter Steinberger 8554267afb
fix(kimi): normalize legacy model IDs from manifest metadata (#146261)
Declare the documented kimi-code, k2p5, and k3[1m] aliases before provider runtime loads. Read the same manifest map from the existing public helper so cold model selection and runtime normalization share one policy.

Preserve registered hooks and public exports, and remove the obsolete type-assertion allowance. Static parser regressions fail for all three legacy IDs on the baseline and retain canonical model controls.

Related: #130706
Prerequisite: #146183
2026-09-12 11:00:50 -07:00

25 lines
1 KiB
TypeScript

// Kimi Coding provider module implements model/runtime integration.
import { buildManifestModelProviderConfig } from "openclaw/plugin-sdk/provider-catalog-shared";
import type { ModelProviderConfig } from "openclaw/plugin-sdk/provider-model-shared";
import manifest from "./openclaw.plugin.json" with { type: "json" };
const KIMI_PROVIDER_ID = "kimi";
const KIMI_CODING_CATALOG = manifest.modelCatalog.providers.kimi;
const KIMI_MODEL_ALIASES = new Map(
Object.entries(manifest.modelIdNormalization.providers.kimi.aliases),
);
export const KIMI_CODING_BASE_URL = KIMI_CODING_CATALOG.baseUrl;
export const KIMI_CODING_DEFAULT_MODEL_ID = KIMI_CODING_CATALOG.defaultModel;
export const KIMI_CODING_LEGACY_MODEL_IDS = ["kimi-code", "k2p5"] as const;
export function buildKimiCodingProvider(): ModelProviderConfig {
return buildManifestModelProviderConfig({
providerId: KIMI_PROVIDER_ID,
catalog: KIMI_CODING_CATALOG,
});
}
export function normalizeKimiCodingModelId(modelId: string): string {
return KIMI_MODEL_ALIASES.get(modelId) ?? modelId;
}