@adhdev/daemon-core 0.9.82-rc.141 → 0.9.82-rc.142
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.js +13 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/mesh/mesh-events.ts +22 -6
package/package.json
CHANGED
package/src/mesh/mesh-events.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { detectCLI } from '../detection/cli-detector.js';
|
|
|
7
7
|
import { LOG } from '../logging/logger.js';
|
|
8
8
|
import { appendLedgerEntry, buildTaskCompletionEvidence, getLedgerDir, getSessionRecoveryContext, isIntentionalCleanupStopEntry, readLedgerEntries } from './mesh-ledger.js';
|
|
9
9
|
import type { MeshLedgerKind, SessionRecoveryContext } from './mesh-ledger.js';
|
|
10
|
-
import { claimNextTask, updateSessionTaskStatus, enqueueTask, updateTaskStatus, getQueue, recordTaskAutoLaunch, updateDirectDispatchStatus, cleanupTerminalDirectDispatches } from './mesh-work-queue.js';
|
|
10
|
+
import { claimNextTask, updateSessionTaskStatus, enqueueTask, updateTaskStatus, getQueue, recordTaskAutoLaunch, updateDirectDispatchStatus, cleanupTerminalDirectDispatches, getActiveDirectDispatches } from './mesh-work-queue.js';
|
|
11
11
|
import { BeadsDB } from './beads-db.js';
|
|
12
12
|
|
|
13
13
|
// ---------------------------------------------------------------------------
|
|
@@ -1615,14 +1615,30 @@ export function setupMeshEventForwarding(components: DaemonComponents) {
|
|
|
1615
1615
|
if (!workspace) return;
|
|
1616
1616
|
const settings = state.settings && typeof state.settings === 'object' ? state.settings as Record<string, unknown> : {};
|
|
1617
1617
|
|
|
1618
|
-
// Coordinator sessions must
|
|
1619
|
-
//
|
|
1620
|
-
|
|
1618
|
+
// Coordinator sessions normally must not inject events into themselves, but a
|
|
1619
|
+
// coordinator session can also be the direct-dispatch target of mesh_send_task
|
|
1620
|
+
// issued by another coordinator (e.g. a remote orchestrator delegated a task to
|
|
1621
|
+
// this local coordinator). In that case the completion event must still flow into
|
|
1622
|
+
// injectMeshSystemMessage so the ledger records task_completed and the *other*
|
|
1623
|
+
// coordinator's pendingCoordinatorEvents queue is populated. Skip only when this
|
|
1624
|
+
// session is purely a coordinator with no in-flight direct dispatch waiting on it.
|
|
1625
|
+
const coordinatorMeshId = readNonEmptyString(settings.meshCoordinatorFor);
|
|
1626
|
+
let meshIdFromDirectDispatch = '';
|
|
1627
|
+
if (coordinatorMeshId) {
|
|
1628
|
+
try {
|
|
1629
|
+
const activeDispatches = getActiveDirectDispatches(coordinatorMeshId);
|
|
1630
|
+
if (activeDispatches.some(d => d.sessionId === instanceId)) {
|
|
1631
|
+
meshIdFromDirectDispatch = coordinatorMeshId;
|
|
1632
|
+
}
|
|
1633
|
+
} catch { /* best-effort */ }
|
|
1634
|
+
if (!meshIdFromDirectDispatch) return;
|
|
1635
|
+
}
|
|
1621
1636
|
|
|
1622
|
-
const meshIdFromRuntime = readNonEmptyString(settings.meshNodeFor);
|
|
1637
|
+
const meshIdFromRuntime = readNonEmptyString(settings.meshNodeFor) || meshIdFromDirectDispatch;
|
|
1623
1638
|
|
|
1624
1639
|
// Only forward events for sessions that were explicitly launched as mesh-node delegates
|
|
1625
|
-
// (meshNodeFor set by mesh_launch_session)
|
|
1640
|
+
// (meshNodeFor set by mesh_launch_session), carry the launchedByCoordinator flag, or
|
|
1641
|
+
// have an active direct-dispatch entry (mesh_send_task to a pre-existing session).
|
|
1626
1642
|
// Do NOT fall back to workspace-based mesh lookup: that would pick up coordinator sessions
|
|
1627
1643
|
// and any other CLI session that happens to share the same workspace, causing spurious
|
|
1628
1644
|
// system-message injection into the coordinator's own conversation.
|