@cortexkit/opencode-antigravity-auth 3.0.19 → 3.0.21

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 (90) hide show
  1. package/README.md +3 -1
  2. package/dist/cli.js +277 -150
  3. package/dist/cli.js.map +3 -3
  4. package/dist/cli.meta.json +43 -23
  5. package/dist/index.js +331 -204
  6. package/dist/index.js.map +3 -3
  7. package/dist/index.meta.json +43 -23
  8. package/dist/server.js +344 -217
  9. package/dist/server.js.map +3 -3
  10. package/dist/server.meta.json +1 -1
  11. package/dist/src/common-auth-embedded/claustrum/consumer.d.ts +10 -0
  12. package/dist/src/common-auth-embedded/claustrum/consumer.js +25 -0
  13. package/dist/src/common-auth-embedded/claustrum/custody.d.ts +6 -2
  14. package/dist/src/common-auth-embedded/claustrum/custody.js +45 -6
  15. package/dist/src/common-auth-embedded/claustrum/hub.d.ts +3 -1
  16. package/dist/src/common-auth-embedded/claustrum/hub.js +75 -6
  17. package/dist/src/common-auth-embedded/claustrum/insula.js +6 -0
  18. package/dist/src/common-auth-embedded/claustrum/roster.js +1 -1
  19. package/dist/src/common-auth-embedded/fs/refresh-file-lock.d.ts +2 -1
  20. package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +3 -1
  21. package/dist/src/common-auth-embedded/fs/with-lock.js +1 -1
  22. package/dist/src/common-auth-embedded/opencode2/index.d.ts +1 -1
  23. package/dist/src/common-auth-embedded/opencode2/install.d.ts +4 -3
  24. package/dist/src/common-auth-embedded/opencode2/install.js +144 -17
  25. package/dist/src/common-auth-embedded/opencode2/types.d.ts +52 -1
  26. package/dist/src/common-auth-embedded/quota-sidebar/index.d.ts +86 -0
  27. package/dist/src/common-auth-embedded/quota-sidebar/index.tsx +630 -0
  28. package/dist/src/common-auth-embedded/source-output.json +73 -53
  29. package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
  30. package/dist/src/ga/tui/host-ga.js +2 -3
  31. package/dist/src/ga/tui/host-ga.js.map +1 -1
  32. package/dist/src/plugin/__fixtures__/verified-store.js +2 -2
  33. package/dist/src/server.d.ts +4 -4
  34. package/dist/src/server.js +4 -4
  35. package/dist/src/tui/quota-layout.d.ts +4 -58
  36. package/dist/src/tui/quota-layout.d.ts.map +1 -1
  37. package/dist/src/tui/quota-layout.js +4 -90
  38. package/dist/src/tui/quota-layout.js.map +1 -1
  39. package/dist/src/tui/sidebar-frame.d.ts +4 -35
  40. package/dist/src/tui/sidebar-frame.d.ts.map +1 -1
  41. package/dist/src/tui/sidebar-frame.js +91 -171
  42. package/dist/src/tui/sidebar-frame.js.map +1 -1
  43. package/dist/src/tui.js +3 -3
  44. package/dist/src/tui.js.map +1 -1
  45. package/dist/tui-build-map.json +27 -13
  46. package/dist/tui-ga-build-map.json +28 -13
  47. package/dist/types/src/common-auth-embedded/claustrum/consumer.d.ts +10 -0
  48. package/dist/types/src/common-auth-embedded/claustrum/custody.d.ts +6 -2
  49. package/dist/types/src/common-auth-embedded/claustrum/hub.d.ts +3 -1
  50. package/dist/types/src/common-auth-embedded/fs/refresh-file-lock.d.ts +2 -1
  51. package/dist/types/src/common-auth-embedded/opencode2/index.d.ts +1 -1
  52. package/dist/types/src/common-auth-embedded/opencode2/install.d.ts +4 -3
  53. package/dist/types/src/common-auth-embedded/opencode2/types.d.ts +52 -1
  54. package/dist/types/src/server.d.ts +4 -4
  55. package/package.json +3 -3
  56. package/src/common-auth-embedded/claustrum/consumer.d.ts +10 -0
  57. package/src/common-auth-embedded/claustrum/consumer.js +25 -0
  58. package/src/common-auth-embedded/claustrum/custody.d.ts +6 -2
  59. package/src/common-auth-embedded/claustrum/custody.js +45 -6
  60. package/src/common-auth-embedded/claustrum/hub.d.ts +3 -1
  61. package/src/common-auth-embedded/claustrum/hub.js +75 -6
  62. package/src/common-auth-embedded/claustrum/insula.js +6 -0
  63. package/src/common-auth-embedded/claustrum/roster.js +1 -1
  64. package/src/common-auth-embedded/fs/refresh-file-lock.d.ts +2 -1
  65. package/src/common-auth-embedded/fs/refresh-file-lock.js +3 -1
  66. package/src/common-auth-embedded/fs/with-lock.js +1 -1
  67. package/src/common-auth-embedded/opencode2/index.d.ts +1 -1
  68. package/src/common-auth-embedded/opencode2/install.d.ts +4 -3
  69. package/src/common-auth-embedded/opencode2/install.js +144 -17
  70. package/src/common-auth-embedded/opencode2/types.d.ts +52 -1
  71. package/src/common-auth-embedded/quota-sidebar/index.d.ts +86 -0
  72. package/src/common-auth-embedded/quota-sidebar/index.tsx +630 -0
  73. package/src/common-auth-embedded/source-output.json +73 -53
  74. package/src/tui-compiled/common-auth-embedded/quota-sidebar/index.js +666 -0
  75. package/src/tui-compiled/tui/quota-layout.js +5 -330
  76. package/src/tui-compiled/tui/sidebar-frame.js +241 -503
  77. package/src/tui-compiled/tui.js +3 -3
  78. package/src/tui-ga-compiled/host-ga.js +2 -3
  79. package/src/tui-ga-compiled/shared/ced204104a639c9c-sidebar-frame.js +241 -503
  80. package/src/tui-ga-compiled/shared/dd4c9e1a907f8ef0-quota-layout.js +5 -330
  81. package/src/tui-ga-compiled/shared/e4ec36f367492969-index.js +666 -0
  82. package/src/tui-ga-raw/host-ga.tsx +2 -3
  83. package/src/tui-ga-raw/shared/ced204104a639c9c-sidebar-frame.tsx +209 -419
  84. package/src/tui-ga-raw/shared/dd4c9e1a907f8ef0-quota-layout.tsx +10 -301
  85. package/src/tui-ga-raw/shared/e4ec36f367492969-index.tsx +630 -0
  86. package/src/tui-raw/common-auth-embedded/quota-sidebar/index.tsx +630 -0
  87. package/src/tui-raw/tui/quota-layout.tsx +10 -301
  88. package/src/tui-raw/tui/sidebar-frame.tsx +209 -419
  89. package/src/tui-raw/tui.tsx +3 -3
  90. package/src/tui.tsx +3 -3
package/dist/index.js CHANGED
@@ -7751,7 +7751,7 @@ async function rmEvictingDir(evictingPath) {
7751
7751
  });
7752
7752
  }
7753
7753
  async function sleep(ms) {
7754
- await new Promise((resolve25) => setTimeout(resolve25, ms));
7754
+ await new Promise((resolve26) => setTimeout(resolve26, 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((resolve25) => {
7871
- lostResolve = resolve25;
7870
+ let lostPromise = new Promise((resolve26) => {
7871
+ lostResolve = resolve26;
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 resolve25 = lostResolve;
7881
+ const resolve26 = lostResolve;
7882
7882
  lostResolve = null;
7883
- resolve25?.();
7883
+ resolve26?.();
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((resolve25) => setTimeout(resolve25, ms));
8506
+ const sleep5 = (ms) => new Promise((resolve26) => setTimeout(resolve26, 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((resolve25) => setTimeout(resolve25, ms));
8554
+ DEFAULT_SLEEP = (ms) => new Promise((resolve26) => setTimeout(resolve26, 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((resolve25, reject) => {
9757
- this.savePromiseResolvers.push({ resolve: resolve25, reject });
9756
+ return new Promise((resolve26, reject) => {
9757
+ this.savePromiseResolvers.push({ resolve: resolve26, 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: resolve25 } of resolvers)
9801
- resolve25();
9800
+ for (const { resolve: resolve26 } of resolvers)
9801
+ resolve26();
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: resolve25 } of resolvers) {
9816
- resolve25();
9815
+ for (const { resolve: resolve26 } of resolvers) {
9816
+ resolve26();
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: resolve25 } of resolvers) {
9824
- resolve25();
9823
+ for (const { resolve: resolve26 } of resolvers) {
9824
+ resolve26();
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((resolve25, reject) => {
10313
+ return new Promise((resolve26, 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(() => resolve25({ head, leftover }));
10336
+ cleanup2(() => resolve26({ 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((resolve25, reject) => {
10350
+ await new Promise((resolve26, 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
- resolve25();
10359
+ resolve26();
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((resolve25, reject) => {
10384
+ return await new Promise((resolve26, 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
- resolve25(tlsSocket);
10399
+ resolve26(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((resolve25, reject) => {
10408
+ return await new Promise((resolve26, 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
- resolve25(socket);
10424
+ resolve26(socket);
10425
10425
  });
10426
10426
  socket.once("error", (error) => {
10427
10427
  cleanup2();
@@ -12494,8 +12494,8 @@ async function acquireRefreshFileLockWithClock(options) {
12494
12494
  let releaseConfirmed = false;
12495
12495
  let loss;
12496
12496
  let resolveLoss;
12497
- const lostPromise = new Promise((resolve25) => {
12498
- resolveLoss = resolve25;
12497
+ const lostPromise = new Promise((resolve26) => {
12498
+ resolveLoss = resolve26;
12499
12499
  });
12500
12500
  function notifyTimerStep(event) {
12501
12501
  try {
@@ -12656,7 +12656,7 @@ async function acquireRefreshFileLockWithClock(options) {
12656
12656
  }
12657
12657
  }
12658
12658
  async function backoff() {
12659
- await new Promise((resolve25) => setTimeout(resolve25, Math.floor(Math.random() * 4)));
12659
+ await new Promise((resolve26) => setTimeout(resolve26, Math.floor(Math.random() * 4)));
12660
12660
  }
12661
12661
  async function readLockState(notifyReady = true) {
12662
12662
  if (notifyReady && options.onStep)
@@ -13094,7 +13094,7 @@ async function acquireRefreshFileLockWithClock(options) {
13094
13094
  ...typeof observed?.expiresAt === "number" ? { observedExpiresAt: observed.expiresAt } : {}
13095
13095
  });
13096
13096
  },
13097
- release: async () => {
13097
+ release: async (signal) => {
13098
13098
  if (windowsPrivateFiles && releaseConfirmed)
13099
13099
  return;
13100
13100
  released = true;
@@ -13135,6 +13135,8 @@ async function acquireRefreshFileLockWithClock(options) {
13135
13135
  releaseConfirmed = removalConfirmed;
13136
13136
  return;
13137
13137
  }
13138
+ if (signal?.aborted)
13139
+ return;
13138
13140
  await recoverStaleEvictionMarker();
13139
13141
  } catch (error) {
13140
13142
  if (windowsPrivateFiles)
@@ -13144,7 +13146,7 @@ async function acquireRefreshFileLockWithClock(options) {
13144
13146
  const remainingMs = deadline - performance.now();
13145
13147
  if (remainingMs <= 0)
13146
13148
  break;
13147
- await new Promise((resolve25) => setTimeout(resolve25, Math.min(delayMs, remainingMs)));
13149
+ await new Promise((resolve26) => setTimeout(resolve26, Math.min(delayMs, remainingMs)));
13148
13150
  delayMs = Math.min(delayMs * 2, 50);
13149
13151
  }
13150
13152
  if (windowsPrivateFiles)
@@ -13187,7 +13189,7 @@ async function withLock(target, options, fn) {
13187
13189
  options.signal?.throwIfAborted();
13188
13190
  return await fn(lock);
13189
13191
  } finally {
13190
- await lock.release();
13192
+ await lock.release(options.signal);
13191
13193
  }
13192
13194
  }
13193
13195
  const remaining = options.timeoutMs - (performance.now() - started);
@@ -13198,7 +13200,7 @@ async function withLock(target, options, fn) {
13198
13200
  timeoutMs: options.timeoutMs
13199
13201
  });
13200
13202
  }
13201
- await new Promise((resolve25) => setTimeout(resolve25, Math.min(25, Math.ceil(remaining))));
13203
+ await new Promise((resolve26) => setTimeout(resolve26, Math.min(25, Math.ceil(remaining))));
13202
13204
  }
13203
13205
  }
13204
13206
  var LockContentionError, LockOwnershipError;
@@ -13317,7 +13319,7 @@ async function acquirePoolLock(spec, defaults, env3) {
13317
13319
  });
13318
13320
  }
13319
13321
  const jitter = Math.floor(Math.random() * (options.retryMs + 1));
13320
- await new Promise((resolve25) => setTimeout(resolve25, Math.min(options.retryMs + jitter, remaining)));
13322
+ await new Promise((resolve26) => setTimeout(resolve26, Math.min(options.retryMs + jitter, remaining)));
13321
13323
  }
13322
13324
  }
13323
13325
  function definedOnly(spec) {
@@ -16359,7 +16361,7 @@ function createEngine(options) {
16359
16361
  });
16360
16362
  }, 500);
16361
16363
  }
16362
- function emit(channel, level, message, data) {
16364
+ function emit(channel3, level, message, data) {
16363
16365
  if (logFileSource === void 0 && captureSink === void 0)
16364
16366
  return;
16365
16367
  try {
@@ -16372,10 +16374,10 @@ function createEngine(options) {
16372
16374
  } catch {
16373
16375
  scrubbedData = "[unserializable]";
16374
16376
  }
16375
- const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${level.toUpperCase()} [${channel}] ${scrubbedMessage}` + (data === void 0 ? "" : safeSerialize(scrubbedData)) + "\n";
16377
+ const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${level.toUpperCase()} [${channel3}] ${scrubbedMessage}` + (data === void 0 ? "" : safeSerialize(scrubbedData)) + "\n";
16376
16378
  try {
16377
16379
  captureSink?.({
16378
- channel,
16380
+ channel: channel3,
16379
16381
  level,
16380
16382
  message: scrubbedMessage,
16381
16383
  data: scrubbedData
@@ -16395,13 +16397,13 @@ function createEngine(options) {
16395
16397
  } catch {
16396
16398
  }
16397
16399
  }
16398
- function createLogger5(channel) {
16400
+ function createLogger5(channel3) {
16399
16401
  return {
16400
- error: (m, d) => emit(channel, "error", m, d),
16401
- warn: (m, d) => emit(channel, "warn", m, d),
16402
- info: (m, d) => emit(channel, "info", m, d),
16403
- debug: (m, d) => emit(channel, "debug", m, d),
16404
- trace: (m, d) => emit(channel, "trace", m, d)
16402
+ error: (m, d) => emit(channel3, "error", m, d),
16403
+ warn: (m, d) => emit(channel3, "warn", m, d),
16404
+ info: (m, d) => emit(channel3, "info", m, d),
16405
+ debug: (m, d) => emit(channel3, "debug", m, d),
16406
+ trace: (m, d) => emit(channel3, "trace", m, d)
16405
16407
  };
16406
16408
  }
16407
16409
  function reset() {
@@ -16439,8 +16441,8 @@ function setLogLevel(l) {
16439
16441
  function flushLogs() {
16440
16442
  return defaultEngine.flushLogs();
16441
16443
  }
16442
- function createLogger2(channel) {
16443
- return defaultEngine.createLogger(channel);
16444
+ function createLogger2(channel3) {
16445
+ return defaultEngine.createLogger(channel3);
16444
16446
  }
16445
16447
  async function flushForTest() {
16446
16448
  return defaultEngine.flushLogs();
@@ -16588,11 +16590,11 @@ var init_quota_writer = __esm({
16588
16590
  const left = deadline - performance.now();
16589
16591
  if (left <= 0)
16590
16592
  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);
16591
- await new Promise((resolve25) => {
16593
+ await new Promise((resolve26) => {
16592
16594
  const done = () => {
16593
16595
  clearTimeout(timer);
16594
16596
  this.wake.delete(done);
16595
- resolve25();
16597
+ resolve26();
16596
16598
  };
16597
16599
  const timer = setTimeout(done, left);
16598
16600
  this.wake.add(done);
@@ -19363,7 +19365,7 @@ async function select(terminal, items, options) {
19363
19365
  writeLine("");
19364
19366
  renderedLines = lines;
19365
19367
  };
19366
- return new Promise((resolve25) => {
19368
+ return new Promise((resolve26) => {
19367
19369
  const wasRaw = stdin.isRaw ?? false;
19368
19370
  const cleanup2 = () => {
19369
19371
  if (cleaned)
@@ -19383,7 +19385,7 @@ async function select(terminal, items, options) {
19383
19385
  };
19384
19386
  const finish = (value) => {
19385
19387
  cleanup2();
19386
- resolve25(value);
19388
+ resolve26(value);
19387
19389
  };
19388
19390
  const onSignal = () => finish(null);
19389
19391
  const onKey = (data) => {
@@ -19423,7 +19425,7 @@ async function select(terminal, items, options) {
19423
19425
  stdin.setRawMode(true);
19424
19426
  } catch {
19425
19427
  cleanup2();
19426
- resolve25(null);
19428
+ resolve26(null);
19427
19429
  return;
19428
19430
  }
19429
19431
  stdin.resume();
@@ -20648,6 +20650,8 @@ var init_insula = __esm({
20648
20650
  ...typeof entry.source === "string" && { source: entry.source }
20649
20651
  }
20650
20652
  };
20653
+ if (entry.stale !== void 0 && (!record2(entry.stale) || entry.stale.class !== "local_source_unavailable"))
20654
+ return { miss: "upstream-failed", reading };
20651
20655
  return now >= fetchedAt + MAX_AGE || entry.stale !== void 0 ? { miss: "stale", reading } : { reading };
20652
20656
  }
20653
20657
  if (this.#completeProviders.has(provider2))
@@ -21469,10 +21473,10 @@ async function drainShutdown(pending, onTimeout) {
21469
21473
  try {
21470
21474
  await Promise.race([
21471
21475
  drained,
21472
- new Promise((resolve25) => {
21476
+ new Promise((resolve26) => {
21473
21477
  timer = setTimeout(() => {
21474
21478
  expired = true;
21475
- resolve25();
21479
+ resolve26();
21476
21480
  }, 2e3);
21477
21481
  })
21478
21482
  ]);
@@ -21490,6 +21494,7 @@ var init_shutdown = __esm({
21490
21494
  });
21491
21495
 
21492
21496
  // ../core/dist/common-auth-embedded/claustrum/custody.js
21497
+ import { channel } from "node:diagnostics_channel";
21493
21498
  import { ClaustrumCredentialError as ClaustrumCredentialError3 } from "@cortexkit/claustrum-client";
21494
21499
  function isScopedCredentialRotation(served, current) {
21495
21500
  return current !== void 0 && !current.fromKeptReceipt && !served.fromKeptReceipt && current.credentialId === served.credentialId && current.accountIdentity === served.accountIdentity && current.recordVersion !== served.recordVersion;
@@ -21546,15 +21551,27 @@ function credentialTypeOf(row, family) {
21546
21551
  return notMine;
21547
21552
  if (!row.categories.includes(family.category))
21548
21553
  return notMine;
21549
- if (row.credentialType !== "oauth" && row.credentialType !== "api_key")
21550
- return notMine;
21551
21554
  if ("classify" in family) {
21555
+ const metadata = rowFactsOf(row);
21556
+ let type;
21557
+ switch (metadata.authMethod) {
21558
+ case "apikey":
21559
+ type = "api_key";
21560
+ break;
21561
+ case "chatgpt":
21562
+ case "antigravity":
21563
+ case "oauth":
21564
+ type = "oauth";
21565
+ break;
21566
+ default:
21567
+ return { kind: "refused", code: "unknown-auth-method" };
21568
+ }
21552
21569
  const facts = {
21553
21570
  credentialId: row.id,
21554
- credentialType: row.credentialType,
21571
+ credentialType: type,
21555
21572
  categories: row.categories,
21556
21573
  refreshAdapter: row.refreshAdapter,
21557
- ...rowFactsOf(row)
21574
+ ...metadata
21558
21575
  };
21559
21576
  if (facts.providerIds === void 0)
21560
21577
  return { kind: "refused", code: "unmapped" };
@@ -21563,13 +21580,15 @@ function credentialTypeOf(row, family) {
21563
21580
  if (result.kind === "not-mine")
21564
21581
  return notMine;
21565
21582
  if (result.kind === "mine" && typeof result.member === "string")
21566
- return { kind: "mine", type: row.credentialType, member: result.member };
21583
+ return { kind: "mine", type, member: result.member };
21567
21584
  if (result.kind === "refused" && typeof result.code === "string" && /^[a-z][a-z0-9-]{0,31}$/.test(result.code) && !result.code.includes("\n") && family.refusalCodes.includes(result.code))
21568
21585
  return { kind: "refused", code: result.code };
21569
21586
  } catch {
21570
21587
  }
21571
21588
  return { kind: "refused", code: "unclassified" };
21572
21589
  }
21590
+ if (row.credentialType !== "oauth" && row.credentialType !== "api_key")
21591
+ return notMine;
21573
21592
  if (row.credentialType === "oauth")
21574
21593
  return row.refreshAdapter === family.refreshAdapter ? { kind: "mine", type: "oauth" } : notMine;
21575
21594
  if (row.credentialType === "api_key" && family.apiKeys)
@@ -21589,7 +21608,7 @@ function grantReachOf(listed) {
21589
21608
  tuples: Object.freeze(grantTuples.map(({ selectorKind, selector, operation }) => Object.freeze({ selectorKind, selector, operation })))
21590
21609
  });
21591
21610
  }
21592
- var defaultLogger, SERVING_MARGIN_MS, KEPT_RECEIPT_MARGIN_MS, ClaustrumScopedCustody;
21611
+ var defaultLogger, phaseDiagnostics, SERVING_MARGIN_MS, KEPT_RECEIPT_MARGIN_MS, ClaustrumScopedCustody;
21593
21612
  var init_custody = __esm({
21594
21613
  "../core/dist/common-auth-embedded/claustrum/custody.js"() {
21595
21614
  "use strict";
@@ -21601,6 +21620,7 @@ var init_custody = __esm({
21601
21620
  init_shutdown();
21602
21621
  init_watch();
21603
21622
  defaultLogger = createLogger2("claustrum");
21623
+ phaseDiagnostics = channel("common-auth.claustrum.phases");
21604
21624
  SERVING_MARGIN_MS = 3e5;
21605
21625
  KEPT_RECEIPT_MARGIN_MS = 6e4;
21606
21626
  ClaustrumScopedCustody = class {
@@ -21704,6 +21724,11 @@ var init_custody = __esm({
21704
21724
  }
21705
21725
  async #token(signal) {
21706
21726
  this.#check(signal);
21727
+ if (phaseDiagnostics.hasSubscribers)
21728
+ phaseDiagnostics.publish({
21729
+ logger: this.#logger,
21730
+ phase: "token read begin"
21731
+ });
21707
21732
  const pending = this.#readToken();
21708
21733
  this.#tokenReads.add(pending);
21709
21734
  let value;
@@ -21711,6 +21736,11 @@ var init_custody = __esm({
21711
21736
  value = await pending;
21712
21737
  } finally {
21713
21738
  this.#tokenReads.delete(pending);
21739
+ if (phaseDiagnostics.hasSubscribers)
21740
+ phaseDiagnostics.publish({
21741
+ logger: this.#logger,
21742
+ phase: "token read end"
21743
+ });
21714
21744
  }
21715
21745
  this.#check(signal);
21716
21746
  if (!/^[0-9a-f]{64}$/.test(value.token) || !Number.isSafeInteger(value.token_generation) || value.token_generation < 1) {
@@ -21772,11 +21802,22 @@ var init_custody = __esm({
21772
21802
  this.#kept.clear();
21773
21803
  throw error;
21774
21804
  }
21805
+ if (phaseDiagnostics.hasSubscribers)
21806
+ phaseDiagnostics.publish({
21807
+ logger: this.#logger,
21808
+ phase: "list scoped begin"
21809
+ });
21775
21810
  try {
21776
21811
  inventory = await this.#call(() => this.#client.listScoped(token), signal);
21777
21812
  } catch (error) {
21778
21813
  this.listFailed(error);
21779
21814
  throw error;
21815
+ } finally {
21816
+ if (phaseDiagnostics.hasSubscribers)
21817
+ phaseDiagnostics.publish({
21818
+ logger: this.#logger,
21819
+ phase: "list scoped end"
21820
+ });
21780
21821
  }
21781
21822
  const skipped = [];
21782
21823
  const refused2 = [];
@@ -22716,7 +22757,7 @@ async function refreshVaultRoster(options) {
22716
22757
  pendingDiscoveries.set(key, discovered);
22717
22758
  throw error;
22718
22759
  } finally {
22719
- await lease.release();
22760
+ await lease.release(options.signal);
22720
22761
  }
22721
22762
  }
22722
22763
  function resolveVaultPrimary(input2) {
@@ -23069,7 +23110,7 @@ var init_consumer = __esm({
23069
23110
  this.#shutdown.signal,
23070
23111
  ...signal ? [signal] : []
23071
23112
  ]);
23072
- return new Promise((resolve25, reject) => {
23113
+ return new Promise((resolve26, reject) => {
23073
23114
  const cleanup2 = () => {
23074
23115
  combined.signal.removeEventListener("abort", abort);
23075
23116
  combined.dispose();
@@ -23084,7 +23125,7 @@ var init_consumer = __esm({
23084
23125
  if (combined.signal.aborted)
23085
23126
  reject(combined.signal.reason);
23086
23127
  else
23087
- resolve25(value);
23128
+ resolve26(value);
23088
23129
  }, (error) => {
23089
23130
  cleanup2();
23090
23131
  reject(error);
@@ -23258,8 +23299,16 @@ var init_consumer = __esm({
23258
23299
  this.#refreshing = void 0;
23259
23300
  });
23260
23301
  this.#track(this.#refreshing);
23302
+ this.#notifyDiscovery(this.#refreshing);
23261
23303
  return this.#refreshing;
23262
23304
  }
23305
+ #notifyDiscovery(promise) {
23306
+ try {
23307
+ this.#options.onDiscovery?.(promise);
23308
+ } catch (error) {
23309
+ this.#options.onError?.(error);
23310
+ }
23311
+ }
23263
23312
  /**
23264
23313
  * Poll in the background and open the vault and insula watches. Until the
23265
23314
  * vault watch is accepted, and whenever it is unavailable, every tick lists
@@ -23489,6 +23538,13 @@ var init_consumer = __esm({
23489
23538
  /** The hub's handle on this member's memory. */
23490
23539
  #hubHooks() {
23491
23540
  return {
23541
+ discovery: (promise) => {
23542
+ const hub = this.#hub;
23543
+ if (!hub || !this.#options.onDiscovery || this.#shutdown.signal.aborted)
23544
+ return;
23545
+ const discovery = this.#track(promise.then((outcome) => this.#hubOutcome(hub, outcome)));
23546
+ this.#notifyDiscovery(discovery);
23547
+ },
23492
23548
  install: (roster) => {
23493
23549
  if (this.#shutdown.signal.aborted)
23494
23550
  return;
@@ -23523,6 +23579,9 @@ var init_consumer = __esm({
23523
23579
  */
23524
23580
  async #hubRefresh(hub) {
23525
23581
  const outcome = await hub.refresh();
23582
+ return this.#hubOutcome(hub, outcome);
23583
+ }
23584
+ #hubOutcome(hub, outcome) {
23526
23585
  this.#assertOpen();
23527
23586
  if (!outcome)
23528
23587
  return void 0;
@@ -23677,6 +23736,8 @@ var init_consumer = __esm({
23677
23736
  this.#assertOpen();
23678
23737
  await declineVaultRoute(this.#options.rosterPath, routeId);
23679
23738
  this.#roster = pendingVaultQuota(this.#options.rosterPath, await readVaultRoster(this.#options.rosterPath));
23739
+ if (this.#roster)
23740
+ this.#hub?.publishRoster(this.#roster);
23680
23741
  if (this.#hub)
23681
23742
  this.#hub.retainUnion();
23682
23743
  else
@@ -23686,6 +23747,8 @@ var init_consumer = __esm({
23686
23747
  this.#assertOpen();
23687
23748
  await acceptVaultRoute(this.#options.rosterPath, routeId);
23688
23749
  this.#roster = pendingVaultQuota(this.#options.rosterPath, await readVaultRoster(this.#options.rosterPath));
23750
+ if (this.#roster)
23751
+ this.#hub?.publishRoster(this.#roster);
23689
23752
  }
23690
23753
  /**
23691
23754
  * Set the order vault accounts are tried in (`reorderVaultRoster`), then
@@ -23696,6 +23759,8 @@ var init_consumer = __esm({
23696
23759
  this.#assertOpen();
23697
23760
  const result = await reorderVaultRoster(this.#options.rosterPath, routeIds);
23698
23761
  this.#roster = pendingVaultQuota(this.#options.rosterPath, await readVaultRoster(this.#options.rosterPath));
23762
+ if (this.#roster)
23763
+ this.#hub?.publishRoster(this.#roster);
23699
23764
  return result;
23700
23765
  }
23701
23766
  /**
@@ -23772,8 +23837,9 @@ var init_consumer = __esm({
23772
23837
 
23773
23838
  // ../core/dist/common-auth-embedded/claustrum/hub.js
23774
23839
  import { createHash as createHash8 } from "node:crypto";
23840
+ import { channel as channel2 } from "node:diagnostics_channel";
23775
23841
  import { readdir, stat as stat6 } from "node:fs/promises";
23776
- import { dirname as dirname10, join as join7 } from "node:path";
23842
+ import { dirname as dirname10, join as join7, resolve as resolve9 } from "node:path";
23777
23843
  function canonicalJson3(value, path5 = /* @__PURE__ */ new Set()) {
23778
23844
  if (value === null)
23779
23845
  return "null";
@@ -23834,12 +23900,12 @@ function unreachableConnect2() {
23834
23900
  return new ClaustrumUnreachableError();
23835
23901
  }
23836
23902
  function untilAborted(pending, signal) {
23837
- return new Promise((resolve25, reject) => {
23903
+ return new Promise((resolve26, reject) => {
23838
23904
  const abort = () => reject(signal.reason);
23839
23905
  signal.addEventListener("abort", abort, { once: true });
23840
23906
  pending.then((value) => {
23841
23907
  signal.removeEventListener("abort", abort);
23842
- resolve25(value);
23908
+ resolve26(value);
23843
23909
  }, (error) => {
23844
23910
  signal.removeEventListener("abort", abort);
23845
23911
  reject(error);
@@ -23851,7 +23917,7 @@ function untilAborted(pending, signal) {
23851
23917
  function enabledRows(roster) {
23852
23918
  return JSON.stringify((roster?.rows ?? []).map((row) => [row.credentialId, row.enabled]));
23853
23919
  }
23854
- var FILE_ID, WINDOWS_DEVICE, FINGERPRINT, PENDING_EVERY_TICK, ClaustrumDiscoveryHub;
23920
+ var sharedRosters, FILE_ID, WINDOWS_DEVICE, FINGERPRINT, PENDING_EVERY_TICK, ClaustrumDiscoveryHub;
23855
23921
  var init_hub = __esm({
23856
23922
  "../core/dist/common-auth-embedded/claustrum/hub.js"() {
23857
23923
  "use strict";
@@ -23865,6 +23931,7 @@ var init_hub = __esm({
23865
23931
  init_roster();
23866
23932
  init_shutdown();
23867
23933
  init_watch();
23934
+ sharedRosters = /* @__PURE__ */ new Map();
23868
23935
  FILE_ID = /^[a-z0-9][a-z0-9._-]{0,63}$/;
23869
23936
  WINDOWS_DEVICE = /^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\.|$)/;
23870
23937
  FINGERPRINT = /^[0-9a-f]{16}$/;
@@ -23971,9 +24038,11 @@ var init_hub = __esm({
23971
24038
  watchMode: () => this.watchState(),
23972
24039
  keptReceiptState: () => this.keptReceiptState(),
23973
24040
  retainUnion: () => this.#retainUnion(),
24041
+ publishRoster: (roster) => this.#publishRoster(entry, roster),
23974
24042
  forget: (credentialId) => this.#current?.custody?.forget(credentialId),
23975
24043
  detach: () => {
23976
24044
  entry.closed = true;
24045
+ entry.releaseRoster?.();
23977
24046
  }
23978
24047
  };
23979
24048
  const consumerOptions = {
@@ -23986,14 +24055,51 @@ var init_hub = __esm({
23986
24055
  },
23987
24056
  ...this.#options.mapAccount && { mapAccount: this.#options.mapAccount },
23988
24057
  ...options.onRoster && { onRoster: options.onRoster },
24058
+ ...options.onDiscovery && { onDiscovery: options.onDiscovery },
23989
24059
  ...options.onError && { onError: options.onError },
23990
24060
  logger: options.logger ?? this.#logger,
23991
24061
  ...this.#options.now && { now: this.#options.now }
23992
24062
  };
23993
24063
  const { consumer, hooks } = createHubMember(port, consumerOptions);
23994
24064
  entry.hooks = hooks;
24065
+ const path5 = resolve9(entry.path);
24066
+ const subscribers = sharedRosters.get(path5) ?? /* @__PURE__ */ new Set();
24067
+ const install = (roster) => {
24068
+ if (entry.closed || this.#active !== true || !this.#current || !this.#live(this.#current) || !hooks.roster() || this.#collides(hooks, roster))
24069
+ return;
24070
+ entry.seen = JSON.stringify(decodedVaultRoster(roster));
24071
+ hooks.install(roster);
24072
+ if (roster.view !== this.#committed?.view)
24073
+ entry.pending ??= { failures: 0, wait: 0 };
24074
+ this.#retainUnion();
24075
+ };
24076
+ subscribers.add(install);
24077
+ entry.receiveRoster = install;
24078
+ sharedRosters.set(path5, subscribers);
24079
+ let subscribed = true;
24080
+ entry.releaseRoster = () => {
24081
+ if (!subscribed)
24082
+ return;
24083
+ subscribed = false;
24084
+ subscribers.delete(install);
24085
+ if (!subscribers.size)
24086
+ sharedRosters.delete(path5);
24087
+ };
23995
24088
  return consumer;
23996
24089
  }
24090
+ #publishRoster(entry, roster) {
24091
+ const generation = this.#current;
24092
+ if (entry.closed || !generation || !this.#live(generation))
24093
+ return;
24094
+ entry.seen = JSON.stringify(decodedVaultRoster(roster));
24095
+ entry.hooks?.install(roster);
24096
+ for (const install of sharedRosters.get(resolve9(entry.path)) ?? []) {
24097
+ if (!this.#live(generation))
24098
+ return;
24099
+ if (install !== entry.receiveRoster)
24100
+ install(roster);
24101
+ }
24102
+ }
23997
24103
  // --- leases ---
23998
24104
  #startGeneration() {
23999
24105
  const generation = {
@@ -24289,6 +24395,8 @@ var init_hub = __esm({
24289
24395
  }));
24290
24396
  run.promise = promise;
24291
24397
  this.#run = run;
24398
+ for (const entry of this.#open())
24399
+ entry.hooks?.discovery(promise);
24292
24400
  return promise;
24293
24401
  }
24294
24402
  /**
@@ -24365,9 +24473,7 @@ var init_hub = __esm({
24365
24473
  this.#markPending(entry);
24366
24474
  continue;
24367
24475
  }
24368
- entry.seen = JSON.stringify(decodedVaultRoster(roster));
24369
- if (!entry.closed)
24370
- hooks.install(roster);
24476
+ this.#publishRoster(entry, roster);
24371
24477
  }
24372
24478
  if (!this.#live(generation))
24373
24479
  return void 0;
@@ -24398,7 +24504,24 @@ var init_hub = __esm({
24398
24504
  throw closed("Claustrum hub member has no base view");
24399
24505
  if (base instanceof Error)
24400
24506
  throw base;
24401
- const seed = base.file ? void 0 : await this.#seed(entry);
24507
+ let seed;
24508
+ if (!base.file) {
24509
+ const phaseDiagnostics2 = channel2("common-auth.claustrum.phases");
24510
+ if (phaseDiagnostics2.hasSubscribers)
24511
+ phaseDiagnostics2.publish({
24512
+ logger: this.#logger,
24513
+ phase: `seed read ${entry.provider} begin`
24514
+ });
24515
+ try {
24516
+ seed = await this.#seed(entry);
24517
+ } finally {
24518
+ if (phaseDiagnostics2.hasSubscribers)
24519
+ phaseDiagnostics2.publish({
24520
+ logger: this.#logger,
24521
+ phase: `seed read ${entry.provider} end`
24522
+ });
24523
+ }
24524
+ }
24402
24525
  const roster = await refreshVaultRoster({
24403
24526
  path: entry.path,
24404
24527
  custody: { discover: async () => share },
@@ -24522,7 +24645,7 @@ var init_hub = __esm({
24522
24645
  }
24523
24646
  const before = enabledRows(memory);
24524
24647
  entry.seen = content;
24525
- hooks.install(file);
24648
+ this.#publishRoster(entry, file);
24526
24649
  if (enabledRows(hooks.roster()) !== before)
24527
24650
  this.#retainUnion();
24528
24651
  }
@@ -24679,6 +24802,8 @@ var init_hub = __esm({
24679
24802
  if (this.#shutdown.signal.aborted)
24680
24803
  return;
24681
24804
  this.#shutdown.abort(closed("Claustrum discovery hub is closed"));
24805
+ for (const entry of this.#members.values())
24806
+ entry.releaseRoster?.();
24682
24807
  if (this.#timer)
24683
24808
  (this.#options.clearTimeoutImpl ?? clearTimeout)(this.#timer);
24684
24809
  this.#timer = void 0;
@@ -25013,7 +25138,7 @@ var init_lock = __esm({
25013
25138
  import { createHash as createHash9 } from "node:crypto";
25014
25139
  import { constants as constants2 } from "node:fs";
25015
25140
  import { lstat as lstat5, mkdir as mkdir10, open as open7, unlink as unlink7 } from "node:fs/promises";
25016
- import { dirname as dirname11, resolve as resolve9 } from "node:path";
25141
+ import { dirname as dirname11, resolve as resolve10 } from "node:path";
25017
25142
  import { setTimeout as sleep2 } from "node:timers/promises";
25018
25143
  function rootSpans(text2) {
25019
25144
  let i = text2.indexOf("{") + 1;
@@ -25214,8 +25339,8 @@ function createPiSlot(options, onStep, hooks) {
25214
25339
  if (!provider2 || !options.authPath || !options.stashPath || !placeholderKey || placeholderKey.startsWith("!") || placeholderKey.includes("$") || !Number.isFinite(timeout) || timeout < 0) {
25215
25340
  throw new PiSlotError("invalid-options");
25216
25341
  }
25217
- const authPath = resolve9(options.authPath);
25218
- const stashPath = resolve9(options.stashPath);
25342
+ const authPath = resolve10(options.authPath);
25343
+ const stashPath = resolve10(options.stashPath);
25219
25344
  if (authPath === stashPath || stashPath === `${authPath}.lock`) {
25220
25345
  throw new PiSlotError("invalid-options");
25221
25346
  }
@@ -25838,8 +25963,8 @@ function getDefaultTierId(allowedTiers) {
25838
25963
  return allowedTiers[0]?.id;
25839
25964
  }
25840
25965
  function wait(ms) {
25841
- return new Promise((resolve25) => {
25842
- setTimeout(resolve25, ms);
25966
+ return new Promise((resolve26) => {
25967
+ setTimeout(resolve26, ms);
25843
25968
  });
25844
25969
  }
25845
25970
  function extractManagedProjectId(payload) {
@@ -28161,12 +28286,12 @@ var init_vault_provider_state = __esm({
28161
28286
  function untilAborted2(pending, signal) {
28162
28287
  if (!signal)
28163
28288
  return pending;
28164
- return new Promise((resolve25, reject) => {
28289
+ return new Promise((resolve26, reject) => {
28165
28290
  const abort = () => reject(signal.reason);
28166
28291
  signal.addEventListener("abort", abort, { once: true });
28167
28292
  if (signal.aborted)
28168
28293
  abort();
28169
- pending.then(resolve25, reject).finally(() => signal.removeEventListener("abort", abort));
28294
+ pending.then(resolve26, reject).finally(() => signal.removeEventListener("abort", abort));
28170
28295
  });
28171
28296
  }
28172
28297
  async function resolveClaustrumConnectionPath(explicit) {
@@ -28640,7 +28765,7 @@ var init_capture_sink2 = __esm({
28640
28765
  import { randomUUID as randomUUID13 } from "node:crypto";
28641
28766
  import { lstat as lstat6, readFile as readFile8, rename as rename8, unlink as unlink8 } from "node:fs/promises";
28642
28767
  import { tmpdir as tmpdir2 } from "node:os";
28643
- import { dirname as dirname13, join as join9, resolve as resolve10 } from "node:path";
28768
+ import { dirname as dirname13, join as join9, resolve as resolve11 } from "node:path";
28644
28769
  function ioCode2(detail) {
28645
28770
  if (detail?.reason === "io-error") {
28646
28771
  if (detail.win32Code === 2 || detail.win32Code === 3)
@@ -28687,7 +28812,7 @@ async function privateOperation2(path5, stage, operation) {
28687
28812
  }
28688
28813
  }
28689
28814
  async function verifySafeDirectory2(path5, options) {
28690
- path5 = resolve10(path5);
28815
+ path5 = resolve11(path5);
28691
28816
  options ??= safeParentOptionsForTest2;
28692
28817
  await privateOperation2(path5, "safe-parent", async () => {
28693
28818
  const result = await (await loadBackend2()).verifySafeParent(path5, options);
@@ -28702,7 +28827,7 @@ async function verifySafeDirectory2(path5, options) {
28702
28827
  });
28703
28828
  }
28704
28829
  async function verifyPrivate2(path5, kind, migrate = false) {
28705
- path5 = resolve10(path5);
28830
+ path5 = resolve11(path5);
28706
28831
  if (kind === "directory")
28707
28832
  return verifySafeDirectory2(path5);
28708
28833
  await privateOperation2(path5, "verify", async () => {
@@ -28737,7 +28862,7 @@ async function verifyPrivate2(path5, kind, migrate = false) {
28737
28862
  });
28738
28863
  }
28739
28864
  async function ensurePrivateDirectory2(path5, _migrate = false, options) {
28740
- path5 = resolve10(path5);
28865
+ path5 = resolve11(path5);
28741
28866
  await privateOperation2(path5, "directory", async () => {
28742
28867
  const api = await loadBackend2();
28743
28868
  try {
@@ -28768,7 +28893,7 @@ async function readPrivateText2(path5, migrate = false) {
28768
28893
  async function readPrivateBuffer2(path5, migrate = false) {
28769
28894
  if (!windowsPrivateFiles2)
28770
28895
  return readFile8(path5);
28771
- path5 = resolve10(path5);
28896
+ path5 = resolve11(path5);
28772
28897
  if (migrate) {
28773
28898
  await verifySafeDirectory2(dirname13(path5));
28774
28899
  await verifyPrivate2(path5, "file", true);
@@ -28776,20 +28901,20 @@ async function readPrivateBuffer2(path5, migrate = false) {
28776
28901
  return privateOperation2(path5, "read", async () => (await loadBackend2()).readOwnerOnly(path5));
28777
28902
  }
28778
28903
  async function createPrivateBytes2(path5, bytes) {
28779
- await verifySafeDirectory2(dirname13(resolve10(path5)));
28904
+ await verifySafeDirectory2(dirname13(resolve11(path5)));
28780
28905
  await privateOperation2(path5, "create", async () => {
28781
- await (await loadBackend2()).createPrivateFile(resolve10(path5), bytes);
28906
+ await (await loadBackend2()).createPrivateFile(resolve11(path5), bytes);
28782
28907
  });
28783
28908
  }
28784
28909
  async function createPrivateDirectoryExclusive2(path5) {
28785
- await verifySafeDirectory2(dirname13(resolve10(path5)));
28910
+ await verifySafeDirectory2(dirname13(resolve11(path5)));
28786
28911
  await privateOperation2(path5, "directory-create", async () => {
28787
- await (await loadBackend2()).createOwnerOnly(resolve10(path5), { kind: "dir" });
28912
+ await (await loadBackend2()).createOwnerOnly(resolve11(path5), { kind: "dir" });
28788
28913
  });
28789
28914
  }
28790
28915
  async function replaceWindowsFile2(from, to, options = {}) {
28791
- from = resolve10(from);
28792
- to = resolve10(to);
28916
+ from = resolve11(from);
28917
+ to = resolve11(to);
28793
28918
  const now = options.now ?? (() => performance.now());
28794
28919
  const start = now();
28795
28920
  const leaseDeadline = options.deadline ?? Infinity;
@@ -28832,7 +28957,7 @@ async function replaceWindowsFile2(from, to, options = {}) {
28832
28957
  throw error;
28833
28958
  }
28834
28959
  async function writePrivateAtomic2(path5, bytes, options = {}) {
28835
- path5 = resolve10(path5);
28960
+ path5 = resolve11(path5);
28836
28961
  await ensurePrivateDirectory2(dirname13(path5));
28837
28962
  try {
28838
28963
  await verifyPrivate2(path5, "file", true);
@@ -28840,7 +28965,7 @@ async function writePrivateAtomic2(path5, bytes, options = {}) {
28840
28965
  if (error.code !== "ENOENT")
28841
28966
  throw error;
28842
28967
  }
28843
- const stage = resolve10(options.stagePath ?? `${path5}.${randomUUID13()}.tmp`);
28968
+ const stage = resolve11(options.stagePath ?? `${path5}.${randomUUID13()}.tmp`);
28844
28969
  if (dirname13(stage) !== dirname13(path5))
28845
28970
  throw new PrivateFileError2(path5, "stage-directory", { code: "EXDEV" });
28846
28971
  let created = false;
@@ -29006,7 +29131,7 @@ var init_redact2 = __esm({
29006
29131
  // src/common-auth-embedded/logger/engine.js
29007
29132
  import { appendFileSync as appendFileSync2, chmodSync as chmodSync2, existsSync as existsSync2, renameSync as renameSync2, statSync as statSync3 } from "node:fs";
29008
29133
  import { open as open8 } from "node:fs/promises";
29009
- import { dirname as dirname14, resolve as resolve11 } from "node:path";
29134
+ import { dirname as dirname14, resolve as resolve12 } from "node:path";
29010
29135
  function chmodPrivate2(path5) {
29011
29136
  try {
29012
29137
  chmodSync2(path5, 384);
@@ -29057,7 +29182,7 @@ async function openWindowsFile2(sink, file) {
29057
29182
  return sink.handle;
29058
29183
  }
29059
29184
  async function flushWindowsFile2(sink, file, text2) {
29060
- file = resolve11(file);
29185
+ file = resolve12(file);
29061
29186
  try {
29062
29187
  if (sink.file !== file)
29063
29188
  await closeWindowsFile2(sink);
@@ -29204,7 +29329,7 @@ function createEngine2(options) {
29204
29329
  });
29205
29330
  }, 500);
29206
29331
  }
29207
- function emit(channel, level, message, data) {
29332
+ function emit(channel3, level, message, data) {
29208
29333
  if (logFileSource === void 0 && captureSink === void 0)
29209
29334
  return;
29210
29335
  try {
@@ -29217,10 +29342,10 @@ function createEngine2(options) {
29217
29342
  } catch {
29218
29343
  scrubbedData = "[unserializable]";
29219
29344
  }
29220
- const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${level.toUpperCase()} [${channel}] ${scrubbedMessage}` + (data === void 0 ? "" : safeSerialize2(scrubbedData)) + "\n";
29345
+ const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${level.toUpperCase()} [${channel3}] ${scrubbedMessage}` + (data === void 0 ? "" : safeSerialize2(scrubbedData)) + "\n";
29221
29346
  try {
29222
29347
  captureSink?.({
29223
- channel,
29348
+ channel: channel3,
29224
29349
  level,
29225
29350
  message: scrubbedMessage,
29226
29351
  data: scrubbedData
@@ -29240,13 +29365,13 @@ function createEngine2(options) {
29240
29365
  } catch {
29241
29366
  }
29242
29367
  }
29243
- function createLogger5(channel) {
29368
+ function createLogger5(channel3) {
29244
29369
  return {
29245
- error: (m, d) => emit(channel, "error", m, d),
29246
- warn: (m, d) => emit(channel, "warn", m, d),
29247
- info: (m, d) => emit(channel, "info", m, d),
29248
- debug: (m, d) => emit(channel, "debug", m, d),
29249
- trace: (m, d) => emit(channel, "trace", m, d)
29370
+ error: (m, d) => emit(channel3, "error", m, d),
29371
+ warn: (m, d) => emit(channel3, "warn", m, d),
29372
+ info: (m, d) => emit(channel3, "info", m, d),
29373
+ debug: (m, d) => emit(channel3, "debug", m, d),
29374
+ trace: (m, d) => emit(channel3, "trace", m, d)
29250
29375
  };
29251
29376
  }
29252
29377
  function reset() {
@@ -30116,11 +30241,11 @@ function createOpenCodeVaultCustody(options) {
30116
30241
  ].join("\n");
30117
30242
  const waitForApproval = async () => {
30118
30243
  while (!closed2) {
30119
- await new Promise((resolve25) => {
30244
+ await new Promise((resolve26) => {
30120
30245
  const done = () => {
30121
30246
  clearTimeout(timer);
30122
30247
  cancelWait = void 0;
30123
- resolve25();
30248
+ resolve26();
30124
30249
  };
30125
30250
  const timer = setTimeout(done, 2e3);
30126
30251
  timer.unref?.();
@@ -30507,7 +30632,7 @@ import { randomUUID as randomUUID14 } from "node:crypto";
30507
30632
  import { realpathSync, rmSync } from "node:fs";
30508
30633
  import { chmod as chmod4, mkdir as mkdir12, readFile as readFile10, rename as rename9, rm as rm5, writeFile as writeFile3 } from "node:fs/promises";
30509
30634
  import { homedir as homedir2 } from "node:os";
30510
- import { join as join11, resolve as resolve12 } from "node:path";
30635
+ import { join as join11, resolve as resolve13 } from "node:path";
30511
30636
  function processHeartbeatDir() {
30512
30637
  const base = process.env.XDG_STATE_HOME || join11(homedir2(), ".local", "state");
30513
30638
  return join11(base, "cortexkit", "antigravity-auth", "processes");
@@ -30520,7 +30645,7 @@ function processConfigFolderKey() {
30520
30645
  try {
30521
30646
  return realpathSync.native(folder);
30522
30647
  } catch {
30523
- return resolve12(folder);
30648
+ return resolve13(folder);
30524
30649
  }
30525
30650
  }
30526
30651
  function processHasOlderGeneration() {
@@ -30966,7 +31091,7 @@ import {
30966
31091
  stat as stat9,
30967
31092
  unlink as unlink9
30968
31093
  } from "node:fs/promises";
30969
- import { basename as basename4, dirname as dirname15, join as join13, resolve as resolve13 } from "node:path";
31094
+ import { basename as basename4, dirname as dirname15, join as join13, resolve as resolve14 } from "node:path";
30970
31095
  function refusalMessage(stateDir, errorClass2) {
30971
31096
  if (errorClass2 === "ERR_PRIVATE_FILES_SECURITY")
30972
31097
  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.`;
@@ -31821,7 +31946,7 @@ async function isVaultShapedKeptState(files) {
31821
31946
  async function removeMovedVaultStateLeftover(vaultDir, accountFile) {
31822
31947
  const location = runtimeLayoutLocation();
31823
31948
  const files = layoutFiles(location, accountFile);
31824
- if (resolve13(vaultDir) !== resolve13(files.vault.next)) return;
31949
+ if (resolve14(vaultDir) !== resolve14(files.vault.next)) return;
31825
31950
  const stateDir = location.stateHomeDir;
31826
31951
  const marker = await readMarker(
31827
31952
  join13(stateDir, RUNTIME_LAYOUT_MARKER_FILE),
@@ -32249,7 +32374,7 @@ import {
32249
32374
  writeFileSync
32250
32375
  } from "node:fs";
32251
32376
  import { homedir as homedir4 } from "node:os";
32252
- import { dirname as dirname16, join as join14, resolve as resolve14 } from "node:path";
32377
+ import { dirname as dirname16, join as join14, resolve as resolve15 } from "node:path";
32253
32378
  async function ensureGitignore(configDir) {
32254
32379
  const gitignorePath = join14(configDir, ".gitignore");
32255
32380
  try {
@@ -32349,8 +32474,8 @@ function migrateLegacyWindowsConfig() {
32349
32474
  }
32350
32475
  }
32351
32476
  function resolveWindowsAccountAnchor(newPath, legacyPath) {
32352
- const standard = resolve14(newPath);
32353
- const legacy = resolve14(legacyPath);
32477
+ const standard = resolve15(newPath);
32478
+ const legacy = resolve15(legacyPath);
32354
32479
  if (standard.toLowerCase() === legacy.toLowerCase()) return newPath;
32355
32480
  const standardPointer = existsSync3(accountStorePointerPath(standard));
32356
32481
  const legacyPointer = existsSync3(accountStorePointerPath(legacy));
@@ -32372,7 +32497,7 @@ function getStoragePathWithMigration() {
32372
32497
  "antigravity-accounts.json"
32373
32498
  );
32374
32499
  const anchored = resolveWindowsAccountAnchor(newPath, legacyPath);
32375
- if (resolve14(anchored).toLowerCase() !== resolve14(newPath).toLowerCase() && !existsSync3(accountStorePointerPath(resolve14(anchored)))) {
32500
+ if (resolve15(anchored).toLowerCase() !== resolve15(newPath).toLowerCase() && !existsSync3(accountStorePointerPath(resolve15(anchored)))) {
32376
32501
  log5.info("Using legacy Windows config path (migration failed)", {
32377
32502
  legacyPath,
32378
32503
  newPath
@@ -32389,7 +32514,7 @@ function accountFileForVault(configDir = getConfigDir()) {
32389
32514
  const configured = join14(configDir, "antigravity-accounts.json");
32390
32515
  if (process.platform !== "win32") return configured;
32391
32516
  const legacyDir = getLegacyWindowsConfigDir();
32392
- if (resolve14(configDir).toLowerCase() === resolve14(legacyDir).toLowerCase())
32517
+ if (resolve15(configDir).toLowerCase() === resolve15(legacyDir).toLowerCase())
32393
32518
  return configured;
32394
32519
  const configuredVault = join14(configDir, "antigravity-auth-vault");
32395
32520
  const legacyVault = join14(legacyDir, "antigravity-auth-vault");
@@ -32420,7 +32545,7 @@ function getStoragePath() {
32420
32545
  }
32421
32546
  async function assertLegacyPoolInUse(legacyPath) {
32422
32547
  try {
32423
- await assertLegacyAccountStorageWritable(resolve14(legacyPath));
32548
+ await assertLegacyAccountStorageWritable(resolve15(legacyPath));
32424
32549
  } catch (error) {
32425
32550
  throw new LegacyAccountPoolRetiredError(legacyPath, { cause: error });
32426
32551
  }
@@ -32438,7 +32563,7 @@ function refusalMessage2(admission) {
32438
32563
  async function bindingOf(options) {
32439
32564
  if (options.legacyPath === void 0) await prepareLocalAccountStore();
32440
32565
  const now = options.now ?? (() => Date.now());
32441
- const legacyPath = resolve14(options.legacyPath ?? getStoragePath());
32566
+ const legacyPath = resolve15(options.legacyPath ?? getStoragePath());
32442
32567
  return {
32443
32568
  legacyPath,
32444
32569
  now,
@@ -32507,7 +32632,7 @@ async function openAccountStore(options) {
32507
32632
  async function initializeFreshAccountStoreFor(modules, options = {}) {
32508
32633
  if (options.legacyPath === void 0) await prepareLocalAccountStore();
32509
32634
  return initializeFreshAccountStore(modules, {
32510
- legacyPath: resolve14(options.legacyPath ?? getStoragePath()),
32635
+ legacyPath: resolve15(options.legacyPath ?? getStoragePath()),
32511
32636
  now: options.now ?? (() => Date.now())
32512
32637
  });
32513
32638
  }
@@ -32585,12 +32710,12 @@ var init_storage = __esm({
32585
32710
  import { createHash as createHash12 } from "node:crypto";
32586
32711
  import { existsSync as existsSync4, promises as fs2, readFileSync as readFileSync2, realpathSync as realpathSync2 } from "node:fs";
32587
32712
  import { homedir as homedir5 } from "node:os";
32588
- import { dirname as dirname17, join as join15, resolve as resolve15 } from "node:path";
32713
+ import { dirname as dirname17, join as join15, resolve as resolve16 } from "node:path";
32589
32714
  function configDirIdentity(path5) {
32590
32715
  try {
32591
32716
  return realpathSync2.native(path5);
32592
32717
  } catch {
32593
- return resolve15(path5);
32718
+ return resolve16(path5);
32594
32719
  }
32595
32720
  }
32596
32721
  function decisionKey(location) {
@@ -33043,13 +33168,13 @@ function closeDebugStream(state) {
33043
33168
  state.logWriter = () => {
33044
33169
  };
33045
33170
  if (state.logFilePath) liveLogFilePaths.delete(state.logFilePath);
33046
- return new Promise((resolve25) => {
33047
- current.once("close", () => resolve25());
33048
- current.once("error", () => resolve25());
33171
+ return new Promise((resolve26) => {
33172
+ current.once("close", () => resolve26());
33173
+ current.once("error", () => resolve26());
33049
33174
  try {
33050
33175
  current.end();
33051
33176
  } catch {
33052
- resolve25();
33177
+ resolve26();
33053
33178
  }
33054
33179
  });
33055
33180
  }
@@ -33314,13 +33439,13 @@ function closeDebugLog() {
33314
33439
  if (!state || !current) return Promise.resolve();
33315
33440
  state.logStream = null;
33316
33441
  if (state.logFilePath) liveLogFilePaths.delete(state.logFilePath);
33317
- return new Promise((resolve25) => {
33318
- current.once("close", () => resolve25());
33319
- current.once("error", () => resolve25());
33442
+ return new Promise((resolve26) => {
33443
+ current.once("close", () => resolve26());
33444
+ current.once("error", () => resolve26());
33320
33445
  try {
33321
33446
  current.end();
33322
33447
  } catch {
33323
- resolve25();
33448
+ resolve26();
33324
33449
  }
33325
33450
  });
33326
33451
  }
@@ -33437,10 +33562,10 @@ function createLocationLogger(options) {
33437
33562
  const engine = createLoggerInstance2({
33438
33563
  level: () => configuredLevel,
33439
33564
  extraSecretKeys: isProviderSecretKey,
33440
- captureSink: ({ channel, level, message, data }) => {
33565
+ captureSink: ({ channel: channel3, level, message, data }) => {
33441
33566
  const extra = data !== null && typeof data === "object" && !Array.isArray(data) ? Object.fromEntries(Object.entries(data)) : void 0;
33442
33567
  emit({
33443
- service: channel,
33568
+ service: channel3,
33444
33569
  level: level === "trace" ? "debug" : level,
33445
33570
  message,
33446
33571
  extra
@@ -33449,12 +33574,12 @@ function createLocationLogger(options) {
33449
33574
  });
33450
33575
  return {
33451
33576
  createLogger(module) {
33452
- const channel = engine.createLogger(`antigravity.${module}`);
33577
+ const channel3 = engine.createLogger(`antigravity.${module}`);
33453
33578
  return {
33454
- debug: (message, extra) => channel.debug(message, extra),
33455
- info: (message, extra) => channel.info(message, extra),
33456
- warn: (message, extra) => channel.warn(message, extra),
33457
- error: (message, extra) => channel.error(message, extra)
33579
+ debug: (message, extra) => channel3.debug(message, extra),
33580
+ info: (message, extra) => channel3.info(message, extra),
33581
+ warn: (message, extra) => channel3.warn(message, extra),
33582
+ error: (message, extra) => channel3.error(message, extra)
33458
33583
  };
33459
33584
  },
33460
33585
  setLevel(level) {
@@ -33495,10 +33620,10 @@ function initLogger3(client) {
33495
33620
  setLogSink(getLegacyLogger().coreLogSink);
33496
33621
  }
33497
33622
  function createLogger4(module) {
33498
- let channel;
33623
+ let channel3;
33499
33624
  const log16 = (level, message, extra) => {
33500
- channel ??= getLegacyLogger().createLogger(module);
33501
- channel[level](message, extra);
33625
+ channel3 ??= getLegacyLogger().createLogger(module);
33626
+ channel3[level](message, extra);
33502
33627
  };
33503
33628
  return {
33504
33629
  debug: (message, extra) => log16("debug", message, extra),
@@ -33531,13 +33656,13 @@ var init_logger4 = __esm({
33531
33656
  // src/plugin/index.ts
33532
33657
  init_dist();
33533
33658
  import { createHash as createHash23, randomUUID as randomUUID21 } from "node:crypto";
33534
- import { join as join38, resolve as resolve24 } from "node:path";
33659
+ import { join as join38, resolve as resolve25 } from "node:path";
33535
33660
 
33536
33661
  // src/cli.ts
33537
33662
  init_dist();
33538
33663
  import { execFile } from "node:child_process";
33539
33664
  import { realpathSync as realpathSync4 } from "node:fs";
33540
- import { resolve as resolve19 } from "node:path";
33665
+ import { resolve as resolve20 } from "node:path";
33541
33666
  import { createInterface } from "node:readline/promises";
33542
33667
  import { fileURLToPath as fileURLToPath2 } from "node:url";
33543
33668
  import { promisify } from "node:util";
@@ -34188,7 +34313,7 @@ function drainSidebarWrites() {
34188
34313
  return sidebarWriteChain;
34189
34314
  }
34190
34315
  async function sleep3(ms) {
34191
- await new Promise((resolve25) => setTimeout(resolve25, ms));
34316
+ await new Promise((resolve26) => setTimeout(resolve26, ms));
34192
34317
  }
34193
34318
  async function acquireSidebarLockWithRetry(stateFile) {
34194
34319
  const start = Date.now();
@@ -35040,14 +35165,14 @@ var LocalQuotaGrantStaleError = class extends Error {
35040
35165
  name = "LocalQuotaGrantStaleError";
35041
35166
  };
35042
35167
  function untilQuotaAborted(pending, signal) {
35043
- return new Promise((resolve25, reject) => {
35168
+ return new Promise((resolve26, reject) => {
35044
35169
  const abort = () => reject(signal.reason);
35045
35170
  if (signal.aborted) abort();
35046
35171
  else signal.addEventListener("abort", abort, { once: true });
35047
35172
  void pending.then(
35048
35173
  (value) => {
35049
35174
  signal.removeEventListener("abort", abort);
35050
- resolve25(value);
35175
+ resolve26(value);
35051
35176
  },
35052
35177
  (error) => {
35053
35178
  signal.removeEventListener("abort", abort);
@@ -35668,12 +35793,12 @@ async function startOAuthListener({
35668
35793
  let resolveCallback;
35669
35794
  let rejectCallback;
35670
35795
  let timeoutHandle;
35671
- const callbackPromise = new Promise((resolve25, reject) => {
35796
+ const callbackPromise = new Promise((resolve26, reject) => {
35672
35797
  resolveCallback = (url) => {
35673
35798
  if (settled) return;
35674
35799
  settled = true;
35675
35800
  if (timeoutHandle) clearTimeout(timeoutHandle);
35676
- resolve25(url);
35801
+ resolve26(url);
35677
35802
  };
35678
35803
  rejectCallback = (error) => {
35679
35804
  if (settled) return;
@@ -35832,7 +35957,7 @@ async function startOAuthListener({
35832
35957
  });
35833
35958
  });
35834
35959
  const bindAddress = getBindAddress();
35835
- await new Promise((resolve25, reject) => {
35960
+ await new Promise((resolve26, reject) => {
35836
35961
  const handleError = (error) => {
35837
35962
  server.off("error", handleError);
35838
35963
  if (error.code === "EADDRINUSE") {
@@ -35848,7 +35973,7 @@ async function startOAuthListener({
35848
35973
  server.once("error", handleError);
35849
35974
  server.listen(port, bindAddress, () => {
35850
35975
  server.off("error", handleError);
35851
- resolve25();
35976
+ resolve26();
35852
35977
  });
35853
35978
  });
35854
35979
  server.on("error", (error) => {
@@ -35856,7 +35981,7 @@ async function startOAuthListener({
35856
35981
  });
35857
35982
  return {
35858
35983
  waitForCallback: () => callbackPromise,
35859
- close: () => new Promise((resolve25, reject) => {
35984
+ close: () => new Promise((resolve26, reject) => {
35860
35985
  server.close((error) => {
35861
35986
  if (error && error.code !== "ERR_SERVER_NOT_RUNNING") {
35862
35987
  reject(error);
@@ -35865,7 +35990,7 @@ async function startOAuthListener({
35865
35990
  if (!settled) {
35866
35991
  rejectCallback(new Error("OAuth listener closed before callback"));
35867
35992
  }
35868
- resolve25();
35993
+ resolve26();
35869
35994
  });
35870
35995
  })
35871
35996
  };
@@ -35884,7 +36009,7 @@ init_runtime_paths();
35884
36009
  // src/setup.ts
35885
36010
  init_dist();
35886
36011
  import { lstat as lstat9, readFile as readFile16 } from "node:fs/promises";
35887
- import { join as join23, resolve as resolve18 } from "node:path";
36012
+ import { join as join23, resolve as resolve19 } from "node:path";
35888
36013
 
35889
36014
  // src/auth-method-labels.ts
35890
36015
  var OPENCODE2_POOL_AUTH_LABEL = "Google (antigravity-auth pool, browser)";
@@ -36056,7 +36181,7 @@ async function select2(terminal, items, options) {
36056
36181
  writeLine("");
36057
36182
  renderedLines = lines;
36058
36183
  };
36059
- return new Promise((resolve25) => {
36184
+ return new Promise((resolve26) => {
36060
36185
  const wasRaw = stdin.isRaw ?? false;
36061
36186
  const cleanup2 = () => {
36062
36187
  if (cleaned)
@@ -36076,7 +36201,7 @@ async function select2(terminal, items, options) {
36076
36201
  };
36077
36202
  const finish = (value) => {
36078
36203
  cleanup2();
36079
- resolve25(value);
36204
+ resolve26(value);
36080
36205
  };
36081
36206
  const onSignal = () => finish(null);
36082
36207
  const onKey = (data) => {
@@ -36116,7 +36241,7 @@ async function select2(terminal, items, options) {
36116
36241
  stdin.setRawMode(true);
36117
36242
  } catch {
36118
36243
  cleanup2();
36119
- resolve25(null);
36244
+ resolve26(null);
36120
36245
  return;
36121
36246
  }
36122
36247
  stdin.resume();
@@ -36130,12 +36255,12 @@ async function select2(terminal, items, options) {
36130
36255
  import { createHash as createHash13, randomBytes as randomBytes5, randomUUID as randomUUID17 } from "node:crypto";
36131
36256
  import { constants as fsConstants2 } from "node:fs";
36132
36257
  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";
36133
- import { basename as basename5, dirname as dirname20, extname as extname2, isAbsolute as isAbsolute3, join as join19, resolve as resolve17 } from "node:path";
36258
+ import { basename as basename5, dirname as dirname20, extname as extname2, isAbsolute as isAbsolute3, join as join19, resolve as resolve18 } from "node:path";
36134
36259
  import { ClaustrumCredentialError as ClaustrumCredentialError5, ClaustrumClient as ClaustrumWireClient2, writeEnrollmentTokenFile as writeEnrollmentTokenFile2 } from "@cortexkit/claustrum-client";
36135
36260
 
36136
36261
  // src/common-auth-embedded/fs/file-read-cache.js
36137
36262
  import { lstat as lstat7 } from "node:fs/promises";
36138
- import { resolve as resolve16 } from "node:path";
36263
+ import { resolve as resolve17 } from "node:path";
36139
36264
  async function identity2(path5) {
36140
36265
  try {
36141
36266
  const metadata = await lstat7(path5);
@@ -36152,7 +36277,7 @@ function sameIdentity2(left, right) {
36152
36277
  var FileReadCache2 = class {
36153
36278
  #entries = /* @__PURE__ */ new Map();
36154
36279
  async read(paths, read, validateHit) {
36155
- const resolvedPaths = paths.map((path5) => resolve16(path5));
36280
+ const resolvedPaths = paths.map((path5) => resolve17(path5));
36156
36281
  const key = JSON.stringify(resolvedPaths);
36157
36282
  const probed = await Promise.all(resolvedPaths.map(identity2));
36158
36283
  const identities = probed.every((entry) => entry !== void 0) ? probed : void 0;
@@ -36272,8 +36397,8 @@ async function acquireRefreshFileLockWithClock2(options) {
36272
36397
  let releaseConfirmed = false;
36273
36398
  let loss;
36274
36399
  let resolveLoss;
36275
- const lostPromise = new Promise((resolve25) => {
36276
- resolveLoss = resolve25;
36400
+ const lostPromise = new Promise((resolve26) => {
36401
+ resolveLoss = resolve26;
36277
36402
  });
36278
36403
  function notifyTimerStep(event) {
36279
36404
  try {
@@ -36434,7 +36559,7 @@ async function acquireRefreshFileLockWithClock2(options) {
36434
36559
  }
36435
36560
  }
36436
36561
  async function backoff() {
36437
- await new Promise((resolve25) => setTimeout(resolve25, Math.floor(Math.random() * 4)));
36562
+ await new Promise((resolve26) => setTimeout(resolve26, Math.floor(Math.random() * 4)));
36438
36563
  }
36439
36564
  async function readLockState(notifyReady = true) {
36440
36565
  if (notifyReady && options.onStep)
@@ -36872,7 +36997,7 @@ async function acquireRefreshFileLockWithClock2(options) {
36872
36997
  ...typeof observed?.expiresAt === "number" ? { observedExpiresAt: observed.expiresAt } : {}
36873
36998
  });
36874
36999
  },
36875
- release: async () => {
37000
+ release: async (signal) => {
36876
37001
  if (windowsPrivateFiles2 && releaseConfirmed)
36877
37002
  return;
36878
37003
  released = true;
@@ -36913,6 +37038,8 @@ async function acquireRefreshFileLockWithClock2(options) {
36913
37038
  releaseConfirmed = removalConfirmed;
36914
37039
  return;
36915
37040
  }
37041
+ if (signal?.aborted)
37042
+ return;
36916
37043
  await recoverStaleEvictionMarker();
36917
37044
  } catch (error) {
36918
37045
  if (windowsPrivateFiles2)
@@ -36922,7 +37049,7 @@ async function acquireRefreshFileLockWithClock2(options) {
36922
37049
  const remainingMs = deadline - performance.now();
36923
37050
  if (remainingMs <= 0)
36924
37051
  break;
36925
- await new Promise((resolve25) => setTimeout(resolve25, Math.min(delayMs, remainingMs)));
37052
+ await new Promise((resolve26) => setTimeout(resolve26, Math.min(delayMs, remainingMs)));
36926
37053
  delayMs = Math.min(delayMs * 2, 50);
36927
37054
  }
36928
37055
  if (windowsPrivateFiles2)
@@ -36995,7 +37122,7 @@ function hostEnrollmentPaths2(input2) {
36995
37122
  const override = input2.override?.trim();
36996
37123
  if (override && !isAbsolute3(override) && !input2.cwd)
36997
37124
  throw new ClaustrumConsumerError2("invalid-state", "A relative Claustrum enrollment override needs a base directory");
36998
- const tokenPath = override ? isAbsolute3(override) ? override : resolve17(input2.cwd, override) : join19(input2.stateDir, `${input2.host}-enrollment.json`);
37125
+ const tokenPath = override ? isAbsolute3(override) ? override : resolve18(input2.cwd, override) : join19(input2.stateDir, `${input2.host}-enrollment.json`);
36999
37126
  return getClaustrumEnrollmentPaths2(tokenPath);
37000
37127
  }
37001
37128
  function isRecord11(value) {
@@ -37623,7 +37750,7 @@ var ByteTail = class {
37623
37750
  };
37624
37751
  var defaultCommandRunner = {
37625
37752
  run(file, args, options = {}) {
37626
- return new Promise((resolve25) => {
37753
+ return new Promise((resolve26) => {
37627
37754
  const started = performance.now();
37628
37755
  const timeoutMs = options.timeoutMs ?? 15e3;
37629
37756
  const stderr = new ByteTail();
@@ -37641,7 +37768,7 @@ var defaultCommandRunner = {
37641
37768
  stdio: ["ignore", "pipe", "pipe"]
37642
37769
  });
37643
37770
  } catch {
37644
- resolve25({
37771
+ resolve26({
37645
37772
  exitCode: 1,
37646
37773
  stdout: "",
37647
37774
  stderr: "",
@@ -37676,7 +37803,7 @@ var defaultCommandRunner = {
37676
37803
  settled = true;
37677
37804
  if (timer)
37678
37805
  clearTimeout(timer);
37679
- resolve25({
37806
+ resolve26({
37680
37807
  exitCode: spawnError ? 1 : outputExceeded ? 1 : code2 ?? 1,
37681
37808
  stdout: Buffer.concat(stdout, stdoutLength).toString("utf8"),
37682
37809
  stderr: stderr.toString(),
@@ -39135,7 +39262,7 @@ async function writeNativeSlot(host, slot, context, expectedAuthority = "local")
39135
39262
  beforeRename: async () => {
39136
39263
  await assertSetupHostsStopped();
39137
39264
  const claustrum = await loadCommonAuthClaustrum();
39138
- const stateDir = host === "opencode" ? openCodeVaultDir(resolve18(accountFileForVault())) : getPiAntigravityVaultDir();
39265
+ const stateDir = host === "opencode" ? openCodeVaultDir(resolve19(accountFileForVault())) : getPiAntigravityVaultDir();
39139
39266
  if (await claustrum.enrollmentAuthority(
39140
39267
  claustrum.hostEnrollmentPaths({ stateDir, host }),
39141
39268
  `antigravity-auth-${host}`
@@ -39173,7 +39300,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
39173
39300
  // `beforeSignIn`, which may move it after this plugin is built.
39174
39301
  paths: {
39175
39302
  get stateDir() {
39176
- return openCodeVaultDir(resolve18(accountFileForVault()));
39303
+ return openCodeVaultDir(resolve19(accountFileForVault()));
39177
39304
  },
39178
39305
  host: "opencode"
39179
39306
  }
@@ -39190,7 +39317,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
39190
39317
  const assertLocal = async (host, context) => {
39191
39318
  if (host === "opencode")
39192
39319
  return assertLocalOpenCodeLogin(
39193
- resolve18(accountFileForVault()),
39320
+ resolve19(accountFileForVault()),
39194
39321
  context.opencodeGeneration
39195
39322
  );
39196
39323
  if (await authority(host) !== "local")
@@ -39820,7 +39947,7 @@ async function runCliProcess(argv, deps) {
39820
39947
  ...deps,
39821
39948
  prepareVaultFolder: deps.prepareVaultFolder ?? (async (options) => {
39822
39949
  const folder = await prepareVaultFolder({
39823
- accountFile: resolve19(accountFileForVault()),
39950
+ accountFile: resolve20(accountFileForVault()),
39824
39951
  ...options
39825
39952
  });
39826
39953
  if (folder.refusal) throw folder.refusal;
@@ -39866,11 +39993,11 @@ function createDefaultCliDependencies() {
39866
39993
  );
39867
39994
  if (host !== "pi")
39868
39995
  await assertLocalOpenCodeLogin(
39869
- resolve19(accountFileForVault()),
39996
+ resolve20(accountFileForVault()),
39870
39997
  context?.opencodeGeneration
39871
39998
  );
39872
39999
  const repository = host === "pi" ? void 0 : await prepareCliLoginStore(
39873
- resolve19(getStoragePath()),
40000
+ resolve20(getStoragePath()),
39874
40001
  context?.opencodeGeneration
39875
40002
  );
39876
40003
  try {
@@ -39886,7 +40013,7 @@ function createDefaultCliDependencies() {
39886
40013
  }
39887
40014
  if (host === "opencode") await assertSetupHostsStopped();
39888
40015
  await assertLocalOpenCodeLogin(
39889
- resolve19(accountFileForVault()),
40016
+ resolve20(accountFileForVault()),
39890
40017
  context?.opencodeGeneration
39891
40018
  );
39892
40019
  await persistCliStoreLogin(
@@ -39906,7 +40033,7 @@ function createDefaultCliDependencies() {
39906
40033
  };
39907
40034
  }
39908
40035
  async function prepareCliLoginStore(legacyPath, generation) {
39909
- await assertLocalOpenCodeLogin(resolve19(accountFileForVault()), generation);
40036
+ await assertLocalOpenCodeLogin(resolve20(accountFileForVault()), generation);
39910
40037
  const modules = await loadCommonAuthStoreModules();
39911
40038
  const options = {
39912
40039
  legacyPath,
@@ -40031,7 +40158,7 @@ async function readAccountStore(legacyPath) {
40031
40158
  function createDefaultAccountStoreOperations() {
40032
40159
  const offline = { processesStopped: true };
40033
40160
  return {
40034
- legacyPath: () => resolve19(
40161
+ legacyPath: () => resolve20(
40035
40162
  decidedAccountStoreAnchor(runtimeLayoutLocation()) ? getStoragePath() : discoveredAccountFile()
40036
40163
  ),
40037
40164
  migrate: async (legacyPath) => createAccountMigrationFactory(await loadCommonAuthStoreModules())({
@@ -40062,7 +40189,7 @@ function createDefaultAccountStoreOperations() {
40062
40189
  };
40063
40190
  }
40064
40191
  function samePath(left, right) {
40065
- return process.platform === "win32" ? resolve19(left).toLowerCase() === resolve19(right).toLowerCase() : resolve19(left) === resolve19(right);
40192
+ return process.platform === "win32" ? resolve20(left).toLowerCase() === resolve20(right).toLowerCase() : resolve20(left) === resolve20(right);
40066
40193
  }
40067
40194
  function isCliEntry() {
40068
40195
  if (import.meta.main !== void 0) return import.meta.main;
@@ -40552,14 +40679,14 @@ function isTuiConnected(sessionId) {
40552
40679
  // src/rpc/rpc-dir.ts
40553
40680
  import { createHash as createHash14 } from "node:crypto";
40554
40681
  import { homedir as homedir10, tmpdir as tmpdir4 } from "node:os";
40555
- import { isAbsolute as isAbsolute4, join as join27, resolve as resolve20 } from "node:path";
40682
+ import { isAbsolute as isAbsolute4, join as join27, resolve as resolve21 } from "node:path";
40556
40683
  var RPC_DIR_ENV = "ANTIGRAVITY_AUTH_RPC_DIR";
40557
40684
  function getRpcDir(projectDirectory) {
40558
40685
  const override = process.env[RPC_DIR_ENV]?.trim();
40559
40686
  if (override) {
40560
- return isAbsolute4(override) ? override : resolve20(projectDirectory, override);
40687
+ return isAbsolute4(override) ? override : resolve21(projectDirectory, override);
40561
40688
  }
40562
- const projectHash = createHash14("sha256").update(resolve20(projectDirectory)).digest("hex").slice(0, 16);
40689
+ const projectHash = createHash14("sha256").update(resolve21(projectDirectory)).digest("hex").slice(0, 16);
40563
40690
  const stateHome = process.env.XDG_STATE_HOME ?? join27(homedir10(), ".local", "state");
40564
40691
  return join27(stateHome, "cortexkit", "antigravity-auth", "rpc", projectHash);
40565
40692
  }
@@ -40573,7 +40700,7 @@ function isSessionId(value) {
40573
40700
  init_private_files2();
40574
40701
  import { createHash as createHash15, randomUUID as randomUUID19 } from "node:crypto";
40575
40702
  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";
40576
- import { join as join28, resolve as resolve21 } from "node:path";
40703
+ import { join as join28, resolve as resolve22 } from "node:path";
40577
40704
  function isProbeablePid(pid) {
40578
40705
  return typeof pid === "number" && Number.isSafeInteger(pid) && pid > 0;
40579
40706
  }
@@ -40660,7 +40787,7 @@ async function sweepRpcState(root, activeDir, isManagedDir, log16) {
40660
40787
  return;
40661
40788
  throw error;
40662
40789
  }
40663
- const active2 = resolve21(activeDir);
40790
+ const active2 = resolve22(activeDir);
40664
40791
  for (const projectDir of projectDirs) {
40665
40792
  if (!projectDir.isDirectory() || !isManagedDir(projectDir.name)) {
40666
40793
  continue;
@@ -40704,7 +40831,7 @@ async function sweepRpcState(root, activeDir, isManagedDir, log16) {
40704
40831
  await unlink12(portFile).catch(() => {
40705
40832
  });
40706
40833
  }
40707
- if (resolve21(dir) !== active2)
40834
+ if (resolve22(dir) !== active2)
40708
40835
  await rmdir3(dir).catch(() => {
40709
40836
  });
40710
40837
  }
@@ -40738,7 +40865,7 @@ var BodyTooLargeError = class extends Error {
40738
40865
  }
40739
40866
  };
40740
40867
  function readBody(req) {
40741
- return new Promise((resolve25, reject) => {
40868
+ return new Promise((resolve26, reject) => {
40742
40869
  const tooLarge = (declaredOversize = false) => {
40743
40870
  req.removeAllListeners("data");
40744
40871
  req.on("data", () => {
@@ -40761,7 +40888,7 @@ function readBody(req) {
40761
40888
  }
40762
40889
  chunks.push(chunk);
40763
40890
  });
40764
- req.on("end", () => resolve25(Buffer.concat(chunks).toString("utf8")));
40891
+ req.on("end", () => resolve26(Buffer.concat(chunks).toString("utf8")));
40765
40892
  req.on("error", reject);
40766
40893
  });
40767
40894
  }
@@ -40940,12 +41067,12 @@ async function startRpcServer(options) {
40940
41067
  json(500, { error: "internal error" });
40941
41068
  }
40942
41069
  }
40943
- const port = await new Promise((resolve25, reject) => {
41070
+ const port = await new Promise((resolve26, reject) => {
40944
41071
  server.on("error", reject);
40945
41072
  server.listen(0, "127.0.0.1", () => {
40946
41073
  const addr = server.address();
40947
41074
  if (addr && typeof addr === "object")
40948
- resolve25(addr.port);
41075
+ resolve26(addr.port);
40949
41076
  else
40950
41077
  reject(new Error("no port"));
40951
41078
  });
@@ -40968,16 +41095,16 @@ async function startRpcServer(options) {
40968
41095
  rpcPort: port
40969
41096
  });
40970
41097
  } catch (error) {
40971
- await new Promise((resolve25) => server.close(() => resolve25()));
41098
+ await new Promise((resolve26) => server.close(() => resolve26()));
40972
41099
  throw error;
40973
41100
  }
40974
41101
  return {
40975
41102
  port,
40976
41103
  token,
40977
41104
  async stop() {
40978
- await new Promise((resolve25) => {
41105
+ await new Promise((resolve26) => {
40979
41106
  server.closeAllConnections?.();
40980
- server.close(() => resolve25());
41107
+ server.close(() => resolve26());
40981
41108
  for (const socket of connections)
40982
41109
  socket.destroy();
40983
41110
  });
@@ -42351,7 +42478,7 @@ async function select3(items, options) {
42351
42478
  }
42352
42479
  renderedLines = linesWritten;
42353
42480
  };
42354
- return new Promise((resolve25) => {
42481
+ return new Promise((resolve26) => {
42355
42482
  const wasRaw = stdin.isRaw ?? false;
42356
42483
  const cleanup2 = () => {
42357
42484
  if (isCleanedUp) return;
@@ -42372,11 +42499,11 @@ async function select3(items, options) {
42372
42499
  };
42373
42500
  const onSignal = () => {
42374
42501
  cleanup2();
42375
- resolve25(null);
42502
+ resolve26(null);
42376
42503
  };
42377
42504
  const finishWithValue = (value) => {
42378
42505
  cleanup2();
42379
- resolve25(value);
42506
+ resolve26(value);
42380
42507
  };
42381
42508
  const findNextSelectable = (from, direction) => {
42382
42509
  if (items.length === 0) return from;
@@ -42422,7 +42549,7 @@ async function select3(items, options) {
42422
42549
  stdin.setRawMode(true);
42423
42550
  } catch {
42424
42551
  cleanup2();
42425
- resolve25(null);
42552
+ resolve26(null);
42426
42553
  return;
42427
42554
  }
42428
42555
  stdin.resume();
@@ -45188,7 +45315,7 @@ init_runtime_paths();
45188
45315
  init_logger4();
45189
45316
  import { existsSync as existsSync11, readFileSync as readFileSync11, realpathSync as realpathSync5 } from "node:fs";
45190
45317
  import { homedir as homedir12 } from "node:os";
45191
- import { basename as basename7, dirname as dirname25, join as join32, resolve as resolve22 } from "node:path";
45318
+ import { basename as basename7, dirname as dirname25, join as join32, resolve as resolve23 } from "node:path";
45192
45319
 
45193
45320
  // src/plugin/config/schema.ts
45194
45321
  import { z } from "zod";
@@ -45746,7 +45873,7 @@ function loadConfigWithLogger(directory, log16) {
45746
45873
  return config;
45747
45874
  }
45748
45875
  function canonicalizeOwnedPath(path5) {
45749
- const absolute = resolve22(path5);
45876
+ const absolute = resolve23(path5);
45750
45877
  const missing = [];
45751
45878
  let current = absolute;
45752
45879
  for (; ; ) {
@@ -50684,10 +50811,10 @@ async function retainResponseLifetime(response, cancellation) {
50684
50811
  cancellation.release();
50685
50812
  throw error;
50686
50813
  }
50687
- let resolve25 = () => {
50814
+ let resolve26 = () => {
50688
50815
  };
50689
50816
  const settled = new Promise((done) => {
50690
- resolve25 = done;
50817
+ resolve26 = done;
50691
50818
  });
50692
50819
  let stopping = false;
50693
50820
  let finished = false;
@@ -50697,7 +50824,7 @@ async function retainResponseLifetime(response, cancellation) {
50697
50824
  finished = true;
50698
50825
  cancellation.signal.removeEventListener("abort", abort);
50699
50826
  cancellation.release();
50700
- resolve25();
50827
+ resolve26();
50701
50828
  };
50702
50829
  const abort = () => {
50703
50830
  if (finished || stopping) return;
@@ -50766,8 +50893,8 @@ function createAfterHandoff(work, signals, onFailure) {
50766
50893
  let running = false;
50767
50894
  let resolveCompletion = () => {
50768
50895
  };
50769
- const completion = new Promise((resolve25) => {
50770
- resolveCompletion = resolve25;
50896
+ const completion = new Promise((resolve26) => {
50897
+ resolveCompletion = resolve26;
50771
50898
  });
50772
50899
  const finish = () => {
50773
50900
  if (finished) return;
@@ -50814,14 +50941,14 @@ function createAfterHandoff(work, signals, onFailure) {
50814
50941
  };
50815
50942
  }
50816
50943
  function publishResponse(dispatch) {
50817
- return new Promise((resolve25, reject) => {
50944
+ return new Promise((resolve26, reject) => {
50818
50945
  let acknowledge;
50819
50946
  void Promise.resolve().then(
50820
50947
  () => dispatch((callback) => {
50821
50948
  acknowledge = callback;
50822
50949
  })
50823
50950
  ).then((response) => {
50824
- resolve25(response);
50951
+ resolve26(response);
50825
50952
  acknowledge?.();
50826
50953
  }, reject);
50827
50954
  });
@@ -52655,10 +52782,10 @@ function resolvePluginDependencies(overrides = {}) {
52655
52782
  }
52656
52783
  async function defaultSleep(ms, signal) {
52657
52784
  if (ms <= 0) return;
52658
- await new Promise((resolve25, reject) => {
52785
+ await new Promise((resolve26, reject) => {
52659
52786
  const timer = setTimeout(() => {
52660
52787
  signal?.removeEventListener("abort", onAbort);
52661
- resolve25();
52788
+ resolve26();
52662
52789
  }, ms);
52663
52790
  timer.unref?.();
52664
52791
  const onAbort = () => {
@@ -53244,7 +53371,7 @@ function throwIfAllKilled(input2) {
53244
53371
  }
53245
53372
 
53246
53373
  // src/plugin/session-context.ts
53247
- import { resolve as resolve23 } from "node:path";
53374
+ import { resolve as resolve24 } from "node:path";
53248
53375
  import { pathToFileURL } from "node:url";
53249
53376
  var FALLBACK_SESSION_KEY = "__default__";
53250
53377
  function extractOpenCodeSessionIdentity(headers) {
@@ -53258,7 +53385,7 @@ var AgySessionRegistry = class {
53258
53385
  requestSessions;
53259
53386
  parentSessionIds = /* @__PURE__ */ new Map();
53260
53387
  constructor(directory, options = {}) {
53261
- const workspaceUri = directory ? pathToFileURL(resolve23(directory)).href : "";
53388
+ const workspaceUri = directory ? pathToFileURL(resolve24(directory)).href : "";
53262
53389
  this.requestSessions = new AgyRequestSessionStore(workspaceUri, options);
53263
53390
  }
53264
53391
  getOrCreate(identity3) {
@@ -53406,7 +53533,7 @@ function formatWaitTime(ms) {
53406
53533
  return remainingMinutes > 0 ? `${hours}h ${remainingMinutes}m` : `${hours}h`;
53407
53534
  }
53408
53535
  function sleep4(ms, signal) {
53409
- return new Promise((resolve25, reject) => {
53536
+ return new Promise((resolve26, reject) => {
53410
53537
  if (signal?.aborted) {
53411
53538
  reject(
53412
53539
  signal.reason instanceof Error ? signal.reason : new Error("Aborted")
@@ -53415,7 +53542,7 @@ function sleep4(ms, signal) {
53415
53542
  }
53416
53543
  const timeout = setTimeout(() => {
53417
53544
  cleanup2();
53418
- resolve25();
53545
+ resolve26();
53419
53546
  }, ms);
53420
53547
  const onAbort = () => {
53421
53548
  cleanup2();
@@ -55903,8 +56030,8 @@ function createPluginLifecycle(options) {
55903
56030
  };
55904
56031
  let failDisposal = () => {
55905
56032
  };
55906
- disposal = new Promise((resolve25, reject) => {
55907
- finishDisposal = resolve25;
56033
+ disposal = new Promise((resolve26, reject) => {
56034
+ finishDisposal = resolve26;
55908
56035
  failDisposal = reject;
55909
56036
  });
55910
56037
  void (async () => {
@@ -56103,7 +56230,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
56103
56230
  await drainSidebarWrites();
56104
56231
  }
56105
56232
  });
56106
- const accountFile = resolve24(accountFileForVault());
56233
+ const accountFile = resolve25(accountFileForVault());
56107
56234
  const vaultFolder = await prepareVaultFolder({ accountFile });
56108
56235
  const unavailableMessage = vaultFolder.refusal?.message ?? VAULT_ACCOUNT_REMEDY;
56109
56236
  let vaultQuotaPoller;