@adhdev/daemon-core 0.5.3 → 0.5.5
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 +79 -2
- package/dist/index.js +1131 -433
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/providers/_builtin/extension/cline/scripts/read_chat.js +14 -1
- package/providers/_builtin/ide/antigravity/scripts/1.106/read_chat.js +24 -1
- package/providers/_builtin/ide/antigravity/scripts/1.107/read_chat.js +24 -1
- package/providers/_builtin/ide/cursor/scripts/0.49/focus_editor.js +3 -3
- package/providers/_builtin/ide/cursor/scripts/0.49/list_models.js +1 -1
- package/providers/_builtin/ide/cursor/scripts/0.49/list_modes.js +1 -1
- package/providers/_builtin/ide/cursor/scripts/0.49/open_panel.js +4 -4
- package/providers/_builtin/ide/cursor/scripts/0.49/read_chat.js +5 -1
- package/providers/_builtin/ide/cursor/scripts/0.49.bak/dismiss_notification.js +30 -0
- package/providers/_builtin/ide/cursor/scripts/0.49.bak/focus_editor.js +13 -0
- package/providers/_builtin/ide/cursor/scripts/0.49.bak/list_models.js +78 -0
- package/providers/_builtin/ide/cursor/scripts/0.49.bak/list_modes.js +40 -0
- package/providers/_builtin/ide/cursor/scripts/0.49.bak/list_notifications.js +23 -0
- package/providers/_builtin/ide/cursor/scripts/0.49.bak/list_sessions.js +42 -0
- package/providers/_builtin/ide/cursor/scripts/0.49.bak/new_session.js +20 -0
- package/providers/_builtin/ide/cursor/scripts/0.49.bak/open_panel.js +23 -0
- package/providers/_builtin/ide/cursor/scripts/0.49.bak/read_chat.js +79 -0
- package/providers/_builtin/ide/cursor/scripts/0.49.bak/resolve_action.js +19 -0
- package/providers/_builtin/ide/cursor/scripts/0.49.bak/scripts.js +78 -0
- package/providers/_builtin/ide/cursor/scripts/0.49.bak/send_message.js +23 -0
- package/providers/_builtin/ide/cursor/scripts/0.49.bak/set_mode.js +38 -0
- package/providers/_builtin/ide/cursor/scripts/0.49.bak/set_model.js +81 -0
- package/providers/_builtin/ide/cursor/scripts/0.49.bak/switch_session.js +28 -0
- package/providers/_builtin/ide/windsurf/scripts/read_chat.js +18 -1
- package/src/cli-adapters/provider-cli-adapter.ts +167 -7
- package/src/commands/cli-manager.ts +128 -30
- package/src/commands/handler.ts +47 -3
- package/src/commands/router.ts +32 -2
- package/src/commands/workspace-commands.ts +108 -0
- package/src/config/config.ts +29 -1
- package/src/config/workspace-activity.ts +65 -0
- package/src/config/workspaces.ts +250 -0
- package/src/daemon/dev-server.ts +1 -1
- package/src/index.ts +5 -0
- package/src/launch.ts +1 -1
- package/src/providers/ide-provider-instance.ts +11 -0
- package/src/status/reporter.ts +23 -4
- package/src/system/host-memory.ts +65 -0
- package/src/types.ts +8 -1
|
@@ -274,6 +274,17 @@ export class IdeProviderInstance implements ProviderInstance {
|
|
|
274
274
|
msg.receivedAt = prevByHash.get(h) || now;
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
+
// Filter messages by provider settings (showThinking, showToolCalls, showTerminal)
|
|
278
|
+
if (raw.messages?.length > 0) {
|
|
279
|
+
const hiddenKinds = new Set<string>();
|
|
280
|
+
if (this.settings.showThinking === false) hiddenKinds.add('thought');
|
|
281
|
+
if (this.settings.showToolCalls === false) hiddenKinds.add('tool');
|
|
282
|
+
if (this.settings.showTerminal === false) hiddenKinds.add('terminal');
|
|
283
|
+
if (hiddenKinds.size > 0) {
|
|
284
|
+
raw.messages = raw.messages.filter((m: any) => !hiddenKinds.has(m.kind));
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
277
288
|
this.cachedChat = { ...raw, activeModal };
|
|
278
289
|
this.detectAgentTransitions(raw, now);
|
|
279
290
|
|
package/src/status/reporter.ts
CHANGED
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
import * as os from 'os';
|
|
9
9
|
import * as path from 'path';
|
|
10
10
|
import { loadConfig } from '../config/config.js';
|
|
11
|
+
import { getWorkspaceState } from '../config/workspaces.js';
|
|
12
|
+
import { getHostMemorySnapshot } from '../system/host-memory.js';
|
|
13
|
+
import { getWorkspaceActivity } from '../config/workspace-activity.js';
|
|
11
14
|
import { LOG } from '../logging/logger.js';
|
|
12
15
|
|
|
13
16
|
// ─── Daemon dependency interface ──────────────────────
|
|
@@ -95,6 +98,11 @@ export class DaemonStatusReporter {
|
|
|
95
98
|
// (agent-stream polling backward compat)
|
|
96
99
|
updateAgentStreams(_ideType: string, _streams: any[]): void { /* Managed by Instance itself */ }
|
|
97
100
|
|
|
101
|
+
/** Reset P2P dedup hash — forces next send to transmit even if content unchanged */
|
|
102
|
+
resetP2PHash(): void {
|
|
103
|
+
this.lastP2PStatusHash = '';
|
|
104
|
+
}
|
|
105
|
+
|
|
98
106
|
// ─── Core ────────────────────────────────────────
|
|
99
107
|
|
|
100
108
|
private ts(): string {
|
|
@@ -197,17 +205,26 @@ export class DaemonStatusReporter {
|
|
|
197
205
|
|
|
198
206
|
|
|
199
207
|
|
|
208
|
+
const cfg = loadConfig();
|
|
209
|
+
const wsState = getWorkspaceState(cfg);
|
|
210
|
+
const memSnap = getHostMemorySnapshot();
|
|
211
|
+
|
|
200
212
|
// ═══ Assemble payload (P2P — required data only) ═══
|
|
201
213
|
const payload: Record<string, any> = {
|
|
202
214
|
daemonMode: true,
|
|
203
|
-
machineNickname:
|
|
215
|
+
machineNickname: cfg.machineNickname || null,
|
|
216
|
+
workspaces: wsState.workspaces,
|
|
217
|
+
defaultWorkspaceId: wsState.defaultWorkspaceId,
|
|
218
|
+
defaultWorkspacePath: wsState.defaultWorkspacePath,
|
|
219
|
+
workspaceActivity: getWorkspaceActivity(cfg, 15),
|
|
204
220
|
machine: {
|
|
205
221
|
hostname: os.hostname(),
|
|
206
222
|
platform: os.platform(),
|
|
207
223
|
arch: os.arch(),
|
|
208
224
|
cpus: os.cpus().length,
|
|
209
|
-
totalMem:
|
|
210
|
-
freeMem:
|
|
225
|
+
totalMem: memSnap.totalMem,
|
|
226
|
+
freeMem: memSnap.freeMem,
|
|
227
|
+
availableMem: memSnap.availableMem,
|
|
211
228
|
loadavg: os.loadavg(),
|
|
212
229
|
uptime: os.uptime(),
|
|
213
230
|
},
|
|
@@ -243,6 +260,8 @@ export class DaemonStatusReporter {
|
|
|
243
260
|
const wsPayload = {
|
|
244
261
|
daemonMode: true,
|
|
245
262
|
machineNickname: payload.machineNickname,
|
|
263
|
+
defaultWorkspaceId: wsState.defaultWorkspaceId,
|
|
264
|
+
workspaceCount: (wsState.workspaces || []).length,
|
|
246
265
|
// managedIdes: server only saves id, type, cdpConnected
|
|
247
266
|
managedIdes: managedIdes.map(ide => ({
|
|
248
267
|
ideType: ide.ideType,
|
|
@@ -271,7 +290,7 @@ export class DaemonStatusReporter {
|
|
|
271
290
|
private sendP2PPayload(payload: Record<string, any>): boolean {
|
|
272
291
|
const { timestamp: _ts, system: _sys, ...hashTarget } = payload;
|
|
273
292
|
if (hashTarget.machine) {
|
|
274
|
-
const { freeMem: _f, loadavg: _l, uptime: _u, ...stableMachine } = hashTarget.machine as any;
|
|
293
|
+
const { freeMem: _f, availableMem: _a, loadavg: _l, uptime: _u, ...stableMachine } = hashTarget.machine as any;
|
|
275
294
|
hashTarget.machine = stableMachine;
|
|
276
295
|
}
|
|
277
296
|
const h = this.simpleHash(JSON.stringify(hashTarget));
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
|
|
13
|
+
import * as os from 'os';
|
|
14
|
+
import { execSync } from 'child_process';
|
|
15
|
+
|
|
16
|
+
export interface HostMemorySnapshot {
|
|
17
|
+
totalMem: number;
|
|
18
|
+
/** Raw kernel "free" — small on macOS; kept for debugging / API compat */
|
|
19
|
+
freeMem: number;
|
|
20
|
+
/** Use this for UI "used %" — on darwin from vm_stat; else equals freeMem */
|
|
21
|
+
availableMem: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function parseDarwinAvailableBytes(totalMem: number): number | null {
|
|
25
|
+
if (os.platform() !== 'darwin') return null;
|
|
26
|
+
try {
|
|
27
|
+
const out = execSync('vm_stat', {
|
|
28
|
+
encoding: 'utf-8',
|
|
29
|
+
timeout: 4000,
|
|
30
|
+
maxBuffer: 256 * 1024,
|
|
31
|
+
});
|
|
32
|
+
const pageSizeMatch = out.match(/page size of (\d+)\s*bytes/i);
|
|
33
|
+
const pageSize = pageSizeMatch ? parseInt(pageSizeMatch[1], 10) : 4096;
|
|
34
|
+
|
|
35
|
+
const counts: Record<string, number> = {};
|
|
36
|
+
for (const line of out.split('\n')) {
|
|
37
|
+
const m = line.match(/^\s*Pages\s+([^:]+):\s+([\d,]+)\s*\.?/);
|
|
38
|
+
if (!m) continue;
|
|
39
|
+
const key = m[1].trim().toLowerCase().replace(/\s+/g, '_');
|
|
40
|
+
const n = parseInt(m[2].replace(/,/g, ''), 10);
|
|
41
|
+
if (!Number.isNaN(n)) counts[key] = n;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const free = counts['free'] ?? 0;
|
|
45
|
+
const inactive = counts['inactive'] ?? 0;
|
|
46
|
+
const speculative = counts['speculative'] ?? 0;
|
|
47
|
+
const purgeable = counts['purgeable'] ?? 0;
|
|
48
|
+
const fileBacked = counts['file_backed'] ?? 0;
|
|
49
|
+
|
|
50
|
+
const availPages = free + inactive + speculative + purgeable + fileBacked;
|
|
51
|
+
const bytes = availPages * pageSize;
|
|
52
|
+
if (!Number.isFinite(bytes) || bytes < 0) return null;
|
|
53
|
+
return Math.min(bytes, totalMem);
|
|
54
|
+
} catch {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function getHostMemorySnapshot(): HostMemorySnapshot {
|
|
60
|
+
const totalMem = os.totalmem();
|
|
61
|
+
const freeMem = os.freemem();
|
|
62
|
+
const darwinAvail = parseDarwinAvailableBytes(totalMem);
|
|
63
|
+
const availableMem = darwinAvail != null ? darwinAvail : freeMem;
|
|
64
|
+
return { totalMem, freeMem, availableMem };
|
|
65
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -43,7 +43,7 @@ export interface IdeEntry {
|
|
|
43
43
|
agentStreams?: AgentStreamEntry[];
|
|
44
44
|
/** Extension agents monitored via CDP */
|
|
45
45
|
extensions?: ExtensionInfo[];
|
|
46
|
-
/**
|
|
46
|
+
/** IDE-reported workspace roots (name + path) */
|
|
47
47
|
workspaceFolders?: { name: string; path: string }[];
|
|
48
48
|
/** Active file path */
|
|
49
49
|
activeFile?: string | null;
|
|
@@ -150,6 +150,8 @@ export interface SystemInfo {
|
|
|
150
150
|
cpus: number;
|
|
151
151
|
totalMem: number;
|
|
152
152
|
freeMem: number;
|
|
153
|
+
/** macOS: reclaimable-inclusive; prefer for UI used% (see host-memory.ts) */
|
|
154
|
+
availableMem?: number;
|
|
153
155
|
loadavg: number[];
|
|
154
156
|
uptime: number;
|
|
155
157
|
arch: string;
|
|
@@ -183,6 +185,11 @@ export interface StatusResponse {
|
|
|
183
185
|
detectedIdes: DetectedIde[];
|
|
184
186
|
availableProviders: ProviderInfo[];
|
|
185
187
|
system: SystemInfo;
|
|
188
|
+
/** Saved workspaces (standalone WS / HTTP status) */
|
|
189
|
+
workspaces?: { id: string; path: string; label?: string; addedAt: number }[];
|
|
190
|
+
defaultWorkspaceId?: string | null;
|
|
191
|
+
defaultWorkspacePath?: string | null;
|
|
192
|
+
workspaceActivity?: { path: string; lastUsedAt: number; kind?: string; agentType?: string }[];
|
|
186
193
|
}
|
|
187
194
|
|
|
188
195
|
/** Agent stream entry within an IDE */
|