@adhdev/daemon-core 0.9.82-rc.131 → 0.9.82-rc.133

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
@@ -1198,7 +1198,7 @@ function buildRulesSection(coordinatorCliType) {
1198
1198
 
1199
1199
  - **Minimize coordinator context.** The coordinator's job is routing, not implementing. Do not read source files, run commands, or analyze code directly \u2014 delegate all of that to node agents. Your context should stay lean.
1200
1200
  - **Delegate analysis too.** If you need to understand a bug or explore the codebase, send that investigation as a task to the queue or a node. Do not do it yourself.
1201
- - **Respect explicit provider requests.** If the user names an agent/provider, pass the matching provider type to \`mesh_launch_session\`: Hermes \u2192 \`hermes-cli\`, Claude Code/Claude \u2192 \`claude-cli\`, Codex \u2192 \`codex-cli\`, Gemini \u2192 \`gemini-cli\`. Never substitute \`claude-cli\` just because the coordinator itself is Claude Code.
1201
+ - **Respect explicit provider requests.** If the user names an agent/provider, pass the matching provider type to \`mesh_launch_session\`: Hermes \u2192 \`hermes-cli\`, Claude Code/Claude \u2192 \`claude-cli\`, Codex \u2192 \`codex-cli\`, Gemini \u2192 \`gemini-cli\`, Antigravity \u2192 \`antigravity-cli\`. Never substitute \`claude-cli\` just because the coordinator itself is Claude Code.
1202
1202
  - **Front-load new task messages.** When calling \`mesh_enqueue_task\` or \`mesh_send_task\` for a new task, include everything the agent needs: what files to touch, what the problem is, what the fix should look like. The agent won't ask follow-up questions.
1203
1203
  - **Avoid context-wasting restarts.** For follow-up, retry, commit/push, preview, or cleanup work on the same issue, prefer the existing idle session and send only the delta from its last verified state. Start a fresh chat/session only for genuinely independent work, explicit provider/user request, unsafe transcript contamination, or required branch/worktree isolation.
1204
1204
  - **Don't inspect code.** Treat delegated agent summaries as self-reports, not verification. Verify side effects via \`mesh_git_status\` (including related repo freshness when configured), not by reading source files.
@@ -3559,7 +3559,13 @@ function injectMeshSystemMessage(components, args) {
3559
3559
  }
3560
3560
  return { success: true, forwarded: 0 };
3561
3561
  }
3562
- if (!isRefineTerminalEvent) {
3562
+ const allCoordinatorsGenerating = isRefineTerminalEvent && coordinatorInstances.every((inst) => {
3563
+ const s = inst.getState();
3564
+ const status = readNonEmptyString2(s.status).toLowerCase();
3565
+ const activeChatStatus = readNonEmptyString2(s.activeChat?.status).toLowerCase();
3566
+ return status === "generating" || status === "streaming" || status === "long_generating" || activeChatStatus === "generating" || activeChatStatus === "streaming";
3567
+ });
3568
+ if (!isRefineTerminalEvent || allCoordinatorsGenerating) {
3563
3569
  if (queuePendingMeshCoordinatorEvent({
3564
3570
  event: args.event,
3565
3571
  meshId: args.meshId,
@@ -3573,9 +3579,16 @@ function injectMeshSystemMessage(components, args) {
3573
3579
  coordinatorMessage: messageText,
3574
3580
  queuedAt: Date.now()
3575
3581
  })) {
3576
- LOG.info("MeshEvents", `Queued ${args.event} for MCP coordinator (mesh ${args.meshId})`);
3582
+ if (allCoordinatorsGenerating) {
3583
+ LOG.info("MeshEvents", `Queued ${args.event} for generating CLI coordinator (mesh ${args.meshId}) \u2014 will be delivered via get_pending_mesh_events when coordinator returns to idle`);
3584
+ } else {
3585
+ LOG.info("MeshEvents", `Queued ${args.event} for MCP coordinator (mesh ${args.meshId})`);
3586
+ }
3577
3587
  }
3578
3588
  }
3589
+ if (allCoordinatorsGenerating) {
3590
+ return { success: true, forwarded: 0, bufferedForGeneratingCoordinator: true };
3591
+ }
3579
3592
  for (const coord of coordinatorInstances) {
3580
3593
  const coordState = coord.getState();
3581
3594
  LOG.info("MeshEvents", `Forwarding mesh event to coordinator ${coordState.instanceId}`);
@@ -9942,6 +9955,7 @@ function buildMeshActiveWorkSummary(activeWork) {
9942
9955
  statusCounts[item.status] += 1;
9943
9956
  }
9944
9957
  const staleDirectCount = activeWork.filter((item) => item.source === "direct" && item.staleReason).length;
9958
+ const staleDirectUnacknowledgedCount = activeWork.filter((item) => item.source === "direct" && item.staleDispatchUnacknowledged).length;
9945
9959
  return {
9946
9960
  totalActiveCount: activeWork.length,
9947
9961
  queueActiveCount: sourceCounts.queue,
@@ -9953,6 +9967,7 @@ function buildMeshActiveWorkSummary(activeWork) {
9953
9967
  sourceCounts,
9954
9968
  statusCounts,
9955
9969
  staleDirectCount,
9970
+ ...staleDirectUnacknowledgedCount > 0 ? { staleDirectUnacknowledgedCount } : {},
9956
9971
  ...staleDirectCount > 0 ? { staleDirectNote: "Stale direct records are orphaned ledger entries whose node/session no longer exists. They are historical recovery evidence only \u2014 not active or unresolved work. The queue (source: queue) is authoritative for pending/assigned tasks." } : {}
9957
9972
  };
9958
9973
  }
@@ -9989,9 +10004,13 @@ function buildMeshActiveWork(opts) {
9989
10004
  const live = sessionStatusFromNodes(opts.nodes, dispatch.nodeId, dispatch.sessionId);
9990
10005
  const status = terminalStatus || live.status || "assigned";
9991
10006
  const terminalRow = Boolean(terminal && terminal.kind !== "task_approval_needed");
9992
- const ledgerOnlyStaleReason = !terminalRow && (status === "idle" || !terminalStatus && !live.status) ? "direct task dispatch has no provider acknowledgement, transcript append, or active runtime transition" : void 0;
10007
+ const dispatchedToIdleSession = dispatch.payload?.dispatchedToIdleSession === true;
10008
+ const isNoTransition = !terminalStatus && !live.status;
10009
+ const isIdleUnacknowledged = status === "idle";
10010
+ const ledgerOnlyStaleReason = !terminalRow && (isIdleUnacknowledged || isNoTransition || dispatchedToIdleSession && isIdleUnacknowledged) ? "direct task dispatch has no provider acknowledgement, transcript append, or active runtime transition" : void 0;
9993
10011
  const message = readString2(dispatch.payload?.message) || readString2(dispatch.payload?.summary) || "";
9994
10012
  const { title, summary: summary2 } = summarizeMessage(message);
10013
+ const isFreshUnacknowledged = Boolean(ledgerOnlyStaleReason && !live.staleReason);
9995
10014
  const record = {
9996
10015
  taskId,
9997
10016
  source: "direct",
@@ -10010,7 +10029,8 @@ function buildMeshActiveWork(opts) {
10010
10029
  terminal: terminalRow,
10011
10030
  terminalKind: terminal?.kind,
10012
10031
  terminalAt: terminal?.timestamp,
10013
- staleReason: live.staleReason || ledgerOnlyStaleReason
10032
+ staleReason: live.staleReason || ledgerOnlyStaleReason,
10033
+ ...isFreshUnacknowledged ? { staleDispatchUnacknowledged: true } : {}
10014
10034
  };
10015
10035
  if (terminalRow) {
10016
10036
  terminalDirectWork.push(record);
@@ -10027,7 +10047,11 @@ function buildMeshActiveWork(opts) {
10027
10047
  terminalDirectWork.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
10028
10048
  const summary = buildMeshActiveWorkSummary(records);
10029
10049
  summary.staleDirectCount = staleDirectWork.length;
10030
- const staleDirectWorkNote = staleDirectWork.length > 0 ? "These are orphaned ledger entries whose original node or session no longer exists in the live mesh. They are historical/recovery evidence only \u2014 not active or unresolved work. Do not treat staleDirectCount as a status mismatch; use the queue (source: queue) as authoritative for pending/assigned tasks." : void 0;
10050
+ const unacknowledgedCount = staleDirectWork.filter((r) => r.staleDispatchUnacknowledged).length;
10051
+ if (unacknowledgedCount > 0) {
10052
+ summary.staleDirectUnacknowledgedCount = unacknowledgedCount;
10053
+ }
10054
+ const staleDirectWorkNote = staleDirectWork.length > 0 ? unacknowledgedCount > 0 && unacknowledgedCount === staleDirectWork.length ? `${unacknowledgedCount} direct dispatch(es) were not acknowledged by the target session \u2014 the session received the agent_command but never transitioned to generating. This is a fresh dispatch failure, not historical noise. Recovery: launch a fresh session on the same node and retry the task, or use mesh_enqueue_task for queue-based assignment.` : unacknowledgedCount > 0 ? `${unacknowledgedCount} of ${staleDirectWork.length} stale direct record(s) are fresh unacknowledged dispatch failures (session still live but never transitioned to generating); the rest are orphaned historical entries whose node/session no longer exists. Fresh unacknowledged dispatches need recovery: launch a fresh session and retry. Orphaned entries are historical evidence only \u2014 not active or unresolved work.` : "These are orphaned ledger entries whose original node or session no longer exists in the live mesh. They are historical/recovery evidence only \u2014 not active or unresolved work. Do not treat staleDirectCount as a status mismatch; use the queue (source: queue) as authoritative for pending/assigned tasks." : void 0;
10031
10055
  if (staleDirectWorkNote) {
10032
10056
  summary.staleDirectNote = staleDirectWorkNote;
10033
10057
  }