@cortexkit/opencode-antigravity-auth 3.0.21 → 3.0.23

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 (94) hide show
  1. package/dist/cli.js +565 -444
  2. package/dist/cli.js.map +4 -4
  3. package/dist/cli.meta.json +99 -49
  4. package/dist/index.js +1151 -656
  5. package/dist/index.js.map +4 -4
  6. package/dist/index.meta.json +156 -56
  7. package/dist/server.js +1180 -680
  8. package/dist/server.js.map +4 -4
  9. package/dist/server.meta.json +1 -1
  10. package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +2 -2
  11. package/dist/src/common-auth-embedded/fs/with-lock.js +37 -10
  12. package/dist/src/common-auth-embedded/quota/format.d.ts +9 -4
  13. package/dist/src/common-auth-embedded/quota/format.js +45 -26
  14. package/dist/src/common-auth-embedded/quota-sidebar/index.tsx +56 -32
  15. package/dist/src/common-auth-embedded/routing-accessor/index.d.ts +62 -0
  16. package/dist/src/common-auth-embedded/routing-accessor/index.js +128 -0
  17. package/dist/src/common-auth-embedded/source-output.json +42 -22
  18. package/dist/src/plugin/__fixtures__/verified-store.js +2 -2
  19. package/dist/src/plugin/index.d.ts.map +1 -1
  20. package/dist/src/plugin/index.js +2 -0
  21. package/dist/src/plugin/index.js.map +1 -1
  22. package/dist/src/plugin/request.d.ts.map +1 -1
  23. package/dist/src/plugin/request.js +1 -0
  24. package/dist/src/plugin/request.js.map +1 -1
  25. package/dist/src/plugin/shared/request-services.d.ts +6 -0
  26. package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
  27. package/dist/src/plugin/shared/request-services.js +89 -2
  28. package/dist/src/plugin/shared/request-services.js.map +1 -1
  29. package/dist/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
  30. package/dist/src/plugin/shared/vault-request-credentials.js +4 -0
  31. package/dist/src/plugin/shared/vault-request-credentials.js.map +1 -1
  32. package/dist/src/plugin/shared/vault-routing-purpose.d.ts +12 -0
  33. package/dist/src/plugin/shared/vault-routing-purpose.d.ts.map +1 -0
  34. package/dist/src/plugin/shared/vault-routing-purpose.js +18 -0
  35. package/dist/src/plugin/shared/vault-routing-purpose.js.map +1 -0
  36. package/dist/src/plugin/shared/vault-routing.d.ts +39 -0
  37. package/dist/src/plugin/shared/vault-routing.d.ts.map +1 -0
  38. package/dist/src/plugin/shared/vault-routing.js +213 -0
  39. package/dist/src/plugin/shared/vault-routing.js.map +1 -0
  40. package/dist/src/plugin/types.d.ts +1 -0
  41. package/dist/src/plugin/types.d.ts.map +1 -1
  42. package/dist/src/runtime-layout.d.ts.map +1 -1
  43. package/dist/src/runtime-layout.js +14 -3
  44. package/dist/src/runtime-layout.js.map +1 -1
  45. package/dist/src/tui/sidebar-frame.d.ts.map +1 -1
  46. package/dist/src/tui/sidebar-frame.js +18 -16
  47. package/dist/src/tui/sidebar-frame.js.map +1 -1
  48. package/dist/src/vault-folder.d.ts.map +1 -1
  49. package/dist/src/vault-folder.js +51 -14
  50. package/dist/src/vault-folder.js.map +1 -1
  51. package/dist/src/version-fence.d.ts +5 -0
  52. package/dist/src/version-fence.d.ts.map +1 -1
  53. package/dist/src/version-fence.js +64 -7
  54. package/dist/src/version-fence.js.map +1 -1
  55. package/dist/tui-build-map.json +13 -13
  56. package/dist/tui-ga-build-map.json +13 -13
  57. package/dist/types/src/common-auth-embedded/quota/format.d.ts +9 -4
  58. package/dist/types/src/common-auth-embedded/routing-accessor/index.d.ts +62 -0
  59. package/dist/types/src/plugin/index.d.ts.map +1 -1
  60. package/dist/types/src/plugin/request.d.ts.map +1 -1
  61. package/dist/types/src/plugin/shared/request-services.d.ts +6 -0
  62. package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -1
  63. package/dist/types/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
  64. package/dist/types/src/plugin/shared/vault-routing-purpose.d.ts +12 -0
  65. package/dist/types/src/plugin/shared/vault-routing-purpose.d.ts.map +1 -0
  66. package/dist/types/src/plugin/shared/vault-routing.d.ts +39 -0
  67. package/dist/types/src/plugin/shared/vault-routing.d.ts.map +1 -0
  68. package/dist/types/src/plugin/types.d.ts +1 -0
  69. package/dist/types/src/plugin/types.d.ts.map +1 -1
  70. package/dist/types/src/runtime-layout.d.ts.map +1 -1
  71. package/dist/types/src/vault-folder.d.ts.map +1 -1
  72. package/dist/types/src/version-fence.d.ts +5 -0
  73. package/dist/types/src/version-fence.d.ts.map +1 -1
  74. package/package.json +2 -2
  75. package/src/common-auth-embedded/fs/refresh-file-lock.js +2 -2
  76. package/src/common-auth-embedded/fs/with-lock.js +37 -10
  77. package/src/common-auth-embedded/quota/format.d.ts +9 -4
  78. package/src/common-auth-embedded/quota/format.js +45 -26
  79. package/src/common-auth-embedded/quota-sidebar/index.tsx +56 -32
  80. package/src/common-auth-embedded/routing-accessor/index.d.ts +62 -0
  81. package/src/common-auth-embedded/routing-accessor/index.js +128 -0
  82. package/src/common-auth-embedded/source-output.json +42 -22
  83. package/src/tui-compiled/common-auth-embedded/quota/format.js +45 -26
  84. package/src/tui-compiled/common-auth-embedded/quota-sidebar/index.js +165 -148
  85. package/src/tui-compiled/tui/sidebar-frame.js +17 -16
  86. package/src/tui-ga-compiled/shared/aef2402f8fc342f0-format.js +45 -26
  87. package/src/tui-ga-compiled/shared/ced204104a639c9c-sidebar-frame.js +17 -16
  88. package/src/tui-ga-compiled/shared/e4ec36f367492969-index.js +165 -148
  89. package/src/tui-ga-raw/shared/aef2402f8fc342f0-format.js +45 -26
  90. package/src/tui-ga-raw/shared/ced204104a639c9c-sidebar-frame.tsx +21 -19
  91. package/src/tui-ga-raw/shared/e4ec36f367492969-index.tsx +56 -32
  92. package/src/tui-raw/common-auth-embedded/quota/format.js +45 -26
  93. package/src/tui-raw/common-auth-embedded/quota-sidebar/index.tsx +56 -32
  94. package/src/tui-raw/tui/sidebar-frame.tsx +21 -19
package/dist/cli.js CHANGED
@@ -1626,10 +1626,10 @@ async function privateDirectory(path2) {
1626
1626
  if (errno(error) !== "EEXIST")
1627
1627
  throw error;
1628
1628
  }
1629
- const stat13 = await lstat2(path2);
1630
- if (!stat13.isDirectory() || stat13.isSymbolicLink())
1629
+ const stat14 = await lstat2(path2);
1630
+ if (!stat14.isDirectory() || stat14.isSymbolicLink())
1631
1631
  throw new AccountMigrationError("successor directory is not a regular directory");
1632
- privateMode(stat13.mode, 448);
1632
+ privateMode(stat14.mode, 448);
1633
1633
  if (windowsPrivateFiles)
1634
1634
  await verifySafeDirectory(path2);
1635
1635
  if (!sameFilesystemPath(await realpath(path2), path2))
@@ -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)
@@ -6375,7 +6375,7 @@ function writeConsoleLog(level, ...args) {
6375
6375
  }
6376
6376
  function createLogger(module) {
6377
6377
  const service = `antigravity.${module}`;
6378
- const log8 = (level, message, extra) => {
6378
+ const log9 = (level, message, extra) => {
6379
6379
  if (_sink) {
6380
6380
  try {
6381
6381
  _sink({ service, level, message, extra });
@@ -6389,10 +6389,10 @@ function createLogger(module) {
6389
6389
  }
6390
6390
  };
6391
6391
  return {
6392
- debug: (message, extra) => log8("debug", message, extra),
6393
- info: (message, extra) => log8("info", message, extra),
6394
- warn: (message, extra) => log8("warn", message, extra),
6395
- error: (message, extra) => log8("error", message, extra)
6392
+ debug: (message, extra) => log9("debug", message, extra),
6393
+ info: (message, extra) => log9("info", message, extra),
6394
+ warn: (message, extra) => log9("warn", message, extra),
6395
+ error: (message, extra) => log9("error", message, extra)
6396
6396
  };
6397
6397
  }
6398
6398
  var ENV_CONSOLE_LOG, _sink;
@@ -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);
@@ -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) {
@@ -16866,7 +16898,7 @@ var init_any_signal = __esm({
16866
16898
  import { createHash as createHash5, randomBytes as randomBytes2, randomUUID as randomUUID10 } from "node:crypto";
16867
16899
  import { constants as fsConstants } from "node:fs";
16868
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";
16869
- 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";
16870
16902
  import { ClaustrumCredentialError as ClaustrumCredentialError2, ClaustrumClient as ClaustrumWireClient, writeEnrollmentTokenFile } from "@cortexkit/claustrum-client";
16871
16903
  function classifyEnrollmentError(error) {
16872
16904
  if (!(error instanceof ClaustrumCredentialError2))
@@ -16892,7 +16924,7 @@ function getClaustrumEnrollmentPaths(tokenPath) {
16892
16924
  const extension = extname(tokenPath) || ".json";
16893
16925
  const stem = basename3(tokenPath, extname(tokenPath));
16894
16926
  return {
16895
- statePath: join6(dirname9(tokenPath), `${stem}-state${extension}`),
16927
+ statePath: join7(dirname9(tokenPath), `${stem}-state${extension}`),
16896
16928
  tokenPath
16897
16929
  };
16898
16930
  }
@@ -16900,7 +16932,7 @@ function hostEnrollmentPaths(input) {
16900
16932
  const override = input.override?.trim();
16901
16933
  if (override && !isAbsolute2(override) && !input.cwd)
16902
16934
  throw new ClaustrumConsumerError("invalid-state", "A relative Claustrum enrollment override needs a base directory");
16903
- 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`);
16904
16936
  return getClaustrumEnrollmentPaths(tokenPath);
16905
16937
  }
16906
16938
  function isRecord6(value) {
@@ -17133,7 +17165,7 @@ async function writeStateAtomic(path2, state, ancestorOptions = {}) {
17133
17165
  }
17134
17166
  if (windowsPrivateFiles)
17135
17167
  return writePrivateAtomic(path2, bytes);
17136
- const temporary = join6(parent, `.${basename3(path2)}.${process.pid}.${randomUUID10()}.tmp`);
17168
+ const temporary = join7(parent, `.${basename3(path2)}.${process.pid}.${randomUUID10()}.tmp`);
17137
17169
  let descriptor;
17138
17170
  let created = false;
17139
17171
  try {
@@ -17629,10 +17661,10 @@ async function drainShutdown(pending, onTimeout) {
17629
17661
  try {
17630
17662
  await Promise.race([
17631
17663
  drained,
17632
- new Promise((resolve21) => {
17664
+ new Promise((resolve22) => {
17633
17665
  timer = setTimeout(() => {
17634
17666
  expired = true;
17635
- resolve21();
17667
+ resolve22();
17636
17668
  }, 2e3);
17637
17669
  })
17638
17670
  ]);
@@ -18402,7 +18434,7 @@ var init_interlock = __esm({
18402
18434
  // ../core/dist/common-auth-embedded/claustrum/roster.js
18403
18435
  import { createHash as createHash6 } from "node:crypto";
18404
18436
  import { stat as stat5 } from "node:fs/promises";
18405
- import { resolve as resolve7 } from "node:path";
18437
+ import { resolve as resolve8 } from "node:path";
18406
18438
  function vaultRosterSeed(roster) {
18407
18439
  return {
18408
18440
  declined: roster.declined.map((entry) => ({ ...entry })),
@@ -18789,16 +18821,16 @@ function applyVaultQuota(current, input) {
18789
18821
  };
18790
18822
  }
18791
18823
  function forgetPendingVaultDiscovery(path2) {
18792
- pendingDiscoveries.delete(resolve7(path2));
18824
+ pendingDiscoveries.delete(resolve8(path2));
18793
18825
  }
18794
18826
  function isVaultRosterLockRefusal(path2, error) {
18795
- const target = resolve7(path2);
18827
+ const target = resolve8(path2);
18796
18828
  if (error instanceof ClaustrumConsumerError)
18797
18829
  return error.kind === "roster-busy";
18798
18830
  if (error instanceof LockContentionError || error instanceof LockOwnershipError)
18799
- return resolve7(error.details.target) === target;
18831
+ return resolve8(error.details.target) === target;
18800
18832
  if (error instanceof PrivateFileError) {
18801
- const failed = resolve7(error.path);
18833
+ const failed = resolve8(error.path);
18802
18834
  return [WRITE_LOCK.name, DISCOVERY_LEASE.name].some((name) => {
18803
18835
  const lock = lockPathFor(target, name);
18804
18836
  return failed === lock || failed.startsWith(`${lock}.`);
@@ -18859,7 +18891,7 @@ async function refreshVaultRoster(options) {
18859
18891
  throw new ClaustrumConsumerError("roster-busy", "Claustrum account discovery is already in progress");
18860
18892
  return persisted;
18861
18893
  }
18862
- const key = resolve7(options.path);
18894
+ const key = resolve8(options.path);
18863
18895
  const listedOver = options.listedOver;
18864
18896
  let discovered;
18865
18897
  try {
@@ -18979,9 +19011,9 @@ var init_roster = __esm({
18979
19011
  });
18980
19012
 
18981
19013
  // ../core/dist/common-auth-embedded/claustrum/quota-writer.js
18982
- import { resolve as resolve8 } from "node:path";
19014
+ import { resolve as resolve9 } from "node:path";
18983
19015
  function writerFor(path2, clock = quotaCommitTimer) {
18984
- const key = resolve8(path2);
19016
+ const key = resolve9(path2);
18985
19017
  let writer = writers.get(key);
18986
19018
  if (!writer) {
18987
19019
  writer = {
@@ -19045,7 +19077,7 @@ function orderedFields(pending) {
19045
19077
  return [...pending.values()].flatMap((account) => [...account.values()]).sort((a, b) => a.order - b.order);
19046
19078
  }
19047
19079
  function pendingVaultQuota(path2, roster) {
19048
- const writer = writers.get(resolve8(path2));
19080
+ const writer = writers.get(resolve9(path2));
19049
19081
  if (writer) {
19050
19082
  for (const field of orderedFields(writer.pending)) {
19051
19083
  if (field.priorReading)
@@ -19056,7 +19088,7 @@ function pendingVaultQuota(path2, roster) {
19056
19088
  return roster;
19057
19089
  }
19058
19090
  function hasPendingVaultQuota(path2) {
19059
- return !!writers.get(resolve8(path2))?.pending.size;
19091
+ return !!writers.get(resolve9(path2))?.pending.size;
19060
19092
  }
19061
19093
  function schedule(writer, delay3) {
19062
19094
  if (writer.running || writer.timer || !writer.pending.size || writer.abort.signal.aborted)
@@ -19121,7 +19153,7 @@ function flush(writer) {
19121
19153
  return writer.running;
19122
19154
  }
19123
19155
  async function drainVaultQuota(path2, timeoutMs = 1e3) {
19124
- const key = resolve8(path2);
19156
+ const key = resolve9(path2);
19125
19157
  const writer = writers.get(key);
19126
19158
  if (!writer)
19127
19159
  return;
@@ -19266,7 +19298,7 @@ var init_consumer = __esm({
19266
19298
  this.#shutdown.signal,
19267
19299
  ...signal ? [signal] : []
19268
19300
  ]);
19269
- return new Promise((resolve21, reject) => {
19301
+ return new Promise((resolve22, reject) => {
19270
19302
  const cleanup2 = () => {
19271
19303
  combined.signal.removeEventListener("abort", abort);
19272
19304
  combined.dispose();
@@ -19281,7 +19313,7 @@ var init_consumer = __esm({
19281
19313
  if (combined.signal.aborted)
19282
19314
  reject(combined.signal.reason);
19283
19315
  else
19284
- resolve21(value);
19316
+ resolve22(value);
19285
19317
  }, (error) => {
19286
19318
  cleanup2();
19287
19319
  reject(error);
@@ -19995,7 +20027,7 @@ var init_consumer = __esm({
19995
20027
  import { createHash as createHash7 } from "node:crypto";
19996
20028
  import { channel as channel2 } from "node:diagnostics_channel";
19997
20029
  import { readdir, stat as stat6 } from "node:fs/promises";
19998
- 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";
19999
20031
  function canonicalJson3(value, path2 = /* @__PURE__ */ new Set()) {
20000
20032
  if (value === null)
20001
20033
  return "null";
@@ -20056,12 +20088,12 @@ function unreachableConnect2() {
20056
20088
  return new ClaustrumUnreachableError();
20057
20089
  }
20058
20090
  function untilAborted(pending, signal) {
20059
- return new Promise((resolve21, reject) => {
20091
+ return new Promise((resolve22, reject) => {
20060
20092
  const abort = () => reject(signal.reason);
20061
20093
  signal.addEventListener("abort", abort, { once: true });
20062
20094
  pending.then((value) => {
20063
20095
  signal.removeEventListener("abort", abort);
20064
- resolve21(value);
20096
+ resolve22(value);
20065
20097
  }, (error) => {
20066
20098
  signal.removeEventListener("abort", abort);
20067
20099
  reject(error);
@@ -20131,13 +20163,13 @@ var init_hub = __esm({
20131
20163
  this.#options = options;
20132
20164
  this.#logger = options.logger ?? createLogger2("claustrum");
20133
20165
  this.#warnShutdown = shutdownWarning(this.#logger, this.#shutdown.signal);
20134
- this.#generationDirectory = join7(options.stateDir, "rosters", hostGeneration);
20166
+ this.#generationDirectory = join8(options.stateDir, "rosters", hostGeneration);
20135
20167
  this.#key = rosterFingerprint(options, providers);
20136
- const directory = join7(this.#generationDirectory, this.#key);
20168
+ const directory = join8(this.#generationDirectory, this.#key);
20137
20169
  for (const provider2 of providers)
20138
20170
  this.#members.set(provider2, {
20139
20171
  provider: provider2,
20140
- path: join7(directory, `${provider2}.json`),
20172
+ path: join8(directory, `${provider2}.json`),
20141
20173
  closed: false
20142
20174
  });
20143
20175
  }
@@ -20218,7 +20250,7 @@ var init_hub = __esm({
20218
20250
  };
20219
20251
  const { consumer, hooks } = createHubMember(port, consumerOptions);
20220
20252
  entry.hooks = hooks;
20221
- const path2 = resolve9(entry.path);
20253
+ const path2 = resolve10(entry.path);
20222
20254
  const subscribers = sharedRosters.get(path2) ?? /* @__PURE__ */ new Set();
20223
20255
  const install = (roster) => {
20224
20256
  if (entry.closed || this.#active !== true || !this.#current || !this.#live(this.#current) || !hooks.roster() || this.#collides(hooks, roster))
@@ -20249,7 +20281,7 @@ var init_hub = __esm({
20249
20281
  return;
20250
20282
  entry.seen = JSON.stringify(decodedVaultRoster(roster));
20251
20283
  entry.hooks?.install(roster);
20252
- for (const install of sharedRosters.get(resolve9(entry.path)) ?? []) {
20284
+ for (const install of sharedRosters.get(resolve10(entry.path)) ?? []) {
20253
20285
  if (!this.#live(generation))
20254
20286
  return;
20255
20287
  if (install !== entry.receiveRoster)
@@ -20705,7 +20737,7 @@ var init_hub = __esm({
20705
20737
  for (const directory of [
20706
20738
  dirname10(this.#generationDirectory),
20707
20739
  this.#generationDirectory,
20708
- join7(this.#generationDirectory, this.#key)
20740
+ join8(this.#generationDirectory, this.#key)
20709
20741
  ])
20710
20742
  await ensureClaustrumPrivateDirectory(directory, {}, "roster directory");
20711
20743
  }
@@ -20717,11 +20749,11 @@ var init_hub = __esm({
20717
20749
  */
20718
20750
  async #seed(entry) {
20719
20751
  const name = `${entry.provider}.json`;
20720
- const candidates = [join7(this.#generationDirectory, name)];
20752
+ const candidates = [join8(this.#generationDirectory, name)];
20721
20753
  try {
20722
20754
  for (const key of await readdir(this.#generationDirectory))
20723
20755
  if (key !== this.#key && FINGERPRINT.test(key))
20724
- candidates.push(join7(this.#generationDirectory, key, name));
20756
+ candidates.push(join8(this.#generationDirectory, key, name));
20725
20757
  } catch {
20726
20758
  }
20727
20759
  let newest;
@@ -21294,7 +21326,7 @@ var init_lock = __esm({
21294
21326
  import { createHash as createHash8 } from "node:crypto";
21295
21327
  import { constants as constants2 } from "node:fs";
21296
21328
  import { lstat as lstat5, mkdir as mkdir10, open as open7, unlink as unlink7 } from "node:fs/promises";
21297
- import { dirname as dirname11, resolve as resolve10 } from "node:path";
21329
+ import { dirname as dirname11, resolve as resolve11 } from "node:path";
21298
21330
  import { setTimeout as sleep2 } from "node:timers/promises";
21299
21331
  function rootSpans(text2) {
21300
21332
  let i = text2.indexOf("{") + 1;
@@ -21391,13 +21423,13 @@ async function safeRead(path2, privateFile = false, afterReadCheck) {
21391
21423
  let file;
21392
21424
  try {
21393
21425
  file = await open7(path2, constants2.O_RDONLY | constants2.O_NOFOLLOW);
21394
- const stat13 = await file.stat();
21395
- if (!stat13.isFile() || privateFile && (stat13.mode & 511) !== 384) {
21426
+ const stat14 = await file.stat();
21427
+ if (!stat14.isFile() || privateFile && (stat14.mode & 511) !== 384) {
21396
21428
  throw new PiSlotError("unsafe-path");
21397
21429
  }
21398
21430
  await afterReadCheck?.(path2);
21399
21431
  const current = await lstat5(path2);
21400
- if (!current.isFile() || current.dev !== stat13.dev || current.ino !== stat13.ino) {
21432
+ if (!current.isFile() || current.dev !== stat14.dev || current.ino !== stat14.ino) {
21401
21433
  throw new PiSlotError("unsafe-path");
21402
21434
  }
21403
21435
  const bytes = await file.readFile();
@@ -21495,8 +21527,8 @@ function createPiSlot(options, onStep, hooks) {
21495
21527
  if (!provider2 || !options.authPath || !options.stashPath || !placeholderKey || placeholderKey.startsWith("!") || placeholderKey.includes("$") || !Number.isFinite(timeout) || timeout < 0) {
21496
21528
  throw new PiSlotError("invalid-options");
21497
21529
  }
21498
- const authPath = resolve10(options.authPath);
21499
- const stashPath = resolve10(options.stashPath);
21530
+ const authPath = resolve11(options.authPath);
21531
+ const stashPath = resolve11(options.stashPath);
21500
21532
  if (authPath === stashPath || stashPath === `${authPath}.lock`) {
21501
21533
  throw new PiSlotError("invalid-options");
21502
21534
  }
@@ -21722,15 +21754,15 @@ var init_model_types = __esm({
21722
21754
 
21723
21755
  // ../core/dist/pi-paths.js
21724
21756
  import { homedir } from "node:os";
21725
- import { dirname as dirname12, join as join8 } from "node:path";
21757
+ import { dirname as dirname12, join as join9 } from "node:path";
21726
21758
  function getPiConfigDir() {
21727
- return process.env.PI_AGENT_DIR?.trim() || join8(homedir(), ".pi", "agent");
21759
+ return process.env.PI_AGENT_DIR?.trim() || join9(homedir(), ".pi", "agent");
21728
21760
  }
21729
21761
  function getPiAntigravityAuthFile() {
21730
- 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");
21731
21763
  }
21732
21764
  function getPiAntigravityVaultDir() {
21733
- return join8(dirname12(getPiAntigravityAuthFile()), "antigravity-auth-vault");
21765
+ return join9(dirname12(getPiAntigravityAuthFile()), "antigravity-auth-vault");
21734
21766
  }
21735
21767
  var init_pi_paths = __esm({
21736
21768
  "../core/dist/pi-paths.js"() {
@@ -21764,8 +21796,8 @@ function getDefaultTierId(allowedTiers) {
21764
21796
  return allowedTiers[0]?.id;
21765
21797
  }
21766
21798
  function wait(ms) {
21767
- return new Promise((resolve21) => {
21768
- setTimeout(resolve21, ms);
21799
+ return new Promise((resolve22) => {
21800
+ setTimeout(resolve22, ms);
21769
21801
  });
21770
21802
  }
21771
21803
  function extractManagedProjectId(payload) {
@@ -22787,7 +22819,7 @@ var init_capture_sink2 = __esm({
22787
22819
  import { randomUUID as randomUUID11 } from "node:crypto";
22788
22820
  import { lstat as lstat6, readFile as readFile7, rename as rename8, unlink as unlink8 } from "node:fs/promises";
22789
22821
  import { tmpdir as tmpdir2 } from "node:os";
22790
- 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";
22791
22823
  function ioCode2(detail) {
22792
22824
  if (detail?.reason === "io-error") {
22793
22825
  if (detail.win32Code === 2 || detail.win32Code === 3)
@@ -22808,7 +22840,7 @@ function isUnavailable2(api, error) {
22808
22840
  }
22809
22841
  async function assertNativeAddonLoads2(api) {
22810
22842
  try {
22811
- 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");
22812
22844
  } catch (error) {
22813
22845
  if (isUnavailable2(api, error))
22814
22846
  throw privateFilesUnavailable2(error);
@@ -22834,7 +22866,7 @@ async function privateOperation2(path2, stage, operation) {
22834
22866
  }
22835
22867
  }
22836
22868
  async function verifySafeDirectory2(path2, options) {
22837
- path2 = resolve11(path2);
22869
+ path2 = resolve12(path2);
22838
22870
  options ??= safeParentOptionsForTest2;
22839
22871
  await privateOperation2(path2, "safe-parent", async () => {
22840
22872
  const result = await (await loadBackend2()).verifySafeParent(path2, options);
@@ -22849,7 +22881,7 @@ async function verifySafeDirectory2(path2, options) {
22849
22881
  });
22850
22882
  }
22851
22883
  async function verifyPrivate2(path2, kind, migrate = false) {
22852
- path2 = resolve11(path2);
22884
+ path2 = resolve12(path2);
22853
22885
  if (kind === "directory")
22854
22886
  return verifySafeDirectory2(path2);
22855
22887
  await privateOperation2(path2, "verify", async () => {
@@ -22884,7 +22916,7 @@ async function verifyPrivate2(path2, kind, migrate = false) {
22884
22916
  });
22885
22917
  }
22886
22918
  async function ensurePrivateDirectory2(path2, _migrate = false, options) {
22887
- path2 = resolve11(path2);
22919
+ path2 = resolve12(path2);
22888
22920
  await privateOperation2(path2, "directory", async () => {
22889
22921
  const api = await loadBackend2();
22890
22922
  try {
@@ -22915,7 +22947,7 @@ async function readPrivateText2(path2, migrate = false) {
22915
22947
  async function readPrivateBuffer2(path2, migrate = false) {
22916
22948
  if (!windowsPrivateFiles2)
22917
22949
  return readFile7(path2);
22918
- path2 = resolve11(path2);
22950
+ path2 = resolve12(path2);
22919
22951
  if (migrate) {
22920
22952
  await verifySafeDirectory2(dirname13(path2));
22921
22953
  await verifyPrivate2(path2, "file", true);
@@ -22923,20 +22955,20 @@ async function readPrivateBuffer2(path2, migrate = false) {
22923
22955
  return privateOperation2(path2, "read", async () => (await loadBackend2()).readOwnerOnly(path2));
22924
22956
  }
22925
22957
  async function createPrivateBytes2(path2, bytes) {
22926
- await verifySafeDirectory2(dirname13(resolve11(path2)));
22958
+ await verifySafeDirectory2(dirname13(resolve12(path2)));
22927
22959
  await privateOperation2(path2, "create", async () => {
22928
- await (await loadBackend2()).createPrivateFile(resolve11(path2), bytes);
22960
+ await (await loadBackend2()).createPrivateFile(resolve12(path2), bytes);
22929
22961
  });
22930
22962
  }
22931
22963
  async function createPrivateDirectoryExclusive2(path2) {
22932
- await verifySafeDirectory2(dirname13(resolve11(path2)));
22964
+ await verifySafeDirectory2(dirname13(resolve12(path2)));
22933
22965
  await privateOperation2(path2, "directory-create", async () => {
22934
- await (await loadBackend2()).createOwnerOnly(resolve11(path2), { kind: "dir" });
22966
+ await (await loadBackend2()).createOwnerOnly(resolve12(path2), { kind: "dir" });
22935
22967
  });
22936
22968
  }
22937
22969
  async function replaceWindowsFile2(from, to, options = {}) {
22938
- from = resolve11(from);
22939
- to = resolve11(to);
22970
+ from = resolve12(from);
22971
+ to = resolve12(to);
22940
22972
  const now = options.now ?? (() => performance.now());
22941
22973
  const start = now();
22942
22974
  const leaseDeadline = options.deadline ?? Infinity;
@@ -22979,7 +23011,7 @@ async function replaceWindowsFile2(from, to, options = {}) {
22979
23011
  throw error;
22980
23012
  }
22981
23013
  async function writePrivateAtomic2(path2, bytes, options = {}) {
22982
- path2 = resolve11(path2);
23014
+ path2 = resolve12(path2);
22983
23015
  await ensurePrivateDirectory2(dirname13(path2));
22984
23016
  try {
22985
23017
  await verifyPrivate2(path2, "file", true);
@@ -22987,7 +23019,7 @@ async function writePrivateAtomic2(path2, bytes, options = {}) {
22987
23019
  if (error.code !== "ENOENT")
22988
23020
  throw error;
22989
23021
  }
22990
- const stage = resolve11(options.stagePath ?? `${path2}.${randomUUID11()}.tmp`);
23022
+ const stage = resolve12(options.stagePath ?? `${path2}.${randomUUID11()}.tmp`);
22991
23023
  if (dirname13(stage) !== dirname13(path2))
22992
23024
  throw new PrivateFileError2(path2, "stage-directory", { code: "EXDEV" });
22993
23025
  let created = false;
@@ -23153,7 +23185,7 @@ var init_redact2 = __esm({
23153
23185
  // src/common-auth-embedded/logger/engine.js
23154
23186
  import { appendFileSync as appendFileSync2, chmodSync as chmodSync2, existsSync as existsSync2, renameSync as renameSync2, statSync as statSync3 } from "node:fs";
23155
23187
  import { open as open8 } from "node:fs/promises";
23156
- import { dirname as dirname14, resolve as resolve12 } from "node:path";
23188
+ import { dirname as dirname14, resolve as resolve13 } from "node:path";
23157
23189
  function chmodPrivate2(path2) {
23158
23190
  try {
23159
23191
  chmodSync2(path2, 384);
@@ -23204,7 +23236,7 @@ async function openWindowsFile2(sink, file) {
23204
23236
  return sink.handle;
23205
23237
  }
23206
23238
  async function flushWindowsFile2(sink, file, text2) {
23207
- file = resolve12(file);
23239
+ file = resolve13(file);
23208
23240
  try {
23209
23241
  if (sink.file !== file)
23210
23242
  await closeWindowsFile2(sink);
@@ -23521,20 +23553,20 @@ import { randomUUID as randomUUID12 } from "node:crypto";
23521
23553
  import { realpathSync, rmSync } from "node:fs";
23522
23554
  import { chmod as chmod3, mkdir as mkdir11, readFile as readFile8, rename as rename9, rm as rm5, writeFile as writeFile3 } from "node:fs/promises";
23523
23555
  import { homedir as homedir2 } from "node:os";
23524
- import { join as join10, resolve as resolve13 } from "node:path";
23556
+ import { join as join11, resolve as resolve14 } from "node:path";
23525
23557
  function processHeartbeatDir() {
23526
- const base = process.env.XDG_STATE_HOME || join10(homedir2(), ".local", "state");
23527
- 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");
23528
23560
  }
23529
23561
  function processHeartbeatPath(pid = process.pid, dir = processHeartbeatDir()) {
23530
- return join10(dir, `${pid}.json`);
23562
+ return join11(dir, `${pid}.json`);
23531
23563
  }
23532
23564
  function processConfigFolderKey() {
23533
23565
  const folder = getConfigDir();
23534
23566
  try {
23535
23567
  return realpathSync.native(folder);
23536
23568
  } catch {
23537
- return resolve13(folder);
23569
+ return resolve14(folder);
23538
23570
  }
23539
23571
  }
23540
23572
  function processHasOlderGeneration() {
@@ -23770,17 +23802,17 @@ var init_process_heartbeat = __esm({
23770
23802
  });
23771
23803
 
23772
23804
  // src/version-fence.ts
23773
- import { readdir as readdir2, readFile as readFile9 } from "node:fs/promises";
23774
- import { homedir as homedir3 } from "node:os";
23775
- import { join as join11 } from "node:path";
23805
+ import { readdir as readdir2, readFile as readFile9, stat as stat8, unlink as unlink9 } from "node:fs/promises";
23806
+ import { homedir as homedir3, uptime } from "node:os";
23807
+ import { join as join12 } from "node:path";
23776
23808
  function defaultStateHome() {
23777
- return process.env.XDG_STATE_HOME || join11(homedir3(), ".local", "state");
23809
+ return process.env.XDG_STATE_HOME || join12(homedir3(), ".local", "state");
23778
23810
  }
23779
23811
  function processHeartbeatDir2(stateHome = defaultStateHome()) {
23780
- return join11(stateHome, "cortexkit", "antigravity-auth", "processes");
23812
+ return join12(stateHome, "cortexkit", "antigravity-auth", "processes");
23781
23813
  }
23782
23814
  function rpcStateRoot(stateHome = defaultStateHome()) {
23783
- return join11(stateHome, "cortexkit", "antigravity-auth", "rpc");
23815
+ return join12(stateHome, "cortexkit", "antigravity-auth", "rpc");
23784
23816
  }
23785
23817
  function isRpcProjectDir(name) {
23786
23818
  return /^[0-9a-f]{16}$/.test(name);
@@ -23854,13 +23886,18 @@ async function readProcessRecord(path2, pid) {
23854
23886
  return { kind: "gone" };
23855
23887
  return { kind: "unreadable" };
23856
23888
  }
23889
+ let startedAt;
23857
23890
  try {
23858
23891
  const value = JSON.parse(text2);
23892
+ if (isRecord9(value) && typeof value.startedAt === "number" && Number.isFinite(value.startedAt))
23893
+ startedAt = value.startedAt;
23859
23894
  if (value !== null && typeof value === "object" && value.pid === pid && typeof value.version === "string") {
23860
23895
  const layouts = value.layouts;
23861
23896
  const stores = value.stores;
23862
23897
  return {
23863
23898
  kind: "ok",
23899
+ text: text2,
23900
+ startedAt,
23864
23901
  version: value.version,
23865
23902
  ...isRecord9(layouts) ? { layouts } : {},
23866
23903
  ...isRecord9(stores) ? { stores } : {}
@@ -23868,14 +23905,45 @@ async function readProcessRecord(path2, pid) {
23868
23905
  }
23869
23906
  } catch {
23870
23907
  }
23871
- return { kind: "unreadable" };
23908
+ return { kind: "unreadable", text: text2, startedAt };
23872
23909
  }
23873
23910
  function isRecord9(value) {
23874
23911
  return value !== null && typeof value === "object" && !Array.isArray(value);
23875
23912
  }
23913
+ function bootTime(options) {
23914
+ try {
23915
+ return (options.now ?? Date.now)() - (options.uptimeSeconds ?? uptime)() * 1e3;
23916
+ } catch {
23917
+ return Number.NaN;
23918
+ }
23919
+ }
23920
+ async function staleRecord(path2, record3, boot, heartbeat) {
23921
+ if (record3.text === void 0 || !Number.isFinite(boot)) return false;
23922
+ let start = heartbeat ? record3.startedAt : void 0;
23923
+ if (start === void 0) {
23924
+ try {
23925
+ start = (await stat8(path2)).mtimeMs;
23926
+ } catch {
23927
+ return false;
23928
+ }
23929
+ }
23930
+ if (!Number.isFinite(start) || !(start < boot - BOOT_TIME_MARGIN_MS))
23931
+ return false;
23932
+ if (heartbeat) {
23933
+ try {
23934
+ if (await readFile9(path2, "utf8") === record3.text) {
23935
+ await unlink9(path2);
23936
+ log5.debug("Removed stale pre-boot heartbeat", { path: path2 });
23937
+ }
23938
+ } catch {
23939
+ }
23940
+ }
23941
+ return true;
23942
+ }
23876
23943
  async function versionFenceOpen(options) {
23877
23944
  const isAlive = options.isAlive ?? pidAlive;
23878
23945
  const self = options.selfPid ?? process.pid;
23946
+ const boot = bootTime(options);
23879
23947
  const blockers = /* @__PURE__ */ new Map();
23880
23948
  const block = (entry) => {
23881
23949
  const key = entry.pid === "unknown" ? `dir:${entry.detail}` : entry.pid;
@@ -23895,10 +23963,11 @@ async function versionFenceOpen(options) {
23895
23963
  for (const name of heartbeats.ok ? heartbeats.names : []) {
23896
23964
  const pid = pidFrom(name, /^(\d+)\.json$/);
23897
23965
  if (pid === void 0 || pid === self) continue;
23898
- const path2 = join11(heartbeatDir, name);
23966
+ const path2 = join12(heartbeatDir, name);
23899
23967
  const heartbeat = await readProcessRecord(path2, pid);
23900
23968
  if (heartbeat.kind === "gone") continue;
23901
- if (!alive(pid)) continue;
23969
+ const live = alive(pid);
23970
+ if (await staleRecord(path2, heartbeat, boot, true) || !live) continue;
23902
23971
  if (heartbeat.kind === "unreadable") {
23903
23972
  block({ pid, version: "unknown", detail: path2 });
23904
23973
  continue;
@@ -23919,7 +23988,7 @@ async function versionFenceOpen(options) {
23919
23988
  block({ pid: "unknown", version: "unknown", detail: projects.error });
23920
23989
  for (const project2 of projects.ok ? projects.names : []) {
23921
23990
  if (!isRpcProjectDir(project2)) continue;
23922
- const dir = join11(rpcRoot, project2);
23991
+ const dir = join12(rpcRoot, project2);
23923
23992
  const ports = await list2(dir);
23924
23993
  if (!ports.ok) {
23925
23994
  if (ports.code === "ENOTDIR") continue;
@@ -23929,9 +23998,10 @@ async function versionFenceOpen(options) {
23929
23998
  for (const name of ports.names) {
23930
23999
  const pid = pidFrom(name, /^port-(\d+)\.json$/);
23931
24000
  if (pid === void 0 || pid === self || !alive(pid)) continue;
23932
- const path2 = join11(dir, name);
24001
+ const path2 = join12(dir, name);
23933
24002
  const port = await readProcessRecord(path2, pid);
23934
24003
  if (port.kind === "gone") continue;
24004
+ if (await staleRecord(path2, port, boot, false)) continue;
23935
24005
  const version = port.kind === "ok" ? port.version : "unknown";
23936
24006
  const order = compareVersions(version, options.currentVersion);
23937
24007
  if (order === void 0 || order < 0)
@@ -23944,9 +24014,109 @@ async function versionFenceOpen(options) {
23944
24014
  blockers: [...blockers.values()].sort((a, b) => rank(a) - rank(b))
23945
24015
  };
23946
24016
  }
24017
+ var log5, BOOT_TIME_MARGIN_MS;
23947
24018
  var init_version_fence = __esm({
23948
24019
  "src/version-fence.ts"() {
23949
24020
  "use strict";
24021
+ init_logger4();
24022
+ log5 = createLogger4("version-fence");
24023
+ BOOT_TIME_MARGIN_MS = 3e5;
24024
+ }
24025
+ });
24026
+
24027
+ // src/vault-folder.ts
24028
+ var vault_folder_exports = {};
24029
+ __export(vault_folder_exports, {
24030
+ __resetVaultFoldersForTest: () => __resetVaultFoldersForTest,
24031
+ currentVaultFolder: () => currentVaultFolder,
24032
+ prepareVaultFolder: () => prepareVaultFolder
24033
+ });
24034
+ import { isAbsolute as isAbsolute3 } from "node:path";
24035
+ function vaultOverride(accountFile) {
24036
+ const kept = refusals.get(overrideRefusalKey);
24037
+ if (kept) return { accountFile, vaultDir: kept.stateDir, refusal: kept };
24038
+ const vaultDir = process.env[OVERRIDE];
24039
+ if (!vaultDir) return void 0;
24040
+ if (isAbsolute3(vaultDir)) return { accountFile, vaultDir };
24041
+ const refusal3 = new RuntimeLayoutRefusal(
24042
+ vaultDir,
24043
+ "relative-vault-dir",
24044
+ `antigravity-auth cannot start: ${OVERRIDE} must be an absolute path. Correct it and restart OpenCode.`
24045
+ );
24046
+ refusals.set(overrideRefusalKey, refusal3);
24047
+ return { accountFile, vaultDir, refusal: refusal3 };
24048
+ }
24049
+ function locationKey() {
24050
+ const location = runtimeLayoutLocation();
24051
+ return `${location.stateHomeDir}\0${location.key}`;
24052
+ }
24053
+ function __resetVaultFoldersForTest() {
24054
+ refusals.clear();
24055
+ }
24056
+ async function prepareVaultFolder(options) {
24057
+ const { accountFile } = options;
24058
+ const override = vaultOverride(accountFile);
24059
+ if (override?.refusal) return override;
24060
+ const key = locationKey();
24061
+ const kept = refusals.get(key);
24062
+ if (kept)
24063
+ return override ? { ...override, refusal: kept } : refused(accountFile, kept);
24064
+ const log9 = options.log ?? createLogger4("runtime-layout");
24065
+ const version = options.version ?? await pluginPackageVersion().catch(() => "unknown");
24066
+ try {
24067
+ if (override) {
24068
+ await ensurePrivateDirectory2(override.vaultDir);
24069
+ } else
24070
+ await prepareRuntimeLayout({
24071
+ version,
24072
+ accountFile,
24073
+ log: log9,
24074
+ ...options.layoutLockWaitMs === void 0 ? {} : { layoutLockWaitMs: options.layoutLockWaitMs }
24075
+ });
24076
+ if (options.accountStore !== false)
24077
+ await prepareAccountStore({ version, log: log9 });
24078
+ } catch (error) {
24079
+ const refusal3 = error instanceof RuntimeLayoutRefusal ? error : new RuntimeLayoutRefusal(
24080
+ override?.vaultDir ?? runtimeLayoutLocation().stateHomeDir,
24081
+ error instanceof Error ? error.name : typeof error
24082
+ );
24083
+ if (!refusals.has(key)) {
24084
+ refusals.set(key, refusal3);
24085
+ log9.warn(refusal3.message, {
24086
+ stateDir: refusal3.stateDir,
24087
+ errorClass: refusal3.errorClass
24088
+ });
24089
+ }
24090
+ return override ? { ...override, refusal: refusals.get(key) ?? refusal3 } : refused(accountFile, refusals.get(key) ?? refusal3);
24091
+ }
24092
+ return override ?? { accountFile, vaultDir: getVaultDir(accountFile) };
24093
+ }
24094
+ function currentVaultFolder(accountFile) {
24095
+ const override = vaultOverride(accountFile);
24096
+ if (override?.refusal) return override;
24097
+ const kept = refusals.get(locationKey());
24098
+ return kept ? override ? { ...override, refusal: kept } : refused(accountFile, kept) : override ?? { accountFile, vaultDir: getVaultDir(accountFile) };
24099
+ }
24100
+ function refused(accountFile, refusal3) {
24101
+ return { accountFile, vaultDir: getVaultDir(accountFile), refusal: refusal3 };
24102
+ }
24103
+ var refusalsKey, globalState2, refusals, OVERRIDE, overrideRefusalKey;
24104
+ var init_vault_folder = __esm({
24105
+ "src/vault-folder.ts"() {
24106
+ "use strict";
24107
+ init_private_files2();
24108
+ init_logger4();
24109
+ init_process_heartbeat();
24110
+ init_runtime_layout();
24111
+ init_runtime_paths();
24112
+ refusalsKey = /* @__PURE__ */ Symbol.for(
24113
+ "@cortexkit/antigravity-auth/vault-folder-refusals"
24114
+ );
24115
+ globalState2 = globalThis;
24116
+ refusals = globalState2[refusalsKey] ?? /* @__PURE__ */ new Map();
24117
+ globalState2[refusalsKey] = refusals;
24118
+ OVERRIDE = "OPENCODE_ANTIGRAVITY_AUTH_VAULT_DIR";
24119
+ overrideRefusalKey = "invalid-vault-dir-override";
23950
24120
  }
23951
24121
  });
23952
24122
 
@@ -23977,10 +24147,10 @@ import {
23977
24147
  readFile as readFile10,
23978
24148
  rename as rename10,
23979
24149
  rmdir as rmdir2,
23980
- stat as stat8,
23981
- unlink as unlink9
24150
+ stat as stat9,
24151
+ unlink as unlink10
23982
24152
  } from "node:fs/promises";
23983
- import { basename as basename4, dirname as dirname15, join as join12, resolve as resolve14 } from "node:path";
24153
+ import { basename as basename4, dirname as dirname15, join as join13, resolve as resolve15 } from "node:path";
23984
24154
  function refusalMessage(stateDir, errorClass2) {
23985
24155
  if (errorClass2 === "ERR_PRIVATE_FILES_SECURITY")
23986
24156
  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.`;
@@ -24033,10 +24203,10 @@ function errorFile(error) {
24033
24203
  ...typeof stage === "string" && stage ? { stage } : {}
24034
24204
  };
24035
24205
  }
24036
- function logCleanupFailure(location, log8, step, error) {
24206
+ function logCleanupFailure(location, log9, step, error) {
24037
24207
  logOnce(
24038
24208
  `${location.key}\0cleanup`,
24039
- () => log8.warn(
24209
+ () => log9.warn(
24040
24210
  "antigravity-auth could not finish removing its old vault files from OpenCode's config folder; it tries again at the next start",
24041
24211
  {
24042
24212
  configDir: location.configDir,
@@ -24065,13 +24235,13 @@ function prepareRuntimeLayout(options) {
24065
24235
  return run;
24066
24236
  }
24067
24237
  async function decide(location, options) {
24068
- const log8 = options.log ?? createLogger4("runtime-layout");
24238
+ const log9 = options.log ?? createLogger4("runtime-layout");
24069
24239
  const stateDir = location.stateHomeDir;
24070
- const markerPath = join12(stateDir, RUNTIME_LAYOUT_MARKER_FILE);
24240
+ const markerPath = join13(stateDir, RUNTIME_LAYOUT_MARKER_FILE);
24071
24241
  const files = layoutFiles(location, options.accountFile);
24072
24242
  const fence = options.fence ?? defaultFence(options.version);
24073
24243
  const stateHome = async () => {
24074
- await settleVault(location, options, "state-home", log8);
24244
+ await settleVault(location, options, "state-home", log9);
24075
24245
  return "state-home";
24076
24246
  };
24077
24247
  let marker = await readMarker(markerPath, stateDir, files.vault.old);
@@ -24079,10 +24249,10 @@ async function decide(location, options) {
24079
24249
  if (marker?.oldFilesRemoved) {
24080
24250
  await refuseReappearedFiles(location, files);
24081
24251
  const manifestLeft = await exists2(
24082
- join12(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE)
24252
+ join13(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE)
24083
24253
  ).catch(() => true);
24084
24254
  if (!manifestLeft) {
24085
- await settleVault(location, options, "state-home", log8);
24255
+ await settleVault(location, options, "state-home", log9);
24086
24256
  return stateHome();
24087
24257
  }
24088
24258
  }
@@ -24094,7 +24264,7 @@ async function decide(location, options) {
24094
24264
  RUNTIME_LAYOUT_LOCK_NAME,
24095
24265
  markerPath,
24096
24266
  options.layoutLockWaitMs ?? LAYOUT_LOCK_WAIT_MS,
24097
- log8
24267
+ log9
24098
24268
  );
24099
24269
  } catch (error) {
24100
24270
  marker = await readMarker(markerPath, stateDir, files.vault.old);
@@ -24114,7 +24284,7 @@ async function decide(location, options) {
24114
24284
  const legacy = async () => {
24115
24285
  try {
24116
24286
  await lock.assertOwned();
24117
- await settleVault(location, options, "legacy", log8);
24287
+ await settleVault(location, options, "legacy", log9);
24118
24288
  } catch (error) {
24119
24289
  throw new RuntimeLayoutRefusal(stateDir, errorClass(error));
24120
24290
  }
@@ -24128,20 +24298,20 @@ async function decide(location, options) {
24128
24298
  if (!marker.oldFilesRemoved && !aliased)
24129
24299
  await finishOldFiles(location, files, markerPath, marker, lock, {
24130
24300
  fence,
24131
- log: log8,
24301
+ log: log9,
24132
24302
  steps: options.steps,
24133
24303
  oldSignatureCache: options.oldSignatureCacheFile ?? legacySignatureCacheFile()
24134
24304
  });
24135
24305
  else if (marker.oldFilesRemoved) {
24136
24306
  await refuseReappearedFiles(location, files);
24137
- await removeLeftoverManifest(location, lock, options.steps, log8);
24307
+ await removeLeftoverManifest(location, lock, options.steps, log9);
24138
24308
  }
24139
24309
  return await stateHome();
24140
24310
  }
24141
24311
  if (aliased) {
24142
24312
  logOnce(
24143
24313
  `${location.key}\0aliased`,
24144
- () => log8.warn(
24314
+ () => log9.warn(
24145
24315
  "antigravity-auth keeps its vault files in OpenCode's config folder: its state folder is that same folder",
24146
24316
  { configDir: location.configDir, stateDir }
24147
24317
  )
@@ -24150,14 +24320,14 @@ async function decide(location, options) {
24150
24320
  }
24151
24321
  const gate = await fence();
24152
24322
  if (!gate.open) {
24153
- logDeferral(location, gate.blockers, log8);
24323
+ logDeferral(location, gate.blockers, log9);
24154
24324
  return await legacy();
24155
24325
  }
24156
24326
  let markerStarted = false;
24157
24327
  try {
24158
24328
  const outcome = await moveFiles(location, files, markerPath, lock, {
24159
24329
  fence,
24160
- log: log8,
24330
+ log: log9,
24161
24331
  steps: options.steps,
24162
24332
  destinationPrivate: options.destinationPrivate ?? defaultDestinationPrivate,
24163
24333
  oldSignatureCache: options.oldSignatureCacheFile ?? legacySignatureCacheFile(),
@@ -24166,13 +24336,13 @@ async function decide(location, options) {
24166
24336
  }
24167
24337
  });
24168
24338
  if (outcome.kind === "deferred") {
24169
- logDeferral(location, outcome.blockers, log8);
24339
+ logDeferral(location, outcome.blockers, log9);
24170
24340
  return await legacy();
24171
24341
  }
24172
24342
  if (outcome.kind === "refused") {
24173
24343
  logOnce(
24174
24344
  `${location.key}\0refused`,
24175
- () => log8.warn(
24345
+ () => log9.warn(
24176
24346
  outcome.reason === "destination-not-private" ? "antigravity-auth keeps its vault files in OpenCode's config folder: the vault folder in its state folder already exists and is not private to your user. It was left unchanged; remove it if it holds nothing you need, then restart OpenCode." : "antigravity-auth keeps its vault files in OpenCode's config folder: it will not move them",
24177
24347
  { reason: outcome.reason, paths: outcome.paths, stateDir }
24178
24348
  )
@@ -24180,7 +24350,7 @@ async function decide(location, options) {
24180
24350
  return await legacy();
24181
24351
  }
24182
24352
  if (outcome.moved)
24183
- log8.info(
24353
+ log9.info(
24184
24354
  "antigravity-auth moved its vault files out of OpenCode's config folder",
24185
24355
  { from: files.vault.old, to: files.vault.next }
24186
24356
  );
@@ -24191,7 +24361,7 @@ async function decide(location, options) {
24191
24361
  return await stateHome();
24192
24362
  logOnce(
24193
24363
  `${location.key}\0failed`,
24194
- () => log8.warn(
24364
+ () => log9.warn(
24195
24365
  "antigravity-auth's vault files stay in OpenCode's config folder: moving them failed; the move is tried again at the next start",
24196
24366
  {
24197
24367
  configDir: location.configDir,
@@ -24220,8 +24390,12 @@ async function settleVault(location, options, layout, _log) {
24220
24390
  }
24221
24391
  async function localAccountStoreAuthorized() {
24222
24392
  const location = runtimeLayoutLocation();
24393
+ const folder = process.env.OPENCODE_ANTIGRAVITY_AUTH_VAULT_DIR ? (await Promise.resolve().then(() => (init_vault_folder(), vault_folder_exports))).currentVaultFolder(
24394
+ accountFileForVault(location.configDir)
24395
+ ) : void 0;
24396
+ if (folder?.refusal) return false;
24223
24397
  const claustrum = await loadCommonAuthClaustrum();
24224
- const vaultDir = decidedRuntimeLayout(location) === "state-home" ? stateHomeVaultDir(location) : legacyVaultDir(accountFileForVault(location.configDir));
24398
+ const vaultDir = folder ? folder.vaultDir : decidedRuntimeLayout(location) === "state-home" ? stateHomeVaultDir(location) : legacyVaultDir(accountFileForVault(location.configDir));
24225
24399
  return await enrollmentAuthority2(
24226
24400
  claustrum.hostEnrollmentPaths({
24227
24401
  stateDir: vaultDir,
@@ -24236,7 +24410,7 @@ async function prepareAccountStore(options) {
24236
24410
  if (!await localAccountStoreAuthorized()) return void 0;
24237
24411
  const decided = decidedAccountStoreAnchor(location);
24238
24412
  if (decided) return decided;
24239
- const log8 = options.log ?? createLogger4("runtime-layout");
24413
+ const log9 = options.log ?? createLogger4("runtime-layout");
24240
24414
  const runKey = `${location.stateHomeDir}\0${location.key}`;
24241
24415
  let run = processState.storeRuns.get(runKey);
24242
24416
  if (!run) {
@@ -24245,14 +24419,14 @@ async function prepareAccountStore(options) {
24245
24419
  await ensureOwnerOnlyDir(location.stateHomeDir);
24246
24420
  const lock = await takeLock(
24247
24421
  RUNTIME_LAYOUT_LOCK_NAME,
24248
- join12(location.stateHomeDir, RUNTIME_LAYOUT_MARKER_FILE),
24422
+ join13(location.stateHomeDir, RUNTIME_LAYOUT_MARKER_FILE),
24249
24423
  options.layoutLockWaitMs ?? LAYOUT_LOCK_WAIT_MS,
24250
- log8
24424
+ log9
24251
24425
  );
24252
24426
  try {
24253
24427
  await lock.assertOwned();
24254
24428
  if (!await localAccountStoreAuthorized()) return void 0;
24255
- return await settleAccountStore(location, options, log8);
24429
+ return await settleAccountStore(location, options, log9);
24256
24430
  } finally {
24257
24431
  await lock.release();
24258
24432
  }
@@ -24263,20 +24437,20 @@ async function prepareAccountStore(options) {
24263
24437
  }
24264
24438
  return run;
24265
24439
  }
24266
- async function settleAccountStore(location, options, log8) {
24440
+ async function settleAccountStore(location, options, log9) {
24267
24441
  const decided = decidedAccountStoreAnchor(location);
24268
24442
  if (decided) return decided;
24269
- const anchor = await decideAccountStore(location, options, log8);
24443
+ const anchor = await decideAccountStore(location, options, log9);
24270
24444
  setAccountStoreAnchor(location, anchor);
24271
24445
  return anchor;
24272
24446
  }
24273
- async function decideAccountStore(location, options, log8) {
24274
- const keepConfig = () => recordAnchor(location, options, "config", log8);
24447
+ async function decideAccountStore(location, options, log9) {
24448
+ const keepConfig = () => recordAnchor(location, options, "config", log9);
24275
24449
  if (processHasOlderGeneration()) {
24276
24450
  logOnce(
24277
24451
  "older-generation-account-store",
24278
24452
  () => showLog(
24279
- log8,
24453
+ log9,
24280
24454
  "antigravity-auth keeps the account store in OpenCode's config folder until OpenCode restarts, because an older version of the plugin ran in this process.",
24281
24455
  { accountStore: "config" }
24282
24456
  )
@@ -24290,7 +24464,7 @@ async function decideAccountStore(location, options, log8) {
24290
24464
  if (!sameSpelling(forward.legacyPath, stateAnchor)) {
24291
24465
  logOnce(
24292
24466
  `${location.key}\0store-forward-elsewhere`,
24293
- () => log8.warn(
24467
+ () => log9.warn(
24294
24468
  "the account store moved to another folder than this process resolved; check XDG_STATE_HOME",
24295
24469
  { movedTo: forward.legacyPath, expected: stateAnchor }
24296
24470
  )
@@ -24301,9 +24475,9 @@ async function decideAccountStore(location, options, log8) {
24301
24475
  options,
24302
24476
  configAnchor,
24303
24477
  stateAnchor,
24304
- log8
24478
+ log9
24305
24479
  );
24306
- return recordAnchor(location, options, "state-home", log8);
24480
+ return recordAnchor(location, options, "state-home", log9);
24307
24481
  }
24308
24482
  if (decidedRuntimeLayout(location) === "legacy") return keepConfig();
24309
24483
  const configStore = await presentAccountStore(configAnchor);
@@ -24315,9 +24489,9 @@ async function decideAccountStore(location, options, log8) {
24315
24489
  `antigravity-auth cannot start: two account stores exist, one at ${configAnchor} and one at ${stateAnchor}, and neither is marked as moved. Keep the one you want and move the other one aside, then restart OpenCode.`
24316
24490
  );
24317
24491
  }
24318
- if (stateStore) return recordAnchor(location, options, "state-home", log8);
24492
+ if (stateStore) return recordAnchor(location, options, "state-home", log9);
24319
24493
  if (configStore) {
24320
- if (!await storeMovePathResolves(stateAnchor, location, log8))
24494
+ if (!await storeMovePathResolves(stateAnchor, location, log9))
24321
24495
  return keepConfig();
24322
24496
  return moveStore(
24323
24497
  location,
@@ -24325,21 +24499,21 @@ async function decideAccountStore(location, options, log8) {
24325
24499
  configAnchor,
24326
24500
  stateAnchor,
24327
24501
  false,
24328
- log8,
24502
+ log9,
24329
24503
  false
24330
24504
  );
24331
24505
  }
24332
- if (await storeArtefacts(stateAnchor) > 0 && !await abandonUnpublishedStore(location, stateAnchor, log8))
24506
+ if (await storeArtefacts(stateAnchor) > 0 && !await abandonUnpublishedStore(location, stateAnchor, log9))
24333
24507
  return keepConfig();
24334
- if (!await storeMovePathResolves(stateAnchor, location, log8))
24508
+ if (!await storeMovePathResolves(stateAnchor, location, log9))
24335
24509
  return keepConfig();
24336
- return initializeStore(location, options, stateAnchor, log8);
24510
+ return initializeStore(location, options, stateAnchor, log9);
24337
24511
  }
24338
- function showLog(log8, message, meta) {
24339
- if (log8.log) log8.log(message, meta);
24340
- else log8.info(message, meta);
24512
+ function showLog(log9, message, meta) {
24513
+ if (log9.log) log9.log(message, meta);
24514
+ else log9.info(message, meta);
24341
24515
  }
24342
- async function recordAnchor(location, options, anchor, log8) {
24516
+ async function recordAnchor(location, options, anchor, log9) {
24343
24517
  try {
24344
24518
  await recordProcessAnchor({
24345
24519
  key: location.key,
@@ -24351,32 +24525,32 @@ async function recordAnchor(location, options, anchor, log8) {
24351
24525
  }
24352
24526
  if (anchor === "state-home")
24353
24527
  showLog(
24354
- log8,
24528
+ log9,
24355
24529
  "antigravity-auth keeps its account store in its state folder",
24356
24530
  { accountStore: anchor }
24357
24531
  );
24358
24532
  return anchor;
24359
24533
  }
24360
- async function storeMovePathResolves(stateAnchor, location, log8) {
24534
+ async function storeMovePathResolves(stateAnchor, location, log9) {
24361
24535
  if (folderResolvesToItself(
24362
- join12(location.stateHomeDir, "antigravity-accounts.json")
24536
+ join13(location.stateHomeDir, "antigravity-accounts.json")
24363
24537
  ))
24364
24538
  return true;
24365
24539
  logOnce(
24366
24540
  `${location.key}\0store-linked-path`,
24367
- () => log8.warn(ACCOUNT_STORE_LINKED_PATH_MESSAGE, {
24541
+ () => log9.warn(ACCOUNT_STORE_LINKED_PATH_MESSAGE, {
24368
24542
  accountStore: stateAnchor,
24369
24543
  stateFolder: location.stateHomeDir
24370
24544
  })
24371
24545
  );
24372
24546
  return false;
24373
24547
  }
24374
- async function storeFenceOpen(location, options, log8) {
24548
+ async function storeFenceOpen(location, options, log9) {
24375
24549
  const gate = await (options.storeFence ?? defaultStoreFence(options.version))();
24376
24550
  if (gate.open) return true;
24377
24551
  logOnce(
24378
24552
  `${location.key}\0store-version-fence`,
24379
- () => log8.info(ACCOUNT_STORE_DEFERRED_MESSAGE, {
24553
+ () => log9.info(ACCOUNT_STORE_DEFERRED_MESSAGE, {
24380
24554
  configDir: location.configDir,
24381
24555
  blockers: gate.blockers
24382
24556
  })
@@ -24403,7 +24577,7 @@ async function storeArtefacts(anchor) {
24403
24577
  (name) => name === store || name.startsWith(`${pool}.store.`) || name.startsWith(pool) && name.endsWith(".tmp")
24404
24578
  ).length;
24405
24579
  }
24406
- async function abandonUnpublishedStore(location, stateAnchor, log8) {
24580
+ async function abandonUnpublishedStore(location, stateAnchor, log9) {
24407
24581
  const store = await loadCommonAuthStoreModules();
24408
24582
  const binding = await readAccountStoreBinding(stateAnchor, store, Date.now);
24409
24583
  if (binding.status === "bound") return false;
@@ -24412,9 +24586,9 @@ async function abandonUnpublishedStore(location, stateAnchor, log8) {
24412
24586
  await rename10(folder, archived).catch((error) => {
24413
24587
  if (error.code !== "ENOENT") throw error;
24414
24588
  });
24415
- await unlink9(accountStorePointerPath(stateAnchor)).catch(() => {
24589
+ await unlink10(accountStorePointerPath(stateAnchor)).catch(() => {
24416
24590
  });
24417
- log8.info(
24591
+ log9.info(
24418
24592
  "antigravity-auth set an unfinished account store aside before starting its move again",
24419
24593
  { configDir: location.configDir, archived }
24420
24594
  );
@@ -24436,9 +24610,9 @@ async function runStoreMove(input) {
24436
24610
  return { status: "pending", reason: outcome.reason };
24437
24611
  return { status: "cancelled" };
24438
24612
  }
24439
- async function moveStore(location, options, source, target, back, log8, forwarded) {
24440
- const keepConfig = () => recordAnchor(location, options, "config", log8);
24441
- if (!await storeFenceOpen(location, options, log8)) return keepConfig();
24613
+ async function moveStore(location, options, source, target, back, log9, forwarded) {
24614
+ const keepConfig = () => recordAnchor(location, options, "config", log9);
24615
+ if (!await storeFenceOpen(location, options, log9)) return keepConfig();
24442
24616
  try {
24443
24617
  const result = await (options.relocate ?? runStoreMove)({
24444
24618
  source,
@@ -24448,7 +24622,7 @@ async function moveStore(location, options, source, target, back, log8, forwarde
24448
24622
  if (result.status !== "completed") {
24449
24623
  logOnce(
24450
24624
  `${location.key}\0store-move-unfinished`,
24451
- () => log8.info(ACCOUNT_STORE_DEFERRED_MESSAGE, {
24625
+ () => log9.info(ACCOUNT_STORE_DEFERRED_MESSAGE, {
24452
24626
  configDir: location.configDir,
24453
24627
  reason: result.status === "pending" ? result.reason : result.status
24454
24628
  })
@@ -24456,14 +24630,14 @@ async function moveStore(location, options, source, target, back, log8, forwarde
24456
24630
  return forwarded ? "state-home" : keepConfig();
24457
24631
  }
24458
24632
  showLog(
24459
- log8,
24633
+ log9,
24460
24634
  "antigravity-auth moved the account store out of OpenCode's config folder",
24461
24635
  { from: source, to: target, generation: result.id }
24462
24636
  );
24463
24637
  } catch (error) {
24464
24638
  logOnce(
24465
24639
  `${location.key}\0store-move-failed`,
24466
- () => log8.warn(
24640
+ () => log9.warn(
24467
24641
  "antigravity-auth's account store stays in OpenCode's config folder: moving it failed; the move is tried again at the next start",
24468
24642
  {
24469
24643
  configDir: location.configDir,
@@ -24474,9 +24648,9 @@ async function moveStore(location, options, source, target, back, log8, forwarde
24474
24648
  );
24475
24649
  return forwarded ? "state-home" : keepConfig();
24476
24650
  }
24477
- return recordAnchor(location, options, "state-home", log8);
24651
+ return recordAnchor(location, options, "state-home", log9);
24478
24652
  }
24479
- async function resumeForwardedStore(location, options, configAnchor, stateAnchor, log8) {
24653
+ async function resumeForwardedStore(location, options, configAnchor, stateAnchor, log9) {
24480
24654
  const store = await loadCommonAuthStoreModules();
24481
24655
  const binding = await readAccountStoreBinding(stateAnchor, store, Date.now);
24482
24656
  if (binding.status === "bound") return;
@@ -24487,13 +24661,13 @@ async function resumeForwardedStore(location, options, configAnchor, stateAnchor
24487
24661
  configAnchor,
24488
24662
  stateAnchor,
24489
24663
  false,
24490
- log8,
24664
+ log9,
24491
24665
  true
24492
24666
  );
24493
24667
  } catch (error) {
24494
24668
  logOnce(
24495
24669
  `${location.key}\0store-resume-failed`,
24496
- () => log8.warn(
24670
+ () => log9.warn(
24497
24671
  "antigravity-auth's account store is still moving; it could not be finished at this start",
24498
24672
  {
24499
24673
  configDir: location.configDir,
@@ -24504,9 +24678,9 @@ async function resumeForwardedStore(location, options, configAnchor, stateAnchor
24504
24678
  );
24505
24679
  }
24506
24680
  }
24507
- async function initializeStore(location, options, stateAnchor, log8) {
24508
- const keepConfig = () => recordAnchor(location, options, "config", log8);
24509
- if (!await storeFenceOpen(location, options, log8)) return keepConfig();
24681
+ async function initializeStore(location, options, stateAnchor, log9) {
24682
+ const keepConfig = () => recordAnchor(location, options, "config", log9);
24683
+ if (!await storeFenceOpen(location, options, log9)) return keepConfig();
24510
24684
  try {
24511
24685
  const store = await loadCommonAuthStoreModules();
24512
24686
  const created = await initializeFreshAccountStore(store, {
@@ -24519,7 +24693,7 @@ async function initializeStore(location, options, stateAnchor, log8) {
24519
24693
  } catch (error) {
24520
24694
  logOnce(
24521
24695
  `${location.key}\0store-init-failed`,
24522
- () => log8.warn(
24696
+ () => log9.warn(
24523
24697
  "antigravity-auth's account store stays in OpenCode's config folder: creating it in its state folder failed; it is tried again at the next start",
24524
24698
  {
24525
24699
  configDir: location.configDir,
@@ -24531,13 +24705,13 @@ async function initializeStore(location, options, stateAnchor, log8) {
24531
24705
  return keepConfig();
24532
24706
  }
24533
24707
  showLog(
24534
- log8,
24708
+ log9,
24535
24709
  "antigravity-auth created its account store in its state folder",
24536
24710
  {
24537
24711
  accountStore: stateAnchor
24538
24712
  }
24539
24713
  );
24540
- return recordAnchor(location, options, "state-home", log8);
24714
+ return recordAnchor(location, options, "state-home", log9);
24541
24715
  }
24542
24716
  async function writeStateHomeStoreForward(id, stateAnchor, configAnchor = legacyAccountFile(runtimeLayoutLocation().configDir)) {
24543
24717
  const forward = {
@@ -24552,10 +24726,10 @@ async function writeStateHomeStoreForward(id, stateAnchor, configAnchor = legacy
24552
24726
  durability: "file-only-on-windows"
24553
24727
  });
24554
24728
  }
24555
- function logDeferral(location, blockers, log8) {
24729
+ function logDeferral(location, blockers, log9) {
24556
24730
  logOnce(
24557
24731
  `${location.key}\0deferred`,
24558
- () => log8.info(RUNTIME_LAYOUT_DEFERRED_MESSAGE, {
24732
+ () => log9.info(RUNTIME_LAYOUT_DEFERRED_MESSAGE, {
24559
24733
  configDir: location.configDir,
24560
24734
  blockers
24561
24735
  })
@@ -24604,7 +24778,7 @@ async function moveFiles(location, files, markerPath, layoutLock, input) {
24604
24778
  for (const path2 of listed) {
24605
24779
  if (wanted.has(path2)) continue;
24606
24780
  await layoutLock.assertOwned();
24607
- await unlink9(path2).catch((error) => {
24781
+ await unlink10(path2).catch((error) => {
24608
24782
  if (error.code !== "ENOENT") throw error;
24609
24783
  });
24610
24784
  }
@@ -24713,13 +24887,13 @@ async function finishOldFiles(location, files, markerPath, marker, layoutLock, i
24713
24887
  if (done) await removeOldVaultFolder(files, layoutLock, input.steps);
24714
24888
  }
24715
24889
  }
24716
- async function removeLeftoverManifest(location, layoutLock, steps, log8) {
24890
+ async function removeLeftoverManifest(location, layoutLock, steps, log9) {
24717
24891
  try {
24718
24892
  await removeManifestOwned(location.stateHomeDir, layoutLock, steps);
24719
24893
  } catch (error) {
24720
24894
  logOnce(
24721
24895
  `${location.key}\0manifest`,
24722
- () => log8.warn(
24896
+ () => log9.warn(
24723
24897
  `antigravity-auth could not remove ${RUNTIME_LAYOUT_MANIFEST_FILE} from its state folder; it tries again at the next start`,
24724
24898
  { stateDir: location.stateHomeDir, errorClass: errorClass(error) }
24725
24899
  )
@@ -24727,7 +24901,7 @@ async function removeLeftoverManifest(location, layoutLock, steps, log8) {
24727
24901
  }
24728
24902
  }
24729
24903
  async function removeManifestOwned(stateDir, layoutLock, steps) {
24730
- const path2 = join12(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE);
24904
+ const path2 = join13(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE);
24731
24905
  if (!await exists2(path2)) return;
24732
24906
  await beforeRemove(path2, layoutLock, steps);
24733
24907
  await removeManifest(stateDir);
@@ -24739,16 +24913,16 @@ async function removeOldVaultFolder(files, layoutLock, steps) {
24739
24913
  } catch {
24740
24914
  }
24741
24915
  }
24742
- async function removeOldSignatureCache(location, path2, layoutLock, steps, log8) {
24916
+ async function removeOldSignatureCache(location, path2, layoutLock, steps, log9) {
24743
24917
  try {
24744
24918
  if (!await exists2(path2)) return;
24745
24919
  await beforeRemove(path2, layoutLock, steps);
24746
- await unlink9(path2);
24920
+ await unlink10(path2);
24747
24921
  } catch (error) {
24748
24922
  if (error?.code === "ENOENT") return;
24749
24923
  logOnce(
24750
24924
  `${location.key}\0signature-cache`,
24751
- () => log8.warn(
24925
+ () => log9.warn(
24752
24926
  "antigravity-auth could not remove its old signature cache from OpenCode's config folder; it is no longer used and can be deleted",
24753
24927
  { path: path2, errorClass: errorClass(error) }
24754
24928
  )
@@ -24759,7 +24933,7 @@ async function beforeRemove(path2, layoutLock, steps) {
24759
24933
  await steps?.beforeRemove?.(path2);
24760
24934
  await layoutLock.assertOwned();
24761
24935
  }
24762
- async function takeDataLocks(files, log8) {
24936
+ async function takeDataLocks(files, log9) {
24763
24937
  const locks = [];
24764
24938
  try {
24765
24939
  if (await exists2(files.vault.old))
@@ -24767,9 +24941,9 @@ async function takeDataLocks(files, log8) {
24767
24941
  locks.push(
24768
24942
  await takeLock(
24769
24943
  lock.name,
24770
- join12(files.vault.old, lock.file),
24944
+ join13(files.vault.old, lock.file),
24771
24945
  lock.waitMs,
24772
- log8
24946
+ log9
24773
24947
  )
24774
24948
  );
24775
24949
  return locks;
@@ -24794,8 +24968,8 @@ function sha256(bytes) {
24794
24968
  }
24795
24969
  function vaultStateFile(files) {
24796
24970
  return {
24797
- old: join12(files.vault.old, VAULT_ENROLLMENT_STATE_FILE),
24798
- next: join12(files.vault.next, VAULT_ENROLLMENT_STATE_FILE)
24971
+ old: join13(files.vault.old, VAULT_ENROLLMENT_STATE_FILE),
24972
+ next: join13(files.vault.next, VAULT_ENROLLMENT_STATE_FILE)
24799
24973
  };
24800
24974
  }
24801
24975
  async function keepableVaultState(files, present2) {
@@ -24833,19 +25007,20 @@ async function isVaultShapedKeptState(files) {
24833
25007
  return vaultShape && proposedName === OPENCODE_VAULT_ENROLLMENT_NAME;
24834
25008
  }
24835
25009
  async function removeMovedVaultStateLeftover(vaultDir, accountFile) {
25010
+ if (process.env.OPENCODE_ANTIGRAVITY_AUTH_VAULT_DIR) return;
24836
25011
  const location = runtimeLayoutLocation();
24837
25012
  const files = layoutFiles(location, accountFile);
24838
- if (resolve14(vaultDir) !== resolve14(files.vault.next)) return;
25013
+ if (resolve15(vaultDir) !== resolve15(files.vault.next)) return;
24839
25014
  const stateDir = location.stateHomeDir;
24840
25015
  const marker = await readMarker(
24841
- join12(stateDir, RUNTIME_LAYOUT_MARKER_FILE),
25016
+ join13(stateDir, RUNTIME_LAYOUT_MARKER_FILE),
24842
25017
  stateDir,
24843
25018
  files.vault.old
24844
25019
  );
24845
25020
  if (!marker?.oldDir || marker.oldDir !== location.key) return;
24846
25021
  const leftover = vaultStateFile(files).old;
24847
25022
  if (!await isVaultShapedKeptState(files)) return;
24848
- await unlink9(leftover).catch((error) => {
25023
+ await unlink10(leftover).catch((error) => {
24849
25024
  if (error.code !== "ENOENT") throw error;
24850
25025
  });
24851
25026
  await rmdir2(files.vault.old).catch(() => {
@@ -24867,13 +25042,13 @@ async function vaultFiles(dir) {
24867
25042
  }
24868
25043
  async function presentOldFiles(files) {
24869
25044
  return (await vaultFiles(files.vault.old)).map((name) => ({
24870
- old: join12(files.vault.old, name),
24871
- next: join12(files.vault.next, name)
25045
+ old: join13(files.vault.old, name),
25046
+ next: join13(files.vault.next, name)
24872
25047
  }));
24873
25048
  }
24874
25049
  async function destinationFiles(files) {
24875
25050
  return (await vaultFiles(files.vault.next)).map(
24876
- (name) => join12(files.vault.next, name)
25051
+ (name) => join13(files.vault.next, name)
24877
25052
  );
24878
25053
  }
24879
25054
  async function physicalAliases(location, files) {
@@ -24882,7 +25057,7 @@ async function physicalAliases(location, files) {
24882
25057
  [files.vault.old, files.vault.next]
24883
25058
  ];
24884
25059
  for (const name of VAULT_FILE_NAMES)
24885
- pairs.push([join12(files.vault.old, name), join12(files.vault.next, name)]);
25060
+ pairs.push([join13(files.vault.old, name), join13(files.vault.next, name)]);
24886
25061
  const aliased = [];
24887
25062
  for (const [old, next] of pairs)
24888
25063
  if (await samePhysical(old, next)) aliased.push(old);
@@ -24891,7 +25066,7 @@ async function physicalAliases(location, files) {
24891
25066
  async function samePhysical(a, b) {
24892
25067
  const id = async (path2) => {
24893
25068
  try {
24894
- const info = await stat8(path2, { bigint: true });
25069
+ const info = await stat9(path2, { bigint: true });
24895
25070
  return info.ino === 0n ? void 0 : `${info.dev}:${info.ino}`;
24896
25071
  } catch (error) {
24897
25072
  const code2 = error.code;
@@ -24981,7 +25156,7 @@ async function unlinkIfIdentical(file, stateDir, guard) {
24981
25156
  if (!same) throw credentialConflict(stateDir, file);
24982
25157
  await guard();
24983
25158
  try {
24984
- await unlink9(file.old);
25159
+ await unlink10(file.old);
24985
25160
  return true;
24986
25161
  } catch (error) {
24987
25162
  if (error.code === "ENOENT") return true;
@@ -24994,11 +25169,11 @@ async function unlinkIfIdentical(file, stateDir, guard) {
24994
25169
  async function refuseReappearedFiles(location, files) {
24995
25170
  const keptState = vaultStateFile(files).old;
24996
25171
  for (const name of await vaultFiles(files.vault.old)) {
24997
- const old = join12(files.vault.old, name);
25172
+ const old = join13(files.vault.old, name);
24998
25173
  if (old === keptState && await isVaultShapedKeptState(files)) continue;
24999
25174
  throw credentialConflict(location.stateHomeDir, {
25000
25175
  old,
25001
- next: join12(files.vault.next, name)
25176
+ next: join13(files.vault.next, name)
25002
25177
  });
25003
25178
  }
25004
25179
  }
@@ -25040,13 +25215,13 @@ async function assertOwnFolder(location, marker, files) {
25040
25215
  const stateDir = location.stateHomeDir;
25041
25216
  if (marker?.oldDir !== void 0 && marker.oldDir !== location.key)
25042
25217
  throw foreignMarker(
25043
- join12(stateDir, RUNTIME_LAYOUT_MARKER_FILE),
25218
+ join13(stateDir, RUNTIME_LAYOUT_MARKER_FILE),
25044
25219
  location.key,
25045
25220
  files.vault.old
25046
25221
  );
25047
25222
  let text2;
25048
25223
  try {
25049
- text2 = await readFile10(join12(stateDir, RUNTIME_CONFIG_DIR_NOTE_FILE), "utf8");
25224
+ text2 = await readFile10(join13(stateDir, RUNTIME_CONFIG_DIR_NOTE_FILE), "utf8");
25050
25225
  } catch (error) {
25051
25226
  const code2 = error.code;
25052
25227
  if (code2 === "ENOENT" || code2 === "ENOTDIR") return;
@@ -25060,7 +25235,7 @@ async function assertOwnFolder(location, marker, files) {
25060
25235
  if (owner !== location.key) throw foreignFolder(stateDir, location.key);
25061
25236
  }
25062
25237
  async function writeOwnerNote(location) {
25063
- const path2 = join12(location.stateHomeDir, RUNTIME_CONFIG_DIR_NOTE_FILE);
25238
+ const path2 = join13(location.stateHomeDir, RUNTIME_CONFIG_DIR_NOTE_FILE);
25064
25239
  if (await exists2(path2)) return;
25065
25240
  await writePrivateText(
25066
25241
  path2,
@@ -25071,7 +25246,7 @@ async function writeOwnerNote(location) {
25071
25246
  async function readManifest(stateDir) {
25072
25247
  let text2;
25073
25248
  try {
25074
- text2 = await readFile10(join12(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE), "utf8");
25249
+ text2 = await readFile10(join13(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE), "utf8");
25075
25250
  } catch (error) {
25076
25251
  if (error.code === "ENOENT") return /* @__PURE__ */ new Set();
25077
25252
  throw error;
@@ -25088,13 +25263,13 @@ async function readManifest(stateDir) {
25088
25263
  }
25089
25264
  async function writeManifest(stateDir, paths) {
25090
25265
  await writePrivateText(
25091
- join12(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE),
25266
+ join13(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE),
25092
25267
  `${JSON.stringify({ version: 1, files: paths }, null, 2)}
25093
25268
  `
25094
25269
  );
25095
25270
  }
25096
25271
  async function removeManifest(stateDir) {
25097
- await unlink9(join12(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE)).catch(
25272
+ await unlink10(join13(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE)).catch(
25098
25273
  (error) => {
25099
25274
  if (error.code !== "ENOENT") throw error;
25100
25275
  }
@@ -25118,7 +25293,7 @@ async function ensureOwnerOnlyDir(path2) {
25118
25293
  await mkdir12(path2, { recursive: true, mode: 448 });
25119
25294
  await chmod4(path2, 448);
25120
25295
  }
25121
- async function takeLock(name, path2, waitMs, log8) {
25296
+ async function takeLock(name, path2, waitMs, log9) {
25122
25297
  const fs3 = await loadCommonAuthFs();
25123
25298
  const started = performance.now();
25124
25299
  let announced = false;
@@ -25143,7 +25318,7 @@ async function takeLock(name, path2, waitMs, log8) {
25143
25318
  );
25144
25319
  if (!announced && waited >= LOCK_WAIT_NOTICE_MS) {
25145
25320
  announced = true;
25146
- log8.info(
25321
+ log9.info(
25147
25322
  `antigravity-auth is waiting up to ${Math.round(waitMs / 1e3)} s for the ${name} lock at ${path2}.${lockHolderText(name)}`,
25148
25323
  { lock: name, path: path2 }
25149
25324
  );
@@ -25156,7 +25331,7 @@ function lockHolderText(name) {
25156
25331
  }
25157
25332
  async function exists2(path2) {
25158
25333
  try {
25159
- await stat8(path2);
25334
+ await stat9(path2);
25160
25335
  return true;
25161
25336
  } catch (error) {
25162
25337
  const code2 = error.code;
@@ -25164,7 +25339,7 @@ async function exists2(path2) {
25164
25339
  throw error;
25165
25340
  }
25166
25341
  }
25167
- var RUNTIME_LAYOUT_LOCK_NAME, RUNTIME_LAYOUT_MANIFEST_FILE, VAULT_ENROLLMENT_STATE_FILE, VAULT_ENROLLMENT_TOKEN_FILE, VAULT_FILE_NAMES, LOCK_TTL_MS, DATA_LOCKS, LAYOUT_LOCK_WAIT_MS, LOCK_RETRY_MS, LOCK_WAIT_NOTICE_MS, MARKER_READ_ATTEMPTS, MARKER_READ_RETRY_MS, SHARING_RETRY_DELAYS_MS, SHARING_RETRY_BUDGET_MS, RUNTIME_LAYOUT_DEFERRED_MESSAGE, ACCOUNT_STORE_DEFERRED_MESSAGE, ACCOUNT_STORE_LINKED_PATH_MESSAGE, RuntimeLayoutRefusal, stateKey2, globalState2, processState, LayoutMoveError, OldVaultFileKeptError, SHA256_HEX2;
25342
+ var RUNTIME_LAYOUT_LOCK_NAME, RUNTIME_LAYOUT_MANIFEST_FILE, VAULT_ENROLLMENT_STATE_FILE, VAULT_ENROLLMENT_TOKEN_FILE, VAULT_FILE_NAMES, LOCK_TTL_MS, DATA_LOCKS, LAYOUT_LOCK_WAIT_MS, LOCK_RETRY_MS, LOCK_WAIT_NOTICE_MS, MARKER_READ_ATTEMPTS, MARKER_READ_RETRY_MS, SHARING_RETRY_DELAYS_MS, SHARING_RETRY_BUDGET_MS, RUNTIME_LAYOUT_DEFERRED_MESSAGE, ACCOUNT_STORE_DEFERRED_MESSAGE, ACCOUNT_STORE_LINKED_PATH_MESSAGE, RuntimeLayoutRefusal, stateKey2, globalState3, processState, LayoutMoveError, OldVaultFileKeptError, SHA256_HEX2;
25168
25343
  var init_runtime_layout = __esm({
25169
25344
  "src/runtime-layout.ts"() {
25170
25345
  "use strict";
@@ -25221,8 +25396,8 @@ var init_runtime_layout = __esm({
25221
25396
  errorClass;
25222
25397
  };
25223
25398
  stateKey2 = /* @__PURE__ */ Symbol.for("@cortexkit/antigravity-auth/runtime-layout-runs");
25224
- globalState2 = globalThis;
25225
- processState = globalState2[stateKey2] ?? {
25399
+ globalState3 = globalThis;
25400
+ processState = globalState3[stateKey2] ?? {
25226
25401
  runs: /* @__PURE__ */ new Map(),
25227
25402
  storeRuns: /* @__PURE__ */ new Map(),
25228
25403
  logged: /* @__PURE__ */ new Set()
@@ -25230,7 +25405,7 @@ var init_runtime_layout = __esm({
25230
25405
  processState.runs ??= /* @__PURE__ */ new Map();
25231
25406
  processState.storeRuns ??= /* @__PURE__ */ new Map();
25232
25407
  processState.logged ??= /* @__PURE__ */ new Set();
25233
- globalState2[stateKey2] = processState;
25408
+ globalState3[stateKey2] = processState;
25234
25409
  LayoutMoveError = class extends Error {
25235
25410
  constructor(code2, message) {
25236
25411
  super(message);
@@ -25263,9 +25438,9 @@ import {
25263
25438
  writeFileSync
25264
25439
  } from "node:fs";
25265
25440
  import { homedir as homedir4 } from "node:os";
25266
- import { dirname as dirname16, join as join13, resolve as resolve15 } from "node:path";
25441
+ import { dirname as dirname16, join as join14, resolve as resolve16 } from "node:path";
25267
25442
  async function ensureGitignore(configDir) {
25268
- const gitignorePath = join13(configDir, ".gitignore");
25443
+ const gitignorePath = join14(configDir, ".gitignore");
25269
25444
  try {
25270
25445
  let content;
25271
25446
  let existingLines = [];
@@ -25291,7 +25466,7 @@ async function ensureGitignore(configDir) {
25291
25466
  `,
25292
25467
  "utf-8"
25293
25468
  );
25294
- log5.info("Created .gitignore in config directory");
25469
+ log6.info("Created .gitignore in config directory");
25295
25470
  } else {
25296
25471
  const suffix = content.endsWith("\n") ? "" : "\n";
25297
25472
  await fs.appendFile(
@@ -25300,19 +25475,19 @@ async function ensureGitignore(configDir) {
25300
25475
  `,
25301
25476
  "utf-8"
25302
25477
  );
25303
- log5.info("Updated .gitignore with missing entries", {
25478
+ log6.info("Updated .gitignore with missing entries", {
25304
25479
  added: missingEntries
25305
25480
  });
25306
25481
  }
25307
25482
  } catch (error) {
25308
- log5.warn("Failed to update .gitignore with account storage entries", {
25483
+ log6.warn("Failed to update .gitignore with account storage entries", {
25309
25484
  error: String(error)
25310
25485
  });
25311
25486
  }
25312
25487
  }
25313
25488
  function getLegacyWindowsConfigDir() {
25314
- return join13(
25315
- process.env.APPDATA || join13(homedir4(), "AppData", "Roaming"),
25489
+ return join14(
25490
+ process.env.APPDATA || join14(homedir4(), "AppData", "Roaming"),
25316
25491
  "opencode"
25317
25492
  );
25318
25493
  }
@@ -25320,15 +25495,15 @@ function getConfigDir() {
25320
25495
  if (process.env.OPENCODE_CONFIG_DIR) {
25321
25496
  return process.env.OPENCODE_CONFIG_DIR;
25322
25497
  }
25323
- const xdgConfig2 = process.env.XDG_CONFIG_HOME || join13(homedir4(), ".config");
25324
- return join13(xdgConfig2, "opencode");
25498
+ const xdgConfig2 = process.env.XDG_CONFIG_HOME || join14(homedir4(), ".config");
25499
+ return join14(xdgConfig2, "opencode");
25325
25500
  }
25326
25501
  function migrateLegacyWindowsConfig() {
25327
25502
  if (process.platform !== "win32") {
25328
25503
  return false;
25329
25504
  }
25330
- const newPath = join13(getConfigDir(), "antigravity-accounts.json");
25331
- const legacyPath = join13(
25505
+ const newPath = join14(getConfigDir(), "antigravity-accounts.json");
25506
+ const legacyPath = join14(
25332
25507
  getLegacyWindowsConfigDir(),
25333
25508
  "antigravity-accounts.json"
25334
25509
  );
@@ -25340,21 +25515,21 @@ function migrateLegacyWindowsConfig() {
25340
25515
  mkdirSync(newConfigDir, { recursive: true });
25341
25516
  try {
25342
25517
  renameSync3(legacyPath, newPath);
25343
- log5.info("Migrated Windows config via rename", {
25518
+ log6.info("Migrated Windows config via rename", {
25344
25519
  from: legacyPath,
25345
25520
  to: newPath
25346
25521
  });
25347
25522
  } catch {
25348
25523
  copyFileSync(legacyPath, newPath);
25349
25524
  unlinkSync(legacyPath);
25350
- log5.info("Migrated Windows config via copy+delete", {
25525
+ log6.info("Migrated Windows config via copy+delete", {
25351
25526
  from: legacyPath,
25352
25527
  to: newPath
25353
25528
  });
25354
25529
  }
25355
25530
  return true;
25356
25531
  } catch (error) {
25357
- log5.warn("Failed to migrate legacy Windows config, will use legacy path", {
25532
+ log6.warn("Failed to migrate legacy Windows config, will use legacy path", {
25358
25533
  legacyPath,
25359
25534
  newPath,
25360
25535
  error: String(error)
@@ -25363,8 +25538,8 @@ function migrateLegacyWindowsConfig() {
25363
25538
  }
25364
25539
  }
25365
25540
  function resolveWindowsAccountAnchor(newPath, legacyPath) {
25366
- const standard = resolve15(newPath);
25367
- const legacy = resolve15(legacyPath);
25541
+ const standard = resolve16(newPath);
25542
+ const legacy = resolve16(legacyPath);
25368
25543
  if (standard.toLowerCase() === legacy.toLowerCase()) return newPath;
25369
25544
  const standardPointer = existsSync3(accountStorePointerPath(standard));
25370
25545
  const legacyPointer = existsSync3(accountStorePointerPath(legacy));
@@ -25378,16 +25553,16 @@ function resolveWindowsAccountAnchor(newPath, legacyPath) {
25378
25553
  return newPath;
25379
25554
  }
25380
25555
  function getStoragePathWithMigration() {
25381
- const newPath = join13(getConfigDir(), "antigravity-accounts.json");
25556
+ const newPath = join14(getConfigDir(), "antigravity-accounts.json");
25382
25557
  if (process.platform === "win32") {
25383
25558
  migrateLegacyWindowsConfig();
25384
- const legacyPath = join13(
25559
+ const legacyPath = join14(
25385
25560
  getLegacyWindowsConfigDir(),
25386
25561
  "antigravity-accounts.json"
25387
25562
  );
25388
25563
  const anchored = resolveWindowsAccountAnchor(newPath, legacyPath);
25389
- if (resolve15(anchored).toLowerCase() !== resolve15(newPath).toLowerCase() && !existsSync3(accountStorePointerPath(resolve15(anchored)))) {
25390
- log5.info("Using legacy Windows config path (migration failed)", {
25564
+ if (resolve16(anchored).toLowerCase() !== resolve16(newPath).toLowerCase() && !existsSync3(accountStorePointerPath(resolve16(anchored)))) {
25565
+ log6.info("Using legacy Windows config path (migration failed)", {
25391
25566
  legacyPath,
25392
25567
  newPath
25393
25568
  });
@@ -25400,20 +25575,20 @@ function stateHomeStoragePath() {
25400
25575
  return stateHomeAccountFile(runtimeLayoutLocation());
25401
25576
  }
25402
25577
  function accountFileForVault(configDir = getConfigDir()) {
25403
- const configured = join13(configDir, "antigravity-accounts.json");
25578
+ const configured = join14(configDir, "antigravity-accounts.json");
25404
25579
  if (process.platform !== "win32") return configured;
25405
25580
  const legacyDir = getLegacyWindowsConfigDir();
25406
- if (resolve15(configDir).toLowerCase() === resolve15(legacyDir).toLowerCase())
25581
+ if (resolve16(configDir).toLowerCase() === resolve16(legacyDir).toLowerCase())
25407
25582
  return configured;
25408
- const configuredVault = join13(configDir, "antigravity-auth-vault");
25409
- const legacyVault = join13(legacyDir, "antigravity-auth-vault");
25583
+ const configuredVault = join14(configDir, "antigravity-auth-vault");
25584
+ const legacyVault = join14(legacyDir, "antigravity-auth-vault");
25410
25585
  const configuredPresent = existsSync3(configuredVault);
25411
25586
  const legacyPresent = existsSync3(legacyVault);
25412
25587
  if (configuredPresent && legacyPresent)
25413
25588
  throw new Error(
25414
25589
  `Two vault folders exist: ${configuredVault} and ${legacyVault}. Keep one vault enrollment before restarting OpenCode.`
25415
25590
  );
25416
- return legacyPresent ? join13(legacyDir, "antigravity-accounts.json") : configured;
25591
+ return legacyPresent ? join14(legacyDir, "antigravity-accounts.json") : configured;
25417
25592
  }
25418
25593
  async function prepareLocalAccountStore() {
25419
25594
  if (!decidedRuntimeLayout(runtimeLayoutLocation())) return;
@@ -25428,13 +25603,13 @@ function getStoragePath() {
25428
25603
  if (anchor === "config") return getStoragePathWithMigration();
25429
25604
  const location = runtimeLayoutLocation();
25430
25605
  if (decidedRuntimeLayout(location))
25431
- return join13(location.configDir, "antigravity-accounts.json");
25606
+ return join14(location.configDir, "antigravity-accounts.json");
25432
25607
  const configPath = getStoragePathWithMigration();
25433
25608
  return readForwardedAccountStore(configPath)?.legacyPath ?? configPath;
25434
25609
  }
25435
25610
  async function assertLegacyPoolInUse(legacyPath) {
25436
25611
  try {
25437
- await assertLegacyAccountStorageWritable(resolve15(legacyPath));
25612
+ await assertLegacyAccountStorageWritable(resolve16(legacyPath));
25438
25613
  } catch (error) {
25439
25614
  throw new LegacyAccountPoolRetiredError(legacyPath, { cause: error });
25440
25615
  }
@@ -25452,7 +25627,7 @@ function refusalMessage2(admission) {
25452
25627
  async function bindingOf(options) {
25453
25628
  if (options.legacyPath === void 0) await prepareLocalAccountStore();
25454
25629
  const now = options.now ?? (() => Date.now());
25455
- const legacyPath = resolve15(options.legacyPath ?? getStoragePath());
25630
+ const legacyPath = resolve16(options.legacyPath ?? getStoragePath());
25456
25631
  return {
25457
25632
  legacyPath,
25458
25633
  now,
@@ -25521,7 +25696,7 @@ async function openAccountStore(options) {
25521
25696
  async function initializeFreshAccountStoreFor(modules, options = {}) {
25522
25697
  if (options.legacyPath === void 0) await prepareLocalAccountStore();
25523
25698
  return initializeFreshAccountStore(modules, {
25524
- legacyPath: resolve15(options.legacyPath ?? getStoragePath()),
25699
+ legacyPath: resolve16(options.legacyPath ?? getStoragePath()),
25525
25700
  now: options.now ?? (() => Date.now())
25526
25701
  });
25527
25702
  }
@@ -25531,14 +25706,14 @@ async function loadAccounts() {
25531
25706
  await ensureGitignore(dirname16(path2));
25532
25707
  return loadAccountStorage(path2);
25533
25708
  }
25534
- var log5, GITIGNORE_ENTRIES, LegacyAccountPoolRetiredError, MIGRATE_COMMAND, UNMIGRATED_ACCOUNT_MESSAGE, ROLLBACK_COMMAND;
25709
+ var log6, GITIGNORE_ENTRIES, LegacyAccountPoolRetiredError, MIGRATE_COMMAND, UNMIGRATED_ACCOUNT_MESSAGE, ROLLBACK_COMMAND;
25535
25710
  var init_storage = __esm({
25536
25711
  "src/plugin/storage.ts"() {
25537
25712
  "use strict";
25538
25713
  init_dist();
25539
25714
  init_runtime_paths();
25540
25715
  init_logger4();
25541
- log5 = createLogger4("storage");
25716
+ log6 = createLogger4("storage");
25542
25717
  GITIGNORE_ENTRIES = [
25543
25718
  "antigravity-accounts.json",
25544
25719
  "antigravity-accounts.json.*.tmp",
@@ -25567,12 +25742,12 @@ var init_storage = __esm({
25567
25742
  import { createHash as createHash11 } from "node:crypto";
25568
25743
  import { existsSync as existsSync4, promises as fs2, readFileSync as readFileSync2, realpathSync as realpathSync2 } from "node:fs";
25569
25744
  import { homedir as homedir5 } from "node:os";
25570
- import { dirname as dirname17, join as join14, resolve as resolve16 } from "node:path";
25745
+ import { dirname as dirname17, join as join15, resolve as resolve17 } from "node:path";
25571
25746
  function configDirIdentity(path2) {
25572
25747
  try {
25573
25748
  return realpathSync2.native(path2);
25574
25749
  } catch {
25575
- return resolve16(path2);
25750
+ return resolve17(path2);
25576
25751
  }
25577
25752
  }
25578
25753
  function decisionKey(location) {
@@ -25580,18 +25755,18 @@ function decisionKey(location) {
25580
25755
  }
25581
25756
  function runtimeLayoutLocation(configDir = getConfigDir()) {
25582
25757
  const stateHome = defaultStateHome();
25583
- const homeConfig = join14(homedir5(), ".config", "opencode");
25758
+ const homeConfig = join15(homedir5(), ".config", "opencode");
25584
25759
  const cacheKey = `${configDir}\0${homeConfig}\0${stateHome}`;
25585
25760
  const cached = shared2.locations.get(cacheKey);
25586
25761
  if (cached && shared2.decisions.has(decisionKey(cached))) return cached;
25587
25762
  const key = configDirIdentity(configDir);
25588
25763
  if (cached && cached.key === key) return cached;
25589
25764
  const isDefaultConfigDir = key === configDirIdentity(homeConfig);
25590
- const root = join14(stateHome, "cortexkit", "antigravity-auth");
25765
+ const root = join15(stateHome, "cortexkit", "antigravity-auth");
25591
25766
  const location = {
25592
25767
  key,
25593
25768
  configDir,
25594
- stateHomeDir: isDefaultConfigDir ? join14(root, "opencode") : join14(
25769
+ stateHomeDir: isDefaultConfigDir ? join15(root, "opencode") : join15(
25595
25770
  root,
25596
25771
  `opencode-${createHash11("sha256").update(key).digest("hex").slice(0, 16)}`
25597
25772
  ),
@@ -25613,46 +25788,46 @@ function decidedAccountStoreAnchor(location) {
25613
25788
  return shared2.storeAnchors.get(`${location.stateHomeDir}\0${location.key}`);
25614
25789
  }
25615
25790
  function currentRuntimeLayout(location = runtimeLayoutLocation()) {
25616
- return decidedRuntimeLayout(location) ?? (existsSync4(join14(location.stateHomeDir, RUNTIME_LAYOUT_MARKER_FILE)) ? "state-home" : "legacy");
25791
+ return decidedRuntimeLayout(location) ?? (existsSync4(join15(location.stateHomeDir, RUNTIME_LAYOUT_MARKER_FILE)) ? "state-home" : "legacy");
25617
25792
  }
25618
25793
  function legacyWindowsConfigDir() {
25619
- return join14(
25620
- process.env.APPDATA || join14(homedir5(), "AppData", "Roaming"),
25794
+ return join15(
25795
+ process.env.APPDATA || join15(homedir5(), "AppData", "Roaming"),
25621
25796
  "opencode"
25622
25797
  );
25623
25798
  }
25624
25799
  function pluginStateDir() {
25625
- return join14(defaultStateHome(), "cortexkit", "antigravity-auth");
25800
+ return join15(defaultStateHome(), "cortexkit", "antigravity-auth");
25626
25801
  }
25627
25802
  function legacySignatureCacheFile() {
25628
- const configHome = process.platform === "win32" ? legacyWindowsConfigDir() : join14(
25629
- process.env.XDG_CONFIG_HOME || join14(homedir5(), ".config"),
25803
+ const configHome = process.platform === "win32" ? legacyWindowsConfigDir() : join15(
25804
+ process.env.XDG_CONFIG_HOME || join15(homedir5(), ".config"),
25630
25805
  "opencode"
25631
25806
  );
25632
- return join14(configHome, SIGNATURE_CACHE_FILE_NAME);
25807
+ return join15(configHome, SIGNATURE_CACHE_FILE_NAME);
25633
25808
  }
25634
25809
  function stateHomeLogsDir() {
25635
- return join14(pluginStateDir(), "logs");
25810
+ return join15(pluginStateDir(), "logs");
25636
25811
  }
25637
25812
  function legacyAccountFile(configDir = getConfigDir()) {
25638
- const standard = join14(configDir, ACCOUNT_FILE_NAME);
25813
+ const standard = join15(configDir, ACCOUNT_FILE_NAME);
25639
25814
  if (process.platform !== "win32") return standard;
25640
25815
  return resolveWindowsAccountAnchor(
25641
25816
  standard,
25642
- join14(legacyWindowsConfigDir(), ACCOUNT_FILE_NAME)
25817
+ join15(legacyWindowsConfigDir(), ACCOUNT_FILE_NAME)
25643
25818
  );
25644
25819
  }
25645
25820
  function legacyVaultDir(accountFile) {
25646
- return join14(dirname17(accountFile), VAULT_DIR_NAME);
25821
+ return join15(dirname17(accountFile), VAULT_DIR_NAME);
25647
25822
  }
25648
25823
  function stateHomeVaultDir(location) {
25649
- return join14(location.stateHomeDir, VAULT_DIR_NAME);
25824
+ return join15(location.stateHomeDir, VAULT_DIR_NAME);
25650
25825
  }
25651
25826
  function accountStorePointerPath2(accountFile) {
25652
25827
  return `${accountFile}${ACCOUNT_STORE_POINTER_SUFFIX}`;
25653
25828
  }
25654
25829
  function stateHomeAccountFile(location) {
25655
- return join14(realPathOrSelf(location.stateHomeDir), ACCOUNT_FILE_NAME);
25830
+ return join15(realPathOrSelf(location.stateHomeDir), ACCOUNT_FILE_NAME);
25656
25831
  }
25657
25832
  function realPathOrSelf(path2) {
25658
25833
  try {
@@ -25872,7 +26047,7 @@ import {
25872
26047
  statSync as statSync4,
25873
26048
  unlinkSync as unlinkSync2
25874
26049
  } from "node:fs";
25875
- import { join as join15 } from "node:path";
26050
+ import { join as join16 } from "node:path";
25876
26051
  import { env } from "node:process";
25877
26052
  function getLogsDir(customLogDir) {
25878
26053
  const logsDir = customLogDir || stateHomeLogsDir();
@@ -25891,9 +26066,9 @@ function createLogFilePath(customLogDir) {
25891
26066
  const logsDir = getLogsDir(requestedLogDir(customLogDir));
25892
26067
  cleanupOldLogs(logsDir, 25);
25893
26068
  const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
25894
- let candidate = join15(logsDir, `antigravity-debug-${timestamp}.log`);
26069
+ let candidate = join16(logsDir, `antigravity-debug-${timestamp}.log`);
25895
26070
  for (let suffix = 2; liveLogFilePaths.has(candidate); suffix++) {
25896
- candidate = join15(logsDir, `antigravity-debug-${timestamp}-${suffix}.log`);
26071
+ candidate = join16(logsDir, `antigravity-debug-${timestamp}-${suffix}.log`);
25897
26072
  }
25898
26073
  return candidate;
25899
26074
  }
@@ -25901,7 +26076,7 @@ function cleanupOldLogs(logsDir, maxFiles) {
25901
26076
  try {
25902
26077
  const files = readdirSync(logsDir).filter(
25903
26078
  (file) => file.startsWith("antigravity-debug-") && file.endsWith(".log")
25904
- ).map((file) => join15(logsDir, file));
26079
+ ).map((file) => join16(logsDir, file));
25905
26080
  if (files.length <= maxFiles) {
25906
26081
  return;
25907
26082
  }
@@ -26234,13 +26409,13 @@ function closeDebugLog() {
26234
26409
  if (!state || !current) return Promise.resolve();
26235
26410
  state.logStream = null;
26236
26411
  if (state.logFilePath) liveLogFilePaths.delete(state.logFilePath);
26237
- return new Promise((resolve21) => {
26238
- current.once("close", () => resolve21());
26239
- current.once("error", () => resolve21());
26412
+ return new Promise((resolve22) => {
26413
+ current.once("close", () => resolve22());
26414
+ current.once("error", () => resolve22());
26240
26415
  try {
26241
26416
  current.end();
26242
26417
  } catch {
26243
- resolve21();
26418
+ resolve22();
26244
26419
  }
26245
26420
  });
26246
26421
  }
@@ -26350,15 +26525,15 @@ function getLegacyLogger() {
26350
26525
  }
26351
26526
  function createLogger4(module) {
26352
26527
  let channel3;
26353
- const log8 = (level, message, extra) => {
26528
+ const log9 = (level, message, extra) => {
26354
26529
  channel3 ??= getLegacyLogger().createLogger(module);
26355
26530
  channel3[level](message, extra);
26356
26531
  };
26357
26532
  return {
26358
- debug: (message, extra) => log8("debug", message, extra),
26359
- info: (message, extra) => log8("info", message, extra),
26360
- warn: (message, extra) => log8("warn", message, extra),
26361
- error: (message, extra) => log8("error", message, extra)
26533
+ debug: (message, extra) => log9("debug", message, extra),
26534
+ info: (message, extra) => log9("info", message, extra),
26535
+ warn: (message, extra) => log9("warn", message, extra),
26536
+ error: (message, extra) => log9("error", message, extra)
26362
26537
  };
26363
26538
  }
26364
26539
  var ENV_CONSOLE_LOG2, LOG_LEVEL_FROM_OPERATOR, legacyClient, legacyLogger;
@@ -26386,7 +26561,7 @@ var init_logger4 = __esm({
26386
26561
  init_dist();
26387
26562
  import { execFile } from "node:child_process";
26388
26563
  import { realpathSync as realpathSync4 } from "node:fs";
26389
- import { resolve as resolve20 } from "node:path";
26564
+ import { resolve as resolve21 } from "node:path";
26390
26565
  import { createInterface } from "node:readline/promises";
26391
26566
  import { fileURLToPath as fileURLToPath2 } from "node:url";
26392
26567
  import { promisify } from "node:util";
@@ -26562,7 +26737,7 @@ init_storage();
26562
26737
  // src/plugin/token.ts
26563
26738
  init_dist();
26564
26739
  init_logger4();
26565
- var log6 = createLogger4("token");
26740
+ var log7 = createLogger4("token");
26566
26741
  function parseOAuthErrorPayload(text2) {
26567
26742
  if (!text2) {
26568
26743
  return {};
@@ -26635,13 +26810,13 @@ async function exchangeRefreshToken(refreshToken, now) {
26635
26810
  const details = [code2, description ?? errorText3].filter(Boolean).join(": ");
26636
26811
  const baseMessage = `Antigravity token refresh failed (${response.status} ${response.statusText})`;
26637
26812
  const message = details ? `${baseMessage} - ${details}` : baseMessage;
26638
- log6.warn("Token refresh failed", {
26813
+ log7.warn("Token refresh failed", {
26639
26814
  status: response.status,
26640
26815
  code: code2,
26641
26816
  details
26642
26817
  });
26643
26818
  if (code2 === "invalid_grant") {
26644
- log6.warn(
26819
+ log7.warn(
26645
26820
  "Google revoked the stored refresh token - reauthentication required"
26646
26821
  );
26647
26822
  invalidateProjectContextCache(refreshToken);
@@ -26683,7 +26858,7 @@ async function refreshAccessToken(auth, _client, _providerId) {
26683
26858
  if (error instanceof AntigravityTokenRefreshError) {
26684
26859
  throw error;
26685
26860
  }
26686
- log6.error("Unexpected token refresh error", { error: String(error) });
26861
+ log7.error("Unexpected token refresh error", { error: String(error) });
26687
26862
  return void 0;
26688
26863
  }
26689
26864
  }
@@ -26700,7 +26875,7 @@ init_dist();
26700
26875
  // src/plugin/quota.ts
26701
26876
  init_logger4();
26702
26877
  init_dist();
26703
- var log7 = createLogger4("quota");
26878
+ var log8 = createLogger4("quota");
26704
26879
  async function checkAccountsQuotaWith(accounts, fetchAccountQuota) {
26705
26880
  const manager = createQuotaManager({
26706
26881
  fetchAccountQuota,
@@ -26794,14 +26969,14 @@ async function fetchQuotaPayloads(options) {
26794
26969
  };
26795
26970
  }
26796
26971
  function untilQuotaAborted(pending, signal) {
26797
- return new Promise((resolve21, reject) => {
26972
+ return new Promise((resolve22, reject) => {
26798
26973
  const abort = () => reject(signal.reason);
26799
26974
  if (signal.aborted) abort();
26800
26975
  else signal.addEventListener("abort", abort, { once: true });
26801
26976
  void pending.then(
26802
26977
  (value) => {
26803
26978
  signal.removeEventListener("abort", abort);
26804
- resolve21(value);
26979
+ resolve22(value);
26805
26980
  },
26806
26981
  (error) => {
26807
26982
  signal.removeEventListener("abort", abort);
@@ -26834,7 +27009,7 @@ function makeFetchAccountQuota(client, providerId, fetchVia) {
26834
27009
  let rotatedRefresh;
26835
27010
  if (purpose === "advisory") {
26836
27011
  if (accessTokenExpired(auth)) {
26837
- log7.debug("advisory-quota-skipped-refresh-needed");
27012
+ log8.debug("advisory-quota-skipped-refresh-needed");
26838
27013
  return {
26839
27014
  index,
26840
27015
  email: account.email,
@@ -26846,7 +27021,7 @@ function makeFetchAccountQuota(client, providerId, fetchVia) {
26846
27021
  const managedProjectId = parts.managedProjectId ?? account.managedProjectId;
26847
27022
  const projectId = managedProjectId ?? parts.projectId ?? account.projectId;
26848
27023
  if (!projectId) {
26849
- log7.debug("advisory-quota-skipped-project-needed");
27024
+ log8.debug("advisory-quota-skipped-project-needed");
26850
27025
  return {
26851
27026
  index,
26852
27027
  email: account.email,
@@ -26868,7 +27043,7 @@ function makeFetchAccountQuota(client, providerId, fetchVia) {
26868
27043
  { timeoutMs: extra.timeoutMs }
26869
27044
  );
26870
27045
  },
26871
- logger: log7
27046
+ logger: log8
26872
27047
  }),
26873
27048
  signal
26874
27049
  );
@@ -26925,7 +27100,7 @@ function makeFetchAccountQuota(client, providerId, fetchVia) {
26925
27100
  managedProjectId,
26926
27101
  projectId: projectContext.effectiveProjectId,
26927
27102
  fetchVia,
26928
- logger: log7
27103
+ logger: log8
26929
27104
  });
26930
27105
  quotaResult = payloads.quota;
26931
27106
  if (quotaResult.error) throw new Error(quotaResult.error);
@@ -27083,12 +27258,12 @@ async function startOAuthListener({
27083
27258
  let resolveCallback;
27084
27259
  let rejectCallback;
27085
27260
  let timeoutHandle;
27086
- const callbackPromise = new Promise((resolve21, reject) => {
27261
+ const callbackPromise = new Promise((resolve22, reject) => {
27087
27262
  resolveCallback = (url) => {
27088
27263
  if (settled) return;
27089
27264
  settled = true;
27090
27265
  if (timeoutHandle) clearTimeout(timeoutHandle);
27091
- resolve21(url);
27266
+ resolve22(url);
27092
27267
  };
27093
27268
  rejectCallback = (error) => {
27094
27269
  if (settled) return;
@@ -27247,7 +27422,7 @@ async function startOAuthListener({
27247
27422
  });
27248
27423
  });
27249
27424
  const bindAddress = getBindAddress();
27250
- await new Promise((resolve21, reject) => {
27425
+ await new Promise((resolve22, reject) => {
27251
27426
  const handleError = (error) => {
27252
27427
  server.off("error", handleError);
27253
27428
  if (error.code === "EADDRINUSE") {
@@ -27263,7 +27438,7 @@ async function startOAuthListener({
27263
27438
  server.once("error", handleError);
27264
27439
  server.listen(port, bindAddress, () => {
27265
27440
  server.off("error", handleError);
27266
- resolve21();
27441
+ resolve22();
27267
27442
  });
27268
27443
  });
27269
27444
  server.on("error", (error) => {
@@ -27271,7 +27446,7 @@ async function startOAuthListener({
27271
27446
  });
27272
27447
  return {
27273
27448
  waitForCallback: () => callbackPromise,
27274
- close: () => new Promise((resolve21, reject) => {
27449
+ close: () => new Promise((resolve22, reject) => {
27275
27450
  server.close((error) => {
27276
27451
  if (error && error.code !== "ERR_SERVER_NOT_RUNNING") {
27277
27452
  reject(error);
@@ -27280,7 +27455,7 @@ async function startOAuthListener({
27280
27455
  if (!settled) {
27281
27456
  rejectCallback(new Error("OAuth listener closed before callback"));
27282
27457
  }
27283
- resolve21();
27458
+ resolve22();
27284
27459
  });
27285
27460
  })
27286
27461
  };
@@ -27299,7 +27474,7 @@ init_runtime_paths();
27299
27474
  // src/setup.ts
27300
27475
  init_dist();
27301
27476
  import { lstat as lstat9, readFile as readFile13 } from "node:fs/promises";
27302
- import { join as join21, resolve as resolve19 } from "node:path";
27477
+ import { join as join22, resolve as resolve20 } from "node:path";
27303
27478
 
27304
27479
  // src/auth-method-labels.ts
27305
27480
  var OPENCODE2_POOL_AUTH_LABEL = "Google (antigravity-auth pool, browser)";
@@ -27471,7 +27646,7 @@ async function select2(terminal, items, options) {
27471
27646
  writeLine("");
27472
27647
  renderedLines = lines;
27473
27648
  };
27474
- return new Promise((resolve21) => {
27649
+ return new Promise((resolve22) => {
27475
27650
  const wasRaw = stdin.isRaw ?? false;
27476
27651
  const cleanup2 = () => {
27477
27652
  if (cleaned)
@@ -27491,7 +27666,7 @@ async function select2(terminal, items, options) {
27491
27666
  };
27492
27667
  const finish = (value) => {
27493
27668
  cleanup2();
27494
- resolve21(value);
27669
+ resolve22(value);
27495
27670
  };
27496
27671
  const onSignal = () => finish(null);
27497
27672
  const onKey = (data) => {
@@ -27531,7 +27706,7 @@ async function select2(terminal, items, options) {
27531
27706
  stdin.setRawMode(true);
27532
27707
  } catch {
27533
27708
  cleanup2();
27534
- resolve21(null);
27709
+ resolve22(null);
27535
27710
  return;
27536
27711
  }
27537
27712
  stdin.resume();
@@ -27544,13 +27719,13 @@ async function select2(terminal, items, options) {
27544
27719
  // src/common-auth-embedded/claustrum/enrollment.js
27545
27720
  import { createHash as createHash12, randomBytes as randomBytes3, randomUUID as randomUUID15 } from "node:crypto";
27546
27721
  import { constants as fsConstants2 } from "node:fs";
27547
- import { chmod as chmod5, mkdir as mkdir14, open as open10, readFile as readFile12, realpath as realpath4, rename as rename12, stat as stat10, unlink as unlink10 } from "node:fs/promises";
27548
- import { basename as basename5, dirname as dirname19, extname as extname2, isAbsolute as isAbsolute3, join as join17, resolve as resolve18 } from "node:path";
27722
+ import { chmod as chmod5, mkdir as mkdir14, open as open10, readFile as readFile12, realpath as realpath4, rename as rename12, stat as stat11, unlink as unlink11 } from "node:fs/promises";
27723
+ import { basename as basename5, dirname as dirname19, extname as extname2, isAbsolute as isAbsolute4, join as join18, resolve as resolve19 } from "node:path";
27549
27724
  import { ClaustrumCredentialError as ClaustrumCredentialError5, ClaustrumClient as ClaustrumWireClient2, writeEnrollmentTokenFile as writeEnrollmentTokenFile2 } from "@cortexkit/claustrum-client";
27550
27725
 
27551
27726
  // src/common-auth-embedded/fs/file-read-cache.js
27552
27727
  import { lstat as lstat7 } from "node:fs/promises";
27553
- import { resolve as resolve17 } from "node:path";
27728
+ import { resolve as resolve18 } from "node:path";
27554
27729
  async function identity2(path2) {
27555
27730
  try {
27556
27731
  const metadata = await lstat7(path2);
@@ -27567,7 +27742,7 @@ function sameIdentity2(left, right) {
27567
27742
  var FileReadCache2 = class {
27568
27743
  #entries = /* @__PURE__ */ new Map();
27569
27744
  async read(paths, read, validateHit) {
27570
- const resolvedPaths = paths.map((path2) => resolve17(path2));
27745
+ const resolvedPaths = paths.map((path2) => resolve18(path2));
27571
27746
  const key = JSON.stringify(resolvedPaths);
27572
27747
  const probed = await Promise.all(resolvedPaths.map(identity2));
27573
27748
  const identities = probed.every((entry) => entry !== void 0) ? probed : void 0;
@@ -27618,10 +27793,11 @@ init_private_files2();
27618
27793
  // src/common-auth-embedded/fs/refresh-file-lock.js
27619
27794
  init_private_files2();
27620
27795
  import { randomUUID as randomUUID14 } from "node:crypto";
27621
- 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";
27622
- import { dirname as dirname18, join as join16 } from "node:path";
27796
+ import { lstat as lstat8, mkdir as mkdir13, open as open9, readFile as readFile11, rename as rename11, rm as rm6, stat as stat10 } from "node:fs/promises";
27797
+ import { dirname as dirname18, join as join17 } from "node:path";
27623
27798
 
27624
27799
  // src/common-auth-embedded/fs/with-lock.js
27800
+ init_private_files2();
27625
27801
  function lockPathFor2(target, name) {
27626
27802
  return `${target}.${name}.lock`;
27627
27803
  }
@@ -27679,7 +27855,7 @@ function acquireRefreshFileLock2(options) {
27679
27855
  }
27680
27856
  async function acquireRefreshFileLockWithClock2(options) {
27681
27857
  const lockPath = lockPathFor2(options.path, options.name);
27682
- const legacyOwnerPath = join16(lockPath, "owner.json");
27858
+ const legacyOwnerPath = join17(lockPath, "owner.json");
27683
27859
  const ownerId = randomUUID14();
27684
27860
  const now = options.now ?? Date.now;
27685
27861
  let renewTimer = null;
@@ -27687,8 +27863,8 @@ async function acquireRefreshFileLockWithClock2(options) {
27687
27863
  let releaseConfirmed = false;
27688
27864
  let loss;
27689
27865
  let resolveLoss;
27690
- const lostPromise = new Promise((resolve21) => {
27691
- resolveLoss = resolve21;
27866
+ const lostPromise = new Promise((resolve22) => {
27867
+ resolveLoss = resolve22;
27692
27868
  });
27693
27869
  function notifyTimerStep(event) {
27694
27870
  try {
@@ -27722,7 +27898,7 @@ async function acquireRefreshFileLockWithClock2(options) {
27722
27898
  let terminalIOError;
27723
27899
  let renewalInFlight = null;
27724
27900
  const evictPath = `${lockPath}.evicting`;
27725
- const evictOwnerPath = join16(evictPath, "owner.json");
27901
+ const evictOwnerPath = join17(evictPath, "owner.json");
27726
27902
  const evictOwnerId = randomUUID14();
27727
27903
  const EVICT_TTL = 5e3;
27728
27904
  const MAX_STEAL_ATTEMPTS = 8;
@@ -27849,7 +28025,7 @@ async function acquireRefreshFileLockWithClock2(options) {
27849
28025
  }
27850
28026
  }
27851
28027
  async function backoff() {
27852
- await new Promise((resolve21) => setTimeout(resolve21, Math.floor(Math.random() * 4)));
28028
+ await new Promise((resolve22) => setTimeout(resolve22, Math.floor(Math.random() * 4)));
27853
28029
  }
27854
28030
  async function readLockState(notifyReady = true) {
27855
28031
  if (notifyReady && options.onStep)
@@ -27871,7 +28047,7 @@ async function acquireRefreshFileLockWithClock2(options) {
27871
28047
  };
27872
28048
  }
27873
28049
  try {
27874
- const current = await stat9(lockPath);
28050
+ const current = await stat10(lockPath);
27875
28051
  const legacyExpiry = Number.isFinite(expiresAt) ? expiresAt : current.mtimeMs + options.ttlMs;
27876
28052
  if (legacyExpiry > now())
27877
28053
  return { status: "live" };
@@ -27938,7 +28114,7 @@ async function acquireRefreshFileLockWithClock2(options) {
27938
28114
  if (!sameMarkerDirectory2(created, current))
27939
28115
  return false;
27940
28116
  try {
27941
- await stat9(evictOwnerPath);
28117
+ await stat10(evictOwnerPath);
27942
28118
  return true;
27943
28119
  } catch (error) {
27944
28120
  if (error.code !== "ENOENT")
@@ -27990,7 +28166,7 @@ async function acquireRefreshFileLockWithClock2(options) {
27990
28166
  async function recoverStaleEvictionMarker() {
27991
28167
  let evictStat;
27992
28168
  try {
27993
- evictStat = await stat9(evictPath);
28169
+ evictStat = await stat10(evictPath);
27994
28170
  } catch (error) {
27995
28171
  if (error.code === "ENOENT")
27996
28172
  return "missing";
@@ -28008,7 +28184,7 @@ async function acquireRefreshFileLockWithClock2(options) {
28008
28184
  if (evictStat.mtimeMs + EVICT_TTL > now()) {
28009
28185
  let hasOwner = true;
28010
28186
  try {
28011
- await stat9(evictOwnerPath);
28187
+ await stat10(evictOwnerPath);
28012
28188
  } catch (error) {
28013
28189
  if (error.code === "ENOENT")
28014
28190
  hasOwner = false;
@@ -28339,7 +28515,7 @@ async function acquireRefreshFileLockWithClock2(options) {
28339
28515
  const remainingMs = deadline - performance.now();
28340
28516
  if (remainingMs <= 0)
28341
28517
  break;
28342
- await new Promise((resolve21) => setTimeout(resolve21, Math.min(delayMs, remainingMs)));
28518
+ await new Promise((resolve22) => setTimeout(resolve22, Math.min(delayMs, remainingMs)));
28343
28519
  delayMs = Math.min(delayMs * 2, 50);
28344
28520
  }
28345
28521
  if (windowsPrivateFiles2)
@@ -28404,15 +28580,15 @@ function getClaustrumEnrollmentPaths2(tokenPath) {
28404
28580
  const extension = extname2(tokenPath) || ".json";
28405
28581
  const stem = basename5(tokenPath, extname2(tokenPath));
28406
28582
  return {
28407
- statePath: join17(dirname19(tokenPath), `${stem}-state${extension}`),
28583
+ statePath: join18(dirname19(tokenPath), `${stem}-state${extension}`),
28408
28584
  tokenPath
28409
28585
  };
28410
28586
  }
28411
28587
  function hostEnrollmentPaths2(input) {
28412
28588
  const override = input.override?.trim();
28413
- if (override && !isAbsolute3(override) && !input.cwd)
28589
+ if (override && !isAbsolute4(override) && !input.cwd)
28414
28590
  throw new ClaustrumConsumerError2("invalid-state", "A relative Claustrum enrollment override needs a base directory");
28415
- const tokenPath = override ? isAbsolute3(override) ? override : resolve18(input.cwd, override) : join17(input.stateDir, `${input.host}-enrollment.json`);
28591
+ const tokenPath = override ? isAbsolute4(override) ? override : resolve19(input.cwd, override) : join18(input.stateDir, `${input.host}-enrollment.json`);
28416
28592
  return getClaustrumEnrollmentPaths2(tokenPath);
28417
28593
  }
28418
28594
  function isRecord10(value) {
@@ -28597,7 +28773,7 @@ async function refuseWritableAncestor2(parent, options = {}) {
28597
28773
  }
28598
28774
  let privateGroup;
28599
28775
  for (; ; ) {
28600
- const metadata = await stat10(component).catch(() => void 0);
28776
+ const metadata = await stat11(component).catch(() => void 0);
28601
28777
  if (metadata && (metadata.mode & 18) !== 0 && (metadata.mode & 512) === 0) {
28602
28778
  if (privateGroup === void 0) {
28603
28779
  privateGroup = gid !== void 0 && await isPrivateGroup2(uid, gid, options);
@@ -28626,7 +28802,7 @@ async function ensureClaustrumPrivateDirectory2(directory, options = {}, what =
28626
28802
  return;
28627
28803
  }
28628
28804
  await mkdir14(directory, { recursive: true, mode: 448 });
28629
- const metadata = await stat10(directory);
28805
+ const metadata = await stat11(directory);
28630
28806
  const uid = process.geteuid?.();
28631
28807
  if (uid !== void 0 && metadata.uid !== uid) {
28632
28808
  throw new ClaustrumConsumerError2("unsafe-file", `Claustrum ${what} must be owned by the current user`);
@@ -28645,7 +28821,7 @@ async function writeStateAtomic2(path2, state, ancestorOptions = {}) {
28645
28821
  }
28646
28822
  if (windowsPrivateFiles2)
28647
28823
  return writePrivateAtomic2(path2, bytes);
28648
- const temporary = join17(parent, `.${basename5(path2)}.${process.pid}.${randomUUID15()}.tmp`);
28824
+ const temporary = join18(parent, `.${basename5(path2)}.${process.pid}.${randomUUID15()}.tmp`);
28649
28825
  let descriptor;
28650
28826
  let created = false;
28651
28827
  try {
@@ -28662,7 +28838,7 @@ async function writeStateAtomic2(path2, state, ancestorOptions = {}) {
28662
28838
  await descriptor?.close().catch(() => {
28663
28839
  });
28664
28840
  if (created)
28665
- await unlink10(temporary).catch(() => {
28841
+ await unlink11(temporary).catch(() => {
28666
28842
  });
28667
28843
  }
28668
28844
  }
@@ -28889,7 +29065,7 @@ var ClaustrumEnrollmentManager2 = class {
28889
29065
  }
28890
29066
  if (refusal3.code === UNSUPPORTED_ENROLLMENT_CODE2) {
28891
29067
  await lock.assertOwned();
28892
- await unlink10(this.#paths.statePath).catch((cause) => {
29068
+ await unlink11(this.#paths.statePath).catch((cause) => {
28893
29069
  if (cause.code !== "ENOENT")
28894
29070
  throw cause;
28895
29071
  });
@@ -28979,7 +29155,7 @@ async function resetClaustrumEnrollmentState2(paths, proposedName) {
28979
29155
  if (state.phase === "pending")
28980
29156
  return "refused-pending";
28981
29157
  await lock.assertOwned();
28982
- await unlink10(paths.statePath);
29158
+ await unlink11(paths.statePath);
28983
29159
  return "reset";
28984
29160
  } finally {
28985
29161
  await lock.release();
@@ -29040,7 +29216,7 @@ var ByteTail = class {
29040
29216
  };
29041
29217
  var defaultCommandRunner = {
29042
29218
  run(file, args, options = {}) {
29043
- return new Promise((resolve21) => {
29219
+ return new Promise((resolve22) => {
29044
29220
  const started = performance.now();
29045
29221
  const timeoutMs = options.timeoutMs ?? 15e3;
29046
29222
  const stderr = new ByteTail();
@@ -29058,7 +29234,7 @@ var defaultCommandRunner = {
29058
29234
  stdio: ["ignore", "pipe", "pipe"]
29059
29235
  });
29060
29236
  } catch {
29061
- resolve21({
29237
+ resolve22({
29062
29238
  exitCode: 1,
29063
29239
  stdout: "",
29064
29240
  stderr: "",
@@ -29093,7 +29269,7 @@ var defaultCommandRunner = {
29093
29269
  settled = true;
29094
29270
  if (timer)
29095
29271
  clearTimeout(timer);
29096
- resolve21({
29272
+ resolve22({
29097
29273
  exitCode: spawnError ? 1 : outputExceeded ? 1 : code2 ?? 1,
29098
29274
  stdout: Buffer.concat(stdout, stdoutLength).toString("utf8"),
29099
29275
  stderr: stderr.toString(),
@@ -29180,7 +29356,7 @@ function recordSetupEnrollment(failure, enrollment) {
29180
29356
  import { accessSync, constants as constants3, existsSync as existsSync6, readFileSync as readFileSync4, realpathSync as realpathSync3, statSync as statSync5 } from "node:fs";
29181
29357
  import { mkdtemp, rm as rm7 } from "node:fs/promises";
29182
29358
  import { tmpdir as tmpdir3 } from "node:os";
29183
- import { join as join18 } from "node:path";
29359
+ import { join as join19 } from "node:path";
29184
29360
  import { parse } from "jsonc-parser";
29185
29361
 
29186
29362
  // src/common-auth-embedded/setup/paths.js
@@ -29215,7 +29391,7 @@ function setupPaths(io = {}) {
29215
29391
  }
29216
29392
 
29217
29393
  // src/common-auth-embedded/setup/detect.js
29218
- function stat11(path2, kind) {
29394
+ function stat12(path2, kind) {
29219
29395
  try {
29220
29396
  return statSync5(path2)[kind]();
29221
29397
  } catch {
@@ -29224,12 +29400,12 @@ function stat11(path2, kind) {
29224
29400
  }
29225
29401
  var defaultSetupFileSystem = {
29226
29402
  exists: existsSync6,
29227
- isFile: (path2) => stat11(path2, "isFile"),
29228
- isDirectory: (path2) => stat11(path2, "isDirectory"),
29403
+ isFile: (path2) => stat12(path2, "isFile"),
29404
+ isDirectory: (path2) => stat12(path2, "isDirectory"),
29229
29405
  isExecutable(path2) {
29230
29406
  try {
29231
29407
  accessSync(path2, constants3.X_OK);
29232
- return stat11(path2, "isFile");
29408
+ return stat12(path2, "isFile");
29233
29409
  } catch {
29234
29410
  return false;
29235
29411
  }
@@ -29351,7 +29527,7 @@ async function detectHosts(plugin, io = {}) {
29351
29527
  return null;
29352
29528
  let root;
29353
29529
  try {
29354
- root = await mkdtemp(join18(tmpdir3(), "common-auth-setup-version-"));
29530
+ root = await mkdtemp(join19(tmpdir3(), "common-auth-setup-version-"));
29355
29531
  const probeEnv = {
29356
29532
  ...env3,
29357
29533
  HOME: root,
@@ -29935,8 +30111,8 @@ import { applyEdits, createScanner, findNodeAtLocation, modify, parse as parse2,
29935
30111
 
29936
30112
  // src/common-auth-embedded/setup/config-write.js
29937
30113
  import { randomUUID as randomUUID16 } from "node:crypto";
29938
- import { mkdir as mkdir15, open as open11, rename as rename13, stat as stat12, unlink as unlink11 } from "node:fs/promises";
29939
- import { basename as basename6, dirname as dirname20, join as join19 } from "node:path";
30114
+ import { mkdir as mkdir15, open as open11, rename as rename13, stat as stat13, unlink as unlink12 } from "node:fs/promises";
30115
+ import { basename as basename6, dirname as dirname20, join as join20 } from "node:path";
29940
30116
  import { setTimeout as delay2 } from "node:timers/promises";
29941
30117
  async function writeHostConfigAtomic(file, content, options = {}) {
29942
30118
  const windows = (options.platform ?? process.platform) === "win32";
@@ -29945,13 +30121,13 @@ async function writeHostConfigAtomic(file, content, options = {}) {
29945
30121
  let mode;
29946
30122
  if (!windows) {
29947
30123
  try {
29948
- mode = (await stat12(file)).mode & 4095;
30124
+ mode = (await stat13(file)).mode & 4095;
29949
30125
  } catch (error) {
29950
30126
  if (error.code !== "ENOENT")
29951
30127
  throw error;
29952
30128
  }
29953
30129
  }
29954
- const stage = join19(parent, `.${basename6(file)}.${(options.stageName ?? randomUUID16)()}.tmp`);
30130
+ const stage = join20(parent, `.${basename6(file)}.${(options.stageName ?? randomUUID16)()}.tmp`);
29955
30131
  let created = false;
29956
30132
  try {
29957
30133
  const handle = await open11(stage, "wx", mode ?? 438);
@@ -29981,7 +30157,7 @@ async function writeHostConfigAtomic(file, content, options = {}) {
29981
30157
  }
29982
30158
  } finally {
29983
30159
  if (created)
29984
- await unlink11(stage).catch(() => {
30160
+ await unlink12(stage).catch(() => {
29985
30161
  });
29986
30162
  }
29987
30163
  }
@@ -30370,10 +30546,10 @@ init_storage();
30370
30546
  // src/plugin/vault-activation.ts
30371
30547
  init_dist();
30372
30548
  import { homedir as homedir7 } from "node:os";
30373
- import { join as join20 } from "node:path";
30549
+ import { join as join21 } from "node:path";
30374
30550
  function nativeOpenCodeAuthPath(env3 = process.env, home = homedir7()) {
30375
- return join20(
30376
- env3.XDG_DATA_HOME || join20(home, ".local", "share"),
30551
+ return join21(
30552
+ env3.XDG_DATA_HOME || join21(home, ".local", "share"),
30377
30553
  "opencode",
30378
30554
  "auth.json"
30379
30555
  );
@@ -30382,63 +30558,7 @@ function nativeOpenCodeAuthPath(env3 = process.env, home = homedir7()) {
30382
30558
  // src/setup.ts
30383
30559
  init_vault_custody();
30384
30560
  init_runtime_paths();
30385
-
30386
- // src/vault-folder.ts
30387
- init_logger4();
30388
- init_process_heartbeat();
30389
- init_runtime_layout();
30390
- init_runtime_paths();
30391
- var refusalsKey = /* @__PURE__ */ Symbol.for(
30392
- "@cortexkit/antigravity-auth/vault-folder-refusals"
30393
- );
30394
- var globalState3 = globalThis;
30395
- var refusals = globalState3[refusalsKey] ?? /* @__PURE__ */ new Map();
30396
- globalState3[refusalsKey] = refusals;
30397
- function locationKey() {
30398
- const location = runtimeLayoutLocation();
30399
- return `${location.stateHomeDir}\0${location.key}`;
30400
- }
30401
- async function prepareVaultFolder(options) {
30402
- const { accountFile } = options;
30403
- const key = locationKey();
30404
- const kept = refusals.get(key);
30405
- if (kept) return refused(accountFile, kept);
30406
- const log8 = options.log ?? createLogger4("runtime-layout");
30407
- const version = options.version ?? await pluginPackageVersion().catch(() => "unknown");
30408
- try {
30409
- await prepareRuntimeLayout({
30410
- version,
30411
- accountFile,
30412
- log: log8,
30413
- ...options.layoutLockWaitMs === void 0 ? {} : { layoutLockWaitMs: options.layoutLockWaitMs }
30414
- });
30415
- if (options.accountStore !== false)
30416
- await prepareAccountStore({ version, log: log8 });
30417
- } catch (error) {
30418
- const refusal3 = error instanceof RuntimeLayoutRefusal ? error : new RuntimeLayoutRefusal(
30419
- runtimeLayoutLocation().stateHomeDir,
30420
- error instanceof Error ? error.name : typeof error
30421
- );
30422
- if (!refusals.has(key)) {
30423
- refusals.set(key, refusal3);
30424
- log8.warn(refusal3.message, {
30425
- stateDir: refusal3.stateDir,
30426
- errorClass: refusal3.errorClass
30427
- });
30428
- }
30429
- return refused(accountFile, refusals.get(key) ?? refusal3);
30430
- }
30431
- return { accountFile, vaultDir: getVaultDir(accountFile) };
30432
- }
30433
- function currentVaultFolder(accountFile) {
30434
- const kept = refusals.get(locationKey());
30435
- return kept ? refused(accountFile, kept) : { accountFile, vaultDir: getVaultDir(accountFile) };
30436
- }
30437
- function refused(accountFile, refusal3) {
30438
- return { accountFile, vaultDir: getVaultDir(accountFile), refusal: refusal3 };
30439
- }
30440
-
30441
- // src/setup.ts
30561
+ init_vault_folder();
30442
30562
  var PI_PLACEHOLDER_KEY = "antigravity-vault-custody";
30443
30563
  async function storePresent(anchor) {
30444
30564
  return await pathPresent(accountStorePointerPath(anchor)) || await pathPresent(anchor);
@@ -30455,7 +30575,7 @@ function openCodeVaultDir(accountFile) {
30455
30575
  return folder.vaultDir;
30456
30576
  }
30457
30577
  function nativeAuthPath(host, context) {
30458
- return host === "opencode" ? nativeOpenCodeAuthPath() : join21(context.piAgentDir, "auth.json");
30578
+ return host === "opencode" ? nativeOpenCodeAuthPath() : join22(context.piAgentDir, "auth.json");
30459
30579
  }
30460
30580
  function provider(host) {
30461
30581
  return host === "opencode" ? OPENCODE_VAULT_PROVIDER : ANTIGRAVITY_PROVIDER_ID;
@@ -30511,7 +30631,7 @@ async function writeNativeSlot(host, slot, context, expectedAuthority = "local")
30511
30631
  beforeRename: async () => {
30512
30632
  await assertSetupHostsStopped();
30513
30633
  const claustrum = await loadCommonAuthClaustrum();
30514
- const stateDir = host === "opencode" ? openCodeVaultDir(resolve19(accountFileForVault())) : getPiAntigravityVaultDir();
30634
+ const stateDir = host === "opencode" ? openCodeVaultDir(resolve20(accountFileForVault())) : getPiAntigravityVaultDir();
30515
30635
  if (await claustrum.enrollmentAuthority(
30516
30636
  claustrum.hostEnrollmentPaths({ stateDir, host }),
30517
30637
  `antigravity-auth-${host}`
@@ -30549,7 +30669,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
30549
30669
  // `beforeSignIn`, which may move it after this plugin is built.
30550
30670
  paths: {
30551
30671
  get stateDir() {
30552
- return openCodeVaultDir(resolve19(accountFileForVault()));
30672
+ return openCodeVaultDir(resolve20(accountFileForVault()));
30553
30673
  },
30554
30674
  host: "opencode"
30555
30675
  }
@@ -30566,7 +30686,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
30566
30686
  const assertLocal = async (host, context) => {
30567
30687
  if (host === "opencode")
30568
30688
  return assertLocalOpenCodeLogin(
30569
- resolve19(accountFileForVault()),
30689
+ resolve20(accountFileForVault()),
30570
30690
  context.opencodeGeneration
30571
30691
  );
30572
30692
  if (await authority(host) !== "local")
@@ -30582,7 +30702,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
30582
30702
  const { openPiSlot: openPiSlot2 } = await loadCommonAuthPiSlot();
30583
30703
  if ((await openPiSlot2({
30584
30704
  authPath: nativeAuthPath(host, context),
30585
- stashPath: join21(piDir, "google-login-stash.json"),
30705
+ stashPath: join22(piDir, "google-login-stash.json"),
30586
30706
  provider: ANTIGRAVITY_PROVIDER_ID,
30587
30707
  placeholderKey: PI_PLACEHOLDER_KEY
30588
30708
  }).inspect()).slot === "placeholder")
@@ -30622,7 +30742,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
30622
30742
  const { openPiSlot: openPiSlot2 } = await loadCommonAuthPiSlot();
30623
30743
  const inspection = await openPiSlot2({
30624
30744
  authPath: nativeAuthPath("pi", context),
30625
- stashPath: join21(piDir, "google-login-stash.json"),
30745
+ stashPath: join22(piDir, "google-login-stash.json"),
30626
30746
  provider: ANTIGRAVITY_PROVIDER_ID,
30627
30747
  placeholderKey: PI_PLACEHOLDER_KEY
30628
30748
  }).inspect();
@@ -30741,7 +30861,7 @@ Setup has not completed the OpenCode 2 native Google connection.
30741
30861
  await assertSetupHostsStopped();
30742
30862
  await openPiSlot2({
30743
30863
  authPath: nativeAuthPath(host, context),
30744
- stashPath: join21(piDir, "google-login-stash.json"),
30864
+ stashPath: join22(piDir, "google-login-stash.json"),
30745
30865
  provider: ANTIGRAVITY_PROVIDER_ID,
30746
30866
  placeholderKey: PI_PLACEHOLDER_KEY
30747
30867
  }).enterVault();
@@ -30807,6 +30927,7 @@ async function runPluginSetup(argv, deps, migrateOpenCode, io = {}) {
30807
30927
  }
30808
30928
 
30809
30929
  // src/cli.ts
30930
+ init_vault_folder();
30810
30931
  var HELP = `Usage: antigravity-auth <command> [options]
30811
30932
 
30812
30933
  Commands:
@@ -31196,7 +31317,7 @@ async function runCliProcess(argv, deps) {
31196
31317
  ...deps,
31197
31318
  prepareVaultFolder: deps.prepareVaultFolder ?? (async (options) => {
31198
31319
  const folder = await prepareVaultFolder({
31199
- accountFile: resolve20(accountFileForVault()),
31320
+ accountFile: resolve21(accountFileForVault()),
31200
31321
  ...options
31201
31322
  });
31202
31323
  if (folder.refusal) throw folder.refusal;
@@ -31242,11 +31363,11 @@ function createDefaultCliDependencies() {
31242
31363
  );
31243
31364
  if (host !== "pi")
31244
31365
  await assertLocalOpenCodeLogin(
31245
- resolve20(accountFileForVault()),
31366
+ resolve21(accountFileForVault()),
31246
31367
  context?.opencodeGeneration
31247
31368
  );
31248
31369
  const repository = host === "pi" ? void 0 : await prepareCliLoginStore(
31249
- resolve20(getStoragePath()),
31370
+ resolve21(getStoragePath()),
31250
31371
  context?.opencodeGeneration
31251
31372
  );
31252
31373
  try {
@@ -31262,7 +31383,7 @@ function createDefaultCliDependencies() {
31262
31383
  }
31263
31384
  if (host === "opencode") await assertSetupHostsStopped();
31264
31385
  await assertLocalOpenCodeLogin(
31265
- resolve20(accountFileForVault()),
31386
+ resolve21(accountFileForVault()),
31266
31387
  context?.opencodeGeneration
31267
31388
  );
31268
31389
  await persistCliStoreLogin(
@@ -31282,7 +31403,7 @@ function createDefaultCliDependencies() {
31282
31403
  };
31283
31404
  }
31284
31405
  async function prepareCliLoginStore(legacyPath, generation) {
31285
- await assertLocalOpenCodeLogin(resolve20(accountFileForVault()), generation);
31406
+ await assertLocalOpenCodeLogin(resolve21(accountFileForVault()), generation);
31286
31407
  const modules = await loadCommonAuthStoreModules();
31287
31408
  const options = {
31288
31409
  legacyPath,
@@ -31407,7 +31528,7 @@ async function readAccountStore(legacyPath) {
31407
31528
  function createDefaultAccountStoreOperations() {
31408
31529
  const offline = { processesStopped: true };
31409
31530
  return {
31410
- legacyPath: () => resolve20(
31531
+ legacyPath: () => resolve21(
31411
31532
  decidedAccountStoreAnchor(runtimeLayoutLocation()) ? getStoragePath() : discoveredAccountFile()
31412
31533
  ),
31413
31534
  migrate: async (legacyPath) => createAccountMigrationFactory(await loadCommonAuthStoreModules())({
@@ -31438,7 +31559,7 @@ function createDefaultAccountStoreOperations() {
31438
31559
  };
31439
31560
  }
31440
31561
  function samePath(left, right) {
31441
- return process.platform === "win32" ? resolve20(left).toLowerCase() === resolve20(right).toLowerCase() : resolve20(left) === resolve20(right);
31562
+ return process.platform === "win32" ? resolve21(left).toLowerCase() === resolve21(right).toLowerCase() : resolve21(left) === resolve21(right);
31442
31563
  }
31443
31564
  function isCliEntry() {
31444
31565
  if (import.meta.main !== void 0) return import.meta.main;