@adhdev/daemon-core 0.8.34 → 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 +585 -256
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +584 -256
- package/dist/index.mjs.map +1 -1
- package/dist/shared-types.d.ts +286 -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 +7 -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/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/boot/daemon-lifecycle.ts +7 -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/chat-commands.ts +192 -17
- 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/router.ts +25 -0
- package/src/commands/stream-commands.d.ts +14 -0
- package/src/commands/stream-commands.ts +14 -10
- 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/config.ts +8 -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 +34 -1
- 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 +204 -38
- package/src/shared-types.ts +319 -16
- package/src/status/builders.d.ts +33 -0
- package/src/status/builders.ts +110 -54
- package/src/status/normalize.ts +54 -19
- package/src/status/reporter.d.ts +69 -0
- package/src/status/reporter.ts +104 -26
- package/src/status/snapshot.d.ts +58 -0
- package/src/status/snapshot.ts +79 -41
- package/src/system/host-memory.d.ts +19 -0
- package/src/types.d.ts +3 -7
- package/src/types.ts +1 -1
package/src/commands/router.ts
CHANGED
|
@@ -31,6 +31,7 @@ import { logCommand } from '../logging/command-log.js';
|
|
|
31
31
|
import type { CommandLogEntry } from '../logging/command-log.js';
|
|
32
32
|
import { getRecentLogs, LOG_PATH } from '../logging/logger.js';
|
|
33
33
|
import { buildSessionEntries } from '../status/builders.js';
|
|
34
|
+
import { buildMachineInfo, buildStatusSnapshot } from '../status/snapshot.js';
|
|
34
35
|
import { getSessionCompletionMarker } from '../status/snapshot.js';
|
|
35
36
|
import { spawnDetachedDaemonUpgradeHelper } from './upgrade-helper.js';
|
|
36
37
|
import * as fs from 'fs';
|
|
@@ -71,6 +72,9 @@ export interface CommandRouterDeps {
|
|
|
71
72
|
getCdpLogFn?: (ideType: string) => (msg: string) => void;
|
|
72
73
|
/** Package name for upgrade detection ('adhdev' or '@adhdev/daemon-standalone') */
|
|
73
74
|
packageName?: string;
|
|
75
|
+
/** Canonical daemon status identity used by snapshot commands */
|
|
76
|
+
statusInstanceId?: string;
|
|
77
|
+
statusVersion?: string;
|
|
74
78
|
/** Session host control plane */
|
|
75
79
|
sessionHostControl?: SessionHostControlPlane | null;
|
|
76
80
|
}
|
|
@@ -491,6 +495,27 @@ export class DaemonCommandRouter {
|
|
|
491
495
|
return { success: true, userName: name };
|
|
492
496
|
}
|
|
493
497
|
|
|
498
|
+
case 'get_status_metadata': {
|
|
499
|
+
const snapshot = buildStatusSnapshot({
|
|
500
|
+
allStates: this.deps.instanceManager.collectAllStates(),
|
|
501
|
+
cdpManagers: this.deps.cdpManagers,
|
|
502
|
+
providerLoader: this.deps.providerLoader,
|
|
503
|
+
detectedIdes: this.deps.detectedIdes.value,
|
|
504
|
+
instanceId: this.deps.statusInstanceId || loadConfig().machineId || 'daemon',
|
|
505
|
+
version: this.deps.statusVersion || 'unknown',
|
|
506
|
+
profile: 'metadata',
|
|
507
|
+
});
|
|
508
|
+
return { success: true, status: snapshot };
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
case 'get_machine_runtime_stats': {
|
|
512
|
+
return {
|
|
513
|
+
success: true,
|
|
514
|
+
machine: buildMachineInfo('full'),
|
|
515
|
+
timestamp: Date.now(),
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
|
|
494
519
|
case 'mark_session_seen': {
|
|
495
520
|
const sessionId = args?.sessionId;
|
|
496
521
|
if (!sessionId || typeof sessionId !== 'string') {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stream Commands — Agent Stream, PTY I/O, Provider Settings,
|
|
3
|
+
* IDE Extension Settings, Extension Script Execution
|
|
4
|
+
*/
|
|
5
|
+
import type { CommandResult, CommandHelpers } from './handler.js';
|
|
6
|
+
export declare function handleFocusSession(h: CommandHelpers, args: any): Promise<CommandResult>;
|
|
7
|
+
export declare function handlePtyInput(h: CommandHelpers, args: any): CommandResult;
|
|
8
|
+
export declare function handlePtyResize(h: CommandHelpers, args: any): CommandResult;
|
|
9
|
+
export declare function handleGetProviderSettings(h: CommandHelpers, args: any): CommandResult;
|
|
10
|
+
export declare function handleSetProviderSetting(h: CommandHelpers, args: any): Promise<CommandResult>;
|
|
11
|
+
export declare function handleExtensionScript(h: CommandHelpers, args: any, scriptName: string): Promise<CommandResult>;
|
|
12
|
+
export declare function handleProviderScript(h: CommandHelpers, args: any): Promise<CommandResult>;
|
|
13
|
+
export declare function handleGetIdeExtensions(h: CommandHelpers, args: any): CommandResult;
|
|
14
|
+
export declare function handleSetIdeExtension(h: CommandHelpers, args: any): CommandResult;
|
|
@@ -164,13 +164,17 @@ function applyProviderPatch(h: CommandHelpers, args: any, payload: any): void {
|
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
async function executeProviderScript(h: CommandHelpers, args: any, scriptName: string): Promise<CommandResult> {
|
|
167
|
-
const
|
|
168
|
-
|
|
167
|
+
const resolvedProviderType =
|
|
168
|
+
h.currentSession?.providerType
|
|
169
|
+
|| h.currentProviderType
|
|
170
|
+
|| args?.agentType
|
|
171
|
+
|| args?.providerType;
|
|
172
|
+
if (!resolvedProviderType) return { success: false, error: 'targetSessionId or providerType is required' };
|
|
169
173
|
|
|
170
174
|
const loader = h.ctx.providerLoader;
|
|
171
175
|
if (!loader) return { success: false, error: 'ProviderLoader not initialized' };
|
|
172
|
-
const provider = loader.resolve(
|
|
173
|
-
if (!provider) return { success: false, error: `Provider not found: ${
|
|
176
|
+
const provider = loader.resolve(resolvedProviderType);
|
|
177
|
+
if (!provider) return { success: false, error: `Provider not found: ${resolvedProviderType}` };
|
|
174
178
|
|
|
175
179
|
const webviewScriptName = `webview${scriptName.charAt(0).toUpperCase() + scriptName.slice(1)}`;
|
|
176
180
|
const hasWebviewScript = provider.category === 'ide' &&
|
|
@@ -179,13 +183,13 @@ async function executeProviderScript(h: CommandHelpers, args: any, scriptName: s
|
|
|
179
183
|
const actualScriptName = hasWebviewScript ? webviewScriptName : scriptName;
|
|
180
184
|
|
|
181
185
|
if (!provider.scripts?.[actualScriptName as keyof typeof provider.scripts]) {
|
|
182
|
-
return { success: false, error: `Script '${actualScriptName}' not available for ${
|
|
186
|
+
return { success: false, error: `Script '${actualScriptName}' not available for ${resolvedProviderType}` };
|
|
183
187
|
}
|
|
184
188
|
|
|
185
189
|
const normalizedArgs = normalizeProviderScriptArgs(args);
|
|
186
190
|
|
|
187
191
|
if (provider.category === 'cli') {
|
|
188
|
-
const adapter = h.getCliAdapter(args?.targetSessionId ||
|
|
192
|
+
const adapter = h.getCliAdapter(args?.targetSessionId || resolvedProviderType);
|
|
189
193
|
if (!adapter?.invokeScript) {
|
|
190
194
|
return { success: false, error: `CLI adapter does not support script '${actualScriptName}'` };
|
|
191
195
|
}
|
|
@@ -213,8 +217,8 @@ async function executeProviderScript(h: CommandHelpers, args: any, scriptName: s
|
|
|
213
217
|
if (!scriptCode) return { success: false, error: `Script '${actualScriptName}' returned null` };
|
|
214
218
|
|
|
215
219
|
const cdpKey = provider.category === 'ide'
|
|
216
|
-
? (h.currentSession?.cdpManagerKey || h.currentManagerKey ||
|
|
217
|
-
: (h.currentSession?.cdpManagerKey || h.currentManagerKey
|
|
220
|
+
? (h.currentSession?.cdpManagerKey || h.currentManagerKey || resolvedProviderType)
|
|
221
|
+
: (h.currentSession?.cdpManagerKey || h.currentManagerKey);
|
|
218
222
|
LOG.info('Command', `[ExtScript] provider=${provider.type} category=${provider.category} cdpKey=${cdpKey}`);
|
|
219
223
|
const cdp = h.getCdp(cdpKey);
|
|
220
224
|
if (!cdp?.isConnected) return { success: false, error: `No CDP connection for ${cdpKey || 'any'}` };
|
|
@@ -224,7 +228,7 @@ async function executeProviderScript(h: CommandHelpers, args: any, scriptName: s
|
|
|
224
228
|
|
|
225
229
|
if (provider.category === 'extension') {
|
|
226
230
|
const runtimeSessionId = h.currentSession?.sessionId || args?.targetSessionId;
|
|
227
|
-
if (!runtimeSessionId) return { success: false, error: `No target session found for ${
|
|
231
|
+
if (!runtimeSessionId) return { success: false, error: `No target session found for ${resolvedProviderType}` };
|
|
228
232
|
const parentSessionId = h.currentSession?.parentSessionId;
|
|
229
233
|
if (parentSessionId) {
|
|
230
234
|
await h.agentStream?.setActiveSession(cdp, parentSessionId, runtimeSessionId);
|
|
@@ -257,7 +261,7 @@ async function executeProviderScript(h: CommandHelpers, args: any, scriptName: s
|
|
|
257
261
|
}
|
|
258
262
|
} else {
|
|
259
263
|
if (!targetSessionId) {
|
|
260
|
-
return { success: false, error: `No active session found for ${
|
|
264
|
+
return { success: false, error: `No active session found for ${resolvedProviderType}` };
|
|
261
265
|
}
|
|
262
266
|
result = await cdp.evaluateInSessionFrame(targetSessionId, scriptCode);
|
|
263
267
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface DaemonUpgradeHelperPayload {
|
|
2
|
+
packageName: string;
|
|
3
|
+
targetVersion: string;
|
|
4
|
+
parentPid: number;
|
|
5
|
+
restartArgv: string[];
|
|
6
|
+
cwd?: string;
|
|
7
|
+
sessionHostAppName?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function spawnDetachedDaemonUpgradeHelper(payload: DaemonUpgradeHelperPayload): void;
|
|
10
|
+
export declare function maybeRunDaemonUpgradeHelperFromEnv(): Promise<boolean>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* workspace_* commands — list/add/remove/default (config.json)
|
|
3
|
+
*/
|
|
4
|
+
export type WorkspaceCommandResult = {
|
|
5
|
+
success: boolean;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
};
|
|
8
|
+
export declare function handleWorkspaceList(): WorkspaceCommandResult;
|
|
9
|
+
export declare function handleWorkspaceAdd(args: any): WorkspaceCommandResult;
|
|
10
|
+
export declare function handleWorkspaceRemove(args: any): WorkspaceCommandResult;
|
|
11
|
+
export declare function handleWorkspaceSetDefault(args: any): WorkspaceCommandResult;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chat History Persistence — Persist completed chat messages to local disk
|
|
3
|
+
*
|
|
4
|
+
* Design:
|
|
5
|
+
* - ~/.adhdev/history/{agentType}/YYYY-MM-DD.jsonl
|
|
6
|
+
* - JSONL format (one line = one message, append-friendly)
|
|
7
|
+
* - Track only new messages (hash comparison with previous)
|
|
8
|
+
* - Auto-rotation (delete files older than 30 days)
|
|
9
|
+
* - Async/non-blocking (no impact on chat collection)
|
|
10
|
+
*/
|
|
11
|
+
interface HistoryMessage {
|
|
12
|
+
ts: string;
|
|
13
|
+
receivedAt: number;
|
|
14
|
+
role: 'user' | 'assistant' | 'system';
|
|
15
|
+
content: string;
|
|
16
|
+
kind?: string;
|
|
17
|
+
senderName?: string;
|
|
18
|
+
agent: string;
|
|
19
|
+
instanceId?: string;
|
|
20
|
+
historySessionId?: string;
|
|
21
|
+
sessionTitle?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface SavedHistorySessionSummary {
|
|
24
|
+
historySessionId: string;
|
|
25
|
+
sessionTitle?: string;
|
|
26
|
+
messageCount: number;
|
|
27
|
+
firstMessageAt: number;
|
|
28
|
+
lastMessageAt: number;
|
|
29
|
+
preview?: string;
|
|
30
|
+
}
|
|
31
|
+
export declare class ChatHistoryWriter {
|
|
32
|
+
/** Last seen message count per agent (deduplication) */
|
|
33
|
+
private lastSeenCounts;
|
|
34
|
+
/** Last seen message hash per agent (deduplication) */
|
|
35
|
+
private lastSeenHashes;
|
|
36
|
+
/** Last appended normalized message signature per agent/session */
|
|
37
|
+
private lastSeenSignatures;
|
|
38
|
+
/** Last appended normalized non-system turn signature per agent/session */
|
|
39
|
+
private lastSeenTurnSignatures;
|
|
40
|
+
private rotated;
|
|
41
|
+
/**
|
|
42
|
+
* Append new messages to history
|
|
43
|
+
*
|
|
44
|
+
* @param agentType agent type (e.g. 'antigravity', 'cursor')
|
|
45
|
+
* @param messages Message array received from readChat
|
|
46
|
+
* @param sessionTitle Current session title
|
|
47
|
+
* @param instanceId IDE instance UUID (distinguishes windows of the same agent)
|
|
48
|
+
*/
|
|
49
|
+
appendNewMessages(agentType: string, messages: Array<{
|
|
50
|
+
role: string;
|
|
51
|
+
content: string;
|
|
52
|
+
receivedAt?: number;
|
|
53
|
+
kind?: string;
|
|
54
|
+
senderName?: string;
|
|
55
|
+
historyDedupKey?: string;
|
|
56
|
+
}>, sessionTitle?: string, instanceId?: string, historySessionId?: string): void;
|
|
57
|
+
seedSessionHistory(agentType: string, messages?: Array<{
|
|
58
|
+
role: string;
|
|
59
|
+
content: string;
|
|
60
|
+
receivedAt?: number;
|
|
61
|
+
kind?: string;
|
|
62
|
+
historyDedupKey?: string;
|
|
63
|
+
}>, historySessionId?: string, instanceId?: string): void;
|
|
64
|
+
appendSystemMarker(agentType: string, content: string, options?: {
|
|
65
|
+
sessionTitle?: string;
|
|
66
|
+
instanceId?: string;
|
|
67
|
+
historySessionId?: string;
|
|
68
|
+
dedupKey?: string;
|
|
69
|
+
receivedAt?: number;
|
|
70
|
+
senderName?: string;
|
|
71
|
+
}): void;
|
|
72
|
+
promoteHistorySession(agentType: string, previousHistorySessionId: string, nextHistorySessionId: string): void;
|
|
73
|
+
compactHistorySession(agentType: string, historySessionId: string): void;
|
|
74
|
+
/** Called when agent session is explicitly changed */
|
|
75
|
+
onSessionChange(agentType: string): void;
|
|
76
|
+
/** Delete history files older than 30 days */
|
|
77
|
+
private rotateOldFiles;
|
|
78
|
+
/** Allow only filename-safe characters */
|
|
79
|
+
private sanitize;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Read history (static — called from P2P commands)
|
|
83
|
+
*
|
|
84
|
+
* Read JSONL files in reverse order, returning most recent messages first.
|
|
85
|
+
* When instanceId is specified, reads only that instance file.
|
|
86
|
+
* Offset/limit-based paging.
|
|
87
|
+
*/
|
|
88
|
+
export declare function readChatHistory(agentType: string, offset?: number, limit?: number, historySessionId?: string): {
|
|
89
|
+
messages: HistoryMessage[];
|
|
90
|
+
hasMore: boolean;
|
|
91
|
+
};
|
|
92
|
+
export declare function listSavedHistorySessions(agentType: string, options?: {
|
|
93
|
+
offset?: number;
|
|
94
|
+
limit?: number;
|
|
95
|
+
}): {
|
|
96
|
+
sessions: SavedHistorySessionSummary[];
|
|
97
|
+
hasMore: boolean;
|
|
98
|
+
};
|
|
99
|
+
export {};
|
package/src/config/config.d.ts
CHANGED
|
@@ -29,6 +29,15 @@ export interface ADHDevConfig {
|
|
|
29
29
|
*/
|
|
30
30
|
machineId?: string;
|
|
31
31
|
machineSecret?: string | null;
|
|
32
|
+
/**
|
|
33
|
+
* Server-side D1 `machines.id` — the row ID assigned when daemon registers via
|
|
34
|
+
* `POST /cli/complete`. This remains useful for account-side machine actions
|
|
35
|
+
* that target the registered machine row directly (for example cloud rename).
|
|
36
|
+
*
|
|
37
|
+
* Machine auth itself uses `machineSecret` (adm_) and no longer falls back
|
|
38
|
+
* to `registeredMachineId`.
|
|
39
|
+
*/
|
|
40
|
+
registeredMachineId?: string;
|
|
32
41
|
providerSettings: Record<string, Record<string, any>>;
|
|
33
42
|
ideSettings: Record<string, {
|
|
34
43
|
extensions?: Record<string, {
|
|
@@ -37,6 +46,11 @@ export interface ADHDevConfig {
|
|
|
37
46
|
}>;
|
|
38
47
|
disableUpstream?: boolean;
|
|
39
48
|
providerDir?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Browser terminal sizing behavior for dashboard CLI panes.
|
|
51
|
+
* Default `measured` keeps terminal size daemon-authoritative.
|
|
52
|
+
* `fit` opt-in restores xterm fit-based sizing for advanced users.
|
|
53
|
+
*/
|
|
40
54
|
terminalSizingMode?: 'measured' | 'fit';
|
|
41
55
|
}
|
|
42
56
|
export declare function generateMachineId(): string;
|
package/src/config/config.ts
CHANGED
|
@@ -18,6 +18,12 @@ export interface ADHDevConfig {
|
|
|
18
18
|
// Server connection
|
|
19
19
|
serverUrl: string;
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Allow server-relayed REST/API commands to reach the daemon.
|
|
23
|
+
* Disabled by default so cloud dashboard traffic stays P2P-only.
|
|
24
|
+
*/
|
|
25
|
+
allowServerApiProxy?: boolean;
|
|
26
|
+
|
|
21
27
|
// Selected IDE (primary)
|
|
22
28
|
selectedIde: string | null;
|
|
23
29
|
|
|
@@ -90,6 +96,7 @@ export interface ADHDevConfig {
|
|
|
90
96
|
|
|
91
97
|
const DEFAULT_CONFIG: ADHDevConfig = {
|
|
92
98
|
serverUrl: 'https://api.adhf.dev',
|
|
99
|
+
allowServerApiProxy: false,
|
|
93
100
|
selectedIde: null,
|
|
94
101
|
configuredIdes: [],
|
|
95
102
|
installedExtensions: [],
|
|
@@ -140,6 +147,7 @@ function normalizeConfig(raw: unknown): ADHDevConfig & { activeWorkspaceId?: str
|
|
|
140
147
|
serverUrl: typeof parsed.serverUrl === 'string' && parsed.serverUrl.trim()
|
|
141
148
|
? parsed.serverUrl
|
|
142
149
|
: DEFAULT_CONFIG.serverUrl,
|
|
150
|
+
allowServerApiProxy: asBoolean(parsed.allowServerApiProxy, DEFAULT_CONFIG.allowServerApiProxy ?? false),
|
|
143
151
|
selectedIde: asNullableString(parsed.selectedIde),
|
|
144
152
|
configuredIdes: asStringArray(parsed.configuredIdes),
|
|
145
153
|
installedExtensions: asStringArray(parsed.installedExtensions),
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified recent activity — launcher-facing "pick up where you launched".
|
|
3
|
+
*
|
|
4
|
+
* Unlike live session state, this is launch oriented:
|
|
5
|
+
* - one normalized row shape for IDE / CLI / ACP
|
|
6
|
+
* - deduped by provider session when available, else by kind + providerType + workspace
|
|
7
|
+
* - used only for quick-launch shortcuts
|
|
8
|
+
*/
|
|
9
|
+
import type { DaemonState } from './state-store.js';
|
|
10
|
+
export interface RecentActivityEntry {
|
|
11
|
+
id: string;
|
|
12
|
+
kind: 'ide' | 'cli' | 'acp';
|
|
13
|
+
providerType: string;
|
|
14
|
+
providerName: string;
|
|
15
|
+
providerSessionId?: string;
|
|
16
|
+
workspace?: string | null;
|
|
17
|
+
currentModel?: string;
|
|
18
|
+
title?: string;
|
|
19
|
+
lastUsedAt: number;
|
|
20
|
+
}
|
|
21
|
+
export declare function buildRecentActivityKey(entry: Pick<RecentActivityEntry, 'kind' | 'providerType' | 'workspace'>): string;
|
|
22
|
+
export declare function buildRecentActivityKeyForEntry(entry: Pick<RecentActivityEntry, 'kind' | 'providerType' | 'workspace' | 'providerSessionId'>): string;
|
|
23
|
+
export declare function appendRecentActivity(state: DaemonState, entry: Omit<RecentActivityEntry, 'id' | 'lastUsedAt'> & {
|
|
24
|
+
lastUsedAt?: number;
|
|
25
|
+
}): DaemonState;
|
|
26
|
+
export declare function getRecentActivity(state: DaemonState, limit?: number): RecentActivityEntry[];
|
|
27
|
+
export declare function getSessionSeenAt(state: DaemonState, sessionId: string): number;
|
|
28
|
+
export declare function getSessionSeenMarker(state: DaemonState, sessionId: string): string;
|
|
29
|
+
export declare function markSessionSeen(state: DaemonState, sessionId: string, seenAt?: number, completionMarker?: string | null): DaemonState;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { DaemonState } from './state-store.js';
|
|
2
|
+
export interface SavedProviderSessionEntry {
|
|
3
|
+
id: string;
|
|
4
|
+
kind: 'cli' | 'acp';
|
|
5
|
+
providerType: string;
|
|
6
|
+
providerName: string;
|
|
7
|
+
providerSessionId: string;
|
|
8
|
+
workspace?: string | null;
|
|
9
|
+
currentModel?: string;
|
|
10
|
+
title?: string;
|
|
11
|
+
createdAt: number;
|
|
12
|
+
lastUsedAt: number;
|
|
13
|
+
}
|
|
14
|
+
export declare function buildSavedProviderSessionKey(providerSessionId: string): string;
|
|
15
|
+
export declare function upsertSavedProviderSession(state: DaemonState, entry: Omit<SavedProviderSessionEntry, 'id' | 'createdAt' | 'lastUsedAt'> & {
|
|
16
|
+
createdAt?: number;
|
|
17
|
+
lastUsedAt?: number;
|
|
18
|
+
}): DaemonState;
|
|
19
|
+
export declare function getSavedProviderSessions(state: DaemonState, filters?: {
|
|
20
|
+
providerType?: string;
|
|
21
|
+
kind?: SavedProviderSessionEntry['kind'];
|
|
22
|
+
}): SavedProviderSessionEntry[];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ADHDev State Store — Runtime state persistence
|
|
3
|
+
*
|
|
4
|
+
* Separates volatile runtime state (sessions, activity, read markers)
|
|
5
|
+
* from static configuration (config.json).
|
|
6
|
+
*
|
|
7
|
+
* State is stored in ~/.adhdev/state.json
|
|
8
|
+
*/
|
|
9
|
+
import type { RecentActivityEntry } from './recent-activity.js';
|
|
10
|
+
import type { SavedProviderSessionEntry } from './saved-sessions.js';
|
|
11
|
+
export interface DaemonState {
|
|
12
|
+
/** Unified recent activity across IDE / CLI / ACP launch flows */
|
|
13
|
+
recentActivity: RecentActivityEntry[];
|
|
14
|
+
/** Persistent resume-capable provider sessions keyed by providerSessionId */
|
|
15
|
+
savedProviderSessions: SavedProviderSessionEntry[];
|
|
16
|
+
/** Last seen timestamps for live sessions, keyed by sessionId */
|
|
17
|
+
sessionReads: Record<string, number>;
|
|
18
|
+
/** Last seen completion marker for live sessions, keyed by sessionId */
|
|
19
|
+
sessionReadMarkers: Record<string, string>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Load runtime state from disk
|
|
23
|
+
*/
|
|
24
|
+
export declare function loadState(): DaemonState;
|
|
25
|
+
/**
|
|
26
|
+
* Save runtime state to disk
|
|
27
|
+
*/
|
|
28
|
+
export declare function saveState(state: DaemonState): void;
|
|
29
|
+
/**
|
|
30
|
+
* Reset runtime state
|
|
31
|
+
*/
|
|
32
|
+
export declare function resetState(): void;
|
|
@@ -17,7 +17,6 @@ export declare function validateWorkspacePath(absPath: string): {
|
|
|
17
17
|
};
|
|
18
18
|
/** Default workspace label from path */
|
|
19
19
|
export declare function defaultWorkspaceLabel(absPath: string): string;
|
|
20
|
-
|
|
21
20
|
export declare function getDefaultWorkspacePath(config: ADHDevConfig): string | null;
|
|
22
21
|
export declare function getWorkspaceState(config: ADHDevConfig): {
|
|
23
22
|
workspaces: WorkspaceEntry[];
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DevServer — Auto-Implement Handlers
|
|
3
|
+
*
|
|
4
|
+
* Extracted from dev-server.ts for maintainability.
|
|
5
|
+
* Contains prompt builders (IDE + CLI), agent spawn logic,
|
|
6
|
+
* SSE streaming, and provider directory resolution for auto-implement.
|
|
7
|
+
*/
|
|
8
|
+
import type * as http from 'http';
|
|
9
|
+
import type { DevServerContext, ProviderCategory } from './dev-server-types.js';
|
|
10
|
+
type CliExerciseVerification = {
|
|
11
|
+
request?: Record<string, any>;
|
|
12
|
+
mustContainAny?: string[];
|
|
13
|
+
mustNotContainAny?: string[];
|
|
14
|
+
mustMatchAny?: string[];
|
|
15
|
+
mustNotMatchAny?: string[];
|
|
16
|
+
lastAssistantMustContainAny?: string[];
|
|
17
|
+
lastAssistantMustNotContainAny?: string[];
|
|
18
|
+
lastAssistantMustMatchAny?: string[];
|
|
19
|
+
lastAssistantMustNotMatchAny?: string[];
|
|
20
|
+
inspectFields?: string[];
|
|
21
|
+
description?: string;
|
|
22
|
+
focusAreas?: string[];
|
|
23
|
+
fixtureName?: string;
|
|
24
|
+
fixtureNames?: string[];
|
|
25
|
+
};
|
|
26
|
+
export declare function getDefaultAutoImplReference(ctx: DevServerContext, category: string, type: string): string;
|
|
27
|
+
export declare function resolveAutoImplReference(ctx: DevServerContext, category: string, requestedReference: string | undefined, targetType: string): string | null;
|
|
28
|
+
export declare function getLatestScriptVersionDir(scriptsDir: string): string | null;
|
|
29
|
+
export declare function resolveAutoImplWritableProviderDir(ctx: DevServerContext, category: ProviderCategory, type: string, requestedDir?: string): {
|
|
30
|
+
dir: string | null;
|
|
31
|
+
reason?: string;
|
|
32
|
+
};
|
|
33
|
+
export declare function loadAutoImplReferenceScripts(ctx: DevServerContext, referenceType: string | null): Record<string, string>;
|
|
34
|
+
export declare function handleAutoImplement(ctx: DevServerContext, type: string, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
35
|
+
export declare function buildAutoImplPrompt(ctx: DevServerContext, type: string, provider: any, providerDir: string, functions: string[], domContext: any, referenceScripts: Record<string, string>, userComment?: string, referenceType?: string | null, verification?: CliExerciseVerification): string;
|
|
36
|
+
export declare function buildCliAutoImplPrompt(ctx: DevServerContext, type: string, provider: any, providerDir: string, functions: string[], referenceScripts: Record<string, string>, userComment?: string, referenceType?: string | null, verification?: CliExerciseVerification): string;
|
|
37
|
+
export declare function handleAutoImplSSE(ctx: DevServerContext, type: string, req: http.IncomingMessage, res: http.ServerResponse): void;
|
|
38
|
+
export declare function handleAutoImplCancel(ctx: DevServerContext, _type: string, _req: http.IncomingMessage, res: http.ServerResponse): void;
|
|
39
|
+
export declare function sendAutoImplSSE(ctx: DevServerContext, msg: {
|
|
40
|
+
event: string;
|
|
41
|
+
data: any;
|
|
42
|
+
}): void;
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DevServer — CDP & DOM Handlers
|
|
3
|
+
*
|
|
4
|
+
* Extracted from dev-server.ts for maintainability.
|
|
5
|
+
*/
|
|
6
|
+
import type * as http from 'http';
|
|
7
|
+
import type { DevServerContext } from './dev-server-types.js';
|
|
8
|
+
export declare function handleCdpEvaluate(ctx: DevServerContext, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
9
|
+
export declare function handleCdpClick(ctx: DevServerContext, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
10
|
+
export declare function handleCdpDomQuery(ctx: DevServerContext, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
11
|
+
export declare function handleScreenshot(ctx: DevServerContext, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
12
|
+
export declare function handleScriptsRun(ctx: DevServerContext, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
13
|
+
export declare function handleTypeAndSend(ctx: DevServerContext, type: string, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
14
|
+
export declare function handleTypeAndSendAt(ctx: DevServerContext, type: string, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
15
|
+
export declare function handleScriptHints(ctx: DevServerContext, type: string, _req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
16
|
+
export declare function handleCdpTargets(ctx: DevServerContext, _req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
17
|
+
export declare function handleDomInspect(ctx: DevServerContext, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
18
|
+
export declare function handleDomChildren(ctx: DevServerContext, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
19
|
+
export declare function handleDomAnalyze(ctx: DevServerContext, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
20
|
+
export declare function handleFindCommon(ctx: DevServerContext, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
21
|
+
export declare function handleFindByText(ctx: DevServerContext, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
22
|
+
export declare function handleDomContext(ctx: DevServerContext, type: string, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DevServer — CLI Debug Handlers
|
|
3
|
+
*
|
|
4
|
+
* Extracted from dev-server.ts for maintainability.
|
|
5
|
+
* All functions take a DevServerContext as their first argument.
|
|
6
|
+
*/
|
|
7
|
+
import type * as http from 'http';
|
|
8
|
+
import type { DevServerContext } from './dev-server-types.js';
|
|
9
|
+
type CliExerciseRequest = {
|
|
10
|
+
type?: string;
|
|
11
|
+
text?: string;
|
|
12
|
+
instanceId?: string;
|
|
13
|
+
workingDir?: string;
|
|
14
|
+
args?: string[];
|
|
15
|
+
autoLaunch?: boolean;
|
|
16
|
+
freshSession?: boolean;
|
|
17
|
+
autoResolveApprovals?: boolean;
|
|
18
|
+
approvalButtonIndex?: number;
|
|
19
|
+
timeoutMs?: number;
|
|
20
|
+
readyTimeoutMs?: number;
|
|
21
|
+
idleSettledMs?: number;
|
|
22
|
+
traceLimit?: number;
|
|
23
|
+
stopWhenDone?: boolean;
|
|
24
|
+
};
|
|
25
|
+
export type CliFixtureAssertions = {
|
|
26
|
+
mustContainAny?: string[];
|
|
27
|
+
mustNotContainAny?: string[];
|
|
28
|
+
mustMatchAny?: string[];
|
|
29
|
+
mustNotMatchAny?: string[];
|
|
30
|
+
lastAssistantMustContainAny?: string[];
|
|
31
|
+
lastAssistantMustNotContainAny?: string[];
|
|
32
|
+
lastAssistantMustMatchAny?: string[];
|
|
33
|
+
lastAssistantMustNotMatchAny?: string[];
|
|
34
|
+
statusesSeen?: string[];
|
|
35
|
+
requireNotTimedOut?: boolean;
|
|
36
|
+
};
|
|
37
|
+
type CliExerciseFixture = {
|
|
38
|
+
version: 1;
|
|
39
|
+
kind: 'cli-exercise-fixture';
|
|
40
|
+
name: string;
|
|
41
|
+
type: string;
|
|
42
|
+
createdAt: string;
|
|
43
|
+
providerDir: string | null;
|
|
44
|
+
providerResolution: Record<string, any> | null;
|
|
45
|
+
request: CliExerciseRequest;
|
|
46
|
+
result: Record<string, any>;
|
|
47
|
+
assertions: CliFixtureAssertions;
|
|
48
|
+
notes?: string;
|
|
49
|
+
};
|
|
50
|
+
export declare function validateCliFixtureResult(result: any, assertions: CliFixtureAssertions): string[];
|
|
51
|
+
export declare function runCliExerciseInternal(ctx: DevServerContext, body: CliExerciseRequest): Promise<Record<string, any>>;
|
|
52
|
+
export declare function runCliAutoImplVerification(ctx: DevServerContext, type: string, verification?: {
|
|
53
|
+
request?: Record<string, any>;
|
|
54
|
+
mustContainAny?: string[];
|
|
55
|
+
mustNotContainAny?: string[];
|
|
56
|
+
mustMatchAny?: string[];
|
|
57
|
+
mustNotMatchAny?: string[];
|
|
58
|
+
lastAssistantMustContainAny?: string[];
|
|
59
|
+
lastAssistantMustNotContainAny?: string[];
|
|
60
|
+
lastAssistantMustMatchAny?: string[];
|
|
61
|
+
lastAssistantMustNotMatchAny?: string[];
|
|
62
|
+
fixtureName?: string;
|
|
63
|
+
fixtureNames?: string[];
|
|
64
|
+
}): Promise<{
|
|
65
|
+
mode: 'fixture_replay' | 'fixture_replay_suite' | 'exercise';
|
|
66
|
+
pass: boolean;
|
|
67
|
+
failures: string[];
|
|
68
|
+
result: Record<string, any>;
|
|
69
|
+
assertions: CliFixtureAssertions;
|
|
70
|
+
fixture?: CliExerciseFixture;
|
|
71
|
+
results?: Array<{
|
|
72
|
+
fixtureName: string;
|
|
73
|
+
pass: boolean;
|
|
74
|
+
failures: string[];
|
|
75
|
+
result: Record<string, any>;
|
|
76
|
+
assertions: CliFixtureAssertions;
|
|
77
|
+
fixture: CliExerciseFixture;
|
|
78
|
+
}>;
|
|
79
|
+
}>;
|
|
80
|
+
/** GET /api/cli/status — list all running CLI/ACP instances with state */
|
|
81
|
+
export declare function handleCliStatus(ctx: DevServerContext, _req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
82
|
+
/** POST /api/cli/launch — launch a CLI agent { type, workingDir?, args? } */
|
|
83
|
+
export declare function handleCliLaunch(ctx: DevServerContext, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
84
|
+
/** POST /api/cli/send — send message to a running CLI { type, text } */
|
|
85
|
+
export declare function handleCliSend(ctx: DevServerContext, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
86
|
+
/** POST /api/cli/stop — stop a running CLI { type } */
|
|
87
|
+
export declare function handleCliStop(ctx: DevServerContext, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
88
|
+
/** GET /api/cli/events — SSE stream of CLI status events */
|
|
89
|
+
export declare function handleCliSSE(ctx: DevServerContext, cliSSEClients: http.ServerResponse[], _req: http.IncomingMessage, res: http.ServerResponse): void;
|
|
90
|
+
/** GET /api/cli/debug/:type — full internal debug state of a CLI adapter */
|
|
91
|
+
export declare function handleCliDebug(ctx: DevServerContext, type: string, _req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
92
|
+
/** GET /api/cli/trace/:type — recent CLI trace timeline plus current debug snapshot */
|
|
93
|
+
export declare function handleCliTrace(ctx: DevServerContext, type: string, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
94
|
+
/** POST /api/cli/exercise — autonomously run a CLI repro and wait for final settled trace */
|
|
95
|
+
export declare function handleCliExercise(ctx: DevServerContext, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
96
|
+
/** POST /api/cli/fixture/capture — run exact exercise once and persist it as a reusable fixture */
|
|
97
|
+
export declare function handleCliFixtureCapture(ctx: DevServerContext, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
98
|
+
/** GET /api/cli/fixtures/:type — list saved exercise fixtures for a provider */
|
|
99
|
+
export declare function handleCliFixtureList(ctx: DevServerContext, type: string, _req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
100
|
+
/** POST /api/cli/fixture/replay — rerun a saved exact exercise and validate against saved assertions */
|
|
101
|
+
export declare function handleCliFixtureReplay(ctx: DevServerContext, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
102
|
+
/** POST /api/cli/resolve — resolve an approval modal { type, buttonIndex } */
|
|
103
|
+
export declare function handleCliResolve(ctx: DevServerContext, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
104
|
+
/** POST /api/cli/raw — send raw keystrokes to PTY { type, keys } */
|
|
105
|
+
export declare function handleCliRaw(ctx: DevServerContext, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
106
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types & context interface for DevServer handler modules.
|
|
3
|
+
*
|
|
4
|
+
* Each handler module (cdp, cli-debug, auto-implement) imports DevServerContext
|
|
5
|
+
* to access shared state and utilities without circular references.
|
|
6
|
+
*/
|
|
7
|
+
import type * as http from 'http';
|
|
8
|
+
import type { ProviderLoader } from '../providers/provider-loader.js';
|
|
9
|
+
import type { DaemonCdpManager } from '../cdp/manager.js';
|
|
10
|
+
import type { ProviderInstanceManager } from '../providers/provider-instance-manager.js';
|
|
11
|
+
import type { DaemonCliManager } from '../commands/cli-manager.js';
|
|
12
|
+
import type { ProviderCategory } from '../providers/contracts.js';
|
|
13
|
+
/**
|
|
14
|
+
* Context passed from the main DevServer to handler modules.
|
|
15
|
+
* Provides access to shared dependencies and utility methods.
|
|
16
|
+
*/
|
|
17
|
+
export interface DevServerContext {
|
|
18
|
+
readonly providerLoader: ProviderLoader;
|
|
19
|
+
readonly cdpManagers: Map<string, DaemonCdpManager>;
|
|
20
|
+
readonly instanceManager: ProviderInstanceManager | null;
|
|
21
|
+
readonly cliManager: DaemonCliManager | null;
|
|
22
|
+
getCdp(ideType?: string): DaemonCdpManager | null;
|
|
23
|
+
json(res: http.ServerResponse, status: number, data: any): void;
|
|
24
|
+
readBody(req: http.IncomingMessage): Promise<any>;
|
|
25
|
+
log(msg: string): void;
|
|
26
|
+
autoImplSSEClients: http.ServerResponse[];
|
|
27
|
+
sendAutoImplSSE(msg: {
|
|
28
|
+
event: string;
|
|
29
|
+
data: any;
|
|
30
|
+
}): void;
|
|
31
|
+
autoImplStatus: {
|
|
32
|
+
running: boolean;
|
|
33
|
+
type: string | null;
|
|
34
|
+
progress: any[];
|
|
35
|
+
};
|
|
36
|
+
autoImplProcess: import('child_process').ChildProcess | null;
|
|
37
|
+
sendCliSSE(data: any): void;
|
|
38
|
+
handleRunScript(type: string, req: http.IncomingMessage, res: http.ServerResponse, parsedBody?: any): Promise<void>;
|
|
39
|
+
findProviderDir(type: string): string | null;
|
|
40
|
+
getLatestScriptVersionDir(scriptsDir: string): string | null;
|
|
41
|
+
}
|
|
42
|
+
/** Re-export for convenience */
|
|
43
|
+
export type { ProviderCategory };
|