@adhdev/daemon-core 0.9.76-rc.12 → 0.9.76-rc.13
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 +67 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +75 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/commands/mesh-coordinator.ts +80 -3
package/dist/index.mjs
CHANGED
|
@@ -19975,7 +19975,8 @@ init_logger();
|
|
|
19975
19975
|
import * as yaml from "js-yaml";
|
|
19976
19976
|
|
|
19977
19977
|
// src/commands/mesh-coordinator.ts
|
|
19978
|
-
import {
|
|
19978
|
+
import { execFileSync as execFileSync2 } from "child_process";
|
|
19979
|
+
import { existsSync as existsSync15, readdirSync as readdirSync6, realpathSync as realpathSync2 } from "fs";
|
|
19979
19980
|
import { createRequire as createRequire2 } from "module";
|
|
19980
19981
|
import * as os17 from "os";
|
|
19981
19982
|
import { dirname as dirname4, isAbsolute as isAbsolute10, join as join18, resolve as resolve13 } from "path";
|
|
@@ -20011,7 +20012,7 @@ function resolveMeshCoordinatorSetup(options) {
|
|
|
20011
20012
|
if (!mcpServer) {
|
|
20012
20013
|
return {
|
|
20013
20014
|
kind: "unsupported",
|
|
20014
|
-
reason: "Could not resolve the ADHDev MCP server entrypoint
|
|
20015
|
+
reason: "Could not resolve the ADHDev MCP server entrypoint and a Node runtime with WebSocket support for daemon IPC mode"
|
|
20015
20016
|
};
|
|
20016
20017
|
}
|
|
20017
20018
|
return {
|
|
@@ -20061,11 +20062,75 @@ function resolveMcpConfigPath(configPath, workspace) {
|
|
|
20061
20062
|
function resolveAdhdevMcpServerLaunch(options) {
|
|
20062
20063
|
const entryPath = resolveAdhdevMcpEntryPath(options.adhdevMcpEntryPath);
|
|
20063
20064
|
if (!entryPath) return null;
|
|
20065
|
+
const nodeExecutable = resolveMcpNodeExecutable(options.nodeExecutable);
|
|
20066
|
+
if (!nodeExecutable) return null;
|
|
20064
20067
|
return {
|
|
20065
|
-
command:
|
|
20068
|
+
command: nodeExecutable,
|
|
20066
20069
|
args: [entryPath, "--mode", "ipc", "--repo-mesh", options.meshId]
|
|
20067
20070
|
};
|
|
20068
20071
|
}
|
|
20072
|
+
function resolveMcpNodeExecutable(explicitExecutable) {
|
|
20073
|
+
const explicit = explicitExecutable?.trim();
|
|
20074
|
+
if (explicit) return explicit;
|
|
20075
|
+
const candidates = [];
|
|
20076
|
+
const addCandidate = (candidate) => {
|
|
20077
|
+
const trimmed = candidate?.trim();
|
|
20078
|
+
if (!trimmed) return;
|
|
20079
|
+
const normalized = normalizeExistingPath(trimmed) || trimmed;
|
|
20080
|
+
if (!candidates.includes(normalized)) candidates.push(normalized);
|
|
20081
|
+
};
|
|
20082
|
+
addCandidate(process.env.ADHDEV_MCP_NODE_EXECUTABLE);
|
|
20083
|
+
addCandidate(process.env.ADHDEV_NODE_EXECUTABLE);
|
|
20084
|
+
addCandidate(process.env.npm_node_execpath);
|
|
20085
|
+
addNodeCandidatesFromPath(process.env.PATH, addCandidate);
|
|
20086
|
+
addNodeCandidatesFromNvm(os17.homedir(), addCandidate);
|
|
20087
|
+
addCandidate("/opt/homebrew/bin/node");
|
|
20088
|
+
addCandidate("/usr/local/bin/node");
|
|
20089
|
+
addCandidate("/usr/bin/node");
|
|
20090
|
+
addCandidate(process.execPath);
|
|
20091
|
+
for (const candidate of candidates) {
|
|
20092
|
+
if (nodeRuntimeSupportsWebSocket(candidate)) return candidate;
|
|
20093
|
+
}
|
|
20094
|
+
return null;
|
|
20095
|
+
}
|
|
20096
|
+
function addNodeCandidatesFromPath(pathValue, addCandidate) {
|
|
20097
|
+
for (const entry of (pathValue || "").split(":")) {
|
|
20098
|
+
const dir = entry.trim();
|
|
20099
|
+
if (!dir) continue;
|
|
20100
|
+
addCandidate(join18(dir, "node"));
|
|
20101
|
+
}
|
|
20102
|
+
}
|
|
20103
|
+
function addNodeCandidatesFromNvm(homeDir, addCandidate) {
|
|
20104
|
+
const versionsDir = join18(homeDir, ".nvm", "versions", "node");
|
|
20105
|
+
try {
|
|
20106
|
+
const versionDirs = readdirSync6(versionsDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort(compareNodeVersionNamesDescending);
|
|
20107
|
+
for (const versionDir of versionDirs) {
|
|
20108
|
+
addCandidate(join18(versionsDir, versionDir, "bin", "node"));
|
|
20109
|
+
}
|
|
20110
|
+
} catch {
|
|
20111
|
+
}
|
|
20112
|
+
}
|
|
20113
|
+
function compareNodeVersionNamesDescending(a, b) {
|
|
20114
|
+
const parse = (value) => value.replace(/^v/, "").split(".").map((part) => Number.parseInt(part, 10) || 0);
|
|
20115
|
+
const left = parse(a);
|
|
20116
|
+
const right = parse(b);
|
|
20117
|
+
for (let i = 0; i < Math.max(left.length, right.length); i++) {
|
|
20118
|
+
const diff = (right[i] || 0) - (left[i] || 0);
|
|
20119
|
+
if (diff !== 0) return diff;
|
|
20120
|
+
}
|
|
20121
|
+
return b.localeCompare(a);
|
|
20122
|
+
}
|
|
20123
|
+
function nodeRuntimeSupportsWebSocket(nodeExecutable) {
|
|
20124
|
+
try {
|
|
20125
|
+
execFileSync2(nodeExecutable, ["-e", "process.exit(typeof WebSocket === 'function' ? 0 : 42)"], {
|
|
20126
|
+
stdio: "ignore",
|
|
20127
|
+
timeout: 3e3
|
|
20128
|
+
});
|
|
20129
|
+
return true;
|
|
20130
|
+
} catch {
|
|
20131
|
+
return false;
|
|
20132
|
+
}
|
|
20133
|
+
}
|
|
20069
20134
|
function resolveAdhdevMcpEntryPath(explicitPath) {
|
|
20070
20135
|
const explicit = explicitPath?.trim();
|
|
20071
20136
|
if (explicit) return normalizeExistingPath(explicit) || explicit;
|
|
@@ -20422,7 +20487,7 @@ function buildStatusSnapshot(options) {
|
|
|
20422
20487
|
}
|
|
20423
20488
|
|
|
20424
20489
|
// src/commands/upgrade-helper.ts
|
|
20425
|
-
import { execFileSync as
|
|
20490
|
+
import { execFileSync as execFileSync3 } from "child_process";
|
|
20426
20491
|
import { spawn as spawn3 } from "child_process";
|
|
20427
20492
|
import * as fs9 from "fs";
|
|
20428
20493
|
import * as os19 from "os";
|
|
@@ -20542,7 +20607,7 @@ function getNpmExecOptions(platform10 = process.platform) {
|
|
|
20542
20607
|
}
|
|
20543
20608
|
function execNpmCommandSync(args, options = {}, surface) {
|
|
20544
20609
|
const execOptions = surface?.execOptions || getNpmExecOptions();
|
|
20545
|
-
return
|
|
20610
|
+
return execFileSync3(
|
|
20546
20611
|
surface?.npmExecutable || "npm",
|
|
20547
20612
|
[...surface?.npmArgsPrefix || [], ...args],
|
|
20548
20613
|
{
|
|
@@ -20555,7 +20620,7 @@ function execNpmCommandSync(args, options = {}, surface) {
|
|
|
20555
20620
|
function killPid(pid) {
|
|
20556
20621
|
try {
|
|
20557
20622
|
if (process.platform === "win32") {
|
|
20558
|
-
|
|
20623
|
+
execFileSync3("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore", windowsHide: true });
|
|
20559
20624
|
} else {
|
|
20560
20625
|
process.kill(pid, "SIGTERM");
|
|
20561
20626
|
}
|
|
@@ -20567,7 +20632,7 @@ function killPid(pid) {
|
|
|
20567
20632
|
function getWindowsProcessCommandLine(pid) {
|
|
20568
20633
|
const pidFilter = `ProcessId=${pid}`;
|
|
20569
20634
|
try {
|
|
20570
|
-
const psOut =
|
|
20635
|
+
const psOut = execFileSync3("powershell.exe", [
|
|
20571
20636
|
"-NoProfile",
|
|
20572
20637
|
"-NonInteractive",
|
|
20573
20638
|
"-ExecutionPolicy",
|
|
@@ -20579,7 +20644,7 @@ function getWindowsProcessCommandLine(pid) {
|
|
|
20579
20644
|
} catch {
|
|
20580
20645
|
}
|
|
20581
20646
|
try {
|
|
20582
|
-
const wmicOut =
|
|
20647
|
+
const wmicOut = execFileSync3("wmic", [
|
|
20583
20648
|
"process",
|
|
20584
20649
|
"where",
|
|
20585
20650
|
pidFilter,
|
|
@@ -20595,7 +20660,7 @@ function getProcessCommandLine(pid) {
|
|
|
20595
20660
|
if (!Number.isFinite(pid) || pid <= 0) return null;
|
|
20596
20661
|
if (process.platform === "win32") return getWindowsProcessCommandLine(pid);
|
|
20597
20662
|
try {
|
|
20598
|
-
const text =
|
|
20663
|
+
const text = execFileSync3("ps", ["-o", "command=", "-p", String(pid)], {
|
|
20599
20664
|
encoding: "utf8",
|
|
20600
20665
|
timeout: 3e3,
|
|
20601
20666
|
stdio: ["ignore", "pipe", "ignore"]
|
|
@@ -20711,7 +20776,7 @@ async function runDaemonUpgradeHelper(payload) {
|
|
|
20711
20776
|
cleanupStaleGlobalInstallDirs(payload.packageName, installCommand.surface);
|
|
20712
20777
|
const spec = `${payload.packageName}@${payload.targetVersion || "latest"}`;
|
|
20713
20778
|
appendUpgradeLog(`Installing ${spec}`);
|
|
20714
|
-
const installOutput =
|
|
20779
|
+
const installOutput = execFileSync3(
|
|
20715
20780
|
installCommand.command,
|
|
20716
20781
|
installCommand.args,
|
|
20717
20782
|
{
|