@cortexkit/opencode-antigravity-auth 3.0.20 → 3.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/dist/cli.js +354 -278
  2. package/dist/cli.js.map +3 -3
  3. package/dist/cli.meta.json +66 -21
  4. package/dist/index.js +841 -392
  5. package/dist/index.js.map +4 -4
  6. package/dist/index.meta.json +123 -28
  7. package/dist/server.js +860 -411
  8. package/dist/server.js.map +4 -4
  9. package/dist/server.meta.json +1 -1
  10. package/dist/src/common-auth-embedded/claustrum/custody.js +25 -0
  11. package/dist/src/common-auth-embedded/claustrum/hub.js +20 -1
  12. package/dist/src/common-auth-embedded/claustrum/insula.js +6 -0
  13. package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +2 -2
  14. package/dist/src/common-auth-embedded/fs/with-lock.js +37 -10
  15. package/dist/src/common-auth-embedded/quota/format.d.ts +9 -4
  16. package/dist/src/common-auth-embedded/quota/format.js +45 -26
  17. package/dist/src/common-auth-embedded/quota-sidebar/index.d.ts +86 -0
  18. package/dist/src/common-auth-embedded/quota-sidebar/index.tsx +654 -0
  19. package/dist/src/common-auth-embedded/routing-accessor/index.d.ts +62 -0
  20. package/dist/src/common-auth-embedded/routing-accessor/index.js +128 -0
  21. package/dist/src/common-auth-embedded/source-output.json +69 -29
  22. package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
  23. package/dist/src/ga/tui/host-ga.js +2 -2
  24. package/dist/src/ga/tui/host-ga.js.map +1 -1
  25. package/dist/src/plugin/__fixtures__/verified-store.js +2 -2
  26. package/dist/src/plugin/index.d.ts.map +1 -1
  27. package/dist/src/plugin/index.js +2 -0
  28. package/dist/src/plugin/index.js.map +1 -1
  29. package/dist/src/plugin/request.d.ts.map +1 -1
  30. package/dist/src/plugin/request.js +1 -0
  31. package/dist/src/plugin/request.js.map +1 -1
  32. package/dist/src/plugin/shared/request-services.d.ts +6 -0
  33. package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
  34. package/dist/src/plugin/shared/request-services.js +89 -2
  35. package/dist/src/plugin/shared/request-services.js.map +1 -1
  36. package/dist/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
  37. package/dist/src/plugin/shared/vault-request-credentials.js +4 -0
  38. package/dist/src/plugin/shared/vault-request-credentials.js.map +1 -1
  39. package/dist/src/plugin/shared/vault-routing-purpose.d.ts +12 -0
  40. package/dist/src/plugin/shared/vault-routing-purpose.d.ts.map +1 -0
  41. package/dist/src/plugin/shared/vault-routing-purpose.js +18 -0
  42. package/dist/src/plugin/shared/vault-routing-purpose.js.map +1 -0
  43. package/dist/src/plugin/shared/vault-routing.d.ts +36 -0
  44. package/dist/src/plugin/shared/vault-routing.d.ts.map +1 -0
  45. package/dist/src/plugin/shared/vault-routing.js +213 -0
  46. package/dist/src/plugin/shared/vault-routing.js.map +1 -0
  47. package/dist/src/plugin/types.d.ts +1 -0
  48. package/dist/src/plugin/types.d.ts.map +1 -1
  49. package/dist/src/tui/quota-layout.d.ts +4 -58
  50. package/dist/src/tui/quota-layout.d.ts.map +1 -1
  51. package/dist/src/tui/quota-layout.js +4 -90
  52. package/dist/src/tui/quota-layout.js.map +1 -1
  53. package/dist/src/tui/sidebar-frame.d.ts +4 -34
  54. package/dist/src/tui/sidebar-frame.d.ts.map +1 -1
  55. package/dist/src/tui/sidebar-frame.js +93 -167
  56. package/dist/src/tui/sidebar-frame.js.map +1 -1
  57. package/dist/src/tui.js +2 -2
  58. package/dist/src/tui.js.map +1 -1
  59. package/dist/tui-build-map.json +31 -17
  60. package/dist/tui-ga-build-map.json +32 -17
  61. package/dist/types/src/common-auth-embedded/quota/format.d.ts +9 -4
  62. package/dist/types/src/common-auth-embedded/routing-accessor/index.d.ts +62 -0
  63. package/dist/types/src/plugin/index.d.ts.map +1 -1
  64. package/dist/types/src/plugin/request.d.ts.map +1 -1
  65. package/dist/types/src/plugin/shared/request-services.d.ts +6 -0
  66. package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -1
  67. package/dist/types/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
  68. package/dist/types/src/plugin/shared/vault-routing-purpose.d.ts +12 -0
  69. package/dist/types/src/plugin/shared/vault-routing-purpose.d.ts.map +1 -0
  70. package/dist/types/src/plugin/shared/vault-routing.d.ts +36 -0
  71. package/dist/types/src/plugin/shared/vault-routing.d.ts.map +1 -0
  72. package/dist/types/src/plugin/types.d.ts +1 -0
  73. package/dist/types/src/plugin/types.d.ts.map +1 -1
  74. package/package.json +2 -2
  75. package/src/common-auth-embedded/claustrum/custody.js +25 -0
  76. package/src/common-auth-embedded/claustrum/hub.js +20 -1
  77. package/src/common-auth-embedded/claustrum/insula.js +6 -0
  78. package/src/common-auth-embedded/fs/refresh-file-lock.js +2 -2
  79. package/src/common-auth-embedded/fs/with-lock.js +37 -10
  80. package/src/common-auth-embedded/quota/format.d.ts +9 -4
  81. package/src/common-auth-embedded/quota/format.js +45 -26
  82. package/src/common-auth-embedded/quota-sidebar/index.d.ts +86 -0
  83. package/src/common-auth-embedded/quota-sidebar/index.tsx +654 -0
  84. package/src/common-auth-embedded/routing-accessor/index.d.ts +62 -0
  85. package/src/common-auth-embedded/routing-accessor/index.js +128 -0
  86. package/src/common-auth-embedded/source-output.json +69 -29
  87. package/src/tui-compiled/common-auth-embedded/quota/format.js +45 -26
  88. package/src/tui-compiled/common-auth-embedded/quota-sidebar/index.js +683 -0
  89. package/src/tui-compiled/tui/quota-layout.js +5 -330
  90. package/src/tui-compiled/tui/sidebar-frame.js +243 -467
  91. package/src/tui-compiled/tui.js +2 -2
  92. package/src/tui-ga-compiled/host-ga.js +2 -2
  93. package/src/tui-ga-compiled/shared/aef2402f8fc342f0-format.js +45 -26
  94. package/src/tui-ga-compiled/shared/ced204104a639c9c-sidebar-frame.js +243 -467
  95. package/src/tui-ga-compiled/shared/dd4c9e1a907f8ef0-quota-layout.js +5 -330
  96. package/src/tui-ga-compiled/shared/e4ec36f367492969-index.js +683 -0
  97. package/src/tui-ga-raw/host-ga.tsx +2 -2
  98. package/src/tui-ga-raw/shared/aef2402f8fc342f0-format.js +45 -26
  99. package/src/tui-ga-raw/shared/ced204104a639c9c-sidebar-frame.tsx +214 -400
  100. package/src/tui-ga-raw/shared/dd4c9e1a907f8ef0-quota-layout.tsx +10 -301
  101. package/src/tui-ga-raw/shared/e4ec36f367492969-index.tsx +654 -0
  102. package/src/tui-raw/common-auth-embedded/quota/format.js +45 -26
  103. package/src/tui-raw/common-auth-embedded/quota-sidebar/index.tsx +654 -0
  104. package/src/tui-raw/tui/quota-layout.tsx +10 -301
  105. package/src/tui-raw/tui/sidebar-frame.tsx +214 -400
  106. package/src/tui-raw/tui.tsx +2 -2
  107. package/src/tui.tsx +2 -2
package/dist/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((resolve21) => setTimeout(resolve21, ms));
6049
+ await new Promise((resolve22) => setTimeout(resolve22, 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((resolve21) => {
6166
- lostResolve = resolve21;
6165
+ let lostPromise = new Promise((resolve22) => {
6166
+ lostResolve = resolve22;
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 resolve21 = lostResolve;
6176
+ const resolve22 = lostResolve;
6177
6177
  lostResolve = null;
6178
- resolve21?.();
6178
+ resolve22?.();
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((resolve21) => setTimeout(resolve21, ms));
6820
+ DEFAULT_SLEEP = (ms) => new Promise((resolve22) => setTimeout(resolve22, 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((resolve21, reject) => {
6988
+ return new Promise((resolve22, 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(() => resolve21({ head, leftover }));
7011
+ cleanup2(() => resolve22({ 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((resolve21, reject) => {
7025
+ await new Promise((resolve22, 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
- resolve21();
7034
+ resolve22();
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((resolve21, reject) => {
7059
+ return await new Promise((resolve22, 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
- resolve21(tlsSocket);
7074
+ resolve22(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((resolve21, reject) => {
7083
+ return await new Promise((resolve22, 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
- resolve21(socket);
7099
+ resolve22(socket);
7100
7100
  });
7101
7101
  socket.once("error", (error) => {
7102
7102
  cleanup2();
@@ -8061,7 +8061,7 @@ function displayOrder(left, right) {
8061
8061
  return left.label < right.label ? -1 : left.label > right.label ? 1 : 0;
8062
8062
  }
8063
8063
  function quotaWindowParts(quota, options) {
8064
- const { windows, age } = scopedWindowParts(quota, options);
8064
+ const { windows, age } = scopedWindowParts(quota, options, true);
8065
8065
  const parts = windows.map(({ part }) => part);
8066
8066
  return age === void 0 ? { windows: parts } : { windows: parts, age };
8067
8067
  }
@@ -8072,25 +8072,36 @@ function withShortNames(windows) {
8072
8072
  }
8073
8073
  return windows;
8074
8074
  }
8075
- function scopedWindowParts(quota, options) {
8075
+ function hasWindowReading(limit) {
8076
+ return Number.isFinite(limit.remainingPercent) && Number.isFinite(limit.checkedAt);
8077
+ }
8078
+ function scopedWindowParts(quota, options, includeUnknown = false) {
8076
8079
  if (!quota)
8077
8080
  return { windows: [] };
8078
8081
  const { now } = options;
8079
- const readings = quota.limits.filter((limit) => limit.kind === "reading" && limit.remainingPercent !== void 0).sort(displayOrder);
8082
+ const readings = quota.limits.filter((limit) => limit.kind === "reading" && (includeUnknown || hasWindowReading(limit))).sort(displayOrder);
8080
8083
  const windows = readings.map((limit) => {
8081
- const remainingPercent = clampPercent(limit.remainingPercent ?? 0);
8084
+ const part = hasWindowReading(limit) ? {
8085
+ kind: "window",
8086
+ reading: "known",
8087
+ name: quotaWindowName(limit),
8088
+ short: "",
8089
+ figure: percentLeft(limit.remainingPercent),
8090
+ remainingPercent: clampPercent(limit.remainingPercent),
8091
+ checkedAt: limit.checkedAt,
8092
+ ...resetDetails(limit.resetsAt, limit.checkedAt, now)
8093
+ } : {
8094
+ kind: "window",
8095
+ reading: "unknown",
8096
+ name: quotaWindowName(limit),
8097
+ short: "",
8098
+ figure: "no reading",
8099
+ resetSinceReading: false
8100
+ };
8082
8101
  return {
8083
8102
  scope: limit.scope,
8084
8103
  ...limit.windowMinutes === void 0 ? {} : { windowMinutes: limit.windowMinutes },
8085
- part: {
8086
- kind: "window",
8087
- name: quotaWindowName(limit),
8088
- short: "",
8089
- figure: percentLeft(limit.remainingPercent ?? 0),
8090
- remainingPercent,
8091
- checkedAt: limit.checkedAt,
8092
- ...resetDetails(limit.resetsAt, limit.checkedAt, now)
8093
- }
8104
+ part
8094
8105
  };
8095
8106
  });
8096
8107
  const budget = quota.budget;
@@ -8102,6 +8113,7 @@ function scopedWindowParts(quota, options) {
8102
8113
  spent: budget.reached,
8103
8114
  part: {
8104
8115
  kind: "budget",
8116
+ reading: "known",
8105
8117
  name: "credits",
8106
8118
  short: "",
8107
8119
  figure,
@@ -8112,8 +8124,9 @@ function scopedWindowParts(quota, options) {
8112
8124
  });
8113
8125
  }
8114
8126
  withShortNames(windows);
8115
- if (windows.length > 0) {
8116
- const age = now - Math.min(...windows.map(({ part }) => part.checkedAt));
8127
+ const readingTimes = windows.flatMap(({ part }) => part.reading === "known" && part.checkedAt !== void 0 ? [part.checkedAt] : []);
8128
+ if (readingTimes.length > 0) {
8129
+ const age = now - Math.min(...readingTimes);
8117
8130
  if (age > (options.staleAfterMs ?? QUOTA_STALE_AFTER_MS)) {
8118
8131
  return { windows, age: `checked ${shortSpan(age)} ago` };
8119
8132
  }
@@ -8212,13 +8225,13 @@ function narrowTextParts(quota, options) {
8212
8225
  function quotaTextParts(quota, options) {
8213
8226
  if (options.form === "narrow")
8214
8227
  return narrowTextParts(quota, options);
8215
- const parts = quotaWindowParts(quota, options);
8228
+ const { windows, age } = scopedWindowParts(quota, options);
8216
8229
  const full = (options.form ?? "full") === "full";
8217
- const text2 = parts.windows.map((part) => {
8230
+ const text2 = windows.map(({ part }) => {
8218
8231
  const reset = full && part.resetIn ? `, resets ${part.resetIn}` : "";
8219
8232
  return `${part.kind === "budget" ? "" : `${part.name} `}${part.figure}${reset}`;
8220
8233
  });
8221
- return parts.age === void 0 ? text2 : [...text2, parts.age];
8234
+ return age === void 0 ? text2 : [...text2, age];
8222
8235
  }
8223
8236
  function formatQuota(quota, options) {
8224
8237
  const parts = quotaTextParts(quota, options);
@@ -8650,8 +8663,8 @@ async function acquireRefreshFileLockWithClock(options) {
8650
8663
  let releaseConfirmed = false;
8651
8664
  let loss;
8652
8665
  let resolveLoss;
8653
- const lostPromise = new Promise((resolve21) => {
8654
- resolveLoss = resolve21;
8666
+ const lostPromise = new Promise((resolve22) => {
8667
+ resolveLoss = resolve22;
8655
8668
  });
8656
8669
  function notifyTimerStep(event) {
8657
8670
  try {
@@ -8812,7 +8825,7 @@ async function acquireRefreshFileLockWithClock(options) {
8812
8825
  }
8813
8826
  }
8814
8827
  async function backoff() {
8815
- await new Promise((resolve21) => setTimeout(resolve21, Math.floor(Math.random() * 4)));
8828
+ await new Promise((resolve22) => setTimeout(resolve22, Math.floor(Math.random() * 4)));
8816
8829
  }
8817
8830
  async function readLockState(notifyReady = true) {
8818
8831
  if (notifyReady && options.onStep)
@@ -9302,7 +9315,7 @@ async function acquireRefreshFileLockWithClock(options) {
9302
9315
  const remainingMs = deadline - performance.now();
9303
9316
  if (remainingMs <= 0)
9304
9317
  break;
9305
- await new Promise((resolve21) => setTimeout(resolve21, Math.min(delayMs, remainingMs)));
9318
+ await new Promise((resolve22) => setTimeout(resolve22, Math.min(delayMs, remainingMs)));
9306
9319
  delayMs = Math.min(delayMs * 2, 50);
9307
9320
  }
9308
9321
  if (windowsPrivateFiles)
@@ -9325,21 +9338,37 @@ var init_refresh_file_lock = __esm({
9325
9338
  });
9326
9339
 
9327
9340
  // ../core/dist/common-auth-embedded/fs/with-lock.js
9341
+ import { join as join6, resolve as resolve3 } from "node:path";
9328
9342
  function lockPathFor(target, name) {
9329
9343
  return `${target}.${name}.lock`;
9330
9344
  }
9345
+ function isChangingLockRead(error, target, name) {
9346
+ if (!windowsPrivateFiles || !(error instanceof PrivateFileError) || error.reason !== "io-error" || error.win32Code !== 32 && error.win32Code !== 303 || error.stage !== "read" && error.stage !== "verify")
9347
+ return false;
9348
+ const path2 = resolve3(lockPathFor(target, name));
9349
+ return error.path === path2 || error.path === join6(path2, "owner.json");
9350
+ }
9331
9351
  async function withLock(target, options, fn) {
9332
9352
  const started = performance.now();
9333
9353
  for (; ; ) {
9334
9354
  options.signal?.throwIfAborted();
9335
- const lock = await acquireRefreshFileLock({
9336
- path: target,
9337
- name: options.name,
9338
- ttlMs: options.ttlMs,
9339
- renew: options.renew ?? false,
9340
- ...options.onStep ? { onStep: options.onStep } : {},
9341
- ...options.onRenewalTimer ? { onRenewalTimer: options.onRenewalTimer } : {}
9342
- });
9355
+ let lock;
9356
+ let changingReadError;
9357
+ try {
9358
+ lock = await acquireRefreshFileLock({
9359
+ path: target,
9360
+ name: options.name,
9361
+ ttlMs: options.ttlMs,
9362
+ renew: options.renew ?? false,
9363
+ ...options.onStep ? { onStep: options.onStep } : {},
9364
+ ...options.onRenewalTimer ? { onRenewalTimer: options.onRenewalTimer } : {}
9365
+ });
9366
+ } catch (error) {
9367
+ if (!isChangingLockRead(error, target, options.name))
9368
+ throw error;
9369
+ lock = null;
9370
+ changingReadError = error;
9371
+ }
9343
9372
  if (lock) {
9344
9373
  try {
9345
9374
  options.signal?.throwIfAborted();
@@ -9350,19 +9379,22 @@ async function withLock(target, options, fn) {
9350
9379
  }
9351
9380
  const remaining = options.timeoutMs - (performance.now() - started);
9352
9381
  if (remaining <= 0) {
9382
+ if (changingReadError)
9383
+ throw changingReadError;
9353
9384
  throw new LockContentionError({
9354
9385
  target,
9355
9386
  name: options.name,
9356
9387
  timeoutMs: options.timeoutMs
9357
9388
  });
9358
9389
  }
9359
- await new Promise((resolve21) => setTimeout(resolve21, Math.min(25, Math.ceil(remaining))));
9390
+ await new Promise((resolve22) => setTimeout(resolve22, Math.min(25, Math.ceil(remaining))));
9360
9391
  }
9361
9392
  }
9362
9393
  var LockContentionError, LockOwnershipError;
9363
9394
  var init_with_lock = __esm({
9364
9395
  "../core/dist/common-auth-embedded/fs/with-lock.js"() {
9365
9396
  "use strict";
9397
+ init_private_files();
9366
9398
  init_refresh_file_lock();
9367
9399
  LockContentionError = class extends Error {
9368
9400
  details;
@@ -9475,7 +9507,7 @@ async function acquirePoolLock(spec, defaults, env3) {
9475
9507
  });
9476
9508
  }
9477
9509
  const jitter = Math.floor(Math.random() * (options.retryMs + 1));
9478
- await new Promise((resolve21) => setTimeout(resolve21, Math.min(options.retryMs + jitter, remaining)));
9510
+ await new Promise((resolve22) => setTimeout(resolve22, Math.min(options.retryMs + jitter, remaining)));
9479
9511
  }
9480
9512
  }
9481
9513
  function definedOnly(spec) {
@@ -12319,7 +12351,7 @@ var init_redact = __esm({
12319
12351
  // ../core/dist/common-auth-embedded/logger/engine.js
12320
12352
  import { appendFileSync, chmodSync, existsSync, renameSync, statSync } from "node:fs";
12321
12353
  import { open as open5 } from "node:fs/promises";
12322
- import { dirname as dirname8, resolve as resolve3 } from "node:path";
12354
+ import { dirname as dirname8, resolve as resolve4 } from "node:path";
12323
12355
  function chmodPrivate(path2) {
12324
12356
  try {
12325
12357
  chmodSync(path2, 384);
@@ -12370,7 +12402,7 @@ async function openWindowsFile(sink, file) {
12370
12402
  return sink.handle;
12371
12403
  }
12372
12404
  async function flushWindowsFile(sink, file, text2) {
12373
- file = resolve3(file);
12405
+ file = resolve4(file);
12374
12406
  try {
12375
12407
  if (sink.file !== file)
12376
12408
  await closeWindowsFile(sink);
@@ -12517,7 +12549,7 @@ function createEngine(options) {
12517
12549
  });
12518
12550
  }, 500);
12519
12551
  }
12520
- function emit(channel, level, message, data) {
12552
+ function emit(channel3, level, message, data) {
12521
12553
  if (logFileSource === void 0 && captureSink === void 0)
12522
12554
  return;
12523
12555
  try {
@@ -12530,10 +12562,10 @@ function createEngine(options) {
12530
12562
  } catch {
12531
12563
  scrubbedData = "[unserializable]";
12532
12564
  }
12533
- const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${level.toUpperCase()} [${channel}] ${scrubbedMessage}` + (data === void 0 ? "" : safeSerialize(scrubbedData)) + "\n";
12565
+ const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${level.toUpperCase()} [${channel3}] ${scrubbedMessage}` + (data === void 0 ? "" : safeSerialize(scrubbedData)) + "\n";
12534
12566
  try {
12535
12567
  captureSink?.({
12536
- channel,
12568
+ channel: channel3,
12537
12569
  level,
12538
12570
  message: scrubbedMessage,
12539
12571
  data: scrubbedData
@@ -12553,13 +12585,13 @@ function createEngine(options) {
12553
12585
  } catch {
12554
12586
  }
12555
12587
  }
12556
- function createLogger5(channel) {
12588
+ function createLogger5(channel3) {
12557
12589
  return {
12558
- error: (m, d) => emit(channel, "error", m, d),
12559
- warn: (m, d) => emit(channel, "warn", m, d),
12560
- info: (m, d) => emit(channel, "info", m, d),
12561
- debug: (m, d) => emit(channel, "debug", m, d),
12562
- trace: (m, d) => emit(channel, "trace", m, d)
12590
+ error: (m, d) => emit(channel3, "error", m, d),
12591
+ warn: (m, d) => emit(channel3, "warn", m, d),
12592
+ info: (m, d) => emit(channel3, "info", m, d),
12593
+ debug: (m, d) => emit(channel3, "debug", m, d),
12594
+ trace: (m, d) => emit(channel3, "trace", m, d)
12563
12595
  };
12564
12596
  }
12565
12597
  function reset() {
@@ -12597,8 +12629,8 @@ function setLogLevel(l) {
12597
12629
  function flushLogs() {
12598
12630
  return defaultEngine.flushLogs();
12599
12631
  }
12600
- function createLogger2(channel) {
12601
- return defaultEngine.createLogger(channel);
12632
+ function createLogger2(channel3) {
12633
+ return defaultEngine.createLogger(channel3);
12602
12634
  }
12603
12635
  async function flushForTest() {
12604
12636
  return defaultEngine.flushLogs();
@@ -12746,11 +12778,11 @@ var init_quota_writer = __esm({
12746
12778
  const left = deadline - performance.now();
12747
12779
  if (left <= 0)
12748
12780
  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);
12749
- await new Promise((resolve21) => {
12781
+ await new Promise((resolve22) => {
12750
12782
  const done = () => {
12751
12783
  clearTimeout(timer);
12752
12784
  this.wake.delete(done);
12753
- resolve21();
12785
+ resolve22();
12754
12786
  };
12755
12787
  const timer = setTimeout(done, left);
12756
12788
  this.wake.add(done);
@@ -13143,7 +13175,7 @@ var init_refresh = __esm({
13143
13175
 
13144
13176
  // ../core/dist/common-auth-embedded/fs/file-read-cache.js
13145
13177
  import { lstat as lstat4 } from "node:fs/promises";
13146
- import { resolve as resolve4 } from "node:path";
13178
+ import { resolve as resolve5 } from "node:path";
13147
13179
  async function identity(path2) {
13148
13180
  try {
13149
13181
  const metadata = await lstat4(path2);
@@ -13164,7 +13196,7 @@ var init_file_read_cache = __esm({
13164
13196
  FileReadCache = class {
13165
13197
  #entries = /* @__PURE__ */ new Map();
13166
13198
  async read(paths, read, validateHit) {
13167
- const resolvedPaths = paths.map((path2) => resolve4(path2));
13199
+ const resolvedPaths = paths.map((path2) => resolve5(path2));
13168
13200
  const key = JSON.stringify(resolvedPaths);
13169
13201
  const probed = await Promise.all(resolvedPaths.map(identity));
13170
13202
  const identities = probed.every((entry) => entry !== void 0) ? probed : void 0;
@@ -15521,7 +15553,7 @@ async function select(terminal, items, options) {
15521
15553
  writeLine("");
15522
15554
  renderedLines = lines;
15523
15555
  };
15524
- return new Promise((resolve21) => {
15556
+ return new Promise((resolve22) => {
15525
15557
  const wasRaw = stdin.isRaw ?? false;
15526
15558
  const cleanup2 = () => {
15527
15559
  if (cleaned)
@@ -15541,7 +15573,7 @@ async function select(terminal, items, options) {
15541
15573
  };
15542
15574
  const finish = (value) => {
15543
15575
  cleanup2();
15544
- resolve21(value);
15576
+ resolve22(value);
15545
15577
  };
15546
15578
  const onSignal = () => finish(null);
15547
15579
  const onKey = (data) => {
@@ -15581,7 +15613,7 @@ async function select(terminal, items, options) {
15581
15613
  stdin.setRawMode(true);
15582
15614
  } catch {
15583
15615
  cleanup2();
15584
- resolve21(null);
15616
+ resolve22(null);
15585
15617
  return;
15586
15618
  }
15587
15619
  stdin.resume();
@@ -16423,7 +16455,7 @@ var init_watch = __esm({
16423
16455
  });
16424
16456
 
16425
16457
  // ../core/dist/common-auth-embedded/claustrum/insula.js
16426
- import { resolve as resolve5 } from "node:path";
16458
+ import { resolve as resolve6 } from "node:path";
16427
16459
  import { storeIdentity } from "@cortexkit/claustrum-client";
16428
16460
  import { SubcClient } from "@cortexkit/subc-client";
16429
16461
  function insulaUsageTransport(options) {
@@ -16551,8 +16583,8 @@ function refusalCode(error) {
16551
16583
  }
16552
16584
  function acquireInsulaQuotaSource(transport, tokenPath) {
16553
16585
  const key = JSON.stringify([
16554
- resolve5(transport.connectionFile),
16555
- resolve5(tokenPath)
16586
+ resolve6(transport.connectionFile),
16587
+ resolve6(tokenPath)
16556
16588
  ]);
16557
16589
  let shared3 = sources.get(key);
16558
16590
  if (!shared3) {
@@ -16806,6 +16838,8 @@ var init_insula = __esm({
16806
16838
  ...typeof entry.source === "string" && { source: entry.source }
16807
16839
  }
16808
16840
  };
16841
+ if (entry.stale !== void 0 && (!record2(entry.stale) || entry.stale.class !== "local_source_unavailable"))
16842
+ return { miss: "upstream-failed", reading };
16809
16843
  return now >= fetchedAt + MAX_AGE || entry.stale !== void 0 ? { miss: "stale", reading } : { reading };
16810
16844
  }
16811
16845
  if (this.#completeProviders.has(provider2))
@@ -16864,7 +16898,7 @@ var init_any_signal = __esm({
16864
16898
  import { createHash as createHash5, randomBytes as randomBytes2, randomUUID as randomUUID10 } from "node:crypto";
16865
16899
  import { constants as fsConstants } from "node:fs";
16866
16900
  import { chmod as chmod2, mkdir as mkdir8, open as open6, readFile as readFile6, realpath as realpath3, rename as rename7, stat as stat4, unlink as unlink6 } from "node:fs/promises";
16867
- import { basename as basename3, dirname as dirname9, extname, isAbsolute as isAbsolute2, join as join6, resolve as resolve6 } from "node:path";
16901
+ import { basename as basename3, dirname as dirname9, extname, isAbsolute as isAbsolute2, join as join7, resolve as resolve7 } from "node:path";
16868
16902
  import { ClaustrumCredentialError as ClaustrumCredentialError2, ClaustrumClient as ClaustrumWireClient, writeEnrollmentTokenFile } from "@cortexkit/claustrum-client";
16869
16903
  function classifyEnrollmentError(error) {
16870
16904
  if (!(error instanceof ClaustrumCredentialError2))
@@ -16890,7 +16924,7 @@ function getClaustrumEnrollmentPaths(tokenPath) {
16890
16924
  const extension = extname(tokenPath) || ".json";
16891
16925
  const stem = basename3(tokenPath, extname(tokenPath));
16892
16926
  return {
16893
- statePath: join6(dirname9(tokenPath), `${stem}-state${extension}`),
16927
+ statePath: join7(dirname9(tokenPath), `${stem}-state${extension}`),
16894
16928
  tokenPath
16895
16929
  };
16896
16930
  }
@@ -16898,7 +16932,7 @@ function hostEnrollmentPaths(input) {
16898
16932
  const override = input.override?.trim();
16899
16933
  if (override && !isAbsolute2(override) && !input.cwd)
16900
16934
  throw new ClaustrumConsumerError("invalid-state", "A relative Claustrum enrollment override needs a base directory");
16901
- const tokenPath = override ? isAbsolute2(override) ? override : resolve6(input.cwd, override) : join6(input.stateDir, `${input.host}-enrollment.json`);
16935
+ const tokenPath = override ? isAbsolute2(override) ? override : resolve7(input.cwd, override) : join7(input.stateDir, `${input.host}-enrollment.json`);
16902
16936
  return getClaustrumEnrollmentPaths(tokenPath);
16903
16937
  }
16904
16938
  function isRecord6(value) {
@@ -17131,7 +17165,7 @@ async function writeStateAtomic(path2, state, ancestorOptions = {}) {
17131
17165
  }
17132
17166
  if (windowsPrivateFiles)
17133
17167
  return writePrivateAtomic(path2, bytes);
17134
- const temporary = join6(parent, `.${basename3(path2)}.${process.pid}.${randomUUID10()}.tmp`);
17168
+ const temporary = join7(parent, `.${basename3(path2)}.${process.pid}.${randomUUID10()}.tmp`);
17135
17169
  let descriptor;
17136
17170
  let created = false;
17137
17171
  try {
@@ -17627,10 +17661,10 @@ async function drainShutdown(pending, onTimeout) {
17627
17661
  try {
17628
17662
  await Promise.race([
17629
17663
  drained,
17630
- new Promise((resolve21) => {
17664
+ new Promise((resolve22) => {
17631
17665
  timer = setTimeout(() => {
17632
17666
  expired = true;
17633
- resolve21();
17667
+ resolve22();
17634
17668
  }, 2e3);
17635
17669
  })
17636
17670
  ]);
@@ -17648,6 +17682,7 @@ var init_shutdown = __esm({
17648
17682
  });
17649
17683
 
17650
17684
  // ../core/dist/common-auth-embedded/claustrum/custody.js
17685
+ import { channel } from "node:diagnostics_channel";
17651
17686
  import { ClaustrumCredentialError as ClaustrumCredentialError3 } from "@cortexkit/claustrum-client";
17652
17687
  function isScopedCredentialRotation(served, current) {
17653
17688
  return current !== void 0 && !current.fromKeptReceipt && !served.fromKeptReceipt && current.credentialId === served.credentialId && current.accountIdentity === served.accountIdentity && current.recordVersion !== served.recordVersion;
@@ -17761,7 +17796,7 @@ function grantReachOf(listed) {
17761
17796
  tuples: Object.freeze(grantTuples.map(({ selectorKind, selector, operation }) => Object.freeze({ selectorKind, selector, operation })))
17762
17797
  });
17763
17798
  }
17764
- var defaultLogger, SERVING_MARGIN_MS, KEPT_RECEIPT_MARGIN_MS, ClaustrumScopedCustody;
17799
+ var defaultLogger, phaseDiagnostics, SERVING_MARGIN_MS, KEPT_RECEIPT_MARGIN_MS, ClaustrumScopedCustody;
17765
17800
  var init_custody = __esm({
17766
17801
  "../core/dist/common-auth-embedded/claustrum/custody.js"() {
17767
17802
  "use strict";
@@ -17773,6 +17808,7 @@ var init_custody = __esm({
17773
17808
  init_shutdown();
17774
17809
  init_watch();
17775
17810
  defaultLogger = createLogger2("claustrum");
17811
+ phaseDiagnostics = channel("common-auth.claustrum.phases");
17776
17812
  SERVING_MARGIN_MS = 3e5;
17777
17813
  KEPT_RECEIPT_MARGIN_MS = 6e4;
17778
17814
  ClaustrumScopedCustody = class {
@@ -17876,6 +17912,11 @@ var init_custody = __esm({
17876
17912
  }
17877
17913
  async #token(signal) {
17878
17914
  this.#check(signal);
17915
+ if (phaseDiagnostics.hasSubscribers)
17916
+ phaseDiagnostics.publish({
17917
+ logger: this.#logger,
17918
+ phase: "token read begin"
17919
+ });
17879
17920
  const pending = this.#readToken();
17880
17921
  this.#tokenReads.add(pending);
17881
17922
  let value;
@@ -17883,6 +17924,11 @@ var init_custody = __esm({
17883
17924
  value = await pending;
17884
17925
  } finally {
17885
17926
  this.#tokenReads.delete(pending);
17927
+ if (phaseDiagnostics.hasSubscribers)
17928
+ phaseDiagnostics.publish({
17929
+ logger: this.#logger,
17930
+ phase: "token read end"
17931
+ });
17886
17932
  }
17887
17933
  this.#check(signal);
17888
17934
  if (!/^[0-9a-f]{64}$/.test(value.token) || !Number.isSafeInteger(value.token_generation) || value.token_generation < 1) {
@@ -17944,11 +17990,22 @@ var init_custody = __esm({
17944
17990
  this.#kept.clear();
17945
17991
  throw error;
17946
17992
  }
17993
+ if (phaseDiagnostics.hasSubscribers)
17994
+ phaseDiagnostics.publish({
17995
+ logger: this.#logger,
17996
+ phase: "list scoped begin"
17997
+ });
17947
17998
  try {
17948
17999
  inventory = await this.#call(() => this.#client.listScoped(token), signal);
17949
18000
  } catch (error) {
17950
18001
  this.listFailed(error);
17951
18002
  throw error;
18003
+ } finally {
18004
+ if (phaseDiagnostics.hasSubscribers)
18005
+ phaseDiagnostics.publish({
18006
+ logger: this.#logger,
18007
+ phase: "list scoped end"
18008
+ });
17952
18009
  }
17953
18010
  const skipped = [];
17954
18011
  const refused2 = [];
@@ -18377,7 +18434,7 @@ var init_interlock = __esm({
18377
18434
  // ../core/dist/common-auth-embedded/claustrum/roster.js
18378
18435
  import { createHash as createHash6 } from "node:crypto";
18379
18436
  import { stat as stat5 } from "node:fs/promises";
18380
- import { resolve as resolve7 } from "node:path";
18437
+ import { resolve as resolve8 } from "node:path";
18381
18438
  function vaultRosterSeed(roster) {
18382
18439
  return {
18383
18440
  declined: roster.declined.map((entry) => ({ ...entry })),
@@ -18764,16 +18821,16 @@ function applyVaultQuota(current, input) {
18764
18821
  };
18765
18822
  }
18766
18823
  function forgetPendingVaultDiscovery(path2) {
18767
- pendingDiscoveries.delete(resolve7(path2));
18824
+ pendingDiscoveries.delete(resolve8(path2));
18768
18825
  }
18769
18826
  function isVaultRosterLockRefusal(path2, error) {
18770
- const target = resolve7(path2);
18827
+ const target = resolve8(path2);
18771
18828
  if (error instanceof ClaustrumConsumerError)
18772
18829
  return error.kind === "roster-busy";
18773
18830
  if (error instanceof LockContentionError || error instanceof LockOwnershipError)
18774
- return resolve7(error.details.target) === target;
18831
+ return resolve8(error.details.target) === target;
18775
18832
  if (error instanceof PrivateFileError) {
18776
- const failed = resolve7(error.path);
18833
+ const failed = resolve8(error.path);
18777
18834
  return [WRITE_LOCK.name, DISCOVERY_LEASE.name].some((name) => {
18778
18835
  const lock = lockPathFor(target, name);
18779
18836
  return failed === lock || failed.startsWith(`${lock}.`);
@@ -18834,7 +18891,7 @@ async function refreshVaultRoster(options) {
18834
18891
  throw new ClaustrumConsumerError("roster-busy", "Claustrum account discovery is already in progress");
18835
18892
  return persisted;
18836
18893
  }
18837
- const key = resolve7(options.path);
18894
+ const key = resolve8(options.path);
18838
18895
  const listedOver = options.listedOver;
18839
18896
  let discovered;
18840
18897
  try {
@@ -18954,9 +19011,9 @@ var init_roster = __esm({
18954
19011
  });
18955
19012
 
18956
19013
  // ../core/dist/common-auth-embedded/claustrum/quota-writer.js
18957
- import { resolve as resolve8 } from "node:path";
19014
+ import { resolve as resolve9 } from "node:path";
18958
19015
  function writerFor(path2, clock = quotaCommitTimer) {
18959
- const key = resolve8(path2);
19016
+ const key = resolve9(path2);
18960
19017
  let writer = writers.get(key);
18961
19018
  if (!writer) {
18962
19019
  writer = {
@@ -19020,7 +19077,7 @@ function orderedFields(pending) {
19020
19077
  return [...pending.values()].flatMap((account) => [...account.values()]).sort((a, b) => a.order - b.order);
19021
19078
  }
19022
19079
  function pendingVaultQuota(path2, roster) {
19023
- const writer = writers.get(resolve8(path2));
19080
+ const writer = writers.get(resolve9(path2));
19024
19081
  if (writer) {
19025
19082
  for (const field of orderedFields(writer.pending)) {
19026
19083
  if (field.priorReading)
@@ -19031,7 +19088,7 @@ function pendingVaultQuota(path2, roster) {
19031
19088
  return roster;
19032
19089
  }
19033
19090
  function hasPendingVaultQuota(path2) {
19034
- return !!writers.get(resolve8(path2))?.pending.size;
19091
+ return !!writers.get(resolve9(path2))?.pending.size;
19035
19092
  }
19036
19093
  function schedule(writer, delay3) {
19037
19094
  if (writer.running || writer.timer || !writer.pending.size || writer.abort.signal.aborted)
@@ -19096,7 +19153,7 @@ function flush(writer) {
19096
19153
  return writer.running;
19097
19154
  }
19098
19155
  async function drainVaultQuota(path2, timeoutMs = 1e3) {
19099
- const key = resolve8(path2);
19156
+ const key = resolve9(path2);
19100
19157
  const writer = writers.get(key);
19101
19158
  if (!writer)
19102
19159
  return;
@@ -19241,7 +19298,7 @@ var init_consumer = __esm({
19241
19298
  this.#shutdown.signal,
19242
19299
  ...signal ? [signal] : []
19243
19300
  ]);
19244
- return new Promise((resolve21, reject) => {
19301
+ return new Promise((resolve22, reject) => {
19245
19302
  const cleanup2 = () => {
19246
19303
  combined.signal.removeEventListener("abort", abort);
19247
19304
  combined.dispose();
@@ -19256,7 +19313,7 @@ var init_consumer = __esm({
19256
19313
  if (combined.signal.aborted)
19257
19314
  reject(combined.signal.reason);
19258
19315
  else
19259
- resolve21(value);
19316
+ resolve22(value);
19260
19317
  }, (error) => {
19261
19318
  cleanup2();
19262
19319
  reject(error);
@@ -19968,8 +20025,9 @@ var init_consumer = __esm({
19968
20025
 
19969
20026
  // ../core/dist/common-auth-embedded/claustrum/hub.js
19970
20027
  import { createHash as createHash7 } from "node:crypto";
20028
+ import { channel as channel2 } from "node:diagnostics_channel";
19971
20029
  import { readdir, stat as stat6 } from "node:fs/promises";
19972
- import { dirname as dirname10, join as join7, resolve as resolve9 } from "node:path";
20030
+ import { dirname as dirname10, join as join8, resolve as resolve10 } from "node:path";
19973
20031
  function canonicalJson3(value, path2 = /* @__PURE__ */ new Set()) {
19974
20032
  if (value === null)
19975
20033
  return "null";
@@ -20030,12 +20088,12 @@ function unreachableConnect2() {
20030
20088
  return new ClaustrumUnreachableError();
20031
20089
  }
20032
20090
  function untilAborted(pending, signal) {
20033
- return new Promise((resolve21, reject) => {
20091
+ return new Promise((resolve22, reject) => {
20034
20092
  const abort = () => reject(signal.reason);
20035
20093
  signal.addEventListener("abort", abort, { once: true });
20036
20094
  pending.then((value) => {
20037
20095
  signal.removeEventListener("abort", abort);
20038
- resolve21(value);
20096
+ resolve22(value);
20039
20097
  }, (error) => {
20040
20098
  signal.removeEventListener("abort", abort);
20041
20099
  reject(error);
@@ -20105,13 +20163,13 @@ var init_hub = __esm({
20105
20163
  this.#options = options;
20106
20164
  this.#logger = options.logger ?? createLogger2("claustrum");
20107
20165
  this.#warnShutdown = shutdownWarning(this.#logger, this.#shutdown.signal);
20108
- this.#generationDirectory = join7(options.stateDir, "rosters", hostGeneration);
20166
+ this.#generationDirectory = join8(options.stateDir, "rosters", hostGeneration);
20109
20167
  this.#key = rosterFingerprint(options, providers);
20110
- const directory = join7(this.#generationDirectory, this.#key);
20168
+ const directory = join8(this.#generationDirectory, this.#key);
20111
20169
  for (const provider2 of providers)
20112
20170
  this.#members.set(provider2, {
20113
20171
  provider: provider2,
20114
- path: join7(directory, `${provider2}.json`),
20172
+ path: join8(directory, `${provider2}.json`),
20115
20173
  closed: false
20116
20174
  });
20117
20175
  }
@@ -20192,7 +20250,7 @@ var init_hub = __esm({
20192
20250
  };
20193
20251
  const { consumer, hooks } = createHubMember(port, consumerOptions);
20194
20252
  entry.hooks = hooks;
20195
- const path2 = resolve9(entry.path);
20253
+ const path2 = resolve10(entry.path);
20196
20254
  const subscribers = sharedRosters.get(path2) ?? /* @__PURE__ */ new Set();
20197
20255
  const install = (roster) => {
20198
20256
  if (entry.closed || this.#active !== true || !this.#current || !this.#live(this.#current) || !hooks.roster() || this.#collides(hooks, roster))
@@ -20223,7 +20281,7 @@ var init_hub = __esm({
20223
20281
  return;
20224
20282
  entry.seen = JSON.stringify(decodedVaultRoster(roster));
20225
20283
  entry.hooks?.install(roster);
20226
- for (const install of sharedRosters.get(resolve9(entry.path)) ?? []) {
20284
+ for (const install of sharedRosters.get(resolve10(entry.path)) ?? []) {
20227
20285
  if (!this.#live(generation))
20228
20286
  return;
20229
20287
  if (install !== entry.receiveRoster)
@@ -20634,7 +20692,24 @@ var init_hub = __esm({
20634
20692
  throw closed("Claustrum hub member has no base view");
20635
20693
  if (base instanceof Error)
20636
20694
  throw base;
20637
- const seed = base.file ? void 0 : await this.#seed(entry);
20695
+ let seed;
20696
+ if (!base.file) {
20697
+ const phaseDiagnostics2 = channel2("common-auth.claustrum.phases");
20698
+ if (phaseDiagnostics2.hasSubscribers)
20699
+ phaseDiagnostics2.publish({
20700
+ logger: this.#logger,
20701
+ phase: `seed read ${entry.provider} begin`
20702
+ });
20703
+ try {
20704
+ seed = await this.#seed(entry);
20705
+ } finally {
20706
+ if (phaseDiagnostics2.hasSubscribers)
20707
+ phaseDiagnostics2.publish({
20708
+ logger: this.#logger,
20709
+ phase: `seed read ${entry.provider} end`
20710
+ });
20711
+ }
20712
+ }
20638
20713
  const roster = await refreshVaultRoster({
20639
20714
  path: entry.path,
20640
20715
  custody: { discover: async () => share },
@@ -20662,7 +20737,7 @@ var init_hub = __esm({
20662
20737
  for (const directory of [
20663
20738
  dirname10(this.#generationDirectory),
20664
20739
  this.#generationDirectory,
20665
- join7(this.#generationDirectory, this.#key)
20740
+ join8(this.#generationDirectory, this.#key)
20666
20741
  ])
20667
20742
  await ensureClaustrumPrivateDirectory(directory, {}, "roster directory");
20668
20743
  }
@@ -20674,11 +20749,11 @@ var init_hub = __esm({
20674
20749
  */
20675
20750
  async #seed(entry) {
20676
20751
  const name = `${entry.provider}.json`;
20677
- const candidates = [join7(this.#generationDirectory, name)];
20752
+ const candidates = [join8(this.#generationDirectory, name)];
20678
20753
  try {
20679
20754
  for (const key of await readdir(this.#generationDirectory))
20680
20755
  if (key !== this.#key && FINGERPRINT.test(key))
20681
- candidates.push(join7(this.#generationDirectory, key, name));
20756
+ candidates.push(join8(this.#generationDirectory, key, name));
20682
20757
  } catch {
20683
20758
  }
20684
20759
  let newest;
@@ -21251,7 +21326,7 @@ var init_lock = __esm({
21251
21326
  import { createHash as createHash8 } from "node:crypto";
21252
21327
  import { constants as constants2 } from "node:fs";
21253
21328
  import { lstat as lstat5, mkdir as mkdir10, open as open7, unlink as unlink7 } from "node:fs/promises";
21254
- import { dirname as dirname11, resolve as resolve10 } from "node:path";
21329
+ import { dirname as dirname11, resolve as resolve11 } from "node:path";
21255
21330
  import { setTimeout as sleep2 } from "node:timers/promises";
21256
21331
  function rootSpans(text2) {
21257
21332
  let i = text2.indexOf("{") + 1;
@@ -21452,8 +21527,8 @@ function createPiSlot(options, onStep, hooks) {
21452
21527
  if (!provider2 || !options.authPath || !options.stashPath || !placeholderKey || placeholderKey.startsWith("!") || placeholderKey.includes("$") || !Number.isFinite(timeout) || timeout < 0) {
21453
21528
  throw new PiSlotError("invalid-options");
21454
21529
  }
21455
- const authPath = resolve10(options.authPath);
21456
- const stashPath = resolve10(options.stashPath);
21530
+ const authPath = resolve11(options.authPath);
21531
+ const stashPath = resolve11(options.stashPath);
21457
21532
  if (authPath === stashPath || stashPath === `${authPath}.lock`) {
21458
21533
  throw new PiSlotError("invalid-options");
21459
21534
  }
@@ -21679,15 +21754,15 @@ var init_model_types = __esm({
21679
21754
 
21680
21755
  // ../core/dist/pi-paths.js
21681
21756
  import { homedir } from "node:os";
21682
- import { dirname as dirname12, join as join8 } from "node:path";
21757
+ import { dirname as dirname12, join as join9 } from "node:path";
21683
21758
  function getPiConfigDir() {
21684
- return process.env.PI_AGENT_DIR?.trim() || join8(homedir(), ".pi", "agent");
21759
+ return process.env.PI_AGENT_DIR?.trim() || join9(homedir(), ".pi", "agent");
21685
21760
  }
21686
21761
  function getPiAntigravityAuthFile() {
21687
- return process.env.PI_ANTIGRAVITY_AUTH_FILE?.trim() || join8(getPiConfigDir(), "antigravity-accounts.json");
21762
+ return process.env.PI_ANTIGRAVITY_AUTH_FILE?.trim() || join9(getPiConfigDir(), "antigravity-accounts.json");
21688
21763
  }
21689
21764
  function getPiAntigravityVaultDir() {
21690
- return join8(dirname12(getPiAntigravityAuthFile()), "antigravity-auth-vault");
21765
+ return join9(dirname12(getPiAntigravityAuthFile()), "antigravity-auth-vault");
21691
21766
  }
21692
21767
  var init_pi_paths = __esm({
21693
21768
  "../core/dist/pi-paths.js"() {
@@ -21721,8 +21796,8 @@ function getDefaultTierId(allowedTiers) {
21721
21796
  return allowedTiers[0]?.id;
21722
21797
  }
21723
21798
  function wait(ms) {
21724
- return new Promise((resolve21) => {
21725
- setTimeout(resolve21, ms);
21799
+ return new Promise((resolve22) => {
21800
+ setTimeout(resolve22, ms);
21726
21801
  });
21727
21802
  }
21728
21803
  function extractManagedProjectId(payload) {
@@ -22744,7 +22819,7 @@ var init_capture_sink2 = __esm({
22744
22819
  import { randomUUID as randomUUID11 } from "node:crypto";
22745
22820
  import { lstat as lstat6, readFile as readFile7, rename as rename8, unlink as unlink8 } from "node:fs/promises";
22746
22821
  import { tmpdir as tmpdir2 } from "node:os";
22747
- import { dirname as dirname13, join as join9, resolve as resolve11 } from "node:path";
22822
+ import { dirname as dirname13, join as join10, resolve as resolve12 } from "node:path";
22748
22823
  function ioCode2(detail) {
22749
22824
  if (detail?.reason === "io-error") {
22750
22825
  if (detail.win32Code === 2 || detail.win32Code === 3)
@@ -22765,7 +22840,7 @@ function isUnavailable2(api, error) {
22765
22840
  }
22766
22841
  async function assertNativeAddonLoads2(api) {
22767
22842
  try {
22768
- await api.verifyPrivatePath(join9(tmpdir2(), `.common-auth-private-files-probe-${randomUUID11()}`), "file");
22843
+ await api.verifyPrivatePath(join10(tmpdir2(), `.common-auth-private-files-probe-${randomUUID11()}`), "file");
22769
22844
  } catch (error) {
22770
22845
  if (isUnavailable2(api, error))
22771
22846
  throw privateFilesUnavailable2(error);
@@ -22791,7 +22866,7 @@ async function privateOperation2(path2, stage, operation) {
22791
22866
  }
22792
22867
  }
22793
22868
  async function verifySafeDirectory2(path2, options) {
22794
- path2 = resolve11(path2);
22869
+ path2 = resolve12(path2);
22795
22870
  options ??= safeParentOptionsForTest2;
22796
22871
  await privateOperation2(path2, "safe-parent", async () => {
22797
22872
  const result = await (await loadBackend2()).verifySafeParent(path2, options);
@@ -22806,7 +22881,7 @@ async function verifySafeDirectory2(path2, options) {
22806
22881
  });
22807
22882
  }
22808
22883
  async function verifyPrivate2(path2, kind, migrate = false) {
22809
- path2 = resolve11(path2);
22884
+ path2 = resolve12(path2);
22810
22885
  if (kind === "directory")
22811
22886
  return verifySafeDirectory2(path2);
22812
22887
  await privateOperation2(path2, "verify", async () => {
@@ -22841,7 +22916,7 @@ async function verifyPrivate2(path2, kind, migrate = false) {
22841
22916
  });
22842
22917
  }
22843
22918
  async function ensurePrivateDirectory2(path2, _migrate = false, options) {
22844
- path2 = resolve11(path2);
22919
+ path2 = resolve12(path2);
22845
22920
  await privateOperation2(path2, "directory", async () => {
22846
22921
  const api = await loadBackend2();
22847
22922
  try {
@@ -22872,7 +22947,7 @@ async function readPrivateText2(path2, migrate = false) {
22872
22947
  async function readPrivateBuffer2(path2, migrate = false) {
22873
22948
  if (!windowsPrivateFiles2)
22874
22949
  return readFile7(path2);
22875
- path2 = resolve11(path2);
22950
+ path2 = resolve12(path2);
22876
22951
  if (migrate) {
22877
22952
  await verifySafeDirectory2(dirname13(path2));
22878
22953
  await verifyPrivate2(path2, "file", true);
@@ -22880,20 +22955,20 @@ async function readPrivateBuffer2(path2, migrate = false) {
22880
22955
  return privateOperation2(path2, "read", async () => (await loadBackend2()).readOwnerOnly(path2));
22881
22956
  }
22882
22957
  async function createPrivateBytes2(path2, bytes) {
22883
- await verifySafeDirectory2(dirname13(resolve11(path2)));
22958
+ await verifySafeDirectory2(dirname13(resolve12(path2)));
22884
22959
  await privateOperation2(path2, "create", async () => {
22885
- await (await loadBackend2()).createPrivateFile(resolve11(path2), bytes);
22960
+ await (await loadBackend2()).createPrivateFile(resolve12(path2), bytes);
22886
22961
  });
22887
22962
  }
22888
22963
  async function createPrivateDirectoryExclusive2(path2) {
22889
- await verifySafeDirectory2(dirname13(resolve11(path2)));
22964
+ await verifySafeDirectory2(dirname13(resolve12(path2)));
22890
22965
  await privateOperation2(path2, "directory-create", async () => {
22891
- await (await loadBackend2()).createOwnerOnly(resolve11(path2), { kind: "dir" });
22966
+ await (await loadBackend2()).createOwnerOnly(resolve12(path2), { kind: "dir" });
22892
22967
  });
22893
22968
  }
22894
22969
  async function replaceWindowsFile2(from, to, options = {}) {
22895
- from = resolve11(from);
22896
- to = resolve11(to);
22970
+ from = resolve12(from);
22971
+ to = resolve12(to);
22897
22972
  const now = options.now ?? (() => performance.now());
22898
22973
  const start = now();
22899
22974
  const leaseDeadline = options.deadline ?? Infinity;
@@ -22936,7 +23011,7 @@ async function replaceWindowsFile2(from, to, options = {}) {
22936
23011
  throw error;
22937
23012
  }
22938
23013
  async function writePrivateAtomic2(path2, bytes, options = {}) {
22939
- path2 = resolve11(path2);
23014
+ path2 = resolve12(path2);
22940
23015
  await ensurePrivateDirectory2(dirname13(path2));
22941
23016
  try {
22942
23017
  await verifyPrivate2(path2, "file", true);
@@ -22944,7 +23019,7 @@ async function writePrivateAtomic2(path2, bytes, options = {}) {
22944
23019
  if (error.code !== "ENOENT")
22945
23020
  throw error;
22946
23021
  }
22947
- const stage = resolve11(options.stagePath ?? `${path2}.${randomUUID11()}.tmp`);
23022
+ const stage = resolve12(options.stagePath ?? `${path2}.${randomUUID11()}.tmp`);
22948
23023
  if (dirname13(stage) !== dirname13(path2))
22949
23024
  throw new PrivateFileError2(path2, "stage-directory", { code: "EXDEV" });
22950
23025
  let created = false;
@@ -23110,7 +23185,7 @@ var init_redact2 = __esm({
23110
23185
  // src/common-auth-embedded/logger/engine.js
23111
23186
  import { appendFileSync as appendFileSync2, chmodSync as chmodSync2, existsSync as existsSync2, renameSync as renameSync2, statSync as statSync3 } from "node:fs";
23112
23187
  import { open as open8 } from "node:fs/promises";
23113
- import { dirname as dirname14, resolve as resolve12 } from "node:path";
23188
+ import { dirname as dirname14, resolve as resolve13 } from "node:path";
23114
23189
  function chmodPrivate2(path2) {
23115
23190
  try {
23116
23191
  chmodSync2(path2, 384);
@@ -23161,7 +23236,7 @@ async function openWindowsFile2(sink, file) {
23161
23236
  return sink.handle;
23162
23237
  }
23163
23238
  async function flushWindowsFile2(sink, file, text2) {
23164
- file = resolve12(file);
23239
+ file = resolve13(file);
23165
23240
  try {
23166
23241
  if (sink.file !== file)
23167
23242
  await closeWindowsFile2(sink);
@@ -23308,7 +23383,7 @@ function createEngine2(options) {
23308
23383
  });
23309
23384
  }, 500);
23310
23385
  }
23311
- function emit(channel, level, message, data) {
23386
+ function emit(channel3, level, message, data) {
23312
23387
  if (logFileSource === void 0 && captureSink === void 0)
23313
23388
  return;
23314
23389
  try {
@@ -23321,10 +23396,10 @@ function createEngine2(options) {
23321
23396
  } catch {
23322
23397
  scrubbedData = "[unserializable]";
23323
23398
  }
23324
- const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${level.toUpperCase()} [${channel}] ${scrubbedMessage}` + (data === void 0 ? "" : safeSerialize2(scrubbedData)) + "\n";
23399
+ const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${level.toUpperCase()} [${channel3}] ${scrubbedMessage}` + (data === void 0 ? "" : safeSerialize2(scrubbedData)) + "\n";
23325
23400
  try {
23326
23401
  captureSink?.({
23327
- channel,
23402
+ channel: channel3,
23328
23403
  level,
23329
23404
  message: scrubbedMessage,
23330
23405
  data: scrubbedData
@@ -23344,13 +23419,13 @@ function createEngine2(options) {
23344
23419
  } catch {
23345
23420
  }
23346
23421
  }
23347
- function createLogger5(channel) {
23422
+ function createLogger5(channel3) {
23348
23423
  return {
23349
- error: (m, d) => emit(channel, "error", m, d),
23350
- warn: (m, d) => emit(channel, "warn", m, d),
23351
- info: (m, d) => emit(channel, "info", m, d),
23352
- debug: (m, d) => emit(channel, "debug", m, d),
23353
- trace: (m, d) => emit(channel, "trace", m, d)
23424
+ error: (m, d) => emit(channel3, "error", m, d),
23425
+ warn: (m, d) => emit(channel3, "warn", m, d),
23426
+ info: (m, d) => emit(channel3, "info", m, d),
23427
+ debug: (m, d) => emit(channel3, "debug", m, d),
23428
+ trace: (m, d) => emit(channel3, "trace", m, d)
23354
23429
  };
23355
23430
  }
23356
23431
  function reset() {
@@ -23478,20 +23553,20 @@ import { randomUUID as randomUUID12 } from "node:crypto";
23478
23553
  import { realpathSync, rmSync } from "node:fs";
23479
23554
  import { chmod as chmod3, mkdir as mkdir11, readFile as readFile8, rename as rename9, rm as rm5, writeFile as writeFile3 } from "node:fs/promises";
23480
23555
  import { homedir as homedir2 } from "node:os";
23481
- import { join as join10, resolve as resolve13 } from "node:path";
23556
+ import { join as join11, resolve as resolve14 } from "node:path";
23482
23557
  function processHeartbeatDir() {
23483
- const base = process.env.XDG_STATE_HOME || join10(homedir2(), ".local", "state");
23484
- return join10(base, "cortexkit", "antigravity-auth", "processes");
23558
+ const base = process.env.XDG_STATE_HOME || join11(homedir2(), ".local", "state");
23559
+ return join11(base, "cortexkit", "antigravity-auth", "processes");
23485
23560
  }
23486
23561
  function processHeartbeatPath(pid = process.pid, dir = processHeartbeatDir()) {
23487
- return join10(dir, `${pid}.json`);
23562
+ return join11(dir, `${pid}.json`);
23488
23563
  }
23489
23564
  function processConfigFolderKey() {
23490
23565
  const folder = getConfigDir();
23491
23566
  try {
23492
23567
  return realpathSync.native(folder);
23493
23568
  } catch {
23494
- return resolve13(folder);
23569
+ return resolve14(folder);
23495
23570
  }
23496
23571
  }
23497
23572
  function processHasOlderGeneration() {
@@ -23729,15 +23804,15 @@ var init_process_heartbeat = __esm({
23729
23804
  // src/version-fence.ts
23730
23805
  import { readdir as readdir2, readFile as readFile9 } from "node:fs/promises";
23731
23806
  import { homedir as homedir3 } from "node:os";
23732
- import { join as join11 } from "node:path";
23807
+ import { join as join12 } from "node:path";
23733
23808
  function defaultStateHome() {
23734
- return process.env.XDG_STATE_HOME || join11(homedir3(), ".local", "state");
23809
+ return process.env.XDG_STATE_HOME || join12(homedir3(), ".local", "state");
23735
23810
  }
23736
23811
  function processHeartbeatDir2(stateHome = defaultStateHome()) {
23737
- return join11(stateHome, "cortexkit", "antigravity-auth", "processes");
23812
+ return join12(stateHome, "cortexkit", "antigravity-auth", "processes");
23738
23813
  }
23739
23814
  function rpcStateRoot(stateHome = defaultStateHome()) {
23740
- return join11(stateHome, "cortexkit", "antigravity-auth", "rpc");
23815
+ return join12(stateHome, "cortexkit", "antigravity-auth", "rpc");
23741
23816
  }
23742
23817
  function isRpcProjectDir(name) {
23743
23818
  return /^[0-9a-f]{16}$/.test(name);
@@ -23852,7 +23927,7 @@ async function versionFenceOpen(options) {
23852
23927
  for (const name of heartbeats.ok ? heartbeats.names : []) {
23853
23928
  const pid = pidFrom(name, /^(\d+)\.json$/);
23854
23929
  if (pid === void 0 || pid === self) continue;
23855
- const path2 = join11(heartbeatDir, name);
23930
+ const path2 = join12(heartbeatDir, name);
23856
23931
  const heartbeat = await readProcessRecord(path2, pid);
23857
23932
  if (heartbeat.kind === "gone") continue;
23858
23933
  if (!alive(pid)) continue;
@@ -23876,7 +23951,7 @@ async function versionFenceOpen(options) {
23876
23951
  block({ pid: "unknown", version: "unknown", detail: projects.error });
23877
23952
  for (const project2 of projects.ok ? projects.names : []) {
23878
23953
  if (!isRpcProjectDir(project2)) continue;
23879
- const dir = join11(rpcRoot, project2);
23954
+ const dir = join12(rpcRoot, project2);
23880
23955
  const ports = await list2(dir);
23881
23956
  if (!ports.ok) {
23882
23957
  if (ports.code === "ENOTDIR") continue;
@@ -23886,7 +23961,7 @@ async function versionFenceOpen(options) {
23886
23961
  for (const name of ports.names) {
23887
23962
  const pid = pidFrom(name, /^port-(\d+)\.json$/);
23888
23963
  if (pid === void 0 || pid === self || !alive(pid)) continue;
23889
- const path2 = join11(dir, name);
23964
+ const path2 = join12(dir, name);
23890
23965
  const port = await readProcessRecord(path2, pid);
23891
23966
  if (port.kind === "gone") continue;
23892
23967
  const version = port.kind === "ok" ? port.version : "unknown";
@@ -23937,7 +24012,7 @@ import {
23937
24012
  stat as stat8,
23938
24013
  unlink as unlink9
23939
24014
  } from "node:fs/promises";
23940
- import { basename as basename4, dirname as dirname15, join as join12, resolve as resolve14 } from "node:path";
24015
+ import { basename as basename4, dirname as dirname15, join as join13, resolve as resolve15 } from "node:path";
23941
24016
  function refusalMessage(stateDir, errorClass2) {
23942
24017
  if (errorClass2 === "ERR_PRIVATE_FILES_SECURITY")
23943
24018
  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.`;
@@ -24024,7 +24099,7 @@ function prepareRuntimeLayout(options) {
24024
24099
  async function decide(location, options) {
24025
24100
  const log8 = options.log ?? createLogger4("runtime-layout");
24026
24101
  const stateDir = location.stateHomeDir;
24027
- const markerPath = join12(stateDir, RUNTIME_LAYOUT_MARKER_FILE);
24102
+ const markerPath = join13(stateDir, RUNTIME_LAYOUT_MARKER_FILE);
24028
24103
  const files = layoutFiles(location, options.accountFile);
24029
24104
  const fence = options.fence ?? defaultFence(options.version);
24030
24105
  const stateHome = async () => {
@@ -24036,7 +24111,7 @@ async function decide(location, options) {
24036
24111
  if (marker?.oldFilesRemoved) {
24037
24112
  await refuseReappearedFiles(location, files);
24038
24113
  const manifestLeft = await exists2(
24039
- join12(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE)
24114
+ join13(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE)
24040
24115
  ).catch(() => true);
24041
24116
  if (!manifestLeft) {
24042
24117
  await settleVault(location, options, "state-home", log8);
@@ -24202,7 +24277,7 @@ async function prepareAccountStore(options) {
24202
24277
  await ensureOwnerOnlyDir(location.stateHomeDir);
24203
24278
  const lock = await takeLock(
24204
24279
  RUNTIME_LAYOUT_LOCK_NAME,
24205
- join12(location.stateHomeDir, RUNTIME_LAYOUT_MARKER_FILE),
24280
+ join13(location.stateHomeDir, RUNTIME_LAYOUT_MARKER_FILE),
24206
24281
  options.layoutLockWaitMs ?? LAYOUT_LOCK_WAIT_MS,
24207
24282
  log8
24208
24283
  );
@@ -24316,7 +24391,7 @@ async function recordAnchor(location, options, anchor, log8) {
24316
24391
  }
24317
24392
  async function storeMovePathResolves(stateAnchor, location, log8) {
24318
24393
  if (folderResolvesToItself(
24319
- join12(location.stateHomeDir, "antigravity-accounts.json")
24394
+ join13(location.stateHomeDir, "antigravity-accounts.json")
24320
24395
  ))
24321
24396
  return true;
24322
24397
  logOnce(
@@ -24684,7 +24759,7 @@ async function removeLeftoverManifest(location, layoutLock, steps, log8) {
24684
24759
  }
24685
24760
  }
24686
24761
  async function removeManifestOwned(stateDir, layoutLock, steps) {
24687
- const path2 = join12(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE);
24762
+ const path2 = join13(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE);
24688
24763
  if (!await exists2(path2)) return;
24689
24764
  await beforeRemove(path2, layoutLock, steps);
24690
24765
  await removeManifest(stateDir);
@@ -24724,7 +24799,7 @@ async function takeDataLocks(files, log8) {
24724
24799
  locks.push(
24725
24800
  await takeLock(
24726
24801
  lock.name,
24727
- join12(files.vault.old, lock.file),
24802
+ join13(files.vault.old, lock.file),
24728
24803
  lock.waitMs,
24729
24804
  log8
24730
24805
  )
@@ -24751,8 +24826,8 @@ function sha256(bytes) {
24751
24826
  }
24752
24827
  function vaultStateFile(files) {
24753
24828
  return {
24754
- old: join12(files.vault.old, VAULT_ENROLLMENT_STATE_FILE),
24755
- next: join12(files.vault.next, VAULT_ENROLLMENT_STATE_FILE)
24829
+ old: join13(files.vault.old, VAULT_ENROLLMENT_STATE_FILE),
24830
+ next: join13(files.vault.next, VAULT_ENROLLMENT_STATE_FILE)
24756
24831
  };
24757
24832
  }
24758
24833
  async function keepableVaultState(files, present2) {
@@ -24792,10 +24867,10 @@ async function isVaultShapedKeptState(files) {
24792
24867
  async function removeMovedVaultStateLeftover(vaultDir, accountFile) {
24793
24868
  const location = runtimeLayoutLocation();
24794
24869
  const files = layoutFiles(location, accountFile);
24795
- if (resolve14(vaultDir) !== resolve14(files.vault.next)) return;
24870
+ if (resolve15(vaultDir) !== resolve15(files.vault.next)) return;
24796
24871
  const stateDir = location.stateHomeDir;
24797
24872
  const marker = await readMarker(
24798
- join12(stateDir, RUNTIME_LAYOUT_MARKER_FILE),
24873
+ join13(stateDir, RUNTIME_LAYOUT_MARKER_FILE),
24799
24874
  stateDir,
24800
24875
  files.vault.old
24801
24876
  );
@@ -24824,13 +24899,13 @@ async function vaultFiles(dir) {
24824
24899
  }
24825
24900
  async function presentOldFiles(files) {
24826
24901
  return (await vaultFiles(files.vault.old)).map((name) => ({
24827
- old: join12(files.vault.old, name),
24828
- next: join12(files.vault.next, name)
24902
+ old: join13(files.vault.old, name),
24903
+ next: join13(files.vault.next, name)
24829
24904
  }));
24830
24905
  }
24831
24906
  async function destinationFiles(files) {
24832
24907
  return (await vaultFiles(files.vault.next)).map(
24833
- (name) => join12(files.vault.next, name)
24908
+ (name) => join13(files.vault.next, name)
24834
24909
  );
24835
24910
  }
24836
24911
  async function physicalAliases(location, files) {
@@ -24839,7 +24914,7 @@ async function physicalAliases(location, files) {
24839
24914
  [files.vault.old, files.vault.next]
24840
24915
  ];
24841
24916
  for (const name of VAULT_FILE_NAMES)
24842
- pairs.push([join12(files.vault.old, name), join12(files.vault.next, name)]);
24917
+ pairs.push([join13(files.vault.old, name), join13(files.vault.next, name)]);
24843
24918
  const aliased = [];
24844
24919
  for (const [old, next] of pairs)
24845
24920
  if (await samePhysical(old, next)) aliased.push(old);
@@ -24951,11 +25026,11 @@ async function unlinkIfIdentical(file, stateDir, guard) {
24951
25026
  async function refuseReappearedFiles(location, files) {
24952
25027
  const keptState = vaultStateFile(files).old;
24953
25028
  for (const name of await vaultFiles(files.vault.old)) {
24954
- const old = join12(files.vault.old, name);
25029
+ const old = join13(files.vault.old, name);
24955
25030
  if (old === keptState && await isVaultShapedKeptState(files)) continue;
24956
25031
  throw credentialConflict(location.stateHomeDir, {
24957
25032
  old,
24958
- next: join12(files.vault.next, name)
25033
+ next: join13(files.vault.next, name)
24959
25034
  });
24960
25035
  }
24961
25036
  }
@@ -24997,13 +25072,13 @@ async function assertOwnFolder(location, marker, files) {
24997
25072
  const stateDir = location.stateHomeDir;
24998
25073
  if (marker?.oldDir !== void 0 && marker.oldDir !== location.key)
24999
25074
  throw foreignMarker(
25000
- join12(stateDir, RUNTIME_LAYOUT_MARKER_FILE),
25075
+ join13(stateDir, RUNTIME_LAYOUT_MARKER_FILE),
25001
25076
  location.key,
25002
25077
  files.vault.old
25003
25078
  );
25004
25079
  let text2;
25005
25080
  try {
25006
- text2 = await readFile10(join12(stateDir, RUNTIME_CONFIG_DIR_NOTE_FILE), "utf8");
25081
+ text2 = await readFile10(join13(stateDir, RUNTIME_CONFIG_DIR_NOTE_FILE), "utf8");
25007
25082
  } catch (error) {
25008
25083
  const code2 = error.code;
25009
25084
  if (code2 === "ENOENT" || code2 === "ENOTDIR") return;
@@ -25017,7 +25092,7 @@ async function assertOwnFolder(location, marker, files) {
25017
25092
  if (owner !== location.key) throw foreignFolder(stateDir, location.key);
25018
25093
  }
25019
25094
  async function writeOwnerNote(location) {
25020
- const path2 = join12(location.stateHomeDir, RUNTIME_CONFIG_DIR_NOTE_FILE);
25095
+ const path2 = join13(location.stateHomeDir, RUNTIME_CONFIG_DIR_NOTE_FILE);
25021
25096
  if (await exists2(path2)) return;
25022
25097
  await writePrivateText(
25023
25098
  path2,
@@ -25028,7 +25103,7 @@ async function writeOwnerNote(location) {
25028
25103
  async function readManifest(stateDir) {
25029
25104
  let text2;
25030
25105
  try {
25031
- text2 = await readFile10(join12(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE), "utf8");
25106
+ text2 = await readFile10(join13(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE), "utf8");
25032
25107
  } catch (error) {
25033
25108
  if (error.code === "ENOENT") return /* @__PURE__ */ new Set();
25034
25109
  throw error;
@@ -25045,13 +25120,13 @@ async function readManifest(stateDir) {
25045
25120
  }
25046
25121
  async function writeManifest(stateDir, paths) {
25047
25122
  await writePrivateText(
25048
- join12(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE),
25123
+ join13(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE),
25049
25124
  `${JSON.stringify({ version: 1, files: paths }, null, 2)}
25050
25125
  `
25051
25126
  );
25052
25127
  }
25053
25128
  async function removeManifest(stateDir) {
25054
- await unlink9(join12(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE)).catch(
25129
+ await unlink9(join13(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE)).catch(
25055
25130
  (error) => {
25056
25131
  if (error.code !== "ENOENT") throw error;
25057
25132
  }
@@ -25220,9 +25295,9 @@ import {
25220
25295
  writeFileSync
25221
25296
  } from "node:fs";
25222
25297
  import { homedir as homedir4 } from "node:os";
25223
- import { dirname as dirname16, join as join13, resolve as resolve15 } from "node:path";
25298
+ import { dirname as dirname16, join as join14, resolve as resolve16 } from "node:path";
25224
25299
  async function ensureGitignore(configDir) {
25225
- const gitignorePath = join13(configDir, ".gitignore");
25300
+ const gitignorePath = join14(configDir, ".gitignore");
25226
25301
  try {
25227
25302
  let content;
25228
25303
  let existingLines = [];
@@ -25268,8 +25343,8 @@ async function ensureGitignore(configDir) {
25268
25343
  }
25269
25344
  }
25270
25345
  function getLegacyWindowsConfigDir() {
25271
- return join13(
25272
- process.env.APPDATA || join13(homedir4(), "AppData", "Roaming"),
25346
+ return join14(
25347
+ process.env.APPDATA || join14(homedir4(), "AppData", "Roaming"),
25273
25348
  "opencode"
25274
25349
  );
25275
25350
  }
@@ -25277,15 +25352,15 @@ function getConfigDir() {
25277
25352
  if (process.env.OPENCODE_CONFIG_DIR) {
25278
25353
  return process.env.OPENCODE_CONFIG_DIR;
25279
25354
  }
25280
- const xdgConfig2 = process.env.XDG_CONFIG_HOME || join13(homedir4(), ".config");
25281
- return join13(xdgConfig2, "opencode");
25355
+ const xdgConfig2 = process.env.XDG_CONFIG_HOME || join14(homedir4(), ".config");
25356
+ return join14(xdgConfig2, "opencode");
25282
25357
  }
25283
25358
  function migrateLegacyWindowsConfig() {
25284
25359
  if (process.platform !== "win32") {
25285
25360
  return false;
25286
25361
  }
25287
- const newPath = join13(getConfigDir(), "antigravity-accounts.json");
25288
- const legacyPath = join13(
25362
+ const newPath = join14(getConfigDir(), "antigravity-accounts.json");
25363
+ const legacyPath = join14(
25289
25364
  getLegacyWindowsConfigDir(),
25290
25365
  "antigravity-accounts.json"
25291
25366
  );
@@ -25320,8 +25395,8 @@ function migrateLegacyWindowsConfig() {
25320
25395
  }
25321
25396
  }
25322
25397
  function resolveWindowsAccountAnchor(newPath, legacyPath) {
25323
- const standard = resolve15(newPath);
25324
- const legacy = resolve15(legacyPath);
25398
+ const standard = resolve16(newPath);
25399
+ const legacy = resolve16(legacyPath);
25325
25400
  if (standard.toLowerCase() === legacy.toLowerCase()) return newPath;
25326
25401
  const standardPointer = existsSync3(accountStorePointerPath(standard));
25327
25402
  const legacyPointer = existsSync3(accountStorePointerPath(legacy));
@@ -25335,15 +25410,15 @@ function resolveWindowsAccountAnchor(newPath, legacyPath) {
25335
25410
  return newPath;
25336
25411
  }
25337
25412
  function getStoragePathWithMigration() {
25338
- const newPath = join13(getConfigDir(), "antigravity-accounts.json");
25413
+ const newPath = join14(getConfigDir(), "antigravity-accounts.json");
25339
25414
  if (process.platform === "win32") {
25340
25415
  migrateLegacyWindowsConfig();
25341
- const legacyPath = join13(
25416
+ const legacyPath = join14(
25342
25417
  getLegacyWindowsConfigDir(),
25343
25418
  "antigravity-accounts.json"
25344
25419
  );
25345
25420
  const anchored = resolveWindowsAccountAnchor(newPath, legacyPath);
25346
- if (resolve15(anchored).toLowerCase() !== resolve15(newPath).toLowerCase() && !existsSync3(accountStorePointerPath(resolve15(anchored)))) {
25421
+ if (resolve16(anchored).toLowerCase() !== resolve16(newPath).toLowerCase() && !existsSync3(accountStorePointerPath(resolve16(anchored)))) {
25347
25422
  log5.info("Using legacy Windows config path (migration failed)", {
25348
25423
  legacyPath,
25349
25424
  newPath
@@ -25357,20 +25432,20 @@ function stateHomeStoragePath() {
25357
25432
  return stateHomeAccountFile(runtimeLayoutLocation());
25358
25433
  }
25359
25434
  function accountFileForVault(configDir = getConfigDir()) {
25360
- const configured = join13(configDir, "antigravity-accounts.json");
25435
+ const configured = join14(configDir, "antigravity-accounts.json");
25361
25436
  if (process.platform !== "win32") return configured;
25362
25437
  const legacyDir = getLegacyWindowsConfigDir();
25363
- if (resolve15(configDir).toLowerCase() === resolve15(legacyDir).toLowerCase())
25438
+ if (resolve16(configDir).toLowerCase() === resolve16(legacyDir).toLowerCase())
25364
25439
  return configured;
25365
- const configuredVault = join13(configDir, "antigravity-auth-vault");
25366
- const legacyVault = join13(legacyDir, "antigravity-auth-vault");
25440
+ const configuredVault = join14(configDir, "antigravity-auth-vault");
25441
+ const legacyVault = join14(legacyDir, "antigravity-auth-vault");
25367
25442
  const configuredPresent = existsSync3(configuredVault);
25368
25443
  const legacyPresent = existsSync3(legacyVault);
25369
25444
  if (configuredPresent && legacyPresent)
25370
25445
  throw new Error(
25371
25446
  `Two vault folders exist: ${configuredVault} and ${legacyVault}. Keep one vault enrollment before restarting OpenCode.`
25372
25447
  );
25373
- return legacyPresent ? join13(legacyDir, "antigravity-accounts.json") : configured;
25448
+ return legacyPresent ? join14(legacyDir, "antigravity-accounts.json") : configured;
25374
25449
  }
25375
25450
  async function prepareLocalAccountStore() {
25376
25451
  if (!decidedRuntimeLayout(runtimeLayoutLocation())) return;
@@ -25385,13 +25460,13 @@ function getStoragePath() {
25385
25460
  if (anchor === "config") return getStoragePathWithMigration();
25386
25461
  const location = runtimeLayoutLocation();
25387
25462
  if (decidedRuntimeLayout(location))
25388
- return join13(location.configDir, "antigravity-accounts.json");
25463
+ return join14(location.configDir, "antigravity-accounts.json");
25389
25464
  const configPath = getStoragePathWithMigration();
25390
25465
  return readForwardedAccountStore(configPath)?.legacyPath ?? configPath;
25391
25466
  }
25392
25467
  async function assertLegacyPoolInUse(legacyPath) {
25393
25468
  try {
25394
- await assertLegacyAccountStorageWritable(resolve15(legacyPath));
25469
+ await assertLegacyAccountStorageWritable(resolve16(legacyPath));
25395
25470
  } catch (error) {
25396
25471
  throw new LegacyAccountPoolRetiredError(legacyPath, { cause: error });
25397
25472
  }
@@ -25409,7 +25484,7 @@ function refusalMessage2(admission) {
25409
25484
  async function bindingOf(options) {
25410
25485
  if (options.legacyPath === void 0) await prepareLocalAccountStore();
25411
25486
  const now = options.now ?? (() => Date.now());
25412
- const legacyPath = resolve15(options.legacyPath ?? getStoragePath());
25487
+ const legacyPath = resolve16(options.legacyPath ?? getStoragePath());
25413
25488
  return {
25414
25489
  legacyPath,
25415
25490
  now,
@@ -25478,7 +25553,7 @@ async function openAccountStore(options) {
25478
25553
  async function initializeFreshAccountStoreFor(modules, options = {}) {
25479
25554
  if (options.legacyPath === void 0) await prepareLocalAccountStore();
25480
25555
  return initializeFreshAccountStore(modules, {
25481
- legacyPath: resolve15(options.legacyPath ?? getStoragePath()),
25556
+ legacyPath: resolve16(options.legacyPath ?? getStoragePath()),
25482
25557
  now: options.now ?? (() => Date.now())
25483
25558
  });
25484
25559
  }
@@ -25524,12 +25599,12 @@ var init_storage = __esm({
25524
25599
  import { createHash as createHash11 } from "node:crypto";
25525
25600
  import { existsSync as existsSync4, promises as fs2, readFileSync as readFileSync2, realpathSync as realpathSync2 } from "node:fs";
25526
25601
  import { homedir as homedir5 } from "node:os";
25527
- import { dirname as dirname17, join as join14, resolve as resolve16 } from "node:path";
25602
+ import { dirname as dirname17, join as join15, resolve as resolve17 } from "node:path";
25528
25603
  function configDirIdentity(path2) {
25529
25604
  try {
25530
25605
  return realpathSync2.native(path2);
25531
25606
  } catch {
25532
- return resolve16(path2);
25607
+ return resolve17(path2);
25533
25608
  }
25534
25609
  }
25535
25610
  function decisionKey(location) {
@@ -25537,18 +25612,18 @@ function decisionKey(location) {
25537
25612
  }
25538
25613
  function runtimeLayoutLocation(configDir = getConfigDir()) {
25539
25614
  const stateHome = defaultStateHome();
25540
- const homeConfig = join14(homedir5(), ".config", "opencode");
25615
+ const homeConfig = join15(homedir5(), ".config", "opencode");
25541
25616
  const cacheKey = `${configDir}\0${homeConfig}\0${stateHome}`;
25542
25617
  const cached = shared2.locations.get(cacheKey);
25543
25618
  if (cached && shared2.decisions.has(decisionKey(cached))) return cached;
25544
25619
  const key = configDirIdentity(configDir);
25545
25620
  if (cached && cached.key === key) return cached;
25546
25621
  const isDefaultConfigDir = key === configDirIdentity(homeConfig);
25547
- const root = join14(stateHome, "cortexkit", "antigravity-auth");
25622
+ const root = join15(stateHome, "cortexkit", "antigravity-auth");
25548
25623
  const location = {
25549
25624
  key,
25550
25625
  configDir,
25551
- stateHomeDir: isDefaultConfigDir ? join14(root, "opencode") : join14(
25626
+ stateHomeDir: isDefaultConfigDir ? join15(root, "opencode") : join15(
25552
25627
  root,
25553
25628
  `opencode-${createHash11("sha256").update(key).digest("hex").slice(0, 16)}`
25554
25629
  ),
@@ -25570,46 +25645,46 @@ function decidedAccountStoreAnchor(location) {
25570
25645
  return shared2.storeAnchors.get(`${location.stateHomeDir}\0${location.key}`);
25571
25646
  }
25572
25647
  function currentRuntimeLayout(location = runtimeLayoutLocation()) {
25573
- return decidedRuntimeLayout(location) ?? (existsSync4(join14(location.stateHomeDir, RUNTIME_LAYOUT_MARKER_FILE)) ? "state-home" : "legacy");
25648
+ return decidedRuntimeLayout(location) ?? (existsSync4(join15(location.stateHomeDir, RUNTIME_LAYOUT_MARKER_FILE)) ? "state-home" : "legacy");
25574
25649
  }
25575
25650
  function legacyWindowsConfigDir() {
25576
- return join14(
25577
- process.env.APPDATA || join14(homedir5(), "AppData", "Roaming"),
25651
+ return join15(
25652
+ process.env.APPDATA || join15(homedir5(), "AppData", "Roaming"),
25578
25653
  "opencode"
25579
25654
  );
25580
25655
  }
25581
25656
  function pluginStateDir() {
25582
- return join14(defaultStateHome(), "cortexkit", "antigravity-auth");
25657
+ return join15(defaultStateHome(), "cortexkit", "antigravity-auth");
25583
25658
  }
25584
25659
  function legacySignatureCacheFile() {
25585
- const configHome = process.platform === "win32" ? legacyWindowsConfigDir() : join14(
25586
- process.env.XDG_CONFIG_HOME || join14(homedir5(), ".config"),
25660
+ const configHome = process.platform === "win32" ? legacyWindowsConfigDir() : join15(
25661
+ process.env.XDG_CONFIG_HOME || join15(homedir5(), ".config"),
25587
25662
  "opencode"
25588
25663
  );
25589
- return join14(configHome, SIGNATURE_CACHE_FILE_NAME);
25664
+ return join15(configHome, SIGNATURE_CACHE_FILE_NAME);
25590
25665
  }
25591
25666
  function stateHomeLogsDir() {
25592
- return join14(pluginStateDir(), "logs");
25667
+ return join15(pluginStateDir(), "logs");
25593
25668
  }
25594
25669
  function legacyAccountFile(configDir = getConfigDir()) {
25595
- const standard = join14(configDir, ACCOUNT_FILE_NAME);
25670
+ const standard = join15(configDir, ACCOUNT_FILE_NAME);
25596
25671
  if (process.platform !== "win32") return standard;
25597
25672
  return resolveWindowsAccountAnchor(
25598
25673
  standard,
25599
- join14(legacyWindowsConfigDir(), ACCOUNT_FILE_NAME)
25674
+ join15(legacyWindowsConfigDir(), ACCOUNT_FILE_NAME)
25600
25675
  );
25601
25676
  }
25602
25677
  function legacyVaultDir(accountFile) {
25603
- return join14(dirname17(accountFile), VAULT_DIR_NAME);
25678
+ return join15(dirname17(accountFile), VAULT_DIR_NAME);
25604
25679
  }
25605
25680
  function stateHomeVaultDir(location) {
25606
- return join14(location.stateHomeDir, VAULT_DIR_NAME);
25681
+ return join15(location.stateHomeDir, VAULT_DIR_NAME);
25607
25682
  }
25608
25683
  function accountStorePointerPath2(accountFile) {
25609
25684
  return `${accountFile}${ACCOUNT_STORE_POINTER_SUFFIX}`;
25610
25685
  }
25611
25686
  function stateHomeAccountFile(location) {
25612
- return join14(realPathOrSelf(location.stateHomeDir), ACCOUNT_FILE_NAME);
25687
+ return join15(realPathOrSelf(location.stateHomeDir), ACCOUNT_FILE_NAME);
25613
25688
  }
25614
25689
  function realPathOrSelf(path2) {
25615
25690
  try {
@@ -25829,7 +25904,7 @@ import {
25829
25904
  statSync as statSync4,
25830
25905
  unlinkSync as unlinkSync2
25831
25906
  } from "node:fs";
25832
- import { join as join15 } from "node:path";
25907
+ import { join as join16 } from "node:path";
25833
25908
  import { env } from "node:process";
25834
25909
  function getLogsDir(customLogDir) {
25835
25910
  const logsDir = customLogDir || stateHomeLogsDir();
@@ -25848,9 +25923,9 @@ function createLogFilePath(customLogDir) {
25848
25923
  const logsDir = getLogsDir(requestedLogDir(customLogDir));
25849
25924
  cleanupOldLogs(logsDir, 25);
25850
25925
  const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
25851
- let candidate = join15(logsDir, `antigravity-debug-${timestamp}.log`);
25926
+ let candidate = join16(logsDir, `antigravity-debug-${timestamp}.log`);
25852
25927
  for (let suffix = 2; liveLogFilePaths.has(candidate); suffix++) {
25853
- candidate = join15(logsDir, `antigravity-debug-${timestamp}-${suffix}.log`);
25928
+ candidate = join16(logsDir, `antigravity-debug-${timestamp}-${suffix}.log`);
25854
25929
  }
25855
25930
  return candidate;
25856
25931
  }
@@ -25858,7 +25933,7 @@ function cleanupOldLogs(logsDir, maxFiles) {
25858
25933
  try {
25859
25934
  const files = readdirSync(logsDir).filter(
25860
25935
  (file) => file.startsWith("antigravity-debug-") && file.endsWith(".log")
25861
- ).map((file) => join15(logsDir, file));
25936
+ ).map((file) => join16(logsDir, file));
25862
25937
  if (files.length <= maxFiles) {
25863
25938
  return;
25864
25939
  }
@@ -26191,13 +26266,13 @@ function closeDebugLog() {
26191
26266
  if (!state || !current) return Promise.resolve();
26192
26267
  state.logStream = null;
26193
26268
  if (state.logFilePath) liveLogFilePaths.delete(state.logFilePath);
26194
- return new Promise((resolve21) => {
26195
- current.once("close", () => resolve21());
26196
- current.once("error", () => resolve21());
26269
+ return new Promise((resolve22) => {
26270
+ current.once("close", () => resolve22());
26271
+ current.once("error", () => resolve22());
26197
26272
  try {
26198
26273
  current.end();
26199
26274
  } catch {
26200
- resolve21();
26275
+ resolve22();
26201
26276
  }
26202
26277
  });
26203
26278
  }
@@ -26255,10 +26330,10 @@ function createLocationLogger(options) {
26255
26330
  const engine = createLoggerInstance2({
26256
26331
  level: () => configuredLevel,
26257
26332
  extraSecretKeys: isProviderSecretKey,
26258
- captureSink: ({ channel, level, message, data }) => {
26333
+ captureSink: ({ channel: channel3, level, message, data }) => {
26259
26334
  const extra = data !== null && typeof data === "object" && !Array.isArray(data) ? Object.fromEntries(Object.entries(data)) : void 0;
26260
26335
  emit({
26261
- service: channel,
26336
+ service: channel3,
26262
26337
  level: level === "trace" ? "debug" : level,
26263
26338
  message,
26264
26339
  extra
@@ -26267,12 +26342,12 @@ function createLocationLogger(options) {
26267
26342
  });
26268
26343
  return {
26269
26344
  createLogger(module) {
26270
- const channel = engine.createLogger(`antigravity.${module}`);
26345
+ const channel3 = engine.createLogger(`antigravity.${module}`);
26271
26346
  return {
26272
- debug: (message, extra) => channel.debug(message, extra),
26273
- info: (message, extra) => channel.info(message, extra),
26274
- warn: (message, extra) => channel.warn(message, extra),
26275
- error: (message, extra) => channel.error(message, extra)
26347
+ debug: (message, extra) => channel3.debug(message, extra),
26348
+ info: (message, extra) => channel3.info(message, extra),
26349
+ warn: (message, extra) => channel3.warn(message, extra),
26350
+ error: (message, extra) => channel3.error(message, extra)
26276
26351
  };
26277
26352
  },
26278
26353
  setLevel(level) {
@@ -26306,10 +26381,10 @@ function getLegacyLogger() {
26306
26381
  return legacyLogger;
26307
26382
  }
26308
26383
  function createLogger4(module) {
26309
- let channel;
26384
+ let channel3;
26310
26385
  const log8 = (level, message, extra) => {
26311
- channel ??= getLegacyLogger().createLogger(module);
26312
- channel[level](message, extra);
26386
+ channel3 ??= getLegacyLogger().createLogger(module);
26387
+ channel3[level](message, extra);
26313
26388
  };
26314
26389
  return {
26315
26390
  debug: (message, extra) => log8("debug", message, extra),
@@ -26343,7 +26418,7 @@ var init_logger4 = __esm({
26343
26418
  init_dist();
26344
26419
  import { execFile } from "node:child_process";
26345
26420
  import { realpathSync as realpathSync4 } from "node:fs";
26346
- import { resolve as resolve20 } from "node:path";
26421
+ import { resolve as resolve21 } from "node:path";
26347
26422
  import { createInterface } from "node:readline/promises";
26348
26423
  import { fileURLToPath as fileURLToPath2 } from "node:url";
26349
26424
  import { promisify } from "node:util";
@@ -26751,14 +26826,14 @@ async function fetchQuotaPayloads(options) {
26751
26826
  };
26752
26827
  }
26753
26828
  function untilQuotaAborted(pending, signal) {
26754
- return new Promise((resolve21, reject) => {
26829
+ return new Promise((resolve22, reject) => {
26755
26830
  const abort = () => reject(signal.reason);
26756
26831
  if (signal.aborted) abort();
26757
26832
  else signal.addEventListener("abort", abort, { once: true });
26758
26833
  void pending.then(
26759
26834
  (value) => {
26760
26835
  signal.removeEventListener("abort", abort);
26761
- resolve21(value);
26836
+ resolve22(value);
26762
26837
  },
26763
26838
  (error) => {
26764
26839
  signal.removeEventListener("abort", abort);
@@ -27040,12 +27115,12 @@ async function startOAuthListener({
27040
27115
  let resolveCallback;
27041
27116
  let rejectCallback;
27042
27117
  let timeoutHandle;
27043
- const callbackPromise = new Promise((resolve21, reject) => {
27118
+ const callbackPromise = new Promise((resolve22, reject) => {
27044
27119
  resolveCallback = (url) => {
27045
27120
  if (settled) return;
27046
27121
  settled = true;
27047
27122
  if (timeoutHandle) clearTimeout(timeoutHandle);
27048
- resolve21(url);
27123
+ resolve22(url);
27049
27124
  };
27050
27125
  rejectCallback = (error) => {
27051
27126
  if (settled) return;
@@ -27204,7 +27279,7 @@ async function startOAuthListener({
27204
27279
  });
27205
27280
  });
27206
27281
  const bindAddress = getBindAddress();
27207
- await new Promise((resolve21, reject) => {
27282
+ await new Promise((resolve22, reject) => {
27208
27283
  const handleError = (error) => {
27209
27284
  server.off("error", handleError);
27210
27285
  if (error.code === "EADDRINUSE") {
@@ -27220,7 +27295,7 @@ async function startOAuthListener({
27220
27295
  server.once("error", handleError);
27221
27296
  server.listen(port, bindAddress, () => {
27222
27297
  server.off("error", handleError);
27223
- resolve21();
27298
+ resolve22();
27224
27299
  });
27225
27300
  });
27226
27301
  server.on("error", (error) => {
@@ -27228,7 +27303,7 @@ async function startOAuthListener({
27228
27303
  });
27229
27304
  return {
27230
27305
  waitForCallback: () => callbackPromise,
27231
- close: () => new Promise((resolve21, reject) => {
27306
+ close: () => new Promise((resolve22, reject) => {
27232
27307
  server.close((error) => {
27233
27308
  if (error && error.code !== "ERR_SERVER_NOT_RUNNING") {
27234
27309
  reject(error);
@@ -27237,7 +27312,7 @@ async function startOAuthListener({
27237
27312
  if (!settled) {
27238
27313
  rejectCallback(new Error("OAuth listener closed before callback"));
27239
27314
  }
27240
- resolve21();
27315
+ resolve22();
27241
27316
  });
27242
27317
  })
27243
27318
  };
@@ -27256,7 +27331,7 @@ init_runtime_paths();
27256
27331
  // src/setup.ts
27257
27332
  init_dist();
27258
27333
  import { lstat as lstat9, readFile as readFile13 } from "node:fs/promises";
27259
- import { join as join21, resolve as resolve19 } from "node:path";
27334
+ import { join as join22, resolve as resolve20 } from "node:path";
27260
27335
 
27261
27336
  // src/auth-method-labels.ts
27262
27337
  var OPENCODE2_POOL_AUTH_LABEL = "Google (antigravity-auth pool, browser)";
@@ -27428,7 +27503,7 @@ async function select2(terminal, items, options) {
27428
27503
  writeLine("");
27429
27504
  renderedLines = lines;
27430
27505
  };
27431
- return new Promise((resolve21) => {
27506
+ return new Promise((resolve22) => {
27432
27507
  const wasRaw = stdin.isRaw ?? false;
27433
27508
  const cleanup2 = () => {
27434
27509
  if (cleaned)
@@ -27448,7 +27523,7 @@ async function select2(terminal, items, options) {
27448
27523
  };
27449
27524
  const finish = (value) => {
27450
27525
  cleanup2();
27451
- resolve21(value);
27526
+ resolve22(value);
27452
27527
  };
27453
27528
  const onSignal = () => finish(null);
27454
27529
  const onKey = (data) => {
@@ -27488,7 +27563,7 @@ async function select2(terminal, items, options) {
27488
27563
  stdin.setRawMode(true);
27489
27564
  } catch {
27490
27565
  cleanup2();
27491
- resolve21(null);
27566
+ resolve22(null);
27492
27567
  return;
27493
27568
  }
27494
27569
  stdin.resume();
@@ -27502,12 +27577,12 @@ async function select2(terminal, items, options) {
27502
27577
  import { createHash as createHash12, randomBytes as randomBytes3, randomUUID as randomUUID15 } from "node:crypto";
27503
27578
  import { constants as fsConstants2 } from "node:fs";
27504
27579
  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";
27505
- import { basename as basename5, dirname as dirname19, extname as extname2, isAbsolute as isAbsolute3, join as join17, resolve as resolve18 } from "node:path";
27580
+ import { basename as basename5, dirname as dirname19, extname as extname2, isAbsolute as isAbsolute3, join as join18, resolve as resolve19 } from "node:path";
27506
27581
  import { ClaustrumCredentialError as ClaustrumCredentialError5, ClaustrumClient as ClaustrumWireClient2, writeEnrollmentTokenFile as writeEnrollmentTokenFile2 } from "@cortexkit/claustrum-client";
27507
27582
 
27508
27583
  // src/common-auth-embedded/fs/file-read-cache.js
27509
27584
  import { lstat as lstat7 } from "node:fs/promises";
27510
- import { resolve as resolve17 } from "node:path";
27585
+ import { resolve as resolve18 } from "node:path";
27511
27586
  async function identity2(path2) {
27512
27587
  try {
27513
27588
  const metadata = await lstat7(path2);
@@ -27524,7 +27599,7 @@ function sameIdentity2(left, right) {
27524
27599
  var FileReadCache2 = class {
27525
27600
  #entries = /* @__PURE__ */ new Map();
27526
27601
  async read(paths, read, validateHit) {
27527
- const resolvedPaths = paths.map((path2) => resolve17(path2));
27602
+ const resolvedPaths = paths.map((path2) => resolve18(path2));
27528
27603
  const key = JSON.stringify(resolvedPaths);
27529
27604
  const probed = await Promise.all(resolvedPaths.map(identity2));
27530
27605
  const identities = probed.every((entry) => entry !== void 0) ? probed : void 0;
@@ -27576,9 +27651,10 @@ init_private_files2();
27576
27651
  init_private_files2();
27577
27652
  import { randomUUID as randomUUID14 } from "node:crypto";
27578
27653
  import { lstat as lstat8, mkdir as mkdir13, open as open9, readFile as readFile11, rename as rename11, rm as rm6, stat as stat9 } from "node:fs/promises";
27579
- import { dirname as dirname18, join as join16 } from "node:path";
27654
+ import { dirname as dirname18, join as join17 } from "node:path";
27580
27655
 
27581
27656
  // src/common-auth-embedded/fs/with-lock.js
27657
+ init_private_files2();
27582
27658
  function lockPathFor2(target, name) {
27583
27659
  return `${target}.${name}.lock`;
27584
27660
  }
@@ -27636,7 +27712,7 @@ function acquireRefreshFileLock2(options) {
27636
27712
  }
27637
27713
  async function acquireRefreshFileLockWithClock2(options) {
27638
27714
  const lockPath = lockPathFor2(options.path, options.name);
27639
- const legacyOwnerPath = join16(lockPath, "owner.json");
27715
+ const legacyOwnerPath = join17(lockPath, "owner.json");
27640
27716
  const ownerId = randomUUID14();
27641
27717
  const now = options.now ?? Date.now;
27642
27718
  let renewTimer = null;
@@ -27644,8 +27720,8 @@ async function acquireRefreshFileLockWithClock2(options) {
27644
27720
  let releaseConfirmed = false;
27645
27721
  let loss;
27646
27722
  let resolveLoss;
27647
- const lostPromise = new Promise((resolve21) => {
27648
- resolveLoss = resolve21;
27723
+ const lostPromise = new Promise((resolve22) => {
27724
+ resolveLoss = resolve22;
27649
27725
  });
27650
27726
  function notifyTimerStep(event) {
27651
27727
  try {
@@ -27679,7 +27755,7 @@ async function acquireRefreshFileLockWithClock2(options) {
27679
27755
  let terminalIOError;
27680
27756
  let renewalInFlight = null;
27681
27757
  const evictPath = `${lockPath}.evicting`;
27682
- const evictOwnerPath = join16(evictPath, "owner.json");
27758
+ const evictOwnerPath = join17(evictPath, "owner.json");
27683
27759
  const evictOwnerId = randomUUID14();
27684
27760
  const EVICT_TTL = 5e3;
27685
27761
  const MAX_STEAL_ATTEMPTS = 8;
@@ -27806,7 +27882,7 @@ async function acquireRefreshFileLockWithClock2(options) {
27806
27882
  }
27807
27883
  }
27808
27884
  async function backoff() {
27809
- await new Promise((resolve21) => setTimeout(resolve21, Math.floor(Math.random() * 4)));
27885
+ await new Promise((resolve22) => setTimeout(resolve22, Math.floor(Math.random() * 4)));
27810
27886
  }
27811
27887
  async function readLockState(notifyReady = true) {
27812
27888
  if (notifyReady && options.onStep)
@@ -28296,7 +28372,7 @@ async function acquireRefreshFileLockWithClock2(options) {
28296
28372
  const remainingMs = deadline - performance.now();
28297
28373
  if (remainingMs <= 0)
28298
28374
  break;
28299
- await new Promise((resolve21) => setTimeout(resolve21, Math.min(delayMs, remainingMs)));
28375
+ await new Promise((resolve22) => setTimeout(resolve22, Math.min(delayMs, remainingMs)));
28300
28376
  delayMs = Math.min(delayMs * 2, 50);
28301
28377
  }
28302
28378
  if (windowsPrivateFiles2)
@@ -28361,7 +28437,7 @@ function getClaustrumEnrollmentPaths2(tokenPath) {
28361
28437
  const extension = extname2(tokenPath) || ".json";
28362
28438
  const stem = basename5(tokenPath, extname2(tokenPath));
28363
28439
  return {
28364
- statePath: join17(dirname19(tokenPath), `${stem}-state${extension}`),
28440
+ statePath: join18(dirname19(tokenPath), `${stem}-state${extension}`),
28365
28441
  tokenPath
28366
28442
  };
28367
28443
  }
@@ -28369,7 +28445,7 @@ function hostEnrollmentPaths2(input) {
28369
28445
  const override = input.override?.trim();
28370
28446
  if (override && !isAbsolute3(override) && !input.cwd)
28371
28447
  throw new ClaustrumConsumerError2("invalid-state", "A relative Claustrum enrollment override needs a base directory");
28372
- const tokenPath = override ? isAbsolute3(override) ? override : resolve18(input.cwd, override) : join17(input.stateDir, `${input.host}-enrollment.json`);
28448
+ const tokenPath = override ? isAbsolute3(override) ? override : resolve19(input.cwd, override) : join18(input.stateDir, `${input.host}-enrollment.json`);
28373
28449
  return getClaustrumEnrollmentPaths2(tokenPath);
28374
28450
  }
28375
28451
  function isRecord10(value) {
@@ -28602,7 +28678,7 @@ async function writeStateAtomic2(path2, state, ancestorOptions = {}) {
28602
28678
  }
28603
28679
  if (windowsPrivateFiles2)
28604
28680
  return writePrivateAtomic2(path2, bytes);
28605
- const temporary = join17(parent, `.${basename5(path2)}.${process.pid}.${randomUUID15()}.tmp`);
28681
+ const temporary = join18(parent, `.${basename5(path2)}.${process.pid}.${randomUUID15()}.tmp`);
28606
28682
  let descriptor;
28607
28683
  let created = false;
28608
28684
  try {
@@ -28997,7 +29073,7 @@ var ByteTail = class {
28997
29073
  };
28998
29074
  var defaultCommandRunner = {
28999
29075
  run(file, args, options = {}) {
29000
- return new Promise((resolve21) => {
29076
+ return new Promise((resolve22) => {
29001
29077
  const started = performance.now();
29002
29078
  const timeoutMs = options.timeoutMs ?? 15e3;
29003
29079
  const stderr = new ByteTail();
@@ -29015,7 +29091,7 @@ var defaultCommandRunner = {
29015
29091
  stdio: ["ignore", "pipe", "pipe"]
29016
29092
  });
29017
29093
  } catch {
29018
- resolve21({
29094
+ resolve22({
29019
29095
  exitCode: 1,
29020
29096
  stdout: "",
29021
29097
  stderr: "",
@@ -29050,7 +29126,7 @@ var defaultCommandRunner = {
29050
29126
  settled = true;
29051
29127
  if (timer)
29052
29128
  clearTimeout(timer);
29053
- resolve21({
29129
+ resolve22({
29054
29130
  exitCode: spawnError ? 1 : outputExceeded ? 1 : code2 ?? 1,
29055
29131
  stdout: Buffer.concat(stdout, stdoutLength).toString("utf8"),
29056
29132
  stderr: stderr.toString(),
@@ -29137,7 +29213,7 @@ function recordSetupEnrollment(failure, enrollment) {
29137
29213
  import { accessSync, constants as constants3, existsSync as existsSync6, readFileSync as readFileSync4, realpathSync as realpathSync3, statSync as statSync5 } from "node:fs";
29138
29214
  import { mkdtemp, rm as rm7 } from "node:fs/promises";
29139
29215
  import { tmpdir as tmpdir3 } from "node:os";
29140
- import { join as join18 } from "node:path";
29216
+ import { join as join19 } from "node:path";
29141
29217
  import { parse } from "jsonc-parser";
29142
29218
 
29143
29219
  // src/common-auth-embedded/setup/paths.js
@@ -29308,7 +29384,7 @@ async function detectHosts(plugin, io = {}) {
29308
29384
  return null;
29309
29385
  let root;
29310
29386
  try {
29311
- root = await mkdtemp(join18(tmpdir3(), "common-auth-setup-version-"));
29387
+ root = await mkdtemp(join19(tmpdir3(), "common-auth-setup-version-"));
29312
29388
  const probeEnv = {
29313
29389
  ...env3,
29314
29390
  HOME: root,
@@ -29893,7 +29969,7 @@ import { applyEdits, createScanner, findNodeAtLocation, modify, parse as parse2,
29893
29969
  // src/common-auth-embedded/setup/config-write.js
29894
29970
  import { randomUUID as randomUUID16 } from "node:crypto";
29895
29971
  import { mkdir as mkdir15, open as open11, rename as rename13, stat as stat12, unlink as unlink11 } from "node:fs/promises";
29896
- import { basename as basename6, dirname as dirname20, join as join19 } from "node:path";
29972
+ import { basename as basename6, dirname as dirname20, join as join20 } from "node:path";
29897
29973
  import { setTimeout as delay2 } from "node:timers/promises";
29898
29974
  async function writeHostConfigAtomic(file, content, options = {}) {
29899
29975
  const windows = (options.platform ?? process.platform) === "win32";
@@ -29908,7 +29984,7 @@ async function writeHostConfigAtomic(file, content, options = {}) {
29908
29984
  throw error;
29909
29985
  }
29910
29986
  }
29911
- const stage = join19(parent, `.${basename6(file)}.${(options.stageName ?? randomUUID16)()}.tmp`);
29987
+ const stage = join20(parent, `.${basename6(file)}.${(options.stageName ?? randomUUID16)()}.tmp`);
29912
29988
  let created = false;
29913
29989
  try {
29914
29990
  const handle = await open11(stage, "wx", mode ?? 438);
@@ -30327,10 +30403,10 @@ init_storage();
30327
30403
  // src/plugin/vault-activation.ts
30328
30404
  init_dist();
30329
30405
  import { homedir as homedir7 } from "node:os";
30330
- import { join as join20 } from "node:path";
30406
+ import { join as join21 } from "node:path";
30331
30407
  function nativeOpenCodeAuthPath(env3 = process.env, home = homedir7()) {
30332
- return join20(
30333
- env3.XDG_DATA_HOME || join20(home, ".local", "share"),
30408
+ return join21(
30409
+ env3.XDG_DATA_HOME || join21(home, ".local", "share"),
30334
30410
  "opencode",
30335
30411
  "auth.json"
30336
30412
  );
@@ -30412,7 +30488,7 @@ function openCodeVaultDir(accountFile) {
30412
30488
  return folder.vaultDir;
30413
30489
  }
30414
30490
  function nativeAuthPath(host, context) {
30415
- return host === "opencode" ? nativeOpenCodeAuthPath() : join21(context.piAgentDir, "auth.json");
30491
+ return host === "opencode" ? nativeOpenCodeAuthPath() : join22(context.piAgentDir, "auth.json");
30416
30492
  }
30417
30493
  function provider(host) {
30418
30494
  return host === "opencode" ? OPENCODE_VAULT_PROVIDER : ANTIGRAVITY_PROVIDER_ID;
@@ -30468,7 +30544,7 @@ async function writeNativeSlot(host, slot, context, expectedAuthority = "local")
30468
30544
  beforeRename: async () => {
30469
30545
  await assertSetupHostsStopped();
30470
30546
  const claustrum = await loadCommonAuthClaustrum();
30471
- const stateDir = host === "opencode" ? openCodeVaultDir(resolve19(accountFileForVault())) : getPiAntigravityVaultDir();
30547
+ const stateDir = host === "opencode" ? openCodeVaultDir(resolve20(accountFileForVault())) : getPiAntigravityVaultDir();
30472
30548
  if (await claustrum.enrollmentAuthority(
30473
30549
  claustrum.hostEnrollmentPaths({ stateDir, host }),
30474
30550
  `antigravity-auth-${host}`
@@ -30506,7 +30582,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
30506
30582
  // `beforeSignIn`, which may move it after this plugin is built.
30507
30583
  paths: {
30508
30584
  get stateDir() {
30509
- return openCodeVaultDir(resolve19(accountFileForVault()));
30585
+ return openCodeVaultDir(resolve20(accountFileForVault()));
30510
30586
  },
30511
30587
  host: "opencode"
30512
30588
  }
@@ -30523,7 +30599,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
30523
30599
  const assertLocal = async (host, context) => {
30524
30600
  if (host === "opencode")
30525
30601
  return assertLocalOpenCodeLogin(
30526
- resolve19(accountFileForVault()),
30602
+ resolve20(accountFileForVault()),
30527
30603
  context.opencodeGeneration
30528
30604
  );
30529
30605
  if (await authority(host) !== "local")
@@ -30539,7 +30615,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
30539
30615
  const { openPiSlot: openPiSlot2 } = await loadCommonAuthPiSlot();
30540
30616
  if ((await openPiSlot2({
30541
30617
  authPath: nativeAuthPath(host, context),
30542
- stashPath: join21(piDir, "google-login-stash.json"),
30618
+ stashPath: join22(piDir, "google-login-stash.json"),
30543
30619
  provider: ANTIGRAVITY_PROVIDER_ID,
30544
30620
  placeholderKey: PI_PLACEHOLDER_KEY
30545
30621
  }).inspect()).slot === "placeholder")
@@ -30579,7 +30655,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
30579
30655
  const { openPiSlot: openPiSlot2 } = await loadCommonAuthPiSlot();
30580
30656
  const inspection = await openPiSlot2({
30581
30657
  authPath: nativeAuthPath("pi", context),
30582
- stashPath: join21(piDir, "google-login-stash.json"),
30658
+ stashPath: join22(piDir, "google-login-stash.json"),
30583
30659
  provider: ANTIGRAVITY_PROVIDER_ID,
30584
30660
  placeholderKey: PI_PLACEHOLDER_KEY
30585
30661
  }).inspect();
@@ -30698,7 +30774,7 @@ Setup has not completed the OpenCode 2 native Google connection.
30698
30774
  await assertSetupHostsStopped();
30699
30775
  await openPiSlot2({
30700
30776
  authPath: nativeAuthPath(host, context),
30701
- stashPath: join21(piDir, "google-login-stash.json"),
30777
+ stashPath: join22(piDir, "google-login-stash.json"),
30702
30778
  provider: ANTIGRAVITY_PROVIDER_ID,
30703
30779
  placeholderKey: PI_PLACEHOLDER_KEY
30704
30780
  }).enterVault();
@@ -31153,7 +31229,7 @@ async function runCliProcess(argv, deps) {
31153
31229
  ...deps,
31154
31230
  prepareVaultFolder: deps.prepareVaultFolder ?? (async (options) => {
31155
31231
  const folder = await prepareVaultFolder({
31156
- accountFile: resolve20(accountFileForVault()),
31232
+ accountFile: resolve21(accountFileForVault()),
31157
31233
  ...options
31158
31234
  });
31159
31235
  if (folder.refusal) throw folder.refusal;
@@ -31199,11 +31275,11 @@ function createDefaultCliDependencies() {
31199
31275
  );
31200
31276
  if (host !== "pi")
31201
31277
  await assertLocalOpenCodeLogin(
31202
- resolve20(accountFileForVault()),
31278
+ resolve21(accountFileForVault()),
31203
31279
  context?.opencodeGeneration
31204
31280
  );
31205
31281
  const repository = host === "pi" ? void 0 : await prepareCliLoginStore(
31206
- resolve20(getStoragePath()),
31282
+ resolve21(getStoragePath()),
31207
31283
  context?.opencodeGeneration
31208
31284
  );
31209
31285
  try {
@@ -31219,7 +31295,7 @@ function createDefaultCliDependencies() {
31219
31295
  }
31220
31296
  if (host === "opencode") await assertSetupHostsStopped();
31221
31297
  await assertLocalOpenCodeLogin(
31222
- resolve20(accountFileForVault()),
31298
+ resolve21(accountFileForVault()),
31223
31299
  context?.opencodeGeneration
31224
31300
  );
31225
31301
  await persistCliStoreLogin(
@@ -31239,7 +31315,7 @@ function createDefaultCliDependencies() {
31239
31315
  };
31240
31316
  }
31241
31317
  async function prepareCliLoginStore(legacyPath, generation) {
31242
- await assertLocalOpenCodeLogin(resolve20(accountFileForVault()), generation);
31318
+ await assertLocalOpenCodeLogin(resolve21(accountFileForVault()), generation);
31243
31319
  const modules = await loadCommonAuthStoreModules();
31244
31320
  const options = {
31245
31321
  legacyPath,
@@ -31364,7 +31440,7 @@ async function readAccountStore(legacyPath) {
31364
31440
  function createDefaultAccountStoreOperations() {
31365
31441
  const offline = { processesStopped: true };
31366
31442
  return {
31367
- legacyPath: () => resolve20(
31443
+ legacyPath: () => resolve21(
31368
31444
  decidedAccountStoreAnchor(runtimeLayoutLocation()) ? getStoragePath() : discoveredAccountFile()
31369
31445
  ),
31370
31446
  migrate: async (legacyPath) => createAccountMigrationFactory(await loadCommonAuthStoreModules())({
@@ -31395,7 +31471,7 @@ function createDefaultAccountStoreOperations() {
31395
31471
  };
31396
31472
  }
31397
31473
  function samePath(left, right) {
31398
- return process.platform === "win32" ? resolve20(left).toLowerCase() === resolve20(right).toLowerCase() : resolve20(left) === resolve20(right);
31474
+ return process.platform === "win32" ? resolve21(left).toLowerCase() === resolve21(right).toLowerCase() : resolve21(left) === resolve21(right);
31399
31475
  }
31400
31476
  function isCliEntry() {
31401
31477
  if (import.meta.main !== void 0) return import.meta.main;