@adhdev/daemon-core 0.7.38 → 0.7.40
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/agent-stream/forward.d.ts +8 -0
- package/dist/agent-stream/index.d.ts +6 -0
- package/dist/agent-stream/manager.d.ts +59 -0
- package/dist/agent-stream/poller.d.ts +41 -0
- package/dist/agent-stream/provider-adapter.d.ts +29 -0
- package/dist/agent-stream/types.d.ts +62 -0
- package/dist/boot/daemon-lifecycle.d.ts +97 -0
- package/dist/cdp/devtools.d.ts +51 -0
- package/dist/cdp/initializer.d.ts +50 -0
- package/dist/cdp/manager.d.ts +145 -0
- package/dist/cdp/scanner.d.ts +58 -0
- package/dist/cdp/setup.d.ts +58 -0
- package/dist/cli-adapter-types.d.ts +25 -0
- package/dist/cli-adapters/provider-cli-adapter.d.ts +229 -0
- package/dist/cli-adapters/pty-transport.d.ts +43 -0
- package/dist/cli-adapters/session-host-transport.d.ts +19 -0
- package/dist/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +12 -0
- package/dist/cli-adapters/terminal-backends/types.d.ts +14 -0
- package/dist/cli-adapters/terminal-backends/xterm-backend.d.ts +13 -0
- package/dist/cli-adapters/terminal-screen.d.ts +27 -0
- package/dist/commands/cdp-commands.d.ts +15 -0
- package/dist/commands/chat-commands.d.ts +15 -0
- package/dist/commands/cli-manager.d.ts +82 -0
- package/dist/commands/handler.d.ts +101 -0
- package/dist/commands/router.d.ts +69 -0
- package/dist/commands/stream-commands.d.ts +13 -0
- package/dist/commands/workspace-commands.d.ts +11 -0
- package/dist/config/chat-history.d.ts +60 -0
- package/dist/config/config.d.ts +103 -0
- package/dist/config/recent-activity.d.ts +27 -0
- package/dist/config/workspaces.d.ts +82 -0
- package/dist/daemon/dev-auto-implement.d.ts +26 -0
- package/dist/daemon/dev-cdp-handlers.d.ts +22 -0
- package/dist/daemon/dev-cli-debug.d.ts +24 -0
- package/dist/daemon/dev-server-types.d.ts +43 -0
- package/dist/daemon/dev-server.d.ts +133 -0
- package/dist/daemon/scaffold-template.d.ts +32 -0
- package/dist/daemon-core.d.ts +36 -0
- package/dist/detection/cli-detector.d.ts +27 -0
- package/dist/detection/ide-detector.d.ts +34 -0
- package/dist/index.d.ts +72 -2499
- package/dist/index.js +673 -879
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +680 -884
- package/dist/index.mjs.map +1 -1
- package/dist/installer.d.ts +50 -0
- package/dist/ipc-protocol.d.ts +111 -0
- package/dist/launch.d.ts +46 -0
- package/dist/logging/command-log.d.ts +31 -0
- package/dist/logging/logger.d.ts +87 -0
- package/dist/providers/acp-provider-instance.d.ts +101 -0
- package/dist/providers/cli-provider-instance.d.ts +43 -0
- package/dist/providers/contracts.d.ts +483 -0
- package/dist/providers/extension-provider-instance.d.ts +44 -0
- package/dist/providers/ide-provider-instance.d.ts +61 -0
- package/dist/providers/index.d.ts +5 -0
- package/dist/providers/provider-instance-manager.d.ts +84 -0
- package/dist/providers/provider-instance.d.ts +148 -0
- package/dist/providers/provider-loader.d.ts +270 -0
- package/dist/providers/status-monitor.d.ts +48 -0
- package/dist/providers/version-archive.d.ts +52 -0
- package/dist/session-host/runtime-support.d.ts +8 -0
- package/dist/sessions/registry.d.ts +24 -0
- package/dist/shared-types-extra.d.ts +29 -0
- package/dist/shared-types.d.ts +205 -0
- package/dist/status/builders.d.ts +33 -0
- package/dist/status/normalize.d.ts +14 -1
- package/dist/status/reporter.d.ts +69 -0
- package/dist/status/snapshot.d.ts +51 -0
- package/dist/system/host-memory.d.ts +19 -0
- package/dist/types.d.ts +123 -0
- package/node_modules/@adhdev/session-host-core/package.json +1 -1
- package/package.json +3 -2
- package/src/commands/cli-manager.ts +1 -26
- package/src/commands/handler.ts +0 -31
- package/src/commands/router.ts +27 -34
- package/src/commands/stream-commands.ts +2 -4
- package/src/commands/workspace-commands.ts +9 -23
- package/src/config/config.ts +7 -81
- package/src/config/recent-activity.ts +24 -12
- package/src/config/workspaces.ts +0 -24
- package/src/index.ts +16 -15
- package/src/providers/provider-loader.ts +13 -5
- package/src/shared-types-extra.ts +34 -0
- package/src/shared-types.d.ts +4 -6
- package/src/shared-types.ts +17 -38
- package/src/status/builders.ts +12 -0
- package/src/status/reporter.ts +2 -1
- package/src/status/snapshot.ts +70 -87
- package/src/types.ts +3 -8
- package/dist/index.d.mts +0 -2504
- package/dist/normalize-DVI4Lo5I.d.mts +0 -947
- package/dist/normalize-DVI4Lo5I.d.ts +0 -947
- package/dist/status/normalize.d.mts +0 -1
- package/src/config/workspace-activity.ts +0 -65
|
@@ -0,0 +1,13 @@
|
|
|
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): CommandResult;
|
|
11
|
+
export declare function handleExtensionScript(h: CommandHelpers, args: any, scriptName: string): Promise<CommandResult>;
|
|
12
|
+
export declare function handleGetIdeExtensions(h: CommandHelpers, args: any): CommandResult;
|
|
13
|
+
export declare function handleSetIdeExtension(h: CommandHelpers, args: any): CommandResult;
|
|
@@ -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,60 @@
|
|
|
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
|
+
agent: string;
|
|
17
|
+
instanceId?: string;
|
|
18
|
+
sessionTitle?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare class ChatHistoryWriter {
|
|
21
|
+
/** Last seen message count per agent (deduplication) */
|
|
22
|
+
private lastSeenCounts;
|
|
23
|
+
/** Last seen message hash per agent (deduplication) */
|
|
24
|
+
private lastSeenHashes;
|
|
25
|
+
/** Last seen append-only terminal transcript per agent */
|
|
26
|
+
private lastSeenTerminal;
|
|
27
|
+
private rotated;
|
|
28
|
+
/**
|
|
29
|
+
* Append new messages to history
|
|
30
|
+
*
|
|
31
|
+
* @param agentType agent type (e.g. 'antigravity', 'cursor')
|
|
32
|
+
* @param messages Message array received from readChat
|
|
33
|
+
* @param sessionTitle Current session title
|
|
34
|
+
* @param instanceId IDE instance UUID (distinguishes windows of the same agent)
|
|
35
|
+
*/
|
|
36
|
+
appendNewMessages(agentType: string, messages: Array<{
|
|
37
|
+
role: string;
|
|
38
|
+
content: string;
|
|
39
|
+
receivedAt?: number;
|
|
40
|
+
}>, sessionTitle?: string, instanceId?: string): void;
|
|
41
|
+
appendTerminalHistory(agentType: string, terminalHistory: string, sessionTitle?: string, instanceId?: string): void;
|
|
42
|
+
/** Called when agent session is explicitly changed */
|
|
43
|
+
onSessionChange(agentType: string): void;
|
|
44
|
+
/** Delete history files older than 30 days */
|
|
45
|
+
private rotateOldFiles;
|
|
46
|
+
/** Allow only filename-safe characters */
|
|
47
|
+
private sanitize;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Read history (static — called from P2P commands)
|
|
51
|
+
*
|
|
52
|
+
* Read JSONL files in reverse order, returning most recent messages first.
|
|
53
|
+
* When instanceId is specified, reads only that instance file.
|
|
54
|
+
* Offset/limit-based paging.
|
|
55
|
+
*/
|
|
56
|
+
export declare function readChatHistory(agentType: string, offset?: number, limit?: number, instanceId?: string): {
|
|
57
|
+
messages: HistoryMessage[];
|
|
58
|
+
hasMore: boolean;
|
|
59
|
+
};
|
|
60
|
+
export {};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ADHDev Launcher — Configuration
|
|
3
|
+
*
|
|
4
|
+
* Manages launcher config, server connection tokens, and user preferences.
|
|
5
|
+
*/
|
|
6
|
+
import type { WorkspaceEntry } from './workspaces.js';
|
|
7
|
+
import type { RecentActivityEntry } from './recent-activity.js';
|
|
8
|
+
export type { WorkspaceEntry } from './workspaces.js';
|
|
9
|
+
export type { RecentActivityEntry } from './recent-activity.js';
|
|
10
|
+
export interface ADHDevConfig {
|
|
11
|
+
serverUrl: string;
|
|
12
|
+
apiToken: string | null;
|
|
13
|
+
connectionToken: string | null;
|
|
14
|
+
selectedIde: string | null;
|
|
15
|
+
configuredIdes: string[];
|
|
16
|
+
installedExtensions: string[];
|
|
17
|
+
autoConnect: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated Not read at runtime. Notification preferences are now managed by:
|
|
20
|
+
* - Web UI layer: useNotificationPrefs (localStorage)
|
|
21
|
+
* - Daemon layer: per-provider settings (approvalAlert, longGeneratingAlert)
|
|
22
|
+
* Kept for backward config compat — will be removed in v0.7+.
|
|
23
|
+
*/
|
|
24
|
+
notifications: boolean;
|
|
25
|
+
userEmail: string | null;
|
|
26
|
+
userName: string | null;
|
|
27
|
+
setupCompleted: boolean;
|
|
28
|
+
setupDate: string | null;
|
|
29
|
+
configuredCLIs: string[];
|
|
30
|
+
enabledIdes: string[];
|
|
31
|
+
/** Saved workspaces for IDE/CLI/ACP launch (daemon-local) */
|
|
32
|
+
workspaces?: WorkspaceEntry[];
|
|
33
|
+
/** Default workspace id (from workspaces[]) — never used implicitly for launch */
|
|
34
|
+
defaultWorkspaceId?: string | null;
|
|
35
|
+
/** Unified recent activity across IDE / CLI / ACP launch flows */
|
|
36
|
+
recentActivity?: RecentActivityEntry[];
|
|
37
|
+
/** Last seen timestamps for live sessions, keyed by sessionId */
|
|
38
|
+
sessionReads?: Record<string, number>;
|
|
39
|
+
/** Last seen completion marker for live sessions, keyed by sessionId */
|
|
40
|
+
sessionReadMarkers?: Record<string, string>;
|
|
41
|
+
machineNickname: string | null;
|
|
42
|
+
/**
|
|
43
|
+
* Stable local machine ID (prefix: `mach_`) — generated locally on first run.
|
|
44
|
+
* Used as daemon instance key (`daemon_<machineId>`) and in status reports.
|
|
45
|
+
* NOT the same as the server-side D1 `machines.id` — see `registeredMachineId`.
|
|
46
|
+
*/
|
|
47
|
+
machineId?: string;
|
|
48
|
+
machineSecret?: string | null;
|
|
49
|
+
/**
|
|
50
|
+
* Server-side D1 `machines.id` — the row ID assigned when daemon registers via
|
|
51
|
+
* `POST /cli/complete`. Corresponds to `machineId` in server DO context
|
|
52
|
+
* (`DaemonConnection.machineId`, `StatusContext.machineId`).
|
|
53
|
+
*
|
|
54
|
+
* Naming differs from server-side `machineId` to avoid confusion with the local
|
|
55
|
+
* `config.machineId` (mach_ prefix) which is a different value.
|
|
56
|
+
*
|
|
57
|
+
* @deprecated Legacy bridge field — will be removed after 2026-04-06.
|
|
58
|
+
* Modern auth flow uses `machineSecret` (adm_) to identify machines.
|
|
59
|
+
*/
|
|
60
|
+
registeredMachineId?: string;
|
|
61
|
+
providerSettings: Record<string, Record<string, any>>;
|
|
62
|
+
ideSettings: Record<string, {
|
|
63
|
+
extensions?: Record<string, {
|
|
64
|
+
enabled: boolean;
|
|
65
|
+
}>;
|
|
66
|
+
}>;
|
|
67
|
+
disableUpstream?: boolean;
|
|
68
|
+
providerDir?: string;
|
|
69
|
+
}
|
|
70
|
+
export declare function generateMachineId(): string;
|
|
71
|
+
export declare function isStableMachineId(machineId?: string | null): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Get the config directory path
|
|
74
|
+
*/
|
|
75
|
+
export declare function getConfigDir(): string;
|
|
76
|
+
/**
|
|
77
|
+
* Load configuration from disk
|
|
78
|
+
*/
|
|
79
|
+
export declare function loadConfig(): ADHDevConfig;
|
|
80
|
+
/**
|
|
81
|
+
* Save configuration to disk
|
|
82
|
+
*/
|
|
83
|
+
export declare function saveConfig(config: ADHDevConfig): void;
|
|
84
|
+
/**
|
|
85
|
+
* Update specific config fields
|
|
86
|
+
*/
|
|
87
|
+
export declare function updateConfig(updates: Partial<ADHDevConfig>): ADHDevConfig;
|
|
88
|
+
/**
|
|
89
|
+
* Mark setup as completed
|
|
90
|
+
*/
|
|
91
|
+
export declare function markSetupComplete(ideId: string | string[], extensions: string[]): ADHDevConfig;
|
|
92
|
+
/**
|
|
93
|
+
* Check if setup has been completed before
|
|
94
|
+
*/
|
|
95
|
+
export declare function isSetupComplete(): boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Reset configuration
|
|
98
|
+
*/
|
|
99
|
+
export declare function resetConfig(): void;
|
|
100
|
+
/**
|
|
101
|
+
* Generate a connection token for server authentication
|
|
102
|
+
*/
|
|
103
|
+
export declare function generateConnectionToken(): string;
|
|
@@ -0,0 +1,27 @@
|
|
|
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 kind + providerType + workspace
|
|
7
|
+
* - used only for quick-launch shortcuts
|
|
8
|
+
*/
|
|
9
|
+
import type { ADHDevConfig } from './config.js';
|
|
10
|
+
export interface RecentActivityEntry {
|
|
11
|
+
id: string;
|
|
12
|
+
kind: 'ide' | 'cli' | 'acp';
|
|
13
|
+
providerType: string;
|
|
14
|
+
providerName: string;
|
|
15
|
+
workspace?: string | null;
|
|
16
|
+
currentModel?: string;
|
|
17
|
+
title?: string;
|
|
18
|
+
lastUsedAt: number;
|
|
19
|
+
}
|
|
20
|
+
export declare function buildRecentActivityKey(entry: Pick<RecentActivityEntry, 'kind' | 'providerType' | 'workspace'>): string;
|
|
21
|
+
export declare function appendRecentActivity(config: ADHDevConfig, entry: Omit<RecentActivityEntry, 'id' | 'lastUsedAt'> & {
|
|
22
|
+
lastUsedAt?: number;
|
|
23
|
+
}): ADHDevConfig;
|
|
24
|
+
export declare function getRecentActivity(config: ADHDevConfig, limit?: number): RecentActivityEntry[];
|
|
25
|
+
export declare function getSessionSeenAt(config: ADHDevConfig, sessionId: string): number;
|
|
26
|
+
export declare function getSessionSeenMarker(config: ADHDevConfig, sessionId: string): string;
|
|
27
|
+
export declare function markSessionSeen(config: ADHDevConfig, sessionId: string, seenAt?: number, completionMarker?: string | null): ADHDevConfig;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Saved workspaces — shared by IDE launch, CLI, ACP (daemon-local).
|
|
3
|
+
*/
|
|
4
|
+
import type { ADHDevConfig } from './config.js';
|
|
5
|
+
export interface WorkspaceEntry {
|
|
6
|
+
id: string;
|
|
7
|
+
path: string;
|
|
8
|
+
label?: string;
|
|
9
|
+
addedAt: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function expandPath(p: string): string;
|
|
12
|
+
export declare function validateWorkspacePath(absPath: string): {
|
|
13
|
+
ok: true;
|
|
14
|
+
} | {
|
|
15
|
+
ok: false;
|
|
16
|
+
error: string;
|
|
17
|
+
};
|
|
18
|
+
/** Default workspace label from path */
|
|
19
|
+
export declare function defaultWorkspaceLabel(absPath: string): string;
|
|
20
|
+
export declare function getDefaultWorkspacePath(config: ADHDevConfig): string | null;
|
|
21
|
+
export declare function getWorkspaceState(config: ADHDevConfig): {
|
|
22
|
+
workspaces: WorkspaceEntry[];
|
|
23
|
+
defaultWorkspaceId: string | null;
|
|
24
|
+
defaultWorkspacePath: string | null;
|
|
25
|
+
};
|
|
26
|
+
export type LaunchDirectorySource = 'dir' | 'workspaceId' | 'defaultWorkspace' | 'home';
|
|
27
|
+
export type ResolveLaunchDirectoryResult = {
|
|
28
|
+
ok: true;
|
|
29
|
+
path: string;
|
|
30
|
+
source: LaunchDirectorySource;
|
|
31
|
+
} | {
|
|
32
|
+
ok: false;
|
|
33
|
+
code: 'WORKSPACE_LAUNCH_CONTEXT_REQUIRED';
|
|
34
|
+
message: string;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Resolve cwd for CLI/ACP. No implicit default workspace or home — caller must pass
|
|
38
|
+
* useDefaultWorkspace or useHome (or an explicit dir / workspaceId).
|
|
39
|
+
*/
|
|
40
|
+
export declare function resolveLaunchDirectory(args: {
|
|
41
|
+
dir?: string;
|
|
42
|
+
workspaceId?: string;
|
|
43
|
+
useDefaultWorkspace?: boolean;
|
|
44
|
+
useHome?: boolean;
|
|
45
|
+
} | undefined, config: ADHDevConfig): ResolveLaunchDirectoryResult;
|
|
46
|
+
/**
|
|
47
|
+
* IDE folder from explicit args only (`workspace`, `workspaceId`, or `useDefaultWorkspace: true`).
|
|
48
|
+
*/
|
|
49
|
+
export declare function resolveIdeWorkspaceFromArgs(args: {
|
|
50
|
+
workspace?: string;
|
|
51
|
+
workspaceId?: string;
|
|
52
|
+
useDefaultWorkspace?: boolean;
|
|
53
|
+
} | undefined, config: ADHDevConfig): string | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* IDE launch folder — same saved workspaces + default as CLI/ACP.
|
|
56
|
+
* After explicit `workspace` / `workspaceId` / `useDefaultWorkspace: true`, falls back to
|
|
57
|
+
* config default workspace when set. Pass `useDefaultWorkspace: false` to open IDE without that folder.
|
|
58
|
+
*/
|
|
59
|
+
export declare function resolveIdeLaunchWorkspace(args: {
|
|
60
|
+
workspace?: string;
|
|
61
|
+
workspaceId?: string;
|
|
62
|
+
useDefaultWorkspace?: boolean;
|
|
63
|
+
} | undefined, config: ADHDevConfig): string | undefined;
|
|
64
|
+
export declare function findWorkspaceByPath(config: ADHDevConfig, rawPath: string): WorkspaceEntry | undefined;
|
|
65
|
+
export declare function addWorkspaceEntry(config: ADHDevConfig, rawPath: string, label?: string, options?: {
|
|
66
|
+
createIfMissing?: boolean;
|
|
67
|
+
}): {
|
|
68
|
+
config: ADHDevConfig;
|
|
69
|
+
entry: WorkspaceEntry;
|
|
70
|
+
} | {
|
|
71
|
+
error: string;
|
|
72
|
+
};
|
|
73
|
+
export declare function removeWorkspaceEntry(config: ADHDevConfig, id: string): {
|
|
74
|
+
config: ADHDevConfig;
|
|
75
|
+
} | {
|
|
76
|
+
error: string;
|
|
77
|
+
};
|
|
78
|
+
export declare function setDefaultWorkspaceId(config: ADHDevConfig, id: string | null): {
|
|
79
|
+
config: ADHDevConfig;
|
|
80
|
+
} | {
|
|
81
|
+
error: string;
|
|
82
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
export declare function getDefaultAutoImplReference(ctx: DevServerContext, category: string, type: string): string;
|
|
11
|
+
export declare function resolveAutoImplReference(ctx: DevServerContext, category: string, requestedReference: string | undefined, targetType: string): string | null;
|
|
12
|
+
export declare function getLatestScriptVersionDir(scriptsDir: string): string | null;
|
|
13
|
+
export declare function resolveAutoImplWritableProviderDir(ctx: DevServerContext, category: ProviderCategory, type: string, requestedDir?: string): {
|
|
14
|
+
dir: string | null;
|
|
15
|
+
reason?: string;
|
|
16
|
+
};
|
|
17
|
+
export declare function loadAutoImplReferenceScripts(ctx: DevServerContext, referenceType: string | null): Record<string, string>;
|
|
18
|
+
export declare function handleAutoImplement(ctx: DevServerContext, type: string, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
19
|
+
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): string;
|
|
20
|
+
export declare function buildCliAutoImplPrompt(ctx: DevServerContext, type: string, provider: any, providerDir: string, functions: string[], referenceScripts: Record<string, string>, userComment?: string, referenceType?: string | null): string;
|
|
21
|
+
export declare function handleAutoImplSSE(ctx: DevServerContext, type: string, req: http.IncomingMessage, res: http.ServerResponse): void;
|
|
22
|
+
export declare function handleAutoImplCancel(ctx: DevServerContext, _type: string, _req: http.IncomingMessage, res: http.ServerResponse): void;
|
|
23
|
+
export declare function sendAutoImplSSE(ctx: DevServerContext, msg: {
|
|
24
|
+
event: string;
|
|
25
|
+
data: any;
|
|
26
|
+
}): void;
|
|
@@ -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,24 @@
|
|
|
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
|
+
/** GET /api/cli/status — list all running CLI/ACP instances with state */
|
|
10
|
+
export declare function handleCliStatus(ctx: DevServerContext, _req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
11
|
+
/** POST /api/cli/launch — launch a CLI agent { type, workingDir?, args? } */
|
|
12
|
+
export declare function handleCliLaunch(ctx: DevServerContext, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
13
|
+
/** POST /api/cli/send — send message to a running CLI { type, text } */
|
|
14
|
+
export declare function handleCliSend(ctx: DevServerContext, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
15
|
+
/** POST /api/cli/stop — stop a running CLI { type } */
|
|
16
|
+
export declare function handleCliStop(ctx: DevServerContext, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
17
|
+
/** GET /api/cli/events — SSE stream of CLI status events */
|
|
18
|
+
export declare function handleCliSSE(ctx: DevServerContext, cliSSEClients: http.ServerResponse[], _req: http.IncomingMessage, res: http.ServerResponse): void;
|
|
19
|
+
/** GET /api/cli/debug/:type — full internal debug state of a CLI adapter */
|
|
20
|
+
export declare function handleCliDebug(ctx: DevServerContext, type: string, _req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
21
|
+
/** POST /api/cli/resolve — resolve an approval modal { type, buttonIndex } */
|
|
22
|
+
export declare function handleCliResolve(ctx: DevServerContext, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
23
|
+
/** POST /api/cli/raw — send raw keystrokes to PTY { type, keys } */
|
|
24
|
+
export declare function handleCliRaw(ctx: DevServerContext, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
@@ -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 };
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import type { DevServerContext } from './dev-server-types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Dev Server — HTTP API for Provider debugging + script development
|
|
4
|
+
*
|
|
5
|
+
* Enabled with `adhdev daemon --dev`
|
|
6
|
+
* Port: 19280 (fixed)
|
|
7
|
+
*
|
|
8
|
+
* API list:
|
|
9
|
+
* GET /api/providers — loaded provider list
|
|
10
|
+
* POST /api/providers/:type/script — specific script execute
|
|
11
|
+
* POST /api/cdp/evaluate — Execute JS expression
|
|
12
|
+
* POST /api/cdp/dom/query — Test selector
|
|
13
|
+
* GET /api/cdp/screenshot — screenshot
|
|
14
|
+
* POST /api/scripts/run — Execute provider script (name + params)
|
|
15
|
+
* GET /api/status — All status (CDP connection, provider etc)
|
|
16
|
+
*/
|
|
17
|
+
import * as http from 'http';
|
|
18
|
+
import type { ProviderLoader } from '../providers/provider-loader.js';
|
|
19
|
+
import type { ChildProcess } from 'child_process';
|
|
20
|
+
import type { DaemonCdpManager } from '../cdp/manager.js';
|
|
21
|
+
import type { ProviderInstanceManager } from '../providers/provider-instance-manager.js';
|
|
22
|
+
import type { DaemonCliManager } from '../commands/cli-manager.js';
|
|
23
|
+
export declare const DEV_SERVER_PORT = 19280;
|
|
24
|
+
export declare class DevServer implements DevServerContext {
|
|
25
|
+
private server;
|
|
26
|
+
providerLoader: ProviderLoader;
|
|
27
|
+
cdpManagers: Map<string, DaemonCdpManager>;
|
|
28
|
+
instanceManager: ProviderInstanceManager | null;
|
|
29
|
+
cliManager: DaemonCliManager | null;
|
|
30
|
+
private logFn;
|
|
31
|
+
private sseClients;
|
|
32
|
+
private watchScriptPath;
|
|
33
|
+
private watchScriptName;
|
|
34
|
+
private watchTimer;
|
|
35
|
+
autoImplProcess: ChildProcess | null;
|
|
36
|
+
autoImplSSEClients: http.ServerResponse[];
|
|
37
|
+
autoImplStatus: {
|
|
38
|
+
running: boolean;
|
|
39
|
+
type: string | null;
|
|
40
|
+
progress: any[];
|
|
41
|
+
};
|
|
42
|
+
private cliSSEClients;
|
|
43
|
+
constructor(options: {
|
|
44
|
+
providerLoader: ProviderLoader;
|
|
45
|
+
cdpManagers: Map<string, DaemonCdpManager>;
|
|
46
|
+
instanceManager?: ProviderInstanceManager;
|
|
47
|
+
cliManager?: DaemonCliManager;
|
|
48
|
+
logFn?: (msg: string) => void;
|
|
49
|
+
});
|
|
50
|
+
log(msg: string): void;
|
|
51
|
+
private readonly routes;
|
|
52
|
+
private matchRoute;
|
|
53
|
+
private getEndpointList;
|
|
54
|
+
start(port?: number): Promise<void>;
|
|
55
|
+
stop(): void;
|
|
56
|
+
private handleListProviders;
|
|
57
|
+
private handleProviderConfig;
|
|
58
|
+
private handleSpawnTest;
|
|
59
|
+
handleRunScript(type: string, req: http.IncomingMessage, res: http.ServerResponse, parsedBody?: any): Promise<void>;
|
|
60
|
+
private handleCdpEvaluate;
|
|
61
|
+
private handleCdpClick;
|
|
62
|
+
private handleCdpDomQuery;
|
|
63
|
+
private handleScreenshot;
|
|
64
|
+
private handleScriptsRun;
|
|
65
|
+
private handleStatus;
|
|
66
|
+
private handleReload;
|
|
67
|
+
private getConsoleDistDir;
|
|
68
|
+
private serveConsole;
|
|
69
|
+
private static MIME_MAP;
|
|
70
|
+
private serveStaticAsset;
|
|
71
|
+
private handleSSE;
|
|
72
|
+
private sendSSE;
|
|
73
|
+
private handleWatchStart;
|
|
74
|
+
private handleWatchStop;
|
|
75
|
+
/** Find the provider directory on disk */
|
|
76
|
+
findProviderDir(type: string): string | null;
|
|
77
|
+
/** GET /api/providers/:type/files — list all files in provider directory */
|
|
78
|
+
private handleListFiles;
|
|
79
|
+
/** GET /api/providers/:type/file?path=scripts.js — read a file */
|
|
80
|
+
private handleReadFile;
|
|
81
|
+
/** POST /api/providers/:type/file — write a file { path, content } */
|
|
82
|
+
private handleWriteFile;
|
|
83
|
+
private handleSource;
|
|
84
|
+
private handleSave;
|
|
85
|
+
private handleTypeAndSend;
|
|
86
|
+
private handleTypeAndSendAt;
|
|
87
|
+
private handleScriptHints;
|
|
88
|
+
private handleValidate;
|
|
89
|
+
private handleAcpChat;
|
|
90
|
+
private handleCdpTargets;
|
|
91
|
+
private handleScaffold;
|
|
92
|
+
private handleDetectVersions;
|
|
93
|
+
private handleDomInspect;
|
|
94
|
+
private handleDomChildren;
|
|
95
|
+
private handleDomAnalyze;
|
|
96
|
+
private handleFindCommon;
|
|
97
|
+
private handleFindByText;
|
|
98
|
+
private handleDomContext;
|
|
99
|
+
getLatestScriptVersionDir(scriptsDir: string): string | null;
|
|
100
|
+
private resolveAutoImplWritableProviderDir;
|
|
101
|
+
private handleAutoImplement;
|
|
102
|
+
private buildAutoImplPrompt;
|
|
103
|
+
private buildCliAutoImplPrompt;
|
|
104
|
+
private handleAutoImplSSE;
|
|
105
|
+
private handleAutoImplCancel;
|
|
106
|
+
sendAutoImplSSE(msg: {
|
|
107
|
+
event: string;
|
|
108
|
+
data: any;
|
|
109
|
+
}): void;
|
|
110
|
+
/** Get CDP manager — matching IDE when ideType specified, first connected one otherwise.
|
|
111
|
+
* DevServer is a debugging tool so first-connected fallback is acceptable,
|
|
112
|
+
* but callers should pass ideType when possible. */
|
|
113
|
+
getCdp(ideType?: string): DaemonCdpManager | null;
|
|
114
|
+
json(res: http.ServerResponse, status: number, data: any): void;
|
|
115
|
+
readBody(req: http.IncomingMessage): Promise<any>;
|
|
116
|
+
/** GET /api/cli/status — list all running CLI/ACP instances with state */
|
|
117
|
+
private handleCliStatus;
|
|
118
|
+
/** POST /api/cli/launch — launch a CLI agent { type, workingDir?, args? } */
|
|
119
|
+
private handleCliLaunch;
|
|
120
|
+
/** POST /api/cli/send — send message to a running CLI { type, text } */
|
|
121
|
+
private handleCliSend;
|
|
122
|
+
/** POST /api/cli/stop — stop a running CLI { type } */
|
|
123
|
+
private handleCliStop;
|
|
124
|
+
/** GET /api/cli/events — SSE stream of CLI status events */
|
|
125
|
+
private handleCliSSE;
|
|
126
|
+
sendCliSSE(data: any): void;
|
|
127
|
+
/** GET /api/cli/debug/:type — full internal debug state of a CLI adapter */
|
|
128
|
+
private handleCliDebug;
|
|
129
|
+
/** POST /api/cli/resolve — resolve an approval modal { type, buttonIndex } */
|
|
130
|
+
private handleCliResolve;
|
|
131
|
+
/** POST /api/cli/raw — send raw keystrokes to PTY { type, keys } */
|
|
132
|
+
private handleCliRaw;
|
|
133
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider scaffold template generator
|
|
3
|
+
* Generates provider.json + scripts/ directory structure (Antigravity pattern).
|
|
4
|
+
*
|
|
5
|
+
* New pattern:
|
|
6
|
+
* - Scripts WITHOUT params: self-invoking IIFE — (() => { ... })()
|
|
7
|
+
* - Scripts WITH params: function expression — (params) => { ... }
|
|
8
|
+
* Router invokes: `(${script})(${JSON.stringify(params)})`
|
|
9
|
+
* - Each function is a separate .js file in scripts/<version>/
|
|
10
|
+
* - scripts.js router loads + invokes individual files
|
|
11
|
+
*/
|
|
12
|
+
export interface ScaffoldOptions {
|
|
13
|
+
cdpPorts?: [number, number];
|
|
14
|
+
cli?: string;
|
|
15
|
+
processName?: string;
|
|
16
|
+
installPath?: string;
|
|
17
|
+
binary?: string;
|
|
18
|
+
extensionId?: string;
|
|
19
|
+
version?: string;
|
|
20
|
+
osPaths?: Record<string, string[]>;
|
|
21
|
+
processNames?: Record<string, string>;
|
|
22
|
+
}
|
|
23
|
+
export interface ScaffoldResult {
|
|
24
|
+
'provider.json': string;
|
|
25
|
+
files?: Record<string, string>;
|
|
26
|
+
}
|
|
27
|
+
export declare function generateTemplate(type: string, name: string, category: string, opts?: ScaffoldOptions): string;
|
|
28
|
+
/**
|
|
29
|
+
* Generate provider.json + per-function script files.
|
|
30
|
+
* Returns a map of relative paths -> file contents.
|
|
31
|
+
*/
|
|
32
|
+
export declare function generateFiles(type: string, name: string, category: string, opts?: ScaffoldOptions): ScaffoldResult;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DaemonCore — Core daemon orchestrator interface
|
|
3
|
+
*
|
|
4
|
+
* Provides the core daemon orchestrator interface consumed by daemon-standalone.
|
|
5
|
+
* Actual implementation extracted from launcher and placed in this package.
|
|
6
|
+
*/
|
|
7
|
+
import type { StatusResponse, CommandResult, DaemonEvent } from './types.js';
|
|
8
|
+
import type { SessionEntry } from './shared-types.js';
|
|
9
|
+
export interface DaemonCoreOptions {
|
|
10
|
+
/** Data directory for config, logs */
|
|
11
|
+
dataDir?: string;
|
|
12
|
+
/** Custom provider directories */
|
|
13
|
+
providerDirs?: string[];
|
|
14
|
+
/** Enable/disable specific detectors */
|
|
15
|
+
enableIdeDetection?: boolean;
|
|
16
|
+
enableCliDetection?: boolean;
|
|
17
|
+
enableAcpDetection?: boolean;
|
|
18
|
+
/** Status report interval (ms) */
|
|
19
|
+
statusInterval?: number;
|
|
20
|
+
}
|
|
21
|
+
export interface IDaemonCore {
|
|
22
|
+
/** Initialize and start the daemon core */
|
|
23
|
+
start(): Promise<void>;
|
|
24
|
+
/** Gracefully stop the daemon */
|
|
25
|
+
stop(): Promise<void>;
|
|
26
|
+
/** Get current daemon status snapshot */
|
|
27
|
+
getStatus(): StatusResponse;
|
|
28
|
+
/** Subscribe to status changes. Returns unsubscribe function. */
|
|
29
|
+
onStatusChange(callback: (status: StatusResponse) => void): () => void;
|
|
30
|
+
/** Subscribe to all daemon events. Returns unsubscribe function. */
|
|
31
|
+
onEvent(callback: (event: DaemonEvent) => void): () => void;
|
|
32
|
+
/** Execute a command (send_chat, new_session, etc.) */
|
|
33
|
+
executeCommand(type: string, payload: any, target?: string): Promise<CommandResult>;
|
|
34
|
+
/** Get current canonical runtime sessions */
|
|
35
|
+
getSessions(): SessionEntry[];
|
|
36
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI AI Agent Detector
|
|
3
|
+
*
|
|
4
|
+
* Dynamic CLI detection based on Provider.
|
|
5
|
+
* Reads spawn.command from cli/acp categories via ProviderLoader to check installation.
|
|
6
|
+
*
|
|
7
|
+
* Uses parallel execution for fast detection across many providers.
|
|
8
|
+
*/
|
|
9
|
+
import type { ProviderLoader } from '../providers/provider-loader.js';
|
|
10
|
+
export interface CLIInfo {
|
|
11
|
+
id: string;
|
|
12
|
+
displayName: string;
|
|
13
|
+
icon: string;
|
|
14
|
+
command: string;
|
|
15
|
+
versionCommand?: string;
|
|
16
|
+
installed: boolean;
|
|
17
|
+
version?: string;
|
|
18
|
+
path?: string;
|
|
19
|
+
category?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Detect all CLI/ACP agents (parallel)
|
|
23
|
+
* @param providerLoader ProviderLoader instance (dynamic list creation)
|
|
24
|
+
*/
|
|
25
|
+
export declare function detectCLIs(providerLoader?: ProviderLoader): Promise<CLIInfo[]>;
|
|
26
|
+
/** Detect specific CLI */
|
|
27
|
+
export declare function detectCLI(cliId: string, providerLoader?: ProviderLoader): Promise<CLIInfo | null>;
|