@cortexkit/opencode-antigravity-auth 3.0.12 → 3.0.14

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 (328) hide show
  1. package/dist/cli.js +9839 -6706
  2. package/dist/cli.js.map +4 -4
  3. package/dist/cli.meta.json +722 -175
  4. package/dist/index.js +4902 -1443
  5. package/dist/index.js.map +4 -4
  6. package/dist/index.meta.json +756 -190
  7. package/dist/server.js +8671 -4993
  8. package/dist/server.js.map +4 -4
  9. package/dist/server.meta.json +1 -1
  10. package/dist/src/__fixtures__/runtime-layout-process.d.ts +2 -0
  11. package/dist/src/__fixtures__/runtime-layout-process.d.ts.map +1 -0
  12. package/dist/src/__fixtures__/runtime-layout-process.js +88 -0
  13. package/dist/src/__fixtures__/runtime-layout-process.js.map +1 -0
  14. package/dist/src/cli.d.ts +26 -0
  15. package/dist/src/cli.d.ts.map +1 -1
  16. package/dist/src/cli.js +44 -1
  17. package/dist/src/cli.js.map +1 -1
  18. package/dist/src/common-auth-embedded/claustrum/consumer.d.ts +77 -2
  19. package/dist/src/common-auth-embedded/claustrum/consumer.js +320 -35
  20. package/dist/src/common-auth-embedded/claustrum/custody.d.ts +36 -1
  21. package/dist/src/common-auth-embedded/claustrum/custody.js +95 -11
  22. package/dist/src/common-auth-embedded/claustrum/enrollment.d.ts +9 -0
  23. package/dist/src/common-auth-embedded/claustrum/enrollment.js +52 -20
  24. package/dist/src/common-auth-embedded/claustrum/hub.d.ts +195 -0
  25. package/dist/src/common-auth-embedded/claustrum/hub.js +1032 -0
  26. package/dist/src/common-auth-embedded/claustrum/index.d.ts +13 -3
  27. package/dist/src/common-auth-embedded/claustrum/index.js +37 -4
  28. package/dist/src/common-auth-embedded/claustrum/quota-writer.d.ts +8 -1
  29. package/dist/src/common-auth-embedded/claustrum/quota-writer.js +34 -12
  30. package/dist/src/common-auth-embedded/claustrum/roster.d.ts +49 -1
  31. package/dist/src/common-auth-embedded/claustrum/roster.js +187 -12
  32. package/dist/src/common-auth-embedded/claustrum/shutdown.js +42 -0
  33. package/dist/src/common-auth-embedded/fs/file-read-cache.js +57 -0
  34. package/dist/src/common-auth-embedded/fs/refresh-file-lock.d.ts +1 -1
  35. package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +36 -14
  36. package/dist/src/common-auth-embedded/opencode2/errors.d.ts +4 -1
  37. package/dist/src/common-auth-embedded/opencode2/index.d.ts +2 -2
  38. package/dist/src/common-auth-embedded/opencode2/index.js +1 -1
  39. package/dist/src/common-auth-embedded/opencode2/install.d.ts +7 -5
  40. package/dist/src/common-auth-embedded/opencode2/install.js +139 -13
  41. package/dist/src/common-auth-embedded/opencode2/types.d.ts +42 -10
  42. package/dist/src/common-auth-embedded/quota/commit-interval.d.ts +9 -0
  43. package/dist/src/common-auth-embedded/quota/commit-interval.js +18 -0
  44. package/dist/src/common-auth-embedded/rpc/rpc-server.js +29 -19
  45. package/dist/src/common-auth-embedded/setup/command.js +40 -47
  46. package/dist/src/common-auth-embedded/setup/flags.d.ts +50 -0
  47. package/dist/src/common-auth-embedded/setup/flags.js +123 -0
  48. package/dist/src/common-auth-embedded/setup/index.d.ts +1 -0
  49. package/dist/src/common-auth-embedded/setup/index.js +1 -0
  50. package/dist/src/common-auth-embedded/setup/register.d.ts +2 -0
  51. package/dist/src/common-auth-embedded/setup/register.js +90 -11
  52. package/dist/src/common-auth-embedded/setup/types.d.ts +7 -1
  53. package/dist/src/common-auth-embedded/source-output.json +173 -109
  54. package/dist/src/common-auth-embedded/store/mutate.d.ts +2 -0
  55. package/dist/src/common-auth-embedded/store/mutate.js +4 -0
  56. package/dist/src/common-auth-embedded/store/pool.d.ts +6 -1
  57. package/dist/src/common-auth-embedded/store/pool.js +1 -1
  58. package/dist/src/common-auth-embedded/store/quota-writer.js +27 -13
  59. package/dist/src/common-auth-embedded/store/settings.d.ts +1 -1
  60. package/dist/src/common-auth-embedded/store/settings.js +16 -6
  61. package/dist/src/ga/rpc/protocol.d.ts +2 -0
  62. package/dist/src/ga/rpc/protocol.d.ts.map +1 -1
  63. package/dist/src/ga/rpc/protocol.js +2 -2
  64. package/dist/src/ga/rpc/protocol.js.map +1 -1
  65. package/dist/src/ga/server/auth.d.ts.map +1 -1
  66. package/dist/src/ga/server/auth.js +7 -2
  67. package/dist/src/ga/server/auth.js.map +1 -1
  68. package/dist/src/ga/server/index.d.ts.map +1 -1
  69. package/dist/src/ga/server/index.js +25 -0
  70. package/dist/src/ga/server/index.js.map +1 -1
  71. package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
  72. package/dist/src/ga/tui/host-ga.js +2 -1
  73. package/dist/src/ga/tui/host-ga.js.map +1 -1
  74. package/dist/src/plugin/__fixtures__/controlled-timeouts.d.ts +7 -0
  75. package/dist/src/plugin/__fixtures__/controlled-timeouts.d.ts.map +1 -0
  76. package/dist/src/plugin/__fixtures__/controlled-timeouts.js +41 -0
  77. package/dist/src/plugin/__fixtures__/controlled-timeouts.js.map +1 -0
  78. package/dist/src/plugin/__fixtures__/release-model-ids.d.ts +2 -0
  79. package/dist/src/plugin/__fixtures__/release-model-ids.d.ts.map +1 -0
  80. package/dist/src/plugin/__fixtures__/release-model-ids.js +11 -0
  81. package/dist/src/plugin/__fixtures__/release-model-ids.js.map +1 -0
  82. package/dist/src/plugin/__fixtures__/verified-store.d.ts +3 -0
  83. package/dist/src/plugin/__fixtures__/verified-store.d.ts.map +1 -0
  84. package/dist/src/plugin/__fixtures__/verified-store.js +50 -0
  85. package/dist/src/plugin/__fixtures__/verified-store.js.map +1 -0
  86. package/dist/src/plugin/auth-loader.d.ts +7 -1
  87. package/dist/src/plugin/auth-loader.d.ts.map +1 -1
  88. package/dist/src/plugin/auth-loader.js +4 -4
  89. package/dist/src/plugin/auth-loader.js.map +1 -1
  90. package/dist/src/plugin/background-vault-quota-refresh.d.ts +10 -0
  91. package/dist/src/plugin/background-vault-quota-refresh.d.ts.map +1 -1
  92. package/dist/src/plugin/background-vault-quota-refresh.js +33 -5
  93. package/dist/src/plugin/background-vault-quota-refresh.js.map +1 -1
  94. package/dist/src/plugin/cache/signature-cache.d.ts +7 -1
  95. package/dist/src/plugin/cache/signature-cache.d.ts.map +1 -1
  96. package/dist/src/plugin/cache/signature-cache.js +10 -13
  97. package/dist/src/plugin/cache/signature-cache.js.map +1 -1
  98. package/dist/src/plugin/command-data.d.ts +2 -2
  99. package/dist/src/plugin/command-data.d.ts.map +1 -1
  100. package/dist/src/plugin/command-data.js +2 -0
  101. package/dist/src/plugin/command-data.js.map +1 -1
  102. package/dist/src/plugin/config/loader.d.ts +2 -1
  103. package/dist/src/plugin/config/loader.d.ts.map +1 -1
  104. package/dist/src/plugin/config/loader.js +4 -2
  105. package/dist/src/plugin/config/loader.js.map +1 -1
  106. package/dist/src/plugin/config/operator-settings-schema.d.ts +1 -1
  107. package/dist/src/plugin/config/schema.d.ts +1 -1
  108. package/dist/src/plugin/config/schema.js +1 -1
  109. package/dist/src/plugin/debug.d.ts.map +1 -1
  110. package/dist/src/plugin/debug.js +18 -19
  111. package/dist/src/plugin/debug.js.map +1 -1
  112. package/dist/src/plugin/errors.js +1 -1
  113. package/dist/src/plugin/errors.js.map +1 -1
  114. package/dist/src/plugin/ga-location-services.d.ts +28 -2
  115. package/dist/src/plugin/ga-location-services.d.ts.map +1 -1
  116. package/dist/src/plugin/ga-location-services.js +118 -31
  117. package/dist/src/plugin/ga-location-services.js.map +1 -1
  118. package/dist/src/plugin/ga-shared-vault-custody.d.ts +78 -0
  119. package/dist/src/plugin/ga-shared-vault-custody.d.ts.map +1 -0
  120. package/dist/src/plugin/ga-shared-vault-custody.js +177 -0
  121. package/dist/src/plugin/ga-shared-vault-custody.js.map +1 -0
  122. package/dist/src/plugin/index.d.ts.map +1 -1
  123. package/dist/src/plugin/index.js +38 -6
  124. package/dist/src/plugin/index.js.map +1 -1
  125. package/dist/src/plugin/killswitch.d.ts.map +1 -1
  126. package/dist/src/plugin/killswitch.js +13 -7
  127. package/dist/src/plugin/killswitch.js.map +1 -1
  128. package/dist/src/plugin/oauth-methods.d.ts.map +1 -1
  129. package/dist/src/plugin/oauth-methods.js +3 -0
  130. package/dist/src/plugin/oauth-methods.js.map +1 -1
  131. package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
  132. package/dist/src/plugin/shared/request-services.js +2 -3
  133. package/dist/src/plugin/shared/request-services.js.map +1 -1
  134. package/dist/src/plugin/shared/source-sidebar.d.ts +6 -0
  135. package/dist/src/plugin/shared/source-sidebar.d.ts.map +1 -1
  136. package/dist/src/plugin/shared/source-sidebar.js +1 -1
  137. package/dist/src/plugin/shared/source-sidebar.js.map +1 -1
  138. package/dist/src/plugin/shared/vault-request-credentials.d.ts +8 -1
  139. package/dist/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
  140. package/dist/src/plugin/shared/vault-request-credentials.js +38 -5
  141. package/dist/src/plugin/shared/vault-request-credentials.js.map +1 -1
  142. package/dist/src/plugin/storage.d.ts +5 -2
  143. package/dist/src/plugin/storage.d.ts.map +1 -1
  144. package/dist/src/plugin/storage.js +5 -4
  145. package/dist/src/plugin/storage.js.map +1 -1
  146. package/dist/src/plugin/ui/auth-menu.d.ts.map +1 -1
  147. package/dist/src/plugin/ui/auth-menu.js +3 -0
  148. package/dist/src/plugin/ui/auth-menu.js.map +1 -1
  149. package/dist/src/plugin/ui/quota-status.d.ts.map +1 -1
  150. package/dist/src/plugin/ui/quota-status.js +4 -2
  151. package/dist/src/plugin/ui/quota-status.js.map +1 -1
  152. package/dist/src/plugin/vault-custody.d.ts +57 -15
  153. package/dist/src/plugin/vault-custody.d.ts.map +1 -1
  154. package/dist/src/plugin/vault-custody.js +259 -45
  155. package/dist/src/plugin/vault-custody.js.map +1 -1
  156. package/dist/src/plugin/vault-insula-quota.d.ts.map +1 -1
  157. package/dist/src/plugin/vault-insula-quota.js +4 -0
  158. package/dist/src/plugin/vault-insula-quota.js.map +1 -1
  159. package/dist/src/plugin/vault-sidebar-projection.d.ts.map +1 -1
  160. package/dist/src/process-heartbeat.d.ts +96 -0
  161. package/dist/src/process-heartbeat.d.ts.map +1 -0
  162. package/dist/src/process-heartbeat.js +285 -0
  163. package/dist/src/process-heartbeat.js.map +1 -0
  164. package/dist/src/rpc/rpc-server.d.ts +8 -0
  165. package/dist/src/rpc/rpc-server.d.ts.map +1 -1
  166. package/dist/src/rpc/rpc-server.js +26 -1
  167. package/dist/src/rpc/rpc-server.js.map +1 -1
  168. package/dist/src/runtime-layout.d.ts +100 -0
  169. package/dist/src/runtime-layout.d.ts.map +1 -0
  170. package/dist/src/runtime-layout.js +1242 -0
  171. package/dist/src/runtime-layout.js.map +1 -0
  172. package/dist/src/runtime-paths.d.ts +132 -0
  173. package/dist/src/runtime-paths.d.ts.map +1 -0
  174. package/dist/src/runtime-paths.js +214 -0
  175. package/dist/src/runtime-paths.js.map +1 -0
  176. package/dist/src/setup.d.ts.map +1 -1
  177. package/dist/src/setup.js +31 -5
  178. package/dist/src/setup.js.map +1 -1
  179. package/dist/src/sidebar-projection.d.ts +3 -1
  180. package/dist/src/sidebar-projection.d.ts.map +1 -1
  181. package/dist/src/sidebar-projection.js +10 -1
  182. package/dist/src/sidebar-projection.js.map +1 -1
  183. package/dist/src/sidebar-state.d.ts +10 -1
  184. package/dist/src/sidebar-state.d.ts.map +1 -1
  185. package/dist/src/sidebar-state.js +12 -2
  186. package/dist/src/sidebar-state.js.map +1 -1
  187. package/dist/src/tui/quota-layout.d.ts +3 -1
  188. package/dist/src/tui/quota-layout.d.ts.map +1 -1
  189. package/dist/src/tui/quota-layout.js +6 -1
  190. package/dist/src/tui/quota-layout.js.map +1 -1
  191. package/dist/src/vault-folder.d.ts +38 -0
  192. package/dist/src/vault-folder.d.ts.map +1 -0
  193. package/dist/src/vault-folder.js +91 -0
  194. package/dist/src/vault-folder.js.map +1 -0
  195. package/dist/src/version-fence.d.ts +54 -0
  196. package/dist/src/version-fence.d.ts.map +1 -0
  197. package/dist/src/version-fence.js +254 -0
  198. package/dist/src/version-fence.js.map +1 -0
  199. package/dist/tui-build-map.json +9 -9
  200. package/dist/tui-ga-build-map.json +13 -13
  201. package/dist/types/src/cli.d.ts +26 -0
  202. package/dist/types/src/cli.d.ts.map +1 -1
  203. package/dist/types/src/common-auth-embedded/claustrum/consumer.d.ts +77 -2
  204. package/dist/types/src/common-auth-embedded/claustrum/custody.d.ts +36 -1
  205. package/dist/types/src/common-auth-embedded/claustrum/enrollment.d.ts +9 -0
  206. package/dist/types/src/common-auth-embedded/claustrum/hub.d.ts +195 -0
  207. package/dist/types/src/common-auth-embedded/claustrum/index.d.ts +13 -3
  208. package/dist/types/src/common-auth-embedded/claustrum/quota-writer.d.ts +8 -1
  209. package/dist/types/src/common-auth-embedded/claustrum/roster.d.ts +49 -1
  210. package/dist/types/src/common-auth-embedded/fs/refresh-file-lock.d.ts +1 -1
  211. package/dist/types/src/common-auth-embedded/opencode2/errors.d.ts +4 -1
  212. package/dist/types/src/common-auth-embedded/opencode2/index.d.ts +2 -2
  213. package/dist/types/src/common-auth-embedded/opencode2/install.d.ts +7 -5
  214. package/dist/types/src/common-auth-embedded/opencode2/types.d.ts +42 -10
  215. package/dist/types/src/common-auth-embedded/quota/commit-interval.d.ts +9 -0
  216. package/dist/types/src/common-auth-embedded/setup/flags.d.ts +50 -0
  217. package/dist/types/src/common-auth-embedded/setup/index.d.ts +1 -0
  218. package/dist/types/src/common-auth-embedded/setup/register.d.ts +2 -0
  219. package/dist/types/src/common-auth-embedded/setup/types.d.ts +7 -1
  220. package/dist/types/src/common-auth-embedded/store/mutate.d.ts +2 -0
  221. package/dist/types/src/common-auth-embedded/store/pool.d.ts +6 -1
  222. package/dist/types/src/common-auth-embedded/store/settings.d.ts +1 -1
  223. package/dist/types/src/ga/rpc/protocol.d.ts +2 -0
  224. package/dist/types/src/ga/rpc/protocol.d.ts.map +1 -1
  225. package/dist/types/src/ga/server/auth.d.ts.map +1 -1
  226. package/dist/types/src/ga/server/index.d.ts.map +1 -1
  227. package/dist/types/src/plugin/auth-loader.d.ts +7 -1
  228. package/dist/types/src/plugin/auth-loader.d.ts.map +1 -1
  229. package/dist/types/src/plugin/background-vault-quota-refresh.d.ts +10 -0
  230. package/dist/types/src/plugin/background-vault-quota-refresh.d.ts.map +1 -1
  231. package/dist/types/src/plugin/cache/signature-cache.d.ts +7 -1
  232. package/dist/types/src/plugin/cache/signature-cache.d.ts.map +1 -1
  233. package/dist/types/src/plugin/command-data.d.ts +2 -2
  234. package/dist/types/src/plugin/command-data.d.ts.map +1 -1
  235. package/dist/types/src/plugin/config/loader.d.ts +2 -1
  236. package/dist/types/src/plugin/config/loader.d.ts.map +1 -1
  237. package/dist/types/src/plugin/debug.d.ts.map +1 -1
  238. package/dist/types/src/plugin/ga-location-services.d.ts +28 -2
  239. package/dist/types/src/plugin/ga-location-services.d.ts.map +1 -1
  240. package/dist/types/src/plugin/ga-shared-vault-custody.d.ts +78 -0
  241. package/dist/types/src/plugin/ga-shared-vault-custody.d.ts.map +1 -0
  242. package/dist/types/src/plugin/index.d.ts.map +1 -1
  243. package/dist/types/src/plugin/killswitch.d.ts.map +1 -1
  244. package/dist/types/src/plugin/oauth-methods.d.ts.map +1 -1
  245. package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -1
  246. package/dist/types/src/plugin/shared/source-sidebar.d.ts +6 -0
  247. package/dist/types/src/plugin/shared/source-sidebar.d.ts.map +1 -1
  248. package/dist/types/src/plugin/shared/vault-request-credentials.d.ts +8 -1
  249. package/dist/types/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
  250. package/dist/types/src/plugin/storage.d.ts +5 -2
  251. package/dist/types/src/plugin/storage.d.ts.map +1 -1
  252. package/dist/types/src/plugin/ui/auth-menu.d.ts.map +1 -1
  253. package/dist/types/src/plugin/ui/quota-status.d.ts.map +1 -1
  254. package/dist/types/src/plugin/vault-custody.d.ts +57 -15
  255. package/dist/types/src/plugin/vault-custody.d.ts.map +1 -1
  256. package/dist/types/src/plugin/vault-insula-quota.d.ts.map +1 -1
  257. package/dist/types/src/plugin/vault-sidebar-projection.d.ts.map +1 -1
  258. package/dist/types/src/process-heartbeat.d.ts +96 -0
  259. package/dist/types/src/process-heartbeat.d.ts.map +1 -0
  260. package/dist/types/src/rpc/rpc-server.d.ts +8 -0
  261. package/dist/types/src/rpc/rpc-server.d.ts.map +1 -1
  262. package/dist/types/src/runtime-layout.d.ts +100 -0
  263. package/dist/types/src/runtime-layout.d.ts.map +1 -0
  264. package/dist/types/src/runtime-paths.d.ts +132 -0
  265. package/dist/types/src/runtime-paths.d.ts.map +1 -0
  266. package/dist/types/src/setup.d.ts.map +1 -1
  267. package/dist/types/src/sidebar-state.d.ts +10 -1
  268. package/dist/types/src/sidebar-state.d.ts.map +1 -1
  269. package/dist/types/src/vault-folder.d.ts +38 -0
  270. package/dist/types/src/vault-folder.d.ts.map +1 -0
  271. package/dist/types/src/version-fence.d.ts +54 -0
  272. package/dist/types/src/version-fence.d.ts.map +1 -0
  273. package/package.json +2 -2
  274. package/src/common-auth-embedded/claustrum/consumer.d.ts +77 -2
  275. package/src/common-auth-embedded/claustrum/consumer.js +320 -35
  276. package/src/common-auth-embedded/claustrum/custody.d.ts +36 -1
  277. package/src/common-auth-embedded/claustrum/custody.js +95 -11
  278. package/src/common-auth-embedded/claustrum/enrollment.d.ts +9 -0
  279. package/src/common-auth-embedded/claustrum/enrollment.js +52 -20
  280. package/src/common-auth-embedded/claustrum/hub.d.ts +195 -0
  281. package/src/common-auth-embedded/claustrum/hub.js +1032 -0
  282. package/src/common-auth-embedded/claustrum/index.d.ts +13 -3
  283. package/src/common-auth-embedded/claustrum/index.js +37 -4
  284. package/src/common-auth-embedded/claustrum/quota-writer.d.ts +8 -1
  285. package/src/common-auth-embedded/claustrum/quota-writer.js +34 -12
  286. package/src/common-auth-embedded/claustrum/roster.d.ts +49 -1
  287. package/src/common-auth-embedded/claustrum/roster.js +187 -12
  288. package/src/common-auth-embedded/claustrum/shutdown.js +42 -0
  289. package/src/common-auth-embedded/fs/file-read-cache.js +57 -0
  290. package/src/common-auth-embedded/fs/refresh-file-lock.d.ts +1 -1
  291. package/src/common-auth-embedded/fs/refresh-file-lock.js +36 -14
  292. package/src/common-auth-embedded/opencode2/errors.d.ts +4 -1
  293. package/src/common-auth-embedded/opencode2/index.d.ts +2 -2
  294. package/src/common-auth-embedded/opencode2/index.js +1 -1
  295. package/src/common-auth-embedded/opencode2/install.d.ts +7 -5
  296. package/src/common-auth-embedded/opencode2/install.js +139 -13
  297. package/src/common-auth-embedded/opencode2/types.d.ts +42 -10
  298. package/src/common-auth-embedded/quota/commit-interval.d.ts +9 -0
  299. package/src/common-auth-embedded/quota/commit-interval.js +18 -0
  300. package/src/common-auth-embedded/rpc/rpc-server.js +29 -19
  301. package/src/common-auth-embedded/setup/command.js +40 -47
  302. package/src/common-auth-embedded/setup/flags.d.ts +50 -0
  303. package/src/common-auth-embedded/setup/flags.js +123 -0
  304. package/src/common-auth-embedded/setup/index.d.ts +1 -0
  305. package/src/common-auth-embedded/setup/index.js +1 -0
  306. package/src/common-auth-embedded/setup/register.d.ts +2 -0
  307. package/src/common-auth-embedded/setup/register.js +90 -11
  308. package/src/common-auth-embedded/setup/types.d.ts +7 -1
  309. package/src/common-auth-embedded/source-output.json +173 -109
  310. package/src/common-auth-embedded/store/mutate.d.ts +2 -0
  311. package/src/common-auth-embedded/store/mutate.js +4 -0
  312. package/src/common-auth-embedded/store/pool.d.ts +6 -1
  313. package/src/common-auth-embedded/store/pool.js +1 -1
  314. package/src/common-auth-embedded/store/quota-writer.js +27 -13
  315. package/src/common-auth-embedded/store/settings.d.ts +1 -1
  316. package/src/common-auth-embedded/store/settings.js +16 -6
  317. package/src/plugin/command-data.ts +4 -2
  318. package/src/sidebar-state.ts +23 -3
  319. package/src/tui-compiled/sidebar-state.js +4 -3
  320. package/src/tui-compiled/tui/quota-layout.js +3 -2
  321. package/src/tui-ga-compiled/host-ga.js +2 -1
  322. package/src/tui-ga-compiled/shared/8ae1927e5910ea81-sidebar-projection.js +9 -2
  323. package/src/tui-ga-compiled/shared/dd4c9e1a907f8ef0-quota-layout.js +3 -2
  324. package/src/tui-ga-raw/host-ga.tsx +12 -1
  325. package/src/tui-ga-raw/shared/8ae1927e5910ea81-sidebar-projection.js +9 -2
  326. package/src/tui-ga-raw/shared/dd4c9e1a907f8ef0-quota-layout.tsx +9 -2
  327. package/src/tui-raw/sidebar-state.js +4 -3
  328. package/src/tui-raw/tui/quota-layout.tsx +9 -2
@@ -0,0 +1,195 @@
1
+ import type { QuotaObservation } from '../quota/index.js';
2
+ import { type ClaustrumConsumer } from './consumer.js';
3
+ import { type ClassifyingClaustrumFamily, type ClaustrumScopedClient, ClaustrumScopedCustody, type IdentityParser, type KeptReceiptState, type VaultGrantReach } from './custody.js';
4
+ import { type ClaustrumLogger } from './errors.js';
5
+ import { type AccountMapper, type VaultRosterFile } from './roster.js';
6
+ import { type WatchMode } from './watch.js';
7
+ export interface ClaustrumDiscoveryHubOptions {
8
+ /**
9
+ * The plugin's owner-only state directory. Member rosters live under
10
+ * `<stateDir>/rosters/<hostGeneration>/<fingerprint>/<provider>.json`.
11
+ */
12
+ stateDir: string;
13
+ /**
14
+ * Which host generation this process runs (for example `opencode1`,
15
+ * `opencode2` or `pi`). Hosts that classify rows differently keep separate
16
+ * roster directories.
17
+ */
18
+ hostGeneration: string;
19
+ /**
20
+ * Everything the plugin's classifier decides with, as plain JSON: the
21
+ * exact object it hands the classifier (its version, the supported-table
22
+ * entries, the reserved provider set and every host fact it reads). The
23
+ * hub hashes it, with the member set, `routePrefix` and `mapAccount`, into
24
+ * the roster key, so processes whose classifiers or projections could
25
+ * disagree never share a roster file. Configuration that `mapAccount`
26
+ * reads, beyond its own source text, belongs here too.
27
+ */
28
+ classifierInput: unknown;
29
+ /**
30
+ * Every provider the plugin serves on this host, fixed for the hub's life.
31
+ * Each is the `member` a classified row names and a roster file name, so
32
+ * it is lowercase ASCII: letters, digits, `.`, `_` and `-`.
33
+ */
34
+ members: readonly string[];
35
+ /** Prefix of every member's vault route ids; part of the roster key. */
36
+ routePrefix?: string;
37
+ /**
38
+ * How every member presents a vault credential (the credential names its
39
+ * member). Part of the roster key by its source text.
40
+ */
41
+ mapAccount?: AccountMapper;
42
+ /** This host's enrollment token, written by setup. */
43
+ tokenPath: string;
44
+ /**
45
+ * The plugin's classifying family. A legacy `ClaustrumFamily` names no
46
+ * member for any row and is refused.
47
+ */
48
+ family: ClassifyingClaustrumFamily<string>;
49
+ connect: () => Promise<ClaustrumScopedClient>;
50
+ /**
51
+ * How long one `connect()` attempt may take before the hub treats the vault
52
+ * as unreachable (default 10 s, as `ClaustrumConsumerOptions`). The hub's
53
+ * connect is shared by every member waiting for a lease, so an attempt that
54
+ * never settles would hold every one of them; after the limit they get an
55
+ * unreachable error and the next acquire connects again.
56
+ */
57
+ connectTimeoutMs?: number;
58
+ /**
59
+ * Whether the plugin takes its accounts from the vault. Read from local
60
+ * state only, never from the vault: on every hub tick, and when a member
61
+ * refreshes or authorizes. The first false read revokes every lease,
62
+ * closes the connection and clears every member.
63
+ */
64
+ isCustodyActive?: () => boolean | Promise<boolean>;
65
+ parseIdentity?: IdentityParser;
66
+ /** As `ClaustrumConsumerOptions.requireAssertion`, for every member. */
67
+ requireAssertion?: boolean;
68
+ /**
69
+ * How often the hub ticks (default 5 s). A tick reads authority, installs
70
+ * member roster files another writer changed under the same view, and
71
+ * lists when a list is due: on every tick while no vault watch is open,
72
+ * when a pending member's retry is due (a member the last list did not
73
+ * commit, retried with a backoff), otherwise every five minutes as a
74
+ * safety net.
75
+ */
76
+ pollIntervalMs?: number;
77
+ setTimeoutImpl?: typeof setTimeout;
78
+ clearTimeoutImpl?: typeof clearTimeout;
79
+ now?: () => number;
80
+ logger?: ClaustrumLogger;
81
+ /**
82
+ * Errors of the hub's own tick, list and watch. A failed list and a vault
83
+ * refusal of the watch also reach every member's `onError`.
84
+ */
85
+ onError?: (error: unknown) => void;
86
+ }
87
+ /**
88
+ * What one hub member takes: only what is per provider. The hub owns the
89
+ * roster path, the enrollment token, the family, the connection, the
90
+ * authority check, the poll timer and the projection inputs that are part of
91
+ * the roster key (`routePrefix`, `mapAccount`), so none of them can be given
92
+ * here. The type parameter matches the consumer `member` returns; members
93
+ * have no insula source.
94
+ */
95
+ export interface ClaustrumHubMemberOptions<_Q = QuotaObservation> {
96
+ /**
97
+ * Ids of the plugin's local pool rows; no vault route id may equal one.
98
+ * Read on every projection and install, so it may change at any time.
99
+ */
100
+ reservedRouteIds?: () => Iterable<string>;
101
+ /** As `ClaustrumConsumerOptions.onRoster`: once per change of view. */
102
+ onRoster?: (roster: VaultRosterFile) => void;
103
+ /** This member's own failures, such as a roster commit that failed. */
104
+ onError?: (error: unknown) => void;
105
+ logger?: ClaustrumLogger;
106
+ }
107
+ /** What a lease may do with the shared custody. */
108
+ export type ClaustrumLeasedCustody = Pick<ClaustrumScopedCustody, 'authorize' | 'reportFailure' | 'forget' | 'keptReceiptState'>;
109
+ /**
110
+ * One acquisition of the hub's shared custody. `custody` throws `closed`
111
+ * after `release()`, and once the connection it belongs to ended for any
112
+ * reason, vault mode going off included. `release()` is idempotent.
113
+ */
114
+ export interface CustodyLease {
115
+ readonly custody: ClaustrumLeasedCustody;
116
+ /** The connection this lease belongs to; each new connection counts up. */
117
+ readonly generation: number;
118
+ release(): void;
119
+ }
120
+ /** The rows the hub's last complete discovery refused or left to others. */
121
+ export interface ClaustrumHubRefusals {
122
+ readonly view: string;
123
+ readonly refused: readonly {
124
+ credentialId?: string;
125
+ code: string;
126
+ }[];
127
+ readonly notMine: number;
128
+ }
129
+ /**
130
+ * One discovery hub per host process: the only vault connection and the only
131
+ * `ClaustrumScopedCustody`, one vault watch and one list per refresh, fanned
132
+ * out to one roster per provider. Members (`member()`) are ordinary
133
+ * `ClaustrumConsumer`s that never connect, list or watch themselves; each
134
+ * holds a custody lease. The connection stays open while vault mode is on,
135
+ * because the hub's own discovery holds a lease of its own, and closes when
136
+ * the last lease of a connection is released, when vault mode goes off, or
137
+ * at `close()`.
138
+ */
139
+ export declare class ClaustrumDiscoveryHub {
140
+ #private;
141
+ constructor(options: ClaustrumDiscoveryHubOptions);
142
+ /** The roster file member `provider` reads and the hub commits. */
143
+ rosterPath(provider: string): string;
144
+ /**
145
+ * Build the consumer for `provider`, once. It is an ordinary
146
+ * `ClaustrumConsumer` whose roster path is `rosterPath(provider)`; it
147
+ * connects, lists and watches only through this hub.
148
+ */
149
+ member<Q = QuotaObservation>(provider: string, options: ClaustrumHubMemberOptions<Q>): ClaustrumConsumer<Q>;
150
+ /**
151
+ * Take a lease on the current connection, connecting first when there is
152
+ * none. The acquirer's count is taken before anything is awaited, so a
153
+ * release elsewhere meanwhile cannot end the connection under it. An abort
154
+ * or a failed connect gives that count back; an acquirer whose connection
155
+ * ended while it waited tries once more on the current one. Rejects with
156
+ * `not-active` while vault mode is off.
157
+ */
158
+ acquire(signal?: AbortSignal): Promise<CustodyLease>;
159
+ /** The current connection and its lease count, for status and tests. */
160
+ leaseState(): {
161
+ readonly generation?: number;
162
+ readonly count: number;
163
+ };
164
+ /**
165
+ * Start the hub's tick, which runs until `close()`. While vault mode is
166
+ * off a tick only reads authority and makes no vault request.
167
+ */
168
+ start(): void;
169
+ /**
170
+ * List once and commit every member, as a tick does. Resolves once every
171
+ * member's memory holds its new roster. Rejects when the list fails; a
172
+ * member's own commit error goes to that member's `onError`.
173
+ */
174
+ refresh(): Promise<void>;
175
+ /**
176
+ * Rows the last discovery every member committed refused, with their fixed
177
+ * codes, and how many rows it left to other plugins. Undefined while
178
+ * unknown: before a complete discovery, and while vault mode is off.
179
+ */
180
+ refusals(): ClaustrumHubRefusals | undefined;
181
+ /** The grant reach of the same discovery as `refusals()`. */
182
+ grantReach(): VaultGrantReach | undefined;
183
+ /** How the hub learns about changes; `polling` until a watch is open. */
184
+ watchState(): WatchMode;
185
+ /** The shared custody's kept receipts, host-wide. */
186
+ keptReceiptState(): KeptReceiptState;
187
+ /**
188
+ * Stop the tick and the watch and close the connection. Members are not
189
+ * closed; they fail `closed` from then on. Use `dispose()` to also allow
190
+ * in-flight discovery up to two seconds to release its file handles.
191
+ */
192
+ close(): void;
193
+ /** Close immediately, then join background work for at most two seconds. */
194
+ dispose(): Promise<void>;
195
+ }
@@ -2,21 +2,31 @@ import { type ClaustrumClientOptions } from '@cortexkit/claustrum-client';
2
2
  import type { ClaustrumScopedClient } from './custody.js';
3
3
  export { ClaustrumCredentialError, type ClaustrumReporterSource, type EnrollmentTokenFile, } from '@cortexkit/claustrum-client';
4
4
  export { ClaustrumUnreachableError, classifyVaultFailure, VAULT_FAILURE_CLASSES, type VaultFailureClass, } from './availability.js';
5
- export { ClaustrumConsumer, type ClaustrumConsumerOptions, type ClaustrumWatchState, type SendOptions, } from './consumer.js';
6
- export { type AccountIdentitySource, type ClaustrumFamily, type ClaustrumRosterWatch, type ClaustrumRosterWatchOptions, type ClaustrumScopedAttempt, type ClaustrumScopedClient, ClaustrumScopedCustody, type ClaustrumScopedIdentity, decideScopedRetryAfter401, type IdentityParser, isScopedCredentialRotation, KEPT_RECEIPT_MARGIN_MS, type KeptReceiptState, type ScopedRetryReason, SERVING_MARGIN_MS, type SkippedVaultReason, type SkippedVaultRecord, type VaultCredential, type VaultCredentialType, type VaultGrantReach, type VaultGrantTuple, type VaultInventory, } from './custody.js';
5
+ export { ClaustrumConsumer, type ClaustrumConsumerOptions, type ClaustrumWatchState, DEFAULT_CONNECT_TIMEOUT_MS, type SendOptions, } from './consumer.js';
6
+ export { type AccountIdentitySource, type ClassifyingClaustrumFamily, type ClaustrumFamily, type ClaustrumFamilyInput, type ClaustrumRosterWatch, type ClaustrumRosterWatchOptions, type ClaustrumScopedAttempt, type ClaustrumScopedClient, ClaustrumScopedCustody, type ClaustrumScopedIdentity, decideScopedRetryAfter401, type IdentityParser, isScopedCredentialRotation, KEPT_RECEIPT_MARGIN_MS, type KeptReceiptState, type ScopedRetryReason, SERVING_MARGIN_MS, type SkippedVaultReason, type SkippedVaultRecord, type VaultCredential, type VaultCredentialType, type VaultGrantReach, type VaultGrantTuple, type VaultInventory, type VaultRowFacts, } from './custody.js';
7
7
  export { type ClaustrumEnrollmentClient, type ClaustrumEnrollmentConnection, type ClaustrumEnrollmentDisconnectResult, ClaustrumEnrollmentManager, type ClaustrumEnrollmentPaths, type ClaustrumEnrollmentResetResult, type ClaustrumEnrollmentStatus, classifyEnrollmentError, connectClaustrumEnrollmentClient, disconnectClaustrumEnrollment, type EnrollmentDisposition, enrollmentAuthority, enrollmentName, getClaustrumEnrollmentPaths, hostEnrollmentPaths, RETRYABLE_ENROLLMENT_CODES, readClaustrumEnrollmentStatus, readClaustrumEnrollmentToken, resetClaustrumEnrollmentState, TERMINAL_ENROLLMENT_CODES, } from './enrollment.js';
8
8
  export { ClaustrumConsumerError, type ClaustrumConsumerFailureKind, type ClaustrumLogger, } from './errors.js';
9
9
  export { assertHostSlotMatchesMode, assertNotCustodyPlaceholder, CUSTODY_PLACEHOLDER_PREFIX, classifyHostSlot, custodyPlaceholder, custodyPlaceholderKey, type HostSlotContent, isCustodyPlaceholder, isCustodyPlaceholderValue, } from './host-slot.js';
10
+ export { ClaustrumDiscoveryHub, type ClaustrumDiscoveryHubOptions, type ClaustrumHubMemberOptions, type ClaustrumHubRefusals, type ClaustrumLeasedCustody, type CustodyLease, } from './hub.js';
10
11
  export { acquireInsulaQuotaSource, type InsulaQuotaContext, type InsulaQuotaLookup, type InsulaQuotaMiss, type InsulaQuotaOptions, type InsulaQuotaReading, type InsulaQuotaResult, type InsulaQuotaSource, type InsulaUsageEntry, type InsulaUsageTransport, type InsulaUsageWatch, type InsulaUsageWindow, type InsulaWatchOptions, } from './insula.js';
11
12
  export { acceptAccount, type DeclinedAccount, declineAccount, isDeclined, } from './interlock.js';
12
13
  export { drainVaultQuota } from './quota-writer.js';
13
- export { type AccountMapper, acceptVaultRoute, DEFAULT_ROUTE_PREFIX, declineVaultRoute, type MutateVaultRosterOptions, mutateVaultRoster, type ProjectionOptions, projectVaultRoster, type QuotaReceipt, type ReorderVaultRosterOptions, type ReorderVaultRosterResult, readVaultRoster, recordVaultAccountQuota, recordVaultQuota, refreshVaultRoster, reorderVaultRoster, resolveVaultPrimary, type VaultPrimary, type VaultPrimaryBinding, type VaultPrimaryUnavailableReason, type VaultRosterFile, type VaultRosterLockContext, type VaultRosterRow, vaultRoutingRows, } from './roster.js';
14
+ export { type AccountMapper, acceptVaultRoute, DEFAULT_ROUTE_PREFIX, declineVaultRoute, type MutateVaultRosterOptions, mutateVaultRoster, type ProjectionOptions, projectVaultRoster, type QuotaReceipt, type ReorderVaultRosterOptions, type ReorderVaultRosterResult, readVaultRoster, recordVaultAccountQuota, recordVaultQuota, refreshVaultRoster, reorderVaultRoster, resolveVaultPrimary, type VaultPrimary, type VaultPrimaryBinding, type VaultPrimaryUnavailableReason, type VaultRosterFile, type VaultRosterLockContext, type VaultRosterRow, type VaultRosterSeed, vaultRosterSeed, vaultRoutingRows, } from './roster.js';
14
15
  export { type ChangeNotice, ChangeNoticeReader, RESUBSCRIBE_BACKOFF_MS, SAFETY_POLL_MS, ScopedRosterWatch, type ScopedRosterWatchOptions, type ScopedWatchEnd, type ScopedWatchHandle, type ScopedWatchNoticeShape, type ScopedWatchSource, WATCH_RETRY_MS, type WatchMode, } from './watch.js';
16
+ /** How long `connectClaustrumScopedClient` waits by default. */
17
+ export declare const SCOPED_CONNECT_TIMEOUT_MS = 10000;
15
18
  /**
16
19
  * Connect the client that lists and fetches this consumer's vault credentials
17
20
  * on the request path. `connectionFile` is required: this library
18
21
  * reads no environment, so the plugin resolves the vault's connection file.
22
+ *
23
+ * The wait is bounded by `connectTimeoutMs` (default 10 s) so a connect that
24
+ * never settles cannot leave a consumer with a pending connection forever; the
25
+ * caller then gets an unreachable error and may try again. A socket handshake
26
+ * has its own limit, but local reads before it (the connection file) do not,
27
+ * and a client that arrives after this deadline is closed, not returned.
19
28
  */
20
29
  export declare function connectClaustrumScopedClient(options: ClaustrumClientOptions & {
21
30
  connectionFile: string;
31
+ connectTimeoutMs?: number;
22
32
  }): Promise<ClaustrumScopedClient>;
@@ -1,3 +1,4 @@
1
+ import { type QuotaCommitTimer } from '../quota/commit-interval.js';
1
2
  import { type QuotaObservation } from '../quota/index.js';
2
3
  import { type QuotaReceipt, type VaultRosterFile } from './roster.js';
3
4
  export type VaultQuotaPublication = {
@@ -8,11 +9,17 @@ export type VaultQuotaPublication = {
8
9
  };
9
10
  type Listener = (publication: VaultQuotaPublication) => void;
10
11
  /** Retain the shared writer; the last consumer's close drains it. */
11
- export declare function retainVaultQuotaWriter(path: string, listener: Listener): () => Promise<void>;
12
+ export declare function retainVaultQuotaWriter(path: string, listener: Listener, clock?: QuotaCommitTimer): () => Promise<void>;
12
13
  /** Enqueue without filesystem work; each quota field retains its own receipt fence. */
13
14
  export declare function enqueueVaultQuota(path: string, publication: VaultQuotaPublication): Promise<boolean>;
14
15
  /** Overlay uncommitted observations when a consumer reloads the durable roster. */
15
16
  export declare function pendingVaultQuota(path: string, roster: VaultRosterFile | undefined): VaultRosterFile | undefined;
17
+ /**
18
+ * Whether this process holds quota readings for `path` that no commit of the
19
+ * durable roster has written yet, so a reader of the file alone is not seeing
20
+ * everything this process would publish.
21
+ */
22
+ export declare function hasPendingVaultQuota(path: string): boolean;
16
23
  /** Wait at most timeoutMs for detached publication; shutdown loss is acceptable. */
17
24
  export declare function drainVaultQuota(path: string, timeoutMs?: number): Promise<void>;
18
25
  export {};
@@ -62,7 +62,25 @@ export interface ProjectionOptions {
62
62
  routePrefix?: string;
63
63
  mapAccount?: AccountMapper;
64
64
  now?: number;
65
+ /**
66
+ * Preferences carried over from another roster file, used only when there
67
+ * is no previous roster: its declines become this roster's declines, and
68
+ * its account order sorts the rows this inventory produces. No row of the
69
+ * seed is ever projected, so a seed cannot make an account routable.
70
+ */
71
+ seed?: VaultRosterSeed;
72
+ }
73
+ /** The preferences one roster file can pass to a first projection elsewhere. */
74
+ export interface VaultRosterSeed {
75
+ readonly declined: readonly DeclinedAccount[];
76
+ /** Accounts in the seed roster's order, matched by account, then by id. */
77
+ readonly order: readonly {
78
+ readonly credentialId: string;
79
+ readonly accountIdentity?: string;
80
+ }[];
65
81
  }
82
+ /** Declines and account order of `roster`, and nothing else of it. */
83
+ export declare function vaultRosterSeed(roster: VaultRosterFile): VaultRosterSeed;
66
84
  export declare const DEFAULT_ROUTE_PREFIX = "vault:";
67
85
  /**
68
86
  * Project the vault's list onto the previous roster. Pure: callers serialize
@@ -87,6 +105,12 @@ export declare function projectVaultRoster(previous: VaultRosterFile | undefined
87
105
  * reaches admission.
88
106
  */
89
107
  export declare function vaultRoutingRows(roster: VaultRosterFile | undefined): RoutingRow[];
108
+ /**
109
+ * `roster` as `readVaultRoster` decodes it from the file that holds it, so a
110
+ * committed roster and a later read of its file compare equal. Package
111
+ * internal: not exported from `/claustrum`.
112
+ */
113
+ export declare function decodedVaultRoster(roster: VaultRosterFile): VaultRosterFile;
90
114
  export declare function readVaultRoster(path: string): Promise<VaultRosterFile | undefined>;
91
115
  /** The ownership assertion available to a roster mutation callback. */
92
116
  export interface VaultRosterLockContext {
@@ -190,6 +214,16 @@ export declare function applyVaultQuota(current: VaultRosterFile | undefined, in
190
214
  kept: boolean;
191
215
  };
192
216
  export declare function forgetPendingVaultDiscovery(path: string): void;
217
+ /**
218
+ * Whether `error` from a roster commit at `path` means another writer had the
219
+ * roster at that moment, not that the commit itself failed: the discovery
220
+ * lease was busy before any roster existed, the write lock stayed busy, or a
221
+ * lock this commit held was lost. On Windows the same lock steps can reject
222
+ * with a PrivateFileError instead (a lock file that could not be read or
223
+ * replaced while another process held it), so a PrivateFileError naming one
224
+ * of this roster's lock files counts the same on every OS.
225
+ */
226
+ export declare function isVaultRosterLockRefusal(path: string, error: unknown): boolean;
193
227
  /**
194
228
  * Discover and commit the roster. The lease covers the list call and the
195
229
  * commit, not just the write: an opaque view cannot tell a delayed old reply
@@ -197,7 +231,8 @@ export declare function forgetPendingVaultDiscovery(path: string): void;
197
231
  * failed list, or custody switching off mid-run, never writes anything; a
198
232
  * peer holding the lease means its last committed roster is served instead.
199
233
  * A write-lock timeout keeps the discovered inventory for the next poll,
200
- * unless a peer has superseded its base view in the meantime.
234
+ * unless a peer has superseded its base view in the meantime. A list that
235
+ * would write the file the roster already holds takes no write lock at all.
201
236
  */
202
237
  export declare function refreshVaultRoster(options: {
203
238
  path: string;
@@ -206,6 +241,19 @@ export declare function refreshVaultRoster(options: {
206
241
  signal?: AbortSignal;
207
242
  projection?: ProjectionOptions | (() => ProjectionOptions);
208
243
  onInventory?: (inventory: VaultInventory) => void;
244
+ /**
245
+ * For a caller that listed before taking this path's discovery lease (the
246
+ * discovery hub lists once for several rosters): the view this roster file
247
+ * held before that list. `custody.discover` then returns that list. It is
248
+ * held to the rule a kept discovery is held to below: it is projected only
249
+ * while the file still holds this view or the list's own view. Otherwise
250
+ * another process committed since the list, and the file is returned
251
+ * unchanged. No discovery is kept for a later call, because such a caller
252
+ * lists again.
253
+ */
254
+ listedOver?: {
255
+ readonly view: string | undefined;
256
+ };
209
257
  }): Promise<VaultRosterFile | undefined>;
210
258
  /**
211
259
  * A host-owned main account as last verified from the vault: the plugin's
@@ -28,7 +28,7 @@ type RefreshFileLockOptions = {
28
28
  onContended?: () => void;
29
29
  /** Synchronous, never awaited; throws and returned promise/thenable rejections are isolated. */
30
30
  onRenewalTimer?: (event: 'scheduled' | 'cancelled') => void;
31
- onStep?: (step: 'stale-marker-stat' | 'stale-marker-claimed' | 'stale-lock-observed' | '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>;
31
+ 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>;
32
32
  };
33
33
  /** Filesystem leases share wall time across all callers and processes. */
34
34
  export declare function acquireRefreshFileLock(options: RefreshFileLockOptions): Promise<RefreshFileLock | null>;
@@ -8,8 +8,11 @@
8
8
  * - `host-credential-on-wire`: after every rewrite, a header still carried
9
9
  * one of the host's placeholder credentials. Sending it would leak a
10
10
  * non-routable value to the provider and fail with a confusing error.
11
+ * - `placement-refused`: an opt-in placeholder gate found the placeholder in
12
+ * multiple headers or outside the credential location it can serve. No
13
+ * account has been selected and no account headers have been read.
11
14
  */
12
- export type OpenCode2AuthFailureKind = 'no-account' | 'host-credential-on-wire';
15
+ export type OpenCode2AuthFailureKind = 'no-account' | 'host-credential-on-wire' | 'placement-refused';
13
16
  export declare class OpenCode2AuthError extends Error {
14
17
  readonly kind: OpenCode2AuthFailureKind;
15
18
  readonly providerID: string;
@@ -1,8 +1,8 @@
1
1
  export type { OpenCode2AuthFailureKind } from './errors.js';
2
2
  export { OpenCode2AuthError } from './errors.js';
3
- export { ATTEMPT_HEADER, applyHeaderEdits, DEFAULT_MAX_RECORDS, installOpenCode2Auth, } from './install.js';
3
+ export { ATTEMPT_HEADER, applyHeaderEdits, DEFAULT_MAX_RECORDS, installOpenCode2Auth, MAX_RETRY_HOLD_MS, } from './install.js';
4
4
  export type { FormAnswer, LoginContext, PoolAuthorization, PoolLoginMethod, RegisterOpenCode2AuthMethodsOptions, VaultActivationMethod, } from './integration.js';
5
5
  export { isPlaceholderCredential, PLACEHOLDER_LIFETIME_MS, PLACEHOLDER_METADATA_KEY, PLACEHOLDER_PREFIX, placeholderCredential, placeholderSecret, registerOpenCode2AuthMethods, VAULT_ACTIVATION_INSTRUCTIONS, } from './integration.js';
6
6
  export type { ServerSentEvent } from './sse.js';
7
7
  export { watchServerSentEvents } from './sse.js';
8
- export type { AccountHeadersResult, AccountRequest, Attempt, AttemptEndReason, AttemptOutcome, ChooseAccountInput, EventVerdict, HeaderEdits, HostError, InstallOpenCode2AuthOptions, LimitSignal, OpenCode2AuthAdapter, OpenCode2AuthEventName, OpenCode2AuthEvents, OpenCode2AuthInstallation, OpenCode2AuthLogger, OpenCode2HookContext, RequestKind, RequestScope, ResponseAccount, RetryReason, SelectingHook, Transport, } from './types.js';
8
+ export type { AccountHeadersResult, AccountRequest, Attempt, AttemptEndReason, AttemptOutcome, ChooseAccountInput, ChooseAccountResult, EventVerdict, HeaderEdits, HostError, InstallOpenCode2AuthOptions, LimitSignal, OpenCode2AuthAdapter, OpenCode2AuthEventName, OpenCode2AuthEvents, OpenCode2AuthInstallation, OpenCode2AuthLogger, OpenCode2HookContext, RequestKind, RequestScope, ResponseAccount, RetryHold, RetryReason, SelectingHook, Transport, } from './types.js';
@@ -1,5 +1,7 @@
1
- import type { HeaderEdits, InstallOpenCode2AuthOptions, OpenCode2AuthAdapter, OpenCode2AuthInstallation, OpenCode2HookContext } from './types.js';
1
+ import type { ChooseAccountResult, HeaderEdits, InstallOpenCode2AuthOptions, OpenCode2AuthAdapter, OpenCode2AuthInstallation, OpenCode2HookContext } from './types.js';
2
2
  export declare const DEFAULT_MAX_RECORDS = 512;
3
+ /** Bound adapter waits while allowing a 15-minute reset plus session jitter. */
4
+ export declare const MAX_RETRY_HOLD_MS: number;
3
5
  /**
4
6
  * The request header `model.request` sets to the attempt it started. The
5
7
  * host builds the HTTP request and the WebSocket handshake from the headers
@@ -49,8 +51,8 @@ export declare function applyHeaderEdits(target: Record<string, string>, edits:
49
51
  * compares the host-prepared secret exactly, then selects a fresh attempt only
50
52
  * for an owned send. Request-object attribution therefore needs no attempt
51
53
  * header. Frames are owned by the latest handshake of their session and kind;
52
- * retry runs only when the session's latest transport was owned. The host's
53
- * retry hook has no request identity, so concurrent mixed-ownership calls
54
- * cannot be distinguished there; owned retries retain the heuristic above.
54
+ * retry runs only when the session's latest transport was owned and the session
55
+ * has never mixed owned and foreign transports. The host's retry hook has no
56
+ * request identity, so a mixed session must keep the host's retry decision.
55
57
  */
56
- export declare function installOpenCode2Auth<Q, A = unknown>(ctx: OpenCode2HookContext, adapter: OpenCode2AuthAdapter<Q, A>, options?: InstallOpenCode2AuthOptions): Promise<OpenCode2AuthInstallation<Q, A>>;
58
+ export declare function installOpenCode2Auth<Q, A = unknown>(ctx: OpenCode2HookContext, adapter: OpenCode2AuthAdapter<Q, A, ChooseAccountResult>, options?: InstallOpenCode2AuthOptions): Promise<OpenCode2AuthInstallation<Q, A>>;
@@ -18,7 +18,7 @@ export interface RequestScope {
18
18
  /** Where a reading or a refusal was seen. */
19
19
  export type Transport = 'http' | 'ws';
20
20
  /**
21
- * A provider refusal that should move the request to another account: a rate
21
+ * A provider refusal that should wait or move the request to another account: a rate
22
22
  * limit, an exhausted usage window, or anything else the adapter decides is
23
23
  * tied to the account rather than to the request.
24
24
  */
@@ -53,7 +53,7 @@ export interface EventVerdict<Q> {
53
53
  */
54
54
  export type HeaderEdits = Readonly<Record<string, string | null>>;
55
55
  export interface ChooseAccountInput extends RequestScope {
56
- /** Informational: the retry hook's advance choice, or a request's own choice. */
56
+ /** The retry hook's advance choice (which may hold), or a request's own choice. */
57
57
  readonly phase: 'retry' | 'request';
58
58
  /**
59
59
  * The account of the attempt this one retries, when the retry hook just
@@ -64,8 +64,8 @@ export interface ChooseAccountInput extends RequestScope {
64
64
  /**
65
65
  * Set when the attempt this one retries was refused for a limit before any
66
66
  * output. The adapter should not pick `accountId` again unless it has
67
- * nothing else; returning it, or `undefined`, tells the retry hook that no
68
- * other account can serve, so the host's own retry decision stands.
67
+ * nothing else; returning it, or `undefined`, keeps the host's own retry
68
+ * decision. An explicit hold instead retains this account with its own wait.
69
69
  */
70
70
  readonly rerouteFrom?: {
71
71
  readonly accountId: string;
@@ -75,6 +75,19 @@ export interface ChooseAccountInput extends RequestScope {
75
75
  export interface AccountRequest extends RequestScope {
76
76
  readonly accountId: string;
77
77
  }
78
+ /** An explicit retry on the refused account, without moving its routing pin. */
79
+ export interface RetryHold {
80
+ readonly hold: {
81
+ /**
82
+ * Adapter-computed wait in milliseconds, including per-session jitter.
83
+ * Finite, non-negative values are clamped to MAX_RETRY_HOLD_MS (20 minutes).
84
+ * Invalid values keep the host's decision and release the choice.
85
+ */
86
+ readonly delayMs: number;
87
+ };
88
+ }
89
+ /** Holds are valid only in phase `retry`, with a recognised account limit. */
90
+ export type ChooseAccountResult = string | RetryHold | undefined;
78
91
  /**
79
92
  * One physical send: created when an account is chosen for a request, and
80
93
  * handed back on every hook call and event that belongs to that send, so a
@@ -164,8 +177,10 @@ export interface HostError {
164
177
  * Everything provider-specific the installer needs. `Q` is the plugin's own
165
178
  * quota reading type; the installer only carries it to the `quota` event.
166
179
  * `A` is the plugin's per-attempt value (see `Attempt`).
180
+ * `Choice` defaults to the legacy ID-only result so existing adapters' direct
181
+ * callers still see IDs. Opt into holds with `ChooseAccountResult`.
167
182
  */
168
- export interface OpenCode2AuthAdapter<Q = unknown, A = unknown> {
183
+ export interface OpenCode2AuthAdapter<Q = unknown, A = unknown, Choice extends ChooseAccountResult = string | undefined> {
169
184
  /** Every hook is scoped to this provider; other providers are untouched. */
170
185
  readonly providerID: string;
171
186
  /**
@@ -179,14 +194,19 @@ export interface OpenCode2AuthAdapter<Q = unknown, A = unknown> {
179
194
  * with `phase: 'retry'` and `rerouteFrom` set. Every returned account,
180
195
  * including the refused one, is kept for the next attempt of that session
181
196
  * and kind: it does not choose again. Another account retries at once;
182
- * the refused account keeps the host's decision and wait. `undefined` or a
197
+ * the refused account keeps the host's decision and wait. `{ hold: { delayMs } }`
198
+ * commits the refused account without changing its pin and replaces the host's
199
+ * wait, even its no-retry decision, only for a recognised account limit before
200
+ * output in an untainted session. Holds returned in phase `request` cannot
201
+ * select an account and are treated as undefined. `undefined` or a
183
202
  * throw commits nothing: the host decides, and the next attempt chooses
184
203
  * with `phase: 'request'`, `previousAccountId` and no `rerouteFrom`.
185
204
  */
186
- chooseAccount(input: ChooseAccountInput): Promise<string | undefined> | string | undefined;
205
+ chooseAccount(input: ChooseAccountInput): Promise<Choice> | Choice;
187
206
  /**
188
207
  * Releases a kept retry choice that will not be used: no retry, a changed
189
- * model or agent, session forgetting/deletion, disposal or record eviction.
208
+ * model or agent, cancellation of a queued retry (session idle), session forgetting/deletion,
209
+ * disposal or record eviction. A hold releases the refused account's choice.
190
210
  * Called once with the original choose input plus its returned accountId,
191
211
  * never for a used choice. Awaited before any later chooseAccount for the
192
212
  * same session; errors are logged and swallowed. A model/agent change
@@ -349,6 +369,13 @@ export interface InstallOpenCode2AuthOptions {
349
369
  */
350
370
  readonly gateOnPlaceholder?: {
351
371
  readonly credential: (headers: Headers) => string | undefined;
372
+ /**
373
+ * Refuse misplaced placeholders before selecting an account. The placeholder
374
+ * must occur in exactly one header and be the extracted secret. Receives a
375
+ * carrier header name for the refusal message. Also runs the handshake URL
376
+ * rewrite before applying account headers to the draft. Opt-in only.
377
+ */
378
+ readonly refuseMisplaced?: (header: string) => string;
352
379
  };
353
380
  /**
354
381
  * Values that must never reach the wire, normally the placeholder the host
@@ -372,9 +399,12 @@ export interface InstallOpenCode2AuthOptions {
372
399
  * no other account can serve the next attempt, so the host's own decision
373
400
  * (its wait, or its refusal to retry) stands and the next attempt may go
374
401
  * to the refused account again;
375
- * - `host-decides`: no limit was recognised, so the host's decision stands.
402
+ * - `hold`: an explicit adapter wait on the refused account, before output;
403
+ * - `host-decides`: no limit was recognised, or the failing call cannot be
404
+ * attributed safely (ambiguous attempts or mixed ownership in a gated
405
+ * session), so the host's decision stands.
376
406
  */
377
- export type RetryReason = 'reroute' | 'output-started' | 'no-account' | 'host-decides-last-account' | 'host-decides';
407
+ export type RetryReason = 'reroute' | 'hold' | 'output-started' | 'no-account' | 'host-decides-last-account' | 'host-decides';
378
408
  /**
379
409
  * The hook that picked an account. Normally `model.request`; a transport hook
380
410
  * picks only when the host skipped `model.request` for that request, which a
@@ -441,6 +471,8 @@ export interface OpenCode2AuthInstallation<Q, A = unknown> {
441
471
  /**
442
472
  * Drops every attempt and revokes in-flight auth selections of a session.
443
473
  * Session deletion does this itself. Later requests may reuse the session id.
474
+ * Foreign transport history survives until dispose: an old foreign call can
475
+ * still retry under that reused id, so forgetting cannot clear retry taint.
444
476
  */
445
477
  forgetSession(sessionID: string): void;
446
478
  /** Number of attempts held. */
@@ -0,0 +1,9 @@
1
+ export declare const QUOTA_COMMIT_INTERVAL_MS = 30000;
2
+ export interface QuotaCommitTimer {
3
+ now(): number;
4
+ schedule(delayMs: number, run: () => Promise<void>): {
5
+ cancel(): void;
6
+ unref?(): void;
7
+ };
8
+ }
9
+ export declare const quotaCommitTimer: QuotaCommitTimer;
@@ -0,0 +1,50 @@
1
+ import type { OpenCodeGeneration, SetupHost } from './types.js';
2
+ export declare const UNAVAILABLE_HOST_MESSAGE = "Requested setup host is unknown or unavailable. Use --host=opencode or --host=pi with a detected host.";
3
+ type SwitchKey = 'yes' | 'dryRun' | 'claustrum' | 'noClaustrum' | 'login' | 'enrollOnly';
4
+ /**
5
+ * One flag the shared setup parser accepts. A switch sets `key` to true; a
6
+ * value flag takes one of `values` as `--name=value`, and also as the next
7
+ * argument (`--name value`) when `spaceForm` is set. `invalid` replaces the
8
+ * unknown-argument refusal when a value flag gets a value it does not accept.
9
+ */
10
+ export type SetupFlag = {
11
+ name: string;
12
+ key: SwitchKey;
13
+ description: string;
14
+ } | {
15
+ name: string;
16
+ key: 'hosts' | 'opencode';
17
+ values: readonly string[];
18
+ spaceForm?: boolean;
19
+ invalid?: string;
20
+ description: string;
21
+ };
22
+ /**
23
+ * Every flag `runSetup` accepts. The parser and `setupUsage` both read this
24
+ * table, so the help a plugin prints cannot list a flag the parser refuses or
25
+ * leave out one it accepts.
26
+ */
27
+ export declare const SETUP_FLAGS: readonly SetupFlag[];
28
+ export interface SetupFlags {
29
+ yes: boolean;
30
+ dryRun: boolean;
31
+ claustrum: boolean;
32
+ noClaustrum: boolean;
33
+ login: boolean;
34
+ enrollOnly: boolean;
35
+ hosts: SetupHost[];
36
+ opencode: OpenCodeGeneration | undefined;
37
+ }
38
+ /** Parse setup's arguments against `SETUP_FLAGS`, refusing anything else. */
39
+ export declare function parseSetupFlags(argv: readonly string[]): SetupFlags;
40
+ /**
41
+ * The flags `runSetup` accepts, one per line, for a plugin's `setup --help`.
42
+ * The shared parser has no `--help` of its own: the plugin's bin checks for
43
+ * `--help` or `-h` before calling `runSetup`, prints this text and any lines of
44
+ * its own, and exits 0. With `command` the text starts with a usage line, such
45
+ * as `Usage: example-auth setup [flags]`.
46
+ */
47
+ export declare function setupUsage(options?: {
48
+ command?: string;
49
+ }): string;
50
+ export {};
@@ -2,6 +2,7 @@ export { AMBIGUOUS_OPENCODE_MESSAGE, runSetup } from './command.js';
2
2
  export { SetupCommandError, setupEnrollment } from './command-error.js';
3
3
  export { detectHosts, detectOpenCodeGeneration, findExecutableOnPath, openCodeDesktopMarkers, } from './detect.js';
4
4
  export { ENROLLMENT_WAIT_MS, HostNotEnrolledError, type HostNotEnrolledReason, UNSUPPORTED_VAULT_MESSAGE, } from './enroll.js';
5
+ export { setupUsage } from './flags.js';
5
6
  export { assertHostsStopped, createProcessFence, listSetupProcesses, ProcessFenceViolationError, ProcessInspectionError, type ProcessInspectionStep, } from './process-fence.js';
6
7
  export { type PlannedWrite, planOpenCodeRegistration, registerOpenCode, registerPi, updatePluginConfig, } from './register.js';
7
8
  export type { CommandResult, CommandRunner, HostDetection, OpenCodeGeneration, ProcessFence, SetupCallbackContext, SetupDetection, SetupEnrollmentOutcome, SetupEnvironment, SetupFileSystem, SetupHost, SetupHostEnrollment, SetupIO, SetupPlugin, SetupResult, } from './types.js';
@@ -3,6 +3,8 @@ export interface PlannedWrite {
3
3
  path: string;
4
4
  content: string;
5
5
  changed: boolean;
6
+ existingLocalEntries?: string[];
7
+ existingNpmEntries?: string[];
6
8
  }
7
9
  /** Edit only array entries so unrelated JSONC text, including comments, survives. */
8
10
  export declare function updatePluginConfig(text: string, key: 'plugin' | 'plugins', pkg: string, version: string): string;
@@ -61,7 +61,13 @@ export interface SetupPlugin {
61
61
  */
62
62
  beforeSignIn?(host: SetupHost, context: SetupCallbackContext): Promise<void>;
63
63
  signInLocal(host: SetupHost, context: SetupCallbackContext): Promise<void>;
64
- migrate(host: SetupHost, context: SetupCallbackContext): Promise<void>;
64
+ /**
65
+ * Moves the host's existing provider credentials into place after the host
66
+ * is registered. Optional: a plugin with nothing to migrate (one that only
67
+ * reads credentials from the vault) leaves it out, and setup then neither
68
+ * calls it nor mentions migration in its dry-run plan.
69
+ */
70
+ migrate?(host: SetupHost, context: SetupCallbackContext): Promise<void>;
65
71
  /** Reject mixed local/vault credentials and activate provider-specific vault access before registration. */
66
72
  beforeRegister?(host: SetupHost, mode: 'local' | 'claustrum', context: SetupCallbackContext): Promise<void>;
67
73
  }
@@ -52,6 +52,8 @@ export type ReadResult = ({
52
52
  kind?: 'snapshot-contended';
53
53
  retryable?: true;
54
54
  };
55
+ /** Settings need only the config classification, not a joined roster snapshot. */
56
+ export declare function readPoolConfig(path: string): Promise<import("./schema.js").ConfigClassification>;
55
57
  /**
56
58
  * Validate config/state/config bytes without locks. Roster replacement writes
57
59
  * config before deleting old state credentials. Re-read a changed config so an