@adhdev/daemon-core 0.9.76-rc.30 → 0.9.76-rc.31

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.mjs CHANGED
@@ -29934,33 +29934,49 @@ init_config();
29934
29934
  // src/mesh/mesh-events.ts
29935
29935
  init_mesh_config();
29936
29936
  init_logger();
29937
+ function readNonEmptyString(value) {
29938
+ return typeof value === "string" && value.trim() ? value.trim() : "";
29939
+ }
29940
+ function formatCompletionMetadata(event) {
29941
+ const parts = [
29942
+ readNonEmptyString(event.targetSessionId) ? `session_id=${readNonEmptyString(event.targetSessionId)}` : "",
29943
+ readNonEmptyString(event.providerType) ? `provider=${readNonEmptyString(event.providerType)}` : "",
29944
+ readNonEmptyString(event.providerSessionId) ? `provider_session_id=${readNonEmptyString(event.providerSessionId)}` : ""
29945
+ ].filter(Boolean);
29946
+ return parts.length > 0 ? ` (${parts.join("; ")})` : "";
29947
+ }
29937
29948
  function setupMeshEventForwarding(components) {
29938
29949
  components.instanceManager.onEvent((event) => {
29939
29950
  if (event.event !== "agent:generating_completed" && event.event !== "agent:waiting_approval") return;
29940
- const instanceId = event.instanceId;
29951
+ const instanceId = readNonEmptyString(event.instanceId);
29941
29952
  if (!instanceId) return;
29942
29953
  const sourceInstance = components.instanceManager.getInstance(instanceId);
29943
29954
  if (!sourceInstance || sourceInstance.category !== "cli") return;
29944
29955
  const state = sourceInstance.getState();
29945
- const workspace = state.workspace;
29956
+ const workspace = readNonEmptyString(state.workspace);
29946
29957
  if (!workspace) return;
29947
- const mesh = getMeshByRepo(workspace);
29948
- if (!mesh) return;
29958
+ const settings = state.settings && typeof state.settings === "object" ? state.settings : {};
29959
+ const meshIdFromRuntime = readNonEmptyString(settings.meshNodeFor);
29960
+ const mesh = meshIdFromRuntime ? getMesh(meshIdFromRuntime) : getMeshByRepo(workspace);
29961
+ const meshId = meshIdFromRuntime || readNonEmptyString(mesh?.id);
29962
+ if (!meshId) return;
29949
29963
  const allInstances = components.instanceManager.getByCategory("cli");
29950
29964
  const coordinatorInstances = allInstances.filter((inst) => {
29951
29965
  const instState = inst.getState();
29952
- if (instState.settings?.meshCoordinatorFor !== mesh.id) return false;
29966
+ if (instState.settings?.meshCoordinatorFor !== meshId) return false;
29953
29967
  if (instState.instanceId === instanceId) return false;
29954
29968
  return true;
29955
29969
  });
29956
29970
  if (coordinatorInstances.length === 0) return;
29957
- const targetNode = mesh.nodes.find((n) => n.workspace === workspace);
29958
- const nodeLabel = targetNode ? `Node '${targetNode.id}'` : `Agent at ${workspace}`;
29971
+ const targetNode = mesh?.nodes?.find((n) => n.workspace === workspace);
29972
+ const runtimeNodeId = readNonEmptyString(settings.meshNodeId);
29973
+ const nodeLabel = targetNode ? `Node '${targetNode.id}'` : runtimeNodeId ? `Node '${runtimeNodeId}'` : `Agent at ${workspace}`;
29974
+ const metadata = formatCompletionMetadata(event);
29959
29975
  let messageText = "";
29960
29976
  if (event.event === "agent:generating_completed") {
29961
- messageText = `[System] ${nodeLabel} has completed its task and is now idle. You may use mesh_read_chat to review its progress.`;
29977
+ messageText = `[System] ${nodeLabel} has completed its task and is now idle${metadata}. You may use mesh_read_chat to review its progress.`;
29962
29978
  } else if (event.event === "agent:waiting_approval") {
29963
- messageText = `[System] ${nodeLabel} is waiting for approval to proceed. You may use mesh_read_chat and mesh_approve to handle it.`;
29979
+ messageText = `[System] ${nodeLabel} is waiting for approval to proceed${metadata}. You may use mesh_read_chat and mesh_approve to handle it.`;
29964
29980
  }
29965
29981
  if (!messageText) return;
29966
29982
  for (const coord of coordinatorInstances) {