@bitkyc08/opencodex 2.10.2 → 2.11.0-preview.20260808

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 (121) hide show
  1. package/README.md +31 -0
  2. package/bin/ocx.mjs +10 -0
  3. package/gui/dist/assets/index-B1P60C4o.js +70 -0
  4. package/gui/dist/assets/index-Bk-PN-70.css +1 -0
  5. package/gui/dist/index.html +2 -2
  6. package/package.json +4 -2
  7. package/src/adapters/cursor/effort-map.ts +11 -0
  8. package/src/adapters/cursor/live-transport.ts +11 -0
  9. package/src/adapters/cursor/native-exec-fs.ts +9 -6
  10. package/src/adapters/cursor/native-exec.ts +4 -2
  11. package/src/adapters/cursor/protobuf-events.ts +176 -4
  12. package/src/adapters/cursor/request-builder.ts +15 -4
  13. package/src/adapters/cursor/tool-definitions.ts +118 -2
  14. package/src/adapters/google.ts +15 -5
  15. package/src/adapters/openai-chat.ts +24 -2
  16. package/src/adapters/openai-responses.ts +2 -1
  17. package/src/bridge.ts +9 -5
  18. package/src/chat/outbound.ts +4 -3
  19. package/src/claude/desktop-3p.ts +222 -2
  20. package/src/claude/outbound.ts +15 -6
  21. package/src/cli/account-api.ts +4 -0
  22. package/src/cli/account-extended.ts +112 -0
  23. package/src/cli/account.ts +23 -6
  24. package/src/cli/claude-desktop.ts +26 -3
  25. package/src/cli/config-command.ts +9 -0
  26. package/src/cli/help.ts +18 -2
  27. package/src/cli/index.ts +277 -55
  28. package/src/cli/models.ts +5 -1
  29. package/src/cli/provider.ts +8 -2
  30. package/src/cli/ready.ts +301 -0
  31. package/src/cli/system-restart-client.ts +146 -0
  32. package/src/cli/tray-proxy.ts +153 -6
  33. package/src/clients/config-export.ts +12 -19
  34. package/src/codex/account-lifecycle.ts +3 -0
  35. package/src/codex/account-namespaces.ts +49 -3
  36. package/src/codex/account-priority.ts +83 -0
  37. package/src/codex/auth-api.ts +83 -0
  38. package/src/codex/auth-context.ts +5 -2
  39. package/src/codex/catalog/provider-fetch.ts +11 -0
  40. package/src/codex/catalog/sync.ts +23 -1
  41. package/src/codex/codex-write-lock.ts +16 -4
  42. package/src/codex/desired-state.ts +37 -4
  43. package/src/codex/history-job.ts +15 -5
  44. package/src/codex/history-provider.ts +31 -14
  45. package/src/codex/history-worker.ts +28 -4
  46. package/src/codex/inject-coordination.ts +13 -1
  47. package/src/codex/inject.ts +360 -66
  48. package/src/codex/internal/history-writer.ts +1 -1
  49. package/src/codex/native-main-lock-file.ts +5 -1
  50. package/src/codex/native-main-owner.ts +17 -3
  51. package/src/codex/native-profile-manager.ts +19 -0
  52. package/src/codex/native-profile-startup.ts +8 -0
  53. package/src/codex/native-residue.ts +140 -27
  54. package/src/codex/pool-rotation.ts +74 -4
  55. package/src/codex/refresh.ts +7 -0
  56. package/src/codex/routing.ts +177 -36
  57. package/src/codex/subagent-model-fallback.ts +34 -4
  58. package/src/codex/sync.ts +61 -0
  59. package/src/codex/upstream-host-health.ts +329 -31
  60. package/src/combos/request.ts +2 -0
  61. package/src/config.ts +221 -2
  62. package/src/images/loop.ts +1 -1
  63. package/src/integrations/native/ownership-preflight.ts +39 -2
  64. package/src/lib/bun-stream-caps.ts +3 -3
  65. package/src/lib/sse-decoder.ts +41 -0
  66. package/src/lib/system-restart-contract.ts +73 -0
  67. package/src/lib/windows-secret-acl.ts +141 -39
  68. package/src/lib/windows-user-principal.ts +283 -0
  69. package/src/lib/winsw.ts +18 -2
  70. package/src/oauth/key-providers.ts +12 -0
  71. package/src/providers/derive.ts +54 -2
  72. package/src/providers/free-directory.ts +6 -5
  73. package/src/providers/model-discovery.ts +9 -3
  74. package/src/providers/quota.ts +592 -0
  75. package/src/providers/registry.ts +316 -13
  76. package/src/responses/parser.ts +26 -10
  77. package/src/responses/reasoning-replay-cache.ts +1 -0
  78. package/src/routing/profile-namespace.ts +15 -0
  79. package/src/routing/profile.ts +2 -1
  80. package/src/server/auth-cors.ts +44 -13
  81. package/src/server/chat-completions.ts +0 -4
  82. package/src/server/claude-messages.ts +73 -15
  83. package/src/server/github-copilot-responses-repair.ts +338 -0
  84. package/src/server/index.ts +328 -111
  85. package/src/server/lifecycle.ts +36 -0
  86. package/src/server/management/agent-settings-routes.ts +147 -56
  87. package/src/server/management/config-routes.ts +7 -2
  88. package/src/server/management/context.ts +4 -0
  89. package/src/server/management/native-integration-routes.ts +199 -20
  90. package/src/server/management/provider-routes.ts +41 -0
  91. package/src/server/management/routing-profile-routes.ts +234 -5
  92. package/src/server/management/system-restart.ts +12 -10
  93. package/src/server/management/system-routes.ts +20 -0
  94. package/src/server/management-auth.ts +51 -3
  95. package/src/server/ports.ts +41 -1
  96. package/src/server/proxy-liveness.ts +129 -4
  97. package/src/server/readiness.ts +99 -0
  98. package/src/server/relay.ts +113 -97
  99. package/src/server/request-log.ts +10 -4
  100. package/src/server/responses/compact.ts +107 -12
  101. package/src/server/responses/core.ts +220 -39
  102. package/src/server/responses-item-id-repair.ts +22 -3
  103. package/src/server/responses-model-rewrite.ts +29 -0
  104. package/src/server/sse-frame-buffer.ts +292 -0
  105. package/src/server/sse-payload-rewrite.ts +25 -14
  106. package/src/server/ws-bridge.ts +27 -22
  107. package/src/service-manager-probe.ts +520 -10
  108. package/src/service.ts +134 -2
  109. package/src/storage/worker-lifecycle.ts +14 -14
  110. package/src/tray/windows-tray.ps1 +74 -9
  111. package/src/types.ts +68 -2
  112. package/src/update/index.ts +12 -0
  113. package/src/update/job.ts +392 -18
  114. package/src/update/npm-cache-preflight.d.mts +47 -0
  115. package/src/update/npm-cache-preflight.mjs +201 -0
  116. package/src/usage/log.ts +1 -1
  117. package/src/vision/index.ts +77 -2
  118. package/src/web-search/loop.ts +1 -1
  119. package/src/web-search/parse.ts +4 -1
  120. package/gui/dist/assets/index-BKVqyYqT.js +0 -70
  121. package/gui/dist/assets/index-Ca_3269W.css +0 -1
package/README.md CHANGED
@@ -60,6 +60,14 @@ ocx start # or `ocx service` to run it in the backgro
60
60
  Open **http://localhost:10100** and configure everything in the web dashboard — add providers
61
61
  (40+ built-ins, or any OpenAI-compatible endpoint), pick models, manage accounts. `ocx gui`
62
62
  re-opens the dashboard at any time.
63
+ It can also manage a **ChatGPT account pool** for Codex auth. Add multiple ChatGPT / Codex accounts,
64
+ refresh their 5h / weekly / 30d quota in the dashboard. Under quota routing, new sessions can use
65
+ the lowest-usage healthy account; round-robin and fill-first use their own policies. Existing Codex
66
+ threads normally retain affinity to the account that started them, so long SSH, tmux, or
67
+ mobile-connected sessions do not jump accounts mid-conversation — but quota re-evaluation, failover,
68
+ account exclusion, affinity expiry, or 401/403 and 429 recovery can rebind them. Give the accounts a
69
+ selection order when one of them — usually your Codex Desktop login — should only be reached for
70
+ once the others are drained.
63
71
 
64
72
  ### For agents
65
73
 
@@ -139,6 +147,8 @@ ocx start [--port 10100] # start the proxy in the foreground
139
147
  ocx stop # stop + restore native Codex
140
148
  ocx service [install|start|stop|status|uninstall|remove] # background service
141
149
  ocx codex-shim install # start the proxy on demand whenever `codex` launches
150
+ ocx health [--json] # check immediate proxy liveness
151
+ ocx ready [--json] [--wait [--timeout <seconds>]] # check post-sync readiness
142
152
  ocx status # is the proxy running?
143
153
  ocx gui # open the web dashboard
144
154
  ocx provider <...> # manage providers (list/add/edit/test/remove)
@@ -151,6 +161,27 @@ ocx update [--tag preview] # update opencodex
151
161
  Unpinned starts may pick another free port if the preferred one is busy; an explicit `--port`
152
162
  never hops. Full reference: [CLI docs](https://opencodex.me/reference/cli/).
153
163
 
164
+ ### Health and readiness
165
+
166
+ `GET /healthz` reports immediate proxy liveness. The unauthenticated `GET /readyz` endpoint reports
167
+ post-sync readiness with the sanitized JSON identity `{service, version, uptime, pid, port, status}`.
168
+ It returns `200` when `status` is `ready`; `pending` and terminal `failed` return `503` with
169
+ `Retry-After: 1`.
170
+
171
+ `ocx ready [--json] [--wait [--timeout <seconds>]]` performs one probe by default. `--wait` polls
172
+ for up to 45 seconds by default, but exits immediately when it observes terminal `failed`;
173
+ `--timeout <seconds>` sets a 1–300 second limit, requires `--wait`, and accepts only positive integers. CLI `--json` output is
174
+ `{ready, status, pid, port}`, where `status` is `ready`, `pending`, `failed`, or `unreachable`.
175
+
176
+ | Exit | Result |
177
+ | --- | --- |
178
+ | `0` | Ready |
179
+ | `1` | Not ready: pending, failed, timeout, or unreachable |
180
+ | `64` | Invalid arguments |
181
+
182
+ An older proxy without `/readyz` fails closed as `unreachable` with exit 1, while `ocx health`
183
+ remains compatible.
184
+
154
185
  ### Autostart: service vs shim
155
186
 
156
187
  Use the **service** (`ocx service`) for an always-on proxy that restarts on crash. Use the
package/bin/ocx.mjs CHANGED
@@ -17,6 +17,10 @@ import { dirname, join, resolve } from "node:path";
17
17
  import { fileURLToPath } from "node:url";
18
18
  import { isRealBunBinary } from "../src/lib/bun-binary-validator.mjs";
19
19
  import { npmInvocation } from "../src/update/npm-invocation.mjs";
20
+ import {
21
+ npmCachePreflightFailureMessage,
22
+ runNpmCachePreflight,
23
+ } from "../src/update/npm-cache-preflight.mjs";
20
24
  import { handoffWindowsTrayForUpdate, planWindowsTrayUpdate } from "../src/update/tray-update-plan.mjs";
21
25
 
22
26
  const PKG = "@bitkyc08/opencodex";
@@ -136,6 +140,12 @@ function runNpmSelfUpdate() {
136
140
  process.exit(0);
137
141
  }
138
142
 
143
+ const cachePreflight = runNpmCachePreflight();
144
+ if (!cachePreflight.ok) {
145
+ console.error(`opencodex: ${npmCachePreflightFailureMessage(cachePreflight.reason)}. Aborting before stopping the proxy.`);
146
+ process.exit(1);
147
+ }
148
+
139
149
  // Remember whether a background service manages the proxy BEFORE stopping — `ocx stop`
140
150
  // unloads it, so a successful update must refresh and restart it afterwards.
141
151
  const serviceStatePath = join(configDir(), "service-state.json");