@adhdev/daemon-core 0.8.34 → 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
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DaemonCommandRouter — Unified command routing for daemon-level commands
|
|
3
|
+
*
|
|
4
|
+
* Unified command routing for daemon-level commands.
|
|
5
|
+
*
|
|
6
|
+
* Routing flow:
|
|
7
|
+
* 1. Daemon-level commands (launch_ide, stop_ide, restart_ide, etc.) → handled here
|
|
8
|
+
* 2. CLI/ACP commands → delegated to cliManager
|
|
9
|
+
* 3. Everything else → delegated to commandHandler.handle()
|
|
10
|
+
*/
|
|
11
|
+
import { DaemonCdpManager } from '../cdp/manager.js';
|
|
12
|
+
import { DaemonCommandHandler } from './handler.js';
|
|
13
|
+
import { DaemonCliManager } from './cli-manager.js';
|
|
14
|
+
import type { ProviderLoader } from '../providers/provider-loader.js';
|
|
15
|
+
import type { ProviderInstanceManager } from '../providers/provider-instance-manager.js';
|
|
16
|
+
import { SessionRegistry } from '../sessions/registry.js';
|
|
17
|
+
export interface SessionHostControlPlane {
|
|
18
|
+
getDiagnostics(payload?: {
|
|
19
|
+
includeSessions?: boolean;
|
|
20
|
+
limit?: number;
|
|
21
|
+
}): Promise<any>;
|
|
22
|
+
listSessions(): Promise<any[]>;
|
|
23
|
+
stopSession(sessionId: string): Promise<any>;
|
|
24
|
+
resumeSession(sessionId: string): Promise<any>;
|
|
25
|
+
restartSession(sessionId: string): Promise<any>;
|
|
26
|
+
sendSignal(sessionId: string, signal: string): Promise<any>;
|
|
27
|
+
forceDetachClient(sessionId: string, clientId: string): Promise<any>;
|
|
28
|
+
pruneDuplicateSessions(payload?: {
|
|
29
|
+
providerType?: string;
|
|
30
|
+
workspace?: string;
|
|
31
|
+
dryRun?: boolean;
|
|
32
|
+
}): Promise<any>;
|
|
33
|
+
acquireWrite(payload: {
|
|
34
|
+
sessionId: string;
|
|
35
|
+
clientId: string;
|
|
36
|
+
ownerType: 'agent' | 'user';
|
|
37
|
+
force?: boolean;
|
|
38
|
+
}): Promise<any>;
|
|
39
|
+
releaseWrite(payload: {
|
|
40
|
+
sessionId: string;
|
|
41
|
+
clientId: string;
|
|
42
|
+
}): Promise<any>;
|
|
43
|
+
}
|
|
44
|
+
export interface CommandRouterDeps {
|
|
45
|
+
commandHandler: DaemonCommandHandler;
|
|
46
|
+
cliManager: DaemonCliManager;
|
|
47
|
+
cdpManagers: Map<string, DaemonCdpManager>;
|
|
48
|
+
providerLoader: ProviderLoader;
|
|
49
|
+
instanceManager: ProviderInstanceManager;
|
|
50
|
+
/** Reference to detected IDEs array (mutable — router updates it) */
|
|
51
|
+
detectedIdes: {
|
|
52
|
+
value: any[];
|
|
53
|
+
};
|
|
54
|
+
sessionRegistry: SessionRegistry;
|
|
55
|
+
/** Callback for CDP manager creation after launch_ide */
|
|
56
|
+
onCdpManagerCreated?: (ideType: string, manager: DaemonCdpManager) => void;
|
|
57
|
+
/** Callback after IDE connected (e.g., startAgentStreamPolling) */
|
|
58
|
+
onIdeConnected?: () => void;
|
|
59
|
+
/** Callback after status change (stop_ide, restart) */
|
|
60
|
+
onStatusChange?: () => void;
|
|
61
|
+
/** Callback after chat-related commands */
|
|
62
|
+
onPostChatCommand?: () => void;
|
|
63
|
+
/** Get a connected CDP manager (for agent stream reset check) */
|
|
64
|
+
getCdpLogFn?: (ideType: string) => (msg: string) => void;
|
|
65
|
+
/** Package name for upgrade detection ('adhdev' or '@adhdev/daemon-standalone') */
|
|
66
|
+
packageName?: string;
|
|
67
|
+
/** Session host control plane */
|
|
68
|
+
sessionHostControl?: SessionHostControlPlane | null;
|
|
69
|
+
}
|
|
70
|
+
export interface CommandRouterResult {
|
|
71
|
+
success: boolean;
|
|
72
|
+
[key: string]: unknown;
|
|
73
|
+
}
|
|
74
|
+
export declare class DaemonCommandRouter {
|
|
75
|
+
private deps;
|
|
76
|
+
constructor(deps: CommandRouterDeps);
|
|
77
|
+
/**
|
|
78
|
+
* Unified command routing.
|
|
79
|
+
* Returns result for all commands:
|
|
80
|
+
* 1. Daemon-level commands (launch_ide, stop_ide, etc.)
|
|
81
|
+
* 2. CLI commands (launch_cli, stop_cli, agent_command)
|
|
82
|
+
* 3. DaemonCommandHandler delegation (CDP/agent-stream/file commands)
|
|
83
|
+
*
|
|
84
|
+
* @param cmd Command name
|
|
85
|
+
* @param args Command arguments
|
|
86
|
+
* @param source Log source ('ws' | 'p2p' | 'standalone' | etc.)
|
|
87
|
+
*/
|
|
88
|
+
execute(cmd: string, args: any, source?: string): Promise<CommandRouterResult>;
|
|
89
|
+
/**
|
|
90
|
+
* Daemon-level command execution (IDE start/stop/restart, CLI, detect, logs).
|
|
91
|
+
* Returns null if not handled at this level → caller delegates to CommandHandler.
|
|
92
|
+
*/
|
|
93
|
+
private executeDaemonCommand;
|
|
94
|
+
/**
|
|
95
|
+
* IDE stop: CDP disconnect + InstanceManager cleanup + optionally kill OS process
|
|
96
|
+
*/
|
|
97
|
+
private stopIde;
|
|
98
|
+
}
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -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 };
|