@cortexkit/opencode-antigravity-auth 3.0.18 → 3.0.20

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 (82) hide show
  1. package/README.md +3 -1
  2. package/dist/cli.js +202 -118
  3. package/dist/cli.js.map +3 -3
  4. package/dist/cli.meta.json +18 -18
  5. package/dist/index.js +263 -179
  6. package/dist/index.js.map +3 -3
  7. package/dist/index.meta.json +25 -25
  8. package/dist/server.js +276 -192
  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 +20 -6
  15. package/dist/src/common-auth-embedded/claustrum/hub.d.ts +3 -1
  16. package/dist/src/common-auth-embedded/claustrum/hub.js +55 -5
  17. package/dist/src/common-auth-embedded/claustrum/roster.js +1 -1
  18. package/dist/src/common-auth-embedded/fs/refresh-file-lock.d.ts +2 -1
  19. package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +3 -1
  20. package/dist/src/common-auth-embedded/fs/with-lock.js +1 -1
  21. package/dist/src/common-auth-embedded/opencode2/index.d.ts +1 -1
  22. package/dist/src/common-auth-embedded/opencode2/install.d.ts +4 -3
  23. package/dist/src/common-auth-embedded/opencode2/install.js +144 -17
  24. package/dist/src/common-auth-embedded/opencode2/types.d.ts +52 -1
  25. package/dist/src/common-auth-embedded/source-output.json +48 -48
  26. package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
  27. package/dist/src/ga/tui/host-ga.js +0 -1
  28. package/dist/src/ga/tui/host-ga.js.map +1 -1
  29. package/dist/src/plugin/__fixtures__/verified-store.js +2 -2
  30. package/dist/src/plugin/config/schema.js +4 -4
  31. package/dist/src/plugin/config/schema.js.map +1 -1
  32. package/dist/src/plugin/config/writer.d.ts +4 -5
  33. package/dist/src/plugin/config/writer.d.ts.map +1 -1
  34. package/dist/src/plugin/config/writer.js +4 -5
  35. package/dist/src/plugin/config/writer.js.map +1 -1
  36. package/dist/src/plugin/errors.js +1 -1
  37. package/dist/src/plugin/request-helpers.js +2 -2
  38. package/dist/src/plugin/request-helpers.js.map +1 -1
  39. package/dist/src/server.d.ts +4 -4
  40. package/dist/src/server.js +4 -4
  41. package/dist/src/tui/sidebar-frame.d.ts +3 -4
  42. package/dist/src/tui/sidebar-frame.d.ts.map +1 -1
  43. package/dist/src/tui/sidebar-frame.js +4 -8
  44. package/dist/src/tui/sidebar-frame.js.map +1 -1
  45. package/dist/src/tui.js +1 -1
  46. package/dist/tui-build-map.json +9 -9
  47. package/dist/tui-ga-build-map.json +9 -9
  48. package/dist/types/src/common-auth-embedded/claustrum/consumer.d.ts +10 -0
  49. package/dist/types/src/common-auth-embedded/claustrum/custody.d.ts +6 -2
  50. package/dist/types/src/common-auth-embedded/claustrum/hub.d.ts +3 -1
  51. package/dist/types/src/common-auth-embedded/fs/refresh-file-lock.d.ts +2 -1
  52. package/dist/types/src/common-auth-embedded/opencode2/index.d.ts +1 -1
  53. package/dist/types/src/common-auth-embedded/opencode2/install.d.ts +4 -3
  54. package/dist/types/src/common-auth-embedded/opencode2/types.d.ts +52 -1
  55. package/dist/types/src/plugin/config/writer.d.ts +4 -5
  56. package/dist/types/src/plugin/config/writer.d.ts.map +1 -1
  57. package/dist/types/src/server.d.ts +4 -4
  58. package/package.json +3 -3
  59. package/src/common-auth-embedded/claustrum/consumer.d.ts +10 -0
  60. package/src/common-auth-embedded/claustrum/consumer.js +25 -0
  61. package/src/common-auth-embedded/claustrum/custody.d.ts +6 -2
  62. package/src/common-auth-embedded/claustrum/custody.js +20 -6
  63. package/src/common-auth-embedded/claustrum/hub.d.ts +3 -1
  64. package/src/common-auth-embedded/claustrum/hub.js +55 -5
  65. package/src/common-auth-embedded/claustrum/roster.js +1 -1
  66. package/src/common-auth-embedded/fs/refresh-file-lock.d.ts +2 -1
  67. package/src/common-auth-embedded/fs/refresh-file-lock.js +3 -1
  68. package/src/common-auth-embedded/fs/with-lock.js +1 -1
  69. package/src/common-auth-embedded/opencode2/index.d.ts +1 -1
  70. package/src/common-auth-embedded/opencode2/install.d.ts +4 -3
  71. package/src/common-auth-embedded/opencode2/install.js +144 -17
  72. package/src/common-auth-embedded/opencode2/types.d.ts +52 -1
  73. package/src/common-auth-embedded/source-output.json +48 -48
  74. package/src/tui-compiled/tui/sidebar-frame.js +35 -72
  75. package/src/tui-compiled/tui.js +1 -1
  76. package/src/tui-ga-compiled/host-ga.js +0 -1
  77. package/src/tui-ga-compiled/shared/ced204104a639c9c-sidebar-frame.js +35 -72
  78. package/src/tui-ga-raw/host-ga.tsx +0 -1
  79. package/src/tui-ga-raw/shared/ced204104a639c9c-sidebar-frame.tsx +7 -29
  80. package/src/tui-raw/tui/sidebar-frame.tsx +7 -29
  81. package/src/tui-raw/tui.tsx +1 -1
  82. package/src/tui.tsx +1 -1
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) {
@@ -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();
@@ -17625,10 +17627,10 @@ async function drainShutdown(pending, onTimeout) {
17625
17627
  try {
17626
17628
  await Promise.race([
17627
17629
  drained,
17628
- new Promise((resolve20) => {
17630
+ new Promise((resolve21) => {
17629
17631
  timer = setTimeout(() => {
17630
17632
  expired = true;
17631
- resolve20();
17633
+ resolve21();
17632
17634
  }, 2e3);
17633
17635
  })
17634
17636
  ]);
@@ -17702,15 +17704,27 @@ function credentialTypeOf(row, family) {
17702
17704
  return notMine;
17703
17705
  if (!row.categories.includes(family.category))
17704
17706
  return notMine;
17705
- if (row.credentialType !== "oauth" && row.credentialType !== "api_key")
17706
- return notMine;
17707
17707
  if ("classify" in family) {
17708
+ const metadata = rowFactsOf(row);
17709
+ let type;
17710
+ switch (metadata.authMethod) {
17711
+ case "apikey":
17712
+ type = "api_key";
17713
+ break;
17714
+ case "chatgpt":
17715
+ case "antigravity":
17716
+ case "oauth":
17717
+ type = "oauth";
17718
+ break;
17719
+ default:
17720
+ return { kind: "refused", code: "unknown-auth-method" };
17721
+ }
17708
17722
  const facts = {
17709
17723
  credentialId: row.id,
17710
- credentialType: row.credentialType,
17724
+ credentialType: type,
17711
17725
  categories: row.categories,
17712
17726
  refreshAdapter: row.refreshAdapter,
17713
- ...rowFactsOf(row)
17727
+ ...metadata
17714
17728
  };
17715
17729
  if (facts.providerIds === void 0)
17716
17730
  return { kind: "refused", code: "unmapped" };
@@ -17719,13 +17733,15 @@ function credentialTypeOf(row, family) {
17719
17733
  if (result.kind === "not-mine")
17720
17734
  return notMine;
17721
17735
  if (result.kind === "mine" && typeof result.member === "string")
17722
- return { kind: "mine", type: row.credentialType, member: result.member };
17736
+ return { kind: "mine", type, member: result.member };
17723
17737
  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
17738
  return { kind: "refused", code: result.code };
17725
17739
  } catch {
17726
17740
  }
17727
17741
  return { kind: "refused", code: "unclassified" };
17728
17742
  }
17743
+ if (row.credentialType !== "oauth" && row.credentialType !== "api_key")
17744
+ return notMine;
17729
17745
  if (row.credentialType === "oauth")
17730
17746
  return row.refreshAdapter === family.refreshAdapter ? { kind: "mine", type: "oauth" } : notMine;
17731
17747
  if (row.credentialType === "api_key" && family.apiKeys)
@@ -18872,7 +18888,7 @@ async function refreshVaultRoster(options) {
18872
18888
  pendingDiscoveries.set(key, discovered);
18873
18889
  throw error;
18874
18890
  } finally {
18875
- await lease.release();
18891
+ await lease.release(options.signal);
18876
18892
  }
18877
18893
  }
18878
18894
  function resolveVaultPrimary(input) {
@@ -19225,7 +19241,7 @@ var init_consumer = __esm({
19225
19241
  this.#shutdown.signal,
19226
19242
  ...signal ? [signal] : []
19227
19243
  ]);
19228
- return new Promise((resolve20, reject) => {
19244
+ return new Promise((resolve21, reject) => {
19229
19245
  const cleanup2 = () => {
19230
19246
  combined.signal.removeEventListener("abort", abort);
19231
19247
  combined.dispose();
@@ -19240,7 +19256,7 @@ var init_consumer = __esm({
19240
19256
  if (combined.signal.aborted)
19241
19257
  reject(combined.signal.reason);
19242
19258
  else
19243
- resolve20(value);
19259
+ resolve21(value);
19244
19260
  }, (error) => {
19245
19261
  cleanup2();
19246
19262
  reject(error);
@@ -19414,8 +19430,16 @@ var init_consumer = __esm({
19414
19430
  this.#refreshing = void 0;
19415
19431
  });
19416
19432
  this.#track(this.#refreshing);
19433
+ this.#notifyDiscovery(this.#refreshing);
19417
19434
  return this.#refreshing;
19418
19435
  }
19436
+ #notifyDiscovery(promise) {
19437
+ try {
19438
+ this.#options.onDiscovery?.(promise);
19439
+ } catch (error) {
19440
+ this.#options.onError?.(error);
19441
+ }
19442
+ }
19419
19443
  /**
19420
19444
  * Poll in the background and open the vault and insula watches. Until the
19421
19445
  * vault watch is accepted, and whenever it is unavailable, every tick lists
@@ -19645,6 +19669,13 @@ var init_consumer = __esm({
19645
19669
  /** The hub's handle on this member's memory. */
19646
19670
  #hubHooks() {
19647
19671
  return {
19672
+ discovery: (promise) => {
19673
+ const hub = this.#hub;
19674
+ if (!hub || !this.#options.onDiscovery || this.#shutdown.signal.aborted)
19675
+ return;
19676
+ const discovery = this.#track(promise.then((outcome) => this.#hubOutcome(hub, outcome)));
19677
+ this.#notifyDiscovery(discovery);
19678
+ },
19648
19679
  install: (roster) => {
19649
19680
  if (this.#shutdown.signal.aborted)
19650
19681
  return;
@@ -19679,6 +19710,9 @@ var init_consumer = __esm({
19679
19710
  */
19680
19711
  async #hubRefresh(hub) {
19681
19712
  const outcome = await hub.refresh();
19713
+ return this.#hubOutcome(hub, outcome);
19714
+ }
19715
+ #hubOutcome(hub, outcome) {
19682
19716
  this.#assertOpen();
19683
19717
  if (!outcome)
19684
19718
  return void 0;
@@ -19833,6 +19867,8 @@ var init_consumer = __esm({
19833
19867
  this.#assertOpen();
19834
19868
  await declineVaultRoute(this.#options.rosterPath, routeId);
19835
19869
  this.#roster = pendingVaultQuota(this.#options.rosterPath, await readVaultRoster(this.#options.rosterPath));
19870
+ if (this.#roster)
19871
+ this.#hub?.publishRoster(this.#roster);
19836
19872
  if (this.#hub)
19837
19873
  this.#hub.retainUnion();
19838
19874
  else
@@ -19842,6 +19878,8 @@ var init_consumer = __esm({
19842
19878
  this.#assertOpen();
19843
19879
  await acceptVaultRoute(this.#options.rosterPath, routeId);
19844
19880
  this.#roster = pendingVaultQuota(this.#options.rosterPath, await readVaultRoster(this.#options.rosterPath));
19881
+ if (this.#roster)
19882
+ this.#hub?.publishRoster(this.#roster);
19845
19883
  }
19846
19884
  /**
19847
19885
  * Set the order vault accounts are tried in (`reorderVaultRoster`), then
@@ -19852,6 +19890,8 @@ var init_consumer = __esm({
19852
19890
  this.#assertOpen();
19853
19891
  const result = await reorderVaultRoster(this.#options.rosterPath, routeIds);
19854
19892
  this.#roster = pendingVaultQuota(this.#options.rosterPath, await readVaultRoster(this.#options.rosterPath));
19893
+ if (this.#roster)
19894
+ this.#hub?.publishRoster(this.#roster);
19855
19895
  return result;
19856
19896
  }
19857
19897
  /**
@@ -19929,7 +19969,7 @@ var init_consumer = __esm({
19929
19969
  // ../core/dist/common-auth-embedded/claustrum/hub.js
19930
19970
  import { createHash as createHash7 } from "node:crypto";
19931
19971
  import { readdir, stat as stat6 } from "node:fs/promises";
19932
- import { dirname as dirname10, join as join7 } from "node:path";
19972
+ import { dirname as dirname10, join as join7, resolve as resolve9 } from "node:path";
19933
19973
  function canonicalJson3(value, path2 = /* @__PURE__ */ new Set()) {
19934
19974
  if (value === null)
19935
19975
  return "null";
@@ -19990,12 +20030,12 @@ function unreachableConnect2() {
19990
20030
  return new ClaustrumUnreachableError();
19991
20031
  }
19992
20032
  function untilAborted(pending, signal) {
19993
- return new Promise((resolve20, reject) => {
20033
+ return new Promise((resolve21, reject) => {
19994
20034
  const abort = () => reject(signal.reason);
19995
20035
  signal.addEventListener("abort", abort, { once: true });
19996
20036
  pending.then((value) => {
19997
20037
  signal.removeEventListener("abort", abort);
19998
- resolve20(value);
20038
+ resolve21(value);
19999
20039
  }, (error) => {
20000
20040
  signal.removeEventListener("abort", abort);
20001
20041
  reject(error);
@@ -20007,7 +20047,7 @@ function untilAborted(pending, signal) {
20007
20047
  function enabledRows(roster) {
20008
20048
  return JSON.stringify((roster?.rows ?? []).map((row) => [row.credentialId, row.enabled]));
20009
20049
  }
20010
- var FILE_ID, WINDOWS_DEVICE, FINGERPRINT, PENDING_EVERY_TICK, ClaustrumDiscoveryHub;
20050
+ var sharedRosters, FILE_ID, WINDOWS_DEVICE, FINGERPRINT, PENDING_EVERY_TICK, ClaustrumDiscoveryHub;
20011
20051
  var init_hub = __esm({
20012
20052
  "../core/dist/common-auth-embedded/claustrum/hub.js"() {
20013
20053
  "use strict";
@@ -20021,6 +20061,7 @@ var init_hub = __esm({
20021
20061
  init_roster();
20022
20062
  init_shutdown();
20023
20063
  init_watch();
20064
+ sharedRosters = /* @__PURE__ */ new Map();
20024
20065
  FILE_ID = /^[a-z0-9][a-z0-9._-]{0,63}$/;
20025
20066
  WINDOWS_DEVICE = /^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\.|$)/;
20026
20067
  FINGERPRINT = /^[0-9a-f]{16}$/;
@@ -20127,9 +20168,11 @@ var init_hub = __esm({
20127
20168
  watchMode: () => this.watchState(),
20128
20169
  keptReceiptState: () => this.keptReceiptState(),
20129
20170
  retainUnion: () => this.#retainUnion(),
20171
+ publishRoster: (roster) => this.#publishRoster(entry, roster),
20130
20172
  forget: (credentialId) => this.#current?.custody?.forget(credentialId),
20131
20173
  detach: () => {
20132
20174
  entry.closed = true;
20175
+ entry.releaseRoster?.();
20133
20176
  }
20134
20177
  };
20135
20178
  const consumerOptions = {
@@ -20142,14 +20185,51 @@ var init_hub = __esm({
20142
20185
  },
20143
20186
  ...this.#options.mapAccount && { mapAccount: this.#options.mapAccount },
20144
20187
  ...options.onRoster && { onRoster: options.onRoster },
20188
+ ...options.onDiscovery && { onDiscovery: options.onDiscovery },
20145
20189
  ...options.onError && { onError: options.onError },
20146
20190
  logger: options.logger ?? this.#logger,
20147
20191
  ...this.#options.now && { now: this.#options.now }
20148
20192
  };
20149
20193
  const { consumer, hooks } = createHubMember(port, consumerOptions);
20150
20194
  entry.hooks = hooks;
20195
+ const path2 = resolve9(entry.path);
20196
+ const subscribers = sharedRosters.get(path2) ?? /* @__PURE__ */ new Set();
20197
+ const install = (roster) => {
20198
+ if (entry.closed || this.#active !== true || !this.#current || !this.#live(this.#current) || !hooks.roster() || this.#collides(hooks, roster))
20199
+ return;
20200
+ entry.seen = JSON.stringify(decodedVaultRoster(roster));
20201
+ hooks.install(roster);
20202
+ if (roster.view !== this.#committed?.view)
20203
+ entry.pending ??= { failures: 0, wait: 0 };
20204
+ this.#retainUnion();
20205
+ };
20206
+ subscribers.add(install);
20207
+ entry.receiveRoster = install;
20208
+ sharedRosters.set(path2, subscribers);
20209
+ let subscribed = true;
20210
+ entry.releaseRoster = () => {
20211
+ if (!subscribed)
20212
+ return;
20213
+ subscribed = false;
20214
+ subscribers.delete(install);
20215
+ if (!subscribers.size)
20216
+ sharedRosters.delete(path2);
20217
+ };
20151
20218
  return consumer;
20152
20219
  }
20220
+ #publishRoster(entry, roster) {
20221
+ const generation = this.#current;
20222
+ if (entry.closed || !generation || !this.#live(generation))
20223
+ return;
20224
+ entry.seen = JSON.stringify(decodedVaultRoster(roster));
20225
+ entry.hooks?.install(roster);
20226
+ for (const install of sharedRosters.get(resolve9(entry.path)) ?? []) {
20227
+ if (!this.#live(generation))
20228
+ return;
20229
+ if (install !== entry.receiveRoster)
20230
+ install(roster);
20231
+ }
20232
+ }
20153
20233
  // --- leases ---
20154
20234
  #startGeneration() {
20155
20235
  const generation = {
@@ -20445,6 +20525,8 @@ var init_hub = __esm({
20445
20525
  }));
20446
20526
  run.promise = promise;
20447
20527
  this.#run = run;
20528
+ for (const entry of this.#open())
20529
+ entry.hooks?.discovery(promise);
20448
20530
  return promise;
20449
20531
  }
20450
20532
  /**
@@ -20521,9 +20603,7 @@ var init_hub = __esm({
20521
20603
  this.#markPending(entry);
20522
20604
  continue;
20523
20605
  }
20524
- entry.seen = JSON.stringify(decodedVaultRoster(roster));
20525
- if (!entry.closed)
20526
- hooks.install(roster);
20606
+ this.#publishRoster(entry, roster);
20527
20607
  }
20528
20608
  if (!this.#live(generation))
20529
20609
  return void 0;
@@ -20678,7 +20758,7 @@ var init_hub = __esm({
20678
20758
  }
20679
20759
  const before = enabledRows(memory);
20680
20760
  entry.seen = content;
20681
- hooks.install(file);
20761
+ this.#publishRoster(entry, file);
20682
20762
  if (enabledRows(hooks.roster()) !== before)
20683
20763
  this.#retainUnion();
20684
20764
  }
@@ -20835,6 +20915,8 @@ var init_hub = __esm({
20835
20915
  if (this.#shutdown.signal.aborted)
20836
20916
  return;
20837
20917
  this.#shutdown.abort(closed("Claustrum discovery hub is closed"));
20918
+ for (const entry of this.#members.values())
20919
+ entry.releaseRoster?.();
20838
20920
  if (this.#timer)
20839
20921
  (this.#options.clearTimeoutImpl ?? clearTimeout)(this.#timer);
20840
20922
  this.#timer = void 0;
@@ -21169,7 +21251,7 @@ var init_lock = __esm({
21169
21251
  import { createHash as createHash8 } from "node:crypto";
21170
21252
  import { constants as constants2 } from "node:fs";
21171
21253
  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";
21254
+ import { dirname as dirname11, resolve as resolve10 } from "node:path";
21173
21255
  import { setTimeout as sleep2 } from "node:timers/promises";
21174
21256
  function rootSpans(text2) {
21175
21257
  let i = text2.indexOf("{") + 1;
@@ -21370,8 +21452,8 @@ function createPiSlot(options, onStep, hooks) {
21370
21452
  if (!provider2 || !options.authPath || !options.stashPath || !placeholderKey || placeholderKey.startsWith("!") || placeholderKey.includes("$") || !Number.isFinite(timeout) || timeout < 0) {
21371
21453
  throw new PiSlotError("invalid-options");
21372
21454
  }
21373
- const authPath = resolve9(options.authPath);
21374
- const stashPath = resolve9(options.stashPath);
21455
+ const authPath = resolve10(options.authPath);
21456
+ const stashPath = resolve10(options.stashPath);
21375
21457
  if (authPath === stashPath || stashPath === `${authPath}.lock`) {
21376
21458
  throw new PiSlotError("invalid-options");
21377
21459
  }
@@ -21639,8 +21721,8 @@ function getDefaultTierId(allowedTiers) {
21639
21721
  return allowedTiers[0]?.id;
21640
21722
  }
21641
21723
  function wait(ms) {
21642
- return new Promise((resolve20) => {
21643
- setTimeout(resolve20, ms);
21724
+ return new Promise((resolve21) => {
21725
+ setTimeout(resolve21, ms);
21644
21726
  });
21645
21727
  }
21646
21728
  function extractManagedProjectId(payload) {
@@ -22662,7 +22744,7 @@ var init_capture_sink2 = __esm({
22662
22744
  import { randomUUID as randomUUID11 } from "node:crypto";
22663
22745
  import { lstat as lstat6, readFile as readFile7, rename as rename8, unlink as unlink8 } from "node:fs/promises";
22664
22746
  import { tmpdir as tmpdir2 } from "node:os";
22665
- import { dirname as dirname13, join as join9, resolve as resolve10 } from "node:path";
22747
+ import { dirname as dirname13, join as join9, resolve as resolve11 } from "node:path";
22666
22748
  function ioCode2(detail) {
22667
22749
  if (detail?.reason === "io-error") {
22668
22750
  if (detail.win32Code === 2 || detail.win32Code === 3)
@@ -22709,7 +22791,7 @@ async function privateOperation2(path2, stage, operation) {
22709
22791
  }
22710
22792
  }
22711
22793
  async function verifySafeDirectory2(path2, options) {
22712
- path2 = resolve10(path2);
22794
+ path2 = resolve11(path2);
22713
22795
  options ??= safeParentOptionsForTest2;
22714
22796
  await privateOperation2(path2, "safe-parent", async () => {
22715
22797
  const result = await (await loadBackend2()).verifySafeParent(path2, options);
@@ -22724,7 +22806,7 @@ async function verifySafeDirectory2(path2, options) {
22724
22806
  });
22725
22807
  }
22726
22808
  async function verifyPrivate2(path2, kind, migrate = false) {
22727
- path2 = resolve10(path2);
22809
+ path2 = resolve11(path2);
22728
22810
  if (kind === "directory")
22729
22811
  return verifySafeDirectory2(path2);
22730
22812
  await privateOperation2(path2, "verify", async () => {
@@ -22759,7 +22841,7 @@ async function verifyPrivate2(path2, kind, migrate = false) {
22759
22841
  });
22760
22842
  }
22761
22843
  async function ensurePrivateDirectory2(path2, _migrate = false, options) {
22762
- path2 = resolve10(path2);
22844
+ path2 = resolve11(path2);
22763
22845
  await privateOperation2(path2, "directory", async () => {
22764
22846
  const api = await loadBackend2();
22765
22847
  try {
@@ -22790,7 +22872,7 @@ async function readPrivateText2(path2, migrate = false) {
22790
22872
  async function readPrivateBuffer2(path2, migrate = false) {
22791
22873
  if (!windowsPrivateFiles2)
22792
22874
  return readFile7(path2);
22793
- path2 = resolve10(path2);
22875
+ path2 = resolve11(path2);
22794
22876
  if (migrate) {
22795
22877
  await verifySafeDirectory2(dirname13(path2));
22796
22878
  await verifyPrivate2(path2, "file", true);
@@ -22798,20 +22880,20 @@ async function readPrivateBuffer2(path2, migrate = false) {
22798
22880
  return privateOperation2(path2, "read", async () => (await loadBackend2()).readOwnerOnly(path2));
22799
22881
  }
22800
22882
  async function createPrivateBytes2(path2, bytes) {
22801
- await verifySafeDirectory2(dirname13(resolve10(path2)));
22883
+ await verifySafeDirectory2(dirname13(resolve11(path2)));
22802
22884
  await privateOperation2(path2, "create", async () => {
22803
- await (await loadBackend2()).createPrivateFile(resolve10(path2), bytes);
22885
+ await (await loadBackend2()).createPrivateFile(resolve11(path2), bytes);
22804
22886
  });
22805
22887
  }
22806
22888
  async function createPrivateDirectoryExclusive2(path2) {
22807
- await verifySafeDirectory2(dirname13(resolve10(path2)));
22889
+ await verifySafeDirectory2(dirname13(resolve11(path2)));
22808
22890
  await privateOperation2(path2, "directory-create", async () => {
22809
- await (await loadBackend2()).createOwnerOnly(resolve10(path2), { kind: "dir" });
22891
+ await (await loadBackend2()).createOwnerOnly(resolve11(path2), { kind: "dir" });
22810
22892
  });
22811
22893
  }
22812
22894
  async function replaceWindowsFile2(from, to, options = {}) {
22813
- from = resolve10(from);
22814
- to = resolve10(to);
22895
+ from = resolve11(from);
22896
+ to = resolve11(to);
22815
22897
  const now = options.now ?? (() => performance.now());
22816
22898
  const start = now();
22817
22899
  const leaseDeadline = options.deadline ?? Infinity;
@@ -22854,7 +22936,7 @@ async function replaceWindowsFile2(from, to, options = {}) {
22854
22936
  throw error;
22855
22937
  }
22856
22938
  async function writePrivateAtomic2(path2, bytes, options = {}) {
22857
- path2 = resolve10(path2);
22939
+ path2 = resolve11(path2);
22858
22940
  await ensurePrivateDirectory2(dirname13(path2));
22859
22941
  try {
22860
22942
  await verifyPrivate2(path2, "file", true);
@@ -22862,7 +22944,7 @@ async function writePrivateAtomic2(path2, bytes, options = {}) {
22862
22944
  if (error.code !== "ENOENT")
22863
22945
  throw error;
22864
22946
  }
22865
- const stage = resolve10(options.stagePath ?? `${path2}.${randomUUID11()}.tmp`);
22947
+ const stage = resolve11(options.stagePath ?? `${path2}.${randomUUID11()}.tmp`);
22866
22948
  if (dirname13(stage) !== dirname13(path2))
22867
22949
  throw new PrivateFileError2(path2, "stage-directory", { code: "EXDEV" });
22868
22950
  let created = false;
@@ -23028,7 +23110,7 @@ var init_redact2 = __esm({
23028
23110
  // src/common-auth-embedded/logger/engine.js
23029
23111
  import { appendFileSync as appendFileSync2, chmodSync as chmodSync2, existsSync as existsSync2, renameSync as renameSync2, statSync as statSync3 } from "node:fs";
23030
23112
  import { open as open8 } from "node:fs/promises";
23031
- import { dirname as dirname14, resolve as resolve11 } from "node:path";
23113
+ import { dirname as dirname14, resolve as resolve12 } from "node:path";
23032
23114
  function chmodPrivate2(path2) {
23033
23115
  try {
23034
23116
  chmodSync2(path2, 384);
@@ -23079,7 +23161,7 @@ async function openWindowsFile2(sink, file) {
23079
23161
  return sink.handle;
23080
23162
  }
23081
23163
  async function flushWindowsFile2(sink, file, text2) {
23082
- file = resolve11(file);
23164
+ file = resolve12(file);
23083
23165
  try {
23084
23166
  if (sink.file !== file)
23085
23167
  await closeWindowsFile2(sink);
@@ -23396,7 +23478,7 @@ import { randomUUID as randomUUID12 } from "node:crypto";
23396
23478
  import { realpathSync, rmSync } from "node:fs";
23397
23479
  import { chmod as chmod3, mkdir as mkdir11, readFile as readFile8, rename as rename9, rm as rm5, writeFile as writeFile3 } from "node:fs/promises";
23398
23480
  import { homedir as homedir2 } from "node:os";
23399
- import { join as join10, resolve as resolve12 } from "node:path";
23481
+ import { join as join10, resolve as resolve13 } from "node:path";
23400
23482
  function processHeartbeatDir() {
23401
23483
  const base = process.env.XDG_STATE_HOME || join10(homedir2(), ".local", "state");
23402
23484
  return join10(base, "cortexkit", "antigravity-auth", "processes");
@@ -23409,7 +23491,7 @@ function processConfigFolderKey() {
23409
23491
  try {
23410
23492
  return realpathSync.native(folder);
23411
23493
  } catch {
23412
- return resolve12(folder);
23494
+ return resolve13(folder);
23413
23495
  }
23414
23496
  }
23415
23497
  function processHasOlderGeneration() {
@@ -23855,7 +23937,7 @@ import {
23855
23937
  stat as stat8,
23856
23938
  unlink as unlink9
23857
23939
  } from "node:fs/promises";
23858
- import { basename as basename4, dirname as dirname15, join as join12, resolve as resolve13 } from "node:path";
23940
+ import { basename as basename4, dirname as dirname15, join as join12, resolve as resolve14 } from "node:path";
23859
23941
  function refusalMessage(stateDir, errorClass2) {
23860
23942
  if (errorClass2 === "ERR_PRIVATE_FILES_SECURITY")
23861
23943
  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 +24792,7 @@ async function isVaultShapedKeptState(files) {
24710
24792
  async function removeMovedVaultStateLeftover(vaultDir, accountFile) {
24711
24793
  const location = runtimeLayoutLocation();
24712
24794
  const files = layoutFiles(location, accountFile);
24713
- if (resolve13(vaultDir) !== resolve13(files.vault.next)) return;
24795
+ if (resolve14(vaultDir) !== resolve14(files.vault.next)) return;
24714
24796
  const stateDir = location.stateHomeDir;
24715
24797
  const marker = await readMarker(
24716
24798
  join12(stateDir, RUNTIME_LAYOUT_MARKER_FILE),
@@ -25138,7 +25220,7 @@ import {
25138
25220
  writeFileSync
25139
25221
  } from "node:fs";
25140
25222
  import { homedir as homedir4 } from "node:os";
25141
- import { dirname as dirname16, join as join13, resolve as resolve14 } from "node:path";
25223
+ import { dirname as dirname16, join as join13, resolve as resolve15 } from "node:path";
25142
25224
  async function ensureGitignore(configDir) {
25143
25225
  const gitignorePath = join13(configDir, ".gitignore");
25144
25226
  try {
@@ -25238,8 +25320,8 @@ function migrateLegacyWindowsConfig() {
25238
25320
  }
25239
25321
  }
25240
25322
  function resolveWindowsAccountAnchor(newPath, legacyPath) {
25241
- const standard = resolve14(newPath);
25242
- const legacy = resolve14(legacyPath);
25323
+ const standard = resolve15(newPath);
25324
+ const legacy = resolve15(legacyPath);
25243
25325
  if (standard.toLowerCase() === legacy.toLowerCase()) return newPath;
25244
25326
  const standardPointer = existsSync3(accountStorePointerPath(standard));
25245
25327
  const legacyPointer = existsSync3(accountStorePointerPath(legacy));
@@ -25261,7 +25343,7 @@ function getStoragePathWithMigration() {
25261
25343
  "antigravity-accounts.json"
25262
25344
  );
25263
25345
  const anchored = resolveWindowsAccountAnchor(newPath, legacyPath);
25264
- if (resolve14(anchored).toLowerCase() !== resolve14(newPath).toLowerCase() && !existsSync3(accountStorePointerPath(resolve14(anchored)))) {
25346
+ if (resolve15(anchored).toLowerCase() !== resolve15(newPath).toLowerCase() && !existsSync3(accountStorePointerPath(resolve15(anchored)))) {
25265
25347
  log5.info("Using legacy Windows config path (migration failed)", {
25266
25348
  legacyPath,
25267
25349
  newPath
@@ -25278,7 +25360,7 @@ function accountFileForVault(configDir = getConfigDir()) {
25278
25360
  const configured = join13(configDir, "antigravity-accounts.json");
25279
25361
  if (process.platform !== "win32") return configured;
25280
25362
  const legacyDir = getLegacyWindowsConfigDir();
25281
- if (resolve14(configDir).toLowerCase() === resolve14(legacyDir).toLowerCase())
25363
+ if (resolve15(configDir).toLowerCase() === resolve15(legacyDir).toLowerCase())
25282
25364
  return configured;
25283
25365
  const configuredVault = join13(configDir, "antigravity-auth-vault");
25284
25366
  const legacyVault = join13(legacyDir, "antigravity-auth-vault");
@@ -25309,7 +25391,7 @@ function getStoragePath() {
25309
25391
  }
25310
25392
  async function assertLegacyPoolInUse(legacyPath) {
25311
25393
  try {
25312
- await assertLegacyAccountStorageWritable(resolve14(legacyPath));
25394
+ await assertLegacyAccountStorageWritable(resolve15(legacyPath));
25313
25395
  } catch (error) {
25314
25396
  throw new LegacyAccountPoolRetiredError(legacyPath, { cause: error });
25315
25397
  }
@@ -25327,7 +25409,7 @@ function refusalMessage2(admission) {
25327
25409
  async function bindingOf(options) {
25328
25410
  if (options.legacyPath === void 0) await prepareLocalAccountStore();
25329
25411
  const now = options.now ?? (() => Date.now());
25330
- const legacyPath = resolve14(options.legacyPath ?? getStoragePath());
25412
+ const legacyPath = resolve15(options.legacyPath ?? getStoragePath());
25331
25413
  return {
25332
25414
  legacyPath,
25333
25415
  now,
@@ -25396,7 +25478,7 @@ async function openAccountStore(options) {
25396
25478
  async function initializeFreshAccountStoreFor(modules, options = {}) {
25397
25479
  if (options.legacyPath === void 0) await prepareLocalAccountStore();
25398
25480
  return initializeFreshAccountStore(modules, {
25399
- legacyPath: resolve14(options.legacyPath ?? getStoragePath()),
25481
+ legacyPath: resolve15(options.legacyPath ?? getStoragePath()),
25400
25482
  now: options.now ?? (() => Date.now())
25401
25483
  });
25402
25484
  }
@@ -25442,12 +25524,12 @@ var init_storage = __esm({
25442
25524
  import { createHash as createHash11 } from "node:crypto";
25443
25525
  import { existsSync as existsSync4, promises as fs2, readFileSync as readFileSync2, realpathSync as realpathSync2 } from "node:fs";
25444
25526
  import { homedir as homedir5 } from "node:os";
25445
- import { dirname as dirname17, join as join14, resolve as resolve15 } from "node:path";
25527
+ import { dirname as dirname17, join as join14, resolve as resolve16 } from "node:path";
25446
25528
  function configDirIdentity(path2) {
25447
25529
  try {
25448
25530
  return realpathSync2.native(path2);
25449
25531
  } catch {
25450
- return resolve15(path2);
25532
+ return resolve16(path2);
25451
25533
  }
25452
25534
  }
25453
25535
  function decisionKey(location) {
@@ -26109,13 +26191,13 @@ function closeDebugLog() {
26109
26191
  if (!state || !current) return Promise.resolve();
26110
26192
  state.logStream = null;
26111
26193
  if (state.logFilePath) liveLogFilePaths.delete(state.logFilePath);
26112
- return new Promise((resolve20) => {
26113
- current.once("close", () => resolve20());
26114
- current.once("error", () => resolve20());
26194
+ return new Promise((resolve21) => {
26195
+ current.once("close", () => resolve21());
26196
+ current.once("error", () => resolve21());
26115
26197
  try {
26116
26198
  current.end();
26117
26199
  } catch {
26118
- resolve20();
26200
+ resolve21();
26119
26201
  }
26120
26202
  });
26121
26203
  }
@@ -26261,7 +26343,7 @@ var init_logger4 = __esm({
26261
26343
  init_dist();
26262
26344
  import { execFile } from "node:child_process";
26263
26345
  import { realpathSync as realpathSync4 } from "node:fs";
26264
- import { resolve as resolve19 } from "node:path";
26346
+ import { resolve as resolve20 } from "node:path";
26265
26347
  import { createInterface } from "node:readline/promises";
26266
26348
  import { fileURLToPath as fileURLToPath2 } from "node:url";
26267
26349
  import { promisify } from "node:util";
@@ -26669,14 +26751,14 @@ async function fetchQuotaPayloads(options) {
26669
26751
  };
26670
26752
  }
26671
26753
  function untilQuotaAborted(pending, signal) {
26672
- return new Promise((resolve20, reject) => {
26754
+ return new Promise((resolve21, reject) => {
26673
26755
  const abort = () => reject(signal.reason);
26674
26756
  if (signal.aborted) abort();
26675
26757
  else signal.addEventListener("abort", abort, { once: true });
26676
26758
  void pending.then(
26677
26759
  (value) => {
26678
26760
  signal.removeEventListener("abort", abort);
26679
- resolve20(value);
26761
+ resolve21(value);
26680
26762
  },
26681
26763
  (error) => {
26682
26764
  signal.removeEventListener("abort", abort);
@@ -26958,12 +27040,12 @@ async function startOAuthListener({
26958
27040
  let resolveCallback;
26959
27041
  let rejectCallback;
26960
27042
  let timeoutHandle;
26961
- const callbackPromise = new Promise((resolve20, reject) => {
27043
+ const callbackPromise = new Promise((resolve21, reject) => {
26962
27044
  resolveCallback = (url) => {
26963
27045
  if (settled) return;
26964
27046
  settled = true;
26965
27047
  if (timeoutHandle) clearTimeout(timeoutHandle);
26966
- resolve20(url);
27048
+ resolve21(url);
26967
27049
  };
26968
27050
  rejectCallback = (error) => {
26969
27051
  if (settled) return;
@@ -27122,7 +27204,7 @@ async function startOAuthListener({
27122
27204
  });
27123
27205
  });
27124
27206
  const bindAddress = getBindAddress();
27125
- await new Promise((resolve20, reject) => {
27207
+ await new Promise((resolve21, reject) => {
27126
27208
  const handleError = (error) => {
27127
27209
  server.off("error", handleError);
27128
27210
  if (error.code === "EADDRINUSE") {
@@ -27138,7 +27220,7 @@ async function startOAuthListener({
27138
27220
  server.once("error", handleError);
27139
27221
  server.listen(port, bindAddress, () => {
27140
27222
  server.off("error", handleError);
27141
- resolve20();
27223
+ resolve21();
27142
27224
  });
27143
27225
  });
27144
27226
  server.on("error", (error) => {
@@ -27146,7 +27228,7 @@ async function startOAuthListener({
27146
27228
  });
27147
27229
  return {
27148
27230
  waitForCallback: () => callbackPromise,
27149
- close: () => new Promise((resolve20, reject) => {
27231
+ close: () => new Promise((resolve21, reject) => {
27150
27232
  server.close((error) => {
27151
27233
  if (error && error.code !== "ERR_SERVER_NOT_RUNNING") {
27152
27234
  reject(error);
@@ -27155,7 +27237,7 @@ async function startOAuthListener({
27155
27237
  if (!settled) {
27156
27238
  rejectCallback(new Error("OAuth listener closed before callback"));
27157
27239
  }
27158
- resolve20();
27240
+ resolve21();
27159
27241
  });
27160
27242
  })
27161
27243
  };
@@ -27174,7 +27256,7 @@ init_runtime_paths();
27174
27256
  // src/setup.ts
27175
27257
  init_dist();
27176
27258
  import { lstat as lstat9, readFile as readFile13 } from "node:fs/promises";
27177
- import { join as join21, resolve as resolve18 } from "node:path";
27259
+ import { join as join21, resolve as resolve19 } from "node:path";
27178
27260
 
27179
27261
  // src/auth-method-labels.ts
27180
27262
  var OPENCODE2_POOL_AUTH_LABEL = "Google (antigravity-auth pool, browser)";
@@ -27346,7 +27428,7 @@ async function select2(terminal, items, options) {
27346
27428
  writeLine("");
27347
27429
  renderedLines = lines;
27348
27430
  };
27349
- return new Promise((resolve20) => {
27431
+ return new Promise((resolve21) => {
27350
27432
  const wasRaw = stdin.isRaw ?? false;
27351
27433
  const cleanup2 = () => {
27352
27434
  if (cleaned)
@@ -27366,7 +27448,7 @@ async function select2(terminal, items, options) {
27366
27448
  };
27367
27449
  const finish = (value) => {
27368
27450
  cleanup2();
27369
- resolve20(value);
27451
+ resolve21(value);
27370
27452
  };
27371
27453
  const onSignal = () => finish(null);
27372
27454
  const onKey = (data) => {
@@ -27406,7 +27488,7 @@ async function select2(terminal, items, options) {
27406
27488
  stdin.setRawMode(true);
27407
27489
  } catch {
27408
27490
  cleanup2();
27409
- resolve20(null);
27491
+ resolve21(null);
27410
27492
  return;
27411
27493
  }
27412
27494
  stdin.resume();
@@ -27420,12 +27502,12 @@ async function select2(terminal, items, options) {
27420
27502
  import { createHash as createHash12, randomBytes as randomBytes3, randomUUID as randomUUID15 } from "node:crypto";
27421
27503
  import { constants as fsConstants2 } from "node:fs";
27422
27504
  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";
27505
+ import { basename as basename5, dirname as dirname19, extname as extname2, isAbsolute as isAbsolute3, join as join17, resolve as resolve18 } from "node:path";
27424
27506
  import { ClaustrumCredentialError as ClaustrumCredentialError5, ClaustrumClient as ClaustrumWireClient2, writeEnrollmentTokenFile as writeEnrollmentTokenFile2 } from "@cortexkit/claustrum-client";
27425
27507
 
27426
27508
  // src/common-auth-embedded/fs/file-read-cache.js
27427
27509
  import { lstat as lstat7 } from "node:fs/promises";
27428
- import { resolve as resolve16 } from "node:path";
27510
+ import { resolve as resolve17 } from "node:path";
27429
27511
  async function identity2(path2) {
27430
27512
  try {
27431
27513
  const metadata = await lstat7(path2);
@@ -27442,7 +27524,7 @@ function sameIdentity2(left, right) {
27442
27524
  var FileReadCache2 = class {
27443
27525
  #entries = /* @__PURE__ */ new Map();
27444
27526
  async read(paths, read, validateHit) {
27445
- const resolvedPaths = paths.map((path2) => resolve16(path2));
27527
+ const resolvedPaths = paths.map((path2) => resolve17(path2));
27446
27528
  const key = JSON.stringify(resolvedPaths);
27447
27529
  const probed = await Promise.all(resolvedPaths.map(identity2));
27448
27530
  const identities = probed.every((entry) => entry !== void 0) ? probed : void 0;
@@ -27562,8 +27644,8 @@ async function acquireRefreshFileLockWithClock2(options) {
27562
27644
  let releaseConfirmed = false;
27563
27645
  let loss;
27564
27646
  let resolveLoss;
27565
- const lostPromise = new Promise((resolve20) => {
27566
- resolveLoss = resolve20;
27647
+ const lostPromise = new Promise((resolve21) => {
27648
+ resolveLoss = resolve21;
27567
27649
  });
27568
27650
  function notifyTimerStep(event) {
27569
27651
  try {
@@ -27724,7 +27806,7 @@ async function acquireRefreshFileLockWithClock2(options) {
27724
27806
  }
27725
27807
  }
27726
27808
  async function backoff() {
27727
- await new Promise((resolve20) => setTimeout(resolve20, Math.floor(Math.random() * 4)));
27809
+ await new Promise((resolve21) => setTimeout(resolve21, Math.floor(Math.random() * 4)));
27728
27810
  }
27729
27811
  async function readLockState(notifyReady = true) {
27730
27812
  if (notifyReady && options.onStep)
@@ -28162,7 +28244,7 @@ async function acquireRefreshFileLockWithClock2(options) {
28162
28244
  ...typeof observed?.expiresAt === "number" ? { observedExpiresAt: observed.expiresAt } : {}
28163
28245
  });
28164
28246
  },
28165
- release: async () => {
28247
+ release: async (signal) => {
28166
28248
  if (windowsPrivateFiles2 && releaseConfirmed)
28167
28249
  return;
28168
28250
  released = true;
@@ -28203,6 +28285,8 @@ async function acquireRefreshFileLockWithClock2(options) {
28203
28285
  releaseConfirmed = removalConfirmed;
28204
28286
  return;
28205
28287
  }
28288
+ if (signal?.aborted)
28289
+ return;
28206
28290
  await recoverStaleEvictionMarker();
28207
28291
  } catch (error) {
28208
28292
  if (windowsPrivateFiles2)
@@ -28212,7 +28296,7 @@ async function acquireRefreshFileLockWithClock2(options) {
28212
28296
  const remainingMs = deadline - performance.now();
28213
28297
  if (remainingMs <= 0)
28214
28298
  break;
28215
- await new Promise((resolve20) => setTimeout(resolve20, Math.min(delayMs, remainingMs)));
28299
+ await new Promise((resolve21) => setTimeout(resolve21, Math.min(delayMs, remainingMs)));
28216
28300
  delayMs = Math.min(delayMs * 2, 50);
28217
28301
  }
28218
28302
  if (windowsPrivateFiles2)
@@ -28285,7 +28369,7 @@ function hostEnrollmentPaths2(input) {
28285
28369
  const override = input.override?.trim();
28286
28370
  if (override && !isAbsolute3(override) && !input.cwd)
28287
28371
  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`);
28372
+ const tokenPath = override ? isAbsolute3(override) ? override : resolve18(input.cwd, override) : join17(input.stateDir, `${input.host}-enrollment.json`);
28289
28373
  return getClaustrumEnrollmentPaths2(tokenPath);
28290
28374
  }
28291
28375
  function isRecord10(value) {
@@ -28913,7 +28997,7 @@ var ByteTail = class {
28913
28997
  };
28914
28998
  var defaultCommandRunner = {
28915
28999
  run(file, args, options = {}) {
28916
- return new Promise((resolve20) => {
29000
+ return new Promise((resolve21) => {
28917
29001
  const started = performance.now();
28918
29002
  const timeoutMs = options.timeoutMs ?? 15e3;
28919
29003
  const stderr = new ByteTail();
@@ -28931,7 +29015,7 @@ var defaultCommandRunner = {
28931
29015
  stdio: ["ignore", "pipe", "pipe"]
28932
29016
  });
28933
29017
  } catch {
28934
- resolve20({
29018
+ resolve21({
28935
29019
  exitCode: 1,
28936
29020
  stdout: "",
28937
29021
  stderr: "",
@@ -28966,7 +29050,7 @@ var defaultCommandRunner = {
28966
29050
  settled = true;
28967
29051
  if (timer)
28968
29052
  clearTimeout(timer);
28969
- resolve20({
29053
+ resolve21({
28970
29054
  exitCode: spawnError ? 1 : outputExceeded ? 1 : code2 ?? 1,
28971
29055
  stdout: Buffer.concat(stdout, stdoutLength).toString("utf8"),
28972
29056
  stderr: stderr.toString(),
@@ -30384,7 +30468,7 @@ async function writeNativeSlot(host, slot, context, expectedAuthority = "local")
30384
30468
  beforeRename: async () => {
30385
30469
  await assertSetupHostsStopped();
30386
30470
  const claustrum = await loadCommonAuthClaustrum();
30387
- const stateDir = host === "opencode" ? openCodeVaultDir(resolve18(accountFileForVault())) : getPiAntigravityVaultDir();
30471
+ const stateDir = host === "opencode" ? openCodeVaultDir(resolve19(accountFileForVault())) : getPiAntigravityVaultDir();
30388
30472
  if (await claustrum.enrollmentAuthority(
30389
30473
  claustrum.hostEnrollmentPaths({ stateDir, host }),
30390
30474
  `antigravity-auth-${host}`
@@ -30422,7 +30506,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
30422
30506
  // `beforeSignIn`, which may move it after this plugin is built.
30423
30507
  paths: {
30424
30508
  get stateDir() {
30425
- return openCodeVaultDir(resolve18(accountFileForVault()));
30509
+ return openCodeVaultDir(resolve19(accountFileForVault()));
30426
30510
  },
30427
30511
  host: "opencode"
30428
30512
  }
@@ -30439,7 +30523,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
30439
30523
  const assertLocal = async (host, context) => {
30440
30524
  if (host === "opencode")
30441
30525
  return assertLocalOpenCodeLogin(
30442
- resolve18(accountFileForVault()),
30526
+ resolve19(accountFileForVault()),
30443
30527
  context.opencodeGeneration
30444
30528
  );
30445
30529
  if (await authority(host) !== "local")
@@ -31069,7 +31153,7 @@ async function runCliProcess(argv, deps) {
31069
31153
  ...deps,
31070
31154
  prepareVaultFolder: deps.prepareVaultFolder ?? (async (options) => {
31071
31155
  const folder = await prepareVaultFolder({
31072
- accountFile: resolve19(accountFileForVault()),
31156
+ accountFile: resolve20(accountFileForVault()),
31073
31157
  ...options
31074
31158
  });
31075
31159
  if (folder.refusal) throw folder.refusal;
@@ -31115,11 +31199,11 @@ function createDefaultCliDependencies() {
31115
31199
  );
31116
31200
  if (host !== "pi")
31117
31201
  await assertLocalOpenCodeLogin(
31118
- resolve19(accountFileForVault()),
31202
+ resolve20(accountFileForVault()),
31119
31203
  context?.opencodeGeneration
31120
31204
  );
31121
31205
  const repository = host === "pi" ? void 0 : await prepareCliLoginStore(
31122
- resolve19(getStoragePath()),
31206
+ resolve20(getStoragePath()),
31123
31207
  context?.opencodeGeneration
31124
31208
  );
31125
31209
  try {
@@ -31135,7 +31219,7 @@ function createDefaultCliDependencies() {
31135
31219
  }
31136
31220
  if (host === "opencode") await assertSetupHostsStopped();
31137
31221
  await assertLocalOpenCodeLogin(
31138
- resolve19(accountFileForVault()),
31222
+ resolve20(accountFileForVault()),
31139
31223
  context?.opencodeGeneration
31140
31224
  );
31141
31225
  await persistCliStoreLogin(
@@ -31155,7 +31239,7 @@ function createDefaultCliDependencies() {
31155
31239
  };
31156
31240
  }
31157
31241
  async function prepareCliLoginStore(legacyPath, generation) {
31158
- await assertLocalOpenCodeLogin(resolve19(accountFileForVault()), generation);
31242
+ await assertLocalOpenCodeLogin(resolve20(accountFileForVault()), generation);
31159
31243
  const modules = await loadCommonAuthStoreModules();
31160
31244
  const options = {
31161
31245
  legacyPath,
@@ -31280,7 +31364,7 @@ async function readAccountStore(legacyPath) {
31280
31364
  function createDefaultAccountStoreOperations() {
31281
31365
  const offline = { processesStopped: true };
31282
31366
  return {
31283
- legacyPath: () => resolve19(
31367
+ legacyPath: () => resolve20(
31284
31368
  decidedAccountStoreAnchor(runtimeLayoutLocation()) ? getStoragePath() : discoveredAccountFile()
31285
31369
  ),
31286
31370
  migrate: async (legacyPath) => createAccountMigrationFactory(await loadCommonAuthStoreModules())({
@@ -31311,7 +31395,7 @@ function createDefaultAccountStoreOperations() {
31311
31395
  };
31312
31396
  }
31313
31397
  function samePath(left, right) {
31314
- return process.platform === "win32" ? resolve19(left).toLowerCase() === resolve19(right).toLowerCase() : resolve19(left) === resolve19(right);
31398
+ return process.platform === "win32" ? resolve20(left).toLowerCase() === resolve20(right).toLowerCase() : resolve20(left) === resolve20(right);
31315
31399
  }
31316
31400
  function isCliEntry() {
31317
31401
  if (import.meta.main !== void 0) return import.meta.main;