8a0903ebf2
The root barrel is now core-only and side-effect free: types, createModels/createProvider, auth substrate, lazyStream/lazyApi, faux, utils. Generated catalogs, api-registry, env-api-keys, images, global stream functions, and per-API lazy wrappers leave the root. New @earendil-works/pi-ai/compat preserves the old surface verbatim as a strict superset of the root: api-dispatch stream/complete with env key injection, the builtin registration side effect (skip-if-present so it cannot clobber earlier overrides), deprecated getModel/getModels/ getProviders aliases of the new getBuiltin* reads in providers/all, lazy api wrappers + setBedrockProviderModule, and image generation. Compat dies with the coding-agent ModelManager migration. Packaging: exports map gains ./compat, ./providers/*, ./api/*; sideEffects array lists only the effectful modules. Old-global imports across agent/coding-agent/examples and pi-ai tests switch to /compat (path-only; compat is a superset). The coding-agent extension loader resolves the pi-ai ROOT specifier to compat, so existing user extensions using the old global API keep working at runtime until compat is removed. vitest configs alias /compat to src; browser smoke imports old globals from /compat.
97 lines
3.9 KiB
TypeScript
97 lines
3.9 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { getModel, getSupportedThinkingLevels } from "../src/compat.ts";
|
|
|
|
describe("getSupportedThinkingLevels", () => {
|
|
it("includes xhigh for Anthropic Opus 4.6 on anthropic-messages API", () => {
|
|
const model = getModel("anthropic", "claude-opus-4-6");
|
|
expect(model).toBeDefined();
|
|
expect(getSupportedThinkingLevels(model!)).toContain("xhigh");
|
|
});
|
|
|
|
it("includes xhigh for Anthropic Opus 4.8 on anthropic-messages API", () => {
|
|
const model = getModel("anthropic", "claude-opus-4-8");
|
|
expect(model).toBeDefined();
|
|
expect(getSupportedThinkingLevels(model!)).toContain("xhigh");
|
|
});
|
|
|
|
it("includes xhigh for Anthropic Opus 4.8 on anthropic-messages API", () => {
|
|
const model = getModel("anthropic", "claude-opus-4-8");
|
|
expect(model).toBeDefined();
|
|
expect(getSupportedThinkingLevels(model!)).toContain("xhigh");
|
|
});
|
|
|
|
it("includes xhigh but not off for Anthropic Claude Fable 5 on anthropic-messages API", () => {
|
|
const model = getModel("anthropic", "claude-fable-5");
|
|
expect(model).toBeDefined();
|
|
expect(getSupportedThinkingLevels(model!)).toContain("xhigh");
|
|
expect(getSupportedThinkingLevels(model!)).not.toContain("off");
|
|
});
|
|
|
|
it("does not include xhigh for Claude Sonnet 4.5", () => {
|
|
const model = getModel("anthropic", "claude-sonnet-4-5");
|
|
expect(model).toBeDefined();
|
|
expect(getSupportedThinkingLevels(model!)).not.toContain("xhigh");
|
|
});
|
|
|
|
it.each(["gpt-5.4", "gpt-5.5"] as const)("includes xhigh for %s models", (modelId) => {
|
|
const model = getModel("openai-codex", modelId);
|
|
expect(model).toBeDefined();
|
|
expect(getSupportedThinkingLevels(model!)).toContain("xhigh");
|
|
});
|
|
|
|
it("includes only medium/high/xhigh for OpenAI GPT-5.5 Pro", () => {
|
|
const model = getModel("openai", "gpt-5.5-pro");
|
|
expect(model).toBeDefined();
|
|
expect(getSupportedThinkingLevels(model!)).toEqual(["medium", "high", "xhigh"]);
|
|
});
|
|
|
|
it("includes only medium/high/xhigh for OpenRouter GPT-5.5 Pro", () => {
|
|
const model = getModel("openrouter", "openai/gpt-5.5-pro");
|
|
expect(model).toBeDefined();
|
|
expect(getSupportedThinkingLevels(model!)).toEqual(["medium", "high", "xhigh"]);
|
|
});
|
|
|
|
it("includes only high/xhigh plus off for DeepSeek V4 Flash on the DeepSeek provider", () => {
|
|
const model = getModel("deepseek", "deepseek-v4-flash");
|
|
expect(model).toBeDefined();
|
|
expect(getSupportedThinkingLevels(model!)).toEqual(["off", "high", "xhigh"]);
|
|
});
|
|
|
|
it("includes only high/xhigh plus off for DeepSeek V4 Flash on opencode-go", () => {
|
|
const model = getModel("opencode-go", "deepseek-v4-flash");
|
|
expect(model).toBeDefined();
|
|
expect(getSupportedThinkingLevels(model!)).toEqual(["off", "high", "xhigh"]);
|
|
});
|
|
|
|
it("includes only high plus off for OpenCode Go Kimi K2.6", () => {
|
|
const model = getModel("opencode-go", "kimi-k2.6");
|
|
expect(model).toBeDefined();
|
|
expect(getSupportedThinkingLevels(model!)).toEqual(["off", "high"]);
|
|
});
|
|
|
|
it("includes only high for OpenCode Grok Build", () => {
|
|
const model = getModel("opencode", "grok-build-0.1");
|
|
expect(model).toBeDefined();
|
|
expect(getSupportedThinkingLevels(model!)).toEqual(["high"]);
|
|
});
|
|
|
|
it("includes only high/xhigh plus off for DeepSeek V4 Flash on OpenRouter", () => {
|
|
const model = getModel("openrouter", "deepseek/deepseek-v4-flash");
|
|
expect(model).toBeDefined();
|
|
expect(getSupportedThinkingLevels(model!)).toEqual(["off", "high", "xhigh"]);
|
|
});
|
|
|
|
it("includes xhigh for OpenRouter Opus 4.6 (openai-completions API)", () => {
|
|
const model = getModel("openrouter", "anthropic/claude-opus-4.6");
|
|
expect(model).toBeDefined();
|
|
expect(getSupportedThinkingLevels(model!)).toContain("xhigh");
|
|
});
|
|
|
|
it("includes xhigh but not off for Bedrock Claude Fable 5", () => {
|
|
const model = getModel("amazon-bedrock", "global.anthropic.claude-fable-5");
|
|
expect(model).toBeDefined();
|
|
expect(getSupportedThinkingLevels(model!)).toContain("xhigh");
|
|
expect(getSupportedThinkingLevels(model!)).not.toContain("off");
|
|
});
|
|
});
|