@adhdev/daemon-standalone 0.9.76-rc.59 → 0.9.76-rc.60

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.76-rc.59",
3
+ "version": "0.9.76-rc.60",
4
4
  "description": "ADHDev standalone daemon — embedded HTTP/WS server for local dashboard",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -40182,7 +40182,7 @@ var init_dist2 = __esm({
40182
40182
  b. If you need branch isolation for parallel work, call \`mesh_clone_node\` to create a worktree node first.
40183
40183
  c. If no session exists, call \`mesh_launch_session\` to start one.
40184
40184
  d. Call \`mesh_send_task\` with 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.
40185
- 4. **Monitor** \u2014 Prefer event-driven completion/status notifications. Do **not** poll \`mesh_read_chat\` repeatedly just because the delegated session has not produced a final assistant message yet; tool/terminal activity means work may still be in progress. Use at most one compact \`mesh_read_chat\` check after a completion/approval signal, an explicit user status request, or a real timeout/stall. Handle approvals via \`mesh_approve\`.
40185
+ 4. **Monitor** \u2014 Prefer event-driven completion/status notifications. Do **not** poll \`mesh_read_chat\` repeatedly just because the delegated session has not produced a final assistant message yet; tool/terminal activity means work may still be in progress. Do not call \`mesh_read_chat\` again within a few seconds for the same generating session; wait for the completion callback/status event instead unless you are debugging a real stall. Use at most one compact \`mesh_read_chat\` check after a completion/approval signal, an explicit user status request, or a real timeout/stall. Handle approvals via \`mesh_approve\`.
40186
40186
  5. **Verify** \u2014 When a task reports completion or git work is visible, call \`mesh_git_status\` to verify changes were made.
40187
40187
  6. **Checkpoint** \u2014 Call \`mesh_checkpoint\` to save the work.
40188
40188
  7. **Clean up** \u2014 Remove worktree nodes via \`mesh_remove_node\` after their work is merged or no longer needed.
@@ -56131,6 +56131,46 @@ function compactChatPayload(payload, opts = {}) {
56131
56131
  };
56132
56132
  }
56133
56133
 
56134
+ // src/tools/read-chat-polling-advisory.ts
56135
+ var RAPID_READ_CHAT_ADVISORY_WINDOW_MS = 5e3;
56136
+ var ACTIVE_READ_STATUSES = /* @__PURE__ */ new Set([
56137
+ "generating",
56138
+ "running",
56139
+ "streaming",
56140
+ "starting",
56141
+ "busy"
56142
+ ]);
56143
+ var recentReads = /* @__PURE__ */ new Map();
56144
+ function isActiveReadChatStatus(status) {
56145
+ return typeof status === "string" && ACTIVE_READ_STATUSES.has(status.toLowerCase());
56146
+ }
56147
+ function annotateRapidReadChatAdvisory(payload, options) {
56148
+ const now = options.now ?? Date.now();
56149
+ const status = options.status ?? payload?.status ?? payload?.data?.status ?? payload?.result?.status;
56150
+ const active = isActiveReadChatStatus(status);
56151
+ const previous = recentReads.get(options.key);
56152
+ if (!active) {
56153
+ recentReads.set(options.key, { at: now, status: typeof status === "string" ? status : void 0 });
56154
+ return payload;
56155
+ }
56156
+ recentReads.set(options.key, { at: now, status: typeof status === "string" ? status : void 0 });
56157
+ if (!previous || !isActiveReadChatStatus(previous.status)) return payload;
56158
+ const elapsedMs = now - previous.at;
56159
+ if (elapsedMs < 0 || elapsedMs >= RAPID_READ_CHAT_ADVISORY_WINDOW_MS) return payload;
56160
+ return {
56161
+ ...payload,
56162
+ pollingAdvisory: {
56163
+ type: "rapid_read_chat_polling",
56164
+ toolName: options.toolName,
56165
+ windowMs: RAPID_READ_CHAT_ADVISORY_WINDOW_MS,
56166
+ elapsedMs,
56167
+ nextSuggestedReadAt: previous.at + RAPID_READ_CHAT_ADVISORY_WINDOW_MS,
56168
+ completionCallbackExpected: Boolean(options.completionCallbackExpected),
56169
+ message: `This session is still ${String(status)}. Avoid repeated ${options.toolName} polling for the same generating session; wait for the completion callback/status event or retry after the suggested time if you are debugging a real stall.`
56170
+ }
56171
+ };
56172
+ }
56173
+
56134
56174
  // src/tools/read-chat.ts
56135
56175
  var READ_CHAT_TOOL = {
56136
56176
  name: "read_chat",
@@ -56166,12 +56206,22 @@ async function readChat(transport, args) {
56166
56206
  ...args.session_id ? { targetSessionId: args.session_id } : {},
56167
56207
  tailLimit: limit
56168
56208
  });
56169
- return formatChatResult(result2, args.session_id, args.format, limit, args.compact);
56209
+ const annotated2 = annotateRapidReadChatAdvisory(result2, {
56210
+ key: `local:${args.session_id ?? "__active__"}`,
56211
+ toolName: "read_chat",
56212
+ completionCallbackExpected: false
56213
+ });
56214
+ return formatChatResult(annotated2, args.session_id, args.format, limit, args.compact);
56170
56215
  }
56171
56216
  if (!args.daemon_id) throw new Error("daemon_id is required in cloud mode");
56172
56217
  const targetId = args.session_id ? `${args.daemon_id}:session:${args.session_id}` : args.daemon_id;
56173
56218
  const result = await transport.readChat(targetId, { limit, sessionId: args.session_id });
56174
- return formatChatResult(result, args.session_id, args.format, limit, args.compact);
56219
+ const annotated = annotateRapidReadChatAdvisory(result, {
56220
+ key: `cloud:${args.daemon_id}:${args.session_id ?? "__active__"}`,
56221
+ toolName: "read_chat",
56222
+ completionCallbackExpected: false
56223
+ });
56224
+ return formatChatResult(annotated, args.session_id, args.format, limit, args.compact);
56175
56225
  }
56176
56226
  function formatChatResult(result, sessionId, format, limit = 50, compact = false) {
56177
56227
  if (!result?.success && result?.error) {
@@ -56187,6 +56237,7 @@ function formatChatResult(result, sessionId, format, limit = 50, compact = false
56187
56237
  return JSON.stringify({
56188
56238
  session_id: sessionId ?? null,
56189
56239
  ...compactPayload,
56240
+ ...result?.pollingAdvisory ? { pollingAdvisory: result.pollingAdvisory } : {},
56190
56241
  messages: compactPayload.messages.map((m) => ({
56191
56242
  role: m.role,
56192
56243
  kind: m.kind ?? null,
@@ -56197,6 +56248,7 @@ function formatChatResult(result, sessionId, format, limit = 50, compact = false
56197
56248
  }
56198
56249
  return JSON.stringify({
56199
56250
  session_id: sessionId ?? null,
56251
+ ...result?.pollingAdvisory ? { pollingAdvisory: result.pollingAdvisory } : {},
56200
56252
  messages: outputMessages.slice(-limit).map((m) => ({
56201
56253
  role: m.role,
56202
56254
  kind: m.kind ?? null,
@@ -56205,13 +56257,20 @@ function formatChatResult(result, sessionId, format, limit = 50, compact = false
56205
56257
  }))
56206
56258
  }, null, 2);
56207
56259
  }
56208
- if (outputMessages.length === 0) return "No messages in chat.";
56260
+ if (outputMessages.length === 0) {
56261
+ return result?.pollingAdvisory ? `No messages in chat.
56262
+
56263
+ Advisory: ${result.pollingAdvisory.message}` : "No messages in chat.";
56264
+ }
56209
56265
  const lines = outputMessages.slice(-limit).map((m) => {
56210
56266
  const role = m.role === "user" ? "User" : m.role === "assistant" ? "Agent" : m.role;
56211
56267
  const content = messageContent(m);
56212
56268
  const truncated = content.length > 500 ? `${content.slice(0, 500)}\u2026` : content;
56213
56269
  return `[${role}] ${truncated}`;
56214
56270
  });
56271
+ if (result?.pollingAdvisory) {
56272
+ lines.push(`Advisory: ${result.pollingAdvisory.message}`);
56273
+ }
56215
56274
  return lines.join("\n\n");
56216
56275
  }
56217
56276
 
@@ -57544,13 +57603,22 @@ async function meshReadChat(ctx, args) {
57544
57603
  ...providerSessionId ? { providerSessionId } : {},
57545
57604
  tailLimit: args.tail ?? 10
57546
57605
  });
57547
- const payload = unwrapCommandPayload(result);
57606
+ const payload = annotateRapidReadChatAdvisory(unwrapCommandPayload(result), {
57607
+ key: `mesh:${args.node_id}:${args.session_id}`,
57608
+ toolName: "mesh_read_chat",
57609
+ completionCallbackExpected: true
57610
+ });
57548
57611
  if (args.compact) {
57549
- return JSON.stringify(compactChatPayload(payload, {
57612
+ const compactPayload = compactChatPayload(payload, {
57550
57613
  nodeId: args.node_id,
57551
57614
  sessionId: args.session_id,
57552
57615
  limit: args.tail ?? 10
57553
- }), null, 2);
57616
+ });
57617
+ return JSON.stringify(
57618
+ payload.pollingAdvisory ? { ...compactPayload, pollingAdvisory: payload.pollingAdvisory } : compactPayload,
57619
+ null,
57620
+ 2
57621
+ );
57554
57622
  }
57555
57623
  return JSON.stringify(payload, null, 2);
57556
57624
  } else {