mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-08-04 11:43:57 +08:00
fix(proxy): improve GitHub Copilot compatibility with modern Claude Code (#5832)
* 修复 Copilot 与新版 Claude Code 的兼容问题 * docs(proxy): correct Copilot placeholder rationale to the real mechanism Claude Code (verified on 2.1.220) does not format-validate ANTHROPIC_API_KEY against sk-ant-*: in headless mode the placeholder is sent upstream as-is. The actual failure mode is the interactive custom-API-key approval prompt, which defaults to "No (recommended)" — following the default ignores the key and lands users in "Not logged in". Also drop the #3289 citation, which describes a missing-placeholder scenario, not key validation. --------- Co-authored-by: Jason <farion1231@gmail.com>
This commit is contained in:
@@ -87,6 +87,17 @@ impl Provider {
|
||||
|| self.claude_base_url_contains("chatgpt.com/backend-api/codex")
|
||||
}
|
||||
|
||||
/// Whether the provider form's "auth field" was explicitly set to
|
||||
/// ANTHROPIC_API_KEY. The form only persists `meta.apiKeyField` for the
|
||||
/// non-default choice, so `None` means the default ANTHROPIC_AUTH_TOKEN.
|
||||
pub fn claude_uses_api_key_field(&self) -> bool {
|
||||
self.meta
|
||||
.as_ref()
|
||||
.and_then(|m| m.api_key_field.as_deref())
|
||||
.map(|field| field.eq_ignore_ascii_case("ANTHROPIC_API_KEY"))
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
fn provider_type(&self) -> Option<&str> {
|
||||
self.meta.as_ref().and_then(|m| m.provider_type.as_deref())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user