@hashimkarim/usagestat-darwin-arm64 2.0.0-alpha.3 → 2.3.2

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 (284) hide show
  1. package/native-manifest.json +1532 -134
  2. package/package.json +235 -2
  3. package/plugins/UPSTREAM-LICENSES.md +6 -2
  4. package/plugins/_provider-icons/LICENSE +21 -0
  5. package/plugins/_provider-icons/NOTICE +12 -0
  6. package/plugins/_provider-icons/licenses/CodexBar-MIT.txt +21 -0
  7. package/plugins/_provider-icons/licenses/LobeHub-MIT.txt +21 -0
  8. package/plugins/_provider-icons/licenses/UsageStat-Bar-MIT.txt +21 -0
  9. package/plugins/_provider-icons/manifest.json +1219 -0
  10. package/plugins/_provider-icons/provenance.json +269 -0
  11. package/plugins/_provider-icons/source.json +4 -0
  12. package/plugins/abacus-ai/icon-color.svg +18 -0
  13. package/plugins/abliteration/LICENSE +21 -0
  14. package/plugins/abliteration/icon.svg +5 -0
  15. package/plugins/abliteration/plugin.js +89 -0
  16. package/plugins/abliteration/plugin.json +24 -0
  17. package/plugins/aerostack/LICENSE +21 -0
  18. package/plugins/aerostack/icon.svg +1 -0
  19. package/plugins/aerostack/plugin.js +94 -0
  20. package/plugins/aerostack/plugin.json +24 -0
  21. package/plugins/aixy/LICENSE +21 -0
  22. package/plugins/aixy/icon.svg +1 -0
  23. package/plugins/aixy/plugin.js +266 -0
  24. package/plugins/aixy/plugin.json +32 -0
  25. package/plugins/antigravity/plugin.js +189 -65
  26. package/plugins/antigravity-cli/icon-color.svg +1 -0
  27. package/plugins/antigravity-cli/icon.svg +1 -3
  28. package/plugins/antigravity-cli/plugin.js +32 -20
  29. package/plugins/antigravity-ide/icon-color.svg +1 -0
  30. package/plugins/antigravity-ide/icon.svg +1 -3
  31. package/plugins/antigravity-ide/plugin.js +19 -7
  32. package/plugins/atlascloud/LICENSE +21 -0
  33. package/plugins/atlascloud/icon-color.svg +1 -0
  34. package/plugins/atlascloud/icon.svg +1 -0
  35. package/plugins/atlascloud/plugin.js +54 -0
  36. package/plugins/atlascloud/plugin.json +24 -0
  37. package/plugins/augment/icon-color.svg +14 -0
  38. package/plugins/bifrost/LICENSE +21 -0
  39. package/plugins/bifrost/icon.svg +3 -0
  40. package/plugins/bifrost/plugin.js +366 -0
  41. package/plugins/bifrost/plugin.json +31 -0
  42. package/plugins/chatbox/LICENSE +21 -0
  43. package/plugins/chatbox/icon.svg +4 -0
  44. package/plugins/chatbox/plugin.js +208 -0
  45. package/plugins/chatbox/plugin.json +24 -0
  46. package/plugins/claude/plugin.js +340 -153
  47. package/plugins/claude/plugin.json +1 -1
  48. package/plugins/claudeplatform/LICENSE +21 -0
  49. package/plugins/claudeplatform/icon.svg +3 -0
  50. package/plugins/claudeplatform/plugin.js +244 -0
  51. package/plugins/claudeplatform/plugin.json +25 -0
  52. package/plugins/clinepass/plugin.js +19 -3
  53. package/plugins/codebuff/icon-color.svg +92 -0
  54. package/plugins/coderabbit/plugin.js +25 -0
  55. package/plugins/coderabbit/plugin.json +12 -0
  56. package/plugins/codex/plugin.js +15 -8
  57. package/plugins/codex/plugin.json +11 -2
  58. package/plugins/command-code/icon-color.svg +3 -0
  59. package/plugins/command-code/plugin.js +7 -3
  60. package/plugins/copilot/icon.svg +1 -1
  61. package/plugins/copilot/plugin.json +1 -0
  62. package/plugins/cosmic/LICENSE +21 -0
  63. package/plugins/cosmic/icon.svg +1 -0
  64. package/plugins/cosmic/plugin.js +134 -0
  65. package/plugins/cosmic/plugin.json +32 -0
  66. package/plugins/crof/icon-color.svg +3 -0
  67. package/plugins/crofai/icon-color.svg +3 -0
  68. package/plugins/crofai/icon.svg +2 -15
  69. package/plugins/cursor/icon-color.svg +1 -0
  70. package/plugins/cursor/plugin.js +51 -14
  71. package/plugins/cursor-nightly/plugin.json +1 -1
  72. package/plugins/deepinfra/icon-color.svg +1 -0
  73. package/plugins/deepinfra/icon.svg +1 -4
  74. package/plugins/deepseek/plugin.js +150 -59
  75. package/plugins/deepseek/plugin.json +3 -1
  76. package/plugins/devin/plugin.js +3 -0
  77. package/plugins/devpass/LICENSE +21 -0
  78. package/plugins/devpass/icon.svg +3 -0
  79. package/plugins/devpass/plugin.js +120 -0
  80. package/plugins/devpass/plugin.json +24 -0
  81. package/plugins/elevenlabs/icon-color.svg +4 -0
  82. package/plugins/exa/LICENSE +21 -0
  83. package/plugins/exa/icon-color.svg +1 -0
  84. package/plugins/exa/icon.svg +1 -0
  85. package/plugins/exa/plugin.js +75 -0
  86. package/plugins/exa/plugin.json +32 -0
  87. package/plugins/factory/icon-color.svg +1 -0
  88. package/plugins/fal/LICENSE +21 -0
  89. package/plugins/fal/icon-color.svg +1 -0
  90. package/plugins/fal/icon.svg +1 -0
  91. package/plugins/fal/plugin.js +74 -0
  92. package/plugins/fal/plugin.json +24 -0
  93. package/plugins/fireworks-ai/icon-color.svg +1 -0
  94. package/plugins/fireworks-ai/icon.svg +1 -6
  95. package/plugins/flora/LICENSE +21 -0
  96. package/plugins/flora/icon.svg +4 -0
  97. package/plugins/flora/plugin.js +93 -0
  98. package/plugins/flora/plugin.json +32 -0
  99. package/plugins/futureagi/LICENSE +21 -0
  100. package/plugins/futureagi/icon.svg +24 -0
  101. package/plugins/futureagi/plugin.js +139 -0
  102. package/plugins/futureagi/plugin.json +32 -0
  103. package/plugins/gemini-apps/LICENSE +21 -0
  104. package/plugins/gemini-apps/icon-color.svg +1 -0
  105. package/plugins/gemini-apps/icon.svg +1 -0
  106. package/plugins/gemini-apps/plugin.js +141 -0
  107. package/plugins/gemini-apps/plugin.json +25 -0
  108. package/plugins/gitkraken/LICENSE +21 -0
  109. package/plugins/gitkraken/icon.svg +2 -0
  110. package/plugins/gitkraken/plugin.js +158 -0
  111. package/plugins/gitkraken/plugin.json +32 -0
  112. package/plugins/googledeveloper/LICENSE +21 -0
  113. package/plugins/googledeveloper/icon.svg +3 -0
  114. package/plugins/googledeveloper/plugin.js +204 -0
  115. package/plugins/googledeveloper/plugin.json +25 -0
  116. package/plugins/grok/icon-color.svg +1 -0
  117. package/plugins/groqcloud/icon-color.svg +1 -0
  118. package/plugins/helmcode/LICENSE +21 -0
  119. package/plugins/helmcode/icon.svg +5 -0
  120. package/plugins/helmcode/plugin.js +253 -0
  121. package/plugins/helmcode/plugin.json +32 -0
  122. package/plugins/huggingface/LICENSE +21 -0
  123. package/plugins/huggingface/icon-color.svg +1 -0
  124. package/plugins/huggingface/icon.svg +1 -0
  125. package/plugins/huggingface/plugin.js +298 -0
  126. package/plugins/huggingface/plugin.json +26 -0
  127. package/plugins/hyper/LICENSE +21 -0
  128. package/plugins/hyper/plugin.js +137 -0
  129. package/plugins/hyper/plugin.json +27 -0
  130. package/plugins/jetbrains-ai-assistant/LICENSE +22 -0
  131. package/plugins/jetbrains-ai-assistant/plugin.js +502 -16
  132. package/plugins/jetbrains-ai-assistant/plugin.json +27 -4
  133. package/plugins/kilo/icon-color.svg +1 -0
  134. package/plugins/kimi/plugin.js +54 -14
  135. package/plugins/kimi/plugin.json +46 -6
  136. package/plugins/langdock/LICENSE +21 -0
  137. package/plugins/langdock/icon.svg +4 -0
  138. package/plugins/langdock/plugin.js +106 -0
  139. package/plugins/langdock/plugin.json +25 -0
  140. package/plugins/linkup/LICENSE +21 -0
  141. package/plugins/linkup/icon.svg +10 -0
  142. package/plugins/linkup/plugin.js +46 -0
  143. package/plugins/linkup/plugin.json +24 -0
  144. package/plugins/litellm/plugin.js +54 -3
  145. package/plugins/lithosai/LICENSE +21 -0
  146. package/plugins/lithosai/icon.svg +1 -0
  147. package/plugins/lithosai/plugin.js +130 -0
  148. package/plugins/lithosai/plugin.json +26 -0
  149. package/plugins/llmman/LICENSE +21 -0
  150. package/plugins/llmman/icon.svg +4 -0
  151. package/plugins/llmman/plugin.js +138 -0
  152. package/plugins/llmman/plugin.json +31 -0
  153. package/plugins/longcat/icon-color.svg +1 -0
  154. package/plugins/longcat/icon.svg +1 -4
  155. package/plugins/manus/icon-color.svg +6 -0
  156. package/plugins/mimo/icon-color.svg +4 -0
  157. package/plugins/mimo/icon.svg +4 -1
  158. package/plugins/mistral/plugin.js +164 -27
  159. package/plugins/moonshot/icon-color.svg +1 -0
  160. package/plugins/munito/LICENSE +21 -0
  161. package/plugins/munito/icon.svg +7 -0
  162. package/plugins/munito/plugin.js +171 -0
  163. package/plugins/munito/plugin.json +24 -0
  164. package/plugins/muse/LICENSE +21 -0
  165. package/plugins/muse/icon.svg +3 -0
  166. package/plugins/muse/plugin.js +288 -0
  167. package/plugins/muse/plugin.json +34 -0
  168. package/plugins/museai/LICENSE +21 -0
  169. package/plugins/museai/icon.svg +3 -0
  170. package/plugins/museai/plugin.js +161 -0
  171. package/plugins/museai/plugin.json +26 -0
  172. package/plugins/nous/LICENSE +21 -0
  173. package/plugins/nous/icon-color.svg +1 -0
  174. package/plugins/nous/icon.svg +1 -0
  175. package/plugins/nous/plugin.js +129 -0
  176. package/plugins/nous/plugin.json +32 -0
  177. package/plugins/ollama/icon-color.svg +1 -0
  178. package/plugins/ollama/plugin.js +58 -0
  179. package/plugins/openai-api/icon-color.svg +1 -0
  180. package/plugins/opencode/icon-color.svg +1 -0
  181. package/plugins/opencode-go/icon-color.svg +1 -0
  182. package/plugins/opencode-go/plugin.js +104 -37
  183. package/plugins/opendesign/LICENSE +21 -0
  184. package/plugins/opendesign/icon.svg +4 -0
  185. package/plugins/opendesign/plugin.js +108 -0
  186. package/plugins/opendesign/plugin.json +25 -0
  187. package/plugins/openrouter/icon-color.svg +1 -0
  188. package/plugins/parallel/LICENSE +21 -0
  189. package/plugins/parallel/icon.svg +11 -0
  190. package/plugins/parallel/plugin.js +97 -0
  191. package/plugins/parallel/plugin.json +25 -0
  192. package/plugins/perplexity/LICENSE +22 -0
  193. package/plugins/perplexity/plugin.js +122 -0
  194. package/plugins/perplexity/plugin.json +36 -7
  195. package/plugins/pi/plugin.js +113 -0
  196. package/plugins/pi/plugin.json +11 -0
  197. package/plugins/qwencloud/LICENSE +21 -0
  198. package/plugins/qwencloud/icon-color.svg +1 -0
  199. package/plugins/qwencloud/icon.svg +1 -4
  200. package/plugins/qwencloud/plugin.js +197 -0
  201. package/plugins/qwencloud/plugin.json +17 -0
  202. package/plugins/raycast/LICENSE +21 -0
  203. package/plugins/raycast/icon.svg +4 -0
  204. package/plugins/raycast/plugin.js +179 -0
  205. package/plugins/raycast/plugin.json +32 -0
  206. package/plugins/replicate/LICENSE +21 -0
  207. package/plugins/replicate/icon-color.svg +1 -0
  208. package/plugins/replicate/icon.svg +1 -0
  209. package/plugins/replicate/plugin.js +170 -0
  210. package/plugins/replicate/plugin.json +25 -0
  211. package/plugins/sailresearch/LICENSE +21 -0
  212. package/plugins/sailresearch/icon.svg +4 -0
  213. package/plugins/sailresearch/plugin.js +104 -0
  214. package/plugins/sailresearch/plugin.json +24 -0
  215. package/plugins/siliconflow/LICENSE +21 -0
  216. package/plugins/siliconflow/icon.svg +3 -0
  217. package/plugins/siliconflow/plugin.js +87 -0
  218. package/plugins/siliconflow/plugin.json +32 -0
  219. package/plugins/sofya/LICENSE +21 -0
  220. package/plugins/sofya/icon.svg +3 -0
  221. package/plugins/sofya/plugin.js +86 -0
  222. package/plugins/sofya/plugin.json +24 -0
  223. package/plugins/soniox/LICENSE +21 -0
  224. package/plugins/soniox/icon.svg +3 -0
  225. package/plugins/soniox/plugin.js +103 -0
  226. package/plugins/soniox/plugin.json +24 -0
  227. package/plugins/synthetic/icon-color.svg +14 -0
  228. package/plugins/synthetic/plugin.js +12 -0
  229. package/plugins/synthetic/plugin.json +51 -9
  230. package/plugins/tavily/LICENSE +21 -0
  231. package/plugins/tavily/icon.svg +3 -0
  232. package/plugins/tavily/plugin.js +61 -0
  233. package/plugins/tavily/plugin.json +24 -0
  234. package/plugins/tinyapi/LICENSE +21 -0
  235. package/plugins/tinyapi/icon.svg +4 -0
  236. package/plugins/tinyapi/plugin.js +73 -0
  237. package/plugins/tinyapi/plugin.json +25 -0
  238. package/plugins/traecn/LICENSE +21 -0
  239. package/plugins/traecn/icon.svg +3 -0
  240. package/plugins/traecn/plugin.js +103 -0
  241. package/plugins/traecn/plugin.json +25 -0
  242. package/plugins/tripo/LICENSE +21 -0
  243. package/plugins/tripo/icon.svg +4 -0
  244. package/plugins/tripo/plugin.js +60 -0
  245. package/plugins/tripo/plugin.json +24 -0
  246. package/plugins/typesafe/LICENSE +21 -0
  247. package/plugins/typesafe/icon.svg +4 -0
  248. package/plugins/typesafe/plugin.js +181 -0
  249. package/plugins/typesafe/plugin.json +25 -0
  250. package/plugins/v0/LICENSE +21 -0
  251. package/plugins/v0/icon-color.svg +1 -0
  252. package/plugins/v0/icon.svg +1 -0
  253. package/plugins/v0/plugin.js +219 -0
  254. package/plugins/v0/plugin.json +32 -0
  255. package/plugins/venice/plugin.js +50 -1
  256. package/plugins/venice/plugin.json +2 -1
  257. package/plugins/vercel/LICENSE +21 -0
  258. package/plugins/vercel/icon-color.svg +1 -0
  259. package/plugins/vercel/icon.svg +1 -0
  260. package/plugins/vercel/plugin.js +202 -0
  261. package/plugins/vercel/plugin.json +54 -0
  262. package/plugins/windsurf/icon-color.svg +1 -0
  263. package/plugins/workbuddy/LICENSE +21 -0
  264. package/plugins/workbuddy/icon.svg +1 -0
  265. package/plugins/workbuddy/plugin.js +318 -0
  266. package/plugins/workbuddy/plugin.json +63 -0
  267. package/plugins/xai/icon-color.svg +1 -0
  268. package/plugins/xai/icon.svg +1 -7
  269. package/plugins/xai/plugin.js +9 -0
  270. package/plugins/xapi/LICENSE +21 -0
  271. package/plugins/xapi/icon.svg +1 -0
  272. package/plugins/xapi/plugin.js +90 -0
  273. package/plugins/xapi/plugin.json +25 -0
  274. package/plugins/xkiro/LICENSE +21 -0
  275. package/plugins/xkiro/icon.svg +1 -0
  276. package/plugins/xkiro/plugin.js +104 -0
  277. package/plugins/xkiro/plugin.json +24 -0
  278. package/plugins/zai/icon-color.svg +1 -0
  279. package/plugins/zai/plugin.js +5 -1
  280. package/plugins/zenmux/icon-color.svg +1 -0
  281. package/plugins/zenmux/icon.svg +1 -3
  282. package/usagestat +0 -0
  283. package/usagestatd +0 -0
  284. package/plugins/cursor-nightly/plugin.js +0 -1416
@@ -10,6 +10,7 @@
10
10
  var FETCH_MODELS_PATH = "/v1internal:fetchAvailableModels"
11
11
  var RETRIEVE_QUOTA_PATH = "/v1internal:retrieveUserQuota"
12
12
  var LOGIN_MESSAGE = "Start Antigravity or run `agy` and try again."
13
+ var QUOTA_DENIED_MESSAGE = "Google denied Antigravity quota access for this account. Open the latest Antigravity or agy client and check account access."
13
14
  var GOOGLE_OAUTH_URL = "https://oauth2.googleapis.com/token"
14
15
  var GOOGLE_CLIENT_ID = "1071006060591-tmhssin2h21lcre235vtolojh4g403ep.apps.googleusercontent.com"
15
16
  var GOOGLE_CLIENT_SECRET = "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"
@@ -155,6 +156,13 @@
155
156
  ctx.host.log.warn("refresh skipped: no refresh token")
156
157
  return null
157
158
  }
159
+ var retryPath = ctx.app.pluginDataDir + "/oauth-retry-" + ctx.host.crypto.sha256Hex(refreshTokenValue) + ".json"
160
+ try {
161
+ if (ctx.host.fs.exists(retryPath)) {
162
+ var rejection = ctx.util.tryParseJson(ctx.host.fs.readText(retryPath))
163
+ if (rejection && rejection.retryAfterMs > Date.now()) return null
164
+ }
165
+ } catch (_) { /* A missing/corrupt cooldown must not prevent login. */ }
158
166
  ctx.host.log.info("attempting Google OAuth token refresh")
159
167
  try {
160
168
  var resp = ctx.host.http.request({
@@ -169,6 +177,12 @@
169
177
  timeoutMs: 15000,
170
178
  })
171
179
  if (resp.status < 200 || resp.status >= 300) {
180
+ var failure = ctx.util.tryParseJson(resp.bodyText)
181
+ if (resp.status === 400 && failure && failure.error === "invalid_grant") {
182
+ // A revoked token will not recover on the next dashboard poll. Store
183
+ // only a deadline under its hash; a new login bypasses this cooldown.
184
+ try { ctx.host.fs.writeText(retryPath, JSON.stringify({ retryAfterMs: Date.now() + 60 * 60 * 1000 })) } catch (_) {}
185
+ }
172
186
  ctx.host.log.warn("Google OAuth refresh returned status: " + resp.status)
173
187
  return null
174
188
  }
@@ -188,22 +202,34 @@
188
202
 
189
203
  // --- Token cache ---
190
204
 
205
+ function tokenCachePath(ctx, profileKey) {
206
+ // Include another hash so the filename remains bounded even on older hosts
207
+ // or test callers with an opaque profile key.
208
+ return ctx.app.pluginDataDir + "/auth-" + ctx.host.crypto.sha256Hex(profileKey) + ".json"
209
+ }
210
+
191
211
  function loadCachedToken(ctx, profileKey) {
192
- var path = ctx.app.pluginDataDir + "/auth.json"
193
- try {
194
- if (!ctx.host.fs.exists(path)) return null
195
- var data = ctx.util.tryParseJson(ctx.host.fs.readText(path))
196
- if (!data || !profileKey || data.profileKey !== profileKey || !data.accessToken || !data.expiresAtMs) return null
197
- if (data.expiresAtMs <= Date.now()) return null
198
- return data.accessToken
199
- } catch (e) {
200
- ctx.host.log.warn("failed to read cached token: " + String(e))
201
- return null
212
+ if (!profileKey) return null
213
+ // Read the old single-slot cache for compatibility, but write only the
214
+ // per-profile file so the IDE and agy cannot evict each other's token.
215
+ var paths = [tokenCachePath(ctx, profileKey), ctx.app.pluginDataDir + "/auth.json"]
216
+ for (var i = 0; i < paths.length; i++) {
217
+ try {
218
+ if (!ctx.host.fs.exists(paths[i])) continue
219
+ var data = ctx.util.tryParseJson(ctx.host.fs.readText(paths[i]))
220
+ if (!data || data.profileKey !== profileKey || !data.accessToken || !data.expiresAtMs) continue
221
+ if (data.expiresAtMs <= Date.now()) continue
222
+ return data.accessToken
223
+ } catch (e) {
224
+ ctx.host.log.warn("failed to read cached token: " + String(e))
225
+ }
202
226
  }
227
+ return null
203
228
  }
204
229
 
205
230
  function cacheToken(ctx, accessToken, expiresInSeconds, profileKey) {
206
- var path = ctx.app.pluginDataDir + "/auth.json"
231
+ if (!profileKey) return
232
+ var path = tokenCachePath(ctx, profileKey)
207
233
  try {
208
234
  ctx.host.fs.writeText(path, JSON.stringify({
209
235
  accessToken: accessToken,
@@ -238,58 +264,126 @@
238
264
  return text || null
239
265
  }
240
266
 
241
- function extractTokenFromObject(obj) {
242
- if (!obj || typeof obj !== "object") return null
267
+ // agy stores {"token":{"access_token","refresh_token","expiry"},"id_token":...}.
268
+ // Search the whole payload for a bearer token before falling back to an ID
269
+ // token: Cloud Code rejects ID tokens, so a top-level id_token must not win.
270
+ var ACCESS_KEYS = ["access_token", "accessToken", "bearerToken", "auth_token", "authToken"]
271
+ var NESTED_KEYS = ["token", "tokens", "oauth", "oauth2", "credentials", "auth"]
243
272
 
244
- var directKeys = [
245
- "access_token",
246
- "accessToken",
247
- "token",
248
- "id_token",
249
- "idToken",
250
- "bearerToken",
251
- "auth_token",
252
- "authToken",
253
- ]
254
- for (var i = 0; i < directKeys.length; i++) {
255
- var value = obj[directKeys[i]]
273
+ function findStringDeep(obj, keys, depth) {
274
+ if (!obj || typeof obj !== "object" || depth > 4) return null
275
+ for (var i = 0; i < keys.length; i++) {
276
+ var value = obj[keys[i]]
256
277
  if (typeof value === "string" && value.trim()) return value.trim()
257
278
  }
258
-
259
- var nestedKeys = ["token", "tokens", "oauth", "oauth2", "credentials", "auth"]
260
- for (var j = 0; j < nestedKeys.length; j++) {
261
- var nested = extractTokenFromObject(obj[nestedKeys[j]])
279
+ for (var j = 0; j < NESTED_KEYS.length; j++) {
280
+ var nested = findStringDeep(obj[NESTED_KEYS[j]], keys, depth + 1)
262
281
  if (nested) return nested
263
282
  }
283
+ return null
284
+ }
264
285
 
286
+ function extractTokenFromObject(obj) {
287
+ if (!obj || typeof obj !== "object") return null
288
+ return findStringDeep(obj, ACCESS_KEYS, 0) || findStringDeep(obj, ["token"], 0) ||
289
+ findStringDeep(obj, ["id_token", "idToken"], 0)
290
+ }
291
+
292
+ function parseExpiryMs(value) {
293
+ if (typeof value === "number" && isFinite(value)) return value < 1e12 ? value * 1000 : value
294
+ if (typeof value === "string" && value.trim()) {
295
+ var ms = Date.parse(value.trim())
296
+ return isFinite(ms) ? ms : null
297
+ }
265
298
  return null
266
299
  }
267
300
 
268
- function extractAgyAccessToken(ctx, raw) {
301
+ // Returns {accessToken, refreshToken, expiryMs} from agy's keyring payload.
302
+ function parseAgyCredentials(ctx, raw) {
269
303
  var text = unwrapAgyKeychainText(ctx, raw)
270
304
  if (!text) return null
271
-
272
305
  var parsed = ctx.util.tryParseJson(text)
273
- if (typeof parsed === "string" && parsed.trim()) return parsed.trim()
274
- if (parsed) return extractTokenFromObject(parsed)
306
+ if (typeof parsed === "string" && parsed.trim()) return { accessToken: parsed.trim(), refreshToken: null, expiryMs: null }
307
+ if (parsed && typeof parsed === "object") {
308
+ var expiry = findStringDeep(parsed, ["expiry", "expires_at", "expiresAt"], 0)
309
+ var numericExpiry = parsed.token && typeof parsed.token === "object" ? parsed.token.expiry_date : null
310
+ return {
311
+ accessToken: extractTokenFromObject(parsed),
312
+ refreshToken: findStringDeep(parsed, ["refresh_token", "refreshToken"], 0),
313
+ expiryMs: parseExpiryMs(expiry) || parseExpiryMs(numericExpiry),
314
+ }
315
+ }
316
+ if (text.indexOf("Bearer ") === 0) return { accessToken: text.slice("Bearer ".length).trim() || null, refreshToken: null, expiryMs: null }
317
+ return { accessToken: text, refreshToken: null, expiryMs: null }
318
+ }
275
319
 
276
- if (text.indexOf("Bearer ") === 0) return text.slice("Bearer ".length).trim() || null
277
- return text
320
+ function extractAgyAccessToken(ctx, raw) {
321
+ var creds = parseAgyCredentials(ctx, raw)
322
+ return creds ? creds.accessToken : null
278
323
  }
279
324
 
280
- function loadAgyKeychainToken(ctx) {
325
+ function loadAgyCredentials(ctx) {
281
326
  if (!ctx.host.keychain || typeof ctx.host.keychain.readGenericPassword !== "function") {
282
327
  return null
283
328
  }
284
329
  try {
285
- var raw = ctx.host.keychain.readGenericPassword(AGY_KEYCHAIN_SERVICE, AGY_KEYCHAIN_ACCOUNT)
286
- return extractAgyAccessToken(ctx, raw)
330
+ return parseAgyCredentials(ctx, ctx.host.keychain.readGenericPassword(AGY_KEYCHAIN_SERVICE, AGY_KEYCHAIN_ACCOUNT))
287
331
  } catch (e) {
288
332
  ctx.host.log.info("agy keychain read failed: " + String(e))
289
333
  return null
290
334
  }
291
335
  }
292
336
 
337
+ function loadAgyKeychainToken(ctx) {
338
+ var creds = loadAgyCredentials(ctx)
339
+ return creds ? creds.accessToken : null
340
+ }
341
+
342
+ // Probe Cloud Code with agy's credentials, refreshing an expired or rejected
343
+ // access token with agy's refresh token (same Google OAuth client).
344
+ function probeAgyCredentials(ctx) {
345
+ var creds = loadAgyCredentials(ctx)
346
+ if (!creds || (!creds.accessToken && !creds.refreshToken)) return null
347
+ var profileKey = creds.refreshToken ? ctx.host.crypto.sha256Hex("agy\n" + creds.refreshToken) : null
348
+ var candidates = []
349
+ var cached = loadCachedToken(ctx, profileKey)
350
+ if (cached) candidates.push(cached)
351
+ var expired = creds.expiryMs != null && creds.expiryMs <= Date.now() + 60000
352
+ if (creds.accessToken && !expired && candidates.indexOf(creds.accessToken) === -1) candidates.push(creds.accessToken)
353
+ var last = null
354
+ for (var i = 0; i < candidates.length; i++) {
355
+ var result = probeAgyToken(ctx, candidates[i])
356
+ if (result && !result._authFailed) return result
357
+ if (result) last = result
358
+ }
359
+ if (creds.refreshToken && (last || !candidates.length)) {
360
+ var refreshed = refreshAccessToken(ctx, creds.refreshToken, profileKey)
361
+ if (refreshed) {
362
+ var refreshedResult = probeAgyToken(ctx, refreshed)
363
+ if (refreshedResult) return refreshedResult
364
+ }
365
+ }
366
+ return last
367
+ }
368
+
369
+ // Consumer agy accounts have no Cloud project, so retrieveUserQuota answers
370
+ // 403 "no valid license" even with a valid token. fetchAvailableModels still
371
+ // reports per-model quota, so use it before treating the token as rejected.
372
+ function probeAgyToken(ctx, token) {
373
+ var quota = probeAgyCloudCode(ctx, token)
374
+ if (quota && !quota._authFailed && !quota._quotaDenied) return quota
375
+ var models = probeCloudCode(ctx, token, "agy", true)
376
+ if (models && !models._authFailed && !models._quotaDenied) {
377
+ if (models._summaryLines) return { plan: null, lines: models._summaryLines }
378
+ var lines = buildModelLines(ctx, parseCloudCodeModels(models))
379
+ if (lines.length > 0) return { plan: null, lines: lines }
380
+ return quota && quota._quotaDenied ? quota : null
381
+ }
382
+ // A quota 403 can mean "no license", not an invalid bearer. If the model
383
+ // endpoint is temporarily unavailable, don't turn that into a token refresh.
384
+ return models || (quota && quota._quotaDenied ? quota : null)
385
+ }
386
+
293
387
  // --- LS discovery ---
294
388
 
295
389
  function discoverNative(ctx, options) {
@@ -355,7 +449,7 @@
355
449
  return null
356
450
  }
357
451
 
358
- function callLs(ctx, port, scheme, csrf, method, body) {
452
+ function callLs(ctx, port, scheme, csrf, method, body, timeoutMs) {
359
453
  var resp = ctx.host.http.request({
360
454
  method: "POST",
361
455
  url: scheme + "://127.0.0.1:" + port + "/" + LS_SERVICE + "/" + method,
@@ -365,7 +459,7 @@
365
459
  "x-codeium-csrf-token": csrf,
366
460
  },
367
461
  bodyText: JSON.stringify(body || {}),
368
- timeoutMs: 10000,
462
+ timeoutMs: timeoutMs || 10000,
369
463
  dangerouslyIgnoreTls: scheme === "https",
370
464
  })
371
465
  if (resp.status < 200 || resp.status >= 300) {
@@ -384,8 +478,10 @@
384
478
 
385
479
  function poolLabel(normalizedLabel) {
386
480
  var lower = normalizedLabel.toLowerCase()
481
+ if (lower.indexOf('argon') !== -1) return null
387
482
  if (lower.indexOf("gemini") !== -1 && lower.indexOf("pro") !== -1) return "Gemini Pro"
388
483
  if (lower.indexOf("gemini") !== -1 && lower.indexOf("flash") !== -1) return "Gemini Flash"
484
+ if (lower.indexOf('gemini') !== -1) return null
389
485
  // All non-Gemini models (Claude, GPT-OSS, etc.) share a single quota pool
390
486
  return "Claude"
391
487
  }
@@ -422,9 +518,11 @@
422
518
  var label = (typeof c.label === "string") ? c.label.trim() : ""
423
519
  if (!label) continue
424
520
  var qi = c.quotaInfo
425
- var frac = (qi && typeof qi.remainingFraction === "number") ? qi.remainingFraction : 0
521
+ if (!qi || !Number.isFinite(qi.remainingFraction)) continue
522
+ var frac = qi.remainingFraction
426
523
  var rtime = (qi && qi.resetTime) || undefined
427
524
  var pool = poolLabel(normalizeLabel(label))
525
+ if (!pool) continue
428
526
  if (!deduped[pool] || frac < deduped[pool].remainingFraction) {
429
527
  deduped[pool] = {
430
528
  label: pool,
@@ -455,7 +553,9 @@
455
553
 
456
554
  // --- Cloud Code API ---
457
555
 
458
- function requestCloudCodeJson(ctx, path, token, userAgent, body) {
556
+ function requestCloudCodeJson(ctx, path, token, userAgent, body, timeoutMs) {
557
+ var summaries = path === '/v1internal:retrieveUserQuotaSummary' ? [] : null
558
+ var denial = null
459
559
  for (var i = 0; i < CLOUD_CODE_URLS.length; i++) {
460
560
  try {
461
561
  var resp = ctx.host.http.request({
@@ -465,32 +565,42 @@
465
565
  Accept: "application/json",
466
566
  "Content-Type": "application/json",
467
567
  Authorization: "Bearer " + token,
468
- "User-Agent": userAgent || "antigravity",
568
+ "User-Agent": ctx.util.antigravityHubUserAgent(),
469
569
  },
470
570
  bodyText: JSON.stringify(body || {}),
471
- timeoutMs: 15000,
571
+ timeoutMs: timeoutMs || 15000,
472
572
  })
473
573
  if (!resp || typeof resp.status !== "number" || !Number.isFinite(resp.status)) {
474
574
  ctx.host.log.warn("Cloud Code returned invalid response shape (" + CLOUD_CODE_URLS[i] + ")")
475
575
  continue
476
576
  }
477
- if (ctx.util.isAuthStatus(resp.status)) return { _authFailed: true }
577
+ if (resp.status === 401 || resp.status === 403) {
578
+ denial = resp.status === 401 ? { _authFailed:true } : { _quotaDenied:true }
579
+ if (!summaries) return denial
580
+ continue
581
+ }
478
582
  if (resp.status >= 200 && resp.status < 300) {
479
583
  var json = ctx.util.tryParseJson(resp.bodyText)
480
584
  if (!json || typeof json !== "object") {
481
585
  ctx.host.log.warn("Cloud Code returned invalid JSON (" + CLOUD_CODE_URLS[i] + ")")
482
586
  continue
483
587
  }
588
+ if (summaries) {summaries.push(json);continue}
484
589
  return json
485
590
  }
486
591
  } catch (e) {
487
592
  ctx.host.log.warn("Cloud Code request failed (" + CLOUD_CODE_URLS[i] + "): " + String(e))
488
593
  }
489
594
  }
490
- return null
595
+ return summaries && summaries.length ? summaries : denial
491
596
  }
492
597
 
493
- function probeCloudCode(ctx, token, userAgent) {
598
+ function probeCloudCode(ctx, token, userAgent, skipSummary) {
599
+ if (!skipSummary) {
600
+ var summary = requestCloudCodeJson(ctx, "/v1internal:retrieveUserQuotaSummary", token, userAgent, {}, 2000)
601
+ var lines = ctx.util.groupedQuotaLines(summary)
602
+ if (lines !== null) return { _summaryLines: lines }
603
+ }
494
604
  return requestCloudCodeJson(ctx, FETCH_MODELS_PATH, token, userAgent, {})
495
605
  }
496
606
 
@@ -511,7 +621,8 @@
511
621
  ""
512
622
  if (!displayName) continue
513
623
  var qi = m.quotaInfo
514
- var frac = (qi && typeof qi.remainingFraction === "number") ? qi.remainingFraction : 0
624
+ if (!qi || !Number.isFinite(qi.remainingFraction)) continue
625
+ var frac = qi.remainingFraction
515
626
  var rtime = (qi && qi.resetTime) || undefined
516
627
  configs.push({
517
628
  label: displayName,
@@ -542,7 +653,8 @@
542
653
  if (!bucket || typeof bucket !== "object") continue
543
654
  var modelId = (typeof bucket.modelId === "string" && bucket.modelId.trim()) || ""
544
655
  if (!modelId) continue
545
- var frac = (typeof bucket.remainingFraction === "number") ? bucket.remainingFraction : 0
656
+ if (!Number.isFinite(bucket.remainingFraction)) continue
657
+ var frac = bucket.remainingFraction
546
658
  configs.push({
547
659
  label: modelId,
548
660
  quotaInfo: { remainingFraction: frac, resetTime: bucket.resetTime || undefined },
@@ -553,20 +665,23 @@
553
665
 
554
666
  function probeAgyCloudCode(ctx, token) {
555
667
  var loadData = requestCloudCodeJson(ctx, LOAD_CODE_ASSIST_PATH, token, "agy", {})
556
- if (!loadData || loadData._authFailed) return loadData
668
+ if (!loadData || loadData._authFailed || loadData._quotaDenied) return loadData
557
669
 
558
670
  var project =
559
671
  typeof loadData.cloudaicompanionProject === "string" && loadData.cloudaicompanionProject.trim()
560
672
  ? loadData.cloudaicompanionProject.trim()
561
673
  : null
562
674
  var quotaData = null
675
+ var summary = requestCloudCodeJson(ctx, "/v1internal:retrieveUserQuotaSummary", token, "agy", project ? { project: project } : {}, 2000)
676
+ var summaryLines = ctx.util.groupedQuotaLines(summary)
677
+ if (summaryLines !== null) return { plan: readAgyPlan(loadData), lines: summaryLines }
563
678
  if (project) {
564
679
  quotaData = requestCloudCodeJson(ctx, RETRIEVE_QUOTA_PATH, token, "agy", { project: project })
565
680
  }
566
- if (!quotaData || quotaData._authFailed) {
681
+ if (!quotaData || quotaData._authFailed || quotaData._quotaDenied) {
567
682
  quotaData = requestCloudCodeJson(ctx, RETRIEVE_QUOTA_PATH, token, "agy", {})
568
683
  }
569
- if (!quotaData || quotaData._authFailed) return quotaData
684
+ if (!quotaData || quotaData._authFailed || quotaData._quotaDenied) return quotaData || (summary && summary._quotaDenied ? summary : null)
570
685
 
571
686
  var lines = buildModelLines(ctx, parseAgyQuotaBuckets(quotaData))
572
687
  if (lines.length === 0) return null
@@ -590,7 +705,13 @@
590
705
  locale: "en",
591
706
  }
592
707
 
593
- // Try GetUserStatus first, fall back to GetCommandModelConfigs
708
+ var summaryLines = null
709
+ try {
710
+ summaryLines = ctx.util.groupedQuotaLines(callLs(ctx, found.port, found.scheme, discovery.csrf,
711
+ "RetrieveUserQuotaSummary", { forceRefresh: true }, 2000))
712
+ } catch (_) {}
713
+
714
+ // GetUserStatus also supplies identity when grouped quota is available.
594
715
  var data = null
595
716
  try {
596
717
  data = callLs(ctx, found.port, found.scheme, discovery.csrf, "GetUserStatus", { metadata: metadata })
@@ -599,7 +720,7 @@
599
720
  }
600
721
  var hasUserStatus = data && data.userStatus
601
722
 
602
- if (!hasUserStatus) {
723
+ if (!hasUserStatus && summaryLines === null) {
603
724
  ctx.host.log.warn("GetUserStatus failed, trying GetCommandModelConfigs")
604
725
  data = callLs(ctx, found.port, found.scheme, discovery.csrf, "GetCommandModelConfigs", { metadata: metadata })
605
726
  }
@@ -610,6 +731,8 @@
610
731
  configs = (data.userStatus.cascadeModelConfigData || {}).clientModelConfigs || []
611
732
  } else if (data && data.clientModelConfigs) {
612
733
  configs = data.clientModelConfigs
734
+ } else if (summaryLines !== null) {
735
+ configs = []
613
736
  } else {
614
737
  return null
615
738
  }
@@ -621,8 +744,8 @@
621
744
  filtered.push(configs[j])
622
745
  }
623
746
 
624
- var lines = buildModelLines(ctx, filtered)
625
- if (lines.length === 0) return null
747
+ var lines = summaryLines !== null ? summaryLines : buildModelLines(ctx, filtered)
748
+ if (lines.length === 0 && summaryLines === null) return null
626
749
 
627
750
  var plan = null
628
751
  if (hasUserStatus) {
@@ -682,7 +805,7 @@
682
805
 
683
806
  var profileKey = dbTokenCandidates.length ? dbTokenCandidates[0].profileKey : null
684
807
  var cached = loadCachedToken(ctx, profileKey)
685
- if (cached && tokens.indexOf(cached) === -1) tokens.push(cached)
808
+ if (cached && tokens.indexOf(cached) === -1) tokens.unshift(cached)
686
809
 
687
810
  var ccData = null
688
811
  var sawAuthFailure = false
@@ -717,21 +840,22 @@
717
840
  }
718
841
  }
719
842
 
720
- if (!dbTokenCandidates.length && (!ccData || ccData._authFailed)) {
721
- var agyToken = loadAgyKeychainToken(ctx)
722
- if (agyToken) {
723
- var agyResult = probeAgyCloudCode(ctx, agyToken)
724
- if (agyResult && !agyResult._authFailed) return agyResult
725
- if (agyResult && agyResult._authFailed) ccData = agyResult
726
- }
843
+ // agy's own login also covers users whose IDE database is stale or absent.
844
+ if (!explicitDb && (!ccData || ccData._authFailed || ccData._quotaDenied)) {
845
+ var agyResult = probeAgyCredentials(ctx)
846
+ if (agyResult && !agyResult._authFailed && !agyResult._quotaDenied) return agyResult
847
+ if (agyResult && agyResult._quotaDenied) ccData = agyResult
848
+ if (agyResult && agyResult._authFailed) ccData = agyResult
727
849
  }
728
850
 
729
- if (ccData && !ccData._authFailed) {
851
+ if (ccData && !ccData._authFailed && !ccData._quotaDenied) {
852
+ if (ccData._summaryLines) return { plan: null, lines: ccData._summaryLines }
730
853
  var configs = parseCloudCodeModels(ccData)
731
854
  var lines = buildModelLines(ctx, configs)
732
855
  if (lines.length > 0) return { plan: null, lines: lines }
733
856
  }
734
857
 
858
+ if (ccData && ccData._quotaDenied) throw QUOTA_DENIED_MESSAGE
735
859
  throw LOGIN_MESSAGE
736
860
  }
737
861
 
@@ -0,0 +1 @@
1
+ <svg height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>Antigravity</title><mask height="23" id="lobe-icons-antigravity-0-_R_0_" maskUnits="userSpaceOnUse" width="24" x="0" y="1"><path d="M21.751 22.607c1.34 1.005 3.35.335 1.508-1.508C17.73 15.74 18.904 1 12.037 1 5.17 1 6.342 15.74.815 21.1c-2.01 2.009.167 2.511 1.507 1.506 5.192-3.517 4.857-9.714 9.715-9.714 4.857 0 4.522 6.197 9.714 9.715z" fill="#fff"></path></mask><g mask="url(#lobe-icons-antigravity-0-_R_0_)"><g filter="url(#lobe-icons-antigravity-1-_R_0_)"><path d="M-1.018-3.992c-.408 3.591 2.686 6.89 6.91 7.37 4.225.48 7.98-2.043 8.387-5.633.408-3.59-2.686-6.89-6.91-7.37-4.225-.479-7.98 2.043-8.387 5.633z" fill="#FFE432"></path></g><g filter="url(#lobe-icons-antigravity-2-_R_0_)"><path d="M15.269 7.747c1.058 4.557 5.691 7.374 10.348 6.293 4.657-1.082 7.575-5.653 6.516-10.21-1.058-4.556-5.691-7.374-10.348-6.292-4.657 1.082-7.575 5.653-6.516 10.21z" fill="#FC413D"></path></g><g filter="url(#lobe-icons-antigravity-3-_R_0_)"><path d="M-12.443 10.804c1.338 4.703 7.36 7.11 13.453 5.378 6.092-1.733 9.947-6.95 8.61-11.652C8.282-.173 2.26-2.58-3.833-.848-9.925.884-13.78 6.1-12.443 10.804z" fill="#00B95C"></path></g><g filter="url(#lobe-icons-antigravity-4-_R_0_)"><path d="M-12.443 10.804c1.338 4.703 7.36 7.11 13.453 5.378 6.092-1.733 9.947-6.95 8.61-11.652C8.282-.173 2.26-2.58-3.833-.848-9.925.884-13.78 6.1-12.443 10.804z" fill="#00B95C"></path></g><g filter="url(#lobe-icons-antigravity-5-_R_0_)"><path d="M-7.608 14.703c3.352 3.424 9.126 3.208 12.896-.483 3.77-3.69 4.108-9.459.756-12.883C2.69-2.087-3.083-1.871-6.853 1.82c-3.77 3.69-4.108 9.458-.755 12.883z" fill="#00B95C"></path></g><g filter="url(#lobe-icons-antigravity-6-_R_0_)"><path d="M9.932 27.617c1.04 4.482 5.384 7.303 9.7 6.3 4.316-1.002 6.971-5.448 5.93-9.93-1.04-4.483-5.384-7.304-9.7-6.301-4.316 1.002-6.971 5.448-5.93 9.93z" fill="#3186FF"></path></g><g filter="url(#lobe-icons-antigravity-7-_R_0_)"><path d="M2.572-8.185C.392-3.329 2.778 2.472 7.9 4.771c5.122 2.3 11.042.227 13.222-4.63 2.18-4.855-.205-10.656-5.327-12.955-5.122-2.3-11.042-.227-13.222 4.63z" fill="#FBBC04"></path></g><g filter="url(#lobe-icons-antigravity-8-_R_0_)"><path d="M-3.267 38.686c-5.277-2.072 3.742-19.117 5.984-24.83 2.243-5.712 8.34-8.664 13.616-6.592 5.278 2.071 11.533 13.482 9.29 19.195-2.242 5.713-23.613 14.298-28.89 12.227z" fill="#3186FF"></path></g><g filter="url(#lobe-icons-antigravity-9-_R_0_)"><path d="M28.71 17.471c-1.413 1.649-5.1.808-8.236-1.878-3.135-2.687-4.531-6.201-3.118-7.85 1.412-1.649 5.1-.808 8.235 1.878s4.532 6.2 3.119 7.85z" fill="#749BFF"></path></g><g filter="url(#lobe-icons-antigravity-10-_R_0_)"><path d="M18.163 9.077c5.81 3.93 12.502 4.19 14.946.577 2.443-3.612-.287-9.727-6.098-13.658-5.81-3.931-12.502-4.19-14.946-.577-2.443 3.612.287 9.727 6.098 13.658z" fill="#FC413D"></path></g><g filter="url(#lobe-icons-antigravity-11-_R_0_)"><path d="M-.915 2.684c-1.44 3.473-.97 6.967 1.05 7.804 2.02.837 4.824-1.3 6.264-4.772 1.44-3.473.97-6.967-1.05-7.804-2.02-.837-4.824 1.3-6.264 4.772z" fill="#FFEE48"></path></g></g><defs><filter color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse" height="17.587" id="lobe-icons-antigravity-1-_R_0_" width="19.838" x="-3.288" y="-11.917"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"></feBlend><feGaussianBlur result="effect1_foregroundBlur_977_115" stdDeviation="1.117"></feGaussianBlur></filter><filter color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse" height="38.565" id="lobe-icons-antigravity-2-_R_0_" width="38.9" x="4.251" y="-13.493"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"></feBlend><feGaussianBlur result="effect1_foregroundBlur_977_115" stdDeviation="5.4"></feGaussianBlur></filter><filter color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse" height="36.517" id="lobe-icons-antigravity-3-_R_0_" width="40.955" x="-21.889" y="-10.592"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"></feBlend><feGaussianBlur result="effect1_foregroundBlur_977_115" stdDeviation="4.591"></feGaussianBlur></filter><filter color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse" height="36.517" id="lobe-icons-antigravity-4-_R_0_" width="40.955" x="-21.889" y="-10.592"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"></feBlend><feGaussianBlur result="effect1_foregroundBlur_977_115" stdDeviation="4.591"></feGaussianBlur></filter><filter color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse" height="36.595" id="lobe-icons-antigravity-5-_R_0_" width="36.632" x="-19.099" y="-10.278"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"></feBlend><feGaussianBlur result="effect1_foregroundBlur_977_115" stdDeviation="4.591"></feGaussianBlur></filter><filter color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse" height="34.087" id="lobe-icons-antigravity-6-_R_0_" width="33.533" x=".981" y="8.758"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"></feBlend><feGaussianBlur result="effect1_foregroundBlur_977_115" stdDeviation="4.363"></feGaussianBlur></filter><filter color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse" height="35.276" id="lobe-icons-antigravity-7-_R_0_" width="35.978" x="-6.143" y="-21.659"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"></feBlend><feGaussianBlur result="effect1_foregroundBlur_977_115" stdDeviation="3.954"></feGaussianBlur></filter><filter color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse" height="46.523" id="lobe-icons-antigravity-8-_R_0_" width="45.114" x="-11.96" y="-.46"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"></feBlend><feGaussianBlur result="effect1_foregroundBlur_977_115" stdDeviation="3.531"></feGaussianBlur></filter><filter color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse" height="24.054" id="lobe-icons-antigravity-9-_R_0_" width="25.094" x="10.485" y=".58"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"></feBlend><feGaussianBlur result="effect1_foregroundBlur_977_115" stdDeviation="3.159"></feGaussianBlur></filter><filter color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse" height="30.007" id="lobe-icons-antigravity-10-_R_0_" width="33.508" x="5.833" y="-12.467"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"></feBlend><feGaussianBlur result="effect1_foregroundBlur_977_115" stdDeviation="2.669"></feGaussianBlur></filter><filter color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse" height="26.151" id="lobe-icons-antigravity-11-_R_0_" width="22.194" x="-8.355" y="-8.876"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"></feBlend><feGaussianBlur result="effect1_foregroundBlur_977_115" stdDeviation="3.303"></feGaussianBlur></filter></defs></svg>
@@ -1,3 +1 @@
1
- <svg width="100" height="100" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">
2
- <path d="M85.2843 88.0301C90.1329 91.6664 97.4057 89.2422 90.7389 82.5755C70.7389 63.1816 74.9813 9.84827 50.1329 9.84827C25.2843 9.84827 29.5267 63.1816 9.52673 82.5755C2.25402 89.8483 10.1328 91.6664 14.9813 88.0301C33.7692 75.3028 32.5571 52.8786 50.1329 52.8786C67.7086 52.8786 66.4965 75.3028 85.2843 88.0301Z" fill="currentColor"/>
3
- </svg>
1
+ <svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>Antigravity</title><path d="M21.751 22.607c1.34 1.005 3.35.335 1.508-1.508C17.73 15.74 18.904 1 12.037 1 5.17 1 6.342 15.74.815 21.1c-2.01 2.009.167 2.511 1.507 1.506 5.192-3.517 4.857-9.714 9.715-9.714 4.857 0 4.522 6.197 9.714 9.715z"></path></svg>
@@ -7,6 +7,7 @@
7
7
  const SESSION_EXPIRED_MESSAGE =
8
8
  "Google sign-in expired. Run `agy` and complete Google sign-in again."
9
9
  const REQUEST_FAILED_MESSAGE = "Antigravity CLI quota request failed. Check your connection and try again."
10
+ const QUOTA_DENIED_MESSAGE = "Google denied Antigravity quota access for this account. Open the latest Antigravity or agy client and check account access."
10
11
  const GOOGLE_OAUTH_URL = "https://oauth2.googleapis.com/token"
11
12
  const GOOGLE_CLIENT_ID =
12
13
  "1071006060591-tmhssin2h21lcre235vtolojh4g403ep.apps.googleusercontent.com"
@@ -67,27 +68,23 @@
67
68
  function extractTokenFromObject(obj) {
68
69
  if (!obj || typeof obj !== "object") return null
69
70
 
70
- var directKeys = [
71
- "access_token",
72
- "accessToken",
73
- "token",
74
- "id_token",
75
- "idToken",
76
- "bearerToken",
77
- "auth_token",
78
- "authToken",
79
- ]
80
- for (var i = 0; i < directKeys.length; i += 1) {
81
- var value = obj[directKeys[i]]
71
+ // Prefer a bearer token anywhere in the payload; an ID token is a last resort
72
+ // (agy stores {"token":{"access_token":...},"id_token":...}).
73
+ return findTokenDeep(obj, ["access_token", "accessToken", "bearerToken", "auth_token", "authToken"], 0) ||
74
+ findTokenDeep(obj, ["token"], 0) || findTokenDeep(obj, ["id_token", "idToken"], 0)
75
+ }
76
+
77
+ function findTokenDeep(obj, keys, depth) {
78
+ if (!obj || typeof obj !== "object" || depth > 4) return null
79
+ for (var i = 0; i < keys.length; i += 1) {
80
+ var value = obj[keys[i]]
82
81
  if (typeof value === "string" && value.trim()) return value.trim()
83
82
  }
84
-
85
83
  var nestedKeys = ["token", "tokens", "oauth", "oauth2", "credentials", "auth"]
86
84
  for (var j = 0; j < nestedKeys.length; j += 1) {
87
- var nested = extractTokenFromObject(obj[nestedKeys[j]])
85
+ var nested = findTokenDeep(obj[nestedKeys[j]], keys, depth + 1)
88
86
  if (nested) return nested
89
87
  }
90
-
91
88
  return null
92
89
  }
93
90
 
@@ -295,10 +292,10 @@
295
292
  Authorization: "Bearer " + token,
296
293
  Accept: "application/json",
297
294
  "Content-Type": "application/json",
298
- "User-Agent": "agy",
295
+ "User-Agent": ctx.util.antigravityHubUserAgent(),
299
296
  },
300
297
  bodyText: JSON.stringify(body || {}),
301
- timeoutMs: 15000,
298
+ timeoutMs: opts.timeoutMs || 15000,
302
299
  })
303
300
  } catch (e) {
304
301
  if (opts.optional) {
@@ -311,7 +308,11 @@
311
308
  if (opts.optional) return null
312
309
  throw REQUEST_FAILED_MESSAGE
313
310
  }
314
- if (ctx.util.isAuthStatus(resp.status)) {
311
+ if (resp.status === 403) {
312
+ if (opts.optional) return null
313
+ throw QUOTA_DENIED_MESSAGE
314
+ }
315
+ if (resp.status === 401) {
315
316
  if (opts.optional) {
316
317
  ctx.host.log.warn(
317
318
  "antigravity-cli optional request HTTP " +
@@ -345,11 +346,15 @@
345
346
 
346
347
  function requestJsonAcrossBases(ctx, path, token, body, options) {
347
348
  var urls = cloudCodeUrls(path)
349
+ var summaries = path === '/v1internal:retrieveUserQuotaSummary' ? [] : null
348
350
  for (var i = 0; i < urls.length; i += 1) {
349
351
  var data = requestJson(ctx, urls[i], token, body, options)
350
- if (data) return data
352
+ if (data) {
353
+ if (summaries) summaries.push(data)
354
+ else return data
355
+ }
351
356
  }
352
- return null
357
+ return summaries && summaries.length ? summaries : null
353
358
  }
354
359
 
355
360
  function makeAuthRetry(ctx, authState) {
@@ -424,6 +429,7 @@
424
429
 
425
430
  function poolForText(text) {
426
431
  var lower = String(text || "").toLowerCase()
432
+ if (lower.indexOf('argon') !== -1) return null
427
433
  if (lower.indexOf("gemini") !== -1 && lower.indexOf("pro") !== -1) return "Gemini Pro"
428
434
  if (lower.indexOf("gemini") !== -1 && lower.indexOf("flash") !== -1) return "Gemini Flash"
429
435
  if (lower.indexOf("gemini") !== -1) return null
@@ -544,6 +550,12 @@
544
550
  if (!loadData) throw REQUEST_FAILED_MESSAGE
545
551
  var plan = readPlan(loadData)
546
552
 
553
+ var project = typeof loadData.cloudaicompanionProject === "string" ? loadData.cloudaicompanionProject.trim() : ""
554
+ var summary = requestJsonAcrossBases(ctx, "/v1internal:retrieveUserQuotaSummary", authState.token,
555
+ project ? { project: project } : {}, { optional: true, timeoutMs: 2000 })
556
+ var summaryLines = ctx.util.groupedQuotaLines(summary)
557
+ if (summaryLines !== null) return { plan: plan || undefined, lines: summaryLines }
558
+
547
559
  var buckets = []
548
560
  // fetchAvailableModels rejects `metadata` in the body (HTTP 400); use {} like Antigravity IDE.
549
561
  var fetchData = requestJsonAcrossBases(ctx, FETCH_MODELS_PATH, authState.token, {}, {
@@ -0,0 +1 @@
1
+ <svg height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>Antigravity</title><mask height="23" id="lobe-icons-antigravity-0-_R_0_" maskUnits="userSpaceOnUse" width="24" x="0" y="1"><path d="M21.751 22.607c1.34 1.005 3.35.335 1.508-1.508C17.73 15.74 18.904 1 12.037 1 5.17 1 6.342 15.74.815 21.1c-2.01 2.009.167 2.511 1.507 1.506 5.192-3.517 4.857-9.714 9.715-9.714 4.857 0 4.522 6.197 9.714 9.715z" fill="#fff"></path></mask><g mask="url(#lobe-icons-antigravity-0-_R_0_)"><g filter="url(#lobe-icons-antigravity-1-_R_0_)"><path d="M-1.018-3.992c-.408 3.591 2.686 6.89 6.91 7.37 4.225.48 7.98-2.043 8.387-5.633.408-3.59-2.686-6.89-6.91-7.37-4.225-.479-7.98 2.043-8.387 5.633z" fill="#FFE432"></path></g><g filter="url(#lobe-icons-antigravity-2-_R_0_)"><path d="M15.269 7.747c1.058 4.557 5.691 7.374 10.348 6.293 4.657-1.082 7.575-5.653 6.516-10.21-1.058-4.556-5.691-7.374-10.348-6.292-4.657 1.082-7.575 5.653-6.516 10.21z" fill="#FC413D"></path></g><g filter="url(#lobe-icons-antigravity-3-_R_0_)"><path d="M-12.443 10.804c1.338 4.703 7.36 7.11 13.453 5.378 6.092-1.733 9.947-6.95 8.61-11.652C8.282-.173 2.26-2.58-3.833-.848-9.925.884-13.78 6.1-12.443 10.804z" fill="#00B95C"></path></g><g filter="url(#lobe-icons-antigravity-4-_R_0_)"><path d="M-12.443 10.804c1.338 4.703 7.36 7.11 13.453 5.378 6.092-1.733 9.947-6.95 8.61-11.652C8.282-.173 2.26-2.58-3.833-.848-9.925.884-13.78 6.1-12.443 10.804z" fill="#00B95C"></path></g><g filter="url(#lobe-icons-antigravity-5-_R_0_)"><path d="M-7.608 14.703c3.352 3.424 9.126 3.208 12.896-.483 3.77-3.69 4.108-9.459.756-12.883C2.69-2.087-3.083-1.871-6.853 1.82c-3.77 3.69-4.108 9.458-.755 12.883z" fill="#00B95C"></path></g><g filter="url(#lobe-icons-antigravity-6-_R_0_)"><path d="M9.932 27.617c1.04 4.482 5.384 7.303 9.7 6.3 4.316-1.002 6.971-5.448 5.93-9.93-1.04-4.483-5.384-7.304-9.7-6.301-4.316 1.002-6.971 5.448-5.93 9.93z" fill="#3186FF"></path></g><g filter="url(#lobe-icons-antigravity-7-_R_0_)"><path d="M2.572-8.185C.392-3.329 2.778 2.472 7.9 4.771c5.122 2.3 11.042.227 13.222-4.63 2.18-4.855-.205-10.656-5.327-12.955-5.122-2.3-11.042-.227-13.222 4.63z" fill="#FBBC04"></path></g><g filter="url(#lobe-icons-antigravity-8-_R_0_)"><path d="M-3.267 38.686c-5.277-2.072 3.742-19.117 5.984-24.83 2.243-5.712 8.34-8.664 13.616-6.592 5.278 2.071 11.533 13.482 9.29 19.195-2.242 5.713-23.613 14.298-28.89 12.227z" fill="#3186FF"></path></g><g filter="url(#lobe-icons-antigravity-9-_R_0_)"><path d="M28.71 17.471c-1.413 1.649-5.1.808-8.236-1.878-3.135-2.687-4.531-6.201-3.118-7.85 1.412-1.649 5.1-.808 8.235 1.878s4.532 6.2 3.119 7.85z" fill="#749BFF"></path></g><g filter="url(#lobe-icons-antigravity-10-_R_0_)"><path d="M18.163 9.077c5.81 3.93 12.502 4.19 14.946.577 2.443-3.612-.287-9.727-6.098-13.658-5.81-3.931-12.502-4.19-14.946-.577-2.443 3.612.287 9.727 6.098 13.658z" fill="#FC413D"></path></g><g filter="url(#lobe-icons-antigravity-11-_R_0_)"><path d="M-.915 2.684c-1.44 3.473-.97 6.967 1.05 7.804 2.02.837 4.824-1.3 6.264-4.772 1.44-3.473.97-6.967-1.05-7.804-2.02-.837-4.824 1.3-6.264 4.772z" fill="#FFEE48"></path></g></g><defs><filter color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse" height="17.587" id="lobe-icons-antigravity-1-_R_0_" width="19.838" x="-3.288" y="-11.917"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"></feBlend><feGaussianBlur result="effect1_foregroundBlur_977_115" stdDeviation="1.117"></feGaussianBlur></filter><filter color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse" height="38.565" id="lobe-icons-antigravity-2-_R_0_" width="38.9" x="4.251" y="-13.493"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"></feBlend><feGaussianBlur result="effect1_foregroundBlur_977_115" stdDeviation="5.4"></feGaussianBlur></filter><filter color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse" height="36.517" id="lobe-icons-antigravity-3-_R_0_" width="40.955" x="-21.889" y="-10.592"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"></feBlend><feGaussianBlur result="effect1_foregroundBlur_977_115" stdDeviation="4.591"></feGaussianBlur></filter><filter color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse" height="36.517" id="lobe-icons-antigravity-4-_R_0_" width="40.955" x="-21.889" y="-10.592"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"></feBlend><feGaussianBlur result="effect1_foregroundBlur_977_115" stdDeviation="4.591"></feGaussianBlur></filter><filter color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse" height="36.595" id="lobe-icons-antigravity-5-_R_0_" width="36.632" x="-19.099" y="-10.278"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"></feBlend><feGaussianBlur result="effect1_foregroundBlur_977_115" stdDeviation="4.591"></feGaussianBlur></filter><filter color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse" height="34.087" id="lobe-icons-antigravity-6-_R_0_" width="33.533" x=".981" y="8.758"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"></feBlend><feGaussianBlur result="effect1_foregroundBlur_977_115" stdDeviation="4.363"></feGaussianBlur></filter><filter color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse" height="35.276" id="lobe-icons-antigravity-7-_R_0_" width="35.978" x="-6.143" y="-21.659"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"></feBlend><feGaussianBlur result="effect1_foregroundBlur_977_115" stdDeviation="3.954"></feGaussianBlur></filter><filter color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse" height="46.523" id="lobe-icons-antigravity-8-_R_0_" width="45.114" x="-11.96" y="-.46"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"></feBlend><feGaussianBlur result="effect1_foregroundBlur_977_115" stdDeviation="3.531"></feGaussianBlur></filter><filter color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse" height="24.054" id="lobe-icons-antigravity-9-_R_0_" width="25.094" x="10.485" y=".58"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"></feBlend><feGaussianBlur result="effect1_foregroundBlur_977_115" stdDeviation="3.159"></feGaussianBlur></filter><filter color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse" height="30.007" id="lobe-icons-antigravity-10-_R_0_" width="33.508" x="5.833" y="-12.467"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"></feBlend><feGaussianBlur result="effect1_foregroundBlur_977_115" stdDeviation="2.669"></feGaussianBlur></filter><filter color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse" height="26.151" id="lobe-icons-antigravity-11-_R_0_" width="22.194" x="-8.355" y="-8.876"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"></feBlend><feGaussianBlur result="effect1_foregroundBlur_977_115" stdDeviation="3.303"></feGaussianBlur></filter></defs></svg>
@@ -1,3 +1 @@
1
- <svg width="100" height="100" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">
2
- <path d="M85.2843 88.0301C90.1329 91.6664 97.4057 89.2422 90.7389 82.5755C70.7389 63.1816 74.9813 9.84827 50.1329 9.84827C25.2843 9.84827 29.5267 63.1816 9.52673 82.5755C2.25402 89.8483 10.1328 91.6664 14.9813 88.0301C33.7692 75.3028 32.5571 52.8786 50.1329 52.8786C67.7086 52.8786 66.4965 75.3028 85.2843 88.0301Z" fill="currentColor"/>
3
- </svg>
1
+ <svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>Antigravity</title><path d="M21.751 22.607c1.34 1.005 3.35.335 1.508-1.508C17.73 15.74 18.904 1 12.037 1 5.17 1 6.342 15.74.815 21.1c-2.01 2.009.167 2.511 1.507 1.506 5.192-3.517 4.857-9.714 9.715-9.714 4.857 0 4.522 6.197 9.714 9.715z"></path></svg>