@adhdev/daemon-standalone 0.9.77-rc.42 → 0.9.77-rc.44

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.42",
3
+ "version": "0.9.77-rc.44",
4
4
  "description": "ADHDev standalone daemon — embedded HTTP/WS server for local dashboard",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -25686,6 +25686,7 @@ function addNode(meshId, opts) {
25686
25686
  workspace: opts.workspace.trim(),
25687
25687
  repoRoot: opts.repoRoot,
25688
25688
  daemonId: opts.daemonId,
25689
+ machineId: opts.machineId,
25689
25690
  userOverrides: opts.userOverrides || {},
25690
25691
  policy: opts.policy || {},
25691
25692
  isLocalWorktree: opts.isLocalWorktree,
@@ -25797,7 +25798,8 @@ function buildRulesSection(coordinatorCliType) {
25797
25798
  - **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.
25798
25799
  - **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.
25799
25800
  - **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.
25800
- - **Front-load the task message.** When calling \`mesh_enqueue_task\` or \`mesh_send_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.
25801
+ - **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.
25802
+ - **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.
25801
25803
  - **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.
25802
25804
  - **Don't over-parallelize.** Start with 1-2 concurrent tasks. Scale up if they succeed. Never launch a duplicate session or second worker solely because \`mesh_read_chat\` has no final assistant message while the delegated session is still showing tool/terminal activity.
25803
25805
  - **Handle failures with context.** If a task fails, check \`mesh_task_history\` first to see if this task was attempted before and how it failed. Read the chat to understand why, then decide: retry on the same node, reassign to a different node, or escalate to the user.
@@ -41404,18 +41406,24 @@ var init_dist2 = __esm({
41404
41406
 
41405
41407
  | Tool | Purpose |
41406
41408
  |------|---------|
41407
- | \`mesh_status\` | Check all nodes' health, git state, and active sessions |
41409
+ | \`mesh_status\` | Check all nodes' health, git state, active sessions, and branch convergence |
41408
41410
  | \`mesh_list_nodes\` | List nodes with workspace paths |
41411
+ | \`mesh_enqueue_task\` | Add a task to the pull-based work queue; idle nodes auto-claim |
41412
+ | \`mesh_view_queue\` | View queue status \u2014 pending, assigned, completed, failed, cancelled tasks |
41413
+ | \`mesh_queue_cancel\` | Cancel a queue task without deleting audit history |
41414
+ | \`mesh_queue_requeue\` | Return a task to pending for retry; clears stale session targets |
41415
+ | \`mesh_send_task\` | Legacy push: enqueue a task targeted at a specific node |
41409
41416
  | \`mesh_launch_session\` | Start a new agent session on a node |
41410
- | \`mesh_send_task\` | Send a task (natural language) to a running agent |
41411
- | \`mesh_read_chat\` | Read an agent's recent messages to check progress |
41417
+ | \`mesh_read_chat\` | Read recent chat messages from a delegated agent session |
41418
+ | \`mesh_read_debug\` | Collect a daemon-side chat/parser debug bundle for a session |
41412
41419
  | \`mesh_task_history\` | Read the task ledger \u2014 dispatches, completions, failures. Use to understand what has been done before deciding next steps |
41413
41420
  | \`mesh_git_status\` | Check git status on a specific node |
41414
41421
  | \`mesh_checkpoint\` | Create a git checkpoint on a node |
41415
41422
  | \`mesh_approve\` | Approve/reject a pending agent action |
41416
41423
  | \`mesh_clone_node\` | Create a worktree node for isolated parallel branch work |
41417
41424
  | \`mesh_refine_node\` | Validate and merge a completed worktree node back into its base branch |
41418
- | \`mesh_remove_node\` | Remove a node (cleans up worktree if applicable) |`;
41425
+ | \`mesh_remove_node\` | Remove a node (cleans up worktree if applicable) |
41426
+ | \`mesh_cleanup_sessions\` | Manually clean up delegated session records for a node |`;
41419
41427
  TOOL_EXPOSURE_PREFLIGHT_SECTION = `## Tool Exposure Preflight
41420
41428
 
41421
41429
  Before doing any coordinator work, confirm that the actual callable tool list includes \`mesh_status\` and the other \`mesh_*\` tools from the table above. If this Repo Mesh coordinator prompt is present but the callable \`mesh_*\` tools are missing, the MCP server/tool manifest is stale or not injected yet. Do not substitute terminal/file/git tools, do not inspect or edit the repository directly, and do not continue as a non-mesh local coding agent. Stop immediately and tell the user to run \`/reload-mcp\` or start a fresh coordinator session so ADHDev can reconnect \`adhdev-mesh\`.`;
@@ -41425,9 +41433,10 @@ Before doing any coordinator work, confirm that the actual callable tool list in
41425
41433
  2. **Plan** \u2014 Decompose the user's request into independent tasks for parallel execution, or sequential tasks when dependencies exist. If \`mesh_task_history\` shows a recent failure for a task, decide whether to retry or reassign.
41426
41434
  3. **Queue / Delegate** \u2014 The Mesh uses an autonomous pull-based Work Queue:
41427
41435
  a. **General Tasks**: Enqueue tasks using \`mesh_enqueue_task\`. Idle node agents will automatically pull tasks from the queue and begin working.
41428
- b. **Node Preparation**: Call \`mesh_launch_session\` to ensure enough agent sessions are active to handle the queue. If you need branch isolation for parallel work, call \`mesh_clone_node\` to create a worktree node first.
41436
+ b. **Node Preparation**: Reuse an existing idle session on the correct node/provider before launching a new chat/session. Call \`mesh_launch_session\` only when no suitable session exists, when the user explicitly asks for a fresh provider/session, or when branch/worktree isolation requires it. If you need branch isolation for parallel work, call \`mesh_clone_node\` to create a worktree node first.
41429
41437
  c. **Targeted Tasks**: Use \`mesh_send_task\` only when you need to bypass the queue and force a specific node to execute a task immediately.
41430
- d. Always provide a **complete, self-contained** instruction that includes all context the agent needs (file paths, line numbers, what to change, why). Do not send partial instructions expecting future follow-up.
41438
+ d. For the first dispatch of a new task, provide a **complete, self-contained** instruction that includes all context the agent needs (file paths, line numbers, what to change, why). Do not send partial instructions expecting future follow-up.
41439
+ e. For a continuation of the same issue in an existing session, send a concise **delta instruction**: current verified state, the exact failed/blocked step, the newly approved action, and final reporting requirements. Do not resend the full original task or open a new chat solely to continue the same work; that wastes coordinator and worker context.
41431
41440
  4. **Monitor** \u2014 Prefer event-driven completion/status notifications. Do **not** poll \`mesh_read_chat\` repeatedly. Use \`mesh_view_queue\` to see the status of all pending, assigned, completed, and failed tasks. Do not call \`mesh_read_chat\` again within a few seconds for the same generating session. Use at most one compact \`mesh_read_chat\` check after a completion/approval signal. Handle approvals via \`mesh_approve\`.
41432
41441
  5. **Verify** \u2014 When a task reports completion or git work is visible, call \`mesh_git_status\` to verify changes were made.
41433
41442
  6. **Checkpoint** \u2014 Call \`mesh_checkpoint\` to save the work.
@@ -41443,7 +41452,7 @@ When a node agent stops unexpectedly, the daemon automatically enriches the syst
41443
41452
  - A recommendation: **retry**, **reassign**, or **escalate**
41444
41453
 
41445
41454
  Follow these recovery rules:
41446
- 1. **If "Retry recommended"**: Re-launch the session on the same node (\`mesh_launch_session\`), then resend the original task (\`mesh_send_task\`). The system message includes the original task text.
41455
+ 1. **If "Retry recommended"**: Check \`mesh_view_queue\` first \u2014 the daemon may have auto-requeued. If not, re-launch the session on the same node (\`mesh_launch_session\`), then resend the original task (\`mesh_send_task\`). The system message includes the original task text.
41447
41456
  2. **If "Max retries exceeded"**: Do NOT retry on the same node. Either reassign the task to a different node, or inform the user that the task requires manual intervention.
41448
41457
  3. **If no recovery context**: The stop may be intentional (normal completion). Use \`mesh_read_chat\` once to verify, then move on.
41449
41458
  4. **Always record what happened**: After handling a failure, briefly note the outcome in your report to the user.`;
@@ -53690,6 +53699,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
53690
53699
  workspace: result.worktreePath,
53691
53700
  repoRoot: result.worktreePath,
53692
53701
  daemonId: sourceNode.daemonId,
53702
+ machineId: sourceNode.machineId ?? sourceNode.machine_id,
53693
53703
  userOverrides: { ...sourceNode.userOverrides || {} },
53694
53704
  policy: { ...sourceNode.policy || {} },
53695
53705
  isLocalWorktree: true,
@@ -53703,6 +53713,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
53703
53713
  workspace: result.worktreePath,
53704
53714
  repoRoot: result.worktreePath,
53705
53715
  daemonId: sourceNode.daemonId,
53716
+ machineId: sourceNode.machineId ?? sourceNode.machine_id,
53706
53717
  userOverrides: { ...sourceNode.userOverrides || {} },
53707
53718
  isLocalWorktree: true,
53708
53719
  worktreeBranch: result.branch,
@@ -58153,14 +58164,40 @@ function resolveCoordinatorNode(ctx) {
58153
58164
  if (preferred) return preferred;
58154
58165
  }
58155
58166
  if (ctx.localMachineId) {
58156
- const byMachine = ctx.mesh.nodes.find((n) => n.machineId === ctx.localMachineId);
58167
+ const byMachine = ctx.mesh.nodes.find((n) => readNodeMachineId(n) === ctx.localMachineId);
58157
58168
  if (byMachine) return byMachine;
58158
58169
  }
58159
58170
  if (ctx.localDaemonId) {
58160
- return ctx.mesh.nodes.find((n) => n.daemonId === ctx.localDaemonId);
58171
+ return ctx.mesh.nodes.find((n) => readNodeDaemonId(n) === ctx.localDaemonId);
58161
58172
  }
58162
58173
  return void 0;
58163
58174
  }
58175
+ function readNodeMachineId(node) {
58176
+ return readString(node.machineId) || readString(node.machine_id);
58177
+ }
58178
+ function readNodeDaemonId(node) {
58179
+ return readString(node.daemonId) || readString(node.daemon_id);
58180
+ }
58181
+ function isDirectLocalNode(ctx, node) {
58182
+ const machineId = readNodeMachineId(node);
58183
+ const daemonId = readNodeDaemonId(node);
58184
+ return Boolean(
58185
+ ctx.localMachineId && machineId === ctx.localMachineId || ctx.localDaemonId && daemonId === ctx.localDaemonId
58186
+ );
58187
+ }
58188
+ function findClonedFromNode(ctx, node) {
58189
+ const clonedFromNodeId = readString(node.clonedFromNodeId) || readString(node.cloned_from_node_id);
58190
+ if (!clonedFromNodeId) return void 0;
58191
+ return ctx.mesh.nodes.find((n) => n.id === clonedFromNodeId || n.nodeId === clonedFromNodeId || n.node_id === clonedFromNodeId);
58192
+ }
58193
+ function isLocalControlPlaneNode(ctx, node) {
58194
+ if (isDirectLocalNode(ctx, node)) return true;
58195
+ if (node.isLocalWorktree === true) {
58196
+ const sourceNode = findClonedFromNode(ctx, node);
58197
+ if (sourceNode && isDirectLocalNode(ctx, sourceNode)) return true;
58198
+ }
58199
+ return false;
58200
+ }
58164
58201
  function meshSessionCacheKey(nodeId, runtimeSessionId) {
58165
58202
  return `${nodeId}:${runtimeSessionId}`;
58166
58203
  }
@@ -58352,7 +58389,7 @@ function summarizeBranchConvergence(nodes) {
58352
58389
  };
58353
58390
  }
58354
58391
  async function commandForNode(ctx, node, command, args = {}) {
58355
- const isLocalNode = ctx.localMachineId && node.machineId === ctx.localMachineId || ctx.localDaemonId && node.daemonId === ctx.localDaemonId;
58392
+ const isLocalNode = isLocalControlPlaneNode(ctx, node);
58356
58393
  if (ctx.transport instanceof IpcTransport && node.daemonId && !isLocalNode) {
58357
58394
  return ctx.transport.meshCommand(node.daemonId, command, args);
58358
58395
  }
@@ -58780,7 +58817,7 @@ async function meshEnqueueTask(ctx, args) {
58780
58817
  });
58781
58818
  const dispatchPromises = [];
58782
58819
  for (const node of ctx.mesh.nodes) {
58783
- const isLocalNode = ctx.localMachineId && node.machineId === ctx.localMachineId || ctx.localDaemonId && node.daemonId === ctx.localDaemonId;
58820
+ const isLocalNode = isLocalControlPlaneNode(ctx, node);
58784
58821
  if (isLocalNode || !node.daemonId) continue;
58785
58822
  dispatchPromises.push(
58786
58823
  ipcDispatchToRemoteAgent(ctx, node, { message: args.message }).then((result) => {
@@ -58891,7 +58928,7 @@ async function meshSendTask(ctx, args) {
58891
58928
  });
58892
58929
  return JSON.stringify(res);
58893
58930
  }
58894
- const isLocalNode = ctx.localMachineId && node.machineId === ctx.localMachineId || ctx.localDaemonId && node.daemonId === ctx.localDaemonId;
58931
+ const isLocalNode = isLocalControlPlaneNode(ctx, node);
58895
58932
  if (ctx.transport instanceof IpcTransport && node.daemonId && !isLocalNode) {
58896
58933
  const cached2 = meshSessionProviderMetadata.get(meshSessionCacheKey(args.node_id, args.session_id || ""));
58897
58934
  const result = await ipcDispatchToRemoteAgent(ctx, node, {
@@ -59106,7 +59143,7 @@ async function meshLaunchSession(ctx, args) {
59106
59143
  });
59107
59144
  } catch {
59108
59145
  }
59109
- const isLocalNode = ctx.localMachineId && node.machineId === ctx.localMachineId || ctx.localDaemonId && node.daemonId === ctx.localDaemonId;
59146
+ const isLocalNode = isLocalControlPlaneNode(ctx, node);
59110
59147
  if (ctx.transport instanceof IpcTransport && node.daemonId && !isLocalNode) {
59111
59148
  ctx.transport.meshCommand(node.daemonId, "trigger_mesh_queue", { meshId: ctx.mesh.id }).catch(() => {
59112
59149
  });