@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.d.ts CHANGED
@@ -37,7 +37,8 @@ export { buildMeshLedgerReconciliationEvidence, buildMeshLedgerReplicaEvidence }
37
37
  export type { MeshLedgerReconciliationEvidence, MeshLedgerReplicaEvidence, MeshLedgerReplicaStatus } from './mesh/mesh-ledger-reconciliation.js';
38
38
  export { enqueueTask, getQueue, claimNextTask, updateTaskStatus, updateSessionTaskStatus, cancelTask, requeueTask, getMeshQueueStats } from './mesh/mesh-work-queue.js';
39
39
  export type { MeshWorkQueueEntry, MeshTaskStatus, MeshWorkQueueStats } from './mesh/mesh-work-queue.js';
40
- export { triggerMeshQueue } from './mesh/mesh-events.js';
40
+ export { triggerMeshQueue, drainPendingMeshCoordinatorEvents, getPendingMeshCoordinatorEvents, clearPendingMeshCoordinatorEvents } from './mesh/mesh-events.js';
41
+ export type { PendingMeshCoordinatorEvent } from './mesh/mesh-events.js';
41
42
  export { P2pRelayFailureError, buildP2pRelayFailurePayload, classifyP2pRelayFailure, isP2pRelayTransportFailure, } from './mesh/p2p-relay-failure.js';
42
43
  export type { P2pRelayFailureClassification, P2pRelayFailureCode, P2pRelayFailureContext, P2pRelayFailurePayload, } from './mesh/p2p-relay-failure.js';
43
44
  export { loadState, saveState, resetState } from './config/state-store.js';
package/dist/index.js CHANGED
@@ -1209,6 +1209,7 @@ function claimNextTask(meshId, nodeId, sessionId) {
1209
1209
  entry.status = "assigned";
1210
1210
  entry.assignedNodeId = nodeId;
1211
1211
  entry.assignedSessionId = sessionId;
1212
+ entry.dispatchTimestamp = (/* @__PURE__ */ new Date()).toISOString();
1212
1213
  entry.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
1213
1214
  writeQueue(meshId, queue);
1214
1215
  return entry;
@@ -1271,15 +1272,22 @@ function requeueTask(meshId, taskId, opts) {
1271
1272
  }
1272
1273
  function updateSessionTaskStatus(meshId, sessionId, status) {
1273
1274
  const queue = readQueue(meshId);
1275
+ let bestIdx = -1;
1276
+ let bestTime = 0;
1274
1277
  for (let i = queue.length - 1; i >= 0; i--) {
1275
1278
  if (queue[i].assignedSessionId === sessionId && queue[i].status === "assigned") {
1276
- queue[i].status = status;
1277
- queue[i].updatedAt = (/* @__PURE__ */ new Date()).toISOString();
1278
- writeQueue(meshId, queue);
1279
- return queue[i];
1279
+ const time = new Date(queue[i].dispatchTimestamp || queue[i].updatedAt).getTime();
1280
+ if (time > bestTime) {
1281
+ bestTime = time;
1282
+ bestIdx = i;
1283
+ }
1280
1284
  }
1281
1285
  }
1282
- return null;
1286
+ if (bestIdx === -1) return null;
1287
+ queue[bestIdx].status = status;
1288
+ queue[bestIdx].updatedAt = (/* @__PURE__ */ new Date()).toISOString();
1289
+ writeQueue(meshId, queue);
1290
+ return queue[bestIdx];
1283
1291
  }
1284
1292
  function getMeshQueueStats(meshId) {
1285
1293
  const queue = readQueue(meshId);
@@ -1679,7 +1687,9 @@ var init_logger = __esm({
1679
1687
  // src/mesh/mesh-events.ts
1680
1688
  var mesh_events_exports = {};
1681
1689
  __export(mesh_events_exports, {
1690
+ clearPendingMeshCoordinatorEvents: () => clearPendingMeshCoordinatorEvents,
1682
1691
  drainPendingMeshCoordinatorEvents: () => drainPendingMeshCoordinatorEvents,
1692
+ getPendingMeshCoordinatorEvents: () => getPendingMeshCoordinatorEvents,
1683
1693
  handleMeshForwardEvent: () => handleMeshForwardEvent,
1684
1694
  setupMeshEventForwarding: () => setupMeshEventForwarding,
1685
1695
  triggerMeshQueue: () => triggerMeshQueue,
@@ -1688,6 +1698,12 @@ __export(mesh_events_exports, {
1688
1698
  function drainPendingMeshCoordinatorEvents() {
1689
1699
  return pendingMeshCoordinatorEvents.splice(0);
1690
1700
  }
1701
+ function getPendingMeshCoordinatorEvents() {
1702
+ return pendingMeshCoordinatorEvents.slice();
1703
+ }
1704
+ function clearPendingMeshCoordinatorEvents() {
1705
+ pendingMeshCoordinatorEvents.splice(0);
1706
+ }
1691
1707
  function readNonEmptyString(value) {
1692
1708
  return typeof value === "string" && value.trim() ? value.trim() : "";
1693
1709
  }
@@ -5533,6 +5549,7 @@ __export(index_exports, {
5533
5549
  classifyHotChatSessionsForSubscriptionFlush: () => classifyHotChatSessionsForSubscriptionFlush,
5534
5550
  classifyP2pRelayFailure: () => classifyP2pRelayFailure,
5535
5551
  clearDebugTrace: () => clearDebugTrace,
5552
+ clearPendingMeshCoordinatorEvents: () => clearPendingMeshCoordinatorEvents,
5536
5553
  compareGitSnapshots: () => compareGitSnapshots,
5537
5554
  configureDebugTraceStore: () => configureDebugTraceStore,
5538
5555
  connectCdpManager: () => connectCdpManager,
@@ -5548,6 +5565,7 @@ __export(index_exports, {
5548
5565
  detectAllVersions: () => detectAllVersions,
5549
5566
  detectCLIs: () => detectCLIs,
5550
5567
  detectIDEs: () => detectIDEs,
5568
+ drainPendingMeshCoordinatorEvents: () => drainPendingMeshCoordinatorEvents,
5551
5569
  enqueueTask: () => enqueueTask,
5552
5570
  ensureSessionHostReady: () => ensureSessionHostReady,
5553
5571
  execNpmCommandSync: () => execNpmCommandSync,
@@ -5574,6 +5592,7 @@ __export(index_exports, {
5574
5592
  getMeshByRepo: () => getMeshByRepo,
5575
5593
  getMeshQueueStats: () => getMeshQueueStats,
5576
5594
  getNpmExecOptions: () => getNpmExecOptions,
5595
+ getPendingMeshCoordinatorEvents: () => getPendingMeshCoordinatorEvents,
5577
5596
  getQueue: () => getQueue,
5578
5597
  getRecentActivity: () => getRecentActivity,
5579
5598
  getRecentCommands: () => getRecentCommands,
@@ -9767,6 +9786,28 @@ var StatusMonitor = class {
9767
9786
  };
9768
9787
 
9769
9788
  // src/providers/chat-message-normalization.ts
9789
+ function extractFinalSummaryFromMessages(messages, maxChars = 500) {
9790
+ if (!Array.isArray(messages) || messages.length === 0) return "";
9791
+ for (let i = messages.length - 1; i >= 0; i--) {
9792
+ const msg = messages[i];
9793
+ if (!msg) continue;
9794
+ const classification = classifyChatMessageVisibility(msg);
9795
+ if (classification.isUserFacing && (msg.role === "assistant" || msg.role === "model")) {
9796
+ const text = flattenContent(msg.content).trim();
9797
+ if (text) return text.slice(0, maxChars);
9798
+ }
9799
+ }
9800
+ for (let i = messages.length - 1; i >= 0; i--) {
9801
+ const msg = messages[i];
9802
+ if (!msg) continue;
9803
+ const classification = classifyChatMessageVisibility(msg);
9804
+ if (classification.isUserFacing) {
9805
+ const text = flattenContent(msg.content).trim();
9806
+ if (text) return text.slice(0, maxChars);
9807
+ }
9808
+ }
9809
+ return "";
9810
+ }
9770
9811
  var BUILTIN_CHAT_MESSAGE_KINDS = ["standard", "thought", "tool", "terminal", "system"];
9771
9812
  var CHAT_MESSAGE_VISIBILITIES = ["user", "debug", "internal", "hidden"];
9772
9813
  var CHAT_MESSAGE_TRANSCRIPT_VISIBILITIES = ["visible", "chat", "user", "debug", "internal", "hidden"];
@@ -11778,7 +11819,8 @@ var ExtensionProviderInstance = class {
11778
11819
  ideType: this.ideType || this.type,
11779
11820
  agentType: this.type,
11780
11821
  agentName: this.agentName || this.provider.name,
11781
- extensionId: this.extensionId || this.type
11822
+ extensionId: this.extensionId || this.type,
11823
+ finalSummary: extractFinalSummaryFromMessages(data?.messages)
11782
11824
  });
11783
11825
  this.generatingStartedAt = 0;
11784
11826
  }
@@ -12546,7 +12588,7 @@ var IdeProviderInstance = class {
12546
12588
  } else if (agentStatus === "idle" && (lastStatus === "generating" || lastStatus === "waiting_approval")) {
12547
12589
  const startedAt = this.generatingStartedAt.get(agentKey);
12548
12590
  const duration = startedAt ? Math.round((now - startedAt) / 1e3) : 0;
12549
- this.pushEvent({ event: "agent:generating_completed", chatTitle, duration, timestamp: now, ideType: this.type });
12591
+ this.pushEvent({ event: "agent:generating_completed", chatTitle, duration, timestamp: now, ideType: this.type, finalSummary: extractFinalSummaryFromMessages(chatData?.messages) });
12550
12592
  this.generatingStartedAt.delete(agentKey);
12551
12593
  }
12552
12594
  this.lastAgentStatuses.set(agentKey, agentStatus);
@@ -17663,7 +17705,8 @@ var CliProviderInstance = class {
17663
17705
  event: "agent:generating_completed",
17664
17706
  chatTitle: pending.chatTitle,
17665
17707
  duration: pending.duration,
17666
- timestamp: pending.timestamp
17708
+ timestamp: pending.timestamp,
17709
+ finalSummary: extractFinalSummaryFromMessages(this.adapter?.getScriptParsedStatus()?.messages)
17667
17710
  });
17668
17711
  this.completedDebouncePending = null;
17669
17712
  this.completedDebounceTimer = null;
@@ -19406,7 +19449,7 @@ ${rawInput}` : rawInput;
19406
19449
  });
19407
19450
  } else if (newStatus === "idle" && (this.lastStatus === "generating" || this.lastStatus === "waiting_approval")) {
19408
19451
  const duration = this.generatingStartedAt ? Math.round((now - this.generatingStartedAt) / 1e3) : 0;
19409
- this.pushEvent({ event: "agent:generating_completed", chatTitle, duration, timestamp: now });
19452
+ this.pushEvent({ event: "agent:generating_completed", chatTitle, duration, timestamp: now, finalSummary: extractFinalSummaryFromMessages(this.messages) });
19410
19453
  this.generatingStartedAt = 0;
19411
19454
  } else if (newStatus === "stopped") {
19412
19455
  this.pushEvent({ event: "agent:stopped", chatTitle, timestamp: now });
@@ -34011,6 +34054,7 @@ async function shutdownDaemonComponents(components) {
34011
34054
  classifyHotChatSessionsForSubscriptionFlush,
34012
34055
  classifyP2pRelayFailure,
34013
34056
  clearDebugTrace,
34057
+ clearPendingMeshCoordinatorEvents,
34014
34058
  compareGitSnapshots,
34015
34059
  configureDebugTraceStore,
34016
34060
  connectCdpManager,
@@ -34026,6 +34070,7 @@ async function shutdownDaemonComponents(components) {
34026
34070
  detectAllVersions,
34027
34071
  detectCLIs,
34028
34072
  detectIDEs,
34073
+ drainPendingMeshCoordinatorEvents,
34029
34074
  enqueueTask,
34030
34075
  ensureSessionHostReady,
34031
34076
  execNpmCommandSync,
@@ -34052,6 +34097,7 @@ async function shutdownDaemonComponents(components) {
34052
34097
  getMeshByRepo,
34053
34098
  getMeshQueueStats,
34054
34099
  getNpmExecOptions,
34100
+ getPendingMeshCoordinatorEvents,
34055
34101
  getQueue,
34056
34102
  getRecentActivity,
34057
34103
  getRecentCommands,