mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-25 22:09:33 +00:00
50 lines
1.6 KiB
TypeScript
50 lines
1.6 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, COHERE_MODEL_CATALOG } from "./models.js";
|
|
import {
|
|
applyCohereConfig,
|
|
applyCohereProviderConfig,
|
|
COHERE_DEFAULT_MODEL_ID,
|
|
COHERE_DEFAULT_MODEL_REF,
|
|
} from "./onboard.js";
|
|
|
|
describe("Cohere onboarding", () => {
|
|
it("registers the manifest catalog through the compatibility endpoint", () => {
|
|
const result = applyCohereProviderConfig({});
|
|
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]);
|
|
expect(buildCohereCatalogModels()).toHaveLength(COHERE_MODEL_CATALOG.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,
|
|
);
|
|
});
|
|
});
|