@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.
@@ -57,6 +57,8 @@ export interface DaemonInitConfig {
57
57
  workspace: string;
58
58
  sessionId: string;
59
59
  }) => void;
60
+ /** Relays a command to a remote mesh node daemon */
61
+ dispatchMeshCommand?: (daemonId: string, command: string, args: Record<string, unknown>) => Promise<any>;
60
62
  }
61
63
  export interface DaemonComponents {
62
64
  providerLoader: ProviderLoader;
@@ -73,6 +75,7 @@ export interface DaemonComponents {
73
75
  value: IDEInfo[];
74
76
  };
75
77
  refreshProviderAvailability: (providerType?: string) => Promise<void>;
78
+ dispatchMeshCommand?: (daemonId: string, command: string, args: Record<string, unknown>) => Promise<any>;
76
79
  }
77
80
  export interface DaemonDevSupportOptions {
78
81
  components: DaemonComponents;
package/dist/index.js CHANGED
@@ -1321,13 +1321,31 @@ function tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType)
1321
1321
  return false;
1322
1322
  }
1323
1323
  LOG.info("MeshQueue", `Node ${nodeId} (${sessionId}) pulled task ${task.id}`);
1324
+ const mesh = getMesh(meshId);
1325
+ const node = mesh?.nodes.find((n) => n.id === nodeId);
1326
+ if (node?.daemonId && components.dispatchMeshCommand) {
1327
+ const isLocalNode = components.cliManager.adapters.has(sessionId);
1328
+ if (!isLocalNode) {
1329
+ components.dispatchMeshCommand(node.daemonId, "agent_command", {
1330
+ targetSessionId: sessionId,
1331
+ cliType: providerType,
1332
+ action: "send_chat",
1333
+ message: task.message
1334
+ }).catch((e) => {
1335
+ LOG.error("MeshQueue", `Failed to dispatch task via P2P to remote node ${nodeId}: ${e?.message}`);
1336
+ updateTaskStatus(meshId, task.id, "failed");
1337
+ });
1338
+ return true;
1339
+ }
1340
+ }
1324
1341
  components.cliManager.handleCliCommand("agent_command", {
1325
1342
  targetSessionId: sessionId,
1326
1343
  cliType: providerType,
1327
1344
  action: "send_chat",
1328
1345
  message: task.message
1329
1346
  }).catch((e) => {
1330
- LOG.error("MeshQueue", `Failed to dispatch task to node ${nodeId}: ${e?.message}`);
1347
+ LOG.error("MeshQueue", `Failed to dispatch task locally to node ${nodeId}: ${e?.message}`);
1348
+ updateTaskStatus(meshId, task.id, "failed");
1331
1349
  });
1332
1350
  return true;
1333
1351
  }
@@ -32329,7 +32347,8 @@ async function initDaemonComponents(config) {
32329
32347
  cdpManagers,
32330
32348
  sessionRegistry,
32331
32349
  detectedIdes: detectedIdesRef,
32332
- refreshProviderAvailability
32350
+ refreshProviderAvailability,
32351
+ dispatchMeshCommand: config.dispatchMeshCommand
32333
32352
  };
32334
32353
  setupMeshEventForwarding(components);
32335
32354
  return components;