codex-multi-auth 2.3.0-beta.1 → 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 (460) hide show
  1. package/README.md +4 -4
  2. package/config/schema/config.schema.json +268 -21
  3. package/dist/index.js +0 -1
  4. package/dist/lib/account-policy.js +0 -1
  5. package/dist/lib/accounts/rate-limits.js +0 -1
  6. package/dist/lib/accounts.d.ts +3 -8
  7. package/dist/lib/accounts.d.ts.map +1 -1
  8. package/dist/lib/accounts.js +2 -3
  9. package/dist/lib/audit.js +0 -1
  10. package/dist/lib/auth/auth.js +0 -1
  11. package/dist/lib/auth/browser.js +0 -1
  12. package/dist/lib/auth/device-auth.js +0 -1
  13. package/dist/lib/auth/index.js +0 -1
  14. package/dist/lib/auth/org-override.js +0 -1
  15. package/dist/lib/auth/server.js +0 -1
  16. package/dist/lib/auth/token-utils.js +0 -1
  17. package/dist/lib/auth-rate-limit.js +0 -1
  18. package/dist/lib/budget-guard.js +0 -1
  19. package/dist/lib/capability-policy.js +0 -1
  20. package/dist/lib/circuit-breaker.js +0 -1
  21. package/dist/lib/cli.js +1 -2
  22. package/dist/lib/codex-cli/index.js +0 -1
  23. package/dist/lib/codex-cli/observability.js +0 -1
  24. package/dist/lib/codex-cli/state.js +0 -1
  25. package/dist/lib/codex-cli/sync.d.ts +2 -2
  26. package/dist/lib/codex-cli/sync.d.ts.map +1 -1
  27. package/dist/lib/codex-cli/sync.js +1 -2
  28. package/dist/lib/codex-cli/writer.js +0 -1
  29. package/dist/lib/codex-manager/account-credentials.d.ts +13 -0
  30. package/dist/lib/codex-manager/account-credentials.d.ts.map +1 -0
  31. package/dist/lib/codex-manager/account-credentials.js +55 -0
  32. package/dist/lib/codex-manager/account-manager-commands.js +0 -1
  33. package/dist/lib/codex-manager/account-pool-write.d.ts +1 -1
  34. package/dist/lib/codex-manager/account-pool-write.d.ts.map +1 -1
  35. package/dist/lib/codex-manager/account-pool-write.js +0 -1
  36. package/dist/lib/codex-manager/backend-category-entry.js +0 -1
  37. package/dist/lib/codex-manager/backend-category-helpers.js +0 -1
  38. package/dist/lib/codex-manager/backend-category-prompt.js +0 -1
  39. package/dist/lib/codex-manager/backend-settings-controller.js +0 -1
  40. package/dist/lib/codex-manager/backend-settings-entry.js +0 -1
  41. package/dist/lib/codex-manager/backend-settings-helpers.js +0 -1
  42. package/dist/lib/codex-manager/backend-settings-prompt.js +0 -1
  43. package/dist/lib/codex-manager/backend-settings-schema.js +0 -1
  44. package/dist/lib/codex-manager/behavior-settings-panel.d.ts +1 -1
  45. package/dist/lib/codex-manager/behavior-settings-panel.d.ts.map +1 -1
  46. package/dist/lib/codex-manager/behavior-settings-panel.js +0 -1
  47. package/dist/lib/codex-manager/commands/account.js +0 -1
  48. package/dist/lib/codex-manager/commands/best.d.ts +8 -0
  49. package/dist/lib/codex-manager/commands/best.d.ts.map +1 -1
  50. package/dist/lib/codex-manager/commands/best.js +64 -1
  51. package/dist/lib/codex-manager/commands/bridge.js +0 -1
  52. package/dist/lib/codex-manager/commands/budget.js +0 -1
  53. package/dist/lib/codex-manager/commands/check.js +0 -1
  54. package/dist/lib/codex-manager/commands/config-explain.js +0 -1
  55. package/dist/lib/codex-manager/commands/debug-bundle.js +0 -1
  56. package/dist/lib/codex-manager/commands/forecast.js +0 -1
  57. package/dist/lib/codex-manager/commands/init-config.js +0 -1
  58. package/dist/lib/codex-manager/commands/integrations.js +0 -1
  59. package/dist/lib/codex-manager/commands/models.js +0 -1
  60. package/dist/lib/codex-manager/commands/monitor.js +0 -1
  61. package/dist/lib/codex-manager/commands/report.js +0 -1
  62. package/dist/lib/codex-manager/commands/rotation.d.ts.map +1 -1
  63. package/dist/lib/codex-manager/commands/rotation.js +1 -4
  64. package/dist/lib/codex-manager/commands/status.js +0 -1
  65. package/dist/lib/codex-manager/commands/switch.js +0 -1
  66. package/dist/lib/codex-manager/commands/uninstall.d.ts.map +1 -1
  67. package/dist/lib/codex-manager/commands/uninstall.js +2 -33
  68. package/dist/lib/codex-manager/commands/unpin.js +0 -1
  69. package/dist/lib/codex-manager/commands/usage.js +0 -1
  70. package/dist/lib/codex-manager/commands/verify.js +0 -1
  71. package/dist/lib/codex-manager/commands/why-selected.js +0 -1
  72. package/dist/lib/codex-manager/commands/workspace.js +0 -1
  73. package/dist/lib/codex-manager/dashboard-display-panel.d.ts +1 -1
  74. package/dist/lib/codex-manager/dashboard-display-panel.d.ts.map +1 -1
  75. package/dist/lib/codex-manager/dashboard-display-panel.js +0 -1
  76. package/dist/lib/codex-manager/dashboard-formatters.js +0 -1
  77. package/dist/lib/codex-manager/dashboard-settings-controller.js +0 -1
  78. package/dist/lib/codex-manager/dashboard-settings-data.js +0 -1
  79. package/dist/lib/codex-manager/dashboard-settings-entry.js +0 -1
  80. package/dist/lib/codex-manager/experimental-settings-entry.js +0 -1
  81. package/dist/lib/codex-manager/experimental-settings-prompt.js +0 -1
  82. package/dist/lib/codex-manager/experimental-settings-schema.js +1 -2
  83. package/dist/lib/codex-manager/experimental-sync-target-entry.js +0 -1
  84. package/dist/lib/codex-manager/experimental-sync-target.js +0 -1
  85. package/dist/lib/codex-manager/forecast-report-commands.js +0 -1
  86. package/dist/lib/codex-manager/forecast-report-shared.d.ts +2 -2
  87. package/dist/lib/codex-manager/forecast-report-shared.d.ts.map +1 -1
  88. package/dist/lib/codex-manager/forecast-report-shared.js +5 -21
  89. package/dist/lib/codex-manager/formatters/account-formatters.d.ts +11 -0
  90. package/dist/lib/codex-manager/formatters/account-formatters.d.ts.map +1 -0
  91. package/dist/lib/codex-manager/formatters/account-formatters.js +79 -0
  92. package/dist/lib/codex-manager/formatters/index.d.ts +5 -0
  93. package/dist/lib/codex-manager/formatters/index.d.ts.map +1 -0
  94. package/dist/lib/codex-manager/formatters/index.js +4 -0
  95. package/dist/lib/codex-manager/formatters/model-formatters.d.ts +12 -0
  96. package/dist/lib/codex-manager/formatters/model-formatters.d.ts.map +1 -0
  97. package/dist/lib/codex-manager/formatters/model-formatters.js +23 -0
  98. package/dist/lib/codex-manager/formatters/quota-formatters.d.ts +11 -0
  99. package/dist/lib/codex-manager/formatters/quota-formatters.d.ts.map +1 -0
  100. package/dist/lib/codex-manager/formatters/quota-formatters.js +104 -0
  101. package/dist/lib/codex-manager/formatters/text-style.d.ts +14 -0
  102. package/dist/lib/codex-manager/formatters/text-style.d.ts.map +1 -0
  103. package/dist/lib/codex-manager/formatters/text-style.js +111 -0
  104. package/dist/lib/codex-manager/health-check.d.ts +14 -0
  105. package/dist/lib/codex-manager/health-check.d.ts.map +1 -0
  106. package/dist/lib/codex-manager/health-check.js +278 -0
  107. package/dist/lib/codex-manager/help.js +0 -1
  108. package/dist/lib/codex-manager/login-action-panel.d.ts +4 -0
  109. package/dist/lib/codex-manager/login-action-panel.d.ts.map +1 -0
  110. package/dist/lib/codex-manager/login-action-panel.js +238 -0
  111. package/dist/lib/codex-manager/login-flow.d.ts +17 -0
  112. package/dist/lib/codex-manager/login-flow.d.ts.map +1 -0
  113. package/dist/lib/codex-manager/login-flow.js +387 -0
  114. package/dist/lib/codex-manager/login-menu-actions.d.ts +20 -0
  115. package/dist/lib/codex-manager/login-menu-actions.d.ts.map +1 -0
  116. package/dist/lib/codex-manager/login-menu-actions.js +303 -0
  117. package/dist/lib/codex-manager/login-menu-data.d.ts +19 -0
  118. package/dist/lib/codex-manager/login-menu-data.d.ts.map +1 -0
  119. package/dist/lib/codex-manager/login-menu-data.js +378 -0
  120. package/dist/lib/codex-manager/login-oauth.d.ts +55 -0
  121. package/dist/lib/codex-manager/login-oauth.d.ts.map +1 -0
  122. package/dist/lib/codex-manager/login-oauth.js +345 -0
  123. package/dist/lib/codex-manager/manual-callback.js +0 -1
  124. package/dist/lib/codex-manager/persist-selected-account.d.ts +24 -0
  125. package/dist/lib/codex-manager/persist-selected-account.d.ts.map +1 -0
  126. package/dist/lib/codex-manager/persist-selected-account.js +107 -0
  127. package/dist/lib/codex-manager/quota-cache-helpers.d.ts +18 -0
  128. package/dist/lib/codex-manager/quota-cache-helpers.d.ts.map +1 -0
  129. package/dist/lib/codex-manager/quota-cache-helpers.js +112 -0
  130. package/dist/lib/codex-manager/rate-limit-markers.js +0 -1
  131. package/dist/lib/codex-manager/repair-commands.js +0 -1
  132. package/dist/lib/codex-manager/settings-hub/backend.js +1 -2
  133. package/dist/lib/codex-manager/settings-hub/dashboard.js +1 -2
  134. package/dist/lib/codex-manager/settings-hub/experimental.js +1 -2
  135. package/dist/lib/codex-manager/settings-hub/index.js +1 -2
  136. package/dist/lib/codex-manager/settings-hub/shared.js +0 -1
  137. package/dist/lib/codex-manager/settings-hub-entry.js +0 -1
  138. package/dist/lib/codex-manager/settings-hub-menu.js +0 -1
  139. package/dist/lib/codex-manager/settings-hub-prompt.js +0 -1
  140. package/dist/lib/codex-manager/settings-hub.js +0 -1
  141. package/dist/lib/codex-manager/settings-panels.js +0 -1
  142. package/dist/lib/codex-manager/settings-persist-utils.js +0 -1
  143. package/dist/lib/codex-manager/settings-preview.js +0 -1
  144. package/dist/lib/codex-manager/settings-write-queue.js +0 -1
  145. package/dist/lib/codex-manager/statusline-order.js +0 -1
  146. package/dist/lib/codex-manager/statusline-settings-panel.d.ts +1 -1
  147. package/dist/lib/codex-manager/statusline-settings-panel.d.ts.map +1 -1
  148. package/dist/lib/codex-manager/statusline-settings-panel.js +0 -1
  149. package/dist/lib/codex-manager/theme-settings-panel.d.ts +1 -1
  150. package/dist/lib/codex-manager/theme-settings-panel.d.ts.map +1 -1
  151. package/dist/lib/codex-manager/theme-settings-panel.js +0 -1
  152. package/dist/lib/codex-manager/unified-settings-controller.js +0 -1
  153. package/dist/lib/codex-manager/unified-settings-entry.js +0 -1
  154. package/dist/lib/codex-manager.d.ts +2 -4
  155. package/dist/lib/codex-manager.d.ts.map +1 -1
  156. package/dist/lib/codex-manager.js +219 -2570
  157. package/dist/lib/config-schema.d.ts +32 -0
  158. package/dist/lib/config-schema.d.ts.map +1 -0
  159. package/dist/lib/config-schema.js +96 -0
  160. package/dist/lib/config.d.ts.map +1 -1
  161. package/dist/lib/config.js +60 -104
  162. package/dist/lib/constants.js +0 -1
  163. package/dist/lib/context-overflow.js +0 -1
  164. package/dist/lib/dashboard-settings.js +0 -1
  165. package/dist/lib/entitlement-cache.js +0 -1
  166. package/dist/lib/env-parsing.js +0 -1
  167. package/dist/lib/errors.js +0 -1
  168. package/dist/lib/forecast.js +0 -1
  169. package/dist/lib/fs-retry.d.ts +46 -0
  170. package/dist/lib/fs-retry.d.ts.map +1 -1
  171. package/dist/lib/fs-retry.js +74 -6
  172. package/dist/lib/health.js +0 -1
  173. package/dist/lib/index.js +0 -1
  174. package/dist/lib/integration-generators.js +0 -1
  175. package/dist/lib/live-account-sync.js +0 -1
  176. package/dist/lib/local-bridge.js +0 -1
  177. package/dist/lib/local-client-tokens.js +0 -1
  178. package/dist/lib/logger.js +0 -1
  179. package/dist/lib/model-capability-matrix.js +0 -1
  180. package/dist/lib/named-backup-export.js +0 -1
  181. package/dist/lib/oc-chatgpt-import-adapter.js +0 -1
  182. package/dist/lib/oc-chatgpt-orchestrator.js +0 -1
  183. package/dist/lib/oc-chatgpt-target-detection.js +0 -1
  184. package/dist/lib/parallel-probe.js +0 -1
  185. package/dist/lib/policy/runtime-policy.js +0 -1
  186. package/dist/lib/preemptive-quota-scheduler.js +0 -1
  187. package/dist/lib/proactive-refresh.js +0 -1
  188. package/dist/lib/prompts/codex-host-bridge.js +0 -1
  189. package/dist/lib/prompts/codex.d.ts +3 -11
  190. package/dist/lib/prompts/codex.d.ts.map +1 -1
  191. package/dist/lib/prompts/codex.js +4 -12
  192. package/dist/lib/prompts/fetch-utils.js +0 -1
  193. package/dist/lib/prompts/host-codex-prompt.js +0 -1
  194. package/dist/lib/quota-cache.d.ts.map +1 -1
  195. package/dist/lib/quota-cache.js +15 -43
  196. package/dist/lib/quota-probe.js +0 -1
  197. package/dist/lib/quota-readiness.js +0 -1
  198. package/dist/lib/recovery/constants.js +0 -1
  199. package/dist/lib/recovery/index.js +0 -1
  200. package/dist/lib/recovery/storage.d.ts.map +1 -1
  201. package/dist/lib/recovery/storage.js +30 -51
  202. package/dist/lib/recovery/storage.js.map +1 -1
  203. package/dist/lib/recovery/types.js +0 -1
  204. package/dist/lib/recovery.js +0 -1
  205. package/dist/lib/refresh-guardian.js +0 -1
  206. package/dist/lib/refresh-lease.d.ts.map +1 -1
  207. package/dist/lib/refresh-lease.js +1 -4
  208. package/dist/lib/refresh-queue.js +0 -1
  209. package/dist/lib/request/error-classification.d.ts +75 -0
  210. package/dist/lib/request/error-classification.d.ts.map +1 -0
  211. package/dist/lib/request/error-classification.js +295 -0
  212. package/dist/lib/request/failover-config.js +0 -1
  213. package/dist/lib/request/failure-policy.js +0 -1
  214. package/dist/lib/request/fetch-helpers.d.ts +10 -114
  215. package/dist/lib/request/fetch-helpers.d.ts.map +1 -1
  216. package/dist/lib/request/fetch-helpers.js +7 -589
  217. package/dist/lib/request/headers.d.ts +33 -0
  218. package/dist/lib/request/headers.d.ts.map +1 -0
  219. package/dist/lib/request/headers.js +64 -0
  220. package/dist/lib/request/helpers/input-utils.js +0 -1
  221. package/dist/lib/request/helpers/model-map.d.ts +10 -0
  222. package/dist/lib/request/helpers/model-map.d.ts.map +1 -1
  223. package/dist/lib/request/helpers/model-map.js +11 -1
  224. package/dist/lib/request/helpers/tool-utils.js +0 -1
  225. package/dist/lib/request/index.js +0 -1
  226. package/dist/lib/request/rate-limit-backoff.js +0 -1
  227. package/dist/lib/request/rate-limit-decision.d.ts +28 -0
  228. package/dist/lib/request/rate-limit-decision.d.ts.map +1 -0
  229. package/dist/lib/request/rate-limit-decision.js +191 -0
  230. package/dist/lib/request/request-attempt-budget.js +0 -1
  231. package/dist/lib/request/request-init.js +0 -1
  232. package/dist/lib/request/request-resilience.js +0 -1
  233. package/dist/lib/request/request-transformer.js +0 -1
  234. package/dist/lib/request/response-compaction.js +0 -1
  235. package/dist/lib/request/response-handler.js +0 -1
  236. package/dist/lib/request/response-metadata.js +0 -1
  237. package/dist/lib/request/stream-failover-runtime.d.ts +8 -0
  238. package/dist/lib/request/stream-failover-runtime.d.ts.map +1 -0
  239. package/dist/lib/request/stream-failover-runtime.js +149 -0
  240. package/dist/lib/request/stream-failover.js +0 -1
  241. package/dist/lib/request/token-refresh.d.ts +30 -0
  242. package/dist/lib/request/token-refresh.d.ts.map +1 -0
  243. package/dist/lib/request/token-refresh.js +116 -0
  244. package/dist/lib/request/url-rewriting.d.ts +24 -0
  245. package/dist/lib/request/url-rewriting.d.ts.map +1 -0
  246. package/dist/lib/request/url-rewriting.js +153 -0
  247. package/dist/lib/request/wait-utils.js +0 -1
  248. package/dist/lib/rotation.d.ts +1 -1
  249. package/dist/lib/rotation.d.ts.map +1 -1
  250. package/dist/lib/rotation.js +0 -1
  251. package/dist/lib/routing-mutex.js +0 -1
  252. package/dist/lib/routing-profiles.js +0 -1
  253. package/dist/lib/runtime/account-check-helpers.js +0 -1
  254. package/dist/lib/runtime/account-check-types.js +0 -1
  255. package/dist/lib/runtime/account-check.js +0 -1
  256. package/dist/lib/runtime/account-health-check.js +0 -1
  257. package/dist/lib/runtime/account-manager-cache-entry.js +0 -1
  258. package/dist/lib/runtime/account-manager-cache.js +0 -1
  259. package/dist/lib/runtime/account-pool.js +0 -1
  260. package/dist/lib/runtime/account-scope.js +0 -1
  261. package/dist/lib/runtime/account-select-event.js +0 -1
  262. package/dist/lib/runtime/account-selection.js +0 -1
  263. package/dist/lib/runtime/account-state.js +0 -1
  264. package/dist/lib/runtime/account-status.js +0 -1
  265. package/dist/lib/runtime/account-storage-scope-entry.js +0 -1
  266. package/dist/lib/runtime/app-bind.js +0 -1
  267. package/dist/lib/runtime/auth-facade.js +0 -1
  268. package/dist/lib/runtime/browser-oauth-flow.js +0 -1
  269. package/dist/lib/runtime/capability-boost.js +0 -1
  270. package/dist/lib/runtime/config-toml.js +0 -1
  271. package/dist/lib/runtime/event-handler.js +0 -1
  272. package/dist/lib/runtime/first-run.d.ts +80 -0
  273. package/dist/lib/runtime/first-run.d.ts.map +1 -0
  274. package/dist/lib/runtime/first-run.js +327 -0
  275. package/dist/lib/runtime/flagged-verify-types.js +0 -1
  276. package/dist/lib/runtime/hydrate-emails.js +0 -1
  277. package/dist/lib/runtime/live-sync-entry.js +0 -1
  278. package/dist/lib/runtime/live-sync.js +0 -1
  279. package/dist/lib/runtime/loader-setup.js +0 -1
  280. package/dist/lib/runtime/login-menu-accounts.js +0 -1
  281. package/dist/lib/runtime/manual-oauth-flow.js +0 -1
  282. package/dist/lib/runtime/oauth-browser-flow.js +0 -1
  283. package/dist/lib/runtime/preemptive-quota.js +0 -1
  284. package/dist/lib/runtime/quota-headers.js +0 -1
  285. package/dist/lib/runtime/quota-probe.js +0 -1
  286. package/dist/lib/runtime/quota-settings.js +0 -1
  287. package/dist/lib/runtime/refresh-guardian-entry.js +0 -1
  288. package/dist/lib/runtime/refresh-guardian.js +0 -1
  289. package/dist/lib/runtime/request-init.js +0 -1
  290. package/dist/lib/runtime/rotation-account-selection.d.ts +38 -0
  291. package/dist/lib/runtime/rotation-account-selection.d.ts.map +1 -0
  292. package/dist/lib/runtime/rotation-account-selection.js +172 -0
  293. package/dist/lib/runtime/rotation-proxy-state.d.ts +54 -0
  294. package/dist/lib/runtime/rotation-proxy-state.d.ts.map +1 -0
  295. package/dist/lib/runtime/rotation-proxy-state.js +56 -0
  296. package/dist/lib/runtime/rotation-server-types.d.ts +57 -0
  297. package/dist/lib/runtime/rotation-server-types.d.ts.map +1 -0
  298. package/dist/lib/runtime/rotation-server-types.js +1 -0
  299. package/dist/lib/runtime/rotation-storage-meta.d.ts +40 -0
  300. package/dist/lib/runtime/rotation-storage-meta.d.ts.map +1 -0
  301. package/dist/lib/runtime/rotation-storage-meta.js +143 -0
  302. package/dist/lib/runtime/rotation-token-refresh.d.ts +25 -0
  303. package/dist/lib/runtime/rotation-token-refresh.d.ts.map +1 -0
  304. package/dist/lib/runtime/rotation-token-refresh.js +99 -0
  305. package/dist/lib/runtime/runtime-current-account.d.ts.map +1 -1
  306. package/dist/lib/runtime/runtime-current-account.js +1 -4
  307. package/dist/lib/runtime/runtime-observability.js +0 -1
  308. package/dist/lib/runtime/runtime-services.js +0 -1
  309. package/dist/lib/runtime/session-affinity-entry.js +0 -1
  310. package/dist/lib/runtime/session-affinity.js +0 -1
  311. package/dist/lib/runtime/session-recovery.js +0 -1
  312. package/dist/lib/runtime/status-marker.js +0 -1
  313. package/dist/lib/runtime/storage-scope.js +0 -1
  314. package/dist/lib/runtime/toast.js +0 -1
  315. package/dist/lib/runtime/ui-runtime-entry.js +0 -1
  316. package/dist/lib/runtime/ui-runtime.js +0 -1
  317. package/dist/lib/runtime/verify-flagged.js +0 -1
  318. package/dist/lib/runtime-constants.js +0 -1
  319. package/dist/lib/runtime-paths.js +0 -1
  320. package/dist/lib/runtime-rotation-proxy.d.ts +7 -124
  321. package/dist/lib/runtime-rotation-proxy.d.ts.map +1 -1
  322. package/dist/lib/runtime-rotation-proxy.js +614 -1353
  323. package/dist/lib/schemas.d.ts +3 -3
  324. package/dist/lib/schemas.js +1 -2
  325. package/dist/lib/session-affinity.js +0 -1
  326. package/dist/lib/shutdown.js +0 -1
  327. package/dist/lib/storage/account-clear-entry.js +0 -1
  328. package/dist/lib/storage/account-clear.js +0 -1
  329. package/dist/lib/storage/account-match-utils.js +0 -1
  330. package/dist/lib/storage/account-persistence.d.ts +1 -1
  331. package/dist/lib/storage/account-persistence.d.ts.map +1 -1
  332. package/dist/lib/storage/account-persistence.js +0 -1
  333. package/dist/lib/storage/account-port.d.ts +1 -1
  334. package/dist/lib/storage/account-port.d.ts.map +1 -1
  335. package/dist/lib/storage/account-port.js +0 -1
  336. package/dist/lib/storage/account-save-entry.d.ts +1 -1
  337. package/dist/lib/storage/account-save-entry.d.ts.map +1 -1
  338. package/dist/lib/storage/account-save-entry.js +0 -1
  339. package/dist/lib/storage/account-save.d.ts +1 -1
  340. package/dist/lib/storage/account-save.d.ts.map +1 -1
  341. package/dist/lib/storage/account-save.js +0 -1
  342. package/dist/lib/storage/account-snapshot.js +0 -1
  343. package/dist/lib/storage/backup-metadata-builder.d.ts +1 -1
  344. package/dist/lib/storage/backup-metadata-builder.d.ts.map +1 -1
  345. package/dist/lib/storage/backup-metadata-builder.js +0 -1
  346. package/dist/lib/storage/backup-metadata.d.ts +13 -0
  347. package/dist/lib/storage/backup-metadata.d.ts.map +1 -1
  348. package/dist/lib/storage/backup-metadata.js +0 -1
  349. package/dist/lib/storage/backup-paths.js +0 -1
  350. package/dist/lib/storage/backup-restore.d.ts +1 -1
  351. package/dist/lib/storage/backup-restore.d.ts.map +1 -1
  352. package/dist/lib/storage/backup-restore.js +0 -1
  353. package/dist/lib/storage/cache-artifacts.js +0 -1
  354. package/dist/lib/storage/error-hints.js +0 -1
  355. package/dist/lib/storage/file-paths.js +0 -1
  356. package/dist/lib/storage/fixture-guards.d.ts +1 -1
  357. package/dist/lib/storage/fixture-guards.d.ts.map +1 -1
  358. package/dist/lib/storage/fixture-guards.js +0 -1
  359. package/dist/lib/storage/flagged-entry.js +0 -1
  360. package/dist/lib/storage/flagged-load-entry.d.ts +1 -1
  361. package/dist/lib/storage/flagged-load-entry.d.ts.map +1 -1
  362. package/dist/lib/storage/flagged-load-entry.js +0 -1
  363. package/dist/lib/storage/flagged-save-entry.d.ts +1 -1
  364. package/dist/lib/storage/flagged-save-entry.d.ts.map +1 -1
  365. package/dist/lib/storage/flagged-save-entry.js +0 -1
  366. package/dist/lib/storage/flagged-storage-file.d.ts +1 -1
  367. package/dist/lib/storage/flagged-storage-file.d.ts.map +1 -1
  368. package/dist/lib/storage/flagged-storage-file.js +0 -1
  369. package/dist/lib/storage/flagged-storage-io.d.ts +1 -1
  370. package/dist/lib/storage/flagged-storage-io.d.ts.map +1 -1
  371. package/dist/lib/storage/flagged-storage-io.js +0 -1
  372. package/dist/lib/storage/flagged-storage.d.ts +1 -1
  373. package/dist/lib/storage/flagged-storage.d.ts.map +1 -1
  374. package/dist/lib/storage/flagged-storage.js +15 -2
  375. package/dist/lib/storage/flagged-storage.js.map +1 -1
  376. package/dist/lib/storage/gitignore.js +0 -1
  377. package/dist/lib/storage/hash.js +0 -1
  378. package/dist/lib/storage/health.js +0 -1
  379. package/dist/lib/storage/identity.js +0 -1
  380. package/dist/lib/storage/import-export.d.ts +1 -1
  381. package/dist/lib/storage/import-export.d.ts.map +1 -1
  382. package/dist/lib/storage/import-export.js +0 -1
  383. package/dist/lib/storage/metadata-section.js +0 -1
  384. package/dist/lib/storage/migrations.d.ts +5 -48
  385. package/dist/lib/storage/migrations.d.ts.map +1 -1
  386. package/dist/lib/storage/migrations.js +5 -2
  387. package/dist/lib/storage/named-backup-entry.js +0 -1
  388. package/dist/lib/storage/named-backups-entry.d.ts +1 -1
  389. package/dist/lib/storage/named-backups-entry.d.ts.map +1 -1
  390. package/dist/lib/storage/named-backups-entry.js +0 -1
  391. package/dist/lib/storage/named-backups.js +0 -1
  392. package/dist/lib/storage/path-state.js +0 -1
  393. package/dist/lib/storage/paths.js +0 -1
  394. package/dist/lib/storage/project-migration.d.ts +1 -1
  395. package/dist/lib/storage/project-migration.d.ts.map +1 -1
  396. package/dist/lib/storage/project-migration.js +0 -1
  397. package/dist/lib/storage/public-types.d.ts +70 -0
  398. package/dist/lib/storage/public-types.d.ts.map +1 -0
  399. package/dist/lib/storage/public-types.js +6 -0
  400. package/dist/lib/storage/record-utils.js +0 -1
  401. package/dist/lib/storage/restore-assessment.d.ts +1 -1
  402. package/dist/lib/storage/restore-assessment.d.ts.map +1 -1
  403. package/dist/lib/storage/restore-assessment.js +0 -1
  404. package/dist/lib/storage/restore-backup-entry.d.ts +1 -1
  405. package/dist/lib/storage/restore-backup-entry.d.ts.map +1 -1
  406. package/dist/lib/storage/restore-backup-entry.js +0 -1
  407. package/dist/lib/storage/restore-metadata.d.ts +1 -1
  408. package/dist/lib/storage/restore-metadata.d.ts.map +1 -1
  409. package/dist/lib/storage/restore-metadata.js +0 -1
  410. package/dist/lib/storage/restore.d.ts +1 -1
  411. package/dist/lib/storage/restore.d.ts.map +1 -1
  412. package/dist/lib/storage/restore.js +0 -1
  413. package/dist/lib/storage/save-retry.d.ts +10 -0
  414. package/dist/lib/storage/save-retry.d.ts.map +1 -0
  415. package/dist/lib/storage/save-retry.js +26 -0
  416. package/dist/lib/storage/snapshot-inspectors.d.ts +1 -1
  417. package/dist/lib/storage/snapshot-inspectors.d.ts.map +1 -1
  418. package/dist/lib/storage/snapshot-inspectors.js +0 -1
  419. package/dist/lib/storage/storage-parser.d.ts +1 -1
  420. package/dist/lib/storage/storage-parser.d.ts.map +1 -1
  421. package/dist/lib/storage/storage-parser.js +0 -1
  422. package/dist/lib/storage/transactions.d.ts +1 -1
  423. package/dist/lib/storage/transactions.d.ts.map +1 -1
  424. package/dist/lib/storage/transactions.js +0 -1
  425. package/dist/lib/storage.d.ts +3 -24
  426. package/dist/lib/storage.d.ts.map +1 -1
  427. package/dist/lib/storage.js +17 -32
  428. package/dist/lib/table-formatter.js +0 -1
  429. package/dist/lib/tools/hashline-tools.js +0 -1
  430. package/dist/lib/types.js +0 -1
  431. package/dist/lib/ui/ansi.js +0 -1
  432. package/dist/lib/ui/auth-menu-builder.d.ts +89 -0
  433. package/dist/lib/ui/auth-menu-builder.d.ts.map +1 -0
  434. package/dist/lib/ui/auth-menu-builder.js +350 -0
  435. package/dist/lib/ui/auth-menu.d.ts +2 -76
  436. package/dist/lib/ui/auth-menu.d.ts.map +1 -1
  437. package/dist/lib/ui/auth-menu.js +3 -349
  438. package/dist/lib/ui/confirm.js +0 -1
  439. package/dist/lib/ui/display-width.js +0 -1
  440. package/dist/lib/ui/format.js +0 -1
  441. package/dist/lib/ui/index.d.ts +10 -0
  442. package/dist/lib/ui/index.d.ts.map +1 -0
  443. package/dist/lib/ui/index.js +9 -0
  444. package/dist/lib/ui/runtime.js +0 -1
  445. package/dist/lib/ui/select.js +0 -1
  446. package/dist/lib/ui/theme.js +0 -1
  447. package/dist/lib/ui/ui-copy.d.ts +159 -0
  448. package/dist/lib/ui/ui-copy.d.ts.map +1 -0
  449. package/dist/lib/ui/ui-copy.js +163 -0
  450. package/dist/lib/unified-settings.js +0 -1
  451. package/dist/lib/update-notice.js +0 -1
  452. package/dist/lib/usage/index.js +0 -1
  453. package/dist/lib/usage/ledger.js +0 -1
  454. package/dist/lib/usage/pricing.js +0 -1
  455. package/dist/lib/usage/redaction.js +0 -1
  456. package/dist/lib/usage/types.js +0 -1
  457. package/dist/lib/utils.js +0 -1
  458. package/package.json +8 -8
  459. package/scripts/postinstall.js +34 -265
  460. package/scripts/preuninstall.js +2 -2
@@ -0,0 +1,32 @@
1
+ /** Repo-relative path of the committed, generated schema file. */
2
+ export declare const CONFIG_SCHEMA_RELATIVE_PATH = "config/schema/config.schema.json";
3
+ type JsonObject = Record<string, unknown>;
4
+ /**
5
+ * Build the full JSON schema document for `config/schema/config.schema.json`.
6
+ *
7
+ * Structure:
8
+ * - Root keeps the original template metadata (`$schema` draft 2020-12, `$id`,
9
+ * `title`) and the template root keys (`plugin`, `provider`, `model`) that
10
+ * the shipped `config/*.json` templates reference via `$schema`.
11
+ * - The complete runtime plugin configuration surface is generated from
12
+ * `PluginConfigSchema` via zod v4's native `z.toJSONSchema()` and embedded
13
+ * as `$defs.pluginConfig`, referenced by the optional root `pluginConfig`
14
+ * property (the shape persisted in unified `settings.json`).
15
+ *
16
+ * `io: "input"` matches runtime semantics: `loadPluginConfig` tolerates and
17
+ * strips unknown keys instead of rejecting them, so the generated definition
18
+ * must not emit `additionalProperties: false`.
19
+ *
20
+ * Key order is the zod shape definition order, which is stable across runs,
21
+ * so output is deterministic.
22
+ */
23
+ export declare function buildConfigJsonSchema(): JsonObject;
24
+ /**
25
+ * Serialize the generated schema exactly as it is committed on disk:
26
+ * 2-space indent (matching the previous handwritten file) plus a trailing
27
+ * newline. `JSON.stringify` preserves insertion order, so the output is
28
+ * byte-for-byte deterministic.
29
+ */
30
+ export declare function renderConfigJsonSchema(): string;
31
+ export {};
32
+ //# sourceMappingURL=config-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-schema.d.ts","sourceRoot":"","sources":["../../lib/config-schema.ts"],"names":[],"mappings":"AAmBA,kEAAkE;AAClE,eAAO,MAAM,2BAA2B,qCAAqC,CAAC;AAE9E,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE1C;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,qBAAqB,IAAI,UAAU,CAmDlD;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CAE/C"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Single source of truth for `config/schema/config.schema.json`.
3
+ *
4
+ * The JSON schema shipped under `config/schema/` is GENERATED from the zod
5
+ * `PluginConfigSchema` in `lib/schemas.ts` so it cannot drift from the real
6
+ * runtime config surface (audit roadmap §4.5.2).
7
+ *
8
+ * - Regenerate the committed file with `npm run generate:schema`
9
+ * (see `scripts/generate-config-schema.mjs`).
10
+ * - Drift is a test failure: `test/config-schema-generated.test.ts`
11
+ * regenerates the schema in-memory and compares it to the committed file.
12
+ *
13
+ * @internal Generator/tooling module: deliberately NOT re-exported from
14
+ * lib/index.ts. Its only consumers are scripts/generate-config-schema.mjs
15
+ * (via the compiled dist output) and the drift-guard test.
16
+ */
17
+ import { z } from "zod";
18
+ import { PluginConfigSchema } from "./schemas.js";
19
+ /** Repo-relative path of the committed, generated schema file. */
20
+ export const CONFIG_SCHEMA_RELATIVE_PATH = "config/schema/config.schema.json";
21
+ /**
22
+ * Build the full JSON schema document for `config/schema/config.schema.json`.
23
+ *
24
+ * Structure:
25
+ * - Root keeps the original template metadata (`$schema` draft 2020-12, `$id`,
26
+ * `title`) and the template root keys (`plugin`, `provider`, `model`) that
27
+ * the shipped `config/*.json` templates reference via `$schema`.
28
+ * - The complete runtime plugin configuration surface is generated from
29
+ * `PluginConfigSchema` via zod v4's native `z.toJSONSchema()` and embedded
30
+ * as `$defs.pluginConfig`, referenced by the optional root `pluginConfig`
31
+ * property (the shape persisted in unified `settings.json`).
32
+ *
33
+ * `io: "input"` matches runtime semantics: `loadPluginConfig` tolerates and
34
+ * strips unknown keys instead of rejecting them, so the generated definition
35
+ * must not emit `additionalProperties: false`.
36
+ *
37
+ * Key order is the zod shape definition order, which is stable across runs,
38
+ * so output is deterministic.
39
+ */
40
+ export function buildConfigJsonSchema() {
41
+ const pluginConfigRaw = z.toJSONSchema(PluginConfigSchema, {
42
+ target: "draft-2020-12",
43
+ io: "input",
44
+ });
45
+ // Guard before mutating: a zod behavior change returning a non-object
46
+ // here should fail loudly, not via a confusing delete/??= throw below.
47
+ if (!pluginConfigRaw ||
48
+ typeof pluginConfigRaw !== "object" ||
49
+ Array.isArray(pluginConfigRaw)) {
50
+ throw new Error("z.toJSONSchema(PluginConfigSchema) returned a non-object");
51
+ }
52
+ const pluginConfig = pluginConfigRaw;
53
+ // The embedded definition inherits the root document's dialect; a nested
54
+ // `$schema` keyword would be redundant noise.
55
+ delete pluginConfig.$schema;
56
+ // ??= so a future .describe() on PluginConfigSchema wins over this default.
57
+ pluginConfig.description ??=
58
+ "Runtime plugin configuration (the `pluginConfig` section of unified settings.json, also accepted flat in CODEX_MULTI_AUTH_CONFIG_PATH overrides). Generated from PluginConfigSchema in lib/schemas.ts — do not edit by hand; run `npm run generate:schema`.";
59
+ return {
60
+ $schema: "https://json-schema.org/draft/2020-12/schema",
61
+ $id: "https://codex-multi-auth.local/schema/config.schema.json",
62
+ title: "codex-multi-auth config template",
63
+ description: "GENERATED FILE — do not edit by hand. Regenerate with `npm run generate:schema` (source: lib/config-schema.ts + PluginConfigSchema in lib/schemas.ts).",
64
+ type: "object",
65
+ properties: {
66
+ plugin: {
67
+ type: "array",
68
+ items: { type: "string" },
69
+ },
70
+ provider: {
71
+ type: "object",
72
+ additionalProperties: true,
73
+ },
74
+ model: {
75
+ type: "string",
76
+ },
77
+ pluginConfig: {
78
+ $ref: "#/$defs/pluginConfig",
79
+ },
80
+ },
81
+ required: ["plugin", "provider"],
82
+ additionalProperties: true,
83
+ $defs: {
84
+ pluginConfig,
85
+ },
86
+ };
87
+ }
88
+ /**
89
+ * Serialize the generated schema exactly as it is committed on disk:
90
+ * 2-space indent (matching the previous handwritten file) plus a trailing
91
+ * newline. `JSON.stringify` preserves insertion order, so the output is
92
+ * byte-for-byte deterministic.
93
+ */
94
+ export function renderConfigJsonSchema() {
95
+ return `${JSON.stringify(buildConfigJsonSchema(), null, 2)}\n`;
96
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../lib/config.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAkF/C,MAAM,MAAM,sBAAsB,GAAG,QAAQ,GAAG,UAAU,CAAC;AAE3D,KAAK,wBAAwB,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,YAAY,CAAC;AAE3E,KAAK,yBAAyB,GAAG,OAAO,CACvC,wBAAwB,EACxB,SAAS,GAAG,MAAM,CAClB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,KAAK,GAAG,yBAAyB,GAAG,SAAS,CAAC;AAEhF,MAAM,WAAW,kBAAkB;IAClC,GAAG,EAAE,MAAM,YAAY,CAAC;IACxB,KAAK,EAAE,OAAO,CAAC;IACf,YAAY,EAAE,OAAO,CAAC;IACtB,MAAM,EAAE,mBAAmB,CAAC;IAC5B,QAAQ,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB;IACnC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,WAAW,EAAE,wBAAwB,CAAC;IACtC,OAAO,EAAE,kBAAkB,EAAE,CAAC;CAC9B;AAUD,wBAAgB,iCAAiC,IAAI,IAAI,CAExD;AAoED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,YAuDnC,CAAC;AAOF;;;;;;;GAOG;AACH,w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,YAAY,EAAE,YAAY,GACxB,MAAM,CAOR;AAED;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,CAO5E;AAED;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,CAO3E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,8BAA8B,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,CAOjF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,CAO3E;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAM3E;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAM7E;AAED;;;;;GAKG;AACH,wBAAgB,oCAAoC,CACnD,YAAY,EAAE,YAAY,GACxB,MAAM,CAOR;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,oCAAoC,CACnD,YAAY,EAAE,YAAY,GACxB,MAAM,CAOR;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,+BAA+B,CAC9C,YAAY,EAAE,YAAY,GACxB,MAAM,CAOR;AAID;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAClC,YAAY,EAAE,YAAY,GACxB,SAAS,GAAG,QAAQ,CAOtB;AAID;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,qBAAqB,CACpC,YAAY,EAAE,YAAY,GACxB,QAAQ,GAAG,YAAY,CAOzB;AAuWD,wBAAgB,4BAA4B,IAAI,mBAAmB,CA0BlE"}
@@ -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