@cortexkit/opencode-antigravity-auth 3.0.11 → 3.0.13

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 (253) hide show
  1. package/dist/cli.js +5120 -2863
  2. package/dist/cli.js.map +4 -4
  3. package/dist/cli.meta.json +581 -211
  4. package/dist/index.js +4806 -2343
  5. package/dist/index.js.map +4 -4
  6. package/dist/index.meta.json +618 -244
  7. package/dist/server.js +14300 -11649
  8. package/dist/server.js.map +4 -4
  9. package/dist/server.meta.json +1 -1
  10. package/dist/src/cli.d.ts +15 -0
  11. package/dist/src/cli.d.ts.map +1 -1
  12. package/dist/src/cli.js +27 -1
  13. package/dist/src/cli.js.map +1 -1
  14. package/dist/src/common-auth-embedded/claustrum/consumer.d.ts +83 -2
  15. package/dist/src/common-auth-embedded/claustrum/consumer.js +337 -37
  16. package/dist/src/common-auth-embedded/claustrum/custody.d.ts +36 -1
  17. package/dist/src/common-auth-embedded/claustrum/custody.js +95 -11
  18. package/dist/src/common-auth-embedded/claustrum/enrollment.js +37 -12
  19. package/dist/src/common-auth-embedded/claustrum/errors.d.ts +1 -1
  20. package/dist/src/common-auth-embedded/claustrum/hub.d.ts +195 -0
  21. package/dist/src/common-auth-embedded/claustrum/hub.js +988 -0
  22. package/dist/src/common-auth-embedded/claustrum/index.d.ts +13 -3
  23. package/dist/src/common-auth-embedded/claustrum/index.js +37 -4
  24. package/dist/src/common-auth-embedded/claustrum/quota-writer.d.ts +8 -1
  25. package/dist/src/common-auth-embedded/claustrum/quota-writer.js +38 -66
  26. package/dist/src/common-auth-embedded/claustrum/roster.d.ts +80 -1
  27. package/dist/src/common-auth-embedded/claustrum/roster.js +259 -12
  28. package/dist/src/common-auth-embedded/claustrum/shutdown.js +42 -0
  29. package/dist/src/common-auth-embedded/commands/builtins.d.ts +37 -0
  30. package/dist/src/common-auth-embedded/commands/builtins.js +95 -13
  31. package/dist/src/common-auth-embedded/commands/index.d.ts +1 -1
  32. package/dist/src/common-auth-embedded/fs/file-read-cache.js +57 -0
  33. package/dist/src/common-auth-embedded/fs/refresh-file-lock.d.ts +1 -1
  34. package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +20 -11
  35. package/dist/src/common-auth-embedded/opencode2/errors.d.ts +4 -1
  36. package/dist/src/common-auth-embedded/opencode2/index.d.ts +2 -2
  37. package/dist/src/common-auth-embedded/opencode2/index.js +1 -1
  38. package/dist/src/common-auth-embedded/opencode2/install.d.ts +10 -7
  39. package/dist/src/common-auth-embedded/opencode2/install.js +318 -71
  40. package/dist/src/common-auth-embedded/opencode2/types.d.ts +78 -9
  41. package/dist/src/common-auth-embedded/quota/commit-interval.d.ts +9 -0
  42. package/dist/src/common-auth-embedded/quota/commit-interval.js +18 -0
  43. package/dist/src/common-auth-embedded/quota/pending.js +48 -0
  44. package/dist/src/common-auth-embedded/rpc/rpc-server.js +29 -19
  45. package/dist/src/common-auth-embedded/setup/command.js +52 -14
  46. package/dist/src/common-auth-embedded/setup/enroll.d.ts +1 -1
  47. package/dist/src/common-auth-embedded/setup/enroll.js +1 -1
  48. package/dist/src/common-auth-embedded/setup/register.d.ts +2 -0
  49. package/dist/src/common-auth-embedded/setup/register.js +90 -11
  50. package/dist/src/common-auth-embedded/source-output.json +188 -124
  51. package/dist/src/common-auth-embedded/store/attribution.d.ts +5 -0
  52. package/dist/src/common-auth-embedded/store/attribution.js +39 -25
  53. package/dist/src/common-auth-embedded/store/mutate.d.ts +2 -0
  54. package/dist/src/common-auth-embedded/store/mutate.js +4 -0
  55. package/dist/src/common-auth-embedded/store/pool.d.ts +22 -0
  56. package/dist/src/common-auth-embedded/store/pool.js +18 -3
  57. package/dist/src/common-auth-embedded/store/pull.js +3 -1
  58. package/dist/src/common-auth-embedded/store/quota-writer.js +312 -0
  59. package/dist/src/common-auth-embedded/store/runtime.d.ts +2 -0
  60. package/dist/src/common-auth-embedded/store/settings.d.ts +1 -1
  61. package/dist/src/common-auth-embedded/store/settings.js +16 -6
  62. package/dist/src/ga/rpc/protocol.d.ts +2 -0
  63. package/dist/src/ga/rpc/protocol.d.ts.map +1 -1
  64. package/dist/src/ga/rpc/protocol.js +2 -2
  65. package/dist/src/ga/rpc/protocol.js.map +1 -1
  66. package/dist/src/ga/server/index.d.ts.map +1 -1
  67. package/dist/src/ga/server/index.js +11 -0
  68. package/dist/src/ga/server/index.js.map +1 -1
  69. package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
  70. package/dist/src/ga/tui/host-ga.js +2 -1
  71. package/dist/src/ga/tui/host-ga.js.map +1 -1
  72. package/dist/src/plugin/background-vault-quota-refresh.d.ts +10 -0
  73. package/dist/src/plugin/background-vault-quota-refresh.d.ts.map +1 -1
  74. package/dist/src/plugin/background-vault-quota-refresh.js +33 -5
  75. package/dist/src/plugin/background-vault-quota-refresh.js.map +1 -1
  76. package/dist/src/plugin/command-data.d.ts +2 -2
  77. package/dist/src/plugin/command-data.d.ts.map +1 -1
  78. package/dist/src/plugin/command-data.js +2 -0
  79. package/dist/src/plugin/command-data.js.map +1 -1
  80. package/dist/src/plugin/config/operator-settings-schema.d.ts +1 -1
  81. package/dist/src/plugin/config/schema.d.ts +1 -1
  82. package/dist/src/plugin/ga-location-services.d.ts +28 -2
  83. package/dist/src/plugin/ga-location-services.d.ts.map +1 -1
  84. package/dist/src/plugin/ga-location-services.js +80 -16
  85. package/dist/src/plugin/ga-location-services.js.map +1 -1
  86. package/dist/src/plugin/ga-shared-vault-custody.d.ts +64 -0
  87. package/dist/src/plugin/ga-shared-vault-custody.d.ts.map +1 -0
  88. package/dist/src/plugin/ga-shared-vault-custody.js +169 -0
  89. package/dist/src/plugin/ga-shared-vault-custody.js.map +1 -0
  90. package/dist/src/plugin/index.d.ts.map +1 -1
  91. package/dist/src/plugin/index.js +11 -1
  92. package/dist/src/plugin/index.js.map +1 -1
  93. package/dist/src/plugin/killswitch.d.ts.map +1 -1
  94. package/dist/src/plugin/killswitch.js +13 -7
  95. package/dist/src/plugin/killswitch.js.map +1 -1
  96. package/dist/src/plugin/oauth-methods.d.ts.map +1 -1
  97. package/dist/src/plugin/oauth-methods.js +3 -0
  98. package/dist/src/plugin/oauth-methods.js.map +1 -1
  99. package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
  100. package/dist/src/plugin/shared/request-services.js +3 -3
  101. package/dist/src/plugin/shared/request-services.js.map +1 -1
  102. package/dist/src/plugin/shared/vault-request-credentials.d.ts +8 -1
  103. package/dist/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
  104. package/dist/src/plugin/shared/vault-request-credentials.js +38 -5
  105. package/dist/src/plugin/shared/vault-request-credentials.js.map +1 -1
  106. package/dist/src/plugin/ui/auth-menu.d.ts.map +1 -1
  107. package/dist/src/plugin/ui/auth-menu.js +3 -0
  108. package/dist/src/plugin/ui/auth-menu.js.map +1 -1
  109. package/dist/src/plugin/ui/quota-status.d.ts.map +1 -1
  110. package/dist/src/plugin/ui/quota-status.js +4 -2
  111. package/dist/src/plugin/ui/quota-status.js.map +1 -1
  112. package/dist/src/plugin/vault-custody.d.ts +28 -7
  113. package/dist/src/plugin/vault-custody.d.ts.map +1 -1
  114. package/dist/src/plugin/vault-custody.js +200 -37
  115. package/dist/src/plugin/vault-custody.js.map +1 -1
  116. package/dist/src/plugin/vault-insula-quota.d.ts.map +1 -1
  117. package/dist/src/plugin/vault-insula-quota.js +4 -0
  118. package/dist/src/plugin/vault-insula-quota.js.map +1 -1
  119. package/dist/src/plugin/vault-sidebar-projection.d.ts.map +1 -1
  120. package/dist/src/process-heartbeat.d.ts +76 -0
  121. package/dist/src/process-heartbeat.d.ts.map +1 -0
  122. package/dist/src/process-heartbeat.js +248 -0
  123. package/dist/src/process-heartbeat.js.map +1 -0
  124. package/dist/src/setup.d.ts.map +1 -1
  125. package/dist/src/setup.js +3 -0
  126. package/dist/src/setup.js.map +1 -1
  127. package/dist/src/sidebar-projection.d.ts +3 -1
  128. package/dist/src/sidebar-projection.d.ts.map +1 -1
  129. package/dist/src/sidebar-projection.js +10 -1
  130. package/dist/src/sidebar-projection.js.map +1 -1
  131. package/dist/src/sidebar-state.d.ts +10 -1
  132. package/dist/src/sidebar-state.d.ts.map +1 -1
  133. package/dist/src/sidebar-state.js +12 -2
  134. package/dist/src/sidebar-state.js.map +1 -1
  135. package/dist/src/tui/quota-layout.d.ts +3 -1
  136. package/dist/src/tui/quota-layout.d.ts.map +1 -1
  137. package/dist/src/tui/quota-layout.js +6 -1
  138. package/dist/src/tui/quota-layout.js.map +1 -1
  139. package/dist/tui-build-map.json +9 -9
  140. package/dist/tui-ga-build-map.json +13 -13
  141. package/dist/types/src/cli.d.ts +15 -0
  142. package/dist/types/src/cli.d.ts.map +1 -1
  143. package/dist/types/src/common-auth-embedded/claustrum/consumer.d.ts +83 -2
  144. package/dist/types/src/common-auth-embedded/claustrum/custody.d.ts +36 -1
  145. package/dist/types/src/common-auth-embedded/claustrum/errors.d.ts +1 -1
  146. package/dist/types/src/common-auth-embedded/claustrum/hub.d.ts +195 -0
  147. package/dist/types/src/common-auth-embedded/claustrum/index.d.ts +13 -3
  148. package/dist/types/src/common-auth-embedded/claustrum/quota-writer.d.ts +8 -1
  149. package/dist/types/src/common-auth-embedded/claustrum/roster.d.ts +80 -1
  150. package/dist/types/src/common-auth-embedded/commands/builtins.d.ts +37 -0
  151. package/dist/types/src/common-auth-embedded/commands/index.d.ts +1 -1
  152. package/dist/types/src/common-auth-embedded/fs/refresh-file-lock.d.ts +1 -1
  153. package/dist/types/src/common-auth-embedded/opencode2/errors.d.ts +4 -1
  154. package/dist/types/src/common-auth-embedded/opencode2/index.d.ts +2 -2
  155. package/dist/types/src/common-auth-embedded/opencode2/install.d.ts +10 -7
  156. package/dist/types/src/common-auth-embedded/opencode2/types.d.ts +78 -9
  157. package/dist/types/src/common-auth-embedded/quota/commit-interval.d.ts +9 -0
  158. package/dist/types/src/common-auth-embedded/setup/enroll.d.ts +1 -1
  159. package/dist/types/src/common-auth-embedded/setup/register.d.ts +2 -0
  160. package/dist/types/src/common-auth-embedded/store/attribution.d.ts +5 -0
  161. package/dist/types/src/common-auth-embedded/store/mutate.d.ts +2 -0
  162. package/dist/types/src/common-auth-embedded/store/pool.d.ts +22 -0
  163. package/dist/types/src/common-auth-embedded/store/runtime.d.ts +2 -0
  164. package/dist/types/src/common-auth-embedded/store/settings.d.ts +1 -1
  165. package/dist/types/src/ga/rpc/protocol.d.ts +2 -0
  166. package/dist/types/src/ga/rpc/protocol.d.ts.map +1 -1
  167. package/dist/types/src/ga/server/index.d.ts.map +1 -1
  168. package/dist/types/src/plugin/background-vault-quota-refresh.d.ts +10 -0
  169. package/dist/types/src/plugin/background-vault-quota-refresh.d.ts.map +1 -1
  170. package/dist/types/src/plugin/command-data.d.ts +2 -2
  171. package/dist/types/src/plugin/command-data.d.ts.map +1 -1
  172. package/dist/types/src/plugin/ga-location-services.d.ts +28 -2
  173. package/dist/types/src/plugin/ga-location-services.d.ts.map +1 -1
  174. package/dist/types/src/plugin/ga-shared-vault-custody.d.ts +64 -0
  175. package/dist/types/src/plugin/ga-shared-vault-custody.d.ts.map +1 -0
  176. package/dist/types/src/plugin/index.d.ts.map +1 -1
  177. package/dist/types/src/plugin/killswitch.d.ts.map +1 -1
  178. package/dist/types/src/plugin/oauth-methods.d.ts.map +1 -1
  179. package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -1
  180. package/dist/types/src/plugin/shared/vault-request-credentials.d.ts +8 -1
  181. package/dist/types/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
  182. package/dist/types/src/plugin/ui/auth-menu.d.ts.map +1 -1
  183. package/dist/types/src/plugin/ui/quota-status.d.ts.map +1 -1
  184. package/dist/types/src/plugin/vault-custody.d.ts +28 -7
  185. package/dist/types/src/plugin/vault-custody.d.ts.map +1 -1
  186. package/dist/types/src/plugin/vault-insula-quota.d.ts.map +1 -1
  187. package/dist/types/src/plugin/vault-sidebar-projection.d.ts.map +1 -1
  188. package/dist/types/src/process-heartbeat.d.ts +76 -0
  189. package/dist/types/src/process-heartbeat.d.ts.map +1 -0
  190. package/dist/types/src/setup.d.ts.map +1 -1
  191. package/dist/types/src/sidebar-state.d.ts +10 -1
  192. package/dist/types/src/sidebar-state.d.ts.map +1 -1
  193. package/package.json +2 -2
  194. package/src/common-auth-embedded/claustrum/consumer.d.ts +83 -2
  195. package/src/common-auth-embedded/claustrum/consumer.js +337 -37
  196. package/src/common-auth-embedded/claustrum/custody.d.ts +36 -1
  197. package/src/common-auth-embedded/claustrum/custody.js +95 -11
  198. package/src/common-auth-embedded/claustrum/enrollment.js +37 -12
  199. package/src/common-auth-embedded/claustrum/errors.d.ts +1 -1
  200. package/src/common-auth-embedded/claustrum/hub.d.ts +195 -0
  201. package/src/common-auth-embedded/claustrum/hub.js +988 -0
  202. package/src/common-auth-embedded/claustrum/index.d.ts +13 -3
  203. package/src/common-auth-embedded/claustrum/index.js +37 -4
  204. package/src/common-auth-embedded/claustrum/quota-writer.d.ts +8 -1
  205. package/src/common-auth-embedded/claustrum/quota-writer.js +38 -66
  206. package/src/common-auth-embedded/claustrum/roster.d.ts +80 -1
  207. package/src/common-auth-embedded/claustrum/roster.js +259 -12
  208. package/src/common-auth-embedded/claustrum/shutdown.js +42 -0
  209. package/src/common-auth-embedded/commands/builtins.d.ts +37 -0
  210. package/src/common-auth-embedded/commands/builtins.js +95 -13
  211. package/src/common-auth-embedded/commands/index.d.ts +1 -1
  212. package/src/common-auth-embedded/fs/file-read-cache.js +57 -0
  213. package/src/common-auth-embedded/fs/refresh-file-lock.d.ts +1 -1
  214. package/src/common-auth-embedded/fs/refresh-file-lock.js +20 -11
  215. package/src/common-auth-embedded/opencode2/errors.d.ts +4 -1
  216. package/src/common-auth-embedded/opencode2/index.d.ts +2 -2
  217. package/src/common-auth-embedded/opencode2/index.js +1 -1
  218. package/src/common-auth-embedded/opencode2/install.d.ts +10 -7
  219. package/src/common-auth-embedded/opencode2/install.js +318 -71
  220. package/src/common-auth-embedded/opencode2/types.d.ts +78 -9
  221. package/src/common-auth-embedded/quota/commit-interval.d.ts +9 -0
  222. package/src/common-auth-embedded/quota/commit-interval.js +18 -0
  223. package/src/common-auth-embedded/quota/pending.js +48 -0
  224. package/src/common-auth-embedded/rpc/rpc-server.js +29 -19
  225. package/src/common-auth-embedded/setup/command.js +52 -14
  226. package/src/common-auth-embedded/setup/enroll.d.ts +1 -1
  227. package/src/common-auth-embedded/setup/enroll.js +1 -1
  228. package/src/common-auth-embedded/setup/register.d.ts +2 -0
  229. package/src/common-auth-embedded/setup/register.js +90 -11
  230. package/src/common-auth-embedded/source-output.json +188 -124
  231. package/src/common-auth-embedded/store/attribution.d.ts +5 -0
  232. package/src/common-auth-embedded/store/attribution.js +39 -25
  233. package/src/common-auth-embedded/store/mutate.d.ts +2 -0
  234. package/src/common-auth-embedded/store/mutate.js +4 -0
  235. package/src/common-auth-embedded/store/pool.d.ts +22 -0
  236. package/src/common-auth-embedded/store/pool.js +18 -3
  237. package/src/common-auth-embedded/store/pull.js +3 -1
  238. package/src/common-auth-embedded/store/quota-writer.js +312 -0
  239. package/src/common-auth-embedded/store/runtime.d.ts +2 -0
  240. package/src/common-auth-embedded/store/settings.d.ts +1 -1
  241. package/src/common-auth-embedded/store/settings.js +16 -6
  242. package/src/plugin/command-data.ts +4 -2
  243. package/src/sidebar-state.ts +23 -3
  244. package/src/tui-compiled/sidebar-state.js +4 -3
  245. package/src/tui-compiled/tui/quota-layout.js +3 -2
  246. package/src/tui-ga-compiled/host-ga.js +2 -1
  247. package/src/tui-ga-compiled/shared/8ae1927e5910ea81-sidebar-projection.js +9 -2
  248. package/src/tui-ga-compiled/shared/dd4c9e1a907f8ef0-quota-layout.js +3 -2
  249. package/src/tui-ga-raw/host-ga.tsx +12 -1
  250. package/src/tui-ga-raw/shared/8ae1927e5910ea81-sidebar-projection.js +9 -2
  251. package/src/tui-ga-raw/shared/dd4c9e1a907f8ef0-quota-layout.tsx +9 -2
  252. package/src/tui-raw/sidebar-state.js +4 -3
  253. package/src/tui-raw/tui/quota-layout.tsx +9 -2
@@ -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, readVaultRoster, recordVaultAccountQuota, recordVaultQuota, refreshVaultRoster, 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;
65
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
+ }[];
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 {
@@ -119,6 +143,37 @@ export declare function mutateVaultRoster<T>(path: string, change: (current: Vau
119
143
  export declare function declineVaultRoute(path: string, routeId: string): Promise<undefined>;
120
144
  /** Lift the user's decline for a vault account and every alias of it. */
121
145
  export declare function acceptVaultRoute(path: string, routeId: string): Promise<undefined>;
146
+ /** Options of `reorderVaultRoster`. */
147
+ export interface ReorderVaultRosterOptions {
148
+ /** Aborts the wait for the roster's write lock. */
149
+ signal?: AbortSignal;
150
+ }
151
+ export interface ReorderVaultRosterResult {
152
+ /** The route id order now on disk. */
153
+ ids: string[];
154
+ /** `unchanged` when the roster was already in this order; nothing was written. */
155
+ outcome: 'reordered' | 'unchanged';
156
+ }
157
+ /**
158
+ * Set the order vault accounts are tried in. Routing reads that order from
159
+ * the roster's row order (`vaultRoutingRows`), and a later discovery keeps
160
+ * each account at its position, so the order lasts until the next reorder.
161
+ * The order is this host's routing preference: the vault has no order of its
162
+ * own, and this never contacts it.
163
+ *
164
+ * `routeIds` must name every roster route id exactly once; anything else
165
+ * (an unknown, missing or repeated id) refuses with `invalid-order` and
166
+ * writes nothing. It runs under the roster's write lock, like every other
167
+ * roster write, so a quota reading or decline committed meanwhile is kept.
168
+ * Each row is kept as the same object, so only the positions change: every
169
+ * row's fields and the rest of the file stay as they were. An order equal to
170
+ * the current one writes nothing. A host with no roster file yet has no
171
+ * routes, so only the empty order is accepted.
172
+ *
173
+ * A `ClaustrumConsumer` in the same process does not see the new order until
174
+ * it re-reads the file: call `consumer.reorder` instead to update both.
175
+ */
176
+ export declare function reorderVaultRoster(path: string, routeIds: readonly string[], options?: ReorderVaultRosterOptions): Promise<ReorderVaultRosterResult>;
122
177
  /**
123
178
  * The receipt fields a quota or profile observation must carry to say which
124
179
  * send (credential and account) it came from. Pass the
@@ -159,6 +214,16 @@ export declare function applyVaultQuota(current: VaultRosterFile | undefined, in
159
214
  kept: boolean;
160
215
  };
161
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;
162
227
  /**
163
228
  * Discover and commit the roster. The lease covers the list call and the
164
229
  * commit, not just the write: an opaque view cannot tell a delayed old reply
@@ -166,7 +231,8 @@ export declare function forgetPendingVaultDiscovery(path: string): void;
166
231
  * failed list, or custody switching off mid-run, never writes anything; a
167
232
  * peer holding the lease means its last committed roster is served instead.
168
233
  * A write-lock timeout keeps the discovered inventory for the next poll,
169
- * 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.
170
236
  */
171
237
  export declare function refreshVaultRoster(options: {
172
238
  path: string;
@@ -175,6 +241,19 @@ export declare function refreshVaultRoster(options: {
175
241
  signal?: AbortSignal;
176
242
  projection?: ProjectionOptions | (() => ProjectionOptions);
177
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
+ };
178
257
  }): Promise<VaultRosterFile | undefined>;
179
258
  /**
180
259
  * A host-owned main account as last verified from the vault: the plugin's
@@ -48,6 +48,43 @@ export interface RoutingSectionOptions {
48
48
  */
49
49
  orderedVariants?: MenuChoice[];
50
50
  formerMainId?: string;
51
+ /**
52
+ * The vault accounts' routing order, for a plugin that can run in vault
53
+ * mode. Called on each build; return the order while the plugin routes
54
+ * through vault accounts and undefined otherwise. While it returns one, the
55
+ * section shows and sets the vault accounts' order (by the name the menu
56
+ * shows for each account) instead of the pool roster's. Wire it to
57
+ * `ClaustrumConsumer.snapshot()` and `ClaustrumConsumer.reorder`, or to
58
+ * `readVaultRoster` and `reorderVaultRoster` for a plugin without a
59
+ * consumer.
60
+ */
61
+ vaultOrder?: () => VaultRoutingOrder | undefined | Promise<VaultRoutingOrder | undefined>;
62
+ }
63
+ /**
64
+ * The order vault accounts are tried in, as the Routing section reads and
65
+ * sets it in vault mode. Shaped after `/claustrum`'s roster, without
66
+ * importing it, so the menu does not need the vault client.
67
+ */
68
+ export interface VaultRoutingOrder {
69
+ /**
70
+ * Every vault roster row, in roster (routing) order: its route id and the
71
+ * name the plugin shows for that account (the roster row's `label`, or its
72
+ * email). Route ids are long and opaque, so the section shows and accepts
73
+ * labels; a route id is still accepted wherever a label is.
74
+ */
75
+ rows: readonly {
76
+ id: string;
77
+ label: string;
78
+ }[];
79
+ /**
80
+ * Sets the order. `ids` are route ids, every one exactly once. Wire it to
81
+ * `ClaustrumConsumer.reorder` or `reorderVaultRoster`, which refuse any
82
+ * other list without writing.
83
+ */
84
+ reorder(ids: readonly string[]): Promise<{
85
+ ids: readonly string[];
86
+ outcome: 'reordered' | 'unchanged';
87
+ }>;
51
88
  }
52
89
  export interface LimitsSectionOptions {
53
90
  /**
@@ -1,4 +1,4 @@
1
- export type { AccountsSectionOptions, LimitsSectionOptions, LoginOutcome, QuotaSectionOptions, RoutingSectionOptions, } from './builtins.js';
1
+ export type { AccountsSectionOptions, LimitsSectionOptions, LoginOutcome, QuotaSectionOptions, RoutingSectionOptions, VaultRoutingOrder, } from './builtins.js';
2
2
  export { MENU_DISABLED_REASON } from './builtins.js';
3
3
  export type { CommandMenu, CommandMenuOptions, StoreSectionSlot, } from './menu.js';
4
4
  export { createCommandMenu, parseApplyRequest } from './menu.js';
@@ -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
@@ -26,8 +28,9 @@ export declare function applyHeaderEdits(target: Record<string, string>, edits:
26
28
  * whether output has started and when the response ended, attributed to
27
29
  * an attempt by the rules below;
28
30
  * - `retry` asks the host to retry at once when an account was refused
29
- * before any output, so `model.request` runs again and can pick another
30
- * account, and refuses to retry once output has started.
31
+ * before any output and `chooseAccount` names another account for the
32
+ * next attempt, keeps the host's decision when the refused account was the
33
+ * last one that can serve, and refuses to retry once output has started.
31
34
  *
32
35
  * Attribution. A send belongs to the attempt named by the mark
33
36
  * `model.request` left on it, so several attempts of one session and kind
@@ -48,8 +51,8 @@ export declare function applyHeaderEdits(target: Record<string, string>, edits:
48
51
  * compares the host-prepared secret exactly, then selects a fresh attempt only
49
52
  * for an owned send. Request-object attribution therefore needs no attempt
50
53
  * header. Frames are owned by the latest handshake of their session and kind;
51
- * retry runs only when the session's latest transport was owned. The host's
52
- * retry hook has no request identity, so concurrent mixed-ownership calls
53
- * 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.
54
57
  */
55
- 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,6 +53,8 @@ export interface EventVerdict<Q> {
53
53
  */
54
54
  export type HeaderEdits = Readonly<Record<string, string | null>>;
55
55
  export interface ChooseAccountInput extends RequestScope {
56
+ /** The retry hook's advance choice (which may hold), or a request's own choice. */
57
+ readonly phase: 'retry' | 'request';
56
58
  /**
57
59
  * The account of the attempt this one retries, when the retry hook just
58
60
  * asked the host to retry an attempt of this session and kind; otherwise
@@ -61,8 +63,9 @@ export interface ChooseAccountInput extends RequestScope {
61
63
  readonly previousAccountId?: string;
62
64
  /**
63
65
  * Set when the attempt this one retries was refused for a limit before any
64
- * output and the retry hook asked the host to try again. The adapter
65
- * should not pick `accountId` again unless it has nothing else.
66
+ * output. The adapter should not pick `accountId` again unless it has
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.
66
69
  */
67
70
  readonly rerouteFrom?: {
68
71
  readonly accountId: string;
@@ -72,6 +75,19 @@ export interface ChooseAccountInput extends RequestScope {
72
75
  export interface AccountRequest extends RequestScope {
73
76
  readonly accountId: string;
74
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;
75
91
  /**
76
92
  * One physical send: created when an account is chosen for a request, and
77
93
  * handed back on every hook call and event that belongs to that send, so a
@@ -161,16 +177,44 @@ export interface HostError {
161
177
  * Everything provider-specific the installer needs. `Q` is the plugin's own
162
178
  * quota reading type; the installer only carries it to the `quota` event.
163
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`.
164
182
  */
165
- export interface OpenCode2AuthAdapter<Q = unknown, A = unknown> {
183
+ export interface OpenCode2AuthAdapter<Q = unknown, A = unknown, Choice extends ChooseAccountResult = string | undefined> {
166
184
  /** Every hook is scoped to this provider; other providers are untouched. */
167
185
  readonly providerID: string;
168
186
  /**
169
- * Picks the account for one model request. Called again for every retry,
170
- * so a refused account can be skipped. Returning `undefined` stops the
171
- * request with `OpenCode2AuthError` kind `no-account`.
187
+ * Commits an account for one attempt. An undefined answer commits nothing
188
+ * to routing state: no consumed retry entry, no queued choice, and no session
189
+ * pin created, moved or deleted. Idempotent maintenance (credential refresh
190
+ * to check usability and recording quota readings) is allowed. On a request,
191
+ * undefined stops with kind `no-account`.
192
+ *
193
+ * After a limit before any output, the retry hook makes this call itself,
194
+ * with `phase: 'retry'` and `rerouteFrom` set. Every returned account,
195
+ * including the refused one, is kept for the next attempt of that session
196
+ * and kind: it does not choose again. Another account retries at once;
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
202
+ * throw commits nothing: the host decides, and the next attempt chooses
203
+ * with `phase: 'request'`, `previousAccountId` and no `rerouteFrom`.
172
204
  */
173
- chooseAccount(input: ChooseAccountInput): Promise<string | undefined> | string | undefined;
205
+ chooseAccount(input: ChooseAccountInput): Promise<Choice> | Choice;
206
+ /**
207
+ * Releases a kept retry choice that will not be used: no retry, a changed
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.
210
+ * Called once with the original choose input plus its returned accountId,
211
+ * never for a used choice. Awaited before any later chooseAccount for the
212
+ * same session; errors are logged and swallowed. A model/agent change
213
+ * releases the old choice before choosing afresh.
214
+ */
215
+ dropChoice?(input: ChooseAccountInput & {
216
+ readonly accountId: string;
217
+ }): Promise<void> | void;
174
218
  /**
175
219
  * The credential and per-account headers for an account, applied in
176
220
  * `model.request`, `http.request` and `experimental.ws.handshake`. The last
@@ -325,6 +369,13 @@ export interface InstallOpenCode2AuthOptions {
325
369
  */
326
370
  readonly gateOnPlaceholder?: {
327
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;
328
379
  };
329
380
  /**
330
381
  * Values that must never reach the wire, normally the placeholder the host
@@ -337,7 +388,23 @@ export interface InstallOpenCode2AuthOptions {
337
388
  readonly maxRecords?: number;
338
389
  readonly logger?: OpenCode2AuthLogger;
339
390
  }
340
- export type RetryReason = 'reroute' | 'output-started' | 'no-account' | 'host-decides';
391
+ /**
392
+ * Why the retry hook decided as it did:
393
+ *
394
+ * - `reroute`: refused for a limit before any output, and `chooseAccount`
395
+ * named another account for the next attempt, so the host retries at once;
396
+ * - `output-started`: output had reached the user, so no retry;
397
+ * - `no-account`: the attempt had no account, so no retry;
398
+ * - `host-decides-last-account`: refused for a limit before any output, but
399
+ * no other account can serve the next attempt, so the host's own decision
400
+ * (its wait, or its refusal to retry) stands and the next attempt may go
401
+ * to the refused account again;
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.
406
+ */
407
+ export type RetryReason = 'reroute' | 'hold' | 'output-started' | 'no-account' | 'host-decides-last-account' | 'host-decides';
341
408
  /**
342
409
  * The hook that picked an account. Normally `model.request`; a transport hook
343
410
  * picks only when the host skipped `model.request` for that request, which a
@@ -404,6 +471,8 @@ export interface OpenCode2AuthInstallation<Q, A = unknown> {
404
471
  /**
405
472
  * Drops every attempt and revokes in-flight auth selections of a session.
406
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.
407
476
  */
408
477
  forgetSession(sessionID: string): void;
409
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;
@@ -1,7 +1,7 @@
1
1
  import { type MenuTerminal } from '../auth-menu/terminal.js';
2
2
  import type { SetupHost, SetupIO, SetupPlugin } from './types.js';
3
3
  /** Fixed text: no version, host or account detail, so it is safe to print anywhere. */
4
- export declare const UNSUPPORTED_VAULT_MESSAGE = "This Claustrum vault does not support connecting plugins yet, so setup cannot connect to it. Run setup without --claustrum to use local accounts.";
4
+ export declare const UNSUPPORTED_VAULT_MESSAGE = "This Claustrum vault is too old to connect plugins. Run ck upgrade to move to Claustrum v0.2.0 or newer (read \"Upgrading from v0.1.3\" in its release notes first), or run setup without --claustrum to use local accounts.";
5
5
  /**
6
6
  * The longest setup waits, in total, for the vault to create the enrollment
7
7
  * request and for an operator to approve it. It matches the wait setup always
@@ -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;
@@ -1,4 +1,6 @@
1
+ import { type StoreContext } from './mutate.js';
1
2
  import { type StoreRuntime } from './runtime.js';
3
+ import { type PoolRow } from './schema.js';
2
4
  /**
3
5
  * What a pull or refresh captured about its row (named by id alongside) when
4
6
  * it was issued. A result applies only while the row with that id still has
@@ -20,6 +22,9 @@ export interface Attribution {
20
22
  credentialEpoch: number;
21
23
  identity?: string;
22
24
  }
25
+ export declare function assertQuotaEpoch(id: string, attribution: Attribution): void;
26
+ export declare function assertQuotaRow(id: string, attribution: Attribution, row: PoolRow | undefined): asserts row is PoolRow;
27
+ export declare function mergedQuota(ctx: StoreContext, id: string, stored: unknown, observation: unknown): unknown;
23
28
  /**
24
29
  * Merges a quota observation into a row's stored map under the store locks,
25
30
  * after attribution passes. Needs no row lock, so it is permitted from
@@ -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
@@ -1,3 +1,4 @@
1
+ import type { QuotaCommitTimer } from '../quota/commit-interval.js';
1
2
  import { type Attribution } from './attribution.js';
2
3
  import type { PoolOperationError } from './errors.js';
3
4
  import type { PoolLogger } from './hooks.js';
@@ -16,6 +17,23 @@ export interface OpenPoolStoreOptions {
16
17
  configPath: string;
17
18
  statePath: string;
18
19
  quota: QuotaCodec;
20
+ /**
21
+ * Opt in to detached, coalesced quota publication, with any `quota` codec.
22
+ * Each accepted observation is queued whole for its row and binding, and
23
+ * the queue is applied in arrival order through `quota.merge` under the
24
+ * store locks, so the codec's own merge decides which fields a newer or
25
+ * older reading replaces. Accepted readings appear in read/load
26
+ * immediately, merged the same way; the returned promise still rejects
27
+ * current-row refusals before queueing. Await dispose or close at shutdown
28
+ * to attempt a bounded drain; readings still pending at its timeout are
29
+ * discarded. Normal quota commits are at least 30 seconds apart; a full
30
+ * queue commits early so response handling never waits for that interval.
31
+ */
32
+ coalesceQuota?: boolean;
33
+ /** Bounded quota drain on close/dispose, in milliseconds; defaults to 1,000. */
34
+ quotaDrainTimeoutMs?: number;
35
+ /** Monotonic clock and scheduling seam for detached quota commits. */
36
+ quotaCommitTimer?: QuotaCommitTimer;
19
37
  /**
20
38
  * The codec of the provider state kept beside each row's credential (see
21
39
  * `ProviderStateCodec`). Without it no row shows a provider state, and
@@ -189,6 +207,10 @@ export interface PoolStore {
189
207
  }>;
190
208
  refresh(id: string, provider: ProviderRefresh, options?: RefreshOptions): Promise<RefreshOutcome>;
191
209
  recordQuota(id: string, attribution: Attribution, observation: unknown): Promise<void>;
210
+ /** Drain opted-in quota publication; subsequent coalesced readings refuse. Idempotent. */
211
+ close(): Promise<void>;
212
+ /** Same bounded quota drain as close(). Does not wait for provider pull hooks. */
213
+ dispose(): Promise<void>;
192
214
  /** Fires a pull for a row admission refused for want of a reading. */
193
215
  requestReading(id: string): void;
194
216
  /** Resolves once every pull fired so far has settled. */
@@ -1,3 +1,4 @@
1
+ import type { Attribution } from './attribution.js';
1
2
  import { type PoolOperation, PoolOperationError } from './errors.js';
2
3
  import { type ReadResult, type StoreContext } from './mutate.js';
3
4
  import type { PoolLockOptions, PoolLockSpec } from './refresh-lock.js';
@@ -10,6 +11,7 @@ export interface StoreRuntime {
10
11
  providerLock: PoolLockSpec;
11
12
  rowLockOptions: Partial<PoolLockOptions>;
12
13
  firePull(id: string, reason: PullReason): void;
14
+ publishQuota?: (id: string, attribution: Attribution, observation: unknown) => Promise<void>;
13
15
  }
14
16
  /**
15
17
  * The row lock's (name, path): keyed by the row's recorded wire identity when
@@ -50,7 +50,7 @@ export type UpdateSettingsResult = {
50
50
  /** `unchanged` when the mutator left the settings as they were; nothing was written. */
51
51
  outcome: 'updated' | 'unchanged';
52
52
  };
53
- /** Reads the settings without taking a lock or writing anything. */
53
+ /** Reads only the config's settings, without taking a lock or writing anything. */
54
54
  export declare function readPoolSettings(rt: StoreRuntime): Promise<SettingsRead>;
55
55
  /**
56
56
  * One locked read-modify-write of the plugin's settings in the config file
@@ -190,6 +190,8 @@ export interface AntigravityAccountDto {
190
190
  readonly quota: {
191
191
  readonly gemini?: AntigravityQuotaEntryDto;
192
192
  readonly 'non-gemini'?: AntigravityQuotaEntryDto;
193
+ /** Present only on accounts whose reading reports the Argon pool. */
194
+ readonly 'gemini-argon'?: AntigravityQuotaEntryDto;
193
195
  };
194
196
  readonly tier?: {
195
197
  readonly id: string;