codex-multi-auth 2.17.2 → 2.17.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (394) hide show
  1. package/.codex-plugin/plugin.json +1 -1
  2. package/README.md +83 -428
  3. package/dist/index.d.ts +0 -1
  4. package/dist/lib/account-policy.d.ts +18 -2
  5. package/dist/lib/account-policy.js +97 -40
  6. package/dist/lib/accounts/rate-limits.d.ts +0 -1
  7. package/dist/lib/accounts.d.ts +0 -1
  8. package/dist/lib/accounts.js +4 -5
  9. package/dist/lib/api-route-store.d.ts +0 -1
  10. package/dist/lib/audit.d.ts +0 -1
  11. package/dist/lib/audit.js +43 -12
  12. package/dist/lib/auth/account-access.d.ts +0 -1
  13. package/dist/lib/auth/account-access.js +5 -1
  14. package/dist/lib/auth/auth.d.ts +4 -3
  15. package/dist/lib/auth/auth.js +220 -28
  16. package/dist/lib/auth/browser.d.ts +0 -1
  17. package/dist/lib/auth/callback-guidance.d.ts +0 -1
  18. package/dist/lib/auth/device-auth.d.ts +0 -1
  19. package/dist/lib/auth/index.d.ts +0 -1
  20. package/dist/lib/auth/org-override.d.ts +0 -1
  21. package/dist/lib/auth/server.d.ts +1 -2
  22. package/dist/lib/auth/server.js +100 -53
  23. package/dist/lib/auth/token-utils.d.ts +0 -1
  24. package/dist/lib/auth-rate-limit.d.ts +0 -1
  25. package/dist/lib/budget-guard.d.ts +16 -2
  26. package/dist/lib/budget-guard.js +123 -43
  27. package/dist/lib/capability-policy.d.ts +0 -1
  28. package/dist/lib/circuit-breaker.d.ts +20 -1
  29. package/dist/lib/circuit-breaker.js +24 -5
  30. package/dist/lib/cli.d.ts +0 -1
  31. package/dist/lib/codex-cli/index.d.ts +0 -1
  32. package/dist/lib/codex-cli/observability.d.ts +0 -1
  33. package/dist/lib/codex-cli/state.d.ts +0 -1
  34. package/dist/lib/codex-cli/sync.d.ts +0 -1
  35. package/dist/lib/codex-cli/writer.d.ts +0 -1
  36. package/dist/lib/codex-manager/account-credentials.d.ts +0 -1
  37. package/dist/lib/codex-manager/account-manager-commands.d.ts +0 -1
  38. package/dist/lib/codex-manager/account-pool-write.d.ts +0 -1
  39. package/dist/lib/codex-manager/active-account-sync.d.ts +6 -0
  40. package/dist/lib/codex-manager/active-account-sync.js +336 -0
  41. package/dist/lib/codex-manager/api-login-menu.d.ts +0 -1
  42. package/dist/lib/codex-manager/backend-category-entry.d.ts +0 -1
  43. package/dist/lib/codex-manager/backend-category-helpers.d.ts +0 -1
  44. package/dist/lib/codex-manager/backend-category-prompt.d.ts +0 -1
  45. package/dist/lib/codex-manager/backend-settings-controller.d.ts +0 -1
  46. package/dist/lib/codex-manager/backend-settings-entry.d.ts +0 -1
  47. package/dist/lib/codex-manager/backend-settings-helpers.d.ts +0 -1
  48. package/dist/lib/codex-manager/backend-settings-prompt.d.ts +0 -1
  49. package/dist/lib/codex-manager/backend-settings-schema.d.ts +0 -1
  50. package/dist/lib/codex-manager/behavior-settings-panel.d.ts +0 -1
  51. package/dist/lib/codex-manager/commands/account.d.ts +8 -3
  52. package/dist/lib/codex-manager/commands/account.js +46 -34
  53. package/dist/lib/codex-manager/commands/best.d.ts +0 -1
  54. package/dist/lib/codex-manager/commands/bridge.d.ts +0 -1
  55. package/dist/lib/codex-manager/commands/budget.d.ts +8 -3
  56. package/dist/lib/codex-manager/commands/budget.js +6 -4
  57. package/dist/lib/codex-manager/commands/check.d.ts +0 -1
  58. package/dist/lib/codex-manager/commands/config-explain.d.ts +0 -1
  59. package/dist/lib/codex-manager/commands/debug-bundle.d.ts +0 -1
  60. package/dist/lib/codex-manager/commands/forecast.d.ts +0 -1
  61. package/dist/lib/codex-manager/commands/history.d.ts +0 -1
  62. package/dist/lib/codex-manager/commands/init-config.d.ts +0 -1
  63. package/dist/lib/codex-manager/commands/integrations.d.ts +0 -1
  64. package/dist/lib/codex-manager/commands/limits.d.ts +0 -1
  65. package/dist/lib/codex-manager/commands/models.d.ts +0 -1
  66. package/dist/lib/codex-manager/commands/monitor.d.ts +0 -1
  67. package/dist/lib/codex-manager/commands/report.d.ts +0 -1
  68. package/dist/lib/codex-manager/commands/resets.d.ts +0 -1
  69. package/dist/lib/codex-manager/commands/resets.js +9 -1
  70. package/dist/lib/codex-manager/commands/rotation.d.ts +0 -1
  71. package/dist/lib/codex-manager/commands/status.d.ts +0 -1
  72. package/dist/lib/codex-manager/commands/switch.d.ts +0 -1
  73. package/dist/lib/codex-manager/commands/uninstall.d.ts +0 -1
  74. package/dist/lib/codex-manager/commands/unpin.d.ts +0 -1
  75. package/dist/lib/codex-manager/commands/usage.d.ts +0 -1
  76. package/dist/lib/codex-manager/commands/verify.d.ts +0 -1
  77. package/dist/lib/codex-manager/commands/why-selected.d.ts +0 -1
  78. package/dist/lib/codex-manager/commands/workspace.d.ts +0 -1
  79. package/dist/lib/codex-manager/dashboard-display-panel.d.ts +0 -1
  80. package/dist/lib/codex-manager/dashboard-formatters.d.ts +0 -1
  81. package/dist/lib/codex-manager/dashboard-settings-controller.d.ts +0 -1
  82. package/dist/lib/codex-manager/dashboard-settings-data.d.ts +0 -1
  83. package/dist/lib/codex-manager/dashboard-settings-entry.d.ts +0 -1
  84. package/dist/lib/codex-manager/experimental-settings-entry.d.ts +0 -1
  85. package/dist/lib/codex-manager/experimental-settings-prompt.d.ts +0 -1
  86. package/dist/lib/codex-manager/experimental-settings-schema.d.ts +0 -1
  87. package/dist/lib/codex-manager/experimental-sync-target-entry.d.ts +0 -1
  88. package/dist/lib/codex-manager/experimental-sync-target.d.ts +0 -1
  89. package/dist/lib/codex-manager/forecast-report-shared.d.ts +0 -1
  90. package/dist/lib/codex-manager/formatters/account-formatters.d.ts +0 -1
  91. package/dist/lib/codex-manager/formatters/index.d.ts +0 -1
  92. package/dist/lib/codex-manager/formatters/model-formatters.d.ts +0 -1
  93. package/dist/lib/codex-manager/formatters/quota-formatters.d.ts +0 -1
  94. package/dist/lib/codex-manager/formatters/text-style.d.ts +0 -1
  95. package/dist/lib/codex-manager/health-check.d.ts +0 -1
  96. package/dist/lib/codex-manager/help.d.ts +0 -1
  97. package/dist/lib/codex-manager/login-action-panel.d.ts +0 -1
  98. package/dist/lib/codex-manager/login-flow.d.ts +0 -1
  99. package/dist/lib/codex-manager/login-menu-actions.d.ts +0 -1
  100. package/dist/lib/codex-manager/login-menu-data.d.ts +0 -1
  101. package/dist/lib/codex-manager/login-oauth.d.ts +0 -1
  102. package/dist/lib/codex-manager/login-workspace-choice.d.ts +0 -1
  103. package/dist/lib/codex-manager/manual-callback.d.ts +0 -1
  104. package/dist/lib/codex-manager/persist-selected-account.d.ts +0 -1
  105. package/dist/lib/codex-manager/quota-cache-helpers.d.ts +0 -1
  106. package/dist/lib/codex-manager/rate-limit-markers.d.ts +0 -1
  107. package/dist/lib/codex-manager/repair-commands.d.ts +0 -1
  108. package/dist/lib/codex-manager/settings-hub/backend.d.ts +0 -1
  109. package/dist/lib/codex-manager/settings-hub/dashboard.d.ts +0 -1
  110. package/dist/lib/codex-manager/settings-hub/experimental.d.ts +0 -1
  111. package/dist/lib/codex-manager/settings-hub/index.d.ts +0 -1
  112. package/dist/lib/codex-manager/settings-hub/shared.d.ts +0 -1
  113. package/dist/lib/codex-manager/settings-hub-entry.d.ts +0 -1
  114. package/dist/lib/codex-manager/settings-hub-menu.d.ts +0 -1
  115. package/dist/lib/codex-manager/settings-hub-prompt.d.ts +0 -1
  116. package/dist/lib/codex-manager/settings-hub.d.ts +0 -1
  117. package/dist/lib/codex-manager/settings-panels.d.ts +0 -1
  118. package/dist/lib/codex-manager/settings-persist-utils.d.ts +0 -1
  119. package/dist/lib/codex-manager/settings-preview.d.ts +0 -1
  120. package/dist/lib/codex-manager/settings-write-queue.d.ts +0 -1
  121. package/dist/lib/codex-manager/statusline-settings-panel.d.ts +0 -1
  122. package/dist/lib/codex-manager/theme-settings-panel.d.ts +0 -1
  123. package/dist/lib/codex-manager/unified-settings-controller.d.ts +0 -1
  124. package/dist/lib/codex-manager/unified-settings-entry.d.ts +0 -1
  125. package/dist/lib/codex-manager.d.ts +1 -2
  126. package/dist/lib/codex-manager.js +5 -95
  127. package/dist/lib/concurrency.d.ts +0 -1
  128. package/dist/lib/config-schema.d.ts +0 -1
  129. package/dist/lib/config.d.ts +0 -1
  130. package/dist/lib/config.js +46 -241
  131. package/dist/lib/constants.d.ts +0 -1
  132. package/dist/lib/context-budget/model-context-windows.d.ts +0 -1
  133. package/dist/lib/context-budget-guard.d.ts +0 -1
  134. package/dist/lib/context-budget-response.d.ts +0 -1
  135. package/dist/lib/context-overflow.d.ts +0 -1
  136. package/dist/lib/dashboard-settings.d.ts +0 -1
  137. package/dist/lib/entitlement-cache.d.ts +0 -1
  138. package/dist/lib/env-parsing.d.ts +13 -1
  139. package/dist/lib/env-parsing.js +21 -0
  140. package/dist/lib/errors.d.ts +0 -1
  141. package/dist/lib/forecast.d.ts +0 -1
  142. package/dist/lib/fs-retry.d.ts +0 -1
  143. package/dist/lib/health.d.ts +0 -1
  144. package/dist/lib/index.d.ts +0 -1
  145. package/dist/lib/integration-generators.d.ts +0 -1
  146. package/dist/lib/live-account-sync.d.ts +0 -1
  147. package/dist/lib/local-bridge.d.ts +0 -1
  148. package/dist/lib/local-bridge.js +4 -1
  149. package/dist/lib/local-client-tokens.d.ts +0 -1
  150. package/dist/lib/local-client-tokens.js +125 -30
  151. package/dist/lib/logger.d.ts +0 -1
  152. package/dist/lib/logger.js +11 -1
  153. package/dist/lib/model-capability-matrix.d.ts +0 -1
  154. package/dist/lib/model-route-policy.d.ts +1 -2
  155. package/dist/lib/named-backup-export.d.ts +0 -1
  156. package/dist/lib/oc-chatgpt-import-adapter.d.ts +0 -1
  157. package/dist/lib/oc-chatgpt-orchestrator.d.ts +0 -1
  158. package/dist/lib/oc-chatgpt-target-detection.d.ts +0 -1
  159. package/dist/lib/parallel-probe.d.ts +0 -1
  160. package/dist/lib/policy/runtime-policy-cache.d.ts +80 -0
  161. package/dist/lib/policy/runtime-policy-cache.js +310 -0
  162. package/dist/lib/policy/runtime-policy.d.ts +1 -2
  163. package/dist/lib/policy/runtime-policy.js +46 -19
  164. package/dist/lib/preemptive-quota-scheduler.d.ts +0 -1
  165. package/dist/lib/proactive-refresh.d.ts +0 -1
  166. package/dist/lib/prompts/codex-host-bridge.d.ts +0 -1
  167. package/dist/lib/prompts/codex.d.ts +0 -1
  168. package/dist/lib/prompts/fetch-utils.d.ts +0 -1
  169. package/dist/lib/prompts/host-codex-prompt.d.ts +0 -1
  170. package/dist/lib/quota-cache.d.ts +0 -1
  171. package/dist/lib/quota-cache.js +60 -36
  172. package/dist/lib/quota-probe.d.ts +0 -1
  173. package/dist/lib/quota-probe.js +5 -2
  174. package/dist/lib/quota-readiness.d.ts +0 -1
  175. package/dist/lib/recovery/constants.d.ts +0 -1
  176. package/dist/lib/recovery/storage.d.ts +0 -1
  177. package/dist/lib/recovery/types.d.ts +0 -1
  178. package/dist/lib/recovery.d.ts +0 -1
  179. package/dist/lib/redaction.d.ts +0 -1
  180. package/dist/lib/refresh-guardian.d.ts +0 -1
  181. package/dist/lib/refresh-lease.d.ts +0 -1
  182. package/dist/lib/refresh-queue.d.ts +0 -1
  183. package/dist/lib/request/client-cancellation.d.ts +0 -1
  184. package/dist/lib/request/error-classification.d.ts +0 -1
  185. package/dist/lib/request/failover-config.d.ts +0 -1
  186. package/dist/lib/request/failure-policy.d.ts +0 -1
  187. package/dist/lib/request/fetch-helpers.d.ts +0 -1
  188. package/dist/lib/request/headers.d.ts +0 -1
  189. package/dist/lib/request/helpers/input-utils.d.ts +0 -1
  190. package/dist/lib/request/helpers/input-utils.js +88 -34
  191. package/dist/lib/request/helpers/model-map.d.ts +0 -1
  192. package/dist/lib/request/helpers/tool-utils.d.ts +0 -1
  193. package/dist/lib/request/helpers/tool-utils.js +421 -4
  194. package/dist/lib/request/index.d.ts +0 -1
  195. package/dist/lib/request/rate-limit-backoff.d.ts +0 -1
  196. package/dist/lib/request/rate-limit-decision.d.ts +0 -1
  197. package/dist/lib/request/request-attempt-budget.d.ts +0 -1
  198. package/dist/lib/request/request-init.d.ts +0 -1
  199. package/dist/lib/request/request-resilience.d.ts +0 -1
  200. package/dist/lib/request/request-transformer.d.ts +0 -1
  201. package/dist/lib/request/request-transformer.js +50 -25
  202. package/dist/lib/request/response-compaction.d.ts +0 -1
  203. package/dist/lib/request/response-handler.d.ts +0 -1
  204. package/dist/lib/request/response-metadata.d.ts +0 -1
  205. package/dist/lib/request/response-outcome.d.ts +0 -1
  206. package/dist/lib/request/stream-failover-runtime.d.ts +0 -1
  207. package/dist/lib/request/stream-failover.d.ts +0 -1
  208. package/dist/lib/request/stream-failover.js +28 -4
  209. package/dist/lib/request/token-refresh.d.ts +0 -1
  210. package/dist/lib/request/url-rewriting.d.ts +0 -1
  211. package/dist/lib/request/wait-utils.d.ts +0 -1
  212. package/dist/lib/rotation.d.ts +0 -1
  213. package/dist/lib/routing-mutex.d.ts +0 -1
  214. package/dist/lib/routing-profiles.d.ts +16 -2
  215. package/dist/lib/routing-profiles.js +119 -44
  216. package/dist/lib/runtime/account-check-helpers.d.ts +0 -1
  217. package/dist/lib/runtime/account-check-types.d.ts +0 -1
  218. package/dist/lib/runtime/account-check.d.ts +0 -1
  219. package/dist/lib/runtime/account-manager-cache-entry.d.ts +0 -1
  220. package/dist/lib/runtime/account-manager-cache.d.ts +0 -1
  221. package/dist/lib/runtime/account-model-catalog.d.ts +1 -2
  222. package/dist/lib/runtime/account-pool.d.ts +0 -1
  223. package/dist/lib/runtime/account-reset-credits.d.ts +0 -1
  224. package/dist/lib/runtime/account-reset-credits.js +8 -2
  225. package/dist/lib/runtime/account-scope.d.ts +0 -1
  226. package/dist/lib/runtime/account-select-event.d.ts +0 -1
  227. package/dist/lib/runtime/account-selection.d.ts +0 -1
  228. package/dist/lib/runtime/account-state.d.ts +0 -1
  229. package/dist/lib/runtime/account-status.d.ts +0 -1
  230. package/dist/lib/runtime/account-storage-scope-entry.d.ts +0 -1
  231. package/dist/lib/runtime/api-model-capabilities.d.ts +0 -1
  232. package/dist/lib/runtime/api-model-runtime.d.ts +0 -1
  233. package/dist/lib/runtime/app-bind.d.ts +0 -1
  234. package/dist/lib/runtime/app-helper-selection.d.ts +0 -1
  235. package/dist/lib/runtime/auth-facade.d.ts +0 -1
  236. package/dist/lib/runtime/automatic-account-checks.d.ts +0 -1
  237. package/dist/lib/runtime/automatic-subscription-checks.d.ts +0 -1
  238. package/dist/lib/runtime/browser-oauth-flow.d.ts +0 -1
  239. package/dist/lib/runtime/capability-boost.d.ts +0 -1
  240. package/dist/lib/runtime/catalog-capabilities.d.ts +0 -1
  241. package/dist/lib/runtime/config-toml.d.ts +0 -1
  242. package/dist/lib/runtime/context-budget-settings.d.ts +0 -1
  243. package/dist/lib/runtime/event-handler.d.ts +0 -1
  244. package/dist/lib/runtime/first-run.d.ts +0 -1
  245. package/dist/lib/runtime/flagged-verify-types.d.ts +0 -1
  246. package/dist/lib/runtime/hydrate-emails.d.ts +0 -1
  247. package/dist/lib/runtime/inference-activity.d.ts +0 -1
  248. package/dist/lib/runtime/live-sync-entry.d.ts +0 -1
  249. package/dist/lib/runtime/live-sync.d.ts +0 -1
  250. package/dist/lib/runtime/loader-setup.d.ts +0 -1
  251. package/dist/lib/runtime/login-menu-accounts.d.ts +0 -1
  252. package/dist/lib/runtime/manual-oauth-flow.d.ts +0 -1
  253. package/dist/lib/runtime/model-discovery-status.d.ts +2 -3
  254. package/dist/lib/runtime/native-account-storage.d.ts +0 -1
  255. package/dist/lib/runtime/native-account-sync.d.ts +0 -1
  256. package/dist/lib/runtime/native-binding-lock.d.ts +0 -1
  257. package/dist/lib/runtime/native-client-auth.d.ts +0 -1
  258. package/dist/lib/runtime/native-provider-config.d.ts +0 -1
  259. package/dist/lib/runtime/native-rate-limits.d.ts +2 -1
  260. package/dist/lib/runtime/native-rate-limits.js +23 -6
  261. package/dist/lib/runtime/preemptive-quota.d.ts +0 -1
  262. package/dist/lib/runtime/quota-headers.d.ts +0 -1
  263. package/dist/lib/runtime/quota-probe.d.ts +0 -1
  264. package/dist/lib/runtime/quota-settings.d.ts +0 -1
  265. package/dist/lib/runtime/refresh-guardian-entry.d.ts +0 -1
  266. package/dist/lib/runtime/refresh-guardian.d.ts +0 -1
  267. package/dist/lib/runtime/request-init.d.ts +0 -1
  268. package/dist/lib/runtime/reset-credit-routing.d.ts +0 -1
  269. package/dist/lib/runtime/reset-credits.d.ts +0 -1
  270. package/dist/lib/runtime/response-output-history.d.ts +0 -1
  271. package/dist/lib/runtime/responses-websocket.d.ts +0 -1
  272. package/dist/lib/runtime/resume-picker.d.ts +0 -1
  273. package/dist/lib/runtime/rotation-account-selection.d.ts +0 -1
  274. package/dist/lib/runtime/rotation-proxy-state.d.ts +0 -1
  275. package/dist/lib/runtime/rotation-server-types.d.ts +0 -1
  276. package/dist/lib/runtime/rotation-storage-meta.d.ts +0 -1
  277. package/dist/lib/runtime/rotation-token-refresh.d.ts +0 -1
  278. package/dist/lib/runtime/runtime-capability-failures.d.ts +0 -1
  279. package/dist/lib/runtime/runtime-current-account.d.ts +0 -1
  280. package/dist/lib/runtime/runtime-observability.d.ts +0 -1
  281. package/dist/lib/runtime/runtime-services.d.ts +0 -1
  282. package/dist/lib/runtime/session-affinity-entry.d.ts +0 -1
  283. package/dist/lib/runtime/session-recovery.d.ts +0 -1
  284. package/dist/lib/runtime/status-marker.d.ts +0 -1
  285. package/dist/lib/runtime/storage-scope.d.ts +0 -1
  286. package/dist/lib/runtime/subscription-first-use.d.ts +0 -1
  287. package/dist/lib/runtime/subscription-quota-event.d.ts +0 -1
  288. package/dist/lib/runtime/subscription-quota-order.d.ts +0 -1
  289. package/dist/lib/runtime/toast.d.ts +0 -1
  290. package/dist/lib/runtime/ui-runtime-entry.d.ts +0 -1
  291. package/dist/lib/runtime/ui-runtime.d.ts +0 -1
  292. package/dist/lib/runtime/verify-flagged.d.ts +0 -1
  293. package/dist/lib/runtime/workspace-model-scopes.d.ts +0 -1
  294. package/dist/lib/runtime-constants.d.ts +0 -1
  295. package/dist/lib/runtime-paths.d.ts +0 -1
  296. package/dist/lib/runtime-rotation-proxy.d.ts +1 -1
  297. package/dist/lib/runtime-rotation-proxy.js +133 -0
  298. package/dist/lib/schemas.d.ts +35 -13
  299. package/dist/lib/schemas.js +19 -2
  300. package/dist/lib/session-affinity.d.ts +0 -1
  301. package/dist/lib/shutdown.d.ts +0 -1
  302. package/dist/lib/storage/account-clear-entry.d.ts +0 -1
  303. package/dist/lib/storage/account-clear.d.ts +0 -1
  304. package/dist/lib/storage/account-match-utils.d.ts +0 -1
  305. package/dist/lib/storage/account-persistence.d.ts +0 -1
  306. package/dist/lib/storage/account-port.d.ts +0 -1
  307. package/dist/lib/storage/account-save-entry.d.ts +0 -1
  308. package/dist/lib/storage/account-save.d.ts +9 -2
  309. package/dist/lib/storage/account-save.js +4 -1
  310. package/dist/lib/storage/account-snapshot.d.ts +0 -1
  311. package/dist/lib/storage/backup-metadata-builder.d.ts +0 -1
  312. package/dist/lib/storage/backup-metadata.d.ts +0 -1
  313. package/dist/lib/storage/backup-paths.d.ts +0 -1
  314. package/dist/lib/storage/backup-restore.d.ts +0 -1
  315. package/dist/lib/storage/cache-artifacts.d.ts +0 -1
  316. package/dist/lib/storage/credential-sidecars.d.ts +0 -1
  317. package/dist/lib/storage/error-hints.d.ts +0 -1
  318. package/dist/lib/storage/file-lock.d.ts +0 -1
  319. package/dist/lib/storage/file-lock.js +33 -1
  320. package/dist/lib/storage/file-paths.d.ts +0 -1
  321. package/dist/lib/storage/fixture-guards.d.ts +0 -1
  322. package/dist/lib/storage/flagged-entry.d.ts +0 -1
  323. package/dist/lib/storage/flagged-load-entry.d.ts +0 -1
  324. package/dist/lib/storage/flagged-save-entry.d.ts +0 -1
  325. package/dist/lib/storage/flagged-storage-file.d.ts +0 -1
  326. package/dist/lib/storage/flagged-storage-io.d.ts +0 -1
  327. package/dist/lib/storage/flagged-storage.d.ts +0 -1
  328. package/dist/lib/storage/gitignore.d.ts +0 -1
  329. package/dist/lib/storage/hash.d.ts +0 -1
  330. package/dist/lib/storage/health.d.ts +0 -1
  331. package/dist/lib/storage/identity.d.ts +0 -1
  332. package/dist/lib/storage/import-export.d.ts +0 -1
  333. package/dist/lib/storage/json-store-lock.d.ts +105 -0
  334. package/dist/lib/storage/json-store-lock.js +259 -0
  335. package/dist/lib/storage/metadata-section.d.ts +0 -1
  336. package/dist/lib/storage/migrations.d.ts +0 -1
  337. package/dist/lib/storage/migrations.js +31 -18
  338. package/dist/lib/storage/named-backup-entry.d.ts +0 -1
  339. package/dist/lib/storage/named-backups-entry.d.ts +0 -1
  340. package/dist/lib/storage/named-backups.d.ts +0 -1
  341. package/dist/lib/storage/path-state.d.ts +0 -1
  342. package/dist/lib/storage/paths.d.ts +0 -1
  343. package/dist/lib/storage/pending-auth.d.ts +9 -3
  344. package/dist/lib/storage/pending-auth.js +30 -8
  345. package/dist/lib/storage/project-migration.d.ts +0 -1
  346. package/dist/lib/storage/public-types.d.ts +0 -1
  347. package/dist/lib/storage/record-identity.d.ts +0 -1
  348. package/dist/lib/storage/record-utils.d.ts +0 -1
  349. package/dist/lib/storage/restore-assessment.d.ts +0 -1
  350. package/dist/lib/storage/restore-backup-entry.d.ts +0 -1
  351. package/dist/lib/storage/restore-metadata.d.ts +0 -1
  352. package/dist/lib/storage/save-retry.d.ts +0 -1
  353. package/dist/lib/storage/snapshot-inspectors.d.ts +0 -1
  354. package/dist/lib/storage/snapshot-merge.d.ts +0 -1
  355. package/dist/lib/storage/storage-parser.d.ts +2 -1
  356. package/dist/lib/storage/storage-parser.js +10 -2
  357. package/dist/lib/storage/transactions.d.ts +0 -1
  358. package/dist/lib/storage.d.ts +15 -2
  359. package/dist/lib/storage.js +612 -25
  360. package/dist/lib/synthetic-response.d.ts +0 -1
  361. package/dist/lib/table-formatter.d.ts +0 -1
  362. package/dist/lib/temp-path.d.ts +0 -1
  363. package/dist/lib/tools/hashline-tools.d.ts +0 -1
  364. package/dist/lib/types.d.ts +0 -1
  365. package/dist/lib/ui/ansi.d.ts +0 -1
  366. package/dist/lib/ui/auth-menu-builder.d.ts +0 -1
  367. package/dist/lib/ui/auth-menu.d.ts +0 -1
  368. package/dist/lib/ui/check-progress.d.ts +0 -1
  369. package/dist/lib/ui/confirm.d.ts +0 -1
  370. package/dist/lib/ui/display-width.d.ts +0 -1
  371. package/dist/lib/ui/format.d.ts +0 -1
  372. package/dist/lib/ui/index.d.ts +0 -1
  373. package/dist/lib/ui/runtime.d.ts +0 -1
  374. package/dist/lib/ui/select.d.ts +0 -1
  375. package/dist/lib/ui/theme.d.ts +0 -1
  376. package/dist/lib/ui/ui-copy.d.ts +0 -1
  377. package/dist/lib/unified-settings.d.ts +13 -11
  378. package/dist/lib/unified-settings.js +22 -14
  379. package/dist/lib/update-notice.d.ts +0 -1
  380. package/dist/lib/usage/index.d.ts +0 -1
  381. package/dist/lib/usage/ledger.d.ts +0 -1
  382. package/dist/lib/usage/pricing.d.ts +0 -1
  383. package/dist/lib/usage/redaction.d.ts +0 -1
  384. package/dist/lib/usage/stream-usage-deferral.d.ts +0 -1
  385. package/dist/lib/usage/types.d.ts +0 -1
  386. package/dist/lib/usage/usage-extraction.d.ts +0 -1
  387. package/dist/lib/utils.d.ts +21 -1
  388. package/dist/lib/utils.js +31 -0
  389. package/dist/lib/wsl.d.ts +0 -1
  390. package/package.json +11 -5
  391. package/scripts/codex-bin-resolver.js +20 -1
  392. package/scripts/codex-multi-auth.js +7 -1
  393. package/scripts/codex.js +288 -7
  394. package/skills/codex-auth-setup/SKILL.md +73 -0
@@ -138,10 +138,10 @@ export declare const AccountMetadataV3Schema: z.ZodObject<{
138
138
  rateLimitResetTimes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodNumber>>>;
139
139
  coolingDownUntil: z.ZodOptional<z.ZodNumber>;
140
140
  cooldownReason: z.ZodOptional<z.ZodEnum<{
141
+ "rate-limit": "rate-limit";
141
142
  "auth-failure": "auth-failure";
142
143
  "network-error": "network-error";
143
144
  "server-error": "server-error";
144
- "rate-limit": "rate-limit";
145
145
  }>>;
146
146
  authInvalidatedAt: z.ZodOptional<z.ZodNumber>;
147
147
  authInvalidationErrorCode: z.ZodOptional<z.ZodString>;
@@ -191,10 +191,10 @@ export declare const AccountStorageV3Schema: z.ZodObject<{
191
191
  rateLimitResetTimes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodNumber>>>;
192
192
  coolingDownUntil: z.ZodOptional<z.ZodNumber>;
193
193
  cooldownReason: z.ZodOptional<z.ZodEnum<{
194
+ "rate-limit": "rate-limit";
194
195
  "auth-failure": "auth-failure";
195
196
  "network-error": "network-error";
196
197
  "server-error": "server-error";
197
- "rate-limit": "rate-limit";
198
198
  }>>;
199
199
  authInvalidatedAt: z.ZodOptional<z.ZodNumber>;
200
200
  authInvalidationErrorCode: z.ZodOptional<z.ZodString>;
@@ -225,6 +225,11 @@ export declare const AccountStorageV3Schema: z.ZodObject<{
225
225
  export type AccountStorageV3FromSchema = z.infer<typeof AccountStorageV3Schema>;
226
226
  /**
227
227
  * Legacy V1 storage format for migration support.
228
+ *
229
+ * The V3-era top-level fields are accepted too: a hybrid file (version:1 but
230
+ * written by newer code) must not lose `activeIndexByFamily` /
231
+ * `pinnedAccountIndex` / `affinityGeneration` at the schema boundary before
232
+ * normalizeAccountStorage can consume them.
228
233
  */
229
234
  export declare const AccountStorageV1Schema: z.ZodObject<{
230
235
  version: z.ZodLiteral<1>;
@@ -255,13 +260,22 @@ export declare const AccountStorageV1Schema: z.ZodObject<{
255
260
  rateLimitResetTime: z.ZodOptional<z.ZodNumber>;
256
261
  coolingDownUntil: z.ZodOptional<z.ZodNumber>;
257
262
  cooldownReason: z.ZodOptional<z.ZodEnum<{
263
+ "rate-limit": "rate-limit";
258
264
  "auth-failure": "auth-failure";
259
265
  "network-error": "network-error";
260
266
  "server-error": "server-error";
261
- "rate-limit": "rate-limit";
262
267
  }>>;
263
- }, z.core.$strip>>;
268
+ }, z.core.$loose>>;
264
269
  activeIndex: z.ZodNumber;
270
+ activeIndexByFamily: z.ZodOptional<z.ZodObject<{
271
+ "gpt-5-codex": z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
272
+ "codex-max": z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
273
+ codex: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
274
+ "gpt-5.2": z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
275
+ "gpt-5.1": z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
276
+ }, z.core.$strip>>;
277
+ pinnedAccountIndex: z.ZodOptional<z.ZodNumber>;
278
+ affinityGeneration: z.ZodOptional<z.ZodNumber>;
265
279
  }, z.core.$strip>;
266
280
  /**
267
281
  * Union of V1 and V3 storage formats for migration detection.
@@ -295,13 +309,22 @@ export declare const AnyAccountStorageSchema: z.ZodDiscriminatedUnion<[z.ZodObje
295
309
  rateLimitResetTime: z.ZodOptional<z.ZodNumber>;
296
310
  coolingDownUntil: z.ZodOptional<z.ZodNumber>;
297
311
  cooldownReason: z.ZodOptional<z.ZodEnum<{
312
+ "rate-limit": "rate-limit";
298
313
  "auth-failure": "auth-failure";
299
314
  "network-error": "network-error";
300
315
  "server-error": "server-error";
301
- "rate-limit": "rate-limit";
302
316
  }>>;
303
- }, z.core.$strip>>;
317
+ }, z.core.$loose>>;
304
318
  activeIndex: z.ZodNumber;
319
+ activeIndexByFamily: z.ZodOptional<z.ZodObject<{
320
+ "gpt-5-codex": z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
321
+ "codex-max": z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
322
+ codex: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
323
+ "gpt-5.2": z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
324
+ "gpt-5.1": z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
325
+ }, z.core.$strip>>;
326
+ pinnedAccountIndex: z.ZodOptional<z.ZodNumber>;
327
+ affinityGeneration: z.ZodOptional<z.ZodNumber>;
305
328
  }, z.core.$strip>, z.ZodObject<{
306
329
  version: z.ZodLiteral<3>;
307
330
  accounts: z.ZodArray<z.ZodObject<{
@@ -332,10 +355,10 @@ export declare const AnyAccountStorageSchema: z.ZodDiscriminatedUnion<[z.ZodObje
332
355
  rateLimitResetTimes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodNumber>>>;
333
356
  coolingDownUntil: z.ZodOptional<z.ZodNumber>;
334
357
  cooldownReason: z.ZodOptional<z.ZodEnum<{
358
+ "rate-limit": "rate-limit";
335
359
  "auth-failure": "auth-failure";
336
360
  "network-error": "network-error";
337
361
  "server-error": "server-error";
338
- "rate-limit": "rate-limit";
339
362
  }>>;
340
363
  authInvalidatedAt: z.ZodOptional<z.ZodNumber>;
341
364
  authInvalidationErrorCode: z.ZodOptional<z.ZodString>;
@@ -397,10 +420,10 @@ export declare const FlaggedAccountMetadataV1Schema: z.ZodObject<{
397
420
  rateLimitResetTimes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodNumber>>>;
398
421
  coolingDownUntil: z.ZodOptional<z.ZodNumber>;
399
422
  cooldownReason: z.ZodOptional<z.ZodEnum<{
423
+ "rate-limit": "rate-limit";
400
424
  "auth-failure": "auth-failure";
401
425
  "network-error": "network-error";
402
426
  "server-error": "server-error";
403
- "rate-limit": "rate-limit";
404
427
  }>>;
405
428
  authInvalidatedAt: z.ZodOptional<z.ZodNumber>;
406
429
  authInvalidationErrorCode: z.ZodOptional<z.ZodString>;
@@ -453,10 +476,10 @@ export declare const FlaggedAccountStorageV1Schema: z.ZodObject<{
453
476
  rateLimitResetTimes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodNumber>>>;
454
477
  coolingDownUntil: z.ZodOptional<z.ZodNumber>;
455
478
  cooldownReason: z.ZodOptional<z.ZodEnum<{
479
+ "rate-limit": "rate-limit";
456
480
  "auth-failure": "auth-failure";
457
481
  "network-error": "network-error";
458
482
  "server-error": "server-error";
459
- "rate-limit": "rate-limit";
460
483
  }>>;
461
484
  authInvalidatedAt: z.ZodOptional<z.ZodNumber>;
462
485
  authInvalidationErrorCode: z.ZodOptional<z.ZodString>;
@@ -495,12 +518,12 @@ export type AccountsJournalEntryFromSchema = z.infer<typeof AccountsJournalEntry
495
518
  * Token failure reason codes.
496
519
  */
497
520
  declare const TokenFailureReasonSchema: z.ZodEnum<{
498
- unknown: "unknown";
499
521
  http_error: "http_error";
500
522
  invalid_response: "invalid_response";
501
523
  network_error: "network_error";
502
524
  missing_refresh: "missing_refresh";
503
525
  timeout: "timeout";
526
+ unknown: "unknown";
504
527
  }>;
505
528
  export type TokenFailureReasonFromSchema = z.infer<typeof TokenFailureReasonSchema>;
506
529
  /**
@@ -521,12 +544,12 @@ export type TokenSuccessFromSchema = z.infer<typeof TokenSuccessSchema>;
521
544
  export declare const TokenFailureSchema: z.ZodObject<{
522
545
  type: z.ZodLiteral<"failed">;
523
546
  reason: z.ZodOptional<z.ZodEnum<{
524
- unknown: "unknown";
525
547
  http_error: "http_error";
526
548
  invalid_response: "invalid_response";
527
549
  network_error: "network_error";
528
550
  missing_refresh: "missing_refresh";
529
551
  timeout: "timeout";
552
+ unknown: "unknown";
530
553
  }>>;
531
554
  statusCode: z.ZodOptional<z.ZodNumber>;
532
555
  message: z.ZodOptional<z.ZodString>;
@@ -545,12 +568,12 @@ export declare const TokenResultSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
545
568
  }, z.core.$strip>, z.ZodObject<{
546
569
  type: z.ZodLiteral<"failed">;
547
570
  reason: z.ZodOptional<z.ZodEnum<{
548
- unknown: "unknown";
549
571
  http_error: "http_error";
550
572
  invalid_response: "invalid_response";
551
573
  network_error: "network_error";
552
574
  missing_refresh: "missing_refresh";
553
575
  timeout: "timeout";
576
+ unknown: "unknown";
554
577
  }>>;
555
578
  statusCode: z.ZodOptional<z.ZodNumber>;
556
579
  message: z.ZodOptional<z.ZodString>;
@@ -624,4 +647,3 @@ export declare function safeParseJson<T>(raw: unknown, schema: z.ZodType<T>, con
624
647
  */
625
648
  export declare function getValidationErrors(schema: z.ZodType, data: unknown): string[];
626
649
  export {};
627
- //# sourceMappingURL=schemas.d.ts.map
@@ -202,8 +202,16 @@ export const AccountStorageV3Schema = z.object({
202
202
  });
203
203
  /**
204
204
  * Legacy V1 account metadata for migration support.
205
+ *
206
+ * Uses `passthrough` so V3-compatible extra fields (workspaces,
207
+ * rateLimitResetTimes, authInvalidatedAt, …) survive the schema boundary:
208
+ * version:1 files with V3-era rows are real (the flagged-accounts store is
209
+ * `version: 1` with full V3 rows) and migrateV1ToV3 now carries unknown
210
+ * fields forward — stripping them here would make that preservation a no-op
211
+ * for every schema-valid file. Same rationale as FlaggedAccountMetadataV1Schema.
205
212
  */
206
- const AccountMetadataV1Schema = z.object({
213
+ const AccountMetadataV1Schema = z
214
+ .object({
207
215
  accountId: z.string().optional(),
208
216
  accountIdSource: AccountIdSourceSchema.optional(),
209
217
  accountLabel: z.string().optional(),
@@ -218,14 +226,23 @@ const AccountMetadataV1Schema = z.object({
218
226
  rateLimitResetTime: z.number().optional(), // V1 used single value
219
227
  coolingDownUntil: z.number().optional(),
220
228
  cooldownReason: CooldownReasonSchema.optional(),
221
- });
229
+ })
230
+ .passthrough();
222
231
  /**
223
232
  * Legacy V1 storage format for migration support.
233
+ *
234
+ * The V3-era top-level fields are accepted too: a hybrid file (version:1 but
235
+ * written by newer code) must not lose `activeIndexByFamily` /
236
+ * `pinnedAccountIndex` / `affinityGeneration` at the schema boundary before
237
+ * normalizeAccountStorage can consume them.
224
238
  */
225
239
  export const AccountStorageV1Schema = z.object({
226
240
  version: z.literal(1),
227
241
  accounts: z.array(AccountMetadataV1Schema),
228
242
  activeIndex: z.number().min(0),
243
+ activeIndexByFamily: ActiveIndexByFamilySchema.optional(),
244
+ pinnedAccountIndex: z.number().int().min(0).optional(),
245
+ affinityGeneration: z.number().int().min(0).optional(),
229
246
  });
230
247
  /**
231
248
  * Union of V1 and V3 storage formats for migration detection.
@@ -40,4 +40,3 @@ export declare class SessionAffinityStore {
40
40
  private findOldestKey;
41
41
  private normalizeWriteVersion;
42
42
  }
43
- //# sourceMappingURL=session-affinity.d.ts.map
@@ -4,4 +4,3 @@ export declare function unregisterCleanup(fn: CleanupFn): void;
4
4
  export declare function runCleanup(): Promise<void>;
5
5
  export declare function getCleanupCount(): number;
6
6
  export {};
7
- //# sourceMappingURL=shutdown.d.ts.map
@@ -13,4 +13,3 @@ export declare function clearAccountsEntry(params: {
13
13
  }) => Promise<void>;
14
14
  logError: (message: string, details: Record<string, unknown>) => void;
15
15
  }): Promise<void>;
16
- //# sourceMappingURL=account-clear-entry.d.ts.map
@@ -5,4 +5,3 @@ export declare function clearAccountStorageArtifacts(params: {
5
5
  backupPaths: string[];
6
6
  logError: (message: string, details: Record<string, unknown>) => void;
7
7
  }): Promise<void>;
8
- //# sourceMappingURL=account-clear.d.ts.map
@@ -6,4 +6,3 @@ export declare function selectNewestAccount<T extends AccountLike>(current: T |
6
6
  export declare function collectDistinctIdentityValues(values: Array<string | undefined>): Set<string>;
7
7
  export declare function findNewestMatchingIndex<T, TRef>(accounts: readonly T[], toRef: (account: T) => TRef, predicate: (ref: TRef) => boolean, selectNewest: (current: T | undefined, candidate: T) => T): number | undefined;
8
8
  export {};
9
- //# sourceMappingURL=account-match-utils.d.ts.map
@@ -1,3 +1,2 @@
1
1
  import type { AccountStorageV3 } from "./public-types.js";
2
2
  export declare function cloneAccountStorageForPersistence(storage: AccountStorageV3 | null | undefined): AccountStorageV3;
3
- //# sourceMappingURL=account-persistence.d.ts.map
@@ -49,4 +49,3 @@ export declare function importAccountsSnapshot(params: {
49
49
  total: number;
50
50
  skipped: number;
51
51
  }>;
52
- //# sourceMappingURL=account-port.d.ts.map
@@ -4,4 +4,3 @@ export declare function saveAccountsEntry(params: {
4
4
  withStorageLock: <T>(fn: () => Promise<T>) => Promise<T>;
5
5
  saveUnlocked: (storage: AccountStorageV3) => Promise<void>;
6
6
  }): Promise<void>;
7
- //# sourceMappingURL=account-save-entry.d.ts.map
@@ -15,16 +15,23 @@ export declare function saveAccountsToDisk(storage: AccountStorageV3, params: {
15
15
  writeTemp: (tempPath: string, content: string) => Promise<void>;
16
16
  statTemp: (tempPath: string) => Promise<{
17
17
  size: number;
18
+ mtimeMs?: number;
19
+ ctimeMs?: number;
20
+ ino?: number;
18
21
  }>;
19
22
  renameTempToPath: (tempPath: string) => Promise<void>;
20
23
  cleanupResetMarker: () => Promise<void>;
21
24
  cleanupWal: () => Promise<void>;
22
25
  cleanupTemp: (tempPath: string) => Promise<void>;
23
- onSaved: () => void;
26
+ onSaved: (stats: {
27
+ size: number;
28
+ mtimeMs?: number;
29
+ ctimeMs?: number;
30
+ ino?: number;
31
+ }, contentSha256: string) => void;
24
32
  logWarn: (message: string, details: Record<string, unknown>) => void;
25
33
  logError: (message: string, details: Record<string, unknown>) => void;
26
34
  createStorageError: (error: unknown) => Error;
27
35
  backupPath: string;
28
36
  createTempPath: () => string;
29
37
  }): Promise<void>;
30
- //# sourceMappingURL=account-save.d.ts.map
@@ -34,7 +34,10 @@ export async function saveAccountsToDisk(storage, params) {
34
34
  }
35
35
  await params.renameTempToPath(tempPath);
36
36
  await params.cleanupResetMarker();
37
- params.onSaved();
37
+ // The temp file's stat fields survive the rename onto the primary path,
38
+ // so together with the content hash they are a free record of what this
39
+ // process last wrote — no extra stat of the destination is needed.
40
+ params.onSaved(stats, params.computeSha256(content));
38
41
  await params.cleanupWal();
39
42
  }
40
43
  catch (error) {
@@ -22,4 +22,3 @@ export declare function describeAccountSnapshot(path: string, kind: BackupSnapsh
22
22
  }>;
23
23
  logWarn: (message: string, meta: Record<string, unknown>) => void;
24
24
  }): Promise<BackupSnapshotMetadata>;
25
- //# sourceMappingURL=account-snapshot.d.ts.map
@@ -29,4 +29,3 @@ export declare function buildBackupMetadata(params: {
29
29
  };
30
30
  }): Promise<BackupMetadata>;
31
31
  export {};
32
- //# sourceMappingURL=backup-metadata-builder.d.ts.map
@@ -39,4 +39,3 @@ export type SnapshotStats = {
39
39
  mtimeMs?: number;
40
40
  };
41
41
  export {};
42
- //# sourceMappingURL=backup-metadata.d.ts.map
@@ -7,4 +7,3 @@ export declare function getAccountsBackupRecoveryCandidates(path: string, depth:
7
7
  export declare function getAccountsWalPath(path: string): string;
8
8
  export declare function getIntentionalResetMarkerPath(path: string): string;
9
9
  export { ACCOUNTS_BACKUP_SUFFIX, ACCOUNTS_WAL_SUFFIX, RESET_MARKER_SUFFIX };
10
- //# sourceMappingURL=backup-paths.d.ts.map
@@ -8,4 +8,3 @@ export declare function restoreAccountsFromBackupPath(path: string, options: {
8
8
  }>;
9
9
  saveAccounts: (storage: AccountStorageV3) => Promise<void>;
10
10
  }): Promise<AccountStorageV3>;
11
- //# sourceMappingURL=backup-restore.d.ts.map
@@ -1,2 +1 @@
1
1
  export declare function isCacheLikeBackupArtifactName(entryName: string): boolean;
2
- //# sourceMappingURL=cache-artifacts.d.ts.map
@@ -10,4 +10,3 @@ export declare function clearCredentialSidecars(): Promise<void>;
10
10
  * keys never survive a reset; the first failure is rethrown afterwards.
11
11
  */
12
12
  export declare function clearAccountsAndCredentialSidecars(clearPool: () => Promise<void>): Promise<void>;
13
- //# sourceMappingURL=credential-sidecars.d.ts.map
@@ -7,4 +7,3 @@ export declare function formatStorageErrorHint(error: unknown, path: string): st
7
7
  * Wrap an arbitrary storage failure in a StorageError with a derived hint.
8
8
  */
9
9
  export declare function toStorageError(message: string, error: unknown, path: string): StorageError;
10
- //# sourceMappingURL=error-hints.d.ts.map
@@ -6,4 +6,3 @@
6
6
  export declare function withFileTransactionLock<T>(path: string, action: () => Promise<T>, options?: {
7
7
  waitMs?: number;
8
8
  }): Promise<T>;
9
- //# sourceMappingURL=file-lock.d.ts.map
@@ -9,6 +9,33 @@ const abandonedOwners = new Set();
9
9
  const leases = new AsyncLocalStorage();
10
10
  const host = createHash("sha256").update(hostname()).digest("hex").slice(0, 16);
11
11
  const ownerPattern = /^([a-f0-9]{16})\.([1-9][0-9]*)\.([a-f0-9-]{36})$/;
12
+ // Contended acquisition retries once ran on a fixed 25ms delay: every waiter
13
+ // woke on the same cadence and re-collided on the rename (p99 ~1.8s under ~200
14
+ // waiters). The base delay now grows mildly from 15ms toward 40ms with up to
15
+ // 10ms of uniform jitter, so each retry lands in ~[15,50)ms and waiters
16
+ // decorrelate instead of stampeding the lock together.
17
+ const LOCK_RETRY_MIN_DELAY_MS = 15;
18
+ const LOCK_RETRY_MAX_BASE_DELAY_MS = 40;
19
+ const LOCK_RETRY_GROWTH_FACTOR = 1.2;
20
+ const LOCK_RETRY_JITTER_MS = 10;
21
+ function lockRetryBaseDelayMs(failedAttempt) {
22
+ return Math.min(LOCK_RETRY_MIN_DELAY_MS * LOCK_RETRY_GROWTH_FACTOR ** (failedAttempt - 1), LOCK_RETRY_MAX_BASE_DELAY_MS);
23
+ }
24
+ // Derive the attempt cap from the delay schedule itself, not a flat ~40ms
25
+ // guess: the first retries are cheaper than steady state (15ms, 18ms, …), so
26
+ // ceil(waitMs / expected) let a short budget expire after roughly half the
27
+ // requested wait — a 70ms budget could return ELOCKED in ~33ms. Summing the
28
+ // zero-jitter base delays keeps retrying until the schedule has slept at
29
+ // least waitMs; jitter only ever extends the wait, never shortens it.
30
+ function lockMaxAttemptsForWaitMs(waitMs) {
31
+ let attempts = 1;
32
+ let coveredMs = 0;
33
+ while (coveredMs < waitMs) {
34
+ coveredMs += lockRetryBaseDelayMs(attempts);
35
+ attempts += 1;
36
+ }
37
+ return attempts;
38
+ }
12
39
  function code(error) {
13
40
  return error?.code;
14
41
  }
@@ -152,7 +179,12 @@ export async function withFileTransactionLock(path, action, options = {}) {
152
179
  await recoverDeadOwner(lock);
153
180
  throw Object.assign(Error("Storage is busy with another live writer; retry shortly."), { code: "ELOCKED" });
154
181
  }
155
- }, { maxAttempts: Math.max(1, Math.ceil((options.waitMs ?? 10000) / 25) + 1), backoffMs: 25, retryableCodes: ["ELOCKED", "EBUSY", "EPERM", "EACCES", "EAGAIN"] });
182
+ }, {
183
+ maxAttempts: lockMaxAttemptsForWaitMs(options.waitMs ?? 10000),
184
+ backoffMs: lockRetryBaseDelayMs,
185
+ jitterMs: LOCK_RETRY_JITTER_MS,
186
+ retryableCodes: ["ELOCKED", "EBUSY", "EPERM", "EACCES", "EAGAIN"],
187
+ });
156
188
  const lease = { active: true };
157
189
  const context = new Map(leases.getStore());
158
190
  context.set(key, lease);
@@ -3,4 +3,3 @@ export { ACCOUNTS_BACKUP_SUFFIX, ACCOUNTS_WAL_SUFFIX, getAccountsBackupPath, get
3
3
  export declare function getAccountsBackupRecoveryCandidates(path: string): string[];
4
4
  export declare function getFlaggedAccountsPath(storagePath: string, fileName: string): string;
5
5
  export declare function getLegacyFlaggedAccountsPath(storagePath: string, legacyFileName: string): string;
6
- //# sourceMappingURL=file-paths.d.ts.map
@@ -1,4 +1,3 @@
1
1
  import type { AccountMetadataV3, AccountStorageV3 } from "./public-types.js";
2
2
  export declare function looksLikeSyntheticFixtureAccount(account: AccountMetadataV3): boolean;
3
3
  export declare function looksLikeSyntheticFixtureStorage(storage: AccountStorageV3 | null): boolean;
4
- //# sourceMappingURL=fixture-guards.d.ts.map
@@ -12,4 +12,3 @@ export declare function clearFlaggedAccountsEntry(params: {
12
12
  }) => Promise<void>;
13
13
  logError: (message: string, details: Record<string, unknown>) => void;
14
14
  }): Promise<void>;
15
- //# sourceMappingURL=flagged-entry.d.ts.map
@@ -19,4 +19,3 @@ export declare function loadFlaggedAccountsEntry(params: {
19
19
  logError: (message: string, details: Record<string, unknown>) => void;
20
20
  logInfo: (message: string, details: Record<string, unknown>) => void;
21
21
  }): Promise<FlaggedAccountStorageV1>;
22
- //# sourceMappingURL=flagged-load-entry.d.ts.map
@@ -4,4 +4,3 @@ export declare function saveFlaggedAccountsEntry(params: {
4
4
  withStorageLock: <T>(fn: () => Promise<T>) => Promise<T>;
5
5
  saveUnlocked: (storage: FlaggedAccountStorageV1) => Promise<void>;
6
6
  }): Promise<void>;
7
- //# sourceMappingURL=flagged-save-entry.d.ts.map
@@ -8,4 +8,3 @@ export declare function loadFlaggedAccountsFromFile(path: string, deps: {
8
8
  normalizeFlaggedStorage: (data: unknown) => FlaggedAccountStorageV1;
9
9
  sleep?: (ms: number) => Promise<void>;
10
10
  }): Promise<FlaggedAccountStorageV1>;
11
- //# sourceMappingURL=flagged-storage-file.d.ts.map
@@ -26,4 +26,3 @@ export declare function clearFlaggedAccountsOnDisk(params: {
26
26
  backupPaths: string[];
27
27
  logError: (message: string, details: Record<string, unknown>) => void;
28
28
  }): Promise<void>;
29
- //# sourceMappingURL=flagged-storage-io.d.ts.map
@@ -3,4 +3,3 @@ export declare function normalizeFlaggedStorage(data: unknown, deps: {
3
3
  isRecord: (value: unknown) => value is Record<string, unknown>;
4
4
  now: () => number;
5
5
  }): FlaggedAccountStorageV1;
6
- //# sourceMappingURL=flagged-storage.d.ts.map
@@ -4,4 +4,3 @@ export declare function ensureCodexGitignoreEntry(params: {
4
4
  logDebug: (message: string, details: Record<string, unknown>) => void;
5
5
  logWarn: (message: string, details: Record<string, unknown>) => void;
6
6
  }): Promise<void>;
7
- //# sourceMappingURL=gitignore.d.ts.map
@@ -1,2 +1 @@
1
1
  export declare function computeSha256(value: string): string;
2
- //# sourceMappingURL=hash.d.ts.map
@@ -19,4 +19,3 @@ export declare function createStorageHealthSummary(params: {
19
19
  schemaErrors?: string[];
20
20
  recoverySource?: "wal";
21
21
  }): StorageHealthSummary;
22
- //# sourceMappingURL=health.d.ts.map
@@ -18,4 +18,3 @@ export declare function toAccountIdentityRef(account: Pick<AccountLike, "account
18
18
  export declare function getAccountIdentityKey(account: Pick<AccountLike, "accountId" | "email" | "refreshToken">): string | undefined;
19
19
  export declare function getRuntimeAccountIdentityKey(account: Pick<RuntimeAccountLike, "accountId" | "email" | "index">): string | number | undefined;
20
20
  export {};
21
- //# sourceMappingURL=identity.d.ts.map
@@ -22,4 +22,3 @@ export declare function mergeImportedAccounts(params: {
22
22
  total: number;
23
23
  skipped: number;
24
24
  };
25
- //# sourceMappingURL=import-export.d.ts.map
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Stamp `updatedAt` for a per-key governance entry with a hybrid logical
3
+ * floor: when the wall clock regressed below the timestamp the entry being
4
+ * overwritten already carries, stamp `prior + 1` instead of `now`. Every
5
+ * upsert-only store merges with `updatedAt >=`, so a backward clock jump
6
+ * would otherwise stamp a semantically-newer write below its own
7
+ * predecessor and the merge would silently drop it. Equal or forward wall
8
+ * times pass through unchanged — ties already resolve to the caller's
9
+ * write under `>=`.
10
+ *
11
+ * `prior` is the entry the writer saw, which can trail the freshest on-disk
12
+ * entry when a concurrent writer lands between the caller's load and its
13
+ * save; baseline-aware save merges re-apply this same floor against the
14
+ * on-disk entry at merge time so the edit still cannot be lost.
15
+ */
16
+ export declare function stampUpdatedAt(now: number, prior: number | undefined): number;
17
+ /**
18
+ * Serialize `task` behind the previous write queued for `path`, so same-file
19
+ * writers inside this process run one at a time in submission order. A failed
20
+ * predecessor never blocks or fails successors. Re-entrant for the same path
21
+ * within one async context.
22
+ *
23
+ * This is the per-path generalization of the module-local `writeQueue`
24
+ * variables the governance stores used to keep by hand.
25
+ */
26
+ export declare function withJsonStoreWriteQueue<T>(path: string, task: () => Promise<T>): Promise<T>;
27
+ /** Test helper: drop queued-write bookkeeping (all paths, or one when given). */
28
+ export declare function resetJsonStoreWriteQueuesForTests(path?: string): void;
29
+ /**
30
+ * Stat `filePath` for its mtime with bounded transient-FS retry (the save
31
+ * path is Windows-sensitive: a single transient EBUSY/EPERM/EAGAIN from an
32
+ * AV/indexer lock must not abort the whole save). ENOENT returns `null`
33
+ * immediately; on exhaustion the last failure surfaces so the caller treats
34
+ * it as a real save error rather than a phantom missing file.
35
+ */
36
+ export declare function getJsonStoreFileMtimeMs(filePath: string): Promise<number | null>;
37
+ /**
38
+ * The `ESTALE` signal used by the CAS retry loop: the file's mtime moved
39
+ * between the caller's stat and its write, so the attempt must re-read and
40
+ * re-merge against the latest on-disk state instead of clobbering it.
41
+ */
42
+ export declare function createJsonStoreStaleError(filePath: string): NodeJS.ErrnoException;
43
+ /**
44
+ * Throw `ESTALE` when `filePath`'s current mtime differs from
45
+ * `expectedMtimeMs` (`null` means "file must still be absent"). Writers that
46
+ * keep their own temp+rename flow call this just before the rename, matching
47
+ * {@link writeJsonStoreFileAtomicWithRetry}'s inline check.
48
+ */
49
+ export declare function assertJsonStoreFileMtimeUnchanged(filePath: string, expectedMtimeMs: number | null): Promise<void>;
50
+ export interface JsonStoreAtomicWriteOptions {
51
+ /**
52
+ * When present (including explicit `null` = "expect the file to be
53
+ * absent"), compare-and-swap guard: abort with `ESTALE` if the target's
54
+ * mtime moved since the caller read it, so the caller can re-read and
55
+ * merge instead of clobbering a concurrent write. Omit the key entirely
56
+ * to skip the check.
57
+ */
58
+ expectedMtimeMs?: number | null;
59
+ /** Temp file mode (and therefore the final file's mode when created). */
60
+ mode?: number;
61
+ /** fsync the temp file before rename so a crash/power-loss cannot leave a truncated store. */
62
+ fsync?: boolean;
63
+ /** Rename retry codes; defaults to EBUSY/EPERM. */
64
+ retryableCodes?: ReadonlySet<string>;
65
+ }
66
+ /**
67
+ * Atomic JSON write: serialize `payload` pretty-printed with a trailing
68
+ * newline to a crypto-random sibling temp file, then rename it over
69
+ * `filePath` with bounded transient-FS retry. Optionally CAS-checks the
70
+ * target mtime first and fsyncs the temp file; on failure the temp is
71
+ * removed best-effort.
72
+ */
73
+ export declare function writeJsonStoreFileAtomicWithRetry(filePath: string, payload: unknown, options?: JsonStoreAtomicWriteOptions): Promise<void>;
74
+ /**
75
+ * Run `task`, retrying `ESTALE` CAS aborts so each attempt can re-read and
76
+ * re-merge against the latest on-disk state (matches the config save loop:
77
+ * 3 attempts, immediate retry, ESTALE-only).
78
+ */
79
+ export declare function withJsonStoreCasRetry<T>(task: () => Promise<T>): Promise<T>;
80
+ export interface JsonStoreFileLockOptions {
81
+ /**
82
+ * How long to wait for a lock held by a LIVE foreign process before
83
+ * failing with `ELOCKTIMEOUT` (default 10s). A crashed holder's lock is
84
+ * reclaimed as soon as its dead PID is observed; a live holder is never
85
+ * evicted — including a reused PID, which fails closed here rather than
86
+ * risking two writers in the critical section.
87
+ */
88
+ waitTimeoutMs?: number;
89
+ }
90
+ /**
91
+ * Cross-process mutex for a JSON store file, delegated to the proven
92
+ * candidate-directory transaction lock in lib/storage/file-lock.ts: each
93
+ * acquirer stages `<path>.write-lock.candidate-*` containing its unique
94
+ * `<host>.<pid>.<uuid>` owner file, then publishes it with a single atomic
95
+ * `rename` (which only succeeds while the lock directory is absent or empty,
96
+ * so there is no ownerless acquisition window). A crashed holder's lock is
97
+ * recovered by unlinking exactly that dead owner's unique filename and
98
+ * removing the directory only while it is still empty — an `rmdir` can never
99
+ * erase a lock that was republished in the meantime, so takeover can never
100
+ * delete another owner's live lock. Waiters on a live holder retry inside
101
+ * `waitTimeoutMs` (default 10s), then this wrapper surfaces the exhaustion
102
+ * as `ELOCKTIMEOUT`. Re-entrant for the same resolved path within one async
103
+ * context.
104
+ */
105
+ export declare function withJsonStoreFileLock<T>(targetPath: string, task: () => Promise<T>, options?: JsonStoreFileLockOptions): Promise<T>;