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.
118 lines
4.1 KiB
TypeScript
118 lines
4.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { claudeDesktopProviderPresets } from "@/config/claudeDesktopProviderPresets";
|
|
import { providerPresets } from "@/config/claudeProviderPresets";
|
|
import { codexProviderPresets } from "@/config/codexProviderPresets";
|
|
import {
|
|
extractCodexBaseUrl,
|
|
extractCodexModelName,
|
|
extractCodexWireApi,
|
|
} from "@/utils/providerConfigUtils";
|
|
|
|
describe("xAI OAuth provider presets", () => {
|
|
it("pins the Claude Code preset to managed Responses auth", () => {
|
|
const preset = providerPresets.find((entry) => entry.name === "xAI (Grok)");
|
|
expect(preset).toBeDefined();
|
|
expect(preset).toMatchObject({
|
|
category: "third_party",
|
|
apiFormat: "openai_responses",
|
|
providerType: "xai_oauth",
|
|
requiresOAuth: true,
|
|
icon: "xai",
|
|
});
|
|
expect((preset!.settingsConfig as any).env).toMatchObject({
|
|
ANTHROPIC_BASE_URL: "https://api.x.ai/v1",
|
|
ANTHROPIC_MODEL: "grok-4.7",
|
|
ANTHROPIC_DEFAULT_HAIKU_MODEL: "grok-4.7",
|
|
ANTHROPIC_DEFAULT_SONNET_MODEL: "grok-4.7",
|
|
ANTHROPIC_DEFAULT_OPUS_MODEL: "grok-4.7",
|
|
});
|
|
expect((preset!.settingsConfig as any).env).not.toHaveProperty(
|
|
"ANTHROPIC_API_KEY",
|
|
);
|
|
expect((preset!.settingsConfig as any).env).not.toHaveProperty(
|
|
"ANTHROPIC_AUTH_TOKEN",
|
|
);
|
|
});
|
|
|
|
it("pins the Claude Desktop preset to proxy Responses mode without 1M", () => {
|
|
const preset = claudeDesktopProviderPresets.find(
|
|
(entry) => entry.name === "xAI (Grok)",
|
|
);
|
|
expect(preset).toMatchObject({
|
|
category: "third_party",
|
|
baseUrl: "https://api.x.ai/v1",
|
|
mode: "proxy",
|
|
apiFormat: "openai_responses",
|
|
providerType: "xai_oauth",
|
|
requiresOAuth: true,
|
|
icon: "xai",
|
|
});
|
|
expect(preset!.modelRoutes).toEqual([
|
|
expect.objectContaining({
|
|
upstreamModel: "grok-4.7",
|
|
supports1m: false,
|
|
}),
|
|
]);
|
|
});
|
|
|
|
it("pins the Codex preset to native Responses via API key (no managed OAuth)", () => {
|
|
const preset = codexProviderPresets.find(
|
|
(entry) => entry.name === "xAI (Grok)",
|
|
);
|
|
expect(preset).toBeDefined();
|
|
expect(preset).toMatchObject({
|
|
category: "third_party",
|
|
apiFormat: "openai_responses",
|
|
icon: "xai",
|
|
});
|
|
// API-key preset: managed-account OAuth is Claude-side only for now.
|
|
expect(preset).not.toHaveProperty("providerType");
|
|
expect(preset!.auth).toEqual({ OPENAI_API_KEY: "" });
|
|
expect(extractCodexBaseUrl(preset!.config)).toBe("https://api.x.ai/v1");
|
|
expect(extractCodexWireApi(preset!.config)).toBe("responses");
|
|
expect(extractCodexModelName(preset!.config)).toBe("grok-4.5");
|
|
expect(preset!.modelCatalog).toEqual([
|
|
expect.objectContaining({
|
|
model: "grok-4.7",
|
|
contextWindow: 500000,
|
|
inputModalities: ["text", "image"],
|
|
supportsParallelToolCalls: true,
|
|
}),
|
|
expect.objectContaining({
|
|
model: "grok-4.5",
|
|
contextWindow: 500000,
|
|
supportsParallelToolCalls: true,
|
|
inputModalities: ["text", "image"],
|
|
}),
|
|
]);
|
|
});
|
|
|
|
it("pins the Codex OAuth preset to managed native Responses", () => {
|
|
const preset = codexProviderPresets.find(
|
|
(entry) => entry.name === "xAI (Grok) OAuth",
|
|
);
|
|
expect(preset).toBeDefined();
|
|
expect(preset).toMatchObject({
|
|
category: "third_party",
|
|
apiFormat: "openai_responses",
|
|
providerType: "xai_oauth",
|
|
requiresOAuth: true,
|
|
icon: "xai",
|
|
});
|
|
// Managed OAuth: auth.json keeps an empty key; the forwarder injects the
|
|
// real access token per request and the adapter pins the base URL.
|
|
expect(preset!.auth).toEqual({ OPENAI_API_KEY: "" });
|
|
expect(extractCodexBaseUrl(preset!.config)).toBe("https://api.x.ai/v1");
|
|
expect(extractCodexWireApi(preset!.config)).toBe("responses");
|
|
expect(extractCodexModelName(preset!.config)).toBe("grok-4.5");
|
|
expect(preset!.modelCatalog).toEqual([
|
|
expect.objectContaining({
|
|
model: "grok-4.5",
|
|
contextWindow: 500000,
|
|
supportsParallelToolCalls: true,
|
|
inputModalities: ["text", "image"],
|
|
}),
|
|
]);
|
|
});
|
|
});
|