@adhdev/daemon-core 0.9.82-rc.336 → 0.9.82-rc.337

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.
@@ -39,6 +39,25 @@ export declare function readRefineJobId(event: {
39
39
  metadataEvent?: Record<string, unknown>;
40
40
  } | Record<string, unknown>): string;
41
41
  export declare function readWorkerResultMetadata(event: Record<string, unknown>): Record<string, unknown> | undefined;
42
+ /**
43
+ * A coordinator that surfaces a REMOTE worker's mesh session has no local instance for
44
+ * it, so the status snapshot's getLastDisplayMessage has nothing to read and the only
45
+ * preview the coordinator-mirrored copy could ever carry comes from the worker's
46
+ * completion event. The worker's latest assistant reply rides on that event as
47
+ * `finalSummary` (and as `workerResult.summary` / `result.summary` on some paths).
48
+ *
49
+ * This resolves that assistant text into a preview the coordinator can stamp onto its
50
+ * mirror entry so the mobile inbox shows the worker's latest assistant response instead
51
+ * of being stuck on the first dispatched user task (which is the only message the
52
+ * coordinator-side transcript ever holds). Returns undefined when the event carries no
53
+ * assistant text — non-completion lifecycle events (generating_started / ready without a
54
+ * summary) must NOT clobber a previously surfaced preview.
55
+ */
56
+ export declare function resolveMeshSurfacedSessionPreview(metadataEvent: Record<string, unknown>): {
57
+ preview: string;
58
+ role: 'assistant';
59
+ receivedAt: number;
60
+ } | undefined;
42
61
  export declare function buildMeshSystemMessage(args: {
43
62
  event: string;
44
63
  nodeLabel: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/daemon-core",
3
- "version": "0.9.82-rc.336",
3
+ "version": "0.9.82-rc.337",
4
4
  "description": "ADHDev daemon core — CDP, IDE detection, providers, command execution",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -46,7 +46,7 @@
46
46
  "author": "vilmire",
47
47
  "license": "AGPL-3.0-or-later",
48
48
  "dependencies": {
49
- "@adhdev/mesh-shared": "0.9.82-rc.336",
49
+ "@adhdev/mesh-shared": "0.9.82-rc.337",
50
50
  "@adhdev/session-host-core": "*",
51
51
  "@agentclientprotocol/sdk": "^0.16.1",
52
52
  "ajv": "^8.20.0",
@@ -30,6 +30,7 @@ import {
30
30
  resolveEventSessionId,
31
31
  readRefineJobId,
32
32
  readWorkerResultMetadata,
33
+ resolveMeshSurfacedSessionPreview,
33
34
  } from './mesh-events-utils.js';
34
35
 
35
36
  // The set of coordinator-daemon ids this daemon answers to when draining the
@@ -1394,6 +1395,15 @@ function injectMeshSystemMessage(components: DaemonComponents, args: {
1394
1395
  // across standalone and cloud.
1395
1396
  if (components.onMeshCoordinatorEventForwarded) {
1396
1397
  try {
1398
+ // T: the coordinator surfaces a remote worker's session but holds no local
1399
+ // instance for it, so the status snapshot can't derive a preview and the
1400
+ // mirror would stay stuck on the first dispatched user task. Resolve the
1401
+ // worker's latest assistant reply (carried on the completion event's
1402
+ // finalSummary / workerResult) into a preview the mirror can stamp, so the
1403
+ // mobile inbox reflects the assistant response. Only completion-style events
1404
+ // carry assistant text; for everything else this is undefined and the prior
1405
+ // surfaced preview is preserved downstream (no clobber).
1406
+ const surfacedPreview = resolveMeshSurfacedSessionPreview(args.metadataEvent);
1397
1407
  components.onMeshCoordinatorEventForwarded({
1398
1408
  event: args.event,
1399
1409
  meshId: args.meshId,
@@ -1405,6 +1415,11 @@ function injectMeshSystemMessage(components: DaemonComponents, args: {
1405
1415
  workspace: readNonEmptyString(args.metadataEvent.workspace)
1406
1416
  || readNonEmptyString(args.metadataEvent.workspaceName)
1407
1417
  || undefined,
1418
+ ...(surfacedPreview ? {
1419
+ meshSessionLastMessagePreview: surfacedPreview.preview,
1420
+ meshSessionLastMessageRole: surfacedPreview.role,
1421
+ meshSessionLastMessageAt: surfacedPreview.receivedAt || undefined,
1422
+ } : {}),
1408
1423
  });
1409
1424
  } catch { /* dashboard metadata sync is best-effort */ }
1410
1425
  }
@@ -107,6 +107,52 @@ export function readWorkerResultMetadata(event: Record<string, unknown>): Record
107
107
  return readRecord(event.workerResult) || readRecord(event.meshWorkerResult) || readRecord(event.structuredResult);
108
108
  }
109
109
 
110
+ const MESH_SURFACED_PREVIEW_MAX_CHARS = 512;
111
+
112
+ /**
113
+ * A coordinator that surfaces a REMOTE worker's mesh session has no local instance for
114
+ * it, so the status snapshot's getLastDisplayMessage has nothing to read and the only
115
+ * preview the coordinator-mirrored copy could ever carry comes from the worker's
116
+ * completion event. The worker's latest assistant reply rides on that event as
117
+ * `finalSummary` (and as `workerResult.summary` / `result.summary` on some paths).
118
+ *
119
+ * This resolves that assistant text into a preview the coordinator can stamp onto its
120
+ * mirror entry so the mobile inbox shows the worker's latest assistant response instead
121
+ * of being stuck on the first dispatched user task (which is the only message the
122
+ * coordinator-side transcript ever holds). Returns undefined when the event carries no
123
+ * assistant text — non-completion lifecycle events (generating_started / ready without a
124
+ * summary) must NOT clobber a previously surfaced preview.
125
+ */
126
+ export function resolveMeshSurfacedSessionPreview(
127
+ metadataEvent: Record<string, unknown>,
128
+ ): { preview: string; role: 'assistant'; receivedAt: number } | undefined {
129
+ const workerResult = readWorkerResultMetadata(metadataEvent);
130
+ const resultRecord = readRecord(metadataEvent.result);
131
+ const summaryText = readNonEmptyString(metadataEvent.finalSummary)
132
+ || readNonEmptyString(workerResult?.summary)
133
+ || readNonEmptyString(workerResult?.finalSummary)
134
+ || readNonEmptyString(resultRecord?.summary)
135
+ || readNonEmptyString(resultRecord?.finalSummary);
136
+ if (!summaryText) return undefined;
137
+ const truncationSuffix = '...[truncated]';
138
+ const preview = summaryText.length > MESH_SURFACED_PREVIEW_MAX_CHARS
139
+ ? `${summaryText.slice(0, MESH_SURFACED_PREVIEW_MAX_CHARS - truncationSuffix.length)}${truncationSuffix}`
140
+ : summaryText;
141
+ const timestamp = readEventTimestampValue(metadataEvent.timestamp);
142
+ return { preview, role: 'assistant', receivedAt: timestamp };
143
+ }
144
+
145
+ function readEventTimestampValue(value: unknown): number {
146
+ if (typeof value === 'number' && Number.isFinite(value)) return value;
147
+ if (typeof value === 'string' && value.trim()) {
148
+ const parsed = Number(value);
149
+ if (Number.isFinite(parsed)) return parsed;
150
+ const dateMs = Date.parse(value);
151
+ if (Number.isFinite(dateMs)) return dateMs;
152
+ }
153
+ return 0;
154
+ }
155
+
110
156
  function formatCompletionMetadata(event: Record<string, unknown>): string {
111
157
  const completionDiagnostic = event.completionDiagnostic && typeof event.completionDiagnostic === 'object'
112
158
  ? event.completionDiagnostic as Record<string, unknown>