fix(copilot): resolve Claude model IDs against live /models list

Copilot upstream returns model_not_supported when the client sends
dash-form Claude IDs (claude-sonnet-4-6, claude-sonnet-4-6[1m]) while
/models only accepts dot form (claude-sonnet-4.6, -1m suffix).

- Add copilot_model_map: syntax normalize (dash->dot, [1m]->-1m) plus
  live /models exact match and family-version fallback, reusing the
  existing 5 min auth cache. Returns None when the whole family is
  absent so upstream surfaces an explicit error instead of silently
  switching families.
- Wire into forwarder Copilot hook; runs before anthropic_to_openai
  conversion.
- Default Opus slot in the Copilot preset maps to Sonnet 4.6: Pro
  dropped all Opus on 2026-04-20 and Pro+ bills Opus 4.7 at 7.5x.
  Users who want real Opus can switch manually in the UI.

Refs: https://github.com/farion1231/cc-switch/issues/2016
This commit is contained in:
Jason
2026-04-24 22:58:58 +08:00
parent c002688a84
commit fcd83ee30d
4 changed files with 427 additions and 2 deletions
+2 -2
View File
@@ -809,10 +809,10 @@ export const providerPresets: ProviderPreset[] = [
settingsConfig: {
env: {
ANTHROPIC_BASE_URL: "https://api.githubcopilot.com",
ANTHROPIC_MODEL: "claude-opus-4.7",
ANTHROPIC_MODEL: "claude-sonnet-4.6",
ANTHROPIC_DEFAULT_HAIKU_MODEL: "claude-haiku-4.5",
ANTHROPIC_DEFAULT_SONNET_MODEL: "claude-sonnet-4.6",
ANTHROPIC_DEFAULT_OPUS_MODEL: "claude-opus-4.7",
ANTHROPIC_DEFAULT_OPUS_MODEL: "claude-sonnet-4.6",
},
},
category: "third_party",