@dotobokuri/fleet-console 1.71.1 → 1.72.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/CLAUDE.md +1 -1
  2. package/README.md +13 -0
  3. package/dist/cli.mjs +396 -339
  4. package/dist/client/assets/{_baseUniq-Bhd1wyKE.js → _baseUniq-D_AjNlwO.js} +1 -1
  5. package/dist/client/assets/{arc-Cu9FOmUr.js → arc-DiscagS3.js} +1 -1
  6. package/dist/client/assets/{architectureDiagram-Q4EWVU46-Dq9FA5I3.js → architectureDiagram-Q4EWVU46-PGPwULb9.js} +1 -1
  7. package/dist/client/assets/{blockDiagram-DXYQGD6D-BDZkCLI1.js → blockDiagram-DXYQGD6D-DLexJaxZ.js} +1 -1
  8. package/dist/client/assets/{c4Diagram-AHTNJAMY-XBPYwanu.js → c4Diagram-AHTNJAMY-D9Ye73ny.js} +1 -1
  9. package/dist/client/assets/channel-CR5OWwKU.js +1 -0
  10. package/dist/client/assets/{chunk-4BX2VUAB-BbTQSLs0.js → chunk-4BX2VUAB-B7YgJYL4.js} +1 -1
  11. package/dist/client/assets/{chunk-4TB4RGXK-DukpmkUz.js → chunk-4TB4RGXK-CEEQcTWi.js} +1 -1
  12. package/dist/client/assets/{chunk-55IACEB6-BFyIa1Ge.js → chunk-55IACEB6-B8AcnGT7.js} +1 -1
  13. package/dist/client/assets/{chunk-EDXVE4YY-D7RHsfQm.js → chunk-EDXVE4YY-DjZ88S2h.js} +1 -1
  14. package/dist/client/assets/{chunk-FMBD7UC4-Co64dt-k.js → chunk-FMBD7UC4-io3C2TDz.js} +1 -1
  15. package/dist/client/assets/{chunk-OYMX7WX6-CdycD6Yh.js → chunk-OYMX7WX6-s0DPD-0B.js} +1 -1
  16. package/dist/client/assets/{chunk-QZHKN3VN-CNvTB1xu.js → chunk-QZHKN3VN-DGcrSXIn.js} +1 -1
  17. package/dist/client/assets/{chunk-YZCP3GAM-CY1_pTO2.js → chunk-YZCP3GAM-Dp1DewA_.js} +1 -1
  18. package/dist/client/assets/classDiagram-6PBFFD2Q-BxfrF-vv.js +1 -0
  19. package/dist/client/assets/classDiagram-v2-HSJHXN6E-BxfrF-vv.js +1 -0
  20. package/dist/client/assets/clone-BH8tX1wM.js +1 -0
  21. package/dist/client/assets/{cose-bilkent-S5V4N54A-PLhfHDPQ.js → cose-bilkent-S5V4N54A-D9PZkL8M.js} +1 -1
  22. package/dist/client/assets/{dagre-KV5264BT-gJnGByq0.js → dagre-KV5264BT-M-8Bl0QN.js} +1 -1
  23. package/dist/client/assets/{diagram-5BDNPKRD-y48OdlFp.js → diagram-5BDNPKRD-CbFVI18N.js} +1 -1
  24. package/dist/client/assets/{diagram-G4DWMVQ6-DSLYc2V1.js → diagram-G4DWMVQ6-Bofydoge.js} +1 -1
  25. package/dist/client/assets/{diagram-MMDJMWI5-DWgtcwcn.js → diagram-MMDJMWI5-BZQV1jqh.js} +1 -1
  26. package/dist/client/assets/{diagram-TYMM5635-CLd83m-G.js → diagram-TYMM5635-v_pX67fP.js} +1 -1
  27. package/dist/client/assets/{erDiagram-SMLLAGMA-CGP2g7Ug.js → erDiagram-SMLLAGMA-DA8k24I7.js} +1 -1
  28. package/dist/client/assets/{flowDiagram-DWJPFMVM-BhKzXbma.js → flowDiagram-DWJPFMVM-CA3Jm5mj.js} +1 -1
  29. package/dist/client/assets/{ganttDiagram-T4ZO3ILL-BdpBmhZF.js → ganttDiagram-T4ZO3ILL-B6YPlixu.js} +1 -1
  30. package/dist/client/assets/{gitGraphDiagram-UUTBAWPF-IylczS5r.js → gitGraphDiagram-UUTBAWPF-3BjoRhTq.js} +1 -1
  31. package/dist/client/assets/{graph-xlKIIKKy.js → graph-CjQR1bpo.js} +1 -1
  32. package/dist/client/assets/{index-DH7xHFza.js → index-B21kBRWF.js} +70 -70
  33. package/dist/client/assets/{infoDiagram-42DDH7IO-Dm9-Iqxb.js → infoDiagram-42DDH7IO-Cz8NXcwy.js} +1 -1
  34. package/dist/client/assets/{ishikawaDiagram-UXIWVN3A-0tPrKKU3.js → ishikawaDiagram-UXIWVN3A-dJiEc4oW.js} +1 -1
  35. package/dist/client/assets/{journeyDiagram-VCZTEJTY-3wTioYxO.js → journeyDiagram-VCZTEJTY-D0e9gSNl.js} +1 -1
  36. package/dist/client/assets/{kanban-definition-6JOO6SKY-DjVcpuse.js → kanban-definition-6JOO6SKY-DJ-tyN1D.js} +1 -1
  37. package/dist/client/assets/{layout-BZ0nnXEn.js → layout-By8oq65c.js} +1 -1
  38. package/dist/client/assets/{linear-DNdW4gLV.js → linear-Bgvt1y1F.js} +1 -1
  39. package/dist/client/assets/{mermaid.core-DpO6yFcA.js → mermaid.core-BzUsxrJd.js} +4 -4
  40. package/dist/client/assets/{min-xMtTJxkM.js → min-C5LKMAsm.js} +1 -1
  41. package/dist/client/assets/{mindmap-definition-QFDTVHPH-8tcRIKM5.js → mindmap-definition-QFDTVHPH-BVEgUjPO.js} +1 -1
  42. package/dist/client/assets/{pieDiagram-DEJITSTG-DOuWZGrv.js → pieDiagram-DEJITSTG-H6ERErU1.js} +1 -1
  43. package/dist/client/assets/{quadrantDiagram-34T5L4WZ-BWPtgVdA.js → quadrantDiagram-34T5L4WZ-B3Y2XYCJ.js} +1 -1
  44. package/dist/client/assets/{requirementDiagram-MS252O5E-CkNpSYqR.js → requirementDiagram-MS252O5E-NgcHrVQM.js} +1 -1
  45. package/dist/client/assets/{sankeyDiagram-XADWPNL6-DUPS39lN.js → sankeyDiagram-XADWPNL6-DtmwsCxU.js} +1 -1
  46. package/dist/client/assets/{sequenceDiagram-FGHM5R23-B4n7l5jw.js → sequenceDiagram-FGHM5R23-Rd0S2w1n.js} +1 -1
  47. package/dist/client/assets/{stateDiagram-FHFEXIEX-DBHsG7yj.js → stateDiagram-FHFEXIEX-Cpag_fk7.js} +1 -1
  48. package/dist/client/assets/stateDiagram-v2-QKLJ7IA2-Cbjujcp-.js +1 -0
  49. package/dist/client/assets/{timeline-definition-GMOUNBTQ-BLxUyg3R.js → timeline-definition-GMOUNBTQ-C8yS2XLP.js} +1 -1
  50. package/dist/client/assets/{vennDiagram-DHZGUBPP-27NkxCen.js → vennDiagram-DHZGUBPP-Bj7SvZFm.js} +1 -1
  51. package/dist/client/assets/{wardley-RL74JXVD-VNgEaZlH.js → wardley-RL74JXVD-DZhhw2v9.js} +1 -1
  52. package/dist/client/assets/{wardleyDiagram-NUSXRM2D-byIhDvPD.js → wardleyDiagram-NUSXRM2D-DgpBbIN3.js} +1 -1
  53. package/dist/client/assets/{xychartDiagram-5P7HB3ND-D0amCilL.js → xychartDiagram-5P7HB3ND-CUq82Sal.js} +1 -1
  54. package/dist/client/index.html +1 -1
  55. package/dist/fleet-plugins/ledger/routes.mjs +62 -5
  56. package/dist/fleet-plugins/quota/routes.mjs +621 -137
  57. package/dist/fleet-plugins/scuttlebutt/routes.mjs +62 -5
  58. package/dist/fleet-plugins/terminal/routes.mjs +1521 -502
  59. package/dist/fleet.mjs +2885 -633
  60. package/package.json +1 -1
  61. package/dist/client/assets/channel-BTX-SvBb.js +0 -1
  62. package/dist/client/assets/classDiagram-6PBFFD2Q-CixB9uB6.js +0 -1
  63. package/dist/client/assets/classDiagram-v2-HSJHXN6E-CixB9uB6.js +0 -1
  64. package/dist/client/assets/clone-DuMuKBBB.js +0 -1
  65. package/dist/client/assets/stateDiagram-v2-QKLJ7IA2--18aeGq2.js +0 -1
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import { execFile } from 'child_process';
2
+ import { execFile, spawn } from 'child_process';
3
3
  import { constants } from 'fs';
4
4
  import fs22 from 'fs/promises';
5
5
  import os4 from 'os';
6
6
  import { promisify } from 'util';
7
- import path32 from 'path';
7
+ import path42 from 'path';
8
8
  import { deflateRawSync } from 'zlib';
9
9
  import * as fs4 from 'node:fs';
10
10
  import * as path from 'node:path';
@@ -20,16 +20,16 @@ var __export = (target, all) => {
20
20
  function definePlugin(definition) {
21
21
  return definition;
22
22
  }
23
- function registerRouter(ctx, path5, handler, catalog) {
23
+ function registerRouter(ctx, path6, handler, catalog) {
24
24
  if (catalog) {
25
- ctx.registerRouter(normalizePath(path5), handler, catalog);
25
+ ctx.registerRouter(normalizePath(path6), handler, catalog);
26
26
  return;
27
27
  }
28
- ctx.registerRouter(normalizePath(path5), handler);
28
+ ctx.registerRouter(normalizePath(path6), handler);
29
29
  }
30
- function normalizePath(path5) {
31
- if (path5.length === 0 || path5 === "/") return "/";
32
- return path5;
30
+ function normalizePath(path6) {
31
+ if (path6.length === 0 || path6 === "/") return "/";
32
+ return path6;
33
33
  }
34
34
 
35
35
  // ../../node_modules/.pnpm/zod@4.4.1/node_modules/zod/v4/classic/external.js
@@ -794,10 +794,10 @@ function mergeDefs(...defs) {
794
794
  function cloneDef(schema) {
795
795
  return mergeDefs(schema._zod.def);
796
796
  }
797
- function getElementAtPath(obj, path5) {
798
- if (!path5)
797
+ function getElementAtPath(obj, path6) {
798
+ if (!path6)
799
799
  return obj;
800
- return path5.reduce((acc, key) => acc?.[key], obj);
800
+ return path6.reduce((acc, key) => acc?.[key], obj);
801
801
  }
802
802
  function promiseAllObject(promisesObj) {
803
803
  const keys = Object.keys(promisesObj);
@@ -1206,11 +1206,11 @@ function explicitlyAborted(x, startIndex = 0) {
1206
1206
  }
1207
1207
  return false;
1208
1208
  }
1209
- function prefixIssues(path5, issues) {
1209
+ function prefixIssues(path6, issues) {
1210
1210
  return issues.map((iss) => {
1211
1211
  var _a3;
1212
1212
  (_a3 = iss).path ?? (_a3.path = []);
1213
- iss.path.unshift(path5);
1213
+ iss.path.unshift(path6);
1214
1214
  return iss;
1215
1215
  });
1216
1216
  }
@@ -1357,16 +1357,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
1357
1357
  }
1358
1358
  function formatError(error51, mapper = (issue2) => issue2.message) {
1359
1359
  const fieldErrors = { _errors: [] };
1360
- const processError = (error52, path5 = []) => {
1360
+ const processError = (error52, path6 = []) => {
1361
1361
  for (const issue2 of error52.issues) {
1362
1362
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1363
- issue2.errors.map((issues) => processError({ issues }, [...path5, ...issue2.path]));
1363
+ issue2.errors.map((issues) => processError({ issues }, [...path6, ...issue2.path]));
1364
1364
  } else if (issue2.code === "invalid_key") {
1365
- processError({ issues: issue2.issues }, [...path5, ...issue2.path]);
1365
+ processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
1366
1366
  } else if (issue2.code === "invalid_element") {
1367
- processError({ issues: issue2.issues }, [...path5, ...issue2.path]);
1367
+ processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
1368
1368
  } else {
1369
- const fullpath = [...path5, ...issue2.path];
1369
+ const fullpath = [...path6, ...issue2.path];
1370
1370
  if (fullpath.length === 0) {
1371
1371
  fieldErrors._errors.push(mapper(issue2));
1372
1372
  } else {
@@ -1393,17 +1393,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
1393
1393
  }
1394
1394
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
1395
1395
  const result = { errors: [] };
1396
- const processError = (error52, path5 = []) => {
1396
+ const processError = (error52, path6 = []) => {
1397
1397
  var _a3, _b;
1398
1398
  for (const issue2 of error52.issues) {
1399
1399
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1400
- issue2.errors.map((issues) => processError({ issues }, [...path5, ...issue2.path]));
1400
+ issue2.errors.map((issues) => processError({ issues }, [...path6, ...issue2.path]));
1401
1401
  } else if (issue2.code === "invalid_key") {
1402
- processError({ issues: issue2.issues }, [...path5, ...issue2.path]);
1402
+ processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
1403
1403
  } else if (issue2.code === "invalid_element") {
1404
- processError({ issues: issue2.issues }, [...path5, ...issue2.path]);
1404
+ processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
1405
1405
  } else {
1406
- const fullpath = [...path5, ...issue2.path];
1406
+ const fullpath = [...path6, ...issue2.path];
1407
1407
  if (fullpath.length === 0) {
1408
1408
  result.errors.push(mapper(issue2));
1409
1409
  continue;
@@ -1435,8 +1435,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
1435
1435
  }
1436
1436
  function toDotPath(_path) {
1437
1437
  const segs = [];
1438
- const path5 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1439
- for (const seg of path5) {
1438
+ const path6 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1439
+ for (const seg of path6) {
1440
1440
  if (typeof seg === "number")
1441
1441
  segs.push(`[${seg}]`);
1442
1442
  else if (typeof seg === "symbol")
@@ -14100,13 +14100,13 @@ function resolveRef(ref, ctx) {
14100
14100
  if (!ref.startsWith("#")) {
14101
14101
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
14102
14102
  }
14103
- const path5 = ref.slice(1).split("/").filter(Boolean);
14104
- if (path5.length === 0) {
14103
+ const path6 = ref.slice(1).split("/").filter(Boolean);
14104
+ if (path6.length === 0) {
14105
14105
  return ctx.rootSchema;
14106
14106
  }
14107
14107
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
14108
- if (path5[0] === defsKey) {
14109
- const key = path5[1];
14108
+ if (path6[0] === defsKey) {
14109
+ const key = path6[1];
14110
14110
  if (!key || !ctx.defs[key]) {
14111
14111
  throw new Error(`Reference not found: ${ref}`);
14112
14112
  }
@@ -17094,8 +17094,8 @@ function bootEnumDescriptorProto(init) {
17094
17094
  }
17095
17095
 
17096
17096
  // ../../node_modules/.pnpm/@bufbuild+protobuf@2.13.0/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/message.js
17097
- function messageDesc(file2, path5, ...paths) {
17098
- return paths.reduce((acc, cur) => acc.nestedMessages[cur], file2.messages[path5]);
17097
+ function messageDesc(file2, path6, ...paths) {
17098
+ return paths.reduce((acc, cur) => acc.nestedMessages[cur], file2.messages[path6]);
17099
17099
  }
17100
17100
 
17101
17101
  // ../../node_modules/.pnpm/@bufbuild+protobuf@2.13.0/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/descriptor_pb.js
@@ -17815,6 +17815,11 @@ var REASONING_EFFORTS = [
17815
17815
  new Map(
17816
17816
  REASONING_EFFORTS.map((effort, index) => [effort, index])
17817
17817
  );
17818
+ var CLAUDE_CLIENT_IDENTITY_SENTENCES = [
17819
+ "You are Claude Code, Anthropic's official CLI for Claude.",
17820
+ "You are a Claude agent, built on Anthropic's Claude Agent SDK."
17821
+ ];
17822
+ Math.max(...CLAUDE_CLIENT_IDENTITY_SENTENCES.map((sentence) => sentence.length)) + 16;
17818
17823
  var benchmarks_default = {
17819
17824
  version: 2,
17820
17825
  sources: {
@@ -18034,6 +18039,46 @@ var models_default = {
18034
18039
  version: 1,
18035
18040
  updatedAt: "2026-08-22T00:00:00Z",
18036
18041
  providers: {
18042
+ antigravity: {
18043
+ name: "Antigravity",
18044
+ defaultModel: "gemini-3.7-flash",
18045
+ source: "live POST https://daily-cloudcode-pa.googleapis.com/v1internal:fetchAvailableModels read with the credential the Antigravity CLI (agy 1.1.18) owns, 2026-08-22; the same read reported defaultAgentModelId gemini-3.7-flash-high and a deprecatedModelIds entry mapping gemini-3.1-pro-high to gemini-pro-agent, and a live streamGenerateContent probe on that date confirmed gemini-3.1-pro-high is refused with INVALID_ARGUMENT while gemini-pro-agent answers. Effort spelling was measured per model on one fixed prompt: gemini-3.7-flash-tiered honours generationConfig.thinkingConfig.thinkingLevel (343 / 407 / 434 reasoning tokens at low / medium / high) so its ladder is a request field, while Gemini 3.1 Pro encodes the rung in the wire id. thinkingLevel accepts low, medium, and high only: minimal and max are both refused. Claude and GPT-OSS models are served by the same subscription but are deliberately not exposed here",
18046
+ models: [
18047
+ {
18048
+ modelId: "gemini-3.7-flash",
18049
+ name: "Gemini-3.7-Flash",
18050
+ capabilityClass: "light",
18051
+ providerModelId: "gemini-3.7-flash-tiered",
18052
+ contextWindow: 1048576,
18053
+ effort: {
18054
+ supported: true,
18055
+ levels: [
18056
+ "low",
18057
+ "medium",
18058
+ "high"
18059
+ ]
18060
+ }
18061
+ },
18062
+ {
18063
+ modelId: "gemini-3.1-pro",
18064
+ name: "Gemini-3.1-Pro",
18065
+ capabilityClass: "flagship",
18066
+ providerModelId: "gemini-3.1-pro-low",
18067
+ contextWindow: 1048576,
18068
+ effort: {
18069
+ supported: true,
18070
+ levels: [
18071
+ "low",
18072
+ "high"
18073
+ ],
18074
+ upstreamModelIds: {
18075
+ low: "gemini-3.1-pro-low",
18076
+ high: "gemini-pro-agent"
18077
+ }
18078
+ }
18079
+ }
18080
+ ]
18081
+ },
18037
18082
  codex: {
18038
18083
  name: "Codex",
18039
18084
  defaultModel: "gpt-5.6-sol",
@@ -19031,7 +19076,7 @@ var models_default = {
19031
19076
  };
19032
19077
  var KIMI_AUTH_PROVIDER_ID = "Claude Code with Moonshot Kimi";
19033
19078
  var KIMI_CODE_API_BASE_URL = "https://api.kimi.com/coding";
19034
- var GATEWAY_PROVIDERS = ["codex", "xai", "cursor", "opencode", "kimi"];
19079
+ var GATEWAY_PROVIDERS = ["codex", "xai", "cursor", "opencode", "antigravity", "kimi"];
19035
19080
  var GATEWAY_MODEL_WIRES = ["anthropic", "responses", "chat-completions"];
19036
19081
  var GATEWAY_REASONING_EFFORTS = [
19037
19082
  "low",
@@ -19139,7 +19184,8 @@ var GatewayModelsRegistrySchema = external_exports.object({
19139
19184
  cursor: GatewayProviderSchema,
19140
19185
  kimi: GatewayProviderSchema,
19141
19186
  opencode: GatewayProviderSchema,
19142
- xai: GatewayProviderSchema
19187
+ xai: GatewayProviderSchema,
19188
+ antigravity: GatewayProviderSchema
19143
19189
  }).strict(),
19144
19190
  pricing: GatewayPricingRegistrySchema
19145
19191
  }).strict();
@@ -19165,7 +19211,6 @@ var registry2 = (() => {
19165
19211
  return parsed;
19166
19212
  })();
19167
19213
  registry2.updatedAt;
19168
- registry2.pricing.observedAt;
19169
19214
  Object.freeze(
19170
19215
  Object.fromEntries(
19171
19216
  Object.entries(registry2.pricing.models).map(([modelId, pricing]) => [
@@ -19373,8 +19418,8 @@ function validateRegistry(value) {
19373
19418
  }
19374
19419
  }
19375
19420
  if (exactModelIds) {
19376
- if (provider !== "cursor") {
19377
- throw new Error(`Gateway effort model id overrides are only supported by Cursor: ${provider}/${model.modelId}`);
19421
+ if (provider !== "cursor" && provider !== "antigravity") {
19422
+ throw new Error(`Gateway effort model id overrides are only supported by Cursor and Antigravity: ${provider}/${model.modelId}`);
19378
19423
  }
19379
19424
  for (const effort of Object.keys(exactModelIds)) {
19380
19425
  if (!model.effort.levels.includes(effort)) {
@@ -19433,63 +19478,375 @@ function findCauseCode(error51) {
19433
19478
  return void 0;
19434
19479
  }
19435
19480
  new TextEncoder().encode(": keep-alive\n\n");
19436
- var MS_PER_HOUR = 36e5;
19437
- var CADENCE_SESSION_MAX_MS = 20 * MS_PER_HOUR;
19438
- var CADENCE_DAILY_MAX_MS = 3 * 24 * MS_PER_HOUR;
19439
- var CADENCE_WEEKLY_MAX_MS = 20 * 24 * MS_PER_HOUR;
19440
- var MIN_ELAPSED_FRACTION = 0.05;
19441
- var PACE_CRITICAL = 1.5;
19442
- var PACE_ELEVATED = 1.1;
19443
- var USED_CRITICAL_PERCENT = 95;
19444
- var USED_ELEVATED_PERCENT = 80;
19445
- function quotaWindowCadence(durationMs) {
19446
- if (durationMs <= CADENCE_SESSION_MAX_MS) return "session";
19447
- if (durationMs <= CADENCE_DAILY_MAX_MS) return "daily";
19448
- if (durationMs <= CADENCE_WEEKLY_MAX_MS) return "weekly";
19449
- return "monthly";
19481
+ var execFileAsync = promisify(execFile);
19482
+ var MAX_CREDENTIAL_BYTES = 65536;
19483
+ var CREDENTIAL_OPEN_FLAGS = process.platform === "win32" ? constants.O_RDONLY : constants.O_RDONLY | constants.O_NONBLOCK;
19484
+ async function readBoundedFile(filePath, maxBytes) {
19485
+ const handle = await fs22.open(filePath, CREDENTIAL_OPEN_FLAGS);
19486
+ try {
19487
+ const stat2 = await handle.stat();
19488
+ if (!stat2.isFile() || stat2.size > maxBytes) return null;
19489
+ const buffer = Buffer.allocUnsafe(maxBytes + 1);
19490
+ let totalBytes = 0;
19491
+ while (totalBytes < buffer.byteLength) {
19492
+ const { bytesRead } = await handle.read(
19493
+ buffer,
19494
+ totalBytes,
19495
+ buffer.byteLength - totalBytes,
19496
+ totalBytes
19497
+ );
19498
+ if (bytesRead === 0) break;
19499
+ totalBytes += bytesRead;
19500
+ }
19501
+ return totalBytes > maxBytes ? null : buffer.subarray(0, totalBytes).toString("utf8");
19502
+ } finally {
19503
+ await handle.close();
19504
+ }
19450
19505
  }
19451
- function windowPressure(usedPercent, paceRatio) {
19452
- if (usedPercent >= USED_CRITICAL_PERCENT || paceRatio !== void 0 && paceRatio >= PACE_CRITICAL) {
19453
- return "critical";
19506
+ var defaultCredentialDeps = {
19507
+ platform: process.platform,
19508
+ homedir: os4.homedir,
19509
+ env: process.env,
19510
+ readBounded: readBoundedFile,
19511
+ execFile: async (file2, args, options) => {
19512
+ const result = await execFileAsync(file2, [...args], options);
19513
+ return result.stdout;
19454
19514
  }
19455
- if (usedPercent >= USED_ELEVATED_PERCENT || paceRatio !== void 0 && paceRatio >= PACE_ELEVATED) {
19456
- return "elevated";
19515
+ };
19516
+ function credentialRecord(value) {
19517
+ return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
19518
+ }
19519
+ function optionalTrimmedString(value) {
19520
+ if (typeof value !== "string") return void 0;
19521
+ const trimmed = value.trim();
19522
+ return trimmed.length > 0 ? trimmed : void 0;
19523
+ }
19524
+ var ANTIGRAVITY_KEYCHAIN_SERVICE = "gemini";
19525
+ var ANTIGRAVITY_KEYCHAIN_ACCOUNT = "antigravity";
19526
+ var GO_KEYRING_BASE64_PREFIX = "go-keyring-base64:";
19527
+ var ANTIGRAVITY_CLI_BINARY = "agy";
19528
+ var ANTIGRAVITY_CLI_REFRESH_ARGS = ["models"];
19529
+ var ANTIGRAVITY_DAILY_API = "https://daily-cloudcode-pa.googleapis.com";
19530
+ var ANTIGRAVITY_PROD_API = "https://cloudcode-pa.googleapis.com";
19531
+ var ANTIGRAVITY_IDE_VERSION = "2.5.5";
19532
+ var ARCH_LABELS = Object.freeze({
19533
+ x64: "amd64",
19534
+ arm64: "arm64",
19535
+ ia32: "386"
19536
+ });
19537
+ function antigravityUserAgent(platform = process.platform, arch = process.arch) {
19538
+ const osType = platform === "win32" ? "windows" : platform;
19539
+ const archLabel = ARCH_LABELS[arch] ?? arch;
19540
+ return `antigravity/ide/${ANTIGRAVITY_IDE_VERSION} (os_type=${osType}; arch=${archLabel}; aidev_client; auth_method=oauth)`;
19541
+ }
19542
+ var ANTIGRAVITY_REFRESH_BUFFER_MS = 6e4;
19543
+ var VENDOR_REFRESH_TIMEOUT_MS = 2e4;
19544
+ var KEYCHAIN_TIMEOUT_MS = 5e3;
19545
+ var WINDOWS_CREDENTIAL_TIMEOUT_MS = 15e3;
19546
+ var vendorRefreshInFlight = /* @__PURE__ */ new Map();
19547
+ function expiry(value) {
19548
+ if (typeof value === "number" && Number.isFinite(value)) {
19549
+ return value < 1e12 ? Math.round(value * 1e3) : Math.round(value);
19457
19550
  }
19458
- return "ok";
19551
+ if (typeof value !== "string") return void 0;
19552
+ const parsed = Date.parse(value);
19553
+ return Number.isFinite(parsed) ? parsed : void 0;
19459
19554
  }
19460
- function deriveQuotaWindowRisk(window, at) {
19461
- const durationMs = window.period?.durationMs;
19462
- if (typeof durationMs !== "number" || !Number.isFinite(durationMs) || durationMs <= 0) {
19463
- return { pressure: windowPressure(window.usedPercent, void 0) };
19555
+ function firstString(source, keys) {
19556
+ for (const key of keys) {
19557
+ const value = optionalTrimmedString(source[key]);
19558
+ if (value !== void 0) return value;
19464
19559
  }
19465
- const startsAt = window.period?.startsAt ?? (window.resetsAt !== void 0 && window.resetsAt > durationMs ? window.resetsAt - durationMs : void 0);
19466
- const resetBoundary = window.resetsAt ?? (startsAt !== void 0 ? startsAt + durationMs : void 0);
19467
- const stale = resetBoundary !== void 0 && at > resetBoundary;
19468
- let elapsedFraction;
19469
- let paceRatio;
19470
- let projectedExhaustionAt;
19471
- if (startsAt !== void 0 && resetBoundary !== void 0 && !stale && at > startsAt) {
19472
- const elapsed = Math.min(1, (at - startsAt) / durationMs);
19473
- elapsedFraction = Math.round(elapsed * 100) / 100;
19474
- if (elapsed >= MIN_ELAPSED_FRACTION) {
19475
- const used = Math.min(1, Math.max(0, window.usedPercent / 100));
19476
- paceRatio = Math.round(used / elapsed * 100) / 100;
19477
- if (used > 0 && used < 1) {
19478
- const exhaustionAt = startsAt + Math.round((at - startsAt) / used);
19479
- if (exhaustionAt < resetBoundary) projectedExhaustionAt = exhaustionAt;
19480
- }
19560
+ return void 0;
19561
+ }
19562
+ function parseAntigravityKeychainValue(raw) {
19563
+ let body = raw.trim();
19564
+ if (body.length === 0) return null;
19565
+ if (body.startsWith(GO_KEYRING_BASE64_PREFIX)) {
19566
+ try {
19567
+ body = Buffer.from(body.slice(GO_KEYRING_BASE64_PREFIX.length), "base64").toString("utf8");
19568
+ } catch {
19569
+ return null;
19481
19570
  }
19482
19571
  }
19572
+ if (/^bearer /i.test(body)) body = body.slice(7).trim();
19573
+ if (!body.startsWith("{")) {
19574
+ return body.length > 0 ? { accessToken: body } : null;
19575
+ }
19576
+ let parsed;
19577
+ try {
19578
+ parsed = JSON.parse(body);
19579
+ } catch {
19580
+ return null;
19581
+ }
19582
+ const root = credentialRecord(parsed);
19583
+ if (!root) return null;
19584
+ const source = credentialRecord(root.token) ?? credentialRecord(root.tokens) ?? credentialRecord(root.oauth) ?? credentialRecord(root.oauth2) ?? credentialRecord(root.credentials) ?? credentialRecord(root.auth) ?? root;
19585
+ const accessToken = firstString(source, [
19586
+ "access_token",
19587
+ "accessToken",
19588
+ "token",
19589
+ "id_token",
19590
+ "idToken",
19591
+ "bearerToken",
19592
+ "auth_token",
19593
+ "authToken"
19594
+ ]);
19595
+ const refreshToken2 = firstString(source, ["refresh_token", "refreshToken"]);
19596
+ const expiresAt = expiry(source.expiry) ?? expiry(source.expires_at) ?? expiry(source.expiresAt);
19597
+ if (!accessToken && !refreshToken2) return null;
19483
19598
  return {
19484
- cadence: quotaWindowCadence(durationMs),
19485
- ...elapsedFraction !== void 0 ? { elapsedFraction } : {},
19486
- ...paceRatio !== void 0 ? { paceRatio } : {},
19487
- ...projectedExhaustionAt !== void 0 ? { projectedExhaustionAt } : {},
19488
- recoveryHalfLifeMs: Math.round(durationMs / 2),
19489
- pressure: windowPressure(window.usedPercent, paceRatio)
19599
+ ...accessToken === void 0 ? {} : { accessToken },
19600
+ ...refreshToken2 === void 0 ? {} : { refreshToken: refreshToken2 },
19601
+ ...expiresAt === void 0 ? {} : { expiresAt }
19602
+ };
19603
+ }
19604
+ var WINDOWS_CREDENTIAL_TARGET = `${ANTIGRAVITY_KEYCHAIN_SERVICE}:${ANTIGRAVITY_KEYCHAIN_ACCOUNT}`;
19605
+ var WINDOWS_CREDENTIAL_READER = `$ErrorActionPreference = 'Stop'
19606
+ Add-Type -TypeDefinition @'
19607
+ using System;
19608
+ using System.Runtime.InteropServices;
19609
+ public static class FleetAntigravityCredential {
19610
+ [DllImport("advapi32.dll", SetLastError=true, CharSet=CharSet.Unicode, EntryPoint="CredReadW")]
19611
+ private static extern bool CredRead(string target, uint type, uint flags, out IntPtr credential);
19612
+ [DllImport("advapi32.dll")]
19613
+ private static extern void CredFree(IntPtr credential);
19614
+ [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
19615
+ private struct CREDENTIAL {
19616
+ public uint Flags; public uint Type; public IntPtr TargetName; public IntPtr Comment;
19617
+ public long LastWritten; public uint CredentialBlobSize; public IntPtr CredentialBlob;
19618
+ public uint Persist; public uint AttributeCount; public IntPtr Attributes;
19619
+ public IntPtr TargetAlias; public IntPtr UserName;
19620
+ }
19621
+ public static string Read(string target) {
19622
+ IntPtr handle;
19623
+ if (!CredRead(target, 1, 0, out handle)) return "";
19624
+ try {
19625
+ CREDENTIAL cred = (CREDENTIAL)Marshal.PtrToStructure(handle, typeof(CREDENTIAL));
19626
+ byte[] blob = new byte[cred.CredentialBlobSize];
19627
+ Marshal.Copy(cred.CredentialBlob, blob, 0, (int)cred.CredentialBlobSize);
19628
+ return Convert.ToBase64String(blob);
19629
+ } finally { CredFree(handle); }
19630
+ }
19631
+ }
19632
+ '@
19633
+ [Console]::Out.Write([FleetAntigravityCredential]::Read('${WINDOWS_CREDENTIAL_TARGET}'))
19634
+ `;
19635
+ function windowsPowerShell(deps) {
19636
+ const systemRoot = optionalTrimmedString(deps.env.SystemRoot);
19637
+ return systemRoot === void 0 ? "powershell.exe" : path42.win32.join(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe");
19638
+ }
19639
+ async function readKeychainValue(deps) {
19640
+ if (deps.platform === "darwin") {
19641
+ const raw = await deps.execFile(
19642
+ "security",
19643
+ [
19644
+ "find-generic-password",
19645
+ "-s",
19646
+ ANTIGRAVITY_KEYCHAIN_SERVICE,
19647
+ "-a",
19648
+ ANTIGRAVITY_KEYCHAIN_ACCOUNT,
19649
+ "-w"
19650
+ ],
19651
+ { timeout: KEYCHAIN_TIMEOUT_MS }
19652
+ );
19653
+ return raw.length > MAX_CREDENTIAL_BYTES ? null : raw;
19654
+ }
19655
+ if (deps.platform === "linux") {
19656
+ const raw = await deps.execFile(
19657
+ "secret-tool",
19658
+ [
19659
+ "lookup",
19660
+ "service",
19661
+ ANTIGRAVITY_KEYCHAIN_SERVICE,
19662
+ "username",
19663
+ ANTIGRAVITY_KEYCHAIN_ACCOUNT
19664
+ ],
19665
+ { timeout: KEYCHAIN_TIMEOUT_MS }
19666
+ );
19667
+ return raw.length > MAX_CREDENTIAL_BYTES ? null : raw;
19668
+ }
19669
+ if (deps.platform === "win32") {
19670
+ const encoded = await deps.execFile(
19671
+ windowsPowerShell(deps),
19672
+ [
19673
+ "-NoProfile",
19674
+ "-NonInteractive",
19675
+ "-EncodedCommand",
19676
+ // `-EncodedCommand` takes UTF-16LE base64, which is what keeps a script
19677
+ // full of quotes and `$` out of Windows command-line quoting entirely.
19678
+ Buffer.from(WINDOWS_CREDENTIAL_READER, "utf16le").toString("base64")
19679
+ ],
19680
+ { timeout: WINDOWS_CREDENTIAL_TIMEOUT_MS }
19681
+ );
19682
+ const blob = encoded.trim();
19683
+ if (blob.length === 0) return null;
19684
+ const raw = Buffer.from(blob, "base64").toString("utf8");
19685
+ return raw.length > MAX_CREDENTIAL_BYTES ? null : raw;
19686
+ }
19687
+ return null;
19688
+ }
19689
+ function spawnVendorRefresh(deps) {
19690
+ const binary = optionalTrimmedString(deps.env.FLEET_ANTIGRAVITY_CLI) ?? ANTIGRAVITY_CLI_BINARY;
19691
+ return new Promise((resolve) => {
19692
+ let child;
19693
+ try {
19694
+ child = spawn(binary, [...ANTIGRAVITY_CLI_REFRESH_ARGS], { stdio: "ignore" });
19695
+ } catch {
19696
+ resolve();
19697
+ return;
19698
+ }
19699
+ let settled = false;
19700
+ const finish = () => {
19701
+ if (settled) return;
19702
+ settled = true;
19703
+ clearTimeout(timer);
19704
+ resolve();
19705
+ };
19706
+ const timer = setTimeout(() => {
19707
+ child.kill("SIGKILL");
19708
+ finish();
19709
+ }, VENDOR_REFRESH_TIMEOUT_MS);
19710
+ child.once("error", finish);
19711
+ child.once("close", finish);
19712
+ });
19713
+ }
19714
+ async function runVendorRefresh(deps, refresh) {
19715
+ const binary = optionalTrimmedString(deps.env.FLEET_ANTIGRAVITY_CLI) ?? ANTIGRAVITY_CLI_BINARY;
19716
+ const key = `${binary}\0${deps.homedir()}`;
19717
+ const existing = vendorRefreshInFlight.get(key);
19718
+ if (existing) return existing;
19719
+ const task = refresh(deps).catch(() => void 0).finally(() => {
19720
+ vendorRefreshInFlight.delete(key);
19721
+ });
19722
+ vendorRefreshInFlight.set(key, task);
19723
+ return task;
19724
+ }
19725
+ async function resolveAntigravityAuth(deps, options = {}) {
19726
+ const now = options.now ?? Date.now;
19727
+ const read = async () => {
19728
+ let raw;
19729
+ try {
19730
+ raw = await readKeychainValue(deps);
19731
+ } catch {
19732
+ return null;
19733
+ }
19734
+ return raw === null ? null : parseAntigravityKeychainValue(raw);
19735
+ };
19736
+ const usable = (token) => {
19737
+ if (!token.accessToken) return null;
19738
+ if (token.expiresAt !== void 0 && token.expiresAt <= now()) return null;
19739
+ return {
19740
+ status: "ok",
19741
+ credentials: {
19742
+ accessToken: token.accessToken,
19743
+ method: "keychain",
19744
+ ...token.expiresAt === void 0 ? {} : { expiresAt: token.expiresAt }
19745
+ }
19746
+ };
19490
19747
  };
19748
+ const stored = await read();
19749
+ if (!stored) return { status: "signed_out" };
19750
+ const stale = stored.expiresAt !== void 0 && stored.expiresAt - now() <= ANTIGRAVITY_REFRESH_BUFFER_MS;
19751
+ if (options.forceRefresh !== true && !stale) {
19752
+ const ready2 = usable(stored);
19753
+ if (ready2) return ready2;
19754
+ }
19755
+ if (!stored.refreshToken) {
19756
+ return usable(stored) ?? { status: stored.accessToken ? "expired" : "signed_out" };
19757
+ }
19758
+ await runVendorRefresh(deps, options.refreshVendorCredential ?? spawnVendorRefresh);
19759
+ const renewed = await read();
19760
+ const ready = renewed ? usable(renewed) : null;
19761
+ if (ready) return ready;
19762
+ return { status: "expired" };
19491
19763
  }
19764
+ var ANTIGRAVITY_LOAD_CODE_ASSIST_URL = `${ANTIGRAVITY_PROD_API}/v1internal:loadCodeAssist`;
19492
19765
  var REQUEST_TIMEOUT_MS = 1e4;
19766
+ var ANTIGRAVITY_CODE_ASSIST_TTL_MS = 36e5;
19767
+ var MAX_PROJECT_ID_LENGTH = 128;
19768
+ var TIER_LABELS = Object.freeze({
19769
+ "free-tier": "Free",
19770
+ "legacy-tier": "Legacy",
19771
+ "standard-tier": "Standard",
19772
+ "g1-pro-tier": "Pro",
19773
+ "g1-ultra-tier": "Ultra"
19774
+ });
19775
+ function antigravityPlanLabel(tierId) {
19776
+ const id = optionalTrimmedString(tierId)?.toLowerCase();
19777
+ if (!id) return void 0;
19778
+ const known = TIER_LABELS[id];
19779
+ if (known) return known;
19780
+ const bare = id.replace(/-tier$/, "").replace(/[-_]+/g, " ").trim();
19781
+ if (bare.length === 0 || bare.length > 24 || !/^[a-z0-9][a-z0-9 .+-]*$/.test(bare)) return void 0;
19782
+ return bare.replace(/(^|\s)([a-z0-9])/g, (_, lead, char) => `${lead}${char.toUpperCase()}`);
19783
+ }
19784
+ function projectId(value) {
19785
+ const id = optionalTrimmedString(value);
19786
+ if (!id || id.length > MAX_PROJECT_ID_LENGTH) return void 0;
19787
+ return /^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(id) ? id : void 0;
19788
+ }
19789
+ async function loadAntigravityCodeAssist(fetchImpl, accessToken, signal) {
19790
+ const controller = new AbortController();
19791
+ const timer = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
19792
+ const onAbort = () => controller.abort();
19793
+ signal?.addEventListener("abort", onAbort, { once: true });
19794
+ try {
19795
+ const response = await fetchImpl(ANTIGRAVITY_LOAD_CODE_ASSIST_URL, {
19796
+ method: "POST",
19797
+ headers: {
19798
+ Accept: "application/json",
19799
+ "Content-Type": "application/json",
19800
+ Authorization: `Bearer ${accessToken}`,
19801
+ "User-Agent": antigravityUserAgent()
19802
+ },
19803
+ body: JSON.stringify({ metadata: { ideType: "ANTIGRAVITY" } }),
19804
+ signal: controller.signal
19805
+ });
19806
+ if (!response.ok) {
19807
+ await response.body?.cancel().catch(() => void 0);
19808
+ return {};
19809
+ }
19810
+ const payload = credentialRecord(await response.json());
19811
+ if (!payload) return {};
19812
+ const project = projectId(payload.cloudaicompanionProject);
19813
+ const plan = antigravityPlanLabel(credentialRecord(payload.currentTier)?.id);
19814
+ return {
19815
+ ...project === void 0 ? {} : { projectId: project },
19816
+ ...plan === void 0 ? {} : { plan }
19817
+ };
19818
+ } catch {
19819
+ return {};
19820
+ } finally {
19821
+ clearTimeout(timer);
19822
+ signal?.removeEventListener("abort", onAbort);
19823
+ }
19824
+ }
19825
+ function createAntigravityCodeAssistCache(now = Date.now, ttlMs = ANTIGRAVITY_CODE_ASSIST_TTL_MS) {
19826
+ let entry;
19827
+ let inFlight;
19828
+ return {
19829
+ async read(fetchImpl, accessToken, signal) {
19830
+ if (entry && entry.token === accessToken && entry.expiresAt > now()) return entry.value;
19831
+ if (inFlight && inFlight.token === accessToken) return inFlight.task;
19832
+ const task = loadAntigravityCodeAssist(fetchImpl, accessToken, signal).then((value) => {
19833
+ if (value.projectId !== void 0 || value.plan !== void 0) {
19834
+ entry = { token: accessToken, value, expiresAt: now() + ttlMs };
19835
+ }
19836
+ return value;
19837
+ }).finally(() => {
19838
+ if (inFlight?.token === accessToken) inFlight = void 0;
19839
+ });
19840
+ inFlight = { token: accessToken, task };
19841
+ return task;
19842
+ },
19843
+ clear() {
19844
+ entry = void 0;
19845
+ inFlight = void 0;
19846
+ }
19847
+ };
19848
+ }
19849
+ var REQUEST_TIMEOUT_MS2 = 1e4;
19493
19850
  var MAX_RESPONSE_BYTES = 262144;
19494
19851
  var MAX_WINDOWS = 8;
19495
19852
  var MAX_CREDIT_ENTRIES = 256;
@@ -19578,7 +19935,7 @@ function modelLabel(value) {
19578
19935
  }
19579
19936
  async function requestJson(fetchImpl, url2, init) {
19580
19937
  const controller = new AbortController();
19581
- const timer = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
19938
+ const timer = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS2);
19582
19939
  try {
19583
19940
  const response = await fetchImpl(url2, {
19584
19941
  ...init,
@@ -19648,48 +20005,171 @@ function sanitizeProviderError(error51) {
19648
20005
  }
19649
20006
  return "Provider request failed";
19650
20007
  }
19651
- var execFileAsync = promisify(execFile);
19652
- var MAX_CREDENTIAL_BYTES = 65536;
19653
- var CREDENTIAL_OPEN_FLAGS = process.platform === "win32" ? constants.O_RDONLY : constants.O_RDONLY | constants.O_NONBLOCK;
19654
- async function readBoundedFile(filePath, maxBytes) {
19655
- const handle = await fs22.open(filePath, CREDENTIAL_OPEN_FLAGS);
20008
+ var ANTIGRAVITY_QUOTA_SUMMARY_URLS = Object.freeze([
20009
+ `${ANTIGRAVITY_DAILY_API}/v1internal:retrieveUserQuotaSummary`,
20010
+ `${ANTIGRAVITY_PROD_API}/v1internal:retrieveUserQuotaSummary`
20011
+ ]);
20012
+ var SESSION_MS = 5 * HOUR_MS;
20013
+ var BUCKETS = Object.freeze({
20014
+ "gemini-5h": { id: "session", label: "Gemini", durationMs: SESSION_MS, reported: true },
20015
+ "gemini-weekly": { id: "weekly", label: "Gemini", durationMs: WEEK_MS, reported: true },
20016
+ "3p-5h": { id: "session", label: "Claude & GPT", durationMs: SESSION_MS, reported: false },
20017
+ "3p-weekly": { id: "weekly", label: "Claude & GPT", durationMs: WEEK_MS, reported: false }
20018
+ });
20019
+ var BUCKET_ORDER = Object.freeze(
20020
+ Object.keys(BUCKETS).filter((bucketId) => BUCKETS[bucketId]?.reported === true)
20021
+ );
20022
+ function usedPercentFromRemaining(value) {
20023
+ if (typeof value !== "number" || !Number.isFinite(value)) return void 0;
20024
+ const clamped = Math.min(1, Math.max(0, value));
20025
+ return Math.round((1 - clamped) * 100);
20026
+ }
20027
+ function parseAntigravityQuotaSummary(payload) {
20028
+ const root = object2(payload);
20029
+ const groups = array2(root?.groups ?? object2(root?.response)?.groups);
20030
+ if (root === null) return null;
20031
+ if (!Array.isArray(root.groups) && !Array.isArray(object2(root.response)?.groups)) return null;
20032
+ const byBucket = /* @__PURE__ */ new Map();
20033
+ for (const rawGroup of groups) {
20034
+ for (const rawBucket of array2(object2(rawGroup)?.buckets)) {
20035
+ const bucket = object2(rawBucket);
20036
+ const bucketId = typeof bucket?.bucketId === "string" ? bucket.bucketId.trim() : "";
20037
+ const known = BUCKETS[bucketId];
20038
+ if (!known?.reported || byBucket.has(bucketId)) continue;
20039
+ const usedPercent = usedPercentFromRemaining(bucket?.remainingFraction);
20040
+ if (usedPercent === void 0) continue;
20041
+ const resetsAt = safeTimestamp(bucket?.resetTime);
20042
+ const period = windowPeriod(known.durationMs, "catalog", resetsAt);
20043
+ byBucket.set(bucketId, {
20044
+ id: known.id,
20045
+ label: known.label,
20046
+ usedPercent,
20047
+ ...resetsAt === void 0 ? {} : { resetsAt },
20048
+ ...period === void 0 ? {} : { period }
20049
+ });
20050
+ }
20051
+ }
20052
+ return BUCKET_ORDER.flatMap((bucketId) => {
20053
+ const window = byBucket.get(bucketId);
20054
+ return window ? [window] : [];
20055
+ });
20056
+ }
20057
+ function quotaHeaders(credentials) {
20058
+ return {
20059
+ Accept: "application/json",
20060
+ "Content-Type": "application/json",
20061
+ Authorization: `Bearer ${credentials.accessToken}`,
20062
+ "User-Agent": antigravityUserAgent()
20063
+ };
20064
+ }
20065
+ var codeAssistCache = createAntigravityCodeAssistCache();
20066
+ async function fetchAntigravityUsage(deps = {}) {
20067
+ const credentialDeps = deps.credentials ?? defaultCredentialDeps;
20068
+ const now = deps.now ?? Date.now;
20069
+ const fetchImpl = deps.fetch ?? fetch;
20070
+ const auth = await resolveAntigravityAuth(credentialDeps, { now });
20071
+ if (auth.status !== "ok") return { status: auth.status };
20072
+ const load = async (credentials) => {
20073
+ let lastError;
20074
+ for (const url2 of ANTIGRAVITY_QUOTA_SUMMARY_URLS) {
20075
+ try {
20076
+ return await postJson(fetchImpl, url2, quotaHeaders(credentials));
20077
+ } catch (error51) {
20078
+ if (expired(error51)) throw error51;
20079
+ lastError = error51;
20080
+ }
20081
+ }
20082
+ throw lastError;
20083
+ };
19656
20084
  try {
19657
- const stat2 = await handle.stat();
19658
- if (!stat2.isFile() || stat2.size > maxBytes) return null;
19659
- const buffer = Buffer.allocUnsafe(maxBytes + 1);
19660
- let totalBytes = 0;
19661
- while (totalBytes < buffer.byteLength) {
19662
- const { bytesRead } = await handle.read(
19663
- buffer,
19664
- totalBytes,
19665
- buffer.byteLength - totalBytes,
19666
- totalBytes
19667
- );
19668
- if (bytesRead === 0) break;
19669
- totalBytes += bytesRead;
20085
+ let credentials = auth.credentials;
20086
+ let payload;
20087
+ try {
20088
+ payload = await load(credentials);
20089
+ } catch (error51) {
20090
+ if (!expired(error51)) throw error51;
20091
+ const retried = await resolveAntigravityAuth(credentialDeps, { now, forceRefresh: true });
20092
+ if (retried.status !== "ok") return { status: "expired" };
20093
+ credentials = retried.credentials;
20094
+ try {
20095
+ payload = await load(credentials);
20096
+ } catch (retryError) {
20097
+ const result = expired(retryError);
20098
+ if (result) return result;
20099
+ throw retryError;
20100
+ }
19670
20101
  }
19671
- return totalBytes > maxBytes ? null : buffer.subarray(0, totalBytes).toString("utf8");
19672
- } finally {
19673
- await handle.close();
20102
+ const windows = parseAntigravityQuotaSummary(payload);
20103
+ if (!windows) throw new Error("Antigravity returned an unsupported quota response");
20104
+ const plan = (await codeAssistCache.read(fetchImpl, credentials.accessToken)).plan;
20105
+ return {
20106
+ status: "ok",
20107
+ method: credentials.method,
20108
+ ...plan ? { plan } : {},
20109
+ windows,
20110
+ fetchedAt: now()
20111
+ };
20112
+ } catch (error51) {
20113
+ const result = expired(error51);
20114
+ if (result) return result;
20115
+ throw error51;
19674
20116
  }
19675
20117
  }
19676
- var defaultCredentialDeps = {
19677
- platform: process.platform,
19678
- homedir: os4.homedir,
19679
- env: process.env,
19680
- readBounded: readBoundedFile,
19681
- execFile: async (file2, args, options) => {
19682
- const result = await execFileAsync(file2, [...args], options);
19683
- return result.stdout;
20118
+ var MS_PER_HOUR = 36e5;
20119
+ var CADENCE_SESSION_MAX_MS = 20 * MS_PER_HOUR;
20120
+ var CADENCE_DAILY_MAX_MS = 3 * 24 * MS_PER_HOUR;
20121
+ var CADENCE_WEEKLY_MAX_MS = 20 * 24 * MS_PER_HOUR;
20122
+ var MIN_ELAPSED_FRACTION = 0.05;
20123
+ var PACE_CRITICAL = 1.5;
20124
+ var PACE_ELEVATED = 1.1;
20125
+ var USED_CRITICAL_PERCENT = 95;
20126
+ var USED_ELEVATED_PERCENT = 80;
20127
+ function quotaWindowCadence(durationMs) {
20128
+ if (durationMs <= CADENCE_SESSION_MAX_MS) return "session";
20129
+ if (durationMs <= CADENCE_DAILY_MAX_MS) return "daily";
20130
+ if (durationMs <= CADENCE_WEEKLY_MAX_MS) return "weekly";
20131
+ return "monthly";
20132
+ }
20133
+ function windowPressure(usedPercent, paceRatio) {
20134
+ if (usedPercent >= USED_CRITICAL_PERCENT || paceRatio !== void 0 && paceRatio >= PACE_CRITICAL) {
20135
+ return "critical";
19684
20136
  }
19685
- };
19686
- function credentialRecord(value) {
19687
- return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
20137
+ if (usedPercent >= USED_ELEVATED_PERCENT || paceRatio !== void 0 && paceRatio >= PACE_ELEVATED) {
20138
+ return "elevated";
20139
+ }
20140
+ return "ok";
19688
20141
  }
19689
- function optionalTrimmedString(value) {
19690
- if (typeof value !== "string") return void 0;
19691
- const trimmed = value.trim();
19692
- return trimmed.length > 0 ? trimmed : void 0;
20142
+ function deriveQuotaWindowRisk(window, at) {
20143
+ const durationMs = window.period?.durationMs;
20144
+ if (typeof durationMs !== "number" || !Number.isFinite(durationMs) || durationMs <= 0) {
20145
+ return { pressure: windowPressure(window.usedPercent, void 0) };
20146
+ }
20147
+ const startsAt = window.period?.startsAt ?? (window.resetsAt !== void 0 && window.resetsAt > durationMs ? window.resetsAt - durationMs : void 0);
20148
+ const resetBoundary = window.resetsAt ?? (startsAt !== void 0 ? startsAt + durationMs : void 0);
20149
+ const stale = resetBoundary !== void 0 && at > resetBoundary;
20150
+ let elapsedFraction;
20151
+ let paceRatio;
20152
+ let projectedExhaustionAt;
20153
+ if (startsAt !== void 0 && resetBoundary !== void 0 && !stale && at > startsAt) {
20154
+ const elapsed = Math.min(1, (at - startsAt) / durationMs);
20155
+ elapsedFraction = Math.round(elapsed * 100) / 100;
20156
+ if (elapsed >= MIN_ELAPSED_FRACTION) {
20157
+ const used = Math.min(1, Math.max(0, window.usedPercent / 100));
20158
+ paceRatio = Math.round(used / elapsed * 100) / 100;
20159
+ if (used > 0 && used < 1) {
20160
+ const exhaustionAt = startsAt + Math.round((at - startsAt) / used);
20161
+ if (exhaustionAt < resetBoundary) projectedExhaustionAt = exhaustionAt;
20162
+ }
20163
+ }
20164
+ }
20165
+ return {
20166
+ cadence: quotaWindowCadence(durationMs),
20167
+ ...elapsedFraction !== void 0 ? { elapsedFraction } : {},
20168
+ ...paceRatio !== void 0 ? { paceRatio } : {},
20169
+ ...projectedExhaustionAt !== void 0 ? { projectedExhaustionAt } : {},
20170
+ recoveryHalfLifeMs: Math.round(durationMs / 2),
20171
+ pressure: windowPressure(window.usedPercent, paceRatio)
20172
+ };
19693
20173
  }
19694
20174
  function optionalString(value) {
19695
20175
  return typeof value === "string" && value.length > 0 ? value : void 0;
@@ -19730,9 +20210,9 @@ async function resolveClaudeCredentials(deps) {
19730
20210
  } catch {
19731
20211
  }
19732
20212
  }
19733
- const configDir = deps.env.CLAUDE_CONFIG_DIR || path32.join(deps.homedir(), ".claude");
20213
+ const configDir = deps.env.CLAUDE_CONFIG_DIR || path42.join(deps.homedir(), ".claude");
19734
20214
  try {
19735
- const raw = await deps.readBounded(path32.join(configDir, ".credentials.json"), MAX_CREDENTIAL_BYTES);
20215
+ const raw = await deps.readBounded(path42.join(configDir, ".credentials.json"), MAX_CREDENTIAL_BYTES);
19736
20216
  return raw === null || raw.length > MAX_CREDENTIAL_BYTES ? null : parseClaudeCredentialJson(raw, "file");
19737
20217
  } catch {
19738
20218
  return null;
@@ -19843,7 +20323,7 @@ function optionalNonEmptyString(value) {
19843
20323
  return typeof value === "string" && value.length > 0 ? value : void 0;
19844
20324
  }
19845
20325
  function codexAuthFilePath(deps) {
19846
- return path32.join(deps.env.CODEX_HOME || path32.join(deps.homedir(), ".codex"), "auth.json");
20326
+ return path42.join(deps.env.CODEX_HOME || path42.join(deps.homedir(), ".codex"), "auth.json");
19847
20327
  }
19848
20328
  async function resolveCodexCredentials(deps) {
19849
20329
  try {
@@ -19904,9 +20384,9 @@ function parseResetCredits(payload) {
19904
20384
  for (let index = 0; index < credits.length && index < MAX_CREDIT_ENTRIES; index += 1) {
19905
20385
  const credit = object2(credits[index]);
19906
20386
  if (credit?.status !== "available") continue;
19907
- const expiry2 = safeTimestamp(credit.expires_at);
19908
- if (expiry2 !== void 0 && (nextExpiresAt === void 0 || expiry2 < nextExpiresAt)) {
19909
- nextExpiresAt = expiry2;
20387
+ const expiry3 = safeTimestamp(credit.expires_at);
20388
+ if (expiry3 !== void 0 && (nextExpiresAt === void 0 || expiry3 < nextExpiresAt)) {
20389
+ nextExpiresAt = expiry3;
19910
20390
  }
19911
20391
  }
19912
20392
  return {
@@ -19973,12 +20453,12 @@ function parseCursorCredentialJson(raw, method) {
19973
20453
  function cursorAuthFilePath(deps) {
19974
20454
  const home = deps.homedir();
19975
20455
  if (deps.platform === "win32") {
19976
- return path32.join(deps.env.APPDATA || path32.join(home, "AppData", "Roaming"), "Cursor", "auth.json");
20456
+ return path42.join(deps.env.APPDATA || path42.join(home, "AppData", "Roaming"), "Cursor", "auth.json");
19977
20457
  }
19978
20458
  if (deps.platform === "darwin") {
19979
- return path32.join(home, ".cursor", "auth.json");
20459
+ return path42.join(home, ".cursor", "auth.json");
19980
20460
  }
19981
- return path32.join(deps.env.XDG_CONFIG_HOME || path32.join(home, ".config"), "cursor", "auth.json");
20461
+ return path42.join(deps.env.XDG_CONFIG_HOME || path42.join(home, ".config"), "cursor", "auth.json");
19982
20462
  }
19983
20463
  async function resolveCursorCredentials(deps) {
19984
20464
  if (deps.platform === "darwin") {
@@ -20251,9 +20731,9 @@ var XAI_CLI_REFRESH_BUFFER_MS = 5 * 60 * 1e3;
20251
20731
  var REFRESH_TIMEOUT_MS = 15e3;
20252
20732
  var FALLBACK_ACCESS_TOKEN_TTL_MS = 36e5;
20253
20733
  function xaiCliAuthFilePath(deps) {
20254
- return path32.join(deps.env.GROK_HOME || path32.join(deps.homedir(), ".grok"), "auth.json");
20734
+ return path42.join(deps.env.GROK_HOME || path42.join(deps.homedir(), ".grok"), "auth.json");
20255
20735
  }
20256
- function expiry(value) {
20736
+ function expiry2(value) {
20257
20737
  if (typeof value !== "string" && typeof value !== "number") return void 0;
20258
20738
  const parsed = typeof value === "number" ? value : Date.parse(value);
20259
20739
  if (!Number.isFinite(parsed)) return void 0;
@@ -20273,7 +20753,7 @@ function jwtExpiry(token) {
20273
20753
  }
20274
20754
  }
20275
20755
  function effectiveExpiry(entry, accessToken) {
20276
- const fromEntry = expiry(entry.expires_at) ?? expiry(entry.expires);
20756
+ const fromEntry = expiry2(entry.expires_at) ?? expiry2(entry.expires);
20277
20757
  const fromJwt = jwtExpiry(accessToken);
20278
20758
  if (fromEntry !== void 0 && fromJwt !== void 0) return Math.min(fromEntry, fromJwt);
20279
20759
  return fromEntry ?? fromJwt;
@@ -20532,7 +21012,8 @@ function createAiGatewayQuotaCollectors(deps) {
20532
21012
  fetchCursor: () => fetchCursorUsage(providerDeps),
20533
21013
  fetchKimi: () => fetchKimiUsage(providerDeps),
20534
21014
  fetchOpencode: () => fetchOpencodeUsage(providerDeps),
20535
- fetchXai: () => fetchXaiUsage(providerDeps)
21015
+ fetchXai: () => fetchXaiUsage(providerDeps),
21016
+ fetchAntigravity: () => fetchAntigravityUsage(providerDeps)
20536
21017
  };
20537
21018
  }
20538
21019
  function isProviderSuccess(value) {
@@ -20546,7 +21027,8 @@ function createQuotaService(deps) {
20546
21027
  cursor: deps.fetchCursor,
20547
21028
  kimi: deps.fetchKimi,
20548
21029
  opencode: deps.fetchOpencode,
20549
- xai: deps.fetchXai ?? (async () => ({ status: "signed_out" }))
21030
+ xai: deps.fetchXai ?? (async () => ({ status: "signed_out" })),
21031
+ antigravity: deps.fetchAntigravity ?? (async () => ({ status: "signed_out" }))
20550
21032
  };
20551
21033
  const cache = /* @__PURE__ */ new Map();
20552
21034
  const lastGood = /* @__PURE__ */ new Map();
@@ -20589,13 +21071,14 @@ function createQuotaService(deps) {
20589
21071
  }
20590
21072
  return {
20591
21073
  async getSummary(options = {}) {
20592
- const [claude, codex, cursor, kimi, opencode, xai] = await Promise.all([
21074
+ const [claude, codex, cursor, kimi, opencode, xai, antigravity] = await Promise.all([
20593
21075
  load("claude", options.force === true || options.forceProvider === "claude"),
20594
21076
  load("codex", options.force === true || options.forceProvider === "codex"),
20595
21077
  load("cursor", options.force === true || options.forceProvider === "cursor"),
20596
21078
  load("kimi", options.force === true || options.forceProvider === "kimi"),
20597
21079
  load("opencode", options.force === true || options.forceProvider === "opencode"),
20598
- load("xai", options.force === true || options.forceProvider === "xai")
21080
+ load("xai", options.force === true || options.forceProvider === "xai"),
21081
+ load("antigravity", options.force === true || options.forceProvider === "antigravity")
20599
21082
  ]);
20600
21083
  return {
20601
21084
  providers: {
@@ -20604,7 +21087,8 @@ function createQuotaService(deps) {
20604
21087
  cursor: withRisk(cursor),
20605
21088
  kimi: withRisk(kimi),
20606
21089
  opencode: withRisk(opencode),
20607
- xai: withRisk(xai)
21090
+ xai: withRisk(xai),
21091
+ antigravity: withRisk(antigravity)
20608
21092
  }
20609
21093
  };
20610
21094
  }
@@ -21470,7 +21954,7 @@ messageDesc(cursorAgentFile, 70);
21470
21954
  new Set(REASONING_EFFORTS);
21471
21955
 
21472
21956
  // ../fleet-plugins/quota/provider-order.ts
21473
- var PROVIDER_ORDER_DEFAULT = ["claude", "codex", "xai", "cursor", "opencode", "kimi"];
21957
+ var PROVIDER_ORDER_DEFAULT = ["claude", "codex", "xai", "cursor", "opencode", "kimi", "antigravity"];
21474
21958
  function isProviderId(value) {
21475
21959
  return PROVIDER_ORDER_DEFAULT.includes(value);
21476
21960
  }