@adhdev/daemon-core 0.9.77-rc.10 → 0.9.77-rc.11
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 +8 -0
- package/dist/index.js +108 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +108 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/commands/mesh-coordinator.ts +28 -6
- package/src/commands/router.ts +99 -0
- package/src/commands/stream-commands.ts +8 -1
- package/src/mesh/mesh-events.ts +1 -1
|
@@ -17,6 +17,14 @@ export type MeshCoordinatorSetup = {
|
|
|
17
17
|
requiresRestart: boolean;
|
|
18
18
|
instructions: string;
|
|
19
19
|
template: string;
|
|
20
|
+
} | {
|
|
21
|
+
/** Provider registers MCP via its own CLI command (e.g. `codex mcp add` / `gemini mcp add`). */
|
|
22
|
+
kind: 'cli_command';
|
|
23
|
+
serverName: string;
|
|
24
|
+
/** The rendered shell command to execute before launching the coordinator session. */
|
|
25
|
+
command: string;
|
|
26
|
+
requiresRestart: boolean;
|
|
27
|
+
instructions: string;
|
|
20
28
|
} | {
|
|
21
29
|
kind: 'unsupported';
|
|
22
30
|
reason: string;
|
package/dist/index.js
CHANGED
|
@@ -1323,7 +1323,7 @@ function tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType)
|
|
|
1323
1323
|
targetSessionId: sessionId,
|
|
1324
1324
|
cliType: providerType,
|
|
1325
1325
|
action: "send_chat",
|
|
1326
|
-
|
|
1326
|
+
message: task.message
|
|
1327
1327
|
}).catch((e) => {
|
|
1328
1328
|
LOG.error("MeshQueue", `Failed to dispatch task to node ${nodeId}: ${e?.message}`);
|
|
1329
1329
|
});
|
|
@@ -15209,11 +15209,13 @@ async function handleOpenPanel(h, args) {
|
|
|
15209
15209
|
async function handlePtyInput(h, args) {
|
|
15210
15210
|
const { cliType, data, targetSessionId } = args || {};
|
|
15211
15211
|
if (!data) return { success: false, error: "data required" };
|
|
15212
|
+
const cleanData = typeof data === "string" ? data.replace(/\x1b\[\?[0-9;]*c/g, "") : data;
|
|
15213
|
+
if (!cleanData) return { success: true };
|
|
15212
15214
|
const adapter = h.getCliAdapter(targetSessionId || cliType);
|
|
15213
15215
|
if (!adapter || typeof adapter.writeRaw !== "function") {
|
|
15214
15216
|
return { success: false, error: `CLI adapter not found: ${targetSessionId || cliType || "unknown"}` };
|
|
15215
15217
|
}
|
|
15216
|
-
await adapter.writeRaw(
|
|
15218
|
+
await adapter.writeRaw(cleanData);
|
|
15217
15219
|
return { success: true };
|
|
15218
15220
|
}
|
|
15219
15221
|
function handlePtyResize(_h, args) {
|
|
@@ -21923,6 +21925,22 @@ function resolveMeshCoordinatorSetup(options) {
|
|
|
21923
21925
|
if (!instructions || !template?.trim()) {
|
|
21924
21926
|
return { kind: "unsupported", reason: "Provider manual MCP setup is missing instructions or template" };
|
|
21925
21927
|
}
|
|
21928
|
+
const renderedTemplate = renderMeshCoordinatorTemplate(template, {
|
|
21929
|
+
meshId,
|
|
21930
|
+
workspace,
|
|
21931
|
+
serverName,
|
|
21932
|
+
adhdevMcpCommand: options.adhdevMcpCommand || DEFAULT_ADHDEV_MCP_COMMAND
|
|
21933
|
+
});
|
|
21934
|
+
const isCliCommand = !renderedTemplate.trim().includes("\n") && !renderedTemplate.trim().startsWith("{");
|
|
21935
|
+
if (isCliCommand) {
|
|
21936
|
+
return {
|
|
21937
|
+
kind: "cli_command",
|
|
21938
|
+
serverName,
|
|
21939
|
+
command: renderedTemplate.trim(),
|
|
21940
|
+
requiresRestart: mcpConfig.requiresRestart === true,
|
|
21941
|
+
instructions
|
|
21942
|
+
};
|
|
21943
|
+
}
|
|
21926
21944
|
return {
|
|
21927
21945
|
kind: "manual",
|
|
21928
21946
|
serverName,
|
|
@@ -21930,12 +21948,7 @@ function resolveMeshCoordinatorSetup(options) {
|
|
|
21930
21948
|
configPathCommand: mcpConfig.configPathCommand,
|
|
21931
21949
|
requiresRestart: mcpConfig.requiresRestart === true,
|
|
21932
21950
|
instructions,
|
|
21933
|
-
template:
|
|
21934
|
-
meshId,
|
|
21935
|
-
workspace,
|
|
21936
|
-
serverName,
|
|
21937
|
-
adhdevMcpCommand: options.adhdevMcpCommand || DEFAULT_ADHDEV_MCP_COMMAND
|
|
21938
|
-
})
|
|
21951
|
+
template: renderedTemplate
|
|
21939
21952
|
};
|
|
21940
21953
|
}
|
|
21941
21954
|
return {
|
|
@@ -24117,6 +24130,93 @@ var DaemonCommandRouter = class {
|
|
|
24117
24130
|
meshCoordinatorSetup: coordinatorSetup
|
|
24118
24131
|
};
|
|
24119
24132
|
}
|
|
24133
|
+
if (coordinatorSetup.kind === "cli_command") {
|
|
24134
|
+
let cliCmdSystemPrompt = "";
|
|
24135
|
+
try {
|
|
24136
|
+
cliCmdSystemPrompt = buildCoordinatorSystemPrompt2({ mesh, coordinatorCliType: cliType });
|
|
24137
|
+
} catch (error) {
|
|
24138
|
+
const message = error?.message || String(error);
|
|
24139
|
+
LOG.error("MeshCoordinator", `Failed to build coordinator prompt: ${message}`);
|
|
24140
|
+
return {
|
|
24141
|
+
success: false,
|
|
24142
|
+
code: "mesh_coordinator_prompt_failed",
|
|
24143
|
+
error: `Failed to build Repo Mesh coordinator prompt: ${message}`,
|
|
24144
|
+
meshId,
|
|
24145
|
+
cliType,
|
|
24146
|
+
workspace
|
|
24147
|
+
};
|
|
24148
|
+
}
|
|
24149
|
+
try {
|
|
24150
|
+
const { execFileSync: execCmdSync } = await import("child_process");
|
|
24151
|
+
const cmdParts = coordinatorSetup.command.trim().split(/\s+/);
|
|
24152
|
+
const [regCmd, ...regArgs] = cmdParts;
|
|
24153
|
+
LOG.info("MeshCoordinator", `Running MCP registration: ${coordinatorSetup.command}`);
|
|
24154
|
+
execCmdSync(regCmd, regArgs, { stdio: "pipe", timeout: 15e3 });
|
|
24155
|
+
} catch (error) {
|
|
24156
|
+
LOG.warn("MeshCoordinator", `MCP registration command failed (may be pre-registered): ${error?.message || error}`);
|
|
24157
|
+
}
|
|
24158
|
+
const cliCmdArgs = [];
|
|
24159
|
+
const cliCmdEnv = {};
|
|
24160
|
+
if (cliCmdSystemPrompt) {
|
|
24161
|
+
if (cliType === "codex-cli") {
|
|
24162
|
+
cliCmdArgs.push("-c", `developer_instructions=${JSON.stringify(cliCmdSystemPrompt)}`);
|
|
24163
|
+
} else if (cliType === "gemini-cli") {
|
|
24164
|
+
try {
|
|
24165
|
+
const { writeFileSync: wfs, existsSync: efs, readFileSync: rfs } = await import("fs");
|
|
24166
|
+
const geminiMdPath = `${workspace}/GEMINI.md`;
|
|
24167
|
+
const marker = "<!-- adhdev-mesh-coordinator-prompt -->";
|
|
24168
|
+
const markerEnd = "<!-- /adhdev-mesh-coordinator-prompt -->";
|
|
24169
|
+
const block = `${marker}
|
|
24170
|
+
${cliCmdSystemPrompt}
|
|
24171
|
+
${markerEnd}`;
|
|
24172
|
+
if (efs(geminiMdPath)) {
|
|
24173
|
+
const existing = rfs(geminiMdPath, "utf-8");
|
|
24174
|
+
const replaced = existing.replace(
|
|
24175
|
+
new RegExp(`${marker}[\\s\\S]*?${markerEnd}`, "g"),
|
|
24176
|
+
block
|
|
24177
|
+
);
|
|
24178
|
+
wfs(geminiMdPath, replaced.includes(marker) ? replaced : `${existing}
|
|
24179
|
+
|
|
24180
|
+
${block}`);
|
|
24181
|
+
} else {
|
|
24182
|
+
wfs(geminiMdPath, block);
|
|
24183
|
+
}
|
|
24184
|
+
LOG.info("MeshCoordinator", `Wrote coordinator prompt to ${workspace}/GEMINI.md`);
|
|
24185
|
+
} catch (e) {
|
|
24186
|
+
LOG.warn("MeshCoordinator", `Could not write GEMINI.md: ${e?.message || e}`);
|
|
24187
|
+
}
|
|
24188
|
+
}
|
|
24189
|
+
}
|
|
24190
|
+
const cliCmdLaunch = await this.deps.cliManager.handleCliCommand("launch_cli", {
|
|
24191
|
+
cliType,
|
|
24192
|
+
dir: workspace,
|
|
24193
|
+
cliArgs: cliCmdArgs.length > 0 ? cliCmdArgs : void 0,
|
|
24194
|
+
env: Object.keys(cliCmdEnv).length > 0 ? cliCmdEnv : void 0,
|
|
24195
|
+
settings: { meshCoordinatorFor: meshId }
|
|
24196
|
+
});
|
|
24197
|
+
if (!cliCmdLaunch?.success) {
|
|
24198
|
+
return { success: false, error: cliCmdLaunch?.error || "Failed to launch CLI session" };
|
|
24199
|
+
}
|
|
24200
|
+
LOG.info("MeshCoordinator", `Launched ${cliType} coordinator (cli_command) for mesh ${meshId}`);
|
|
24201
|
+
try {
|
|
24202
|
+
const { appendLedgerEntry: appendLedgerEntry2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
|
|
24203
|
+
appendLedgerEntry2(meshId, {
|
|
24204
|
+
kind: "coordinator_started",
|
|
24205
|
+
sessionId: cliCmdLaunch.sessionId || cliCmdLaunch.id,
|
|
24206
|
+
providerType: cliType,
|
|
24207
|
+
payload: { workspace }
|
|
24208
|
+
});
|
|
24209
|
+
} catch {
|
|
24210
|
+
}
|
|
24211
|
+
return {
|
|
24212
|
+
success: true,
|
|
24213
|
+
meshId,
|
|
24214
|
+
cliType,
|
|
24215
|
+
workspace,
|
|
24216
|
+
sessionId: cliCmdLaunch.sessionId || cliCmdLaunch.id,
|
|
24217
|
+
mcpRegistered: true
|
|
24218
|
+
};
|
|
24219
|
+
}
|
|
24120
24220
|
const configFormat = coordinatorSetup.configFormat;
|
|
24121
24221
|
if (configFormat !== "claude_mcp_json" && configFormat !== "hermes_config_yaml") {
|
|
24122
24222
|
return {
|