@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/dist/index.js CHANGED
@@ -43344,6 +43344,14 @@ ${effect.notification.body || ""}`.trim();
43344
43344
  const readChat = bundle.readChat && typeof bundle.readChat === "object" ? bundle.readChat : {};
43345
43345
  const cli = bundle.cli && typeof bundle.cli === "object" ? bundle.cli : null;
43346
43346
  const frontend = bundle.frontend && typeof bundle.frontend === "object" ? bundle.frontend : null;
43347
+ const debugReadChat = readChat.debugReadChat && typeof readChat.debugReadChat === "object" ? readChat.debugReadChat : {};
43348
+ const parsedStatus = cli?.parsedStatus && typeof cli.parsedStatus === "object" ? cli.parsedStatus : null;
43349
+ const cliParsedMessageCount = Array.isArray(parsedStatus?.messages) ? parsedStatus.messages.length : void 0;
43350
+ const readChatReturnedMessages = Array.isArray(readChat.messagesTail) ? readChat.messagesTail.length : void 0;
43351
+ const cliPartialResponse = typeof cli?.partialResponse === "string" ? cli.partialResponse : "";
43352
+ const readChatStatus = typeof readChat.status === "string" ? readChat.status : "";
43353
+ const cliStatus = typeof cli?.status === "string" ? cli.status : "";
43354
+ const cliParsedStatus = typeof parsedStatus?.status === "string" ? parsedStatus.status : "";
43347
43355
  return {
43348
43356
  createdAt: bundle.createdAt,
43349
43357
  targetSessionId: target.targetSessionId,
@@ -43352,8 +43360,22 @@ ${effect.notification.body || ""}`.trim();
43352
43360
  readChatSuccess: readChat.success,
43353
43361
  readChatStatus: readChat.status,
43354
43362
  readChatTotalMessages: readChat.totalMessages,
43363
+ readChatReturnedMessages,
43355
43364
  cliStatus: cli?.status,
43365
+ cliParsedStatus: cliParsedStatus || void 0,
43356
43366
  cliMessageCount: cli?.messageCount,
43367
+ cliParsedMessageCount,
43368
+ cliPartialResponseChars: cliPartialResponse.length,
43369
+ parserAdapterStatusMismatch: Boolean(cliStatus && cliParsedStatus && cliStatus !== cliParsedStatus),
43370
+ parserReadChatStatusMismatch: Boolean(readChatStatus && cliParsedStatus && readChatStatus !== cliParsedStatus),
43371
+ readChatDebug: Object.keys(debugReadChat).length ? {
43372
+ adapterStatus: debugReadChat.adapterStatus,
43373
+ parsedStatus: debugReadChat.parsedStatus,
43374
+ returnedStatus: debugReadChat.returnedStatus,
43375
+ parsedMsgCount: debugReadChat.parsedMsgCount,
43376
+ returnedMsgCount: debugReadChat.returnedMsgCount,
43377
+ shouldPreferAdapterMessages: debugReadChat.shouldPreferAdapterMessages
43378
+ } : void 0,
43357
43379
  hasFrontendSnapshot: !!frontend
43358
43380
  };
43359
43381
  }
@@ -51573,6 +51595,98 @@ Run 'adhdev doctor' for detailed diagnostics.`
51573
51595
  return null;
51574
51596
  }
51575
51597
  }
51598
+ init_mesh_config();
51599
+ init_logger();
51600
+ function readNonEmptyString(value) {
51601
+ return typeof value === "string" && value.trim() ? value.trim() : "";
51602
+ }
51603
+ function formatCompletionMetadata(event) {
51604
+ const parts = [
51605
+ readNonEmptyString(event.targetSessionId) ? `session_id=${readNonEmptyString(event.targetSessionId)}` : "",
51606
+ readNonEmptyString(event.providerType) ? `provider=${readNonEmptyString(event.providerType)}` : "",
51607
+ readNonEmptyString(event.providerSessionId) ? `provider_session_id=${readNonEmptyString(event.providerSessionId)}` : ""
51608
+ ].filter(Boolean);
51609
+ return parts.length > 0 ? ` (${parts.join("; ")})` : "";
51610
+ }
51611
+ function buildMeshSystemMessage(args) {
51612
+ const metadata = formatCompletionMetadata(args.metadataEvent);
51613
+ if (args.event === "agent:generating_completed") {
51614
+ return `[System] ${args.nodeLabel} has completed its task and is now idle${metadata}. You may use mesh_read_chat to review its progress.`;
51615
+ }
51616
+ if (args.event === "agent:waiting_approval") {
51617
+ return `[System] ${args.nodeLabel} is waiting for approval to proceed${metadata}. You may use mesh_read_chat and mesh_approve to handle it.`;
51618
+ }
51619
+ return "";
51620
+ }
51621
+ function injectMeshSystemMessage(components, args) {
51622
+ const coordinatorInstances = components.instanceManager.getByCategory("cli").filter((inst) => {
51623
+ const instState = inst.getState();
51624
+ if (instState.settings?.meshCoordinatorFor !== args.meshId) return false;
51625
+ if (args.sourceInstanceId && instState.instanceId === args.sourceInstanceId) return false;
51626
+ return true;
51627
+ });
51628
+ if (coordinatorInstances.length === 0) return { success: true, forwarded: 0 };
51629
+ const messageText = buildMeshSystemMessage({
51630
+ event: args.event,
51631
+ nodeLabel: args.nodeLabel,
51632
+ metadataEvent: args.metadataEvent
51633
+ });
51634
+ if (!messageText) return { success: false, error: "unsupported mesh event" };
51635
+ for (const coord of coordinatorInstances) {
51636
+ const coordState = coord.getState();
51637
+ LOG2.info("MeshEvents", `Forwarding mesh event to coordinator ${coordState.instanceId}`);
51638
+ coord.onEvent("send_message", { input: { text: messageText, textFallback: messageText } });
51639
+ }
51640
+ return { success: true, forwarded: coordinatorInstances.length };
51641
+ }
51642
+ function handleMeshForwardEvent(components, payload) {
51643
+ const eventName = readNonEmptyString(payload.event);
51644
+ if (eventName !== "agent:generating_completed" && eventName !== "agent:waiting_approval") {
51645
+ return { success: false, error: "unsupported mesh event" };
51646
+ }
51647
+ const meshId = readNonEmptyString(payload.meshId);
51648
+ if (!meshId) return { success: false, error: "meshId required" };
51649
+ const nodeId = readNonEmptyString(payload.nodeId);
51650
+ const workspace = readNonEmptyString(payload.workspace);
51651
+ const nodeLabel = nodeId ? `Node '${nodeId}'` : workspace ? `Agent at ${workspace}` : "Remote agent";
51652
+ return injectMeshSystemMessage(components, {
51653
+ meshId,
51654
+ nodeLabel,
51655
+ event: eventName,
51656
+ metadataEvent: {
51657
+ targetSessionId: readNonEmptyString(payload.targetSessionId) || readNonEmptyString(payload.sessionId),
51658
+ providerType: readNonEmptyString(payload.providerType),
51659
+ providerSessionId: readNonEmptyString(payload.providerSessionId)
51660
+ }
51661
+ });
51662
+ }
51663
+ function setupMeshEventForwarding(components) {
51664
+ components.instanceManager.onEvent((event) => {
51665
+ if (event.event !== "agent:generating_completed" && event.event !== "agent:waiting_approval") return;
51666
+ const instanceId = readNonEmptyString(event.instanceId);
51667
+ if (!instanceId) return;
51668
+ const sourceInstance = components.instanceManager.getInstance(instanceId);
51669
+ if (!sourceInstance || sourceInstance.category !== "cli") return;
51670
+ const state = sourceInstance.getState();
51671
+ const workspace = readNonEmptyString(state.workspace);
51672
+ if (!workspace) return;
51673
+ const settings = state.settings && typeof state.settings === "object" ? state.settings : {};
51674
+ const meshIdFromRuntime = readNonEmptyString(settings.meshNodeFor);
51675
+ const mesh = meshIdFromRuntime ? getMesh(meshIdFromRuntime) : getMeshByRepo(workspace);
51676
+ const meshId = meshIdFromRuntime || readNonEmptyString(mesh?.id);
51677
+ if (!meshId) return;
51678
+ const targetNode = mesh?.nodes?.find((n) => n.workspace === workspace);
51679
+ const runtimeNodeId = readNonEmptyString(settings.meshNodeId);
51680
+ const nodeLabel = targetNode ? `Node '${targetNode.id}'` : runtimeNodeId ? `Node '${runtimeNodeId}'` : `Agent at ${workspace}`;
51681
+ injectMeshSystemMessage(components, {
51682
+ meshId,
51683
+ sourceInstanceId: instanceId,
51684
+ nodeLabel,
51685
+ event: event.event,
51686
+ metadataEvent: event
51687
+ });
51688
+ });
51689
+ }
51576
51690
  var os18 = __toESM2(require("os"));
51577
51691
  init_config();
51578
51692
  init_terminal_screen();
@@ -52537,6 +52651,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
52537
52651
  async executeDaemonCommand(cmd, args) {
52538
52652
  switch (cmd) {
52539
52653
  // ─── CLI / ACP commands ───
52654
+ case "mesh_forward_event": {
52655
+ return handleMeshForwardEvent({ instanceManager: this.deps.instanceManager }, args);
52656
+ }
52540
52657
  case "launch_cli":
52541
52658
  case "stop_cli":
52542
52659
  case "set_cli_view_mode":
@@ -61107,60 +61224,6 @@ data: ${JSON.stringify(msg.data)}
61107
61224
  };
61108
61225
  init_logger();
61109
61226
  init_config();
61110
- init_mesh_config();
61111
- init_logger();
61112
- function readNonEmptyString(value) {
61113
- return typeof value === "string" && value.trim() ? value.trim() : "";
61114
- }
61115
- function formatCompletionMetadata(event) {
61116
- const parts = [
61117
- readNonEmptyString(event.targetSessionId) ? `session_id=${readNonEmptyString(event.targetSessionId)}` : "",
61118
- readNonEmptyString(event.providerType) ? `provider=${readNonEmptyString(event.providerType)}` : "",
61119
- readNonEmptyString(event.providerSessionId) ? `provider_session_id=${readNonEmptyString(event.providerSessionId)}` : ""
61120
- ].filter(Boolean);
61121
- return parts.length > 0 ? ` (${parts.join("; ")})` : "";
61122
- }
61123
- function setupMeshEventForwarding(components) {
61124
- components.instanceManager.onEvent((event) => {
61125
- if (event.event !== "agent:generating_completed" && event.event !== "agent:waiting_approval") return;
61126
- const instanceId = readNonEmptyString(event.instanceId);
61127
- if (!instanceId) return;
61128
- const sourceInstance = components.instanceManager.getInstance(instanceId);
61129
- if (!sourceInstance || sourceInstance.category !== "cli") return;
61130
- const state = sourceInstance.getState();
61131
- const workspace = readNonEmptyString(state.workspace);
61132
- if (!workspace) return;
61133
- const settings = state.settings && typeof state.settings === "object" ? state.settings : {};
61134
- const meshIdFromRuntime = readNonEmptyString(settings.meshNodeFor);
61135
- const mesh = meshIdFromRuntime ? getMesh(meshIdFromRuntime) : getMeshByRepo(workspace);
61136
- const meshId = meshIdFromRuntime || readNonEmptyString(mesh?.id);
61137
- if (!meshId) return;
61138
- const allInstances = components.instanceManager.getByCategory("cli");
61139
- const coordinatorInstances = allInstances.filter((inst) => {
61140
- const instState = inst.getState();
61141
- if (instState.settings?.meshCoordinatorFor !== meshId) return false;
61142
- if (instState.instanceId === instanceId) return false;
61143
- return true;
61144
- });
61145
- if (coordinatorInstances.length === 0) return;
61146
- const targetNode = mesh?.nodes?.find((n) => n.workspace === workspace);
61147
- const runtimeNodeId = readNonEmptyString(settings.meshNodeId);
61148
- const nodeLabel = targetNode ? `Node '${targetNode.id}'` : runtimeNodeId ? `Node '${runtimeNodeId}'` : `Agent at ${workspace}`;
61149
- const metadata = formatCompletionMetadata(event);
61150
- let messageText = "";
61151
- if (event.event === "agent:generating_completed") {
61152
- messageText = `[System] ${nodeLabel} has completed its task and is now idle${metadata}. You may use mesh_read_chat to review its progress.`;
61153
- } else if (event.event === "agent:waiting_approval") {
61154
- messageText = `[System] ${nodeLabel} is waiting for approval to proceed${metadata}. You may use mesh_read_chat and mesh_approve to handle it.`;
61155
- }
61156
- if (!messageText) return;
61157
- for (const coord of coordinatorInstances) {
61158
- const coordState = coord.getState();
61159
- LOG2.info("MeshEvents", `Forwarding event from ${workspace} to coordinator ${coordState.instanceId}`);
61160
- coord.onEvent("send_message", { input: { text: messageText, textFallback: messageText } });
61161
- }
61162
- });
61163
- }
61164
61227
  async function initDaemonComponents2(config2) {
61165
61228
  installGlobalInterceptor();
61166
61229
  const appConfig = loadConfig2();
@@ -62169,6 +62232,7 @@ if (process.platform === "win32") {
62169
62232
  var SESSION_TARGET_COMMANDS = /* @__PURE__ */ new Set([
62170
62233
  "send_chat",
62171
62234
  "read_chat",
62235
+ "get_chat_debug_bundle",
62172
62236
  "chat_history",
62173
62237
  "resolve_action",
62174
62238
  "set_cli_view_mode",