@adhdev/daemon-core 0.9.82-rc.336 → 0.9.82-rc.338
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 +1 -1
- package/dist/index.js +43 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -6
- package/dist/index.mjs.map +1 -1
- package/dist/mesh/mesh-events-utils.d.ts +19 -0
- package/dist/status/snapshot.d.ts +25 -0
- package/package.json +2 -2
- package/src/index.ts +1 -1
- package/src/mesh/mesh-events-coordinator.ts +15 -0
- package/src/mesh/mesh-events-utils.ts +46 -0
- package/src/providers/cli-provider-instance.ts +8 -1
- package/src/status/snapshot.ts +11 -1
|
@@ -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;
|
|
@@ -65,6 +65,31 @@ export interface RecentReadDebugSnapshot {
|
|
|
65
65
|
}
|
|
66
66
|
export declare function shouldEmitRecentReadDebugLog(cache: Map<string, string>, snapshot: RecentReadDebugSnapshot): boolean;
|
|
67
67
|
export declare function buildMachineInfo(profile?: 'full' | 'live' | 'metadata'): MachineInfo;
|
|
68
|
+
/**
|
|
69
|
+
* Resolve the last user-visible (non-system) message for a session as a preview.
|
|
70
|
+
*
|
|
71
|
+
* Exported so the cloud coordinator can derive a preview for a LOCAL mesh-owned
|
|
72
|
+
* worktree session directly from the real provider instance it hosts. A REMOTE
|
|
73
|
+
* worker session has no local instance (its preview rides the completion event's
|
|
74
|
+
* finalSummary — see resolveMeshSurfacedSessionPreview), but a LOCAL coordinator
|
|
75
|
+
* IS the worker, so its hosted instance's transcript holds the assistant reply and
|
|
76
|
+
* this is the source of truth for that case.
|
|
77
|
+
*/
|
|
78
|
+
export declare function getLastDisplayMessage(session: {
|
|
79
|
+
activeChat?: {
|
|
80
|
+
messages?: Array<{
|
|
81
|
+
role?: string;
|
|
82
|
+
content?: unknown;
|
|
83
|
+
receivedAt?: number | string;
|
|
84
|
+
timestamp?: number | string;
|
|
85
|
+
}> | null;
|
|
86
|
+
} | null;
|
|
87
|
+
}): {
|
|
88
|
+
role: string;
|
|
89
|
+
preview: string;
|
|
90
|
+
receivedAt: number;
|
|
91
|
+
hash: string;
|
|
92
|
+
} | null;
|
|
68
93
|
export { getSessionCurrentNotificationId, applySessionNotificationOverlay } from '../config/recent-activity.js';
|
|
69
94
|
export declare function getSessionCompletionMarker(session: {
|
|
70
95
|
activeChat?: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adhdev/daemon-core",
|
|
3
|
-
"version": "0.9.82-rc.
|
|
3
|
+
"version": "0.9.82-rc.338",
|
|
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.
|
|
49
|
+
"@adhdev/mesh-shared": "0.9.82-rc.338",
|
|
50
50
|
"@adhdev/session-host-core": "*",
|
|
51
51
|
"@agentclientprotocol/sdk": "^0.16.1",
|
|
52
52
|
"ajv": "^8.20.0",
|
package/src/index.ts
CHANGED
|
@@ -320,7 +320,7 @@ export type {
|
|
|
320
320
|
// ── Status ──
|
|
321
321
|
export { DaemonStatusReporter } from './status/reporter.js';
|
|
322
322
|
export { buildSessionEntries, findCdpManager, hasCdpManager, isCdpConnected } from './status/builders.js';
|
|
323
|
-
export { buildStatusSnapshot, buildMachineInfo } from './status/snapshot.js';
|
|
323
|
+
export { buildStatusSnapshot, buildMachineInfo, getLastDisplayMessage } from './status/snapshot.js';
|
|
324
324
|
export { getDaemonBuildInfo } from './build-info.js';
|
|
325
325
|
export type { DaemonBuildInfo } from './build-info.js';
|
|
326
326
|
export { normalizeManagedStatus, isManagedStatusWorking, isManagedStatusWaiting, normalizeActiveChatData } from './status/normalize.js';
|
|
@@ -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>
|
|
@@ -1425,8 +1425,15 @@ export class CliProviderInstance implements ProviderInstance {
|
|
|
1425
1425
|
chatTitle: pending.chatTitle,
|
|
1426
1426
|
duration: pending.duration,
|
|
1427
1427
|
timestamp: pending.timestamp,
|
|
1428
|
+
// When finalization is forced past the timeout on a `parsed_status:` block
|
|
1429
|
+
// (the parser never confirmed a final assistant turn) we previously rode an
|
|
1430
|
+
// empty `finalSummary` unconditionally. That empty value propagates to the
|
|
1431
|
+
// mesh coordinator's mirror preview (meshSessionLastMessagePreview), leaving a
|
|
1432
|
+
// delegated session's inbox preview blank — or, for a LOCAL worktree session,
|
|
1433
|
+
// stuck on the dispatched user task. If the parser DID surface assistant text,
|
|
1434
|
+
// prefer it; only fall back to '' when no assistant summary can be derived.
|
|
1428
1435
|
finalSummary: blockReason.startsWith('parsed_status:')
|
|
1429
|
-
? ''
|
|
1436
|
+
? (this.completionFinalSummary(this.adapter?.getScriptParsedStatus()?.messages) ?? '')
|
|
1430
1437
|
: this.completionFinalSummary(this.adapter?.getScriptParsedStatus()?.messages),
|
|
1431
1438
|
completionDiagnostic,
|
|
1432
1439
|
});
|
package/src/status/snapshot.ts
CHANGED
|
@@ -283,7 +283,17 @@ function simplePreviewHash(value: string): string {
|
|
|
283
283
|
return h.toString(16);
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
-
|
|
286
|
+
/**
|
|
287
|
+
* Resolve the last user-visible (non-system) message for a session as a preview.
|
|
288
|
+
*
|
|
289
|
+
* Exported so the cloud coordinator can derive a preview for a LOCAL mesh-owned
|
|
290
|
+
* worktree session directly from the real provider instance it hosts. A REMOTE
|
|
291
|
+
* worker session has no local instance (its preview rides the completion event's
|
|
292
|
+
* finalSummary — see resolveMeshSurfacedSessionPreview), but a LOCAL coordinator
|
|
293
|
+
* IS the worker, so its hosted instance's transcript holds the assistant reply and
|
|
294
|
+
* this is the source of truth for that case.
|
|
295
|
+
*/
|
|
296
|
+
export function getLastDisplayMessage(session: {
|
|
287
297
|
activeChat?: {
|
|
288
298
|
messages?: Array<{
|
|
289
299
|
role?: string;
|