codex-multi-auth 2.17.0 → 2.17.2

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 (75) hide show
  1. package/.codex-plugin/plugin.json +9 -9
  2. package/LICENSE +21 -21
  3. package/README.md +487 -484
  4. package/assets/codex-multi-auth-icon.svg +39 -39
  5. package/assets/readme-hero.svg +31 -31
  6. package/config/README.md +31 -31
  7. package/config/codex-legacy.json +1221 -1221
  8. package/config/codex-modern.json +423 -423
  9. package/config/minimal-codex.json +15 -15
  10. package/dist/lib/accounts.d.ts +1 -7
  11. package/dist/lib/accounts.d.ts.map +1 -1
  12. package/dist/lib/accounts.js +3 -14
  13. package/dist/lib/codex-manager/commands/forecast.d.ts +1 -1
  14. package/dist/lib/codex-manager/commands/forecast.d.ts.map +1 -1
  15. package/dist/lib/codex-manager/commands/forecast.js +2 -2
  16. package/dist/lib/codex-manager/health-check.js +1 -1
  17. package/dist/lib/codex-manager/login-menu-data.d.ts.map +1 -1
  18. package/dist/lib/codex-manager/login-menu-data.js +7 -3
  19. package/dist/lib/codex-manager/quota-cache-helpers.d.ts +7 -1
  20. package/dist/lib/codex-manager/quota-cache-helpers.d.ts.map +1 -1
  21. package/dist/lib/codex-manager/quota-cache-helpers.js +34 -19
  22. package/dist/lib/codex-manager/repair-commands.js +1 -1
  23. package/dist/lib/context-budget-response.js +8 -8
  24. package/dist/lib/context-overflow.js +10 -10
  25. package/dist/lib/oauth-success.html +125 -125
  26. package/dist/lib/prompts/codex-host-bridge.js +138 -138
  27. package/dist/lib/prompts/codex.js +79 -79
  28. package/dist/lib/quota-cache.d.ts +7 -3
  29. package/dist/lib/quota-cache.d.ts.map +1 -1
  30. package/dist/lib/quota-cache.js +91 -59
  31. package/dist/lib/quota-readiness.d.ts +7 -2
  32. package/dist/lib/quota-readiness.d.ts.map +1 -1
  33. package/dist/lib/quota-readiness.js +25 -4
  34. package/dist/lib/runtime/app-bind.d.ts.map +1 -1
  35. package/dist/lib/runtime/app-bind.js +10 -2
  36. package/dist/lib/runtime/automatic-account-checks.d.ts +5 -1
  37. package/dist/lib/runtime/automatic-account-checks.d.ts.map +1 -1
  38. package/dist/lib/runtime/automatic-account-checks.js +29 -2
  39. package/dist/lib/runtime/automatic-subscription-checks.d.ts +1 -1
  40. package/dist/lib/runtime/automatic-subscription-checks.d.ts.map +1 -1
  41. package/dist/lib/runtime/automatic-subscription-checks.js +13 -16
  42. package/dist/lib/runtime-rotation-proxy.js +3 -3
  43. package/dist/lib/storage/pending-auth.d.ts +1 -0
  44. package/dist/lib/storage/pending-auth.d.ts.map +1 -1
  45. package/dist/lib/storage/pending-auth.js +4 -2
  46. package/dist/lib/storage/record-identity.d.ts +16 -0
  47. package/dist/lib/storage/record-identity.d.ts.map +1 -0
  48. package/dist/lib/storage/record-identity.js +16 -0
  49. package/node_modules/@codex-ai/plugin/dist/index.d.ts +2 -2
  50. package/node_modules/@codex-ai/plugin/dist/index.js +2 -2
  51. package/node_modules/@codex-ai/plugin/dist/tool.d.ts +42 -42
  52. package/node_modules/@codex-ai/plugin/dist/tool.js +29 -29
  53. package/node_modules/@codex-ai/plugin/package.json +9 -9
  54. package/node_modules/@codex-ai/sdk/dist/index.d.ts +4 -4
  55. package/node_modules/@codex-ai/sdk/dist/index.js +2 -2
  56. package/node_modules/@codex-ai/sdk/package.json +8 -8
  57. package/package.json +200 -200
  58. package/scripts/codex-app-launcher.js +653 -653
  59. package/scripts/codex-app-router.js +373 -373
  60. package/scripts/codex-bin-resolver.js +313 -313
  61. package/scripts/codex-multi-auth.js +59 -59
  62. package/scripts/codex-routing.js +62 -62
  63. package/scripts/codex.js +6642 -6642
  64. package/scripts/install-codex-auth-utils.js +213 -213
  65. package/scripts/mcodex.js +367 -367
  66. package/scripts/postinstall.js +114 -114
  67. package/scripts/preuninstall.js +265 -265
  68. package/vendor/codex-ai-plugin/dist/index.d.ts +2 -2
  69. package/vendor/codex-ai-plugin/dist/index.js +2 -2
  70. package/vendor/codex-ai-plugin/dist/tool.d.ts +42 -42
  71. package/vendor/codex-ai-plugin/dist/tool.js +29 -29
  72. package/vendor/codex-ai-plugin/package.json +9 -9
  73. package/vendor/codex-ai-sdk/dist/index.d.ts +4 -4
  74. package/vendor/codex-ai-sdk/dist/index.js +2 -2
  75. package/vendor/codex-ai-sdk/package.json +8 -8
package/README.md CHANGED
@@ -1,484 +1,487 @@
1
- # codex-multi-auth: multi-account OAuth for the official Codex CLI
2
-
3
- [![npm version](https://img.shields.io/npm/v/codex-multi-auth.svg)](https://www.npmjs.com/package/codex-multi-auth)
4
- [![npm downloads](https://img.shields.io/npm/dw/codex-multi-auth.svg)](https://www.npmjs.com/package/codex-multi-auth)
5
- [![CI](https://github.com/ndycode/codex-multi-auth/actions/workflows/ci.yml/badge.svg)](https://github.com/ndycode/codex-multi-auth/actions/workflows/ci.yml)
6
- [![MIT license](https://img.shields.io/npm/l/codex-multi-auth.svg)](LICENSE)
7
-
8
- `codex-multi-auth` is a multi-account OAuth manager for the official `@openai/codex` CLI. It gives Codex CLI users explicit ChatGPT account login, account switching, health checks, local diagnostics, project-scoped storage, and default-on runtime Responses rotation without taking over the official `codex` binary. Use `codex-multi-auth ...` for account management, or `codex-multi-auth-codex ...` only when you intentionally want the optional forwarding wrapper.
9
-
10
- Use it when you need a local Codex CLI multi-account workflow with visible account state, safer recovery commands, and a loopback-only runtime rotation proxy for request-bearing forwarded Codex sessions.
11
-
12
- <img width="1270" height="729" alt="codex-multi-auth terminal dashboard for Codex CLI multi-account OAuth account status" src="https://github.com/user-attachments/assets/0cecb77e-a6d3-432a-ba48-3577db0c7093" />
13
-
14
-
15
-
16
- > [!NOTE]
17
- > Legacy scoped prerelease package `@ndycode/codex-multi-auth` is migration-only.
18
- > Use `codex-multi-auth` for all new installs.
19
-
20
- ## What You Get
21
-
22
- - Codex CLI multi-account OAuth management with a dedicated `codex-multi-auth ...` command family
23
- - Explicit ChatGPT account login, saved-account listing, account switching, health checks, and diagnostics
24
- - Optional `codex-multi-auth-codex ...` forwarding wrapper for official Codex CLI commands when you choose wrapper-launched sessions
25
- - Health-aware account selection, quota forecasting, automatic failover, and flagged-account recovery
26
- - Project-scoped account storage under `~/.codex/multi-auth/projects/<project-key>/...` for repo-specific workflows
27
- - Interactive terminal dashboard for account actions, settings, search, and hotkeys
28
- - Forecast, report, fix, doctor, verify, monitor, and rotation commands for operational confidence
29
- - Local usage ledger, budget guards, account policy controls, routing profiles, and model/account capability views
30
- - Runtime counters, budget/cooldown state, and multi-auth probe visibility in `codex-multi-auth status` / `codex-multi-auth report`
31
- - Default-on loopback Responses proxy for live account rotation inside forwarded Codex CLI/app sessions
32
- - [Image generation/edit transport](docs/reference/image-routes.md) through the same authenticated runtime proxy
33
- - [Built-in image_gen provider compatibility](docs/reference/imagegen-provider-compatibility.md) through the same authenticated runtime proxy
34
- - Optional loopback-only local bridge for `/health`, `/v1/models`, and `/v1/responses`, protected by hashed local client tokens
35
- - Reversible packaged Codex app bind and user-level launcher routing helpers that do not patch official app binaries
36
- - Session affinity, live account sync, proactive refresh, and preemptive quota deferral controls
37
- - Codex-oriented request/prompt compatibility with strict runtime handling and documented error contracts
38
- - Stable docs for install, configuration, troubleshooting, upgrade, public API, storage paths, and release notes
39
-
40
- ---
41
-
42
- ## Optional automatic subscription priming
43
-
44
- Run `codex-multi-auth account auto-prime <index> on` to opt an account into
45
- periodic first-use checks by the running CLI/app router (every 15 minutes).
46
- It completes a tiny response only for an unused personal subscription and
47
- consumes subscription quota. The default is off; use `off` to disable it.
48
- Manual `check` still needs `--prime`. See the [command reference](docs/reference/commands.md).
49
-
50
- ## Why Developers Use It
51
-
52
- `codex-multi-auth` makes local Codex account state visible and recoverable. Instead of one opaque auth file, you get a named account pool, deterministic account switching, health-aware selection, JSON diagnostics for automation, and safe repair commands for stale or damaged local state. The architecture is designed for personal development workflows: credentials stay local, runtime rotation is loopback-only, and official Codex install paths keep owning the `codex` command.
53
-
54
- ---
55
-
56
- ## Current Architecture At A Glance
57
-
58
- `codex-multi-auth` ships four global binaries:
59
-
60
- | Binary | Purpose |
61
- | --- | --- |
62
- | `codex-multi-auth` | Primary account manager; accepts bare auth subcommands such as `login`, `status`, `switch`, `forecast`, and `rotation status` |
63
- | `codex-multi-auth-codex` | Optional wrapper that handles `auth ...` locally and forwards every other command to the official Codex CLI |
64
- | `mcodex` | Convenience launcher over `codex-multi-auth-codex` with optional `--monitor` and `--tmux` modes |
65
- | `codex-multi-auth-app-launcher` | Optional desktop launcher helper for supported user-level shortcuts and wrapper apps |
66
-
67
- The package does not publish a global `codex` binary. Keep `codex` owned by the official OpenAI install path. Use `codex-multi-auth-codex ...` or `mcodex ...` only when you intentionally want this package's forwarding wrapper.
68
-
69
- With runtime rotation enabled, interactive `mcodex resume` lists saved CLI and desktop sessions across providers in the current directory. Use `mcodex resume --all` to include other directories, or `-C <directory>` to change the project scope. Select a session to resume it through multi-auth; Escape cancels. Discovery uses the official local Codex app-server and does not rewrite session metadata. Desktop and CLI must use the same `CODEX_HOME` for shared history.
70
-
71
- Explicit session IDs, `--last`, remote connections, non-interactive invocations, and the in-session `/resume` command retain native Codex behavior. The cross-provider picker requires an official Codex version supporting the app-server `thread/list` API.
72
-
73
- ---
74
-
75
- <details open>
76
- <summary><b>Terms and Usage Notice</b></summary>
77
-
78
- > [!CAUTION]
79
- > This project uses OAuth account credentials and is intended for personal development use.
80
- >
81
- > By using this package, you acknowledge:
82
- > - This is an independent open-source project, not an official OpenAI product
83
- > - You are responsible for your own usage and policy compliance
84
- > - For production/commercial workloads, use the OpenAI Platform API
85
-
86
- </details>
87
-
88
- ---
89
-
90
- ## Installation
91
-
92
- <details open>
93
- <summary><b>For Humans</b></summary>
94
-
95
- ### Option A: Standard install
96
-
97
- ```bash
98
- npm i -g codex-multi-auth
99
- ```
100
-
101
- ### Option B: Migrate from legacy scoped prerelease
102
-
103
- ```bash
104
- npm uninstall -g @ndycode/codex-multi-auth
105
- npm i -g codex-multi-auth
106
- ```
107
-
108
- ### Option C: Verify wiring
109
-
110
- `codex --version` confirms the official Codex CLI is reachable. `codex-multi-auth --version` confirms the installed manager package version. `codex-multi-auth-codex --version` is the optional forwarding wrapper entrypoint.
111
-
112
- ```bash
113
- codex --version
114
- codex-multi-auth --version
115
- codex-multi-auth status
116
- ```
117
-
118
- Any official install path is fine as long as `codex` is on `PATH`: `npm i -g @openai/codex`, `brew install --cask codex`, or an official release binary.
119
-
120
- </details>
121
-
122
- <details>
123
- <summary><b>For LLM Agents</b></summary>
124
-
125
- ### Step-by-step
126
-
127
- 1. Install global package:
128
- - `npm i -g codex-multi-auth`
129
- 2. Run first login flow with `codex-multi-auth login`
130
- 3. Validate state with `codex-multi-auth status` and `codex-multi-auth check`
131
- 4. Confirm routing with `codex-multi-auth forecast --live`
132
-
133
- ### Verification
134
-
135
- ```bash
136
- codex-multi-auth status
137
- codex-multi-auth check
138
- ```
139
-
140
- </details>
141
-
142
- ---
143
-
144
- ## Quick Start
145
-
146
- Install and sign in:
147
-
148
- ```bash
149
- npm i -g @openai/codex
150
- npm i -g codex-multi-auth
151
- codex-multi-auth login
152
- ```
153
-
154
- If you already installed the official native CLI via Homebrew or a release binary, you only need:
155
-
156
- ```bash
157
- npm i -g codex-multi-auth
158
- codex-multi-auth login
159
- ```
160
-
161
- Verify the manager and the new account:
162
-
163
- ```bash
164
- codex-multi-auth status
165
- codex-multi-auth check
166
- ```
167
-
168
- Use these next:
169
-
170
- ```bash
171
- codex-multi-auth list
172
- codex-multi-auth switch 2
173
- codex-multi-auth forecast --live
174
- ```
175
-
176
- If browser launch is blocked, use the alternate login paths in [docs/getting-started.md](docs/getting-started.md#alternate-login-paths).
177
- For remote or headless shells, prefer `codex-multi-auth login --device-auth`.
178
- To refresh one saved account without changing the active selection or manual
179
- pin, run:
180
-
181
- ```bash
182
- codex-multi-auth login --account <index|email|account_id> --preserve-selection
183
- ```
184
-
185
- Add `--device-auth` on a remote shell. The refreshed OAuth identity must match
186
- the requested saved account or nothing is written. Refreshing the account Codex
187
- is currently using still publishes its new tokens to the native CLI; refreshing
188
- any other account leaves the active selection and the manual pin untouched. A
189
- disabled account stays disabled. `--account` cannot be combined with `--org`,
190
- which would rebind the row to a different workspace.
191
-
192
- ---
193
-
194
- ## Command Toolkit
195
-
196
- ### Start here
197
-
198
- | Command | What it answers |
199
- | --- | --- |
200
- | `codex-multi-auth login` | How do I add or re-open the account menu? |
201
- | `codex-multi-auth status` | What does my account pool, pin, and runtime metrics look like? (`list` is the same output) |
202
- | `codex-multi-auth check` | Do live health probes against my saved accounts succeed? |
203
-
204
- ### Daily use
205
-
206
- | Command | What it answers |
207
- | --- | --- |
208
- | `codex-multi-auth list` | Alias of `status` — full account/runtime dump |
209
- | `codex-multi-auth switch <index>` | How do I pin a different saved account for runtime routing? |
210
- | `codex-multi-auth unpin` | How do I clear a manual pin and resume hybrid rotation? |
211
- | `codex-multi-auth workspace <account> [workspace]` | How do I list or set an account's active workspace? |
212
- | `codex-multi-auth best --live` | How do I switch to the forecast-best account (clears any pin)? |
213
- | `codex-multi-auth-codex --account <index\|email\|id>` | How do I force one account for a single wrapper session without changing my default? |
214
- | `codex-multi-auth forecast --live` | Which account looks best for the next session? |
215
-
216
- ### Repair
217
-
218
- | Command | What it answers |
219
- | --- | --- |
220
- | `codex-multi-auth verify-flagged` | Can any previously flagged account be restored? |
221
- | `codex-multi-auth verify --paths` | Do my storage path chain and sandbox probes still pass self-test? |
222
- | `codex-multi-auth fix --dry-run` | What safe storage or account repairs are available? |
223
- | `codex-multi-auth doctor --fix` | Can the CLI diagnose and apply the safest fixes now? |
224
- | `codex-multi-auth uninstall` | Remove residual artifacts (run BEFORE `npm uninstall`; npm@7+ no longer fires `preuninstall`) |
225
-
226
- ### Advanced
227
-
228
- | Command | What it answers |
229
- | --- | --- |
230
- | `codex-multi-auth report --live --json` | How do I get the full machine-readable health report? |
231
- | `codex-multi-auth limits --json [--refresh]` | How do I read account quota windows without parsing internal cache files or terminal text? |
232
- | `codex-multi-auth fix --live --model gpt-5.5` | How do I run live repair probes with a chosen model? |
233
- | `codex-multi-auth why-selected --json` | Which account does the selector pick now, and why? |
234
- | `codex-multi-auth usage --since 24h --by project` | What local usage has been recorded recently? |
235
- | `codex-multi-auth monitor --json` | What is the combined usage, policy, quota, runtime, and project state? |
236
- | `codex-multi-auth bridge token create --label local-client` | How do I create a local bridge bearer token? |
237
- | `codex-multi-auth integrations --kind python` | How do I generate local bridge client snippets? |
238
- | `codex-multi-auth rotation status` | Is live runtime account rotation enabled for forwarded Codex sessions? |
239
-
240
- ### Reliability behavior
241
-
242
- - whole-pool replay is disabled by default when every account is rate-limited
243
- - active requests use a bounded outbound request budget so one prompt cannot walk the full pool indefinitely
244
- - repeated cross-account 5xx bursts trigger a short cooldown instead of continuing aggressive rotation
245
- - proactive refresh is staggered to reduce background refresh bursts
246
- - `codex-multi-auth status` surfaces recent runtime request metrics in text output, and `codex-multi-auth report --json` exposes the machine-readable cooldown/runtime snapshot
247
-
248
- ---
249
-
250
- ## Dashboard Hotkeys
251
-
252
- ### Main dashboard
253
-
254
- | Key | Action |
255
- | --- | --- |
256
- | `Up` / `Down` | Move selection |
257
- | `Enter` | Select/open |
258
- | `1-9` | Quick switch |
259
- | `/` | Search |
260
- | `?` | Toggle help |
261
- | `Q` | Back/cancel |
262
-
263
- ### Account details
264
-
265
- | Key | Action |
266
- | --- | --- |
267
- | `S` | Set current account |
268
- | `R` | Refresh/re-login account |
269
- | `E` | Enable/disable account |
270
- | `D` | Delete account |
271
-
272
- ---
273
-
274
- ## Storage Paths
275
-
276
- | File | Default path |
277
- | --- | --- |
278
- | Settings | `~/.codex/multi-auth/settings.json` |
279
- | Accounts | `~/.codex/multi-auth/openai-codex-accounts.json` |
280
- | Flagged accounts | `~/.codex/multi-auth/openai-codex-flagged-accounts.json` |
281
- | Quota cache | `~/.codex/multi-auth/quota-cache.json` |
282
- | Runtime observability | `~/.codex/multi-auth/runtime-observability.json` |
283
- | Usage ledger | `~/.codex/multi-auth/usage/usage-ledger.jsonl` |
284
- | Account policies | `~/.codex/multi-auth/account-policies.json` |
285
- | Routing profiles | `~/.codex/multi-auth/routing-profiles.json` |
286
- | Budget guards | `~/.codex/multi-auth/budget-guards.json` |
287
- | Local client tokens | `~/.codex/multi-auth/local-client-tokens.json` |
288
- | Runtime app helper status | `~/.codex/multi-auth/runtime-rotation-app-helper.<pid>.json` |
289
- | Runtime app helper owner metadata | `~/.codex/multi-auth/runtime-rotation-app-helper-owner.<pid>.json` |
290
- | Persistent app bind state/logs | `~/.codex/multi-auth/app-bind/` |
291
- | Logs | `~/.codex/multi-auth/logs/codex-plugin/` |
292
- | Per-project accounts | `~/.codex/multi-auth/projects/<project-key>/openai-codex-accounts.json` |
293
-
294
- Override root with `CODEX_MULTI_AUTH_DIR=<path>`.
295
-
296
- ---
297
-
298
- ## Configuration
299
-
300
- Primary config root:
301
- - `~/.codex/multi-auth/settings.json`
302
- - or `CODEX_MULTI_AUTH_DIR/settings.json` when custom root is set
303
-
304
- Selected runtime/environment overrides:
305
-
306
- | Variable | Effect |
307
- | --- | --- |
308
- | `CODEX_MULTI_AUTH_DIR` | Override settings/accounts root |
309
- | `CODEX_MULTI_AUTH_CONFIG_PATH` | Prefer this config file when it exists (also the save target when set) |
310
- | `CODEX_MODE=0/1` | Disable/enable Codex mode |
311
- | `CODEX_MULTI_AUTH_FORCE_ACCOUNT=<index\|email\|id>` | Force one account for a single `codex-multi-auth-codex` run (ephemeral; requires rotation proxy) |
312
- | `CODEX_MULTI_AUTH_BYPASS=1` | Skip multi-auth intercept and forward straight to official Codex |
313
- | `CODEX_MULTI_AUTH_RUNTIME_ROTATION_PROXY=0/1` | Opt out/in of live Responses proxy rotation for forwarded Codex CLI/app sessions |
314
- | `CODEX_MULTI_AUTH_RUNTIME_PROXY_UPSTREAM_BASE_URL=http://127.0.0.1:<port>/<path>` | Route the runtime rotation proxy through an explicit loopback HTTP upstream; requires an explicit port and a numeric loopback host (`127.0.0.0/8` or `[::1]`), and rejects credentials, query strings, fragments, HTTPS, and every other host |
315
- | `CODEX_MULTI_AUTH_MODEL_CAPACITY_RETRY_MS=<ms>` | Wall-clock ceiling on how long one request waits out a "selected model is at capacity" response before giving up (default 600000, max 3600000, `0` disables) |
316
- | `CODEX_MULTI_AUTH_APP_ROTATION_IDLE_MS=<ms>` | Override automatic Codex app helper idle shutdown |
317
- | `CODEX_MULTI_AUTH_APP_BIND_INSTALL=0/1` | Opt out/in of packaged Codex app bind self-heal on first CLI run or rotation enable |
318
- | `CODEX_MULTI_AUTH_APP_LAUNCHER_INSTALL=0/1` | Opt out/in of routing supported app shortcuts on first CLI run or rotation enable |
319
- | `CODEX_TUI_V2=0/1` | Disable/enable TUI v2 |
320
- | `CODEX_TUI_COLOR_PROFILE=truecolor\|ansi256\|ansi16` | TUI color profile |
321
- | `CODEX_TUI_GLYPHS=ascii\|unicode\|auto` | TUI glyph style |
322
- | `CODEX_AUTH_BACKGROUND_RESPONSES=0/1` | Opt in/out of stateful Responses `background: true` compatibility |
323
- | `CODEX_AUTH_FETCH_TIMEOUT_MS=<ms>` | Request timeout override |
324
- | `CODEX_AUTH_STREAM_STALL_TIMEOUT_MS=<ms>` | Stream stall timeout override |
325
-
326
- Validate config after changes:
327
-
328
- ```bash
329
- codex-multi-auth status
330
- codex-multi-auth check
331
- codex-multi-auth forecast --live
332
- ```
333
-
334
- Responses background mode stays opt-in. Enable `backgroundResponses` in settings or `CODEX_AUTH_BACKGROUND_RESPONSES=1` only for callers that intentionally send `background: true`, because those requests switch from stateless `store=false` routing to stateful `store=true`. See [docs/upgrade.md](docs/upgrade.md) for rollout guidance.
335
-
336
- Runtime rotation is enabled by default for request-bearing wrapper-launched Codex sessions. Package install scripts stay side-effect-free: npm postinstall only prints a short notice (and stays silent in CI or non-interactive installs). The first CLI run after an install self-heals supported packaged Codex app binds and user-level launcher routing when possible (recorded once in a `first-run-setup.json` marker under the multi-auth runtime root), while `codex-multi-auth rotation enable` remains the explicit repair command. `codex-multi-auth rotation disable` turns the setting off and removes the persistent app bind. Set `CODEX_MULTI_AUTH_RUNTIME_ROTATION_PROXY=0`, `CODEX_MULTI_AUTH_APP_BIND_INSTALL=0`, or `CODEX_MULTI_AUTH_APP_LAUNCHER_INSTALL=0` to opt out of the matching default behavior.
337
-
338
- Advanced local proxy chains can set `CODEX_MULTI_AUTH_RUNTIME_PROXY_UPSTREAM_BASE_URL` for one wrapper process. The wrapper passes that URL to both the shadow-runtime and interactive-helper rotation paths and fails closed if the configured upstream is invalid or unavailable; it never falls back silently to the direct backend while an explicit upstream is required. Because the request that reaches the upstream carries the managed OAuth bearer token, the host must be a numeric loopback literal: a name such as `localhost` is rejected, since a hosts-file entry can point it at a routable address. "Fails closed" also covers the case where runtime rotation itself is off (`CODEX_MULTI_AUTH_RUNTIME_ROTATION_PROXY=0`, `CODEX_MULTI_AUTH_BYPASS=1`, or the setting disabled): a request-bearing invocation exits non-zero rather than bypassing the configured upstream. Subcommands that make no backend requests still run normally.
339
-
340
- When the backend answers that the selected model is at capacity, the runtime proxy waits and re-sends the request instead of burning the pool. Capacity is a property of the model, not of an account, so rotating spends the transient budget against accounts that all fail identically and the request ends as a 503 within seconds. The wait backs off (2s, 5s, 15s, 30s, then 60s), honors an upstream `retry-after` when one is sent, and stops at a wall-clock deadline set by `CODEX_MULTI_AUTH_MODEL_CAPACITY_RETRY_MS` (10 minutes by default, 1 hour maximum). Set that variable to `0` to restore the previous rotate-and-fail behavior. The responding account is left completely unpenalized: its pool token is refunded and it is never marked rate limited or cooled down, so selection runs normally on the next pass and may pick any healthy account. The wait is abandoned if the client disconnects, so no further upstream request is sent for a response nobody is reading. See [#689](https://github.com/ndycode/codex-multi-auth/issues/689).
341
-
342
- Trust boundary: the loopback check bounds exposure to the local machine, and nothing more. It does not authenticate the process listening on that port, and plaintext HTTP is what a local inspection proxy needs, so any process that can bind the port you name receives the managed bearer token in cleartext. Set this variable only on a machine where you trust every local process that can bind a loopback port, and only for as long as you need the chain.
343
-
344
- Installed wrappers may perform a best-effort daily npm version check during normal forwarded Codex startup. When a newer package is detected, the wrapper only prints a manual notice on an interactive TTY or when `CODEX_MULTI_AUTH_DEBUG=1`: `npm install -g codex-multi-auth@latest`. It never runs npm install or update commands for you.
345
-
346
- ---
347
-
348
- ## Experimental Settings Highlights
349
-
350
- The Settings menu now includes an `Experimental` section for staged features:
351
-
352
- - preview-first sync into `oc-chatgpt-multi-auth`
353
- - named local pool backup export with filename prompt
354
- - refresh guard toggle and interval controls moved out of Backend Controls
355
- - context budget guard: pause a session before it hits the model's context window, with independently configurable soft/hard thresholds (default 65% / 69%) — ships disabled; see [Context Budget Guard](docs/features.md#context-budget-guard-experimental)
356
-
357
- These flows are intentionally non-destructive by default: sync previews before apply, destination-only accounts are preserved, and backup filename collisions fail safely.
358
-
359
- ---
360
-
361
- ## Troubleshooting
362
-
363
- <details open>
364
- <summary><b>60-second recovery</b></summary>
365
-
366
- ```bash
367
- codex-multi-auth doctor --fix
368
- codex-multi-auth check
369
- codex-multi-auth forecast --live
370
- ```
371
-
372
- If still broken:
373
-
374
- ```bash
375
- codex-multi-auth login
376
- ```
377
-
378
- </details>
379
-
380
- <details>
381
- <summary><b>Common symptoms</b></summary>
382
-
383
- - `codex-multi-auth` unrecognized: run `where codex-multi-auth` or `which codex-multi-auth`, then follow `docs/troubleshooting.md` for install checks
384
- - Switch succeeds but wrong account appears active: run `codex-multi-auth switch <index>`, then restart session
385
- - Requests fail fast with a pool cooldown message: wait for the cooldown window or inspect `codex-multi-auth status`
386
- - Requests fail fast after repeated upstream 5xx errors: inspect `codex-multi-auth report --json` for runtime traffic and cooldown details
387
- - Storage cleanup fails with `EBUSY` / `EPERM` (Windows): run `codex-multi-auth doctor --fix` to retry, or manually remove `~/.codex/multi-auth/<project-key>/` and re-login
388
- - OAuth callback on port `1455` fails: free the port and re-run `codex-multi-auth login`
389
- - Login hangs in WSL, or installing in WSL breaks a working Windows install: Windows and WSL contend for callback port `1455`, and the browser opens on the Windows host either way — see [Windows and WSL side by side](docs/troubleshooting.md#windows-and-wsl-side-by-side), or use `codex-multi-auth login --device-auth`, which needs no callback port
390
- - Browser launch is blocked or you are in a headless shell: prefer `codex-multi-auth login --device-auth`; use `codex-multi-auth login --manual` or `CODEX_AUTH_NO_BROWSER=1` only when you need the callback-paste fallback
391
- - `missing field id_token` / `token_expired` / `refresh_token_reused`: re-login affected account
392
-
393
- </details>
394
-
395
- <details>
396
- <summary><b>Diagnostics pack</b></summary>
397
-
398
- ```bash
399
- codex-multi-auth list
400
- codex-multi-auth status
401
- codex-multi-auth check
402
- codex-multi-auth verify-flagged --json
403
- codex-multi-auth forecast --live
404
- codex-multi-auth fix --dry-run
405
- codex-multi-auth report --live --json
406
- codex-multi-auth doctor --json
407
- ```
408
-
409
- </details>
410
-
411
- ---
412
-
413
- ## Documentation
414
-
415
- - Docs portal: [docs/README.md](docs/README.md)
416
- - Getting started: [docs/getting-started.md](docs/getting-started.md)
417
- - Features: [docs/features.md](docs/features.md)
418
- - Configuration: [docs/configuration.md](docs/configuration.md)
419
- - Troubleshooting: [docs/troubleshooting.md](docs/troubleshooting.md)
420
- - Commands reference: [docs/reference/commands.md](docs/reference/commands.md)
421
- - Public API contract: [docs/reference/public-api.md](docs/reference/public-api.md)
422
- - Error contracts: [docs/reference/error-contracts.md](docs/reference/error-contracts.md)
423
- - Settings reference: [docs/reference/settings.md](docs/reference/settings.md)
424
- - Storage paths: [docs/reference/storage-paths.md](docs/reference/storage-paths.md)
425
- - Upgrade guide: [docs/upgrade.md](docs/upgrade.md)
426
- - Privacy: [docs/privacy.md](docs/privacy.md)
427
-
428
- ---
429
-
430
- ## Release Notes
431
-
432
- - Current stable: [docs/releases/v2.17.0.md](docs/releases/v2.17.0.md) — install via `npm i -g codex-multi-auth`
433
- - Previous stable: [docs/releases/v2.8.3.md](docs/releases/v2.8.3.md)
434
- - Previous stable: [docs/releases/v2.8.2.md](docs/releases/v2.8.2.md)
435
- - Previous stable: [docs/releases/v2.7.1.md](docs/releases/v2.7.1.md)
436
- - Previous stable: [docs/releases/v2.7.0.md](docs/releases/v2.7.0.md)
437
- - Previous stable: [docs/releases/v2.6.0.md](docs/releases/v2.6.0.md)
438
- - Previous stable: [docs/releases/v2.5.0.md](docs/releases/v2.5.0.md)
439
- - Previous stable: [docs/releases/v2.4.0.md](docs/releases/v2.4.0.md)
440
- - Previous stable: [docs/releases/v2.3.3.md](docs/releases/v2.3.3.md)
441
- - Previous stable: [docs/releases/v2.3.2.md](docs/releases/v2.3.2.md)
442
- - Previous stable: [docs/releases/v2.3.1.md](docs/releases/v2.3.1.md)
443
- - Previous stable: [docs/releases/v2.3.0.md](docs/releases/v2.3.0.md)
444
- - Previous stable: [docs/releases/v2.2.2.md](docs/releases/v2.2.2.md)
445
- - Previous stable: [docs/releases/v2.2.1.md](docs/releases/v2.2.1.md)
446
- - Previous stable: [docs/releases/v2.2.0.md](docs/releases/v2.2.0.md)
447
- - Previous stable: [docs/releases/v2.1.12.md](docs/releases/v2.1.12.md)
448
- - Earlier stable: [docs/releases/v2.1.11.md](docs/releases/v2.1.11.md)
449
- - Earlier stable: [docs/releases/v2.1.10.md](docs/releases/v2.1.10.md)
450
- - Earlier stable: [docs/releases/v2.1.8.md](docs/releases/v2.1.8.md)
451
- - Earlier stable: [docs/releases/v2.1.7.md](docs/releases/v2.1.7.md)
452
- - Earlier stable: [docs/releases/v2.1.6.md](docs/releases/v2.1.6.md)
453
- - Earlier stable: [docs/releases/v2.1.5.md](docs/releases/v2.1.5.md)
454
- - Earlier stable: [docs/releases/v2.1.4.md](docs/releases/v2.1.4.md)
455
- - Earlier stable: [docs/releases/v2.1.3.md](docs/releases/v2.1.3.md)
456
- - Earlier stable: [docs/releases/v2.1.2.md](docs/releases/v2.1.2.md)
457
- - Earlier stable: [docs/releases/v2.1.1.md](docs/releases/v2.1.1.md)
458
- - Earlier stable: [docs/releases/v2.1.0.md](docs/releases/v2.1.0.md)
459
- - Earlier stable: [docs/releases/v1.3.2.md](docs/releases/v1.3.2.md)
460
- - Stable archive: [docs/releases/v1.3.1.md](docs/releases/v1.3.1.md)
461
- - Full release archive: [docs/README.md#release-history](docs/README.md#release-history)
462
- - Archived prerelease: [docs/releases/v0.1.0-beta.0.md](docs/releases/v0.1.0-beta.0.md)
463
-
464
- ## License
465
-
466
- MIT License. See [LICENSE](LICENSE).
467
-
468
- <details>
469
- <summary><b>Legal</b></summary>
470
-
471
- - Not affiliated with OpenAI.
472
- - "ChatGPT", "Codex", and "OpenAI" are trademarks of OpenAI.
473
- - You assume responsibility for your own usage and compliance.
474
-
475
- </details>
476
-
477
- ### Optional native desktop binding
478
-
479
- Native desktop features such as Remote Control pairing need the real desktop
480
- account identity. Use `codex-multi-auth rotation bind-app --native` to preserve
481
- that login while routing inference through managed accounts. Add
482
- `--catalog-account <index>` to use one account's live model catalog. This mode
483
- requires file-backed desktop credentials; see the [rotation command reference](docs/reference/commands.md#native-provider-binding-opt-in)
484
- for setup, limitations, and rollback.
1
+ # codex-multi-auth: multi-account OAuth for the official Codex CLI
2
+
3
+ [![npm version](https://img.shields.io/npm/v/codex-multi-auth.svg)](https://www.npmjs.com/package/codex-multi-auth)
4
+ [![npm downloads](https://img.shields.io/npm/dw/codex-multi-auth.svg)](https://www.npmjs.com/package/codex-multi-auth)
5
+ [![CI](https://github.com/ndycode/codex-multi-auth/actions/workflows/ci.yml/badge.svg)](https://github.com/ndycode/codex-multi-auth/actions/workflows/ci.yml)
6
+ [![MIT license](https://img.shields.io/npm/l/codex-multi-auth.svg)](LICENSE)
7
+
8
+ `codex-multi-auth` is a multi-account OAuth manager for the official `@openai/codex` CLI. It gives Codex CLI users explicit ChatGPT account login, account switching, health checks, local diagnostics, project-scoped storage, and default-on runtime Responses rotation without taking over the official `codex` binary. Use `codex-multi-auth ...` for account management, or `codex-multi-auth-codex ...` only when you intentionally want the optional forwarding wrapper.
9
+
10
+ Use it when you need a local Codex CLI multi-account workflow with visible account state, safer recovery commands, and a loopback-only runtime rotation proxy for request-bearing forwarded Codex sessions.
11
+
12
+ <img width="1270" height="729" alt="codex-multi-auth terminal dashboard for Codex CLI multi-account OAuth account status" src="https://github.com/user-attachments/assets/0cecb77e-a6d3-432a-ba48-3577db0c7093" />
13
+
14
+
15
+
16
+ > [!NOTE]
17
+ > Legacy scoped prerelease package `@ndycode/codex-multi-auth` is migration-only.
18
+ > Use `codex-multi-auth` for all new installs.
19
+
20
+ ## What You Get
21
+
22
+ - Codex CLI multi-account OAuth management with a dedicated `codex-multi-auth ...` command family
23
+ - Explicit ChatGPT account login, saved-account listing, account switching, health checks, and diagnostics
24
+ - Optional `codex-multi-auth-codex ...` forwarding wrapper for official Codex CLI commands when you choose wrapper-launched sessions
25
+ - Health-aware account selection, quota forecasting, automatic failover, and flagged-account recovery
26
+ - Project-scoped account storage under `~/.codex/multi-auth/projects/<project-key>/...` for repo-specific workflows
27
+ - Interactive terminal dashboard for account actions, settings, search, and hotkeys
28
+ - Forecast, report, fix, doctor, verify, monitor, and rotation commands for operational confidence
29
+ - Local usage ledger, budget guards, account policy controls, routing profiles, and model/account capability views
30
+ - Runtime counters, budget/cooldown state, and multi-auth probe visibility in `codex-multi-auth status` / `codex-multi-auth report`
31
+ - Default-on loopback Responses proxy for live account rotation inside forwarded Codex CLI/app sessions
32
+ - [Image generation/edit transport](docs/reference/image-routes.md) through the same authenticated runtime proxy
33
+ - [Built-in image_gen provider compatibility](docs/reference/imagegen-provider-compatibility.md) through the same authenticated runtime proxy
34
+ - Optional loopback-only local bridge for `/health`, `/v1/models`, and `/v1/responses`, protected by hashed local client tokens
35
+ - Reversible packaged Codex app bind and user-level launcher routing helpers that do not patch official app binaries
36
+ - Session affinity, live account sync, proactive refresh, and preemptive quota deferral controls
37
+ - Codex-oriented request/prompt compatibility with strict runtime handling and documented error contracts
38
+ - Stable docs for install, configuration, troubleshooting, upgrade, public API, storage paths, and release notes
39
+
40
+ ---
41
+
42
+ ## Optional automatic subscription priming
43
+
44
+ Run `codex-multi-auth account auto-prime <index> on` to opt an account into
45
+ periodic first-use checks by the running CLI/app router (every 15 minutes).
46
+ It completes a tiny response only for an unused personal subscription and
47
+ consumes subscription quota. Checks follow the saved workspace selection and
48
+ track each saved account separately, including members of a shared organization.
49
+ Status reads quota for the selected workspace; routing reads quota for the request’s exact workspace.
50
+ Select Personal for a Personal subscription. The default is off; use `off` to disable it.
51
+ Manual `check` still needs `--prime`. See the [command reference](docs/reference/commands.md).
52
+
53
+ ## Why Developers Use It
54
+
55
+ `codex-multi-auth` makes local Codex account state visible and recoverable. Instead of one opaque auth file, you get a named account pool, deterministic account switching, health-aware selection, JSON diagnostics for automation, and safe repair commands for stale or damaged local state. The architecture is designed for personal development workflows: credentials stay local, runtime rotation is loopback-only, and official Codex install paths keep owning the `codex` command.
56
+
57
+ ---
58
+
59
+ ## Current Architecture At A Glance
60
+
61
+ `codex-multi-auth` ships four global binaries:
62
+
63
+ | Binary | Purpose |
64
+ | --- | --- |
65
+ | `codex-multi-auth` | Primary account manager; accepts bare auth subcommands such as `login`, `status`, `switch`, `forecast`, and `rotation status` |
66
+ | `codex-multi-auth-codex` | Optional wrapper that handles `auth ...` locally and forwards every other command to the official Codex CLI |
67
+ | `mcodex` | Convenience launcher over `codex-multi-auth-codex` with optional `--monitor` and `--tmux` modes |
68
+ | `codex-multi-auth-app-launcher` | Optional desktop launcher helper for supported user-level shortcuts and wrapper apps |
69
+
70
+ The package does not publish a global `codex` binary. Keep `codex` owned by the official OpenAI install path. Use `codex-multi-auth-codex ...` or `mcodex ...` only when you intentionally want this package's forwarding wrapper.
71
+
72
+ With runtime rotation enabled, interactive `mcodex resume` lists saved CLI and desktop sessions across providers in the current directory. Use `mcodex resume --all` to include other directories, or `-C <directory>` to change the project scope. Select a session to resume it through multi-auth; Escape cancels. Discovery uses the official local Codex app-server and does not rewrite session metadata. Desktop and CLI must use the same `CODEX_HOME` for shared history.
73
+
74
+ Explicit session IDs, `--last`, remote connections, non-interactive invocations, and the in-session `/resume` command retain native Codex behavior. The cross-provider picker requires an official Codex version supporting the app-server `thread/list` API.
75
+
76
+ ---
77
+
78
+ <details open>
79
+ <summary><b>Terms and Usage Notice</b></summary>
80
+
81
+ > [!CAUTION]
82
+ > This project uses OAuth account credentials and is intended for personal development use.
83
+ >
84
+ > By using this package, you acknowledge:
85
+ > - This is an independent open-source project, not an official OpenAI product
86
+ > - You are responsible for your own usage and policy compliance
87
+ > - For production/commercial workloads, use the OpenAI Platform API
88
+
89
+ </details>
90
+
91
+ ---
92
+
93
+ ## Installation
94
+
95
+ <details open>
96
+ <summary><b>For Humans</b></summary>
97
+
98
+ ### Option A: Standard install
99
+
100
+ ```bash
101
+ npm i -g codex-multi-auth
102
+ ```
103
+
104
+ ### Option B: Migrate from legacy scoped prerelease
105
+
106
+ ```bash
107
+ npm uninstall -g @ndycode/codex-multi-auth
108
+ npm i -g codex-multi-auth
109
+ ```
110
+
111
+ ### Option C: Verify wiring
112
+
113
+ `codex --version` confirms the official Codex CLI is reachable. `codex-multi-auth --version` confirms the installed manager package version. `codex-multi-auth-codex --version` is the optional forwarding wrapper entrypoint.
114
+
115
+ ```bash
116
+ codex --version
117
+ codex-multi-auth --version
118
+ codex-multi-auth status
119
+ ```
120
+
121
+ Any official install path is fine as long as `codex` is on `PATH`: `npm i -g @openai/codex`, `brew install --cask codex`, or an official release binary.
122
+
123
+ </details>
124
+
125
+ <details>
126
+ <summary><b>For LLM Agents</b></summary>
127
+
128
+ ### Step-by-step
129
+
130
+ 1. Install global package:
131
+ - `npm i -g codex-multi-auth`
132
+ 2. Run first login flow with `codex-multi-auth login`
133
+ 3. Validate state with `codex-multi-auth status` and `codex-multi-auth check`
134
+ 4. Confirm routing with `codex-multi-auth forecast --live`
135
+
136
+ ### Verification
137
+
138
+ ```bash
139
+ codex-multi-auth status
140
+ codex-multi-auth check
141
+ ```
142
+
143
+ </details>
144
+
145
+ ---
146
+
147
+ ## Quick Start
148
+
149
+ Install and sign in:
150
+
151
+ ```bash
152
+ npm i -g @openai/codex
153
+ npm i -g codex-multi-auth
154
+ codex-multi-auth login
155
+ ```
156
+
157
+ If you already installed the official native CLI via Homebrew or a release binary, you only need:
158
+
159
+ ```bash
160
+ npm i -g codex-multi-auth
161
+ codex-multi-auth login
162
+ ```
163
+
164
+ Verify the manager and the new account:
165
+
166
+ ```bash
167
+ codex-multi-auth status
168
+ codex-multi-auth check
169
+ ```
170
+
171
+ Use these next:
172
+
173
+ ```bash
174
+ codex-multi-auth list
175
+ codex-multi-auth switch 2
176
+ codex-multi-auth forecast --live
177
+ ```
178
+
179
+ If browser launch is blocked, use the alternate login paths in [docs/getting-started.md](docs/getting-started.md#alternate-login-paths).
180
+ For remote or headless shells, prefer `codex-multi-auth login --device-auth`.
181
+ To refresh one saved account without changing the active selection or manual
182
+ pin, run:
183
+
184
+ ```bash
185
+ codex-multi-auth login --account <index|email|account_id> --preserve-selection
186
+ ```
187
+
188
+ Add `--device-auth` on a remote shell. The refreshed OAuth identity must match
189
+ the requested saved account or nothing is written. Refreshing the account Codex
190
+ is currently using still publishes its new tokens to the native CLI; refreshing
191
+ any other account leaves the active selection and the manual pin untouched. A
192
+ disabled account stays disabled. `--account` cannot be combined with `--org`,
193
+ which would rebind the row to a different workspace.
194
+
195
+ ---
196
+
197
+ ## Command Toolkit
198
+
199
+ ### Start here
200
+
201
+ | Command | What it answers |
202
+ | --- | --- |
203
+ | `codex-multi-auth login` | How do I add or re-open the account menu? |
204
+ | `codex-multi-auth status` | What does my account pool, pin, and runtime metrics look like? (`list` is the same output) |
205
+ | `codex-multi-auth check` | Do live health probes against my saved accounts succeed? |
206
+
207
+ ### Daily use
208
+
209
+ | Command | What it answers |
210
+ | --- | --- |
211
+ | `codex-multi-auth list` | Alias of `status` — full account/runtime dump |
212
+ | `codex-multi-auth switch <index>` | How do I pin a different saved account for runtime routing? |
213
+ | `codex-multi-auth unpin` | How do I clear a manual pin and resume hybrid rotation? |
214
+ | `codex-multi-auth workspace <account> [workspace]` | How do I list or set an account's active workspace? |
215
+ | `codex-multi-auth best --live` | How do I switch to the forecast-best account (clears any pin)? |
216
+ | `codex-multi-auth-codex --account <index\|email\|id>` | How do I force one account for a single wrapper session without changing my default? |
217
+ | `codex-multi-auth forecast --live` | Which account looks best for the next session? |
218
+
219
+ ### Repair
220
+
221
+ | Command | What it answers |
222
+ | --- | --- |
223
+ | `codex-multi-auth verify-flagged` | Can any previously flagged account be restored? |
224
+ | `codex-multi-auth verify --paths` | Do my storage path chain and sandbox probes still pass self-test? |
225
+ | `codex-multi-auth fix --dry-run` | What safe storage or account repairs are available? |
226
+ | `codex-multi-auth doctor --fix` | Can the CLI diagnose and apply the safest fixes now? |
227
+ | `codex-multi-auth uninstall` | Remove residual artifacts (run BEFORE `npm uninstall`; npm@7+ no longer fires `preuninstall`) |
228
+
229
+ ### Advanced
230
+
231
+ | Command | What it answers |
232
+ | --- | --- |
233
+ | `codex-multi-auth report --live --json` | How do I get the full machine-readable health report? |
234
+ | `codex-multi-auth limits --json [--refresh]` | How do I read account quota windows without parsing internal cache files or terminal text? |
235
+ | `codex-multi-auth fix --live --model gpt-5.5` | How do I run live repair probes with a chosen model? |
236
+ | `codex-multi-auth why-selected --json` | Which account does the selector pick now, and why? |
237
+ | `codex-multi-auth usage --since 24h --by project` | What local usage has been recorded recently? |
238
+ | `codex-multi-auth monitor --json` | What is the combined usage, policy, quota, runtime, and project state? |
239
+ | `codex-multi-auth bridge token create --label local-client` | How do I create a local bridge bearer token? |
240
+ | `codex-multi-auth integrations --kind python` | How do I generate local bridge client snippets? |
241
+ | `codex-multi-auth rotation status` | Is live runtime account rotation enabled for forwarded Codex sessions? |
242
+
243
+ ### Reliability behavior
244
+
245
+ - whole-pool replay is disabled by default when every account is rate-limited
246
+ - active requests use a bounded outbound request budget so one prompt cannot walk the full pool indefinitely
247
+ - repeated cross-account 5xx bursts trigger a short cooldown instead of continuing aggressive rotation
248
+ - proactive refresh is staggered to reduce background refresh bursts
249
+ - `codex-multi-auth status` surfaces recent runtime request metrics in text output, and `codex-multi-auth report --json` exposes the machine-readable cooldown/runtime snapshot
250
+
251
+ ---
252
+
253
+ ## Dashboard Hotkeys
254
+
255
+ ### Main dashboard
256
+
257
+ | Key | Action |
258
+ | --- | --- |
259
+ | `Up` / `Down` | Move selection |
260
+ | `Enter` | Select/open |
261
+ | `1-9` | Quick switch |
262
+ | `/` | Search |
263
+ | `?` | Toggle help |
264
+ | `Q` | Back/cancel |
265
+
266
+ ### Account details
267
+
268
+ | Key | Action |
269
+ | --- | --- |
270
+ | `S` | Set current account |
271
+ | `R` | Refresh/re-login account |
272
+ | `E` | Enable/disable account |
273
+ | `D` | Delete account |
274
+
275
+ ---
276
+
277
+ ## Storage Paths
278
+
279
+ | File | Default path |
280
+ | --- | --- |
281
+ | Settings | `~/.codex/multi-auth/settings.json` |
282
+ | Accounts | `~/.codex/multi-auth/openai-codex-accounts.json` |
283
+ | Flagged accounts | `~/.codex/multi-auth/openai-codex-flagged-accounts.json` |
284
+ | Quota cache | `~/.codex/multi-auth/quota-cache.json` |
285
+ | Runtime observability | `~/.codex/multi-auth/runtime-observability.json` |
286
+ | Usage ledger | `~/.codex/multi-auth/usage/usage-ledger.jsonl` |
287
+ | Account policies | `~/.codex/multi-auth/account-policies.json` |
288
+ | Routing profiles | `~/.codex/multi-auth/routing-profiles.json` |
289
+ | Budget guards | `~/.codex/multi-auth/budget-guards.json` |
290
+ | Local client tokens | `~/.codex/multi-auth/local-client-tokens.json` |
291
+ | Runtime app helper status | `~/.codex/multi-auth/runtime-rotation-app-helper.<pid>.json` |
292
+ | Runtime app helper owner metadata | `~/.codex/multi-auth/runtime-rotation-app-helper-owner.<pid>.json` |
293
+ | Persistent app bind state/logs | `~/.codex/multi-auth/app-bind/` |
294
+ | Logs | `~/.codex/multi-auth/logs/codex-plugin/` |
295
+ | Per-project accounts | `~/.codex/multi-auth/projects/<project-key>/openai-codex-accounts.json` |
296
+
297
+ Override root with `CODEX_MULTI_AUTH_DIR=<path>`.
298
+
299
+ ---
300
+
301
+ ## Configuration
302
+
303
+ Primary config root:
304
+ - `~/.codex/multi-auth/settings.json`
305
+ - or `CODEX_MULTI_AUTH_DIR/settings.json` when custom root is set
306
+
307
+ Selected runtime/environment overrides:
308
+
309
+ | Variable | Effect |
310
+ | --- | --- |
311
+ | `CODEX_MULTI_AUTH_DIR` | Override settings/accounts root |
312
+ | `CODEX_MULTI_AUTH_CONFIG_PATH` | Prefer this config file when it exists (also the save target when set) |
313
+ | `CODEX_MODE=0/1` | Disable/enable Codex mode |
314
+ | `CODEX_MULTI_AUTH_FORCE_ACCOUNT=<index\|email\|id>` | Force one account for a single `codex-multi-auth-codex` run (ephemeral; requires rotation proxy) |
315
+ | `CODEX_MULTI_AUTH_BYPASS=1` | Skip multi-auth intercept and forward straight to official Codex |
316
+ | `CODEX_MULTI_AUTH_RUNTIME_ROTATION_PROXY=0/1` | Opt out/in of live Responses proxy rotation for forwarded Codex CLI/app sessions |
317
+ | `CODEX_MULTI_AUTH_RUNTIME_PROXY_UPSTREAM_BASE_URL=http://127.0.0.1:<port>/<path>` | Route the runtime rotation proxy through an explicit loopback HTTP upstream; requires an explicit port and a numeric loopback host (`127.0.0.0/8` or `[::1]`), and rejects credentials, query strings, fragments, HTTPS, and every other host |
318
+ | `CODEX_MULTI_AUTH_MODEL_CAPACITY_RETRY_MS=<ms>` | Wall-clock ceiling on how long one request waits out a "selected model is at capacity" response before giving up (default 600000, max 3600000, `0` disables) |
319
+ | `CODEX_MULTI_AUTH_APP_ROTATION_IDLE_MS=<ms>` | Override automatic Codex app helper idle shutdown |
320
+ | `CODEX_MULTI_AUTH_APP_BIND_INSTALL=0/1` | Opt out/in of packaged Codex app bind self-heal on first CLI run or rotation enable |
321
+ | `CODEX_MULTI_AUTH_APP_LAUNCHER_INSTALL=0/1` | Opt out/in of routing supported app shortcuts on first CLI run or rotation enable |
322
+ | `CODEX_TUI_V2=0/1` | Disable/enable TUI v2 |
323
+ | `CODEX_TUI_COLOR_PROFILE=truecolor\|ansi256\|ansi16` | TUI color profile |
324
+ | `CODEX_TUI_GLYPHS=ascii\|unicode\|auto` | TUI glyph style |
325
+ | `CODEX_AUTH_BACKGROUND_RESPONSES=0/1` | Opt in/out of stateful Responses `background: true` compatibility |
326
+ | `CODEX_AUTH_FETCH_TIMEOUT_MS=<ms>` | Request timeout override |
327
+ | `CODEX_AUTH_STREAM_STALL_TIMEOUT_MS=<ms>` | Stream stall timeout override |
328
+
329
+ Validate config after changes:
330
+
331
+ ```bash
332
+ codex-multi-auth status
333
+ codex-multi-auth check
334
+ codex-multi-auth forecast --live
335
+ ```
336
+
337
+ Responses background mode stays opt-in. Enable `backgroundResponses` in settings or `CODEX_AUTH_BACKGROUND_RESPONSES=1` only for callers that intentionally send `background: true`, because those requests switch from stateless `store=false` routing to stateful `store=true`. See [docs/upgrade.md](docs/upgrade.md) for rollout guidance.
338
+
339
+ Runtime rotation is enabled by default for request-bearing wrapper-launched Codex sessions. Package install scripts stay side-effect-free: npm postinstall only prints a short notice (and stays silent in CI or non-interactive installs). The first CLI run after an install self-heals supported packaged Codex app binds and user-level launcher routing when possible (recorded once in a `first-run-setup.json` marker under the multi-auth runtime root), while `codex-multi-auth rotation enable` remains the explicit repair command. `codex-multi-auth rotation disable` turns the setting off and removes the persistent app bind. Set `CODEX_MULTI_AUTH_RUNTIME_ROTATION_PROXY=0`, `CODEX_MULTI_AUTH_APP_BIND_INSTALL=0`, or `CODEX_MULTI_AUTH_APP_LAUNCHER_INSTALL=0` to opt out of the matching default behavior.
340
+
341
+ Advanced local proxy chains can set `CODEX_MULTI_AUTH_RUNTIME_PROXY_UPSTREAM_BASE_URL` for one wrapper process. The wrapper passes that URL to both the shadow-runtime and interactive-helper rotation paths and fails closed if the configured upstream is invalid or unavailable; it never falls back silently to the direct backend while an explicit upstream is required. Because the request that reaches the upstream carries the managed OAuth bearer token, the host must be a numeric loopback literal: a name such as `localhost` is rejected, since a hosts-file entry can point it at a routable address. "Fails closed" also covers the case where runtime rotation itself is off (`CODEX_MULTI_AUTH_RUNTIME_ROTATION_PROXY=0`, `CODEX_MULTI_AUTH_BYPASS=1`, or the setting disabled): a request-bearing invocation exits non-zero rather than bypassing the configured upstream. Subcommands that make no backend requests still run normally.
342
+
343
+ When the backend answers that the selected model is at capacity, the runtime proxy waits and re-sends the request instead of burning the pool. Capacity is a property of the model, not of an account, so rotating spends the transient budget against accounts that all fail identically and the request ends as a 503 within seconds. The wait backs off (2s, 5s, 15s, 30s, then 60s), honors an upstream `retry-after` when one is sent, and stops at a wall-clock deadline set by `CODEX_MULTI_AUTH_MODEL_CAPACITY_RETRY_MS` (10 minutes by default, 1 hour maximum). Set that variable to `0` to restore the previous rotate-and-fail behavior. The responding account is left completely unpenalized: its pool token is refunded and it is never marked rate limited or cooled down, so selection runs normally on the next pass and may pick any healthy account. The wait is abandoned if the client disconnects, so no further upstream request is sent for a response nobody is reading. See [#689](https://github.com/ndycode/codex-multi-auth/issues/689).
344
+
345
+ Trust boundary: the loopback check bounds exposure to the local machine, and nothing more. It does not authenticate the process listening on that port, and plaintext HTTP is what a local inspection proxy needs, so any process that can bind the port you name receives the managed bearer token in cleartext. Set this variable only on a machine where you trust every local process that can bind a loopback port, and only for as long as you need the chain.
346
+
347
+ Installed wrappers may perform a best-effort daily npm version check during normal forwarded Codex startup. When a newer package is detected, the wrapper only prints a manual notice on an interactive TTY or when `CODEX_MULTI_AUTH_DEBUG=1`: `npm install -g codex-multi-auth@latest`. It never runs npm install or update commands for you.
348
+
349
+ ---
350
+
351
+ ## Experimental Settings Highlights
352
+
353
+ The Settings menu now includes an `Experimental` section for staged features:
354
+
355
+ - preview-first sync into `oc-chatgpt-multi-auth`
356
+ - named local pool backup export with filename prompt
357
+ - refresh guard toggle and interval controls moved out of Backend Controls
358
+ - context budget guard: pause a session before it hits the model's context window, with independently configurable soft/hard thresholds (default 65% / 69%) — ships disabled; see [Context Budget Guard](docs/features.md#context-budget-guard-experimental)
359
+
360
+ These flows are intentionally non-destructive by default: sync previews before apply, destination-only accounts are preserved, and backup filename collisions fail safely.
361
+
362
+ ---
363
+
364
+ ## Troubleshooting
365
+
366
+ <details open>
367
+ <summary><b>60-second recovery</b></summary>
368
+
369
+ ```bash
370
+ codex-multi-auth doctor --fix
371
+ codex-multi-auth check
372
+ codex-multi-auth forecast --live
373
+ ```
374
+
375
+ If still broken:
376
+
377
+ ```bash
378
+ codex-multi-auth login
379
+ ```
380
+
381
+ </details>
382
+
383
+ <details>
384
+ <summary><b>Common symptoms</b></summary>
385
+
386
+ - `codex-multi-auth` unrecognized: run `where codex-multi-auth` or `which codex-multi-auth`, then follow `docs/troubleshooting.md` for install checks
387
+ - Switch succeeds but wrong account appears active: run `codex-multi-auth switch <index>`, then restart session
388
+ - Requests fail fast with a pool cooldown message: wait for the cooldown window or inspect `codex-multi-auth status`
389
+ - Requests fail fast after repeated upstream 5xx errors: inspect `codex-multi-auth report --json` for runtime traffic and cooldown details
390
+ - Storage cleanup fails with `EBUSY` / `EPERM` (Windows): run `codex-multi-auth doctor --fix` to retry, or manually remove `~/.codex/multi-auth/<project-key>/` and re-login
391
+ - OAuth callback on port `1455` fails: free the port and re-run `codex-multi-auth login`
392
+ - Login hangs in WSL, or installing in WSL breaks a working Windows install: Windows and WSL contend for callback port `1455`, and the browser opens on the Windows host either way — see [Windows and WSL side by side](docs/troubleshooting.md#windows-and-wsl-side-by-side), or use `codex-multi-auth login --device-auth`, which needs no callback port
393
+ - Browser launch is blocked or you are in a headless shell: prefer `codex-multi-auth login --device-auth`; use `codex-multi-auth login --manual` or `CODEX_AUTH_NO_BROWSER=1` only when you need the callback-paste fallback
394
+ - `missing field id_token` / `token_expired` / `refresh_token_reused`: re-login affected account
395
+
396
+ </details>
397
+
398
+ <details>
399
+ <summary><b>Diagnostics pack</b></summary>
400
+
401
+ ```bash
402
+ codex-multi-auth list
403
+ codex-multi-auth status
404
+ codex-multi-auth check
405
+ codex-multi-auth verify-flagged --json
406
+ codex-multi-auth forecast --live
407
+ codex-multi-auth fix --dry-run
408
+ codex-multi-auth report --live --json
409
+ codex-multi-auth doctor --json
410
+ ```
411
+
412
+ </details>
413
+
414
+ ---
415
+
416
+ ## Documentation
417
+
418
+ - Docs portal: [docs/README.md](docs/README.md)
419
+ - Getting started: [docs/getting-started.md](docs/getting-started.md)
420
+ - Features: [docs/features.md](docs/features.md)
421
+ - Configuration: [docs/configuration.md](docs/configuration.md)
422
+ - Troubleshooting: [docs/troubleshooting.md](docs/troubleshooting.md)
423
+ - Commands reference: [docs/reference/commands.md](docs/reference/commands.md)
424
+ - Public API contract: [docs/reference/public-api.md](docs/reference/public-api.md)
425
+ - Error contracts: [docs/reference/error-contracts.md](docs/reference/error-contracts.md)
426
+ - Settings reference: [docs/reference/settings.md](docs/reference/settings.md)
427
+ - Storage paths: [docs/reference/storage-paths.md](docs/reference/storage-paths.md)
428
+ - Upgrade guide: [docs/upgrade.md](docs/upgrade.md)
429
+ - Privacy: [docs/privacy.md](docs/privacy.md)
430
+
431
+ ---
432
+
433
+ ## Release Notes
434
+
435
+ - Current stable: [docs/releases/v2.17.0.md](docs/releases/v2.17.0.md) — install via `npm i -g codex-multi-auth`
436
+ - Previous stable: [docs/releases/v2.8.3.md](docs/releases/v2.8.3.md)
437
+ - Previous stable: [docs/releases/v2.8.2.md](docs/releases/v2.8.2.md)
438
+ - Previous stable: [docs/releases/v2.7.1.md](docs/releases/v2.7.1.md)
439
+ - Previous stable: [docs/releases/v2.7.0.md](docs/releases/v2.7.0.md)
440
+ - Previous stable: [docs/releases/v2.6.0.md](docs/releases/v2.6.0.md)
441
+ - Previous stable: [docs/releases/v2.5.0.md](docs/releases/v2.5.0.md)
442
+ - Previous stable: [docs/releases/v2.4.0.md](docs/releases/v2.4.0.md)
443
+ - Previous stable: [docs/releases/v2.3.3.md](docs/releases/v2.3.3.md)
444
+ - Previous stable: [docs/releases/v2.3.2.md](docs/releases/v2.3.2.md)
445
+ - Previous stable: [docs/releases/v2.3.1.md](docs/releases/v2.3.1.md)
446
+ - Previous stable: [docs/releases/v2.3.0.md](docs/releases/v2.3.0.md)
447
+ - Previous stable: [docs/releases/v2.2.2.md](docs/releases/v2.2.2.md)
448
+ - Previous stable: [docs/releases/v2.2.1.md](docs/releases/v2.2.1.md)
449
+ - Previous stable: [docs/releases/v2.2.0.md](docs/releases/v2.2.0.md)
450
+ - Previous stable: [docs/releases/v2.1.12.md](docs/releases/v2.1.12.md)
451
+ - Earlier stable: [docs/releases/v2.1.11.md](docs/releases/v2.1.11.md)
452
+ - Earlier stable: [docs/releases/v2.1.10.md](docs/releases/v2.1.10.md)
453
+ - Earlier stable: [docs/releases/v2.1.8.md](docs/releases/v2.1.8.md)
454
+ - Earlier stable: [docs/releases/v2.1.7.md](docs/releases/v2.1.7.md)
455
+ - Earlier stable: [docs/releases/v2.1.6.md](docs/releases/v2.1.6.md)
456
+ - Earlier stable: [docs/releases/v2.1.5.md](docs/releases/v2.1.5.md)
457
+ - Earlier stable: [docs/releases/v2.1.4.md](docs/releases/v2.1.4.md)
458
+ - Earlier stable: [docs/releases/v2.1.3.md](docs/releases/v2.1.3.md)
459
+ - Earlier stable: [docs/releases/v2.1.2.md](docs/releases/v2.1.2.md)
460
+ - Earlier stable: [docs/releases/v2.1.1.md](docs/releases/v2.1.1.md)
461
+ - Earlier stable: [docs/releases/v2.1.0.md](docs/releases/v2.1.0.md)
462
+ - Earlier stable: [docs/releases/v1.3.2.md](docs/releases/v1.3.2.md)
463
+ - Stable archive: [docs/releases/v1.3.1.md](docs/releases/v1.3.1.md)
464
+ - Full release archive: [docs/README.md#release-history](docs/README.md#release-history)
465
+ - Archived prerelease: [docs/releases/v0.1.0-beta.0.md](docs/releases/v0.1.0-beta.0.md)
466
+
467
+ ## License
468
+
469
+ MIT License. See [LICENSE](LICENSE).
470
+
471
+ <details>
472
+ <summary><b>Legal</b></summary>
473
+
474
+ - Not affiliated with OpenAI.
475
+ - "ChatGPT", "Codex", and "OpenAI" are trademarks of OpenAI.
476
+ - You assume responsibility for your own usage and compliance.
477
+
478
+ </details>
479
+
480
+ ### Optional native desktop binding
481
+
482
+ Native desktop features such as Remote Control pairing need the real desktop
483
+ account identity. Use `codex-multi-auth rotation bind-app --native` to preserve
484
+ that login while routing inference through managed accounts. Add
485
+ `--catalog-account <index>` to use one account's live model catalog. This mode
486
+ requires file-backed desktop credentials; see the [rotation command reference](docs/reference/commands.md#native-provider-binding-opt-in)
487
+ for setup, limitations, and rollback.