@adhdev/daemon-standalone 0.9.77-rc.26 → 0.9.77-rc.28

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.77-rc.26",
3
+ "version": "0.9.77-rc.28",
4
4
  "description": "ADHDev standalone daemon — embedded HTTP/WS server for local dashboard",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -57470,34 +57470,42 @@ async function ipcDispatchToRemoteAgent(ctx, node, args) {
57470
57470
  const transport = ctx.transport;
57471
57471
  const daemonId = node.daemonId;
57472
57472
  let sessionId = args.session_id?.trim() || "";
57473
- let resolvedProviderType = args.providerType?.trim() || "";
57473
+ const providerPriorityList = Array.isArray(node.policy?.providerPriority) ? node.policy.providerPriority : [];
57474
+ let resolvedProviderType = args.providerType?.trim() || providerPriorityList[0] || "";
57474
57475
  if (!sessionId) {
57475
57476
  try {
57476
- const sessionsResult = await transport.meshCommand(daemonId, "get_cli_sessions", {});
57477
- const payload = unwrapCommandPayload(sessionsResult);
57478
- const sessions = Array.isArray(payload?.sessions) ? payload.sessions : Array.isArray(sessionsResult?.sessions) ? sessionsResult.sessions : [];
57477
+ const relayResult = await transport.meshCommand(daemonId, "get_status_metadata", {});
57478
+ const innerResult = relayResult?.result ?? relayResult;
57479
+ const statusObj = innerResult?.status ?? innerResult;
57480
+ const sessions = Array.isArray(statusObj?.sessions) ? statusObj.sessions : [];
57479
57481
  const meshSessions = sessions.filter(
57480
57482
  (s) => s?.settings?.meshNodeFor === ctx.mesh.id || s?.settings?.meshNodeId === node.id || s?.settings?.launchedByCoordinator === true
57481
57483
  );
57482
- const targetSession = meshSessions[0] || sessions[0];
57483
- if (targetSession?.sessionId || targetSession?.id) {
57484
- sessionId = targetSession.sessionId || targetSession.id;
57485
- if (!resolvedProviderType) resolvedProviderType = targetSession.providerType || targetSession.cliType || "";
57484
+ const targetSession = meshSessions[0] || sessions.find(
57485
+ (s) => !resolvedProviderType || s?.providerType === resolvedProviderType || s?.cliType === resolvedProviderType
57486
+ ) || sessions[0];
57487
+ if (targetSession?.id || targetSession?.sessionId) {
57488
+ sessionId = targetSession.id || targetSession.sessionId;
57489
+ if (!resolvedProviderType) {
57490
+ resolvedProviderType = targetSession.providerType || targetSession.cliType || "";
57491
+ }
57486
57492
  }
57487
57493
  } catch {
57488
57494
  }
57489
57495
  }
57490
- if (!sessionId) {
57491
- return { success: false, error: `No active session found on remote node '${node.id}'. Use mesh_launch_session first.` };
57496
+ if (!resolvedProviderType) {
57497
+ return { success: false, error: `Cannot dispatch to remote node '${node.id}': providerType unknown. Set providerPriority on the node policy or call mesh_launch_session first.` };
57492
57498
  }
57493
57499
  try {
57494
57500
  await transport.meshCommand(daemonId, "agent_command", {
57495
- targetSessionId: sessionId,
57501
+ // Precise match when sessionId known, fuzzy type match otherwise
57502
+ ...sessionId ? { targetSessionId: sessionId } : {},
57503
+ agentType: resolvedProviderType,
57496
57504
  cliType: resolvedProviderType,
57497
57505
  action: "send_chat",
57498
57506
  message: args.message
57499
57507
  });
57500
- return { success: true, dispatched: true, sessionId };
57508
+ return { success: true, dispatched: true, sessionId: sessionId || resolvedProviderType };
57501
57509
  } catch (e) {
57502
57510
  return { success: false, error: `P2P dispatch failed: ${e?.message || String(e)}` };
57503
57511
  }