2.9 KiB
2.9 KiB
build.md
环境要求
- Windows 需要 PowerShell 5.1+ 或 PowerShell 7+
- macOS / Linux 需要
bash - Node.js 18+
直接运行网关
node .\gateway.mjs --config .\config.example.json
推荐用法
Windows:
powershell -ExecutionPolicy Bypass -File .\scripts\launch-ui.ps1
macOS / Linux:
bash ./scripts/launch-ui.sh
说明:
- 第一次运行会自动安装并接管当前 Codex provider
- 再次运行会自动拉起或重启 gateway,并重新打开 UI
- 不依赖
cc-switch安装本体,也不依赖cc-switch路由模式 - macOS / Linux 入口依赖
bash和Node.js 18+ - 推荐显式使用
bash ...sh,避免跨平台复制后可执行位丢失
只启动不自动开浏览器
powershell -ExecutionPolicy Bypass -File .\scripts\launch-ui.ps1 -NoOpen
bash ./scripts/launch-ui.sh --no-open
手工安装入口
Windows:
powershell -ExecutionPolicy Bypass -File .\scripts\install-for-current-provider.ps1
macOS / Linux:
bash ./scripts/install-for-current-provider.sh
恢复原配置
Windows:
powershell -ExecutionPolicy Bypass -File .\scripts\restore-codex-config.ps1
macOS / Linux:
bash ./scripts/restore-codex-config.sh
打开管理页面
http://127.0.0.1:4610/__codex_retry_gateway/ui
页面支持:
- 查看当前接管状态
- 查看跨重启保留的请求累计统计,以及当前进程的实时日志
- 查看
516命中次数与516占比 - 热更新
reasoning_equals/endpoints/non_stream_status_code/log_match - 一键恢复 Codex 原设置并关闭 gateway
本地验证
powershell -ExecutionPolicy Bypass -File .\scripts\test-launch-ui.ps1
powershell -ExecutionPolicy Bypass -File .\scripts\test-launch-ui-unix.ps1
powershell -ExecutionPolicy Bypass -File .\scripts\test-gateway-e2e.ps1
powershell -ExecutionPolicy Bypass -File .\scripts\test-install-restore.ps1
本机真实验证命令
Invoke-WebRequest -UseBasicParsing 'http://127.0.0.1:4610/__codex_retry_gateway/health'
Invoke-WebRequest -UseBasicParsing 'http://127.0.0.1:4610/__codex_retry_gateway/ui'
powershell -ExecutionPolicy Bypass -File .\scripts\launch-ui.ps1 -NoOpen
$auth = Get-Content -Raw (Join-Path $env:USERPROFILE '.codex\auth.json') | ConvertFrom-Json
$headers = @{ Authorization = "Bearer $($auth.OPENAI_API_KEY)" }
Invoke-WebRequest -UseBasicParsing 'http://127.0.0.1:4610/v1/models' -Headers $headers
codex exec --ephemeral --skip-git-repo-check --color never --dangerously-bypass-approvals-and-sandbox -m gpt-5.4-mini -C $env:TEMP --output-last-message (Join-Path $env:TEMP 'codex-retry-gateway-clean-smoke.txt') '只回复OK'
bash ./scripts/launch-ui.sh --no-open