@adhdev/daemon-core 0.8.33 → 0.8.35
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 +127 -102
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +127 -102
- package/dist/index.mjs.map +1 -1
- package/dist/shared-types.d.ts +38 -0
- package/dist/status/reporter.d.ts +3 -0
- package/node_modules/@adhdev/session-host-core/package.json +1 -1
- package/package.json +1 -1
- package/src/agent-stream/forward.d.ts +8 -0
- package/src/agent-stream/index.d.ts +6 -0
- package/src/agent-stream/manager.d.ts +60 -0
- package/src/agent-stream/poller.d.ts +41 -0
- package/src/agent-stream/provider-adapter.d.ts +36 -0
- package/src/agent-stream/types.d.ts +68 -0
- package/src/boot/daemon-lifecycle.d.ts +100 -0
- package/src/cdp/devtools.d.ts +51 -0
- package/src/cdp/initializer.d.ts +50 -0
- package/src/cdp/manager.d.ts +147 -0
- package/src/cdp/scanner.d.ts +58 -0
- package/src/cdp/setup.d.ts +58 -0
- package/src/cli-adapter-types.d.ts +57 -0
- package/src/cli-adapters/provider-cli-adapter.d.ts +177 -0
- package/src/cli-adapters/provider-cli-adapter.ts +115 -91
- package/src/cli-adapters/provider-cli-config.d.ts +30 -0
- package/src/cli-adapters/provider-cli-parse.d.ts +42 -0
- package/src/cli-adapters/provider-cli-runtime.d.ts +29 -0
- package/src/cli-adapters/provider-cli-shared.d.ts +158 -0
- package/src/cli-adapters/pty-transport.d.ts +48 -0
- package/src/cli-adapters/session-host-transport.d.ts +20 -0
- package/src/cli-adapters/spawn-env.d.ts +8 -0
- package/src/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +16 -0
- package/src/cli-adapters/terminal-backends/types.d.ts +18 -0
- package/src/cli-adapters/terminal-backends/xterm-backend.d.ts +17 -0
- package/src/cli-adapters/terminal-screen.d.ts +33 -0
- package/src/commands/cdp-commands.d.ts +15 -0
- package/src/commands/chat-commands.d.ts +15 -0
- package/src/commands/cli-manager.d.ts +94 -0
- package/src/commands/handler.d.ts +103 -0
- package/src/commands/router.d.ts +98 -0
- package/src/commands/stream-commands.d.ts +14 -0
- package/src/commands/upgrade-helper.d.ts +10 -0
- package/src/commands/workspace-commands.d.ts +11 -0
- package/src/config/chat-history.d.ts +99 -0
- package/src/config/config.d.ts +14 -0
- package/src/config/recent-activity.d.ts +29 -0
- package/src/config/saved-sessions.d.ts +22 -0
- package/src/config/state-store.d.ts +32 -0
- package/src/config/workspaces.d.ts +0 -1
- package/src/daemon/dev-auto-implement.d.ts +43 -0
- package/src/daemon/dev-cdp-handlers.d.ts +22 -0
- package/src/daemon/dev-cli-debug.d.ts +106 -0
- package/src/daemon/dev-server-types.d.ts +43 -0
- package/src/daemon/dev-server.d.ts +140 -0
- package/src/daemon/scaffold-template.d.ts +32 -0
- package/src/daemon-core.d.ts +36 -0
- package/src/detection/cli-detector.d.ts +31 -0
- package/src/detection/ide-detector.d.ts +35 -0
- package/src/index.d.ts +83 -0
- package/src/index.ts +2 -0
- package/src/installer.d.ts +50 -0
- package/src/ipc-protocol.d.ts +111 -0
- package/src/launch.d.ts +46 -0
- package/src/logging/command-log.d.ts +31 -0
- package/src/logging/logger.d.ts +89 -0
- package/src/providers/acp-provider-instance.d.ts +102 -0
- package/src/providers/approval-utils.d.ts +7 -0
- package/src/providers/cli-provider-instance.d.ts +86 -0
- package/src/providers/contracts.d.ts +193 -1
- package/src/providers/control-effects.d.ts +4 -0
- package/src/providers/extension-provider-instance.d.ts +61 -0
- package/src/providers/ide-provider-instance.d.ts +70 -0
- package/src/providers/provider-instance-manager.d.ts +84 -0
- package/src/providers/provider-instance.d.ts +7 -1
- package/src/providers/provider-loader.d.ts +299 -0
- package/src/providers/status-monitor.d.ts +48 -0
- package/src/providers/version-archive.d.ts +52 -0
- package/src/session-host/runtime-support.d.ts +8 -0
- package/src/sessions/reconcile.d.ts +22 -0
- package/src/sessions/registry.d.ts +24 -0
- package/src/shared-types-extra.d.ts +29 -0
- package/src/shared-types.d.ts +79 -22
- package/src/shared-types.ts +40 -0
- package/src/status/builders.d.ts +33 -0
- package/src/status/reporter.d.ts +69 -0
- package/src/status/reporter.ts +16 -13
- package/src/status/snapshot.d.ts +58 -0
- package/src/system/host-memory.d.ts +19 -0
- package/src/types.d.ts +3 -7
package/src/shared-types.d.ts
CHANGED
|
@@ -36,6 +36,8 @@ export interface AgentSessionStream {
|
|
|
36
36
|
export type SessionTransport = 'cdp-page' | 'cdp-webview' | 'pty' | 'acp';
|
|
37
37
|
export type SessionKind = 'workspace' | 'agent';
|
|
38
38
|
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';
|
|
39
|
+
import type { RuntimeWriteOwner, RuntimeAttachedClient, SessionStatus } from './shared-types-extra.js';
|
|
40
|
+
export type { RuntimeWriteOwner, RuntimeAttachedClient, SessionStatus } from './shared-types-extra.js';
|
|
39
41
|
export interface SessionEntry {
|
|
40
42
|
id: string;
|
|
41
43
|
parentId: string | null;
|
|
@@ -44,21 +46,16 @@ export interface SessionEntry {
|
|
|
44
46
|
providerSessionId?: string;
|
|
45
47
|
kind: SessionKind;
|
|
46
48
|
transport: SessionTransport;
|
|
47
|
-
status:
|
|
49
|
+
status: SessionStatus;
|
|
48
50
|
title: string;
|
|
49
51
|
workspace: string | null;
|
|
50
52
|
runtimeKey?: string;
|
|
51
53
|
runtimeDisplayName?: string;
|
|
52
54
|
runtimeWorkspaceLabel?: string;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
runtimeAttachedClients?: {
|
|
58
|
-
clientId: string;
|
|
59
|
-
type: 'daemon' | 'web' | 'local-terminal';
|
|
60
|
-
readOnly: boolean;
|
|
61
|
-
}[];
|
|
55
|
+
/** CLI only: active presentation mode */
|
|
56
|
+
mode?: 'terminal' | 'chat';
|
|
57
|
+
runtimeWriteOwner?: RuntimeWriteOwner | null;
|
|
58
|
+
runtimeAttachedClients?: RuntimeAttachedClient[];
|
|
62
59
|
resume?: ProviderResumeCapability;
|
|
63
60
|
activeChat: _ActiveChatData | null;
|
|
64
61
|
capabilities: SessionCapability[];
|
|
@@ -68,10 +65,36 @@ export interface SessionEntry {
|
|
|
68
65
|
currentAutoApprove?: string;
|
|
69
66
|
acpConfigOptions?: AcpConfigOption[];
|
|
70
67
|
acpModes?: AcpMode[];
|
|
68
|
+
/** Dynamic control current values (generic key-value) */
|
|
71
69
|
controlValues?: Record<string, string | number | boolean>;
|
|
70
|
+
/** Provider-declared controls schema (transmitted once, cached by frontend) */
|
|
72
71
|
providerControls?: ProviderControlSchema[];
|
|
73
72
|
errorMessage?: string;
|
|
74
73
|
errorReason?: _ProviderErrorReason;
|
|
74
|
+
lastUpdated?: number;
|
|
75
|
+
unread?: boolean;
|
|
76
|
+
lastSeenAt?: number;
|
|
77
|
+
inboxBucket?: RecentSessionBucket;
|
|
78
|
+
surfaceHidden?: boolean;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Compact session metadata stored in UserSessionDO and reused by server-side
|
|
82
|
+
* status/convenience APIs. This intentionally excludes rich UI-only fields.
|
|
83
|
+
*/
|
|
84
|
+
export interface CompactSessionEntry {
|
|
85
|
+
id: string;
|
|
86
|
+
parentId: string | null;
|
|
87
|
+
providerType: string;
|
|
88
|
+
providerName: string;
|
|
89
|
+
kind: SessionKind;
|
|
90
|
+
transport: SessionTransport;
|
|
91
|
+
status: SessionStatus;
|
|
92
|
+
title: string;
|
|
93
|
+
workspace: string | null;
|
|
94
|
+
cdpConnected?: boolean;
|
|
95
|
+
currentModel?: string;
|
|
96
|
+
currentPlan?: string;
|
|
97
|
+
currentAutoApprove?: string;
|
|
75
98
|
}
|
|
76
99
|
/** Available provider information */
|
|
77
100
|
export interface AvailableProviderInfo {
|
|
@@ -80,6 +103,8 @@ export interface AvailableProviderInfo {
|
|
|
80
103
|
category: 'ide' | 'extension' | 'cli' | 'acp';
|
|
81
104
|
displayName: string;
|
|
82
105
|
icon: string;
|
|
106
|
+
installed?: boolean;
|
|
107
|
+
detectedPath?: string | null;
|
|
83
108
|
}
|
|
84
109
|
/** ACP config option (model/mode/thought_level selection) */
|
|
85
110
|
export interface AcpConfigOption {
|
|
@@ -99,24 +124,39 @@ export interface AcpMode {
|
|
|
99
124
|
name: string;
|
|
100
125
|
description?: string;
|
|
101
126
|
}
|
|
102
|
-
/** Provider control schema
|
|
127
|
+
/** Provider control schema transmitted to frontend */
|
|
103
128
|
export interface ProviderControlSchema {
|
|
104
129
|
id: string;
|
|
105
|
-
type: 'select' | 'toggle' | 'cycle' | 'slider' | 'action';
|
|
130
|
+
type: 'select' | 'toggle' | 'cycle' | 'slider' | 'action' | 'display';
|
|
106
131
|
label: string;
|
|
107
132
|
icon?: string;
|
|
108
133
|
placement: 'bar' | 'header' | 'menu';
|
|
109
|
-
|
|
134
|
+
/** Static options (for select/cycle) */
|
|
135
|
+
options?: {
|
|
136
|
+
value: string;
|
|
137
|
+
label: string;
|
|
138
|
+
description?: string;
|
|
139
|
+
group?: string;
|
|
140
|
+
}[];
|
|
141
|
+
/** Dynamic options — frontend should call listScript to load */
|
|
110
142
|
dynamic?: boolean;
|
|
143
|
+
/** Script name to list options */
|
|
111
144
|
listScript?: string;
|
|
145
|
+
/** Script name to change value (value-based controls) */
|
|
112
146
|
setScript?: string;
|
|
147
|
+
/** Field name in readChat result for current value */
|
|
113
148
|
readFrom?: string;
|
|
149
|
+
/** Default value */
|
|
114
150
|
defaultValue?: string | number | boolean;
|
|
151
|
+
/** Script name to invoke (action type) */
|
|
115
152
|
invokeScript?: string;
|
|
153
|
+
/** How to display action result */
|
|
116
154
|
resultDisplay?: 'toast' | 'inline' | 'none';
|
|
155
|
+
/** Slider range */
|
|
117
156
|
min?: number;
|
|
118
157
|
max?: number;
|
|
119
158
|
step?: number;
|
|
159
|
+
/** Sort order */
|
|
120
160
|
order?: number;
|
|
121
161
|
}
|
|
122
162
|
/** Machine hardware/OS info (reported by daemon, displayed by web) */
|
|
@@ -141,13 +181,9 @@ export interface DetectedIdeInfo {
|
|
|
141
181
|
running: boolean;
|
|
142
182
|
path?: string;
|
|
143
183
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
lastUsedAt: number;
|
|
148
|
-
kind?: string;
|
|
149
|
-
agentType?: string;
|
|
150
|
-
}
|
|
184
|
+
export type { RecentSessionBucket, TerminalBackendStatus } from './shared-types-extra.js';
|
|
185
|
+
import type { RecentSessionBucket } from './shared-types-extra.js';
|
|
186
|
+
import type { TerminalBackendStatus } from './shared-types-extra.js';
|
|
151
187
|
export interface RecentLaunchEntry {
|
|
152
188
|
id: string;
|
|
153
189
|
providerType: string;
|
|
@@ -159,8 +195,27 @@ export interface RecentLaunchEntry {
|
|
|
159
195
|
currentModel?: string;
|
|
160
196
|
lastLaunchedAt: number;
|
|
161
197
|
}
|
|
198
|
+
/** Compact machine payload broadcast by UserSessionDO to cloud dashboards. */
|
|
199
|
+
export interface CompactDaemonEntry {
|
|
200
|
+
id: string;
|
|
201
|
+
type?: string;
|
|
202
|
+
machineId?: string;
|
|
203
|
+
platform?: string;
|
|
204
|
+
hostname?: string;
|
|
205
|
+
nickname?: string;
|
|
206
|
+
p2p?: StatusReportPayload['p2p'];
|
|
207
|
+
cdpConnected?: boolean;
|
|
208
|
+
timestamp?: number;
|
|
209
|
+
version?: string;
|
|
210
|
+
serverVersion?: string;
|
|
211
|
+
versionMismatch?: boolean;
|
|
212
|
+
terminalBackend?: TerminalBackendStatus;
|
|
213
|
+
detectedIdes?: DetectedIdeInfo[];
|
|
214
|
+
availableProviders?: AvailableProviderInfo[];
|
|
215
|
+
sessions?: CompactSessionEntry[];
|
|
216
|
+
}
|
|
162
217
|
export interface StatusReportPayload {
|
|
163
|
-
/**
|
|
218
|
+
/** Unique daemon instance identifier */
|
|
164
219
|
instanceId: string;
|
|
165
220
|
/** Daemon version */
|
|
166
221
|
version: string;
|
|
@@ -188,6 +243,8 @@ export interface StatusReportPayload {
|
|
|
188
243
|
defaultWorkspaceId?: string | null;
|
|
189
244
|
defaultWorkspacePath?: string | null;
|
|
190
245
|
terminalSizingMode?: 'measured' | 'fit';
|
|
191
|
-
workspaceActivity?: WorkspaceActivity[];
|
|
192
246
|
recentLaunches?: RecentLaunchEntry[];
|
|
247
|
+
terminalBackend?: TerminalBackendStatus;
|
|
248
|
+
/** Available providers (present in StatusSnapshot, optional in raw payload) */
|
|
249
|
+
availableProviders?: AvailableProviderInfo[];
|
|
193
250
|
}
|
package/src/shared-types.ts
CHANGED
|
@@ -129,6 +129,26 @@ export interface SessionEntry {
|
|
|
129
129
|
surfaceHidden?: boolean;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
+
/**
|
|
133
|
+
* Compact session metadata stored in UserSessionDO and reused by server-side
|
|
134
|
+
* status/convenience APIs. This intentionally excludes rich UI-only fields.
|
|
135
|
+
*/
|
|
136
|
+
export interface CompactSessionEntry {
|
|
137
|
+
id: string;
|
|
138
|
+
parentId: string | null;
|
|
139
|
+
providerType: string;
|
|
140
|
+
providerName: string;
|
|
141
|
+
kind: SessionKind;
|
|
142
|
+
transport: SessionTransport;
|
|
143
|
+
status: SessionStatus;
|
|
144
|
+
title: string;
|
|
145
|
+
workspace: string | null;
|
|
146
|
+
cdpConnected?: boolean;
|
|
147
|
+
currentModel?: string;
|
|
148
|
+
currentPlan?: string;
|
|
149
|
+
currentAutoApprove?: string;
|
|
150
|
+
}
|
|
151
|
+
|
|
132
152
|
/** Available provider information */
|
|
133
153
|
export interface AvailableProviderInfo {
|
|
134
154
|
type: string;
|
|
@@ -231,6 +251,26 @@ export interface RecentLaunchEntry {
|
|
|
231
251
|
lastLaunchedAt: number;
|
|
232
252
|
}
|
|
233
253
|
|
|
254
|
+
/** Compact machine payload broadcast by UserSessionDO to cloud dashboards. */
|
|
255
|
+
export interface CompactDaemonEntry {
|
|
256
|
+
id: string;
|
|
257
|
+
type?: string;
|
|
258
|
+
machineId?: string;
|
|
259
|
+
platform?: string;
|
|
260
|
+
hostname?: string;
|
|
261
|
+
nickname?: string;
|
|
262
|
+
p2p?: StatusReportPayload['p2p'];
|
|
263
|
+
cdpConnected?: boolean;
|
|
264
|
+
timestamp?: number;
|
|
265
|
+
version?: string;
|
|
266
|
+
serverVersion?: string;
|
|
267
|
+
versionMismatch?: boolean;
|
|
268
|
+
terminalBackend?: TerminalBackendStatus;
|
|
269
|
+
detectedIdes?: DetectedIdeInfo[];
|
|
270
|
+
availableProviders?: AvailableProviderInfo[];
|
|
271
|
+
sessions?: CompactSessionEntry[];
|
|
272
|
+
}
|
|
273
|
+
|
|
234
274
|
// ─── Status Report Payload (daemon → server) ────────────────────────
|
|
235
275
|
// Full payload shape sent via WebSocket status_report
|
|
236
276
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Status Builders — shared conversion functions for ProviderState → ManagedEntry
|
|
3
|
+
*
|
|
4
|
+
* Used by:
|
|
5
|
+
* - daemon-standalone (StandaloneServer.getStatus)
|
|
6
|
+
* - DaemonStatusReporter
|
|
7
|
+
*
|
|
8
|
+
* Consolidates ProviderState→ManagedEntry mapping logic.
|
|
9
|
+
*/
|
|
10
|
+
import type { DaemonCdpManager } from '../cdp/manager.js';
|
|
11
|
+
import type { SessionEntry } from '../shared-types.js';
|
|
12
|
+
import type { ProviderState } from '../providers/provider-instance.js';
|
|
13
|
+
/**
|
|
14
|
+
* Find a CDP manager by key, with prefix matching for multi-window support.
|
|
15
|
+
*
|
|
16
|
+
* Lookup order:
|
|
17
|
+
* 1. Exact match: cdpManagers.get(key)
|
|
18
|
+
* 2. Prefix match: key starts with `${ideType}_` (multi-window: "cursor_remote_vs")
|
|
19
|
+
* 3. null
|
|
20
|
+
*
|
|
21
|
+
* This replaces raw `cdpManagers.get(ideType)` calls that broke when
|
|
22
|
+
* multi-window keys like "cursor_remote_vs" were used.
|
|
23
|
+
*/
|
|
24
|
+
export declare function findCdpManager(cdpManagers: Map<string, DaemonCdpManager>, key: string): DaemonCdpManager | null;
|
|
25
|
+
/**
|
|
26
|
+
* Check if any CDP manager matches the given key (exact or prefix).
|
|
27
|
+
*/
|
|
28
|
+
export declare function hasCdpManager(cdpManagers: Map<string, DaemonCdpManager>, key: string): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Check if any CDP manager matching the key is connected.
|
|
31
|
+
*/
|
|
32
|
+
export declare function isCdpConnected(cdpManagers: Map<string, DaemonCdpManager>, key: string): boolean;
|
|
33
|
+
export declare function buildSessionEntries(allStates: ProviderState[], cdpManagers: Map<string, DaemonCdpManager>): SessionEntry[];
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DaemonStatusReporter — status collect & transmit (StatusReport / P2P / StatusEvent)
|
|
3
|
+
*
|
|
4
|
+
* Collect status from ProviderInstanceManager → assemble payload → transmit
|
|
5
|
+
* Each Instance manages its own status/transition. This module only assembles + transmits.
|
|
6
|
+
*/
|
|
7
|
+
import type { DaemonCdpManager } from '../cdp/manager.js';
|
|
8
|
+
import type { ProviderState } from '../providers/provider-instance.js';
|
|
9
|
+
export interface StatusReporterDeps {
|
|
10
|
+
serverConn: {
|
|
11
|
+
isConnected(): boolean;
|
|
12
|
+
sendMessage(type: string, data: any): void;
|
|
13
|
+
getUserPlan(): string;
|
|
14
|
+
} | null;
|
|
15
|
+
cdpManagers: Map<string, DaemonCdpManager>;
|
|
16
|
+
p2p: {
|
|
17
|
+
isConnected: boolean;
|
|
18
|
+
isAvailable: boolean;
|
|
19
|
+
connectionState: string;
|
|
20
|
+
connectedPeerCount: number;
|
|
21
|
+
screenshotActive: boolean;
|
|
22
|
+
sendStatus(data: any): void;
|
|
23
|
+
} | null;
|
|
24
|
+
providerLoader: {
|
|
25
|
+
resolve(type: string): any;
|
|
26
|
+
getAll(): any[];
|
|
27
|
+
};
|
|
28
|
+
detectedIdes: any[];
|
|
29
|
+
instanceId: string;
|
|
30
|
+
daemonVersion?: string;
|
|
31
|
+
instanceManager: {
|
|
32
|
+
collectAllStates(): ProviderState[];
|
|
33
|
+
collectStatesByCategory(cat: string): ProviderState[];
|
|
34
|
+
};
|
|
35
|
+
getScreenshotUsage?: () => {
|
|
36
|
+
dailyUsedMinutes: number;
|
|
37
|
+
dailyBudgetMinutes: number;
|
|
38
|
+
budgetExhausted: boolean;
|
|
39
|
+
} | null;
|
|
40
|
+
}
|
|
41
|
+
export declare class DaemonStatusReporter {
|
|
42
|
+
private deps;
|
|
43
|
+
private log;
|
|
44
|
+
private lastStatusSentAt;
|
|
45
|
+
private statusPendingThrottle;
|
|
46
|
+
private lastP2PStatusHash;
|
|
47
|
+
private lastStatusSummary;
|
|
48
|
+
private statusTimer;
|
|
49
|
+
private p2pTimer;
|
|
50
|
+
constructor(deps: StatusReporterDeps, opts?: {
|
|
51
|
+
logFn?: (msg: string) => void;
|
|
52
|
+
});
|
|
53
|
+
startReporting(): void;
|
|
54
|
+
stopReporting(): void;
|
|
55
|
+
onStatusChange(): void;
|
|
56
|
+
throttledReport(): void;
|
|
57
|
+
emitStatusEvent(event: Record<string, unknown>): void;
|
|
58
|
+
removeAgentTracking(_key: string): void;
|
|
59
|
+
updateAgentStreams(_ideType: string, _streams: any[]): void;
|
|
60
|
+
/** Reset P2P dedup hash — forces next send to transmit even if content unchanged */
|
|
61
|
+
resetP2PHash(): void;
|
|
62
|
+
private ts;
|
|
63
|
+
private summarizeLargePayloadSessions;
|
|
64
|
+
sendUnifiedStatusReport(opts?: {
|
|
65
|
+
p2pOnly?: boolean;
|
|
66
|
+
}): Promise<void>;
|
|
67
|
+
private sendP2PPayload;
|
|
68
|
+
private simpleHash;
|
|
69
|
+
}
|
package/src/status/reporter.ts
CHANGED
|
@@ -38,6 +38,7 @@ export class DaemonStatusReporter {
|
|
|
38
38
|
private lastStatusSentAt = 0;
|
|
39
39
|
private statusPendingThrottle = false;
|
|
40
40
|
private lastP2PStatusHash = '';
|
|
41
|
+
private lastServerStatusHash = '';
|
|
41
42
|
private lastStatusSummary = '';
|
|
42
43
|
|
|
43
44
|
private statusTimer: NodeJS.Timeout | null = null;
|
|
@@ -52,12 +53,12 @@ export class DaemonStatusReporter {
|
|
|
52
53
|
|
|
53
54
|
startReporting(): void {
|
|
54
55
|
setTimeout(() => {
|
|
55
|
-
this.sendUnifiedStatusReport().catch(e => LOG.warn('Status', `Initial report failed: ${e?.message}`));
|
|
56
|
+
this.sendUnifiedStatusReport({ forceServer: true, reason: 'initial' }).catch(e => LOG.warn('Status', `Initial report failed: ${e?.message}`));
|
|
56
57
|
}, 2000);
|
|
57
58
|
|
|
58
59
|
const scheduleServerReport = () => {
|
|
59
60
|
this.statusTimer = setTimeout(() => {
|
|
60
|
-
this.sendUnifiedStatusReport().catch(e => LOG.warn('Status', `Periodic report failed: ${e?.message}`));
|
|
61
|
+
this.sendUnifiedStatusReport({ forceServer: true, reason: 'periodic' }).catch(e => LOG.warn('Status', `Periodic report failed: ${e?.message}`));
|
|
61
62
|
scheduleServerReport();
|
|
62
63
|
}, 30_000);
|
|
63
64
|
};
|
|
@@ -135,7 +136,7 @@ export class DaemonStatusReporter {
|
|
|
135
136
|
.join(', ');
|
|
136
137
|
}
|
|
137
138
|
|
|
138
|
-
async sendUnifiedStatusReport(opts?: { p2pOnly?: boolean }): Promise<void> {
|
|
139
|
+
async sendUnifiedStatusReport(opts?: { p2pOnly?: boolean; forceServer?: boolean; reason?: string }): Promise<void> {
|
|
139
140
|
const { serverConn, p2p } = this.deps;
|
|
140
141
|
if (!serverConn?.isConnected()) return;
|
|
141
142
|
this.lastStatusSentAt = Date.now();
|
|
@@ -216,6 +217,8 @@ export class DaemonStatusReporter {
|
|
|
216
217
|
|
|
217
218
|
// ═══ Server transmit (minimal routing meta only) ═══
|
|
218
219
|
if (opts?.p2pOnly) return;
|
|
220
|
+
// Server relay only needs compact session metadata for routing, compact status,
|
|
221
|
+
// initial_state fallback, and lightweight API/session inspection.
|
|
219
222
|
const wsPayload = {
|
|
220
223
|
daemonMode: true,
|
|
221
224
|
sessions: sessions.map((session) => ({
|
|
@@ -232,23 +235,23 @@ export class DaemonStatusReporter {
|
|
|
232
235
|
currentModel: session.currentModel,
|
|
233
236
|
currentPlan: session.currentPlan,
|
|
234
237
|
currentAutoApprove: session.currentAutoApprove,
|
|
235
|
-
lastUpdated: session.lastUpdated,
|
|
236
|
-
unread: session.unread,
|
|
237
|
-
lastSeenAt: session.lastSeenAt,
|
|
238
|
-
inboxBucket: session.inboxBucket,
|
|
239
|
-
surfaceHidden: session.surfaceHidden,
|
|
240
|
-
controlValues: session.controlValues,
|
|
241
|
-
providerControls: session.providerControls,
|
|
242
|
-
acpConfigOptions: session.acpConfigOptions,
|
|
243
|
-
acpModes: session.acpModes,
|
|
244
238
|
})),
|
|
245
239
|
p2p: payload.p2p,
|
|
246
240
|
timestamp: now,
|
|
247
241
|
detectedIdes: payload.detectedIdes,
|
|
248
242
|
availableProviders: payload.availableProviders,
|
|
249
243
|
};
|
|
244
|
+
const wsHash = this.simpleHash(JSON.stringify({
|
|
245
|
+
...wsPayload,
|
|
246
|
+
timestamp: undefined,
|
|
247
|
+
}));
|
|
248
|
+
if (!opts?.forceServer && wsHash === this.lastServerStatusHash) {
|
|
249
|
+
LOG.debug('Server', `skip duplicate status_report${opts?.reason ? ` (${opts.reason})` : ''}`);
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
this.lastServerStatusHash = wsHash;
|
|
250
253
|
serverConn.sendMessage('status_report', wsPayload);
|
|
251
|
-
LOG.debug('Server', `sent status_report (${JSON.stringify(wsPayload).length} bytes)`);
|
|
254
|
+
LOG.debug('Server', `sent status_report (${JSON.stringify(wsPayload).length} bytes)${opts?.reason ? ` [${opts.reason}]` : ''}`);
|
|
252
255
|
}
|
|
253
256
|
|
|
254
257
|
// ─── P2P ─────────────────────────────────────────
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared status snapshot builders.
|
|
3
|
+
*
|
|
4
|
+
* Used by:
|
|
5
|
+
* - DaemonStatusReporter (cloud)
|
|
6
|
+
* - daemon-standalone HTTP/WS status responses
|
|
7
|
+
*/
|
|
8
|
+
import type { DaemonCdpManager } from '../cdp/manager.js';
|
|
9
|
+
import type { ProviderState } from '../providers/provider-instance.js';
|
|
10
|
+
import type { AvailableProviderInfo, StatusReportPayload } from '../shared-types.js';
|
|
11
|
+
export interface StatusSnapshotOptions {
|
|
12
|
+
allStates: ProviderState[];
|
|
13
|
+
cdpManagers: Map<string, DaemonCdpManager>;
|
|
14
|
+
providerLoader: {
|
|
15
|
+
getAll(): Array<{
|
|
16
|
+
type: string;
|
|
17
|
+
icon?: string;
|
|
18
|
+
displayName?: string;
|
|
19
|
+
category: 'ide' | 'extension' | 'cli' | 'acp';
|
|
20
|
+
}>;
|
|
21
|
+
getAvailableProviderInfos?: () => Array<{
|
|
22
|
+
type: string;
|
|
23
|
+
icon?: string;
|
|
24
|
+
displayName?: string;
|
|
25
|
+
category: 'ide' | 'extension' | 'cli' | 'acp';
|
|
26
|
+
installed?: boolean;
|
|
27
|
+
detectedPath?: string | null;
|
|
28
|
+
}>;
|
|
29
|
+
};
|
|
30
|
+
detectedIdes: Array<{
|
|
31
|
+
id: string;
|
|
32
|
+
name?: string;
|
|
33
|
+
displayName?: string;
|
|
34
|
+
installed?: boolean;
|
|
35
|
+
path?: string;
|
|
36
|
+
}>;
|
|
37
|
+
instanceId: string;
|
|
38
|
+
version: string;
|
|
39
|
+
daemonMode: boolean;
|
|
40
|
+
timestamp?: number;
|
|
41
|
+
p2p?: StatusReportPayload['p2p'];
|
|
42
|
+
machineNickname?: string | null;
|
|
43
|
+
}
|
|
44
|
+
export interface StatusSnapshot extends StatusReportPayload {
|
|
45
|
+
availableProviders: AvailableProviderInfo[];
|
|
46
|
+
}
|
|
47
|
+
export declare function getSessionCompletionMarker(session: {
|
|
48
|
+
activeChat?: {
|
|
49
|
+
messages?: Array<{
|
|
50
|
+
role?: string;
|
|
51
|
+
id?: string;
|
|
52
|
+
index?: number;
|
|
53
|
+
receivedAt?: number | string;
|
|
54
|
+
_turnKey?: string;
|
|
55
|
+
}> | null;
|
|
56
|
+
} | null;
|
|
57
|
+
}): string;
|
|
58
|
+
export declare function buildStatusSnapshot(options: StatusSnapshotOptions): StatusSnapshot;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host memory metrics — macOS-aware "available" memory.
|
|
3
|
+
*
|
|
4
|
+
* Node's os.freemem() on darwin reports only the tiny truly-free pool; most RAM
|
|
5
|
+
* sits in inactive/file-backed cache that the OS can reclaim. Dashboard "used %"
|
|
6
|
+
* based on (total - freemem) looks ~99% almost always — misleading.
|
|
7
|
+
*
|
|
8
|
+
* On macOS we parse `vm_stat` and approximate available bytes as:
|
|
9
|
+
* (free + inactive + speculative + purgeable [+ file_backed]) × page size
|
|
10
|
+
* (aligned with common Activity Monitor–style interpretations.)
|
|
11
|
+
*/
|
|
12
|
+
export interface HostMemorySnapshot {
|
|
13
|
+
totalMem: number;
|
|
14
|
+
/** Raw kernel "free" — small on macOS; kept for debugging / API compat */
|
|
15
|
+
freeMem: number;
|
|
16
|
+
/** Use this for UI "used %" — on darwin from vm_stat; else equals freeMem */
|
|
17
|
+
availableMem: number;
|
|
18
|
+
}
|
|
19
|
+
export declare function getHostMemorySnapshot(): HostMemorySnapshot;
|
package/src/types.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Shared types referenced by daemon-core, daemon-standalone, and web-core.
|
|
5
5
|
* When modifying this file, also update interface contracts in AGENT_PROTOCOL.md.
|
|
6
6
|
*/
|
|
7
|
-
import type { StatusReportPayload } from './shared-types.js';
|
|
7
|
+
import type { StatusReportPayload, AvailableProviderInfo } from './shared-types.js';
|
|
8
8
|
/** Full status response from /api/v1/status and WS events */
|
|
9
9
|
export interface StatusResponse extends StatusReportPayload {
|
|
10
10
|
/** For standalone API compat */
|
|
@@ -15,7 +15,7 @@ export interface StatusResponse extends StatusReportPayload {
|
|
|
15
15
|
/** User display name from config */
|
|
16
16
|
userName?: string;
|
|
17
17
|
/** Available providers */
|
|
18
|
-
availableProviders:
|
|
18
|
+
availableProviders: AvailableProviderInfo[];
|
|
19
19
|
/** System info (legacy compat) */
|
|
20
20
|
system?: SystemInfo;
|
|
21
21
|
}
|
|
@@ -111,11 +111,7 @@ export interface DetectedIde {
|
|
|
111
111
|
installed: boolean;
|
|
112
112
|
running: boolean;
|
|
113
113
|
}
|
|
114
|
-
export interface ProviderInfo {
|
|
115
|
-
type: string;
|
|
116
|
-
icon: string;
|
|
117
|
-
displayName: string;
|
|
118
|
-
category: string;
|
|
114
|
+
export interface ProviderInfo extends AvailableProviderInfo {
|
|
119
115
|
}
|
|
120
116
|
/** Flattened agent entry from /api/v1/agents */
|
|
121
117
|
export interface AgentEntry {
|