@cortexkit/opencode-antigravity-auth 1.1.0 → 2.0.1

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 (379) hide show
  1. package/README.md +225 -569
  2. package/dist/cli.js +4017 -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 +20742 -14586
  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/account-command-oauth.d.ts +34 -0
  38. package/dist/src/plugin/account-command-oauth.d.ts.map +1 -0
  39. package/dist/src/plugin/account-command-oauth.js +156 -0
  40. package/dist/src/plugin/account-command-oauth.js.map +1 -0
  41. package/dist/src/plugin/accounts.d.ts +7 -256
  42. package/dist/src/plugin/accounts.d.ts.map +1 -1
  43. package/dist/src/plugin/accounts.js +31 -1367
  44. package/dist/src/plugin/accounts.js.map +1 -1
  45. package/dist/src/plugin/agy-request-metadata.d.ts +1 -1
  46. package/dist/src/plugin/agy-request-metadata.js +1 -1
  47. package/dist/src/plugin/agy-transport.d.ts +1 -1
  48. package/dist/src/plugin/agy-transport.js +1 -1
  49. package/dist/src/plugin/auth-doctor.d.ts +6 -6
  50. package/dist/src/plugin/auth-doctor.d.ts.map +1 -1
  51. package/dist/src/plugin/auth-doctor.js +74 -66
  52. package/dist/src/plugin/auth-doctor.js.map +1 -1
  53. package/dist/src/plugin/auth-drift.d.ts +4 -4
  54. package/dist/src/plugin/auth-drift.d.ts.map +1 -1
  55. package/dist/src/plugin/auth-drift.js +15 -15
  56. package/dist/src/plugin/auth-drift.js.map +1 -1
  57. package/dist/src/plugin/auth-loader.d.ts +50 -0
  58. package/dist/src/plugin/auth-loader.d.ts.map +1 -0
  59. package/dist/src/plugin/auth-loader.js +225 -0
  60. package/dist/src/plugin/auth-loader.js.map +1 -0
  61. package/dist/src/plugin/auth.d.ts +1 -1
  62. package/dist/src/plugin/auth.js +1 -1
  63. package/dist/src/plugin/background-quota-refresh.d.ts +146 -0
  64. package/dist/src/plugin/background-quota-refresh.d.ts.map +1 -0
  65. package/dist/src/plugin/background-quota-refresh.js +347 -0
  66. package/dist/src/plugin/background-quota-refresh.js.map +1 -0
  67. package/dist/src/plugin/cache/index.d.ts +1 -1
  68. package/dist/src/plugin/cache/index.d.ts.map +1 -1
  69. package/dist/src/plugin/cache/index.js +1 -1
  70. package/dist/src/plugin/cache/index.js.map +1 -1
  71. package/dist/src/plugin/cache/signature-cache.d.ts +1 -1
  72. package/dist/src/plugin/cache/signature-cache.d.ts.map +1 -1
  73. package/dist/src/plugin/cache/signature-cache.js +23 -24
  74. package/dist/src/plugin/cache/signature-cache.js.map +1 -1
  75. package/dist/src/plugin/cache.d.ts +6 -5
  76. package/dist/src/plugin/cache.d.ts.map +1 -1
  77. package/dist/src/plugin/cache.js +21 -7
  78. package/dist/src/plugin/cache.js.map +1 -1
  79. package/dist/src/plugin/catalog.d.ts +23 -0
  80. package/dist/src/plugin/catalog.d.ts.map +1 -0
  81. package/dist/src/plugin/catalog.js +60 -0
  82. package/dist/src/plugin/catalog.js.map +1 -0
  83. package/dist/src/plugin/cli.d.ts +7 -7
  84. package/dist/src/plugin/cli.d.ts.map +1 -1
  85. package/dist/src/plugin/cli.js +62 -55
  86. package/dist/src/plugin/cli.js.map +1 -1
  87. package/dist/src/plugin/command-data.d.ts +329 -0
  88. package/dist/src/plugin/command-data.d.ts.map +1 -0
  89. package/dist/src/plugin/command-data.js +517 -0
  90. package/dist/src/plugin/command-data.js.map +1 -0
  91. package/dist/src/plugin/commands.d.ts +154 -0
  92. package/dist/src/plugin/commands.d.ts.map +1 -0
  93. package/dist/src/plugin/commands.js +746 -0
  94. package/dist/src/plugin/commands.js.map +1 -0
  95. package/dist/src/plugin/config/index.d.ts +2 -2
  96. package/dist/src/plugin/config/index.d.ts.map +1 -1
  97. package/dist/src/plugin/config/index.js +2 -2
  98. package/dist/src/plugin/config/index.js.map +1 -1
  99. package/dist/src/plugin/config/loader.d.ts +1 -1
  100. package/dist/src/plugin/config/loader.d.ts.map +1 -1
  101. package/dist/src/plugin/config/loader.js +18 -16
  102. package/dist/src/plugin/config/loader.js.map +1 -1
  103. package/dist/src/plugin/config/models.d.ts +2 -2
  104. package/dist/src/plugin/config/models.d.ts.map +1 -1
  105. package/dist/src/plugin/config/models.js +1 -1
  106. package/dist/src/plugin/config/models.js.map +1 -1
  107. package/dist/src/plugin/config/operator-settings-schema.d.ts +29 -0
  108. package/dist/src/plugin/config/operator-settings-schema.d.ts.map +1 -0
  109. package/dist/src/plugin/config/operator-settings-schema.js +28 -0
  110. package/dist/src/plugin/config/operator-settings-schema.js.map +1 -0
  111. package/dist/src/plugin/config/schema.d.ts +23 -2
  112. package/dist/src/plugin/config/schema.d.ts.map +1 -1
  113. package/dist/src/plugin/config/schema.js +109 -25
  114. package/dist/src/plugin/config/schema.js.map +1 -1
  115. package/dist/src/plugin/config/updater.d.ts.map +1 -1
  116. package/dist/src/plugin/config/updater.js +15 -15
  117. package/dist/src/plugin/config/updater.js.map +1 -1
  118. package/dist/src/plugin/config/writer.d.ts +34 -0
  119. package/dist/src/plugin/config/writer.d.ts.map +1 -0
  120. package/dist/src/plugin/config/writer.js +81 -0
  121. package/dist/src/plugin/config/writer.js.map +1 -0
  122. package/dist/src/plugin/core/streaming/index.d.ts +1 -1
  123. package/dist/src/plugin/core/streaming/index.d.ts.map +1 -1
  124. package/dist/src/plugin/core/streaming/index.js +1 -1
  125. package/dist/src/plugin/core/streaming/index.js.map +1 -1
  126. package/dist/src/plugin/core/streaming/transformer.d.ts.map +1 -1
  127. package/dist/src/plugin/core/streaming/transformer.js +85 -44
  128. package/dist/src/plugin/core/streaming/transformer.js.map +1 -1
  129. package/dist/src/plugin/core/streaming/types.d.ts.map +1 -1
  130. package/dist/src/plugin/debug.d.ts +10 -3
  131. package/dist/src/plugin/debug.d.ts.map +1 -1
  132. package/dist/src/plugin/debug.js +110 -47
  133. package/dist/src/plugin/debug.js.map +1 -1
  134. package/dist/src/plugin/dependencies.d.ts +129 -0
  135. package/dist/src/plugin/dependencies.d.ts.map +1 -0
  136. package/dist/src/plugin/dependencies.js +107 -0
  137. package/dist/src/plugin/dependencies.js.map +1 -0
  138. package/dist/src/plugin/errors.d.ts +27 -0
  139. package/dist/src/plugin/errors.d.ts.map +1 -1
  140. package/dist/src/plugin/errors.js +29 -3
  141. package/dist/src/plugin/errors.js.map +1 -1
  142. package/dist/src/plugin/event-handler.d.ts +53 -0
  143. package/dist/src/plugin/event-handler.d.ts.map +1 -0
  144. package/dist/src/plugin/event-handler.js +101 -0
  145. package/dist/src/plugin/event-handler.js.map +1 -0
  146. package/dist/src/plugin/fetch/retry-state.d.ts +61 -0
  147. package/dist/src/plugin/fetch/retry-state.d.ts.map +1 -0
  148. package/dist/src/plugin/fetch/retry-state.js +248 -0
  149. package/dist/src/plugin/fetch/retry-state.js.map +1 -0
  150. package/dist/src/plugin/fetch/warmup.d.ts +30 -0
  151. package/dist/src/plugin/fetch/warmup.d.ts.map +1 -0
  152. package/dist/src/plugin/fetch/warmup.js +76 -0
  153. package/dist/src/plugin/fetch/warmup.js.map +1 -0
  154. package/dist/src/plugin/fetch-interceptor.d.ts +59 -0
  155. package/dist/src/plugin/fetch-interceptor.d.ts.map +1 -0
  156. package/dist/src/plugin/fetch-interceptor.js +1399 -0
  157. package/dist/src/plugin/fetch-interceptor.js.map +1 -0
  158. package/dist/src/plugin/fetch-routing.d.ts +26 -0
  159. package/dist/src/plugin/fetch-routing.d.ts.map +1 -0
  160. package/dist/src/plugin/fetch-routing.js +99 -0
  161. package/dist/src/plugin/fetch-routing.js.map +1 -0
  162. package/dist/src/plugin/fingerprint.d.ts +1 -1
  163. package/dist/src/plugin/fingerprint.js +1 -1
  164. package/dist/src/plugin/gemini-dump.d.ts +5 -5
  165. package/dist/src/plugin/gemini-dump.d.ts.map +1 -1
  166. package/dist/src/plugin/gemini-dump.js +109 -55
  167. package/dist/src/plugin/gemini-dump.js.map +1 -1
  168. package/dist/src/plugin/google-search-tool.d.ts +9 -0
  169. package/dist/src/plugin/google-search-tool.d.ts.map +1 -0
  170. package/dist/src/plugin/google-search-tool.js +56 -0
  171. package/dist/src/plugin/google-search-tool.js.map +1 -0
  172. package/dist/src/plugin/image-saver.d.ts.map +1 -1
  173. package/dist/src/plugin/image-saver.js +16 -16
  174. package/dist/src/plugin/image-saver.js.map +1 -1
  175. package/dist/src/plugin/index.d.ts +30 -0
  176. package/dist/src/plugin/index.d.ts.map +1 -0
  177. package/dist/src/plugin/index.js +411 -0
  178. package/dist/src/plugin/index.js.map +1 -0
  179. package/dist/src/plugin/killswitch.d.ts +94 -0
  180. package/dist/src/plugin/killswitch.d.ts.map +1 -0
  181. package/dist/src/plugin/killswitch.js +197 -0
  182. package/dist/src/plugin/killswitch.js.map +1 -0
  183. package/dist/src/plugin/lifecycle.d.ts +40 -0
  184. package/dist/src/plugin/lifecycle.d.ts.map +1 -0
  185. package/dist/src/plugin/lifecycle.js +73 -0
  186. package/dist/src/plugin/lifecycle.js.map +1 -0
  187. package/dist/src/plugin/logger.d.ts +10 -1
  188. package/dist/src/plugin/logger.d.ts.map +1 -1
  189. package/dist/src/plugin/logger.js +38 -12
  190. package/dist/src/plugin/logger.js.map +1 -1
  191. package/dist/src/plugin/logging-utils.d.ts +35 -1
  192. package/dist/src/plugin/logging-utils.d.ts.map +1 -1
  193. package/dist/src/plugin/logging-utils.js +98 -15
  194. package/dist/src/plugin/logging-utils.js.map +1 -1
  195. package/dist/src/plugin/model-registry.d.ts +1 -1
  196. package/dist/src/plugin/model-registry.js +1 -1
  197. package/dist/src/plugin/oauth-login.d.ts +22 -0
  198. package/dist/src/plugin/oauth-login.d.ts.map +1 -0
  199. package/dist/src/plugin/oauth-login.js +37 -0
  200. package/dist/src/plugin/oauth-login.js.map +1 -0
  201. package/dist/src/plugin/oauth-methods.d.ts +42 -0
  202. package/dist/src/plugin/oauth-methods.d.ts.map +1 -0
  203. package/dist/src/plugin/oauth-methods.js +1276 -0
  204. package/dist/src/plugin/oauth-methods.js.map +1 -0
  205. package/dist/src/plugin/operator-settings.d.ts +40 -0
  206. package/dist/src/plugin/operator-settings.d.ts.map +1 -0
  207. package/dist/src/plugin/operator-settings.js +148 -0
  208. package/dist/src/plugin/operator-settings.js.map +1 -0
  209. package/dist/src/plugin/persist-account-pool.d.ts +37 -0
  210. package/dist/src/plugin/persist-account-pool.d.ts.map +1 -0
  211. package/dist/src/plugin/persist-account-pool.js +142 -0
  212. package/dist/src/plugin/persist-account-pool.js.map +1 -0
  213. package/dist/src/plugin/project.d.ts +1 -1
  214. package/dist/src/plugin/project.js +1 -1
  215. package/dist/src/plugin/prompt-context.d.ts.map +1 -1
  216. package/dist/src/plugin/prompt-context.js +11 -11
  217. package/dist/src/plugin/prompt-context.js.map +1 -1
  218. package/dist/src/plugin/quota.d.ts +138 -41
  219. package/dist/src/plugin/quota.d.ts.map +1 -1
  220. package/dist/src/plugin/quota.js +417 -285
  221. package/dist/src/plugin/quota.js.map +1 -1
  222. package/dist/src/plugin/recovery/constants.d.ts.map +1 -1
  223. package/dist/src/plugin/recovery/constants.js +24 -15
  224. package/dist/src/plugin/recovery/constants.js.map +1 -1
  225. package/dist/src/plugin/recovery/index.d.ts +3 -3
  226. package/dist/src/plugin/recovery/index.d.ts.map +1 -1
  227. package/dist/src/plugin/recovery/index.js +3 -3
  228. package/dist/src/plugin/recovery/index.js.map +1 -1
  229. package/dist/src/plugin/recovery/storage.d.ts +1 -1
  230. package/dist/src/plugin/recovery/storage.d.ts.map +1 -1
  231. package/dist/src/plugin/recovery/storage.js +31 -39
  232. package/dist/src/plugin/recovery/storage.js.map +1 -1
  233. package/dist/src/plugin/recovery/types.d.ts +12 -12
  234. package/dist/src/plugin/recovery/types.d.ts.map +1 -1
  235. package/dist/src/plugin/recovery.d.ts +3 -3
  236. package/dist/src/plugin/recovery.d.ts.map +1 -1
  237. package/dist/src/plugin/recovery.js +62 -58
  238. package/dist/src/plugin/recovery.js.map +1 -1
  239. package/dist/src/plugin/refresh-queue.d.ts +5 -2
  240. package/dist/src/plugin/refresh-queue.d.ts.map +1 -1
  241. package/dist/src/plugin/refresh-queue.js +37 -15
  242. package/dist/src/plugin/refresh-queue.js.map +1 -1
  243. package/dist/src/plugin/request-helpers.d.ts +1 -1
  244. package/dist/src/plugin/request-helpers.d.ts.map +1 -1
  245. package/dist/src/plugin/request-helpers.js +451 -352
  246. package/dist/src/plugin/request-helpers.js.map +1 -1
  247. package/dist/src/plugin/request.d.ts +7 -7
  248. package/dist/src/plugin/request.d.ts.map +1 -1
  249. package/dist/src/plugin/request.js +622 -384
  250. package/dist/src/plugin/request.js.map +1 -1
  251. package/dist/src/plugin/rotation.d.ts +1 -168
  252. package/dist/src/plugin/rotation.d.ts.map +1 -1
  253. package/dist/src/plugin/rotation.js +1 -327
  254. package/dist/src/plugin/rotation.js.map +1 -1
  255. package/dist/src/plugin/search.d.ts.map +1 -1
  256. package/dist/src/plugin/search.js +39 -35
  257. package/dist/src/plugin/search.js.map +1 -1
  258. package/dist/src/plugin/server.d.ts +1 -1
  259. package/dist/src/plugin/server.d.ts.map +1 -1
  260. package/dist/src/plugin/server.js +42 -37
  261. package/dist/src/plugin/server.js.map +1 -1
  262. package/dist/src/plugin/session-context.d.ts +2 -1
  263. package/dist/src/plugin/session-context.d.ts.map +1 -1
  264. package/dist/src/plugin/session-context.js +11 -7
  265. package/dist/src/plugin/session-context.js.map +1 -1
  266. package/dist/src/plugin/storage.d.ts +59 -120
  267. package/dist/src/plugin/storage.d.ts.map +1 -1
  268. package/dist/src/plugin/storage.js +140 -485
  269. package/dist/src/plugin/storage.js.map +1 -1
  270. package/dist/src/plugin/stores/signature-store.d.ts.map +1 -1
  271. package/dist/src/plugin/stores/signature-store.js.map +1 -1
  272. package/dist/src/plugin/thinking-recovery.d.ts.map +1 -1
  273. package/dist/src/plugin/thinking-recovery.js +35 -33
  274. package/dist/src/plugin/thinking-recovery.js.map +1 -1
  275. package/dist/src/plugin/token.d.ts +2 -2
  276. package/dist/src/plugin/token.d.ts.map +1 -1
  277. package/dist/src/plugin/token.js +30 -21
  278. package/dist/src/plugin/token.js.map +1 -1
  279. package/dist/src/plugin/transform/cross-model-sanitizer.d.ts +1 -1
  280. package/dist/src/plugin/transform/cross-model-sanitizer.js +1 -1
  281. package/dist/src/plugin/transform/index.d.ts +1 -1
  282. package/dist/src/plugin/transform/index.js +1 -1
  283. package/dist/src/plugin/transform/model-resolver.d.ts +1 -1
  284. package/dist/src/plugin/transform/model-resolver.js +1 -1
  285. package/dist/src/plugin/transform/types.d.ts +1 -1
  286. package/dist/src/plugin/transform/types.js +1 -1
  287. package/dist/src/plugin/types.d.ts +25 -69
  288. package/dist/src/plugin/types.d.ts.map +1 -1
  289. package/dist/src/plugin/ui/ansi.d.ts.map +1 -1
  290. package/dist/src/plugin/ui/ansi.js.map +1 -1
  291. package/dist/src/plugin/ui/auth-menu.d.ts +1 -1
  292. package/dist/src/plugin/ui/auth-menu.d.ts.map +1 -1
  293. package/dist/src/plugin/ui/auth-menu.js +84 -35
  294. package/dist/src/plugin/ui/auth-menu.js.map +1 -1
  295. package/dist/src/plugin/ui/confirm.d.ts.map +1 -1
  296. package/dist/src/plugin/ui/confirm.js.map +1 -1
  297. package/dist/src/plugin/ui/model-status.d.ts +3 -3
  298. package/dist/src/plugin/ui/model-status.d.ts.map +1 -1
  299. package/dist/src/plugin/ui/model-status.js +3 -3
  300. package/dist/src/plugin/ui/model-status.js.map +1 -1
  301. package/dist/src/plugin/ui/quota-status.d.ts +4 -4
  302. package/dist/src/plugin/ui/quota-status.d.ts.map +1 -1
  303. package/dist/src/plugin/ui/quota-status.js +49 -49
  304. package/dist/src/plugin/ui/quota-status.js.map +1 -1
  305. package/dist/src/plugin/ui/select.d.ts.map +1 -1
  306. package/dist/src/plugin/ui/select.js +22 -12
  307. package/dist/src/plugin/ui/select.js.map +1 -1
  308. package/dist/src/plugin/version.d.ts +1 -1
  309. package/dist/src/plugin/version.js +1 -1
  310. package/dist/src/rpc/notifications.d.ts +6 -0
  311. package/dist/src/rpc/notifications.d.ts.map +1 -0
  312. package/dist/src/rpc/notifications.js +46 -0
  313. package/dist/src/rpc/notifications.js.map +1 -0
  314. package/dist/src/rpc/port-file.d.ts +13 -0
  315. package/dist/src/rpc/port-file.d.ts.map +1 -0
  316. package/dist/src/rpc/port-file.js +109 -0
  317. package/dist/src/rpc/port-file.js.map +1 -0
  318. package/dist/src/rpc/protocol.d.ts +22 -0
  319. package/dist/src/rpc/protocol.d.ts.map +1 -0
  320. package/dist/src/rpc/protocol.js +1 -0
  321. package/dist/src/rpc/protocol.js.map +1 -0
  322. package/dist/src/rpc/rpc-client.d.ts +10 -0
  323. package/dist/src/rpc/rpc-client.d.ts.map +1 -0
  324. package/dist/src/rpc/rpc-client.js +58 -0
  325. package/dist/src/rpc/rpc-client.js.map +1 -0
  326. package/dist/src/rpc/rpc-dir.d.ts +4 -0
  327. package/dist/src/rpc/rpc-dir.d.ts.map +1 -0
  328. package/dist/src/rpc/rpc-dir.js +19 -0
  329. package/dist/src/rpc/rpc-dir.js.map +1 -0
  330. package/dist/src/rpc/rpc-server.d.ts +13 -0
  331. package/dist/src/rpc/rpc-server.d.ts.map +1 -0
  332. package/dist/src/rpc/rpc-server.js +231 -0
  333. package/dist/src/rpc/rpc-server.js.map +1 -0
  334. package/dist/src/sidebar-state.d.ts +357 -0
  335. package/dist/src/sidebar-state.d.ts.map +1 -0
  336. package/dist/src/sidebar-state.js +680 -0
  337. package/dist/src/sidebar-state.js.map +1 -0
  338. package/dist/src/tui/command-dialogs.d.ts +61 -0
  339. package/dist/src/tui/command-dialogs.d.ts.map +1 -0
  340. package/dist/src/tui/command-dialogs.js +595 -0
  341. package/dist/src/tui/command-dialogs.js.map +1 -0
  342. package/dist/src/tui/file-logger.d.ts +41 -0
  343. package/dist/src/tui/file-logger.d.ts.map +1 -0
  344. package/dist/src/tui/file-logger.js +114 -0
  345. package/dist/src/tui/file-logger.js.map +1 -0
  346. package/dist/src/tui-preferences.d.ts +40 -0
  347. package/dist/src/tui-preferences.d.ts.map +1 -0
  348. package/dist/src/tui-preferences.js +328 -0
  349. package/dist/src/tui-preferences.js.map +1 -0
  350. package/dist/src/tui.d.ts +68 -0
  351. package/dist/src/tui.d.ts.map +1 -0
  352. package/dist/src/tui.js +697 -0
  353. package/dist/src/tui.js.map +1 -0
  354. package/package.json +46 -22
  355. package/src/plugin/command-data.ts +931 -0
  356. package/src/rpc/port-file.ts +143 -0
  357. package/src/rpc/protocol.ts +31 -0
  358. package/src/rpc/rpc-client.ts +102 -0
  359. package/src/rpc/rpc-dir.ts +24 -0
  360. package/src/sidebar-state.ts +991 -0
  361. package/src/tui/command-dialogs.tsx +832 -0
  362. package/src/tui/entry.mjs +74 -0
  363. package/src/tui/file-logger.ts +145 -0
  364. package/src/tui-compiled/plugin/command-data.ts +931 -0
  365. package/src/tui-compiled/rpc/port-file.ts +143 -0
  366. package/src/tui-compiled/rpc/protocol.ts +31 -0
  367. package/src/tui-compiled/rpc/rpc-client.ts +102 -0
  368. package/src/tui-compiled/rpc/rpc-dir.ts +24 -0
  369. package/src/tui-compiled/sidebar-state.ts +991 -0
  370. package/src/tui-compiled/tui/command-dialogs.tsx +779 -0
  371. package/src/tui-compiled/tui/file-logger.ts +145 -0
  372. package/src/tui-compiled/tui-preferences.ts +416 -0
  373. package/src/tui-compiled/tui.tsx +1193 -0
  374. package/src/tui-preferences.ts +416 -0
  375. package/src/tui.tsx +1171 -0
  376. package/dist/src/plugin.d.ts +0 -48
  377. package/dist/src/plugin.d.ts.map +0 -1
  378. package/dist/src/plugin.js +0 -3311
  379. package/dist/src/plugin.js.map +0 -1
@@ -0,0 +1,41 @@
1
+ /**
2
+ * File-backed logger for the OpenTUI sidebar tree.
3
+ *
4
+ * The TUI renders directly into the host terminal. Any stray write to the
5
+ * terminal from inside the render path (or any module it imports) corrupts
6
+ * the frame buffer — a single byte out of place shoves every subsequent
7
+ * cell right and breaks the sidebar.
8
+ *
9
+ * This logger writes to a rotating file under the host's log directory and
10
+ * never touches stdout/stderr. The plugin already wires up the same kind of
11
+ * file logger via `debug.ts`; the sidebar gets its own file so log lines
12
+ * from this tree are easy to attribute.
13
+ */
14
+ export type TuiLogLevel = 'debug' | 'info' | 'warn' | 'error';
15
+ export interface TuiLogger {
16
+ debug(message: string, extra?: Record<string, unknown>): void;
17
+ info(message: string, extra?: Record<string, unknown>): void;
18
+ warn(message: string, extra?: Record<string, unknown>): void;
19
+ error(message: string, extra?: Record<string, unknown>): void;
20
+ /** Resolve the path the logger writes to. `undefined` when file logging is disabled. */
21
+ getLogPath(): string | undefined;
22
+ }
23
+ interface FileLoggerOptions {
24
+ filePath: string;
25
+ maxBytes?: number;
26
+ }
27
+ /**
28
+ * Resolve the on-disk path for the TUI's log file.
29
+ *
30
+ * - `ANTIGRAVITY_AUTH_TUI_LOG_FILE` wins when set (used by tests so they
31
+ * never touch a real user log file).
32
+ * - Otherwise write under `<xdg-state>/cortexkit/antigravity-auth/tui.log`.
33
+ *
34
+ * Falls back to a temp file when the host path cannot be resolved (e.g. no
35
+ * home directory on a hostile CI box); the file logger itself never throws,
36
+ * it just drops the line.
37
+ */
38
+ export declare function resolveTuiLogPath(): string;
39
+ export declare function createTuiFileLogger(options?: Partial<FileLoggerOptions>): TuiLogger;
40
+ export {};
41
+ //# sourceMappingURL=file-logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-logger.d.ts","sourceRoot":"","sources":["../../../src/tui/file-logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAcH,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;AAE7D,MAAM,WAAW,SAAS;IACxB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;IAC7D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;IAC5D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;IAC5D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;IAC7D,wFAAwF;IACxF,UAAU,IAAI,MAAM,GAAG,SAAS,CAAA;CACjC;AAYD,UAAU,iBAAiB;IACzB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAK1C;AAED,wBAAgB,mBAAmB,CACjC,OAAO,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,GACnC,SAAS,CAIX"}
@@ -0,0 +1,114 @@
1
+ /**
2
+ * File-backed logger for the OpenTUI sidebar tree.
3
+ *
4
+ * The TUI renders directly into the host terminal. Any stray write to the
5
+ * terminal from inside the render path (or any module it imports) corrupts
6
+ * the frame buffer — a single byte out of place shoves every subsequent
7
+ * cell right and breaks the sidebar.
8
+ *
9
+ * This logger writes to a rotating file under the host's log directory and
10
+ * never touches stdout/stderr. The plugin already wires up the same kind of
11
+ * file logger via `debug.ts`; the sidebar gets its own file so log lines
12
+ * from this tree are easy to attribute.
13
+ */
14
+ import { appendFileSync, chmodSync, existsSync, mkdirSync, readFileSync, statSync, writeFileSync, } from 'node:fs';
15
+ import { homedir } from 'node:os';
16
+ import { dirname, join } from 'node:path';
17
+ const LOG_PREFIX = '[opencode-antigravity-auth/tui]';
18
+ const DEFAULT_MAX_BYTES = 1_000_000;
19
+ const MAX_KEEP_LINES = 200;
20
+ /**
21
+ * Owner-read/write only — matches the rest of the plugin's on-disk
22
+ * sensitive state (account storage, signature cache). Windows ignores
23
+ * POSIX mode bits so the assertion in the test is best-effort there.
24
+ */
25
+ const FILE_MODE = 0o600;
26
+ /**
27
+ * Resolve the on-disk path for the TUI's log file.
28
+ *
29
+ * - `ANTIGRAVITY_AUTH_TUI_LOG_FILE` wins when set (used by tests so they
30
+ * never touch a real user log file).
31
+ * - Otherwise write under `<xdg-state>/cortexkit/antigravity-auth/tui.log`.
32
+ *
33
+ * Falls back to a temp file when the host path cannot be resolved (e.g. no
34
+ * home directory on a hostile CI box); the file logger itself never throws,
35
+ * it just drops the line.
36
+ */
37
+ export function resolveTuiLogPath() {
38
+ const override = process.env.ANTIGRAVITY_AUTH_TUI_LOG_FILE;
39
+ if (override && override.trim().length > 0)
40
+ return override;
41
+ const base = process.env.XDG_STATE_HOME || join(homedir(), '.local', 'state');
42
+ return join(base, 'cortexkit', 'antigravity-auth', 'tui.log');
43
+ }
44
+ export function createTuiFileLogger(options) {
45
+ const filePath = options?.filePath ?? resolveTuiLogPath();
46
+ const maxBytes = options?.maxBytes ?? DEFAULT_MAX_BYTES;
47
+ return createFileLogger({ filePath, maxBytes });
48
+ }
49
+ function createFileLogger(options) {
50
+ const { filePath, maxBytes = DEFAULT_MAX_BYTES } = options;
51
+ const rotateIfNeeded = () => {
52
+ try {
53
+ if (!existsSync(filePath))
54
+ return;
55
+ const stat = statSync(filePath);
56
+ if (stat.size < maxBytes)
57
+ return;
58
+ // Tail-truncate: keep the last MAX_KEEP_LINES, drop the rest. Cheap,
59
+ // bounded, and good enough for a sidecar debug stream.
60
+ const text = readFileSync(filePath, 'utf-8');
61
+ const lines = text.split('\n');
62
+ const keepFrom = Math.max(0, lines.length - MAX_KEEP_LINES);
63
+ const tail = lines.slice(keepFrom).join('\n');
64
+ writeFileSync(filePath, tail, 'utf-8');
65
+ // `writeFileSync` over an existing file keeps its mode; we rotate
66
+ // the file specifically to enforce owner-only access, so re-assert
67
+ // the mode after the truncation.
68
+ chmodSync(filePath, FILE_MODE);
69
+ }
70
+ catch {
71
+ // Best-effort; ignore rotation errors.
72
+ }
73
+ };
74
+ const write = (level, message, extra) => {
75
+ try {
76
+ rotateIfNeeded();
77
+ // Enforce 0o700 on the parent directory even when it already
78
+ // exists — `mkdirSync({ recursive: true, mode })` only sets the
79
+ // mode on the leaf directory it creates, so an existing leaky
80
+ // directory would keep its old mode. The post-hoc chmodSync
81
+ // closes the gap.
82
+ mkdirSync(dirname(filePath), { recursive: true, mode: 0o700 });
83
+ chmodSync(dirname(filePath), 0o700);
84
+ const payload = {
85
+ ts: Date.now(),
86
+ level,
87
+ message,
88
+ };
89
+ if (extra && Object.keys(extra).length > 0)
90
+ payload.extra = extra;
91
+ // `mode: 0o600` so the log file is owner-only — the same default the
92
+ // plugin's account storage applies. `appendFileSync` only honours the
93
+ // mode flag when the file is created, so existing files keep whatever
94
+ // mode they had. `chmodSync` below re-asserts the mode after every
95
+ // append so a leaked-permissions file is repaired on the next write.
96
+ appendFileSync(filePath, `${LOG_PREFIX} ${JSON.stringify(payload)}\n`, {
97
+ encoding: 'utf-8',
98
+ mode: FILE_MODE,
99
+ });
100
+ chmodSync(filePath, FILE_MODE);
101
+ }
102
+ catch {
103
+ // Drop the line — file logging must never throw into the render path.
104
+ }
105
+ };
106
+ return {
107
+ debug: (message, extra) => write('debug', message, extra),
108
+ info: (message, extra) => write('info', message, extra),
109
+ warn: (message, extra) => write('warn', message, extra),
110
+ error: (message, extra) => write('error', message, extra),
111
+ getLogPath: () => filePath,
112
+ };
113
+ }
114
+ //# sourceMappingURL=file-logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-logger.js","sourceRoot":"","sources":["../../../src/tui/file-logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,cAAc,EACd,SAAS,EACT,UAAU,EACV,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,aAAa,GACd,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAazC,MAAM,UAAU,GAAG,iCAAiC,CAAA;AACpD,MAAM,iBAAiB,GAAG,SAAS,CAAA;AACnC,MAAM,cAAc,GAAG,GAAG,CAAA;A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AAO;gBACjB,IAAI,EAAE,SAAS;aAChB,CAAC,CAAA;YACF,SAAS,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAA;QAChC,CAAC;QAAC,MAAM,CAAC;YACP,sEAAsE;QACxE,CAAC;IACH,CAAC,CAAA;IAED,OAAO;QACL,KAAK,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC;QACzD,IAAI,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC;QACvD,IAAI,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC;QACvD,KAAK,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC;QACzD,UAAU,EAAE,GAAG,EAAE,CAAC,QAAQ;KAC3B,CAAA;AACH,CAAC"}
@@ -0,0 +1,40 @@
1
+ export declare const TUI_PREFS_FILE_ENV = "OPENCODE_TUI_PREFERENCES_FILE";
2
+ export declare function getTuiPreferencesFile(): string;
3
+ export declare function readTuiPreferencesFile(): Promise<Record<string, unknown>>;
4
+ export declare const PLUGIN_KEY = "antigravity-auth";
5
+ export declare const DEFAULT_SLOT_ORDER = 160;
6
+ export interface AntigravityAuthTuiPrefs {
7
+ forceToTop: boolean;
8
+ order: number;
9
+ startCollapsed: boolean;
10
+ rememberCollapsed: boolean;
11
+ collapsed: boolean | null;
12
+ pollMs: number;
13
+ refreshDebounceMs: number;
14
+ header: {
15
+ label: string;
16
+ showVersion: boolean;
17
+ };
18
+ sections: {
19
+ quota: boolean;
20
+ fallbackAccounts: boolean;
21
+ routing: boolean;
22
+ health: boolean;
23
+ };
24
+ appearance: {
25
+ barWidth: number;
26
+ barFilledChar: string;
27
+ barEmptyChar: string;
28
+ warnThreshold: number;
29
+ errorThreshold: number;
30
+ };
31
+ }
32
+ export type AppearancePrefs = AntigravityAuthTuiPrefs['appearance'];
33
+ export declare const DEFAULT_PREFS: AntigravityAuthTuiPrefs;
34
+ export declare function resolveAntigravityAuthPrefs(root: Record<string, unknown>): AntigravityAuthTuiPrefs;
35
+ export declare function computeEffectiveOrder(root: Record<string, unknown>, pluginKey: string, defaultOrder: number): number;
36
+ type JsonValue = string | number | boolean | null;
37
+ export declare function queueTuiPreferenceUpdate(pluginKey: string, path: string[], value: JsonValue): Promise<void>;
38
+ export declare function watchTuiPreferences(onChange: () => void): () => void;
39
+ export {};
40
+ //# sourceMappingURL=tui-preferences.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tui-preferences.d.ts","sourceRoot":"","sources":["../../src/tui-preferences.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,kBAAkB,kCAAkC,CAAA;AAUjE,wBAAgB,qBAAqB,IAAI,MAAM,CAO9C;AAWD,wBAAsB,sBAAsB,IAAI,OAAO,CACrD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CACxB,CAUA;AAED,eAAO,MAAM,UAAU,qBAAqB,CAAA;AAC5C,eAAO,MAAM,kBAAkB,MAAM,CAAA;AAErC,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,OAAO,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,cAAc,EAAE,OAAO,CAAA;IACvB,iBAAiB,EAAE,OAAO,CAAA;IAE1B,SAAS,EAAE,OAAO,GAAG,IAAI,CAAA;IACzB,MAAM,EAAE,MAAM,CAAA;IACd,iBAAiB,EAAE,MAAM,CAAA;IACzB,MAAM,EAAE;QACN,KAAK,EAAE,MAAM,CAAA;QACb,WAAW,EAAE,OAAO,CAAA;KACrB,CAAA;IACD,QAAQ,EAAE;QACR,KAAK,EAAE,OAAO,CAAA;QACd,gBAAgB,EAAE,OAAO,CAAA;QACzB,OAAO,EAAE,OAAO,CAAA;QAChB,MAAM,EAAE,OAAO,CAAA;KAChB,CAAA;IACD,UAAU,EAAE;QACV,QAAQ,EAAE,MAAM,CAAA;QAChB,aAAa,EAAE,MAAM,CAAA;QACrB,YAAY,EAAE,MAAM,CAAA;QACpB,aAAa,EAAE,MAAM,CAAA;QACrB,cAAc,EAAE,MAAM,CAAA;KACvB,CAAA;CACF;AAED,MAAM,MAAM,eAAe,GAAG,uBAAuB,CAAC,YAAY,CAAC,CAAA;AAEnE,eAAO,MAAM,aAAa,EAAE,uBAsB3B,CAAA;AAkCD,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,uBAAuB,CAqEzB;AAiBD,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,GACnB,MAAM,CAOR;AASD,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAA;AAyDjD,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EAAE,EACd,KAAK,EAAE,SAAS,GACf,OAAO,CAAC,IAAI,CAAC,CAKf;AAuBD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CA2EpE"}
@@ -0,0 +1,328 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { watch } from 'node:fs';
3
+ import { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
4
+ import { homedir } from 'node:os';
5
+ import { basename, dirname, join } from 'node:path';
6
+ import { clearTimeout as nativeClearTimeout, setTimeout as nativeSetTimeout, } from 'node:timers';
7
+ import { acquireFencedFileLock } from '@cortexkit/antigravity-auth-core/file-lock';
8
+ import { applyEdits, modify, parse } from 'jsonc-parser';
9
+ export const TUI_PREFS_FILE_ENV = 'OPENCODE_TUI_PREFERENCES_FILE';
10
+ const FILE_NAME = 'tui-preferences.jsonc';
11
+ const PREFERENCES_LOCK_NAME = 'preferences';
12
+ const PREFERENCES_LOCK_TTL_MS = 10_000;
13
+ const PREFERENCES_LOCK_TIMEOUT_MS = 2_000;
14
+ const PREFERENCES_LOCK_RETRY_MS = 25;
15
+ // Shared preferences file for opencode TUI plugins. One top-level key per
16
+ // plugin (short name, e.g. "antigravity-auth"). The file is optional: every
17
+ // reader must fall back to defaults when it is missing or malformed.
18
+ export function getTuiPreferencesFile() {
19
+ const override = process.env[TUI_PREFS_FILE_ENV];
20
+ if (override)
21
+ return override;
22
+ const configDir = process.env.OPENCODE_CONFIG_DIR ||
23
+ join(process.env.XDG_CONFIG_HOME || join(homedir(), '.config'), 'opencode');
24
+ return join(configDir, FILE_NAME);
25
+ }
26
+ function isRecord(value) {
27
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
28
+ }
29
+ // Tolerant read: missing file, parse errors, or a non-object root all resolve
30
+ // to {} so the sidebar never crashes on user-edited content. jsonc-parser's
31
+ // fault-tolerant parse can still hand back a partial object for an
32
+ // unterminated/bracketed file or trailing garbage, so we collect errors and
33
+ // treat any reported fault as malformed.
34
+ export async function readTuiPreferencesFile() {
35
+ try {
36
+ const raw = await readFile(getTuiPreferencesFile(), 'utf8');
37
+ const errors = [];
38
+ const root = parse(raw, errors, { allowTrailingComma: true });
39
+ if (errors.length > 0)
40
+ return {};
41
+ return isRecord(root) ? root : {};
42
+ }
43
+ catch {
44
+ return {};
45
+ }
46
+ }
47
+ export const PLUGIN_KEY = 'antigravity-auth';
48
+ export const DEFAULT_SLOT_ORDER = 160;
49
+ export const DEFAULT_PREFS = {
50
+ forceToTop: false,
51
+ order: DEFAULT_SLOT_ORDER,
52
+ startCollapsed: false,
53
+ rememberCollapsed: true,
54
+ collapsed: null,
55
+ pollMs: 1500,
56
+ refreshDebounceMs: 200,
57
+ header: { label: 'ANTIGRAVITY', showVersion: true },
58
+ sections: {
59
+ quota: true,
60
+ fallbackAccounts: true,
61
+ routing: true,
62
+ health: true,
63
+ },
64
+ appearance: {
65
+ barWidth: 10,
66
+ barFilledChar: '█',
67
+ barEmptyChar: '░',
68
+ warnThreshold: 50,
69
+ errorThreshold: 80,
70
+ },
71
+ };
72
+ function bool(value, fallback) {
73
+ return typeof value === 'boolean' ? value : fallback;
74
+ }
75
+ function int(value, fallback, min, max) {
76
+ if (typeof value !== 'number' || !Number.isFinite(value))
77
+ return fallback;
78
+ return Math.min(Math.max(Math.round(value), min), max);
79
+ }
80
+ function label(value, fallback, maxLength) {
81
+ if (typeof value !== 'string' || value.length === 0)
82
+ return fallback;
83
+ return value.slice(0, maxLength);
84
+ }
85
+ function char(value, fallback) {
86
+ if (typeof value !== 'string')
87
+ return fallback;
88
+ const first = [...value][0];
89
+ return first ?? fallback;
90
+ }
91
+ // Per-key validation: every value is independently clamped/defaulted so one
92
+ // bad entry never poisons the rest. Never throws.
93
+ //
94
+ // Antigravity reads the thresholds as remaining-percent: healthy when the
95
+ // remaining is above `warnThreshold`, warn between `errorThreshold` and
96
+ // `warnThreshold`, error below `errorThreshold`. So `errorThreshold` is the
97
+ // smaller number (the danger floor) and must stay strictly below `warnThreshold`.
98
+ export function resolveAntigravityAuthPrefs(root) {
99
+ const entry = root[PLUGIN_KEY];
100
+ if (!isRecord(entry))
101
+ return structuredClone(DEFAULT_PREFS);
102
+ const d = DEFAULT_PREFS;
103
+ const header = isRecord(entry.header) ? entry.header : {};
104
+ const sections = isRecord(entry.sections) ? entry.sections : {};
105
+ const appearance = isRecord(entry.appearance) ? entry.appearance : {};
106
+ const configuredWarnThreshold = int(appearance.warnThreshold, d.appearance.warnThreshold, 0, 99);
107
+ const configuredErrorThreshold = int(appearance.errorThreshold, d.appearance.errorThreshold, 0, 100);
108
+ // Older preferences stored remaining-percent thresholds, whose error value
109
+ // was lower than warn. Convert that shape while accepting the fleet's new
110
+ // used-percent ordering without a preferences schema migration.
111
+ const [warnThreshold, errorThreshold] = configuredErrorThreshold < configuredWarnThreshold
112
+ ? [100 - configuredWarnThreshold, 100 - configuredErrorThreshold]
113
+ : [
114
+ configuredWarnThreshold,
115
+ Math.max(configuredErrorThreshold, Math.min(configuredWarnThreshold + 1, 100)),
116
+ ];
117
+ return {
118
+ forceToTop: bool(entry.forceToTop, d.forceToTop),
119
+ order: int(entry.order, d.order, -10000, 10000),
120
+ startCollapsed: bool(entry.startCollapsed, d.startCollapsed),
121
+ rememberCollapsed: bool(entry.rememberCollapsed, d.rememberCollapsed),
122
+ collapsed: typeof entry.collapsed === 'boolean' ? entry.collapsed : null,
123
+ pollMs: int(entry.pollMs, d.pollMs, 500, 30000),
124
+ refreshDebounceMs: int(entry.refreshDebounceMs, d.refreshDebounceMs, 50, 5000),
125
+ header: {
126
+ label: label(header.label, d.header.label, 20),
127
+ showVersion: bool(header.showVersion, d.header.showVersion),
128
+ },
129
+ sections: {
130
+ quota: bool(sections.quota, d.sections.quota),
131
+ fallbackAccounts: bool(sections.fallbackAccounts, d.sections.fallbackAccounts),
132
+ routing: bool(sections.routing, d.sections.routing),
133
+ health: bool(sections.health, d.sections.health),
134
+ },
135
+ appearance: {
136
+ barWidth: int(appearance.barWidth, d.appearance.barWidth, 4, 40),
137
+ barFilledChar: char(appearance.barFilledChar, d.appearance.barFilledChar),
138
+ barEmptyChar: char(appearance.barEmptyChar, d.appearance.barEmptyChar),
139
+ warnThreshold,
140
+ errorThreshold,
141
+ },
142
+ };
143
+ }
144
+ const FORCE_TOP_BASE = -100000;
145
+ // Shared forceToTop convention: forced plugins sort below FORCE_TOP_BASE,
146
+ // ordered among themselves by their top-level key's position in the file, so
147
+ // users reprioritize by reordering keys. The user-facing `order` knob clamps
148
+ // to -10000..10000, strictly above the forced band, so a manual order can
149
+ // never beat forceToTop. Host slots render ascending by order; opencode's
150
+ // built-ins occupy 100-500.
151
+ //
152
+ // Key-naming requirement: plugin keys must be non-integer-like short names
153
+ // (e.g. "antigravity-auth"). JavaScript object key iteration order hoists
154
+ // integer-like keys ("0", "1", "42") ahead of any string keys, which would
155
+ // skew the indexOf-based ordering of forced plugins. The shared
156
+ // `tui-preferences.jsonc` convention requires non-numeric names, so this
157
+ // implementation does not paper over the JS quirk.
158
+ export function computeEffectiveOrder(root, pluginKey, defaultOrder) {
159
+ const entry = root[pluginKey];
160
+ if (!isRecord(entry))
161
+ return defaultOrder;
162
+ if (entry.forceToTop === true) {
163
+ return FORCE_TOP_BASE + Object.keys(root).indexOf(pluginKey);
164
+ }
165
+ return int(entry.order, defaultOrder, -10000, 10000);
166
+ }
167
+ const TEMPLATE = `// Shared preferences for opencode TUI plugins.
168
+ // One top-level key per plugin (short name). See each plugin's README for
169
+ // its supported settings. This file is safe to hand-edit; plugins update
170
+ // individual keys in place and preserve comments.
171
+ {}
172
+ `;
173
+ async function acquirePreferencesLock(file) {
174
+ const deadline = Date.now() + PREFERENCES_LOCK_TIMEOUT_MS;
175
+ for (;;) {
176
+ const lock = await acquireFencedFileLock({
177
+ path: file,
178
+ name: PREFERENCES_LOCK_NAME,
179
+ ttlMs: PREFERENCES_LOCK_TTL_MS,
180
+ renew: true,
181
+ });
182
+ if (lock)
183
+ return lock;
184
+ if (Date.now() >= deadline) {
185
+ throw new Error(`Timed out acquiring TUI preferences lock: ${file}`);
186
+ }
187
+ await new Promise((resolve) => nativeSetTimeout(resolve, PREFERENCES_LOCK_RETRY_MS));
188
+ }
189
+ }
190
+ async function writePreference(pluginKey, path, value) {
191
+ const file = getTuiPreferencesFile();
192
+ await mkdir(dirname(file), { recursive: true });
193
+ const lock = await acquirePreferencesLock(file);
194
+ const tmp = `${file}.${process.pid}.${randomUUID()}.tmp`;
195
+ try {
196
+ let text;
197
+ try {
198
+ text = await readFile(file, 'utf8');
199
+ }
200
+ catch {
201
+ text = '';
202
+ }
203
+ if (text.trim() === '')
204
+ text = TEMPLATE;
205
+ const edits = modify(text, [pluginKey, ...path], value, {
206
+ formattingOptions: { insertSpaces: true, tabSize: 2 },
207
+ });
208
+ const next = applyEdits(text, edits);
209
+ await writeFile(tmp, next, { encoding: 'utf8', mode: 0o600 });
210
+ await lock.assertOwned();
211
+ await rename(tmp, file);
212
+ }
213
+ finally {
214
+ await rm(tmp, { force: true }).catch(() => { });
215
+ await lock.release();
216
+ }
217
+ }
218
+ let writeChain = Promise.resolve();
219
+ // Writes are serialized on a promise chain: each update re-reads the file,
220
+ // applies a minimal comment-preserving edit to one property, and replaces the
221
+ // file atomically (temp + rename in the same directory). Best-effort by
222
+ // design — preferences are never worth crashing the TUI over.
223
+ export function queueTuiPreferenceUpdate(pluginKey, path, value) {
224
+ writeChain = writeChain
225
+ .then(() => writePreference(pluginKey, path, value))
226
+ .catch(() => { });
227
+ return writeChain;
228
+ }
229
+ const WATCH_DEBOUNCE_MS = 150;
230
+ const WATCH_POLL_MS = 100;
231
+ // Watches the directory rather than the file: editors and our own atomic
232
+ // writes replace the file via rename, which kills file-level watchers.
233
+ //
234
+ // Filtering is two-stage:
235
+ // 1. Filename pre-filter: only debounce events for the preferences file
236
+ // name, or our atomic-write temp file. This is a cheap first pass that
237
+ // drops the common case (unrelated sibling files).
238
+ // 2. Content check inside the debounce: after the timer fires, re-read
239
+ // the file and compare it against the last seen content. Only fire
240
+ // `onChange` when the content actually changed. This is the authority.
241
+ // Some platforms (notably macOS FSEvents and a few inotify backends)
242
+ // can misattribute a rename of an unrelated sibling file to the
243
+ // real preferences filename in addition to emitting the sibling's
244
+ // own event, so a name-only filter still produces a stray callback.
245
+ // A content comparison is robust against that, against coalesced
246
+ // events, and against mtime granularity.
247
+ //
248
+ // Returns a disposer; never throws.
249
+ export function watchTuiPreferences(onChange) {
250
+ const file = getTuiPreferencesFile();
251
+ const name = basename(file);
252
+ let timer = null;
253
+ let lastSeen = null;
254
+ let observedEvent = false;
255
+ let disposed = false;
256
+ const checkForChange = async () => {
257
+ const text = await readFile(file, 'utf8').catch(() => null);
258
+ if (disposed || text === null)
259
+ return;
260
+ if (text === lastSeen)
261
+ return;
262
+ lastSeen = text;
263
+ onChange();
264
+ };
265
+ const scheduleCheck = () => {
266
+ observedEvent = true;
267
+ if (timer)
268
+ nativeClearTimeout(timer);
269
+ timer = nativeSetTimeout(() => {
270
+ timer = null;
271
+ void checkForChange();
272
+ }, WATCH_DEBOUNCE_MS);
273
+ };
274
+ // Seed asynchronously. If a real file event arrives before the read resolves,
275
+ // do not let the seed overwrite that pending change; the debounced re-read
276
+ // will compare against the previous value and fire.
277
+ void readFile(file, 'utf8')
278
+ .then((text) => {
279
+ if (!observedEvent && lastSeen === null)
280
+ lastSeen = text;
281
+ })
282
+ .catch(() => { });
283
+ try {
284
+ const watcher = watch(dirname(file), (_event, filename) => {
285
+ // Exact match against the preferences file name, plus the temp file
286
+ // we use for atomic writes (carrying our pid + `.tmp`).
287
+ const isOurs = filename === name ||
288
+ (filename?.startsWith(`${name}.`) && filename.endsWith('.tmp'));
289
+ if (filename != null && !isOurs)
290
+ return;
291
+ scheduleCheck();
292
+ });
293
+ // Bun's fs.watch can miss atomic temp-file rename updates on some
294
+ // backends, so keep a low-cost polling loop as the correctness path.
295
+ // Use recursive timers instead of fs.watchFile because watchFile can keep
296
+ // Bun test processes alive long after unwatchFile().
297
+ let pollTimer = null;
298
+ let pollInFlight = false;
299
+ const schedulePoll = () => {
300
+ if (disposed || pollTimer)
301
+ return;
302
+ pollTimer = nativeSetTimeout(() => {
303
+ pollTimer = null;
304
+ if (disposed || pollInFlight)
305
+ return;
306
+ pollInFlight = true;
307
+ void checkForChange().finally(() => {
308
+ pollInFlight = false;
309
+ schedulePoll();
310
+ });
311
+ }, WATCH_POLL_MS);
312
+ pollTimer.unref?.();
313
+ };
314
+ schedulePoll();
315
+ return () => {
316
+ disposed = true;
317
+ if (timer)
318
+ nativeClearTimeout(timer);
319
+ if (pollTimer)
320
+ nativeClearTimeout(pollTimer);
321
+ watcher.close();
322
+ };
323
+ }
324
+ catch {
325
+ return () => { };
326
+ }
327
+ }
328
+ //# sourceMappingURL=tui-preferences.js.map
@@ -0,0 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;gBAAE,kBAAkB,CAAC,KAAK,CAAC,CAAA;YACpC,IAAI,SAAS;gBAAE,kBAAkB,CAAC,SAAS,CAAC,CAAA;YAC5C,OAAO,CAAC,KAAK,EAAE,CAAA;QACjB,CAAC,CAAA;IACH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,GAAG,EAAE,GAAE,CAAC,CAAA;IACjB,CAAC;AACH,CAAC"}
@@ -0,0 +1,68 @@
1
+ /** @jsxImportSource @opentui/solid */
2
+ import type { TuiPluginApi, TuiPluginModule, TuiThemeCurrent } from '@opencode-ai/plugin/tui';
3
+ import { createSlot } from '@opentui/solid';
4
+ import { type JSX } from 'solid-js';
5
+ import type { RpcNotification } from './rpc/protocol';
6
+ import { type SidebarStateV1 } from './sidebar-state';
7
+ import { type TuiLogger } from './tui/file-logger';
8
+ import { type AntigravityAuthTuiPrefs } from './tui-preferences';
9
+ type Theme = TuiThemeCurrent;
10
+ export interface SidebarPanelProps {
11
+ /** Override the file the TUI polls. Defaults to `getSidebarStateFile()`. */
12
+ stateFile?: string;
13
+ /** Override the polling interval. Defaults to 2000ms. */
14
+ pollIntervalMs?: number;
15
+ /** Override the logger; tests inject a logger that captures into memory. */
16
+ logger?: TuiLogger;
17
+ /** Optional override for the current epoch in milliseconds (tests). */
18
+ now?: () => number;
19
+ /** Optional prefs controller — when present, drives collapse/expand and
20
+ * section toggles. Module-scoped controller is created at plugin init. */
21
+ controller?: SidebarController;
22
+ /** Optional live-theme accessor. The host's `api.theme.current` is wired
23
+ * through here in production; tests pass a custom accessor to flip theme
24
+ * and assert re-render. Falls back to FALLBACK_THEME when unset. */
25
+ theme?: () => Theme;
26
+ /** The slot session determines which route is relevant to this sidebar. */
27
+ sessionId?: string;
28
+ }
29
+ export interface SidebarController {
30
+ prefs: () => AntigravityAuthTuiPrefs;
31
+ collapsed: () => boolean;
32
+ toggleCollapsed: () => void;
33
+ }
34
+ export declare function createSidebarController(initialPrefs: AntigravityAuthTuiPrefs): SidebarController;
35
+ export declare function resolveQuotaDialogActiveId(state: SidebarStateV1, sessionId: string | undefined): string | undefined;
36
+ export declare function QuotaDialogContent(props: {
37
+ api: TuiPluginApi;
38
+ controller: SidebarController;
39
+ sessionId: string | undefined;
40
+ }): JSX.Element;
41
+ export declare function SidebarPanel(props: SidebarPanelProps): JSX.Element;
42
+ /**
43
+ * Solid slot registry binding exposed for hosts that want to mount the
44
+ * sidebar inside their renderer. Hosts that already own a slot registry can
45
+ * use `createSlot` directly; we re-export for convenience and to keep the
46
+ * contract visible at the module entry point.
47
+ */
48
+ export declare const sidebar_content: typeof createSlot;
49
+ interface RpcNotificationPollOptions {
50
+ pending: (lastReceivedId: number, sessionId?: string) => Promise<RpcNotification[]>;
51
+ currentSessionId: () => string | undefined;
52
+ dispatch: (notification: RpcNotification) => void | Promise<void>;
53
+ schedule: (poll: () => Promise<void>, intervalMs: number) => void;
54
+ /**
55
+ * File logger used to surface poll errors. Must be a file logger — the
56
+ * host terminal is the frame buffer, so writes to stdout/stderr would
57
+ * corrupt the sidebar render. The plugin production path uses
58
+ * `resolveLogger(undefined)` to fall through to the on-disk file
59
+ * logger.
60
+ */
61
+ logger: TuiLogger;
62
+ }
63
+ export declare function startRpcNotificationPolling(options: RpcNotificationPollOptions): void;
64
+ declare const plugin: TuiPluginModule & {
65
+ id: string;
66
+ };
67
+ export default plugin;
68
+ //# sourceMappingURL=tui.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tui.d.ts","sourceRoot":"","sources":["../../src/tui.tsx"],"names":[],"mappings":"AAAA,sCAAsC;AAwCtC,OAAO,KAAK,EAEV,YAAY,EACZ,eAAe,EACf,eAAe,EAChB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAIL,KAAK,GAAG,EAIT,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAGrD,OAAO,EAKL,KAAK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