@cortexkit/opencode-antigravity-auth 2.2.0 → 3.0.0

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 (957) hide show
  1. package/README.md +95 -89
  2. package/dist/cli.js +18469 -810
  3. package/dist/cli.js.map +4 -4
  4. package/dist/cli.meta.json +4079 -0
  5. package/dist/index.js +40923 -16450
  6. package/dist/index.js.map +4 -4
  7. package/dist/index.meta.json +6949 -0
  8. package/dist/server.js +50948 -0
  9. package/dist/server.js.map +7 -0
  10. package/dist/server.meta.json +7284 -0
  11. package/dist/src/cli.d.ts +46 -1
  12. package/dist/src/cli.d.ts.map +1 -1
  13. package/dist/src/cli.js +207 -2
  14. package/dist/src/cli.js.map +1 -1
  15. package/dist/src/common-auth-embedded/NOTICE.txt +21 -0
  16. package/dist/src/common-auth-embedded/auth-menu/accounts.d.ts +97 -0
  17. package/dist/src/common-auth-embedded/auth-menu/accounts.js +387 -0
  18. package/dist/src/common-auth-embedded/auth-menu/ansi.d.ts +26 -0
  19. package/dist/src/common-auth-embedded/auth-menu/ansi.js +98 -0
  20. package/dist/src/common-auth-embedded/auth-menu/confirm.d.ts +7 -0
  21. package/dist/src/common-auth-embedded/auth-menu/confirm.js +21 -0
  22. package/dist/src/common-auth-embedded/auth-menu/doctor.d.ts +52 -0
  23. package/dist/src/common-auth-embedded/auth-menu/doctor.js +81 -0
  24. package/dist/src/common-auth-embedded/auth-menu/index.d.ts +17 -0
  25. package/dist/src/common-auth-embedded/auth-menu/index.js +12 -0
  26. package/dist/src/common-auth-embedded/auth-menu/login.d.ts +55 -0
  27. package/dist/src/common-auth-embedded/auth-menu/login.js +83 -0
  28. package/dist/src/common-auth-embedded/auth-menu/menu.d.ts +59 -0
  29. package/dist/src/common-auth-embedded/auth-menu/menu.js +73 -0
  30. package/dist/src/common-auth-embedded/auth-menu/opencode-v1.d.ts +49 -0
  31. package/dist/src/common-auth-embedded/auth-menu/opencode-v1.js +47 -0
  32. package/dist/src/common-auth-embedded/auth-menu/select.d.ts +21 -0
  33. package/dist/src/common-auth-embedded/auth-menu/select.js +159 -0
  34. package/dist/src/common-auth-embedded/auth-menu/terminal.d.ts +43 -0
  35. package/dist/src/common-auth-embedded/auth-menu/terminal.js +19 -0
  36. package/dist/src/common-auth-embedded/claustrum/consumer.d.ts +102 -0
  37. package/dist/src/common-auth-embedded/claustrum/consumer.js +298 -0
  38. package/dist/src/common-auth-embedded/claustrum/custody.d.ts +175 -0
  39. package/dist/src/common-auth-embedded/claustrum/custody.js +354 -0
  40. package/dist/src/common-auth-embedded/claustrum/enrollment.d.ts +158 -0
  41. package/dist/src/common-auth-embedded/claustrum/enrollment.js +759 -0
  42. package/dist/src/common-auth-embedded/claustrum/errors.d.ts +16 -0
  43. package/dist/src/common-auth-embedded/claustrum/errors.js +8 -0
  44. package/dist/src/common-auth-embedded/claustrum/host-slot.d.ts +39 -0
  45. package/dist/src/common-auth-embedded/claustrum/host-slot.js +72 -0
  46. package/dist/src/common-auth-embedded/claustrum/index.d.ts +18 -0
  47. package/dist/src/common-auth-embedded/claustrum/index.js +22 -0
  48. package/dist/src/common-auth-embedded/claustrum/interlock.d.ts +27 -0
  49. package/dist/src/common-auth-embedded/claustrum/interlock.js +29 -0
  50. package/dist/src/common-auth-embedded/claustrum/roster.d.ts +208 -0
  51. package/dist/src/common-auth-embedded/claustrum/roster.js +536 -0
  52. package/dist/src/common-auth-embedded/commands/builtins.d.ts +71 -0
  53. package/dist/src/common-auth-embedded/commands/builtins.js +534 -0
  54. package/dist/src/common-auth-embedded/commands/index.d.ts +10 -0
  55. package/dist/src/common-auth-embedded/commands/index.js +5 -0
  56. package/dist/src/common-auth-embedded/commands/menu.d.ts +61 -0
  57. package/dist/src/common-auth-embedded/commands/menu.js +300 -0
  58. package/dist/src/common-auth-embedded/commands/model.d.ts +238 -0
  59. package/dist/src/common-auth-embedded/commands/model.js +16 -0
  60. package/dist/src/common-auth-embedded/commands/pi.d.ts +23 -0
  61. package/dist/src/common-auth-embedded/commands/pi.js +206 -0
  62. package/dist/src/common-auth-embedded/commands/seam.d.ts +72 -0
  63. package/dist/src/common-auth-embedded/commands/seam.js +301 -0
  64. package/dist/src/common-auth-embedded/fs/atomic-write.d.ts +20 -0
  65. package/dist/src/common-auth-embedded/fs/atomic-write.js +80 -0
  66. package/dist/src/common-auth-embedded/fs/index.d.ts +7 -0
  67. package/dist/src/common-auth-embedded/fs/index.js +6 -0
  68. package/dist/src/common-auth-embedded/fs/lock-constants.d.ts +14 -0
  69. package/dist/src/common-auth-embedded/fs/lock-constants.js +14 -0
  70. package/dist/src/common-auth-embedded/fs/refresh-file-lock.d.ts +33 -0
  71. package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +501 -0
  72. package/dist/src/common-auth-embedded/fs/with-lock.d.ts +33 -0
  73. package/dist/src/common-auth-embedded/fs/with-lock.js +48 -0
  74. package/dist/src/common-auth-embedded/logger/capture-sink.d.ts +14 -0
  75. package/dist/src/common-auth-embedded/logger/capture-sink.js +13 -0
  76. package/dist/src/common-auth-embedded/logger/engine.d.ts +100 -0
  77. package/dist/src/common-auth-embedded/logger/engine.js +246 -0
  78. package/dist/src/common-auth-embedded/logger/index.d.ts +6 -0
  79. package/dist/src/common-auth-embedded/logger/index.js +3 -0
  80. package/dist/src/common-auth-embedded/logger/redact.d.ts +11 -0
  81. package/dist/src/common-auth-embedded/logger/redact.js +83 -0
  82. package/dist/src/common-auth-embedded/opencode2/errors.d.ts +25 -0
  83. package/dist/src/common-auth-embedded/opencode2/errors.js +15 -0
  84. package/dist/src/common-auth-embedded/opencode2/index.d.ts +8 -0
  85. package/dist/src/common-auth-embedded/opencode2/index.js +4 -0
  86. package/dist/src/common-auth-embedded/opencode2/install.d.ts +55 -0
  87. package/dist/src/common-auth-embedded/opencode2/install.js +886 -0
  88. package/dist/src/common-auth-embedded/opencode2/integration.d.ts +112 -0
  89. package/dist/src/common-auth-embedded/opencode2/integration.js +143 -0
  90. package/dist/src/common-auth-embedded/opencode2/sse.d.ts +12 -0
  91. package/dist/src/common-auth-embedded/opencode2/sse.js +60 -0
  92. package/dist/src/common-auth-embedded/opencode2/types.d.ts +413 -0
  93. package/dist/src/common-auth-embedded/pi-slot/index.d.ts +3 -0
  94. package/dist/src/common-auth-embedded/pi-slot/index.js +2 -0
  95. package/dist/src/common-auth-embedded/pi-slot/lock.js +212 -0
  96. package/dist/src/common-auth-embedded/pi-slot/slot.d.ts +49 -0
  97. package/dist/src/common-auth-embedded/pi-slot/slot.js +383 -0
  98. package/dist/src/common-auth-embedded/quota/codec.d.ts +11 -0
  99. package/dist/src/common-auth-embedded/quota/codec.js +12 -0
  100. package/dist/src/common-auth-embedded/quota/format.d.ts +46 -0
  101. package/dist/src/common-auth-embedded/quota/format.js +138 -0
  102. package/dist/src/common-auth-embedded/quota/index.d.ts +10 -0
  103. package/dist/src/common-auth-embedded/quota/index.js +5 -0
  104. package/dist/src/common-auth-embedded/quota/map.d.ts +63 -0
  105. package/dist/src/common-auth-embedded/quota/map.js +105 -0
  106. package/dist/src/common-auth-embedded/quota/merge.d.ts +48 -0
  107. package/dist/src/common-auth-embedded/quota/merge.js +162 -0
  108. package/dist/src/common-auth-embedded/quota/projection.d.ts +64 -0
  109. package/dist/src/common-auth-embedded/quota/projection.js +134 -0
  110. package/dist/src/common-auth-embedded/routing/admission.d.ts +93 -0
  111. package/dist/src/common-auth-embedded/routing/admission.js +142 -0
  112. package/dist/src/common-auth-embedded/routing/index.d.ts +8 -0
  113. package/dist/src/common-auth-embedded/routing/index.js +4 -0
  114. package/dist/src/common-auth-embedded/routing/ordered.d.ts +47 -0
  115. package/dist/src/common-auth-embedded/routing/ordered.js +58 -0
  116. package/dist/src/common-auth-embedded/routing/pins.d.ts +22 -0
  117. package/dist/src/common-auth-embedded/routing/pins.js +34 -0
  118. package/dist/src/common-auth-embedded/routing/sticky.d.ts +158 -0
  119. package/dist/src/common-auth-embedded/routing/sticky.js +339 -0
  120. package/dist/src/common-auth-embedded/rpc/client.d.ts +3 -0
  121. package/dist/src/common-auth-embedded/rpc/client.js +2 -0
  122. package/dist/src/common-auth-embedded/rpc/index.d.ts +10 -0
  123. package/dist/src/common-auth-embedded/rpc/index.js +5 -0
  124. package/dist/src/common-auth-embedded/rpc/notifications.d.ts +73 -0
  125. package/dist/src/common-auth-embedded/rpc/notifications.js +100 -0
  126. package/dist/src/common-auth-embedded/rpc/port-file.d.ts +33 -0
  127. package/dist/src/common-auth-embedded/rpc/port-file.js +217 -0
  128. package/dist/src/common-auth-embedded/rpc/rpc-client.d.ts +30 -0
  129. package/dist/src/common-auth-embedded/rpc/rpc-client.js +253 -0
  130. package/dist/src/common-auth-embedded/rpc/rpc-server.d.ts +58 -0
  131. package/dist/src/common-auth-embedded/rpc/rpc-server.js +311 -0
  132. package/dist/src/common-auth-embedded/rpc/server-registry.d.ts +11 -0
  133. package/dist/src/common-auth-embedded/rpc/server-registry.js +47 -0
  134. package/dist/src/common-auth-embedded/source-output.json +1326 -0
  135. package/dist/src/common-auth-embedded/store/attribution.d.ts +28 -0
  136. package/dist/src/common-auth-embedded/store/attribution.js +60 -0
  137. package/dist/src/common-auth-embedded/store/errors.d.ts +55 -0
  138. package/dist/src/common-auth-embedded/store/errors.js +38 -0
  139. package/dist/src/common-auth-embedded/store/hooks.d.ts +12 -0
  140. package/dist/src/common-auth-embedded/store/hooks.js +34 -0
  141. package/dist/src/common-auth-embedded/store/identity.d.ts +39 -0
  142. package/dist/src/common-auth-embedded/store/identity.js +79 -0
  143. package/dist/src/common-auth-embedded/store/index.d.ts +21 -0
  144. package/dist/src/common-auth-embedded/store/index.js +7 -0
  145. package/dist/src/common-auth-embedded/store/mutate.d.ts +189 -0
  146. package/dist/src/common-auth-embedded/store/mutate.js +500 -0
  147. package/dist/src/common-auth-embedded/store/pool.d.ts +196 -0
  148. package/dist/src/common-auth-embedded/store/pool.js +120 -0
  149. package/dist/src/common-auth-embedded/store/provider-state.d.ts +131 -0
  150. package/dist/src/common-auth-embedded/store/provider-state.js +226 -0
  151. package/dist/src/common-auth-embedded/store/publication.d.ts +47 -0
  152. package/dist/src/common-auth-embedded/store/publication.js +304 -0
  153. package/dist/src/common-auth-embedded/store/pull.d.ts +36 -0
  154. package/dist/src/common-auth-embedded/store/pull.js +143 -0
  155. package/dist/src/common-auth-embedded/store/refresh-lock.d.ts +63 -0
  156. package/dist/src/common-auth-embedded/store/refresh-lock.js +136 -0
  157. package/dist/src/common-auth-embedded/store/refresh.d.ts +72 -0
  158. package/dist/src/common-auth-embedded/store/refresh.js +225 -0
  159. package/dist/src/common-auth-embedded/store/reserved.js +13 -0
  160. package/dist/src/common-auth-embedded/store/rows.d.ts +313 -0
  161. package/dist/src/common-auth-embedded/store/rows.js +1258 -0
  162. package/dist/src/common-auth-embedded/store/runtime.d.ts +36 -0
  163. package/dist/src/common-auth-embedded/store/runtime.js +68 -0
  164. package/dist/src/common-auth-embedded/store/schema.d.ts +443 -0
  165. package/dist/src/common-auth-embedded/store/schema.js +754 -0
  166. package/dist/src/common-auth-embedded/store/settings.d.ts +63 -0
  167. package/dist/src/common-auth-embedded/store/settings.js +120 -0
  168. package/dist/src/common-auth-embedded/store/torn.d.ts +78 -0
  169. package/dist/src/common-auth-embedded/store/torn.js +294 -0
  170. package/dist/src/common-auth-embedded/tui/index.d.ts +8 -0
  171. package/dist/src/common-auth-embedded/tui/index.js +21 -0
  172. package/dist/src/common-auth-embedded/util/any-signal.js +42 -0
  173. package/dist/src/constants.d.ts +1 -0
  174. package/dist/src/constants.d.ts.map +1 -1
  175. package/dist/src/constants.js +4 -0
  176. package/dist/src/constants.js.map +1 -1
  177. package/dist/src/ga/proxy-guard.d.ts +120 -0
  178. package/dist/src/ga/proxy-guard.d.ts.map +1 -0
  179. package/dist/src/ga/proxy-guard.js +269 -0
  180. package/dist/src/ga/proxy-guard.js.map +1 -0
  181. package/dist/src/ga/rpc/protocol.d.ts +504 -0
  182. package/dist/src/ga/rpc/protocol.d.ts.map +1 -0
  183. package/dist/src/ga/rpc/protocol.js +1278 -0
  184. package/dist/src/ga/rpc/protocol.js.map +1 -0
  185. package/dist/src/ga/server/auth.d.ts +9 -0
  186. package/dist/src/ga/server/auth.d.ts.map +1 -0
  187. package/dist/src/ga/server/auth.js +37 -0
  188. package/dist/src/ga/server/auth.js.map +1 -0
  189. package/dist/src/ga/server/index.d.ts +576 -0
  190. package/dist/src/ga/server/index.d.ts.map +1 -0
  191. package/dist/src/ga/server/index.js +1012 -0
  192. package/dist/src/ga/server/index.js.map +1 -0
  193. package/dist/src/ga/tui/host-ga.d.ts +350 -0
  194. package/dist/src/ga/tui/host-ga.d.ts.map +1 -0
  195. package/dist/src/ga/tui/host-ga.js +1242 -0
  196. package/dist/src/ga/tui/host-ga.js.map +1 -0
  197. package/dist/src/logging/provider-key-policy.d.ts +9 -0
  198. package/dist/src/logging/provider-key-policy.d.ts.map +1 -0
  199. package/dist/src/logging/provider-key-policy.js +11 -0
  200. package/dist/src/logging/provider-key-policy.js.map +1 -0
  201. package/dist/src/plugin/account-access.d.ts +130 -15
  202. package/dist/src/plugin/account-access.d.ts.map +1 -1
  203. package/dist/src/plugin/account-access.js +331 -129
  204. package/dist/src/plugin/account-access.js.map +1 -1
  205. package/dist/src/plugin/account-blocks.d.ts +102 -0
  206. package/dist/src/plugin/account-blocks.d.ts.map +1 -0
  207. package/dist/src/plugin/account-blocks.js +196 -0
  208. package/dist/src/plugin/account-blocks.js.map +1 -0
  209. package/dist/src/plugin/accounts.d.ts +85 -1
  210. package/dist/src/plugin/accounts.d.ts.map +1 -1
  211. package/dist/src/plugin/accounts.js +127 -3
  212. package/dist/src/plugin/accounts.js.map +1 -1
  213. package/dist/src/plugin/auth-loader.d.ts +69 -5
  214. package/dist/src/plugin/auth-loader.d.ts.map +1 -1
  215. package/dist/src/plugin/auth-loader.js +355 -52
  216. package/dist/src/plugin/auth-loader.js.map +1 -1
  217. package/dist/src/plugin/background-quota-refresh.d.ts +54 -8
  218. package/dist/src/plugin/background-quota-refresh.d.ts.map +1 -1
  219. package/dist/src/plugin/background-quota-refresh.js +81 -24
  220. package/dist/src/plugin/background-quota-refresh.js.map +1 -1
  221. package/dist/src/plugin/cache/index.d.ts +1 -1
  222. package/dist/src/plugin/cache/index.d.ts.map +1 -1
  223. package/dist/src/plugin/cache/index.js +1 -1
  224. package/dist/src/plugin/cache/index.js.map +1 -1
  225. package/dist/src/plugin/cache/signature-cache.d.ts +55 -10
  226. package/dist/src/plugin/cache/signature-cache.d.ts.map +1 -1
  227. package/dist/src/plugin/cache/signature-cache.js +100 -41
  228. package/dist/src/plugin/cache/signature-cache.js.map +1 -1
  229. package/dist/src/plugin/cache.d.ts +80 -16
  230. package/dist/src/plugin/cache.d.ts.map +1 -1
  231. package/dist/src/plugin/cache.js +339 -200
  232. package/dist/src/plugin/cache.js.map +1 -1
  233. package/dist/src/plugin/catalog.d.ts +4 -18
  234. package/dist/src/plugin/catalog.d.ts.map +1 -1
  235. package/dist/src/plugin/catalog.js +11 -41
  236. package/dist/src/plugin/catalog.js.map +1 -1
  237. package/dist/src/plugin/command-apply.d.ts +58 -0
  238. package/dist/src/plugin/command-apply.d.ts.map +1 -0
  239. package/dist/src/plugin/command-apply.js +168 -0
  240. package/dist/src/plugin/command-apply.js.map +1 -0
  241. package/dist/src/plugin/command-data.d.ts +1 -0
  242. package/dist/src/plugin/command-data.d.ts.map +1 -1
  243. package/dist/src/plugin/command-data.js +2 -0
  244. package/dist/src/plugin/command-data.js.map +1 -1
  245. package/dist/src/plugin/commands.d.ts +142 -132
  246. package/dist/src/plugin/commands.d.ts.map +1 -1
  247. package/dist/src/plugin/commands.js +214 -686
  248. package/dist/src/plugin/commands.js.map +1 -1
  249. package/dist/src/plugin/config/index.d.ts +1 -1
  250. package/dist/src/plugin/config/index.d.ts.map +1 -1
  251. package/dist/src/plugin/config/index.js +1 -1
  252. package/dist/src/plugin/config/index.js.map +1 -1
  253. package/dist/src/plugin/config/loader.d.ts +37 -1
  254. package/dist/src/plugin/config/loader.d.ts.map +1 -1
  255. package/dist/src/plugin/config/loader.js +64 -9
  256. package/dist/src/plugin/config/loader.js.map +1 -1
  257. package/dist/src/plugin/config/operator-settings-schema.d.ts +2 -2
  258. package/dist/src/plugin/config/schema.d.ts +2 -2
  259. package/dist/src/plugin/config/writer.d.ts +7 -0
  260. package/dist/src/plugin/config/writer.d.ts.map +1 -1
  261. package/dist/src/plugin/config/writer.js +10 -1
  262. package/dist/src/plugin/config/writer.js.map +1 -1
  263. package/dist/src/plugin/debug.d.ts +72 -29
  264. package/dist/src/plugin/debug.d.ts.map +1 -1
  265. package/dist/src/plugin/debug.js +353 -239
  266. package/dist/src/plugin/debug.js.map +1 -1
  267. package/dist/src/plugin/fetch/retry-state.d.ts +1 -1
  268. package/dist/src/plugin/fetch/retry-state.d.ts.map +1 -1
  269. package/dist/src/plugin/fetch/retry-state.js.map +1 -1
  270. package/dist/src/plugin/fetch-interceptor.d.ts +66 -11
  271. package/dist/src/plugin/fetch-interceptor.d.ts.map +1 -1
  272. package/dist/src/plugin/fetch-interceptor.js +228 -1347
  273. package/dist/src/plugin/fetch-interceptor.js.map +1 -1
  274. package/dist/src/plugin/fetch-routing.d.ts +7 -2
  275. package/dist/src/plugin/fetch-routing.d.ts.map +1 -1
  276. package/dist/src/plugin/fetch-routing.js +7 -4
  277. package/dist/src/plugin/fetch-routing.js.map +1 -1
  278. package/dist/src/plugin/ga-location-services.d.ts +389 -0
  279. package/dist/src/plugin/ga-location-services.d.ts.map +1 -0
  280. package/dist/src/plugin/ga-location-services.js +1838 -0
  281. package/dist/src/plugin/ga-location-services.js.map +1 -0
  282. package/dist/src/plugin/gemini-dump.d.ts +37 -12
  283. package/dist/src/plugin/gemini-dump.d.ts.map +1 -1
  284. package/dist/src/plugin/gemini-dump.js +42 -21
  285. package/dist/src/plugin/gemini-dump.js.map +1 -1
  286. package/dist/src/plugin/google-search-tool.d.ts +2 -1
  287. package/dist/src/plugin/google-search-tool.d.ts.map +1 -1
  288. package/dist/src/plugin/google-search-tool.js +4 -1
  289. package/dist/src/plugin/google-search-tool.js.map +1 -1
  290. package/dist/src/plugin/index.d.ts.map +1 -1
  291. package/dist/src/plugin/index.js +505 -141
  292. package/dist/src/plugin/index.js.map +1 -1
  293. package/dist/src/plugin/killswitch.d.ts +1 -2
  294. package/dist/src/plugin/killswitch.d.ts.map +1 -1
  295. package/dist/src/plugin/lifecycle.d.ts +24 -1
  296. package/dist/src/plugin/lifecycle.d.ts.map +1 -1
  297. package/dist/src/plugin/lifecycle.js +95 -8
  298. package/dist/src/plugin/lifecycle.js.map +1 -1
  299. package/dist/src/plugin/logger.d.ts +61 -10
  300. package/dist/src/plugin/logger.d.ts.map +1 -1
  301. package/dist/src/plugin/logger.js +134 -63
  302. package/dist/src/plugin/logger.js.map +1 -1
  303. package/dist/src/plugin/neutral-types.d.ts +42 -0
  304. package/dist/src/plugin/neutral-types.d.ts.map +1 -0
  305. package/dist/src/plugin/neutral-types.js +12 -0
  306. package/dist/src/plugin/neutral-types.js.map +1 -0
  307. package/dist/src/plugin/oauth-methods.d.ts +2 -1
  308. package/dist/src/plugin/oauth-methods.d.ts.map +1 -1
  309. package/dist/src/plugin/oauth-methods.js +173 -88
  310. package/dist/src/plugin/oauth-methods.js.map +1 -1
  311. package/dist/src/plugin/operator-settings.d.ts +34 -0
  312. package/dist/src/plugin/operator-settings.d.ts.map +1 -1
  313. package/dist/src/plugin/operator-settings.js +105 -2
  314. package/dist/src/plugin/operator-settings.js.map +1 -1
  315. package/dist/src/plugin/persist-account-pool.d.ts +63 -2
  316. package/dist/src/plugin/persist-account-pool.d.ts.map +1 -1
  317. package/dist/src/plugin/persist-account-pool.js +125 -2
  318. package/dist/src/plugin/persist-account-pool.js.map +1 -1
  319. package/dist/src/plugin/quota.d.ts +335 -35
  320. package/dist/src/plugin/quota.d.ts.map +1 -1
  321. package/dist/src/plugin/quota.js +825 -95
  322. package/dist/src/plugin/quota.js.map +1 -1
  323. package/dist/src/plugin/refresh-queue.d.ts +35 -5
  324. package/dist/src/plugin/refresh-queue.d.ts.map +1 -1
  325. package/dist/src/plugin/refresh-queue.js +50 -16
  326. package/dist/src/plugin/refresh-queue.js.map +1 -1
  327. package/dist/src/plugin/request-helpers.d.ts +30 -5
  328. package/dist/src/plugin/request-helpers.d.ts.map +1 -1
  329. package/dist/src/plugin/request-helpers.js +82 -17
  330. package/dist/src/plugin/request-helpers.js.map +1 -1
  331. package/dist/src/plugin/request.d.ts +63 -15
  332. package/dist/src/plugin/request.d.ts.map +1 -1
  333. package/dist/src/plugin/request.js +190 -60
  334. package/dist/src/plugin/request.js.map +1 -1
  335. package/dist/src/plugin/session-context.d.ts.map +1 -1
  336. package/dist/src/plugin/session-context.js +5 -2
  337. package/dist/src/plugin/session-context.js.map +1 -1
  338. package/dist/src/plugin/shared/local-grant.d.ts +26 -0
  339. package/dist/src/plugin/shared/local-grant.d.ts.map +1 -0
  340. package/dist/src/plugin/shared/local-grant.js +19 -0
  341. package/dist/src/plugin/shared/local-grant.js.map +1 -0
  342. package/dist/src/plugin/shared/request-cancellation.d.ts +12 -0
  343. package/dist/src/plugin/shared/request-cancellation.d.ts.map +1 -0
  344. package/dist/src/plugin/shared/request-cancellation.js +118 -0
  345. package/dist/src/plugin/shared/request-cancellation.js.map +1 -0
  346. package/dist/src/plugin/shared/request-services.d.ts +375 -0
  347. package/dist/src/plugin/shared/request-services.d.ts.map +1 -0
  348. package/dist/src/plugin/shared/request-services.js +1743 -0
  349. package/dist/src/plugin/shared/request-services.js.map +1 -0
  350. package/dist/src/plugin/shared/runtime.d.ts +217 -0
  351. package/dist/src/plugin/shared/runtime.d.ts.map +1 -0
  352. package/dist/src/plugin/shared/runtime.js +345 -0
  353. package/dist/src/plugin/shared/runtime.js.map +1 -0
  354. package/dist/src/plugin/shared/source-sidebar.d.ts +15 -0
  355. package/dist/src/plugin/shared/source-sidebar.d.ts.map +1 -0
  356. package/dist/src/plugin/shared/source-sidebar.js +41 -0
  357. package/dist/src/plugin/shared/source-sidebar.js.map +1 -0
  358. package/dist/src/plugin/shared/vault-menu.d.ts +5 -0
  359. package/dist/src/plugin/shared/vault-menu.d.ts.map +1 -0
  360. package/dist/src/plugin/shared/vault-menu.js +49 -0
  361. package/dist/src/plugin/shared/vault-menu.js.map +1 -0
  362. package/dist/src/plugin/shared/vault-request-credentials.d.ts +168 -0
  363. package/dist/src/plugin/shared/vault-request-credentials.d.ts.map +1 -0
  364. package/dist/src/plugin/shared/vault-request-credentials.js +485 -0
  365. package/dist/src/plugin/shared/vault-request-credentials.js.map +1 -0
  366. package/dist/src/plugin/storage.d.ts +127 -1
  367. package/dist/src/plugin/storage.d.ts.map +1 -1
  368. package/dist/src/plugin/storage.js +188 -3
  369. package/dist/src/plugin/storage.js.map +1 -1
  370. package/dist/src/plugin/token.d.ts +23 -1
  371. package/dist/src/plugin/token.d.ts.map +1 -1
  372. package/dist/src/plugin/token.js +117 -58
  373. package/dist/src/plugin/token.js.map +1 -1
  374. package/dist/src/plugin/ui/quota-status.d.ts +1 -10
  375. package/dist/src/plugin/ui/quota-status.d.ts.map +1 -1
  376. package/dist/src/plugin/ui/quota-status.js +6 -42
  377. package/dist/src/plugin/ui/quota-status.js.map +1 -1
  378. package/dist/src/plugin/vault-activation.d.ts +11 -0
  379. package/dist/src/plugin/vault-activation.d.ts.map +1 -0
  380. package/dist/src/plugin/vault-activation.js +53 -0
  381. package/dist/src/plugin/vault-activation.js.map +1 -0
  382. package/dist/src/plugin/vault-custody.d.ts +131 -0
  383. package/dist/src/plugin/vault-custody.d.ts.map +1 -0
  384. package/dist/src/plugin/vault-custody.js +381 -0
  385. package/dist/src/plugin/vault-custody.js.map +1 -0
  386. package/dist/src/quota-presentation.d.ts +18 -0
  387. package/dist/src/quota-presentation.d.ts.map +1 -0
  388. package/dist/src/quota-presentation.js +58 -0
  389. package/dist/src/quota-presentation.js.map +1 -0
  390. package/dist/src/rpc/notifications.d.ts +2 -2
  391. package/dist/src/rpc/notifications.d.ts.map +1 -1
  392. package/dist/src/rpc/notifications.js +1 -1
  393. package/dist/src/rpc/notifications.js.map +1 -1
  394. package/dist/src/rpc/port-file.d.ts +2 -12
  395. package/dist/src/rpc/port-file.d.ts.map +1 -1
  396. package/dist/src/rpc/port-file.js +5 -107
  397. package/dist/src/rpc/port-file.js.map +1 -1
  398. package/dist/src/rpc/protocol.d.ts +47 -16
  399. package/dist/src/rpc/protocol.d.ts.map +1 -1
  400. package/dist/src/rpc/rpc-client.d.ts +27 -3
  401. package/dist/src/rpc/rpc-client.d.ts.map +1 -1
  402. package/dist/src/rpc/rpc-client.js +55 -45
  403. package/dist/src/rpc/rpc-client.js.map +1 -1
  404. package/dist/src/rpc/rpc-server.d.ts +13 -2
  405. package/dist/src/rpc/rpc-server.d.ts.map +1 -1
  406. package/dist/src/rpc/rpc-server.js +38 -212
  407. package/dist/src/rpc/rpc-server.js.map +1 -1
  408. package/dist/src/server.d.ts +30 -0
  409. package/dist/src/server.d.ts.map +1 -0
  410. package/dist/src/server.js +29 -0
  411. package/dist/src/server.js.map +1 -0
  412. package/dist/src/sidebar-projection.d.ts +102 -0
  413. package/dist/src/sidebar-projection.d.ts.map +1 -0
  414. package/dist/src/sidebar-projection.js +146 -0
  415. package/dist/src/sidebar-projection.js.map +1 -0
  416. package/dist/src/sidebar-state.d.ts +13 -5
  417. package/dist/src/sidebar-state.d.ts.map +1 -1
  418. package/dist/src/sidebar-state.js +49 -16
  419. package/dist/src/sidebar-state.js.map +1 -1
  420. package/dist/src/tui/command-dialogs.d.ts +58 -52
  421. package/dist/src/tui/command-dialogs.d.ts.map +1 -1
  422. package/dist/src/tui/command-dialogs.js +379 -571
  423. package/dist/src/tui/command-dialogs.js.map +1 -1
  424. package/dist/src/tui/file-logger.d.ts +2 -3
  425. package/dist/src/tui/file-logger.d.ts.map +1 -1
  426. package/dist/src/tui/file-logger.js +21 -7
  427. package/dist/src/tui/file-logger.js.map +1 -1
  428. package/dist/src/tui/host-api.d.ts +196 -0
  429. package/dist/src/tui/host-api.d.ts.map +1 -0
  430. package/dist/src/tui/host-api.js +357 -0
  431. package/dist/src/tui/host-api.js.map +1 -0
  432. package/dist/src/tui/host-v1.d.ts +60 -0
  433. package/dist/src/tui/host-v1.d.ts.map +1 -0
  434. package/dist/src/tui/host-v1.js +147 -0
  435. package/dist/src/tui/host-v1.js.map +1 -0
  436. package/dist/src/tui/vault-setup.d.ts +98 -0
  437. package/dist/src/tui/vault-setup.d.ts.map +1 -0
  438. package/dist/src/tui/vault-setup.js +198 -0
  439. package/dist/src/tui/vault-setup.js.map +1 -0
  440. package/dist/src/tui.d.ts +4 -11
  441. package/dist/src/tui.d.ts.map +1 -1
  442. package/dist/src/tui.js +33 -75
  443. package/dist/src/tui.js.map +1 -1
  444. package/dist/tui-build-map.json +380 -0
  445. package/dist/tui-ga-build-map.json +187 -0
  446. package/dist/types/src/antigravity/oauth.d.ts +2 -0
  447. package/dist/types/src/antigravity/oauth.d.ts.map +1 -0
  448. package/dist/types/src/cli.d.ts +66 -0
  449. package/dist/types/src/cli.d.ts.map +1 -0
  450. package/dist/types/src/common-auth-embedded/commands/builtins.d.ts +71 -0
  451. package/dist/types/src/common-auth-embedded/commands/index.d.ts +10 -0
  452. package/dist/types/src/common-auth-embedded/commands/menu.d.ts +61 -0
  453. package/dist/types/src/common-auth-embedded/commands/model.d.ts +238 -0
  454. package/dist/types/src/common-auth-embedded/commands/pi.d.ts +23 -0
  455. package/dist/types/src/common-auth-embedded/commands/seam.d.ts +72 -0
  456. package/dist/types/src/common-auth-embedded/fs/refresh-file-lock.d.ts +33 -0
  457. package/dist/types/src/common-auth-embedded/logger/capture-sink.d.ts +14 -0
  458. package/dist/types/src/common-auth-embedded/logger/engine.d.ts +100 -0
  459. package/dist/types/src/common-auth-embedded/logger/index.d.ts +6 -0
  460. package/dist/types/src/common-auth-embedded/logger/redact.d.ts +11 -0
  461. package/dist/types/src/common-auth-embedded/quota/codec.d.ts +11 -0
  462. package/dist/types/src/common-auth-embedded/quota/format.d.ts +46 -0
  463. package/dist/types/src/common-auth-embedded/quota/index.d.ts +10 -0
  464. package/dist/types/src/common-auth-embedded/quota/map.d.ts +63 -0
  465. package/dist/types/src/common-auth-embedded/quota/merge.d.ts +48 -0
  466. package/dist/types/src/common-auth-embedded/quota/projection.d.ts +64 -0
  467. package/dist/types/src/common-auth-embedded/store/attribution.d.ts +28 -0
  468. package/dist/types/src/common-auth-embedded/store/errors.d.ts +55 -0
  469. package/dist/types/src/common-auth-embedded/store/hooks.d.ts +12 -0
  470. package/dist/types/src/common-auth-embedded/store/identity.d.ts +39 -0
  471. package/dist/types/src/common-auth-embedded/store/index.d.ts +21 -0
  472. package/dist/types/src/common-auth-embedded/store/mutate.d.ts +189 -0
  473. package/dist/types/src/common-auth-embedded/store/pool.d.ts +196 -0
  474. package/dist/types/src/common-auth-embedded/store/provider-state.d.ts +131 -0
  475. package/dist/types/src/common-auth-embedded/store/publication.d.ts +47 -0
  476. package/dist/types/src/common-auth-embedded/store/pull.d.ts +36 -0
  477. package/dist/types/src/common-auth-embedded/store/refresh-lock.d.ts +63 -0
  478. package/dist/types/src/common-auth-embedded/store/refresh.d.ts +72 -0
  479. package/dist/types/src/common-auth-embedded/store/rows.d.ts +313 -0
  480. package/dist/types/src/common-auth-embedded/store/runtime.d.ts +36 -0
  481. package/dist/types/src/common-auth-embedded/store/schema.d.ts +443 -0
  482. package/dist/types/src/common-auth-embedded/store/settings.d.ts +63 -0
  483. package/dist/types/src/common-auth-embedded/store/torn.d.ts +78 -0
  484. package/dist/types/src/constants.d.ts +3 -0
  485. package/dist/types/src/constants.d.ts.map +1 -0
  486. package/dist/types/src/ga/proxy-guard.d.ts +120 -0
  487. package/dist/types/src/ga/proxy-guard.d.ts.map +1 -0
  488. package/dist/types/src/ga/rpc/protocol.d.ts +504 -0
  489. package/dist/types/src/ga/rpc/protocol.d.ts.map +1 -0
  490. package/dist/types/src/ga/server/auth.d.ts +9 -0
  491. package/dist/types/src/ga/server/auth.d.ts.map +1 -0
  492. package/dist/types/src/ga/server/index.d.ts +576 -0
  493. package/dist/types/src/ga/server/index.d.ts.map +1 -0
  494. package/dist/types/src/hooks/auto-update-checker/cache.d.ts +3 -0
  495. package/dist/types/src/hooks/auto-update-checker/cache.d.ts.map +1 -0
  496. package/dist/types/src/hooks/auto-update-checker/checker.d.ts +16 -0
  497. package/dist/types/src/hooks/auto-update-checker/checker.d.ts.map +1 -0
  498. package/dist/types/src/hooks/auto-update-checker/constants.d.ts +9 -0
  499. package/dist/types/src/hooks/auto-update-checker/constants.d.ts.map +1 -0
  500. package/dist/types/src/hooks/auto-update-checker/index.d.ts +34 -0
  501. package/dist/types/src/hooks/auto-update-checker/index.d.ts.map +1 -0
  502. package/dist/types/src/hooks/auto-update-checker/logging.d.ts +3 -0
  503. package/dist/types/src/hooks/auto-update-checker/logging.d.ts.map +1 -0
  504. package/dist/types/src/hooks/auto-update-checker/types.d.ts +25 -0
  505. package/dist/types/src/hooks/auto-update-checker/types.d.ts.map +1 -0
  506. package/dist/types/src/logging/provider-key-policy.d.ts +9 -0
  507. package/dist/types/src/logging/provider-key-policy.d.ts.map +1 -0
  508. package/dist/types/src/plugin/account-access.d.ts +214 -0
  509. package/dist/types/src/plugin/account-access.d.ts.map +1 -0
  510. package/dist/types/src/plugin/account-blocks.d.ts +102 -0
  511. package/dist/types/src/plugin/account-blocks.d.ts.map +1 -0
  512. package/dist/types/src/plugin/account-command-oauth.d.ts +34 -0
  513. package/dist/types/src/plugin/account-command-oauth.d.ts.map +1 -0
  514. package/dist/types/src/plugin/accounts.d.ts +94 -0
  515. package/dist/types/src/plugin/accounts.d.ts.map +1 -0
  516. package/dist/types/src/plugin/agy-request-metadata.d.ts +2 -0
  517. package/dist/types/src/plugin/agy-request-metadata.d.ts.map +1 -0
  518. package/dist/types/src/plugin/agy-transport.d.ts +2 -0
  519. package/dist/types/src/plugin/agy-transport.d.ts.map +1 -0
  520. package/dist/types/src/plugin/auth-doctor.d.ts +30 -0
  521. package/dist/types/src/plugin/auth-doctor.d.ts.map +1 -0
  522. package/dist/types/src/plugin/auth-drift.d.ts +13 -0
  523. package/dist/types/src/plugin/auth-drift.d.ts.map +1 -0
  524. package/dist/types/src/plugin/auth-loader.d.ts +114 -0
  525. package/dist/types/src/plugin/auth-loader.d.ts.map +1 -0
  526. package/dist/types/src/plugin/auth.d.ts +2 -0
  527. package/dist/types/src/plugin/auth.d.ts.map +1 -0
  528. package/dist/types/src/plugin/background-quota-refresh.d.ts +192 -0
  529. package/dist/types/src/plugin/background-quota-refresh.d.ts.map +1 -0
  530. package/dist/types/src/plugin/cache/signature-cache.d.ts +156 -0
  531. package/dist/types/src/plugin/cache/signature-cache.d.ts.map +1 -0
  532. package/dist/types/src/plugin/cache.d.ts +109 -0
  533. package/dist/types/src/plugin/cache.d.ts.map +1 -0
  534. package/dist/types/src/plugin/catalog.d.ts +9 -0
  535. package/dist/types/src/plugin/catalog.d.ts.map +1 -0
  536. package/dist/types/src/plugin/cli.d.ts +44 -0
  537. package/dist/types/src/plugin/cli.d.ts.map +1 -0
  538. package/dist/types/src/plugin/command-apply.d.ts +58 -0
  539. package/dist/types/src/plugin/command-apply.d.ts.map +1 -0
  540. package/dist/types/src/plugin/command-data.d.ts +330 -0
  541. package/dist/types/src/plugin/command-data.d.ts.map +1 -0
  542. package/dist/types/src/plugin/commands.d.ts +164 -0
  543. package/dist/types/src/plugin/commands.d.ts.map +1 -0
  544. package/dist/types/src/plugin/config/index.d.ts +16 -0
  545. package/dist/types/src/plugin/config/index.d.ts.map +1 -0
  546. package/dist/types/src/plugin/config/loader.d.ts +72 -0
  547. package/dist/types/src/plugin/config/loader.d.ts.map +1 -0
  548. package/dist/types/src/plugin/config/models.d.ts +3 -0
  549. package/dist/types/src/plugin/config/models.d.ts.map +1 -0
  550. package/dist/types/src/plugin/config/operator-settings-schema.d.ts +29 -0
  551. package/dist/types/src/plugin/config/operator-settings-schema.d.ts.map +1 -0
  552. package/dist/types/src/plugin/config/schema.d.ts +162 -0
  553. package/dist/types/src/plugin/config/schema.d.ts.map +1 -0
  554. package/dist/types/src/plugin/config/updater.d.ts +55 -0
  555. package/dist/types/src/plugin/config/updater.d.ts.map +1 -0
  556. package/dist/types/src/plugin/config/writer.d.ts +41 -0
  557. package/dist/types/src/plugin/config/writer.d.ts.map +1 -0
  558. package/dist/types/src/plugin/core/streaming/index.d.ts +3 -0
  559. package/dist/types/src/plugin/core/streaming/index.d.ts.map +1 -0
  560. package/dist/types/src/plugin/core/streaming/transformer.d.ts +12 -0
  561. package/dist/types/src/plugin/core/streaming/transformer.d.ts.map +1 -0
  562. package/dist/types/src/plugin/core/streaming/types.d.ts +34 -0
  563. package/dist/types/src/plugin/core/streaming/types.d.ts.map +1 -0
  564. package/dist/types/src/plugin/debug.d.ts +144 -0
  565. package/dist/types/src/plugin/debug.d.ts.map +1 -0
  566. package/dist/types/src/plugin/dependencies.d.ts +129 -0
  567. package/dist/types/src/plugin/dependencies.d.ts.map +1 -0
  568. package/dist/types/src/plugin/errors.d.ts +55 -0
  569. package/dist/types/src/plugin/errors.d.ts.map +1 -0
  570. package/dist/types/src/plugin/event-handler.d.ts +53 -0
  571. package/dist/types/src/plugin/event-handler.d.ts.map +1 -0
  572. package/dist/types/src/plugin/fetch/retry-state.d.ts +61 -0
  573. package/dist/types/src/plugin/fetch/retry-state.d.ts.map +1 -0
  574. package/dist/types/src/plugin/fetch/warmup.d.ts +30 -0
  575. package/dist/types/src/plugin/fetch/warmup.d.ts.map +1 -0
  576. package/dist/types/src/plugin/fetch-interceptor.d.ts +114 -0
  577. package/dist/types/src/plugin/fetch-interceptor.d.ts.map +1 -0
  578. package/dist/types/src/plugin/fetch-routing.d.ts +31 -0
  579. package/dist/types/src/plugin/fetch-routing.d.ts.map +1 -0
  580. package/dist/types/src/plugin/fingerprint.d.ts +2 -0
  581. package/dist/types/src/plugin/fingerprint.d.ts.map +1 -0
  582. package/dist/types/src/plugin/ga-location-services.d.ts +389 -0
  583. package/dist/types/src/plugin/ga-location-services.d.ts.map +1 -0
  584. package/dist/types/src/plugin/gemini-dump.d.ts +72 -0
  585. package/dist/types/src/plugin/gemini-dump.d.ts.map +1 -0
  586. package/dist/types/src/plugin/google-search-tool.d.ts +10 -0
  587. package/dist/types/src/plugin/google-search-tool.d.ts.map +1 -0
  588. package/dist/types/src/plugin/image-saver.d.ts +6 -0
  589. package/dist/types/src/plugin/image-saver.d.ts.map +1 -0
  590. package/dist/types/src/plugin/index.d.ts +30 -0
  591. package/dist/types/src/plugin/index.d.ts.map +1 -0
  592. package/dist/types/src/plugin/killswitch.d.ts +93 -0
  593. package/dist/types/src/plugin/killswitch.d.ts.map +1 -0
  594. package/dist/types/src/plugin/lifecycle.d.ts +63 -0
  595. package/dist/types/src/plugin/lifecycle.d.ts.map +1 -0
  596. package/dist/types/src/plugin/logger.d.ts +83 -0
  597. package/dist/types/src/plugin/logger.d.ts.map +1 -0
  598. package/dist/types/src/plugin/logging-utils.d.ts +57 -0
  599. package/dist/types/src/plugin/logging-utils.d.ts.map +1 -0
  600. package/dist/types/src/plugin/model-registry.d.ts +2 -0
  601. package/dist/types/src/plugin/model-registry.d.ts.map +1 -0
  602. package/dist/types/src/plugin/neutral-types.d.ts +42 -0
  603. package/dist/types/src/plugin/neutral-types.d.ts.map +1 -0
  604. package/dist/types/src/plugin/oauth-login.d.ts +22 -0
  605. package/dist/types/src/plugin/oauth-login.d.ts.map +1 -0
  606. package/dist/types/src/plugin/oauth-methods.d.ts +43 -0
  607. package/dist/types/src/plugin/oauth-methods.d.ts.map +1 -0
  608. package/dist/types/src/plugin/operator-settings.d.ts +74 -0
  609. package/dist/types/src/plugin/operator-settings.d.ts.map +1 -0
  610. package/dist/types/src/plugin/persist-account-pool.d.ts +98 -0
  611. package/dist/types/src/plugin/persist-account-pool.d.ts.map +1 -0
  612. package/dist/types/src/plugin/project.d.ts +2 -0
  613. package/dist/types/src/plugin/project.d.ts.map +1 -0
  614. package/dist/types/src/plugin/prompt-context.d.ts +18 -0
  615. package/dist/types/src/plugin/prompt-context.d.ts.map +1 -0
  616. package/dist/types/src/plugin/quota.d.ts +441 -0
  617. package/dist/types/src/plugin/quota.d.ts.map +1 -0
  618. package/dist/types/src/plugin/recovery/constants.d.ts +22 -0
  619. package/dist/types/src/plugin/recovery/constants.d.ts.map +1 -0
  620. package/dist/types/src/plugin/recovery/storage.d.ts +24 -0
  621. package/dist/types/src/plugin/recovery/storage.d.ts.map +1 -0
  622. package/dist/types/src/plugin/recovery/types.d.ts +116 -0
  623. package/dist/types/src/plugin/recovery/types.d.ts.map +1 -0
  624. package/dist/types/src/plugin/recovery.d.ts +61 -0
  625. package/dist/types/src/plugin/recovery.d.ts.map +1 -0
  626. package/dist/types/src/plugin/refresh-queue.d.ts +133 -0
  627. package/dist/types/src/plugin/refresh-queue.d.ts.map +1 -0
  628. package/dist/types/src/plugin/request-helpers.d.ts +304 -0
  629. package/dist/types/src/plugin/request-helpers.d.ts.map +1 -0
  630. package/dist/types/src/plugin/request.d.ts +161 -0
  631. package/dist/types/src/plugin/request.d.ts.map +1 -0
  632. package/dist/types/src/plugin/rotation.d.ts +2 -0
  633. package/dist/types/src/plugin/rotation.d.ts.map +1 -0
  634. package/dist/types/src/plugin/search.d.ts +25 -0
  635. package/dist/types/src/plugin/search.d.ts.map +1 -0
  636. package/dist/types/src/plugin/server.d.ts +23 -0
  637. package/dist/types/src/plugin/server.d.ts.map +1 -0
  638. package/dist/types/src/plugin/session-context.d.ts +22 -0
  639. package/dist/types/src/plugin/session-context.d.ts.map +1 -0
  640. package/dist/types/src/plugin/shared/local-grant.d.ts +26 -0
  641. package/dist/types/src/plugin/shared/local-grant.d.ts.map +1 -0
  642. package/dist/types/src/plugin/shared/request-cancellation.d.ts +12 -0
  643. package/dist/types/src/plugin/shared/request-cancellation.d.ts.map +1 -0
  644. package/dist/types/src/plugin/shared/request-services.d.ts +375 -0
  645. package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -0
  646. package/dist/types/src/plugin/shared/runtime.d.ts +217 -0
  647. package/dist/types/src/plugin/shared/runtime.d.ts.map +1 -0
  648. package/dist/types/src/plugin/shared/source-sidebar.d.ts +15 -0
  649. package/dist/types/src/plugin/shared/source-sidebar.d.ts.map +1 -0
  650. package/dist/types/src/plugin/shared/vault-menu.d.ts +5 -0
  651. package/dist/types/src/plugin/shared/vault-menu.d.ts.map +1 -0
  652. package/dist/types/src/plugin/shared/vault-request-credentials.d.ts +168 -0
  653. package/dist/types/src/plugin/shared/vault-request-credentials.d.ts.map +1 -0
  654. package/dist/types/src/plugin/storage.d.ts +221 -0
  655. package/dist/types/src/plugin/storage.d.ts.map +1 -0
  656. package/dist/types/src/plugin/stores/signature-store.d.ts +5 -0
  657. package/dist/types/src/plugin/stores/signature-store.d.ts.map +1 -0
  658. package/dist/types/src/plugin/thinking-recovery.d.ts +90 -0
  659. package/dist/types/src/plugin/thinking-recovery.d.ts.map +1 -0
  660. package/dist/types/src/plugin/token.d.ts +41 -0
  661. package/dist/types/src/plugin/token.d.ts.map +1 -0
  662. package/dist/types/src/plugin/transform/cross-model-sanitizer.d.ts +2 -0
  663. package/dist/types/src/plugin/transform/cross-model-sanitizer.d.ts.map +1 -0
  664. package/dist/types/src/plugin/transform/index.d.ts +2 -0
  665. package/dist/types/src/plugin/transform/index.d.ts.map +1 -0
  666. package/dist/types/src/plugin/transform/model-resolver.d.ts +2 -0
  667. package/dist/types/src/plugin/transform/model-resolver.d.ts.map +1 -0
  668. package/dist/types/src/plugin/transform/types.d.ts +2 -0
  669. package/dist/types/src/plugin/transform/types.d.ts.map +1 -0
  670. package/dist/types/src/plugin/types.d.ts +36 -0
  671. package/dist/types/src/plugin/types.d.ts.map +1 -0
  672. package/dist/types/src/plugin/ui/ansi.d.ts +32 -0
  673. package/dist/types/src/plugin/ui/ansi.d.ts.map +1 -0
  674. package/dist/types/src/plugin/ui/auth-menu.d.ts +59 -0
  675. package/dist/types/src/plugin/ui/auth-menu.d.ts.map +1 -0
  676. package/dist/types/src/plugin/ui/confirm.d.ts +2 -0
  677. package/dist/types/src/plugin/ui/confirm.d.ts.map +1 -0
  678. package/dist/types/src/plugin/ui/quota-status.d.ts +73 -0
  679. package/dist/types/src/plugin/ui/quota-status.d.ts.map +1 -0
  680. package/dist/types/src/plugin/ui/select.d.ts +23 -0
  681. package/dist/types/src/plugin/ui/select.d.ts.map +1 -0
  682. package/dist/types/src/plugin/vault-activation.d.ts +11 -0
  683. package/dist/types/src/plugin/vault-activation.d.ts.map +1 -0
  684. package/dist/types/src/plugin/vault-custody.d.ts +131 -0
  685. package/dist/types/src/plugin/vault-custody.d.ts.map +1 -0
  686. package/dist/types/src/plugin/version.d.ts +2 -0
  687. package/dist/types/src/plugin/version.d.ts.map +1 -0
  688. package/dist/types/src/quota-presentation.d.ts +18 -0
  689. package/dist/types/src/quota-presentation.d.ts.map +1 -0
  690. package/dist/types/src/rpc/notifications.d.ts +6 -0
  691. package/dist/types/src/rpc/notifications.d.ts.map +1 -0
  692. package/dist/types/src/rpc/protocol.d.ts +53 -0
  693. package/dist/types/src/rpc/protocol.d.ts.map +1 -0
  694. package/dist/types/src/rpc/rpc-dir.d.ts +4 -0
  695. package/dist/types/src/rpc/rpc-dir.d.ts.map +1 -0
  696. package/dist/types/src/rpc/rpc-server.d.ts +24 -0
  697. package/dist/types/src/rpc/rpc-server.d.ts.map +1 -0
  698. package/dist/types/src/server.d.ts +30 -0
  699. package/dist/types/src/server.d.ts.map +1 -0
  700. package/dist/types/src/sidebar-state.d.ts +365 -0
  701. package/dist/types/src/sidebar-state.d.ts.map +1 -0
  702. package/dist/types/src/tui/host-api.d.ts +196 -0
  703. package/dist/types/src/tui/host-api.d.ts.map +1 -0
  704. package/package.json +45 -18
  705. package/server.js +6 -0
  706. package/src/common-auth-embedded/NOTICE.txt +21 -0
  707. package/src/common-auth-embedded/auth-menu/accounts.d.ts +97 -0
  708. package/src/common-auth-embedded/auth-menu/accounts.js +387 -0
  709. package/src/common-auth-embedded/auth-menu/ansi.d.ts +26 -0
  710. package/src/common-auth-embedded/auth-menu/ansi.js +98 -0
  711. package/src/common-auth-embedded/auth-menu/confirm.d.ts +7 -0
  712. package/src/common-auth-embedded/auth-menu/confirm.js +21 -0
  713. package/src/common-auth-embedded/auth-menu/doctor.d.ts +52 -0
  714. package/src/common-auth-embedded/auth-menu/doctor.js +81 -0
  715. package/src/common-auth-embedded/auth-menu/index.d.ts +17 -0
  716. package/src/common-auth-embedded/auth-menu/index.js +12 -0
  717. package/src/common-auth-embedded/auth-menu/login.d.ts +55 -0
  718. package/src/common-auth-embedded/auth-menu/login.js +83 -0
  719. package/src/common-auth-embedded/auth-menu/menu.d.ts +59 -0
  720. package/src/common-auth-embedded/auth-menu/menu.js +73 -0
  721. package/src/common-auth-embedded/auth-menu/opencode-v1.d.ts +49 -0
  722. package/src/common-auth-embedded/auth-menu/opencode-v1.js +47 -0
  723. package/src/common-auth-embedded/auth-menu/select.d.ts +21 -0
  724. package/src/common-auth-embedded/auth-menu/select.js +159 -0
  725. package/src/common-auth-embedded/auth-menu/terminal.d.ts +43 -0
  726. package/src/common-auth-embedded/auth-menu/terminal.js +19 -0
  727. package/src/common-auth-embedded/claustrum/consumer.d.ts +102 -0
  728. package/src/common-auth-embedded/claustrum/consumer.js +298 -0
  729. package/src/common-auth-embedded/claustrum/custody.d.ts +175 -0
  730. package/src/common-auth-embedded/claustrum/custody.js +354 -0
  731. package/src/common-auth-embedded/claustrum/enrollment.d.ts +158 -0
  732. package/src/common-auth-embedded/claustrum/enrollment.js +759 -0
  733. package/src/common-auth-embedded/claustrum/errors.d.ts +16 -0
  734. package/src/common-auth-embedded/claustrum/errors.js +8 -0
  735. package/src/common-auth-embedded/claustrum/host-slot.d.ts +39 -0
  736. package/src/common-auth-embedded/claustrum/host-slot.js +72 -0
  737. package/src/common-auth-embedded/claustrum/index.d.ts +18 -0
  738. package/src/common-auth-embedded/claustrum/index.js +22 -0
  739. package/src/common-auth-embedded/claustrum/interlock.d.ts +27 -0
  740. package/src/common-auth-embedded/claustrum/interlock.js +29 -0
  741. package/src/common-auth-embedded/claustrum/roster.d.ts +208 -0
  742. package/src/common-auth-embedded/claustrum/roster.js +536 -0
  743. package/src/common-auth-embedded/commands/builtins.d.ts +71 -0
  744. package/src/common-auth-embedded/commands/builtins.js +534 -0
  745. package/src/common-auth-embedded/commands/index.d.ts +10 -0
  746. package/src/common-auth-embedded/commands/index.js +5 -0
  747. package/src/common-auth-embedded/commands/menu.d.ts +61 -0
  748. package/src/common-auth-embedded/commands/menu.js +300 -0
  749. package/src/common-auth-embedded/commands/model.d.ts +238 -0
  750. package/src/common-auth-embedded/commands/model.js +16 -0
  751. package/src/common-auth-embedded/commands/pi.d.ts +23 -0
  752. package/src/common-auth-embedded/commands/pi.js +206 -0
  753. package/src/common-auth-embedded/commands/seam.d.ts +72 -0
  754. package/src/common-auth-embedded/commands/seam.js +301 -0
  755. package/src/common-auth-embedded/fs/atomic-write.d.ts +20 -0
  756. package/src/common-auth-embedded/fs/atomic-write.js +80 -0
  757. package/src/common-auth-embedded/fs/index.d.ts +7 -0
  758. package/src/common-auth-embedded/fs/index.js +6 -0
  759. package/src/common-auth-embedded/fs/lock-constants.d.ts +14 -0
  760. package/src/common-auth-embedded/fs/lock-constants.js +14 -0
  761. package/src/common-auth-embedded/fs/refresh-file-lock.d.ts +33 -0
  762. package/src/common-auth-embedded/fs/refresh-file-lock.js +501 -0
  763. package/src/common-auth-embedded/fs/with-lock.d.ts +33 -0
  764. package/src/common-auth-embedded/fs/with-lock.js +48 -0
  765. package/src/common-auth-embedded/logger/capture-sink.d.ts +14 -0
  766. package/src/common-auth-embedded/logger/capture-sink.js +13 -0
  767. package/src/common-auth-embedded/logger/engine.d.ts +100 -0
  768. package/src/common-auth-embedded/logger/engine.js +246 -0
  769. package/src/common-auth-embedded/logger/index.d.ts +6 -0
  770. package/src/common-auth-embedded/logger/index.js +3 -0
  771. package/src/common-auth-embedded/logger/redact.d.ts +11 -0
  772. package/src/common-auth-embedded/logger/redact.js +83 -0
  773. package/src/common-auth-embedded/opencode2/errors.d.ts +25 -0
  774. package/src/common-auth-embedded/opencode2/errors.js +15 -0
  775. package/src/common-auth-embedded/opencode2/index.d.ts +8 -0
  776. package/src/common-auth-embedded/opencode2/index.js +4 -0
  777. package/src/common-auth-embedded/opencode2/install.d.ts +55 -0
  778. package/src/common-auth-embedded/opencode2/install.js +886 -0
  779. package/src/common-auth-embedded/opencode2/integration.d.ts +112 -0
  780. package/src/common-auth-embedded/opencode2/integration.js +143 -0
  781. package/src/common-auth-embedded/opencode2/sse.d.ts +12 -0
  782. package/src/common-auth-embedded/opencode2/sse.js +60 -0
  783. package/src/common-auth-embedded/opencode2/types.d.ts +413 -0
  784. package/src/common-auth-embedded/pi-slot/index.d.ts +3 -0
  785. package/src/common-auth-embedded/pi-slot/index.js +2 -0
  786. package/src/common-auth-embedded/pi-slot/lock.js +212 -0
  787. package/src/common-auth-embedded/pi-slot/slot.d.ts +49 -0
  788. package/src/common-auth-embedded/pi-slot/slot.js +383 -0
  789. package/src/common-auth-embedded/quota/codec.d.ts +11 -0
  790. package/src/common-auth-embedded/quota/codec.js +12 -0
  791. package/src/common-auth-embedded/quota/format.d.ts +46 -0
  792. package/src/common-auth-embedded/quota/format.js +138 -0
  793. package/src/common-auth-embedded/quota/index.d.ts +10 -0
  794. package/src/common-auth-embedded/quota/index.js +5 -0
  795. package/src/common-auth-embedded/quota/map.d.ts +63 -0
  796. package/src/common-auth-embedded/quota/map.js +105 -0
  797. package/src/common-auth-embedded/quota/merge.d.ts +48 -0
  798. package/src/common-auth-embedded/quota/merge.js +162 -0
  799. package/src/common-auth-embedded/quota/projection.d.ts +64 -0
  800. package/src/common-auth-embedded/quota/projection.js +134 -0
  801. package/src/common-auth-embedded/routing/admission.d.ts +93 -0
  802. package/src/common-auth-embedded/routing/admission.js +142 -0
  803. package/src/common-auth-embedded/routing/index.d.ts +8 -0
  804. package/src/common-auth-embedded/routing/index.js +4 -0
  805. package/src/common-auth-embedded/routing/ordered.d.ts +47 -0
  806. package/src/common-auth-embedded/routing/ordered.js +58 -0
  807. package/src/common-auth-embedded/routing/pins.d.ts +22 -0
  808. package/src/common-auth-embedded/routing/pins.js +34 -0
  809. package/src/common-auth-embedded/routing/sticky.d.ts +158 -0
  810. package/src/common-auth-embedded/routing/sticky.js +339 -0
  811. package/src/common-auth-embedded/rpc/client.d.ts +3 -0
  812. package/src/common-auth-embedded/rpc/client.js +2 -0
  813. package/src/common-auth-embedded/rpc/index.d.ts +10 -0
  814. package/src/common-auth-embedded/rpc/index.js +5 -0
  815. package/src/common-auth-embedded/rpc/notifications.d.ts +73 -0
  816. package/src/common-auth-embedded/rpc/notifications.js +100 -0
  817. package/src/common-auth-embedded/rpc/port-file.d.ts +33 -0
  818. package/src/common-auth-embedded/rpc/port-file.js +217 -0
  819. package/src/common-auth-embedded/rpc/rpc-client.d.ts +30 -0
  820. package/src/common-auth-embedded/rpc/rpc-client.js +253 -0
  821. package/src/common-auth-embedded/rpc/rpc-server.d.ts +58 -0
  822. package/src/common-auth-embedded/rpc/rpc-server.js +311 -0
  823. package/src/common-auth-embedded/rpc/server-registry.d.ts +11 -0
  824. package/src/common-auth-embedded/rpc/server-registry.js +47 -0
  825. package/src/common-auth-embedded/source-output.json +1326 -0
  826. package/src/common-auth-embedded/store/attribution.d.ts +28 -0
  827. package/src/common-auth-embedded/store/attribution.js +60 -0
  828. package/src/common-auth-embedded/store/errors.d.ts +55 -0
  829. package/src/common-auth-embedded/store/errors.js +38 -0
  830. package/src/common-auth-embedded/store/hooks.d.ts +12 -0
  831. package/src/common-auth-embedded/store/hooks.js +34 -0
  832. package/src/common-auth-embedded/store/identity.d.ts +39 -0
  833. package/src/common-auth-embedded/store/identity.js +79 -0
  834. package/src/common-auth-embedded/store/index.d.ts +21 -0
  835. package/src/common-auth-embedded/store/index.js +7 -0
  836. package/src/common-auth-embedded/store/mutate.d.ts +189 -0
  837. package/src/common-auth-embedded/store/mutate.js +500 -0
  838. package/src/common-auth-embedded/store/pool.d.ts +196 -0
  839. package/src/common-auth-embedded/store/pool.js +120 -0
  840. package/src/common-auth-embedded/store/provider-state.d.ts +131 -0
  841. package/src/common-auth-embedded/store/provider-state.js +226 -0
  842. package/src/common-auth-embedded/store/publication.d.ts +47 -0
  843. package/src/common-auth-embedded/store/publication.js +304 -0
  844. package/src/common-auth-embedded/store/pull.d.ts +36 -0
  845. package/src/common-auth-embedded/store/pull.js +143 -0
  846. package/src/common-auth-embedded/store/refresh-lock.d.ts +63 -0
  847. package/src/common-auth-embedded/store/refresh-lock.js +136 -0
  848. package/src/common-auth-embedded/store/refresh.d.ts +72 -0
  849. package/src/common-auth-embedded/store/refresh.js +225 -0
  850. package/src/common-auth-embedded/store/reserved.js +13 -0
  851. package/src/common-auth-embedded/store/rows.d.ts +313 -0
  852. package/src/common-auth-embedded/store/rows.js +1258 -0
  853. package/src/common-auth-embedded/store/runtime.d.ts +36 -0
  854. package/src/common-auth-embedded/store/runtime.js +68 -0
  855. package/src/common-auth-embedded/store/schema.d.ts +443 -0
  856. package/src/common-auth-embedded/store/schema.js +754 -0
  857. package/src/common-auth-embedded/store/settings.d.ts +63 -0
  858. package/src/common-auth-embedded/store/settings.js +120 -0
  859. package/src/common-auth-embedded/store/torn.d.ts +78 -0
  860. package/src/common-auth-embedded/store/torn.js +294 -0
  861. package/src/common-auth-embedded/tui/index.d.ts +8 -0
  862. package/src/common-auth-embedded/tui/index.js +21 -0
  863. package/src/common-auth-embedded/util/any-signal.js +42 -0
  864. package/src/plugin/command-data.ts +3 -0
  865. package/src/rpc/port-file.ts +6 -140
  866. package/src/rpc/protocol.ts +59 -24
  867. package/src/rpc/rpc-client.ts +101 -71
  868. package/src/sidebar-state.ts +82 -24
  869. package/src/tui/command-dialogs.tsx +412 -776
  870. package/src/tui/entry.d.mts +17 -0
  871. package/src/tui/entry.mjs +34 -66
  872. package/src/tui/file-logger.ts +22 -7
  873. package/src/tui-compiled/common-auth-embedded/logger/capture-sink.js +13 -0
  874. package/src/tui-compiled/common-auth-embedded/logger/engine.js +246 -0
  875. package/src/tui-compiled/common-auth-embedded/logger/index.js +3 -0
  876. package/src/tui-compiled/common-auth-embedded/logger/redact.js +83 -0
  877. package/src/tui-compiled/common-auth-embedded/quota/codec.js +12 -0
  878. package/src/tui-compiled/common-auth-embedded/quota/format.js +138 -0
  879. package/src/tui-compiled/common-auth-embedded/quota/index.js +5 -0
  880. package/src/tui-compiled/common-auth-embedded/quota/map.js +105 -0
  881. package/src/tui-compiled/common-auth-embedded/quota/merge.js +162 -0
  882. package/src/tui-compiled/common-auth-embedded/quota/projection.js +134 -0
  883. package/src/tui-compiled/common-auth-embedded/rpc/client.js +2 -0
  884. package/src/tui-compiled/common-auth-embedded/rpc/port-file.js +217 -0
  885. package/src/tui-compiled/common-auth-embedded/rpc/rpc-client.js +253 -0
  886. package/src/tui-compiled/logging/provider-key-policy.js +3 -0
  887. package/src/tui-compiled/quota-presentation.js +42 -0
  888. package/src/tui-compiled/rpc/rpc-client.js +35 -0
  889. package/src/tui-compiled/rpc/rpc-dir.js +13 -0
  890. package/src/tui-compiled/selector.js +21 -0
  891. package/src/tui-compiled/sidebar-state.js +401 -0
  892. package/src/tui-compiled/tui/command-dialogs.js +424 -0
  893. package/src/tui-compiled/tui/file-logger.js +73 -0
  894. package/src/tui-compiled/tui/host-api.js +269 -0
  895. package/src/tui-compiled/tui/host-v1.js +228 -0
  896. package/src/tui-compiled/tui-preferences.js +230 -0
  897. package/src/tui-compiled/{tui.tsx → tui.js} +140 -231
  898. package/src/tui-ga-compiled/host-ga.js +1304 -0
  899. package/src/tui-ga-compiled/selector.js +21 -0
  900. package/src/tui-ga-compiled/shared/07365a7d2ccade4c-host-api.js +269 -0
  901. package/src/tui-ga-compiled/shared/0e19a88ff3535906-command-dialogs.js +424 -0
  902. package/src/tui-ga-compiled/shared/1ff34afa7c42d196-projection.js +134 -0
  903. package/src/tui-ga-compiled/shared/77138df80c7ae006-map.js +105 -0
  904. package/src/tui-ga-compiled/shared/8ae1927e5910ea81-sidebar-projection.js +112 -0
  905. package/src/tui-ga-compiled/shared/98cc0c186c46c42d-quota-presentation.js +42 -0
  906. package/src/tui-ga-compiled/shared/aef2402f8fc342f0-format.js +138 -0
  907. package/src/tui-ga-compiled/shared/bf17cbee28e58197-index.js +5 -0
  908. package/src/tui-ga-compiled/shared/ca21dc417b36dc5d-codec.js +12 -0
  909. package/src/tui-ga-compiled/shared/ecc214300932dfb6-merge.js +162 -0
  910. package/src/tui-ga-raw/host-ga.tsx +1740 -0
  911. package/src/tui-ga-raw/selector.js +21 -0
  912. package/src/tui-ga-raw/shared/07365a7d2ccade4c-host-api.js +269 -0
  913. package/src/tui-ga-raw/shared/0e19a88ff3535906-command-dialogs.tsx +468 -0
  914. package/src/tui-ga-raw/shared/1ff34afa7c42d196-projection.js +134 -0
  915. package/src/tui-ga-raw/shared/77138df80c7ae006-map.js +105 -0
  916. package/src/tui-ga-raw/shared/8ae1927e5910ea81-sidebar-projection.js +112 -0
  917. package/src/tui-ga-raw/shared/98cc0c186c46c42d-quota-presentation.js +42 -0
  918. package/src/tui-ga-raw/shared/aef2402f8fc342f0-format.js +138 -0
  919. package/src/tui-ga-raw/shared/bf17cbee28e58197-index.js +5 -0
  920. package/src/tui-ga-raw/shared/ca21dc417b36dc5d-codec.js +12 -0
  921. package/src/tui-ga-raw/shared/ecc214300932dfb6-merge.js +162 -0
  922. package/src/tui-raw/common-auth-embedded/logger/capture-sink.js +13 -0
  923. package/src/tui-raw/common-auth-embedded/logger/engine.js +246 -0
  924. package/src/tui-raw/common-auth-embedded/logger/index.js +3 -0
  925. package/src/tui-raw/common-auth-embedded/logger/redact.js +83 -0
  926. package/src/tui-raw/common-auth-embedded/quota/codec.js +12 -0
  927. package/src/tui-raw/common-auth-embedded/quota/format.js +138 -0
  928. package/src/tui-raw/common-auth-embedded/quota/index.js +5 -0
  929. package/src/tui-raw/common-auth-embedded/quota/map.js +105 -0
  930. package/src/tui-raw/common-auth-embedded/quota/merge.js +162 -0
  931. package/src/tui-raw/common-auth-embedded/quota/projection.js +134 -0
  932. package/src/tui-raw/common-auth-embedded/rpc/client.js +2 -0
  933. package/src/tui-raw/common-auth-embedded/rpc/port-file.js +217 -0
  934. package/src/tui-raw/common-auth-embedded/rpc/rpc-client.js +253 -0
  935. package/src/tui-raw/logging/provider-key-policy.js +3 -0
  936. package/src/tui-raw/quota-presentation.js +42 -0
  937. package/src/tui-raw/rpc/rpc-client.js +35 -0
  938. package/src/tui-raw/rpc/rpc-dir.js +13 -0
  939. package/src/tui-raw/selector.js +21 -0
  940. package/src/tui-raw/sidebar-state.js +401 -0
  941. package/src/tui-raw/tui/command-dialogs.tsx +468 -0
  942. package/src/tui-raw/tui/file-logger.js +73 -0
  943. package/src/tui-raw/tui/host-api.js +269 -0
  944. package/src/tui-raw/tui/host-v1.tsx +249 -0
  945. package/src/tui-raw/tui-preferences.js +230 -0
  946. package/src/tui-raw/tui.tsx +1088 -0
  947. package/src/tui.tsx +58 -141
  948. package/tui.js +6 -0
  949. package/src/tui-compiled/plugin/command-data.ts +0 -931
  950. package/src/tui-compiled/rpc/port-file.ts +0 -143
  951. package/src/tui-compiled/rpc/protocol.ts +0 -31
  952. package/src/tui-compiled/rpc/rpc-client.ts +0 -102
  953. package/src/tui-compiled/rpc/rpc-dir.ts +0 -24
  954. package/src/tui-compiled/sidebar-state.ts +0 -991
  955. package/src/tui-compiled/tui/command-dialogs.tsx +0 -779
  956. package/src/tui-compiled/tui/file-logger.ts +0 -145
  957. package/src/tui-compiled/tui-preferences.ts +0 -416
@@ -0,0 +1,1838 @@
1
+ /**
2
+ * The OpenCode 2 (GA host) location services: account state for the
3
+ * `antigravity-auth` RPC `state` method, the shared `/antigravity` menu
4
+ * behind `apply`, and `createGaLocationServicesFactory`, which builds a
5
+ * location's services from the bound account repository and the shared
6
+ * request pipeline.
7
+ *
8
+ * Accounts come from the location's account repository, read once per
9
+ * `state` call. Each account in a state answer carries an opaque selector: a
10
+ * random string issued for one exact credential (row id, credential epoch
11
+ * and recorded identity), kept across reads and reorders and retired when
12
+ * that credential is replaced, re-identified or removed. Account actions run
13
+ * through the shared menu, whose own opaque item ids are bound the same way;
14
+ * an account position is never accepted as a target.
15
+ *
16
+ * Everything a location needs (repository, settings controller, dump switch,
17
+ * logger) arrives explicitly; nothing here reads a process-global binding.
18
+ * The GA server module is imported for types only, so it can import this
19
+ * module's factory without a cycle.
20
+ */
21
+ import { randomBytes } from 'node:crypto';
22
+ import { ANTIGRAVITY_MENU_COMMAND, antigravitySettingsSections, authorizeAntigravity, createAccountRepositoryFactory, createAntigravityCommandMenu, ensureProjectContext, exchangeAntigravity, fetchWithAgyCliTransport, formatRefreshParts, loadCommonAuthCommands, loadCommonAuthStoreModules, parseRefreshParts, readAccountStoreAdmission, readAccountStoreBinding, refreshAntigravityToken, rowRefKey, sameRowRef, VAULT_ACCOUNT_REMEDY, } from '@cortexkit/antigravity-auth-core';
23
+ import { createRepositoryAccountAccessService, extractAccountAccessErrorDetails, } from "./account-access.js";
24
+ import { createLocalAccountCredentials, loadAccountManagerFromRepository, } from "./accounts.js";
25
+ import { createStoreAccountLimits, diagnosticsMenuSection, operatorMenuSettings, } from "./command-apply.js";
26
+ import { createAuthorizedFetchAccountQuota, createStoreQuotaService, } from "./quota.js";
27
+ import { buildThinkingWarmupBody, getImageModelLocalTitle, getLastCacheStats, prepareAntigravityRequest, transformAntigravityResponse, } from "./request.js";
28
+ import { startOAuthListener } from "./server.js";
29
+ import { AgySessionRegistry } from "./session-context.js";
30
+ import { createLocalQuotaRefresh, createRequestExecutor, } from "./shared/request-services.js";
31
+ import { createMemoryQuotaSnapshots, } from "./shared/runtime.js";
32
+ import { createVaultAccountMenuSections } from './shared/vault-menu';
33
+ import { checkVaultQuota, createVaultAccountPool, vaultAccountRowKey, } from "./shared/vault-request-credentials.js";
34
+ import { getStoragePath } from './storage';
35
+ import { createOpenCodeVaultCustody, } from "./vault-custody.js";
36
+ /** Accounts one `state` answer may carry (`ANTIGRAVITY_RPC_LIMITS.accounts`). */
37
+ const ACCOUNT_LIMIT = 64;
38
+ /**
39
+ * How many retired selectors are remembered so a late action on one is
40
+ * answered `stale-target` rather than `unknown-target`. Older ones are
41
+ * forgotten and then answered `unknown-target`; neither outcome writes.
42
+ */
43
+ const RETIRED_SELECTOR_MEMORY = 256;
44
+ /**
45
+ * 192 random bits as `sel-` plus 32 URL-safe characters, the selector shape
46
+ * the RPC contract accepts; carries no account data.
47
+ */
48
+ function defaultSelector() {
49
+ return `sel-${randomBytes(24).toString('base64url')}`;
50
+ }
51
+ export function createGaSelectorRegistry(createSelector = defaultSelector) {
52
+ /** Live selectors by exact ref key, and the ref each selector names. */
53
+ const live = new Map();
54
+ const liveRefs = new Map();
55
+ /** Retired selectors in retirement order (oldest first). */
56
+ const retired = new Map();
57
+ const issued = new Set();
58
+ const fresh = () => {
59
+ for (;;) {
60
+ const selector = createSelector();
61
+ if (!issued.has(selector))
62
+ return selector;
63
+ }
64
+ };
65
+ return {
66
+ plan(refs) {
67
+ const additions = new Map();
68
+ const selectors = refs.map((ref) => {
69
+ const key = rowRefKey(ref);
70
+ const existing = live.get(key) ?? additions.get(key)?.selector;
71
+ if (existing !== undefined)
72
+ return existing;
73
+ const selector = fresh();
74
+ additions.set(key, { selector, ref });
75
+ return selector;
76
+ });
77
+ const keep = new Set(refs.map((ref) => rowRefKey(ref)));
78
+ let committed = false;
79
+ return {
80
+ selectors,
81
+ commit() {
82
+ if (committed)
83
+ return [];
84
+ committed = true;
85
+ const retiredNow = [];
86
+ for (const [key, selector] of live) {
87
+ if (keep.has(key))
88
+ continue;
89
+ const ref = liveRefs.get(selector);
90
+ live.delete(key);
91
+ liveRefs.delete(selector);
92
+ if (ref !== undefined)
93
+ retired.set(selector, ref);
94
+ retiredNow.push(selector);
95
+ }
96
+ for (const [key, entry] of additions) {
97
+ if (live.has(key))
98
+ continue;
99
+ issued.add(entry.selector);
100
+ live.set(key, entry.selector);
101
+ liveRefs.set(entry.selector, entry.ref);
102
+ }
103
+ while (retired.size > RETIRED_SELECTOR_MEMORY) {
104
+ const oldest = retired.keys().next().value;
105
+ if (oldest === undefined)
106
+ break;
107
+ retired.delete(oldest);
108
+ }
109
+ return retiredNow;
110
+ },
111
+ };
112
+ },
113
+ resolve(selector) {
114
+ const ref = liveRefs.get(selector);
115
+ if (ref !== undefined)
116
+ return { kind: 'live', ref };
117
+ const old = retired.get(selector);
118
+ if (old !== undefined)
119
+ return { kind: 'retired', ref: old };
120
+ return { kind: 'unknown' };
121
+ },
122
+ };
123
+ }
124
+ function routingSlotsOf(read, ref) {
125
+ const routing = read.routing;
126
+ if (routing === undefined)
127
+ return [];
128
+ const slots = [];
129
+ if (routing.activeRow && sameRowRef(routing.activeRow, ref))
130
+ slots.push('active');
131
+ const byFamily = routing.activeRowByFamily;
132
+ if (byFamily?.claude && sameRowRef(byFamily.claude, ref))
133
+ slots.push('claude');
134
+ if (byFamily?.gemini && sameRowRef(byFamily.gemini, ref))
135
+ slots.push('gemini');
136
+ return slots;
137
+ }
138
+ function metadataStatusOf(row) {
139
+ const view = row.metadata;
140
+ if (view.status === 'present')
141
+ return 'present';
142
+ if (view.status === 'absent')
143
+ return 'absent';
144
+ return view.reason === 'uncovered' ? 'dropped-uncovered' : 'dropped-invalid';
145
+ }
146
+ /**
147
+ * The access block the row's metadata records. Absent or dropped metadata
148
+ * cannot rule a block out, so it is `unknown`, never `none`.
149
+ */
150
+ export function accessBlockOf(row) {
151
+ if (row.metadata.status !== 'present')
152
+ return { kind: 'unknown' };
153
+ const metadata = row.metadata.metadata;
154
+ const verification = metadata.verificationRequired;
155
+ const ineligible = metadata.accountIneligible;
156
+ const flag = (value) => value === undefined || value === null || typeof value === 'boolean';
157
+ if (!flag(verification) || !flag(ineligible))
158
+ return { kind: 'invalid' };
159
+ if (verification === true && ineligible === true)
160
+ return { kind: 'invalid' };
161
+ if (verification === true) {
162
+ const reason = metadata.verificationRequiredReason;
163
+ return {
164
+ kind: 'verification-required',
165
+ reason: reason === undefined || reason === null
166
+ ? 'unrecorded'
167
+ : reason === 'validation-required'
168
+ ? 'validation-required'
169
+ : 'other',
170
+ };
171
+ }
172
+ if (ineligible === true) {
173
+ const reason = metadata.accountIneligibleReason;
174
+ return {
175
+ kind: 'ineligible',
176
+ reason: reason === undefined || reason === null
177
+ ? 'unrecorded'
178
+ : reason === 'account-ineligible'
179
+ ? 'account-ineligible'
180
+ : 'other',
181
+ };
182
+ }
183
+ return { kind: 'none' };
184
+ }
185
+ function cooldownOf(row) {
186
+ if (row.metadata.status !== 'present')
187
+ return null;
188
+ const until = row.metadata.metadata.coolingDownUntil;
189
+ return typeof until === 'number' ? until : null;
190
+ }
191
+ function quotaOf(row) {
192
+ if (row.quota.status !== 'present')
193
+ return undefined;
194
+ const groups = row.quota.quota.cachedQuota;
195
+ if (!groups)
196
+ return undefined;
197
+ const out = {};
198
+ for (const [key, group] of Object.entries(groups)) {
199
+ out[key] = {
200
+ ...(typeof group.remainingFraction === 'number'
201
+ ? { remainingFraction: group.remainingFraction }
202
+ : {}),
203
+ ...(typeof group.resetTime === 'string'
204
+ ? { resetTime: group.resetTime }
205
+ : {}),
206
+ modelCount: group.modelCount,
207
+ ...(group.windows
208
+ ? {
209
+ windows: group.windows.map((window) => ({
210
+ window: window.window,
211
+ remainingFraction: window.remainingFraction,
212
+ resetTime: window.resetTime,
213
+ })),
214
+ }
215
+ : {}),
216
+ };
217
+ }
218
+ return out;
219
+ }
220
+ function tierOf(row) {
221
+ if (row.metadata.status !== 'present')
222
+ return undefined;
223
+ const metadata = row.metadata.metadata;
224
+ if (typeof metadata.capturedTierId !== 'string' ||
225
+ typeof metadata.capturedTierAt !== 'number')
226
+ return undefined;
227
+ return {
228
+ id: metadata.capturedTierId,
229
+ ...(typeof metadata.capturedPaidTierId === 'string'
230
+ ? { paidId: metadata.capturedPaidTierId }
231
+ : {}),
232
+ capturedAt: metadata.capturedTierAt,
233
+ };
234
+ }
235
+ /**
236
+ * The redaction input for one row: position, flags, cooldown, quota and
237
+ * tier. It carries no email, label, token, project, identity or row id.
238
+ */
239
+ function redactionInputOf(row, position, current, health) {
240
+ const cooldown = cooldownOf(row);
241
+ const quota = quotaOf(row);
242
+ const tier = tierOf(row);
243
+ const score = health(row);
244
+ return {
245
+ index: position,
246
+ enabled: row.enabled,
247
+ current,
248
+ ...(cooldown !== null ? { coolingDownUntil: cooldown } : {}),
249
+ ...(score !== undefined ? { healthScore: score } : {}),
250
+ ...(quota !== undefined ? { cachedQuota: quota } : {}),
251
+ ...(row.quota.status === 'present' &&
252
+ typeof row.quota.quota.cachedQuotaUpdatedAt === 'number'
253
+ ? { cachedQuotaUpdatedAt: row.quota.quota.cachedQuotaUpdatedAt }
254
+ : {}),
255
+ ...(tier !== undefined ? { tier } : {}),
256
+ };
257
+ }
258
+ // ---------------------------------------------------------------------------
259
+ // Settings
260
+ // ---------------------------------------------------------------------------
261
+ /**
262
+ * The settings DTO from the location's live controller and dump switch. It
263
+ * only reads; per-account killswitch overrides stay out because their keys
264
+ * derive from refresh tokens.
265
+ */
266
+ export function gaSettingsOf(settings, dump) {
267
+ return {
268
+ routing: {
269
+ cliFirst: settings.routing.cli_first,
270
+ quotaStyleFallback: settings.routing.quota_style_fallback,
271
+ },
272
+ killswitch: {
273
+ enabled: settings.killswitch.enabled,
274
+ minimumRemainingPercent: settings.killswitch.minimum_remaining_percent,
275
+ },
276
+ logLevel: settings.log_level,
277
+ dump: { enabled: dump.isEnabled() },
278
+ };
279
+ }
280
+ function project(read, registry, health) {
281
+ if (read.status !== 'ready') {
282
+ return { read, rows: [], overLimit: null, plan: null };
283
+ }
284
+ if (read.rows.length > ACCOUNT_LIMIT) {
285
+ return { read, rows: [], overLimit: read.rows.length, plan: null };
286
+ }
287
+ const plan = registry.plan(read.rows.map((row) => row.ref));
288
+ const rows = read.rows.map((row, position) => {
289
+ const slots = routingSlotsOf(read, row.ref);
290
+ return {
291
+ selector: plan.selectors[position] ?? '',
292
+ row: redactionInputOf(row, position, slots.includes('active'), health),
293
+ source: row,
294
+ slots,
295
+ };
296
+ });
297
+ return { read, rows, overLimit: null, plan };
298
+ }
299
+ function abortError(signal) {
300
+ return signal.reason instanceof Error
301
+ ? signal.reason
302
+ : new Error('The state read was aborted');
303
+ }
304
+ /**
305
+ * Builds the `state` source. Reads run one at a time, so `readSeq` follows
306
+ * the order answers are built in; an aborted read leaves the selector
307
+ * registry unchanged. The diagnostic observer, when present, is called
308
+ * synchronously with a view of the same read.
309
+ */
310
+ export function createGaAccountStateSource(options) {
311
+ let readSeq = 0;
312
+ let queue = Promise.resolve();
313
+ const health = options.health ?? (() => undefined);
314
+ const readOnce = async (input) => {
315
+ if (input.signal.aborted)
316
+ throw abortError(input.signal);
317
+ const read = await options.repository.read();
318
+ if (input.signal.aborted)
319
+ throw abortError(input.signal);
320
+ const projected = project(read, options.registry, health);
321
+ const settings = options.settings();
322
+ const status = options.status();
323
+ const route = options.route(input.scope);
324
+ if (input.signal.aborted)
325
+ throw abortError(input.signal);
326
+ const retiredSelectors = projected.plan?.commit() ?? [];
327
+ readSeq = options.nextReadSeq?.() ?? readSeq + 1;
328
+ const answer = {
329
+ readSeq,
330
+ accounts: projected.overLimit !== null
331
+ ? { kind: 'over-limit', count: projected.overLimit }
332
+ : {
333
+ kind: 'complete',
334
+ rows: projected.rows.map(({ selector, row }) => ({
335
+ selector,
336
+ row,
337
+ })),
338
+ },
339
+ route,
340
+ status,
341
+ settings,
342
+ };
343
+ if (options.observe) {
344
+ const accounts = projected.rows.map(({ selector, source, slots }, position) => ({
345
+ selector,
346
+ position,
347
+ enabled: source.enabled,
348
+ usable: source.usable,
349
+ metadataStatus: metadataStatusOf(source),
350
+ accessBlock: accessBlockOf(source),
351
+ currentFor: slots,
352
+ cooldownUntil: cooldownOf(source),
353
+ }));
354
+ try {
355
+ options.observe({
356
+ generation: options.generation,
357
+ readSeq,
358
+ status: read.status,
359
+ accountsStatus: projected.overLimit !== null ? 'over-limit' : 'complete',
360
+ accounts,
361
+ retiredSelectors,
362
+ });
363
+ }
364
+ catch {
365
+ // A diagnostic observer cannot change the answer.
366
+ }
367
+ }
368
+ return answer;
369
+ };
370
+ return {
371
+ read(input) {
372
+ const next = queue.then(() => readOnce(input), () => readOnce(input));
373
+ queue = next.catch(() => undefined);
374
+ return next;
375
+ },
376
+ };
377
+ }
378
+ /**
379
+ * The location's `/antigravity` menu: the shared core menu in repository
380
+ * mode over this activation's repository and runtime. Accounts are acted on
381
+ * by the menu's own opaque item ids, each bound to one exact credential;
382
+ * Routing, Limits and Diagnostics read and write this location's settings
383
+ * controller and dump switch. `commands` must be the module whose
384
+ * `parseApplyRequest` the RPC activation uses.
385
+ */
386
+ export function createGaLocationMenu(input) {
387
+ const runtime = input.runtime;
388
+ return createAntigravityCommandMenu({
389
+ source: 'repository',
390
+ commands: input.commands,
391
+ accounts: input.repository,
392
+ settings: operatorMenuSettings(runtime.operatorSettings),
393
+ diagnostics: diagnosticsMenuSection({
394
+ settings: runtime.operatorSettings,
395
+ dump: runtime.dump,
396
+ applyLogLevel: () => runtime.applyOperatorSettings(),
397
+ }),
398
+ accountLimits: createStoreAccountLimits({
399
+ repository: input.repository,
400
+ settings: runtime.operatorSettings,
401
+ }),
402
+ ...(input.refreshQuota ? { refreshQuota: input.refreshQuota } : {}),
403
+ ...(input.reauthorize ? { reauthorize: input.reauthorize } : {}),
404
+ ...(input.vault ? { extras: [input.vault] } : {}),
405
+ });
406
+ }
407
+ /** The menu invocation for one RPC scope; its notices are queued there. */
408
+ function scopeInvocation(scope, notify) {
409
+ return {
410
+ ...(scope.kind === 'session' ? { sessionId: scope.sessionID } : {}),
411
+ notify(message, kind) {
412
+ notify(scope, {
413
+ command: ANTIGRAVITY_MENU_COMMAND,
414
+ notify: { message, kind: kind ?? 'info' },
415
+ });
416
+ },
417
+ };
418
+ }
419
+ /**
420
+ * The menu service over the location's menu. Each request (already accepted
421
+ * by the library's own parser) runs through the menu with an invocation for
422
+ * its scope, whose notices are queued for that scope; once the activation's
423
+ * signal aborts, no new action starts. After every apply, `afterApply`
424
+ * brings the routing state up to date with what the action wrote; its
425
+ * failure is reported to the scope but does not change the menu's answer.
426
+ */
427
+ export function createGaMenuCommandService(input) {
428
+ return {
429
+ async apply({ request, scope, signal }) {
430
+ if (signal.aborted)
431
+ throw abortError(signal);
432
+ const result = await input.menu.apply(request, scopeInvocation(scope, input.notify));
433
+ if (input.afterApply) {
434
+ try {
435
+ await input.afterApply();
436
+ }
437
+ catch {
438
+ input.notify(scope, {
439
+ command: ANTIGRAVITY_MENU_COMMAND,
440
+ notify: {
441
+ message: 'The change was saved, but routing has not picked it up yet.',
442
+ kind: 'warning',
443
+ },
444
+ });
445
+ }
446
+ }
447
+ return result;
448
+ },
449
+ async open({ scope, signal }) {
450
+ if (signal.aborted)
451
+ throw abortError(signal);
452
+ const payload = await input.menu.open(scopeInvocation(scope, input.notify));
453
+ if (signal.aborted)
454
+ throw abortError(signal);
455
+ input.notify(scope, payload);
456
+ },
457
+ };
458
+ }
459
+ /**
460
+ * The account items' Reauthorize action for a GA location: a browser
461
+ * sign-in whose result replaces exactly the credential the item was opened
462
+ * for (through the account adapters' repository access service, which also
463
+ * refuses a sign-in to a different Google account and clears the row's
464
+ * access blocks). The action answers once the sign-in has started and the
465
+ * callback listener is waiting; the rest finishes in the background and is
466
+ * reported to the invoking session. `afterChange` brings routing up to date
467
+ * with the new credential.
468
+ *
469
+ * Without an override, the redirect is received by this package's own
470
+ * callback listener on the registered redirect address, which accepts only
471
+ * the state of the sign-in it was started for.
472
+ */
473
+ export function createGaReauthorize(input) {
474
+ const authorize = input.overrides.oauth?.authorize ?? authorizeAntigravity;
475
+ const exchange = input.overrides.oauth?.exchange ?? exchangeAntigravity;
476
+ const waitForCode = input.overrides.oauth?.waitForCode;
477
+ const access = createRepositoryAccountAccessService({
478
+ repository: input.repository,
479
+ // A GA location has no terminal: it opens no browser itself and asks
480
+ // no account question; the sign-in link is shown in the menu instead.
481
+ openBrowser: async () => false,
482
+ prompt: {
483
+ selectAccount: async () => undefined,
484
+ confirmOpenVerificationUrl: async () => false,
485
+ },
486
+ });
487
+ const listeners = new Set();
488
+ const continuations = new Set();
489
+ const shutdown = new AbortController();
490
+ let disposed = false;
491
+ const waitForRedirect = (code) => new Promise((resolve, reject) => {
492
+ const detach = () => shutdown.signal.removeEventListener('abort', abort);
493
+ const abort = () => {
494
+ detach();
495
+ reject(shutdown.signal.reason);
496
+ };
497
+ if (shutdown.signal.aborted)
498
+ reject(shutdown.signal.reason);
499
+ else
500
+ shutdown.signal.addEventListener('abort', abort, { once: true });
501
+ void code.then((value) => {
502
+ detach();
503
+ resolve(value);
504
+ }, (error) => {
505
+ detach();
506
+ reject(error);
507
+ });
508
+ });
509
+ /** Return the callback promise inside an object so setup can finish before the browser login. */
510
+ const startWaiting = async (expectedState) => {
511
+ if (waitForCode)
512
+ return { code: waitForCode(expectedState) };
513
+ const listener = await startOAuthListener();
514
+ if (disposed) {
515
+ await listener.close();
516
+ throw shutdown.signal.reason;
517
+ }
518
+ listeners.add(listener);
519
+ const code = (async () => {
520
+ try {
521
+ const url = await listener.waitForCallback();
522
+ if (url.searchParams.get('state') !== expectedState)
523
+ throw new Error('The sign-in answered for a different request');
524
+ const code = url.searchParams.get('code');
525
+ if (!code)
526
+ throw new Error('The sign-in returned no code');
527
+ return code;
528
+ }
529
+ finally {
530
+ listeners.delete(listener);
531
+ await listener.close();
532
+ }
533
+ })();
534
+ return { code };
535
+ };
536
+ return {
537
+ async run(ref, invocation) {
538
+ if (disposed)
539
+ return {
540
+ ok: false,
541
+ text: 'The location is shutting down.',
542
+ code: 'refused',
543
+ };
544
+ await input.assertAdmission?.();
545
+ const authorization = await authorize();
546
+ if (disposed)
547
+ throw shutdown.signal.reason;
548
+ const state = new URL(authorization.url).searchParams.get('state');
549
+ if (!state)
550
+ return {
551
+ ok: false,
552
+ text: 'The sign-in could not be started.',
553
+ code: 'action-failed',
554
+ };
555
+ const waiting = await startWaiting(state);
556
+ const continuation = (async () => {
557
+ try {
558
+ const code = await waitForRedirect(waiting.code);
559
+ await input.assertAdmission?.();
560
+ if (disposed)
561
+ throw shutdown.signal.reason;
562
+ const result = await exchange(code, state);
563
+ if (result.type !== 'success') {
564
+ invocation.notify('The sign-in was not completed.', 'error');
565
+ return;
566
+ }
567
+ await access.reauthorizeAccount(ref, result);
568
+ await input.afterChange();
569
+ invocation.notify('Account reauthorized.', 'info');
570
+ }
571
+ catch {
572
+ if (!disposed)
573
+ invocation.notify('The account could not be reauthorized.', 'error');
574
+ }
575
+ })();
576
+ continuations.add(continuation);
577
+ void continuation.then(() => continuations.delete(continuation), () => continuations.delete(continuation));
578
+ return `Sign in with the browser to reauthorize this account:\n${authorization.url}\nWaiting for the browser…`;
579
+ },
580
+ async dispose() {
581
+ disposed = true;
582
+ shutdown.abort(new Error('The location is shutting down.'));
583
+ const open = [...listeners];
584
+ listeners.clear();
585
+ const results = await Promise.allSettled(open.map((listener) => listener.close()));
586
+ while (continuations.size > 0)
587
+ await Promise.allSettled([...continuations]);
588
+ const failure = results.find((result) => result.status === 'rejected');
589
+ if (failure?.status === 'rejected')
590
+ throw failure.reason;
591
+ },
592
+ };
593
+ }
594
+ /**
595
+ * Reads the OpenCode 2 host's own sign-in for `integrationID` in the shape
596
+ * the vault library classifies: an OAuth credential as
597
+ * `{ type: 'oauth', refresh, access, expires }`, a key credential as
598
+ * `{ type: 'api', key }`, and no active connection as `undefined` (empty).
599
+ * An active connection whose credential cannot be resolved, or a credential
600
+ * of another shape, rejects: custody is then refused, never decided on a
601
+ * slot read as empty by mistake.
602
+ */
603
+ export function createGaHostSlotReader(connections, integrationID) {
604
+ return async () => {
605
+ const connection = await connections.active(integrationID);
606
+ if (connection === undefined)
607
+ return undefined;
608
+ const credential = await connections.resolve(connection);
609
+ if (typeof credential !== 'object' || credential === null)
610
+ throw new Error('The host sign-in could not be resolved');
611
+ if ('type' in credential &&
612
+ credential.type === 'oauth' &&
613
+ 'refresh' in credential &&
614
+ typeof credential.refresh === 'string' &&
615
+ 'access' in credential &&
616
+ typeof credential.access === 'string' &&
617
+ 'expires' in credential &&
618
+ typeof credential.expires === 'number')
619
+ return {
620
+ type: 'oauth',
621
+ refresh: credential.refresh,
622
+ access: credential.access,
623
+ expires: credential.expires,
624
+ };
625
+ if ('type' in credential &&
626
+ credential.type === 'key' &&
627
+ 'key' in credential &&
628
+ typeof credential.key === 'string')
629
+ return { type: 'api', key: credential.key };
630
+ throw new Error('The host sign-in has an unknown shape');
631
+ };
632
+ }
633
+ // ---------------------------------------------------------------------------
634
+ // Location services factory
635
+ // ---------------------------------------------------------------------------
636
+ /** The legacy account file name inside a location directory. */
637
+ export const GA_ACCOUNTS_FILE = 'antigravity-accounts.json';
638
+ /**
639
+ * The repository's token exchange: the core OAuth refresh, or the test
640
+ * override. It returns the bare tokens; the repository stores them.
641
+ */
642
+ function tokenExchange(overrides) {
643
+ const refresh = overrides.refreshAccessToken ?? refreshAntigravityToken;
644
+ return async ({ refreshToken }) => {
645
+ const result = await refresh(refreshToken);
646
+ return {
647
+ accessToken: result.access,
648
+ refreshToken: result.refresh,
649
+ expiresAt: result.expires,
650
+ };
651
+ };
652
+ }
653
+ function storeRefusal(status) {
654
+ return new Error(status.status === 'initialization-required'
655
+ ? 'The Antigravity account store is not initialized; initialize it with the antigravity-auth CLI.'
656
+ : status.status === 'error'
657
+ ? `The Antigravity account store cannot be opened: ${status.reason}`
658
+ : `The Antigravity account store is ${status.status}; finish its migration or rollback with \`antigravity-auth migrate --offline\` or \`antigravity-auth rollback --offline\`.`);
659
+ }
660
+ /**
661
+ * Opens the location's account repository on the migration's canonical
662
+ * binding: a completed generation the repository may open, including to
663
+ * resume its own pending clear or replace work. Binding is not permission
664
+ * to route; `assertServingAdmission` checks that before any credential is
665
+ * used. Initialization and migration are offline CLI operations, never a
666
+ * side effect of activation.
667
+ */
668
+ async function openLocationRepository(directory, bindings, overrides) {
669
+ const legacyPath = bindings.resolveAccountFile(directory);
670
+ const modules = await bindings.loadStoreModules();
671
+ const binding = await readAccountStoreBinding(legacyPath, modules, bindings.now);
672
+ if (binding.status !== 'bound')
673
+ throw storeRefusal(binding);
674
+ return {
675
+ repository: createAccountRepositoryFactory(modules)({
676
+ paths: binding.paths,
677
+ now: bindings.now,
678
+ exchange: tokenExchange(overrides),
679
+ }),
680
+ legacyPath,
681
+ generation: binding.receipt.id,
682
+ modules,
683
+ };
684
+ }
685
+ /**
686
+ * Serving needs the full admission of the same generation the repository
687
+ * was bound to: healthy current rows and no pending management work.
688
+ */
689
+ async function assertServingAdmission(location, now) {
690
+ const admission = await readAccountStoreAdmission(location.legacyPath, location.modules, now, location.generation);
691
+ if (admission.status === 'active')
692
+ return;
693
+ if (admission.status === 'pending' && admission.phase === 'activate')
694
+ throw new Error('An Antigravity account operation is still finishing; reopen the session once it completes.');
695
+ throw storeRefusal(admission);
696
+ }
697
+ // ---------------------------------------------------------------------------
698
+ // Request pipeline (local account repository)
699
+ // ---------------------------------------------------------------------------
700
+ /**
701
+ * How long a response body may stall before the transport destroys the
702
+ * socket; the GA raw sender (`GA_RAW_IDLE_TIMEOUT_MS`) uses the same five
703
+ * minutes. Declared here because the GA server module is imported for types
704
+ * only.
705
+ */
706
+ const GA_TRANSPORT_IDLE_TIMEOUT_MS = 300_000;
707
+ /**
708
+ * Local credentials for a repository-backed GA location, in the shared
709
+ * engine's `local` domain. A refresh is of the selected account itself:
710
+ * `refreshAccount` uses the ref the account was loaded with, so the
711
+ * repository stores a successor token only for that exact credential and
712
+ * refuses one whose row has since changed. Rows are never found again by
713
+ * token.
714
+ */
715
+ export function createGaLocalCredentials(manager, options) {
716
+ const local = createLocalAccountCredentials(manager, {
717
+ repository: options.repository,
718
+ ...(options.overrides.ensureProjectContext
719
+ ? { ensureProject: options.overrides.ensureProjectContext }
720
+ : {}),
721
+ });
722
+ return {
723
+ domain: 'local',
724
+ toAuthDetails: (account) => manager.toAuthDetails(account),
725
+ updateFromAuth: (account, auth) => manager.updateFromAuth(account, auth),
726
+ removeAccount: (account) => manager.removeAccount(account),
727
+ saveToDisk: () => manager.saveToDisk(),
728
+ saveToDiskReplace: () => manager.saveToDiskReplace(),
729
+ refresh: (account) => local.refresh(account),
730
+ // Checking and resolution use the captured row ID, epoch and identity,
731
+ // never whichever replacement the account object might later refer to.
732
+ captureGrant: (grant) => local.captureGrant(grant),
733
+ ensureProject: (auth) => local.ensureProject(auth),
734
+ isInvalidGrant: (error) => local.isInvalidGrant(error),
735
+ // The GA host keeps no OAuth credential of its own for this provider;
736
+ // accounts live only in the repository, so there is nothing to clear.
737
+ clearStoredAuth: async () => undefined,
738
+ ...(options.refreshQuotaAfterSuccess
739
+ ? { refreshQuotaAfterSuccess: options.refreshQuotaAfterSuccess }
740
+ : {}),
741
+ };
742
+ }
743
+ /** How close to expiry a stored access token is still used as is. */
744
+ const QUOTA_TOKEN_SKEW_MS = 60_000;
745
+ /**
746
+ * Resolves the bearer for one quota check from the repository, by the
747
+ * target's captured ref only. A row that no longer holds that exact
748
+ * credential (replaced, re-identified or removed) is refused rather than
749
+ * checked on its successor. An expired token is refreshed through the
750
+ * repository's attributed refresh, never locally.
751
+ */
752
+ export async function authorizeGaQuotaCheck(repository, target, now) {
753
+ const ref = target.rowRef;
754
+ if (ref === undefined)
755
+ return { status: 'refused', reason: 'unattributed' };
756
+ const read = await repository.read();
757
+ if (read.status !== 'ready')
758
+ return { status: 'refused', reason: 'not-ready' };
759
+ const row = read.rows.find((candidate) => sameRowRef(candidate.ref, ref));
760
+ if (row === undefined ||
761
+ row.credential === undefined ||
762
+ !row.enabled ||
763
+ !row.usable ||
764
+ row.metadata.status !== 'present')
765
+ return { status: 'refused', reason: 'stale' };
766
+ const metadata = row.metadata.status === 'present' ? row.metadata.metadata : undefined;
767
+ const projects = {
768
+ ...(metadata?.projectId ? { projectId: metadata.projectId } : {}),
769
+ ...(metadata?.managedProjectId
770
+ ? { managedProjectId: metadata.managedProjectId }
771
+ : {}),
772
+ };
773
+ const stored = row.credential;
774
+ if (stored.accessToken !== undefined &&
775
+ stored.expiresAt !== undefined &&
776
+ stored.expiresAt - QUOTA_TOKEN_SKEW_MS > now()) {
777
+ return {
778
+ status: 'authorized',
779
+ ref,
780
+ auth: {
781
+ type: 'oauth',
782
+ refresh: formatRefreshParts({
783
+ refreshToken: stored.refreshToken,
784
+ ...projects,
785
+ }),
786
+ access: stored.accessToken,
787
+ expires: stored.expiresAt,
788
+ },
789
+ };
790
+ }
791
+ const outcome = await repository.refresh(ref);
792
+ if (outcome.status !== 'rotated')
793
+ return { status: 'refused', reason: 'refresh-refused' };
794
+ const after = await repository.read();
795
+ const successor = after.status === 'ready'
796
+ ? after.rows.find((candidate) => sameRowRef(candidate.ref, outcome.ref))
797
+ : undefined;
798
+ if (successor?.credential === undefined ||
799
+ !successor.enabled ||
800
+ !successor.usable ||
801
+ successor.metadata.status !== 'present')
802
+ return { status: 'refused', reason: 'stale' };
803
+ return {
804
+ status: 'authorized',
805
+ ref: outcome.ref,
806
+ auth: {
807
+ type: 'oauth',
808
+ refresh: formatRefreshParts({
809
+ refreshToken: successor.credential.refreshToken,
810
+ ...(successor.metadata.metadata.projectId
811
+ ? { projectId: successor.metadata.metadata.projectId }
812
+ : {}),
813
+ ...(successor.metadata.metadata.managedProjectId
814
+ ? { managedProjectId: successor.metadata.metadata.managedProjectId }
815
+ : {}),
816
+ }),
817
+ access: outcome.accessToken,
818
+ expires: outcome.expiresAt,
819
+ },
820
+ };
821
+ }
822
+ function isRowRef(value) {
823
+ return (typeof value === 'object' &&
824
+ value !== null &&
825
+ 'id' in value &&
826
+ typeof value.id === 'string' &&
827
+ 'credentialEpoch' in value &&
828
+ typeof value.credentialEpoch === 'number' &&
829
+ (!('identity' in value) ||
830
+ value.identity === undefined ||
831
+ typeof value.identity === 'string'));
832
+ }
833
+ /** The captured ref a quota target carries, when it carries a valid one. */
834
+ function rowRefOfTarget(account) {
835
+ if (!('rowRef' in account))
836
+ return undefined;
837
+ return isRowRef(account.rowRef) ? account.rowRef : undefined;
838
+ }
839
+ /**
840
+ * The GA location's quota fetcher. Each check is attributed to the target's
841
+ * captured repository ref: the bearer comes from `authorizeGaQuotaCheck`
842
+ * (stored token, or the repository's attributed refresh), and a target
843
+ * without a ref, or whose credential has since changed, is answered with an
844
+ * error result instead of being checked on another credential.
845
+ */
846
+ export function createGaFetchAccountQuota(options) {
847
+ const ensureProject = options.overrides.ensureProjectContext ?? ensureProjectContext;
848
+ const quotaFetch = options.overrides.quotaFetch;
849
+ return createAuthorizedFetchAccountQuota({
850
+ logger: options.logger,
851
+ ...(quotaFetch ? { transport: () => quotaFetch } : {}),
852
+ async authorize(account) {
853
+ // Captured before any await: the ref of exactly this target.
854
+ const rowRef = rowRefOfTarget(account);
855
+ await options.assertAdmission?.();
856
+ const authorization = await authorizeGaQuotaCheck(options.repository, { rowRef }, options.now);
857
+ if (authorization.status !== 'authorized')
858
+ return { status: 'refused', reason: authorization.reason };
859
+ const ref = authorization.ref;
860
+ const accessToken = authorization.auth.access ?? '';
861
+ await options.assertAdmission?.();
862
+ const project = await ensureProject(authorization.auth);
863
+ await options.assertAdmission?.();
864
+ const managedProjectId = parseRefreshParts(project.auth.refresh).managedProjectId;
865
+ return {
866
+ status: 'authorized',
867
+ domain: 'local',
868
+ accessToken,
869
+ projectId: project.effectiveProjectId,
870
+ ...(managedProjectId ? { managedProjectId } : {}),
871
+ // Before every request: the row must still hold exactly this
872
+ // credential and this access token.
873
+ confirmSend: async () => {
874
+ await options.assertAdmission?.();
875
+ const read = await options.repository.read();
876
+ const row = read.status === 'ready'
877
+ ? read.rows.find((candidate) => sameRowRef(candidate.ref, ref))
878
+ : undefined;
879
+ if (row === undefined ||
880
+ !row.enabled ||
881
+ !row.usable ||
882
+ row.metadata.status !== 'present')
883
+ return { status: 'stale', reason: 'credential changed' };
884
+ if (row.credential?.accessToken !== accessToken)
885
+ return { status: 'stale', reason: 'access token changed' };
886
+ await options.assertAdmission?.();
887
+ return { status: 'current' };
888
+ },
889
+ };
890
+ },
891
+ });
892
+ }
893
+ export function createGaRouteBook(limit = 256) {
894
+ const routes = new Map();
895
+ return {
896
+ record(sessionId, entry) {
897
+ routes.delete(sessionId);
898
+ routes.set(sessionId, {
899
+ accountId: entry.accountId,
900
+ modelFamily: entry.modelFamily,
901
+ headerStyle: entry.headerStyle,
902
+ ...(entry.strategy ? { strategy: entry.strategy } : {}),
903
+ updatedAt: entry.updatedAt,
904
+ });
905
+ while (routes.size > limit) {
906
+ const oldest = routes.keys().next().value;
907
+ if (oldest === undefined)
908
+ break;
909
+ routes.delete(oldest);
910
+ }
911
+ },
912
+ route(scope) {
913
+ return scope.kind === 'session'
914
+ ? (routes.get(scope.sessionID) ?? null)
915
+ : null;
916
+ },
917
+ };
918
+ }
919
+ /** Runs one bridged job through the shared request engine. */
920
+ export function createGaJobExecutor(executor) {
921
+ return (job, context) => executor.execute(job.url, {
922
+ method: 'POST',
923
+ headers: { 'content-type': 'application/json' },
924
+ body: job.body,
925
+ signal: context.signal,
926
+ }, {
927
+ session: {
928
+ sessionId: job.sessionID,
929
+ parentSessionId: job.parentSessionID,
930
+ },
931
+ });
932
+ }
933
+ /**
934
+ * The shared request engine's collaborators that do not depend on where the
935
+ * accounts' credentials live: this location's config, session registry,
936
+ * operator settings, wire, debug log, dump switch and route book, and the
937
+ * AGY transport with the GA raw sender's idle timeout and signal observer.
938
+ */
939
+ function gaEngineCollaborators(input) {
940
+ const runtime = input.runtime;
941
+ const observe = input.overrides.observeRawSenderSignal;
942
+ return {
943
+ config: runtime.config.config,
944
+ sessions: new AgySessionRegistry(runtime.directory),
945
+ operatorSettings: runtime.operatorSettings,
946
+ transport: (url, init, options) => {
947
+ const transportOptions = {
948
+ ...options,
949
+ idleTimeoutMs: options?.idleTimeoutMs ?? GA_TRANSPORT_IDLE_TIMEOUT_MS,
950
+ };
951
+ if (observe && transportOptions.signal) {
952
+ try {
953
+ observe(transportOptions.signal);
954
+ }
955
+ catch {
956
+ // A diagnostic failure must not change or delay the dispatch.
957
+ }
958
+ }
959
+ return fetchWithAgyCliTransport(url, init, transportOptions);
960
+ },
961
+ fetchImpl: (request, init) => fetch(request, init),
962
+ wire: {
963
+ prepare: prepareAntigravityRequest,
964
+ transformResponse: transformAntigravityResponse,
965
+ buildThinkingWarmupBody,
966
+ getImageModelLocalTitle,
967
+ getLastCacheStats,
968
+ },
969
+ debug: runtime.debug,
970
+ dump: runtime.dump,
971
+ logger: input.logger,
972
+ classifyAccessError: extractAccountAccessErrorDetails,
973
+ onRouting: (sessionId, entry) => input.routes.record(sessionId, entry),
974
+ };
975
+ }
976
+ /**
977
+ * The shared request engine over a repository-backed account manager. The
978
+ * engine is the same one OpenCode 1 uses; only its collaborators are this
979
+ * location's.
980
+ */
981
+ export async function createGaLocalRequestPipeline(input) {
982
+ const runtime = input.runtime;
983
+ await input.assertAdmission?.();
984
+ const manager = await loadAccountManagerFromRepository(input.repository);
985
+ input.accounts.current = manager;
986
+ input.accounts.quotaLogger = runtime.logger.createLogger('quota');
987
+ await runtime.replaceAccounts(manager);
988
+ const logger = runtime.logger.createLogger('request');
989
+ const executor = createRequestExecutor({
990
+ ...gaEngineCollaborators({
991
+ runtime,
992
+ overrides: input.overrides,
993
+ routes: input.routes,
994
+ logger,
995
+ }),
996
+ accounts: manager,
997
+ ...(input.assertAdmission
998
+ ? { assertAdmission: input.assertAdmission }
999
+ : {}),
1000
+ credentials: createGaLocalCredentials(manager, {
1001
+ repository: input.repository,
1002
+ overrides: input.overrides,
1003
+ refreshQuotaAfterSuccess: createLocalQuotaRefresh(manager, runtime.quotaManager, logger),
1004
+ }),
1005
+ // The trackers the manager selects with, so recorded outcomes steer
1006
+ // the next selection.
1007
+ trackers: {
1008
+ health: manager.healthTracker,
1009
+ token: manager.tokenTracker,
1010
+ },
1011
+ });
1012
+ // Local custody: the same store quota service the OpenCode 1 menu uses,
1013
+ // over this activation's manager and repository.
1014
+ const quotaFetch = input.overrides.quotaFetch;
1015
+ const storeQuota = createStoreQuotaService({
1016
+ manager,
1017
+ repository: input.repository,
1018
+ ...(input.assertAdmission
1019
+ ? {
1020
+ mayRun: async () => {
1021
+ await input.assertAdmission?.();
1022
+ return true;
1023
+ },
1024
+ }
1025
+ : {}),
1026
+ logger: runtime.logger.createLogger('store-quota'),
1027
+ ...(quotaFetch ? { transport: () => quotaFetch } : {}),
1028
+ });
1029
+ return {
1030
+ execute: createGaJobExecutor(executor),
1031
+ refreshQuota: (refs) => storeQuota.checkStoreQuota(refs),
1032
+ refreshAccounts: () => manager.refreshFromRepository(),
1033
+ async dispose() {
1034
+ await executor.dispose();
1035
+ await storeQuota.dispose();
1036
+ if (input.accounts.current === manager) {
1037
+ input.accounts.current = null;
1038
+ input.accounts.quotaLogger = null;
1039
+ }
1040
+ await runtime.replaceAccounts(null);
1041
+ await manager.dispose();
1042
+ },
1043
+ };
1044
+ }
1045
+ /**
1046
+ * The shared request engine for a location whose accounts are held by the
1047
+ * vault. Selection runs on the shared `AccountSelector` over the vault's
1048
+ * selectable routes (metadata rows, no credential); every physical send
1049
+ * takes a fresh receipt for the selected route through
1050
+ * `createVaultRequestCredentials`. Nothing is refreshed or cached locally.
1051
+ * `refreshAccounts` re-reads the vault roster and keeps each route's
1052
+ * selection state while its route, credential and asserted account stay
1053
+ * the same. With `state`, a route's selection state is restored from and
1054
+ * saved to the vault's provider-state file, attributed to the receipt that
1055
+ * last served it.
1056
+ */
1057
+ export async function createGaVaultRequestPipeline(input) {
1058
+ const { pool } = input;
1059
+ await input.assertAdmission?.();
1060
+ await pool.sync();
1061
+ const logger = input.runtime.logger.createLogger('request');
1062
+ const executor = createRequestExecutor({
1063
+ ...gaEngineCollaborators({
1064
+ runtime: input.runtime,
1065
+ overrides: input.overrides,
1066
+ routes: input.routes,
1067
+ logger,
1068
+ }),
1069
+ accounts: pool.selector,
1070
+ ...(input.assertAdmission
1071
+ ? { assertAdmission: input.assertAdmission }
1072
+ : {}),
1073
+ credentials: pool.credentials,
1074
+ trackers: {
1075
+ health: pool.selector.healthTracker,
1076
+ token: pool.selector.tokenTracker,
1077
+ },
1078
+ });
1079
+ return {
1080
+ execute: async (job, context) => {
1081
+ await input.assertAdmission?.();
1082
+ await pool.sync();
1083
+ return createGaJobExecutor(executor)(job, context);
1084
+ },
1085
+ rows: () => pool.selector.rows,
1086
+ refreshAccounts: async () => {
1087
+ await input.assertAdmission?.();
1088
+ await pool.refresh();
1089
+ },
1090
+ async dispose() {
1091
+ await executor.dispose();
1092
+ await pool.flush();
1093
+ },
1094
+ };
1095
+ }
1096
+ // ---------------------------------------------------------------------------
1097
+ // Vault custody location
1098
+ // ---------------------------------------------------------------------------
1099
+ /**
1100
+ * Opaque item and state selectors for vault routes, one per route,
1101
+ * credential and asserted account for the life of the activation.
1102
+ */
1103
+ function vaultSelectors(createSelector) {
1104
+ const byKey = new Map();
1105
+ return (row) => {
1106
+ const key = vaultAccountRowKey(row);
1107
+ let selector = byKey.get(key);
1108
+ if (selector === undefined) {
1109
+ selector = createSelector();
1110
+ byKey.set(key, selector);
1111
+ }
1112
+ return selector;
1113
+ };
1114
+ }
1115
+ /**
1116
+ * The `state` source of a vault custody location: the vault's selectable
1117
+ * accounts as redaction rows with opaque selectors, read one at a time.
1118
+ * Vault rows carry no metadata or access blocks of this plugin's own.
1119
+ */
1120
+ function createGaVaultStateSource(input) {
1121
+ let readSeq = 0;
1122
+ let queue = Promise.resolve();
1123
+ const readOnce = async (scope, signal) => {
1124
+ if (signal.aborted)
1125
+ throw abortError(signal);
1126
+ const rows = input.rows();
1127
+ const settings = input.settings();
1128
+ const route = input.route(scope);
1129
+ if (signal.aborted)
1130
+ throw abortError(signal);
1131
+ readSeq = input.nextReadSeq?.() ?? readSeq + 1;
1132
+ const overLimit = rows.length > ACCOUNT_LIMIT;
1133
+ const answer = {
1134
+ readSeq,
1135
+ accounts: overLimit
1136
+ ? { kind: 'over-limit', count: rows.length }
1137
+ : {
1138
+ kind: 'complete',
1139
+ rows: rows.map((row, position) => ({
1140
+ selector: input.selectorOf(row),
1141
+ row: {
1142
+ index: position,
1143
+ enabled: row.enabled,
1144
+ current: false,
1145
+ ...(row.coolingDownUntil !== undefined
1146
+ ? { coolingDownUntil: row.coolingDownUntil }
1147
+ : {}),
1148
+ ...(row.cachedQuota !== undefined
1149
+ ? { cachedQuota: row.cachedQuota }
1150
+ : {}),
1151
+ },
1152
+ })),
1153
+ },
1154
+ route,
1155
+ status: {
1156
+ checkedAt: null,
1157
+ quotaBackoffUntil: null,
1158
+ routingAuthoritative: true,
1159
+ },
1160
+ settings,
1161
+ };
1162
+ if (input.observe) {
1163
+ try {
1164
+ input.observe({
1165
+ generation: input.generation,
1166
+ readSeq,
1167
+ status: 'ready',
1168
+ accountsStatus: overLimit ? 'over-limit' : 'complete',
1169
+ accounts: overLimit
1170
+ ? []
1171
+ : rows.map((row, position) => ({
1172
+ selector: input.selectorOf(row),
1173
+ position,
1174
+ enabled: row.enabled,
1175
+ usable: row.enabled,
1176
+ metadataStatus: 'absent',
1177
+ accessBlock: { kind: 'unknown' },
1178
+ currentFor: [],
1179
+ cooldownUntil: row.coolingDownUntil ?? null,
1180
+ })),
1181
+ retiredSelectors: [],
1182
+ });
1183
+ }
1184
+ catch {
1185
+ // A diagnostic observer cannot change the answer.
1186
+ }
1187
+ }
1188
+ return answer;
1189
+ };
1190
+ return {
1191
+ read({ scope, signal }) {
1192
+ const next = queue.then(() => readOnce(scope, signal), () => readOnce(scope, signal));
1193
+ queue = next.catch(() => undefined);
1194
+ return next;
1195
+ },
1196
+ };
1197
+ }
1198
+ /**
1199
+ * A GA location whose accounts are held by the vault. No local account
1200
+ * store is opened. Saved Google logins stay dormant on disk. The vault
1201
+ * source is taken from custody, and requests go through
1202
+ * `createGaVaultRequestPipeline`, and the menu shows the vault's accounts,
1203
+ * this location's settings and the Vault section. The runtime keeps quota
1204
+ * snapshots in memory; it gets no account view, so its quota poller and
1205
+ * token refresh queue do not run for vault accounts.
1206
+ */
1207
+ async function createGaVaultLocationServices(input) {
1208
+ const { custody, overrides } = input;
1209
+ await input.assertAdmission?.();
1210
+ const source = await custody.custodySource();
1211
+ const selectorOf = vaultSelectors(input.bindings.createSelector ?? defaultSelector);
1212
+ let pipeline = null;
1213
+ let disposed = null;
1214
+ return {
1215
+ runtime: {
1216
+ quotaSnapshots: createMemoryQuotaSnapshots(),
1217
+ // Never called: the runtime is given no account view for vault rows,
1218
+ // so neither its quota poller nor its refresh queue runs.
1219
+ fetchAccountQuota: async (account) => ({
1220
+ index: 0,
1221
+ email: account.email,
1222
+ status: 'error',
1223
+ disabled: false,
1224
+ error: 'vault accounts are not checked by this location',
1225
+ }),
1226
+ refreshToken: async () => undefined,
1227
+ },
1228
+ async start(start) {
1229
+ if (disposed)
1230
+ throw new Error('The location services are disposed');
1231
+ const location = start.runtime;
1232
+ const routes = createGaRouteBook();
1233
+ const vaultLogger = location.logger.createLogger('vault-state');
1234
+ const pool = createVaultAccountPool({
1235
+ source,
1236
+ durable: {
1237
+ source,
1238
+ readState: () => custody.readState(),
1239
+ onError: (error) => vaultLogger.debug('vault-state-write-dropped', {
1240
+ error: error instanceof Error ? error.name : 'unknown',
1241
+ }),
1242
+ },
1243
+ });
1244
+ pipeline = await createGaVaultRequestPipeline({
1245
+ ...(input.assertAdmission
1246
+ ? { assertAdmission: input.assertAdmission }
1247
+ : {}),
1248
+ pool,
1249
+ runtime: location,
1250
+ overrides,
1251
+ routes,
1252
+ });
1253
+ const fetchVaultQuota = input.bindings.fetchVaultQuota;
1254
+ const quotaLogger = location.logger.createLogger('vault-quota');
1255
+ const checkQuota = fetchVaultQuota
1256
+ ? (signal) => checkVaultQuota({
1257
+ pool,
1258
+ fetchReading: async (ref, check) => {
1259
+ await input.assertAdmission?.();
1260
+ return fetchVaultQuota({
1261
+ source,
1262
+ ref,
1263
+ signal: check,
1264
+ logger: quotaLogger,
1265
+ ...(overrides.quotaFetch
1266
+ ? { transport: overrides.quotaFetch }
1267
+ : {}),
1268
+ });
1269
+ },
1270
+ signal,
1271
+ onError: (error) => quotaLogger.debug('vault-quota-not-recorded', {
1272
+ error: error instanceof Error ? error.name : 'unknown',
1273
+ }),
1274
+ })
1275
+ : undefined;
1276
+ const started = pipeline;
1277
+ const settings = operatorMenuSettings(location.operatorSettings);
1278
+ const menu = createAntigravityCommandMenu({
1279
+ source: 'sections',
1280
+ commands: await loadCommonAuthCommands(),
1281
+ sections: {
1282
+ ...createVaultAccountMenuSections(pool, selectorOf, checkQuota),
1283
+ ...antigravitySettingsSections(settings),
1284
+ },
1285
+ diagnostics: diagnosticsMenuSection({
1286
+ settings: location.operatorSettings,
1287
+ dump: location.dump,
1288
+ applyLogLevel: () => location.applyOperatorSettings(),
1289
+ }),
1290
+ extras: [custody.menuSection()],
1291
+ });
1292
+ input.bindRefresh?.(() => started.refreshAccounts());
1293
+ return {
1294
+ execute: started.execute,
1295
+ state: createGaVaultStateSource({
1296
+ rows: () => started.rows(),
1297
+ selectorOf,
1298
+ ...(input.nextReadSeq ? { nextReadSeq: input.nextReadSeq } : {}),
1299
+ generation: start.generation,
1300
+ settings: () => gaSettingsOf(location.operatorSettings.get(), location.dump),
1301
+ route: (scope) => routes.route(scope),
1302
+ ...(overrides.observeAccountSnapshot
1303
+ ? { observe: overrides.observeAccountSnapshot }
1304
+ : {}),
1305
+ }),
1306
+ commands: createGaMenuCommandService({
1307
+ menu,
1308
+ notify: start.notify,
1309
+ afterApply: () => input.afterApply ? input.afterApply() : started.refreshAccounts(),
1310
+ }),
1311
+ };
1312
+ },
1313
+ dispose() {
1314
+ disposed ??= (async () => {
1315
+ const active = pipeline;
1316
+ pipeline = null;
1317
+ input.bindRefresh?.(undefined);
1318
+ if (active)
1319
+ await active.dispose();
1320
+ })();
1321
+ return disposed;
1322
+ },
1323
+ };
1324
+ }
1325
+ export function createGaLocationServicesFactory(bindings) {
1326
+ return async ({ directory, overrides }) => {
1327
+ const custody = bindings.custody?.({
1328
+ accountFile: bindings.resolveAccountFile(directory),
1329
+ overrides,
1330
+ });
1331
+ let closing = false;
1332
+ let started = false;
1333
+ let disposal;
1334
+ // Enrollment selects a binding, not its lifetime. Local files stay unopened
1335
+ // until a locally authorized operation needs them, and failures can retry.
1336
+ let repositoryPromise;
1337
+ let servingRepository;
1338
+ let localPromise;
1339
+ let vaultPromise;
1340
+ let vaultServices;
1341
+ let localPipeline;
1342
+ let reauthorize;
1343
+ let readSeq = 0;
1344
+ const inFlight = new Set();
1345
+ const run = (work) => {
1346
+ if (closing)
1347
+ return Promise.reject(new Error('The location services are disposed'));
1348
+ const pending = Promise.resolve().then(work);
1349
+ inFlight.add(pending);
1350
+ void pending.then(() => inFlight.delete(pending), () => inFlight.delete(pending));
1351
+ return pending;
1352
+ };
1353
+ const nextReadSeq = () => ++readSeq;
1354
+ const registry = createGaSelectorRegistry(bindings.createSelector);
1355
+ const authority = async () => {
1356
+ if (!custody)
1357
+ return 'local';
1358
+ const mode = await custody.readMode();
1359
+ return mode.ok
1360
+ ? mode.record.mode === 'custody'
1361
+ ? 'vault'
1362
+ : 'local'
1363
+ : 'unreadable';
1364
+ };
1365
+ const assertLocal = async () => {
1366
+ if (closing)
1367
+ throw new Error('The location services are disposed');
1368
+ const selected = await authority();
1369
+ if (closing)
1370
+ throw new Error('The location services are disposed');
1371
+ if (selected !== 'local')
1372
+ throw new Error(VAULT_ACCOUNT_REMEDY);
1373
+ };
1374
+ let refreshVaultBinding;
1375
+ const refreshSelectedSource = async () => {
1376
+ const selected = await authority();
1377
+ if (closing)
1378
+ throw new Error('The location services are disposed');
1379
+ if (selected === 'unreadable')
1380
+ throw new Error(VAULT_ACCOUNT_REMEDY);
1381
+ // A menu action may change sources. Refresh only the newly selected
1382
+ // account view, keeping both runtime bindings and their generation intact.
1383
+ if (selected === 'local') {
1384
+ await assertLocal();
1385
+ await localPipeline?.refreshAccounts();
1386
+ }
1387
+ else {
1388
+ if (vaultPromise)
1389
+ await vaultPromise;
1390
+ await refreshVaultBinding?.();
1391
+ }
1392
+ };
1393
+ const getRepository = async () => {
1394
+ await assertLocal();
1395
+ repositoryPromise ??= openLocationRepository(directory, bindings, overrides).catch((error) => {
1396
+ repositoryPromise = undefined;
1397
+ throw error;
1398
+ });
1399
+ const repository = (await repositoryPromise).repository;
1400
+ if (!servingRepository) {
1401
+ const methods = new Map();
1402
+ const pendingAdmissions = new Set();
1403
+ const refusedWrites = [];
1404
+ servingRepository = new Proxy(repository, {
1405
+ get(target, key) {
1406
+ const value = Reflect.get(target, key, target);
1407
+ if (typeof value !== 'function')
1408
+ return value;
1409
+ if (!methods.has(key)) {
1410
+ methods.set(key, (...args) => {
1411
+ if (key === 'flush' || key === 'settled' || key === 'dispose') {
1412
+ return (async () => {
1413
+ // Calls still awaiting the local-source check have not entered
1414
+ // the repository's queue. Wait for them before flushing it.
1415
+ await Promise.allSettled([...pendingAdmissions]);
1416
+ const result = await Reflect.apply(value, target, args);
1417
+ if (key !== 'settled' && refusedWrites.length > 0) {
1418
+ const failures = refusedWrites.splice(0);
1419
+ throw new AggregateError(failures, 'Local writes were refused by source authority');
1420
+ }
1421
+ return result;
1422
+ })();
1423
+ }
1424
+ const pending = (async () => {
1425
+ // A refresh that passed the local-source check saves its new
1426
+ // credentials inside this call. Later operations check again.
1427
+ try {
1428
+ await assertLocal();
1429
+ }
1430
+ catch (error) {
1431
+ if (key !== 'read')
1432
+ refusedWrites.push(error);
1433
+ throw error;
1434
+ }
1435
+ return Reflect.apply(value, target, args);
1436
+ })();
1437
+ pendingAdmissions.add(pending);
1438
+ void pending.then(() => pendingAdmissions.delete(pending), () => pendingAdmissions.delete(pending));
1439
+ return pending;
1440
+ });
1441
+ }
1442
+ return methods.get(key);
1443
+ },
1444
+ });
1445
+ }
1446
+ return servingRepository;
1447
+ };
1448
+ let runtime;
1449
+ try {
1450
+ const collaborators = bindings.runtime({
1451
+ directory,
1452
+ getRepository,
1453
+ assertAdmission: assertLocal,
1454
+ overrides,
1455
+ });
1456
+ const previousMayRun = collaborators.mayRun;
1457
+ runtime = {
1458
+ ...collaborators,
1459
+ mayRun: async () => !closing &&
1460
+ (await authority()) === 'local' &&
1461
+ (!previousMayRun || (await previousMayRun())),
1462
+ };
1463
+ }
1464
+ catch (error) {
1465
+ await custody?.dispose().catch(() => { });
1466
+ throw error;
1467
+ }
1468
+ return {
1469
+ runtime,
1470
+ async start(input) {
1471
+ if (closing)
1472
+ throw new Error('The location services are disposed');
1473
+ if (started)
1474
+ throw new Error('The location services already started');
1475
+ started = true;
1476
+ const location = input.runtime;
1477
+ const settings = operatorMenuSettings(location.operatorSettings);
1478
+ const recoveryMenu = createAntigravityCommandMenu({
1479
+ source: 'sections',
1480
+ commands: await loadCommonAuthCommands(),
1481
+ sections: {
1482
+ accounts: {
1483
+ title: 'Accounts',
1484
+ build: async () => ({
1485
+ lines: [
1486
+ 'Account access is unavailable. Open Vault to inspect or recover enrollment.',
1487
+ ],
1488
+ items: [],
1489
+ actions: [],
1490
+ }),
1491
+ },
1492
+ quota: {
1493
+ title: 'Quota',
1494
+ build: async () => ({
1495
+ lines: ['No quota reading is available.'],
1496
+ items: [],
1497
+ actions: [],
1498
+ }),
1499
+ },
1500
+ ...antigravitySettingsSections(settings),
1501
+ },
1502
+ diagnostics: diagnosticsMenuSection({
1503
+ settings: location.operatorSettings,
1504
+ dump: location.dump,
1505
+ applyLogLevel: () => location.applyOperatorSettings(),
1506
+ }),
1507
+ ...(custody ? { extras: [custody.menuSection()] } : {}),
1508
+ });
1509
+ const recovery = {
1510
+ execute: async () => {
1511
+ throw new Error(VAULT_ACCOUNT_REMEDY);
1512
+ },
1513
+ state: {
1514
+ read: async ({ signal }) => {
1515
+ if (signal.aborted)
1516
+ throw abortError(signal);
1517
+ return {
1518
+ readSeq: nextReadSeq(),
1519
+ accounts: { kind: 'complete', rows: [] },
1520
+ route: null,
1521
+ status: {
1522
+ checkedAt: null,
1523
+ quotaBackoffUntil: null,
1524
+ routingAuthoritative: false,
1525
+ },
1526
+ settings: gaSettingsOf(location.operatorSettings.get(), location.dump),
1527
+ };
1528
+ },
1529
+ },
1530
+ commands: createGaMenuCommandService({
1531
+ menu: recoveryMenu,
1532
+ notify: input.notify,
1533
+ }),
1534
+ };
1535
+ const local = () => {
1536
+ localPromise ??= (async () => {
1537
+ const repository = await getRepository();
1538
+ const opened = await repositoryPromise;
1539
+ if (!opened)
1540
+ throw new Error('The local repository was not constructed');
1541
+ await assertServingAdmission(opened, bindings.now);
1542
+ await assertLocal();
1543
+ let pipeline;
1544
+ let pendingReauthorization;
1545
+ try {
1546
+ const routes = createGaRouteBook();
1547
+ pipeline = await bindings.createPipeline({
1548
+ repository,
1549
+ runtime: location,
1550
+ send: input.send,
1551
+ generation: input.generation,
1552
+ overrides,
1553
+ routes,
1554
+ assertAdmission: assertLocal,
1555
+ });
1556
+ const started = pipeline;
1557
+ const refreshAccounts = async () => {
1558
+ await assertLocal();
1559
+ await started.refreshAccounts();
1560
+ };
1561
+ pendingReauthorization = createGaReauthorize({
1562
+ repository,
1563
+ assertAdmission: assertLocal,
1564
+ overrides,
1565
+ afterChange: refreshAccounts,
1566
+ });
1567
+ const checkQuota = started.refreshQuota;
1568
+ const menu = createGaLocationMenu({
1569
+ commands: await loadCommonAuthCommands(),
1570
+ repository,
1571
+ runtime: location,
1572
+ reauthorize: pendingReauthorization,
1573
+ ...(custody ? { vault: custody.menuSection() } : {}),
1574
+ ...(checkQuota
1575
+ ? {
1576
+ refreshQuota: async (refs) => {
1577
+ await assertLocal();
1578
+ return checkQuota(refs);
1579
+ },
1580
+ }
1581
+ : {}),
1582
+ });
1583
+ localPipeline = started;
1584
+ reauthorize = pendingReauthorization;
1585
+ return {
1586
+ state: createGaAccountStateSource({
1587
+ repository,
1588
+ registry,
1589
+ generation: input.generation,
1590
+ nextReadSeq,
1591
+ settings: () => gaSettingsOf(location.operatorSettings.get(), location.dump),
1592
+ status: () => ({
1593
+ checkedAt: null,
1594
+ quotaBackoffUntil: null,
1595
+ routingAuthoritative: true,
1596
+ }),
1597
+ route: (scope) => routes.route(scope),
1598
+ ...(overrides.observeAccountSnapshot
1599
+ ? { observe: overrides.observeAccountSnapshot }
1600
+ : {}),
1601
+ }),
1602
+ commands: createGaMenuCommandService({
1603
+ menu,
1604
+ notify: input.notify,
1605
+ afterApply: () => refreshSelectedSource(),
1606
+ }),
1607
+ execute: started.execute,
1608
+ };
1609
+ }
1610
+ catch (error) {
1611
+ await pendingReauthorization?.dispose().catch(() => { });
1612
+ await pipeline?.dispose().catch(() => { });
1613
+ await location.replaceAccounts(null).catch(() => { });
1614
+ throw error;
1615
+ }
1616
+ })().catch((error) => {
1617
+ localPromise = undefined;
1618
+ throw error;
1619
+ });
1620
+ return localPromise;
1621
+ };
1622
+ const vault = () => {
1623
+ if (!custody)
1624
+ return Promise.reject(new Error('Vault custody is unavailable'));
1625
+ vaultPromise ??= (async () => {
1626
+ const created = await createGaVaultLocationServices({
1627
+ custody,
1628
+ overrides,
1629
+ bindings,
1630
+ nextReadSeq,
1631
+ afterApply: refreshSelectedSource,
1632
+ bindRefresh: (refresh) => {
1633
+ refreshVaultBinding = refresh;
1634
+ },
1635
+ assertAdmission: async () => {
1636
+ const selected = await authority();
1637
+ if (closing || selected !== 'vault')
1638
+ throw new Error(VAULT_ACCOUNT_REMEDY);
1639
+ },
1640
+ });
1641
+ try {
1642
+ const serving = await created.start(input);
1643
+ vaultServices = created;
1644
+ return serving;
1645
+ }
1646
+ catch (error) {
1647
+ await created.dispose().catch(() => { });
1648
+ throw error;
1649
+ }
1650
+ })().catch((error) => {
1651
+ vaultPromise = undefined;
1652
+ throw error;
1653
+ });
1654
+ return vaultPromise;
1655
+ };
1656
+ const choose = async (purpose) => {
1657
+ if (closing)
1658
+ throw new Error('The location services are disposed');
1659
+ const selected = await authority();
1660
+ if (closing)
1661
+ throw new Error('The location services are disposed');
1662
+ if (selected === 'local')
1663
+ return local();
1664
+ if (selected === 'unreadable') {
1665
+ if (purpose === 'execute')
1666
+ throw new Error(VAULT_ACCOUNT_REMEDY);
1667
+ return recovery;
1668
+ }
1669
+ try {
1670
+ return await vault();
1671
+ }
1672
+ catch (error) {
1673
+ if (purpose === 'execute')
1674
+ throw error;
1675
+ return recovery;
1676
+ }
1677
+ };
1678
+ let reads = Promise.resolve();
1679
+ return {
1680
+ execute: (job, context) => run(async () => {
1681
+ if (context.signal.aborted)
1682
+ throw context.signal.reason;
1683
+ return (await choose('execute')).execute(job, context);
1684
+ }),
1685
+ commands: {
1686
+ apply: (request) => run(async () => {
1687
+ if (request.signal.aborted)
1688
+ throw request.signal.reason;
1689
+ return (await choose('view')).commands.apply(request);
1690
+ }),
1691
+ open: (request) => run(async () => {
1692
+ if (request.signal.aborted)
1693
+ throw request.signal.reason;
1694
+ return (await choose('view')).commands.open(request);
1695
+ }),
1696
+ },
1697
+ state: {
1698
+ read(request) {
1699
+ return run(() => {
1700
+ const pending = reads.then(async () => {
1701
+ if (closing)
1702
+ throw new Error('The location services are disposed');
1703
+ if (request.signal.aborted)
1704
+ throw request.signal.reason;
1705
+ for (let attempt = 0; attempt < 2; attempt++) {
1706
+ const before = await authority();
1707
+ const answer = await (await choose('view')).state.read(request);
1708
+ if (before === (await authority()))
1709
+ return answer;
1710
+ }
1711
+ throw new Error('Account authority changed while reading state');
1712
+ });
1713
+ reads = pending.catch(() => undefined);
1714
+ return pending;
1715
+ });
1716
+ },
1717
+ },
1718
+ };
1719
+ },
1720
+ dispose() {
1721
+ closing = true;
1722
+ disposal ??= (async () => {
1723
+ await Promise.allSettled([
1724
+ localPromise,
1725
+ vaultPromise,
1726
+ repositoryPromise,
1727
+ ]);
1728
+ try {
1729
+ const resources = Promise.allSettled([
1730
+ reauthorize?.dispose(),
1731
+ localPipeline?.dispose(),
1732
+ vaultServices?.dispose(),
1733
+ ]);
1734
+ await Promise.allSettled([...inFlight]);
1735
+ const results = await resources;
1736
+ while (inFlight.size > 0)
1737
+ await Promise.allSettled([...inFlight]);
1738
+ const failure = results.find((result) => result.status === 'rejected');
1739
+ if (failure?.status === 'rejected')
1740
+ throw failure.reason;
1741
+ }
1742
+ finally {
1743
+ try {
1744
+ await custody?.dispose();
1745
+ }
1746
+ finally {
1747
+ const opened = await repositoryPromise?.catch(() => undefined);
1748
+ await opened?.repository.dispose();
1749
+ }
1750
+ }
1751
+ })();
1752
+ return disposal;
1753
+ },
1754
+ };
1755
+ };
1756
+ }
1757
+ /**
1758
+ * The runtime collaborators of a repository-backed GA location: quota
1759
+ * snapshots kept in memory (a GA location writes no sidebar file), the
1760
+ * ref-attributed quota fetcher, and a token refresher that refreshes the
1761
+ * account it is handed through this activation's manager.
1762
+ */
1763
+ export function createGaRuntimeCollaborators(input) {
1764
+ return {
1765
+ quotaSnapshots: createMemoryQuotaSnapshots(),
1766
+ fetchAccountQuota: async (account, signal) => {
1767
+ const repository = await input.getRepository();
1768
+ return createGaFetchAccountQuota({
1769
+ repository,
1770
+ ...(input.assertAdmission
1771
+ ? { assertAdmission: input.assertAdmission }
1772
+ : {}),
1773
+ now: input.now,
1774
+ overrides: input.overrides,
1775
+ logger: {
1776
+ debug: (...args) => input.accounts.quotaLogger?.debug(...args),
1777
+ },
1778
+ })(account, signal);
1779
+ },
1780
+ refreshToken: async (_auth, account) => {
1781
+ const manager = input.accounts.current;
1782
+ if (manager === null || !manager.getAccounts().includes(account))
1783
+ return undefined;
1784
+ const outcome = await manager.refreshAccount(account);
1785
+ return outcome.status === 'rotated'
1786
+ ? manager.toAuthDetails(account)
1787
+ : undefined;
1788
+ },
1789
+ };
1790
+ }
1791
+ /**
1792
+ * The production GA location services: the embedded common-auth store,
1793
+ * the system clock, the repository-backed request pipeline and the
1794
+ * collaborators above. Every activation gets its own repository, account
1795
+ * slot and pipeline. With `vault`, a location can also serve the vault's
1796
+ * accounts: its mode file decides, and the menu's Vault section switches.
1797
+ */
1798
+ export function createGaLocationServicesForHost(vault) {
1799
+ return (input) => {
1800
+ const accounts = { current: null, quotaLogger: null };
1801
+ return createGaLocationServicesFactory({
1802
+ loadStoreModules: loadCommonAuthStoreModules,
1803
+ resolveAccountFile: getStoragePath,
1804
+ now: Date.now,
1805
+ runtime: ({ getRepository, assertAdmission, overrides }) => createGaRuntimeCollaborators({
1806
+ getRepository,
1807
+ assertAdmission,
1808
+ overrides,
1809
+ accounts,
1810
+ now: Date.now,
1811
+ }),
1812
+ createPipeline: (pipeline) => createGaLocalRequestPipeline({ ...pipeline, accounts }),
1813
+ ...(vault
1814
+ ? {
1815
+ custody: ({ accountFile }) => createOpenCodeVaultCustody({
1816
+ accountFile,
1817
+ readHostSlot: vault.readHostSlot,
1818
+ ...(vault.connectionFile
1819
+ ? { connectionFile: vault.connectionFile }
1820
+ : {}),
1821
+ // The engine reads each send's HTTP status itself.
1822
+ reporterSource: 'direct',
1823
+ }),
1824
+ }
1825
+ : {}),
1826
+ })(input);
1827
+ };
1828
+ }
1829
+ /** The connection API belongs to this setup context, not a module-wide host. */
1830
+ export const createGaLocationServices = (input) => {
1831
+ const readHostSlot = input.connections
1832
+ ? createGaHostSlotReader(input.connections, 'google')
1833
+ : async () => {
1834
+ throw new Error('The host integration connection API is unavailable');
1835
+ };
1836
+ return createGaLocationServicesForHost({ readHostSlot })(input);
1837
+ };
1838
+ //# sourceMappingURL=ga-location-services.js.map