@cortexkit/opencode-antigravity-auth 3.1.4 → 3.1.5

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 (46) hide show
  1. package/README.md +3 -2
  2. package/dist/cli.js +158 -74
  3. package/dist/cli.js.map +4 -4
  4. package/dist/cli.meta.json +88 -15
  5. package/dist/index.js +244 -96
  6. package/dist/index.js.map +4 -4
  7. package/dist/index.meta.json +92 -19
  8. package/dist/server.js +242 -94
  9. package/dist/server.js.map +4 -4
  10. package/dist/server.meta.json +1 -1
  11. package/dist/src/common-auth-embedded/auth-menu/login.js +4 -1
  12. package/dist/src/common-auth-embedded/routing-accessor/cache-policy.d.ts +2 -2
  13. package/dist/src/common-auth-embedded/routing-accessor/cache-policy.js +1 -0
  14. package/dist/src/common-auth-embedded/setup/command.js +40 -19
  15. package/dist/src/common-auth-embedded/setup/enroll.d.ts +2 -1
  16. package/dist/src/common-auth-embedded/setup/enroll.js +12 -7
  17. package/dist/src/common-auth-embedded/setup/process-fence.d.ts +9 -0
  18. package/dist/src/common-auth-embedded/setup/process-fence.js +52 -8
  19. package/dist/src/common-auth-embedded/setup/process-guard.d.ts +12 -0
  20. package/dist/src/common-auth-embedded/setup/process-guard.js +32 -0
  21. package/dist/src/common-auth-embedded/setup/register.d.ts +2 -1
  22. package/dist/src/common-auth-embedded/setup/register.js +12 -2
  23. package/dist/src/common-auth-embedded/source-output.json +54 -38
  24. package/dist/src/plugin/__fixtures__/verified-store.d.ts +1 -1
  25. package/dist/src/plugin/__fixtures__/verified-store.js +4 -4
  26. package/dist/tui-build-map.json +1 -1
  27. package/dist/tui-ga-build-map.json +1 -1
  28. package/dist/types/src/common-auth-embedded/routing-accessor/cache-policy.d.ts +2 -2
  29. package/dist/types/src/common-auth-embedded/setup/enroll.d.ts +2 -1
  30. package/dist/types/src/common-auth-embedded/setup/process-fence.d.ts +9 -0
  31. package/dist/types/src/common-auth-embedded/setup/process-guard.d.ts +12 -0
  32. package/dist/types/src/common-auth-embedded/setup/register.d.ts +2 -1
  33. package/package.json +2 -2
  34. package/src/common-auth-embedded/auth-menu/login.js +4 -1
  35. package/src/common-auth-embedded/routing-accessor/cache-policy.d.ts +2 -2
  36. package/src/common-auth-embedded/routing-accessor/cache-policy.js +1 -0
  37. package/src/common-auth-embedded/setup/command.js +40 -19
  38. package/src/common-auth-embedded/setup/enroll.d.ts +2 -1
  39. package/src/common-auth-embedded/setup/enroll.js +12 -7
  40. package/src/common-auth-embedded/setup/process-fence.d.ts +9 -0
  41. package/src/common-auth-embedded/setup/process-fence.js +52 -8
  42. package/src/common-auth-embedded/setup/process-guard.d.ts +12 -0
  43. package/src/common-auth-embedded/setup/process-guard.js +32 -0
  44. package/src/common-auth-embedded/setup/register.d.ts +2 -1
  45. package/src/common-auth-embedded/setup/register.js +12 -2
  46. package/src/common-auth-embedded/source-output.json +54 -38
package/dist/index.js CHANGED
@@ -761,12 +761,12 @@ async function replaceWindowsFile(from, to, options = {}) {
761
761
  const delays = [0, 10, 20, 40, 80, 100];
762
762
  let original;
763
763
  let attempts2 = 0;
764
- for (const delay3 of delays) {
764
+ for (const delay4 of delays) {
765
765
  const deadline = Math.min(retryDeadline ?? Infinity, leaseDeadline);
766
766
  if (now() >= deadline)
767
767
  break;
768
- if (delay3)
769
- await (options.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms))))(Math.min(delay3, Math.max(0, deadline - now())));
768
+ if (delay4)
769
+ await (options.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms))))(Math.min(delay4, Math.max(0, deadline - now())));
770
770
  if (now() >= deadline)
771
771
  break;
772
772
  const fenceStart = now();
@@ -4563,8 +4563,8 @@ var init_model_registry = __esm({
4563
4563
  // ../core/dist/rotation.js
4564
4564
  function unconfirmedRateLimitDelayMs(retryAfter, now = Date.now()) {
4565
4565
  const value = retryAfter?.trim();
4566
- const delay3 = value ? /^\d+(?:\.\d+)?$/.test(value) ? Number(value) * 1e3 : Date.parse(value) - now : Number.NaN;
4567
- return Number.isFinite(delay3) ? Math.min(UNCONFIRMED_RATE_LIMIT_MAX_MS, Math.max(UNCONFIRMED_RATE_LIMIT_MIN_MS, delay3)) : UNCONFIRMED_RATE_LIMIT_MIN_MS;
4566
+ const delay4 = value ? /^\d+(?:\.\d+)?$/.test(value) ? Number(value) * 1e3 : Date.parse(value) - now : Number.NaN;
4567
+ return Number.isFinite(delay4) ? Math.min(UNCONFIRMED_RATE_LIMIT_MAX_MS, Math.max(UNCONFIRMED_RATE_LIMIT_MIN_MS, delay4)) : UNCONFIRMED_RATE_LIMIT_MIN_MS;
4568
4568
  }
4569
4569
  function parseRateLimitReason(reason, message, status) {
4570
4570
  if (status === 529 || status === 503)
@@ -8911,9 +8911,9 @@ async function acquireWithRetry(path5, sleep5) {
8911
8911
  return lock;
8912
8912
  }
8913
8913
  if (attempt < RETRY_DELAYS_MS.length) {
8914
- const delay3 = RETRY_DELAYS_MS[attempt];
8915
- if (delay3 !== void 0) {
8916
- await sleep5(delay3);
8914
+ const delay4 = RETRY_DELAYS_MS[attempt];
8915
+ if (delay4 !== void 0) {
8916
+ await sleep5(delay4);
8917
8917
  }
8918
8918
  }
8919
8919
  }
@@ -17625,11 +17625,11 @@ var init_quota_writer = __esm({
17625
17625
  overlay(rows) {
17626
17626
  return rows.map((row) => this.overlayRow(row));
17627
17627
  }
17628
- schedule(delay3) {
17628
+ schedule(delay4) {
17629
17629
  if (this.running || this.timer || !this.pending.size || this.stopped)
17630
17630
  return;
17631
17631
  const remaining = this.closed ? 0 : (this.committedAt ?? -Infinity) + QUOTA_COMMIT_INTERVAL_MS - this.clock.now();
17632
- this.timer = this.clock.schedule(Math.max(delay3, remaining), () => {
17632
+ this.timer = this.clock.schedule(Math.max(delay4, remaining), () => {
17633
17633
  this.timer = void 0;
17634
17634
  return this.flush();
17635
17635
  });
@@ -17729,8 +17729,8 @@ var init_quota_writer = __esm({
17729
17729
  this.running = void 0;
17730
17730
  for (const wake of this.wake)
17731
17731
  wake();
17732
- const delay3 = this.failures ? Math.min(5e3, 100 * 2 ** Math.min(this.failures, 6)) * (0.5 + Math.random()) : COALESCE_MS;
17733
- this.schedule(delay3);
17732
+ const delay4 = this.failures ? Math.min(5e3, 100 * 2 ** Math.min(this.failures, 6)) * (0.5 + Math.random()) : COALESCE_MS;
17733
+ this.schedule(delay4);
17734
17734
  }
17735
17735
  })();
17736
17736
  return this.running;
@@ -20470,11 +20470,12 @@ var init_doctor = __esm({
20470
20470
 
20471
20471
  // ../core/dist/common-auth-embedded/auth-menu/login.js
20472
20472
  import { spawn as defaultSpawn } from "node:child_process";
20473
+ import { win32 } from "node:path";
20473
20474
  function openBrowserForMenu(url, platform = process.platform, spawn2 = defaultSpawn) {
20474
20475
  try {
20475
20476
  if (platform === "win32") {
20476
20477
  const command = `Start-Process '${url.replaceAll("'", "''")}'`;
20477
- const child2 = spawn2("powershell.exe", [
20478
+ const child2 = spawn2(win32.resolve(process.env.SystemRoot ?? process.env.windir ?? "C:\\Windows", "System32", "WindowsPowerShell", "v1.0", "powershell.exe"), [
20478
20479
  "-NoProfile",
20479
20480
  "-NonInteractive",
20480
20481
  "-WindowStyle",
@@ -21417,12 +21418,12 @@ var init_watch = __esm({
21417
21418
  this.#options.logger?.debug("claustrum vault watch", { mode, reason });
21418
21419
  this.#options.onMode?.(mode);
21419
21420
  }
21420
- #later(delay3, run) {
21421
+ #later(delay4, run) {
21421
21422
  this.#timer = (this.#options.setTimeoutImpl ?? setTimeout)(() => {
21422
21423
  this.#timer = void 0;
21423
21424
  if (!this.#stopped)
21424
21425
  run();
21425
- }, delay3);
21426
+ }, delay4);
21426
21427
  this.#timer.unref?.();
21427
21428
  }
21428
21429
  async #open(resubscribed) {
@@ -21494,10 +21495,10 @@ var init_watch = __esm({
21494
21495
  const now = (this.#options.now ?? Date.now)();
21495
21496
  if (watch2.acceptedAt !== void 0 && now - watch2.acceptedAt >= SAFETY_POLL_MS)
21496
21497
  this.#closes = 0;
21497
- const delay3 = Math.min(RESUBSCRIBE_BACKOFF_MS * 2 ** Math.min(this.#closes, 16), WATCH_RETRY_MS);
21498
+ const delay4 = Math.min(RESUBSCRIBE_BACKOFF_MS * 2 ** Math.min(this.#closes, 16), WATCH_RETRY_MS);
21498
21499
  this.#closes++;
21499
21500
  this.#setMode("polling", "resubscribing");
21500
- this.#later(delay3, () => void this.#open(true));
21501
+ this.#later(delay4, () => void this.#open(true));
21501
21502
  return;
21502
21503
  }
21503
21504
  this.#fallback(end.kind);
@@ -21788,12 +21789,12 @@ var init_insula = __esm({
21788
21789
  watch2?.handle?.stop();
21789
21790
  this.#mode = "polling";
21790
21791
  }
21791
- #later(delay3) {
21792
+ #later(delay4) {
21792
21793
  this.#timer = (this.#timers.setTimeoutImpl ?? setTimeout)(() => {
21793
21794
  this.#timer = void 0;
21794
21795
  if (this.#watchers > 0 && !this.#watch)
21795
21796
  this.#open();
21796
- }, delay3);
21797
+ }, delay4);
21797
21798
  this.#timer.unref?.();
21798
21799
  }
21799
21800
  #open() {
@@ -21841,10 +21842,10 @@ var init_insula = __esm({
21841
21842
  return;
21842
21843
  }
21843
21844
  if (watch2.notices > 0) {
21844
- const delay3 = Math.min(RESUBSCRIBE_BACKOFF_MS * 2 ** Math.min(this.#closes, 16), WATCH_RETRY_MS);
21845
+ const delay4 = Math.min(RESUBSCRIBE_BACKOFF_MS * 2 ** Math.min(this.#closes, 16), WATCH_RETRY_MS);
21845
21846
  this.#closes++;
21846
21847
  this.#mode = "polling";
21847
- this.#later(delay3);
21848
+ this.#later(delay4);
21848
21849
  return;
21849
21850
  }
21850
21851
  this.#mode = "fallback";
@@ -23533,9 +23534,9 @@ var init_custody = __esm({
23533
23534
  users: 0,
23534
23535
  error,
23535
23536
  pending: Promise.resolve().then(async () => {
23536
- let delay3 = 250;
23537
+ let delay4 = 250;
23537
23538
  for (; ; ) {
23538
- await this.#receiptBackoff(delay3, controller.signal);
23539
+ await this.#receiptBackoff(delay4, controller.signal);
23539
23540
  try {
23540
23541
  return await this.#authorizeFresh(identity4, token, controller.signal);
23541
23542
  } catch (failure2) {
@@ -23543,7 +23544,7 @@ var init_custody = __esm({
23543
23544
  if (classifyVaultFailure(failure2) !== "unreachable")
23544
23545
  throw failure2;
23545
23546
  created.error = failure2;
23546
- delay3 = Math.min(delay3 * 2, 1e3);
23547
+ delay4 = Math.min(delay4 * 2, 1e3);
23547
23548
  }
23548
23549
  }
23549
23550
  })
@@ -23597,7 +23598,7 @@ var init_custody = __esm({
23597
23598
  }
23598
23599
  }
23599
23600
  }
23600
- #receiptBackoff(delay3, signal) {
23601
+ #receiptBackoff(delay4, signal) {
23601
23602
  this.#check(signal);
23602
23603
  return new Promise((resolve32, reject) => {
23603
23604
  const abort = () => {
@@ -23608,7 +23609,7 @@ var init_custody = __esm({
23608
23609
  const timer = this.#setTimeout(() => {
23609
23610
  signal.removeEventListener("abort", abort);
23610
23611
  resolve32();
23611
- }, delay3);
23612
+ }, delay4);
23612
23613
  timer.unref?.();
23613
23614
  signal.addEventListener("abort", abort, { once: true });
23614
23615
  if (signal.aborted)
@@ -24632,11 +24633,11 @@ function pendingVaultQuota(path5, roster) {
24632
24633
  function hasPendingVaultQuota(path5) {
24633
24634
  return !!writers.get(resolve11(path5))?.pending.size;
24634
24635
  }
24635
- function schedule(writer, delay3) {
24636
+ function schedule(writer, delay4) {
24636
24637
  if (writer.running || writer.timer || !writer.pending.size || writer.abort.signal.aborted)
24637
24638
  return;
24638
24639
  const remaining = writer.draining ? 0 : (writer.committedAt ?? -Infinity) + QUOTA_COMMIT_INTERVAL_MS - writer.clock.now();
24639
- writer.timer = writer.clock.schedule(Math.max(delay3, remaining), () => {
24640
+ writer.timer = writer.clock.schedule(Math.max(delay4, remaining), () => {
24640
24641
  writer.timer = void 0;
24641
24642
  return flush(writer);
24642
24643
  });
@@ -25073,13 +25074,13 @@ var init_consumer = __esm({
25073
25074
  }
25074
25075
  if (this.#shutdown.signal.aborted)
25075
25076
  return;
25076
- const delay3 = this.#options.pollIntervalMs ?? 5e3;
25077
- if (delay3 <= 0)
25077
+ const delay4 = this.#options.pollIntervalMs ?? 5e3;
25078
+ if (delay4 <= 0)
25078
25079
  return;
25079
25080
  this.#timer = (this.#options.setTimeoutImpl ?? setTimeout)(() => {
25080
25081
  this.#timer = void 0;
25081
25082
  void this.#track(tick());
25082
- }, delay3);
25083
+ }, delay4);
25083
25084
  this.#timer.unref?.();
25084
25085
  };
25085
25086
  void this.#track(tick());
@@ -26549,13 +26550,13 @@ var init_hub = __esm({
26549
26550
  }
26550
26551
  if (this.#shutdown.signal.aborted)
26551
26552
  return;
26552
- const delay3 = this.#options.pollIntervalMs ?? 5e3;
26553
- if (delay3 <= 0)
26553
+ const delay4 = this.#options.pollIntervalMs ?? 5e3;
26554
+ if (delay4 <= 0)
26554
26555
  return;
26555
26556
  this.#timer = (this.#options.setTimeoutImpl ?? setTimeout)(() => {
26556
26557
  this.#timer = void 0;
26557
26558
  void this.#track(this.#tick());
26558
- }, delay3);
26559
+ }, delay4);
26559
26560
  this.#timer.unref?.();
26560
26561
  }
26561
26562
  /**
@@ -26846,12 +26847,12 @@ async function acquirePiLock(authPath, onCompromised, onRenew) {
26846
26847
  if (!released && lastUpdate + RENEWAL_STALE < Date.now())
26847
26848
  compromise();
26848
26849
  }
26849
- function schedule2(delay3 = UPDATE) {
26850
+ function schedule2(delay4 = UPDATE) {
26850
26851
  if (released)
26851
26852
  return;
26852
26853
  timer = setTimeout(() => {
26853
26854
  void update();
26854
- }, delay3);
26855
+ }, delay4);
26855
26856
  timer.unref();
26856
26857
  }
26857
26858
  function retry(error) {
@@ -28788,7 +28789,7 @@ function isSchemaObject(value) {
28788
28789
  function describeValue(value) {
28789
28790
  return JSON.stringify(value) ?? String(value);
28790
28791
  }
28791
- function normalizeNullableTypeArray(schema) {
28792
+ function normalizeNullableTypeArray(schema, unionHints) {
28792
28793
  if (!Array.isArray(schema.type))
28793
28794
  return schema;
28794
28795
  if (schema.type.length === 0 || schema.type.some((type) => typeof type !== "string" || !ALLOWED_JSON_SCHEMA_TYPES.has(type.toLowerCase()))) {
@@ -28799,7 +28800,37 @@ function normalizeNullableTypeArray(schema) {
28799
28800
  ];
28800
28801
  const nonNull = types.filter((type) => type !== "null");
28801
28802
  if (nonNull.length > 1) {
28802
- return schema;
28803
+ if (!unionHints)
28804
+ return schema;
28805
+ const { type: _type, ...base } = schema;
28806
+ if (types.includes("null"))
28807
+ base.nullable = true;
28808
+ const coversEveryType = ["object", "array", "string", "boolean"].every((type) => nonNull.includes(type)) && (nonNull.includes("number") || nonNull.includes("integer"));
28809
+ if (!coversEveryType && (Array.isArray(base.anyOf) || Array.isArray(base.oneOf))) {
28810
+ unionHints.push("type: additional union constraints omitted.");
28811
+ return base;
28812
+ }
28813
+ const branches = nonNull.map((type) => {
28814
+ const branch = { type };
28815
+ for (const key of TYPE_ARRAY_BRANCH_FIELDS[type] ?? []) {
28816
+ if (!Object.hasOwn(base, key))
28817
+ continue;
28818
+ if (key === "enum" && (!Array.isArray(base.enum) || !base.enum.every((value) => typeof value === "string")))
28819
+ continue;
28820
+ branch[key] = base[key];
28821
+ }
28822
+ return branch;
28823
+ });
28824
+ for (const key of /* @__PURE__ */ new Set([
28825
+ ...Object.values(TYPE_ARRAY_BRANCH_FIELDS).flat(),
28826
+ "minProperties",
28827
+ "maxProperties"
28828
+ ])) {
28829
+ if (key === "enum" && Array.isArray(base.enum) && !base.enum.every((value) => typeof value === "string"))
28830
+ continue;
28831
+ delete base[key];
28832
+ }
28833
+ return coversEveryType ? base : { ...base, anyOf: branches };
28803
28834
  }
28804
28835
  return {
28805
28836
  ...schema,
@@ -28917,7 +28948,7 @@ function toGeminiSchema(schema, options = {}) {
28917
28948
  return schema;
28918
28949
  }
28919
28950
  const numericConstraintHints = [];
28920
- const inputSchema = normalizeNullableTypeArray(mergeSchemaAllOf(schema, numericConstraintHints));
28951
+ const inputSchema = normalizeNullableTypeArray(mergeSchemaAllOf(schema, numericConstraintHints), options.claudeValidated ? void 0 : numericConstraintHints);
28921
28952
  const schemaType = typeof inputSchema.type === "string" ? inputSchema.type.toUpperCase() : void 0;
28922
28953
  let result = {};
28923
28954
  const propertyNames = /* @__PURE__ */ new Set();
@@ -29268,7 +29299,7 @@ function wrapToolsAsFunctionDeclarations(payload) {
29268
29299
  passthroughToolCount: passthroughTools.length + (hasWebSearchTool && functionDeclarations.length === 0 ? 1 : 0)
29269
29300
  };
29270
29301
  }
29271
- var ALLOWED_SCHEMA_FIELDS, NUMERIC_SCHEMA_CONSTRAINTS, ALLOWED_JSON_SCHEMA_TYPES, CLAUDE_VALIDATED_HINT_FIELDS, VALID_ASPECT_RATIOS;
29302
+ var ALLOWED_SCHEMA_FIELDS, NUMERIC_SCHEMA_CONSTRAINTS, ALLOWED_JSON_SCHEMA_TYPES, TYPE_ARRAY_BRANCH_FIELDS, CLAUDE_VALIDATED_HINT_FIELDS, VALID_ASPECT_RATIOS;
29272
29303
  var init_gemini = __esm({
29273
29304
  "../core/dist/transform/gemini.js"() {
29274
29305
  "use strict";
@@ -29318,6 +29349,30 @@ var init_gemini = __esm({
29318
29349
  "object",
29319
29350
  "null"
29320
29351
  ]);
29352
+ TYPE_ARRAY_BRANCH_FIELDS = {
29353
+ object: [
29354
+ "properties",
29355
+ "required",
29356
+ "propertyOrdering",
29357
+ "additionalProperties"
29358
+ ],
29359
+ array: ["items", "minItems", "maxItems"],
29360
+ string: ["enum", "format", "minLength", "maxLength", "pattern"],
29361
+ number: [
29362
+ "minimum",
29363
+ "maximum",
29364
+ "exclusiveMinimum",
29365
+ "exclusiveMaximum",
29366
+ "multipleOf"
29367
+ ],
29368
+ integer: [
29369
+ "minimum",
29370
+ "maximum",
29371
+ "exclusiveMinimum",
29372
+ "exclusiveMaximum",
29373
+ "multipleOf"
29374
+ ]
29375
+ };
29321
29376
  CLAUDE_VALIDATED_HINT_FIELDS = /* @__PURE__ */ new Set([
29322
29377
  "minLength",
29323
29378
  "maxLength",
@@ -29982,6 +30037,15 @@ function assertRosterBinding(roster, attribution, claustrum) {
29982
30037
  if (!roster || !row?.enabled || row.state !== "active" || row.stale === true || row.unclaimed === true || row.credentialId !== attribution.credentialId || row.accountIdentity !== attribution.accountIdentity || claustrum.isDeclined(roster.declined, attribution.credentialId, attribution.accountIdentity))
29983
30038
  throw new VaultProviderStateError("binding-stale", "the vault route no longer serves the attributed credential and account");
29984
30039
  }
30040
+ function quotaBoundState(current, attribution) {
30041
+ if (current?.quota === void 0 || current.observed.routeId === attribution.routeId && current.observed.credentialId === attribution.credentialId)
30042
+ return current;
30043
+ return Object.freeze({
30044
+ observed: current.observed,
30045
+ ...current.metadata !== void 0 ? { metadata: current.metadata } : {},
30046
+ ...current.extensions !== void 0 ? { extensions: current.extensions } : {}
30047
+ });
30048
+ }
29985
30049
  async function commitVaultProviderState(input2) {
29986
30050
  const { claustrum, fs: fs7, statePath } = input2;
29987
30051
  input2.signal?.throwIfAborted();
@@ -29997,7 +30061,7 @@ async function commitVaultProviderState(input2) {
29997
30061
  const file = await readVaultProviderState(statePath);
29998
30062
  input2.signal?.throwIfAborted();
29999
30063
  const current = vaultAccountState(file, identity4);
30000
- const requested = input2.update(current);
30064
+ const requested = input2.update(quotaBoundState(current, attribution));
30001
30065
  if (isRecord9(requested) && typeof requested.then === "function")
30002
30066
  throw new VaultProviderStateError("invalid-update", "a state update must be synchronous");
30003
30067
  if (requested === void 0)
@@ -30105,7 +30169,7 @@ async function commitVaultProviderStates(input2) {
30105
30169
  const identity4 = entry.attribution.accountIdentity;
30106
30170
  const current = Object.hasOwn(accounts, identity4) ? accounts[identity4] : void 0;
30107
30171
  try {
30108
- const requested = entry.update(current);
30172
+ const requested = entry.update(quotaBoundState(current, entry.attribution));
30109
30173
  if (isRecord9(requested) && typeof requested.then === "function")
30110
30174
  throw new VaultProviderStateError("invalid-update", "a state update must be synchronous");
30111
30175
  if (requested === void 0 || requested === null && !current) {
@@ -30860,12 +30924,12 @@ async function replaceWindowsFile2(from, to, options = {}) {
30860
30924
  const delays = [0, 10, 20, 40, 80, 100];
30861
30925
  let original;
30862
30926
  let attempts2 = 0;
30863
- for (const delay3 of delays) {
30927
+ for (const delay4 of delays) {
30864
30928
  const deadline = Math.min(retryDeadline ?? Infinity, leaseDeadline);
30865
30929
  if (now() >= deadline)
30866
30930
  break;
30867
- if (delay3)
30868
- await (options.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms))))(Math.min(delay3, Math.max(0, deadline - now())));
30931
+ if (delay4)
30932
+ await (options.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms))))(Math.min(delay4, Math.max(0, deadline - now())));
30869
30933
  if (now() >= deadline)
30870
30934
  break;
30871
30935
  const fenceStart = now();
@@ -34376,8 +34440,8 @@ function isWindowsSharingError(error, platform) {
34376
34440
  }
34377
34441
  async function unlinkIfIdentical(file, stateDir, guard, io = { platform: process.platform, readFile: readFile12, unlink: unlink11 }) {
34378
34442
  const started = performance.now();
34379
- for (const delay3 of SHARING_RETRY_DELAYS_MS) {
34380
- if (delay3 > 0) await new Promise((done) => setTimeout(done, delay3));
34443
+ for (const delay4 of SHARING_RETRY_DELAYS_MS) {
34444
+ if (delay4 > 0) await new Promise((done) => setTimeout(done, delay4));
34381
34445
  let same;
34382
34446
  try {
34383
34447
  same = (await io.readFile(file.old)).equals(await io.readFile(file.next));
@@ -40728,12 +40792,12 @@ import { parse } from "jsonc-parser";
40728
40792
 
40729
40793
  // src/common-auth-embedded/setup/paths.js
40730
40794
  import { homedir as homedir7 } from "node:os";
40731
- import { posix, win32 } from "node:path";
40795
+ import { posix, win32 as win322 } from "node:path";
40732
40796
  import { fileURLToPath } from "node:url";
40733
40797
  function setupPaths(io = {}) {
40734
40798
  const env3 = io.env ?? process.env;
40735
40799
  const platform = io.platform ?? process.platform;
40736
- const path5 = platform === "win32" ? win32 : posix;
40800
+ const path5 = platform === "win32" ? win322 : posix;
40737
40801
  const home = io.home ?? (platform === "win32" ? env3.USERPROFILE : env3.HOME) ?? homedir7();
40738
40802
  const cwd = io.cwd ?? process.cwd();
40739
40803
  const absolute = (value) => path5.resolve(cwd, value);
@@ -40960,7 +41024,20 @@ import { setTimeout as delay } from "node:timers/promises";
40960
41024
  import { writeEnrollmentTokenFile as writeEnrollmentTokenFile3 } from "@cortexkit/claustrum-client";
40961
41025
 
40962
41026
  // src/common-auth-embedded/setup/process-fence.js
41027
+ import { statSync as statSync6 } from "node:fs";
41028
+ import { win32 as win323 } from "node:path";
40963
41029
  var WINDOWS_CIM_TIMEOUT_MS = 45e3;
41030
+ var WINDOWS_ARM_POWERSHELL_TIMEOUT_MS = 9e4;
41031
+ function isFile(file) {
41032
+ try {
41033
+ return statSync6(file).isFile();
41034
+ } catch {
41035
+ return false;
41036
+ }
41037
+ }
41038
+ function windowsEnv(env3, name) {
41039
+ return Object.entries(env3).find(([key]) => key.toUpperCase() === name.toUpperCase())?.[1];
41040
+ }
40964
41041
  var HOSTS = /* @__PURE__ */ new Set(["opencode", "litecode", "opencode2", "pi"]);
40965
41042
  var RUNTIMES = /* @__PURE__ */ new Set(["node", "bun"]);
40966
41043
  var WINDOWS_FENCE_FILTER = [...HOSTS, ...RUNTIMES].map((name) => `Name LIKE '${name}%'`).join(" OR ");
@@ -41032,6 +41109,7 @@ function hostName(command) {
41032
41109
  var ProcessInspectionError = class extends Error {
41033
41110
  code = "process-inspection-failed";
41034
41111
  step;
41112
+ program;
41035
41113
  exitCode;
41036
41114
  signal;
41037
41115
  timedOut;
@@ -41040,6 +41118,7 @@ var ProcessInspectionError = class extends Error {
41040
41118
  super("Process inspection failed; setup cannot prove hosts are stopped.");
41041
41119
  this.name = "ProcessInspectionError";
41042
41120
  this.step = details.step;
41121
+ this.program = details.program;
41043
41122
  this.exitCode = details.exitCode;
41044
41123
  this.signal = details.signal;
41045
41124
  this.timedOut = details.timedOut;
@@ -41067,6 +41146,8 @@ Please quit all OpenCode, LiteCode, and Pi processes before running setup.`);
41067
41146
  };
41068
41147
  async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
41069
41148
  const windows2 = (options.platform ?? process.platform) === "win32";
41149
+ const env3 = options.env ?? process.env;
41150
+ const system32 = windows2 ? win323.resolve(windowsEnv(env3, "SystemRoot") ?? windowsEnv(env3, "windir") ?? "C:\\Windows", "System32") : "";
41070
41151
  const selfPid = options.selfPid ?? process.pid;
41071
41152
  let inspection = {
41072
41153
  step: windows2 ? "tasklist" : "ps",
@@ -41075,10 +41156,11 @@ async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
41075
41156
  timedOut: false,
41076
41157
  durationMs: 0
41077
41158
  };
41078
- const inspect = async (step, file, args, timeoutMs) => {
41159
+ const inspect = async (step, file, args, timeoutMs, program) => {
41079
41160
  const started = performance.now();
41080
41161
  inspection = {
41081
41162
  step,
41163
+ ...program && { program },
41082
41164
  exitCode: null,
41083
41165
  signal: null,
41084
41166
  timedOut: false,
@@ -41091,6 +41173,7 @@ async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
41091
41173
  });
41092
41174
  inspection = {
41093
41175
  step,
41176
+ ...program && { program },
41094
41177
  exitCode: result.exitCode,
41095
41178
  signal: result.signal ?? null,
41096
41179
  timedOut: result.timedOut ?? false,
@@ -41103,9 +41186,23 @@ async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
41103
41186
  options.onStep?.({ ...inspection });
41104
41187
  }
41105
41188
  };
41189
+ const inspectCim = (args) => {
41190
+ const pwsh = win323.resolve(windowsEnv(env3, "ProgramFiles") ?? "C:\\Program Files", "PowerShell", "7", "pwsh.exe");
41191
+ const program = (options.isFile ?? isFile)(pwsh) ? "pwsh" : "powershell";
41192
+ const arm64 = (windowsEnv(env3, "PROCESSOR_ARCHITEW6432") ?? windowsEnv(env3, "PROCESSOR_ARCHITECTURE"))?.toUpperCase() === "ARM64";
41193
+ const slow = program === "powershell" && arm64;
41194
+ if (slow)
41195
+ 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.");
41196
+ 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);
41197
+ };
41106
41198
  try {
41107
41199
  if (windows2 && options.hostImagesOnly) {
41108
- const details = await inspect("CIM", "powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", WINDOWS_FENCE_QUERY], WINDOWS_CIM_TIMEOUT_MS);
41200
+ const details = await inspectCim([
41201
+ "-NoProfile",
41202
+ "-NonInteractive",
41203
+ "-Command",
41204
+ WINDOWS_FENCE_QUERY
41205
+ ]);
41109
41206
  if (details.exitCode !== 0)
41110
41207
  throw new ProcessInspectionError(inspection);
41111
41208
  const value = JSON.parse(details.stdout);
@@ -41127,7 +41224,7 @@ async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
41127
41224
  }
41128
41225
  return processes2;
41129
41226
  }
41130
- const result = await inspect(windows2 ? "tasklist" : "ps", windows2 ? "tasklist.exe" : "ps", windows2 ? ["/fo", "csv", "/nh"] : ["-eo", "pid,command"]);
41227
+ const result = await inspect(windows2 ? "tasklist" : "ps", windows2 ? win323.resolve(system32, "tasklist.exe") : "ps", windows2 ? ["/fo", "csv", "/nh"] : ["-eo", "pid,command"]);
41131
41228
  if (result.exitCode !== 0)
41132
41229
  throw new ProcessInspectionError(inspection);
41133
41230
  const processes = [];
@@ -41161,12 +41258,12 @@ async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
41161
41258
  throw new ProcessInspectionError(inspection);
41162
41259
  const runtimes = processes.filter((entry) => entry.pid !== selfPid && /^(?:node|bun)\.exe$/i.test(entry.command));
41163
41260
  if (windows2 && runtimes.length && options.inspectRuntimes !== false) {
41164
- const details = await inspect("CIM", "powershell.exe", [
41261
+ const details = await inspectCim([
41165
41262
  "-NoProfile",
41166
41263
  "-NonInteractive",
41167
41264
  "-Command",
41168
41265
  `$ErrorActionPreference = 'Stop'; Get-CimInstance Win32_Process -Filter "Name = 'node.exe' OR Name = 'bun.exe'" | Select-Object ProcessId,CommandLine | ConvertTo-Json -Compress`
41169
- ], WINDOWS_CIM_TIMEOUT_MS);
41266
+ ]);
41170
41267
  if (details.exitCode !== 0)
41171
41268
  throw new ProcessInspectionError(inspection);
41172
41269
  const value = JSON.parse(details.stdout || "null");
@@ -41222,6 +41319,36 @@ async function assertHostsStopped(fence, env3) {
41222
41319
  throw new ProcessFenceViolationError(active2);
41223
41320
  }
41224
41321
 
41322
+ // src/common-auth-embedded/setup/process-guard.js
41323
+ var SetupProcessGuard = class {
41324
+ inspect;
41325
+ now;
41326
+ #checkedAt;
41327
+ constructor(inspect, now = () => performance.now()) {
41328
+ this.inspect = inspect;
41329
+ this.now = now;
41330
+ }
41331
+ async check(options = {}) {
41332
+ if (options.reuse && this.#checkedAt !== void 0) {
41333
+ const age = this.now() - this.#checkedAt;
41334
+ if (age >= 0 && age < 5e3)
41335
+ return;
41336
+ }
41337
+ this.#checkedAt = void 0;
41338
+ await this.inspect();
41339
+ this.#checkedAt = this.now();
41340
+ }
41341
+ /** Callbacks, writes and waits can all make an earlier inspection stale. */
41342
+ async step(run) {
41343
+ this.#checkedAt = void 0;
41344
+ try {
41345
+ return await run();
41346
+ } finally {
41347
+ this.#checkedAt = void 0;
41348
+ }
41349
+ }
41350
+ };
41351
+
41225
41352
  // src/common-auth-embedded/setup/enroll.js
41226
41353
  var ENROLLMENT_INCOMPLETE_MESSAGE = "Claustrum enrollment did not complete. Inspect and approve with ck, then rerun setup.";
41227
41354
  var UNSUPPORTED_VAULT_MESSAGE = 'This Claustrum vault is too old to connect plugins. Run ck upgrade to move to Claustrum v0.2.0 or newer (read "Upgrading from v0.1.3" in its release notes first), or run setup without --claustrum to use local accounts.';
@@ -41250,7 +41377,8 @@ async function connectSetupHost(plugin, host, io, terminal, fence) {
41250
41377
  throw new Error(VAULT_HOST_CONNECT_REFUSAL2);
41251
41378
  const { name, displayName, requestedGrants, grantFallback, paths: input2 } = plugin.vault.hosts[host];
41252
41379
  const paths = hostEnrollmentPaths2(input2);
41253
- await fence();
41380
+ const guard = typeof fence === "function" ? new SetupProcessGuard(fence, io.now) : fence;
41381
+ await guard.check({ reuse: true });
41254
41382
  const client = await (io.connect ?? connectClaustrumEnrollmentClient2)({
41255
41383
  connectionFile: plugin.vault.connectionFile,
41256
41384
  handshakeTimeoutMs: 2e3
@@ -41271,11 +41399,10 @@ async function connectSetupHost(plugin, host, io, terminal, fence) {
41271
41399
  // starts PowerShell.
41272
41400
  client,
41273
41401
  writeTokenFile: async (path5, file) => {
41274
- await fence();
41275
- await writeEnrollmentTokenFile3(path5, file);
41402
+ await guard.check();
41403
+ await guard.step(() => writeEnrollmentTokenFile3(path5, file));
41276
41404
  }
41277
41405
  });
41278
- await fence();
41279
41406
  const initial = await manager.status();
41280
41407
  if (initial.state === "approved") {
41281
41408
  printLine2(terminal, `Already connected as ${initial.approvedName ?? initial.proposedName}.`);
@@ -41292,7 +41419,8 @@ async function connectSetupHost(plugin, host, io, terminal, fence) {
41292
41419
  let reportedCode;
41293
41420
  let failedProposals = 0;
41294
41421
  for (; ; ) {
41295
- const status = await manager.reconcile();
41422
+ await guard.check({ reuse: true });
41423
+ const status = await guard.step(() => manager.reconcile());
41296
41424
  if (status.state === "approved") {
41297
41425
  printLine2(terminal, `Connected ${host} to Claustrum.`);
41298
41426
  const access = await confirmEnrollmentAccess(client, status, paths.tokenPath, requestedGrants);
@@ -41340,8 +41468,8 @@ async function connectSetupHost(plugin, host, io, terminal, fence) {
41340
41468
  const remaining = deadline - now();
41341
41469
  if (remaining <= 0)
41342
41470
  break;
41343
- await wait2(Math.min(pause, remaining));
41344
- await fence();
41471
+ await guard.step(() => wait2(Math.min(pause, remaining)));
41472
+ await guard.check();
41345
41473
  }
41346
41474
  if (printedRequest)
41347
41475
  throw new HostNotEnrolledError(`Claustrum approval is still pending. In another terminal, run: ${approveCommand(printedRequest, name)} and then rerun setup.`, {
@@ -41491,6 +41619,8 @@ async function selectSetupHosts(terminal, found) {
41491
41619
  }
41492
41620
 
41493
41621
  // src/common-auth-embedded/setup/register.js
41622
+ import { rename as rename14 } from "node:fs/promises";
41623
+ import { setTimeout as delay3 } from "node:timers/promises";
41494
41624
  import { domainToUnicode } from "node:url";
41495
41625
  import { applyEdits, createScanner, findNodeAtLocation, modify, parse as parse2, parseTree } from "jsonc-parser";
41496
41626
 
@@ -41700,12 +41830,15 @@ function planOpenCodeRegistration(plugin, generation, io = {}) {
41700
41830
  });
41701
41831
  }
41702
41832
  async function registerOpenCode(writes, beforeWrite) {
41833
+ const guard = typeof beforeWrite === "function" ? new SetupProcessGuard(beforeWrite) : beforeWrite;
41703
41834
  for (const write of writes) {
41704
41835
  if (!write.changed)
41705
41836
  continue;
41706
- await beforeWrite?.();
41707
41837
  await writeHostConfigAtomic(write.path, write.content, {
41708
- beforeRename: beforeWrite
41838
+ // Only the rename publishes host-readable config; recheck on every retry.
41839
+ beforeRename: guard ? () => guard.check({ reuse: true }) : void 0,
41840
+ rename: guard ? (from, to) => guard.step(() => rename14(from, to)) : void 0,
41841
+ wait: guard ? (ms) => guard.step(() => delay3(ms)) : void 0
41709
41842
  });
41710
41843
  }
41711
41844
  }
@@ -41804,7 +41937,11 @@ async function runSetup(plugin, argv = [], io = {}) {
41804
41937
  return { hosts, dryRun: options.dryRun, mode: "local", detection };
41805
41938
  }
41806
41939
  const { env: env3, platform } = setupPaths(io);
41807
- const fence = io.fence ?? createProcessFence(io.runner ?? defaultCommandRunner, { platform });
41940
+ const fence = io.fence ?? createProcessFence(io.runner ?? defaultCommandRunner, {
41941
+ platform,
41942
+ isFile: io.fs?.isFile.bind(io.fs),
41943
+ onProgress: (line) => printLine2(terminal, line)
41944
+ });
41808
41945
  const stopped = async () => {
41809
41946
  try {
41810
41947
  await assertHostsStopped(fence, env3);
@@ -41814,6 +41951,7 @@ async function runSetup(plugin, argv = [], io = {}) {
41814
41951
  throw error;
41815
41952
  }
41816
41953
  };
41954
+ const guard = new SetupProcessGuard(stopped, io.now);
41817
41955
  printLine2(terminal, "Checking that OpenCode and Pi are not running\u2026");
41818
41956
  if (options.dryRun) {
41819
41957
  try {
@@ -41829,16 +41967,17 @@ async function runSetup(plugin, argv = [], io = {}) {
41829
41967
  if (error instanceof ProcessInspectionError)
41830
41968
  printLine2(terminal, error.refusalText);
41831
41969
  }
41832
- } else
41833
- await stopped();
41970
+ } else {
41971
+ await guard.check();
41972
+ }
41834
41973
  if ((options.claustrum || options.enrollOnly) && !detection.claustrum.available)
41835
41974
  throw new Error("Claustrum is not available. Start ck, or omit vault-only flags and use --no-claustrum for local sign-in.");
41836
41975
  let useVault = options.claustrum || options.enrollOnly;
41837
41976
  if (!useVault && !options.login && !options.noClaustrum && !assumeYes && detection.claustrum.available && isInteractive2(terminal)) {
41838
- const choice = await select2(terminal, [
41977
+ const choice = await guard.step(() => select2(terminal, [
41839
41978
  { label: "No", value: false },
41840
41979
  { label: "Yes", value: true }
41841
- ], { message: "Connect these hosts to the Claustrum vault?" });
41980
+ ], { message: "Connect these hosts to the Claustrum vault?" }));
41842
41981
  if (choice === null) {
41843
41982
  printLine2(terminal, "Setup cancelled. Nothing was changed.");
41844
41983
  return { hosts: [], dryRun: options.dryRun, mode: "local", detection };
@@ -41889,13 +42028,14 @@ ${write.content}`);
41889
42028
  const enrollmentAccess = /* @__PURE__ */ new Map();
41890
42029
  try {
41891
42030
  for (const host of hosts) {
41892
- await stopped();
41893
- await plugin.beforeSignIn?.(host, context);
41894
- await stopped();
42031
+ if (plugin.beforeSignIn) {
42032
+ await guard.check({ reuse: true });
42033
+ await guard.step(() => plugin.beforeSignIn?.(host, context));
42034
+ }
41895
42035
  if (useVault) {
41896
42036
  enrollment.set(host, "unknown");
41897
42037
  try {
41898
- const access = await connectSetupHost(plugin, host, io, terminal, stopped);
42038
+ const access = await connectSetupHost(plugin, host, io, terminal, guard);
41899
42039
  if (access)
41900
42040
  enrollmentAccess.set(host, access);
41901
42041
  } catch (error) {
@@ -41904,19 +42044,26 @@ ${write.content}`);
41904
42044
  throw error;
41905
42045
  }
41906
42046
  enrollment.set(host, "enrolled");
41907
- } else
41908
- await plugin.signInLocal(host, context);
41909
- await stopped();
42047
+ } else {
42048
+ await guard.check({ reuse: true });
42049
+ await guard.step(() => plugin.signInLocal(host, context));
42050
+ }
41910
42051
  if (options.enrollOnly)
41911
42052
  continue;
41912
- await plugin.beforeRegister?.(host, mode, context);
41913
- await stopped();
42053
+ if (plugin.beforeRegister) {
42054
+ await guard.check({ reuse: true });
42055
+ await guard.step(() => plugin.beforeRegister?.(host, mode, context));
42056
+ }
41914
42057
  if (host === "opencode")
41915
- await registerOpenCode(writes, stopped);
41916
- else
41917
- await registerPi(plugin, detection.pi.executable, io);
41918
- await stopped();
41919
- await plugin.migrate?.(host, context);
42058
+ await registerOpenCode(writes, guard);
42059
+ else {
42060
+ await guard.check({ reuse: true });
42061
+ await guard.step(() => registerPi(plugin, detection.pi.executable, io));
42062
+ }
42063
+ if (plugin.migrate) {
42064
+ await guard.check({ reuse: true });
42065
+ await guard.step(() => plugin.migrate?.(host, context));
42066
+ }
41920
42067
  }
41921
42068
  } catch (error) {
41922
42069
  if (enrollment.size === 0)
@@ -43579,7 +43726,7 @@ function isSessionId(value) {
43579
43726
  // src/common-auth-embedded/rpc/port-file.js
43580
43727
  init_private_files2();
43581
43728
  import { createHash as createHash15, randomUUID as randomUUID19 } from "node:crypto";
43582
- import { chmod as chmod7, mkdir as mkdir17, open as open12, readdir as readdir6, rename as rename14, rmdir as rmdir3, stat as stat17, unlink as unlink15 } from "node:fs/promises";
43729
+ import { chmod as chmod7, mkdir as mkdir17, open as open12, readdir as readdir6, rename as rename15, rmdir as rmdir3, stat as stat17, unlink as unlink15 } from "node:fs/promises";
43583
43730
  import { uptime as uptime2 } from "node:os";
43584
43731
  import { join as join30, resolve as resolve26 } from "node:path";
43585
43732
  function staleBefore(clock2) {
@@ -43661,7 +43808,7 @@ async function writePortFile(dir, entry, options = {}) {
43661
43808
  await handle.chmod(384);
43662
43809
  await handle.close();
43663
43810
  handle = void 0;
43664
- await rename14(tmp, target);
43811
+ await rename15(tmp, target);
43665
43812
  created = false;
43666
43813
  } finally {
43667
43814
  await handle?.close().catch(() => {
@@ -44936,7 +45083,7 @@ import { join as join33, resolve as resolve28 } from "node:path";
44936
45083
  // ../core/dist/common-auth-embedded/tui-prefs/watcher.js
44937
45084
  init_canonical_file_path();
44938
45085
  init_private_files();
44939
- import { lstatSync, readFileSync as readFileSync8, readlinkSync, realpathSync as realpathSync5, statSync as statSync7, watch } from "node:fs";
45086
+ import { lstatSync, readFileSync as readFileSync8, readlinkSync, realpathSync as realpathSync5, statSync as statSync8, watch } from "node:fs";
44940
45087
  import { readFile as readFile17, stat as stat18 } from "node:fs/promises";
44941
45088
  import { basename as basename10, dirname as dirname24, join as join32, resolve as resolve27 } from "node:path";
44942
45089
  import { clearTimeout as clearTimeout2, setTimeout as setTimeout2 } from "node:timers";
@@ -44980,7 +45127,7 @@ function watchFile(file, onChange, options, settings) {
44980
45127
  let lastSeen = null;
44981
45128
  if (settings || !windowsPrivateFiles)
44982
45129
  try {
44983
- const metadata = identity3((options.fs?.statSync ?? statSync7)(path5), settings);
45130
+ const metadata = identity3((options.fs?.statSync ?? statSync8)(path5), settings);
44984
45131
  lastSeen = (options.fs?.readFileSync ?? ((file2) => readFileSync8(file2, "utf8")))(path5);
44985
45132
  lastMetadata = metadata;
44986
45133
  } catch {
@@ -46324,7 +46471,7 @@ async function moveSettingsOnce(options) {
46324
46471
  }
46325
46472
 
46326
46473
  // ../core/dist/common-auth-embedded/settings/paths.js
46327
- import { posix as posix2, win32 as win322 } from "node:path";
46474
+ import { posix as posix2, win32 as win324 } from "node:path";
46328
46475
  function isAbsoluteForPlatform(path5, platform) {
46329
46476
  if (platform !== "win32")
46330
46477
  return path5.startsWith("/");
@@ -46335,7 +46482,7 @@ function isAbsoluteForPlatform(path5, platform) {
46335
46482
  return /^[\\/]{2}[^\\/]+[\\/][^\\/]+/.test(path5);
46336
46483
  }
46337
46484
  function cortexkitConfigDir({ env: env3, platform, homedir: homedir17 }) {
46338
- const paths = platform === "win32" ? win322 : posix2;
46485
+ const paths = platform === "win32" ? win324 : posix2;
46339
46486
  const absolute = (value) => value !== void 0 && isAbsoluteForPlatform(value, platform);
46340
46487
  let base;
46341
46488
  if (absolute(env3.XDG_CONFIG_HOME)) {
@@ -46358,7 +46505,7 @@ function settingsFilePath({ plugin, override, ...options }) {
46358
46505
  if (override && isAbsoluteForPlatform(override, options.platform)) {
46359
46506
  return override;
46360
46507
  }
46361
- const paths = options.platform === "win32" ? win322 : posix2;
46508
+ const paths = options.platform === "win32" ? win324 : posix2;
46362
46509
  return paths.join(cortexkitConfigDir(options), `${plugin}.jsonc`);
46363
46510
  }
46364
46511
 
@@ -47062,9 +47209,9 @@ init_version_fence();
47062
47209
 
47063
47210
  // src/settings/location.ts
47064
47211
  import { realpath as realpath6 } from "node:fs/promises";
47065
- import { posix as posix3, win32 as win323 } from "node:path";
47212
+ import { posix as posix3, win32 as win325 } from "node:path";
47066
47213
  async function folderIdentity(folder, platform) {
47067
- const paths = platform === "win32" ? win323 : posix3;
47214
+ const paths = platform === "win32" ? win325 : posix3;
47068
47215
  try {
47069
47216
  return await realpath6(folder);
47070
47217
  } catch {
@@ -47073,7 +47220,7 @@ async function folderIdentity(folder, platform) {
47073
47220
  }
47074
47221
  async function resolveSettingsLocation(options) {
47075
47222
  const { env: env3, platform, homedir: homedir17 } = options;
47076
- const paths = platform === "win32" ? win323 : posix3;
47223
+ const paths = platform === "win32" ? win325 : posix3;
47077
47224
  const override = env3.OPENCODE_ANTIGRAVITY_AUTH_SETTINGS_FILE;
47078
47225
  const file = settingsFilePath({
47079
47226
  plugin: "antigravity-auth",
@@ -47450,12 +47597,12 @@ function createSettingsRuntime(options) {
47450
47597
  void enqueue(refreshAll);
47451
47598
  });
47452
47599
  };
47453
- const scheduleAttempt = (delay3) => {
47600
+ const scheduleAttempt = (delay4) => {
47454
47601
  if (disposed) return;
47455
47602
  retryTimer = setTimeout(() => {
47456
47603
  retryTimer = void 0;
47457
47604
  void enqueue(attemptMove);
47458
- }, delay3);
47605
+ }, delay4);
47459
47606
  retryTimer.unref?.();
47460
47607
  };
47461
47608
  const attemptMove = async () => {
@@ -58449,14 +58596,14 @@ var BackgroundVaultQuotaRefresh = class {
58449
58596
  this.abortTick();
58450
58597
  await this.inFlight;
58451
58598
  }
58452
- schedule(delay3, intervalWait = null) {
58599
+ schedule(delay4, intervalWait = null) {
58453
58600
  if (this.disposed || !this.started) return;
58454
58601
  this.intervalWait = intervalWait;
58455
58602
  this.timer = setTimeout(() => {
58456
58603
  this.timer = null;
58457
58604
  this.intervalWait = null;
58458
58605
  void this.tick();
58459
- }, delay3);
58606
+ }, delay4);
58460
58607
  this.timer.unref?.();
58461
58608
  }
58462
58609
  /** One serialized tick; also used by deterministic composition tests. */
@@ -59393,6 +59540,7 @@ function routingHandle(sessionId) {
59393
59540
  var CACHE_WARM_STOP_REASONS = [
59394
59541
  "cost-cap",
59395
59542
  "count-cap",
59543
+ "deadline-missed",
59396
59544
  "outside-hours",
59397
59545
  "session-ended",
59398
59546
  "unsupported"