Files
9router/tests/unit/capabilities.test.js
KhuatHieu 13b468b889 fix(commandcode): preserve images and reasoning_effort on /alpha/generate
Command Code dropped vision and ignored client effort through the router:
image blocks became "[image omitted]", HTTP image URLs were never inlined,
and reasoning_effort landed on the envelope wrapper instead of params (so the
DeepSeek family mapping remapped low -> high). The catalog also treated
deepseek/deepseek-v4.1-flash as text-only, so the vision adapter stole those
requests to another provider.

- Map OpenAI image_url / Claude image blocks (base64 or data-URI) to the
  native {type:"image", image:"data:...;base64,...", mimeType} generate block.
- Add FORMATS.COMMANDCODE to TARGETS_NEED_BASE64 so remote http(s) images are
  inlined by the existing SSRF-safe fetcher before translation.
- Write reasoning_effort inside params for targetFormat commandcode and pass
  low|medium|high|xhigh|max through unmapped; allow it in thinkingLevels.
- Provider-scoped capabilities for commandcode/cmc: vision except the CLI
  text-only denylist, thinkingFormat commandcode, so family patterns
  (deepseek-v4 -> thinkingFormat deepseek, vision false) no longer win.
- Quota Tracker: whoami + billing credits/subscriptions (credits vs plan cap,
  5h and weekly windows), labels from AI_PROVIDERS[].name.
2026-09-16 20:17:25 +07:00

99 lines
4.0 KiB
JavaScript

import { describe, expect, it } from "vitest";
import { getCapabilitiesForModel } from "../../open-sse/providers/capabilities.js";
describe("getCapabilitiesForModel", () => {
const claudeSonnet5Expected = {
contextWindow: 1000000,
maxOutput: 128000,
thinkingFormat: "claude-adaptive",
reasoning: true,
vision: true,
search: true,
};
const kiroGpt56Expected = {
contextWindow: 272000,
maxOutput: 128000,
thinkingFormat: "openai",
reasoning: true,
vision: true,
search: true,
};
it("reports Kiro Claude Opus 5 variants as 1M adaptive-thinking models", () => {
for (const model of [
"claude-opus-5",
"anthropic/claude-opus-5",
"claude-opus-5-thinking",
"claude-opus-5-agentic",
"claude-opus-5-thinking-agentic",
]) {
expect(getCapabilitiesForModel("kiro", model)).toMatchObject(claudeSonnet5Expected);
}
});
it("reports Claude Fable 5.1 as a permanent adaptive-thinking model", () => {
expect(getCapabilitiesForModel("claude", "claude-fable-5-1")).toMatchObject({
...claudeSonnet5Expected,
thinkingCanDisable: false,
});
});
it("reports Kiro Claude Opus 4.8 as a 1M context model", () => {
expect(getCapabilitiesForModel("kiro", "claude-opus-4.8").contextWindow).toBe(1000000);
expect(getCapabilitiesForModel("kiro", "anthropic/claude-opus-4.8").contextWindow).toBe(1000000);
expect(getCapabilitiesForModel("kiro", "claude-opus-4-8").contextWindow).toBe(1000000);
expect(getCapabilitiesForModel("kiro", "claude-opus-4.8-thinking").contextWindow).toBe(1000000);
expect(getCapabilitiesForModel("kiro", "claude-opus-4-8-thinking").contextWindow).toBe(1000000);
});
it("reports Kiro Claude Sonnet 5 as a 1M adaptive-thinking model", () => {
expect(getCapabilitiesForModel("kiro", "claude-sonnet-5")).toMatchObject(claudeSonnet5Expected);
expect(getCapabilitiesForModel("kiro", "anthropic/claude-sonnet-5")).toMatchObject(claudeSonnet5Expected);
expect(getCapabilitiesForModel("kiro", "claude-sonnet-5-thinking")).toMatchObject(claudeSonnet5Expected);
expect(getCapabilitiesForModel("kiro", "claude-sonnet-5-agentic")).toMatchObject(claudeSonnet5Expected);
expect(getCapabilitiesForModel("kiro", "claude-sonnet-5-thinking-agentic")).toMatchObject(claudeSonnet5Expected);
});
it("reports Kiro GPT 5.6 models with the Kiro 272k context window", () => {
expect(getCapabilitiesForModel("kiro", "gpt-5.6-sol")).toMatchObject(kiroGpt56Expected);
expect(getCapabilitiesForModel("kiro", "openai/gpt-5.6-sol")).toMatchObject(kiroGpt56Expected);
expect(getCapabilitiesForModel("kiro", "gpt-5.6-terra-thinking")).toMatchObject(kiroGpt56Expected);
expect(getCapabilitiesForModel("kiro", "gpt-5.6-luna-agentic")).toMatchObject(kiroGpt56Expected);
expect(getCapabilitiesForModel("kiro", "gpt-5.6-sol-thinking-agentic")).toMatchObject(kiroGpt56Expected);
});
it("reports Codex GPT 6.0 Astra as a vision and thinking capable model", () => {
expect(getCapabilitiesForModel("codex", "gpt-6-astra")).toMatchObject({
vision: true,
reasoning: true,
search: true,
thinkingFormat: "openai",
contextWindow: 272000,
maxOutput: 128000,
});
});
it("CommandCode v4.1-flash is vision + effort capable", () => {
expect(getCapabilitiesForModel("commandcode", "deepseek/deepseek-v4.1-flash")).toMatchObject({
vision: true,
reasoning: true,
thinkingFormat: "commandcode",
thinkingEffortSupported: true,
});
});
it("CommandCode MiniMax-M3 is vision capable", () => {
expect(getCapabilitiesForModel("commandcode", "MiniMaxAI/MiniMax-M3").vision).toBe(true);
});
it("CommandCode text-only DeepSeek V4 Flash stays non-vision", () => {
expect(getCapabilitiesForModel("commandcode", "deepseek/deepseek-v4-flash").vision).toBe(false);
expect(getCapabilitiesForModel("commandcode", "deepseek/deepseek-v4-flash")).toMatchObject({
reasoning: true,
thinkingFormat: "commandcode",
thinkingEffortSupported: true,
});
});
});