@cortexkit/opencode-antigravity-auth 3.1.8 → 3.1.10

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 (118) hide show
  1. package/README.md +4 -0
  2. package/dist/cli.js +256 -179
  3. package/dist/cli.js.map +4 -4
  4. package/dist/cli.meta.json +88 -44
  5. package/dist/index.js +5466 -4823
  6. package/dist/index.js.map +4 -4
  7. package/dist/index.meta.json +333 -269
  8. package/dist/server.js +1321 -608
  9. package/dist/server.js.map +4 -4
  10. package/dist/server.meta.json +1 -1
  11. package/dist/src/common-auth-embedded/claustrum/custody.d.ts +16 -5
  12. package/dist/src/common-auth-embedded/claustrum/custody.js +31 -14
  13. package/dist/src/common-auth-embedded/fs/private-files.js +8 -3
  14. package/dist/src/common-auth-embedded/opencode2/index.d.ts +1 -1
  15. package/dist/src/common-auth-embedded/opencode2/index.js +1 -1
  16. package/dist/src/common-auth-embedded/opencode2/install.d.ts +6 -1
  17. package/dist/src/common-auth-embedded/opencode2/install.js +14 -4
  18. package/dist/src/common-auth-embedded/opencode2/types.d.ts +10 -7
  19. package/dist/src/common-auth-embedded/routing-accessor/index.d.ts +71 -16
  20. package/dist/src/common-auth-embedded/routing-accessor/index.js +123 -17
  21. package/dist/src/common-auth-embedded/setup/process-fence.js +20 -3
  22. package/dist/src/common-auth-embedded/source-output.json +44 -44
  23. package/dist/src/common-auth-embedded/store/mutate.js +34 -13
  24. package/dist/src/ga/server/index.d.ts +1 -1
  25. package/dist/src/ga/server/index.d.ts.map +1 -1
  26. package/dist/src/ga/server/index.js +58 -19
  27. package/dist/src/ga/server/index.js.map +1 -1
  28. package/dist/src/plugin/__fixtures__/release-model-ids.d.ts.map +1 -1
  29. package/dist/src/plugin/__fixtures__/release-model-ids.js +1 -0
  30. package/dist/src/plugin/__fixtures__/release-model-ids.js.map +1 -1
  31. package/dist/src/plugin/__fixtures__/verified-store.js +2 -2
  32. package/dist/src/plugin/auth-loader.d.ts.map +1 -1
  33. package/dist/src/plugin/auth-loader.js +102 -80
  34. package/dist/src/plugin/auth-loader.js.map +1 -1
  35. package/dist/src/plugin/config/models.d.ts +1 -1
  36. package/dist/src/plugin/config/models.d.ts.map +1 -1
  37. package/dist/src/plugin/config/models.js +10 -5
  38. package/dist/src/plugin/config/models.js.map +1 -1
  39. package/dist/src/plugin/fetch-interceptor.d.ts.map +1 -1
  40. package/dist/src/plugin/fetch-interceptor.js +27 -13
  41. package/dist/src/plugin/fetch-interceptor.js.map +1 -1
  42. package/dist/src/plugin/ga-location-services.d.ts.map +1 -1
  43. package/dist/src/plugin/ga-location-services.js +21 -11
  44. package/dist/src/plugin/ga-location-services.js.map +1 -1
  45. package/dist/src/plugin/index.d.ts.map +1 -1
  46. package/dist/src/plugin/index.js +13 -5
  47. package/dist/src/plugin/index.js.map +1 -1
  48. package/dist/src/plugin/request.d.ts.map +1 -1
  49. package/dist/src/plugin/request.js +8 -8
  50. package/dist/src/plugin/request.js.map +1 -1
  51. package/dist/src/plugin/shared/opencode-retry-hints.d.ts +2 -0
  52. package/dist/src/plugin/shared/opencode-retry-hints.d.ts.map +1 -0
  53. package/dist/src/plugin/shared/opencode-retry-hints.js +22 -0
  54. package/dist/src/plugin/shared/opencode-retry-hints.js.map +1 -0
  55. package/dist/src/plugin/shared/request-services.d.ts +2 -0
  56. package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
  57. package/dist/src/plugin/shared/request-services.js +410 -112
  58. package/dist/src/plugin/shared/request-services.js.map +1 -1
  59. package/dist/src/plugin/shared/vault-routing-purpose.d.ts +6 -2
  60. package/dist/src/plugin/shared/vault-routing-purpose.d.ts.map +1 -1
  61. package/dist/src/plugin/shared/vault-routing-purpose.js +13 -7
  62. package/dist/src/plugin/shared/vault-routing-purpose.js.map +1 -1
  63. package/dist/src/plugin/shared/vault-routing.d.ts +8 -1
  64. package/dist/src/plugin/shared/vault-routing.d.ts.map +1 -1
  65. package/dist/src/plugin/shared/vault-routing.js +12 -4
  66. package/dist/src/plugin/shared/vault-routing.js.map +1 -1
  67. package/dist/src/plugin/storage.d.ts +1 -0
  68. package/dist/src/plugin/storage.d.ts.map +1 -1
  69. package/dist/src/plugin/storage.js +3 -3
  70. package/dist/src/plugin/storage.js.map +1 -1
  71. package/dist/src/plugin/vault-custody.d.ts +6 -13
  72. package/dist/src/plugin/vault-custody.d.ts.map +1 -1
  73. package/dist/src/plugin/vault-custody.js +19 -16
  74. package/dist/src/plugin/vault-custody.js.map +1 -1
  75. package/dist/tui-build-map.json +5 -5
  76. package/dist/tui-ga-build-map.json +1 -1
  77. package/dist/types/src/common-auth-embedded/claustrum/custody.d.ts +16 -5
  78. package/dist/types/src/common-auth-embedded/opencode2/index.d.ts +1 -1
  79. package/dist/types/src/common-auth-embedded/opencode2/install.d.ts +6 -1
  80. package/dist/types/src/common-auth-embedded/opencode2/types.d.ts +10 -7
  81. package/dist/types/src/common-auth-embedded/routing-accessor/index.d.ts +71 -16
  82. package/dist/types/src/ga/server/index.d.ts +1 -1
  83. package/dist/types/src/ga/server/index.d.ts.map +1 -1
  84. package/dist/types/src/plugin/auth-loader.d.ts.map +1 -1
  85. package/dist/types/src/plugin/config/models.d.ts +1 -1
  86. package/dist/types/src/plugin/config/models.d.ts.map +1 -1
  87. package/dist/types/src/plugin/fetch-interceptor.d.ts.map +1 -1
  88. package/dist/types/src/plugin/ga-location-services.d.ts.map +1 -1
  89. package/dist/types/src/plugin/index.d.ts.map +1 -1
  90. package/dist/types/src/plugin/request.d.ts.map +1 -1
  91. package/dist/types/src/plugin/shared/opencode-retry-hints.d.ts +2 -0
  92. package/dist/types/src/plugin/shared/opencode-retry-hints.d.ts.map +1 -0
  93. package/dist/types/src/plugin/shared/request-services.d.ts +2 -0
  94. package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -1
  95. package/dist/types/src/plugin/shared/vault-routing-purpose.d.ts +6 -2
  96. package/dist/types/src/plugin/shared/vault-routing-purpose.d.ts.map +1 -1
  97. package/dist/types/src/plugin/shared/vault-routing.d.ts +8 -1
  98. package/dist/types/src/plugin/shared/vault-routing.d.ts.map +1 -1
  99. package/dist/types/src/plugin/storage.d.ts +1 -0
  100. package/dist/types/src/plugin/storage.d.ts.map +1 -1
  101. package/dist/types/src/plugin/vault-custody.d.ts +6 -13
  102. package/dist/types/src/plugin/vault-custody.d.ts.map +1 -1
  103. package/package.json +2 -2
  104. package/src/common-auth-embedded/claustrum/custody.d.ts +16 -5
  105. package/src/common-auth-embedded/claustrum/custody.js +31 -14
  106. package/src/common-auth-embedded/fs/private-files.js +8 -3
  107. package/src/common-auth-embedded/opencode2/index.d.ts +1 -1
  108. package/src/common-auth-embedded/opencode2/index.js +1 -1
  109. package/src/common-auth-embedded/opencode2/install.d.ts +6 -1
  110. package/src/common-auth-embedded/opencode2/install.js +14 -4
  111. package/src/common-auth-embedded/opencode2/types.d.ts +10 -7
  112. package/src/common-auth-embedded/routing-accessor/index.d.ts +71 -16
  113. package/src/common-auth-embedded/routing-accessor/index.js +123 -17
  114. package/src/common-auth-embedded/setup/process-fence.js +20 -3
  115. package/src/common-auth-embedded/source-output.json +44 -44
  116. package/src/common-auth-embedded/store/mutate.js +34 -13
  117. package/src/tui-compiled/common-auth-embedded/fs/private-files.js +8 -3
  118. package/src/tui-raw/common-auth-embedded/fs/private-files.js +8 -3
package/dist/cli.js CHANGED
@@ -638,8 +638,11 @@ function loadBackend() {
638
638
  });
639
639
  return backend;
640
640
  }
641
+ function isSharingIoError(detail) {
642
+ return detail?.reason === "io-error" && (detail.win32Code === 32 || detail.win32Code === 303);
643
+ }
641
644
  function isWindowsSharingViolation(error) {
642
- return windowsPrivateFiles && error instanceof PrivateFileError && error.reason === "io-error" && (error.win32Code === 32 || error.win32Code === 303);
645
+ return windowsPrivateFiles && error instanceof PrivateFileError && isSharingIoError(error);
643
646
  }
644
647
  async function privateOperation(path2, stage, operation) {
645
648
  try {
@@ -761,12 +764,12 @@ async function replaceWindowsFile(from, to, options = {}) {
761
764
  const delays = [0, 10, 20, 40, 80, 100];
762
765
  let original;
763
766
  let attempts2 = 0;
764
- for (const delay4 of delays) {
767
+ for (const delay5 of delays) {
765
768
  const deadline = Math.min(retryDeadline ?? Infinity, leaseDeadline);
766
769
  if (now() >= deadline)
767
770
  break;
768
- if (delay4)
769
- await (options.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms))))(Math.min(delay4, Math.max(0, deadline - now())));
771
+ if (delay5)
772
+ await (options.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms))))(Math.min(delay5, Math.max(0, deadline - now())));
770
773
  if (now() >= deadline)
771
774
  break;
772
775
  const fenceStart = now();
@@ -889,7 +892,7 @@ var init_private_files = __esm({
889
892
  // The reason stays on `.reason`: its word "unavailable" would make
890
893
  // OpenCode 1 retry a plain error carrying this message.
891
894
  `Private file refused at ${stage}: ${path2}. The Windows native addon of @cortexkit/private-files could not be loaded, so owner-only access cannot be enforced and nothing was read or written. Reinstall the plugin so the private-files Windows prebuild for this architecture is present; Windows has no safe fallback to permission bits.`
892
- ) : `Private file refused at ${stage}: ${path2} (${detail?.reason ?? detail?.code ?? "io-error"}). Keep this file in a folder that only you, the system or administrators can change, such as a folder in your home directory. If other users could read the file before, sign in again to replace the credentials it held. On Windows the file must also be on a local drive that keeps Windows file permissions, such as NTFS.`, { cause });
895
+ ) : isSharingIoError(detail) ? `Private file busy at ${stage}: ${path2}. Another process was replacing or deleting this file at the same moment (Windows error ${detail.win32Code}).` : `Private file refused at ${stage}: ${path2} (${detail?.reason ?? detail?.code ?? "io-error"}). Keep this file in a folder that only you, the system or administrators can change, such as a folder in your home directory. If other users could read the file before, sign in again to replace the credentials it held. On Windows the file must also be on a local drive that keeps Windows file permissions, such as NTFS.`, { cause });
893
896
  this.path = path2;
894
897
  this.stage = stage;
895
898
  this.name = "PrivateFileError";
@@ -4044,6 +4047,8 @@ function getResolverAliasMap() {
4044
4047
  }
4045
4048
  function getQuotaGroupForModel(modelId, hasArgonPool = false) {
4046
4049
  const normalized = modelId.toLowerCase();
4050
+ if (isGeminiNeonModel(normalized))
4051
+ return "gemini";
4047
4052
  if (isGeminiHydrogenModel(normalized))
4048
4053
  return "gemini";
4049
4054
  if (isGeminiCarbonModel(normalized))
@@ -4066,6 +4071,9 @@ function isGeminiCarbonModel(model) {
4066
4071
  function isGeminiHydrogenModel(model) {
4067
4072
  return /^(?:antigravity-)?gemini-4-hydrogen(?:-(?:low|medium|high|xhigh))?$/.test(model.toLowerCase());
4068
4073
  }
4074
+ function isGeminiNeonModel(model) {
4075
+ return /^(?:antigravity-)?gemini-4-neon(?:-(?:low|medium|high|xhigh))?$/i.test(model);
4076
+ }
4069
4077
  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;
4070
4078
  var init_model_registry = __esm({
4071
4079
  "../core/dist/model-registry.js"() {
@@ -4078,6 +4086,18 @@ var init_model_registry = __esm({
4078
4086
  DEFAULT_COST = { input: 0, output: 0 };
4079
4087
  DEFAULT_OPTIONS = {};
4080
4088
  ALL_MODEL_DEFINITIONS = {
4089
+ "antigravity-gemini-4-neon": defineModel("antigravity-gemini-4-neon", {
4090
+ name: "Gemini 4 Neon (Antigravity)",
4091
+ reasoning: true,
4092
+ limit: { context: 1048576, output: 262144 },
4093
+ modalities: DEFAULT_MODALITIES,
4094
+ variants: {
4095
+ low: { thinkingLevel: "low" },
4096
+ medium: { thinkingLevel: "medium" },
4097
+ high: { thinkingLevel: "high" },
4098
+ xhigh: { thinkingLevel: "xhigh" }
4099
+ }
4100
+ }),
4081
4101
  "antigravity-gemini-4-hydrogen": defineModel("antigravity-gemini-4-hydrogen", {
4082
4102
  name: "Gemini 4 Hydrogen (Antigravity)",
4083
4103
  reasoning: true,
@@ -4225,6 +4245,7 @@ var init_model_registry = __esm({
4225
4245
  "antigravity-gemini-4-argon",
4226
4246
  "antigravity-gemini-4-carbon",
4227
4247
  "antigravity-gemini-4-hydrogen",
4248
+ "antigravity-gemini-4-neon",
4228
4249
  "antigravity-gemini-3.8-flash",
4229
4250
  "antigravity-gemini-3.1-flash-image",
4230
4251
  "antigravity-claude-sonnet-5-5",
@@ -6626,7 +6647,7 @@ function writeConsoleLog(level, ...args) {
6626
6647
  }
6627
6648
  function createLogger(module) {
6628
6649
  const service = `antigravity.${module}`;
6629
- const log9 = (level, message, extra) => {
6650
+ const log10 = (level, message, extra) => {
6630
6651
  if (_sink) {
6631
6652
  try {
6632
6653
  _sink({ service, level, message, extra });
@@ -6640,10 +6661,10 @@ function createLogger(module) {
6640
6661
  }
6641
6662
  };
6642
6663
  return {
6643
- debug: (message, extra) => log9("debug", message, extra),
6644
- info: (message, extra) => log9("info", message, extra),
6645
- warn: (message, extra) => log9("warn", message, extra),
6646
- error: (message, extra) => log9("error", message, extra)
6664
+ debug: (message, extra) => log10("debug", message, extra),
6665
+ info: (message, extra) => log10("info", message, extra),
6666
+ warn: (message, extra) => log10("warn", message, extra),
6667
+ error: (message, extra) => log10("error", message, extra)
6647
6668
  };
6648
6669
  }
6649
6670
  var ENV_CONSOLE_LOG, _sink;
@@ -6995,9 +7016,9 @@ async function acquireWithRetry(path2, sleep3) {
6995
7016
  return lock;
6996
7017
  }
6997
7018
  if (attempt < RETRY_DELAYS_MS.length) {
6998
- const delay4 = RETRY_DELAYS_MS[attempt];
6999
- if (delay4 !== void 0) {
7000
- await sleep3(delay4);
7019
+ const delay5 = RETRY_DELAYS_MS[attempt];
7020
+ if (delay5 !== void 0) {
7021
+ await sleep3(delay5);
7001
7022
  }
7002
7023
  }
7003
7024
  }
@@ -11224,14 +11245,19 @@ var init_torn = __esm({
11224
11245
  });
11225
11246
 
11226
11247
  // ../core/dist/common-auth-embedded/store/mutate.js
11227
- import { setTimeout as snapshotDelay } from "node:timers/promises";
11248
+ import { setTimeout as delay } from "node:timers/promises";
11228
11249
  async function readText(path2) {
11229
- try {
11230
- return await readPrivateText(path2, windowsPrivateFiles);
11231
- } catch (error) {
11232
- if (error.code === "ENOENT")
11233
- return void 0;
11234
- throw error;
11250
+ for (let attempt = 0; ; attempt++) {
11251
+ try {
11252
+ return await readPrivateText(path2, windowsPrivateFiles);
11253
+ } catch (error) {
11254
+ if (error.code === "ENOENT")
11255
+ return void 0;
11256
+ const wait2 = sharingRetryDelays[attempt];
11257
+ if (wait2 === void 0 || !isWindowsSharingViolation(error))
11258
+ throw error;
11259
+ await delay(wait2);
11260
+ }
11235
11261
  }
11236
11262
  }
11237
11263
  function parseFile(text2) {
@@ -11248,12 +11274,21 @@ async function readPoolConfig(path2) {
11248
11274
  }
11249
11275
  async function readPool(ctx) {
11250
11276
  for (let attempt = 0; attempt < 3; attempt++) {
11251
- const configText = await readText(ctx.configPath);
11252
- const stateText = await readText(ctx.statePath);
11253
- const checkedConfigText = await readText(ctx.configPath);
11277
+ let configText;
11278
+ let stateText;
11279
+ let checkedConfigText;
11280
+ try {
11281
+ configText = await readText(ctx.configPath);
11282
+ stateText = await readText(ctx.statePath);
11283
+ checkedConfigText = await readText(ctx.configPath);
11284
+ } catch (error) {
11285
+ if (isWindowsSharingViolation(error))
11286
+ break;
11287
+ throw error;
11288
+ }
11254
11289
  if (configText !== checkedConfigText) {
11255
11290
  if (attempt < 2)
11256
- await snapshotDelay(2 + Math.floor(Math.random() * 4));
11291
+ await delay(2 + Math.floor(Math.random() * 4));
11257
11292
  continue;
11258
11293
  }
11259
11294
  const config = classifyConfig(parseFile(configText));
@@ -11433,7 +11468,7 @@ async function runOperation(ctx, operation, rowId2, onFailure, body) {
11433
11468
  await locks.releaseAll();
11434
11469
  }
11435
11470
  }
11436
- var Transaction;
11471
+ var sharingRetryDelays, Transaction;
11437
11472
  var init_mutate = __esm({
11438
11473
  "../core/dist/common-auth-embedded/store/mutate.js"() {
11439
11474
  "use strict";
@@ -11446,6 +11481,7 @@ var init_mutate = __esm({
11446
11481
  init_reserved();
11447
11482
  init_schema();
11448
11483
  init_torn();
11484
+ sharingRetryDelays = [5, 10, 20, 40, 80, 160, 320, 400];
11449
11485
  Transaction = class {
11450
11486
  ctx;
11451
11487
  snapshot;
@@ -13397,11 +13433,11 @@ var init_quota_writer = __esm({
13397
13433
  overlay(rows) {
13398
13434
  return rows.map((row) => this.overlayRow(row));
13399
13435
  }
13400
- schedule(delay4) {
13436
+ schedule(delay5) {
13401
13437
  if (this.running || this.timer || !this.pending.size || this.stopped)
13402
13438
  return;
13403
13439
  const remaining = this.closed ? 0 : (this.committedAt ?? -Infinity) + QUOTA_COMMIT_INTERVAL_MS - this.clock.now();
13404
- this.timer = this.clock.schedule(Math.max(delay4, remaining), () => {
13440
+ this.timer = this.clock.schedule(Math.max(delay5, remaining), () => {
13405
13441
  this.timer = void 0;
13406
13442
  return this.flush();
13407
13443
  });
@@ -13501,8 +13537,8 @@ var init_quota_writer = __esm({
13501
13537
  this.running = void 0;
13502
13538
  for (const wake of this.wake)
13503
13539
  wake();
13504
- const delay4 = this.failures ? Math.min(5e3, 100 * 2 ** Math.min(this.failures, 6)) * (0.5 + Math.random()) : COALESCE_MS;
13505
- this.schedule(delay4);
13540
+ const delay5 = this.failures ? Math.min(5e3, 100 * 2 ** Math.min(this.failures, 6)) * (0.5 + Math.random()) : COALESCE_MS;
13541
+ this.schedule(delay5);
13506
13542
  }
13507
13543
  })();
13508
13544
  return this.running;
@@ -17190,12 +17226,12 @@ var init_watch = __esm({
17190
17226
  this.#options.logger?.debug("claustrum vault watch", { mode, reason });
17191
17227
  this.#options.onMode?.(mode);
17192
17228
  }
17193
- #later(delay4, run) {
17229
+ #later(delay5, run) {
17194
17230
  this.#timer = (this.#options.setTimeoutImpl ?? setTimeout)(() => {
17195
17231
  this.#timer = void 0;
17196
17232
  if (!this.#stopped)
17197
17233
  run();
17198
- }, delay4);
17234
+ }, delay5);
17199
17235
  this.#timer.unref?.();
17200
17236
  }
17201
17237
  async #open(resubscribed) {
@@ -17267,10 +17303,10 @@ var init_watch = __esm({
17267
17303
  const now = (this.#options.now ?? Date.now)();
17268
17304
  if (watch.acceptedAt !== void 0 && now - watch.acceptedAt >= SAFETY_POLL_MS)
17269
17305
  this.#closes = 0;
17270
- const delay4 = Math.min(RESUBSCRIBE_BACKOFF_MS * 2 ** Math.min(this.#closes, 16), WATCH_RETRY_MS);
17306
+ const delay5 = Math.min(RESUBSCRIBE_BACKOFF_MS * 2 ** Math.min(this.#closes, 16), WATCH_RETRY_MS);
17271
17307
  this.#closes++;
17272
17308
  this.#setMode("polling", "resubscribing");
17273
- this.#later(delay4, () => void this.#open(true));
17309
+ this.#later(delay5, () => void this.#open(true));
17274
17310
  return;
17275
17311
  }
17276
17312
  this.#fallback(end.kind);
@@ -17561,12 +17597,12 @@ var init_insula = __esm({
17561
17597
  watch?.handle?.stop();
17562
17598
  this.#mode = "polling";
17563
17599
  }
17564
- #later(delay4) {
17600
+ #later(delay5) {
17565
17601
  this.#timer = (this.#timers.setTimeoutImpl ?? setTimeout)(() => {
17566
17602
  this.#timer = void 0;
17567
17603
  if (this.#watchers > 0 && !this.#watch)
17568
17604
  this.#open();
17569
- }, delay4);
17605
+ }, delay5);
17570
17606
  this.#timer.unref?.();
17571
17607
  }
17572
17608
  #open() {
@@ -17614,10 +17650,10 @@ var init_insula = __esm({
17614
17650
  return;
17615
17651
  }
17616
17652
  if (watch.notices > 0) {
17617
- const delay4 = Math.min(RESUBSCRIBE_BACKOFF_MS * 2 ** Math.min(this.#closes, 16), WATCH_RETRY_MS);
17653
+ const delay5 = Math.min(RESUBSCRIBE_BACKOFF_MS * 2 ** Math.min(this.#closes, 16), WATCH_RETRY_MS);
17618
17654
  this.#closes++;
17619
17655
  this.#mode = "polling";
17620
- this.#later(delay4);
17656
+ this.#later(delay5);
17621
17657
  return;
17622
17658
  }
17623
17659
  this.#mode = "fallback";
@@ -18795,22 +18831,22 @@ function credentialTypeOf(row, family) {
18795
18831
  return notMine;
18796
18832
  if ("classify" in family) {
18797
18833
  const metadata = rowFactsOf(row);
18798
- let type;
18834
+ let type2;
18799
18835
  switch (metadata.authMethod) {
18800
18836
  case "apikey":
18801
- type = "api_key";
18837
+ type2 = "api_key";
18802
18838
  break;
18803
18839
  case "chatgpt":
18804
18840
  case "antigravity":
18805
18841
  case "oauth":
18806
- type = "oauth";
18842
+ type2 = "oauth";
18807
18843
  break;
18808
18844
  default:
18809
18845
  return { kind: "refused", code: "unknown-auth-method" };
18810
18846
  }
18811
18847
  const facts = {
18812
18848
  credentialId: row.id,
18813
- credentialType: type,
18849
+ credentialType: type2,
18814
18850
  categories: row.categories,
18815
18851
  refreshAdapter: row.refreshAdapter,
18816
18852
  ...metadata
@@ -18822,24 +18858,37 @@ function credentialTypeOf(row, family) {
18822
18858
  if (result.kind === "not-mine")
18823
18859
  return notMine;
18824
18860
  if (result.kind === "mine" && typeof result.member === "string")
18825
- return { kind: "mine", type, member: result.member };
18861
+ return { kind: "mine", type: type2, member: result.member };
18826
18862
  if (result.kind === "refused" && typeof result.code === "string" && /^[a-z][a-z0-9-]{0,31}$/.test(result.code) && !result.code.includes("\n") && family.refusalCodes.includes(result.code))
18827
18863
  return { kind: "refused", code: result.code };
18828
18864
  } catch {
18829
18865
  }
18830
18866
  return { kind: "refused", code: "unclassified" };
18831
18867
  }
18832
- if (row.credentialType !== "oauth" && row.credentialType !== "api_key")
18868
+ const type = row.credentialType;
18869
+ if (type === "oauth") {
18870
+ if (row.refreshAdapter !== family.refreshAdapter)
18871
+ return notMine;
18872
+ } else if (type === "api_key") {
18873
+ if (!family.apiKeys || row.refreshAdapter !== void 0)
18874
+ return notMine;
18875
+ } else {
18833
18876
  return notMine;
18834
- if (row.credentialType === "oauth")
18835
- return row.refreshAdapter === family.refreshAdapter ? { kind: "mine", type: "oauth" } : notMine;
18836
- if (row.credentialType === "api_key" && family.apiKeys)
18837
- return row.refreshAdapter === void 0 ? { kind: "mine", type: "api_key" } : notMine;
18838
- return notMine;
18877
+ }
18878
+ const { authMethod } = rowFactsOf(row, { includeProviderIds: false });
18879
+ if (authMethod !== void 0) {
18880
+ const matchesType = type === "oauth" ? authMethod === "chatgpt" || authMethod === "antigravity" || authMethod === "oauth" : authMethod === "apikey";
18881
+ if (!matchesType)
18882
+ return { kind: "refused", code: "unknown-auth-method" };
18883
+ }
18884
+ return { kind: "mine", type };
18839
18885
  }
18840
- function rowFactsOf(row) {
18886
+ function rowFactsOf(row, { includeProviderIds = true } = {}) {
18841
18887
  const metadata = row;
18842
- return { providerIds: metadata.providerIds, authMethod: metadata.authMethod };
18888
+ return {
18889
+ providerIds: includeProviderIds ? metadata.providerIds : void 0,
18890
+ authMethod: metadata.authMethod
18891
+ };
18843
18892
  }
18844
18893
  function grantReachOf(listed) {
18845
18894
  const { grants, grantTuples } = listed;
@@ -19171,14 +19220,15 @@ var init_custody = __esm({
19171
19220
  for (const record3 of skipped)
19172
19221
  this.#logger.warn("skipped malformed vault record", record3);
19173
19222
  const grantReach = grantReachOf(inventory);
19223
+ const classifying = "classify" in this.#family;
19174
19224
  return {
19175
19225
  view: inventory.view,
19176
19226
  credentials: Object.freeze(credentials),
19177
19227
  skipped: Object.freeze(skipped),
19178
- ..."classify" in this.#family && {
19179
- refused: Object.freeze(refused2),
19180
- notMine
19228
+ ...(classifying || refused2.length > 0) && {
19229
+ refused: Object.freeze(refused2)
19181
19230
  },
19231
+ ...classifying && { notMine },
19182
19232
  ...grantReach && { grantReach }
19183
19233
  };
19184
19234
  }
@@ -19306,9 +19356,9 @@ var init_custody = __esm({
19306
19356
  users: 0,
19307
19357
  error,
19308
19358
  pending: Promise.resolve().then(async () => {
19309
- let delay4 = 250;
19359
+ let delay5 = 250;
19310
19360
  for (; ; ) {
19311
- await this.#receiptBackoff(delay4, controller.signal);
19361
+ await this.#receiptBackoff(delay5, controller.signal);
19312
19362
  try {
19313
19363
  return await this.#authorizeFresh(identity3, token, controller.signal);
19314
19364
  } catch (failure) {
@@ -19316,7 +19366,7 @@ var init_custody = __esm({
19316
19366
  if (classifyVaultFailure(failure) !== "unreachable")
19317
19367
  throw failure;
19318
19368
  created.error = failure;
19319
- delay4 = Math.min(delay4 * 2, 1e3);
19369
+ delay5 = Math.min(delay5 * 2, 1e3);
19320
19370
  }
19321
19371
  }
19322
19372
  })
@@ -19370,7 +19420,7 @@ var init_custody = __esm({
19370
19420
  }
19371
19421
  }
19372
19422
  }
19373
- #receiptBackoff(delay4, signal) {
19423
+ #receiptBackoff(delay5, signal) {
19374
19424
  this.#check(signal);
19375
19425
  return new Promise((resolve25, reject) => {
19376
19426
  const abort = () => {
@@ -19381,7 +19431,7 @@ var init_custody = __esm({
19381
19431
  const timer = this.#setTimeout(() => {
19382
19432
  signal.removeEventListener("abort", abort);
19383
19433
  resolve25();
19384
- }, delay4);
19434
+ }, delay5);
19385
19435
  timer.unref?.();
19386
19436
  signal.addEventListener("abort", abort, { once: true });
19387
19437
  if (signal.aborted)
@@ -20405,11 +20455,11 @@ function pendingVaultQuota(path2, roster) {
20405
20455
  function hasPendingVaultQuota(path2) {
20406
20456
  return !!writers.get(resolve11(path2))?.pending.size;
20407
20457
  }
20408
- function schedule(writer, delay4) {
20458
+ function schedule(writer, delay5) {
20409
20459
  if (writer.running || writer.timer || !writer.pending.size || writer.abort.signal.aborted)
20410
20460
  return;
20411
20461
  const remaining = writer.draining ? 0 : (writer.committedAt ?? -Infinity) + QUOTA_COMMIT_INTERVAL_MS - writer.clock.now();
20412
- writer.timer = writer.clock.schedule(Math.max(delay4, remaining), () => {
20462
+ writer.timer = writer.clock.schedule(Math.max(delay5, remaining), () => {
20413
20463
  writer.timer = void 0;
20414
20464
  return flush(writer);
20415
20465
  });
@@ -20846,13 +20896,13 @@ var init_consumer = __esm({
20846
20896
  }
20847
20897
  if (this.#shutdown.signal.aborted)
20848
20898
  return;
20849
- const delay4 = this.#options.pollIntervalMs ?? 5e3;
20850
- if (delay4 <= 0)
20899
+ const delay5 = this.#options.pollIntervalMs ?? 5e3;
20900
+ if (delay5 <= 0)
20851
20901
  return;
20852
20902
  this.#timer = (this.#options.setTimeoutImpl ?? setTimeout)(() => {
20853
20903
  this.#timer = void 0;
20854
20904
  void this.#track(tick());
20855
- }, delay4);
20905
+ }, delay5);
20856
20906
  this.#timer.unref?.();
20857
20907
  };
20858
20908
  void this.#track(tick());
@@ -22322,13 +22372,13 @@ var init_hub = __esm({
22322
22372
  }
22323
22373
  if (this.#shutdown.signal.aborted)
22324
22374
  return;
22325
- const delay4 = this.#options.pollIntervalMs ?? 5e3;
22326
- if (delay4 <= 0)
22375
+ const delay5 = this.#options.pollIntervalMs ?? 5e3;
22376
+ if (delay5 <= 0)
22327
22377
  return;
22328
22378
  this.#timer = (this.#options.setTimeoutImpl ?? setTimeout)(() => {
22329
22379
  this.#timer = void 0;
22330
22380
  void this.#track(this.#tick());
22331
- }, delay4);
22381
+ }, delay5);
22332
22382
  this.#timer.unref?.();
22333
22383
  }
22334
22384
  /**
@@ -22619,12 +22669,12 @@ async function acquirePiLock(authPath, onCompromised, onRenew) {
22619
22669
  if (!released && lastUpdate + RENEWAL_STALE < Date.now())
22620
22670
  compromise();
22621
22671
  }
22622
- function schedule2(delay4 = UPDATE) {
22672
+ function schedule2(delay5 = UPDATE) {
22623
22673
  if (released)
22624
22674
  return;
22625
22675
  timer = setTimeout(() => {
22626
22676
  void update();
22627
- }, delay4);
22677
+ }, delay5);
22628
22678
  timer.unref();
22629
22679
  }
22630
22680
  function retry(error) {
@@ -23109,6 +23159,32 @@ var init_harness_identity = __esm({
23109
23159
  }
23110
23160
  });
23111
23161
 
23162
+ // ../core/dist/pre-response-deadline.js
23163
+ var init_pre_response_deadline = __esm({
23164
+ "../core/dist/pre-response-deadline.js"() {
23165
+ "use strict";
23166
+ }
23167
+ });
23168
+
23169
+ // ../core/dist/vault-folder-refusal.js
23170
+ var init_vault_folder_refusal = __esm({
23171
+ "../core/dist/vault-folder-refusal.js"() {
23172
+ "use strict";
23173
+ }
23174
+ });
23175
+
23176
+ // ../core/dist/host-failure.js
23177
+ var init_host_failure = __esm({
23178
+ "../core/dist/host-failure.js"() {
23179
+ "use strict";
23180
+ init_account_migration();
23181
+ init_account_repository();
23182
+ init_credential_redaction();
23183
+ init_pre_response_deadline();
23184
+ init_vault_folder_refusal();
23185
+ }
23186
+ });
23187
+
23112
23188
  // ../core/dist/model-types.js
23113
23189
  var init_model_types = __esm({
23114
23190
  "../core/dist/model-types.js"() {
@@ -23134,13 +23210,6 @@ var init_pi_paths = __esm({
23134
23210
  }
23135
23211
  });
23136
23212
 
23137
- // ../core/dist/pre-response-deadline.js
23138
- var init_pre_response_deadline = __esm({
23139
- "../core/dist/pre-response-deadline.js"() {
23140
- "use strict";
23141
- }
23142
- });
23143
-
23144
23213
  // ../core/dist/project.js
23145
23214
  function buildBootstrapRequestBody(extra = {}) {
23146
23215
  return {
@@ -24107,13 +24176,6 @@ var init_vault_enrollment_authority = __esm({
24107
24176
  }
24108
24177
  });
24109
24178
 
24110
- // ../core/dist/vault-folder-refusal.js
24111
- var init_vault_folder_refusal = __esm({
24112
- "../core/dist/vault-folder-refusal.js"() {
24113
- "use strict";
24114
- }
24115
- });
24116
-
24117
24179
  // ../core/dist/version.js
24118
24180
  var init_version = __esm({
24119
24181
  "../core/dist/version.js"() {
@@ -24152,6 +24214,7 @@ var init_dist = __esm({
24152
24214
  init_file_lock();
24153
24215
  init_fingerprint();
24154
24216
  init_harness_identity();
24217
+ init_host_failure();
24155
24218
  init_logger();
24156
24219
  init_model_registry();
24157
24220
  init_model_types();
@@ -24223,8 +24286,11 @@ function loadBackend2() {
24223
24286
  });
24224
24287
  return backend2;
24225
24288
  }
24289
+ function isSharingIoError2(detail) {
24290
+ return detail?.reason === "io-error" && (detail.win32Code === 32 || detail.win32Code === 303);
24291
+ }
24226
24292
  function isWindowsSharingViolation2(error) {
24227
- return windowsPrivateFiles2 && error instanceof PrivateFileError2 && error.reason === "io-error" && (error.win32Code === 32 || error.win32Code === 303);
24293
+ return windowsPrivateFiles2 && error instanceof PrivateFileError2 && isSharingIoError2(error);
24228
24294
  }
24229
24295
  async function privateOperation2(path2, stage, operation) {
24230
24296
  try {
@@ -24346,12 +24412,12 @@ async function replaceWindowsFile2(from, to, options = {}) {
24346
24412
  const delays = [0, 10, 20, 40, 80, 100];
24347
24413
  let original;
24348
24414
  let attempts2 = 0;
24349
- for (const delay4 of delays) {
24415
+ for (const delay5 of delays) {
24350
24416
  const deadline = Math.min(retryDeadline ?? Infinity, leaseDeadline);
24351
24417
  if (now() >= deadline)
24352
24418
  break;
24353
- if (delay4)
24354
- await (options.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms))))(Math.min(delay4, Math.max(0, deadline - now())));
24419
+ if (delay5)
24420
+ await (options.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms))))(Math.min(delay5, Math.max(0, deadline - now())));
24355
24421
  if (now() >= deadline)
24356
24422
  break;
24357
24423
  const fenceStart = now();
@@ -24474,7 +24540,7 @@ var init_private_files2 = __esm({
24474
24540
  // The reason stays on `.reason`: its word "unavailable" would make
24475
24541
  // OpenCode 1 retry a plain error carrying this message.
24476
24542
  `Private file refused at ${stage}: ${path2}. The Windows native addon of @cortexkit/private-files could not be loaded, so owner-only access cannot be enforced and nothing was read or written. Reinstall the plugin so the private-files Windows prebuild for this architecture is present; Windows has no safe fallback to permission bits.`
24477
- ) : `Private file refused at ${stage}: ${path2} (${detail?.reason ?? detail?.code ?? "io-error"}). Keep this file in a folder that only you, the system or administrators can change, such as a folder in your home directory. If other users could read the file before, sign in again to replace the credentials it held. On Windows the file must also be on a local drive that keeps Windows file permissions, such as NTFS.`, { cause });
24543
+ ) : isSharingIoError2(detail) ? `Private file busy at ${stage}: ${path2}. Another process was replacing or deleting this file at the same moment (Windows error ${detail.win32Code}).` : `Private file refused at ${stage}: ${path2} (${detail?.reason ?? detail?.code ?? "io-error"}). Keep this file in a folder that only you, the system or administrators can change, such as a folder in your home directory. If other users could read the file before, sign in again to replace the credentials it held. On Windows the file must also be on a local drive that keeps Windows file permissions, such as NTFS.`, { cause });
24478
24544
  this.path = path2;
24479
24545
  this.stage = stage;
24480
24546
  this.name = "PrivateFileError";
@@ -25442,7 +25508,7 @@ async function prepareVaultFolder(options) {
25442
25508
  const kept = refusals.get(key);
25443
25509
  if (kept)
25444
25510
  return override ? { ...override, refusal: kept } : refused(accountFile, kept);
25445
- const log9 = options.log ?? createLogger4("runtime-layout");
25511
+ const log10 = options.log ?? createLogger4("runtime-layout");
25446
25512
  const version = options.version ?? await pluginPackageVersion().catch(() => "unknown");
25447
25513
  try {
25448
25514
  if (override) {
@@ -25451,11 +25517,11 @@ async function prepareVaultFolder(options) {
25451
25517
  await prepareRuntimeLayout({
25452
25518
  version,
25453
25519
  accountFile,
25454
- log: log9,
25520
+ log: log10,
25455
25521
  ...options.layoutLockWaitMs === void 0 ? {} : { layoutLockWaitMs: options.layoutLockWaitMs }
25456
25522
  });
25457
25523
  if (options.accountStore !== false)
25458
- await prepareAccountStore({ version, log: log9 });
25524
+ await prepareAccountStore({ version, log: log10 });
25459
25525
  } catch (error) {
25460
25526
  const refusal3 = error instanceof RuntimeLayoutRefusal ? error : new RuntimeLayoutRefusal(
25461
25527
  override?.vaultDir ?? runtimeLayoutLocation().stateHomeDir,
@@ -25463,7 +25529,7 @@ async function prepareVaultFolder(options) {
25463
25529
  );
25464
25530
  if (!refusals.has(key)) {
25465
25531
  refusals.set(key, refusal3);
25466
- log9.warn(refusal3.message, {
25532
+ log10.warn(refusal3.message, {
25467
25533
  stateDir: refusal3.stateDir,
25468
25534
  errorClass: refusal3.errorClass
25469
25535
  });
@@ -25584,10 +25650,10 @@ function errorFile(error) {
25584
25650
  ...typeof stage === "string" && stage ? { stage } : {}
25585
25651
  };
25586
25652
  }
25587
- function logCleanupFailure(location, log9, step, error) {
25653
+ function logCleanupFailure(location, log10, step, error) {
25588
25654
  logOnce(
25589
25655
  `${location.key}\0cleanup`,
25590
- () => log9.warn(
25656
+ () => log10.warn(
25591
25657
  "antigravity-auth could not finish removing its old vault files from OpenCode's config folder; it tries again at the next start",
25592
25658
  {
25593
25659
  configDir: location.configDir,
@@ -25616,13 +25682,13 @@ function prepareRuntimeLayout(options) {
25616
25682
  return run;
25617
25683
  }
25618
25684
  async function decide(location, options) {
25619
- const log9 = options.log ?? createLogger4("runtime-layout");
25685
+ const log10 = options.log ?? createLogger4("runtime-layout");
25620
25686
  const stateDir = location.stateHomeDir;
25621
25687
  const markerPath = join14(stateDir, RUNTIME_LAYOUT_MARKER_FILE);
25622
25688
  const files = layoutFiles(location, options.accountFile);
25623
25689
  const fence = options.fence ?? defaultFence(options.version);
25624
25690
  const stateHome = async () => {
25625
- await settleVault(location, options, "state-home", log9);
25691
+ await settleVault(location, options, "state-home", log10);
25626
25692
  return "state-home";
25627
25693
  };
25628
25694
  let marker = await readMarker(markerPath, stateDir, files.vault.old);
@@ -25633,7 +25699,7 @@ async function decide(location, options) {
25633
25699
  join14(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE)
25634
25700
  ).catch(() => true);
25635
25701
  if (!manifestLeft) {
25636
- await settleVault(location, options, "state-home", log9);
25702
+ await settleVault(location, options, "state-home", log10);
25637
25703
  return stateHome();
25638
25704
  }
25639
25705
  }
@@ -25645,7 +25711,7 @@ async function decide(location, options) {
25645
25711
  RUNTIME_LAYOUT_LOCK_NAME,
25646
25712
  markerPath,
25647
25713
  options.layoutLockWaitMs ?? LAYOUT_LOCK_WAIT_MS,
25648
- log9
25714
+ log10
25649
25715
  );
25650
25716
  } catch (error) {
25651
25717
  marker = await readMarker(markerPath, stateDir, files.vault.old);
@@ -25665,7 +25731,7 @@ async function decide(location, options) {
25665
25731
  const legacy = async () => {
25666
25732
  try {
25667
25733
  await lock.assertOwned();
25668
- await settleVault(location, options, "legacy", log9);
25734
+ await settleVault(location, options, "legacy", log10);
25669
25735
  } catch (error) {
25670
25736
  throw new RuntimeLayoutRefusal(stateDir, errorClass(error));
25671
25737
  }
@@ -25679,20 +25745,20 @@ async function decide(location, options) {
25679
25745
  if (!marker.oldFilesRemoved && !aliased)
25680
25746
  await finishOldFiles(location, files, markerPath, marker, lock, {
25681
25747
  fence,
25682
- log: log9,
25748
+ log: log10,
25683
25749
  steps: options.steps,
25684
25750
  oldSignatureCache: options.oldSignatureCacheFile ?? legacySignatureCacheFile()
25685
25751
  });
25686
25752
  else if (marker.oldFilesRemoved) {
25687
25753
  await refuseReappearedFiles(location, files);
25688
- await removeLeftoverManifest(location, lock, options.steps, log9);
25754
+ await removeLeftoverManifest(location, lock, options.steps, log10);
25689
25755
  }
25690
25756
  return await stateHome();
25691
25757
  }
25692
25758
  if (aliased) {
25693
25759
  logOnce(
25694
25760
  `${location.key}\0aliased`,
25695
- () => log9.warn(
25761
+ () => log10.warn(
25696
25762
  "antigravity-auth keeps its vault files in OpenCode's config folder: its state folder is that same folder",
25697
25763
  { configDir: location.configDir, stateDir }
25698
25764
  )
@@ -25701,14 +25767,14 @@ async function decide(location, options) {
25701
25767
  }
25702
25768
  const gate = await fence();
25703
25769
  if (!gate.open) {
25704
- logDeferral(location, gate.blockers, log9);
25770
+ logDeferral(location, gate.blockers, log10);
25705
25771
  return await legacy();
25706
25772
  }
25707
25773
  let markerStarted = false;
25708
25774
  try {
25709
25775
  const outcome = await moveFiles(location, files, markerPath, lock, {
25710
25776
  fence,
25711
- log: log9,
25777
+ log: log10,
25712
25778
  steps: options.steps,
25713
25779
  destinationPrivate: options.destinationPrivate ?? defaultDestinationPrivate,
25714
25780
  oldSignatureCache: options.oldSignatureCacheFile ?? legacySignatureCacheFile(),
@@ -25717,13 +25783,13 @@ async function decide(location, options) {
25717
25783
  }
25718
25784
  });
25719
25785
  if (outcome.kind === "deferred") {
25720
- logDeferral(location, outcome.blockers, log9);
25786
+ logDeferral(location, outcome.blockers, log10);
25721
25787
  return await legacy();
25722
25788
  }
25723
25789
  if (outcome.kind === "refused") {
25724
25790
  logOnce(
25725
25791
  `${location.key}\0refused`,
25726
- () => log9.warn(
25792
+ () => log10.warn(
25727
25793
  outcome.reason === "destination-not-private" ? "antigravity-auth keeps its vault files in OpenCode's config folder: the vault folder in its state folder already exists and is not private to your user. It was left unchanged; remove it if it holds nothing you need, then restart OpenCode." : "antigravity-auth keeps its vault files in OpenCode's config folder: it will not move them",
25728
25794
  { reason: outcome.reason, paths: outcome.paths, stateDir }
25729
25795
  )
@@ -25731,7 +25797,7 @@ async function decide(location, options) {
25731
25797
  return await legacy();
25732
25798
  }
25733
25799
  if (outcome.moved)
25734
- log9.info(
25800
+ log10.info(
25735
25801
  "antigravity-auth moved its vault files out of OpenCode's config folder",
25736
25802
  { from: files.vault.old, to: files.vault.next }
25737
25803
  );
@@ -25742,7 +25808,7 @@ async function decide(location, options) {
25742
25808
  return await stateHome();
25743
25809
  logOnce(
25744
25810
  `${location.key}\0failed`,
25745
- () => log9.warn(
25811
+ () => log10.warn(
25746
25812
  "antigravity-auth's vault files stay in OpenCode's config folder: moving them failed; the move is tried again at the next start",
25747
25813
  {
25748
25814
  configDir: location.configDir,
@@ -25791,7 +25857,7 @@ async function prepareAccountStore(options) {
25791
25857
  if (!await localAccountStoreAuthorized()) return void 0;
25792
25858
  const decided = decidedAccountStoreAnchor(location);
25793
25859
  if (decided) return decided;
25794
- const log9 = options.log ?? createLogger4("runtime-layout");
25860
+ const log10 = options.log ?? createLogger4("runtime-layout");
25795
25861
  const runKey = `${location.stateHomeDir}\0${location.key}`;
25796
25862
  let run = processState.storeRuns.get(runKey);
25797
25863
  if (!run) {
@@ -25802,12 +25868,12 @@ async function prepareAccountStore(options) {
25802
25868
  RUNTIME_LAYOUT_LOCK_NAME,
25803
25869
  join14(location.stateHomeDir, RUNTIME_LAYOUT_MARKER_FILE),
25804
25870
  options.layoutLockWaitMs ?? LAYOUT_LOCK_WAIT_MS,
25805
- log9
25871
+ log10
25806
25872
  );
25807
25873
  try {
25808
25874
  await lock.assertOwned();
25809
25875
  if (!await localAccountStoreAuthorized()) return void 0;
25810
- return await settleAccountStore(location, options, log9);
25876
+ return await settleAccountStore(location, options, log10);
25811
25877
  } finally {
25812
25878
  await lock.release();
25813
25879
  }
@@ -25818,20 +25884,20 @@ async function prepareAccountStore(options) {
25818
25884
  }
25819
25885
  return run;
25820
25886
  }
25821
- async function settleAccountStore(location, options, log9) {
25887
+ async function settleAccountStore(location, options, log10) {
25822
25888
  const decided = decidedAccountStoreAnchor(location);
25823
25889
  if (decided) return decided;
25824
- const anchor = await decideAccountStore(location, options, log9);
25890
+ const anchor = await decideAccountStore(location, options, log10);
25825
25891
  setAccountStoreAnchor(location, anchor);
25826
25892
  return anchor;
25827
25893
  }
25828
- async function decideAccountStore(location, options, log9) {
25829
- const keepConfig = () => recordAnchor(location, options, "config", log9);
25894
+ async function decideAccountStore(location, options, log10) {
25895
+ const keepConfig = () => recordAnchor(location, options, "config", log10);
25830
25896
  if (processHasOlderGeneration()) {
25831
25897
  logOnce(
25832
25898
  "older-generation-account-store",
25833
25899
  () => showLog(
25834
- log9,
25900
+ log10,
25835
25901
  "antigravity-auth keeps the account store in OpenCode's config folder until OpenCode restarts, because an older version of the plugin ran in this process.",
25836
25902
  { accountStore: "config" }
25837
25903
  )
@@ -25845,7 +25911,7 @@ async function decideAccountStore(location, options, log9) {
25845
25911
  if (!sameSpelling(forward.legacyPath, stateAnchor)) {
25846
25912
  logOnce(
25847
25913
  `${location.key}\0store-forward-elsewhere`,
25848
- () => log9.warn(
25914
+ () => log10.warn(
25849
25915
  "the account store moved to another folder than this process resolved; check XDG_STATE_HOME",
25850
25916
  { movedTo: forward.legacyPath, expected: stateAnchor }
25851
25917
  )
@@ -25856,9 +25922,9 @@ async function decideAccountStore(location, options, log9) {
25856
25922
  options,
25857
25923
  configAnchor,
25858
25924
  stateAnchor,
25859
- log9
25925
+ log10
25860
25926
  );
25861
- return recordAnchor(location, options, "state-home", log9);
25927
+ return recordAnchor(location, options, "state-home", log10);
25862
25928
  }
25863
25929
  if (decidedRuntimeLayout(location) === "legacy") return keepConfig();
25864
25930
  const configStore = await presentAccountStore(configAnchor);
@@ -25870,9 +25936,9 @@ async function decideAccountStore(location, options, log9) {
25870
25936
  `antigravity-auth cannot start: two account stores exist, one at ${configAnchor} and one at ${stateAnchor}, and neither is marked as moved. Keep the one you want and move the other one aside, then restart OpenCode.`
25871
25937
  );
25872
25938
  }
25873
- if (stateStore) return recordAnchor(location, options, "state-home", log9);
25939
+ if (stateStore) return recordAnchor(location, options, "state-home", log10);
25874
25940
  if (configStore) {
25875
- if (!await storeMovePathResolves(stateAnchor, location, log9))
25941
+ if (!await storeMovePathResolves(stateAnchor, location, log10))
25876
25942
  return keepConfig();
25877
25943
  return moveStore(
25878
25944
  location,
@@ -25880,21 +25946,21 @@ async function decideAccountStore(location, options, log9) {
25880
25946
  configAnchor,
25881
25947
  stateAnchor,
25882
25948
  false,
25883
- log9,
25949
+ log10,
25884
25950
  false
25885
25951
  );
25886
25952
  }
25887
- if (await storeArtefacts(stateAnchor) > 0 && !await abandonUnpublishedStore(location, stateAnchor, log9))
25953
+ if (await storeArtefacts(stateAnchor) > 0 && !await abandonUnpublishedStore(location, stateAnchor, log10))
25888
25954
  return keepConfig();
25889
- if (!await storeMovePathResolves(stateAnchor, location, log9))
25955
+ if (!await storeMovePathResolves(stateAnchor, location, log10))
25890
25956
  return keepConfig();
25891
- return initializeStore(location, options, stateAnchor, log9);
25957
+ return initializeStore(location, options, stateAnchor, log10);
25892
25958
  }
25893
- function showLog(log9, message, meta) {
25894
- if (log9.log) log9.log(message, meta);
25895
- else log9.info(message, meta);
25959
+ function showLog(log10, message, meta) {
25960
+ if (log10.log) log10.log(message, meta);
25961
+ else log10.info(message, meta);
25896
25962
  }
25897
- async function recordAnchor(location, options, anchor, log9) {
25963
+ async function recordAnchor(location, options, anchor, log10) {
25898
25964
  try {
25899
25965
  await recordProcessAnchor({
25900
25966
  key: location.key,
@@ -25906,32 +25972,32 @@ async function recordAnchor(location, options, anchor, log9) {
25906
25972
  }
25907
25973
  if (anchor === "state-home")
25908
25974
  showLog(
25909
- log9,
25975
+ log10,
25910
25976
  "antigravity-auth keeps its account store in its state folder",
25911
25977
  { accountStore: anchor }
25912
25978
  );
25913
25979
  return anchor;
25914
25980
  }
25915
- async function storeMovePathResolves(stateAnchor, location, log9) {
25981
+ async function storeMovePathResolves(stateAnchor, location, log10) {
25916
25982
  if (folderResolvesToItself(
25917
25983
  join14(location.stateHomeDir, "antigravity-accounts.json")
25918
25984
  ))
25919
25985
  return true;
25920
25986
  logOnce(
25921
25987
  `${location.key}\0store-linked-path`,
25922
- () => log9.warn(ACCOUNT_STORE_LINKED_PATH_MESSAGE, {
25988
+ () => log10.warn(ACCOUNT_STORE_LINKED_PATH_MESSAGE, {
25923
25989
  accountStore: stateAnchor,
25924
25990
  stateFolder: location.stateHomeDir
25925
25991
  })
25926
25992
  );
25927
25993
  return false;
25928
25994
  }
25929
- async function storeFenceOpen(location, options, log9) {
25995
+ async function storeFenceOpen(location, options, log10) {
25930
25996
  const gate = await (options.storeFence ?? defaultStoreFence(options.version))();
25931
25997
  if (gate.open) return true;
25932
25998
  logOnce(
25933
25999
  `${location.key}\0store-version-fence`,
25934
- () => log9.info(ACCOUNT_STORE_DEFERRED_MESSAGE, {
26000
+ () => log10.info(ACCOUNT_STORE_DEFERRED_MESSAGE, {
25935
26001
  configDir: location.configDir,
25936
26002
  blockers: gate.blockers
25937
26003
  })
@@ -25958,7 +26024,7 @@ async function storeArtefacts(anchor) {
25958
26024
  (name) => name === store || name.startsWith(`${pool}.store.`) || name.startsWith(pool) && name.endsWith(".tmp")
25959
26025
  ).length;
25960
26026
  }
25961
- async function abandonUnpublishedStore(location, stateAnchor, log9) {
26027
+ async function abandonUnpublishedStore(location, stateAnchor, log10) {
25962
26028
  const store = await loadCommonAuthStoreModules();
25963
26029
  const binding = await readAccountStoreBinding(stateAnchor, store, Date.now);
25964
26030
  if (binding.status === "bound") return false;
@@ -25969,7 +26035,7 @@ async function abandonUnpublishedStore(location, stateAnchor, log9) {
25969
26035
  });
25970
26036
  await unlink11(accountStorePointerPath(stateAnchor)).catch(() => {
25971
26037
  });
25972
- log9.info(
26038
+ log10.info(
25973
26039
  "antigravity-auth set an unfinished account store aside before starting its move again",
25974
26040
  { configDir: location.configDir, archived }
25975
26041
  );
@@ -25991,9 +26057,9 @@ async function runStoreMove(input) {
25991
26057
  return { status: "pending", reason: outcome.reason };
25992
26058
  return { status: "cancelled" };
25993
26059
  }
25994
- async function moveStore(location, options, source, target, back, log9, forwarded) {
25995
- const keepConfig = () => recordAnchor(location, options, "config", log9);
25996
- if (!await storeFenceOpen(location, options, log9)) return keepConfig();
26060
+ async function moveStore(location, options, source, target, back, log10, forwarded) {
26061
+ const keepConfig = () => recordAnchor(location, options, "config", log10);
26062
+ if (!await storeFenceOpen(location, options, log10)) return keepConfig();
25997
26063
  try {
25998
26064
  const result = await (options.relocate ?? runStoreMove)({
25999
26065
  source,
@@ -26003,7 +26069,7 @@ async function moveStore(location, options, source, target, back, log9, forwarde
26003
26069
  if (result.status !== "completed") {
26004
26070
  logOnce(
26005
26071
  `${location.key}\0store-move-unfinished`,
26006
- () => log9.info(ACCOUNT_STORE_DEFERRED_MESSAGE, {
26072
+ () => log10.info(ACCOUNT_STORE_DEFERRED_MESSAGE, {
26007
26073
  configDir: location.configDir,
26008
26074
  reason: result.status === "pending" ? result.reason : result.status
26009
26075
  })
@@ -26011,14 +26077,14 @@ async function moveStore(location, options, source, target, back, log9, forwarde
26011
26077
  return forwarded ? "state-home" : keepConfig();
26012
26078
  }
26013
26079
  showLog(
26014
- log9,
26080
+ log10,
26015
26081
  "antigravity-auth moved the account store out of OpenCode's config folder",
26016
26082
  { from: source, to: target, generation: result.id }
26017
26083
  );
26018
26084
  } catch (error) {
26019
26085
  logOnce(
26020
26086
  `${location.key}\0store-move-failed`,
26021
- () => log9.warn(
26087
+ () => log10.warn(
26022
26088
  "antigravity-auth's account store stays in OpenCode's config folder: moving it failed; the move is tried again at the next start",
26023
26089
  {
26024
26090
  configDir: location.configDir,
@@ -26029,9 +26095,9 @@ async function moveStore(location, options, source, target, back, log9, forwarde
26029
26095
  );
26030
26096
  return forwarded ? "state-home" : keepConfig();
26031
26097
  }
26032
- return recordAnchor(location, options, "state-home", log9);
26098
+ return recordAnchor(location, options, "state-home", log10);
26033
26099
  }
26034
- async function resumeForwardedStore(location, options, configAnchor, stateAnchor, log9) {
26100
+ async function resumeForwardedStore(location, options, configAnchor, stateAnchor, log10) {
26035
26101
  const store = await loadCommonAuthStoreModules();
26036
26102
  const binding = await readAccountStoreBinding(stateAnchor, store, Date.now);
26037
26103
  if (binding.status === "bound") return;
@@ -26042,13 +26108,13 @@ async function resumeForwardedStore(location, options, configAnchor, stateAnchor
26042
26108
  configAnchor,
26043
26109
  stateAnchor,
26044
26110
  false,
26045
- log9,
26111
+ log10,
26046
26112
  true
26047
26113
  );
26048
26114
  } catch (error) {
26049
26115
  logOnce(
26050
26116
  `${location.key}\0store-resume-failed`,
26051
- () => log9.warn(
26117
+ () => log10.warn(
26052
26118
  "antigravity-auth's account store is still moving; it could not be finished at this start",
26053
26119
  {
26054
26120
  configDir: location.configDir,
@@ -26059,9 +26125,9 @@ async function resumeForwardedStore(location, options, configAnchor, stateAnchor
26059
26125
  );
26060
26126
  }
26061
26127
  }
26062
- async function initializeStore(location, options, stateAnchor, log9) {
26063
- const keepConfig = () => recordAnchor(location, options, "config", log9);
26064
- if (!await storeFenceOpen(location, options, log9)) return keepConfig();
26128
+ async function initializeStore(location, options, stateAnchor, log10) {
26129
+ const keepConfig = () => recordAnchor(location, options, "config", log10);
26130
+ if (!await storeFenceOpen(location, options, log10)) return keepConfig();
26065
26131
  try {
26066
26132
  const store = await loadCommonAuthStoreModules();
26067
26133
  const created = await initializeFreshAccountStore(store, {
@@ -26074,7 +26140,7 @@ async function initializeStore(location, options, stateAnchor, log9) {
26074
26140
  } catch (error) {
26075
26141
  logOnce(
26076
26142
  `${location.key}\0store-init-failed`,
26077
- () => log9.warn(
26143
+ () => log10.warn(
26078
26144
  "antigravity-auth's account store stays in OpenCode's config folder: creating it in its state folder failed; it is tried again at the next start",
26079
26145
  {
26080
26146
  configDir: location.configDir,
@@ -26086,13 +26152,13 @@ async function initializeStore(location, options, stateAnchor, log9) {
26086
26152
  return keepConfig();
26087
26153
  }
26088
26154
  showLog(
26089
- log9,
26155
+ log10,
26090
26156
  "antigravity-auth created its account store in its state folder",
26091
26157
  {
26092
26158
  accountStore: stateAnchor
26093
26159
  }
26094
26160
  );
26095
- return recordAnchor(location, options, "state-home", log9);
26161
+ return recordAnchor(location, options, "state-home", log10);
26096
26162
  }
26097
26163
  async function writeStateHomeStoreForward(id, stateAnchor, configAnchor = legacyAccountFile(runtimeLayoutLocation().configDir)) {
26098
26164
  const forward = {
@@ -26107,10 +26173,10 @@ async function writeStateHomeStoreForward(id, stateAnchor, configAnchor = legacy
26107
26173
  durability: "file-only-on-windows"
26108
26174
  });
26109
26175
  }
26110
- function logDeferral(location, blockers, log9) {
26176
+ function logDeferral(location, blockers, log10) {
26111
26177
  logOnce(
26112
26178
  `${location.key}\0deferred`,
26113
- () => log9.info(RUNTIME_LAYOUT_DEFERRED_MESSAGE, {
26179
+ () => log10.info(RUNTIME_LAYOUT_DEFERRED_MESSAGE, {
26114
26180
  configDir: location.configDir,
26115
26181
  blockers
26116
26182
  })
@@ -26268,13 +26334,13 @@ async function finishOldFiles(location, files, markerPath, marker, layoutLock, i
26268
26334
  if (done) await removeOldVaultFolder(files, layoutLock, input.steps);
26269
26335
  }
26270
26336
  }
26271
- async function removeLeftoverManifest(location, layoutLock, steps, log9) {
26337
+ async function removeLeftoverManifest(location, layoutLock, steps, log10) {
26272
26338
  try {
26273
26339
  await removeManifestOwned(location.stateHomeDir, layoutLock, steps);
26274
26340
  } catch (error) {
26275
26341
  logOnce(
26276
26342
  `${location.key}\0manifest`,
26277
- () => log9.warn(
26343
+ () => log10.warn(
26278
26344
  `antigravity-auth could not remove ${RUNTIME_LAYOUT_MANIFEST_FILE} from its state folder; it tries again at the next start`,
26279
26345
  { stateDir: location.stateHomeDir, errorClass: errorClass(error) }
26280
26346
  )
@@ -26294,7 +26360,7 @@ async function removeOldVaultFolder(files, layoutLock, steps) {
26294
26360
  } catch {
26295
26361
  }
26296
26362
  }
26297
- async function removeOldSignatureCache(location, path2, layoutLock, steps, log9) {
26363
+ async function removeOldSignatureCache(location, path2, layoutLock, steps, log10) {
26298
26364
  try {
26299
26365
  if (!await exists2(path2)) return;
26300
26366
  await beforeRemove(path2, layoutLock, steps);
@@ -26303,7 +26369,7 @@ async function removeOldSignatureCache(location, path2, layoutLock, steps, log9)
26303
26369
  if (error?.code === "ENOENT") return;
26304
26370
  logOnce(
26305
26371
  `${location.key}\0signature-cache`,
26306
- () => log9.warn(
26372
+ () => log10.warn(
26307
26373
  "antigravity-auth could not remove its old signature cache from OpenCode's config folder; it is no longer used and can be deleted",
26308
26374
  { path: path2, errorClass: errorClass(error) }
26309
26375
  )
@@ -26314,7 +26380,7 @@ async function beforeRemove(path2, layoutLock, steps) {
26314
26380
  await steps?.beforeRemove?.(path2);
26315
26381
  await layoutLock.assertOwned();
26316
26382
  }
26317
- async function takeDataLocks(files, log9) {
26383
+ async function takeDataLocks(files, log10) {
26318
26384
  const locks = [];
26319
26385
  try {
26320
26386
  if (await exists2(files.vault.old))
@@ -26324,7 +26390,7 @@ async function takeDataLocks(files, log9) {
26324
26390
  lock.name,
26325
26391
  join14(files.vault.old, lock.file),
26326
26392
  lock.waitMs,
26327
- log9
26393
+ log10
26328
26394
  )
26329
26395
  );
26330
26396
  return locks;
@@ -26521,8 +26587,8 @@ function isWindowsSharingError(error, platform) {
26521
26587
  }
26522
26588
  async function unlinkIfIdentical(file, stateDir, guard, io = { platform: process.platform, readFile: readFile10, unlink: unlink11 }) {
26523
26589
  const started = performance.now();
26524
- for (const delay4 of SHARING_RETRY_DELAYS_MS) {
26525
- if (delay4 > 0) await new Promise((done) => setTimeout(done, delay4));
26590
+ for (const delay5 of SHARING_RETRY_DELAYS_MS) {
26591
+ if (delay5 > 0) await new Promise((done) => setTimeout(done, delay5));
26526
26592
  let same;
26527
26593
  try {
26528
26594
  same = (await io.readFile(file.old)).equals(await io.readFile(file.next));
@@ -26675,7 +26741,7 @@ async function ensureOwnerOnlyDir(path2) {
26675
26741
  await mkdir12(path2, { recursive: true, mode: 448 });
26676
26742
  await chmod4(path2, 448);
26677
26743
  }
26678
- async function takeLock(name, path2, waitMs, log9) {
26744
+ async function takeLock(name, path2, waitMs, log10) {
26679
26745
  const fs3 = await loadCommonAuthFs();
26680
26746
  const started = performance.now();
26681
26747
  let announced = false;
@@ -26700,7 +26766,7 @@ async function takeLock(name, path2, waitMs, log9) {
26700
26766
  );
26701
26767
  if (!announced && waited >= LOCK_WAIT_NOTICE_MS) {
26702
26768
  announced = true;
26703
- log9.info(
26769
+ log10.info(
26704
26770
  `antigravity-auth is waiting up to ${Math.round(waitMs / 1e3)} s for the ${name} lock at ${path2}.${lockHolderText(name)}`,
26705
26771
  { lock: name, path: path2 }
26706
26772
  );
@@ -26996,7 +27062,7 @@ async function assertLegacyPoolInUse(legacyPath) {
26996
27062
  throw new LegacyAccountPoolRetiredError(legacyPath, { cause: error });
26997
27063
  }
26998
27064
  }
26999
- function refusalMessage2(admission) {
27065
+ function accountStoreAdmissionMessage(admission) {
27000
27066
  switch (admission.status) {
27001
27067
  case "busy":
27002
27068
  return new AccountStoreBusyError().message;
@@ -27031,7 +27097,7 @@ function unboundOpening(binding) {
27031
27097
  return {
27032
27098
  status: "refused",
27033
27099
  admission: binding,
27034
- message: refusalMessage2(binding)
27100
+ message: accountStoreAdmissionMessage(binding)
27035
27101
  };
27036
27102
  }
27037
27103
  async function openAccountStore(options) {
@@ -27073,7 +27139,7 @@ async function openAccountStore(options) {
27073
27139
  return {
27074
27140
  status: "refused",
27075
27141
  admission,
27076
- message: refusalMessage2(admission)
27142
+ message: accountStoreAdmissionMessage(admission)
27077
27143
  };
27078
27144
  }
27079
27145
  }
@@ -27917,19 +27983,19 @@ function getLegacyLogger() {
27917
27983
  }
27918
27984
  function createLogger4(module) {
27919
27985
  let channel3;
27920
- const log9 = (level, message, extra) => {
27986
+ const log10 = (level, message, extra) => {
27921
27987
  channel3 ??= getLegacyLogger().createLogger(module);
27922
27988
  channel3[level](message, extra);
27923
27989
  };
27924
27990
  return {
27925
- debug: (message, extra) => log9("debug", message, extra),
27926
- info: (message, extra) => log9("info", message, extra),
27991
+ debug: (message, extra) => log10("debug", message, extra),
27992
+ info: (message, extra) => log10("info", message, extra),
27927
27993
  hostInfo: (message, extra) => {
27928
27994
  channel3 ??= getLegacyLogger().createLogger(module);
27929
27995
  channel3.hostInfo?.(message, extra);
27930
27996
  },
27931
- warn: (message, extra) => log9("warn", message, extra),
27932
- error: (message, extra) => log9("error", message, extra)
27997
+ warn: (message, extra) => log10("warn", message, extra),
27998
+ error: (message, extra) => log10("error", message, extra)
27933
27999
  };
27934
28000
  }
27935
28001
  var ENV_CONSOLE_LOG2, LOG_LEVEL_FROM_OPERATOR, legacyClient, legacyLogger;
@@ -31502,13 +31568,15 @@ async function detectHosts(plugin, io = {}) {
31502
31568
  }
31503
31569
 
31504
31570
  // src/common-auth-embedded/setup/enroll.js
31505
- import { setTimeout as delay } from "node:timers/promises";
31571
+ import { setTimeout as delay2 } from "node:timers/promises";
31506
31572
  import { writeEnrollmentTokenFile as writeEnrollmentTokenFile3 } from "@cortexkit/claustrum-client";
31507
31573
 
31508
31574
  // src/common-auth-embedded/setup/process-fence.js
31575
+ init_logger3();
31509
31576
  import { statSync as statSync6 } from "node:fs";
31510
31577
  import { win32 as win323 } from "node:path";
31511
31578
  var WINDOWS_CIM_TIMEOUT_MS = 45e3;
31579
+ var log9 = createLogger3("setup-process-fence");
31512
31580
  var WINDOWS_ARM_POWERSHELL_TIMEOUT_MS = 9e4;
31513
31581
  function isFile(file) {
31514
31582
  try {
@@ -31668,14 +31736,23 @@ async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
31668
31736
  options.onStep?.({ ...inspection });
31669
31737
  }
31670
31738
  };
31671
- const inspectCim = (args) => {
31739
+ const inspectCim = async (args) => {
31672
31740
  const pwsh = win323.resolve(windowsEnv(env3, "ProgramFiles") ?? "C:\\Program Files", "PowerShell", "7", "pwsh.exe");
31673
31741
  const program = (options.isFile ?? isFile)(pwsh) ? "pwsh" : "powershell";
31674
31742
  const arm64 = (windowsEnv(env3, "PROCESSOR_ARCHITEW6432") ?? windowsEnv(env3, "PROCESSOR_ARCHITECTURE"))?.toUpperCase() === "ARM64";
31675
31743
  const slow = program === "powershell" && arm64;
31676
31744
  if (slow)
31677
31745
  options.onProgress?.("Checking that OpenCode and Pi are not running. Without PowerShell 7 this can take up to a minute on Windows ARM; installing PowerShell 7 makes it fast.");
31678
- return inspect("CIM", program === "pwsh" ? pwsh : win323.resolve(system32, "WindowsPowerShell", "v1.0", "powershell.exe"), args, slow ? WINDOWS_ARM_POWERSHELL_TIMEOUT_MS : WINDOWS_CIM_TIMEOUT_MS, program);
31746
+ const file = program === "pwsh" ? pwsh : win323.resolve(system32, "WindowsPowerShell", "v1.0", "powershell.exe");
31747
+ const timeoutMs = slow ? WINDOWS_ARM_POWERSHELL_TIMEOUT_MS : WINDOWS_CIM_TIMEOUT_MS;
31748
+ const started = performance.now();
31749
+ const result = await inspect("CIM", file, args, timeoutMs, program);
31750
+ const remaining = Math.floor(timeoutMs - (performance.now() - started));
31751
+ if ((result.exitCode === 3221225477 || result.exitCode === -1073741819) && !result.timedOut && !result.signal && !result.spawnError && remaining > 0) {
31752
+ log9.warn("Windows process query crashed with an access violation; retrying once");
31753
+ return inspect("CIM", file, args, remaining, program);
31754
+ }
31755
+ return result;
31679
31756
  };
31680
31757
  try {
31681
31758
  if (windows && options.hostImagesOnly) {
@@ -31868,7 +31945,7 @@ async function connectSetupHost(plugin, host, io, terminal, fence) {
31868
31945
  throw new HostNotEnrolledError("Claustrum connection failed; start ck and rerun setup.", { reason: "connection-failed" });
31869
31946
  });
31870
31947
  const now = io.now ?? (() => performance.now());
31871
- const wait2 = io.wait ?? delay;
31948
+ const wait2 = io.wait ?? delay2;
31872
31949
  try {
31873
31950
  const manager = new ClaustrumEnrollmentManager2({
31874
31951
  proposedName: name,
@@ -32102,7 +32179,7 @@ async function selectSetupHosts(terminal, found) {
32102
32179
 
32103
32180
  // src/common-auth-embedded/setup/register.js
32104
32181
  import { rename as rename14 } from "node:fs/promises";
32105
- import { setTimeout as delay3 } from "node:timers/promises";
32182
+ import { setTimeout as delay4 } from "node:timers/promises";
32106
32183
  import { domainToUnicode } from "node:url";
32107
32184
  import { applyEdits, createScanner, findNodeAtLocation, modify, parse as parse2, parseTree } from "jsonc-parser";
32108
32185
 
@@ -32110,7 +32187,7 @@ import { applyEdits, createScanner, findNodeAtLocation, modify, parse as parse2,
32110
32187
  import { randomUUID as randomUUID16 } from "node:crypto";
32111
32188
  import { mkdir as mkdir15, open as open11, rename as rename13, stat as stat15, unlink as unlink14 } from "node:fs/promises";
32112
32189
  import { basename as basename9, dirname as dirname21, join as join21 } from "node:path";
32113
- import { setTimeout as delay2 } from "node:timers/promises";
32190
+ import { setTimeout as delay3 } from "node:timers/promises";
32114
32191
  async function writeHostConfigAtomic(file, content, options = {}) {
32115
32192
  const windows = (options.platform ?? process.platform) === "win32";
32116
32193
  const parent = dirname21(file);
@@ -32149,7 +32226,7 @@ async function writeHostConfigAtomic(file, content, options = {}) {
32149
32226
  const remaining = 2e3 - (now() - started);
32150
32227
  if (!windows || !["EPERM", "EBUSY", "EACCES"].includes(code2 ?? "") || remaining <= 0 || attempt >= 40)
32151
32228
  throw new Error(`Unable to replace host config ${file}. Close editors or other programs using the file, then rerun setup.`);
32152
- await (options.wait ?? delay2)(Math.min(remaining, 25 * 2 ** Math.min(attempt, 2)));
32229
+ await (options.wait ?? delay3)(Math.min(remaining, 25 * 2 ** Math.min(attempt, 2)));
32153
32230
  }
32154
32231
  }
32155
32232
  } finally {
@@ -32320,7 +32397,7 @@ async function registerOpenCode(writes, beforeWrite) {
32320
32397
  // Only the rename publishes host-readable config; recheck on every retry.
32321
32398
  beforeRename: guard ? () => guard.check({ reuse: true }) : void 0,
32322
32399
  rename: guard ? (from, to) => guard.step(() => rename14(from, to)) : void 0,
32323
- wait: guard ? (ms) => guard.step(() => delay3(ms)) : void 0
32400
+ wait: guard ? (ms) => guard.step(() => delay4(ms)) : void 0
32324
32401
  });
32325
32402
  }
32326
32403
  }