@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
|
@@ -23,10 +23,12 @@ export type MeshCoordinatorSetup = {
|
|
|
23
23
|
};
|
|
24
24
|
export interface ResolveMeshCoordinatorSetupOptions {
|
|
25
25
|
provider?: ProviderModule | null;
|
|
26
|
+
cliType?: string;
|
|
26
27
|
meshId: string;
|
|
27
28
|
workspace: string;
|
|
28
29
|
adhdevMcpCommand?: string;
|
|
29
30
|
adhdevMcpEntryPath?: string;
|
|
30
31
|
nodeExecutable?: string;
|
|
31
32
|
}
|
|
33
|
+
export declare function createHermesManualMeshCoordinatorSetup(meshId: string, workspace: string): MeshCoordinatorSetup;
|
|
32
34
|
export declare function resolveMeshCoordinatorSetup(options: ResolveMeshCoordinatorSetupOptions): MeshCoordinatorSetup;
|
package/dist/index.js
CHANGED
|
@@ -20208,6 +20208,55 @@ var os17 = __toESM(require("os"));
|
|
|
20208
20208
|
var import_node_path = require("path");
|
|
20209
20209
|
var DEFAULT_SERVER_NAME = "adhdev-mesh";
|
|
20210
20210
|
var DEFAULT_ADHDEV_MCP_COMMAND = "adhdev-mcp";
|
|
20211
|
+
var HERMES_CLI_TYPE = "hermes-cli";
|
|
20212
|
+
var HERMES_MCP_CONFIG_PATH = "~/.hermes/config.yaml";
|
|
20213
|
+
function isHermesProvider(provider, cliType) {
|
|
20214
|
+
const type = cliType?.trim() || provider?.type?.trim() || "";
|
|
20215
|
+
return type === HERMES_CLI_TYPE;
|
|
20216
|
+
}
|
|
20217
|
+
function resolveHermesMeshCoordinatorSetup(options) {
|
|
20218
|
+
const mcpServer = resolveAdhdevMcpServerLaunch({
|
|
20219
|
+
meshId: options.meshId,
|
|
20220
|
+
nodeExecutable: options.nodeExecutable,
|
|
20221
|
+
adhdevMcpEntryPath: options.adhdevMcpEntryPath
|
|
20222
|
+
});
|
|
20223
|
+
if (!mcpServer) {
|
|
20224
|
+
return {
|
|
20225
|
+
kind: "unsupported",
|
|
20226
|
+
reason: "Could not resolve the ADHDev MCP server entrypoint and a Node runtime with WebSocket support for daemon IPC mode"
|
|
20227
|
+
};
|
|
20228
|
+
}
|
|
20229
|
+
const configPath = resolveMcpConfigPath(HERMES_MCP_CONFIG_PATH, options.workspace);
|
|
20230
|
+
if (!configPath.trim()) {
|
|
20231
|
+
return createHermesManualMeshCoordinatorSetup(options.meshId, options.workspace);
|
|
20232
|
+
}
|
|
20233
|
+
return {
|
|
20234
|
+
kind: "auto_import",
|
|
20235
|
+
serverName: DEFAULT_SERVER_NAME,
|
|
20236
|
+
configPath,
|
|
20237
|
+
configFormat: "hermes_config_yaml",
|
|
20238
|
+
mcpServer
|
|
20239
|
+
};
|
|
20240
|
+
}
|
|
20241
|
+
function createHermesManualMeshCoordinatorSetup(meshId, workspace) {
|
|
20242
|
+
return {
|
|
20243
|
+
kind: "manual",
|
|
20244
|
+
serverName: DEFAULT_SERVER_NAME,
|
|
20245
|
+
configFormat: "hermes_config_yaml",
|
|
20246
|
+
configPathCommand: HERMES_MCP_CONFIG_PATH,
|
|
20247
|
+
requiresRestart: true,
|
|
20248
|
+
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.",
|
|
20249
|
+
template: renderMeshCoordinatorTemplate(
|
|
20250
|
+
"mcp_servers:\n {{serverName}}:\n command: {{adhdevMcpCommand}}\n args:\n - --repo-mesh\n - {{meshId}}\n enabled: true\n",
|
|
20251
|
+
{
|
|
20252
|
+
meshId,
|
|
20253
|
+
workspace,
|
|
20254
|
+
serverName: DEFAULT_SERVER_NAME,
|
|
20255
|
+
adhdevMcpCommand: DEFAULT_ADHDEV_MCP_COMMAND
|
|
20256
|
+
}
|
|
20257
|
+
)
|
|
20258
|
+
};
|
|
20259
|
+
}
|
|
20211
20260
|
function resolveMeshCoordinatorSetup(options) {
|
|
20212
20261
|
const { provider, meshId, workspace } = options;
|
|
20213
20262
|
const config = provider?.meshCoordinator;
|
|
@@ -20217,6 +20266,9 @@ function resolveMeshCoordinatorSetup(options) {
|
|
|
20217
20266
|
reason: config?.reason || "Provider does not declare Repo Mesh coordinator support"
|
|
20218
20267
|
};
|
|
20219
20268
|
}
|
|
20269
|
+
if (isHermesProvider(provider, options.cliType)) {
|
|
20270
|
+
return resolveHermesMeshCoordinatorSetup(options);
|
|
20271
|
+
}
|
|
20220
20272
|
const mcpConfig = config.mcpConfig;
|
|
20221
20273
|
if (!mcpConfig || mcpConfig.mode === "none") {
|
|
20222
20274
|
return {
|
|
@@ -22036,6 +22088,7 @@ var DaemonCommandRouter = class {
|
|
|
22036
22088
|
const providerMeta = this.deps.providerLoader.resolve?.(cliType) || this.deps.providerLoader.getMeta(cliType);
|
|
22037
22089
|
const coordinatorSetup = resolveMeshCoordinatorSetup({
|
|
22038
22090
|
provider: providerMeta,
|
|
22091
|
+
cliType,
|
|
22039
22092
|
meshId,
|
|
22040
22093
|
workspace
|
|
22041
22094
|
});
|
|
@@ -22089,7 +22142,34 @@ var DaemonCommandRouter = class {
|
|
|
22089
22142
|
const { existsSync: existsSync23, readFileSync: readFileSync15, writeFileSync: writeFileSync12, copyFileSync: copyFileSync3, mkdirSync: mkdirSync14 } = await import("fs");
|
|
22090
22143
|
const { dirname: dirname9 } = await import("path");
|
|
22091
22144
|
const mcpConfigPath = coordinatorSetup.configPath;
|
|
22092
|
-
|
|
22145
|
+
const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
|
|
22146
|
+
const returnManualFallback = (message) => ({
|
|
22147
|
+
success: false,
|
|
22148
|
+
code: "mesh_coordinator_manual_mcp_setup_required",
|
|
22149
|
+
error: message,
|
|
22150
|
+
meshId,
|
|
22151
|
+
cliType,
|
|
22152
|
+
workspace,
|
|
22153
|
+
meshCoordinatorSetup: hermesManualFallback
|
|
22154
|
+
});
|
|
22155
|
+
const mcpServerEntry = {
|
|
22156
|
+
command: coordinatorSetup.mcpServer.command,
|
|
22157
|
+
args: coordinatorSetup.mcpServer.args
|
|
22158
|
+
};
|
|
22159
|
+
if (args?.inlineMesh) {
|
|
22160
|
+
mcpServerEntry.env = {
|
|
22161
|
+
ADHDEV_INLINE_MESH: JSON.stringify(mesh),
|
|
22162
|
+
ADHDEV_MCP_TRANSPORT: "ipc"
|
|
22163
|
+
};
|
|
22164
|
+
}
|
|
22165
|
+
try {
|
|
22166
|
+
mkdirSync14(dirname9(mcpConfigPath), { recursive: true });
|
|
22167
|
+
} catch (error) {
|
|
22168
|
+
const message = `Could not prepare MCP config path for automatic setup: ${error?.message || error}`;
|
|
22169
|
+
LOG.error("MeshCoordinator", message);
|
|
22170
|
+
if (hermesManualFallback) return returnManualFallback(message);
|
|
22171
|
+
return { success: false, code: "mesh_coordinator_config_write_failed", error: message, meshId, cliType, workspace };
|
|
22172
|
+
}
|
|
22093
22173
|
const hadExistingMcpConfig = existsSync23(mcpConfigPath);
|
|
22094
22174
|
let existingMcpConfig = {};
|
|
22095
22175
|
if (hadExistingMcpConfig) {
|
|
@@ -22105,16 +22185,6 @@ var DaemonCommandRouter = class {
|
|
|
22105
22185
|
};
|
|
22106
22186
|
}
|
|
22107
22187
|
}
|
|
22108
|
-
const mcpServerEntry = {
|
|
22109
|
-
command: coordinatorSetup.mcpServer.command,
|
|
22110
|
-
args: coordinatorSetup.mcpServer.args
|
|
22111
|
-
};
|
|
22112
|
-
if (args?.inlineMesh) {
|
|
22113
|
-
mcpServerEntry.env = {
|
|
22114
|
-
ADHDEV_INLINE_MESH: JSON.stringify(mesh),
|
|
22115
|
-
ADHDEV_MCP_TRANSPORT: "ipc"
|
|
22116
|
-
};
|
|
22117
|
-
}
|
|
22118
22188
|
const mcpServersKey = getMcpServersKey(configFormat);
|
|
22119
22189
|
const existingServers = existingMcpConfig[mcpServersKey];
|
|
22120
22190
|
const mcpConfig = {
|
|
@@ -22124,7 +22194,14 @@ var DaemonCommandRouter = class {
|
|
|
22124
22194
|
[coordinatorSetup.serverName]: mcpServerEntry
|
|
22125
22195
|
}
|
|
22126
22196
|
};
|
|
22127
|
-
|
|
22197
|
+
try {
|
|
22198
|
+
writeFileSync12(mcpConfigPath, serializeMeshCoordinatorMcpConfig(mcpConfig, configFormat), "utf-8");
|
|
22199
|
+
} catch (error) {
|
|
22200
|
+
const message = `Could not write MCP config for automatic setup: ${error?.message || error}`;
|
|
22201
|
+
LOG.error("MeshCoordinator", message);
|
|
22202
|
+
if (hermesManualFallback) return returnManualFallback(message);
|
|
22203
|
+
return { success: false, code: "mesh_coordinator_config_write_failed", error: message, meshId, cliType, workspace };
|
|
22204
|
+
}
|
|
22128
22205
|
LOG.info("MeshCoordinator", `Wrote ${mcpConfigPath} with ${coordinatorSetup.serverName} server`);
|
|
22129
22206
|
const cliArgs = [];
|
|
22130
22207
|
const launchEnv = {};
|