mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-10-25 17:22:27 +08:00
Move first-party, sponsor and relay presets to current model IDs so a pasted Key works without editing the model list. - Claude: opus/sonnet 5 -> 5.5, haiku 4.5 -> 5.5, fable 5 -> 5.1 - GPT: gpt-5.6-sol / gpt-6-sol -> gpt-6.1-sol; add gpt-6-astra/luna - Gemini 3.6 Flash -> 3.8 Flash, 3.1 Pro preview -> 4 Argon; Grok 4.5 -> 4.7; GLM 5.1/5.2 -> 5.3 (+5.3 Flash); DeepSeek V4 Flash -> V4.1 Flash; Doubao 2.1 Pro 260628 -> 260915; StepFun Step Plan -> step-5-preview; add Kimi K3.1 Pro, Qwen3.8 Max, MiniMax M3.1 Flash where the site serves them - Drop retired models: NVIDIA moonshotai/kimi-k3 (EOL 2026-10-15, now kimi-k2.6 without unverified Codex reasoning levels), MiMo V2.5 / V2.5 Pro, Claude Sonnet 4.5, MiniMax M2.7 on Tencent Token Plan Enterprise Pro - Relay presets follow each site's own ID spelling and catalog; DIT.ai, BuyToken and hao.ai are left as configured from their docs; Soshow, SiliconFlow CN, OpenCode Zen and the Ark rolling alias stay - MoArk Codex keeps the tested Kimi-K2.7-Code; K3.1 Pro and Qwen3.8 Max stay out of its Codex catalog until their levels are verified Tests updated to the new IDs; cross-app invariants unchanged.
97 lines
3.3 KiB
TypeScript
97 lines
3.3 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { codexProviderPresets } from "@/config/codexProviderPresets";
|
|
import { providerPresets } from "@/config/claudeProviderPresets";
|
|
import type { Provider } from "@/types";
|
|
import { providerNeedsRouting } from "@/utils/providerCapabilities";
|
|
|
|
const CODEX_BASE_URL = "https://api.commandcode.ai/provider/v1";
|
|
const CLAUDE_BASE_URL = "https://api.commandcode.ai/provider";
|
|
|
|
function asProvider(
|
|
id: string,
|
|
settingsConfig: Record<string, unknown>,
|
|
apiFormat?: string,
|
|
): Provider {
|
|
return {
|
|
id,
|
|
name: "Command Code",
|
|
category: "third_party",
|
|
settingsConfig,
|
|
meta: apiFormat ? { apiFormat } : undefined,
|
|
} as Provider;
|
|
}
|
|
|
|
describe("Command Code provider presets", () => {
|
|
it("adds the Codex preset with a native Responses non-Claude catalog", () => {
|
|
const preset = codexProviderPresets.find(
|
|
(item) => item.name === "Command Code",
|
|
);
|
|
|
|
expect(preset).toBeDefined();
|
|
expect(preset?.apiFormat).toBe("openai_responses");
|
|
expect(preset?.endpointCandidates).toEqual([CODEX_BASE_URL]);
|
|
expect(preset?.config).toContain(`base_url = "${CODEX_BASE_URL}"`);
|
|
expect(preset?.config).toContain('model = "deepseek/deepseek-v4.1-flash"');
|
|
expect(preset?.config).toContain('wire_api = "responses"');
|
|
expect(preset?.modelCatalog?.map((model) => model.model)).toEqual([
|
|
"deepseek/deepseek-v4.1-flash",
|
|
"z-ai/glm-5.3-flash",
|
|
"Qwen/Qwen3.8-Flash",
|
|
"moonshotai/Kimi-K3.1-Pro",
|
|
"zai-org/GLM-5.3",
|
|
]);
|
|
expect(
|
|
preset?.modelCatalog?.some((model) => model.model.includes("claude")),
|
|
).toBe(false);
|
|
});
|
|
|
|
it("connects the Codex preset directly through Responses", () => {
|
|
const preset = codexProviderPresets.find(
|
|
(item) => item.name === "Command Code",
|
|
);
|
|
const provider = asProvider(
|
|
"command-code",
|
|
{
|
|
auth: { OPENAI_API_KEY: "" },
|
|
config: preset?.config ?? "",
|
|
},
|
|
preset?.apiFormat,
|
|
);
|
|
|
|
expect(preset?.apiFormat).toBe("openai_responses");
|
|
expect(providerNeedsRouting("codex", provider)).toBe(false);
|
|
});
|
|
|
|
it("adds the Claude Code Anthropic preset with role model mapping", () => {
|
|
const preset = providerPresets.find((item) => item.name === "Command Code");
|
|
const env = (preset?.settingsConfig as { env?: Record<string, string> })
|
|
?.env;
|
|
|
|
expect(preset).toBeDefined();
|
|
expect(env).toMatchObject({
|
|
ANTHROPIC_BASE_URL: CLAUDE_BASE_URL,
|
|
ANTHROPIC_AUTH_TOKEN: "",
|
|
ANTHROPIC_MODEL: "deepseek/deepseek-v4.1-flash[1M]",
|
|
ANTHROPIC_DEFAULT_HAIKU_MODEL: "deepseek/deepseek-v4.1-flash[1M]",
|
|
ANTHROPIC_DEFAULT_SONNET_MODEL: "deepseek/deepseek-v4.1-flash[1M]",
|
|
ANTHROPIC_DEFAULT_OPUS_MODEL: "deepseek/deepseek-v4.1-flash[1M]",
|
|
});
|
|
expect(preset?.apiFormat).toBe("openai_chat");
|
|
expect(preset?.modelsUrl).toBe(
|
|
"https://api.commandcode.ai/provider/v1/models",
|
|
);
|
|
expect(preset?.apiKeyField).toBeUndefined();
|
|
});
|
|
|
|
it("routes Claude Code through Chat Completions for open models", () => {
|
|
const preset = providerPresets.find((item) => item.name === "Command Code");
|
|
const provider = asProvider(
|
|
"command-code",
|
|
preset?.settingsConfig as Record<string, unknown>,
|
|
preset?.apiFormat,
|
|
);
|
|
|
|
expect(providerNeedsRouting("claude", provider)).toBe(true);
|
|
});
|
|
});
|