@adhdev/daemon-standalone 1.0.39-rc.1 → 1.0.39-rc.3

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.
package/dist/index.js CHANGED
@@ -36528,10 +36528,10 @@ var require_dist3 = __commonJS({
36528
36528
  }
36529
36529
  function getDaemonBuildInfo() {
36530
36530
  if (cached2) return cached2;
36531
- const commit = readInjected(true ? "a1082159590bba25809d2f8a65c10055b8d3bc97" : void 0) ?? "unknown";
36532
- const commitShort = readInjected(true ? "a1082159" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
36533
- const version2 = readInjected(true ? "1.0.39-rc.1" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
36534
- const builtAt = readInjected(true ? "2026-08-07T02:52:22.815Z" : void 0);
36531
+ const commit = readInjected(true ? "454a3fb1673f9dd4b935c6081ae41ac24abf778f" : void 0) ?? "unknown";
36532
+ const commitShort = readInjected(true ? "454a3fb1" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
36533
+ const version2 = readInjected(true ? "1.0.39-rc.3" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
36534
+ const builtAt = readInjected(true ? "2026-08-07T11:02:28.517Z" : void 0);
36535
36535
  cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
36536
36536
  return cached2;
36537
36537
  }
@@ -77537,6 +77537,7 @@ ${lastSnapshot}`;
77537
77537
  resolveMuted: () => resolveMuted,
77538
77538
  resolveNodeSchedulingPriority: () => resolveNodeSchedulingPriority,
77539
77539
  resolveNotBefore: () => resolveNotBefore,
77540
+ resolveNpmPublishedVersion: () => resolveNpmPublishedVersion,
77540
77541
  resolveProviderChannel: () => resolveProviderChannel,
77541
77542
  resolveProviderMaxParallel: () => resolveProviderMaxParallel,
77542
77543
  resolveScopedMeshId: () => resolveScopedMeshId,
@@ -90707,6 +90708,27 @@ exec "${portableNode}" "${cliEntry}" "$@"
90707
90708
  }
90708
90709
  );
90709
90710
  }
90711
+ function resolveNpmPublishedVersion(packageName, tagOrVersion, surface, options = {}) {
90712
+ const args = ["view", `${packageName}@${tagOrVersion}`, "version"];
90713
+ const execOptions = {
90714
+ encoding: "utf-8",
90715
+ ..."timeout" in options ? options.timeout === void 0 ? {} : { timeout: options.timeout } : { timeout: 1e4 },
90716
+ ...options.stdio ? { stdio: options.stdio } : {}
90717
+ };
90718
+ if (options.execFileSync) {
90719
+ const runnerOptions = surface?.execOptions || getNpmExecOptions();
90720
+ return String(options.execFileSync(
90721
+ surface?.npmExecutable || "npm",
90722
+ [...surface?.npmArgsPrefix || [], ...args],
90723
+ {
90724
+ ...execOptions,
90725
+ ...runnerOptions,
90726
+ ...process.platform === "win32" ? { windowsHide: true } : {}
90727
+ }
90728
+ )).trim();
90729
+ }
90730
+ return String(execNpmCommandSync(args, execOptions, surface)).trim();
90731
+ }
90710
90732
  function isManagedSessionHostPid(pid) {
90711
90733
  const commandLine = getProcessCommandLine(pid);
90712
90734
  return !!commandLine && /session-host-daemon/i.test(commandLine);
@@ -90807,24 +90829,75 @@ exec "${portableNode}" "${cliEntry}" "$@"
90807
90829
  function buildManualRecoveryCommand(installCommand) {
90808
90830
  return [installCommand.command, ...installCommand.args].map((part) => /\s/.test(part) ? `"${part}"` : part).join(" ");
90809
90831
  }
90810
- function emitUpgradeFailureNotice(lines, configDir = getConfigDir2()) {
90832
+ var UPGRADE_FAILURE_TARGET_MARKER = "adhdev-upgrade-target:";
90833
+ function emitUpgradeFailureNotice(lines, configDir = getConfigDir2(), options = {}) {
90811
90834
  const body = lines.join("\n");
90812
90835
  appendUpgradeLog(`Upgrade blocked \u2014 user action required:
90813
90836
  ${body}`, configDir);
90837
+ const target = typeof options.targetVersion === "string" ? options.targetVersion.trim() : "";
90838
+ const marker = target ? `${UPGRADE_FAILURE_TARGET_MARKER} ${target}
90839
+ ` : "";
90814
90840
  try {
90815
- fs20.writeFileSync(getUpgradeFailureNoticePath(configDir), `[${(/* @__PURE__ */ new Date()).toISOString()}]
90841
+ fs20.writeFileSync(
90842
+ getUpgradeFailureNoticePath(configDir),
90843
+ `[${(/* @__PURE__ */ new Date()).toISOString()}]
90816
90844
  ${body}
90817
- `, "utf8");
90845
+ ${marker}`,
90846
+ "utf8"
90847
+ );
90818
90848
  } catch {
90819
90849
  }
90820
90850
  }
90851
+ function clearUpgradeFailureNotice(configDir = getConfigDir2()) {
90852
+ const noticePath = getUpgradeFailureNoticePath(configDir);
90853
+ try {
90854
+ fs20.unlinkSync(noticePath);
90855
+ } catch (error48) {
90856
+ if (error48?.code === "ENOENT") return;
90857
+ appendUpgradeLog(
90858
+ `Failed to clear stale upgrade-failure notice (${error48?.code || "error"}): ${noticePath} \u2014 ${error48?.message || String(error48)}. Investigate a file lock or permissions: until it is removed, every daemon boot will keep warning about this ALREADY-RESOLVED failure.`,
90859
+ configDir
90860
+ );
90861
+ }
90862
+ }
90863
+ function formatUpgradeNoticeAge(ageMs2) {
90864
+ if (ageMs2 < 0) return "in the future (clock skew?)";
90865
+ const minutes = Math.floor(ageMs2 / 6e4);
90866
+ if (minutes < 1) return "just now";
90867
+ if (minutes < 60) return `${minutes}m ago`;
90868
+ const hours = Math.floor(minutes / 60);
90869
+ if (hours < 24) return `${hours}h ago`;
90870
+ return `${Math.floor(hours / 24)}d ago`;
90871
+ }
90872
+ function parseUpgradeNoticeTimestamp(notice) {
90873
+ const match = /^\[([^\]\n]+)\]/.exec(notice);
90874
+ if (!match) return null;
90875
+ const parsed = Date.parse(match[1]);
90876
+ return Number.isFinite(parsed) ? new Date(parsed).toISOString() : null;
90877
+ }
90878
+ function parseUpgradeNoticeTargetVersion(notice) {
90879
+ const pattern = new RegExp(`^${UPGRADE_FAILURE_TARGET_MARKER}\\s*(.+)$`, "m");
90880
+ const match = pattern.exec(notice);
90881
+ const value = match?.[1]?.trim();
90882
+ return value ? value : null;
90883
+ }
90821
90884
  function readUpgradeFailureNotice(configDir = getConfigDir2()) {
90822
90885
  try {
90823
90886
  const noticePath = getUpgradeFailureNoticePath(configDir);
90824
90887
  if (!fs20.existsSync(noticePath)) return null;
90825
90888
  const notice = fs20.readFileSync(noticePath, "utf8").trim();
90826
90889
  if (!notice) return null;
90827
- return { noticePath, logPath: getUpgradeLogPath(configDir), notice };
90890
+ const recordedAt = parseUpgradeNoticeTimestamp(notice);
90891
+ const ageMs2 = recordedAt ? Date.now() - Date.parse(recordedAt) : null;
90892
+ return {
90893
+ noticePath,
90894
+ logPath: getUpgradeLogPath(configDir),
90895
+ notice,
90896
+ recordedAt,
90897
+ ageMs: ageMs2,
90898
+ ageLabel: ageMs2 === null ? null : formatUpgradeNoticeAge(ageMs2),
90899
+ targetVersion: parseUpgradeNoticeTargetVersion(notice)
90900
+ };
90828
90901
  } catch {
90829
90902
  return null;
90830
90903
  }
@@ -90930,10 +91003,7 @@ ${body}
90930
91003
  if (payload.skipInstall) {
90931
91004
  appendUpgradeLog("Restart-only mode \u2014 package install skipped, re-spawning daemon");
90932
91005
  spawnDetachedDaemonRestart(restartArgv, payload.cwd);
90933
- try {
90934
- fs20.unlinkSync(getUpgradeFailureNoticePath());
90935
- } catch {
90936
- }
91006
+ clearUpgradeFailureNotice();
90937
91007
  return;
90938
91008
  }
90939
91009
  const instanceDir = resolveInstanceDir();
@@ -90987,13 +91057,10 @@ ${body}
90987
91057
  `adhdev ${payload.packageName}@${payload.targetVersion} upgrade failed and was rolled back: ${error48?.message || String(error48)}`,
90988
91058
  `Previous version preserved (active prefix: ${windowsInstallerLayout.activePrefix}).`,
90989
91059
  "See daemon-upgrade.log for the full install/health trace. The next daemon start will retry."
90990
- ]);
91060
+ ], getConfigDir2(), { targetVersion: payload.targetVersion });
90991
91061
  throw error48;
90992
91062
  }
90993
- try {
90994
- fs20.unlinkSync(getUpgradeFailureNoticePath());
90995
- } catch {
90996
- }
91063
+ clearUpgradeFailureNotice();
90997
91064
  appendUpgradeLog("Installer-managed Windows atomic upgrade completed");
90998
91065
  return;
90999
91066
  }
@@ -91041,7 +91108,7 @@ ${body}
91041
91108
  notice.push("To recover, reinstall manually:");
91042
91109
  }
91043
91110
  notice.push(` ${buildManualRecoveryCommand(installCommand)}`);
91044
- emitUpgradeFailureNotice(notice);
91111
+ emitUpgradeFailureNotice(notice, getConfigDir2(), { targetVersion: payload.targetVersion });
91045
91112
  }
91046
91113
  throw error48;
91047
91114
  }
@@ -91060,7 +91127,7 @@ ${body}
91060
91127
  "so the running daemon was left on its previous version and was NOT restarted.",
91061
91128
  "To recover, reinstall (this forces the shipped prebuild instead of a source rebuild):",
91062
91129
  ` ${buildManualRecoveryCommand(installCommand)}`
91063
- ]);
91130
+ ], getConfigDir2(), { targetVersion: payload.targetVersion });
91064
91131
  throw error48;
91065
91132
  }
91066
91133
  }
@@ -91070,10 +91137,7 @@ ${body}
91070
91137
  appendUpgradeLog("Post-install staging cleanup complete");
91071
91138
  }
91072
91139
  spawnDetachedDaemonRestart(restartArgv, payload.cwd);
91073
- try {
91074
- fs20.unlinkSync(getUpgradeFailureNoticePath());
91075
- } catch {
91076
- }
91140
+ clearUpgradeFailureNotice();
91077
91141
  }
91078
91142
  function spawnDetachedDaemonRestart(restartArgv, cwd) {
91079
91143
  if (restartArgv.length > 0) {
@@ -91435,7 +91499,7 @@ ${body}
91435
91499
  LOG2.info("Upgrade", "Ignoring deprecated channel hint \u2014 upgrade target is the build track");
91436
91500
  }
91437
91501
  const npmTag = IDENTITY.npmTag;
91438
- const latest = String(execNpmCommandSync(["view", `${pkgName}@${npmTag}`, "version"], { encoding: "utf-8", timeout: 1e4 }, npmSurface)).trim();
91502
+ const latest = resolveNpmPublishedVersion(pkgName, npmTag, npmSurface);
91439
91503
  LOG2.info("Upgrade", `Latest ${pkgName}@${npmTag}: v${latest}`);
91440
91504
  let currentInstalled = null;
91441
91505
  try {
@@ -124469,8 +124533,12 @@ data: ${JSON.stringify(msg.data)}
124469
124533
  loadMeshCoordinatorRegistry();
124470
124534
  const upgradeFailureNotice = readUpgradeFailureNotice();
124471
124535
  if (upgradeFailureNotice) {
124472
- LOG2.warn("Upgrade", `Previous daemon upgrade FAILED and was rolled back \u2014 this daemon is running the previous version. Notice (${upgradeFailureNotice.noticePath}):
124473
- ${upgradeFailureNotice.notice}`);
124536
+ const age = upgradeFailureNotice.ageLabel ? `${upgradeFailureNotice.ageLabel}, recorded ${upgradeFailureNotice.recordedAt}` : "recorded at an unknown time";
124537
+ const target = upgradeFailureNotice.targetVersion ? `, attempted target v${upgradeFailureNotice.targetVersion}` : "";
124538
+ const running = (config2.statusVersion || "").trim().replace(/^v/, "");
124539
+ const supersededHint = upgradeFailureNotice.targetVersion && running && upgradeFailureNotice.targetVersion.replace(/^v/, "") !== running ? ` This notice targets a DIFFERENT version than the one now running (v${running}) \u2014 it is most likely a stale record of an earlier attempt, not a report about this boot.` : "";
124540
+ LOG2.warn("Upgrade", `Previous daemon upgrade FAILED and was rolled back \u2014 this daemon is running the previous version. Notice (${age}${target}) at ${upgradeFailureNotice.noticePath}:
124541
+ ${upgradeFailureNotice.notice}${supersededHint}`);
124474
124542
  }
124475
124543
  const appConfig = loadConfig2();
124476
124544
  const providerSourceMode = appConfig.providerSourceMode || "normal";