@cortexkit/opencode-antigravity-auth 3.0.8 → 3.0.10

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 (145) hide show
  1. package/dist/cli.js +584 -189
  2. package/dist/cli.js.map +4 -4
  3. package/dist/cli.meta.json +122 -48
  4. package/dist/index.js +920 -336
  5. package/dist/index.js.map +4 -4
  6. package/dist/index.meta.json +141 -64
  7. package/dist/server.js +954 -368
  8. package/dist/server.js.map +4 -4
  9. package/dist/server.meta.json +1 -1
  10. package/dist/src/common-auth-embedded/auth-menu/login.d.ts +6 -10
  11. package/dist/src/common-auth-embedded/auth-menu/login.js +14 -11
  12. package/dist/src/common-auth-embedded/claustrum/consumer.d.ts +8 -2
  13. package/dist/src/common-auth-embedded/claustrum/consumer.js +64 -21
  14. package/dist/src/common-auth-embedded/claustrum/index.d.ts +2 -1
  15. package/dist/src/common-auth-embedded/claustrum/index.js +1 -0
  16. package/dist/src/common-auth-embedded/claustrum/insula.d.ts +23 -0
  17. package/dist/src/common-auth-embedded/claustrum/insula.js +64 -2
  18. package/dist/src/common-auth-embedded/claustrum/quota-writer.d.ts +18 -0
  19. package/dist/src/common-auth-embedded/claustrum/quota-writer.js +253 -0
  20. package/dist/src/common-auth-embedded/claustrum/roster.d.ts +18 -2
  21. package/dist/src/common-auth-embedded/claustrum/roster.js +100 -43
  22. package/dist/src/common-auth-embedded/fs/with-lock.d.ts +1 -0
  23. package/dist/src/common-auth-embedded/fs/with-lock.js +2 -0
  24. package/dist/src/common-auth-embedded/quota/format.d.ts +19 -0
  25. package/dist/src/common-auth-embedded/quota/format.js +50 -5
  26. package/dist/src/common-auth-embedded/quota/index.d.ts +3 -3
  27. package/dist/src/common-auth-embedded/quota/index.js +2 -2
  28. package/dist/src/common-auth-embedded/quota/map.d.ts +24 -1
  29. package/dist/src/common-auth-embedded/quota/map.js +31 -6
  30. package/dist/src/common-auth-embedded/quota/merge.d.ts +6 -1
  31. package/dist/src/common-auth-embedded/quota/merge.js +17 -3
  32. package/dist/src/common-auth-embedded/quota/projection.d.ts +3 -1
  33. package/dist/src/common-auth-embedded/quota/projection.js +3 -1
  34. package/dist/src/common-auth-embedded/setup/process-fence.d.ts +7 -0
  35. package/dist/src/common-auth-embedded/setup/process-fence.js +5 -3
  36. package/dist/src/common-auth-embedded/source-output.json +95 -79
  37. package/dist/src/plugin/background-vault-quota-refresh.d.ts.map +1 -1
  38. package/dist/src/plugin/background-vault-quota-refresh.js +8 -1
  39. package/dist/src/plugin/background-vault-quota-refresh.js.map +1 -1
  40. package/dist/src/plugin/index.d.ts.map +1 -1
  41. package/dist/src/plugin/index.js +1 -0
  42. package/dist/src/plugin/index.js.map +1 -1
  43. package/dist/src/plugin/quota.d.ts +1 -1
  44. package/dist/src/plugin/quota.d.ts.map +1 -1
  45. package/dist/src/plugin/quota.js +17 -5
  46. package/dist/src/plugin/quota.js.map +1 -1
  47. package/dist/src/plugin/request-helpers.d.ts +5 -0
  48. package/dist/src/plugin/request-helpers.d.ts.map +1 -1
  49. package/dist/src/plugin/request-helpers.js +1 -0
  50. package/dist/src/plugin/request-helpers.js.map +1 -1
  51. package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
  52. package/dist/src/plugin/shared/request-services.js +123 -5
  53. package/dist/src/plugin/shared/request-services.js.map +1 -1
  54. package/dist/src/plugin/shared/vault-request-credentials.d.ts +9 -6
  55. package/dist/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
  56. package/dist/src/plugin/shared/vault-request-credentials.js +9 -4
  57. package/dist/src/plugin/shared/vault-request-credentials.js.map +1 -1
  58. package/dist/src/plugin/vault-custody.d.ts +2 -0
  59. package/dist/src/plugin/vault-custody.d.ts.map +1 -1
  60. package/dist/src/plugin/vault-custody.js +9 -0
  61. package/dist/src/plugin/vault-custody.js.map +1 -1
  62. package/dist/src/plugin/vault-insula-quota.d.ts +6 -0
  63. package/dist/src/plugin/vault-insula-quota.d.ts.map +1 -0
  64. package/dist/src/plugin/vault-insula-quota.js +50 -0
  65. package/dist/src/plugin/vault-insula-quota.js.map +1 -0
  66. package/dist/src/plugin/vault-quota-outcome.d.ts +1 -1
  67. package/dist/src/plugin/vault-quota-outcome.d.ts.map +1 -1
  68. package/dist/src/plugin/vault-quota-outcome.js.map +1 -1
  69. package/dist/tui-build-map.json +21 -21
  70. package/dist/tui-ga-build-map.json +21 -21
  71. package/dist/types/src/common-auth-embedded/claustrum/consumer.d.ts +8 -2
  72. package/dist/types/src/common-auth-embedded/claustrum/index.d.ts +2 -1
  73. package/dist/types/src/common-auth-embedded/claustrum/insula.d.ts +23 -0
  74. package/dist/types/src/common-auth-embedded/claustrum/quota-writer.d.ts +18 -0
  75. package/dist/types/src/common-auth-embedded/claustrum/roster.d.ts +18 -2
  76. package/dist/types/src/common-auth-embedded/quota/format.d.ts +19 -0
  77. package/dist/types/src/common-auth-embedded/quota/index.d.ts +3 -3
  78. package/dist/types/src/common-auth-embedded/quota/map.d.ts +24 -1
  79. package/dist/types/src/common-auth-embedded/quota/merge.d.ts +6 -1
  80. package/dist/types/src/common-auth-embedded/quota/projection.d.ts +3 -1
  81. package/dist/types/src/common-auth-embedded/setup/process-fence.d.ts +7 -0
  82. package/dist/types/src/plugin/background-vault-quota-refresh.d.ts.map +1 -1
  83. package/dist/types/src/plugin/config/schema.d.ts +2 -2
  84. package/dist/types/src/plugin/index.d.ts.map +1 -1
  85. package/dist/types/src/plugin/quota.d.ts +1 -1
  86. package/dist/types/src/plugin/quota.d.ts.map +1 -1
  87. package/dist/types/src/plugin/request-helpers.d.ts +5 -0
  88. package/dist/types/src/plugin/request-helpers.d.ts.map +1 -1
  89. package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -1
  90. package/dist/types/src/plugin/shared/vault-request-credentials.d.ts +9 -6
  91. package/dist/types/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
  92. package/dist/types/src/plugin/vault-custody.d.ts +2 -0
  93. package/dist/types/src/plugin/vault-custody.d.ts.map +1 -1
  94. package/dist/types/src/plugin/vault-insula-quota.d.ts +6 -0
  95. package/dist/types/src/plugin/vault-insula-quota.d.ts.map +1 -0
  96. package/dist/types/src/plugin/vault-quota-outcome.d.ts +1 -1
  97. package/dist/types/src/plugin/vault-quota-outcome.d.ts.map +1 -1
  98. package/package.json +2 -2
  99. package/src/common-auth-embedded/auth-menu/login.d.ts +6 -10
  100. package/src/common-auth-embedded/auth-menu/login.js +14 -11
  101. package/src/common-auth-embedded/claustrum/consumer.d.ts +8 -2
  102. package/src/common-auth-embedded/claustrum/consumer.js +64 -21
  103. package/src/common-auth-embedded/claustrum/index.d.ts +2 -1
  104. package/src/common-auth-embedded/claustrum/index.js +1 -0
  105. package/src/common-auth-embedded/claustrum/insula.d.ts +23 -0
  106. package/src/common-auth-embedded/claustrum/insula.js +64 -2
  107. package/src/common-auth-embedded/claustrum/quota-writer.d.ts +18 -0
  108. package/src/common-auth-embedded/claustrum/quota-writer.js +253 -0
  109. package/src/common-auth-embedded/claustrum/roster.d.ts +18 -2
  110. package/src/common-auth-embedded/claustrum/roster.js +100 -43
  111. package/src/common-auth-embedded/fs/with-lock.d.ts +1 -0
  112. package/src/common-auth-embedded/fs/with-lock.js +2 -0
  113. package/src/common-auth-embedded/quota/format.d.ts +19 -0
  114. package/src/common-auth-embedded/quota/format.js +50 -5
  115. package/src/common-auth-embedded/quota/index.d.ts +3 -3
  116. package/src/common-auth-embedded/quota/index.js +2 -2
  117. package/src/common-auth-embedded/quota/map.d.ts +24 -1
  118. package/src/common-auth-embedded/quota/map.js +31 -6
  119. package/src/common-auth-embedded/quota/merge.d.ts +6 -1
  120. package/src/common-auth-embedded/quota/merge.js +17 -3
  121. package/src/common-auth-embedded/quota/projection.d.ts +3 -1
  122. package/src/common-auth-embedded/quota/projection.js +3 -1
  123. package/src/common-auth-embedded/setup/process-fence.d.ts +7 -0
  124. package/src/common-auth-embedded/setup/process-fence.js +5 -3
  125. package/src/common-auth-embedded/source-output.json +95 -79
  126. package/src/tui-compiled/common-auth-embedded/quota/format.js +50 -5
  127. package/src/tui-compiled/common-auth-embedded/quota/index.js +2 -2
  128. package/src/tui-compiled/common-auth-embedded/quota/map.js +31 -6
  129. package/src/tui-compiled/common-auth-embedded/quota/merge.js +17 -3
  130. package/src/tui-compiled/common-auth-embedded/quota/projection.js +3 -1
  131. package/src/tui-ga-compiled/shared/1ff34afa7c42d196-projection.js +3 -1
  132. package/src/tui-ga-compiled/shared/77138df80c7ae006-map.js +31 -6
  133. package/src/tui-ga-compiled/shared/aef2402f8fc342f0-format.js +50 -5
  134. package/src/tui-ga-compiled/shared/bf17cbee28e58197-index.js +2 -2
  135. package/src/tui-ga-compiled/shared/ecc214300932dfb6-merge.js +17 -3
  136. package/src/tui-ga-raw/shared/1ff34afa7c42d196-projection.js +3 -1
  137. package/src/tui-ga-raw/shared/77138df80c7ae006-map.js +31 -6
  138. package/src/tui-ga-raw/shared/aef2402f8fc342f0-format.js +50 -5
  139. package/src/tui-ga-raw/shared/bf17cbee28e58197-index.js +2 -2
  140. package/src/tui-ga-raw/shared/ecc214300932dfb6-merge.js +17 -3
  141. package/src/tui-raw/common-auth-embedded/quota/format.js +50 -5
  142. package/src/tui-raw/common-auth-embedded/quota/index.js +2 -2
  143. package/src/tui-raw/common-auth-embedded/quota/map.js +31 -6
  144. package/src/tui-raw/common-auth-embedded/quota/merge.js +17 -3
  145. package/src/tui-raw/common-auth-embedded/quota/projection.js +3 -1
package/dist/index.js CHANGED
@@ -64,6 +64,12 @@ function isQuotaCounter(value) {
64
64
  function isQuotaCounters(value) {
65
65
  return isRecord2(value) && Object.values(value).every(isQuotaCounter);
66
66
  }
67
+ function isBoolean(value) {
68
+ return typeof value === "boolean";
69
+ }
70
+ function isQuotaCredits(value) {
71
+ return isRecord2(value) && typeof value.hasCredits === "boolean" && typeof value.unlimited === "boolean" && optional2(value, "balance", isFiniteNumber) && optional2(value, "overageLimitReached", isBoolean) && isFiniteNumber(value.checkedAt);
72
+ }
67
73
  function readQuotaCounters(value) {
68
74
  if (!isRecord2(value))
69
75
  return void 0;
@@ -75,11 +81,16 @@ function decodeQuotaMap(value) {
75
81
  return value;
76
82
  if (!isRecord2(value))
77
83
  return void 0;
78
- const { counters: rawCounters, ...rest } = value;
84
+ const { counters: rawCounters, credits: rawCredits, ...rest } = value;
79
85
  if (!isQuotaMap(rest))
80
86
  return void 0;
81
87
  const counters = readQuotaCounters(rawCounters);
82
- return { ...rest, ...counters === void 0 ? {} : { counters } };
88
+ const credits = isQuotaCredits(rawCredits) ? rawCredits : void 0;
89
+ return {
90
+ ...rest,
91
+ ...counters === void 0 ? {} : { counters },
92
+ ...credits === void 0 ? {} : { credits }
93
+ };
83
94
  }
84
95
  function isQuotaMap(value) {
85
96
  if (!isRecord2(value) || !Array.isArray(value.limits))
@@ -93,7 +104,7 @@ function isQuotaMap(value) {
93
104
  return false;
94
105
  seen.add(key);
95
106
  }
96
- return optional2(value, "budget", isCreditBudgetEntry) && optional2(value, "counters", isQuotaCounters);
107
+ return optional2(value, "budget", isCreditBudgetEntry) && optional2(value, "counters", isQuotaCounters) && optional2(value, "credits", isQuotaCredits);
97
108
  }
98
109
  var ALL_SCOPE, DEFAULT_REQUIRED_LABELS;
99
110
  var init_map = __esm({
@@ -156,7 +167,7 @@ function isQuotaObservation(value) {
156
167
  }
157
168
  if (!coverage.every(isObservedPair))
158
169
  return false;
159
- return (value.budget === void 0 || isObservedBudget(value.budget)) && (value.counters === void 0 || isQuotaCounters(value.counters));
170
+ return (value.budget === void 0 || isObservedBudget(value.budget)) && (value.counters === void 0 || isQuotaCounters(value.counters)) && (value.credits === void 0 || isQuotaCredits(value.credits));
160
171
  }
161
172
  function compareEntries(left, right) {
162
173
  if (left.scope !== right.scope)
@@ -182,6 +193,14 @@ function mergeCounters(stored, observed) {
182
193
  }
183
194
  return counters.size === 0 ? void 0 : Object.fromEntries(counters);
184
195
  }
196
+ function mergeCredits(stored, observed) {
197
+ if (observed === void 0)
198
+ return stored;
199
+ if (stored !== void 0 && observed.checkedAt < stored.checkedAt) {
200
+ return stored;
201
+ }
202
+ return { ...observed };
203
+ }
185
204
  function mergeQuotaObservation(stored, observation) {
186
205
  const decoded = stored === void 0 ? void 0 : decodeQuotaMap(stored);
187
206
  if (stored !== void 0 && decoded === void 0) {
@@ -225,14 +244,16 @@ function mergeQuotaObservation(stored, observation) {
225
244
  const existing = entries.get(key);
226
245
  entries.set(key, existing === void 0 || existing.kind === "absent" ? { scope, label: pair.label, kind: "absent", checkedAt: at } : { scope, label: pair.label, kind: "retired", retiredAt: at });
227
246
  }
228
- const { limits: _limits, budget: _budget, counters: _counters, ...unknownKeys } = base;
247
+ const { limits: _limits, budget: _budget, counters: _counters, credits: _credits, ...unknownKeys } = base;
229
248
  const budget = mergeBudget(base.budget, observation.budget, at);
230
249
  const counters = mergeCounters(base.counters, observation.counters);
250
+ const credits = mergeCredits(base.credits, observation.credits);
231
251
  return {
232
252
  ...unknownKeys,
233
253
  limits: [...entries.values()].sort(compareEntries),
234
254
  ...budget === void 0 ? {} : { budget },
235
- ...counters === void 0 ? {} : { counters }
255
+ ...counters === void 0 ? {} : { counters },
256
+ ...credits === void 0 ? {} : { credits }
236
257
  };
237
258
  }
238
259
  var QuotaCodecError;
@@ -323,16 +344,23 @@ function displayOrder(left, right) {
323
344
  return left.label < right.label ? -1 : left.label > right.label ? 1 : 0;
324
345
  }
325
346
  function quotaWindowParts(quota, options) {
326
- const { windows, age } = scopedWindowParts(quota, options);
327
- const parts = windows.map(({ part }) => part);
347
+ const { windows: windows2, age } = scopedWindowParts(quota, options);
348
+ const parts = windows2.map(({ part }) => part);
328
349
  return age === void 0 ? { windows: parts } : { windows: parts, age };
329
350
  }
351
+ function withShortNames(windows2) {
352
+ const abbreviations = scopeAbbreviations(windows2.filter(({ part, scope }) => part.kind === "window" && scope !== ALL_SCOPE).map(({ scope }) => scope));
353
+ for (const window of windows2) {
354
+ window.part.short = window.part.kind === "budget" ? "cr" : window.scope === ALL_SCOPE ? window.part.name : abbreviations.get(window.scope) ?? window.scope;
355
+ }
356
+ return windows2;
357
+ }
330
358
  function scopedWindowParts(quota, options) {
331
359
  if (!quota)
332
360
  return { windows: [] };
333
361
  const { now } = options;
334
362
  const readings = quota.limits.filter((limit) => limit.kind === "reading" && limit.remainingPercent !== void 0).sort(displayOrder);
335
- const windows = readings.map((limit) => {
363
+ const windows2 = readings.map((limit) => {
336
364
  const remainingPercent = clampPercent(limit.remainingPercent ?? 0);
337
365
  return {
338
366
  scope: limit.scope,
@@ -340,6 +368,7 @@ function scopedWindowParts(quota, options) {
340
368
  part: {
341
369
  kind: "window",
342
370
  name: quotaWindowName(limit),
371
+ short: "",
343
372
  figure: percentLeft(limit.remainingPercent ?? 0),
344
373
  remainingPercent,
345
374
  checkedAt: limit.checkedAt,
@@ -351,12 +380,13 @@ function scopedWindowParts(quota, options) {
351
380
  if (budget) {
352
381
  const remainingPercent = budget.remainingPercent;
353
382
  const figure = budget.reached ? "credits spent" : remainingPercent !== void 0 ? `credits ${percentLeft(remainingPercent)}` : "credits available";
354
- windows.push({
383
+ windows2.push({
355
384
  scope: ALL_SCOPE,
356
385
  spent: budget.reached,
357
386
  part: {
358
387
  kind: "budget",
359
388
  name: "credits",
389
+ short: "",
360
390
  figure,
361
391
  ...remainingPercent === void 0 ? {} : { remainingPercent: clampPercent(remainingPercent) },
362
392
  checkedAt: budget.checkedAt,
@@ -364,13 +394,14 @@ function scopedWindowParts(quota, options) {
364
394
  }
365
395
  });
366
396
  }
367
- if (windows.length > 0) {
368
- const age = now - Math.min(...windows.map(({ part }) => part.checkedAt));
397
+ withShortNames(windows2);
398
+ if (windows2.length > 0) {
399
+ const age = now - Math.min(...windows2.map(({ part }) => part.checkedAt));
369
400
  if (age > (options.staleAfterMs ?? QUOTA_STALE_AFTER_MS)) {
370
- return { windows, age: `checked ${shortSpan(age)} ago` };
401
+ return { windows: windows2, age: `checked ${shortSpan(age)} ago` };
371
402
  }
372
403
  }
373
- return { windows };
404
+ return { windows: windows2 };
374
405
  }
375
406
  function isQuotaStale(quota, options) {
376
407
  return scopedWindowParts(quota, options).age !== void 0;
@@ -410,10 +441,10 @@ function groupShortNames(groups) {
410
441
  const short = scopeAbbreviations(labels);
411
442
  return labels.map((label) => short.get(label) ?? label);
412
443
  }
413
- function groupedNarrowPieces(groups, windows) {
444
+ function groupedNarrowPieces(groups, windows2) {
414
445
  if (!groups || groups.length === 0)
415
446
  return void 0;
416
- const reported = windows.filter(({ part }) => part.kind === "window");
447
+ const reported = windows2.filter(({ part }) => part.kind === "window");
417
448
  if (reported.some(({ scope }) => scope === ALL_SCOPE))
418
449
  return void 0;
419
450
  const candidates = groups.flatMap((group, listed) => {
@@ -437,21 +468,20 @@ function groupedNarrowPieces(groups, windows) {
437
468
  });
438
469
  }
439
470
  function narrowTextParts(quota, options) {
440
- const { windows } = scopedWindowParts(quota, options);
441
- const grouped = groupedNarrowPieces(quota?.groups, windows);
471
+ const { windows: windows2 } = scopedWindowParts(quota, options);
472
+ const grouped = groupedNarrowPieces(quota?.groups, windows2);
442
473
  if (grouped)
443
474
  return grouped;
444
- const general = windows.filter(({ part, scope }) => part.kind === "window" && scope === ALL_SCOPE);
445
- const scoped = windows.filter(({ part, scope }) => part.kind === "window" && scope !== ALL_SCOPE);
446
- const abbreviations = scopeAbbreviations(scoped.map(({ scope }) => scope));
447
- const budget = windows.find(({ part }) => part.kind === "budget");
475
+ const general = windows2.filter(({ part, scope }) => part.kind === "window" && scope === ALL_SCOPE);
476
+ const scoped = windows2.filter(({ part, scope }) => part.kind === "window" && scope !== ALL_SCOPE);
477
+ const budget = windows2.find(({ part }) => part.kind === "budget");
448
478
  const budgetLeft = budget?.spent ? 0 : budget?.part.remainingPercent;
449
479
  const extras = [
450
- ...scoped.map(({ scope, part }) => ({
451
- label: abbreviations.get(scope) ?? scope,
480
+ ...scoped.map(({ part }) => ({
481
+ label: part.short,
452
482
  remaining: part.remainingPercent ?? 0
453
483
  })),
454
- ...budgetLeft === void 0 ? [] : [{ label: "cr", remaining: budgetLeft }]
484
+ ...budgetLeft === void 0 || budget === void 0 ? [] : [{ label: budget.part.short, remaining: budgetLeft }]
455
485
  ];
456
486
  const tightest = extras.reduce((best, item) => best === void 0 || item.remaining < best.remaining ? item : best, void 0);
457
487
  const pieces = general.map(({ part }) => `${part.name} ${wholePercent(part.remainingPercent ?? 0)}%`);
@@ -459,7 +489,7 @@ function narrowTextParts(quota, options) {
459
489
  pieces.push(`${tightest.label} ${wholePercent(tightest.remaining)}%`);
460
490
  }
461
491
  if (pieces.length === 0)
462
- return windows.map(({ part }) => part.figure);
492
+ return windows2.map(({ part }) => part.figure);
463
493
  return pieces.map((piece, index) => index === pieces.length - 1 ? `${piece} left` : piece);
464
494
  }
465
495
  function quotaTextParts(quota, options) {
@@ -479,6 +509,16 @@ function formatQuota(quota, options) {
479
509
  return parts.join(" \xB7 ");
480
510
  return quota && quota.limits.length > 0 ? NO_LIMITS_REPORTED : NO_QUOTA_READING;
481
511
  }
512
+ function quotaCreditsText(credits) {
513
+ if (credits === void 0)
514
+ return void 0;
515
+ if (credits.unlimited)
516
+ return "Unlimited";
517
+ if (!credits.hasCredits)
518
+ return void 0;
519
+ const { balance } = credits;
520
+ return typeof balance === "number" && Number.isFinite(balance) && balance > 0 ? `${Math.round(balance)} credits` : "Available";
521
+ }
482
522
  var QUOTA_STALE_AFTER_MS, NO_QUOTA_READING, NO_LIMITS_REPORTED, NARROW_GROUP_LIMIT;
483
523
  var init_format = __esm({
484
524
  "../core/dist/common-auth-embedded/quota/format.js"() {
@@ -560,12 +600,14 @@ function projectQuota(map, scope = ALL_SCOPE) {
560
600
  const checkedAt = stamped.length > 0 ? Math.min(...stamped.map((limit) => limit.checkedAt)) : void 0;
561
601
  const budget = map?.budget?.kind === "reading" ? projectBudget(map.budget) : void 0;
562
602
  const counters = readQuotaCounters(map?.counters);
603
+ const credits = isQuotaCredits(map?.credits) ? map.credits : void 0;
563
604
  return {
564
605
  scope,
565
606
  limits,
566
607
  ...checkedAt === void 0 ? {} : { checkedAt },
567
608
  ...budget === void 0 ? {} : { budget },
568
- ...counters === void 0 ? {} : { counters }
609
+ ...counters === void 0 ? {} : { counters },
610
+ ...credits === void 0 ? {} : { credits }
569
611
  };
570
612
  }
571
613
  function budgetExhaustedResetAt(quota, now) {
@@ -608,12 +650,14 @@ __export(quota_exports, {
608
650
  emptyQuotaMap: () => emptyQuotaMap,
609
651
  formatQuota: () => formatQuota,
610
652
  futureResetAt: () => futureResetAt,
653
+ isQuotaCredits: () => isQuotaCredits,
611
654
  isQuotaMap: () => isQuotaMap,
612
655
  isQuotaObservation: () => isQuotaObservation,
613
656
  isQuotaStale: () => isQuotaStale,
614
657
  mergeQuotaObservation: () => mergeQuotaObservation,
615
658
  projectQuota: () => projectQuota,
616
659
  quotaCodec: () => quotaCodec2,
660
+ quotaCreditsText: () => quotaCreditsText,
617
661
  quotaTextParts: () => quotaTextParts,
618
662
  quotaWindowName: () => quotaWindowName,
619
663
  quotaWindowParts: () => quotaWindowParts,
@@ -1114,8 +1158,8 @@ async function acquireRefreshFileLockWithClock(options) {
1114
1158
  let releaseConfirmed = false;
1115
1159
  let loss;
1116
1160
  let resolveLoss;
1117
- const lostPromise = new Promise((resolve18) => {
1118
- resolveLoss = resolve18;
1161
+ const lostPromise = new Promise((resolve20) => {
1162
+ resolveLoss = resolve20;
1119
1163
  });
1120
1164
  function notifyTimerStep(event) {
1121
1165
  try {
@@ -1272,7 +1316,7 @@ async function acquireRefreshFileLockWithClock(options) {
1272
1316
  }
1273
1317
  }
1274
1318
  async function backoff() {
1275
- await new Promise((resolve18) => setTimeout(resolve18, Math.floor(Math.random() * 4)));
1319
+ await new Promise((resolve20) => setTimeout(resolve20, Math.floor(Math.random() * 4)));
1276
1320
  }
1277
1321
  async function readLockState(notifyReady = true) {
1278
1322
  if (notifyReady && options.onStep)
@@ -1722,6 +1766,7 @@ function lockPathFor(target, name) {
1722
1766
  async function withLock(target, options, fn) {
1723
1767
  const started = performance.now();
1724
1768
  for (; ; ) {
1769
+ options.signal?.throwIfAborted();
1725
1770
  const lock = await acquireRefreshFileLock({
1726
1771
  path: target,
1727
1772
  name: options.name,
@@ -1732,6 +1777,7 @@ async function withLock(target, options, fn) {
1732
1777
  });
1733
1778
  if (lock) {
1734
1779
  try {
1780
+ options.signal?.throwIfAborted();
1735
1781
  return await fn(lock);
1736
1782
  } finally {
1737
1783
  await lock.release();
@@ -1745,7 +1791,7 @@ async function withLock(target, options, fn) {
1745
1791
  timeoutMs: options.timeoutMs
1746
1792
  });
1747
1793
  }
1748
- await new Promise((resolve18) => setTimeout(resolve18, Math.min(25, Math.ceil(remaining))));
1794
+ await new Promise((resolve20) => setTimeout(resolve20, Math.min(25, Math.ceil(remaining))));
1749
1795
  }
1750
1796
  }
1751
1797
  var LockContentionError, LockOwnershipError;
@@ -1781,13 +1827,13 @@ function assertNotInsideHook(operation) {
1781
1827
  function runInsideHook(operation, fn) {
1782
1828
  return insideHook.run(operation, async () => await fn());
1783
1829
  }
1784
- async function callFailureHook(operation, hook, rowId2, error, logger2) {
1830
+ async function callFailureHook(operation, hook, rowId2, error, logger3) {
1785
1831
  if (!hook)
1786
1832
  return;
1787
1833
  try {
1788
1834
  await runInsideHook(operation, () => hook(rowId2, error));
1789
1835
  } catch (hookError) {
1790
- logger2?.warn("store failure hook threw; the original failure stands", {
1836
+ logger3?.warn("store failure hook threw; the original failure stands", {
1791
1837
  operation,
1792
1838
  rowId: rowId2,
1793
1839
  error: hookError instanceof Error ? hookError.message : String(hookError)
@@ -1864,7 +1910,7 @@ async function acquirePoolLock(spec, defaults, env3) {
1864
1910
  });
1865
1911
  }
1866
1912
  const jitter = Math.floor(Math.random() * (options.retryMs + 1));
1867
- await new Promise((resolve18) => setTimeout(resolve18, Math.min(options.retryMs + jitter, remaining)));
1913
+ await new Promise((resolve20) => setTimeout(resolve20, Math.min(options.retryMs + jitter, remaining)));
1868
1914
  }
1869
1915
  }
1870
1916
  function definedOnly(spec) {
@@ -2942,11 +2988,11 @@ var init_mutate = __esm({
2942
2988
  if (isRecord4(this.state.accounts) && Object.hasOwn(this.state.accounts, id))
2943
2989
  delete this.state.accounts[id];
2944
2990
  }
2945
- setStateAccount(id, fields) {
2991
+ setStateAccount(id, fields2) {
2946
2992
  if (!isRecord4(this.state.accounts))
2947
2993
  this.state.accounts = {};
2948
2994
  Object.defineProperty(this.state.accounts, id, {
2949
- value: fields,
2995
+ value: fields2,
2950
2996
  enumerable: true,
2951
2997
  writable: true,
2952
2998
  configurable: true
@@ -4495,12 +4541,12 @@ var init_pull = __esm({
4495
4541
  firedAtLoad;
4496
4542
  logger;
4497
4543
  inflight = /* @__PURE__ */ new Set();
4498
- constructor(rt, hook, onFailure, firedAtLoad, logger2) {
4544
+ constructor(rt, hook, onFailure, firedAtLoad, logger3) {
4499
4545
  this.rt = rt;
4500
4546
  this.hook = hook;
4501
4547
  this.onFailure = onFailure;
4502
4548
  this.firedAtLoad = firedAtLoad;
4503
- this.logger = logger2;
4549
+ this.logger = logger3;
4504
4550
  }
4505
4551
  fire(id, reason) {
4506
4552
  if (!this.hook)
@@ -5582,15 +5628,15 @@ function createRedactor(options = {}) {
5582
5628
  return SECRET_KEY_EXACT.test(key) || normalized.includes("apikey") || normalized.endsWith("secret") || normalized.endsWith("password") || normalized.endsWith("token") && !normalized.endsWith("tokens") || !!options.extraSecretKeys?.(normalized);
5583
5629
  }
5584
5630
  function errorEntries(error) {
5585
- const fields = error;
5631
+ const fields2 = error;
5586
5632
  const entries = [
5587
5633
  ["name", error.name],
5588
5634
  ["message", error.message],
5589
5635
  ["stack", error.stack]
5590
5636
  ];
5591
5637
  for (const key of ["code", "status", "cause"])
5592
- if (fields[key] !== void 0)
5593
- entries.push([key, fields[key]]);
5638
+ if (fields2[key] !== void 0)
5639
+ entries.push([key, fields2[key]]);
5594
5640
  const listed = new Set(entries.map(([key]) => key));
5595
5641
  for (const entry of Object.entries(error))
5596
5642
  if (!listed.has(entry[0]))
@@ -5832,7 +5878,7 @@ function createEngine(options) {
5832
5878
  } catch {
5833
5879
  }
5834
5880
  }
5835
- function schedule() {
5881
+ function schedule2() {
5836
5882
  if (!timer)
5837
5883
  timer = setTimeout(() => {
5838
5884
  timer = void 0;
@@ -5874,7 +5920,7 @@ function createEngine(options) {
5874
5920
  void flushed.catch(() => {
5875
5921
  });
5876
5922
  } else
5877
- schedule();
5923
+ schedule2();
5878
5924
  } catch {
5879
5925
  }
5880
5926
  }
@@ -6745,9 +6791,9 @@ function findAction(sections, request) {
6745
6791
  return actions?.find((action) => action.id === request.actionId);
6746
6792
  }
6747
6793
  function createCommandMenu(options) {
6748
- const logger2 = options.logger ?? createLogger2("commands");
6794
+ const logger3 = options.logger ?? createLogger2("commands");
6749
6795
  const redact3 = createTextRedactor(options.redaction);
6750
- const seam = { logger: logger2, redact: redact3 };
6796
+ const seam = { logger: logger3, redact: redact3 };
6751
6797
  const now = options.now ?? Date.now;
6752
6798
  const extras = options.extras ?? [];
6753
6799
  const replaced = options.replace ?? {};
@@ -6774,7 +6820,7 @@ function createCommandMenu(options) {
6774
6820
  content: await section.build(invocation)
6775
6821
  };
6776
6822
  } catch (error) {
6777
- logger2.warn("command menu section failed to build", {
6823
+ logger3.warn("command menu section failed to build", {
6778
6824
  command: options.command,
6779
6825
  section: id,
6780
6826
  error: redact3(error instanceof Error ? error.message : String(error))
@@ -6861,7 +6907,7 @@ function createCommandMenu(options) {
6861
6907
  };
6862
6908
  } catch (error) {
6863
6909
  const failure2 = projectFailure(error);
6864
- logger2.warn("command menu action failed", {
6910
+ logger3.warn("command menu action failed", {
6865
6911
  command: options.command,
6866
6912
  section: request.sectionId,
6867
6913
  action: request.actionId,
@@ -7227,12 +7273,12 @@ var init_doctor = __esm({
7227
7273
  });
7228
7274
 
7229
7275
  // ../core/dist/common-auth-embedded/auth-menu/login.js
7230
- import { execFileSync as defaultExecFileSync, spawn as defaultSpawn } from "node:child_process";
7231
- function openBrowserForMenu(url, platform = process.platform, execFileSync = defaultExecFileSync, spawn2 = defaultSpawn) {
7276
+ import { spawn as defaultSpawn } from "node:child_process";
7277
+ function openBrowserForMenu(url, platform = process.platform, spawn2 = defaultSpawn) {
7232
7278
  try {
7233
7279
  if (platform === "win32") {
7234
7280
  const command = `Start-Process '${url.replaceAll("'", "''")}'`;
7235
- const child = spawn2("powershell.exe", [
7281
+ const child2 = spawn2("powershell.exe", [
7236
7282
  "-NoProfile",
7237
7283
  "-NonInteractive",
7238
7284
  "-WindowStyle",
@@ -7240,17 +7286,18 @@ function openBrowserForMenu(url, platform = process.platform, execFileSync = def
7240
7286
  "-EncodedCommand",
7241
7287
  Buffer.from(command, "utf16le").toString("base64")
7242
7288
  ], { stdio: "ignore", windowsHide: true });
7243
- child.on("error", () => {
7244
- });
7245
- child.unref();
7246
- return child.pid !== void 0;
7247
- } else {
7248
- execFileSync(platform === "darwin" ? "open" : "xdg-open", [url], {
7249
- stdio: "ignore",
7250
- timeout: 3e3
7289
+ child2.on("error", () => {
7251
7290
  });
7291
+ child2.unref();
7292
+ return child2.pid !== void 0;
7252
7293
  }
7253
- return true;
7294
+ const child = spawn2(platform === "darwin" ? "open" : "xdg-open", [url], {
7295
+ stdio: "ignore"
7296
+ });
7297
+ child.on("error", () => {
7298
+ });
7299
+ child.unref();
7300
+ return child.pid !== void 0;
7254
7301
  } catch {
7255
7302
  return false;
7256
7303
  }
@@ -7472,7 +7519,7 @@ async function select(terminal, items, options) {
7472
7519
  writeLine("");
7473
7520
  renderedLines = lines;
7474
7521
  };
7475
- return new Promise((resolve18) => {
7522
+ return new Promise((resolve20) => {
7476
7523
  const wasRaw = stdin.isRaw ?? false;
7477
7524
  const cleanup2 = () => {
7478
7525
  if (cleaned)
@@ -7492,7 +7539,7 @@ async function select(terminal, items, options) {
7492
7539
  };
7493
7540
  const finish = (value) => {
7494
7541
  cleanup2();
7495
- resolve18(value);
7542
+ resolve20(value);
7496
7543
  };
7497
7544
  const onSignal = () => finish(null);
7498
7545
  const onKey = (data) => {
@@ -7532,7 +7579,7 @@ async function select(terminal, items, options) {
7532
7579
  stdin.setRawMode(true);
7533
7580
  } catch {
7534
7581
  cleanup2();
7535
- resolve18(null);
7582
+ resolve20(null);
7536
7583
  return;
7537
7584
  }
7538
7585
  stdin.resume();
@@ -8523,7 +8570,7 @@ function acquireInsulaQuotaSource(transport, tokenPath) {
8523
8570
  }
8524
8571
  };
8525
8572
  }
8526
- var MINUTE, MAX_AGE, sources, attempts, InsulaQuotaSource;
8573
+ var MINUTE, MAX_AGE, COLD_WAIT, sources, attempts, InsulaQuotaSource;
8527
8574
  var init_insula = __esm({
8528
8575
  "../core/dist/common-auth-embedded/claustrum/insula.js"() {
8529
8576
  "use strict";
@@ -8531,12 +8578,16 @@ var init_insula = __esm({
8531
8578
  init_watch();
8532
8579
  MINUTE = 6e4;
8533
8580
  MAX_AGE = 4 * MINUTE;
8581
+ COLD_WAIT = 2 * MINUTE;
8534
8582
  sources = /* @__PURE__ */ new Map();
8535
8583
  attempts = /* @__PURE__ */ new Map();
8536
8584
  InsulaQuotaSource = class {
8537
8585
  transport;
8538
8586
  key;
8539
8587
  #entries = [];
8588
+ #available = false;
8589
+ #completeProviders = /* @__PURE__ */ new Set();
8590
+ #coldSince = /* @__PURE__ */ new Map();
8540
8591
  /** Every usage.get, polled or watch-driven, shares this one slot. */
8541
8592
  #reads = new CoalescedRead(async () => {
8542
8593
  try {
@@ -8544,8 +8595,14 @@ var init_insula = __esm({
8544
8595
  if (!record2(reply) || !Array.isArray(reply.result) || reply.error !== void 0)
8545
8596
  throw new Error("unavailable insula usage");
8546
8597
  this.#entries = reply.result.filter((entry) => record2(entry) && typeof entry.provider === "string");
8598
+ this.#available = this.#entries.length === reply.result.length && (reply.completeProviders === void 0 || Array.isArray(reply.completeProviders) && reply.completeProviders.every((value) => typeof value === "string"));
8599
+ this.#completeProviders = new Set(this.#available && Array.isArray(reply.completeProviders) ? reply.completeProviders : []);
8600
+ for (const provider2 of this.#completeProviders)
8601
+ this.#coldSince.delete(provider2);
8547
8602
  } catch {
8548
8603
  this.#entries = [];
8604
+ this.#available = false;
8605
+ this.#completeProviders.clear();
8549
8606
  }
8550
8607
  }, () => {
8551
8608
  });
@@ -8724,6 +8781,37 @@ var init_insula = __esm({
8724
8781
  }
8725
8782
  return void 0;
8726
8783
  }
8784
+ /** Cache-only background lookup; current() retains its original miss behavior. */
8785
+ lookup(provider2, accountId, now) {
8786
+ if (!this.#available)
8787
+ return { miss: "unreachable" };
8788
+ const entry = this.#entries.find((value) => value.provider === provider2 && typeof value.account === "string" && value.account.trim() === accountId);
8789
+ const errorClass = (entry ?? this.#entries.find((value) => value.provider === provider2 && value.account === void 0 && value.errorClass !== void 0))?.errorClass;
8790
+ if (errorClass === "upstream_failed")
8791
+ return { miss: "upstream-failed" };
8792
+ if (errorClass === "credential_absent" || errorClass === "credential_unusable" || errorClass === "credential_rejected")
8793
+ return { miss: "credential" };
8794
+ if (errorClass !== void 0)
8795
+ return { miss: "unreachable" };
8796
+ if (entry) {
8797
+ const fetchedAt = typeof entry.fetchedAt === "string" ? Date.parse(entry.fetchedAt) : Number.NaN;
8798
+ if (!record2(entry.usage) || !Number.isFinite(fetchedAt))
8799
+ return { miss: "unreachable" };
8800
+ const reading = {
8801
+ entry,
8802
+ context: {
8803
+ fetchedAt,
8804
+ ...typeof entry.source === "string" && { source: entry.source }
8805
+ }
8806
+ };
8807
+ return now >= fetchedAt + MAX_AGE || entry.stale !== void 0 ? { miss: "stale", reading } : { reading };
8808
+ }
8809
+ if (this.#completeProviders.has(provider2))
8810
+ return { miss: "absent" };
8811
+ const since = this.#coldSince.get(provider2) ?? now;
8812
+ this.#coldSince.set(provider2, since);
8813
+ return { miss: now - since >= COLD_WAIT ? "unreachable" : "cold" };
8814
+ }
8727
8815
  };
8728
8816
  }
8729
8817
  });
@@ -8937,13 +9025,13 @@ async function readBoundedJson(path5) {
8937
9025
  await descriptor.close();
8938
9026
  }
8939
9027
  }
8940
- function accountRecords(text2, fields) {
9028
+ function accountRecords(text2, fields2) {
8941
9029
  const records = [];
8942
9030
  for (const line of text2.split("\n")) {
8943
9031
  if (line.trim() === "" || line.startsWith("#"))
8944
9032
  continue;
8945
9033
  const parts = line.split(":");
8946
- if (parts.length !== fields || !/^[^\s:,]+$/.test(parts[0] ?? "") || !/^\d+$/.test(parts[2] ?? "") || !Number.isSafeInteger(Number(parts[2])) || fields === 7 && (!/^\d+$/.test(parts[3] ?? "") || !Number.isSafeInteger(Number(parts[3]))) || fields === 4 && parts[3] !== "" && !/^[^\s:,]+(?:,[^\s:,]+)*$/.test(parts[3] ?? ""))
9034
+ if (parts.length !== fields2 || !/^[^\s:,]+$/.test(parts[0] ?? "") || !/^\d+$/.test(parts[2] ?? "") || !Number.isSafeInteger(Number(parts[2])) || fields2 === 7 && (!/^\d+$/.test(parts[3] ?? "") || !Number.isSafeInteger(Number(parts[3]))) || fields2 === 4 && parts[3] !== "" && !/^[^\s:,]+(?:,[^\s:,]+)*$/.test(parts[3] ?? ""))
8947
9035
  return void 0;
8948
9036
  records.push(parts);
8949
9037
  }
@@ -9493,9 +9581,9 @@ function scopedRetryReason(served, current) {
9493
9581
  return "version-unchanged";
9494
9582
  return "rotated";
9495
9583
  }
9496
- function decideScopedRetryAfter401(site, served, current, logger2 = defaultLogger) {
9584
+ function decideScopedRetryAfter401(site, served, current, logger3 = defaultLogger) {
9497
9585
  const retry = isScopedCredentialRotation(served, current);
9498
- logger2.debug("scoped 401 re-authorized", {
9586
+ logger3.debug("scoped 401 re-authorized", {
9499
9587
  site,
9500
9588
  credentialId: served.credentialId,
9501
9589
  servedVersion: served.recordVersion,
@@ -10068,6 +10156,7 @@ var init_interlock = __esm({
10068
10156
 
10069
10157
  // ../core/dist/common-auth-embedded/claustrum/roster.js
10070
10158
  import { createHash as createHash7 } from "node:crypto";
10159
+ import { resolve as resolve6 } from "node:path";
10071
10160
  function hash(value) {
10072
10161
  return createHash7("sha256").update(value).digest("hex");
10073
10162
  }
@@ -10288,7 +10377,7 @@ async function readVaultRoster(path5) {
10288
10377
  return decodeRoster(value);
10289
10378
  }
10290
10379
  async function mutateVaultRoster(path5, change, options = {}) {
10291
- return withLock(path5, WRITE_LOCK, async (lock) => {
10380
+ return withLock(path5, { ...WRITE_LOCK, signal: options.signal }, async (lock) => {
10292
10381
  const current = await readVaultRoster(path5);
10293
10382
  const { next, result } = await change(current, {
10294
10383
  assertOwned: () => lock.assertOwned()
@@ -10298,6 +10387,7 @@ async function mutateVaultRoster(path5, change, options = {}) {
10298
10387
  await writeJsonAtomic2(path5, next, {
10299
10388
  beforeRename: async () => {
10300
10389
  await options.beforePublish?.();
10390
+ options.signal?.throwIfAborted();
10301
10391
  await lock.assertOwned();
10302
10392
  }
10303
10393
  });
@@ -10347,43 +10437,51 @@ function receiptFence(row, receipt2) {
10347
10437
  return "bind";
10348
10438
  return "refuse";
10349
10439
  }
10350
- function recordVaultQuota(path5, input2) {
10351
- return mutateVaultRoster(path5, (current) => {
10352
- const row = current?.rows.find((entry) => entry.routeId === input2.routeId);
10353
- const fence = !current || !row ? "refuse" : receiptFence(row, input2);
10354
- if (!current || !row || fence === "refuse")
10355
- return { result: false };
10356
- const quota = mergeQuotaObservation(row.quota, input2.observation);
10357
- const bound = fence === "bind" ? { accountIdentity: input2.accountIdentity, unclaimed: true } : {};
10358
- return {
10359
- next: {
10360
- ...current,
10361
- rows: current.rows.map((entry) => entry === row ? { ...entry, ...bound, quota } : entry)
10362
- },
10363
- result: true
10364
- };
10440
+ async function recordVaultQuota(path5, input2) {
10441
+ const { routeId, observation, ...receipt2 } = input2;
10442
+ return enqueueFencedVaultQuota(path5, {
10443
+ routeId,
10444
+ observation,
10445
+ accountIdentity: receipt2.accountIdentity,
10446
+ receipt: receipt2
10365
10447
  });
10366
10448
  }
10449
+ async function enqueueFencedVaultQuota(path5, publication2) {
10450
+ if (!isQuotaObservation(publication2.observation))
10451
+ return false;
10452
+ const current = pendingVaultQuota(path5, await readVaultRoster(path5));
10453
+ if (!applyVaultQuota(current, publication2).kept)
10454
+ return false;
10455
+ return enqueueVaultQuota(path5, publication2);
10456
+ }
10367
10457
  function recordVaultAccountQuota(path5, input2) {
10368
- return mutateVaultRoster(path5, (current) => {
10369
- const row = current?.rows.find((entry) => entry.routeId === input2.routeId);
10370
- if (!current || !row || row.accountIdentity === void 0 || row.accountIdentity !== input2.accountIdentity)
10371
- return { result: false };
10372
- const quota = mergeQuotaObservation(row.quota, input2.observation);
10373
- return {
10374
- next: {
10375
- ...current,
10376
- rows: current.rows.map((entry) => entry === row ? { ...entry, quota } : entry)
10377
- },
10378
- result: true
10379
- };
10380
- });
10458
+ return enqueueFencedVaultQuota(path5, input2);
10459
+ }
10460
+ function applyVaultQuota(current, input2) {
10461
+ const row = current?.rows.find((entry) => entry.routeId === input2.routeId);
10462
+ const fence = !row ? "refuse" : input2.receipt ? receiptFence(row, input2.receipt) : row.accountIdentity !== void 0 && row.accountIdentity === input2.accountIdentity ? "hold" : "refuse";
10463
+ if (!current || !row || fence === "refuse")
10464
+ return { roster: current, kept: false };
10465
+ const quota = mergeQuotaObservation(row.quota, input2.observation);
10466
+ const bound = fence === "bind" ? { accountIdentity: input2.accountIdentity, unclaimed: true } : {};
10467
+ return {
10468
+ roster: {
10469
+ ...current,
10470
+ rows: current.rows.map((entry) => entry === row ? { ...entry, ...bound, quota } : entry)
10471
+ },
10472
+ kept: true
10473
+ };
10474
+ }
10475
+ function forgetPendingVaultDiscovery(path5) {
10476
+ pendingDiscoveries.delete(resolve6(path5));
10381
10477
  }
10382
10478
  async function refreshVaultRoster(options) {
10383
10479
  options.signal?.throwIfAborted();
10384
10480
  const active2 = async () => await options.isActive?.() ?? true;
10385
- if (!await active2())
10481
+ if (!await active2()) {
10482
+ forgetPendingVaultDiscovery(options.path);
10386
10483
  return void 0;
10484
+ }
10387
10485
  const lease = await acquireRefreshFileLock({
10388
10486
  ...DISCOVERY_LEASE,
10389
10487
  path: options.path,
@@ -10396,8 +10494,18 @@ async function refreshVaultRoster(options) {
10396
10494
  throw new ClaustrumConsumerError("roster-busy", "Claustrum account discovery is already in progress");
10397
10495
  return persisted;
10398
10496
  }
10497
+ const key = resolve6(options.path);
10498
+ let discovered;
10399
10499
  try {
10400
- const inventory = await options.custody.discover(options.signal);
10500
+ const previous = await readVaultRoster(options.path);
10501
+ const pending = pendingDiscoveries.get(key);
10502
+ discovered = pending && (pending.previousView === previous?.view || pending.inventory.view === previous?.view) ? pending : {
10503
+ inventory: await options.custody.discover(options.signal),
10504
+ previousView: previous?.view
10505
+ };
10506
+ pendingDiscoveries.delete(key);
10507
+ const { inventory } = discovered;
10508
+ options.onInventory?.(inventory);
10401
10509
  options.signal?.throwIfAborted();
10402
10510
  return await mutateVaultRoster(options.path, async (current) => {
10403
10511
  if (!await active2())
@@ -10408,7 +10516,16 @@ async function refreshVaultRoster(options) {
10408
10516
  const next = projectVaultRoster(current, inventory, projection);
10409
10517
  const changed = JSON.stringify(current) !== JSON.stringify(next);
10410
10518
  return { ...changed && { next }, result: next };
10519
+ }, {
10520
+ beforePublish: async () => {
10521
+ options.signal?.throwIfAborted();
10522
+ await lease.assertOwned();
10523
+ }
10411
10524
  });
10525
+ } catch (error) {
10526
+ if (error instanceof LockContentionError && discovered && !options.signal?.aborted && await active2())
10527
+ pendingDiscoveries.set(key, discovered);
10528
+ throw error;
10412
10529
  } finally {
10413
10530
  await lease.release();
10414
10531
  }
@@ -10445,7 +10562,7 @@ function resolveVaultPrimary(input2) {
10445
10562
  ...previous && previous.accountIdentity !== identity && { replaced: previous }
10446
10563
  };
10447
10564
  }
10448
- var DEFAULT_ROUTE_PREFIX, SKIPPED_REASONS, WRITE_LOCK, DISCOVERY_LEASE;
10565
+ var DEFAULT_ROUTE_PREFIX, SKIPPED_REASONS, WRITE_LOCK, DISCOVERY_LEASE, pendingDiscoveries;
10449
10566
  var init_roster = __esm({
10450
10567
  "../core/dist/common-auth-embedded/claustrum/roster.js"() {
10451
10568
  "use strict";
@@ -10454,6 +10571,8 @@ var init_roster = __esm({
10454
10571
  init_quota();
10455
10572
  init_errors2();
10456
10573
  init_interlock();
10574
+ init_quota_writer();
10575
+ init_quota_writer();
10457
10576
  DEFAULT_ROUTE_PREFIX = "vault:";
10458
10577
  SKIPPED_REASONS = /* @__PURE__ */ new Set([
10459
10578
  "empty credential id",
@@ -10464,9 +10583,238 @@ var init_roster = __esm({
10464
10583
  WRITE_LOCK = {
10465
10584
  name: "claustrum-roster-write",
10466
10585
  ttlMs: 1e4,
10467
- timeoutMs: 5e3
10586
+ timeoutMs: 5e3,
10587
+ renew: true
10468
10588
  };
10469
10589
  DISCOVERY_LEASE = { name: "claustrum-roster", ttlMs: 3e4 };
10590
+ pendingDiscoveries = /* @__PURE__ */ new Map();
10591
+ }
10592
+ });
10593
+
10594
+ // ../core/dist/common-auth-embedded/claustrum/quota-writer.js
10595
+ import { resolve as resolve7 } from "node:path";
10596
+ function writerFor(path5) {
10597
+ const key = resolve7(path5);
10598
+ let writer = writers.get(key);
10599
+ if (!writer) {
10600
+ writer = {
10601
+ path: key,
10602
+ pending: /* @__PURE__ */ new Map(),
10603
+ listeners: /* @__PURE__ */ new Set(),
10604
+ wake: /* @__PURE__ */ new Set(),
10605
+ abort: new AbortController(),
10606
+ failures: 0,
10607
+ draining: false,
10608
+ order: 0
10609
+ };
10610
+ writers.set(key, writer);
10611
+ }
10612
+ return writer;
10613
+ }
10614
+ function retainVaultQuotaWriter(path5, listener) {
10615
+ const writer = writerFor(path5);
10616
+ writer.listeners.add(listener);
10617
+ let released;
10618
+ return () => released ??= (() => {
10619
+ writer.listeners.delete(listener);
10620
+ return writer.listeners.size ? Promise.resolve() : drainVaultQuota(path5);
10621
+ })();
10622
+ }
10623
+ function fields(publication2) {
10624
+ const result = /* @__PURE__ */ new Map();
10625
+ const { observation } = publication2;
10626
+ const witness = JSON.stringify([
10627
+ publication2.routeId,
10628
+ publication2.receipt?.credentialId,
10629
+ publication2.receipt?.accountIdentitySource,
10630
+ publication2.receipt?.expectedAccountIdentity
10631
+ ]);
10632
+ const add = (key, at, part) => result.set(`${witness}:${key}`, {
10633
+ at,
10634
+ order: 0,
10635
+ publication: { ...publication2, observation: part }
10636
+ });
10637
+ const keyFor = (scope, label) => JSON.stringify([scope ?? "all", label]);
10638
+ const read = /* @__PURE__ */ new Set();
10639
+ for (const reading of observation.readings ?? []) {
10640
+ const key = keyFor(reading.scope, reading.label);
10641
+ read.add(key);
10642
+ add(key, observation.checkedAt, {
10643
+ checkedAt: observation.checkedAt,
10644
+ readings: [{ ...reading }]
10645
+ });
10646
+ }
10647
+ for (const pair of observation.coverage ?? []) {
10648
+ const key = keyFor(pair.scope, pair.label);
10649
+ if (!read.has(key))
10650
+ add(key, observation.checkedAt, {
10651
+ checkedAt: observation.checkedAt,
10652
+ coverage: [{ ...pair }]
10653
+ });
10654
+ }
10655
+ if (observation.budget)
10656
+ add("budget", observation.checkedAt, {
10657
+ checkedAt: observation.checkedAt,
10658
+ budget: { ...observation.budget }
10659
+ });
10660
+ for (const [name, counter] of Object.entries(observation.counters ?? {})) {
10661
+ add(`counter:${name}`, counter.checkedAt, {
10662
+ checkedAt: observation.checkedAt,
10663
+ counters: { [name]: { ...counter } }
10664
+ });
10665
+ }
10666
+ if (observation.credits)
10667
+ add("credits", observation.credits.checkedAt, {
10668
+ checkedAt: observation.checkedAt,
10669
+ credits: { ...observation.credits }
10670
+ });
10671
+ if (!result.size)
10672
+ add("empty", observation.checkedAt, { checkedAt: observation.checkedAt });
10673
+ return result;
10674
+ }
10675
+ function enqueueVaultQuota(path5, publication2) {
10676
+ if (!isQuotaObservation(publication2.observation))
10677
+ return Promise.resolve(false);
10678
+ const writer = writerFor(path5);
10679
+ const account = JSON.stringify([
10680
+ publication2.accountIdentity ?? null,
10681
+ publication2.accountIdentity === void 0 ? publication2.routeId : null
10682
+ ]);
10683
+ const pending = writer.pending.get(account) ?? /* @__PURE__ */ new Map();
10684
+ for (const [key, field] of fields(publication2)) {
10685
+ const previous = pending.get(key);
10686
+ if (!previous || field.at >= previous.at) {
10687
+ field.order = ++writer.order;
10688
+ if (field.publication.observation.coverage)
10689
+ field.priorReading = previous?.publication.observation.readings ? previous.publication : previous?.priorReading;
10690
+ pending.set(key, field);
10691
+ }
10692
+ }
10693
+ if (pending.size)
10694
+ writer.pending.set(account, pending);
10695
+ for (const listener of writer.listeners)
10696
+ listener(publication2);
10697
+ schedule(writer, COALESCE_MS);
10698
+ return Promise.resolve(true);
10699
+ }
10700
+ function orderedFields(pending) {
10701
+ return [...pending.values()].flatMap((account) => [...account.values()]).sort((a, b) => a.order - b.order);
10702
+ }
10703
+ function pendingVaultQuota(path5, roster) {
10704
+ const writer = writers.get(resolve7(path5));
10705
+ if (writer) {
10706
+ for (const field of orderedFields(writer.pending)) {
10707
+ if (field.priorReading)
10708
+ roster = applyVaultQuota(roster, field.priorReading).roster;
10709
+ roster = applyVaultQuota(roster, field.publication).roster;
10710
+ }
10711
+ }
10712
+ return roster;
10713
+ }
10714
+ function schedule(writer, delay3) {
10715
+ if (writer.running || writer.timer || !writer.pending.size || writer.abort.signal.aborted)
10716
+ return;
10717
+ writer.timer = setTimeout(() => {
10718
+ writer.timer = void 0;
10719
+ flush(writer);
10720
+ }, delay3);
10721
+ if (!writer.draining)
10722
+ writer.timer.unref?.();
10723
+ }
10724
+ function flush(writer) {
10725
+ if (writer.running || writer.abort.signal.aborted)
10726
+ return;
10727
+ const batch = new Map([...writer.pending].map(([account, pending]) => [
10728
+ account,
10729
+ new Map(pending)
10730
+ ]));
10731
+ writer.running = (async () => {
10732
+ try {
10733
+ await mutateVaultRoster(writer.path, (current) => {
10734
+ let next = current;
10735
+ for (const field of orderedFields(batch)) {
10736
+ if (field.priorReading)
10737
+ next = applyVaultQuota(next, field.priorReading).roster;
10738
+ next = applyVaultQuota(next, field.publication).roster;
10739
+ }
10740
+ return { ...next !== current && { next }, result: void 0 };
10741
+ }, { signal: writer.abort.signal });
10742
+ for (const [account, fields2] of batch) {
10743
+ const pending = writer.pending.get(account);
10744
+ for (const [key, field] of fields2) {
10745
+ if (pending?.get(key) === field)
10746
+ pending.delete(key);
10747
+ }
10748
+ if (!pending?.size)
10749
+ writer.pending.delete(account);
10750
+ }
10751
+ writer.failures = 0;
10752
+ } catch (error) {
10753
+ if (!writer.abort.signal.aborted && writer.failures++ === 0) {
10754
+ logger.warn("vault quota publication delayed; retrying", {
10755
+ error: error instanceof Error ? error.message : String(error)
10756
+ });
10757
+ }
10758
+ } finally {
10759
+ writer.running = void 0;
10760
+ for (const wake of writer.wake)
10761
+ wake();
10762
+ const backoff = writer.failures ? Math.min(5e3, 100 * 2 ** Math.min(writer.failures, 6)) * (0.5 + Math.random()) : COALESCE_MS;
10763
+ schedule(writer, backoff);
10764
+ }
10765
+ })();
10766
+ }
10767
+ async function drainVaultQuota(path5, timeoutMs = 1e3) {
10768
+ const key = resolve7(path5);
10769
+ const writer = writers.get(key);
10770
+ if (!writer)
10771
+ return;
10772
+ writer.draining = true;
10773
+ clearTimeout(writer.timer);
10774
+ writer.timer = void 0;
10775
+ let deadline;
10776
+ let wake;
10777
+ const drained = new Promise((done) => {
10778
+ wake = () => {
10779
+ if (!writer.pending.size || writer.abort.signal.aborted)
10780
+ done();
10781
+ };
10782
+ writer.wake.add(wake);
10783
+ wake();
10784
+ });
10785
+ try {
10786
+ if (writer.pending.size)
10787
+ flush(writer);
10788
+ await Promise.race([
10789
+ drained,
10790
+ new Promise((done) => {
10791
+ deadline = setTimeout(done, Math.max(0, timeoutMs));
10792
+ })
10793
+ ]);
10794
+ } finally {
10795
+ clearTimeout(deadline);
10796
+ if (wake)
10797
+ writer.wake.delete(wake);
10798
+ writer.draining = false;
10799
+ if (!writer.listeners.size) {
10800
+ writer.abort.abort();
10801
+ clearTimeout(writer.timer);
10802
+ writer.pending.clear();
10803
+ if (writers.get(key) === writer)
10804
+ writers.delete(key);
10805
+ }
10806
+ }
10807
+ }
10808
+ var writers, logger, COALESCE_MS;
10809
+ var init_quota_writer = __esm({
10810
+ "../core/dist/common-auth-embedded/claustrum/quota-writer.js"() {
10811
+ "use strict";
10812
+ init_logger();
10813
+ init_quota();
10814
+ init_roster();
10815
+ writers = /* @__PURE__ */ new Map();
10816
+ logger = createLogger2("claustrum");
10817
+ COALESCE_MS = 100;
10470
10818
  }
10471
10819
  });
10472
10820
 
@@ -10481,6 +10829,7 @@ var init_consumer = __esm({
10481
10829
  init_enrollment();
10482
10830
  init_errors2();
10483
10831
  init_insula();
10832
+ init_quota_writer();
10484
10833
  init_roster();
10485
10834
  init_watch();
10486
10835
  ClaustrumConsumer = class {
@@ -10501,11 +10850,16 @@ var init_consumer = __esm({
10501
10850
  #insula;
10502
10851
  #vaultWatch;
10503
10852
  #releaseInsulaWatch;
10853
+ #insulaSkips = /* @__PURE__ */ new Map();
10504
10854
  /** When this instance last completed a discovery, by `now`. */
10505
10855
  #discoveredAt;
10856
+ #releaseQuotaWriter;
10506
10857
  constructor(options) {
10507
10858
  this.#options = options;
10508
10859
  this.#logger = options.logger ?? createLogger2("claustrum");
10860
+ this.#releaseQuotaWriter = retainVaultQuotaWriter(options.rosterPath, (publication2) => {
10861
+ this.#roster = applyVaultQuota(this.#roster, publication2).roster;
10862
+ });
10509
10863
  }
10510
10864
  #assertOpen(signal) {
10511
10865
  this.#shutdown.signal.throwIfAborted();
@@ -10519,7 +10873,7 @@ var init_consumer = __esm({
10519
10873
  this.#shutdown.signal,
10520
10874
  ...signal ? [signal] : []
10521
10875
  ]);
10522
- return new Promise((resolve18, reject) => {
10876
+ return new Promise((resolve20, reject) => {
10523
10877
  const cleanup2 = () => {
10524
10878
  combined.signal.removeEventListener("abort", abort);
10525
10879
  combined.dispose();
@@ -10534,7 +10888,7 @@ var init_consumer = __esm({
10534
10888
  if (combined.signal.aborted)
10535
10889
  reject(combined.signal.reason);
10536
10890
  else
10537
- resolve18(value);
10891
+ resolve20(value);
10538
10892
  }, (error) => {
10539
10893
  cleanup2();
10540
10894
  reject(error);
@@ -10634,11 +10988,9 @@ var init_consumer = __esm({
10634
10988
  let discovered;
10635
10989
  const roster = await refreshVaultRoster({
10636
10990
  path: this.#options.rosterPath,
10637
- custody: {
10638
- discover: async (signal) => {
10639
- discovered = await custody.discover(signal);
10640
- return discovered;
10641
- }
10991
+ custody,
10992
+ onInventory: (inventory) => {
10993
+ discovered = inventory;
10642
10994
  },
10643
10995
  isActive: () => this.#active(),
10644
10996
  signal: this.#shutdown.signal,
@@ -10651,7 +11003,7 @@ var init_consumer = __esm({
10651
11003
  });
10652
11004
  this.#assertOpen();
10653
11005
  const changed = roster?.view !== this.#roster?.view;
10654
- this.#roster = roster;
11006
+ this.#roster = pendingVaultQuota(this.#options.rosterPath, roster);
10655
11007
  custody.retain(roster?.rows ?? []);
10656
11008
  if (discovered && roster?.view !== void 0)
10657
11009
  this.#grantReach = discovered.grantReach ? { view: roster.view, reach: discovered.grantReach } : void 0;
@@ -10787,13 +11139,48 @@ var init_consumer = __esm({
10787
11139
  return void 0;
10788
11140
  try {
10789
11141
  await readClaustrumEnrollmentToken(this.#options.tokenPath);
10790
- const roster = await readVaultRoster(this.#options.rosterPath);
11142
+ const roster = pendingVaultQuota(this.#options.rosterPath, await readVaultRoster(this.#options.rosterPath));
10791
11143
  const row = roster?.rows.find((entry) => entry.routeId === routeId);
10792
11144
  return this.#normalizeInsulaQuota(row?.accountIdentity);
10793
11145
  } catch {
10794
11146
  return void 0;
10795
11147
  }
10796
11148
  }
11149
+ /** Cache-only background lookup, preserving the reason a route has no reading. */
11150
+ async lookupInsulaQuotaForRoute(routeId) {
11151
+ const options = this.#options.insula;
11152
+ if (!options || this.#shutdown.signal.aborted || !await this.#active())
11153
+ return { miss: "unreachable" };
11154
+ try {
11155
+ await readClaustrumEnrollmentToken(this.#options.tokenPath);
11156
+ const roster = pendingVaultQuota(this.#options.rosterPath, await readVaultRoster(this.#options.rosterPath));
11157
+ const account = roster?.rows.find((row) => row.routeId === routeId)?.accountIdentity;
11158
+ if (!account || !this.#insula)
11159
+ return { miss: "unreachable" };
11160
+ const result = this.#insula.source.lookup(options.provider, account, (this.#options.now ?? Date.now)());
11161
+ const reading = result.reading && options.normalize(result.reading.entry, result.reading.context);
11162
+ if (result.miss)
11163
+ return { miss: result.miss, ...reading !== void 0 && { reading } };
11164
+ return reading === void 0 ? { miss: "unreachable" } : { reading };
11165
+ } catch {
11166
+ return { miss: "unreachable" };
11167
+ }
11168
+ }
11169
+ /** Skip the fallback poll while insula is cold or its upstream fetch failed. */
11170
+ async pollInsulaQuotaForRoute(routeId, fallback) {
11171
+ const result = await this.lookupInsulaQuotaForRoute(routeId);
11172
+ if (result.miss === "cold" || result.miss === "upstream-failed") {
11173
+ if (this.#insulaSkips.get(routeId) !== result.miss) {
11174
+ this.#insulaSkips.set(routeId, result.miss);
11175
+ this.#logger.warn("skipped insula provider poll", {
11176
+ reason: result.miss
11177
+ });
11178
+ }
11179
+ return void 0;
11180
+ }
11181
+ this.#insulaSkips.delete(routeId);
11182
+ return result.miss ? fallback() : result.reading;
11183
+ }
10797
11184
  #normalizeInsulaQuota(accountIdentity) {
10798
11185
  if (!this.#options.insula || !accountIdentity)
10799
11186
  return void 0;
@@ -10816,7 +11203,7 @@ var init_consumer = __esm({
10816
11203
  this.#insula = void 0;
10817
11204
  throw new ClaustrumConsumerError("not-active", "Claustrum scoped custody is not active");
10818
11205
  }
10819
- const current = await readVaultRoster(this.#options.rosterPath);
11206
+ const current = pendingVaultQuota(this.#options.rosterPath, await readVaultRoster(this.#options.rosterPath));
10820
11207
  this.#assertOpen(signal);
10821
11208
  const observed = roster.rows.find((row) => row.routeId === routeId);
10822
11209
  const configured = current?.rows.find((row) => row.routeId === routeId);
@@ -10895,13 +11282,13 @@ var init_consumer = __esm({
10895
11282
  async decline(routeId) {
10896
11283
  this.#assertOpen();
10897
11284
  await declineVaultRoute(this.#options.rosterPath, routeId);
10898
- this.#roster = await readVaultRoster(this.#options.rosterPath);
11285
+ this.#roster = pendingVaultQuota(this.#options.rosterPath, await readVaultRoster(this.#options.rosterPath));
10899
11286
  this.#custody?.retain(this.#roster?.rows ?? []);
10900
11287
  }
10901
11288
  async accept(routeId) {
10902
11289
  this.#assertOpen();
10903
11290
  await acceptVaultRoute(this.#options.rosterPath, routeId);
10904
- this.#roster = await readVaultRoster(this.#options.rosterPath);
11291
+ this.#roster = pendingVaultQuota(this.#options.rosterPath, await readVaultRoster(this.#options.rosterPath));
10905
11292
  }
10906
11293
  /**
10907
11294
  * Store a quota or profile observation for a vault route. The receipt the
@@ -10911,7 +11298,7 @@ var init_consumer = __esm({
10911
11298
  */
10912
11299
  async recordQuota(routeId, observation, attempt) {
10913
11300
  this.#assertOpen();
10914
- const kept = await recordVaultQuota(this.#options.rosterPath, {
11301
+ return recordVaultQuota(this.#options.rosterPath, {
10915
11302
  routeId,
10916
11303
  observation,
10917
11304
  credentialId: attempt.credentialId,
@@ -10923,27 +11310,21 @@ var init_consumer = __esm({
10923
11310
  expectedAccountIdentity: attempt.expectedAccountIdentity
10924
11311
  }
10925
11312
  });
10926
- if (kept)
10927
- this.#roster = await readVaultRoster(this.#options.rosterPath);
10928
- return kept;
10929
11313
  }
10930
11314
  /**
10931
11315
  * Store a background observation that belongs to an account rather than to
10932
11316
  * a served credential (an insula reading from `cachedInsulaQuotaForRoute`).
10933
11317
  * It lands only while the route is still bound to that known account, so no
10934
11318
  * credential fetch is needed and a replaced account's reading is dropped.
10935
- * The in-memory roster is reloaded from the file, without a vault call.
11319
+ * Memory updates immediately; durable publication is detached and coalesced.
10936
11320
  */
10937
11321
  async recordAccountQuota(routeId, accountIdentity, observation) {
10938
11322
  this.#assertOpen();
10939
- const kept = await recordVaultAccountQuota(this.#options.rosterPath, {
11323
+ return recordVaultAccountQuota(this.#options.rosterPath, {
10940
11324
  routeId,
10941
11325
  accountIdentity,
10942
11326
  observation
10943
11327
  });
10944
- if (kept)
10945
- this.#roster = await readVaultRoster(this.#options.rosterPath);
10946
- return kept;
10947
11328
  }
10948
11329
  close() {
10949
11330
  if (this.#shutdown.signal.aborted)
@@ -10958,6 +11339,13 @@ var init_consumer = __esm({
10958
11339
  this.#insula = void 0;
10959
11340
  this.#roster = void 0;
10960
11341
  this.#grantReach = void 0;
11342
+ void this.#releaseQuotaWriter();
11343
+ forgetPendingVaultDiscovery(this.#options.rosterPath);
11344
+ }
11345
+ /** Close immediately; the last consumer also waits for the writer's bounded drain. */
11346
+ async dispose() {
11347
+ this.close();
11348
+ await this.#releaseQuotaWriter();
10961
11349
  }
10962
11350
  };
10963
11351
  }
@@ -11000,6 +11388,7 @@ __export(claustrum_exports, {
11000
11388
  declineAccount: () => declineAccount,
11001
11389
  declineVaultRoute: () => declineVaultRoute,
11002
11390
  disconnectClaustrumEnrollment: () => disconnectClaustrumEnrollment,
11391
+ drainVaultQuota: () => drainVaultQuota,
11003
11392
  enrollmentAuthority: () => enrollmentAuthority,
11004
11393
  enrollmentName: () => enrollmentName,
11005
11394
  getClaustrumEnrollmentPaths: () => getClaustrumEnrollmentPaths,
@@ -11038,6 +11427,7 @@ var init_claustrum = __esm({
11038
11427
  init_host_slot();
11039
11428
  init_insula();
11040
11429
  init_interlock();
11430
+ init_quota_writer();
11041
11431
  init_roster();
11042
11432
  init_watch();
11043
11433
  }
@@ -11118,7 +11508,7 @@ async function acquirePiLock(authPath, onCompromised, onRenew) {
11118
11508
  if (!released && lastUpdate + RENEWAL_STALE < Date.now())
11119
11509
  compromise();
11120
11510
  }
11121
- function schedule(delay3 = UPDATE) {
11511
+ function schedule2(delay3 = UPDATE) {
11122
11512
  if (released)
11123
11513
  return;
11124
11514
  timer = setTimeout(() => {
@@ -11132,7 +11522,7 @@ async function acquirePiLock(authPath, onCompromised, onRenew) {
11132
11522
  if (errorCode(error) === "ENOENT" || lastUpdate + RENEWAL_STALE < Date.now())
11133
11523
  compromise();
11134
11524
  else
11135
- schedule(1e3);
11525
+ schedule2(1e3);
11136
11526
  }
11137
11527
  async function update() {
11138
11528
  assertFresh();
@@ -11165,14 +11555,14 @@ async function acquirePiLock(authPath, onCompromised, onRenew) {
11165
11555
  mtime = next.getTime();
11166
11556
  lastUpdate = Date.now();
11167
11557
  active.set(path5, { ...identity, mtime, renewedAt: lastUpdate });
11168
- schedule();
11558
+ schedule2();
11169
11559
  }
11170
11560
  onRenew?.(async () => {
11171
11561
  if (timer)
11172
11562
  clearTimeout(timer);
11173
11563
  await update();
11174
11564
  });
11175
- schedule();
11565
+ schedule2();
11176
11566
  return {
11177
11567
  assertFresh,
11178
11568
  async release() {
@@ -11231,7 +11621,7 @@ var init_lock = __esm({
11231
11621
  import { createHash as createHash8 } from "node:crypto";
11232
11622
  import { constants as constants2 } from "node:fs";
11233
11623
  import { lstat as lstat3, mkdir as mkdir10, open as open7, unlink as unlink7 } from "node:fs/promises";
11234
- import { dirname as dirname10, resolve as resolve6 } from "node:path";
11624
+ import { dirname as dirname10, resolve as resolve8 } from "node:path";
11235
11625
  import { setTimeout as sleep2 } from "node:timers/promises";
11236
11626
  function rootSpans(text2) {
11237
11627
  let i = text2.indexOf("{") + 1;
@@ -11432,8 +11822,8 @@ function createPiSlot(options, onStep, hooks) {
11432
11822
  if (!provider2 || !options.authPath || !options.stashPath || !placeholderKey || placeholderKey.startsWith("!") || placeholderKey.includes("$") || !Number.isFinite(timeout) || timeout < 0) {
11433
11823
  throw new PiSlotError("invalid-options");
11434
11824
  }
11435
- const authPath = resolve6(options.authPath);
11436
- const stashPath = resolve6(options.stashPath);
11825
+ const authPath = resolve8(options.authPath);
11826
+ const stashPath = resolve8(options.stashPath);
11437
11827
  if (authPath === stashPath || stashPath === `${authPath}.lock`) {
11438
11828
  throw new PiSlotError("invalid-options");
11439
11829
  }
@@ -11602,7 +11992,7 @@ var init_pi_slot = __esm({
11602
11992
 
11603
11993
  // src/plugin/index.ts
11604
11994
  import { createHash as createHash20, randomUUID as randomUUID20 } from "node:crypto";
11605
- import { join as join31, resolve as resolve17 } from "node:path";
11995
+ import { join as join31, resolve as resolve19 } from "node:path";
11606
11996
 
11607
11997
  // ../core/dist/abort-forwarding.js
11608
11998
  function forwardAbort(source, target) {
@@ -18150,7 +18540,7 @@ async function rmEvictingDir(evictingPath) {
18150
18540
  });
18151
18541
  }
18152
18542
  async function sleep(ms) {
18153
- await new Promise((resolve18) => setTimeout(resolve18, ms));
18543
+ await new Promise((resolve20) => setTimeout(resolve20, ms));
18154
18544
  }
18155
18545
  async function acquireFencedFileLock(options) {
18156
18546
  const lockPath = `${options.path}.${options.name}.lock`;
@@ -18266,8 +18656,8 @@ function buildLock(lockPath, evictingPath, ownerId, options, now) {
18266
18656
  let released = false;
18267
18657
  let lost = false;
18268
18658
  let lostResolve = null;
18269
- let lostPromise = new Promise((resolve18) => {
18270
- lostResolve = resolve18;
18659
+ let lostPromise = new Promise((resolve20) => {
18660
+ lostResolve = resolve20;
18271
18661
  });
18272
18662
  const markLost = () => {
18273
18663
  if (lost)
@@ -18277,9 +18667,9 @@ function buildLock(lockPath, evictingPath, ownerId, options, now) {
18277
18667
  clearInterval(renewTimer);
18278
18668
  renewTimer = null;
18279
18669
  }
18280
- const resolve18 = lostResolve;
18670
+ const resolve20 = lostResolve;
18281
18671
  lostResolve = null;
18282
- resolve18?.();
18672
+ resolve20?.();
18283
18673
  };
18284
18674
  const setupRenew = () => {
18285
18675
  if (options.renew === false)
@@ -18506,7 +18896,7 @@ var AccountStorageUnreadableError = class extends Error {
18506
18896
  }
18507
18897
  };
18508
18898
  var RETRY_DELAYS_MS = [100, 200, 400, 800, 1e3];
18509
- var DEFAULT_SLEEP = (ms) => new Promise((resolve18) => setTimeout(resolve18, ms));
18899
+ var DEFAULT_SLEEP = (ms) => new Promise((resolve20) => setTimeout(resolve20, ms));
18510
18900
  var DEFAULT_BUILD_BACKUP_PATH = (path5, now) => `${path5}.corrupt-${now.toISOString().replace(/[:.]/g, "-")}`;
18511
18901
  async function ensureSecurePermissions(path5) {
18512
18902
  try {
@@ -18897,7 +19287,7 @@ async function saveAccountStorageReplace(path5, incoming) {
18897
19287
  return mutateAccountStorage(path5, () => incoming);
18898
19288
  }
18899
19289
  async function clearAccountStorage(path5) {
18900
- const sleep5 = (ms) => new Promise((resolve18) => setTimeout(resolve18, ms));
19290
+ const sleep5 = (ms) => new Promise((resolve20) => setTimeout(resolve20, ms));
18901
19291
  const lock = await acquireWithRetry(path5, sleep5);
18902
19292
  try {
18903
19293
  await assertLegacyAccountStorageWritable(path5);
@@ -20088,8 +20478,8 @@ var AccountManager = class _AccountManager {
20088
20478
  await this.saveInFlight;
20089
20479
  return;
20090
20480
  }
20091
- return new Promise((resolve18, reject) => {
20092
- this.savePromiseResolvers.push({ resolve: resolve18, reject });
20481
+ return new Promise((resolve20, reject) => {
20482
+ this.savePromiseResolvers.push({ resolve: resolve20, reject });
20093
20483
  });
20094
20484
  }
20095
20485
  async dispose() {
@@ -20132,8 +20522,8 @@ var AccountManager = class _AccountManager {
20132
20522
  reject(error);
20133
20523
  throw error;
20134
20524
  }
20135
- for (const { resolve: resolve18 } of resolvers)
20136
- resolve18();
20525
+ for (const { resolve: resolve20 } of resolvers)
20526
+ resolve20();
20137
20527
  }
20138
20528
  async executeSave() {
20139
20529
  this.savePending = false;
@@ -20147,16 +20537,16 @@ var AccountManager = class _AccountManager {
20147
20537
  }
20148
20538
  try {
20149
20539
  await this.saveToDisk();
20150
- for (const { resolve: resolve18 } of resolvers) {
20151
- resolve18();
20540
+ for (const { resolve: resolve20 } of resolvers) {
20541
+ resolve20();
20152
20542
  }
20153
20543
  } catch (error) {
20154
20544
  if (isStorageLockContention(error)) {
20155
20545
  this.onDiagnostic?.("Skipped account-state persist due to storage lock contention", {
20156
20546
  error: String(error)
20157
20547
  });
20158
- for (const { resolve: resolve18 } of resolvers) {
20159
- resolve18();
20548
+ for (const { resolve: resolve20 } of resolvers) {
20549
+ resolve20();
20160
20550
  }
20161
20551
  return;
20162
20552
  }
@@ -20633,7 +21023,7 @@ function getHttpsProxy(url) {
20633
21023
  }
20634
21024
  }
20635
21025
  function waitForHead(socket, timeoutMs, onTimeout) {
20636
- return new Promise((resolve18, reject) => {
21026
+ return new Promise((resolve20, reject) => {
20637
21027
  let buffer = Buffer3.alloc(0);
20638
21028
  const timeout = setTimeout(() => {
20639
21029
  onTimeout();
@@ -20656,7 +21046,7 @@ function waitForHead(socket, timeoutMs, onTimeout) {
20656
21046
  return;
20657
21047
  const head = buffer.subarray(0, marker).toString("latin1");
20658
21048
  const leftover = buffer.subarray(marker + 4);
20659
- cleanup2(() => resolve18({ head, leftover }));
21049
+ cleanup2(() => resolve20({ head, leftover }));
20660
21050
  };
20661
21051
  socket.on("data", onData);
20662
21052
  socket.once("error", onError);
@@ -20670,7 +21060,7 @@ async function connectViaProxy(proxyUrl, targetUrl, timeoutMs, signal, onDebug)
20670
21060
  port: Number(proxyUrl.port || DEFAULT_PROXY_PORT),
20671
21061
  signal: signal ?? void 0
20672
21062
  });
20673
- await new Promise((resolve18, reject) => {
21063
+ await new Promise((resolve20, reject) => {
20674
21064
  const timeout = setTimeout(() => {
20675
21065
  onDebug?.(`agy transport proxy connect timeout after ${timeoutMs}ms`);
20676
21066
  proxySocket.destroy();
@@ -20679,7 +21069,7 @@ async function connectViaProxy(proxyUrl, targetUrl, timeoutMs, signal, onDebug)
20679
21069
  const cleanup2 = () => clearTimeout(timeout);
20680
21070
  proxySocket.once("connect", () => {
20681
21071
  cleanup2();
20682
- resolve18();
21072
+ resolve20();
20683
21073
  });
20684
21074
  proxySocket.once("error", (error) => {
20685
21075
  cleanup2();
@@ -20704,7 +21094,7 @@ Host: ${targetHost}:${targetPort}\r
20704
21094
  if (leftover.length > 0) {
20705
21095
  proxySocket.unshift(leftover);
20706
21096
  }
20707
- return await new Promise((resolve18, reject) => {
21097
+ return await new Promise((resolve20, reject) => {
20708
21098
  const tlsOptions = {
20709
21099
  socket: proxySocket,
20710
21100
  servername: targetHost,
@@ -20719,7 +21109,7 @@ Host: ${targetHost}:${targetPort}\r
20719
21109
  const cleanup2 = () => clearTimeout(timeout);
20720
21110
  tlsSocket.once("secureConnect", () => {
20721
21111
  cleanup2();
20722
- resolve18(tlsSocket);
21112
+ resolve20(tlsSocket);
20723
21113
  });
20724
21114
  tlsSocket.once("error", (error) => {
20725
21115
  cleanup2();
@@ -20728,7 +21118,7 @@ Host: ${targetHost}:${targetPort}\r
20728
21118
  });
20729
21119
  }
20730
21120
  async function connectDirect(targetUrl, timeoutMs, signal, onDebug) {
20731
- return await new Promise((resolve18, reject) => {
21121
+ return await new Promise((resolve20, reject) => {
20732
21122
  const tlsOptions = {
20733
21123
  host: targetUrl.hostname,
20734
21124
  port: Number(targetUrl.port || DEFAULT_HTTPS_PORT),
@@ -20744,7 +21134,7 @@ async function connectDirect(targetUrl, timeoutMs, signal, onDebug) {
20744
21134
  const cleanup2 = () => clearTimeout(timeout);
20745
21135
  socket.once("secureConnect", () => {
20746
21136
  cleanup2();
20747
- resolve18(socket);
21137
+ resolve20(socket);
20748
21138
  });
20749
21139
  socket.once("error", (error) => {
20750
21140
  cleanup2();
@@ -21006,6 +21396,7 @@ var ANTIGRAVITY_SCOPES = [
21006
21396
  var ANTIGRAVITY_REDIRECT_URI = "http://localhost:51121/oauth-callback";
21007
21397
  var ANTIGRAVITY_ENDPOINT_DAILY = "https://daily-cloudcode-pa.googleapis.com";
21008
21398
  var ANTIGRAVITY_ENDPOINT_PROD = "https://cloudcode-pa.googleapis.com";
21399
+ var ANTIGRAVITY_QUOTA_ENDPOINT = ANTIGRAVITY_ENDPOINT_DAILY;
21009
21400
  var ANTIGRAVITY_ENDPOINT_FALLBACKS = [
21010
21401
  ANTIGRAVITY_ENDPOINT_DAILY,
21011
21402
  ANTIGRAVITY_ENDPOINT_PROD
@@ -21407,9 +21798,9 @@ function projectAntigravityQuota(quota) {
21407
21798
  const model = MODEL_LABELS[scope];
21408
21799
  if (!model)
21409
21800
  continue;
21410
- const windows = group.windows ?? [];
21411
- if (windows.length) {
21412
- for (const window of windows) {
21801
+ const windows2 = group.windows ?? [];
21802
+ if (windows2.length) {
21803
+ for (const window of windows2) {
21413
21804
  if (!Number.isFinite(window.remainingFraction))
21414
21805
  continue;
21415
21806
  const duration = window.window === "weekly" ? "7d" : "5h";
@@ -21946,11 +22337,11 @@ function containsCredential(value, credentials, projectIds, seen = /* @__PURE__
21946
22337
  function redactCredentialError(error, credentials, projectIds) {
21947
22338
  const source = error instanceof Error || error instanceof DOMException ? error : void 0;
21948
22339
  const message = redactCredentialText(source?.message ?? String(error), credentials, projectIds);
21949
- const fields = source ? Reflect.ownKeys(source).map((key) => ({
22340
+ const fields2 = source ? Reflect.ownKeys(source).map((key) => ({
21950
22341
  key,
21951
22342
  descriptor: Object.getOwnPropertyDescriptor(source, key)
21952
22343
  })) : [];
21953
- const cause = fields.find(({ key }) => key === "cause")?.descriptor;
22344
+ const cause = fields2.find(({ key }) => key === "cause")?.descriptor;
21954
22345
  const secretCause = cause && (!("value" in cause) || containsCredential(cause.value, credentials, projectIds));
21955
22346
  try {
21956
22347
  if (source) {
@@ -21960,7 +22351,7 @@ function redactCredentialError(error, credentials, projectIds) {
21960
22351
  configurable: true,
21961
22352
  writable: true
21962
22353
  });
21963
- for (const { key, descriptor } of fields) {
22354
+ for (const { key, descriptor } of fields2) {
21964
22355
  if (key === "message" || key === "cause" || !("value" in descriptor))
21965
22356
  continue;
21966
22357
  const value = scrub2(descriptor.value, credentials, projectIds);
@@ -21975,7 +22366,7 @@ function redactCredentialError(error, credentials, projectIds) {
21975
22366
  }
21976
22367
  const safe = new Error(message);
21977
22368
  safe.name = redactCredentialText(source?.name ?? "Error", credentials, projectIds);
21978
- for (const { key, descriptor } of fields) {
22369
+ for (const { key, descriptor } of fields2) {
21979
22370
  if (key === "message" || key === "cause" || !("value" in descriptor))
21980
22371
  continue;
21981
22372
  Object.defineProperty(safe, key, {
@@ -22286,8 +22677,8 @@ function getDefaultTierId(allowedTiers) {
22286
22677
  return allowedTiers[0]?.id;
22287
22678
  }
22288
22679
  function wait(ms) {
22289
- return new Promise((resolve18) => {
22290
- setTimeout(resolve18, ms);
22680
+ return new Promise((resolve20) => {
22681
+ setTimeout(resolve20, ms);
22291
22682
  });
22292
22683
  }
22293
22684
  function extractManagedProjectId(payload) {
@@ -22831,13 +23222,13 @@ function aggregateQuota(models) {
22831
23222
  perModel.sort((a, b) => a.modelId.localeCompare(b.modelId));
22832
23223
  return { groups, perModel, modelCount: totalCount };
22833
23224
  }
22834
- function mostConstrainedWindow(windows) {
22835
- if (windows.length === 0)
23225
+ function mostConstrainedWindow(windows2) {
23226
+ if (windows2.length === 0)
22836
23227
  return void 0;
22837
- let best = windows[0];
22838
- for (let i = 1; i < windows.length; i++) {
22839
- if (windows[i].remainingFraction < best.remainingFraction) {
22840
- best = windows[i];
23228
+ let best = windows2[0];
23229
+ for (let i = 1; i < windows2.length; i++) {
23230
+ if (windows2[i].remainingFraction < best.remainingFraction) {
23231
+ best = windows2[i];
22841
23232
  }
22842
23233
  }
22843
23234
  return {
@@ -22874,21 +23265,21 @@ function aggregateQuotaSummary(response) {
22874
23265
  const groups = {};
22875
23266
  let totalCount = 0;
22876
23267
  for (const group of response.groups) {
22877
- const windows = [];
23268
+ const windows2 = [];
22878
23269
  for (const bucket of group.buckets) {
22879
23270
  const pool2 = poolForBucketId(bucket.bucketId);
22880
23271
  if (!pool2)
22881
23272
  continue;
22882
- windows.push({
23273
+ windows2.push({
22883
23274
  window: bucket.window,
22884
23275
  remainingFraction: normalizeRemainingFraction(bucket.remainingFraction),
22885
23276
  resetTime: bucket.resetTime
22886
23277
  });
22887
23278
  }
22888
- if (windows.length === 0)
23279
+ if (windows2.length === 0)
22889
23280
  continue;
22890
- windows.sort((a, b) => windowDurationMs(a.window) - windowDurationMs(b.window));
22891
- const constrained = mostConstrainedWindow(windows);
23281
+ windows2.sort((a, b) => windowDurationMs(a.window) - windowDurationMs(b.window));
23282
+ const constrained = mostConstrainedWindow(windows2);
22892
23283
  const recognizedBucket = group.buckets.find((bucket) => poolForBucketId(bucket.bucketId));
22893
23284
  if (!recognizedBucket)
22894
23285
  continue;
@@ -22900,7 +23291,7 @@ function aggregateQuotaSummary(response) {
22900
23291
  remainingFraction: constrained.remainingFraction,
22901
23292
  resetTime: constrained.resetTime,
22902
23293
  modelCount,
22903
- windows
23294
+ windows: windows2
22904
23295
  };
22905
23296
  totalCount += modelCount;
22906
23297
  }
@@ -24314,12 +24705,12 @@ async function commitVaultProviderState(input2) {
24314
24705
  function untilAborted(pending, signal) {
24315
24706
  if (!signal)
24316
24707
  return pending;
24317
- return new Promise((resolve18, reject) => {
24708
+ return new Promise((resolve20, reject) => {
24318
24709
  const abort = () => reject(signal.reason);
24319
24710
  signal.addEventListener("abort", abort, { once: true });
24320
24711
  if (signal.aborted)
24321
24712
  abort();
24322
- pending.then(resolve18, reject).finally(() => signal.removeEventListener("abort", abort));
24713
+ pending.then(resolve20, reject).finally(() => signal.removeEventListener("abort", abort));
24323
24714
  });
24324
24715
  }
24325
24716
  var AntigravityVaultSourceError = class extends Error {
@@ -24406,7 +24797,8 @@ function createAntigravityVaultAccountSource(options) {
24406
24797
  pollIntervalMs: options.pollIntervalMs
24407
24798
  },
24408
24799
  ...options.now && { now: options.now },
24409
- ...options.logger && { logger: options.logger }
24800
+ ...options.logger && { logger: options.logger },
24801
+ ...options.insula && { insula: options.insula }
24410
24802
  });
24411
24803
  const issued = /* @__PURE__ */ new WeakMap();
24412
24804
  const isDeclined2 = claustrum.isDeclined.bind(claustrum);
@@ -24518,6 +24910,37 @@ function createAntigravityVaultAccountSource(options) {
24518
24910
  recordVersion: admission.recordVersion
24519
24911
  });
24520
24912
  },
24913
+ pollInsulaQuotaForRoute: async (ref, fallback, signal, onSkip) => {
24914
+ await assertServing(signal);
24915
+ assertCurrentRoute(ref);
24916
+ if (!consumer.pollInsulaQuotaForRoute)
24917
+ return fallback();
24918
+ let usedFallback = false;
24919
+ const reading = await untilAborted(consumer.pollInsulaQuotaForRoute(ref.routeId, () => {
24920
+ usedFallback = true;
24921
+ return fallback();
24922
+ }), signal);
24923
+ if (reading === void 0) {
24924
+ const result = consumer.lookupInsulaQuotaForRoute ? await untilAborted(consumer.lookupInsulaQuotaForRoute(ref.routeId), signal) : void 0;
24925
+ if (result?.miss === "cold" || result?.miss === "upstream-failed")
24926
+ onSkip?.(result.miss);
24927
+ return void 0;
24928
+ }
24929
+ if (usedFallback)
24930
+ return reading;
24931
+ if (reading.accountIdentity !== ref.accountIdentity)
24932
+ throw new AntigravityVaultSourceError("identity-contradicted", "The background quota reading belongs to another vault account");
24933
+ const admission = await admit2(ref, signal);
24934
+ return {
24935
+ ...reading,
24936
+ quotaAttribution: {
24937
+ routeId: admission.routeId,
24938
+ credentialId: admission.credentialId,
24939
+ accountIdentity: admission.accountIdentity,
24940
+ recordVersion: admission.recordVersion
24941
+ }
24942
+ };
24943
+ },
24521
24944
  commitState: async (attribution, update, signal) => {
24522
24945
  assertOpen(signal);
24523
24946
  if (!options.state)
@@ -24652,7 +25075,7 @@ async function initAntigravityVersion() {
24652
25075
  // src/cli.ts
24653
25076
  import { execFile } from "node:child_process";
24654
25077
  import { realpathSync as realpathSync2 } from "node:fs";
24655
- import { resolve as resolve12 } from "node:path";
25078
+ import { resolve as resolve14 } from "node:path";
24656
25079
  import { createInterface } from "node:readline/promises";
24657
25080
  import { fileURLToPath as fileURLToPath2 } from "node:url";
24658
25081
  import { promisify } from "node:util";
@@ -24710,17 +25133,17 @@ import {
24710
25133
  writeFileSync
24711
25134
  } from "node:fs";
24712
25135
  import { homedir as homedir3 } from "node:os";
24713
- import { dirname as dirname14, join as join8, resolve as resolve9 } from "node:path";
25136
+ import { dirname as dirname14, join as join8, resolve as resolve11 } from "node:path";
24714
25137
 
24715
25138
  // src/common-auth-embedded/logger/engine.js
24716
25139
  import { appendFileSync as appendFileSync2, chmodSync as chmodSync2, existsSync as existsSync2, renameSync as renameSync2, statSync as statSync3 } from "node:fs";
24717
25140
  import { open as open8 } from "node:fs/promises";
24718
- import { dirname as dirname13, resolve as resolve8 } from "node:path";
25141
+ import { dirname as dirname13, resolve as resolve10 } from "node:path";
24719
25142
 
24720
25143
  // src/common-auth-embedded/fs/private-files.js
24721
25144
  import { randomUUID as randomUUID13 } from "node:crypto";
24722
25145
  import { lstat as lstat4, readFile as readFile8, rename as rename7, unlink as unlink8 } from "node:fs/promises";
24723
- import { dirname as dirname12, resolve as resolve7 } from "node:path";
25146
+ import { dirname as dirname12, resolve as resolve9 } from "node:path";
24724
25147
  var windowsPrivateFiles2 = process.platform === "win32";
24725
25148
  var migrationNotices2 = /* @__PURE__ */ new Set();
24726
25149
  function ioCode2(detail) {
@@ -24771,7 +25194,7 @@ async function privateOperation2(path5, stage, operation) {
24771
25194
  }
24772
25195
  var safeParentOptionsForTest2;
24773
25196
  async function verifySafeDirectory2(path5, options) {
24774
- path5 = resolve7(path5);
25197
+ path5 = resolve9(path5);
24775
25198
  options ??= safeParentOptionsForTest2;
24776
25199
  await privateOperation2(path5, "safe-parent", async () => {
24777
25200
  const result = await (await loadBackend2()).verifySafeParent(path5, options);
@@ -24786,7 +25209,7 @@ async function verifySafeDirectory2(path5, options) {
24786
25209
  });
24787
25210
  }
24788
25211
  async function verifyPrivate2(path5, kind, migrate = false) {
24789
- path5 = resolve7(path5);
25212
+ path5 = resolve9(path5);
24790
25213
  if (kind === "directory")
24791
25214
  return verifySafeDirectory2(path5);
24792
25215
  await privateOperation2(path5, "verify", async () => {
@@ -24821,7 +25244,7 @@ async function verifyPrivate2(path5, kind, migrate = false) {
24821
25244
  });
24822
25245
  }
24823
25246
  async function ensurePrivateDirectory3(path5, _migrate = false, options) {
24824
- path5 = resolve7(path5);
25247
+ path5 = resolve9(path5);
24825
25248
  await privateOperation2(path5, "directory", async () => {
24826
25249
  const api = await loadBackend2();
24827
25250
  try {
@@ -24852,7 +25275,7 @@ async function readPrivateText2(path5, migrate = false) {
24852
25275
  async function readPrivateBuffer2(path5, migrate = false) {
24853
25276
  if (!windowsPrivateFiles2)
24854
25277
  return readFile8(path5);
24855
- path5 = resolve7(path5);
25278
+ path5 = resolve9(path5);
24856
25279
  if (migrate) {
24857
25280
  await verifySafeDirectory2(dirname12(path5));
24858
25281
  await verifyPrivate2(path5, "file", true);
@@ -24860,20 +25283,20 @@ async function readPrivateBuffer2(path5, migrate = false) {
24860
25283
  return privateOperation2(path5, "read", async () => (await loadBackend2()).readOwnerOnly(path5));
24861
25284
  }
24862
25285
  async function createPrivateBytes2(path5, bytes) {
24863
- await verifySafeDirectory2(dirname12(resolve7(path5)));
25286
+ await verifySafeDirectory2(dirname12(resolve9(path5)));
24864
25287
  await privateOperation2(path5, "create", async () => {
24865
- await (await loadBackend2()).createPrivateFile(resolve7(path5), bytes);
25288
+ await (await loadBackend2()).createPrivateFile(resolve9(path5), bytes);
24866
25289
  });
24867
25290
  }
24868
25291
  async function createPrivateDirectoryExclusive2(path5) {
24869
- await verifySafeDirectory2(dirname12(resolve7(path5)));
25292
+ await verifySafeDirectory2(dirname12(resolve9(path5)));
24870
25293
  await privateOperation2(path5, "directory-create", async () => {
24871
- await (await loadBackend2()).createOwnerOnly(resolve7(path5), { kind: "dir" });
25294
+ await (await loadBackend2()).createOwnerOnly(resolve9(path5), { kind: "dir" });
24872
25295
  });
24873
25296
  }
24874
25297
  async function replaceWindowsFile2(from, to, options = {}) {
24875
- from = resolve7(from);
24876
- to = resolve7(to);
25298
+ from = resolve9(from);
25299
+ to = resolve9(to);
24877
25300
  const now = options.now ?? (() => performance.now());
24878
25301
  const start = now();
24879
25302
  const leaseDeadline = options.deadline ?? Infinity;
@@ -24916,7 +25339,7 @@ async function replaceWindowsFile2(from, to, options = {}) {
24916
25339
  throw error;
24917
25340
  }
24918
25341
  async function writePrivateAtomic2(path5, bytes, options = {}) {
24919
- path5 = resolve7(path5);
25342
+ path5 = resolve9(path5);
24920
25343
  await ensurePrivateDirectory3(dirname12(path5));
24921
25344
  try {
24922
25345
  await verifyPrivate2(path5, "file", true);
@@ -24924,7 +25347,7 @@ async function writePrivateAtomic2(path5, bytes, options = {}) {
24924
25347
  if (error.code !== "ENOENT")
24925
25348
  throw error;
24926
25349
  }
24927
- const stage = resolve7(options.stagePath ?? `${path5}.${randomUUID13()}.tmp`);
25350
+ const stage = resolve9(options.stagePath ?? `${path5}.${randomUUID13()}.tmp`);
24928
25351
  if (dirname12(stage) !== dirname12(path5))
24929
25352
  throw new PrivateFileError2(path5, "stage-directory", { code: "EXDEV" });
24930
25353
  let created = false;
@@ -25000,15 +25423,15 @@ function createRedactor2(options = {}) {
25000
25423
  return SECRET_KEY_EXACT2.test(key) || normalized.includes("apikey") || normalized.endsWith("secret") || normalized.endsWith("password") || normalized.endsWith("token") && !normalized.endsWith("tokens") || !!options.extraSecretKeys?.(normalized);
25001
25424
  }
25002
25425
  function errorEntries(error) {
25003
- const fields = error;
25426
+ const fields2 = error;
25004
25427
  const entries = [
25005
25428
  ["name", error.name],
25006
25429
  ["message", error.message],
25007
25430
  ["stack", error.stack]
25008
25431
  ];
25009
25432
  for (const key of ["code", "status", "cause"])
25010
- if (fields[key] !== void 0)
25011
- entries.push([key, fields[key]]);
25433
+ if (fields2[key] !== void 0)
25434
+ entries.push([key, fields2[key]]);
25012
25435
  const listed = new Set(entries.map(([key]) => key));
25013
25436
  for (const entry of Object.entries(error))
25014
25437
  if (!listed.has(entry[0]))
@@ -25109,7 +25532,7 @@ async function openWindowsFile2(sink, file) {
25109
25532
  return sink.handle;
25110
25533
  }
25111
25534
  async function flushWindowsFile2(sink, file, text2) {
25112
- file = resolve8(file);
25535
+ file = resolve10(file);
25113
25536
  try {
25114
25537
  if (sink.file !== file)
25115
25538
  await closeWindowsFile2(sink);
@@ -25246,7 +25669,7 @@ function createEngine2(options) {
25246
25669
  } catch {
25247
25670
  }
25248
25671
  }
25249
- function schedule() {
25672
+ function schedule2() {
25250
25673
  if (!timer)
25251
25674
  timer = setTimeout(() => {
25252
25675
  timer = void 0;
@@ -25288,7 +25711,7 @@ function createEngine2(options) {
25288
25711
  void flushed.catch(() => {
25289
25712
  });
25290
25713
  } else
25291
- schedule();
25714
+ schedule2();
25292
25715
  } catch {
25293
25716
  }
25294
25717
  }
@@ -25629,13 +26052,13 @@ function closeDebugStream(state) {
25629
26052
  state.logWriter = () => {
25630
26053
  };
25631
26054
  if (state.logFilePath) liveLogFilePaths.delete(state.logFilePath);
25632
- return new Promise((resolve18) => {
25633
- current.once("close", () => resolve18());
25634
- current.once("error", () => resolve18());
26055
+ return new Promise((resolve20) => {
26056
+ current.once("close", () => resolve20());
26057
+ current.once("error", () => resolve20());
25635
26058
  try {
25636
26059
  current.end();
25637
26060
  } catch {
25638
- resolve18();
26061
+ resolve20();
25639
26062
  }
25640
26063
  });
25641
26064
  }
@@ -25907,13 +26330,13 @@ function closeDebugLog() {
25907
26330
  if (!state || !current) return Promise.resolve();
25908
26331
  state.logStream = null;
25909
26332
  if (state.logFilePath) liveLogFilePaths.delete(state.logFilePath);
25910
- return new Promise((resolve18) => {
25911
- current.once("close", () => resolve18());
25912
- current.once("error", () => resolve18());
26333
+ return new Promise((resolve20) => {
26334
+ current.once("close", () => resolve20());
26335
+ current.once("error", () => resolve20());
25913
26336
  try {
25914
26337
  current.end();
25915
26338
  } catch {
25916
- resolve18();
26339
+ resolve20();
25917
26340
  }
25918
26341
  });
25919
26342
  }
@@ -26280,7 +26703,7 @@ var LegacyAccountPoolRetiredError = class extends Error {
26280
26703
  };
26281
26704
  async function assertLegacyPoolInUse(legacyPath) {
26282
26705
  try {
26283
- await assertLegacyAccountStorageWritable(resolve9(legacyPath));
26706
+ await assertLegacyAccountStorageWritable(resolve11(legacyPath));
26284
26707
  } catch (error) {
26285
26708
  throw new LegacyAccountPoolRetiredError(legacyPath, { cause: error });
26286
26709
  }
@@ -26300,7 +26723,7 @@ function refusalMessage(admission) {
26300
26723
  }
26301
26724
  async function bindingOf(options) {
26302
26725
  const now = options.now ?? (() => Date.now());
26303
- const legacyPath = resolve9(options.legacyPath ?? getStoragePath());
26726
+ const legacyPath = resolve11(options.legacyPath ?? getStoragePath());
26304
26727
  return {
26305
26728
  legacyPath,
26306
26729
  now,
@@ -26368,7 +26791,7 @@ async function openAccountStore(options) {
26368
26791
  }
26369
26792
  function initializeFreshAccountStoreFor(modules, options = {}) {
26370
26793
  return initializeFreshAccountStore(modules, {
26371
- legacyPath: resolve9(options.legacyPath ?? getStoragePath()),
26794
+ legacyPath: resolve11(options.legacyPath ?? getStoragePath()),
26372
26795
  now: options.now ?? (() => Date.now())
26373
26796
  });
26374
26797
  }
@@ -26760,7 +27183,7 @@ function normalizeQuota(input2) {
26760
27183
  const resetAt = toFiniteNumber(record3.resetAt) ?? void 0;
26761
27184
  const checkedAt = toFiniteNumber(record3.checkedAt) ?? void 0;
26762
27185
  const windowsRaw = record3.windows;
26763
- let windows;
27186
+ let windows2;
26764
27187
  if (Array.isArray(windowsRaw)) {
26765
27188
  const parsed = windowsRaw.filter(isObject).map((w) => {
26766
27189
  const win = w.window;
@@ -26779,14 +27202,14 @@ function normalizeQuota(input2) {
26779
27202
  ...ca !== null && ca >= 0 ? { checkedAt: ca } : {}
26780
27203
  };
26781
27204
  }).filter((v) => v !== null);
26782
- if (parsed.length > 0) windows = parsed;
27205
+ if (parsed.length > 0) windows2 = parsed;
26783
27206
  }
26784
27207
  return {
26785
27208
  remainingPercent: clampNumber(remaining, 0, 100),
26786
27209
  ...fraction !== null ? { remainingFraction: clampNumber(fraction, 0, 1) } : {},
26787
27210
  resetAt,
26788
27211
  ...checkedAt !== void 0 ? { checkedAt } : {},
26789
- windows
27212
+ windows: windows2
26790
27213
  };
26791
27214
  }
26792
27215
  function normalizeRouting(input2) {
@@ -26906,7 +27329,7 @@ function projectQuotaPoolForSidebar(source, checkedAt) {
26906
27329
  const parsed = Date.parse(source.resetTime);
26907
27330
  if (Number.isFinite(parsed)) resetAt = parsed;
26908
27331
  }
26909
- const windows = source.windows?.length ? source.windows.map((w) => ({
27332
+ const windows2 = source.windows?.length ? source.windows.map((w) => ({
26910
27333
  window: w.window,
26911
27334
  ...readingAt !== void 0 ? { checkedAt: readingAt } : {},
26912
27335
  remainingPercent: clampNumber(
@@ -26924,7 +27347,7 @@ function projectQuotaPoolForSidebar(source, checkedAt) {
26924
27347
  remainingPercent,
26925
27348
  remainingFraction: clampNumber(fraction, 0, 1),
26926
27349
  resetAt,
26927
- windows,
27350
+ windows: windows2,
26928
27351
  ...readingAt !== void 0 ? { checkedAt: readingAt } : {}
26929
27352
  };
26930
27353
  }
@@ -26991,7 +27414,7 @@ function drainSidebarWrites() {
26991
27414
  return sidebarWriteChain;
26992
27415
  }
26993
27416
  async function sleep3(ms) {
26994
- await new Promise((resolve18) => setTimeout(resolve18, ms));
27417
+ await new Promise((resolve20) => setTimeout(resolve20, ms));
26995
27418
  }
26996
27419
  async function acquireSidebarLockWithRetry(stateFile) {
26997
27420
  const start = Date.now();
@@ -27301,8 +27724,8 @@ var openCodeStore = {
27301
27724
  clear: async () => {
27302
27725
  }
27303
27726
  };
27304
- function defaultDiagnostic(message, fields) {
27305
- debugLogToFile(fields ? `${message} ${JSON.stringify(fields)}` : message);
27727
+ function defaultDiagnostic(message, fields2) {
27728
+ debugLogToFile(fields2 ? `${message} ${JSON.stringify(fields2)}` : message);
27306
27729
  }
27307
27730
  var AccountStoreNotReadyError = class extends Error {
27308
27731
  read;
@@ -27449,7 +27872,7 @@ function createLocationQuotaManager(options) {
27449
27872
  fetchTimeoutMs: options.fetchTimeoutMs
27450
27873
  });
27451
27874
  const sidebar = options.sidebar;
27452
- const logger2 = options.logger;
27875
+ const logger3 = options.logger;
27453
27876
  return withSidebarPushAfterRefresh(
27454
27877
  manager,
27455
27878
  sidebar ? (account) => pushSidebarQuotaSnapshot(
@@ -27458,7 +27881,7 @@ function createLocationQuotaManager(options) {
27458
27881
  sidebar.getActiveIndexByFamily,
27459
27882
  {
27460
27883
  write: sidebar.write,
27461
- logger: logger2,
27884
+ logger: logger3,
27462
27885
  healthScore: sidebar.healthScore ?? null,
27463
27886
  now: sidebar.now
27464
27887
  }
@@ -27595,7 +28018,7 @@ async function fetchLegacyModelsFallback(options) {
27595
28018
  const modelsResponse = await fetchAvailableModels({
27596
28019
  accessToken: options.accessToken,
27597
28020
  projectId: options.projectId,
27598
- endpoints: ANTIGRAVITY_ENDPOINT_FALLBACKS,
28021
+ endpoints: [ANTIGRAVITY_QUOTA_ENDPOINT],
27599
28022
  userAgent: buildAntigravityHarnessUserAgent(),
27600
28023
  timeoutMs: 1e4,
27601
28024
  ...options.fetchVia ? { fetchVia: options.fetchVia } : {}
@@ -27624,7 +28047,7 @@ async function fetchQuotaPayloads(options) {
27624
28047
  accessToken,
27625
28048
  managedProjectId,
27626
28049
  projectId,
27627
- endpoints: ANTIGRAVITY_ENDPOINT_FALLBACKS,
28050
+ endpoints: [ANTIGRAVITY_QUOTA_ENDPOINT],
27628
28051
  userAgent: buildAntigravityHarnessUserAgent(),
27629
28052
  timeoutMs: 1e4,
27630
28053
  ...fetchVia ? { fetchVia } : {}
@@ -27741,7 +28164,7 @@ async function fetchVaultAccountQuota(options) {
27741
28164
  return result;
27742
28165
  };
27743
28166
  const fetchSummary = async () => {
27744
- for (const endpoint of ANTIGRAVITY_ENDPOINT_FALLBACKS) {
28167
+ for (const endpoint of [ANTIGRAVITY_QUOTA_ENDPOINT]) {
27745
28168
  const result = await attempt(
27746
28169
  async (grant, fetchVia) => aggregateQuotaSummary(
27747
28170
  (await fetchQuotaSummary({
@@ -27763,7 +28186,7 @@ async function fetchVaultAccountQuota(options) {
27763
28186
  }
27764
28187
  if (result.refused) break;
27765
28188
  }
27766
- for (const endpoint of ANTIGRAVITY_ENDPOINT_FALLBACKS) {
28189
+ for (const endpoint of [ANTIGRAVITY_QUOTA_ENDPOINT]) {
27767
28190
  for (const withProject of [true, false]) {
27768
28191
  const result = await attempt(
27769
28192
  (grant, fetchVia) => fetchAvailableModels({
@@ -27822,14 +28245,14 @@ var LocalQuotaGrantStaleError = class extends Error {
27822
28245
  name = "LocalQuotaGrantStaleError";
27823
28246
  };
27824
28247
  function untilQuotaAborted(pending, signal) {
27825
- return new Promise((resolve18, reject) => {
28248
+ return new Promise((resolve20, reject) => {
27826
28249
  const abort = () => reject(signal.reason);
27827
28250
  if (signal.aborted) abort();
27828
28251
  else signal.addEventListener("abort", abort, { once: true });
27829
28252
  void pending.then(
27830
28253
  (value) => {
27831
28254
  signal.removeEventListener("abort", abort);
27832
- resolve18(value);
28255
+ resolve20(value);
27833
28256
  },
27834
28257
  (error) => {
27835
28258
  signal.removeEventListener("abort", abort);
@@ -27906,6 +28329,14 @@ function createAuthorizedFetchAccountQuota(options) {
27906
28329
  error: `quota check refused (stale grant: ${staleReason})`
27907
28330
  };
27908
28331
  }
28332
+ if (payloads.quota.error) {
28333
+ return {
28334
+ ...base,
28335
+ status: "error",
28336
+ disabled: false,
28337
+ error: payloads.quota.error
28338
+ };
28339
+ }
27909
28340
  return {
27910
28341
  ...base,
27911
28342
  status: "ok",
@@ -27981,6 +28412,7 @@ function makeFetchAccountQuota(client, providerId, fetchVia) {
27981
28412
  }),
27982
28413
  signal
27983
28414
  );
28415
+ if (payloads.quota.error) throw new Error(payloads.quota.error);
27984
28416
  return {
27985
28417
  index,
27986
28418
  email: account.email,
@@ -28036,6 +28468,7 @@ function makeFetchAccountQuota(client, providerId, fetchVia) {
28036
28468
  logger: log7
28037
28469
  });
28038
28470
  quotaResult = payloads.quota;
28471
+ if (quotaResult.error) throw new Error(quotaResult.error);
28039
28472
  fellBackToLegacy = payloads.fellBackToLegacy;
28040
28473
  for (const [family, groupQuota] of Object.entries(quotaResult.groups)) {
28041
28474
  const remainingPercent = (groupQuota.remainingFraction ?? 0) * 100;
@@ -28179,7 +28612,7 @@ function heldAccount(manager, ref) {
28179
28612
  );
28180
28613
  }
28181
28614
  function createStoreQuotaService(options) {
28182
- const { manager, logger: logger2 } = options;
28615
+ const { manager, logger: logger3 } = options;
28183
28616
  const credentials = options.credentials ?? createLocalAccountCredentials(manager, { repository: options.repository });
28184
28617
  const authorize = async (account, _signal, purpose = "required") => {
28185
28618
  const ref = account.rowRef;
@@ -28252,11 +28685,11 @@ function createStoreQuotaService(options) {
28252
28685
  };
28253
28686
  const fetchAccountQuota = createAuthorizedFetchAccountQuota({
28254
28687
  authorize: (account) => authorize(account),
28255
- logger: logger2,
28688
+ logger: logger3,
28256
28689
  transport: options.transport
28257
28690
  });
28258
28691
  const quotaManager = createLocationQuotaManager({
28259
- logger: logger2,
28692
+ logger: logger3,
28260
28693
  fetchAccountQuota,
28261
28694
  // Backoff and cache are per credential: a re-authenticated row starts
28262
28695
  // fresh instead of inheriting its predecessor's state.
@@ -28329,7 +28762,7 @@ function createStoreQuotaService(options) {
28329
28762
  (failure2) => failure2.rowId
28330
28763
  );
28331
28764
  failedRows = report === void 0 || failedIds.length === 0 || failedIds.some((id) => id === void 0) ? "all" : new Set(failedIds.filter((id) => id !== void 0));
28332
- logger2.debug("quota readings were not all persisted", {
28765
+ logger3.debug("quota readings were not all persisted", {
28333
28766
  error: error instanceof Error ? error.message : String(error)
28334
28767
  });
28335
28768
  }
@@ -28440,12 +28873,12 @@ async function startOAuthListener({
28440
28873
  let resolveCallback;
28441
28874
  let rejectCallback;
28442
28875
  let timeoutHandle;
28443
- const callbackPromise = new Promise((resolve18, reject) => {
28876
+ const callbackPromise = new Promise((resolve20, reject) => {
28444
28877
  resolveCallback = (url) => {
28445
28878
  if (settled) return;
28446
28879
  settled = true;
28447
28880
  if (timeoutHandle) clearTimeout(timeoutHandle);
28448
- resolve18(url);
28881
+ resolve20(url);
28449
28882
  };
28450
28883
  rejectCallback = (error) => {
28451
28884
  if (settled) return;
@@ -28604,7 +29037,7 @@ async function startOAuthListener({
28604
29037
  });
28605
29038
  });
28606
29039
  const bindAddress = getBindAddress();
28607
- await new Promise((resolve18, reject) => {
29040
+ await new Promise((resolve20, reject) => {
28608
29041
  const handleError = (error) => {
28609
29042
  server.off("error", handleError);
28610
29043
  if (error.code === "EADDRINUSE") {
@@ -28620,7 +29053,7 @@ async function startOAuthListener({
28620
29053
  server.once("error", handleError);
28621
29054
  server.listen(port, bindAddress, () => {
28622
29055
  server.off("error", handleError);
28623
- resolve18();
29056
+ resolve20();
28624
29057
  });
28625
29058
  });
28626
29059
  server.on("error", (error) => {
@@ -28628,7 +29061,7 @@ async function startOAuthListener({
28628
29061
  });
28629
29062
  return {
28630
29063
  waitForCallback: () => callbackPromise,
28631
- close: () => new Promise((resolve18, reject) => {
29064
+ close: () => new Promise((resolve20, reject) => {
28632
29065
  server.close((error) => {
28633
29066
  if (error && error.code !== "ERR_SERVER_NOT_RUNNING") {
28634
29067
  reject(error);
@@ -28637,7 +29070,7 @@ async function startOAuthListener({
28637
29070
  if (!settled) {
28638
29071
  rejectCallback(new Error("OAuth listener closed before callback"));
28639
29072
  }
28640
- resolve18();
29073
+ resolve20();
28641
29074
  });
28642
29075
  })
28643
29076
  };
@@ -28649,7 +29082,7 @@ async function startOAuthListener({
28649
29082
 
28650
29083
  // src/setup.ts
28651
29084
  import { lstat as lstat5, readFile as readFile13 } from "node:fs/promises";
28652
- import { join as join16, resolve as resolve11 } from "node:path";
29085
+ import { join as join16, resolve as resolve13 } from "node:path";
28653
29086
 
28654
29087
  // src/auth-method-labels.ts
28655
29088
  var OPENCODE2_POOL_AUTH_LABEL = "Google (antigravity-auth pool, browser)";
@@ -28821,7 +29254,7 @@ async function select2(terminal, items, options) {
28821
29254
  writeLine("");
28822
29255
  renderedLines = lines;
28823
29256
  };
28824
- return new Promise((resolve18) => {
29257
+ return new Promise((resolve20) => {
28825
29258
  const wasRaw = stdin.isRaw ?? false;
28826
29259
  const cleanup2 = () => {
28827
29260
  if (cleaned)
@@ -28841,7 +29274,7 @@ async function select2(terminal, items, options) {
28841
29274
  };
28842
29275
  const finish = (value) => {
28843
29276
  cleanup2();
28844
- resolve18(value);
29277
+ resolve20(value);
28845
29278
  };
28846
29279
  const onSignal = () => finish(null);
28847
29280
  const onKey = (data) => {
@@ -28881,7 +29314,7 @@ async function select2(terminal, items, options) {
28881
29314
  stdin.setRawMode(true);
28882
29315
  } catch {
28883
29316
  cleanup2();
28884
- resolve18(null);
29317
+ resolve20(null);
28885
29318
  return;
28886
29319
  }
28887
29320
  stdin.resume();
@@ -28895,7 +29328,7 @@ async function select2(terminal, items, options) {
28895
29328
  import { createHash as createHash10, randomBytes as randomBytes5, randomUUID as randomUUID16 } from "node:crypto";
28896
29329
  import { constants as fsConstants2 } from "node:fs";
28897
29330
  import { chmod as chmod3, mkdir as mkdir12, open as open10, readFile as readFile10, realpath as realpath4, rename as rename9, stat as stat7, unlink as unlink9 } from "node:fs/promises";
28898
- import { basename as basename4, dirname as dirname17, extname as extname2, isAbsolute as isAbsolute3, join as join11, resolve as resolve10 } from "node:path";
29331
+ import { basename as basename4, dirname as dirname17, extname as extname2, isAbsolute as isAbsolute3, join as join11, resolve as resolve12 } from "node:path";
28899
29332
  import { ClaustrumCredentialError as ClaustrumCredentialError5, ClaustrumClient as ClaustrumWireClient2, writeEnrollmentTokenFile as writeEnrollmentTokenFile2 } from "@cortexkit/claustrum-client";
28900
29333
 
28901
29334
  // src/common-auth-embedded/fs/lock-constants.js
@@ -28960,8 +29393,8 @@ async function acquireRefreshFileLockWithClock2(options) {
28960
29393
  let releaseConfirmed = false;
28961
29394
  let loss;
28962
29395
  let resolveLoss;
28963
- const lostPromise = new Promise((resolve18) => {
28964
- resolveLoss = resolve18;
29396
+ const lostPromise = new Promise((resolve20) => {
29397
+ resolveLoss = resolve20;
28965
29398
  });
28966
29399
  function notifyTimerStep(event) {
28967
29400
  try {
@@ -29118,7 +29551,7 @@ async function acquireRefreshFileLockWithClock2(options) {
29118
29551
  }
29119
29552
  }
29120
29553
  async function backoff() {
29121
- await new Promise((resolve18) => setTimeout(resolve18, Math.floor(Math.random() * 4)));
29554
+ await new Promise((resolve20) => setTimeout(resolve20, Math.floor(Math.random() * 4)));
29122
29555
  }
29123
29556
  async function readLockState(notifyReady = true) {
29124
29557
  if (notifyReady && options.onStep)
@@ -29604,7 +30037,7 @@ function hostEnrollmentPaths2(input2) {
29604
30037
  const override = input2.override?.trim();
29605
30038
  if (override && !isAbsolute3(override) && !input2.cwd)
29606
30039
  throw new ClaustrumConsumerError2("invalid-state", "A relative Claustrum enrollment override needs a base directory");
29607
- const tokenPath = override ? isAbsolute3(override) ? override : resolve10(input2.cwd, override) : join11(input2.stateDir, `${input2.host}-enrollment.json`);
30040
+ const tokenPath = override ? isAbsolute3(override) ? override : resolve12(input2.cwd, override) : join11(input2.stateDir, `${input2.host}-enrollment.json`);
29608
30041
  return getClaustrumEnrollmentPaths2(tokenPath);
29609
30042
  }
29610
30043
  function isRecord10(value) {
@@ -29733,13 +30166,13 @@ async function readBoundedJson2(path5) {
29733
30166
  await descriptor.close();
29734
30167
  }
29735
30168
  }
29736
- function accountRecords2(text2, fields) {
30169
+ function accountRecords2(text2, fields2) {
29737
30170
  const records = [];
29738
30171
  for (const line of text2.split("\n")) {
29739
30172
  if (line.trim() === "" || line.startsWith("#"))
29740
30173
  continue;
29741
30174
  const parts = line.split(":");
29742
- if (parts.length !== fields || !/^[^\s:,]+$/.test(parts[0] ?? "") || !/^\d+$/.test(parts[2] ?? "") || !Number.isSafeInteger(Number(parts[2])) || fields === 7 && (!/^\d+$/.test(parts[3] ?? "") || !Number.isSafeInteger(Number(parts[3]))) || fields === 4 && parts[3] !== "" && !/^[^\s:,]+(?:,[^\s:,]+)*$/.test(parts[3] ?? ""))
30175
+ if (parts.length !== fields2 || !/^[^\s:,]+$/.test(parts[0] ?? "") || !/^\d+$/.test(parts[2] ?? "") || !Number.isSafeInteger(Number(parts[2])) || fields2 === 7 && (!/^\d+$/.test(parts[3] ?? "") || !Number.isSafeInteger(Number(parts[3]))) || fields2 === 4 && parts[3] !== "" && !/^[^\s:,]+(?:,[^\s:,]+)*$/.test(parts[3] ?? ""))
29743
30176
  return void 0;
29744
30177
  records.push(parts);
29745
30178
  }
@@ -30199,7 +30632,7 @@ var ByteTail = class {
30199
30632
  };
30200
30633
  var defaultCommandRunner = {
30201
30634
  run(file, args, options = {}) {
30202
- return new Promise((resolve18) => {
30635
+ return new Promise((resolve20) => {
30203
30636
  const started = performance.now();
30204
30637
  const timeoutMs = options.timeoutMs ?? 15e3;
30205
30638
  const stderr = new ByteTail();
@@ -30217,7 +30650,7 @@ var defaultCommandRunner = {
30217
30650
  stdio: ["ignore", "pipe", "pipe"]
30218
30651
  });
30219
30652
  } catch {
30220
- resolve18({
30653
+ resolve20({
30221
30654
  exitCode: 1,
30222
30655
  stdout: "",
30223
30656
  stderr: "",
@@ -30252,7 +30685,7 @@ var defaultCommandRunner = {
30252
30685
  settled = true;
30253
30686
  if (timer)
30254
30687
  clearTimeout(timer);
30255
- resolve18({
30688
+ resolve20({
30256
30689
  exitCode: spawnError ? 1 : outputExceeded ? 1 : code2 ?? 1,
30257
30690
  stdout: Buffer.concat(stdout, stdoutLength).toString("utf8"),
30258
30691
  stderr: stderr.toString(),
@@ -30680,9 +31113,10 @@ Please quit all OpenCode, LiteCode, and Pi processes before running setup.`);
30680
31113
  }
30681
31114
  };
30682
31115
  async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
30683
- const windows = (options.platform ?? process.platform) === "win32";
31116
+ const windows2 = (options.platform ?? process.platform) === "win32";
31117
+ const selfPid = options.selfPid ?? process.pid;
30684
31118
  let inspection = {
30685
- step: windows ? "tasklist" : "ps",
31119
+ step: windows2 ? "tasklist" : "ps",
30686
31120
  exitCode: null,
30687
31121
  signal: null,
30688
31122
  timedOut: false,
@@ -30717,7 +31151,7 @@ async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
30717
31151
  }
30718
31152
  };
30719
31153
  try {
30720
- const result = await inspect(windows ? "tasklist" : "ps", windows ? "tasklist.exe" : "ps", windows ? ["/fo", "csv", "/nh"] : ["-eo", "pid,command"]);
31154
+ const result = await inspect(windows2 ? "tasklist" : "ps", windows2 ? "tasklist.exe" : "ps", windows2 ? ["/fo", "csv", "/nh"] : ["-eo", "pid,command"]);
30721
31155
  if (result.exitCode !== 0)
30722
31156
  throw new ProcessInspectionError(inspection);
30723
31157
  const processes = [];
@@ -30727,7 +31161,7 @@ async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
30727
31161
  continue;
30728
31162
  let pid;
30729
31163
  let command;
30730
- if (windows) {
31164
+ if (windows2) {
30731
31165
  const match = /^"([^"]+)","(\d+)"(?:,|$)/.exec(trimmed);
30732
31166
  if (!match)
30733
31167
  throw new ProcessInspectionError(inspection);
@@ -30749,8 +31183,8 @@ async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
30749
31183
  }
30750
31184
  if (!processes.length)
30751
31185
  throw new ProcessInspectionError(inspection);
30752
- const runtimes = processes.filter((entry) => entry.pid !== process.pid && /^(?:node|bun)\.exe$/i.test(entry.command));
30753
- if (windows && runtimes.length && options.inspectRuntimes !== false) {
31186
+ const runtimes = processes.filter((entry) => entry.pid !== selfPid && /^(?:node|bun)\.exe$/i.test(entry.command));
31187
+ if (windows2 && runtimes.length && options.inspectRuntimes !== false) {
30754
31188
  const details = await inspect("CIM", "powershell.exe", [
30755
31189
  "-NoProfile",
30756
31190
  "-NonInteractive",
@@ -30782,7 +31216,8 @@ async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
30782
31216
  }
30783
31217
  }
30784
31218
  function createProcessFence(runner = defaultCommandRunner, options = {}) {
30785
- const isHost = (entry) => entry.pid !== process.pid && hostName(entry.command) !== null;
31219
+ const selfPid = options.selfPid ?? process.pid;
31220
+ const isHost = (entry) => entry.pid !== selfPid && hostName(entry.command) !== null;
30786
31221
  return {
30787
31222
  async listRunningHosts(env3) {
30788
31223
  return (await listSetupProcesses(runner, { ...options, env: env3 })).filter(isHost);
@@ -30793,10 +31228,10 @@ function createProcessFence(runner = defaultCommandRunner, options = {}) {
30793
31228
  env: env3,
30794
31229
  inspectRuntimes: false
30795
31230
  });
30796
- const windows = (options.platform ?? process.platform) === "win32";
31231
+ const windows2 = (options.platform ?? process.platform) === "win32";
30797
31232
  return {
30798
31233
  hosts: processes.filter(isHost),
30799
- uncheckedRuntimes: windows ? processes.filter((entry) => entry.pid !== process.pid && /^(?:node|bun)\.exe$/i.test(entry.command)).length : 0
31234
+ uncheckedRuntimes: windows2 ? processes.filter((entry) => entry.pid !== selfPid && /^(?:node|bun)\.exe$/i.test(entry.command)).length : 0
30800
31235
  };
30801
31236
  }
30802
31237
  };
@@ -30907,11 +31342,11 @@ import { mkdir as mkdir13, open as open11, rename as rename10, stat as stat9, un
30907
31342
  import { basename as basename5, dirname as dirname18, join as join13 } from "node:path";
30908
31343
  import { setTimeout as delay2 } from "node:timers/promises";
30909
31344
  async function writeHostConfigAtomic(file, content, options = {}) {
30910
- const windows = (options.platform ?? process.platform) === "win32";
31345
+ const windows2 = (options.platform ?? process.platform) === "win32";
30911
31346
  const parent = dirname18(file);
30912
31347
  await mkdir13(parent, { recursive: true });
30913
31348
  let mode;
30914
- if (!windows) {
31349
+ if (!windows2) {
30915
31350
  try {
30916
31351
  mode = (await stat9(file)).mode & 4095;
30917
31352
  } catch (error) {
@@ -30942,7 +31377,7 @@ async function writeHostConfigAtomic(file, content, options = {}) {
30942
31377
  } catch (error) {
30943
31378
  const code2 = error.code;
30944
31379
  const remaining = 2e3 - (now() - started);
30945
- if (!windows || !["EPERM", "EBUSY", "EACCES"].includes(code2 ?? "") || remaining <= 0 || attempt >= 40)
31380
+ if (!windows2 || !["EPERM", "EBUSY", "EACCES"].includes(code2 ?? "") || remaining <= 0 || attempt >= 40)
30946
31381
  throw new Error(`Unable to replace host config ${file}. Close editors or other programs using the file, then rerun setup.`);
30947
31382
  await (options.wait ?? delay2)(Math.min(remaining, 25 * 2 ** Math.min(attempt, 2)));
30948
31383
  }
@@ -31540,7 +31975,7 @@ function createVaultSelectionState(options) {
31540
31975
  report(error);
31541
31976
  }
31542
31977
  };
31543
- const flush = () => {
31978
+ const flush2 = () => {
31544
31979
  writing = writing.then(async () => {
31545
31980
  for (const row of [...changed]) await writeRow(row);
31546
31981
  });
@@ -31556,7 +31991,7 @@ function createVaultSelectionState(options) {
31556
31991
  accessVerdict: mark,
31557
31992
  fingerprint: mark,
31558
31993
  requestSave: () => {
31559
- void flush();
31994
+ void flush2();
31560
31995
  }
31561
31996
  },
31562
31997
  admitted(row, attribution) {
@@ -31579,7 +32014,7 @@ function createVaultSelectionState(options) {
31579
32014
  }
31580
32015
  }
31581
32016
  },
31582
- flush,
32017
+ flush: flush2,
31583
32018
  recordQuota(attribution, quota, signal) {
31584
32019
  return options.source.commitState(
31585
32020
  attribution,
@@ -31706,6 +32141,10 @@ async function checkVaultQuota(input2) {
31706
32141
  input2.onStage?.("fetch");
31707
32142
  const answer = await input2.fetchReading(row.route, input2.signal);
31708
32143
  input2.signal.throwIfAborted();
32144
+ if (answer === void 0) {
32145
+ input2.onOutcome?.("fetch-failed");
32146
+ continue;
32147
+ }
31709
32148
  const attribution = answer.quotaAttribution;
31710
32149
  if (answer.quota.error !== void 0) {
31711
32150
  input2.onOutcome?.("fetch-failed");
@@ -31715,7 +32154,7 @@ async function checkVaultQuota(input2) {
31715
32154
  input2.onOutcome?.("unattributed");
31716
32155
  continue;
31717
32156
  }
31718
- const reading = vaultQuotaState(answer.quota, now());
32157
+ const reading = vaultQuotaState(answer.quota, answer.observedAt ?? now());
31719
32158
  input2.onStage?.("commit");
31720
32159
  input2.signal.throwIfAborted();
31721
32160
  const result = await state.recordQuota(attribution, reading, input2.signal);
@@ -31746,6 +32185,48 @@ async function checkVaultQuota(input2) {
31746
32185
  return { checked, notChecked: rows.length - checked };
31747
32186
  }
31748
32187
 
32188
+ // src/plugin/vault-insula-quota.ts
32189
+ var windows = [
32190
+ ["gemini-5h", "gemini", "5h"],
32191
+ ["gemini-weekly", "gemini", "weekly"],
32192
+ ["3p-5h", "non-gemini", "5h"],
32193
+ ["3p-weekly", "non-gemini", "weekly"]
32194
+ ];
32195
+ var normalizeVaultInsulaQuota = (entry, context) => {
32196
+ if (entry.source !== "vault") return void 0;
32197
+ if (entry.provider !== "antigravity" || !entry.account?.trim() || !Number.isFinite(context.fetchedAt))
32198
+ return void 0;
32199
+ const groups = {};
32200
+ for (const [id, group, window] of windows) {
32201
+ const reading = entry.usage?.extraRateWindows?.find(
32202
+ (extra) => extra.id === id
32203
+ )?.window;
32204
+ if (!reading || !Number.isFinite(reading.usedPercent) || reading.usedPercent < 0 || reading.usedPercent > 100)
32205
+ continue;
32206
+ const normalized = {
32207
+ window,
32208
+ remainingFraction: 1 - reading.usedPercent / 100,
32209
+ resetTime: reading.resetsAt ?? ""
32210
+ };
32211
+ let summary = groups[group];
32212
+ if (summary === void 0) {
32213
+ summary = { modelCount: 0, windows: [] };
32214
+ groups[group] = summary;
32215
+ }
32216
+ summary.windows?.push(normalized);
32217
+ if (summary.remainingFraction === void 0 || normalized.remainingFraction < summary.remainingFraction) {
32218
+ summary.remainingFraction = normalized.remainingFraction;
32219
+ summary.resetTime = normalized.resetTime;
32220
+ }
32221
+ }
32222
+ if (Object.keys(groups).length === 0) return void 0;
32223
+ return {
32224
+ quota: { groups, modelCount: 0 },
32225
+ accountIdentity: entry.account.trim(),
32226
+ observedAt: context.fetchedAt
32227
+ };
32228
+ };
32229
+
31749
32230
  // src/plugin/vault-custody.ts
31750
32231
  var OPENCODE_VAULT_PROVIDER = "google";
31751
32232
  var OPENCODE_VAULT_HOST = "opencode";
@@ -31854,6 +32335,12 @@ function createOpenCodeVaultCustody(options) {
31854
32335
  onError: () => options.onRosterChanged?.(),
31855
32336
  reporterSource: options.reporterSource,
31856
32337
  state: { path: paths.stateFile, fs: await loadCommonAuthFs() },
32338
+ ...options.insulaQuota ? {
32339
+ insula: {
32340
+ provider: "antigravity",
32341
+ normalize: normalizeVaultInsulaQuota
32342
+ }
32343
+ } : {},
31857
32344
  ...options.logger ? { logger: options.logger } : {},
31858
32345
  ...options.now ? { now: options.now } : {},
31859
32346
  ...options.pollIntervalMs !== void 0 ? { pollIntervalMs: options.pollIntervalMs } : {}
@@ -31926,11 +32413,11 @@ function createOpenCodeVaultCustody(options) {
31926
32413
  ].join("\n");
31927
32414
  const waitForApproval = async () => {
31928
32415
  while (!closed) {
31929
- await new Promise((resolve18) => {
32416
+ await new Promise((resolve20) => {
31930
32417
  const done = () => {
31931
32418
  clearTimeout(timer);
31932
32419
  cancelWait = void 0;
31933
- resolve18();
32420
+ resolve20();
31934
32421
  };
31935
32422
  const timer = setTimeout(done, 2e3);
31936
32423
  timer.unref?.();
@@ -32271,7 +32758,7 @@ async function writeNativeSlot(host, slot, context, expectedAuthority = "local")
32271
32758
  beforeRename: async () => {
32272
32759
  await assertSetupHostsStopped();
32273
32760
  const claustrum = await loadCommonAuthClaustrum();
32274
- const stateDir = host === "opencode" ? openCodeVaultPaths(resolve11(getStoragePath())).dir : getPiAntigravityVaultDir();
32761
+ const stateDir = host === "opencode" ? openCodeVaultPaths(resolve13(getStoragePath())).dir : getPiAntigravityVaultDir();
32275
32762
  if (await claustrum.enrollmentAuthority(
32276
32763
  claustrum.hostEnrollmentPaths({ stateDir, host }),
32277
32764
  `antigravity-auth-${host}`
@@ -32301,7 +32788,7 @@ async function persistPiSetupLogin(result, context) {
32301
32788
  }
32302
32789
  async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
32303
32790
  const claustrum = await loadCommonAuthClaustrum();
32304
- const opencode = openCodeVaultPaths(resolve11(getStoragePath()));
32791
+ const opencode = openCodeVaultPaths(resolve13(getStoragePath()));
32305
32792
  const piDir = getPiAntigravityVaultDir();
32306
32793
  const hosts = {
32307
32794
  opencode: {
@@ -32320,7 +32807,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
32320
32807
  const assertLocal = async (host, context) => {
32321
32808
  if (host === "opencode")
32322
32809
  return assertLocalOpenCodeLogin(
32323
- resolve11(getStoragePath()),
32810
+ resolve13(getStoragePath()),
32324
32811
  context.opencodeGeneration
32325
32812
  );
32326
32813
  if (await authority(host) !== "local")
@@ -32852,7 +33339,7 @@ function createDefaultCliDependencies() {
32852
33339
  throw new Error(
32853
33340
  "Pi setup requires its detected native agent directory."
32854
33341
  );
32855
- const legacyPath = resolve12(getStoragePath());
33342
+ const legacyPath = resolve14(getStoragePath());
32856
33343
  const repository = host === "pi" ? void 0 : await prepareCliLoginStore(legacyPath, context?.opencodeGeneration);
32857
33344
  try {
32858
33345
  return await performOAuthLogin(request, {
@@ -33012,7 +33499,7 @@ async function readAccountStore(legacyPath) {
33012
33499
  function createDefaultAccountStoreOperations() {
33013
33500
  const offline = { processesStopped: true };
33014
33501
  return {
33015
- legacyPath: () => resolve12(getStoragePath()),
33502
+ legacyPath: () => resolve14(getStoragePath()),
33016
33503
  migrate: async (legacyPath) => createAccountMigrationFactory(await loadCommonAuthStoreModules())({
33017
33504
  legacyPath,
33018
33505
  offline,
@@ -33513,14 +34000,14 @@ function isTuiConnected(sessionId) {
33513
34000
  // src/rpc/rpc-dir.ts
33514
34001
  import { createHash as createHash11 } from "node:crypto";
33515
34002
  import { homedir as homedir8, tmpdir as tmpdir2 } from "node:os";
33516
- import { isAbsolute as isAbsolute4, join as join20, resolve as resolve13 } from "node:path";
34003
+ import { isAbsolute as isAbsolute4, join as join20, resolve as resolve15 } from "node:path";
33517
34004
  var RPC_DIR_ENV = "ANTIGRAVITY_AUTH_RPC_DIR";
33518
34005
  function getRpcDir(projectDirectory) {
33519
34006
  const override = process.env[RPC_DIR_ENV]?.trim();
33520
34007
  if (override) {
33521
- return isAbsolute4(override) ? override : resolve13(projectDirectory, override);
34008
+ return isAbsolute4(override) ? override : resolve15(projectDirectory, override);
33522
34009
  }
33523
- const projectHash = createHash11("sha256").update(resolve13(projectDirectory)).digest("hex").slice(0, 16);
34010
+ const projectHash = createHash11("sha256").update(resolve15(projectDirectory)).digest("hex").slice(0, 16);
33524
34011
  const stateHome = process.env.XDG_STATE_HOME ?? join20(homedir8(), ".local", "state");
33525
34012
  return join20(stateHome, "cortexkit", "antigravity-auth", "rpc", projectHash);
33526
34013
  }
@@ -33533,7 +34020,7 @@ function isSessionId(value) {
33533
34020
  // src/common-auth-embedded/rpc/port-file.js
33534
34021
  import { createHash as createHash12, randomUUID as randomUUID18 } from "node:crypto";
33535
34022
  import { chmod as chmod5, mkdir as mkdir15, open as open12, readdir, rename as rename11, rmdir as rmdir2, stat as stat10, unlink as unlink11 } from "node:fs/promises";
33536
- import { join as join21, resolve as resolve14 } from "node:path";
34023
+ import { join as join21, resolve as resolve16 } from "node:path";
33537
34024
  function isProbeablePid(pid) {
33538
34025
  return typeof pid === "number" && Number.isSafeInteger(pid) && pid > 0;
33539
34026
  }
@@ -33620,7 +34107,7 @@ async function sweepRpcState(root, activeDir, isManagedDir, log16) {
33620
34107
  return;
33621
34108
  throw error;
33622
34109
  }
33623
- const active2 = resolve14(activeDir);
34110
+ const active2 = resolve16(activeDir);
33624
34111
  for (const projectDir of projectDirs) {
33625
34112
  if (!projectDir.isDirectory() || !isManagedDir(projectDir.name)) {
33626
34113
  continue;
@@ -33664,7 +34151,7 @@ async function sweepRpcState(root, activeDir, isManagedDir, log16) {
33664
34151
  await unlink11(portFile).catch(() => {
33665
34152
  });
33666
34153
  }
33667
- if (resolve14(dir) !== active2)
34154
+ if (resolve16(dir) !== active2)
33668
34155
  await rmdir2(dir).catch(() => {
33669
34156
  });
33670
34157
  }
@@ -33694,7 +34181,7 @@ var BodyTooLargeError = class extends Error {
33694
34181
  }
33695
34182
  };
33696
34183
  function readBody(req) {
33697
- return new Promise((resolve18, reject) => {
34184
+ return new Promise((resolve20, reject) => {
33698
34185
  const tooLarge = (declaredOversize = false) => {
33699
34186
  req.removeAllListeners("data");
33700
34187
  req.on("data", () => {
@@ -33717,7 +34204,7 @@ function readBody(req) {
33717
34204
  }
33718
34205
  chunks.push(chunk);
33719
34206
  });
33720
- req.on("end", () => resolve18(Buffer.concat(chunks).toString("utf8")));
34207
+ req.on("end", () => resolve20(Buffer.concat(chunks).toString("utf8")));
33721
34208
  req.on("error", reject);
33722
34209
  });
33723
34210
  }
@@ -33885,12 +34372,12 @@ async function startRpcServer(options) {
33885
34372
  json(500, { error: "internal error" });
33886
34373
  }
33887
34374
  }
33888
- const port = await new Promise((resolve18, reject) => {
34375
+ const port = await new Promise((resolve20, reject) => {
33889
34376
  server.on("error", reject);
33890
34377
  server.listen(0, "127.0.0.1", () => {
33891
34378
  const addr = server.address();
33892
34379
  if (addr && typeof addr === "object")
33893
- resolve18(addr.port);
34380
+ resolve20(addr.port);
33894
34381
  else
33895
34382
  reject(new Error("no port"));
33896
34383
  });
@@ -33913,16 +34400,16 @@ async function startRpcServer(options) {
33913
34400
  rpcPort: port
33914
34401
  });
33915
34402
  } catch (error) {
33916
- await new Promise((resolve18) => server.close(() => resolve18()));
34403
+ await new Promise((resolve20) => server.close(() => resolve20()));
33917
34404
  throw error;
33918
34405
  }
33919
34406
  return {
33920
34407
  port,
33921
34408
  token,
33922
34409
  async stop() {
33923
- await new Promise((resolve18) => {
34410
+ await new Promise((resolve20) => {
33924
34411
  server.closeAllConnections?.();
33925
- server.close(() => resolve18());
34412
+ server.close(() => resolve20());
33926
34413
  for (const socket of connections)
33927
34414
  socket.destroy();
33928
34415
  });
@@ -33996,21 +34483,21 @@ function parsePending(value) {
33996
34483
  function present4(value) {
33997
34484
  return value === null ? void 0 : value;
33998
34485
  }
33999
- function accessBlockOf(fields) {
34000
- if (fields === void 0) return { kind: "none" };
34001
- if (fields.accountIneligible === true) {
34002
- const reason = present4(fields.accountIneligibleReason);
34003
- const at = present4(fields.accountIneligibleAt);
34486
+ function accessBlockOf(fields2) {
34487
+ if (fields2 === void 0) return { kind: "none" };
34488
+ if (fields2.accountIneligible === true) {
34489
+ const reason = present4(fields2.accountIneligibleReason);
34490
+ const at = present4(fields2.accountIneligibleAt);
34004
34491
  return {
34005
34492
  kind: "ineligible",
34006
34493
  ...reason !== void 0 ? { reason } : {},
34007
34494
  ...at !== void 0 ? { at } : {}
34008
34495
  };
34009
34496
  }
34010
- if (fields.verificationRequired === true) {
34011
- const reason = present4(fields.verificationRequiredReason);
34012
- const verificationUrl = present4(fields.verificationUrl);
34013
- const at = present4(fields.verificationRequiredAt);
34497
+ if (fields2.verificationRequired === true) {
34498
+ const reason = present4(fields2.verificationRequiredReason);
34499
+ const verificationUrl = present4(fields2.verificationUrl);
34500
+ const at = present4(fields2.verificationRequiredAt);
34014
34501
  return {
34015
34502
  kind: "verification-required",
34016
34503
  ...reason !== void 0 ? { reason } : {},
@@ -35265,7 +35752,7 @@ async function select3(items, options) {
35265
35752
  }
35266
35753
  renderedLines = linesWritten;
35267
35754
  };
35268
- return new Promise((resolve18) => {
35755
+ return new Promise((resolve20) => {
35269
35756
  const wasRaw = stdin.isRaw ?? false;
35270
35757
  const cleanup2 = () => {
35271
35758
  if (isCleanedUp) return;
@@ -35286,11 +35773,11 @@ async function select3(items, options) {
35286
35773
  };
35287
35774
  const onSignal = () => {
35288
35775
  cleanup2();
35289
- resolve18(null);
35776
+ resolve20(null);
35290
35777
  };
35291
35778
  const finishWithValue = (value) => {
35292
35779
  cleanup2();
35293
- resolve18(value);
35780
+ resolve20(value);
35294
35781
  };
35295
35782
  const findNextSelectable = (from, direction) => {
35296
35783
  if (items.length === 0) return from;
@@ -35336,7 +35823,7 @@ async function select3(items, options) {
35336
35823
  stdin.setRawMode(true);
35337
35824
  } catch {
35338
35825
  cleanup2();
35339
- resolve18(null);
35826
+ resolve20(null);
35340
35827
  return;
35341
35828
  }
35342
35829
  stdin.resume();
@@ -38092,7 +38579,7 @@ var SignatureCache = class {
38092
38579
  // src/plugin/config/loader.ts
38093
38580
  import { existsSync as existsSync10, readFileSync as readFileSync10, realpathSync as realpathSync3 } from "node:fs";
38094
38581
  import { homedir as homedir11 } from "node:os";
38095
- import { basename as basename6, dirname as dirname23, join as join25, resolve as resolve15 } from "node:path";
38582
+ import { basename as basename6, dirname as dirname23, join as join25, resolve as resolve17 } from "node:path";
38096
38583
 
38097
38584
  // src/plugin/config/schema.ts
38098
38585
  import { z } from "zod";
@@ -38650,7 +39137,7 @@ function loadConfigWithLogger(directory, log16) {
38650
39137
  return config;
38651
39138
  }
38652
39139
  function canonicalizeOwnedPath(path5) {
38653
- const absolute = resolve15(path5);
39140
+ const absolute = resolve17(path5);
38654
39141
  const missing = [];
38655
39142
  let current = absolute;
38656
39143
  for (; ; ) {
@@ -41571,6 +42058,7 @@ var NATIVE_GOOGLE_ERROR_MESSAGES = {
41571
42058
  operator_policy: "Antigravity account pool is unavailable under the operator quota policy. Adjust /antigravity-killswitch or refresh quota.",
41572
42059
  soft_quota: "Antigravity account pool is unavailable under the quota protection policy. Add accounts, wait for quota reset, or disable soft quota protection.",
41573
42060
  pool_unavailable: "Antigravity account pool has no account available within the configured wait limit. Add accounts with `opencode auth login` or wait for quota reset.",
42061
+ model_unavailable: "The requested Antigravity model is not available to the configured accounts. Choose another model.",
41574
42062
  missing_access_token: "Missing access token. Run `opencode auth login` to reauthenticate.",
41575
42063
  empty_response: "Antigravity returned an empty response after the internal retry attempts."
41576
42064
  };
@@ -43567,10 +44055,10 @@ async function retainResponseLifetime(response, cancellation) {
43567
44055
  cancellation.release();
43568
44056
  throw error;
43569
44057
  }
43570
- let resolve18 = () => {
44058
+ let resolve20 = () => {
43571
44059
  };
43572
44060
  const settled = new Promise((done) => {
43573
- resolve18 = done;
44061
+ resolve20 = done;
43574
44062
  });
43575
44063
  let stopping = false;
43576
44064
  let finished = false;
@@ -43580,7 +44068,7 @@ async function retainResponseLifetime(response, cancellation) {
43580
44068
  finished = true;
43581
44069
  cancellation.signal.removeEventListener("abort", abort);
43582
44070
  cancellation.release();
43583
- resolve18();
44071
+ resolve20();
43584
44072
  };
43585
44073
  const abort = () => {
43586
44074
  if (finished || stopping) return;
@@ -43649,8 +44137,8 @@ function createAfterHandoff(work, signals, onFailure) {
43649
44137
  let running = false;
43650
44138
  let resolveCompletion = () => {
43651
44139
  };
43652
- const completion = new Promise((resolve18) => {
43653
- resolveCompletion = resolve18;
44140
+ const completion = new Promise((resolve20) => {
44141
+ resolveCompletion = resolve20;
43654
44142
  });
43655
44143
  const finish = () => {
43656
44144
  if (finished) return;
@@ -43697,14 +44185,14 @@ function createAfterHandoff(work, signals, onFailure) {
43697
44185
  };
43698
44186
  }
43699
44187
  function publishResponse(dispatch) {
43700
- return new Promise((resolve18, reject) => {
44188
+ return new Promise((resolve20, reject) => {
43701
44189
  let acknowledge;
43702
44190
  void Promise.resolve().then(
43703
44191
  () => dispatch((callback) => {
43704
44192
  acknowledge = callback;
43705
44193
  })
43706
44194
  ).then((response) => {
43707
- resolve18(response);
44195
+ resolve20(response);
43708
44196
  acknowledge?.();
43709
44197
  }, reject);
43710
44198
  });
@@ -44698,7 +45186,7 @@ var BackgroundVaultQuotaRefresh = class {
44698
45186
  fetchReading: async (ref, signal) => {
44699
45187
  rowFailure = "fetch-failed";
44700
45188
  await this.assertActive(controller);
44701
- const reading = await fetchVaultAccountQuota({
45189
+ const fallback = () => fetchVaultAccountQuota({
44702
45190
  source,
44703
45191
  ref,
44704
45192
  signal,
@@ -44708,7 +45196,10 @@ var BackgroundVaultQuotaRefresh = class {
44708
45196
  if (kind !== "unknown" || outcome.errorKind === void 0)
44709
45197
  outcome.errorKind = kind;
44710
45198
  if (refused)
44711
- rowFailure = vaultQuotaErrorReason(error, "admission-refused");
45199
+ rowFailure = vaultQuotaErrorReason(
45200
+ error,
45201
+ "admission-refused"
45202
+ );
44712
45203
  },
44713
45204
  transport: async (url, init, extra) => {
44714
45205
  await this.assertActive(controller);
@@ -44731,6 +45222,16 @@ var BackgroundVaultQuotaRefresh = class {
44731
45222
  }
44732
45223
  }
44733
45224
  });
45225
+ const reading = source.pollInsulaQuotaForRoute ? await source.pollInsulaQuotaForRoute(
45226
+ ref,
45227
+ fallback,
45228
+ signal,
45229
+ (reason) => {
45230
+ rowFailure = `insula-${reason}`;
45231
+ }
45232
+ ) : await fallback();
45233
+ if (reading === void 0 && rowFailure === "fetch-failed")
45234
+ rowFailure = "insula-skipped";
44734
45235
  await this.assertActive(controller);
44735
45236
  await lock.assertOwned();
44736
45237
  return reading;
@@ -45391,7 +45892,7 @@ function toCommandAccountRow(entry) {
45391
45892
  const parsed = Date.parse(cachedEntry.resetTime);
45392
45893
  if (Number.isFinite(parsed)) resetAt = parsed;
45393
45894
  }
45394
- const windows = cachedEntry.windows?.length ? cachedEntry.windows.map((w) => ({
45895
+ const windows2 = cachedEntry.windows?.length ? cachedEntry.windows.map((w) => ({
45395
45896
  window: w.window,
45396
45897
  remainingPercent: Math.round(w.remainingFraction * 100),
45397
45898
  resetAt: typeof w.resetTime === "string" && w.resetTime.length > 0 ? (() => {
@@ -45404,7 +45905,7 @@ function toCommandAccountRow(entry) {
45404
45905
  label: QUOTA_GROUP_LABELS[key],
45405
45906
  remainingPercent,
45406
45907
  resetAt,
45407
- windows
45908
+ windows: windows2
45408
45909
  });
45409
45910
  }
45410
45911
  const label = `Account ${entry.index + 1}`;
@@ -45480,10 +45981,10 @@ function resolvePluginDependencies(overrides = {}) {
45480
45981
  }
45481
45982
  async function defaultSleep(ms, signal) {
45482
45983
  if (ms <= 0) return;
45483
- await new Promise((resolve18, reject) => {
45984
+ await new Promise((resolve20, reject) => {
45484
45985
  const timer = setTimeout(() => {
45485
45986
  signal?.removeEventListener("abort", onAbort);
45486
- resolve18();
45987
+ resolve20();
45487
45988
  }, ms);
45488
45989
  timer.unref?.();
45489
45990
  const onAbort = () => {
@@ -45505,7 +46006,7 @@ function createEventHandler({
45505
46006
  sessionRegistry,
45506
46007
  sessionRecovery,
45507
46008
  updateChecker,
45508
- logger: logger2
46009
+ logger: logger3
45509
46010
  }) {
45510
46011
  return async (input2) => {
45511
46012
  await updateChecker.event(input2);
@@ -45517,14 +46018,14 @@ function createEventHandler({
45517
46018
  sessionRegistry.register(sessionId, parentSessionId);
45518
46019
  }
45519
46020
  if (parentSessionId) {
45520
- logger2.debug("child-session-detected", {
46021
+ logger3.debug("child-session-detected", {
45521
46022
  sessionId,
45522
46023
  parentID: parentSessionId
45523
46024
  });
45524
46025
  } else {
45525
46026
  const previousSummary = lifecycle.getAccountManager()?.getSessionSummary();
45526
46027
  if (previousSummary && (previousSummary.totalClaude > 0 || previousSummary.totalGemini > 0)) {
45527
- logger2.debug("prev-session-quota-summary", {
46028
+ logger3.debug("prev-session-quota-summary", {
45528
46029
  durationMinutes: previousSummary.durationMinutes,
45529
46030
  totalClaude: previousSummary.totalClaude,
45530
46031
  totalGemini: previousSummary.totalGemini,
@@ -45532,7 +46033,7 @@ function createEventHandler({
45532
46033
  accountsUsed: previousSummary.accountsUsed
45533
46034
  });
45534
46035
  }
45535
- logger2.debug("root-session-detected", { sessionId });
46036
+ logger3.debug("root-session-detected", { sessionId });
45536
46037
  }
45537
46038
  }
45538
46039
  if (input2.event.type === "session.deleted") {
@@ -45541,7 +46042,7 @@ function createEventHandler({
45541
46042
  if (sessionId) {
45542
46043
  sessionRegistry.delete(sessionId);
45543
46044
  lifecycle.getAccountManager()?.deleteSessionState(sessionId);
45544
- const eventLogger = logger2;
46045
+ const eventLogger = logger3;
45545
46046
  void removeSidebarActiveRouting(sessionId).catch((error2) => {
45546
46047
  eventLogger.debug("sidebar-route-remove-failed", {
45547
46048
  sessionId,
@@ -45577,7 +46078,7 @@ function createEventHandler({
45577
46078
  });
45578
46079
  const successToast = getRecoverySuccessToast();
45579
46080
  const isChildSession = sessionRegistry.getParentSessionId(sessionID) !== null;
45580
- logger2.debug("recovery-toast", {
46081
+ logger3.debug("recovery-toast", {
45581
46082
  ...successToast,
45582
46083
  isChildSession,
45583
46084
  toastScope: config.toast_scope
@@ -46060,7 +46561,7 @@ function throwIfAllKilled(input2) {
46060
46561
  }
46061
46562
 
46062
46563
  // src/plugin/session-context.ts
46063
- import { resolve as resolve16 } from "node:path";
46564
+ import { resolve as resolve18 } from "node:path";
46064
46565
  import { pathToFileURL } from "node:url";
46065
46566
  var FALLBACK_SESSION_KEY = "__default__";
46066
46567
  function extractOpenCodeSessionIdentity(headers) {
@@ -46074,7 +46575,7 @@ var AgySessionRegistry = class {
46074
46575
  requestSessions;
46075
46576
  parentSessionIds = /* @__PURE__ */ new Map();
46076
46577
  constructor(directory, options = {}) {
46077
- const workspaceUri = directory ? pathToFileURL(resolve16(directory)).href : "";
46578
+ const workspaceUri = directory ? pathToFileURL(resolve18(directory)).href : "";
46078
46579
  this.requestSessions = new AgyRequestSessionStore(workspaceUri, options);
46079
46580
  }
46080
46581
  getOrCreate(identity) {
@@ -46222,7 +46723,7 @@ function formatWaitTime(ms) {
46222
46723
  return remainingMinutes > 0 ? `${hours}h ${remainingMinutes}m` : `${hours}h`;
46223
46724
  }
46224
46725
  function sleep4(ms, signal) {
46225
- return new Promise((resolve18, reject) => {
46726
+ return new Promise((resolve20, reject) => {
46226
46727
  if (signal?.aborted) {
46227
46728
  reject(
46228
46729
  signal.reason instanceof Error ? signal.reason : new Error("Aborted")
@@ -46231,7 +46732,7 @@ function sleep4(ms, signal) {
46231
46732
  }
46232
46733
  const timeout = setTimeout(() => {
46233
46734
  cleanup2();
46234
- resolve18();
46735
+ resolve20();
46235
46736
  }, ms);
46236
46737
  const onAbort = () => {
46237
46738
  cleanup2();
@@ -46487,6 +46988,7 @@ function createRequestExecutor(deps) {
46487
46988
  let localRecaptureUsed = false;
46488
46989
  const maxWaitMs = (config.max_rate_limit_wait_seconds ?? 300) * 1e3;
46489
46990
  let allAccountsBlockedAt;
46991
+ const modelUnavailableIndexes = /* @__PURE__ */ new Set();
46490
46992
  while (true) {
46491
46993
  await assertAdmission();
46492
46994
  checkAborted();
@@ -46550,6 +47052,26 @@ function createRequestExecutor(deps) {
46550
47052
  const killedIndexes = eligibleIndexes === null ? void 0 : new Set(
46551
47053
  accountManager.getAccounts().map((entry) => entry.index).filter((index) => !eligibleIndexes.has(index))
46552
47054
  );
47055
+ if (modelUnavailableIndexes.size > 0) {
47056
+ const candidates = accountManager.getEnabledAccounts().filter(
47057
+ (entry) => eligibleIndexes === null || eligibleIndexes.has(entry.index)
47058
+ );
47059
+ if (candidates.length > 0 && candidates.every((entry) => modelUnavailableIndexes.has(entry.index))) {
47060
+ pushDebug(
47061
+ `model-unavailable: all ${candidates.length} eligible account(s) skipped`
47062
+ );
47063
+ log16.warn("model-unavailable-all-accounts", {
47064
+ family,
47065
+ model,
47066
+ accounts: candidates.length
47067
+ });
47068
+ return createNativeGoogleErrorResponse({
47069
+ status: 412,
47070
+ reason: "model_unavailable"
47071
+ });
47072
+ }
47073
+ }
47074
+ const excludedIndexes = modelUnavailableIndexes.size === 0 ? killedIndexes : /* @__PURE__ */ new Set([...killedIndexes ?? [], ...modelUnavailableIndexes]);
46553
47075
  let account = accountManager.getCurrentOrNextForFamily(
46554
47076
  family,
46555
47077
  model,
@@ -46558,7 +47080,7 @@ function createRequestExecutor(deps) {
46558
47080
  config.soft_quota_threshold_percent,
46559
47081
  softQuotaCacheTtlMs,
46560
47082
  accountSessionIdentity,
46561
- killedIndexes
47083
+ excludedIndexes
46562
47084
  );
46563
47085
  if (account && eligibleIndexes !== null && !eligibleIndexes.has(account.index)) {
46564
47086
  pushDebug(
@@ -47025,6 +47547,7 @@ function createRequestExecutor(deps) {
47025
47547
  };
47026
47548
  let apiRequestCount = 0;
47027
47549
  let shouldSwitchAccount = false;
47550
+ let skippedForModelUnavailable = false;
47028
47551
  if (account.fingerprint) {
47029
47552
  pushDebug(
47030
47553
  `fingerprint: deviceId=${account.fingerprint.deviceId.slice(0, 8)}...`
@@ -47404,6 +47927,37 @@ function createRequestExecutor(deps) {
47404
47927
  shouldSwitchAccount = true;
47405
47928
  break;
47406
47929
  }
47930
+ if (response.status === 404 && currentEndpoint === ANTIGRAVITY_ENDPOINT_DAILY) {
47931
+ const notFoundBody = await deadline.wait(
47932
+ () => response.clone().text().catch(() => "")
47933
+ );
47934
+ const unavailable = parseModelUnavailableError(notFoundBody);
47935
+ if (unavailable) {
47936
+ if (tokenConsumed) {
47937
+ trackers.token.refund(account.index);
47938
+ tokenConsumed = false;
47939
+ }
47940
+ const reasonCodes = unavailable.reasons.length > 0 ? unavailable.reasons.join(",") : "none";
47941
+ const note = `model-unavailable idx=${account.index} status=${unavailable.status} reasons=${reasonCodes}`;
47942
+ pushDebug(note);
47943
+ debug.logAntigravityDebugResponse(debugContext, response, {
47944
+ note
47945
+ });
47946
+ log16.info("model-unavailable", {
47947
+ accountIndex: account.index,
47948
+ family,
47949
+ model,
47950
+ status: unavailable.status,
47951
+ reasons: unavailable.reasons
47952
+ });
47953
+ void response.body?.cancel().catch(() => {
47954
+ });
47955
+ modelUnavailableIndexes.add(account.index);
47956
+ skippedForModelUnavailable = true;
47957
+ shouldSwitchAccount = true;
47958
+ break;
47959
+ }
47960
+ }
47407
47961
  const quotaKey = getQuotaKey(family, model);
47408
47962
  retryState.resetRateLimitState(account.index, quotaKey);
47409
47963
  retryState.resetAccountFailureState(account.index);
@@ -47470,7 +48024,7 @@ function createRequestExecutor(deps) {
47470
48024
  break;
47471
48025
  }
47472
48026
  }
47473
- const shouldRetryEndpoint = response.status === 403 || response.status === 404 || response.status >= 500;
48027
+ const shouldRetryEndpoint = response.status === 404 || response.status >= 500;
47474
48028
  if (shouldRetryEndpoint && i < ANTIGRAVITY_ENDPOINT_FALLBACKS.length - 1) {
47475
48029
  await logResponseBody2(debugContext, response, response.status);
47476
48030
  lastFailure = createFailureContext(response);
@@ -47721,6 +48275,9 @@ function createRequestExecutor(deps) {
47721
48275
  }
47722
48276
  }
47723
48277
  }
48278
+ if (shouldSwitchAccount && skippedForModelUnavailable) {
48279
+ continue;
48280
+ }
47724
48281
  if (shouldSwitchAccount) {
47725
48282
  accountSwitchCount++;
47726
48283
  if (accountSwitchCount > maxAccountSwitches) {
@@ -47923,6 +48480,32 @@ function createRequestExecutor(deps) {
47923
48480
  dispose
47924
48481
  };
47925
48482
  }
48483
+ var ERROR_REASON_CODE = /^[A-Za-z0-9_.-]{1,128}$/;
48484
+ function parseModelUnavailableError(bodyText) {
48485
+ let body;
48486
+ try {
48487
+ body = JSON.parse(bodyText);
48488
+ } catch {
48489
+ return null;
48490
+ }
48491
+ const envelope = Array.isArray(body) ? body[0] : body;
48492
+ if (!envelope || typeof envelope !== "object") return null;
48493
+ const error = envelope.error;
48494
+ if (!error || typeof error !== "object") return null;
48495
+ if (error.status !== "NOT_FOUND") return null;
48496
+ const details = error.details;
48497
+ const reasons = [];
48498
+ if (Array.isArray(details)) {
48499
+ for (const detail of details) {
48500
+ if (!detail || typeof detail !== "object") continue;
48501
+ const reason = detail.reason;
48502
+ if (typeof reason === "string" && ERROR_REASON_CODE.test(reason)) {
48503
+ reasons.push(reason);
48504
+ }
48505
+ }
48506
+ }
48507
+ return { status: "NOT_FOUND", reasons };
48508
+ }
47926
48509
  function extractRateLimitBodyInfo(body) {
47927
48510
  if (!body || typeof body !== "object") return { retryDelayMs: null };
47928
48511
  const error = body.error;
@@ -48617,8 +49200,8 @@ function createPluginLifecycle(options) {
48617
49200
  };
48618
49201
  let failDisposal = () => {
48619
49202
  };
48620
- disposal = new Promise((resolve18, reject) => {
48621
- finishDisposal = resolve18;
49203
+ disposal = new Promise((resolve20, reject) => {
49204
+ finishDisposal = resolve20;
48622
49205
  failDisposal = reject;
48623
49206
  });
48624
49207
  void (async () => {
@@ -48731,7 +49314,7 @@ function createVaultAccountMenuSections(pool, selectorOf, checkQuota) {
48731
49314
  }
48732
49315
 
48733
49316
  // src/plugin/index.ts
48734
- var logger = createLogger4("plugin");
49317
+ var logger2 = createLogger4("plugin");
48735
49318
  function quotaAccountIdentity4(refreshToken) {
48736
49319
  return createHash20("sha256").update(refreshToken).digest("hex").slice(0, 16);
48737
49320
  }
@@ -48800,7 +49383,8 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
48800
49383
  });
48801
49384
  let vaultQuotaPoller;
48802
49385
  const vaultCustody = createOpenCodeVaultCustody({
48803
- accountFile: resolve17(getStoragePath()),
49386
+ accountFile: resolve19(getStoragePath()),
49387
+ insulaQuota: true,
48804
49388
  readHostSlot: async () => {
48805
49389
  if (!cachedGetAuth)
48806
49390
  throw new Error("OpenCode has not provided its sign-in yet");
@@ -48923,7 +49507,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
48923
49507
  });
48924
49508
  function scheduleSidebarPublication() {
48925
49509
  void sidebarPublisher.publish().catch(
48926
- (error) => logger.debug("sidebar-source-publish-failed", {
49510
+ (error) => logger2.debug("sidebar-source-publish-failed", {
48927
49511
  error: error instanceof Error ? error.name : "unknown"
48928
49512
  })
48929
49513
  );
@@ -48953,7 +49537,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
48953
49537
  }
48954
49538
  );
48955
49539
  })().catch(
48956
- (error) => logger.debug("sidebar-routing-publish-failed", {
49540
+ (error) => logger2.debug("sidebar-routing-publish-failed", {
48957
49541
  error: error instanceof Error ? error.name : "unknown"
48958
49542
  })
48959
49543
  );
@@ -48998,8 +49582,8 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
48998
49582
  readProviderState: () => vaultCustody.readState(),
48999
49583
  publishSidebar: () => sidebarPublisher.publish(),
49000
49584
  transport: vaultQuotaTransport,
49001
- logger,
49002
- onOutcome: (level, outcome) => (level === "warn" ? quotaOutcomeLogger : logger)[level](
49585
+ logger: logger2,
49586
+ onOutcome: (level, outcome) => (level === "warn" ? quotaOutcomeLogger : logger2)[level](
49003
49587
  "vault-quota-tick",
49004
49588
  { ...outcome }
49005
49589
  ),
@@ -49035,7 +49619,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
49035
49619
  sessionRegistry,
49036
49620
  sessionRecovery,
49037
49621
  updateChecker,
49038
- logger
49622
+ logger: logger2
49039
49623
  });
49040
49624
  let storeQuota = null;
49041
49625
  const currentStoreQuota = async (knownRepository) => {
@@ -49141,7 +49725,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
49141
49725
  source,
49142
49726
  ref,
49143
49727
  signal: check,
49144
- logger,
49728
+ logger: logger2,
49145
49729
  transport: vaultQuotaTransport
49146
49730
  })
49147
49731
  },
@@ -49401,7 +49985,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
49401
49985
  if (await readAuthority() === "local")
49402
49986
  await lifecycle.getAccountManager()?.refreshFromRepository();
49403
49987
  } catch (error) {
49404
- logger.warn("menu-routing-refresh-failed", { error: String(error) });
49988
+ logger2.warn("menu-routing-refresh-failed", { error: String(error) });
49405
49989
  pushNotification(
49406
49990
  {
49407
49991
  command: ANTIGRAVITY_MENU_COMMAND,