@adhdev/daemon-core 0.9.76-rc.11 → 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/cli-adapters/provider-cli-adapter.d.ts +2 -1
- package/dist/cli-adapters/provider-cli-runtime.d.ts +1 -0
- package/dist/commands/cli-manager.d.ts +6 -4
- package/dist/index.js +158 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +167 -56
- package/dist/index.mjs.map +1 -1
- package/dist/providers/cli-provider-instance.d.ts +1 -0
- package/package.json +3 -1
- package/src/cli-adapters/provider-cli-adapter.ts +2 -0
- package/src/cli-adapters/provider-cli-runtime.ts +3 -2
- package/src/commands/cli-manager.ts +13 -3
- package/src/commands/mesh-coordinator.ts +91 -5
- package/src/commands/router.ts +54 -13
- package/src/providers/cli-provider-instance.ts +2 -1
package/dist/index.mjs
CHANGED
|
@@ -1630,7 +1630,7 @@ import * as os10 from "os";
|
|
|
1630
1630
|
import * as path15 from "path";
|
|
1631
1631
|
import { DEFAULT_SESSION_HOST_COLS, DEFAULT_SESSION_HOST_ROWS } from "@adhdev/session-host-core";
|
|
1632
1632
|
function resolveCliSpawnPlan(options) {
|
|
1633
|
-
const { provider, runtimeSettings, workingDir, extraArgs } = options;
|
|
1633
|
+
const { provider, runtimeSettings, workingDir, extraArgs, extraEnv } = options;
|
|
1634
1634
|
const { spawn: spawnConfig } = provider;
|
|
1635
1635
|
const configuredCommand = typeof runtimeSettings.executablePath === "string" && runtimeSettings.executablePath.trim() ? runtimeSettings.executablePath.trim() : spawnConfig.command;
|
|
1636
1636
|
const binaryPath = findBinary(configuredCommand);
|
|
@@ -1654,7 +1654,7 @@ function resolveCliSpawnPlan(options) {
|
|
|
1654
1654
|
shellCmd = binaryPath;
|
|
1655
1655
|
shellArgs = allArgs;
|
|
1656
1656
|
}
|
|
1657
|
-
const env = buildCliSpawnEnv(process.env, spawnConfig.env);
|
|
1657
|
+
const env = buildCliSpawnEnv(process.env, { ...spawnConfig.env || {}, ...extraEnv || {} });
|
|
1658
1658
|
env.TERMINAL_CWD = workingDir;
|
|
1659
1659
|
return {
|
|
1660
1660
|
binaryPath,
|
|
@@ -1753,8 +1753,9 @@ var init_provider_cli_adapter = __esm({
|
|
|
1753
1753
|
init_provider_cli_runtime();
|
|
1754
1754
|
init_provider_cli_shared();
|
|
1755
1755
|
ProviderCliAdapter = class _ProviderCliAdapter {
|
|
1756
|
-
constructor(provider, workingDir, extraArgs = [], transportFactory = new NodePtyTransportFactory()) {
|
|
1756
|
+
constructor(provider, workingDir, extraArgs = [], extraEnv = {}, transportFactory = new NodePtyTransportFactory()) {
|
|
1757
1757
|
this.extraArgs = extraArgs;
|
|
1758
|
+
this.extraEnv = extraEnv;
|
|
1758
1759
|
this.provider = provider;
|
|
1759
1760
|
this.transportFactory = transportFactory;
|
|
1760
1761
|
this.cliType = provider.type;
|
|
@@ -2070,7 +2071,8 @@ ${lastSnapshot}`;
|
|
|
2070
2071
|
provider: this.provider,
|
|
2071
2072
|
runtimeSettings: this.runtimeSettings,
|
|
2072
2073
|
workingDir: this.workingDir,
|
|
2073
|
-
extraArgs: this.extraArgs
|
|
2074
|
+
extraArgs: this.extraArgs,
|
|
2075
|
+
extraEnv: this.extraEnv
|
|
2074
2076
|
});
|
|
2075
2077
|
LOG.info("CLI", `[${this.cliType}] Spawning in ${this.workingDir}`);
|
|
2076
2078
|
this.resetTraceSession();
|
|
@@ -5786,17 +5788,17 @@ function checkPathExists(paths) {
|
|
|
5786
5788
|
return null;
|
|
5787
5789
|
}
|
|
5788
5790
|
async function detectIDEs(providerLoader) {
|
|
5789
|
-
const
|
|
5791
|
+
const os22 = platform();
|
|
5790
5792
|
const results = [];
|
|
5791
5793
|
for (const def of getMergedDefinitions()) {
|
|
5792
5794
|
const cliPath = findCliCommand(providerLoader?.getIdeCliCommand(def.id, def.cli) || def.cli);
|
|
5793
|
-
const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[
|
|
5795
|
+
const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[os22] || []) || []);
|
|
5794
5796
|
let resolvedCli = cliPath;
|
|
5795
|
-
if (!resolvedCli && appPath &&
|
|
5797
|
+
if (!resolvedCli && appPath && os22 === "darwin") {
|
|
5796
5798
|
const bundledCli = `${appPath}/Contents/Resources/app/bin/${def.cli}`;
|
|
5797
5799
|
if (existsSync6(bundledCli)) resolvedCli = bundledCli;
|
|
5798
5800
|
}
|
|
5799
|
-
if (!resolvedCli && appPath &&
|
|
5801
|
+
if (!resolvedCli && appPath && os22 === "win32") {
|
|
5800
5802
|
const { dirname: dirname9 } = await import("path");
|
|
5801
5803
|
const appDir = dirname9(appPath);
|
|
5802
5804
|
const candidates = [
|
|
@@ -5813,7 +5815,7 @@ async function detectIDEs(providerLoader) {
|
|
|
5813
5815
|
}
|
|
5814
5816
|
}
|
|
5815
5817
|
}
|
|
5816
|
-
const installed =
|
|
5818
|
+
const installed = os22 === "darwin" ? !!(resolvedCli || appPath) : !!resolvedCli;
|
|
5817
5819
|
const version = resolvedCli ? getIdeVersion(resolvedCli) : null;
|
|
5818
5820
|
results.push({
|
|
5819
5821
|
id: def.id,
|
|
@@ -14746,7 +14748,7 @@ var CliProviderInstance = class {
|
|
|
14746
14748
|
this.providerSessionId = options?.providerSessionId;
|
|
14747
14749
|
this.launchMode = options?.launchMode || "new";
|
|
14748
14750
|
this.onProviderSessionResolved = options?.onProviderSessionResolved;
|
|
14749
|
-
this.adapter = new ProviderCliAdapter(provider, workingDir, cliArgs, transportFactory);
|
|
14751
|
+
this.adapter = new ProviderCliAdapter(provider, workingDir, cliArgs, options?.extraEnv || {}, transportFactory);
|
|
14750
14752
|
this.monitor = new StatusMonitor();
|
|
14751
14753
|
this.historyWriter = new ChatHistoryWriter();
|
|
14752
14754
|
}
|
|
@@ -16962,7 +16964,7 @@ var DaemonCliManager = class {
|
|
|
16962
16964
|
attachExisting
|
|
16963
16965
|
}) || void 0;
|
|
16964
16966
|
}
|
|
16965
|
-
createAdapter(cliType, workingDir, cliArgs, runtimeId, providerSessionId, attachExisting = false) {
|
|
16967
|
+
createAdapter(cliType, workingDir, cliArgs, runtimeId, providerSessionId, attachExisting = false, extraEnv) {
|
|
16966
16968
|
const normalizedType = this.providerLoader.resolveAlias(cliType);
|
|
16967
16969
|
const provider = this.providerLoader.getMeta(normalizedType);
|
|
16968
16970
|
if (provider && provider.category === "cli" && provider.patterns && provider.spawn) {
|
|
@@ -16976,7 +16978,7 @@ var DaemonCliManager = class {
|
|
|
16976
16978
|
providerSessionId,
|
|
16977
16979
|
attachExisting
|
|
16978
16980
|
);
|
|
16979
|
-
return new ProviderCliAdapter(resolvedProvider, workingDir, cliArgs, transportFactory);
|
|
16981
|
+
return new ProviderCliAdapter(resolvedProvider, workingDir, cliArgs, extraEnv || {}, transportFactory);
|
|
16980
16982
|
}
|
|
16981
16983
|
throw new Error(`No CLI provider found for '${cliType}'. Create a provider.js in providers/cli/${cliType}/`);
|
|
16982
16984
|
}
|
|
@@ -17179,6 +17181,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
17179
17181
|
{
|
|
17180
17182
|
providerSessionId: sessionBinding.providerSessionId,
|
|
17181
17183
|
launchMode: sessionBinding.launchMode,
|
|
17184
|
+
extraEnv: options?.extraEnv,
|
|
17182
17185
|
onProviderSessionResolved: ({ providerSessionId, providerName, providerType, workspace }) => {
|
|
17183
17186
|
this.persistRecentActivity({
|
|
17184
17187
|
kind: "cli",
|
|
@@ -17199,7 +17202,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
17199
17202
|
resolvedCliArgs,
|
|
17200
17203
|
key,
|
|
17201
17204
|
sessionBinding.providerSessionId,
|
|
17202
|
-
false
|
|
17205
|
+
false,
|
|
17206
|
+
options?.extraEnv
|
|
17203
17207
|
);
|
|
17204
17208
|
try {
|
|
17205
17209
|
await adapter.spawn();
|
|
@@ -17428,7 +17432,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
17428
17432
|
dir,
|
|
17429
17433
|
args?.cliArgs,
|
|
17430
17434
|
args?.initialModel,
|
|
17431
|
-
{ resumeSessionId: args?.resumeSessionId, settingsOverride: args?.settings }
|
|
17435
|
+
{ resumeSessionId: args?.resumeSessionId, settingsOverride: args?.settings, extraEnv: args?.env }
|
|
17432
17436
|
);
|
|
17433
17437
|
return {
|
|
17434
17438
|
success: true,
|
|
@@ -19968,11 +19972,14 @@ cleanOldFiles();
|
|
|
19968
19972
|
|
|
19969
19973
|
// src/commands/router.ts
|
|
19970
19974
|
init_logger();
|
|
19975
|
+
import * as yaml from "js-yaml";
|
|
19971
19976
|
|
|
19972
19977
|
// src/commands/mesh-coordinator.ts
|
|
19973
|
-
import {
|
|
19978
|
+
import { execFileSync as execFileSync2 } from "child_process";
|
|
19979
|
+
import { existsSync as existsSync15, readdirSync as readdirSync6, realpathSync as realpathSync2 } from "fs";
|
|
19974
19980
|
import { createRequire as createRequire2 } from "module";
|
|
19975
|
-
import
|
|
19981
|
+
import * as os17 from "os";
|
|
19982
|
+
import { dirname as dirname4, isAbsolute as isAbsolute10, join as join18, resolve as resolve13 } from "path";
|
|
19976
19983
|
var DEFAULT_SERVER_NAME = "adhdev-mesh";
|
|
19977
19984
|
var DEFAULT_ADHDEV_MCP_COMMAND = "adhdev-mcp";
|
|
19978
19985
|
function resolveMeshCoordinatorSetup(options) {
|
|
@@ -20005,13 +20012,13 @@ function resolveMeshCoordinatorSetup(options) {
|
|
|
20005
20012
|
if (!mcpServer) {
|
|
20006
20013
|
return {
|
|
20007
20014
|
kind: "unsupported",
|
|
20008
|
-
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"
|
|
20009
20016
|
};
|
|
20010
20017
|
}
|
|
20011
20018
|
return {
|
|
20012
20019
|
kind: "auto_import",
|
|
20013
20020
|
serverName,
|
|
20014
|
-
configPath:
|
|
20021
|
+
configPath: resolveMcpConfigPath(path27, workspace),
|
|
20015
20022
|
configFormat: mcpConfig.format,
|
|
20016
20023
|
mcpServer
|
|
20017
20024
|
};
|
|
@@ -20045,14 +20052,85 @@ function resolveMeshCoordinatorSetup(options) {
|
|
|
20045
20052
|
function renderMeshCoordinatorTemplate(template, values) {
|
|
20046
20053
|
return template.replace(/\{\{\s*(meshId|workspace|serverName|adhdevMcpCommand)\s*\}\}/g, (_, key) => values[key] || "");
|
|
20047
20054
|
}
|
|
20055
|
+
function resolveMcpConfigPath(configPath, workspace) {
|
|
20056
|
+
const trimmed = configPath.trim();
|
|
20057
|
+
if (trimmed === "~") return os17.homedir();
|
|
20058
|
+
if (trimmed.startsWith("~/")) return join18(os17.homedir(), trimmed.slice(2));
|
|
20059
|
+
if (isAbsolute10(trimmed)) return trimmed;
|
|
20060
|
+
return join18(workspace, trimmed);
|
|
20061
|
+
}
|
|
20048
20062
|
function resolveAdhdevMcpServerLaunch(options) {
|
|
20049
20063
|
const entryPath = resolveAdhdevMcpEntryPath(options.adhdevMcpEntryPath);
|
|
20050
20064
|
if (!entryPath) return null;
|
|
20065
|
+
const nodeExecutable = resolveMcpNodeExecutable(options.nodeExecutable);
|
|
20066
|
+
if (!nodeExecutable) return null;
|
|
20051
20067
|
return {
|
|
20052
|
-
command:
|
|
20068
|
+
command: nodeExecutable,
|
|
20053
20069
|
args: [entryPath, "--mode", "ipc", "--repo-mesh", options.meshId]
|
|
20054
20070
|
};
|
|
20055
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
|
+
}
|
|
20056
20134
|
function resolveAdhdevMcpEntryPath(explicitPath) {
|
|
20057
20135
|
const explicit = explicitPath?.trim();
|
|
20058
20136
|
if (explicit) return normalizeExistingPath(explicit) || explicit;
|
|
@@ -20097,7 +20175,7 @@ function normalizeExistingPath(filePath) {
|
|
|
20097
20175
|
|
|
20098
20176
|
// src/status/snapshot.ts
|
|
20099
20177
|
init_config();
|
|
20100
|
-
import * as
|
|
20178
|
+
import * as os18 from "os";
|
|
20101
20179
|
init_terminal_screen();
|
|
20102
20180
|
init_logger();
|
|
20103
20181
|
var READ_DEBUG_ENABLED = process.argv.includes("--dev") || process.env.ADHDEV_READ_DEBUG === "1";
|
|
@@ -20152,8 +20230,8 @@ function buildAvailableProviders(providerLoader) {
|
|
|
20152
20230
|
}
|
|
20153
20231
|
function buildMachineInfo(profile = "full") {
|
|
20154
20232
|
const base = {
|
|
20155
|
-
hostname:
|
|
20156
|
-
platform:
|
|
20233
|
+
hostname: os18.hostname(),
|
|
20234
|
+
platform: os18.platform()
|
|
20157
20235
|
};
|
|
20158
20236
|
if (profile === "live") {
|
|
20159
20237
|
return base;
|
|
@@ -20162,23 +20240,23 @@ function buildMachineInfo(profile = "full") {
|
|
|
20162
20240
|
const memSnap2 = getHostMemorySnapshot();
|
|
20163
20241
|
return {
|
|
20164
20242
|
...base,
|
|
20165
|
-
arch:
|
|
20166
|
-
cpus:
|
|
20243
|
+
arch: os18.arch(),
|
|
20244
|
+
cpus: os18.cpus().length,
|
|
20167
20245
|
totalMem: memSnap2.totalMem,
|
|
20168
|
-
release:
|
|
20246
|
+
release: os18.release()
|
|
20169
20247
|
};
|
|
20170
20248
|
}
|
|
20171
20249
|
const memSnap = getHostMemorySnapshot();
|
|
20172
20250
|
return {
|
|
20173
20251
|
...base,
|
|
20174
|
-
arch:
|
|
20175
|
-
cpus:
|
|
20252
|
+
arch: os18.arch(),
|
|
20253
|
+
cpus: os18.cpus().length,
|
|
20176
20254
|
totalMem: memSnap.totalMem,
|
|
20177
20255
|
freeMem: memSnap.freeMem,
|
|
20178
20256
|
availableMem: memSnap.availableMem,
|
|
20179
|
-
loadavg:
|
|
20180
|
-
uptime:
|
|
20181
|
-
release:
|
|
20257
|
+
loadavg: os18.loadavg(),
|
|
20258
|
+
uptime: os18.uptime(),
|
|
20259
|
+
release: os18.release()
|
|
20182
20260
|
};
|
|
20183
20261
|
}
|
|
20184
20262
|
function parseMessageTime(value) {
|
|
@@ -20409,14 +20487,14 @@ function buildStatusSnapshot(options) {
|
|
|
20409
20487
|
}
|
|
20410
20488
|
|
|
20411
20489
|
// src/commands/upgrade-helper.ts
|
|
20412
|
-
import { execFileSync as
|
|
20490
|
+
import { execFileSync as execFileSync3 } from "child_process";
|
|
20413
20491
|
import { spawn as spawn3 } from "child_process";
|
|
20414
20492
|
import * as fs9 from "fs";
|
|
20415
|
-
import * as
|
|
20493
|
+
import * as os19 from "os";
|
|
20416
20494
|
import * as path21 from "path";
|
|
20417
20495
|
var UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
|
|
20418
20496
|
function getUpgradeLogPath() {
|
|
20419
|
-
const home =
|
|
20497
|
+
const home = os19.homedir();
|
|
20420
20498
|
const dir = path21.join(home, ".adhdev");
|
|
20421
20499
|
fs9.mkdirSync(dir, { recursive: true });
|
|
20422
20500
|
return path21.join(dir, "daemon-upgrade.log");
|
|
@@ -20529,7 +20607,7 @@ function getNpmExecOptions(platform10 = process.platform) {
|
|
|
20529
20607
|
}
|
|
20530
20608
|
function execNpmCommandSync(args, options = {}, surface) {
|
|
20531
20609
|
const execOptions = surface?.execOptions || getNpmExecOptions();
|
|
20532
|
-
return
|
|
20610
|
+
return execFileSync3(
|
|
20533
20611
|
surface?.npmExecutable || "npm",
|
|
20534
20612
|
[...surface?.npmArgsPrefix || [], ...args],
|
|
20535
20613
|
{
|
|
@@ -20542,7 +20620,7 @@ function execNpmCommandSync(args, options = {}, surface) {
|
|
|
20542
20620
|
function killPid(pid) {
|
|
20543
20621
|
try {
|
|
20544
20622
|
if (process.platform === "win32") {
|
|
20545
|
-
|
|
20623
|
+
execFileSync3("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore", windowsHide: true });
|
|
20546
20624
|
} else {
|
|
20547
20625
|
process.kill(pid, "SIGTERM");
|
|
20548
20626
|
}
|
|
@@ -20554,7 +20632,7 @@ function killPid(pid) {
|
|
|
20554
20632
|
function getWindowsProcessCommandLine(pid) {
|
|
20555
20633
|
const pidFilter = `ProcessId=${pid}`;
|
|
20556
20634
|
try {
|
|
20557
|
-
const psOut =
|
|
20635
|
+
const psOut = execFileSync3("powershell.exe", [
|
|
20558
20636
|
"-NoProfile",
|
|
20559
20637
|
"-NonInteractive",
|
|
20560
20638
|
"-ExecutionPolicy",
|
|
@@ -20566,7 +20644,7 @@ function getWindowsProcessCommandLine(pid) {
|
|
|
20566
20644
|
} catch {
|
|
20567
20645
|
}
|
|
20568
20646
|
try {
|
|
20569
|
-
const wmicOut =
|
|
20647
|
+
const wmicOut = execFileSync3("wmic", [
|
|
20570
20648
|
"process",
|
|
20571
20649
|
"where",
|
|
20572
20650
|
pidFilter,
|
|
@@ -20582,7 +20660,7 @@ function getProcessCommandLine(pid) {
|
|
|
20582
20660
|
if (!Number.isFinite(pid) || pid <= 0) return null;
|
|
20583
20661
|
if (process.platform === "win32") return getWindowsProcessCommandLine(pid);
|
|
20584
20662
|
try {
|
|
20585
|
-
const text =
|
|
20663
|
+
const text = execFileSync3("ps", ["-o", "command=", "-p", String(pid)], {
|
|
20586
20664
|
encoding: "utf8",
|
|
20587
20665
|
timeout: 3e3,
|
|
20588
20666
|
stdio: ["ignore", "pipe", "ignore"]
|
|
@@ -20608,7 +20686,7 @@ async function waitForPidExit(pid, timeoutMs) {
|
|
|
20608
20686
|
}
|
|
20609
20687
|
}
|
|
20610
20688
|
function stopSessionHostProcesses(appName) {
|
|
20611
|
-
const pidFile = path21.join(
|
|
20689
|
+
const pidFile = path21.join(os19.homedir(), ".adhdev", `${appName}-session-host.pid`);
|
|
20612
20690
|
try {
|
|
20613
20691
|
if (fs9.existsSync(pidFile)) {
|
|
20614
20692
|
const pid = Number.parseInt(fs9.readFileSync(pidFile, "utf8").trim(), 10);
|
|
@@ -20625,7 +20703,7 @@ function stopSessionHostProcesses(appName) {
|
|
|
20625
20703
|
}
|
|
20626
20704
|
}
|
|
20627
20705
|
function removeDaemonPidFile() {
|
|
20628
|
-
const pidFile = path21.join(
|
|
20706
|
+
const pidFile = path21.join(os19.homedir(), ".adhdev", "daemon.pid");
|
|
20629
20707
|
try {
|
|
20630
20708
|
fs9.unlinkSync(pidFile);
|
|
20631
20709
|
} catch {
|
|
@@ -20698,7 +20776,7 @@ async function runDaemonUpgradeHelper(payload) {
|
|
|
20698
20776
|
cleanupStaleGlobalInstallDirs(payload.packageName, installCommand.surface);
|
|
20699
20777
|
const spec = `${payload.packageName}@${payload.targetVersion || "latest"}`;
|
|
20700
20778
|
appendUpgradeLog(`Installing ${spec}`);
|
|
20701
|
-
const installOutput =
|
|
20779
|
+
const installOutput = execFileSync3(
|
|
20702
20780
|
installCommand.command,
|
|
20703
20781
|
installCommand.args,
|
|
20704
20782
|
{
|
|
@@ -20763,6 +20841,22 @@ function normalizeReleaseChannel(value) {
|
|
|
20763
20841
|
function resolveUpgradeChannel(args) {
|
|
20764
20842
|
return normalizeReleaseChannel(args?.channel) || normalizeReleaseChannel(args?.updatePolicy?.channel) || normalizeReleaseChannel(args?.npmTag) || normalizeReleaseChannel(loadConfig().updateChannel) || "stable";
|
|
20765
20843
|
}
|
|
20844
|
+
function loadYamlModule() {
|
|
20845
|
+
return yaml;
|
|
20846
|
+
}
|
|
20847
|
+
function getMcpServersKey(format) {
|
|
20848
|
+
return format === "hermes_config_yaml" ? "mcp_servers" : "mcpServers";
|
|
20849
|
+
}
|
|
20850
|
+
function parseMeshCoordinatorMcpConfig(text, format) {
|
|
20851
|
+
if (!text.trim()) return {};
|
|
20852
|
+
if (format === "claude_mcp_json") return JSON.parse(text);
|
|
20853
|
+
const parsed = loadYamlModule().load(text);
|
|
20854
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
|
|
20855
|
+
}
|
|
20856
|
+
function serializeMeshCoordinatorMcpConfig(config, format) {
|
|
20857
|
+
if (format === "claude_mcp_json") return JSON.stringify(config, null, 2);
|
|
20858
|
+
return loadYamlModule().dump(config, { noRefs: true, lineWidth: 120 });
|
|
20859
|
+
}
|
|
20766
20860
|
var CHAT_COMMANDS = [
|
|
20767
20861
|
"send_chat",
|
|
20768
20862
|
"new_chat",
|
|
@@ -21740,7 +21834,8 @@ var DaemonCommandRouter = class {
|
|
|
21740
21834
|
meshCoordinatorSetup: coordinatorSetup
|
|
21741
21835
|
};
|
|
21742
21836
|
}
|
|
21743
|
-
|
|
21837
|
+
const configFormat = coordinatorSetup.configFormat;
|
|
21838
|
+
if (configFormat !== "claude_mcp_json" && configFormat !== "hermes_config_yaml") {
|
|
21744
21839
|
return {
|
|
21745
21840
|
success: false,
|
|
21746
21841
|
code: "mesh_coordinator_unsupported",
|
|
@@ -21765,15 +21860,23 @@ var DaemonCommandRouter = class {
|
|
|
21765
21860
|
workspace
|
|
21766
21861
|
};
|
|
21767
21862
|
}
|
|
21768
|
-
const { existsSync: existsSync23, readFileSync: readFileSync15, writeFileSync: writeFileSync12, copyFileSync: copyFileSync3 } = await import("fs");
|
|
21863
|
+
const { existsSync: existsSync23, readFileSync: readFileSync15, writeFileSync: writeFileSync12, copyFileSync: copyFileSync3, mkdirSync: mkdirSync14 } = await import("fs");
|
|
21864
|
+
const { dirname: dirname9 } = await import("path");
|
|
21769
21865
|
const mcpConfigPath = coordinatorSetup.configPath;
|
|
21866
|
+
mkdirSync14(dirname9(mcpConfigPath), { recursive: true });
|
|
21770
21867
|
const hadExistingMcpConfig = existsSync23(mcpConfigPath);
|
|
21771
21868
|
let existingMcpConfig = {};
|
|
21772
21869
|
if (hadExistingMcpConfig) {
|
|
21773
21870
|
try {
|
|
21774
|
-
existingMcpConfig =
|
|
21871
|
+
existingMcpConfig = parseMeshCoordinatorMcpConfig(readFileSync15(mcpConfigPath, "utf-8"), configFormat);
|
|
21775
21872
|
copyFileSync3(mcpConfigPath, mcpConfigPath + ".backup");
|
|
21776
|
-
} catch {
|
|
21873
|
+
} catch (error) {
|
|
21874
|
+
LOG.error("MeshCoordinator", `Failed to parse existing MCP config ${mcpConfigPath}: ${error?.message || error}`);
|
|
21875
|
+
return {
|
|
21876
|
+
success: false,
|
|
21877
|
+
code: "mesh_coordinator_config_parse_failed",
|
|
21878
|
+
error: `Failed to parse existing MCP config at ${mcpConfigPath}`
|
|
21879
|
+
};
|
|
21777
21880
|
}
|
|
21778
21881
|
}
|
|
21779
21882
|
const mcpServerEntry = {
|
|
@@ -21786,18 +21889,25 @@ var DaemonCommandRouter = class {
|
|
|
21786
21889
|
ADHDEV_MCP_TRANSPORT: "ipc"
|
|
21787
21890
|
};
|
|
21788
21891
|
}
|
|
21892
|
+
const mcpServersKey = getMcpServersKey(configFormat);
|
|
21893
|
+
const existingServers = existingMcpConfig[mcpServersKey];
|
|
21789
21894
|
const mcpConfig = {
|
|
21790
21895
|
...existingMcpConfig,
|
|
21791
|
-
|
|
21792
|
-
...
|
|
21896
|
+
[mcpServersKey]: {
|
|
21897
|
+
...existingServers && typeof existingServers === "object" && !Array.isArray(existingServers) ? existingServers : {},
|
|
21793
21898
|
[coordinatorSetup.serverName]: mcpServerEntry
|
|
21794
21899
|
}
|
|
21795
21900
|
};
|
|
21796
|
-
writeFileSync12(mcpConfigPath,
|
|
21901
|
+
writeFileSync12(mcpConfigPath, serializeMeshCoordinatorMcpConfig(mcpConfig, configFormat), "utf-8");
|
|
21797
21902
|
LOG.info("MeshCoordinator", `Wrote ${mcpConfigPath} with ${coordinatorSetup.serverName} server`);
|
|
21798
21903
|
const cliArgs = [];
|
|
21904
|
+
const launchEnv = {};
|
|
21799
21905
|
if (systemPrompt) {
|
|
21800
|
-
|
|
21906
|
+
if (configFormat === "hermes_config_yaml") {
|
|
21907
|
+
launchEnv.HERMES_EPHEMERAL_SYSTEM_PROMPT = systemPrompt;
|
|
21908
|
+
} else {
|
|
21909
|
+
cliArgs.push("--append-system-prompt", systemPrompt);
|
|
21910
|
+
}
|
|
21801
21911
|
}
|
|
21802
21912
|
if (cliType === "claude-cli") {
|
|
21803
21913
|
cliArgs.push("--mcp-config", coordinatorSetup.configPath);
|
|
@@ -21806,6 +21916,7 @@ var DaemonCommandRouter = class {
|
|
|
21806
21916
|
cliType,
|
|
21807
21917
|
dir: workspace,
|
|
21808
21918
|
cliArgs: cliArgs.length > 0 ? cliArgs : void 0,
|
|
21919
|
+
env: Object.keys(launchEnv).length > 0 ? launchEnv : void 0,
|
|
21809
21920
|
settings: {
|
|
21810
21921
|
meshCoordinatorFor: meshId
|
|
21811
21922
|
}
|
|
@@ -23467,10 +23578,10 @@ var ProviderInstanceManager = class {
|
|
|
23467
23578
|
// src/providers/version-archive.ts
|
|
23468
23579
|
import * as fs11 from "fs";
|
|
23469
23580
|
import * as path22 from "path";
|
|
23470
|
-
import * as
|
|
23581
|
+
import * as os20 from "os";
|
|
23471
23582
|
import { execSync as execSync5 } from "child_process";
|
|
23472
23583
|
import { platform as platform8 } from "os";
|
|
23473
|
-
var ARCHIVE_PATH = path22.join(
|
|
23584
|
+
var ARCHIVE_PATH = path22.join(os20.homedir(), ".adhdev", "version-history.json");
|
|
23474
23585
|
var MAX_ENTRIES_PER_PROVIDER = 20;
|
|
23475
23586
|
var VersionArchive = class {
|
|
23476
23587
|
history = {};
|
|
@@ -23573,7 +23684,7 @@ function getVersion(binary, versionCommand) {
|
|
|
23573
23684
|
function checkPathExists2(paths) {
|
|
23574
23685
|
for (const p of paths) {
|
|
23575
23686
|
if (p.includes("*")) {
|
|
23576
|
-
const home =
|
|
23687
|
+
const home = os20.homedir();
|
|
23577
23688
|
const resolved = p.replace(/\*/g, home.split(path22.sep).pop() || "");
|
|
23578
23689
|
if (fs11.existsSync(resolved)) return resolved;
|
|
23579
23690
|
} else {
|
|
@@ -25962,7 +26073,7 @@ async function handleCliRaw(ctx, req, res) {
|
|
|
25962
26073
|
// src/daemon/dev-auto-implement.ts
|
|
25963
26074
|
import * as fs14 from "fs";
|
|
25964
26075
|
import * as path25 from "path";
|
|
25965
|
-
import * as
|
|
26076
|
+
import * as os21 from "os";
|
|
25966
26077
|
function getAutoImplPid(ctx) {
|
|
25967
26078
|
const pid = ctx.autoImplProcess?.pid;
|
|
25968
26079
|
return typeof pid === "number" && pid > 0 ? pid : null;
|
|
@@ -26163,7 +26274,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
26163
26274
|
});
|
|
26164
26275
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
26165
26276
|
const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
|
|
26166
|
-
const tmpDir = path25.join(
|
|
26277
|
+
const tmpDir = path25.join(os21.tmpdir(), "adhdev-autoimpl");
|
|
26167
26278
|
if (!fs14.existsSync(tmpDir)) fs14.mkdirSync(tmpDir, { recursive: true });
|
|
26168
26279
|
const promptFile = path25.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
|
|
26169
26280
|
fs14.writeFileSync(promptFile, prompt, "utf-8");
|
|
@@ -26318,7 +26429,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
26318
26429
|
const interactiveFlags = ["--yolo", "--interactive", "-i"];
|
|
26319
26430
|
const baseArgs = [...spawn4.args || []].filter((a) => !interactiveFlags.includes(a));
|
|
26320
26431
|
let shellCmd;
|
|
26321
|
-
const isWin =
|
|
26432
|
+
const isWin = os21.platform() === "win32";
|
|
26322
26433
|
const escapeArg = (a) => isWin ? `"${a.replace(/"/g, '""')}"` : `'${a.replace(/'/g, "'\\''")}'`;
|
|
26323
26434
|
const promptMode = autoImpl?.promptMode ?? "stdin";
|
|
26324
26435
|
const extraArgs = autoImpl?.extraArgs ?? [];
|
|
@@ -26357,7 +26468,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
26357
26468
|
try {
|
|
26358
26469
|
const pty = __require("node-pty");
|
|
26359
26470
|
ctx.log(`Auto-implement spawn (PTY): ${shellCmd}`);
|
|
26360
|
-
const isWin2 =
|
|
26471
|
+
const isWin2 = os21.platform() === "win32";
|
|
26361
26472
|
child = pty.spawn(isWin2 ? "cmd.exe" : process.env.SHELL || "/bin/zsh", [isWin2 ? "/c" : "-c", shellCmd], {
|
|
26362
26473
|
name: "xterm-256color",
|
|
26363
26474
|
cols: 120,
|