@adhdev/daemon-core 0.9.77-rc.50 → 0.9.77-rc.51

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
@@ -1207,6 +1207,7 @@ function claimNextTask(meshId, nodeId, sessionId) {
1207
1207
  entry.status = "assigned";
1208
1208
  entry.assignedNodeId = nodeId;
1209
1209
  entry.assignedSessionId = sessionId;
1210
+ entry.dispatchTimestamp = (/* @__PURE__ */ new Date()).toISOString();
1210
1211
  entry.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
1211
1212
  writeQueue(meshId, queue);
1212
1213
  return entry;
@@ -1269,15 +1270,22 @@ function requeueTask(meshId, taskId, opts) {
1269
1270
  }
1270
1271
  function updateSessionTaskStatus(meshId, sessionId, status) {
1271
1272
  const queue = readQueue(meshId);
1273
+ let bestIdx = -1;
1274
+ let bestTime = 0;
1272
1275
  for (let i = queue.length - 1; i >= 0; i--) {
1273
1276
  if (queue[i].assignedSessionId === sessionId && queue[i].status === "assigned") {
1274
- queue[i].status = status;
1275
- queue[i].updatedAt = (/* @__PURE__ */ new Date()).toISOString();
1276
- writeQueue(meshId, queue);
1277
- return queue[i];
1277
+ const time = new Date(queue[i].dispatchTimestamp || queue[i].updatedAt).getTime();
1278
+ if (time > bestTime) {
1279
+ bestTime = time;
1280
+ bestIdx = i;
1281
+ }
1278
1282
  }
1279
1283
  }
1280
- return null;
1284
+ if (bestIdx === -1) return null;
1285
+ queue[bestIdx].status = status;
1286
+ queue[bestIdx].updatedAt = (/* @__PURE__ */ new Date()).toISOString();
1287
+ writeQueue(meshId, queue);
1288
+ return queue[bestIdx];
1281
1289
  }
1282
1290
  function getMeshQueueStats(meshId) {
1283
1291
  const queue = readQueue(meshId);
@@ -1673,7 +1681,9 @@ var init_logger = __esm({
1673
1681
  // src/mesh/mesh-events.ts
1674
1682
  var mesh_events_exports = {};
1675
1683
  __export(mesh_events_exports, {
1684
+ clearPendingMeshCoordinatorEvents: () => clearPendingMeshCoordinatorEvents,
1676
1685
  drainPendingMeshCoordinatorEvents: () => drainPendingMeshCoordinatorEvents,
1686
+ getPendingMeshCoordinatorEvents: () => getPendingMeshCoordinatorEvents,
1677
1687
  handleMeshForwardEvent: () => handleMeshForwardEvent,
1678
1688
  setupMeshEventForwarding: () => setupMeshEventForwarding,
1679
1689
  triggerMeshQueue: () => triggerMeshQueue,
@@ -1682,6 +1692,12 @@ __export(mesh_events_exports, {
1682
1692
  function drainPendingMeshCoordinatorEvents() {
1683
1693
  return pendingMeshCoordinatorEvents.splice(0);
1684
1694
  }
1695
+ function getPendingMeshCoordinatorEvents() {
1696
+ return pendingMeshCoordinatorEvents.slice();
1697
+ }
1698
+ function clearPendingMeshCoordinatorEvents() {
1699
+ pendingMeshCoordinatorEvents.splice(0);
1700
+ }
1685
1701
  function readNonEmptyString(value) {
1686
1702
  return typeof value === "string" && value.trim() ? value.trim() : "";
1687
1703
  }
@@ -9533,6 +9549,28 @@ var StatusMonitor = class {
9533
9549
  };
9534
9550
 
9535
9551
  // src/providers/chat-message-normalization.ts
9552
+ function extractFinalSummaryFromMessages(messages, maxChars = 500) {
9553
+ if (!Array.isArray(messages) || messages.length === 0) return "";
9554
+ for (let i = messages.length - 1; i >= 0; i--) {
9555
+ const msg = messages[i];
9556
+ if (!msg) continue;
9557
+ const classification = classifyChatMessageVisibility(msg);
9558
+ if (classification.isUserFacing && (msg.role === "assistant" || msg.role === "model")) {
9559
+ const text = flattenContent(msg.content).trim();
9560
+ if (text) return text.slice(0, maxChars);
9561
+ }
9562
+ }
9563
+ for (let i = messages.length - 1; i >= 0; i--) {
9564
+ const msg = messages[i];
9565
+ if (!msg) continue;
9566
+ const classification = classifyChatMessageVisibility(msg);
9567
+ if (classification.isUserFacing) {
9568
+ const text = flattenContent(msg.content).trim();
9569
+ if (text) return text.slice(0, maxChars);
9570
+ }
9571
+ }
9572
+ return "";
9573
+ }
9536
9574
  var BUILTIN_CHAT_MESSAGE_KINDS = ["standard", "thought", "tool", "terminal", "system"];
9537
9575
  var CHAT_MESSAGE_VISIBILITIES = ["user", "debug", "internal", "hidden"];
9538
9576
  var CHAT_MESSAGE_TRANSCRIPT_VISIBILITIES = ["visible", "chat", "user", "debug", "internal", "hidden"];
@@ -11544,7 +11582,8 @@ var ExtensionProviderInstance = class {
11544
11582
  ideType: this.ideType || this.type,
11545
11583
  agentType: this.type,
11546
11584
  agentName: this.agentName || this.provider.name,
11547
- extensionId: this.extensionId || this.type
11585
+ extensionId: this.extensionId || this.type,
11586
+ finalSummary: extractFinalSummaryFromMessages(data?.messages)
11548
11587
  });
11549
11588
  this.generatingStartedAt = 0;
11550
11589
  }
@@ -12312,7 +12351,7 @@ var IdeProviderInstance = class {
12312
12351
  } else if (agentStatus === "idle" && (lastStatus === "generating" || lastStatus === "waiting_approval")) {
12313
12352
  const startedAt = this.generatingStartedAt.get(agentKey);
12314
12353
  const duration = startedAt ? Math.round((now - startedAt) / 1e3) : 0;
12315
- this.pushEvent({ event: "agent:generating_completed", chatTitle, duration, timestamp: now, ideType: this.type });
12354
+ this.pushEvent({ event: "agent:generating_completed", chatTitle, duration, timestamp: now, ideType: this.type, finalSummary: extractFinalSummaryFromMessages(chatData?.messages) });
12316
12355
  this.generatingStartedAt.delete(agentKey);
12317
12356
  }
12318
12357
  this.lastAgentStatuses.set(agentKey, agentStatus);
@@ -17429,7 +17468,8 @@ var CliProviderInstance = class {
17429
17468
  event: "agent:generating_completed",
17430
17469
  chatTitle: pending.chatTitle,
17431
17470
  duration: pending.duration,
17432
- timestamp: pending.timestamp
17471
+ timestamp: pending.timestamp,
17472
+ finalSummary: extractFinalSummaryFromMessages(this.adapter?.getScriptParsedStatus()?.messages)
17433
17473
  });
17434
17474
  this.completedDebouncePending = null;
17435
17475
  this.completedDebounceTimer = null;
@@ -19177,7 +19217,7 @@ ${rawInput}` : rawInput;
19177
19217
  });
19178
19218
  } else if (newStatus === "idle" && (this.lastStatus === "generating" || this.lastStatus === "waiting_approval")) {
19179
19219
  const duration = this.generatingStartedAt ? Math.round((now - this.generatingStartedAt) / 1e3) : 0;
19180
- this.pushEvent({ event: "agent:generating_completed", chatTitle, duration, timestamp: now });
19220
+ this.pushEvent({ event: "agent:generating_completed", chatTitle, duration, timestamp: now, finalSummary: extractFinalSummaryFromMessages(this.messages) });
19181
19221
  this.generatingStartedAt = 0;
19182
19222
  } else if (newStatus === "stopped") {
19183
19223
  this.pushEvent({ event: "agent:stopped", chatTitle, timestamp: now });
@@ -33786,6 +33826,7 @@ export {
33786
33826
  classifyHotChatSessionsForSubscriptionFlush,
33787
33827
  classifyP2pRelayFailure,
33788
33828
  clearDebugTrace,
33829
+ clearPendingMeshCoordinatorEvents,
33789
33830
  compareGitSnapshots,
33790
33831
  configureDebugTraceStore,
33791
33832
  connectCdpManager,
@@ -33801,6 +33842,7 @@ export {
33801
33842
  detectAllVersions,
33802
33843
  detectCLIs,
33803
33844
  detectIDEs,
33845
+ drainPendingMeshCoordinatorEvents,
33804
33846
  enqueueTask,
33805
33847
  ensureSessionHostReady,
33806
33848
  execNpmCommandSync,
@@ -33827,6 +33869,7 @@ export {
33827
33869
  getMeshByRepo,
33828
33870
  getMeshQueueStats,
33829
33871
  getNpmExecOptions,
33872
+ getPendingMeshCoordinatorEvents,
33830
33873
  getQueue,
33831
33874
  getRecentActivity,
33832
33875
  getRecentCommands,