@cortexkit/opencode-antigravity-auth 3.0.38 → 3.0.39

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/README.md +1 -1
  2. package/dist/cli.js +602 -320
  3. package/dist/cli.js.map +4 -4
  4. package/dist/cli.meta.json +100 -32
  5. package/dist/index.js +807 -384
  6. package/dist/index.js.map +4 -4
  7. package/dist/index.meta.json +115 -39
  8. package/dist/server.js +828 -398
  9. package/dist/server.js.map +4 -4
  10. package/dist/server.meta.json +1 -1
  11. package/dist/src/common-auth-embedded/claustrum/availability.d.ts +7 -1
  12. package/dist/src/common-auth-embedded/claustrum/availability.js +9 -1
  13. package/dist/src/common-auth-embedded/claustrum/custody.d.ts +11 -2
  14. package/dist/src/common-auth-embedded/claustrum/custody.js +89 -31
  15. package/dist/src/common-auth-embedded/claustrum/enrollment.d.ts +4 -0
  16. package/dist/src/common-auth-embedded/claustrum/enrollment.js +33 -2
  17. package/dist/src/common-auth-embedded/claustrum/host.js +11 -7
  18. package/dist/src/common-auth-embedded/claustrum/index.d.ts +1 -1
  19. package/dist/src/common-auth-embedded/claustrum/index.js +1 -1
  20. package/dist/src/common-auth-embedded/fs/lock-record.js +55 -0
  21. package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +148 -92
  22. package/dist/src/common-auth-embedded/fs/with-lock.js +19 -13
  23. package/dist/src/common-auth-embedded/quota-sidebar/index.d.ts +2 -36
  24. package/dist/src/common-auth-embedded/quota-sidebar/index.tsx +49 -607
  25. package/dist/src/common-auth-embedded/routing-accessor/cache-policy.d.ts +3 -0
  26. package/dist/src/common-auth-embedded/routing-accessor/cache-policy.js +11 -0
  27. package/dist/src/common-auth-embedded/routing-accessor/index.d.ts +48 -5
  28. package/dist/src/common-auth-embedded/routing-accessor/index.js +136 -5
  29. package/dist/src/common-auth-embedded/setup/enroll.js +2 -1
  30. package/dist/src/common-auth-embedded/setup/types.d.ts +1 -0
  31. package/dist/src/common-auth-embedded/source-output.json +72 -64
  32. package/dist/src/ga/tui/host-ga.d.ts +20 -3
  33. package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
  34. package/dist/src/ga/tui/host-ga.js +102 -25
  35. package/dist/src/ga/tui/host-ga.js.map +1 -1
  36. package/dist/src/plugin/__fixtures__/release-model-ids.d.ts.map +1 -1
  37. package/dist/src/plugin/__fixtures__/release-model-ids.js +1 -0
  38. package/dist/src/plugin/__fixtures__/release-model-ids.js.map +1 -1
  39. package/dist/src/plugin/__fixtures__/verified-store.js +2 -2
  40. package/dist/src/plugin/ga-location-services.d.ts +1 -0
  41. package/dist/src/plugin/ga-location-services.d.ts.map +1 -1
  42. package/dist/src/plugin/ga-location-services.js +6 -0
  43. package/dist/src/plugin/ga-location-services.js.map +1 -1
  44. package/dist/src/plugin/request.d.ts.map +1 -1
  45. package/dist/src/plugin/request.js +3 -1
  46. package/dist/src/plugin/request.js.map +1 -1
  47. package/dist/src/setup.d.ts.map +1 -1
  48. package/dist/src/setup.js +2 -0
  49. package/dist/src/setup.js.map +1 -1
  50. package/dist/tui-build-map.json +19 -5
  51. package/dist/tui-ga-build-map.json +23 -9
  52. package/dist/types/src/common-auth-embedded/claustrum/availability.d.ts +7 -1
  53. package/dist/types/src/common-auth-embedded/claustrum/custody.d.ts +11 -2
  54. package/dist/types/src/common-auth-embedded/claustrum/enrollment.d.ts +4 -0
  55. package/dist/types/src/common-auth-embedded/claustrum/index.d.ts +1 -1
  56. package/dist/types/src/common-auth-embedded/routing-accessor/cache-policy.d.ts +3 -0
  57. package/dist/types/src/common-auth-embedded/routing-accessor/index.d.ts +48 -5
  58. package/dist/types/src/common-auth-embedded/setup/types.d.ts +1 -0
  59. package/dist/types/src/plugin/ga-location-services.d.ts +1 -0
  60. package/dist/types/src/plugin/ga-location-services.d.ts.map +1 -1
  61. package/dist/types/src/plugin/request.d.ts.map +1 -1
  62. package/dist/types/src/setup.d.ts.map +1 -1
  63. package/package.json +4 -3
  64. package/src/common-auth-embedded/claustrum/availability.d.ts +7 -1
  65. package/src/common-auth-embedded/claustrum/availability.js +9 -1
  66. package/src/common-auth-embedded/claustrum/custody.d.ts +11 -2
  67. package/src/common-auth-embedded/claustrum/custody.js +89 -31
  68. package/src/common-auth-embedded/claustrum/enrollment.d.ts +4 -0
  69. package/src/common-auth-embedded/claustrum/enrollment.js +33 -2
  70. package/src/common-auth-embedded/claustrum/host.js +11 -7
  71. package/src/common-auth-embedded/claustrum/index.d.ts +1 -1
  72. package/src/common-auth-embedded/claustrum/index.js +1 -1
  73. package/src/common-auth-embedded/fs/lock-record.js +55 -0
  74. package/src/common-auth-embedded/fs/refresh-file-lock.js +148 -92
  75. package/src/common-auth-embedded/fs/with-lock.js +19 -13
  76. package/src/common-auth-embedded/quota-sidebar/index.d.ts +2 -36
  77. package/src/common-auth-embedded/quota-sidebar/index.tsx +49 -607
  78. package/src/common-auth-embedded/routing-accessor/cache-policy.d.ts +3 -0
  79. package/src/common-auth-embedded/routing-accessor/cache-policy.js +11 -0
  80. package/src/common-auth-embedded/routing-accessor/index.d.ts +48 -5
  81. package/src/common-auth-embedded/routing-accessor/index.js +136 -5
  82. package/src/common-auth-embedded/setup/enroll.js +2 -1
  83. package/src/common-auth-embedded/setup/types.d.ts +1 -0
  84. package/src/common-auth-embedded/source-output.json +72 -64
  85. package/src/tui-compiled/common-auth-embedded/quota-sidebar/index.js +36 -674
  86. package/src/tui-compiled/shared/a75d0d866c227b3f-index.js +678 -0
  87. package/src/tui-ga-compiled/host-ga.js +86 -26
  88. package/src/tui-ga-compiled/shared/a75d0d866c227b3f-index.js +678 -0
  89. package/src/tui-ga-compiled/shared/e4ec36f367492969-index.js +36 -674
  90. package/src/tui-ga-raw/host-ga.tsx +122 -25
  91. package/src/tui-ga-raw/shared/a75d0d866c227b3f-index.tsx +681 -0
  92. package/src/tui-ga-raw/shared/e4ec36f367492969-index.tsx +49 -607
  93. package/src/tui-raw/common-auth-embedded/quota-sidebar/index.tsx +49 -607
  94. package/src/tui-raw/shared/a75d0d866c227b3f-index.tsx +681 -0
package/dist/cli.js CHANGED
@@ -5851,6 +5851,8 @@ function getResolverAliasMap() {
5851
5851
  }
5852
5852
  function getQuotaGroupForModel(modelId, hasArgonPool = false) {
5853
5853
  const normalized = modelId.toLowerCase();
5854
+ if (isGeminiCarbonModel(normalized))
5855
+ return "gemini";
5854
5856
  if (isGeminiArgonModel(normalized))
5855
5857
  return hasArgonPool ? "gemini-argon" : void 0;
5856
5858
  return QUOTA_GROUP_BY_MODEL_ID[normalized] ?? // Check Claude / GPT-OSS substrings BEFORE the `gemini` substring so
@@ -5863,6 +5865,9 @@ function getQuotaGroupForModel(modelId, hasArgonPool = false) {
5863
5865
  function isGeminiArgonModel(model) {
5864
5866
  return /^(?:antigravity-)?gemini-4-argon(?:-(?:low|medium|high))?$/.test(model.toLowerCase());
5865
5867
  }
5868
+ function isGeminiCarbonModel(model) {
5869
+ return /^(?:antigravity-)?gemini-4-carbon(?:-(?:low|medium|high))?$/.test(model.toLowerCase());
5870
+ }
5866
5871
  var DEFAULT_MODALITIES, MODEL_RELEASE_DATE, DEFAULT_COST, DEFAULT_OPTIONS, ALL_MODEL_DEFINITIONS, RESOLVER_ALIASES, QUOTA_GROUP_BY_MODEL_ID, ANTIGRAVITY_OPENCODE_MODEL_IDS, OPENCODE_MODEL_DEFINITIONS;
5867
5872
  var init_model_registry = __esm({
5868
5873
  "../core/dist/model-registry.js"() {
@@ -5886,6 +5891,17 @@ var init_model_registry = __esm({
5886
5891
  high: { thinkingLevel: "high" }
5887
5892
  }
5888
5893
  }),
5894
+ "antigravity-gemini-4-carbon": defineModel("antigravity-gemini-4-carbon", {
5895
+ name: "Gemini 4 Carbon (Antigravity)",
5896
+ reasoning: true,
5897
+ limit: { context: 1048576, output: 262144 },
5898
+ modalities: DEFAULT_MODALITIES,
5899
+ variants: {
5900
+ low: { thinkingLevel: "low" },
5901
+ medium: { thinkingLevel: "medium" },
5902
+ high: { thinkingLevel: "high" }
5903
+ }
5904
+ }),
5889
5905
  "antigravity-gemini-3.1-flash-image": defineModel("antigravity-gemini-3.1-flash-image", {
5890
5906
  name: "Gemini 3.1 Flash Image (Antigravity)",
5891
5907
  reasoning: false,
@@ -5933,6 +5949,9 @@ var init_model_registry = __esm({
5933
5949
  })
5934
5950
  };
5935
5951
  RESOLVER_ALIASES = {
5952
+ "gemini-4-carbon-low": "gemini-4-carbon",
5953
+ "gemini-4-carbon-medium": "gemini-4-carbon",
5954
+ "gemini-4-carbon-high": "gemini-4-carbon",
5936
5955
  "gemini-4-argon-low": "gemini-4-argon",
5937
5956
  "gemini-4-argon-medium": "gemini-4-argon",
5938
5957
  "gemini-4-argon-high": "gemini-4-argon",
@@ -5994,6 +6013,7 @@ var init_model_registry = __esm({
5994
6013
  };
5995
6014
  ANTIGRAVITY_OPENCODE_MODEL_IDS = [
5996
6015
  "antigravity-gemini-4-argon",
6016
+ "antigravity-gemini-4-carbon",
5997
6017
  "antigravity-gemini-3.8-flash",
5998
6018
  "antigravity-gemini-3.1-flash-image",
5999
6019
  "antigravity-claude-sonnet-5-5",
@@ -6104,7 +6124,7 @@ async function rmEvictingDir(evictingPath) {
6104
6124
  });
6105
6125
  }
6106
6126
  async function sleep(ms) {
6107
- await new Promise((resolve22) => setTimeout(resolve22, ms));
6127
+ await new Promise((resolve24) => setTimeout(resolve24, ms));
6108
6128
  }
6109
6129
  async function acquireFencedFileLock(options) {
6110
6130
  const lockPath = `${options.path}.${options.name}.lock`;
@@ -6220,8 +6240,8 @@ function buildLock(lockPath, evictingPath, ownerId, options, now) {
6220
6240
  let released = false;
6221
6241
  let lost = false;
6222
6242
  let lostResolve = null;
6223
- let lostPromise = new Promise((resolve22) => {
6224
- lostResolve = resolve22;
6243
+ let lostPromise = new Promise((resolve24) => {
6244
+ lostResolve = resolve24;
6225
6245
  });
6226
6246
  const markLost = () => {
6227
6247
  if (lost)
@@ -6231,9 +6251,9 @@ function buildLock(lockPath, evictingPath, ownerId, options, now) {
6231
6251
  clearInterval(renewTimer);
6232
6252
  renewTimer = null;
6233
6253
  }
6234
- const resolve22 = lostResolve;
6254
+ const resolve24 = lostResolve;
6235
6255
  lostResolve = null;
6236
- resolve22?.();
6256
+ resolve24?.();
6237
6257
  };
6238
6258
  const setupRenew = () => {
6239
6259
  if (options.renew === false)
@@ -6875,7 +6895,7 @@ var init_account_storage = __esm({
6875
6895
  }
6876
6896
  };
6877
6897
  RETRY_DELAYS_MS = [100, 200, 400, 800, 1e3];
6878
- DEFAULT_SLEEP = (ms) => new Promise((resolve22) => setTimeout(resolve22, ms));
6898
+ DEFAULT_SLEEP = (ms) => new Promise((resolve24) => setTimeout(resolve24, ms));
6879
6899
  DEFAULT_BUILD_BACKUP_PATH = (path2, now) => `${path2}.corrupt-${now.toISOString().replace(/[:.]/g, "-")}`;
6880
6900
  }
6881
6901
  });
@@ -7043,7 +7063,7 @@ function getHttpsProxy(url) {
7043
7063
  }
7044
7064
  }
7045
7065
  function waitForHead(socket, timeoutMs, onTimeout) {
7046
- return new Promise((resolve22, reject) => {
7066
+ return new Promise((resolve24, reject) => {
7047
7067
  let buffer = Buffer2.alloc(0);
7048
7068
  const timeout = setTimeout(() => {
7049
7069
  onTimeout();
@@ -7066,7 +7086,7 @@ function waitForHead(socket, timeoutMs, onTimeout) {
7066
7086
  return;
7067
7087
  const head = buffer.subarray(0, marker).toString("latin1");
7068
7088
  const leftover = buffer.subarray(marker + 4);
7069
- cleanup2(() => resolve22({ head, leftover }));
7089
+ cleanup2(() => resolve24({ head, leftover }));
7070
7090
  };
7071
7091
  socket.on("data", onData);
7072
7092
  socket.once("error", onError);
@@ -7080,7 +7100,7 @@ async function connectViaProxy(proxyUrl, targetUrl, timeoutMs, signal, onDebug)
7080
7100
  port: Number(proxyUrl.port || DEFAULT_PROXY_PORT),
7081
7101
  signal: signal ?? void 0
7082
7102
  });
7083
- await new Promise((resolve22, reject) => {
7103
+ await new Promise((resolve24, reject) => {
7084
7104
  const timeout = setTimeout(() => {
7085
7105
  onDebug?.(`agy transport proxy connect timeout after ${timeoutMs}ms`);
7086
7106
  proxySocket.destroy();
@@ -7089,7 +7109,7 @@ async function connectViaProxy(proxyUrl, targetUrl, timeoutMs, signal, onDebug)
7089
7109
  const cleanup2 = () => clearTimeout(timeout);
7090
7110
  proxySocket.once("connect", () => {
7091
7111
  cleanup2();
7092
- resolve22();
7112
+ resolve24();
7093
7113
  });
7094
7114
  proxySocket.once("error", (error) => {
7095
7115
  cleanup2();
@@ -7114,7 +7134,7 @@ Host: ${targetHost}:${targetPort}\r
7114
7134
  if (leftover.length > 0) {
7115
7135
  proxySocket.unshift(leftover);
7116
7136
  }
7117
- return await new Promise((resolve22, reject) => {
7137
+ return await new Promise((resolve24, reject) => {
7118
7138
  const tlsOptions = {
7119
7139
  socket: proxySocket,
7120
7140
  servername: targetHost,
@@ -7129,7 +7149,7 @@ Host: ${targetHost}:${targetPort}\r
7129
7149
  const cleanup2 = () => clearTimeout(timeout);
7130
7150
  tlsSocket.once("secureConnect", () => {
7131
7151
  cleanup2();
7132
- resolve22(tlsSocket);
7152
+ resolve24(tlsSocket);
7133
7153
  });
7134
7154
  tlsSocket.once("error", (error) => {
7135
7155
  cleanup2();
@@ -7138,7 +7158,7 @@ Host: ${targetHost}:${targetPort}\r
7138
7158
  });
7139
7159
  }
7140
7160
  async function connectDirect(targetUrl, timeoutMs, signal, onDebug) {
7141
- return await new Promise((resolve22, reject) => {
7161
+ return await new Promise((resolve24, reject) => {
7142
7162
  const tlsOptions = {
7143
7163
  host: targetUrl.hostname,
7144
7164
  port: Number(targetUrl.port || DEFAULT_HTTPS_PORT),
@@ -7154,7 +7174,7 @@ async function connectDirect(targetUrl, timeoutMs, signal, onDebug) {
7154
7174
  const cleanup2 = () => clearTimeout(timeout);
7155
7175
  socket.once("secureConnect", () => {
7156
7176
  cleanup2();
7157
- resolve22(socket);
7177
+ resolve24(socket);
7158
7178
  });
7159
7179
  socket.once("error", (error) => {
7160
7180
  cleanup2();
@@ -8711,6 +8731,45 @@ var init_atomic_write2 = __esm({
8711
8731
  }
8712
8732
  });
8713
8733
 
8734
+ // ../core/dist/common-auth-embedded/fs/lock-record.js
8735
+ import { resolve as resolve3 } from "node:path";
8736
+ function isWindowsAccessDeniedRead(error, paths) {
8737
+ return error instanceof PrivateFileError && error.reason === "io-error" && error.win32Code === 5 && (error.stage === "read" || error.stage === "verify") && paths.some((path2) => resolve3(path2) === error.path);
8738
+ }
8739
+ function isWindowsAccessDeniedCreate(error, paths, stage) {
8740
+ return error instanceof PrivateFileError && error.reason === "io-error" && error.win32Code === 5 && error.stage === stage && paths.some((path2) => resolve3(path2) === error.path);
8741
+ }
8742
+ async function readLockRecord(path2, read) {
8743
+ try {
8744
+ return await read();
8745
+ } catch (error) {
8746
+ if (!isWindowsAccessDeniedRead(error, [path2]))
8747
+ throw error;
8748
+ try {
8749
+ return await read();
8750
+ } catch (recheckError) {
8751
+ if (recheckError.code === "ENOENT")
8752
+ throw new DisappearedLockRecordError(path2, error);
8753
+ throw error;
8754
+ }
8755
+ }
8756
+ }
8757
+ var DisappearedLockRecordError;
8758
+ var init_lock_record = __esm({
8759
+ "../core/dist/common-auth-embedded/fs/lock-record.js"() {
8760
+ "use strict";
8761
+ init_private_files();
8762
+ DisappearedLockRecordError = class extends Error {
8763
+ path;
8764
+ code = "ENOENT";
8765
+ constructor(path2, cause) {
8766
+ super(`Lock record disappeared: ${path2}`, { cause });
8767
+ this.path = path2;
8768
+ }
8769
+ };
8770
+ }
8771
+ });
8772
+
8714
8773
  // ../core/dist/common-auth-embedded/fs/refresh-file-lock.js
8715
8774
  import { randomUUID as randomUUID7 } from "node:crypto";
8716
8775
  import { link as link2, lstat as lstat3, mkdir as mkdir7, open as open4, readFile as readFile5, rename as rename6, rm as rm4, stat as stat3 } from "node:fs/promises";
@@ -8793,8 +8852,8 @@ async function acquireRefreshFileLockWithClock(options) {
8793
8852
  let releaseConfirmed = false;
8794
8853
  let loss;
8795
8854
  let resolveLoss;
8796
- const lostPromise = new Promise((resolve22) => {
8797
- resolveLoss = resolve22;
8855
+ const lostPromise = new Promise((resolve24) => {
8856
+ resolveLoss = resolve24;
8798
8857
  });
8799
8858
  function notifyTimerStep(event) {
8800
8859
  try {
@@ -8832,15 +8891,18 @@ async function acquireRefreshFileLockWithClock(options) {
8832
8891
  const evictOwnerId = randomUUID7();
8833
8892
  const EVICT_TTL = 5e3;
8834
8893
  const MAX_STEAL_ATTEMPTS = 8;
8894
+ function isChangingLockCreate(error) {
8895
+ return windowsPrivateFiles && (isWindowsAccessDeniedCreate(error, [lockPath], "create") || isWindowsAccessDeniedCreate(error, [evictPath], "directory-create"));
8896
+ }
8835
8897
  async function readOwner() {
8836
8898
  if (windowsPrivateFiles) {
8837
8899
  try {
8838
- return JSON.parse(await readPrivateText(lockPath, true));
8900
+ return JSON.parse(await readLockRecord(lockPath, () => readPrivateText(lockPath, true)));
8839
8901
  } catch (error) {
8840
8902
  if (error.code !== "EISDIR" && error.reason !== "wrong-kind")
8841
8903
  throw error;
8842
- await verifyPrivate(lockPath, "directory", true);
8843
- return JSON.parse(await readPrivateText(legacyOwnerPath, true));
8904
+ await readLockRecord(lockPath, () => verifyPrivate(lockPath, "directory", true));
8905
+ return JSON.parse(await readLockRecord(legacyOwnerPath, () => readPrivateText(legacyOwnerPath, true)));
8844
8906
  }
8845
8907
  }
8846
8908
  try {
@@ -8916,8 +8978,8 @@ async function acquireRefreshFileLockWithClock(options) {
8916
8978
  await options.onStep("lease-contention-read-ready");
8917
8979
  try {
8918
8980
  if (code2 === "EISDIR") {
8919
- await verifyPrivate(lockPath, "directory", true);
8920
- await readPrivateText(legacyOwnerPath, true);
8981
+ await readLockRecord(lockPath, () => verifyPrivate(lockPath, "directory", true));
8982
+ await readLockRecord(legacyOwnerPath, () => readPrivateText(legacyOwnerPath, true));
8921
8983
  } else
8922
8984
  await readOwner();
8923
8985
  } catch (readError) {
@@ -8955,7 +9017,7 @@ async function acquireRefreshFileLockWithClock(options) {
8955
9017
  }
8956
9018
  }
8957
9019
  async function backoff() {
8958
- await new Promise((resolve22) => setTimeout(resolve22, Math.floor(Math.random() * 4)));
9020
+ await new Promise((resolve24) => setTimeout(resolve24, Math.floor(Math.random() * 4)));
8959
9021
  }
8960
9022
  async function readLockState(notifyReady = true) {
8961
9023
  if (notifyReady && options.onStep)
@@ -8964,6 +9026,8 @@ async function acquireRefreshFileLockWithClock(options) {
8964
9026
  try {
8965
9027
  owner = await readOwner();
8966
9028
  } catch (error) {
9029
+ if (error instanceof DisappearedLockRecordError)
9030
+ return { status: "missing" };
8967
9031
  if (windowsPrivateFiles && error.code !== "ENOENT")
8968
9032
  throw error;
8969
9033
  }
@@ -9011,7 +9075,7 @@ async function acquireRefreshFileLockWithClock(options) {
9011
9075
  }
9012
9076
  async function ownsEvictionMarker() {
9013
9077
  try {
9014
- const owner = JSON.parse(await readPrivateText(evictOwnerPath, windowsPrivateFiles));
9078
+ const owner = JSON.parse(await readLockRecord(evictOwnerPath, () => readPrivateText(evictOwnerPath, windowsPrivateFiles)));
9015
9079
  return owner?.ownerId === evictOwnerId;
9016
9080
  } catch (error) {
9017
9081
  if (windowsPrivateFiles && error.code !== "ENOENT")
@@ -9046,7 +9110,7 @@ async function acquireRefreshFileLockWithClock(options) {
9046
9110
  const remainingMs = deadline - performance.now();
9047
9111
  if (remainingMs <= 0)
9048
9112
  throw original;
9049
- await new Promise((resolve22) => setTimeout(resolve22, Math.min(delayMs, remainingMs)));
9113
+ await new Promise((resolve24) => setTimeout(resolve24, Math.min(delayMs, remainingMs)));
9050
9114
  if (performance.now() >= deadline)
9051
9115
  throw original;
9052
9116
  delayMs = Math.min(delayMs * 2, 50);
@@ -9150,7 +9214,7 @@ async function acquireRefreshFileLockWithClock(options) {
9150
9214
  }
9151
9215
  if (windowsPrivateFiles) {
9152
9216
  try {
9153
- await verifyPrivate(evictPath, "directory", true);
9217
+ await readLockRecord(evictPath, () => verifyPrivate(evictPath, "directory", true));
9154
9218
  } catch (error) {
9155
9219
  if (error.code === "ENOENT")
9156
9220
  return "missing";
@@ -9205,8 +9269,8 @@ async function acquireRefreshFileLockWithClock(options) {
9205
9269
  if (error.code === "EEXIST") {
9206
9270
  if (windowsPrivateFiles) {
9207
9271
  try {
9208
- await verifyPrivate(evictPath, "directory", true);
9209
- await readPrivateText(evictOwnerPath, true);
9272
+ await readLockRecord(evictPath, () => verifyPrivate(evictPath, "directory", true));
9273
+ await readLockRecord(evictOwnerPath, () => readPrivateText(evictOwnerPath, true));
9210
9274
  } catch (ownerError) {
9211
9275
  if (ownerError.code !== "ENOENT")
9212
9276
  throw ownerError;
@@ -9227,7 +9291,11 @@ async function acquireRefreshFileLockWithClock(options) {
9227
9291
  try {
9228
9292
  await releaseEvictionMarker(deadline);
9229
9293
  } catch (error) {
9230
- if (isRetryableRemoval(actionError, lockPath) && isRetryableRemoval(error, evictPath))
9294
+ if ((isRetryableRemoval(actionError, lockPath) || isWindowsAccessDeniedRead(actionError, [
9295
+ lockPath,
9296
+ legacyOwnerPath,
9297
+ evictOwnerPath
9298
+ ])) && (isRetryableRemoval(error, evictPath) || isWindowsAccessDeniedRead(error, [evictOwnerPath])))
9231
9299
  throw actionError;
9232
9300
  throw error;
9233
9301
  }
@@ -9243,7 +9311,7 @@ async function acquireRefreshFileLockWithClock(options) {
9243
9311
  try {
9244
9312
  owner = await readOwner();
9245
9313
  } catch (error) {
9246
- if (windowsPrivateFiles)
9314
+ if (windowsPrivateFiles && !(error instanceof DisappearedLockRecordError))
9247
9315
  throw error;
9248
9316
  return;
9249
9317
  }
@@ -9321,7 +9389,7 @@ async function acquireRefreshFileLockWithClock(options) {
9321
9389
  await options.onStep("renewal-marker-unavailable");
9322
9390
  }
9323
9391
  } catch (error) {
9324
- if (windowsPrivateFiles && error instanceof PrivateFileError) {
9392
+ if (windowsPrivateFiles && error instanceof PrivateFileError && !isChangingLockCreate(error)) {
9325
9393
  terminalIOError = error;
9326
9394
  recordLoss("renewal-failed");
9327
9395
  shouldReschedule = false;
@@ -9367,72 +9435,90 @@ async function acquireRefreshFileLockWithClock(options) {
9367
9435
  }
9368
9436
  return null;
9369
9437
  }
9370
- let acquired = await tryAcquire();
9438
+ let acquired = false;
9439
+ let changingCreateError;
9440
+ try {
9441
+ acquired = await tryAcquire();
9442
+ } catch (error) {
9443
+ if (!isChangingLockCreate(error))
9444
+ throw error;
9445
+ changingCreateError = error;
9446
+ }
9371
9447
  if (!acquired) {
9372
9448
  for (let attempt = 0; attempt < MAX_STEAL_ATTEMPTS; attempt++) {
9373
- acquired = await tryAcquire();
9374
- if (acquired)
9375
- break;
9376
- const observed = await readLockState();
9377
- if (observed.status === "live")
9378
- return contended();
9379
- if (observed.status === "missing")
9380
- continue;
9381
- if (options.onStep)
9382
- await options.onStep("stale-lock-observed");
9383
- try {
9384
- if (!await tryAcquireEvictionMarker()) {
9385
- await backoff();
9386
- continue;
9387
- }
9388
- } catch (evictError) {
9389
- const code2 = evictError.code;
9390
- if (code2 !== "EEXIST")
9391
- throw evictError;
9392
- const recovered = await recoverStaleEvictionMarker();
9393
- if (recovered === "fresh")
9394
- return null;
9395
- await backoff();
9396
- continue;
9397
- }
9398
9449
  try {
9399
- const confirmed = await readLockState();
9400
- if (confirmed.status === "live")
9450
+ acquired = await tryAcquire();
9451
+ if (acquired)
9452
+ break;
9453
+ const observed = await readLockState();
9454
+ if (observed.status === "live")
9401
9455
  return contended();
9402
- if (!sameStaleLock(observed.identity, confirmed))
9456
+ if (observed.status === "missing")
9403
9457
  continue;
9404
- if (!await ownsEvictionMarker())
9405
- return null;
9406
9458
  if (options.onStep)
9407
- await options.onStep("stale-lock-confirmed");
9408
- if (!await ownsEvictionMarker())
9409
- return null;
9410
- const current = await readLockState(false);
9411
- if (!sameStaleLock(observed.identity, current))
9459
+ await options.onStep("stale-lock-observed");
9460
+ try {
9461
+ if (!await tryAcquireEvictionMarker()) {
9462
+ await backoff();
9463
+ continue;
9464
+ }
9465
+ } catch (evictError) {
9466
+ const code2 = evictError.code;
9467
+ if (code2 !== "EEXIST")
9468
+ throw evictError;
9469
+ const recovered = await recoverStaleEvictionMarker();
9470
+ if (recovered === "fresh")
9471
+ return null;
9472
+ await backoff();
9412
9473
  continue;
9413
- await removeLeaseObject(lockPath);
9414
- if (!await ownsEvictionMarker())
9415
- return null;
9416
- if (options.onStep)
9417
- await options.onStep("stale-lock-removed");
9418
- acquired = await tryAcquire();
9419
- if (!acquired)
9420
- return null;
9421
- if (options.onStep)
9422
- await options.onStep("stale-lock-recreated");
9423
- if (!await ownsEvictionMarker()) {
9424
- await relinquishLockAfterMarkerLoss();
9425
- acquired = false;
9426
- return null;
9427
9474
  }
9428
- break;
9429
- } finally {
9430
- await releaseEvictionMarker();
9475
+ try {
9476
+ const confirmed = await readLockState();
9477
+ if (confirmed.status === "live")
9478
+ return contended();
9479
+ if (!sameStaleLock(observed.identity, confirmed))
9480
+ continue;
9481
+ if (!await ownsEvictionMarker())
9482
+ return null;
9483
+ if (options.onStep)
9484
+ await options.onStep("stale-lock-confirmed");
9485
+ if (!await ownsEvictionMarker())
9486
+ return null;
9487
+ const current = await readLockState(false);
9488
+ if (!sameStaleLock(observed.identity, current))
9489
+ continue;
9490
+ await removeLeaseObject(lockPath);
9491
+ if (!await ownsEvictionMarker())
9492
+ return null;
9493
+ if (options.onStep)
9494
+ await options.onStep("stale-lock-removed");
9495
+ acquired = await tryAcquire();
9496
+ if (!acquired)
9497
+ return null;
9498
+ if (options.onStep)
9499
+ await options.onStep("stale-lock-recreated");
9500
+ if (!await ownsEvictionMarker()) {
9501
+ await relinquishLockAfterMarkerLoss();
9502
+ acquired = false;
9503
+ return null;
9504
+ }
9505
+ break;
9506
+ } finally {
9507
+ await releaseEvictionMarker();
9508
+ }
9509
+ } catch (error) {
9510
+ if (!isChangingLockCreate(error))
9511
+ throw error;
9512
+ changingCreateError ??= error;
9513
+ await backoff();
9431
9514
  }
9432
9515
  }
9433
9516
  }
9434
- if (!acquired)
9517
+ if (!acquired) {
9518
+ if (changingCreateError)
9519
+ throw changingCreateError;
9435
9520
  return null;
9521
+ }
9436
9522
  scheduleRenewal();
9437
9523
  return {
9438
9524
  ownerId,
@@ -9470,6 +9556,7 @@ async function acquireRefreshFileLockWithClock(options) {
9470
9556
  const deadline = performance.now() + EVICT_TTL + 1e3;
9471
9557
  let delayMs = 5;
9472
9558
  let removalError;
9559
+ let changingRecordError;
9473
9560
  for (; ; ) {
9474
9561
  try {
9475
9562
  let removalConfirmed = false;
@@ -9495,6 +9582,7 @@ async function acquireRefreshFileLockWithClock(options) {
9495
9582
  await removeLeaseObject(lockPath);
9496
9583
  removalConfirmed = true;
9497
9584
  }, deadline);
9585
+ changingRecordError = void 0;
9498
9586
  if (markerAcquired) {
9499
9587
  if (windowsPrivateFiles && !removalConfirmed)
9500
9588
  throw new PrivateFileError(lockPath, "release-not-confirmed", {
@@ -9507,23 +9595,32 @@ async function acquireRefreshFileLockWithClock(options) {
9507
9595
  return;
9508
9596
  await recoverStaleEvictionMarker(deadline);
9509
9597
  } catch (error) {
9510
- if (!isRetryableRemoval(error, lockPath)) {
9598
+ const changingRecord = windowsPrivateFiles && (isChangingLockCreate(error) || isWindowsAccessDeniedRead(error, [
9599
+ lockPath,
9600
+ legacyOwnerPath,
9601
+ evictPath,
9602
+ evictOwnerPath
9603
+ ]));
9604
+ if (!isRetryableRemoval(error, lockPath) && !changingRecord) {
9511
9605
  if (windowsPrivateFiles)
9512
9606
  throw error;
9513
9607
  return;
9514
9608
  }
9515
- removalError ??= error;
9609
+ if (changingRecord)
9610
+ changingRecordError ??= error;
9611
+ else
9612
+ removalError ??= error;
9516
9613
  }
9517
9614
  const remainingMs = deadline - performance.now();
9518
9615
  if (remainingMs <= 0)
9519
9616
  break;
9520
- await new Promise((resolve22) => setTimeout(resolve22, Math.min(delayMs, remainingMs)));
9617
+ await new Promise((resolve24) => setTimeout(resolve24, Math.min(delayMs, remainingMs)));
9521
9618
  if (windowsPrivateFiles && performance.now() >= deadline)
9522
9619
  break;
9523
9620
  delayMs = Math.min(delayMs * 2, 50);
9524
9621
  }
9525
9622
  if (windowsPrivateFiles)
9526
- throw removalError ?? new PrivateFileError(lockPath, "release-not-confirmed", {
9623
+ throw changingRecordError ?? removalError ?? new PrivateFileError(lockPath, "release-not-confirmed", {
9527
9624
  code: "ETIMEDOUT"
9528
9625
  });
9529
9626
  }
@@ -9533,6 +9630,7 @@ var leaseCreationTestHooks, setRefreshLockRenewalTimeout, clearRefreshLockRenewa
9533
9630
  var init_refresh_file_lock = __esm({
9534
9631
  "../core/dist/common-auth-embedded/fs/refresh-file-lock.js"() {
9535
9632
  "use strict";
9633
+ init_lock_record();
9536
9634
  init_private_files();
9537
9635
  init_with_lock();
9538
9636
  setRefreshLockRenewalTimeout = globalThis.setTimeout.bind(globalThis);
@@ -9542,22 +9640,21 @@ var init_refresh_file_lock = __esm({
9542
9640
  });
9543
9641
 
9544
9642
  // ../core/dist/common-auth-embedded/fs/with-lock.js
9545
- import { join as join6, resolve as resolve3 } from "node:path";
9643
+ import { join as join6, resolve as resolve4 } from "node:path";
9546
9644
  function lockPathFor(target, name) {
9547
9645
  return `${target}.${name}.lock`;
9548
9646
  }
9549
- function isChangingLockRead(error, target, name) {
9550
- if (!isWindowsSharingViolation(error) || error.stage !== "read" && error.stage !== "verify")
9551
- return false;
9552
- const path2 = resolve3(lockPathFor(target, name));
9553
- return error.path === path2 || error.path === join6(path2, "owner.json");
9647
+ function isChangingLockRecord(error, target, name) {
9648
+ const path2 = resolve4(lockPathFor(target, name));
9649
+ const paths = [path2, join6(path2, "owner.json")];
9650
+ return (isWindowsSharingViolation(error) || isWindowsAccessDeniedRead(error, paths)) && (error.stage === "read" || error.stage === "verify") && paths.includes(error.path) || windowsPrivateFiles && (isWindowsAccessDeniedCreate(error, [path2], "create") || isWindowsAccessDeniedCreate(error, [`${path2}.evicting`], "directory-create"));
9554
9651
  }
9555
9652
  async function withLock(target, options, fn) {
9556
9653
  const started = performance.now();
9654
+ let changingRecordError;
9557
9655
  for (; ; ) {
9558
9656
  options.signal?.throwIfAborted();
9559
9657
  let lock;
9560
- let changingReadError;
9561
9658
  try {
9562
9659
  lock = await acquireRefreshFileLock({
9563
9660
  path: target,
@@ -9567,11 +9664,12 @@ async function withLock(target, options, fn) {
9567
9664
  ...options.onStep ? { onStep: options.onStep } : {},
9568
9665
  ...options.onRenewalTimer ? { onRenewalTimer: options.onRenewalTimer } : {}
9569
9666
  });
9667
+ changingRecordError = void 0;
9570
9668
  } catch (error) {
9571
- if (!isChangingLockRead(error, target, options.name))
9669
+ if (!isChangingLockRecord(error, target, options.name))
9572
9670
  throw error;
9573
9671
  lock = null;
9574
- changingReadError = error;
9672
+ changingRecordError ??= error;
9575
9673
  }
9576
9674
  if (lock) {
9577
9675
  try {
@@ -9583,21 +9681,22 @@ async function withLock(target, options, fn) {
9583
9681
  }
9584
9682
  const remaining = options.timeoutMs - (performance.now() - started);
9585
9683
  if (remaining <= 0) {
9586
- if (changingReadError)
9587
- throw changingReadError;
9684
+ if (changingRecordError)
9685
+ throw changingRecordError;
9588
9686
  throw new LockContentionError({
9589
9687
  target,
9590
9688
  name: options.name,
9591
9689
  timeoutMs: options.timeoutMs
9592
9690
  });
9593
9691
  }
9594
- await new Promise((resolve22) => setTimeout(resolve22, Math.min(25, Math.ceil(remaining))));
9692
+ await new Promise((resolve24) => setTimeout(resolve24, Math.min(25, Math.ceil(remaining))));
9595
9693
  }
9596
9694
  }
9597
9695
  var LockContentionError, LockOwnershipError;
9598
9696
  var init_with_lock = __esm({
9599
9697
  "../core/dist/common-auth-embedded/fs/with-lock.js"() {
9600
9698
  "use strict";
9699
+ init_lock_record();
9601
9700
  init_private_files();
9602
9701
  init_refresh_file_lock();
9603
9702
  LockContentionError = class extends Error {
@@ -9680,7 +9779,7 @@ async function acquirePoolLock(spec, defaults, env3) {
9680
9779
  });
9681
9780
  }
9682
9781
  const jitter = Math.floor(Math.random() * (options.retryMs + 1));
9683
- await new Promise((resolve22) => setTimeout(resolve22, Math.min(options.retryMs + jitter, remaining)));
9782
+ await new Promise((resolve24) => setTimeout(resolve24, Math.min(options.retryMs + jitter, remaining)));
9684
9783
  }
9685
9784
  }
9686
9785
  function definedOnly(spec) {
@@ -12574,7 +12673,7 @@ var init_redact = __esm({
12574
12673
  // ../core/dist/common-auth-embedded/logger/engine.js
12575
12674
  import { appendFileSync, chmodSync, existsSync, renameSync, statSync } from "node:fs";
12576
12675
  import { open as open5 } from "node:fs/promises";
12577
- import { dirname as dirname8, resolve as resolve4 } from "node:path";
12676
+ import { dirname as dirname8, resolve as resolve5 } from "node:path";
12578
12677
  function chmodPrivate(path2) {
12579
12678
  try {
12580
12679
  chmodSync(path2, 384);
@@ -12625,7 +12724,7 @@ async function openWindowsFile(sink, file) {
12625
12724
  return sink.handle;
12626
12725
  }
12627
12726
  async function flushWindowsFile(sink, file, text2) {
12628
- file = resolve4(file);
12727
+ file = resolve5(file);
12629
12728
  try {
12630
12729
  if (sink.file !== file)
12631
12730
  await closeWindowsFile(sink);
@@ -13001,11 +13100,11 @@ var init_quota_writer = __esm({
13001
13100
  const left = deadline - performance.now();
13002
13101
  if (left <= 0)
13003
13102
  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);
13004
- await new Promise((resolve22) => {
13103
+ await new Promise((resolve24) => {
13005
13104
  const done = () => {
13006
13105
  clearTimeout(timer);
13007
13106
  this.wake.delete(done);
13008
- resolve22();
13107
+ resolve24();
13009
13108
  };
13010
13109
  const timer = setTimeout(done, left);
13011
13110
  this.wake.add(done);
@@ -13398,7 +13497,7 @@ var init_refresh = __esm({
13398
13497
 
13399
13498
  // ../core/dist/common-auth-embedded/fs/file-read-cache.js
13400
13499
  import { lstat as lstat4, stat as stat4 } from "node:fs/promises";
13401
- import { resolve as resolve5 } from "node:path";
13500
+ import { resolve as resolve6 } from "node:path";
13402
13501
  async function identity(path2, followSymlinks) {
13403
13502
  try {
13404
13503
  const metadata = await (followSymlinks ? stat4(path2) : lstat4(path2));
@@ -13423,7 +13522,7 @@ var init_file_read_cache = __esm({
13423
13522
  this.#followSymlinks = options.followSymlinks ?? false;
13424
13523
  }
13425
13524
  async read(paths, read, validateHit) {
13426
- const resolvedPaths = paths.map((path2) => resolve5(path2));
13525
+ const resolvedPaths = paths.map((path2) => resolve6(path2));
13427
13526
  const key = JSON.stringify(resolvedPaths);
13428
13527
  const probed = await Promise.all(resolvedPaths.map((path2) => identity(path2, this.#followSymlinks)));
13429
13528
  const identities = probed.every((entry) => entry !== void 0) ? probed : void 0;
@@ -15612,9 +15711,17 @@ var init_availability = __esm({
15612
15711
  ERR_PRIVATE_FILES_SECURITY: "answered"
15613
15712
  });
15614
15713
  ClaustrumUnreachableError = class extends ClaustrumConsumerError {
15615
- constructor() {
15714
+ /**
15715
+ * Non-secret host connection diagnostic. A missing accessor can recover
15716
+ * once the host bridge installs; a failed accessor could not provide a client.
15717
+ * Other unreachable failures leave this unset. Never use adapter error text.
15718
+ */
15719
+ reason;
15720
+ constructor(reason) {
15616
15721
  super("unavailable", "Claustrum scoped operation unavailable");
15617
15722
  this.name = "ClaustrumUnreachableError";
15723
+ if (reason === "host-accessor-missing" || reason === "host-accessor-failed")
15724
+ this.reason = reason;
15618
15725
  }
15619
15726
  };
15620
15727
  }
@@ -15635,7 +15742,7 @@ function hostError(error) {
15635
15742
  if (typeof value.code === "string" && (value.class === "transient" || value.class === "permanent" || value.class === "auth_required" || value.class === "context_overflow") && (value.action === "gone" || value.action === "reauth" || value.action === "retry" || value.action === "reduce_and_retry"))
15636
15743
  return new ClaustrumCredentialError2(value.code, value.class, value.action);
15637
15744
  if (value.name === "ClaustrumUnreachableError" || typeof value.code === "string" && classifyVaultFailure(Object.assign(new Error(), { code: value.code })) === "unreachable")
15638
- return new ClaustrumUnreachableError();
15745
+ return new ClaustrumUnreachableError(value.reason === "host-accessor-missing" || value.reason === "host-accessor-failed" ? value.reason : void 0);
15639
15746
  return error;
15640
15747
  }
15641
15748
  function call(operation) {
@@ -15701,14 +15808,15 @@ function connectVaultHost(pluginId) {
15701
15808
  throw new ClaustrumUnreachableError();
15702
15809
  try {
15703
15810
  const accessor = globalThis[/* @__PURE__ */ Symbol.for("cortexkit.vault")];
15704
- if (typeof accessor !== "function")
15705
- throw new ClaustrumUnreachableError();
15706
- const client = wrapHostClient(accessor(pluginId));
15707
- hostClients.add(client);
15708
- return client;
15811
+ if (typeof accessor === "function") {
15812
+ const client = wrapHostClient(accessor(pluginId));
15813
+ hostClients.add(client);
15814
+ return client;
15815
+ }
15709
15816
  } catch {
15710
- throw new ClaustrumUnreachableError();
15817
+ throw new ClaustrumUnreachableError("host-accessor-failed");
15711
15818
  }
15819
+ throw new ClaustrumUnreachableError("host-accessor-missing");
15712
15820
  }
15713
15821
  var VAULT_HOST_STATUS, VAULT_HOST_CONNECT_REFUSAL, hostClients;
15714
15822
  var init_host = __esm({
@@ -16044,7 +16152,7 @@ async function select(terminal, items, options) {
16044
16152
  writeLine("");
16045
16153
  renderedLines = lines;
16046
16154
  };
16047
- return new Promise((resolve22) => {
16155
+ return new Promise((resolve24) => {
16048
16156
  const wasRaw = stdin.isRaw ?? false;
16049
16157
  const cleanup2 = () => {
16050
16158
  if (cleaned)
@@ -16064,7 +16172,7 @@ async function select(terminal, items, options) {
16064
16172
  };
16065
16173
  const finish = (value) => {
16066
16174
  cleanup2();
16067
- resolve22(value);
16175
+ resolve24(value);
16068
16176
  };
16069
16177
  const onSignal = () => finish(null);
16070
16178
  const onKey = (data) => {
@@ -16104,7 +16212,7 @@ async function select(terminal, items, options) {
16104
16212
  stdin.setRawMode(true);
16105
16213
  } catch {
16106
16214
  cleanup2();
16107
- resolve22(null);
16215
+ resolve24(null);
16108
16216
  return;
16109
16217
  }
16110
16218
  stdin.resume();
@@ -16840,7 +16948,7 @@ var init_watch = __esm({
16840
16948
  });
16841
16949
 
16842
16950
  // ../core/dist/common-auth-embedded/claustrum/insula.js
16843
- import { resolve as resolve6 } from "node:path";
16951
+ import { resolve as resolve7 } from "node:path";
16844
16952
  import { storeIdentity } from "@cortexkit/claustrum-client";
16845
16953
  import { SubcClient } from "@cortexkit/subc-client";
16846
16954
  function insulaUsageTransport(options) {
@@ -16968,8 +17076,8 @@ function refusalCode(error) {
16968
17076
  }
16969
17077
  function acquireInsulaQuotaSource(transport, tokenPath) {
16970
17078
  const key = JSON.stringify([
16971
- resolve6(transport.connectionFile),
16972
- resolve6(tokenPath)
17079
+ resolve7(transport.connectionFile),
17080
+ resolve7(tokenPath)
16973
17081
  ]);
16974
17082
  let shared3 = sources.get(key);
16975
17083
  if (!shared3) {
@@ -17283,7 +17391,7 @@ var init_any_signal = __esm({
17283
17391
  import { createHash as createHash5, randomBytes as randomBytes2, randomUUID as randomUUID10 } from "node:crypto";
17284
17392
  import { constants as fsConstants } from "node:fs";
17285
17393
  import { chmod as chmod2, mkdir as mkdir8, open as open6, readFile as readFile6, realpath as realpath3, rename as rename7, stat as stat5, unlink as unlink6 } from "node:fs/promises";
17286
- import { basename as basename3, dirname as dirname9, extname, isAbsolute as isAbsolute2, join as join7, resolve as resolve7 } from "node:path";
17394
+ import { basename as basename3, dirname as dirname9, extname, isAbsolute as isAbsolute2, join as join7, resolve as resolve8 } from "node:path";
17287
17395
  import { ClaustrumCredentialError as ClaustrumCredentialError3, ClaustrumClient as ClaustrumWireClient, writeEnrollmentTokenFile } from "@cortexkit/claustrum-client";
17288
17396
  function classifyEnrollmentError(error) {
17289
17397
  if (!(error instanceof ClaustrumCredentialError3))
@@ -17302,6 +17410,10 @@ function enrollmentName(plugin, host) {
17302
17410
  throw new ClaustrumConsumerError("invalid-state", "Claustrum enrollment names use lowercase letters, digits and dashes");
17303
17411
  return `${plugin}-${host}`;
17304
17412
  }
17413
+ function validEnrollmentDisplayName(displayName) {
17414
+ const length = Array.from(displayName).length;
17415
+ return length >= 1 && length <= 40 && !/[\p{Cc}\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069\u200b-\u200d\u2060\ufeff]/u.test(displayName);
17416
+ }
17305
17417
  function connectClaustrumEnrollmentClient(options) {
17306
17418
  return ClaustrumWireClient.connect(options);
17307
17419
  }
@@ -17317,7 +17429,7 @@ function hostEnrollmentPaths(input) {
17317
17429
  const override = input.override?.trim();
17318
17430
  if (override && !isAbsolute2(override) && !input.cwd)
17319
17431
  throw new ClaustrumConsumerError("invalid-state", "A relative Claustrum enrollment override needs a base directory");
17320
- const tokenPath = override ? isAbsolute2(override) ? override : resolve7(input.cwd, override) : join7(input.stateDir, `${input.host}-enrollment.json`);
17432
+ const tokenPath = override ? isAbsolute2(override) ? override : resolve8(input.cwd, override) : join7(input.stateDir, `${input.host}-enrollment.json`);
17321
17433
  return getClaustrumEnrollmentPaths(tokenPath);
17322
17434
  }
17323
17435
  function isRecord6(value) {
@@ -17784,15 +17896,19 @@ var init_enrollment = __esm({
17784
17896
  #client;
17785
17897
  #paths;
17786
17898
  #proposedName;
17899
+ #displayName;
17787
17900
  #now;
17788
17901
  #mintSecret;
17789
17902
  #writeTokenFile;
17790
17903
  #ancestorOptions;
17791
17904
  constructor(options) {
17905
+ if (options.displayName !== void 0 && !validEnrollmentDisplayName(options.displayName))
17906
+ throw new ClaustrumConsumerError("invalid-state", "invalid Claustrum enrollment display name");
17792
17907
  this.#ancestorOptions = options.ancestorOptions ?? {};
17793
17908
  this.#client = options.client;
17794
17909
  this.#paths = options.paths;
17795
17910
  this.#proposedName = options.proposedName;
17911
+ this.#displayName = options.displayName;
17796
17912
  this.#now = options.now ?? Date.now;
17797
17913
  this.#mintSecret = options.mintSecret ?? (() => randomBytes2(32).toString("hex"));
17798
17914
  this.#writeTokenFile = options.writeTokenFile ?? writeEnrollmentTokenFile;
@@ -17882,10 +17998,23 @@ var init_enrollment = __esm({
17882
17998
  if (!state.requestId) {
17883
17999
  try {
17884
18000
  const requestSecretHash = createHash5("sha256").update(Buffer.from(state.requestSecret, "hex")).digest("hex");
17885
- const proposed = await this.#client.enrollPropose({
18001
+ const proposal = {
17886
18002
  name: state.proposedName,
17887
18003
  requestSecretHash
17888
- });
18004
+ };
18005
+ let proposed;
18006
+ try {
18007
+ proposed = await this.#client.enrollPropose({
18008
+ ...proposal,
18009
+ ...this.#displayName !== void 0 && {
18010
+ displayName: this.#displayName
18011
+ }
18012
+ });
18013
+ } catch (error) {
18014
+ if (this.#displayName === void 0 || !(error instanceof ClaustrumCredentialError3) || error.code !== "invalid_params")
18015
+ throw error;
18016
+ proposed = await this.#client.enrollPropose(proposal);
18017
+ }
17889
18018
  state = {
17890
18019
  ...state,
17891
18020
  requestId: proposed.requestId,
@@ -18052,10 +18181,10 @@ async function drainShutdown(pending, onTimeout) {
18052
18181
  try {
18053
18182
  await Promise.race([
18054
18183
  drained,
18055
- new Promise((resolve22) => {
18184
+ new Promise((resolve24) => {
18056
18185
  timer = setTimeout(() => {
18057
18186
  expired = true;
18058
- resolve22();
18187
+ resolve24();
18059
18188
  }, 2e3);
18060
18189
  })
18061
18190
  ]);
@@ -18399,8 +18528,15 @@ var init_custody = __esm({
18399
18528
  this.#warnShutdown = shutdownWarning(this.#logger);
18400
18529
  this.#setTimeout = options.setTimeoutImpl ?? setTimeout;
18401
18530
  this.#clearTimeout = options.clearTimeoutImpl ?? clearTimeout;
18531
+ const currentClient = () => this.#client;
18402
18532
  this.#usage = new ScopedUsageReporter({
18403
- client: this.#client,
18533
+ client: {
18534
+ // Queued readings follow a replacement without losing client capability checks.
18535
+ get reportUsageScoped() {
18536
+ const client = currentClient();
18537
+ return client.reportUsageScoped?.bind(client);
18538
+ }
18539
+ },
18404
18540
  owns: (id) => this.#usageServed.has(id),
18405
18541
  token: async () => hasVaultHost() ? "" : checkedEnrollmentToken(await this.#readToken()),
18406
18542
  logger: this.#logger,
@@ -18408,12 +18544,30 @@ var init_custody = __esm({
18408
18544
  clearTimeout: this.#clearTimeout
18409
18545
  });
18410
18546
  }
18547
+ /**
18548
+ * Replace the connection to the same vault without discarding receipts or
18549
+ * their enrollment tokens. Open roster watches restart on the new client;
18550
+ * their existing handles remain usable. Passing the current client does nothing.
18551
+ * Neither client is closed here: the caller closes the old one, and custody's
18552
+ * close()/dispose() still closes the client it holds at shutdown.
18553
+ * While hosted, next must come from connectVaultHost, as in the constructor.
18554
+ */
18555
+ replaceClient(next) {
18556
+ this.#check();
18557
+ if (next === this.#client)
18558
+ return;
18559
+ if (hasVaultHost() && !isVaultHostClient(next))
18560
+ throw new ClaustrumUnreachableError();
18561
+ this.#client = next;
18562
+ for (const watch of this.#watches)
18563
+ watch.restart();
18564
+ }
18411
18565
  /** A watch losing its transport is the same outage as an unreachable read. */
18412
18566
  transportLost(error) {
18413
18567
  if (this.#closed || this.#outage)
18414
18568
  return;
18415
18569
  this.#outage = true;
18416
- this.#outageError = error instanceof ClaustrumCredentialError5 ? error : new ClaustrumUnreachableError();
18570
+ this.#outageError = error instanceof ClaustrumCredentialError5 ? error : new ClaustrumUnreachableError(error instanceof ClaustrumUnreachableError ? error.reason : void 0);
18417
18571
  this.#logger.warn("serving kept vault receipt", { reason: "unreachable" });
18418
18572
  this.#scheduleProbe();
18419
18573
  }
@@ -18511,7 +18665,7 @@ var init_custody = __esm({
18511
18665
  if (error instanceof ClaustrumCredentialError5)
18512
18666
  throw error;
18513
18667
  if (classifyVaultFailure(error) === "unreachable")
18514
- throw new ClaustrumUnreachableError();
18668
+ throw new ClaustrumUnreachableError(error instanceof ClaustrumUnreachableError ? error.reason : void 0);
18515
18669
  throw new ClaustrumConsumerError("unavailable", "Claustrum scoped operation unavailable");
18516
18670
  } finally {
18517
18671
  removeAbortListener?.();
@@ -18727,7 +18881,7 @@ var init_custody = __esm({
18727
18881
  if (kept.since === null)
18728
18882
  kept.since = this.#now();
18729
18883
  const attempt = Object.freeze(Object.defineProperty({ ...kept.attempt, fromKeptReceipt: true }, "accessToken", { value: kept.attempt.accessToken, enumerable: false }));
18730
- this.#provenance.set(attempt, this.#provenance.get(kept.attempt) ?? { token, client: this.#client });
18884
+ this.#provenance.set(attempt, this.#provenance.get(kept.attempt) ?? { token });
18731
18885
  this.#keptAttempts.set(attempt, routeId);
18732
18886
  return attempt;
18733
18887
  }
@@ -18788,15 +18942,15 @@ var init_custody = __esm({
18788
18942
  recordVersion: served.recordVersion,
18789
18943
  expiresAtMs
18790
18944
  }, "accessToken", { value: accessToken, enumerable: false }));
18791
- this.#provenance.set(attempt, { token, client: this.#client });
18945
+ this.#provenance.set(attempt, { token });
18792
18946
  return attempt;
18793
18947
  }
18794
18948
  /**
18795
18949
  * Report that a send this consumer actually made was rejected. Only a 401
18796
18950
  * is reported (the vault refuses 429, 402 and 5xx reports), addressed by
18797
18951
  * credential id with the exact record version that send was served, and
18798
- * sent through the client and enrollment token that authorized it. A receipt
18799
- * this custody did not issue is refused rather than reported.
18952
+ * sent through the current client with the enrollment token that authorized
18953
+ * it. A receipt this custody did not issue is refused rather than reported.
18800
18954
  */
18801
18955
  async reportFailure(attempt, status, reporterSource) {
18802
18956
  if (status !== 401)
@@ -18820,7 +18974,7 @@ var init_custody = __esm({
18820
18974
  const pending = this.#reports.get(attempt);
18821
18975
  if (pending)
18822
18976
  return pending;
18823
- const report = this.#call(() => provenance.client.reportAuthFailureScoped({
18977
+ const report = this.#call(() => this.#client.reportAuthFailureScoped({
18824
18978
  credentialId: attempt.credentialId,
18825
18979
  enrollmentToken: provenance.token,
18826
18980
  providerStatus: 401,
@@ -18861,34 +19015,64 @@ var init_custody = __esm({
18861
19015
  */
18862
19016
  watchRoster(options) {
18863
19017
  this.#check();
18864
- const watch = new ScopedRosterWatch({
18865
- client: this.#client,
18866
- enrollmentToken: () => this.#token(),
18867
- view: options.view ?? (() => this.#discoveredView),
18868
- discover: async (view) => {
18869
- await options.onView(view);
18870
- },
18871
- onRefused: (error) => {
18872
- this.listFailed(error);
18873
- options.onRefused?.(error);
19018
+ const currentView = options.view ?? (() => this.#discoveredView);
19019
+ let discovering;
19020
+ let watch;
19021
+ const create = (resubscribed = false) => {
19022
+ const opened = new ScopedRosterWatch({
19023
+ client: this.#client,
19024
+ enrollmentToken: () => this.#token(),
19025
+ // Nothing observed the gap between clients, even if the view is unchanged.
19026
+ view: () => resubscribed ? void 0 : currentView(),
19027
+ discover: async (view) => {
19028
+ while (discovering)
19029
+ await discovering.catch(() => {
19030
+ });
19031
+ if (watch !== opened)
19032
+ return;
19033
+ resubscribed = false;
19034
+ discovering = Promise.resolve().then(() => options.onView(view));
19035
+ try {
19036
+ await discovering;
19037
+ } finally {
19038
+ discovering = void 0;
19039
+ }
19040
+ },
19041
+ onRefused: (error) => {
19042
+ this.listFailed(error);
19043
+ options.onRefused?.(error);
19044
+ },
19045
+ onTransportLost: () => this.transportLost(),
19046
+ onReachable: () => this.reachable(),
19047
+ onError: options.onError,
19048
+ onMode: options.onMode,
19049
+ logger: this.#logger,
19050
+ now: this.#now,
19051
+ setTimeoutImpl: this.#setTimeout,
19052
+ clearTimeoutImpl: this.#clearTimeout
19053
+ });
19054
+ return opened;
19055
+ };
19056
+ watch = create();
19057
+ const tracked = {
19058
+ restart: () => {
19059
+ const previousMode = watch.mode;
19060
+ watch.stop();
19061
+ watch = create(true);
19062
+ if (previousMode !== watch.mode)
19063
+ options.onMode?.(watch.mode);
19064
+ watch.start();
18874
19065
  },
18875
- onTransportLost: () => this.transportLost(),
18876
- onReachable: () => this.reachable(),
18877
- onError: options.onError,
18878
- onMode: options.onMode,
18879
- logger: this.#logger,
18880
- now: this.#now,
18881
- setTimeoutImpl: this.#setTimeout,
18882
- clearTimeoutImpl: this.#clearTimeout
18883
- });
18884
- this.#watches.add(watch);
19066
+ stop: () => watch.stop()
19067
+ };
19068
+ this.#watches.add(tracked);
18885
19069
  watch.start();
18886
19070
  return {
18887
19071
  get mode() {
18888
19072
  return watch.mode;
18889
19073
  },
18890
19074
  close: () => {
18891
- this.#watches.delete(watch);
19075
+ this.#watches.delete(tracked);
18892
19076
  watch.stop();
18893
19077
  }
18894
19078
  };
@@ -19028,7 +19212,7 @@ var init_interlock = __esm({
19028
19212
  // ../core/dist/common-auth-embedded/claustrum/roster.js
19029
19213
  import { createHash as createHash6 } from "node:crypto";
19030
19214
  import { stat as stat6 } from "node:fs/promises";
19031
- import { resolve as resolve8 } from "node:path";
19215
+ import { resolve as resolve9 } from "node:path";
19032
19216
  function vaultRosterSeed(roster) {
19033
19217
  return {
19034
19218
  declined: roster.declined.map((entry) => ({ ...entry })),
@@ -19430,16 +19614,16 @@ function applyVaultQuota(current, input) {
19430
19614
  };
19431
19615
  }
19432
19616
  function forgetPendingVaultDiscovery(path2) {
19433
- pendingDiscoveries.delete(resolve8(path2));
19617
+ pendingDiscoveries.delete(resolve9(path2));
19434
19618
  }
19435
19619
  function isVaultRosterLockRefusal(path2, error) {
19436
- const target = resolve8(path2);
19620
+ const target = resolve9(path2);
19437
19621
  if (error instanceof ClaustrumConsumerError)
19438
19622
  return error.kind === "roster-busy";
19439
19623
  if (error instanceof LockContentionError || error instanceof LockOwnershipError)
19440
- return resolve8(error.details.target) === target;
19624
+ return resolve9(error.details.target) === target;
19441
19625
  if (error instanceof PrivateFileError) {
19442
- const failed = resolve8(error.path);
19626
+ const failed = resolve9(error.path);
19443
19627
  return [WRITE_LOCK.name, DISCOVERY_LEASE.name].some((name) => {
19444
19628
  const lock = lockPathFor(target, name);
19445
19629
  return failed === lock || failed.startsWith(`${lock}.`);
@@ -19500,7 +19684,7 @@ async function refreshVaultRoster(options) {
19500
19684
  throw new ClaustrumConsumerError("roster-busy", "Claustrum account discovery is already in progress");
19501
19685
  return persisted;
19502
19686
  }
19503
- const key = resolve8(options.path);
19687
+ const key = resolve9(options.path);
19504
19688
  const listedOver = options.listedOver;
19505
19689
  let discovered;
19506
19690
  try {
@@ -19624,9 +19808,9 @@ var init_roster = __esm({
19624
19808
  });
19625
19809
 
19626
19810
  // ../core/dist/common-auth-embedded/claustrum/quota-writer.js
19627
- import { resolve as resolve9 } from "node:path";
19811
+ import { resolve as resolve10 } from "node:path";
19628
19812
  function writerFor(path2, clock = quotaCommitTimer) {
19629
- const key = resolve9(path2);
19813
+ const key = resolve10(path2);
19630
19814
  let writer = writers.get(key);
19631
19815
  if (!writer) {
19632
19816
  writer = {
@@ -19690,7 +19874,7 @@ function orderedFields(pending) {
19690
19874
  return [...pending.values()].flatMap((account) => [...account.values()]).sort((a, b) => a.order - b.order);
19691
19875
  }
19692
19876
  function pendingVaultQuota(path2, roster) {
19693
- const writer = writers.get(resolve9(path2));
19877
+ const writer = writers.get(resolve10(path2));
19694
19878
  if (writer) {
19695
19879
  for (const field of orderedFields(writer.pending)) {
19696
19880
  if (field.priorReading)
@@ -19701,7 +19885,7 @@ function pendingVaultQuota(path2, roster) {
19701
19885
  return roster;
19702
19886
  }
19703
19887
  function hasPendingVaultQuota(path2) {
19704
- return !!writers.get(resolve9(path2))?.pending.size;
19888
+ return !!writers.get(resolve10(path2))?.pending.size;
19705
19889
  }
19706
19890
  function schedule(writer, delay3) {
19707
19891
  if (writer.running || writer.timer || !writer.pending.size || writer.abort.signal.aborted)
@@ -19766,7 +19950,7 @@ function flush(writer) {
19766
19950
  return writer.running;
19767
19951
  }
19768
19952
  async function drainVaultQuota(path2, timeoutMs = 1e3) {
19769
- const key = resolve9(path2);
19953
+ const key = resolve10(path2);
19770
19954
  const writer = writers.get(key);
19771
19955
  if (!writer)
19772
19956
  return;
@@ -19914,7 +20098,7 @@ var init_consumer = __esm({
19914
20098
  this.#shutdown.signal,
19915
20099
  ...signal ? [signal] : []
19916
20100
  ]);
19917
- return new Promise((resolve22, reject) => {
20101
+ return new Promise((resolve24, reject) => {
19918
20102
  const cleanup2 = () => {
19919
20103
  combined.signal.removeEventListener("abort", abort);
19920
20104
  combined.dispose();
@@ -19929,7 +20113,7 @@ var init_consumer = __esm({
19929
20113
  if (combined.signal.aborted)
19930
20114
  reject(combined.signal.reason);
19931
20115
  else
19932
- resolve22(value);
20116
+ resolve24(value);
19933
20117
  }, (error) => {
19934
20118
  cleanup2();
19935
20119
  reject(error);
@@ -20674,7 +20858,7 @@ var init_consumer = __esm({
20674
20858
  import { createHash as createHash7 } from "node:crypto";
20675
20859
  import { channel as channel2 } from "node:diagnostics_channel";
20676
20860
  import { readdir, stat as stat7 } from "node:fs/promises";
20677
- import { dirname as dirname10, join as join8, resolve as resolve10 } from "node:path";
20861
+ import { dirname as dirname10, join as join8, resolve as resolve11 } from "node:path";
20678
20862
  function canonicalJson3(value, path2 = /* @__PURE__ */ new Set()) {
20679
20863
  if (value === null)
20680
20864
  return "null";
@@ -20735,12 +20919,12 @@ function unreachableConnect2() {
20735
20919
  return new ClaustrumUnreachableError();
20736
20920
  }
20737
20921
  function untilAborted(pending, signal) {
20738
- return new Promise((resolve22, reject) => {
20922
+ return new Promise((resolve24, reject) => {
20739
20923
  const abort = () => reject(signal.reason);
20740
20924
  signal.addEventListener("abort", abort, { once: true });
20741
20925
  pending.then((value) => {
20742
20926
  signal.removeEventListener("abort", abort);
20743
- resolve22(value);
20927
+ resolve24(value);
20744
20928
  }, (error) => {
20745
20929
  signal.removeEventListener("abort", abort);
20746
20930
  reject(error);
@@ -20898,7 +21082,7 @@ var init_hub = __esm({
20898
21082
  };
20899
21083
  const { consumer, hooks } = createHubMember(port, consumerOptions);
20900
21084
  entry.hooks = hooks;
20901
- const path2 = resolve10(entry.path);
21085
+ const path2 = resolve11(entry.path);
20902
21086
  const subscribers = sharedRosters.get(path2) ?? /* @__PURE__ */ new Set();
20903
21087
  const install = (roster) => {
20904
21088
  if (entry.closed || this.#active !== true || !this.#current || !this.#live(this.#current) || !hooks.roster() || this.#collides(hooks, roster))
@@ -20929,7 +21113,7 @@ var init_hub = __esm({
20929
21113
  return;
20930
21114
  entry.seen = JSON.stringify(decodedVaultRoster(roster));
20931
21115
  entry.hooks?.install(roster);
20932
- for (const install of sharedRosters.get(resolve10(entry.path)) ?? []) {
21116
+ for (const install of sharedRosters.get(resolve11(entry.path)) ?? []) {
20933
21117
  if (!this.#live(generation))
20934
21118
  return;
20935
21119
  if (install !== entry.receiveRoster)
@@ -21732,6 +21916,7 @@ __export(claustrum_exports, {
21732
21916
  reorderVaultRoster: () => reorderVaultRoster,
21733
21917
  resetClaustrumEnrollmentState: () => resetClaustrumEnrollmentState,
21734
21918
  resolveVaultPrimary: () => resolveVaultPrimary,
21919
+ validEnrollmentDisplayName: () => validEnrollmentDisplayName,
21735
21920
  vaultAuthority: () => vaultAuthority,
21736
21921
  vaultRosterSeed: () => vaultRosterSeed,
21737
21922
  vaultRoutingRows: () => vaultRoutingRows
@@ -21988,7 +22173,7 @@ var init_lock = __esm({
21988
22173
  import { createHash as createHash8 } from "node:crypto";
21989
22174
  import { constants as constants2 } from "node:fs";
21990
22175
  import { lstat as lstat5, mkdir as mkdir10, open as open7, unlink as unlink7 } from "node:fs/promises";
21991
- import { dirname as dirname11, resolve as resolve11 } from "node:path";
22176
+ import { dirname as dirname11, resolve as resolve12 } from "node:path";
21992
22177
  import { setTimeout as sleep2 } from "node:timers/promises";
21993
22178
  function rootSpans(text2) {
21994
22179
  let i = text2.indexOf("{") + 1;
@@ -22189,8 +22374,8 @@ function createPiSlot(options, onStep, hooks) {
22189
22374
  if (!provider2 || !options.authPath || !options.stashPath || !placeholderKey || placeholderKey.startsWith("!") || placeholderKey.includes("$") || !Number.isFinite(timeout) || timeout < 0) {
22190
22375
  throw new PiSlotError("invalid-options");
22191
22376
  }
22192
- const authPath = resolve11(options.authPath);
22193
- const stashPath = resolve11(options.stashPath);
22377
+ const authPath = resolve12(options.authPath);
22378
+ const stashPath = resolve12(options.stashPath);
22194
22379
  if (authPath === stashPath || stashPath === `${authPath}.lock`) {
22195
22380
  throw new PiSlotError("invalid-options");
22196
22381
  }
@@ -22458,8 +22643,8 @@ function getDefaultTierId(allowedTiers) {
22458
22643
  return allowedTiers[0]?.id;
22459
22644
  }
22460
22645
  function wait(ms) {
22461
- return new Promise((resolve22) => {
22462
- setTimeout(resolve22, ms);
22646
+ return new Promise((resolve24) => {
22647
+ setTimeout(resolve24, ms);
22463
22648
  });
22464
22649
  }
22465
22650
  function extractManagedProjectId(payload) {
@@ -23481,7 +23666,7 @@ var init_capture_sink2 = __esm({
23481
23666
  import { randomUUID as randomUUID11 } from "node:crypto";
23482
23667
  import { lstat as lstat6, readFile as readFile7, rename as rename8, unlink as unlink8 } from "node:fs/promises";
23483
23668
  import { tmpdir as tmpdir2 } from "node:os";
23484
- import { dirname as dirname13, join as join10, resolve as resolve12 } from "node:path";
23669
+ import { dirname as dirname13, join as join10, resolve as resolve13 } from "node:path";
23485
23670
  function ioCode2(detail) {
23486
23671
  if (detail?.reason === "io-error") {
23487
23672
  if (detail.win32Code === 2 || detail.win32Code === 3)
@@ -23531,7 +23716,7 @@ async function privateOperation2(path2, stage, operation) {
23531
23716
  }
23532
23717
  }
23533
23718
  async function verifySafeDirectory2(path2, options) {
23534
- path2 = resolve12(path2);
23719
+ path2 = resolve13(path2);
23535
23720
  options ??= safeParentOptionsForTest2;
23536
23721
  await privateOperation2(path2, "safe-parent", async () => {
23537
23722
  const result = await (await loadBackend2()).verifySafeParent(path2, options);
@@ -23546,7 +23731,7 @@ async function verifySafeDirectory2(path2, options) {
23546
23731
  });
23547
23732
  }
23548
23733
  async function verifyPrivate2(path2, kind, migrate = false) {
23549
- path2 = resolve12(path2);
23734
+ path2 = resolve13(path2);
23550
23735
  if (kind === "directory")
23551
23736
  return verifySafeDirectory2(path2);
23552
23737
  await privateOperation2(path2, "verify", async () => {
@@ -23581,7 +23766,7 @@ async function verifyPrivate2(path2, kind, migrate = false) {
23581
23766
  });
23582
23767
  }
23583
23768
  async function ensurePrivateDirectory2(path2, _migrate = false, options) {
23584
- path2 = resolve12(path2);
23769
+ path2 = resolve13(path2);
23585
23770
  await privateOperation2(path2, "directory", async () => {
23586
23771
  const api = await loadBackend2();
23587
23772
  try {
@@ -23612,7 +23797,7 @@ async function readPrivateText2(path2, migrate = false) {
23612
23797
  async function readPrivateBuffer2(path2, migrate = false) {
23613
23798
  if (!windowsPrivateFiles2)
23614
23799
  return readFile7(path2);
23615
- path2 = resolve12(path2);
23800
+ path2 = resolve13(path2);
23616
23801
  if (migrate) {
23617
23802
  await verifySafeDirectory2(dirname13(path2));
23618
23803
  await verifyPrivate2(path2, "file", true);
@@ -23620,20 +23805,20 @@ async function readPrivateBuffer2(path2, migrate = false) {
23620
23805
  return privateOperation2(path2, "read", async () => (await loadBackend2()).readOwnerOnly(path2));
23621
23806
  }
23622
23807
  async function createPrivateBytes2(path2, bytes) {
23623
- await verifySafeDirectory2(dirname13(resolve12(path2)));
23808
+ await verifySafeDirectory2(dirname13(resolve13(path2)));
23624
23809
  await privateOperation2(path2, "create", async () => {
23625
- await (await loadBackend2()).createPrivateFile(resolve12(path2), bytes);
23810
+ await (await loadBackend2()).createPrivateFile(resolve13(path2), bytes);
23626
23811
  });
23627
23812
  }
23628
23813
  async function createPrivateDirectoryExclusive2(path2) {
23629
- await verifySafeDirectory2(dirname13(resolve12(path2)));
23814
+ await verifySafeDirectory2(dirname13(resolve13(path2)));
23630
23815
  await privateOperation2(path2, "directory-create", async () => {
23631
- await (await loadBackend2()).createOwnerOnly(resolve12(path2), { kind: "dir" });
23816
+ await (await loadBackend2()).createOwnerOnly(resolve13(path2), { kind: "dir" });
23632
23817
  });
23633
23818
  }
23634
23819
  async function replaceWindowsFile2(from, to, options = {}) {
23635
- from = resolve12(from);
23636
- to = resolve12(to);
23820
+ from = resolve13(from);
23821
+ to = resolve13(to);
23637
23822
  const now = options.now ?? (() => performance.now());
23638
23823
  const start = now();
23639
23824
  const leaseDeadline = options.deadline ?? Infinity;
@@ -23676,7 +23861,7 @@ async function replaceWindowsFile2(from, to, options = {}) {
23676
23861
  throw error;
23677
23862
  }
23678
23863
  async function writePrivateAtomic2(path2, bytes, options = {}) {
23679
- path2 = resolve12(path2);
23864
+ path2 = resolve13(path2);
23680
23865
  await ensurePrivateDirectory2(dirname13(path2));
23681
23866
  try {
23682
23867
  await verifyPrivate2(path2, "file", true);
@@ -23684,7 +23869,7 @@ async function writePrivateAtomic2(path2, bytes, options = {}) {
23684
23869
  if (error.code !== "ENOENT")
23685
23870
  throw error;
23686
23871
  }
23687
- const stage = resolve12(options.stagePath ?? `${path2}.${randomUUID11()}.tmp`);
23872
+ const stage = resolve13(options.stagePath ?? `${path2}.${randomUUID11()}.tmp`);
23688
23873
  if (dirname13(stage) !== dirname13(path2))
23689
23874
  throw new PrivateFileError2(path2, "stage-directory", { code: "EXDEV" });
23690
23875
  let created = false;
@@ -23850,7 +24035,7 @@ var init_redact2 = __esm({
23850
24035
  // src/common-auth-embedded/logger/engine.js
23851
24036
  import { appendFileSync as appendFileSync2, chmodSync as chmodSync2, existsSync as existsSync2, renameSync as renameSync2, statSync as statSync3 } from "node:fs";
23852
24037
  import { open as open8 } from "node:fs/promises";
23853
- import { dirname as dirname14, resolve as resolve13 } from "node:path";
24038
+ import { dirname as dirname14, resolve as resolve14 } from "node:path";
23854
24039
  function chmodPrivate2(path2) {
23855
24040
  try {
23856
24041
  chmodSync2(path2, 384);
@@ -23901,7 +24086,7 @@ async function openWindowsFile2(sink, file) {
23901
24086
  return sink.handle;
23902
24087
  }
23903
24088
  async function flushWindowsFile2(sink, file, text2) {
23904
- file = resolve13(file);
24089
+ file = resolve14(file);
23905
24090
  try {
23906
24091
  if (sink.file !== file)
23907
24092
  await closeWindowsFile2(sink);
@@ -24222,7 +24407,7 @@ import { randomUUID as randomUUID12 } from "node:crypto";
24222
24407
  import { realpathSync, rmSync } from "node:fs";
24223
24408
  import { chmod as chmod3, mkdir as mkdir11, readFile as readFile8, rename as rename9, rm as rm5, writeFile as writeFile3 } from "node:fs/promises";
24224
24409
  import { homedir as homedir2 } from "node:os";
24225
- import { join as join11, resolve as resolve14 } from "node:path";
24410
+ import { join as join11, resolve as resolve15 } from "node:path";
24226
24411
  function processHeartbeatDir() {
24227
24412
  const base = process.env.XDG_STATE_HOME || join11(homedir2(), ".local", "state");
24228
24413
  return join11(base, "cortexkit", "antigravity-auth", "processes");
@@ -24235,7 +24420,7 @@ function processConfigFolderKey() {
24235
24420
  try {
24236
24421
  return realpathSync.native(folder);
24237
24422
  } catch {
24238
- return resolve14(folder);
24423
+ return resolve15(folder);
24239
24424
  }
24240
24425
  }
24241
24426
  function processHasOlderGeneration() {
@@ -24819,7 +25004,7 @@ import {
24819
25004
  stat as stat10,
24820
25005
  unlink as unlink10
24821
25006
  } from "node:fs/promises";
24822
- import { basename as basename4, dirname as dirname15, join as join13, resolve as resolve15 } from "node:path";
25007
+ import { basename as basename4, dirname as dirname15, join as join13, resolve as resolve16 } from "node:path";
24823
25008
  function refusalMessage(stateDir, errorClass2) {
24824
25009
  if (errorClass2 === "ERR_PRIVATE_FILES_SECURITY")
24825
25010
  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.`;
@@ -25679,7 +25864,7 @@ async function removeMovedVaultStateLeftover(vaultDir, accountFile) {
25679
25864
  if (process.env.OPENCODE_ANTIGRAVITY_AUTH_VAULT_DIR) return;
25680
25865
  const location = runtimeLayoutLocation();
25681
25866
  const files = layoutFiles(location, accountFile);
25682
- if (resolve15(vaultDir) !== resolve15(files.vault.next)) return;
25867
+ if (resolve16(vaultDir) !== resolve16(files.vault.next)) return;
25683
25868
  const stateDir = location.stateHomeDir;
25684
25869
  const marker = await readMarker(
25685
25870
  join13(stateDir, RUNTIME_LAYOUT_MARKER_FILE),
@@ -26108,7 +26293,7 @@ import {
26108
26293
  writeFileSync
26109
26294
  } from "node:fs";
26110
26295
  import { homedir as homedir4 } from "node:os";
26111
- import { dirname as dirname16, join as join14, resolve as resolve16 } from "node:path";
26296
+ import { dirname as dirname16, join as join14, resolve as resolve17 } from "node:path";
26112
26297
  async function ensureGitignore(configDir) {
26113
26298
  const gitignorePath = join14(configDir, ".gitignore");
26114
26299
  try {
@@ -26208,8 +26393,8 @@ function migrateLegacyWindowsConfig() {
26208
26393
  }
26209
26394
  }
26210
26395
  function resolveWindowsAccountAnchor(newPath, legacyPath) {
26211
- const standard = resolve16(newPath);
26212
- const legacy = resolve16(legacyPath);
26396
+ const standard = resolve17(newPath);
26397
+ const legacy = resolve17(legacyPath);
26213
26398
  if (standard.toLowerCase() === legacy.toLowerCase()) return newPath;
26214
26399
  const standardPointer = existsSync3(accountStorePointerPath(standard));
26215
26400
  const legacyPointer = existsSync3(accountStorePointerPath(legacy));
@@ -26231,7 +26416,7 @@ function getStoragePathWithMigration() {
26231
26416
  "antigravity-accounts.json"
26232
26417
  );
26233
26418
  const anchored = resolveWindowsAccountAnchor(newPath, legacyPath);
26234
- if (resolve16(anchored).toLowerCase() !== resolve16(newPath).toLowerCase() && !existsSync3(accountStorePointerPath(resolve16(anchored)))) {
26419
+ if (resolve17(anchored).toLowerCase() !== resolve17(newPath).toLowerCase() && !existsSync3(accountStorePointerPath(resolve17(anchored)))) {
26235
26420
  log6.info("Using legacy Windows config path (migration failed)", {
26236
26421
  legacyPath,
26237
26422
  newPath
@@ -26248,7 +26433,7 @@ function accountFileForVault(configDir = getConfigDir()) {
26248
26433
  const configured = join14(configDir, "antigravity-accounts.json");
26249
26434
  if (process.platform !== "win32") return configured;
26250
26435
  const legacyDir = getLegacyWindowsConfigDir();
26251
- if (resolve16(configDir).toLowerCase() === resolve16(legacyDir).toLowerCase())
26436
+ if (resolve17(configDir).toLowerCase() === resolve17(legacyDir).toLowerCase())
26252
26437
  return configured;
26253
26438
  const configuredVault = join14(configDir, "antigravity-auth-vault");
26254
26439
  const legacyVault = join14(legacyDir, "antigravity-auth-vault");
@@ -26279,7 +26464,7 @@ function getStoragePath() {
26279
26464
  }
26280
26465
  async function assertLegacyPoolInUse(legacyPath) {
26281
26466
  try {
26282
- await assertLegacyAccountStorageWritable(resolve16(legacyPath));
26467
+ await assertLegacyAccountStorageWritable(resolve17(legacyPath));
26283
26468
  } catch (error) {
26284
26469
  throw new LegacyAccountPoolRetiredError(legacyPath, { cause: error });
26285
26470
  }
@@ -26299,7 +26484,7 @@ function refusalMessage2(admission) {
26299
26484
  async function bindingOf(options) {
26300
26485
  if (options.legacyPath === void 0) await prepareLocalAccountStore();
26301
26486
  const now = options.now ?? (() => Date.now());
26302
- const legacyPath = resolve16(options.legacyPath ?? getStoragePath());
26487
+ const legacyPath = resolve17(options.legacyPath ?? getStoragePath());
26303
26488
  return {
26304
26489
  legacyPath,
26305
26490
  now,
@@ -26368,7 +26553,7 @@ async function openAccountStore(options) {
26368
26553
  async function initializeFreshAccountStoreFor(modules, options = {}) {
26369
26554
  if (options.legacyPath === void 0) await prepareLocalAccountStore();
26370
26555
  return initializeFreshAccountStore(modules, {
26371
- legacyPath: resolve16(options.legacyPath ?? getStoragePath()),
26556
+ legacyPath: resolve17(options.legacyPath ?? getStoragePath()),
26372
26557
  now: options.now ?? (() => Date.now())
26373
26558
  });
26374
26559
  }
@@ -26414,12 +26599,12 @@ var init_storage = __esm({
26414
26599
  import { createHash as createHash11 } from "node:crypto";
26415
26600
  import { existsSync as existsSync4, promises as fs2, readFileSync as readFileSync2, realpathSync as realpathSync2 } from "node:fs";
26416
26601
  import { homedir as homedir5 } from "node:os";
26417
- import { dirname as dirname17, join as join15, resolve as resolve17 } from "node:path";
26602
+ import { dirname as dirname17, join as join15, resolve as resolve18 } from "node:path";
26418
26603
  function configDirIdentity(path2) {
26419
26604
  try {
26420
26605
  return realpathSync2.native(path2);
26421
26606
  } catch {
26422
- return resolve17(path2);
26607
+ return resolve18(path2);
26423
26608
  }
26424
26609
  }
26425
26610
  function decisionKey(location) {
@@ -27081,13 +27266,13 @@ function closeDebugLog() {
27081
27266
  if (!state || !current) return Promise.resolve();
27082
27267
  state.logStream = null;
27083
27268
  if (state.logFilePath) liveLogFilePaths.delete(state.logFilePath);
27084
- return new Promise((resolve22) => {
27085
- current.once("close", () => resolve22());
27086
- current.once("error", () => resolve22());
27269
+ return new Promise((resolve24) => {
27270
+ current.once("close", () => resolve24());
27271
+ current.once("error", () => resolve24());
27087
27272
  try {
27088
27273
  current.end();
27089
27274
  } catch {
27090
- resolve22();
27275
+ resolve24();
27091
27276
  }
27092
27277
  });
27093
27278
  }
@@ -27234,7 +27419,7 @@ var init_logger4 = __esm({
27234
27419
  init_dist();
27235
27420
  import { execFile } from "node:child_process";
27236
27421
  import { realpathSync as realpathSync4 } from "node:fs";
27237
- import { resolve as resolve21 } from "node:path";
27422
+ import { resolve as resolve23 } from "node:path";
27238
27423
  import { createInterface } from "node:readline/promises";
27239
27424
  import { fileURLToPath as fileURLToPath2 } from "node:url";
27240
27425
  import { promisify } from "node:util";
@@ -27642,14 +27827,14 @@ async function fetchQuotaPayloads(options) {
27642
27827
  };
27643
27828
  }
27644
27829
  function untilQuotaAborted(pending, signal) {
27645
- return new Promise((resolve22, reject) => {
27830
+ return new Promise((resolve24, reject) => {
27646
27831
  const abort = () => reject(signal.reason);
27647
27832
  if (signal.aborted) abort();
27648
27833
  else signal.addEventListener("abort", abort, { once: true });
27649
27834
  void pending.then(
27650
27835
  (value) => {
27651
27836
  signal.removeEventListener("abort", abort);
27652
- resolve22(value);
27837
+ resolve24(value);
27653
27838
  },
27654
27839
  (error) => {
27655
27840
  signal.removeEventListener("abort", abort);
@@ -27931,12 +28116,12 @@ async function startOAuthListener({
27931
28116
  let resolveCallback;
27932
28117
  let rejectCallback;
27933
28118
  let timeoutHandle;
27934
- const callbackPromise = new Promise((resolve22, reject) => {
28119
+ const callbackPromise = new Promise((resolve24, reject) => {
27935
28120
  resolveCallback = (url) => {
27936
28121
  if (settled) return;
27937
28122
  settled = true;
27938
28123
  if (timeoutHandle) clearTimeout(timeoutHandle);
27939
- resolve22(url);
28124
+ resolve24(url);
27940
28125
  };
27941
28126
  rejectCallback = (error) => {
27942
28127
  if (settled) return;
@@ -28095,7 +28280,7 @@ async function startOAuthListener({
28095
28280
  });
28096
28281
  });
28097
28282
  const bindAddress = getBindAddress();
28098
- await new Promise((resolve22, reject) => {
28283
+ await new Promise((resolve24, reject) => {
28099
28284
  const handleError = (error) => {
28100
28285
  server.off("error", handleError);
28101
28286
  if (error.code === "EADDRINUSE") {
@@ -28111,7 +28296,7 @@ async function startOAuthListener({
28111
28296
  server.once("error", handleError);
28112
28297
  server.listen(port, bindAddress, () => {
28113
28298
  server.off("error", handleError);
28114
- resolve22();
28299
+ resolve24();
28115
28300
  });
28116
28301
  });
28117
28302
  server.on("error", (error) => {
@@ -28119,7 +28304,7 @@ async function startOAuthListener({
28119
28304
  });
28120
28305
  return {
28121
28306
  waitForCallback: () => callbackPromise,
28122
- close: () => new Promise((resolve22, reject) => {
28307
+ close: () => new Promise((resolve24, reject) => {
28123
28308
  server.close((error) => {
28124
28309
  if (error && error.code !== "ERR_SERVER_NOT_RUNNING") {
28125
28310
  reject(error);
@@ -28128,7 +28313,7 @@ async function startOAuthListener({
28128
28313
  if (!settled) {
28129
28314
  rejectCallback(new Error("OAuth listener closed before callback"));
28130
28315
  }
28131
- resolve22();
28316
+ resolve24();
28132
28317
  });
28133
28318
  })
28134
28319
  };
@@ -28147,7 +28332,7 @@ init_runtime_paths();
28147
28332
  // src/setup.ts
28148
28333
  init_dist();
28149
28334
  import { lstat as lstat9, readFile as readFile13 } from "node:fs/promises";
28150
- import { join as join22, resolve as resolve20 } from "node:path";
28335
+ import { join as join22, resolve as resolve22 } from "node:path";
28151
28336
 
28152
28337
  // src/auth-method-labels.ts
28153
28338
  var OPENCODE2_POOL_AUTH_LABEL = "Google (antigravity-auth pool, browser)";
@@ -28320,7 +28505,7 @@ async function select2(terminal, items, options) {
28320
28505
  writeLine("");
28321
28506
  renderedLines = lines;
28322
28507
  };
28323
- return new Promise((resolve22) => {
28508
+ return new Promise((resolve24) => {
28324
28509
  const wasRaw = stdin.isRaw ?? false;
28325
28510
  const cleanup2 = () => {
28326
28511
  if (cleaned)
@@ -28340,7 +28525,7 @@ async function select2(terminal, items, options) {
28340
28525
  };
28341
28526
  const finish = (value) => {
28342
28527
  cleanup2();
28343
- resolve22(value);
28528
+ resolve24(value);
28344
28529
  };
28345
28530
  const onSignal = () => finish(null);
28346
28531
  const onKey = (data) => {
@@ -28380,7 +28565,7 @@ async function select2(terminal, items, options) {
28380
28565
  stdin.setRawMode(true);
28381
28566
  } catch {
28382
28567
  cleanup2();
28383
- resolve22(null);
28568
+ resolve24(null);
28384
28569
  return;
28385
28570
  }
28386
28571
  stdin.resume();
@@ -28394,12 +28579,12 @@ async function select2(terminal, items, options) {
28394
28579
  import { createHash as createHash12, randomBytes as randomBytes3, randomUUID as randomUUID15 } from "node:crypto";
28395
28580
  import { constants as fsConstants2 } from "node:fs";
28396
28581
  import { chmod as chmod5, mkdir as mkdir14, open as open10, readFile as readFile12, realpath as realpath4, rename as rename12, stat as stat13, unlink as unlink11 } from "node:fs/promises";
28397
- import { basename as basename5, dirname as dirname19, extname as extname2, isAbsolute as isAbsolute4, join as join18, resolve as resolve19 } from "node:path";
28582
+ import { basename as basename5, dirname as dirname19, extname as extname2, isAbsolute as isAbsolute4, join as join18, resolve as resolve21 } from "node:path";
28398
28583
  import { ClaustrumCredentialError as ClaustrumCredentialError9, ClaustrumClient as ClaustrumWireClient2, writeEnrollmentTokenFile as writeEnrollmentTokenFile2 } from "@cortexkit/claustrum-client";
28399
28584
 
28400
28585
  // src/common-auth-embedded/fs/file-read-cache.js
28401
28586
  import { lstat as lstat7, stat as stat11 } from "node:fs/promises";
28402
- import { resolve as resolve18 } from "node:path";
28587
+ import { resolve as resolve19 } from "node:path";
28403
28588
  async function identity2(path2, followSymlinks) {
28404
28589
  try {
28405
28590
  const metadata = await (followSymlinks ? stat11(path2) : lstat7(path2));
@@ -28420,7 +28605,7 @@ var FileReadCache2 = class {
28420
28605
  this.#followSymlinks = options.followSymlinks ?? false;
28421
28606
  }
28422
28607
  async read(paths, read, validateHit) {
28423
- const resolvedPaths = paths.map((path2) => resolve18(path2));
28608
+ const resolvedPaths = paths.map((path2) => resolve19(path2));
28424
28609
  const key = JSON.stringify(resolvedPaths);
28425
28610
  const probed = await Promise.all(resolvedPaths.map((path2) => identity2(path2, this.#followSymlinks)));
28426
28611
  const identities = probed.every((entry) => entry !== void 0) ? probed : void 0;
@@ -28469,11 +28654,46 @@ var WRITER_LOCK_CONSTANTS2 = Object.freeze({
28469
28654
  init_private_files2();
28470
28655
 
28471
28656
  // src/common-auth-embedded/fs/refresh-file-lock.js
28472
- init_private_files2();
28473
28657
  import { randomUUID as randomUUID14 } from "node:crypto";
28474
28658
  import { link as link3, lstat as lstat8, mkdir as mkdir13, open as open9, readFile as readFile11, rename as rename11, rm as rm6, stat as stat12 } from "node:fs/promises";
28475
28659
  import { dirname as dirname18, join as join17 } from "node:path";
28476
28660
 
28661
+ // src/common-auth-embedded/fs/lock-record.js
28662
+ init_private_files2();
28663
+ import { resolve as resolve20 } from "node:path";
28664
+ var DisappearedLockRecordError2 = class extends Error {
28665
+ path;
28666
+ code = "ENOENT";
28667
+ constructor(path2, cause) {
28668
+ super(`Lock record disappeared: ${path2}`, { cause });
28669
+ this.path = path2;
28670
+ }
28671
+ };
28672
+ function isWindowsAccessDeniedRead2(error, paths) {
28673
+ return error instanceof PrivateFileError2 && error.reason === "io-error" && error.win32Code === 5 && (error.stage === "read" || error.stage === "verify") && paths.some((path2) => resolve20(path2) === error.path);
28674
+ }
28675
+ function isWindowsAccessDeniedCreate2(error, paths, stage) {
28676
+ return error instanceof PrivateFileError2 && error.reason === "io-error" && error.win32Code === 5 && error.stage === stage && paths.some((path2) => resolve20(path2) === error.path);
28677
+ }
28678
+ async function readLockRecord2(path2, read) {
28679
+ try {
28680
+ return await read();
28681
+ } catch (error) {
28682
+ if (!isWindowsAccessDeniedRead2(error, [path2]))
28683
+ throw error;
28684
+ try {
28685
+ return await read();
28686
+ } catch (recheckError) {
28687
+ if (recheckError.code === "ENOENT")
28688
+ throw new DisappearedLockRecordError2(path2, error);
28689
+ throw error;
28690
+ }
28691
+ }
28692
+ }
28693
+
28694
+ // src/common-auth-embedded/fs/refresh-file-lock.js
28695
+ init_private_files2();
28696
+
28477
28697
  // src/common-auth-embedded/fs/with-lock.js
28478
28698
  init_private_files2();
28479
28699
  function lockPathFor2(target, name) {
@@ -28572,8 +28792,8 @@ async function acquireRefreshFileLockWithClock2(options) {
28572
28792
  let releaseConfirmed = false;
28573
28793
  let loss;
28574
28794
  let resolveLoss;
28575
- const lostPromise = new Promise((resolve22) => {
28576
- resolveLoss = resolve22;
28795
+ const lostPromise = new Promise((resolve24) => {
28796
+ resolveLoss = resolve24;
28577
28797
  });
28578
28798
  function notifyTimerStep(event) {
28579
28799
  try {
@@ -28611,15 +28831,18 @@ async function acquireRefreshFileLockWithClock2(options) {
28611
28831
  const evictOwnerId = randomUUID14();
28612
28832
  const EVICT_TTL = 5e3;
28613
28833
  const MAX_STEAL_ATTEMPTS = 8;
28834
+ function isChangingLockCreate(error) {
28835
+ return windowsPrivateFiles2 && (isWindowsAccessDeniedCreate2(error, [lockPath], "create") || isWindowsAccessDeniedCreate2(error, [evictPath], "directory-create"));
28836
+ }
28614
28837
  async function readOwner() {
28615
28838
  if (windowsPrivateFiles2) {
28616
28839
  try {
28617
- return JSON.parse(await readPrivateText2(lockPath, true));
28840
+ return JSON.parse(await readLockRecord2(lockPath, () => readPrivateText2(lockPath, true)));
28618
28841
  } catch (error) {
28619
28842
  if (error.code !== "EISDIR" && error.reason !== "wrong-kind")
28620
28843
  throw error;
28621
- await verifyPrivate2(lockPath, "directory", true);
28622
- return JSON.parse(await readPrivateText2(legacyOwnerPath, true));
28844
+ await readLockRecord2(lockPath, () => verifyPrivate2(lockPath, "directory", true));
28845
+ return JSON.parse(await readLockRecord2(legacyOwnerPath, () => readPrivateText2(legacyOwnerPath, true)));
28623
28846
  }
28624
28847
  }
28625
28848
  try {
@@ -28695,8 +28918,8 @@ async function acquireRefreshFileLockWithClock2(options) {
28695
28918
  await options.onStep("lease-contention-read-ready");
28696
28919
  try {
28697
28920
  if (code2 === "EISDIR") {
28698
- await verifyPrivate2(lockPath, "directory", true);
28699
- await readPrivateText2(legacyOwnerPath, true);
28921
+ await readLockRecord2(lockPath, () => verifyPrivate2(lockPath, "directory", true));
28922
+ await readLockRecord2(legacyOwnerPath, () => readPrivateText2(legacyOwnerPath, true));
28700
28923
  } else
28701
28924
  await readOwner();
28702
28925
  } catch (readError) {
@@ -28734,7 +28957,7 @@ async function acquireRefreshFileLockWithClock2(options) {
28734
28957
  }
28735
28958
  }
28736
28959
  async function backoff() {
28737
- await new Promise((resolve22) => setTimeout(resolve22, Math.floor(Math.random() * 4)));
28960
+ await new Promise((resolve24) => setTimeout(resolve24, Math.floor(Math.random() * 4)));
28738
28961
  }
28739
28962
  async function readLockState(notifyReady = true) {
28740
28963
  if (notifyReady && options.onStep)
@@ -28743,6 +28966,8 @@ async function acquireRefreshFileLockWithClock2(options) {
28743
28966
  try {
28744
28967
  owner = await readOwner();
28745
28968
  } catch (error) {
28969
+ if (error instanceof DisappearedLockRecordError2)
28970
+ return { status: "missing" };
28746
28971
  if (windowsPrivateFiles2 && error.code !== "ENOENT")
28747
28972
  throw error;
28748
28973
  }
@@ -28790,7 +29015,7 @@ async function acquireRefreshFileLockWithClock2(options) {
28790
29015
  }
28791
29016
  async function ownsEvictionMarker() {
28792
29017
  try {
28793
- const owner = JSON.parse(await readPrivateText2(evictOwnerPath, windowsPrivateFiles2));
29018
+ const owner = JSON.parse(await readLockRecord2(evictOwnerPath, () => readPrivateText2(evictOwnerPath, windowsPrivateFiles2)));
28794
29019
  return owner?.ownerId === evictOwnerId;
28795
29020
  } catch (error) {
28796
29021
  if (windowsPrivateFiles2 && error.code !== "ENOENT")
@@ -28825,7 +29050,7 @@ async function acquireRefreshFileLockWithClock2(options) {
28825
29050
  const remainingMs = deadline - performance.now();
28826
29051
  if (remainingMs <= 0)
28827
29052
  throw original;
28828
- await new Promise((resolve22) => setTimeout(resolve22, Math.min(delayMs, remainingMs)));
29053
+ await new Promise((resolve24) => setTimeout(resolve24, Math.min(delayMs, remainingMs)));
28829
29054
  if (performance.now() >= deadline)
28830
29055
  throw original;
28831
29056
  delayMs = Math.min(delayMs * 2, 50);
@@ -28929,7 +29154,7 @@ async function acquireRefreshFileLockWithClock2(options) {
28929
29154
  }
28930
29155
  if (windowsPrivateFiles2) {
28931
29156
  try {
28932
- await verifyPrivate2(evictPath, "directory", true);
29157
+ await readLockRecord2(evictPath, () => verifyPrivate2(evictPath, "directory", true));
28933
29158
  } catch (error) {
28934
29159
  if (error.code === "ENOENT")
28935
29160
  return "missing";
@@ -28984,8 +29209,8 @@ async function acquireRefreshFileLockWithClock2(options) {
28984
29209
  if (error.code === "EEXIST") {
28985
29210
  if (windowsPrivateFiles2) {
28986
29211
  try {
28987
- await verifyPrivate2(evictPath, "directory", true);
28988
- await readPrivateText2(evictOwnerPath, true);
29212
+ await readLockRecord2(evictPath, () => verifyPrivate2(evictPath, "directory", true));
29213
+ await readLockRecord2(evictOwnerPath, () => readPrivateText2(evictOwnerPath, true));
28989
29214
  } catch (ownerError) {
28990
29215
  if (ownerError.code !== "ENOENT")
28991
29216
  throw ownerError;
@@ -29006,7 +29231,11 @@ async function acquireRefreshFileLockWithClock2(options) {
29006
29231
  try {
29007
29232
  await releaseEvictionMarker(deadline);
29008
29233
  } catch (error) {
29009
- if (isRetryableRemoval(actionError, lockPath) && isRetryableRemoval(error, evictPath))
29234
+ if ((isRetryableRemoval(actionError, lockPath) || isWindowsAccessDeniedRead2(actionError, [
29235
+ lockPath,
29236
+ legacyOwnerPath,
29237
+ evictOwnerPath
29238
+ ])) && (isRetryableRemoval(error, evictPath) || isWindowsAccessDeniedRead2(error, [evictOwnerPath])))
29010
29239
  throw actionError;
29011
29240
  throw error;
29012
29241
  }
@@ -29022,7 +29251,7 @@ async function acquireRefreshFileLockWithClock2(options) {
29022
29251
  try {
29023
29252
  owner = await readOwner();
29024
29253
  } catch (error) {
29025
- if (windowsPrivateFiles2)
29254
+ if (windowsPrivateFiles2 && !(error instanceof DisappearedLockRecordError2))
29026
29255
  throw error;
29027
29256
  return;
29028
29257
  }
@@ -29100,7 +29329,7 @@ async function acquireRefreshFileLockWithClock2(options) {
29100
29329
  await options.onStep("renewal-marker-unavailable");
29101
29330
  }
29102
29331
  } catch (error) {
29103
- if (windowsPrivateFiles2 && error instanceof PrivateFileError2) {
29332
+ if (windowsPrivateFiles2 && error instanceof PrivateFileError2 && !isChangingLockCreate(error)) {
29104
29333
  terminalIOError = error;
29105
29334
  recordLoss("renewal-failed");
29106
29335
  shouldReschedule = false;
@@ -29146,72 +29375,90 @@ async function acquireRefreshFileLockWithClock2(options) {
29146
29375
  }
29147
29376
  return null;
29148
29377
  }
29149
- let acquired = await tryAcquire();
29378
+ let acquired = false;
29379
+ let changingCreateError;
29380
+ try {
29381
+ acquired = await tryAcquire();
29382
+ } catch (error) {
29383
+ if (!isChangingLockCreate(error))
29384
+ throw error;
29385
+ changingCreateError = error;
29386
+ }
29150
29387
  if (!acquired) {
29151
29388
  for (let attempt = 0; attempt < MAX_STEAL_ATTEMPTS; attempt++) {
29152
- acquired = await tryAcquire();
29153
- if (acquired)
29154
- break;
29155
- const observed = await readLockState();
29156
- if (observed.status === "live")
29157
- return contended();
29158
- if (observed.status === "missing")
29159
- continue;
29160
- if (options.onStep)
29161
- await options.onStep("stale-lock-observed");
29162
- try {
29163
- if (!await tryAcquireEvictionMarker()) {
29164
- await backoff();
29165
- continue;
29166
- }
29167
- } catch (evictError) {
29168
- const code2 = evictError.code;
29169
- if (code2 !== "EEXIST")
29170
- throw evictError;
29171
- const recovered = await recoverStaleEvictionMarker();
29172
- if (recovered === "fresh")
29173
- return null;
29174
- await backoff();
29175
- continue;
29176
- }
29177
29389
  try {
29178
- const confirmed = await readLockState();
29179
- if (confirmed.status === "live")
29390
+ acquired = await tryAcquire();
29391
+ if (acquired)
29392
+ break;
29393
+ const observed = await readLockState();
29394
+ if (observed.status === "live")
29180
29395
  return contended();
29181
- if (!sameStaleLock(observed.identity, confirmed))
29396
+ if (observed.status === "missing")
29182
29397
  continue;
29183
- if (!await ownsEvictionMarker())
29184
- return null;
29185
29398
  if (options.onStep)
29186
- await options.onStep("stale-lock-confirmed");
29187
- if (!await ownsEvictionMarker())
29188
- return null;
29189
- const current = await readLockState(false);
29190
- if (!sameStaleLock(observed.identity, current))
29399
+ await options.onStep("stale-lock-observed");
29400
+ try {
29401
+ if (!await tryAcquireEvictionMarker()) {
29402
+ await backoff();
29403
+ continue;
29404
+ }
29405
+ } catch (evictError) {
29406
+ const code2 = evictError.code;
29407
+ if (code2 !== "EEXIST")
29408
+ throw evictError;
29409
+ const recovered = await recoverStaleEvictionMarker();
29410
+ if (recovered === "fresh")
29411
+ return null;
29412
+ await backoff();
29191
29413
  continue;
29192
- await removeLeaseObject(lockPath);
29193
- if (!await ownsEvictionMarker())
29194
- return null;
29195
- if (options.onStep)
29196
- await options.onStep("stale-lock-removed");
29197
- acquired = await tryAcquire();
29198
- if (!acquired)
29199
- return null;
29200
- if (options.onStep)
29201
- await options.onStep("stale-lock-recreated");
29202
- if (!await ownsEvictionMarker()) {
29203
- await relinquishLockAfterMarkerLoss();
29204
- acquired = false;
29205
- return null;
29206
29414
  }
29207
- break;
29208
- } finally {
29209
- await releaseEvictionMarker();
29415
+ try {
29416
+ const confirmed = await readLockState();
29417
+ if (confirmed.status === "live")
29418
+ return contended();
29419
+ if (!sameStaleLock(observed.identity, confirmed))
29420
+ continue;
29421
+ if (!await ownsEvictionMarker())
29422
+ return null;
29423
+ if (options.onStep)
29424
+ await options.onStep("stale-lock-confirmed");
29425
+ if (!await ownsEvictionMarker())
29426
+ return null;
29427
+ const current = await readLockState(false);
29428
+ if (!sameStaleLock(observed.identity, current))
29429
+ continue;
29430
+ await removeLeaseObject(lockPath);
29431
+ if (!await ownsEvictionMarker())
29432
+ return null;
29433
+ if (options.onStep)
29434
+ await options.onStep("stale-lock-removed");
29435
+ acquired = await tryAcquire();
29436
+ if (!acquired)
29437
+ return null;
29438
+ if (options.onStep)
29439
+ await options.onStep("stale-lock-recreated");
29440
+ if (!await ownsEvictionMarker()) {
29441
+ await relinquishLockAfterMarkerLoss();
29442
+ acquired = false;
29443
+ return null;
29444
+ }
29445
+ break;
29446
+ } finally {
29447
+ await releaseEvictionMarker();
29448
+ }
29449
+ } catch (error) {
29450
+ if (!isChangingLockCreate(error))
29451
+ throw error;
29452
+ changingCreateError ??= error;
29453
+ await backoff();
29210
29454
  }
29211
29455
  }
29212
29456
  }
29213
- if (!acquired)
29457
+ if (!acquired) {
29458
+ if (changingCreateError)
29459
+ throw changingCreateError;
29214
29460
  return null;
29461
+ }
29215
29462
  scheduleRenewal();
29216
29463
  return {
29217
29464
  ownerId,
@@ -29249,6 +29496,7 @@ async function acquireRefreshFileLockWithClock2(options) {
29249
29496
  const deadline = performance.now() + EVICT_TTL + 1e3;
29250
29497
  let delayMs = 5;
29251
29498
  let removalError;
29499
+ let changingRecordError;
29252
29500
  for (; ; ) {
29253
29501
  try {
29254
29502
  let removalConfirmed = false;
@@ -29274,6 +29522,7 @@ async function acquireRefreshFileLockWithClock2(options) {
29274
29522
  await removeLeaseObject(lockPath);
29275
29523
  removalConfirmed = true;
29276
29524
  }, deadline);
29525
+ changingRecordError = void 0;
29277
29526
  if (markerAcquired) {
29278
29527
  if (windowsPrivateFiles2 && !removalConfirmed)
29279
29528
  throw new PrivateFileError2(lockPath, "release-not-confirmed", {
@@ -29286,23 +29535,32 @@ async function acquireRefreshFileLockWithClock2(options) {
29286
29535
  return;
29287
29536
  await recoverStaleEvictionMarker(deadline);
29288
29537
  } catch (error) {
29289
- if (!isRetryableRemoval(error, lockPath)) {
29538
+ const changingRecord = windowsPrivateFiles2 && (isChangingLockCreate(error) || isWindowsAccessDeniedRead2(error, [
29539
+ lockPath,
29540
+ legacyOwnerPath,
29541
+ evictPath,
29542
+ evictOwnerPath
29543
+ ]));
29544
+ if (!isRetryableRemoval(error, lockPath) && !changingRecord) {
29290
29545
  if (windowsPrivateFiles2)
29291
29546
  throw error;
29292
29547
  return;
29293
29548
  }
29294
- removalError ??= error;
29549
+ if (changingRecord)
29550
+ changingRecordError ??= error;
29551
+ else
29552
+ removalError ??= error;
29295
29553
  }
29296
29554
  const remainingMs = deadline - performance.now();
29297
29555
  if (remainingMs <= 0)
29298
29556
  break;
29299
- await new Promise((resolve22) => setTimeout(resolve22, Math.min(delayMs, remainingMs)));
29557
+ await new Promise((resolve24) => setTimeout(resolve24, Math.min(delayMs, remainingMs)));
29300
29558
  if (windowsPrivateFiles2 && performance.now() >= deadline)
29301
29559
  break;
29302
29560
  delayMs = Math.min(delayMs * 2, 50);
29303
29561
  }
29304
29562
  if (windowsPrivateFiles2)
29305
- throw removalError ?? new PrivateFileError2(lockPath, "release-not-confirmed", {
29563
+ throw changingRecordError ?? removalError ?? new PrivateFileError2(lockPath, "release-not-confirmed", {
29306
29564
  code: "ETIMEDOUT"
29307
29565
  });
29308
29566
  }
@@ -29442,6 +29700,10 @@ function classifyEnrollmentError2(error) {
29442
29700
  disposition: error.action === "retry" ? "retry" : "terminal"
29443
29701
  };
29444
29702
  }
29703
+ function validEnrollmentDisplayName2(displayName) {
29704
+ const length = Array.from(displayName).length;
29705
+ return length >= 1 && length <= 40 && !/[\p{Cc}\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069\u200b-\u200d\u2060\ufeff]/u.test(displayName);
29706
+ }
29445
29707
  function connectClaustrumEnrollmentClient2(options) {
29446
29708
  return ClaustrumWireClient2.connect(options);
29447
29709
  }
@@ -29457,7 +29719,7 @@ function hostEnrollmentPaths2(input) {
29457
29719
  const override = input.override?.trim();
29458
29720
  if (override && !isAbsolute4(override) && !input.cwd)
29459
29721
  throw new ClaustrumConsumerError2("invalid-state", "A relative Claustrum enrollment override needs a base directory");
29460
- const tokenPath = override ? isAbsolute4(override) ? override : resolve19(input.cwd, override) : join18(input.stateDir, `${input.host}-enrollment.json`);
29722
+ const tokenPath = override ? isAbsolute4(override) ? override : resolve21(input.cwd, override) : join18(input.stateDir, `${input.host}-enrollment.json`);
29461
29723
  return getClaustrumEnrollmentPaths2(tokenPath);
29462
29724
  }
29463
29725
  function isRecord10(value) {
@@ -29818,15 +30080,19 @@ var ClaustrumEnrollmentManager2 = class {
29818
30080
  #client;
29819
30081
  #paths;
29820
30082
  #proposedName;
30083
+ #displayName;
29821
30084
  #now;
29822
30085
  #mintSecret;
29823
30086
  #writeTokenFile;
29824
30087
  #ancestorOptions;
29825
30088
  constructor(options) {
30089
+ if (options.displayName !== void 0 && !validEnrollmentDisplayName2(options.displayName))
30090
+ throw new ClaustrumConsumerError2("invalid-state", "invalid Claustrum enrollment display name");
29826
30091
  this.#ancestorOptions = options.ancestorOptions ?? {};
29827
30092
  this.#client = options.client;
29828
30093
  this.#paths = options.paths;
29829
30094
  this.#proposedName = options.proposedName;
30095
+ this.#displayName = options.displayName;
29830
30096
  this.#now = options.now ?? Date.now;
29831
30097
  this.#mintSecret = options.mintSecret ?? (() => randomBytes3(32).toString("hex"));
29832
30098
  this.#writeTokenFile = options.writeTokenFile ?? writeEnrollmentTokenFile2;
@@ -29916,10 +30182,23 @@ var ClaustrumEnrollmentManager2 = class {
29916
30182
  if (!state.requestId) {
29917
30183
  try {
29918
30184
  const requestSecretHash = createHash12("sha256").update(Buffer.from(state.requestSecret, "hex")).digest("hex");
29919
- const proposed = await this.#client.enrollPropose({
30185
+ const proposal = {
29920
30186
  name: state.proposedName,
29921
30187
  requestSecretHash
29922
- });
30188
+ };
30189
+ let proposed;
30190
+ try {
30191
+ proposed = await this.#client.enrollPropose({
30192
+ ...proposal,
30193
+ ...this.#displayName !== void 0 && {
30194
+ displayName: this.#displayName
30195
+ }
30196
+ });
30197
+ } catch (error) {
30198
+ if (this.#displayName === void 0 || !(error instanceof ClaustrumCredentialError9) || error.code !== "invalid_params")
30199
+ throw error;
30200
+ proposed = await this.#client.enrollPropose(proposal);
30201
+ }
29923
30202
  state = {
29924
30203
  ...state,
29925
30204
  requestId: proposed.requestId,
@@ -30090,7 +30369,7 @@ var ByteTail = class {
30090
30369
  };
30091
30370
  var defaultCommandRunner = {
30092
30371
  run(file, args, options = {}) {
30093
- return new Promise((resolve22) => {
30372
+ return new Promise((resolve24) => {
30094
30373
  const started = performance.now();
30095
30374
  const timeoutMs = options.timeoutMs ?? 15e3;
30096
30375
  const stderr = new ByteTail();
@@ -30108,7 +30387,7 @@ var defaultCommandRunner = {
30108
30387
  stdio: ["ignore", "pipe", "pipe"]
30109
30388
  });
30110
30389
  } catch {
30111
- resolve22({
30390
+ resolve24({
30112
30391
  exitCode: 1,
30113
30392
  stdout: "",
30114
30393
  stderr: "",
@@ -30143,7 +30422,7 @@ var defaultCommandRunner = {
30143
30422
  settled = true;
30144
30423
  if (timer)
30145
30424
  clearTimeout(timer);
30146
- resolve22({
30425
+ resolve24({
30147
30426
  exitCode: spawnError ? 1 : outputExceeded ? 1 : code2 ?? 1,
30148
30427
  stdout: Buffer.concat(stdout, stdoutLength).toString("utf8"),
30149
30428
  stderr: stderr.toString(),
@@ -30755,7 +31034,7 @@ function approveCommand(requestId, name) {
30755
31034
  async function connectSetupHost(plugin, host, io, terminal, fence) {
30756
31035
  if (hasVaultHost2())
30757
31036
  throw new Error(VAULT_HOST_CONNECT_REFUSAL2);
30758
- const { name, paths: input } = plugin.vault.hosts[host];
31037
+ const { name, displayName, paths: input } = plugin.vault.hosts[host];
30759
31038
  const paths = hostEnrollmentPaths2(input);
30760
31039
  await fence();
30761
31040
  const client = await (io.connect ?? connectClaustrumEnrollmentClient2)({
@@ -30769,6 +31048,7 @@ async function connectSetupHost(plugin, host, io, terminal, fence) {
30769
31048
  try {
30770
31049
  const manager = new ClaustrumEnrollmentManager2({
30771
31050
  proposedName: name,
31051
+ displayName,
30772
31052
  paths,
30773
31053
  // Each tick of the wait below checks the fence once, just before
30774
31054
  // reconcile proposes or polls. Checking again inside every vault call
@@ -31515,7 +31795,7 @@ async function writeNativeSlot(host, slot, context, expectedAuthority = "local")
31515
31795
  beforeRename: async () => {
31516
31796
  await assertSetupHostsStopped();
31517
31797
  const claustrum = await loadCommonAuthClaustrum();
31518
- const stateDir = host === "opencode" ? openCodeVaultDir(resolve20(accountFileForVault())) : getPiAntigravityVaultDir();
31798
+ const stateDir = host === "opencode" ? openCodeVaultDir(resolve22(accountFileForVault())) : getPiAntigravityVaultDir();
31519
31799
  if (await claustrum.vaultAuthority(
31520
31800
  claustrum.hostEnrollmentPaths({ stateDir, host }),
31521
31801
  `antigravity-auth-${host}`
@@ -31549,17 +31829,19 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
31549
31829
  const hosts = {
31550
31830
  opencode: {
31551
31831
  name: OPENCODE_VAULT_ENROLLMENT_NAME,
31832
+ displayName: "Antigravity sign-in for OpenCode",
31552
31833
  // Read at each use: a real run settles the vault folder in
31553
31834
  // `beforeSignIn`, which may move it after this plugin is built.
31554
31835
  paths: {
31555
31836
  get stateDir() {
31556
- return openCodeVaultDir(resolve20(accountFileForVault()));
31837
+ return openCodeVaultDir(resolve22(accountFileForVault()));
31557
31838
  },
31558
31839
  host: "opencode"
31559
31840
  }
31560
31841
  },
31561
31842
  pi: {
31562
31843
  name: "antigravity-auth-pi",
31844
+ displayName: "Antigravity sign-in for Pi",
31563
31845
  paths: { stateDir: piDir, host: "pi" }
31564
31846
  }
31565
31847
  };
@@ -31570,7 +31852,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
31570
31852
  const assertLocal = async (host, context) => {
31571
31853
  if (host === "opencode")
31572
31854
  return assertLocalOpenCodeLogin(
31573
- resolve20(accountFileForVault()),
31855
+ resolve22(accountFileForVault()),
31574
31856
  context.opencodeGeneration
31575
31857
  );
31576
31858
  if (await authority(host) !== "local")
@@ -32230,7 +32512,7 @@ async function runCliProcess(argv, deps) {
32230
32512
  ...deps,
32231
32513
  prepareVaultFolder: deps.prepareVaultFolder ?? (async (options) => {
32232
32514
  const folder = await prepareVaultFolder({
32233
- accountFile: resolve21(accountFileForVault()),
32515
+ accountFile: resolve23(accountFileForVault()),
32234
32516
  ...options
32235
32517
  });
32236
32518
  if (folder.refusal) throw folder.refusal;
@@ -32276,11 +32558,11 @@ function createDefaultCliDependencies() {
32276
32558
  );
32277
32559
  if (host !== "pi")
32278
32560
  await assertLocalOpenCodeLogin(
32279
- resolve21(accountFileForVault()),
32561
+ resolve23(accountFileForVault()),
32280
32562
  context?.opencodeGeneration
32281
32563
  );
32282
32564
  const repository = host === "pi" ? void 0 : await prepareCliLoginStore(
32283
- resolve21(getStoragePath()),
32565
+ resolve23(getStoragePath()),
32284
32566
  context?.opencodeGeneration
32285
32567
  );
32286
32568
  try {
@@ -32296,7 +32578,7 @@ function createDefaultCliDependencies() {
32296
32578
  }
32297
32579
  if (host === "opencode") await assertSetupHostsStopped();
32298
32580
  await assertLocalOpenCodeLogin(
32299
- resolve21(accountFileForVault()),
32581
+ resolve23(accountFileForVault()),
32300
32582
  context?.opencodeGeneration
32301
32583
  );
32302
32584
  await persistCliStoreLogin(
@@ -32316,7 +32598,7 @@ function createDefaultCliDependencies() {
32316
32598
  };
32317
32599
  }
32318
32600
  async function prepareCliLoginStore(legacyPath, generation) {
32319
- await assertLocalOpenCodeLogin(resolve21(accountFileForVault()), generation);
32601
+ await assertLocalOpenCodeLogin(resolve23(accountFileForVault()), generation);
32320
32602
  const modules = await loadCommonAuthStoreModules();
32321
32603
  const options = {
32322
32604
  legacyPath,
@@ -32461,7 +32743,7 @@ async function readAccountStore(legacyPath) {
32461
32743
  function createDefaultAccountStoreOperations() {
32462
32744
  const offline = { processesStopped: true };
32463
32745
  return {
32464
- legacyPath: () => resolve21(
32746
+ legacyPath: () => resolve23(
32465
32747
  decidedAccountStoreAnchor(runtimeLayoutLocation()) ? getStoragePath() : discoveredAccountFile()
32466
32748
  ),
32467
32749
  migrate: async (legacyPath) => createAccountMigrationFactory(await loadCommonAuthStoreModules())({
@@ -32492,7 +32774,7 @@ function createDefaultAccountStoreOperations() {
32492
32774
  };
32493
32775
  }
32494
32776
  function samePath(left, right) {
32495
- return process.platform === "win32" ? resolve21(left).toLowerCase() === resolve21(right).toLowerCase() : resolve21(left) === resolve21(right);
32777
+ return process.platform === "win32" ? resolve23(left).toLowerCase() === resolve23(right).toLowerCase() : resolve23(left) === resolve23(right);
32496
32778
  }
32497
32779
  function isCliEntry() {
32498
32780
  if (import.meta.main !== void 0) return import.meta.main;