@cortexkit/opencode-antigravity-auth 1.0.1 → 2.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 (374) hide show
  1. package/README.md +225 -553
  2. package/dist/cli.js +3790 -0
  3. package/dist/cli.js.map +7 -0
  4. package/dist/index.d.ts +1 -3
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +18951 -13145
  7. package/dist/index.js.map +4 -4
  8. package/dist/src/antigravity/oauth.d.ts +1 -1
  9. package/dist/src/antigravity/oauth.js +1 -1
  10. package/dist/src/cli.d.ts +21 -0
  11. package/dist/src/cli.d.ts.map +1 -0
  12. package/dist/src/cli.js +237 -0
  13. package/dist/src/cli.js.map +1 -0
  14. package/dist/src/constants.d.ts +1 -1
  15. package/dist/src/constants.js +1 -1
  16. package/dist/src/hooks/auto-update-checker/cache.d.ts.map +1 -1
  17. package/dist/src/hooks/auto-update-checker/cache.js +13 -13
  18. package/dist/src/hooks/auto-update-checker/cache.js.map +1 -1
  19. package/dist/src/hooks/auto-update-checker/checker.d.ts +1 -1
  20. package/dist/src/hooks/auto-update-checker/checker.d.ts.map +1 -1
  21. package/dist/src/hooks/auto-update-checker/checker.js +75 -51
  22. package/dist/src/hooks/auto-update-checker/checker.js.map +1 -1
  23. package/dist/src/hooks/auto-update-checker/constants.d.ts.map +1 -1
  24. package/dist/src/hooks/auto-update-checker/constants.js +12 -12
  25. package/dist/src/hooks/auto-update-checker/constants.js.map +1 -1
  26. package/dist/src/hooks/auto-update-checker/index.d.ts +6 -6
  27. package/dist/src/hooks/auto-update-checker/index.d.ts.map +1 -1
  28. package/dist/src/hooks/auto-update-checker/index.js +17 -17
  29. package/dist/src/hooks/auto-update-checker/index.js.map +1 -1
  30. package/dist/src/hooks/auto-update-checker/logging.js +2 -2
  31. package/dist/src/hooks/auto-update-checker/logging.js.map +1 -1
  32. package/dist/src/hooks/auto-update-checker/types.d.ts.map +1 -1
  33. package/dist/src/plugin/account-access.d.ts +99 -0
  34. package/dist/src/plugin/account-access.d.ts.map +1 -0
  35. package/dist/src/plugin/account-access.js +480 -0
  36. package/dist/src/plugin/account-access.js.map +1 -0
  37. package/dist/src/plugin/accounts.d.ts +7 -236
  38. package/dist/src/plugin/accounts.d.ts.map +1 -1
  39. package/dist/src/plugin/accounts.js +31 -1166
  40. package/dist/src/plugin/accounts.js.map +1 -1
  41. package/dist/src/plugin/agy-request-metadata.d.ts +2 -0
  42. package/dist/src/plugin/agy-request-metadata.d.ts.map +1 -0
  43. package/dist/src/plugin/agy-request-metadata.js +2 -0
  44. package/dist/src/plugin/agy-request-metadata.js.map +1 -0
  45. package/dist/src/plugin/agy-transport.d.ts +1 -1
  46. package/dist/src/plugin/agy-transport.js +1 -1
  47. package/dist/src/plugin/auth-doctor.d.ts +6 -6
  48. package/dist/src/plugin/auth-doctor.d.ts.map +1 -1
  49. package/dist/src/plugin/auth-doctor.js +79 -62
  50. package/dist/src/plugin/auth-doctor.js.map +1 -1
  51. package/dist/src/plugin/auth-drift.d.ts +4 -4
  52. package/dist/src/plugin/auth-drift.d.ts.map +1 -1
  53. package/dist/src/plugin/auth-drift.js +15 -15
  54. package/dist/src/plugin/auth-drift.js.map +1 -1
  55. package/dist/src/plugin/auth-loader.d.ts +35 -0
  56. package/dist/src/plugin/auth-loader.d.ts.map +1 -0
  57. package/dist/src/plugin/auth-loader.js +144 -0
  58. package/dist/src/plugin/auth-loader.js.map +1 -0
  59. package/dist/src/plugin/auth.d.ts +1 -1
  60. package/dist/src/plugin/auth.js +1 -1
  61. package/dist/src/plugin/cache/index.d.ts +1 -1
  62. package/dist/src/plugin/cache/index.d.ts.map +1 -1
  63. package/dist/src/plugin/cache/index.js +1 -1
  64. package/dist/src/plugin/cache/index.js.map +1 -1
  65. package/dist/src/plugin/cache/signature-cache.d.ts +1 -1
  66. package/dist/src/plugin/cache/signature-cache.d.ts.map +1 -1
  67. package/dist/src/plugin/cache/signature-cache.js +23 -24
  68. package/dist/src/plugin/cache/signature-cache.js.map +1 -1
  69. package/dist/src/plugin/cache.d.ts +6 -5
  70. package/dist/src/plugin/cache.d.ts.map +1 -1
  71. package/dist/src/plugin/cache.js +21 -7
  72. package/dist/src/plugin/cache.js.map +1 -1
  73. package/dist/src/plugin/catalog.d.ts +23 -0
  74. package/dist/src/plugin/catalog.d.ts.map +1 -0
  75. package/dist/src/plugin/catalog.js +60 -0
  76. package/dist/src/plugin/catalog.js.map +1 -0
  77. package/dist/src/plugin/cli.d.ts +7 -7
  78. package/dist/src/plugin/cli.d.ts.map +1 -1
  79. package/dist/src/plugin/cli.js +62 -55
  80. package/dist/src/plugin/cli.js.map +1 -1
  81. package/dist/src/plugin/command-data.d.ts +276 -0
  82. package/dist/src/plugin/command-data.d.ts.map +1 -0
  83. package/dist/src/plugin/command-data.js +325 -0
  84. package/dist/src/plugin/command-data.js.map +1 -0
  85. package/dist/src/plugin/commands.d.ts +151 -0
  86. package/dist/src/plugin/commands.d.ts.map +1 -0
  87. package/dist/src/plugin/commands.js +639 -0
  88. package/dist/src/plugin/commands.js.map +1 -0
  89. package/dist/src/plugin/config/index.d.ts +2 -2
  90. package/dist/src/plugin/config/index.d.ts.map +1 -1
  91. package/dist/src/plugin/config/index.js +2 -2
  92. package/dist/src/plugin/config/index.js.map +1 -1
  93. package/dist/src/plugin/config/loader.d.ts +1 -1
  94. package/dist/src/plugin/config/loader.d.ts.map +1 -1
  95. package/dist/src/plugin/config/loader.js +18 -16
  96. package/dist/src/plugin/config/loader.js.map +1 -1
  97. package/dist/src/plugin/config/models.d.ts +2 -2
  98. package/dist/src/plugin/config/models.d.ts.map +1 -1
  99. package/dist/src/plugin/config/models.js +1 -1
  100. package/dist/src/plugin/config/models.js.map +1 -1
  101. package/dist/src/plugin/config/operator-settings-schema.d.ts +29 -0
  102. package/dist/src/plugin/config/operator-settings-schema.d.ts.map +1 -0
  103. package/dist/src/plugin/config/operator-settings-schema.js +28 -0
  104. package/dist/src/plugin/config/operator-settings-schema.js.map +1 -0
  105. package/dist/src/plugin/config/schema.d.ts +21 -2
  106. package/dist/src/plugin/config/schema.d.ts.map +1 -1
  107. package/dist/src/plugin/config/schema.js +85 -25
  108. package/dist/src/plugin/config/schema.js.map +1 -1
  109. package/dist/src/plugin/config/updater.d.ts.map +1 -1
  110. package/dist/src/plugin/config/updater.js +15 -15
  111. package/dist/src/plugin/config/updater.js.map +1 -1
  112. package/dist/src/plugin/config/writer.d.ts +34 -0
  113. package/dist/src/plugin/config/writer.d.ts.map +1 -0
  114. package/dist/src/plugin/config/writer.js +81 -0
  115. package/dist/src/plugin/config/writer.js.map +1 -0
  116. package/dist/src/plugin/core/streaming/index.d.ts +1 -1
  117. package/dist/src/plugin/core/streaming/index.d.ts.map +1 -1
  118. package/dist/src/plugin/core/streaming/index.js +1 -1
  119. package/dist/src/plugin/core/streaming/index.js.map +1 -1
  120. package/dist/src/plugin/core/streaming/transformer.d.ts.map +1 -1
  121. package/dist/src/plugin/core/streaming/transformer.js +85 -44
  122. package/dist/src/plugin/core/streaming/transformer.js.map +1 -1
  123. package/dist/src/plugin/core/streaming/types.d.ts.map +1 -1
  124. package/dist/src/plugin/debug.d.ts +3 -3
  125. package/dist/src/plugin/debug.d.ts.map +1 -1
  126. package/dist/src/plugin/debug.js +85 -47
  127. package/dist/src/plugin/debug.js.map +1 -1
  128. package/dist/src/plugin/dependencies.d.ts +129 -0
  129. package/dist/src/plugin/dependencies.d.ts.map +1 -0
  130. package/dist/src/plugin/dependencies.js +107 -0
  131. package/dist/src/plugin/dependencies.js.map +1 -0
  132. package/dist/src/plugin/errors.d.ts +27 -0
  133. package/dist/src/plugin/errors.d.ts.map +1 -1
  134. package/dist/src/plugin/errors.js +29 -3
  135. package/dist/src/plugin/errors.js.map +1 -1
  136. package/dist/src/plugin/event-handler.d.ts +53 -0
  137. package/dist/src/plugin/event-handler.d.ts.map +1 -0
  138. package/dist/src/plugin/event-handler.js +101 -0
  139. package/dist/src/plugin/event-handler.js.map +1 -0
  140. package/dist/src/plugin/fetch/retry-state.d.ts +61 -0
  141. package/dist/src/plugin/fetch/retry-state.d.ts.map +1 -0
  142. package/dist/src/plugin/fetch/retry-state.js +248 -0
  143. package/dist/src/plugin/fetch/retry-state.js.map +1 -0
  144. package/dist/src/plugin/fetch/warmup.d.ts +30 -0
  145. package/dist/src/plugin/fetch/warmup.d.ts.map +1 -0
  146. package/dist/src/plugin/fetch/warmup.js +76 -0
  147. package/dist/src/plugin/fetch/warmup.js.map +1 -0
  148. package/dist/src/plugin/fetch-interceptor.d.ts +59 -0
  149. package/dist/src/plugin/fetch-interceptor.d.ts.map +1 -0
  150. package/dist/src/plugin/fetch-interceptor.js +1387 -0
  151. package/dist/src/plugin/fetch-interceptor.js.map +1 -0
  152. package/dist/src/plugin/fetch-routing.d.ts +26 -0
  153. package/dist/src/plugin/fetch-routing.d.ts.map +1 -0
  154. package/dist/src/plugin/fetch-routing.js +99 -0
  155. package/dist/src/plugin/fetch-routing.js.map +1 -0
  156. package/dist/src/plugin/fingerprint.d.ts +1 -1
  157. package/dist/src/plugin/fingerprint.js +1 -1
  158. package/dist/src/plugin/gemini-dump.d.ts +5 -5
  159. package/dist/src/plugin/gemini-dump.d.ts.map +1 -1
  160. package/dist/src/plugin/gemini-dump.js +109 -55
  161. package/dist/src/plugin/gemini-dump.js.map +1 -1
  162. package/dist/src/plugin/google-search-tool.d.ts +9 -0
  163. package/dist/src/plugin/google-search-tool.d.ts.map +1 -0
  164. package/dist/src/plugin/google-search-tool.js +56 -0
  165. package/dist/src/plugin/google-search-tool.js.map +1 -0
  166. package/dist/src/plugin/image-saver.d.ts +2 -21
  167. package/dist/src/plugin/image-saver.d.ts.map +1 -1
  168. package/dist/src/plugin/image-saver.js +22 -56
  169. package/dist/src/plugin/image-saver.js.map +1 -1
  170. package/dist/src/plugin/index.d.ts +23 -0
  171. package/dist/src/plugin/index.d.ts.map +1 -0
  172. package/dist/src/plugin/index.js +308 -0
  173. package/dist/src/plugin/index.js.map +1 -0
  174. package/dist/src/plugin/killswitch.d.ts +94 -0
  175. package/dist/src/plugin/killswitch.d.ts.map +1 -0
  176. package/dist/src/plugin/killswitch.js +194 -0
  177. package/dist/src/plugin/killswitch.js.map +1 -0
  178. package/dist/src/plugin/lifecycle.d.ts +40 -0
  179. package/dist/src/plugin/lifecycle.d.ts.map +1 -0
  180. package/dist/src/plugin/lifecycle.js +73 -0
  181. package/dist/src/plugin/lifecycle.js.map +1 -0
  182. package/dist/src/plugin/logger.d.ts +10 -1
  183. package/dist/src/plugin/logger.d.ts.map +1 -1
  184. package/dist/src/plugin/logger.js +38 -12
  185. package/dist/src/plugin/logger.js.map +1 -1
  186. package/dist/src/plugin/logging-utils.d.ts +35 -1
  187. package/dist/src/plugin/logging-utils.d.ts.map +1 -1
  188. package/dist/src/plugin/logging-utils.js +98 -15
  189. package/dist/src/plugin/logging-utils.js.map +1 -1
  190. package/dist/src/plugin/model-registry.d.ts +1 -1
  191. package/dist/src/plugin/model-registry.js +1 -1
  192. package/dist/src/plugin/oauth-login.d.ts +22 -0
  193. package/dist/src/plugin/oauth-login.d.ts.map +1 -0
  194. package/dist/src/plugin/oauth-login.js +37 -0
  195. package/dist/src/plugin/oauth-login.js.map +1 -0
  196. package/dist/src/plugin/oauth-methods.d.ts +42 -0
  197. package/dist/src/plugin/oauth-methods.d.ts.map +1 -0
  198. package/dist/src/plugin/oauth-methods.js +1284 -0
  199. package/dist/src/plugin/oauth-methods.js.map +1 -0
  200. package/dist/src/plugin/operator-settings.d.ts +40 -0
  201. package/dist/src/plugin/operator-settings.d.ts.map +1 -0
  202. package/dist/src/plugin/operator-settings.js +148 -0
  203. package/dist/src/plugin/operator-settings.js.map +1 -0
  204. package/dist/src/plugin/persist-account-pool.d.ts +37 -0
  205. package/dist/src/plugin/persist-account-pool.d.ts.map +1 -0
  206. package/dist/src/plugin/persist-account-pool.js +142 -0
  207. package/dist/src/plugin/persist-account-pool.js.map +1 -0
  208. package/dist/src/plugin/project.d.ts +1 -1
  209. package/dist/src/plugin/project.js +1 -1
  210. package/dist/src/plugin/prompt-context.d.ts.map +1 -1
  211. package/dist/src/plugin/prompt-context.js +11 -11
  212. package/dist/src/plugin/prompt-context.js.map +1 -1
  213. package/dist/src/plugin/quota.d.ts +97 -41
  214. package/dist/src/plugin/quota.d.ts.map +1 -1
  215. package/dist/src/plugin/quota.js +273 -285
  216. package/dist/src/plugin/quota.js.map +1 -1
  217. package/dist/src/plugin/recovery/constants.d.ts.map +1 -1
  218. package/dist/src/plugin/recovery/constants.js +24 -15
  219. package/dist/src/plugin/recovery/constants.js.map +1 -1
  220. package/dist/src/plugin/recovery/index.d.ts +3 -3
  221. package/dist/src/plugin/recovery/index.d.ts.map +1 -1
  222. package/dist/src/plugin/recovery/index.js +3 -3
  223. package/dist/src/plugin/recovery/index.js.map +1 -1
  224. package/dist/src/plugin/recovery/storage.d.ts +1 -1
  225. package/dist/src/plugin/recovery/storage.d.ts.map +1 -1
  226. package/dist/src/plugin/recovery/storage.js +31 -39
  227. package/dist/src/plugin/recovery/storage.js.map +1 -1
  228. package/dist/src/plugin/recovery/types.d.ts +12 -12
  229. package/dist/src/plugin/recovery/types.d.ts.map +1 -1
  230. package/dist/src/plugin/recovery.d.ts +3 -3
  231. package/dist/src/plugin/recovery.d.ts.map +1 -1
  232. package/dist/src/plugin/recovery.js +62 -58
  233. package/dist/src/plugin/recovery.js.map +1 -1
  234. package/dist/src/plugin/refresh-queue.d.ts +5 -2
  235. package/dist/src/plugin/refresh-queue.d.ts.map +1 -1
  236. package/dist/src/plugin/refresh-queue.js +37 -15
  237. package/dist/src/plugin/refresh-queue.js.map +1 -1
  238. package/dist/src/plugin/request-helpers.d.ts +2 -1
  239. package/dist/src/plugin/request-helpers.d.ts.map +1 -1
  240. package/dist/src/plugin/request-helpers.js +458 -354
  241. package/dist/src/plugin/request-helpers.js.map +1 -1
  242. package/dist/src/plugin/request.d.ts +12 -6
  243. package/dist/src/plugin/request.d.ts.map +1 -1
  244. package/dist/src/plugin/request.js +801 -390
  245. package/dist/src/plugin/request.js.map +1 -1
  246. package/dist/src/plugin/rotation.d.ts +1 -168
  247. package/dist/src/plugin/rotation.d.ts.map +1 -1
  248. package/dist/src/plugin/rotation.js +1 -327
  249. package/dist/src/plugin/rotation.js.map +1 -1
  250. package/dist/src/plugin/search.d.ts.map +1 -1
  251. package/dist/src/plugin/search.js +39 -35
  252. package/dist/src/plugin/search.js.map +1 -1
  253. package/dist/src/plugin/server.d.ts +1 -1
  254. package/dist/src/plugin/server.d.ts.map +1 -1
  255. package/dist/src/plugin/server.js +42 -37
  256. package/dist/src/plugin/server.js.map +1 -1
  257. package/dist/src/plugin/session-context.d.ts +22 -0
  258. package/dist/src/plugin/session-context.d.ts.map +1 -0
  259. package/dist/src/plugin/session-context.js +67 -0
  260. package/dist/src/plugin/session-context.js.map +1 -0
  261. package/dist/src/plugin/storage.d.ts +59 -114
  262. package/dist/src/plugin/storage.d.ts.map +1 -1
  263. package/dist/src/plugin/storage.js +140 -474
  264. package/dist/src/plugin/storage.js.map +1 -1
  265. package/dist/src/plugin/stores/signature-store.d.ts.map +1 -1
  266. package/dist/src/plugin/stores/signature-store.js.map +1 -1
  267. package/dist/src/plugin/thinking-recovery.d.ts.map +1 -1
  268. package/dist/src/plugin/thinking-recovery.js +35 -33
  269. package/dist/src/plugin/thinking-recovery.js.map +1 -1
  270. package/dist/src/plugin/token.d.ts +2 -2
  271. package/dist/src/plugin/token.d.ts.map +1 -1
  272. package/dist/src/plugin/token.js +30 -21
  273. package/dist/src/plugin/token.js.map +1 -1
  274. package/dist/src/plugin/transform/cross-model-sanitizer.d.ts +1 -1
  275. package/dist/src/plugin/transform/cross-model-sanitizer.js +1 -1
  276. package/dist/src/plugin/transform/index.d.ts +1 -1
  277. package/dist/src/plugin/transform/index.js +1 -1
  278. package/dist/src/plugin/transform/model-resolver.d.ts +1 -1
  279. package/dist/src/plugin/transform/model-resolver.js +1 -1
  280. package/dist/src/plugin/transform/types.d.ts +1 -1
  281. package/dist/src/plugin/transform/types.js +1 -1
  282. package/dist/src/plugin/types.d.ts +25 -69
  283. package/dist/src/plugin/types.d.ts.map +1 -1
  284. package/dist/src/plugin/ui/ansi.d.ts.map +1 -1
  285. package/dist/src/plugin/ui/ansi.js.map +1 -1
  286. package/dist/src/plugin/ui/auth-menu.d.ts +2 -2
  287. package/dist/src/plugin/ui/auth-menu.d.ts.map +1 -1
  288. package/dist/src/plugin/ui/auth-menu.js +84 -31
  289. package/dist/src/plugin/ui/auth-menu.js.map +1 -1
  290. package/dist/src/plugin/ui/confirm.d.ts.map +1 -1
  291. package/dist/src/plugin/ui/confirm.js.map +1 -1
  292. package/dist/src/plugin/ui/model-status.d.ts +3 -3
  293. package/dist/src/plugin/ui/model-status.d.ts.map +1 -1
  294. package/dist/src/plugin/ui/model-status.js +3 -3
  295. package/dist/src/plugin/ui/model-status.js.map +1 -1
  296. package/dist/src/plugin/ui/quota-status.d.ts +4 -4
  297. package/dist/src/plugin/ui/quota-status.d.ts.map +1 -1
  298. package/dist/src/plugin/ui/quota-status.js +51 -48
  299. package/dist/src/plugin/ui/quota-status.js.map +1 -1
  300. package/dist/src/plugin/ui/select.d.ts.map +1 -1
  301. package/dist/src/plugin/ui/select.js +22 -12
  302. package/dist/src/plugin/ui/select.js.map +1 -1
  303. package/dist/src/plugin/version.d.ts +1 -1
  304. package/dist/src/plugin/version.js +1 -1
  305. package/dist/src/rpc/notifications.d.ts +6 -0
  306. package/dist/src/rpc/notifications.d.ts.map +1 -0
  307. package/dist/src/rpc/notifications.js +46 -0
  308. package/dist/src/rpc/notifications.js.map +1 -0
  309. package/dist/src/rpc/port-file.d.ts +13 -0
  310. package/dist/src/rpc/port-file.d.ts.map +1 -0
  311. package/dist/src/rpc/port-file.js +109 -0
  312. package/dist/src/rpc/port-file.js.map +1 -0
  313. package/dist/src/rpc/protocol.d.ts +22 -0
  314. package/dist/src/rpc/protocol.d.ts.map +1 -0
  315. package/dist/src/rpc/protocol.js +1 -0
  316. package/dist/src/rpc/protocol.js.map +1 -0
  317. package/dist/src/rpc/rpc-client.d.ts +10 -0
  318. package/dist/src/rpc/rpc-client.d.ts.map +1 -0
  319. package/dist/src/rpc/rpc-client.js +58 -0
  320. package/dist/src/rpc/rpc-client.js.map +1 -0
  321. package/dist/src/rpc/rpc-dir.d.ts +4 -0
  322. package/dist/src/rpc/rpc-dir.d.ts.map +1 -0
  323. package/dist/src/rpc/rpc-dir.js +19 -0
  324. package/dist/src/rpc/rpc-dir.js.map +1 -0
  325. package/dist/src/rpc/rpc-server.d.ts +13 -0
  326. package/dist/src/rpc/rpc-server.d.ts.map +1 -0
  327. package/dist/src/rpc/rpc-server.js +231 -0
  328. package/dist/src/rpc/rpc-server.js.map +1 -0
  329. package/dist/src/sidebar-state.d.ts +240 -0
  330. package/dist/src/sidebar-state.d.ts.map +1 -0
  331. package/dist/src/sidebar-state.js +520 -0
  332. package/dist/src/sidebar-state.js.map +1 -0
  333. package/dist/src/tui/command-dialogs.d.ts +61 -0
  334. package/dist/src/tui/command-dialogs.d.ts.map +1 -0
  335. package/dist/src/tui/command-dialogs.js +497 -0
  336. package/dist/src/tui/command-dialogs.js.map +1 -0
  337. package/dist/src/tui/file-logger.d.ts +41 -0
  338. package/dist/src/tui/file-logger.d.ts.map +1 -0
  339. package/dist/src/tui/file-logger.js +114 -0
  340. package/dist/src/tui/file-logger.js.map +1 -0
  341. package/dist/src/tui-preferences.d.ts +40 -0
  342. package/dist/src/tui-preferences.d.ts.map +1 -0
  343. package/dist/src/tui-preferences.js +328 -0
  344. package/dist/src/tui-preferences.js.map +1 -0
  345. package/dist/src/tui.d.ts +68 -0
  346. package/dist/src/tui.d.ts.map +1 -0
  347. package/dist/src/tui.js +662 -0
  348. package/dist/src/tui.js.map +1 -0
  349. package/package.json +46 -22
  350. package/src/plugin/command-data.ts +651 -0
  351. package/src/rpc/port-file.ts +143 -0
  352. package/src/rpc/protocol.ts +31 -0
  353. package/src/rpc/rpc-client.ts +102 -0
  354. package/src/rpc/rpc-dir.ts +24 -0
  355. package/src/sidebar-state.ts +717 -0
  356. package/src/tui/command-dialogs.tsx +699 -0
  357. package/src/tui/entry.mjs +74 -0
  358. package/src/tui/file-logger.ts +145 -0
  359. package/src/tui-compiled/plugin/command-data.ts +651 -0
  360. package/src/tui-compiled/rpc/port-file.ts +143 -0
  361. package/src/tui-compiled/rpc/protocol.ts +31 -0
  362. package/src/tui-compiled/rpc/rpc-client.ts +102 -0
  363. package/src/tui-compiled/rpc/rpc-dir.ts +24 -0
  364. package/src/tui-compiled/sidebar-state.ts +717 -0
  365. package/src/tui-compiled/tui/command-dialogs.tsx +659 -0
  366. package/src/tui-compiled/tui/file-logger.ts +145 -0
  367. package/src/tui-compiled/tui-preferences.ts +416 -0
  368. package/src/tui-compiled/tui.tsx +1150 -0
  369. package/src/tui-preferences.ts +416 -0
  370. package/src/tui.tsx +1117 -0
  371. package/dist/src/plugin.d.ts +0 -32
  372. package/dist/src/plugin.d.ts.map +0 -1
  373. package/dist/src/plugin.js +0 -3151
  374. package/dist/src/plugin.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sidebar-state.d.ts","sourceRoot":"","sources":["../../src/sidebar-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAeH,eAAO,MAAM,qBAAqB,EAAG,CAAU,CAAA;AAE/C,MAAM,MAAM,eAAe,GACvB,QAAQ,GACR,YAAY,GACZ,cAAc,GACd,SAAS,CAAA;AAEb,MAAM,WAAW,iBAAiB;IAChC,gBAAgB,EAAE,MAAM,CAAA;IACxB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,OAAO,CAAA;IAChB,aAAa,CAA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Sidebar state contract for the OpenTUI sidebar.
3
+ *
4
+ * This module is the read-only seam between the long-running plugin and the
5
+ * Solid/OpenTUI sidebar tree. It deliberately does NOT import account storage,
6
+ * the account manager, OAuth code, or any other privileged host-side module:
7
+ * the TUI is rendered inside the host's terminal and a single stray import
8
+ * could leak credentials or pull a heavy manager into the render path.
9
+ *
10
+ * The plugin writes a redacted snapshot to the file resolved by
11
+ * `getSidebarStateFile()` and the TUI polls it. The contract version is `1`:
12
+ * any future field that the TUI cannot understand must be ignored, and any
13
+ * broken/missing file must collapse to `DEFAULT_SIDEBAR_STATE`.
14
+ *
15
+ * ## Writer surface
16
+ *
17
+ * The plugin-side writers live here too so the read and write halves of the
18
+ * contract evolve together. They are imported by the plugin (auth-loader,
19
+ * quota, fetch-interceptor, event-handler, commands) but never invoked from
20
+ * the TUI's compiled tree — that tree only calls the readers, so the
21
+ * heavyweight core imports below never run inside the host's render path.
22
+ *
23
+ * Every disk mutation follows the same recipe:
24
+ *
25
+ * 1. Serialize through `sidebarWriteChain` so concurrent in-process calls
26
+ * never interleave merges against the same file.
27
+ * 2. Acquire Task 7's `acquireFencedFileLock` with bounded retry+jitter
28
+ * (≤2s). A live cross-process holder that does not release in time
29
+ * surfaces as `SidebarStateLockContentionError`.
30
+ * 3. Re-read and normalize the on-disk state while holding the lock.
31
+ * 4. Merge the new machine or routing payload against the re-read state.
32
+ * 5. `assertOwned()` + `writeJsonAtomic` with mode 0o600, then release.
33
+ *
34
+ * The merge step is deterministic: machine fields adopt only when the new
35
+ * `checkedAt` is ≥ the on-disk one, `routingAuthoritative` is sticky-true,
36
+ * and `activeRouting` is merged independently and pruned to the freshest
37
+ * 100 entries within 24h.
38
+ */
39
+ import { mkdirSync, readFileSync } from 'node:fs';
40
+ import { homedir } from 'node:os';
41
+ import { dirname, join } from 'node:path';
42
+ // Subpath imports (not the barrel): this file ships into the TUI's
43
+ // compiled tree, and the barrel re-exports account/OAuth/quota modules
44
+ // that must never execute inside the host's render path.
45
+ import { writeJsonAtomic } from '@cortexkit/antigravity-auth-core/atomic-write';
46
+ import { acquireFencedFileLock, } from '@cortexkit/antigravity-auth-core/file-lock';
47
+ import { xdgState } from 'xdg-basedir';
48
+ export const SIDEBAR_STATE_VERSION = 1;
49
+ export const DEFAULT_SIDEBAR_STATE = {
50
+ version: SIDEBAR_STATE_VERSION,
51
+ checkedAt: 0,
52
+ accounts: [],
53
+ activeRouting: {},
54
+ routingAuthoritative: false,
55
+ };
56
+ export const SIDEBAR_STATE_ENV = 'ANTIGRAVITY_AUTH_SIDEBAR_STATE_FILE';
57
+ const SIDEBAR_STATE_DIR = 'cortexkit/antigravity-auth';
58
+ const SIDEBAR_STATE_FILENAME = 'sidebar-state.json';
59
+ /** Active routing entries older than this are dropped on every merge. */
60
+ const ACTIVE_ROUTING_MAX_AGE_MS = 24 * 60 * 60 * 1000;
61
+ /** Active routing map is capped at this many newest entries. */
62
+ const ACTIVE_ROUTING_MAX_ENTRIES = 100;
63
+ const SIDEBAR_LOCK_NAME = 'sidebar';
64
+ const SIDEBAR_LOCK_TTL_MS = 10_000;
65
+ const SIDEBAR_LOCK_TIMEOUT_MS = 2_000;
66
+ const SIDEBAR_LOCK_RETRY_BASE_MS = 25;
67
+ const SIDEBAR_LOCK_RETRY_CAP_MS = 75;
68
+ const SIDEBAR_LOCK_JITTER_MS = 25;
69
+ const SIDEBAR_STATE_DIR_MODE = 0o700;
70
+ const SIDEBAR_STATE_FILE_MODE = 0o600;
71
+ /**
72
+ * Thrown by every writer when the cross-process lock cannot be acquired
73
+ * within `SIDEBAR_LOCK_TIMEOUT_MS`. The caller decides whether to surface
74
+ * a toast, drop the write, or retry the next tick.
75
+ */
76
+ export class SidebarStateLockContentionError extends Error {
77
+ details;
78
+ constructor(stateFile, timeoutMs) {
79
+ super(`Could not acquire sidebar-state lock at ${stateFile} within ${timeoutMs}ms`);
80
+ this.name = 'SidebarStateLockContentionError';
81
+ this.details = { stateFile, timeoutMs };
82
+ }
83
+ }
84
+ let sidebarMergeHooks = null;
85
+ /**
86
+ * Install (or clear with `null`) the deterministic race hooks. Tests use
87
+ * these to inject interleavings; production callers leave them unset. The
88
+ * module-level state means a test must reset hooks in its own `afterEach`
89
+ * to avoid bleeding into the next test.
90
+ */
91
+ export function setSidebarMergeHooks(hooks) {
92
+ sidebarMergeHooks = hooks;
93
+ }
94
+ async function emitMergeStep(step) {
95
+ await sidebarMergeHooks?.onStep?.(step);
96
+ }
97
+ /**
98
+ * Resolve the on-disk path the plugin writes to and the TUI reads from.
99
+ *
100
+ * - `ANTIGRAVITY_AUTH_SIDEBAR_STATE_FILE` wins when set (tests, packaged
101
+ * installers, and any user override).
102
+ * - Otherwise fall back to the XDG state directory, mirroring the path
103
+ * conventions used elsewhere in the project.
104
+ */
105
+ export function getSidebarStateFile() {
106
+ const override = process.env[SIDEBAR_STATE_ENV];
107
+ if (override && override.trim().length > 0)
108
+ return override;
109
+ const base = xdgState ?? join(homedir(), '.local', 'state');
110
+ return join(base, SIDEBAR_STATE_DIR, SIDEBAR_STATE_FILENAME);
111
+ }
112
+ /**
113
+ * Read and normalize the sidebar state file. Returns the default state when
114
+ * the file is missing, unreadable, malformed, or schema-incompatible — the TUI
115
+ * must never throw out of `readSidebarState()`, the panel just shows
116
+ * "Awaiting Antigravity state" and the next poll retries.
117
+ *
118
+ * The read is sync on purpose: the TUI polls on a 2-second timer and the file
119
+ * is tiny (a handful of accounts); an async read here would just add race
120
+ * surface area against Solid's reactive render cycle.
121
+ */
122
+ export function readSidebarState(path = getSidebarStateFile()) {
123
+ let raw;
124
+ try {
125
+ raw = readFileSync(path, 'utf-8');
126
+ }
127
+ catch {
128
+ return { ...DEFAULT_SIDEBAR_STATE };
129
+ }
130
+ let parsed;
131
+ try {
132
+ parsed = JSON.parse(raw);
133
+ }
134
+ catch {
135
+ return { ...DEFAULT_SIDEBAR_STATE, lastError: 'malformed-json' };
136
+ }
137
+ return normalizeSidebarState(parsed);
138
+ }
139
+ function normalizeSidebarState(input) {
140
+ if (!isObject(input)) {
141
+ return { ...DEFAULT_SIDEBAR_STATE, lastError: 'shape' };
142
+ }
143
+ const record = input;
144
+ const version = record.version;
145
+ if (version !== SIDEBAR_STATE_VERSION) {
146
+ return {
147
+ ...DEFAULT_SIDEBAR_STATE,
148
+ lastError: `unsupported-version:${stringifySafe(version)}`,
149
+ };
150
+ }
151
+ const accountsRaw = record.accounts;
152
+ const accounts = Array.isArray(accountsRaw)
153
+ ? accountsRaw
154
+ .map((entry) => normalizeAccount(entry))
155
+ .filter((entry) => entry !== null)
156
+ : [];
157
+ const routingRaw = record.activeRouting;
158
+ const activeRouting = {};
159
+ if (isObject(routingRaw)) {
160
+ for (const [sessionId, entry] of Object.entries(routingRaw)) {
161
+ const normalized = normalizeRouting(entry);
162
+ if (normalized)
163
+ activeRouting[sessionId] = normalized;
164
+ }
165
+ }
166
+ const checkedAt = toFiniteNumber(record.checkedAt);
167
+ const routingAuthoritative = record.routingAuthoritative === true;
168
+ const quotaBackoffUntil = toFiniteNumber(record.quotaBackoffUntil);
169
+ const lastError = typeof record.lastError === 'string' ? record.lastError : undefined;
170
+ return {
171
+ version: SIDEBAR_STATE_VERSION,
172
+ checkedAt: checkedAt ?? 0,
173
+ accounts,
174
+ activeRouting,
175
+ routingAuthoritative,
176
+ quotaBackoffUntil: quotaBackoffUntil ?? undefined,
177
+ lastError,
178
+ };
179
+ }
180
+ function normalizeAccount(input) {
181
+ if (!isObject(input))
182
+ return null;
183
+ const record = input;
184
+ const id = typeof record.id === 'string' ? record.id : null;
185
+ const label = typeof record.label === 'string' ? record.label : null;
186
+ if (!id || !label)
187
+ return null;
188
+ const enabled = record.enabled !== false;
189
+ const health = clampNumber(toFiniteNumber(record.health), 0, 100);
190
+ const current = record.current === true;
191
+ const cooldownUntil = toFiniteNumber(record.cooldownUntil) ?? undefined;
192
+ const quotaRaw = record.quota;
193
+ const quota = {};
194
+ if (isObject(quotaRaw)) {
195
+ for (const key of [
196
+ 'claude',
197
+ 'gemini-pro',
198
+ 'gemini-flash',
199
+ 'gpt-oss',
200
+ ]) {
201
+ const entry = quotaRaw[key];
202
+ const normalized = normalizeQuota(entry);
203
+ if (normalized)
204
+ quota[key] = normalized;
205
+ }
206
+ }
207
+ return {
208
+ id,
209
+ label,
210
+ enabled,
211
+ health,
212
+ current,
213
+ cooldownUntil,
214
+ quota,
215
+ };
216
+ }
217
+ function normalizeQuota(input) {
218
+ if (!isObject(input))
219
+ return null;
220
+ const record = input;
221
+ const remaining = toFiniteNumber(record.remainingPercent);
222
+ if (remaining === null)
223
+ return null;
224
+ const resetAt = toFiniteNumber(record.resetAt) ?? undefined;
225
+ return {
226
+ remainingPercent: clampNumber(remaining, 0, 100),
227
+ resetAt,
228
+ };
229
+ }
230
+ function normalizeRouting(input) {
231
+ if (!isObject(input))
232
+ return null;
233
+ const record = input;
234
+ const accountId = typeof record.accountId === 'string' ? record.accountId : null;
235
+ const modelFamily = record.modelFamily;
236
+ const headerStyle = record.headerStyle;
237
+ const strategy = record.strategy;
238
+ const updatedAt = toFiniteNumber(record.updatedAt) ?? 0;
239
+ if (!accountId ||
240
+ (modelFamily !== 'claude' && modelFamily !== 'gemini') ||
241
+ (headerStyle !== 'antigravity' && headerStyle !== 'gemini-cli')) {
242
+ return null;
243
+ }
244
+ return {
245
+ accountId,
246
+ modelFamily,
247
+ headerStyle,
248
+ strategy: strategy === 'sticky' ||
249
+ strategy === 'round-robin' ||
250
+ strategy === 'hybrid'
251
+ ? strategy
252
+ : undefined,
253
+ updatedAt,
254
+ };
255
+ }
256
+ function isObject(value) {
257
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
258
+ }
259
+ function toFiniteNumber(value) {
260
+ if (typeof value === 'number' && Number.isFinite(value))
261
+ return value;
262
+ if (typeof value === 'string') {
263
+ const parsed = Number(value);
264
+ return Number.isFinite(parsed) ? parsed : null;
265
+ }
266
+ return null;
267
+ }
268
+ function clampNumber(value, min, max) {
269
+ if (value === null)
270
+ return min;
271
+ if (value < min)
272
+ return min;
273
+ if (value > max)
274
+ return max;
275
+ return value;
276
+ }
277
+ function stringifySafe(value) {
278
+ if (typeof value === 'string')
279
+ return value;
280
+ try {
281
+ return JSON.stringify(value) ?? 'unknown';
282
+ }
283
+ catch {
284
+ return 'unknown';
285
+ }
286
+ }
287
+ /**
288
+ * Ensure the parent directory for the sidebar state file exists. Convenience
289
+ * helper used by writers (tests, plugins) — the TUI itself does not write.
290
+ */
291
+ export function ensureSidebarStateDir(path = getSidebarStateFile()) {
292
+ mkdirSync(dirname(path), { recursive: true, mode: SIDEBAR_STATE_DIR_MODE });
293
+ }
294
+ /**
295
+ * Drop active-routing entries older than 24h and cap the map at the freshest
296
+ * 100. Pure helper exposed for unit testing; the writers call it on every
297
+ * merge so the on-disk map never grows without bound.
298
+ */
299
+ export function pruneActiveRouting(map, now) {
300
+ const cutoff = now - ACTIVE_ROUTING_MAX_AGE_MS;
301
+ const filtered = [];
302
+ for (const [sessionId, entry] of Object.entries(map)) {
303
+ if (entry.updatedAt >= cutoff) {
304
+ filtered.push([sessionId, entry]);
305
+ }
306
+ }
307
+ filtered.sort((a, b) => b[1].updatedAt - a[1].updatedAt);
308
+ if (filtered.length <= ACTIVE_ROUTING_MAX_ENTRIES) {
309
+ return Object.fromEntries(filtered);
310
+ }
311
+ return Object.fromEntries(filtered.slice(0, ACTIVE_ROUTING_MAX_ENTRIES));
312
+ }
313
+ /**
314
+ * Convert a live account snapshot into the redacted shape the TUI renders.
315
+ * The redacted `SidebarAccountState` carries no email, refresh token, access
316
+ * token, project ID, fingerprint, OAuth profile name, or other personal or
317
+ * credential-shaped fields. Display labels are generated ordinal account names.
318
+ */
319
+ export function redactAccountForSidebar(source) {
320
+ const id = `acct-${source.index}`;
321
+ const label = `Account ${source.index + 1}`;
322
+ const enabled = source.enabled !== false;
323
+ const current = source.current === true;
324
+ const cooldownUntil = typeof source.coolingDownUntil === 'number' &&
325
+ Number.isFinite(source.coolingDownUntil)
326
+ ? source.coolingDownUntil
327
+ : undefined;
328
+ const health = clampNumber(typeof source.healthScore === 'number' ? source.healthScore : null, 0, 100);
329
+ const quota = {};
330
+ const cached = source.cachedQuota;
331
+ if (cached) {
332
+ for (const key of [
333
+ 'claude',
334
+ 'gemini-pro',
335
+ 'gemini-flash',
336
+ 'gpt-oss',
337
+ ]) {
338
+ const entry = cached[key];
339
+ if (!entry)
340
+ continue;
341
+ const fraction = entry.remainingFraction;
342
+ if (typeof fraction !== 'number' || !Number.isFinite(fraction))
343
+ continue;
344
+ const remainingPercent = clampNumber(Math.round(fraction * 100), 0, 100);
345
+ let resetAt;
346
+ if (typeof entry.resetTime === 'string' && entry.resetTime.length > 0) {
347
+ const parsed = Date.parse(entry.resetTime);
348
+ if (Number.isFinite(parsed))
349
+ resetAt = parsed;
350
+ }
351
+ quota[key] = { remainingPercent, resetAt };
352
+ }
353
+ }
354
+ return {
355
+ id,
356
+ label,
357
+ enabled,
358
+ health,
359
+ current,
360
+ cooldownUntil,
361
+ quota,
362
+ };
363
+ }
364
+ /**
365
+ * Build a `SidebarMachineState` from a list of live account snapshots.
366
+ * Convenience for the auth-loader / quota writer call sites that already
367
+ * hold an array of accounts and want to push a single snapshot.
368
+ */
369
+ export function buildSidebarMachineStateFromAccounts(accounts, options = {}) {
370
+ return {
371
+ checkedAt: options.checkedAt ?? Date.now(),
372
+ accounts: accounts.map((entry) => redactAccountForSidebar(entry)),
373
+ quotaBackoffUntil: options.quotaBackoffUntil,
374
+ lastError: options.lastError,
375
+ routingAuthoritative: options.routingAuthoritative,
376
+ };
377
+ }
378
+ let sidebarWriteChain = Promise.resolve();
379
+ function enqueueSidebarWrite(work) {
380
+ // Always run `work` regardless of whether the prior link resolved or
381
+ // rejected — a failed write must not poison the chain for the next caller.
382
+ const next = sidebarWriteChain.then(work, work);
383
+ sidebarWriteChain = next.then(() => undefined, () => undefined);
384
+ return next;
385
+ }
386
+ /**
387
+ * Wait for any in-flight sidebar state write to drain. The plugin lifecycle
388
+ * calls this during `dispose()` so the file logger and RPC server are torn
389
+ * down only after every queued write has either landed or thrown.
390
+ */
391
+ export function drainSidebarWrites() {
392
+ return sidebarWriteChain;
393
+ }
394
+ async function sleep(ms) {
395
+ await new Promise((resolve) => setTimeout(resolve, ms));
396
+ }
397
+ async function acquireSidebarLockWithRetry(stateFile) {
398
+ const start = Date.now();
399
+ let attempt = 0;
400
+ while (true) {
401
+ await emitMergeStep('await-lock');
402
+ const lock = await acquireFencedFileLock({
403
+ path: stateFile,
404
+ name: SIDEBAR_LOCK_NAME,
405
+ ttlMs: SIDEBAR_LOCK_TTL_MS,
406
+ renew: true,
407
+ });
408
+ if (lock) {
409
+ await emitMergeStep('acquired-lock');
410
+ return lock;
411
+ }
412
+ const elapsed = Date.now() - start;
413
+ if (elapsed >= SIDEBAR_LOCK_TIMEOUT_MS) {
414
+ throw new SidebarStateLockContentionError(stateFile, SIDEBAR_LOCK_TIMEOUT_MS);
415
+ }
416
+ const backoff = Math.min(SIDEBAR_LOCK_RETRY_CAP_MS, SIDEBAR_LOCK_RETRY_BASE_MS + attempt * 10);
417
+ const jitter = Math.floor(Math.random() * SIDEBAR_LOCK_JITTER_MS);
418
+ await sleep(backoff + jitter);
419
+ attempt++;
420
+ }
421
+ }
422
+ async function performSidebarWrite(stateFile, merge) {
423
+ await enqueueSidebarWrite(async () => {
424
+ ensureSidebarStateDir(stateFile);
425
+ const lock = await acquireSidebarLockWithRetry(stateFile);
426
+ try {
427
+ await lock.assertOwned();
428
+ const existing = readSidebarState(stateFile);
429
+ await emitMergeStep('read-state');
430
+ const merged = merge(existing);
431
+ await emitMergeStep('merged-state');
432
+ await writeJsonAtomic(stateFile, merged);
433
+ // `writeJsonAtomic` stages a tmp file with mode 0o600 and renames onto
434
+ // the target; POSIX rename replaces the inode so the new file inherits
435
+ // the staged mode bits. Windows ignores POSIX modes so the assertion
436
+ // in tests is best-effort there.
437
+ await emitMergeStep('wrote-state');
438
+ }
439
+ finally {
440
+ await lock.release().catch(() => { });
441
+ }
442
+ });
443
+ }
444
+ /**
445
+ * Merge a new machine-state payload against the on-disk state.
446
+ *
447
+ * Stale writes (new `checkedAt` < existing) are dropped — only newer/equal
448
+ * `checkedAt` may replace machine fields. The merge preserves
449
+ * `routingAuthoritative: true` once it is true (sticky-true), keeps the
450
+ * existing `activeRouting` intact (routing is merged via its own writer),
451
+ * and prunes any expired routing entries as a side effect.
452
+ */
453
+ function mergeMachineState(existing, next) {
454
+ if (next.checkedAt < existing.checkedAt) {
455
+ return {
456
+ ...existing,
457
+ activeRouting: pruneActiveRouting(existing.activeRouting, Date.now()),
458
+ };
459
+ }
460
+ return {
461
+ version: SIDEBAR_STATE_VERSION,
462
+ checkedAt: next.checkedAt,
463
+ accounts: next.accounts,
464
+ quotaBackoffUntil: next.quotaBackoffUntil,
465
+ lastError: next.lastError,
466
+ routingAuthoritative: existing.routingAuthoritative === true ||
467
+ next.routingAuthoritative === true,
468
+ // Symmetric with the stale-write branch: every machine-write merge
469
+ // re-prunes activeRouting so a long-running TUI session eventually
470
+ // drops dead routes even when no fresh routing upsert lands. Cheap
471
+ // (a single Object.entries + sort over ≤100 entries) and bounded.
472
+ activeRouting: pruneActiveRouting(existing.activeRouting, Date.now()),
473
+ };
474
+ }
475
+ /**
476
+ * Upsert a single session's active routing entry. The fetch interceptor calls
477
+ * this with `authoritative: true` after every final route selection; the
478
+ * `accountId`/`modelFamily`/`headerStyle` fields are already redacted by the
479
+ * caller (the writer never sees token or project fields).
480
+ */
481
+ export async function upsertSidebarActiveRouting(sessionId, entry, options = {}) {
482
+ const stateFile = options.stateFile ?? getSidebarStateFile();
483
+ await performSidebarWrite(stateFile, (existing) => {
484
+ const activeRouting = { ...existing.activeRouting, [sessionId]: entry };
485
+ return {
486
+ ...existing,
487
+ routingAuthoritative: options.authoritative === true ? true : existing.routingAuthoritative,
488
+ activeRouting: pruneActiveRouting(activeRouting, Date.now()),
489
+ };
490
+ });
491
+ }
492
+ /**
493
+ * Remove one session's active routing entry. The event handler calls this
494
+ * when a session is deleted so the sidebar does not retain dead routes.
495
+ */
496
+ export async function removeSidebarActiveRouting(sessionId, options = {}) {
497
+ const stateFile = options.stateFile ?? getSidebarStateFile();
498
+ await performSidebarWrite(stateFile, (existing) => {
499
+ if (!(sessionId in existing.activeRouting)) {
500
+ return existing;
501
+ }
502
+ const activeRouting = { ...existing.activeRouting };
503
+ delete activeRouting[sessionId];
504
+ return {
505
+ ...existing,
506
+ activeRouting,
507
+ };
508
+ });
509
+ }
510
+ /**
511
+ * Write a new machine-state snapshot. The fetch interceptor and quota
512
+ * manager call this after each refresh; auth-loader calls it after the
513
+ * account pool is materialized.
514
+ */
515
+ export async function setSidebarMachineState(next, options = {}) {
516
+ const stateFile = options.stateFile ?? getSidebarStateFile();
517
+ await performSidebarWrite(stateFile, (existing) => mergeMachineState(existing, next));
518
+ }
519
+ void SIDEBAR_STATE_FILE_MODE;
520
+ //# sourceMappingURL=sidebar-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sidebar-state.js","sourceRoot":"","sources":["../../src/sidebar-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACzC,mEAAmE;AACnE,uEAAuE;AACvE,yDAAyD;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,+CAA+C,CAAA;AAC/E,OAAO,EACL,qBAAqB,GAEtB,MAAM,4CAA4C,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAU,CAAA;AA2D/C,MAAM,CAAC,MAAM,qBAAqB,GAAmB;IACnD,OAAO,EAAE,qBAAqB;IAC9B,SAAS,EAAE,CAAC;IACZ,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d,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,IAAyB,EACzB,UAAoC,EAAE;IAEtC,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,mBAAmB,EAAE,CAAA;IAC5D,MAAM,mBAAmB,CAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,EAAE,CAChD,iBAAiB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAClC,CAAA;AACH,CAAC;AAED,KAAK,uBAAuB,CAAA"}
@@ -0,0 +1,61 @@
1
+ /** @jsxImportSource @opentui/solid */
2
+ /**
3
+ * Imperative command-dialog dispatcher for the /antigravity-* slash commands.
4
+ *
5
+ * Mirrors the fleet sibling layout (see `anthropic-auth-live` /
6
+ * `openai-auth-live` `packages/opencode/src/tui/command-dialogs.tsx`):
7
+ * each command's dialog opens with its data/status content rendered into the
8
+ * dialog BODY as a column of plain `<text>` nodes — non-selectable,
9
+ * non-searchable — and a separate `<DialogSelect>` below carries ONLY the
10
+ * real actions with proper `{title, description}` shapes the host renders
11
+ * on separate lines. The earlier implementation crammed the data rows into
12
+ * `DialogSelect`'s `placeholder` (which participates in type-ahead search)
13
+ * and concatenated label+description into a single highlighted option line;
14
+ * this rewrite separates data from actions the way the host expects.
15
+ *
16
+ * Contract:
17
+ * - Every main/subdialog calls `api.ui.dialog.setSize('xlarge')` before
18
+ * `api.ui.dialog.replace()` so the host reserves enough width for the
19
+ * longest line in any branch.
20
+ * - `apply(command, args, options?)` is the RPC apply path the dispatch
21
+ * site (the module-scoped poll in `tui.tsx`) supplies. The dispatcher
22
+ * forwards `options.timeoutMs` so a long-running apply (account add /
23
+ * refresh, future quota refresh) gets the right RPC timeout.
24
+ * - All `DialogSelect` options must remain VISIBLE — the host's
25
+ * `disabled: true` is a hard hide, so this file must never set it.
26
+ * Invalid actions stay visible with an explanatory description and are
27
+ * rejected in `onSelect`. The `no hide-property option scan` test in
28
+ * the verification gates pins this contract.
29
+ * - `onSelect` awaits the apply, toasts the result, then either clears
30
+ * the dialog or replaces it for multi-step flows. The dialog stack
31
+ * never sees a `clear()` between apply and re-render so the user
32
+ * always sees feedback (per the dispatcher contract).
33
+ */
34
+ import type { TuiPluginApi } from '@opencode-ai/plugin/tui';
35
+ import type { CommandModalName, OpenDialogPayload } from '../rpc/protocol';
36
+ /**
37
+ * Apply handler the dispatcher calls when the user selects a dialog
38
+ * option. Mirrors `ApplyRequest` from `rpc/protocol` plus the
39
+ * `RpcRequestOptions.timeoutMs` knob the RPC client already accepts —
40
+ * the call site in `tui.tsx` forwards these directly into
41
+ * `rpcClient.apply(request, options)`.
42
+ */
43
+ export type ApplyFn = (command: CommandModalName, args: string, options?: {
44
+ timeoutMs?: number;
45
+ }) => Promise<{
46
+ text: string;
47
+ knobs: Record<string, unknown>;
48
+ }>;
49
+ /**
50
+ * Mount the dialog for `payload.command` on the live TUI.
51
+ *
52
+ * The dispatcher branches on `payload.command` — each branch is
53
+ * self-contained: render the data body, render the host DialogSelect
54
+ * below it with the real actions, wire `onSelect` to await `apply(...)`,
55
+ * then toast the result and clear (or replace for multi-step flows).
56
+ * Unknown commands throw so a future command registered in
57
+ * `MODAL_COMMANDS` without a dispatcher branch fails loudly at the first
58
+ * dialog open.
59
+ */
60
+ export declare function openCommandDialog(api: TuiPluginApi, payload: OpenDialogPayload, apply: ApplyFn): void;
61
+ //# sourceMappingURL=command-dialogs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-dialogs.d.ts","sourceRoot":"","sources":["../../../src/tui/command-dialogs.tsx"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAE3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAE1E;;;;;;GAMG;AACH,MAAM,MAAM,OAAO,GAAG,CACpB,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,KAC7B,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,CAAC,CAAA;AAE9D;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,YAAY,EACjB,OAAO,EAAE,iBAAiB,EAC1B,KAAK,EAAE,OAAO,GACb,IAAI,CA0BN"}