@adhdev/daemon-core 0.9.76-rc.19 → 0.9.76-rc.20
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/commands/mesh-coordinator.d.ts +2 -0
- package/dist/index.js +89 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +89 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/commands/mesh-coordinator.ts +57 -0
- package/src/commands/router.ts +45 -16
package/dist/index.mjs
CHANGED
|
@@ -20016,6 +20016,55 @@ import * as os17 from "os";
|
|
|
20016
20016
|
import { dirname as dirname4, isAbsolute as isAbsolute10, join as join18, resolve as resolve13 } from "path";
|
|
20017
20017
|
var DEFAULT_SERVER_NAME = "adhdev-mesh";
|
|
20018
20018
|
var DEFAULT_ADHDEV_MCP_COMMAND = "adhdev-mcp";
|
|
20019
|
+
var HERMES_CLI_TYPE = "hermes-cli";
|
|
20020
|
+
var HERMES_MCP_CONFIG_PATH = "~/.hermes/config.yaml";
|
|
20021
|
+
function isHermesProvider(provider, cliType) {
|
|
20022
|
+
const type = cliType?.trim() || provider?.type?.trim() || "";
|
|
20023
|
+
return type === HERMES_CLI_TYPE;
|
|
20024
|
+
}
|
|
20025
|
+
function resolveHermesMeshCoordinatorSetup(options) {
|
|
20026
|
+
const mcpServer = resolveAdhdevMcpServerLaunch({
|
|
20027
|
+
meshId: options.meshId,
|
|
20028
|
+
nodeExecutable: options.nodeExecutable,
|
|
20029
|
+
adhdevMcpEntryPath: options.adhdevMcpEntryPath
|
|
20030
|
+
});
|
|
20031
|
+
if (!mcpServer) {
|
|
20032
|
+
return {
|
|
20033
|
+
kind: "unsupported",
|
|
20034
|
+
reason: "Could not resolve the ADHDev MCP server entrypoint and a Node runtime with WebSocket support for daemon IPC mode"
|
|
20035
|
+
};
|
|
20036
|
+
}
|
|
20037
|
+
const configPath = resolveMcpConfigPath(HERMES_MCP_CONFIG_PATH, options.workspace);
|
|
20038
|
+
if (!configPath.trim()) {
|
|
20039
|
+
return createHermesManualMeshCoordinatorSetup(options.meshId, options.workspace);
|
|
20040
|
+
}
|
|
20041
|
+
return {
|
|
20042
|
+
kind: "auto_import",
|
|
20043
|
+
serverName: DEFAULT_SERVER_NAME,
|
|
20044
|
+
configPath,
|
|
20045
|
+
configFormat: "hermes_config_yaml",
|
|
20046
|
+
mcpServer
|
|
20047
|
+
};
|
|
20048
|
+
}
|
|
20049
|
+
function createHermesManualMeshCoordinatorSetup(meshId, workspace) {
|
|
20050
|
+
return {
|
|
20051
|
+
kind: "manual",
|
|
20052
|
+
serverName: DEFAULT_SERVER_NAME,
|
|
20053
|
+
configFormat: "hermes_config_yaml",
|
|
20054
|
+
configPathCommand: HERMES_MCP_CONFIG_PATH,
|
|
20055
|
+
requiresRestart: true,
|
|
20056
|
+
instructions: "Hermes CLI does not auto-import repo-local .mcp.json. Add this MCP server to Hermes config under mcp_servers, then start a fresh Hermes session.",
|
|
20057
|
+
template: renderMeshCoordinatorTemplate(
|
|
20058
|
+
"mcp_servers:\n {{serverName}}:\n command: {{adhdevMcpCommand}}\n args:\n - --repo-mesh\n - {{meshId}}\n enabled: true\n",
|
|
20059
|
+
{
|
|
20060
|
+
meshId,
|
|
20061
|
+
workspace,
|
|
20062
|
+
serverName: DEFAULT_SERVER_NAME,
|
|
20063
|
+
adhdevMcpCommand: DEFAULT_ADHDEV_MCP_COMMAND
|
|
20064
|
+
}
|
|
20065
|
+
)
|
|
20066
|
+
};
|
|
20067
|
+
}
|
|
20019
20068
|
function resolveMeshCoordinatorSetup(options) {
|
|
20020
20069
|
const { provider, meshId, workspace } = options;
|
|
20021
20070
|
const config = provider?.meshCoordinator;
|
|
@@ -20025,6 +20074,9 @@ function resolveMeshCoordinatorSetup(options) {
|
|
|
20025
20074
|
reason: config?.reason || "Provider does not declare Repo Mesh coordinator support"
|
|
20026
20075
|
};
|
|
20027
20076
|
}
|
|
20077
|
+
if (isHermesProvider(provider, options.cliType)) {
|
|
20078
|
+
return resolveHermesMeshCoordinatorSetup(options);
|
|
20079
|
+
}
|
|
20028
20080
|
const mcpConfig = config.mcpConfig;
|
|
20029
20081
|
if (!mcpConfig || mcpConfig.mode === "none") {
|
|
20030
20082
|
return {
|
|
@@ -21844,6 +21896,7 @@ var DaemonCommandRouter = class {
|
|
|
21844
21896
|
const providerMeta = this.deps.providerLoader.resolve?.(cliType) || this.deps.providerLoader.getMeta(cliType);
|
|
21845
21897
|
const coordinatorSetup = resolveMeshCoordinatorSetup({
|
|
21846
21898
|
provider: providerMeta,
|
|
21899
|
+
cliType,
|
|
21847
21900
|
meshId,
|
|
21848
21901
|
workspace
|
|
21849
21902
|
});
|
|
@@ -21897,7 +21950,34 @@ var DaemonCommandRouter = class {
|
|
|
21897
21950
|
const { existsSync: existsSync23, readFileSync: readFileSync15, writeFileSync: writeFileSync12, copyFileSync: copyFileSync3, mkdirSync: mkdirSync14 } = await import("fs");
|
|
21898
21951
|
const { dirname: dirname9 } = await import("path");
|
|
21899
21952
|
const mcpConfigPath = coordinatorSetup.configPath;
|
|
21900
|
-
|
|
21953
|
+
const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
|
|
21954
|
+
const returnManualFallback = (message) => ({
|
|
21955
|
+
success: false,
|
|
21956
|
+
code: "mesh_coordinator_manual_mcp_setup_required",
|
|
21957
|
+
error: message,
|
|
21958
|
+
meshId,
|
|
21959
|
+
cliType,
|
|
21960
|
+
workspace,
|
|
21961
|
+
meshCoordinatorSetup: hermesManualFallback
|
|
21962
|
+
});
|
|
21963
|
+
const mcpServerEntry = {
|
|
21964
|
+
command: coordinatorSetup.mcpServer.command,
|
|
21965
|
+
args: coordinatorSetup.mcpServer.args
|
|
21966
|
+
};
|
|
21967
|
+
if (args?.inlineMesh) {
|
|
21968
|
+
mcpServerEntry.env = {
|
|
21969
|
+
ADHDEV_INLINE_MESH: JSON.stringify(mesh),
|
|
21970
|
+
ADHDEV_MCP_TRANSPORT: "ipc"
|
|
21971
|
+
};
|
|
21972
|
+
}
|
|
21973
|
+
try {
|
|
21974
|
+
mkdirSync14(dirname9(mcpConfigPath), { recursive: true });
|
|
21975
|
+
} catch (error) {
|
|
21976
|
+
const message = `Could not prepare MCP config path for automatic setup: ${error?.message || error}`;
|
|
21977
|
+
LOG.error("MeshCoordinator", message);
|
|
21978
|
+
if (hermesManualFallback) return returnManualFallback(message);
|
|
21979
|
+
return { success: false, code: "mesh_coordinator_config_write_failed", error: message, meshId, cliType, workspace };
|
|
21980
|
+
}
|
|
21901
21981
|
const hadExistingMcpConfig = existsSync23(mcpConfigPath);
|
|
21902
21982
|
let existingMcpConfig = {};
|
|
21903
21983
|
if (hadExistingMcpConfig) {
|
|
@@ -21913,16 +21993,6 @@ var DaemonCommandRouter = class {
|
|
|
21913
21993
|
};
|
|
21914
21994
|
}
|
|
21915
21995
|
}
|
|
21916
|
-
const mcpServerEntry = {
|
|
21917
|
-
command: coordinatorSetup.mcpServer.command,
|
|
21918
|
-
args: coordinatorSetup.mcpServer.args
|
|
21919
|
-
};
|
|
21920
|
-
if (args?.inlineMesh) {
|
|
21921
|
-
mcpServerEntry.env = {
|
|
21922
|
-
ADHDEV_INLINE_MESH: JSON.stringify(mesh),
|
|
21923
|
-
ADHDEV_MCP_TRANSPORT: "ipc"
|
|
21924
|
-
};
|
|
21925
|
-
}
|
|
21926
21996
|
const mcpServersKey = getMcpServersKey(configFormat);
|
|
21927
21997
|
const existingServers = existingMcpConfig[mcpServersKey];
|
|
21928
21998
|
const mcpConfig = {
|
|
@@ -21932,7 +22002,14 @@ var DaemonCommandRouter = class {
|
|
|
21932
22002
|
[coordinatorSetup.serverName]: mcpServerEntry
|
|
21933
22003
|
}
|
|
21934
22004
|
};
|
|
21935
|
-
|
|
22005
|
+
try {
|
|
22006
|
+
writeFileSync12(mcpConfigPath, serializeMeshCoordinatorMcpConfig(mcpConfig, configFormat), "utf-8");
|
|
22007
|
+
} catch (error) {
|
|
22008
|
+
const message = `Could not write MCP config for automatic setup: ${error?.message || error}`;
|
|
22009
|
+
LOG.error("MeshCoordinator", message);
|
|
22010
|
+
if (hermesManualFallback) return returnManualFallback(message);
|
|
22011
|
+
return { success: false, code: "mesh_coordinator_config_write_failed", error: message, meshId, cliType, workspace };
|
|
22012
|
+
}
|
|
21936
22013
|
LOG.info("MeshCoordinator", `Wrote ${mcpConfigPath} with ${coordinatorSetup.serverName} server`);
|
|
21937
22014
|
const cliArgs = [];
|
|
21938
22015
|
const launchEnv = {};
|