Files
openclaw/extensions/cohere/models.ts
2026-07-15 16:23:47 -07:00

44 lines
1.7 KiB
TypeScript

/**
* Cohere model catalog helpers derived from the plugin manifest.
*/
import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
import { buildManifestModelProviderConfig } from "openclaw/plugin-sdk/provider-catalog-shared";
import type { ModelDefinitionConfig } from "openclaw/plugin-sdk/provider-model-shared";
import manifest from "./openclaw.plugin.json" with { type: "json" };
const COHERE_MANIFEST_CATALOG = manifest.modelCatalog.providers.cohere;
export const COHERE_BASE_URL = COHERE_MANIFEST_CATALOG.baseUrl;
export const COHERE_MODEL_CATALOG = COHERE_MANIFEST_CATALOG.models;
export const COHERE_COMMAND_A_PLUS_MODEL_ID = "command-a-plus-05-2026";
const COHERE_COMMAND_A_REASONING_MODEL_ID = "command-a-reasoning-08-2025";
const COHERE_NORTH_MINI_CODE_MODEL_ID = "north-mini-code-1-0";
const COHERE_MODERN_MODEL_IDS = new Set([
COHERE_COMMAND_A_PLUS_MODEL_ID,
COHERE_COMMAND_A_REASONING_MODEL_ID,
// Modern sweeps require agent tool use; Vision explicitly does not support tools.
COHERE_NORTH_MINI_CODE_MODEL_ID,
]);
export function isModernCohereModelId(modelId: string): boolean {
return COHERE_MODERN_MODEL_IDS.has(modelId.trim().toLowerCase());
}
export function buildCohereCatalogModels(): ModelDefinitionConfig[] {
return buildManifestModelProviderConfig({
providerId: "cohere",
catalog: COHERE_MANIFEST_CATALOG,
}).models;
}
export function buildCohereModelDefinition(
model: (typeof COHERE_MODEL_CATALOG)[number],
): ModelDefinitionConfig {
const providerConfig = buildManifestModelProviderConfig({
providerId: "cohere",
catalog: { ...COHERE_MANIFEST_CATALOG, models: [model] },
});
return expectDefined(providerConfig.models.at(0), "normalized Cohere manifest model");
}