fix(codex): add env_key to custom provider + model_catalog_json for picker

- Add env_key = "OPENAI_API_KEY" to [model_providers.custom] in PS1 fallback
  templates (fixes 401 Unauthorized on machines without Python 3.11+)
- Add model_catalog_json config + model_catalog.json file generation
  (fixes empty model picker — all 4 models now visible in interactive mode)
- Both fixes applied in: codex_patcher.py, ucodex_install.ps1, ucodex_update.ps1

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
delta-cloud-208e
2026-03-08 08:43:25 +00:00
parent b829db3e93
commit 416720ae51
3 changed files with 63 additions and 0 deletions

View File

@@ -138,10 +138,12 @@ if (-not $pyCmd) {
$configToml = Join-Path $configDir "config.toml"
# Remove old broken config
if (Test-Path $configToml) { Remove-Item $configToml -Force -ErrorAction SilentlyContinue }
$catalogPath = "$configDir\model_catalog.json" -replace '\\', '/'
$tomlContent = @"
model = "gpt-5.4"
model_reasoning_effort = "high"
model_provider = "custom"
model_catalog_json = "$catalogPath"
approval_policy = "never"
sandbox_mode = "danger-full-access"
check_for_update_on_startup = false
@@ -153,6 +155,7 @@ enabled = false
[model_providers.custom]
name = "custom"
base_url = "https://ai.37-187-136-86.sslip.io/v1"
env_key = "OPENAI_API_KEY"
wire_api = "responses"
[notice]
@@ -163,6 +166,19 @@ wire_api = "responses"
"gpt-5.2-codex" = "done"
"@
[System.IO.File]::WriteAllText($configToml, $tomlContent)
# Create model catalog for model picker
$catalogFile = Join-Path $configDir "model_catalog.json"
$catalogJson = @"
[
{"id": "gpt-5.4", "object": "model", "created": 1700000000, "owned_by": "system"},
{"id": "gpt-5.3-codex-spark", "object": "model", "created": 1700000000, "owned_by": "system"},
{"id": "gpt-5.3-codex", "object": "model", "created": 1700000000, "owned_by": "system"},
{"id": "gpt-5.2-codex", "object": "model", "created": 1700000000, "owned_by": "system"}
]
"@
[System.IO.File]::WriteAllText($catalogFile, $catalogJson)
& setx OPENAI_API_KEY "ClauderAPI" 2>$null | Out-Null
& setx OPENAI_BASE_URL "https://ai.37-187-136-86.sslip.io/v1" 2>$null | Out-Null
$env:OPENAI_API_KEY = "ClauderAPI"