@adhdev/daemon-standalone 0.9.76-rc.32 → 0.9.76-rc.34

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/daemon-standalone",
3
- "version": "0.9.76-rc.32",
3
+ "version": "0.9.76-rc.34",
4
4
  "description": "ADHDev standalone daemon — embedded HTTP/WS server for local dashboard",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -31123,6 +31123,14 @@ function buildChatDebugBundleSummary(bundle) {
31123
31123
  const readChat2 = bundle.readChat && typeof bundle.readChat === "object" ? bundle.readChat : {};
31124
31124
  const cli = bundle.cli && typeof bundle.cli === "object" ? bundle.cli : null;
31125
31125
  const frontend = bundle.frontend && typeof bundle.frontend === "object" ? bundle.frontend : null;
31126
+ const debugReadChat = readChat2.debugReadChat && typeof readChat2.debugReadChat === "object" ? readChat2.debugReadChat : {};
31127
+ const parsedStatus = cli?.parsedStatus && typeof cli.parsedStatus === "object" ? cli.parsedStatus : null;
31128
+ const cliParsedMessageCount = Array.isArray(parsedStatus?.messages) ? parsedStatus.messages.length : void 0;
31129
+ const readChatReturnedMessages = Array.isArray(readChat2.messagesTail) ? readChat2.messagesTail.length : void 0;
31130
+ const cliPartialResponse = typeof cli?.partialResponse === "string" ? cli.partialResponse : "";
31131
+ const readChatStatus = typeof readChat2.status === "string" ? readChat2.status : "";
31132
+ const cliStatus = typeof cli?.status === "string" ? cli.status : "";
31133
+ const cliParsedStatus = typeof parsedStatus?.status === "string" ? parsedStatus.status : "";
31126
31134
  return {
31127
31135
  createdAt: bundle.createdAt,
31128
31136
  targetSessionId: target.targetSessionId,
@@ -31131,8 +31139,22 @@ function buildChatDebugBundleSummary(bundle) {
31131
31139
  readChatSuccess: readChat2.success,
31132
31140
  readChatStatus: readChat2.status,
31133
31141
  readChatTotalMessages: readChat2.totalMessages,
31142
+ readChatReturnedMessages,
31134
31143
  cliStatus: cli?.status,
31144
+ cliParsedStatus: cliParsedStatus || void 0,
31135
31145
  cliMessageCount: cli?.messageCount,
31146
+ cliParsedMessageCount,
31147
+ cliPartialResponseChars: cliPartialResponse.length,
31148
+ parserAdapterStatusMismatch: Boolean(cliStatus && cliParsedStatus && cliStatus !== cliParsedStatus),
31149
+ parserReadChatStatusMismatch: Boolean(readChatStatus && cliParsedStatus && readChatStatus !== cliParsedStatus),
31150
+ readChatDebug: Object.keys(debugReadChat).length ? {
31151
+ adapterStatus: debugReadChat.adapterStatus,
31152
+ parsedStatus: debugReadChat.parsedStatus,
31153
+ returnedStatus: debugReadChat.returnedStatus,
31154
+ parsedMsgCount: debugReadChat.parsedMsgCount,
31155
+ returnedMsgCount: debugReadChat.returnedMsgCount,
31156
+ shouldPreferAdapterMessages: debugReadChat.shouldPreferAdapterMessages
31157
+ } : void 0,
31136
31158
  hasFrontendSnapshot: !!frontend
31137
31159
  };
31138
31160
  }
@@ -34578,6 +34600,96 @@ function normalizeExistingPath(filePath) {
34578
34600
  return null;
34579
34601
  }
34580
34602
  }
34603
+ function readNonEmptyString(value) {
34604
+ return typeof value === "string" && value.trim() ? value.trim() : "";
34605
+ }
34606
+ function formatCompletionMetadata(event) {
34607
+ const parts = [
34608
+ readNonEmptyString(event.targetSessionId) ? `session_id=${readNonEmptyString(event.targetSessionId)}` : "",
34609
+ readNonEmptyString(event.providerType) ? `provider=${readNonEmptyString(event.providerType)}` : "",
34610
+ readNonEmptyString(event.providerSessionId) ? `provider_session_id=${readNonEmptyString(event.providerSessionId)}` : ""
34611
+ ].filter(Boolean);
34612
+ return parts.length > 0 ? ` (${parts.join("; ")})` : "";
34613
+ }
34614
+ function buildMeshSystemMessage(args) {
34615
+ const metadata = formatCompletionMetadata(args.metadataEvent);
34616
+ if (args.event === "agent:generating_completed") {
34617
+ return `[System] ${args.nodeLabel} has completed its task and is now idle${metadata}. You may use mesh_read_chat to review its progress.`;
34618
+ }
34619
+ if (args.event === "agent:waiting_approval") {
34620
+ return `[System] ${args.nodeLabel} is waiting for approval to proceed${metadata}. You may use mesh_read_chat and mesh_approve to handle it.`;
34621
+ }
34622
+ return "";
34623
+ }
34624
+ function injectMeshSystemMessage(components, args) {
34625
+ const coordinatorInstances = components.instanceManager.getByCategory("cli").filter((inst) => {
34626
+ const instState = inst.getState();
34627
+ if (instState.settings?.meshCoordinatorFor !== args.meshId) return false;
34628
+ if (args.sourceInstanceId && instState.instanceId === args.sourceInstanceId) return false;
34629
+ return true;
34630
+ });
34631
+ if (coordinatorInstances.length === 0) return { success: true, forwarded: 0 };
34632
+ const messageText = buildMeshSystemMessage({
34633
+ event: args.event,
34634
+ nodeLabel: args.nodeLabel,
34635
+ metadataEvent: args.metadataEvent
34636
+ });
34637
+ if (!messageText) return { success: false, error: "unsupported mesh event" };
34638
+ for (const coord of coordinatorInstances) {
34639
+ const coordState = coord.getState();
34640
+ LOG.info("MeshEvents", `Forwarding mesh event to coordinator ${coordState.instanceId}`);
34641
+ coord.onEvent("send_message", { input: { text: messageText, textFallback: messageText } });
34642
+ }
34643
+ return { success: true, forwarded: coordinatorInstances.length };
34644
+ }
34645
+ function handleMeshForwardEvent(components, payload) {
34646
+ const eventName = readNonEmptyString(payload.event);
34647
+ if (eventName !== "agent:generating_completed" && eventName !== "agent:waiting_approval") {
34648
+ return { success: false, error: "unsupported mesh event" };
34649
+ }
34650
+ const meshId = readNonEmptyString(payload.meshId);
34651
+ if (!meshId) return { success: false, error: "meshId required" };
34652
+ const nodeId = readNonEmptyString(payload.nodeId);
34653
+ const workspace = readNonEmptyString(payload.workspace);
34654
+ const nodeLabel = nodeId ? `Node '${nodeId}'` : workspace ? `Agent at ${workspace}` : "Remote agent";
34655
+ return injectMeshSystemMessage(components, {
34656
+ meshId,
34657
+ nodeLabel,
34658
+ event: eventName,
34659
+ metadataEvent: {
34660
+ targetSessionId: readNonEmptyString(payload.targetSessionId) || readNonEmptyString(payload.sessionId),
34661
+ providerType: readNonEmptyString(payload.providerType),
34662
+ providerSessionId: readNonEmptyString(payload.providerSessionId)
34663
+ }
34664
+ });
34665
+ }
34666
+ function setupMeshEventForwarding(components) {
34667
+ components.instanceManager.onEvent((event) => {
34668
+ if (event.event !== "agent:generating_completed" && event.event !== "agent:waiting_approval") return;
34669
+ const instanceId = readNonEmptyString(event.instanceId);
34670
+ if (!instanceId) return;
34671
+ const sourceInstance = components.instanceManager.getInstance(instanceId);
34672
+ if (!sourceInstance || sourceInstance.category !== "cli") return;
34673
+ const state = sourceInstance.getState();
34674
+ const workspace = readNonEmptyString(state.workspace);
34675
+ if (!workspace) return;
34676
+ const settings = state.settings && typeof state.settings === "object" ? state.settings : {};
34677
+ const meshIdFromRuntime = readNonEmptyString(settings.meshNodeFor);
34678
+ const mesh = meshIdFromRuntime ? getMesh(meshIdFromRuntime) : getMeshByRepo(workspace);
34679
+ const meshId = meshIdFromRuntime || readNonEmptyString(mesh?.id);
34680
+ if (!meshId) return;
34681
+ const targetNode = mesh?.nodes?.find((n) => n.workspace === workspace);
34682
+ const runtimeNodeId = readNonEmptyString(settings.meshNodeId);
34683
+ const nodeLabel = targetNode ? `Node '${targetNode.id}'` : runtimeNodeId ? `Node '${runtimeNodeId}'` : `Agent at ${workspace}`;
34684
+ injectMeshSystemMessage(components, {
34685
+ meshId,
34686
+ sourceInstanceId: instanceId,
34687
+ nodeLabel,
34688
+ event: event.event,
34689
+ metadataEvent: event
34690
+ });
34691
+ });
34692
+ }
34581
34693
  function buildRecentReadDebugSignature(snapshot) {
34582
34694
  return [
34583
34695
  snapshot.providerType,
@@ -39498,58 +39610,6 @@ function launchIDE(ide, workspacePath) {
39498
39610
  return false;
39499
39611
  }
39500
39612
  }
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
39613
  async function initDaemonComponents(config2) {
39554
39614
  installGlobalInterceptor();
39555
39615
  const appConfig = loadConfig();
@@ -50624,6 +50684,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
50624
50684
  DEFAULT_ADHDEV_MCP_COMMAND = "adhdev-mcp";
50625
50685
  HERMES_CLI_TYPE = "hermes-cli";
50626
50686
  HERMES_MCP_CONFIG_PATH = "~/.hermes/config.yaml";
50687
+ init_mesh_config();
50688
+ init_logger();
50627
50689
  init_config();
50628
50690
  init_terminal_screen();
50629
50691
  init_logger();
@@ -50805,6 +50867,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
50805
50867
  async executeDaemonCommand(cmd, args) {
50806
50868
  switch (cmd) {
50807
50869
  // ─── CLI / ACP commands ───
50870
+ case "mesh_forward_event": {
50871
+ return handleMeshForwardEvent({ instanceManager: this.deps.instanceManager }, args);
50872
+ }
50808
50873
  case "launch_cli":
50809
50874
  case "stop_cli":
50810
50875
  case "set_cli_view_mode":
@@ -55213,8 +55278,6 @@ data: ${JSON.stringify(msg.data)}
55213
55278
  };
55214
55279
  init_logger();
55215
55280
  init_config();
55216
- init_mesh_config();
55217
- init_logger();
55218
55281
  }
55219
55282
  });
55220
55283
 
@@ -55320,6 +55383,23 @@ var CloudTransport = class {
55320
55383
  if (!res.ok) throw new Error(`Read chat failed: ${res.status}`);
55321
55384
  return res.json();
55322
55385
  }
55386
+ async getChatDebugBundle(targetId, opts = {}) {
55387
+ const res = await fetch(
55388
+ `${this.baseUrl}/api/v1/shortcuts/${encodeURIComponent(targetId)}/chat/debug`,
55389
+ {
55390
+ method: "POST",
55391
+ headers: this.headers(),
55392
+ body: JSON.stringify({
55393
+ ...opts.agentType ? { agentType: opts.agentType } : {},
55394
+ ...opts.sessionId ? { sessionId: opts.sessionId } : {},
55395
+ ...opts.tailLimit ? { tailLimit: opts.tailLimit } : {},
55396
+ ...opts.delivery ? { delivery: opts.delivery } : {}
55397
+ })
55398
+ }
55399
+ );
55400
+ if (!res.ok) throw new Error(`Chat debug bundle failed: ${res.status}`);
55401
+ return res.json();
55402
+ }
55323
55403
  async sendChat(targetId, message, opts = {}) {
55324
55404
  const res = await fetch(
55325
55405
  `${this.baseUrl}/api/v1/shortcuts/${encodeURIComponent(targetId)}/chat`,
@@ -55765,6 +55845,93 @@ function formatChatResult(result, sessionId, format, limit = 50) {
55765
55845
  return lines.join("\n\n");
55766
55846
  }
55767
55847
 
55848
+ // src/tools/read-chat-debug.ts
55849
+ var READ_CHAT_DEBUG_TOOL = {
55850
+ name: "read_chat_debug",
55851
+ description: "Collect a daemon-side chat/parser debug bundle for an agent session without opening the browser UI. Prefer this when terminal/chat diverge or long CLI transcripts parse incorrectly. Defaults to daemon_file delivery and returns a saved bundle locator.",
55852
+ inputSchema: {
55853
+ type: "object",
55854
+ properties: {
55855
+ session_id: {
55856
+ type: "string",
55857
+ description: "Target session ID (from list_sessions). Required for reliable routing."
55858
+ },
55859
+ daemon_id: {
55860
+ type: "string",
55861
+ description: "Daemon ID (cloud mode only). Omit for local mode."
55862
+ },
55863
+ agent_type: {
55864
+ type: "string",
55865
+ description: "Optional provider/agent type hint, e.g. hermes-cli, claude-cli, codex-cli."
55866
+ },
55867
+ limit: {
55868
+ type: "number",
55869
+ description: "Max read_chat tail messages embedded in the bundle (default: 40)."
55870
+ },
55871
+ delivery: {
55872
+ type: "string",
55873
+ enum: ["daemon_file", "inline"],
55874
+ description: "daemon_file saves the full sanitized bundle on the daemon and returns a locator; inline returns the sanitized bundle in the MCP response. Default: daemon_file."
55875
+ },
55876
+ ...FORMAT_PROP
55877
+ },
55878
+ required: ["session_id"]
55879
+ }
55880
+ };
55881
+ async function readChatDebug(transport, args) {
55882
+ const sessionId = typeof args.session_id === "string" ? args.session_id.trim() : "";
55883
+ if (!sessionId) throw new Error("session_id is required");
55884
+ const tailLimit = args.limit ?? 40;
55885
+ const delivery = args.delivery === "inline" ? "inline" : "daemon_file";
55886
+ const commandArgs = {
55887
+ targetSessionId: sessionId,
55888
+ tailLimit,
55889
+ ...args.agent_type ? { agentType: args.agent_type, providerType: args.agent_type } : {},
55890
+ ...delivery === "daemon_file" ? { delivery: "daemon_file" } : {}
55891
+ };
55892
+ let result;
55893
+ if (isLocalTransport(transport)) {
55894
+ result = await transport.command("get_chat_debug_bundle", commandArgs);
55895
+ } else {
55896
+ if (!args.daemon_id) throw new Error("daemon_id is required in cloud mode");
55897
+ const targetId = `${args.daemon_id}:session:${sessionId}`;
55898
+ result = await transport.getChatDebugBundle(targetId, {
55899
+ sessionId,
55900
+ agentType: args.agent_type,
55901
+ tailLimit,
55902
+ delivery
55903
+ });
55904
+ }
55905
+ return formatChatDebugResult(result, { sessionId, delivery, format: args.format });
55906
+ }
55907
+ function formatChatDebugResult(result, options) {
55908
+ if (!result?.success && result?.error) {
55909
+ if (options.format === "json") return JSON.stringify({ success: false, error: result.error }, null, 2);
55910
+ return `Error: ${result.error}`;
55911
+ }
55912
+ if (options.format === "json") {
55913
+ return JSON.stringify(result, null, 2);
55914
+ }
55915
+ if (result?.delivery === "daemon_file") {
55916
+ const summary = result.summary && typeof result.summary === "object" ? result.summary : {};
55917
+ return [
55918
+ "ADHDev chat debug bundle saved on daemon.",
55919
+ `session_id: ${options.sessionId}`,
55920
+ `bundle_id: ${String(result.bundleId || "")}`,
55921
+ `saved_path: ${String(result.savedPath || "")}`,
55922
+ `size_bytes: ${String(result.sizeBytes || "")}`,
55923
+ `created_at: ${String(result.createdAt || "")}`,
55924
+ `read_chat_status: ${String(summary.readChatStatus || "")}`,
55925
+ `read_chat_total_messages: ${String(summary.readChatTotalMessages ?? "")}`,
55926
+ `cli_status: ${String(summary.cliStatus || "")}`,
55927
+ `cli_message_count: ${String(summary.cliMessageCount ?? "")}`
55928
+ ].join("\n");
55929
+ }
55930
+ if (typeof result?.text === "string") return result.text;
55931
+ if (result?.bundle) return JSON.stringify(result.bundle, null, 2);
55932
+ return JSON.stringify(result, null, 2);
55933
+ }
55934
+
55768
55935
  // src/tools/send-chat.ts
55769
55936
  var SEND_CHAT_TOOL = {
55770
55937
  name: "send_chat",
@@ -56629,6 +56796,17 @@ function extractGitDiff(value) {
56629
56796
  function extractLaunchPayload(value) {
56630
56797
  return findNestedPayload(value, (payload) => Boolean(payload?.sessionId || payload?.id || payload?.runtimeSessionId));
56631
56798
  }
56799
+ function resolveCoordinatorNode(ctx) {
56800
+ const preferredNodeId = typeof ctx.mesh.coordinator?.preferredNodeId === "string" ? ctx.mesh.coordinator.preferredNodeId.trim() : "";
56801
+ if (preferredNodeId) {
56802
+ const preferred = ctx.mesh.nodes.find((n) => n.id === preferredNodeId && typeof n.daemonId === "string" && n.daemonId.trim());
56803
+ if (preferred) return preferred;
56804
+ }
56805
+ if (ctx.localDaemonId) {
56806
+ return ctx.mesh.nodes.find((n) => n.daemonId === ctx.localDaemonId);
56807
+ }
56808
+ return void 0;
56809
+ }
56632
56810
  function meshSessionCacheKey(nodeId, runtimeSessionId) {
56633
56811
  return `${nodeId}:${runtimeSessionId}`;
56634
56812
  }
@@ -56718,6 +56896,21 @@ var MESH_READ_CHAT_TOOL = {
56718
56896
  required: ["node_id", "session_id"]
56719
56897
  }
56720
56898
  };
56899
+ var MESH_READ_DEBUG_TOOL = {
56900
+ name: "mesh_read_debug",
56901
+ description: "Collect a daemon-side chat/parser debug bundle for a delegated agent session on a mesh node without opening the browser UI. Defaults to daemon_file delivery and returns a saved bundle locator.",
56902
+ inputSchema: {
56903
+ type: "object",
56904
+ properties: {
56905
+ node_id: { type: "string", description: "Target node ID." },
56906
+ session_id: { type: "string", description: "Agent session ID to debug." },
56907
+ provider_session_id: { type: "string", description: "Optional provider transcript/session ID for completed session history." },
56908
+ tail: { type: "number", description: "Number of recent read_chat messages to embed (default: 40)." },
56909
+ delivery: { type: "string", enum: ["daemon_file", "inline"], description: "daemon_file saves the full sanitized bundle on the daemon; inline returns it directly. Default: daemon_file." }
56910
+ },
56911
+ required: ["node_id", "session_id"]
56912
+ }
56913
+ };
56721
56914
  var MESH_LAUNCH_SESSION_TOOL = {
56722
56915
  name: "mesh_launch_session",
56723
56916
  description: "Launch a new agent session on a mesh node. Returns the session ID for subsequent send_task/read_chat calls. If the user names a provider, preserve it exactly: Hermes = hermes-cli, Claude Code/Claude = claude-cli, Codex = codex-cli, Gemini = gemini-cli. If type is omitted, resolve strictly from the node policy providerPriority and provider detection; fail closed when no configured provider is usable. Do not default to claude-cli.",
@@ -56795,6 +56988,7 @@ var ALL_MESH_TOOLS = [
56795
56988
  MESH_LIST_NODES_TOOL,
56796
56989
  MESH_SEND_TASK_TOOL,
56797
56990
  MESH_READ_CHAT_TOOL,
56991
+ MESH_READ_DEBUG_TOOL,
56798
56992
  MESH_LAUNCH_SESSION_TOOL,
56799
56993
  MESH_GIT_STATUS_TOOL,
56800
56994
  MESH_CHECKPOINT_TOOL,
@@ -56911,6 +57105,26 @@ async function meshReadChat(ctx, args) {
56911
57105
  return JSON.stringify({ error: "Cloud mesh read_chat not yet implemented" });
56912
57106
  }
56913
57107
  }
57108
+ async function meshReadDebug(ctx, args) {
57109
+ const node = await findNodeWithRefresh(ctx, args.node_id);
57110
+ if (isLocalTransport(ctx.transport)) {
57111
+ const cached2 = meshSessionProviderMetadata.get(meshSessionCacheKey(args.node_id, args.session_id));
57112
+ const providerSessionId = typeof args.provider_session_id === "string" && args.provider_session_id.trim() ? args.provider_session_id.trim() : cached2?.providerSessionId;
57113
+ const delivery = args.delivery === "inline" ? void 0 : "daemon_file";
57114
+ const result = await commandForNode(ctx, node, "get_chat_debug_bundle", {
57115
+ sessionId: args.session_id,
57116
+ targetSessionId: args.session_id,
57117
+ workspace: node.workspace,
57118
+ ...cached2?.providerType ? { agentType: cached2.providerType, providerType: cached2.providerType } : {},
57119
+ ...providerSessionId ? { providerSessionId } : {},
57120
+ tailLimit: args.tail ?? 40,
57121
+ ...delivery ? { delivery } : {}
57122
+ });
57123
+ const payload = unwrapCommandPayload(result);
57124
+ return JSON.stringify(payload, null, 2);
57125
+ }
57126
+ return JSON.stringify({ error: "Cloud mesh read_debug not yet implemented" });
57127
+ }
56914
57128
  async function meshLaunchSession(ctx, args) {
56915
57129
  const node = await findNodeWithRefresh(ctx, args.node_id);
56916
57130
  if (isLocalTransport(ctx.transport)) {
@@ -56934,12 +57148,15 @@ async function meshLaunchSession(ctx, args) {
56934
57148
  return JSON.stringify({ success: false, error: `No usable provider detected for node '${args.node_id}' from providerPriority: ${failed.join("; ")}` });
56935
57149
  }
56936
57150
  }
57151
+ const coordinatorNode = resolveCoordinatorNode(ctx);
56937
57152
  const result = await commandForNode(ctx, node, "launch_cli", {
56938
57153
  cliType: resolvedProviderType,
56939
57154
  dir: node.workspace,
56940
57155
  settings: {
56941
57156
  meshNodeFor: ctx.mesh.id,
56942
57157
  meshNodeId: args.node_id,
57158
+ ...coordinatorNode?.daemonId ? { meshCoordinatorDaemonId: coordinatorNode.daemonId } : {},
57159
+ ...coordinatorNode?.id ? { meshCoordinatorNodeId: coordinatorNode.id } : {},
56943
57160
  launchedByCoordinator: true
56944
57161
  }
56945
57162
  });
@@ -57174,7 +57391,16 @@ async function startMcpServer(opts) {
57174
57391
  `);
57175
57392
  process.exit(1);
57176
57393
  }
57177
- const meshCtx = { mesh, transport };
57394
+ let localDaemonId;
57395
+ if (transport instanceof IpcTransport) {
57396
+ try {
57397
+ const statusResult = await transport.getStatus();
57398
+ const instanceId = typeof statusResult?.status?.instanceId === "string" ? statusResult.status.instanceId.trim() : "";
57399
+ if (instanceId) localDaemonId = instanceId;
57400
+ } catch {
57401
+ }
57402
+ }
57403
+ const meshCtx = { mesh, transport, ...localDaemonId ? { localDaemonId } : {} };
57178
57404
  const coordinatorPrompt = await buildMeshModeCoordinatorPrompt(mesh);
57179
57405
  const server2 = new import_server.Server(
57180
57406
  { name: "adhdev-mcp-server", version: "0.9.75" },
@@ -57214,6 +57440,9 @@ async function startMcpServer(opts) {
57214
57440
  case "mesh_read_chat":
57215
57441
  text = await meshReadChat(meshCtx, a);
57216
57442
  break;
57443
+ case "mesh_read_debug":
57444
+ text = await meshReadDebug(meshCtx, a);
57445
+ break;
57217
57446
  case "mesh_launch_session":
57218
57447
  text = await meshLaunchSession(meshCtx, a);
57219
57448
  break;
@@ -57253,6 +57482,7 @@ async function startMcpServer(opts) {
57253
57482
  STOP_SESSION_TOOL,
57254
57483
  CHECK_PENDING_TOOL,
57255
57484
  READ_CHAT_TOOL,
57485
+ READ_CHAT_DEBUG_TOOL,
57256
57486
  SEND_CHAT_TOOL,
57257
57487
  APPROVE_TOOL,
57258
57488
  GIT_STATUS_TOOL,
@@ -57284,6 +57514,10 @@ async function startMcpServer(opts) {
57284
57514
  const text = await readChat(transport, a);
57285
57515
  return { content: [{ type: "text", text }] };
57286
57516
  }
57517
+ case "read_chat_debug": {
57518
+ const text = await readChatDebug(transport, a);
57519
+ return { content: [{ type: "text", text }] };
57520
+ }
57287
57521
  case "send_chat": {
57288
57522
  const text = await sendChat(transport, { message: a.message, session_id: a.session_id, daemon_id: a.daemon_id });
57289
57523
  return { content: [{ type: "text", text }] };
@@ -57432,8 +57666,8 @@ Environment variables:
57432
57666
  ADHDEV_MESH_ID Mesh ID (mesh mode)
57433
57667
  ADHDEV_MCP_TRANSPORT Transport: local, cloud, or ipc
57434
57668
 
57435
- Standard tools: list_daemons, list_sessions, launch_session, stop_session, check_pending, read_chat, send_chat, approve, git_status, git_log, git_diff, git_checkpoint, git_push, screenshot
57436
- Mesh tools: mesh_status, mesh_list_nodes, mesh_send_task, mesh_read_chat, mesh_launch_session, mesh_git_status, mesh_checkpoint, mesh_approve, mesh_clone_node, mesh_remove_node
57669
+ Standard tools: list_daemons, list_sessions, launch_session, stop_session, check_pending, read_chat, read_chat_debug, send_chat, approve, git_status, git_log, git_diff, git_checkpoint, git_push, screenshot
57670
+ Mesh tools: mesh_status, mesh_list_nodes, mesh_send_task, mesh_read_chat, mesh_read_debug, mesh_launch_session, mesh_git_status, mesh_checkpoint, mesh_approve, mesh_clone_node, mesh_remove_node
57437
57671
  `.trim());
57438
57672
  }
57439
57673
  startMcpServer(parseArgs(process.argv)).catch((err) => {