* fix(models): resolve openrouter compat aliases * fix(models): cover openrouter free interactive alias * fix(models): mirror openrouter compat aliases in runtime resolver * fix(models): align openrouter free allowlist aliases
59 lines
1.5 KiB
TypeScript
59 lines
1.5 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import type { OpenClawConfig } from "../config/types.js";
|
|
import { resolveAllowedModelRef, resolveConfiguredModelRef } from "./model-selection-resolve.js";
|
|
|
|
describe("model-selection-resolve OpenRouter compat aliases", () => {
|
|
it("resolves openrouter:auto through the canonical OpenRouter auto model", () => {
|
|
const cfg = {
|
|
agents: {
|
|
defaults: {
|
|
model: { primary: "openrouter:auto" },
|
|
},
|
|
},
|
|
} as OpenClawConfig;
|
|
|
|
expect(
|
|
resolveConfiguredModelRef({
|
|
cfg,
|
|
defaultProvider: "anthropic",
|
|
defaultModel: "claude-sonnet-4-6",
|
|
}),
|
|
).toEqual({ provider: "openrouter", model: "openrouter/auto" });
|
|
});
|
|
|
|
it("resolves openrouter:free through the runtime allowlist path", () => {
|
|
const cfg = {
|
|
agents: {
|
|
defaults: {
|
|
models: {
|
|
"openrouter/meta-llama/llama-3.3-70b-instruct:free": {},
|
|
},
|
|
},
|
|
},
|
|
} as OpenClawConfig;
|
|
|
|
const catalog = [
|
|
{
|
|
provider: "openrouter",
|
|
id: "meta-llama/llama-3.3-70b-instruct:free",
|
|
name: "Llama 3.3 70B Free",
|
|
},
|
|
];
|
|
|
|
expect(
|
|
resolveAllowedModelRef({
|
|
cfg,
|
|
catalog,
|
|
raw: "openrouter:free",
|
|
defaultProvider: "anthropic",
|
|
}),
|
|
).toEqual({
|
|
ref: {
|
|
provider: "openrouter",
|
|
model: "meta-llama/llama-3.3-70b-instruct:free",
|
|
},
|
|
key: "openrouter/meta-llama/llama-3.3-70b-instruct:free",
|
|
});
|
|
});
|
|
});
|