@adhdev/daemon-standalone 1.0.39-rc.2 → 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 ? "38c912aafd78adf13d2647bd84b7dffc3c65eece" : void 0) ?? "unknown";
36532
- const commitShort = readInjected(true ? "38c912aa" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
36533
- const version2 = readInjected(true ? "1.0.39-rc.2" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
36534
- const builtAt = readInjected(true ? "2026-08-07T06:34:33.803Z" : 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
  }
@@ -90829,24 +90829,75 @@ exec "${portableNode}" "${cliEntry}" "$@"
90829
90829
  function buildManualRecoveryCommand(installCommand) {
90830
90830
  return [installCommand.command, ...installCommand.args].map((part) => /\s/.test(part) ? `"${part}"` : part).join(" ");
90831
90831
  }
90832
- function emitUpgradeFailureNotice(lines, configDir = getConfigDir2()) {
90832
+ var UPGRADE_FAILURE_TARGET_MARKER = "adhdev-upgrade-target:";
90833
+ function emitUpgradeFailureNotice(lines, configDir = getConfigDir2(), options = {}) {
90833
90834
  const body = lines.join("\n");
90834
90835
  appendUpgradeLog(`Upgrade blocked \u2014 user action required:
90835
90836
  ${body}`, configDir);
90837
+ const target = typeof options.targetVersion === "string" ? options.targetVersion.trim() : "";
90838
+ const marker = target ? `${UPGRADE_FAILURE_TARGET_MARKER} ${target}
90839
+ ` : "";
90836
90840
  try {
90837
- fs20.writeFileSync(getUpgradeFailureNoticePath(configDir), `[${(/* @__PURE__ */ new Date()).toISOString()}]
90841
+ fs20.writeFileSync(
90842
+ getUpgradeFailureNoticePath(configDir),
90843
+ `[${(/* @__PURE__ */ new Date()).toISOString()}]
90838
90844
  ${body}
90839
- `, "utf8");
90845
+ ${marker}`,
90846
+ "utf8"
90847
+ );
90840
90848
  } catch {
90841
90849
  }
90842
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
+ }
90843
90884
  function readUpgradeFailureNotice(configDir = getConfigDir2()) {
90844
90885
  try {
90845
90886
  const noticePath = getUpgradeFailureNoticePath(configDir);
90846
90887
  if (!fs20.existsSync(noticePath)) return null;
90847
90888
  const notice = fs20.readFileSync(noticePath, "utf8").trim();
90848
90889
  if (!notice) return null;
90849
- 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
+ };
90850
90901
  } catch {
90851
90902
  return null;
90852
90903
  }
@@ -90952,10 +91003,7 @@ ${body}
90952
91003
  if (payload.skipInstall) {
90953
91004
  appendUpgradeLog("Restart-only mode \u2014 package install skipped, re-spawning daemon");
90954
91005
  spawnDetachedDaemonRestart(restartArgv, payload.cwd);
90955
- try {
90956
- fs20.unlinkSync(getUpgradeFailureNoticePath());
90957
- } catch {
90958
- }
91006
+ clearUpgradeFailureNotice();
90959
91007
  return;
90960
91008
  }
90961
91009
  const instanceDir = resolveInstanceDir();
@@ -91009,13 +91057,10 @@ ${body}
91009
91057
  `adhdev ${payload.packageName}@${payload.targetVersion} upgrade failed and was rolled back: ${error48?.message || String(error48)}`,
91010
91058
  `Previous version preserved (active prefix: ${windowsInstallerLayout.activePrefix}).`,
91011
91059
  "See daemon-upgrade.log for the full install/health trace. The next daemon start will retry."
91012
- ]);
91060
+ ], getConfigDir2(), { targetVersion: payload.targetVersion });
91013
91061
  throw error48;
91014
91062
  }
91015
- try {
91016
- fs20.unlinkSync(getUpgradeFailureNoticePath());
91017
- } catch {
91018
- }
91063
+ clearUpgradeFailureNotice();
91019
91064
  appendUpgradeLog("Installer-managed Windows atomic upgrade completed");
91020
91065
  return;
91021
91066
  }
@@ -91063,7 +91108,7 @@ ${body}
91063
91108
  notice.push("To recover, reinstall manually:");
91064
91109
  }
91065
91110
  notice.push(` ${buildManualRecoveryCommand(installCommand)}`);
91066
- emitUpgradeFailureNotice(notice);
91111
+ emitUpgradeFailureNotice(notice, getConfigDir2(), { targetVersion: payload.targetVersion });
91067
91112
  }
91068
91113
  throw error48;
91069
91114
  }
@@ -91082,7 +91127,7 @@ ${body}
91082
91127
  "so the running daemon was left on its previous version and was NOT restarted.",
91083
91128
  "To recover, reinstall (this forces the shipped prebuild instead of a source rebuild):",
91084
91129
  ` ${buildManualRecoveryCommand(installCommand)}`
91085
- ]);
91130
+ ], getConfigDir2(), { targetVersion: payload.targetVersion });
91086
91131
  throw error48;
91087
91132
  }
91088
91133
  }
@@ -91092,10 +91137,7 @@ ${body}
91092
91137
  appendUpgradeLog("Post-install staging cleanup complete");
91093
91138
  }
91094
91139
  spawnDetachedDaemonRestart(restartArgv, payload.cwd);
91095
- try {
91096
- fs20.unlinkSync(getUpgradeFailureNoticePath());
91097
- } catch {
91098
- }
91140
+ clearUpgradeFailureNotice();
91099
91141
  }
91100
91142
  function spawnDetachedDaemonRestart(restartArgv, cwd) {
91101
91143
  if (restartArgv.length > 0) {
@@ -124491,8 +124533,12 @@ data: ${JSON.stringify(msg.data)}
124491
124533
  loadMeshCoordinatorRegistry();
124492
124534
  const upgradeFailureNotice = readUpgradeFailureNotice();
124493
124535
  if (upgradeFailureNotice) {
124494
- LOG2.warn("Upgrade", `Previous daemon upgrade FAILED and was rolled back \u2014 this daemon is running the previous version. Notice (${upgradeFailureNotice.noticePath}):
124495
- ${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}`);
124496
124542
  }
124497
124543
  const appConfig = loadConfig2();
124498
124544
  const providerSourceMode = appConfig.providerSourceMode || "normal";