@adhdev/daemon-core 0.9.76-rc.12 → 0.9.76-rc.14
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.js
CHANGED
|
@@ -20167,6 +20167,7 @@ var yaml = __toESM(require("js-yaml"));
|
|
|
20167
20167
|
init_logger();
|
|
20168
20168
|
|
|
20169
20169
|
// src/commands/mesh-coordinator.ts
|
|
20170
|
+
var import_node_child_process3 = require("child_process");
|
|
20170
20171
|
var import_node_fs3 = require("fs");
|
|
20171
20172
|
var import_node_module2 = require("module");
|
|
20172
20173
|
var os17 = __toESM(require("os"));
|
|
@@ -20203,7 +20204,7 @@ function resolveMeshCoordinatorSetup(options) {
|
|
|
20203
20204
|
if (!mcpServer) {
|
|
20204
20205
|
return {
|
|
20205
20206
|
kind: "unsupported",
|
|
20206
|
-
reason: "Could not resolve the ADHDev MCP server entrypoint
|
|
20207
|
+
reason: "Could not resolve the ADHDev MCP server entrypoint and a Node runtime with WebSocket support for daemon IPC mode"
|
|
20207
20208
|
};
|
|
20208
20209
|
}
|
|
20209
20210
|
return {
|
|
@@ -20253,11 +20254,75 @@ function resolveMcpConfigPath(configPath, workspace) {
|
|
|
20253
20254
|
function resolveAdhdevMcpServerLaunch(options) {
|
|
20254
20255
|
const entryPath = resolveAdhdevMcpEntryPath(options.adhdevMcpEntryPath);
|
|
20255
20256
|
if (!entryPath) return null;
|
|
20257
|
+
const nodeExecutable = resolveMcpNodeExecutable(options.nodeExecutable);
|
|
20258
|
+
if (!nodeExecutable) return null;
|
|
20256
20259
|
return {
|
|
20257
|
-
command:
|
|
20260
|
+
command: nodeExecutable,
|
|
20258
20261
|
args: [entryPath, "--mode", "ipc", "--repo-mesh", options.meshId]
|
|
20259
20262
|
};
|
|
20260
20263
|
}
|
|
20264
|
+
function resolveMcpNodeExecutable(explicitExecutable) {
|
|
20265
|
+
const explicit = explicitExecutable?.trim();
|
|
20266
|
+
if (explicit) return explicit;
|
|
20267
|
+
const candidates = [];
|
|
20268
|
+
const addCandidate = (candidate) => {
|
|
20269
|
+
const trimmed = candidate?.trim();
|
|
20270
|
+
if (!trimmed) return;
|
|
20271
|
+
const normalized = normalizeExistingPath(trimmed) || trimmed;
|
|
20272
|
+
if (!candidates.includes(normalized)) candidates.push(normalized);
|
|
20273
|
+
};
|
|
20274
|
+
addCandidate(process.env.ADHDEV_MCP_NODE_EXECUTABLE);
|
|
20275
|
+
addCandidate(process.env.ADHDEV_NODE_EXECUTABLE);
|
|
20276
|
+
addCandidate(process.env.npm_node_execpath);
|
|
20277
|
+
addNodeCandidatesFromPath(process.env.PATH, addCandidate);
|
|
20278
|
+
addNodeCandidatesFromNvm(os17.homedir(), addCandidate);
|
|
20279
|
+
addCandidate("/opt/homebrew/bin/node");
|
|
20280
|
+
addCandidate("/usr/local/bin/node");
|
|
20281
|
+
addCandidate("/usr/bin/node");
|
|
20282
|
+
addCandidate(process.execPath);
|
|
20283
|
+
for (const candidate of candidates) {
|
|
20284
|
+
if (nodeRuntimeSupportsWebSocket(candidate)) return candidate;
|
|
20285
|
+
}
|
|
20286
|
+
return null;
|
|
20287
|
+
}
|
|
20288
|
+
function addNodeCandidatesFromPath(pathValue, addCandidate) {
|
|
20289
|
+
for (const entry of (pathValue || "").split(":")) {
|
|
20290
|
+
const dir = entry.trim();
|
|
20291
|
+
if (!dir) continue;
|
|
20292
|
+
addCandidate((0, import_node_path.join)(dir, "node"));
|
|
20293
|
+
}
|
|
20294
|
+
}
|
|
20295
|
+
function addNodeCandidatesFromNvm(homeDir, addCandidate) {
|
|
20296
|
+
const versionsDir = (0, import_node_path.join)(homeDir, ".nvm", "versions", "node");
|
|
20297
|
+
try {
|
|
20298
|
+
const versionDirs = (0, import_node_fs3.readdirSync)(versionsDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort(compareNodeVersionNamesDescending);
|
|
20299
|
+
for (const versionDir of versionDirs) {
|
|
20300
|
+
addCandidate((0, import_node_path.join)(versionsDir, versionDir, "bin", "node"));
|
|
20301
|
+
}
|
|
20302
|
+
} catch {
|
|
20303
|
+
}
|
|
20304
|
+
}
|
|
20305
|
+
function compareNodeVersionNamesDescending(a, b) {
|
|
20306
|
+
const parse = (value) => value.replace(/^v/, "").split(".").map((part) => Number.parseInt(part, 10) || 0);
|
|
20307
|
+
const left = parse(a);
|
|
20308
|
+
const right = parse(b);
|
|
20309
|
+
for (let i = 0; i < Math.max(left.length, right.length); i++) {
|
|
20310
|
+
const diff = (right[i] || 0) - (left[i] || 0);
|
|
20311
|
+
if (diff !== 0) return diff;
|
|
20312
|
+
}
|
|
20313
|
+
return b.localeCompare(a);
|
|
20314
|
+
}
|
|
20315
|
+
function nodeRuntimeSupportsWebSocket(nodeExecutable) {
|
|
20316
|
+
try {
|
|
20317
|
+
(0, import_node_child_process3.execFileSync)(nodeExecutable, ["-e", "process.exit(typeof WebSocket === 'function' ? 0 : 42)"], {
|
|
20318
|
+
stdio: "ignore",
|
|
20319
|
+
timeout: 3e3
|
|
20320
|
+
});
|
|
20321
|
+
return true;
|
|
20322
|
+
} catch {
|
|
20323
|
+
return false;
|
|
20324
|
+
}
|
|
20325
|
+
}
|
|
20261
20326
|
function resolveAdhdevMcpEntryPath(explicitPath) {
|
|
20262
20327
|
const explicit = explicitPath?.trim();
|
|
20263
20328
|
if (explicit) return normalizeExistingPath(explicit) || explicit;
|