@cortexkit/opencode-openai-auth 1.23.1 → 1.23.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 (226) hide show
  1. package/dist/bin.js +7 -7
  2. package/dist/{index-7hy72nfy.js → index-9kges8jy.js} +2 -2
  3. package/dist/index-ekt6aq17.js +60 -0
  4. package/dist/index-nd2ks7er.js +2 -0
  5. package/dist/{index-p81hxfe6.js → index-vf4nn20q.js} +1 -1
  6. package/dist/{index-bd18sfjj.js → index-x00sxt2w.js} +10 -10
  7. package/dist/{index-3ya2s179.js → index-xkngfyvc.js} +1 -1
  8. package/dist/index.d.ts +3 -2
  9. package/dist/index.js +1 -1
  10. package/dist/{runtime-layout-B07ApQZL.d.ts → internal-DacVgEWs.d.ts} +86 -663
  11. package/dist/rpc/port-file.js +1 -1
  12. package/dist/runtime-layout-Dcbj_Rq3.d.ts +650 -0
  13. package/dist/{sidebar-state--OTpRzFd.d.ts → sidebar-state-L--CdbLi.d.ts} +4 -15
  14. package/dist/sidebar-state.d.ts +1 -1
  15. package/dist/sidebar-state.js +1 -1
  16. package/dist/tui.d.ts +5 -2
  17. package/dist/v2/server.d.ts +2 -1
  18. package/dist/v2/server.js +4 -4
  19. package/package.json +1 -1
  20. package/src/tui-compiled/raw/shared/054118b2705fdc20-ansi.js +98 -0
  21. package/src/tui-compiled/raw/shared/0895e780489c494d-window.js +33 -0
  22. package/src/tui-compiled/raw/shared/0b7d24474e2f33e9-credential-redaction.js +424 -0
  23. package/src/tui-compiled/raw/shared/0c9533222cb4380c-namespace.js +224 -0
  24. package/src/tui-compiled/raw/shared/112607e46a5b5f58-accounts.js +393 -0
  25. package/src/tui-compiled/raw/shared/136fa4abe48ad69d-cachekeep.js +411 -0
  26. package/src/tui-compiled/raw/shared/1547bd74f4214d2d-index.js +28 -0
  27. package/src/tui-compiled/raw/shared/1567207f323dc733-codex-http.js +44 -0
  28. package/src/tui-compiled/raw/shared/15f402885cbb2fb3-envelope-loss.js +151 -0
  29. package/src/tui-compiled/raw/shared/18df43cab4563acf-families.js +149 -0
  30. package/src/tui-compiled/raw/shared/1a4c289eec261e04-codex-instructions.js +59 -0
  31. package/src/tui-compiled/raw/shared/1afd446e190ef85c-vault-messages.js +12 -0
  32. package/src/tui-compiled/raw/shared/1b06ec96856ff8b9-codex-endpoint.js +17 -0
  33. package/src/tui-compiled/raw/shared/1e2f1a89bb34a773-vault-adapter.js +110 -0
  34. package/src/tui-compiled/raw/shared/2194fb8e8b42d7d5-insula-quota.js +73 -0
  35. package/src/tui-compiled/raw/shared/22b2bce42f2d6806-handle.js +10 -0
  36. package/src/tui-compiled/raw/shared/2577ec69f9973ae9-quota-normalize.js +13 -14
  37. package/src/tui-compiled/raw/shared/26055d4e5ad5e71f-codex-request.js +198 -0
  38. package/src/tui-compiled/raw/shared/26b57ac4c3b0c3f6-unconfirmed-retain-counter.js +41 -0
  39. package/src/tui-compiled/raw/shared/2bb681e99c2721d7-registry.js +538 -0
  40. package/src/tui-compiled/raw/shared/2dce6e9613993329-quota-manager.js +13 -20
  41. package/src/tui-compiled/raw/shared/2ec33b3e2b8ac38a-terminal.js +168 -0
  42. package/src/tui-compiled/raw/shared/30bcca1d1b4240a0-pool-session-pins.js +32 -0
  43. package/src/tui-compiled/raw/shared/3af9a210aa2ccdf2-codex-call-status.js +21 -0
  44. package/src/tui-compiled/raw/shared/3b31b36bf0877602-wording.js +120 -0
  45. package/src/tui-compiled/raw/shared/3c4c1a2d3fc92726-failure.js +59 -0
  46. package/src/tui-compiled/raw/shared/3dfe71eec6e0487d-presets.js +240 -0
  47. package/src/tui-compiled/raw/shared/43de3a5c4845cfc1-pool-adapter.js +149 -0
  48. package/src/tui-compiled/raw/shared/49353b63a833c8fb-session-cache-policy.js +60 -0
  49. package/src/tui-compiled/raw/shared/4adf46e07e025363-axes.js +7 -0
  50. package/src/tui-compiled/raw/shared/4ba847b77580b1eb-confirm.js +21 -0
  51. package/src/tui-compiled/raw/shared/4d05c2d7a531aece-oauth.js +48 -36
  52. package/src/tui-compiled/raw/shared/5018d4665e969588-limit-policy.js +159 -0
  53. package/src/tui-compiled/raw/shared/595bdf3fff13ba79-limit-identity.js +49 -0
  54. package/src/tui-compiled/raw/shared/59def9e82b61204a-session-cache-activity.js +35 -0
  55. package/src/tui-compiled/raw/shared/5d806e1a305d14f5-commands.js +879 -0
  56. package/src/tui-compiled/raw/shared/5fc39320fa8bd3a0-limit-registry.js +473 -0
  57. package/src/tui-compiled/raw/shared/63c1ee7e70e85e8d-vault.js +1 -0
  58. package/src/tui-compiled/raw/shared/6545ab7f757314b7-refresh-all-quota.js +237 -0
  59. package/src/tui-compiled/raw/shared/66937534c260d20b-stable-json.js +11 -0
  60. package/src/tui-compiled/raw/shared/7056acef1b021f19-bridge.js +10 -0
  61. package/src/tui-compiled/raw/shared/72d2ca42883809b4-marker.js +107 -0
  62. package/src/tui-compiled/raw/shared/775431e21f469203-record.js +3 -0
  63. package/src/tui-compiled/raw/shared/799f3ade4efbd1ea-opencode-v1.js +47 -0
  64. package/src/tui-compiled/raw/shared/7b2a0471b29e4f5e-wake.js +47 -0
  65. package/src/tui-compiled/raw/shared/7b5d6afff4ff32b9-select.js +159 -0
  66. package/src/tui-compiled/raw/shared/7bf96bf4d9249b3d-vault-billing.js +108 -0
  67. package/src/tui-compiled/raw/shared/7c98bde36aad4819-input-transformations.js +34 -0
  68. package/src/tui-compiled/raw/shared/7fb0418303f20a10-index.js +3 -0
  69. package/src/tui-compiled/raw/shared/806e12ccbad34388-pi-wait.js +51 -0
  70. package/src/tui-compiled/raw/shared/81ae201b724cac14-menu.js +73 -0
  71. package/src/tui-compiled/raw/shared/8349ed25dc629e97-scope.js +10 -0
  72. package/src/tui-compiled/raw/shared/86da3379973780b9-limit-provenance.js +60 -0
  73. package/src/tui-compiled/raw/shared/8aba66ed486d30a7-decide.js +425 -0
  74. package/src/tui-compiled/raw/shared/8c0c8df25a5dca1f-manager.js +735 -0
  75. package/src/tui-compiled/raw/shared/8c42bbec02f59636-vault-routing.js +212 -0
  76. package/src/tui-compiled/raw/shared/8ca6175bfae53e13-envelope.js +123 -0
  77. package/src/tui-compiled/raw/shared/8d0245e41049d83f-header-classifier.js +121 -0
  78. package/src/tui-compiled/raw/shared/9c162809179c7560-login.js +89 -0
  79. package/src/tui-compiled/raw/shared/a1f495296a4b756f-frame-turn.js +72 -0
  80. package/src/tui-compiled/raw/shared/a37138dcbd893f55-hold-bounds.js +5 -0
  81. package/src/tui-compiled/raw/shared/aa7fb10d77a2cccd-vault-account-menu.js +133 -0
  82. package/src/tui-compiled/raw/shared/adc5eeb5a8d28280-persistence.js +9 -0
  83. package/src/tui-compiled/raw/shared/b301c79e6378d1fb-vault.js +678 -0
  84. package/src/tui-compiled/raw/shared/b3c11de5f36e617a-reset.js +44 -0
  85. package/src/tui-compiled/raw/shared/ba6535c610d1edb3-pool-source-state.js +100 -0
  86. package/src/tui-compiled/raw/shared/bd4aef685681048c-duration.js +20 -0
  87. package/src/tui-compiled/raw/shared/bd5977eca210d2b8-index.js +662 -0
  88. package/src/tui-compiled/raw/shared/bfc46d34f4c9db33-limit-recovery.js +127 -0
  89. package/src/tui-compiled/raw/shared/c66495424ad84aee-hold.js +25 -0
  90. package/src/tui-compiled/raw/shared/c6a67b836bd5afcd-vault-command-menu.js +300 -0
  91. package/src/tui-compiled/raw/shared/c9340fb545c4e5de-internal.js +73 -0
  92. package/src/tui-compiled/raw/shared/c954c6447b7b9b64-activity.js +52 -0
  93. package/src/tui-compiled/raw/shared/cba8b0aee46b8526-codex-lite.js +85 -0
  94. package/src/tui-compiled/raw/shared/cec39ccddab4fe9c-labels.js +11 -0
  95. package/src/tui-compiled/raw/shared/cef0f2346957e83c-index.js +552 -0
  96. package/src/tui-compiled/raw/shared/cf7dedf24f902d68-dump-size.js +41 -0
  97. package/src/tui-compiled/raw/shared/d422d6dbc4e35199-background-quota-refresh.js +107 -0
  98. package/src/tui-compiled/raw/shared/d5b268767d330507-doctor.js +81 -0
  99. package/src/tui-compiled/raw/shared/d7ac5ca41f49121b-index.js +12 -0
  100. package/src/tui-compiled/raw/shared/d7fa77560855dee2-jitter.js +9 -0
  101. package/src/tui-compiled/raw/shared/de7f7d8803624369-path.js +31 -0
  102. package/src/tui-compiled/raw/shared/df0bdc74fb0c0db0-limit-mark.js +27 -0
  103. package/src/tui-compiled/raw/shared/e26c2bb5722ab047-routing-hold.js +23 -0
  104. package/src/tui-compiled/raw/shared/e2ae081583adfce3-dump.js +80 -0
  105. package/src/tui-compiled/raw/shared/e44ba1b3a9903f5d-reset-credits.js +483 -0
  106. package/src/tui-compiled/raw/shared/e5229952fc12f647-codex-models.js +34 -0
  107. package/src/tui-compiled/raw/shared/e8fda84e90176436-uuid-v7.js +13 -0
  108. package/src/tui-compiled/raw/shared/ea56007991dbf068-terminal.js +19 -0
  109. package/src/tui-compiled/raw/shared/ec6f1d96e7d70174-quota-refusal.js +145 -0
  110. package/src/tui-compiled/raw/shared/f03d7b43a214a4a1-canonical-input.js +42 -0
  111. package/src/tui-compiled/raw/shared/f1012265b3a768c7-merge-laws.js +31 -0
  112. package/src/tui-compiled/raw/shared/f2ca864fe967415a-cache-policy.js +198 -0
  113. package/src/tui-compiled/raw/shared/f317a4740f9d76f8-identity.js +21 -0
  114. package/src/tui-compiled/raw/shared/f607353c4126272a-routing-wait.js +19 -0
  115. package/src/tui-compiled/raw/shared/f6189f5c9aee31eb-decision.js +55 -0
  116. package/src/tui-compiled/raw/shared/f6d728f5e601f98b-request-history.js +120 -0
  117. package/src/tui-compiled/raw/shared/f981e6b15fb76cdb-codex-body.js +28 -0
  118. package/src/tui-compiled/raw/shared/fda579e5a0a54165-codex-effort.js +60 -0
  119. package/src/tui-compiled/raw/sidebar-state.js +54 -4
  120. package/src/tui-compiled/raw/tui/v2-dialog.js +1 -1
  121. package/src/tui-compiled/raw/tui.tsx +27 -5
  122. package/src/tui-compiled/runtime/shared/054118b2705fdc20-ansi.js +98 -0
  123. package/src/tui-compiled/runtime/shared/0895e780489c494d-window.js +33 -0
  124. package/src/tui-compiled/runtime/shared/0b7d24474e2f33e9-credential-redaction.js +424 -0
  125. package/src/tui-compiled/runtime/shared/0c9533222cb4380c-namespace.js +224 -0
  126. package/src/tui-compiled/runtime/shared/112607e46a5b5f58-accounts.js +393 -0
  127. package/src/tui-compiled/runtime/shared/136fa4abe48ad69d-cachekeep.js +411 -0
  128. package/src/tui-compiled/runtime/shared/1547bd74f4214d2d-index.js +28 -0
  129. package/src/tui-compiled/runtime/shared/1567207f323dc733-codex-http.js +44 -0
  130. package/src/tui-compiled/runtime/shared/15f402885cbb2fb3-envelope-loss.js +151 -0
  131. package/src/tui-compiled/runtime/shared/18df43cab4563acf-families.js +149 -0
  132. package/src/tui-compiled/runtime/shared/1a4c289eec261e04-codex-instructions.js +59 -0
  133. package/src/tui-compiled/runtime/shared/1afd446e190ef85c-vault-messages.js +12 -0
  134. package/src/tui-compiled/runtime/shared/1b06ec96856ff8b9-codex-endpoint.js +17 -0
  135. package/src/tui-compiled/runtime/shared/1e2f1a89bb34a773-vault-adapter.js +110 -0
  136. package/src/tui-compiled/runtime/shared/2194fb8e8b42d7d5-insula-quota.js +73 -0
  137. package/src/tui-compiled/runtime/shared/22b2bce42f2d6806-handle.js +10 -0
  138. package/src/tui-compiled/runtime/shared/2577ec69f9973ae9-quota-normalize.js +13 -14
  139. package/src/tui-compiled/runtime/shared/26055d4e5ad5e71f-codex-request.js +198 -0
  140. package/src/tui-compiled/runtime/shared/26b57ac4c3b0c3f6-unconfirmed-retain-counter.js +41 -0
  141. package/src/tui-compiled/runtime/shared/2bb681e99c2721d7-registry.js +538 -0
  142. package/src/tui-compiled/runtime/shared/2dce6e9613993329-quota-manager.js +13 -20
  143. package/src/tui-compiled/runtime/shared/2ec33b3e2b8ac38a-terminal.js +168 -0
  144. package/src/tui-compiled/runtime/shared/30bcca1d1b4240a0-pool-session-pins.js +32 -0
  145. package/src/tui-compiled/runtime/shared/3af9a210aa2ccdf2-codex-call-status.js +21 -0
  146. package/src/tui-compiled/runtime/shared/3b31b36bf0877602-wording.js +120 -0
  147. package/src/tui-compiled/runtime/shared/3c4c1a2d3fc92726-failure.js +59 -0
  148. package/src/tui-compiled/runtime/shared/3dfe71eec6e0487d-presets.js +240 -0
  149. package/src/tui-compiled/runtime/shared/43de3a5c4845cfc1-pool-adapter.js +149 -0
  150. package/src/tui-compiled/runtime/shared/49353b63a833c8fb-session-cache-policy.js +60 -0
  151. package/src/tui-compiled/runtime/shared/4adf46e07e025363-axes.js +7 -0
  152. package/src/tui-compiled/runtime/shared/4ba847b77580b1eb-confirm.js +21 -0
  153. package/src/tui-compiled/runtime/shared/4d05c2d7a531aece-oauth.js +48 -36
  154. package/src/tui-compiled/runtime/shared/5018d4665e969588-limit-policy.js +159 -0
  155. package/src/tui-compiled/runtime/shared/595bdf3fff13ba79-limit-identity.js +49 -0
  156. package/src/tui-compiled/runtime/shared/59def9e82b61204a-session-cache-activity.js +35 -0
  157. package/src/tui-compiled/runtime/shared/5d806e1a305d14f5-commands.js +879 -0
  158. package/src/tui-compiled/runtime/shared/5fc39320fa8bd3a0-limit-registry.js +473 -0
  159. package/src/tui-compiled/runtime/shared/63c1ee7e70e85e8d-vault.js +1 -0
  160. package/src/tui-compiled/runtime/shared/6545ab7f757314b7-refresh-all-quota.js +237 -0
  161. package/src/tui-compiled/runtime/shared/66937534c260d20b-stable-json.js +11 -0
  162. package/src/tui-compiled/runtime/shared/7056acef1b021f19-bridge.js +10 -0
  163. package/src/tui-compiled/runtime/shared/72d2ca42883809b4-marker.js +107 -0
  164. package/src/tui-compiled/runtime/shared/775431e21f469203-record.js +3 -0
  165. package/src/tui-compiled/runtime/shared/799f3ade4efbd1ea-opencode-v1.js +47 -0
  166. package/src/tui-compiled/runtime/shared/7b2a0471b29e4f5e-wake.js +47 -0
  167. package/src/tui-compiled/runtime/shared/7b5d6afff4ff32b9-select.js +159 -0
  168. package/src/tui-compiled/runtime/shared/7bf96bf4d9249b3d-vault-billing.js +108 -0
  169. package/src/tui-compiled/runtime/shared/7c98bde36aad4819-input-transformations.js +34 -0
  170. package/src/tui-compiled/runtime/shared/7fb0418303f20a10-index.js +3 -0
  171. package/src/tui-compiled/runtime/shared/806e12ccbad34388-pi-wait.js +51 -0
  172. package/src/tui-compiled/runtime/shared/81ae201b724cac14-menu.js +73 -0
  173. package/src/tui-compiled/runtime/shared/8349ed25dc629e97-scope.js +10 -0
  174. package/src/tui-compiled/runtime/shared/86da3379973780b9-limit-provenance.js +60 -0
  175. package/src/tui-compiled/runtime/shared/8aba66ed486d30a7-decide.js +425 -0
  176. package/src/tui-compiled/runtime/shared/8c0c8df25a5dca1f-manager.js +735 -0
  177. package/src/tui-compiled/runtime/shared/8c42bbec02f59636-vault-routing.js +212 -0
  178. package/src/tui-compiled/runtime/shared/8ca6175bfae53e13-envelope.js +123 -0
  179. package/src/tui-compiled/runtime/shared/8d0245e41049d83f-header-classifier.js +121 -0
  180. package/src/tui-compiled/runtime/shared/9c162809179c7560-login.js +89 -0
  181. package/src/tui-compiled/runtime/shared/a1f495296a4b756f-frame-turn.js +72 -0
  182. package/src/tui-compiled/runtime/shared/a37138dcbd893f55-hold-bounds.js +5 -0
  183. package/src/tui-compiled/runtime/shared/aa7fb10d77a2cccd-vault-account-menu.js +133 -0
  184. package/src/tui-compiled/runtime/shared/adc5eeb5a8d28280-persistence.js +9 -0
  185. package/src/tui-compiled/runtime/shared/b301c79e6378d1fb-vault.js +678 -0
  186. package/src/tui-compiled/runtime/shared/b3c11de5f36e617a-reset.js +44 -0
  187. package/src/tui-compiled/runtime/shared/ba6535c610d1edb3-pool-source-state.js +100 -0
  188. package/src/tui-compiled/runtime/shared/bd4aef685681048c-duration.js +20 -0
  189. package/src/tui-compiled/runtime/shared/bd5977eca210d2b8-index.js +662 -0
  190. package/src/tui-compiled/runtime/shared/bfc46d34f4c9db33-limit-recovery.js +127 -0
  191. package/src/tui-compiled/runtime/shared/c66495424ad84aee-hold.js +25 -0
  192. package/src/tui-compiled/runtime/shared/c6a67b836bd5afcd-vault-command-menu.js +300 -0
  193. package/src/tui-compiled/runtime/shared/c9340fb545c4e5de-internal.js +73 -0
  194. package/src/tui-compiled/runtime/shared/c954c6447b7b9b64-activity.js +52 -0
  195. package/src/tui-compiled/runtime/shared/cba8b0aee46b8526-codex-lite.js +85 -0
  196. package/src/tui-compiled/runtime/shared/cec39ccddab4fe9c-labels.js +11 -0
  197. package/src/tui-compiled/runtime/shared/cef0f2346957e83c-index.js +552 -0
  198. package/src/tui-compiled/runtime/shared/cf7dedf24f902d68-dump-size.js +41 -0
  199. package/src/tui-compiled/runtime/shared/d422d6dbc4e35199-background-quota-refresh.js +107 -0
  200. package/src/tui-compiled/runtime/shared/d5b268767d330507-doctor.js +81 -0
  201. package/src/tui-compiled/runtime/shared/d7ac5ca41f49121b-index.js +12 -0
  202. package/src/tui-compiled/runtime/shared/d7fa77560855dee2-jitter.js +9 -0
  203. package/src/tui-compiled/runtime/shared/de7f7d8803624369-path.js +31 -0
  204. package/src/tui-compiled/runtime/shared/df0bdc74fb0c0db0-limit-mark.js +27 -0
  205. package/src/tui-compiled/runtime/shared/e26c2bb5722ab047-routing-hold.js +23 -0
  206. package/src/tui-compiled/runtime/shared/e2ae081583adfce3-dump.js +80 -0
  207. package/src/tui-compiled/runtime/shared/e44ba1b3a9903f5d-reset-credits.js +483 -0
  208. package/src/tui-compiled/runtime/shared/e5229952fc12f647-codex-models.js +34 -0
  209. package/src/tui-compiled/runtime/shared/e8fda84e90176436-uuid-v7.js +13 -0
  210. package/src/tui-compiled/runtime/shared/ea56007991dbf068-terminal.js +19 -0
  211. package/src/tui-compiled/runtime/shared/ec6f1d96e7d70174-quota-refusal.js +145 -0
  212. package/src/tui-compiled/runtime/shared/f03d7b43a214a4a1-canonical-input.js +42 -0
  213. package/src/tui-compiled/runtime/shared/f1012265b3a768c7-merge-laws.js +31 -0
  214. package/src/tui-compiled/runtime/shared/f2ca864fe967415a-cache-policy.js +198 -0
  215. package/src/tui-compiled/runtime/shared/f317a4740f9d76f8-identity.js +21 -0
  216. package/src/tui-compiled/runtime/shared/f607353c4126272a-routing-wait.js +19 -0
  217. package/src/tui-compiled/runtime/shared/f6189f5c9aee31eb-decision.js +55 -0
  218. package/src/tui-compiled/runtime/shared/f6d728f5e601f98b-request-history.js +120 -0
  219. package/src/tui-compiled/runtime/shared/f981e6b15fb76cdb-codex-body.js +28 -0
  220. package/src/tui-compiled/runtime/shared/fda579e5a0a54165-codex-effort.js +60 -0
  221. package/src/tui-compiled/runtime/sidebar-state.js +54 -4
  222. package/src/tui-compiled/runtime/tui/v2-dialog.js +1 -1
  223. package/src/tui-compiled/runtime/tui.js +11 -4
  224. package/dist/index-0p8r7cpy.js +0 -60
  225. package/dist/index-px1t650b.js +0 -2
  226. package/dist/map-D5PHhv4z.d.ts +0 -72
@@ -1,49 +1,14 @@
1
- import { r as QuotaMap } from "./map-D5PHhv4z.js";
2
1
  import "@cortexkit/private-files";
3
2
  import { ClaustrumClient, EnrollmentPollOutcome, ScopedInventoryRow } from "@cortexkit/claustrum-client";
4
3
  import { Plugin } from "@opencode/plugin";
5
4
  import "@opencode/plugin/promise/session";
6
- interface LockLoss {
7
- readonly reason: 'taken-over' | 'expired' | 'unreadable' | 'renewal-failed' | 'marker-lost';
8
- readonly expectedOwnerId: string;
9
- readonly observedOwnerId?: string;
10
- readonly observedExpiresAt?: number;
11
- }
12
- interface RefreshFileLock {
13
- readonly ownerId: string;
14
- assertOwned(): Promise<void>;
15
- /** Abort stops release retries; the unrenewed lease is left to expire by TTL. */
16
- release(signal?: AbortSignal): Promise<void>;
17
- /** Resolves once on detected loss; remains pending after an owner's release. */
18
- whenLost(): Promise<LockLoss>;
19
- hasLost(): boolean;
20
- }
21
- type RefreshFileLockOptions = {
22
- name: string;
23
- ttlMs: number;
24
- /**
25
- * File the lock is named after. Required: the lock and the write it guards
26
- * must target the same file, and a default resolved in here could only ever
27
- * be one host's path.
28
- */
29
- path: string;
30
- renew?: boolean;
31
- renewIntervalMs?: number;
32
- /** Notifies a live-owner refusal without awaiting; observer failures are ignored. */
33
- onContended?: () => void;
34
- /** Synchronous, never awaited; throws and returned promise/thenable rejections are isolated. */
35
- onRenewalTimer?: (event: 'scheduled' | 'cancelled') => void;
36
- onStep?: (step: 'stale-marker-stat' | 'stale-marker-claimed' | 'stale-lock-observed' | 'lease-contention-read-ready' | 'lock-read-ready' | 'lock-missing' | 'stale-lock-confirmed' | 'stale-lock-removed' | 'stale-lock-recreated' | 'eviction-marker-acquired' | 'renewal-owner-confirmed' | 'renewal-marker-unavailable' | 'renewal-write-fenced' | 'renewal-write-ready' | 'renewal-write-finished' | 'relinquish-read' | 'renewal-finished' | 'release-owner-confirmed') => void | Promise<void>;
37
- };
38
- /** Filesystem leases share wall time across all callers and processes. */
39
- declare function acquireRefreshFileLock(options: RefreshFileLockOptions): Promise<RefreshFileLock | null>;
40
5
  type QuotaWindowName = string;
41
6
  type ProviderQuotaFn = (input: {
42
7
  accessToken: string;
43
8
  fetchImpl: typeof fetch;
44
9
  now: () => number;
45
10
  }) => Promise<OAuthQuotaSnapshot>;
46
- type QuotaEntry = {
11
+ type QuotaEntry$1 = {
47
12
  quota: OAuthQuotaSnapshot;
48
13
  refreshAfter: number;
49
14
  checkedAt: number;
@@ -94,15 +59,15 @@ declare class QuotaManager {
94
59
  * refetches for the current account. Called without a token (e.g. for
95
60
  * display) it returns whatever is cached.
96
61
  */
97
- getMain(accessToken?: string): QuotaEntry | null;
62
+ getMain(accessToken?: string): QuotaEntry$1 | null;
98
63
  /**
99
64
  * Cached fallback quota entry. Pass the live access token to enforce token
100
65
  * binding: if the entry was produced by a different token (account re-login),
101
66
  * it is dropped and null is returned so the caller refetches.
102
67
  */
103
- getFallback(accountId: string, accessToken?: string): QuotaEntry | null;
104
- getAllFallbacks(): Map<string, QuotaEntry>;
105
- setMain(accessToken: string, entry: QuotaEntry, accountId?: string, completeSnapshot?: boolean): void;
68
+ getFallback(accountId: string, accessToken?: string): QuotaEntry$1 | null;
69
+ getAllFallbacks(): Map<string, QuotaEntry$1>;
70
+ setMain(accessToken: string, entry: QuotaEntry$1, accountId?: string, completeSnapshot?: boolean): void;
106
71
  /**
107
72
  * Non-invalidating read of the cached main quota for POLICY decisions
108
73
  * (killswitch). Unlike getMain(token), a token mismatch does NOT drop the
@@ -115,7 +80,7 @@ declare class QuotaManager {
115
80
  * B's quota. When identity is unknown on either side, the cached snapshot is
116
81
  * returned (best-effort) — the same fail-open-on-unknown stance as elsewhere.
117
82
  */
118
- peekMainForPolicy(accountId?: string): QuotaEntry | null;
83
+ peekMainForPolicy(accountId?: string): QuotaEntry$1 | null;
119
84
  /**
120
85
  * Non-invalidating read of a cached fallback quota for POLICY decisions
121
86
  * (killswitch, admission). Keyed by the stable internal account id, so a
@@ -127,8 +92,8 @@ declare class QuotaManager {
127
92
  * identity's (possibly exhausted) quota is never judged against its
128
93
  * replacement. Unknown on either side fails open, matching peekMainForPolicy.
129
94
  */
130
- peekFallbackForPolicy(accountId: string, identity?: string): QuotaEntry | null;
131
- setFallback(accountId: string, entry: QuotaEntry, accessToken?: string, completeSnapshot?: boolean, identity?: string): void;
95
+ peekFallbackForPolicy(accountId: string, identity?: string): QuotaEntry$1 | null;
96
+ setFallback(accountId: string, entry: QuotaEntry$1, accessToken?: string, completeSnapshot?: boolean, identity?: string): void;
132
97
  /**
133
98
  * Mark accountId ('main' or a fallback id) rate-limited until resetAtMs.
134
99
  * Keeps the LATER reset: skips only when an existing mark is strictly
@@ -147,6 +112,7 @@ declare class QuotaManager {
147
112
  rateLimitedUntil(accountId: string): number | undefined;
148
113
  /** Explicit early clear — read-time expiry in isRateLimited is primary. */
149
114
  clearRateLimited(accountId: string): void;
115
+ private clearRecoveredRateLimit;
150
116
  refreshMain(accessToken: string): Promise<OAuthQuotaSnapshot>;
151
117
  refreshFallback(accountId: string, accessToken: string): Promise<OAuthQuotaSnapshot>;
152
118
  refreshAllFallbacks(accounts: OAuthAccount[]): Promise<void>;
@@ -248,11 +214,11 @@ interface OAuthQuotaSnapshot {
248
214
  credits?: OAuthCredits;
249
215
  }
250
216
  interface OAuthSpendControlReading {
251
- limit: number;
252
- used: number;
253
- remaining: number;
254
- usedPercent: number;
255
- remainingPercent: number;
217
+ limit?: number;
218
+ used?: number;
219
+ remaining?: number;
220
+ usedPercent?: number;
221
+ remainingPercent?: number;
256
222
  resetsAt?: string;
257
223
  unit?: string;
258
224
  source?: string;
@@ -651,6 +617,77 @@ interface KeptReceiptState {
651
617
  readonly active: boolean;
652
618
  readonly since: number | null;
653
619
  }
620
+ interface QuotaReadingEntry {
621
+ scope: string;
622
+ label: string;
623
+ kind: 'reading';
624
+ checkedAt: number;
625
+ usedPercent: number;
626
+ /** ISO timestamp at which the window resets, as the provider reported it. */
627
+ resetsAt?: string;
628
+ /** Window length in minutes, when the provider reported one. */
629
+ windowMinutes?: number;
630
+ }
631
+ interface QuotaRetiredEntry {
632
+ scope: string;
633
+ label: string;
634
+ kind: 'retired';
635
+ retiredAt: number;
636
+ }
637
+ interface QuotaAbsentEntry {
638
+ scope: string;
639
+ label: string;
640
+ kind: 'absent';
641
+ checkedAt: number;
642
+ }
643
+ type QuotaEntry = QuotaReadingEntry | QuotaRetiredEntry | QuotaAbsentEntry;
644
+ interface CreditBudgetReading {
645
+ kind: 'reading';
646
+ checkedAt: number;
647
+ /** The provider's own verdict that the budget is spent. */
648
+ reached: boolean;
649
+ remainingPercent?: number;
650
+ usedPercent?: number;
651
+ resetsAt?: string;
652
+ limit?: number;
653
+ used?: number;
654
+ remaining?: number;
655
+ unit?: string;
656
+ }
657
+ interface CreditBudgetCleared {
658
+ kind: 'cleared';
659
+ checkedAt: number;
660
+ }
661
+ type CreditBudgetEntry = CreditBudgetReading | CreditBudgetCleared;
662
+ interface QuotaCounter {
663
+ value: number;
664
+ checkedAt: number;
665
+ }
666
+ /**
667
+ * Prepaid credits a provider account holds beside its rate-limit windows (for
668
+ * example a ChatGPT workspace's credits, which keep requests working after a
669
+ * window is used up). This is a state, not a count or the spend budget: the
670
+ * account has credits or not, they may be unlimited, and the provider may
671
+ * report a balance. It carries its own observation time.
672
+ */
673
+ interface QuotaCredits {
674
+ hasCredits: boolean;
675
+ unlimited: boolean;
676
+ /** The balance the provider reported, when it reported one. */
677
+ balance?: number;
678
+ /** The provider's verdict that the overage allowance is used up. */
679
+ overageLimitReached?: boolean;
680
+ checkedAt: number;
681
+ }
682
+ interface QuotaMap {
683
+ limits: QuotaEntry[];
684
+ /** Absent means no observation has reported on the budget yet. */
685
+ budget?: CreditBudgetEntry;
686
+ /** Provider-named counts, each with its own observation time. */
687
+ counters?: Record<string, QuotaCounter>;
688
+ /** Absent means no observation has reported on prepaid credits yet. */
689
+ credits?: QuotaCredits;
690
+ }
654
691
  /**
655
692
  * The declined-account interlock: the user's "do not use this vault account",
656
693
  * kept on the consumer side because the vault has no notion of it.
@@ -668,13 +705,6 @@ interface DeclinedAccount {
668
705
  readonly credentialId: string;
669
706
  readonly accountIdentity?: string;
670
707
  }
671
- interface QuotaCommitTimer {
672
- now(): number;
673
- schedule(delayMs: number, run: () => Promise<void>): {
674
- cancel(): void;
675
- unref?(): void;
676
- };
677
- }
678
708
  /**
679
709
  * One vault account as the pool sees it. It carries no bearer material: the
680
710
  * access token is fetched from the vault for every send. Several vault
@@ -808,275 +838,6 @@ interface ClaustrumEnrollmentPaths {
808
838
  statePath: string;
809
839
  tokenPath: string;
810
840
  }
811
- type OAuthCredential = {
812
- type: 'oauth';
813
- access?: string;
814
- refresh: string;
815
- expires?: number;
816
- };
817
- type ApiKeyCredential = {
818
- type: 'api';
819
- apiKey: string;
820
- baseURL: string;
821
- authHeader?: 'authorization-bearer' | 'x-api-key';
822
- };
823
- /** A credential as stored: an OAuth credential also carries its refresh stamp. */
824
- type StoredCredential = (OAuthCredential & {
825
- lastRefreshedAt?: number;
826
- }) | ApiKeyCredential;
827
- /** Quota codec supplied by `/quota`: the store never interprets the map itself. */
828
- interface QuotaCodec {
829
- validate(value: unknown): boolean;
830
- /** Normalize persisted quota before validation, when the codec supports it. */
831
- decode?(value: unknown): unknown;
832
- merge(stored: unknown | undefined, observation: unknown): unknown;
833
- }
834
- /**
835
- * What `ProviderStateCodec.onReplace` is told about a replacement: the row id,
836
- * the credential epoch the new credential starts, `previousIdentity` (the
837
- * identity the locked row recorded before the replace), `identity` (the
838
- * identity the replace records), and the provider state the caller handed to
839
- * `replace`, if any. Each identity is absent when none was recorded.
840
- */
841
- interface ProviderStateReplacement {
842
- id: string;
843
- credentialEpoch: number;
844
- previousIdentity?: string;
845
- identity?: string;
846
- incoming?: unknown;
847
- }
848
- /**
849
- * Codec for the provider state a plugin keeps beside each row's credential
850
- * (a project id, a device fingerprint, eligibility times: whatever belongs to
851
- * that credential). The store never interprets the value: it stores it as
852
- * JSON, asks `validate` before every write and on every load, and calls the
853
- * hooks below where two values meet. Every hook is synchronous and runs
854
- * under the store locks.
855
- */
856
- interface ProviderStateCodec {
857
- validate(value: unknown): boolean;
858
- /**
859
- * The part of a (valid) value that belongs to the credential: what is true
860
- * of the account the credential signs in to, such as a project id or a
861
- * device fingerprint, as opposed to what the plugin merely tracks about
862
- * its use, such as a cooldown or a cursor. The credential stamp covers the
863
- * digest of exactly this projection, so a foreign edit of it hides the
864
- * value, while the rest may change through `updateProviderState` without
865
- * the stamp being rewritten. It must be a pure function of the value that
866
- * returns JSON with a deterministic key order. Without it the whole value
867
- * is credential-bound.
868
- */
869
- credentialBound?(value: unknown): unknown;
870
- /**
871
- * Combines the value on disk with one a write brings (`add` of a secret the
872
- * pool already holds, `rotate`, or a refresh whose provider returned a
873
- * state). Called only when the row has a value on disk; without it the
874
- * incoming value replaces the stored one. Its result is validated.
875
- */
876
- merge?(onDisk: unknown, incoming: unknown): unknown;
877
- /**
878
- * The provider state of a row once `replace` gives it a new credential
879
- * epoch. `previous` is the old credential's value (undefined when the row
880
- * shows none). Returning undefined clears it. Without this hook a replace
881
- * keeps the value handed to `replace` and otherwise clears the state.
882
- */
883
- onReplace?(previous: unknown | undefined, replacement: ProviderStateReplacement): unknown | undefined;
884
- }
885
- /** Every library operation that can fail, as named in the failure value. */
886
- type PoolOperation = 'initialize' | 'add' | 'replace' | 'rotate' | 'disable' | 'enable' | 'remove' | 'reorder' | 'updateSettings' | 'updateLimitsNamespace' | 'recordIdentity' | 'updateProviderState' | 'refresh' | 'pull' | 'publishRoster';
887
- /**
888
- * How far an operation got before it failed.
889
- *
890
- * `before-first-write`: nothing was written; both files are as they were.
891
- * `after-first-write`: the operation's first file write landed and a later one
892
- * did not; what that first write left is on disk and is never rolled back
893
- * (add: a state entry no roster row names, which no reader loads; replace:
894
- * the new credential stamped ahead of the config, which readers show as a
895
- * torn row and the next store write on it completes; rotate: the rotated
896
- * credential beside the old per-row entry). `pull`: a quota pull, or the
897
- * recording of its result, failed.
898
- */
899
- type PoolFailurePhase = 'before-first-write' | 'after-first-write' | 'pull';
900
- /**
901
- * Why an operation failed. `lock-contention` and `lock-ownership` are the two
902
- * lock outcomes (a wait that ran out, and a lease found lost); the rest are
903
- * refusals and failures of the operation itself.
904
- */
905
- type PoolFailureKind = 'lock-contention' | 'lock-ownership' | 'pending-migration' | 'load-error' | 'snapshot-contended' | 'publication-sync' | 'publication-incomplete' | 'unknown-row' | 'invalid-row' | 'invalid-input' | 'id-exists' | 'id-removed' | 'type-mismatch' | 'no-credential' | 'row-disabled' | 'row-protected' | 'row-staged' | 'credential-exists' | 'publication-mismatch' | 'duplicate-identity' | 'identity-mismatch' | 'identity-contradicted' | 'endpoint-mismatch' | 'row-key-changed' | 'invalid-order' | 'refresh-stamp-ahead' | 'unbound-credential' | 'attribution' | 'provider' | 'pull' | 'invalid-quota' | 'invalid-provider-state' | 'after-persist-hook' | 'unexpected';
906
- /**
907
- * The single failure value of every store operation. `committed` is present
908
- * only when the operation had already written a credential to the state file
909
- * before it failed (a partial rotation or refresh): it is the credential now
910
- * on disk, so a caller never has to re-read the files to learn it.
911
- */
912
- declare class PoolOperationError extends Error {
913
- readonly operation: PoolOperation;
914
- readonly rowId: string | undefined;
915
- readonly phase: PoolFailurePhase;
916
- readonly retryable: boolean;
917
- readonly kind: PoolFailureKind;
918
- readonly committed: StoredCredential | undefined;
919
- constructor(details: {
920
- operation: PoolOperation;
921
- rowId?: string;
922
- phase: PoolFailurePhase;
923
- retryable: boolean;
924
- kind: PoolFailureKind;
925
- committed?: StoredCredential;
926
- message?: string;
927
- cause?: unknown;
928
- });
929
- }
930
- interface PoolLogger {
931
- warn(message: string, data?: unknown): void;
932
- }
933
- type LockStep = NonNullable<Parameters<typeof acquireRefreshFileLock>[0]['onStep']> extends ((step: infer S) => unknown) ? S : never;
934
- /** Tuning shared by every lock the store takes; each field is overridable. */
935
- interface PoolLockOptions {
936
- ttlMs: number;
937
- timeoutMs: number;
938
- retryMs: number;
939
- renew: boolean;
940
- renewIntervalMs?: number;
941
- }
942
- /** A lock: the (name, path) pair naming its file plus optional tuning. */
943
- interface PoolLockSpec extends Partial<PoolLockOptions> {
944
- name: string;
945
- path: string;
946
- }
947
- type LockEvent = {
948
- type: 'acquired' | 'released' | 'contended';
949
- name: string;
950
- path: string;
951
- };
952
- interface LockEnvironment {
953
- onLockEvent?: (event: LockEvent) => void;
954
- onLockStep?: (lock: {
955
- name: string;
956
- path: string;
957
- }, step: LockStep) => void | Promise<void>;
958
- onRenewalTimer?: (lock: {
959
- name: string;
960
- path: string;
961
- }, event: 'scheduled' | 'cancelled') => void;
962
- }
963
- /** Named points on the write path, for crash and ownership injection. */
964
- type WriteStep = 'before-config-write' | 'after-config-write' | 'before-state-write' | 'after-state-write';
965
- /** Awaitable pause points on the pull and refresh paths. */
966
- type HoldPoint = 'refresh-before-provider' | 'pull-before-request';
967
- interface StoreContext {
968
- provider: string;
969
- configPath: string;
970
- statePath: string;
971
- codec: QuotaCodec;
972
- /** The provider-state codec; without one no row shows a provider state. */
973
- providerState?: ProviderStateCodec;
974
- now: () => number;
975
- storeLocks: readonly PoolLockSpec[];
976
- lockDefaults: PoolLockOptions;
977
- lockEnv: LockEnvironment;
978
- logger?: PoolLogger;
979
- onStep?: (step: WriteStep, info: {
980
- operation: PoolOperation;
981
- rowId: string | undefined;
982
- }) => void | Promise<void>;
983
- hold?: (point: HoldPoint, rowId: string) => void | Promise<void>;
984
- /** Ids whose per-row entry a library write dropped in this process. */
985
- removedIds: Set<string>;
986
- /**
987
- * When true, rows whose credential stamp is not bound load `unbound` and
988
- * the operations that use a credential refuse them (see
989
- * `OpenPoolStoreOptions.requireCredentialStamps`).
990
- */
991
- requireCredentialStamps?: boolean;
992
- requireRemovedFingerprint?: boolean;
993
- }
994
- /** Where a pull was fired from; `load` fires at most once per process per row. */
995
- type PullReason = 'load' | 'add' | 'replace' | 'admission';
996
- /** What a pull is issued with: the credential and its attribution tuple. */
997
- interface PullRequest {
998
- id: string;
999
- credential: StoredCredential;
1000
- credentialEpoch: number;
1001
- identity?: string;
1002
- reason: PullReason;
1003
- }
1004
- type PullHook = (request: PullRequest) => Promise<unknown>;
1005
- interface OpenPoolStoreOptions {
1006
- /** The provider every row of this pool belongs to; keys the provider-wide lock. */
1007
- provider: string;
1008
- configPath: string;
1009
- statePath: string;
1010
- quota: QuotaCodec;
1011
- /**
1012
- * Opt in to detached, coalesced quota publication, with any `quota` codec.
1013
- * Each accepted observation is queued whole for its row and binding, and
1014
- * the queue is applied in arrival order through `quota.merge` under the
1015
- * store locks, so the codec's own merge decides which fields a newer or
1016
- * older reading replaces. Accepted readings appear in read/load
1017
- * immediately, merged the same way; the returned promise still rejects
1018
- * current-row refusals before queueing. Await dispose or close at shutdown
1019
- * to attempt a bounded drain; readings still pending at its timeout are
1020
- * discarded. Normal quota commits are at least 30 seconds apart; a full
1021
- * queue commits early so response handling never waits for that interval.
1022
- */
1023
- coalesceQuota?: boolean;
1024
- /** Bounded quota drain on close/dispose, in milliseconds; defaults to 1,000. */
1025
- quotaDrainTimeoutMs?: number;
1026
- /** Monotonic clock and scheduling seam for detached quota commits. */
1027
- quotaCommitTimer?: QuotaCommitTimer;
1028
- /**
1029
- * The codec of the provider state kept beside each row's credential (see
1030
- * `ProviderStateCodec`). Without it no row shows a provider state, and
1031
- * every write that would set one refuses (`invalid-input`); writes that
1032
- * leave it alone keep the value on disk as it is, and `replace` clears it.
1033
- */
1034
- providerState?: ProviderStateCodec;
1035
- /**
1036
- * Refuse every credential this store did not stamp (default false, which
1037
- * loads unstamped and mis-stamped credentials as older writers left them).
1038
- * When true, a row whose `stamp` is not `bound` loads `unbound` and is no
1039
- * candidate, and every operation that would use or keep its credential or
1040
- * what was observed about it (`refresh`, quota pulls, `recordQuota`,
1041
- * `recordIdentity`, `rotate`, and an `add` of the same secret or onto the
1042
- * same credential-less row) refuses with `unbound-credential` before any
1043
- * provider call or write, checked again under the locks and at commit.
1044
- * Nothing makes such a row bound except `replace`, which starts a new
1045
- * credential epoch and drops what was observed about the old one.
1046
- * An interrupted add's state-only orphan is recovered only when its stamp
1047
- * binds the stored and incoming material, including a supplied identity and
1048
- * an API key's endpoint/header. Otherwise add refuses `unbound-credential`
1049
- * without writing; `remove(id)` explicitly discards the orphan.
1050
- */
1051
- requireCredentialStamps?: boolean;
1052
- /** Require an exact secret fingerprint for every roster-publication removal. */
1053
- requireRemovedFingerprint?: boolean;
1054
- /** Logical clock for refresh stamps and `addedAt`; filesystem leases always use wall time. */
1055
- now?: () => number;
1056
- /**
1057
- * Ordered store-lock list held across every read-modify-write. Defaults to
1058
- * the older writers' `save` lock at the config path, then at the state path.
1059
- */
1060
- storeLocks?: readonly PoolLockSpec[];
1061
- /** Defaults for every lock the store takes (see `POOL_LOCK_DEFAULTS`). */
1062
- lockOptions?: Partial<PoolLockOptions>;
1063
- /** Overrides for the row locks only. */
1064
- rowLockOptions?: Partial<PoolLockOptions>;
1065
- /** The provider-wide lock; defaults to `provider-<provider>` beside the state file. */
1066
- providerLock?: PoolLockSpec;
1067
- /** Quota pull hook, fired without being awaited. */
1068
- pull?: PullHook;
1069
- /** Receives every pull failure, since no caller awaits a pull. */
1070
- onPullFailure?: (rowId: string, error: PoolOperationError) => void | Promise<void>;
1071
- logger?: PoolLogger;
1072
- /** Named write steps, awaited; a test seam for crash and ownership rows. */
1073
- onStep?: StoreContext['onStep'];
1074
- /** Awaitable hold points on the refresh and pull paths; a test seam. */
1075
- hold?: (point: HoldPoint, rowId: string) => void | Promise<void>;
1076
- onLockEvent?: LockEnvironment['onLockEvent'];
1077
- onLockStep?: LockEnvironment['onLockStep'];
1078
- onRenewalTimer?: LockEnvironment['onRenewalTimer'];
1079
- }
1080
841
  /** Existing callbacks may return a promise for an in-progress quota poll. */
1081
842
  type QuotaReadingRequest = ((id: string) => void) | ((id: string) => Promise<unknown> | undefined);
1082
843
  type VaultHost = 'opencode' | 'pi';
@@ -1319,89 +1080,6 @@ declare class OpenAiVault {
1319
1080
  /** Join the consumer's bounded drain so a restart cannot inherit a half-written lease. */
1320
1081
  dispose(): Promise<void>;
1321
1082
  }
1322
- interface CodexEffortState {
1323
- pinnedEffort?: string;
1324
- effortUpdates?: Array<{
1325
- anchor: number;
1326
- fingerprint: string;
1327
- effort: string;
1328
- }>;
1329
- }
1330
- interface CanonicalInput {
1331
- texts: string[];
1332
- snapshots: unknown[];
1333
- retainable: boolean;
1334
- }
1335
- declare const CODEX_VERSION = "0.166.0";
1336
- declare const CODEX_USER_AGENT = "codex_exec/0.166.0 (Debian 12.0.0; aarch64) unknown (codex_exec; 0.166.0)";
1337
- interface CodexSessionMetadata extends CodexEffortState {
1338
- threadID: string;
1339
- turnID: string;
1340
- windowID: string;
1341
- turnStartedAt?: number;
1342
- input?: unknown[];
1343
- canonicalInput?: CanonicalInput;
1344
- }
1345
- interface CodexRequestRuntime {
1346
- now: () => number;
1347
- uuid: () => string;
1348
- }
1349
- interface IdTokenClaims {
1350
- chatgpt_account_id?: string;
1351
- email?: string;
1352
- organizations?: Array<{
1353
- id: string;
1354
- }>;
1355
- 'https://api.openai.com/auth'?: {
1356
- chatgpt_account_id?: string;
1357
- };
1358
- }
1359
- declare function parseJwtClaims(token: string): IdTokenClaims | undefined;
1360
- declare function extractAccountIdFromClaims(claims: IdTokenClaims): string | undefined;
1361
- interface TokenResponse {
1362
- id_token: string;
1363
- access_token: string;
1364
- refresh_token: string;
1365
- expires_in?: number;
1366
- }
1367
- /**
1368
- * Minimal shape of a fallback OAuth account for ingestion. Matches the
1369
- * fields used by upsertAccount and beginAccountLogin, compatible with
1370
- * the full OAuthAccount type in accounts.ts.
1371
- */
1372
- interface IngestAccount {
1373
- id: string;
1374
- label?: string;
1375
- type: 'oauth';
1376
- access?: string;
1377
- refresh: string;
1378
- expires?: number;
1379
- enabled: boolean;
1380
- addedAt: number;
1381
- lastUsed: number;
1382
- /**
1383
- * When the token was obtained. Stamped at login so a freshly added account
1384
- * carries a refresh marker — without it, the runtime-state merge cannot tell a
1385
- * rotated token from a stale one (both default to 0) and a concurrent stale
1386
- * save could roll the token back.
1387
- */
1388
- lastRefreshedAt?: number;
1389
- /** Stable ChatGPT account identifier from the OAuth token claims. */
1390
- accountId?: string;
1391
- }
1392
- interface BeginAccountLoginOptions {
1393
- label?: string;
1394
- headless?: boolean;
1395
- signal?: AbortSignal;
1396
- /** Host package version, sent as the version half of the `User-Agent`. */
1397
- version: string;
1398
- }
1399
- interface BeginAccountLoginResult {
1400
- url: string;
1401
- instructions: string;
1402
- /** Resolves after the user completes the OAuth flow with a ready-to-ingest account. */
1403
- completion: Promise<IngestAccount>;
1404
- }
1405
1083
  interface ResetTargetIdentity {
1406
1084
  accountKey: string;
1407
1085
  label: string;
@@ -1409,259 +1087,4 @@ interface ResetTargetIdentity {
1409
1087
  chatgptAccountId?: string;
1410
1088
  onAuthFailure?: (status: number) => Promise<void>;
1411
1089
  }
1412
- /** One live process that keeps the fence shut. */
1413
- interface VersionFenceBlocker {
1414
- /** `'unknown'` when a whole directory could not be read. */
1415
- pid: number | 'unknown';
1416
- /** The version its heartbeat or port file names, or `'unknown'`. */
1417
- version: string;
1418
- /** The file or directory that showed it. */
1419
- detail: string;
1420
- }
1421
- type VersionFenceResult = {
1422
- open: true;
1423
- } | {
1424
- open: false;
1425
- blockers: VersionFenceBlocker[];
1426
- };
1427
- /** The host login slot, shaped like the plugin's `client.auth`. */
1428
- interface HostSlotAdapter {
1429
- /** The shared auth.json path, independent of a plugin's config root. */
1430
- path?: string;
1431
- migrationDisabledReason?: () => string | undefined;
1432
- get(input: {
1433
- path: {
1434
- id: string;
1435
- };
1436
- }): Promise<unknown>;
1437
- set(input: {
1438
- path: {
1439
- id: string;
1440
- };
1441
- body: unknown;
1442
- }): Promise<unknown>;
1443
- all(): Promise<Record<string, unknown>>;
1444
- }
1445
- interface PoolMigrationLogger {
1446
- info(message: string, data?: Record<string, unknown>): void;
1447
- warn(message: string, data?: Record<string, unknown>): void;
1448
- }
1449
- /** Named points between this module's own writes; awaited, for crash tests. */
1450
- type PoolMigrationStep = 'after-pool-key-write' | 'after-record-write' | 'after-row-write' | 'after-verify' | 'after-carry-over' | 'before-placeholder-write' | 'after-placeholder-write' | 'after-record-clear' | 'after-marker-write';
1451
- /** Timing of the legacy file locks and of waits on them. */
1452
- interface LegacyLockOptions {
1453
- mainRefreshTtlMs: number;
1454
- fallbackTtlMs: number;
1455
- /** Lease of the `save` lock pair around this module's own config writes. */
1456
- saveTtlMs: number;
1457
- renew: boolean;
1458
- renewIntervalMs?: number;
1459
- /** How long to wait for a held legacy lock before giving up (real clock). */
1460
- timeoutMs: number;
1461
- retryMs: number;
1462
- }
1463
- interface PoolMigrationDeps {
1464
- paths: AccountPaths;
1465
- slot: HostSlotAdapter;
1466
- /** Stop waiting for transfer locks; a transfer already holding them finishes. */
1467
- signal?: AbortSignal;
1468
- now?: () => number;
1469
- sleep?: (ms: number) => Promise<void>;
1470
- /** Id for a new row whose login carries no usable wire identity. */
1471
- newId?: () => string;
1472
- log?: PoolMigrationLogger;
1473
- legacyLocks?: Partial<LegacyLockOptions>;
1474
- /** Bound and poll interval for waiting out an active legacy main lease. */
1475
- leaseWait?: {
1476
- timeoutMs: number;
1477
- pollMs: number;
1478
- };
1479
- /** Pass-through options for the pool store this module opens. */
1480
- store?: Partial<Pick<OpenPoolStoreOptions, 'lockOptions' | 'rowLockOptions' | 'providerLock' | 'storeLocks' | 'onStep' | 'onLockEvent'>>;
1481
- onStep?: (step: PoolMigrationStep) => void | Promise<void>;
1482
- /**
1483
- * Whether the Claustrum vault serves this host's accounts. The built-in
1484
- * adopter does not change course on it: a pool row for an account the
1485
- * vault also holds is skipped by the account source (`pool-account-source.ts`),
1486
- * which neither routes nor refreshes it locally, so adoption can safely
1487
- * move a slot login into the pool and put the placeholder back. The
1488
- * placeholder has to be back: OpenCode 1 installs the plugin's fetch only
1489
- * when its `openai` slot holds an OAuth value.
1490
- */
1491
- vaultServes?: () => boolean;
1492
- }
1493
- type SlotNothingKind = 'api' | 'placeholder' | 'empty' | 'tombstone' | 'slot-absent' | 'declined';
1494
- type PoolTransferOutcome = {
1495
- status: 'slot-read-only';
1496
- reason: string;
1497
- } |
1498
- /**
1499
- * The adoption left the slot alone because the vault serves this host's
1500
- * accounts. The built-in adopter (`adoptHostSlotLogin`) no longer returns
1501
- * this; it can still come from a custom adopter passed to the background
1502
- * runner (`adopt` in `pool-lifecycle.ts`).
1503
- */
1504
- {
1505
- status: 'vault-owns-accounts';
1506
- } |
1507
- /**
1508
- * An openai-auth process older than this one is running (see
1509
- * `version-fence.ts`); nothing was written. The migration runs once they
1510
- * are gone.
1511
- */
1512
- {
1513
- status: 'deferred';
1514
- reason: 'older-version-running';
1515
- blockers: VersionFenceBlocker[];
1516
- } |
1517
- /** Migration already recorded as done; nothing was imported. */
1518
- {
1519
- status: 'already-migrated';
1520
- } |
1521
- /**
1522
- * The slot holds the placeholder, but it was not this store that moved the
1523
- * login out of the slot. The transfer record below is the pending-transfer
1524
- * record in this store's config, written before a transfer touches a row.
1525
- * - `placeholder-without-main`: another store sharing this login slot
1526
- * moved the login, so the login is that store's. Either this store has
1527
- * no `main` row and no transfer record, and nothing is written; or this
1528
- * store's own transfer was under way and found the placeholder tagged
1529
- * with another config root, and only the copy that transfer had put into
1530
- * a row is removed (the other store holds the login now) and the record
1531
- * cleared.
1532
- * - `placeholder-origin-unknown`: this store has a transfer record, but
1533
- * the placeholder is untagged (it has no `accountId` naming the config
1534
- * root that wrote it; builds before this one wrote it that way). The
1535
- * row copy may be this store's only copy of the credential, so it is not
1536
- * deleted; another store may own the login, so the row is disabled
1537
- * rather than routed or refreshed. The record is cleared so that a later
1538
- * background run does not find it and disable the row again after
1539
- * someone has re-enabled it.
1540
- */
1541
- {
1542
- status: 'refused';
1543
- reason: 'placeholder-without-main' | 'placeholder-origin-unknown';
1544
- } |
1545
- /** Adoption asked for before the migration ran. */
1546
- {
1547
- status: 'not-migrated';
1548
- } | {
1549
- status: 'nothing-to-import';
1550
- slot: SlotNothingKind;
1551
- } | {
1552
- status: 'completed';
1553
- rowId: string;
1554
- operation: 'add' | 'rotate' | 'replace' | 'resumed';
1555
- /**
1556
- * `written`: the placeholder was written and read back.
1557
- * `already-present`: a resumed run found the placeholder in place.
1558
- * `slot-moved-on`: the slot changed to another value before the fence;
1559
- * it is left for the next adoption. (A placeholder replaced between its
1560
- * write and the readback ends the run as `retry`,
1561
- * `placeholder-overwritten`, not here.)
1562
- */
1563
- placeholder: 'written' | 'already-present' | 'slot-moved-on';
1564
- } |
1565
- /**
1566
- * An interrupted transfer's row holds neither its old credential nor the
1567
- * slot's: someone rotated it after the interruption, so the slot copy may
1568
- * be stale. The slot is left alone and this exact slot value is declined
1569
- * for adoption; the user's next login resolves it.
1570
- */
1571
- {
1572
- status: 'ambiguous';
1573
- rowId: string;
1574
- } | {
1575
- status: 'retry';
1576
- reason: 'host-slot-indeterminate' | 'legacy-refresh-in-progress' | 'lock-contention' | 'verify-failed' | 'torn-read' | 'slot-changed' |
1577
- /**
1578
- * Something replaced the placeholder between its write and the
1579
- * readback. The record and the shield stay, since the slot may hold
1580
- * the very token the row now holds; the next run reads the slot
1581
- * again and finishes the transfer from what it finds.
1582
- */
1583
- 'placeholder-overwritten' | 'unsettled' |
1584
- /**
1585
- * An adoption found the vault's first roster read still unfinished
1586
- * after its wait, so whether the vault serves this host was unknown;
1587
- * nothing was adopted.
1588
- */
1589
- 'vault-roster-pending' | `store-${string}`;
1590
- } | {
1591
- status: 'error';
1592
- reason: string;
1593
- };
1594
- /** What the migration needs beyond an adoption run. */
1595
- interface PoolMigrationFenceDeps {
1596
- /**
1597
- * The version fence (`migrationFenceOpen` in `version-fence.ts`, bound to
1598
- * this build's version). While it is shut the migration writes nothing.
1599
- */
1600
- fence: () => Promise<VersionFenceResult>;
1601
- }
1602
- /**
1603
- * One-time move of the host-slot credential into the pool row `main`
1604
- * (fallback rows are already pool rows: same ids, same files). It writes
1605
- * nothing while an older openai-auth process runs (`deferred`). A re-run
1606
- * after completion does nothing.
1607
- */
1608
- declare function migrateToPool(deps: PoolMigrationDeps & PoolMigrationFenceDeps): Promise<PoolTransferOutcome>;
1609
- /**
1610
- * After migration: a real login found in the host slot (someone ran
1611
- * `/login openai` in OpenCode) moves into the pool, matched by wire identity,
1612
- * and the placeholder goes back into the slot.
1613
- */
1614
- declare function adoptHostSlotLogin(deps: PoolMigrationDeps): Promise<PoolTransferOutcome>;
1615
- interface PoolLifecycleTimers {
1616
- set(run: () => void, ms: number): unknown;
1617
- clear(handle: unknown): void;
1618
- }
1619
- interface PoolLifecycleDeps {
1620
- /** Read at every run, so it follows the configured store path. */
1621
- paths: () => AccountPaths;
1622
- slot: HostSlotAdapter;
1623
- /** This build's version, for the version fence. */
1624
- version: string;
1625
- log?: PoolMigrationLogger;
1626
- /** Defaults to `migrationFenceOpen` for `version`. */
1627
- fence?: () => Promise<VersionFenceResult>;
1628
- migrate?: typeof migrateToPool;
1629
- adopt?: typeof adoptHostSlotLogin;
1630
- timers?: PoolLifecycleTimers;
1631
- random?: () => number;
1632
- /** Passed through to every migration and adoption run (tests). */
1633
- runDeps?: Partial<PoolMigrationDeps>;
1634
- /**
1635
- * True while no migration or adoption may run: the host is in vault mode,
1636
- * which writes no local account file. Read before every run.
1637
- */
1638
- paused?: () => boolean | Promise<boolean>;
1639
- }
1640
- interface RuntimeLayoutLogger {
1641
- info(message: string, meta?: Record<string, unknown>): unknown;
1642
- warn(message: string, meta?: Record<string, unknown>): unknown;
1643
- }
1644
- interface RuntimeLayoutOptions {
1645
- /** This build's version, for the version fence. */
1646
- version: string;
1647
- log?: RuntimeLayoutLogger;
1648
- /** Defaults to `migrationFenceOpen` for `version`, with the layout checks. */
1649
- fence?: () => Promise<VersionFenceResult>;
1650
- /**
1651
- * Test seams, run at one step of the move. A step that throws stands in for
1652
- * a crash there: nothing after it runs.
1653
- */
1654
- steps?: {
1655
- afterCopy?: () => void | Promise<void>;
1656
- afterMarker?: () => void | Promise<void>;
1657
- /**
1658
- * Runs right before each removal of an old file, of the move's
1659
- * `layout-moving.json` and of the old vault folder, ahead of the lease
1660
- * check that guards it.
1661
- */
1662
- beforeRemove?: (path: string) => void | Promise<void>;
1663
- };
1664
- /** Test seam: how long to wait for the layout lock. */
1665
- layoutLockWaitMs?: number;
1666
- }
1667
- export { AccountPaths as C, loadAccounts as S, BackgroundQuotaRefresh as _, BeginAccountLoginOptions as a, OAuthAccount as b, TokenResponse as c, CODEX_USER_AGENT as d, CODEX_VERSION as f, OpenAiVaultOptions as g, OpenAiVault as h, ResetTargetIdentity as i, extractAccountIdFromClaims as l, CodexSessionMetadata as m, PoolLifecycleDeps as n, BeginAccountLoginResult as o, CodexRequestRuntime as p, HostSlotAdapter as r, IdTokenClaims as s, RuntimeLayoutOptions as t, parseJwtClaims as u, AccountStorage as v, QuotaManager as w, OAuthQuotaSnapshot as x, FallbackAccount as y };
1090
+ export { QuotaCredits as a, FallbackAccount as c, loadAccounts as d, AccountPaths as f, QuotaCounter as i, OAuthAccount as l, OpenAiVault as n, BackgroundQuotaRefresh as o, QuotaManager as p, OpenAiVaultOptions as r, AccountStorage as s, ResetTargetIdentity as t, OAuthQuotaSnapshot as u };