@adhdev/daemon-core 0.9.77-rc.21 → 0.9.77-rc.22

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
@@ -1315,13 +1315,31 @@ function tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType)
1315
1315
  return false;
1316
1316
  }
1317
1317
  LOG.info("MeshQueue", `Node ${nodeId} (${sessionId}) pulled task ${task.id}`);
1318
+ const mesh = getMesh(meshId);
1319
+ const node = mesh?.nodes.find((n) => n.id === nodeId);
1320
+ if (node?.daemonId && components.dispatchMeshCommand) {
1321
+ const isLocalNode = components.cliManager.adapters.has(sessionId);
1322
+ if (!isLocalNode) {
1323
+ components.dispatchMeshCommand(node.daemonId, "agent_command", {
1324
+ targetSessionId: sessionId,
1325
+ cliType: providerType,
1326
+ action: "send_chat",
1327
+ message: task.message
1328
+ }).catch((e) => {
1329
+ LOG.error("MeshQueue", `Failed to dispatch task via P2P to remote node ${nodeId}: ${e?.message}`);
1330
+ updateTaskStatus(meshId, task.id, "failed");
1331
+ });
1332
+ return true;
1333
+ }
1334
+ }
1318
1335
  components.cliManager.handleCliCommand("agent_command", {
1319
1336
  targetSessionId: sessionId,
1320
1337
  cliType: providerType,
1321
1338
  action: "send_chat",
1322
1339
  message: task.message
1323
1340
  }).catch((e) => {
1324
- LOG.error("MeshQueue", `Failed to dispatch task to node ${nodeId}: ${e?.message}`);
1341
+ LOG.error("MeshQueue", `Failed to dispatch task locally to node ${nodeId}: ${e?.message}`);
1342
+ updateTaskStatus(meshId, task.id, "failed");
1325
1343
  });
1326
1344
  return true;
1327
1345
  }
@@ -32117,7 +32135,8 @@ async function initDaemonComponents(config) {
32117
32135
  cdpManagers,
32118
32136
  sessionRegistry,
32119
32137
  detectedIdes: detectedIdesRef,
32120
- refreshProviderAvailability
32138
+ refreshProviderAvailability,
32139
+ dispatchMeshCommand: config.dispatchMeshCommand
32121
32140
  };
32122
32141
  setupMeshEventForwarding(components);
32123
32142
  return components;