@cortexkit/opencode-antigravity-auth 3.0.21 → 3.0.22

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 (80) hide show
  1. package/dist/cli.js +279 -246
  2. package/dist/cli.js.map +3 -3
  3. package/dist/cli.meta.json +38 -13
  4. package/dist/index.js +766 -360
  5. package/dist/index.js.map +4 -4
  6. package/dist/index.meta.json +95 -20
  7. package/dist/server.js +785 -379
  8. package/dist/server.js.map +4 -4
  9. package/dist/server.meta.json +1 -1
  10. package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +2 -2
  11. package/dist/src/common-auth-embedded/fs/with-lock.js +37 -10
  12. package/dist/src/common-auth-embedded/quota/format.d.ts +9 -4
  13. package/dist/src/common-auth-embedded/quota/format.js +45 -26
  14. package/dist/src/common-auth-embedded/quota-sidebar/index.tsx +56 -32
  15. package/dist/src/common-auth-embedded/routing-accessor/index.d.ts +62 -0
  16. package/dist/src/common-auth-embedded/routing-accessor/index.js +128 -0
  17. package/dist/src/common-auth-embedded/source-output.json +42 -22
  18. package/dist/src/plugin/__fixtures__/verified-store.js +2 -2
  19. package/dist/src/plugin/index.d.ts.map +1 -1
  20. package/dist/src/plugin/index.js +2 -0
  21. package/dist/src/plugin/index.js.map +1 -1
  22. package/dist/src/plugin/request.d.ts.map +1 -1
  23. package/dist/src/plugin/request.js +1 -0
  24. package/dist/src/plugin/request.js.map +1 -1
  25. package/dist/src/plugin/shared/request-services.d.ts +6 -0
  26. package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
  27. package/dist/src/plugin/shared/request-services.js +89 -2
  28. package/dist/src/plugin/shared/request-services.js.map +1 -1
  29. package/dist/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
  30. package/dist/src/plugin/shared/vault-request-credentials.js +4 -0
  31. package/dist/src/plugin/shared/vault-request-credentials.js.map +1 -1
  32. package/dist/src/plugin/shared/vault-routing-purpose.d.ts +12 -0
  33. package/dist/src/plugin/shared/vault-routing-purpose.d.ts.map +1 -0
  34. package/dist/src/plugin/shared/vault-routing-purpose.js +18 -0
  35. package/dist/src/plugin/shared/vault-routing-purpose.js.map +1 -0
  36. package/dist/src/plugin/shared/vault-routing.d.ts +36 -0
  37. package/dist/src/plugin/shared/vault-routing.d.ts.map +1 -0
  38. package/dist/src/plugin/shared/vault-routing.js +213 -0
  39. package/dist/src/plugin/shared/vault-routing.js.map +1 -0
  40. package/dist/src/plugin/types.d.ts +1 -0
  41. package/dist/src/plugin/types.d.ts.map +1 -1
  42. package/dist/src/tui/sidebar-frame.d.ts.map +1 -1
  43. package/dist/src/tui/sidebar-frame.js +18 -16
  44. package/dist/src/tui/sidebar-frame.js.map +1 -1
  45. package/dist/tui-build-map.json +13 -13
  46. package/dist/tui-ga-build-map.json +13 -13
  47. package/dist/types/src/common-auth-embedded/quota/format.d.ts +9 -4
  48. package/dist/types/src/common-auth-embedded/routing-accessor/index.d.ts +62 -0
  49. package/dist/types/src/plugin/index.d.ts.map +1 -1
  50. package/dist/types/src/plugin/request.d.ts.map +1 -1
  51. package/dist/types/src/plugin/shared/request-services.d.ts +6 -0
  52. package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -1
  53. package/dist/types/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
  54. package/dist/types/src/plugin/shared/vault-routing-purpose.d.ts +12 -0
  55. package/dist/types/src/plugin/shared/vault-routing-purpose.d.ts.map +1 -0
  56. package/dist/types/src/plugin/shared/vault-routing.d.ts +36 -0
  57. package/dist/types/src/plugin/shared/vault-routing.d.ts.map +1 -0
  58. package/dist/types/src/plugin/types.d.ts +1 -0
  59. package/dist/types/src/plugin/types.d.ts.map +1 -1
  60. package/package.json +2 -2
  61. package/src/common-auth-embedded/fs/refresh-file-lock.js +2 -2
  62. package/src/common-auth-embedded/fs/with-lock.js +37 -10
  63. package/src/common-auth-embedded/quota/format.d.ts +9 -4
  64. package/src/common-auth-embedded/quota/format.js +45 -26
  65. package/src/common-auth-embedded/quota-sidebar/index.tsx +56 -32
  66. package/src/common-auth-embedded/routing-accessor/index.d.ts +62 -0
  67. package/src/common-auth-embedded/routing-accessor/index.js +128 -0
  68. package/src/common-auth-embedded/source-output.json +42 -22
  69. package/src/tui-compiled/common-auth-embedded/quota/format.js +45 -26
  70. package/src/tui-compiled/common-auth-embedded/quota-sidebar/index.js +165 -148
  71. package/src/tui-compiled/tui/sidebar-frame.js +17 -16
  72. package/src/tui-ga-compiled/shared/aef2402f8fc342f0-format.js +45 -26
  73. package/src/tui-ga-compiled/shared/ced204104a639c9c-sidebar-frame.js +17 -16
  74. package/src/tui-ga-compiled/shared/e4ec36f367492969-index.js +165 -148
  75. package/src/tui-ga-raw/shared/aef2402f8fc342f0-format.js +45 -26
  76. package/src/tui-ga-raw/shared/ced204104a639c9c-sidebar-frame.tsx +21 -19
  77. package/src/tui-ga-raw/shared/e4ec36f367492969-index.tsx +56 -32
  78. package/src/tui-raw/common-auth-embedded/quota/format.js +45 -26
  79. package/src/tui-raw/common-auth-embedded/quota-sidebar/index.tsx +56 -32
  80. package/src/tui-raw/tui/sidebar-frame.tsx +21 -19
package/dist/server.js CHANGED
@@ -7751,7 +7751,7 @@ async function rmEvictingDir(evictingPath) {
7751
7751
  });
7752
7752
  }
7753
7753
  async function sleep(ms) {
7754
- await new Promise((resolve27) => setTimeout(resolve27, ms));
7754
+ await new Promise((resolve28) => setTimeout(resolve28, ms));
7755
7755
  }
7756
7756
  async function acquireFencedFileLock(options) {
7757
7757
  const lockPath = `${options.path}.${options.name}.lock`;
@@ -7867,8 +7867,8 @@ function buildLock(lockPath, evictingPath, ownerId, options, now) {
7867
7867
  let released = false;
7868
7868
  let lost = false;
7869
7869
  let lostResolve = null;
7870
- let lostPromise = new Promise((resolve27) => {
7871
- lostResolve = resolve27;
7870
+ let lostPromise = new Promise((resolve28) => {
7871
+ lostResolve = resolve28;
7872
7872
  });
7873
7873
  const markLost = () => {
7874
7874
  if (lost)
@@ -7878,9 +7878,9 @@ function buildLock(lockPath, evictingPath, ownerId, options, now) {
7878
7878
  clearInterval(renewTimer);
7879
7879
  renewTimer = null;
7880
7880
  }
7881
- const resolve27 = lostResolve;
7881
+ const resolve28 = lostResolve;
7882
7882
  lostResolve = null;
7883
- resolve27?.();
7883
+ resolve28?.();
7884
7884
  };
7885
7885
  const setupRenew = () => {
7886
7886
  if (options.renew === false)
@@ -8503,7 +8503,7 @@ async function saveAccountStorageReplace(path5, incoming) {
8503
8503
  return mutateAccountStorage(path5, () => incoming);
8504
8504
  }
8505
8505
  async function clearAccountStorage(path5) {
8506
- const sleep5 = (ms) => new Promise((resolve27) => setTimeout(resolve27, ms));
8506
+ const sleep5 = (ms) => new Promise((resolve28) => setTimeout(resolve28, ms));
8507
8507
  const lock = await acquireWithRetry(path5, sleep5);
8508
8508
  try {
8509
8509
  await assertLegacyAccountStorageWritable(path5);
@@ -8551,7 +8551,7 @@ var init_account_storage = __esm({
8551
8551
  }
8552
8552
  };
8553
8553
  RETRY_DELAYS_MS = [100, 200, 400, 800, 1e3];
8554
- DEFAULT_SLEEP = (ms) => new Promise((resolve27) => setTimeout(resolve27, ms));
8554
+ DEFAULT_SLEEP = (ms) => new Promise((resolve28) => setTimeout(resolve28, ms));
8555
8555
  DEFAULT_BUILD_BACKUP_PATH = (path5, now) => `${path5}.corrupt-${now.toISOString().replace(/[:.]/g, "-")}`;
8556
8556
  }
8557
8557
  });
@@ -9753,8 +9753,8 @@ var init_account_manager = __esm({
9753
9753
  await this.saveInFlight;
9754
9754
  return;
9755
9755
  }
9756
- return new Promise((resolve27, reject) => {
9757
- this.savePromiseResolvers.push({ resolve: resolve27, reject });
9756
+ return new Promise((resolve28, reject) => {
9757
+ this.savePromiseResolvers.push({ resolve: resolve28, reject });
9758
9758
  });
9759
9759
  }
9760
9760
  async dispose() {
@@ -9797,8 +9797,8 @@ var init_account_manager = __esm({
9797
9797
  reject(error);
9798
9798
  throw error;
9799
9799
  }
9800
- for (const { resolve: resolve27 } of resolvers)
9801
- resolve27();
9800
+ for (const { resolve: resolve28 } of resolvers)
9801
+ resolve28();
9802
9802
  }
9803
9803
  async executeSave() {
9804
9804
  this.savePending = false;
@@ -9812,16 +9812,16 @@ var init_account_manager = __esm({
9812
9812
  }
9813
9813
  try {
9814
9814
  await this.saveToDisk();
9815
- for (const { resolve: resolve27 } of resolvers) {
9816
- resolve27();
9815
+ for (const { resolve: resolve28 } of resolvers) {
9816
+ resolve28();
9817
9817
  }
9818
9818
  } catch (error) {
9819
9819
  if (isStorageLockContention(error)) {
9820
9820
  this.onDiagnostic?.("Skipped account-state persist due to storage lock contention", {
9821
9821
  error: String(error)
9822
9822
  });
9823
- for (const { resolve: resolve27 } of resolvers) {
9824
- resolve27();
9823
+ for (const { resolve: resolve28 } of resolvers) {
9824
+ resolve28();
9825
9825
  }
9826
9826
  return;
9827
9827
  }
@@ -10310,7 +10310,7 @@ function getHttpsProxy(url) {
10310
10310
  }
10311
10311
  }
10312
10312
  function waitForHead(socket, timeoutMs, onTimeout) {
10313
- return new Promise((resolve27, reject) => {
10313
+ return new Promise((resolve28, reject) => {
10314
10314
  let buffer = Buffer3.alloc(0);
10315
10315
  const timeout = setTimeout(() => {
10316
10316
  onTimeout();
@@ -10333,7 +10333,7 @@ function waitForHead(socket, timeoutMs, onTimeout) {
10333
10333
  return;
10334
10334
  const head = buffer.subarray(0, marker).toString("latin1");
10335
10335
  const leftover = buffer.subarray(marker + 4);
10336
- cleanup2(() => resolve27({ head, leftover }));
10336
+ cleanup2(() => resolve28({ head, leftover }));
10337
10337
  };
10338
10338
  socket.on("data", onData);
10339
10339
  socket.once("error", onError);
@@ -10347,7 +10347,7 @@ async function connectViaProxy(proxyUrl, targetUrl, timeoutMs, signal, onDebug)
10347
10347
  port: Number(proxyUrl.port || DEFAULT_PROXY_PORT),
10348
10348
  signal: signal ?? void 0
10349
10349
  });
10350
- await new Promise((resolve27, reject) => {
10350
+ await new Promise((resolve28, reject) => {
10351
10351
  const timeout = setTimeout(() => {
10352
10352
  onDebug?.(`agy transport proxy connect timeout after ${timeoutMs}ms`);
10353
10353
  proxySocket.destroy();
@@ -10356,7 +10356,7 @@ async function connectViaProxy(proxyUrl, targetUrl, timeoutMs, signal, onDebug)
10356
10356
  const cleanup2 = () => clearTimeout(timeout);
10357
10357
  proxySocket.once("connect", () => {
10358
10358
  cleanup2();
10359
- resolve27();
10359
+ resolve28();
10360
10360
  });
10361
10361
  proxySocket.once("error", (error) => {
10362
10362
  cleanup2();
@@ -10381,7 +10381,7 @@ Host: ${targetHost}:${targetPort}\r
10381
10381
  if (leftover.length > 0) {
10382
10382
  proxySocket.unshift(leftover);
10383
10383
  }
10384
- return await new Promise((resolve27, reject) => {
10384
+ return await new Promise((resolve28, reject) => {
10385
10385
  const tlsOptions = {
10386
10386
  socket: proxySocket,
10387
10387
  servername: targetHost,
@@ -10396,7 +10396,7 @@ Host: ${targetHost}:${targetPort}\r
10396
10396
  const cleanup2 = () => clearTimeout(timeout);
10397
10397
  tlsSocket.once("secureConnect", () => {
10398
10398
  cleanup2();
10399
- resolve27(tlsSocket);
10399
+ resolve28(tlsSocket);
10400
10400
  });
10401
10401
  tlsSocket.once("error", (error) => {
10402
10402
  cleanup2();
@@ -10405,7 +10405,7 @@ Host: ${targetHost}:${targetPort}\r
10405
10405
  });
10406
10406
  }
10407
10407
  async function connectDirect(targetUrl, timeoutMs, signal, onDebug) {
10408
- return await new Promise((resolve27, reject) => {
10408
+ return await new Promise((resolve28, reject) => {
10409
10409
  const tlsOptions = {
10410
10410
  host: targetUrl.hostname,
10411
10411
  port: Number(targetUrl.port || DEFAULT_HTTPS_PORT),
@@ -10421,7 +10421,7 @@ async function connectDirect(targetUrl, timeoutMs, signal, onDebug) {
10421
10421
  const cleanup2 = () => clearTimeout(timeout);
10422
10422
  socket.once("secureConnect", () => {
10423
10423
  cleanup2();
10424
- resolve27(socket);
10424
+ resolve28(socket);
10425
10425
  });
10426
10426
  socket.once("error", (error) => {
10427
10427
  cleanup2();
@@ -11434,7 +11434,7 @@ function displayOrder(left, right) {
11434
11434
  return left.label < right.label ? -1 : left.label > right.label ? 1 : 0;
11435
11435
  }
11436
11436
  function quotaWindowParts(quota, options) {
11437
- const { windows: windows2, age } = scopedWindowParts(quota, options);
11437
+ const { windows: windows2, age } = scopedWindowParts(quota, options, true);
11438
11438
  const parts = windows2.map(({ part }) => part);
11439
11439
  return age === void 0 ? { windows: parts } : { windows: parts, age };
11440
11440
  }
@@ -11445,25 +11445,36 @@ function withShortNames(windows2) {
11445
11445
  }
11446
11446
  return windows2;
11447
11447
  }
11448
- function scopedWindowParts(quota, options) {
11448
+ function hasWindowReading(limit) {
11449
+ return Number.isFinite(limit.remainingPercent) && Number.isFinite(limit.checkedAt);
11450
+ }
11451
+ function scopedWindowParts(quota, options, includeUnknown = false) {
11449
11452
  if (!quota)
11450
11453
  return { windows: [] };
11451
11454
  const { now } = options;
11452
- const readings = quota.limits.filter((limit) => limit.kind === "reading" && limit.remainingPercent !== void 0).sort(displayOrder);
11455
+ const readings = quota.limits.filter((limit) => limit.kind === "reading" && (includeUnknown || hasWindowReading(limit))).sort(displayOrder);
11453
11456
  const windows2 = readings.map((limit) => {
11454
- const remainingPercent = clampPercent(limit.remainingPercent ?? 0);
11457
+ const part = hasWindowReading(limit) ? {
11458
+ kind: "window",
11459
+ reading: "known",
11460
+ name: quotaWindowName(limit),
11461
+ short: "",
11462
+ figure: percentLeft(limit.remainingPercent),
11463
+ remainingPercent: clampPercent(limit.remainingPercent),
11464
+ checkedAt: limit.checkedAt,
11465
+ ...resetDetails(limit.resetsAt, limit.checkedAt, now)
11466
+ } : {
11467
+ kind: "window",
11468
+ reading: "unknown",
11469
+ name: quotaWindowName(limit),
11470
+ short: "",
11471
+ figure: "no reading",
11472
+ resetSinceReading: false
11473
+ };
11455
11474
  return {
11456
11475
  scope: limit.scope,
11457
11476
  ...limit.windowMinutes === void 0 ? {} : { windowMinutes: limit.windowMinutes },
11458
- part: {
11459
- kind: "window",
11460
- name: quotaWindowName(limit),
11461
- short: "",
11462
- figure: percentLeft(limit.remainingPercent ?? 0),
11463
- remainingPercent,
11464
- checkedAt: limit.checkedAt,
11465
- ...resetDetails(limit.resetsAt, limit.checkedAt, now)
11466
- }
11477
+ part
11467
11478
  };
11468
11479
  });
11469
11480
  const budget = quota.budget;
@@ -11475,6 +11486,7 @@ function scopedWindowParts(quota, options) {
11475
11486
  spent: budget.reached,
11476
11487
  part: {
11477
11488
  kind: "budget",
11489
+ reading: "known",
11478
11490
  name: "credits",
11479
11491
  short: "",
11480
11492
  figure,
@@ -11485,8 +11497,9 @@ function scopedWindowParts(quota, options) {
11485
11497
  });
11486
11498
  }
11487
11499
  withShortNames(windows2);
11488
- if (windows2.length > 0) {
11489
- const age = now - Math.min(...windows2.map(({ part }) => part.checkedAt));
11500
+ const readingTimes = windows2.flatMap(({ part }) => part.reading === "known" && part.checkedAt !== void 0 ? [part.checkedAt] : []);
11501
+ if (readingTimes.length > 0) {
11502
+ const age = now - Math.min(...readingTimes);
11490
11503
  if (age > (options.staleAfterMs ?? QUOTA_STALE_AFTER_MS)) {
11491
11504
  return { windows: windows2, age: `checked ${shortSpan(age)} ago` };
11492
11505
  }
@@ -11585,13 +11598,13 @@ function narrowTextParts(quota, options) {
11585
11598
  function quotaTextParts(quota, options) {
11586
11599
  if (options.form === "narrow")
11587
11600
  return narrowTextParts(quota, options);
11588
- const parts = quotaWindowParts(quota, options);
11601
+ const { windows: windows2, age } = scopedWindowParts(quota, options);
11589
11602
  const full = (options.form ?? "full") === "full";
11590
- const text2 = parts.windows.map((part) => {
11603
+ const text2 = windows2.map(({ part }) => {
11591
11604
  const reset = full && part.resetIn ? `, resets ${part.resetIn}` : "";
11592
11605
  return `${part.kind === "budget" ? "" : `${part.name} `}${part.figure}${reset}`;
11593
11606
  });
11594
- return parts.age === void 0 ? text2 : [...text2, parts.age];
11607
+ return age === void 0 ? text2 : [...text2, age];
11595
11608
  }
11596
11609
  function formatQuota(quota, options) {
11597
11610
  const parts = quotaTextParts(quota, options);
@@ -12494,8 +12507,8 @@ async function acquireRefreshFileLockWithClock(options) {
12494
12507
  let releaseConfirmed = false;
12495
12508
  let loss;
12496
12509
  let resolveLoss;
12497
- const lostPromise = new Promise((resolve27) => {
12498
- resolveLoss = resolve27;
12510
+ const lostPromise = new Promise((resolve28) => {
12511
+ resolveLoss = resolve28;
12499
12512
  });
12500
12513
  function notifyTimerStep(event) {
12501
12514
  try {
@@ -12656,7 +12669,7 @@ async function acquireRefreshFileLockWithClock(options) {
12656
12669
  }
12657
12670
  }
12658
12671
  async function backoff() {
12659
- await new Promise((resolve27) => setTimeout(resolve27, Math.floor(Math.random() * 4)));
12672
+ await new Promise((resolve28) => setTimeout(resolve28, Math.floor(Math.random() * 4)));
12660
12673
  }
12661
12674
  async function readLockState(notifyReady = true) {
12662
12675
  if (notifyReady && options.onStep)
@@ -13146,7 +13159,7 @@ async function acquireRefreshFileLockWithClock(options) {
13146
13159
  const remainingMs = deadline - performance.now();
13147
13160
  if (remainingMs <= 0)
13148
13161
  break;
13149
- await new Promise((resolve27) => setTimeout(resolve27, Math.min(delayMs, remainingMs)));
13162
+ await new Promise((resolve28) => setTimeout(resolve28, Math.min(delayMs, remainingMs)));
13150
13163
  delayMs = Math.min(delayMs * 2, 50);
13151
13164
  }
13152
13165
  if (windowsPrivateFiles)
@@ -13169,21 +13182,37 @@ var init_refresh_file_lock = __esm({
13169
13182
  });
13170
13183
 
13171
13184
  // ../core/dist/common-auth-embedded/fs/with-lock.js
13185
+ import { join as join6, resolve as resolve3 } from "node:path";
13172
13186
  function lockPathFor(target, name) {
13173
13187
  return `${target}.${name}.lock`;
13174
13188
  }
13189
+ function isChangingLockRead(error, target, name) {
13190
+ if (!windowsPrivateFiles || !(error instanceof PrivateFileError) || error.reason !== "io-error" || error.win32Code !== 32 && error.win32Code !== 303 || error.stage !== "read" && error.stage !== "verify")
13191
+ return false;
13192
+ const path5 = resolve3(lockPathFor(target, name));
13193
+ return error.path === path5 || error.path === join6(path5, "owner.json");
13194
+ }
13175
13195
  async function withLock(target, options, fn) {
13176
13196
  const started = performance.now();
13177
13197
  for (; ; ) {
13178
13198
  options.signal?.throwIfAborted();
13179
- const lock = await acquireRefreshFileLock({
13180
- path: target,
13181
- name: options.name,
13182
- ttlMs: options.ttlMs,
13183
- renew: options.renew ?? false,
13184
- ...options.onStep ? { onStep: options.onStep } : {},
13185
- ...options.onRenewalTimer ? { onRenewalTimer: options.onRenewalTimer } : {}
13186
- });
13199
+ let lock;
13200
+ let changingReadError;
13201
+ try {
13202
+ lock = await acquireRefreshFileLock({
13203
+ path: target,
13204
+ name: options.name,
13205
+ ttlMs: options.ttlMs,
13206
+ renew: options.renew ?? false,
13207
+ ...options.onStep ? { onStep: options.onStep } : {},
13208
+ ...options.onRenewalTimer ? { onRenewalTimer: options.onRenewalTimer } : {}
13209
+ });
13210
+ } catch (error) {
13211
+ if (!isChangingLockRead(error, target, options.name))
13212
+ throw error;
13213
+ lock = null;
13214
+ changingReadError = error;
13215
+ }
13187
13216
  if (lock) {
13188
13217
  try {
13189
13218
  options.signal?.throwIfAborted();
@@ -13194,19 +13223,22 @@ async function withLock(target, options, fn) {
13194
13223
  }
13195
13224
  const remaining = options.timeoutMs - (performance.now() - started);
13196
13225
  if (remaining <= 0) {
13226
+ if (changingReadError)
13227
+ throw changingReadError;
13197
13228
  throw new LockContentionError({
13198
13229
  target,
13199
13230
  name: options.name,
13200
13231
  timeoutMs: options.timeoutMs
13201
13232
  });
13202
13233
  }
13203
- await new Promise((resolve27) => setTimeout(resolve27, Math.min(25, Math.ceil(remaining))));
13234
+ await new Promise((resolve28) => setTimeout(resolve28, Math.min(25, Math.ceil(remaining))));
13204
13235
  }
13205
13236
  }
13206
13237
  var LockContentionError, LockOwnershipError;
13207
13238
  var init_with_lock = __esm({
13208
13239
  "../core/dist/common-auth-embedded/fs/with-lock.js"() {
13209
13240
  "use strict";
13241
+ init_private_files();
13210
13242
  init_refresh_file_lock();
13211
13243
  LockContentionError = class extends Error {
13212
13244
  details;
@@ -13319,7 +13351,7 @@ async function acquirePoolLock(spec, defaults, env3) {
13319
13351
  });
13320
13352
  }
13321
13353
  const jitter = Math.floor(Math.random() * (options.retryMs + 1));
13322
- await new Promise((resolve27) => setTimeout(resolve27, Math.min(options.retryMs + jitter, remaining)));
13354
+ await new Promise((resolve28) => setTimeout(resolve28, Math.min(options.retryMs + jitter, remaining)));
13323
13355
  }
13324
13356
  }
13325
13357
  function definedOnly(spec) {
@@ -16163,7 +16195,7 @@ var init_redact = __esm({
16163
16195
  // ../core/dist/common-auth-embedded/logger/engine.js
16164
16196
  import { appendFileSync, chmodSync, existsSync, renameSync, statSync } from "node:fs";
16165
16197
  import { open as open5 } from "node:fs/promises";
16166
- import { dirname as dirname8, resolve as resolve3 } from "node:path";
16198
+ import { dirname as dirname8, resolve as resolve4 } from "node:path";
16167
16199
  function chmodPrivate(path5) {
16168
16200
  try {
16169
16201
  chmodSync(path5, 384);
@@ -16214,7 +16246,7 @@ async function openWindowsFile(sink, file) {
16214
16246
  return sink.handle;
16215
16247
  }
16216
16248
  async function flushWindowsFile(sink, file, text2) {
16217
- file = resolve3(file);
16249
+ file = resolve4(file);
16218
16250
  try {
16219
16251
  if (sink.file !== file)
16220
16252
  await closeWindowsFile(sink);
@@ -16590,11 +16622,11 @@ var init_quota_writer = __esm({
16590
16622
  const left = deadline - performance.now();
16591
16623
  if (left <= 0)
16592
16624
  throw refusal2("pull", id, "lock-contention", `pool quota queue for ${id} is full (${POOL_QUOTA_QUEUE_LIMIT} readings) and the store locks stayed held`, true);
16593
- await new Promise((resolve27) => {
16625
+ await new Promise((resolve28) => {
16594
16626
  const done = () => {
16595
16627
  clearTimeout(timer);
16596
16628
  this.wake.delete(done);
16597
- resolve27();
16629
+ resolve28();
16598
16630
  };
16599
16631
  const timer = setTimeout(done, left);
16600
16632
  this.wake.add(done);
@@ -16987,7 +17019,7 @@ var init_refresh = __esm({
16987
17019
 
16988
17020
  // ../core/dist/common-auth-embedded/fs/file-read-cache.js
16989
17021
  import { lstat as lstat4 } from "node:fs/promises";
16990
- import { resolve as resolve4 } from "node:path";
17022
+ import { resolve as resolve5 } from "node:path";
16991
17023
  async function identity(path5) {
16992
17024
  try {
16993
17025
  const metadata = await lstat4(path5);
@@ -17008,7 +17040,7 @@ var init_file_read_cache = __esm({
17008
17040
  FileReadCache = class {
17009
17041
  #entries = /* @__PURE__ */ new Map();
17010
17042
  async read(paths, read, validateHit) {
17011
- const resolvedPaths = paths.map((path5) => resolve4(path5));
17043
+ const resolvedPaths = paths.map((path5) => resolve5(path5));
17012
17044
  const key = JSON.stringify(resolvedPaths);
17013
17045
  const probed = await Promise.all(resolvedPaths.map(identity));
17014
17046
  const identities = probed.every((entry) => entry !== void 0) ? probed : void 0;
@@ -19365,7 +19397,7 @@ async function select(terminal, items, options) {
19365
19397
  writeLine("");
19366
19398
  renderedLines = lines;
19367
19399
  };
19368
- return new Promise((resolve27) => {
19400
+ return new Promise((resolve28) => {
19369
19401
  const wasRaw = stdin.isRaw ?? false;
19370
19402
  const cleanup2 = () => {
19371
19403
  if (cleaned)
@@ -19385,7 +19417,7 @@ async function select(terminal, items, options) {
19385
19417
  };
19386
19418
  const finish = (value) => {
19387
19419
  cleanup2();
19388
- resolve27(value);
19420
+ resolve28(value);
19389
19421
  };
19390
19422
  const onSignal = () => finish(null);
19391
19423
  const onKey = (data) => {
@@ -19425,7 +19457,7 @@ async function select(terminal, items, options) {
19425
19457
  stdin.setRawMode(true);
19426
19458
  } catch {
19427
19459
  cleanup2();
19428
- resolve27(null);
19460
+ resolve28(null);
19429
19461
  return;
19430
19462
  }
19431
19463
  stdin.resume();
@@ -20267,7 +20299,7 @@ var init_watch = __esm({
20267
20299
  });
20268
20300
 
20269
20301
  // ../core/dist/common-auth-embedded/claustrum/insula.js
20270
- import { resolve as resolve5 } from "node:path";
20302
+ import { resolve as resolve6 } from "node:path";
20271
20303
  import { storeIdentity } from "@cortexkit/claustrum-client";
20272
20304
  import { SubcClient } from "@cortexkit/subc-client";
20273
20305
  function insulaUsageTransport(options) {
@@ -20395,8 +20427,8 @@ function refusalCode(error) {
20395
20427
  }
20396
20428
  function acquireInsulaQuotaSource(transport, tokenPath) {
20397
20429
  const key = JSON.stringify([
20398
- resolve5(transport.connectionFile),
20399
- resolve5(tokenPath)
20430
+ resolve6(transport.connectionFile),
20431
+ resolve6(tokenPath)
20400
20432
  ]);
20401
20433
  let shared4 = sources.get(key);
20402
20434
  if (!shared4) {
@@ -20710,7 +20742,7 @@ var init_any_signal = __esm({
20710
20742
  import { createHash as createHash6, randomBytes as randomBytes4, randomUUID as randomUUID12 } from "node:crypto";
20711
20743
  import { constants as fsConstants } from "node:fs";
20712
20744
  import { chmod as chmod2, mkdir as mkdir8, open as open6, readFile as readFile6, realpath as realpath3, rename as rename7, stat as stat4, unlink as unlink6 } from "node:fs/promises";
20713
- import { basename as basename3, dirname as dirname9, extname, isAbsolute as isAbsolute2, join as join6, resolve as resolve6 } from "node:path";
20745
+ import { basename as basename3, dirname as dirname9, extname, isAbsolute as isAbsolute2, join as join7, resolve as resolve7 } from "node:path";
20714
20746
  import { ClaustrumCredentialError as ClaustrumCredentialError2, ClaustrumClient as ClaustrumWireClient, writeEnrollmentTokenFile } from "@cortexkit/claustrum-client";
20715
20747
  function classifyEnrollmentError(error) {
20716
20748
  if (!(error instanceof ClaustrumCredentialError2))
@@ -20736,7 +20768,7 @@ function getClaustrumEnrollmentPaths(tokenPath) {
20736
20768
  const extension = extname(tokenPath) || ".json";
20737
20769
  const stem = basename3(tokenPath, extname(tokenPath));
20738
20770
  return {
20739
- statePath: join6(dirname9(tokenPath), `${stem}-state${extension}`),
20771
+ statePath: join7(dirname9(tokenPath), `${stem}-state${extension}`),
20740
20772
  tokenPath
20741
20773
  };
20742
20774
  }
@@ -20744,7 +20776,7 @@ function hostEnrollmentPaths(input2) {
20744
20776
  const override = input2.override?.trim();
20745
20777
  if (override && !isAbsolute2(override) && !input2.cwd)
20746
20778
  throw new ClaustrumConsumerError("invalid-state", "A relative Claustrum enrollment override needs a base directory");
20747
- const tokenPath = override ? isAbsolute2(override) ? override : resolve6(input2.cwd, override) : join6(input2.stateDir, `${input2.host}-enrollment.json`);
20779
+ const tokenPath = override ? isAbsolute2(override) ? override : resolve7(input2.cwd, override) : join7(input2.stateDir, `${input2.host}-enrollment.json`);
20748
20780
  return getClaustrumEnrollmentPaths(tokenPath);
20749
20781
  }
20750
20782
  function isRecord6(value) {
@@ -20977,7 +21009,7 @@ async function writeStateAtomic(path5, state, ancestorOptions = {}) {
20977
21009
  }
20978
21010
  if (windowsPrivateFiles)
20979
21011
  return writePrivateAtomic(path5, bytes);
20980
- const temporary = join6(parent, `.${basename3(path5)}.${process.pid}.${randomUUID12()}.tmp`);
21012
+ const temporary = join7(parent, `.${basename3(path5)}.${process.pid}.${randomUUID12()}.tmp`);
20981
21013
  let descriptor;
20982
21014
  let created = false;
20983
21015
  try {
@@ -21473,10 +21505,10 @@ async function drainShutdown(pending, onTimeout) {
21473
21505
  try {
21474
21506
  await Promise.race([
21475
21507
  drained,
21476
- new Promise((resolve27) => {
21508
+ new Promise((resolve28) => {
21477
21509
  timer = setTimeout(() => {
21478
21510
  expired = true;
21479
- resolve27();
21511
+ resolve28();
21480
21512
  }, 2e3);
21481
21513
  })
21482
21514
  ]);
@@ -22246,7 +22278,7 @@ var init_interlock = __esm({
22246
22278
  // ../core/dist/common-auth-embedded/claustrum/roster.js
22247
22279
  import { createHash as createHash7 } from "node:crypto";
22248
22280
  import { stat as stat5 } from "node:fs/promises";
22249
- import { resolve as resolve7 } from "node:path";
22281
+ import { resolve as resolve8 } from "node:path";
22250
22282
  function vaultRosterSeed(roster) {
22251
22283
  return {
22252
22284
  declined: roster.declined.map((entry) => ({ ...entry })),
@@ -22633,16 +22665,16 @@ function applyVaultQuota(current, input2) {
22633
22665
  };
22634
22666
  }
22635
22667
  function forgetPendingVaultDiscovery(path5) {
22636
- pendingDiscoveries.delete(resolve7(path5));
22668
+ pendingDiscoveries.delete(resolve8(path5));
22637
22669
  }
22638
22670
  function isVaultRosterLockRefusal(path5, error) {
22639
- const target = resolve7(path5);
22671
+ const target = resolve8(path5);
22640
22672
  if (error instanceof ClaustrumConsumerError)
22641
22673
  return error.kind === "roster-busy";
22642
22674
  if (error instanceof LockContentionError || error instanceof LockOwnershipError)
22643
- return resolve7(error.details.target) === target;
22675
+ return resolve8(error.details.target) === target;
22644
22676
  if (error instanceof PrivateFileError) {
22645
- const failed = resolve7(error.path);
22677
+ const failed = resolve8(error.path);
22646
22678
  return [WRITE_LOCK.name, DISCOVERY_LEASE.name].some((name) => {
22647
22679
  const lock = lockPathFor(target, name);
22648
22680
  return failed === lock || failed.startsWith(`${lock}.`);
@@ -22703,7 +22735,7 @@ async function refreshVaultRoster(options) {
22703
22735
  throw new ClaustrumConsumerError("roster-busy", "Claustrum account discovery is already in progress");
22704
22736
  return persisted;
22705
22737
  }
22706
- const key = resolve7(options.path);
22738
+ const key = resolve8(options.path);
22707
22739
  const listedOver = options.listedOver;
22708
22740
  let discovered;
22709
22741
  try {
@@ -22823,9 +22855,9 @@ var init_roster = __esm({
22823
22855
  });
22824
22856
 
22825
22857
  // ../core/dist/common-auth-embedded/claustrum/quota-writer.js
22826
- import { resolve as resolve8 } from "node:path";
22858
+ import { resolve as resolve9 } from "node:path";
22827
22859
  function writerFor(path5, clock2 = quotaCommitTimer) {
22828
- const key = resolve8(path5);
22860
+ const key = resolve9(path5);
22829
22861
  let writer = writers.get(key);
22830
22862
  if (!writer) {
22831
22863
  writer = {
@@ -22889,7 +22921,7 @@ function orderedFields(pending) {
22889
22921
  return [...pending.values()].flatMap((account) => [...account.values()]).sort((a, b) => a.order - b.order);
22890
22922
  }
22891
22923
  function pendingVaultQuota(path5, roster) {
22892
- const writer = writers.get(resolve8(path5));
22924
+ const writer = writers.get(resolve9(path5));
22893
22925
  if (writer) {
22894
22926
  for (const field of orderedFields(writer.pending)) {
22895
22927
  if (field.priorReading)
@@ -22900,7 +22932,7 @@ function pendingVaultQuota(path5, roster) {
22900
22932
  return roster;
22901
22933
  }
22902
22934
  function hasPendingVaultQuota(path5) {
22903
- return !!writers.get(resolve8(path5))?.pending.size;
22935
+ return !!writers.get(resolve9(path5))?.pending.size;
22904
22936
  }
22905
22937
  function schedule(writer, delay3) {
22906
22938
  if (writer.running || writer.timer || !writer.pending.size || writer.abort.signal.aborted)
@@ -22965,7 +22997,7 @@ function flush(writer) {
22965
22997
  return writer.running;
22966
22998
  }
22967
22999
  async function drainVaultQuota(path5, timeoutMs = 1e3) {
22968
- const key = resolve8(path5);
23000
+ const key = resolve9(path5);
22969
23001
  const writer = writers.get(key);
22970
23002
  if (!writer)
22971
23003
  return;
@@ -23110,7 +23142,7 @@ var init_consumer = __esm({
23110
23142
  this.#shutdown.signal,
23111
23143
  ...signal ? [signal] : []
23112
23144
  ]);
23113
- return new Promise((resolve27, reject) => {
23145
+ return new Promise((resolve28, reject) => {
23114
23146
  const cleanup2 = () => {
23115
23147
  combined.signal.removeEventListener("abort", abort);
23116
23148
  combined.dispose();
@@ -23125,7 +23157,7 @@ var init_consumer = __esm({
23125
23157
  if (combined.signal.aborted)
23126
23158
  reject(combined.signal.reason);
23127
23159
  else
23128
- resolve27(value);
23160
+ resolve28(value);
23129
23161
  }, (error) => {
23130
23162
  cleanup2();
23131
23163
  reject(error);
@@ -23839,7 +23871,7 @@ var init_consumer = __esm({
23839
23871
  import { createHash as createHash8 } from "node:crypto";
23840
23872
  import { channel as channel2 } from "node:diagnostics_channel";
23841
23873
  import { readdir, stat as stat6 } from "node:fs/promises";
23842
- import { dirname as dirname10, join as join7, resolve as resolve9 } from "node:path";
23874
+ import { dirname as dirname10, join as join8, resolve as resolve10 } from "node:path";
23843
23875
  function canonicalJson3(value, path5 = /* @__PURE__ */ new Set()) {
23844
23876
  if (value === null)
23845
23877
  return "null";
@@ -23900,12 +23932,12 @@ function unreachableConnect2() {
23900
23932
  return new ClaustrumUnreachableError();
23901
23933
  }
23902
23934
  function untilAborted(pending, signal) {
23903
- return new Promise((resolve27, reject) => {
23935
+ return new Promise((resolve28, reject) => {
23904
23936
  const abort = () => reject(signal.reason);
23905
23937
  signal.addEventListener("abort", abort, { once: true });
23906
23938
  pending.then((value) => {
23907
23939
  signal.removeEventListener("abort", abort);
23908
- resolve27(value);
23940
+ resolve28(value);
23909
23941
  }, (error) => {
23910
23942
  signal.removeEventListener("abort", abort);
23911
23943
  reject(error);
@@ -23975,13 +24007,13 @@ var init_hub = __esm({
23975
24007
  this.#options = options;
23976
24008
  this.#logger = options.logger ?? createLogger2("claustrum");
23977
24009
  this.#warnShutdown = shutdownWarning(this.#logger, this.#shutdown.signal);
23978
- this.#generationDirectory = join7(options.stateDir, "rosters", hostGeneration);
24010
+ this.#generationDirectory = join8(options.stateDir, "rosters", hostGeneration);
23979
24011
  this.#key = rosterFingerprint(options, providers);
23980
- const directory = join7(this.#generationDirectory, this.#key);
24012
+ const directory = join8(this.#generationDirectory, this.#key);
23981
24013
  for (const provider2 of providers)
23982
24014
  this.#members.set(provider2, {
23983
24015
  provider: provider2,
23984
- path: join7(directory, `${provider2}.json`),
24016
+ path: join8(directory, `${provider2}.json`),
23985
24017
  closed: false
23986
24018
  });
23987
24019
  }
@@ -24062,7 +24094,7 @@ var init_hub = __esm({
24062
24094
  };
24063
24095
  const { consumer, hooks } = createHubMember(port, consumerOptions);
24064
24096
  entry.hooks = hooks;
24065
- const path5 = resolve9(entry.path);
24097
+ const path5 = resolve10(entry.path);
24066
24098
  const subscribers = sharedRosters.get(path5) ?? /* @__PURE__ */ new Set();
24067
24099
  const install = (roster) => {
24068
24100
  if (entry.closed || this.#active !== true || !this.#current || !this.#live(this.#current) || !hooks.roster() || this.#collides(hooks, roster))
@@ -24093,7 +24125,7 @@ var init_hub = __esm({
24093
24125
  return;
24094
24126
  entry.seen = JSON.stringify(decodedVaultRoster(roster));
24095
24127
  entry.hooks?.install(roster);
24096
- for (const install of sharedRosters.get(resolve9(entry.path)) ?? []) {
24128
+ for (const install of sharedRosters.get(resolve10(entry.path)) ?? []) {
24097
24129
  if (!this.#live(generation))
24098
24130
  return;
24099
24131
  if (install !== entry.receiveRoster)
@@ -24549,7 +24581,7 @@ var init_hub = __esm({
24549
24581
  for (const directory of [
24550
24582
  dirname10(this.#generationDirectory),
24551
24583
  this.#generationDirectory,
24552
- join7(this.#generationDirectory, this.#key)
24584
+ join8(this.#generationDirectory, this.#key)
24553
24585
  ])
24554
24586
  await ensureClaustrumPrivateDirectory(directory, {}, "roster directory");
24555
24587
  }
@@ -24561,11 +24593,11 @@ var init_hub = __esm({
24561
24593
  */
24562
24594
  async #seed(entry) {
24563
24595
  const name = `${entry.provider}.json`;
24564
- const candidates = [join7(this.#generationDirectory, name)];
24596
+ const candidates = [join8(this.#generationDirectory, name)];
24565
24597
  try {
24566
24598
  for (const key of await readdir(this.#generationDirectory))
24567
24599
  if (key !== this.#key && FINGERPRINT.test(key))
24568
- candidates.push(join7(this.#generationDirectory, key, name));
24600
+ candidates.push(join8(this.#generationDirectory, key, name));
24569
24601
  } catch {
24570
24602
  }
24571
24603
  let newest;
@@ -25138,7 +25170,7 @@ var init_lock = __esm({
25138
25170
  import { createHash as createHash9 } from "node:crypto";
25139
25171
  import { constants as constants2 } from "node:fs";
25140
25172
  import { lstat as lstat5, mkdir as mkdir10, open as open7, unlink as unlink7 } from "node:fs/promises";
25141
- import { dirname as dirname11, resolve as resolve10 } from "node:path";
25173
+ import { dirname as dirname11, resolve as resolve11 } from "node:path";
25142
25174
  import { setTimeout as sleep2 } from "node:timers/promises";
25143
25175
  function rootSpans(text2) {
25144
25176
  let i = text2.indexOf("{") + 1;
@@ -25339,8 +25371,8 @@ function createPiSlot(options, onStep, hooks) {
25339
25371
  if (!provider2 || !options.authPath || !options.stashPath || !placeholderKey || placeholderKey.startsWith("!") || placeholderKey.includes("$") || !Number.isFinite(timeout) || timeout < 0) {
25340
25372
  throw new PiSlotError("invalid-options");
25341
25373
  }
25342
- const authPath = resolve10(options.authPath);
25343
- const stashPath = resolve10(options.stashPath);
25374
+ const authPath = resolve11(options.authPath);
25375
+ const stashPath = resolve11(options.stashPath);
25344
25376
  if (authPath === stashPath || stashPath === `${authPath}.lock`) {
25345
25377
  throw new PiSlotError("invalid-options");
25346
25378
  }
@@ -25773,15 +25805,15 @@ var init_model_types = __esm({
25773
25805
 
25774
25806
  // ../core/dist/pi-paths.js
25775
25807
  import { homedir } from "node:os";
25776
- import { dirname as dirname12, join as join8 } from "node:path";
25808
+ import { dirname as dirname12, join as join9 } from "node:path";
25777
25809
  function getPiConfigDir() {
25778
- return process.env.PI_AGENT_DIR?.trim() || join8(homedir(), ".pi", "agent");
25810
+ return process.env.PI_AGENT_DIR?.trim() || join9(homedir(), ".pi", "agent");
25779
25811
  }
25780
25812
  function getPiAntigravityAuthFile() {
25781
- return process.env.PI_ANTIGRAVITY_AUTH_FILE?.trim() || join8(getPiConfigDir(), "antigravity-accounts.json");
25813
+ return process.env.PI_ANTIGRAVITY_AUTH_FILE?.trim() || join9(getPiConfigDir(), "antigravity-accounts.json");
25782
25814
  }
25783
25815
  function getPiAntigravityVaultDir() {
25784
- return join8(dirname12(getPiAntigravityAuthFile()), "antigravity-auth-vault");
25816
+ return join9(dirname12(getPiAntigravityAuthFile()), "antigravity-auth-vault");
25785
25817
  }
25786
25818
  var init_pi_paths = __esm({
25787
25819
  "../core/dist/pi-paths.js"() {
@@ -25963,8 +25995,8 @@ function getDefaultTierId(allowedTiers) {
25963
25995
  return allowedTiers[0]?.id;
25964
25996
  }
25965
25997
  function wait(ms) {
25966
- return new Promise((resolve27) => {
25967
- setTimeout(resolve27, ms);
25998
+ return new Promise((resolve28) => {
25999
+ setTimeout(resolve28, ms);
25968
26000
  });
25969
26001
  }
25970
26002
  function extractManagedProjectId(payload) {
@@ -28286,12 +28318,12 @@ var init_vault_provider_state = __esm({
28286
28318
  function untilAborted2(pending, signal) {
28287
28319
  if (!signal)
28288
28320
  return pending;
28289
- return new Promise((resolve27, reject) => {
28321
+ return new Promise((resolve28, reject) => {
28290
28322
  const abort = () => reject(signal.reason);
28291
28323
  signal.addEventListener("abort", abort, { once: true });
28292
28324
  if (signal.aborted)
28293
28325
  abort();
28294
- pending.then(resolve27, reject).finally(() => signal.removeEventListener("abort", abort));
28326
+ pending.then(resolve28, reject).finally(() => signal.removeEventListener("abort", abort));
28295
28327
  });
28296
28328
  }
28297
28329
  async function resolveClaustrumConnectionPath(explicit) {
@@ -28765,7 +28797,7 @@ var init_capture_sink2 = __esm({
28765
28797
  import { randomUUID as randomUUID13 } from "node:crypto";
28766
28798
  import { lstat as lstat6, readFile as readFile8, rename as rename8, unlink as unlink8 } from "node:fs/promises";
28767
28799
  import { tmpdir as tmpdir2 } from "node:os";
28768
- import { dirname as dirname13, join as join9, resolve as resolve11 } from "node:path";
28800
+ import { dirname as dirname13, join as join10, resolve as resolve12 } from "node:path";
28769
28801
  function ioCode2(detail) {
28770
28802
  if (detail?.reason === "io-error") {
28771
28803
  if (detail.win32Code === 2 || detail.win32Code === 3)
@@ -28786,7 +28818,7 @@ function isUnavailable2(api, error) {
28786
28818
  }
28787
28819
  async function assertNativeAddonLoads2(api) {
28788
28820
  try {
28789
- await api.verifyPrivatePath(join9(tmpdir2(), `.common-auth-private-files-probe-${randomUUID13()}`), "file");
28821
+ await api.verifyPrivatePath(join10(tmpdir2(), `.common-auth-private-files-probe-${randomUUID13()}`), "file");
28790
28822
  } catch (error) {
28791
28823
  if (isUnavailable2(api, error))
28792
28824
  throw privateFilesUnavailable2(error);
@@ -28812,7 +28844,7 @@ async function privateOperation2(path5, stage, operation) {
28812
28844
  }
28813
28845
  }
28814
28846
  async function verifySafeDirectory2(path5, options) {
28815
- path5 = resolve11(path5);
28847
+ path5 = resolve12(path5);
28816
28848
  options ??= safeParentOptionsForTest2;
28817
28849
  await privateOperation2(path5, "safe-parent", async () => {
28818
28850
  const result = await (await loadBackend2()).verifySafeParent(path5, options);
@@ -28827,7 +28859,7 @@ async function verifySafeDirectory2(path5, options) {
28827
28859
  });
28828
28860
  }
28829
28861
  async function verifyPrivate2(path5, kind, migrate = false) {
28830
- path5 = resolve11(path5);
28862
+ path5 = resolve12(path5);
28831
28863
  if (kind === "directory")
28832
28864
  return verifySafeDirectory2(path5);
28833
28865
  await privateOperation2(path5, "verify", async () => {
@@ -28862,7 +28894,7 @@ async function verifyPrivate2(path5, kind, migrate = false) {
28862
28894
  });
28863
28895
  }
28864
28896
  async function ensurePrivateDirectory2(path5, _migrate = false, options) {
28865
- path5 = resolve11(path5);
28897
+ path5 = resolve12(path5);
28866
28898
  await privateOperation2(path5, "directory", async () => {
28867
28899
  const api = await loadBackend2();
28868
28900
  try {
@@ -28893,7 +28925,7 @@ async function readPrivateText2(path5, migrate = false) {
28893
28925
  async function readPrivateBuffer2(path5, migrate = false) {
28894
28926
  if (!windowsPrivateFiles2)
28895
28927
  return readFile8(path5);
28896
- path5 = resolve11(path5);
28928
+ path5 = resolve12(path5);
28897
28929
  if (migrate) {
28898
28930
  await verifySafeDirectory2(dirname13(path5));
28899
28931
  await verifyPrivate2(path5, "file", true);
@@ -28901,20 +28933,20 @@ async function readPrivateBuffer2(path5, migrate = false) {
28901
28933
  return privateOperation2(path5, "read", async () => (await loadBackend2()).readOwnerOnly(path5));
28902
28934
  }
28903
28935
  async function createPrivateBytes2(path5, bytes) {
28904
- await verifySafeDirectory2(dirname13(resolve11(path5)));
28936
+ await verifySafeDirectory2(dirname13(resolve12(path5)));
28905
28937
  await privateOperation2(path5, "create", async () => {
28906
- await (await loadBackend2()).createPrivateFile(resolve11(path5), bytes);
28938
+ await (await loadBackend2()).createPrivateFile(resolve12(path5), bytes);
28907
28939
  });
28908
28940
  }
28909
28941
  async function createPrivateDirectoryExclusive2(path5) {
28910
- await verifySafeDirectory2(dirname13(resolve11(path5)));
28942
+ await verifySafeDirectory2(dirname13(resolve12(path5)));
28911
28943
  await privateOperation2(path5, "directory-create", async () => {
28912
- await (await loadBackend2()).createOwnerOnly(resolve11(path5), { kind: "dir" });
28944
+ await (await loadBackend2()).createOwnerOnly(resolve12(path5), { kind: "dir" });
28913
28945
  });
28914
28946
  }
28915
28947
  async function replaceWindowsFile2(from, to, options = {}) {
28916
- from = resolve11(from);
28917
- to = resolve11(to);
28948
+ from = resolve12(from);
28949
+ to = resolve12(to);
28918
28950
  const now = options.now ?? (() => performance.now());
28919
28951
  const start = now();
28920
28952
  const leaseDeadline = options.deadline ?? Infinity;
@@ -28957,7 +28989,7 @@ async function replaceWindowsFile2(from, to, options = {}) {
28957
28989
  throw error;
28958
28990
  }
28959
28991
  async function writePrivateAtomic2(path5, bytes, options = {}) {
28960
- path5 = resolve11(path5);
28992
+ path5 = resolve12(path5);
28961
28993
  await ensurePrivateDirectory2(dirname13(path5));
28962
28994
  try {
28963
28995
  await verifyPrivate2(path5, "file", true);
@@ -28965,7 +28997,7 @@ async function writePrivateAtomic2(path5, bytes, options = {}) {
28965
28997
  if (error.code !== "ENOENT")
28966
28998
  throw error;
28967
28999
  }
28968
- const stage = resolve11(options.stagePath ?? `${path5}.${randomUUID13()}.tmp`);
29000
+ const stage = resolve12(options.stagePath ?? `${path5}.${randomUUID13()}.tmp`);
28969
29001
  if (dirname13(stage) !== dirname13(path5))
28970
29002
  throw new PrivateFileError2(path5, "stage-directory", { code: "EXDEV" });
28971
29003
  let created = false;
@@ -29131,7 +29163,7 @@ var init_redact2 = __esm({
29131
29163
  // src/common-auth-embedded/logger/engine.js
29132
29164
  import { appendFileSync as appendFileSync2, chmodSync as chmodSync2, existsSync as existsSync2, renameSync as renameSync2, statSync as statSync3 } from "node:fs";
29133
29165
  import { open as open8 } from "node:fs/promises";
29134
- import { dirname as dirname14, resolve as resolve12 } from "node:path";
29166
+ import { dirname as dirname14, resolve as resolve13 } from "node:path";
29135
29167
  function chmodPrivate2(path5) {
29136
29168
  try {
29137
29169
  chmodSync2(path5, 384);
@@ -29182,7 +29214,7 @@ async function openWindowsFile2(sink, file) {
29182
29214
  return sink.handle;
29183
29215
  }
29184
29216
  async function flushWindowsFile2(sink, file, text2) {
29185
- file = resolve12(file);
29217
+ file = resolve13(file);
29186
29218
  try {
29187
29219
  if (sink.file !== file)
29188
29220
  await closeWindowsFile2(sink);
@@ -29467,6 +29499,10 @@ function createVaultRequestCredentials(source, onAdmitted) {
29467
29499
  const issued = /* @__PURE__ */ new WeakMap();
29468
29500
  return {
29469
29501
  domain: "vault",
29502
+ routingCandidate: (row) => ({
29503
+ accountId: row.route.accountIdentity,
29504
+ credentialId: row.route.credentialId
29505
+ }),
29470
29506
  ...source.retryAfter401 && {
29471
29507
  retryAfter401(served, current, site) {
29472
29508
  const original = issued.get(served);
@@ -29978,7 +30014,7 @@ var init_vault_insula_quota = __esm({
29978
30014
 
29979
30015
  // src/plugin/vault-custody.ts
29980
30016
  import { chmod as chmod3, mkdir as mkdir11, readFile as readFile9, stat as stat8 } from "node:fs/promises";
29981
- import { join as join10 } from "node:path";
30017
+ import { join as join11 } from "node:path";
29982
30018
  async function enrollmentFilesIdentity(paths) {
29983
30019
  const takenAt = performance.now();
29984
30020
  let coarse = process.platform === "win32";
@@ -30002,9 +30038,9 @@ function openCodeVaultPaths(vaultDir) {
30002
30038
  const dir = vaultDir;
30003
30039
  return {
30004
30040
  dir,
30005
- modeFile: join10(dir, "opencode-mode.json"),
30006
- rosterFile: join10(dir, "opencode-roster.json"),
30007
- stateFile: join10(dir, "opencode-state.json")
30041
+ modeFile: join11(dir, "opencode-mode.json"),
30042
+ rosterFile: join11(dir, "opencode-roster.json"),
30043
+ stateFile: join11(dir, "opencode-state.json")
30008
30044
  };
30009
30045
  }
30010
30046
  async function ensureVaultDir(dir) {
@@ -30241,11 +30277,11 @@ function createOpenCodeVaultCustody(options) {
30241
30277
  ].join("\n");
30242
30278
  const waitForApproval = async () => {
30243
30279
  while (!closed2) {
30244
- await new Promise((resolve27) => {
30280
+ await new Promise((resolve28) => {
30245
30281
  const done = () => {
30246
30282
  clearTimeout(timer);
30247
30283
  cancelWait = void 0;
30248
- resolve27();
30284
+ resolve28();
30249
30285
  };
30250
30286
  const timer = setTimeout(done, 2e3);
30251
30287
  timer.unref?.();
@@ -30632,20 +30668,20 @@ import { randomUUID as randomUUID14 } from "node:crypto";
30632
30668
  import { realpathSync, rmSync } from "node:fs";
30633
30669
  import { chmod as chmod4, mkdir as mkdir12, readFile as readFile10, rename as rename9, rm as rm5, writeFile as writeFile3 } from "node:fs/promises";
30634
30670
  import { homedir as homedir2 } from "node:os";
30635
- import { join as join11, resolve as resolve13 } from "node:path";
30671
+ import { join as join12, resolve as resolve14 } from "node:path";
30636
30672
  function processHeartbeatDir() {
30637
- const base = process.env.XDG_STATE_HOME || join11(homedir2(), ".local", "state");
30638
- return join11(base, "cortexkit", "antigravity-auth", "processes");
30673
+ const base = process.env.XDG_STATE_HOME || join12(homedir2(), ".local", "state");
30674
+ return join12(base, "cortexkit", "antigravity-auth", "processes");
30639
30675
  }
30640
30676
  function processHeartbeatPath(pid = process.pid, dir = processHeartbeatDir()) {
30641
- return join11(dir, `${pid}.json`);
30677
+ return join12(dir, `${pid}.json`);
30642
30678
  }
30643
30679
  function processConfigFolderKey() {
30644
30680
  const folder = getConfigDir();
30645
30681
  try {
30646
30682
  return realpathSync.native(folder);
30647
30683
  } catch {
30648
- return resolve13(folder);
30684
+ return resolve14(folder);
30649
30685
  }
30650
30686
  }
30651
30687
  function processHasOlderGeneration() {
@@ -30883,15 +30919,15 @@ var init_process_heartbeat = __esm({
30883
30919
  // src/version-fence.ts
30884
30920
  import { readdir as readdir2, readFile as readFile11 } from "node:fs/promises";
30885
30921
  import { homedir as homedir3 } from "node:os";
30886
- import { join as join12 } from "node:path";
30922
+ import { join as join13 } from "node:path";
30887
30923
  function defaultStateHome() {
30888
- return process.env.XDG_STATE_HOME || join12(homedir3(), ".local", "state");
30924
+ return process.env.XDG_STATE_HOME || join13(homedir3(), ".local", "state");
30889
30925
  }
30890
30926
  function processHeartbeatDir2(stateHome = defaultStateHome()) {
30891
- return join12(stateHome, "cortexkit", "antigravity-auth", "processes");
30927
+ return join13(stateHome, "cortexkit", "antigravity-auth", "processes");
30892
30928
  }
30893
30929
  function rpcStateRoot(stateHome = defaultStateHome()) {
30894
- return join12(stateHome, "cortexkit", "antigravity-auth", "rpc");
30930
+ return join13(stateHome, "cortexkit", "antigravity-auth", "rpc");
30895
30931
  }
30896
30932
  function isRpcProjectDir(name) {
30897
30933
  return /^[0-9a-f]{16}$/.test(name);
@@ -31006,7 +31042,7 @@ async function versionFenceOpen(options) {
31006
31042
  for (const name of heartbeats.ok ? heartbeats.names : []) {
31007
31043
  const pid = pidFrom(name, /^(\d+)\.json$/);
31008
31044
  if (pid === void 0 || pid === self) continue;
31009
- const path5 = join12(heartbeatDir, name);
31045
+ const path5 = join13(heartbeatDir, name);
31010
31046
  const heartbeat = await readProcessRecord(path5, pid);
31011
31047
  if (heartbeat.kind === "gone") continue;
31012
31048
  if (!alive(pid)) continue;
@@ -31030,7 +31066,7 @@ async function versionFenceOpen(options) {
31030
31066
  block({ pid: "unknown", version: "unknown", detail: projects.error });
31031
31067
  for (const project3 of projects.ok ? projects.names : []) {
31032
31068
  if (!isRpcProjectDir(project3)) continue;
31033
- const dir = join12(rpcRoot, project3);
31069
+ const dir = join13(rpcRoot, project3);
31034
31070
  const ports = await list2(dir);
31035
31071
  if (!ports.ok) {
31036
31072
  if (ports.code === "ENOTDIR") continue;
@@ -31040,7 +31076,7 @@ async function versionFenceOpen(options) {
31040
31076
  for (const name of ports.names) {
31041
31077
  const pid = pidFrom(name, /^port-(\d+)\.json$/);
31042
31078
  if (pid === void 0 || pid === self || !alive(pid)) continue;
31043
- const path5 = join12(dir, name);
31079
+ const path5 = join13(dir, name);
31044
31080
  const port = await readProcessRecord(path5, pid);
31045
31081
  if (port.kind === "gone") continue;
31046
31082
  const version = port.kind === "ok" ? port.version : "unknown";
@@ -31091,7 +31127,7 @@ import {
31091
31127
  stat as stat9,
31092
31128
  unlink as unlink9
31093
31129
  } from "node:fs/promises";
31094
- import { basename as basename4, dirname as dirname15, join as join13, resolve as resolve14 } from "node:path";
31130
+ import { basename as basename4, dirname as dirname15, join as join14, resolve as resolve15 } from "node:path";
31095
31131
  function refusalMessage(stateDir, errorClass2) {
31096
31132
  if (errorClass2 === "ERR_PRIVATE_FILES_SECURITY")
31097
31133
  return `antigravity-auth cannot start: ${stateDir} is not a folder only your user can access, or it is a link, so the plugin will not use it (${errorClass2}). Replace it with a plain folder of your own, then restart OpenCode.`;
@@ -31178,7 +31214,7 @@ function prepareRuntimeLayout(options) {
31178
31214
  async function decide(location, options) {
31179
31215
  const log16 = options.log ?? createLogger4("runtime-layout");
31180
31216
  const stateDir = location.stateHomeDir;
31181
- const markerPath = join13(stateDir, RUNTIME_LAYOUT_MARKER_FILE);
31217
+ const markerPath = join14(stateDir, RUNTIME_LAYOUT_MARKER_FILE);
31182
31218
  const files = layoutFiles(location, options.accountFile);
31183
31219
  const fence = options.fence ?? defaultFence(options.version);
31184
31220
  const stateHome = async () => {
@@ -31190,7 +31226,7 @@ async function decide(location, options) {
31190
31226
  if (marker?.oldFilesRemoved) {
31191
31227
  await refuseReappearedFiles(location, files);
31192
31228
  const manifestLeft = await exists2(
31193
- join13(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE)
31229
+ join14(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE)
31194
31230
  ).catch(() => true);
31195
31231
  if (!manifestLeft) {
31196
31232
  await settleVault(location, options, "state-home", log16);
@@ -31356,7 +31392,7 @@ async function prepareAccountStore(options) {
31356
31392
  await ensureOwnerOnlyDir(location.stateHomeDir);
31357
31393
  const lock = await takeLock(
31358
31394
  RUNTIME_LAYOUT_LOCK_NAME,
31359
- join13(location.stateHomeDir, RUNTIME_LAYOUT_MARKER_FILE),
31395
+ join14(location.stateHomeDir, RUNTIME_LAYOUT_MARKER_FILE),
31360
31396
  options.layoutLockWaitMs ?? LAYOUT_LOCK_WAIT_MS,
31361
31397
  log16
31362
31398
  );
@@ -31470,7 +31506,7 @@ async function recordAnchor(location, options, anchor, log16) {
31470
31506
  }
31471
31507
  async function storeMovePathResolves(stateAnchor, location, log16) {
31472
31508
  if (folderResolvesToItself(
31473
- join13(location.stateHomeDir, "antigravity-accounts.json")
31509
+ join14(location.stateHomeDir, "antigravity-accounts.json")
31474
31510
  ))
31475
31511
  return true;
31476
31512
  logOnce(
@@ -31838,7 +31874,7 @@ async function removeLeftoverManifest(location, layoutLock, steps, log16) {
31838
31874
  }
31839
31875
  }
31840
31876
  async function removeManifestOwned(stateDir, layoutLock, steps) {
31841
- const path5 = join13(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE);
31877
+ const path5 = join14(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE);
31842
31878
  if (!await exists2(path5)) return;
31843
31879
  await beforeRemove(path5, layoutLock, steps);
31844
31880
  await removeManifest(stateDir);
@@ -31878,7 +31914,7 @@ async function takeDataLocks(files, log16) {
31878
31914
  locks.push(
31879
31915
  await takeLock(
31880
31916
  lock.name,
31881
- join13(files.vault.old, lock.file),
31917
+ join14(files.vault.old, lock.file),
31882
31918
  lock.waitMs,
31883
31919
  log16
31884
31920
  )
@@ -31905,8 +31941,8 @@ function sha256(bytes) {
31905
31941
  }
31906
31942
  function vaultStateFile(files) {
31907
31943
  return {
31908
- old: join13(files.vault.old, VAULT_ENROLLMENT_STATE_FILE),
31909
- next: join13(files.vault.next, VAULT_ENROLLMENT_STATE_FILE)
31944
+ old: join14(files.vault.old, VAULT_ENROLLMENT_STATE_FILE),
31945
+ next: join14(files.vault.next, VAULT_ENROLLMENT_STATE_FILE)
31910
31946
  };
31911
31947
  }
31912
31948
  async function keepableVaultState(files, present6) {
@@ -31946,10 +31982,10 @@ async function isVaultShapedKeptState(files) {
31946
31982
  async function removeMovedVaultStateLeftover(vaultDir, accountFile) {
31947
31983
  const location = runtimeLayoutLocation();
31948
31984
  const files = layoutFiles(location, accountFile);
31949
- if (resolve14(vaultDir) !== resolve14(files.vault.next)) return;
31985
+ if (resolve15(vaultDir) !== resolve15(files.vault.next)) return;
31950
31986
  const stateDir = location.stateHomeDir;
31951
31987
  const marker = await readMarker(
31952
- join13(stateDir, RUNTIME_LAYOUT_MARKER_FILE),
31988
+ join14(stateDir, RUNTIME_LAYOUT_MARKER_FILE),
31953
31989
  stateDir,
31954
31990
  files.vault.old
31955
31991
  );
@@ -31978,13 +32014,13 @@ async function vaultFiles(dir) {
31978
32014
  }
31979
32015
  async function presentOldFiles(files) {
31980
32016
  return (await vaultFiles(files.vault.old)).map((name) => ({
31981
- old: join13(files.vault.old, name),
31982
- next: join13(files.vault.next, name)
32017
+ old: join14(files.vault.old, name),
32018
+ next: join14(files.vault.next, name)
31983
32019
  }));
31984
32020
  }
31985
32021
  async function destinationFiles(files) {
31986
32022
  return (await vaultFiles(files.vault.next)).map(
31987
- (name) => join13(files.vault.next, name)
32023
+ (name) => join14(files.vault.next, name)
31988
32024
  );
31989
32025
  }
31990
32026
  async function physicalAliases(location, files) {
@@ -31993,7 +32029,7 @@ async function physicalAliases(location, files) {
31993
32029
  [files.vault.old, files.vault.next]
31994
32030
  ];
31995
32031
  for (const name of VAULT_FILE_NAMES)
31996
- pairs.push([join13(files.vault.old, name), join13(files.vault.next, name)]);
32032
+ pairs.push([join14(files.vault.old, name), join14(files.vault.next, name)]);
31997
32033
  const aliased = [];
31998
32034
  for (const [old, next] of pairs)
31999
32035
  if (await samePhysical(old, next)) aliased.push(old);
@@ -32105,11 +32141,11 @@ async function unlinkIfIdentical(file, stateDir, guard) {
32105
32141
  async function refuseReappearedFiles(location, files) {
32106
32142
  const keptState = vaultStateFile(files).old;
32107
32143
  for (const name of await vaultFiles(files.vault.old)) {
32108
- const old = join13(files.vault.old, name);
32144
+ const old = join14(files.vault.old, name);
32109
32145
  if (old === keptState && await isVaultShapedKeptState(files)) continue;
32110
32146
  throw credentialConflict(location.stateHomeDir, {
32111
32147
  old,
32112
- next: join13(files.vault.next, name)
32148
+ next: join14(files.vault.next, name)
32113
32149
  });
32114
32150
  }
32115
32151
  }
@@ -32151,13 +32187,13 @@ async function assertOwnFolder(location, marker, files) {
32151
32187
  const stateDir = location.stateHomeDir;
32152
32188
  if (marker?.oldDir !== void 0 && marker.oldDir !== location.key)
32153
32189
  throw foreignMarker(
32154
- join13(stateDir, RUNTIME_LAYOUT_MARKER_FILE),
32190
+ join14(stateDir, RUNTIME_LAYOUT_MARKER_FILE),
32155
32191
  location.key,
32156
32192
  files.vault.old
32157
32193
  );
32158
32194
  let text2;
32159
32195
  try {
32160
- text2 = await readFile12(join13(stateDir, RUNTIME_CONFIG_DIR_NOTE_FILE), "utf8");
32196
+ text2 = await readFile12(join14(stateDir, RUNTIME_CONFIG_DIR_NOTE_FILE), "utf8");
32161
32197
  } catch (error) {
32162
32198
  const code2 = error.code;
32163
32199
  if (code2 === "ENOENT" || code2 === "ENOTDIR") return;
@@ -32171,7 +32207,7 @@ async function assertOwnFolder(location, marker, files) {
32171
32207
  if (owner !== location.key) throw foreignFolder(stateDir, location.key);
32172
32208
  }
32173
32209
  async function writeOwnerNote(location) {
32174
- const path5 = join13(location.stateHomeDir, RUNTIME_CONFIG_DIR_NOTE_FILE);
32210
+ const path5 = join14(location.stateHomeDir, RUNTIME_CONFIG_DIR_NOTE_FILE);
32175
32211
  if (await exists2(path5)) return;
32176
32212
  await writePrivateText(
32177
32213
  path5,
@@ -32182,7 +32218,7 @@ async function writeOwnerNote(location) {
32182
32218
  async function readManifest(stateDir) {
32183
32219
  let text2;
32184
32220
  try {
32185
- text2 = await readFile12(join13(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE), "utf8");
32221
+ text2 = await readFile12(join14(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE), "utf8");
32186
32222
  } catch (error) {
32187
32223
  if (error.code === "ENOENT") return /* @__PURE__ */ new Set();
32188
32224
  throw error;
@@ -32199,13 +32235,13 @@ async function readManifest(stateDir) {
32199
32235
  }
32200
32236
  async function writeManifest(stateDir, paths) {
32201
32237
  await writePrivateText(
32202
- join13(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE),
32238
+ join14(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE),
32203
32239
  `${JSON.stringify({ version: 1, files: paths }, null, 2)}
32204
32240
  `
32205
32241
  );
32206
32242
  }
32207
32243
  async function removeManifest(stateDir) {
32208
- await unlink9(join13(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE)).catch(
32244
+ await unlink9(join14(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE)).catch(
32209
32245
  (error) => {
32210
32246
  if (error.code !== "ENOENT") throw error;
32211
32247
  }
@@ -32374,9 +32410,9 @@ import {
32374
32410
  writeFileSync
32375
32411
  } from "node:fs";
32376
32412
  import { homedir as homedir4 } from "node:os";
32377
- import { dirname as dirname16, join as join14, resolve as resolve15 } from "node:path";
32413
+ import { dirname as dirname16, join as join15, resolve as resolve16 } from "node:path";
32378
32414
  async function ensureGitignore(configDir) {
32379
- const gitignorePath = join14(configDir, ".gitignore");
32415
+ const gitignorePath = join15(configDir, ".gitignore");
32380
32416
  try {
32381
32417
  let content;
32382
32418
  let existingLines = [];
@@ -32422,8 +32458,8 @@ async function ensureGitignore(configDir) {
32422
32458
  }
32423
32459
  }
32424
32460
  function getLegacyWindowsConfigDir() {
32425
- return join14(
32426
- process.env.APPDATA || join14(homedir4(), "AppData", "Roaming"),
32461
+ return join15(
32462
+ process.env.APPDATA || join15(homedir4(), "AppData", "Roaming"),
32427
32463
  "opencode"
32428
32464
  );
32429
32465
  }
@@ -32431,15 +32467,15 @@ function getConfigDir() {
32431
32467
  if (process.env.OPENCODE_CONFIG_DIR) {
32432
32468
  return process.env.OPENCODE_CONFIG_DIR;
32433
32469
  }
32434
- const xdgConfig2 = process.env.XDG_CONFIG_HOME || join14(homedir4(), ".config");
32435
- return join14(xdgConfig2, "opencode");
32470
+ const xdgConfig2 = process.env.XDG_CONFIG_HOME || join15(homedir4(), ".config");
32471
+ return join15(xdgConfig2, "opencode");
32436
32472
  }
32437
32473
  function migrateLegacyWindowsConfig() {
32438
32474
  if (process.platform !== "win32") {
32439
32475
  return false;
32440
32476
  }
32441
- const newPath = join14(getConfigDir(), "antigravity-accounts.json");
32442
- const legacyPath = join14(
32477
+ const newPath = join15(getConfigDir(), "antigravity-accounts.json");
32478
+ const legacyPath = join15(
32443
32479
  getLegacyWindowsConfigDir(),
32444
32480
  "antigravity-accounts.json"
32445
32481
  );
@@ -32474,8 +32510,8 @@ function migrateLegacyWindowsConfig() {
32474
32510
  }
32475
32511
  }
32476
32512
  function resolveWindowsAccountAnchor(newPath, legacyPath) {
32477
- const standard = resolve15(newPath);
32478
- const legacy = resolve15(legacyPath);
32513
+ const standard = resolve16(newPath);
32514
+ const legacy = resolve16(legacyPath);
32479
32515
  if (standard.toLowerCase() === legacy.toLowerCase()) return newPath;
32480
32516
  const standardPointer = existsSync3(accountStorePointerPath(standard));
32481
32517
  const legacyPointer = existsSync3(accountStorePointerPath(legacy));
@@ -32489,15 +32525,15 @@ function resolveWindowsAccountAnchor(newPath, legacyPath) {
32489
32525
  return newPath;
32490
32526
  }
32491
32527
  function getStoragePathWithMigration() {
32492
- const newPath = join14(getConfigDir(), "antigravity-accounts.json");
32528
+ const newPath = join15(getConfigDir(), "antigravity-accounts.json");
32493
32529
  if (process.platform === "win32") {
32494
32530
  migrateLegacyWindowsConfig();
32495
- const legacyPath = join14(
32531
+ const legacyPath = join15(
32496
32532
  getLegacyWindowsConfigDir(),
32497
32533
  "antigravity-accounts.json"
32498
32534
  );
32499
32535
  const anchored = resolveWindowsAccountAnchor(newPath, legacyPath);
32500
- if (resolve15(anchored).toLowerCase() !== resolve15(newPath).toLowerCase() && !existsSync3(accountStorePointerPath(resolve15(anchored)))) {
32536
+ if (resolve16(anchored).toLowerCase() !== resolve16(newPath).toLowerCase() && !existsSync3(accountStorePointerPath(resolve16(anchored)))) {
32501
32537
  log5.info("Using legacy Windows config path (migration failed)", {
32502
32538
  legacyPath,
32503
32539
  newPath
@@ -32511,20 +32547,20 @@ function stateHomeStoragePath() {
32511
32547
  return stateHomeAccountFile(runtimeLayoutLocation());
32512
32548
  }
32513
32549
  function accountFileForVault(configDir = getConfigDir()) {
32514
- const configured = join14(configDir, "antigravity-accounts.json");
32550
+ const configured = join15(configDir, "antigravity-accounts.json");
32515
32551
  if (process.platform !== "win32") return configured;
32516
32552
  const legacyDir = getLegacyWindowsConfigDir();
32517
- if (resolve15(configDir).toLowerCase() === resolve15(legacyDir).toLowerCase())
32553
+ if (resolve16(configDir).toLowerCase() === resolve16(legacyDir).toLowerCase())
32518
32554
  return configured;
32519
- const configuredVault = join14(configDir, "antigravity-auth-vault");
32520
- const legacyVault = join14(legacyDir, "antigravity-auth-vault");
32555
+ const configuredVault = join15(configDir, "antigravity-auth-vault");
32556
+ const legacyVault = join15(legacyDir, "antigravity-auth-vault");
32521
32557
  const configuredPresent = existsSync3(configuredVault);
32522
32558
  const legacyPresent = existsSync3(legacyVault);
32523
32559
  if (configuredPresent && legacyPresent)
32524
32560
  throw new Error(
32525
32561
  `Two vault folders exist: ${configuredVault} and ${legacyVault}. Keep one vault enrollment before restarting OpenCode.`
32526
32562
  );
32527
- return legacyPresent ? join14(legacyDir, "antigravity-accounts.json") : configured;
32563
+ return legacyPresent ? join15(legacyDir, "antigravity-accounts.json") : configured;
32528
32564
  }
32529
32565
  async function prepareLocalAccountStore() {
32530
32566
  if (!decidedRuntimeLayout(runtimeLayoutLocation())) return;
@@ -32539,13 +32575,13 @@ function getStoragePath() {
32539
32575
  if (anchor === "config") return getStoragePathWithMigration();
32540
32576
  const location = runtimeLayoutLocation();
32541
32577
  if (decidedRuntimeLayout(location))
32542
- return join14(location.configDir, "antigravity-accounts.json");
32578
+ return join15(location.configDir, "antigravity-accounts.json");
32543
32579
  const configPath = getStoragePathWithMigration();
32544
32580
  return readForwardedAccountStore(configPath)?.legacyPath ?? configPath;
32545
32581
  }
32546
32582
  async function assertLegacyPoolInUse(legacyPath) {
32547
32583
  try {
32548
- await assertLegacyAccountStorageWritable(resolve15(legacyPath));
32584
+ await assertLegacyAccountStorageWritable(resolve16(legacyPath));
32549
32585
  } catch (error) {
32550
32586
  throw new LegacyAccountPoolRetiredError(legacyPath, { cause: error });
32551
32587
  }
@@ -32563,7 +32599,7 @@ function refusalMessage2(admission) {
32563
32599
  async function bindingOf(options) {
32564
32600
  if (options.legacyPath === void 0) await prepareLocalAccountStore();
32565
32601
  const now = options.now ?? (() => Date.now());
32566
- const legacyPath = resolve15(options.legacyPath ?? getStoragePath());
32602
+ const legacyPath = resolve16(options.legacyPath ?? getStoragePath());
32567
32603
  return {
32568
32604
  legacyPath,
32569
32605
  now,
@@ -32632,7 +32668,7 @@ async function openAccountStore(options) {
32632
32668
  async function initializeFreshAccountStoreFor(modules, options = {}) {
32633
32669
  if (options.legacyPath === void 0) await prepareLocalAccountStore();
32634
32670
  return initializeFreshAccountStore(modules, {
32635
- legacyPath: resolve15(options.legacyPath ?? getStoragePath()),
32671
+ legacyPath: resolve16(options.legacyPath ?? getStoragePath()),
32636
32672
  now: options.now ?? (() => Date.now())
32637
32673
  });
32638
32674
  }
@@ -32710,12 +32746,12 @@ var init_storage = __esm({
32710
32746
  import { createHash as createHash12 } from "node:crypto";
32711
32747
  import { existsSync as existsSync4, promises as fs2, readFileSync as readFileSync2, realpathSync as realpathSync2 } from "node:fs";
32712
32748
  import { homedir as homedir5 } from "node:os";
32713
- import { dirname as dirname17, join as join15, resolve as resolve16 } from "node:path";
32749
+ import { dirname as dirname17, join as join16, resolve as resolve17 } from "node:path";
32714
32750
  function configDirIdentity(path5) {
32715
32751
  try {
32716
32752
  return realpathSync2.native(path5);
32717
32753
  } catch {
32718
- return resolve16(path5);
32754
+ return resolve17(path5);
32719
32755
  }
32720
32756
  }
32721
32757
  function decisionKey(location) {
@@ -32723,18 +32759,18 @@ function decisionKey(location) {
32723
32759
  }
32724
32760
  function runtimeLayoutLocation(configDir = getConfigDir()) {
32725
32761
  const stateHome = defaultStateHome();
32726
- const homeConfig = join15(homedir5(), ".config", "opencode");
32762
+ const homeConfig = join16(homedir5(), ".config", "opencode");
32727
32763
  const cacheKey = `${configDir}\0${homeConfig}\0${stateHome}`;
32728
32764
  const cached = shared2.locations.get(cacheKey);
32729
32765
  if (cached && shared2.decisions.has(decisionKey(cached))) return cached;
32730
32766
  const key = configDirIdentity(configDir);
32731
32767
  if (cached && cached.key === key) return cached;
32732
32768
  const isDefaultConfigDir = key === configDirIdentity(homeConfig);
32733
- const root = join15(stateHome, "cortexkit", "antigravity-auth");
32769
+ const root = join16(stateHome, "cortexkit", "antigravity-auth");
32734
32770
  const location = {
32735
32771
  key,
32736
32772
  configDir,
32737
- stateHomeDir: isDefaultConfigDir ? join15(root, "opencode") : join15(
32773
+ stateHomeDir: isDefaultConfigDir ? join16(root, "opencode") : join16(
32738
32774
  root,
32739
32775
  `opencode-${createHash12("sha256").update(key).digest("hex").slice(0, 16)}`
32740
32776
  ),
@@ -32756,49 +32792,49 @@ function decidedAccountStoreAnchor(location) {
32756
32792
  return shared2.storeAnchors.get(`${location.stateHomeDir}\0${location.key}`);
32757
32793
  }
32758
32794
  function currentRuntimeLayout(location = runtimeLayoutLocation()) {
32759
- return decidedRuntimeLayout(location) ?? (existsSync4(join15(location.stateHomeDir, RUNTIME_LAYOUT_MARKER_FILE)) ? "state-home" : "legacy");
32795
+ return decidedRuntimeLayout(location) ?? (existsSync4(join16(location.stateHomeDir, RUNTIME_LAYOUT_MARKER_FILE)) ? "state-home" : "legacy");
32760
32796
  }
32761
32797
  function legacyWindowsConfigDir() {
32762
- return join15(
32763
- process.env.APPDATA || join15(homedir5(), "AppData", "Roaming"),
32798
+ return join16(
32799
+ process.env.APPDATA || join16(homedir5(), "AppData", "Roaming"),
32764
32800
  "opencode"
32765
32801
  );
32766
32802
  }
32767
32803
  function pluginStateDir() {
32768
- return join15(defaultStateHome(), "cortexkit", "antigravity-auth");
32804
+ return join16(defaultStateHome(), "cortexkit", "antigravity-auth");
32769
32805
  }
32770
32806
  function stateHomeSignatureCacheFile() {
32771
- return join15(pluginStateDir(), SIGNATURE_CACHE_FILE_NAME);
32807
+ return join16(pluginStateDir(), SIGNATURE_CACHE_FILE_NAME);
32772
32808
  }
32773
32809
  function legacySignatureCacheFile() {
32774
- const configHome = process.platform === "win32" ? legacyWindowsConfigDir() : join15(
32775
- process.env.XDG_CONFIG_HOME || join15(homedir5(), ".config"),
32810
+ const configHome = process.platform === "win32" ? legacyWindowsConfigDir() : join16(
32811
+ process.env.XDG_CONFIG_HOME || join16(homedir5(), ".config"),
32776
32812
  "opencode"
32777
32813
  );
32778
- return join15(configHome, SIGNATURE_CACHE_FILE_NAME);
32814
+ return join16(configHome, SIGNATURE_CACHE_FILE_NAME);
32779
32815
  }
32780
32816
  function stateHomeLogsDir() {
32781
- return join15(pluginStateDir(), "logs");
32817
+ return join16(pluginStateDir(), "logs");
32782
32818
  }
32783
32819
  function legacyAccountFile(configDir = getConfigDir()) {
32784
- const standard = join15(configDir, ACCOUNT_FILE_NAME);
32820
+ const standard = join16(configDir, ACCOUNT_FILE_NAME);
32785
32821
  if (process.platform !== "win32") return standard;
32786
32822
  return resolveWindowsAccountAnchor(
32787
32823
  standard,
32788
- join15(legacyWindowsConfigDir(), ACCOUNT_FILE_NAME)
32824
+ join16(legacyWindowsConfigDir(), ACCOUNT_FILE_NAME)
32789
32825
  );
32790
32826
  }
32791
32827
  function legacyVaultDir(accountFile) {
32792
- return join15(dirname17(accountFile), VAULT_DIR_NAME);
32828
+ return join16(dirname17(accountFile), VAULT_DIR_NAME);
32793
32829
  }
32794
32830
  function stateHomeVaultDir(location) {
32795
- return join15(location.stateHomeDir, VAULT_DIR_NAME);
32831
+ return join16(location.stateHomeDir, VAULT_DIR_NAME);
32796
32832
  }
32797
32833
  function accountStorePointerPath2(accountFile) {
32798
32834
  return `${accountFile}${ACCOUNT_STORE_POINTER_SUFFIX}`;
32799
32835
  }
32800
32836
  function stateHomeAccountFile(location) {
32801
- return join15(realPathOrSelf(location.stateHomeDir), ACCOUNT_FILE_NAME);
32837
+ return join16(realPathOrSelf(location.stateHomeDir), ACCOUNT_FILE_NAME);
32802
32838
  }
32803
32839
  function realPathOrSelf(path5) {
32804
32840
  try {
@@ -33042,7 +33078,7 @@ import {
33042
33078
  statSync as statSync4,
33043
33079
  unlinkSync as unlinkSync2
33044
33080
  } from "node:fs";
33045
- import { join as join16 } from "node:path";
33081
+ import { join as join17 } from "node:path";
33046
33082
  import { env } from "node:process";
33047
33083
  function getLogsDir(customLogDir) {
33048
33084
  const logsDir = customLogDir || stateHomeLogsDir();
@@ -33061,9 +33097,9 @@ function createLogFilePath(customLogDir) {
33061
33097
  const logsDir = getLogsDir(requestedLogDir(customLogDir));
33062
33098
  cleanupOldLogs(logsDir, 25);
33063
33099
  const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
33064
- let candidate = join16(logsDir, `antigravity-debug-${timestamp}.log`);
33100
+ let candidate = join17(logsDir, `antigravity-debug-${timestamp}.log`);
33065
33101
  for (let suffix = 2; liveLogFilePaths.has(candidate); suffix++) {
33066
- candidate = join16(logsDir, `antigravity-debug-${timestamp}-${suffix}.log`);
33102
+ candidate = join17(logsDir, `antigravity-debug-${timestamp}-${suffix}.log`);
33067
33103
  }
33068
33104
  return candidate;
33069
33105
  }
@@ -33071,7 +33107,7 @@ function cleanupOldLogs(logsDir, maxFiles) {
33071
33107
  try {
33072
33108
  const files = readdirSync(logsDir).filter(
33073
33109
  (file) => file.startsWith("antigravity-debug-") && file.endsWith(".log")
33074
- ).map((file) => join16(logsDir, file));
33110
+ ).map((file) => join17(logsDir, file));
33075
33111
  if (files.length <= maxFiles) {
33076
33112
  return;
33077
33113
  }
@@ -33168,13 +33204,13 @@ function closeDebugStream(state) {
33168
33204
  state.logWriter = () => {
33169
33205
  };
33170
33206
  if (state.logFilePath) liveLogFilePaths.delete(state.logFilePath);
33171
- return new Promise((resolve27) => {
33172
- current.once("close", () => resolve27());
33173
- current.once("error", () => resolve27());
33207
+ return new Promise((resolve28) => {
33208
+ current.once("close", () => resolve28());
33209
+ current.once("error", () => resolve28());
33174
33210
  try {
33175
33211
  current.end();
33176
33212
  } catch {
33177
- resolve27();
33213
+ resolve28();
33178
33214
  }
33179
33215
  });
33180
33216
  }
@@ -33439,13 +33475,13 @@ function closeDebugLog() {
33439
33475
  if (!state || !current) return Promise.resolve();
33440
33476
  state.logStream = null;
33441
33477
  if (state.logFilePath) liveLogFilePaths.delete(state.logFilePath);
33442
- return new Promise((resolve27) => {
33443
- current.once("close", () => resolve27());
33444
- current.once("error", () => resolve27());
33478
+ return new Promise((resolve28) => {
33479
+ current.once("close", () => resolve28());
33480
+ current.once("error", () => resolve28());
33445
33481
  try {
33446
33482
  current.end();
33447
33483
  } catch {
33448
- resolve27();
33484
+ resolve28();
33449
33485
  }
33450
33486
  });
33451
33487
  }
@@ -34912,7 +34948,7 @@ init_runtime_paths();
34912
34948
  init_logger4();
34913
34949
  import { existsSync as existsSync5, readFileSync as readFileSync3, realpathSync as realpathSync3 } from "node:fs";
34914
34950
  import { homedir as homedir6 } from "node:os";
34915
- import { basename as basename5, dirname as dirname18, join as join17, resolve as resolve17 } from "node:path";
34951
+ import { basename as basename5, dirname as dirname18, join as join18, resolve as resolve18 } from "node:path";
34916
34952
 
34917
34953
  // src/plugin/config/schema.ts
34918
34954
  import { z } from "zod";
@@ -35407,14 +35443,14 @@ function getConfigDir2() {
35407
35443
  if (process.env.OPENCODE_CONFIG_DIR) {
35408
35444
  return process.env.OPENCODE_CONFIG_DIR;
35409
35445
  }
35410
- const xdgConfig2 = process.env.XDG_CONFIG_HOME || join17(homedir6(), ".config");
35411
- return join17(xdgConfig2, "opencode");
35446
+ const xdgConfig2 = process.env.XDG_CONFIG_HOME || join18(homedir6(), ".config");
35447
+ return join18(xdgConfig2, "opencode");
35412
35448
  }
35413
35449
  function getUserConfigPath() {
35414
- return join17(getConfigDir2(), "antigravity.json");
35450
+ return join18(getConfigDir2(), "antigravity.json");
35415
35451
  }
35416
35452
  function getProjectConfigPath(directory) {
35417
- return join17(directory, ".opencode", "antigravity.json");
35453
+ return join18(directory, ".opencode", "antigravity.json");
35418
35454
  }
35419
35455
  function loadConfigFile(path5, log16) {
35420
35456
  try {
@@ -35486,12 +35522,12 @@ function createLocationConfig(directory, options) {
35486
35522
  };
35487
35523
  }
35488
35524
  function canonicalizeOwnedPath(path5) {
35489
- const absolute = resolve17(path5);
35525
+ const absolute = resolve18(path5);
35490
35526
  const missing = [];
35491
35527
  let current = absolute;
35492
35528
  for (; ; ) {
35493
35529
  try {
35494
- return join17(realpathSync3(current), ...missing.reverse());
35530
+ return join18(realpathSync3(current), ...missing.reverse());
35495
35531
  } catch {
35496
35532
  const parent = dirname18(current);
35497
35533
  if (parent === current) return absolute;
@@ -35865,14 +35901,14 @@ function createStoreAccountLimits(input2) {
35865
35901
 
35866
35902
  // src/plugin/ga-shared-vault-custody.ts
35867
35903
  init_dist();
35868
- import { resolve as resolve18 } from "node:path";
35904
+ import { resolve as resolve19 } from "node:path";
35869
35905
 
35870
35906
  // src/sidebar-state.ts
35871
35907
  init_atomic_write();
35872
35908
  init_file_lock();
35873
35909
  import { chmodSync as chmodSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync6 } from "node:fs";
35874
35910
  import { homedir as homedir7 } from "node:os";
35875
- import { dirname as dirname19, join as join18 } from "node:path";
35911
+ import { dirname as dirname19, join as join19 } from "node:path";
35876
35912
 
35877
35913
  // ../../node_modules/.bun/xdg-basedir@5.1.0/node_modules/xdg-basedir/index.js
35878
35914
  import os from "os";
@@ -35931,8 +35967,8 @@ async function emitMergeStep(step) {
35931
35967
  function getSidebarStateFile() {
35932
35968
  const override = process.env[SIDEBAR_STATE_ENV];
35933
35969
  if (override && override.trim().length > 0) return override;
35934
- const base = xdgState ?? join18(homedir7(), ".local", "state");
35935
- return join18(base, SIDEBAR_STATE_DIR, SIDEBAR_STATE_FILENAME);
35970
+ const base = xdgState ?? join19(homedir7(), ".local", "state");
35971
+ return join19(base, SIDEBAR_STATE_DIR, SIDEBAR_STATE_FILENAME);
35936
35972
  }
35937
35973
  function readSidebarState(path5 = getSidebarStateFile()) {
35938
35974
  let raw;
@@ -36281,7 +36317,7 @@ function drainSidebarWrites() {
36281
36317
  return sidebarWriteChain;
36282
36318
  }
36283
36319
  async function sleep3(ms) {
36284
- await new Promise((resolve27) => setTimeout(resolve27, ms));
36320
+ await new Promise((resolve28) => setTimeout(resolve28, ms));
36285
36321
  }
36286
36322
  async function acquireSidebarLockWithRetry(stateFile) {
36287
36323
  const start = Date.now();
@@ -36840,14 +36876,14 @@ var LocalQuotaGrantStaleError = class extends Error {
36840
36876
  name = "LocalQuotaGrantStaleError";
36841
36877
  };
36842
36878
  function untilQuotaAborted(pending, signal) {
36843
- return new Promise((resolve27, reject) => {
36879
+ return new Promise((resolve28, reject) => {
36844
36880
  const abort = () => reject(signal.reason);
36845
36881
  if (signal.aborted) abort();
36846
36882
  else signal.addEventListener("abort", abort, { once: true });
36847
36883
  void pending.then(
36848
36884
  (value) => {
36849
36885
  signal.removeEventListener("abort", abort);
36850
- resolve27(value);
36886
+ resolve28(value);
36851
36887
  },
36852
36888
  (error) => {
36853
36889
  signal.removeEventListener("abort", abort);
@@ -37742,7 +37778,7 @@ init_vault_request_credentials();
37742
37778
  init_vault_custody();
37743
37779
  var shared3 = /* @__PURE__ */ new Map();
37744
37780
  function acquireGaVaultCustody(options) {
37745
- const key = options.layoutRefusal === void 0 ? resolve18(options.vaultDir) : `unsettled\0${resolve18(options.vaultDir)}`;
37781
+ const key = options.layoutRefusal === void 0 ? resolve19(options.vaultDir) : `unsettled\0${resolve19(options.vaultDir)}`;
37746
37782
  let entry = shared3.get(key);
37747
37783
  if (!entry) {
37748
37784
  const leases = /* @__PURE__ */ new Set();
@@ -38067,7 +38103,7 @@ import {
38067
38103
  writeFileSync as writeFileSync2
38068
38104
  } from "node:fs";
38069
38105
  import { tmpdir as tmpdir3 } from "node:os";
38070
- import { dirname as dirname20, join as join19 } from "node:path";
38106
+ import { dirname as dirname20, join as join20 } from "node:path";
38071
38107
  function getSignatureCacheFilePath() {
38072
38108
  return stateHomeSignatureCacheFile();
38073
38109
  }
@@ -38351,7 +38387,7 @@ var SignatureCache = class {
38351
38387
  last_write: now
38352
38388
  }
38353
38389
  };
38354
- const tmpPath = join19(
38390
+ const tmpPath = join20(
38355
38391
  tmpdir3(),
38356
38392
  `antigravity-cache-${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`
38357
38393
  );
@@ -38708,9 +38744,9 @@ function clearSignatureCache(sessionId) {
38708
38744
  // src/plugin/image-saver.ts
38709
38745
  import { chmodSync as chmodSync4, existsSync as existsSync9, mkdirSync as mkdirSync5, writeFileSync as writeFileSync3 } from "node:fs";
38710
38746
  import { homedir as homedir8 } from "node:os";
38711
- import { join as join20 } from "node:path";
38747
+ import { join as join21 } from "node:path";
38712
38748
  function getImageOutputDir(outputDir) {
38713
- const resolved = outputDir ?? join20(homedir8(), ".opencode", "generated-images");
38749
+ const resolved = outputDir ?? join21(homedir8(), ".opencode", "generated-images");
38714
38750
  if (!existsSync9(resolved)) {
38715
38751
  mkdirSync5(resolved, { recursive: true, mode: 448 });
38716
38752
  }
@@ -38733,7 +38769,7 @@ function generateImageFilename(mimeType) {
38733
38769
  function saveImageToDisk(base64Data, mimeType, outputDir) {
38734
38770
  try {
38735
38771
  const resolvedOutputDir = getImageOutputDir(outputDir);
38736
- const filePath = join20(resolvedOutputDir, generateImageFilename(mimeType));
38772
+ const filePath = join21(resolvedOutputDir, generateImageFilename(mimeType));
38737
38773
  writeFileSync3(filePath, Buffer.from(base64Data, "base64"), { mode: 384 });
38738
38774
  chmodSync4(filePath, 384);
38739
38775
  return filePath;
@@ -39174,10 +39210,10 @@ init_logging_utils();
39174
39210
  import { createHash as createHash15 } from "node:crypto";
39175
39211
  import { appendFileSync as appendFileSync4, mkdirSync as mkdirSync6, writeFileSync as writeFileSync4 } from "node:fs";
39176
39212
  import { tmpdir as tmpdir4 } from "node:os";
39177
- import { join as join21 } from "node:path";
39213
+ import { join as join22 } from "node:path";
39178
39214
  var DUMP_STATUS_TITLE = "## Gemini Dump Status";
39179
39215
  var DUMP_DIR_ENV = "OPENCODE_ANTIGRAVITY_GEMINI_DUMP_DIR";
39180
- var DEFAULT_DUMP_DIR = join21(tmpdir4(), "opencode-antigravity-gemini-dumps");
39216
+ var DEFAULT_DUMP_DIR = join22(tmpdir4(), "opencode-antigravity-gemini-dumps");
39181
39217
  var DUMP_DIR_MODE = 448;
39182
39218
  var DUMP_FILE_MODE = 384;
39183
39219
  var nextDumpId = 0;
@@ -39331,7 +39367,7 @@ function writeGeminiDump(input2) {
39331
39367
  nextDumpId += 1;
39332
39368
  const id = `${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}-${String(nextDumpId).padStart(5, "0")}-${input2.streaming ? "stream" : "json"}`;
39333
39369
  const dumpDir = getGeminiDumpDirectory();
39334
- const prefix = join21(dumpDir, id);
39370
+ const prefix = join22(dumpDir, id);
39335
39371
  mkdirSync6(dumpDir, { recursive: true, mode: DUMP_DIR_MODE });
39336
39372
  const context = {
39337
39373
  id,
@@ -39422,21 +39458,21 @@ import {
39422
39458
  unlinkSync as unlinkSync4,
39423
39459
  writeFileSync as writeFileSync5
39424
39460
  } from "node:fs";
39425
- import { join as join23 } from "node:path";
39461
+ import { join as join24 } from "node:path";
39426
39462
 
39427
39463
  // src/plugin/recovery/constants.ts
39428
39464
  import { homedir as homedir9 } from "node:os";
39429
- import { join as join22 } from "node:path";
39465
+ import { join as join23 } from "node:path";
39430
39466
  function getXdgData() {
39431
39467
  const platform = process.platform;
39432
39468
  if (platform === "win32") {
39433
- return process.env.APPDATA || join22(homedir9(), "AppData", "Roaming");
39469
+ return process.env.APPDATA || join23(homedir9(), "AppData", "Roaming");
39434
39470
  }
39435
- return process.env.XDG_DATA_HOME || join22(homedir9(), ".local", "share");
39471
+ return process.env.XDG_DATA_HOME || join23(homedir9(), ".local", "share");
39436
39472
  }
39437
- var OPENCODE_STORAGE = join22(getXdgData(), "opencode", "storage");
39438
- var MESSAGE_STORAGE = join22(OPENCODE_STORAGE, "message");
39439
- var PART_STORAGE = join22(OPENCODE_STORAGE, "part");
39473
+ var OPENCODE_STORAGE = join23(getXdgData(), "opencode", "storage");
39474
+ var MESSAGE_STORAGE = join23(OPENCODE_STORAGE, "message");
39475
+ var PART_STORAGE = join23(OPENCODE_STORAGE, "part");
39440
39476
  var THINKING_TYPES = /* @__PURE__ */ new Set([
39441
39477
  "thinking",
39442
39478
  "redacted_thinking",
@@ -39446,13 +39482,13 @@ var THINKING_TYPES = /* @__PURE__ */ new Set([
39446
39482
  // src/plugin/recovery/storage.ts
39447
39483
  function getMessageDir(sessionID) {
39448
39484
  if (!existsSync10(MESSAGE_STORAGE)) return "";
39449
- const directPath = join23(MESSAGE_STORAGE, sessionID);
39485
+ const directPath = join24(MESSAGE_STORAGE, sessionID);
39450
39486
  if (existsSync10(directPath)) {
39451
39487
  return directPath;
39452
39488
  }
39453
39489
  try {
39454
39490
  for (const dir of readdirSync2(MESSAGE_STORAGE)) {
39455
- const sessionPath = join23(MESSAGE_STORAGE, dir, sessionID);
39491
+ const sessionPath = join24(MESSAGE_STORAGE, dir, sessionID);
39456
39492
  if (existsSync10(sessionPath)) {
39457
39493
  return sessionPath;
39458
39494
  }
@@ -39469,7 +39505,7 @@ function readMessages(sessionID) {
39469
39505
  for (const file of readdirSync2(messageDir)) {
39470
39506
  if (!file.endsWith(".json")) continue;
39471
39507
  try {
39472
- const content = readFileSync8(join23(messageDir, file), "utf-8");
39508
+ const content = readFileSync8(join24(messageDir, file), "utf-8");
39473
39509
  messages.push(JSON.parse(content));
39474
39510
  } catch {
39475
39511
  }
@@ -39485,14 +39521,14 @@ function readMessages(sessionID) {
39485
39521
  });
39486
39522
  }
39487
39523
  function readParts(messageID) {
39488
- const partDir = join23(PART_STORAGE, messageID);
39524
+ const partDir = join24(PART_STORAGE, messageID);
39489
39525
  if (!existsSync10(partDir)) return [];
39490
39526
  const parts = [];
39491
39527
  try {
39492
39528
  for (const file of readdirSync2(partDir)) {
39493
39529
  if (!file.endsWith(".json")) continue;
39494
39530
  try {
39495
- const content = readFileSync8(join23(partDir, file), "utf-8");
39531
+ const content = readFileSync8(join24(partDir, file), "utf-8");
39496
39532
  parts.push(JSON.parse(content));
39497
39533
  } catch {
39498
39534
  }
@@ -39534,7 +39570,7 @@ function findMessagesWithOrphanThinking(sessionID) {
39534
39570
  return result;
39535
39571
  }
39536
39572
  function prependThinkingPart(sessionID, messageID) {
39537
- const partDir = join23(PART_STORAGE, messageID);
39573
+ const partDir = join24(PART_STORAGE, messageID);
39538
39574
  try {
39539
39575
  if (!existsSync10(partDir)) {
39540
39576
  mkdirSync7(partDir, { recursive: true });
@@ -39549,7 +39585,7 @@ function prependThinkingPart(sessionID, messageID) {
39549
39585
  synthetic: true
39550
39586
  };
39551
39587
  writeFileSync5(
39552
- join23(partDir, `${partId}.json`),
39588
+ join24(partDir, `${partId}.json`),
39553
39589
  JSON.stringify(part, null, 2)
39554
39590
  );
39555
39591
  return true;
@@ -39558,14 +39594,14 @@ function prependThinkingPart(sessionID, messageID) {
39558
39594
  }
39559
39595
  }
39560
39596
  function stripThinkingParts(messageID) {
39561
- const partDir = join23(PART_STORAGE, messageID);
39597
+ const partDir = join24(PART_STORAGE, messageID);
39562
39598
  if (!existsSync10(partDir)) return false;
39563
39599
  let anyRemoved = false;
39564
39600
  try {
39565
39601
  for (const file of readdirSync2(partDir)) {
39566
39602
  if (!file.endsWith(".json")) continue;
39567
39603
  try {
39568
- const filePath = join23(partDir, file);
39604
+ const filePath = join24(partDir, file);
39569
39605
  const content = readFileSync8(filePath, "utf-8");
39570
39606
  const part = JSON.parse(content);
39571
39607
  if (THINKING_TYPES.has(part.type)) {
@@ -42372,6 +42408,7 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
42372
42408
  headers.delete("x-parent-session-id");
42373
42409
  headers.delete("x-opencode-session-id");
42374
42410
  headers.delete("x-opencode-parent-session-id");
42411
+ headers.delete("x-antigravity-internal-request-purpose");
42375
42412
  headers.delete("x-goog-user-project");
42376
42413
  headers.delete("X-Goog-Api-Client");
42377
42414
  headers.delete("Client-Metadata");
@@ -43374,12 +43411,12 @@ async function startOAuthListener({
43374
43411
  let resolveCallback;
43375
43412
  let rejectCallback;
43376
43413
  let timeoutHandle;
43377
- const callbackPromise = new Promise((resolve27, reject) => {
43414
+ const callbackPromise = new Promise((resolve28, reject) => {
43378
43415
  resolveCallback = (url) => {
43379
43416
  if (settled) return;
43380
43417
  settled = true;
43381
43418
  if (timeoutHandle) clearTimeout(timeoutHandle);
43382
- resolve27(url);
43419
+ resolve28(url);
43383
43420
  };
43384
43421
  rejectCallback = (error) => {
43385
43422
  if (settled) return;
@@ -43538,7 +43575,7 @@ async function startOAuthListener({
43538
43575
  });
43539
43576
  });
43540
43577
  const bindAddress = getBindAddress();
43541
- await new Promise((resolve27, reject) => {
43578
+ await new Promise((resolve28, reject) => {
43542
43579
  const handleError = (error) => {
43543
43580
  server.off("error", handleError);
43544
43581
  if (error.code === "EADDRINUSE") {
@@ -43554,7 +43591,7 @@ async function startOAuthListener({
43554
43591
  server.once("error", handleError);
43555
43592
  server.listen(port, bindAddress, () => {
43556
43593
  server.off("error", handleError);
43557
- resolve27();
43594
+ resolve28();
43558
43595
  });
43559
43596
  });
43560
43597
  server.on("error", (error) => {
@@ -43562,7 +43599,7 @@ async function startOAuthListener({
43562
43599
  });
43563
43600
  return {
43564
43601
  waitForCallback: () => callbackPromise,
43565
- close: () => new Promise((resolve27, reject) => {
43602
+ close: () => new Promise((resolve28, reject) => {
43566
43603
  server.close((error) => {
43567
43604
  if (error && error.code !== "ERR_SERVER_NOT_RUNNING") {
43568
43605
  reject(error);
@@ -43571,7 +43608,7 @@ async function startOAuthListener({
43571
43608
  if (!settled) {
43572
43609
  rejectCallback(new Error("OAuth listener closed before callback"));
43573
43610
  }
43574
- resolve27();
43611
+ resolve28();
43575
43612
  });
43576
43613
  })
43577
43614
  };
@@ -43582,7 +43619,7 @@ async function startOAuthListener({
43582
43619
  }
43583
43620
 
43584
43621
  // src/plugin/session-context.ts
43585
- import { resolve as resolve19 } from "node:path";
43622
+ import { resolve as resolve20 } from "node:path";
43586
43623
  import { pathToFileURL } from "node:url";
43587
43624
  var FALLBACK_SESSION_KEY = "__default__";
43588
43625
  function extractOpenCodeSessionIdentity(headers) {
@@ -43596,7 +43633,7 @@ var AgySessionRegistry = class {
43596
43633
  requestSessions;
43597
43634
  parentSessionIds = /* @__PURE__ */ new Map();
43598
43635
  constructor(directory, options = {}) {
43599
- const workspaceUri = directory ? pathToFileURL(resolve19(directory)).href : "";
43636
+ const workspaceUri = directory ? pathToFileURL(resolve20(directory)).href : "";
43600
43637
  this.requestSessions = new AgyRequestSessionStore(workspaceUri, options);
43601
43638
  }
43602
43639
  getOrCreate(identity3) {
@@ -43725,6 +43762,107 @@ function isFlushReport(value) {
43725
43762
  // src/plugin/shared/request-services.ts
43726
43763
  init_dist();
43727
43764
 
43765
+ // src/common-auth-embedded/routing-accessor/index.js
43766
+ function isObject2(value) {
43767
+ return typeof value === "object" && value !== null;
43768
+ }
43769
+ function routingHandle(sessionId) {
43770
+ const routing = Reflect.get(globalThis, /* @__PURE__ */ Symbol.for("cortexkit.routing"));
43771
+ if (typeof routing !== "function")
43772
+ return void 0;
43773
+ const handle = routing(sessionId);
43774
+ return isObject2(handle) ? handle : void 0;
43775
+ }
43776
+ function selectionFor(answer, candidates) {
43777
+ if (!isObject2(answer))
43778
+ return void 0;
43779
+ const accountId = answer.account_id;
43780
+ const credentialId = answer.credential_id;
43781
+ if (typeof accountId !== "string")
43782
+ return void 0;
43783
+ if (credentialId !== void 0 && typeof credentialId !== "string") {
43784
+ return void 0;
43785
+ }
43786
+ const candidate = candidates.find((route) => route.accountId === accountId && (credentialId === void 0 || route.credentialId === credentialId));
43787
+ if (!candidate)
43788
+ return void 0;
43789
+ const hold = answer.hold;
43790
+ const retryAfterMs = isObject2(hold) ? hold.retry_after_ms : void 0;
43791
+ if (typeof retryAfterMs === "number" && Number.isFinite(retryAfterMs) && retryAfterMs >= 0) {
43792
+ return { candidate, hold: { retry_after_ms: retryAfterMs } };
43793
+ }
43794
+ return { candidate };
43795
+ }
43796
+ async function askRouting(input2) {
43797
+ let timer;
43798
+ try {
43799
+ const handle = routingHandle(input2.sessionId);
43800
+ if (!handle)
43801
+ return void 0;
43802
+ const accountFor = handle.accountFor;
43803
+ if (typeof accountFor !== "function")
43804
+ return void 0;
43805
+ const requested = input2.deadlineMs ?? 500;
43806
+ const deadlineMs = Number.isNaN(requested) ? 500 : Math.min(2e3, Math.max(1, requested));
43807
+ const expired = new Promise((resolve28) => {
43808
+ timer = setTimeout(() => resolve28(void 0), deadlineMs);
43809
+ timer.unref();
43810
+ });
43811
+ const pending = accountFor.call(handle, { provider: input2.provider, modelId: input2.modelId }, { deadlineMs });
43812
+ if (!isObject2(pending) || typeof pending.then !== "function")
43813
+ return void 0;
43814
+ const answer = await Promise.race([pending, expired]);
43815
+ return selectionFor(answer, input2.candidates);
43816
+ } catch {
43817
+ return void 0;
43818
+ } finally {
43819
+ clearTimeout(timer);
43820
+ }
43821
+ }
43822
+ function reportRouting(input2) {
43823
+ try {
43824
+ const handle = routingHandle(input2.sessionId);
43825
+ if (!handle)
43826
+ return;
43827
+ const report = handle.report;
43828
+ if (typeof report !== "function")
43829
+ return;
43830
+ const identity3 = {
43831
+ account_id: input2.accountId,
43832
+ ...input2.credentialId !== void 0 ? { credential_id: input2.credentialId } : {}
43833
+ };
43834
+ let payload;
43835
+ switch (input2.outcome) {
43836
+ case "served":
43837
+ payload = { ...identity3, outcome: "served", headers: input2.headers };
43838
+ break;
43839
+ case "exhausted": {
43840
+ const { window, pool } = input2;
43841
+ if (window !== "5h" && window !== "7d")
43842
+ return;
43843
+ if (pool !== void 0 && (typeof pool !== "string" || pool.length === 0 || pool.includes(":")))
43844
+ return;
43845
+ payload = {
43846
+ ...identity3,
43847
+ outcome: "exhausted",
43848
+ window,
43849
+ ...pool ? { pool } : {},
43850
+ ...input2.resetsAt !== void 0 ? { resets_at: input2.resetsAt } : {}
43851
+ };
43852
+ break;
43853
+ }
43854
+ default:
43855
+ return;
43856
+ }
43857
+ const pending = report.call(handle, payload);
43858
+ if (isObject2(pending) && typeof pending.then === "function") {
43859
+ void Promise.resolve(pending).catch(() => {
43860
+ });
43861
+ }
43862
+ } catch {
43863
+ }
43864
+ }
43865
+
43728
43866
  // src/plugin/errors.ts
43729
43867
  var AntigravityKillswitchError = class extends Error {
43730
43868
  family;
@@ -44225,10 +44363,10 @@ async function retainResponseLifetime(response, cancellation) {
44225
44363
  cancellation.release();
44226
44364
  throw error;
44227
44365
  }
44228
- let resolve27 = () => {
44366
+ let resolve28 = () => {
44229
44367
  };
44230
44368
  const settled = new Promise((done) => {
44231
- resolve27 = done;
44369
+ resolve28 = done;
44232
44370
  });
44233
44371
  let stopping = false;
44234
44372
  let finished = false;
@@ -44238,7 +44376,7 @@ async function retainResponseLifetime(response, cancellation) {
44238
44376
  finished = true;
44239
44377
  cancellation.signal.removeEventListener("abort", abort);
44240
44378
  cancellation.release();
44241
- resolve27();
44379
+ resolve28();
44242
44380
  };
44243
44381
  const abort = () => {
44244
44382
  if (finished || stopping) return;
@@ -44307,8 +44445,8 @@ function createAfterHandoff(work, signals, onFailure) {
44307
44445
  let running = false;
44308
44446
  let resolveCompletion = () => {
44309
44447
  };
44310
- const completion = new Promise((resolve27) => {
44311
- resolveCompletion = resolve27;
44448
+ const completion = new Promise((resolve28) => {
44449
+ resolveCompletion = resolve28;
44312
44450
  });
44313
44451
  const finish = () => {
44314
44452
  if (finished) return;
@@ -44355,19 +44493,205 @@ function createAfterHandoff(work, signals, onFailure) {
44355
44493
  };
44356
44494
  }
44357
44495
  function publishResponse(dispatch) {
44358
- return new Promise((resolve27, reject) => {
44496
+ return new Promise((resolve28, reject) => {
44359
44497
  let acknowledge;
44360
44498
  void Promise.resolve().then(
44361
44499
  () => dispatch((callback) => {
44362
44500
  acknowledge = callback;
44363
44501
  })
44364
44502
  ).then((response) => {
44365
- resolve27(response);
44503
+ resolve28(response);
44366
44504
  acknowledge?.();
44367
44505
  }, reject);
44368
44506
  });
44369
44507
  }
44370
44508
 
44509
+ // src/plugin/shared/vault-routing.ts
44510
+ var ROUTING_GROUP_SCOPED_EXHAUSTION = false;
44511
+ function hasVaultRoutingAccessor() {
44512
+ try {
44513
+ return typeof Reflect.get(globalThis, /* @__PURE__ */ Symbol.for("cortexkit.routing")) === "function";
44514
+ } catch {
44515
+ return false;
44516
+ }
44517
+ }
44518
+ function routingQuotaScope(group, window) {
44519
+ const limitWindow = window === "5h" ? "five_hour" : window === "weekly" ? "seven_day" : void 0;
44520
+ return limitWindow ? { pool: group === "non-gemini" ? "3p" : group, limitWindow } : void 0;
44521
+ }
44522
+ function routingExhaustionFields(scope) {
44523
+ return {
44524
+ pool: scope.pool,
44525
+ window: scope.limitWindow === "five_hour" ? "5h" : "7d"
44526
+ };
44527
+ }
44528
+ function reportVaultExhaustion(input2, groupScopedExhaustion = ROUTING_GROUP_SCOPED_EXHAUSTION, report = reportRouting) {
44529
+ if (!hasVaultRoutingAccessor() || input2.signal?.aborted || input2.status !== 429 || input2.reason !== "QUOTA_EXHAUSTED" || !Number.isFinite(input2.observedAt) || (input2.observedAt ?? 0) <= 0 || (input2.observedAt ?? Infinity) > Date.now())
44530
+ return;
44531
+ for (const window of input2.quota?.windows ?? []) {
44532
+ if (window.remainingFraction !== 0) continue;
44533
+ const scope = routingQuotaScope(input2.group, window.window);
44534
+ const resetsAt = Date.parse(window.resetTime);
44535
+ if (!scope || !Number.isFinite(resetsAt) || resetsAt <= Date.now()) continue;
44536
+ if (groupScopedExhaustion)
44537
+ report({
44538
+ ...input2.identity,
44539
+ outcome: "exhausted",
44540
+ ...routingExhaustionFields(scope),
44541
+ resetsAt
44542
+ });
44543
+ }
44544
+ }
44545
+ var RATE_LIMIT_HEADERS = [
44546
+ "retry-after",
44547
+ "retry-after-ms",
44548
+ "ratelimit-limit",
44549
+ "ratelimit-remaining",
44550
+ "ratelimit-reset",
44551
+ "ratelimit-policy",
44552
+ "x-ratelimit-limit",
44553
+ "x-ratelimit-remaining",
44554
+ "x-ratelimit-reset",
44555
+ "x-ratelimit-limit-requests",
44556
+ "x-ratelimit-remaining-requests",
44557
+ "x-ratelimit-reset-requests",
44558
+ "x-ratelimit-limit-tokens",
44559
+ "x-ratelimit-remaining-tokens",
44560
+ "x-ratelimit-reset-tokens"
44561
+ ];
44562
+ function streamFailure(value) {
44563
+ if (!value || typeof value !== "object") return false;
44564
+ if (Array.isArray(value)) return value.some(streamFailure);
44565
+ const event = value;
44566
+ return event.error != null || event.type === "error" || event.type === "response.failed" || event.status === "failed" || streamFailure(event.response);
44567
+ }
44568
+ function observeVaultUpstream(response, signal) {
44569
+ if (!hasVaultRoutingAccessor() || !response.ok || signal?.aborted)
44570
+ return void 0;
44571
+ let completed = false;
44572
+ return {
44573
+ response: observeBody(response, () => {
44574
+ completed = !signal?.aborted;
44575
+ }),
44576
+ completedSuccessfully: () => completed
44577
+ };
44578
+ }
44579
+ function observeVaultServed(identity3, response, signal, upstream) {
44580
+ if (!hasVaultRoutingAccessor() || !response.ok || signal?.aborted)
44581
+ return response;
44582
+ const report = () => {
44583
+ if (signal?.aborted || upstream && !upstream.completedSuccessfully() || !hasVaultRoutingAccessor())
44584
+ return;
44585
+ const headers = {};
44586
+ for (const name of RATE_LIMIT_HEADERS) {
44587
+ const value = response.headers.get(name);
44588
+ if (value !== null) headers[name] = value;
44589
+ }
44590
+ reportRouting({ ...identity3, outcome: "served", headers });
44591
+ };
44592
+ return observeBody(response, report);
44593
+ }
44594
+ function observeBody(response, complete) {
44595
+ if (!response.body) {
44596
+ complete();
44597
+ return response;
44598
+ }
44599
+ const sse = response.headers.get("content-type")?.includes("text/event-stream");
44600
+ const reader = response.body.getReader();
44601
+ const decoder = new TextDecoder();
44602
+ let pending = "";
44603
+ let failed = false;
44604
+ const inspect = (line) => {
44605
+ if (line.length > 1024 * 1024) {
44606
+ failed = true;
44607
+ return;
44608
+ }
44609
+ if (line.startsWith("event:") && line.slice(6).trim() === "error")
44610
+ failed = true;
44611
+ if (!line.startsWith("data:") || !/"(?:error|response.failed|failed)"/.test(line))
44612
+ return;
44613
+ try {
44614
+ failed ||= streamFailure(JSON.parse(line.slice(5)));
44615
+ } catch {
44616
+ failed = true;
44617
+ }
44618
+ };
44619
+ const body = new ReadableStream(
44620
+ {
44621
+ async pull(controller) {
44622
+ try {
44623
+ const chunk = await reader.read();
44624
+ if (chunk.done) {
44625
+ if (sse) inspect(pending + decoder.decode());
44626
+ else if (/"(?:error|response.failed|failed)"/.test(pending)) {
44627
+ try {
44628
+ failed ||= streamFailure(JSON.parse(pending + decoder.decode()));
44629
+ } catch {
44630
+ failed = true;
44631
+ }
44632
+ }
44633
+ if (!failed) complete();
44634
+ controller.close();
44635
+ reader.releaseLock();
44636
+ return;
44637
+ }
44638
+ if (!failed) {
44639
+ pending += decoder.decode(chunk.value, { stream: true });
44640
+ if (sse) {
44641
+ let newline = pending.indexOf("\n");
44642
+ while (newline >= 0) {
44643
+ inspect(pending.slice(0, newline));
44644
+ pending = pending.slice(newline + 1);
44645
+ newline = pending.indexOf("\n");
44646
+ }
44647
+ }
44648
+ if (pending.length > 1024 * 1024) {
44649
+ failed = true;
44650
+ pending = "";
44651
+ }
44652
+ }
44653
+ controller.enqueue(chunk.value);
44654
+ } catch (error) {
44655
+ failed = true;
44656
+ controller.error(error);
44657
+ reader.releaseLock();
44658
+ }
44659
+ },
44660
+ async cancel(reason) {
44661
+ failed = true;
44662
+ try {
44663
+ await reader.cancel(reason);
44664
+ } finally {
44665
+ reader.releaseLock();
44666
+ }
44667
+ }
44668
+ },
44669
+ { highWaterMark: 0 }
44670
+ );
44671
+ const observed = new Response(body, {
44672
+ status: response.status,
44673
+ statusText: response.statusText,
44674
+ headers: response.headers
44675
+ });
44676
+ Object.defineProperties(observed, {
44677
+ url: { value: response.url },
44678
+ redirected: { value: response.redirected }
44679
+ });
44680
+ return observed;
44681
+ }
44682
+
44683
+ // src/plugin/shared/vault-routing-purpose.ts
44684
+ var VAULT_ROUTING_PURPOSE_HEADER = "x-antigravity-internal-request-purpose";
44685
+ function createVaultRoutingHeaders(providerId) {
44686
+ return async (input2, output2) => {
44687
+ if (input2.model.providerID !== providerId) return;
44688
+ output2.headers[VAULT_ROUTING_PURPOSE_HEADER] = input2.agent === "build" || input2.agent === "plan" ? "primary" : "auxiliary";
44689
+ };
44690
+ }
44691
+ function isPrimaryVaultRequest(kind, headers) {
44692
+ return kind === void 0 ? new Headers(headers).get(VAULT_ROUTING_PURPOSE_HEADER) === "primary" : kind === "primary";
44693
+ }
44694
+
44371
44695
  // src/plugin/shared/request-services.ts
44372
44696
  var FIRST_RETRY_DELAY_MS = 1e3;
44373
44697
  function prepareAgyWireRequest(wire, request) {
@@ -44464,7 +44788,7 @@ function formatWaitTime(ms) {
44464
44788
  return remainingMinutes > 0 ? `${hours}h ${remainingMinutes}m` : `${hours}h`;
44465
44789
  }
44466
44790
  function sleep4(ms, signal) {
44467
- return new Promise((resolve27, reject) => {
44791
+ return new Promise((resolve28, reject) => {
44468
44792
  if (signal?.aborted) {
44469
44793
  reject(
44470
44794
  signal.reason instanceof Error ? signal.reason : new Error("Aborted")
@@ -44473,7 +44797,7 @@ function sleep4(ms, signal) {
44473
44797
  }
44474
44798
  const timeout = setTimeout(() => {
44475
44799
  cleanup2();
44476
- resolve27();
44800
+ resolve28();
44477
44801
  }, ms);
44478
44802
  const onAbort = () => {
44479
44803
  cleanup2();
@@ -44559,7 +44883,7 @@ function createRequestExecutor(deps) {
44559
44883
  log16.debug("send-admission-401-report-failed", { error: String(error) });
44560
44884
  });
44561
44885
  };
44562
- const reportRouting = (sessionId, entry) => {
44886
+ const reportRouting2 = (sessionId, entry) => {
44563
44887
  if (!onRouting) return;
44564
44888
  try {
44565
44889
  onRouting(sessionId, entry);
@@ -44730,6 +45054,7 @@ function createRequestExecutor(deps) {
44730
45054
  const maxWaitMs = (config.max_rate_limit_wait_seconds ?? 300) * 1e3;
44731
45055
  let allAccountsBlockedAt;
44732
45056
  const modelUnavailableIndexes = /* @__PURE__ */ new Set();
45057
+ let routingPlacementConsidered = false;
44733
45058
  while (true) {
44734
45059
  await assertAdmission();
44735
45060
  checkAborted();
@@ -44813,6 +45138,11 @@ function createRequestExecutor(deps) {
44813
45138
  }
44814
45139
  }
44815
45140
  const excludedIndexes = modelUnavailableIndexes.size === 0 ? killedIndexes : /* @__PURE__ */ new Set([...killedIndexes ?? [], ...modelUnavailableIndexes]);
45141
+ const routingPresent = credentials.domain === "vault" && hasVaultRoutingAccessor();
45142
+ const firstPlacement = routingPresent && !routingPlacementConsidered && accountSessionIdentity && !accountManager.getCurrentAccountForFamily(
45143
+ family,
45144
+ accountSessionIdentity
45145
+ );
44816
45146
  let account = accountManager.getCurrentOrNextForFamily(
44817
45147
  family,
44818
45148
  model,
@@ -44823,6 +45153,50 @@ function createRequestExecutor(deps) {
44823
45153
  accountSessionIdentity,
44824
45154
  excludedIndexes
44825
45155
  );
45156
+ if (account) {
45157
+ routingPlacementConsidered = true;
45158
+ if (firstPlacement && credentials.domain === "vault" && credentials.routingCandidate && model && isPrimaryVaultRequest(kind, init?.headers)) {
45159
+ const candidates = accountManager.getEnabledAccounts().filter(
45160
+ (row) => !excludedIndexes?.has(row.index) && !accountManager.isRateLimited(row, family, model) && !accountManager.isAccountCoolingDown(row) && !accountManager.isAccountOverSoftQuota(
45161
+ row,
45162
+ family,
45163
+ config.soft_quota_threshold_percent,
45164
+ softQuotaCacheTtlMs,
45165
+ model
45166
+ )
45167
+ ).map((row) => ({
45168
+ ...credentials.routingCandidate(row),
45169
+ index: row.index
45170
+ }));
45171
+ if (candidates.length > 0) {
45172
+ const answer = await deadline.wait(
45173
+ () => askRouting({
45174
+ sessionId: accountSessionIdentity.id,
45175
+ provider: "antigravity",
45176
+ modelId: model,
45177
+ candidates,
45178
+ deadlineMs: Math.min(500, deadline.remainingMs())
45179
+ })
45180
+ );
45181
+ checkAborted();
45182
+ if (answer && answer.candidate.index !== account.index) {
45183
+ account = accountManager.getCurrentOrNextForFamily(
45184
+ family,
45185
+ model,
45186
+ config.account_selection_strategy,
45187
+ config.pid_offset_enabled,
45188
+ config.soft_quota_threshold_percent,
45189
+ softQuotaCacheTtlMs,
45190
+ accountSessionIdentity,
45191
+ /* @__PURE__ */ new Set([
45192
+ ...excludedIndexes ?? [],
45193
+ ...accountManager.getAccounts().filter((row) => row.index !== answer.candidate.index).map((row) => row.index)
45194
+ ])
45195
+ ) ?? account;
45196
+ }
45197
+ }
45198
+ }
45199
+ }
44826
45200
  if (account && eligibleIndexes !== null && !eligibleIndexes.has(account.index)) {
44827
45201
  pushDebug(
44828
45202
  `killswitch-excluded idx=${account.index} (precomputed eligible set)`
@@ -45482,7 +45856,7 @@ function createRequestExecutor(deps) {
45482
45856
  strategy: config.account_selection_strategy,
45483
45857
  updatedAt: Date.now()
45484
45858
  };
45485
- reportRouting(sessionKey, routingEntry);
45859
+ reportRouting2(sessionKey, routingEntry);
45486
45860
  }
45487
45861
  if (response.status === 429 || response.status === 503 || response.status === 529) {
45488
45862
  if (tokenConsumed) {
@@ -45517,6 +45891,26 @@ function createRequestExecutor(deps) {
45517
45891
  reasonInfo.message,
45518
45892
  response.status
45519
45893
  );
45894
+ if (credentials.domain === "vault" && sendAdmission && sessionKey && hasVaultRoutingAccessor()) {
45895
+ const group = resolveQuotaGroup(
45896
+ family,
45897
+ model,
45898
+ account.cachedQuota
45899
+ );
45900
+ reportVaultExhaustion({
45901
+ identity: {
45902
+ sessionId: sessionKey,
45903
+ accountId: sendAdmission.accountIdentity,
45904
+ credentialId: sendAdmission.credentialId
45905
+ },
45906
+ status: response.status,
45907
+ reason: rateLimitReason,
45908
+ group,
45909
+ quota: account.cachedQuota?.[group],
45910
+ observedAt: account.cachedQuotaUpdatedAt,
45911
+ signal: abortSignal
45912
+ });
45913
+ }
45520
45914
  if (rateLimitReason === "MODEL_CAPACITY_EXHAUSTED" || rateLimitReason === "SERVER_ERROR") {
45521
45915
  totalCapacityRetries++;
45522
45916
  if (isCapacityRetryBudgetExhausted(totalCapacityRetries)) {
@@ -45854,9 +46248,10 @@ function createRequestExecutor(deps) {
45854
46248
  const _emptyAttemptKeyClean = `${prepared.sessionId ?? "none"}:${prepared.effectiveModel ?? "unknown"}`;
45855
46249
  retryState.clearEmptyResponseAttempts();
45856
46250
  }
46251
+ const routingObservation = credentials.domain === "vault" && sendAdmission && sessionKey && response.ok && hasVaultRoutingAccessor() ? observeVaultUpstream(response, abortSignal) : void 0;
45857
46252
  const transformedResponse = await deadline.wait(
45858
46253
  () => wire.transformResponse(
45859
- response,
46254
+ routingObservation?.response ?? response,
45860
46255
  prepared.streaming,
45861
46256
  debugContext,
45862
46257
  prepared.requestedModel,
@@ -45928,7 +46323,16 @@ function createRequestExecutor(deps) {
45928
46323
  const refresh = credentials.refreshQuotaAfterSuccess;
45929
46324
  waitPolicy.quota = (signal) => refresh(account, config.quota_refresh_interval_minutes, signal);
45930
46325
  }
45931
- return transformedResponse;
46326
+ return routingObservation && credentials.domain === "vault" && sendAdmission && sessionKey && hasVaultRoutingAccessor() && response.ok ? observeVaultServed(
46327
+ {
46328
+ sessionId: sessionKey,
46329
+ accountId: sendAdmission.accountIdentity,
46330
+ credentialId: sendAdmission.credentialId
46331
+ },
46332
+ transformedResponse,
46333
+ abortSignal,
46334
+ routingObservation
46335
+ ) : transformedResponse;
45932
46336
  } catch (error) {
45933
46337
  if (error instanceof PreResponseTimeoutError) throw error;
45934
46338
  checkAborted();
@@ -47556,7 +47960,7 @@ function createGaReauthorize(input2) {
47556
47960
  const continuations = /* @__PURE__ */ new Set();
47557
47961
  const shutdown = new AbortController();
47558
47962
  let disposed = false;
47559
- const waitForRedirect = (code2) => new Promise((resolve27, reject) => {
47963
+ const waitForRedirect = (code2) => new Promise((resolve28, reject) => {
47560
47964
  const detach = () => shutdown.signal.removeEventListener("abort", abort);
47561
47965
  const abort = () => {
47562
47966
  detach();
@@ -47567,7 +47971,7 @@ function createGaReauthorize(input2) {
47567
47971
  void code2.then(
47568
47972
  (value) => {
47569
47973
  detach();
47570
- resolve27(value);
47974
+ resolve28(value);
47571
47975
  },
47572
47976
  (error) => {
47573
47977
  detach();
@@ -50228,11 +50632,11 @@ init_dist();
50228
50632
  var GA_POOL_METHOD_ID = "antigravity-auth-pool-browser";
50229
50633
  var LOGIN_FAILED = "The Antigravity pool login could not be completed.";
50230
50634
  function abortable(pending, signal) {
50231
- return new Promise((resolve27, reject) => {
50635
+ return new Promise((resolve28, reject) => {
50232
50636
  const abort = () => reject(signal.reason);
50233
50637
  if (signal.aborted) abort();
50234
50638
  else signal.addEventListener("abort", abort, { once: true });
50235
- void pending.then(resolve27, reject).finally(() => {
50639
+ void pending.then(resolve28, reject).finally(() => {
50236
50640
  signal.removeEventListener("abort", abort);
50237
50641
  });
50238
50642
  });
@@ -50602,11 +51006,11 @@ async function startGaLoopbackBridge(options) {
50602
51006
  }
50603
51007
  }
50604
51008
  };
50605
- await new Promise((resolve27, reject) => {
51009
+ await new Promise((resolve28, reject) => {
50606
51010
  server.once("error", reject);
50607
51011
  server.listen(0, BRIDGE_HOST, () => {
50608
51012
  server.off("error", reject);
50609
- resolve27();
51013
+ resolve28();
50610
51014
  });
50611
51015
  });
50612
51016
  server.unref();
@@ -50710,8 +51114,8 @@ async function startGaLoopbackBridge(options) {
50710
51114
  disposal = (async () => {
50711
51115
  for (const { timer } of queued.values()) clearTimeout(timer);
50712
51116
  queued.clear();
50713
- const closed2 = new Promise((resolve27) => {
50714
- server.close(() => resolve27());
51117
+ const closed2 = new Promise((resolve28) => {
51118
+ server.close(() => resolve28());
50715
51119
  });
50716
51120
  for (const controller of running) {
50717
51121
  controller.abort(
@@ -50775,9 +51179,9 @@ async function pipeResponse(upstream, response, onFailure, onHandoff) {
50775
51179
  return;
50776
51180
  }
50777
51181
  if (!response.write(value) && !response.destroyed) {
50778
- await new Promise((resolve27) => {
50779
- response.once("drain", resolve27);
50780
- response.once("close", resolve27);
51182
+ await new Promise((resolve28) => {
51183
+ response.once("drain", resolve28);
51184
+ response.once("close", resolve28);
50781
51185
  });
50782
51186
  }
50783
51187
  if (response.destroyed) {
@@ -50818,30 +51222,30 @@ function classifyGaSetupContext(context) {
50818
51222
  const location = record3.location;
50819
51223
  if (session === void 0 && location === void 0) return "legacy";
50820
51224
  const missing = [];
50821
- if (!isObject2(location) || typeof location.directory !== "string") {
51225
+ if (!isObject3(location) || typeof location.directory !== "string") {
50822
51226
  missing.push("location.directory");
50823
51227
  }
50824
- if (!isObject2(session) || typeof session.hook !== "function") {
51228
+ if (!isObject3(session) || typeof session.hook !== "function") {
50825
51229
  missing.push("session.hook");
50826
51230
  }
50827
51231
  if (session !== void 0 && location !== void 0 && missing.length === 0) {
50828
51232
  const rpc = record3.rpc;
50829
- if (!isObject2(rpc) && typeof rpc !== "function" || typeof Reflect.get(rpc, "register") !== "function") {
51233
+ if (!isObject3(rpc) && typeof rpc !== "function" || typeof Reflect.get(rpc, "register") !== "function") {
50830
51234
  missing.push("rpc.register");
50831
51235
  }
50832
51236
  const provider2 = record3.provider;
50833
- if (!isObject2(provider2) || typeof provider2.transform !== "function") {
51237
+ if (!isObject3(provider2) || typeof provider2.transform !== "function") {
50834
51238
  missing.push("provider.transform");
50835
51239
  }
50836
51240
  const command = record3.command;
50837
- if (!isObject2(command) || typeof command.transform !== "function") {
51241
+ if (!isObject3(command) || typeof command.transform !== "function") {
50838
51242
  missing.push("command.transform");
50839
51243
  }
50840
51244
  }
50841
51245
  if (missing.length > 0) throw new GaSetupContextError(missing);
50842
51246
  return "ga";
50843
51247
  }
50844
- function isObject2(value) {
51248
+ function isObject3(value) {
50845
51249
  return typeof value === "object" && value !== null;
50846
51250
  }
50847
51251
  function createGaGeneration() {
@@ -51448,13 +51852,13 @@ function createGaAntigravityPlugin(overrides = {}) {
51448
51852
  // src/plugin/index.ts
51449
51853
  init_dist();
51450
51854
  import { createHash as createHash23, randomUUID as randomUUID22 } from "node:crypto";
51451
- import { join as join38, resolve as resolve26 } from "node:path";
51855
+ import { join as join39, resolve as resolve27 } from "node:path";
51452
51856
 
51453
51857
  // src/cli.ts
51454
51858
  init_dist();
51455
51859
  import { execFile } from "node:child_process";
51456
51860
  import { realpathSync as realpathSync5 } from "node:fs";
51457
- import { resolve as resolve23 } from "node:path";
51861
+ import { resolve as resolve24 } from "node:path";
51458
51862
  import { createInterface } from "node:readline/promises";
51459
51863
  import { fileURLToPath as fileURLToPath2 } from "node:url";
51460
51864
  import { promisify } from "node:util";
@@ -51511,7 +51915,7 @@ init_runtime_paths();
51511
51915
  // src/setup.ts
51512
51916
  init_dist();
51513
51917
  import { lstat as lstat9, readFile as readFile16 } from "node:fs/promises";
51514
- import { join as join29, resolve as resolve22 } from "node:path";
51918
+ import { join as join30, resolve as resolve23 } from "node:path";
51515
51919
 
51516
51920
  // src/common-auth-embedded/auth-menu/ansi.js
51517
51921
  var ANSI2 = {
@@ -51679,7 +52083,7 @@ async function select2(terminal, items, options) {
51679
52083
  writeLine("");
51680
52084
  renderedLines = lines;
51681
52085
  };
51682
- return new Promise((resolve27) => {
52086
+ return new Promise((resolve28) => {
51683
52087
  const wasRaw = stdin.isRaw ?? false;
51684
52088
  const cleanup2 = () => {
51685
52089
  if (cleaned)
@@ -51699,7 +52103,7 @@ async function select2(terminal, items, options) {
51699
52103
  };
51700
52104
  const finish = (value) => {
51701
52105
  cleanup2();
51702
- resolve27(value);
52106
+ resolve28(value);
51703
52107
  };
51704
52108
  const onSignal = () => finish(null);
51705
52109
  const onKey = (data) => {
@@ -51739,7 +52143,7 @@ async function select2(terminal, items, options) {
51739
52143
  stdin.setRawMode(true);
51740
52144
  } catch {
51741
52145
  cleanup2();
51742
- resolve27(null);
52146
+ resolve28(null);
51743
52147
  return;
51744
52148
  }
51745
52149
  stdin.resume();
@@ -51753,12 +52157,12 @@ async function select2(terminal, items, options) {
51753
52157
  import { createHash as createHash18, randomBytes as randomBytes6, randomUUID as randomUUID19 } from "node:crypto";
51754
52158
  import { constants as fsConstants2 } from "node:fs";
51755
52159
  import { chmod as chmod6, mkdir as mkdir15, open as open10, readFile as readFile14, realpath as realpath4, rename as rename12, stat as stat11, unlink as unlink10 } from "node:fs/promises";
51756
- import { basename as basename6, dirname as dirname22, extname as extname2, isAbsolute as isAbsolute3, join as join25, resolve as resolve21 } from "node:path";
52160
+ import { basename as basename6, dirname as dirname22, extname as extname2, isAbsolute as isAbsolute3, join as join26, resolve as resolve22 } from "node:path";
51757
52161
  import { ClaustrumCredentialError as ClaustrumCredentialError5, ClaustrumClient as ClaustrumWireClient2, writeEnrollmentTokenFile as writeEnrollmentTokenFile2 } from "@cortexkit/claustrum-client";
51758
52162
 
51759
52163
  // src/common-auth-embedded/fs/file-read-cache.js
51760
52164
  import { lstat as lstat7 } from "node:fs/promises";
51761
- import { resolve as resolve20 } from "node:path";
52165
+ import { resolve as resolve21 } from "node:path";
51762
52166
  async function identity2(path5) {
51763
52167
  try {
51764
52168
  const metadata = await lstat7(path5);
@@ -51775,7 +52179,7 @@ function sameIdentity2(left, right) {
51775
52179
  var FileReadCache2 = class {
51776
52180
  #entries = /* @__PURE__ */ new Map();
51777
52181
  async read(paths, read, validateHit) {
51778
- const resolvedPaths = paths.map((path5) => resolve20(path5));
52182
+ const resolvedPaths = paths.map((path5) => resolve21(path5));
51779
52183
  const key = JSON.stringify(resolvedPaths);
51780
52184
  const probed = await Promise.all(resolvedPaths.map(identity2));
51781
52185
  const identities = probed.every((entry) => entry !== void 0) ? probed : void 0;
@@ -51827,9 +52231,10 @@ init_private_files2();
51827
52231
  init_private_files2();
51828
52232
  import { randomUUID as randomUUID18 } from "node:crypto";
51829
52233
  import { lstat as lstat8, mkdir as mkdir14, open as open9, readFile as readFile13, rename as rename11, rm as rm6, stat as stat10 } from "node:fs/promises";
51830
- import { dirname as dirname21, join as join24 } from "node:path";
52234
+ import { dirname as dirname21, join as join25 } from "node:path";
51831
52235
 
51832
52236
  // src/common-auth-embedded/fs/with-lock.js
52237
+ init_private_files2();
51833
52238
  function lockPathFor2(target, name) {
51834
52239
  return `${target}.${name}.lock`;
51835
52240
  }
@@ -51887,7 +52292,7 @@ function acquireRefreshFileLock2(options) {
51887
52292
  }
51888
52293
  async function acquireRefreshFileLockWithClock2(options) {
51889
52294
  const lockPath = lockPathFor2(options.path, options.name);
51890
- const legacyOwnerPath = join24(lockPath, "owner.json");
52295
+ const legacyOwnerPath = join25(lockPath, "owner.json");
51891
52296
  const ownerId = randomUUID18();
51892
52297
  const now = options.now ?? Date.now;
51893
52298
  let renewTimer = null;
@@ -51895,8 +52300,8 @@ async function acquireRefreshFileLockWithClock2(options) {
51895
52300
  let releaseConfirmed = false;
51896
52301
  let loss;
51897
52302
  let resolveLoss;
51898
- const lostPromise = new Promise((resolve27) => {
51899
- resolveLoss = resolve27;
52303
+ const lostPromise = new Promise((resolve28) => {
52304
+ resolveLoss = resolve28;
51900
52305
  });
51901
52306
  function notifyTimerStep(event) {
51902
52307
  try {
@@ -51930,7 +52335,7 @@ async function acquireRefreshFileLockWithClock2(options) {
51930
52335
  let terminalIOError;
51931
52336
  let renewalInFlight = null;
51932
52337
  const evictPath = `${lockPath}.evicting`;
51933
- const evictOwnerPath = join24(evictPath, "owner.json");
52338
+ const evictOwnerPath = join25(evictPath, "owner.json");
51934
52339
  const evictOwnerId = randomUUID18();
51935
52340
  const EVICT_TTL = 5e3;
51936
52341
  const MAX_STEAL_ATTEMPTS = 8;
@@ -52057,7 +52462,7 @@ async function acquireRefreshFileLockWithClock2(options) {
52057
52462
  }
52058
52463
  }
52059
52464
  async function backoff() {
52060
- await new Promise((resolve27) => setTimeout(resolve27, Math.floor(Math.random() * 4)));
52465
+ await new Promise((resolve28) => setTimeout(resolve28, Math.floor(Math.random() * 4)));
52061
52466
  }
52062
52467
  async function readLockState(notifyReady = true) {
52063
52468
  if (notifyReady && options.onStep)
@@ -52547,7 +52952,7 @@ async function acquireRefreshFileLockWithClock2(options) {
52547
52952
  const remainingMs = deadline - performance.now();
52548
52953
  if (remainingMs <= 0)
52549
52954
  break;
52550
- await new Promise((resolve27) => setTimeout(resolve27, Math.min(delayMs, remainingMs)));
52955
+ await new Promise((resolve28) => setTimeout(resolve28, Math.min(delayMs, remainingMs)));
52551
52956
  delayMs = Math.min(delayMs * 2, 50);
52552
52957
  }
52553
52958
  if (windowsPrivateFiles2)
@@ -52612,7 +53017,7 @@ function getClaustrumEnrollmentPaths2(tokenPath) {
52612
53017
  const extension = extname2(tokenPath) || ".json";
52613
53018
  const stem = basename6(tokenPath, extname2(tokenPath));
52614
53019
  return {
52615
- statePath: join25(dirname22(tokenPath), `${stem}-state${extension}`),
53020
+ statePath: join26(dirname22(tokenPath), `${stem}-state${extension}`),
52616
53021
  tokenPath
52617
53022
  };
52618
53023
  }
@@ -52620,7 +53025,7 @@ function hostEnrollmentPaths2(input2) {
52620
53025
  const override = input2.override?.trim();
52621
53026
  if (override && !isAbsolute3(override) && !input2.cwd)
52622
53027
  throw new ClaustrumConsumerError2("invalid-state", "A relative Claustrum enrollment override needs a base directory");
52623
- const tokenPath = override ? isAbsolute3(override) ? override : resolve21(input2.cwd, override) : join25(input2.stateDir, `${input2.host}-enrollment.json`);
53028
+ const tokenPath = override ? isAbsolute3(override) ? override : resolve22(input2.cwd, override) : join26(input2.stateDir, `${input2.host}-enrollment.json`);
52624
53029
  return getClaustrumEnrollmentPaths2(tokenPath);
52625
53030
  }
52626
53031
  function isRecord11(value) {
@@ -52853,7 +53258,7 @@ async function writeStateAtomic2(path5, state, ancestorOptions = {}) {
52853
53258
  }
52854
53259
  if (windowsPrivateFiles2)
52855
53260
  return writePrivateAtomic2(path5, bytes);
52856
- const temporary = join25(parent, `.${basename6(path5)}.${process.pid}.${randomUUID19()}.tmp`);
53261
+ const temporary = join26(parent, `.${basename6(path5)}.${process.pid}.${randomUUID19()}.tmp`);
52857
53262
  let descriptor;
52858
53263
  let created = false;
52859
53264
  try {
@@ -53248,7 +53653,7 @@ var ByteTail = class {
53248
53653
  };
53249
53654
  var defaultCommandRunner = {
53250
53655
  run(file, args, options = {}) {
53251
- return new Promise((resolve27) => {
53656
+ return new Promise((resolve28) => {
53252
53657
  const started = performance.now();
53253
53658
  const timeoutMs = options.timeoutMs ?? 15e3;
53254
53659
  const stderr = new ByteTail();
@@ -53266,7 +53671,7 @@ var defaultCommandRunner = {
53266
53671
  stdio: ["ignore", "pipe", "pipe"]
53267
53672
  });
53268
53673
  } catch {
53269
- resolve27({
53674
+ resolve28({
53270
53675
  exitCode: 1,
53271
53676
  stdout: "",
53272
53677
  stderr: "",
@@ -53301,7 +53706,7 @@ var defaultCommandRunner = {
53301
53706
  settled = true;
53302
53707
  if (timer)
53303
53708
  clearTimeout(timer);
53304
- resolve27({
53709
+ resolve28({
53305
53710
  exitCode: spawnError ? 1 : outputExceeded ? 1 : code2 ?? 1,
53306
53711
  stdout: Buffer.concat(stdout, stdoutLength).toString("utf8"),
53307
53712
  stderr: stderr.toString(),
@@ -53388,7 +53793,7 @@ function recordSetupEnrollment(failure2, enrollment) {
53388
53793
  import { accessSync, constants as constants3, existsSync as existsSync12, readFileSync as readFileSync10, realpathSync as realpathSync4, statSync as statSync5 } from "node:fs";
53389
53794
  import { mkdtemp, rm as rm7 } from "node:fs/promises";
53390
53795
  import { tmpdir as tmpdir5 } from "node:os";
53391
- import { join as join26 } from "node:path";
53796
+ import { join as join27 } from "node:path";
53392
53797
  import { parse } from "jsonc-parser";
53393
53798
 
53394
53799
  // src/common-auth-embedded/setup/paths.js
@@ -53559,7 +53964,7 @@ async function detectHosts(plugin2, io = {}) {
53559
53964
  return null;
53560
53965
  let root;
53561
53966
  try {
53562
- root = await mkdtemp(join26(tmpdir5(), "common-auth-setup-version-"));
53967
+ root = await mkdtemp(join27(tmpdir5(), "common-auth-setup-version-"));
53563
53968
  const probeEnv = {
53564
53969
  ...env3,
53565
53970
  HOME: root,
@@ -54144,7 +54549,7 @@ import { applyEdits, createScanner, findNodeAtLocation, modify, parse as parse2,
54144
54549
  // src/common-auth-embedded/setup/config-write.js
54145
54550
  import { randomUUID as randomUUID20 } from "node:crypto";
54146
54551
  import { mkdir as mkdir16, open as open11, rename as rename13, stat as stat13, unlink as unlink11 } from "node:fs/promises";
54147
- import { basename as basename7, dirname as dirname23, join as join27 } from "node:path";
54552
+ import { basename as basename7, dirname as dirname23, join as join28 } from "node:path";
54148
54553
  import { setTimeout as delay2 } from "node:timers/promises";
54149
54554
  async function writeHostConfigAtomic(file, content, options = {}) {
54150
54555
  const windows2 = (options.platform ?? process.platform) === "win32";
@@ -54159,7 +54564,7 @@ async function writeHostConfigAtomic(file, content, options = {}) {
54159
54564
  throw error;
54160
54565
  }
54161
54566
  }
54162
- const stage = join27(parent, `.${basename7(file)}.${(options.stageName ?? randomUUID20)()}.tmp`);
54567
+ const stage = join28(parent, `.${basename7(file)}.${(options.stageName ?? randomUUID20)()}.tmp`);
54163
54568
  let created = false;
54164
54569
  try {
54165
54570
  const handle = await open11(stage, "wx", mode ?? 438);
@@ -54579,11 +54984,11 @@ init_storage();
54579
54984
  init_dist();
54580
54985
  import { readFile as readFile15 } from "node:fs/promises";
54581
54986
  import { homedir as homedir11 } from "node:os";
54582
- import { join as join28 } from "node:path";
54987
+ import { join as join29 } from "node:path";
54583
54988
  var V1_VAULT_ACTIVATION_LABEL = "Activate approved Antigravity vault";
54584
54989
  function nativeOpenCodeAuthPath(env3 = process.env, home = homedir11()) {
54585
- return join28(
54586
- env3.XDG_DATA_HOME || join28(home, ".local", "share"),
54990
+ return join29(
54991
+ env3.XDG_DATA_HOME || join29(home, ".local", "share"),
54587
54992
  "opencode",
54588
54993
  "auth.json"
54589
54994
  );
@@ -54647,7 +55052,7 @@ function openCodeVaultDir(accountFile) {
54647
55052
  return folder.vaultDir;
54648
55053
  }
54649
55054
  function nativeAuthPath(host, context) {
54650
- return host === "opencode" ? nativeOpenCodeAuthPath() : join29(context.piAgentDir, "auth.json");
55055
+ return host === "opencode" ? nativeOpenCodeAuthPath() : join30(context.piAgentDir, "auth.json");
54651
55056
  }
54652
55057
  function provider(host) {
54653
55058
  return host === "opencode" ? OPENCODE_VAULT_PROVIDER : ANTIGRAVITY_PROVIDER_ID;
@@ -54703,7 +55108,7 @@ async function writeNativeSlot(host, slot, context, expectedAuthority = "local")
54703
55108
  beforeRename: async () => {
54704
55109
  await assertSetupHostsStopped();
54705
55110
  const claustrum = await loadCommonAuthClaustrum();
54706
- const stateDir = host === "opencode" ? openCodeVaultDir(resolve22(accountFileForVault())) : getPiAntigravityVaultDir();
55111
+ const stateDir = host === "opencode" ? openCodeVaultDir(resolve23(accountFileForVault())) : getPiAntigravityVaultDir();
54707
55112
  if (await claustrum.enrollmentAuthority(
54708
55113
  claustrum.hostEnrollmentPaths({ stateDir, host }),
54709
55114
  `antigravity-auth-${host}`
@@ -54741,7 +55146,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
54741
55146
  // `beforeSignIn`, which may move it after this plugin is built.
54742
55147
  paths: {
54743
55148
  get stateDir() {
54744
- return openCodeVaultDir(resolve22(accountFileForVault()));
55149
+ return openCodeVaultDir(resolve23(accountFileForVault()));
54745
55150
  },
54746
55151
  host: "opencode"
54747
55152
  }
@@ -54758,7 +55163,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
54758
55163
  const assertLocal = async (host, context) => {
54759
55164
  if (host === "opencode")
54760
55165
  return assertLocalOpenCodeLogin(
54761
- resolve22(accountFileForVault()),
55166
+ resolve23(accountFileForVault()),
54762
55167
  context.opencodeGeneration
54763
55168
  );
54764
55169
  if (await authority(host) !== "local")
@@ -54774,7 +55179,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
54774
55179
  const { openPiSlot: openPiSlot2 } = await loadCommonAuthPiSlot();
54775
55180
  if ((await openPiSlot2({
54776
55181
  authPath: nativeAuthPath(host, context),
54777
- stashPath: join29(piDir, "google-login-stash.json"),
55182
+ stashPath: join30(piDir, "google-login-stash.json"),
54778
55183
  provider: ANTIGRAVITY_PROVIDER_ID,
54779
55184
  placeholderKey: PI_PLACEHOLDER_KEY
54780
55185
  }).inspect()).slot === "placeholder")
@@ -54814,7 +55219,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
54814
55219
  const { openPiSlot: openPiSlot2 } = await loadCommonAuthPiSlot();
54815
55220
  const inspection = await openPiSlot2({
54816
55221
  authPath: nativeAuthPath("pi", context),
54817
- stashPath: join29(piDir, "google-login-stash.json"),
55222
+ stashPath: join30(piDir, "google-login-stash.json"),
54818
55223
  provider: ANTIGRAVITY_PROVIDER_ID,
54819
55224
  placeholderKey: PI_PLACEHOLDER_KEY
54820
55225
  }).inspect();
@@ -54933,7 +55338,7 @@ Setup has not completed the OpenCode 2 native Google connection.
54933
55338
  await assertSetupHostsStopped();
54934
55339
  await openPiSlot2({
54935
55340
  authPath: nativeAuthPath(host, context),
54936
- stashPath: join29(piDir, "google-login-stash.json"),
55341
+ stashPath: join30(piDir, "google-login-stash.json"),
54937
55342
  provider: ANTIGRAVITY_PROVIDER_ID,
54938
55343
  placeholderKey: PI_PLACEHOLDER_KEY
54939
55344
  }).enterVault();
@@ -55388,7 +55793,7 @@ async function runCliProcess(argv, deps) {
55388
55793
  ...deps,
55389
55794
  prepareVaultFolder: deps.prepareVaultFolder ?? (async (options) => {
55390
55795
  const folder = await prepareVaultFolder({
55391
- accountFile: resolve23(accountFileForVault()),
55796
+ accountFile: resolve24(accountFileForVault()),
55392
55797
  ...options
55393
55798
  });
55394
55799
  if (folder.refusal) throw folder.refusal;
@@ -55434,11 +55839,11 @@ function createDefaultCliDependencies() {
55434
55839
  );
55435
55840
  if (host !== "pi")
55436
55841
  await assertLocalOpenCodeLogin(
55437
- resolve23(accountFileForVault()),
55842
+ resolve24(accountFileForVault()),
55438
55843
  context?.opencodeGeneration
55439
55844
  );
55440
55845
  const repository = host === "pi" ? void 0 : await prepareCliLoginStore(
55441
- resolve23(getStoragePath()),
55846
+ resolve24(getStoragePath()),
55442
55847
  context?.opencodeGeneration
55443
55848
  );
55444
55849
  try {
@@ -55454,7 +55859,7 @@ function createDefaultCliDependencies() {
55454
55859
  }
55455
55860
  if (host === "opencode") await assertSetupHostsStopped();
55456
55861
  await assertLocalOpenCodeLogin(
55457
- resolve23(accountFileForVault()),
55862
+ resolve24(accountFileForVault()),
55458
55863
  context?.opencodeGeneration
55459
55864
  );
55460
55865
  await persistCliStoreLogin(
@@ -55474,7 +55879,7 @@ function createDefaultCliDependencies() {
55474
55879
  };
55475
55880
  }
55476
55881
  async function prepareCliLoginStore(legacyPath, generation) {
55477
- await assertLocalOpenCodeLogin(resolve23(accountFileForVault()), generation);
55882
+ await assertLocalOpenCodeLogin(resolve24(accountFileForVault()), generation);
55478
55883
  const modules = await loadCommonAuthStoreModules();
55479
55884
  const options = {
55480
55885
  legacyPath,
@@ -55599,7 +56004,7 @@ async function readAccountStore(legacyPath) {
55599
56004
  function createDefaultAccountStoreOperations() {
55600
56005
  const offline = { processesStopped: true };
55601
56006
  return {
55602
- legacyPath: () => resolve23(
56007
+ legacyPath: () => resolve24(
55603
56008
  decidedAccountStoreAnchor(runtimeLayoutLocation()) ? getStoragePath() : discoveredAccountFile()
55604
56009
  ),
55605
56010
  migrate: async (legacyPath) => createAccountMigrationFactory(await loadCommonAuthStoreModules())({
@@ -55630,7 +56035,7 @@ function createDefaultAccountStoreOperations() {
55630
56035
  };
55631
56036
  }
55632
56037
  function samePath(left, right) {
55633
- return process.platform === "win32" ? resolve23(left).toLowerCase() === resolve23(right).toLowerCase() : resolve23(left) === resolve23(right);
56038
+ return process.platform === "win32" ? resolve24(left).toLowerCase() === resolve24(right).toLowerCase() : resolve24(left) === resolve24(right);
55634
56039
  }
55635
56040
  function isCliEntry() {
55636
56041
  if (import.meta.main !== void 0) return import.meta.main;
@@ -56120,16 +56525,16 @@ function isTuiConnected(sessionId) {
56120
56525
  // src/rpc/rpc-dir.ts
56121
56526
  import { createHash as createHash19 } from "node:crypto";
56122
56527
  import { homedir as homedir13, tmpdir as tmpdir6 } from "node:os";
56123
- import { isAbsolute as isAbsolute4, join as join33, resolve as resolve24 } from "node:path";
56528
+ import { isAbsolute as isAbsolute4, join as join34, resolve as resolve25 } from "node:path";
56124
56529
  var RPC_DIR_ENV = "ANTIGRAVITY_AUTH_RPC_DIR";
56125
56530
  function getRpcDir(projectDirectory) {
56126
56531
  const override = process.env[RPC_DIR_ENV]?.trim();
56127
56532
  if (override) {
56128
- return isAbsolute4(override) ? override : resolve24(projectDirectory, override);
56533
+ return isAbsolute4(override) ? override : resolve25(projectDirectory, override);
56129
56534
  }
56130
- const projectHash = createHash19("sha256").update(resolve24(projectDirectory)).digest("hex").slice(0, 16);
56131
- const stateHome = process.env.XDG_STATE_HOME ?? join33(homedir13(), ".local", "state");
56132
- return join33(stateHome, "cortexkit", "antigravity-auth", "rpc", projectHash);
56535
+ const projectHash = createHash19("sha256").update(resolve25(projectDirectory)).digest("hex").slice(0, 16);
56536
+ const stateHome = process.env.XDG_STATE_HOME ?? join34(homedir13(), ".local", "state");
56537
+ return join34(stateHome, "cortexkit", "antigravity-auth", "rpc", projectHash);
56133
56538
  }
56134
56539
 
56135
56540
  // src/common-auth-embedded/rpc/notifications.js
@@ -56141,7 +56546,7 @@ function isSessionId(value) {
56141
56546
  init_private_files2();
56142
56547
  import { createHash as createHash20, randomUUID as randomUUID21 } from "node:crypto";
56143
56548
  import { chmod as chmod7, mkdir as mkdir17, open as open12, readdir as readdir4, rename as rename14, rmdir as rmdir3, stat as stat14, unlink as unlink12 } from "node:fs/promises";
56144
- import { join as join34, resolve as resolve25 } from "node:path";
56549
+ import { join as join35, resolve as resolve26 } from "node:path";
56145
56550
  function isProbeablePid(pid) {
56146
56551
  return typeof pid === "number" && Number.isSafeInteger(pid) && pid > 0;
56147
56552
  }
@@ -56172,7 +56577,7 @@ async function removeCorruptPortFile(portFile, log16) {
56172
56577
  }
56173
56578
  async function writePortFile(dir, entry, options = {}) {
56174
56579
  const writeOnce = async () => {
56175
- const target = join34(dir, `port-${entry.pid}.json`);
56580
+ const target = join35(dir, `port-${entry.pid}.json`);
56176
56581
  if (windowsPrivateFiles2) {
56177
56582
  await ensurePrivateDirectory2(dir, options.secureDir ?? false);
56178
56583
  await options.beforeWrite?.();
@@ -56228,12 +56633,12 @@ async function sweepRpcState(root, activeDir, isManagedDir, log16) {
56228
56633
  return;
56229
56634
  throw error;
56230
56635
  }
56231
- const active2 = resolve25(activeDir);
56636
+ const active2 = resolve26(activeDir);
56232
56637
  for (const projectDir of projectDirs) {
56233
56638
  if (!projectDir.isDirectory() || !isManagedDir(projectDir.name)) {
56234
56639
  continue;
56235
56640
  }
56236
- const dir = join34(root, projectDir.name);
56641
+ const dir = join35(root, projectDir.name);
56237
56642
  let names;
56238
56643
  try {
56239
56644
  names = await readdir4(dir);
@@ -56245,7 +56650,7 @@ async function sweepRpcState(root, activeDir, isManagedDir, log16) {
56245
56650
  for (const name of names) {
56246
56651
  if (!name.startsWith("port-") || !name.endsWith(".json"))
56247
56652
  continue;
56248
- const portFile = join34(dir, name);
56653
+ const portFile = join35(dir, name);
56249
56654
  let raw;
56250
56655
  try {
56251
56656
  raw = await readPrivateText2(portFile);
@@ -56272,7 +56677,7 @@ async function sweepRpcState(root, activeDir, isManagedDir, log16) {
56272
56677
  await unlink12(portFile).catch(() => {
56273
56678
  });
56274
56679
  }
56275
- if (resolve25(dir) !== active2)
56680
+ if (resolve26(dir) !== active2)
56276
56681
  await rmdir3(dir).catch(() => {
56277
56682
  });
56278
56683
  }
@@ -56286,7 +56691,7 @@ init_private_files2();
56286
56691
  import { randomBytes as randomBytes7, timingSafeEqual } from "node:crypto";
56287
56692
  import { unlink as unlink13 } from "node:fs/promises";
56288
56693
  import { createServer as createServer3 } from "node:http";
56289
- import { join as join35 } from "node:path";
56694
+ import { join as join36 } from "node:path";
56290
56695
  var RpcRequestError = class extends Error {
56291
56696
  status;
56292
56697
  constructor(status, message) {
@@ -56306,7 +56711,7 @@ var BodyTooLargeError = class extends Error {
56306
56711
  }
56307
56712
  };
56308
56713
  function readBody(req) {
56309
- return new Promise((resolve27, reject) => {
56714
+ return new Promise((resolve28, reject) => {
56310
56715
  const tooLarge = (declaredOversize = false) => {
56311
56716
  req.removeAllListeners("data");
56312
56717
  req.on("data", () => {
@@ -56329,7 +56734,7 @@ function readBody(req) {
56329
56734
  }
56330
56735
  chunks.push(chunk);
56331
56736
  });
56332
- req.on("end", () => resolve27(Buffer.concat(chunks).toString("utf8")));
56737
+ req.on("end", () => resolve28(Buffer.concat(chunks).toString("utf8")));
56333
56738
  req.on("error", reject);
56334
56739
  });
56335
56740
  }
@@ -56508,12 +56913,12 @@ async function startRpcServer(options) {
56508
56913
  json(500, { error: "internal error" });
56509
56914
  }
56510
56915
  }
56511
- const port = await new Promise((resolve27, reject) => {
56916
+ const port = await new Promise((resolve28, reject) => {
56512
56917
  server.on("error", reject);
56513
56918
  server.listen(0, "127.0.0.1", () => {
56514
56919
  const addr = server.address();
56515
56920
  if (addr && typeof addr === "object")
56516
- resolve27(addr.port);
56921
+ resolve28(addr.port);
56517
56922
  else
56518
56923
  reject(new Error("no port"));
56519
56924
  });
@@ -56536,20 +56941,20 @@ async function startRpcServer(options) {
56536
56941
  rpcPort: port
56537
56942
  });
56538
56943
  } catch (error) {
56539
- await new Promise((resolve27) => server.close(() => resolve27()));
56944
+ await new Promise((resolve28) => server.close(() => resolve28()));
56540
56945
  throw error;
56541
56946
  }
56542
56947
  return {
56543
56948
  port,
56544
56949
  token,
56545
56950
  async stop() {
56546
- await new Promise((resolve27) => {
56951
+ await new Promise((resolve28) => {
56547
56952
  server.closeAllConnections?.();
56548
- server.close(() => resolve27());
56953
+ server.close(() => resolve28());
56549
56954
  for (const socket of connections)
56550
56955
  socket.destroy();
56551
56956
  });
56552
- const portFile = join35(options.dir, `port-${process.pid}.json`);
56957
+ const portFile = join36(options.dir, `port-${process.pid}.json`);
56553
56958
  const current = await readPrivateText2(portFile).then((raw) => JSON.parse(raw)).catch((error) => {
56554
56959
  if (error instanceof PrivateFileError2 && error.code !== "ENOENT")
56555
56960
  throw error;
@@ -56869,7 +57274,7 @@ import { createInterface as createInterface2 } from "node:readline/promises";
56869
57274
  // src/plugin/config/updater.ts
56870
57275
  import { existsSync as existsSync15, mkdirSync as mkdirSync8, readFileSync as readFileSync13, writeFileSync as writeFileSync8 } from "node:fs";
56871
57276
  import { homedir as homedir14 } from "node:os";
56872
- import { dirname as dirname25, join as join36 } from "node:path";
57277
+ import { dirname as dirname25, join as join37 } from "node:path";
56873
57278
 
56874
57279
  // src/plugin/model-registry.ts
56875
57280
  init_dist();
@@ -56886,13 +57291,13 @@ function stripJsonCommentsAndTrailingCommas(json) {
56886
57291
  ).replace(/,(\s*[}\]])/g, "$1");
56887
57292
  }
56888
57293
  function getOpencodeConfigDir() {
56889
- const xdgConfig2 = process.env.XDG_CONFIG_HOME || join36(homedir14(), ".config");
56890
- return join36(xdgConfig2, "opencode");
57294
+ const xdgConfig2 = process.env.XDG_CONFIG_HOME || join37(homedir14(), ".config");
57295
+ return join37(xdgConfig2, "opencode");
56891
57296
  }
56892
57297
  function getOpencodeConfigPath() {
56893
57298
  const configDir = getOpencodeConfigDir();
56894
- const jsoncPath = join36(configDir, OPENCODE_JSONC_FILENAME);
56895
- const jsonPath = join36(configDir, OPENCODE_JSON_FILENAME);
57299
+ const jsoncPath = join37(configDir, OPENCODE_JSONC_FILENAME);
57300
+ const jsonPath = join37(configDir, OPENCODE_JSON_FILENAME);
56896
57301
  if (existsSync15(jsoncPath)) {
56897
57302
  return jsoncPath;
56898
57303
  }
@@ -57151,7 +57556,7 @@ async function select3(items, options) {
57151
57556
  }
57152
57557
  renderedLines = linesWritten;
57153
57558
  };
57154
- return new Promise((resolve27) => {
57559
+ return new Promise((resolve28) => {
57155
57560
  const wasRaw = stdin.isRaw ?? false;
57156
57561
  const cleanup2 = () => {
57157
57562
  if (isCleanedUp) return;
@@ -57172,11 +57577,11 @@ async function select3(items, options) {
57172
57577
  };
57173
57578
  const onSignal = () => {
57174
57579
  cleanup2();
57175
- resolve27(null);
57580
+ resolve28(null);
57176
57581
  };
57177
57582
  const finishWithValue = (value) => {
57178
57583
  cleanup2();
57179
- resolve27(value);
57584
+ resolve28(value);
57180
57585
  };
57181
57586
  const findNextSelectable = (from, direction) => {
57182
57587
  if (items.length === 0) return from;
@@ -57222,7 +57627,7 @@ async function select3(items, options) {
57222
57627
  stdin.setRawMode(true);
57223
57628
  } catch {
57224
57629
  cleanup2();
57225
- resolve27(null);
57630
+ resolve28(null);
57226
57631
  return;
57227
57632
  }
57228
57633
  stdin.resume();
@@ -60189,15 +60594,15 @@ init_debug();
60189
60594
  // src/plugin/dependencies.ts
60190
60595
  init_dist();
60191
60596
  import { homedir as homedir15 } from "node:os";
60192
- import { join as join37 } from "node:path";
60597
+ import { join as join38 } from "node:path";
60193
60598
  function defaultFilesystemRoots() {
60194
- const xdgConfig2 = process.env.XDG_CONFIG_HOME ?? join37(homedir15(), ".config");
60195
- const xdgState2 = process.env.XDG_STATE_HOME ?? join37(homedir15(), ".local", "state");
60599
+ const xdgConfig2 = process.env.XDG_CONFIG_HOME ?? join38(homedir15(), ".config");
60600
+ const xdgState2 = process.env.XDG_STATE_HOME ?? join38(homedir15(), ".local", "state");
60196
60601
  return {
60197
60602
  projectRoot: process.cwd(),
60198
- userConfigRoot: join37(xdgConfig2, "opencode"),
60199
- sidebarStateRoot: join37(xdgState2, "cortexkit", "antigravity-auth"),
60200
- rpcRoot: join37(xdgState2, "cortexkit", "antigravity-auth", "rpc")
60603
+ userConfigRoot: join38(xdgConfig2, "opencode"),
60604
+ sidebarStateRoot: join38(xdgState2, "cortexkit", "antigravity-auth"),
60605
+ rpcRoot: join38(xdgState2, "cortexkit", "antigravity-auth", "rpc")
60201
60606
  };
60202
60607
  }
60203
60608
  function resolvePluginDependencies(overrides = {}) {
@@ -60226,10 +60631,10 @@ function resolvePluginDependencies(overrides = {}) {
60226
60631
  }
60227
60632
  async function defaultSleep(ms, signal) {
60228
60633
  if (ms <= 0) return;
60229
- await new Promise((resolve27, reject) => {
60634
+ await new Promise((resolve28, reject) => {
60230
60635
  const timer = setTimeout(() => {
60231
60636
  signal?.removeEventListener("abort", onAbort);
60232
- resolve27();
60637
+ resolve28();
60233
60638
  }, ms);
60234
60639
  timer.unref?.();
60235
60640
  const onAbort = () => {
@@ -60949,8 +61354,8 @@ function createPluginLifecycle(options) {
60949
61354
  };
60950
61355
  let failDisposal = () => {
60951
61356
  };
60952
- disposal = new Promise((resolve27, reject) => {
60953
- finishDisposal = resolve27;
61357
+ disposal = new Promise((resolve28, reject) => {
61358
+ finishDisposal = resolve28;
60954
61359
  failDisposal = reject;
60955
61360
  });
60956
61361
  void (async () => {
@@ -61099,7 +61504,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
61099
61504
  await drainSidebarWrites();
61100
61505
  }
61101
61506
  });
61102
- const accountFile = resolve26(accountFileForVault());
61507
+ const accountFile = resolve27(accountFileForVault());
61103
61508
  const vaultFolder = await prepareVaultFolder({ accountFile });
61104
61509
  const unavailableMessage = vaultFolder.refusal?.message ?? VAULT_ACCOUNT_REMEDY;
61105
61510
  let vaultQuotaPoller;
@@ -61322,7 +61727,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
61322
61727
  lifecycle.register(vaultQuotaPoller, "producer");
61323
61728
  }
61324
61729
  const operatorSettings = createOperatorSettingsController({
61325
- projectConfigPath: join38(directory, ".opencode", "antigravity.json"),
61730
+ projectConfigPath: join39(directory, ".opencode", "antigravity.json"),
61326
61731
  // getUserConfigPath() already returns the full file path including
61327
61732
  // 'antigravity.json' — do NOT join again or the path double-nests
61328
61733
  // into <dir>/antigravity.json/antigravity.json.
@@ -61762,6 +62167,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
61762
62167
  );
61763
62168
  },
61764
62169
  "command.execute.before": commandExecuteBefore,
62170
+ "chat.headers": createVaultRoutingHeaders(providerId),
61765
62171
  event,
61766
62172
  tool: { google_search: googleSearchTool },
61767
62173
  auth: {