@adhdev/daemon-core 0.6.67 → 0.6.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +71 -37
- package/dist/index.js +174 -54
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/agent-stream/forward.ts +29 -0
- package/src/agent-stream/poller.ts +1 -2
- package/src/boot/daemon-lifecycle.ts +2 -3
- package/src/cdp/initializer.ts +18 -12
- package/src/cdp/manager.ts +3 -0
- package/src/cdp/scanner.ts +2 -2
- package/src/cdp/setup.ts +3 -6
- package/src/commands/router.ts +5 -6
- package/src/config/config.ts +3 -0
- package/src/daemon/dev-server.ts +47 -0
- package/src/daemon-core.ts +1 -1
- package/src/index.ts +3 -2
- package/src/providers/provider-loader.ts +14 -9
- package/src/shared-types.ts +5 -6
- package/src/status/builders.ts +2 -3
- package/src/status/reporter.ts +18 -48
- package/src/status/snapshot.ts +123 -0
- package/src/types.ts +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -178,6 +178,7 @@ interface ADHDevConfig {
|
|
|
178
178
|
}>;
|
|
179
179
|
}>;
|
|
180
180
|
disableUpstream?: boolean;
|
|
181
|
+
providerDir?: string;
|
|
181
182
|
}
|
|
182
183
|
interface CliHistoryEntry {
|
|
183
184
|
category?: 'ide' | 'cli' | 'acp';
|
|
@@ -238,14 +239,13 @@ declare function getWorkspaceState(config: ADHDevConfig): {
|
|
|
238
239
|
/**
|
|
239
240
|
* ADHDev Shared Types — Cross-package type definitions
|
|
240
241
|
*
|
|
241
|
-
* Types used across daemon-core, web-core,
|
|
242
|
+
* Types used across daemon-core, web-core, and downstream consumers.
|
|
242
243
|
* Import via: import type { ... } from '@adhdev/daemon-core/types'
|
|
243
244
|
*
|
|
244
245
|
* IMPORTANT: This file must remain runtime-free (types only).
|
|
245
|
-
* Cloudflare Workers (server) can import type-only modules safely.
|
|
246
246
|
*/
|
|
247
247
|
|
|
248
|
-
/** IDE entry as reported by daemon to
|
|
248
|
+
/** IDE entry as reported by daemon to dashboard */
|
|
249
249
|
interface ManagedIdeEntry {
|
|
250
250
|
ideType: string;
|
|
251
251
|
ideVersion: string;
|
|
@@ -261,7 +261,7 @@ interface ManagedIdeEntry {
|
|
|
261
261
|
currentPlan?: string;
|
|
262
262
|
currentAutoApprove?: string;
|
|
263
263
|
}
|
|
264
|
-
/** CLI entry as reported by daemon to
|
|
264
|
+
/** CLI entry as reported by daemon to dashboard */
|
|
265
265
|
interface ManagedCliEntry {
|
|
266
266
|
id: string;
|
|
267
267
|
instanceId: string;
|
|
@@ -272,7 +272,7 @@ interface ManagedCliEntry {
|
|
|
272
272
|
workspace: string;
|
|
273
273
|
activeChat: ActiveChatData | null;
|
|
274
274
|
}
|
|
275
|
-
/** ACP entry as reported by daemon to
|
|
275
|
+
/** ACP entry as reported by daemon to dashboard */
|
|
276
276
|
interface ManagedAcpEntry {
|
|
277
277
|
id: string;
|
|
278
278
|
acpType: string;
|
|
@@ -705,7 +705,7 @@ interface ProviderSettingSchema extends ProviderSettingDef {
|
|
|
705
705
|
/**
|
|
706
706
|
* ADHDev Daemon Core — Shared Types
|
|
707
707
|
*
|
|
708
|
-
* Shared types referenced by daemon-core, daemon-standalone,
|
|
708
|
+
* Shared types referenced by daemon-core, daemon-standalone, and web-core.
|
|
709
709
|
* When modifying this file, also update interface contracts in AGENT_PROTOCOL.md.
|
|
710
710
|
*/
|
|
711
711
|
|
|
@@ -833,7 +833,7 @@ interface AgentEntry {
|
|
|
833
833
|
/**
|
|
834
834
|
* DaemonCore — Core daemon orchestrator interface
|
|
835
835
|
*
|
|
836
|
-
*
|
|
836
|
+
* Provides the core daemon orchestrator interface consumed by daemon-standalone.
|
|
837
837
|
* Actual implementation extracted from launcher and placed in this package.
|
|
838
838
|
*/
|
|
839
839
|
|
|
@@ -1337,6 +1337,8 @@ declare class DaemonCdpManager {
|
|
|
1337
1337
|
private isMainPageUrl;
|
|
1338
1338
|
/** Connected page title (includes workspace name) */
|
|
1339
1339
|
get pageTitle(): string;
|
|
1340
|
+
/** Connected target ID */
|
|
1341
|
+
get targetId(): string | null;
|
|
1340
1342
|
/**
|
|
1341
1343
|
* Query all workbench pages on port (static)
|
|
1342
1344
|
* Returns multiple entries if multiple IDE windows are open on same port
|
|
@@ -1595,8 +1597,7 @@ declare class DaemonAgentStreamManager {
|
|
|
1595
1597
|
/**
|
|
1596
1598
|
* AgentStreamPoller — Periodic agent stream polling + extension dynamic management
|
|
1597
1599
|
*
|
|
1598
|
-
*
|
|
1599
|
-
* Used by both daemon-cloud and daemon-standalone.
|
|
1600
|
+
* Handles periodic agent stream polling and extension dynamic management.
|
|
1600
1601
|
*
|
|
1601
1602
|
* Responsibilities:
|
|
1602
1603
|
* 1. Refresh extension providers in CDP managers (config changes take effect immediately)
|
|
@@ -1936,11 +1937,8 @@ declare class IdeProviderInstance implements ProviderInstance {
|
|
|
1936
1937
|
/**
|
|
1937
1938
|
* DaemonCdpSetup — Shared CDP initialization helpers
|
|
1938
1939
|
*
|
|
1939
|
-
*
|
|
1940
|
-
*
|
|
1941
|
-
*
|
|
1942
|
-
* Used by both daemon-cloud and daemon-standalone to ensure
|
|
1943
|
-
* consistent CDP → ProviderInstance registration.
|
|
1940
|
+
* Common CDP setup logic for consistent
|
|
1941
|
+
* CDP → ProviderInstance registration.
|
|
1944
1942
|
*/
|
|
1945
1943
|
|
|
1946
1944
|
interface CdpSetupContext {
|
|
@@ -1949,7 +1947,7 @@ interface CdpSetupContext {
|
|
|
1949
1947
|
cdpManagers: Map<string, DaemonCdpManager>;
|
|
1950
1948
|
/** UUID instanceId → CDP manager key mapping */
|
|
1951
1949
|
instanceIdMap: Map<string, string>;
|
|
1952
|
-
/** Server connection (optional
|
|
1950
|
+
/** Server connection (optional) */
|
|
1953
1951
|
serverConn?: any;
|
|
1954
1952
|
}
|
|
1955
1953
|
interface SetupIdeInstanceOptions {
|
|
@@ -1995,7 +1993,7 @@ declare function probeCdpPort(port: number, timeoutMs?: number): Promise<boolean
|
|
|
1995
1993
|
/**
|
|
1996
1994
|
* DaemonCdpScanner — Periodic CDP port scanning & auto-connect
|
|
1997
1995
|
*
|
|
1998
|
-
*
|
|
1996
|
+
* Periodic CDP port scanning and auto-connect for IDE discovery.
|
|
1999
1997
|
* Provides a unified approach to:
|
|
2000
1998
|
* 1. Initial CDP port discovery
|
|
2001
1999
|
* 2. Periodic scanning for newly launched IDEs
|
|
@@ -2044,7 +2042,7 @@ declare class DaemonCdpScanner {
|
|
|
2044
2042
|
*/
|
|
2045
2043
|
private connectSingleWindow;
|
|
2046
2044
|
/**
|
|
2047
|
-
* Multi-window connection
|
|
2045
|
+
* Multi-window connection.
|
|
2048
2046
|
* Multiple CDP managers per IDE — one per workbench page.
|
|
2049
2047
|
*/
|
|
2050
2048
|
private connectMultiWindow;
|
|
@@ -2053,7 +2051,7 @@ declare class DaemonCdpScanner {
|
|
|
2053
2051
|
/**
|
|
2054
2052
|
* DaemonCdpInitializer — Unified CDP initialization + periodic scanning
|
|
2055
2053
|
*
|
|
2056
|
-
*
|
|
2054
|
+
* Unified CDP initialization + periodic scanning.
|
|
2057
2055
|
*
|
|
2058
2056
|
* Features:
|
|
2059
2057
|
* 1. Initial connection: connectAll() — multi-window aware
|
|
@@ -2175,8 +2173,7 @@ declare class DaemonCliManager {
|
|
|
2175
2173
|
/**
|
|
2176
2174
|
* DaemonCommandRouter — Unified command routing for daemon-level commands
|
|
2177
2175
|
*
|
|
2178
|
-
*
|
|
2179
|
-
* Used by both daemon-cloud and daemon-standalone.
|
|
2176
|
+
* Unified command routing for daemon-level commands.
|
|
2180
2177
|
*
|
|
2181
2178
|
* Routing flow:
|
|
2182
2179
|
* 1. Daemon-level commands (launch_ide, stop_ide, restart_ide, etc.) → handled here
|
|
@@ -2196,13 +2193,13 @@ interface CommandRouterDeps {
|
|
|
2196
2193
|
};
|
|
2197
2194
|
/** UUID instanceId → CDP manager key mapping */
|
|
2198
2195
|
instanceIdMap: Map<string, string>;
|
|
2199
|
-
/** Callback for CDP manager creation after launch_ide
|
|
2196
|
+
/** Callback for CDP manager creation after launch_ide */
|
|
2200
2197
|
onCdpManagerCreated?: (ideType: string, manager: DaemonCdpManager) => void;
|
|
2201
2198
|
/** Callback after IDE connected (e.g., startAgentStreamPolling) */
|
|
2202
2199
|
onIdeConnected?: () => void;
|
|
2203
2200
|
/** Callback after status change (stop_ide, restart) */
|
|
2204
2201
|
onStatusChange?: () => void;
|
|
2205
|
-
/** Callback after chat-related commands
|
|
2202
|
+
/** Callback after chat-related commands */
|
|
2206
2203
|
onPostChatCommand?: () => void;
|
|
2207
2204
|
/** Get a connected CDP manager (for agent stream reset check) */
|
|
2208
2205
|
getCdpLogFn?: (ideType: string) => (msg: string) => void;
|
|
@@ -2267,15 +2264,8 @@ interface StatusReporterDeps {
|
|
|
2267
2264
|
resolve(type: string): any;
|
|
2268
2265
|
getAll(): any[];
|
|
2269
2266
|
};
|
|
2270
|
-
adapters: Map<string, {
|
|
2271
|
-
cliType: string;
|
|
2272
|
-
cliName: string;
|
|
2273
|
-
workingDir: string;
|
|
2274
|
-
getStatus(): any;
|
|
2275
|
-
getPartialResponse(): string;
|
|
2276
|
-
}>;
|
|
2277
2267
|
detectedIdes: any[];
|
|
2278
|
-
|
|
2268
|
+
instanceId: string;
|
|
2279
2269
|
daemonVersion?: string;
|
|
2280
2270
|
instanceManager: {
|
|
2281
2271
|
collectAllStates(): ProviderState[];
|
|
@@ -2320,11 +2310,10 @@ declare class DaemonStatusReporter {
|
|
|
2320
2310
|
* Status Builders — shared conversion functions for ProviderState → ManagedEntry
|
|
2321
2311
|
*
|
|
2322
2312
|
* Used by:
|
|
2323
|
-
* - daemon-cloud (DaemonStatusReporter)
|
|
2324
2313
|
* - daemon-standalone (StandaloneServer.getStatus)
|
|
2314
|
+
* - DaemonStatusReporter
|
|
2325
2315
|
*
|
|
2326
|
-
* Consolidates
|
|
2327
|
-
* previously copy-pasted between cloud and standalone codebases.
|
|
2316
|
+
* Consolidates ProviderState→ManagedEntry mapping logic.
|
|
2328
2317
|
*/
|
|
2329
2318
|
|
|
2330
2319
|
/**
|
|
@@ -2382,6 +2371,44 @@ declare function buildAllManagedEntries(allStates: ProviderState[], cdpManagers:
|
|
|
2382
2371
|
managedAcps: ManagedAcpEntry[];
|
|
2383
2372
|
};
|
|
2384
2373
|
|
|
2374
|
+
/**
|
|
2375
|
+
* Shared status snapshot builders.
|
|
2376
|
+
*
|
|
2377
|
+
* Used by:
|
|
2378
|
+
* - DaemonStatusReporter (cloud)
|
|
2379
|
+
* - daemon-standalone HTTP/WS status responses
|
|
2380
|
+
*/
|
|
2381
|
+
|
|
2382
|
+
interface StatusSnapshotOptions {
|
|
2383
|
+
allStates: ProviderState[];
|
|
2384
|
+
cdpManagers: Map<string, unknown>;
|
|
2385
|
+
providerLoader: {
|
|
2386
|
+
getAll(): Array<{
|
|
2387
|
+
type: string;
|
|
2388
|
+
icon?: string;
|
|
2389
|
+
displayName?: string;
|
|
2390
|
+
category: 'ide' | 'extension' | 'cli' | 'acp';
|
|
2391
|
+
}>;
|
|
2392
|
+
};
|
|
2393
|
+
detectedIdes: Array<{
|
|
2394
|
+
id: string;
|
|
2395
|
+
name?: string;
|
|
2396
|
+
displayName?: string;
|
|
2397
|
+
installed?: boolean;
|
|
2398
|
+
path?: string;
|
|
2399
|
+
}>;
|
|
2400
|
+
instanceId: string;
|
|
2401
|
+
version: string;
|
|
2402
|
+
daemonMode: boolean;
|
|
2403
|
+
timestamp?: number;
|
|
2404
|
+
p2p?: StatusReportPayload['p2p'];
|
|
2405
|
+
machineNickname?: string | null;
|
|
2406
|
+
}
|
|
2407
|
+
interface StatusSnapshot extends StatusReportPayload {
|
|
2408
|
+
availableProviders: AvailableProviderInfo[];
|
|
2409
|
+
}
|
|
2410
|
+
declare function buildStatusSnapshot(options: StatusSnapshotOptions): StatusSnapshot;
|
|
2411
|
+
|
|
2385
2412
|
/**
|
|
2386
2413
|
* ADHDev Daemon — unified logger (v2)
|
|
2387
2414
|
*
|
|
@@ -2538,6 +2565,15 @@ declare function getAvailableIdeIds(): string[];
|
|
|
2538
2565
|
declare const DEFAULT_DAEMON_PORT = 19222;
|
|
2539
2566
|
declare const DAEMON_WS_PATH = "/ipc";
|
|
2540
2567
|
|
|
2568
|
+
/**
|
|
2569
|
+
* Shared helper for forwarding agent stream snapshots into the IDE instance.
|
|
2570
|
+
*
|
|
2571
|
+
* Both cloud and standalone daemons use the same InstanceManager wiring.
|
|
2572
|
+
*/
|
|
2573
|
+
declare function forwardAgentStreamsToIdeInstance(instanceManager: {
|
|
2574
|
+
getInstance: (key: string) => any;
|
|
2575
|
+
}, ideType: string, streams: any[]): void;
|
|
2576
|
+
|
|
2541
2577
|
/**
|
|
2542
2578
|
* ProviderCliAdapter — Script-based CLI Adapter
|
|
2543
2579
|
*
|
|
@@ -3051,7 +3087,7 @@ declare function getAIExtensions(): ExtensionInfo[];
|
|
|
3051
3087
|
declare function launchIDE(ide: IDEInfo, workspacePath?: string): boolean;
|
|
3052
3088
|
|
|
3053
3089
|
/**
|
|
3054
|
-
* Daemon Lifecycle — Shared init + shutdown
|
|
3090
|
+
* Daemon Lifecycle — Shared init + shutdown logic
|
|
3055
3091
|
*
|
|
3056
3092
|
* initDaemonComponents(): Creates all core daemon components in correct order.
|
|
3057
3093
|
* shutdownDaemonComponents(): Graceful shutdown of all components.
|
|
@@ -3101,7 +3137,6 @@ interface DaemonComponents {
|
|
|
3101
3137
|
}
|
|
3102
3138
|
/**
|
|
3103
3139
|
* Initialize all daemon core components.
|
|
3104
|
-
* Shared by both cloud and standalone daemons.
|
|
3105
3140
|
*
|
|
3106
3141
|
* Order:
|
|
3107
3142
|
* 1. Global log interceptor
|
|
@@ -3116,7 +3151,6 @@ interface DaemonComponents {
|
|
|
3116
3151
|
declare function initDaemonComponents(config: DaemonInitConfig): Promise<DaemonComponents>;
|
|
3117
3152
|
/**
|
|
3118
3153
|
* Graceful shutdown of all daemon components.
|
|
3119
|
-
* Shared by both cloud and standalone daemons.
|
|
3120
3154
|
*
|
|
3121
3155
|
* Order:
|
|
3122
3156
|
* 1. Stop timers (poller, cdpInitializer)
|
|
@@ -3127,4 +3161,4 @@ declare function initDaemonComponents(config: DaemonInitConfig): Promise<DaemonC
|
|
|
3127
3161
|
*/
|
|
3128
3162
|
declare function shutdownDaemonComponents(components: DaemonComponents): Promise<void>;
|
|
3129
3163
|
|
|
3130
|
-
export { type AcpConfigOption, type AcpMode, AcpProviderInstance, type AcpProviderState, type ActiveChatData, type AgentEntry, AgentStreamPoller, type AgentStreamPollerDeps, type AvailableProviderInfo, CdpDomHandlers, type CdpInitializerConfig, type CdpScannerOptions, type CdpSetupContext, type CdpTargetFilter, type ChatMessage, type CliAdapter, CliProviderInstance, type CliProviderState, type CommandContext, type CommandResult$1 as CommandResult, type CommandRouterDeps, type CommandRouterResult, type CommandResult$2 as CoreCommandResult, DAEMON_WS_PATH, DEFAULT_DAEMON_PORT, DaemonAgentStreamManager, DaemonCdpInitializer, DaemonCdpManager, DaemonCdpScanner, DaemonCliManager, DaemonCommandHandler, DaemonCommandRouter, type DaemonComponents, type DaemonCoreOptions, type DaemonEvent, type DaemonInitConfig, DaemonStatusReporter, type DetectedIde, type DetectedIdeInfo, DevServer, type ExtensionInfo$1 as ExtensionInfo, type ExtensionProviderState, type HostMemorySnapshot, type IDEInfo, type IDaemonCore, IdeProviderInstance, type IdeProviderState, type ExtensionInfo as InstallerExtensionInfo, LOG, type LogEntry, type LogLevel, type MachineInfo, type ManagedAcpEntry, type ManagedAgentStream, type ManagedCliEntry, type ManagedIdeEntry, ProviderCliAdapter, type ProviderConfig, type ProviderErrorReason, type ProviderInfo, ProviderInstanceManager, ProviderLoader, type ProviderModule, type ProviderStatus, type ProviderVersionInfo, type ScopedLogger, type SetupIdeInstanceOptions, type StatusReportPayload, type StatusResponse, type SystemInfo, VersionArchive, type VersionHistory, type WorkspaceActivity, type WorkspaceEntry, addCliHistory, buildAllManagedEntries, buildManagedAcps, buildManagedClis, buildManagedIdes, connectCdpManager, detectAllVersions, detectCLIs, detectIDEs, findCdpManager, getAIExtensions, getAvailableIdeIds, getHostMemorySnapshot, getLogLevel, getRecentCommands, getRecentLogs, getWorkspaceActivity, getWorkspaceState, hasCdpManager, initDaemonComponents, installExtensions, installGlobalInterceptor, isCdpConnected, isExtensionInstalled, isIdeRunning, isSetupComplete, killIdeProcess, launchIDE, launchWithCdp, loadConfig, logCommand, markSetupComplete, probeCdpPort, readChatHistory, registerExtensionProviders, resetConfig, saveConfig, setLogLevel, setupIdeInstance, shutdownDaemonComponents, updateConfig };
|
|
3164
|
+
export { type AcpConfigOption, type AcpMode, AcpProviderInstance, type AcpProviderState, type ActiveChatData, type AgentEntry, AgentStreamPoller, type AgentStreamPollerDeps, type AvailableProviderInfo, CdpDomHandlers, type CdpInitializerConfig, type CdpScannerOptions, type CdpSetupContext, type CdpTargetFilter, type ChatMessage, type CliAdapter, CliProviderInstance, type CliProviderState, type CommandContext, type CommandResult$1 as CommandResult, type CommandRouterDeps, type CommandRouterResult, type CommandResult$2 as CoreCommandResult, DAEMON_WS_PATH, DEFAULT_DAEMON_PORT, DaemonAgentStreamManager, DaemonCdpInitializer, DaemonCdpManager, DaemonCdpScanner, DaemonCliManager, DaemonCommandHandler, DaemonCommandRouter, type DaemonComponents, type DaemonCoreOptions, type DaemonEvent, type DaemonInitConfig, DaemonStatusReporter, type DetectedIde, type DetectedIdeInfo, DevServer, type ExtensionInfo$1 as ExtensionInfo, type ExtensionProviderState, type HostMemorySnapshot, type IDEInfo, type IDaemonCore, IdeProviderInstance, type IdeProviderState, type ExtensionInfo as InstallerExtensionInfo, LOG, type LogEntry, type LogLevel, type MachineInfo, type ManagedAcpEntry, type ManagedAgentStream, type ManagedCliEntry, type ManagedIdeEntry, ProviderCliAdapter, type ProviderConfig, type ProviderErrorReason, type ProviderInfo, ProviderInstanceManager, ProviderLoader, type ProviderModule, type ProviderStatus, type ProviderVersionInfo, type ScopedLogger, type SetupIdeInstanceOptions, type StatusReportPayload, type StatusResponse, type StatusSnapshot, type StatusSnapshotOptions, type SystemInfo, VersionArchive, type VersionHistory, type WorkspaceActivity, type WorkspaceEntry, addCliHistory, buildAllManagedEntries, buildManagedAcps, buildManagedClis, buildManagedIdes, buildStatusSnapshot, connectCdpManager, detectAllVersions, detectCLIs, detectIDEs, findCdpManager, forwardAgentStreamsToIdeInstance, getAIExtensions, getAvailableIdeIds, getHostMemorySnapshot, getLogLevel, getRecentCommands, getRecentLogs, getWorkspaceActivity, getWorkspaceState, hasCdpManager, initDaemonComponents, installExtensions, installGlobalInterceptor, isCdpConnected, isExtensionInstalled, isIdeRunning, isSetupComplete, killIdeProcess, launchIDE, launchWithCdp, loadConfig, logCommand, markSetupComplete, probeCdpPort, readChatHistory, registerExtensionProviders, resetConfig, saveConfig, setLogLevel, setupIdeInstance, shutdownDaemonComponents, updateConfig };
|
package/dist/index.js
CHANGED
|
@@ -1666,11 +1666,13 @@ __export(index_exports, {
|
|
|
1666
1666
|
buildManagedAcps: () => buildManagedAcps,
|
|
1667
1667
|
buildManagedClis: () => buildManagedClis,
|
|
1668
1668
|
buildManagedIdes: () => buildManagedIdes,
|
|
1669
|
+
buildStatusSnapshot: () => buildStatusSnapshot,
|
|
1669
1670
|
connectCdpManager: () => connectCdpManager,
|
|
1670
1671
|
detectAllVersions: () => detectAllVersions,
|
|
1671
1672
|
detectCLIs: () => detectCLIs,
|
|
1672
1673
|
detectIDEs: () => detectIDEs,
|
|
1673
1674
|
findCdpManager: () => findCdpManager,
|
|
1675
|
+
forwardAgentStreamsToIdeInstance: () => forwardAgentStreamsToIdeInstance,
|
|
1674
1676
|
getAIExtensions: () => getAIExtensions,
|
|
1675
1677
|
getAvailableIdeIds: () => getAvailableIdeIds,
|
|
1676
1678
|
getHostMemorySnapshot: () => getHostMemorySnapshot,
|
|
@@ -2008,6 +2010,10 @@ var DaemonCdpManager = class {
|
|
|
2008
2010
|
get pageTitle() {
|
|
2009
2011
|
return this._pageTitle;
|
|
2010
2012
|
}
|
|
2013
|
+
/** Connected target ID */
|
|
2014
|
+
get targetId() {
|
|
2015
|
+
return this._targetId;
|
|
2016
|
+
}
|
|
2011
2017
|
/**
|
|
2012
2018
|
* Query all workbench pages on port (static)
|
|
2013
2019
|
* Returns multiple entries if multiple IDE windows are open on same port
|
|
@@ -4118,7 +4124,7 @@ var DaemonCdpScanner = class {
|
|
|
4118
4124
|
this.opts.onConnected?.(ide, ide, manager);
|
|
4119
4125
|
}
|
|
4120
4126
|
/**
|
|
4121
|
-
* Multi-window connection
|
|
4127
|
+
* Multi-window connection.
|
|
4122
4128
|
* Multiple CDP managers per IDE — one per workbench page.
|
|
4123
4129
|
*/
|
|
4124
4130
|
async connectMultiWindow(port, ide) {
|
|
@@ -4205,6 +4211,7 @@ var DaemonCdpInitializer = class {
|
|
|
4205
4211
|
const { providerLoader, cdpManagers } = this.config;
|
|
4206
4212
|
const targets = await DaemonCdpManager.listAllTargets(port);
|
|
4207
4213
|
if (targets.length === 0) {
|
|
4214
|
+
if (cdpManagers.has(ide)) return;
|
|
4208
4215
|
if (!await probeCdpPort(port)) return;
|
|
4209
4216
|
const provider = providerLoader.getMeta(ide);
|
|
4210
4217
|
const manager = new DaemonCdpManager(
|
|
@@ -4224,12 +4231,19 @@ var DaemonCdpInitializer = class {
|
|
|
4224
4231
|
}
|
|
4225
4232
|
for (let i = 0; i < targets.length; i++) {
|
|
4226
4233
|
const target = targets[i];
|
|
4234
|
+
let alreadyTracked = false;
|
|
4235
|
+
for (const [key, m] of cdpManagers.entries()) {
|
|
4236
|
+
if ((key === ide || key.startsWith(`${ide}_`)) && m.targetId === target.id) {
|
|
4237
|
+
alreadyTracked = true;
|
|
4238
|
+
break;
|
|
4239
|
+
}
|
|
4240
|
+
}
|
|
4241
|
+
if (alreadyTracked) continue;
|
|
4227
4242
|
let managerKey;
|
|
4228
|
-
if (targets.length === 1) {
|
|
4243
|
+
if (targets.length === 1 && !cdpManagers.has(ide)) {
|
|
4229
4244
|
managerKey = ide;
|
|
4230
4245
|
} else {
|
|
4231
|
-
|
|
4232
|
-
managerKey = `${ide}_${workspaceName}`;
|
|
4246
|
+
managerKey = `${ide}_${target.id}`;
|
|
4233
4247
|
}
|
|
4234
4248
|
if (cdpManagers.has(managerKey)) continue;
|
|
4235
4249
|
const provider = providerLoader.getMeta(ide);
|
|
@@ -4260,10 +4274,6 @@ var DaemonCdpInitializer = class {
|
|
|
4260
4274
|
const portMap = providerLoader.getCdpPortMap();
|
|
4261
4275
|
for (const [ide, ports] of Object.entries(portMap)) {
|
|
4262
4276
|
const primaryPort = ports[0];
|
|
4263
|
-
const alreadyConnected = [...cdpManagers.entries()].some(
|
|
4264
|
-
([key, m]) => m.isConnected && (key === ide || key.startsWith(ide + "_"))
|
|
4265
|
-
);
|
|
4266
|
-
if (alreadyConnected) continue;
|
|
4267
4277
|
await this.connectIdePort(primaryPort, ide);
|
|
4268
4278
|
}
|
|
4269
4279
|
}, intervalMs);
|
|
@@ -6290,8 +6300,9 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
6290
6300
|
} else {
|
|
6291
6301
|
this.builtinDirs = [];
|
|
6292
6302
|
}
|
|
6293
|
-
|
|
6294
|
-
this.
|
|
6303
|
+
const defaultProvidersDir = path6.join(os7.homedir(), ".adhdev", "providers");
|
|
6304
|
+
this.userDir = options?.userDir || defaultProvidersDir;
|
|
6305
|
+
this.upstreamDir = path6.join(defaultProvidersDir, ".upstream");
|
|
6295
6306
|
this.disableUpstream = options?.disableUpstream ?? false;
|
|
6296
6307
|
this.logFn = options?.logFn || LOG.forComponent("Provider").asLogFn();
|
|
6297
6308
|
}
|
|
@@ -6498,7 +6509,8 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
6498
6509
|
try {
|
|
6499
6510
|
const { loadConfig: loadConfig2 } = (init_config(), __toCommonJS(config_exports));
|
|
6500
6511
|
const config = loadConfig2();
|
|
6501
|
-
const
|
|
6512
|
+
const baseIdeType = ideType.split("_")[0];
|
|
6513
|
+
const val = config.ideSettings?.[baseIdeType]?.extensions?.[type]?.enabled;
|
|
6502
6514
|
return val === true;
|
|
6503
6515
|
} catch {
|
|
6504
6516
|
return false;
|
|
@@ -6511,10 +6523,11 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
6511
6523
|
try {
|
|
6512
6524
|
const { loadConfig: loadConfig2, saveConfig: saveConfig2 } = (init_config(), __toCommonJS(config_exports));
|
|
6513
6525
|
const config = loadConfig2();
|
|
6526
|
+
const baseIdeType = ideType.split("_")[0];
|
|
6514
6527
|
if (!config.ideSettings) config.ideSettings = {};
|
|
6515
|
-
if (!config.ideSettings[
|
|
6516
|
-
if (!config.ideSettings[
|
|
6517
|
-
config.ideSettings[
|
|
6528
|
+
if (!config.ideSettings[baseIdeType]) config.ideSettings[baseIdeType] = {};
|
|
6529
|
+
if (!config.ideSettings[baseIdeType].extensions) config.ideSettings[baseIdeType].extensions = {};
|
|
6530
|
+
config.ideSettings[baseIdeType].extensions[extensionType] = { enabled };
|
|
6518
6531
|
saveConfig2(config);
|
|
6519
6532
|
this.log(`IDE extension setting: ${ideType}.${extensionType}.enabled = ${enabled}`);
|
|
6520
6533
|
return true;
|
|
@@ -8050,10 +8063,76 @@ var DaemonCommandRouter = class {
|
|
|
8050
8063
|
};
|
|
8051
8064
|
|
|
8052
8065
|
// src/status/reporter.ts
|
|
8066
|
+
init_logger();
|
|
8067
|
+
|
|
8068
|
+
// src/status/snapshot.ts
|
|
8053
8069
|
var os10 = __toESM(require("os"));
|
|
8054
8070
|
init_config();
|
|
8055
8071
|
init_workspaces();
|
|
8056
|
-
|
|
8072
|
+
function buildDetectedIdeInfos(detectedIdes, cdpManagers) {
|
|
8073
|
+
return detectedIdes.filter((ide) => ide.installed !== false).map((ide) => ({
|
|
8074
|
+
id: ide.id,
|
|
8075
|
+
type: ide.id,
|
|
8076
|
+
name: ide.displayName || ide.name || ide.id,
|
|
8077
|
+
running: isCdpConnected(cdpManagers, ide.id),
|
|
8078
|
+
...ide.path ? { path: ide.path } : {}
|
|
8079
|
+
}));
|
|
8080
|
+
}
|
|
8081
|
+
function buildAvailableProviders(providerLoader) {
|
|
8082
|
+
return providerLoader.getAll().map((provider) => ({
|
|
8083
|
+
type: provider.type,
|
|
8084
|
+
name: provider.displayName || provider.type,
|
|
8085
|
+
displayName: provider.displayName || provider.type,
|
|
8086
|
+
icon: provider.icon || "\u{1F4BB}",
|
|
8087
|
+
category: provider.category
|
|
8088
|
+
}));
|
|
8089
|
+
}
|
|
8090
|
+
function buildStatusSnapshot(options) {
|
|
8091
|
+
const cfg = loadConfig();
|
|
8092
|
+
const wsState = getWorkspaceState(cfg);
|
|
8093
|
+
const memSnap = getHostMemorySnapshot();
|
|
8094
|
+
const { managedIdes, managedClis, managedAcps } = buildAllManagedEntries(
|
|
8095
|
+
options.allStates,
|
|
8096
|
+
options.cdpManagers,
|
|
8097
|
+
{
|
|
8098
|
+
detectedIdes: options.detectedIdes.map((ide) => ({
|
|
8099
|
+
id: ide.id,
|
|
8100
|
+
installed: ide.installed !== false
|
|
8101
|
+
}))
|
|
8102
|
+
}
|
|
8103
|
+
);
|
|
8104
|
+
return {
|
|
8105
|
+
instanceId: options.instanceId,
|
|
8106
|
+
version: options.version,
|
|
8107
|
+
daemonMode: options.daemonMode,
|
|
8108
|
+
machine: {
|
|
8109
|
+
hostname: os10.hostname(),
|
|
8110
|
+
platform: os10.platform(),
|
|
8111
|
+
arch: os10.arch(),
|
|
8112
|
+
cpus: os10.cpus().length,
|
|
8113
|
+
totalMem: memSnap.totalMem,
|
|
8114
|
+
freeMem: memSnap.freeMem,
|
|
8115
|
+
availableMem: memSnap.availableMem,
|
|
8116
|
+
loadavg: os10.loadavg(),
|
|
8117
|
+
uptime: os10.uptime(),
|
|
8118
|
+
release: os10.release()
|
|
8119
|
+
},
|
|
8120
|
+
machineNickname: options.machineNickname ?? cfg.machineNickname ?? null,
|
|
8121
|
+
timestamp: options.timestamp ?? Date.now(),
|
|
8122
|
+
detectedIdes: buildDetectedIdeInfos(options.detectedIdes, options.cdpManagers),
|
|
8123
|
+
...options.p2p ? { p2p: options.p2p } : {},
|
|
8124
|
+
managedIdes,
|
|
8125
|
+
managedClis,
|
|
8126
|
+
managedAcps,
|
|
8127
|
+
workspaces: wsState.workspaces,
|
|
8128
|
+
defaultWorkspaceId: wsState.defaultWorkspaceId,
|
|
8129
|
+
defaultWorkspacePath: wsState.defaultWorkspacePath,
|
|
8130
|
+
workspaceActivity: getWorkspaceActivity(cfg, 15),
|
|
8131
|
+
availableProviders: buildAvailableProviders(options.providerLoader)
|
|
8132
|
+
};
|
|
8133
|
+
}
|
|
8134
|
+
|
|
8135
|
+
// src/status/reporter.ts
|
|
8057
8136
|
var DaemonStatusReporter = class {
|
|
8058
8137
|
deps;
|
|
8059
8138
|
log;
|
|
@@ -8160,46 +8239,25 @@ var DaemonStatusReporter = class {
|
|
|
8160
8239
|
allStates,
|
|
8161
8240
|
this.deps.cdpManagers
|
|
8162
8241
|
);
|
|
8163
|
-
const cfg = loadConfig();
|
|
8164
|
-
const wsState = getWorkspaceState(cfg);
|
|
8165
|
-
const memSnap = getHostMemorySnapshot();
|
|
8166
8242
|
const payload = {
|
|
8167
|
-
|
|
8168
|
-
|
|
8169
|
-
|
|
8170
|
-
|
|
8171
|
-
|
|
8172
|
-
|
|
8173
|
-
|
|
8174
|
-
|
|
8175
|
-
|
|
8176
|
-
|
|
8177
|
-
|
|
8178
|
-
|
|
8179
|
-
|
|
8180
|
-
|
|
8181
|
-
|
|
8182
|
-
|
|
8183
|
-
},
|
|
8184
|
-
managedIdes,
|
|
8185
|
-
managedClis,
|
|
8186
|
-
managedAcps,
|
|
8187
|
-
p2p: {
|
|
8188
|
-
available: p2p?.isAvailable || false,
|
|
8189
|
-
state: p2p?.connectionState || "unavailable",
|
|
8190
|
-
peers: p2p?.connectedPeerCount || 0,
|
|
8191
|
-
screenshotActive: p2p?.screenshotActive || false
|
|
8192
|
-
},
|
|
8243
|
+
...buildStatusSnapshot({
|
|
8244
|
+
allStates,
|
|
8245
|
+
cdpManagers: this.deps.cdpManagers,
|
|
8246
|
+
providerLoader: this.deps.providerLoader,
|
|
8247
|
+
detectedIdes: this.deps.detectedIdes || [],
|
|
8248
|
+
instanceId: this.deps.instanceId,
|
|
8249
|
+
version: this.deps.daemonVersion || "unknown",
|
|
8250
|
+
daemonMode: true,
|
|
8251
|
+
timestamp: now,
|
|
8252
|
+
p2p: {
|
|
8253
|
+
available: p2p?.isAvailable || false,
|
|
8254
|
+
state: p2p?.connectionState || "unavailable",
|
|
8255
|
+
peers: p2p?.connectedPeerCount || 0,
|
|
8256
|
+
screenshotActive: p2p?.screenshotActive || false
|
|
8257
|
+
}
|
|
8258
|
+
}),
|
|
8193
8259
|
screenshotUsage: this.deps.getScreenshotUsage?.() || null,
|
|
8194
|
-
connectedExtensions: []
|
|
8195
|
-
detectedIdes: this.deps.detectedIdes || [],
|
|
8196
|
-
availableProviders: this.deps.providerLoader.getAll().map((p) => ({
|
|
8197
|
-
type: p.type,
|
|
8198
|
-
icon: p.icon || "\u{1F4BB}",
|
|
8199
|
-
displayName: p.displayName || p.type,
|
|
8200
|
-
category: p.category
|
|
8201
|
-
})),
|
|
8202
|
-
timestamp: now
|
|
8260
|
+
connectedExtensions: []
|
|
8203
8261
|
};
|
|
8204
8262
|
const p2pSent = this.sendP2PPayload(payload);
|
|
8205
8263
|
if (p2pSent) {
|
|
@@ -10235,6 +10293,23 @@ var AgentStreamPoller = class {
|
|
|
10235
10293
|
}
|
|
10236
10294
|
};
|
|
10237
10295
|
|
|
10296
|
+
// src/agent-stream/forward.ts
|
|
10297
|
+
function forwardAgentStreamsToIdeInstance(instanceManager, ideType, streams) {
|
|
10298
|
+
const ideInstance = instanceManager.getInstance(`ide:${ideType}`);
|
|
10299
|
+
if (!ideInstance?.onEvent) return;
|
|
10300
|
+
for (const stream of streams) {
|
|
10301
|
+
ideInstance.onEvent("stream_update", {
|
|
10302
|
+
extensionType: stream.agentType,
|
|
10303
|
+
streams: [stream],
|
|
10304
|
+
messages: stream.messages || [],
|
|
10305
|
+
status: stream.status || "idle",
|
|
10306
|
+
activeModal: stream.activeModal || null,
|
|
10307
|
+
model: stream.model || void 0,
|
|
10308
|
+
mode: stream.mode || void 0
|
|
10309
|
+
});
|
|
10310
|
+
}
|
|
10311
|
+
}
|
|
10312
|
+
|
|
10238
10313
|
// src/providers/provider-instance-manager.ts
|
|
10239
10314
|
init_logger();
|
|
10240
10315
|
var ProviderInstanceManager = class {
|
|
@@ -13219,6 +13294,31 @@ var DevServer = class _DevServer {
|
|
|
13219
13294
|
lines.push("");
|
|
13220
13295
|
}
|
|
13221
13296
|
}
|
|
13297
|
+
const docsDir = path12.join(providerDir, "../../docs");
|
|
13298
|
+
const loadGuide = (name) => {
|
|
13299
|
+
try {
|
|
13300
|
+
const p = path12.join(docsDir, name);
|
|
13301
|
+
if (fs9.existsSync(p)) return fs9.readFileSync(p, "utf-8");
|
|
13302
|
+
} catch {
|
|
13303
|
+
}
|
|
13304
|
+
return null;
|
|
13305
|
+
};
|
|
13306
|
+
const providerGuide = loadGuide("PROVIDER_GUIDE.md");
|
|
13307
|
+
if (providerGuide) {
|
|
13308
|
+
lines.push("## Documentation: PROVIDER_GUIDE.md");
|
|
13309
|
+
lines.push("```markdown");
|
|
13310
|
+
lines.push(providerGuide);
|
|
13311
|
+
lines.push("```");
|
|
13312
|
+
lines.push("");
|
|
13313
|
+
}
|
|
13314
|
+
const cdpGuide = loadGuide("CDP_SELECTOR_GUIDE.md");
|
|
13315
|
+
if (cdpGuide) {
|
|
13316
|
+
lines.push("## Documentation: CDP_SELECTOR_GUIDE.md");
|
|
13317
|
+
lines.push("```markdown");
|
|
13318
|
+
lines.push(cdpGuide);
|
|
13319
|
+
lines.push("```");
|
|
13320
|
+
lines.push("");
|
|
13321
|
+
}
|
|
13222
13322
|
lines.push("## Task");
|
|
13223
13323
|
lines.push(`Edit files in \`${providerDir}\` to implement: **${functions.join(", ")}**`);
|
|
13224
13324
|
lines.push("");
|
|
@@ -13415,6 +13515,23 @@ var DevServer = class _DevServer {
|
|
|
13415
13515
|
lines.push("");
|
|
13416
13516
|
}
|
|
13417
13517
|
}
|
|
13518
|
+
const docsDir = path12.join(providerDir, "../../docs");
|
|
13519
|
+
const loadGuide = (name) => {
|
|
13520
|
+
try {
|
|
13521
|
+
const p = path12.join(docsDir, name);
|
|
13522
|
+
if (fs9.existsSync(p)) return fs9.readFileSync(p, "utf-8");
|
|
13523
|
+
} catch {
|
|
13524
|
+
}
|
|
13525
|
+
return null;
|
|
13526
|
+
};
|
|
13527
|
+
const providerGuide = loadGuide("PROVIDER_GUIDE.md");
|
|
13528
|
+
if (providerGuide) {
|
|
13529
|
+
lines.push("## Documentation: PROVIDER_GUIDE.md");
|
|
13530
|
+
lines.push("```markdown");
|
|
13531
|
+
lines.push(providerGuide);
|
|
13532
|
+
lines.push("```");
|
|
13533
|
+
lines.push("");
|
|
13534
|
+
}
|
|
13418
13535
|
lines.push("## Runtime Contract");
|
|
13419
13536
|
lines.push("The daemon runtime is already implemented in `packages/daemon-core/src/cli-adapters/provider-cli-adapter.ts`.");
|
|
13420
13537
|
lines.push("Your scripts receive PTY-derived input and must return plain JS objects.");
|
|
@@ -14039,7 +14156,8 @@ async function initDaemonComponents(config) {
|
|
|
14039
14156
|
const disableUpstream = appConfig.disableUpstream ?? false;
|
|
14040
14157
|
const providerLoader = new ProviderLoader({
|
|
14041
14158
|
logFn: config.providerLogFn,
|
|
14042
|
-
disableUpstream
|
|
14159
|
+
disableUpstream,
|
|
14160
|
+
userDir: appConfig.providerDir
|
|
14043
14161
|
});
|
|
14044
14162
|
if (!disableUpstream && !providerLoader.hasUpstream()) {
|
|
14045
14163
|
LOG.info("Provider", "No upstream providers found \u2014 downloading from GitHub...");
|
|
@@ -14213,11 +14331,13 @@ async function shutdownDaemonComponents(components) {
|
|
|
14213
14331
|
buildManagedAcps,
|
|
14214
14332
|
buildManagedClis,
|
|
14215
14333
|
buildManagedIdes,
|
|
14334
|
+
buildStatusSnapshot,
|
|
14216
14335
|
connectCdpManager,
|
|
14217
14336
|
detectAllVersions,
|
|
14218
14337
|
detectCLIs,
|
|
14219
14338
|
detectIDEs,
|
|
14220
14339
|
findCdpManager,
|
|
14340
|
+
forwardAgentStreamsToIdeInstance,
|
|
14221
14341
|
getAIExtensions,
|
|
14222
14342
|
getAvailableIdeIds,
|
|
14223
14343
|
getHostMemorySnapshot,
|