@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.js CHANGED
@@ -1203,7 +1203,7 @@ function buildRulesSection(coordinatorCliType) {
1203
1203
 
1204
1204
  - **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.
1205
1205
  - **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.
1206
- - **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.
1206
+ - **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.
1207
1207
  - **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.
1208
1208
  - **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.
1209
1209
  - **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.
@@ -3564,7 +3564,13 @@ function injectMeshSystemMessage(components, args) {
3564
3564
  }
3565
3565
  return { success: true, forwarded: 0 };
3566
3566
  }
3567
- if (!isRefineTerminalEvent) {
3567
+ const allCoordinatorsGenerating = isRefineTerminalEvent && coordinatorInstances.every((inst) => {
3568
+ const s = inst.getState();
3569
+ const status = readNonEmptyString2(s.status).toLowerCase();
3570
+ const activeChatStatus = readNonEmptyString2(s.activeChat?.status).toLowerCase();
3571
+ return status === "generating" || status === "streaming" || status === "long_generating" || activeChatStatus === "generating" || activeChatStatus === "streaming";
3572
+ });
3573
+ if (!isRefineTerminalEvent || allCoordinatorsGenerating) {
3568
3574
  if (queuePendingMeshCoordinatorEvent({
3569
3575
  event: args.event,
3570
3576
  meshId: args.meshId,
@@ -3578,9 +3584,16 @@ function injectMeshSystemMessage(components, args) {
3578
3584
  coordinatorMessage: messageText,
3579
3585
  queuedAt: Date.now()
3580
3586
  })) {
3581
- LOG.info("MeshEvents", `Queued ${args.event} for MCP coordinator (mesh ${args.meshId})`);
3587
+ if (allCoordinatorsGenerating) {
3588
+ 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`);
3589
+ } else {
3590
+ LOG.info("MeshEvents", `Queued ${args.event} for MCP coordinator (mesh ${args.meshId})`);
3591
+ }
3582
3592
  }
3583
3593
  }
3594
+ if (allCoordinatorsGenerating) {
3595
+ return { success: true, forwarded: 0, bufferedForGeneratingCoordinator: true };
3596
+ }
3584
3597
  for (const coord of coordinatorInstances) {
3585
3598
  const coordState = coord.getState();
3586
3599
  LOG.info("MeshEvents", `Forwarding mesh event to coordinator ${coordState.instanceId}`);
@@ -10208,6 +10221,7 @@ function buildMeshActiveWorkSummary(activeWork) {
10208
10221
  statusCounts[item.status] += 1;
10209
10222
  }
10210
10223
  const staleDirectCount = activeWork.filter((item) => item.source === "direct" && item.staleReason).length;
10224
+ const staleDirectUnacknowledgedCount = activeWork.filter((item) => item.source === "direct" && item.staleDispatchUnacknowledged).length;
10211
10225
  return {
10212
10226
  totalActiveCount: activeWork.length,
10213
10227
  queueActiveCount: sourceCounts.queue,
@@ -10219,6 +10233,7 @@ function buildMeshActiveWorkSummary(activeWork) {
10219
10233
  sourceCounts,
10220
10234
  statusCounts,
10221
10235
  staleDirectCount,
10236
+ ...staleDirectUnacknowledgedCount > 0 ? { staleDirectUnacknowledgedCount } : {},
10222
10237
  ...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." } : {}
10223
10238
  };
10224
10239
  }
@@ -10255,9 +10270,13 @@ function buildMeshActiveWork(opts) {
10255
10270
  const live = sessionStatusFromNodes(opts.nodes, dispatch.nodeId, dispatch.sessionId);
10256
10271
  const status = terminalStatus || live.status || "assigned";
10257
10272
  const terminalRow = Boolean(terminal && terminal.kind !== "task_approval_needed");
10258
- const ledgerOnlyStaleReason = !terminalRow && (status === "idle" || !terminalStatus && !live.status) ? "direct task dispatch has no provider acknowledgement, transcript append, or active runtime transition" : void 0;
10273
+ const dispatchedToIdleSession = dispatch.payload?.dispatchedToIdleSession === true;
10274
+ const isNoTransition = !terminalStatus && !live.status;
10275
+ const isIdleUnacknowledged = status === "idle";
10276
+ const ledgerOnlyStaleReason = !terminalRow && (isIdleUnacknowledged || isNoTransition || dispatchedToIdleSession && isIdleUnacknowledged) ? "direct task dispatch has no provider acknowledgement, transcript append, or active runtime transition" : void 0;
10259
10277
  const message = readString2(dispatch.payload?.message) || readString2(dispatch.payload?.summary) || "";
10260
10278
  const { title, summary: summary2 } = summarizeMessage(message);
10279
+ const isFreshUnacknowledged = Boolean(ledgerOnlyStaleReason && !live.staleReason);
10261
10280
  const record = {
10262
10281
  taskId,
10263
10282
  source: "direct",
@@ -10276,7 +10295,8 @@ function buildMeshActiveWork(opts) {
10276
10295
  terminal: terminalRow,
10277
10296
  terminalKind: terminal?.kind,
10278
10297
  terminalAt: terminal?.timestamp,
10279
- staleReason: live.staleReason || ledgerOnlyStaleReason
10298
+ staleReason: live.staleReason || ledgerOnlyStaleReason,
10299
+ ...isFreshUnacknowledged ? { staleDispatchUnacknowledged: true } : {}
10280
10300
  };
10281
10301
  if (terminalRow) {
10282
10302
  terminalDirectWork.push(record);
@@ -10293,7 +10313,11 @@ function buildMeshActiveWork(opts) {
10293
10313
  terminalDirectWork.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
10294
10314
  const summary = buildMeshActiveWorkSummary(records);
10295
10315
  summary.staleDirectCount = staleDirectWork.length;
10296
- 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;
10316
+ const unacknowledgedCount = staleDirectWork.filter((r) => r.staleDispatchUnacknowledged).length;
10317
+ if (unacknowledgedCount > 0) {
10318
+ summary.staleDirectUnacknowledgedCount = unacknowledgedCount;
10319
+ }
10320
+ 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;
10297
10321
  if (staleDirectWorkNote) {
10298
10322
  summary.staleDirectNote = staleDirectWorkNote;
10299
10323
  }