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.
41 lines
1.6 KiB
JavaScript
41 lines
1.6 KiB
JavaScript
// Guards the refactored USAGE_HANDLERS dispatch: unsupported → message, supported → routed.
|
|
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
|
|
// Stub network so handlers don't hit real APIs; each call resolves an empty 200.
|
|
vi.mock("../../open-sse/utils/proxyFetch.js", () => ({
|
|
proxyAwareFetch: vi.fn(async () => ({
|
|
ok: true,
|
|
status: 200,
|
|
json: async () => ({}),
|
|
text: async () => "{}",
|
|
})),
|
|
}));
|
|
|
|
const load = () => import("../../open-sse/services/usage.js");
|
|
const SUPPORTED = [
|
|
"github", "gemini-cli", "antigravity", "claude", "codex", "kiro",
|
|
"qoder", "iflow", "ollama", "glm", "glm-cn",
|
|
"minimax", "minimax-cn", "vercel-ai-gateway", "grok-cli", "kimi",
|
|
"deepseek", "opencode-go", "zed", "commandcode",
|
|
];
|
|
|
|
describe("usage dispatch", () => {
|
|
beforeEach(() => vi.clearAllMocks());
|
|
|
|
it("unsupported provider → not-implemented message", async () => {
|
|
const { getUsageForProvider } = await load();
|
|
const res = await getUsageForProvider({ provider: "totally-unknown" });
|
|
expect(res).toEqual({ message: "Usage API not implemented for totally-unknown" });
|
|
});
|
|
|
|
it("every supported provider routes to its handler (no fallback message)", async () => {
|
|
const { getUsageForProvider } = await load();
|
|
for (const provider of SUPPORTED) {
|
|
const res = await getUsageForProvider({ provider, accessToken: "t", apiKey: "k" });
|
|
// Routed handler must return an object and never the unsupported fallback
|
|
expect(res, `${provider} routed`).toBeTypeOf("object");
|
|
expect(res?.message).not.toBe(`Usage API not implemented for ${provider}`);
|
|
}
|
|
});
|
|
});
|