@cortexkit/opencode-antigravity-auth 3.0.30 → 3.0.32

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 (76) hide show
  1. package/dist/cli.js +104 -81
  2. package/dist/cli.js.map +3 -3
  3. package/dist/cli.meta.json +24 -19
  4. package/dist/index.js +171 -140
  5. package/dist/index.js.map +3 -3
  6. package/dist/index.meta.json +28 -23
  7. package/dist/server.js +171 -140
  8. package/dist/server.js.map +3 -3
  9. package/dist/server.meta.json +1 -1
  10. package/dist/src/common-auth-embedded/claustrum/roster.d.ts +2 -0
  11. package/dist/src/common-auth-embedded/claustrum/roster.js +32 -8
  12. package/dist/src/common-auth-embedded/fs/file-read-cache.js +10 -5
  13. package/dist/src/common-auth-embedded/limits/axes.d.ts +7 -1
  14. package/dist/src/common-auth-embedded/limits/decide.d.ts +5 -0
  15. package/dist/src/common-auth-embedded/limits/families.d.ts +4 -2
  16. package/dist/src/common-auth-embedded/limits/marker.d.ts +5 -0
  17. package/dist/src/common-auth-embedded/limits/request-history.d.ts +3 -1
  18. package/dist/src/common-auth-embedded/opencode2/install.d.ts +2 -1
  19. package/dist/src/common-auth-embedded/opencode2/install.js +58 -9
  20. package/dist/src/common-auth-embedded/opencode2/types.d.ts +19 -3
  21. package/dist/src/common-auth-embedded/routing-accessor/index.d.ts +30 -5
  22. package/dist/src/common-auth-embedded/routing-accessor/index.js +121 -33
  23. package/dist/src/common-auth-embedded/setup/enroll.js +7 -1
  24. package/dist/src/common-auth-embedded/source-output.json +63 -63
  25. package/dist/src/common-auth-embedded/store/index.d.ts +1 -1
  26. package/dist/src/common-auth-embedded/store/limits-namespace.d.ts +7 -1
  27. package/dist/src/common-auth-embedded/store/limits-namespace.js +19 -7
  28. package/dist/src/common-auth-embedded/store/pool.d.ts +1 -1
  29. package/dist/src/common-auth-embedded/store/pool.js +1 -1
  30. package/dist/src/plugin/__fixtures__/release-model-ids.d.ts.map +1 -1
  31. package/dist/src/plugin/__fixtures__/release-model-ids.js +0 -1
  32. package/dist/src/plugin/__fixtures__/release-model-ids.js.map +1 -1
  33. package/dist/src/plugin/__fixtures__/verified-store.js +2 -2
  34. package/dist/src/plugin/account-access.js +1 -1
  35. package/dist/src/plugin/request.d.ts.map +1 -1
  36. package/dist/src/plugin/request.js +3 -2
  37. package/dist/src/plugin/request.js.map +1 -1
  38. package/dist/src/plugin/shared/request-services.d.ts +1 -1
  39. package/dist/src/plugin/shared/request-services.js +1 -1
  40. package/dist/tui-build-map.json +1 -1
  41. package/dist/tui-ga-build-map.json +1 -1
  42. package/dist/types/src/common-auth-embedded/claustrum/roster.d.ts +2 -0
  43. package/dist/types/src/common-auth-embedded/limits/axes.d.ts +7 -1
  44. package/dist/types/src/common-auth-embedded/limits/decide.d.ts +5 -0
  45. package/dist/types/src/common-auth-embedded/limits/families.d.ts +4 -2
  46. package/dist/types/src/common-auth-embedded/limits/marker.d.ts +5 -0
  47. package/dist/types/src/common-auth-embedded/limits/request-history.d.ts +3 -1
  48. package/dist/types/src/common-auth-embedded/opencode2/install.d.ts +2 -1
  49. package/dist/types/src/common-auth-embedded/opencode2/types.d.ts +19 -3
  50. package/dist/types/src/common-auth-embedded/routing-accessor/index.d.ts +30 -5
  51. package/dist/types/src/common-auth-embedded/store/index.d.ts +1 -1
  52. package/dist/types/src/common-auth-embedded/store/limits-namespace.d.ts +7 -1
  53. package/dist/types/src/common-auth-embedded/store/pool.d.ts +1 -1
  54. package/dist/types/src/plugin/request.d.ts.map +1 -1
  55. package/dist/types/src/plugin/shared/request-services.d.ts +1 -1
  56. package/package.json +3 -3
  57. package/src/common-auth-embedded/claustrum/roster.d.ts +2 -0
  58. package/src/common-auth-embedded/claustrum/roster.js +32 -8
  59. package/src/common-auth-embedded/fs/file-read-cache.js +10 -5
  60. package/src/common-auth-embedded/limits/axes.d.ts +7 -1
  61. package/src/common-auth-embedded/limits/decide.d.ts +5 -0
  62. package/src/common-auth-embedded/limits/families.d.ts +4 -2
  63. package/src/common-auth-embedded/limits/marker.d.ts +5 -0
  64. package/src/common-auth-embedded/limits/request-history.d.ts +3 -1
  65. package/src/common-auth-embedded/opencode2/install.d.ts +2 -1
  66. package/src/common-auth-embedded/opencode2/install.js +58 -9
  67. package/src/common-auth-embedded/opencode2/types.d.ts +19 -3
  68. package/src/common-auth-embedded/routing-accessor/index.d.ts +30 -5
  69. package/src/common-auth-embedded/routing-accessor/index.js +121 -33
  70. package/src/common-auth-embedded/setup/enroll.js +7 -1
  71. package/src/common-auth-embedded/source-output.json +63 -63
  72. package/src/common-auth-embedded/store/index.d.ts +1 -1
  73. package/src/common-auth-embedded/store/limits-namespace.d.ts +7 -1
  74. package/src/common-auth-embedded/store/limits-namespace.js +19 -7
  75. package/src/common-auth-embedded/store/pool.d.ts +1 -1
  76. package/src/common-auth-embedded/store/pool.js +1 -1
package/dist/cli.js CHANGED
@@ -1629,10 +1629,10 @@ async function privateDirectory(path2) {
1629
1629
  if (errno(error) !== "EEXIST")
1630
1630
  throw error;
1631
1631
  }
1632
- const stat14 = await lstat2(path2);
1633
- if (!stat14.isDirectory() || stat14.isSymbolicLink())
1632
+ const stat16 = await lstat2(path2);
1633
+ if (!stat16.isDirectory() || stat16.isSymbolicLink())
1634
1634
  throw new AccountMigrationError("successor directory is not a regular directory");
1635
- privateMode(stat14.mode, 448);
1635
+ privateMode(stat16.mode, 448);
1636
1636
  if (windowsPrivateFiles)
1637
1637
  await verifySafeDirectory(path2);
1638
1638
  if (!sameFilesystemPath(await realpath(path2), path2))
@@ -5866,17 +5866,6 @@ var init_model_registry = __esm({
5866
5866
  high: { thinkingLevel: "high" }
5867
5867
  }
5868
5868
  }),
5869
- "antigravity-gemini-3.5-flash": defineModel("antigravity-gemini-3.5-flash", {
5870
- name: "Gemini 3.5 Flash (Antigravity)",
5871
- reasoning: true,
5872
- limit: { context: 1048576, output: 65536 },
5873
- modalities: DEFAULT_MODALITIES,
5874
- variants: {
5875
- low: { thinkingLevel: "low" },
5876
- medium: { thinkingLevel: "medium" },
5877
- high: { thinkingLevel: "high" }
5878
- }
5879
- }),
5880
5869
  "antigravity-gemini-3.1-flash-image": defineModel("antigravity-gemini-3.1-flash-image", {
5881
5870
  name: "Gemini 3.1 Flash Image (Antigravity)",
5882
5871
  reasoning: false,
@@ -5932,7 +5921,6 @@ var init_model_registry = __esm({
5932
5921
  "gemini-3-flash-low": "gemini-3-flash",
5933
5922
  "gemini-3-flash-medium": "gemini-3-flash",
5934
5923
  "gemini-3-flash-high": "gemini-3-flash",
5935
- "gemini-3.5-flash-low": "gemini-3.5-flash",
5936
5924
  "gemini-3.5-flash-medium": "gemini-3.5-flash",
5937
5925
  "gemini-3.5-flash-high": "gemini-3.5-flash",
5938
5926
  "gemini-3.6-flash-low": "gemini-3.6-flash",
@@ -5968,9 +5956,6 @@ var init_model_registry = __esm({
5968
5956
  "gemini-3.1-pro-low": "gemini",
5969
5957
  "gemini-3.1-pro-high": "gemini",
5970
5958
  "gemini-3-flash": "gemini",
5971
- "gemini-3-flash-agent": "gemini",
5972
- "gemini-3.5-flash-low": "gemini",
5973
- "gemini-3.5-flash-extra-low": "gemini",
5974
5959
  "gemini-3.6-flash-low": "gemini",
5975
5960
  "gemini-3.6-flash-medium": "gemini",
5976
5961
  "gemini-3.6-flash-high": "gemini",
@@ -5990,7 +5975,6 @@ var init_model_registry = __esm({
5990
5975
  ANTIGRAVITY_OPENCODE_MODEL_IDS = [
5991
5976
  "antigravity-gemini-4-argon",
5992
5977
  "antigravity-gemini-3.8-flash",
5993
- "antigravity-gemini-3.5-flash",
5994
5978
  "antigravity-gemini-3.1-flash-image",
5995
5979
  "antigravity-claude-sonnet-5-5",
5996
5980
  "antigravity-claude-opus-5-5",
@@ -10984,7 +10968,7 @@ var init_attribution = __esm({
10984
10968
  });
10985
10969
 
10986
10970
  // ../core/dist/common-auth-embedded/store/limits-namespace.js
10987
- async function updatePoolLimitsNamespace(rt, mutator) {
10971
+ async function updatePoolLimitsNamespace(rt, mutator, options = {}) {
10988
10972
  assertLimitsWriteAllowed();
10989
10973
  const { ctx } = rt;
10990
10974
  await runOperation(ctx, "updateLimitsNamespace", void 0, void 0, async (locks, progress) => {
@@ -11004,13 +10988,21 @@ async function updatePoolLimitsNamespace(rt, mutator) {
11004
10988
  operation: "updateLimitsNamespace",
11005
10989
  rowId: void 0
11006
10990
  };
11007
- await writeJsonAtomic2(ctx.configPath, config, {
11008
- beforeRename: async () => {
11009
- await ctx.onStep?.("before-config-write", info);
11010
- await locks.assertAll();
11011
- }
11012
- });
10991
+ try {
10992
+ await writeJsonAtomic2(ctx.configPath, config, {
10993
+ beforeRename: async () => {
10994
+ await ctx.onStep?.("before-config-write", info);
10995
+ await locks.assertAll();
10996
+ options.beforePublish?.();
10997
+ }
10998
+ });
10999
+ } catch (error) {
11000
+ if (error && typeof error === "object" && "published" in error && error.published === true)
11001
+ options.onPublished?.();
11002
+ throw error;
11003
+ }
11013
11004
  progress.writes++;
11005
+ options.onPublished?.();
11014
11006
  await ctx.onStep?.("after-config-write", info);
11015
11007
  });
11016
11008
  }
@@ -13355,11 +13347,11 @@ var init_refresh = __esm({
13355
13347
  });
13356
13348
 
13357
13349
  // ../core/dist/common-auth-embedded/fs/file-read-cache.js
13358
- import { lstat as lstat4 } from "node:fs/promises";
13350
+ import { lstat as lstat4, stat as stat4 } from "node:fs/promises";
13359
13351
  import { resolve as resolve5 } from "node:path";
13360
- async function identity(path2) {
13352
+ async function identity(path2, followSymlinks) {
13361
13353
  try {
13362
- const metadata = await lstat4(path2);
13354
+ const metadata = await (followSymlinks ? stat4(path2) : lstat4(path2));
13363
13355
  return metadata.isFile() ? metadata : void 0;
13364
13356
  } catch (error) {
13365
13357
  return error.code === "ENOENT" ? "absent" : void 0;
@@ -13375,11 +13367,15 @@ var init_file_read_cache = __esm({
13375
13367
  "../core/dist/common-auth-embedded/fs/file-read-cache.js"() {
13376
13368
  "use strict";
13377
13369
  FileReadCache = class {
13370
+ #followSymlinks;
13378
13371
  #entries = /* @__PURE__ */ new Map();
13372
+ constructor(options = {}) {
13373
+ this.#followSymlinks = options.followSymlinks ?? false;
13374
+ }
13379
13375
  async read(paths, read, validateHit) {
13380
13376
  const resolvedPaths = paths.map((path2) => resolve5(path2));
13381
13377
  const key = JSON.stringify(resolvedPaths);
13382
- const probed = await Promise.all(resolvedPaths.map(identity));
13378
+ const probed = await Promise.all(resolvedPaths.map((path2) => identity(path2, this.#followSymlinks)));
13383
13379
  const identities = probed.every((entry) => entry !== void 0) ? probed : void 0;
13384
13380
  const cached = this.#entries.get(key);
13385
13381
  if (identities && cached && identities.every((entry, index) => {
@@ -13616,7 +13612,7 @@ function openPoolStore(options) {
13616
13612
  reorder: (ids, callOptions) => reorderRows(rt, ids, callOptions),
13617
13613
  readSettings: () => readPoolSettings(rt),
13618
13614
  updateSettings: (mutator, callOptions) => updatePoolSettings(rt, mutator, callOptions),
13619
- updateLimitsNamespace: (mutator) => updatePoolLimitsNamespace(rt, mutator),
13615
+ updateLimitsNamespace: (mutator, options2) => updatePoolLimitsNamespace(rt, mutator, options2),
13620
13616
  recordIdentity: (id, identity3, attribution, callOptions) => recordRowIdentity(rt, id, identity3, attribution, callOptions),
13621
13617
  refresh: (id, provider2, callOptions) => refreshRow(rt, id, provider2, callOptions),
13622
13618
  recordQuota: record3,
@@ -17127,7 +17123,7 @@ var init_any_signal = __esm({
17127
17123
  // ../core/dist/common-auth-embedded/claustrum/enrollment.js
17128
17124
  import { createHash as createHash5, randomBytes as randomBytes2, randomUUID as randomUUID10 } from "node:crypto";
17129
17125
  import { constants as fsConstants } from "node:fs";
17130
- import { chmod as chmod2, mkdir as mkdir8, open as open6, readFile as readFile6, realpath as realpath3, rename as rename7, stat as stat4, unlink as unlink6 } from "node:fs/promises";
17126
+ 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";
17131
17127
  import { basename as basename3, dirname as dirname9, extname, isAbsolute as isAbsolute2, join as join7, resolve as resolve7 } from "node:path";
17132
17128
  import { ClaustrumCredentialError as ClaustrumCredentialError2, ClaustrumClient as ClaustrumWireClient, writeEnrollmentTokenFile } from "@cortexkit/claustrum-client";
17133
17129
  function classifyEnrollmentError(error) {
@@ -17347,7 +17343,7 @@ async function refuseWritableAncestor(parent, options = {}) {
17347
17343
  }
17348
17344
  let privateGroup;
17349
17345
  for (; ; ) {
17350
- const metadata = await stat4(component).catch(() => void 0);
17346
+ const metadata = await stat5(component).catch(() => void 0);
17351
17347
  if (metadata && (metadata.mode & 18) !== 0 && (metadata.mode & 512) === 0) {
17352
17348
  if (privateGroup === void 0) {
17353
17349
  privateGroup = gid !== void 0 && await isPrivateGroup(uid, gid, options);
@@ -17376,7 +17372,7 @@ async function ensureClaustrumPrivateDirectory(directory, options = {}, what = "
17376
17372
  return;
17377
17373
  }
17378
17374
  await mkdir8(directory, { recursive: true, mode: 448 });
17379
- const metadata = await stat4(directory);
17375
+ const metadata = await stat5(directory);
17380
17376
  const uid = process.geteuid?.();
17381
17377
  if (uid !== void 0 && metadata.uid !== uid) {
17382
17378
  throw new ClaustrumConsumerError("unsafe-file", `Claustrum ${what} must be owned by the current user`);
@@ -18857,7 +18853,7 @@ var init_interlock = __esm({
18857
18853
 
18858
18854
  // ../core/dist/common-auth-embedded/claustrum/roster.js
18859
18855
  import { createHash as createHash6 } from "node:crypto";
18860
- import { stat as stat5 } from "node:fs/promises";
18856
+ import { stat as stat6 } from "node:fs/promises";
18861
18857
  import { resolve as resolve8 } from "node:path";
18862
18858
  function vaultRosterSeed(roster) {
18863
18859
  return {
@@ -19088,6 +19084,12 @@ function decodedVaultRoster(roster) {
19088
19084
  return decodeRoster(JSON.parse(JSON.stringify(roster)));
19089
19085
  }
19090
19086
  async function readVaultRoster(path2) {
19087
+ if (windowsPrivateFiles)
19088
+ return readFreshVaultRoster(path2);
19089
+ const roster = await rosterReadCache.read([path2], ([resolvedPath = path2]) => readFreshVaultRoster(resolvedPath));
19090
+ return structuredClone(roster);
19091
+ }
19092
+ async function readFreshVaultRoster(path2) {
19091
19093
  let text2;
19092
19094
  try {
19093
19095
  text2 = await readPrivateText(path2, windowsPrivateFiles);
@@ -19106,19 +19108,26 @@ async function readVaultRoster(path2) {
19106
19108
  }
19107
19109
  async function mutateVaultRoster(path2, change, options = {}) {
19108
19110
  return withLock(path2, { ...WRITE_LOCK, signal: options.signal }, async (lock) => {
19109
- const current = await readVaultRoster(path2);
19111
+ const current = await readFreshVaultRoster(path2);
19110
19112
  const { next, result } = await change(current, {
19111
19113
  assertOwned: () => lock.assertOwned()
19112
19114
  });
19113
19115
  if (next) {
19114
19116
  await lock.assertOwned();
19115
- await writeJsonAtomic2(path2, next, {
19116
- beforeRename: async () => {
19117
- await options.beforePublish?.();
19118
- options.signal?.throwIfAborted();
19119
- await lock.assertOwned();
19120
- }
19121
- });
19117
+ try {
19118
+ await writeJsonAtomic2(path2, next, {
19119
+ beforeRename: async () => {
19120
+ await options.beforePublish?.();
19121
+ options.signal?.throwIfAborted();
19122
+ await lock.assertOwned();
19123
+ }
19124
+ });
19125
+ } catch (error) {
19126
+ if (error && typeof error === "object" && "published" in error && error.published === true)
19127
+ options.onPublished?.();
19128
+ throw error;
19129
+ }
19130
+ options.onPublished?.();
19122
19131
  }
19123
19132
  return result;
19124
19133
  });
@@ -19266,7 +19275,7 @@ function isVaultRosterLockRefusal(path2, error) {
19266
19275
  }
19267
19276
  async function fileStamp(path2) {
19268
19277
  try {
19269
- const { dev, ino, size, mtimeMs } = await stat5(path2);
19278
+ const { dev, ino, size, mtimeMs } = await stat6(path2);
19270
19279
  return { dev, ino, size, mtimeMs };
19271
19280
  } catch {
19272
19281
  return void 0;
@@ -19406,10 +19415,11 @@ function resolveVaultPrimary(input) {
19406
19415
  ...previous && previous.accountIdentity !== identity3 && { replaced: previous }
19407
19416
  };
19408
19417
  }
19409
- var DEFAULT_ROUTE_PREFIX, SKIPPED_REASONS, WRITE_LOCK, DISCOVERY_LEASE, pendingDiscoveries, UNLOCKED_READ_ATTEMPTS;
19418
+ var DEFAULT_ROUTE_PREFIX, SKIPPED_REASONS, rosterReadCache, WRITE_LOCK, DISCOVERY_LEASE, pendingDiscoveries, UNLOCKED_READ_ATTEMPTS;
19410
19419
  var init_roster = __esm({
19411
19420
  "../core/dist/common-auth-embedded/claustrum/roster.js"() {
19412
19421
  "use strict";
19422
+ init_file_read_cache();
19413
19423
  init_fs();
19414
19424
  init_private_files();
19415
19425
  init_quota();
@@ -19424,6 +19434,9 @@ var init_roster = __esm({
19424
19434
  "blank account identity",
19425
19435
  "empty state"
19426
19436
  ]);
19437
+ rosterReadCache = new FileReadCache({
19438
+ followSymlinks: true
19439
+ });
19427
19440
  WRITE_LOCK = {
19428
19441
  name: "claustrum-roster-write",
19429
19442
  ttlMs: 1e4,
@@ -20479,7 +20492,7 @@ var init_consumer = __esm({
20479
20492
  // ../core/dist/common-auth-embedded/claustrum/hub.js
20480
20493
  import { createHash as createHash7 } from "node:crypto";
20481
20494
  import { channel as channel2 } from "node:diagnostics_channel";
20482
- import { readdir, stat as stat6 } from "node:fs/promises";
20495
+ import { readdir, stat as stat7 } from "node:fs/promises";
20483
20496
  import { dirname as dirname10, join as join8, resolve as resolve10 } from "node:path";
20484
20497
  function canonicalJson3(value, path2 = /* @__PURE__ */ new Set()) {
20485
20498
  if (value === null)
@@ -21220,7 +21233,7 @@ var init_hub = __esm({
21220
21233
  let newest;
21221
21234
  for (const path2 of candidates) {
21222
21235
  try {
21223
- const modified = (await stat6(path2)).mtimeMs;
21236
+ const modified = (await stat7(path2)).mtimeMs;
21224
21237
  const roster = await readVaultRoster(path2);
21225
21238
  if (roster && (!newest || modified > newest.modified))
21226
21239
  newest = { modified, roster };
@@ -21587,7 +21600,7 @@ var init_claustrum = __esm({
21587
21600
 
21588
21601
  // ../core/dist/common-auth-embedded/pi-slot/lock.js
21589
21602
  import { rmdirSync, statSync as statSync2, utimesSync } from "node:fs";
21590
- import { mkdir as mkdir9, rmdir, stat as stat7, utimes } from "node:fs/promises";
21603
+ import { mkdir as mkdir9, rmdir, stat as stat8, utimes } from "node:fs/promises";
21591
21604
  function sameDirectory(observed, identity3) {
21592
21605
  return observed.dev === identity3.dev && observed.ino === identity3.ino;
21593
21606
  }
@@ -21615,7 +21628,7 @@ async function acquire(path2, stale) {
21615
21628
  throw held();
21616
21629
  let mtime;
21617
21630
  try {
21618
- mtime = (await stat7(path2)).mtime.getTime();
21631
+ mtime = (await stat8(path2)).mtime.getTime();
21619
21632
  } catch (error2) {
21620
21633
  if (errorCode(error2) === "ENOENT")
21621
21634
  return acquire(path2, 0);
@@ -21628,7 +21641,7 @@ async function acquire(path2, stale) {
21628
21641
  }
21629
21642
  let created;
21630
21643
  try {
21631
- const st = await stat7(path2);
21644
+ const st = await stat8(path2);
21632
21645
  created = { dev: st.dev, ino: st.ino };
21633
21646
  } catch {
21634
21647
  created = void 0;
@@ -21638,14 +21651,14 @@ async function acquire(path2, stale) {
21638
21651
  const probe = new Date(Math.ceil(Date.now() / 1e3) * 1e3 + 5);
21639
21652
  await utimes(path2, probe, probe);
21640
21653
  }
21641
- const observed = await stat7(path2);
21654
+ const observed = await stat8(path2);
21642
21655
  const mtime = observed.mtime.getTime();
21643
21656
  precision ??= mtime % 1e3 === 0 ? "s" : "ms";
21644
21657
  return { dev: observed.dev, ino: observed.ino, mtime };
21645
21658
  } catch (error) {
21646
21659
  try {
21647
21660
  if (created) {
21648
- const current = await stat7(path2).catch(() => void 0);
21661
+ const current = await stat8(path2).catch(() => void 0);
21649
21662
  if (current && current.dev === created.dev && current.ino === created.ino)
21650
21663
  await remove(path2).catch(() => {
21651
21664
  });
@@ -21745,7 +21758,7 @@ async function acquirePiLock(authPath, onCompromised, onRenew) {
21745
21758
  }
21746
21759
  let observed;
21747
21760
  try {
21748
- observed = await stat7(path2);
21761
+ observed = await stat8(path2);
21749
21762
  } catch (error) {
21750
21763
  if (errorCode(error) !== "ENOENT")
21751
21764
  throw error;
@@ -21884,13 +21897,13 @@ async function safeRead(path2, privateFile = false, afterReadCheck) {
21884
21897
  let file;
21885
21898
  try {
21886
21899
  file = await open7(path2, constants2.O_RDONLY | constants2.O_NOFOLLOW);
21887
- const stat14 = await file.stat();
21888
- if (!stat14.isFile() || privateFile && (stat14.mode & 511) !== 384) {
21900
+ const stat16 = await file.stat();
21901
+ if (!stat16.isFile() || privateFile && (stat16.mode & 511) !== 384) {
21889
21902
  throw new PiSlotError("unsafe-path");
21890
21903
  }
21891
21904
  await afterReadCheck?.(path2);
21892
21905
  const current = await lstat5(path2);
21893
- if (!current.isFile() || current.dev !== stat14.dev || current.ino !== stat14.ino) {
21906
+ if (!current.isFile() || current.dev !== stat16.dev || current.ino !== stat16.ino) {
21894
21907
  throw new PiSlotError("unsafe-path");
21895
21908
  }
21896
21909
  const bytes = await file.readFile();
@@ -24266,7 +24279,7 @@ var init_process_heartbeat = __esm({
24266
24279
  });
24267
24280
 
24268
24281
  // src/version-fence.ts
24269
- import { readdir as readdir2, readFile as readFile9, stat as stat8, unlink as unlink9 } from "node:fs/promises";
24282
+ import { readdir as readdir2, readFile as readFile9, stat as stat9, unlink as unlink9 } from "node:fs/promises";
24270
24283
  import { homedir as homedir3, uptime } from "node:os";
24271
24284
  import { join as join12 } from "node:path";
24272
24285
  function defaultStateHome() {
@@ -24386,7 +24399,7 @@ async function staleRecord(path2, record3, boot, heartbeat) {
24386
24399
  let start = heartbeat ? record3.startedAt : void 0;
24387
24400
  if (start === void 0) {
24388
24401
  try {
24389
- start = (await stat8(path2)).mtimeMs;
24402
+ start = (await stat9(path2)).mtimeMs;
24390
24403
  } catch {
24391
24404
  return false;
24392
24405
  }
@@ -24611,7 +24624,7 @@ import {
24611
24624
  readFile as readFile10,
24612
24625
  rename as rename10,
24613
24626
  rmdir as rmdir2,
24614
- stat as stat9,
24627
+ stat as stat10,
24615
24628
  unlink as unlink10
24616
24629
  } from "node:fs/promises";
24617
24630
  import { basename as basename4, dirname as dirname15, join as join13, resolve as resolve15 } from "node:path";
@@ -25530,7 +25543,7 @@ async function physicalAliases(location, files) {
25530
25543
  async function samePhysical(a, b) {
25531
25544
  const id = async (path2) => {
25532
25545
  try {
25533
- const info = await stat9(path2, { bigint: true });
25546
+ const info = await stat10(path2, { bigint: true });
25534
25547
  return info.ino === 0n ? void 0 : `${info.dev}:${info.ino}`;
25535
25548
  } catch (error) {
25536
25549
  const code2 = error.code;
@@ -25796,7 +25809,7 @@ function lockHolderText(name) {
25796
25809
  }
25797
25810
  async function exists2(path2) {
25798
25811
  try {
25799
- await stat9(path2);
25812
+ await stat10(path2);
25800
25813
  return true;
25801
25814
  } catch (error) {
25802
25815
  const code2 = error.code;
@@ -28187,16 +28200,16 @@ async function select2(terminal, items, options) {
28187
28200
  // src/common-auth-embedded/claustrum/enrollment.js
28188
28201
  import { createHash as createHash12, randomBytes as randomBytes3, randomUUID as randomUUID15 } from "node:crypto";
28189
28202
  import { constants as fsConstants2 } from "node:fs";
28190
- import { chmod as chmod5, mkdir as mkdir14, open as open10, readFile as readFile12, realpath as realpath4, rename as rename12, stat as stat11, unlink as unlink11 } from "node:fs/promises";
28203
+ 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";
28191
28204
  import { basename as basename5, dirname as dirname19, extname as extname2, isAbsolute as isAbsolute4, join as join18, resolve as resolve19 } from "node:path";
28192
28205
  import { ClaustrumCredentialError as ClaustrumCredentialError6, ClaustrumClient as ClaustrumWireClient2, writeEnrollmentTokenFile as writeEnrollmentTokenFile2 } from "@cortexkit/claustrum-client";
28193
28206
 
28194
28207
  // src/common-auth-embedded/fs/file-read-cache.js
28195
- import { lstat as lstat7 } from "node:fs/promises";
28208
+ import { lstat as lstat7, stat as stat11 } from "node:fs/promises";
28196
28209
  import { resolve as resolve18 } from "node:path";
28197
- async function identity2(path2) {
28210
+ async function identity2(path2, followSymlinks) {
28198
28211
  try {
28199
- const metadata = await lstat7(path2);
28212
+ const metadata = await (followSymlinks ? stat11(path2) : lstat7(path2));
28200
28213
  return metadata.isFile() ? metadata : void 0;
28201
28214
  } catch (error) {
28202
28215
  return error.code === "ENOENT" ? "absent" : void 0;
@@ -28208,11 +28221,15 @@ function sameIdentity2(left, right) {
28208
28221
  return left.dev === right.dev && left.ino === right.ino && left.size === right.size && left.mtimeMs === right.mtimeMs && left.ctimeMs === right.ctimeMs;
28209
28222
  }
28210
28223
  var FileReadCache2 = class {
28224
+ #followSymlinks;
28211
28225
  #entries = /* @__PURE__ */ new Map();
28226
+ constructor(options = {}) {
28227
+ this.#followSymlinks = options.followSymlinks ?? false;
28228
+ }
28212
28229
  async read(paths, read, validateHit) {
28213
28230
  const resolvedPaths = paths.map((path2) => resolve18(path2));
28214
28231
  const key = JSON.stringify(resolvedPaths);
28215
- const probed = await Promise.all(resolvedPaths.map(identity2));
28232
+ const probed = await Promise.all(resolvedPaths.map((path2) => identity2(path2, this.#followSymlinks)));
28216
28233
  const identities = probed.every((entry) => entry !== void 0) ? probed : void 0;
28217
28234
  const cached = this.#entries.get(key);
28218
28235
  if (identities && cached && identities.every((entry, index) => {
@@ -28261,7 +28278,7 @@ init_private_files2();
28261
28278
  // src/common-auth-embedded/fs/refresh-file-lock.js
28262
28279
  init_private_files2();
28263
28280
  import { randomUUID as randomUUID14 } from "node:crypto";
28264
- import { lstat as lstat8, mkdir as mkdir13, open as open9, readFile as readFile11, rename as rename11, rm as rm6, stat as stat10 } from "node:fs/promises";
28281
+ import { 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";
28265
28282
  import { dirname as dirname18, join as join17 } from "node:path";
28266
28283
 
28267
28284
  // src/common-auth-embedded/fs/with-lock.js
@@ -28515,7 +28532,7 @@ async function acquireRefreshFileLockWithClock2(options) {
28515
28532
  };
28516
28533
  }
28517
28534
  try {
28518
- const current = await stat10(lockPath);
28535
+ const current = await stat12(lockPath);
28519
28536
  const legacyExpiry = Number.isFinite(expiresAt) ? expiresAt : current.mtimeMs + options.ttlMs;
28520
28537
  if (legacyExpiry > now())
28521
28538
  return { status: "live" };
@@ -28609,7 +28626,7 @@ async function acquireRefreshFileLockWithClock2(options) {
28609
28626
  if (!ownedDirectory)
28610
28627
  return false;
28611
28628
  try {
28612
- await stat10(evictOwnerPath);
28629
+ await stat12(evictOwnerPath);
28613
28630
  return false;
28614
28631
  } catch (error) {
28615
28632
  if (error.code !== "ENOENT")
@@ -28630,7 +28647,7 @@ async function acquireRefreshFileLockWithClock2(options) {
28630
28647
  return false;
28631
28648
  stillOurs = true;
28632
28649
  try {
28633
- await stat10(evictOwnerPath);
28650
+ await stat12(evictOwnerPath);
28634
28651
  return false;
28635
28652
  } catch (error) {
28636
28653
  return error.code === "ENOENT";
@@ -28680,7 +28697,7 @@ async function acquireRefreshFileLockWithClock2(options) {
28680
28697
  async function recoverStaleEvictionMarker(deadline) {
28681
28698
  let evictStat;
28682
28699
  try {
28683
- evictStat = await stat10(evictPath);
28700
+ evictStat = await stat12(evictPath);
28684
28701
  } catch (error) {
28685
28702
  if (error.code === "ENOENT")
28686
28703
  return "missing";
@@ -28698,7 +28715,7 @@ async function acquireRefreshFileLockWithClock2(options) {
28698
28715
  if (evictStat.mtimeMs + EVICT_TTL > now()) {
28699
28716
  let hasOwner = true;
28700
28717
  try {
28701
- await stat10(evictOwnerPath);
28718
+ await stat12(evictOwnerPath);
28702
28719
  } catch (error) {
28703
28720
  if (error.code === "ENOENT")
28704
28721
  hasOwner = false;
@@ -29315,7 +29332,7 @@ async function refuseWritableAncestor2(parent, options = {}) {
29315
29332
  }
29316
29333
  let privateGroup;
29317
29334
  for (; ; ) {
29318
- const metadata = await stat11(component).catch(() => void 0);
29335
+ const metadata = await stat13(component).catch(() => void 0);
29319
29336
  if (metadata && (metadata.mode & 18) !== 0 && (metadata.mode & 512) === 0) {
29320
29337
  if (privateGroup === void 0) {
29321
29338
  privateGroup = gid !== void 0 && await isPrivateGroup2(uid, gid, options);
@@ -29344,7 +29361,7 @@ async function ensureClaustrumPrivateDirectory2(directory, options = {}, what =
29344
29361
  return;
29345
29362
  }
29346
29363
  await mkdir14(directory, { recursive: true, mode: 448 });
29347
- const metadata = await stat11(directory);
29364
+ const metadata = await stat13(directory);
29348
29365
  const uid = process.geteuid?.();
29349
29366
  if (uid !== void 0 && metadata.uid !== uid) {
29350
29367
  throw new ClaustrumConsumerError2("unsafe-file", `Claustrum ${what} must be owned by the current user`);
@@ -29933,7 +29950,7 @@ function setupPaths(io = {}) {
29933
29950
  }
29934
29951
 
29935
29952
  // src/common-auth-embedded/setup/detect.js
29936
- function stat12(path2, kind) {
29953
+ function stat14(path2, kind) {
29937
29954
  try {
29938
29955
  return statSync5(path2)[kind]();
29939
29956
  } catch {
@@ -29942,12 +29959,12 @@ function stat12(path2, kind) {
29942
29959
  }
29943
29960
  var defaultSetupFileSystem = {
29944
29961
  exists: existsSync6,
29945
- isFile: (path2) => stat12(path2, "isFile"),
29946
- isDirectory: (path2) => stat12(path2, "isDirectory"),
29962
+ isFile: (path2) => stat14(path2, "isFile"),
29963
+ isDirectory: (path2) => stat14(path2, "isDirectory"),
29947
29964
  isExecutable(path2) {
29948
29965
  try {
29949
29966
  accessSync(path2, constants3.X_OK);
29950
- return stat12(path2, "isFile");
29967
+ return stat14(path2, "isFile");
29951
29968
  } catch {
29952
29969
  return false;
29953
29970
  }
@@ -30446,6 +30463,12 @@ async function connectSetupHost(plugin, host, io, terminal, fence) {
30446
30463
  await writeEnrollmentTokenFile3(path2, file);
30447
30464
  }
30448
30465
  });
30466
+ await fence();
30467
+ const initial = await manager.status();
30468
+ if (initial.state === "approved") {
30469
+ printLine2(terminal, `Already connected as ${initial.approvedName ?? initial.proposedName}.`);
30470
+ return;
30471
+ }
30449
30472
  printLine2(terminal, `Asking the vault to connect ${name}\u2026`);
30450
30473
  const deadline = now() + ENROLLMENT_WAIT_MS;
30451
30474
  let printedRequest;
@@ -30453,7 +30476,6 @@ async function connectSetupHost(plugin, host, io, terminal, fence) {
30453
30476
  let reportedCode;
30454
30477
  let failedProposals = 0;
30455
30478
  for (; ; ) {
30456
- await fence();
30457
30479
  const status = await manager.reconcile();
30458
30480
  if (status.state === "approved") {
30459
30481
  printLine2(terminal, `Connected ${host} to Claustrum.`);
@@ -30499,6 +30521,7 @@ async function connectSetupHost(plugin, host, io, terminal, fence) {
30499
30521
  if (remaining <= 0)
30500
30522
  break;
30501
30523
  await wait2(Math.min(pause, remaining));
30524
+ await fence();
30502
30525
  }
30503
30526
  if (printedRequest)
30504
30527
  throw new HostNotEnrolledError(`Claustrum approval is still pending. In another terminal, run: ${approveCommand(printedRequest, name)} and then rerun setup.`, {
@@ -30653,7 +30676,7 @@ import { applyEdits, createScanner, findNodeAtLocation, modify, parse as parse2,
30653
30676
 
30654
30677
  // src/common-auth-embedded/setup/config-write.js
30655
30678
  import { randomUUID as randomUUID16 } from "node:crypto";
30656
- import { mkdir as mkdir15, open as open11, rename as rename13, stat as stat13, unlink as unlink12 } from "node:fs/promises";
30679
+ import { mkdir as mkdir15, open as open11, rename as rename13, stat as stat15, unlink as unlink12 } from "node:fs/promises";
30657
30680
  import { basename as basename6, dirname as dirname20, join as join20 } from "node:path";
30658
30681
  import { setTimeout as delay2 } from "node:timers/promises";
30659
30682
  async function writeHostConfigAtomic(file, content, options = {}) {
@@ -30663,7 +30686,7 @@ async function writeHostConfigAtomic(file, content, options = {}) {
30663
30686
  let mode;
30664
30687
  if (!windows) {
30665
30688
  try {
30666
- mode = (await stat13(file)).mode & 4095;
30689
+ mode = (await stat15(file)).mode & 4095;
30667
30690
  } catch (error) {
30668
30691
  if (error.code !== "ENOENT")
30669
30692
  throw error;