@cortexkit/opencode-antigravity-auth 3.0.20 → 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 (107) hide show
  1. package/dist/cli.js +354 -278
  2. package/dist/cli.js.map +3 -3
  3. package/dist/cli.meta.json +66 -21
  4. package/dist/index.js +841 -392
  5. package/dist/index.js.map +4 -4
  6. package/dist/index.meta.json +123 -28
  7. package/dist/server.js +860 -411
  8. package/dist/server.js.map +4 -4
  9. package/dist/server.meta.json +1 -1
  10. package/dist/src/common-auth-embedded/claustrum/custody.js +25 -0
  11. package/dist/src/common-auth-embedded/claustrum/hub.js +20 -1
  12. package/dist/src/common-auth-embedded/claustrum/insula.js +6 -0
  13. package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +2 -2
  14. package/dist/src/common-auth-embedded/fs/with-lock.js +37 -10
  15. package/dist/src/common-auth-embedded/quota/format.d.ts +9 -4
  16. package/dist/src/common-auth-embedded/quota/format.js +45 -26
  17. package/dist/src/common-auth-embedded/quota-sidebar/index.d.ts +86 -0
  18. package/dist/src/common-auth-embedded/quota-sidebar/index.tsx +654 -0
  19. package/dist/src/common-auth-embedded/routing-accessor/index.d.ts +62 -0
  20. package/dist/src/common-auth-embedded/routing-accessor/index.js +128 -0
  21. package/dist/src/common-auth-embedded/source-output.json +69 -29
  22. package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
  23. package/dist/src/ga/tui/host-ga.js +2 -2
  24. package/dist/src/ga/tui/host-ga.js.map +1 -1
  25. package/dist/src/plugin/__fixtures__/verified-store.js +2 -2
  26. package/dist/src/plugin/index.d.ts.map +1 -1
  27. package/dist/src/plugin/index.js +2 -0
  28. package/dist/src/plugin/index.js.map +1 -1
  29. package/dist/src/plugin/request.d.ts.map +1 -1
  30. package/dist/src/plugin/request.js +1 -0
  31. package/dist/src/plugin/request.js.map +1 -1
  32. package/dist/src/plugin/shared/request-services.d.ts +6 -0
  33. package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
  34. package/dist/src/plugin/shared/request-services.js +89 -2
  35. package/dist/src/plugin/shared/request-services.js.map +1 -1
  36. package/dist/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
  37. package/dist/src/plugin/shared/vault-request-credentials.js +4 -0
  38. package/dist/src/plugin/shared/vault-request-credentials.js.map +1 -1
  39. package/dist/src/plugin/shared/vault-routing-purpose.d.ts +12 -0
  40. package/dist/src/plugin/shared/vault-routing-purpose.d.ts.map +1 -0
  41. package/dist/src/plugin/shared/vault-routing-purpose.js +18 -0
  42. package/dist/src/plugin/shared/vault-routing-purpose.js.map +1 -0
  43. package/dist/src/plugin/shared/vault-routing.d.ts +36 -0
  44. package/dist/src/plugin/shared/vault-routing.d.ts.map +1 -0
  45. package/dist/src/plugin/shared/vault-routing.js +213 -0
  46. package/dist/src/plugin/shared/vault-routing.js.map +1 -0
  47. package/dist/src/plugin/types.d.ts +1 -0
  48. package/dist/src/plugin/types.d.ts.map +1 -1
  49. package/dist/src/tui/quota-layout.d.ts +4 -58
  50. package/dist/src/tui/quota-layout.d.ts.map +1 -1
  51. package/dist/src/tui/quota-layout.js +4 -90
  52. package/dist/src/tui/quota-layout.js.map +1 -1
  53. package/dist/src/tui/sidebar-frame.d.ts +4 -34
  54. package/dist/src/tui/sidebar-frame.d.ts.map +1 -1
  55. package/dist/src/tui/sidebar-frame.js +93 -167
  56. package/dist/src/tui/sidebar-frame.js.map +1 -1
  57. package/dist/src/tui.js +2 -2
  58. package/dist/src/tui.js.map +1 -1
  59. package/dist/tui-build-map.json +31 -17
  60. package/dist/tui-ga-build-map.json +32 -17
  61. package/dist/types/src/common-auth-embedded/quota/format.d.ts +9 -4
  62. package/dist/types/src/common-auth-embedded/routing-accessor/index.d.ts +62 -0
  63. package/dist/types/src/plugin/index.d.ts.map +1 -1
  64. package/dist/types/src/plugin/request.d.ts.map +1 -1
  65. package/dist/types/src/plugin/shared/request-services.d.ts +6 -0
  66. package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -1
  67. package/dist/types/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
  68. package/dist/types/src/plugin/shared/vault-routing-purpose.d.ts +12 -0
  69. package/dist/types/src/plugin/shared/vault-routing-purpose.d.ts.map +1 -0
  70. package/dist/types/src/plugin/shared/vault-routing.d.ts +36 -0
  71. package/dist/types/src/plugin/shared/vault-routing.d.ts.map +1 -0
  72. package/dist/types/src/plugin/types.d.ts +1 -0
  73. package/dist/types/src/plugin/types.d.ts.map +1 -1
  74. package/package.json +2 -2
  75. package/src/common-auth-embedded/claustrum/custody.js +25 -0
  76. package/src/common-auth-embedded/claustrum/hub.js +20 -1
  77. package/src/common-auth-embedded/claustrum/insula.js +6 -0
  78. package/src/common-auth-embedded/fs/refresh-file-lock.js +2 -2
  79. package/src/common-auth-embedded/fs/with-lock.js +37 -10
  80. package/src/common-auth-embedded/quota/format.d.ts +9 -4
  81. package/src/common-auth-embedded/quota/format.js +45 -26
  82. package/src/common-auth-embedded/quota-sidebar/index.d.ts +86 -0
  83. package/src/common-auth-embedded/quota-sidebar/index.tsx +654 -0
  84. package/src/common-auth-embedded/routing-accessor/index.d.ts +62 -0
  85. package/src/common-auth-embedded/routing-accessor/index.js +128 -0
  86. package/src/common-auth-embedded/source-output.json +69 -29
  87. package/src/tui-compiled/common-auth-embedded/quota/format.js +45 -26
  88. package/src/tui-compiled/common-auth-embedded/quota-sidebar/index.js +683 -0
  89. package/src/tui-compiled/tui/quota-layout.js +5 -330
  90. package/src/tui-compiled/tui/sidebar-frame.js +243 -467
  91. package/src/tui-compiled/tui.js +2 -2
  92. package/src/tui-ga-compiled/host-ga.js +2 -2
  93. package/src/tui-ga-compiled/shared/aef2402f8fc342f0-format.js +45 -26
  94. package/src/tui-ga-compiled/shared/ced204104a639c9c-sidebar-frame.js +243 -467
  95. package/src/tui-ga-compiled/shared/dd4c9e1a907f8ef0-quota-layout.js +5 -330
  96. package/src/tui-ga-compiled/shared/e4ec36f367492969-index.js +683 -0
  97. package/src/tui-ga-raw/host-ga.tsx +2 -2
  98. package/src/tui-ga-raw/shared/aef2402f8fc342f0-format.js +45 -26
  99. package/src/tui-ga-raw/shared/ced204104a639c9c-sidebar-frame.tsx +214 -400
  100. package/src/tui-ga-raw/shared/dd4c9e1a907f8ef0-quota-layout.tsx +10 -301
  101. package/src/tui-ga-raw/shared/e4ec36f367492969-index.tsx +654 -0
  102. package/src/tui-raw/common-auth-embedded/quota/format.js +45 -26
  103. package/src/tui-raw/common-auth-embedded/quota-sidebar/index.tsx +654 -0
  104. package/src/tui-raw/tui/quota-layout.tsx +10 -301
  105. package/src/tui-raw/tui/sidebar-frame.tsx +214 -400
  106. package/src/tui-raw/tui.tsx +2 -2
  107. package/src/tui.tsx +2 -2
package/dist/server.js CHANGED
@@ -7751,7 +7751,7 @@ async function rmEvictingDir(evictingPath) {
7751
7751
  });
7752
7752
  }
7753
7753
  async function sleep(ms) {
7754
- await new Promise((resolve27) => setTimeout(resolve27, ms));
7754
+ await new Promise((resolve28) => setTimeout(resolve28, ms));
7755
7755
  }
7756
7756
  async function acquireFencedFileLock(options) {
7757
7757
  const lockPath = `${options.path}.${options.name}.lock`;
@@ -7867,8 +7867,8 @@ function buildLock(lockPath, evictingPath, ownerId, options, now) {
7867
7867
  let released = false;
7868
7868
  let lost = false;
7869
7869
  let lostResolve = null;
7870
- let lostPromise = new Promise((resolve27) => {
7871
- lostResolve = resolve27;
7870
+ let lostPromise = new Promise((resolve28) => {
7871
+ lostResolve = resolve28;
7872
7872
  });
7873
7873
  const markLost = () => {
7874
7874
  if (lost)
@@ -7878,9 +7878,9 @@ function buildLock(lockPath, evictingPath, ownerId, options, now) {
7878
7878
  clearInterval(renewTimer);
7879
7879
  renewTimer = null;
7880
7880
  }
7881
- const resolve27 = lostResolve;
7881
+ const resolve28 = lostResolve;
7882
7882
  lostResolve = null;
7883
- resolve27?.();
7883
+ resolve28?.();
7884
7884
  };
7885
7885
  const setupRenew = () => {
7886
7886
  if (options.renew === false)
@@ -8503,7 +8503,7 @@ async function saveAccountStorageReplace(path5, incoming) {
8503
8503
  return mutateAccountStorage(path5, () => incoming);
8504
8504
  }
8505
8505
  async function clearAccountStorage(path5) {
8506
- const sleep5 = (ms) => new Promise((resolve27) => setTimeout(resolve27, ms));
8506
+ const sleep5 = (ms) => new Promise((resolve28) => setTimeout(resolve28, ms));
8507
8507
  const lock = await acquireWithRetry(path5, sleep5);
8508
8508
  try {
8509
8509
  await assertLegacyAccountStorageWritable(path5);
@@ -8551,7 +8551,7 @@ var init_account_storage = __esm({
8551
8551
  }
8552
8552
  };
8553
8553
  RETRY_DELAYS_MS = [100, 200, 400, 800, 1e3];
8554
- DEFAULT_SLEEP = (ms) => new Promise((resolve27) => setTimeout(resolve27, ms));
8554
+ DEFAULT_SLEEP = (ms) => new Promise((resolve28) => setTimeout(resolve28, ms));
8555
8555
  DEFAULT_BUILD_BACKUP_PATH = (path5, now) => `${path5}.corrupt-${now.toISOString().replace(/[:.]/g, "-")}`;
8556
8556
  }
8557
8557
  });
@@ -9753,8 +9753,8 @@ var init_account_manager = __esm({
9753
9753
  await this.saveInFlight;
9754
9754
  return;
9755
9755
  }
9756
- return new Promise((resolve27, reject) => {
9757
- this.savePromiseResolvers.push({ resolve: resolve27, reject });
9756
+ return new Promise((resolve28, reject) => {
9757
+ this.savePromiseResolvers.push({ resolve: resolve28, reject });
9758
9758
  });
9759
9759
  }
9760
9760
  async dispose() {
@@ -9797,8 +9797,8 @@ var init_account_manager = __esm({
9797
9797
  reject(error);
9798
9798
  throw error;
9799
9799
  }
9800
- for (const { resolve: resolve27 } of resolvers)
9801
- resolve27();
9800
+ for (const { resolve: resolve28 } of resolvers)
9801
+ resolve28();
9802
9802
  }
9803
9803
  async executeSave() {
9804
9804
  this.savePending = false;
@@ -9812,16 +9812,16 @@ var init_account_manager = __esm({
9812
9812
  }
9813
9813
  try {
9814
9814
  await this.saveToDisk();
9815
- for (const { resolve: resolve27 } of resolvers) {
9816
- resolve27();
9815
+ for (const { resolve: resolve28 } of resolvers) {
9816
+ resolve28();
9817
9817
  }
9818
9818
  } catch (error) {
9819
9819
  if (isStorageLockContention(error)) {
9820
9820
  this.onDiagnostic?.("Skipped account-state persist due to storage lock contention", {
9821
9821
  error: String(error)
9822
9822
  });
9823
- for (const { resolve: resolve27 } of resolvers) {
9824
- resolve27();
9823
+ for (const { resolve: resolve28 } of resolvers) {
9824
+ resolve28();
9825
9825
  }
9826
9826
  return;
9827
9827
  }
@@ -10310,7 +10310,7 @@ function getHttpsProxy(url) {
10310
10310
  }
10311
10311
  }
10312
10312
  function waitForHead(socket, timeoutMs, onTimeout) {
10313
- return new Promise((resolve27, reject) => {
10313
+ return new Promise((resolve28, reject) => {
10314
10314
  let buffer = Buffer3.alloc(0);
10315
10315
  const timeout = setTimeout(() => {
10316
10316
  onTimeout();
@@ -10333,7 +10333,7 @@ function waitForHead(socket, timeoutMs, onTimeout) {
10333
10333
  return;
10334
10334
  const head = buffer.subarray(0, marker).toString("latin1");
10335
10335
  const leftover = buffer.subarray(marker + 4);
10336
- cleanup2(() => resolve27({ head, leftover }));
10336
+ cleanup2(() => resolve28({ head, leftover }));
10337
10337
  };
10338
10338
  socket.on("data", onData);
10339
10339
  socket.once("error", onError);
@@ -10347,7 +10347,7 @@ async function connectViaProxy(proxyUrl, targetUrl, timeoutMs, signal, onDebug)
10347
10347
  port: Number(proxyUrl.port || DEFAULT_PROXY_PORT),
10348
10348
  signal: signal ?? void 0
10349
10349
  });
10350
- await new Promise((resolve27, reject) => {
10350
+ await new Promise((resolve28, reject) => {
10351
10351
  const timeout = setTimeout(() => {
10352
10352
  onDebug?.(`agy transport proxy connect timeout after ${timeoutMs}ms`);
10353
10353
  proxySocket.destroy();
@@ -10356,7 +10356,7 @@ async function connectViaProxy(proxyUrl, targetUrl, timeoutMs, signal, onDebug)
10356
10356
  const cleanup2 = () => clearTimeout(timeout);
10357
10357
  proxySocket.once("connect", () => {
10358
10358
  cleanup2();
10359
- resolve27();
10359
+ resolve28();
10360
10360
  });
10361
10361
  proxySocket.once("error", (error) => {
10362
10362
  cleanup2();
@@ -10381,7 +10381,7 @@ Host: ${targetHost}:${targetPort}\r
10381
10381
  if (leftover.length > 0) {
10382
10382
  proxySocket.unshift(leftover);
10383
10383
  }
10384
- return await new Promise((resolve27, reject) => {
10384
+ return await new Promise((resolve28, reject) => {
10385
10385
  const tlsOptions = {
10386
10386
  socket: proxySocket,
10387
10387
  servername: targetHost,
@@ -10396,7 +10396,7 @@ Host: ${targetHost}:${targetPort}\r
10396
10396
  const cleanup2 = () => clearTimeout(timeout);
10397
10397
  tlsSocket.once("secureConnect", () => {
10398
10398
  cleanup2();
10399
- resolve27(tlsSocket);
10399
+ resolve28(tlsSocket);
10400
10400
  });
10401
10401
  tlsSocket.once("error", (error) => {
10402
10402
  cleanup2();
@@ -10405,7 +10405,7 @@ Host: ${targetHost}:${targetPort}\r
10405
10405
  });
10406
10406
  }
10407
10407
  async function connectDirect(targetUrl, timeoutMs, signal, onDebug) {
10408
- return await new Promise((resolve27, reject) => {
10408
+ return await new Promise((resolve28, reject) => {
10409
10409
  const tlsOptions = {
10410
10410
  host: targetUrl.hostname,
10411
10411
  port: Number(targetUrl.port || DEFAULT_HTTPS_PORT),
@@ -10421,7 +10421,7 @@ async function connectDirect(targetUrl, timeoutMs, signal, onDebug) {
10421
10421
  const cleanup2 = () => clearTimeout(timeout);
10422
10422
  socket.once("secureConnect", () => {
10423
10423
  cleanup2();
10424
- resolve27(socket);
10424
+ resolve28(socket);
10425
10425
  });
10426
10426
  socket.once("error", (error) => {
10427
10427
  cleanup2();
@@ -11434,7 +11434,7 @@ function displayOrder(left, right) {
11434
11434
  return left.label < right.label ? -1 : left.label > right.label ? 1 : 0;
11435
11435
  }
11436
11436
  function quotaWindowParts(quota, options) {
11437
- const { windows: windows2, age } = scopedWindowParts(quota, options);
11437
+ const { windows: windows2, age } = scopedWindowParts(quota, options, true);
11438
11438
  const parts = windows2.map(({ part }) => part);
11439
11439
  return age === void 0 ? { windows: parts } : { windows: parts, age };
11440
11440
  }
@@ -11445,25 +11445,36 @@ function withShortNames(windows2) {
11445
11445
  }
11446
11446
  return windows2;
11447
11447
  }
11448
- function scopedWindowParts(quota, options) {
11448
+ function hasWindowReading(limit) {
11449
+ return Number.isFinite(limit.remainingPercent) && Number.isFinite(limit.checkedAt);
11450
+ }
11451
+ function scopedWindowParts(quota, options, includeUnknown = false) {
11449
11452
  if (!quota)
11450
11453
  return { windows: [] };
11451
11454
  const { now } = options;
11452
- const readings = quota.limits.filter((limit) => limit.kind === "reading" && limit.remainingPercent !== void 0).sort(displayOrder);
11455
+ const readings = quota.limits.filter((limit) => limit.kind === "reading" && (includeUnknown || hasWindowReading(limit))).sort(displayOrder);
11453
11456
  const windows2 = readings.map((limit) => {
11454
- const remainingPercent = clampPercent(limit.remainingPercent ?? 0);
11457
+ const part = hasWindowReading(limit) ? {
11458
+ kind: "window",
11459
+ reading: "known",
11460
+ name: quotaWindowName(limit),
11461
+ short: "",
11462
+ figure: percentLeft(limit.remainingPercent),
11463
+ remainingPercent: clampPercent(limit.remainingPercent),
11464
+ checkedAt: limit.checkedAt,
11465
+ ...resetDetails(limit.resetsAt, limit.checkedAt, now)
11466
+ } : {
11467
+ kind: "window",
11468
+ reading: "unknown",
11469
+ name: quotaWindowName(limit),
11470
+ short: "",
11471
+ figure: "no reading",
11472
+ resetSinceReading: false
11473
+ };
11455
11474
  return {
11456
11475
  scope: limit.scope,
11457
11476
  ...limit.windowMinutes === void 0 ? {} : { windowMinutes: limit.windowMinutes },
11458
- part: {
11459
- kind: "window",
11460
- name: quotaWindowName(limit),
11461
- short: "",
11462
- figure: percentLeft(limit.remainingPercent ?? 0),
11463
- remainingPercent,
11464
- checkedAt: limit.checkedAt,
11465
- ...resetDetails(limit.resetsAt, limit.checkedAt, now)
11466
- }
11477
+ part
11467
11478
  };
11468
11479
  });
11469
11480
  const budget = quota.budget;
@@ -11475,6 +11486,7 @@ function scopedWindowParts(quota, options) {
11475
11486
  spent: budget.reached,
11476
11487
  part: {
11477
11488
  kind: "budget",
11489
+ reading: "known",
11478
11490
  name: "credits",
11479
11491
  short: "",
11480
11492
  figure,
@@ -11485,8 +11497,9 @@ function scopedWindowParts(quota, options) {
11485
11497
  });
11486
11498
  }
11487
11499
  withShortNames(windows2);
11488
- if (windows2.length > 0) {
11489
- const age = now - Math.min(...windows2.map(({ part }) => part.checkedAt));
11500
+ const readingTimes = windows2.flatMap(({ part }) => part.reading === "known" && part.checkedAt !== void 0 ? [part.checkedAt] : []);
11501
+ if (readingTimes.length > 0) {
11502
+ const age = now - Math.min(...readingTimes);
11490
11503
  if (age > (options.staleAfterMs ?? QUOTA_STALE_AFTER_MS)) {
11491
11504
  return { windows: windows2, age: `checked ${shortSpan(age)} ago` };
11492
11505
  }
@@ -11585,13 +11598,13 @@ function narrowTextParts(quota, options) {
11585
11598
  function quotaTextParts(quota, options) {
11586
11599
  if (options.form === "narrow")
11587
11600
  return narrowTextParts(quota, options);
11588
- const parts = quotaWindowParts(quota, options);
11601
+ const { windows: windows2, age } = scopedWindowParts(quota, options);
11589
11602
  const full = (options.form ?? "full") === "full";
11590
- const text2 = parts.windows.map((part) => {
11603
+ const text2 = windows2.map(({ part }) => {
11591
11604
  const reset = full && part.resetIn ? `, resets ${part.resetIn}` : "";
11592
11605
  return `${part.kind === "budget" ? "" : `${part.name} `}${part.figure}${reset}`;
11593
11606
  });
11594
- return parts.age === void 0 ? text2 : [...text2, parts.age];
11607
+ return age === void 0 ? text2 : [...text2, age];
11595
11608
  }
11596
11609
  function formatQuota(quota, options) {
11597
11610
  const parts = quotaTextParts(quota, options);
@@ -12494,8 +12507,8 @@ async function acquireRefreshFileLockWithClock(options) {
12494
12507
  let releaseConfirmed = false;
12495
12508
  let loss;
12496
12509
  let resolveLoss;
12497
- const lostPromise = new Promise((resolve27) => {
12498
- resolveLoss = resolve27;
12510
+ const lostPromise = new Promise((resolve28) => {
12511
+ resolveLoss = resolve28;
12499
12512
  });
12500
12513
  function notifyTimerStep(event) {
12501
12514
  try {
@@ -12656,7 +12669,7 @@ async function acquireRefreshFileLockWithClock(options) {
12656
12669
  }
12657
12670
  }
12658
12671
  async function backoff() {
12659
- await new Promise((resolve27) => setTimeout(resolve27, Math.floor(Math.random() * 4)));
12672
+ await new Promise((resolve28) => setTimeout(resolve28, Math.floor(Math.random() * 4)));
12660
12673
  }
12661
12674
  async function readLockState(notifyReady = true) {
12662
12675
  if (notifyReady && options.onStep)
@@ -13146,7 +13159,7 @@ async function acquireRefreshFileLockWithClock(options) {
13146
13159
  const remainingMs = deadline - performance.now();
13147
13160
  if (remainingMs <= 0)
13148
13161
  break;
13149
- await new Promise((resolve27) => setTimeout(resolve27, Math.min(delayMs, remainingMs)));
13162
+ await new Promise((resolve28) => setTimeout(resolve28, Math.min(delayMs, remainingMs)));
13150
13163
  delayMs = Math.min(delayMs * 2, 50);
13151
13164
  }
13152
13165
  if (windowsPrivateFiles)
@@ -13169,21 +13182,37 @@ var init_refresh_file_lock = __esm({
13169
13182
  });
13170
13183
 
13171
13184
  // ../core/dist/common-auth-embedded/fs/with-lock.js
13185
+ import { join as join6, resolve as resolve3 } from "node:path";
13172
13186
  function lockPathFor(target, name) {
13173
13187
  return `${target}.${name}.lock`;
13174
13188
  }
13189
+ function isChangingLockRead(error, target, name) {
13190
+ if (!windowsPrivateFiles || !(error instanceof PrivateFileError) || error.reason !== "io-error" || error.win32Code !== 32 && error.win32Code !== 303 || error.stage !== "read" && error.stage !== "verify")
13191
+ return false;
13192
+ const path5 = resolve3(lockPathFor(target, name));
13193
+ return error.path === path5 || error.path === join6(path5, "owner.json");
13194
+ }
13175
13195
  async function withLock(target, options, fn) {
13176
13196
  const started = performance.now();
13177
13197
  for (; ; ) {
13178
13198
  options.signal?.throwIfAborted();
13179
- const lock = await acquireRefreshFileLock({
13180
- path: target,
13181
- name: options.name,
13182
- ttlMs: options.ttlMs,
13183
- renew: options.renew ?? false,
13184
- ...options.onStep ? { onStep: options.onStep } : {},
13185
- ...options.onRenewalTimer ? { onRenewalTimer: options.onRenewalTimer } : {}
13186
- });
13199
+ let lock;
13200
+ let changingReadError;
13201
+ try {
13202
+ lock = await acquireRefreshFileLock({
13203
+ path: target,
13204
+ name: options.name,
13205
+ ttlMs: options.ttlMs,
13206
+ renew: options.renew ?? false,
13207
+ ...options.onStep ? { onStep: options.onStep } : {},
13208
+ ...options.onRenewalTimer ? { onRenewalTimer: options.onRenewalTimer } : {}
13209
+ });
13210
+ } catch (error) {
13211
+ if (!isChangingLockRead(error, target, options.name))
13212
+ throw error;
13213
+ lock = null;
13214
+ changingReadError = error;
13215
+ }
13187
13216
  if (lock) {
13188
13217
  try {
13189
13218
  options.signal?.throwIfAborted();
@@ -13194,19 +13223,22 @@ async function withLock(target, options, fn) {
13194
13223
  }
13195
13224
  const remaining = options.timeoutMs - (performance.now() - started);
13196
13225
  if (remaining <= 0) {
13226
+ if (changingReadError)
13227
+ throw changingReadError;
13197
13228
  throw new LockContentionError({
13198
13229
  target,
13199
13230
  name: options.name,
13200
13231
  timeoutMs: options.timeoutMs
13201
13232
  });
13202
13233
  }
13203
- await new Promise((resolve27) => setTimeout(resolve27, Math.min(25, Math.ceil(remaining))));
13234
+ await new Promise((resolve28) => setTimeout(resolve28, Math.min(25, Math.ceil(remaining))));
13204
13235
  }
13205
13236
  }
13206
13237
  var LockContentionError, LockOwnershipError;
13207
13238
  var init_with_lock = __esm({
13208
13239
  "../core/dist/common-auth-embedded/fs/with-lock.js"() {
13209
13240
  "use strict";
13241
+ init_private_files();
13210
13242
  init_refresh_file_lock();
13211
13243
  LockContentionError = class extends Error {
13212
13244
  details;
@@ -13319,7 +13351,7 @@ async function acquirePoolLock(spec, defaults, env3) {
13319
13351
  });
13320
13352
  }
13321
13353
  const jitter = Math.floor(Math.random() * (options.retryMs + 1));
13322
- await new Promise((resolve27) => setTimeout(resolve27, Math.min(options.retryMs + jitter, remaining)));
13354
+ await new Promise((resolve28) => setTimeout(resolve28, Math.min(options.retryMs + jitter, remaining)));
13323
13355
  }
13324
13356
  }
13325
13357
  function definedOnly(spec) {
@@ -16163,7 +16195,7 @@ var init_redact = __esm({
16163
16195
  // ../core/dist/common-auth-embedded/logger/engine.js
16164
16196
  import { appendFileSync, chmodSync, existsSync, renameSync, statSync } from "node:fs";
16165
16197
  import { open as open5 } from "node:fs/promises";
16166
- import { dirname as dirname8, resolve as resolve3 } from "node:path";
16198
+ import { dirname as dirname8, resolve as resolve4 } from "node:path";
16167
16199
  function chmodPrivate(path5) {
16168
16200
  try {
16169
16201
  chmodSync(path5, 384);
@@ -16214,7 +16246,7 @@ async function openWindowsFile(sink, file) {
16214
16246
  return sink.handle;
16215
16247
  }
16216
16248
  async function flushWindowsFile(sink, file, text2) {
16217
- file = resolve3(file);
16249
+ file = resolve4(file);
16218
16250
  try {
16219
16251
  if (sink.file !== file)
16220
16252
  await closeWindowsFile(sink);
@@ -16361,7 +16393,7 @@ function createEngine(options) {
16361
16393
  });
16362
16394
  }, 500);
16363
16395
  }
16364
- function emit(channel, level, message, data) {
16396
+ function emit(channel3, level, message, data) {
16365
16397
  if (logFileSource === void 0 && captureSink === void 0)
16366
16398
  return;
16367
16399
  try {
@@ -16374,10 +16406,10 @@ function createEngine(options) {
16374
16406
  } catch {
16375
16407
  scrubbedData = "[unserializable]";
16376
16408
  }
16377
- const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${level.toUpperCase()} [${channel}] ${scrubbedMessage}` + (data === void 0 ? "" : safeSerialize(scrubbedData)) + "\n";
16409
+ const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${level.toUpperCase()} [${channel3}] ${scrubbedMessage}` + (data === void 0 ? "" : safeSerialize(scrubbedData)) + "\n";
16378
16410
  try {
16379
16411
  captureSink?.({
16380
- channel,
16412
+ channel: channel3,
16381
16413
  level,
16382
16414
  message: scrubbedMessage,
16383
16415
  data: scrubbedData
@@ -16397,13 +16429,13 @@ function createEngine(options) {
16397
16429
  } catch {
16398
16430
  }
16399
16431
  }
16400
- function createLogger5(channel) {
16432
+ function createLogger5(channel3) {
16401
16433
  return {
16402
- error: (m, d) => emit(channel, "error", m, d),
16403
- warn: (m, d) => emit(channel, "warn", m, d),
16404
- info: (m, d) => emit(channel, "info", m, d),
16405
- debug: (m, d) => emit(channel, "debug", m, d),
16406
- trace: (m, d) => emit(channel, "trace", m, d)
16434
+ error: (m, d) => emit(channel3, "error", m, d),
16435
+ warn: (m, d) => emit(channel3, "warn", m, d),
16436
+ info: (m, d) => emit(channel3, "info", m, d),
16437
+ debug: (m, d) => emit(channel3, "debug", m, d),
16438
+ trace: (m, d) => emit(channel3, "trace", m, d)
16407
16439
  };
16408
16440
  }
16409
16441
  function reset() {
@@ -16441,8 +16473,8 @@ function setLogLevel(l) {
16441
16473
  function flushLogs() {
16442
16474
  return defaultEngine.flushLogs();
16443
16475
  }
16444
- function createLogger2(channel) {
16445
- return defaultEngine.createLogger(channel);
16476
+ function createLogger2(channel3) {
16477
+ return defaultEngine.createLogger(channel3);
16446
16478
  }
16447
16479
  async function flushForTest() {
16448
16480
  return defaultEngine.flushLogs();
@@ -16590,11 +16622,11 @@ var init_quota_writer = __esm({
16590
16622
  const left = deadline - performance.now();
16591
16623
  if (left <= 0)
16592
16624
  throw refusal2("pull", id, "lock-contention", `pool quota queue for ${id} is full (${POOL_QUOTA_QUEUE_LIMIT} readings) and the store locks stayed held`, true);
16593
- await new Promise((resolve27) => {
16625
+ await new Promise((resolve28) => {
16594
16626
  const done = () => {
16595
16627
  clearTimeout(timer);
16596
16628
  this.wake.delete(done);
16597
- resolve27();
16629
+ resolve28();
16598
16630
  };
16599
16631
  const timer = setTimeout(done, left);
16600
16632
  this.wake.add(done);
@@ -16987,7 +17019,7 @@ var init_refresh = __esm({
16987
17019
 
16988
17020
  // ../core/dist/common-auth-embedded/fs/file-read-cache.js
16989
17021
  import { lstat as lstat4 } from "node:fs/promises";
16990
- import { resolve as resolve4 } from "node:path";
17022
+ import { resolve as resolve5 } from "node:path";
16991
17023
  async function identity(path5) {
16992
17024
  try {
16993
17025
  const metadata = await lstat4(path5);
@@ -17008,7 +17040,7 @@ var init_file_read_cache = __esm({
17008
17040
  FileReadCache = class {
17009
17041
  #entries = /* @__PURE__ */ new Map();
17010
17042
  async read(paths, read, validateHit) {
17011
- const resolvedPaths = paths.map((path5) => resolve4(path5));
17043
+ const resolvedPaths = paths.map((path5) => resolve5(path5));
17012
17044
  const key = JSON.stringify(resolvedPaths);
17013
17045
  const probed = await Promise.all(resolvedPaths.map(identity));
17014
17046
  const identities = probed.every((entry) => entry !== void 0) ? probed : void 0;
@@ -19365,7 +19397,7 @@ async function select(terminal, items, options) {
19365
19397
  writeLine("");
19366
19398
  renderedLines = lines;
19367
19399
  };
19368
- return new Promise((resolve27) => {
19400
+ return new Promise((resolve28) => {
19369
19401
  const wasRaw = stdin.isRaw ?? false;
19370
19402
  const cleanup2 = () => {
19371
19403
  if (cleaned)
@@ -19385,7 +19417,7 @@ async function select(terminal, items, options) {
19385
19417
  };
19386
19418
  const finish = (value) => {
19387
19419
  cleanup2();
19388
- resolve27(value);
19420
+ resolve28(value);
19389
19421
  };
19390
19422
  const onSignal = () => finish(null);
19391
19423
  const onKey = (data) => {
@@ -19425,7 +19457,7 @@ async function select(terminal, items, options) {
19425
19457
  stdin.setRawMode(true);
19426
19458
  } catch {
19427
19459
  cleanup2();
19428
- resolve27(null);
19460
+ resolve28(null);
19429
19461
  return;
19430
19462
  }
19431
19463
  stdin.resume();
@@ -20267,7 +20299,7 @@ var init_watch = __esm({
20267
20299
  });
20268
20300
 
20269
20301
  // ../core/dist/common-auth-embedded/claustrum/insula.js
20270
- import { resolve as resolve5 } from "node:path";
20302
+ import { resolve as resolve6 } from "node:path";
20271
20303
  import { storeIdentity } from "@cortexkit/claustrum-client";
20272
20304
  import { SubcClient } from "@cortexkit/subc-client";
20273
20305
  function insulaUsageTransport(options) {
@@ -20395,8 +20427,8 @@ function refusalCode(error) {
20395
20427
  }
20396
20428
  function acquireInsulaQuotaSource(transport, tokenPath) {
20397
20429
  const key = JSON.stringify([
20398
- resolve5(transport.connectionFile),
20399
- resolve5(tokenPath)
20430
+ resolve6(transport.connectionFile),
20431
+ resolve6(tokenPath)
20400
20432
  ]);
20401
20433
  let shared4 = sources.get(key);
20402
20434
  if (!shared4) {
@@ -20650,6 +20682,8 @@ var init_insula = __esm({
20650
20682
  ...typeof entry.source === "string" && { source: entry.source }
20651
20683
  }
20652
20684
  };
20685
+ if (entry.stale !== void 0 && (!record2(entry.stale) || entry.stale.class !== "local_source_unavailable"))
20686
+ return { miss: "upstream-failed", reading };
20653
20687
  return now >= fetchedAt + MAX_AGE || entry.stale !== void 0 ? { miss: "stale", reading } : { reading };
20654
20688
  }
20655
20689
  if (this.#completeProviders.has(provider2))
@@ -20708,7 +20742,7 @@ var init_any_signal = __esm({
20708
20742
  import { createHash as createHash6, randomBytes as randomBytes4, randomUUID as randomUUID12 } from "node:crypto";
20709
20743
  import { constants as fsConstants } from "node:fs";
20710
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";
20711
- 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";
20712
20746
  import { ClaustrumCredentialError as ClaustrumCredentialError2, ClaustrumClient as ClaustrumWireClient, writeEnrollmentTokenFile } from "@cortexkit/claustrum-client";
20713
20747
  function classifyEnrollmentError(error) {
20714
20748
  if (!(error instanceof ClaustrumCredentialError2))
@@ -20734,7 +20768,7 @@ function getClaustrumEnrollmentPaths(tokenPath) {
20734
20768
  const extension = extname(tokenPath) || ".json";
20735
20769
  const stem = basename3(tokenPath, extname(tokenPath));
20736
20770
  return {
20737
- statePath: join6(dirname9(tokenPath), `${stem}-state${extension}`),
20771
+ statePath: join7(dirname9(tokenPath), `${stem}-state${extension}`),
20738
20772
  tokenPath
20739
20773
  };
20740
20774
  }
@@ -20742,7 +20776,7 @@ function hostEnrollmentPaths(input2) {
20742
20776
  const override = input2.override?.trim();
20743
20777
  if (override && !isAbsolute2(override) && !input2.cwd)
20744
20778
  throw new ClaustrumConsumerError("invalid-state", "A relative Claustrum enrollment override needs a base directory");
20745
- 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`);
20746
20780
  return getClaustrumEnrollmentPaths(tokenPath);
20747
20781
  }
20748
20782
  function isRecord6(value) {
@@ -20975,7 +21009,7 @@ async function writeStateAtomic(path5, state, ancestorOptions = {}) {
20975
21009
  }
20976
21010
  if (windowsPrivateFiles)
20977
21011
  return writePrivateAtomic(path5, bytes);
20978
- const temporary = join6(parent, `.${basename3(path5)}.${process.pid}.${randomUUID12()}.tmp`);
21012
+ const temporary = join7(parent, `.${basename3(path5)}.${process.pid}.${randomUUID12()}.tmp`);
20979
21013
  let descriptor;
20980
21014
  let created = false;
20981
21015
  try {
@@ -21471,10 +21505,10 @@ async function drainShutdown(pending, onTimeout) {
21471
21505
  try {
21472
21506
  await Promise.race([
21473
21507
  drained,
21474
- new Promise((resolve27) => {
21508
+ new Promise((resolve28) => {
21475
21509
  timer = setTimeout(() => {
21476
21510
  expired = true;
21477
- resolve27();
21511
+ resolve28();
21478
21512
  }, 2e3);
21479
21513
  })
21480
21514
  ]);
@@ -21492,6 +21526,7 @@ var init_shutdown = __esm({
21492
21526
  });
21493
21527
 
21494
21528
  // ../core/dist/common-auth-embedded/claustrum/custody.js
21529
+ import { channel } from "node:diagnostics_channel";
21495
21530
  import { ClaustrumCredentialError as ClaustrumCredentialError3 } from "@cortexkit/claustrum-client";
21496
21531
  function isScopedCredentialRotation(served, current) {
21497
21532
  return current !== void 0 && !current.fromKeptReceipt && !served.fromKeptReceipt && current.credentialId === served.credentialId && current.accountIdentity === served.accountIdentity && current.recordVersion !== served.recordVersion;
@@ -21605,7 +21640,7 @@ function grantReachOf(listed) {
21605
21640
  tuples: Object.freeze(grantTuples.map(({ selectorKind, selector, operation }) => Object.freeze({ selectorKind, selector, operation })))
21606
21641
  });
21607
21642
  }
21608
- var defaultLogger, SERVING_MARGIN_MS, KEPT_RECEIPT_MARGIN_MS, ClaustrumScopedCustody;
21643
+ var defaultLogger, phaseDiagnostics, SERVING_MARGIN_MS, KEPT_RECEIPT_MARGIN_MS, ClaustrumScopedCustody;
21609
21644
  var init_custody = __esm({
21610
21645
  "../core/dist/common-auth-embedded/claustrum/custody.js"() {
21611
21646
  "use strict";
@@ -21617,6 +21652,7 @@ var init_custody = __esm({
21617
21652
  init_shutdown();
21618
21653
  init_watch();
21619
21654
  defaultLogger = createLogger2("claustrum");
21655
+ phaseDiagnostics = channel("common-auth.claustrum.phases");
21620
21656
  SERVING_MARGIN_MS = 3e5;
21621
21657
  KEPT_RECEIPT_MARGIN_MS = 6e4;
21622
21658
  ClaustrumScopedCustody = class {
@@ -21720,6 +21756,11 @@ var init_custody = __esm({
21720
21756
  }
21721
21757
  async #token(signal) {
21722
21758
  this.#check(signal);
21759
+ if (phaseDiagnostics.hasSubscribers)
21760
+ phaseDiagnostics.publish({
21761
+ logger: this.#logger,
21762
+ phase: "token read begin"
21763
+ });
21723
21764
  const pending = this.#readToken();
21724
21765
  this.#tokenReads.add(pending);
21725
21766
  let value;
@@ -21727,6 +21768,11 @@ var init_custody = __esm({
21727
21768
  value = await pending;
21728
21769
  } finally {
21729
21770
  this.#tokenReads.delete(pending);
21771
+ if (phaseDiagnostics.hasSubscribers)
21772
+ phaseDiagnostics.publish({
21773
+ logger: this.#logger,
21774
+ phase: "token read end"
21775
+ });
21730
21776
  }
21731
21777
  this.#check(signal);
21732
21778
  if (!/^[0-9a-f]{64}$/.test(value.token) || !Number.isSafeInteger(value.token_generation) || value.token_generation < 1) {
@@ -21788,11 +21834,22 @@ var init_custody = __esm({
21788
21834
  this.#kept.clear();
21789
21835
  throw error;
21790
21836
  }
21837
+ if (phaseDiagnostics.hasSubscribers)
21838
+ phaseDiagnostics.publish({
21839
+ logger: this.#logger,
21840
+ phase: "list scoped begin"
21841
+ });
21791
21842
  try {
21792
21843
  inventory = await this.#call(() => this.#client.listScoped(token), signal);
21793
21844
  } catch (error) {
21794
21845
  this.listFailed(error);
21795
21846
  throw error;
21847
+ } finally {
21848
+ if (phaseDiagnostics.hasSubscribers)
21849
+ phaseDiagnostics.publish({
21850
+ logger: this.#logger,
21851
+ phase: "list scoped end"
21852
+ });
21796
21853
  }
21797
21854
  const skipped = [];
21798
21855
  const refused2 = [];
@@ -22221,7 +22278,7 @@ var init_interlock = __esm({
22221
22278
  // ../core/dist/common-auth-embedded/claustrum/roster.js
22222
22279
  import { createHash as createHash7 } from "node:crypto";
22223
22280
  import { stat as stat5 } from "node:fs/promises";
22224
- import { resolve as resolve7 } from "node:path";
22281
+ import { resolve as resolve8 } from "node:path";
22225
22282
  function vaultRosterSeed(roster) {
22226
22283
  return {
22227
22284
  declined: roster.declined.map((entry) => ({ ...entry })),
@@ -22608,16 +22665,16 @@ function applyVaultQuota(current, input2) {
22608
22665
  };
22609
22666
  }
22610
22667
  function forgetPendingVaultDiscovery(path5) {
22611
- pendingDiscoveries.delete(resolve7(path5));
22668
+ pendingDiscoveries.delete(resolve8(path5));
22612
22669
  }
22613
22670
  function isVaultRosterLockRefusal(path5, error) {
22614
- const target = resolve7(path5);
22671
+ const target = resolve8(path5);
22615
22672
  if (error instanceof ClaustrumConsumerError)
22616
22673
  return error.kind === "roster-busy";
22617
22674
  if (error instanceof LockContentionError || error instanceof LockOwnershipError)
22618
- return resolve7(error.details.target) === target;
22675
+ return resolve8(error.details.target) === target;
22619
22676
  if (error instanceof PrivateFileError) {
22620
- const failed = resolve7(error.path);
22677
+ const failed = resolve8(error.path);
22621
22678
  return [WRITE_LOCK.name, DISCOVERY_LEASE.name].some((name) => {
22622
22679
  const lock = lockPathFor(target, name);
22623
22680
  return failed === lock || failed.startsWith(`${lock}.`);
@@ -22678,7 +22735,7 @@ async function refreshVaultRoster(options) {
22678
22735
  throw new ClaustrumConsumerError("roster-busy", "Claustrum account discovery is already in progress");
22679
22736
  return persisted;
22680
22737
  }
22681
- const key = resolve7(options.path);
22738
+ const key = resolve8(options.path);
22682
22739
  const listedOver = options.listedOver;
22683
22740
  let discovered;
22684
22741
  try {
@@ -22798,9 +22855,9 @@ var init_roster = __esm({
22798
22855
  });
22799
22856
 
22800
22857
  // ../core/dist/common-auth-embedded/claustrum/quota-writer.js
22801
- import { resolve as resolve8 } from "node:path";
22858
+ import { resolve as resolve9 } from "node:path";
22802
22859
  function writerFor(path5, clock2 = quotaCommitTimer) {
22803
- const key = resolve8(path5);
22860
+ const key = resolve9(path5);
22804
22861
  let writer = writers.get(key);
22805
22862
  if (!writer) {
22806
22863
  writer = {
@@ -22864,7 +22921,7 @@ function orderedFields(pending) {
22864
22921
  return [...pending.values()].flatMap((account) => [...account.values()]).sort((a, b) => a.order - b.order);
22865
22922
  }
22866
22923
  function pendingVaultQuota(path5, roster) {
22867
- const writer = writers.get(resolve8(path5));
22924
+ const writer = writers.get(resolve9(path5));
22868
22925
  if (writer) {
22869
22926
  for (const field of orderedFields(writer.pending)) {
22870
22927
  if (field.priorReading)
@@ -22875,7 +22932,7 @@ function pendingVaultQuota(path5, roster) {
22875
22932
  return roster;
22876
22933
  }
22877
22934
  function hasPendingVaultQuota(path5) {
22878
- return !!writers.get(resolve8(path5))?.pending.size;
22935
+ return !!writers.get(resolve9(path5))?.pending.size;
22879
22936
  }
22880
22937
  function schedule(writer, delay3) {
22881
22938
  if (writer.running || writer.timer || !writer.pending.size || writer.abort.signal.aborted)
@@ -22940,7 +22997,7 @@ function flush(writer) {
22940
22997
  return writer.running;
22941
22998
  }
22942
22999
  async function drainVaultQuota(path5, timeoutMs = 1e3) {
22943
- const key = resolve8(path5);
23000
+ const key = resolve9(path5);
22944
23001
  const writer = writers.get(key);
22945
23002
  if (!writer)
22946
23003
  return;
@@ -23085,7 +23142,7 @@ var init_consumer = __esm({
23085
23142
  this.#shutdown.signal,
23086
23143
  ...signal ? [signal] : []
23087
23144
  ]);
23088
- return new Promise((resolve27, reject) => {
23145
+ return new Promise((resolve28, reject) => {
23089
23146
  const cleanup2 = () => {
23090
23147
  combined.signal.removeEventListener("abort", abort);
23091
23148
  combined.dispose();
@@ -23100,7 +23157,7 @@ var init_consumer = __esm({
23100
23157
  if (combined.signal.aborted)
23101
23158
  reject(combined.signal.reason);
23102
23159
  else
23103
- resolve27(value);
23160
+ resolve28(value);
23104
23161
  }, (error) => {
23105
23162
  cleanup2();
23106
23163
  reject(error);
@@ -23812,8 +23869,9 @@ var init_consumer = __esm({
23812
23869
 
23813
23870
  // ../core/dist/common-auth-embedded/claustrum/hub.js
23814
23871
  import { createHash as createHash8 } from "node:crypto";
23872
+ import { channel as channel2 } from "node:diagnostics_channel";
23815
23873
  import { readdir, stat as stat6 } from "node:fs/promises";
23816
- 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";
23817
23875
  function canonicalJson3(value, path5 = /* @__PURE__ */ new Set()) {
23818
23876
  if (value === null)
23819
23877
  return "null";
@@ -23874,12 +23932,12 @@ function unreachableConnect2() {
23874
23932
  return new ClaustrumUnreachableError();
23875
23933
  }
23876
23934
  function untilAborted(pending, signal) {
23877
- return new Promise((resolve27, reject) => {
23935
+ return new Promise((resolve28, reject) => {
23878
23936
  const abort = () => reject(signal.reason);
23879
23937
  signal.addEventListener("abort", abort, { once: true });
23880
23938
  pending.then((value) => {
23881
23939
  signal.removeEventListener("abort", abort);
23882
- resolve27(value);
23940
+ resolve28(value);
23883
23941
  }, (error) => {
23884
23942
  signal.removeEventListener("abort", abort);
23885
23943
  reject(error);
@@ -23949,13 +24007,13 @@ var init_hub = __esm({
23949
24007
  this.#options = options;
23950
24008
  this.#logger = options.logger ?? createLogger2("claustrum");
23951
24009
  this.#warnShutdown = shutdownWarning(this.#logger, this.#shutdown.signal);
23952
- this.#generationDirectory = join7(options.stateDir, "rosters", hostGeneration);
24010
+ this.#generationDirectory = join8(options.stateDir, "rosters", hostGeneration);
23953
24011
  this.#key = rosterFingerprint(options, providers);
23954
- const directory = join7(this.#generationDirectory, this.#key);
24012
+ const directory = join8(this.#generationDirectory, this.#key);
23955
24013
  for (const provider2 of providers)
23956
24014
  this.#members.set(provider2, {
23957
24015
  provider: provider2,
23958
- path: join7(directory, `${provider2}.json`),
24016
+ path: join8(directory, `${provider2}.json`),
23959
24017
  closed: false
23960
24018
  });
23961
24019
  }
@@ -24036,7 +24094,7 @@ var init_hub = __esm({
24036
24094
  };
24037
24095
  const { consumer, hooks } = createHubMember(port, consumerOptions);
24038
24096
  entry.hooks = hooks;
24039
- const path5 = resolve9(entry.path);
24097
+ const path5 = resolve10(entry.path);
24040
24098
  const subscribers = sharedRosters.get(path5) ?? /* @__PURE__ */ new Set();
24041
24099
  const install = (roster) => {
24042
24100
  if (entry.closed || this.#active !== true || !this.#current || !this.#live(this.#current) || !hooks.roster() || this.#collides(hooks, roster))
@@ -24067,7 +24125,7 @@ var init_hub = __esm({
24067
24125
  return;
24068
24126
  entry.seen = JSON.stringify(decodedVaultRoster(roster));
24069
24127
  entry.hooks?.install(roster);
24070
- for (const install of sharedRosters.get(resolve9(entry.path)) ?? []) {
24128
+ for (const install of sharedRosters.get(resolve10(entry.path)) ?? []) {
24071
24129
  if (!this.#live(generation))
24072
24130
  return;
24073
24131
  if (install !== entry.receiveRoster)
@@ -24478,7 +24536,24 @@ var init_hub = __esm({
24478
24536
  throw closed("Claustrum hub member has no base view");
24479
24537
  if (base instanceof Error)
24480
24538
  throw base;
24481
- const seed = base.file ? void 0 : await this.#seed(entry);
24539
+ let seed;
24540
+ if (!base.file) {
24541
+ const phaseDiagnostics2 = channel2("common-auth.claustrum.phases");
24542
+ if (phaseDiagnostics2.hasSubscribers)
24543
+ phaseDiagnostics2.publish({
24544
+ logger: this.#logger,
24545
+ phase: `seed read ${entry.provider} begin`
24546
+ });
24547
+ try {
24548
+ seed = await this.#seed(entry);
24549
+ } finally {
24550
+ if (phaseDiagnostics2.hasSubscribers)
24551
+ phaseDiagnostics2.publish({
24552
+ logger: this.#logger,
24553
+ phase: `seed read ${entry.provider} end`
24554
+ });
24555
+ }
24556
+ }
24482
24557
  const roster = await refreshVaultRoster({
24483
24558
  path: entry.path,
24484
24559
  custody: { discover: async () => share },
@@ -24506,7 +24581,7 @@ var init_hub = __esm({
24506
24581
  for (const directory of [
24507
24582
  dirname10(this.#generationDirectory),
24508
24583
  this.#generationDirectory,
24509
- join7(this.#generationDirectory, this.#key)
24584
+ join8(this.#generationDirectory, this.#key)
24510
24585
  ])
24511
24586
  await ensureClaustrumPrivateDirectory(directory, {}, "roster directory");
24512
24587
  }
@@ -24518,11 +24593,11 @@ var init_hub = __esm({
24518
24593
  */
24519
24594
  async #seed(entry) {
24520
24595
  const name = `${entry.provider}.json`;
24521
- const candidates = [join7(this.#generationDirectory, name)];
24596
+ const candidates = [join8(this.#generationDirectory, name)];
24522
24597
  try {
24523
24598
  for (const key of await readdir(this.#generationDirectory))
24524
24599
  if (key !== this.#key && FINGERPRINT.test(key))
24525
- candidates.push(join7(this.#generationDirectory, key, name));
24600
+ candidates.push(join8(this.#generationDirectory, key, name));
24526
24601
  } catch {
24527
24602
  }
24528
24603
  let newest;
@@ -25095,7 +25170,7 @@ var init_lock = __esm({
25095
25170
  import { createHash as createHash9 } from "node:crypto";
25096
25171
  import { constants as constants2 } from "node:fs";
25097
25172
  import { lstat as lstat5, mkdir as mkdir10, open as open7, unlink as unlink7 } from "node:fs/promises";
25098
- import { dirname as dirname11, resolve as resolve10 } from "node:path";
25173
+ import { dirname as dirname11, resolve as resolve11 } from "node:path";
25099
25174
  import { setTimeout as sleep2 } from "node:timers/promises";
25100
25175
  function rootSpans(text2) {
25101
25176
  let i = text2.indexOf("{") + 1;
@@ -25296,8 +25371,8 @@ function createPiSlot(options, onStep, hooks) {
25296
25371
  if (!provider2 || !options.authPath || !options.stashPath || !placeholderKey || placeholderKey.startsWith("!") || placeholderKey.includes("$") || !Number.isFinite(timeout) || timeout < 0) {
25297
25372
  throw new PiSlotError("invalid-options");
25298
25373
  }
25299
- const authPath = resolve10(options.authPath);
25300
- const stashPath = resolve10(options.stashPath);
25374
+ const authPath = resolve11(options.authPath);
25375
+ const stashPath = resolve11(options.stashPath);
25301
25376
  if (authPath === stashPath || stashPath === `${authPath}.lock`) {
25302
25377
  throw new PiSlotError("invalid-options");
25303
25378
  }
@@ -25730,15 +25805,15 @@ var init_model_types = __esm({
25730
25805
 
25731
25806
  // ../core/dist/pi-paths.js
25732
25807
  import { homedir } from "node:os";
25733
- import { dirname as dirname12, join as join8 } from "node:path";
25808
+ import { dirname as dirname12, join as join9 } from "node:path";
25734
25809
  function getPiConfigDir() {
25735
- return process.env.PI_AGENT_DIR?.trim() || join8(homedir(), ".pi", "agent");
25810
+ return process.env.PI_AGENT_DIR?.trim() || join9(homedir(), ".pi", "agent");
25736
25811
  }
25737
25812
  function getPiAntigravityAuthFile() {
25738
- 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");
25739
25814
  }
25740
25815
  function getPiAntigravityVaultDir() {
25741
- return join8(dirname12(getPiAntigravityAuthFile()), "antigravity-auth-vault");
25816
+ return join9(dirname12(getPiAntigravityAuthFile()), "antigravity-auth-vault");
25742
25817
  }
25743
25818
  var init_pi_paths = __esm({
25744
25819
  "../core/dist/pi-paths.js"() {
@@ -25920,8 +25995,8 @@ function getDefaultTierId(allowedTiers) {
25920
25995
  return allowedTiers[0]?.id;
25921
25996
  }
25922
25997
  function wait(ms) {
25923
- return new Promise((resolve27) => {
25924
- setTimeout(resolve27, ms);
25998
+ return new Promise((resolve28) => {
25999
+ setTimeout(resolve28, ms);
25925
26000
  });
25926
26001
  }
25927
26002
  function extractManagedProjectId(payload) {
@@ -28243,12 +28318,12 @@ var init_vault_provider_state = __esm({
28243
28318
  function untilAborted2(pending, signal) {
28244
28319
  if (!signal)
28245
28320
  return pending;
28246
- return new Promise((resolve27, reject) => {
28321
+ return new Promise((resolve28, reject) => {
28247
28322
  const abort = () => reject(signal.reason);
28248
28323
  signal.addEventListener("abort", abort, { once: true });
28249
28324
  if (signal.aborted)
28250
28325
  abort();
28251
- pending.then(resolve27, reject).finally(() => signal.removeEventListener("abort", abort));
28326
+ pending.then(resolve28, reject).finally(() => signal.removeEventListener("abort", abort));
28252
28327
  });
28253
28328
  }
28254
28329
  async function resolveClaustrumConnectionPath(explicit) {
@@ -28722,7 +28797,7 @@ var init_capture_sink2 = __esm({
28722
28797
  import { randomUUID as randomUUID13 } from "node:crypto";
28723
28798
  import { lstat as lstat6, readFile as readFile8, rename as rename8, unlink as unlink8 } from "node:fs/promises";
28724
28799
  import { tmpdir as tmpdir2 } from "node:os";
28725
- 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";
28726
28801
  function ioCode2(detail) {
28727
28802
  if (detail?.reason === "io-error") {
28728
28803
  if (detail.win32Code === 2 || detail.win32Code === 3)
@@ -28743,7 +28818,7 @@ function isUnavailable2(api, error) {
28743
28818
  }
28744
28819
  async function assertNativeAddonLoads2(api) {
28745
28820
  try {
28746
- 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");
28747
28822
  } catch (error) {
28748
28823
  if (isUnavailable2(api, error))
28749
28824
  throw privateFilesUnavailable2(error);
@@ -28769,7 +28844,7 @@ async function privateOperation2(path5, stage, operation) {
28769
28844
  }
28770
28845
  }
28771
28846
  async function verifySafeDirectory2(path5, options) {
28772
- path5 = resolve11(path5);
28847
+ path5 = resolve12(path5);
28773
28848
  options ??= safeParentOptionsForTest2;
28774
28849
  await privateOperation2(path5, "safe-parent", async () => {
28775
28850
  const result = await (await loadBackend2()).verifySafeParent(path5, options);
@@ -28784,7 +28859,7 @@ async function verifySafeDirectory2(path5, options) {
28784
28859
  });
28785
28860
  }
28786
28861
  async function verifyPrivate2(path5, kind, migrate = false) {
28787
- path5 = resolve11(path5);
28862
+ path5 = resolve12(path5);
28788
28863
  if (kind === "directory")
28789
28864
  return verifySafeDirectory2(path5);
28790
28865
  await privateOperation2(path5, "verify", async () => {
@@ -28819,7 +28894,7 @@ async function verifyPrivate2(path5, kind, migrate = false) {
28819
28894
  });
28820
28895
  }
28821
28896
  async function ensurePrivateDirectory2(path5, _migrate = false, options) {
28822
- path5 = resolve11(path5);
28897
+ path5 = resolve12(path5);
28823
28898
  await privateOperation2(path5, "directory", async () => {
28824
28899
  const api = await loadBackend2();
28825
28900
  try {
@@ -28850,7 +28925,7 @@ async function readPrivateText2(path5, migrate = false) {
28850
28925
  async function readPrivateBuffer2(path5, migrate = false) {
28851
28926
  if (!windowsPrivateFiles2)
28852
28927
  return readFile8(path5);
28853
- path5 = resolve11(path5);
28928
+ path5 = resolve12(path5);
28854
28929
  if (migrate) {
28855
28930
  await verifySafeDirectory2(dirname13(path5));
28856
28931
  await verifyPrivate2(path5, "file", true);
@@ -28858,20 +28933,20 @@ async function readPrivateBuffer2(path5, migrate = false) {
28858
28933
  return privateOperation2(path5, "read", async () => (await loadBackend2()).readOwnerOnly(path5));
28859
28934
  }
28860
28935
  async function createPrivateBytes2(path5, bytes) {
28861
- await verifySafeDirectory2(dirname13(resolve11(path5)));
28936
+ await verifySafeDirectory2(dirname13(resolve12(path5)));
28862
28937
  await privateOperation2(path5, "create", async () => {
28863
- await (await loadBackend2()).createPrivateFile(resolve11(path5), bytes);
28938
+ await (await loadBackend2()).createPrivateFile(resolve12(path5), bytes);
28864
28939
  });
28865
28940
  }
28866
28941
  async function createPrivateDirectoryExclusive2(path5) {
28867
- await verifySafeDirectory2(dirname13(resolve11(path5)));
28942
+ await verifySafeDirectory2(dirname13(resolve12(path5)));
28868
28943
  await privateOperation2(path5, "directory-create", async () => {
28869
- await (await loadBackend2()).createOwnerOnly(resolve11(path5), { kind: "dir" });
28944
+ await (await loadBackend2()).createOwnerOnly(resolve12(path5), { kind: "dir" });
28870
28945
  });
28871
28946
  }
28872
28947
  async function replaceWindowsFile2(from, to, options = {}) {
28873
- from = resolve11(from);
28874
- to = resolve11(to);
28948
+ from = resolve12(from);
28949
+ to = resolve12(to);
28875
28950
  const now = options.now ?? (() => performance.now());
28876
28951
  const start = now();
28877
28952
  const leaseDeadline = options.deadline ?? Infinity;
@@ -28914,7 +28989,7 @@ async function replaceWindowsFile2(from, to, options = {}) {
28914
28989
  throw error;
28915
28990
  }
28916
28991
  async function writePrivateAtomic2(path5, bytes, options = {}) {
28917
- path5 = resolve11(path5);
28992
+ path5 = resolve12(path5);
28918
28993
  await ensurePrivateDirectory2(dirname13(path5));
28919
28994
  try {
28920
28995
  await verifyPrivate2(path5, "file", true);
@@ -28922,7 +28997,7 @@ async function writePrivateAtomic2(path5, bytes, options = {}) {
28922
28997
  if (error.code !== "ENOENT")
28923
28998
  throw error;
28924
28999
  }
28925
- const stage = resolve11(options.stagePath ?? `${path5}.${randomUUID13()}.tmp`);
29000
+ const stage = resolve12(options.stagePath ?? `${path5}.${randomUUID13()}.tmp`);
28926
29001
  if (dirname13(stage) !== dirname13(path5))
28927
29002
  throw new PrivateFileError2(path5, "stage-directory", { code: "EXDEV" });
28928
29003
  let created = false;
@@ -29088,7 +29163,7 @@ var init_redact2 = __esm({
29088
29163
  // src/common-auth-embedded/logger/engine.js
29089
29164
  import { appendFileSync as appendFileSync2, chmodSync as chmodSync2, existsSync as existsSync2, renameSync as renameSync2, statSync as statSync3 } from "node:fs";
29090
29165
  import { open as open8 } from "node:fs/promises";
29091
- import { dirname as dirname14, resolve as resolve12 } from "node:path";
29166
+ import { dirname as dirname14, resolve as resolve13 } from "node:path";
29092
29167
  function chmodPrivate2(path5) {
29093
29168
  try {
29094
29169
  chmodSync2(path5, 384);
@@ -29139,7 +29214,7 @@ async function openWindowsFile2(sink, file) {
29139
29214
  return sink.handle;
29140
29215
  }
29141
29216
  async function flushWindowsFile2(sink, file, text2) {
29142
- file = resolve12(file);
29217
+ file = resolve13(file);
29143
29218
  try {
29144
29219
  if (sink.file !== file)
29145
29220
  await closeWindowsFile2(sink);
@@ -29286,7 +29361,7 @@ function createEngine2(options) {
29286
29361
  });
29287
29362
  }, 500);
29288
29363
  }
29289
- function emit(channel, level, message, data) {
29364
+ function emit(channel3, level, message, data) {
29290
29365
  if (logFileSource === void 0 && captureSink === void 0)
29291
29366
  return;
29292
29367
  try {
@@ -29299,10 +29374,10 @@ function createEngine2(options) {
29299
29374
  } catch {
29300
29375
  scrubbedData = "[unserializable]";
29301
29376
  }
29302
- const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${level.toUpperCase()} [${channel}] ${scrubbedMessage}` + (data === void 0 ? "" : safeSerialize2(scrubbedData)) + "\n";
29377
+ const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${level.toUpperCase()} [${channel3}] ${scrubbedMessage}` + (data === void 0 ? "" : safeSerialize2(scrubbedData)) + "\n";
29303
29378
  try {
29304
29379
  captureSink?.({
29305
- channel,
29380
+ channel: channel3,
29306
29381
  level,
29307
29382
  message: scrubbedMessage,
29308
29383
  data: scrubbedData
@@ -29322,13 +29397,13 @@ function createEngine2(options) {
29322
29397
  } catch {
29323
29398
  }
29324
29399
  }
29325
- function createLogger5(channel) {
29400
+ function createLogger5(channel3) {
29326
29401
  return {
29327
- error: (m, d) => emit(channel, "error", m, d),
29328
- warn: (m, d) => emit(channel, "warn", m, d),
29329
- info: (m, d) => emit(channel, "info", m, d),
29330
- debug: (m, d) => emit(channel, "debug", m, d),
29331
- trace: (m, d) => emit(channel, "trace", m, d)
29402
+ error: (m, d) => emit(channel3, "error", m, d),
29403
+ warn: (m, d) => emit(channel3, "warn", m, d),
29404
+ info: (m, d) => emit(channel3, "info", m, d),
29405
+ debug: (m, d) => emit(channel3, "debug", m, d),
29406
+ trace: (m, d) => emit(channel3, "trace", m, d)
29332
29407
  };
29333
29408
  }
29334
29409
  function reset() {
@@ -29424,6 +29499,10 @@ function createVaultRequestCredentials(source, onAdmitted) {
29424
29499
  const issued = /* @__PURE__ */ new WeakMap();
29425
29500
  return {
29426
29501
  domain: "vault",
29502
+ routingCandidate: (row) => ({
29503
+ accountId: row.route.accountIdentity,
29504
+ credentialId: row.route.credentialId
29505
+ }),
29427
29506
  ...source.retryAfter401 && {
29428
29507
  retryAfter401(served, current, site) {
29429
29508
  const original = issued.get(served);
@@ -29935,7 +30014,7 @@ var init_vault_insula_quota = __esm({
29935
30014
 
29936
30015
  // src/plugin/vault-custody.ts
29937
30016
  import { chmod as chmod3, mkdir as mkdir11, readFile as readFile9, stat as stat8 } from "node:fs/promises";
29938
- import { join as join10 } from "node:path";
30017
+ import { join as join11 } from "node:path";
29939
30018
  async function enrollmentFilesIdentity(paths) {
29940
30019
  const takenAt = performance.now();
29941
30020
  let coarse = process.platform === "win32";
@@ -29959,9 +30038,9 @@ function openCodeVaultPaths(vaultDir) {
29959
30038
  const dir = vaultDir;
29960
30039
  return {
29961
30040
  dir,
29962
- modeFile: join10(dir, "opencode-mode.json"),
29963
- rosterFile: join10(dir, "opencode-roster.json"),
29964
- 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")
29965
30044
  };
29966
30045
  }
29967
30046
  async function ensureVaultDir(dir) {
@@ -30198,11 +30277,11 @@ function createOpenCodeVaultCustody(options) {
30198
30277
  ].join("\n");
30199
30278
  const waitForApproval = async () => {
30200
30279
  while (!closed2) {
30201
- await new Promise((resolve27) => {
30280
+ await new Promise((resolve28) => {
30202
30281
  const done = () => {
30203
30282
  clearTimeout(timer);
30204
30283
  cancelWait = void 0;
30205
- resolve27();
30284
+ resolve28();
30206
30285
  };
30207
30286
  const timer = setTimeout(done, 2e3);
30208
30287
  timer.unref?.();
@@ -30589,20 +30668,20 @@ import { randomUUID as randomUUID14 } from "node:crypto";
30589
30668
  import { realpathSync, rmSync } from "node:fs";
30590
30669
  import { chmod as chmod4, mkdir as mkdir12, readFile as readFile10, rename as rename9, rm as rm5, writeFile as writeFile3 } from "node:fs/promises";
30591
30670
  import { homedir as homedir2 } from "node:os";
30592
- import { join as join11, resolve as resolve13 } from "node:path";
30671
+ import { join as join12, resolve as resolve14 } from "node:path";
30593
30672
  function processHeartbeatDir() {
30594
- const base = process.env.XDG_STATE_HOME || join11(homedir2(), ".local", "state");
30595
- 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");
30596
30675
  }
30597
30676
  function processHeartbeatPath(pid = process.pid, dir = processHeartbeatDir()) {
30598
- return join11(dir, `${pid}.json`);
30677
+ return join12(dir, `${pid}.json`);
30599
30678
  }
30600
30679
  function processConfigFolderKey() {
30601
30680
  const folder = getConfigDir();
30602
30681
  try {
30603
30682
  return realpathSync.native(folder);
30604
30683
  } catch {
30605
- return resolve13(folder);
30684
+ return resolve14(folder);
30606
30685
  }
30607
30686
  }
30608
30687
  function processHasOlderGeneration() {
@@ -30840,15 +30919,15 @@ var init_process_heartbeat = __esm({
30840
30919
  // src/version-fence.ts
30841
30920
  import { readdir as readdir2, readFile as readFile11 } from "node:fs/promises";
30842
30921
  import { homedir as homedir3 } from "node:os";
30843
- import { join as join12 } from "node:path";
30922
+ import { join as join13 } from "node:path";
30844
30923
  function defaultStateHome() {
30845
- return process.env.XDG_STATE_HOME || join12(homedir3(), ".local", "state");
30924
+ return process.env.XDG_STATE_HOME || join13(homedir3(), ".local", "state");
30846
30925
  }
30847
30926
  function processHeartbeatDir2(stateHome = defaultStateHome()) {
30848
- return join12(stateHome, "cortexkit", "antigravity-auth", "processes");
30927
+ return join13(stateHome, "cortexkit", "antigravity-auth", "processes");
30849
30928
  }
30850
30929
  function rpcStateRoot(stateHome = defaultStateHome()) {
30851
- return join12(stateHome, "cortexkit", "antigravity-auth", "rpc");
30930
+ return join13(stateHome, "cortexkit", "antigravity-auth", "rpc");
30852
30931
  }
30853
30932
  function isRpcProjectDir(name) {
30854
30933
  return /^[0-9a-f]{16}$/.test(name);
@@ -30963,7 +31042,7 @@ async function versionFenceOpen(options) {
30963
31042
  for (const name of heartbeats.ok ? heartbeats.names : []) {
30964
31043
  const pid = pidFrom(name, /^(\d+)\.json$/);
30965
31044
  if (pid === void 0 || pid === self) continue;
30966
- const path5 = join12(heartbeatDir, name);
31045
+ const path5 = join13(heartbeatDir, name);
30967
31046
  const heartbeat = await readProcessRecord(path5, pid);
30968
31047
  if (heartbeat.kind === "gone") continue;
30969
31048
  if (!alive(pid)) continue;
@@ -30987,7 +31066,7 @@ async function versionFenceOpen(options) {
30987
31066
  block({ pid: "unknown", version: "unknown", detail: projects.error });
30988
31067
  for (const project3 of projects.ok ? projects.names : []) {
30989
31068
  if (!isRpcProjectDir(project3)) continue;
30990
- const dir = join12(rpcRoot, project3);
31069
+ const dir = join13(rpcRoot, project3);
30991
31070
  const ports = await list2(dir);
30992
31071
  if (!ports.ok) {
30993
31072
  if (ports.code === "ENOTDIR") continue;
@@ -30997,7 +31076,7 @@ async function versionFenceOpen(options) {
30997
31076
  for (const name of ports.names) {
30998
31077
  const pid = pidFrom(name, /^port-(\d+)\.json$/);
30999
31078
  if (pid === void 0 || pid === self || !alive(pid)) continue;
31000
- const path5 = join12(dir, name);
31079
+ const path5 = join13(dir, name);
31001
31080
  const port = await readProcessRecord(path5, pid);
31002
31081
  if (port.kind === "gone") continue;
31003
31082
  const version = port.kind === "ok" ? port.version : "unknown";
@@ -31048,7 +31127,7 @@ import {
31048
31127
  stat as stat9,
31049
31128
  unlink as unlink9
31050
31129
  } from "node:fs/promises";
31051
- 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";
31052
31131
  function refusalMessage(stateDir, errorClass2) {
31053
31132
  if (errorClass2 === "ERR_PRIVATE_FILES_SECURITY")
31054
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.`;
@@ -31135,7 +31214,7 @@ function prepareRuntimeLayout(options) {
31135
31214
  async function decide(location, options) {
31136
31215
  const log16 = options.log ?? createLogger4("runtime-layout");
31137
31216
  const stateDir = location.stateHomeDir;
31138
- const markerPath = join13(stateDir, RUNTIME_LAYOUT_MARKER_FILE);
31217
+ const markerPath = join14(stateDir, RUNTIME_LAYOUT_MARKER_FILE);
31139
31218
  const files = layoutFiles(location, options.accountFile);
31140
31219
  const fence = options.fence ?? defaultFence(options.version);
31141
31220
  const stateHome = async () => {
@@ -31147,7 +31226,7 @@ async function decide(location, options) {
31147
31226
  if (marker?.oldFilesRemoved) {
31148
31227
  await refuseReappearedFiles(location, files);
31149
31228
  const manifestLeft = await exists2(
31150
- join13(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE)
31229
+ join14(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE)
31151
31230
  ).catch(() => true);
31152
31231
  if (!manifestLeft) {
31153
31232
  await settleVault(location, options, "state-home", log16);
@@ -31313,7 +31392,7 @@ async function prepareAccountStore(options) {
31313
31392
  await ensureOwnerOnlyDir(location.stateHomeDir);
31314
31393
  const lock = await takeLock(
31315
31394
  RUNTIME_LAYOUT_LOCK_NAME,
31316
- join13(location.stateHomeDir, RUNTIME_LAYOUT_MARKER_FILE),
31395
+ join14(location.stateHomeDir, RUNTIME_LAYOUT_MARKER_FILE),
31317
31396
  options.layoutLockWaitMs ?? LAYOUT_LOCK_WAIT_MS,
31318
31397
  log16
31319
31398
  );
@@ -31427,7 +31506,7 @@ async function recordAnchor(location, options, anchor, log16) {
31427
31506
  }
31428
31507
  async function storeMovePathResolves(stateAnchor, location, log16) {
31429
31508
  if (folderResolvesToItself(
31430
- join13(location.stateHomeDir, "antigravity-accounts.json")
31509
+ join14(location.stateHomeDir, "antigravity-accounts.json")
31431
31510
  ))
31432
31511
  return true;
31433
31512
  logOnce(
@@ -31795,7 +31874,7 @@ async function removeLeftoverManifest(location, layoutLock, steps, log16) {
31795
31874
  }
31796
31875
  }
31797
31876
  async function removeManifestOwned(stateDir, layoutLock, steps) {
31798
- const path5 = join13(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE);
31877
+ const path5 = join14(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE);
31799
31878
  if (!await exists2(path5)) return;
31800
31879
  await beforeRemove(path5, layoutLock, steps);
31801
31880
  await removeManifest(stateDir);
@@ -31835,7 +31914,7 @@ async function takeDataLocks(files, log16) {
31835
31914
  locks.push(
31836
31915
  await takeLock(
31837
31916
  lock.name,
31838
- join13(files.vault.old, lock.file),
31917
+ join14(files.vault.old, lock.file),
31839
31918
  lock.waitMs,
31840
31919
  log16
31841
31920
  )
@@ -31862,8 +31941,8 @@ function sha256(bytes) {
31862
31941
  }
31863
31942
  function vaultStateFile(files) {
31864
31943
  return {
31865
- old: join13(files.vault.old, VAULT_ENROLLMENT_STATE_FILE),
31866
- 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)
31867
31946
  };
31868
31947
  }
31869
31948
  async function keepableVaultState(files, present6) {
@@ -31903,10 +31982,10 @@ async function isVaultShapedKeptState(files) {
31903
31982
  async function removeMovedVaultStateLeftover(vaultDir, accountFile) {
31904
31983
  const location = runtimeLayoutLocation();
31905
31984
  const files = layoutFiles(location, accountFile);
31906
- if (resolve14(vaultDir) !== resolve14(files.vault.next)) return;
31985
+ if (resolve15(vaultDir) !== resolve15(files.vault.next)) return;
31907
31986
  const stateDir = location.stateHomeDir;
31908
31987
  const marker = await readMarker(
31909
- join13(stateDir, RUNTIME_LAYOUT_MARKER_FILE),
31988
+ join14(stateDir, RUNTIME_LAYOUT_MARKER_FILE),
31910
31989
  stateDir,
31911
31990
  files.vault.old
31912
31991
  );
@@ -31935,13 +32014,13 @@ async function vaultFiles(dir) {
31935
32014
  }
31936
32015
  async function presentOldFiles(files) {
31937
32016
  return (await vaultFiles(files.vault.old)).map((name) => ({
31938
- old: join13(files.vault.old, name),
31939
- next: join13(files.vault.next, name)
32017
+ old: join14(files.vault.old, name),
32018
+ next: join14(files.vault.next, name)
31940
32019
  }));
31941
32020
  }
31942
32021
  async function destinationFiles(files) {
31943
32022
  return (await vaultFiles(files.vault.next)).map(
31944
- (name) => join13(files.vault.next, name)
32023
+ (name) => join14(files.vault.next, name)
31945
32024
  );
31946
32025
  }
31947
32026
  async function physicalAliases(location, files) {
@@ -31950,7 +32029,7 @@ async function physicalAliases(location, files) {
31950
32029
  [files.vault.old, files.vault.next]
31951
32030
  ];
31952
32031
  for (const name of VAULT_FILE_NAMES)
31953
- 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)]);
31954
32033
  const aliased = [];
31955
32034
  for (const [old, next] of pairs)
31956
32035
  if (await samePhysical(old, next)) aliased.push(old);
@@ -32062,11 +32141,11 @@ async function unlinkIfIdentical(file, stateDir, guard) {
32062
32141
  async function refuseReappearedFiles(location, files) {
32063
32142
  const keptState = vaultStateFile(files).old;
32064
32143
  for (const name of await vaultFiles(files.vault.old)) {
32065
- const old = join13(files.vault.old, name);
32144
+ const old = join14(files.vault.old, name);
32066
32145
  if (old === keptState && await isVaultShapedKeptState(files)) continue;
32067
32146
  throw credentialConflict(location.stateHomeDir, {
32068
32147
  old,
32069
- next: join13(files.vault.next, name)
32148
+ next: join14(files.vault.next, name)
32070
32149
  });
32071
32150
  }
32072
32151
  }
@@ -32108,13 +32187,13 @@ async function assertOwnFolder(location, marker, files) {
32108
32187
  const stateDir = location.stateHomeDir;
32109
32188
  if (marker?.oldDir !== void 0 && marker.oldDir !== location.key)
32110
32189
  throw foreignMarker(
32111
- join13(stateDir, RUNTIME_LAYOUT_MARKER_FILE),
32190
+ join14(stateDir, RUNTIME_LAYOUT_MARKER_FILE),
32112
32191
  location.key,
32113
32192
  files.vault.old
32114
32193
  );
32115
32194
  let text2;
32116
32195
  try {
32117
- text2 = await readFile12(join13(stateDir, RUNTIME_CONFIG_DIR_NOTE_FILE), "utf8");
32196
+ text2 = await readFile12(join14(stateDir, RUNTIME_CONFIG_DIR_NOTE_FILE), "utf8");
32118
32197
  } catch (error) {
32119
32198
  const code2 = error.code;
32120
32199
  if (code2 === "ENOENT" || code2 === "ENOTDIR") return;
@@ -32128,7 +32207,7 @@ async function assertOwnFolder(location, marker, files) {
32128
32207
  if (owner !== location.key) throw foreignFolder(stateDir, location.key);
32129
32208
  }
32130
32209
  async function writeOwnerNote(location) {
32131
- const path5 = join13(location.stateHomeDir, RUNTIME_CONFIG_DIR_NOTE_FILE);
32210
+ const path5 = join14(location.stateHomeDir, RUNTIME_CONFIG_DIR_NOTE_FILE);
32132
32211
  if (await exists2(path5)) return;
32133
32212
  await writePrivateText(
32134
32213
  path5,
@@ -32139,7 +32218,7 @@ async function writeOwnerNote(location) {
32139
32218
  async function readManifest(stateDir) {
32140
32219
  let text2;
32141
32220
  try {
32142
- text2 = await readFile12(join13(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE), "utf8");
32221
+ text2 = await readFile12(join14(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE), "utf8");
32143
32222
  } catch (error) {
32144
32223
  if (error.code === "ENOENT") return /* @__PURE__ */ new Set();
32145
32224
  throw error;
@@ -32156,13 +32235,13 @@ async function readManifest(stateDir) {
32156
32235
  }
32157
32236
  async function writeManifest(stateDir, paths) {
32158
32237
  await writePrivateText(
32159
- join13(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE),
32238
+ join14(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE),
32160
32239
  `${JSON.stringify({ version: 1, files: paths }, null, 2)}
32161
32240
  `
32162
32241
  );
32163
32242
  }
32164
32243
  async function removeManifest(stateDir) {
32165
- await unlink9(join13(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE)).catch(
32244
+ await unlink9(join14(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE)).catch(
32166
32245
  (error) => {
32167
32246
  if (error.code !== "ENOENT") throw error;
32168
32247
  }
@@ -32331,9 +32410,9 @@ import {
32331
32410
  writeFileSync
32332
32411
  } from "node:fs";
32333
32412
  import { homedir as homedir4 } from "node:os";
32334
- 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";
32335
32414
  async function ensureGitignore(configDir) {
32336
- const gitignorePath = join14(configDir, ".gitignore");
32415
+ const gitignorePath = join15(configDir, ".gitignore");
32337
32416
  try {
32338
32417
  let content;
32339
32418
  let existingLines = [];
@@ -32379,8 +32458,8 @@ async function ensureGitignore(configDir) {
32379
32458
  }
32380
32459
  }
32381
32460
  function getLegacyWindowsConfigDir() {
32382
- return join14(
32383
- process.env.APPDATA || join14(homedir4(), "AppData", "Roaming"),
32461
+ return join15(
32462
+ process.env.APPDATA || join15(homedir4(), "AppData", "Roaming"),
32384
32463
  "opencode"
32385
32464
  );
32386
32465
  }
@@ -32388,15 +32467,15 @@ function getConfigDir() {
32388
32467
  if (process.env.OPENCODE_CONFIG_DIR) {
32389
32468
  return process.env.OPENCODE_CONFIG_DIR;
32390
32469
  }
32391
- const xdgConfig2 = process.env.XDG_CONFIG_HOME || join14(homedir4(), ".config");
32392
- return join14(xdgConfig2, "opencode");
32470
+ const xdgConfig2 = process.env.XDG_CONFIG_HOME || join15(homedir4(), ".config");
32471
+ return join15(xdgConfig2, "opencode");
32393
32472
  }
32394
32473
  function migrateLegacyWindowsConfig() {
32395
32474
  if (process.platform !== "win32") {
32396
32475
  return false;
32397
32476
  }
32398
- const newPath = join14(getConfigDir(), "antigravity-accounts.json");
32399
- const legacyPath = join14(
32477
+ const newPath = join15(getConfigDir(), "antigravity-accounts.json");
32478
+ const legacyPath = join15(
32400
32479
  getLegacyWindowsConfigDir(),
32401
32480
  "antigravity-accounts.json"
32402
32481
  );
@@ -32431,8 +32510,8 @@ function migrateLegacyWindowsConfig() {
32431
32510
  }
32432
32511
  }
32433
32512
  function resolveWindowsAccountAnchor(newPath, legacyPath) {
32434
- const standard = resolve15(newPath);
32435
- const legacy = resolve15(legacyPath);
32513
+ const standard = resolve16(newPath);
32514
+ const legacy = resolve16(legacyPath);
32436
32515
  if (standard.toLowerCase() === legacy.toLowerCase()) return newPath;
32437
32516
  const standardPointer = existsSync3(accountStorePointerPath(standard));
32438
32517
  const legacyPointer = existsSync3(accountStorePointerPath(legacy));
@@ -32446,15 +32525,15 @@ function resolveWindowsAccountAnchor(newPath, legacyPath) {
32446
32525
  return newPath;
32447
32526
  }
32448
32527
  function getStoragePathWithMigration() {
32449
- const newPath = join14(getConfigDir(), "antigravity-accounts.json");
32528
+ const newPath = join15(getConfigDir(), "antigravity-accounts.json");
32450
32529
  if (process.platform === "win32") {
32451
32530
  migrateLegacyWindowsConfig();
32452
- const legacyPath = join14(
32531
+ const legacyPath = join15(
32453
32532
  getLegacyWindowsConfigDir(),
32454
32533
  "antigravity-accounts.json"
32455
32534
  );
32456
32535
  const anchored = resolveWindowsAccountAnchor(newPath, legacyPath);
32457
- if (resolve15(anchored).toLowerCase() !== resolve15(newPath).toLowerCase() && !existsSync3(accountStorePointerPath(resolve15(anchored)))) {
32536
+ if (resolve16(anchored).toLowerCase() !== resolve16(newPath).toLowerCase() && !existsSync3(accountStorePointerPath(resolve16(anchored)))) {
32458
32537
  log5.info("Using legacy Windows config path (migration failed)", {
32459
32538
  legacyPath,
32460
32539
  newPath
@@ -32468,20 +32547,20 @@ function stateHomeStoragePath() {
32468
32547
  return stateHomeAccountFile(runtimeLayoutLocation());
32469
32548
  }
32470
32549
  function accountFileForVault(configDir = getConfigDir()) {
32471
- const configured = join14(configDir, "antigravity-accounts.json");
32550
+ const configured = join15(configDir, "antigravity-accounts.json");
32472
32551
  if (process.platform !== "win32") return configured;
32473
32552
  const legacyDir = getLegacyWindowsConfigDir();
32474
- if (resolve15(configDir).toLowerCase() === resolve15(legacyDir).toLowerCase())
32553
+ if (resolve16(configDir).toLowerCase() === resolve16(legacyDir).toLowerCase())
32475
32554
  return configured;
32476
- const configuredVault = join14(configDir, "antigravity-auth-vault");
32477
- const legacyVault = join14(legacyDir, "antigravity-auth-vault");
32555
+ const configuredVault = join15(configDir, "antigravity-auth-vault");
32556
+ const legacyVault = join15(legacyDir, "antigravity-auth-vault");
32478
32557
  const configuredPresent = existsSync3(configuredVault);
32479
32558
  const legacyPresent = existsSync3(legacyVault);
32480
32559
  if (configuredPresent && legacyPresent)
32481
32560
  throw new Error(
32482
32561
  `Two vault folders exist: ${configuredVault} and ${legacyVault}. Keep one vault enrollment before restarting OpenCode.`
32483
32562
  );
32484
- return legacyPresent ? join14(legacyDir, "antigravity-accounts.json") : configured;
32563
+ return legacyPresent ? join15(legacyDir, "antigravity-accounts.json") : configured;
32485
32564
  }
32486
32565
  async function prepareLocalAccountStore() {
32487
32566
  if (!decidedRuntimeLayout(runtimeLayoutLocation())) return;
@@ -32496,13 +32575,13 @@ function getStoragePath() {
32496
32575
  if (anchor === "config") return getStoragePathWithMigration();
32497
32576
  const location = runtimeLayoutLocation();
32498
32577
  if (decidedRuntimeLayout(location))
32499
- return join14(location.configDir, "antigravity-accounts.json");
32578
+ return join15(location.configDir, "antigravity-accounts.json");
32500
32579
  const configPath = getStoragePathWithMigration();
32501
32580
  return readForwardedAccountStore(configPath)?.legacyPath ?? configPath;
32502
32581
  }
32503
32582
  async function assertLegacyPoolInUse(legacyPath) {
32504
32583
  try {
32505
- await assertLegacyAccountStorageWritable(resolve15(legacyPath));
32584
+ await assertLegacyAccountStorageWritable(resolve16(legacyPath));
32506
32585
  } catch (error) {
32507
32586
  throw new LegacyAccountPoolRetiredError(legacyPath, { cause: error });
32508
32587
  }
@@ -32520,7 +32599,7 @@ function refusalMessage2(admission) {
32520
32599
  async function bindingOf(options) {
32521
32600
  if (options.legacyPath === void 0) await prepareLocalAccountStore();
32522
32601
  const now = options.now ?? (() => Date.now());
32523
- const legacyPath = resolve15(options.legacyPath ?? getStoragePath());
32602
+ const legacyPath = resolve16(options.legacyPath ?? getStoragePath());
32524
32603
  return {
32525
32604
  legacyPath,
32526
32605
  now,
@@ -32589,7 +32668,7 @@ async function openAccountStore(options) {
32589
32668
  async function initializeFreshAccountStoreFor(modules, options = {}) {
32590
32669
  if (options.legacyPath === void 0) await prepareLocalAccountStore();
32591
32670
  return initializeFreshAccountStore(modules, {
32592
- legacyPath: resolve15(options.legacyPath ?? getStoragePath()),
32671
+ legacyPath: resolve16(options.legacyPath ?? getStoragePath()),
32593
32672
  now: options.now ?? (() => Date.now())
32594
32673
  });
32595
32674
  }
@@ -32667,12 +32746,12 @@ var init_storage = __esm({
32667
32746
  import { createHash as createHash12 } from "node:crypto";
32668
32747
  import { existsSync as existsSync4, promises as fs2, readFileSync as readFileSync2, realpathSync as realpathSync2 } from "node:fs";
32669
32748
  import { homedir as homedir5 } from "node:os";
32670
- 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";
32671
32750
  function configDirIdentity(path5) {
32672
32751
  try {
32673
32752
  return realpathSync2.native(path5);
32674
32753
  } catch {
32675
- return resolve16(path5);
32754
+ return resolve17(path5);
32676
32755
  }
32677
32756
  }
32678
32757
  function decisionKey(location) {
@@ -32680,18 +32759,18 @@ function decisionKey(location) {
32680
32759
  }
32681
32760
  function runtimeLayoutLocation(configDir = getConfigDir()) {
32682
32761
  const stateHome = defaultStateHome();
32683
- const homeConfig = join15(homedir5(), ".config", "opencode");
32762
+ const homeConfig = join16(homedir5(), ".config", "opencode");
32684
32763
  const cacheKey = `${configDir}\0${homeConfig}\0${stateHome}`;
32685
32764
  const cached = shared2.locations.get(cacheKey);
32686
32765
  if (cached && shared2.decisions.has(decisionKey(cached))) return cached;
32687
32766
  const key = configDirIdentity(configDir);
32688
32767
  if (cached && cached.key === key) return cached;
32689
32768
  const isDefaultConfigDir = key === configDirIdentity(homeConfig);
32690
- const root = join15(stateHome, "cortexkit", "antigravity-auth");
32769
+ const root = join16(stateHome, "cortexkit", "antigravity-auth");
32691
32770
  const location = {
32692
32771
  key,
32693
32772
  configDir,
32694
- stateHomeDir: isDefaultConfigDir ? join15(root, "opencode") : join15(
32773
+ stateHomeDir: isDefaultConfigDir ? join16(root, "opencode") : join16(
32695
32774
  root,
32696
32775
  `opencode-${createHash12("sha256").update(key).digest("hex").slice(0, 16)}`
32697
32776
  ),
@@ -32713,49 +32792,49 @@ function decidedAccountStoreAnchor(location) {
32713
32792
  return shared2.storeAnchors.get(`${location.stateHomeDir}\0${location.key}`);
32714
32793
  }
32715
32794
  function currentRuntimeLayout(location = runtimeLayoutLocation()) {
32716
- 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");
32717
32796
  }
32718
32797
  function legacyWindowsConfigDir() {
32719
- return join15(
32720
- process.env.APPDATA || join15(homedir5(), "AppData", "Roaming"),
32798
+ return join16(
32799
+ process.env.APPDATA || join16(homedir5(), "AppData", "Roaming"),
32721
32800
  "opencode"
32722
32801
  );
32723
32802
  }
32724
32803
  function pluginStateDir() {
32725
- return join15(defaultStateHome(), "cortexkit", "antigravity-auth");
32804
+ return join16(defaultStateHome(), "cortexkit", "antigravity-auth");
32726
32805
  }
32727
32806
  function stateHomeSignatureCacheFile() {
32728
- return join15(pluginStateDir(), SIGNATURE_CACHE_FILE_NAME);
32807
+ return join16(pluginStateDir(), SIGNATURE_CACHE_FILE_NAME);
32729
32808
  }
32730
32809
  function legacySignatureCacheFile() {
32731
- const configHome = process.platform === "win32" ? legacyWindowsConfigDir() : join15(
32732
- 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"),
32733
32812
  "opencode"
32734
32813
  );
32735
- return join15(configHome, SIGNATURE_CACHE_FILE_NAME);
32814
+ return join16(configHome, SIGNATURE_CACHE_FILE_NAME);
32736
32815
  }
32737
32816
  function stateHomeLogsDir() {
32738
- return join15(pluginStateDir(), "logs");
32817
+ return join16(pluginStateDir(), "logs");
32739
32818
  }
32740
32819
  function legacyAccountFile(configDir = getConfigDir()) {
32741
- const standard = join15(configDir, ACCOUNT_FILE_NAME);
32820
+ const standard = join16(configDir, ACCOUNT_FILE_NAME);
32742
32821
  if (process.platform !== "win32") return standard;
32743
32822
  return resolveWindowsAccountAnchor(
32744
32823
  standard,
32745
- join15(legacyWindowsConfigDir(), ACCOUNT_FILE_NAME)
32824
+ join16(legacyWindowsConfigDir(), ACCOUNT_FILE_NAME)
32746
32825
  );
32747
32826
  }
32748
32827
  function legacyVaultDir(accountFile) {
32749
- return join15(dirname17(accountFile), VAULT_DIR_NAME);
32828
+ return join16(dirname17(accountFile), VAULT_DIR_NAME);
32750
32829
  }
32751
32830
  function stateHomeVaultDir(location) {
32752
- return join15(location.stateHomeDir, VAULT_DIR_NAME);
32831
+ return join16(location.stateHomeDir, VAULT_DIR_NAME);
32753
32832
  }
32754
32833
  function accountStorePointerPath2(accountFile) {
32755
32834
  return `${accountFile}${ACCOUNT_STORE_POINTER_SUFFIX}`;
32756
32835
  }
32757
32836
  function stateHomeAccountFile(location) {
32758
- return join15(realPathOrSelf(location.stateHomeDir), ACCOUNT_FILE_NAME);
32837
+ return join16(realPathOrSelf(location.stateHomeDir), ACCOUNT_FILE_NAME);
32759
32838
  }
32760
32839
  function realPathOrSelf(path5) {
32761
32840
  try {
@@ -32999,7 +33078,7 @@ import {
32999
33078
  statSync as statSync4,
33000
33079
  unlinkSync as unlinkSync2
33001
33080
  } from "node:fs";
33002
- import { join as join16 } from "node:path";
33081
+ import { join as join17 } from "node:path";
33003
33082
  import { env } from "node:process";
33004
33083
  function getLogsDir(customLogDir) {
33005
33084
  const logsDir = customLogDir || stateHomeLogsDir();
@@ -33018,9 +33097,9 @@ function createLogFilePath(customLogDir) {
33018
33097
  const logsDir = getLogsDir(requestedLogDir(customLogDir));
33019
33098
  cleanupOldLogs(logsDir, 25);
33020
33099
  const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
33021
- let candidate = join16(logsDir, `antigravity-debug-${timestamp}.log`);
33100
+ let candidate = join17(logsDir, `antigravity-debug-${timestamp}.log`);
33022
33101
  for (let suffix = 2; liveLogFilePaths.has(candidate); suffix++) {
33023
- candidate = join16(logsDir, `antigravity-debug-${timestamp}-${suffix}.log`);
33102
+ candidate = join17(logsDir, `antigravity-debug-${timestamp}-${suffix}.log`);
33024
33103
  }
33025
33104
  return candidate;
33026
33105
  }
@@ -33028,7 +33107,7 @@ function cleanupOldLogs(logsDir, maxFiles) {
33028
33107
  try {
33029
33108
  const files = readdirSync(logsDir).filter(
33030
33109
  (file) => file.startsWith("antigravity-debug-") && file.endsWith(".log")
33031
- ).map((file) => join16(logsDir, file));
33110
+ ).map((file) => join17(logsDir, file));
33032
33111
  if (files.length <= maxFiles) {
33033
33112
  return;
33034
33113
  }
@@ -33125,13 +33204,13 @@ function closeDebugStream(state) {
33125
33204
  state.logWriter = () => {
33126
33205
  };
33127
33206
  if (state.logFilePath) liveLogFilePaths.delete(state.logFilePath);
33128
- return new Promise((resolve27) => {
33129
- current.once("close", () => resolve27());
33130
- current.once("error", () => resolve27());
33207
+ return new Promise((resolve28) => {
33208
+ current.once("close", () => resolve28());
33209
+ current.once("error", () => resolve28());
33131
33210
  try {
33132
33211
  current.end();
33133
33212
  } catch {
33134
- resolve27();
33213
+ resolve28();
33135
33214
  }
33136
33215
  });
33137
33216
  }
@@ -33396,13 +33475,13 @@ function closeDebugLog() {
33396
33475
  if (!state || !current) return Promise.resolve();
33397
33476
  state.logStream = null;
33398
33477
  if (state.logFilePath) liveLogFilePaths.delete(state.logFilePath);
33399
- return new Promise((resolve27) => {
33400
- current.once("close", () => resolve27());
33401
- current.once("error", () => resolve27());
33478
+ return new Promise((resolve28) => {
33479
+ current.once("close", () => resolve28());
33480
+ current.once("error", () => resolve28());
33402
33481
  try {
33403
33482
  current.end();
33404
33483
  } catch {
33405
- resolve27();
33484
+ resolve28();
33406
33485
  }
33407
33486
  });
33408
33487
  }
@@ -33519,10 +33598,10 @@ function createLocationLogger(options) {
33519
33598
  const engine = createLoggerInstance2({
33520
33599
  level: () => configuredLevel,
33521
33600
  extraSecretKeys: isProviderSecretKey,
33522
- captureSink: ({ channel, level, message, data }) => {
33601
+ captureSink: ({ channel: channel3, level, message, data }) => {
33523
33602
  const extra = data !== null && typeof data === "object" && !Array.isArray(data) ? Object.fromEntries(Object.entries(data)) : void 0;
33524
33603
  emit({
33525
- service: channel,
33604
+ service: channel3,
33526
33605
  level: level === "trace" ? "debug" : level,
33527
33606
  message,
33528
33607
  extra
@@ -33531,12 +33610,12 @@ function createLocationLogger(options) {
33531
33610
  });
33532
33611
  return {
33533
33612
  createLogger(module) {
33534
- const channel = engine.createLogger(`antigravity.${module}`);
33613
+ const channel3 = engine.createLogger(`antigravity.${module}`);
33535
33614
  return {
33536
- debug: (message, extra) => channel.debug(message, extra),
33537
- info: (message, extra) => channel.info(message, extra),
33538
- warn: (message, extra) => channel.warn(message, extra),
33539
- error: (message, extra) => channel.error(message, extra)
33615
+ debug: (message, extra) => channel3.debug(message, extra),
33616
+ info: (message, extra) => channel3.info(message, extra),
33617
+ warn: (message, extra) => channel3.warn(message, extra),
33618
+ error: (message, extra) => channel3.error(message, extra)
33540
33619
  };
33541
33620
  },
33542
33621
  setLevel(level) {
@@ -33577,10 +33656,10 @@ function initLogger3(client) {
33577
33656
  setLogSink(getLegacyLogger().coreLogSink);
33578
33657
  }
33579
33658
  function createLogger4(module) {
33580
- let channel;
33659
+ let channel3;
33581
33660
  const log16 = (level, message, extra) => {
33582
- channel ??= getLegacyLogger().createLogger(module);
33583
- channel[level](message, extra);
33661
+ channel3 ??= getLegacyLogger().createLogger(module);
33662
+ channel3[level](message, extra);
33584
33663
  };
33585
33664
  return {
33586
33665
  debug: (message, extra) => log16("debug", message, extra),
@@ -34869,7 +34948,7 @@ init_runtime_paths();
34869
34948
  init_logger4();
34870
34949
  import { existsSync as existsSync5, readFileSync as readFileSync3, realpathSync as realpathSync3 } from "node:fs";
34871
34950
  import { homedir as homedir6 } from "node:os";
34872
- import { basename as basename5, dirname as dirname18, join as join17, resolve as resolve17 } from "node:path";
34951
+ import { basename as basename5, dirname as dirname18, join as join18, resolve as resolve18 } from "node:path";
34873
34952
 
34874
34953
  // src/plugin/config/schema.ts
34875
34954
  import { z } from "zod";
@@ -35364,14 +35443,14 @@ function getConfigDir2() {
35364
35443
  if (process.env.OPENCODE_CONFIG_DIR) {
35365
35444
  return process.env.OPENCODE_CONFIG_DIR;
35366
35445
  }
35367
- const xdgConfig2 = process.env.XDG_CONFIG_HOME || join17(homedir6(), ".config");
35368
- return join17(xdgConfig2, "opencode");
35446
+ const xdgConfig2 = process.env.XDG_CONFIG_HOME || join18(homedir6(), ".config");
35447
+ return join18(xdgConfig2, "opencode");
35369
35448
  }
35370
35449
  function getUserConfigPath() {
35371
- return join17(getConfigDir2(), "antigravity.json");
35450
+ return join18(getConfigDir2(), "antigravity.json");
35372
35451
  }
35373
35452
  function getProjectConfigPath(directory) {
35374
- return join17(directory, ".opencode", "antigravity.json");
35453
+ return join18(directory, ".opencode", "antigravity.json");
35375
35454
  }
35376
35455
  function loadConfigFile(path5, log16) {
35377
35456
  try {
@@ -35443,12 +35522,12 @@ function createLocationConfig(directory, options) {
35443
35522
  };
35444
35523
  }
35445
35524
  function canonicalizeOwnedPath(path5) {
35446
- const absolute = resolve17(path5);
35525
+ const absolute = resolve18(path5);
35447
35526
  const missing = [];
35448
35527
  let current = absolute;
35449
35528
  for (; ; ) {
35450
35529
  try {
35451
- return join17(realpathSync3(current), ...missing.reverse());
35530
+ return join18(realpathSync3(current), ...missing.reverse());
35452
35531
  } catch {
35453
35532
  const parent = dirname18(current);
35454
35533
  if (parent === current) return absolute;
@@ -35822,14 +35901,14 @@ function createStoreAccountLimits(input2) {
35822
35901
 
35823
35902
  // src/plugin/ga-shared-vault-custody.ts
35824
35903
  init_dist();
35825
- import { resolve as resolve18 } from "node:path";
35904
+ import { resolve as resolve19 } from "node:path";
35826
35905
 
35827
35906
  // src/sidebar-state.ts
35828
35907
  init_atomic_write();
35829
35908
  init_file_lock();
35830
35909
  import { chmodSync as chmodSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync6 } from "node:fs";
35831
35910
  import { homedir as homedir7 } from "node:os";
35832
- import { dirname as dirname19, join as join18 } from "node:path";
35911
+ import { dirname as dirname19, join as join19 } from "node:path";
35833
35912
 
35834
35913
  // ../../node_modules/.bun/xdg-basedir@5.1.0/node_modules/xdg-basedir/index.js
35835
35914
  import os from "os";
@@ -35888,8 +35967,8 @@ async function emitMergeStep(step) {
35888
35967
  function getSidebarStateFile() {
35889
35968
  const override = process.env[SIDEBAR_STATE_ENV];
35890
35969
  if (override && override.trim().length > 0) return override;
35891
- const base = xdgState ?? join18(homedir7(), ".local", "state");
35892
- return join18(base, SIDEBAR_STATE_DIR, SIDEBAR_STATE_FILENAME);
35970
+ const base = xdgState ?? join19(homedir7(), ".local", "state");
35971
+ return join19(base, SIDEBAR_STATE_DIR, SIDEBAR_STATE_FILENAME);
35893
35972
  }
35894
35973
  function readSidebarState(path5 = getSidebarStateFile()) {
35895
35974
  let raw;
@@ -36238,7 +36317,7 @@ function drainSidebarWrites() {
36238
36317
  return sidebarWriteChain;
36239
36318
  }
36240
36319
  async function sleep3(ms) {
36241
- await new Promise((resolve27) => setTimeout(resolve27, ms));
36320
+ await new Promise((resolve28) => setTimeout(resolve28, ms));
36242
36321
  }
36243
36322
  async function acquireSidebarLockWithRetry(stateFile) {
36244
36323
  const start = Date.now();
@@ -36797,14 +36876,14 @@ var LocalQuotaGrantStaleError = class extends Error {
36797
36876
  name = "LocalQuotaGrantStaleError";
36798
36877
  };
36799
36878
  function untilQuotaAborted(pending, signal) {
36800
- return new Promise((resolve27, reject) => {
36879
+ return new Promise((resolve28, reject) => {
36801
36880
  const abort = () => reject(signal.reason);
36802
36881
  if (signal.aborted) abort();
36803
36882
  else signal.addEventListener("abort", abort, { once: true });
36804
36883
  void pending.then(
36805
36884
  (value) => {
36806
36885
  signal.removeEventListener("abort", abort);
36807
- resolve27(value);
36886
+ resolve28(value);
36808
36887
  },
36809
36888
  (error) => {
36810
36889
  signal.removeEventListener("abort", abort);
@@ -37699,7 +37778,7 @@ init_vault_request_credentials();
37699
37778
  init_vault_custody();
37700
37779
  var shared3 = /* @__PURE__ */ new Map();
37701
37780
  function acquireGaVaultCustody(options) {
37702
- const key = options.layoutRefusal === void 0 ? resolve18(options.vaultDir) : `unsettled\0${resolve18(options.vaultDir)}`;
37781
+ const key = options.layoutRefusal === void 0 ? resolve19(options.vaultDir) : `unsettled\0${resolve19(options.vaultDir)}`;
37703
37782
  let entry = shared3.get(key);
37704
37783
  if (!entry) {
37705
37784
  const leases = /* @__PURE__ */ new Set();
@@ -38024,7 +38103,7 @@ import {
38024
38103
  writeFileSync as writeFileSync2
38025
38104
  } from "node:fs";
38026
38105
  import { tmpdir as tmpdir3 } from "node:os";
38027
- import { dirname as dirname20, join as join19 } from "node:path";
38106
+ import { dirname as dirname20, join as join20 } from "node:path";
38028
38107
  function getSignatureCacheFilePath() {
38029
38108
  return stateHomeSignatureCacheFile();
38030
38109
  }
@@ -38308,7 +38387,7 @@ var SignatureCache = class {
38308
38387
  last_write: now
38309
38388
  }
38310
38389
  };
38311
- const tmpPath = join19(
38390
+ const tmpPath = join20(
38312
38391
  tmpdir3(),
38313
38392
  `antigravity-cache-${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`
38314
38393
  );
@@ -38665,9 +38744,9 @@ function clearSignatureCache(sessionId) {
38665
38744
  // src/plugin/image-saver.ts
38666
38745
  import { chmodSync as chmodSync4, existsSync as existsSync9, mkdirSync as mkdirSync5, writeFileSync as writeFileSync3 } from "node:fs";
38667
38746
  import { homedir as homedir8 } from "node:os";
38668
- import { join as join20 } from "node:path";
38747
+ import { join as join21 } from "node:path";
38669
38748
  function getImageOutputDir(outputDir) {
38670
- const resolved = outputDir ?? join20(homedir8(), ".opencode", "generated-images");
38749
+ const resolved = outputDir ?? join21(homedir8(), ".opencode", "generated-images");
38671
38750
  if (!existsSync9(resolved)) {
38672
38751
  mkdirSync5(resolved, { recursive: true, mode: 448 });
38673
38752
  }
@@ -38690,7 +38769,7 @@ function generateImageFilename(mimeType) {
38690
38769
  function saveImageToDisk(base64Data, mimeType, outputDir) {
38691
38770
  try {
38692
38771
  const resolvedOutputDir = getImageOutputDir(outputDir);
38693
- const filePath = join20(resolvedOutputDir, generateImageFilename(mimeType));
38772
+ const filePath = join21(resolvedOutputDir, generateImageFilename(mimeType));
38694
38773
  writeFileSync3(filePath, Buffer.from(base64Data, "base64"), { mode: 384 });
38695
38774
  chmodSync4(filePath, 384);
38696
38775
  return filePath;
@@ -39131,10 +39210,10 @@ init_logging_utils();
39131
39210
  import { createHash as createHash15 } from "node:crypto";
39132
39211
  import { appendFileSync as appendFileSync4, mkdirSync as mkdirSync6, writeFileSync as writeFileSync4 } from "node:fs";
39133
39212
  import { tmpdir as tmpdir4 } from "node:os";
39134
- import { join as join21 } from "node:path";
39213
+ import { join as join22 } from "node:path";
39135
39214
  var DUMP_STATUS_TITLE = "## Gemini Dump Status";
39136
39215
  var DUMP_DIR_ENV = "OPENCODE_ANTIGRAVITY_GEMINI_DUMP_DIR";
39137
- var DEFAULT_DUMP_DIR = join21(tmpdir4(), "opencode-antigravity-gemini-dumps");
39216
+ var DEFAULT_DUMP_DIR = join22(tmpdir4(), "opencode-antigravity-gemini-dumps");
39138
39217
  var DUMP_DIR_MODE = 448;
39139
39218
  var DUMP_FILE_MODE = 384;
39140
39219
  var nextDumpId = 0;
@@ -39288,7 +39367,7 @@ function writeGeminiDump(input2) {
39288
39367
  nextDumpId += 1;
39289
39368
  const id = `${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}-${String(nextDumpId).padStart(5, "0")}-${input2.streaming ? "stream" : "json"}`;
39290
39369
  const dumpDir = getGeminiDumpDirectory();
39291
- const prefix = join21(dumpDir, id);
39370
+ const prefix = join22(dumpDir, id);
39292
39371
  mkdirSync6(dumpDir, { recursive: true, mode: DUMP_DIR_MODE });
39293
39372
  const context = {
39294
39373
  id,
@@ -39379,21 +39458,21 @@ import {
39379
39458
  unlinkSync as unlinkSync4,
39380
39459
  writeFileSync as writeFileSync5
39381
39460
  } from "node:fs";
39382
- import { join as join23 } from "node:path";
39461
+ import { join as join24 } from "node:path";
39383
39462
 
39384
39463
  // src/plugin/recovery/constants.ts
39385
39464
  import { homedir as homedir9 } from "node:os";
39386
- import { join as join22 } from "node:path";
39465
+ import { join as join23 } from "node:path";
39387
39466
  function getXdgData() {
39388
39467
  const platform = process.platform;
39389
39468
  if (platform === "win32") {
39390
- return process.env.APPDATA || join22(homedir9(), "AppData", "Roaming");
39469
+ return process.env.APPDATA || join23(homedir9(), "AppData", "Roaming");
39391
39470
  }
39392
- return process.env.XDG_DATA_HOME || join22(homedir9(), ".local", "share");
39471
+ return process.env.XDG_DATA_HOME || join23(homedir9(), ".local", "share");
39393
39472
  }
39394
- var OPENCODE_STORAGE = join22(getXdgData(), "opencode", "storage");
39395
- var MESSAGE_STORAGE = join22(OPENCODE_STORAGE, "message");
39396
- var PART_STORAGE = join22(OPENCODE_STORAGE, "part");
39473
+ var OPENCODE_STORAGE = join23(getXdgData(), "opencode", "storage");
39474
+ var MESSAGE_STORAGE = join23(OPENCODE_STORAGE, "message");
39475
+ var PART_STORAGE = join23(OPENCODE_STORAGE, "part");
39397
39476
  var THINKING_TYPES = /* @__PURE__ */ new Set([
39398
39477
  "thinking",
39399
39478
  "redacted_thinking",
@@ -39403,13 +39482,13 @@ var THINKING_TYPES = /* @__PURE__ */ new Set([
39403
39482
  // src/plugin/recovery/storage.ts
39404
39483
  function getMessageDir(sessionID) {
39405
39484
  if (!existsSync10(MESSAGE_STORAGE)) return "";
39406
- const directPath = join23(MESSAGE_STORAGE, sessionID);
39485
+ const directPath = join24(MESSAGE_STORAGE, sessionID);
39407
39486
  if (existsSync10(directPath)) {
39408
39487
  return directPath;
39409
39488
  }
39410
39489
  try {
39411
39490
  for (const dir of readdirSync2(MESSAGE_STORAGE)) {
39412
- const sessionPath = join23(MESSAGE_STORAGE, dir, sessionID);
39491
+ const sessionPath = join24(MESSAGE_STORAGE, dir, sessionID);
39413
39492
  if (existsSync10(sessionPath)) {
39414
39493
  return sessionPath;
39415
39494
  }
@@ -39426,7 +39505,7 @@ function readMessages(sessionID) {
39426
39505
  for (const file of readdirSync2(messageDir)) {
39427
39506
  if (!file.endsWith(".json")) continue;
39428
39507
  try {
39429
- const content = readFileSync8(join23(messageDir, file), "utf-8");
39508
+ const content = readFileSync8(join24(messageDir, file), "utf-8");
39430
39509
  messages.push(JSON.parse(content));
39431
39510
  } catch {
39432
39511
  }
@@ -39442,14 +39521,14 @@ function readMessages(sessionID) {
39442
39521
  });
39443
39522
  }
39444
39523
  function readParts(messageID) {
39445
- const partDir = join23(PART_STORAGE, messageID);
39524
+ const partDir = join24(PART_STORAGE, messageID);
39446
39525
  if (!existsSync10(partDir)) return [];
39447
39526
  const parts = [];
39448
39527
  try {
39449
39528
  for (const file of readdirSync2(partDir)) {
39450
39529
  if (!file.endsWith(".json")) continue;
39451
39530
  try {
39452
- const content = readFileSync8(join23(partDir, file), "utf-8");
39531
+ const content = readFileSync8(join24(partDir, file), "utf-8");
39453
39532
  parts.push(JSON.parse(content));
39454
39533
  } catch {
39455
39534
  }
@@ -39491,7 +39570,7 @@ function findMessagesWithOrphanThinking(sessionID) {
39491
39570
  return result;
39492
39571
  }
39493
39572
  function prependThinkingPart(sessionID, messageID) {
39494
- const partDir = join23(PART_STORAGE, messageID);
39573
+ const partDir = join24(PART_STORAGE, messageID);
39495
39574
  try {
39496
39575
  if (!existsSync10(partDir)) {
39497
39576
  mkdirSync7(partDir, { recursive: true });
@@ -39506,7 +39585,7 @@ function prependThinkingPart(sessionID, messageID) {
39506
39585
  synthetic: true
39507
39586
  };
39508
39587
  writeFileSync5(
39509
- join23(partDir, `${partId}.json`),
39588
+ join24(partDir, `${partId}.json`),
39510
39589
  JSON.stringify(part, null, 2)
39511
39590
  );
39512
39591
  return true;
@@ -39515,14 +39594,14 @@ function prependThinkingPart(sessionID, messageID) {
39515
39594
  }
39516
39595
  }
39517
39596
  function stripThinkingParts(messageID) {
39518
- const partDir = join23(PART_STORAGE, messageID);
39597
+ const partDir = join24(PART_STORAGE, messageID);
39519
39598
  if (!existsSync10(partDir)) return false;
39520
39599
  let anyRemoved = false;
39521
39600
  try {
39522
39601
  for (const file of readdirSync2(partDir)) {
39523
39602
  if (!file.endsWith(".json")) continue;
39524
39603
  try {
39525
- const filePath = join23(partDir, file);
39604
+ const filePath = join24(partDir, file);
39526
39605
  const content = readFileSync8(filePath, "utf-8");
39527
39606
  const part = JSON.parse(content);
39528
39607
  if (THINKING_TYPES.has(part.type)) {
@@ -42329,6 +42408,7 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
42329
42408
  headers.delete("x-parent-session-id");
42330
42409
  headers.delete("x-opencode-session-id");
42331
42410
  headers.delete("x-opencode-parent-session-id");
42411
+ headers.delete("x-antigravity-internal-request-purpose");
42332
42412
  headers.delete("x-goog-user-project");
42333
42413
  headers.delete("X-Goog-Api-Client");
42334
42414
  headers.delete("Client-Metadata");
@@ -43331,12 +43411,12 @@ async function startOAuthListener({
43331
43411
  let resolveCallback;
43332
43412
  let rejectCallback;
43333
43413
  let timeoutHandle;
43334
- const callbackPromise = new Promise((resolve27, reject) => {
43414
+ const callbackPromise = new Promise((resolve28, reject) => {
43335
43415
  resolveCallback = (url) => {
43336
43416
  if (settled) return;
43337
43417
  settled = true;
43338
43418
  if (timeoutHandle) clearTimeout(timeoutHandle);
43339
- resolve27(url);
43419
+ resolve28(url);
43340
43420
  };
43341
43421
  rejectCallback = (error) => {
43342
43422
  if (settled) return;
@@ -43495,7 +43575,7 @@ async function startOAuthListener({
43495
43575
  });
43496
43576
  });
43497
43577
  const bindAddress = getBindAddress();
43498
- await new Promise((resolve27, reject) => {
43578
+ await new Promise((resolve28, reject) => {
43499
43579
  const handleError = (error) => {
43500
43580
  server.off("error", handleError);
43501
43581
  if (error.code === "EADDRINUSE") {
@@ -43511,7 +43591,7 @@ async function startOAuthListener({
43511
43591
  server.once("error", handleError);
43512
43592
  server.listen(port, bindAddress, () => {
43513
43593
  server.off("error", handleError);
43514
- resolve27();
43594
+ resolve28();
43515
43595
  });
43516
43596
  });
43517
43597
  server.on("error", (error) => {
@@ -43519,7 +43599,7 @@ async function startOAuthListener({
43519
43599
  });
43520
43600
  return {
43521
43601
  waitForCallback: () => callbackPromise,
43522
- close: () => new Promise((resolve27, reject) => {
43602
+ close: () => new Promise((resolve28, reject) => {
43523
43603
  server.close((error) => {
43524
43604
  if (error && error.code !== "ERR_SERVER_NOT_RUNNING") {
43525
43605
  reject(error);
@@ -43528,7 +43608,7 @@ async function startOAuthListener({
43528
43608
  if (!settled) {
43529
43609
  rejectCallback(new Error("OAuth listener closed before callback"));
43530
43610
  }
43531
- resolve27();
43611
+ resolve28();
43532
43612
  });
43533
43613
  })
43534
43614
  };
@@ -43539,7 +43619,7 @@ async function startOAuthListener({
43539
43619
  }
43540
43620
 
43541
43621
  // src/plugin/session-context.ts
43542
- import { resolve as resolve19 } from "node:path";
43622
+ import { resolve as resolve20 } from "node:path";
43543
43623
  import { pathToFileURL } from "node:url";
43544
43624
  var FALLBACK_SESSION_KEY = "__default__";
43545
43625
  function extractOpenCodeSessionIdentity(headers) {
@@ -43553,7 +43633,7 @@ var AgySessionRegistry = class {
43553
43633
  requestSessions;
43554
43634
  parentSessionIds = /* @__PURE__ */ new Map();
43555
43635
  constructor(directory, options = {}) {
43556
- const workspaceUri = directory ? pathToFileURL(resolve19(directory)).href : "";
43636
+ const workspaceUri = directory ? pathToFileURL(resolve20(directory)).href : "";
43557
43637
  this.requestSessions = new AgyRequestSessionStore(workspaceUri, options);
43558
43638
  }
43559
43639
  getOrCreate(identity3) {
@@ -43682,6 +43762,107 @@ function isFlushReport(value) {
43682
43762
  // src/plugin/shared/request-services.ts
43683
43763
  init_dist();
43684
43764
 
43765
+ // src/common-auth-embedded/routing-accessor/index.js
43766
+ function isObject2(value) {
43767
+ return typeof value === "object" && value !== null;
43768
+ }
43769
+ function routingHandle(sessionId) {
43770
+ const routing = Reflect.get(globalThis, /* @__PURE__ */ Symbol.for("cortexkit.routing"));
43771
+ if (typeof routing !== "function")
43772
+ return void 0;
43773
+ const handle = routing(sessionId);
43774
+ return isObject2(handle) ? handle : void 0;
43775
+ }
43776
+ function selectionFor(answer, candidates) {
43777
+ if (!isObject2(answer))
43778
+ return void 0;
43779
+ const accountId = answer.account_id;
43780
+ const credentialId = answer.credential_id;
43781
+ if (typeof accountId !== "string")
43782
+ return void 0;
43783
+ if (credentialId !== void 0 && typeof credentialId !== "string") {
43784
+ return void 0;
43785
+ }
43786
+ const candidate = candidates.find((route) => route.accountId === accountId && (credentialId === void 0 || route.credentialId === credentialId));
43787
+ if (!candidate)
43788
+ return void 0;
43789
+ const hold = answer.hold;
43790
+ const retryAfterMs = isObject2(hold) ? hold.retry_after_ms : void 0;
43791
+ if (typeof retryAfterMs === "number" && Number.isFinite(retryAfterMs) && retryAfterMs >= 0) {
43792
+ return { candidate, hold: { retry_after_ms: retryAfterMs } };
43793
+ }
43794
+ return { candidate };
43795
+ }
43796
+ async function askRouting(input2) {
43797
+ let timer;
43798
+ try {
43799
+ const handle = routingHandle(input2.sessionId);
43800
+ if (!handle)
43801
+ return void 0;
43802
+ const accountFor = handle.accountFor;
43803
+ if (typeof accountFor !== "function")
43804
+ return void 0;
43805
+ const requested = input2.deadlineMs ?? 500;
43806
+ const deadlineMs = Number.isNaN(requested) ? 500 : Math.min(2e3, Math.max(1, requested));
43807
+ const expired = new Promise((resolve28) => {
43808
+ timer = setTimeout(() => resolve28(void 0), deadlineMs);
43809
+ timer.unref();
43810
+ });
43811
+ const pending = accountFor.call(handle, { provider: input2.provider, modelId: input2.modelId }, { deadlineMs });
43812
+ if (!isObject2(pending) || typeof pending.then !== "function")
43813
+ return void 0;
43814
+ const answer = await Promise.race([pending, expired]);
43815
+ return selectionFor(answer, input2.candidates);
43816
+ } catch {
43817
+ return void 0;
43818
+ } finally {
43819
+ clearTimeout(timer);
43820
+ }
43821
+ }
43822
+ function reportRouting(input2) {
43823
+ try {
43824
+ const handle = routingHandle(input2.sessionId);
43825
+ if (!handle)
43826
+ return;
43827
+ const report = handle.report;
43828
+ if (typeof report !== "function")
43829
+ return;
43830
+ const identity3 = {
43831
+ account_id: input2.accountId,
43832
+ ...input2.credentialId !== void 0 ? { credential_id: input2.credentialId } : {}
43833
+ };
43834
+ let payload;
43835
+ switch (input2.outcome) {
43836
+ case "served":
43837
+ payload = { ...identity3, outcome: "served", headers: input2.headers };
43838
+ break;
43839
+ case "exhausted": {
43840
+ const { window, pool } = input2;
43841
+ if (window !== "5h" && window !== "7d")
43842
+ return;
43843
+ if (pool !== void 0 && (typeof pool !== "string" || pool.length === 0 || pool.includes(":")))
43844
+ return;
43845
+ payload = {
43846
+ ...identity3,
43847
+ outcome: "exhausted",
43848
+ window,
43849
+ ...pool ? { pool } : {},
43850
+ ...input2.resetsAt !== void 0 ? { resets_at: input2.resetsAt } : {}
43851
+ };
43852
+ break;
43853
+ }
43854
+ default:
43855
+ return;
43856
+ }
43857
+ const pending = report.call(handle, payload);
43858
+ if (isObject2(pending) && typeof pending.then === "function") {
43859
+ void Promise.resolve(pending).catch(() => {
43860
+ });
43861
+ }
43862
+ } catch {
43863
+ }
43864
+ }
43865
+
43685
43866
  // src/plugin/errors.ts
43686
43867
  var AntigravityKillswitchError = class extends Error {
43687
43868
  family;
@@ -44182,10 +44363,10 @@ async function retainResponseLifetime(response, cancellation) {
44182
44363
  cancellation.release();
44183
44364
  throw error;
44184
44365
  }
44185
- let resolve27 = () => {
44366
+ let resolve28 = () => {
44186
44367
  };
44187
44368
  const settled = new Promise((done) => {
44188
- resolve27 = done;
44369
+ resolve28 = done;
44189
44370
  });
44190
44371
  let stopping = false;
44191
44372
  let finished = false;
@@ -44195,7 +44376,7 @@ async function retainResponseLifetime(response, cancellation) {
44195
44376
  finished = true;
44196
44377
  cancellation.signal.removeEventListener("abort", abort);
44197
44378
  cancellation.release();
44198
- resolve27();
44379
+ resolve28();
44199
44380
  };
44200
44381
  const abort = () => {
44201
44382
  if (finished || stopping) return;
@@ -44264,8 +44445,8 @@ function createAfterHandoff(work, signals, onFailure) {
44264
44445
  let running = false;
44265
44446
  let resolveCompletion = () => {
44266
44447
  };
44267
- const completion = new Promise((resolve27) => {
44268
- resolveCompletion = resolve27;
44448
+ const completion = new Promise((resolve28) => {
44449
+ resolveCompletion = resolve28;
44269
44450
  });
44270
44451
  const finish = () => {
44271
44452
  if (finished) return;
@@ -44312,19 +44493,205 @@ function createAfterHandoff(work, signals, onFailure) {
44312
44493
  };
44313
44494
  }
44314
44495
  function publishResponse(dispatch) {
44315
- return new Promise((resolve27, reject) => {
44496
+ return new Promise((resolve28, reject) => {
44316
44497
  let acknowledge;
44317
44498
  void Promise.resolve().then(
44318
44499
  () => dispatch((callback) => {
44319
44500
  acknowledge = callback;
44320
44501
  })
44321
44502
  ).then((response) => {
44322
- resolve27(response);
44503
+ resolve28(response);
44323
44504
  acknowledge?.();
44324
44505
  }, reject);
44325
44506
  });
44326
44507
  }
44327
44508
 
44509
+ // src/plugin/shared/vault-routing.ts
44510
+ var ROUTING_GROUP_SCOPED_EXHAUSTION = false;
44511
+ function hasVaultRoutingAccessor() {
44512
+ try {
44513
+ return typeof Reflect.get(globalThis, /* @__PURE__ */ Symbol.for("cortexkit.routing")) === "function";
44514
+ } catch {
44515
+ return false;
44516
+ }
44517
+ }
44518
+ function routingQuotaScope(group, window) {
44519
+ const limitWindow = window === "5h" ? "five_hour" : window === "weekly" ? "seven_day" : void 0;
44520
+ return limitWindow ? { pool: group === "non-gemini" ? "3p" : group, limitWindow } : void 0;
44521
+ }
44522
+ function routingExhaustionFields(scope) {
44523
+ return {
44524
+ pool: scope.pool,
44525
+ window: scope.limitWindow === "five_hour" ? "5h" : "7d"
44526
+ };
44527
+ }
44528
+ function reportVaultExhaustion(input2, groupScopedExhaustion = ROUTING_GROUP_SCOPED_EXHAUSTION, report = reportRouting) {
44529
+ if (!hasVaultRoutingAccessor() || input2.signal?.aborted || input2.status !== 429 || input2.reason !== "QUOTA_EXHAUSTED" || !Number.isFinite(input2.observedAt) || (input2.observedAt ?? 0) <= 0 || (input2.observedAt ?? Infinity) > Date.now())
44530
+ return;
44531
+ for (const window of input2.quota?.windows ?? []) {
44532
+ if (window.remainingFraction !== 0) continue;
44533
+ const scope = routingQuotaScope(input2.group, window.window);
44534
+ const resetsAt = Date.parse(window.resetTime);
44535
+ if (!scope || !Number.isFinite(resetsAt) || resetsAt <= Date.now()) continue;
44536
+ if (groupScopedExhaustion)
44537
+ report({
44538
+ ...input2.identity,
44539
+ outcome: "exhausted",
44540
+ ...routingExhaustionFields(scope),
44541
+ resetsAt
44542
+ });
44543
+ }
44544
+ }
44545
+ var RATE_LIMIT_HEADERS = [
44546
+ "retry-after",
44547
+ "retry-after-ms",
44548
+ "ratelimit-limit",
44549
+ "ratelimit-remaining",
44550
+ "ratelimit-reset",
44551
+ "ratelimit-policy",
44552
+ "x-ratelimit-limit",
44553
+ "x-ratelimit-remaining",
44554
+ "x-ratelimit-reset",
44555
+ "x-ratelimit-limit-requests",
44556
+ "x-ratelimit-remaining-requests",
44557
+ "x-ratelimit-reset-requests",
44558
+ "x-ratelimit-limit-tokens",
44559
+ "x-ratelimit-remaining-tokens",
44560
+ "x-ratelimit-reset-tokens"
44561
+ ];
44562
+ function streamFailure(value) {
44563
+ if (!value || typeof value !== "object") return false;
44564
+ if (Array.isArray(value)) return value.some(streamFailure);
44565
+ const event = value;
44566
+ return event.error != null || event.type === "error" || event.type === "response.failed" || event.status === "failed" || streamFailure(event.response);
44567
+ }
44568
+ function observeVaultUpstream(response, signal) {
44569
+ if (!hasVaultRoutingAccessor() || !response.ok || signal?.aborted)
44570
+ return void 0;
44571
+ let completed = false;
44572
+ return {
44573
+ response: observeBody(response, () => {
44574
+ completed = !signal?.aborted;
44575
+ }),
44576
+ completedSuccessfully: () => completed
44577
+ };
44578
+ }
44579
+ function observeVaultServed(identity3, response, signal, upstream) {
44580
+ if (!hasVaultRoutingAccessor() || !response.ok || signal?.aborted)
44581
+ return response;
44582
+ const report = () => {
44583
+ if (signal?.aborted || upstream && !upstream.completedSuccessfully() || !hasVaultRoutingAccessor())
44584
+ return;
44585
+ const headers = {};
44586
+ for (const name of RATE_LIMIT_HEADERS) {
44587
+ const value = response.headers.get(name);
44588
+ if (value !== null) headers[name] = value;
44589
+ }
44590
+ reportRouting({ ...identity3, outcome: "served", headers });
44591
+ };
44592
+ return observeBody(response, report);
44593
+ }
44594
+ function observeBody(response, complete) {
44595
+ if (!response.body) {
44596
+ complete();
44597
+ return response;
44598
+ }
44599
+ const sse = response.headers.get("content-type")?.includes("text/event-stream");
44600
+ const reader = response.body.getReader();
44601
+ const decoder = new TextDecoder();
44602
+ let pending = "";
44603
+ let failed = false;
44604
+ const inspect = (line) => {
44605
+ if (line.length > 1024 * 1024) {
44606
+ failed = true;
44607
+ return;
44608
+ }
44609
+ if (line.startsWith("event:") && line.slice(6).trim() === "error")
44610
+ failed = true;
44611
+ if (!line.startsWith("data:") || !/"(?:error|response.failed|failed)"/.test(line))
44612
+ return;
44613
+ try {
44614
+ failed ||= streamFailure(JSON.parse(line.slice(5)));
44615
+ } catch {
44616
+ failed = true;
44617
+ }
44618
+ };
44619
+ const body = new ReadableStream(
44620
+ {
44621
+ async pull(controller) {
44622
+ try {
44623
+ const chunk = await reader.read();
44624
+ if (chunk.done) {
44625
+ if (sse) inspect(pending + decoder.decode());
44626
+ else if (/"(?:error|response.failed|failed)"/.test(pending)) {
44627
+ try {
44628
+ failed ||= streamFailure(JSON.parse(pending + decoder.decode()));
44629
+ } catch {
44630
+ failed = true;
44631
+ }
44632
+ }
44633
+ if (!failed) complete();
44634
+ controller.close();
44635
+ reader.releaseLock();
44636
+ return;
44637
+ }
44638
+ if (!failed) {
44639
+ pending += decoder.decode(chunk.value, { stream: true });
44640
+ if (sse) {
44641
+ let newline = pending.indexOf("\n");
44642
+ while (newline >= 0) {
44643
+ inspect(pending.slice(0, newline));
44644
+ pending = pending.slice(newline + 1);
44645
+ newline = pending.indexOf("\n");
44646
+ }
44647
+ }
44648
+ if (pending.length > 1024 * 1024) {
44649
+ failed = true;
44650
+ pending = "";
44651
+ }
44652
+ }
44653
+ controller.enqueue(chunk.value);
44654
+ } catch (error) {
44655
+ failed = true;
44656
+ controller.error(error);
44657
+ reader.releaseLock();
44658
+ }
44659
+ },
44660
+ async cancel(reason) {
44661
+ failed = true;
44662
+ try {
44663
+ await reader.cancel(reason);
44664
+ } finally {
44665
+ reader.releaseLock();
44666
+ }
44667
+ }
44668
+ },
44669
+ { highWaterMark: 0 }
44670
+ );
44671
+ const observed = new Response(body, {
44672
+ status: response.status,
44673
+ statusText: response.statusText,
44674
+ headers: response.headers
44675
+ });
44676
+ Object.defineProperties(observed, {
44677
+ url: { value: response.url },
44678
+ redirected: { value: response.redirected }
44679
+ });
44680
+ return observed;
44681
+ }
44682
+
44683
+ // src/plugin/shared/vault-routing-purpose.ts
44684
+ var VAULT_ROUTING_PURPOSE_HEADER = "x-antigravity-internal-request-purpose";
44685
+ function createVaultRoutingHeaders(providerId) {
44686
+ return async (input2, output2) => {
44687
+ if (input2.model.providerID !== providerId) return;
44688
+ output2.headers[VAULT_ROUTING_PURPOSE_HEADER] = input2.agent === "build" || input2.agent === "plan" ? "primary" : "auxiliary";
44689
+ };
44690
+ }
44691
+ function isPrimaryVaultRequest(kind, headers) {
44692
+ return kind === void 0 ? new Headers(headers).get(VAULT_ROUTING_PURPOSE_HEADER) === "primary" : kind === "primary";
44693
+ }
44694
+
44328
44695
  // src/plugin/shared/request-services.ts
44329
44696
  var FIRST_RETRY_DELAY_MS = 1e3;
44330
44697
  function prepareAgyWireRequest(wire, request) {
@@ -44421,7 +44788,7 @@ function formatWaitTime(ms) {
44421
44788
  return remainingMinutes > 0 ? `${hours}h ${remainingMinutes}m` : `${hours}h`;
44422
44789
  }
44423
44790
  function sleep4(ms, signal) {
44424
- return new Promise((resolve27, reject) => {
44791
+ return new Promise((resolve28, reject) => {
44425
44792
  if (signal?.aborted) {
44426
44793
  reject(
44427
44794
  signal.reason instanceof Error ? signal.reason : new Error("Aborted")
@@ -44430,7 +44797,7 @@ function sleep4(ms, signal) {
44430
44797
  }
44431
44798
  const timeout = setTimeout(() => {
44432
44799
  cleanup2();
44433
- resolve27();
44800
+ resolve28();
44434
44801
  }, ms);
44435
44802
  const onAbort = () => {
44436
44803
  cleanup2();
@@ -44516,7 +44883,7 @@ function createRequestExecutor(deps) {
44516
44883
  log16.debug("send-admission-401-report-failed", { error: String(error) });
44517
44884
  });
44518
44885
  };
44519
- const reportRouting = (sessionId, entry) => {
44886
+ const reportRouting2 = (sessionId, entry) => {
44520
44887
  if (!onRouting) return;
44521
44888
  try {
44522
44889
  onRouting(sessionId, entry);
@@ -44687,6 +45054,7 @@ function createRequestExecutor(deps) {
44687
45054
  const maxWaitMs = (config.max_rate_limit_wait_seconds ?? 300) * 1e3;
44688
45055
  let allAccountsBlockedAt;
44689
45056
  const modelUnavailableIndexes = /* @__PURE__ */ new Set();
45057
+ let routingPlacementConsidered = false;
44690
45058
  while (true) {
44691
45059
  await assertAdmission();
44692
45060
  checkAborted();
@@ -44770,6 +45138,11 @@ function createRequestExecutor(deps) {
44770
45138
  }
44771
45139
  }
44772
45140
  const excludedIndexes = modelUnavailableIndexes.size === 0 ? killedIndexes : /* @__PURE__ */ new Set([...killedIndexes ?? [], ...modelUnavailableIndexes]);
45141
+ const routingPresent = credentials.domain === "vault" && hasVaultRoutingAccessor();
45142
+ const firstPlacement = routingPresent && !routingPlacementConsidered && accountSessionIdentity && !accountManager.getCurrentAccountForFamily(
45143
+ family,
45144
+ accountSessionIdentity
45145
+ );
44773
45146
  let account = accountManager.getCurrentOrNextForFamily(
44774
45147
  family,
44775
45148
  model,
@@ -44780,6 +45153,50 @@ function createRequestExecutor(deps) {
44780
45153
  accountSessionIdentity,
44781
45154
  excludedIndexes
44782
45155
  );
45156
+ if (account) {
45157
+ routingPlacementConsidered = true;
45158
+ if (firstPlacement && credentials.domain === "vault" && credentials.routingCandidate && model && isPrimaryVaultRequest(kind, init?.headers)) {
45159
+ const candidates = accountManager.getEnabledAccounts().filter(
45160
+ (row) => !excludedIndexes?.has(row.index) && !accountManager.isRateLimited(row, family, model) && !accountManager.isAccountCoolingDown(row) && !accountManager.isAccountOverSoftQuota(
45161
+ row,
45162
+ family,
45163
+ config.soft_quota_threshold_percent,
45164
+ softQuotaCacheTtlMs,
45165
+ model
45166
+ )
45167
+ ).map((row) => ({
45168
+ ...credentials.routingCandidate(row),
45169
+ index: row.index
45170
+ }));
45171
+ if (candidates.length > 0) {
45172
+ const answer = await deadline.wait(
45173
+ () => askRouting({
45174
+ sessionId: accountSessionIdentity.id,
45175
+ provider: "antigravity",
45176
+ modelId: model,
45177
+ candidates,
45178
+ deadlineMs: Math.min(500, deadline.remainingMs())
45179
+ })
45180
+ );
45181
+ checkAborted();
45182
+ if (answer && answer.candidate.index !== account.index) {
45183
+ account = accountManager.getCurrentOrNextForFamily(
45184
+ family,
45185
+ model,
45186
+ config.account_selection_strategy,
45187
+ config.pid_offset_enabled,
45188
+ config.soft_quota_threshold_percent,
45189
+ softQuotaCacheTtlMs,
45190
+ accountSessionIdentity,
45191
+ /* @__PURE__ */ new Set([
45192
+ ...excludedIndexes ?? [],
45193
+ ...accountManager.getAccounts().filter((row) => row.index !== answer.candidate.index).map((row) => row.index)
45194
+ ])
45195
+ ) ?? account;
45196
+ }
45197
+ }
45198
+ }
45199
+ }
44783
45200
  if (account && eligibleIndexes !== null && !eligibleIndexes.has(account.index)) {
44784
45201
  pushDebug(
44785
45202
  `killswitch-excluded idx=${account.index} (precomputed eligible set)`
@@ -45439,7 +45856,7 @@ function createRequestExecutor(deps) {
45439
45856
  strategy: config.account_selection_strategy,
45440
45857
  updatedAt: Date.now()
45441
45858
  };
45442
- reportRouting(sessionKey, routingEntry);
45859
+ reportRouting2(sessionKey, routingEntry);
45443
45860
  }
45444
45861
  if (response.status === 429 || response.status === 503 || response.status === 529) {
45445
45862
  if (tokenConsumed) {
@@ -45474,6 +45891,26 @@ function createRequestExecutor(deps) {
45474
45891
  reasonInfo.message,
45475
45892
  response.status
45476
45893
  );
45894
+ if (credentials.domain === "vault" && sendAdmission && sessionKey && hasVaultRoutingAccessor()) {
45895
+ const group = resolveQuotaGroup(
45896
+ family,
45897
+ model,
45898
+ account.cachedQuota
45899
+ );
45900
+ reportVaultExhaustion({
45901
+ identity: {
45902
+ sessionId: sessionKey,
45903
+ accountId: sendAdmission.accountIdentity,
45904
+ credentialId: sendAdmission.credentialId
45905
+ },
45906
+ status: response.status,
45907
+ reason: rateLimitReason,
45908
+ group,
45909
+ quota: account.cachedQuota?.[group],
45910
+ observedAt: account.cachedQuotaUpdatedAt,
45911
+ signal: abortSignal
45912
+ });
45913
+ }
45477
45914
  if (rateLimitReason === "MODEL_CAPACITY_EXHAUSTED" || rateLimitReason === "SERVER_ERROR") {
45478
45915
  totalCapacityRetries++;
45479
45916
  if (isCapacityRetryBudgetExhausted(totalCapacityRetries)) {
@@ -45811,9 +46248,10 @@ function createRequestExecutor(deps) {
45811
46248
  const _emptyAttemptKeyClean = `${prepared.sessionId ?? "none"}:${prepared.effectiveModel ?? "unknown"}`;
45812
46249
  retryState.clearEmptyResponseAttempts();
45813
46250
  }
46251
+ const routingObservation = credentials.domain === "vault" && sendAdmission && sessionKey && response.ok && hasVaultRoutingAccessor() ? observeVaultUpstream(response, abortSignal) : void 0;
45814
46252
  const transformedResponse = await deadline.wait(
45815
46253
  () => wire.transformResponse(
45816
- response,
46254
+ routingObservation?.response ?? response,
45817
46255
  prepared.streaming,
45818
46256
  debugContext,
45819
46257
  prepared.requestedModel,
@@ -45885,7 +46323,16 @@ function createRequestExecutor(deps) {
45885
46323
  const refresh = credentials.refreshQuotaAfterSuccess;
45886
46324
  waitPolicy.quota = (signal) => refresh(account, config.quota_refresh_interval_minutes, signal);
45887
46325
  }
45888
- return transformedResponse;
46326
+ return routingObservation && credentials.domain === "vault" && sendAdmission && sessionKey && hasVaultRoutingAccessor() && response.ok ? observeVaultServed(
46327
+ {
46328
+ sessionId: sessionKey,
46329
+ accountId: sendAdmission.accountIdentity,
46330
+ credentialId: sendAdmission.credentialId
46331
+ },
46332
+ transformedResponse,
46333
+ abortSignal,
46334
+ routingObservation
46335
+ ) : transformedResponse;
45889
46336
  } catch (error) {
45890
46337
  if (error instanceof PreResponseTimeoutError) throw error;
45891
46338
  checkAborted();
@@ -47513,7 +47960,7 @@ function createGaReauthorize(input2) {
47513
47960
  const continuations = /* @__PURE__ */ new Set();
47514
47961
  const shutdown = new AbortController();
47515
47962
  let disposed = false;
47516
- const waitForRedirect = (code2) => new Promise((resolve27, reject) => {
47963
+ const waitForRedirect = (code2) => new Promise((resolve28, reject) => {
47517
47964
  const detach = () => shutdown.signal.removeEventListener("abort", abort);
47518
47965
  const abort = () => {
47519
47966
  detach();
@@ -47524,7 +47971,7 @@ function createGaReauthorize(input2) {
47524
47971
  void code2.then(
47525
47972
  (value) => {
47526
47973
  detach();
47527
- resolve27(value);
47974
+ resolve28(value);
47528
47975
  },
47529
47976
  (error) => {
47530
47977
  detach();
@@ -50185,11 +50632,11 @@ init_dist();
50185
50632
  var GA_POOL_METHOD_ID = "antigravity-auth-pool-browser";
50186
50633
  var LOGIN_FAILED = "The Antigravity pool login could not be completed.";
50187
50634
  function abortable(pending, signal) {
50188
- return new Promise((resolve27, reject) => {
50635
+ return new Promise((resolve28, reject) => {
50189
50636
  const abort = () => reject(signal.reason);
50190
50637
  if (signal.aborted) abort();
50191
50638
  else signal.addEventListener("abort", abort, { once: true });
50192
- void pending.then(resolve27, reject).finally(() => {
50639
+ void pending.then(resolve28, reject).finally(() => {
50193
50640
  signal.removeEventListener("abort", abort);
50194
50641
  });
50195
50642
  });
@@ -50559,11 +51006,11 @@ async function startGaLoopbackBridge(options) {
50559
51006
  }
50560
51007
  }
50561
51008
  };
50562
- await new Promise((resolve27, reject) => {
51009
+ await new Promise((resolve28, reject) => {
50563
51010
  server.once("error", reject);
50564
51011
  server.listen(0, BRIDGE_HOST, () => {
50565
51012
  server.off("error", reject);
50566
- resolve27();
51013
+ resolve28();
50567
51014
  });
50568
51015
  });
50569
51016
  server.unref();
@@ -50667,8 +51114,8 @@ async function startGaLoopbackBridge(options) {
50667
51114
  disposal = (async () => {
50668
51115
  for (const { timer } of queued.values()) clearTimeout(timer);
50669
51116
  queued.clear();
50670
- const closed2 = new Promise((resolve27) => {
50671
- server.close(() => resolve27());
51117
+ const closed2 = new Promise((resolve28) => {
51118
+ server.close(() => resolve28());
50672
51119
  });
50673
51120
  for (const controller of running) {
50674
51121
  controller.abort(
@@ -50732,9 +51179,9 @@ async function pipeResponse(upstream, response, onFailure, onHandoff) {
50732
51179
  return;
50733
51180
  }
50734
51181
  if (!response.write(value) && !response.destroyed) {
50735
- await new Promise((resolve27) => {
50736
- response.once("drain", resolve27);
50737
- response.once("close", resolve27);
51182
+ await new Promise((resolve28) => {
51183
+ response.once("drain", resolve28);
51184
+ response.once("close", resolve28);
50738
51185
  });
50739
51186
  }
50740
51187
  if (response.destroyed) {
@@ -50775,30 +51222,30 @@ function classifyGaSetupContext(context) {
50775
51222
  const location = record3.location;
50776
51223
  if (session === void 0 && location === void 0) return "legacy";
50777
51224
  const missing = [];
50778
- if (!isObject2(location) || typeof location.directory !== "string") {
51225
+ if (!isObject3(location) || typeof location.directory !== "string") {
50779
51226
  missing.push("location.directory");
50780
51227
  }
50781
- if (!isObject2(session) || typeof session.hook !== "function") {
51228
+ if (!isObject3(session) || typeof session.hook !== "function") {
50782
51229
  missing.push("session.hook");
50783
51230
  }
50784
51231
  if (session !== void 0 && location !== void 0 && missing.length === 0) {
50785
51232
  const rpc = record3.rpc;
50786
- if (!isObject2(rpc) && typeof rpc !== "function" || typeof Reflect.get(rpc, "register") !== "function") {
51233
+ if (!isObject3(rpc) && typeof rpc !== "function" || typeof Reflect.get(rpc, "register") !== "function") {
50787
51234
  missing.push("rpc.register");
50788
51235
  }
50789
51236
  const provider2 = record3.provider;
50790
- if (!isObject2(provider2) || typeof provider2.transform !== "function") {
51237
+ if (!isObject3(provider2) || typeof provider2.transform !== "function") {
50791
51238
  missing.push("provider.transform");
50792
51239
  }
50793
51240
  const command = record3.command;
50794
- if (!isObject2(command) || typeof command.transform !== "function") {
51241
+ if (!isObject3(command) || typeof command.transform !== "function") {
50795
51242
  missing.push("command.transform");
50796
51243
  }
50797
51244
  }
50798
51245
  if (missing.length > 0) throw new GaSetupContextError(missing);
50799
51246
  return "ga";
50800
51247
  }
50801
- function isObject2(value) {
51248
+ function isObject3(value) {
50802
51249
  return typeof value === "object" && value !== null;
50803
51250
  }
50804
51251
  function createGaGeneration() {
@@ -51405,13 +51852,13 @@ function createGaAntigravityPlugin(overrides = {}) {
51405
51852
  // src/plugin/index.ts
51406
51853
  init_dist();
51407
51854
  import { createHash as createHash23, randomUUID as randomUUID22 } from "node:crypto";
51408
- import { join as join38, resolve as resolve26 } from "node:path";
51855
+ import { join as join39, resolve as resolve27 } from "node:path";
51409
51856
 
51410
51857
  // src/cli.ts
51411
51858
  init_dist();
51412
51859
  import { execFile } from "node:child_process";
51413
51860
  import { realpathSync as realpathSync5 } from "node:fs";
51414
- import { resolve as resolve23 } from "node:path";
51861
+ import { resolve as resolve24 } from "node:path";
51415
51862
  import { createInterface } from "node:readline/promises";
51416
51863
  import { fileURLToPath as fileURLToPath2 } from "node:url";
51417
51864
  import { promisify } from "node:util";
@@ -51468,7 +51915,7 @@ init_runtime_paths();
51468
51915
  // src/setup.ts
51469
51916
  init_dist();
51470
51917
  import { lstat as lstat9, readFile as readFile16 } from "node:fs/promises";
51471
- import { join as join29, resolve as resolve22 } from "node:path";
51918
+ import { join as join30, resolve as resolve23 } from "node:path";
51472
51919
 
51473
51920
  // src/common-auth-embedded/auth-menu/ansi.js
51474
51921
  var ANSI2 = {
@@ -51636,7 +52083,7 @@ async function select2(terminal, items, options) {
51636
52083
  writeLine("");
51637
52084
  renderedLines = lines;
51638
52085
  };
51639
- return new Promise((resolve27) => {
52086
+ return new Promise((resolve28) => {
51640
52087
  const wasRaw = stdin.isRaw ?? false;
51641
52088
  const cleanup2 = () => {
51642
52089
  if (cleaned)
@@ -51656,7 +52103,7 @@ async function select2(terminal, items, options) {
51656
52103
  };
51657
52104
  const finish = (value) => {
51658
52105
  cleanup2();
51659
- resolve27(value);
52106
+ resolve28(value);
51660
52107
  };
51661
52108
  const onSignal = () => finish(null);
51662
52109
  const onKey = (data) => {
@@ -51696,7 +52143,7 @@ async function select2(terminal, items, options) {
51696
52143
  stdin.setRawMode(true);
51697
52144
  } catch {
51698
52145
  cleanup2();
51699
- resolve27(null);
52146
+ resolve28(null);
51700
52147
  return;
51701
52148
  }
51702
52149
  stdin.resume();
@@ -51710,12 +52157,12 @@ async function select2(terminal, items, options) {
51710
52157
  import { createHash as createHash18, randomBytes as randomBytes6, randomUUID as randomUUID19 } from "node:crypto";
51711
52158
  import { constants as fsConstants2 } from "node:fs";
51712
52159
  import { chmod as chmod6, mkdir as mkdir15, open as open10, readFile as readFile14, realpath as realpath4, rename as rename12, stat as stat11, unlink as unlink10 } from "node:fs/promises";
51713
- import { basename as basename6, dirname as dirname22, extname as extname2, isAbsolute as isAbsolute3, join as join25, resolve as resolve21 } from "node:path";
52160
+ import { basename as basename6, dirname as dirname22, extname as extname2, isAbsolute as isAbsolute3, join as join26, resolve as resolve22 } from "node:path";
51714
52161
  import { ClaustrumCredentialError as ClaustrumCredentialError5, ClaustrumClient as ClaustrumWireClient2, writeEnrollmentTokenFile as writeEnrollmentTokenFile2 } from "@cortexkit/claustrum-client";
51715
52162
 
51716
52163
  // src/common-auth-embedded/fs/file-read-cache.js
51717
52164
  import { lstat as lstat7 } from "node:fs/promises";
51718
- import { resolve as resolve20 } from "node:path";
52165
+ import { resolve as resolve21 } from "node:path";
51719
52166
  async function identity2(path5) {
51720
52167
  try {
51721
52168
  const metadata = await lstat7(path5);
@@ -51732,7 +52179,7 @@ function sameIdentity2(left, right) {
51732
52179
  var FileReadCache2 = class {
51733
52180
  #entries = /* @__PURE__ */ new Map();
51734
52181
  async read(paths, read, validateHit) {
51735
- const resolvedPaths = paths.map((path5) => resolve20(path5));
52182
+ const resolvedPaths = paths.map((path5) => resolve21(path5));
51736
52183
  const key = JSON.stringify(resolvedPaths);
51737
52184
  const probed = await Promise.all(resolvedPaths.map(identity2));
51738
52185
  const identities = probed.every((entry) => entry !== void 0) ? probed : void 0;
@@ -51784,9 +52231,10 @@ init_private_files2();
51784
52231
  init_private_files2();
51785
52232
  import { randomUUID as randomUUID18 } from "node:crypto";
51786
52233
  import { lstat as lstat8, mkdir as mkdir14, open as open9, readFile as readFile13, rename as rename11, rm as rm6, stat as stat10 } from "node:fs/promises";
51787
- import { dirname as dirname21, join as join24 } from "node:path";
52234
+ import { dirname as dirname21, join as join25 } from "node:path";
51788
52235
 
51789
52236
  // src/common-auth-embedded/fs/with-lock.js
52237
+ init_private_files2();
51790
52238
  function lockPathFor2(target, name) {
51791
52239
  return `${target}.${name}.lock`;
51792
52240
  }
@@ -51844,7 +52292,7 @@ function acquireRefreshFileLock2(options) {
51844
52292
  }
51845
52293
  async function acquireRefreshFileLockWithClock2(options) {
51846
52294
  const lockPath = lockPathFor2(options.path, options.name);
51847
- const legacyOwnerPath = join24(lockPath, "owner.json");
52295
+ const legacyOwnerPath = join25(lockPath, "owner.json");
51848
52296
  const ownerId = randomUUID18();
51849
52297
  const now = options.now ?? Date.now;
51850
52298
  let renewTimer = null;
@@ -51852,8 +52300,8 @@ async function acquireRefreshFileLockWithClock2(options) {
51852
52300
  let releaseConfirmed = false;
51853
52301
  let loss;
51854
52302
  let resolveLoss;
51855
- const lostPromise = new Promise((resolve27) => {
51856
- resolveLoss = resolve27;
52303
+ const lostPromise = new Promise((resolve28) => {
52304
+ resolveLoss = resolve28;
51857
52305
  });
51858
52306
  function notifyTimerStep(event) {
51859
52307
  try {
@@ -51887,7 +52335,7 @@ async function acquireRefreshFileLockWithClock2(options) {
51887
52335
  let terminalIOError;
51888
52336
  let renewalInFlight = null;
51889
52337
  const evictPath = `${lockPath}.evicting`;
51890
- const evictOwnerPath = join24(evictPath, "owner.json");
52338
+ const evictOwnerPath = join25(evictPath, "owner.json");
51891
52339
  const evictOwnerId = randomUUID18();
51892
52340
  const EVICT_TTL = 5e3;
51893
52341
  const MAX_STEAL_ATTEMPTS = 8;
@@ -52014,7 +52462,7 @@ async function acquireRefreshFileLockWithClock2(options) {
52014
52462
  }
52015
52463
  }
52016
52464
  async function backoff() {
52017
- await new Promise((resolve27) => setTimeout(resolve27, Math.floor(Math.random() * 4)));
52465
+ await new Promise((resolve28) => setTimeout(resolve28, Math.floor(Math.random() * 4)));
52018
52466
  }
52019
52467
  async function readLockState(notifyReady = true) {
52020
52468
  if (notifyReady && options.onStep)
@@ -52504,7 +52952,7 @@ async function acquireRefreshFileLockWithClock2(options) {
52504
52952
  const remainingMs = deadline - performance.now();
52505
52953
  if (remainingMs <= 0)
52506
52954
  break;
52507
- await new Promise((resolve27) => setTimeout(resolve27, Math.min(delayMs, remainingMs)));
52955
+ await new Promise((resolve28) => setTimeout(resolve28, Math.min(delayMs, remainingMs)));
52508
52956
  delayMs = Math.min(delayMs * 2, 50);
52509
52957
  }
52510
52958
  if (windowsPrivateFiles2)
@@ -52569,7 +53017,7 @@ function getClaustrumEnrollmentPaths2(tokenPath) {
52569
53017
  const extension = extname2(tokenPath) || ".json";
52570
53018
  const stem = basename6(tokenPath, extname2(tokenPath));
52571
53019
  return {
52572
- statePath: join25(dirname22(tokenPath), `${stem}-state${extension}`),
53020
+ statePath: join26(dirname22(tokenPath), `${stem}-state${extension}`),
52573
53021
  tokenPath
52574
53022
  };
52575
53023
  }
@@ -52577,7 +53025,7 @@ function hostEnrollmentPaths2(input2) {
52577
53025
  const override = input2.override?.trim();
52578
53026
  if (override && !isAbsolute3(override) && !input2.cwd)
52579
53027
  throw new ClaustrumConsumerError2("invalid-state", "A relative Claustrum enrollment override needs a base directory");
52580
- const tokenPath = override ? isAbsolute3(override) ? override : resolve21(input2.cwd, override) : join25(input2.stateDir, `${input2.host}-enrollment.json`);
53028
+ const tokenPath = override ? isAbsolute3(override) ? override : resolve22(input2.cwd, override) : join26(input2.stateDir, `${input2.host}-enrollment.json`);
52581
53029
  return getClaustrumEnrollmentPaths2(tokenPath);
52582
53030
  }
52583
53031
  function isRecord11(value) {
@@ -52810,7 +53258,7 @@ async function writeStateAtomic2(path5, state, ancestorOptions = {}) {
52810
53258
  }
52811
53259
  if (windowsPrivateFiles2)
52812
53260
  return writePrivateAtomic2(path5, bytes);
52813
- const temporary = join25(parent, `.${basename6(path5)}.${process.pid}.${randomUUID19()}.tmp`);
53261
+ const temporary = join26(parent, `.${basename6(path5)}.${process.pid}.${randomUUID19()}.tmp`);
52814
53262
  let descriptor;
52815
53263
  let created = false;
52816
53264
  try {
@@ -53205,7 +53653,7 @@ var ByteTail = class {
53205
53653
  };
53206
53654
  var defaultCommandRunner = {
53207
53655
  run(file, args, options = {}) {
53208
- return new Promise((resolve27) => {
53656
+ return new Promise((resolve28) => {
53209
53657
  const started = performance.now();
53210
53658
  const timeoutMs = options.timeoutMs ?? 15e3;
53211
53659
  const stderr = new ByteTail();
@@ -53223,7 +53671,7 @@ var defaultCommandRunner = {
53223
53671
  stdio: ["ignore", "pipe", "pipe"]
53224
53672
  });
53225
53673
  } catch {
53226
- resolve27({
53674
+ resolve28({
53227
53675
  exitCode: 1,
53228
53676
  stdout: "",
53229
53677
  stderr: "",
@@ -53258,7 +53706,7 @@ var defaultCommandRunner = {
53258
53706
  settled = true;
53259
53707
  if (timer)
53260
53708
  clearTimeout(timer);
53261
- resolve27({
53709
+ resolve28({
53262
53710
  exitCode: spawnError ? 1 : outputExceeded ? 1 : code2 ?? 1,
53263
53711
  stdout: Buffer.concat(stdout, stdoutLength).toString("utf8"),
53264
53712
  stderr: stderr.toString(),
@@ -53345,7 +53793,7 @@ function recordSetupEnrollment(failure2, enrollment) {
53345
53793
  import { accessSync, constants as constants3, existsSync as existsSync12, readFileSync as readFileSync10, realpathSync as realpathSync4, statSync as statSync5 } from "node:fs";
53346
53794
  import { mkdtemp, rm as rm7 } from "node:fs/promises";
53347
53795
  import { tmpdir as tmpdir5 } from "node:os";
53348
- import { join as join26 } from "node:path";
53796
+ import { join as join27 } from "node:path";
53349
53797
  import { parse } from "jsonc-parser";
53350
53798
 
53351
53799
  // src/common-auth-embedded/setup/paths.js
@@ -53516,7 +53964,7 @@ async function detectHosts(plugin2, io = {}) {
53516
53964
  return null;
53517
53965
  let root;
53518
53966
  try {
53519
- root = await mkdtemp(join26(tmpdir5(), "common-auth-setup-version-"));
53967
+ root = await mkdtemp(join27(tmpdir5(), "common-auth-setup-version-"));
53520
53968
  const probeEnv = {
53521
53969
  ...env3,
53522
53970
  HOME: root,
@@ -54101,7 +54549,7 @@ import { applyEdits, createScanner, findNodeAtLocation, modify, parse as parse2,
54101
54549
  // src/common-auth-embedded/setup/config-write.js
54102
54550
  import { randomUUID as randomUUID20 } from "node:crypto";
54103
54551
  import { mkdir as mkdir16, open as open11, rename as rename13, stat as stat13, unlink as unlink11 } from "node:fs/promises";
54104
- import { basename as basename7, dirname as dirname23, join as join27 } from "node:path";
54552
+ import { basename as basename7, dirname as dirname23, join as join28 } from "node:path";
54105
54553
  import { setTimeout as delay2 } from "node:timers/promises";
54106
54554
  async function writeHostConfigAtomic(file, content, options = {}) {
54107
54555
  const windows2 = (options.platform ?? process.platform) === "win32";
@@ -54116,7 +54564,7 @@ async function writeHostConfigAtomic(file, content, options = {}) {
54116
54564
  throw error;
54117
54565
  }
54118
54566
  }
54119
- const stage = join27(parent, `.${basename7(file)}.${(options.stageName ?? randomUUID20)()}.tmp`);
54567
+ const stage = join28(parent, `.${basename7(file)}.${(options.stageName ?? randomUUID20)()}.tmp`);
54120
54568
  let created = false;
54121
54569
  try {
54122
54570
  const handle = await open11(stage, "wx", mode ?? 438);
@@ -54536,11 +54984,11 @@ init_storage();
54536
54984
  init_dist();
54537
54985
  import { readFile as readFile15 } from "node:fs/promises";
54538
54986
  import { homedir as homedir11 } from "node:os";
54539
- import { join as join28 } from "node:path";
54987
+ import { join as join29 } from "node:path";
54540
54988
  var V1_VAULT_ACTIVATION_LABEL = "Activate approved Antigravity vault";
54541
54989
  function nativeOpenCodeAuthPath(env3 = process.env, home = homedir11()) {
54542
- return join28(
54543
- env3.XDG_DATA_HOME || join28(home, ".local", "share"),
54990
+ return join29(
54991
+ env3.XDG_DATA_HOME || join29(home, ".local", "share"),
54544
54992
  "opencode",
54545
54993
  "auth.json"
54546
54994
  );
@@ -54604,7 +55052,7 @@ function openCodeVaultDir(accountFile) {
54604
55052
  return folder.vaultDir;
54605
55053
  }
54606
55054
  function nativeAuthPath(host, context) {
54607
- return host === "opencode" ? nativeOpenCodeAuthPath() : join29(context.piAgentDir, "auth.json");
55055
+ return host === "opencode" ? nativeOpenCodeAuthPath() : join30(context.piAgentDir, "auth.json");
54608
55056
  }
54609
55057
  function provider(host) {
54610
55058
  return host === "opencode" ? OPENCODE_VAULT_PROVIDER : ANTIGRAVITY_PROVIDER_ID;
@@ -54660,7 +55108,7 @@ async function writeNativeSlot(host, slot, context, expectedAuthority = "local")
54660
55108
  beforeRename: async () => {
54661
55109
  await assertSetupHostsStopped();
54662
55110
  const claustrum = await loadCommonAuthClaustrum();
54663
- const stateDir = host === "opencode" ? openCodeVaultDir(resolve22(accountFileForVault())) : getPiAntigravityVaultDir();
55111
+ const stateDir = host === "opencode" ? openCodeVaultDir(resolve23(accountFileForVault())) : getPiAntigravityVaultDir();
54664
55112
  if (await claustrum.enrollmentAuthority(
54665
55113
  claustrum.hostEnrollmentPaths({ stateDir, host }),
54666
55114
  `antigravity-auth-${host}`
@@ -54698,7 +55146,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
54698
55146
  // `beforeSignIn`, which may move it after this plugin is built.
54699
55147
  paths: {
54700
55148
  get stateDir() {
54701
- return openCodeVaultDir(resolve22(accountFileForVault()));
55149
+ return openCodeVaultDir(resolve23(accountFileForVault()));
54702
55150
  },
54703
55151
  host: "opencode"
54704
55152
  }
@@ -54715,7 +55163,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
54715
55163
  const assertLocal = async (host, context) => {
54716
55164
  if (host === "opencode")
54717
55165
  return assertLocalOpenCodeLogin(
54718
- resolve22(accountFileForVault()),
55166
+ resolve23(accountFileForVault()),
54719
55167
  context.opencodeGeneration
54720
55168
  );
54721
55169
  if (await authority(host) !== "local")
@@ -54731,7 +55179,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
54731
55179
  const { openPiSlot: openPiSlot2 } = await loadCommonAuthPiSlot();
54732
55180
  if ((await openPiSlot2({
54733
55181
  authPath: nativeAuthPath(host, context),
54734
- stashPath: join29(piDir, "google-login-stash.json"),
55182
+ stashPath: join30(piDir, "google-login-stash.json"),
54735
55183
  provider: ANTIGRAVITY_PROVIDER_ID,
54736
55184
  placeholderKey: PI_PLACEHOLDER_KEY
54737
55185
  }).inspect()).slot === "placeholder")
@@ -54771,7 +55219,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
54771
55219
  const { openPiSlot: openPiSlot2 } = await loadCommonAuthPiSlot();
54772
55220
  const inspection = await openPiSlot2({
54773
55221
  authPath: nativeAuthPath("pi", context),
54774
- stashPath: join29(piDir, "google-login-stash.json"),
55222
+ stashPath: join30(piDir, "google-login-stash.json"),
54775
55223
  provider: ANTIGRAVITY_PROVIDER_ID,
54776
55224
  placeholderKey: PI_PLACEHOLDER_KEY
54777
55225
  }).inspect();
@@ -54890,7 +55338,7 @@ Setup has not completed the OpenCode 2 native Google connection.
54890
55338
  await assertSetupHostsStopped();
54891
55339
  await openPiSlot2({
54892
55340
  authPath: nativeAuthPath(host, context),
54893
- stashPath: join29(piDir, "google-login-stash.json"),
55341
+ stashPath: join30(piDir, "google-login-stash.json"),
54894
55342
  provider: ANTIGRAVITY_PROVIDER_ID,
54895
55343
  placeholderKey: PI_PLACEHOLDER_KEY
54896
55344
  }).enterVault();
@@ -55345,7 +55793,7 @@ async function runCliProcess(argv, deps) {
55345
55793
  ...deps,
55346
55794
  prepareVaultFolder: deps.prepareVaultFolder ?? (async (options) => {
55347
55795
  const folder = await prepareVaultFolder({
55348
- accountFile: resolve23(accountFileForVault()),
55796
+ accountFile: resolve24(accountFileForVault()),
55349
55797
  ...options
55350
55798
  });
55351
55799
  if (folder.refusal) throw folder.refusal;
@@ -55391,11 +55839,11 @@ function createDefaultCliDependencies() {
55391
55839
  );
55392
55840
  if (host !== "pi")
55393
55841
  await assertLocalOpenCodeLogin(
55394
- resolve23(accountFileForVault()),
55842
+ resolve24(accountFileForVault()),
55395
55843
  context?.opencodeGeneration
55396
55844
  );
55397
55845
  const repository = host === "pi" ? void 0 : await prepareCliLoginStore(
55398
- resolve23(getStoragePath()),
55846
+ resolve24(getStoragePath()),
55399
55847
  context?.opencodeGeneration
55400
55848
  );
55401
55849
  try {
@@ -55411,7 +55859,7 @@ function createDefaultCliDependencies() {
55411
55859
  }
55412
55860
  if (host === "opencode") await assertSetupHostsStopped();
55413
55861
  await assertLocalOpenCodeLogin(
55414
- resolve23(accountFileForVault()),
55862
+ resolve24(accountFileForVault()),
55415
55863
  context?.opencodeGeneration
55416
55864
  );
55417
55865
  await persistCliStoreLogin(
@@ -55431,7 +55879,7 @@ function createDefaultCliDependencies() {
55431
55879
  };
55432
55880
  }
55433
55881
  async function prepareCliLoginStore(legacyPath, generation) {
55434
- await assertLocalOpenCodeLogin(resolve23(accountFileForVault()), generation);
55882
+ await assertLocalOpenCodeLogin(resolve24(accountFileForVault()), generation);
55435
55883
  const modules = await loadCommonAuthStoreModules();
55436
55884
  const options = {
55437
55885
  legacyPath,
@@ -55556,7 +56004,7 @@ async function readAccountStore(legacyPath) {
55556
56004
  function createDefaultAccountStoreOperations() {
55557
56005
  const offline = { processesStopped: true };
55558
56006
  return {
55559
- legacyPath: () => resolve23(
56007
+ legacyPath: () => resolve24(
55560
56008
  decidedAccountStoreAnchor(runtimeLayoutLocation()) ? getStoragePath() : discoveredAccountFile()
55561
56009
  ),
55562
56010
  migrate: async (legacyPath) => createAccountMigrationFactory(await loadCommonAuthStoreModules())({
@@ -55587,7 +56035,7 @@ function createDefaultAccountStoreOperations() {
55587
56035
  };
55588
56036
  }
55589
56037
  function samePath(left, right) {
55590
- return process.platform === "win32" ? resolve23(left).toLowerCase() === resolve23(right).toLowerCase() : resolve23(left) === resolve23(right);
56038
+ return process.platform === "win32" ? resolve24(left).toLowerCase() === resolve24(right).toLowerCase() : resolve24(left) === resolve24(right);
55591
56039
  }
55592
56040
  function isCliEntry() {
55593
56041
  if (import.meta.main !== void 0) return import.meta.main;
@@ -56077,16 +56525,16 @@ function isTuiConnected(sessionId) {
56077
56525
  // src/rpc/rpc-dir.ts
56078
56526
  import { createHash as createHash19 } from "node:crypto";
56079
56527
  import { homedir as homedir13, tmpdir as tmpdir6 } from "node:os";
56080
- import { isAbsolute as isAbsolute4, join as join33, resolve as resolve24 } from "node:path";
56528
+ import { isAbsolute as isAbsolute4, join as join34, resolve as resolve25 } from "node:path";
56081
56529
  var RPC_DIR_ENV = "ANTIGRAVITY_AUTH_RPC_DIR";
56082
56530
  function getRpcDir(projectDirectory) {
56083
56531
  const override = process.env[RPC_DIR_ENV]?.trim();
56084
56532
  if (override) {
56085
- return isAbsolute4(override) ? override : resolve24(projectDirectory, override);
56533
+ return isAbsolute4(override) ? override : resolve25(projectDirectory, override);
56086
56534
  }
56087
- const projectHash = createHash19("sha256").update(resolve24(projectDirectory)).digest("hex").slice(0, 16);
56088
- const stateHome = process.env.XDG_STATE_HOME ?? join33(homedir13(), ".local", "state");
56089
- return join33(stateHome, "cortexkit", "antigravity-auth", "rpc", projectHash);
56535
+ const projectHash = createHash19("sha256").update(resolve25(projectDirectory)).digest("hex").slice(0, 16);
56536
+ const stateHome = process.env.XDG_STATE_HOME ?? join34(homedir13(), ".local", "state");
56537
+ return join34(stateHome, "cortexkit", "antigravity-auth", "rpc", projectHash);
56090
56538
  }
56091
56539
 
56092
56540
  // src/common-auth-embedded/rpc/notifications.js
@@ -56098,7 +56546,7 @@ function isSessionId(value) {
56098
56546
  init_private_files2();
56099
56547
  import { createHash as createHash20, randomUUID as randomUUID21 } from "node:crypto";
56100
56548
  import { chmod as chmod7, mkdir as mkdir17, open as open12, readdir as readdir4, rename as rename14, rmdir as rmdir3, stat as stat14, unlink as unlink12 } from "node:fs/promises";
56101
- import { join as join34, resolve as resolve25 } from "node:path";
56549
+ import { join as join35, resolve as resolve26 } from "node:path";
56102
56550
  function isProbeablePid(pid) {
56103
56551
  return typeof pid === "number" && Number.isSafeInteger(pid) && pid > 0;
56104
56552
  }
@@ -56129,7 +56577,7 @@ async function removeCorruptPortFile(portFile, log16) {
56129
56577
  }
56130
56578
  async function writePortFile(dir, entry, options = {}) {
56131
56579
  const writeOnce = async () => {
56132
- const target = join34(dir, `port-${entry.pid}.json`);
56580
+ const target = join35(dir, `port-${entry.pid}.json`);
56133
56581
  if (windowsPrivateFiles2) {
56134
56582
  await ensurePrivateDirectory2(dir, options.secureDir ?? false);
56135
56583
  await options.beforeWrite?.();
@@ -56185,12 +56633,12 @@ async function sweepRpcState(root, activeDir, isManagedDir, log16) {
56185
56633
  return;
56186
56634
  throw error;
56187
56635
  }
56188
- const active2 = resolve25(activeDir);
56636
+ const active2 = resolve26(activeDir);
56189
56637
  for (const projectDir of projectDirs) {
56190
56638
  if (!projectDir.isDirectory() || !isManagedDir(projectDir.name)) {
56191
56639
  continue;
56192
56640
  }
56193
- const dir = join34(root, projectDir.name);
56641
+ const dir = join35(root, projectDir.name);
56194
56642
  let names;
56195
56643
  try {
56196
56644
  names = await readdir4(dir);
@@ -56202,7 +56650,7 @@ async function sweepRpcState(root, activeDir, isManagedDir, log16) {
56202
56650
  for (const name of names) {
56203
56651
  if (!name.startsWith("port-") || !name.endsWith(".json"))
56204
56652
  continue;
56205
- const portFile = join34(dir, name);
56653
+ const portFile = join35(dir, name);
56206
56654
  let raw;
56207
56655
  try {
56208
56656
  raw = await readPrivateText2(portFile);
@@ -56229,7 +56677,7 @@ async function sweepRpcState(root, activeDir, isManagedDir, log16) {
56229
56677
  await unlink12(portFile).catch(() => {
56230
56678
  });
56231
56679
  }
56232
- if (resolve25(dir) !== active2)
56680
+ if (resolve26(dir) !== active2)
56233
56681
  await rmdir3(dir).catch(() => {
56234
56682
  });
56235
56683
  }
@@ -56243,7 +56691,7 @@ init_private_files2();
56243
56691
  import { randomBytes as randomBytes7, timingSafeEqual } from "node:crypto";
56244
56692
  import { unlink as unlink13 } from "node:fs/promises";
56245
56693
  import { createServer as createServer3 } from "node:http";
56246
- import { join as join35 } from "node:path";
56694
+ import { join as join36 } from "node:path";
56247
56695
  var RpcRequestError = class extends Error {
56248
56696
  status;
56249
56697
  constructor(status, message) {
@@ -56263,7 +56711,7 @@ var BodyTooLargeError = class extends Error {
56263
56711
  }
56264
56712
  };
56265
56713
  function readBody(req) {
56266
- return new Promise((resolve27, reject) => {
56714
+ return new Promise((resolve28, reject) => {
56267
56715
  const tooLarge = (declaredOversize = false) => {
56268
56716
  req.removeAllListeners("data");
56269
56717
  req.on("data", () => {
@@ -56286,7 +56734,7 @@ function readBody(req) {
56286
56734
  }
56287
56735
  chunks.push(chunk);
56288
56736
  });
56289
- req.on("end", () => resolve27(Buffer.concat(chunks).toString("utf8")));
56737
+ req.on("end", () => resolve28(Buffer.concat(chunks).toString("utf8")));
56290
56738
  req.on("error", reject);
56291
56739
  });
56292
56740
  }
@@ -56465,12 +56913,12 @@ async function startRpcServer(options) {
56465
56913
  json(500, { error: "internal error" });
56466
56914
  }
56467
56915
  }
56468
- const port = await new Promise((resolve27, reject) => {
56916
+ const port = await new Promise((resolve28, reject) => {
56469
56917
  server.on("error", reject);
56470
56918
  server.listen(0, "127.0.0.1", () => {
56471
56919
  const addr = server.address();
56472
56920
  if (addr && typeof addr === "object")
56473
- resolve27(addr.port);
56921
+ resolve28(addr.port);
56474
56922
  else
56475
56923
  reject(new Error("no port"));
56476
56924
  });
@@ -56493,20 +56941,20 @@ async function startRpcServer(options) {
56493
56941
  rpcPort: port
56494
56942
  });
56495
56943
  } catch (error) {
56496
- await new Promise((resolve27) => server.close(() => resolve27()));
56944
+ await new Promise((resolve28) => server.close(() => resolve28()));
56497
56945
  throw error;
56498
56946
  }
56499
56947
  return {
56500
56948
  port,
56501
56949
  token,
56502
56950
  async stop() {
56503
- await new Promise((resolve27) => {
56951
+ await new Promise((resolve28) => {
56504
56952
  server.closeAllConnections?.();
56505
- server.close(() => resolve27());
56953
+ server.close(() => resolve28());
56506
56954
  for (const socket of connections)
56507
56955
  socket.destroy();
56508
56956
  });
56509
- const portFile = join35(options.dir, `port-${process.pid}.json`);
56957
+ const portFile = join36(options.dir, `port-${process.pid}.json`);
56510
56958
  const current = await readPrivateText2(portFile).then((raw) => JSON.parse(raw)).catch((error) => {
56511
56959
  if (error instanceof PrivateFileError2 && error.code !== "ENOENT")
56512
56960
  throw error;
@@ -56826,7 +57274,7 @@ import { createInterface as createInterface2 } from "node:readline/promises";
56826
57274
  // src/plugin/config/updater.ts
56827
57275
  import { existsSync as existsSync15, mkdirSync as mkdirSync8, readFileSync as readFileSync13, writeFileSync as writeFileSync8 } from "node:fs";
56828
57276
  import { homedir as homedir14 } from "node:os";
56829
- import { dirname as dirname25, join as join36 } from "node:path";
57277
+ import { dirname as dirname25, join as join37 } from "node:path";
56830
57278
 
56831
57279
  // src/plugin/model-registry.ts
56832
57280
  init_dist();
@@ -56843,13 +57291,13 @@ function stripJsonCommentsAndTrailingCommas(json) {
56843
57291
  ).replace(/,(\s*[}\]])/g, "$1");
56844
57292
  }
56845
57293
  function getOpencodeConfigDir() {
56846
- const xdgConfig2 = process.env.XDG_CONFIG_HOME || join36(homedir14(), ".config");
56847
- return join36(xdgConfig2, "opencode");
57294
+ const xdgConfig2 = process.env.XDG_CONFIG_HOME || join37(homedir14(), ".config");
57295
+ return join37(xdgConfig2, "opencode");
56848
57296
  }
56849
57297
  function getOpencodeConfigPath() {
56850
57298
  const configDir = getOpencodeConfigDir();
56851
- const jsoncPath = join36(configDir, OPENCODE_JSONC_FILENAME);
56852
- const jsonPath = join36(configDir, OPENCODE_JSON_FILENAME);
57299
+ const jsoncPath = join37(configDir, OPENCODE_JSONC_FILENAME);
57300
+ const jsonPath = join37(configDir, OPENCODE_JSON_FILENAME);
56853
57301
  if (existsSync15(jsoncPath)) {
56854
57302
  return jsoncPath;
56855
57303
  }
@@ -57108,7 +57556,7 @@ async function select3(items, options) {
57108
57556
  }
57109
57557
  renderedLines = linesWritten;
57110
57558
  };
57111
- return new Promise((resolve27) => {
57559
+ return new Promise((resolve28) => {
57112
57560
  const wasRaw = stdin.isRaw ?? false;
57113
57561
  const cleanup2 = () => {
57114
57562
  if (isCleanedUp) return;
@@ -57129,11 +57577,11 @@ async function select3(items, options) {
57129
57577
  };
57130
57578
  const onSignal = () => {
57131
57579
  cleanup2();
57132
- resolve27(null);
57580
+ resolve28(null);
57133
57581
  };
57134
57582
  const finishWithValue = (value) => {
57135
57583
  cleanup2();
57136
- resolve27(value);
57584
+ resolve28(value);
57137
57585
  };
57138
57586
  const findNextSelectable = (from, direction) => {
57139
57587
  if (items.length === 0) return from;
@@ -57179,7 +57627,7 @@ async function select3(items, options) {
57179
57627
  stdin.setRawMode(true);
57180
57628
  } catch {
57181
57629
  cleanup2();
57182
- resolve27(null);
57630
+ resolve28(null);
57183
57631
  return;
57184
57632
  }
57185
57633
  stdin.resume();
@@ -60146,15 +60594,15 @@ init_debug();
60146
60594
  // src/plugin/dependencies.ts
60147
60595
  init_dist();
60148
60596
  import { homedir as homedir15 } from "node:os";
60149
- import { join as join37 } from "node:path";
60597
+ import { join as join38 } from "node:path";
60150
60598
  function defaultFilesystemRoots() {
60151
- const xdgConfig2 = process.env.XDG_CONFIG_HOME ?? join37(homedir15(), ".config");
60152
- const xdgState2 = process.env.XDG_STATE_HOME ?? join37(homedir15(), ".local", "state");
60599
+ const xdgConfig2 = process.env.XDG_CONFIG_HOME ?? join38(homedir15(), ".config");
60600
+ const xdgState2 = process.env.XDG_STATE_HOME ?? join38(homedir15(), ".local", "state");
60153
60601
  return {
60154
60602
  projectRoot: process.cwd(),
60155
- userConfigRoot: join37(xdgConfig2, "opencode"),
60156
- sidebarStateRoot: join37(xdgState2, "cortexkit", "antigravity-auth"),
60157
- rpcRoot: join37(xdgState2, "cortexkit", "antigravity-auth", "rpc")
60603
+ userConfigRoot: join38(xdgConfig2, "opencode"),
60604
+ sidebarStateRoot: join38(xdgState2, "cortexkit", "antigravity-auth"),
60605
+ rpcRoot: join38(xdgState2, "cortexkit", "antigravity-auth", "rpc")
60158
60606
  };
60159
60607
  }
60160
60608
  function resolvePluginDependencies(overrides = {}) {
@@ -60183,10 +60631,10 @@ function resolvePluginDependencies(overrides = {}) {
60183
60631
  }
60184
60632
  async function defaultSleep(ms, signal) {
60185
60633
  if (ms <= 0) return;
60186
- await new Promise((resolve27, reject) => {
60634
+ await new Promise((resolve28, reject) => {
60187
60635
  const timer = setTimeout(() => {
60188
60636
  signal?.removeEventListener("abort", onAbort);
60189
- resolve27();
60637
+ resolve28();
60190
60638
  }, ms);
60191
60639
  timer.unref?.();
60192
60640
  const onAbort = () => {
@@ -60906,8 +61354,8 @@ function createPluginLifecycle(options) {
60906
61354
  };
60907
61355
  let failDisposal = () => {
60908
61356
  };
60909
- disposal = new Promise((resolve27, reject) => {
60910
- finishDisposal = resolve27;
61357
+ disposal = new Promise((resolve28, reject) => {
61358
+ finishDisposal = resolve28;
60911
61359
  failDisposal = reject;
60912
61360
  });
60913
61361
  void (async () => {
@@ -61056,7 +61504,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
61056
61504
  await drainSidebarWrites();
61057
61505
  }
61058
61506
  });
61059
- const accountFile = resolve26(accountFileForVault());
61507
+ const accountFile = resolve27(accountFileForVault());
61060
61508
  const vaultFolder = await prepareVaultFolder({ accountFile });
61061
61509
  const unavailableMessage = vaultFolder.refusal?.message ?? VAULT_ACCOUNT_REMEDY;
61062
61510
  let vaultQuotaPoller;
@@ -61279,7 +61727,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
61279
61727
  lifecycle.register(vaultQuotaPoller, "producer");
61280
61728
  }
61281
61729
  const operatorSettings = createOperatorSettingsController({
61282
- projectConfigPath: join38(directory, ".opencode", "antigravity.json"),
61730
+ projectConfigPath: join39(directory, ".opencode", "antigravity.json"),
61283
61731
  // getUserConfigPath() already returns the full file path including
61284
61732
  // 'antigravity.json' — do NOT join again or the path double-nests
61285
61733
  // into <dir>/antigravity.json/antigravity.json.
@@ -61719,6 +62167,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
61719
62167
  );
61720
62168
  },
61721
62169
  "command.execute.before": commandExecuteBefore,
62170
+ "chat.headers": createVaultRoutingHeaders(providerId),
61722
62171
  event,
61723
62172
  tool: { google_search: googleSearchTool },
61724
62173
  auth: {