@adhdev/daemon-standalone 0.9.76-rc.32 → 0.9.76-rc.33
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 +95 -54
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/vendor/mcp-server/index.js +119 -55
- package/vendor/mcp-server/index.js.map +1 -1
package/package.json
CHANGED
|
@@ -34578,6 +34578,96 @@ function normalizeExistingPath(filePath) {
|
|
|
34578
34578
|
return null;
|
|
34579
34579
|
}
|
|
34580
34580
|
}
|
|
34581
|
+
function readNonEmptyString(value) {
|
|
34582
|
+
return typeof value === "string" && value.trim() ? value.trim() : "";
|
|
34583
|
+
}
|
|
34584
|
+
function formatCompletionMetadata(event) {
|
|
34585
|
+
const parts = [
|
|
34586
|
+
readNonEmptyString(event.targetSessionId) ? `session_id=${readNonEmptyString(event.targetSessionId)}` : "",
|
|
34587
|
+
readNonEmptyString(event.providerType) ? `provider=${readNonEmptyString(event.providerType)}` : "",
|
|
34588
|
+
readNonEmptyString(event.providerSessionId) ? `provider_session_id=${readNonEmptyString(event.providerSessionId)}` : ""
|
|
34589
|
+
].filter(Boolean);
|
|
34590
|
+
return parts.length > 0 ? ` (${parts.join("; ")})` : "";
|
|
34591
|
+
}
|
|
34592
|
+
function buildMeshSystemMessage(args) {
|
|
34593
|
+
const metadata = formatCompletionMetadata(args.metadataEvent);
|
|
34594
|
+
if (args.event === "agent:generating_completed") {
|
|
34595
|
+
return `[System] ${args.nodeLabel} has completed its task and is now idle${metadata}. You may use mesh_read_chat to review its progress.`;
|
|
34596
|
+
}
|
|
34597
|
+
if (args.event === "agent:waiting_approval") {
|
|
34598
|
+
return `[System] ${args.nodeLabel} is waiting for approval to proceed${metadata}. You may use mesh_read_chat and mesh_approve to handle it.`;
|
|
34599
|
+
}
|
|
34600
|
+
return "";
|
|
34601
|
+
}
|
|
34602
|
+
function injectMeshSystemMessage(components, args) {
|
|
34603
|
+
const coordinatorInstances = components.instanceManager.getByCategory("cli").filter((inst) => {
|
|
34604
|
+
const instState = inst.getState();
|
|
34605
|
+
if (instState.settings?.meshCoordinatorFor !== args.meshId) return false;
|
|
34606
|
+
if (args.sourceInstanceId && instState.instanceId === args.sourceInstanceId) return false;
|
|
34607
|
+
return true;
|
|
34608
|
+
});
|
|
34609
|
+
if (coordinatorInstances.length === 0) return { success: true, forwarded: 0 };
|
|
34610
|
+
const messageText = buildMeshSystemMessage({
|
|
34611
|
+
event: args.event,
|
|
34612
|
+
nodeLabel: args.nodeLabel,
|
|
34613
|
+
metadataEvent: args.metadataEvent
|
|
34614
|
+
});
|
|
34615
|
+
if (!messageText) return { success: false, error: "unsupported mesh event" };
|
|
34616
|
+
for (const coord of coordinatorInstances) {
|
|
34617
|
+
const coordState = coord.getState();
|
|
34618
|
+
LOG.info("MeshEvents", `Forwarding mesh event to coordinator ${coordState.instanceId}`);
|
|
34619
|
+
coord.onEvent("send_message", { input: { text: messageText, textFallback: messageText } });
|
|
34620
|
+
}
|
|
34621
|
+
return { success: true, forwarded: coordinatorInstances.length };
|
|
34622
|
+
}
|
|
34623
|
+
function handleMeshForwardEvent(components, payload) {
|
|
34624
|
+
const eventName = readNonEmptyString(payload.event);
|
|
34625
|
+
if (eventName !== "agent:generating_completed" && eventName !== "agent:waiting_approval") {
|
|
34626
|
+
return { success: false, error: "unsupported mesh event" };
|
|
34627
|
+
}
|
|
34628
|
+
const meshId = readNonEmptyString(payload.meshId);
|
|
34629
|
+
if (!meshId) return { success: false, error: "meshId required" };
|
|
34630
|
+
const nodeId = readNonEmptyString(payload.nodeId);
|
|
34631
|
+
const workspace = readNonEmptyString(payload.workspace);
|
|
34632
|
+
const nodeLabel = nodeId ? `Node '${nodeId}'` : workspace ? `Agent at ${workspace}` : "Remote agent";
|
|
34633
|
+
return injectMeshSystemMessage(components, {
|
|
34634
|
+
meshId,
|
|
34635
|
+
nodeLabel,
|
|
34636
|
+
event: eventName,
|
|
34637
|
+
metadataEvent: {
|
|
34638
|
+
targetSessionId: readNonEmptyString(payload.targetSessionId) || readNonEmptyString(payload.sessionId),
|
|
34639
|
+
providerType: readNonEmptyString(payload.providerType),
|
|
34640
|
+
providerSessionId: readNonEmptyString(payload.providerSessionId)
|
|
34641
|
+
}
|
|
34642
|
+
});
|
|
34643
|
+
}
|
|
34644
|
+
function setupMeshEventForwarding(components) {
|
|
34645
|
+
components.instanceManager.onEvent((event) => {
|
|
34646
|
+
if (event.event !== "agent:generating_completed" && event.event !== "agent:waiting_approval") return;
|
|
34647
|
+
const instanceId = readNonEmptyString(event.instanceId);
|
|
34648
|
+
if (!instanceId) return;
|
|
34649
|
+
const sourceInstance = components.instanceManager.getInstance(instanceId);
|
|
34650
|
+
if (!sourceInstance || sourceInstance.category !== "cli") return;
|
|
34651
|
+
const state = sourceInstance.getState();
|
|
34652
|
+
const workspace = readNonEmptyString(state.workspace);
|
|
34653
|
+
if (!workspace) return;
|
|
34654
|
+
const settings = state.settings && typeof state.settings === "object" ? state.settings : {};
|
|
34655
|
+
const meshIdFromRuntime = readNonEmptyString(settings.meshNodeFor);
|
|
34656
|
+
const mesh = meshIdFromRuntime ? getMesh(meshIdFromRuntime) : getMeshByRepo(workspace);
|
|
34657
|
+
const meshId = meshIdFromRuntime || readNonEmptyString(mesh?.id);
|
|
34658
|
+
if (!meshId) return;
|
|
34659
|
+
const targetNode = mesh?.nodes?.find((n) => n.workspace === workspace);
|
|
34660
|
+
const runtimeNodeId = readNonEmptyString(settings.meshNodeId);
|
|
34661
|
+
const nodeLabel = targetNode ? `Node '${targetNode.id}'` : runtimeNodeId ? `Node '${runtimeNodeId}'` : `Agent at ${workspace}`;
|
|
34662
|
+
injectMeshSystemMessage(components, {
|
|
34663
|
+
meshId,
|
|
34664
|
+
sourceInstanceId: instanceId,
|
|
34665
|
+
nodeLabel,
|
|
34666
|
+
event: event.event,
|
|
34667
|
+
metadataEvent: event
|
|
34668
|
+
});
|
|
34669
|
+
});
|
|
34670
|
+
}
|
|
34581
34671
|
function buildRecentReadDebugSignature(snapshot) {
|
|
34582
34672
|
return [
|
|
34583
34673
|
snapshot.providerType,
|
|
@@ -39498,58 +39588,6 @@ function launchIDE(ide, workspacePath) {
|
|
|
39498
39588
|
return false;
|
|
39499
39589
|
}
|
|
39500
39590
|
}
|
|
39501
|
-
function readNonEmptyString(value) {
|
|
39502
|
-
return typeof value === "string" && value.trim() ? value.trim() : "";
|
|
39503
|
-
}
|
|
39504
|
-
function formatCompletionMetadata(event) {
|
|
39505
|
-
const parts = [
|
|
39506
|
-
readNonEmptyString(event.targetSessionId) ? `session_id=${readNonEmptyString(event.targetSessionId)}` : "",
|
|
39507
|
-
readNonEmptyString(event.providerType) ? `provider=${readNonEmptyString(event.providerType)}` : "",
|
|
39508
|
-
readNonEmptyString(event.providerSessionId) ? `provider_session_id=${readNonEmptyString(event.providerSessionId)}` : ""
|
|
39509
|
-
].filter(Boolean);
|
|
39510
|
-
return parts.length > 0 ? ` (${parts.join("; ")})` : "";
|
|
39511
|
-
}
|
|
39512
|
-
function setupMeshEventForwarding(components) {
|
|
39513
|
-
components.instanceManager.onEvent((event) => {
|
|
39514
|
-
if (event.event !== "agent:generating_completed" && event.event !== "agent:waiting_approval") return;
|
|
39515
|
-
const instanceId = readNonEmptyString(event.instanceId);
|
|
39516
|
-
if (!instanceId) return;
|
|
39517
|
-
const sourceInstance = components.instanceManager.getInstance(instanceId);
|
|
39518
|
-
if (!sourceInstance || sourceInstance.category !== "cli") return;
|
|
39519
|
-
const state = sourceInstance.getState();
|
|
39520
|
-
const workspace = readNonEmptyString(state.workspace);
|
|
39521
|
-
if (!workspace) return;
|
|
39522
|
-
const settings = state.settings && typeof state.settings === "object" ? state.settings : {};
|
|
39523
|
-
const meshIdFromRuntime = readNonEmptyString(settings.meshNodeFor);
|
|
39524
|
-
const mesh = meshIdFromRuntime ? getMesh(meshIdFromRuntime) : getMeshByRepo(workspace);
|
|
39525
|
-
const meshId = meshIdFromRuntime || readNonEmptyString(mesh?.id);
|
|
39526
|
-
if (!meshId) return;
|
|
39527
|
-
const allInstances = components.instanceManager.getByCategory("cli");
|
|
39528
|
-
const coordinatorInstances = allInstances.filter((inst) => {
|
|
39529
|
-
const instState = inst.getState();
|
|
39530
|
-
if (instState.settings?.meshCoordinatorFor !== meshId) return false;
|
|
39531
|
-
if (instState.instanceId === instanceId) return false;
|
|
39532
|
-
return true;
|
|
39533
|
-
});
|
|
39534
|
-
if (coordinatorInstances.length === 0) return;
|
|
39535
|
-
const targetNode = mesh?.nodes?.find((n) => n.workspace === workspace);
|
|
39536
|
-
const runtimeNodeId = readNonEmptyString(settings.meshNodeId);
|
|
39537
|
-
const nodeLabel = targetNode ? `Node '${targetNode.id}'` : runtimeNodeId ? `Node '${runtimeNodeId}'` : `Agent at ${workspace}`;
|
|
39538
|
-
const metadata = formatCompletionMetadata(event);
|
|
39539
|
-
let messageText = "";
|
|
39540
|
-
if (event.event === "agent:generating_completed") {
|
|
39541
|
-
messageText = `[System] ${nodeLabel} has completed its task and is now idle${metadata}. You may use mesh_read_chat to review its progress.`;
|
|
39542
|
-
} else if (event.event === "agent:waiting_approval") {
|
|
39543
|
-
messageText = `[System] ${nodeLabel} is waiting for approval to proceed${metadata}. You may use mesh_read_chat and mesh_approve to handle it.`;
|
|
39544
|
-
}
|
|
39545
|
-
if (!messageText) return;
|
|
39546
|
-
for (const coord of coordinatorInstances) {
|
|
39547
|
-
const coordState = coord.getState();
|
|
39548
|
-
LOG.info("MeshEvents", `Forwarding event from ${workspace} to coordinator ${coordState.instanceId}`);
|
|
39549
|
-
coord.onEvent("send_message", { input: { text: messageText, textFallback: messageText } });
|
|
39550
|
-
}
|
|
39551
|
-
});
|
|
39552
|
-
}
|
|
39553
39591
|
async function initDaemonComponents(config2) {
|
|
39554
39592
|
installGlobalInterceptor();
|
|
39555
39593
|
const appConfig = loadConfig();
|
|
@@ -50624,6 +50662,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
50624
50662
|
DEFAULT_ADHDEV_MCP_COMMAND = "adhdev-mcp";
|
|
50625
50663
|
HERMES_CLI_TYPE = "hermes-cli";
|
|
50626
50664
|
HERMES_MCP_CONFIG_PATH = "~/.hermes/config.yaml";
|
|
50665
|
+
init_mesh_config();
|
|
50666
|
+
init_logger();
|
|
50627
50667
|
init_config();
|
|
50628
50668
|
init_terminal_screen();
|
|
50629
50669
|
init_logger();
|
|
@@ -50805,6 +50845,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
50805
50845
|
async executeDaemonCommand(cmd, args) {
|
|
50806
50846
|
switch (cmd) {
|
|
50807
50847
|
// ─── CLI / ACP commands ───
|
|
50848
|
+
case "mesh_forward_event": {
|
|
50849
|
+
return handleMeshForwardEvent({ instanceManager: this.deps.instanceManager }, args);
|
|
50850
|
+
}
|
|
50808
50851
|
case "launch_cli":
|
|
50809
50852
|
case "stop_cli":
|
|
50810
50853
|
case "set_cli_view_mode":
|
|
@@ -55213,8 +55256,6 @@ data: ${JSON.stringify(msg.data)}
|
|
|
55213
55256
|
};
|
|
55214
55257
|
init_logger();
|
|
55215
55258
|
init_config();
|
|
55216
|
-
init_mesh_config();
|
|
55217
|
-
init_logger();
|
|
55218
55259
|
}
|
|
55219
55260
|
});
|
|
55220
55261
|
|
|
@@ -56629,6 +56670,17 @@ function extractGitDiff(value) {
|
|
|
56629
56670
|
function extractLaunchPayload(value) {
|
|
56630
56671
|
return findNestedPayload(value, (payload) => Boolean(payload?.sessionId || payload?.id || payload?.runtimeSessionId));
|
|
56631
56672
|
}
|
|
56673
|
+
function resolveCoordinatorNode(ctx) {
|
|
56674
|
+
const preferredNodeId = typeof ctx.mesh.coordinator?.preferredNodeId === "string" ? ctx.mesh.coordinator.preferredNodeId.trim() : "";
|
|
56675
|
+
if (preferredNodeId) {
|
|
56676
|
+
const preferred = ctx.mesh.nodes.find((n) => n.id === preferredNodeId && typeof n.daemonId === "string" && n.daemonId.trim());
|
|
56677
|
+
if (preferred) return preferred;
|
|
56678
|
+
}
|
|
56679
|
+
if (ctx.localDaemonId) {
|
|
56680
|
+
return ctx.mesh.nodes.find((n) => n.daemonId === ctx.localDaemonId);
|
|
56681
|
+
}
|
|
56682
|
+
return void 0;
|
|
56683
|
+
}
|
|
56632
56684
|
function meshSessionCacheKey(nodeId, runtimeSessionId) {
|
|
56633
56685
|
return `${nodeId}:${runtimeSessionId}`;
|
|
56634
56686
|
}
|
|
@@ -56934,12 +56986,15 @@ async function meshLaunchSession(ctx, args) {
|
|
|
56934
56986
|
return JSON.stringify({ success: false, error: `No usable provider detected for node '${args.node_id}' from providerPriority: ${failed.join("; ")}` });
|
|
56935
56987
|
}
|
|
56936
56988
|
}
|
|
56989
|
+
const coordinatorNode = resolveCoordinatorNode(ctx);
|
|
56937
56990
|
const result = await commandForNode(ctx, node, "launch_cli", {
|
|
56938
56991
|
cliType: resolvedProviderType,
|
|
56939
56992
|
dir: node.workspace,
|
|
56940
56993
|
settings: {
|
|
56941
56994
|
meshNodeFor: ctx.mesh.id,
|
|
56942
56995
|
meshNodeId: args.node_id,
|
|
56996
|
+
...coordinatorNode?.daemonId ? { meshCoordinatorDaemonId: coordinatorNode.daemonId } : {},
|
|
56997
|
+
...coordinatorNode?.id ? { meshCoordinatorNodeId: coordinatorNode.id } : {},
|
|
56943
56998
|
launchedByCoordinator: true
|
|
56944
56999
|
}
|
|
56945
57000
|
});
|
|
@@ -57174,7 +57229,16 @@ async function startMcpServer(opts) {
|
|
|
57174
57229
|
`);
|
|
57175
57230
|
process.exit(1);
|
|
57176
57231
|
}
|
|
57177
|
-
|
|
57232
|
+
let localDaemonId;
|
|
57233
|
+
if (transport instanceof IpcTransport) {
|
|
57234
|
+
try {
|
|
57235
|
+
const statusResult = await transport.getStatus();
|
|
57236
|
+
const instanceId = typeof statusResult?.status?.instanceId === "string" ? statusResult.status.instanceId.trim() : "";
|
|
57237
|
+
if (instanceId) localDaemonId = instanceId;
|
|
57238
|
+
} catch {
|
|
57239
|
+
}
|
|
57240
|
+
}
|
|
57241
|
+
const meshCtx = { mesh, transport, ...localDaemonId ? { localDaemonId } : {} };
|
|
57178
57242
|
const coordinatorPrompt = await buildMeshModeCoordinatorPrompt(mesh);
|
|
57179
57243
|
const server2 = new import_server.Server(
|
|
57180
57244
|
{ name: "adhdev-mcp-server", version: "0.9.75" },
|