From 48a19b8a0df42ae1060247043baaf295dc470171 Mon Sep 17 00:00:00 2001 From: Cepvor <154242055+Evsdrg@users.noreply.github.com> Date: Sun, 17 May 2026 07:29:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20isUsing3PServices=20=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E6=89=80=E6=9C=89=E9=9D=9E=20Anthropic=20provider=20(#1235)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原实现仅检查 Bedrock/Vertex/Foundry,遗漏了 OpenAI、Gemini、Grok 三个通过 CLAUDE_CODE_USE_* 环境变量切换的第三方 provider。 这导致: - 命令可用性判定中 OpenAI/Gemini/Grok 用户被错误识别为 console 用户 (/fast、/install-github-app 两个 Anthropic 专有命令误显示) - auth status 显示中这些用户被误报为"未登录" Co-authored-by: deepseek-v4-pro[1m] --- src/utils/auth.ts | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/utils/auth.ts b/src/utils/auth.ts index 9473b0d6b..a7b744373 100644 --- a/src/utils/auth.ts +++ b/src/utils/auth.ts @@ -1724,12 +1724,29 @@ export function getSubscriptionName(): string { } } -/** Check if using third-party services (Bedrock or Vertex or Foundry) */ +/** + * Check if using third-party services (non-Anthropic providers). + * + * This function gates several behaviours that should only apply when the user + * is NOT calling the first-party Anthropic API directly: + * - auth status display (authStatus handler) + * - command visibility (login/logout shown for non-3P) + * - command availability checks (meetsAvailabilityRequirement) + * + * KEEP IN SYNC with providers.ts — when a new CLAUDE_CODE_USE_* env var is + * added to getAPIProvider(), the corresponding check MUST be added here. + * Providers whose selection is controlled purely via settings.modelType + * (rather than env vars) are NOT covered by this function and may need + * separate handling in the call sites above. + */ export function isUsing3PServices(): boolean { return !!( isEnvTruthy(process.env.CLAUDE_CODE_USE_BEDROCK) || isEnvTruthy(process.env.CLAUDE_CODE_USE_VERTEX) || - isEnvTruthy(process.env.CLAUDE_CODE_USE_FOUNDRY) + isEnvTruthy(process.env.CLAUDE_CODE_USE_FOUNDRY) || + isEnvTruthy(process.env.CLAUDE_CODE_USE_OPENAI) || + isEnvTruthy(process.env.CLAUDE_CODE_USE_GEMINI) || + isEnvTruthy(process.env.CLAUDE_CODE_USE_GROK) ) }