@adhdev/daemon-standalone 0.9.82-rc.357 → 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 ? "37b9d1d9e10336707dbc0861a96d5bcc55cc015e" : void 0) ?? "unknown";
30040
- const commitShort = readInjected(true ? "37b9d1d9" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
30041
- const version2 = readInjected(true ? "0.9.82-rc.357" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
30042
- const builtAt = readInjected(true ? "2026-06-23T00:25:47.104Z" : 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;
@@ -43540,7 +43538,7 @@ ${cleanBody}`;
43540
43538
  occurredAt: occurredAtMs != null ? new Date(occurredAtMs).toISOString() : void 0,
43541
43539
  taskId: eventTaskId
43542
43540
  });
43543
- const leaveDirectDispatchActive = !task && opts?.tentativeIfDirect === true;
43541
+ const leaveDirectDispatchActive = !task && opts?.tentativeIfDirect === true || !eventTaskId && !sessionHasActiveAssignment(args.meshId, sessionId);
43544
43542
  if (!leaveDirectDispatchActive) {
43545
43543
  updateDirectDispatchStatus(args.meshId, sessionId, outcome, eventTaskId);
43546
43544
  }
@@ -43639,7 +43637,9 @@ ${cleanBody}`;
43639
43637
  }
43640
43638
  if (sessionId) {
43641
43639
  const startedTaskId = readNonEmptyString2(args.metadataEvent.taskId) || void 0;
43642
- updateDirectDispatchStatus(args.meshId, sessionId, "acked", startedTaskId);
43640
+ if (startedTaskId || sessionHasActiveAssignment(args.meshId, sessionId)) {
43641
+ updateDirectDispatchStatus(args.meshId, sessionId, "acked", startedTaskId);
43642
+ }
43643
43643
  const activeDeliveries = (() => {
43644
43644
  try {
43645
43645
  return MeshRuntimeStore.getInstance().getActiveSessionDeliveries(args.meshId, sessionId);
@@ -43740,7 +43740,7 @@ ${cleanBody}`;
43740
43740
  targetNodeId: autoNodeId
43741
43741
  });
43742
43742
  LOG2.info("MeshRecovery", `Auto-requeued failed task: ${task.id} for node ${autoNodeId}`);
43743
- const node = mesh?.nodes.find((n) => n.id === autoNodeId);
43743
+ const node = mesh?.nodes.find((n) => meshNodeIdMatches(n, autoNodeId));
43744
43744
  if (node) {
43745
43745
  components.cliManager.handleCliCommand("launch_cli", {
43746
43746
  cliType: recoveryContext.failedProviderType,
@@ -44485,7 +44485,7 @@ ${cleanBody}`;
44485
44485
  for (const node of mesh.nodes) {
44486
44486
  const nodeDaemonId = readNonEmptyString2(node.daemonId);
44487
44487
  if (!nodeDaemonId) continue;
44488
- if (localDaemonId && nodeDaemonId === localDaemonId) continue;
44488
+ if (daemonIdsEquivalent(nodeDaemonId, localDaemonId)) continue;
44489
44489
  if (candidateDaemonIds.includes(nodeDaemonId)) continue;
44490
44490
  for (const pendingEventArgs of pulls) {
44491
44491
  let events;
@@ -44542,7 +44542,7 @@ ${cleanBody}`;
44542
44542
  if (!sessionId || !nodeId || !taskId) continue;
44543
44543
  const node = nodeById.get(nodeId);
44544
44544
  const nodeDaemonId = readNonEmptyString2(node?.daemonId);
44545
- 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);
44546
44546
  const providerType = readNonEmptyString2(dispatch.providerType);
44547
44547
  const readArgs = {
44548
44548
  sessionId,
@@ -44617,7 +44617,7 @@ ${cleanBody}`;
44617
44617
  const dispatchMeshCommand = components.dispatchMeshCommand;
44618
44618
  return Promise.all(mesh.nodes.map(async (node) => {
44619
44619
  const nodeDaemonId = readNonEmptyString2(node.daemonId);
44620
- const isLocalNode = !nodeDaemonId || selfIds.includes(nodeDaemonId) || localDaemonId !== void 0 && nodeDaemonId === localDaemonId;
44620
+ const isLocalNode = !nodeDaemonId || selfIds.includes(nodeDaemonId) || daemonIdsEquivalent(nodeDaemonId, localDaemonId);
44621
44621
  let statusResult;
44622
44622
  try {
44623
44623
  if (isLocalNode) {
@@ -49341,6 +49341,7 @@ ${lastSnapshot}`;
49341
49341
  evaluateCondition: () => evaluateCondition,
49342
49342
  extractButtonsFromRule: () => extractButtonsFromRule,
49343
49343
  extractTitle: () => extractTitle,
49344
+ lastContiguousNumberedBlock: () => lastContiguousNumberedBlock,
49344
49345
  resolveSections: () => resolveSections,
49345
49346
  sectionText: () => sectionText
49346
49347
  });
@@ -49581,7 +49582,6 @@ ${lastSnapshot}`;
49581
49582
  label += " " + next.trim();
49582
49583
  j += 1;
49583
49584
  }
49584
- if (buttons.some((b) => b.index === idx)) continue;
49585
49585
  const key = keyTemplate.replace(/\{index\}/g, String(idx));
49586
49586
  buttons.push({ index: idx, label, key, current });
49587
49587
  i = j - 1;
@@ -49593,13 +49593,22 @@ ${lastSnapshot}`;
49593
49593
  const idx = Number(m[1]);
49594
49594
  const label = String(m[2] ?? "").trim();
49595
49595
  if (!Number.isFinite(idx) || idx <= 0 || !label) continue;
49596
- if (buttons.some((b) => b.index === idx)) continue;
49597
49596
  const key = keyTemplate.replace(/\{index\}/g, String(idx));
49598
49597
  buttons.push({ index: idx, label, key, current: hasCursorMarker(m[0]) });
49599
49598
  }
49600
49599
  }
49601
- buttons.sort((a, b) => a.index - b.index);
49602
- return buttons;
49600
+ const block2 = lastContiguousNumberedBlock(buttons);
49601
+ block2.sort((a, b) => a.index - b.index);
49602
+ return block2;
49603
+ }
49604
+ function lastContiguousNumberedBlock(entries) {
49605
+ if (entries.length <= 1) return entries.slice();
49606
+ let start = entries.length - 1;
49607
+ for (let i = entries.length - 1; i > 0; i -= 1) {
49608
+ if (entries[i - 1].index === entries[i].index - 1) start = i - 1;
49609
+ else break;
49610
+ }
49611
+ return entries.slice(start);
49603
49612
  }
49604
49613
  function hasCursorMarker(text) {
49605
49614
  return /^\s*[❯›>]/.test(text);
@@ -63885,6 +63894,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
63885
63894
  return;
63886
63895
  }
63887
63896
  }
63897
+ init_evaluator();
63888
63898
  var fs13 = __toESM2(require("fs"));
63889
63899
  var os18 = __toESM2(require("os"));
63890
63900
  var path222 = __toESM2(require("path"));
@@ -65096,21 +65106,19 @@ ${formatManifestValidationIssues2(validation.issues)}`,
65096
65106
  const ec = action.extract_choices;
65097
65107
  if (!ec?.pattern) return [];
65098
65108
  const text = this.readScreenSectionText(ec.section);
65099
- const out = [];
65100
- const seen = /* @__PURE__ */ new Set();
65109
+ const all = [];
65101
65110
  for (const rawLine of text.split("\n")) {
65102
65111
  const line = rawLine.replace(/\r$/, "");
65103
65112
  const m = new RegExp(ec.pattern, ec.flags ?? "").exec(line);
65104
65113
  if (!m) continue;
65105
65114
  const idx = Number(m[1]);
65106
- if (!Number.isFinite(idx) || seen.has(idx)) continue;
65115
+ if (!Number.isFinite(idx) || idx <= 0) continue;
65107
65116
  const label = (m[2] ?? "").replace(/\s+/g, " ").trim();
65108
65117
  if (!label) continue;
65109
65118
  const current = /^\s*[❯›>]/.test(line) || /[✔✓●]\s*$/.test(label);
65110
- seen.add(idx);
65111
- out.push({ index: idx, label, current });
65119
+ all.push({ index: idx, label, current });
65112
65120
  }
65113
- return out;
65121
+ return lastContiguousNumberedBlock(all);
65114
65122
  }
65115
65123
  /** Live text of a named screen section (or the whole screen when no
65116
65124
  * section is named), resolved from the driver's current sections. */
@@ -74456,6 +74464,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
74456
74464
  const pathKey = Object.keys(env2).find((k) => k.toLowerCase() === "path") || "PATH";
74457
74465
  const current = env2[pathKey] || "";
74458
74466
  env2[pathKey] = current ? `${nodeBinDir};${current}` : nodeBinDir;
74467
+ env2.ADHDEV_BOOTSTRAP = "1";
74459
74468
  return env2;
74460
74469
  }
74461
74470
  function getNpmExecOptions(platform10 = process.platform) {
@@ -74565,6 +74574,94 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
74565
74574
  await waitForPidExit(killedPid, 15e3);
74566
74575
  }
74567
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
+ }
74568
74665
  function isRetriableInstallLockError(error48) {
74569
74666
  const code = error48?.code;
74570
74667
  if (code === "EBUSY" || code === "EPERM") return true;
@@ -74651,6 +74748,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
74651
74748
  }
74652
74749
  await stopSessionHostProcesses(sessionHostAppName);
74653
74750
  removeDaemonPidFile();
74751
+ await stopForeignNativeAddonHolders(installCommand.surface.packageRoot, { parentPid: payload.parentPid });
74654
74752
  cleanupStaleGlobalInstallDirs(payload.packageName, installCommand.surface);
74655
74753
  const spec = `${payload.packageName}@${payload.targetVersion || "latest"}`;
74656
74754
  appendUpgradeLog(`Installing ${spec}`);
@@ -74672,11 +74770,30 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
74672
74770
  break;
74673
74771
  } catch (error48) {
74674
74772
  if (attempt < maxInstallAttempts && isRetriableInstallLockError(error48)) {
74675
- 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 });
74676
74775
  cleanupStaleGlobalInstallDirs(payload.packageName, installCommand.surface);
74677
74776
  await new Promise((resolve24) => setTimeout(resolve24, attempt * 1500));
74678
74777
  continue;
74679
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
+ }
74680
74797
  throw error48;
74681
74798
  }
74682
74799
  }
@@ -77341,7 +77458,7 @@ ${mergeTreeErr?.stderr || ""}`;
77341
77458
  return sanitizedInlineMesh;
77342
77459
  }
77343
77460
  async getMeshForCommand(meshId, inlineMesh, options) {
77344
- const preferInline = options?.preferInline === true;
77461
+ const preferInline = options?.preferInline !== false;
77345
77462
  if (preferInline) {
77346
77463
  const cached4 = this.getCachedInlineMesh(meshId);
77347
77464
  if (cached4) {
@@ -81700,7 +81817,7 @@ ${ptyResult.output.slice(-2e3)}`);
81700
81817
  workspace
81701
81818
  };
81702
81819
  }
81703
- 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");
81704
81821
  const { dirname: dirname17 } = await import("path");
81705
81822
  const mcpConfigPath = coordinatorSetup.configPath;
81706
81823
  const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
@@ -81773,7 +81890,7 @@ ${ptyResult.output.slice(-2e3)}`);
81773
81890
  }
81774
81891
  };
81775
81892
  try {
81776
- writeFileSync23(mcpConfigPath, serializeMeshCoordinatorMcpConfig(mcpConfig, configFormat), "utf-8");
81893
+ writeFileSync24(mcpConfigPath, serializeMeshCoordinatorMcpConfig(mcpConfig, configFormat), "utf-8");
81777
81894
  } catch (error48) {
81778
81895
  const message = `Could not write MCP config for automatic setup: ${error48?.message || error48}`;
81779
81896
  LOG2.error("MeshCoordinator", message);