omnius 1.0.971 → 1.0.972

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.
@@ -304306,6 +304306,11 @@ function readDaemonSupervisionHealth(port, options = {}) {
304306
304306
  const record2 = pruneExpiredAttempts(readRecord(port, now, options), now, policy);
304307
304307
  return toHealth(record2, now, policy);
304308
304308
  }
304309
+ function findVerifiedDaemonSignalLease(pid, port, leases) {
304310
+ return leases.find(
304311
+ (lease) => lease.pid === pid && lease.status === "active" && lease.ownerKind === "daemon" && lease.ownerId === `daemon:${port}`
304312
+ ) ?? null;
304313
+ }
304309
304314
  var DAEMON_SUPERVISION_SCHEMA;
304310
304315
  var init_daemon_supervision = __esm({
304311
304316
  "packages/cli/src/daemon-supervision.ts"() {
@@ -304700,7 +304705,7 @@ var init_daemon_service = __esm({
304700
304705
 
304701
304706
  // packages/cli/src/daemon.ts
304702
304707
  import { spawn as spawn2 } from "node:child_process";
304703
- import { existsSync as existsSync7, readFileSync as readFileSync6, writeFileSync as writeFileSync4, mkdirSync as mkdirSync6, unlinkSync as unlinkSync2, openSync as openSync2, closeSync as closeSync2, writeSync, statSync as statSync2, renameSync as renameSync4 } from "node:fs";
304708
+ import { existsSync as existsSync7, readFileSync as readFileSync6, writeFileSync as writeFileSync4, mkdirSync as mkdirSync6, unlinkSync as unlinkSync2, openSync as openSync2, closeSync as closeSync2, writeSync, lstatSync as lstatSync2, statSync as statSync2, renameSync as renameSync4 } from "node:fs";
304704
304709
  import { join as join15 } from "node:path";
304705
304710
  import { homedir as homedir15 } from "node:os";
304706
304711
  import { createServer as createNetServer } from "node:net";
@@ -304729,10 +304734,52 @@ function processIsAlive(pid) {
304729
304734
  return error.code !== "ESRCH";
304730
304735
  }
304731
304736
  }
304737
+ function readLinuxBootId() {
304738
+ if (process.platform !== "linux") return;
304739
+ try {
304740
+ const id2 = readFileSync6("/proc/sys/kernel/random/boot_id", "utf8").trim();
304741
+ return LINUX_BOOT_ID.test(id2) ? id2 : void 0;
304742
+ } catch {
304743
+ return;
304744
+ }
304745
+ }
304746
+ function readLinuxProcessBirth(pid) {
304747
+ try {
304748
+ const stat = readFileSync6(`/proc/${pid}/stat`, "utf8");
304749
+ const fields = stat.slice(stat.lastIndexOf(")") + 2).trim().split(/\s+/);
304750
+ const state = fields[0], start = fields[19];
304751
+ return state && start && /^\d+$/.test(start) ? { start, state } : void 0;
304752
+ } catch {
304753
+ return;
304754
+ }
304755
+ }
304756
+ function currentDaemonLockIdentity() {
304757
+ const bootId = readLinuxBootId();
304758
+ const birth = bootId && readLinuxProcessBirth(process.pid);
304759
+ return birth ? { bootId, processStart: birth.start } : {};
304760
+ }
304761
+ function daemonLockOwnerIsStale(record2) {
304762
+ if (process.platform !== "linux") return false;
304763
+ if (record2.bootId === void 0 && record2.processStart === void 0) {
304764
+ try {
304765
+ const seconds = readFileSync6("/proc/stat", "utf8").match(/^btime (\d+)$/m)?.[1];
304766
+ const bootTime = Number(seconds) * 1e3;
304767
+ return Number.isSafeInteger(bootTime) && bootTime > 0 && record2.startedAt < bootTime;
304768
+ } catch {
304769
+ return false;
304770
+ }
304771
+ }
304772
+ if (typeof record2.bootId !== "string" || !LINUX_BOOT_ID.test(record2.bootId) || typeof record2.processStart !== "string" || !/^\d+$/.test(record2.processStart)) return false;
304773
+ const bootId = readLinuxBootId();
304774
+ if (!bootId) return false;
304775
+ if (record2.bootId.toLowerCase() !== bootId.toLowerCase()) return true;
304776
+ const birth = readLinuxProcessBirth(record2.pid);
304777
+ return Boolean(birth && (birth.start !== record2.processStart || birth.state === "Z" || birth.state === "X"));
304778
+ }
304732
304779
  function readDaemonLock(lockFile) {
304733
304780
  try {
304734
304781
  const value = JSON.parse(readFileSync6(lockFile, "utf8"));
304735
- if (typeof value.endpoint !== "string" || typeof value.pid !== "number" || !Number.isInteger(value.pid) || value.pid <= 0 || typeof value.token !== "string" || typeof value.startedAt !== "number") {
304782
+ if (typeof value.endpoint !== "string" || typeof value.pid !== "number" || !Number.isInteger(value.pid) || value.pid <= 0 || typeof value.token !== "string" || typeof value.startedAt !== "number" || !Number.isFinite(value.startedAt) || value.startedAt < 0) {
304736
304783
  return null;
304737
304784
  }
304738
304785
  return value;
@@ -304760,7 +304807,8 @@ function claimDaemonEndpoint(port = getDaemonPort(), inheritedToken) {
304760
304807
  endpoint,
304761
304808
  pid: process.pid,
304762
304809
  token,
304763
- startedAt: Date.now()
304810
+ startedAt: Date.now(),
304811
+ ...currentDaemonLockIdentity()
304764
304812
  };
304765
304813
  let fd = null;
304766
304814
  try {
@@ -304784,16 +304832,18 @@ function claimDaemonEndpoint(port = getDaemonPort(), inheritedToken) {
304784
304832
  }
304785
304833
  const existing = readDaemonLock(lockFile);
304786
304834
  if (existing?.endpoint === endpoint && inheritedToken && existing.token === inheritedToken) {
304787
- const transferred = { ...existing, pid: process.pid, startedAt: Date.now() };
304788
- writeFileSync4(lockFile, JSON.stringify(transferred), { encoding: "utf8", mode: 384 });
304835
+ writeFileSync4(lockFile, JSON.stringify(record2), { encoding: "utf8", mode: 384 });
304789
304836
  return { endpoint, lockFile, pid: process.pid, port, token: inheritedToken };
304790
304837
  }
304791
- if (existing && processIsAlive(existing.pid) || !existing && daemonLockIsInitializing(lockFile)) {
304792
- return null;
304793
- }
304794
- try {
304795
- unlinkSync2(lockFile);
304796
- } catch {
304838
+ if (existing) {
304839
+ if (existing.endpoint !== endpoint || processIsAlive(existing.pid) && !daemonLockOwnerIsStale(existing)) return null;
304840
+ if (!removeDaemonLockIfUnchanged(port, existing)) return null;
304841
+ } else {
304842
+ if (daemonLockIsInitializing(lockFile)) return null;
304843
+ try {
304844
+ unlinkSync2(lockFile);
304845
+ } catch {
304846
+ }
304797
304847
  }
304798
304848
  }
304799
304849
  return null;
@@ -304837,16 +304887,18 @@ async function getDaemonReportedIdentity(port) {
304837
304887
  return null;
304838
304888
  }
304839
304889
  }
304840
- async function waitForDaemonReady(port, expectedVersion, attempts = 24) {
304890
+ async function waitForDaemonReady(port, expectedVersion, attempts = 24, startupEnded) {
304841
304891
  let observedVersion = null;
304842
304892
  for (let attempt = 0; attempt < attempts; attempt++) {
304843
304893
  await new Promise((resolve13) => setTimeout(resolve13, 500));
304844
304894
  const identity = await getDaemonReportedIdentity(port);
304845
- if (!identity) continue;
304846
- observedVersion = identity.bootVersion;
304847
- if (!expectedVersion || expectedVersion === "0.0.0" || observedVersion === expectedVersion) {
304848
- return { ok: true, observedVersion };
304895
+ if (identity) {
304896
+ observedVersion = identity.bootVersion;
304897
+ if (!expectedVersion || expectedVersion === "0.0.0" || observedVersion === expectedVersion) {
304898
+ return { ok: true, observedVersion };
304899
+ }
304849
304900
  }
304901
+ if (startupEnded?.()) break;
304850
304902
  }
304851
304903
  return { ok: false, observedVersion };
304852
304904
  }
@@ -305062,10 +305114,13 @@ async function waitForDaemonStopped(port, attempts = DAEMON_GRACEFUL_STOP_ATTEMP
305062
305114
  }
305063
305115
  function removeDaemonLockIfUnchanged(port, expected) {
305064
305116
  const lockFile = daemonLockFile(port);
305065
- const current = readDaemonLock(lockFile);
305066
- if (!current) return true;
305067
- if (current.pid !== expected.pid || current.token !== expected.token) return false;
305068
305117
  try {
305118
+ const before = lstatSync2(lockFile);
305119
+ if (!before.isFile()) return false;
305120
+ const current = readDaemonLock(lockFile);
305121
+ if (!current || current.endpoint !== expected.endpoint || current.pid !== expected.pid || current.token !== expected.token || current.startedAt !== expected.startedAt || current.bootId !== expected.bootId || current.processStart !== expected.processStart) return false;
305122
+ const after = lstatSync2(lockFile);
305123
+ if (before.dev !== after.dev || before.ino !== after.ino || before.ctimeMs !== after.ctimeMs) return false;
305069
305124
  unlinkSync2(lockFile);
305070
305125
  return true;
305071
305126
  } catch (error) {
@@ -305075,9 +305130,10 @@ function removeDaemonLockIfUnchanged(port, expected) {
305075
305130
  async function reclaimStaleDaemonEndpointClaim(port, verifiedStoppedPids = /* @__PURE__ */ new Set(), dependencies = DEFAULT_CLAIM_RECLAIM_DEPENDENCIES) {
305076
305131
  const record2 = dependencies.readLock(port);
305077
305132
  if (!record2) return dependencies.portIsFree(port);
305133
+ if (record2.endpoint !== daemonEndpoint(port)) return false;
305078
305134
  if (!await dependencies.portIsFree(port)) return false;
305079
305135
  const clearExactClaim = async () => dependencies.removeLockIfUnchanged(port, record2) && dependencies.portIsFree(port);
305080
- if (verifiedStoppedPids.has(record2.pid) || !dependencies.processIsAlive(record2.pid)) {
305136
+ if (verifiedStoppedPids.has(record2.pid) || !dependencies.processIsAlive(record2.pid) || dependencies.ownerIsStale?.(record2)) {
305081
305137
  return clearExactClaim();
305082
305138
  }
305083
305139
  const lease = dependencies.leases().find(
@@ -305170,7 +305226,7 @@ async function restartDaemon(port, expectedVersion, preferredEntrypoint, service
305170
305226
  if (managed) {
305171
305227
  if (!await scopedDaemonServiceOwnsPort(managed, p)) {
305172
305228
  const holders = await portHolderPids(p);
305173
- if (!holders || holders.some((pid2) => pidIsInManagedDaemonUnit(pid2))) return false;
305229
+ if (!holders || holders.some((pid) => pidIsInManagedDaemonUnit(pid))) return false;
305174
305230
  const reclaimed2 = await reclaimOwnedDaemonListener(p);
305175
305231
  if (!reclaimed2.ok) return false;
305176
305232
  await reclaimStaleDaemonEndpointClaim(p, new Set(reclaimed2.clearedPids));
@@ -305203,9 +305259,9 @@ async function restartDaemon(port, expectedVersion, preferredEntrypoint, service
305203
305259
  const reclaimed = await reclaimOwnedDaemonListener(p);
305204
305260
  if (!reclaimed.ok) return false;
305205
305261
  if (!await reclaimStaleDaemonEndpointClaim(p, new Set(reclaimed.clearedPids))) return false;
305206
- const pid = await startDaemon(p, preferredEntrypoint);
305207
- if (!pid) return false;
305208
- return (await waitForDaemonReady(p, expectedVersion)).ok;
305262
+ const launch = await launchDetachedDaemon(p, preferredEntrypoint);
305263
+ if (!launch) return false;
305264
+ return (await settleDetachedDaemonStartup(launch, expectedVersion)).ok;
305209
305265
  }
305210
305266
  function looksLikeNodeEntrypoint(path3) {
305211
305267
  if (/\.(?:mjs|cjs|js)$/i.test(path3)) return true;
@@ -305269,25 +305325,28 @@ async function reinstallUserDaemonService(port, expectedVersion, preferredEntryp
305269
305325
  return false;
305270
305326
  }
305271
305327
  }
305272
- async function startDaemon(port = getDaemonPort(), preferredEntrypoint) {
305328
+ function daemonChildHasExited(child) {
305329
+ return child.exitCode !== null || child.signalCode !== null;
305330
+ }
305331
+ async function launchDetachedDaemon(port, preferredEntrypoint) {
305273
305332
  mkdirSync6(OMNIUS_DIR, { recursive: true });
305274
305333
  const daemonPort = port;
305275
305334
  const endpointClaim = claimDaemonEndpoint(daemonPort);
305276
305335
  if (!endpointClaim) return null;
305277
- const nodeExe = process.execPath;
305278
- const daemonCommand = await resolveDaemonCommand(nodeExe, preferredEntrypoint);
305279
- if (!daemonCommand) {
305280
- releaseDaemonEndpointClaim(endpointClaim);
305281
- return null;
305282
- }
305283
305336
  let outFd = null;
305284
305337
  let errFd = null;
305338
+ let child;
305285
305339
  try {
305340
+ const daemonCommand = await resolveDaemonCommand(process.execPath, preferredEntrypoint);
305341
+ if (!daemonCommand) {
305342
+ releaseDaemonEndpointClaim(endpointClaim);
305343
+ return null;
305344
+ }
305286
305345
  outFd = openSync2(join15(OMNIUS_DIR, "daemon.log"), "a");
305287
305346
  errFd = openSync2(join15(OMNIUS_DIR, "daemon.err.log"), "a");
305288
305347
  const leaseId = newProcessLeaseId("daemon");
305289
305348
  const ownerId = `daemon:${daemonPort}`;
305290
- const child = spawn2(daemonCommand.command, daemonCommand.args, {
305349
+ const launchedChild = child = spawn2(daemonCommand.command, daemonCommand.args, {
305291
305350
  detached: true,
305292
305351
  stdio: ["ignore", outFd, errFd],
305293
305352
  env: {
@@ -305303,27 +305362,34 @@ async function startDaemon(port = getDaemonPort(), preferredEntrypoint) {
305303
305362
  OMNIUS_PROCESS_PERSISTENT: "1"
305304
305363
  }
305305
305364
  });
305306
- child.unref();
305307
- const pid = child.pid ?? null;
305308
- if (pid) {
305309
- writeFileSync4(PID_FILE, String(pid), "utf8");
305310
- registerProcessLease({
305311
- leaseId,
305312
- pid,
305313
- pgid: process.platform === "win32" ? void 0 : pid,
305314
- ownerKind: "daemon",
305315
- ownerId,
305316
- projectRoot: process.cwd(),
305317
- lifecycle: "daemon",
305318
- persistent: true,
305319
- reason: `shared API daemon on port ${daemonPort}`,
305320
- command: [daemonCommand.command, ...daemonCommand.args].join(" "),
305321
- cwd: process.cwd()
305322
- });
305365
+ const launched = await new Promise((resolve13) => {
305366
+ launchedChild.once("spawn", () => resolve13(true));
305367
+ launchedChild.once("error", () => resolve13(false));
305368
+ });
305369
+ const pid = child.pid;
305370
+ if (!launched || !pid) {
305371
+ releaseDaemonEndpointClaim(endpointClaim);
305372
+ return null;
305323
305373
  }
305324
- return pid;
305374
+ child.unref();
305375
+ child.once("exit", () => releaseDaemonEndpointClaim(endpointClaim));
305376
+ registerProcessLease({
305377
+ leaseId,
305378
+ pid,
305379
+ pgid: process.platform === "win32" ? void 0 : pid,
305380
+ ownerKind: "daemon",
305381
+ ownerId,
305382
+ projectRoot: process.cwd(),
305383
+ lifecycle: "daemon",
305384
+ persistent: true,
305385
+ reason: `shared API daemon on port ${daemonPort}`,
305386
+ command: [daemonCommand.command, ...daemonCommand.args].join(" "),
305387
+ cwd: process.cwd()
305388
+ });
305389
+ writeFileSync4(PID_FILE, String(pid), "utf8");
305390
+ return { child, pid, claim: endpointClaim, leaseId };
305325
305391
  } catch {
305326
- releaseDaemonEndpointClaim(endpointClaim);
305392
+ if (!child?.pid || daemonChildHasExited(child)) releaseDaemonEndpointClaim(endpointClaim);
305327
305393
  return null;
305328
305394
  } finally {
305329
305395
  if (outFd !== null) try {
@@ -305336,6 +305402,38 @@ async function startDaemon(port = getDaemonPort(), preferredEntrypoint) {
305336
305402
  }
305337
305403
  }
305338
305404
  }
305405
+ async function settleDetachedDaemonStartup(launch, expectedVersion, attempts) {
305406
+ const { child, claim, pid, leaseId } = launch;
305407
+ const readOwnClaim = () => {
305408
+ const current2 = readDaemonLock(claim.lockFile);
305409
+ return current2?.token === claim.token && current2.endpoint === claim.endpoint ? current2 : null;
305410
+ };
305411
+ const ready = await waitForDaemonReady(
305412
+ claim.port,
305413
+ expectedVersion,
305414
+ attempts,
305415
+ () => daemonChildHasExited(child) && (readOwnClaim()?.pid ?? claim.pid) === claim.pid
305416
+ );
305417
+ if (ready.ok) return ready;
305418
+ const current = readOwnClaim();
305419
+ const ownerPid = current && current.pid !== claim.pid ? current.pid : pid;
305420
+ let settled = ownerPid === pid && daemonChildHasExited(child);
305421
+ if (!settled) {
305422
+ const lease = findVerifiedDaemonSignalLease(ownerPid, claim.port, listProcessLeases({ includeInactive: false }));
305423
+ if (lease?.leaseId === leaseId) {
305424
+ const stopped = await stopDaemonLeaseGracefully(leaseId, "daemon readiness deadline expired");
305425
+ settled = stopped.action === "dead" || stopped.action === "killed";
305426
+ }
305427
+ }
305428
+ if (settled) {
305429
+ releaseDaemonEndpointClaim({ ...claim, pid: current?.pid ?? claim.pid });
305430
+ try {
305431
+ if (readFileSync6(PID_FILE, "utf8").trim() === String(pid)) unlinkSync2(PID_FILE);
305432
+ } catch {
305433
+ }
305434
+ }
305435
+ return ready;
305436
+ }
305339
305437
  async function stopDaemonAtPort(port = getDaemonPort(), dependencies) {
305340
305438
  const deps = dependencies ?? daemonStopDependencies(await discoverDaemonServiceAtPort(port));
305341
305439
  if (await deps.managedServiceMatchesPort(port)) return await deps.stopManagedService() && await deps.waitForStopped(port);
@@ -305354,7 +305452,7 @@ async function quiesceDaemonForUpdate(port = getDaemonPort(), scope) {
305354
305452
  if (managed) dependencies.stopManagedService = () => stopManagedDaemonForUpdate(managed, () => waitForDaemonStopped(port));
305355
305453
  return stopDaemonAtPort(port, dependencies);
305356
305454
  }
305357
- var OMNIUS_DIR, PID_FILE, DEFAULT_PORT2, LOCK_INITIALIZATION_GRACE_MS, DAEMON_GRACEFUL_STOP_ATTEMPTS, DEFAULT_RECLAIM_DEPENDENCIES, DEFAULT_CLAIM_RECLAIM_DEPENDENCIES, daemonStopDependencies;
305455
+ var OMNIUS_DIR, PID_FILE, DEFAULT_PORT2, LOCK_INITIALIZATION_GRACE_MS, LINUX_BOOT_ID, DAEMON_GRACEFUL_STOP_ATTEMPTS, DEFAULT_RECLAIM_DEPENDENCIES, DEFAULT_CLAIM_RECLAIM_DEPENDENCIES, daemonStopDependencies;
305358
305456
  var init_daemon = __esm({
305359
305457
  "packages/cli/src/daemon.ts"() {
305360
305458
  init_dist5();
@@ -305365,6 +305463,7 @@ var init_daemon = __esm({
305365
305463
  PID_FILE = join15(OMNIUS_DIR, "daemon.pid");
305366
305464
  DEFAULT_PORT2 = 11435;
305367
305465
  LOCK_INITIALIZATION_GRACE_MS = 5e3;
305466
+ LINUX_BOOT_ID = /^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i;
305368
305467
  DAEMON_GRACEFUL_STOP_ATTEMPTS = 20;
305369
305468
  DEFAULT_RECLAIM_DEPENDENCIES = {
305370
305469
  holderPids: (port) => portHolderPids(port),
@@ -305377,6 +305476,7 @@ var init_daemon = __esm({
305377
305476
  readLock: (port) => readDaemonLock(daemonLockFile(port)),
305378
305477
  portIsFree: (port) => daemonPortIsFree(port),
305379
305478
  processIsAlive: (pid) => processIsAlive(pid),
305479
+ ownerIsStale: daemonLockOwnerIsStale,
305380
305480
  leases: () => listProcessLeases({ includeInactive: false }),
305381
305481
  stopLease: (leaseId, port) => stopDaemonLeaseGracefully(leaseId, `stale daemon endpoint claim on port ${port}`),
305382
305482
  removeLockIfUnchanged: (port, expected) => removeDaemonLockIfUnchanged(port, expected)
@@ -305410,7 +305510,7 @@ import {
305410
305510
  fchmodSync,
305411
305511
  fstatSync as fstatSync2,
305412
305512
  fsyncSync as fsyncSync2,
305413
- lstatSync as lstatSync4,
305513
+ lstatSync as lstatSync5,
305414
305514
  readlinkSync as readlinkSync2,
305415
305515
  mkdirSync as mkdirSync7,
305416
305516
  openSync as openSync4,
@@ -305484,8 +305584,8 @@ init_daemon_checkpoint_interrupted();
305484
305584
  init_daemon_service_authorization();
305485
305585
 
305486
305586
  // packages/cli/src/user-systemd-environment.ts
305487
- import { lstatSync as lstatSync2 } from "node:fs";
305488
- function userManagerEnvironment(env, uid = process.getuid?.(), inspect = lstatSync2) {
305587
+ import { lstatSync as lstatSync3 } from "node:fs";
305588
+ function userManagerEnvironment(env, uid = process.getuid?.(), inspect = lstatSync3) {
305489
305589
  if (env["XDG_RUNTIME_DIR"] && env["DBUS_SESSION_BUS_ADDRESS"]) return env;
305490
305590
  if (uid === void 0 || !Number.isSafeInteger(uid) || uid < 0) return env;
305491
305591
  const runtimeDir = env["XDG_RUNTIME_DIR"] || `/run/user/${uid}`;
@@ -305535,7 +305635,7 @@ async function pruneStaleUpdateRecoveries(modulesRoot, options = {}) {
305535
305635
 
305536
305636
  // packages/cli/src/npm-install-recovery.ts
305537
305637
  import { createHash as createHash4, randomUUID as randomUUID4 } from "node:crypto";
305538
- import { closeSync as closeSync3, constants as constants2, fstatSync, fsyncSync, ftruncateSync, lstatSync as lstatSync3, openSync as openSync3, readFileSync as readFileSync7, readdirSync, readSync as readSync2, unlinkSync as unlinkSync3, writeFileSync as writeFileSync5 } from "node:fs";
305638
+ import { closeSync as closeSync3, constants as constants2, fstatSync, fsyncSync, ftruncateSync, lstatSync as lstatSync4, openSync as openSync3, readFileSync as readFileSync7, readdirSync, readSync as readSync2, unlinkSync as unlinkSync3, writeFileSync as writeFileSync5 } from "node:fs";
305539
305639
  import { chmod, cp, lstat as lstat2, mkdir, readdir as readdir2, realpath, rename, rm as rm2 } from "node:fs/promises";
305540
305640
  import { basename as basename8, dirname as dirname9, isAbsolute as isAbsolute7, join as join17, resolve as resolve11 } from "node:path";
305541
305641
  var NpmInstallBusyError = class extends Error {
@@ -305677,7 +305777,7 @@ function processIdentity(pid) {
305677
305777
  }
305678
305778
  }
305679
305779
  function readInstallOwner(path3) {
305680
- const before = lstatSync3(path3);
305780
+ const before = lstatSync4(path3);
305681
305781
  const valid = (value) => value.isFile() && !value.isSymbolicLink() && value.size > 0 && value.size <= 4096 && value.nlink === 1 && (process.platform === "win32" || value.uid === process.getuid?.() && (value.mode & 63) === 0);
305682
305782
  if (!valid(before)) throw new NpmInstallBusyError("The npm install owner record is unsafe or unknown; it was retained for inspection.");
305683
305783
  const fd = openSync3(path3, constants2.O_RDONLY | constants2.O_NOFOLLOW | constants2.O_NONBLOCK);
@@ -305720,9 +305820,9 @@ function provedAbsent(owner) {
305720
305820
  var ABANDONED_EMPTY_GUARD_MS = 6e4;
305721
305821
  function removeAbandonedEmptyGuard(guardPath) {
305722
305822
  try {
305723
- const metadata = lstatSync3(guardPath);
305823
+ const metadata = lstatSync4(guardPath);
305724
305824
  if (!metadata.isFile() || metadata.size !== 0 || metadata.nlink !== 1 || metadata.uid !== process.getuid?.() || (metadata.mode & 63) !== 0 || Date.now() - metadata.mtimeMs < ABANDONED_EMPTY_GUARD_MS) return false;
305725
- const current = lstatSync3(guardPath);
305825
+ const current = lstatSync4(guardPath);
305726
305826
  if (!sameIdentity(metadata, current) || current.size !== 0) return false;
305727
305827
  unlinkSync3(guardPath);
305728
305828
  return true;
@@ -305740,7 +305840,7 @@ async function acquireNpmInstallLease(modulesRoot, options = {}) {
305740
305840
  if (!sameIdentity(logicalMetadata, rootMetadata)) throw new Error("npm modules root changed before installer admission.");
305741
305841
  const lockPath = join17(root, ".omnius-install.lock"), guardPath = lockPath + ".guard", nonce = randomUUID4();
305742
305842
  const assertRoot = () => {
305743
- const current = lstatSync3(root);
305843
+ const current = lstatSync4(root);
305744
305844
  assertOwnedDirectory(current, "global modules root");
305745
305845
  if (!sameIdentity(rootMetadata, current)) throw new Error("npm modules root changed; no installer may proceed.");
305746
305846
  };
@@ -305767,7 +305867,7 @@ async function acquireNpmInstallLease(modulesRoot, options = {}) {
305767
305867
  } finally {
305768
305868
  try {
305769
305869
  if (!recorded) {
305770
- if (sameIdentity(metadata, lstatSync3(guardPath))) unlinkSync3(guardPath);
305870
+ if (sameIdentity(metadata, lstatSync4(guardPath))) unlinkSync3(guardPath);
305771
305871
  } else {
305772
305872
  const current = readInstallOwner(guardPath);
305773
305873
  if (sameIdentity(metadata, current.metadata) && current.owner.nonce === guardNonce) unlinkSync3(guardPath);
@@ -305857,7 +305957,7 @@ var REQUIRED_OMNIUS_RUNTIME_FILES = [
305857
305957
  "dist/update-worker-runtime.js"
305858
305958
  ];
305859
305959
  function hashOwnedFile(path3) {
305860
- const before = lstatSync3(path3);
305960
+ const before = lstatSync4(path3);
305861
305961
  const valid = (metadata) => metadata.isFile() && !metadata.isSymbolicLink() && metadata.size > 0 && metadata.size <= 128 * 1024 * 1024 && (process.platform === "win32" || metadata.uid === process.getuid?.() && (metadata.mode & 2) === 0);
305862
305962
  if (!valid(before)) throw new Error(`Omnius runtime file is missing or unsafe: ${path3}`);
305863
305963
  const fd = openSync3(path3, constants2.O_RDONLY | constants2.O_NOFOLLOW | constants2.O_NONBLOCK);
@@ -305887,10 +305987,10 @@ function inspectNpmRuntimeInstallation(packagePath) {
305887
305987
  return inspectRuntimeDirectory(canonical2, root);
305888
305988
  }
305889
305989
  function inspectRuntimeDirectory(canonical2, root) {
305890
- const before = lstatSync3(canonical2);
305891
- assertOwnedDirectory(lstatSync3(root), "global modules root");
305990
+ const before = lstatSync4(canonical2);
305991
+ assertOwnedDirectory(lstatSync4(root), "global modules root");
305892
305992
  assertOwnedDirectory(before, "Omnius package");
305893
- assertOwnedDirectory(lstatSync3(join17(canonical2, "dist")), "Omnius runtime");
305993
+ assertOwnedDirectory(lstatSync4(join17(canonical2, "dist")), "Omnius runtime");
305894
305994
  const files = {};
305895
305995
  for (const file of REQUIRED_OMNIUS_RUNTIME_FILES) files[file] = hashOwnedFile(join17(canonical2, file));
305896
305996
  const manifest = JSON.parse(readFileSync7(join17(canonical2, "package.json"), "utf8"));
@@ -305900,11 +306000,11 @@ function inspectRuntimeDirectory(canonical2, root) {
305900
306000
  if (typeof binTarget !== "string" || !/^[A-Za-z0-9_./-]+$/.test(binTarget) || isAbsolute7(binTarget) || binTarget.split("/").some((part) => !part || part === ".." || part === "."))
305901
306001
  throw new Error("Omnius runtime manifest has no safe declared omnius executable.");
305902
306002
  for (const directory of binTarget.split("/").slice(0, -1).reduce((paths, part) => [...paths, join17(paths.at(-1) ?? canonical2, part)], []))
305903
- assertOwnedDirectory(lstatSync3(directory), "Omnius executable directory");
306003
+ assertOwnedDirectory(lstatSync4(directory), "Omnius executable directory");
305904
306004
  files[binTarget] ??= hashOwnedFile(join17(canonical2, binTarget));
305905
306005
  if (!readFileSync7(join17(canonical2, "dist/update-worker.js"), "utf8").includes("omnius.update-worker-bootstrap.v2"))
305906
306006
  throw new Error("Omnius runtime has no compatible update worker bootstrap.");
305907
- if (hashOwnedFile(join17(canonical2, "package.json")) !== files["package.json"] || !sameIdentity(before, lstatSync3(canonical2)))
306007
+ if (hashOwnedFile(join17(canonical2, "package.json")) !== files["package.json"] || !sameIdentity(before, lstatSync4(canonical2)))
305908
306008
  throw new Error("Omnius package changed during runtime verification.");
305909
306009
  return {
305910
306010
  modulesRoot: root,
@@ -305979,19 +306079,19 @@ async function restoreVerifiedNpmInstallation(snapshot, options) {
305979
306079
  if (!validPath(path3)) return false;
305980
306080
  let metadata;
305981
306081
  try {
305982
- metadata = lstatSync3(path3);
306082
+ metadata = lstatSync4(path3);
305983
306083
  } catch (error) {
305984
306084
  if (error.code === "ENOENT") return false;
305985
306085
  throw error;
305986
306086
  }
305987
306087
  if (metadata.dev !== snapshot.device || metadata.ino !== snapshot.inode) return false;
305988
306088
  assertOwnedDirectory(metadata, "prior Omnius package");
305989
- assertOwnedDirectory(lstatSync3(join17(path3, "dist")), "prior Omnius runtime");
306089
+ assertOwnedDirectory(lstatSync4(join17(path3, "dist")), "prior Omnius runtime");
305990
306090
  for (const [file, digest3] of Object.entries(snapshot.files)) {
305991
306091
  if (!/^[A-Za-z0-9_./-]+$/.test(file) || isAbsolute7(file) || file.split("/").some((part) => !part || part === "." || part === "..") || hashOwnedFile(join17(path3, file)) !== digest3) throw new Error("Prior Omnius runtime changed; restoration was held.");
305992
306092
  }
305993
306093
  for (const directory of snapshot.binTarget.split("/").slice(0, -1).reduce((paths, part) => [...paths, join17(paths.at(-1) ?? path3, part)], []))
305994
- assertOwnedDirectory(lstatSync3(directory), "prior Omnius executable directory");
306094
+ assertOwnedDirectory(lstatSync4(directory), "prior Omnius executable directory");
305995
306095
  return true;
305996
306096
  };
305997
306097
  const source = [canonical2, retiredNpmPackagePath(canonical2), ...(options.backups ?? []).map((backup) => backup.backupPath)].find(matches);
@@ -306066,6 +306166,11 @@ async function removeVerifiedNpmRetirementBackup(backup) {
306066
306166
  }
306067
306167
 
306068
306168
  // packages/cli/src/update-service.ts
306169
+ var AutomaticUpdateDeferredError = class extends Error {
306170
+ constructor() {
306171
+ super("Automatic update deferred because the daemon has not confirmed it is idle.");
306172
+ }
306173
+ };
306069
306174
  var UpdateCancelledError = class extends Error {
306070
306175
  constructor(message = "Update cancelled. Package changes already made are retained; no rollback is claimed.") {
306071
306176
  super(message);
@@ -306084,7 +306189,7 @@ function watchUpdateCancellation(operationId, paths = resolveUpdatePaths()) {
306084
306189
  const check = () => {
306085
306190
  if (controller.signal.aborted) return;
306086
306191
  try {
306087
- const metadata = lstatSync4(path3);
306192
+ const metadata = lstatSync5(path3);
306088
306193
  if (!metadata.isFile() || metadata.isSymbolicLink() || metadata.size > 1024) return;
306089
306194
  const request = JSON.parse(readFileSync8(path3, "utf8"));
306090
306195
  const state = readUpdateState(paths);
@@ -306119,7 +306224,7 @@ function resolveUpdatePaths(env = process.env, platform2 = process.platform, hom
306119
306224
  function ensurePrivateDirectories(paths) {
306120
306225
  for (const path3 of [paths.stateDir, paths.cacheDir]) {
306121
306226
  mkdirSync7(path3, { recursive: true, mode: 448 });
306122
- const before = lstatSync4(path3);
306227
+ const before = lstatSync5(path3);
306123
306228
  if (!before.isDirectory() || before.isSymbolicLink() || process.platform !== "win32" && (before.uid !== process.getuid?.() || (before.mode & 18) !== 0)) throw new Error("Update coordination directories must be owned and not writable by other users");
306124
306229
  const fd = openSync4(path3, constants3.O_RDONLY | constants3.O_DIRECTORY | constants3.O_NOFOLLOW);
306125
306230
  try {
@@ -306134,7 +306239,7 @@ function ensurePrivateDirectories(paths) {
306134
306239
  function privateRecord(path3, limit = 4096) {
306135
306240
  let before;
306136
306241
  try {
306137
- before = lstatSync4(path3);
306242
+ before = lstatSync5(path3);
306138
306243
  } catch (error) {
306139
306244
  if (error.code === "ENOENT") return null;
306140
306245
  throw error;
@@ -306174,7 +306279,7 @@ function processIdentity2(pid) {
306174
306279
  }
306175
306280
  function interruptedGuardSnapshot(path3) {
306176
306281
  try {
306177
- const before = lstatSync4(path3), owner = privateRecord(path3), metadata = lstatSync4(path3);
306282
+ const before = lstatSync5(path3), owner = privateRecord(path3), metadata = lstatSync5(path3);
306178
306283
  if (!owner || before.dev !== metadata.dev || before.ino !== metadata.ino || !Number.isSafeInteger(owner.pid) || owner.pid <= 0 || typeof owner.nonce !== "string" || !/^[A-Za-z0-9_-]{1,128}$/.test(owner.nonce) || process.platform === "linux" && (typeof owner.process_identity !== "string" || !/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}:\d+$/i.test(owner.process_identity))) return null;
306179
306284
  return { owner, metadata };
306180
306285
  } catch {
@@ -306216,13 +306321,13 @@ function recoverInterruptedUpdateGuard(path3) {
306216
306321
  recorded = true;
306217
306322
  const current = interruptedGuardSnapshot(path3);
306218
306323
  if (!current || current.metadata.dev !== initial.metadata.dev || current.metadata.ino !== initial.metadata.ino || current.owner.nonce !== initial.owner.nonce || current.owner.pid !== initial.owner.pid || current.owner.process_identity !== initial.owner.process_identity || !guardOwnerIsProvablyDead(current.owner)) return false;
306219
- const final = lstatSync4(path3);
306324
+ const final = lstatSync5(path3);
306220
306325
  if (final.dev !== current.metadata.dev || final.ino !== current.metadata.ino) return false;
306221
306326
  unlinkSync4(path3);
306222
306327
  return true;
306223
306328
  } finally {
306224
306329
  try {
306225
- const current = lstatSync4(recoveryPath);
306330
+ const current = lstatSync5(recoveryPath);
306226
306331
  if (current.dev === claimed.dev && current.ino === claimed.ino && (!recorded || privateRecord(recoveryPath)?.nonce === nonce)) unlinkSync4(recoveryPath);
306227
306332
  } catch {
306228
306333
  }
@@ -306261,7 +306366,7 @@ function withUpdateOwnership(paths, mutation) {
306261
306366
  }
306262
306367
  const created = () => {
306263
306368
  try {
306264
- const current = lstatSync4(path3);
306369
+ const current = lstatSync5(path3);
306265
306370
  return current.ino === original.ino && current.dev === original.dev;
306266
306371
  } catch {
306267
306372
  return false;
@@ -306560,7 +306665,7 @@ async function quiesceDaemonWithRetry(quiesce, attempts = 3, pauseMs = 250) {
306560
306665
  try {
306561
306666
  if (await quiesce()) return true;
306562
306667
  } catch (error) {
306563
- if (error instanceof DaemonServiceAuthorizationError || error instanceof DaemonCheckpointInterruptedError) throw error;
306668
+ if (error instanceof DaemonServiceAuthorizationError || error instanceof DaemonCheckpointInterruptedError || error instanceof AutomaticUpdateDeferredError) throw error;
306564
306669
  }
306565
306670
  if (attempt < boundedAttempts && pauseMs > 0) {
306566
306671
  await new Promise((resolve13) => setTimeout(resolve13, pauseMs));
@@ -306600,11 +306705,11 @@ function restoreOmniusExecutableLink(prefix, installation) {
306600
306705
  }
306601
306706
  const directory = dirname10(executable);
306602
306707
  if (!existsSync8(directory)) mkdirSync7(directory, { recursive: false, mode: 493 });
306603
- const metadata = lstatSync4(directory);
306708
+ const metadata = lstatSync5(directory);
306604
306709
  if (!metadata.isDirectory() || metadata.isSymbolicLink() || metadata.uid !== process.getuid?.() || (metadata.mode & 2) !== 0)
306605
306710
  throw new Error("The Omnius executable directory is unsafe; no link was changed.");
306606
306711
  try {
306607
- const existing = lstatSync4(executable);
306712
+ const existing = lstatSync5(executable);
306608
306713
  if (!existing.isSymbolicLink() || existing.uid !== process.getuid?.() || resolve12(directory, readlinkSync2(executable)) !== target)
306609
306714
  throw new Error("A different executable occupies the Omnius bin path; it was retained.");
306610
306715
  } catch (error) {
@@ -306618,6 +306723,7 @@ async function runVerifiedUpdateTransaction(initial, dependencies, paths = resol
306618
306723
  let installStarted = false;
306619
306724
  let installerSettled = true;
306620
306725
  let packageVerified = false;
306726
+ let recoveryInstallation;
306621
306727
  let previousInstallation;
306622
306728
  let previousInstallationCopy;
306623
306729
  const retirementBackups = [];
@@ -306784,6 +306890,7 @@ async function runVerifiedUpdateTransaction(initial, dependencies, paths = resol
306784
306890
  const evidence = dependencies.inspectInstall ? await dependencies.inspectInstall(target, npmPath, env) : await inspectGlobalOmniusInstall(target, { npmPath, env, cwd });
306785
306891
  throwIfCancelled();
306786
306892
  packageVerified = true;
306893
+ recoveryInstallation = evidence;
306787
306894
  state = await transition(state, {
306788
306895
  phase: "package_verified",
306789
306896
  npm_prefix: evidence.npmPrefix,
@@ -306883,7 +306990,8 @@ async function runVerifiedUpdateTransaction(initial, dependencies, paths = resol
306883
306990
  return state;
306884
306991
  } catch (error) {
306885
306992
  if (cancelPublication) await cancelPublication;
306886
- const cancelled = error instanceof UpdateCancelledError || dependencies.signal?.aborted === true;
306993
+ const deferred = error instanceof AutomaticUpdateDeferredError;
306994
+ const cancelled = deferred || error instanceof UpdateCancelledError || dependencies.signal?.aborted === true;
306887
306995
  const message = error instanceof Error ? error.message : String(error);
306888
306996
  let recoveryNote;
306889
306997
  let packageRecoveryNote;
@@ -306923,6 +307031,7 @@ async function runVerifiedUpdateTransaction(initial, dependencies, paths = resol
306923
307031
  assertRecoveryOwned();
306924
307032
  if (verified.packageHash !== previousInstallation.packageHash) throw new Error("Restored Omnius manifest differs from the pre-install verification.");
306925
307033
  restoredPackageVerified = true;
307034
+ recoveryInstallation = verified;
306926
307035
  state = await transition(state, {
306927
307036
  package_recovery: { status: recovered.status, ...journal(recovered) },
306928
307037
  npm_recoveries: state.npm_recoveries?.map((item) => item.backup_path === recovered.sourcePath ? { ...item, status: "restored" } : item),
@@ -306944,6 +307053,7 @@ async function runVerifiedUpdateTransaction(initial, dependencies, paths = resol
306944
307053
  }
306945
307054
  }
306946
307055
  if (!cancelled && packageVerified && installerSettled && installLease && previousInstallation && previousInstallationCopy) {
307056
+ recoveryInstallation = void 0;
306947
307057
  state = await transition(state, { phase: "rolling_back" }, paths);
306948
307058
  try {
306949
307059
  const recovered = await restoreVerifiedNpmInstallation(previousInstallationCopy, {
@@ -306966,6 +307076,7 @@ async function runVerifiedUpdateTransaction(initial, dependencies, paths = resol
306966
307076
  const verified = await inspectGlobalOmniusInstall(previousInstallation.version, { npmPath, env, cwd });
306967
307077
  if (verified.packageHash !== previousInstallation.packageHash) throw new Error("the restored manifest differs from the pre-install verification");
306968
307078
  restoredPackageVerified = rolledBack = true;
307079
+ recoveryInstallation = verified;
306969
307080
  state = await transition(state, {
306970
307081
  rolled_back_to: verified.installedVersion,
306971
307082
  package_recovery: {
@@ -306989,10 +307100,20 @@ async function runVerifiedUpdateTransaction(initial, dependencies, paths = resol
306989
307100
  packageRecoveryNote = `Rollback could not be verified: ${detail}`;
306990
307101
  }
306991
307102
  }
306992
- if ((daemonQuiesced || rolledBack || unchangedPackage) && dependencies.recoverDaemon && installerSettled && (!installStarted || packageVerified || restoredPackageVerified)) {
307103
+ if ((daemonQuiesced || rolledBack || unchangedPackage) && dependencies.recoverDaemon && installerSettled && (!installStarted || recoveryInstallation)) {
306993
307104
  state = await transition(state, { phase: "recovering" }, paths);
306994
307105
  try {
306995
- const recovered = await dependencies.recoverDaemon(unchangedPackage && { version: unchangedPackage.version, packageHash: unchangedPackage.packageHash });
307106
+ if (!installStarted && previousInstallation) {
307107
+ const retained = await inspectGlobalOmniusInstall(previousInstallation.version, { npmPath, env, cwd });
307108
+ if (retained.packageHash !== previousInstallation.packageHash) throw new Error("The retained Omnius manifest changed before daemon recovery.");
307109
+ recoveryInstallation = retained;
307110
+ }
307111
+ const recoveryTarget = recoveryInstallation && {
307112
+ version: recoveryInstallation.installedVersion,
307113
+ packageHash: recoveryInstallation.packageHash,
307114
+ executablePath: recoveryInstallation.executablePath
307115
+ };
307116
+ const recovered = await dependencies.recoverDaemon(recoveryTarget);
306996
307117
  recoveryNote = recovered ? "The daemon was restarted after the interrupted update." : "The daemon could not be recovered automatically after the failed update.";
306997
307118
  if (rolledBack && state.tray_was_running && dependencies.restartTray && state.global_executable) {
306998
307119
  recoveryNote += await dependencies.restartTray(state.global_executable).catch(() => false) ? " The indicator was relaunched on the restored version." : " The indicator could not be relaunched on the restored version.";
@@ -307007,7 +307128,8 @@ async function runVerifiedUpdateTransaction(initial, dependencies, paths = resol
307007
307128
  status: cancelled ? "cancelled" : "failed",
307008
307129
  phase: cancelled ? "cancelled" : "failed",
307009
307130
  completed_at: (/* @__PURE__ */ new Date()).toISOString(),
307010
- error: cancelled ? installerSettled ? "Update cancelled after the owned operation settled." : "Update cancellation requested; owned installer shutdown could not be confirmed." : message,
307131
+ ...deferred ? { automatic_deferred: true } : {},
307132
+ error: cancelled && !deferred ? installerSettled ? "Update cancelled after the owned operation settled." : "Update cancellation requested; owned installer shutdown could not be confirmed." : message,
307011
307133
  remediation: [
307012
307134
  packageRecoveryNote,
307013
307135
  cancelled && installStarted && !restoredPackageVerified ? "Package files may have changed. No rollback was performed; verify the installed version before retrying." : void 0,
@@ -307578,7 +307700,7 @@ var PROVIDER_PRESETS = [
307578
307700
  ];
307579
307701
 
307580
307702
  // packages/cli/src/provider-credentials.ts
307581
- import { constants as constants4, closeSync as closeSync5, existsSync as existsSync9, fstatSync as fstatSync3, fsyncSync as fsyncSync3, lstatSync as lstatSync5, mkdirSync as mkdirSync8, openSync as openSync5, readFileSync as readFileSync9, readdirSync as readdirSync2, renameSync as renameSync6, unlinkSync as unlinkSync5, writeFileSync as writeFileSync7 } from "node:fs";
307703
+ import { constants as constants4, closeSync as closeSync5, existsSync as existsSync9, fstatSync as fstatSync3, fsyncSync as fsyncSync3, lstatSync as lstatSync6, mkdirSync as mkdirSync8, openSync as openSync5, readFileSync as readFileSync9, readdirSync as readdirSync2, renameSync as renameSync6, unlinkSync as unlinkSync5, writeFileSync as writeFileSync7 } from "node:fs";
307582
307704
  var NOFOLLOW = constants4.O_NOFOLLOW ?? 0;
307583
307705
 
307584
307706
  // packages/cli/src/config.ts
@@ -308047,6 +308169,26 @@ async function launchDetachedTray(executable, endpoint) {
308047
308169
  }
308048
308170
  async function runUpdateWorkerRuntime(state, paths, endpoint) {
308049
308171
  const cancellation = watchUpdateCancellation(state.operation_id, paths);
308172
+ let idleHandoffRequested = false;
308173
+ const requestIdleHandoff = async (method) => {
308174
+ const url = new URL("/v1/update/idle-handoff", endpoint);
308175
+ if (!["127.0.0.1", "localhost", "[::1]"].includes(url.hostname) || url.username || url.password || url.protocol !== "http:" && url.protocol !== "https:") throw new AutomaticUpdateDeferredError();
308176
+ if (!state.automatic_handoff_token) throw new AutomaticUpdateDeferredError();
308177
+ const response = await fetch(url, {
308178
+ method,
308179
+ headers: { "Content-Type": "application/json", Authorization: `Bearer ${state.automatic_handoff_token}` },
308180
+ body: JSON.stringify({ operation_id: state.operation_id }),
308181
+ redirect: "error",
308182
+ signal: AbortSignal.timeout(method === "POST" ? 8e3 : 1e3)
308183
+ }).catch((error) => {
308184
+ if (error?.cause?.code === "ECONNREFUSED") return null;
308185
+ throw new AutomaticUpdateDeferredError();
308186
+ });
308187
+ if (method === "POST" && response) {
308188
+ const receipt = response.ok ? await response.json().catch(() => null) : null;
308189
+ if (receipt?.idle !== true || receipt.operation_id !== state.operation_id) throw new AutomaticUpdateDeferredError();
308190
+ }
308191
+ };
308050
308192
  try {
308051
308193
  const port = Number(new URL(endpoint).port || "11435");
308052
308194
  const trayWasRunning = state.tray_was_running || !cancellation.signal.aborted && (await getTrayStatus(endpoint)).running;
@@ -308057,13 +308199,18 @@ async function runUpdateWorkerRuntime(state, paths, endpoint) {
308057
308199
  {
308058
308200
  quiesceDaemon: async () => {
308059
308201
  if (daemonScope === void 0) daemonScope = (await discoverDaemonServiceAtPort(port))?.scope ?? null;
308202
+ if (state.automatic === true) {
308203
+ idleHandoffRequested = true;
308204
+ await requestIdleHandoff("POST");
308205
+ if (cancellation.signal.aborted) return false;
308206
+ }
308060
308207
  return quiesceDaemonForUpdate(port, daemonScope);
308061
308208
  },
308062
308209
  restartDaemon: (expected, executable) => restartDaemon(port, expected, executable, daemonScope),
308063
- recoverDaemon: async (unchangedPackage) => {
308064
- await restartDaemon(port, unchangedPackage?.version, void 0, daemonScope);
308210
+ recoverDaemon: async (target) => {
308211
+ await restartDaemon(port, target?.version, target?.executablePath, daemonScope);
308065
308212
  const ready = await getDaemonReportedIdentity(port);
308066
- return Boolean(ready && (!unchangedPackage || ready.bootVersion === unchangedPackage.version && ready.bootPackageHash === unchangedPackage.packageHash));
308213
+ return Boolean(ready && (!target || ready.bootVersion === target.version && ready.bootPackageHash === target.packageHash));
308067
308214
  },
308068
308215
  observeDaemon: async () => {
308069
308216
  const identity = await getDaemonReportedIdentity(port);
@@ -308081,6 +308228,7 @@ async function runUpdateWorkerRuntime(state, paths, endpoint) {
308081
308228
  );
308082
308229
  return finalState;
308083
308230
  } finally {
308231
+ if (idleHandoffRequested) await requestIdleHandoff("DELETE").catch(() => void 0);
308084
308232
  cancellation.close();
308085
308233
  }
308086
308234
  }