antigravity-auth 1.6.0 → 1.7.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 (258) hide show
  1. package/README.md +79 -41
  2. package/dist/cli.js +17854 -0
  3. package/dist/handler.js +25147 -0
  4. package/dist/index.js +25138 -5
  5. package/package.json +66 -54
  6. package/dist/antigravity/oauth.d.ts +0 -30
  7. package/dist/antigravity/oauth.js +0 -170
  8. package/dist/claude/login.d.ts +0 -7
  9. package/dist/claude/login.js +0 -480
  10. package/dist/claude/menu-helpers.d.ts +0 -22
  11. package/dist/claude/menu-helpers.js +0 -281
  12. package/dist/claude/proxy-manager.d.ts +0 -11
  13. package/dist/claude/proxy-manager.js +0 -129
  14. package/dist/claude/proxy.d.ts +0 -1
  15. package/dist/claude/proxy.js +0 -733
  16. package/dist/constants.d.ts +0 -138
  17. package/dist/constants.js +0 -216
  18. package/dist/hooks/auto-update-checker/cache.d.ts +0 -2
  19. package/dist/hooks/auto-update-checker/cache.js +0 -70
  20. package/dist/hooks/auto-update-checker/checker.d.ts +0 -15
  21. package/dist/hooks/auto-update-checker/checker.js +0 -233
  22. package/dist/hooks/auto-update-checker/constants.d.ts +0 -8
  23. package/dist/hooks/auto-update-checker/constants.js +0 -22
  24. package/dist/hooks/auto-update-checker/index.d.ts +0 -33
  25. package/dist/hooks/auto-update-checker/index.js +0 -121
  26. package/dist/hooks/auto-update-checker/logging.d.ts +0 -2
  27. package/dist/hooks/auto-update-checker/logging.js +0 -8
  28. package/dist/hooks/auto-update-checker/types.d.ts +0 -24
  29. package/dist/hooks/auto-update-checker/types.js +0 -1
  30. package/dist/index.d.ts +0 -6
  31. package/dist/opencode/hooks/auto-update-checker/cache.d.ts +0 -2
  32. package/dist/opencode/hooks/auto-update-checker/cache.js +0 -70
  33. package/dist/opencode/hooks/auto-update-checker/checker.d.ts +0 -15
  34. package/dist/opencode/hooks/auto-update-checker/checker.js +0 -233
  35. package/dist/opencode/hooks/auto-update-checker/constants.d.ts +0 -8
  36. package/dist/opencode/hooks/auto-update-checker/constants.js +0 -22
  37. package/dist/opencode/hooks/auto-update-checker/index.d.ts +0 -33
  38. package/dist/opencode/hooks/auto-update-checker/index.js +0 -121
  39. package/dist/opencode/hooks/auto-update-checker/logging.d.ts +0 -2
  40. package/dist/opencode/hooks/auto-update-checker/logging.js +0 -8
  41. package/dist/opencode/hooks/auto-update-checker/types.d.ts +0 -24
  42. package/dist/opencode/hooks/auto-update-checker/types.js +0 -1
  43. package/dist/opencode/plugin.d.ts +0 -29
  44. package/dist/opencode/plugin.js +0 -2954
  45. package/dist/plugin/accounts.d.ts +0 -173
  46. package/dist/plugin/accounts.js +0 -966
  47. package/dist/plugin/auth.d.ts +0 -20
  48. package/dist/plugin/auth.js +0 -44
  49. package/dist/plugin/cache/index.d.ts +0 -4
  50. package/dist/plugin/cache/index.js +0 -4
  51. package/dist/plugin/cache/signature-cache.d.ts +0 -110
  52. package/dist/plugin/cache/signature-cache.js +0 -347
  53. package/dist/plugin/cache.d.ts +0 -43
  54. package/dist/plugin/cache.js +0 -180
  55. package/dist/plugin/cli.d.ts +0 -26
  56. package/dist/plugin/cli.js +0 -126
  57. package/dist/plugin/config/index.d.ts +0 -15
  58. package/dist/plugin/config/index.js +0 -15
  59. package/dist/plugin/config/loader.d.ts +0 -38
  60. package/dist/plugin/config/loader.js +0 -150
  61. package/dist/plugin/config/models.d.ts +0 -26
  62. package/dist/plugin/config/models.js +0 -95
  63. package/dist/plugin/config/schema.d.ts +0 -144
  64. package/dist/plugin/config/schema.js +0 -458
  65. package/dist/plugin/config/updater.d.ts +0 -76
  66. package/dist/plugin/config/updater.js +0 -205
  67. package/dist/plugin/core/streaming/index.d.ts +0 -2
  68. package/dist/plugin/core/streaming/index.js +0 -2
  69. package/dist/plugin/core/streaming/transformer.d.ts +0 -9
  70. package/dist/plugin/core/streaming/transformer.js +0 -301
  71. package/dist/plugin/core/streaming/types.d.ts +0 -28
  72. package/dist/plugin/core/streaming/types.js +0 -1
  73. package/dist/plugin/debug.d.ts +0 -93
  74. package/dist/plugin/debug.js +0 -375
  75. package/dist/plugin/errors.d.ts +0 -27
  76. package/dist/plugin/errors.js +0 -41
  77. package/dist/plugin/fingerprint.d.ts +0 -69
  78. package/dist/plugin/fingerprint.js +0 -137
  79. package/dist/plugin/image-saver.d.ts +0 -24
  80. package/dist/plugin/image-saver.js +0 -78
  81. package/dist/plugin/logger.d.ts +0 -35
  82. package/dist/plugin/logger.js +0 -67
  83. package/dist/plugin/logging-utils.d.ts +0 -22
  84. package/dist/plugin/logging-utils.js +0 -91
  85. package/dist/plugin/project.d.ts +0 -32
  86. package/dist/plugin/project.js +0 -229
  87. package/dist/plugin/quota.d.ts +0 -34
  88. package/dist/plugin/quota.js +0 -261
  89. package/dist/plugin/recovery/constants.d.ts +0 -21
  90. package/dist/plugin/recovery/constants.js +0 -42
  91. package/dist/plugin/recovery/index.d.ts +0 -11
  92. package/dist/plugin/recovery/index.js +0 -11
  93. package/dist/plugin/recovery/storage.d.ts +0 -23
  94. package/dist/plugin/recovery/storage.js +0 -340
  95. package/dist/plugin/recovery/types.d.ts +0 -115
  96. package/dist/plugin/recovery/types.js +0 -6
  97. package/dist/plugin/recovery.d.ts +0 -60
  98. package/dist/plugin/recovery.js +0 -360
  99. package/dist/plugin/refresh-queue.d.ts +0 -99
  100. package/dist/plugin/refresh-queue.js +0 -235
  101. package/dist/plugin/request-helpers.d.ts +0 -281
  102. package/dist/plugin/request-helpers.js +0 -2200
  103. package/dist/plugin/request.d.ts +0 -110
  104. package/dist/plugin/request.js +0 -1489
  105. package/dist/plugin/rotation.d.ts +0 -182
  106. package/dist/plugin/rotation.js +0 -364
  107. package/dist/plugin/search.d.ts +0 -31
  108. package/dist/plugin/search.js +0 -185
  109. package/dist/plugin/server.d.ts +0 -22
  110. package/dist/plugin/server.js +0 -306
  111. package/dist/plugin/storage.d.ts +0 -136
  112. package/dist/plugin/storage.js +0 -599
  113. package/dist/plugin/stores/signature-store.d.ts +0 -4
  114. package/dist/plugin/stores/signature-store.js +0 -24
  115. package/dist/plugin/thinking-recovery.d.ts +0 -89
  116. package/dist/plugin/thinking-recovery.js +0 -289
  117. package/dist/plugin/token.d.ts +0 -18
  118. package/dist/plugin/token.js +0 -127
  119. package/dist/plugin/transform/claude.d.ts +0 -79
  120. package/dist/plugin/transform/claude.js +0 -256
  121. package/dist/plugin/transform/cross-model-sanitizer.d.ts +0 -34
  122. package/dist/plugin/transform/cross-model-sanitizer.js +0 -224
  123. package/dist/plugin/transform/gemini.d.ts +0 -132
  124. package/dist/plugin/transform/gemini.js +0 -659
  125. package/dist/plugin/transform/index.d.ts +0 -14
  126. package/dist/plugin/transform/index.js +0 -9
  127. package/dist/plugin/transform/model-resolver.d.ts +0 -98
  128. package/dist/plugin/transform/model-resolver.js +0 -320
  129. package/dist/plugin/transform/types.d.ts +0 -110
  130. package/dist/plugin/transform/types.js +0 -1
  131. package/dist/plugin/types.d.ts +0 -95
  132. package/dist/plugin/types.js +0 -1
  133. package/dist/plugin/ui/ansi.d.ts +0 -31
  134. package/dist/plugin/ui/ansi.js +0 -45
  135. package/dist/plugin/ui/auth-menu.d.ts +0 -47
  136. package/dist/plugin/ui/auth-menu.js +0 -199
  137. package/dist/plugin/ui/confirm.d.ts +0 -1
  138. package/dist/plugin/ui/confirm.js +0 -14
  139. package/dist/plugin/ui/select.d.ts +0 -22
  140. package/dist/plugin/ui/select.js +0 -243
  141. package/dist/plugin/version.d.ts +0 -18
  142. package/dist/plugin/version.js +0 -79
  143. package/dist/src/antigravity/oauth.d.ts +0 -30
  144. package/dist/src/antigravity/oauth.js +0 -170
  145. package/dist/src/constants.d.ts +0 -138
  146. package/dist/src/constants.js +0 -216
  147. package/dist/src/hooks/auto-update-checker/cache.d.ts +0 -2
  148. package/dist/src/hooks/auto-update-checker/cache.js +0 -70
  149. package/dist/src/hooks/auto-update-checker/checker.d.ts +0 -15
  150. package/dist/src/hooks/auto-update-checker/checker.js +0 -233
  151. package/dist/src/hooks/auto-update-checker/constants.d.ts +0 -8
  152. package/dist/src/hooks/auto-update-checker/constants.js +0 -22
  153. package/dist/src/hooks/auto-update-checker/index.d.ts +0 -33
  154. package/dist/src/hooks/auto-update-checker/index.js +0 -121
  155. package/dist/src/hooks/auto-update-checker/logging.d.ts +0 -2
  156. package/dist/src/hooks/auto-update-checker/logging.js +0 -8
  157. package/dist/src/hooks/auto-update-checker/types.d.ts +0 -24
  158. package/dist/src/hooks/auto-update-checker/types.js +0 -1
  159. package/dist/src/index.d.ts +0 -6
  160. package/dist/src/index.js +0 -5
  161. package/dist/src/plugin/accounts.d.ts +0 -173
  162. package/dist/src/plugin/accounts.js +0 -966
  163. package/dist/src/plugin/auth.d.ts +0 -20
  164. package/dist/src/plugin/auth.js +0 -44
  165. package/dist/src/plugin/cache/index.d.ts +0 -4
  166. package/dist/src/plugin/cache/index.js +0 -4
  167. package/dist/src/plugin/cache/signature-cache.d.ts +0 -110
  168. package/dist/src/plugin/cache/signature-cache.js +0 -347
  169. package/dist/src/plugin/cache.d.ts +0 -43
  170. package/dist/src/plugin/cache.js +0 -180
  171. package/dist/src/plugin/cli.d.ts +0 -26
  172. package/dist/src/plugin/cli.js +0 -126
  173. package/dist/src/plugin/config/index.d.ts +0 -15
  174. package/dist/src/plugin/config/index.js +0 -15
  175. package/dist/src/plugin/config/loader.d.ts +0 -38
  176. package/dist/src/plugin/config/loader.js +0 -150
  177. package/dist/src/plugin/config/models.d.ts +0 -26
  178. package/dist/src/plugin/config/models.js +0 -95
  179. package/dist/src/plugin/config/schema.d.ts +0 -144
  180. package/dist/src/plugin/config/schema.js +0 -458
  181. package/dist/src/plugin/config/updater.d.ts +0 -76
  182. package/dist/src/plugin/config/updater.js +0 -205
  183. package/dist/src/plugin/core/streaming/index.d.ts +0 -2
  184. package/dist/src/plugin/core/streaming/index.js +0 -2
  185. package/dist/src/plugin/core/streaming/transformer.d.ts +0 -9
  186. package/dist/src/plugin/core/streaming/transformer.js +0 -301
  187. package/dist/src/plugin/core/streaming/types.d.ts +0 -28
  188. package/dist/src/plugin/core/streaming/types.js +0 -1
  189. package/dist/src/plugin/debug.d.ts +0 -93
  190. package/dist/src/plugin/debug.js +0 -375
  191. package/dist/src/plugin/errors.d.ts +0 -27
  192. package/dist/src/plugin/errors.js +0 -41
  193. package/dist/src/plugin/fingerprint.d.ts +0 -69
  194. package/dist/src/plugin/fingerprint.js +0 -137
  195. package/dist/src/plugin/image-saver.d.ts +0 -24
  196. package/dist/src/plugin/image-saver.js +0 -78
  197. package/dist/src/plugin/logger.d.ts +0 -35
  198. package/dist/src/plugin/logger.js +0 -67
  199. package/dist/src/plugin/logging-utils.d.ts +0 -22
  200. package/dist/src/plugin/logging-utils.js +0 -91
  201. package/dist/src/plugin/project.d.ts +0 -32
  202. package/dist/src/plugin/project.js +0 -229
  203. package/dist/src/plugin/quota.d.ts +0 -34
  204. package/dist/src/plugin/quota.js +0 -261
  205. package/dist/src/plugin/recovery/constants.d.ts +0 -21
  206. package/dist/src/plugin/recovery/constants.js +0 -42
  207. package/dist/src/plugin/recovery/index.d.ts +0 -11
  208. package/dist/src/plugin/recovery/index.js +0 -11
  209. package/dist/src/plugin/recovery/storage.d.ts +0 -23
  210. package/dist/src/plugin/recovery/storage.js +0 -340
  211. package/dist/src/plugin/recovery/types.d.ts +0 -115
  212. package/dist/src/plugin/recovery/types.js +0 -6
  213. package/dist/src/plugin/recovery.d.ts +0 -60
  214. package/dist/src/plugin/recovery.js +0 -360
  215. package/dist/src/plugin/refresh-queue.d.ts +0 -99
  216. package/dist/src/plugin/refresh-queue.js +0 -235
  217. package/dist/src/plugin/request-helpers.d.ts +0 -281
  218. package/dist/src/plugin/request-helpers.js +0 -2200
  219. package/dist/src/plugin/request.d.ts +0 -110
  220. package/dist/src/plugin/request.js +0 -1489
  221. package/dist/src/plugin/rotation.d.ts +0 -182
  222. package/dist/src/plugin/rotation.js +0 -364
  223. package/dist/src/plugin/search.d.ts +0 -31
  224. package/dist/src/plugin/search.js +0 -185
  225. package/dist/src/plugin/server.d.ts +0 -22
  226. package/dist/src/plugin/server.js +0 -306
  227. package/dist/src/plugin/storage.d.ts +0 -136
  228. package/dist/src/plugin/storage.js +0 -599
  229. package/dist/src/plugin/stores/signature-store.d.ts +0 -4
  230. package/dist/src/plugin/stores/signature-store.js +0 -24
  231. package/dist/src/plugin/thinking-recovery.d.ts +0 -89
  232. package/dist/src/plugin/thinking-recovery.js +0 -289
  233. package/dist/src/plugin/token.d.ts +0 -18
  234. package/dist/src/plugin/token.js +0 -127
  235. package/dist/src/plugin/transform/claude.d.ts +0 -79
  236. package/dist/src/plugin/transform/claude.js +0 -256
  237. package/dist/src/plugin/transform/cross-model-sanitizer.d.ts +0 -34
  238. package/dist/src/plugin/transform/cross-model-sanitizer.js +0 -224
  239. package/dist/src/plugin/transform/gemini.d.ts +0 -132
  240. package/dist/src/plugin/transform/gemini.js +0 -659
  241. package/dist/src/plugin/transform/index.d.ts +0 -14
  242. package/dist/src/plugin/transform/index.js +0 -9
  243. package/dist/src/plugin/transform/model-resolver.d.ts +0 -98
  244. package/dist/src/plugin/transform/model-resolver.js +0 -320
  245. package/dist/src/plugin/transform/types.d.ts +0 -110
  246. package/dist/src/plugin/transform/types.js +0 -1
  247. package/dist/src/plugin/types.d.ts +0 -95
  248. package/dist/src/plugin/types.js +0 -1
  249. package/dist/src/plugin/ui/ansi.d.ts +0 -31
  250. package/dist/src/plugin/ui/ansi.js +0 -45
  251. package/dist/src/plugin/ui/auth-menu.d.ts +0 -47
  252. package/dist/src/plugin/ui/auth-menu.js +0 -199
  253. package/dist/src/plugin/ui/confirm.d.ts +0 -1
  254. package/dist/src/plugin/ui/confirm.js +0 -14
  255. package/dist/src/plugin/ui/select.d.ts +0 -22
  256. package/dist/src/plugin/ui/select.js +0 -243
  257. package/dist/src/plugin/version.d.ts +0 -18
  258. package/dist/src/plugin/version.js +0 -79
@@ -1,180 +0,0 @@
1
- import { accessTokenExpired } from "./auth";
2
- import { createHash } from "node:crypto";
3
- const authCache = new Map();
4
- /**
5
- * Produces a stable cache key from a refresh token string.
6
- */
7
- function normalizeRefreshKey(refresh) {
8
- const key = refresh?.trim();
9
- return key ? key : undefined;
10
- }
11
- /**
12
- * Returns a cached auth snapshot when available, favoring unexpired tokens.
13
- */
14
- export function resolveCachedAuth(auth) {
15
- const key = normalizeRefreshKey(auth.refresh);
16
- if (!key) {
17
- return auth;
18
- }
19
- const cached = authCache.get(key);
20
- if (!cached) {
21
- authCache.set(key, auth);
22
- return auth;
23
- }
24
- if (!accessTokenExpired(auth)) {
25
- authCache.set(key, auth);
26
- return auth;
27
- }
28
- if (!accessTokenExpired(cached)) {
29
- return cached;
30
- }
31
- authCache.set(key, auth);
32
- return auth;
33
- }
34
- /**
35
- * Stores the latest auth snapshot keyed by refresh token.
36
- */
37
- export function storeCachedAuth(auth) {
38
- const key = normalizeRefreshKey(auth.refresh);
39
- if (!key) {
40
- return;
41
- }
42
- authCache.set(key, auth);
43
- }
44
- /**
45
- * Clears cached auth globally or for a specific refresh token.
46
- */
47
- export function clearCachedAuth(refresh) {
48
- if (!refresh) {
49
- authCache.clear();
50
- return;
51
- }
52
- const key = normalizeRefreshKey(refresh);
53
- if (key) {
54
- authCache.delete(key);
55
- }
56
- }
57
- // ============================================================================
58
- // ============================================================================
59
- import { createSignatureCache } from "./cache/signature-cache";
60
- const signatureCache = new Map();
61
- const SIGNATURE_CACHE_TTL_MS = 60 * 60 * 1000;
62
- const MAX_ENTRIES_PER_SESSION = 100;
63
- // 16 hex chars = 64-bit key space; keeps memory bounded while making collisions extremely unlikely.
64
- const SIGNATURE_TEXT_HASH_HEX_LEN = 16;
65
- let diskCache = null;
66
- /**
67
- * Initialize the disk-based signature cache.
68
- * Call this from plugin initialization when keep_thinking is enabled.
69
- */
70
- export function initDiskSignatureCache(config) {
71
- diskCache = createSignatureCache(config);
72
- return diskCache;
73
- }
74
- /**
75
- * Get the disk cache instance (for testing/debugging).
76
- */
77
- export function getDiskSignatureCache() {
78
- return diskCache;
79
- }
80
- /**
81
- * Hashes text content into a stable, Unicode-safe key.
82
- *
83
- * Uses SHA-256 over UTF-8 bytes and truncates to keep memory usage bounded.
84
- */
85
- function hashText(text) {
86
- return createHash("sha256").update(text, "utf8").digest("hex").slice(0, SIGNATURE_TEXT_HASH_HEX_LEN);
87
- }
88
- /**
89
- * Create a disk cache key from sessionId and textHash.
90
- */
91
- function makeDiskKey(sessionId, textHash) {
92
- return `${sessionId}:${textHash}`;
93
- }
94
- /**
95
- * Caches a thinking signature for a given session and text.
96
- * Used for Claude models that require signed thinking blocks in multi-turn conversations.
97
- * Also writes to disk cache if enabled.
98
- */
99
- export function cacheSignature(sessionId, text, signature) {
100
- if (!sessionId || !text || !signature)
101
- return;
102
- const textHash = hashText(text);
103
- let sessionMemCache = signatureCache.get(sessionId);
104
- if (!sessionMemCache) {
105
- sessionMemCache = new Map();
106
- signatureCache.set(sessionId, sessionMemCache);
107
- }
108
- if (sessionMemCache.size >= MAX_ENTRIES_PER_SESSION) {
109
- const now = Date.now();
110
- for (const [key, entry] of sessionMemCache.entries()) {
111
- if (now - entry.timestamp > SIGNATURE_CACHE_TTL_MS) {
112
- sessionMemCache.delete(key);
113
- }
114
- }
115
- if (sessionMemCache.size >= MAX_ENTRIES_PER_SESSION) {
116
- const entries = Array.from(sessionMemCache.entries())
117
- .sort((a, b) => a[1].timestamp - b[1].timestamp);
118
- const toRemove = entries.slice(0, Math.floor(MAX_ENTRIES_PER_SESSION / 4));
119
- for (const [key] of toRemove) {
120
- sessionMemCache.delete(key);
121
- }
122
- }
123
- }
124
- sessionMemCache.set(textHash, { signature, timestamp: Date.now() });
125
- if (diskCache) {
126
- const diskKey = makeDiskKey(sessionId, textHash);
127
- diskCache.store(diskKey, signature);
128
- }
129
- }
130
- /**
131
- * Retrieves a cached signature for a given session and text.
132
- * Checks memory first, then falls back to disk cache.
133
- * Returns undefined if not found or expired.
134
- */
135
- export function getCachedSignature(sessionId, text) {
136
- if (!sessionId || !text)
137
- return undefined;
138
- const textHash = hashText(text);
139
- const sessionMemCache = signatureCache.get(sessionId);
140
- if (sessionMemCache) {
141
- const entry = sessionMemCache.get(textHash);
142
- if (entry) {
143
- if (Date.now() - entry.timestamp > SIGNATURE_CACHE_TTL_MS) {
144
- sessionMemCache.delete(textHash);
145
- }
146
- else {
147
- return entry.signature;
148
- }
149
- }
150
- }
151
- if (diskCache) {
152
- const diskKey = makeDiskKey(sessionId, textHash);
153
- const diskValue = diskCache.retrieve(diskKey);
154
- if (diskValue) {
155
- let memCache = signatureCache.get(sessionId);
156
- if (!memCache) {
157
- memCache = new Map();
158
- signatureCache.set(sessionId, memCache);
159
- }
160
- memCache.set(textHash, { signature: diskValue, timestamp: Date.now() });
161
- return diskValue;
162
- }
163
- }
164
- return undefined;
165
- }
166
- /**
167
- * Clears signature cache for a specific session or all sessions.
168
- * Also clears from disk cache if enabled.
169
- */
170
- export function clearSignatureCache(sessionId) {
171
- if (sessionId) {
172
- signatureCache.delete(sessionId);
173
- }
174
- else {
175
- signatureCache.clear();
176
- }
177
- }
178
- // ============================================================================
179
- // ============================================================================
180
- export { SignatureCache, createSignatureCache } from "./cache/signature-cache";
@@ -1,26 +0,0 @@
1
- import { type AccountStatus } from "./ui/auth-menu";
2
- export declare function promptProjectId(): Promise<string>;
3
- export declare function promptAddAnotherAccount(currentCount: number): Promise<boolean>;
4
- export type LoginMode = "add" | "fresh" | "manage" | "check" | "verify" | "verify-all" | "proxies" | "cancel";
5
- export interface ExistingAccountInfo {
6
- email?: string;
7
- index: number;
8
- addedAt?: number;
9
- lastUsed?: number;
10
- status?: AccountStatus;
11
- isCurrentAccount?: boolean;
12
- enabled?: boolean;
13
- }
14
- export interface LoginMenuResult {
15
- mode: LoginMode;
16
- deleteAccountIndex?: number;
17
- refreshAccountIndex?: number;
18
- toggleAccountIndex?: number;
19
- verifyAccountIndex?: number;
20
- proxiesAccountIndex?: number;
21
- verifyAll?: boolean;
22
- deleteAll?: boolean;
23
- }
24
- export declare function promptLoginMode(existingAccounts: ExistingAccountInfo[]): Promise<LoginMenuResult>;
25
- export { isTTY, showProxyMenu, promptProxyUrl } from "./ui/auth-menu";
26
- export type { AccountStatus } from "./ui/auth-menu";
@@ -1,126 +0,0 @@
1
- import { createInterface } from "node:readline/promises";
2
- import { stdin as input, stdout as output } from "node:process";
3
- import { showAuthMenu, showAccountDetails, isTTY, } from "./ui/auth-menu";
4
- import { updateOpencodeConfig } from "./config/updater";
5
- export async function promptProjectId() {
6
- const rl = createInterface({ input, output });
7
- try {
8
- const answer = await rl.question("Project ID (leave blank to use your default project): ");
9
- return answer.trim();
10
- }
11
- finally {
12
- rl.close();
13
- }
14
- }
15
- export async function promptAddAnotherAccount(currentCount) {
16
- const rl = createInterface({ input, output });
17
- try {
18
- const answer = await rl.question(`Add another account? (${currentCount} added) (y/n): `);
19
- const normalized = answer.trim().toLowerCase();
20
- return normalized === "y" || normalized === "yes";
21
- }
22
- finally {
23
- rl.close();
24
- }
25
- }
26
- async function promptLoginModeFallback(existingAccounts) {
27
- const rl = createInterface({ input, output });
28
- try {
29
- console.log(`\n${existingAccounts.length} account(s) saved:`);
30
- for (const acc of existingAccounts) {
31
- const label = acc.email || `Account ${acc.index + 1}`;
32
- console.log(` ${acc.index + 1}. ${label}`);
33
- }
34
- console.log("");
35
- while (true) {
36
- const answer = await rl.question("(a)dd new, (f)resh start, (c)heck quotas, (v)erify, (va) verify all, (p) proxies? [a/f/c/v/va/p]: ");
37
- const normalized = answer.trim().toLowerCase();
38
- if (normalized === "a" || normalized === "add") {
39
- return { mode: "add" };
40
- }
41
- if (normalized === "f" || normalized === "fresh") {
42
- return { mode: "fresh" };
43
- }
44
- if (normalized === "c" || normalized === "check") {
45
- return { mode: "check" };
46
- }
47
- if (normalized === "v" || normalized === "verify") {
48
- return { mode: "verify" };
49
- }
50
- if (normalized === "va" || normalized === "verify-all" || normalized === "all") {
51
- return { mode: "verify-all", verifyAll: true };
52
- }
53
- if (normalized === "p" || normalized === "proxies") {
54
- return { mode: "proxies" };
55
- }
56
- console.log("Please enter 'a', 'f', 'c', 'v', or 'va'.");
57
- }
58
- }
59
- finally {
60
- rl.close();
61
- }
62
- }
63
- export async function promptLoginMode(existingAccounts) {
64
- if (!isTTY()) {
65
- return promptLoginModeFallback(existingAccounts);
66
- }
67
- const accounts = existingAccounts.map(acc => ({
68
- email: acc.email,
69
- index: acc.index,
70
- addedAt: acc.addedAt,
71
- lastUsed: acc.lastUsed,
72
- status: acc.status,
73
- isCurrentAccount: acc.isCurrentAccount,
74
- enabled: acc.enabled,
75
- }));
76
- console.log("");
77
- while (true) {
78
- const action = await showAuthMenu(accounts);
79
- switch (action.type) {
80
- case "add":
81
- return { mode: "add" };
82
- case "check":
83
- return { mode: "check" };
84
- case "verify":
85
- return { mode: "verify" };
86
- case "verify-all":
87
- return { mode: "verify-all", verifyAll: true };
88
- case "select-account": {
89
- const accountAction = await showAccountDetails(action.account);
90
- if (accountAction === "delete") {
91
- return { mode: "add", deleteAccountIndex: action.account.index };
92
- }
93
- if (accountAction === "refresh") {
94
- return { mode: "add", refreshAccountIndex: action.account.index };
95
- }
96
- if (accountAction === "toggle") {
97
- return { mode: "manage", toggleAccountIndex: action.account.index };
98
- }
99
- if (accountAction === "verify") {
100
- return { mode: "verify", verifyAccountIndex: action.account.index };
101
- }
102
- if (accountAction === "proxies") {
103
- return { mode: "proxies", proxiesAccountIndex: action.account.index };
104
- }
105
- continue;
106
- }
107
- case "delete-all":
108
- return { mode: "fresh", deleteAll: true };
109
- case "proxies":
110
- return { mode: "proxies" };
111
- case "configure-models": {
112
- const result = await updateOpencodeConfig();
113
- if (result.success) {
114
- console.log(`\n✓ Models configured in ${result.configPath}\n`);
115
- }
116
- else {
117
- console.log(`\n✗ Failed to configure models: ${result.error}\n`);
118
- }
119
- continue;
120
- }
121
- case "cancel":
122
- return { mode: "cancel" };
123
- }
124
- }
125
- }
126
- export { isTTY, showProxyMenu, promptProxyUrl } from "./ui/auth-menu";
@@ -1,15 +0,0 @@
1
- /**
2
- * Configuration module for opencode-antigravity-auth plugin.
3
- *
4
- * @example
5
- * ```typescript
6
- * import { loadConfig, type AntigravityConfig } from "./config";
7
- *
8
- * const config = loadConfig(directory);
9
- * if (config.session_recovery) {
10
- * // Enable session recovery
11
- * }
12
- * ```
13
- */
14
- export { AntigravityConfigSchema, SignatureCacheConfigSchema, DEFAULT_CONFIG, type AntigravityConfig, type SignatureCacheConfig, } from "./schema";
15
- export { loadConfig, getUserConfigPath, getProjectConfigPath, getDefaultLogsDir, configExists, initRuntimeConfig, getKeepThinking, } from "./loader";
@@ -1,15 +0,0 @@
1
- /**
2
- * Configuration module for opencode-antigravity-auth plugin.
3
- *
4
- * @example
5
- * ```typescript
6
- * import { loadConfig, type AntigravityConfig } from "./config";
7
- *
8
- * const config = loadConfig(directory);
9
- * if (config.session_recovery) {
10
- * // Enable session recovery
11
- * }
12
- * ```
13
- */
14
- export { AntigravityConfigSchema, SignatureCacheConfigSchema, DEFAULT_CONFIG, } from "./schema";
15
- export { loadConfig, getUserConfigPath, getProjectConfigPath, getDefaultLogsDir, configExists, initRuntimeConfig, getKeepThinking, } from "./loader";
@@ -1,38 +0,0 @@
1
- /**
2
- * Configuration loader for opencode-antigravity-auth plugin.
3
- *
4
- * Loads config from files.
5
- * Priority (lowest to highest):
6
- * 1. Schema defaults
7
- * 2. User config file
8
- * 3. Project config file
9
- */
10
- import { type AntigravityConfig } from "./schema";
11
- /**
12
- * Get the user-level config file path.
13
- * Prefers ~/.config/opencode/config/antigravity.json (new location).
14
- * Falls back to ~/.config/opencode/antigravity.json (legacy) and auto-migrates.
15
- */
16
- export declare function getUserConfigPath(): string;
17
- /**
18
- * Get the project-level config file path.
19
- */
20
- export declare function getProjectConfigPath(directory: string): string;
21
- /**
22
- * Load the complete configuration.
23
- *
24
- * @param directory - The project directory (for project-level config)
25
- * @returns Fully resolved configuration
26
- */
27
- export declare function loadConfig(directory: string): AntigravityConfig;
28
- /**
29
- * Check if a config file exists at the given path.
30
- */
31
- export declare function configExists(path: string): boolean;
32
- /**
33
- * Get the default logs directory.
34
- * Uses ~/.config/opencode/logs/ (centralized logs folder).
35
- */
36
- export declare function getDefaultLogsDir(): string;
37
- export declare function initRuntimeConfig(config: AntigravityConfig): void;
38
- export declare function getKeepThinking(): boolean;
@@ -1,150 +0,0 @@
1
- /**
2
- * Configuration loader for opencode-antigravity-auth plugin.
3
- *
4
- * Loads config from files.
5
- * Priority (lowest to highest):
6
- * 1. Schema defaults
7
- * 2. User config file
8
- * 3. Project config file
9
- */
10
- import { existsSync, readFileSync, copyFileSync, mkdirSync } from "node:fs";
11
- import { join } from "node:path";
12
- import { homedir } from "node:os";
13
- import { AntigravityConfigSchema, DEFAULT_CONFIG } from "./schema";
14
- import { createLogger } from "../logger";
15
- const log = createLogger("config");
16
- // =============================================================================
17
- // =============================================================================
18
- /**
19
- * Get the config directory path, with the following precedence:
20
- * 1. OPENCODE_CONFIG_DIR env var (if set)
21
- * 2. ~/.config/opencode (all platforms, including Windows)
22
- */
23
- function getConfigDir() {
24
- // 1. Check for explicit override via env var
25
- if (process.env.OPENCODE_CONFIG_DIR) {
26
- return process.env.OPENCODE_CONFIG_DIR;
27
- }
28
- // 2. Use ~/.config/opencode on all platforms (including Windows)
29
- const xdgConfig = process.env.XDG_CONFIG_HOME || join(homedir(), ".config");
30
- return join(xdgConfig, "opencode");
31
- }
32
- /**
33
- * Get the user-level config file path.
34
- * Prefers ~/.config/opencode/config/antigravity.json (new location).
35
- * Falls back to ~/.config/opencode/antigravity.json (legacy) and auto-migrates.
36
- */
37
- export function getUserConfigPath() {
38
- const configFolder = join(getConfigDir(), "config");
39
- const newPath = join(configFolder, "antigravity.json");
40
- if (existsSync(newPath))
41
- return newPath;
42
- const legacyPath = join(getConfigDir(), "antigravity.json");
43
- if (existsSync(legacyPath)) {
44
- try {
45
- if (!existsSync(configFolder))
46
- mkdirSync(configFolder, { recursive: true });
47
- copyFileSync(legacyPath, newPath);
48
- return newPath;
49
- }
50
- catch { }
51
- return legacyPath;
52
- }
53
- return newPath;
54
- }
55
- /**
56
- * Get the project-level config file path.
57
- */
58
- export function getProjectConfigPath(directory) {
59
- return join(directory, ".opencode", "antigravity.json");
60
- }
61
- // =============================================================================
62
- // =============================================================================
63
- /**
64
- * Load and parse a config file, returning null if not found or invalid.
65
- */
66
- function loadConfigFile(path) {
67
- try {
68
- if (!existsSync(path)) {
69
- return null;
70
- }
71
- const content = readFileSync(path, "utf-8");
72
- const rawConfig = JSON.parse(content);
73
- const result = AntigravityConfigSchema.partial().safeParse(rawConfig);
74
- if (!result.success) {
75
- log.warn("Config validation error", {
76
- path,
77
- issues: result.error.issues.map(i => `${i.path.join(".")}: ${i.message}`).join(", "),
78
- });
79
- return null;
80
- }
81
- return result.data;
82
- }
83
- catch (error) {
84
- if (error instanceof SyntaxError) {
85
- log.warn("Invalid JSON in config file", { path, error: error.message });
86
- }
87
- else {
88
- log.warn("Failed to load config file", { path, error: String(error) });
89
- }
90
- return null;
91
- }
92
- }
93
- /**
94
- * Deep merge two config objects, with override taking precedence.
95
- */
96
- function mergeConfigs(base, override) {
97
- return {
98
- ...base,
99
- ...override,
100
- // Deep merge signature_cache if both exist
101
- signature_cache: override.signature_cache
102
- ? {
103
- ...base.signature_cache,
104
- ...override.signature_cache,
105
- }
106
- : base.signature_cache,
107
- };
108
- }
109
- // =============================================================================
110
- // =============================================================================
111
- /**
112
- * Load the complete configuration.
113
- *
114
- * @param directory - The project directory (for project-level config)
115
- * @returns Fully resolved configuration
116
- */
117
- export function loadConfig(directory) {
118
- let config = { ...DEFAULT_CONFIG };
119
- const userConfigPath = getUserConfigPath();
120
- const userConfig = loadConfigFile(userConfigPath);
121
- if (userConfig) {
122
- config = mergeConfigs(config, userConfig);
123
- }
124
- const projectConfigPath = getProjectConfigPath(directory);
125
- const projectConfig = loadConfigFile(projectConfigPath);
126
- if (projectConfig) {
127
- config = mergeConfigs(config, projectConfig);
128
- }
129
- return config;
130
- }
131
- /**
132
- * Check if a config file exists at the given path.
133
- */
134
- export function configExists(path) {
135
- return existsSync(path);
136
- }
137
- /**
138
- * Get the default logs directory.
139
- * Uses ~/.config/opencode/logs/ (centralized logs folder).
140
- */
141
- export function getDefaultLogsDir() {
142
- return join(getConfigDir(), "logs");
143
- }
144
- let runtimeConfig = null;
145
- export function initRuntimeConfig(config) {
146
- runtimeConfig = config;
147
- }
148
- export function getKeepThinking() {
149
- return runtimeConfig?.keep_thinking ?? false;
150
- }
@@ -1,26 +0,0 @@
1
- import type { ProviderModel } from "../types";
2
- export type ModelThinkingLevel = "minimal" | "low" | "medium" | "high";
3
- export interface ModelThinkingConfig {
4
- thinkingBudget: number;
5
- }
6
- export interface ModelVariant {
7
- thinkingLevel?: ModelThinkingLevel;
8
- thinkingConfig?: ModelThinkingConfig;
9
- }
10
- export interface ModelLimit {
11
- context: number;
12
- output: number;
13
- }
14
- export type ModelModality = "text" | "image" | "pdf";
15
- export interface ModelModalities {
16
- input: ModelModality[];
17
- output: ModelModality[];
18
- }
19
- export interface OpencodeModelDefinition extends ProviderModel {
20
- name: string;
21
- limit: ModelLimit;
22
- modalities: ModelModalities;
23
- variants?: Record<string, ModelVariant>;
24
- }
25
- export type OpencodeModelDefinitions = Record<string, OpencodeModelDefinition>;
26
- export declare const OPENCODE_MODEL_DEFINITIONS: OpencodeModelDefinitions;
@@ -1,95 +0,0 @@
1
- const DEFAULT_MODALITIES = {
2
- input: ["text", "image", "pdf"],
3
- output: ["text"],
4
- };
5
- export const OPENCODE_MODEL_DEFINITIONS = {
6
- "antigravity-auto": {
7
- name: "Antigravity Auto",
8
- limit: { context: 200000, output: 65535 },
9
- modalities: DEFAULT_MODALITIES,
10
- },
11
- "antigravity-auto-best": {
12
- name: "Antigravity Auto (Best)",
13
- limit: { context: 200000, output: 65535 },
14
- modalities: DEFAULT_MODALITIES,
15
- },
16
- "antigravity-auto-high": {
17
- name: "Antigravity Auto (High)",
18
- limit: { context: 200000, output: 65535 },
19
- modalities: DEFAULT_MODALITIES,
20
- },
21
- "antigravity-auto-balanced": {
22
- name: "Antigravity Auto (Balanced)",
23
- limit: { context: 200000, output: 65535 },
24
- modalities: DEFAULT_MODALITIES,
25
- },
26
- "antigravity-auto-fastest": {
27
- name: "Antigravity Auto (Fastest)",
28
- limit: { context: 200000, output: 65535 },
29
- modalities: DEFAULT_MODALITIES,
30
- },
31
- "antigravity-gemini-3.1-pro": {
32
- name: "Gemini 3.1 Pro (Antigravity)",
33
- limit: { context: 1048576, output: 65535 },
34
- modalities: DEFAULT_MODALITIES,
35
- variants: {
36
- low: { thinkingLevel: "low" },
37
- high: { thinkingLevel: "high" },
38
- },
39
- },
40
- "antigravity-gemini-3-flash": {
41
- name: "Gemini 3 Flash (Antigravity)",
42
- limit: { context: 1048576, output: 65536 },
43
- modalities: DEFAULT_MODALITIES,
44
- variants: {
45
- minimal: { thinkingLevel: "minimal" },
46
- low: { thinkingLevel: "low" },
47
- medium: { thinkingLevel: "medium" },
48
- high: { thinkingLevel: "high" },
49
- },
50
- },
51
- "antigravity-claude-sonnet-4-6": {
52
- name: "Claude Sonnet 4.6 (Antigravity)",
53
- limit: { context: 200000, output: 64000 },
54
- modalities: DEFAULT_MODALITIES,
55
- },
56
- "antigravity-claude-opus-4-6-thinking": {
57
- name: "Claude Opus 4.6 Thinking (Antigravity)",
58
- limit: { context: 200000, output: 64000 },
59
- modalities: DEFAULT_MODALITIES,
60
- variants: {
61
- low: { thinkingConfig: { thinkingBudget: 8192 } },
62
- max: { thinkingConfig: { thinkingBudget: 32768 } },
63
- },
64
- },
65
- "gemini-2.5-flash": {
66
- name: "Gemini 2.5 Flash (Gemini CLI)",
67
- limit: { context: 1048576, output: 65536 },
68
- modalities: DEFAULT_MODALITIES,
69
- },
70
- "gemini-2.5-pro": {
71
- name: "Gemini 2.5 Pro (Gemini CLI)",
72
- limit: { context: 1048576, output: 65536 },
73
- modalities: DEFAULT_MODALITIES,
74
- },
75
- "gemini-3-flash-preview": {
76
- name: "Gemini 3 Flash Preview (Gemini CLI)",
77
- limit: { context: 1048576, output: 65536 },
78
- modalities: DEFAULT_MODALITIES,
79
- },
80
- "gemini-3-pro-preview": {
81
- name: "Gemini 3 Pro Preview (Gemini CLI)",
82
- limit: { context: 1048576, output: 65535 },
83
- modalities: DEFAULT_MODALITIES,
84
- },
85
- "gemini-3.1-pro-preview": {
86
- name: "Gemini 3.1 Pro Preview (Gemini CLI)",
87
- limit: { context: 1048576, output: 65535 },
88
- modalities: DEFAULT_MODALITIES,
89
- },
90
- "gemini-3.1-pro-preview-customtools": {
91
- name: "Gemini 3.1 Pro Preview Custom Tools (Gemini CLI)",
92
- limit: { context: 1048576, output: 65535 },
93
- modalities: DEFAULT_MODALITIES,
94
- },
95
- };