@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/cli.js CHANGED
@@ -6046,7 +6046,7 @@ async function rmEvictingDir(evictingPath) {
6046
6046
  });
6047
6047
  }
6048
6048
  async function sleep(ms) {
6049
- await new Promise((resolve20) => setTimeout(resolve20, ms));
6049
+ await new Promise((resolve21) => setTimeout(resolve21, ms));
6050
6050
  }
6051
6051
  async function acquireFencedFileLock(options) {
6052
6052
  const lockPath = `${options.path}.${options.name}.lock`;
@@ -6162,8 +6162,8 @@ function buildLock(lockPath, evictingPath, ownerId, options, now) {
6162
6162
  let released = false;
6163
6163
  let lost = false;
6164
6164
  let lostResolve = null;
6165
- let lostPromise = new Promise((resolve20) => {
6166
- lostResolve = resolve20;
6165
+ let lostPromise = new Promise((resolve21) => {
6166
+ lostResolve = resolve21;
6167
6167
  });
6168
6168
  const markLost = () => {
6169
6169
  if (lost)
@@ -6173,9 +6173,9 @@ function buildLock(lockPath, evictingPath, ownerId, options, now) {
6173
6173
  clearInterval(renewTimer);
6174
6174
  renewTimer = null;
6175
6175
  }
6176
- const resolve20 = lostResolve;
6176
+ const resolve21 = lostResolve;
6177
6177
  lostResolve = null;
6178
- resolve20?.();
6178
+ resolve21?.();
6179
6179
  };
6180
6180
  const setupRenew = () => {
6181
6181
  if (options.renew === false)
@@ -6817,7 +6817,7 @@ var init_account_storage = __esm({
6817
6817
  }
6818
6818
  };
6819
6819
  RETRY_DELAYS_MS = [100, 200, 400, 800, 1e3];
6820
- DEFAULT_SLEEP = (ms) => new Promise((resolve20) => setTimeout(resolve20, ms));
6820
+ DEFAULT_SLEEP = (ms) => new Promise((resolve21) => setTimeout(resolve21, ms));
6821
6821
  DEFAULT_BUILD_BACKUP_PATH = (path2, now) => `${path2}.corrupt-${now.toISOString().replace(/[:.]/g, "-")}`;
6822
6822
  }
6823
6823
  });
@@ -6985,7 +6985,7 @@ function getHttpsProxy(url) {
6985
6985
  }
6986
6986
  }
6987
6987
  function waitForHead(socket, timeoutMs, onTimeout) {
6988
- return new Promise((resolve20, reject) => {
6988
+ return new Promise((resolve21, reject) => {
6989
6989
  let buffer = Buffer2.alloc(0);
6990
6990
  const timeout = setTimeout(() => {
6991
6991
  onTimeout();
@@ -7008,7 +7008,7 @@ function waitForHead(socket, timeoutMs, onTimeout) {
7008
7008
  return;
7009
7009
  const head = buffer.subarray(0, marker).toString("latin1");
7010
7010
  const leftover = buffer.subarray(marker + 4);
7011
- cleanup2(() => resolve20({ head, leftover }));
7011
+ cleanup2(() => resolve21({ head, leftover }));
7012
7012
  };
7013
7013
  socket.on("data", onData);
7014
7014
  socket.once("error", onError);
@@ -7022,7 +7022,7 @@ async function connectViaProxy(proxyUrl, targetUrl, timeoutMs, signal, onDebug)
7022
7022
  port: Number(proxyUrl.port || DEFAULT_PROXY_PORT),
7023
7023
  signal: signal ?? void 0
7024
7024
  });
7025
- await new Promise((resolve20, reject) => {
7025
+ await new Promise((resolve21, reject) => {
7026
7026
  const timeout = setTimeout(() => {
7027
7027
  onDebug?.(`agy transport proxy connect timeout after ${timeoutMs}ms`);
7028
7028
  proxySocket.destroy();
@@ -7031,7 +7031,7 @@ async function connectViaProxy(proxyUrl, targetUrl, timeoutMs, signal, onDebug)
7031
7031
  const cleanup2 = () => clearTimeout(timeout);
7032
7032
  proxySocket.once("connect", () => {
7033
7033
  cleanup2();
7034
- resolve20();
7034
+ resolve21();
7035
7035
  });
7036
7036
  proxySocket.once("error", (error) => {
7037
7037
  cleanup2();
@@ -7056,7 +7056,7 @@ Host: ${targetHost}:${targetPort}\r
7056
7056
  if (leftover.length > 0) {
7057
7057
  proxySocket.unshift(leftover);
7058
7058
  }
7059
- return await new Promise((resolve20, reject) => {
7059
+ return await new Promise((resolve21, reject) => {
7060
7060
  const tlsOptions = {
7061
7061
  socket: proxySocket,
7062
7062
  servername: targetHost,
@@ -7071,7 +7071,7 @@ Host: ${targetHost}:${targetPort}\r
7071
7071
  const cleanup2 = () => clearTimeout(timeout);
7072
7072
  tlsSocket.once("secureConnect", () => {
7073
7073
  cleanup2();
7074
- resolve20(tlsSocket);
7074
+ resolve21(tlsSocket);
7075
7075
  });
7076
7076
  tlsSocket.once("error", (error) => {
7077
7077
  cleanup2();
@@ -7080,7 +7080,7 @@ Host: ${targetHost}:${targetPort}\r
7080
7080
  });
7081
7081
  }
7082
7082
  async function connectDirect(targetUrl, timeoutMs, signal, onDebug) {
7083
- return await new Promise((resolve20, reject) => {
7083
+ return await new Promise((resolve21, reject) => {
7084
7084
  const tlsOptions = {
7085
7085
  host: targetUrl.hostname,
7086
7086
  port: Number(targetUrl.port || DEFAULT_HTTPS_PORT),
@@ -7096,7 +7096,7 @@ async function connectDirect(targetUrl, timeoutMs, signal, onDebug) {
7096
7096
  const cleanup2 = () => clearTimeout(timeout);
7097
7097
  socket.once("secureConnect", () => {
7098
7098
  cleanup2();
7099
- resolve20(socket);
7099
+ resolve21(socket);
7100
7100
  });
7101
7101
  socket.once("error", (error) => {
7102
7102
  cleanup2();
@@ -8650,8 +8650,8 @@ async function acquireRefreshFileLockWithClock(options) {
8650
8650
  let releaseConfirmed = false;
8651
8651
  let loss;
8652
8652
  let resolveLoss;
8653
- const lostPromise = new Promise((resolve20) => {
8654
- resolveLoss = resolve20;
8653
+ const lostPromise = new Promise((resolve21) => {
8654
+ resolveLoss = resolve21;
8655
8655
  });
8656
8656
  function notifyTimerStep(event) {
8657
8657
  try {
@@ -8812,7 +8812,7 @@ async function acquireRefreshFileLockWithClock(options) {
8812
8812
  }
8813
8813
  }
8814
8814
  async function backoff() {
8815
- await new Promise((resolve20) => setTimeout(resolve20, Math.floor(Math.random() * 4)));
8815
+ await new Promise((resolve21) => setTimeout(resolve21, Math.floor(Math.random() * 4)));
8816
8816
  }
8817
8817
  async function readLockState(notifyReady = true) {
8818
8818
  if (notifyReady && options.onStep)
@@ -9250,7 +9250,7 @@ async function acquireRefreshFileLockWithClock(options) {
9250
9250
  ...typeof observed?.expiresAt === "number" ? { observedExpiresAt: observed.expiresAt } : {}
9251
9251
  });
9252
9252
  },
9253
- release: async () => {
9253
+ release: async (signal) => {
9254
9254
  if (windowsPrivateFiles && releaseConfirmed)
9255
9255
  return;
9256
9256
  released = true;
@@ -9291,6 +9291,8 @@ async function acquireRefreshFileLockWithClock(options) {
9291
9291
  releaseConfirmed = removalConfirmed;
9292
9292
  return;
9293
9293
  }
9294
+ if (signal?.aborted)
9295
+ return;
9294
9296
  await recoverStaleEvictionMarker();
9295
9297
  } catch (error) {
9296
9298
  if (windowsPrivateFiles)
@@ -9300,7 +9302,7 @@ async function acquireRefreshFileLockWithClock(options) {
9300
9302
  const remainingMs = deadline - performance.now();
9301
9303
  if (remainingMs <= 0)
9302
9304
  break;
9303
- await new Promise((resolve20) => setTimeout(resolve20, Math.min(delayMs, remainingMs)));
9305
+ await new Promise((resolve21) => setTimeout(resolve21, Math.min(delayMs, remainingMs)));
9304
9306
  delayMs = Math.min(delayMs * 2, 50);
9305
9307
  }
9306
9308
  if (windowsPrivateFiles)
@@ -9343,7 +9345,7 @@ async function withLock(target, options, fn) {
9343
9345
  options.signal?.throwIfAborted();
9344
9346
  return await fn(lock);
9345
9347
  } finally {
9346
- await lock.release();
9348
+ await lock.release(options.signal);
9347
9349
  }
9348
9350
  }
9349
9351
  const remaining = options.timeoutMs - (performance.now() - started);
@@ -9354,7 +9356,7 @@ async function withLock(target, options, fn) {
9354
9356
  timeoutMs: options.timeoutMs
9355
9357
  });
9356
9358
  }
9357
- await new Promise((resolve20) => setTimeout(resolve20, Math.min(25, Math.ceil(remaining))));
9359
+ await new Promise((resolve21) => setTimeout(resolve21, Math.min(25, Math.ceil(remaining))));
9358
9360
  }
9359
9361
  }
9360
9362
  var LockContentionError, LockOwnershipError;
@@ -9473,7 +9475,7 @@ async function acquirePoolLock(spec, defaults, env3) {
9473
9475
  });
9474
9476
  }
9475
9477
  const jitter = Math.floor(Math.random() * (options.retryMs + 1));
9476
- await new Promise((resolve20) => setTimeout(resolve20, Math.min(options.retryMs + jitter, remaining)));
9478
+ await new Promise((resolve21) => setTimeout(resolve21, Math.min(options.retryMs + jitter, remaining)));
9477
9479
  }
9478
9480
  }
9479
9481
  function definedOnly(spec) {
@@ -12515,7 +12517,7 @@ function createEngine(options) {
12515
12517
  });
12516
12518
  }, 500);
12517
12519
  }
12518
- function emit(channel, level, message, data) {
12520
+ function emit(channel3, level, message, data) {
12519
12521
  if (logFileSource === void 0 && captureSink === void 0)
12520
12522
  return;
12521
12523
  try {
@@ -12528,10 +12530,10 @@ function createEngine(options) {
12528
12530
  } catch {
12529
12531
  scrubbedData = "[unserializable]";
12530
12532
  }
12531
- const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${level.toUpperCase()} [${channel}] ${scrubbedMessage}` + (data === void 0 ? "" : safeSerialize(scrubbedData)) + "\n";
12533
+ const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${level.toUpperCase()} [${channel3}] ${scrubbedMessage}` + (data === void 0 ? "" : safeSerialize(scrubbedData)) + "\n";
12532
12534
  try {
12533
12535
  captureSink?.({
12534
- channel,
12536
+ channel: channel3,
12535
12537
  level,
12536
12538
  message: scrubbedMessage,
12537
12539
  data: scrubbedData
@@ -12551,13 +12553,13 @@ function createEngine(options) {
12551
12553
  } catch {
12552
12554
  }
12553
12555
  }
12554
- function createLogger5(channel) {
12556
+ function createLogger5(channel3) {
12555
12557
  return {
12556
- error: (m, d) => emit(channel, "error", m, d),
12557
- warn: (m, d) => emit(channel, "warn", m, d),
12558
- info: (m, d) => emit(channel, "info", m, d),
12559
- debug: (m, d) => emit(channel, "debug", m, d),
12560
- trace: (m, d) => emit(channel, "trace", m, d)
12558
+ error: (m, d) => emit(channel3, "error", m, d),
12559
+ warn: (m, d) => emit(channel3, "warn", m, d),
12560
+ info: (m, d) => emit(channel3, "info", m, d),
12561
+ debug: (m, d) => emit(channel3, "debug", m, d),
12562
+ trace: (m, d) => emit(channel3, "trace", m, d)
12561
12563
  };
12562
12564
  }
12563
12565
  function reset() {
@@ -12595,8 +12597,8 @@ function setLogLevel(l) {
12595
12597
  function flushLogs() {
12596
12598
  return defaultEngine.flushLogs();
12597
12599
  }
12598
- function createLogger2(channel) {
12599
- return defaultEngine.createLogger(channel);
12600
+ function createLogger2(channel3) {
12601
+ return defaultEngine.createLogger(channel3);
12600
12602
  }
12601
12603
  async function flushForTest() {
12602
12604
  return defaultEngine.flushLogs();
@@ -12744,11 +12746,11 @@ var init_quota_writer = __esm({
12744
12746
  const left = deadline - performance.now();
12745
12747
  if (left <= 0)
12746
12748
  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);
12747
- await new Promise((resolve20) => {
12749
+ await new Promise((resolve21) => {
12748
12750
  const done = () => {
12749
12751
  clearTimeout(timer);
12750
12752
  this.wake.delete(done);
12751
- resolve20();
12753
+ resolve21();
12752
12754
  };
12753
12755
  const timer = setTimeout(done, left);
12754
12756
  this.wake.add(done);
@@ -15519,7 +15521,7 @@ async function select(terminal, items, options) {
15519
15521
  writeLine("");
15520
15522
  renderedLines = lines;
15521
15523
  };
15522
- return new Promise((resolve20) => {
15524
+ return new Promise((resolve21) => {
15523
15525
  const wasRaw = stdin.isRaw ?? false;
15524
15526
  const cleanup2 = () => {
15525
15527
  if (cleaned)
@@ -15539,7 +15541,7 @@ async function select(terminal, items, options) {
15539
15541
  };
15540
15542
  const finish = (value) => {
15541
15543
  cleanup2();
15542
- resolve20(value);
15544
+ resolve21(value);
15543
15545
  };
15544
15546
  const onSignal = () => finish(null);
15545
15547
  const onKey = (data) => {
@@ -15579,7 +15581,7 @@ async function select(terminal, items, options) {
15579
15581
  stdin.setRawMode(true);
15580
15582
  } catch {
15581
15583
  cleanup2();
15582
- resolve20(null);
15584
+ resolve21(null);
15583
15585
  return;
15584
15586
  }
15585
15587
  stdin.resume();
@@ -16804,6 +16806,8 @@ var init_insula = __esm({
16804
16806
  ...typeof entry.source === "string" && { source: entry.source }
16805
16807
  }
16806
16808
  };
16809
+ if (entry.stale !== void 0 && (!record2(entry.stale) || entry.stale.class !== "local_source_unavailable"))
16810
+ return { miss: "upstream-failed", reading };
16807
16811
  return now >= fetchedAt + MAX_AGE || entry.stale !== void 0 ? { miss: "stale", reading } : { reading };
16808
16812
  }
16809
16813
  if (this.#completeProviders.has(provider2))
@@ -17625,10 +17629,10 @@ async function drainShutdown(pending, onTimeout) {
17625
17629
  try {
17626
17630
  await Promise.race([
17627
17631
  drained,
17628
- new Promise((resolve20) => {
17632
+ new Promise((resolve21) => {
17629
17633
  timer = setTimeout(() => {
17630
17634
  expired = true;
17631
- resolve20();
17635
+ resolve21();
17632
17636
  }, 2e3);
17633
17637
  })
17634
17638
  ]);
@@ -17646,6 +17650,7 @@ var init_shutdown = __esm({
17646
17650
  });
17647
17651
 
17648
17652
  // ../core/dist/common-auth-embedded/claustrum/custody.js
17653
+ import { channel } from "node:diagnostics_channel";
17649
17654
  import { ClaustrumCredentialError as ClaustrumCredentialError3 } from "@cortexkit/claustrum-client";
17650
17655
  function isScopedCredentialRotation(served, current) {
17651
17656
  return current !== void 0 && !current.fromKeptReceipt && !served.fromKeptReceipt && current.credentialId === served.credentialId && current.accountIdentity === served.accountIdentity && current.recordVersion !== served.recordVersion;
@@ -17702,15 +17707,27 @@ function credentialTypeOf(row, family) {
17702
17707
  return notMine;
17703
17708
  if (!row.categories.includes(family.category))
17704
17709
  return notMine;
17705
- if (row.credentialType !== "oauth" && row.credentialType !== "api_key")
17706
- return notMine;
17707
17710
  if ("classify" in family) {
17711
+ const metadata = rowFactsOf(row);
17712
+ let type;
17713
+ switch (metadata.authMethod) {
17714
+ case "apikey":
17715
+ type = "api_key";
17716
+ break;
17717
+ case "chatgpt":
17718
+ case "antigravity":
17719
+ case "oauth":
17720
+ type = "oauth";
17721
+ break;
17722
+ default:
17723
+ return { kind: "refused", code: "unknown-auth-method" };
17724
+ }
17708
17725
  const facts = {
17709
17726
  credentialId: row.id,
17710
- credentialType: row.credentialType,
17727
+ credentialType: type,
17711
17728
  categories: row.categories,
17712
17729
  refreshAdapter: row.refreshAdapter,
17713
- ...rowFactsOf(row)
17730
+ ...metadata
17714
17731
  };
17715
17732
  if (facts.providerIds === void 0)
17716
17733
  return { kind: "refused", code: "unmapped" };
@@ -17719,13 +17736,15 @@ function credentialTypeOf(row, family) {
17719
17736
  if (result.kind === "not-mine")
17720
17737
  return notMine;
17721
17738
  if (result.kind === "mine" && typeof result.member === "string")
17722
- return { kind: "mine", type: row.credentialType, member: result.member };
17739
+ return { kind: "mine", type, member: result.member };
17723
17740
  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))
17724
17741
  return { kind: "refused", code: result.code };
17725
17742
  } catch {
17726
17743
  }
17727
17744
  return { kind: "refused", code: "unclassified" };
17728
17745
  }
17746
+ if (row.credentialType !== "oauth" && row.credentialType !== "api_key")
17747
+ return notMine;
17729
17748
  if (row.credentialType === "oauth")
17730
17749
  return row.refreshAdapter === family.refreshAdapter ? { kind: "mine", type: "oauth" } : notMine;
17731
17750
  if (row.credentialType === "api_key" && family.apiKeys)
@@ -17745,7 +17764,7 @@ function grantReachOf(listed) {
17745
17764
  tuples: Object.freeze(grantTuples.map(({ selectorKind, selector, operation }) => Object.freeze({ selectorKind, selector, operation })))
17746
17765
  });
17747
17766
  }
17748
- var defaultLogger, SERVING_MARGIN_MS, KEPT_RECEIPT_MARGIN_MS, ClaustrumScopedCustody;
17767
+ var defaultLogger, phaseDiagnostics, SERVING_MARGIN_MS, KEPT_RECEIPT_MARGIN_MS, ClaustrumScopedCustody;
17749
17768
  var init_custody = __esm({
17750
17769
  "../core/dist/common-auth-embedded/claustrum/custody.js"() {
17751
17770
  "use strict";
@@ -17757,6 +17776,7 @@ var init_custody = __esm({
17757
17776
  init_shutdown();
17758
17777
  init_watch();
17759
17778
  defaultLogger = createLogger2("claustrum");
17779
+ phaseDiagnostics = channel("common-auth.claustrum.phases");
17760
17780
  SERVING_MARGIN_MS = 3e5;
17761
17781
  KEPT_RECEIPT_MARGIN_MS = 6e4;
17762
17782
  ClaustrumScopedCustody = class {
@@ -17860,6 +17880,11 @@ var init_custody = __esm({
17860
17880
  }
17861
17881
  async #token(signal) {
17862
17882
  this.#check(signal);
17883
+ if (phaseDiagnostics.hasSubscribers)
17884
+ phaseDiagnostics.publish({
17885
+ logger: this.#logger,
17886
+ phase: "token read begin"
17887
+ });
17863
17888
  const pending = this.#readToken();
17864
17889
  this.#tokenReads.add(pending);
17865
17890
  let value;
@@ -17867,6 +17892,11 @@ var init_custody = __esm({
17867
17892
  value = await pending;
17868
17893
  } finally {
17869
17894
  this.#tokenReads.delete(pending);
17895
+ if (phaseDiagnostics.hasSubscribers)
17896
+ phaseDiagnostics.publish({
17897
+ logger: this.#logger,
17898
+ phase: "token read end"
17899
+ });
17870
17900
  }
17871
17901
  this.#check(signal);
17872
17902
  if (!/^[0-9a-f]{64}$/.test(value.token) || !Number.isSafeInteger(value.token_generation) || value.token_generation < 1) {
@@ -17928,11 +17958,22 @@ var init_custody = __esm({
17928
17958
  this.#kept.clear();
17929
17959
  throw error;
17930
17960
  }
17961
+ if (phaseDiagnostics.hasSubscribers)
17962
+ phaseDiagnostics.publish({
17963
+ logger: this.#logger,
17964
+ phase: "list scoped begin"
17965
+ });
17931
17966
  try {
17932
17967
  inventory = await this.#call(() => this.#client.listScoped(token), signal);
17933
17968
  } catch (error) {
17934
17969
  this.listFailed(error);
17935
17970
  throw error;
17971
+ } finally {
17972
+ if (phaseDiagnostics.hasSubscribers)
17973
+ phaseDiagnostics.publish({
17974
+ logger: this.#logger,
17975
+ phase: "list scoped end"
17976
+ });
17936
17977
  }
17937
17978
  const skipped = [];
17938
17979
  const refused2 = [];
@@ -18872,7 +18913,7 @@ async function refreshVaultRoster(options) {
18872
18913
  pendingDiscoveries.set(key, discovered);
18873
18914
  throw error;
18874
18915
  } finally {
18875
- await lease.release();
18916
+ await lease.release(options.signal);
18876
18917
  }
18877
18918
  }
18878
18919
  function resolveVaultPrimary(input) {
@@ -19225,7 +19266,7 @@ var init_consumer = __esm({
19225
19266
  this.#shutdown.signal,
19226
19267
  ...signal ? [signal] : []
19227
19268
  ]);
19228
- return new Promise((resolve20, reject) => {
19269
+ return new Promise((resolve21, reject) => {
19229
19270
  const cleanup2 = () => {
19230
19271
  combined.signal.removeEventListener("abort", abort);
19231
19272
  combined.dispose();
@@ -19240,7 +19281,7 @@ var init_consumer = __esm({
19240
19281
  if (combined.signal.aborted)
19241
19282
  reject(combined.signal.reason);
19242
19283
  else
19243
- resolve20(value);
19284
+ resolve21(value);
19244
19285
  }, (error) => {
19245
19286
  cleanup2();
19246
19287
  reject(error);
@@ -19414,8 +19455,16 @@ var init_consumer = __esm({
19414
19455
  this.#refreshing = void 0;
19415
19456
  });
19416
19457
  this.#track(this.#refreshing);
19458
+ this.#notifyDiscovery(this.#refreshing);
19417
19459
  return this.#refreshing;
19418
19460
  }
19461
+ #notifyDiscovery(promise) {
19462
+ try {
19463
+ this.#options.onDiscovery?.(promise);
19464
+ } catch (error) {
19465
+ this.#options.onError?.(error);
19466
+ }
19467
+ }
19419
19468
  /**
19420
19469
  * Poll in the background and open the vault and insula watches. Until the
19421
19470
  * vault watch is accepted, and whenever it is unavailable, every tick lists
@@ -19645,6 +19694,13 @@ var init_consumer = __esm({
19645
19694
  /** The hub's handle on this member's memory. */
19646
19695
  #hubHooks() {
19647
19696
  return {
19697
+ discovery: (promise) => {
19698
+ const hub = this.#hub;
19699
+ if (!hub || !this.#options.onDiscovery || this.#shutdown.signal.aborted)
19700
+ return;
19701
+ const discovery = this.#track(promise.then((outcome) => this.#hubOutcome(hub, outcome)));
19702
+ this.#notifyDiscovery(discovery);
19703
+ },
19648
19704
  install: (roster) => {
19649
19705
  if (this.#shutdown.signal.aborted)
19650
19706
  return;
@@ -19679,6 +19735,9 @@ var init_consumer = __esm({
19679
19735
  */
19680
19736
  async #hubRefresh(hub) {
19681
19737
  const outcome = await hub.refresh();
19738
+ return this.#hubOutcome(hub, outcome);
19739
+ }
19740
+ #hubOutcome(hub, outcome) {
19682
19741
  this.#assertOpen();
19683
19742
  if (!outcome)
19684
19743
  return void 0;
@@ -19833,6 +19892,8 @@ var init_consumer = __esm({
19833
19892
  this.#assertOpen();
19834
19893
  await declineVaultRoute(this.#options.rosterPath, routeId);
19835
19894
  this.#roster = pendingVaultQuota(this.#options.rosterPath, await readVaultRoster(this.#options.rosterPath));
19895
+ if (this.#roster)
19896
+ this.#hub?.publishRoster(this.#roster);
19836
19897
  if (this.#hub)
19837
19898
  this.#hub.retainUnion();
19838
19899
  else
@@ -19842,6 +19903,8 @@ var init_consumer = __esm({
19842
19903
  this.#assertOpen();
19843
19904
  await acceptVaultRoute(this.#options.rosterPath, routeId);
19844
19905
  this.#roster = pendingVaultQuota(this.#options.rosterPath, await readVaultRoster(this.#options.rosterPath));
19906
+ if (this.#roster)
19907
+ this.#hub?.publishRoster(this.#roster);
19845
19908
  }
19846
19909
  /**
19847
19910
  * Set the order vault accounts are tried in (`reorderVaultRoster`), then
@@ -19852,6 +19915,8 @@ var init_consumer = __esm({
19852
19915
  this.#assertOpen();
19853
19916
  const result = await reorderVaultRoster(this.#options.rosterPath, routeIds);
19854
19917
  this.#roster = pendingVaultQuota(this.#options.rosterPath, await readVaultRoster(this.#options.rosterPath));
19918
+ if (this.#roster)
19919
+ this.#hub?.publishRoster(this.#roster);
19855
19920
  return result;
19856
19921
  }
19857
19922
  /**
@@ -19928,8 +19993,9 @@ var init_consumer = __esm({
19928
19993
 
19929
19994
  // ../core/dist/common-auth-embedded/claustrum/hub.js
19930
19995
  import { createHash as createHash7 } from "node:crypto";
19996
+ import { channel as channel2 } from "node:diagnostics_channel";
19931
19997
  import { readdir, stat as stat6 } from "node:fs/promises";
19932
- import { dirname as dirname10, join as join7 } from "node:path";
19998
+ import { dirname as dirname10, join as join7, resolve as resolve9 } from "node:path";
19933
19999
  function canonicalJson3(value, path2 = /* @__PURE__ */ new Set()) {
19934
20000
  if (value === null)
19935
20001
  return "null";
@@ -19990,12 +20056,12 @@ function unreachableConnect2() {
19990
20056
  return new ClaustrumUnreachableError();
19991
20057
  }
19992
20058
  function untilAborted(pending, signal) {
19993
- return new Promise((resolve20, reject) => {
20059
+ return new Promise((resolve21, reject) => {
19994
20060
  const abort = () => reject(signal.reason);
19995
20061
  signal.addEventListener("abort", abort, { once: true });
19996
20062
  pending.then((value) => {
19997
20063
  signal.removeEventListener("abort", abort);
19998
- resolve20(value);
20064
+ resolve21(value);
19999
20065
  }, (error) => {
20000
20066
  signal.removeEventListener("abort", abort);
20001
20067
  reject(error);
@@ -20007,7 +20073,7 @@ function untilAborted(pending, signal) {
20007
20073
  function enabledRows(roster) {
20008
20074
  return JSON.stringify((roster?.rows ?? []).map((row) => [row.credentialId, row.enabled]));
20009
20075
  }
20010
- var FILE_ID, WINDOWS_DEVICE, FINGERPRINT, PENDING_EVERY_TICK, ClaustrumDiscoveryHub;
20076
+ var sharedRosters, FILE_ID, WINDOWS_DEVICE, FINGERPRINT, PENDING_EVERY_TICK, ClaustrumDiscoveryHub;
20011
20077
  var init_hub = __esm({
20012
20078
  "../core/dist/common-auth-embedded/claustrum/hub.js"() {
20013
20079
  "use strict";
@@ -20021,6 +20087,7 @@ var init_hub = __esm({
20021
20087
  init_roster();
20022
20088
  init_shutdown();
20023
20089
  init_watch();
20090
+ sharedRosters = /* @__PURE__ */ new Map();
20024
20091
  FILE_ID = /^[a-z0-9][a-z0-9._-]{0,63}$/;
20025
20092
  WINDOWS_DEVICE = /^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\.|$)/;
20026
20093
  FINGERPRINT = /^[0-9a-f]{16}$/;
@@ -20127,9 +20194,11 @@ var init_hub = __esm({
20127
20194
  watchMode: () => this.watchState(),
20128
20195
  keptReceiptState: () => this.keptReceiptState(),
20129
20196
  retainUnion: () => this.#retainUnion(),
20197
+ publishRoster: (roster) => this.#publishRoster(entry, roster),
20130
20198
  forget: (credentialId) => this.#current?.custody?.forget(credentialId),
20131
20199
  detach: () => {
20132
20200
  entry.closed = true;
20201
+ entry.releaseRoster?.();
20133
20202
  }
20134
20203
  };
20135
20204
  const consumerOptions = {
@@ -20142,14 +20211,51 @@ var init_hub = __esm({
20142
20211
  },
20143
20212
  ...this.#options.mapAccount && { mapAccount: this.#options.mapAccount },
20144
20213
  ...options.onRoster && { onRoster: options.onRoster },
20214
+ ...options.onDiscovery && { onDiscovery: options.onDiscovery },
20145
20215
  ...options.onError && { onError: options.onError },
20146
20216
  logger: options.logger ?? this.#logger,
20147
20217
  ...this.#options.now && { now: this.#options.now }
20148
20218
  };
20149
20219
  const { consumer, hooks } = createHubMember(port, consumerOptions);
20150
20220
  entry.hooks = hooks;
20221
+ const path2 = resolve9(entry.path);
20222
+ const subscribers = sharedRosters.get(path2) ?? /* @__PURE__ */ new Set();
20223
+ const install = (roster) => {
20224
+ if (entry.closed || this.#active !== true || !this.#current || !this.#live(this.#current) || !hooks.roster() || this.#collides(hooks, roster))
20225
+ return;
20226
+ entry.seen = JSON.stringify(decodedVaultRoster(roster));
20227
+ hooks.install(roster);
20228
+ if (roster.view !== this.#committed?.view)
20229
+ entry.pending ??= { failures: 0, wait: 0 };
20230
+ this.#retainUnion();
20231
+ };
20232
+ subscribers.add(install);
20233
+ entry.receiveRoster = install;
20234
+ sharedRosters.set(path2, subscribers);
20235
+ let subscribed = true;
20236
+ entry.releaseRoster = () => {
20237
+ if (!subscribed)
20238
+ return;
20239
+ subscribed = false;
20240
+ subscribers.delete(install);
20241
+ if (!subscribers.size)
20242
+ sharedRosters.delete(path2);
20243
+ };
20151
20244
  return consumer;
20152
20245
  }
20246
+ #publishRoster(entry, roster) {
20247
+ const generation = this.#current;
20248
+ if (entry.closed || !generation || !this.#live(generation))
20249
+ return;
20250
+ entry.seen = JSON.stringify(decodedVaultRoster(roster));
20251
+ entry.hooks?.install(roster);
20252
+ for (const install of sharedRosters.get(resolve9(entry.path)) ?? []) {
20253
+ if (!this.#live(generation))
20254
+ return;
20255
+ if (install !== entry.receiveRoster)
20256
+ install(roster);
20257
+ }
20258
+ }
20153
20259
  // --- leases ---
20154
20260
  #startGeneration() {
20155
20261
  const generation = {
@@ -20445,6 +20551,8 @@ var init_hub = __esm({
20445
20551
  }));
20446
20552
  run.promise = promise;
20447
20553
  this.#run = run;
20554
+ for (const entry of this.#open())
20555
+ entry.hooks?.discovery(promise);
20448
20556
  return promise;
20449
20557
  }
20450
20558
  /**
@@ -20521,9 +20629,7 @@ var init_hub = __esm({
20521
20629
  this.#markPending(entry);
20522
20630
  continue;
20523
20631
  }
20524
- entry.seen = JSON.stringify(decodedVaultRoster(roster));
20525
- if (!entry.closed)
20526
- hooks.install(roster);
20632
+ this.#publishRoster(entry, roster);
20527
20633
  }
20528
20634
  if (!this.#live(generation))
20529
20635
  return void 0;
@@ -20554,7 +20660,24 @@ var init_hub = __esm({
20554
20660
  throw closed("Claustrum hub member has no base view");
20555
20661
  if (base instanceof Error)
20556
20662
  throw base;
20557
- const seed = base.file ? void 0 : await this.#seed(entry);
20663
+ let seed;
20664
+ if (!base.file) {
20665
+ const phaseDiagnostics2 = channel2("common-auth.claustrum.phases");
20666
+ if (phaseDiagnostics2.hasSubscribers)
20667
+ phaseDiagnostics2.publish({
20668
+ logger: this.#logger,
20669
+ phase: `seed read ${entry.provider} begin`
20670
+ });
20671
+ try {
20672
+ seed = await this.#seed(entry);
20673
+ } finally {
20674
+ if (phaseDiagnostics2.hasSubscribers)
20675
+ phaseDiagnostics2.publish({
20676
+ logger: this.#logger,
20677
+ phase: `seed read ${entry.provider} end`
20678
+ });
20679
+ }
20680
+ }
20558
20681
  const roster = await refreshVaultRoster({
20559
20682
  path: entry.path,
20560
20683
  custody: { discover: async () => share },
@@ -20678,7 +20801,7 @@ var init_hub = __esm({
20678
20801
  }
20679
20802
  const before = enabledRows(memory);
20680
20803
  entry.seen = content;
20681
- hooks.install(file);
20804
+ this.#publishRoster(entry, file);
20682
20805
  if (enabledRows(hooks.roster()) !== before)
20683
20806
  this.#retainUnion();
20684
20807
  }
@@ -20835,6 +20958,8 @@ var init_hub = __esm({
20835
20958
  if (this.#shutdown.signal.aborted)
20836
20959
  return;
20837
20960
  this.#shutdown.abort(closed("Claustrum discovery hub is closed"));
20961
+ for (const entry of this.#members.values())
20962
+ entry.releaseRoster?.();
20838
20963
  if (this.#timer)
20839
20964
  (this.#options.clearTimeoutImpl ?? clearTimeout)(this.#timer);
20840
20965
  this.#timer = void 0;
@@ -21169,7 +21294,7 @@ var init_lock = __esm({
21169
21294
  import { createHash as createHash8 } from "node:crypto";
21170
21295
  import { constants as constants2 } from "node:fs";
21171
21296
  import { lstat as lstat5, mkdir as mkdir10, open as open7, unlink as unlink7 } from "node:fs/promises";
21172
- import { dirname as dirname11, resolve as resolve9 } from "node:path";
21297
+ import { dirname as dirname11, resolve as resolve10 } from "node:path";
21173
21298
  import { setTimeout as sleep2 } from "node:timers/promises";
21174
21299
  function rootSpans(text2) {
21175
21300
  let i = text2.indexOf("{") + 1;
@@ -21370,8 +21495,8 @@ function createPiSlot(options, onStep, hooks) {
21370
21495
  if (!provider2 || !options.authPath || !options.stashPath || !placeholderKey || placeholderKey.startsWith("!") || placeholderKey.includes("$") || !Number.isFinite(timeout) || timeout < 0) {
21371
21496
  throw new PiSlotError("invalid-options");
21372
21497
  }
21373
- const authPath = resolve9(options.authPath);
21374
- const stashPath = resolve9(options.stashPath);
21498
+ const authPath = resolve10(options.authPath);
21499
+ const stashPath = resolve10(options.stashPath);
21375
21500
  if (authPath === stashPath || stashPath === `${authPath}.lock`) {
21376
21501
  throw new PiSlotError("invalid-options");
21377
21502
  }
@@ -21639,8 +21764,8 @@ function getDefaultTierId(allowedTiers) {
21639
21764
  return allowedTiers[0]?.id;
21640
21765
  }
21641
21766
  function wait(ms) {
21642
- return new Promise((resolve20) => {
21643
- setTimeout(resolve20, ms);
21767
+ return new Promise((resolve21) => {
21768
+ setTimeout(resolve21, ms);
21644
21769
  });
21645
21770
  }
21646
21771
  function extractManagedProjectId(payload) {
@@ -22662,7 +22787,7 @@ var init_capture_sink2 = __esm({
22662
22787
  import { randomUUID as randomUUID11 } from "node:crypto";
22663
22788
  import { lstat as lstat6, readFile as readFile7, rename as rename8, unlink as unlink8 } from "node:fs/promises";
22664
22789
  import { tmpdir as tmpdir2 } from "node:os";
22665
- import { dirname as dirname13, join as join9, resolve as resolve10 } from "node:path";
22790
+ import { dirname as dirname13, join as join9, resolve as resolve11 } from "node:path";
22666
22791
  function ioCode2(detail) {
22667
22792
  if (detail?.reason === "io-error") {
22668
22793
  if (detail.win32Code === 2 || detail.win32Code === 3)
@@ -22709,7 +22834,7 @@ async function privateOperation2(path2, stage, operation) {
22709
22834
  }
22710
22835
  }
22711
22836
  async function verifySafeDirectory2(path2, options) {
22712
- path2 = resolve10(path2);
22837
+ path2 = resolve11(path2);
22713
22838
  options ??= safeParentOptionsForTest2;
22714
22839
  await privateOperation2(path2, "safe-parent", async () => {
22715
22840
  const result = await (await loadBackend2()).verifySafeParent(path2, options);
@@ -22724,7 +22849,7 @@ async function verifySafeDirectory2(path2, options) {
22724
22849
  });
22725
22850
  }
22726
22851
  async function verifyPrivate2(path2, kind, migrate = false) {
22727
- path2 = resolve10(path2);
22852
+ path2 = resolve11(path2);
22728
22853
  if (kind === "directory")
22729
22854
  return verifySafeDirectory2(path2);
22730
22855
  await privateOperation2(path2, "verify", async () => {
@@ -22759,7 +22884,7 @@ async function verifyPrivate2(path2, kind, migrate = false) {
22759
22884
  });
22760
22885
  }
22761
22886
  async function ensurePrivateDirectory2(path2, _migrate = false, options) {
22762
- path2 = resolve10(path2);
22887
+ path2 = resolve11(path2);
22763
22888
  await privateOperation2(path2, "directory", async () => {
22764
22889
  const api = await loadBackend2();
22765
22890
  try {
@@ -22790,7 +22915,7 @@ async function readPrivateText2(path2, migrate = false) {
22790
22915
  async function readPrivateBuffer2(path2, migrate = false) {
22791
22916
  if (!windowsPrivateFiles2)
22792
22917
  return readFile7(path2);
22793
- path2 = resolve10(path2);
22918
+ path2 = resolve11(path2);
22794
22919
  if (migrate) {
22795
22920
  await verifySafeDirectory2(dirname13(path2));
22796
22921
  await verifyPrivate2(path2, "file", true);
@@ -22798,20 +22923,20 @@ async function readPrivateBuffer2(path2, migrate = false) {
22798
22923
  return privateOperation2(path2, "read", async () => (await loadBackend2()).readOwnerOnly(path2));
22799
22924
  }
22800
22925
  async function createPrivateBytes2(path2, bytes) {
22801
- await verifySafeDirectory2(dirname13(resolve10(path2)));
22926
+ await verifySafeDirectory2(dirname13(resolve11(path2)));
22802
22927
  await privateOperation2(path2, "create", async () => {
22803
- await (await loadBackend2()).createPrivateFile(resolve10(path2), bytes);
22928
+ await (await loadBackend2()).createPrivateFile(resolve11(path2), bytes);
22804
22929
  });
22805
22930
  }
22806
22931
  async function createPrivateDirectoryExclusive2(path2) {
22807
- await verifySafeDirectory2(dirname13(resolve10(path2)));
22932
+ await verifySafeDirectory2(dirname13(resolve11(path2)));
22808
22933
  await privateOperation2(path2, "directory-create", async () => {
22809
- await (await loadBackend2()).createOwnerOnly(resolve10(path2), { kind: "dir" });
22934
+ await (await loadBackend2()).createOwnerOnly(resolve11(path2), { kind: "dir" });
22810
22935
  });
22811
22936
  }
22812
22937
  async function replaceWindowsFile2(from, to, options = {}) {
22813
- from = resolve10(from);
22814
- to = resolve10(to);
22938
+ from = resolve11(from);
22939
+ to = resolve11(to);
22815
22940
  const now = options.now ?? (() => performance.now());
22816
22941
  const start = now();
22817
22942
  const leaseDeadline = options.deadline ?? Infinity;
@@ -22854,7 +22979,7 @@ async function replaceWindowsFile2(from, to, options = {}) {
22854
22979
  throw error;
22855
22980
  }
22856
22981
  async function writePrivateAtomic2(path2, bytes, options = {}) {
22857
- path2 = resolve10(path2);
22982
+ path2 = resolve11(path2);
22858
22983
  await ensurePrivateDirectory2(dirname13(path2));
22859
22984
  try {
22860
22985
  await verifyPrivate2(path2, "file", true);
@@ -22862,7 +22987,7 @@ async function writePrivateAtomic2(path2, bytes, options = {}) {
22862
22987
  if (error.code !== "ENOENT")
22863
22988
  throw error;
22864
22989
  }
22865
- const stage = resolve10(options.stagePath ?? `${path2}.${randomUUID11()}.tmp`);
22990
+ const stage = resolve11(options.stagePath ?? `${path2}.${randomUUID11()}.tmp`);
22866
22991
  if (dirname13(stage) !== dirname13(path2))
22867
22992
  throw new PrivateFileError2(path2, "stage-directory", { code: "EXDEV" });
22868
22993
  let created = false;
@@ -23028,7 +23153,7 @@ var init_redact2 = __esm({
23028
23153
  // src/common-auth-embedded/logger/engine.js
23029
23154
  import { appendFileSync as appendFileSync2, chmodSync as chmodSync2, existsSync as existsSync2, renameSync as renameSync2, statSync as statSync3 } from "node:fs";
23030
23155
  import { open as open8 } from "node:fs/promises";
23031
- import { dirname as dirname14, resolve as resolve11 } from "node:path";
23156
+ import { dirname as dirname14, resolve as resolve12 } from "node:path";
23032
23157
  function chmodPrivate2(path2) {
23033
23158
  try {
23034
23159
  chmodSync2(path2, 384);
@@ -23079,7 +23204,7 @@ async function openWindowsFile2(sink, file) {
23079
23204
  return sink.handle;
23080
23205
  }
23081
23206
  async function flushWindowsFile2(sink, file, text2) {
23082
- file = resolve11(file);
23207
+ file = resolve12(file);
23083
23208
  try {
23084
23209
  if (sink.file !== file)
23085
23210
  await closeWindowsFile2(sink);
@@ -23226,7 +23351,7 @@ function createEngine2(options) {
23226
23351
  });
23227
23352
  }, 500);
23228
23353
  }
23229
- function emit(channel, level, message, data) {
23354
+ function emit(channel3, level, message, data) {
23230
23355
  if (logFileSource === void 0 && captureSink === void 0)
23231
23356
  return;
23232
23357
  try {
@@ -23239,10 +23364,10 @@ function createEngine2(options) {
23239
23364
  } catch {
23240
23365
  scrubbedData = "[unserializable]";
23241
23366
  }
23242
- const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${level.toUpperCase()} [${channel}] ${scrubbedMessage}` + (data === void 0 ? "" : safeSerialize2(scrubbedData)) + "\n";
23367
+ const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${level.toUpperCase()} [${channel3}] ${scrubbedMessage}` + (data === void 0 ? "" : safeSerialize2(scrubbedData)) + "\n";
23243
23368
  try {
23244
23369
  captureSink?.({
23245
- channel,
23370
+ channel: channel3,
23246
23371
  level,
23247
23372
  message: scrubbedMessage,
23248
23373
  data: scrubbedData
@@ -23262,13 +23387,13 @@ function createEngine2(options) {
23262
23387
  } catch {
23263
23388
  }
23264
23389
  }
23265
- function createLogger5(channel) {
23390
+ function createLogger5(channel3) {
23266
23391
  return {
23267
- error: (m, d) => emit(channel, "error", m, d),
23268
- warn: (m, d) => emit(channel, "warn", m, d),
23269
- info: (m, d) => emit(channel, "info", m, d),
23270
- debug: (m, d) => emit(channel, "debug", m, d),
23271
- trace: (m, d) => emit(channel, "trace", m, d)
23392
+ error: (m, d) => emit(channel3, "error", m, d),
23393
+ warn: (m, d) => emit(channel3, "warn", m, d),
23394
+ info: (m, d) => emit(channel3, "info", m, d),
23395
+ debug: (m, d) => emit(channel3, "debug", m, d),
23396
+ trace: (m, d) => emit(channel3, "trace", m, d)
23272
23397
  };
23273
23398
  }
23274
23399
  function reset() {
@@ -23396,7 +23521,7 @@ import { randomUUID as randomUUID12 } from "node:crypto";
23396
23521
  import { realpathSync, rmSync } from "node:fs";
23397
23522
  import { chmod as chmod3, mkdir as mkdir11, readFile as readFile8, rename as rename9, rm as rm5, writeFile as writeFile3 } from "node:fs/promises";
23398
23523
  import { homedir as homedir2 } from "node:os";
23399
- import { join as join10, resolve as resolve12 } from "node:path";
23524
+ import { join as join10, resolve as resolve13 } from "node:path";
23400
23525
  function processHeartbeatDir() {
23401
23526
  const base = process.env.XDG_STATE_HOME || join10(homedir2(), ".local", "state");
23402
23527
  return join10(base, "cortexkit", "antigravity-auth", "processes");
@@ -23409,7 +23534,7 @@ function processConfigFolderKey() {
23409
23534
  try {
23410
23535
  return realpathSync.native(folder);
23411
23536
  } catch {
23412
- return resolve12(folder);
23537
+ return resolve13(folder);
23413
23538
  }
23414
23539
  }
23415
23540
  function processHasOlderGeneration() {
@@ -23855,7 +23980,7 @@ import {
23855
23980
  stat as stat8,
23856
23981
  unlink as unlink9
23857
23982
  } from "node:fs/promises";
23858
- import { basename as basename4, dirname as dirname15, join as join12, resolve as resolve13 } from "node:path";
23983
+ import { basename as basename4, dirname as dirname15, join as join12, resolve as resolve14 } from "node:path";
23859
23984
  function refusalMessage(stateDir, errorClass2) {
23860
23985
  if (errorClass2 === "ERR_PRIVATE_FILES_SECURITY")
23861
23986
  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.`;
@@ -24710,7 +24835,7 @@ async function isVaultShapedKeptState(files) {
24710
24835
  async function removeMovedVaultStateLeftover(vaultDir, accountFile) {
24711
24836
  const location = runtimeLayoutLocation();
24712
24837
  const files = layoutFiles(location, accountFile);
24713
- if (resolve13(vaultDir) !== resolve13(files.vault.next)) return;
24838
+ if (resolve14(vaultDir) !== resolve14(files.vault.next)) return;
24714
24839
  const stateDir = location.stateHomeDir;
24715
24840
  const marker = await readMarker(
24716
24841
  join12(stateDir, RUNTIME_LAYOUT_MARKER_FILE),
@@ -25138,7 +25263,7 @@ import {
25138
25263
  writeFileSync
25139
25264
  } from "node:fs";
25140
25265
  import { homedir as homedir4 } from "node:os";
25141
- import { dirname as dirname16, join as join13, resolve as resolve14 } from "node:path";
25266
+ import { dirname as dirname16, join as join13, resolve as resolve15 } from "node:path";
25142
25267
  async function ensureGitignore(configDir) {
25143
25268
  const gitignorePath = join13(configDir, ".gitignore");
25144
25269
  try {
@@ -25238,8 +25363,8 @@ function migrateLegacyWindowsConfig() {
25238
25363
  }
25239
25364
  }
25240
25365
  function resolveWindowsAccountAnchor(newPath, legacyPath) {
25241
- const standard = resolve14(newPath);
25242
- const legacy = resolve14(legacyPath);
25366
+ const standard = resolve15(newPath);
25367
+ const legacy = resolve15(legacyPath);
25243
25368
  if (standard.toLowerCase() === legacy.toLowerCase()) return newPath;
25244
25369
  const standardPointer = existsSync3(accountStorePointerPath(standard));
25245
25370
  const legacyPointer = existsSync3(accountStorePointerPath(legacy));
@@ -25261,7 +25386,7 @@ function getStoragePathWithMigration() {
25261
25386
  "antigravity-accounts.json"
25262
25387
  );
25263
25388
  const anchored = resolveWindowsAccountAnchor(newPath, legacyPath);
25264
- if (resolve14(anchored).toLowerCase() !== resolve14(newPath).toLowerCase() && !existsSync3(accountStorePointerPath(resolve14(anchored)))) {
25389
+ if (resolve15(anchored).toLowerCase() !== resolve15(newPath).toLowerCase() && !existsSync3(accountStorePointerPath(resolve15(anchored)))) {
25265
25390
  log5.info("Using legacy Windows config path (migration failed)", {
25266
25391
  legacyPath,
25267
25392
  newPath
@@ -25278,7 +25403,7 @@ function accountFileForVault(configDir = getConfigDir()) {
25278
25403
  const configured = join13(configDir, "antigravity-accounts.json");
25279
25404
  if (process.platform !== "win32") return configured;
25280
25405
  const legacyDir = getLegacyWindowsConfigDir();
25281
- if (resolve14(configDir).toLowerCase() === resolve14(legacyDir).toLowerCase())
25406
+ if (resolve15(configDir).toLowerCase() === resolve15(legacyDir).toLowerCase())
25282
25407
  return configured;
25283
25408
  const configuredVault = join13(configDir, "antigravity-auth-vault");
25284
25409
  const legacyVault = join13(legacyDir, "antigravity-auth-vault");
@@ -25309,7 +25434,7 @@ function getStoragePath() {
25309
25434
  }
25310
25435
  async function assertLegacyPoolInUse(legacyPath) {
25311
25436
  try {
25312
- await assertLegacyAccountStorageWritable(resolve14(legacyPath));
25437
+ await assertLegacyAccountStorageWritable(resolve15(legacyPath));
25313
25438
  } catch (error) {
25314
25439
  throw new LegacyAccountPoolRetiredError(legacyPath, { cause: error });
25315
25440
  }
@@ -25327,7 +25452,7 @@ function refusalMessage2(admission) {
25327
25452
  async function bindingOf(options) {
25328
25453
  if (options.legacyPath === void 0) await prepareLocalAccountStore();
25329
25454
  const now = options.now ?? (() => Date.now());
25330
- const legacyPath = resolve14(options.legacyPath ?? getStoragePath());
25455
+ const legacyPath = resolve15(options.legacyPath ?? getStoragePath());
25331
25456
  return {
25332
25457
  legacyPath,
25333
25458
  now,
@@ -25396,7 +25521,7 @@ async function openAccountStore(options) {
25396
25521
  async function initializeFreshAccountStoreFor(modules, options = {}) {
25397
25522
  if (options.legacyPath === void 0) await prepareLocalAccountStore();
25398
25523
  return initializeFreshAccountStore(modules, {
25399
- legacyPath: resolve14(options.legacyPath ?? getStoragePath()),
25524
+ legacyPath: resolve15(options.legacyPath ?? getStoragePath()),
25400
25525
  now: options.now ?? (() => Date.now())
25401
25526
  });
25402
25527
  }
@@ -25442,12 +25567,12 @@ var init_storage = __esm({
25442
25567
  import { createHash as createHash11 } from "node:crypto";
25443
25568
  import { existsSync as existsSync4, promises as fs2, readFileSync as readFileSync2, realpathSync as realpathSync2 } from "node:fs";
25444
25569
  import { homedir as homedir5 } from "node:os";
25445
- import { dirname as dirname17, join as join14, resolve as resolve15 } from "node:path";
25570
+ import { dirname as dirname17, join as join14, resolve as resolve16 } from "node:path";
25446
25571
  function configDirIdentity(path2) {
25447
25572
  try {
25448
25573
  return realpathSync2.native(path2);
25449
25574
  } catch {
25450
- return resolve15(path2);
25575
+ return resolve16(path2);
25451
25576
  }
25452
25577
  }
25453
25578
  function decisionKey(location) {
@@ -26109,13 +26234,13 @@ function closeDebugLog() {
26109
26234
  if (!state || !current) return Promise.resolve();
26110
26235
  state.logStream = null;
26111
26236
  if (state.logFilePath) liveLogFilePaths.delete(state.logFilePath);
26112
- return new Promise((resolve20) => {
26113
- current.once("close", () => resolve20());
26114
- current.once("error", () => resolve20());
26237
+ return new Promise((resolve21) => {
26238
+ current.once("close", () => resolve21());
26239
+ current.once("error", () => resolve21());
26115
26240
  try {
26116
26241
  current.end();
26117
26242
  } catch {
26118
- resolve20();
26243
+ resolve21();
26119
26244
  }
26120
26245
  });
26121
26246
  }
@@ -26173,10 +26298,10 @@ function createLocationLogger(options) {
26173
26298
  const engine = createLoggerInstance2({
26174
26299
  level: () => configuredLevel,
26175
26300
  extraSecretKeys: isProviderSecretKey,
26176
- captureSink: ({ channel, level, message, data }) => {
26301
+ captureSink: ({ channel: channel3, level, message, data }) => {
26177
26302
  const extra = data !== null && typeof data === "object" && !Array.isArray(data) ? Object.fromEntries(Object.entries(data)) : void 0;
26178
26303
  emit({
26179
- service: channel,
26304
+ service: channel3,
26180
26305
  level: level === "trace" ? "debug" : level,
26181
26306
  message,
26182
26307
  extra
@@ -26185,12 +26310,12 @@ function createLocationLogger(options) {
26185
26310
  });
26186
26311
  return {
26187
26312
  createLogger(module) {
26188
- const channel = engine.createLogger(`antigravity.${module}`);
26313
+ const channel3 = engine.createLogger(`antigravity.${module}`);
26189
26314
  return {
26190
- debug: (message, extra) => channel.debug(message, extra),
26191
- info: (message, extra) => channel.info(message, extra),
26192
- warn: (message, extra) => channel.warn(message, extra),
26193
- error: (message, extra) => channel.error(message, extra)
26315
+ debug: (message, extra) => channel3.debug(message, extra),
26316
+ info: (message, extra) => channel3.info(message, extra),
26317
+ warn: (message, extra) => channel3.warn(message, extra),
26318
+ error: (message, extra) => channel3.error(message, extra)
26194
26319
  };
26195
26320
  },
26196
26321
  setLevel(level) {
@@ -26224,10 +26349,10 @@ function getLegacyLogger() {
26224
26349
  return legacyLogger;
26225
26350
  }
26226
26351
  function createLogger4(module) {
26227
- let channel;
26352
+ let channel3;
26228
26353
  const log8 = (level, message, extra) => {
26229
- channel ??= getLegacyLogger().createLogger(module);
26230
- channel[level](message, extra);
26354
+ channel3 ??= getLegacyLogger().createLogger(module);
26355
+ channel3[level](message, extra);
26231
26356
  };
26232
26357
  return {
26233
26358
  debug: (message, extra) => log8("debug", message, extra),
@@ -26261,7 +26386,7 @@ var init_logger4 = __esm({
26261
26386
  init_dist();
26262
26387
  import { execFile } from "node:child_process";
26263
26388
  import { realpathSync as realpathSync4 } from "node:fs";
26264
- import { resolve as resolve19 } from "node:path";
26389
+ import { resolve as resolve20 } from "node:path";
26265
26390
  import { createInterface } from "node:readline/promises";
26266
26391
  import { fileURLToPath as fileURLToPath2 } from "node:url";
26267
26392
  import { promisify } from "node:util";
@@ -26669,14 +26794,14 @@ async function fetchQuotaPayloads(options) {
26669
26794
  };
26670
26795
  }
26671
26796
  function untilQuotaAborted(pending, signal) {
26672
- return new Promise((resolve20, reject) => {
26797
+ return new Promise((resolve21, reject) => {
26673
26798
  const abort = () => reject(signal.reason);
26674
26799
  if (signal.aborted) abort();
26675
26800
  else signal.addEventListener("abort", abort, { once: true });
26676
26801
  void pending.then(
26677
26802
  (value) => {
26678
26803
  signal.removeEventListener("abort", abort);
26679
- resolve20(value);
26804
+ resolve21(value);
26680
26805
  },
26681
26806
  (error) => {
26682
26807
  signal.removeEventListener("abort", abort);
@@ -26958,12 +27083,12 @@ async function startOAuthListener({
26958
27083
  let resolveCallback;
26959
27084
  let rejectCallback;
26960
27085
  let timeoutHandle;
26961
- const callbackPromise = new Promise((resolve20, reject) => {
27086
+ const callbackPromise = new Promise((resolve21, reject) => {
26962
27087
  resolveCallback = (url) => {
26963
27088
  if (settled) return;
26964
27089
  settled = true;
26965
27090
  if (timeoutHandle) clearTimeout(timeoutHandle);
26966
- resolve20(url);
27091
+ resolve21(url);
26967
27092
  };
26968
27093
  rejectCallback = (error) => {
26969
27094
  if (settled) return;
@@ -27122,7 +27247,7 @@ async function startOAuthListener({
27122
27247
  });
27123
27248
  });
27124
27249
  const bindAddress = getBindAddress();
27125
- await new Promise((resolve20, reject) => {
27250
+ await new Promise((resolve21, reject) => {
27126
27251
  const handleError = (error) => {
27127
27252
  server.off("error", handleError);
27128
27253
  if (error.code === "EADDRINUSE") {
@@ -27138,7 +27263,7 @@ async function startOAuthListener({
27138
27263
  server.once("error", handleError);
27139
27264
  server.listen(port, bindAddress, () => {
27140
27265
  server.off("error", handleError);
27141
- resolve20();
27266
+ resolve21();
27142
27267
  });
27143
27268
  });
27144
27269
  server.on("error", (error) => {
@@ -27146,7 +27271,7 @@ async function startOAuthListener({
27146
27271
  });
27147
27272
  return {
27148
27273
  waitForCallback: () => callbackPromise,
27149
- close: () => new Promise((resolve20, reject) => {
27274
+ close: () => new Promise((resolve21, reject) => {
27150
27275
  server.close((error) => {
27151
27276
  if (error && error.code !== "ERR_SERVER_NOT_RUNNING") {
27152
27277
  reject(error);
@@ -27155,7 +27280,7 @@ async function startOAuthListener({
27155
27280
  if (!settled) {
27156
27281
  rejectCallback(new Error("OAuth listener closed before callback"));
27157
27282
  }
27158
- resolve20();
27283
+ resolve21();
27159
27284
  });
27160
27285
  })
27161
27286
  };
@@ -27174,7 +27299,7 @@ init_runtime_paths();
27174
27299
  // src/setup.ts
27175
27300
  init_dist();
27176
27301
  import { lstat as lstat9, readFile as readFile13 } from "node:fs/promises";
27177
- import { join as join21, resolve as resolve18 } from "node:path";
27302
+ import { join as join21, resolve as resolve19 } from "node:path";
27178
27303
 
27179
27304
  // src/auth-method-labels.ts
27180
27305
  var OPENCODE2_POOL_AUTH_LABEL = "Google (antigravity-auth pool, browser)";
@@ -27346,7 +27471,7 @@ async function select2(terminal, items, options) {
27346
27471
  writeLine("");
27347
27472
  renderedLines = lines;
27348
27473
  };
27349
- return new Promise((resolve20) => {
27474
+ return new Promise((resolve21) => {
27350
27475
  const wasRaw = stdin.isRaw ?? false;
27351
27476
  const cleanup2 = () => {
27352
27477
  if (cleaned)
@@ -27366,7 +27491,7 @@ async function select2(terminal, items, options) {
27366
27491
  };
27367
27492
  const finish = (value) => {
27368
27493
  cleanup2();
27369
- resolve20(value);
27494
+ resolve21(value);
27370
27495
  };
27371
27496
  const onSignal = () => finish(null);
27372
27497
  const onKey = (data) => {
@@ -27406,7 +27531,7 @@ async function select2(terminal, items, options) {
27406
27531
  stdin.setRawMode(true);
27407
27532
  } catch {
27408
27533
  cleanup2();
27409
- resolve20(null);
27534
+ resolve21(null);
27410
27535
  return;
27411
27536
  }
27412
27537
  stdin.resume();
@@ -27420,12 +27545,12 @@ async function select2(terminal, items, options) {
27420
27545
  import { createHash as createHash12, randomBytes as randomBytes3, randomUUID as randomUUID15 } from "node:crypto";
27421
27546
  import { constants as fsConstants2 } from "node:fs";
27422
27547
  import { chmod as chmod5, mkdir as mkdir14, open as open10, readFile as readFile12, realpath as realpath4, rename as rename12, stat as stat10, unlink as unlink10 } from "node:fs/promises";
27423
- import { basename as basename5, dirname as dirname19, extname as extname2, isAbsolute as isAbsolute3, join as join17, resolve as resolve17 } from "node:path";
27548
+ import { basename as basename5, dirname as dirname19, extname as extname2, isAbsolute as isAbsolute3, join as join17, resolve as resolve18 } from "node:path";
27424
27549
  import { ClaustrumCredentialError as ClaustrumCredentialError5, ClaustrumClient as ClaustrumWireClient2, writeEnrollmentTokenFile as writeEnrollmentTokenFile2 } from "@cortexkit/claustrum-client";
27425
27550
 
27426
27551
  // src/common-auth-embedded/fs/file-read-cache.js
27427
27552
  import { lstat as lstat7 } from "node:fs/promises";
27428
- import { resolve as resolve16 } from "node:path";
27553
+ import { resolve as resolve17 } from "node:path";
27429
27554
  async function identity2(path2) {
27430
27555
  try {
27431
27556
  const metadata = await lstat7(path2);
@@ -27442,7 +27567,7 @@ function sameIdentity2(left, right) {
27442
27567
  var FileReadCache2 = class {
27443
27568
  #entries = /* @__PURE__ */ new Map();
27444
27569
  async read(paths, read, validateHit) {
27445
- const resolvedPaths = paths.map((path2) => resolve16(path2));
27570
+ const resolvedPaths = paths.map((path2) => resolve17(path2));
27446
27571
  const key = JSON.stringify(resolvedPaths);
27447
27572
  const probed = await Promise.all(resolvedPaths.map(identity2));
27448
27573
  const identities = probed.every((entry) => entry !== void 0) ? probed : void 0;
@@ -27562,8 +27687,8 @@ async function acquireRefreshFileLockWithClock2(options) {
27562
27687
  let releaseConfirmed = false;
27563
27688
  let loss;
27564
27689
  let resolveLoss;
27565
- const lostPromise = new Promise((resolve20) => {
27566
- resolveLoss = resolve20;
27690
+ const lostPromise = new Promise((resolve21) => {
27691
+ resolveLoss = resolve21;
27567
27692
  });
27568
27693
  function notifyTimerStep(event) {
27569
27694
  try {
@@ -27724,7 +27849,7 @@ async function acquireRefreshFileLockWithClock2(options) {
27724
27849
  }
27725
27850
  }
27726
27851
  async function backoff() {
27727
- await new Promise((resolve20) => setTimeout(resolve20, Math.floor(Math.random() * 4)));
27852
+ await new Promise((resolve21) => setTimeout(resolve21, Math.floor(Math.random() * 4)));
27728
27853
  }
27729
27854
  async function readLockState(notifyReady = true) {
27730
27855
  if (notifyReady && options.onStep)
@@ -28162,7 +28287,7 @@ async function acquireRefreshFileLockWithClock2(options) {
28162
28287
  ...typeof observed?.expiresAt === "number" ? { observedExpiresAt: observed.expiresAt } : {}
28163
28288
  });
28164
28289
  },
28165
- release: async () => {
28290
+ release: async (signal) => {
28166
28291
  if (windowsPrivateFiles2 && releaseConfirmed)
28167
28292
  return;
28168
28293
  released = true;
@@ -28203,6 +28328,8 @@ async function acquireRefreshFileLockWithClock2(options) {
28203
28328
  releaseConfirmed = removalConfirmed;
28204
28329
  return;
28205
28330
  }
28331
+ if (signal?.aborted)
28332
+ return;
28206
28333
  await recoverStaleEvictionMarker();
28207
28334
  } catch (error) {
28208
28335
  if (windowsPrivateFiles2)
@@ -28212,7 +28339,7 @@ async function acquireRefreshFileLockWithClock2(options) {
28212
28339
  const remainingMs = deadline - performance.now();
28213
28340
  if (remainingMs <= 0)
28214
28341
  break;
28215
- await new Promise((resolve20) => setTimeout(resolve20, Math.min(delayMs, remainingMs)));
28342
+ await new Promise((resolve21) => setTimeout(resolve21, Math.min(delayMs, remainingMs)));
28216
28343
  delayMs = Math.min(delayMs * 2, 50);
28217
28344
  }
28218
28345
  if (windowsPrivateFiles2)
@@ -28285,7 +28412,7 @@ function hostEnrollmentPaths2(input) {
28285
28412
  const override = input.override?.trim();
28286
28413
  if (override && !isAbsolute3(override) && !input.cwd)
28287
28414
  throw new ClaustrumConsumerError2("invalid-state", "A relative Claustrum enrollment override needs a base directory");
28288
- const tokenPath = override ? isAbsolute3(override) ? override : resolve17(input.cwd, override) : join17(input.stateDir, `${input.host}-enrollment.json`);
28415
+ const tokenPath = override ? isAbsolute3(override) ? override : resolve18(input.cwd, override) : join17(input.stateDir, `${input.host}-enrollment.json`);
28289
28416
  return getClaustrumEnrollmentPaths2(tokenPath);
28290
28417
  }
28291
28418
  function isRecord10(value) {
@@ -28913,7 +29040,7 @@ var ByteTail = class {
28913
29040
  };
28914
29041
  var defaultCommandRunner = {
28915
29042
  run(file, args, options = {}) {
28916
- return new Promise((resolve20) => {
29043
+ return new Promise((resolve21) => {
28917
29044
  const started = performance.now();
28918
29045
  const timeoutMs = options.timeoutMs ?? 15e3;
28919
29046
  const stderr = new ByteTail();
@@ -28931,7 +29058,7 @@ var defaultCommandRunner = {
28931
29058
  stdio: ["ignore", "pipe", "pipe"]
28932
29059
  });
28933
29060
  } catch {
28934
- resolve20({
29061
+ resolve21({
28935
29062
  exitCode: 1,
28936
29063
  stdout: "",
28937
29064
  stderr: "",
@@ -28966,7 +29093,7 @@ var defaultCommandRunner = {
28966
29093
  settled = true;
28967
29094
  if (timer)
28968
29095
  clearTimeout(timer);
28969
- resolve20({
29096
+ resolve21({
28970
29097
  exitCode: spawnError ? 1 : outputExceeded ? 1 : code2 ?? 1,
28971
29098
  stdout: Buffer.concat(stdout, stdoutLength).toString("utf8"),
28972
29099
  stderr: stderr.toString(),
@@ -30384,7 +30511,7 @@ async function writeNativeSlot(host, slot, context, expectedAuthority = "local")
30384
30511
  beforeRename: async () => {
30385
30512
  await assertSetupHostsStopped();
30386
30513
  const claustrum = await loadCommonAuthClaustrum();
30387
- const stateDir = host === "opencode" ? openCodeVaultDir(resolve18(accountFileForVault())) : getPiAntigravityVaultDir();
30514
+ const stateDir = host === "opencode" ? openCodeVaultDir(resolve19(accountFileForVault())) : getPiAntigravityVaultDir();
30388
30515
  if (await claustrum.enrollmentAuthority(
30389
30516
  claustrum.hostEnrollmentPaths({ stateDir, host }),
30390
30517
  `antigravity-auth-${host}`
@@ -30422,7 +30549,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
30422
30549
  // `beforeSignIn`, which may move it after this plugin is built.
30423
30550
  paths: {
30424
30551
  get stateDir() {
30425
- return openCodeVaultDir(resolve18(accountFileForVault()));
30552
+ return openCodeVaultDir(resolve19(accountFileForVault()));
30426
30553
  },
30427
30554
  host: "opencode"
30428
30555
  }
@@ -30439,7 +30566,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
30439
30566
  const assertLocal = async (host, context) => {
30440
30567
  if (host === "opencode")
30441
30568
  return assertLocalOpenCodeLogin(
30442
- resolve18(accountFileForVault()),
30569
+ resolve19(accountFileForVault()),
30443
30570
  context.opencodeGeneration
30444
30571
  );
30445
30572
  if (await authority(host) !== "local")
@@ -31069,7 +31196,7 @@ async function runCliProcess(argv, deps) {
31069
31196
  ...deps,
31070
31197
  prepareVaultFolder: deps.prepareVaultFolder ?? (async (options) => {
31071
31198
  const folder = await prepareVaultFolder({
31072
- accountFile: resolve19(accountFileForVault()),
31199
+ accountFile: resolve20(accountFileForVault()),
31073
31200
  ...options
31074
31201
  });
31075
31202
  if (folder.refusal) throw folder.refusal;
@@ -31115,11 +31242,11 @@ function createDefaultCliDependencies() {
31115
31242
  );
31116
31243
  if (host !== "pi")
31117
31244
  await assertLocalOpenCodeLogin(
31118
- resolve19(accountFileForVault()),
31245
+ resolve20(accountFileForVault()),
31119
31246
  context?.opencodeGeneration
31120
31247
  );
31121
31248
  const repository = host === "pi" ? void 0 : await prepareCliLoginStore(
31122
- resolve19(getStoragePath()),
31249
+ resolve20(getStoragePath()),
31123
31250
  context?.opencodeGeneration
31124
31251
  );
31125
31252
  try {
@@ -31135,7 +31262,7 @@ function createDefaultCliDependencies() {
31135
31262
  }
31136
31263
  if (host === "opencode") await assertSetupHostsStopped();
31137
31264
  await assertLocalOpenCodeLogin(
31138
- resolve19(accountFileForVault()),
31265
+ resolve20(accountFileForVault()),
31139
31266
  context?.opencodeGeneration
31140
31267
  );
31141
31268
  await persistCliStoreLogin(
@@ -31155,7 +31282,7 @@ function createDefaultCliDependencies() {
31155
31282
  };
31156
31283
  }
31157
31284
  async function prepareCliLoginStore(legacyPath, generation) {
31158
- await assertLocalOpenCodeLogin(resolve19(accountFileForVault()), generation);
31285
+ await assertLocalOpenCodeLogin(resolve20(accountFileForVault()), generation);
31159
31286
  const modules = await loadCommonAuthStoreModules();
31160
31287
  const options = {
31161
31288
  legacyPath,
@@ -31280,7 +31407,7 @@ async function readAccountStore(legacyPath) {
31280
31407
  function createDefaultAccountStoreOperations() {
31281
31408
  const offline = { processesStopped: true };
31282
31409
  return {
31283
- legacyPath: () => resolve19(
31410
+ legacyPath: () => resolve20(
31284
31411
  decidedAccountStoreAnchor(runtimeLayoutLocation()) ? getStoragePath() : discoveredAccountFile()
31285
31412
  ),
31286
31413
  migrate: async (legacyPath) => createAccountMigrationFactory(await loadCommonAuthStoreModules())({
@@ -31311,7 +31438,7 @@ function createDefaultAccountStoreOperations() {
31311
31438
  };
31312
31439
  }
31313
31440
  function samePath(left, right) {
31314
- return process.platform === "win32" ? resolve19(left).toLowerCase() === resolve19(right).toLowerCase() : resolve19(left) === resolve19(right);
31441
+ return process.platform === "win32" ? resolve20(left).toLowerCase() === resolve20(right).toLowerCase() : resolve20(left) === resolve20(right);
31315
31442
  }
31316
31443
  function isCliEntry() {
31317
31444
  if (import.meta.main !== void 0) return import.meta.main;