fix(installer-ps1): drop ANTHROPIC_API_KEY + dynamic models fetch

Auth conflict warning fix: setting both ANTHROPIC_AUTH_TOKEN and
ANTHROPIC_API_KEY simultaneously triggers Anthropic CLI to print
"Auth conflict" on every claude invocation. Drop API_KEY (we never
needed both — AUTH_TOKEN is the canonical for our proxy).

Best-effort cleanup: clear stale ANTHROPIC_API_KEY from User env (set
by previous installer versions).

Models stale fix: hardcoded list (qwen3-coder-plus, gemini-3.1-pro-preview,
glm-5, glm-4.7 etc.) was missing latest gemini-3.1-pro, gemini-3-flash,
glm-5.1. Now fetches CLAUDE_CUSTOM_MODELS from the private config repo
(unlimitedcoding-config/patcher.config.json) at install time, with
fallback to a small known-good list if fetch fails.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
delta-cloud-208e
2026-04-25 05:46:48 +00:00
parent 4b70384863
commit 136f60351c

View File

@@ -138,13 +138,32 @@ if (-not (Test-Command "claude")) {
Write-Host " Setting environment variables..." -ForegroundColor Cyan
# Fetch the latest models list from the private config repo so the installer
# always reflects the current CLAUDE_CUSTOM_MODELS roster (was hardcoded —
# stale within a week of any model rotation).
$configToken = "cadffcb0a6a3be728ac1ff619bb40c86588f6837"
$configUrl = "https://git.sensey24.ru/aibot777/unlimitedcoding-config/raw/branch/main/patcher.config.json"
$customModels = "claude-opus-4-7,claude-sonnet-4-6,gpt-5.4,gpt-5.3-codex,glm-5.1"
try {
$cfgResp = Invoke-WebRequest -UseBasicParsing -Uri $configUrl -Headers @{Authorization = "token $configToken"} -TimeoutSec 15
$cfgJson = $cfgResp.Content | ConvertFrom-Json
if ($cfgJson.models) {
$customModels = ($cfgJson.models -join ",")
Write-Host " Models list fetched from config repo ($($cfgJson.models.Count) models)" -ForegroundColor Green
}
} catch {
Write-Host " Could not fetch latest models — using fallback list" -ForegroundColor Yellow
}
# IMPORTANT: only ANTHROPIC_AUTH_TOKEN is set. Setting both AUTH_TOKEN and
# API_KEY simultaneously triggers Anthropic CLI's "Auth conflict" warning
# on every `claude` invocation.
$envVars = @{
"ANTHROPIC_API_KEY" = "ClauderAPI2"
"ANTHROPIC_AUTH_TOKEN" = "ClauderAPI2"
"ANTHROPIC_BASE_URL" = "https://ai.37-187-136-86.sslip.io"
"ANTHROPIC_DEFAULT_OPUS_MODEL" = "claude-opus-4-7"
"ANTHROPIC_DEFAULT_SONNET_MODEL" = "claude-sonnet-4-6"
"CLAUDE_CUSTOM_MODELS" = "claude-opus-4-7,claude-opus-4-6,claude-sonnet-4-6,gpt-5.4,gpt-5.3-codex,gpt-5.2-codex,claude-opus-4-5-20251101,claude-sonnet-4-5-20250929,gemini-3.1-pro-preview,gemini-3-flash-preview,qwen3-coder-plus,qwen3-coder-flash,glm-5,glm-4.7"
"CLAUDE_CUSTOM_MODELS" = $customModels
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC" = "1"
"CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY" = "1"
"DISABLE_TELEMETRY" = "1"
@@ -153,11 +172,16 @@ $envVars = @{
"CLAUDE_CODE_EFFORT_LEVEL" = "high"
}
# Best-effort: clear stale ANTHROPIC_API_KEY from previous installs that
# set both env vars (user may have run an older installer that did so).
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_API_KEY", $null, "User")
Remove-Item -Path "Env:\ANTHROPIC_API_KEY" -ErrorAction SilentlyContinue
foreach ($k in $envVars.Keys) {
[System.Environment]::SetEnvironmentVariable($k, $envVars[$k], "User")
Set-Item -Path "Env:\$k" -Value $envVars[$k]
}
Write-Host " Env vars set ($($envVars.Count) variables)" -ForegroundColor Green
Write-Host " Env vars set ($($envVars.Count) variables, ANTHROPIC_API_KEY cleared)" -ForegroundColor Green
# ---- Configure settings ----