@adhdev/daemon-core 0.8.35 → 0.8.36
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/boot/daemon-lifecycle.d.ts +4 -0
- package/dist/commands/router.d.ts +3 -0
- package/dist/config/config.d.ts +5 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +458 -154
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +457 -154
- package/dist/index.mjs.map +1 -1
- package/dist/shared-types.d.ts +248 -16
- package/dist/status/builders.d.ts +5 -1
- package/dist/status/normalize.d.ts +11 -1
- package/dist/status/normalize.js +36 -16
- package/dist/status/normalize.js.map +1 -1
- package/dist/status/normalize.mjs +35 -16
- package/dist/status/normalize.mjs.map +1 -1
- package/dist/status/reporter.d.ts +4 -0
- package/dist/status/snapshot.d.ts +5 -5
- package/dist/types.d.ts +1 -1
- package/node_modules/@adhdev/session-host-core/package.json +1 -1
- package/package.json +1 -1
- package/src/boot/daemon-lifecycle.ts +7 -0
- package/src/commands/chat-commands.ts +192 -17
- package/src/commands/router.ts +25 -0
- package/src/commands/stream-commands.ts +14 -10
- package/src/config/config.ts +8 -0
- package/src/index.d.ts +2 -2
- package/src/index.ts +32 -1
- package/src/shared-types.d.ts +125 -16
- package/src/shared-types.ts +279 -16
- package/src/status/builders.ts +110 -54
- package/src/status/normalize.ts +54 -19
- package/src/status/reporter.ts +88 -13
- package/src/status/snapshot.ts +79 -41
- package/src/types.ts +1 -1
package/src/status/snapshot.ts
CHANGED
|
@@ -15,11 +15,12 @@ import { getHostMemorySnapshot } from '../system/host-memory.js';
|
|
|
15
15
|
import { getTerminalBackendRuntimeStatus } from '../cli-adapters/terminal-screen.js';
|
|
16
16
|
import { LOG } from '../logging/logger.js';
|
|
17
17
|
import type { DaemonCdpManager } from '../cdp/manager.js';
|
|
18
|
-
import { buildSessionEntries, isCdpConnected } from './builders.js';
|
|
18
|
+
import { buildSessionEntries, isCdpConnected, type SessionEntryProfile } from './builders.js';
|
|
19
19
|
import type { ProviderState } from '../providers/provider-instance.js';
|
|
20
20
|
import type {
|
|
21
21
|
AvailableProviderInfo,
|
|
22
22
|
DetectedIdeInfo,
|
|
23
|
+
MachineInfo,
|
|
23
24
|
RecentLaunchEntry,
|
|
24
25
|
RecentSessionBucket,
|
|
25
26
|
SessionEntry,
|
|
@@ -54,15 +55,13 @@ export interface StatusSnapshotOptions {
|
|
|
54
55
|
}>;
|
|
55
56
|
instanceId: string;
|
|
56
57
|
version: string;
|
|
57
|
-
daemonMode: boolean;
|
|
58
58
|
timestamp?: number;
|
|
59
59
|
p2p?: StatusReportPayload['p2p'];
|
|
60
60
|
machineNickname?: string | null;
|
|
61
|
+
profile?: SessionEntryProfile;
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
export
|
|
64
|
-
availableProviders: AvailableProviderInfo[];
|
|
65
|
-
}
|
|
64
|
+
export type StatusSnapshot = StatusReportPayload;
|
|
66
65
|
|
|
67
66
|
const READ_DEBUG_ENABLED = process.argv.includes('--dev') || process.env.ADHDEV_READ_DEBUG === '1';
|
|
68
67
|
|
|
@@ -103,6 +102,41 @@ function buildAvailableProviders(
|
|
|
103
102
|
}));
|
|
104
103
|
}
|
|
105
104
|
|
|
105
|
+
export function buildMachineInfo(profile: 'full' | 'live' | 'metadata' = 'full'): MachineInfo {
|
|
106
|
+
const base: MachineInfo = {
|
|
107
|
+
hostname: os.hostname(),
|
|
108
|
+
platform: os.platform(),
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
if (profile === 'live') {
|
|
112
|
+
return base;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (profile === 'metadata') {
|
|
116
|
+
const memSnap = getHostMemorySnapshot();
|
|
117
|
+
return {
|
|
118
|
+
...base,
|
|
119
|
+
arch: os.arch(),
|
|
120
|
+
cpus: os.cpus().length,
|
|
121
|
+
totalMem: memSnap.totalMem,
|
|
122
|
+
release: os.release(),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const memSnap = getHostMemorySnapshot();
|
|
127
|
+
return {
|
|
128
|
+
...base,
|
|
129
|
+
arch: os.arch(),
|
|
130
|
+
cpus: os.cpus().length,
|
|
131
|
+
totalMem: memSnap.totalMem,
|
|
132
|
+
freeMem: memSnap.freeMem,
|
|
133
|
+
availableMem: memSnap.availableMem,
|
|
134
|
+
loadavg: os.loadavg(),
|
|
135
|
+
uptime: os.uptime(),
|
|
136
|
+
release: os.release(),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
106
140
|
function parseMessageTime(value: unknown): number {
|
|
107
141
|
if (typeof value === 'number' && Number.isFinite(value)) return value;
|
|
108
142
|
if (typeof value === 'string') {
|
|
@@ -207,28 +241,39 @@ function buildRecentLaunches(
|
|
|
207
241
|
}
|
|
208
242
|
|
|
209
243
|
export function buildStatusSnapshot(options: StatusSnapshotOptions): StatusSnapshot {
|
|
244
|
+
const profile = options.profile || 'full';
|
|
210
245
|
const cfg = loadConfig();
|
|
211
246
|
const state = loadState();
|
|
212
247
|
const wsState = getWorkspaceState(cfg);
|
|
213
|
-
const memSnap = getHostMemorySnapshot();
|
|
214
248
|
const recentActivity = getRecentActivity(state, 20);
|
|
215
|
-
const
|
|
249
|
+
const unreadSourceSessions = buildSessionEntries(
|
|
216
250
|
options.allStates,
|
|
217
251
|
options.cdpManagers,
|
|
252
|
+
{ profile: 'full' },
|
|
218
253
|
);
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
254
|
+
const sessions = profile === 'full'
|
|
255
|
+
? unreadSourceSessions
|
|
256
|
+
: buildSessionEntries(
|
|
257
|
+
options.allStates,
|
|
258
|
+
options.cdpManagers,
|
|
259
|
+
{ profile },
|
|
260
|
+
);
|
|
261
|
+
const sessionsById = new Map(sessions.map((session) => [session.id, session]));
|
|
262
|
+
for (const sourceSession of unreadSourceSessions) {
|
|
263
|
+
const session = sessionsById.get(sourceSession.id);
|
|
264
|
+
if (!session) continue;
|
|
265
|
+
const lastSeenAt = getSessionSeenAt(state, sourceSession.id);
|
|
266
|
+
const seenCompletionMarker = getSessionSeenMarker(state, sourceSession.id);
|
|
267
|
+
const lastUsedAt = getSessionLastUsedAt(sourceSession);
|
|
268
|
+
const completionMarker = getSessionCompletionMarker(sourceSession);
|
|
269
|
+
const { unread, inboxBucket } = sourceSession.surfaceHidden
|
|
225
270
|
? { unread: false, inboxBucket: 'idle' as RecentSessionBucket }
|
|
226
271
|
: getUnreadState(
|
|
227
|
-
getSessionMessageUpdatedAt(
|
|
228
|
-
|
|
272
|
+
getSessionMessageUpdatedAt(sourceSession) > 0,
|
|
273
|
+
sourceSession.status,
|
|
229
274
|
lastUsedAt,
|
|
230
275
|
lastSeenAt,
|
|
231
|
-
getLastMessageRole(
|
|
276
|
+
getLastMessageRole(sourceSession),
|
|
232
277
|
completionMarker,
|
|
233
278
|
seenCompletionMarker,
|
|
234
279
|
);
|
|
@@ -238,39 +283,32 @@ export function buildStatusSnapshot(options: StatusSnapshotOptions): StatusSnaps
|
|
|
238
283
|
if (READ_DEBUG_ENABLED && (session.unread || session.inboxBucket !== 'idle' || session.providerType.includes('codex'))) {
|
|
239
284
|
LOG.info(
|
|
240
285
|
'RecentRead',
|
|
241
|
-
`snapshot session id=${session.id} provider=${session.providerType} status=${String(session.status || '')} bucket=${inboxBucket} unread=${String(unread)} lastSeenAt=${lastSeenAt} completionMarker=${completionMarker || '-'} seenMarker=${seenCompletionMarker || '-'} lastUpdated=${String(session.lastUpdated || 0)} lastUsedAt=${lastUsedAt} lastRole=${getLastMessageRole(
|
|
286
|
+
`snapshot session id=${session.id} provider=${session.providerType} status=${String(session.status || '')} bucket=${inboxBucket} unread=${String(unread)} lastSeenAt=${lastSeenAt} completionMarker=${completionMarker || '-'} seenMarker=${seenCompletionMarker || '-'} lastUpdated=${String(session.lastUpdated || 0)} lastUsedAt=${lastUsedAt} lastRole=${getLastMessageRole(sourceSession)} msgUpdatedAt=${getSessionMessageUpdatedAt(sourceSession)}`,
|
|
242
287
|
);
|
|
243
288
|
}
|
|
244
289
|
}
|
|
245
|
-
const
|
|
290
|
+
const includeMachineMetadata = profile !== 'live';
|
|
291
|
+
const terminalBackend = includeMachineMetadata
|
|
292
|
+
? getTerminalBackendRuntimeStatus()
|
|
293
|
+
: undefined;
|
|
246
294
|
|
|
247
295
|
return {
|
|
248
296
|
instanceId: options.instanceId,
|
|
249
|
-
version: options.version,
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
hostname: os.hostname(),
|
|
253
|
-
platform: os.platform(),
|
|
254
|
-
arch: os.arch(),
|
|
255
|
-
cpus: os.cpus().length,
|
|
256
|
-
totalMem: memSnap.totalMem,
|
|
257
|
-
freeMem: memSnap.freeMem,
|
|
258
|
-
availableMem: memSnap.availableMem,
|
|
259
|
-
loadavg: os.loadavg(),
|
|
260
|
-
uptime: os.uptime(),
|
|
261
|
-
release: os.release(),
|
|
262
|
-
},
|
|
263
|
-
machineNickname: options.machineNickname ?? cfg.machineNickname ?? null,
|
|
297
|
+
...(includeMachineMetadata ? { version: options.version } : {}),
|
|
298
|
+
machine: buildMachineInfo(profile),
|
|
299
|
+
...(includeMachineMetadata ? { machineNickname: options.machineNickname ?? cfg.machineNickname ?? null } : {}),
|
|
264
300
|
timestamp: options.timestamp ?? Date.now(),
|
|
265
|
-
detectedIdes: buildDetectedIdeInfos(options.detectedIdes, options.cdpManagers),
|
|
266
301
|
...(options.p2p ? { p2p: options.p2p } : {}),
|
|
267
302
|
sessions,
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
303
|
+
...(terminalBackend ? { terminalBackend } : {}),
|
|
304
|
+
...(includeMachineMetadata && {
|
|
305
|
+
detectedIdes: buildDetectedIdeInfos(options.detectedIdes, options.cdpManagers),
|
|
306
|
+
workspaces: wsState.workspaces,
|
|
307
|
+
defaultWorkspaceId: wsState.defaultWorkspaceId,
|
|
308
|
+
defaultWorkspacePath: wsState.defaultWorkspacePath,
|
|
309
|
+
terminalSizingMode: cfg.terminalSizingMode || 'measured',
|
|
310
|
+
recentLaunches: buildRecentLaunches(recentActivity),
|
|
311
|
+
availableProviders: buildAvailableProviders(options.providerLoader),
|
|
312
|
+
}),
|
|
275
313
|
};
|
|
276
314
|
}
|
package/src/types.ts
CHANGED
|
@@ -18,7 +18,7 @@ export interface StatusResponse extends StatusReportPayload {
|
|
|
18
18
|
/** User display name from config */
|
|
19
19
|
userName?: string;
|
|
20
20
|
/** Available providers */
|
|
21
|
-
availableProviders
|
|
21
|
+
availableProviders?: AvailableProviderInfo[];
|
|
22
22
|
/** System info (legacy compat) */
|
|
23
23
|
system?: SystemInfo;
|
|
24
24
|
}
|