mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-02 09:41:37 +00:00
60 lines
2.1 KiB
TypeScript
60 lines
2.1 KiB
TypeScript
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
|
|
import { resolveAgentModelPrimaryValue } from "openclaw/plugin-sdk/provider-onboard";
|
|
import { describe, expect, it } from "vitest";
|
|
import { buildCohereCatalogModels, COHERE_BASE_URL } from "./models.js";
|
|
import { applyCohereConfig } from "./onboard.js";
|
|
import manifest from "./openclaw.plugin.json" with { type: "json" };
|
|
|
|
const COHERE_DEFAULT_MODEL_REF = `cohere/${manifest.modelCatalog.providers.cohere.defaultModel}`;
|
|
const COHERE_DEFAULT_MODEL_ID = "command-a-plus-05-2026";
|
|
const COHERE_COMMAND_A_REASONING_MODEL_ID = "command-a-reasoning-08-2025";
|
|
const COHERE_COMMAND_A_VISION_MODEL_ID = "command-a-vision-07-2025";
|
|
const COHERE_NORTH_MINI_CODE_MODEL_ID = "north-mini-code-1-0";
|
|
|
|
describe("Cohere onboarding", () => {
|
|
it("registers the manifest catalog through the onboarding preset", () => {
|
|
const result = applyCohereConfig({});
|
|
const provider = result.models?.providers?.cohere;
|
|
|
|
expect(provider).toMatchObject({
|
|
baseUrl: COHERE_BASE_URL,
|
|
api: "openai-completions",
|
|
});
|
|
expect(provider?.models?.map((model) => model.id)).toEqual([
|
|
COHERE_DEFAULT_MODEL_ID,
|
|
"command-a-03-2025",
|
|
COHERE_COMMAND_A_REASONING_MODEL_ID,
|
|
COHERE_COMMAND_A_VISION_MODEL_ID,
|
|
COHERE_NORTH_MINI_CODE_MODEL_ID,
|
|
]);
|
|
expect(buildCohereCatalogModels()).toHaveLength(
|
|
manifest.modelCatalog.providers.cohere.models.length,
|
|
);
|
|
});
|
|
|
|
it("sets Cohere only when there is no primary model", () => {
|
|
const existing: OpenClawConfig = {
|
|
agents: {
|
|
defaults: {
|
|
model: { primary: "openai/gpt-5.5" },
|
|
},
|
|
},
|
|
};
|
|
|
|
const result = applyCohereConfig(existing);
|
|
|
|
expect(resolveAgentModelPrimaryValue(result.agents?.defaults?.model)).toBe("openai/gpt-5.5");
|
|
expect(result.agents?.defaults?.models?.[COHERE_DEFAULT_MODEL_REF]).toEqual({
|
|
alias: "Cohere Command A+",
|
|
});
|
|
});
|
|
|
|
it("uses Cohere as the first configured primary model", () => {
|
|
const result = applyCohereConfig({});
|
|
|
|
expect(resolveAgentModelPrimaryValue(result.agents?.defaults?.model)).toBe(
|
|
COHERE_DEFAULT_MODEL_REF,
|
|
);
|
|
});
|
|
});
|