@percygfx/opencode-antigravity-auth 0.0.0-stage → 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 (312) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +896 -3
  3. package/dist/index.d.ts +4 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +3 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/rpc.d.ts +176 -0
  8. package/dist/rpc.d.ts.map +1 -0
  9. package/dist/rpc.js +91 -0
  10. package/dist/rpc.js.map +1 -0
  11. package/dist/server.d.ts +3 -0
  12. package/dist/server.d.ts.map +1 -0
  13. package/dist/server.js +5 -0
  14. package/dist/server.js.map +1 -0
  15. package/dist/src/antigravity/oauth.d.ts +31 -0
  16. package/dist/src/antigravity/oauth.d.ts.map +1 -0
  17. package/dist/src/antigravity/oauth.js +171 -0
  18. package/dist/src/antigravity/oauth.js.map +1 -0
  19. package/dist/src/constants.d.ts +153 -0
  20. package/dist/src/constants.d.ts.map +1 -0
  21. package/dist/src/constants.js +238 -0
  22. package/dist/src/constants.js.map +1 -0
  23. package/dist/src/core/gateway.d.ts +43 -0
  24. package/dist/src/core/gateway.d.ts.map +1 -0
  25. package/dist/src/core/gateway.js +241 -0
  26. package/dist/src/core/gateway.js.map +1 -0
  27. package/dist/src/core/index.d.ts +8 -0
  28. package/dist/src/core/index.d.ts.map +1 -0
  29. package/dist/src/core/index.js +8 -0
  30. package/dist/src/core/index.js.map +1 -0
  31. package/dist/src/core/types.d.ts +60 -0
  32. package/dist/src/core/types.d.ts.map +1 -0
  33. package/dist/src/core/types.js +5 -0
  34. package/dist/src/core/types.js.map +1 -0
  35. package/dist/src/hooks/auto-update-checker/cache.d.ts +3 -0
  36. package/dist/src/hooks/auto-update-checker/cache.d.ts.map +1 -0
  37. package/dist/src/hooks/auto-update-checker/cache.js +71 -0
  38. package/dist/src/hooks/auto-update-checker/cache.js.map +1 -0
  39. package/dist/src/hooks/auto-update-checker/checker.d.ts +16 -0
  40. package/dist/src/hooks/auto-update-checker/checker.d.ts.map +1 -0
  41. package/dist/src/hooks/auto-update-checker/checker.js +234 -0
  42. package/dist/src/hooks/auto-update-checker/checker.js.map +1 -0
  43. package/dist/src/hooks/auto-update-checker/constants.d.ts +11 -0
  44. package/dist/src/hooks/auto-update-checker/constants.d.ts.map +1 -0
  45. package/dist/src/hooks/auto-update-checker/constants.js +26 -0
  46. package/dist/src/hooks/auto-update-checker/constants.js.map +1 -0
  47. package/dist/src/hooks/auto-update-checker/index.d.ts +34 -0
  48. package/dist/src/hooks/auto-update-checker/index.d.ts.map +1 -0
  49. package/dist/src/hooks/auto-update-checker/index.js +122 -0
  50. package/dist/src/hooks/auto-update-checker/index.js.map +1 -0
  51. package/dist/src/hooks/auto-update-checker/logging.d.ts +3 -0
  52. package/dist/src/hooks/auto-update-checker/logging.d.ts.map +1 -0
  53. package/dist/src/hooks/auto-update-checker/logging.js +9 -0
  54. package/dist/src/hooks/auto-update-checker/logging.js.map +1 -0
  55. package/dist/src/hooks/auto-update-checker/types.d.ts +25 -0
  56. package/dist/src/hooks/auto-update-checker/types.d.ts.map +1 -0
  57. package/dist/src/hooks/auto-update-checker/types.js +1 -0
  58. package/dist/src/hooks/auto-update-checker/types.js.map +1 -0
  59. package/dist/src/opencode-v2/accounts.d.ts +24 -0
  60. package/dist/src/opencode-v2/accounts.d.ts.map +1 -0
  61. package/dist/src/opencode-v2/accounts.js +109 -0
  62. package/dist/src/opencode-v2/accounts.js.map +1 -0
  63. package/dist/src/opencode-v2/catalog.d.ts +31 -0
  64. package/dist/src/opencode-v2/catalog.d.ts.map +1 -0
  65. package/dist/src/opencode-v2/catalog.js +68 -0
  66. package/dist/src/opencode-v2/catalog.js.map +1 -0
  67. package/dist/src/opencode-v2/client-shim.d.ts +9 -0
  68. package/dist/src/opencode-v2/client-shim.d.ts.map +1 -0
  69. package/dist/src/opencode-v2/client-shim.js +42 -0
  70. package/dist/src/opencode-v2/client-shim.js.map +1 -0
  71. package/dist/src/opencode-v2/clipboard.d.ts +7 -0
  72. package/dist/src/opencode-v2/clipboard.d.ts.map +1 -0
  73. package/dist/src/opencode-v2/clipboard.js +54 -0
  74. package/dist/src/opencode-v2/clipboard.js.map +1 -0
  75. package/dist/src/opencode-v2/index.d.ts +5 -0
  76. package/dist/src/opencode-v2/index.d.ts.map +1 -0
  77. package/dist/src/opencode-v2/index.js +4 -0
  78. package/dist/src/opencode-v2/index.js.map +1 -0
  79. package/dist/src/opencode-v2/plugin.d.ts +23 -0
  80. package/dist/src/opencode-v2/plugin.d.ts.map +1 -0
  81. package/dist/src/opencode-v2/plugin.js +466 -0
  82. package/dist/src/opencode-v2/plugin.js.map +1 -0
  83. package/dist/src/opencode-v2/proxy.d.ts +23 -0
  84. package/dist/src/opencode-v2/proxy.d.ts.map +1 -0
  85. package/dist/src/opencode-v2/proxy.js +148 -0
  86. package/dist/src/opencode-v2/proxy.js.map +1 -0
  87. package/dist/src/opencode-v2/quota-format.d.ts +19 -0
  88. package/dist/src/opencode-v2/quota-format.d.ts.map +1 -0
  89. package/dist/src/opencode-v2/quota-format.js +71 -0
  90. package/dist/src/opencode-v2/quota-format.js.map +1 -0
  91. package/dist/src/opencode-v2/quota.d.ts +18 -0
  92. package/dist/src/opencode-v2/quota.d.ts.map +1 -0
  93. package/dist/src/opencode-v2/quota.js +118 -0
  94. package/dist/src/opencode-v2/quota.js.map +1 -0
  95. package/dist/src/opencode-v2/sign-in-attempts.d.ts +52 -0
  96. package/dist/src/opencode-v2/sign-in-attempts.d.ts.map +1 -0
  97. package/dist/src/opencode-v2/sign-in-attempts.js +81 -0
  98. package/dist/src/opencode-v2/sign-in-attempts.js.map +1 -0
  99. package/dist/src/plugin/account-models.d.ts +38 -0
  100. package/dist/src/plugin/account-models.d.ts.map +1 -0
  101. package/dist/src/plugin/account-models.js +78 -0
  102. package/dist/src/plugin/account-models.js.map +1 -0
  103. package/dist/src/plugin/accounts.d.ts +186 -0
  104. package/dist/src/plugin/accounts.d.ts.map +1 -0
  105. package/dist/src/plugin/accounts.js +1045 -0
  106. package/dist/src/plugin/accounts.js.map +1 -0
  107. package/dist/src/plugin/auth.d.ts +21 -0
  108. package/dist/src/plugin/auth.d.ts.map +1 -0
  109. package/dist/src/plugin/auth.js +46 -0
  110. package/dist/src/plugin/auth.js.map +1 -0
  111. package/dist/src/plugin/cache/index.d.ts +5 -0
  112. package/dist/src/plugin/cache/index.d.ts.map +1 -0
  113. package/dist/src/plugin/cache/index.js +5 -0
  114. package/dist/src/plugin/cache/index.js.map +1 -0
  115. package/dist/src/plugin/cache/signature-cache.d.ts +111 -0
  116. package/dist/src/plugin/cache/signature-cache.d.ts.map +1 -0
  117. package/dist/src/plugin/cache/signature-cache.js +375 -0
  118. package/dist/src/plugin/cache/signature-cache.js.map +1 -0
  119. package/dist/src/plugin/cache.d.ts +44 -0
  120. package/dist/src/plugin/cache.d.ts.map +1 -0
  121. package/dist/src/plugin/cache.js +200 -0
  122. package/dist/src/plugin/cache.js.map +1 -0
  123. package/dist/src/plugin/cli.d.ts +26 -0
  124. package/dist/src/plugin/cli.d.ts.map +1 -0
  125. package/dist/src/plugin/cli.js +119 -0
  126. package/dist/src/plugin/cli.js.map +1 -0
  127. package/dist/src/plugin/config/index.d.ts +16 -0
  128. package/dist/src/plugin/config/index.d.ts.map +1 -0
  129. package/dist/src/plugin/config/index.js +16 -0
  130. package/dist/src/plugin/config/index.js.map +1 -0
  131. package/dist/src/plugin/config/loader.d.ts +36 -0
  132. package/dist/src/plugin/config/loader.d.ts.map +1 -0
  133. package/dist/src/plugin/config/loader.js +140 -0
  134. package/dist/src/plugin/config/loader.js.map +1 -0
  135. package/dist/src/plugin/config/models.d.ts +41 -0
  136. package/dist/src/plugin/config/models.d.ts.map +1 -0
  137. package/dist/src/plugin/config/models.js +46 -0
  138. package/dist/src/plugin/config/models.js.map +1 -0
  139. package/dist/src/plugin/config/schema.d.ts +135 -0
  140. package/dist/src/plugin/config/schema.d.ts.map +1 -0
  141. package/dist/src/plugin/config/schema.js +438 -0
  142. package/dist/src/plugin/config/schema.js.map +1 -0
  143. package/dist/src/plugin/config/updater.d.ts +55 -0
  144. package/dist/src/plugin/config/updater.d.ts.map +1 -0
  145. package/dist/src/plugin/config/updater.js +125 -0
  146. package/dist/src/plugin/config/updater.js.map +1 -0
  147. package/dist/src/plugin/core/streaming/index.d.ts +3 -0
  148. package/dist/src/plugin/core/streaming/index.d.ts.map +1 -0
  149. package/dist/src/plugin/core/streaming/index.js +3 -0
  150. package/dist/src/plugin/core/streaming/index.js.map +1 -0
  151. package/dist/src/plugin/core/streaming/transformer.d.ts +10 -0
  152. package/dist/src/plugin/core/streaming/transformer.d.ts.map +1 -0
  153. package/dist/src/plugin/core/streaming/transformer.js +271 -0
  154. package/dist/src/plugin/core/streaming/transformer.js.map +1 -0
  155. package/dist/src/plugin/core/streaming/types.d.ts +27 -0
  156. package/dist/src/plugin/core/streaming/types.d.ts.map +1 -0
  157. package/dist/src/plugin/core/streaming/types.js +1 -0
  158. package/dist/src/plugin/core/streaming/types.js.map +1 -0
  159. package/dist/src/plugin/debug.d.ts +94 -0
  160. package/dist/src/plugin/debug.d.ts.map +1 -0
  161. package/dist/src/plugin/debug.js +382 -0
  162. package/dist/src/plugin/debug.js.map +1 -0
  163. package/dist/src/plugin/errors.d.ts +28 -0
  164. package/dist/src/plugin/errors.d.ts.map +1 -0
  165. package/dist/src/plugin/errors.js +42 -0
  166. package/dist/src/plugin/errors.js.map +1 -0
  167. package/dist/src/plugin/fingerprint.d.ts +70 -0
  168. package/dist/src/plugin/fingerprint.d.ts.map +1 -0
  169. package/dist/src/plugin/fingerprint.js +138 -0
  170. package/dist/src/plugin/fingerprint.js.map +1 -0
  171. package/dist/src/plugin/image-saver.d.ts +25 -0
  172. package/dist/src/plugin/image-saver.d.ts.map +1 -0
  173. package/dist/src/plugin/image-saver.js +86 -0
  174. package/dist/src/plugin/image-saver.js.map +1 -0
  175. package/dist/src/plugin/logger.d.ts +36 -0
  176. package/dist/src/plugin/logger.d.ts.map +1 -0
  177. package/dist/src/plugin/logger.js +71 -0
  178. package/dist/src/plugin/logger.js.map +1 -0
  179. package/dist/src/plugin/logging-utils.d.ts +23 -0
  180. package/dist/src/plugin/logging-utils.d.ts.map +1 -0
  181. package/dist/src/plugin/logging-utils.js +92 -0
  182. package/dist/src/plugin/logging-utils.js.map +1 -0
  183. package/dist/src/plugin/model-discovery.d.ts +28 -0
  184. package/dist/src/plugin/model-discovery.d.ts.map +1 -0
  185. package/dist/src/plugin/model-discovery.js +59 -0
  186. package/dist/src/plugin/model-discovery.js.map +1 -0
  187. package/dist/src/plugin/model-registry.d.ts +108 -0
  188. package/dist/src/plugin/model-registry.d.ts.map +1 -0
  189. package/dist/src/plugin/model-registry.js +304 -0
  190. package/dist/src/plugin/model-registry.js.map +1 -0
  191. package/dist/src/plugin/project.d.ts +33 -0
  192. package/dist/src/plugin/project.d.ts.map +1 -0
  193. package/dist/src/plugin/project.js +235 -0
  194. package/dist/src/plugin/project.js.map +1 -0
  195. package/dist/src/plugin/quota.d.ts +58 -0
  196. package/dist/src/plugin/quota.d.ts.map +1 -0
  197. package/dist/src/plugin/quota.js +296 -0
  198. package/dist/src/plugin/quota.js.map +1 -0
  199. package/dist/src/plugin/recovery/constants.d.ts +22 -0
  200. package/dist/src/plugin/recovery/constants.d.ts.map +1 -0
  201. package/dist/src/plugin/recovery/constants.js +43 -0
  202. package/dist/src/plugin/recovery/constants.js.map +1 -0
  203. package/dist/src/plugin/recovery/index.d.ts +12 -0
  204. package/dist/src/plugin/recovery/index.d.ts.map +1 -0
  205. package/dist/src/plugin/recovery/index.js +12 -0
  206. package/dist/src/plugin/recovery/index.js.map +1 -0
  207. package/dist/src/plugin/recovery/storage.d.ts +24 -0
  208. package/dist/src/plugin/recovery/storage.d.ts.map +1 -0
  209. package/dist/src/plugin/recovery/storage.js +354 -0
  210. package/dist/src/plugin/recovery/storage.js.map +1 -0
  211. package/dist/src/plugin/recovery/types.d.ts +116 -0
  212. package/dist/src/plugin/recovery/types.d.ts.map +1 -0
  213. package/dist/src/plugin/recovery/types.js +6 -0
  214. package/dist/src/plugin/recovery/types.js.map +1 -0
  215. package/dist/src/plugin/recovery.d.ts +61 -0
  216. package/dist/src/plugin/recovery.d.ts.map +1 -0
  217. package/dist/src/plugin/recovery.js +381 -0
  218. package/dist/src/plugin/recovery.js.map +1 -0
  219. package/dist/src/plugin/refresh-queue.d.ts +100 -0
  220. package/dist/src/plugin/refresh-queue.d.ts.map +1 -0
  221. package/dist/src/plugin/refresh-queue.js +247 -0
  222. package/dist/src/plugin/refresh-queue.js.map +1 -0
  223. package/dist/src/plugin/request-helpers.d.ts +282 -0
  224. package/dist/src/plugin/request-helpers.d.ts.map +1 -0
  225. package/dist/src/plugin/request-helpers.js +2343 -0
  226. package/dist/src/plugin/request-helpers.js.map +1 -0
  227. package/dist/src/plugin/request.d.ts +95 -0
  228. package/dist/src/plugin/request.d.ts.map +1 -0
  229. package/dist/src/plugin/request.js +1491 -0
  230. package/dist/src/plugin/request.js.map +1 -0
  231. package/dist/src/plugin/rotation.d.ts +169 -0
  232. package/dist/src/plugin/rotation.d.ts.map +1 -0
  233. package/dist/src/plugin/rotation.js +328 -0
  234. package/dist/src/plugin/rotation.js.map +1 -0
  235. package/dist/src/plugin/search.d.ts +32 -0
  236. package/dist/src/plugin/search.d.ts.map +1 -0
  237. package/dist/src/plugin/search.js +195 -0
  238. package/dist/src/plugin/search.js.map +1 -0
  239. package/dist/src/plugin/server.d.ts +23 -0
  240. package/dist/src/plugin/server.d.ts.map +1 -0
  241. package/dist/src/plugin/server.js +324 -0
  242. package/dist/src/plugin/server.js.map +1 -0
  243. package/dist/src/plugin/storage.d.ts +173 -0
  244. package/dist/src/plugin/storage.d.ts.map +1 -0
  245. package/dist/src/plugin/storage.js +674 -0
  246. package/dist/src/plugin/storage.js.map +1 -0
  247. package/dist/src/plugin/stores/signature-store.d.ts +5 -0
  248. package/dist/src/plugin/stores/signature-store.d.ts.map +1 -0
  249. package/dist/src/plugin/stores/signature-store.js +25 -0
  250. package/dist/src/plugin/stores/signature-store.js.map +1 -0
  251. package/dist/src/plugin/thinking-recovery.d.ts +90 -0
  252. package/dist/src/plugin/thinking-recovery.d.ts.map +1 -0
  253. package/dist/src/plugin/thinking-recovery.js +316 -0
  254. package/dist/src/plugin/thinking-recovery.js.map +1 -0
  255. package/dist/src/plugin/token.d.ts +19 -0
  256. package/dist/src/plugin/token.d.ts.map +1 -0
  257. package/dist/src/plugin/token.js +128 -0
  258. package/dist/src/plugin/token.js.map +1 -0
  259. package/dist/src/plugin/transform/claude.d.ts +80 -0
  260. package/dist/src/plugin/transform/claude.d.ts.map +1 -0
  261. package/dist/src/plugin/transform/claude.js +265 -0
  262. package/dist/src/plugin/transform/claude.js.map +1 -0
  263. package/dist/src/plugin/transform/cross-model-sanitizer.d.ts +35 -0
  264. package/dist/src/plugin/transform/cross-model-sanitizer.d.ts.map +1 -0
  265. package/dist/src/plugin/transform/cross-model-sanitizer.js +225 -0
  266. package/dist/src/plugin/transform/cross-model-sanitizer.js.map +1 -0
  267. package/dist/src/plugin/transform/gemini.d.ts +100 -0
  268. package/dist/src/plugin/transform/gemini.d.ts.map +1 -0
  269. package/dist/src/plugin/transform/gemini.js +446 -0
  270. package/dist/src/plugin/transform/gemini.js.map +1 -0
  271. package/dist/src/plugin/transform/index.d.ts +15 -0
  272. package/dist/src/plugin/transform/index.d.ts.map +1 -0
  273. package/dist/src/plugin/transform/index.js +14 -0
  274. package/dist/src/plugin/transform/index.js.map +1 -0
  275. package/dist/src/plugin/transform/model-resolver.d.ts +99 -0
  276. package/dist/src/plugin/transform/model-resolver.d.ts.map +1 -0
  277. package/dist/src/plugin/transform/model-resolver.js +340 -0
  278. package/dist/src/plugin/transform/model-resolver.js.map +1 -0
  279. package/dist/src/plugin/transform/types.d.ts +111 -0
  280. package/dist/src/plugin/transform/types.d.ts.map +1 -0
  281. package/dist/src/plugin/transform/types.js +1 -0
  282. package/dist/src/plugin/transform/types.js.map +1 -0
  283. package/dist/src/plugin/types.d.ts +97 -0
  284. package/dist/src/plugin/types.d.ts.map +1 -0
  285. package/dist/src/plugin/types.js +1 -0
  286. package/dist/src/plugin/types.js.map +1 -0
  287. package/dist/src/plugin/ui/ansi.d.ts +32 -0
  288. package/dist/src/plugin/ui/ansi.d.ts.map +1 -0
  289. package/dist/src/plugin/ui/ansi.js +52 -0
  290. package/dist/src/plugin/ui/ansi.js.map +1 -0
  291. package/dist/src/plugin/ui/auth-menu.d.ts +33 -0
  292. package/dist/src/plugin/ui/auth-menu.d.ts.map +1 -0
  293. package/dist/src/plugin/ui/auth-menu.js +110 -0
  294. package/dist/src/plugin/ui/auth-menu.js.map +1 -0
  295. package/dist/src/plugin/ui/confirm.d.ts +2 -0
  296. package/dist/src/plugin/ui/confirm.d.ts.map +1 -0
  297. package/dist/src/plugin/ui/confirm.js +15 -0
  298. package/dist/src/plugin/ui/confirm.js.map +1 -0
  299. package/dist/src/plugin/ui/select.d.ts +23 -0
  300. package/dist/src/plugin/ui/select.d.ts.map +1 -0
  301. package/dist/src/plugin/ui/select.js +254 -0
  302. package/dist/src/plugin/ui/select.js.map +1 -0
  303. package/dist/src/plugin/version.d.ts +19 -0
  304. package/dist/src/plugin/version.d.ts.map +1 -0
  305. package/dist/src/plugin/version.js +80 -0
  306. package/dist/src/plugin/version.js.map +1 -0
  307. package/dist/src/plugin.d.ts +51 -0
  308. package/dist/src/plugin.d.ts.map +1 -0
  309. package/dist/src/plugin.js +2852 -0
  310. package/dist/src/plugin.js.map +1 -0
  311. package/dist/tui.js +420 -0
  312. package/package.json +99 -6
@@ -0,0 +1,674 @@
1
+ import { promises as fs } from "node:fs";
2
+ import { existsSync, readFileSync, writeFileSync, appendFileSync, mkdirSync, renameSync, copyFileSync, unlinkSync, } from "node:fs";
3
+ import { dirname, join } from "node:path";
4
+ import { homedir } from "node:os";
5
+ import { createHash, randomBytes } from "node:crypto";
6
+ import lockfile from "proper-lockfile";
7
+ import { createLogger } from "./logger";
8
+ const log = createLogger("storage");
9
+ /**
10
+ * Files/directories that should be gitignored in the config directory.
11
+ * These contain sensitive data or machine-specific state.
12
+ */
13
+ export const GITIGNORE_ENTRIES = [
14
+ ".gitignore",
15
+ "antigravity-accounts.json",
16
+ "antigravity-accounts.json.*.tmp",
17
+ "antigravity-signature-cache.json",
18
+ "antigravity-logs/",
19
+ ];
20
+ /**
21
+ * Ensures a .gitignore file exists in the config directory with entries
22
+ * for sensitive files. Creates the file if missing, or appends missing
23
+ * entries if it already exists.
24
+ */
25
+ export async function ensureGitignore(configDir) {
26
+ const gitignorePath = join(configDir, ".gitignore");
27
+ try {
28
+ let content;
29
+ let existingLines = [];
30
+ try {
31
+ content = await fs.readFile(gitignorePath, "utf-8");
32
+ existingLines = content.split("\n").map((line) => line.trim());
33
+ }
34
+ catch (error) {
35
+ if (error.code !== "ENOENT") {
36
+ return;
37
+ }
38
+ content = "";
39
+ }
40
+ const missingEntries = GITIGNORE_ENTRIES.filter((entry) => !existingLines.includes(entry));
41
+ if (missingEntries.length === 0) {
42
+ return;
43
+ }
44
+ if (content === "") {
45
+ await fs.writeFile(gitignorePath, missingEntries.join("\n") + "\n", "utf-8");
46
+ log.info("Created .gitignore in config directory");
47
+ }
48
+ else {
49
+ const suffix = content.endsWith("\n") ? "" : "\n";
50
+ await fs.appendFile(gitignorePath, suffix + missingEntries.join("\n") + "\n", "utf-8");
51
+ log.info("Updated .gitignore with missing entries", {
52
+ added: missingEntries,
53
+ });
54
+ }
55
+ }
56
+ catch {
57
+ // Non-critical feature
58
+ }
59
+ }
60
+ /**
61
+ * Synchronous version of ensureGitignore for use in sync code paths.
62
+ */
63
+ export function ensureGitignoreSync(configDir) {
64
+ const gitignorePath = join(configDir, ".gitignore");
65
+ try {
66
+ let content;
67
+ let existingLines = [];
68
+ if (existsSync(gitignorePath)) {
69
+ content = readFileSync(gitignorePath, "utf-8");
70
+ existingLines = content.split("\n").map((line) => line.trim());
71
+ }
72
+ else {
73
+ content = "";
74
+ }
75
+ const missingEntries = GITIGNORE_ENTRIES.filter((entry) => !existingLines.includes(entry));
76
+ if (missingEntries.length === 0) {
77
+ return;
78
+ }
79
+ if (content === "") {
80
+ writeFileSync(gitignorePath, missingEntries.join("\n") + "\n", "utf-8");
81
+ log.info("Created .gitignore in config directory");
82
+ }
83
+ else {
84
+ const suffix = content.endsWith("\n") ? "" : "\n";
85
+ appendFileSync(gitignorePath, suffix + missingEntries.join("\n") + "\n", "utf-8");
86
+ log.info("Updated .gitignore with missing entries", {
87
+ added: missingEntries,
88
+ });
89
+ }
90
+ }
91
+ catch {
92
+ // Non-critical feature
93
+ }
94
+ }
95
+ /**
96
+ * Gets the legacy Windows config directory (%APPDATA%\opencode).
97
+ * Used for migration from older plugin versions.
98
+ */
99
+ function getLegacyWindowsConfigDir() {
100
+ return join(process.env.APPDATA || join(homedir(), "AppData", "Roaming"), "opencode");
101
+ }
102
+ /**
103
+ * Gets the config directory path, with the following precedence:
104
+ * 1. OPENCODE_CONFIG_DIR env var (if set)
105
+ * 2. ~/.config/opencode (all platforms, including Windows)
106
+ *
107
+ * On Windows, also checks for legacy %APPDATA%\opencode path for migration.
108
+ */
109
+ function getConfigDir() {
110
+ // 1. Check for explicit override via env var
111
+ if (process.env.OPENCODE_CONFIG_DIR) {
112
+ return process.env.OPENCODE_CONFIG_DIR;
113
+ }
114
+ // 2. Use ~/.config/opencode on all platforms (including Windows)
115
+ const xdgConfig = process.env.XDG_CONFIG_HOME || join(homedir(), ".config");
116
+ return join(xdgConfig, "opencode");
117
+ }
118
+ /**
119
+ * Migrates config from legacy Windows location to the new path.
120
+ * Moves the file if legacy exists and new doesn't.
121
+ * Returns true if migration was performed.
122
+ */
123
+ function migrateLegacyWindowsConfig() {
124
+ if (process.platform !== "win32") {
125
+ return false;
126
+ }
127
+ const newPath = join(getConfigDir(), "antigravity-accounts.json");
128
+ const legacyPath = join(getLegacyWindowsConfigDir(), "antigravity-accounts.json");
129
+ // Only migrate if legacy exists and new doesn't
130
+ if (!existsSync(legacyPath) || existsSync(newPath)) {
131
+ return false;
132
+ }
133
+ try {
134
+ // Ensure new config directory exists
135
+ const newConfigDir = getConfigDir();
136
+ mkdirSync(newConfigDir, { recursive: true });
137
+ // Try rename first (atomic, but fails across filesystems)
138
+ try {
139
+ renameSync(legacyPath, newPath);
140
+ log.info("Migrated Windows config via rename", { from: legacyPath, to: newPath });
141
+ }
142
+ catch {
143
+ // Fallback: copy then delete (for cross-filesystem moves)
144
+ copyFileSync(legacyPath, newPath);
145
+ unlinkSync(legacyPath);
146
+ log.info("Migrated Windows config via copy+delete", { from: legacyPath, to: newPath });
147
+ }
148
+ return true;
149
+ }
150
+ catch (error) {
151
+ log.warn("Failed to migrate legacy Windows config, will use legacy path", {
152
+ legacyPath,
153
+ newPath,
154
+ error: String(error),
155
+ });
156
+ return false;
157
+ }
158
+ }
159
+ /**
160
+ * Gets the storage path, migrating from legacy Windows location if needed.
161
+ * On Windows, attempts to move legacy config to new path for alignment.
162
+ */
163
+ function getStoragePathWithMigration() {
164
+ const newPath = join(getConfigDir(), "antigravity-accounts.json");
165
+ // On Windows, attempt to migrate legacy config to new location
166
+ if (process.platform === "win32") {
167
+ migrateLegacyWindowsConfig();
168
+ // If migration failed and legacy still exists, fall back to it
169
+ if (!existsSync(newPath)) {
170
+ const legacyPath = join(getLegacyWindowsConfigDir(), "antigravity-accounts.json");
171
+ if (existsSync(legacyPath)) {
172
+ log.info("Using legacy Windows config path (migration failed)", {
173
+ legacyPath,
174
+ newPath,
175
+ });
176
+ return legacyPath;
177
+ }
178
+ }
179
+ }
180
+ return newPath;
181
+ }
182
+ export function getStoragePath() {
183
+ return getStoragePathWithMigration();
184
+ }
185
+ /**
186
+ * Gets the config directory path. Exported for use by other modules.
187
+ */
188
+ export { getConfigDir };
189
+ const LOCK_OPTIONS = {
190
+ stale: 10000,
191
+ retries: {
192
+ retries: 5,
193
+ minTimeout: 100,
194
+ maxTimeout: 1000,
195
+ factor: 2,
196
+ },
197
+ };
198
+ /**
199
+ * Ensures the file has secure permissions (0600) on POSIX systems.
200
+ * This is a best-effort operation and ignores errors on Windows/unsupported FS.
201
+ */
202
+ async function ensureSecurePermissions(path) {
203
+ try {
204
+ await fs.chmod(path, 0o600);
205
+ }
206
+ catch {
207
+ // Ignore errors (e.g. Windows, file doesn't exist, FS doesn't support chmod)
208
+ }
209
+ }
210
+ async function ensureFileExists(path) {
211
+ try {
212
+ await fs.access(path);
213
+ }
214
+ catch {
215
+ await fs.mkdir(dirname(path), { recursive: true });
216
+ await fs.writeFile(path, JSON.stringify({ version: 4, accounts: [], activeIndex: 0 }, null, 2), { encoding: "utf-8", mode: 0o600 });
217
+ }
218
+ }
219
+ async function withFileLock(path, fn) {
220
+ await ensureFileExists(path);
221
+ let release = null;
222
+ try {
223
+ release = await lockfile.lock(path, LOCK_OPTIONS);
224
+ return await fn();
225
+ }
226
+ finally {
227
+ if (release) {
228
+ try {
229
+ await release();
230
+ }
231
+ catch (unlockError) {
232
+ log.warn("Failed to release lock", { error: String(unlockError) });
233
+ }
234
+ }
235
+ }
236
+ }
237
+ /** Fingerprint of a refresh token, so retired tokens can be recognized without storing them. */
238
+ export function hashRefreshToken(refreshToken) {
239
+ return createHash("sha256").update(refreshToken).digest("hex").slice(0, 32);
240
+ }
241
+ const MAX_RETIRED_TOKEN_HASHES = 200;
242
+ function mergeRetired(...lists) {
243
+ const merged = [...new Set(lists.flatMap((list) => list ?? []))];
244
+ return merged.slice(-MAX_RETIRED_TOKEN_HASHES);
245
+ }
246
+ function withoutRetired(accounts, retired) {
247
+ if (retired.length === 0)
248
+ return accounts;
249
+ const set = new Set(retired);
250
+ return accounts.filter((account) => !set.has(hashRefreshToken(account.refreshToken)));
251
+ }
252
+ function mergeAccountStorage(existing, incoming, unretiredHashes = []) {
253
+ const unretired = new Set(unretiredHashes);
254
+ const retired = mergeRetired(existing.retiredTokenHashes, incoming.retiredTokenHashes).filter((hash) => !unretired.has(hash));
255
+ const retiredSet = new Set(retired);
256
+ const isRetired = (acc) => retiredSet.has(hashRefreshToken(acc.refreshToken));
257
+ // Merge in place, so positions (activeIndex, activeIndexByFamily) keep pointing at the same accounts.
258
+ const merged = [...existing.accounts];
259
+ const indexByToken = new Map(merged.map((acc, index) => [acc.refreshToken, index]));
260
+ const indexByEmail = new Map(merged.flatMap((acc, index) => (acc.email ? [[acc.email, index]] : [])));
261
+ for (const acc of incoming.accounts) {
262
+ if (!acc.refreshToken || isRetired(acc))
263
+ continue;
264
+ let index = indexByToken.get(acc.refreshToken);
265
+ if (index === undefined && acc.email) {
266
+ // The same Google account under another token (re-authentication): take over its slot when
267
+ // the stored token is retired or older; otherwise the email dedupe below keeps the newer one.
268
+ const sameEmail = indexByEmail.get(acc.email);
269
+ const stored = sameEmail === undefined ? undefined : merged[sameEmail];
270
+ if (stored && (isRetired(stored) || (acc.lastUsed || 0) >= (stored.lastUsed || 0)))
271
+ index = sameEmail;
272
+ }
273
+ if (index === undefined) {
274
+ indexByToken.set(acc.refreshToken, merged.length);
275
+ if (acc.email)
276
+ indexByEmail.set(acc.email, merged.length);
277
+ merged.push(acc);
278
+ continue;
279
+ }
280
+ const existingAcc = merged[index];
281
+ // An account manager loaded before the last discovery must not drop or roll back its list.
282
+ const newerModels = (acc.availableModelsUpdatedAt ?? 0) >= (existingAcc.availableModelsUpdatedAt ?? 0) && acc.availableModels
283
+ ? acc
284
+ : existingAcc;
285
+ merged[index] = {
286
+ ...existingAcc,
287
+ ...acc,
288
+ // Preserve manually configured projectId/managedProjectId if not in incoming
289
+ projectId: acc.projectId ?? existingAcc.projectId,
290
+ managedProjectId: acc.managedProjectId ?? existingAcc.managedProjectId,
291
+ rateLimitResetTimes: {
292
+ ...existingAcc.rateLimitResetTimes,
293
+ ...acc.rateLimitResetTimes,
294
+ },
295
+ lastUsed: Math.max(existingAcc.lastUsed || 0, acc.lastUsed || 0),
296
+ availableModels: newerModels.availableModels,
297
+ availableModelsUpdatedAt: newerModels.availableModelsUpdatedAt,
298
+ };
299
+ indexByToken.set(acc.refreshToken, index);
300
+ }
301
+ return {
302
+ version: 4,
303
+ // Same Google account under two tokens (one replaced but not retired): keep the newest.
304
+ accounts: deduplicateAccountsByEmail(merged.filter((acc) => !isRetired(acc))),
305
+ activeIndex: incoming.activeIndex,
306
+ activeIndexByFamily: incoming.activeIndexByFamily,
307
+ ...(retired.length > 0 ? { retiredTokenHashes: retired } : {}),
308
+ };
309
+ }
310
+ export function deduplicateAccountsByEmail(accounts) {
311
+ const emailToNewestIndex = new Map();
312
+ const indicesToKeep = new Set();
313
+ // First pass: find the newest account for each email (by lastUsed, then addedAt)
314
+ for (let i = 0; i < accounts.length; i++) {
315
+ const acc = accounts[i];
316
+ if (!acc)
317
+ continue;
318
+ if (!acc.email) {
319
+ // No email - keep this account (can't deduplicate without email)
320
+ indicesToKeep.add(i);
321
+ continue;
322
+ }
323
+ const existingIndex = emailToNewestIndex.get(acc.email);
324
+ if (existingIndex === undefined) {
325
+ emailToNewestIndex.set(acc.email, i);
326
+ continue;
327
+ }
328
+ // Compare to find which is newer
329
+ const existing = accounts[existingIndex];
330
+ if (!existing) {
331
+ emailToNewestIndex.set(acc.email, i);
332
+ continue;
333
+ }
334
+ // Prefer higher lastUsed, then higher addedAt
335
+ // Compare fields separately to avoid integer overflow with large timestamps
336
+ const currLastUsed = acc.lastUsed || 0;
337
+ const existLastUsed = existing.lastUsed || 0;
338
+ const currAddedAt = acc.addedAt || 0;
339
+ const existAddedAt = existing.addedAt || 0;
340
+ const isNewer = currLastUsed > existLastUsed ||
341
+ (currLastUsed === existLastUsed && currAddedAt > existAddedAt);
342
+ if (isNewer) {
343
+ emailToNewestIndex.set(acc.email, i);
344
+ }
345
+ }
346
+ // Add all the newest email-based indices to the keep set
347
+ for (const idx of emailToNewestIndex.values()) {
348
+ indicesToKeep.add(idx);
349
+ }
350
+ // Build the deduplicated list, preserving original order for kept items
351
+ const result = [];
352
+ for (let i = 0; i < accounts.length; i++) {
353
+ if (indicesToKeep.has(i)) {
354
+ const acc = accounts[i];
355
+ if (acc) {
356
+ result.push(acc);
357
+ }
358
+ }
359
+ }
360
+ return result;
361
+ }
362
+ function migrateV1ToV2(v1) {
363
+ return {
364
+ version: 2,
365
+ accounts: v1.accounts.map((acc) => {
366
+ const rateLimitResetTimes = {};
367
+ if (acc.isRateLimited &&
368
+ acc.rateLimitResetTime &&
369
+ acc.rateLimitResetTime > Date.now()) {
370
+ rateLimitResetTimes.claude = acc.rateLimitResetTime;
371
+ rateLimitResetTimes.gemini = acc.rateLimitResetTime;
372
+ }
373
+ return {
374
+ email: acc.email,
375
+ refreshToken: acc.refreshToken,
376
+ projectId: acc.projectId,
377
+ managedProjectId: acc.managedProjectId,
378
+ addedAt: acc.addedAt,
379
+ lastUsed: acc.lastUsed,
380
+ lastSwitchReason: acc.lastSwitchReason,
381
+ rateLimitResetTimes: Object.keys(rateLimitResetTimes).length > 0
382
+ ? rateLimitResetTimes
383
+ : undefined,
384
+ };
385
+ }),
386
+ activeIndex: v1.activeIndex,
387
+ };
388
+ }
389
+ export function migrateV2ToV3(v2) {
390
+ return {
391
+ version: 3,
392
+ accounts: v2.accounts.map((acc) => {
393
+ const rateLimitResetTimes = {};
394
+ if (acc.rateLimitResetTimes?.claude &&
395
+ acc.rateLimitResetTimes.claude > Date.now()) {
396
+ rateLimitResetTimes.claude = acc.rateLimitResetTimes.claude;
397
+ }
398
+ if (acc.rateLimitResetTimes?.gemini &&
399
+ acc.rateLimitResetTimes.gemini > Date.now()) {
400
+ rateLimitResetTimes["gemini-antigravity"] =
401
+ acc.rateLimitResetTimes.gemini;
402
+ }
403
+ return {
404
+ email: acc.email,
405
+ refreshToken: acc.refreshToken,
406
+ projectId: acc.projectId,
407
+ managedProjectId: acc.managedProjectId,
408
+ addedAt: acc.addedAt,
409
+ lastUsed: acc.lastUsed,
410
+ lastSwitchReason: acc.lastSwitchReason,
411
+ rateLimitResetTimes: Object.keys(rateLimitResetTimes).length > 0
412
+ ? rateLimitResetTimes
413
+ : undefined,
414
+ };
415
+ }),
416
+ activeIndex: v2.activeIndex,
417
+ };
418
+ }
419
+ export function migrateV3ToV4(v3) {
420
+ return {
421
+ version: 4,
422
+ accounts: v3.accounts.map((acc) => ({
423
+ ...acc,
424
+ fingerprint: undefined,
425
+ fingerprintHistory: undefined,
426
+ })),
427
+ activeIndex: v3.activeIndex,
428
+ activeIndexByFamily: v3.activeIndexByFamily,
429
+ };
430
+ }
431
+ export async function loadAccounts() {
432
+ try {
433
+ const path = getStoragePath();
434
+ // Ensure permissions are correct on load (fixes existing files)
435
+ await ensureSecurePermissions(path);
436
+ const content = await fs.readFile(path, "utf-8");
437
+ const data = JSON.parse(content);
438
+ if (!Array.isArray(data.accounts)) {
439
+ log.warn("Invalid storage format, ignoring");
440
+ return null;
441
+ }
442
+ let storage;
443
+ if (data.version === 1) {
444
+ log.info("Migrating account storage from v1 to v4");
445
+ const v2 = migrateV1ToV2(data);
446
+ const v3 = migrateV2ToV3(v2);
447
+ storage = migrateV3ToV4(v3);
448
+ try {
449
+ await saveAccounts(storage);
450
+ log.info("Migration to v4 complete");
451
+ }
452
+ catch (saveError) {
453
+ log.warn("Failed to persist migrated storage", {
454
+ error: String(saveError),
455
+ });
456
+ }
457
+ }
458
+ else if (data.version === 2) {
459
+ log.info("Migrating account storage from v2 to v4");
460
+ const v3 = migrateV2ToV3(data);
461
+ storage = migrateV3ToV4(v3);
462
+ try {
463
+ await saveAccounts(storage);
464
+ log.info("Migration to v4 complete");
465
+ }
466
+ catch (saveError) {
467
+ log.warn("Failed to persist migrated storage", {
468
+ error: String(saveError),
469
+ });
470
+ }
471
+ }
472
+ else if (data.version === 3) {
473
+ log.info("Migrating account storage from v3 to v4");
474
+ storage = migrateV3ToV4(data);
475
+ try {
476
+ await saveAccounts(storage);
477
+ log.info("Migration to v4 complete");
478
+ }
479
+ catch (saveError) {
480
+ log.warn("Failed to persist migrated storage", {
481
+ error: String(saveError),
482
+ });
483
+ }
484
+ }
485
+ else if (data.version === 4) {
486
+ storage = data;
487
+ }
488
+ else {
489
+ log.warn("Unknown storage version, ignoring", {
490
+ version: data.version,
491
+ });
492
+ return null;
493
+ }
494
+ // Validate accounts have required fields
495
+ const validAccounts = storage.accounts.filter((a) => {
496
+ return (!!a &&
497
+ typeof a === "object" &&
498
+ typeof a.refreshToken === "string");
499
+ });
500
+ // Drop retired tokens, then deduplicate by email (keeps newest entry for each email)
501
+ const retiredTokenHashes = Array.isArray(storage.retiredTokenHashes) ? storage.retiredTokenHashes : [];
502
+ const deduplicatedAccounts = deduplicateAccountsByEmail(withoutRetired(validAccounts, retiredTokenHashes));
503
+ // Clamp activeIndex to valid range after deduplication
504
+ let activeIndex = typeof storage.activeIndex === "number" &&
505
+ Number.isFinite(storage.activeIndex)
506
+ ? storage.activeIndex
507
+ : 0;
508
+ if (deduplicatedAccounts.length > 0) {
509
+ activeIndex = Math.min(activeIndex, deduplicatedAccounts.length - 1);
510
+ activeIndex = Math.max(activeIndex, 0);
511
+ }
512
+ else {
513
+ activeIndex = 0;
514
+ }
515
+ return {
516
+ version: 4,
517
+ accounts: deduplicatedAccounts,
518
+ activeIndex,
519
+ activeIndexByFamily: storage.activeIndexByFamily,
520
+ ...(retiredTokenHashes.length > 0 ? { retiredTokenHashes } : {}),
521
+ };
522
+ }
523
+ catch (error) {
524
+ const code = error.code;
525
+ if (code === "ENOENT") {
526
+ return null;
527
+ }
528
+ log.error("Failed to load account storage", { error: String(error) });
529
+ return null;
530
+ }
531
+ }
532
+ /**
533
+ * Merges `storage` into the file. `options.unretireTokens` lifts the retirement of tokens a
534
+ * sign-in just wrote (in case Google hands back a token that was retired before).
535
+ */
536
+ export async function saveAccounts(storage, options = {}) {
537
+ const path = getStoragePath();
538
+ const configDir = dirname(path);
539
+ await fs.mkdir(configDir, { recursive: true });
540
+ await ensureGitignore(configDir);
541
+ await withFileLock(path, async () => {
542
+ const existing = await loadAccountsUnsafe();
543
+ const unretired = (options.unretireTokens ?? []).map(hashRefreshToken);
544
+ const merged = existing ? mergeAccountStorage(existing, storage, unretired) : storage;
545
+ await writeStorageFile(path, merged);
546
+ });
547
+ }
548
+ /** Writes through a temp file and a rename, so readers never see a half-written pool. */
549
+ async function writeStorageFile(path, storage) {
550
+ const tempPath = `${path}.${randomBytes(6).toString("hex")}.tmp`;
551
+ try {
552
+ await fs.writeFile(tempPath, JSON.stringify(storage, null, 2), { encoding: "utf-8", mode: 0o600 });
553
+ await fs.rename(tempPath, path);
554
+ }
555
+ catch (error) {
556
+ // Clean up temp file on failure to prevent accumulation
557
+ try {
558
+ await fs.unlink(tempPath);
559
+ }
560
+ catch {
561
+ // Ignore cleanup errors (file may not exist)
562
+ }
563
+ throw error;
564
+ }
565
+ }
566
+ /**
567
+ * Stores discovered model lists on their accounts, changing nothing else. Reads and writes under
568
+ * the file lock, so it cannot undo a concurrent change by a running account manager.
569
+ */
570
+ export async function updateAccountModels(updates) {
571
+ if (updates.length === 0)
572
+ return;
573
+ const path = getStoragePath();
574
+ await withFileLock(path, async () => {
575
+ const existing = await loadAccountsUnsafe();
576
+ if (!existing)
577
+ return;
578
+ const byToken = new Map(updates.map((update) => [update.refreshToken, update]));
579
+ let changed = false;
580
+ const accounts = existing.accounts.map((account) => {
581
+ const update = byToken.get(account.refreshToken);
582
+ if (!update || (account.availableModelsUpdatedAt ?? 0) > update.availableModelsUpdatedAt)
583
+ return account;
584
+ changed = true;
585
+ return {
586
+ ...account,
587
+ availableModels: update.availableModels,
588
+ availableModelsUpdatedAt: update.availableModelsUpdatedAt,
589
+ };
590
+ });
591
+ if (changed)
592
+ await writeStorageFile(path, { ...existing, accounts });
593
+ });
594
+ }
595
+ /**
596
+ * Save accounts storage by replacing the entire file (no merge).
597
+ * Use this for destructive operations like delete where we need to
598
+ * remove accounts that would otherwise be merged back from existing storage.
599
+ */
600
+ export async function saveAccountsReplace(storage) {
601
+ const path = getStoragePath();
602
+ const configDir = dirname(path);
603
+ await fs.mkdir(configDir, { recursive: true });
604
+ await ensureGitignore(configDir);
605
+ await withFileLock(path, async () => {
606
+ // Keep the retired-token list across replacing writes, and never write a retired token back.
607
+ const existing = await loadAccountsUnsafe();
608
+ const retired = mergeRetired(existing?.retiredTokenHashes, storage.retiredTokenHashes);
609
+ storage = {
610
+ ...storage,
611
+ accounts: withoutRetired(storage.accounts, retired),
612
+ ...(retired.length > 0 ? { retiredTokenHashes: retired } : {}),
613
+ };
614
+ await writeStorageFile(path, storage);
615
+ });
616
+ }
617
+ /**
618
+ * Retires refresh tokens (replaced or removed accounts): their accounts are dropped from the
619
+ * pool now, and merges from account managers that still hold them can't bring them back.
620
+ */
621
+ export async function retireRefreshTokens(refreshTokens) {
622
+ if (refreshTokens.length === 0)
623
+ return;
624
+ const storage = await loadAccounts();
625
+ if (!storage)
626
+ return;
627
+ await saveAccountsReplace({
628
+ ...storage,
629
+ retiredTokenHashes: mergeRetired(storage.retiredTokenHashes, refreshTokens.map(hashRefreshToken)),
630
+ });
631
+ }
632
+ async function loadAccountsUnsafe() {
633
+ try {
634
+ const path = getStoragePath();
635
+ // Ensure permissions are correct on load (fixes existing files)
636
+ await ensureSecurePermissions(path);
637
+ const content = await fs.readFile(path, "utf-8");
638
+ const parsed = JSON.parse(content);
639
+ if (parsed.version === 1) {
640
+ return migrateV3ToV4(migrateV2ToV3(migrateV1ToV2(parsed)));
641
+ }
642
+ if (parsed.version === 2) {
643
+ return migrateV3ToV4(migrateV2ToV3(parsed));
644
+ }
645
+ if (parsed.version === 3) {
646
+ return migrateV3ToV4(parsed);
647
+ }
648
+ const retiredTokenHashes = Array.isArray(parsed.retiredTokenHashes) ? parsed.retiredTokenHashes : [];
649
+ return {
650
+ ...parsed,
651
+ accounts: deduplicateAccountsByEmail(withoutRetired(parsed.accounts, retiredTokenHashes)),
652
+ };
653
+ }
654
+ catch (error) {
655
+ const code = error.code;
656
+ if (code === "ENOENT") {
657
+ return null;
658
+ }
659
+ return null;
660
+ }
661
+ }
662
+ export async function clearAccounts() {
663
+ try {
664
+ const path = getStoragePath();
665
+ await fs.unlink(path);
666
+ }
667
+ catch (error) {
668
+ const code = error.code;
669
+ if (code !== "ENOENT") {
670
+ log.error("Failed to clear account storage", { error: String(error) });
671
+ }
672
+ }
673
+ }
674
+ //# sourceMappingURL=storage.js.map