@adhdev/daemon-standalone 0.9.77-rc.26 → 0.9.77-rc.27
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
|
@@ -57470,34 +57470,41 @@ 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
|
-
|
|
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
|
|
57477
|
-
const payload = unwrapCommandPayload(
|
|
57478
|
-
const sessions = Array.isArray(payload?.sessions) ? payload.sessions : Array.isArray(
|
|
57477
|
+
const statusResult = await transport.meshCommand(daemonId, "get_status_metadata", {});
|
|
57478
|
+
const payload = unwrapCommandPayload(statusResult);
|
|
57479
|
+
const sessions = Array.isArray(payload?.sessions) ? payload.sessions : Array.isArray(payload?.status?.sessions) ? payload.status.sessions : [];
|
|
57479
57480
|
const meshSessions = sessions.filter(
|
|
57480
57481
|
(s) => s?.settings?.meshNodeFor === ctx.mesh.id || s?.settings?.meshNodeId === node.id || s?.settings?.launchedByCoordinator === true
|
|
57481
57482
|
);
|
|
57482
|
-
const targetSession = meshSessions[0] || sessions
|
|
57483
|
-
|
|
57484
|
-
|
|
57485
|
-
|
|
57483
|
+
const targetSession = meshSessions[0] || sessions.find(
|
|
57484
|
+
(s) => !resolvedProviderType || s?.providerType === resolvedProviderType || s?.cliType === resolvedProviderType
|
|
57485
|
+
) || sessions[0];
|
|
57486
|
+
if (targetSession?.id || targetSession?.sessionId) {
|
|
57487
|
+
sessionId = targetSession.id || targetSession.sessionId;
|
|
57488
|
+
if (!resolvedProviderType) {
|
|
57489
|
+
resolvedProviderType = targetSession.providerType || targetSession.cliType || "";
|
|
57490
|
+
}
|
|
57486
57491
|
}
|
|
57487
57492
|
} catch {
|
|
57488
57493
|
}
|
|
57489
57494
|
}
|
|
57490
|
-
if (!
|
|
57491
|
-
return { success: false, error: `
|
|
57495
|
+
if (!resolvedProviderType) {
|
|
57496
|
+
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
57497
|
}
|
|
57493
57498
|
try {
|
|
57494
57499
|
await transport.meshCommand(daemonId, "agent_command", {
|
|
57495
|
-
|
|
57500
|
+
// Precise match when sessionId known, fuzzy type match otherwise
|
|
57501
|
+
...sessionId ? { targetSessionId: sessionId } : {},
|
|
57502
|
+
agentType: resolvedProviderType,
|
|
57496
57503
|
cliType: resolvedProviderType,
|
|
57497
57504
|
action: "send_chat",
|
|
57498
57505
|
message: args.message
|
|
57499
57506
|
});
|
|
57500
|
-
return { success: true, dispatched: true, sessionId };
|
|
57507
|
+
return { success: true, dispatched: true, sessionId: sessionId || resolvedProviderType };
|
|
57501
57508
|
} catch (e) {
|
|
57502
57509
|
return { success: false, error: `P2P dispatch failed: ${e?.message || String(e)}` };
|
|
57503
57510
|
}
|