@bitkyc08/opencodex 2.7.23 → 2.7.24-preview.20260718

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.ko.md +37 -7
  2. package/README.md +52 -11
  3. package/README.zh-CN.md +36 -7
  4. package/bin/ocx.mjs +5 -3
  5. package/gui/dist/assets/index-DDs2IUqv.js +40 -0
  6. package/gui/dist/assets/index-Dq3eZ1cU.css +1 -0
  7. package/gui/dist/index.html +2 -2
  8. package/gui/dist/provider-icons/opencode.svg +1 -1
  9. package/package.json +5 -2
  10. package/src/adapters/anthropic-image-normalize.ts +70 -29
  11. package/src/adapters/cursor/transport-retry.ts +20 -1
  12. package/src/adapters/run-turn-queue.ts +40 -0
  13. package/src/codex/auth-api.ts +10 -1
  14. package/src/codex/auth-context.ts +33 -7
  15. package/src/codex/catalog.ts +357 -23
  16. package/src/codex/routing.ts +10 -4
  17. package/src/combos/failover.ts +102 -0
  18. package/src/combos/index.ts +37 -0
  19. package/src/combos/request.ts +31 -0
  20. package/src/combos/resolve.ts +171 -0
  21. package/src/combos/types.ts +203 -0
  22. package/src/config.ts +280 -11
  23. package/src/lib/errors.ts +86 -24
  24. package/src/lib/upstream-retry.ts +8 -4
  25. package/src/oauth/index.ts +7 -1
  26. package/src/oauth/key-providers.ts +2 -32
  27. package/src/oauth/login-cli.ts +4 -3
  28. package/src/oauth/token-guardian.ts +38 -3
  29. package/src/providers/derive.ts +27 -2
  30. package/src/providers/kiro-models.ts +8 -3
  31. package/src/providers/label.ts +3 -1
  32. package/src/providers/openai-sidecar.ts +94 -0
  33. package/src/providers/openai-tier-startup.ts +27 -0
  34. package/src/providers/openai-tiers.ts +283 -0
  35. package/src/providers/openai-virtual-models.ts +82 -0
  36. package/src/providers/quota.ts +344 -24
  37. package/src/providers/registry.ts +112 -20
  38. package/src/reasoning-effort.ts +12 -11
  39. package/src/router.ts +80 -36
  40. package/src/server/auth-cors.ts +85 -9
  41. package/src/server/images.ts +31 -75
  42. package/src/server/index.ts +45 -86
  43. package/src/server/management-api.ts +273 -21
  44. package/src/server/request-log.ts +221 -20
  45. package/src/server/responses.ts +594 -75
  46. package/src/server/search.ts +22 -37
  47. package/src/types.ts +49 -1
  48. package/src/update/index.ts +50 -6
  49. package/src/update/job.ts +21 -4
  50. package/src/usage/log.ts +124 -1
  51. package/src/usage/summary.ts +147 -56
  52. package/src/vision/index.ts +20 -19
  53. package/src/web-search/index.ts +15 -17
  54. package/gui/dist/assets/index-Bk_GgFrh.css +0 -1
  55. package/gui/dist/assets/index-DQjt6Hly.js +0 -40
package/README.ko.md CHANGED
@@ -70,6 +70,7 @@ flowchart LR
70
70
 
71
71
  ```bash
72
72
  # 설치 (Bun 런타임이 자동으로 번들됩니다 — Node 18+ 만 있으면 됩니다)
73
+ # 사용자 소유 Node(nvm/fnm)를 권장합니다 — `sudo npm install -g …`는 피하세요
73
74
  npm install -g @bitkyc08/opencodex
74
75
 
75
76
  # 대화형 설정 (config 작성 + Codex 주입 + 자동 시작 shim 설치 선택)
@@ -86,16 +87,25 @@ codex "Write a hello world in Rust"
86
87
  ```
87
88
 
88
89
  <details>
89
- <summary><b>"bundled Bun runtime is missing" 오류가 나나요?</b></summary>
90
+ <summary><b>"bundled Bun runtime is missing" 오류 / npm이 Bun 설치 스크립트를 차단했나요?</b></summary>
90
91
 
91
92
  <br/>
92
93
 
93
- opencodex는 Bun 런타임을 의존성으로 번들하고 Node 런처로 실행하므로 Bun을 직접 설치할 필요가 **없습니다**. "bundled Bun runtime is missing" 오류가 보이면 설치 과정에서 lifecycle 스크립트나 optional 의존성이 건너뛰어진 경우입니다. 해당 플래그 없이 다시 설치하세요:
94
+ opencodex는 Bun 런타임을 의존성으로 번들하고 Node 런처로 실행하므로 Bun을 직접 설치할 필요가 **없습니다**. "bundled Bun runtime is missing" 오류가 보이면 설치 과정에서 lifecycle 스크립트(npm이 `allowScripts`로 bun postinstall을 차단한 경우 포함)나 optional 의존성이 건너뛰어진 경우입니다. bun 설치 스크립트를 허용해서 다시 설치하세요:
94
95
 
95
96
  ```bash
96
- npm install -g @bitkyc08/opencodex # --ignore-scripts, --omit=optional 없이
97
+ npm install -g --allow-scripts=bun @bitkyc08/opencodex # --ignore-scripts, --omit=optional 없이
98
+
99
+ # 처음에 sudo로 설치했다면 sudo를 유지하세요:
100
+ sudo npm install -g --allow-scripts=bun @bitkyc08/opencodex
97
101
  ```
98
102
 
103
+ npm 경고가 제안하는 축약 명령에는 패키지 이름이 빠져 있어 현재 디렉터리를
104
+ 재설치하게 됩니다. 항상 `@bitkyc08/opencodex`를 명시하세요.
105
+
106
+ sudo로 루트 소유 prefix에 설치했다면 위의 sudo 재설치가 해당 prefix를 풀어주지만,
107
+ 가능할 때 사용자 소유 Node(nvm, fnm, 사용자 npm prefix)로 옮기는 편이 좋습니다.
108
+
99
109
  </details>
100
110
 
101
111
  ## 프로바이더 추가하기
@@ -157,7 +167,27 @@ routing/catalog metadata를 준비해 둡니다.
157
167
  <img src="assets/codex-app-picker.png" alt="opencodex 라우팅 모델을 reasoning effort 선택기와 함께 보여주는 Codex App" width="480">
158
168
  </p>
159
169
 
160
- ## ChatGPT 계정
170
+ ## OpenAI 프로바이더 계정 모드
171
+
172
+ | 프로바이더 ID | 경로 | 자격증명 | 동작 |
173
+ |---|---|---|---|
174
+ | `openai` | Codex 로그인 | 메인 + 추가 Codex 계정 | 기본 Pool, 선택 가능한 Direct 모드 |
175
+ | `openai-apikey` | OpenAI API | API key/key pool | Codex 계정 라우팅 없음 |
176
+
177
+ - Pool은 메인 로그인과 추가 계정을 포함하며 affinity·쿼터·cooldown·failover를 적용합니다.
178
+ - Direct는 풀 상태를 건드리지 않고 현재 caller/메인 로그인 bearer만 사용합니다.
179
+ - 새 설치와 모드가 없는 config는 Pool이 기본입니다. 대시보드 **Providers**에서 모드를 바꿔도
180
+ `gpt-5.6-sol` 같은 bare 모델 id는 그대로입니다.
181
+ - `openai-apikey/gpt-5.6-sol`은 API를 선택하며 Codex 로그인과 API 자격증명 사이에는 fallback이 없습니다.
182
+ - 현재 marker는 `openaiProviderTierVersion: 2`이고 원본은
183
+ `~/.opencodex/config.json.pre-openai-tiers-v2.bak`에 보존됩니다.
184
+ 복원: `cp ~/.opencodex/config.json.pre-openai-tiers-v2.bak ~/.opencodex/config.json`
185
+ - 이전 v1 3-provider config는 단일 `openai` 행으로 자동 이관됩니다.
186
+ - API 티어의 GPT-5.6 metadata는 context 1,050,000 / max input 922,000입니다.
187
+ `gpt-5.6-sol-pro`, `terra-pro`, `luna-pro`는 공개 virtual id를 유지하면서 wire에서는 base id와
188
+ `reasoning.mode: "pro"`로 전송됩니다.
189
+
190
+ ### Pool 계정 동작
161
191
 
162
192
  대시보드의 **Codex Auth**를 열어 풀 계정을 추가하고, 다음 Codex 세션을 어느 계정이 처리할지 고르세요.
163
193
  opencodex는 두 가지 동작을 분리해서 유지합니다:
@@ -178,8 +208,8 @@ opencodex는 두 가지 동작을 분리해서 유지합니다:
178
208
  - **ChatGPT 계정을 안전하게 풀링.** 기존 Codex 스레드는 한 계정에 유지하면서, 새 세션은 쿼터 갱신과 비-PII 요청 라벨과 함께 풀에서 사용량이 낮은 계정을 자동 선택할 수 있습니다.
179
209
  - **한 번 로그인하면 API 키는 생략.** xAI, Anthropic, Kimi는 OAuth를 지원하므로 기존 계정으로 인증할 수 있고 토큰은 자동 갱신됩니다. 또는 `codex login`을 forward 하거나, API 키를 붙여넣거나, `${ENV_VAR}` 참조를 쓸 수 있습니다 — 선택은 자유입니다.
180
210
  - **Codex가 동작하는 모든 곳에서.** Codex CLI, TUI, App, SDK에 자동으로 주입됩니다. 라우팅된 모델이 네이티브 모델처럼 Codex 모델 선택기에 나타납니다.
181
- - **알맞은 모델에 위임.** 대시보드나 config에서 최대 5개의 라우팅/네이티브 모델을 Codex 서브에이전트 선택기에 노출해, 복잡한 작업은 reasoning 모델로, 빠른 작업은 저렴한 모델로 보낼 수 있습니다. v2 멀티에이전트 표면(GPT-5.6 Sol/Terra)에서는 프록시가 간결한 위임 가이드를 주입합니다. 선호 서브에이전트 모델·effort(`injectionModel` / `injectionEffort`), 노출된 모델 로스터와 각 모델이 지원하는 effort 사다리, 그리고 크로스모델 `spawn_agent` 호출이 실제로 먹히게 하는 `fork_turns` 규칙까지. 문구를 직접 쓰고 싶다면 `injectionPrompt`에 `{{model}}` / `{{effort}}` / `{{roster}}` 플레이스홀더를 넣으면 됩니다.
182
- - **프리뷰 게이트된 OpenAI rollout에 대비.** GPT-5.6 Sol/Terra/Luna 항목은 upstream 스펙 그대로(Sol/Terra`ultra`까지, Luna는 `max`까지; 372k usable context) ChatGPT passthrough, OpenAI API key, OpenRouter route에 준비되어 있습니다.
211
+ - **알맞은 모델에 위임.** 대시보드나 config에서 최대 5개의 라우팅/네이티브 모델을 Codex 서브에이전트 선택기에 노출해, 복잡한 작업은 reasoning 모델로, 빠른 작업은 저렴한 모델로 보낼 수 있습니다. v2 멀티에이전트 표면(GPT-5.6 Sol/Terra)에서는 프록시가 간결한 위임 가이드를 주입합니다. 선호 서브에이전트 모델·effort(`injectionModel` / `injectionEffort`), 노출된 모델 로스터와 각 모델이 지원하는 effort 사다리, 그리고 크로스모델 `spawn_agent` 오버라이드를 적용하는 `fork_turns` 규칙까지. 알려진 제한: 네이티브 부모가 라우팅 자식을 스폰하면 작업 본문이 백엔드 암호화 상태로 도착해 유실될 수 있습니다([#92](https://github.com/lidge-jun/opencodex/issues/92)) — 안정적인 크로스 프로바이더 위임에는 v1 표면을 쓰세요. 문구를 직접 쓰고 싶다면 `injectionPrompt`에 `{{model}}` / `{{effort}}` / `{{roster}}` 플레이스홀더를 넣으면 됩니다.
212
+ - **프리뷰 게이트된 OpenAI rollout에 대비.** GPT-5.6 Sol/Terra/Luna effort 사다리를 보존합니다. Direct/Multi는 372k Codex 계약을, OpenAI API OpenRouter 1.05M metadata를 사용합니다.
183
213
  - **어떤 모델에도 초능력을.** OpenAI가 아닌 모델도 ChatGPT 로그인 위에서 도는 `gpt-5.4-mini` sidecar로 실제 웹 검색과 이미지 이해를 사용합니다.
184
214
  - **이미지를 네이티브로 생성.** Codex의 독립형 `image_gen` 도구는 생성할 때 `POST /v1/images/generations`, 편집할 때 `POST /v1/images/edits`를 사용합니다. Responses의 hosted `image_generation` 도구와는 별개입니다.
185
215
  - **무슨 일이 일어나는지 보이게.** 웹 대시보드가 프로바이더, OAuth 상태, 모델 선택, upstream이 보고한 cached/cache-write 토큰 수를 포함한 실시간 요청 로그를 보여줍니다 — 왜 요청이 실패했는지 더는 추측하지 않아도 됩니다.
@@ -285,7 +315,7 @@ opencodex는 `config.json.invalid-<timestamp>`로 백업하고 경고를 출력
285
315
  전체에 적용되는 Codex 노출용 컨텍스트 상한, `modelContextWindows`는 모델별 상한,
286
316
  `modelInputModalities`는 `["text"]`나 `["text", "image"]` 같은 모델별 입력 힌트입니다. 이 값들은 라이브
287
317
  `/models` 메타데이터를 상한으로 제한할 뿐, 더 작은 라이브 컨텍스트를 늘리지는 않습니다. 번들된 GPT-5.6
288
- Sol/Terra/Luna fallback metadata는 OpenAI API key와 OpenRouter catalog 항목에 372,000 토큰 usable
318
+ Sol/Terra/Luna fallback metadata는 OpenAI API key와 OpenRouter catalog 항목에 1,050,000 토큰
289
319
  context window를 사용하며, upstream preview access를 우회하지 않습니다. 전체 필드는 설정 레퍼런스를
290
320
  참고하세요.
291
321
 
package/README.md CHANGED
@@ -70,6 +70,7 @@ Requires [Node](https://nodejs.org) 18+. The Bun runtime is bundled automaticall
70
70
 
71
71
  ```bash
72
72
  # Install (bundles the Bun runtime automatically — only Node 18+ required)
73
+ # Prefer a user-owned Node (nvm/fnm) — avoid `sudo npm install -g …`
73
74
  npm install -g @bitkyc08/opencodex
74
75
 
75
76
  # Interactive setup (writes config, injects into Codex, and offers autostart shim install)
@@ -86,19 +87,31 @@ codex "Write a hello world in Rust"
86
87
  ```
87
88
 
88
89
  <details>
89
- <summary><b>"bundled Bun runtime is missing" error?</b></summary>
90
+ <summary><b>"bundled Bun runtime is missing" / npm blocked Bun install scripts?</b></summary>
90
91
 
91
92
  <br/>
92
93
 
93
94
  opencodex bundles the Bun runtime as a dependency and runs it via a Node
94
95
  launcher, so you do **not** need to install Bun yourself. If you see a
95
96
  "bundled Bun runtime is missing" error, the install skipped lifecycle scripts
96
- or optional dependencies. Reinstall without those flags:
97
+ (including npm blocking bun's postinstall under `allowScripts`) or optional
98
+ dependencies. Reinstall without those flags, allowing bun's install script:
97
99
 
98
100
  ```bash
99
- npm install -g @bitkyc08/opencodex # no --ignore-scripts, no --omit=optional
101
+ npm install -g --allow-scripts=bun @bitkyc08/opencodex # no --ignore-scripts, no --omit=optional
102
+
103
+ # if the original install used sudo, keep using sudo:
104
+ sudo npm install -g --allow-scripts=bun @bitkyc08/opencodex
100
105
  ```
101
106
 
107
+ npm's own warning suggests an abbreviated command without the package name —
108
+ that would reinstall the current directory, so always pass
109
+ `@bitkyc08/opencodex` explicitly.
110
+
111
+ If you installed with `sudo` into a root-owned prefix, the sudo reinstall above
112
+ unblocks that prefix — but prefer migrating to a user-owned Node (nvm, fnm, or
113
+ a user npm prefix) when you can.
114
+
102
115
  </details>
103
116
 
104
117
  ## Add a provider
@@ -158,10 +171,38 @@ routing and catalog metadata for accounts and providers that can serve them.
158
171
  <img src="assets/codex-app-picker.png" alt="Codex App showing opencodex routed models with reasoning effort picker" width="480">
159
172
  </p>
160
173
 
161
- ## ChatGPT account pool
162
-
163
- Open **Codex Auth** in the dashboard to add pool accounts and choose which account should handle the
164
- next Codex session. opencodex keeps two separate behaviors:
174
+ ## OpenAI provider account modes
175
+
176
+ | Provider ID | Route | Credential | Behavior |
177
+ |---|---|---|---|
178
+ | `openai` | Codex login | Main + added Codex accounts | Pool by default; optional Direct mode |
179
+ | `openai-apikey` | OpenAI API | API key/key pool | No Codex account routing |
180
+
181
+ - Pool includes the main Codex login and added accounts, with affinity, quota, cooldown, and failover.
182
+ - Direct short-circuits pool state and uses only the current caller/main-login bearer.
183
+ - Fresh installs and configs with no persisted mode default to Pool. Change the mode on the
184
+ dashboard's **Providers** page; model ids stay bare in either mode.
185
+ - The legacy public provider id `chatgpt` is hidden after migration. The original config is retained
186
+ once at `~/.opencodex/config.json.pre-openai-tiers-v2.bak`; restore it with
187
+ `cp ~/.opencodex/config.json.pre-openai-tiers-v2.bak ~/.opencodex/config.json`.
188
+ - Current configs use `openaiProviderTierVersion: 2`. Earlier v1 three-provider configs migrate
189
+ automatically into the single `openai` row.
190
+ - The API tier includes Pro virtual models (`gpt-5.6-sol-pro`, `gpt-5.6-terra-pro`,
191
+ `gpt-5.6-luna-pro`). At the wire level, each rewrites to its base model with
192
+ `reasoning.mode: "pro"`.
193
+ - Its catalog is fixed to eight ids: `gpt-5.5`, `gpt-5.6`, Sol/Terra/Luna, and the three
194
+ corresponding Pro virtual ids. There is no generic `gpt-5.6-pro` alias.
195
+ - Compact requests keep the selected tier but send the base model without a reasoning object.
196
+ - Official API metadata is 1,050,000 context tokens and 922,000 max input tokens.
197
+
198
+ Use `gpt-5.6-sol` for the configured `openai` account mode and
199
+ `openai-apikey/gpt-5.6-sol` for the API key. Codex-login and API credentials never fall through to
200
+ one another.
201
+
202
+ ### Pool account behavior
203
+
204
+ Open **Codex Auth** in the dashboard to add accounts and choose which account should handle the
205
+ next Codex session. opencodex keeps these behaviors:
165
206
 
166
207
  - **Existing sessions keep affinity.** A thread id is bound to the selected account and reused on
167
208
  later turns, so a long request or a mobile/SSH-attached session keeps using the same account.
@@ -183,8 +224,8 @@ next Codex session. opencodex keeps two separate behaviors:
183
224
  - **Log in once, skip the API key.** OAuth support for xAI, Anthropic, and Kimi means you can authenticate with your existing account. Tokens auto-refresh. Or forward your `codex login`, paste an API key, or use `${ENV_VAR}` references — your call.
184
225
  - **Works everywhere Codex does.** Injects into Codex CLI, TUI, App, and SDK automatically. Routed models show up in Codex's model picker just like native ones.
185
226
  - **History-safe injection.** On local installs the proxy points Codex's own built-in `openai` provider at itself via a single `openai_base_url` line — new threads keep their native provider tag, so ongoing chat history is never remapped and an unclean shutdown can't hide it. (Threads re-tagged by older versions are migrated back once on the first start; remote/LAN binds use a dedicated provider entry instead, since they need an API-key header.)
186
- - **Delegate to the right model.** Feature up to five routed or native models in Codex's subagent picker from the dashboard or config — route complex tasks to a reasoning model, fast tasks to a cheap one. On the v2 multi-agent surface (GPT-5.6 Sol/Terra) the proxy injects compact delegation guidance: a preferred sub-agent model and effort (`injectionModel` / `injectionEffort`), the featured-model roster with the effort ladder each supports, and the `fork_turns` rules that make cross-model `spawn_agent` calls actually stick. Want your own wording? Set `injectionPrompt` with `{{model}}` / `{{effort}}` / `{{roster}}` placeholders.
187
- - **Prepare for preview-gated OpenAI rollouts.** GPT-5.6 Sol/Terra/Luna entries ship with the exact upstream spec (Sol/Terra reach `ultra`, Luna caps at `max`; 372k usable context) for ChatGPT passthrough, OpenAI API key, and OpenRouter routes when upstream access is available.
227
+ - **Delegate to the right model.** Feature up to five routed or native models in Codex's subagent picker from the dashboard or config — route complex tasks to a reasoning model, fast tasks to a cheap one. On the v2 multi-agent surface (GPT-5.6 Sol/Terra) the proxy injects compact delegation guidance: a preferred sub-agent model and effort (`injectionModel` / `injectionEffort`), the featured-model roster with the effort ladder each supports, and the `fork_turns` rules that let cross-model `spawn_agent` calls apply their overrides. Known limitation: when a native parent spawns a routed child, the task body can currently arrive backend-encrypted and be lost ([#92](https://github.com/lidge-jun/opencodex/issues/92)) — use the v1 surface for reliable cross-provider delegation. Want your own wording? Set `injectionPrompt` with `{{model}}` / `{{effort}}` / `{{roster}}` placeholders.
228
+ - **Prepare for preview-gated OpenAI rollouts.** GPT-5.6 Sol/Terra/Luna entries preserve the upstream effort ladders. Direct/Multi use the 372k Codex contract; OpenAI API and OpenRouter use 1.05M metadata when upstream access is available.
188
229
  - **Give any model superpowers.** Non-OpenAI models get real web search and image understanding via a `gpt-5.4-mini` sidecar over your ChatGPT login.
189
230
  - **Generate images natively.** Codex's standalone `image_gen` tool uses `POST /v1/images/generations` for generation and `POST /v1/images/edits` for edits; it is separate from the hosted Responses `image_generation` tool.
190
231
  - **See what's happening.** The web dashboard shows providers, OAuth status, model selection, and a live request log, including cached/cache-write token counts when upstream reports them — no more guessing why a request failed.
@@ -302,8 +343,8 @@ Provider entries can also annotate routed catalog metadata. Use `contextWindow`
302
343
  Codex-visible context cap, `modelContextWindows` for model-specific caps, and
303
344
  `modelInputModalities` for model-specific catalog input hints such as `["text"]` or
304
345
  `["text", "image"]`. Context values cap live `/models` metadata; they never raise a smaller live
305
- context window. The bundled GPT-5.6 Sol/Terra/Luna fallback metadata uses a 372,000-token usable
306
- context window for OpenAI API key and OpenRouter catalog entries; it does not bypass upstream preview
346
+ context window. The bundled GPT-5.6 Sol/Terra/Luna fallback metadata uses a 1,050,000-token context
347
+ window for OpenAI API key and OpenRouter catalog entries; it does not bypass upstream preview
307
348
  access. See the configuration reference for the full field list.
308
349
 
309
350
  > **GLM-5.2 1M context via Z.AI:** through the `openai-chat` adapter, both `glm-5.2`
package/README.zh-CN.md CHANGED
@@ -69,6 +69,7 @@ flowchart LR
69
69
 
70
70
  ```bash
71
71
  # 安装(自动打包 Bun 运行时 —— 只需 Node 18+)
72
+ # 推荐使用用户自有的 Node(nvm/fnm)—— 避免 `sudo npm install -g …`
72
73
  npm install -g @bitkyc08/opencodex
73
74
 
74
75
  # 交互式初始化(写入配置 + 注入 Codex)
@@ -82,16 +83,25 @@ codex "Write a hello world in Rust"
82
83
  ```
83
84
 
84
85
  <details>
85
- <summary><b>遇到 "bundled Bun runtime is missing" 错误?</b></summary>
86
+ <summary><b>遇到 "bundled Bun runtime is missing" 错误 / npm 拦截了 Bun 安装脚本?</b></summary>
86
87
 
87
88
  <br/>
88
89
 
89
- opencodex 把 Bun 运行时作为依赖打包,并通过 Node 启动器运行,所以你**不需要**自己安装 Bun。如果看到 "bundled Bun runtime is missing" 错误,说明安装时跳过了 lifecycle 脚本或 optional 依赖。请不带这些标志重新安装:
90
+ opencodex 把 Bun 运行时作为依赖打包,并通过 Node 启动器运行,所以你**不需要**自己安装 Bun。如果看到 "bundled Bun runtime is missing" 错误,说明安装时跳过了 lifecycle 脚本(包括 npm 通过 `allowScripts` 拦截 bun postinstall 的情况)或 optional 依赖。请允许 bun 安装脚本后重新安装:
90
91
 
91
92
  ```bash
92
- npm install -g @bitkyc08/opencodex # 不要加 --ignore-scripts、--omit=optional
93
+ npm install -g --allow-scripts=bun @bitkyc08/opencodex # 不要加 --ignore-scripts、--omit=optional
94
+
95
+ # 如果最初是用 sudo 安装的,请继续使用 sudo:
96
+ sudo npm install -g --allow-scripts=bun @bitkyc08/opencodex
93
97
  ```
94
98
 
99
+ npm 警告里给出的缩写命令缺少包名,会把当前目录重新安装进去,
100
+ 请始终显式写上 `@bitkyc08/opencodex`。
101
+
102
+ 如果之前用 sudo 安装到了 root 前缀,上面的 sudo 重装可以解除该前缀的拦截 ——
103
+ 但建议在条件允许时迁移到用户自有的 Node(nvm、fnm 或用户 npm prefix)。
104
+
95
105
  </details>
96
106
 
97
107
  ## 亮点
@@ -101,8 +111,8 @@ npm install -g @bitkyc08/opencodex # 不要加 --ignore-scripts、--omit=optio
101
111
  - **安全地池化 ChatGPT 账户。** 现有 Codex 线程保持在一个账户上,而新会话可以从池中自动挑选使用量更低的账户,并带有配额刷新和非 PII 请求标签。
102
112
  - **登录一次,免填 API key。** xAI、Anthropic、Kimi 支持 OAuth,可用现有账户认证,token 自动刷新。也可以转发 `codex login`、粘贴 API key,或使用 `${ENV_VAR}` 引用 —— 随你选择。
103
113
  - **Codex 在哪里能用,它就在哪里能用。** 自动注入 Codex CLI、TUI、App 和 SDK。路由模型像原生模型一样出现在 Codex 的模型选择器里。
104
- - **委派给合适的模型。** 在仪表盘或 config 中把最多 5 个路由/原生模型放进 Codex 的 subagent 选择器 —— 复杂任务交给 reasoning 模型,快速任务交给便宜模型。在 v2 多智能体表面(GPT-5.6 Sol/Terra)上,代理会注入精简的委派指引:首选子智能体模型与 effort(`injectionModel` / `injectionEffort`)、featured 模型清单及各自支持的 effort 阶梯,以及让跨模型 `spawn_agent` 调用真正生效的 `fork_turns` 规则。想自定义文案,可在 `injectionPrompt` 中使用 `{{model}}` / `{{effort}}` / `{{roster}}` 占位符。
105
- - **为 preview-gated OpenAI rollout 做好准备。** GPT-5.6 Sol/Terra/Luna 条目采用与 upstream 完全一致的规格(Sol/Terra `ultra`,Luna 到 `max`;372k 可用上下文),覆盖 ChatGPT passthrough、OpenAI API key OpenRouter 路由。
114
+ - **委派给合适的模型。** 在仪表盘或 config 中把最多 5 个路由/原生模型放进 Codex 的 subagent 选择器 —— 复杂任务交给 reasoning 模型,快速任务交给便宜模型。在 v2 多智能体表面(GPT-5.6 Sol/Terra)上,代理会注入精简的委派指引:首选子智能体模型与 effort(`injectionModel` / `injectionEffort`)、featured 模型清单及各自支持的 effort 阶梯,以及让跨模型 `spawn_agent` 覆盖得以应用的 `fork_turns` 规则。已知限制:原生父代理 spawn 路由子代理时,任务正文可能以后端加密形式到达而丢失([#92](https://github.com/lidge-jun/opencodex/issues/92))—— 需要可靠的跨 provider 委派请使用 v1 表面。想自定义文案,可在 `injectionPrompt` 中使用 `{{model}}` / `{{effort}}` / `{{roster}}` 占位符。
115
+ - **为 preview-gated OpenAI rollout 做好准备。** GPT-5.6 Sol/Terra/Luna 保留 upstream effort 阶梯。Direct/Multi 使用 372k Codex 契约,OpenAI API OpenRouter 使用 1.05M 元数据。
106
116
  - **给任意模型超能力。** 非 OpenAI 模型也能通过你的 ChatGPT 登录上运行的 `gpt-5.4-mini` sidecar 获得真正的网页搜索和图片理解。
107
117
  - **原生生成图片。** Codex 的独立 `image_gen` 工具通过 `POST /v1/images/generations` 生成图片、通过 `POST /v1/images/edits` 编辑图片;它独立于 hosted Responses 的 `image_generation` 工具。
108
118
  - **看清正在发生什么。** Web 仪表盘展示 provider、OAuth 状态、模型选择和实时请求日志;当上游返回时,也会包含 cached/cache-write token 计数 —— 不必再猜测请求为何失败。
@@ -166,7 +176,26 @@ preview gate 限制;opencodex 只是准备好你的账户/provider 可访问
166
176
  <img src="assets/codex-app-picker.png" alt="Codex App 展示 opencodex 路由模型及 reasoning effort 选择器" width="480">
167
177
  </p>
168
178
 
169
- ## ChatGPT 账户池
179
+ ## OpenAI provider 层级
180
+
181
+ | Provider ID | 层级 | 凭证 | 行为 |
182
+ |---|---|---|---|
183
+ | `openai` | Codex Direct | 当前 Codex 主登录 | 单账户,不读取或轮换池 |
184
+ | `openai-multi` | Codex 多账户 | 主账户 + 添加的账户 | affinity、配额、冷却、failover |
185
+ | `openai-apikey` | OpenAI API | API key/key pool | 不进行 Codex 账户路由 |
186
+
187
+ - Codex 主账户始终是 Multi 池的普通成员,不是池外 fallback。
188
+ - 新安装默认使用 Direct(`openai`)。`gpt-5.6-sol` 选择 Direct,
189
+ `openai-multi/gpt-5.6-sol` 选择 Multi,`openai-apikey/gpt-5.6-sol` 选择 API。
190
+ - 三个层级之间不会因凭证缺失而相互 fallback。
191
+ - 升级时,带池账户的旧配置迁移到 Multi;旧的公开 `chatgpt` provider id 会被隐藏。
192
+ 原配置只备份一次到 `~/.opencodex/config.json.pre-openai-tiers-v1.bak`。恢复命令:
193
+ `cp ~/.opencodex/config.json.pre-openai-tiers-v1.bak ~/.opencodex/config.json`
194
+ - API 层 GPT-5.6 元数据为 1,050,000 context / 922,000 max input。
195
+ `gpt-5.6-sol-pro`、`terra-pro`、`luna-pro` 保留公开 virtual id,线上请求改写为 base id 加
196
+ `reasoning.mode: "pro"`。
197
+
198
+ ### 多账户行为
170
199
 
171
200
  打开仪表盘中的 **Codex Auth** 来添加池账户,并选择由哪个账户处理下一个 Codex 会话。
172
201
  opencodex 保持两种独立行为:
@@ -273,7 +302,7 @@ npm uninstall -g @bitkyc08/opencodex
273
302
  provider 条目还可以标注路由目录元数据。`contextWindow` 设置 provider 级别、对 Codex 可见的上下文上限,
274
303
  `modelContextWindows` 设置按模型的上限,`modelInputModalities` 设置按模型的目录输入提示,例如 `["text"]`
275
304
  或 `["text", "image"]`。这些值只会对实时 `/models` 元数据设上限,绝不会抬高更小的实时上下文窗口。内置
276
- GPT-5.6 Sol/Terra/Luna fallback 元数据会为 OpenAI API key 和 OpenRouter 目录条目使用 372,000 token 的
305
+ GPT-5.6 Sol/Terra/Luna fallback 元数据会为 OpenAI API key 和 OpenRouter 目录条目使用 1,050,000 token 的
277
306
  usable context window;它不会绕过上游 preview access。完整字段参阅配置参考。
278
307
 
279
308
  > **通过 Z.AI 使用 GLM-5.2 1M 上下文:** 在 `openai-chat` adapter 下,`glm-5.2` 和 `glm-5.2[1m]` 都可用 ——
package/bin/ocx.mjs CHANGED
@@ -191,9 +191,11 @@ function fail(msg) {
191
191
  console.error(
192
192
  `opencodex: ${msg}\n` +
193
193
  "The bundled Bun runtime could not be prepared. This usually means the\n" +
194
- "install skipped lifecycle scripts or optional dependencies. Reinstall with:\n" +
195
- " npm install -g @bitkyc08/opencodex\n" +
196
- "(without --ignore-scripts and without --omit=optional / optional=false)"
194
+ "install skipped lifecycle scripts (e.g. npm blocked bun's postinstall\n" +
195
+ "under allowScripts) or optional dependencies. Reinstall with:\n" +
196
+ " npm install -g --allow-scripts=bun @bitkyc08/opencodex\n" +
197
+ "(use sudo if the original install used sudo; without --ignore-scripts\n" +
198
+ "and without --omit=optional / optional=false)"
197
199
  );
198
200
  process.exit(1);
199
201
  }