Anthropic now blocks third-party apps from using Pro/Max subscription quotas via direct API calls. This change makes the claude-code provider (which delegates to the local claude CLI binary) the default path for Anthropic subscription users — TOS-compliant because requests flow through Anthropic's own infrastructure. Changes: - Enhanced readiness check to verify CLI auth status (not just binary) - Startup migration: auto-switch anthropic → claude-code when CLI ready - Error recovery: auto-switch on third-party 400 block error - Onboarding: removed Anthropic from OAuth, added Claude CLI option - Added claude-code to flat-rate providers (no dynamic routing benefit) Closes #3772
37 lines
1 KiB
TypeScript
37 lines
1 KiB
TypeScript
// GSD2 — Claude CLI binary detection for onboarding
|
|
// Lightweight check used at onboarding time (before extensions load).
|
|
// The full readiness check with caching lives in the claude-code-cli extension.
|
|
|
|
import { execFileSync } from 'node:child_process'
|
|
|
|
/**
|
|
* Check if the `claude` binary is installed (regardless of auth state).
|
|
*/
|
|
export function isClaudeBinaryInstalled(): boolean {
|
|
try {
|
|
execFileSync('claude', ['--version'], { timeout: 5_000, stdio: 'pipe' })
|
|
return true
|
|
} catch {
|
|
return false
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Check if the `claude` CLI is installed AND authenticated.
|
|
*/
|
|
export function isClaudeCliReady(): boolean {
|
|
try {
|
|
execFileSync('claude', ['--version'], { timeout: 5_000, stdio: 'pipe' })
|
|
} catch {
|
|
return false
|
|
}
|
|
|
|
try {
|
|
const output = execFileSync('claude', ['auth', 'status'], { timeout: 5_000, stdio: 'pipe' })
|
|
.toString()
|
|
.toLowerCase()
|
|
return !(/not logged in|no credentials|unauthenticated|not authenticated/i.test(output))
|
|
} catch {
|
|
return false
|
|
}
|
|
}
|