@adhdev/daemon-core 0.7.38 → 0.7.39
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 +101 -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 +458 -637
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +465 -642
- 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 +213 -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 +38 -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 +1 -18
- package/src/commands/stream-commands.ts +2 -4
- package/src/commands/workspace-commands.ts +9 -23
- package/src/config/config.ts +1 -78
- 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.ts +14 -27
- package/src/status/builders.ts +12 -0
- package/src/status/reporter.ts +1 -0
- package/src/status/snapshot.ts +26 -13
- 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
package/dist/index.d.ts
CHANGED
|
@@ -1,2504 +1,77 @@
|
|
|
1
|
-
import { S as StatusResponse, D as DaemonEvent, C as CommandResult$2, a as SessionEntry, P as ProviderCategory, b as ProviderModule, R as ResolvedProvider, c as ProviderSettingSchema, d as CdpTargetFilter, e as ProviderInstance, I as InstanceContext, f as ProviderState, g as ProviderEvent, h as SessionTransport, i as StatusReportPayload, A as AvailableProviderInfo, j as ProviderResumeCapability, k as AcpProviderState, l as ContentBlock } from './normalize-DVI4Lo5I.js';
|
|
2
|
-
export { m as AcpConfigOption, n as AcpMode, o as ActiveChatData, p as AgentEntry, q as AgentSessionStream, r as ChatMessage, s as CliProviderState, t as DetectedIde, u as DetectedIdeInfo, E as ExtensionInfo, v as ExtensionProviderState, w as IdeProviderState, M as MachineInfo, x as ManagedStatus, y as ProviderConfig, z as ProviderControlSchema, B as ProviderErrorReason, F as ProviderInfo, G as ProviderStatus, H as RecentActivityEntry, J as SessionCapability, K as SessionKind, L as SystemInfo, W as WorkspaceActivity, N as WorkspaceEntry, O as addCliHistory, Q as appendRecentActivity, T as getRecentActivity, U as getWorkspaceActivity, V as getWorkspaceState, X as isManagedStatusWaiting, Y as isManagedStatusWorking, Z as isSetupComplete, _ as loadConfig, $ as markSetupComplete, a0 as normalizeActiveChatData, a1 as normalizeManagedStatus, a2 as resetConfig, a3 as saveConfig, a4 as updateConfig } from './normalize-DVI4Lo5I.js';
|
|
3
|
-
import * as child_process from 'child_process';
|
|
4
|
-
import { ChildProcess } from 'child_process';
|
|
5
|
-
import * as http from 'http';
|
|
6
|
-
import { SessionHostEndpoint, SessionHostCategory } from '@adhdev/session-host-core';
|
|
7
|
-
export { SessionHostEndpoint } from '@adhdev/session-host-core';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* DaemonCore — Core daemon orchestrator interface
|
|
11
|
-
*
|
|
12
|
-
* Provides the core daemon orchestrator interface consumed by daemon-standalone.
|
|
13
|
-
* Actual implementation extracted from launcher and placed in this package.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
interface DaemonCoreOptions {
|
|
17
|
-
/** Data directory for config, logs */
|
|
18
|
-
dataDir?: string;
|
|
19
|
-
/** Custom provider directories */
|
|
20
|
-
providerDirs?: string[];
|
|
21
|
-
/** Enable/disable specific detectors */
|
|
22
|
-
enableIdeDetection?: boolean;
|
|
23
|
-
enableCliDetection?: boolean;
|
|
24
|
-
enableAcpDetection?: boolean;
|
|
25
|
-
/** Status report interval (ms) */
|
|
26
|
-
statusInterval?: number;
|
|
27
|
-
}
|
|
28
|
-
interface IDaemonCore {
|
|
29
|
-
/** Initialize and start the daemon core */
|
|
30
|
-
start(): Promise<void>;
|
|
31
|
-
/** Gracefully stop the daemon */
|
|
32
|
-
stop(): Promise<void>;
|
|
33
|
-
/** Get current daemon status snapshot */
|
|
34
|
-
getStatus(): StatusResponse;
|
|
35
|
-
/** Subscribe to status changes. Returns unsubscribe function. */
|
|
36
|
-
onStatusChange(callback: (status: StatusResponse) => void): () => void;
|
|
37
|
-
/** Subscribe to all daemon events. Returns unsubscribe function. */
|
|
38
|
-
onEvent(callback: (event: DaemonEvent) => void): () => void;
|
|
39
|
-
/** Execute a command (send_chat, new_session, etc.) */
|
|
40
|
-
executeCommand(type: string, payload: any, target?: string): Promise<CommandResult$2>;
|
|
41
|
-
/** Get current canonical runtime sessions */
|
|
42
|
-
getSessions(): SessionEntry[];
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* ADHDev — IDE Detector (canonical implementation)
|
|
47
|
-
*
|
|
48
|
-
* Detects installed IDEs on the user's local machine.
|
|
49
|
-
* Supports macOS, Windows, and Linux.
|
|
50
|
-
*
|
|
51
|
-
* Migrated from @adhdev/core — this is now the single source of truth.
|
|
52
|
-
*/
|
|
53
|
-
interface IDEInfo {
|
|
54
|
-
id: string;
|
|
55
|
-
name: string;
|
|
56
|
-
displayName: string;
|
|
57
|
-
installed: boolean;
|
|
58
|
-
path: string | null;
|
|
59
|
-
cliCommand: string | null;
|
|
60
|
-
version: string | null;
|
|
61
|
-
icon: string;
|
|
62
|
-
notes?: string;
|
|
63
|
-
}
|
|
64
|
-
declare function detectIDEs(): Promise<IDEInfo[]>;
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Provider Version Detection & Archiving
|
|
68
|
-
*
|
|
69
|
-
* Detects installed versions for all provider categories (IDE, CLI, ACP, Extension).
|
|
70
|
-
* Archives version history to ~/.adhdev/version-history.json for compatibility tracking.
|
|
71
|
-
*
|
|
72
|
-
* Usage:
|
|
73
|
-
* const archive = new VersionArchive();
|
|
74
|
-
* const results = await detectAllVersions(providerLoader, archive);
|
|
75
|
-
*/
|
|
76
|
-
|
|
77
|
-
interface ProviderVersionInfo {
|
|
78
|
-
type: string;
|
|
79
|
-
name: string;
|
|
80
|
-
category: string;
|
|
81
|
-
installed: boolean;
|
|
82
|
-
version: string | null;
|
|
83
|
-
path: string | null;
|
|
84
|
-
binary: string | null;
|
|
85
|
-
detectedAt: string;
|
|
86
|
-
/**
|
|
87
|
-
* Set when the detected version is NOT listed in provider.json testedVersions.
|
|
88
|
-
* Means scripts may not work correctly with this version.
|
|
89
|
-
*/
|
|
90
|
-
warning?: string;
|
|
91
|
-
}
|
|
92
|
-
interface VersionHistoryEntry {
|
|
93
|
-
version: string;
|
|
94
|
-
detectedAt: string;
|
|
95
|
-
os: string;
|
|
96
|
-
}
|
|
97
|
-
interface VersionHistory {
|
|
98
|
-
[providerType: string]: VersionHistoryEntry[];
|
|
99
|
-
}
|
|
100
|
-
declare class VersionArchive {
|
|
101
|
-
private history;
|
|
102
|
-
constructor();
|
|
103
|
-
private load;
|
|
104
|
-
/** Record a detected version (deduplicates same version) */
|
|
105
|
-
record(type: string, version: string): void;
|
|
106
|
-
/** Get version history for a provider */
|
|
107
|
-
getHistory(type: string): VersionHistoryEntry[];
|
|
108
|
-
/** Get latest known version for a provider */
|
|
109
|
-
getLatest(type: string): string | null;
|
|
110
|
-
/** Get full archive */
|
|
111
|
-
getAll(): VersionHistory;
|
|
112
|
-
private save;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Detect versions for all loaded providers
|
|
116
|
-
*/
|
|
117
|
-
declare function detectAllVersions(loader: ProviderLoader, archive?: VersionArchive): Promise<ProviderVersionInfo[]>;
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* ProviderLoader — Provider discovery + OS/version override resolution
|
|
121
|
-
*
|
|
122
|
-
* Role:
|
|
123
|
-
* 1. Load providers from upstream auto-download (~/.adhdev/providers/.upstream/)
|
|
124
|
-
* 2. Load user custom from ~/.adhdev/providers/ (overrides)
|
|
125
|
-
* 3. Apply OS/version overrides (process.platform + detected IDE version)
|
|
126
|
-
* 4. Hot-reload support (fs.watch)
|
|
127
|
-
*
|
|
128
|
-
* Design principles:
|
|
129
|
-
* - Load JS files via require() (CJS compatible)
|
|
130
|
-
* - User custom can override builtin
|
|
131
|
-
* - provider.js files are independent, so load order doesn't matter
|
|
132
|
-
*/
|
|
133
|
-
|
|
134
|
-
declare class ProviderLoader {
|
|
135
|
-
private providers;
|
|
136
|
-
private userDir;
|
|
137
|
-
private upstreamDir;
|
|
138
|
-
private disableUpstream;
|
|
139
|
-
private watchers;
|
|
140
|
-
private logFn;
|
|
141
|
-
private versionArchive;
|
|
142
|
-
private scriptsCache;
|
|
143
|
-
/** Inject VersionArchive so resolve() can auto-detect installed versions */
|
|
144
|
-
setVersionArchive(archive: VersionArchive): void;
|
|
145
|
-
private static readonly GITHUB_TARBALL_URL;
|
|
146
|
-
private static readonly META_FILE;
|
|
147
|
-
constructor(options?: {
|
|
148
|
-
userDir?: string;
|
|
149
|
-
logFn?: (msg: string) => void;
|
|
150
|
-
/** Disable upstream auto-download (for dev/testing/OSS) */
|
|
151
|
-
disableUpstream?: boolean;
|
|
152
|
-
});
|
|
153
|
-
private log;
|
|
154
|
-
/**
|
|
155
|
-
* User override root (~/.adhdev/providers by default).
|
|
156
|
-
*/
|
|
157
|
-
getUserDir(): string;
|
|
158
|
-
/**
|
|
159
|
-
* Auto-updated upstream root (~/.adhdev/providers/.upstream by default).
|
|
160
|
-
*/
|
|
161
|
-
getUpstreamDir(): string;
|
|
162
|
-
/**
|
|
163
|
-
* Provider search order for on-disk lookups.
|
|
164
|
-
* Highest-priority editable overrides come first.
|
|
165
|
-
*/
|
|
166
|
-
getProviderRoots(): string[];
|
|
167
|
-
/**
|
|
168
|
-
* Canonical provider directory shape for a given root.
|
|
169
|
-
*/
|
|
170
|
-
getProviderDir(root: string, category: ProviderCategory, type: string): string;
|
|
171
|
-
/**
|
|
172
|
-
* Canonical user override directory for a provider.
|
|
173
|
-
*/
|
|
174
|
-
getUserProviderDir(category: ProviderCategory, type: string): string;
|
|
175
|
-
/**
|
|
176
|
-
* Canonical upstream directory for a provider.
|
|
177
|
-
*/
|
|
178
|
-
getUpstreamProviderDir(category: ProviderCategory, type: string): string;
|
|
179
|
-
/**
|
|
180
|
-
* Find the on-disk directory for a provider by type.
|
|
181
|
-
* Search order: user override → upstream.
|
|
182
|
-
*/
|
|
183
|
-
findProviderDir(type: string): string | null;
|
|
184
|
-
/**
|
|
185
|
-
* Resolve a file within a provider directory.
|
|
186
|
-
*/
|
|
187
|
-
resolveProviderFile(type: string, ...segments: string[]): string | null;
|
|
188
|
-
/**
|
|
189
|
-
* Load all providers (3-tier priority)
|
|
190
|
-
* 1. .upstream/ (GitHub auto-download — primary source)
|
|
191
|
-
* 2. User custom (~/.adhdev/providers/ excluding .upstream)
|
|
192
|
-
* User custom always wins (highest priority).
|
|
193
|
-
* If .upstream/ is empty, call fetchLatest() before loadAll().
|
|
194
|
-
*/
|
|
195
|
-
loadAll(): void;
|
|
196
|
-
/**
|
|
197
|
-
* Check if upstream directory exists and has providers.
|
|
198
|
-
*/
|
|
199
|
-
hasUpstream(): boolean;
|
|
200
|
-
/**
|
|
201
|
-
* Get raw provider metadata by type (NO scripts loaded).
|
|
202
|
-
* Safe for: category checks, icon, displayName, targetFilter, cdpPorts.
|
|
203
|
-
* NOT safe for: script execution (readChat, listModels, sendMessage).
|
|
204
|
-
* Use resolve() when scripts are needed.
|
|
205
|
-
*/
|
|
206
|
-
getMeta(type: string): ProviderModule | undefined;
|
|
207
|
-
/**
|
|
208
|
-
* Resolve provider type by alias
|
|
209
|
-
* 'claude' → 'claude-cli', 'codex' → 'codex-cli' etc
|
|
210
|
-
* Returns input as-is if no match found.
|
|
211
|
-
*/
|
|
212
|
-
resolveAlias(input: string): string;
|
|
213
|
-
/**
|
|
214
|
-
* Get provider with alias resolution (get + alias fallback)
|
|
215
|
-
*/
|
|
216
|
-
getByAlias(input: string): ProviderModule | undefined;
|
|
217
|
-
/**
|
|
218
|
-
* Build CLI/ACP detection list (replaces cli-detector)
|
|
219
|
-
* Dynamically generated from provider.js spawn.command.
|
|
220
|
-
*/
|
|
221
|
-
getCliDetectionList(): {
|
|
222
|
-
id: string;
|
|
223
|
-
displayName: string;
|
|
224
|
-
icon: string;
|
|
225
|
-
command: string;
|
|
226
|
-
category: string;
|
|
227
|
-
versionCommand?: string;
|
|
228
|
-
}[];
|
|
229
|
-
/**
|
|
230
|
-
* List providers by category
|
|
231
|
-
*/
|
|
232
|
-
getByCategory(cat: ProviderCategory): ProviderModule[];
|
|
233
|
-
/**
|
|
234
|
-
* Extension Extension providers with extensionIdPattern only
|
|
235
|
-
* (used by discoverAgentWebviews in daemon-cdp.ts)
|
|
236
|
-
*/
|
|
237
|
-
getExtensionProviders(): ProviderModule[];
|
|
238
|
-
/**
|
|
239
|
-
* All loaded providers
|
|
240
|
-
*/
|
|
241
|
-
getAll(): ProviderModule[];
|
|
242
|
-
/**
|
|
243
|
-
* Check if a provider is enabled (per-IDE)
|
|
244
|
-
* Checks ideSettings[ideType].extensions[type].enabled.
|
|
245
|
-
* Default false (disabled) — user must explicitly enable.
|
|
246
|
-
* Always returns true when called without ideType.
|
|
247
|
-
*/
|
|
248
|
-
isEnabled(type: string, ideType?: string): boolean;
|
|
249
|
-
/**
|
|
250
|
-
* Save IDE extension enabled setting
|
|
251
|
-
*/
|
|
252
|
-
setIdeExtensionEnabled(ideType: string, extensionType: string, enabled: boolean): boolean;
|
|
253
|
-
/**
|
|
254
|
-
* Return only enabled providers by category (per-IDE)
|
|
255
|
-
*/
|
|
256
|
-
getEnabledByCategory(cat: ProviderCategory, ideType?: string): ProviderModule[];
|
|
257
|
-
/**
|
|
258
|
-
* Extension Enabled extension providers with extensionIdPattern only (per-IDE)
|
|
259
|
-
*/
|
|
260
|
-
getEnabledExtensionProviders(ideType?: string): ProviderModule[];
|
|
261
|
-
/**
|
|
262
|
-
* Return CDP port map for IDE providers
|
|
263
|
-
* Used by launch.ts, adhdev-daemon.ts
|
|
264
|
-
*/
|
|
265
|
-
getCdpPortMap(): Record<string, [number, number]>;
|
|
266
|
-
/**
|
|
267
|
-
* Return IDE process name map (macOS)
|
|
268
|
-
*/
|
|
269
|
-
getMacAppIdentifiers(): Record<string, string>;
|
|
270
|
-
/**
|
|
271
|
-
* Return IDE process name map (Windows)
|
|
272
|
-
*/
|
|
273
|
-
getWinProcessNames(): Record<string, string[]>;
|
|
274
|
-
/**
|
|
275
|
-
* Available IDE types (only those with cdpPorts)
|
|
276
|
-
*/
|
|
277
|
-
getAvailableIdeTypes(): string[];
|
|
278
|
-
/**
|
|
279
|
-
* Register IDE providers to core/detector registry
|
|
280
|
-
* → Enables detectIDEs() to detect provider.js-based IDEs
|
|
281
|
-
*/
|
|
282
|
-
registerToDetector(): number;
|
|
283
|
-
/**
|
|
284
|
-
* Return final provider with OS/version overrides applied.
|
|
285
|
-
*
|
|
286
|
-
* Script resolution order:
|
|
287
|
-
* 1. compatibility array (new format — preferred)
|
|
288
|
-
* Provider.json defines: "compatibility": [{ "ideVersion": ">=1.107.0", "scriptDir": "scripts/1.107" }]
|
|
289
|
-
* First matching range wins. Fallback: defaultScriptDir.
|
|
290
|
-
* 2. versions field (legacy format — backward compat)
|
|
291
|
-
* "versions": { "< 1.107.0": { "__dir": "scripts/legacy" } }
|
|
292
|
-
* 3. Root scripts.js (original format — no versioning)
|
|
293
|
-
*
|
|
294
|
-
* Version source: context.version → VersionArchive → undefined
|
|
295
|
-
*/
|
|
296
|
-
resolve(type: string, context?: {
|
|
297
|
-
os?: string;
|
|
298
|
-
version?: string;
|
|
299
|
-
}): ResolvedProvider | undefined;
|
|
300
|
-
/**
|
|
301
|
-
* Load scripts from a scriptDir within a provider directory.
|
|
302
|
-
* Tries scripts.js first, then individual .js files.
|
|
303
|
-
*/
|
|
304
|
-
private loadScriptsFromDir;
|
|
305
|
-
/**
|
|
306
|
-
* Hot-reload: start watching for file changes
|
|
307
|
-
*/
|
|
308
|
-
watch(): void;
|
|
309
|
-
/**
|
|
310
|
-
* Stop hot-reload
|
|
311
|
-
*/
|
|
312
|
-
stopWatch(): void;
|
|
313
|
-
/**
|
|
314
|
-
* Full reload
|
|
315
|
-
*/
|
|
316
|
-
reload(): void;
|
|
317
|
-
/**
|
|
318
|
-
* Download latest providers tarball from GitHub → extract to .upstream/
|
|
319
|
-
* - ETag-based change detection (skip if unchanged)
|
|
320
|
-
* - Never touches user custom files in ~/.adhdev/providers/
|
|
321
|
-
* - Runs in background; existing providers are kept on failure
|
|
322
|
-
*
|
|
323
|
-
* @returns Whether an update occurred
|
|
324
|
-
*/
|
|
325
|
-
fetchLatest(): Promise<{
|
|
326
|
-
updated: boolean;
|
|
327
|
-
error?: string;
|
|
328
|
-
}>;
|
|
329
|
-
/** HTTP(S) file download (follows redirects) */
|
|
330
|
-
private downloadFile;
|
|
331
|
-
/** Recursive directory copy */
|
|
332
|
-
private copyDirRecursive;
|
|
333
|
-
/** .meta.json save */
|
|
334
|
-
private writeMeta;
|
|
335
|
-
/** Count provider files (provider.js or provider.json) */
|
|
336
|
-
private countProviders;
|
|
337
|
-
/**
|
|
338
|
-
* Get public settings schema for a provider (for dashboard UI rendering)
|
|
339
|
-
*/
|
|
340
|
-
getPublicSettings(type: string): ProviderSettingSchema[];
|
|
341
|
-
/**
|
|
342
|
-
* Get public settings schema for all providers
|
|
343
|
-
*/
|
|
344
|
-
getAllPublicSettings(): Record<string, ProviderSettingSchema[]>;
|
|
345
|
-
/**
|
|
346
|
-
* Resolved setting value for a provider (default + user override)
|
|
347
|
-
*/
|
|
348
|
-
getSettingValue(type: string, key: string): any;
|
|
349
|
-
/**
|
|
350
|
-
* All resolved settings for a provider (default + user override)
|
|
351
|
-
*/
|
|
352
|
-
getSettings(type: string): Record<string, any>;
|
|
353
|
-
/**
|
|
354
|
-
* Save provider setting value (writes to config.json)
|
|
355
|
-
*/
|
|
356
|
-
setSetting(type: string, key: string, value: any): boolean;
|
|
357
|
-
/**
|
|
358
|
-
* Find the on-disk directory for a provider by type.
|
|
359
|
-
* Canonical shape: root/category/type.
|
|
360
|
-
*/
|
|
361
|
-
private findProviderDirInternal;
|
|
362
|
-
/**
|
|
363
|
-
* Build a scripts function map from individual .js files in a directory.
|
|
364
|
-
* Each file is wrapped as: (params?) => fs.readFileSync(filePath, 'utf-8')
|
|
365
|
-
* (template substitution is NOT applied here — scripts.js handles that)
|
|
366
|
-
*/
|
|
367
|
-
private buildScriptWrappersFromDir;
|
|
368
|
-
/**
|
|
369
|
-
* Recursively scan directory to load provider files
|
|
370
|
-
* Supports two formats:
|
|
371
|
-
* 1. provider.json (metadata) + scripts.js (optional CDP scripts)
|
|
372
|
-
* 2. provider.js (legacy — everything in one file)
|
|
373
|
-
* Structure: dir/category/agent-name/provider.{json,js}
|
|
374
|
-
*/
|
|
375
|
-
private loadDir;
|
|
376
|
-
/**
|
|
377
|
-
* Simple semver range matching
|
|
378
|
-
* Supported formats: '>=4.0.0', '<3.0.0', '>=2.1.0'
|
|
379
|
-
*/
|
|
380
|
-
private matchesVersion;
|
|
381
|
-
private compareVersions;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
/**
|
|
385
|
-
* CLI AI Agent Detector
|
|
386
|
-
*
|
|
387
|
-
* Dynamic CLI detection based on Provider.
|
|
388
|
-
* Reads spawn.command from cli/acp categories via ProviderLoader to check installation.
|
|
389
|
-
*
|
|
390
|
-
* Uses parallel execution for fast detection across many providers.
|
|
391
|
-
*/
|
|
392
|
-
|
|
393
|
-
interface CLIInfo {
|
|
394
|
-
id: string;
|
|
395
|
-
displayName: string;
|
|
396
|
-
icon: string;
|
|
397
|
-
command: string;
|
|
398
|
-
versionCommand?: string;
|
|
399
|
-
installed: boolean;
|
|
400
|
-
version?: string;
|
|
401
|
-
path?: string;
|
|
402
|
-
category?: string;
|
|
403
|
-
}
|
|
404
|
-
/**
|
|
405
|
-
* Detect all CLI/ACP agents (parallel)
|
|
406
|
-
* @param providerLoader ProviderLoader instance (dynamic list creation)
|
|
407
|
-
*/
|
|
408
|
-
declare function detectCLIs(providerLoader?: ProviderLoader): Promise<CLIInfo[]>;
|
|
409
|
-
|
|
410
|
-
/**
|
|
411
|
-
* Host memory metrics — macOS-aware "available" memory.
|
|
412
|
-
*
|
|
413
|
-
* Node's os.freemem() on darwin reports only the tiny truly-free pool; most RAM
|
|
414
|
-
* sits in inactive/file-backed cache that the OS can reclaim. Dashboard "used %"
|
|
415
|
-
* based on (total - freemem) looks ~99% almost always — misleading.
|
|
416
|
-
*
|
|
417
|
-
* On macOS we parse `vm_stat` and approximate available bytes as:
|
|
418
|
-
* (free + inactive + speculative + purgeable [+ file_backed]) × page size
|
|
419
|
-
* (aligned with common Activity Monitor–style interpretations.)
|
|
420
|
-
*/
|
|
421
|
-
interface HostMemorySnapshot {
|
|
422
|
-
totalMem: number;
|
|
423
|
-
/** Raw kernel "free" — small on macOS; kept for debugging / API compat */
|
|
424
|
-
freeMem: number;
|
|
425
|
-
/** Use this for UI "used %" — on darwin from vm_stat; else equals freeMem */
|
|
426
|
-
availableMem: number;
|
|
427
|
-
}
|
|
428
|
-
declare function getHostMemorySnapshot(): HostMemorySnapshot;
|
|
429
|
-
|
|
430
|
-
/**
|
|
431
|
-
* CDP Manager for ADHDev Daemon
|
|
432
|
-
*
|
|
433
|
-
* Ported cdp.ts from Extension for Daemon use.
|
|
434
|
-
* vscode dependencies removed — works in pure Node.js environment.
|
|
435
|
-
*
|
|
436
|
-
* Connects to IDE CDP port (9222, 9333 etc) to:
|
|
437
|
-
* - Execute JS via Runtime.evaluate
|
|
438
|
-
* - Agent webview iframe search & session connection
|
|
439
|
-
* - DOM query
|
|
440
|
-
*/
|
|
441
|
-
|
|
442
|
-
interface CdpTarget {
|
|
443
|
-
id: string;
|
|
444
|
-
type: string;
|
|
445
|
-
title: string;
|
|
446
|
-
url: string;
|
|
447
|
-
webSocketDebuggerUrl: string;
|
|
448
|
-
}
|
|
449
|
-
interface AgentWebviewTarget {
|
|
450
|
-
targetId: string;
|
|
451
|
-
extensionId: string;
|
|
452
|
-
agentType: string;
|
|
453
|
-
url: string;
|
|
454
|
-
}
|
|
455
|
-
declare class DaemonCdpManager {
|
|
456
|
-
private ws;
|
|
457
|
-
private browserWs;
|
|
458
|
-
private browserMsgId;
|
|
459
|
-
private browserPending;
|
|
460
|
-
private msgId;
|
|
461
|
-
private pending;
|
|
462
|
-
private port;
|
|
463
|
-
private _connected;
|
|
464
|
-
private _browserConnected;
|
|
465
|
-
private targetUrl;
|
|
466
|
-
private reconnectTimer;
|
|
467
|
-
private contexts;
|
|
468
|
-
private connectPromise;
|
|
469
|
-
private failureCount;
|
|
470
|
-
private readonly MAX_FAILURES;
|
|
471
|
-
private agentSessions;
|
|
472
|
-
private logFn;
|
|
473
|
-
private extensionProviders;
|
|
474
|
-
private _lastDiscoverSig;
|
|
475
|
-
private _targetId;
|
|
476
|
-
private _pageTitle;
|
|
477
|
-
private _targetFilter;
|
|
478
|
-
private _lastDiscoveredTargets?;
|
|
479
|
-
constructor(port?: number, logFn?: (msg: string) => void, targetId?: string, targetFilter?: CdpTargetFilter);
|
|
480
|
-
/** Set target filter (can be updated after construction) */
|
|
481
|
-
setTargetFilter(filter: CdpTargetFilter): void;
|
|
482
|
-
/**
|
|
483
|
-
* Check if a page title should be excluded (non-main page).
|
|
484
|
-
* Uses provider-configured titleExcludes, falls back to default pattern.
|
|
485
|
-
*/
|
|
486
|
-
private isNonMainTitle;
|
|
487
|
-
/**
|
|
488
|
-
* Check if a page URL matches the main window criteria.
|
|
489
|
-
* Uses provider-configured urlIncludes/urlExcludes.
|
|
490
|
-
*/
|
|
491
|
-
private isMainPageUrl;
|
|
492
|
-
/** Connected page title (includes workspace name) */
|
|
493
|
-
get pageTitle(): string;
|
|
494
|
-
/** Connected target ID */
|
|
495
|
-
get targetId(): string | null;
|
|
496
|
-
/**
|
|
497
|
-
* Query all workbench pages on port (static)
|
|
498
|
-
* Returns multiple entries if multiple IDE windows are open on same port
|
|
499
|
-
*/
|
|
500
|
-
static listAllTargets(port: number): Promise<CdpTarget[]>;
|
|
501
|
-
setPort(port: number): void;
|
|
502
|
-
getPort(): number;
|
|
503
|
-
private log;
|
|
504
|
-
connect(): Promise<boolean>;
|
|
505
|
-
private doConnect;
|
|
506
|
-
private findTargetOnPort;
|
|
507
|
-
private findTarget;
|
|
508
|
-
setExtensionProviders(providers: {
|
|
509
|
-
agentType: string;
|
|
510
|
-
extensionId: string;
|
|
511
|
-
extensionIdPattern: RegExp;
|
|
512
|
-
}[]): void;
|
|
513
|
-
private connectToTarget;
|
|
514
|
-
/** Browser-level CDP connection — needed for Target discovery */
|
|
515
|
-
private connectBrowserWs;
|
|
516
|
-
private getBrowserWsUrl;
|
|
517
|
-
private sendBrowser;
|
|
518
|
-
private scheduleReconnect;
|
|
519
|
-
disconnect(): void;
|
|
520
|
-
get isConnected(): boolean;
|
|
521
|
-
private sendInternal;
|
|
522
|
-
send(method: string, params?: Record<string, unknown>, timeoutMs?: number): Promise<any>;
|
|
523
|
-
sendCdpCommand(method: string, params?: Record<string, unknown>): Promise<any>;
|
|
524
|
-
evaluate(expression: string, timeoutMs?: number): Promise<unknown>;
|
|
525
|
-
querySelector(selector: string): Promise<string | null>;
|
|
526
|
-
/**
|
|
527
|
-
* Input text via CDP protocol then send Enter
|
|
528
|
-
* Used for editors where execCommand does not work (e.g. Lexical).
|
|
529
|
-
*
|
|
530
|
-
* 1. Find editor by selector, focus + click
|
|
531
|
-
* 2. Insert text via Input.insertText
|
|
532
|
-
* 3. Send Enter via Input.dispatchKeyEvent
|
|
533
|
-
*/
|
|
534
|
-
typeAndSend(selector: string, text: string): Promise<boolean>;
|
|
535
|
-
/**
|
|
536
|
-
* Coordinate-based typeAndSend — for input fields inside webview iframe
|
|
537
|
-
* Receives coordinates directly instead of selector for click+input+Enter
|
|
538
|
-
*/
|
|
539
|
-
typeAndSendAt(x: number, y: number, text: string): Promise<boolean>;
|
|
540
|
-
/**
|
|
541
|
-
* Evaluate JS from inside Webview iframe
|
|
542
|
-
* Kiro, PearAI etc Used for IDEs where chat UI is inside webview iframe.
|
|
543
|
-
*
|
|
544
|
-
* 1. Query Target.getTargets via browser WS → find vscode-webview iframes
|
|
545
|
-
* 2. Target.attachToTarget → session acquire
|
|
546
|
-
* 3. Page.getFrameTree → nested iframe find
|
|
547
|
-
* 4. Page.createIsolatedWorld → contextId acquire
|
|
548
|
-
* 5. Runtime.evaluate → result return
|
|
549
|
-
*
|
|
550
|
-
* @param expression JS expression to execute
|
|
551
|
-
* @param matchFn webview iframe URL match function (optional, all webview attempt)
|
|
552
|
-
* @returns evaluate result or null
|
|
553
|
-
*/
|
|
554
|
-
evaluateInWebviewFrame(expression: string, matchFn?: (bodyPreview: string) => boolean): Promise<string | null>;
|
|
555
|
-
discoverAgentWebviews(): Promise<AgentWebviewTarget[]>;
|
|
556
|
-
attachToAgent(target: AgentWebviewTarget): Promise<string | null>;
|
|
557
|
-
evaluateInSession(sessionId: string, expression: string, timeoutMs?: number): Promise<unknown>;
|
|
558
|
-
/**
|
|
559
|
-
* Evaluate inside the child frame of an attached session.
|
|
560
|
-
* Extension webviews have a nested iframe structure:
|
|
561
|
-
* outer (vscode-webview://) → inner (extension React app)
|
|
562
|
-
* This method navigates into the inner frame using CDP Page.getFrameTree.
|
|
563
|
-
* Falls back to evaluateInSession if no child frame is found.
|
|
564
|
-
*/
|
|
565
|
-
evaluateInSessionFrame(sessionId: string, expression: string, timeoutMs?: number): Promise<unknown>;
|
|
566
|
-
detachAgent(sessionId: string): Promise<void>;
|
|
567
|
-
detachAllAgents(): Promise<void>;
|
|
568
|
-
getAgentSessions(): Map<string, AgentWebviewTarget>;
|
|
569
|
-
private getCurrentPageWebviewUrls;
|
|
570
|
-
captureScreenshot(opts?: {
|
|
571
|
-
quality?: number;
|
|
572
|
-
}): Promise<Buffer | null>;
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
/**
|
|
576
|
-
* ProviderInstanceManager — lifecycle management for all ProviderInstances
|
|
577
|
-
*
|
|
578
|
-
* Role:
|
|
579
|
-
* 1. Instance create/delete
|
|
580
|
-
* 2. Tick engine (periodic onTick calls)
|
|
581
|
-
* 3. Collect overall state
|
|
582
|
-
* 4. Event collection and propagation
|
|
583
|
-
*/
|
|
584
|
-
|
|
585
|
-
declare class ProviderInstanceManager {
|
|
586
|
-
private instances;
|
|
587
|
-
private tickTimer;
|
|
588
|
-
private tickInterval;
|
|
589
|
-
private eventListeners;
|
|
590
|
-
/**
|
|
591
|
-
* Instance add and initialize
|
|
592
|
-
*/
|
|
593
|
-
addInstance(id: string, instance: ProviderInstance, context: InstanceContext): Promise<void>;
|
|
594
|
-
/**
|
|
595
|
-
* Instance remove
|
|
596
|
-
*/
|
|
597
|
-
removeInstance(id: string): void;
|
|
598
|
-
removeByCategory(category: 'cli' | 'ide' | 'extension' | 'acp', options?: {
|
|
599
|
-
dispose?: boolean;
|
|
600
|
-
}): number;
|
|
601
|
-
/**
|
|
602
|
-
* Import by Instance ID
|
|
603
|
-
*/
|
|
604
|
-
getInstance(id: string): ProviderInstance | undefined;
|
|
605
|
-
/**
|
|
606
|
-
* Per-category Instance list
|
|
607
|
-
*/
|
|
608
|
-
getByCategory(category: 'cli' | 'ide' | 'extension' | 'acp'): ProviderInstance[];
|
|
609
|
-
/**
|
|
610
|
-
* All Instance count
|
|
611
|
-
*/
|
|
612
|
-
get size(): number;
|
|
613
|
-
/**
|
|
614
|
-
* All Instance IDs (for iteration without exposing the private Map)
|
|
615
|
-
*/
|
|
616
|
-
listInstanceIds(): string[];
|
|
617
|
-
/**
|
|
618
|
-
* all Instance's current status collect
|
|
619
|
-
* + Propagate pending events to event listeners
|
|
620
|
-
*/
|
|
621
|
-
collectAllStates(): ProviderState[];
|
|
622
|
-
/**
|
|
623
|
-
* Per-category status collect
|
|
624
|
-
*/
|
|
625
|
-
collectStatesByCategory(category: 'cli' | 'ide' | 'extension' | 'acp'): ProviderState[];
|
|
626
|
-
/**
|
|
627
|
-
* Start tick — periodically call all Instance.onTick() call
|
|
628
|
-
*/
|
|
629
|
-
startTicking(intervalMs?: number): void;
|
|
630
|
-
/**
|
|
631
|
-
* Stop tick
|
|
632
|
-
*/
|
|
633
|
-
stopTicking(): void;
|
|
634
|
-
/**
|
|
635
|
-
* Register event listener (used for daemon status_event transmission)
|
|
636
|
-
*/
|
|
637
|
-
onEvent(listener: (event: ProviderEvent & {
|
|
638
|
-
providerType: string;
|
|
639
|
-
}) => void): void;
|
|
640
|
-
private emitPendingEvents;
|
|
641
|
-
/**
|
|
642
|
-
* Forward event to specific Instance
|
|
643
|
-
*/
|
|
644
|
-
sendEvent(id: string, event: string, data?: any): void;
|
|
645
|
-
/**
|
|
646
|
-
* Broadcast event to all Instances
|
|
647
|
-
*/
|
|
648
|
-
broadcast(event: string, data?: any): void;
|
|
649
|
-
/**
|
|
650
|
-
* Update settings for all instances of a given provider type.
|
|
651
|
-
* Called when user changes settings from dashboard.
|
|
652
|
-
*/
|
|
653
|
-
updateInstanceSettings(providerType: string, settings: Record<string, any>): number;
|
|
654
|
-
/**
|
|
655
|
-
* All terminate
|
|
656
|
-
*/
|
|
657
|
-
disposeAll(): void;
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
interface SessionRuntimeTarget {
|
|
661
|
-
sessionId: string;
|
|
662
|
-
parentSessionId: string | null;
|
|
663
|
-
providerType: string;
|
|
664
|
-
transport: SessionTransport;
|
|
665
|
-
cdpManagerKey?: string;
|
|
666
|
-
adapterKey?: string;
|
|
667
|
-
instanceKey?: string;
|
|
668
|
-
}
|
|
669
|
-
declare class SessionRegistry {
|
|
670
|
-
private readonly bySessionId;
|
|
671
|
-
private readonly byManagerKey;
|
|
672
|
-
private readonly byInstanceKey;
|
|
673
|
-
private readonly byParentSessionId;
|
|
674
|
-
register(target: SessionRuntimeTarget): void;
|
|
675
|
-
get(sessionId: string | undefined | null): SessionRuntimeTarget | undefined;
|
|
676
|
-
unregister(sessionId: string | undefined | null): void;
|
|
677
|
-
unregisterByManagerKey(managerKey: string): void;
|
|
678
|
-
unregisterByInstanceKey(instanceKey: string): void;
|
|
679
|
-
listChildren(parentSessionId: string): SessionRuntimeTarget[];
|
|
680
|
-
private addIndex;
|
|
681
|
-
private removeIndex;
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
/**
|
|
685
|
-
* Agent Stream Types — ported for Daemon (identical to original)
|
|
686
|
-
*
|
|
687
|
-
* Agent stream types.
|
|
688
|
-
* No vscode dependency — can be used as-is.
|
|
689
|
-
*/
|
|
690
|
-
/** Agent chat message */
|
|
691
|
-
interface AgentChatMessage {
|
|
692
|
-
role: 'user' | 'assistant' | 'system';
|
|
693
|
-
content: string;
|
|
694
|
-
timestamp?: number;
|
|
695
|
-
}
|
|
696
|
-
/** Agent chat history item */
|
|
697
|
-
interface AgentChatListItem {
|
|
698
|
-
title: string;
|
|
699
|
-
id: string;
|
|
700
|
-
status?: string;
|
|
701
|
-
time?: string;
|
|
702
|
-
cost?: string;
|
|
703
|
-
}
|
|
704
|
-
/** Agent stream status */
|
|
705
|
-
interface AgentStreamState {
|
|
706
|
-
agentType: string;
|
|
707
|
-
agentName: string;
|
|
708
|
-
extensionId: string;
|
|
709
|
-
status: 'idle' | 'streaming' | 'waiting_approval' | 'error' | 'disconnected' | 'panel_hidden' | 'not_monitored';
|
|
710
|
-
messages: AgentChatMessage[];
|
|
711
|
-
inputContent: string;
|
|
712
|
-
/** @deprecated Use controlValues['model'] — kept for backward compatibility */
|
|
713
|
-
model?: string;
|
|
714
|
-
/** @deprecated Use controlValues['mode'] — kept for backward compatibility */
|
|
715
|
-
mode?: string;
|
|
716
|
-
activeModal?: {
|
|
717
|
-
message: string;
|
|
718
|
-
buttons: string[];
|
|
719
|
-
};
|
|
720
|
-
/** Dynamic control current values (populated from readChat + provider controls schema) */
|
|
721
|
-
controlValues?: Record<string, string | number | boolean>;
|
|
722
|
-
}
|
|
723
|
-
/** Agent stream adapter interface */
|
|
724
|
-
interface IAgentStreamAdapter {
|
|
725
|
-
readonly agentType: string;
|
|
726
|
-
readonly agentName: string;
|
|
727
|
-
readonly extensionId: string;
|
|
728
|
-
readonly extensionIdPattern: RegExp;
|
|
729
|
-
readChat(evaluate: AgentEvaluateFn): Promise<AgentStreamState>;
|
|
730
|
-
sendMessage(evaluate: AgentEvaluateFn, text: string): Promise<void>;
|
|
731
|
-
resolveAction(evaluate: AgentEvaluateFn, action: string, button?: string): Promise<boolean>;
|
|
732
|
-
newSession(evaluate: AgentEvaluateFn): Promise<void>;
|
|
733
|
-
listChats?(evaluate: AgentEvaluateFn): Promise<AgentChatListItem[]>;
|
|
734
|
-
switchSession?(evaluate: AgentEvaluateFn, sessionId: string): Promise<boolean>;
|
|
735
|
-
focusEditor?(evaluate: AgentEvaluateFn): Promise<void>;
|
|
736
|
-
setProvider?(provider: any): void;
|
|
737
|
-
}
|
|
738
|
-
type AgentEvaluateFn = (expression: string, timeoutMs?: number) => Promise<unknown>;
|
|
739
|
-
|
|
740
|
-
/**
|
|
741
|
-
* DaemonAgentStreamManager — manage agent streams (ported for Daemon)
|
|
742
|
-
*
|
|
743
|
-
* Agent stream manager for extension data collection.
|
|
744
|
-
* All vscode dependencies removed — pure Node.js environment.
|
|
745
|
-
*
|
|
746
|
-
* Panel focus is delegated to Extension via IPC.
|
|
747
|
-
* CDP session management uses DaemonCdpManager directly.
|
|
748
|
-
*/
|
|
749
|
-
|
|
750
|
-
interface ManagedAgent {
|
|
751
|
-
adapter: IAgentStreamAdapter;
|
|
752
|
-
runtimeSessionId: string;
|
|
753
|
-
parentSessionId: string;
|
|
754
|
-
cdpSessionId: string;
|
|
755
|
-
target: AgentWebviewTarget;
|
|
756
|
-
lastState: AgentStreamState | null;
|
|
757
|
-
lastError: string | null;
|
|
758
|
-
lastHiddenCheckTime: number;
|
|
759
|
-
}
|
|
760
|
-
declare class DaemonAgentStreamManager {
|
|
761
|
-
private readonly sessionRegistry?;
|
|
762
|
-
private adaptersByType;
|
|
763
|
-
private managedBySessionId;
|
|
764
|
-
private enabled;
|
|
765
|
-
private logFn;
|
|
766
|
-
private lastDiscoveryTimeByParent;
|
|
767
|
-
private discoveryIntervalMsByParent;
|
|
768
|
-
private activeSessionIdByParent;
|
|
769
|
-
constructor(logFn?: (msg: string) => void, providerLoader?: ProviderLoader, sessionRegistry?: SessionRegistry | undefined);
|
|
770
|
-
setEnabled(enabled: boolean): void;
|
|
771
|
-
get isEnabled(): boolean;
|
|
772
|
-
getActiveSessionId(parentSessionId: string): string | null;
|
|
773
|
-
private isRecoverableSessionError;
|
|
774
|
-
private getSessionTarget;
|
|
775
|
-
resetParentSession(parentSessionId: string): void;
|
|
776
|
-
/** Panel focus based on provider.js focusPanel or extensionId (currently no-op) */
|
|
777
|
-
ensureSessionPanelOpen(_sessionId: string): Promise<void>;
|
|
778
|
-
setActiveSession(cdp: DaemonCdpManager, parentSessionId: string, sessionId: string | null): Promise<void>;
|
|
779
|
-
private resolveSessionIdForTarget;
|
|
780
|
-
private connectManagedSession;
|
|
781
|
-
/** Agent webview discovery + session connection */
|
|
782
|
-
syncActiveSession(cdp: DaemonCdpManager, parentSessionId: string): Promise<void>;
|
|
783
|
-
/** Collect active extension session state */
|
|
784
|
-
collectActiveSession(cdp: DaemonCdpManager, parentSessionId: string): Promise<AgentStreamState | null>;
|
|
785
|
-
sendToSession(cdp: DaemonCdpManager, sessionId: string, text: string): Promise<boolean>;
|
|
786
|
-
resolveSessionAction(cdp: DaemonCdpManager, sessionId: string, action: 'approve' | 'reject'): Promise<boolean>;
|
|
787
|
-
newSession(cdp: DaemonCdpManager, sessionId: string): Promise<boolean>;
|
|
788
|
-
listSessionChats(cdp: DaemonCdpManager, sessionId: string): Promise<AgentChatListItem[]>;
|
|
789
|
-
switchConversation(cdp: DaemonCdpManager, sessionId: string, conversationId: string): Promise<boolean>;
|
|
790
|
-
focusSession(cdp: DaemonCdpManager, sessionId: string): Promise<boolean>;
|
|
791
|
-
getConnectedSessions(parentSessionId?: string): string[];
|
|
792
|
-
getManagedSession(sessionId: string): ManagedAgent | undefined;
|
|
793
|
-
dispose(cdpManagers: Map<string, DaemonCdpManager>): Promise<void>;
|
|
794
|
-
resolveSessionForAgent(parentSessionId: string, agentType: string): string | null;
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
/**
|
|
798
|
-
* AgentStreamPoller — Periodic agent stream polling + extension dynamic management
|
|
799
|
-
*
|
|
800
|
-
* Handles periodic agent stream polling and extension dynamic management.
|
|
801
|
-
*
|
|
802
|
-
* Responsibilities:
|
|
803
|
-
* 1. Refresh extension providers in CDP managers (config changes take effect immediately)
|
|
804
|
-
* 2. Dynamically add/remove IDE instance extensions based on enabled state
|
|
805
|
-
* 3. Sync agent sessions + collect agent streams
|
|
806
|
-
* 4. Auto-discover agents in connected IDEs
|
|
807
|
-
*/
|
|
808
|
-
|
|
809
|
-
interface AgentStreamPollerDeps {
|
|
810
|
-
agentStreamManager: DaemonAgentStreamManager;
|
|
811
|
-
providerLoader: ProviderLoader;
|
|
812
|
-
instanceManager: ProviderInstanceManager;
|
|
813
|
-
cdpManagers: Map<string, DaemonCdpManager>;
|
|
814
|
-
sessionRegistry: SessionRegistry;
|
|
815
|
-
/** Callback when agent streams are updated */
|
|
816
|
-
onStreamsUpdated?: (ideType: string, streams: AgentStreamState[]) => void;
|
|
817
|
-
}
|
|
818
|
-
declare class AgentStreamPoller {
|
|
819
|
-
private deps;
|
|
820
|
-
private timer;
|
|
821
|
-
constructor(deps: AgentStreamPollerDeps);
|
|
822
|
-
/** Currently active IDE type for agent streaming */
|
|
823
|
-
get activeIde(): string | null;
|
|
824
|
-
/** Reset active IDE tracking (e.g., when IDE is stopped) */
|
|
825
|
-
resetActiveIde(parentSessionId: string): void;
|
|
826
|
-
/** Start polling (idempotent — ignored if already started) */
|
|
827
|
-
start(intervalMs?: number): void;
|
|
828
|
-
/** Stop polling */
|
|
829
|
-
stop(): void;
|
|
830
|
-
/** Single poll tick — can also be called manually */
|
|
831
|
-
private tick;
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
/**
|
|
835
|
-
* Chat History Persistence — Persist completed chat messages to local disk
|
|
836
|
-
*
|
|
837
|
-
* Design:
|
|
838
|
-
* - ~/.adhdev/history/{agentType}/YYYY-MM-DD.jsonl
|
|
839
|
-
* - JSONL format (one line = one message, append-friendly)
|
|
840
|
-
* - Track only new messages (hash comparison with previous)
|
|
841
|
-
* - Auto-rotation (delete files older than 30 days)
|
|
842
|
-
* - Async/non-blocking (no impact on chat collection)
|
|
843
|
-
*/
|
|
844
|
-
interface HistoryMessage {
|
|
845
|
-
ts: string;
|
|
846
|
-
receivedAt: number;
|
|
847
|
-
role: 'user' | 'assistant' | 'system';
|
|
848
|
-
content: string;
|
|
849
|
-
agent: string;
|
|
850
|
-
instanceId?: string;
|
|
851
|
-
sessionTitle?: string;
|
|
852
|
-
}
|
|
853
|
-
declare class ChatHistoryWriter {
|
|
854
|
-
/** Last seen message count per agent (deduplication) */
|
|
855
|
-
private lastSeenCounts;
|
|
856
|
-
/** Last seen message hash per agent (deduplication) */
|
|
857
|
-
private lastSeenHashes;
|
|
858
|
-
/** Last seen append-only terminal transcript per agent */
|
|
859
|
-
private lastSeenTerminal;
|
|
860
|
-
private rotated;
|
|
861
|
-
/**
|
|
862
|
-
* Append new messages to history
|
|
863
|
-
*
|
|
864
|
-
* @param agentType agent type (e.g. 'antigravity', 'cursor')
|
|
865
|
-
* @param messages Message array received from readChat
|
|
866
|
-
* @param sessionTitle Current session title
|
|
867
|
-
* @param instanceId IDE instance UUID (distinguishes windows of the same agent)
|
|
868
|
-
*/
|
|
869
|
-
appendNewMessages(agentType: string, messages: Array<{
|
|
870
|
-
role: string;
|
|
871
|
-
content: string;
|
|
872
|
-
receivedAt?: number;
|
|
873
|
-
}>, sessionTitle?: string, instanceId?: string): void;
|
|
874
|
-
appendTerminalHistory(agentType: string, terminalHistory: string, sessionTitle?: string, instanceId?: string): void;
|
|
875
|
-
/** Called when agent session is explicitly changed */
|
|
876
|
-
onSessionChange(agentType: string): void;
|
|
877
|
-
/** Delete history files older than 30 days */
|
|
878
|
-
private rotateOldFiles;
|
|
879
|
-
/** Allow only filename-safe characters */
|
|
880
|
-
private sanitize;
|
|
881
|
-
}
|
|
882
|
-
/**
|
|
883
|
-
* Read history (static — called from P2P commands)
|
|
884
|
-
*
|
|
885
|
-
* Read JSONL files in reverse order, returning most recent messages first.
|
|
886
|
-
* When instanceId is specified, reads only that instance file.
|
|
887
|
-
* Offset/limit-based paging.
|
|
888
|
-
*/
|
|
889
|
-
declare function readChatHistory(agentType: string, offset?: number, limit?: number, instanceId?: string): {
|
|
890
|
-
messages: HistoryMessage[];
|
|
891
|
-
hasMore: boolean;
|
|
892
|
-
};
|
|
893
|
-
|
|
894
|
-
/**
|
|
895
|
-
* DaemonCommandHandler — unified command routing for CDP & CLI
|
|
896
|
-
*
|
|
897
|
-
* Routes incoming commands (from server WS, P2P, or local WS) to
|
|
898
|
-
* the correct CDP manager or CLI adapter.
|
|
899
|
-
*
|
|
900
|
-
* Key concepts:
|
|
901
|
-
* - extractIdeType(): determines target IDE from targetSessionId or ideType
|
|
902
|
-
* - getCdp(): returns the DaemonCdpManager for current command
|
|
903
|
-
* - getProvider(): returns the ProviderModule for current command
|
|
904
|
-
* - handle(): main entry point, sets context then dispatches
|
|
905
|
-
*/
|
|
906
|
-
|
|
907
|
-
interface CommandResult$1 {
|
|
908
|
-
success: boolean;
|
|
909
|
-
[key: string]: unknown;
|
|
910
|
-
}
|
|
911
|
-
interface CommandContext {
|
|
912
|
-
cdpManagers: Map<string, DaemonCdpManager>;
|
|
913
|
-
ideType: string;
|
|
914
|
-
adapters: Map<string, any>;
|
|
915
|
-
providerLoader?: ProviderLoader;
|
|
916
|
-
/** ProviderInstanceManager — for runtime settings propagation */
|
|
917
|
-
instanceManager?: ProviderInstanceManager;
|
|
918
|
-
sessionRegistry?: SessionRegistry;
|
|
919
|
-
}
|
|
920
|
-
/**
|
|
921
|
-
* Shared helpers interface — passed to sub-module command functions
|
|
922
|
-
* for accessing CDP, providers, agent streams, and other handler-owned state.
|
|
923
|
-
*/
|
|
924
|
-
interface CommandHelpers {
|
|
925
|
-
getCdp(ideType?: string): DaemonCdpManager | null;
|
|
926
|
-
getProvider(overrideType?: string): ProviderModule | undefined;
|
|
927
|
-
getProviderScript(scriptName: string, params?: Record<string, string>, ideType?: string): string | null;
|
|
928
|
-
evaluateProviderScript(scriptName: string, params?: Record<string, string>, timeout?: number): Promise<{
|
|
929
|
-
result: any;
|
|
930
|
-
category: string;
|
|
931
|
-
} | null>;
|
|
932
|
-
getCliAdapter(type?: string): any | null;
|
|
933
|
-
readonly currentManagerKey: string | undefined;
|
|
934
|
-
readonly currentIdeType: string | undefined;
|
|
935
|
-
readonly currentProviderType: string | undefined;
|
|
936
|
-
readonly currentSession: SessionRuntimeTarget | undefined;
|
|
937
|
-
readonly agentStream: DaemonAgentStreamManager | null;
|
|
938
|
-
readonly ctx: CommandContext;
|
|
939
|
-
readonly historyWriter: ChatHistoryWriter;
|
|
940
|
-
}
|
|
941
|
-
declare class DaemonCommandHandler implements CommandHelpers {
|
|
942
|
-
private _ctx;
|
|
943
|
-
private _agentStream;
|
|
944
|
-
private domHandlers;
|
|
945
|
-
private _historyWriter;
|
|
946
|
-
/** Current request route context */
|
|
947
|
-
private _currentRoute;
|
|
948
|
-
constructor(ctx: CommandContext);
|
|
949
|
-
get ctx(): CommandContext;
|
|
950
|
-
get agentStream(): DaemonAgentStreamManager | null;
|
|
951
|
-
get historyWriter(): ChatHistoryWriter;
|
|
952
|
-
get currentManagerKey(): string | undefined;
|
|
953
|
-
get currentIdeType(): string | undefined;
|
|
954
|
-
get currentProviderType(): string | undefined;
|
|
955
|
-
get currentSession(): SessionRuntimeTarget | undefined;
|
|
956
|
-
/** Get CDP manager for a specific session or manager key. */
|
|
957
|
-
getCdp(ideType?: string): DaemonCdpManager | null;
|
|
958
|
-
/**
|
|
959
|
-
* Get provider module — _currentProviderType (agentType priority) use.
|
|
960
|
-
*/
|
|
961
|
-
getProvider(overrideType?: string): ProviderModule | undefined;
|
|
962
|
-
/** Get a provider script by name from ProviderLoader. */
|
|
963
|
-
getProviderScript(scriptName: string, params?: Record<string, string>, ideType?: string): string | null;
|
|
964
|
-
/**
|
|
965
|
-
* per-category CDP script execute:
|
|
966
|
-
* IDE → cdp.evaluate(script) (main window)
|
|
967
|
-
* Extension → cdp.evaluateInSession(sessionId, script) (webview)
|
|
968
|
-
*/
|
|
969
|
-
evaluateProviderScript(scriptName: string, params?: Record<string, string>, timeout?: number): Promise<{
|
|
970
|
-
result: any;
|
|
971
|
-
category: string;
|
|
972
|
-
} | null>;
|
|
973
|
-
/** CLI adapter search */
|
|
974
|
-
getCliAdapter(type?: string): any | null;
|
|
975
|
-
private inferProviderType;
|
|
976
|
-
private resolveRoute;
|
|
977
|
-
/** Extract CDP scope key from target session or explicit ideType */
|
|
978
|
-
private extractIdeType;
|
|
979
|
-
private logCommandStart;
|
|
980
|
-
private logCommandEnd;
|
|
981
|
-
setAgentStreamManager(manager: DaemonAgentStreamManager): void;
|
|
982
|
-
handle(cmd: string, args: any): Promise<CommandResult$1>;
|
|
983
|
-
private dispatch;
|
|
984
|
-
private handleGetRecentWorkspaces;
|
|
985
|
-
private handleRefreshScripts;
|
|
986
|
-
private proxyDevServerPost;
|
|
987
|
-
private proxyDevServerGet;
|
|
988
|
-
private proxyDevServerScaffold;
|
|
989
|
-
}
|
|
990
|
-
|
|
991
|
-
/**
|
|
992
|
-
* CDP DOM Analysis Tools — DOM dump, query, debug
|
|
993
|
-
*
|
|
994
|
-
* Separated from daemon-commands.ts.
|
|
995
|
-
* Tools for analyzing DOM structure when developing new IDE scripts.
|
|
996
|
-
*/
|
|
997
|
-
|
|
998
|
-
type CdpGetter = (ideType?: string) => DaemonCdpManager | null;
|
|
999
|
-
/**
|
|
1000
|
-
* CDP DOM analysis handler
|
|
1001
|
-
*
|
|
1002
|
-
* Uses getCdp from DaemonCommandHandler.
|
|
1003
|
-
*/
|
|
1004
|
-
declare class CdpDomHandlers {
|
|
1005
|
-
private getCdp;
|
|
1006
|
-
constructor(getCdp: CdpGetter);
|
|
1007
|
-
/**
|
|
1008
|
-
* CDP DOM Dump — IDE's DOM tree retrieve
|
|
1009
|
-
*
|
|
1010
|
-
* args:
|
|
1011
|
-
* selector?: string — CSS selector to dump specific area only (default: All)
|
|
1012
|
-
* depth?: number — Dump depth limit (default: 10)
|
|
1013
|
-
* attrs?: boolean — Whether to include properties (default: true)
|
|
1014
|
-
* maxLength?: number — Max character count (default: 200000)
|
|
1015
|
-
* format?: 'html' | 'tree' | 'summary' — Output format (default: 'html')
|
|
1016
|
-
* sessionId?: string — Agent webview session ID (if provided, match webview DOM)
|
|
1017
|
-
*/
|
|
1018
|
-
handleDomDump(args: any): Promise<CommandResult$1>;
|
|
1019
|
-
/**
|
|
1020
|
-
* CDP DOM Query — CSS Test selector
|
|
1021
|
-
* Check how many elements match selector and what elements they are
|
|
1022
|
-
*
|
|
1023
|
-
* args:
|
|
1024
|
-
* selector: string — CSS selector
|
|
1025
|
-
* limit?: number — Max element count to return (default: 20)
|
|
1026
|
-
* content?: boolean — Whether to include text content (default: true)
|
|
1027
|
-
* sessionId?: string — agent webview session ID
|
|
1028
|
-
*/
|
|
1029
|
-
handleDomQuery(args: any): Promise<CommandResult$1>;
|
|
1030
|
-
/**
|
|
1031
|
-
* CDP DOM Debug — IDE AI panel specialized analysis
|
|
1032
|
-
* Collect all essential info at once when supporting new IDE
|
|
1033
|
-
*
|
|
1034
|
-
* args:
|
|
1035
|
-
* ideType?: string — IDE type hint
|
|
1036
|
-
* sessionId?: string — agent webview session ID
|
|
1037
|
-
*/
|
|
1038
|
-
handleDomDebug(args: any): Promise<CommandResult$1>;
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
|
-
/**
|
|
1042
|
-
* ExtensionProviderInstance — Runtime instance for Extension Provider
|
|
1043
|
-
*
|
|
1044
|
-
* Manages IDE extensions (Cline, Roo Code, etc).
|
|
1045
|
-
* CDP webview discovery + agent stream collection moved here.
|
|
1046
|
-
*/
|
|
1047
|
-
|
|
1048
|
-
declare class ExtensionProviderInstance implements ProviderInstance {
|
|
1049
|
-
readonly type: string;
|
|
1050
|
-
readonly category: "extension";
|
|
1051
|
-
private provider;
|
|
1052
|
-
private context;
|
|
1053
|
-
private settings;
|
|
1054
|
-
private events;
|
|
1055
|
-
private currentStatus;
|
|
1056
|
-
private agentStreams;
|
|
1057
|
-
private messages;
|
|
1058
|
-
private activeModal;
|
|
1059
|
-
private currentModel;
|
|
1060
|
-
private currentMode;
|
|
1061
|
-
private controlValues;
|
|
1062
|
-
private lastAgentStatus;
|
|
1063
|
-
private generatingStartedAt;
|
|
1064
|
-
private monitor;
|
|
1065
|
-
private instanceId;
|
|
1066
|
-
private ideType;
|
|
1067
|
-
private chatId;
|
|
1068
|
-
private chatTitle;
|
|
1069
|
-
private agentName;
|
|
1070
|
-
private extensionId;
|
|
1071
|
-
constructor(provider: ProviderModule);
|
|
1072
|
-
init(context: InstanceContext): Promise<void>;
|
|
1073
|
-
onTick(): Promise<void>;
|
|
1074
|
-
getState(): ProviderState;
|
|
1075
|
-
onEvent(event: string, data?: any): void;
|
|
1076
|
-
dispose(): void;
|
|
1077
|
-
/** Query UUID instanceId */
|
|
1078
|
-
getInstanceId(): string;
|
|
1079
|
-
private detectTransition;
|
|
1080
|
-
private pushEvent;
|
|
1081
|
-
private flushEvents;
|
|
1082
|
-
private resolveChatTitle;
|
|
1083
|
-
}
|
|
1084
|
-
|
|
1085
|
-
/**
|
|
1086
|
-
* IdeProviderInstance — Runtime instance for IDE Provider
|
|
1087
|
-
*
|
|
1088
|
-
* Within a single IDE:
|
|
1089
|
-
* 1. Native chat (readChat via CDP)
|
|
1090
|
-
* 2. Extension agents (Cline, Roo Code etc)
|
|
1091
|
-
*
|
|
1092
|
-
* IDE Instance manages child Extension Instances.
|
|
1093
|
-
* Daemon collects all via a single IDE Instance.getState() call.
|
|
1094
|
-
*/
|
|
1095
|
-
|
|
1096
|
-
declare class IdeProviderInstance implements ProviderInstance {
|
|
1097
|
-
readonly type: string;
|
|
1098
|
-
readonly category: "ide";
|
|
1099
|
-
private provider;
|
|
1100
|
-
private context;
|
|
1101
|
-
private settings;
|
|
1102
|
-
private events;
|
|
1103
|
-
private tickErrorCount;
|
|
1104
|
-
private cachedChat;
|
|
1105
|
-
private currentStatus;
|
|
1106
|
-
private lastAgentStatuses;
|
|
1107
|
-
private generatingStartedAt;
|
|
1108
|
-
private tickBusy;
|
|
1109
|
-
private monitor;
|
|
1110
|
-
private historyWriter;
|
|
1111
|
-
private autoApproveBusy;
|
|
1112
|
-
private ideVersion;
|
|
1113
|
-
private instanceId;
|
|
1114
|
-
private workspace;
|
|
1115
|
-
private extensions;
|
|
1116
|
-
constructor(provider: ProviderModule, instanceKey?: string);
|
|
1117
|
-
init(context: InstanceContext): Promise<void>;
|
|
1118
|
-
onTick(): Promise<void>;
|
|
1119
|
-
getState(): ProviderState;
|
|
1120
|
-
onEvent(event: string, data?: any): void;
|
|
1121
|
-
dispose(): void;
|
|
1122
|
-
/** Extension Instance add */
|
|
1123
|
-
addExtension(provider: ProviderModule, settings?: Record<string, any>): Promise<void>;
|
|
1124
|
-
/** Extension Instance remove */
|
|
1125
|
-
removeExtension(type: string): void;
|
|
1126
|
-
/** Extension Instance Import */
|
|
1127
|
-
getExtension(type: string): ExtensionProviderInstance | undefined;
|
|
1128
|
-
/** Child Extension list */
|
|
1129
|
-
getExtensionTypes(): string[];
|
|
1130
|
-
/** Query UUID instanceId */
|
|
1131
|
-
getInstanceId(): string;
|
|
1132
|
-
/** all Extension Instance list */
|
|
1133
|
-
getExtensionInstances(): ExtensionProviderInstance[];
|
|
1134
|
-
/** Set workspace from daemon launch context */
|
|
1135
|
-
setWorkspace(workspace: string): void;
|
|
1136
|
-
private readChat;
|
|
1137
|
-
private getReadChatScript;
|
|
1138
|
-
private detectAgentTransitions;
|
|
1139
|
-
private pushEvent;
|
|
1140
|
-
private flushEvents;
|
|
1141
|
-
updateCdp(cdp: InstanceContext['cdp']): void;
|
|
1142
|
-
private autoApproveViaScript;
|
|
1143
|
-
}
|
|
1144
|
-
|
|
1145
|
-
/**
|
|
1146
|
-
* DaemonCdpSetup — Shared CDP initialization helpers
|
|
1147
|
-
*
|
|
1148
|
-
* Common CDP setup logic for consistent
|
|
1149
|
-
* CDP → ProviderInstance registration.
|
|
1150
|
-
*/
|
|
1151
|
-
|
|
1152
|
-
interface CdpSetupContext {
|
|
1153
|
-
providerLoader: ProviderLoader;
|
|
1154
|
-
instanceManager: ProviderInstanceManager;
|
|
1155
|
-
cdpManagers: Map<string, DaemonCdpManager>;
|
|
1156
|
-
sessionRegistry: SessionRegistry;
|
|
1157
|
-
/** Server connection (optional) */
|
|
1158
|
-
serverConn?: any;
|
|
1159
|
-
}
|
|
1160
|
-
interface SetupIdeInstanceOptions {
|
|
1161
|
-
/** Provider-based IDE type (e.g., 'antigravity', 'cursor') */
|
|
1162
|
-
ideType: string;
|
|
1163
|
-
/** Connected CDP manager */
|
|
1164
|
-
manager: DaemonCdpManager;
|
|
1165
|
-
/** CDP manager key (for multi-window: 'antigravity_remote_vs', single: 'antigravity') */
|
|
1166
|
-
managerKey?: string;
|
|
1167
|
-
/** Provider settings override */
|
|
1168
|
-
settings?: Record<string, any>;
|
|
1169
|
-
}
|
|
1170
|
-
/**
|
|
1171
|
-
* Register extension providers on a CDP manager.
|
|
1172
|
-
* Common pattern used during CDP init and periodic scans.
|
|
1173
|
-
*/
|
|
1174
|
-
declare function registerExtensionProviders(providerLoader: ProviderLoader, manager: DaemonCdpManager, ideType: string): void;
|
|
1175
|
-
/**
|
|
1176
|
-
* Setup a CDP-connected IDE as a ProviderInstance.
|
|
1177
|
-
*
|
|
1178
|
-
* Performs:
|
|
1179
|
-
* 1. providerLoader.resolve() to get scripts
|
|
1180
|
-
* 2. Create IdeProviderInstance
|
|
1181
|
-
* 3. Register in InstanceManager
|
|
1182
|
-
* 4. Register enabled extensions
|
|
1183
|
-
* 5. Register runtime sessions (workspace + extension children)
|
|
1184
|
-
*
|
|
1185
|
-
* @returns The created IdeProviderInstance, or null if provider not found
|
|
1186
|
-
*/
|
|
1187
|
-
declare function setupIdeInstance(ctx: CdpSetupContext, opts: SetupIdeInstanceOptions): Promise<IdeProviderInstance | null>;
|
|
1188
|
-
/**
|
|
1189
|
-
* Create and connect a DaemonCdpManager for a given port.
|
|
1190
|
-
*
|
|
1191
|
-
* @returns Connected manager or null if connection failed
|
|
1192
|
-
*/
|
|
1193
|
-
declare function connectCdpManager(port: number, ideType: string, logFn: (msg: string) => void, providerLoader: ProviderLoader, targetId?: string): Promise<DaemonCdpManager | null>;
|
|
1194
|
-
/**
|
|
1195
|
-
* Probe a CDP port to check if it's listening.
|
|
1196
|
-
* @returns true if CDP is available on this port
|
|
1197
|
-
*/
|
|
1198
|
-
declare function probeCdpPort(port: number, timeoutMs?: number): Promise<boolean>;
|
|
1199
|
-
|
|
1200
|
-
/**
|
|
1201
|
-
* DaemonCdpScanner — Periodic CDP port scanning & auto-connect
|
|
1202
|
-
*
|
|
1203
|
-
* Periodic CDP port scanning and auto-connect for IDE discovery.
|
|
1204
|
-
* Provides a unified approach to:
|
|
1205
|
-
* 1. Initial CDP port discovery
|
|
1206
|
-
* 2. Periodic scanning for newly launched IDEs
|
|
1207
|
-
* 3. Multi-window support (multiple pages on same port)
|
|
1208
|
-
*/
|
|
1209
|
-
|
|
1210
|
-
interface CdpScannerOptions {
|
|
1211
|
-
/** Context for setup operations */
|
|
1212
|
-
ctx: CdpSetupContext;
|
|
1213
|
-
/** Log function for per-IDE CDP logs */
|
|
1214
|
-
logFn?: (ideType: string) => (msg: string) => void;
|
|
1215
|
-
/** Whether to support multi-window (multiple pages per port) */
|
|
1216
|
-
multiWindow?: boolean;
|
|
1217
|
-
/** Scan interval in ms (default: 30000) */
|
|
1218
|
-
scanIntervalMs?: number;
|
|
1219
|
-
/** Callback when a new CDP connection is established */
|
|
1220
|
-
onConnected?: (ideType: string, managerKey: string, manager: DaemonCdpManager) => void;
|
|
1221
|
-
}
|
|
1222
|
-
declare class DaemonCdpScanner {
|
|
1223
|
-
private ctx;
|
|
1224
|
-
private opts;
|
|
1225
|
-
private scanTimer;
|
|
1226
|
-
private discoveryTimer;
|
|
1227
|
-
constructor(opts: CdpScannerOptions);
|
|
1228
|
-
/**
|
|
1229
|
-
* Initial CDP discovery — connect to all available IDEs.
|
|
1230
|
-
* Supports both single-window and multi-window modes.
|
|
1231
|
-
*/
|
|
1232
|
-
initialScan(enabledIdes?: string[]): Promise<void>;
|
|
1233
|
-
/**
|
|
1234
|
-
* Start periodic scanning for newly launched IDEs.
|
|
1235
|
-
*/
|
|
1236
|
-
startPeriodicScan(): void;
|
|
1237
|
-
/**
|
|
1238
|
-
* Start periodic agent webview discovery on all connected CDPs.
|
|
1239
|
-
*/
|
|
1240
|
-
startWebviewDiscovery(intervalMs?: number): void;
|
|
1241
|
-
/**
|
|
1242
|
-
* Stop all timers.
|
|
1243
|
-
*/
|
|
1244
|
-
stop(): void;
|
|
1245
|
-
private getLogFn;
|
|
1246
|
-
/**
|
|
1247
|
-
* Single-window connection (standalone mode).
|
|
1248
|
-
* One CDP manager per IDE, first working port wins.
|
|
1249
|
-
*/
|
|
1250
|
-
private connectSingleWindow;
|
|
1251
|
-
/**
|
|
1252
|
-
* Multi-window connection.
|
|
1253
|
-
* Multiple CDP managers per IDE — one per workbench page.
|
|
1254
|
-
*/
|
|
1255
|
-
private connectMultiWindow;
|
|
1256
|
-
}
|
|
1257
|
-
|
|
1258
|
-
/**
|
|
1259
|
-
* DaemonCdpInitializer — Unified CDP initialization + periodic scanning
|
|
1260
|
-
*
|
|
1261
|
-
* Unified CDP initialization + periodic scanning.
|
|
1262
|
-
*
|
|
1263
|
-
* Features:
|
|
1264
|
-
* 1. Initial connection: connectAll() — multi-window aware
|
|
1265
|
-
* 2. Periodic scan: startPeriodicScan() — auto-detect newly opened IDEs
|
|
1266
|
-
* 3. Discovery: startDiscovery() — periodic agent webview discovery
|
|
1267
|
-
*/
|
|
1268
|
-
|
|
1269
|
-
interface CdpInitializerConfig {
|
|
1270
|
-
providerLoader: ProviderLoader;
|
|
1271
|
-
cdpManagers: Map<string, DaemonCdpManager>;
|
|
1272
|
-
/** Filter: only connect these IDEs (empty/undefined = all) */
|
|
1273
|
-
enabledIdes?: string[];
|
|
1274
|
-
/** Callback when a new CDP manager is connected */
|
|
1275
|
-
onConnected?: (ideType: string, manager: DaemonCdpManager, managerKey: string) => void | Promise<void>;
|
|
1276
|
-
/** Callback when a stale/disconnected CDP manager is removed */
|
|
1277
|
-
onDisconnected?: (ideType: string, manager: DaemonCdpManager, managerKey: string, reason: 'ide_closed' | 'target_closed' | 'target_rekeyed') => void | Promise<void>;
|
|
1278
|
-
}
|
|
1279
|
-
declare class DaemonCdpInitializer {
|
|
1280
|
-
private config;
|
|
1281
|
-
private scanTimer;
|
|
1282
|
-
private discoveryTimer;
|
|
1283
|
-
constructor(config: CdpInitializerConfig);
|
|
1284
|
-
/**
|
|
1285
|
-
* Connect to all detected IDEs.
|
|
1286
|
-
* Multi-window aware: creates separate CdpManager per workbench page.
|
|
1287
|
-
*/
|
|
1288
|
-
connectAll(detectedIdes: any[]): Promise<void>;
|
|
1289
|
-
/**
|
|
1290
|
-
* Connect to a single IDE port.
|
|
1291
|
-
* Tries multi-window first (listAllTargets), falls back to direct connect.
|
|
1292
|
-
*/
|
|
1293
|
-
private connectIdePort;
|
|
1294
|
-
private pruneStaleManagers;
|
|
1295
|
-
/**
|
|
1296
|
-
* Start periodic scanning for newly opened IDEs.
|
|
1297
|
-
* Idempotent — ignored if already started.
|
|
1298
|
-
*/
|
|
1299
|
-
startPeriodicScan(intervalMs?: number): void;
|
|
1300
|
-
/**
|
|
1301
|
-
* Start periodic agent webview discovery.
|
|
1302
|
-
*/
|
|
1303
|
-
startDiscovery(intervalMs?: number): void;
|
|
1304
|
-
/** Stop all timers */
|
|
1305
|
-
stop(): void;
|
|
1306
|
-
}
|
|
1307
|
-
|
|
1308
|
-
/**
|
|
1309
|
-
* CliAdapter — common interface for CLI agents
|
|
1310
|
-
*
|
|
1311
|
-
* Contract implemented by all CLI adapters (ProviderCliAdapter etc).
|
|
1312
|
-
*/
|
|
1313
|
-
interface CliAdapter {
|
|
1314
|
-
cliType: string;
|
|
1315
|
-
cliName: string;
|
|
1316
|
-
workingDir: string;
|
|
1317
|
-
spawn(): Promise<void>;
|
|
1318
|
-
sendMessage(text: string): Promise<void>;
|
|
1319
|
-
getStatus(): any;
|
|
1320
|
-
getPartialResponse(): string;
|
|
1321
|
-
saveAndStop?(): Promise<void>;
|
|
1322
|
-
shutdown(): void;
|
|
1323
|
-
detach?(): void;
|
|
1324
|
-
cancel(): void;
|
|
1325
|
-
isProcessing(): boolean;
|
|
1326
|
-
isReady(): boolean;
|
|
1327
|
-
setOnStatusChange(callback: () => void): void;
|
|
1328
|
-
setServerConn?(serverConn: any): void;
|
|
1329
|
-
setOnPtyData?(callback: (data: string) => void): void;
|
|
1330
|
-
writeRaw?(data: string): void;
|
|
1331
|
-
resize?(cols: number, rows: number): void;
|
|
1332
|
-
}
|
|
1333
|
-
|
|
1334
|
-
interface PtySpawnOptions {
|
|
1335
|
-
cwd: string;
|
|
1336
|
-
env: Record<string, string>;
|
|
1337
|
-
cols: number;
|
|
1338
|
-
rows: number;
|
|
1339
|
-
}
|
|
1340
|
-
interface PtyRuntimeWriteOwner {
|
|
1341
|
-
clientId: string;
|
|
1342
|
-
ownerType: 'agent' | 'user';
|
|
1343
|
-
}
|
|
1344
|
-
interface PtyRuntimeClientInfo {
|
|
1345
|
-
clientId: string;
|
|
1346
|
-
type: 'daemon' | 'web' | 'local-terminal';
|
|
1347
|
-
readOnly: boolean;
|
|
1348
|
-
}
|
|
1349
|
-
interface PtyRuntimeMetadata {
|
|
1350
|
-
runtimeId: string;
|
|
1351
|
-
runtimeKey?: string;
|
|
1352
|
-
displayName?: string;
|
|
1353
|
-
workspaceLabel?: string;
|
|
1354
|
-
writeOwner?: PtyRuntimeWriteOwner | null;
|
|
1355
|
-
attachedClients?: PtyRuntimeClientInfo[];
|
|
1356
|
-
}
|
|
1357
|
-
interface PtyRuntimeTransport {
|
|
1358
|
-
readonly pid: number;
|
|
1359
|
-
readonly ready: Promise<void>;
|
|
1360
|
-
write(data: string): void;
|
|
1361
|
-
resize(cols: number, rows: number): void;
|
|
1362
|
-
kill(): void;
|
|
1363
|
-
clearBuffer?(): void;
|
|
1364
|
-
detach?(): void;
|
|
1365
|
-
getMetadata?(): PtyRuntimeMetadata | null;
|
|
1366
|
-
onData(callback: (data: string) => void): void;
|
|
1367
|
-
onExit(callback: (info: {
|
|
1368
|
-
exitCode: number;
|
|
1369
|
-
}) => void): void;
|
|
1370
|
-
}
|
|
1371
|
-
interface PtyTransportFactory {
|
|
1372
|
-
spawn(command: string, args: string[], options: PtySpawnOptions): PtyRuntimeTransport;
|
|
1373
|
-
}
|
|
1374
|
-
declare class NodePtyTransportFactory implements PtyTransportFactory {
|
|
1375
|
-
spawn(command: string, args: string[], options: PtySpawnOptions): PtyRuntimeTransport;
|
|
1376
|
-
}
|
|
1377
|
-
|
|
1378
|
-
/**
|
|
1379
|
-
* DaemonCliManager — CLI session creation, management, and command handling
|
|
1380
|
-
*
|
|
1381
|
-
* Separated from adhdev-daemon.ts.
|
|
1382
|
-
* CLI cases of createAdapter, startCliSession, stopCliSession, executeDaemonCommand extracted to independent module extract.
|
|
1383
|
-
*/
|
|
1384
|
-
|
|
1385
|
-
interface CliManagerDeps {
|
|
1386
|
-
/** Server connection — injected into adapter */
|
|
1387
|
-
getServerConn(): any | null;
|
|
1388
|
-
/** P2P — PTY output transmit */
|
|
1389
|
-
getP2p(): {
|
|
1390
|
-
broadcastPtyOutput(key: string, data: string): void;
|
|
1391
|
-
} | null;
|
|
1392
|
-
/** StatusReporter callback */
|
|
1393
|
-
onStatusChange(): void;
|
|
1394
|
-
removeAgentTracking(key: string): void;
|
|
1395
|
-
/** InstanceManager — register in CLI unified status */
|
|
1396
|
-
getInstanceManager(): ProviderInstanceManager | null;
|
|
1397
|
-
getSessionRegistry?(): SessionRegistry | null;
|
|
1398
|
-
createPtyTransportFactory?: (params: CliTransportFactoryParams) => PtyTransportFactory | null;
|
|
1399
|
-
listHostedCliRuntimes?: () => Promise<HostedCliRuntimeDescriptor[]>;
|
|
1400
|
-
}
|
|
1401
|
-
type CommandResult = {
|
|
1402
|
-
success: boolean;
|
|
1403
|
-
[key: string]: unknown;
|
|
1404
|
-
};
|
|
1405
|
-
interface CliTransportFactoryParams {
|
|
1406
|
-
runtimeId: string;
|
|
1407
|
-
providerType: string;
|
|
1408
|
-
workspace: string;
|
|
1409
|
-
cliArgs?: string[];
|
|
1410
|
-
attachExisting?: boolean;
|
|
1411
|
-
}
|
|
1412
|
-
interface HostedCliRuntimeDescriptor {
|
|
1413
|
-
runtimeId: string;
|
|
1414
|
-
runtimeKey?: string;
|
|
1415
|
-
displayName?: string;
|
|
1416
|
-
workspaceLabel?: string;
|
|
1417
|
-
lifecycle?: 'starting' | 'running' | 'stopping' | 'stopped' | 'failed' | 'interrupted';
|
|
1418
|
-
recoveryState?: string | null;
|
|
1419
|
-
cliType: string;
|
|
1420
|
-
workspace: string;
|
|
1421
|
-
cliArgs?: string[];
|
|
1422
|
-
}
|
|
1423
|
-
declare class DaemonCliManager {
|
|
1424
|
-
readonly adapters: Map<string, CliAdapter>;
|
|
1425
|
-
private deps;
|
|
1426
|
-
private providerLoader;
|
|
1427
|
-
constructor(deps: CliManagerDeps, providerLoader: ProviderLoader);
|
|
1428
|
-
getCliKey(cliType: string, dir: string): string;
|
|
1429
|
-
private persistRecentDir;
|
|
1430
|
-
private persistRecentActivity;
|
|
1431
|
-
private getTransportFactory;
|
|
1432
|
-
private createAdapter;
|
|
1433
|
-
private startCliExitMonitor;
|
|
1434
|
-
private registerCliInstance;
|
|
1435
|
-
startSession(cliType: string, workingDir: string, cliArgs?: string[], initialModel?: string): Promise<void>;
|
|
1436
|
-
stopSession(key: string): Promise<void>;
|
|
1437
|
-
stopSessionWithMode(key: string, mode: 'hard' | 'save'): Promise<void>;
|
|
1438
|
-
shutdownAll(): void;
|
|
1439
|
-
detachAll(): void;
|
|
1440
|
-
restoreHostedSessions(records?: HostedCliRuntimeDescriptor[]): Promise<number>;
|
|
1441
|
-
/**
|
|
1442
|
-
* Search for CLI adapter. Priority order:
|
|
1443
|
-
* 0. sessionId (UUID direct match)
|
|
1444
|
-
* 1. agentType + dir (iteration match)
|
|
1445
|
-
* 2. agentType fuzzy match (⚠ returns first match when multiple sessions exist)
|
|
1446
|
-
*/
|
|
1447
|
-
findAdapter(agentType: string, opts?: {
|
|
1448
|
-
dir?: string;
|
|
1449
|
-
instanceKey?: string;
|
|
1450
|
-
}): {
|
|
1451
|
-
adapter: CliAdapter;
|
|
1452
|
-
key: string;
|
|
1453
|
-
} | null;
|
|
1454
|
-
handleCliCommand(cmd: string, args: any): Promise<CommandResult | null>;
|
|
1455
|
-
}
|
|
1456
|
-
|
|
1457
|
-
/**
|
|
1458
|
-
* DaemonCommandRouter — Unified command routing for daemon-level commands
|
|
1459
|
-
*
|
|
1460
|
-
* Unified command routing for daemon-level commands.
|
|
1461
|
-
*
|
|
1462
|
-
* Routing flow:
|
|
1463
|
-
* 1. Daemon-level commands (launch_ide, stop_ide, restart_ide, etc.) → handled here
|
|
1464
|
-
* 2. CLI/ACP commands → delegated to cliManager
|
|
1465
|
-
* 3. Everything else → delegated to commandHandler.handle()
|
|
1466
|
-
*/
|
|
1467
|
-
|
|
1468
|
-
interface CommandRouterDeps {
|
|
1469
|
-
commandHandler: DaemonCommandHandler;
|
|
1470
|
-
cliManager: DaemonCliManager;
|
|
1471
|
-
cdpManagers: Map<string, DaemonCdpManager>;
|
|
1472
|
-
providerLoader: ProviderLoader;
|
|
1473
|
-
instanceManager: ProviderInstanceManager;
|
|
1474
|
-
/** Reference to detected IDEs array (mutable — router updates it) */
|
|
1475
|
-
detectedIdes: {
|
|
1476
|
-
value: any[];
|
|
1477
|
-
};
|
|
1478
|
-
sessionRegistry: SessionRegistry;
|
|
1479
|
-
/** Callback for CDP manager creation after launch_ide */
|
|
1480
|
-
onCdpManagerCreated?: (ideType: string, manager: DaemonCdpManager) => void;
|
|
1481
|
-
/** Callback after IDE connected (e.g., startAgentStreamPolling) */
|
|
1482
|
-
onIdeConnected?: () => void;
|
|
1483
|
-
/** Callback after status change (stop_ide, restart) */
|
|
1484
|
-
onStatusChange?: () => void;
|
|
1485
|
-
/** Callback after chat-related commands */
|
|
1486
|
-
onPostChatCommand?: () => void;
|
|
1487
|
-
/** Get a connected CDP manager (for agent stream reset check) */
|
|
1488
|
-
getCdpLogFn?: (ideType: string) => (msg: string) => void;
|
|
1489
|
-
/** Package name for upgrade detection ('adhdev' or '@adhdev/daemon-standalone') */
|
|
1490
|
-
packageName?: string;
|
|
1491
|
-
}
|
|
1492
|
-
interface CommandRouterResult {
|
|
1493
|
-
success: boolean;
|
|
1494
|
-
[key: string]: unknown;
|
|
1495
|
-
}
|
|
1496
|
-
declare class DaemonCommandRouter {
|
|
1497
|
-
private deps;
|
|
1498
|
-
constructor(deps: CommandRouterDeps);
|
|
1499
|
-
/**
|
|
1500
|
-
* Unified command routing.
|
|
1501
|
-
* Returns result for all commands:
|
|
1502
|
-
* 1. Daemon-level commands (launch_ide, stop_ide, etc.)
|
|
1503
|
-
* 2. CLI commands (launch_cli, stop_cli, agent_command)
|
|
1504
|
-
* 3. DaemonCommandHandler delegation (CDP/agent-stream/file commands)
|
|
1505
|
-
*
|
|
1506
|
-
* @param cmd Command name
|
|
1507
|
-
* @param args Command arguments
|
|
1508
|
-
* @param source Log source ('ws' | 'p2p' | 'standalone' | etc.)
|
|
1509
|
-
*/
|
|
1510
|
-
execute(cmd: string, args: any, source?: string): Promise<CommandRouterResult>;
|
|
1511
|
-
/**
|
|
1512
|
-
* Daemon-level command execution (IDE start/stop/restart, CLI, detect, logs).
|
|
1513
|
-
* Returns null if not handled at this level → caller delegates to CommandHandler.
|
|
1514
|
-
*/
|
|
1515
|
-
private executeDaemonCommand;
|
|
1516
|
-
/**
|
|
1517
|
-
* IDE stop: CDP disconnect + InstanceManager cleanup + optionally kill OS process
|
|
1518
|
-
*/
|
|
1519
|
-
private stopIde;
|
|
1520
|
-
}
|
|
1521
|
-
|
|
1522
|
-
/**
|
|
1523
|
-
* DaemonStatusReporter — status collect & transmit (StatusReport / P2P / StatusEvent)
|
|
1524
|
-
*
|
|
1525
|
-
* Collect status from ProviderInstanceManager → assemble payload → transmit
|
|
1526
|
-
* Each Instance manages its own status/transition. This module only assembles + transmits.
|
|
1527
|
-
*/
|
|
1528
|
-
|
|
1529
|
-
interface StatusReporterDeps {
|
|
1530
|
-
serverConn: {
|
|
1531
|
-
isConnected(): boolean;
|
|
1532
|
-
sendMessage(type: string, data: any): void;
|
|
1533
|
-
getUserPlan(): string;
|
|
1534
|
-
} | null;
|
|
1535
|
-
cdpManagers: Map<string, {
|
|
1536
|
-
isConnected: boolean;
|
|
1537
|
-
}>;
|
|
1538
|
-
p2p: {
|
|
1539
|
-
isConnected: boolean;
|
|
1540
|
-
isAvailable: boolean;
|
|
1541
|
-
connectionState: string;
|
|
1542
|
-
connectedPeerCount: number;
|
|
1543
|
-
screenshotActive: boolean;
|
|
1544
|
-
sendStatus(data: any): void;
|
|
1545
|
-
} | null;
|
|
1546
|
-
providerLoader: {
|
|
1547
|
-
resolve(type: string): any;
|
|
1548
|
-
getAll(): any[];
|
|
1549
|
-
};
|
|
1550
|
-
detectedIdes: any[];
|
|
1551
|
-
instanceId: string;
|
|
1552
|
-
daemonVersion?: string;
|
|
1553
|
-
instanceManager: {
|
|
1554
|
-
collectAllStates(): ProviderState[];
|
|
1555
|
-
collectStatesByCategory(cat: string): ProviderState[];
|
|
1556
|
-
};
|
|
1557
|
-
getScreenshotUsage?: () => {
|
|
1558
|
-
dailyUsedMinutes: number;
|
|
1559
|
-
dailyBudgetMinutes: number;
|
|
1560
|
-
budgetExhausted: boolean;
|
|
1561
|
-
} | null;
|
|
1562
|
-
}
|
|
1563
|
-
declare class DaemonStatusReporter {
|
|
1564
|
-
private deps;
|
|
1565
|
-
private log;
|
|
1566
|
-
private lastStatusSentAt;
|
|
1567
|
-
private statusPendingThrottle;
|
|
1568
|
-
private lastP2PStatusHash;
|
|
1569
|
-
private lastStatusSummary;
|
|
1570
|
-
private statusTimer;
|
|
1571
|
-
private p2pTimer;
|
|
1572
|
-
constructor(deps: StatusReporterDeps, opts?: {
|
|
1573
|
-
logFn?: (msg: string) => void;
|
|
1574
|
-
});
|
|
1575
|
-
startReporting(): void;
|
|
1576
|
-
stopReporting(): void;
|
|
1577
|
-
onStatusChange(): void;
|
|
1578
|
-
throttledReport(): void;
|
|
1579
|
-
emitStatusEvent(event: Record<string, unknown>): void;
|
|
1580
|
-
removeAgentTracking(_key: string): void;
|
|
1581
|
-
updateAgentStreams(_ideType: string, _streams: any[]): void;
|
|
1582
|
-
/** Reset P2P dedup hash — forces next send to transmit even if content unchanged */
|
|
1583
|
-
resetP2PHash(): void;
|
|
1584
|
-
private ts;
|
|
1585
|
-
sendUnifiedStatusReport(opts?: {
|
|
1586
|
-
p2pOnly?: boolean;
|
|
1587
|
-
}): Promise<void>;
|
|
1588
|
-
private sendP2PPayload;
|
|
1589
|
-
private simpleHash;
|
|
1590
|
-
}
|
|
1591
|
-
|
|
1592
|
-
/**
|
|
1593
|
-
* Status Builders — shared conversion functions for ProviderState → ManagedEntry
|
|
1594
|
-
*
|
|
1595
|
-
* Used by:
|
|
1596
|
-
* - daemon-standalone (StandaloneServer.getStatus)
|
|
1597
|
-
* - DaemonStatusReporter
|
|
1598
|
-
*
|
|
1599
|
-
* Consolidates ProviderState→ManagedEntry mapping logic.
|
|
1600
|
-
*/
|
|
1601
|
-
|
|
1602
|
-
/**
|
|
1603
|
-
* Find a CDP manager by key, with prefix matching for multi-window support.
|
|
1604
|
-
*
|
|
1605
|
-
* Lookup order:
|
|
1606
|
-
* 1. Exact match: cdpManagers.get(key)
|
|
1607
|
-
* 2. Prefix match: key starts with `${ideType}_` (multi-window: "cursor_remote_vs")
|
|
1608
|
-
* 3. null
|
|
1609
|
-
*
|
|
1610
|
-
* This replaces raw `cdpManagers.get(ideType)` calls that broke when
|
|
1611
|
-
* multi-window keys like "cursor_remote_vs" were used.
|
|
1612
|
-
*/
|
|
1613
|
-
declare function findCdpManager(cdpManagers: Map<string, DaemonCdpManager>, key: string): DaemonCdpManager | null;
|
|
1614
|
-
/**
|
|
1615
|
-
* Check if any CDP manager matches the given key (exact or prefix).
|
|
1616
|
-
*/
|
|
1617
|
-
declare function hasCdpManager(cdpManagers: Map<string, DaemonCdpManager>, key: string): boolean;
|
|
1618
|
-
/**
|
|
1619
|
-
* Check if any CDP manager matching the key is connected.
|
|
1620
|
-
*/
|
|
1621
|
-
declare function isCdpConnected(cdpManagers: Map<string, DaemonCdpManager>, key: string): boolean;
|
|
1622
|
-
declare function buildSessionEntries(allStates: ProviderState[], cdpManagers: Map<string, DaemonCdpManager>): SessionEntry[];
|
|
1623
|
-
|
|
1624
|
-
/**
|
|
1625
|
-
* Shared status snapshot builders.
|
|
1626
|
-
*
|
|
1627
|
-
* Used by:
|
|
1628
|
-
* - DaemonStatusReporter (cloud)
|
|
1629
|
-
* - daemon-standalone HTTP/WS status responses
|
|
1630
|
-
*/
|
|
1631
|
-
|
|
1632
|
-
interface StatusSnapshotOptions {
|
|
1633
|
-
allStates: ProviderState[];
|
|
1634
|
-
cdpManagers: Map<string, unknown>;
|
|
1635
|
-
providerLoader: {
|
|
1636
|
-
getAll(): Array<{
|
|
1637
|
-
type: string;
|
|
1638
|
-
icon?: string;
|
|
1639
|
-
displayName?: string;
|
|
1640
|
-
category: 'ide' | 'extension' | 'cli' | 'acp';
|
|
1641
|
-
}>;
|
|
1642
|
-
};
|
|
1643
|
-
detectedIdes: Array<{
|
|
1644
|
-
id: string;
|
|
1645
|
-
name?: string;
|
|
1646
|
-
displayName?: string;
|
|
1647
|
-
installed?: boolean;
|
|
1648
|
-
path?: string;
|
|
1649
|
-
}>;
|
|
1650
|
-
instanceId: string;
|
|
1651
|
-
version: string;
|
|
1652
|
-
daemonMode: boolean;
|
|
1653
|
-
timestamp?: number;
|
|
1654
|
-
p2p?: StatusReportPayload['p2p'];
|
|
1655
|
-
machineNickname?: string | null;
|
|
1656
|
-
}
|
|
1657
|
-
interface StatusSnapshot extends StatusReportPayload {
|
|
1658
|
-
availableProviders: AvailableProviderInfo[];
|
|
1659
|
-
}
|
|
1660
|
-
declare function buildStatusSnapshot(options: StatusSnapshotOptions): StatusSnapshot;
|
|
1661
|
-
|
|
1662
|
-
/**
|
|
1663
|
-
* ADHDev Daemon — unified logger (v2)
|
|
1664
|
-
*
|
|
1665
|
-
* log level: DEBUG < INFO < WARN < ERROR
|
|
1666
|
-
*
|
|
1667
|
-
* Features:
|
|
1668
|
-
* 1. daemonLog(category, msg, level) — explicit per-category logging
|
|
1669
|
-
* 2. installGlobalInterceptor() — Auto-intercept console.log (once on daemon start)
|
|
1670
|
-
* 3. Recent log ring buffer — for remote transmission via P2P/WS
|
|
1671
|
-
* 4. File logging — ~/Library/Logs/adhdev/daemon.log (10MB rolling)
|
|
1672
|
-
*
|
|
1673
|
-
* use:
|
|
1674
|
-
* import { daemonLog, LOG } from './daemon-logger';
|
|
1675
|
-
* LOG.info('CDP', 'Connected to cursor on port 9333');
|
|
1676
|
-
* LOG.debug('StatusReport', 'P2P heartbeat sent');
|
|
1677
|
-
* LOG.warn('IdeInstance', 'onTick error: ...');
|
|
1678
|
-
* LOG.error('Server', 'WebSocket disconnected');
|
|
1679
|
-
*/
|
|
1680
|
-
type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
1681
|
-
declare function setLogLevel(level: LogLevel): void;
|
|
1682
|
-
declare function getLogLevel(): LogLevel;
|
|
1683
|
-
interface LogEntry {
|
|
1684
|
-
ts: number;
|
|
1685
|
-
level: LogLevel;
|
|
1686
|
-
category: string;
|
|
1687
|
-
message: string;
|
|
1688
|
-
}
|
|
1689
|
-
/** Get recent N logs (for remote transmission) */
|
|
1690
|
-
declare function getRecentLogs(count?: number, minLevel?: LogLevel): LogEntry[];
|
|
1691
|
-
/**
|
|
1692
|
-
* Scoped logger instance for a specific component.
|
|
1693
|
-
* Created via LOG.forComponent('CDP:cursor').
|
|
1694
|
-
*/
|
|
1695
|
-
interface ScopedLogger {
|
|
1696
|
-
debug: (msg: string) => void;
|
|
1697
|
-
info: (msg: string) => void;
|
|
1698
|
-
warn: (msg: string) => void;
|
|
1699
|
-
error: (msg: string) => void;
|
|
1700
|
-
/** Returns a plain (msg: string) => void function at the given level.
|
|
1701
|
-
* Useful as logFn callback for ProviderLoader, DaemonStatusReporter, etc. */
|
|
1702
|
-
asLogFn: (level?: LogLevel) => (msg: string) => void;
|
|
1703
|
-
}
|
|
1704
|
-
/**
|
|
1705
|
-
* LOG — unified logging API
|
|
1706
|
-
*
|
|
1707
|
-
* Usage:
|
|
1708
|
-
* LOG.info('CDP', 'Connected to cursor on port 9333');
|
|
1709
|
-
* LOG.debug('StatusReport', 'P2P heartbeat sent');
|
|
1710
|
-
*
|
|
1711
|
-
* Component-scoped logger:
|
|
1712
|
-
* const log = LOG.forComponent('ACP:cursor');
|
|
1713
|
-
* log.info('Session created');
|
|
1714
|
-
* log.debug('Heartbeat');
|
|
1715
|
-
*
|
|
1716
|
-
* As callback for external components:
|
|
1717
|
-
* new ProviderLoader({ logFn: LOG.forComponent('Provider').asLogFn() });
|
|
1718
|
-
* new DaemonStatusReporter({ logFn: LOG.forComponent('Status').asLogFn() });
|
|
1719
|
-
*/
|
|
1720
|
-
declare const LOG: {
|
|
1721
|
-
debug: (category: string, msg: string) => void;
|
|
1722
|
-
info: (category: string, msg: string) => void;
|
|
1723
|
-
warn: (category: string, msg: string) => void;
|
|
1724
|
-
error: (category: string, msg: string) => void;
|
|
1725
|
-
/**
|
|
1726
|
-
* Create a scoped logger for a specific component.
|
|
1727
|
-
* Category is baked in so callers only pass the message.
|
|
1728
|
-
*/
|
|
1729
|
-
forComponent(category: string): ScopedLogger;
|
|
1730
|
-
};
|
|
1731
|
-
/**
|
|
1732
|
-
* console.log/warn/error global interceptor install
|
|
1733
|
-
* Prevent recording in places not using daemonLog.
|
|
1734
|
-
* daemon start when 1time call.
|
|
1735
|
-
*/
|
|
1736
|
-
declare function installGlobalInterceptor(): void;
|
|
1737
|
-
|
|
1738
|
-
/**
|
|
1739
|
-
* ADHDev Daemon — Command History Logger
|
|
1740
|
-
*
|
|
1741
|
-
* Record all commands from dashboard/WS/P2P/Extension/API to local file.
|
|
1742
|
-
* Per-date JSONL file, 7-day retention, 5MB limit.
|
|
1743
|
-
*
|
|
1744
|
-
* Purpose:
|
|
1745
|
-
* - Debugging: track what command came and when
|
|
1746
|
-
* - Audit: record all commands executed from remote
|
|
1747
|
-
* - Stats: identify frequently used features
|
|
1748
|
-
*/
|
|
1749
|
-
interface CommandLogEntry {
|
|
1750
|
-
ts: string;
|
|
1751
|
-
cmd: string;
|
|
1752
|
-
source: 'ws' | 'p2p' | 'ext' | 'api' | 'standalone' | 'unknown';
|
|
1753
|
-
args?: Record<string, unknown>;
|
|
1754
|
-
success?: boolean;
|
|
1755
|
-
error?: string;
|
|
1756
|
-
durationMs?: number;
|
|
1757
|
-
}
|
|
1758
|
-
/**
|
|
1759
|
-
* Log a command received from the dashboard/WS/P2P/extension/API.
|
|
1760
|
-
* Call this at the entry point of command handling.
|
|
1761
|
-
*/
|
|
1762
|
-
declare function logCommand(entry: CommandLogEntry): void;
|
|
1763
|
-
/**
|
|
1764
|
-
* Read recent command history (for dashboard display / debugging)
|
|
1765
|
-
*/
|
|
1766
|
-
declare function getRecentCommands(count?: number): CommandLogEntry[];
|
|
1767
|
-
|
|
1768
|
-
/**
|
|
1769
|
-
* ADHDev Launcher — IDE Launch/Relaunch with CDP
|
|
1770
|
-
*
|
|
1771
|
-
* Launches IDE with Chrome DevTools Protocol (remote-debugging-port).
|
|
1772
|
-
* If IDE is already running, terminates it and restarts with CDP option.
|
|
1773
|
-
*
|
|
1774
|
-
* Pipeline:
|
|
1775
|
-
* 1. IDE process detection (already running?)
|
|
1776
|
-
* 2. If already running with CDP → reuse as-is
|
|
1777
|
-
* 3. If running without CDP → kill process → wait → restart with CDP
|
|
1778
|
-
* 4. Not running → start fresh with CDP
|
|
1779
|
-
*
|
|
1780
|
-
* Usage:
|
|
1781
|
-
* adhdev launch — Launch configured IDE with CDP port
|
|
1782
|
-
* adhdev launch cursor — Launch Cursor with CDP port
|
|
1783
|
-
* adhdev launch --workspace /path — Open specific workspace
|
|
1784
|
-
*/
|
|
1785
|
-
/** Kill IDE process (graceful → force) */
|
|
1786
|
-
declare function killIdeProcess(ideId: string): Promise<boolean>;
|
|
1787
|
-
/** Check if IDE process is running */
|
|
1788
|
-
declare function isIdeRunning(ideId: string): boolean;
|
|
1789
|
-
interface LaunchOptions {
|
|
1790
|
-
ideId?: string;
|
|
1791
|
-
workspace?: string;
|
|
1792
|
-
newWindow?: boolean;
|
|
1793
|
-
}
|
|
1794
|
-
interface LaunchResult {
|
|
1795
|
-
success: boolean;
|
|
1796
|
-
ideId: string;
|
|
1797
|
-
ideName: string;
|
|
1798
|
-
port: number;
|
|
1799
|
-
action: 'started' | 'restarted' | 'reused' | 'failed';
|
|
1800
|
-
message: string;
|
|
1801
|
-
error?: string;
|
|
1802
|
-
}
|
|
1803
|
-
/**
|
|
1804
|
-
* Execute IDE with CDP port (relaunch pipeline)
|
|
1805
|
-
*
|
|
1806
|
-
* 1. IDE detect
|
|
1807
|
-
* 2. per-fixed IDE CDP port determine
|
|
1808
|
-
* 3. CDP not active → reuse
|
|
1809
|
-
* 4. IDE execute during but CDP none → terminate → restart with CDP
|
|
1810
|
-
* 5. IDE not running → start fresh with CDP
|
|
1811
|
-
*/
|
|
1812
|
-
declare function launchWithCdp(options?: LaunchOptions): Promise<LaunchResult>;
|
|
1813
|
-
declare function getAvailableIdeIds(): string[];
|
|
1814
|
-
|
|
1815
|
-
declare const DEFAULT_DAEMON_PORT = 19222;
|
|
1816
|
-
declare const DAEMON_WS_PATH = "/ipc";
|
|
1817
|
-
|
|
1818
|
-
/**
|
|
1819
|
-
* Shared helper for forwarding agent stream snapshots into the IDE instance.
|
|
1820
|
-
*
|
|
1821
|
-
* Both cloud and standalone daemons use the same InstanceManager wiring.
|
|
1822
|
-
*/
|
|
1823
|
-
declare function forwardAgentStreamsToIdeInstance(instanceManager: {
|
|
1824
|
-
getInstance: (key: string) => any;
|
|
1825
|
-
}, ideType: string, streams: any[]): void;
|
|
1826
|
-
|
|
1827
|
-
/**
|
|
1828
|
-
* ProviderCliAdapter — Script-based CLI Adapter
|
|
1829
|
-
*
|
|
1830
|
-
* All CLI providers use versioned scripts (like IDE providers).
|
|
1831
|
-
* Scripts are Node.js functions that receive PTY buffer data and return structured results.
|
|
1832
|
-
*
|
|
1833
|
-
* Required scripts in scripts/{version}/scripts.js:
|
|
1834
|
-
* - detectStatus(input) → AgentStatus string ('idle' | 'generating' | 'waiting_approval')
|
|
1835
|
-
* - parseOutput(input) → ReadChatResult { messages, status, activeModal, ... }
|
|
1836
|
-
* - parseApproval(input) → ModalInfo | null
|
|
1837
|
-
*
|
|
1838
|
-
* provider.json contract:
|
|
1839
|
-
* type, name, category: 'cli', binary, spawn, approvalKeys
|
|
1840
|
-
* compatibility: [{ ideVersion, scriptDir }] ← versioned scripts
|
|
1841
|
-
*/
|
|
1842
|
-
|
|
1843
|
-
interface CliChatMessage {
|
|
1844
|
-
role: 'user' | 'assistant';
|
|
1845
|
-
content: string;
|
|
1846
|
-
timestamp?: number;
|
|
1847
|
-
}
|
|
1848
|
-
interface CliSessionStatus {
|
|
1849
|
-
status: 'idle' | 'generating' | 'waiting_approval' | 'error' | 'stopped' | 'starting';
|
|
1850
|
-
messages: CliChatMessage[];
|
|
1851
|
-
workingDir: string;
|
|
1852
|
-
activeModal: {
|
|
1853
|
-
message: string;
|
|
1854
|
-
buttons: string[];
|
|
1855
|
-
} | null;
|
|
1856
|
-
terminalHistory?: string;
|
|
1857
|
-
}
|
|
1858
|
-
/**
|
|
1859
|
-
* CLI Script Functions.
|
|
1860
|
-
* Unlike IDE scripts (which return JS code strings for CDP evaluate),
|
|
1861
|
-
* CLI scripts are Node.js functions that receive PTY buffer data and return structured results.
|
|
1862
|
-
*/
|
|
1863
|
-
interface CliScripts {
|
|
1864
|
-
/** Full PTY buffer → ReadChatResult (messages, status, activeModal) */
|
|
1865
|
-
parseOutput?: (input: CliScriptInput) => any;
|
|
1866
|
-
/** Lightweight status detection (high-frequency polling) → AgentStatus string */
|
|
1867
|
-
detectStatus?: (input: {
|
|
1868
|
-
tail: string;
|
|
1869
|
-
screenText?: string;
|
|
1870
|
-
rawBuffer?: string;
|
|
1871
|
-
}) => string | null;
|
|
1872
|
-
/** Parse approval modal from PTY output → ModalInfo | null */
|
|
1873
|
-
parseApproval?: (input: {
|
|
1874
|
-
buffer: string;
|
|
1875
|
-
screenText?: string;
|
|
1876
|
-
rawBuffer?: string;
|
|
1877
|
-
tail: string;
|
|
1878
|
-
}) => {
|
|
1879
|
-
message: string;
|
|
1880
|
-
buttons: string[];
|
|
1881
|
-
} | null;
|
|
1882
|
-
/** Produce a cli-specific prompt from a dashboard action payload */
|
|
1883
|
-
resolveAction?: (data: any) => string;
|
|
1884
|
-
/** Custom scripts */
|
|
1885
|
-
[name: string]: ((input: any) => any) | undefined;
|
|
1886
|
-
}
|
|
1887
|
-
interface CliScriptInput {
|
|
1888
|
-
buffer: string;
|
|
1889
|
-
rawBuffer: string;
|
|
1890
|
-
recentBuffer: string;
|
|
1891
|
-
screenText: string;
|
|
1892
|
-
terminalHistory?: string;
|
|
1893
|
-
messages: CliChatMessage[];
|
|
1894
|
-
partialResponse: string;
|
|
1895
|
-
}
|
|
1896
|
-
interface CliProviderModule {
|
|
1897
|
-
type: string;
|
|
1898
|
-
name: string;
|
|
1899
|
-
category: 'cli';
|
|
1900
|
-
binary: string;
|
|
1901
|
-
sendDelayMs?: number;
|
|
1902
|
-
sendKey?: string;
|
|
1903
|
-
submitStrategy?: 'wait_for_echo' | 'immediate';
|
|
1904
|
-
spawn: {
|
|
1905
|
-
command: string;
|
|
1906
|
-
args: string[];
|
|
1907
|
-
shell: boolean;
|
|
1908
|
-
env: Record<string, string>;
|
|
1909
|
-
};
|
|
1910
|
-
timeouts?: {
|
|
1911
|
-
/** PTY output batch transmit interval (default 50ms) */
|
|
1912
|
-
ptyFlush?: number;
|
|
1913
|
-
/** Wait for startup dialog auto-proceed (default 300ms) */
|
|
1914
|
-
dialogAccept?: number;
|
|
1915
|
-
/** Approval detect cooldown (default 2000ms) */
|
|
1916
|
-
approvalCooldown?: number;
|
|
1917
|
-
/** Check for completion on no-response during generating (default 6000ms) */
|
|
1918
|
-
generatingIdle?: number;
|
|
1919
|
-
/** Check for completion on no-response (default 5000ms) */
|
|
1920
|
-
idleFinish?: number;
|
|
1921
|
-
/** Max response wait (default 300000ms = 5min) */
|
|
1922
|
-
maxResponse?: number;
|
|
1923
|
-
/** shutdown after kill wait (default 1000ms) */
|
|
1924
|
-
shutdownGrace?: number;
|
|
1925
|
-
/** Output settle debounce before evaluating status (default 300ms) */
|
|
1926
|
-
outputSettle?: number;
|
|
1927
|
-
};
|
|
1928
|
-
resume?: ProviderResumeCapability;
|
|
1929
|
-
}
|
|
1930
|
-
declare class ProviderCliAdapter implements CliAdapter {
|
|
1931
|
-
private extraArgs;
|
|
1932
|
-
readonly cliType: string;
|
|
1933
|
-
readonly cliName: string;
|
|
1934
|
-
workingDir: string;
|
|
1935
|
-
private provider;
|
|
1936
|
-
private ptyProcess;
|
|
1937
|
-
private transportFactory;
|
|
1938
|
-
private messages;
|
|
1939
|
-
private committedMessages;
|
|
1940
|
-
private structuredMessages;
|
|
1941
|
-
private currentStatus;
|
|
1942
|
-
private onStatusChange;
|
|
1943
|
-
private responseBuffer;
|
|
1944
|
-
private recentOutputBuffer;
|
|
1945
|
-
private isWaitingForResponse;
|
|
1946
|
-
private activeModal;
|
|
1947
|
-
private responseTimeout;
|
|
1948
|
-
private idleTimeout;
|
|
1949
|
-
private ready;
|
|
1950
|
-
private startupBuffer;
|
|
1951
|
-
private startupParseGate;
|
|
1952
|
-
private spawnAt;
|
|
1953
|
-
private onPtyDataCallback;
|
|
1954
|
-
private pendingOutputParseBuffer;
|
|
1955
|
-
private pendingOutputParseTimer;
|
|
1956
|
-
private ptyOutputBuffer;
|
|
1957
|
-
private ptyOutputFlushTimer;
|
|
1958
|
-
private serverConn;
|
|
1959
|
-
private logBuffer;
|
|
1960
|
-
private lastApprovalResolvedAt;
|
|
1961
|
-
private approvalTransitionBuffer;
|
|
1962
|
-
private approvalExitTimeout;
|
|
1963
|
-
private pendingScriptStatus;
|
|
1964
|
-
private pendingScriptStatusSince;
|
|
1965
|
-
private pendingScriptStatusTimer;
|
|
1966
|
-
private settleTimer;
|
|
1967
|
-
private settledBuffer;
|
|
1968
|
-
private submitPendingUntil;
|
|
1969
|
-
private responseSettleIgnoreUntil;
|
|
1970
|
-
private responseEpoch;
|
|
1971
|
-
private submitRetryTimer;
|
|
1972
|
-
private submitRetryUsed;
|
|
1973
|
-
private submitRetryPromptSnippet;
|
|
1974
|
-
private resizeSuppressUntil;
|
|
1975
|
-
private statusHistory;
|
|
1976
|
-
private cliScripts;
|
|
1977
|
-
/** Full accumulated ANSI-stripped PTY output */
|
|
1978
|
-
private accumulatedBuffer;
|
|
1979
|
-
/** Full accumulated raw PTY output (with ANSI) */
|
|
1980
|
-
private accumulatedRawBuffer;
|
|
1981
|
-
/** Current visible terminal screen snapshot */
|
|
1982
|
-
private terminalScreen;
|
|
1983
|
-
/** Rolling append-only terminal transcript built from screen snapshots */
|
|
1984
|
-
private terminalHistory;
|
|
1985
|
-
/** Max accumulated buffer size (last 50KB) */
|
|
1986
|
-
private static readonly MAX_ACCUMULATED_BUFFER;
|
|
1987
|
-
private currentTurnScope;
|
|
1988
|
-
private syncMessageViews;
|
|
1989
|
-
private sliceFromOffset;
|
|
1990
|
-
private buildParseInput;
|
|
1991
|
-
private setStatus;
|
|
1992
|
-
private readonly timeouts;
|
|
1993
|
-
private readonly approvalKeys;
|
|
1994
|
-
private readonly sendDelayMs;
|
|
1995
|
-
private readonly sendKey;
|
|
1996
|
-
private readonly submitStrategy;
|
|
1997
|
-
private static readonly SCRIPT_STATUS_DEBOUNCE_MS;
|
|
1998
|
-
constructor(provider: CliProviderModule, workingDir: string, extraArgs?: string[], transportFactory?: PtyTransportFactory);
|
|
1999
|
-
/** Inject CLI scripts after construction (e.g. when resolved by ProviderLoader) */
|
|
2000
|
-
setCliScripts(scripts: CliScripts): void;
|
|
2001
|
-
setServerConn(serverConn: any): void;
|
|
2002
|
-
setOnStatusChange(callback: () => void): void;
|
|
2003
|
-
setOnPtyData(callback: (data: string) => void): void;
|
|
2004
|
-
private flushPendingOutputParse;
|
|
2005
|
-
spawn(): Promise<void>;
|
|
2006
|
-
private handleOutput;
|
|
2007
|
-
private scheduleSettle;
|
|
2008
|
-
private armApprovalExitTimeout;
|
|
2009
|
-
private looksLikeVisibleIdlePrompt;
|
|
2010
|
-
private evaluateSettled;
|
|
2011
|
-
private finishResponse;
|
|
2012
|
-
private commitCurrentTranscript;
|
|
2013
|
-
private runDetectStatus;
|
|
2014
|
-
private runParseApproval;
|
|
2015
|
-
getStatus(): CliSessionStatus;
|
|
2016
|
-
/**
|
|
2017
|
-
* Script-based full parse — returns ReadChatResult.
|
|
2018
|
-
* Called by command handler / dashboard for rich content rendering.
|
|
2019
|
-
*/
|
|
2020
|
-
getScriptParsedStatus(): any;
|
|
2021
|
-
private parseCurrentTranscript;
|
|
2022
|
-
/** Whether this adapter has CLI scripts loaded */
|
|
2023
|
-
hasCliScripts(): boolean;
|
|
2024
|
-
/**
|
|
2025
|
-
* Resolves an action (like 'fix' lint error) from the dashboard.
|
|
2026
|
-
* Uses resolveAction script if available, otherwise falls back to standard text.
|
|
2027
|
-
*/
|
|
2028
|
-
resolveAction(data: any): Promise<void>;
|
|
2029
|
-
sendMessage(text: string): Promise<void>;
|
|
2030
|
-
getPartialResponse(): string;
|
|
2031
|
-
getRuntimeMetadata(): PtyRuntimeMetadata | null;
|
|
2032
|
-
cancel(): void;
|
|
2033
|
-
saveAndStop(): Promise<void>;
|
|
2034
|
-
private waitForStopped;
|
|
2035
|
-
shutdown(): void;
|
|
2036
|
-
detach(): void;
|
|
2037
|
-
clearHistory(): void;
|
|
2038
|
-
isProcessing(): boolean;
|
|
2039
|
-
isReady(): boolean;
|
|
2040
|
-
writeRaw(data: string): void;
|
|
2041
|
-
resolveModal(buttonIndex: number): void;
|
|
2042
|
-
resize(cols: number, rows: number): void;
|
|
2043
|
-
getDebugState(): Record<string, any>;
|
|
2044
|
-
}
|
|
2045
|
-
|
|
2046
|
-
/**
|
|
2047
|
-
* CliProviderInstance — Runtime instance for CLI Provider
|
|
2048
|
-
*
|
|
2049
|
-
* Lifecycle layer on top of ProviderCliAdapter.
|
|
2050
|
-
* collectCliData() + status transition logic from daemon-status.ts moved here.
|
|
2051
|
-
*/
|
|
2052
|
-
|
|
2053
|
-
declare class CliProviderInstance implements ProviderInstance {
|
|
2054
|
-
private provider;
|
|
2055
|
-
private workingDir;
|
|
2056
|
-
private cliArgs;
|
|
2057
|
-
readonly type: string;
|
|
2058
|
-
readonly category: "cli";
|
|
2059
|
-
private adapter;
|
|
2060
|
-
private context;
|
|
2061
|
-
private events;
|
|
2062
|
-
private lastStatus;
|
|
2063
|
-
private generatingStartedAt;
|
|
2064
|
-
private settings;
|
|
2065
|
-
private monitor;
|
|
2066
|
-
private generatingDebounceTimer;
|
|
2067
|
-
private generatingDebouncePending;
|
|
2068
|
-
private lastApprovalEventAt;
|
|
2069
|
-
private historyWriter;
|
|
2070
|
-
readonly instanceId: string;
|
|
2071
|
-
constructor(provider: ProviderModule, workingDir: string, cliArgs?: string[], instanceId?: string, transportFactory?: PtyTransportFactory);
|
|
2072
|
-
init(context: InstanceContext): Promise<void>;
|
|
2073
|
-
onTick(): Promise<void>;
|
|
2074
|
-
getState(): ProviderState;
|
|
2075
|
-
onEvent(event: string, data?: any): void;
|
|
2076
|
-
dispose(): void;
|
|
2077
|
-
private completedDebounceTimer;
|
|
2078
|
-
private completedDebouncePending;
|
|
2079
|
-
private detectStatusTransition;
|
|
2080
|
-
private pushEvent;
|
|
2081
|
-
private flushEvents;
|
|
2082
|
-
getAdapter(): ProviderCliAdapter;
|
|
2083
|
-
get cliType(): string;
|
|
2084
|
-
get cliName(): string;
|
|
2085
|
-
}
|
|
2086
|
-
|
|
2087
|
-
/**
|
|
2088
|
-
* AcpProviderInstance — ACP (Agent Client Protocol) Provider runtime instance
|
|
2089
|
-
*
|
|
2090
|
-
* Spawns ACP agent process and communicates via the official ACP SDK.
|
|
2091
|
-
* Uses ClientSideConnection + ndJsonStream for structured protocol communication.
|
|
2092
|
-
*
|
|
2093
|
-
* ACP spec: https://agentclientprotocol.com
|
|
2094
|
-
* ACP SDK: @agentclientprotocol/sdk@0.16.1
|
|
2095
|
-
*
|
|
2096
|
-
* lifecycle:
|
|
2097
|
-
* 1. init() → Spawn agent process + ACP initialize handshake
|
|
2098
|
-
* 2. onTick() → no-op (ACP event based)
|
|
2099
|
-
* 3. getState() → ProviderState return (dashboard for display)
|
|
2100
|
-
* 4. onEvent('send_message') → session/prompt transmit
|
|
2101
|
-
* 5. dispose() → kill process
|
|
2102
|
-
*/
|
|
2103
|
-
|
|
2104
|
-
declare class AcpProviderInstance implements ProviderInstance {
|
|
2105
|
-
private cliArgs;
|
|
2106
|
-
readonly type: string;
|
|
2107
|
-
readonly category: "acp";
|
|
2108
|
-
private readonly log;
|
|
2109
|
-
private provider;
|
|
2110
|
-
private context;
|
|
2111
|
-
private settings;
|
|
2112
|
-
private events;
|
|
2113
|
-
private monitor;
|
|
2114
|
-
private process;
|
|
2115
|
-
private connection;
|
|
2116
|
-
private sessionId;
|
|
2117
|
-
private messages;
|
|
2118
|
-
private currentStatus;
|
|
2119
|
-
private lastStatus;
|
|
2120
|
-
private generatingStartedAt;
|
|
2121
|
-
private agentCapabilities;
|
|
2122
|
-
private currentModel;
|
|
2123
|
-
private currentMode;
|
|
2124
|
-
private activeToolCalls;
|
|
2125
|
-
private stopReason;
|
|
2126
|
-
private partialContent;
|
|
2127
|
-
/** Rich content blocks accumulated during streaming */
|
|
2128
|
-
private partialBlocks;
|
|
2129
|
-
/** Tool calls collected during current turn */
|
|
2130
|
-
private turnToolCalls;
|
|
2131
|
-
private errorMessage;
|
|
2132
|
-
private errorReason;
|
|
2133
|
-
private stderrBuffer;
|
|
2134
|
-
private spawnedAt;
|
|
2135
|
-
private configOptions;
|
|
2136
|
-
private availableModes;
|
|
2137
|
-
/** Static config mode — agent doesn't support config/* methods */
|
|
2138
|
-
private useStaticConfig;
|
|
2139
|
-
/** Current config selections (for spawnArgBuilder) */
|
|
2140
|
-
private selectedConfig;
|
|
2141
|
-
private workingDir;
|
|
2142
|
-
private instanceId;
|
|
2143
|
-
constructor(provider: ProviderModule, workingDir: string, cliArgs?: string[]);
|
|
2144
|
-
init(context: InstanceContext): Promise<void>;
|
|
2145
|
-
onTick(): Promise<void>;
|
|
2146
|
-
getState(): AcpProviderState;
|
|
2147
|
-
onEvent(event: string, data?: any): void;
|
|
2148
|
-
getInstanceId(): string;
|
|
2149
|
-
private parseConfigOptions;
|
|
2150
|
-
private parseModes;
|
|
2151
|
-
setConfigOption(category: string, value: string): Promise<void>;
|
|
2152
|
-
setMode(modeId: string): Promise<void>;
|
|
2153
|
-
/** Static config: kill process and restart with new args */
|
|
2154
|
-
private restartWithNewConfig;
|
|
2155
|
-
/** Update settings at runtime (called when user changes settings from dashboard) */
|
|
2156
|
-
updateSettings(newSettings: Record<string, any>): void;
|
|
2157
|
-
dispose(): void;
|
|
2158
|
-
private spawnAgent;
|
|
2159
|
-
private createClient;
|
|
2160
|
-
private initialize;
|
|
2161
|
-
private createSession;
|
|
2162
|
-
sendPrompt(text: string, contentBlocks?: ContentBlock[]): Promise<void>;
|
|
2163
|
-
private cancelSession;
|
|
2164
|
-
private permissionResolvers;
|
|
2165
|
-
private resolvePermission;
|
|
2166
|
-
private handleSessionUpdate;
|
|
2167
|
-
/** Handle legacy session/update formats (pre-standardization compat) */
|
|
2168
|
-
private handleLegacyUpdate;
|
|
2169
|
-
/** Map SDK ToolCallStatus to internal status */
|
|
2170
|
-
private mapToolCallStatus;
|
|
2171
|
-
/** Truncate content for transport (text: 2000 chars, images preserved) */
|
|
2172
|
-
private truncateContent;
|
|
2173
|
-
/** Build ContentBlock[] from current partial state */
|
|
2174
|
-
private buildPartialBlocks;
|
|
2175
|
-
/** Finalize streaming content into an assistant message */
|
|
2176
|
-
private finalizeAssistantMessage;
|
|
2177
|
-
/** Convert ACP ToolCallContent[] to our ToolCallContent[] */
|
|
2178
|
-
private convertToolCallContent;
|
|
2179
|
-
private detectStatusTransition;
|
|
2180
|
-
private pushEvent;
|
|
2181
|
-
private flushEvents;
|
|
2182
|
-
get cliType(): string;
|
|
2183
|
-
get cliName(): string;
|
|
2184
|
-
/** ACP Agent capabilities (available after initialize) */
|
|
2185
|
-
getCapabilities(): Record<string, any>;
|
|
2186
|
-
}
|
|
2187
|
-
|
|
2188
|
-
/**
|
|
2189
|
-
* Context passed from the main DevServer to handler modules.
|
|
2190
|
-
* Provides access to shared dependencies and utility methods.
|
|
2191
|
-
*/
|
|
2192
|
-
interface DevServerContext {
|
|
2193
|
-
readonly providerLoader: ProviderLoader;
|
|
2194
|
-
readonly cdpManagers: Map<string, DaemonCdpManager>;
|
|
2195
|
-
readonly instanceManager: ProviderInstanceManager | null;
|
|
2196
|
-
readonly cliManager: DaemonCliManager | null;
|
|
2197
|
-
getCdp(ideType?: string): DaemonCdpManager | null;
|
|
2198
|
-
json(res: http.ServerResponse, status: number, data: any): void;
|
|
2199
|
-
readBody(req: http.IncomingMessage): Promise<any>;
|
|
2200
|
-
log(msg: string): void;
|
|
2201
|
-
autoImplSSEClients: http.ServerResponse[];
|
|
2202
|
-
sendAutoImplSSE(msg: {
|
|
2203
|
-
event: string;
|
|
2204
|
-
data: any;
|
|
2205
|
-
}): void;
|
|
2206
|
-
autoImplStatus: {
|
|
2207
|
-
running: boolean;
|
|
2208
|
-
type: string | null;
|
|
2209
|
-
progress: any[];
|
|
2210
|
-
};
|
|
2211
|
-
autoImplProcess: child_process.ChildProcess | null;
|
|
2212
|
-
sendCliSSE(data: any): void;
|
|
2213
|
-
handleRunScript(type: string, req: http.IncomingMessage, res: http.ServerResponse, parsedBody?: any): Promise<void>;
|
|
2214
|
-
findProviderDir(type: string): string | null;
|
|
2215
|
-
getLatestScriptVersionDir(scriptsDir: string): string | null;
|
|
2216
|
-
}
|
|
2217
|
-
|
|
2218
|
-
declare class DevServer implements DevServerContext {
|
|
2219
|
-
private server;
|
|
2220
|
-
providerLoader: ProviderLoader;
|
|
2221
|
-
cdpManagers: Map<string, DaemonCdpManager>;
|
|
2222
|
-
instanceManager: ProviderInstanceManager | null;
|
|
2223
|
-
cliManager: DaemonCliManager | null;
|
|
2224
|
-
private logFn;
|
|
2225
|
-
private sseClients;
|
|
2226
|
-
private watchScriptPath;
|
|
2227
|
-
private watchScriptName;
|
|
2228
|
-
private watchTimer;
|
|
2229
|
-
autoImplProcess: ChildProcess | null;
|
|
2230
|
-
autoImplSSEClients: http.ServerResponse[];
|
|
2231
|
-
autoImplStatus: {
|
|
2232
|
-
running: boolean;
|
|
2233
|
-
type: string | null;
|
|
2234
|
-
progress: any[];
|
|
2235
|
-
};
|
|
2236
|
-
private cliSSEClients;
|
|
2237
|
-
constructor(options: {
|
|
2238
|
-
providerLoader: ProviderLoader;
|
|
2239
|
-
cdpManagers: Map<string, DaemonCdpManager>;
|
|
2240
|
-
instanceManager?: ProviderInstanceManager;
|
|
2241
|
-
cliManager?: DaemonCliManager;
|
|
2242
|
-
logFn?: (msg: string) => void;
|
|
2243
|
-
});
|
|
2244
|
-
log(msg: string): void;
|
|
2245
|
-
private readonly routes;
|
|
2246
|
-
private matchRoute;
|
|
2247
|
-
private getEndpointList;
|
|
2248
|
-
start(port?: number): Promise<void>;
|
|
2249
|
-
stop(): void;
|
|
2250
|
-
private handleListProviders;
|
|
2251
|
-
private handleProviderConfig;
|
|
2252
|
-
private handleSpawnTest;
|
|
2253
|
-
handleRunScript(type: string, req: http.IncomingMessage, res: http.ServerResponse, parsedBody?: any): Promise<void>;
|
|
2254
|
-
private handleCdpEvaluate;
|
|
2255
|
-
private handleCdpClick;
|
|
2256
|
-
private handleCdpDomQuery;
|
|
2257
|
-
private handleScreenshot;
|
|
2258
|
-
private handleScriptsRun;
|
|
2259
|
-
private handleStatus;
|
|
2260
|
-
private handleReload;
|
|
2261
|
-
private getConsoleDistDir;
|
|
2262
|
-
private serveConsole;
|
|
2263
|
-
private static MIME_MAP;
|
|
2264
|
-
private serveStaticAsset;
|
|
2265
|
-
private handleSSE;
|
|
2266
|
-
private sendSSE;
|
|
2267
|
-
private handleWatchStart;
|
|
2268
|
-
private handleWatchStop;
|
|
2269
|
-
/** Find the provider directory on disk */
|
|
2270
|
-
findProviderDir(type: string): string | null;
|
|
2271
|
-
/** GET /api/providers/:type/files — list all files in provider directory */
|
|
2272
|
-
private handleListFiles;
|
|
2273
|
-
/** GET /api/providers/:type/file?path=scripts.js — read a file */
|
|
2274
|
-
private handleReadFile;
|
|
2275
|
-
/** POST /api/providers/:type/file — write a file { path, content } */
|
|
2276
|
-
private handleWriteFile;
|
|
2277
|
-
private handleSource;
|
|
2278
|
-
private handleSave;
|
|
2279
|
-
private handleTypeAndSend;
|
|
2280
|
-
private handleTypeAndSendAt;
|
|
2281
|
-
private handleScriptHints;
|
|
2282
|
-
private handleValidate;
|
|
2283
|
-
private handleAcpChat;
|
|
2284
|
-
private handleCdpTargets;
|
|
2285
|
-
private handleScaffold;
|
|
2286
|
-
private handleDetectVersions;
|
|
2287
|
-
private handleDomInspect;
|
|
2288
|
-
private handleDomChildren;
|
|
2289
|
-
private handleDomAnalyze;
|
|
2290
|
-
private handleFindCommon;
|
|
2291
|
-
private handleFindByText;
|
|
2292
|
-
private handleDomContext;
|
|
2293
|
-
getLatestScriptVersionDir(scriptsDir: string): string | null;
|
|
2294
|
-
private resolveAutoImplWritableProviderDir;
|
|
2295
|
-
private handleAutoImplement;
|
|
2296
|
-
private buildAutoImplPrompt;
|
|
2297
|
-
private buildCliAutoImplPrompt;
|
|
2298
|
-
private handleAutoImplSSE;
|
|
2299
|
-
private handleAutoImplCancel;
|
|
2300
|
-
sendAutoImplSSE(msg: {
|
|
2301
|
-
event: string;
|
|
2302
|
-
data: any;
|
|
2303
|
-
}): void;
|
|
2304
|
-
/** Get CDP manager — matching IDE when ideType specified, first connected one otherwise.
|
|
2305
|
-
* DevServer is a debugging tool so first-connected fallback is acceptable,
|
|
2306
|
-
* but callers should pass ideType when possible. */
|
|
2307
|
-
getCdp(ideType?: string): DaemonCdpManager | null;
|
|
2308
|
-
json(res: http.ServerResponse, status: number, data: any): void;
|
|
2309
|
-
readBody(req: http.IncomingMessage): Promise<any>;
|
|
2310
|
-
/** GET /api/cli/status — list all running CLI/ACP instances with state */
|
|
2311
|
-
private handleCliStatus;
|
|
2312
|
-
/** POST /api/cli/launch — launch a CLI agent { type, workingDir?, args? } */
|
|
2313
|
-
private handleCliLaunch;
|
|
2314
|
-
/** POST /api/cli/send — send message to a running CLI { type, text } */
|
|
2315
|
-
private handleCliSend;
|
|
2316
|
-
/** POST /api/cli/stop — stop a running CLI { type } */
|
|
2317
|
-
private handleCliStop;
|
|
2318
|
-
/** GET /api/cli/events — SSE stream of CLI status events */
|
|
2319
|
-
private handleCliSSE;
|
|
2320
|
-
sendCliSSE(data: any): void;
|
|
2321
|
-
/** GET /api/cli/debug/:type — full internal debug state of a CLI adapter */
|
|
2322
|
-
private handleCliDebug;
|
|
2323
|
-
/** POST /api/cli/resolve — resolve an approval modal { type, buttonIndex } */
|
|
2324
|
-
private handleCliResolve;
|
|
2325
|
-
/** POST /api/cli/raw — send raw keystrokes to PTY { type, keys } */
|
|
2326
|
-
private handleCliRaw;
|
|
2327
|
-
}
|
|
2328
|
-
|
|
2329
|
-
interface SessionHostPtyTransportFactoryOptions {
|
|
2330
|
-
endpoint?: SessionHostEndpoint;
|
|
2331
|
-
appName?: string;
|
|
2332
|
-
clientId: string;
|
|
2333
|
-
runtimeId: string;
|
|
2334
|
-
providerType: string;
|
|
2335
|
-
category?: SessionHostCategory;
|
|
2336
|
-
workspace: string;
|
|
2337
|
-
meta?: Record<string, unknown>;
|
|
2338
|
-
attachExisting?: boolean;
|
|
2339
|
-
}
|
|
2340
|
-
declare class SessionHostPtyTransportFactory implements PtyTransportFactory {
|
|
2341
|
-
private readonly options;
|
|
2342
|
-
constructor(options: SessionHostPtyTransportFactoryOptions);
|
|
2343
|
-
spawn(command: string, args: string[], spawnOptions: PtySpawnOptions): PtyRuntimeTransport;
|
|
2344
|
-
}
|
|
2345
|
-
|
|
2346
|
-
declare function ensureSessionHostReady(options: {
|
|
2347
|
-
appName?: string;
|
|
2348
|
-
spawnHost: () => void;
|
|
2349
|
-
timeoutMs?: number;
|
|
2350
|
-
}): Promise<SessionHostEndpoint>;
|
|
2351
|
-
declare function listHostedCliRuntimes(endpoint: SessionHostEndpoint): Promise<HostedCliRuntimeDescriptor[]>;
|
|
2352
|
-
|
|
2353
|
-
/**
|
|
2354
|
-
* ADHDev Launcher — Extension Installer
|
|
2355
|
-
*
|
|
2356
|
-
* Installs VS Code extensions via CLI commands.
|
|
2357
|
-
* Supports installing user-selected AI extensions.
|
|
2358
|
-
*/
|
|
2359
|
-
|
|
2360
|
-
interface ExtensionInfo {
|
|
2361
|
-
id: string;
|
|
2362
|
-
name: string;
|
|
2363
|
-
displayName: string;
|
|
2364
|
-
marketplaceId: string;
|
|
2365
|
-
description: string;
|
|
2366
|
-
category: 'ai-agent' | 'utility';
|
|
2367
|
-
icon: string;
|
|
2368
|
-
recommended: boolean;
|
|
2369
|
-
requiresApiKey?: boolean;
|
|
2370
|
-
apiKeyName?: string;
|
|
2371
|
-
website?: string;
|
|
2372
|
-
vsixUrl?: string;
|
|
2373
|
-
}
|
|
2374
|
-
interface InstallResult {
|
|
2375
|
-
extensionId: string;
|
|
2376
|
-
marketplaceId: string;
|
|
2377
|
-
success: boolean;
|
|
2378
|
-
alreadyInstalled: boolean;
|
|
2379
|
-
error?: string;
|
|
2380
|
-
}
|
|
2381
|
-
/**
|
|
2382
|
-
* Check if an extension is already installed
|
|
2383
|
-
*/
|
|
2384
|
-
declare function isExtensionInstalled(ide: IDEInfo, marketplaceId: string): boolean;
|
|
2385
|
-
/**
|
|
2386
|
-
* Install multiple extensions sequentially
|
|
2387
|
-
*/
|
|
2388
|
-
declare function installExtensions(ide: IDEInfo, extensions: ExtensionInfo[], onProgress?: (current: number, total: number, ext: ExtensionInfo, result: InstallResult) => void): Promise<InstallResult[]>;
|
|
2389
|
-
/**
|
|
2390
|
-
* Get AI agent extensions
|
|
2391
|
-
*/
|
|
2392
|
-
declare function getAIExtensions(): ExtensionInfo[];
|
|
2393
|
-
/**
|
|
2394
|
-
* Launch IDE after installation
|
|
2395
|
-
*/
|
|
2396
|
-
declare function launchIDE(ide: IDEInfo, workspacePath?: string): boolean;
|
|
2397
|
-
|
|
2398
|
-
/**
|
|
2399
|
-
* Daemon Lifecycle — Shared init + shutdown logic
|
|
2400
|
-
*
|
|
2401
|
-
* initDaemonComponents(): Creates all core daemon components in correct order.
|
|
2402
|
-
* shutdownDaemonComponents(): Graceful shutdown of all components.
|
|
2403
|
-
*
|
|
2404
|
-
* Transport-specific setup (ServerConnection, P2P, HTTP/WS) remains in each daemon.
|
|
2405
|
-
*/
|
|
2406
|
-
|
|
2407
|
-
interface DaemonInitConfig {
|
|
2408
|
-
/** ProviderLoader log function */
|
|
2409
|
-
providerLogFn?: (msg: string) => void;
|
|
2410
|
-
/** CLI Manager deps (transport-specific) */
|
|
2411
|
-
cliManagerDeps: {
|
|
2412
|
-
getServerConn: () => any;
|
|
2413
|
-
getP2p: () => any;
|
|
2414
|
-
onStatusChange: () => void;
|
|
2415
|
-
removeAgentTracking: (key: string) => void;
|
|
2416
|
-
createPtyTransportFactory?: (params: CliTransportFactoryParams) => PtyTransportFactory | null;
|
|
2417
|
-
listHostedCliRuntimes?: () => Promise<HostedCliRuntimeDescriptor[]>;
|
|
2418
|
-
};
|
|
2419
|
-
/** CDP config */
|
|
2420
|
-
enabledIdes?: string[];
|
|
2421
|
-
/** Router transport-specific callbacks */
|
|
2422
|
-
onStatusChange?: () => void;
|
|
2423
|
-
onPostChatCommand?: () => void;
|
|
2424
|
-
getCdpLogFn?: (ideType: string) => (msg: string) => void;
|
|
2425
|
-
/** Additional callback after CDP manager created (transport-specific extras) */
|
|
2426
|
-
onCdpManagerSetup?: (ideType: string, manager: DaemonCdpManager, managerKey: string) => void | Promise<void>;
|
|
2427
|
-
/** Poller callback (transport-specific) */
|
|
2428
|
-
onStreamsUpdated?: (ideType: string, streams: any[]) => void;
|
|
2429
|
-
/** Instance ticking interval (ms), default 5000 */
|
|
2430
|
-
tickIntervalMs?: number;
|
|
2431
|
-
/** CDP scan interval (ms), default 30000 */
|
|
2432
|
-
cdpScanIntervalMs?: number;
|
|
2433
|
-
}
|
|
2434
|
-
interface DaemonComponents {
|
|
2435
|
-
providerLoader: ProviderLoader;
|
|
2436
|
-
instanceManager: ProviderInstanceManager;
|
|
2437
|
-
cliManager: DaemonCliManager;
|
|
2438
|
-
commandHandler: DaemonCommandHandler;
|
|
2439
|
-
agentStreamManager: DaemonAgentStreamManager;
|
|
2440
|
-
router: DaemonCommandRouter;
|
|
2441
|
-
poller: AgentStreamPoller;
|
|
2442
|
-
cdpInitializer: DaemonCdpInitializer;
|
|
2443
|
-
cdpManagers: Map<string, DaemonCdpManager>;
|
|
2444
|
-
sessionRegistry: SessionRegistry;
|
|
2445
|
-
detectedIdes: {
|
|
2446
|
-
value: any[];
|
|
2447
|
-
};
|
|
2448
|
-
}
|
|
2449
|
-
interface DaemonDevSupportOptions {
|
|
2450
|
-
components: DaemonComponents;
|
|
2451
|
-
logFn?: (msg: string) => void;
|
|
2452
|
-
}
|
|
2453
|
-
/**
|
|
2454
|
-
* Initialize all daemon core components.
|
|
2455
|
-
*
|
|
2456
|
-
* Order:
|
|
2457
|
-
* 1. Global log interceptor
|
|
2458
|
-
* 2. ProviderLoader
|
|
2459
|
-
* 3. InstanceManager + CliManager
|
|
2460
|
-
* 4. Detect IDEs
|
|
2461
|
-
* 5. CdpInitializer → connectAll + periodic scan + discovery
|
|
2462
|
-
* 6. CommandHandler + AgentStreamManager
|
|
2463
|
-
* 7. Router + Poller
|
|
2464
|
-
* 8. Start instance ticking
|
|
2465
|
-
*/
|
|
2466
|
-
declare function initDaemonComponents(config: DaemonInitConfig): Promise<DaemonComponents>;
|
|
2467
|
-
/**
|
|
2468
|
-
* Start shared dev-only helpers:
|
|
2469
|
-
* - DevServer on port 19280
|
|
2470
|
-
* - Provider hot-reload watcher
|
|
2471
|
-
*/
|
|
2472
|
-
declare function startDaemonDevSupport(options: DaemonDevSupportOptions): Promise<DevServer>;
|
|
2473
|
-
/**
|
|
2474
|
-
* Graceful shutdown of all daemon components.
|
|
2475
|
-
*
|
|
2476
|
-
* Order:
|
|
2477
|
-
* 1. Stop timers (poller, cdpInitializer)
|
|
2478
|
-
* 2. Dispose agent stream
|
|
2479
|
-
* 3. Shutdown CLIs
|
|
2480
|
-
* 4. Dispose instances
|
|
2481
|
-
* 5. Disconnect CDPs
|
|
2482
|
-
*/
|
|
2483
|
-
declare function shutdownDaemonComponents(components: DaemonComponents): Promise<void>;
|
|
2484
|
-
|
|
2485
1
|
/**
|
|
2486
2
|
* @adhdev/daemon-core — Public API
|
|
2487
3
|
*
|
|
2488
4
|
* Core logic for daemon: CDP, Provider, IDE detection, CLI/ACP adapters and more.
|
|
2489
5
|
*/
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
}
|
|
2503
|
-
|
|
2504
|
-
export {
|
|
6
|
+
export type { ChatMessage, ExtensionInfo, CommandResult as CoreCommandResult, ProviderConfig, DaemonEvent, StatusResponse, SystemInfo, DetectedIde, ProviderInfo, AgentEntry, } from './types.js';
|
|
7
|
+
export type { SessionEntry, SessionTransport, SessionKind, SessionCapability, AgentSessionStream, AvailableProviderInfo, AcpConfigOption, AcpMode, ProviderControlSchema, StatusReportPayload, MachineInfo, DetectedIdeInfo, WorkspaceEntry, ProviderStatus, ProviderErrorReason, ActiveChatData, IdeProviderState, CliProviderState, AcpProviderState, ExtensionProviderState, } from './shared-types.js';
|
|
8
|
+
import type { RuntimeWriteOwner as _RuntimeWriteOwner } from './shared-types-extra.js';
|
|
9
|
+
import type { RuntimeAttachedClient as _RuntimeAttachedClient } from './shared-types-extra.js';
|
|
10
|
+
import type { RecentSessionEntry as _RecentSessionEntry } from './shared-types.js';
|
|
11
|
+
import type { TerminalBackendStatus as _TerminalBackendStatus } from './shared-types-extra.js';
|
|
12
|
+
export type RuntimeWriteOwner = _RuntimeWriteOwner;
|
|
13
|
+
export type RuntimeAttachedClient = _RuntimeAttachedClient;
|
|
14
|
+
export type RecentSessionEntry = _RecentSessionEntry;
|
|
15
|
+
export type TerminalBackendStatus = _TerminalBackendStatus;
|
|
16
|
+
export type SessionStatus = 'idle' | 'generating' | 'waiting_approval' | 'error' | 'stopped' | 'starting' | 'panel_hidden' | 'not_monitored' | 'disconnected';
|
|
17
|
+
export type RecentSessionBucket = 'needs_attention' | 'working' | 'task_complete' | 'idle';
|
|
18
|
+
export type { IDaemonCore, DaemonCoreOptions } from './daemon-core.js';
|
|
19
|
+
export { loadConfig, saveConfig, resetConfig, isSetupComplete, markSetupComplete, updateConfig } from './config/config.js';
|
|
20
|
+
export { getWorkspaceState } from './config/workspaces.js';
|
|
21
|
+
export { appendRecentActivity, getRecentActivity } from './config/recent-activity.js';
|
|
22
|
+
export type { RecentActivityEntry } from './config/recent-activity.js';
|
|
23
|
+
export { detectIDEs } from './detection/ide-detector.js';
|
|
24
|
+
export type { IDEInfo } from './detection/ide-detector.js';
|
|
25
|
+
export { detectCLIs } from './detection/cli-detector.js';
|
|
26
|
+
export { getHostMemorySnapshot } from './system/host-memory.js';
|
|
27
|
+
export type { HostMemorySnapshot } from './system/host-memory.js';
|
|
28
|
+
export { DaemonCdpManager } from './cdp/manager.js';
|
|
29
|
+
export { CdpDomHandlers } from './cdp/devtools.js';
|
|
30
|
+
export { setupIdeInstance, registerExtensionProviders, connectCdpManager, probeCdpPort } from './cdp/setup.js';
|
|
31
|
+
export type { CdpSetupContext, SetupIdeInstanceOptions } from './cdp/setup.js';
|
|
32
|
+
export { DaemonCdpScanner } from './cdp/scanner.js';
|
|
33
|
+
export type { CdpScannerOptions } from './cdp/scanner.js';
|
|
34
|
+
export { DaemonCdpInitializer } from './cdp/initializer.js';
|
|
35
|
+
export type { CdpInitializerConfig } from './cdp/initializer.js';
|
|
36
|
+
export { DaemonCommandHandler } from './commands/handler.js';
|
|
37
|
+
export type { CommandResult, CommandContext } from './commands/handler.js';
|
|
38
|
+
export { DaemonCommandRouter } from './commands/router.js';
|
|
39
|
+
export type { CommandRouterDeps, CommandRouterResult } from './commands/router.js';
|
|
40
|
+
export { DaemonStatusReporter } from './status/reporter.js';
|
|
41
|
+
export { buildSessionEntries, findCdpManager, hasCdpManager, isCdpConnected } from './status/builders.js';
|
|
42
|
+
export { buildStatusSnapshot } from './status/snapshot.js';
|
|
43
|
+
export { normalizeManagedStatus, isManagedStatusWorking, isManagedStatusWaiting, normalizeActiveChatData } from './status/normalize.js';
|
|
44
|
+
export type { ManagedStatus } from './status/normalize.js';
|
|
45
|
+
export type { StatusSnapshotOptions, StatusSnapshot } from './status/snapshot.js';
|
|
46
|
+
export { LOG, installGlobalInterceptor, setLogLevel, getLogLevel, getRecentLogs } from './logging/logger.js';
|
|
47
|
+
export type { ScopedLogger, LogLevel, LogEntry } from './logging/logger.js';
|
|
48
|
+
export { logCommand, getRecentCommands } from './logging/command-log.js';
|
|
49
|
+
export { DaemonCliManager } from './commands/cli-manager.js';
|
|
50
|
+
export { launchWithCdp, getAvailableIdeIds, killIdeProcess, isIdeRunning } from './launch.js';
|
|
51
|
+
export { DEFAULT_DAEMON_PORT, DAEMON_WS_PATH } from './ipc-protocol.js';
|
|
52
|
+
export { readChatHistory } from './config/chat-history.js';
|
|
53
|
+
export { DaemonAgentStreamManager } from './agent-stream/index.js';
|
|
54
|
+
export { AgentStreamPoller } from './agent-stream/index.js';
|
|
55
|
+
export type { AgentStreamPollerDeps } from './agent-stream/index.js';
|
|
56
|
+
export { forwardAgentStreamsToIdeInstance } from './agent-stream/forward.js';
|
|
57
|
+
export { ProviderLoader } from './providers/provider-loader.js';
|
|
58
|
+
export { ProviderInstanceManager } from './providers/provider-instance-manager.js';
|
|
59
|
+
export { IdeProviderInstance } from './providers/ide-provider-instance.js';
|
|
60
|
+
export { CliProviderInstance } from './providers/cli-provider-instance.js';
|
|
61
|
+
export { AcpProviderInstance } from './providers/acp-provider-instance.js';
|
|
62
|
+
export type { ProviderModule, CdpTargetFilter, ProviderResumeCapability } from './providers/contracts.js';
|
|
63
|
+
export { VersionArchive, detectAllVersions } from './providers/version-archive.js';
|
|
64
|
+
export type { ProviderVersionInfo, VersionHistory } from './providers/version-archive.js';
|
|
65
|
+
export { DevServer } from './daemon/dev-server.js';
|
|
66
|
+
export { ProviderCliAdapter } from './cli-adapters/provider-cli-adapter.js';
|
|
67
|
+
export type { CliAdapter } from './cli-adapter-types.js';
|
|
68
|
+
export { NodePtyTransportFactory } from './cli-adapters/pty-transport.js';
|
|
69
|
+
export type { PtyRuntimeTransport, PtyTransportFactory, PtySpawnOptions } from './cli-adapters/pty-transport.js';
|
|
70
|
+
export { SessionHostPtyTransportFactory } from './cli-adapters/session-host-transport.js';
|
|
71
|
+
export type { HostedCliRuntimeDescriptor, CliTransportFactoryParams } from './commands/cli-manager.js';
|
|
72
|
+
export { ensureSessionHostReady, listHostedCliRuntimes } from './session-host/runtime-support.js';
|
|
73
|
+
export type { SessionHostEndpoint } from '@adhdev/session-host-core';
|
|
74
|
+
export { getAIExtensions, installExtensions, launchIDE, isExtensionInstalled } from './installer.js';
|
|
75
|
+
export type { ExtensionInfo as InstallerExtensionInfo } from './installer.js';
|
|
76
|
+
export { initDaemonComponents, startDaemonDevSupport, shutdownDaemonComponents } from './boot/daemon-lifecycle.js';
|
|
77
|
+
export type { DaemonInitConfig, DaemonComponents, DaemonDevSupportOptions } from './boot/daemon-lifecycle.js';
|