@adhdev/daemon-core 0.8.35 → 0.8.37

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.
@@ -33,6 +33,117 @@ export interface AgentSessionStream {
33
33
  buttons: string[];
34
34
  } | null;
35
35
  }
36
+ export type ReadChatSyncMode = 'full' | 'append' | 'replace_tail' | 'noop';
37
+ export interface ReadChatCursor {
38
+ knownMessageCount?: number;
39
+ lastMessageSignature?: string;
40
+ tailLimit?: number;
41
+ }
42
+ export interface ReadChatSyncResult {
43
+ messages: ChatMessage[];
44
+ status: string;
45
+ title?: string;
46
+ activeModal?: {
47
+ message: string;
48
+ buttons: string[];
49
+ } | null;
50
+ syncMode: ReadChatSyncMode;
51
+ replaceFrom: number;
52
+ totalMessages: number;
53
+ lastMessageSignature: string;
54
+ }
55
+ export type TransportTopic = 'session.chat_tail' | 'machine.runtime' | 'session_host.diagnostics' | 'session.modal' | 'daemon.metadata';
56
+ export interface SessionChatTailSubscriptionParams extends ReadChatCursor {
57
+ targetSessionId: string;
58
+ historySessionId?: string;
59
+ }
60
+ export interface MachineRuntimeSubscriptionParams {
61
+ intervalMs?: number;
62
+ }
63
+ export interface SessionModalSubscriptionParams {
64
+ targetSessionId: string;
65
+ }
66
+ export interface DaemonMetadataSubscriptionParams {
67
+ includeSessions?: boolean;
68
+ }
69
+ export interface SessionHostDiagnosticsSubscriptionParams {
70
+ includeSessions?: boolean;
71
+ limit?: number;
72
+ intervalMs?: number;
73
+ }
74
+ export interface SessionChatTailUpdate extends ReadChatSyncResult {
75
+ topic: 'session.chat_tail';
76
+ key: string;
77
+ sessionId: string;
78
+ historySessionId?: string;
79
+ seq: number;
80
+ timestamp: number;
81
+ }
82
+ export interface MachineRuntimeUpdate {
83
+ topic: 'machine.runtime';
84
+ key: string;
85
+ machine: MachineInfo;
86
+ seq: number;
87
+ timestamp: number;
88
+ }
89
+ export interface SessionHostDiagnosticsUpdate {
90
+ topic: 'session_host.diagnostics';
91
+ key: string;
92
+ diagnostics: SessionHostDiagnosticsSnapshot;
93
+ seq: number;
94
+ timestamp: number;
95
+ }
96
+ export interface SessionModalUpdate {
97
+ topic: 'session.modal';
98
+ key: string;
99
+ sessionId: string;
100
+ status: string;
101
+ title?: string;
102
+ modalMessage?: string;
103
+ modalButtons?: string[];
104
+ seq: number;
105
+ timestamp: number;
106
+ }
107
+ export interface DaemonMetadataUpdate {
108
+ topic: 'daemon.metadata';
109
+ key: string;
110
+ daemonId: string;
111
+ status: StatusReportPayload;
112
+ userName?: string;
113
+ seq: number;
114
+ timestamp: number;
115
+ }
116
+ export interface TopicUpdateEnvelopeMap {
117
+ 'session.chat_tail': SessionChatTailUpdate;
118
+ 'machine.runtime': MachineRuntimeUpdate;
119
+ 'session_host.diagnostics': SessionHostDiagnosticsUpdate;
120
+ 'session.modal': SessionModalUpdate;
121
+ 'daemon.metadata': DaemonMetadataUpdate;
122
+ }
123
+ export type TopicUpdateEnvelope = TopicUpdateEnvelopeMap[TransportTopic];
124
+ export interface SubscribeRequestMap {
125
+ 'session.chat_tail': SessionChatTailSubscriptionParams;
126
+ 'machine.runtime': MachineRuntimeSubscriptionParams;
127
+ 'session_host.diagnostics': SessionHostDiagnosticsSubscriptionParams;
128
+ 'session.modal': SessionModalSubscriptionParams;
129
+ 'daemon.metadata': DaemonMetadataSubscriptionParams;
130
+ }
131
+ export type SubscribeRequest = {
132
+ [K in TransportTopic]: {
133
+ type: 'subscribe';
134
+ topic: K;
135
+ key: string;
136
+ params: SubscribeRequestMap[K];
137
+ };
138
+ }[TransportTopic];
139
+ export type UnsubscribeRequest = {
140
+ [K in TransportTopic]: {
141
+ type: 'unsubscribe';
142
+ topic: K;
143
+ key: string;
144
+ };
145
+ }[TransportTopic];
146
+ export type StandaloneWsStatusPayload = StatusReportPayload;
36
147
  export type SessionTransport = 'cdp-page' | 'cdp-webview' | 'pty' | 'acp';
37
148
  export type SessionKind = 'workspace' | 'agent';
38
149
  export type SessionCapability = 'read_chat' | 'send_message' | 'new_session' | 'list_sessions' | 'switch_session' | 'resolve_action' | 'terminal_io' | 'resize_terminal' | 'change_model' | 'set_mode' | 'set_thought_level';
@@ -42,13 +153,13 @@ export interface SessionEntry {
42
153
  id: string;
43
154
  parentId: string | null;
44
155
  providerType: string;
45
- providerName: string;
156
+ providerName?: string;
46
157
  providerSessionId?: string;
47
158
  kind: SessionKind;
48
159
  transport: SessionTransport;
49
160
  status: SessionStatus;
50
161
  title: string;
51
- workspace: string | null;
162
+ workspace?: string | null;
52
163
  runtimeKey?: string;
53
164
  runtimeDisplayName?: string;
54
165
  runtimeWorkspaceLabel?: string;
@@ -58,7 +169,7 @@ export interface SessionEntry {
58
169
  runtimeAttachedClients?: RuntimeAttachedClient[];
59
170
  resume?: ProviderResumeCapability;
60
171
  activeChat: _ActiveChatData | null;
61
- capabilities: SessionCapability[];
172
+ capabilities?: SessionCapability[];
62
173
  cdpConnected?: boolean;
63
174
  currentModel?: string;
64
175
  currentPlan?: string;
@@ -163,15 +274,15 @@ export interface ProviderControlSchema {
163
274
  export interface MachineInfo {
164
275
  hostname: string;
165
276
  platform: string;
166
- arch: string;
167
- cpus: number;
168
- totalMem: number;
169
- freeMem: number;
277
+ arch?: string;
278
+ cpus?: number;
279
+ totalMem?: number;
280
+ freeMem?: number;
170
281
  /** macOS: reclaimable-inclusive; prefer for UI used% */
171
282
  availableMem?: number;
172
- loadavg: number[];
173
- uptime: number;
174
- release: string;
283
+ loadavg?: number[];
284
+ uptime?: number;
285
+ release?: string;
175
286
  }
176
287
  /** Detected IDE on a machine */
177
288
  export interface DetectedIdeInfo {
@@ -217,18 +328,16 @@ export interface CompactDaemonEntry {
217
328
  export interface StatusReportPayload {
218
329
  /** Unique daemon instance identifier */
219
330
  instanceId: string;
220
- /** Daemon version */
221
- version: string;
222
- /** Daemon mode flag */
223
- daemonMode: boolean;
331
+ /** Daemon version (metadata/full snapshots only) */
332
+ version?: string;
224
333
  /** Machine info */
225
334
  machine: MachineInfo;
226
335
  /** Machine nickname (user-set) */
227
336
  machineNickname?: string | null;
228
337
  /** Timestamp */
229
338
  timestamp: number;
230
- /** Detected IDEs on this machine */
231
- detectedIdes: DetectedIdeInfo[];
339
+ /** Detected IDEs on this machine (metadata snapshot only) */
340
+ detectedIdes?: DetectedIdeInfo[];
232
341
  /** P2P state */
233
342
  p2p?: {
234
343
  available: boolean;
@@ -69,6 +69,192 @@ export interface AgentSessionStream {
69
69
  activeModal: { message: string; buttons: string[] } | null;
70
70
  }
71
71
 
72
+ export type ReadChatSyncMode = 'full' | 'append' | 'replace_tail' | 'noop';
73
+
74
+ export interface ReadChatCursor {
75
+ knownMessageCount?: number;
76
+ lastMessageSignature?: string;
77
+ tailLimit?: number;
78
+ }
79
+
80
+ export interface ReadChatSyncResult {
81
+ messages: ChatMessage[];
82
+ status: string;
83
+ title?: string;
84
+ activeModal?: { message: string; buttons: string[] } | null;
85
+ syncMode: ReadChatSyncMode;
86
+ replaceFrom: number;
87
+ totalMessages: number;
88
+ lastMessageSignature: string;
89
+ }
90
+
91
+ export interface SessionHostAttachedClient {
92
+ clientId: string;
93
+ type: string;
94
+ readOnly: boolean;
95
+ attachedAt: number;
96
+ lastSeenAt: number;
97
+ }
98
+
99
+ export interface SessionHostWriteOwner {
100
+ clientId: string;
101
+ ownerType: 'agent' | 'user';
102
+ acquiredAt: number;
103
+ }
104
+
105
+ export interface SessionHostRecord {
106
+ sessionId: string;
107
+ runtimeKey: string;
108
+ displayName: string;
109
+ workspaceLabel: string;
110
+ providerType: string;
111
+ workspace: string;
112
+ lifecycle: 'starting' | 'running' | 'stopping' | 'stopped' | 'failed' | 'interrupted';
113
+ writeOwner: SessionHostWriteOwner | null;
114
+ attachedClients: SessionHostAttachedClient[];
115
+ osPid?: number;
116
+ lastActivityAt: number;
117
+ createdAt: number;
118
+ startedAt?: number;
119
+ meta?: Record<string, unknown>;
120
+ }
121
+
122
+ export interface SessionHostLogEntry {
123
+ timestamp: number;
124
+ level: 'debug' | 'info' | 'warn' | 'error';
125
+ message: string;
126
+ sessionId?: string;
127
+ }
128
+
129
+ export interface SessionHostRequestTrace {
130
+ timestamp: number;
131
+ requestId: string;
132
+ type: string;
133
+ sessionId?: string;
134
+ clientId?: string;
135
+ success: boolean;
136
+ durationMs: number;
137
+ error?: string;
138
+ }
139
+
140
+ export interface SessionHostRuntimeTransition {
141
+ timestamp: number;
142
+ sessionId: string;
143
+ action: string;
144
+ lifecycle?: string;
145
+ detail?: string;
146
+ success?: boolean;
147
+ error?: string;
148
+ }
149
+
150
+ export interface SessionHostDiagnosticsSnapshot {
151
+ hostStartedAt: number;
152
+ endpoint: string;
153
+ runtimeCount: number;
154
+ sessions?: SessionHostRecord[];
155
+ recentLogs: SessionHostLogEntry[];
156
+ recentRequests: SessionHostRequestTrace[];
157
+ recentTransitions: SessionHostRuntimeTransition[];
158
+ }
159
+
160
+ export type TransportTopic = 'session.chat_tail' | 'machine.runtime' | 'session_host.diagnostics' | 'session.modal' | 'daemon.metadata';
161
+
162
+ export interface SessionChatTailSubscriptionParams extends ReadChatCursor {
163
+ targetSessionId: string;
164
+ historySessionId?: string;
165
+ }
166
+
167
+ export interface MachineRuntimeSubscriptionParams {
168
+ intervalMs?: number;
169
+ }
170
+
171
+ export interface SessionModalSubscriptionParams {
172
+ targetSessionId: string;
173
+ }
174
+
175
+ export interface DaemonMetadataSubscriptionParams {
176
+ includeSessions?: boolean;
177
+ }
178
+
179
+ export interface SessionHostDiagnosticsSubscriptionParams {
180
+ includeSessions?: boolean;
181
+ limit?: number;
182
+ intervalMs?: number;
183
+ }
184
+
185
+ export interface SessionChatTailUpdate extends ReadChatSyncResult {
186
+ topic: 'session.chat_tail';
187
+ key: string;
188
+ sessionId: string;
189
+ historySessionId?: string;
190
+ seq: number;
191
+ timestamp: number;
192
+ }
193
+
194
+ export interface MachineRuntimeUpdate {
195
+ topic: 'machine.runtime';
196
+ key: string;
197
+ machine: MachineInfo;
198
+ seq: number;
199
+ timestamp: number;
200
+ }
201
+
202
+ export interface SessionHostDiagnosticsUpdate {
203
+ topic: 'session_host.diagnostics';
204
+ key: string;
205
+ diagnostics: SessionHostDiagnosticsSnapshot;
206
+ seq: number;
207
+ timestamp: number;
208
+ }
209
+
210
+ export interface SessionModalUpdate {
211
+ topic: 'session.modal';
212
+ key: string;
213
+ sessionId: string;
214
+ status: string;
215
+ title?: string;
216
+ modalMessage?: string;
217
+ modalButtons?: string[];
218
+ seq: number;
219
+ timestamp: number;
220
+ }
221
+
222
+ export interface DaemonMetadataUpdate {
223
+ topic: 'daemon.metadata';
224
+ key: string;
225
+ daemonId: string;
226
+ status: StatusReportPayload;
227
+ userName?: string;
228
+ seq: number;
229
+ timestamp: number;
230
+ }
231
+
232
+ export interface TopicUpdateEnvelopeMap {
233
+ 'session.chat_tail': SessionChatTailUpdate;
234
+ 'machine.runtime': MachineRuntimeUpdate;
235
+ 'session_host.diagnostics': SessionHostDiagnosticsUpdate;
236
+ 'session.modal': SessionModalUpdate;
237
+ 'daemon.metadata': DaemonMetadataUpdate;
238
+ }
239
+
240
+ export type TopicUpdateEnvelope = TopicUpdateEnvelopeMap[TransportTopic];
241
+
242
+ export interface SubscribeRequestMap {
243
+ 'session.chat_tail': SessionChatTailSubscriptionParams;
244
+ 'machine.runtime': MachineRuntimeSubscriptionParams;
245
+ 'session_host.diagnostics': SessionHostDiagnosticsSubscriptionParams;
246
+ 'session.modal': SessionModalSubscriptionParams;
247
+ 'daemon.metadata': DaemonMetadataSubscriptionParams;
248
+ }
249
+
250
+ export type SubscribeRequest =
251
+ { [K in TransportTopic]: { type: 'subscribe'; topic: K; key: string; params: SubscribeRequestMap[K] } }[TransportTopic];
252
+
253
+ export type UnsubscribeRequest =
254
+ { [K in TransportTopic]: { type: 'unsubscribe'; topic: K; key: string } }[TransportTopic];
255
+
256
+ export type StandaloneWsStatusPayload = StatusReportPayload;
257
+
72
258
  export type SessionTransport = 'cdp-page' | 'cdp-webview' | 'pty' | 'acp';
73
259
 
74
260
  export type SessionKind = 'workspace' | 'agent';
@@ -93,13 +279,13 @@ export interface SessionEntry {
93
279
  id: string;
94
280
  parentId: string | null;
95
281
  providerType: string;
96
- providerName: string;
282
+ providerName?: string;
97
283
  providerSessionId?: string;
98
284
  kind: SessionKind;
99
285
  transport: SessionTransport;
100
286
  status: SessionStatus;
101
287
  title: string;
102
- workspace: string | null;
288
+ workspace?: string | null;
103
289
  runtimeKey?: string;
104
290
  runtimeDisplayName?: string;
105
291
  runtimeWorkspaceLabel?: string;
@@ -109,7 +295,7 @@ export interface SessionEntry {
109
295
  runtimeAttachedClients?: RuntimeAttachedClient[];
110
296
  resume?: ProviderResumeCapability;
111
297
  activeChat: _ActiveChatData | null;
112
- capabilities: SessionCapability[];
298
+ capabilities?: SessionCapability[];
113
299
  cdpConnected?: boolean;
114
300
  currentModel?: string;
115
301
  currentPlan?: string;
@@ -215,15 +401,15 @@ export interface ProviderControlSchema {
215
401
  export interface MachineInfo {
216
402
  hostname: string;
217
403
  platform: string;
218
- arch: string;
219
- cpus: number;
220
- totalMem: number;
221
- freeMem: number;
404
+ arch?: string;
405
+ cpus?: number;
406
+ totalMem?: number;
407
+ freeMem?: number;
222
408
  /** macOS: reclaimable-inclusive; prefer for UI used% */
223
409
  availableMem?: number;
224
- loadavg: number[];
225
- uptime: number;
226
- release: string;
410
+ loadavg?: number[];
411
+ uptime?: number;
412
+ release?: string;
227
413
  }
228
414
 
229
415
  /** Detected IDE on a machine */
@@ -271,24 +457,101 @@ export interface CompactDaemonEntry {
271
457
  sessions?: CompactSessionEntry[];
272
458
  }
273
459
 
460
+ /** Minimal daemon list payload returned by the cloud server REST API. */
461
+ export interface CloudDaemonSummaryEntry {
462
+ id: string;
463
+ type?: string;
464
+ machineId?: string;
465
+ platform?: string;
466
+ hostname?: string;
467
+ nickname?: string;
468
+ p2p?: StatusReportPayload['p2p'];
469
+ cdpConnected?: boolean;
470
+ timestamp?: number;
471
+ version?: string;
472
+ serverVersion?: string;
473
+ versionMismatch?: boolean;
474
+ terminalBackend?: TerminalBackendStatus;
475
+ }
476
+
477
+ /** Minimal daemon bootstrap payload used by dashboard WS to initiate P2P. */
478
+ export interface DashboardBootstrapDaemonEntry {
479
+ id: string;
480
+ p2p?: StatusReportPayload['p2p'];
481
+ timestamp?: number;
482
+ }
483
+
484
+ export type DaemonStatusEventName =
485
+ | 'agent:generating_started'
486
+ | 'agent:waiting_approval'
487
+ | 'agent:generating_completed'
488
+ | 'agent:stopped'
489
+ | 'monitor:long_generating';
490
+
491
+ /** Minimal daemon-originated event payload relayed through the server. */
492
+ export interface DaemonStatusEventPayload {
493
+ event: DaemonStatusEventName;
494
+ timestamp: number;
495
+ targetSessionId?: string;
496
+ providerType?: string;
497
+ duration?: number;
498
+ elapsedSec?: number;
499
+ modalMessage?: string;
500
+ modalButtons?: string[];
501
+ }
502
+
503
+ export type DashboardStatusEventName =
504
+ | DaemonStatusEventName
505
+ | 'daemon:disconnect'
506
+ | 'team:session_viewed'
507
+ | 'team:view_request'
508
+ | 'team:view_request_approved'
509
+ | 'team:view_request_rejected';
510
+
511
+ /** Sanitized event payload delivered to dashboard clients. */
512
+ export interface DashboardStatusEventPayload {
513
+ event: DashboardStatusEventName;
514
+ timestamp: number;
515
+ daemonId?: string;
516
+ providerType?: string;
517
+ targetSessionId?: string;
518
+ duration?: number;
519
+ elapsedSec?: number;
520
+ modalMessage?: string;
521
+ modalButtons?: string[];
522
+ requestId?: string;
523
+ requesterName?: string;
524
+ targetName?: string;
525
+ orgId?: string;
526
+ permission?: string;
527
+ shareUrl?: string;
528
+ shareToken?: string;
529
+ viewerName?: string;
530
+ }
531
+
532
+ /** Minimal daemon->cloud status payload used for routing, fallback, and server APIs. */
533
+ export interface CloudStatusReportPayload {
534
+ sessions: CompactSessionEntry[];
535
+ p2p?: StatusReportPayload['p2p'];
536
+ timestamp: number;
537
+ }
538
+
274
539
  // ─── Status Report Payload (daemon → server) ────────────────────────
275
540
  // Full payload shape sent via WebSocket status_report
276
541
 
277
542
  export interface StatusReportPayload {
278
543
  /** Unique daemon instance identifier */
279
544
  instanceId: string;
280
- /** Daemon version */
281
- version: string;
282
- /** Daemon mode flag */
283
- daemonMode: boolean;
545
+ /** Daemon version (metadata/full snapshots only) */
546
+ version?: string;
284
547
  /** Machine info */
285
548
  machine: MachineInfo;
286
549
  /** Machine nickname (user-set) */
287
550
  machineNickname?: string | null;
288
551
  /** Timestamp */
289
552
  timestamp: number;
290
- /** Detected IDEs on this machine */
291
- detectedIdes: DetectedIdeInfo[];
553
+ /** Detected IDEs on this machine (metadata snapshot only) */
554
+ detectedIdes?: DetectedIdeInfo[];
292
555
  /** P2P state */
293
556
  p2p?: { available: boolean; state: string; peers: number; screenshotActive?: boolean };
294
557
  /** Canonical daemon runtime sessions */