codex-multi-auth 2.17.0 → 2.17.3

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 (450) hide show
  1. package/.codex-plugin/plugin.json +9 -9
  2. package/LICENSE +21 -21
  3. package/README.md +142 -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/index.d.ts +0 -1
  11. package/dist/lib/account-policy.d.ts +18 -2
  12. package/dist/lib/account-policy.js +97 -40
  13. package/dist/lib/accounts/rate-limits.d.ts +0 -1
  14. package/dist/lib/accounts.d.ts +1 -8
  15. package/dist/lib/accounts.d.ts.map +1 -1
  16. package/dist/lib/accounts.js +7 -19
  17. package/dist/lib/api-route-store.d.ts +0 -1
  18. package/dist/lib/audit.d.ts +0 -1
  19. package/dist/lib/audit.js +43 -12
  20. package/dist/lib/auth/account-access.d.ts +0 -1
  21. package/dist/lib/auth/account-access.js +5 -1
  22. package/dist/lib/auth/auth.d.ts +4 -3
  23. package/dist/lib/auth/auth.js +220 -28
  24. package/dist/lib/auth/browser.d.ts +0 -1
  25. package/dist/lib/auth/callback-guidance.d.ts +0 -1
  26. package/dist/lib/auth/device-auth.d.ts +0 -1
  27. package/dist/lib/auth/index.d.ts +0 -1
  28. package/dist/lib/auth/org-override.d.ts +0 -1
  29. package/dist/lib/auth/server.d.ts +1 -2
  30. package/dist/lib/auth/server.js +100 -53
  31. package/dist/lib/auth/token-utils.d.ts +0 -1
  32. package/dist/lib/auth-rate-limit.d.ts +0 -1
  33. package/dist/lib/budget-guard.d.ts +16 -2
  34. package/dist/lib/budget-guard.js +123 -43
  35. package/dist/lib/capability-policy.d.ts +0 -1
  36. package/dist/lib/circuit-breaker.d.ts +20 -1
  37. package/dist/lib/circuit-breaker.js +24 -5
  38. package/dist/lib/cli.d.ts +0 -1
  39. package/dist/lib/codex-cli/index.d.ts +0 -1
  40. package/dist/lib/codex-cli/observability.d.ts +0 -1
  41. package/dist/lib/codex-cli/state.d.ts +0 -1
  42. package/dist/lib/codex-cli/sync.d.ts +0 -1
  43. package/dist/lib/codex-cli/writer.d.ts +0 -1
  44. package/dist/lib/codex-manager/account-credentials.d.ts +0 -1
  45. package/dist/lib/codex-manager/account-manager-commands.d.ts +0 -1
  46. package/dist/lib/codex-manager/account-pool-write.d.ts +0 -1
  47. package/dist/lib/codex-manager/active-account-sync.d.ts +6 -0
  48. package/dist/lib/codex-manager/active-account-sync.js +336 -0
  49. package/dist/lib/codex-manager/api-login-menu.d.ts +0 -1
  50. package/dist/lib/codex-manager/backend-category-entry.d.ts +0 -1
  51. package/dist/lib/codex-manager/backend-category-helpers.d.ts +0 -1
  52. package/dist/lib/codex-manager/backend-category-prompt.d.ts +0 -1
  53. package/dist/lib/codex-manager/backend-settings-controller.d.ts +0 -1
  54. package/dist/lib/codex-manager/backend-settings-entry.d.ts +0 -1
  55. package/dist/lib/codex-manager/backend-settings-helpers.d.ts +0 -1
  56. package/dist/lib/codex-manager/backend-settings-prompt.d.ts +0 -1
  57. package/dist/lib/codex-manager/backend-settings-schema.d.ts +0 -1
  58. package/dist/lib/codex-manager/behavior-settings-panel.d.ts +0 -1
  59. package/dist/lib/codex-manager/commands/account.d.ts +8 -3
  60. package/dist/lib/codex-manager/commands/account.js +46 -34
  61. package/dist/lib/codex-manager/commands/best.d.ts +0 -1
  62. package/dist/lib/codex-manager/commands/bridge.d.ts +0 -1
  63. package/dist/lib/codex-manager/commands/budget.d.ts +8 -3
  64. package/dist/lib/codex-manager/commands/budget.js +6 -4
  65. package/dist/lib/codex-manager/commands/check.d.ts +0 -1
  66. package/dist/lib/codex-manager/commands/config-explain.d.ts +0 -1
  67. package/dist/lib/codex-manager/commands/debug-bundle.d.ts +0 -1
  68. package/dist/lib/codex-manager/commands/forecast.d.ts +1 -2
  69. package/dist/lib/codex-manager/commands/forecast.d.ts.map +1 -1
  70. package/dist/lib/codex-manager/commands/forecast.js +2 -2
  71. package/dist/lib/codex-manager/commands/history.d.ts +0 -1
  72. package/dist/lib/codex-manager/commands/init-config.d.ts +0 -1
  73. package/dist/lib/codex-manager/commands/integrations.d.ts +0 -1
  74. package/dist/lib/codex-manager/commands/limits.d.ts +0 -1
  75. package/dist/lib/codex-manager/commands/models.d.ts +0 -1
  76. package/dist/lib/codex-manager/commands/monitor.d.ts +0 -1
  77. package/dist/lib/codex-manager/commands/report.d.ts +0 -1
  78. package/dist/lib/codex-manager/commands/resets.d.ts +0 -1
  79. package/dist/lib/codex-manager/commands/resets.js +9 -1
  80. package/dist/lib/codex-manager/commands/rotation.d.ts +0 -1
  81. package/dist/lib/codex-manager/commands/status.d.ts +0 -1
  82. package/dist/lib/codex-manager/commands/switch.d.ts +0 -1
  83. package/dist/lib/codex-manager/commands/uninstall.d.ts +0 -1
  84. package/dist/lib/codex-manager/commands/unpin.d.ts +0 -1
  85. package/dist/lib/codex-manager/commands/usage.d.ts +0 -1
  86. package/dist/lib/codex-manager/commands/verify.d.ts +0 -1
  87. package/dist/lib/codex-manager/commands/why-selected.d.ts +0 -1
  88. package/dist/lib/codex-manager/commands/workspace.d.ts +0 -1
  89. package/dist/lib/codex-manager/dashboard-display-panel.d.ts +0 -1
  90. package/dist/lib/codex-manager/dashboard-formatters.d.ts +0 -1
  91. package/dist/lib/codex-manager/dashboard-settings-controller.d.ts +0 -1
  92. package/dist/lib/codex-manager/dashboard-settings-data.d.ts +0 -1
  93. package/dist/lib/codex-manager/dashboard-settings-entry.d.ts +0 -1
  94. package/dist/lib/codex-manager/experimental-settings-entry.d.ts +0 -1
  95. package/dist/lib/codex-manager/experimental-settings-prompt.d.ts +0 -1
  96. package/dist/lib/codex-manager/experimental-settings-schema.d.ts +0 -1
  97. package/dist/lib/codex-manager/experimental-sync-target-entry.d.ts +0 -1
  98. package/dist/lib/codex-manager/experimental-sync-target.d.ts +0 -1
  99. package/dist/lib/codex-manager/forecast-report-shared.d.ts +0 -1
  100. package/dist/lib/codex-manager/formatters/account-formatters.d.ts +0 -1
  101. package/dist/lib/codex-manager/formatters/index.d.ts +0 -1
  102. package/dist/lib/codex-manager/formatters/model-formatters.d.ts +0 -1
  103. package/dist/lib/codex-manager/formatters/quota-formatters.d.ts +0 -1
  104. package/dist/lib/codex-manager/formatters/text-style.d.ts +0 -1
  105. package/dist/lib/codex-manager/health-check.d.ts +0 -1
  106. package/dist/lib/codex-manager/health-check.js +1 -1
  107. package/dist/lib/codex-manager/help.d.ts +0 -1
  108. package/dist/lib/codex-manager/login-action-panel.d.ts +0 -1
  109. package/dist/lib/codex-manager/login-flow.d.ts +0 -1
  110. package/dist/lib/codex-manager/login-menu-actions.d.ts +0 -1
  111. package/dist/lib/codex-manager/login-menu-data.d.ts +0 -1
  112. package/dist/lib/codex-manager/login-menu-data.d.ts.map +1 -1
  113. package/dist/lib/codex-manager/login-menu-data.js +7 -3
  114. package/dist/lib/codex-manager/login-oauth.d.ts +0 -1
  115. package/dist/lib/codex-manager/login-workspace-choice.d.ts +0 -1
  116. package/dist/lib/codex-manager/manual-callback.d.ts +0 -1
  117. package/dist/lib/codex-manager/persist-selected-account.d.ts +0 -1
  118. package/dist/lib/codex-manager/quota-cache-helpers.d.ts +7 -2
  119. package/dist/lib/codex-manager/quota-cache-helpers.d.ts.map +1 -1
  120. package/dist/lib/codex-manager/quota-cache-helpers.js +34 -19
  121. package/dist/lib/codex-manager/rate-limit-markers.d.ts +0 -1
  122. package/dist/lib/codex-manager/repair-commands.d.ts +0 -1
  123. package/dist/lib/codex-manager/repair-commands.js +1 -1
  124. package/dist/lib/codex-manager/settings-hub/backend.d.ts +0 -1
  125. package/dist/lib/codex-manager/settings-hub/dashboard.d.ts +0 -1
  126. package/dist/lib/codex-manager/settings-hub/experimental.d.ts +0 -1
  127. package/dist/lib/codex-manager/settings-hub/index.d.ts +0 -1
  128. package/dist/lib/codex-manager/settings-hub/shared.d.ts +0 -1
  129. package/dist/lib/codex-manager/settings-hub-entry.d.ts +0 -1
  130. package/dist/lib/codex-manager/settings-hub-menu.d.ts +0 -1
  131. package/dist/lib/codex-manager/settings-hub-prompt.d.ts +0 -1
  132. package/dist/lib/codex-manager/settings-hub.d.ts +0 -1
  133. package/dist/lib/codex-manager/settings-panels.d.ts +0 -1
  134. package/dist/lib/codex-manager/settings-persist-utils.d.ts +0 -1
  135. package/dist/lib/codex-manager/settings-preview.d.ts +0 -1
  136. package/dist/lib/codex-manager/settings-write-queue.d.ts +0 -1
  137. package/dist/lib/codex-manager/statusline-settings-panel.d.ts +0 -1
  138. package/dist/lib/codex-manager/theme-settings-panel.d.ts +0 -1
  139. package/dist/lib/codex-manager/unified-settings-controller.d.ts +0 -1
  140. package/dist/lib/codex-manager/unified-settings-entry.d.ts +0 -1
  141. package/dist/lib/codex-manager.d.ts +1 -2
  142. package/dist/lib/codex-manager.js +5 -95
  143. package/dist/lib/concurrency.d.ts +0 -1
  144. package/dist/lib/config-schema.d.ts +0 -1
  145. package/dist/lib/config.d.ts +0 -1
  146. package/dist/lib/config.js +46 -241
  147. package/dist/lib/constants.d.ts +0 -1
  148. package/dist/lib/context-budget/model-context-windows.d.ts +0 -1
  149. package/dist/lib/context-budget-guard.d.ts +0 -1
  150. package/dist/lib/context-budget-response.d.ts +0 -1
  151. package/dist/lib/context-budget-response.js +8 -8
  152. package/dist/lib/context-overflow.d.ts +0 -1
  153. package/dist/lib/context-overflow.js +10 -10
  154. package/dist/lib/dashboard-settings.d.ts +0 -1
  155. package/dist/lib/entitlement-cache.d.ts +0 -1
  156. package/dist/lib/env-parsing.d.ts +13 -1
  157. package/dist/lib/env-parsing.js +21 -0
  158. package/dist/lib/errors.d.ts +0 -1
  159. package/dist/lib/forecast.d.ts +0 -1
  160. package/dist/lib/fs-retry.d.ts +0 -1
  161. package/dist/lib/health.d.ts +0 -1
  162. package/dist/lib/index.d.ts +0 -1
  163. package/dist/lib/integration-generators.d.ts +0 -1
  164. package/dist/lib/live-account-sync.d.ts +0 -1
  165. package/dist/lib/local-bridge.d.ts +0 -1
  166. package/dist/lib/local-bridge.js +4 -1
  167. package/dist/lib/local-client-tokens.d.ts +0 -1
  168. package/dist/lib/local-client-tokens.js +125 -30
  169. package/dist/lib/logger.d.ts +0 -1
  170. package/dist/lib/logger.js +11 -1
  171. package/dist/lib/model-capability-matrix.d.ts +0 -1
  172. package/dist/lib/model-route-policy.d.ts +1 -2
  173. package/dist/lib/named-backup-export.d.ts +0 -1
  174. package/dist/lib/oauth-success.html +125 -125
  175. package/dist/lib/oc-chatgpt-import-adapter.d.ts +0 -1
  176. package/dist/lib/oc-chatgpt-orchestrator.d.ts +0 -1
  177. package/dist/lib/oc-chatgpt-target-detection.d.ts +0 -1
  178. package/dist/lib/parallel-probe.d.ts +0 -1
  179. package/dist/lib/policy/runtime-policy-cache.d.ts +80 -0
  180. package/dist/lib/policy/runtime-policy-cache.js +310 -0
  181. package/dist/lib/policy/runtime-policy.d.ts +1 -2
  182. package/dist/lib/policy/runtime-policy.js +46 -19
  183. package/dist/lib/preemptive-quota-scheduler.d.ts +0 -1
  184. package/dist/lib/proactive-refresh.d.ts +0 -1
  185. package/dist/lib/prompts/codex-host-bridge.d.ts +0 -1
  186. package/dist/lib/prompts/codex-host-bridge.js +138 -138
  187. package/dist/lib/prompts/codex.d.ts +0 -1
  188. package/dist/lib/prompts/codex.js +79 -79
  189. package/dist/lib/prompts/fetch-utils.d.ts +0 -1
  190. package/dist/lib/prompts/host-codex-prompt.d.ts +0 -1
  191. package/dist/lib/quota-cache.d.ts +7 -4
  192. package/dist/lib/quota-cache.d.ts.map +1 -1
  193. package/dist/lib/quota-cache.js +117 -61
  194. package/dist/lib/quota-probe.d.ts +0 -1
  195. package/dist/lib/quota-probe.js +5 -2
  196. package/dist/lib/quota-readiness.d.ts +7 -3
  197. package/dist/lib/quota-readiness.d.ts.map +1 -1
  198. package/dist/lib/quota-readiness.js +25 -4
  199. package/dist/lib/recovery/constants.d.ts +0 -1
  200. package/dist/lib/recovery/storage.d.ts +0 -1
  201. package/dist/lib/recovery/types.d.ts +0 -1
  202. package/dist/lib/recovery.d.ts +0 -1
  203. package/dist/lib/redaction.d.ts +0 -1
  204. package/dist/lib/refresh-guardian.d.ts +0 -1
  205. package/dist/lib/refresh-lease.d.ts +0 -1
  206. package/dist/lib/refresh-queue.d.ts +0 -1
  207. package/dist/lib/request/client-cancellation.d.ts +0 -1
  208. package/dist/lib/request/error-classification.d.ts +0 -1
  209. package/dist/lib/request/failover-config.d.ts +0 -1
  210. package/dist/lib/request/failure-policy.d.ts +0 -1
  211. package/dist/lib/request/fetch-helpers.d.ts +0 -1
  212. package/dist/lib/request/headers.d.ts +0 -1
  213. package/dist/lib/request/helpers/input-utils.d.ts +0 -1
  214. package/dist/lib/request/helpers/input-utils.js +88 -34
  215. package/dist/lib/request/helpers/model-map.d.ts +0 -1
  216. package/dist/lib/request/helpers/tool-utils.d.ts +0 -1
  217. package/dist/lib/request/helpers/tool-utils.js +421 -4
  218. package/dist/lib/request/index.d.ts +0 -1
  219. package/dist/lib/request/rate-limit-backoff.d.ts +0 -1
  220. package/dist/lib/request/rate-limit-decision.d.ts +0 -1
  221. package/dist/lib/request/request-attempt-budget.d.ts +0 -1
  222. package/dist/lib/request/request-init.d.ts +0 -1
  223. package/dist/lib/request/request-resilience.d.ts +0 -1
  224. package/dist/lib/request/request-transformer.d.ts +0 -1
  225. package/dist/lib/request/request-transformer.js +50 -25
  226. package/dist/lib/request/response-compaction.d.ts +0 -1
  227. package/dist/lib/request/response-handler.d.ts +0 -1
  228. package/dist/lib/request/response-metadata.d.ts +0 -1
  229. package/dist/lib/request/response-outcome.d.ts +0 -1
  230. package/dist/lib/request/stream-failover-runtime.d.ts +0 -1
  231. package/dist/lib/request/stream-failover.d.ts +0 -1
  232. package/dist/lib/request/stream-failover.js +28 -4
  233. package/dist/lib/request/token-refresh.d.ts +0 -1
  234. package/dist/lib/request/url-rewriting.d.ts +0 -1
  235. package/dist/lib/request/wait-utils.d.ts +0 -1
  236. package/dist/lib/rotation.d.ts +0 -1
  237. package/dist/lib/routing-mutex.d.ts +0 -1
  238. package/dist/lib/routing-profiles.d.ts +16 -2
  239. package/dist/lib/routing-profiles.js +119 -44
  240. package/dist/lib/runtime/account-check-helpers.d.ts +0 -1
  241. package/dist/lib/runtime/account-check-types.d.ts +0 -1
  242. package/dist/lib/runtime/account-check.d.ts +0 -1
  243. package/dist/lib/runtime/account-manager-cache-entry.d.ts +0 -1
  244. package/dist/lib/runtime/account-manager-cache.d.ts +0 -1
  245. package/dist/lib/runtime/account-model-catalog.d.ts +1 -2
  246. package/dist/lib/runtime/account-pool.d.ts +0 -1
  247. package/dist/lib/runtime/account-reset-credits.d.ts +0 -1
  248. package/dist/lib/runtime/account-reset-credits.js +8 -2
  249. package/dist/lib/runtime/account-scope.d.ts +0 -1
  250. package/dist/lib/runtime/account-select-event.d.ts +0 -1
  251. package/dist/lib/runtime/account-selection.d.ts +0 -1
  252. package/dist/lib/runtime/account-state.d.ts +0 -1
  253. package/dist/lib/runtime/account-status.d.ts +0 -1
  254. package/dist/lib/runtime/account-storage-scope-entry.d.ts +0 -1
  255. package/dist/lib/runtime/api-model-capabilities.d.ts +0 -1
  256. package/dist/lib/runtime/api-model-runtime.d.ts +0 -1
  257. package/dist/lib/runtime/app-bind.d.ts +0 -1
  258. package/dist/lib/runtime/app-bind.d.ts.map +1 -1
  259. package/dist/lib/runtime/app-bind.js +10 -2
  260. package/dist/lib/runtime/app-helper-selection.d.ts +0 -1
  261. package/dist/lib/runtime/auth-facade.d.ts +0 -1
  262. package/dist/lib/runtime/automatic-account-checks.d.ts +5 -2
  263. package/dist/lib/runtime/automatic-account-checks.d.ts.map +1 -1
  264. package/dist/lib/runtime/automatic-account-checks.js +29 -2
  265. package/dist/lib/runtime/automatic-subscription-checks.d.ts +1 -2
  266. package/dist/lib/runtime/automatic-subscription-checks.d.ts.map +1 -1
  267. package/dist/lib/runtime/automatic-subscription-checks.js +13 -16
  268. package/dist/lib/runtime/browser-oauth-flow.d.ts +0 -1
  269. package/dist/lib/runtime/capability-boost.d.ts +0 -1
  270. package/dist/lib/runtime/catalog-capabilities.d.ts +0 -1
  271. package/dist/lib/runtime/config-toml.d.ts +0 -1
  272. package/dist/lib/runtime/context-budget-settings.d.ts +0 -1
  273. package/dist/lib/runtime/event-handler.d.ts +0 -1
  274. package/dist/lib/runtime/first-run.d.ts +0 -1
  275. package/dist/lib/runtime/flagged-verify-types.d.ts +0 -1
  276. package/dist/lib/runtime/hydrate-emails.d.ts +0 -1
  277. package/dist/lib/runtime/inference-activity.d.ts +0 -1
  278. package/dist/lib/runtime/live-sync-entry.d.ts +0 -1
  279. package/dist/lib/runtime/live-sync.d.ts +0 -1
  280. package/dist/lib/runtime/loader-setup.d.ts +0 -1
  281. package/dist/lib/runtime/login-menu-accounts.d.ts +0 -1
  282. package/dist/lib/runtime/manual-oauth-flow.d.ts +0 -1
  283. package/dist/lib/runtime/model-discovery-status.d.ts +2 -3
  284. package/dist/lib/runtime/native-account-storage.d.ts +0 -1
  285. package/dist/lib/runtime/native-account-sync.d.ts +0 -1
  286. package/dist/lib/runtime/native-binding-lock.d.ts +0 -1
  287. package/dist/lib/runtime/native-client-auth.d.ts +0 -1
  288. package/dist/lib/runtime/native-provider-config.d.ts +0 -1
  289. package/dist/lib/runtime/native-rate-limits.d.ts +2 -1
  290. package/dist/lib/runtime/native-rate-limits.js +23 -6
  291. package/dist/lib/runtime/preemptive-quota.d.ts +0 -1
  292. package/dist/lib/runtime/quota-headers.d.ts +0 -1
  293. package/dist/lib/runtime/quota-probe.d.ts +0 -1
  294. package/dist/lib/runtime/quota-settings.d.ts +0 -1
  295. package/dist/lib/runtime/refresh-guardian-entry.d.ts +0 -1
  296. package/dist/lib/runtime/refresh-guardian.d.ts +0 -1
  297. package/dist/lib/runtime/request-init.d.ts +0 -1
  298. package/dist/lib/runtime/reset-credit-routing.d.ts +0 -1
  299. package/dist/lib/runtime/reset-credits.d.ts +0 -1
  300. package/dist/lib/runtime/response-output-history.d.ts +0 -1
  301. package/dist/lib/runtime/responses-websocket.d.ts +0 -1
  302. package/dist/lib/runtime/resume-picker.d.ts +0 -1
  303. package/dist/lib/runtime/rotation-account-selection.d.ts +0 -1
  304. package/dist/lib/runtime/rotation-proxy-state.d.ts +0 -1
  305. package/dist/lib/runtime/rotation-server-types.d.ts +0 -1
  306. package/dist/lib/runtime/rotation-storage-meta.d.ts +0 -1
  307. package/dist/lib/runtime/rotation-token-refresh.d.ts +0 -1
  308. package/dist/lib/runtime/runtime-capability-failures.d.ts +0 -1
  309. package/dist/lib/runtime/runtime-current-account.d.ts +0 -1
  310. package/dist/lib/runtime/runtime-observability.d.ts +0 -1
  311. package/dist/lib/runtime/runtime-services.d.ts +0 -1
  312. package/dist/lib/runtime/session-affinity-entry.d.ts +0 -1
  313. package/dist/lib/runtime/session-recovery.d.ts +0 -1
  314. package/dist/lib/runtime/status-marker.d.ts +0 -1
  315. package/dist/lib/runtime/storage-scope.d.ts +0 -1
  316. package/dist/lib/runtime/subscription-first-use.d.ts +0 -1
  317. package/dist/lib/runtime/subscription-quota-event.d.ts +0 -1
  318. package/dist/lib/runtime/subscription-quota-order.d.ts +0 -1
  319. package/dist/lib/runtime/toast.d.ts +0 -1
  320. package/dist/lib/runtime/ui-runtime-entry.d.ts +0 -1
  321. package/dist/lib/runtime/ui-runtime.d.ts +0 -1
  322. package/dist/lib/runtime/verify-flagged.d.ts +0 -1
  323. package/dist/lib/runtime/workspace-model-scopes.d.ts +0 -1
  324. package/dist/lib/runtime-constants.d.ts +0 -1
  325. package/dist/lib/runtime-paths.d.ts +0 -1
  326. package/dist/lib/runtime-rotation-proxy.d.ts +1 -1
  327. package/dist/lib/runtime-rotation-proxy.js +136 -3
  328. package/dist/lib/schemas.d.ts +35 -13
  329. package/dist/lib/schemas.js +19 -2
  330. package/dist/lib/session-affinity.d.ts +0 -1
  331. package/dist/lib/shutdown.d.ts +0 -1
  332. package/dist/lib/storage/account-clear-entry.d.ts +0 -1
  333. package/dist/lib/storage/account-clear.d.ts +0 -1
  334. package/dist/lib/storage/account-match-utils.d.ts +0 -1
  335. package/dist/lib/storage/account-persistence.d.ts +0 -1
  336. package/dist/lib/storage/account-port.d.ts +0 -1
  337. package/dist/lib/storage/account-save-entry.d.ts +0 -1
  338. package/dist/lib/storage/account-save.d.ts +9 -2
  339. package/dist/lib/storage/account-save.js +4 -1
  340. package/dist/lib/storage/account-snapshot.d.ts +0 -1
  341. package/dist/lib/storage/backup-metadata-builder.d.ts +0 -1
  342. package/dist/lib/storage/backup-metadata.d.ts +0 -1
  343. package/dist/lib/storage/backup-paths.d.ts +0 -1
  344. package/dist/lib/storage/backup-restore.d.ts +0 -1
  345. package/dist/lib/storage/cache-artifacts.d.ts +0 -1
  346. package/dist/lib/storage/credential-sidecars.d.ts +0 -1
  347. package/dist/lib/storage/error-hints.d.ts +0 -1
  348. package/dist/lib/storage/file-lock.d.ts +0 -1
  349. package/dist/lib/storage/file-lock.js +33 -1
  350. package/dist/lib/storage/file-paths.d.ts +0 -1
  351. package/dist/lib/storage/fixture-guards.d.ts +0 -1
  352. package/dist/lib/storage/flagged-entry.d.ts +0 -1
  353. package/dist/lib/storage/flagged-load-entry.d.ts +0 -1
  354. package/dist/lib/storage/flagged-save-entry.d.ts +0 -1
  355. package/dist/lib/storage/flagged-storage-file.d.ts +0 -1
  356. package/dist/lib/storage/flagged-storage-io.d.ts +0 -1
  357. package/dist/lib/storage/flagged-storage.d.ts +0 -1
  358. package/dist/lib/storage/gitignore.d.ts +0 -1
  359. package/dist/lib/storage/hash.d.ts +0 -1
  360. package/dist/lib/storage/health.d.ts +0 -1
  361. package/dist/lib/storage/identity.d.ts +0 -1
  362. package/dist/lib/storage/import-export.d.ts +0 -1
  363. package/dist/lib/storage/json-store-lock.d.ts +105 -0
  364. package/dist/lib/storage/json-store-lock.js +259 -0
  365. package/dist/lib/storage/metadata-section.d.ts +0 -1
  366. package/dist/lib/storage/migrations.d.ts +0 -1
  367. package/dist/lib/storage/migrations.js +31 -18
  368. package/dist/lib/storage/named-backup-entry.d.ts +0 -1
  369. package/dist/lib/storage/named-backups-entry.d.ts +0 -1
  370. package/dist/lib/storage/named-backups.d.ts +0 -1
  371. package/dist/lib/storage/path-state.d.ts +0 -1
  372. package/dist/lib/storage/paths.d.ts +0 -1
  373. package/dist/lib/storage/pending-auth.d.ts +10 -3
  374. package/dist/lib/storage/pending-auth.d.ts.map +1 -1
  375. package/dist/lib/storage/pending-auth.js +33 -9
  376. package/dist/lib/storage/project-migration.d.ts +0 -1
  377. package/dist/lib/storage/public-types.d.ts +0 -1
  378. package/dist/lib/storage/record-identity.d.ts +15 -0
  379. package/dist/lib/storage/record-identity.d.ts.map +1 -0
  380. package/dist/lib/storage/record-identity.js +16 -0
  381. package/dist/lib/storage/record-utils.d.ts +0 -1
  382. package/dist/lib/storage/restore-assessment.d.ts +0 -1
  383. package/dist/lib/storage/restore-backup-entry.d.ts +0 -1
  384. package/dist/lib/storage/restore-metadata.d.ts +0 -1
  385. package/dist/lib/storage/save-retry.d.ts +0 -1
  386. package/dist/lib/storage/snapshot-inspectors.d.ts +0 -1
  387. package/dist/lib/storage/snapshot-merge.d.ts +0 -1
  388. package/dist/lib/storage/storage-parser.d.ts +2 -1
  389. package/dist/lib/storage/storage-parser.js +10 -2
  390. package/dist/lib/storage/transactions.d.ts +0 -1
  391. package/dist/lib/storage.d.ts +15 -2
  392. package/dist/lib/storage.js +612 -25
  393. package/dist/lib/synthetic-response.d.ts +0 -1
  394. package/dist/lib/table-formatter.d.ts +0 -1
  395. package/dist/lib/temp-path.d.ts +0 -1
  396. package/dist/lib/tools/hashline-tools.d.ts +0 -1
  397. package/dist/lib/types.d.ts +0 -1
  398. package/dist/lib/ui/ansi.d.ts +0 -1
  399. package/dist/lib/ui/auth-menu-builder.d.ts +0 -1
  400. package/dist/lib/ui/auth-menu.d.ts +0 -1
  401. package/dist/lib/ui/check-progress.d.ts +0 -1
  402. package/dist/lib/ui/confirm.d.ts +0 -1
  403. package/dist/lib/ui/display-width.d.ts +0 -1
  404. package/dist/lib/ui/format.d.ts +0 -1
  405. package/dist/lib/ui/index.d.ts +0 -1
  406. package/dist/lib/ui/runtime.d.ts +0 -1
  407. package/dist/lib/ui/select.d.ts +0 -1
  408. package/dist/lib/ui/theme.d.ts +0 -1
  409. package/dist/lib/ui/ui-copy.d.ts +0 -1
  410. package/dist/lib/unified-settings.d.ts +13 -11
  411. package/dist/lib/unified-settings.js +22 -14
  412. package/dist/lib/update-notice.d.ts +0 -1
  413. package/dist/lib/usage/index.d.ts +0 -1
  414. package/dist/lib/usage/ledger.d.ts +0 -1
  415. package/dist/lib/usage/pricing.d.ts +0 -1
  416. package/dist/lib/usage/redaction.d.ts +0 -1
  417. package/dist/lib/usage/stream-usage-deferral.d.ts +0 -1
  418. package/dist/lib/usage/types.d.ts +0 -1
  419. package/dist/lib/usage/usage-extraction.d.ts +0 -1
  420. package/dist/lib/utils.d.ts +21 -1
  421. package/dist/lib/utils.js +31 -0
  422. package/dist/lib/wsl.d.ts +0 -1
  423. package/node_modules/@codex-ai/plugin/dist/index.d.ts +2 -2
  424. package/node_modules/@codex-ai/plugin/dist/index.js +2 -2
  425. package/node_modules/@codex-ai/plugin/dist/tool.d.ts +42 -42
  426. package/node_modules/@codex-ai/plugin/dist/tool.js +29 -29
  427. package/node_modules/@codex-ai/plugin/package.json +9 -9
  428. package/node_modules/@codex-ai/sdk/dist/index.d.ts +4 -4
  429. package/node_modules/@codex-ai/sdk/dist/index.js +2 -2
  430. package/node_modules/@codex-ai/sdk/package.json +8 -8
  431. package/package.json +206 -200
  432. package/scripts/codex-app-launcher.js +653 -653
  433. package/scripts/codex-app-router.js +373 -373
  434. package/scripts/codex-bin-resolver.js +332 -313
  435. package/scripts/codex-multi-auth.js +65 -59
  436. package/scripts/codex-routing.js +62 -62
  437. package/scripts/codex.js +6923 -6642
  438. package/scripts/install-codex-auth-utils.js +213 -213
  439. package/scripts/mcodex.js +367 -367
  440. package/scripts/postinstall.js +114 -114
  441. package/scripts/preuninstall.js +265 -265
  442. package/skills/codex-auth-setup/SKILL.md +73 -0
  443. package/vendor/codex-ai-plugin/dist/index.d.ts +2 -2
  444. package/vendor/codex-ai-plugin/dist/index.js +2 -2
  445. package/vendor/codex-ai-plugin/dist/tool.d.ts +42 -42
  446. package/vendor/codex-ai-plugin/dist/tool.js +29 -29
  447. package/vendor/codex-ai-plugin/package.json +9 -9
  448. package/vendor/codex-ai-sdk/dist/index.d.ts +4 -4
  449. package/vendor/codex-ai-sdk/dist/index.js +2 -2
  450. package/vendor/codex-ai-sdk/package.json +8 -8
package/README.md CHANGED
@@ -1,484 +1,142 @@
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
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 keeps a named pool of ChatGPT sign-ins on your machine, lets you switch the active account, and — when you run Codex through its optional wrapper — rotates accounts across live requests through a loopback-only proxy. It never installs or shadows a `codex` binary; the official OpenAI install keeps owning that command.
9
+
10
+ Use it when one Codex account is not enough: you hit rate limits or quota windows, you split work across organizations and workspaces, you want per-project account pools, or you run unattended agents that need JSON diagnostics and safe repair commands instead of one opaque auth file.
11
+
12
+ ## What it does
13
+
14
+ - **Account pool** — OAuth login for multiple ChatGPT accounts, stored locally under `~/.codex/multi-auth` (files `0600`, directories `0700`), with per-project pools under `projects/<project-key>/`.
15
+ - **Switching and selection** — pin an account, pick the forecast-best one, or let health- and quota-aware hybrid selection rotate for you.
16
+ - **Runtime rotation** — a default-on, loopback-only proxy that forwards Responses API and model-discovery traffic through the best available account during wrapper-launched Codex sessions.
17
+ - **Diagnostics and repair** — status, live health checks, quota forecasts, JSON reports, and `fix`/`doctor`/`verify` commands that recover stale or damaged local state.
18
+ - **Local governance** — file-backed usage ledger, budget guards, account tags/weights/pause/drain policies, routing profiles, and an optional loopback bridge with bearer tokens for local OpenAI-compatible clients.
19
+ - **Desktop routing (optional)** — a reversible bind of the packaged Codex app plus user-level launcher helpers; official app binaries are never patched.
20
+
21
+ ## The four binaries
22
+
23
+ | Binary | Role |
24
+ | --- | --- |
25
+ | `codex-multi-auth` | The account manager. Runs all 31 management subcommands locally (`login`, `status`, `switch`, `forecast`, `rotation`, `fix`, ...). The `auth` prefix is optional: `codex-multi-auth login` ≡ `codex-multi-auth auth login`. |
26
+ | `codex-multi-auth-codex` | Opt-in wrapper. Handles `auth ...` locally and forwards every other command to the official Codex CLI, enabling the rotation proxy for request-bearing commands. |
27
+ | `mcodex` | Convenience launcher over the wrapper, with optional `--monitor` and `--tmux` modes. No account logic of its own. |
28
+ | `codex-multi-auth-app-launcher` | User-level OS launcher routing helper (Windows shortcut, macOS wrapper app, Linux `.desktop`). |
29
+
30
+ ## Install
31
+
32
+ Requirements: Node.js >= 18.17, and the official Codex CLI on `PATH` (`npm i -g @openai/codex`, Homebrew, or a release binary).
33
+
34
+ ```bash
35
+ npm i -g codex-multi-auth
36
+ ```
37
+
38
+ > [!NOTE]
39
+ > The legacy scoped prerelease `@ndycode/codex-multi-auth` is migration-only. Install `codex-multi-auth` for all new setups; see [docs/upgrade.md](docs/upgrade.md) to migrate.
40
+
41
+ ## Quick start (5 minutes)
42
+
43
+ ```bash
44
+ # 1. Sign in a ChatGPT account (browser OAuth, loopback callback on localhost:1455)
45
+ codex-multi-auth login
46
+
47
+ # 2. Repeat login to add more accounts, then inspect the pool
48
+ codex-multi-auth status
49
+
50
+ # 3. Probe account health and preview which account would serve next
51
+ codex-multi-auth check
52
+ codex-multi-auth forecast --live
53
+ ```
54
+
55
+ Headless or remote shell? Use `codex-multi-auth login --device-auth` — no callback port needed. Blocked browser? See [alternate login paths](docs/getting-started.md#log-in).
56
+
57
+ Run Codex through the wrapper so requests rotate across the pool:
58
+
59
+ ```bash
60
+ codex-multi-auth-codex # interactive TUI, rotation on by default
61
+ codex-multi-auth-codex exec "summarize this repo"
62
+ mcodex # same wrapper, shorter name
63
+ ```
64
+
65
+ ## Command map
66
+
67
+ `codex-multi-auth` ships 31 subcommands. The full surface — every flag, hotkey, and JSON mode — is in [docs/reference/commands.md](docs/reference/commands.md).
68
+
69
+ | Group | Commands | Purpose |
70
+ | --- | --- | --- |
71
+ | Accounts | `login`, `list`, `status`, `switch <i>`, `unpin`, `workspace` | sign in, inspect the pool, pin or switch the active account, pick workspaces |
72
+ | Selection | `forecast`, `best`, `why-selected`, `check`, `limits`, `models` | preview, explain, and probe which account serves the next request |
73
+ | Runtime | `rotation status` `enable` `disable` `bind-app` `unbind-app` `reset-runtime` `reset-rate-limits` | inspect and control live rotation and the app bind |
74
+ | Repair | `fix`, `doctor`, `verify`, `verify-flagged`, `uninstall` | diagnose and repair storage, flagged accounts, and install residue |
75
+ | Governance | `usage`, `budget`, `account`, `monitor`, `history`, `resets` | usage ledger, budget limits, tags/weights/pause/drain, snapshots |
76
+ | Local clients | `bridge`, `integrations` | bearer tokens and client snippets for the loopback bridge |
77
+ | Config | `config explain` `template`, `init-config`, `debug bundle`, `features` | effective-config report, config templates, sanitized debug bundle |
78
+
79
+ Everyday examples:
80
+
81
+ ```bash
82
+ codex-multi-auth switch 2 # pin account #2
83
+ codex-multi-auth report --live --json # full machine-readable health report
84
+ codex-multi-auth fix --live --model gpt-5.5 # live repair probes with a chosen model
85
+ codex-multi-auth doctor --fix # diagnose and apply the safest fixes
86
+ codex-multi-auth usage --since 24h --by model # local usage ledger summary
87
+ codex-multi-auth rotation status # is live rotation enabled?
88
+ ```
89
+
90
+ ## Runtime rotation, in one paragraph
91
+
92
+ With rotation on (the default), request-bearing wrapper commands — `exec`, `review`, `resume`, `fork`, `app`, and the bare TUI — route through a local proxy that picks the healthiest account per request, refreshes tokens as needed, and fails over across the pool on rate limits within a bounded retry budget. The proxy listens on loopback only, authenticates its own clients with a per-process token, forwards only Responses API and model-discovery calls, and never writes account emails or tokens to client headers or logs. Plain `codex` is never touched: rotation exists only inside `codex-multi-auth-codex`/`mcodex` sessions, or inside the packaged desktop app after an opt-in, reversible bind. Turn it off with `codex-multi-auth rotation disable` or `CODEX_MULTI_AUTH_RUNTIME_ROTATION_PROXY=0`.
93
+
94
+ ## Where state lives
95
+
96
+ | What | Path |
97
+ | --- | --- |
98
+ | Accounts, settings, quota cache, usage ledger, policies, observability | `~/.codex/multi-auth/` |
99
+ | Per-project account pools | `~/.codex/multi-auth/projects/<project-key>/` |
100
+ | Official Codex state (kept by the official install) | `~/.codex/` |
101
+ | Override the multi-auth root | `CODEX_MULTI_AUTH_DIR=<path>` |
102
+
103
+ Full path map: [docs/reference/storage-paths.md](docs/reference/storage-paths.md).
104
+
105
+ ## Troubleshooting in 60 seconds
106
+
107
+ ```bash
108
+ codex-multi-auth doctor --fix
109
+ codex-multi-auth check
110
+ codex-multi-auth forecast --live
111
+ ```
112
+
113
+ Common symptoms — wrong active account, OAuth callback port `1455` already bound, Windows/WSL port contention, `EBUSY`/`EPERM` on Windows — are covered in [docs/troubleshooting.md](docs/troubleshooting.md).
114
+
115
+ ## Documentation
116
+
117
+ | Doc | What it covers |
118
+ | --- | --- |
119
+ | [docs/index.md](docs/index.md) | Product overview — what it does at runtime and who needs it |
120
+ | [docs/README.md](docs/README.md) | Full documentation portal and sitemap |
121
+ | [docs/getting-started.md](docs/getting-started.md) | Install, first login, day-1 commands |
122
+ | [docs/features.md](docs/features.md) | Feature tour |
123
+ | [docs/architecture.md](docs/architecture.md) | Components, request flow, trust boundaries |
124
+ | [docs/configuration.md](docs/configuration.md) | Settings and environment overrides |
125
+ | [docs/reference/commands.md](docs/reference/commands.md) | Every command, flag, and hotkey |
126
+ | [docs/reference/public-api.md](docs/reference/public-api.md) | Public API stability tiers and semver contract |
127
+ | [docs/troubleshooting.md](docs/troubleshooting.md) | Recovery playbooks |
128
+ | [docs/faq.md](docs/faq.md) | Common questions |
129
+ | [docs/upgrade.md](docs/upgrade.md) | Version and legacy-package migration |
130
+ | [docs/privacy.md](docs/privacy.md) | Data handling and local storage behavior |
131
+
132
+ ## Release notes
133
+
134
+ - Current stable: [v2.17.3](docs/releases/v2.17.3.md) — `npm i -g codex-multi-auth`
135
+ - Earlier stable lines: [v2.6.0](docs/releases/v2.6.0.md), [v2.5.0](docs/releases/v2.5.0.md)
136
+ - Full release archive: [docs/README.md#release-history](docs/README.md#release-history)
137
+
138
+ ## Terms and license
139
+
140
+ `codex-multi-auth` uses OAuth account credentials and is intended for personal development use. It is an independent open-source project, not an official OpenAI product; you are responsible for your own usage and policy compliance, and for production or commercial workloads you should use the OpenAI Platform API. "ChatGPT", "Codex", and "OpenAI" are trademarks of OpenAI.
141
+
142
+ MIT license — see [LICENSE](LICENSE).