@cortexkit/opencode-antigravity-auth 3.1.8 → 3.1.9

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 (101) hide show
  1. package/dist/cli.js +111 -77
  2. package/dist/cli.js.map +4 -4
  3. package/dist/cli.meta.json +71 -32
  4. package/dist/index.js +5072 -4519
  5. package/dist/index.js.map +4 -4
  6. package/dist/index.meta.json +315 -256
  7. package/dist/server.js +1018 -395
  8. package/dist/server.js.map +4 -4
  9. package/dist/server.meta.json +1 -1
  10. package/dist/src/common-auth-embedded/fs/private-files.js +8 -3
  11. package/dist/src/common-auth-embedded/opencode2/index.d.ts +1 -1
  12. package/dist/src/common-auth-embedded/opencode2/index.js +1 -1
  13. package/dist/src/common-auth-embedded/opencode2/install.d.ts +6 -1
  14. package/dist/src/common-auth-embedded/opencode2/install.js +14 -4
  15. package/dist/src/common-auth-embedded/opencode2/types.d.ts +10 -7
  16. package/dist/src/common-auth-embedded/routing-accessor/index.d.ts +66 -16
  17. package/dist/src/common-auth-embedded/routing-accessor/index.js +123 -17
  18. package/dist/src/common-auth-embedded/source-output.json +35 -35
  19. package/dist/src/common-auth-embedded/store/mutate.js +34 -13
  20. package/dist/src/ga/server/index.d.ts +1 -1
  21. package/dist/src/ga/server/index.d.ts.map +1 -1
  22. package/dist/src/ga/server/index.js +58 -19
  23. package/dist/src/ga/server/index.js.map +1 -1
  24. package/dist/src/plugin/__fixtures__/verified-store.js +2 -2
  25. package/dist/src/plugin/auth-loader.d.ts.map +1 -1
  26. package/dist/src/plugin/auth-loader.js +102 -80
  27. package/dist/src/plugin/auth-loader.js.map +1 -1
  28. package/dist/src/plugin/fetch-interceptor.d.ts.map +1 -1
  29. package/dist/src/plugin/fetch-interceptor.js +27 -13
  30. package/dist/src/plugin/fetch-interceptor.js.map +1 -1
  31. package/dist/src/plugin/ga-location-services.d.ts.map +1 -1
  32. package/dist/src/plugin/ga-location-services.js +21 -11
  33. package/dist/src/plugin/ga-location-services.js.map +1 -1
  34. package/dist/src/plugin/index.d.ts.map +1 -1
  35. package/dist/src/plugin/index.js +13 -5
  36. package/dist/src/plugin/index.js.map +1 -1
  37. package/dist/src/plugin/request.d.ts.map +1 -1
  38. package/dist/src/plugin/request.js +2 -2
  39. package/dist/src/plugin/request.js.map +1 -1
  40. package/dist/src/plugin/shared/opencode-retry-hints.d.ts +2 -0
  41. package/dist/src/plugin/shared/opencode-retry-hints.d.ts.map +1 -0
  42. package/dist/src/plugin/shared/opencode-retry-hints.js +22 -0
  43. package/dist/src/plugin/shared/opencode-retry-hints.js.map +1 -0
  44. package/dist/src/plugin/shared/request-services.d.ts +2 -0
  45. package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
  46. package/dist/src/plugin/shared/request-services.js +410 -112
  47. package/dist/src/plugin/shared/request-services.js.map +1 -1
  48. package/dist/src/plugin/shared/vault-routing-purpose.d.ts +6 -2
  49. package/dist/src/plugin/shared/vault-routing-purpose.d.ts.map +1 -1
  50. package/dist/src/plugin/shared/vault-routing-purpose.js +13 -7
  51. package/dist/src/plugin/shared/vault-routing-purpose.js.map +1 -1
  52. package/dist/src/plugin/shared/vault-routing.d.ts +8 -1
  53. package/dist/src/plugin/shared/vault-routing.d.ts.map +1 -1
  54. package/dist/src/plugin/shared/vault-routing.js +12 -4
  55. package/dist/src/plugin/shared/vault-routing.js.map +1 -1
  56. package/dist/src/plugin/storage.d.ts +1 -0
  57. package/dist/src/plugin/storage.d.ts.map +1 -1
  58. package/dist/src/plugin/storage.js +3 -3
  59. package/dist/src/plugin/storage.js.map +1 -1
  60. package/dist/src/plugin/vault-custody.d.ts +6 -13
  61. package/dist/src/plugin/vault-custody.d.ts.map +1 -1
  62. package/dist/src/plugin/vault-custody.js +19 -16
  63. package/dist/src/plugin/vault-custody.js.map +1 -1
  64. package/dist/tui-build-map.json +5 -5
  65. package/dist/tui-ga-build-map.json +1 -1
  66. package/dist/types/src/common-auth-embedded/opencode2/index.d.ts +1 -1
  67. package/dist/types/src/common-auth-embedded/opencode2/install.d.ts +6 -1
  68. package/dist/types/src/common-auth-embedded/opencode2/types.d.ts +10 -7
  69. package/dist/types/src/common-auth-embedded/routing-accessor/index.d.ts +66 -16
  70. package/dist/types/src/ga/server/index.d.ts +1 -1
  71. package/dist/types/src/ga/server/index.d.ts.map +1 -1
  72. package/dist/types/src/plugin/auth-loader.d.ts.map +1 -1
  73. package/dist/types/src/plugin/fetch-interceptor.d.ts.map +1 -1
  74. package/dist/types/src/plugin/ga-location-services.d.ts.map +1 -1
  75. package/dist/types/src/plugin/index.d.ts.map +1 -1
  76. package/dist/types/src/plugin/request.d.ts.map +1 -1
  77. package/dist/types/src/plugin/shared/opencode-retry-hints.d.ts +2 -0
  78. package/dist/types/src/plugin/shared/opencode-retry-hints.d.ts.map +1 -0
  79. package/dist/types/src/plugin/shared/request-services.d.ts +2 -0
  80. package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -1
  81. package/dist/types/src/plugin/shared/vault-routing-purpose.d.ts +6 -2
  82. package/dist/types/src/plugin/shared/vault-routing-purpose.d.ts.map +1 -1
  83. package/dist/types/src/plugin/shared/vault-routing.d.ts +8 -1
  84. package/dist/types/src/plugin/shared/vault-routing.d.ts.map +1 -1
  85. package/dist/types/src/plugin/storage.d.ts +1 -0
  86. package/dist/types/src/plugin/storage.d.ts.map +1 -1
  87. package/dist/types/src/plugin/vault-custody.d.ts +6 -13
  88. package/dist/types/src/plugin/vault-custody.d.ts.map +1 -1
  89. package/package.json +2 -2
  90. package/src/common-auth-embedded/fs/private-files.js +8 -3
  91. package/src/common-auth-embedded/opencode2/index.d.ts +1 -1
  92. package/src/common-auth-embedded/opencode2/index.js +1 -1
  93. package/src/common-auth-embedded/opencode2/install.d.ts +6 -1
  94. package/src/common-auth-embedded/opencode2/install.js +14 -4
  95. package/src/common-auth-embedded/opencode2/types.d.ts +10 -7
  96. package/src/common-auth-embedded/routing-accessor/index.d.ts +66 -16
  97. package/src/common-auth-embedded/routing-accessor/index.js +123 -17
  98. package/src/common-auth-embedded/source-output.json +35 -35
  99. package/src/common-auth-embedded/store/mutate.js +34 -13
  100. package/src/tui-compiled/common-auth-embedded/fs/private-files.js +8 -3
  101. 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";
@@ -6995,9 +6998,9 @@ async function acquireWithRetry(path2, sleep3) {
6995
6998
  return lock;
6996
6999
  }
6997
7000
  if (attempt < RETRY_DELAYS_MS.length) {
6998
- const delay4 = RETRY_DELAYS_MS[attempt];
6999
- if (delay4 !== void 0) {
7000
- await sleep3(delay4);
7001
+ const delay5 = RETRY_DELAYS_MS[attempt];
7002
+ if (delay5 !== void 0) {
7003
+ await sleep3(delay5);
7001
7004
  }
7002
7005
  }
7003
7006
  }
@@ -11224,14 +11227,19 @@ var init_torn = __esm({
11224
11227
  });
11225
11228
 
11226
11229
  // ../core/dist/common-auth-embedded/store/mutate.js
11227
- import { setTimeout as snapshotDelay } from "node:timers/promises";
11230
+ import { setTimeout as delay } from "node:timers/promises";
11228
11231
  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;
11232
+ for (let attempt = 0; ; attempt++) {
11233
+ try {
11234
+ return await readPrivateText(path2, windowsPrivateFiles);
11235
+ } catch (error) {
11236
+ if (error.code === "ENOENT")
11237
+ return void 0;
11238
+ const wait2 = sharingRetryDelays[attempt];
11239
+ if (wait2 === void 0 || !isWindowsSharingViolation(error))
11240
+ throw error;
11241
+ await delay(wait2);
11242
+ }
11235
11243
  }
11236
11244
  }
11237
11245
  function parseFile(text2) {
@@ -11248,12 +11256,21 @@ async function readPoolConfig(path2) {
11248
11256
  }
11249
11257
  async function readPool(ctx) {
11250
11258
  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);
11259
+ let configText;
11260
+ let stateText;
11261
+ let checkedConfigText;
11262
+ try {
11263
+ configText = await readText(ctx.configPath);
11264
+ stateText = await readText(ctx.statePath);
11265
+ checkedConfigText = await readText(ctx.configPath);
11266
+ } catch (error) {
11267
+ if (isWindowsSharingViolation(error))
11268
+ break;
11269
+ throw error;
11270
+ }
11254
11271
  if (configText !== checkedConfigText) {
11255
11272
  if (attempt < 2)
11256
- await snapshotDelay(2 + Math.floor(Math.random() * 4));
11273
+ await delay(2 + Math.floor(Math.random() * 4));
11257
11274
  continue;
11258
11275
  }
11259
11276
  const config = classifyConfig(parseFile(configText));
@@ -11433,7 +11450,7 @@ async function runOperation(ctx, operation, rowId2, onFailure, body) {
11433
11450
  await locks.releaseAll();
11434
11451
  }
11435
11452
  }
11436
- var Transaction;
11453
+ var sharingRetryDelays, Transaction;
11437
11454
  var init_mutate = __esm({
11438
11455
  "../core/dist/common-auth-embedded/store/mutate.js"() {
11439
11456
  "use strict";
@@ -11446,6 +11463,7 @@ var init_mutate = __esm({
11446
11463
  init_reserved();
11447
11464
  init_schema();
11448
11465
  init_torn();
11466
+ sharingRetryDelays = [5, 10, 20, 40, 80, 160, 320, 400];
11449
11467
  Transaction = class {
11450
11468
  ctx;
11451
11469
  snapshot;
@@ -13397,11 +13415,11 @@ var init_quota_writer = __esm({
13397
13415
  overlay(rows) {
13398
13416
  return rows.map((row) => this.overlayRow(row));
13399
13417
  }
13400
- schedule(delay4) {
13418
+ schedule(delay5) {
13401
13419
  if (this.running || this.timer || !this.pending.size || this.stopped)
13402
13420
  return;
13403
13421
  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), () => {
13422
+ this.timer = this.clock.schedule(Math.max(delay5, remaining), () => {
13405
13423
  this.timer = void 0;
13406
13424
  return this.flush();
13407
13425
  });
@@ -13501,8 +13519,8 @@ var init_quota_writer = __esm({
13501
13519
  this.running = void 0;
13502
13520
  for (const wake of this.wake)
13503
13521
  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);
13522
+ const delay5 = this.failures ? Math.min(5e3, 100 * 2 ** Math.min(this.failures, 6)) * (0.5 + Math.random()) : COALESCE_MS;
13523
+ this.schedule(delay5);
13506
13524
  }
13507
13525
  })();
13508
13526
  return this.running;
@@ -17190,12 +17208,12 @@ var init_watch = __esm({
17190
17208
  this.#options.logger?.debug("claustrum vault watch", { mode, reason });
17191
17209
  this.#options.onMode?.(mode);
17192
17210
  }
17193
- #later(delay4, run) {
17211
+ #later(delay5, run) {
17194
17212
  this.#timer = (this.#options.setTimeoutImpl ?? setTimeout)(() => {
17195
17213
  this.#timer = void 0;
17196
17214
  if (!this.#stopped)
17197
17215
  run();
17198
- }, delay4);
17216
+ }, delay5);
17199
17217
  this.#timer.unref?.();
17200
17218
  }
17201
17219
  async #open(resubscribed) {
@@ -17267,10 +17285,10 @@ var init_watch = __esm({
17267
17285
  const now = (this.#options.now ?? Date.now)();
17268
17286
  if (watch.acceptedAt !== void 0 && now - watch.acceptedAt >= SAFETY_POLL_MS)
17269
17287
  this.#closes = 0;
17270
- const delay4 = Math.min(RESUBSCRIBE_BACKOFF_MS * 2 ** Math.min(this.#closes, 16), WATCH_RETRY_MS);
17288
+ const delay5 = Math.min(RESUBSCRIBE_BACKOFF_MS * 2 ** Math.min(this.#closes, 16), WATCH_RETRY_MS);
17271
17289
  this.#closes++;
17272
17290
  this.#setMode("polling", "resubscribing");
17273
- this.#later(delay4, () => void this.#open(true));
17291
+ this.#later(delay5, () => void this.#open(true));
17274
17292
  return;
17275
17293
  }
17276
17294
  this.#fallback(end.kind);
@@ -17561,12 +17579,12 @@ var init_insula = __esm({
17561
17579
  watch?.handle?.stop();
17562
17580
  this.#mode = "polling";
17563
17581
  }
17564
- #later(delay4) {
17582
+ #later(delay5) {
17565
17583
  this.#timer = (this.#timers.setTimeoutImpl ?? setTimeout)(() => {
17566
17584
  this.#timer = void 0;
17567
17585
  if (this.#watchers > 0 && !this.#watch)
17568
17586
  this.#open();
17569
- }, delay4);
17587
+ }, delay5);
17570
17588
  this.#timer.unref?.();
17571
17589
  }
17572
17590
  #open() {
@@ -17614,10 +17632,10 @@ var init_insula = __esm({
17614
17632
  return;
17615
17633
  }
17616
17634
  if (watch.notices > 0) {
17617
- const delay4 = Math.min(RESUBSCRIBE_BACKOFF_MS * 2 ** Math.min(this.#closes, 16), WATCH_RETRY_MS);
17635
+ const delay5 = Math.min(RESUBSCRIBE_BACKOFF_MS * 2 ** Math.min(this.#closes, 16), WATCH_RETRY_MS);
17618
17636
  this.#closes++;
17619
17637
  this.#mode = "polling";
17620
- this.#later(delay4);
17638
+ this.#later(delay5);
17621
17639
  return;
17622
17640
  }
17623
17641
  this.#mode = "fallback";
@@ -19306,9 +19324,9 @@ var init_custody = __esm({
19306
19324
  users: 0,
19307
19325
  error,
19308
19326
  pending: Promise.resolve().then(async () => {
19309
- let delay4 = 250;
19327
+ let delay5 = 250;
19310
19328
  for (; ; ) {
19311
- await this.#receiptBackoff(delay4, controller.signal);
19329
+ await this.#receiptBackoff(delay5, controller.signal);
19312
19330
  try {
19313
19331
  return await this.#authorizeFresh(identity3, token, controller.signal);
19314
19332
  } catch (failure) {
@@ -19316,7 +19334,7 @@ var init_custody = __esm({
19316
19334
  if (classifyVaultFailure(failure) !== "unreachable")
19317
19335
  throw failure;
19318
19336
  created.error = failure;
19319
- delay4 = Math.min(delay4 * 2, 1e3);
19337
+ delay5 = Math.min(delay5 * 2, 1e3);
19320
19338
  }
19321
19339
  }
19322
19340
  })
@@ -19370,7 +19388,7 @@ var init_custody = __esm({
19370
19388
  }
19371
19389
  }
19372
19390
  }
19373
- #receiptBackoff(delay4, signal) {
19391
+ #receiptBackoff(delay5, signal) {
19374
19392
  this.#check(signal);
19375
19393
  return new Promise((resolve25, reject) => {
19376
19394
  const abort = () => {
@@ -19381,7 +19399,7 @@ var init_custody = __esm({
19381
19399
  const timer = this.#setTimeout(() => {
19382
19400
  signal.removeEventListener("abort", abort);
19383
19401
  resolve25();
19384
- }, delay4);
19402
+ }, delay5);
19385
19403
  timer.unref?.();
19386
19404
  signal.addEventListener("abort", abort, { once: true });
19387
19405
  if (signal.aborted)
@@ -20405,11 +20423,11 @@ function pendingVaultQuota(path2, roster) {
20405
20423
  function hasPendingVaultQuota(path2) {
20406
20424
  return !!writers.get(resolve11(path2))?.pending.size;
20407
20425
  }
20408
- function schedule(writer, delay4) {
20426
+ function schedule(writer, delay5) {
20409
20427
  if (writer.running || writer.timer || !writer.pending.size || writer.abort.signal.aborted)
20410
20428
  return;
20411
20429
  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), () => {
20430
+ writer.timer = writer.clock.schedule(Math.max(delay5, remaining), () => {
20413
20431
  writer.timer = void 0;
20414
20432
  return flush(writer);
20415
20433
  });
@@ -20846,13 +20864,13 @@ var init_consumer = __esm({
20846
20864
  }
20847
20865
  if (this.#shutdown.signal.aborted)
20848
20866
  return;
20849
- const delay4 = this.#options.pollIntervalMs ?? 5e3;
20850
- if (delay4 <= 0)
20867
+ const delay5 = this.#options.pollIntervalMs ?? 5e3;
20868
+ if (delay5 <= 0)
20851
20869
  return;
20852
20870
  this.#timer = (this.#options.setTimeoutImpl ?? setTimeout)(() => {
20853
20871
  this.#timer = void 0;
20854
20872
  void this.#track(tick());
20855
- }, delay4);
20873
+ }, delay5);
20856
20874
  this.#timer.unref?.();
20857
20875
  };
20858
20876
  void this.#track(tick());
@@ -22322,13 +22340,13 @@ var init_hub = __esm({
22322
22340
  }
22323
22341
  if (this.#shutdown.signal.aborted)
22324
22342
  return;
22325
- const delay4 = this.#options.pollIntervalMs ?? 5e3;
22326
- if (delay4 <= 0)
22343
+ const delay5 = this.#options.pollIntervalMs ?? 5e3;
22344
+ if (delay5 <= 0)
22327
22345
  return;
22328
22346
  this.#timer = (this.#options.setTimeoutImpl ?? setTimeout)(() => {
22329
22347
  this.#timer = void 0;
22330
22348
  void this.#track(this.#tick());
22331
- }, delay4);
22349
+ }, delay5);
22332
22350
  this.#timer.unref?.();
22333
22351
  }
22334
22352
  /**
@@ -22619,12 +22637,12 @@ async function acquirePiLock(authPath, onCompromised, onRenew) {
22619
22637
  if (!released && lastUpdate + RENEWAL_STALE < Date.now())
22620
22638
  compromise();
22621
22639
  }
22622
- function schedule2(delay4 = UPDATE) {
22640
+ function schedule2(delay5 = UPDATE) {
22623
22641
  if (released)
22624
22642
  return;
22625
22643
  timer = setTimeout(() => {
22626
22644
  void update();
22627
- }, delay4);
22645
+ }, delay5);
22628
22646
  timer.unref();
22629
22647
  }
22630
22648
  function retry(error) {
@@ -23109,6 +23127,32 @@ var init_harness_identity = __esm({
23109
23127
  }
23110
23128
  });
23111
23129
 
23130
+ // ../core/dist/pre-response-deadline.js
23131
+ var init_pre_response_deadline = __esm({
23132
+ "../core/dist/pre-response-deadline.js"() {
23133
+ "use strict";
23134
+ }
23135
+ });
23136
+
23137
+ // ../core/dist/vault-folder-refusal.js
23138
+ var init_vault_folder_refusal = __esm({
23139
+ "../core/dist/vault-folder-refusal.js"() {
23140
+ "use strict";
23141
+ }
23142
+ });
23143
+
23144
+ // ../core/dist/host-failure.js
23145
+ var init_host_failure = __esm({
23146
+ "../core/dist/host-failure.js"() {
23147
+ "use strict";
23148
+ init_account_migration();
23149
+ init_account_repository();
23150
+ init_credential_redaction();
23151
+ init_pre_response_deadline();
23152
+ init_vault_folder_refusal();
23153
+ }
23154
+ });
23155
+
23112
23156
  // ../core/dist/model-types.js
23113
23157
  var init_model_types = __esm({
23114
23158
  "../core/dist/model-types.js"() {
@@ -23134,13 +23178,6 @@ var init_pi_paths = __esm({
23134
23178
  }
23135
23179
  });
23136
23180
 
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
23181
  // ../core/dist/project.js
23145
23182
  function buildBootstrapRequestBody(extra = {}) {
23146
23183
  return {
@@ -24107,13 +24144,6 @@ var init_vault_enrollment_authority = __esm({
24107
24144
  }
24108
24145
  });
24109
24146
 
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
24147
  // ../core/dist/version.js
24118
24148
  var init_version = __esm({
24119
24149
  "../core/dist/version.js"() {
@@ -24152,6 +24182,7 @@ var init_dist = __esm({
24152
24182
  init_file_lock();
24153
24183
  init_fingerprint();
24154
24184
  init_harness_identity();
24185
+ init_host_failure();
24155
24186
  init_logger();
24156
24187
  init_model_registry();
24157
24188
  init_model_types();
@@ -24223,8 +24254,11 @@ function loadBackend2() {
24223
24254
  });
24224
24255
  return backend2;
24225
24256
  }
24257
+ function isSharingIoError2(detail) {
24258
+ return detail?.reason === "io-error" && (detail.win32Code === 32 || detail.win32Code === 303);
24259
+ }
24226
24260
  function isWindowsSharingViolation2(error) {
24227
- return windowsPrivateFiles2 && error instanceof PrivateFileError2 && error.reason === "io-error" && (error.win32Code === 32 || error.win32Code === 303);
24261
+ return windowsPrivateFiles2 && error instanceof PrivateFileError2 && isSharingIoError2(error);
24228
24262
  }
24229
24263
  async function privateOperation2(path2, stage, operation) {
24230
24264
  try {
@@ -24346,12 +24380,12 @@ async function replaceWindowsFile2(from, to, options = {}) {
24346
24380
  const delays = [0, 10, 20, 40, 80, 100];
24347
24381
  let original;
24348
24382
  let attempts2 = 0;
24349
- for (const delay4 of delays) {
24383
+ for (const delay5 of delays) {
24350
24384
  const deadline = Math.min(retryDeadline ?? Infinity, leaseDeadline);
24351
24385
  if (now() >= deadline)
24352
24386
  break;
24353
- if (delay4)
24354
- await (options.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms))))(Math.min(delay4, Math.max(0, deadline - now())));
24387
+ if (delay5)
24388
+ await (options.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms))))(Math.min(delay5, Math.max(0, deadline - now())));
24355
24389
  if (now() >= deadline)
24356
24390
  break;
24357
24391
  const fenceStart = now();
@@ -24474,7 +24508,7 @@ var init_private_files2 = __esm({
24474
24508
  // The reason stays on `.reason`: its word "unavailable" would make
24475
24509
  // OpenCode 1 retry a plain error carrying this message.
24476
24510
  `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 });
24511
+ ) : 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
24512
  this.path = path2;
24479
24513
  this.stage = stage;
24480
24514
  this.name = "PrivateFileError";
@@ -26521,8 +26555,8 @@ function isWindowsSharingError(error, platform) {
26521
26555
  }
26522
26556
  async function unlinkIfIdentical(file, stateDir, guard, io = { platform: process.platform, readFile: readFile10, unlink: unlink11 }) {
26523
26557
  const started = performance.now();
26524
- for (const delay4 of SHARING_RETRY_DELAYS_MS) {
26525
- if (delay4 > 0) await new Promise((done) => setTimeout(done, delay4));
26558
+ for (const delay5 of SHARING_RETRY_DELAYS_MS) {
26559
+ if (delay5 > 0) await new Promise((done) => setTimeout(done, delay5));
26526
26560
  let same;
26527
26561
  try {
26528
26562
  same = (await io.readFile(file.old)).equals(await io.readFile(file.next));
@@ -26996,7 +27030,7 @@ async function assertLegacyPoolInUse(legacyPath) {
26996
27030
  throw new LegacyAccountPoolRetiredError(legacyPath, { cause: error });
26997
27031
  }
26998
27032
  }
26999
- function refusalMessage2(admission) {
27033
+ function accountStoreAdmissionMessage(admission) {
27000
27034
  switch (admission.status) {
27001
27035
  case "busy":
27002
27036
  return new AccountStoreBusyError().message;
@@ -27031,7 +27065,7 @@ function unboundOpening(binding) {
27031
27065
  return {
27032
27066
  status: "refused",
27033
27067
  admission: binding,
27034
- message: refusalMessage2(binding)
27068
+ message: accountStoreAdmissionMessage(binding)
27035
27069
  };
27036
27070
  }
27037
27071
  async function openAccountStore(options) {
@@ -27073,7 +27107,7 @@ async function openAccountStore(options) {
27073
27107
  return {
27074
27108
  status: "refused",
27075
27109
  admission,
27076
- message: refusalMessage2(admission)
27110
+ message: accountStoreAdmissionMessage(admission)
27077
27111
  };
27078
27112
  }
27079
27113
  }
@@ -31502,7 +31536,7 @@ async function detectHosts(plugin, io = {}) {
31502
31536
  }
31503
31537
 
31504
31538
  // src/common-auth-embedded/setup/enroll.js
31505
- import { setTimeout as delay } from "node:timers/promises";
31539
+ import { setTimeout as delay2 } from "node:timers/promises";
31506
31540
  import { writeEnrollmentTokenFile as writeEnrollmentTokenFile3 } from "@cortexkit/claustrum-client";
31507
31541
 
31508
31542
  // src/common-auth-embedded/setup/process-fence.js
@@ -31868,7 +31902,7 @@ async function connectSetupHost(plugin, host, io, terminal, fence) {
31868
31902
  throw new HostNotEnrolledError("Claustrum connection failed; start ck and rerun setup.", { reason: "connection-failed" });
31869
31903
  });
31870
31904
  const now = io.now ?? (() => performance.now());
31871
- const wait2 = io.wait ?? delay;
31905
+ const wait2 = io.wait ?? delay2;
31872
31906
  try {
31873
31907
  const manager = new ClaustrumEnrollmentManager2({
31874
31908
  proposedName: name,
@@ -32102,7 +32136,7 @@ async function selectSetupHosts(terminal, found) {
32102
32136
 
32103
32137
  // src/common-auth-embedded/setup/register.js
32104
32138
  import { rename as rename14 } from "node:fs/promises";
32105
- import { setTimeout as delay3 } from "node:timers/promises";
32139
+ import { setTimeout as delay4 } from "node:timers/promises";
32106
32140
  import { domainToUnicode } from "node:url";
32107
32141
  import { applyEdits, createScanner, findNodeAtLocation, modify, parse as parse2, parseTree } from "jsonc-parser";
32108
32142
 
@@ -32110,7 +32144,7 @@ import { applyEdits, createScanner, findNodeAtLocation, modify, parse as parse2,
32110
32144
  import { randomUUID as randomUUID16 } from "node:crypto";
32111
32145
  import { mkdir as mkdir15, open as open11, rename as rename13, stat as stat15, unlink as unlink14 } from "node:fs/promises";
32112
32146
  import { basename as basename9, dirname as dirname21, join as join21 } from "node:path";
32113
- import { setTimeout as delay2 } from "node:timers/promises";
32147
+ import { setTimeout as delay3 } from "node:timers/promises";
32114
32148
  async function writeHostConfigAtomic(file, content, options = {}) {
32115
32149
  const windows = (options.platform ?? process.platform) === "win32";
32116
32150
  const parent = dirname21(file);
@@ -32149,7 +32183,7 @@ async function writeHostConfigAtomic(file, content, options = {}) {
32149
32183
  const remaining = 2e3 - (now() - started);
32150
32184
  if (!windows || !["EPERM", "EBUSY", "EACCES"].includes(code2 ?? "") || remaining <= 0 || attempt >= 40)
32151
32185
  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)));
32186
+ await (options.wait ?? delay3)(Math.min(remaining, 25 * 2 ** Math.min(attempt, 2)));
32153
32187
  }
32154
32188
  }
32155
32189
  } finally {
@@ -32320,7 +32354,7 @@ async function registerOpenCode(writes, beforeWrite) {
32320
32354
  // Only the rename publishes host-readable config; recheck on every retry.
32321
32355
  beforeRename: guard ? () => guard.check({ reuse: true }) : void 0,
32322
32356
  rename: guard ? (from, to) => guard.step(() => rename14(from, to)) : void 0,
32323
- wait: guard ? (ms) => guard.step(() => delay3(ms)) : void 0
32357
+ wait: guard ? (ms) => guard.step(() => delay4(ms)) : void 0
32324
32358
  });
32325
32359
  }
32326
32360
  }