@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/index.js CHANGED
@@ -7751,7 +7751,7 @@ async function rmEvictingDir(evictingPath) {
7751
7751
  });
7752
7752
  }
7753
7753
  async function sleep(ms) {
7754
- await new Promise((resolve26) => setTimeout(resolve26, ms));
7754
+ await new Promise((resolve27) => setTimeout(resolve27, 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((resolve26) => {
7871
- lostResolve = resolve26;
7870
+ let lostPromise = new Promise((resolve27) => {
7871
+ lostResolve = resolve27;
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 resolve26 = lostResolve;
7881
+ const resolve27 = lostResolve;
7882
7882
  lostResolve = null;
7883
- resolve26?.();
7883
+ resolve27?.();
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((resolve26) => setTimeout(resolve26, ms));
8506
+ const sleep5 = (ms) => new Promise((resolve27) => setTimeout(resolve27, 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((resolve26) => setTimeout(resolve26, ms));
8554
+ DEFAULT_SLEEP = (ms) => new Promise((resolve27) => setTimeout(resolve27, 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((resolve26, reject) => {
9757
- this.savePromiseResolvers.push({ resolve: resolve26, reject });
9756
+ return new Promise((resolve27, reject) => {
9757
+ this.savePromiseResolvers.push({ resolve: resolve27, 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: resolve26 } of resolvers)
9801
- resolve26();
9800
+ for (const { resolve: resolve27 } of resolvers)
9801
+ resolve27();
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: resolve26 } of resolvers) {
9816
- resolve26();
9815
+ for (const { resolve: resolve27 } of resolvers) {
9816
+ resolve27();
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: resolve26 } of resolvers) {
9824
- resolve26();
9823
+ for (const { resolve: resolve27 } of resolvers) {
9824
+ resolve27();
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((resolve26, reject) => {
10313
+ return new Promise((resolve27, 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(() => resolve26({ head, leftover }));
10336
+ cleanup2(() => resolve27({ 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((resolve26, reject) => {
10350
+ await new Promise((resolve27, 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
- resolve26();
10359
+ resolve27();
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((resolve26, reject) => {
10384
+ return await new Promise((resolve27, 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
- resolve26(tlsSocket);
10399
+ resolve27(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((resolve26, reject) => {
10408
+ return await new Promise((resolve27, 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
- resolve26(socket);
10424
+ resolve27(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((resolve26) => {
12498
- resolveLoss = resolve26;
12510
+ const lostPromise = new Promise((resolve27) => {
12511
+ resolveLoss = resolve27;
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((resolve26) => setTimeout(resolve26, Math.floor(Math.random() * 4)));
12672
+ await new Promise((resolve27) => setTimeout(resolve27, 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((resolve26) => setTimeout(resolve26, Math.min(delayMs, remainingMs)));
13162
+ await new Promise((resolve27) => setTimeout(resolve27, 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((resolve26) => setTimeout(resolve26, Math.min(25, Math.ceil(remaining))));
13234
+ await new Promise((resolve27) => setTimeout(resolve27, 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((resolve26) => setTimeout(resolve26, Math.min(options.retryMs + jitter, remaining)));
13354
+ await new Promise((resolve27) => setTimeout(resolve27, 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((resolve26) => {
16625
+ await new Promise((resolve27) => {
16594
16626
  const done = () => {
16595
16627
  clearTimeout(timer);
16596
16628
  this.wake.delete(done);
16597
- resolve26();
16629
+ resolve27();
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((resolve26) => {
19400
+ return new Promise((resolve27) => {
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
- resolve26(value);
19420
+ resolve27(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
- resolve26(null);
19460
+ resolve27(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 shared3 = sources.get(key);
20402
20434
  if (!shared3) {
@@ -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((resolve26) => {
21508
+ new Promise((resolve27) => {
21477
21509
  timer = setTimeout(() => {
21478
21510
  expired = true;
21479
- resolve26();
21511
+ resolve27();
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((resolve26, reject) => {
23145
+ return new Promise((resolve27, 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
- resolve26(value);
23160
+ resolve27(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((resolve26, reject) => {
23935
+ return new Promise((resolve27, 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
- resolve26(value);
23940
+ resolve27(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((resolve26) => {
25967
- setTimeout(resolve26, ms);
25998
+ return new Promise((resolve27) => {
25999
+ setTimeout(resolve27, 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((resolve26, reject) => {
28321
+ return new Promise((resolve27, 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(resolve26, reject).finally(() => signal.removeEventListener("abort", abort));
28326
+ pending.then(resolve27, 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((resolve26) => {
30280
+ await new Promise((resolve27) => {
30245
30281
  const done = () => {
30246
30282
  clearTimeout(timer);
30247
30283
  cancelWait = void 0;
30248
- resolve26();
30284
+ resolve27();
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 project2 of projects.ok ? projects.names : []) {
31032
31068
  if (!isRpcProjectDir(project2)) continue;
31033
- const dir = join12(rpcRoot, project2);
31069
+ const dir = join13(rpcRoot, project2);
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, present5) {
@@ -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((resolve26) => {
33172
- current.once("close", () => resolve26());
33173
- current.once("error", () => resolve26());
33207
+ return new Promise((resolve27) => {
33208
+ current.once("close", () => resolve27());
33209
+ current.once("error", () => resolve27());
33174
33210
  try {
33175
33211
  current.end();
33176
33212
  } catch {
33177
- resolve26();
33213
+ resolve27();
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((resolve26) => {
33443
- current.once("close", () => resolve26());
33444
- current.once("error", () => resolve26());
33478
+ return new Promise((resolve27) => {
33479
+ current.once("close", () => resolve27());
33480
+ current.once("error", () => resolve27());
33445
33481
  try {
33446
33482
  current.end();
33447
33483
  } catch {
33448
- resolve26();
33484
+ resolve27();
33449
33485
  }
33450
33486
  });
33451
33487
  }
@@ -33656,13 +33692,13 @@ var init_logger4 = __esm({
33656
33692
  // src/plugin/index.ts
33657
33693
  init_dist();
33658
33694
  import { createHash as createHash23, randomUUID as randomUUID21 } from "node:crypto";
33659
- import { join as join38, resolve as resolve25 } from "node:path";
33695
+ import { join as join39, resolve as resolve26 } from "node:path";
33660
33696
 
33661
33697
  // src/cli.ts
33662
33698
  init_dist();
33663
33699
  import { execFile } from "node:child_process";
33664
33700
  import { realpathSync as realpathSync4 } from "node:fs";
33665
- import { resolve as resolve20 } from "node:path";
33701
+ import { resolve as resolve21 } from "node:path";
33666
33702
  import { createInterface } from "node:readline/promises";
33667
33703
  import { fileURLToPath as fileURLToPath2 } from "node:url";
33668
33704
  import { promisify } from "node:util";
@@ -33904,7 +33940,7 @@ init_atomic_write();
33904
33940
  init_file_lock();
33905
33941
  import { chmodSync as chmodSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync3 } from "node:fs";
33906
33942
  import { homedir as homedir6 } from "node:os";
33907
- import { dirname as dirname18, join as join17 } from "node:path";
33943
+ import { dirname as dirname18, join as join18 } from "node:path";
33908
33944
 
33909
33945
  // ../../node_modules/.bun/xdg-basedir@5.1.0/node_modules/xdg-basedir/index.js
33910
33946
  import os from "os";
@@ -33963,8 +33999,8 @@ async function emitMergeStep(step) {
33963
33999
  function getSidebarStateFile() {
33964
34000
  const override = process.env[SIDEBAR_STATE_ENV];
33965
34001
  if (override && override.trim().length > 0) return override;
33966
- const base = xdgState ?? join17(homedir6(), ".local", "state");
33967
- return join17(base, SIDEBAR_STATE_DIR, SIDEBAR_STATE_FILENAME);
34002
+ const base = xdgState ?? join18(homedir6(), ".local", "state");
34003
+ return join18(base, SIDEBAR_STATE_DIR, SIDEBAR_STATE_FILENAME);
33968
34004
  }
33969
34005
  function readSidebarState(path5 = getSidebarStateFile()) {
33970
34006
  let raw;
@@ -34313,7 +34349,7 @@ function drainSidebarWrites() {
34313
34349
  return sidebarWriteChain;
34314
34350
  }
34315
34351
  async function sleep3(ms) {
34316
- await new Promise((resolve26) => setTimeout(resolve26, ms));
34352
+ await new Promise((resolve27) => setTimeout(resolve27, ms));
34317
34353
  }
34318
34354
  async function acquireSidebarLockWithRetry(stateFile) {
34319
34355
  const start = Date.now();
@@ -35165,14 +35201,14 @@ var LocalQuotaGrantStaleError = class extends Error {
35165
35201
  name = "LocalQuotaGrantStaleError";
35166
35202
  };
35167
35203
  function untilQuotaAborted(pending, signal) {
35168
- return new Promise((resolve26, reject) => {
35204
+ return new Promise((resolve27, reject) => {
35169
35205
  const abort = () => reject(signal.reason);
35170
35206
  if (signal.aborted) abort();
35171
35207
  else signal.addEventListener("abort", abort, { once: true });
35172
35208
  void pending.then(
35173
35209
  (value) => {
35174
35210
  signal.removeEventListener("abort", abort);
35175
- resolve26(value);
35211
+ resolve27(value);
35176
35212
  },
35177
35213
  (error) => {
35178
35214
  signal.removeEventListener("abort", abort);
@@ -35793,12 +35829,12 @@ async function startOAuthListener({
35793
35829
  let resolveCallback;
35794
35830
  let rejectCallback;
35795
35831
  let timeoutHandle;
35796
- const callbackPromise = new Promise((resolve26, reject) => {
35832
+ const callbackPromise = new Promise((resolve27, reject) => {
35797
35833
  resolveCallback = (url) => {
35798
35834
  if (settled) return;
35799
35835
  settled = true;
35800
35836
  if (timeoutHandle) clearTimeout(timeoutHandle);
35801
- resolve26(url);
35837
+ resolve27(url);
35802
35838
  };
35803
35839
  rejectCallback = (error) => {
35804
35840
  if (settled) return;
@@ -35957,7 +35993,7 @@ async function startOAuthListener({
35957
35993
  });
35958
35994
  });
35959
35995
  const bindAddress = getBindAddress();
35960
- await new Promise((resolve26, reject) => {
35996
+ await new Promise((resolve27, reject) => {
35961
35997
  const handleError = (error) => {
35962
35998
  server.off("error", handleError);
35963
35999
  if (error.code === "EADDRINUSE") {
@@ -35973,7 +36009,7 @@ async function startOAuthListener({
35973
36009
  server.once("error", handleError);
35974
36010
  server.listen(port, bindAddress, () => {
35975
36011
  server.off("error", handleError);
35976
- resolve26();
36012
+ resolve27();
35977
36013
  });
35978
36014
  });
35979
36015
  server.on("error", (error) => {
@@ -35981,7 +36017,7 @@ async function startOAuthListener({
35981
36017
  });
35982
36018
  return {
35983
36019
  waitForCallback: () => callbackPromise,
35984
- close: () => new Promise((resolve26, reject) => {
36020
+ close: () => new Promise((resolve27, reject) => {
35985
36021
  server.close((error) => {
35986
36022
  if (error && error.code !== "ERR_SERVER_NOT_RUNNING") {
35987
36023
  reject(error);
@@ -35990,7 +36026,7 @@ async function startOAuthListener({
35990
36026
  if (!settled) {
35991
36027
  rejectCallback(new Error("OAuth listener closed before callback"));
35992
36028
  }
35993
- resolve26();
36029
+ resolve27();
35994
36030
  });
35995
36031
  })
35996
36032
  };
@@ -36009,7 +36045,7 @@ init_runtime_paths();
36009
36045
  // src/setup.ts
36010
36046
  init_dist();
36011
36047
  import { lstat as lstat9, readFile as readFile16 } from "node:fs/promises";
36012
- import { join as join23, resolve as resolve19 } from "node:path";
36048
+ import { join as join24, resolve as resolve20 } from "node:path";
36013
36049
 
36014
36050
  // src/auth-method-labels.ts
36015
36051
  var OPENCODE2_POOL_AUTH_LABEL = "Google (antigravity-auth pool, browser)";
@@ -36181,7 +36217,7 @@ async function select2(terminal, items, options) {
36181
36217
  writeLine("");
36182
36218
  renderedLines = lines;
36183
36219
  };
36184
- return new Promise((resolve26) => {
36220
+ return new Promise((resolve27) => {
36185
36221
  const wasRaw = stdin.isRaw ?? false;
36186
36222
  const cleanup2 = () => {
36187
36223
  if (cleaned)
@@ -36201,7 +36237,7 @@ async function select2(terminal, items, options) {
36201
36237
  };
36202
36238
  const finish = (value) => {
36203
36239
  cleanup2();
36204
- resolve26(value);
36240
+ resolve27(value);
36205
36241
  };
36206
36242
  const onSignal = () => finish(null);
36207
36243
  const onKey = (data) => {
@@ -36241,7 +36277,7 @@ async function select2(terminal, items, options) {
36241
36277
  stdin.setRawMode(true);
36242
36278
  } catch {
36243
36279
  cleanup2();
36244
- resolve26(null);
36280
+ resolve27(null);
36245
36281
  return;
36246
36282
  }
36247
36283
  stdin.resume();
@@ -36255,12 +36291,12 @@ async function select2(terminal, items, options) {
36255
36291
  import { createHash as createHash13, randomBytes as randomBytes5, randomUUID as randomUUID17 } from "node:crypto";
36256
36292
  import { constants as fsConstants2 } from "node:fs";
36257
36293
  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";
36258
- import { basename as basename5, dirname as dirname20, extname as extname2, isAbsolute as isAbsolute3, join as join19, resolve as resolve18 } from "node:path";
36294
+ import { basename as basename5, dirname as dirname20, extname as extname2, isAbsolute as isAbsolute3, join as join20, resolve as resolve19 } from "node:path";
36259
36295
  import { ClaustrumCredentialError as ClaustrumCredentialError5, ClaustrumClient as ClaustrumWireClient2, writeEnrollmentTokenFile as writeEnrollmentTokenFile2 } from "@cortexkit/claustrum-client";
36260
36296
 
36261
36297
  // src/common-auth-embedded/fs/file-read-cache.js
36262
36298
  import { lstat as lstat7 } from "node:fs/promises";
36263
- import { resolve as resolve17 } from "node:path";
36299
+ import { resolve as resolve18 } from "node:path";
36264
36300
  async function identity2(path5) {
36265
36301
  try {
36266
36302
  const metadata = await lstat7(path5);
@@ -36277,7 +36313,7 @@ function sameIdentity2(left, right) {
36277
36313
  var FileReadCache2 = class {
36278
36314
  #entries = /* @__PURE__ */ new Map();
36279
36315
  async read(paths, read, validateHit) {
36280
- const resolvedPaths = paths.map((path5) => resolve17(path5));
36316
+ const resolvedPaths = paths.map((path5) => resolve18(path5));
36281
36317
  const key = JSON.stringify(resolvedPaths);
36282
36318
  const probed = await Promise.all(resolvedPaths.map(identity2));
36283
36319
  const identities = probed.every((entry) => entry !== void 0) ? probed : void 0;
@@ -36329,9 +36365,10 @@ init_private_files2();
36329
36365
  init_private_files2();
36330
36366
  import { randomUUID as randomUUID16 } from "node:crypto";
36331
36367
  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";
36332
- import { dirname as dirname19, join as join18 } from "node:path";
36368
+ import { dirname as dirname19, join as join19 } from "node:path";
36333
36369
 
36334
36370
  // src/common-auth-embedded/fs/with-lock.js
36371
+ init_private_files2();
36335
36372
  function lockPathFor2(target, name) {
36336
36373
  return `${target}.${name}.lock`;
36337
36374
  }
@@ -36389,7 +36426,7 @@ function acquireRefreshFileLock2(options) {
36389
36426
  }
36390
36427
  async function acquireRefreshFileLockWithClock2(options) {
36391
36428
  const lockPath = lockPathFor2(options.path, options.name);
36392
- const legacyOwnerPath = join18(lockPath, "owner.json");
36429
+ const legacyOwnerPath = join19(lockPath, "owner.json");
36393
36430
  const ownerId = randomUUID16();
36394
36431
  const now = options.now ?? Date.now;
36395
36432
  let renewTimer = null;
@@ -36397,8 +36434,8 @@ async function acquireRefreshFileLockWithClock2(options) {
36397
36434
  let releaseConfirmed = false;
36398
36435
  let loss;
36399
36436
  let resolveLoss;
36400
- const lostPromise = new Promise((resolve26) => {
36401
- resolveLoss = resolve26;
36437
+ const lostPromise = new Promise((resolve27) => {
36438
+ resolveLoss = resolve27;
36402
36439
  });
36403
36440
  function notifyTimerStep(event) {
36404
36441
  try {
@@ -36432,7 +36469,7 @@ async function acquireRefreshFileLockWithClock2(options) {
36432
36469
  let terminalIOError;
36433
36470
  let renewalInFlight = null;
36434
36471
  const evictPath = `${lockPath}.evicting`;
36435
- const evictOwnerPath = join18(evictPath, "owner.json");
36472
+ const evictOwnerPath = join19(evictPath, "owner.json");
36436
36473
  const evictOwnerId = randomUUID16();
36437
36474
  const EVICT_TTL = 5e3;
36438
36475
  const MAX_STEAL_ATTEMPTS = 8;
@@ -36559,7 +36596,7 @@ async function acquireRefreshFileLockWithClock2(options) {
36559
36596
  }
36560
36597
  }
36561
36598
  async function backoff() {
36562
- await new Promise((resolve26) => setTimeout(resolve26, Math.floor(Math.random() * 4)));
36599
+ await new Promise((resolve27) => setTimeout(resolve27, Math.floor(Math.random() * 4)));
36563
36600
  }
36564
36601
  async function readLockState(notifyReady = true) {
36565
36602
  if (notifyReady && options.onStep)
@@ -37049,7 +37086,7 @@ async function acquireRefreshFileLockWithClock2(options) {
37049
37086
  const remainingMs = deadline - performance.now();
37050
37087
  if (remainingMs <= 0)
37051
37088
  break;
37052
- await new Promise((resolve26) => setTimeout(resolve26, Math.min(delayMs, remainingMs)));
37089
+ await new Promise((resolve27) => setTimeout(resolve27, Math.min(delayMs, remainingMs)));
37053
37090
  delayMs = Math.min(delayMs * 2, 50);
37054
37091
  }
37055
37092
  if (windowsPrivateFiles2)
@@ -37114,7 +37151,7 @@ function getClaustrumEnrollmentPaths2(tokenPath) {
37114
37151
  const extension = extname2(tokenPath) || ".json";
37115
37152
  const stem = basename5(tokenPath, extname2(tokenPath));
37116
37153
  return {
37117
- statePath: join19(dirname20(tokenPath), `${stem}-state${extension}`),
37154
+ statePath: join20(dirname20(tokenPath), `${stem}-state${extension}`),
37118
37155
  tokenPath
37119
37156
  };
37120
37157
  }
@@ -37122,7 +37159,7 @@ function hostEnrollmentPaths2(input2) {
37122
37159
  const override = input2.override?.trim();
37123
37160
  if (override && !isAbsolute3(override) && !input2.cwd)
37124
37161
  throw new ClaustrumConsumerError2("invalid-state", "A relative Claustrum enrollment override needs a base directory");
37125
- const tokenPath = override ? isAbsolute3(override) ? override : resolve18(input2.cwd, override) : join19(input2.stateDir, `${input2.host}-enrollment.json`);
37162
+ const tokenPath = override ? isAbsolute3(override) ? override : resolve19(input2.cwd, override) : join20(input2.stateDir, `${input2.host}-enrollment.json`);
37126
37163
  return getClaustrumEnrollmentPaths2(tokenPath);
37127
37164
  }
37128
37165
  function isRecord11(value) {
@@ -37355,7 +37392,7 @@ async function writeStateAtomic2(path5, state, ancestorOptions = {}) {
37355
37392
  }
37356
37393
  if (windowsPrivateFiles2)
37357
37394
  return writePrivateAtomic2(path5, bytes);
37358
- const temporary = join19(parent, `.${basename5(path5)}.${process.pid}.${randomUUID17()}.tmp`);
37395
+ const temporary = join20(parent, `.${basename5(path5)}.${process.pid}.${randomUUID17()}.tmp`);
37359
37396
  let descriptor;
37360
37397
  let created = false;
37361
37398
  try {
@@ -37750,7 +37787,7 @@ var ByteTail = class {
37750
37787
  };
37751
37788
  var defaultCommandRunner = {
37752
37789
  run(file, args, options = {}) {
37753
- return new Promise((resolve26) => {
37790
+ return new Promise((resolve27) => {
37754
37791
  const started = performance.now();
37755
37792
  const timeoutMs = options.timeoutMs ?? 15e3;
37756
37793
  const stderr = new ByteTail();
@@ -37768,7 +37805,7 @@ var defaultCommandRunner = {
37768
37805
  stdio: ["ignore", "pipe", "pipe"]
37769
37806
  });
37770
37807
  } catch {
37771
- resolve26({
37808
+ resolve27({
37772
37809
  exitCode: 1,
37773
37810
  stdout: "",
37774
37811
  stderr: "",
@@ -37803,7 +37840,7 @@ var defaultCommandRunner = {
37803
37840
  settled = true;
37804
37841
  if (timer)
37805
37842
  clearTimeout(timer);
37806
- resolve26({
37843
+ resolve27({
37807
37844
  exitCode: spawnError ? 1 : outputExceeded ? 1 : code2 ?? 1,
37808
37845
  stdout: Buffer.concat(stdout, stdoutLength).toString("utf8"),
37809
37846
  stderr: stderr.toString(),
@@ -37890,7 +37927,7 @@ function recordSetupEnrollment(failure2, enrollment) {
37890
37927
  import { accessSync, constants as constants3, existsSync as existsSync6, readFileSync as readFileSync5, realpathSync as realpathSync3, statSync as statSync5 } from "node:fs";
37891
37928
  import { mkdtemp, rm as rm7 } from "node:fs/promises";
37892
37929
  import { tmpdir as tmpdir3 } from "node:os";
37893
- import { join as join20 } from "node:path";
37930
+ import { join as join21 } from "node:path";
37894
37931
  import { parse } from "jsonc-parser";
37895
37932
 
37896
37933
  // src/common-auth-embedded/setup/paths.js
@@ -38061,7 +38098,7 @@ async function detectHosts(plugin, io = {}) {
38061
38098
  return null;
38062
38099
  let root;
38063
38100
  try {
38064
- root = await mkdtemp(join20(tmpdir3(), "common-auth-setup-version-"));
38101
+ root = await mkdtemp(join21(tmpdir3(), "common-auth-setup-version-"));
38065
38102
  const probeEnv = {
38066
38103
  ...env3,
38067
38104
  HOME: root,
@@ -38646,7 +38683,7 @@ import { applyEdits, createScanner, findNodeAtLocation, modify, parse as parse2,
38646
38683
  // src/common-auth-embedded/setup/config-write.js
38647
38684
  import { randomUUID as randomUUID18 } from "node:crypto";
38648
38685
  import { mkdir as mkdir16, open as open11, rename as rename13, stat as stat13, unlink as unlink11 } from "node:fs/promises";
38649
- import { basename as basename6, dirname as dirname21, join as join21 } from "node:path";
38686
+ import { basename as basename6, dirname as dirname21, join as join22 } from "node:path";
38650
38687
  import { setTimeout as delay2 } from "node:timers/promises";
38651
38688
  async function writeHostConfigAtomic(file, content, options = {}) {
38652
38689
  const windows2 = (options.platform ?? process.platform) === "win32";
@@ -38661,7 +38698,7 @@ async function writeHostConfigAtomic(file, content, options = {}) {
38661
38698
  throw error;
38662
38699
  }
38663
38700
  }
38664
- const stage = join21(parent, `.${basename6(file)}.${(options.stageName ?? randomUUID18)()}.tmp`);
38701
+ const stage = join22(parent, `.${basename6(file)}.${(options.stageName ?? randomUUID18)()}.tmp`);
38665
38702
  let created = false;
38666
38703
  try {
38667
38704
  const handle = await open11(stage, "wx", mode ?? 438);
@@ -39081,11 +39118,11 @@ init_storage();
39081
39118
  init_dist();
39082
39119
  import { readFile as readFile15 } from "node:fs/promises";
39083
39120
  import { homedir as homedir8 } from "node:os";
39084
- import { join as join22 } from "node:path";
39121
+ import { join as join23 } from "node:path";
39085
39122
  var V1_VAULT_ACTIVATION_LABEL = "Activate approved Antigravity vault";
39086
39123
  function nativeOpenCodeAuthPath(env3 = process.env, home = homedir8()) {
39087
- return join22(
39088
- env3.XDG_DATA_HOME || join22(home, ".local", "share"),
39124
+ return join23(
39125
+ env3.XDG_DATA_HOME || join23(home, ".local", "share"),
39089
39126
  "opencode",
39090
39127
  "auth.json"
39091
39128
  );
@@ -39206,7 +39243,7 @@ function openCodeVaultDir(accountFile) {
39206
39243
  return folder.vaultDir;
39207
39244
  }
39208
39245
  function nativeAuthPath(host, context) {
39209
- return host === "opencode" ? nativeOpenCodeAuthPath() : join23(context.piAgentDir, "auth.json");
39246
+ return host === "opencode" ? nativeOpenCodeAuthPath() : join24(context.piAgentDir, "auth.json");
39210
39247
  }
39211
39248
  function provider(host) {
39212
39249
  return host === "opencode" ? OPENCODE_VAULT_PROVIDER : ANTIGRAVITY_PROVIDER_ID;
@@ -39262,7 +39299,7 @@ async function writeNativeSlot(host, slot, context, expectedAuthority = "local")
39262
39299
  beforeRename: async () => {
39263
39300
  await assertSetupHostsStopped();
39264
39301
  const claustrum = await loadCommonAuthClaustrum();
39265
- const stateDir = host === "opencode" ? openCodeVaultDir(resolve19(accountFileForVault())) : getPiAntigravityVaultDir();
39302
+ const stateDir = host === "opencode" ? openCodeVaultDir(resolve20(accountFileForVault())) : getPiAntigravityVaultDir();
39266
39303
  if (await claustrum.enrollmentAuthority(
39267
39304
  claustrum.hostEnrollmentPaths({ stateDir, host }),
39268
39305
  `antigravity-auth-${host}`
@@ -39300,7 +39337,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
39300
39337
  // `beforeSignIn`, which may move it after this plugin is built.
39301
39338
  paths: {
39302
39339
  get stateDir() {
39303
- return openCodeVaultDir(resolve19(accountFileForVault()));
39340
+ return openCodeVaultDir(resolve20(accountFileForVault()));
39304
39341
  },
39305
39342
  host: "opencode"
39306
39343
  }
@@ -39317,7 +39354,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
39317
39354
  const assertLocal = async (host, context) => {
39318
39355
  if (host === "opencode")
39319
39356
  return assertLocalOpenCodeLogin(
39320
- resolve19(accountFileForVault()),
39357
+ resolve20(accountFileForVault()),
39321
39358
  context.opencodeGeneration
39322
39359
  );
39323
39360
  if (await authority(host) !== "local")
@@ -39333,7 +39370,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
39333
39370
  const { openPiSlot: openPiSlot2 } = await loadCommonAuthPiSlot();
39334
39371
  if ((await openPiSlot2({
39335
39372
  authPath: nativeAuthPath(host, context),
39336
- stashPath: join23(piDir, "google-login-stash.json"),
39373
+ stashPath: join24(piDir, "google-login-stash.json"),
39337
39374
  provider: ANTIGRAVITY_PROVIDER_ID,
39338
39375
  placeholderKey: PI_PLACEHOLDER_KEY
39339
39376
  }).inspect()).slot === "placeholder")
@@ -39373,7 +39410,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
39373
39410
  const { openPiSlot: openPiSlot2 } = await loadCommonAuthPiSlot();
39374
39411
  const inspection = await openPiSlot2({
39375
39412
  authPath: nativeAuthPath("pi", context),
39376
- stashPath: join23(piDir, "google-login-stash.json"),
39413
+ stashPath: join24(piDir, "google-login-stash.json"),
39377
39414
  provider: ANTIGRAVITY_PROVIDER_ID,
39378
39415
  placeholderKey: PI_PLACEHOLDER_KEY
39379
39416
  }).inspect();
@@ -39492,7 +39529,7 @@ Setup has not completed the OpenCode 2 native Google connection.
39492
39529
  await assertSetupHostsStopped();
39493
39530
  await openPiSlot2({
39494
39531
  authPath: nativeAuthPath(host, context),
39495
- stashPath: join23(piDir, "google-login-stash.json"),
39532
+ stashPath: join24(piDir, "google-login-stash.json"),
39496
39533
  provider: ANTIGRAVITY_PROVIDER_ID,
39497
39534
  placeholderKey: PI_PLACEHOLDER_KEY
39498
39535
  }).enterVault();
@@ -39947,7 +39984,7 @@ async function runCliProcess(argv, deps) {
39947
39984
  ...deps,
39948
39985
  prepareVaultFolder: deps.prepareVaultFolder ?? (async (options) => {
39949
39986
  const folder = await prepareVaultFolder({
39950
- accountFile: resolve20(accountFileForVault()),
39987
+ accountFile: resolve21(accountFileForVault()),
39951
39988
  ...options
39952
39989
  });
39953
39990
  if (folder.refusal) throw folder.refusal;
@@ -39993,11 +40030,11 @@ function createDefaultCliDependencies() {
39993
40030
  );
39994
40031
  if (host !== "pi")
39995
40032
  await assertLocalOpenCodeLogin(
39996
- resolve20(accountFileForVault()),
40033
+ resolve21(accountFileForVault()),
39997
40034
  context?.opencodeGeneration
39998
40035
  );
39999
40036
  const repository = host === "pi" ? void 0 : await prepareCliLoginStore(
40000
- resolve20(getStoragePath()),
40037
+ resolve21(getStoragePath()),
40001
40038
  context?.opencodeGeneration
40002
40039
  );
40003
40040
  try {
@@ -40013,7 +40050,7 @@ function createDefaultCliDependencies() {
40013
40050
  }
40014
40051
  if (host === "opencode") await assertSetupHostsStopped();
40015
40052
  await assertLocalOpenCodeLogin(
40016
- resolve20(accountFileForVault()),
40053
+ resolve21(accountFileForVault()),
40017
40054
  context?.opencodeGeneration
40018
40055
  );
40019
40056
  await persistCliStoreLogin(
@@ -40033,7 +40070,7 @@ function createDefaultCliDependencies() {
40033
40070
  };
40034
40071
  }
40035
40072
  async function prepareCliLoginStore(legacyPath, generation) {
40036
- await assertLocalOpenCodeLogin(resolve20(accountFileForVault()), generation);
40073
+ await assertLocalOpenCodeLogin(resolve21(accountFileForVault()), generation);
40037
40074
  const modules = await loadCommonAuthStoreModules();
40038
40075
  const options = {
40039
40076
  legacyPath,
@@ -40158,7 +40195,7 @@ async function readAccountStore(legacyPath) {
40158
40195
  function createDefaultAccountStoreOperations() {
40159
40196
  const offline = { processesStopped: true };
40160
40197
  return {
40161
- legacyPath: () => resolve20(
40198
+ legacyPath: () => resolve21(
40162
40199
  decidedAccountStoreAnchor(runtimeLayoutLocation()) ? getStoragePath() : discoveredAccountFile()
40163
40200
  ),
40164
40201
  migrate: async (legacyPath) => createAccountMigrationFactory(await loadCommonAuthStoreModules())({
@@ -40189,7 +40226,7 @@ function createDefaultAccountStoreOperations() {
40189
40226
  };
40190
40227
  }
40191
40228
  function samePath(left, right) {
40192
- return process.platform === "win32" ? resolve20(left).toLowerCase() === resolve20(right).toLowerCase() : resolve20(left) === resolve20(right);
40229
+ return process.platform === "win32" ? resolve21(left).toLowerCase() === resolve21(right).toLowerCase() : resolve21(left) === resolve21(right);
40193
40230
  }
40194
40231
  function isCliEntry() {
40195
40232
  if (import.meta.main !== void 0) return import.meta.main;
@@ -40679,16 +40716,16 @@ function isTuiConnected(sessionId) {
40679
40716
  // src/rpc/rpc-dir.ts
40680
40717
  import { createHash as createHash14 } from "node:crypto";
40681
40718
  import { homedir as homedir10, tmpdir as tmpdir4 } from "node:os";
40682
- import { isAbsolute as isAbsolute4, join as join27, resolve as resolve21 } from "node:path";
40719
+ import { isAbsolute as isAbsolute4, join as join28, resolve as resolve22 } from "node:path";
40683
40720
  var RPC_DIR_ENV = "ANTIGRAVITY_AUTH_RPC_DIR";
40684
40721
  function getRpcDir(projectDirectory) {
40685
40722
  const override = process.env[RPC_DIR_ENV]?.trim();
40686
40723
  if (override) {
40687
- return isAbsolute4(override) ? override : resolve21(projectDirectory, override);
40724
+ return isAbsolute4(override) ? override : resolve22(projectDirectory, override);
40688
40725
  }
40689
- const projectHash = createHash14("sha256").update(resolve21(projectDirectory)).digest("hex").slice(0, 16);
40690
- const stateHome = process.env.XDG_STATE_HOME ?? join27(homedir10(), ".local", "state");
40691
- return join27(stateHome, "cortexkit", "antigravity-auth", "rpc", projectHash);
40726
+ const projectHash = createHash14("sha256").update(resolve22(projectDirectory)).digest("hex").slice(0, 16);
40727
+ const stateHome = process.env.XDG_STATE_HOME ?? join28(homedir10(), ".local", "state");
40728
+ return join28(stateHome, "cortexkit", "antigravity-auth", "rpc", projectHash);
40692
40729
  }
40693
40730
 
40694
40731
  // src/common-auth-embedded/rpc/notifications.js
@@ -40700,7 +40737,7 @@ function isSessionId(value) {
40700
40737
  init_private_files2();
40701
40738
  import { createHash as createHash15, randomUUID as randomUUID19 } from "node:crypto";
40702
40739
  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";
40703
- import { join as join28, resolve as resolve22 } from "node:path";
40740
+ import { join as join29, resolve as resolve23 } from "node:path";
40704
40741
  function isProbeablePid(pid) {
40705
40742
  return typeof pid === "number" && Number.isSafeInteger(pid) && pid > 0;
40706
40743
  }
@@ -40731,7 +40768,7 @@ async function removeCorruptPortFile(portFile, log16) {
40731
40768
  }
40732
40769
  async function writePortFile(dir, entry, options = {}) {
40733
40770
  const writeOnce = async () => {
40734
- const target = join28(dir, `port-${entry.pid}.json`);
40771
+ const target = join29(dir, `port-${entry.pid}.json`);
40735
40772
  if (windowsPrivateFiles2) {
40736
40773
  await ensurePrivateDirectory2(dir, options.secureDir ?? false);
40737
40774
  await options.beforeWrite?.();
@@ -40787,12 +40824,12 @@ async function sweepRpcState(root, activeDir, isManagedDir, log16) {
40787
40824
  return;
40788
40825
  throw error;
40789
40826
  }
40790
- const active2 = resolve22(activeDir);
40827
+ const active2 = resolve23(activeDir);
40791
40828
  for (const projectDir of projectDirs) {
40792
40829
  if (!projectDir.isDirectory() || !isManagedDir(projectDir.name)) {
40793
40830
  continue;
40794
40831
  }
40795
- const dir = join28(root, projectDir.name);
40832
+ const dir = join29(root, projectDir.name);
40796
40833
  let names;
40797
40834
  try {
40798
40835
  names = await readdir4(dir);
@@ -40804,7 +40841,7 @@ async function sweepRpcState(root, activeDir, isManagedDir, log16) {
40804
40841
  for (const name of names) {
40805
40842
  if (!name.startsWith("port-") || !name.endsWith(".json"))
40806
40843
  continue;
40807
- const portFile = join28(dir, name);
40844
+ const portFile = join29(dir, name);
40808
40845
  let raw;
40809
40846
  try {
40810
40847
  raw = await readPrivateText2(portFile);
@@ -40831,7 +40868,7 @@ async function sweepRpcState(root, activeDir, isManagedDir, log16) {
40831
40868
  await unlink12(portFile).catch(() => {
40832
40869
  });
40833
40870
  }
40834
- if (resolve22(dir) !== active2)
40871
+ if (resolve23(dir) !== active2)
40835
40872
  await rmdir3(dir).catch(() => {
40836
40873
  });
40837
40874
  }
@@ -40845,7 +40882,7 @@ init_private_files2();
40845
40882
  import { randomBytes as randomBytes6, timingSafeEqual } from "node:crypto";
40846
40883
  import { unlink as unlink13 } from "node:fs/promises";
40847
40884
  import { createServer as createServer2 } from "node:http";
40848
- import { join as join29 } from "node:path";
40885
+ import { join as join30 } from "node:path";
40849
40886
  var RpcRequestError = class extends Error {
40850
40887
  status;
40851
40888
  constructor(status, message) {
@@ -40865,7 +40902,7 @@ var BodyTooLargeError = class extends Error {
40865
40902
  }
40866
40903
  };
40867
40904
  function readBody(req) {
40868
- return new Promise((resolve26, reject) => {
40905
+ return new Promise((resolve27, reject) => {
40869
40906
  const tooLarge = (declaredOversize = false) => {
40870
40907
  req.removeAllListeners("data");
40871
40908
  req.on("data", () => {
@@ -40888,7 +40925,7 @@ function readBody(req) {
40888
40925
  }
40889
40926
  chunks.push(chunk);
40890
40927
  });
40891
- req.on("end", () => resolve26(Buffer.concat(chunks).toString("utf8")));
40928
+ req.on("end", () => resolve27(Buffer.concat(chunks).toString("utf8")));
40892
40929
  req.on("error", reject);
40893
40930
  });
40894
40931
  }
@@ -41067,12 +41104,12 @@ async function startRpcServer(options) {
41067
41104
  json(500, { error: "internal error" });
41068
41105
  }
41069
41106
  }
41070
- const port = await new Promise((resolve26, reject) => {
41107
+ const port = await new Promise((resolve27, reject) => {
41071
41108
  server.on("error", reject);
41072
41109
  server.listen(0, "127.0.0.1", () => {
41073
41110
  const addr = server.address();
41074
41111
  if (addr && typeof addr === "object")
41075
- resolve26(addr.port);
41112
+ resolve27(addr.port);
41076
41113
  else
41077
41114
  reject(new Error("no port"));
41078
41115
  });
@@ -41095,20 +41132,20 @@ async function startRpcServer(options) {
41095
41132
  rpcPort: port
41096
41133
  });
41097
41134
  } catch (error) {
41098
- await new Promise((resolve26) => server.close(() => resolve26()));
41135
+ await new Promise((resolve27) => server.close(() => resolve27()));
41099
41136
  throw error;
41100
41137
  }
41101
41138
  return {
41102
41139
  port,
41103
41140
  token,
41104
41141
  async stop() {
41105
- await new Promise((resolve26) => {
41142
+ await new Promise((resolve27) => {
41106
41143
  server.closeAllConnections?.();
41107
- server.close(() => resolve26());
41144
+ server.close(() => resolve27());
41108
41145
  for (const socket of connections)
41109
41146
  socket.destroy();
41110
41147
  });
41111
- const portFile = join29(options.dir, `port-${process.pid}.json`);
41148
+ const portFile = join30(options.dir, `port-${process.pid}.json`);
41112
41149
  const current = await readPrivateText2(portFile).then((raw) => JSON.parse(raw)).catch((error) => {
41113
41150
  if (error instanceof PrivateFileError2 && error.code !== "ENOENT")
41114
41151
  throw error;
@@ -42196,7 +42233,7 @@ import { createInterface as createInterface2 } from "node:readline/promises";
42196
42233
  // src/plugin/config/updater.ts
42197
42234
  import { existsSync as existsSync9, mkdirSync as mkdirSync4, readFileSync as readFileSync8, writeFileSync as writeFileSync4 } from "node:fs";
42198
42235
  import { homedir as homedir11 } from "node:os";
42199
- import { dirname as dirname23, join as join30 } from "node:path";
42236
+ import { dirname as dirname23, join as join31 } from "node:path";
42200
42237
 
42201
42238
  // src/plugin/model-registry.ts
42202
42239
  init_dist();
@@ -42213,13 +42250,13 @@ function stripJsonCommentsAndTrailingCommas(json) {
42213
42250
  ).replace(/,(\s*[}\]])/g, "$1");
42214
42251
  }
42215
42252
  function getOpencodeConfigDir() {
42216
- const xdgConfig2 = process.env.XDG_CONFIG_HOME || join30(homedir11(), ".config");
42217
- return join30(xdgConfig2, "opencode");
42253
+ const xdgConfig2 = process.env.XDG_CONFIG_HOME || join31(homedir11(), ".config");
42254
+ return join31(xdgConfig2, "opencode");
42218
42255
  }
42219
42256
  function getOpencodeConfigPath() {
42220
42257
  const configDir = getOpencodeConfigDir();
42221
- const jsoncPath = join30(configDir, OPENCODE_JSONC_FILENAME);
42222
- const jsonPath = join30(configDir, OPENCODE_JSON_FILENAME);
42258
+ const jsoncPath = join31(configDir, OPENCODE_JSONC_FILENAME);
42259
+ const jsonPath = join31(configDir, OPENCODE_JSON_FILENAME);
42223
42260
  if (existsSync9(jsoncPath)) {
42224
42261
  return jsoncPath;
42225
42262
  }
@@ -42478,7 +42515,7 @@ async function select3(items, options) {
42478
42515
  }
42479
42516
  renderedLines = linesWritten;
42480
42517
  };
42481
- return new Promise((resolve26) => {
42518
+ return new Promise((resolve27) => {
42482
42519
  const wasRaw = stdin.isRaw ?? false;
42483
42520
  const cleanup2 = () => {
42484
42521
  if (isCleanedUp) return;
@@ -42499,11 +42536,11 @@ async function select3(items, options) {
42499
42536
  };
42500
42537
  const onSignal = () => {
42501
42538
  cleanup2();
42502
- resolve26(null);
42539
+ resolve27(null);
42503
42540
  };
42504
42541
  const finishWithValue = (value) => {
42505
42542
  cleanup2();
42506
- resolve26(value);
42543
+ resolve27(value);
42507
42544
  };
42508
42545
  const findNextSelectable = (from, direction) => {
42509
42546
  if (items.length === 0) return from;
@@ -42549,7 +42586,7 @@ async function select3(items, options) {
42549
42586
  stdin.setRawMode(true);
42550
42587
  } catch {
42551
42588
  cleanup2();
42552
- resolve26(null);
42589
+ resolve27(null);
42553
42590
  return;
42554
42591
  }
42555
42592
  stdin.resume();
@@ -44961,7 +44998,7 @@ import {
44961
44998
  writeFileSync as writeFileSync5
44962
44999
  } from "node:fs";
44963
45000
  import { tmpdir as tmpdir5 } from "node:os";
44964
- import { dirname as dirname24, join as join31 } from "node:path";
45001
+ import { dirname as dirname24, join as join32 } from "node:path";
44965
45002
  function getSignatureCacheFilePath() {
44966
45003
  return stateHomeSignatureCacheFile();
44967
45004
  }
@@ -45245,7 +45282,7 @@ var SignatureCache = class {
45245
45282
  last_write: now
45246
45283
  }
45247
45284
  };
45248
- const tmpPath = join31(
45285
+ const tmpPath = join32(
45249
45286
  tmpdir5(),
45250
45287
  `antigravity-cache-${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`
45251
45288
  );
@@ -45315,7 +45352,7 @@ init_runtime_paths();
45315
45352
  init_logger4();
45316
45353
  import { existsSync as existsSync11, readFileSync as readFileSync11, realpathSync as realpathSync5 } from "node:fs";
45317
45354
  import { homedir as homedir12 } from "node:os";
45318
- import { basename as basename7, dirname as dirname25, join as join32, resolve as resolve23 } from "node:path";
45355
+ import { basename as basename7, dirname as dirname25, join as join33, resolve as resolve24 } from "node:path";
45319
45356
 
45320
45357
  // src/plugin/config/schema.ts
45321
45358
  import { z } from "zod";
@@ -45810,14 +45847,14 @@ function getConfigDir2() {
45810
45847
  if (process.env.OPENCODE_CONFIG_DIR) {
45811
45848
  return process.env.OPENCODE_CONFIG_DIR;
45812
45849
  }
45813
- const xdgConfig2 = process.env.XDG_CONFIG_HOME || join32(homedir12(), ".config");
45814
- return join32(xdgConfig2, "opencode");
45850
+ const xdgConfig2 = process.env.XDG_CONFIG_HOME || join33(homedir12(), ".config");
45851
+ return join33(xdgConfig2, "opencode");
45815
45852
  }
45816
45853
  function getUserConfigPath() {
45817
- return join32(getConfigDir2(), "antigravity.json");
45854
+ return join33(getConfigDir2(), "antigravity.json");
45818
45855
  }
45819
45856
  function getProjectConfigPath(directory) {
45820
- return join32(directory, ".opencode", "antigravity.json");
45857
+ return join33(directory, ".opencode", "antigravity.json");
45821
45858
  }
45822
45859
  function loadConfigFile(path5, log16) {
45823
45860
  try {
@@ -45873,12 +45910,12 @@ function loadConfigWithLogger(directory, log16) {
45873
45910
  return config;
45874
45911
  }
45875
45912
  function canonicalizeOwnedPath(path5) {
45876
- const absolute = resolve23(path5);
45913
+ const absolute = resolve24(path5);
45877
45914
  const missing = [];
45878
45915
  let current = absolute;
45879
45916
  for (; ; ) {
45880
45917
  try {
45881
- return join32(realpathSync5(current), ...missing.reverse());
45918
+ return join33(realpathSync5(current), ...missing.reverse());
45882
45919
  } catch {
45883
45920
  const parent = dirname25(current);
45884
45921
  if (parent === current) return absolute;
@@ -46184,9 +46221,9 @@ function clearSignatureCache(sessionId) {
46184
46221
  // src/plugin/image-saver.ts
46185
46222
  import { chmodSync as chmodSync4, existsSync as existsSync12, mkdirSync as mkdirSync6, writeFileSync as writeFileSync6 } from "node:fs";
46186
46223
  import { homedir as homedir13 } from "node:os";
46187
- import { join as join33 } from "node:path";
46224
+ import { join as join34 } from "node:path";
46188
46225
  function getImageOutputDir(outputDir) {
46189
- const resolved = outputDir ?? join33(homedir13(), ".opencode", "generated-images");
46226
+ const resolved = outputDir ?? join34(homedir13(), ".opencode", "generated-images");
46190
46227
  if (!existsSync12(resolved)) {
46191
46228
  mkdirSync6(resolved, { recursive: true, mode: 448 });
46192
46229
  }
@@ -46209,7 +46246,7 @@ function generateImageFilename(mimeType) {
46209
46246
  function saveImageToDisk(base64Data, mimeType, outputDir) {
46210
46247
  try {
46211
46248
  const resolvedOutputDir = getImageOutputDir(outputDir);
46212
- const filePath = join33(resolvedOutputDir, generateImageFilename(mimeType));
46249
+ const filePath = join34(resolvedOutputDir, generateImageFilename(mimeType));
46213
46250
  writeFileSync6(filePath, Buffer.from(base64Data, "base64"), { mode: 384 });
46214
46251
  chmodSync4(filePath, 384);
46215
46252
  return filePath;
@@ -46650,10 +46687,10 @@ init_logging_utils();
46650
46687
  import { createHash as createHash17 } from "node:crypto";
46651
46688
  import { appendFileSync as appendFileSync4, mkdirSync as mkdirSync7, writeFileSync as writeFileSync7 } from "node:fs";
46652
46689
  import { tmpdir as tmpdir6 } from "node:os";
46653
- import { join as join34 } from "node:path";
46690
+ import { join as join35 } from "node:path";
46654
46691
  var DUMP_STATUS_TITLE = "## Gemini Dump Status";
46655
46692
  var DUMP_DIR_ENV = "OPENCODE_ANTIGRAVITY_GEMINI_DUMP_DIR";
46656
- var DEFAULT_DUMP_DIR = join34(tmpdir6(), "opencode-antigravity-gemini-dumps");
46693
+ var DEFAULT_DUMP_DIR = join35(tmpdir6(), "opencode-antigravity-gemini-dumps");
46657
46694
  var DUMP_DIR_MODE = 448;
46658
46695
  var DUMP_FILE_MODE = 384;
46659
46696
  var nextDumpId = 0;
@@ -46807,7 +46844,7 @@ function writeGeminiDump(input2) {
46807
46844
  nextDumpId += 1;
46808
46845
  const id = `${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}-${String(nextDumpId).padStart(5, "0")}-${input2.streaming ? "stream" : "json"}`;
46809
46846
  const dumpDir = getGeminiDumpDirectory();
46810
- const prefix = join34(dumpDir, id);
46847
+ const prefix = join35(dumpDir, id);
46811
46848
  mkdirSync7(dumpDir, { recursive: true, mode: DUMP_DIR_MODE });
46812
46849
  const context = {
46813
46850
  id,
@@ -46898,21 +46935,21 @@ import {
46898
46935
  unlinkSync as unlinkSync4,
46899
46936
  writeFileSync as writeFileSync8
46900
46937
  } from "node:fs";
46901
- import { join as join36 } from "node:path";
46938
+ import { join as join37 } from "node:path";
46902
46939
 
46903
46940
  // src/plugin/recovery/constants.ts
46904
46941
  import { homedir as homedir14 } from "node:os";
46905
- import { join as join35 } from "node:path";
46942
+ import { join as join36 } from "node:path";
46906
46943
  function getXdgData() {
46907
46944
  const platform = process.platform;
46908
46945
  if (platform === "win32") {
46909
- return process.env.APPDATA || join35(homedir14(), "AppData", "Roaming");
46946
+ return process.env.APPDATA || join36(homedir14(), "AppData", "Roaming");
46910
46947
  }
46911
- return process.env.XDG_DATA_HOME || join35(homedir14(), ".local", "share");
46948
+ return process.env.XDG_DATA_HOME || join36(homedir14(), ".local", "share");
46912
46949
  }
46913
- var OPENCODE_STORAGE = join35(getXdgData(), "opencode", "storage");
46914
- var MESSAGE_STORAGE = join35(OPENCODE_STORAGE, "message");
46915
- var PART_STORAGE = join35(OPENCODE_STORAGE, "part");
46950
+ var OPENCODE_STORAGE = join36(getXdgData(), "opencode", "storage");
46951
+ var MESSAGE_STORAGE = join36(OPENCODE_STORAGE, "message");
46952
+ var PART_STORAGE = join36(OPENCODE_STORAGE, "part");
46916
46953
  var THINKING_TYPES = /* @__PURE__ */ new Set([
46917
46954
  "thinking",
46918
46955
  "redacted_thinking",
@@ -46922,13 +46959,13 @@ var THINKING_TYPES = /* @__PURE__ */ new Set([
46922
46959
  // src/plugin/recovery/storage.ts
46923
46960
  function getMessageDir(sessionID) {
46924
46961
  if (!existsSync13(MESSAGE_STORAGE)) return "";
46925
- const directPath = join36(MESSAGE_STORAGE, sessionID);
46962
+ const directPath = join37(MESSAGE_STORAGE, sessionID);
46926
46963
  if (existsSync13(directPath)) {
46927
46964
  return directPath;
46928
46965
  }
46929
46966
  try {
46930
46967
  for (const dir of readdirSync2(MESSAGE_STORAGE)) {
46931
- const sessionPath = join36(MESSAGE_STORAGE, dir, sessionID);
46968
+ const sessionPath = join37(MESSAGE_STORAGE, dir, sessionID);
46932
46969
  if (existsSync13(sessionPath)) {
46933
46970
  return sessionPath;
46934
46971
  }
@@ -46945,7 +46982,7 @@ function readMessages(sessionID) {
46945
46982
  for (const file of readdirSync2(messageDir)) {
46946
46983
  if (!file.endsWith(".json")) continue;
46947
46984
  try {
46948
- const content = readFileSync12(join36(messageDir, file), "utf-8");
46985
+ const content = readFileSync12(join37(messageDir, file), "utf-8");
46949
46986
  messages.push(JSON.parse(content));
46950
46987
  } catch {
46951
46988
  }
@@ -46961,14 +46998,14 @@ function readMessages(sessionID) {
46961
46998
  });
46962
46999
  }
46963
47000
  function readParts(messageID) {
46964
- const partDir = join36(PART_STORAGE, messageID);
47001
+ const partDir = join37(PART_STORAGE, messageID);
46965
47002
  if (!existsSync13(partDir)) return [];
46966
47003
  const parts = [];
46967
47004
  try {
46968
47005
  for (const file of readdirSync2(partDir)) {
46969
47006
  if (!file.endsWith(".json")) continue;
46970
47007
  try {
46971
- const content = readFileSync12(join36(partDir, file), "utf-8");
47008
+ const content = readFileSync12(join37(partDir, file), "utf-8");
46972
47009
  parts.push(JSON.parse(content));
46973
47010
  } catch {
46974
47011
  }
@@ -47010,7 +47047,7 @@ function findMessagesWithOrphanThinking(sessionID) {
47010
47047
  return result;
47011
47048
  }
47012
47049
  function prependThinkingPart(sessionID, messageID) {
47013
- const partDir = join36(PART_STORAGE, messageID);
47050
+ const partDir = join37(PART_STORAGE, messageID);
47014
47051
  try {
47015
47052
  if (!existsSync13(partDir)) {
47016
47053
  mkdirSync8(partDir, { recursive: true });
@@ -47025,7 +47062,7 @@ function prependThinkingPart(sessionID, messageID) {
47025
47062
  synthetic: true
47026
47063
  };
47027
47064
  writeFileSync8(
47028
- join36(partDir, `${partId}.json`),
47065
+ join37(partDir, `${partId}.json`),
47029
47066
  JSON.stringify(part, null, 2)
47030
47067
  );
47031
47068
  return true;
@@ -47034,14 +47071,14 @@ function prependThinkingPart(sessionID, messageID) {
47034
47071
  }
47035
47072
  }
47036
47073
  function stripThinkingParts(messageID) {
47037
- const partDir = join36(PART_STORAGE, messageID);
47074
+ const partDir = join37(PART_STORAGE, messageID);
47038
47075
  if (!existsSync13(partDir)) return false;
47039
47076
  let anyRemoved = false;
47040
47077
  try {
47041
47078
  for (const file of readdirSync2(partDir)) {
47042
47079
  if (!file.endsWith(".json")) continue;
47043
47080
  try {
47044
- const filePath = join36(partDir, file);
47081
+ const filePath = join37(partDir, file);
47045
47082
  const content = readFileSync12(filePath, "utf-8");
47046
47083
  const part = JSON.parse(content);
47047
47084
  if (THINKING_TYPES.has(part.type)) {
@@ -49848,6 +49885,7 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
49848
49885
  headers.delete("x-parent-session-id");
49849
49886
  headers.delete("x-opencode-session-id");
49850
49887
  headers.delete("x-opencode-parent-session-id");
49888
+ headers.delete("x-antigravity-internal-request-purpose");
49851
49889
  headers.delete("x-goog-user-project");
49852
49890
  headers.delete("X-Goog-Api-Client");
49853
49891
  headers.delete("Client-Metadata");
@@ -50811,10 +50849,10 @@ async function retainResponseLifetime(response, cancellation) {
50811
50849
  cancellation.release();
50812
50850
  throw error;
50813
50851
  }
50814
- let resolve26 = () => {
50852
+ let resolve27 = () => {
50815
50853
  };
50816
50854
  const settled = new Promise((done) => {
50817
- resolve26 = done;
50855
+ resolve27 = done;
50818
50856
  });
50819
50857
  let stopping = false;
50820
50858
  let finished = false;
@@ -50824,7 +50862,7 @@ async function retainResponseLifetime(response, cancellation) {
50824
50862
  finished = true;
50825
50863
  cancellation.signal.removeEventListener("abort", abort);
50826
50864
  cancellation.release();
50827
- resolve26();
50865
+ resolve27();
50828
50866
  };
50829
50867
  const abort = () => {
50830
50868
  if (finished || stopping) return;
@@ -50893,8 +50931,8 @@ function createAfterHandoff(work, signals, onFailure) {
50893
50931
  let running = false;
50894
50932
  let resolveCompletion = () => {
50895
50933
  };
50896
- const completion = new Promise((resolve26) => {
50897
- resolveCompletion = resolve26;
50934
+ const completion = new Promise((resolve27) => {
50935
+ resolveCompletion = resolve27;
50898
50936
  });
50899
50937
  const finish = () => {
50900
50938
  if (finished) return;
@@ -50941,14 +50979,14 @@ function createAfterHandoff(work, signals, onFailure) {
50941
50979
  };
50942
50980
  }
50943
50981
  function publishResponse(dispatch) {
50944
- return new Promise((resolve26, reject) => {
50982
+ return new Promise((resolve27, reject) => {
50945
50983
  let acknowledge;
50946
50984
  void Promise.resolve().then(
50947
50985
  () => dispatch((callback) => {
50948
50986
  acknowledge = callback;
50949
50987
  })
50950
50988
  ).then((response) => {
50951
- resolve26(response);
50989
+ resolve27(response);
50952
50990
  acknowledge?.();
50953
50991
  }, reject);
50954
50992
  });
@@ -52745,15 +52783,15 @@ init_debug();
52745
52783
  // src/plugin/dependencies.ts
52746
52784
  init_dist();
52747
52785
  import { homedir as homedir15 } from "node:os";
52748
- import { join as join37 } from "node:path";
52786
+ import { join as join38 } from "node:path";
52749
52787
  function defaultFilesystemRoots() {
52750
- const xdgConfig2 = process.env.XDG_CONFIG_HOME ?? join37(homedir15(), ".config");
52751
- const xdgState2 = process.env.XDG_STATE_HOME ?? join37(homedir15(), ".local", "state");
52788
+ const xdgConfig2 = process.env.XDG_CONFIG_HOME ?? join38(homedir15(), ".config");
52789
+ const xdgState2 = process.env.XDG_STATE_HOME ?? join38(homedir15(), ".local", "state");
52752
52790
  return {
52753
52791
  projectRoot: process.cwd(),
52754
- userConfigRoot: join37(xdgConfig2, "opencode"),
52755
- sidebarStateRoot: join37(xdgState2, "cortexkit", "antigravity-auth"),
52756
- rpcRoot: join37(xdgState2, "cortexkit", "antigravity-auth", "rpc")
52792
+ userConfigRoot: join38(xdgConfig2, "opencode"),
52793
+ sidebarStateRoot: join38(xdgState2, "cortexkit", "antigravity-auth"),
52794
+ rpcRoot: join38(xdgState2, "cortexkit", "antigravity-auth", "rpc")
52757
52795
  };
52758
52796
  }
52759
52797
  function resolvePluginDependencies(overrides = {}) {
@@ -52782,10 +52820,10 @@ function resolvePluginDependencies(overrides = {}) {
52782
52820
  }
52783
52821
  async function defaultSleep(ms, signal) {
52784
52822
  if (ms <= 0) return;
52785
- await new Promise((resolve26, reject) => {
52823
+ await new Promise((resolve27, reject) => {
52786
52824
  const timer = setTimeout(() => {
52787
52825
  signal?.removeEventListener("abort", onAbort);
52788
- resolve26();
52826
+ resolve27();
52789
52827
  }, ms);
52790
52828
  timer.unref?.();
52791
52829
  const onAbort = () => {
@@ -52906,6 +52944,107 @@ init_logger4();
52906
52944
  // src/plugin/shared/request-services.ts
52907
52945
  init_dist();
52908
52946
 
52947
+ // src/common-auth-embedded/routing-accessor/index.js
52948
+ function isObject2(value) {
52949
+ return typeof value === "object" && value !== null;
52950
+ }
52951
+ function routingHandle(sessionId) {
52952
+ const routing = Reflect.get(globalThis, /* @__PURE__ */ Symbol.for("cortexkit.routing"));
52953
+ if (typeof routing !== "function")
52954
+ return void 0;
52955
+ const handle = routing(sessionId);
52956
+ return isObject2(handle) ? handle : void 0;
52957
+ }
52958
+ function selectionFor(answer, candidates) {
52959
+ if (!isObject2(answer))
52960
+ return void 0;
52961
+ const accountId = answer.account_id;
52962
+ const credentialId = answer.credential_id;
52963
+ if (typeof accountId !== "string")
52964
+ return void 0;
52965
+ if (credentialId !== void 0 && typeof credentialId !== "string") {
52966
+ return void 0;
52967
+ }
52968
+ const candidate = candidates.find((route) => route.accountId === accountId && (credentialId === void 0 || route.credentialId === credentialId));
52969
+ if (!candidate)
52970
+ return void 0;
52971
+ const hold = answer.hold;
52972
+ const retryAfterMs = isObject2(hold) ? hold.retry_after_ms : void 0;
52973
+ if (typeof retryAfterMs === "number" && Number.isFinite(retryAfterMs) && retryAfterMs >= 0) {
52974
+ return { candidate, hold: { retry_after_ms: retryAfterMs } };
52975
+ }
52976
+ return { candidate };
52977
+ }
52978
+ async function askRouting(input2) {
52979
+ let timer;
52980
+ try {
52981
+ const handle = routingHandle(input2.sessionId);
52982
+ if (!handle)
52983
+ return void 0;
52984
+ const accountFor = handle.accountFor;
52985
+ if (typeof accountFor !== "function")
52986
+ return void 0;
52987
+ const requested = input2.deadlineMs ?? 500;
52988
+ const deadlineMs = Number.isNaN(requested) ? 500 : Math.min(2e3, Math.max(1, requested));
52989
+ const expired = new Promise((resolve27) => {
52990
+ timer = setTimeout(() => resolve27(void 0), deadlineMs);
52991
+ timer.unref();
52992
+ });
52993
+ const pending = accountFor.call(handle, { provider: input2.provider, modelId: input2.modelId }, { deadlineMs });
52994
+ if (!isObject2(pending) || typeof pending.then !== "function")
52995
+ return void 0;
52996
+ const answer = await Promise.race([pending, expired]);
52997
+ return selectionFor(answer, input2.candidates);
52998
+ } catch {
52999
+ return void 0;
53000
+ } finally {
53001
+ clearTimeout(timer);
53002
+ }
53003
+ }
53004
+ function reportRouting(input2) {
53005
+ try {
53006
+ const handle = routingHandle(input2.sessionId);
53007
+ if (!handle)
53008
+ return;
53009
+ const report = handle.report;
53010
+ if (typeof report !== "function")
53011
+ return;
53012
+ const identity3 = {
53013
+ account_id: input2.accountId,
53014
+ ...input2.credentialId !== void 0 ? { credential_id: input2.credentialId } : {}
53015
+ };
53016
+ let payload;
53017
+ switch (input2.outcome) {
53018
+ case "served":
53019
+ payload = { ...identity3, outcome: "served", headers: input2.headers };
53020
+ break;
53021
+ case "exhausted": {
53022
+ const { window, pool } = input2;
53023
+ if (window !== "5h" && window !== "7d")
53024
+ return;
53025
+ if (pool !== void 0 && (typeof pool !== "string" || pool.length === 0 || pool.includes(":")))
53026
+ return;
53027
+ payload = {
53028
+ ...identity3,
53029
+ outcome: "exhausted",
53030
+ window,
53031
+ ...pool ? { pool } : {},
53032
+ ...input2.resetsAt !== void 0 ? { resets_at: input2.resetsAt } : {}
53033
+ };
53034
+ break;
53035
+ }
53036
+ default:
53037
+ return;
53038
+ }
53039
+ const pending = report.call(handle, payload);
53040
+ if (isObject2(pending) && typeof pending.then === "function") {
53041
+ void Promise.resolve(pending).catch(() => {
53042
+ });
53043
+ }
53044
+ } catch {
53045
+ }
53046
+ }
53047
+
52909
53048
  // src/plugin/errors.ts
52910
53049
  var AntigravityKillswitchError = class extends Error {
52911
53050
  family;
@@ -53371,7 +53510,7 @@ function throwIfAllKilled(input2) {
53371
53510
  }
53372
53511
 
53373
53512
  // src/plugin/session-context.ts
53374
- import { resolve as resolve24 } from "node:path";
53513
+ import { resolve as resolve25 } from "node:path";
53375
53514
  import { pathToFileURL } from "node:url";
53376
53515
  var FALLBACK_SESSION_KEY = "__default__";
53377
53516
  function extractOpenCodeSessionIdentity(headers) {
@@ -53385,7 +53524,7 @@ var AgySessionRegistry = class {
53385
53524
  requestSessions;
53386
53525
  parentSessionIds = /* @__PURE__ */ new Map();
53387
53526
  constructor(directory, options = {}) {
53388
- const workspaceUri = directory ? pathToFileURL(resolve24(directory)).href : "";
53527
+ const workspaceUri = directory ? pathToFileURL(resolve25(directory)).href : "";
53389
53528
  this.requestSessions = new AgyRequestSessionStore(workspaceUri, options);
53390
53529
  }
53391
53530
  getOrCreate(identity3) {
@@ -53437,6 +53576,192 @@ var AgySessionRegistry = class {
53437
53576
  }
53438
53577
  };
53439
53578
 
53579
+ // src/plugin/shared/vault-routing.ts
53580
+ var ROUTING_GROUP_SCOPED_EXHAUSTION = false;
53581
+ function hasVaultRoutingAccessor() {
53582
+ try {
53583
+ return typeof Reflect.get(globalThis, /* @__PURE__ */ Symbol.for("cortexkit.routing")) === "function";
53584
+ } catch {
53585
+ return false;
53586
+ }
53587
+ }
53588
+ function routingQuotaScope(group, window) {
53589
+ const limitWindow = window === "5h" ? "five_hour" : window === "weekly" ? "seven_day" : void 0;
53590
+ return limitWindow ? { pool: group === "non-gemini" ? "3p" : group, limitWindow } : void 0;
53591
+ }
53592
+ function routingExhaustionFields(scope) {
53593
+ return {
53594
+ pool: scope.pool,
53595
+ window: scope.limitWindow === "five_hour" ? "5h" : "7d"
53596
+ };
53597
+ }
53598
+ function reportVaultExhaustion(input2, groupScopedExhaustion = ROUTING_GROUP_SCOPED_EXHAUSTION, report = reportRouting) {
53599
+ 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())
53600
+ return;
53601
+ for (const window of input2.quota?.windows ?? []) {
53602
+ if (window.remainingFraction !== 0) continue;
53603
+ const scope = routingQuotaScope(input2.group, window.window);
53604
+ const resetsAt = Date.parse(window.resetTime);
53605
+ if (!scope || !Number.isFinite(resetsAt) || resetsAt <= Date.now()) continue;
53606
+ if (groupScopedExhaustion)
53607
+ report({
53608
+ ...input2.identity,
53609
+ outcome: "exhausted",
53610
+ ...routingExhaustionFields(scope),
53611
+ resetsAt
53612
+ });
53613
+ }
53614
+ }
53615
+ var RATE_LIMIT_HEADERS = [
53616
+ "retry-after",
53617
+ "retry-after-ms",
53618
+ "ratelimit-limit",
53619
+ "ratelimit-remaining",
53620
+ "ratelimit-reset",
53621
+ "ratelimit-policy",
53622
+ "x-ratelimit-limit",
53623
+ "x-ratelimit-remaining",
53624
+ "x-ratelimit-reset",
53625
+ "x-ratelimit-limit-requests",
53626
+ "x-ratelimit-remaining-requests",
53627
+ "x-ratelimit-reset-requests",
53628
+ "x-ratelimit-limit-tokens",
53629
+ "x-ratelimit-remaining-tokens",
53630
+ "x-ratelimit-reset-tokens"
53631
+ ];
53632
+ function streamFailure(value) {
53633
+ if (!value || typeof value !== "object") return false;
53634
+ if (Array.isArray(value)) return value.some(streamFailure);
53635
+ const event = value;
53636
+ return event.error != null || event.type === "error" || event.type === "response.failed" || event.status === "failed" || streamFailure(event.response);
53637
+ }
53638
+ function observeVaultUpstream(response, signal) {
53639
+ if (!hasVaultRoutingAccessor() || !response.ok || signal?.aborted)
53640
+ return void 0;
53641
+ let completed = false;
53642
+ return {
53643
+ response: observeBody(response, () => {
53644
+ completed = !signal?.aborted;
53645
+ }),
53646
+ completedSuccessfully: () => completed
53647
+ };
53648
+ }
53649
+ function observeVaultServed(identity3, response, signal, upstream) {
53650
+ if (!hasVaultRoutingAccessor() || !response.ok || signal?.aborted)
53651
+ return response;
53652
+ const report = () => {
53653
+ if (signal?.aborted || upstream && !upstream.completedSuccessfully() || !hasVaultRoutingAccessor())
53654
+ return;
53655
+ const headers = {};
53656
+ for (const name of RATE_LIMIT_HEADERS) {
53657
+ const value = response.headers.get(name);
53658
+ if (value !== null) headers[name] = value;
53659
+ }
53660
+ reportRouting({ ...identity3, outcome: "served", headers });
53661
+ };
53662
+ return observeBody(response, report);
53663
+ }
53664
+ function observeBody(response, complete) {
53665
+ if (!response.body) {
53666
+ complete();
53667
+ return response;
53668
+ }
53669
+ const sse = response.headers.get("content-type")?.includes("text/event-stream");
53670
+ const reader = response.body.getReader();
53671
+ const decoder = new TextDecoder();
53672
+ let pending = "";
53673
+ let failed = false;
53674
+ const inspect = (line) => {
53675
+ if (line.length > 1024 * 1024) {
53676
+ failed = true;
53677
+ return;
53678
+ }
53679
+ if (line.startsWith("event:") && line.slice(6).trim() === "error")
53680
+ failed = true;
53681
+ if (!line.startsWith("data:") || !/"(?:error|response.failed|failed)"/.test(line))
53682
+ return;
53683
+ try {
53684
+ failed ||= streamFailure(JSON.parse(line.slice(5)));
53685
+ } catch {
53686
+ failed = true;
53687
+ }
53688
+ };
53689
+ const body = new ReadableStream(
53690
+ {
53691
+ async pull(controller) {
53692
+ try {
53693
+ const chunk = await reader.read();
53694
+ if (chunk.done) {
53695
+ if (sse) inspect(pending + decoder.decode());
53696
+ else if (/"(?:error|response.failed|failed)"/.test(pending)) {
53697
+ try {
53698
+ failed ||= streamFailure(JSON.parse(pending + decoder.decode()));
53699
+ } catch {
53700
+ failed = true;
53701
+ }
53702
+ }
53703
+ if (!failed) complete();
53704
+ controller.close();
53705
+ reader.releaseLock();
53706
+ return;
53707
+ }
53708
+ if (!failed) {
53709
+ pending += decoder.decode(chunk.value, { stream: true });
53710
+ if (sse) {
53711
+ let newline = pending.indexOf("\n");
53712
+ while (newline >= 0) {
53713
+ inspect(pending.slice(0, newline));
53714
+ pending = pending.slice(newline + 1);
53715
+ newline = pending.indexOf("\n");
53716
+ }
53717
+ }
53718
+ if (pending.length > 1024 * 1024) {
53719
+ failed = true;
53720
+ pending = "";
53721
+ }
53722
+ }
53723
+ controller.enqueue(chunk.value);
53724
+ } catch (error) {
53725
+ failed = true;
53726
+ controller.error(error);
53727
+ reader.releaseLock();
53728
+ }
53729
+ },
53730
+ async cancel(reason) {
53731
+ failed = true;
53732
+ try {
53733
+ await reader.cancel(reason);
53734
+ } finally {
53735
+ reader.releaseLock();
53736
+ }
53737
+ }
53738
+ },
53739
+ { highWaterMark: 0 }
53740
+ );
53741
+ const observed = new Response(body, {
53742
+ status: response.status,
53743
+ statusText: response.statusText,
53744
+ headers: response.headers
53745
+ });
53746
+ Object.defineProperties(observed, {
53747
+ url: { value: response.url },
53748
+ redirected: { value: response.redirected }
53749
+ });
53750
+ return observed;
53751
+ }
53752
+
53753
+ // src/plugin/shared/vault-routing-purpose.ts
53754
+ var VAULT_ROUTING_PURPOSE_HEADER = "x-antigravity-internal-request-purpose";
53755
+ function createVaultRoutingHeaders(providerId) {
53756
+ return async (input2, output2) => {
53757
+ if (input2.model.providerID !== providerId) return;
53758
+ output2.headers[VAULT_ROUTING_PURPOSE_HEADER] = input2.agent === "build" || input2.agent === "plan" ? "primary" : "auxiliary";
53759
+ };
53760
+ }
53761
+ function isPrimaryVaultRequest(kind, headers) {
53762
+ return kind === void 0 ? new Headers(headers).get(VAULT_ROUTING_PURPOSE_HEADER) === "primary" : kind === "primary";
53763
+ }
53764
+
53440
53765
  // src/plugin/shared/request-services.ts
53441
53766
  var FIRST_RETRY_DELAY_MS = 1e3;
53442
53767
  function prepareAgyWireRequest(wire, request) {
@@ -53533,7 +53858,7 @@ function formatWaitTime(ms) {
53533
53858
  return remainingMinutes > 0 ? `${hours}h ${remainingMinutes}m` : `${hours}h`;
53534
53859
  }
53535
53860
  function sleep4(ms, signal) {
53536
- return new Promise((resolve26, reject) => {
53861
+ return new Promise((resolve27, reject) => {
53537
53862
  if (signal?.aborted) {
53538
53863
  reject(
53539
53864
  signal.reason instanceof Error ? signal.reason : new Error("Aborted")
@@ -53542,7 +53867,7 @@ function sleep4(ms, signal) {
53542
53867
  }
53543
53868
  const timeout = setTimeout(() => {
53544
53869
  cleanup2();
53545
- resolve26();
53870
+ resolve27();
53546
53871
  }, ms);
53547
53872
  const onAbort = () => {
53548
53873
  cleanup2();
@@ -53628,7 +53953,7 @@ function createRequestExecutor(deps) {
53628
53953
  log16.debug("send-admission-401-report-failed", { error: String(error) });
53629
53954
  });
53630
53955
  };
53631
- const reportRouting = (sessionId, entry) => {
53956
+ const reportRouting2 = (sessionId, entry) => {
53632
53957
  if (!onRouting) return;
53633
53958
  try {
53634
53959
  onRouting(sessionId, entry);
@@ -53799,6 +54124,7 @@ function createRequestExecutor(deps) {
53799
54124
  const maxWaitMs = (config.max_rate_limit_wait_seconds ?? 300) * 1e3;
53800
54125
  let allAccountsBlockedAt;
53801
54126
  const modelUnavailableIndexes = /* @__PURE__ */ new Set();
54127
+ let routingPlacementConsidered = false;
53802
54128
  while (true) {
53803
54129
  await assertAdmission();
53804
54130
  checkAborted();
@@ -53882,6 +54208,11 @@ function createRequestExecutor(deps) {
53882
54208
  }
53883
54209
  }
53884
54210
  const excludedIndexes = modelUnavailableIndexes.size === 0 ? killedIndexes : /* @__PURE__ */ new Set([...killedIndexes ?? [], ...modelUnavailableIndexes]);
54211
+ const routingPresent = credentials.domain === "vault" && hasVaultRoutingAccessor();
54212
+ const firstPlacement = routingPresent && !routingPlacementConsidered && accountSessionIdentity && !accountManager.getCurrentAccountForFamily(
54213
+ family,
54214
+ accountSessionIdentity
54215
+ );
53885
54216
  let account = accountManager.getCurrentOrNextForFamily(
53886
54217
  family,
53887
54218
  model,
@@ -53892,6 +54223,50 @@ function createRequestExecutor(deps) {
53892
54223
  accountSessionIdentity,
53893
54224
  excludedIndexes
53894
54225
  );
54226
+ if (account) {
54227
+ routingPlacementConsidered = true;
54228
+ if (firstPlacement && credentials.domain === "vault" && credentials.routingCandidate && model && isPrimaryVaultRequest(kind, init?.headers)) {
54229
+ const candidates = accountManager.getEnabledAccounts().filter(
54230
+ (row) => !excludedIndexes?.has(row.index) && !accountManager.isRateLimited(row, family, model) && !accountManager.isAccountCoolingDown(row) && !accountManager.isAccountOverSoftQuota(
54231
+ row,
54232
+ family,
54233
+ config.soft_quota_threshold_percent,
54234
+ softQuotaCacheTtlMs,
54235
+ model
54236
+ )
54237
+ ).map((row) => ({
54238
+ ...credentials.routingCandidate(row),
54239
+ index: row.index
54240
+ }));
54241
+ if (candidates.length > 0) {
54242
+ const answer = await deadline.wait(
54243
+ () => askRouting({
54244
+ sessionId: accountSessionIdentity.id,
54245
+ provider: "antigravity",
54246
+ modelId: model,
54247
+ candidates,
54248
+ deadlineMs: Math.min(500, deadline.remainingMs())
54249
+ })
54250
+ );
54251
+ checkAborted();
54252
+ if (answer && answer.candidate.index !== account.index) {
54253
+ account = accountManager.getCurrentOrNextForFamily(
54254
+ family,
54255
+ model,
54256
+ config.account_selection_strategy,
54257
+ config.pid_offset_enabled,
54258
+ config.soft_quota_threshold_percent,
54259
+ softQuotaCacheTtlMs,
54260
+ accountSessionIdentity,
54261
+ /* @__PURE__ */ new Set([
54262
+ ...excludedIndexes ?? [],
54263
+ ...accountManager.getAccounts().filter((row) => row.index !== answer.candidate.index).map((row) => row.index)
54264
+ ])
54265
+ ) ?? account;
54266
+ }
54267
+ }
54268
+ }
54269
+ }
53895
54270
  if (account && eligibleIndexes !== null && !eligibleIndexes.has(account.index)) {
53896
54271
  pushDebug(
53897
54272
  `killswitch-excluded idx=${account.index} (precomputed eligible set)`
@@ -54551,7 +54926,7 @@ function createRequestExecutor(deps) {
54551
54926
  strategy: config.account_selection_strategy,
54552
54927
  updatedAt: Date.now()
54553
54928
  };
54554
- reportRouting(sessionKey, routingEntry);
54929
+ reportRouting2(sessionKey, routingEntry);
54555
54930
  }
54556
54931
  if (response.status === 429 || response.status === 503 || response.status === 529) {
54557
54932
  if (tokenConsumed) {
@@ -54586,6 +54961,26 @@ function createRequestExecutor(deps) {
54586
54961
  reasonInfo.message,
54587
54962
  response.status
54588
54963
  );
54964
+ if (credentials.domain === "vault" && sendAdmission && sessionKey && hasVaultRoutingAccessor()) {
54965
+ const group = resolveQuotaGroup(
54966
+ family,
54967
+ model,
54968
+ account.cachedQuota
54969
+ );
54970
+ reportVaultExhaustion({
54971
+ identity: {
54972
+ sessionId: sessionKey,
54973
+ accountId: sendAdmission.accountIdentity,
54974
+ credentialId: sendAdmission.credentialId
54975
+ },
54976
+ status: response.status,
54977
+ reason: rateLimitReason,
54978
+ group,
54979
+ quota: account.cachedQuota?.[group],
54980
+ observedAt: account.cachedQuotaUpdatedAt,
54981
+ signal: abortSignal
54982
+ });
54983
+ }
54589
54984
  if (rateLimitReason === "MODEL_CAPACITY_EXHAUSTED" || rateLimitReason === "SERVER_ERROR") {
54590
54985
  totalCapacityRetries++;
54591
54986
  if (isCapacityRetryBudgetExhausted(totalCapacityRetries)) {
@@ -54923,9 +55318,10 @@ function createRequestExecutor(deps) {
54923
55318
  const _emptyAttemptKeyClean = `${prepared.sessionId ?? "none"}:${prepared.effectiveModel ?? "unknown"}`;
54924
55319
  retryState.clearEmptyResponseAttempts();
54925
55320
  }
55321
+ const routingObservation = credentials.domain === "vault" && sendAdmission && sessionKey && response.ok && hasVaultRoutingAccessor() ? observeVaultUpstream(response, abortSignal) : void 0;
54926
55322
  const transformedResponse = await deadline.wait(
54927
55323
  () => wire.transformResponse(
54928
- response,
55324
+ routingObservation?.response ?? response,
54929
55325
  prepared.streaming,
54930
55326
  debugContext,
54931
55327
  prepared.requestedModel,
@@ -54997,7 +55393,16 @@ function createRequestExecutor(deps) {
54997
55393
  const refresh = credentials.refreshQuotaAfterSuccess;
54998
55394
  waitPolicy.quota = (signal) => refresh(account, config.quota_refresh_interval_minutes, signal);
54999
55395
  }
55000
- return transformedResponse;
55396
+ return routingObservation && credentials.domain === "vault" && sendAdmission && sessionKey && hasVaultRoutingAccessor() && response.ok ? observeVaultServed(
55397
+ {
55398
+ sessionId: sessionKey,
55399
+ accountId: sendAdmission.accountIdentity,
55400
+ credentialId: sendAdmission.credentialId
55401
+ },
55402
+ transformedResponse,
55403
+ abortSignal,
55404
+ routingObservation
55405
+ ) : transformedResponse;
55001
55406
  } catch (error) {
55002
55407
  if (error instanceof PreResponseTimeoutError) throw error;
55003
55408
  checkAborted();
@@ -56030,8 +56435,8 @@ function createPluginLifecycle(options) {
56030
56435
  };
56031
56436
  let failDisposal = () => {
56032
56437
  };
56033
- disposal = new Promise((resolve26, reject) => {
56034
- finishDisposal = resolve26;
56438
+ disposal = new Promise((resolve27, reject) => {
56439
+ finishDisposal = resolve27;
56035
56440
  failDisposal = reject;
56036
56441
  });
56037
56442
  void (async () => {
@@ -56230,7 +56635,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
56230
56635
  await drainSidebarWrites();
56231
56636
  }
56232
56637
  });
56233
- const accountFile = resolve25(accountFileForVault());
56638
+ const accountFile = resolve26(accountFileForVault());
56234
56639
  const vaultFolder = await prepareVaultFolder({ accountFile });
56235
56640
  const unavailableMessage = vaultFolder.refusal?.message ?? VAULT_ACCOUNT_REMEDY;
56236
56641
  let vaultQuotaPoller;
@@ -56453,7 +56858,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
56453
56858
  lifecycle.register(vaultQuotaPoller, "producer");
56454
56859
  }
56455
56860
  const operatorSettings = createOperatorSettingsController({
56456
- projectConfigPath: join38(directory, ".opencode", "antigravity.json"),
56861
+ projectConfigPath: join39(directory, ".opencode", "antigravity.json"),
56457
56862
  // getUserConfigPath() already returns the full file path including
56458
56863
  // 'antigravity.json' — do NOT join again or the path double-nests
56459
56864
  // into <dir>/antigravity.json/antigravity.json.
@@ -56893,6 +57298,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
56893
57298
  );
56894
57299
  },
56895
57300
  "command.execute.before": commandExecuteBefore,
57301
+ "chat.headers": createVaultRoutingHeaders(providerId),
56896
57302
  event,
56897
57303
  tool: { google_search: googleSearchTool },
56898
57304
  auth: {