codex-multi-auth 2.6.0 → 2.7.0

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.
package/README.md CHANGED
@@ -1,424 +1,433 @@
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
- - Optional loopback-only local bridge for `/health`, `/v1/models`, and `/v1/responses`, protected by hashed local client tokens
33
- - Reversible packaged Codex app bind and user-level launcher routing helpers that do not patch official app binaries
34
- - Session affinity, live account sync, proactive refresh, and preemptive quota deferral controls
35
- - Codex-oriented request/prompt compatibility with strict runtime handling and documented error contracts
36
- - Stable docs for install, configuration, troubleshooting, upgrade, public API, storage paths, and release notes
37
-
38
- ---
39
-
40
- ## Why Developers Use It
41
-
42
- `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.
43
-
44
- ---
45
-
46
- ## Current Architecture At A Glance
47
-
48
- `codex-multi-auth` now ships three distinct global binaries:
49
-
50
- | Binary | Purpose |
51
- | --- | --- |
52
- | `codex-multi-auth` | Primary account manager; accepts bare auth subcommands such as `login`, `status`, `switch`, `forecast`, and `rotation status` |
53
- | `codex-multi-auth-codex` | Optional wrapper that handles `auth ...` locally and forwards every other command to the official Codex CLI |
54
- | `codex-multi-auth-app-launcher` | Optional desktop launcher helper for supported user-level shortcuts and wrapper apps |
55
-
56
- The package does not publish a global `codex` binary. Keep `codex` owned by the official OpenAI install path and use `codex-multi-auth-codex ...` only when you intentionally want this package's forwarding wrapper.
57
-
58
- ---
59
-
60
- <details open>
61
- <summary><b>Terms and Usage Notice</b></summary>
62
-
63
- > [!CAUTION]
64
- > This project uses OAuth account credentials and is intended for personal development use.
65
- >
66
- > By using this package, you acknowledge:
67
- > - This is an independent open-source project, not an official OpenAI product
68
- > - You are responsible for your own usage and policy compliance
69
- > - For production/commercial workloads, use the OpenAI Platform API
70
-
71
- </details>
72
-
73
- ---
74
-
75
- ## Installation
76
-
77
- <details open>
78
- <summary><b>For Humans</b></summary>
79
-
80
- ### Option A: Standard install
81
-
82
- ```bash
83
- npm i -g codex-multi-auth
84
- ```
85
-
86
- ### Option B: Migrate from legacy scoped prerelease
87
-
88
- ```bash
89
- npm uninstall -g @ndycode/codex-multi-auth
90
- npm i -g codex-multi-auth
91
- ```
92
-
93
- ### Option C: Verify wiring
94
-
95
- `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.
96
-
97
- ```bash
98
- codex --version
99
- codex-multi-auth --version
100
- codex-multi-auth status
101
- ```
102
-
103
- 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.
104
-
105
- </details>
106
-
107
- <details>
108
- <summary><b>For LLM Agents</b></summary>
109
-
110
- ### Step-by-step
111
-
112
- 1. Install global package:
113
- - `npm i -g codex-multi-auth`
114
- 2. Run first login flow with `codex-multi-auth login`
115
- 3. Validate state with `codex-multi-auth status` and `codex-multi-auth check`
116
- 4. Confirm routing with `codex-multi-auth forecast --live`
117
-
118
- ### Verification
119
-
120
- ```bash
121
- codex-multi-auth status
122
- codex-multi-auth check
123
- ```
124
-
125
- </details>
126
-
127
- ---
128
-
129
- ## Quick Start
130
-
131
- Install and sign in:
132
-
133
- ```bash
134
- npm i -g @openai/codex
135
- npm i -g codex-multi-auth
136
- codex-multi-auth login
137
- ```
138
-
139
- If you already installed the official native CLI via Homebrew or a release binary, you only need:
140
-
141
- ```bash
142
- npm i -g codex-multi-auth
143
- codex-multi-auth login
144
- ```
145
-
146
- Verify the manager and the new account:
147
-
148
- ```bash
149
- codex-multi-auth status
150
- codex-multi-auth check
151
- ```
152
-
153
- Use these next:
154
-
155
- ```bash
156
- codex-multi-auth list
157
- codex-multi-auth switch 2
158
- codex-multi-auth forecast --live
159
- ```
160
-
161
- If browser launch is blocked, use the alternate login paths in [docs/getting-started.md](docs/getting-started.md#alternate-login-paths).
162
- For remote or headless shells, prefer `codex-multi-auth login --device-auth`.
163
-
164
- ---
165
-
166
- ## Command Toolkit
167
-
168
- ### Start here
169
-
170
- | Command | What it answers |
171
- | --- | --- |
172
- | `codex-multi-auth login` | How do I add or re-open the account menu? |
173
- | `codex-multi-auth status` | Is the wrapper active right now? |
174
- | `codex-multi-auth check` | Do my saved accounts look healthy? |
175
-
176
- ### Daily use
177
-
178
- | Command | What it answers |
179
- | --- | --- |
180
- | `codex-multi-auth list` | Which accounts are saved and which one is active? |
181
- | `codex-multi-auth switch <index>` | How do I move to a different saved account? |
182
- | `codex-multi-auth-codex --account <index\|email\|id>` | How do I force one account for a single wrapper session without changing my default? |
183
- | `codex-multi-auth forecast --live` | Which account looks best for the next session? |
184
-
185
- ### Repair
186
-
187
- | Command | What it answers |
188
- | --- | --- |
189
- | `codex-multi-auth verify-flagged` | Can any previously flagged account be restored? |
190
- | `codex-multi-auth verify --paths` | Do my storage path chain and sandbox probes still pass self-test? |
191
- | `codex-multi-auth fix --dry-run` | What safe storage or account repairs are available? |
192
- | `codex-multi-auth doctor --fix` | Can the CLI diagnose and apply the safest fixes now? |
193
- | `codex-multi-auth uninstall` | Remove residual artifacts (run BEFORE `npm uninstall`; npm@7+ no longer fires `preuninstall`) |
194
-
195
- ### Advanced
196
-
197
- | Command | What it answers |
198
- | --- | --- |
199
- | `codex-multi-auth report --live --json` | How do I get the full machine-readable health report? |
200
- | `codex-multi-auth fix --live --model gpt-5.5` | How do I run live repair probes with a chosen model? |
201
- | `codex-multi-auth why-selected --json` | Which account does the selector pick now, and why? |
202
- | `codex-multi-auth usage --since 24h --by project` | What local usage has been recorded recently? |
203
- | `codex-multi-auth monitor --json` | What is the combined usage, policy, quota, runtime, and project state? |
204
- | `codex-multi-auth bridge token create --label local-client` | How do I create a local bridge bearer token? |
205
- | `codex-multi-auth integrations --kind python` | How do I generate local bridge client snippets? |
206
- | `codex-multi-auth rotation status` | Is live runtime account rotation enabled for forwarded Codex sessions? |
207
-
208
- ### Reliability behavior
209
-
210
- - whole-pool replay is disabled by default when every account is rate-limited
211
- - active requests use a bounded outbound request budget so one prompt cannot walk the full pool indefinitely
212
- - repeated cross-account 5xx bursts trigger a short cooldown instead of continuing aggressive rotation
213
- - proactive refresh is staggered to reduce background refresh bursts
214
- - `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
215
-
216
- ---
217
-
218
- ## Dashboard Hotkeys
219
-
220
- ### Main dashboard
221
-
222
- | Key | Action |
223
- | --- | --- |
224
- | `Up` / `Down` | Move selection |
225
- | `Enter` | Select/open |
226
- | `1-9` | Quick switch |
227
- | `/` | Search |
228
- | `?` | Toggle help |
229
- | `Q` | Back/cancel |
230
-
231
- ### Account details
232
-
233
- | Key | Action |
234
- | --- | --- |
235
- | `S` | Set current account |
236
- | `R` | Refresh/re-login account |
237
- | `E` | Enable/disable account |
238
- | `D` | Delete account |
239
-
240
- ---
241
-
242
- ## Storage Paths
243
-
244
- | File | Default path |
245
- | --- | --- |
246
- | Settings | `~/.codex/multi-auth/settings.json` |
247
- | Accounts | `~/.codex/multi-auth/openai-codex-accounts.json` |
248
- | Flagged accounts | `~/.codex/multi-auth/openai-codex-flagged-accounts.json` |
249
- | Quota cache | `~/.codex/multi-auth/quota-cache.json` |
250
- | Runtime observability | `~/.codex/multi-auth/runtime-observability.json` |
251
- | Usage ledger | `~/.codex/multi-auth/usage/usage-ledger.jsonl` |
252
- | Account policies | `~/.codex/multi-auth/account-policies.json` |
253
- | Routing profiles | `~/.codex/multi-auth/routing-profiles.json` |
254
- | Budget guards | `~/.codex/multi-auth/budget-guards.json` |
255
- | Local client tokens | `~/.codex/multi-auth/local-client-tokens.json` |
256
- | Runtime app helper status | `~/.codex/multi-auth/runtime-rotation-app-helper.json` |
257
- | Persistent app bind state/logs | `~/.codex/multi-auth/app-bind/` |
258
- | Logs | `~/.codex/multi-auth/logs/codex-plugin/` |
259
- | Per-project accounts | `~/.codex/multi-auth/projects/<project-key>/openai-codex-accounts.json` |
260
-
261
- Override root with `CODEX_MULTI_AUTH_DIR=<path>`.
262
-
263
- ---
264
-
265
- ## Configuration
266
-
267
- Primary config root:
268
- - `~/.codex/multi-auth/settings.json`
269
- - or `CODEX_MULTI_AUTH_DIR/settings.json` when custom root is set
270
-
271
- Selected runtime/environment overrides:
272
-
273
- | Variable | Effect |
274
- | --- | --- |
275
- | `CODEX_MULTI_AUTH_DIR` | Override settings/accounts root |
276
- | `CODEX_MULTI_AUTH_CONFIG_PATH` | Alternate config file path |
277
- | `CODEX_MODE=0/1` | Disable/enable Codex mode |
278
- | `CODEX_MULTI_AUTH_RUNTIME_ROTATION_PROXY=0/1` | Opt out/in of live Responses proxy rotation for forwarded Codex CLI/app sessions |
279
- | `CODEX_MULTI_AUTH_APP_ROTATION_IDLE_MS=<ms>` | Override automatic Codex app helper idle shutdown |
280
- | `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 |
281
- | `CODEX_MULTI_AUTH_APP_LAUNCHER_INSTALL=0/1` | Opt out/in of routing supported app shortcuts on first CLI run or rotation enable |
282
- | `CODEX_TUI_V2=0/1` | Disable/enable TUI v2 |
283
- | `CODEX_TUI_COLOR_PROFILE=truecolor\|ansi256\|ansi16` | TUI color profile |
284
- | `CODEX_TUI_GLYPHS=ascii\|unicode\|auto` | TUI glyph style |
285
- | `CODEX_AUTH_BACKGROUND_RESPONSES=0/1` | Opt in/out of stateful Responses `background: true` compatibility |
286
- | `CODEX_AUTH_FETCH_TIMEOUT_MS=<ms>` | Request timeout override |
287
- | `CODEX_AUTH_STREAM_STALL_TIMEOUT_MS=<ms>` | Stream stall timeout override |
288
-
289
- Validate config after changes:
290
-
291
- ```bash
292
- codex-multi-auth status
293
- codex-multi-auth check
294
- codex-multi-auth forecast --live
295
- ```
296
-
297
- 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.
298
-
299
- 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.
300
-
301
- 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.
302
-
303
- ---
304
-
305
- ## Experimental Settings Highlights
306
-
307
- The Settings menu now includes an `Experimental` section for staged features:
308
-
309
- - preview-first sync into `oc-chatgpt-multi-auth`
310
- - named local pool backup export with filename prompt
311
- - refresh guard toggle and interval controls moved out of Backend Controls
312
-
313
- These flows are intentionally non-destructive by default: sync previews before apply, destination-only accounts are preserved, and backup filename collisions fail safely.
314
-
315
- ---
316
-
317
- ## Troubleshooting
318
-
319
- <details open>
320
- <summary><b>60-second recovery</b></summary>
321
-
322
- ```bash
323
- codex-multi-auth doctor --fix
324
- codex-multi-auth check
325
- codex-multi-auth forecast --live
326
- ```
327
-
328
- If still broken:
329
-
330
- ```bash
331
- codex-multi-auth login
332
- ```
333
-
334
- </details>
335
-
336
- <details>
337
- <summary><b>Common symptoms</b></summary>
338
-
339
- - `codex-multi-auth` unrecognized: run `where codex-multi-auth` or `which codex-multi-auth`, then follow `docs/troubleshooting.md` for install checks
340
- - Switch succeeds but wrong account appears active: run `codex-multi-auth switch <index>`, then restart session
341
- - Requests fail fast with a pool cooldown message: wait for the cooldown window or inspect `codex-multi-auth status`
342
- - Requests fail fast after repeated upstream 5xx errors: inspect `codex-multi-auth report --json` for runtime traffic and cooldown details
343
- - 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
344
- - OAuth callback on port `1455` fails: free the port and re-run `codex-multi-auth login`
345
- - 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
346
- - `missing field id_token` / `token_expired` / `refresh_token_reused`: re-login affected account
347
-
348
- </details>
349
-
350
- <details>
351
- <summary><b>Diagnostics pack</b></summary>
352
-
353
- ```bash
354
- codex-multi-auth list
355
- codex-multi-auth status
356
- codex-multi-auth check
357
- codex-multi-auth verify-flagged --json
358
- codex-multi-auth forecast --live
359
- codex-multi-auth fix --dry-run
360
- codex-multi-auth report --live --json
361
- codex-multi-auth doctor --json
362
- ```
363
-
364
- </details>
365
-
366
- ---
367
-
368
- ## Documentation
369
-
370
- - Docs portal: [docs/README.md](docs/README.md)
371
- - Getting started: [docs/getting-started.md](docs/getting-started.md)
372
- - Features: [docs/features.md](docs/features.md)
373
- - Configuration: [docs/configuration.md](docs/configuration.md)
374
- - Troubleshooting: [docs/troubleshooting.md](docs/troubleshooting.md)
375
- - Commands reference: [docs/reference/commands.md](docs/reference/commands.md)
376
- - Public API contract: [docs/reference/public-api.md](docs/reference/public-api.md)
377
- - Error contracts: [docs/reference/error-contracts.md](docs/reference/error-contracts.md)
378
- - Settings reference: [docs/reference/settings.md](docs/reference/settings.md)
379
- - Storage paths: [docs/reference/storage-paths.md](docs/reference/storage-paths.md)
380
- - Upgrade guide: [docs/upgrade.md](docs/upgrade.md)
381
- - Privacy: [docs/privacy.md](docs/privacy.md)
382
-
383
- ---
384
-
385
- ## Release Notes
386
-
387
- - Current stable: [docs/releases/v2.5.0.md](docs/releases/v2.5.0.md) — install via `npm i -g codex-multi-auth`
388
- - Previous stable: [docs/releases/v2.4.0.md](docs/releases/v2.4.0.md)
389
- - Previous stable: [docs/releases/v2.3.3.md](docs/releases/v2.3.3.md)
390
- - Previous stable: [docs/releases/v2.3.2.md](docs/releases/v2.3.2.md)
391
- - Previous stable: [docs/releases/v2.3.1.md](docs/releases/v2.3.1.md)
392
- - Previous stable: [docs/releases/v2.3.0.md](docs/releases/v2.3.0.md)
393
- - Previous stable: [docs/releases/v2.2.2.md](docs/releases/v2.2.2.md)
394
- - Previous stable: [docs/releases/v2.2.1.md](docs/releases/v2.2.1.md)
395
- - Previous stable: [docs/releases/v2.2.0.md](docs/releases/v2.2.0.md)
396
- - Previous stable: [docs/releases/v2.1.12.md](docs/releases/v2.1.12.md)
397
- - Earlier stable: [docs/releases/v2.1.11.md](docs/releases/v2.1.11.md)
398
- - Earlier stable: [docs/releases/v2.1.10.md](docs/releases/v2.1.10.md)
399
- - Earlier stable: [docs/releases/v2.1.8.md](docs/releases/v2.1.8.md)
400
- - Earlier stable: [docs/releases/v2.1.7.md](docs/releases/v2.1.7.md)
401
- - Earlier stable: [docs/releases/v2.1.6.md](docs/releases/v2.1.6.md)
402
- - Earlier stable: [docs/releases/v2.1.5.md](docs/releases/v2.1.5.md)
403
- - Earlier stable: [docs/releases/v2.1.4.md](docs/releases/v2.1.4.md)
404
- - Earlier stable: [docs/releases/v2.1.3.md](docs/releases/v2.1.3.md)
405
- - Earlier stable: [docs/releases/v2.1.2.md](docs/releases/v2.1.2.md)
406
- - Earlier stable: [docs/releases/v2.1.1.md](docs/releases/v2.1.1.md)
407
- - Earlier stable: [docs/releases/v2.1.0.md](docs/releases/v2.1.0.md)
408
- - Earlier stable: [docs/releases/v1.3.2.md](docs/releases/v1.3.2.md)
409
- - Stable archive: [docs/releases/v1.3.1.md](docs/releases/v1.3.1.md)
410
- - Full release archive: [docs/README.md#release-history](docs/README.md#release-history)
411
- - Archived prerelease: [docs/releases/v0.1.0-beta.0.md](docs/releases/v0.1.0-beta.0.md)
412
-
413
- ## License
414
-
415
- MIT License. See [LICENSE](LICENSE).
416
-
417
- <details>
418
- <summary><b>Legal</b></summary>
419
-
420
- - Not affiliated with OpenAI.
421
- - "ChatGPT", "Codex", and "OpenAI" are trademarks of OpenAI.
422
- - You assume responsibility for your own usage and compliance.
423
-
424
- </details>
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
+ - Optional loopback-only local bridge for `/health`, `/v1/models`, and `/v1/responses`, protected by hashed local client tokens
33
+ - Reversible packaged Codex app bind and user-level launcher routing helpers that do not patch official app binaries
34
+ - Session affinity, live account sync, proactive refresh, and preemptive quota deferral controls
35
+ - Codex-oriented request/prompt compatibility with strict runtime handling and documented error contracts
36
+ - Stable docs for install, configuration, troubleshooting, upgrade, public API, storage paths, and release notes
37
+
38
+ ---
39
+
40
+ ## Why Developers Use It
41
+
42
+ `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.
43
+
44
+ ---
45
+
46
+ ## Current Architecture At A Glance
47
+
48
+ `codex-multi-auth` ships four global binaries:
49
+
50
+ | Binary | Purpose |
51
+ | --- | --- |
52
+ | `codex-multi-auth` | Primary account manager; accepts bare auth subcommands such as `login`, `status`, `switch`, `forecast`, and `rotation status` |
53
+ | `codex-multi-auth-codex` | Optional wrapper that handles `auth ...` locally and forwards every other command to the official Codex CLI |
54
+ | `mcodex` | Convenience launcher over `codex-multi-auth-codex` with optional `--monitor` and `--tmux` modes |
55
+ | `codex-multi-auth-app-launcher` | Optional desktop launcher helper for supported user-level shortcuts and wrapper apps |
56
+
57
+ 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.
58
+
59
+ ---
60
+
61
+ <details open>
62
+ <summary><b>Terms and Usage Notice</b></summary>
63
+
64
+ > [!CAUTION]
65
+ > This project uses OAuth account credentials and is intended for personal development use.
66
+ >
67
+ > By using this package, you acknowledge:
68
+ > - This is an independent open-source project, not an official OpenAI product
69
+ > - You are responsible for your own usage and policy compliance
70
+ > - For production/commercial workloads, use the OpenAI Platform API
71
+
72
+ </details>
73
+
74
+ ---
75
+
76
+ ## Installation
77
+
78
+ <details open>
79
+ <summary><b>For Humans</b></summary>
80
+
81
+ ### Option A: Standard install
82
+
83
+ ```bash
84
+ npm i -g codex-multi-auth
85
+ ```
86
+
87
+ ### Option B: Migrate from legacy scoped prerelease
88
+
89
+ ```bash
90
+ npm uninstall -g @ndycode/codex-multi-auth
91
+ npm i -g codex-multi-auth
92
+ ```
93
+
94
+ ### Option C: Verify wiring
95
+
96
+ `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.
97
+
98
+ ```bash
99
+ codex --version
100
+ codex-multi-auth --version
101
+ codex-multi-auth status
102
+ ```
103
+
104
+ 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.
105
+
106
+ </details>
107
+
108
+ <details>
109
+ <summary><b>For LLM Agents</b></summary>
110
+
111
+ ### Step-by-step
112
+
113
+ 1. Install global package:
114
+ - `npm i -g codex-multi-auth`
115
+ 2. Run first login flow with `codex-multi-auth login`
116
+ 3. Validate state with `codex-multi-auth status` and `codex-multi-auth check`
117
+ 4. Confirm routing with `codex-multi-auth forecast --live`
118
+
119
+ ### Verification
120
+
121
+ ```bash
122
+ codex-multi-auth status
123
+ codex-multi-auth check
124
+ ```
125
+
126
+ </details>
127
+
128
+ ---
129
+
130
+ ## Quick Start
131
+
132
+ Install and sign in:
133
+
134
+ ```bash
135
+ npm i -g @openai/codex
136
+ npm i -g codex-multi-auth
137
+ codex-multi-auth login
138
+ ```
139
+
140
+ If you already installed the official native CLI via Homebrew or a release binary, you only need:
141
+
142
+ ```bash
143
+ npm i -g codex-multi-auth
144
+ codex-multi-auth login
145
+ ```
146
+
147
+ Verify the manager and the new account:
148
+
149
+ ```bash
150
+ codex-multi-auth status
151
+ codex-multi-auth check
152
+ ```
153
+
154
+ Use these next:
155
+
156
+ ```bash
157
+ codex-multi-auth list
158
+ codex-multi-auth switch 2
159
+ codex-multi-auth forecast --live
160
+ ```
161
+
162
+ If browser launch is blocked, use the alternate login paths in [docs/getting-started.md](docs/getting-started.md#alternate-login-paths).
163
+ For remote or headless shells, prefer `codex-multi-auth login --device-auth`.
164
+
165
+ ---
166
+
167
+ ## Command Toolkit
168
+
169
+ ### Start here
170
+
171
+ | Command | What it answers |
172
+ | --- | --- |
173
+ | `codex-multi-auth login` | How do I add or re-open the account menu? |
174
+ | `codex-multi-auth status` | What does my account pool, pin, and runtime metrics look like? (`list` is the same output) |
175
+ | `codex-multi-auth check` | Do live health probes against my saved accounts succeed? |
176
+
177
+ ### Daily use
178
+
179
+ | Command | What it answers |
180
+ | --- | --- |
181
+ | `codex-multi-auth list` | Alias of `status` — full account/runtime dump |
182
+ | `codex-multi-auth switch <index>` | How do I pin a different saved account for runtime routing? |
183
+ | `codex-multi-auth unpin` | How do I clear a manual pin and resume hybrid rotation? |
184
+ | `codex-multi-auth workspace <account> [workspace]` | How do I list or set an account's active workspace? |
185
+ | `codex-multi-auth best --live` | How do I switch to the forecast-best account (clears any pin)? |
186
+ | `codex-multi-auth-codex --account <index\|email\|id>` | How do I force one account for a single wrapper session without changing my default? |
187
+ | `codex-multi-auth forecast --live` | Which account looks best for the next session? |
188
+
189
+ ### Repair
190
+
191
+ | Command | What it answers |
192
+ | --- | --- |
193
+ | `codex-multi-auth verify-flagged` | Can any previously flagged account be restored? |
194
+ | `codex-multi-auth verify --paths` | Do my storage path chain and sandbox probes still pass self-test? |
195
+ | `codex-multi-auth fix --dry-run` | What safe storage or account repairs are available? |
196
+ | `codex-multi-auth doctor --fix` | Can the CLI diagnose and apply the safest fixes now? |
197
+ | `codex-multi-auth uninstall` | Remove residual artifacts (run BEFORE `npm uninstall`; npm@7+ no longer fires `preuninstall`) |
198
+
199
+ ### Advanced
200
+
201
+ | Command | What it answers |
202
+ | --- | --- |
203
+ | `codex-multi-auth report --live --json` | How do I get the full machine-readable health report? |
204
+ | `codex-multi-auth fix --live --model gpt-5.5` | How do I run live repair probes with a chosen model? |
205
+ | `codex-multi-auth why-selected --json` | Which account does the selector pick now, and why? |
206
+ | `codex-multi-auth usage --since 24h --by project` | What local usage has been recorded recently? |
207
+ | `codex-multi-auth monitor --json` | What is the combined usage, policy, quota, runtime, and project state? |
208
+ | `codex-multi-auth bridge token create --label local-client` | How do I create a local bridge bearer token? |
209
+ | `codex-multi-auth integrations --kind python` | How do I generate local bridge client snippets? |
210
+ | `codex-multi-auth rotation status` | Is live runtime account rotation enabled for forwarded Codex sessions? |
211
+
212
+ ### Reliability behavior
213
+
214
+ - whole-pool replay is disabled by default when every account is rate-limited
215
+ - active requests use a bounded outbound request budget so one prompt cannot walk the full pool indefinitely
216
+ - repeated cross-account 5xx bursts trigger a short cooldown instead of continuing aggressive rotation
217
+ - proactive refresh is staggered to reduce background refresh bursts
218
+ - `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
219
+
220
+ ---
221
+
222
+ ## Dashboard Hotkeys
223
+
224
+ ### Main dashboard
225
+
226
+ | Key | Action |
227
+ | --- | --- |
228
+ | `Up` / `Down` | Move selection |
229
+ | `Enter` | Select/open |
230
+ | `1-9` | Quick switch |
231
+ | `/` | Search |
232
+ | `?` | Toggle help |
233
+ | `Q` | Back/cancel |
234
+
235
+ ### Account details
236
+
237
+ | Key | Action |
238
+ | --- | --- |
239
+ | `S` | Set current account |
240
+ | `R` | Refresh/re-login account |
241
+ | `E` | Enable/disable account |
242
+ | `D` | Delete account |
243
+
244
+ ---
245
+
246
+ ## Storage Paths
247
+
248
+ | File | Default path |
249
+ | --- | --- |
250
+ | Settings | `~/.codex/multi-auth/settings.json` |
251
+ | Accounts | `~/.codex/multi-auth/openai-codex-accounts.json` |
252
+ | Flagged accounts | `~/.codex/multi-auth/openai-codex-flagged-accounts.json` |
253
+ | Quota cache | `~/.codex/multi-auth/quota-cache.json` |
254
+ | Runtime observability | `~/.codex/multi-auth/runtime-observability.json` |
255
+ | Usage ledger | `~/.codex/multi-auth/usage/usage-ledger.jsonl` |
256
+ | Account policies | `~/.codex/multi-auth/account-policies.json` |
257
+ | Routing profiles | `~/.codex/multi-auth/routing-profiles.json` |
258
+ | Budget guards | `~/.codex/multi-auth/budget-guards.json` |
259
+ | Local client tokens | `~/.codex/multi-auth/local-client-tokens.json` |
260
+ | Runtime app helper status | `~/.codex/multi-auth/runtime-rotation-app-helper.json` |
261
+ | Persistent app bind state/logs | `~/.codex/multi-auth/app-bind/` |
262
+ | Logs | `~/.codex/multi-auth/logs/codex-plugin/` |
263
+ | Per-project accounts | `~/.codex/multi-auth/projects/<project-key>/openai-codex-accounts.json` |
264
+
265
+ Override root with `CODEX_MULTI_AUTH_DIR=<path>`.
266
+
267
+ ---
268
+
269
+ ## Configuration
270
+
271
+ Primary config root:
272
+ - `~/.codex/multi-auth/settings.json`
273
+ - or `CODEX_MULTI_AUTH_DIR/settings.json` when custom root is set
274
+
275
+ Selected runtime/environment overrides:
276
+
277
+ | Variable | Effect |
278
+ | --- | --- |
279
+ | `CODEX_MULTI_AUTH_DIR` | Override settings/accounts root |
280
+ | `CODEX_MULTI_AUTH_CONFIG_PATH` | Prefer this config file when it exists (also the save target when set) |
281
+ | `CODEX_MODE=0/1` | Disable/enable Codex mode |
282
+ | `CODEX_MULTI_AUTH_FORCE_ACCOUNT=<index\|email\|id>` | Force one account for a single `codex-multi-auth-codex` run (ephemeral; requires rotation proxy) |
283
+ | `CODEX_MULTI_AUTH_BYPASS=1` | Skip multi-auth intercept and forward straight to official Codex |
284
+ | `CODEX_MULTI_AUTH_RUNTIME_ROTATION_PROXY=0/1` | Opt out/in of live Responses proxy rotation for forwarded Codex CLI/app sessions |
285
+ | `CODEX_MULTI_AUTH_APP_ROTATION_IDLE_MS=<ms>` | Override automatic Codex app helper idle shutdown |
286
+ | `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 |
287
+ | `CODEX_MULTI_AUTH_APP_LAUNCHER_INSTALL=0/1` | Opt out/in of routing supported app shortcuts on first CLI run or rotation enable |
288
+ | `CODEX_TUI_V2=0/1` | Disable/enable TUI v2 |
289
+ | `CODEX_TUI_COLOR_PROFILE=truecolor\|ansi256\|ansi16` | TUI color profile |
290
+ | `CODEX_TUI_GLYPHS=ascii\|unicode\|auto` | TUI glyph style |
291
+ | `CODEX_AUTH_BACKGROUND_RESPONSES=0/1` | Opt in/out of stateful Responses `background: true` compatibility |
292
+ | `CODEX_AUTH_FETCH_TIMEOUT_MS=<ms>` | Request timeout override |
293
+ | `CODEX_AUTH_STREAM_STALL_TIMEOUT_MS=<ms>` | Stream stall timeout override |
294
+
295
+ Validate config after changes:
296
+
297
+ ```bash
298
+ codex-multi-auth status
299
+ codex-multi-auth check
300
+ codex-multi-auth forecast --live
301
+ ```
302
+
303
+ 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.
304
+
305
+ 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.
306
+
307
+ 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.
308
+
309
+ ---
310
+
311
+ ## Experimental Settings Highlights
312
+
313
+ The Settings menu now includes an `Experimental` section for staged features:
314
+
315
+ - preview-first sync into `oc-chatgpt-multi-auth`
316
+ - named local pool backup export with filename prompt
317
+ - refresh guard toggle and interval controls moved out of Backend Controls
318
+
319
+ These flows are intentionally non-destructive by default: sync previews before apply, destination-only accounts are preserved, and backup filename collisions fail safely.
320
+
321
+ ---
322
+
323
+ ## Troubleshooting
324
+
325
+ <details open>
326
+ <summary><b>60-second recovery</b></summary>
327
+
328
+ ```bash
329
+ codex-multi-auth doctor --fix
330
+ codex-multi-auth check
331
+ codex-multi-auth forecast --live
332
+ ```
333
+
334
+ If still broken:
335
+
336
+ ```bash
337
+ codex-multi-auth login
338
+ ```
339
+
340
+ </details>
341
+
342
+ <details>
343
+ <summary><b>Common symptoms</b></summary>
344
+
345
+ - `codex-multi-auth` unrecognized: run `where codex-multi-auth` or `which codex-multi-auth`, then follow `docs/troubleshooting.md` for install checks
346
+ - Switch succeeds but wrong account appears active: run `codex-multi-auth switch <index>`, then restart session
347
+ - Requests fail fast with a pool cooldown message: wait for the cooldown window or inspect `codex-multi-auth status`
348
+ - Requests fail fast after repeated upstream 5xx errors: inspect `codex-multi-auth report --json` for runtime traffic and cooldown details
349
+ - 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
350
+ - OAuth callback on port `1455` fails: free the port and re-run `codex-multi-auth login`
351
+ - 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
352
+ - 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
353
+ - `missing field id_token` / `token_expired` / `refresh_token_reused`: re-login affected account
354
+
355
+ </details>
356
+
357
+ <details>
358
+ <summary><b>Diagnostics pack</b></summary>
359
+
360
+ ```bash
361
+ codex-multi-auth list
362
+ codex-multi-auth status
363
+ codex-multi-auth check
364
+ codex-multi-auth verify-flagged --json
365
+ codex-multi-auth forecast --live
366
+ codex-multi-auth fix --dry-run
367
+ codex-multi-auth report --live --json
368
+ codex-multi-auth doctor --json
369
+ ```
370
+
371
+ </details>
372
+
373
+ ---
374
+
375
+ ## Documentation
376
+
377
+ - Docs portal: [docs/README.md](docs/README.md)
378
+ - Getting started: [docs/getting-started.md](docs/getting-started.md)
379
+ - Features: [docs/features.md](docs/features.md)
380
+ - Configuration: [docs/configuration.md](docs/configuration.md)
381
+ - Troubleshooting: [docs/troubleshooting.md](docs/troubleshooting.md)
382
+ - Commands reference: [docs/reference/commands.md](docs/reference/commands.md)
383
+ - Public API contract: [docs/reference/public-api.md](docs/reference/public-api.md)
384
+ - Error contracts: [docs/reference/error-contracts.md](docs/reference/error-contracts.md)
385
+ - Settings reference: [docs/reference/settings.md](docs/reference/settings.md)
386
+ - Storage paths: [docs/reference/storage-paths.md](docs/reference/storage-paths.md)
387
+ - Upgrade guide: [docs/upgrade.md](docs/upgrade.md)
388
+ - Privacy: [docs/privacy.md](docs/privacy.md)
389
+
390
+ ---
391
+
392
+ ## Release Notes
393
+
394
+ - Current stable: [docs/releases/v2.7.0.md](docs/releases/v2.7.0.md) — install via `npm i -g codex-multi-auth`
395
+ - Previous stable: [docs/releases/v2.6.0.md](docs/releases/v2.6.0.md)
396
+ - Previous stable: [docs/releases/v2.5.0.md](docs/releases/v2.5.0.md)
397
+ - Previous stable: [docs/releases/v2.4.0.md](docs/releases/v2.4.0.md)
398
+ - Previous stable: [docs/releases/v2.3.3.md](docs/releases/v2.3.3.md)
399
+ - Previous stable: [docs/releases/v2.3.2.md](docs/releases/v2.3.2.md)
400
+ - Previous stable: [docs/releases/v2.3.1.md](docs/releases/v2.3.1.md)
401
+ - Previous stable: [docs/releases/v2.3.0.md](docs/releases/v2.3.0.md)
402
+ - Previous stable: [docs/releases/v2.2.2.md](docs/releases/v2.2.2.md)
403
+ - Previous stable: [docs/releases/v2.2.1.md](docs/releases/v2.2.1.md)
404
+ - Previous stable: [docs/releases/v2.2.0.md](docs/releases/v2.2.0.md)
405
+ - Previous stable: [docs/releases/v2.1.12.md](docs/releases/v2.1.12.md)
406
+ - Earlier stable: [docs/releases/v2.1.11.md](docs/releases/v2.1.11.md)
407
+ - Earlier stable: [docs/releases/v2.1.10.md](docs/releases/v2.1.10.md)
408
+ - Earlier stable: [docs/releases/v2.1.8.md](docs/releases/v2.1.8.md)
409
+ - Earlier stable: [docs/releases/v2.1.7.md](docs/releases/v2.1.7.md)
410
+ - Earlier stable: [docs/releases/v2.1.6.md](docs/releases/v2.1.6.md)
411
+ - Earlier stable: [docs/releases/v2.1.5.md](docs/releases/v2.1.5.md)
412
+ - Earlier stable: [docs/releases/v2.1.4.md](docs/releases/v2.1.4.md)
413
+ - Earlier stable: [docs/releases/v2.1.3.md](docs/releases/v2.1.3.md)
414
+ - Earlier stable: [docs/releases/v2.1.2.md](docs/releases/v2.1.2.md)
415
+ - Earlier stable: [docs/releases/v2.1.1.md](docs/releases/v2.1.1.md)
416
+ - Earlier stable: [docs/releases/v2.1.0.md](docs/releases/v2.1.0.md)
417
+ - Earlier stable: [docs/releases/v1.3.2.md](docs/releases/v1.3.2.md)
418
+ - Stable archive: [docs/releases/v1.3.1.md](docs/releases/v1.3.1.md)
419
+ - Full release archive: [docs/README.md#release-history](docs/README.md#release-history)
420
+ - Archived prerelease: [docs/releases/v0.1.0-beta.0.md](docs/releases/v0.1.0-beta.0.md)
421
+
422
+ ## License
423
+
424
+ MIT License. See [LICENSE](LICENSE).
425
+
426
+ <details>
427
+ <summary><b>Legal</b></summary>
428
+
429
+ - Not affiliated with OpenAI.
430
+ - "ChatGPT", "Codex", and "OpenAI" are trademarks of OpenAI.
431
+ - You assume responsibility for your own usage and compliance.
432
+
433
+ </details>