@adhdev/daemon-standalone 0.9.82-rc.358 → 0.9.82-rc.359

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
@@ -30036,10 +30036,10 @@ var require_dist3 = __commonJS({
30036
30036
  }
30037
30037
  function getDaemonBuildInfo() {
30038
30038
  if (cached2) return cached2;
30039
- const commit = readInjected(true ? "7210e80591d8d9ab378ee786ffb233027437461a" : void 0) ?? "unknown";
30040
- const commitShort = readInjected(true ? "7210e805" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
30041
- const version2 = readInjected(true ? "0.9.82-rc.358" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
30042
- const builtAt = readInjected(true ? "2026-06-23T01:41:19.647Z" : void 0);
30039
+ const commit = readInjected(true ? "56a1f2a986ab2c2bb7888189d9b027d6067f2317" : void 0) ?? "unknown";
30040
+ const commitShort = readInjected(true ? "56a1f2a9" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
30041
+ const version2 = readInjected(true ? "0.9.82-rc.359" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
30042
+ const builtAt = readInjected(true ? "2026-06-23T05:03:37.127Z" : void 0);
30043
30043
  cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
30044
30044
  return cached2;
30045
30045
  }
@@ -42804,9 +42804,7 @@ ${cleanBody}`;
42804
42804
  const machineId = readNonEmptyString2(node?.machineId);
42805
42805
  const appConfig = loadConfig2();
42806
42806
  const localMachineId = readNonEmptyString2(appConfig.machineId) || readNonEmptyString2(appConfig.registeredMachineId);
42807
- const cloudDaemonId = localMachineId ? `daemon_${localMachineId}` : "";
42808
- const standaloneDaemonId = localMachineId ? `standalone_${localMachineId}` : "";
42809
- const daemonMatchesLocal = !daemonId || daemonId === cloudDaemonId || daemonId === standaloneDaemonId;
42807
+ const daemonMatchesLocal = !daemonId || daemonIdsEquivalent(daemonId, localMachineId);
42810
42808
  const machineMatchesLocal = !machineId || !!localMachineId && machineId === localMachineId;
42811
42809
  if (node?.isLocalWorktree === true) {
42812
42810
  return daemonMatchesLocal && machineMatchesLocal;
@@ -43742,7 +43740,7 @@ ${cleanBody}`;
43742
43740
  targetNodeId: autoNodeId
43743
43741
  });
43744
43742
  LOG2.info("MeshRecovery", `Auto-requeued failed task: ${task.id} for node ${autoNodeId}`);
43745
- const node = mesh?.nodes.find((n) => n.id === autoNodeId);
43743
+ const node = mesh?.nodes.find((n) => meshNodeIdMatches(n, autoNodeId));
43746
43744
  if (node) {
43747
43745
  components.cliManager.handleCliCommand("launch_cli", {
43748
43746
  cliType: recoveryContext.failedProviderType,
@@ -44487,7 +44485,7 @@ ${cleanBody}`;
44487
44485
  for (const node of mesh.nodes) {
44488
44486
  const nodeDaemonId = readNonEmptyString2(node.daemonId);
44489
44487
  if (!nodeDaemonId) continue;
44490
- if (localDaemonId && nodeDaemonId === localDaemonId) continue;
44488
+ if (daemonIdsEquivalent(nodeDaemonId, localDaemonId)) continue;
44491
44489
  if (candidateDaemonIds.includes(nodeDaemonId)) continue;
44492
44490
  for (const pendingEventArgs of pulls) {
44493
44491
  let events;
@@ -44544,7 +44542,7 @@ ${cleanBody}`;
44544
44542
  if (!sessionId || !nodeId || !taskId) continue;
44545
44543
  const node = nodeById.get(nodeId);
44546
44544
  const nodeDaemonId = readNonEmptyString2(node?.daemonId);
44547
- const isLocalNode = !nodeDaemonId || selfIds.includes(nodeDaemonId) || localDaemonId !== void 0 && nodeDaemonId === localDaemonId || !!components.instanceManager.getInstance(sessionId);
44545
+ const isLocalNode = !nodeDaemonId || selfIds.includes(nodeDaemonId) || daemonIdsEquivalent(nodeDaemonId, localDaemonId) || !!components.instanceManager.getInstance(sessionId);
44548
44546
  const providerType = readNonEmptyString2(dispatch.providerType);
44549
44547
  const readArgs = {
44550
44548
  sessionId,
@@ -44619,7 +44617,7 @@ ${cleanBody}`;
44619
44617
  const dispatchMeshCommand = components.dispatchMeshCommand;
44620
44618
  return Promise.all(mesh.nodes.map(async (node) => {
44621
44619
  const nodeDaemonId = readNonEmptyString2(node.daemonId);
44622
- const isLocalNode = !nodeDaemonId || selfIds.includes(nodeDaemonId) || localDaemonId !== void 0 && nodeDaemonId === localDaemonId;
44620
+ const isLocalNode = !nodeDaemonId || selfIds.includes(nodeDaemonId) || daemonIdsEquivalent(nodeDaemonId, localDaemonId);
44623
44621
  let statusResult;
44624
44622
  try {
44625
44623
  if (isLocalNode) {
@@ -74466,6 +74464,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
74466
74464
  const pathKey = Object.keys(env2).find((k) => k.toLowerCase() === "path") || "PATH";
74467
74465
  const current = env2[pathKey] || "";
74468
74466
  env2[pathKey] = current ? `${nodeBinDir};${current}` : nodeBinDir;
74467
+ env2.ADHDEV_BOOTSTRAP = "1";
74469
74468
  return env2;
74470
74469
  }
74471
74470
  function getNpmExecOptions(platform10 = process.platform) {
@@ -74575,6 +74574,94 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
74575
74574
  await waitForPidExit(killedPid, 15e3);
74576
74575
  }
74577
74576
  }
74577
+ var LOCKED_NATIVE_ADDON_BASENAMES = ["conpty.node", "ghostty-vt.dll"];
74578
+ function listForeignNativeAddonHolders(packageRoot) {
74579
+ if (process.platform !== "win32" || !packageRoot) return [];
74580
+ const rootLower = packageRoot.replace(/\//g, "\\").replace(/'/g, "''").toLowerCase();
74581
+ const endsWithChecks = LOCKED_NATIVE_ADDON_BASENAMES.map((name) => `$lf.EndsWith('${name}')`).join(" -or ");
74582
+ const script = [
74583
+ `$root = '${rootLower}'`,
74584
+ `Get-Process node -ErrorAction SilentlyContinue | ForEach-Object {`,
74585
+ ` $p = $_`,
74586
+ ` try {`,
74587
+ ` foreach ($m in $p.Modules) {`,
74588
+ ` $fn = $m.FileName`,
74589
+ ` if ($fn) {`,
74590
+ ` $lf = $fn.ToLower()`,
74591
+ ` if ($lf.StartsWith($root) -and (${endsWithChecks})) { $p.Id; break }`,
74592
+ ` }`,
74593
+ ` }`,
74594
+ ` } catch {}`,
74595
+ `}`
74596
+ ].join("\n");
74597
+ let out = "";
74598
+ try {
74599
+ out = String((0, import_child_process8.execFileSync)("powershell.exe", [
74600
+ "-NoProfile",
74601
+ "-NonInteractive",
74602
+ "-ExecutionPolicy",
74603
+ "Bypass",
74604
+ "-Command",
74605
+ script
74606
+ ], { encoding: "utf8", timeout: 8e3, stdio: ["ignore", "pipe", "ignore"], windowsHide: true })).trim();
74607
+ } catch {
74608
+ return [];
74609
+ }
74610
+ const selfPid = process.pid;
74611
+ const seen = /* @__PURE__ */ new Set();
74612
+ const holders = [];
74613
+ for (const line of out.split(/\r?\n/)) {
74614
+ const pid = Number.parseInt(line.trim(), 10);
74615
+ if (!Number.isFinite(pid) || pid <= 0 || pid === selfPid || seen.has(pid)) continue;
74616
+ seen.add(pid);
74617
+ holders.push({ pid, commandLine: getProcessCommandLine(pid) });
74618
+ }
74619
+ return holders;
74620
+ }
74621
+ async function stopForeignNativeAddonHolders(packageRoot, options = {}) {
74622
+ if (process.platform !== "win32" || !packageRoot) return [];
74623
+ const parentPid = Number.isFinite(options.parentPid) ? Number(options.parentPid) : -1;
74624
+ const holders = listForeignNativeAddonHolders(packageRoot);
74625
+ const results = [];
74626
+ for (const holder of holders) {
74627
+ if (holder.pid === parentPid) continue;
74628
+ appendUpgradeLog(
74629
+ `Foreign native-addon holder found: pid ${holder.pid}${holder.commandLine ? ` \u2014 ${holder.commandLine}` : ""}`
74630
+ );
74631
+ const killed = killPid2(holder.pid);
74632
+ if (killed) {
74633
+ await waitForPidExit(holder.pid, 15e3);
74634
+ appendUpgradeLog(`Terminated foreign native-addon holder pid ${holder.pid}`);
74635
+ } else {
74636
+ appendUpgradeLog(`Failed to terminate foreign native-addon holder pid ${holder.pid}`);
74637
+ }
74638
+ results.push({ ...holder, killed });
74639
+ }
74640
+ return results;
74641
+ }
74642
+ function getUpgradeFailureNoticePath() {
74643
+ const home = os27.homedir();
74644
+ const dir = path36.join(home, ".adhdev");
74645
+ try {
74646
+ fs25.mkdirSync(dir, { recursive: true });
74647
+ } catch {
74648
+ }
74649
+ return path36.join(dir, "daemon-upgrade-last-error.txt");
74650
+ }
74651
+ function buildManualRecoveryCommand(installCommand) {
74652
+ return [installCommand.command, ...installCommand.args].map((part) => /\s/.test(part) ? `"${part}"` : part).join(" ");
74653
+ }
74654
+ function emitUpgradeFailureNotice(lines) {
74655
+ const body = lines.join("\n");
74656
+ appendUpgradeLog(`Upgrade blocked \u2014 user action required:
74657
+ ${body}`);
74658
+ try {
74659
+ fs25.writeFileSync(getUpgradeFailureNoticePath(), `[${(/* @__PURE__ */ new Date()).toISOString()}]
74660
+ ${body}
74661
+ `, "utf8");
74662
+ } catch {
74663
+ }
74664
+ }
74578
74665
  function isRetriableInstallLockError(error48) {
74579
74666
  const code = error48?.code;
74580
74667
  if (code === "EBUSY" || code === "EPERM") return true;
@@ -74661,6 +74748,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
74661
74748
  }
74662
74749
  await stopSessionHostProcesses(sessionHostAppName);
74663
74750
  removeDaemonPidFile();
74751
+ await stopForeignNativeAddonHolders(installCommand.surface.packageRoot, { parentPid: payload.parentPid });
74664
74752
  cleanupStaleGlobalInstallDirs(payload.packageName, installCommand.surface);
74665
74753
  const spec = `${payload.packageName}@${payload.targetVersion || "latest"}`;
74666
74754
  appendUpgradeLog(`Installing ${spec}`);
@@ -74682,11 +74770,30 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
74682
74770
  break;
74683
74771
  } catch (error48) {
74684
74772
  if (attempt < maxInstallAttempts && isRetriableInstallLockError(error48)) {
74685
- appendUpgradeLog(`Install attempt ${attempt} hit a file lock (${error48?.code || "lock"}); cleaning staging and retrying after backoff`);
74773
+ appendUpgradeLog(`Install attempt ${attempt} hit a file lock (${error48?.code || "lock"}); clearing holders + staging and retrying after backoff`);
74774
+ await stopForeignNativeAddonHolders(installCommand.surface.packageRoot, { parentPid: payload.parentPid });
74686
74775
  cleanupStaleGlobalInstallDirs(payload.packageName, installCommand.surface);
74687
74776
  await new Promise((resolve24) => setTimeout(resolve24, attempt * 1500));
74688
74777
  continue;
74689
74778
  }
74779
+ if (isRetriableInstallLockError(error48)) {
74780
+ const blockers = listForeignNativeAddonHolders(installCommand.surface.packageRoot);
74781
+ const notice = [
74782
+ `adhdev ${spec} could not be installed: a file lock (${error48?.code || "EBUSY/EPERM"}) is blocking the native addon.`
74783
+ ];
74784
+ if (blockers.length > 0) {
74785
+ notice.push("Processes still holding the lock:");
74786
+ for (const b of blockers) {
74787
+ notice.push(` pid ${b.pid}${b.commandLine ? ` \u2014 ${b.commandLine}` : ""}`);
74788
+ }
74789
+ notice.push("To recover, stop them and reinstall:");
74790
+ notice.push(` Stop-Process -Id ${blockers.map((b) => b.pid).join(",")} -Force`);
74791
+ } else {
74792
+ notice.push("To recover, reinstall manually:");
74793
+ }
74794
+ notice.push(` ${buildManualRecoveryCommand(installCommand)}`);
74795
+ emitUpgradeFailureNotice(notice);
74796
+ }
74690
74797
  throw error48;
74691
74798
  }
74692
74799
  }
@@ -77351,7 +77458,7 @@ ${mergeTreeErr?.stderr || ""}`;
77351
77458
  return sanitizedInlineMesh;
77352
77459
  }
77353
77460
  async getMeshForCommand(meshId, inlineMesh, options) {
77354
- const preferInline = options?.preferInline === true;
77461
+ const preferInline = options?.preferInline !== false;
77355
77462
  if (preferInline) {
77356
77463
  const cached4 = this.getCachedInlineMesh(meshId);
77357
77464
  if (cached4) {
@@ -81710,7 +81817,7 @@ ${ptyResult.output.slice(-2e3)}`);
81710
81817
  workspace
81711
81818
  };
81712
81819
  }
81713
- const { existsSync: existsSync46, readFileSync: readFileSync37, writeFileSync: writeFileSync23, copyFileSync: copyFileSync4, mkdirSync: mkdirSync21 } = await import("fs");
81820
+ const { existsSync: existsSync46, readFileSync: readFileSync37, writeFileSync: writeFileSync24, copyFileSync: copyFileSync4, mkdirSync: mkdirSync21 } = await import("fs");
81714
81821
  const { dirname: dirname17 } = await import("path");
81715
81822
  const mcpConfigPath = coordinatorSetup.configPath;
81716
81823
  const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
@@ -81783,7 +81890,7 @@ ${ptyResult.output.slice(-2e3)}`);
81783
81890
  }
81784
81891
  };
81785
81892
  try {
81786
- writeFileSync23(mcpConfigPath, serializeMeshCoordinatorMcpConfig(mcpConfig, configFormat), "utf-8");
81893
+ writeFileSync24(mcpConfigPath, serializeMeshCoordinatorMcpConfig(mcpConfig, configFormat), "utf-8");
81787
81894
  } catch (error48) {
81788
81895
  const message = `Could not write MCP config for automatic setup: ${error48?.message || error48}`;
81789
81896
  LOG2.error("MeshCoordinator", message);