codex-multi-auth 2.3.0-beta.0 → 2.3.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (470) hide show
  1. package/.codex-plugin/plugin.json +1 -1
  2. package/README.md +4 -3
  3. package/config/schema/config.schema.json +268 -21
  4. package/dist/index.js +0 -1
  5. package/dist/lib/account-policy.js +0 -1
  6. package/dist/lib/accounts/rate-limits.js +0 -1
  7. package/dist/lib/accounts.d.ts +3 -8
  8. package/dist/lib/accounts.d.ts.map +1 -1
  9. package/dist/lib/accounts.js +2 -3
  10. package/dist/lib/audit.js +0 -1
  11. package/dist/lib/auth/auth.js +0 -1
  12. package/dist/lib/auth/browser.js +0 -1
  13. package/dist/lib/auth/device-auth.js +0 -1
  14. package/dist/lib/auth/index.js +0 -1
  15. package/dist/lib/auth/org-override.js +0 -1
  16. package/dist/lib/auth/server.js +0 -1
  17. package/dist/lib/auth/token-utils.js +0 -1
  18. package/dist/lib/auth-rate-limit.js +0 -1
  19. package/dist/lib/budget-guard.js +0 -1
  20. package/dist/lib/capability-policy.js +0 -1
  21. package/dist/lib/circuit-breaker.js +0 -1
  22. package/dist/lib/cli.js +1 -2
  23. package/dist/lib/codex-cli/index.js +0 -1
  24. package/dist/lib/codex-cli/observability.js +0 -1
  25. package/dist/lib/codex-cli/state.js +0 -1
  26. package/dist/lib/codex-cli/sync.d.ts +2 -2
  27. package/dist/lib/codex-cli/sync.d.ts.map +1 -1
  28. package/dist/lib/codex-cli/sync.js +1 -2
  29. package/dist/lib/codex-cli/writer.js +0 -1
  30. package/dist/lib/codex-manager/account-credentials.d.ts +13 -0
  31. package/dist/lib/codex-manager/account-credentials.d.ts.map +1 -0
  32. package/dist/lib/codex-manager/account-credentials.js +55 -0
  33. package/dist/lib/codex-manager/account-manager-commands.js +0 -1
  34. package/dist/lib/codex-manager/account-pool-write.d.ts +95 -0
  35. package/dist/lib/codex-manager/account-pool-write.d.ts.map +1 -0
  36. package/dist/lib/codex-manager/account-pool-write.js +165 -0
  37. package/dist/lib/codex-manager/account-pool-write.js.map +1 -0
  38. package/dist/lib/codex-manager/backend-category-entry.js +0 -1
  39. package/dist/lib/codex-manager/backend-category-helpers.js +0 -1
  40. package/dist/lib/codex-manager/backend-category-prompt.js +0 -1
  41. package/dist/lib/codex-manager/backend-settings-controller.js +0 -1
  42. package/dist/lib/codex-manager/backend-settings-entry.js +0 -1
  43. package/dist/lib/codex-manager/backend-settings-helpers.js +0 -1
  44. package/dist/lib/codex-manager/backend-settings-prompt.js +0 -1
  45. package/dist/lib/codex-manager/backend-settings-schema.js +0 -1
  46. package/dist/lib/codex-manager/behavior-settings-panel.d.ts +1 -1
  47. package/dist/lib/codex-manager/behavior-settings-panel.d.ts.map +1 -1
  48. package/dist/lib/codex-manager/behavior-settings-panel.js +0 -1
  49. package/dist/lib/codex-manager/commands/account.js +0 -1
  50. package/dist/lib/codex-manager/commands/best.d.ts +8 -0
  51. package/dist/lib/codex-manager/commands/best.d.ts.map +1 -1
  52. package/dist/lib/codex-manager/commands/best.js +64 -1
  53. package/dist/lib/codex-manager/commands/bridge.js +0 -1
  54. package/dist/lib/codex-manager/commands/budget.js +0 -1
  55. package/dist/lib/codex-manager/commands/check.js +0 -1
  56. package/dist/lib/codex-manager/commands/config-explain.js +0 -1
  57. package/dist/lib/codex-manager/commands/debug-bundle.js +0 -1
  58. package/dist/lib/codex-manager/commands/forecast.js +0 -1
  59. package/dist/lib/codex-manager/commands/init-config.js +0 -1
  60. package/dist/lib/codex-manager/commands/integrations.js +0 -1
  61. package/dist/lib/codex-manager/commands/models.js +0 -1
  62. package/dist/lib/codex-manager/commands/monitor.js +0 -1
  63. package/dist/lib/codex-manager/commands/report.js +0 -1
  64. package/dist/lib/codex-manager/commands/rotation.d.ts.map +1 -1
  65. package/dist/lib/codex-manager/commands/rotation.js +1 -4
  66. package/dist/lib/codex-manager/commands/status.js +0 -1
  67. package/dist/lib/codex-manager/commands/switch.js +0 -1
  68. package/dist/lib/codex-manager/commands/uninstall.d.ts.map +1 -1
  69. package/dist/lib/codex-manager/commands/uninstall.js +2 -33
  70. package/dist/lib/codex-manager/commands/unpin.js +0 -1
  71. package/dist/lib/codex-manager/commands/usage.js +0 -1
  72. package/dist/lib/codex-manager/commands/verify.js +0 -1
  73. package/dist/lib/codex-manager/commands/why-selected.js +0 -1
  74. package/dist/lib/codex-manager/commands/workspace.js +0 -1
  75. package/dist/lib/codex-manager/dashboard-display-panel.d.ts +1 -1
  76. package/dist/lib/codex-manager/dashboard-display-panel.d.ts.map +1 -1
  77. package/dist/lib/codex-manager/dashboard-display-panel.js +0 -1
  78. package/dist/lib/codex-manager/dashboard-formatters.js +0 -1
  79. package/dist/lib/codex-manager/dashboard-settings-controller.js +0 -1
  80. package/dist/lib/codex-manager/dashboard-settings-data.js +0 -1
  81. package/dist/lib/codex-manager/dashboard-settings-entry.js +0 -1
  82. package/dist/lib/codex-manager/experimental-settings-entry.js +0 -1
  83. package/dist/lib/codex-manager/experimental-settings-prompt.js +0 -1
  84. package/dist/lib/codex-manager/experimental-settings-schema.js +1 -2
  85. package/dist/lib/codex-manager/experimental-sync-target-entry.js +0 -1
  86. package/dist/lib/codex-manager/experimental-sync-target.js +0 -1
  87. package/dist/lib/codex-manager/forecast-report-commands.js +0 -1
  88. package/dist/lib/codex-manager/forecast-report-shared.d.ts +2 -2
  89. package/dist/lib/codex-manager/forecast-report-shared.d.ts.map +1 -1
  90. package/dist/lib/codex-manager/forecast-report-shared.js +5 -21
  91. package/dist/lib/codex-manager/formatters/account-formatters.d.ts +11 -0
  92. package/dist/lib/codex-manager/formatters/account-formatters.d.ts.map +1 -0
  93. package/dist/lib/codex-manager/formatters/account-formatters.js +79 -0
  94. package/dist/lib/codex-manager/formatters/index.d.ts +5 -0
  95. package/dist/lib/codex-manager/formatters/index.d.ts.map +1 -0
  96. package/dist/lib/codex-manager/formatters/index.js +4 -0
  97. package/dist/lib/codex-manager/formatters/model-formatters.d.ts +12 -0
  98. package/dist/lib/codex-manager/formatters/model-formatters.d.ts.map +1 -0
  99. package/dist/lib/codex-manager/formatters/model-formatters.js +23 -0
  100. package/dist/lib/codex-manager/formatters/quota-formatters.d.ts +11 -0
  101. package/dist/lib/codex-manager/formatters/quota-formatters.d.ts.map +1 -0
  102. package/dist/lib/codex-manager/formatters/quota-formatters.js +104 -0
  103. package/dist/lib/codex-manager/formatters/text-style.d.ts +14 -0
  104. package/dist/lib/codex-manager/formatters/text-style.d.ts.map +1 -0
  105. package/dist/lib/codex-manager/formatters/text-style.js +111 -0
  106. package/dist/lib/codex-manager/health-check.d.ts +14 -0
  107. package/dist/lib/codex-manager/health-check.d.ts.map +1 -0
  108. package/dist/lib/codex-manager/health-check.js +278 -0
  109. package/dist/lib/codex-manager/help.js +0 -1
  110. package/dist/lib/codex-manager/login-action-panel.d.ts +4 -0
  111. package/dist/lib/codex-manager/login-action-panel.d.ts.map +1 -0
  112. package/dist/lib/codex-manager/login-action-panel.js +238 -0
  113. package/dist/lib/codex-manager/login-flow.d.ts +17 -0
  114. package/dist/lib/codex-manager/login-flow.d.ts.map +1 -0
  115. package/dist/lib/codex-manager/login-flow.js +387 -0
  116. package/dist/lib/codex-manager/login-menu-actions.d.ts +20 -0
  117. package/dist/lib/codex-manager/login-menu-actions.d.ts.map +1 -0
  118. package/dist/lib/codex-manager/login-menu-actions.js +303 -0
  119. package/dist/lib/codex-manager/login-menu-data.d.ts +19 -0
  120. package/dist/lib/codex-manager/login-menu-data.d.ts.map +1 -0
  121. package/dist/lib/codex-manager/login-menu-data.js +378 -0
  122. package/dist/lib/codex-manager/login-oauth.d.ts +55 -0
  123. package/dist/lib/codex-manager/login-oauth.d.ts.map +1 -0
  124. package/dist/lib/codex-manager/login-oauth.js +345 -0
  125. package/dist/lib/codex-manager/manual-callback.d.ts +33 -0
  126. package/dist/lib/codex-manager/manual-callback.d.ts.map +1 -0
  127. package/dist/lib/codex-manager/manual-callback.js +30 -0
  128. package/dist/lib/codex-manager/manual-callback.js.map +1 -0
  129. package/dist/lib/codex-manager/persist-selected-account.d.ts +24 -0
  130. package/dist/lib/codex-manager/persist-selected-account.d.ts.map +1 -0
  131. package/dist/lib/codex-manager/persist-selected-account.js +107 -0
  132. package/dist/lib/codex-manager/quota-cache-helpers.d.ts +18 -0
  133. package/dist/lib/codex-manager/quota-cache-helpers.d.ts.map +1 -0
  134. package/dist/lib/codex-manager/quota-cache-helpers.js +112 -0
  135. package/dist/lib/codex-manager/rate-limit-markers.js +0 -1
  136. package/dist/lib/codex-manager/repair-commands.js +0 -1
  137. package/dist/lib/codex-manager/settings-hub/backend.js +1 -2
  138. package/dist/lib/codex-manager/settings-hub/dashboard.js +1 -2
  139. package/dist/lib/codex-manager/settings-hub/experimental.js +1 -2
  140. package/dist/lib/codex-manager/settings-hub/index.js +1 -2
  141. package/dist/lib/codex-manager/settings-hub/shared.js +0 -1
  142. package/dist/lib/codex-manager/settings-hub-entry.js +0 -1
  143. package/dist/lib/codex-manager/settings-hub-menu.js +0 -1
  144. package/dist/lib/codex-manager/settings-hub-prompt.js +0 -1
  145. package/dist/lib/codex-manager/settings-hub.js +0 -1
  146. package/dist/lib/codex-manager/settings-panels.js +0 -1
  147. package/dist/lib/codex-manager/settings-persist-utils.js +0 -1
  148. package/dist/lib/codex-manager/settings-preview.js +0 -1
  149. package/dist/lib/codex-manager/settings-write-queue.js +0 -1
  150. package/dist/lib/codex-manager/statusline-order.js +0 -1
  151. package/dist/lib/codex-manager/statusline-settings-panel.d.ts +1 -1
  152. package/dist/lib/codex-manager/statusline-settings-panel.d.ts.map +1 -1
  153. package/dist/lib/codex-manager/statusline-settings-panel.js +0 -1
  154. package/dist/lib/codex-manager/theme-settings-panel.d.ts +1 -1
  155. package/dist/lib/codex-manager/theme-settings-panel.d.ts.map +1 -1
  156. package/dist/lib/codex-manager/theme-settings-panel.js +0 -1
  157. package/dist/lib/codex-manager/unified-settings-controller.js +0 -1
  158. package/dist/lib/codex-manager/unified-settings-entry.js +0 -1
  159. package/dist/lib/codex-manager.d.ts +2 -4
  160. package/dist/lib/codex-manager.d.ts.map +1 -1
  161. package/dist/lib/codex-manager.js +219 -2578
  162. package/dist/lib/codex-manager.js.map +1 -1
  163. package/dist/lib/config-schema.d.ts +32 -0
  164. package/dist/lib/config-schema.d.ts.map +1 -0
  165. package/dist/lib/config-schema.js +96 -0
  166. package/dist/lib/config.d.ts.map +1 -1
  167. package/dist/lib/config.js +60 -104
  168. package/dist/lib/constants.js +0 -1
  169. package/dist/lib/context-overflow.js +0 -1
  170. package/dist/lib/dashboard-settings.js +0 -1
  171. package/dist/lib/entitlement-cache.js +0 -1
  172. package/dist/lib/env-parsing.js +0 -1
  173. package/dist/lib/errors.js +0 -1
  174. package/dist/lib/forecast.js +0 -1
  175. package/dist/lib/fs-retry.d.ts +46 -0
  176. package/dist/lib/fs-retry.d.ts.map +1 -1
  177. package/dist/lib/fs-retry.js +74 -6
  178. package/dist/lib/health.js +0 -1
  179. package/dist/lib/index.js +0 -1
  180. package/dist/lib/integration-generators.js +0 -1
  181. package/dist/lib/live-account-sync.js +0 -1
  182. package/dist/lib/local-bridge.js +0 -1
  183. package/dist/lib/local-client-tokens.js +0 -1
  184. package/dist/lib/logger.js +0 -1
  185. package/dist/lib/model-capability-matrix.js +0 -1
  186. package/dist/lib/named-backup-export.js +0 -1
  187. package/dist/lib/oc-chatgpt-import-adapter.js +0 -1
  188. package/dist/lib/oc-chatgpt-orchestrator.js +0 -1
  189. package/dist/lib/oc-chatgpt-target-detection.js +0 -1
  190. package/dist/lib/parallel-probe.js +0 -1
  191. package/dist/lib/policy/runtime-policy.js +0 -1
  192. package/dist/lib/preemptive-quota-scheduler.js +0 -1
  193. package/dist/lib/proactive-refresh.js +0 -1
  194. package/dist/lib/prompts/codex-host-bridge.js +0 -1
  195. package/dist/lib/prompts/codex.d.ts +3 -11
  196. package/dist/lib/prompts/codex.d.ts.map +1 -1
  197. package/dist/lib/prompts/codex.js +4 -12
  198. package/dist/lib/prompts/fetch-utils.js +0 -1
  199. package/dist/lib/prompts/host-codex-prompt.js +0 -1
  200. package/dist/lib/quota-cache.d.ts.map +1 -1
  201. package/dist/lib/quota-cache.js +15 -43
  202. package/dist/lib/quota-probe.js +0 -1
  203. package/dist/lib/quota-readiness.js +0 -1
  204. package/dist/lib/recovery/constants.js +0 -1
  205. package/dist/lib/recovery/index.js +0 -1
  206. package/dist/lib/recovery/storage.d.ts.map +1 -1
  207. package/dist/lib/recovery/storage.js +30 -51
  208. package/dist/lib/recovery/storage.js.map +1 -1
  209. package/dist/lib/recovery/types.js +0 -1
  210. package/dist/lib/recovery.js +0 -1
  211. package/dist/lib/refresh-guardian.js +0 -1
  212. package/dist/lib/refresh-lease.d.ts.map +1 -1
  213. package/dist/lib/refresh-lease.js +1 -4
  214. package/dist/lib/refresh-queue.js +0 -1
  215. package/dist/lib/request/error-classification.d.ts +75 -0
  216. package/dist/lib/request/error-classification.d.ts.map +1 -0
  217. package/dist/lib/request/error-classification.js +295 -0
  218. package/dist/lib/request/failover-config.js +0 -1
  219. package/dist/lib/request/failure-policy.js +0 -1
  220. package/dist/lib/request/fetch-helpers.d.ts +10 -114
  221. package/dist/lib/request/fetch-helpers.d.ts.map +1 -1
  222. package/dist/lib/request/fetch-helpers.js +7 -589
  223. package/dist/lib/request/headers.d.ts +33 -0
  224. package/dist/lib/request/headers.d.ts.map +1 -0
  225. package/dist/lib/request/headers.js +64 -0
  226. package/dist/lib/request/helpers/input-utils.js +0 -1
  227. package/dist/lib/request/helpers/model-map.d.ts +10 -0
  228. package/dist/lib/request/helpers/model-map.d.ts.map +1 -1
  229. package/dist/lib/request/helpers/model-map.js +11 -1
  230. package/dist/lib/request/helpers/tool-utils.js +0 -1
  231. package/dist/lib/request/index.js +0 -1
  232. package/dist/lib/request/rate-limit-backoff.js +0 -1
  233. package/dist/lib/request/rate-limit-decision.d.ts +28 -0
  234. package/dist/lib/request/rate-limit-decision.d.ts.map +1 -0
  235. package/dist/lib/request/rate-limit-decision.js +191 -0
  236. package/dist/lib/request/request-attempt-budget.js +0 -1
  237. package/dist/lib/request/request-init.js +0 -1
  238. package/dist/lib/request/request-resilience.js +0 -1
  239. package/dist/lib/request/request-transformer.js +0 -1
  240. package/dist/lib/request/response-compaction.js +0 -1
  241. package/dist/lib/request/response-handler.js +0 -1
  242. package/dist/lib/request/response-metadata.js +0 -1
  243. package/dist/lib/request/stream-failover-runtime.d.ts +8 -0
  244. package/dist/lib/request/stream-failover-runtime.d.ts.map +1 -0
  245. package/dist/lib/request/stream-failover-runtime.js +149 -0
  246. package/dist/lib/request/stream-failover.js +0 -1
  247. package/dist/lib/request/token-refresh.d.ts +30 -0
  248. package/dist/lib/request/token-refresh.d.ts.map +1 -0
  249. package/dist/lib/request/token-refresh.js +116 -0
  250. package/dist/lib/request/url-rewriting.d.ts +24 -0
  251. package/dist/lib/request/url-rewriting.d.ts.map +1 -0
  252. package/dist/lib/request/url-rewriting.js +153 -0
  253. package/dist/lib/request/wait-utils.js +0 -1
  254. package/dist/lib/rotation.d.ts +1 -1
  255. package/dist/lib/rotation.d.ts.map +1 -1
  256. package/dist/lib/rotation.js +0 -1
  257. package/dist/lib/routing-mutex.js +0 -1
  258. package/dist/lib/routing-profiles.js +0 -1
  259. package/dist/lib/runtime/account-check-helpers.js +0 -1
  260. package/dist/lib/runtime/account-check-types.js +0 -1
  261. package/dist/lib/runtime/account-check.js +0 -1
  262. package/dist/lib/runtime/account-health-check.js +0 -1
  263. package/dist/lib/runtime/account-manager-cache-entry.js +0 -1
  264. package/dist/lib/runtime/account-manager-cache.js +0 -1
  265. package/dist/lib/runtime/account-pool.js +0 -1
  266. package/dist/lib/runtime/account-scope.js +0 -1
  267. package/dist/lib/runtime/account-select-event.js +0 -1
  268. package/dist/lib/runtime/account-selection.js +0 -1
  269. package/dist/lib/runtime/account-state.js +0 -1
  270. package/dist/lib/runtime/account-status.js +0 -1
  271. package/dist/lib/runtime/account-storage-scope-entry.js +0 -1
  272. package/dist/lib/runtime/app-bind.js +0 -1
  273. package/dist/lib/runtime/auth-facade.js +0 -1
  274. package/dist/lib/runtime/browser-oauth-flow.js +0 -1
  275. package/dist/lib/runtime/capability-boost.js +0 -1
  276. package/dist/lib/runtime/config-toml.js +0 -1
  277. package/dist/lib/runtime/event-handler.js +0 -1
  278. package/dist/lib/runtime/first-run.d.ts +80 -0
  279. package/dist/lib/runtime/first-run.d.ts.map +1 -0
  280. package/dist/lib/runtime/first-run.js +327 -0
  281. package/dist/lib/runtime/flagged-verify-types.js +0 -1
  282. package/dist/lib/runtime/hydrate-emails.js +0 -1
  283. package/dist/lib/runtime/live-sync-entry.js +0 -1
  284. package/dist/lib/runtime/live-sync.js +0 -1
  285. package/dist/lib/runtime/loader-setup.js +0 -1
  286. package/dist/lib/runtime/login-menu-accounts.js +0 -1
  287. package/dist/lib/runtime/manual-oauth-flow.js +0 -1
  288. package/dist/lib/runtime/oauth-browser-flow.js +0 -1
  289. package/dist/lib/runtime/preemptive-quota.js +0 -1
  290. package/dist/lib/runtime/quota-headers.js +0 -1
  291. package/dist/lib/runtime/quota-probe.js +0 -1
  292. package/dist/lib/runtime/quota-settings.js +0 -1
  293. package/dist/lib/runtime/refresh-guardian-entry.js +0 -1
  294. package/dist/lib/runtime/refresh-guardian.js +0 -1
  295. package/dist/lib/runtime/request-init.js +0 -1
  296. package/dist/lib/runtime/rotation-account-selection.d.ts +38 -0
  297. package/dist/lib/runtime/rotation-account-selection.d.ts.map +1 -0
  298. package/dist/lib/runtime/rotation-account-selection.js +172 -0
  299. package/dist/lib/runtime/rotation-proxy-state.d.ts +54 -0
  300. package/dist/lib/runtime/rotation-proxy-state.d.ts.map +1 -0
  301. package/dist/lib/runtime/rotation-proxy-state.js +56 -0
  302. package/dist/lib/runtime/rotation-server-types.d.ts +57 -0
  303. package/dist/lib/runtime/rotation-server-types.d.ts.map +1 -0
  304. package/dist/lib/runtime/rotation-server-types.js +1 -0
  305. package/dist/lib/runtime/rotation-storage-meta.d.ts +40 -0
  306. package/dist/lib/runtime/rotation-storage-meta.d.ts.map +1 -0
  307. package/dist/lib/runtime/rotation-storage-meta.js +143 -0
  308. package/dist/lib/runtime/rotation-token-refresh.d.ts +25 -0
  309. package/dist/lib/runtime/rotation-token-refresh.d.ts.map +1 -0
  310. package/dist/lib/runtime/rotation-token-refresh.js +99 -0
  311. package/dist/lib/runtime/runtime-current-account.d.ts.map +1 -1
  312. package/dist/lib/runtime/runtime-current-account.js +1 -4
  313. package/dist/lib/runtime/runtime-observability.js +0 -1
  314. package/dist/lib/runtime/runtime-services.js +0 -1
  315. package/dist/lib/runtime/session-affinity-entry.js +0 -1
  316. package/dist/lib/runtime/session-affinity.js +0 -1
  317. package/dist/lib/runtime/session-recovery.js +0 -1
  318. package/dist/lib/runtime/status-marker.js +0 -1
  319. package/dist/lib/runtime/storage-scope.js +0 -1
  320. package/dist/lib/runtime/toast.js +0 -1
  321. package/dist/lib/runtime/ui-runtime-entry.js +0 -1
  322. package/dist/lib/runtime/ui-runtime.js +0 -1
  323. package/dist/lib/runtime/verify-flagged.js +0 -1
  324. package/dist/lib/runtime-constants.js +0 -1
  325. package/dist/lib/runtime-paths.js +0 -1
  326. package/dist/lib/runtime-rotation-proxy.d.ts +7 -124
  327. package/dist/lib/runtime-rotation-proxy.d.ts.map +1 -1
  328. package/dist/lib/runtime-rotation-proxy.js +614 -1353
  329. package/dist/lib/schemas.d.ts +3 -3
  330. package/dist/lib/schemas.js +1 -2
  331. package/dist/lib/session-affinity.js +0 -1
  332. package/dist/lib/shutdown.js +0 -1
  333. package/dist/lib/storage/account-clear-entry.js +0 -1
  334. package/dist/lib/storage/account-clear.js +0 -1
  335. package/dist/lib/storage/account-match-utils.js +0 -1
  336. package/dist/lib/storage/account-persistence.d.ts +1 -1
  337. package/dist/lib/storage/account-persistence.d.ts.map +1 -1
  338. package/dist/lib/storage/account-persistence.js +0 -1
  339. package/dist/lib/storage/account-port.d.ts +1 -1
  340. package/dist/lib/storage/account-port.d.ts.map +1 -1
  341. package/dist/lib/storage/account-port.js +0 -1
  342. package/dist/lib/storage/account-save-entry.d.ts +1 -1
  343. package/dist/lib/storage/account-save-entry.d.ts.map +1 -1
  344. package/dist/lib/storage/account-save-entry.js +0 -1
  345. package/dist/lib/storage/account-save.d.ts +1 -1
  346. package/dist/lib/storage/account-save.d.ts.map +1 -1
  347. package/dist/lib/storage/account-save.js +0 -1
  348. package/dist/lib/storage/account-snapshot.js +0 -1
  349. package/dist/lib/storage/backup-metadata-builder.d.ts +1 -1
  350. package/dist/lib/storage/backup-metadata-builder.d.ts.map +1 -1
  351. package/dist/lib/storage/backup-metadata-builder.js +0 -1
  352. package/dist/lib/storage/backup-metadata.d.ts +13 -0
  353. package/dist/lib/storage/backup-metadata.d.ts.map +1 -1
  354. package/dist/lib/storage/backup-metadata.js +0 -1
  355. package/dist/lib/storage/backup-paths.js +0 -1
  356. package/dist/lib/storage/backup-restore.d.ts +1 -1
  357. package/dist/lib/storage/backup-restore.d.ts.map +1 -1
  358. package/dist/lib/storage/backup-restore.js +0 -1
  359. package/dist/lib/storage/cache-artifacts.js +0 -1
  360. package/dist/lib/storage/error-hints.js +0 -1
  361. package/dist/lib/storage/file-paths.js +0 -1
  362. package/dist/lib/storage/fixture-guards.d.ts +1 -1
  363. package/dist/lib/storage/fixture-guards.d.ts.map +1 -1
  364. package/dist/lib/storage/fixture-guards.js +0 -1
  365. package/dist/lib/storage/flagged-entry.js +0 -1
  366. package/dist/lib/storage/flagged-load-entry.d.ts +1 -1
  367. package/dist/lib/storage/flagged-load-entry.d.ts.map +1 -1
  368. package/dist/lib/storage/flagged-load-entry.js +0 -1
  369. package/dist/lib/storage/flagged-save-entry.d.ts +1 -1
  370. package/dist/lib/storage/flagged-save-entry.d.ts.map +1 -1
  371. package/dist/lib/storage/flagged-save-entry.js +0 -1
  372. package/dist/lib/storage/flagged-storage-file.d.ts +1 -1
  373. package/dist/lib/storage/flagged-storage-file.d.ts.map +1 -1
  374. package/dist/lib/storage/flagged-storage-file.js +0 -1
  375. package/dist/lib/storage/flagged-storage-io.d.ts +1 -1
  376. package/dist/lib/storage/flagged-storage-io.d.ts.map +1 -1
  377. package/dist/lib/storage/flagged-storage-io.js +0 -1
  378. package/dist/lib/storage/flagged-storage.d.ts +1 -1
  379. package/dist/lib/storage/flagged-storage.d.ts.map +1 -1
  380. package/dist/lib/storage/flagged-storage.js +15 -2
  381. package/dist/lib/storage/flagged-storage.js.map +1 -1
  382. package/dist/lib/storage/gitignore.js +0 -1
  383. package/dist/lib/storage/hash.js +0 -1
  384. package/dist/lib/storage/health.js +0 -1
  385. package/dist/lib/storage/identity.js +0 -1
  386. package/dist/lib/storage/import-export.d.ts +1 -1
  387. package/dist/lib/storage/import-export.d.ts.map +1 -1
  388. package/dist/lib/storage/import-export.js +0 -1
  389. package/dist/lib/storage/metadata-section.js +0 -1
  390. package/dist/lib/storage/migrations.d.ts +5 -48
  391. package/dist/lib/storage/migrations.d.ts.map +1 -1
  392. package/dist/lib/storage/migrations.js +5 -2
  393. package/dist/lib/storage/named-backup-entry.js +0 -1
  394. package/dist/lib/storage/named-backups-entry.d.ts +1 -1
  395. package/dist/lib/storage/named-backups-entry.d.ts.map +1 -1
  396. package/dist/lib/storage/named-backups-entry.js +0 -1
  397. package/dist/lib/storage/named-backups.js +0 -1
  398. package/dist/lib/storage/path-state.js +0 -1
  399. package/dist/lib/storage/paths.js +0 -1
  400. package/dist/lib/storage/project-migration.d.ts +1 -1
  401. package/dist/lib/storage/project-migration.d.ts.map +1 -1
  402. package/dist/lib/storage/project-migration.js +0 -1
  403. package/dist/lib/storage/public-types.d.ts +70 -0
  404. package/dist/lib/storage/public-types.d.ts.map +1 -0
  405. package/dist/lib/storage/public-types.js +6 -0
  406. package/dist/lib/storage/record-utils.js +0 -1
  407. package/dist/lib/storage/restore-assessment.d.ts +1 -1
  408. package/dist/lib/storage/restore-assessment.d.ts.map +1 -1
  409. package/dist/lib/storage/restore-assessment.js +0 -1
  410. package/dist/lib/storage/restore-backup-entry.d.ts +1 -1
  411. package/dist/lib/storage/restore-backup-entry.d.ts.map +1 -1
  412. package/dist/lib/storage/restore-backup-entry.js +0 -1
  413. package/dist/lib/storage/restore-metadata.d.ts +1 -1
  414. package/dist/lib/storage/restore-metadata.d.ts.map +1 -1
  415. package/dist/lib/storage/restore-metadata.js +0 -1
  416. package/dist/lib/storage/restore.d.ts +1 -1
  417. package/dist/lib/storage/restore.d.ts.map +1 -1
  418. package/dist/lib/storage/restore.js +0 -1
  419. package/dist/lib/storage/save-retry.d.ts +10 -0
  420. package/dist/lib/storage/save-retry.d.ts.map +1 -0
  421. package/dist/lib/storage/save-retry.js +26 -0
  422. package/dist/lib/storage/snapshot-inspectors.d.ts +1 -1
  423. package/dist/lib/storage/snapshot-inspectors.d.ts.map +1 -1
  424. package/dist/lib/storage/snapshot-inspectors.js +0 -1
  425. package/dist/lib/storage/storage-parser.d.ts +1 -1
  426. package/dist/lib/storage/storage-parser.d.ts.map +1 -1
  427. package/dist/lib/storage/storage-parser.js +0 -1
  428. package/dist/lib/storage/transactions.d.ts +1 -1
  429. package/dist/lib/storage/transactions.d.ts.map +1 -1
  430. package/dist/lib/storage/transactions.js +0 -1
  431. package/dist/lib/storage.d.ts +3 -24
  432. package/dist/lib/storage.d.ts.map +1 -1
  433. package/dist/lib/storage.js +17 -32
  434. package/dist/lib/table-formatter.js +0 -1
  435. package/dist/lib/tools/hashline-tools.js +0 -1
  436. package/dist/lib/types.js +0 -1
  437. package/dist/lib/ui/ansi.js +0 -1
  438. package/dist/lib/ui/auth-menu-builder.d.ts +89 -0
  439. package/dist/lib/ui/auth-menu-builder.d.ts.map +1 -0
  440. package/dist/lib/ui/auth-menu-builder.js +350 -0
  441. package/dist/lib/ui/auth-menu.d.ts +2 -76
  442. package/dist/lib/ui/auth-menu.d.ts.map +1 -1
  443. package/dist/lib/ui/auth-menu.js +3 -349
  444. package/dist/lib/ui/confirm.js +0 -1
  445. package/dist/lib/ui/copy.d.ts +2 -0
  446. package/dist/lib/ui/copy.d.ts.map +1 -1
  447. package/dist/lib/ui/copy.js +2 -0
  448. package/dist/lib/ui/copy.js.map +1 -1
  449. package/dist/lib/ui/display-width.js +0 -1
  450. package/dist/lib/ui/format.js +0 -1
  451. package/dist/lib/ui/index.d.ts +10 -0
  452. package/dist/lib/ui/index.d.ts.map +1 -0
  453. package/dist/lib/ui/index.js +9 -0
  454. package/dist/lib/ui/runtime.js +0 -1
  455. package/dist/lib/ui/select.js +0 -1
  456. package/dist/lib/ui/theme.js +0 -1
  457. package/dist/lib/ui/ui-copy.d.ts +159 -0
  458. package/dist/lib/ui/ui-copy.d.ts.map +1 -0
  459. package/dist/lib/ui/ui-copy.js +163 -0
  460. package/dist/lib/unified-settings.js +0 -1
  461. package/dist/lib/update-notice.js +0 -1
  462. package/dist/lib/usage/index.js +0 -1
  463. package/dist/lib/usage/ledger.js +0 -1
  464. package/dist/lib/usage/pricing.js +0 -1
  465. package/dist/lib/usage/redaction.js +0 -1
  466. package/dist/lib/usage/types.js +0 -1
  467. package/dist/lib/utils.js +0 -1
  468. package/package.json +8 -8
  469. package/scripts/postinstall.js +34 -265
  470. package/scripts/preuninstall.js +2 -2
@@ -2,6 +2,7 @@ import { existsSync, promises as fs, readFileSync } from "node:fs";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { dirname, join } from "node:path";
4
4
  import { parseBooleanEnv } from "./env-parsing.js";
5
+ import { withRetry, withRetrySync } from "./fs-retry.js";
5
6
  import { logWarn } from "./logger.js";
6
7
  import { getCodexHomeDir, getCodexMultiAuthDir, getLegacyCodexDir, } from "./runtime-paths.js";
7
8
  import { getValidationErrors, PluginConfigSchema } from "./schemas.js";
@@ -32,33 +33,19 @@ const RETRYABLE_CONFIG_READ_CODES = new Set(["EBUSY", "EPERM", "EAGAIN"]);
32
33
  * attempts). ENOENT and SyntaxError are not retryable and propagate unchanged.
33
34
  */
34
35
  function readFileSyncWithConfigRetry(configPath) {
35
- const maxAttempts = 5;
36
- let lastError;
37
- for (let attempt = 0; attempt < maxAttempts; attempt += 1) {
38
- try {
39
- return readFileSync(configPath, "utf-8");
40
- }
41
- catch (error) {
42
- lastError = error;
43
- const code = error?.code;
44
- if (typeof code === "string" &&
45
- RETRYABLE_CONFIG_READ_CODES.has(code) &&
46
- attempt < maxAttempts - 1) {
47
- // Immediate retry — NOT a blocking sleep. loadPluginConfig() is
48
- // synchronous and runs on startup, so the previous Atomics.wait froze
49
- // the entire event loop for up to ~150ms on a transient Windows AV /
50
- // indexer lock. An immediate re-read costs microseconds and a brief
51
- // exclusive lock is typically released by the next attempt; if it
52
- // genuinely persists we fail fast (the caller falls back to defaults)
53
- // rather than stalling the process.
54
- continue;
55
- }
56
- throw error;
57
- }
58
- }
59
- // Exhausted attempts on a retryable code: surface the last error so the caller
60
- // classifies it (unreadable) instead of silently returning stale/empty content.
61
- throw lastError;
36
+ // Immediate retry (backoffMs: 0) — NOT a blocking sleep. loadPluginConfig()
37
+ // is synchronous and runs on startup, so the previous Atomics.wait froze the
38
+ // entire event loop for up to ~150ms on a transient Windows AV / indexer
39
+ // lock. An immediate re-read costs microseconds and a brief exclusive lock
40
+ // is typically released by the next attempt; if it genuinely persists we
41
+ // fail fast (the caller falls back to defaults) rather than stalling the
42
+ // process. On exhaustion the last error surfaces so the caller classifies it
43
+ // (unreadable) instead of silently returning stale/empty content.
44
+ return withRetrySync(() => readFileSync(configPath, "utf-8"), {
45
+ maxAttempts: 5,
46
+ backoffMs: 0,
47
+ retryableCodes: RETRYABLE_CONFIG_READ_CODES,
48
+ });
62
49
  }
63
50
  function logConfigWarnOnce(message) {
64
51
  if (emittedConfigWarnings.has(message)) {
@@ -332,10 +319,6 @@ function stripUtf8Bom(content) {
332
319
  function isRecord(value) {
333
320
  return value !== null && typeof value === "object" && !Array.isArray(value);
334
321
  }
335
- function isRetryableFsError(error) {
336
- const code = error?.code;
337
- return typeof code === "string" && RETRYABLE_FS_CODES.has(code);
338
- }
339
322
  function sleep(ms) {
340
323
  return new Promise((resolve) => setTimeout(resolve, ms));
341
324
  }
@@ -344,30 +327,24 @@ async function getConfigFileMtimeMs(filePath) {
344
327
  // run on the Windows-sensitive save path, where a transient EBUSY/EPERM/EAGAIN
345
328
  // from an AV/indexer lock on a single fs.stat would abort the entire save.
346
329
  // Mirror readConfigRecordForSave's bounded transient-FS retry (same code set,
347
- // same backoff, 5 attempts). ENOENT still returns null immediately.
348
- let lastError;
349
- for (let attempt = 0; attempt < 5; attempt += 1) {
330
+ // same backoff, 5 attempts). ENOENT still returns null immediately. On
331
+ // exhaustion the last failure surfaces so the caller treats it as a real
332
+ // save error rather than a phantom missing file.
333
+ return withRetry(async () => {
350
334
  try {
351
335
  return (await fs.stat(filePath)).mtimeMs;
352
336
  }
353
337
  catch (error) {
354
- const code = error?.code;
355
- if (code === "ENOENT") {
338
+ if (error?.code === "ENOENT") {
356
339
  return null;
357
340
  }
358
- lastError = error;
359
- if (typeof code === "string" &&
360
- RETRYABLE_CONFIG_READ_CODES.has(code) &&
361
- attempt < 4) {
362
- await sleep(10 * 2 ** attempt);
363
- continue;
364
- }
365
341
  throw error;
366
342
  }
367
- }
368
- // Exhausted retries on a transient code: surface the last failure so the caller
369
- // treats it as a real save error rather than a phantom missing file.
370
- throw lastError;
343
+ }, {
344
+ maxAttempts: 5,
345
+ backoffMs: (attempt) => 10 * 2 ** (attempt - 1),
346
+ retryableCodes: RETRYABLE_CONFIG_READ_CODES,
347
+ });
371
348
  }
372
349
  async function writeJsonFileAtomicWithRetry(filePath, payload, options) {
373
350
  const tempPath = `${filePath}.${process.pid}.${Date.now()}.${Math.random().toString(36).slice(2, 8)}.tmp`;
@@ -386,19 +363,12 @@ async function writeJsonFileAtomicWithRetry(filePath, payload, options) {
386
363
  throw staleError;
387
364
  }
388
365
  }
389
- for (let attempt = 0; attempt < 5; attempt += 1) {
390
- try {
391
- await fs.rename(tempPath, filePath);
392
- renamed = true;
393
- return;
394
- }
395
- catch (error) {
396
- if (!isRetryableFsError(error) || attempt >= 4) {
397
- throw error;
398
- }
399
- await sleep(10 * 2 ** attempt);
400
- }
401
- }
366
+ await withRetry(() => fs.rename(tempPath, filePath), {
367
+ maxAttempts: 5,
368
+ backoffMs: (attempt) => 10 * 2 ** (attempt - 1),
369
+ retryableCodes: RETRYABLE_FS_CODES,
370
+ });
371
+ renamed = true;
402
372
  }
403
373
  finally {
404
374
  if (!renamed) {
@@ -438,25 +408,17 @@ const CONFIG_LOCK_TTL_MS = 10_000;
438
408
  const CONFIG_LOCK_WAIT_TIMEOUT_MS = 10_000;
439
409
  const CONFIG_LOCK_POLL_MS = 50;
440
410
  async function unlinkConfigLockWithRetry(lockPath) {
441
- for (let attempt = 0; attempt < 5; attempt += 1) {
442
- try {
443
- await fs.unlink(lockPath);
444
- return;
445
- }
446
- catch (error) {
447
- const code = error?.code;
448
- if (code === "ENOENT")
449
- return;
450
- if (typeof code === "string" &&
451
- RETRYABLE_FS_CODES.has(code) &&
452
- attempt < 4) {
453
- await sleep(10 * 2 ** attempt);
454
- continue;
455
- }
456
- // Best-effort release: a leftover lockfile is recovered as stale by the
457
- // next acquirer via its expiry/mtime, so never fail the save over this.
458
- return;
459
- }
411
+ try {
412
+ await withRetry(() => fs.unlink(lockPath), {
413
+ maxAttempts: 5,
414
+ backoffMs: (attempt) => 10 * 2 ** (attempt - 1),
415
+ retryableCodes: RETRYABLE_FS_CODES,
416
+ });
417
+ }
418
+ catch {
419
+ // ENOENT (already released) or best-effort release failure: a leftover
420
+ // lockfile is recovered as stale by the next acquirer via its
421
+ // expiry/mtime, so never fail the save over this.
460
422
  }
461
423
  }
462
424
  // Owner-safe release: only unlink the lockfile if it still carries OUR owner
@@ -596,8 +558,8 @@ async function readConfigRecordForSave(configPath) {
596
558
  if (!existsSync(configPath)) {
597
559
  return { status: "missing" };
598
560
  }
599
- for (let attempt = 0; attempt < 5; attempt += 1) {
600
- try {
561
+ try {
562
+ return await withRetry(async () => {
601
563
  const fileContent = await fs.readFile(configPath, "utf-8");
602
564
  const normalizedFileContent = stripUtf8Bom(fileContent);
603
565
  const parsed = JSON.parse(normalizedFileContent);
@@ -607,32 +569,27 @@ async function readConfigRecordForSave(configPath) {
607
569
  return { status: "invalid", errorMessage };
608
570
  }
609
571
  return { status: "ok", record: parsed };
572
+ }, {
573
+ maxAttempts: 5,
574
+ backoffMs: (attempt) => 10 * 2 ** (attempt - 1),
575
+ retryableCodes: RETRYABLE_CONFIG_READ_CODES,
576
+ });
577
+ }
578
+ catch (error) {
579
+ const code = error?.code;
580
+ if (code === "ENOENT") {
581
+ return { status: "missing" };
610
582
  }
611
- catch (error) {
612
- const code = error?.code;
613
- if (code === "ENOENT") {
614
- return { status: "missing" };
615
- }
616
- if (typeof code === "string" &&
617
- RETRYABLE_CONFIG_READ_CODES.has(code) &&
618
- attempt < 4) {
619
- await sleep(10 * 2 ** attempt);
620
- continue;
621
- }
622
- const errorMessage = `Failed to read config from ${configPath}: ${error instanceof Error ? error.message : String(error)}`;
623
- logConfigWarnOnce(errorMessage);
624
- if (error instanceof SyntaxError) {
625
- return { status: "invalid", errorMessage };
626
- }
627
- if (typeof code === "string") {
628
- return { status: "unreadable", errorMessage };
629
- }
583
+ const errorMessage = `Failed to read config from ${configPath}: ${error instanceof Error ? error.message : String(error)}`;
584
+ logConfigWarnOnce(errorMessage);
585
+ if (error instanceof SyntaxError) {
630
586
  return { status: "invalid", errorMessage };
631
587
  }
588
+ if (typeof code === "string") {
589
+ return { status: "unreadable", errorMessage };
590
+ }
591
+ return { status: "invalid", errorMessage };
632
592
  }
633
- const errorMessage = `Failed to read config from ${configPath}.`;
634
- logConfigWarnOnce(errorMessage);
635
- return { status: "unreadable", errorMessage };
636
593
  }
637
594
  function resolveStoredPluginConfigRecord() {
638
595
  // config-01: mirror loadPluginConfig()'s precedence exactly. loadPluginConfig
@@ -1728,4 +1685,3 @@ export function getPluginConfigExplainReport() {
1728
1685
  entries,
1729
1686
  };
1730
1687
  }
1731
- //# sourceMappingURL=config.js.map
@@ -78,4 +78,3 @@ export const ACCOUNT_LIMITS = {
78
78
  /** Number of consecutive auth failures before auto-removing account */
79
79
  MAX_AUTH_FAILURES_BEFORE_REMOVAL: 3,
80
80
  };
81
- //# sourceMappingURL=constants.js.map
@@ -139,4 +139,3 @@ export async function handleContextOverflow(response, model) {
139
139
  }
140
140
  return { handled: false };
141
141
  }
142
- //# sourceMappingURL=context-overflow.js.map
@@ -324,4 +324,3 @@ export async function saveDashboardDisplaySettings(settings) {
324
324
  const normalized = normalizeDashboardDisplaySettings(settings);
325
325
  await saveUnifiedDashboardSettings(toJsonRecord(normalized));
326
326
  }
327
- //# sourceMappingURL=dashboard-settings.js.map
@@ -149,4 +149,3 @@ export class EntitlementCache {
149
149
  return { accounts };
150
150
  }
151
151
  }
152
- //# sourceMappingURL=entitlement-cache.js.map
@@ -31,4 +31,3 @@ export function parseBooleanEnv(value) {
31
31
  return false;
32
32
  return undefined;
33
33
  }
34
- //# sourceMappingURL=env-parsing.js.map
@@ -136,4 +136,3 @@ export function isCodexUnavailableError(error) {
136
136
  return (error instanceof Error &&
137
137
  error.code === ErrorCode.CODEX_UNAVAILABLE);
138
138
  }
139
- //# sourceMappingURL=errors.js.map
@@ -342,4 +342,3 @@ export function buildForecastExplanation(results, recommendation) {
342
342
  })),
343
343
  };
344
344
  }
345
- //# sourceMappingURL=forecast.js.map
@@ -3,5 +3,51 @@ export declare const FILE_RETRY_MAX_ATTEMPTS = 6;
3
3
  export declare const FILE_RETRY_BASE_DELAY_MS = 25;
4
4
  export declare const FILE_RETRY_JITTER_MS = 20;
5
5
  export declare function shouldRetryFileOperation(error: unknown): boolean;
6
+ /**
7
+ * Options for {@link withRetry} / {@link withRetrySync}.
8
+ *
9
+ * The shape is deliberately wide enough to express every hand-rolled
10
+ * file-retry loop in the codebase without changing any call site's behavior:
11
+ * per-site attempt counts, exponential/linear backoff schedules, optional
12
+ * jitter, and per-site retryable code sets are all preserved exactly.
13
+ */
14
+ export interface RetryOptions {
15
+ /** Total number of attempts (including the first one). Must be >= 1. */
16
+ maxAttempts: number;
17
+ /**
18
+ * Delay before the next attempt, either a fixed number of milliseconds or
19
+ * a function of the 1-based index of the attempt that just failed (so the
20
+ * delay after the first failure is `backoffMs(1)`). A computed delay <= 0
21
+ * retries immediately without scheduling a timer.
22
+ */
23
+ backoffMs: number | ((attempt: number) => number);
24
+ /**
25
+ * Optional jitter: adds `Math.floor(Math.random() * jitterMs)` to each
26
+ * computed backoff delay.
27
+ */
28
+ jitterMs?: number;
29
+ /**
30
+ * Error codes considered transient. Defaults to {@link FILE_RETRY_CODES}.
31
+ * An error retries only when it carries a string `code` in this set;
32
+ * everything else is rethrown immediately.
33
+ */
34
+ retryableCodes?: ReadonlySet<string> | readonly string[];
35
+ /** Invoked after each retryable failure, before the backoff delay. */
36
+ onRetry?: (error: unknown, attempt: number) => void;
37
+ }
38
+ /**
39
+ * Run `operation`, retrying on transient filesystem error codes with a
40
+ * per-call backoff schedule. Non-retryable errors are rethrown immediately;
41
+ * once `maxAttempts` is exhausted the error from the final attempt is
42
+ * rethrown unchanged. No delay is scheduled after the final attempt.
43
+ */
44
+ export declare function withRetry<T>(operation: () => Promise<T> | T, options: RetryOptions): Promise<T>;
45
+ /**
46
+ * Synchronous variant of {@link withRetry} for callers that cannot await
47
+ * (e.g. the synchronous recovery storage paths). Delays use a bounded
48
+ * busy-wait, so keep per-site schedules short; a computed delay <= 0 retries
49
+ * immediately without spinning.
50
+ */
51
+ export declare function withRetrySync<T>(operation: () => T, options: RetryOptions): T;
6
52
  export declare function withFileOperationRetry<T>(operation: () => Promise<T>): Promise<T>;
7
53
  //# sourceMappingURL=fs-retry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fs-retry.d.ts","sourceRoot":"","sources":["../../lib/fs-retry.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,aAM3B,CAAC;AACH,eAAO,MAAM,uBAAuB,IAAI,CAAC;AACzC,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAC3C,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAMvC,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAOhE;AAED,wBAAsB,sBAAsB,CAAC,CAAC,EAC7C,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACzB,OAAO,CAAC,CAAC,CAAC,CAcZ"}
1
+ {"version":3,"file":"fs-retry.d.ts","sourceRoot":"","sources":["../../lib/fs-retry.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,aAM3B,CAAC;AACH,eAAO,MAAM,uBAAuB,IAAI,CAAC;AACzC,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAC3C,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAMvC,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAOhE;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IAC5B,wEAAwE;IACxE,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,SAAS,EAAE,MAAM,GAAG,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC;IAClD;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,cAAc,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,SAAS,MAAM,EAAE,CAAC;IACzD,sEAAsE;IACtE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACpD;AAgCD;;;;;GAKG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAChC,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,EAC/B,OAAO,EAAE,YAAY,GACnB,OAAO,CAAC,CAAC,CAAC,CAkBZ;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,YAAY,GAAG,CAAC,CAqB7E;AAED,wBAAgB,sBAAsB,CAAC,CAAC,EACvC,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACzB,OAAO,CAAC,CAAC,CAAC,CAOZ"}
@@ -17,19 +17,87 @@ export function shouldRetryFileOperation(error) {
17
17
  typeof error.code === "string" &&
18
18
  FILE_RETRY_CODES.has(error.code));
19
19
  }
20
- export async function withFileOperationRetry(operation) {
20
+ function getErrorCode(error) {
21
+ if (typeof error !== "object" || error === null)
22
+ return undefined;
23
+ const code = error.code;
24
+ return typeof code === "string" ? code : undefined;
25
+ }
26
+ function isRetryableError(error, retryableCodes) {
27
+ const code = getErrorCode(error);
28
+ if (code === undefined)
29
+ return false;
30
+ if (retryableCodes === undefined)
31
+ return FILE_RETRY_CODES.has(code);
32
+ return Array.isArray(retryableCodes)
33
+ ? retryableCodes.includes(code)
34
+ : retryableCodes.has(code);
35
+ }
36
+ function computeDelayMs(options, attempt) {
37
+ const base = typeof options.backoffMs === "function"
38
+ ? options.backoffMs(attempt)
39
+ : options.backoffMs;
40
+ const jitter = options.jitterMs !== undefined && options.jitterMs > 0
41
+ ? Math.floor(Math.random() * options.jitterMs)
42
+ : 0;
43
+ return base + jitter;
44
+ }
45
+ /**
46
+ * Run `operation`, retrying on transient filesystem error codes with a
47
+ * per-call backoff schedule. Non-retryable errors are rethrown immediately;
48
+ * once `maxAttempts` is exhausted the error from the final attempt is
49
+ * rethrown unchanged. No delay is scheduled after the final attempt.
50
+ */
51
+ export async function withRetry(operation, options) {
21
52
  for (let attempt = 1;; attempt += 1) {
22
53
  try {
23
54
  return await operation();
24
55
  }
25
56
  catch (error) {
26
- if (!shouldRetryFileOperation(error) || attempt >= FILE_RETRY_MAX_ATTEMPTS) {
57
+ if (!isRetryableError(error, options.retryableCodes) ||
58
+ attempt >= options.maxAttempts) {
27
59
  throw error;
28
60
  }
29
- const delayMs = FILE_RETRY_BASE_DELAY_MS * 2 ** (attempt - 1) +
30
- Math.floor(Math.random() * FILE_RETRY_JITTER_MS);
31
- await sleep(delayMs);
61
+ options.onRetry?.(error, attempt);
62
+ const delayMs = computeDelayMs(options, attempt);
63
+ if (delayMs > 0) {
64
+ await sleep(delayMs);
65
+ }
32
66
  }
33
67
  }
34
68
  }
35
- //# sourceMappingURL=fs-retry.js.map
69
+ /**
70
+ * Synchronous variant of {@link withRetry} for callers that cannot await
71
+ * (e.g. the synchronous recovery storage paths). Delays use a bounded
72
+ * busy-wait, so keep per-site schedules short; a computed delay <= 0 retries
73
+ * immediately without spinning.
74
+ */
75
+ export function withRetrySync(operation, options) {
76
+ for (let attempt = 1;; attempt += 1) {
77
+ try {
78
+ return operation();
79
+ }
80
+ catch (error) {
81
+ if (!isRetryableError(error, options.retryableCodes) ||
82
+ attempt >= options.maxAttempts) {
83
+ throw error;
84
+ }
85
+ options.onRetry?.(error, attempt);
86
+ const delayMs = computeDelayMs(options, attempt);
87
+ if (delayMs > 0) {
88
+ const waitUntil = Date.now() + delayMs;
89
+ while (Date.now() < waitUntil) {
90
+ // Busy-wait within the bounded per-attempt budget.
91
+ }
92
+ }
93
+ }
94
+ }
95
+ }
96
+ export function withFileOperationRetry(operation) {
97
+ return withRetry(operation, {
98
+ maxAttempts: FILE_RETRY_MAX_ATTEMPTS,
99
+ backoffMs: (attempt) => FILE_RETRY_BASE_DELAY_MS * 2 ** (attempt - 1),
100
+ jitterMs: FILE_RETRY_JITTER_MS,
101
+ retryableCodes: FILE_RETRY_CODES,
102
+ });
103
+ }
@@ -71,4 +71,3 @@ export function formatHealthReport(health) {
71
71
  }
72
72
  return lines.join("\n");
73
73
  }
74
- //# sourceMappingURL=health.js.map
package/dist/lib/index.js CHANGED
@@ -39,4 +39,3 @@ export * from "./policy/runtime-policy.js";
39
39
  export * from "./local-bridge.js";
40
40
  export * from "./local-client-tokens.js";
41
41
  export * from "./integration-generators.js";
42
- //# sourceMappingURL=index.js.map
@@ -90,4 +90,3 @@ export function generateIntegrationSnippet(kind, input = {}) {
90
90
  export function generateIntegrationSnippets(kinds = ["opencode", "openclaw", "python", "curl", "env"], input = {}) {
91
91
  return kinds.map((kind) => generateIntegrationSnippet(kind, input));
92
92
  }
93
- //# sourceMappingURL=integration-generators.js.map
@@ -193,4 +193,3 @@ export class LiveAccountSync {
193
193
  }
194
194
  }
195
195
  }
196
- //# sourceMappingURL=live-account-sync.js.map
@@ -320,4 +320,3 @@ export async function startLocalBridge(options) {
320
320
  },
321
321
  };
322
322
  }
323
- //# sourceMappingURL=local-bridge.js.map
@@ -250,4 +250,3 @@ export async function verifyLocalClientBearerToken(authorizationHeader, now = Da
250
250
  export function resetLocalClientTokenWriteQueueForTests() {
251
251
  writeQueue = Promise.resolve();
252
252
  }
253
- //# sourceMappingURL=local-client-tokens.js.map
@@ -447,4 +447,3 @@ export function getRequestId() {
447
447
  return requestCounter;
448
448
  }
449
449
  export { formatDuration, maskEmail, maskString, maskToken, sanitizeValue };
450
- //# sourceMappingURL=logger.js.map
@@ -89,4 +89,3 @@ export function buildModelCapabilityMatrix(input) {
89
89
  entries,
90
90
  };
91
91
  }
92
- //# sourceMappingURL=model-capability-matrix.js.map
@@ -204,4 +204,3 @@ export async function exportNamedBackupFile(name, dependencies, options) {
204
204
  inFlightNamedBackupExports.delete(exportKey);
205
205
  }
206
206
  }
207
- //# sourceMappingURL=named-backup-export.js.map
@@ -519,4 +519,3 @@ export function previewOcChatgptImportMerge(options) {
519
519
  activeSelectionBehavior: "preserve-destination",
520
520
  };
521
521
  }
522
- //# sourceMappingURL=oc-chatgpt-import-adapter.js.map
@@ -186,4 +186,3 @@ export async function runNamedBackupExport(options) {
186
186
  return { kind: "error", path, error };
187
187
  }
188
188
  }
189
- //# sourceMappingURL=oc-chatgpt-orchestrator.js.map
@@ -324,4 +324,3 @@ export function detectOcChatgptMultiAuthTarget(options) {
324
324
  })),
325
325
  };
326
326
  }
327
- //# sourceMappingURL=oc-chatgpt-target-detection.js.map
@@ -152,4 +152,3 @@ export function createProbeCandidates(accounts) {
152
152
  controller: new AbortController(),
153
153
  }));
154
154
  }
155
- //# sourceMappingURL=parallel-probe.js.map
@@ -175,4 +175,3 @@ export function createRuntimeUsageRecorder(input) {
175
175
  },
176
176
  };
177
177
  }
178
- //# sourceMappingURL=runtime-policy.js.map
@@ -230,4 +230,3 @@ export class PreemptiveQuotaScheduler {
230
230
  return removed;
231
231
  }
232
232
  }
233
- //# sourceMappingURL=preemptive-quota-scheduler.js.map
@@ -160,4 +160,3 @@ export function applyRefreshResult(account, result) {
160
160
  }
161
161
  account.email = sanitizeEmail(extractAccountEmail(result.access)) ?? account.email;
162
162
  }
163
- //# sourceMappingURL=proactive-refresh.js.map
@@ -166,4 +166,3 @@ export const CODEX_HOST_BRIDGE_META = {
166
166
  "Git protocols (in Codex)",
167
167
  ],
168
168
  };
169
- //# sourceMappingURL=codex-host-bridge.js.map
@@ -1,19 +1,11 @@
1
- import { type PromptModelFamily } from "../request/helpers/model-map.js";
1
+ import { type ModelFamily } from "../request/helpers/model-map.js";
2
2
  /**
3
3
  * Clear the memory cache - exposed for testing
4
4
  * @internal
5
5
  */
6
6
  export declare function __clearCacheForTesting(): void;
7
- /**
8
- * Model family type for prompt selection
9
- * Maps to different system prompts in the Codex CLI
10
- */
11
- export type ModelFamily = PromptModelFamily;
12
- /**
13
- * All supported model families
14
- * Used for per-family account rotation and rate limit tracking
15
- */
16
- export declare const MODEL_FAMILIES: readonly ModelFamily[];
7
+ export { MODEL_FAMILIES } from "../request/helpers/model-map.js";
8
+ export type { ModelFamily } from "../request/helpers/model-map.js";
17
9
  /**
18
10
  * Determine the prompt family based on the effective model name.
19
11
  *
@@ -1 +1 @@
1
- {"version":3,"file":"codex.d.ts","sourceRoot":"","sources":["../../../lib/prompts/codex.ts"],"names":[],"mappings":"AAOA,OAAO,EAAkC,KAAK,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AA2EzG;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAI7C;AAWD;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,iBAAiB,CAAC;AAE5C;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,SAAS,WAAW,EAMvC,CAAC;AAyBX;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,eAAe,EAAE,MAAM,GAAG,WAAW,CAEnE;AA4ED;;;;;;;;;GASG;AACH,wBAAsB,oBAAoB,CACzC,eAAe,SAAgB,GAC7B,OAAO,CAAC,MAAM,CAAC,CAkHjB;AA6GD;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,GAAE,MAAM,EAAO,GAAG,IAAI,CAiBpE;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,ozGA+EV,CAAC"}
1
+ {"version":3,"file":"codex.d.ts","sourceRoot":"","sources":["../../../lib/prompts/codex.ts"],"names":[],"mappings":"AAOA,OAAO,EAAkC,KAAK,WAAW,EAAE,MAAM,iCAAiC,CAAC;AA2EnG;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAI7C;AAcD,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,YAAY,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAyBnE;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,eAAe,EAAE,MAAM,GAAG,WAAW,CAEnE;AA4ED;;;;;;;;;GASG;AACH,wBAAsB,oBAAoB,CACzC,eAAe,SAAgB,GAC7B,OAAO,CAAC,MAAM,CAAC,CAkHjB;AA6GD;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,GAAE,MAAM,EAAO,GAAG,IAAI,CAiBpE;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,ozGA+EV,CAAC"}
@@ -77,17 +77,10 @@ function setCacheEntry(key, value) {
77
77
  }
78
78
  memoryCache.set(key, value);
79
79
  }
80
- /**
81
- * All supported model families
82
- * Used for per-family account rotation and rate limit tracking
83
- */
84
- export const MODEL_FAMILIES = [
85
- "gpt-5-codex",
86
- "codex-max",
87
- "codex",
88
- "gpt-5.2",
89
- "gpt-5.1",
90
- ];
80
+ // ModelFamily/MODEL_FAMILIES live in the leaf model-map module so low-level
81
+ // modules (schemas, storage types) can use them without importing this file.
82
+ // Re-exported here to preserve the historical import surface.
83
+ export { MODEL_FAMILIES } from "../request/helpers/model-map.js";
91
84
  /**
92
85
  * Prompt file mapping for each model family
93
86
  * Based on codex-rs/core/src/model_family.rs logic
@@ -465,4 +458,3 @@ When hashline_read is available:
465
458
  - Never call \`request_user_input\` unless collaboration mode is explicitly Plan mode.
466
459
  </safety_rules>
467
460
  </user_instructions>`;
468
- //# sourceMappingURL=codex.js.map
@@ -162,4 +162,3 @@ export async function readBodyTextGuarded(response, maxBytes = PROMPT_FETCH_MAX_
162
162
  }
163
163
  return text;
164
164
  }
165
- //# sourceMappingURL=fetch-utils.js.map
@@ -370,4 +370,3 @@ export function prewarmHostCodexPrompt() {
370
370
  logDebug("Codex prompt prewarm failed", { error: String(error) });
371
371
  });
372
372
  }
373
- //# sourceMappingURL=host-codex-prompt.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"quota-cache.d.ts","sourceRoot":"","sources":["../../lib/quota-cache.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,gBAAgB;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,SAAS,EAAE,gBAAgB,CAAC;CAC5B;AAED,MAAM,WAAW,cAAc;IAC9B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC7C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;CACzC;AA2HD;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,cAAc,CAAC,CA4B9D;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAiExE"}
1
+ {"version":3,"file":"quota-cache.d.ts","sourceRoot":"","sources":["../../lib/quota-cache.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,gBAAgB;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,SAAS,EAAE,gBAAgB,CAAC;CAC5B;AAED,MAAM,WAAW,cAAc;IAC9B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC7C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;CACzC;AAsGD;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,cAAc,CAAC,CA4B9D;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CA4DxE"}