@adhdev/daemon-core 0.8.34 → 0.8.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +127 -102
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.mjs +127 -102
  5. package/dist/index.mjs.map +1 -1
  6. package/dist/shared-types.d.ts +38 -0
  7. package/dist/status/reporter.d.ts +3 -0
  8. package/node_modules/@adhdev/session-host-core/package.json +1 -1
  9. package/package.json +1 -1
  10. package/src/agent-stream/forward.d.ts +8 -0
  11. package/src/agent-stream/index.d.ts +6 -0
  12. package/src/agent-stream/manager.d.ts +60 -0
  13. package/src/agent-stream/poller.d.ts +41 -0
  14. package/src/agent-stream/provider-adapter.d.ts +36 -0
  15. package/src/agent-stream/types.d.ts +68 -0
  16. package/src/boot/daemon-lifecycle.d.ts +100 -0
  17. package/src/cdp/devtools.d.ts +51 -0
  18. package/src/cdp/initializer.d.ts +50 -0
  19. package/src/cdp/manager.d.ts +147 -0
  20. package/src/cdp/scanner.d.ts +58 -0
  21. package/src/cdp/setup.d.ts +58 -0
  22. package/src/cli-adapter-types.d.ts +57 -0
  23. package/src/cli-adapters/provider-cli-adapter.d.ts +177 -0
  24. package/src/cli-adapters/provider-cli-adapter.ts +115 -91
  25. package/src/cli-adapters/provider-cli-config.d.ts +30 -0
  26. package/src/cli-adapters/provider-cli-parse.d.ts +42 -0
  27. package/src/cli-adapters/provider-cli-runtime.d.ts +29 -0
  28. package/src/cli-adapters/provider-cli-shared.d.ts +158 -0
  29. package/src/cli-adapters/pty-transport.d.ts +48 -0
  30. package/src/cli-adapters/session-host-transport.d.ts +20 -0
  31. package/src/cli-adapters/spawn-env.d.ts +8 -0
  32. package/src/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +16 -0
  33. package/src/cli-adapters/terminal-backends/types.d.ts +18 -0
  34. package/src/cli-adapters/terminal-backends/xterm-backend.d.ts +17 -0
  35. package/src/cli-adapters/terminal-screen.d.ts +33 -0
  36. package/src/commands/cdp-commands.d.ts +15 -0
  37. package/src/commands/chat-commands.d.ts +15 -0
  38. package/src/commands/cli-manager.d.ts +94 -0
  39. package/src/commands/handler.d.ts +103 -0
  40. package/src/commands/router.d.ts +98 -0
  41. package/src/commands/stream-commands.d.ts +14 -0
  42. package/src/commands/upgrade-helper.d.ts +10 -0
  43. package/src/commands/workspace-commands.d.ts +11 -0
  44. package/src/config/chat-history.d.ts +99 -0
  45. package/src/config/config.d.ts +14 -0
  46. package/src/config/recent-activity.d.ts +29 -0
  47. package/src/config/saved-sessions.d.ts +22 -0
  48. package/src/config/state-store.d.ts +32 -0
  49. package/src/config/workspaces.d.ts +0 -1
  50. package/src/daemon/dev-auto-implement.d.ts +43 -0
  51. package/src/daemon/dev-cdp-handlers.d.ts +22 -0
  52. package/src/daemon/dev-cli-debug.d.ts +106 -0
  53. package/src/daemon/dev-server-types.d.ts +43 -0
  54. package/src/daemon/dev-server.d.ts +140 -0
  55. package/src/daemon/scaffold-template.d.ts +32 -0
  56. package/src/daemon-core.d.ts +36 -0
  57. package/src/detection/cli-detector.d.ts +31 -0
  58. package/src/detection/ide-detector.d.ts +35 -0
  59. package/src/index.d.ts +83 -0
  60. package/src/index.ts +2 -0
  61. package/src/installer.d.ts +50 -0
  62. package/src/ipc-protocol.d.ts +111 -0
  63. package/src/launch.d.ts +46 -0
  64. package/src/logging/command-log.d.ts +31 -0
  65. package/src/logging/logger.d.ts +89 -0
  66. package/src/providers/acp-provider-instance.d.ts +102 -0
  67. package/src/providers/approval-utils.d.ts +7 -0
  68. package/src/providers/cli-provider-instance.d.ts +86 -0
  69. package/src/providers/contracts.d.ts +193 -1
  70. package/src/providers/control-effects.d.ts +4 -0
  71. package/src/providers/extension-provider-instance.d.ts +61 -0
  72. package/src/providers/ide-provider-instance.d.ts +70 -0
  73. package/src/providers/provider-instance-manager.d.ts +84 -0
  74. package/src/providers/provider-instance.d.ts +7 -1
  75. package/src/providers/provider-loader.d.ts +299 -0
  76. package/src/providers/status-monitor.d.ts +48 -0
  77. package/src/providers/version-archive.d.ts +52 -0
  78. package/src/session-host/runtime-support.d.ts +8 -0
  79. package/src/sessions/reconcile.d.ts +22 -0
  80. package/src/sessions/registry.d.ts +24 -0
  81. package/src/shared-types-extra.d.ts +29 -0
  82. package/src/shared-types.d.ts +79 -22
  83. package/src/shared-types.ts +40 -0
  84. package/src/status/builders.d.ts +33 -0
  85. package/src/status/reporter.d.ts +69 -0
  86. package/src/status/reporter.ts +16 -13
  87. package/src/status/snapshot.d.ts +58 -0
  88. package/src/system/host-memory.d.ts +19 -0
  89. package/src/types.d.ts +3 -7
@@ -0,0 +1,140 @@
1
+ import type { DevServerContext } from './dev-server-types.js';
2
+ /**
3
+ * Dev Server — HTTP API for Provider debugging + script development
4
+ *
5
+ * Enabled with `adhdev daemon --dev`
6
+ * Port: 19280 (fixed)
7
+ *
8
+ * API list:
9
+ * GET /api/providers — loaded provider list
10
+ * POST /api/providers/:type/script — specific script execute
11
+ * POST /api/cdp/evaluate — Execute JS expression
12
+ * POST /api/cdp/dom/query — Test selector
13
+ * GET /api/cdp/screenshot — screenshot
14
+ * POST /api/scripts/run — Execute provider script (name + params)
15
+ * GET /api/status — All status (CDP connection, provider etc)
16
+ */
17
+ import * as http from 'http';
18
+ import type { ProviderLoader } from '../providers/provider-loader.js';
19
+ import type { ChildProcess } from 'child_process';
20
+ import type { DaemonCdpManager } from '../cdp/manager.js';
21
+ import type { ProviderInstanceManager } from '../providers/provider-instance-manager.js';
22
+ import type { DaemonCliManager } from '../commands/cli-manager.js';
23
+ export declare const DEV_SERVER_PORT = 19280;
24
+ export declare class DevServer implements DevServerContext {
25
+ private server;
26
+ providerLoader: ProviderLoader;
27
+ cdpManagers: Map<string, DaemonCdpManager>;
28
+ instanceManager: ProviderInstanceManager | null;
29
+ cliManager: DaemonCliManager | null;
30
+ private logFn;
31
+ private sseClients;
32
+ private watchScriptPath;
33
+ private watchScriptName;
34
+ private watchTimer;
35
+ autoImplProcess: ChildProcess | null;
36
+ autoImplSSEClients: http.ServerResponse[];
37
+ autoImplStatus: {
38
+ running: boolean;
39
+ type: string | null;
40
+ progress: any[];
41
+ };
42
+ private cliSSEClients;
43
+ constructor(options: {
44
+ providerLoader: ProviderLoader;
45
+ cdpManagers: Map<string, DaemonCdpManager>;
46
+ instanceManager?: ProviderInstanceManager;
47
+ cliManager?: DaemonCliManager;
48
+ logFn?: (msg: string) => void;
49
+ });
50
+ log(msg: string): void;
51
+ private readonly routes;
52
+ private matchRoute;
53
+ private getEndpointList;
54
+ start(port?: number): Promise<void>;
55
+ stop(): void;
56
+ private handleListProviders;
57
+ private handleProviderConfig;
58
+ private handleSpawnTest;
59
+ handleRunScript(type: string, req: http.IncomingMessage, res: http.ServerResponse, parsedBody?: any): Promise<void>;
60
+ private handleCdpEvaluate;
61
+ private handleCdpClick;
62
+ private handleCdpDomQuery;
63
+ private handleScreenshot;
64
+ private handleScriptsRun;
65
+ private handleStatus;
66
+ private handleReload;
67
+ private getConsoleDistDir;
68
+ private serveConsole;
69
+ private static MIME_MAP;
70
+ private serveStaticAsset;
71
+ private handleSSE;
72
+ private sendSSE;
73
+ private handleWatchStart;
74
+ private handleWatchStop;
75
+ /** Find the provider directory on disk */
76
+ findProviderDir(type: string): string | null;
77
+ /** GET /api/providers/:type/files — list all files in provider directory */
78
+ private handleListFiles;
79
+ /** GET /api/providers/:type/file?path=scripts.js — read a file */
80
+ private handleReadFile;
81
+ /** POST /api/providers/:type/file — write a file { path, content } */
82
+ private handleWriteFile;
83
+ private handleSource;
84
+ private handleSave;
85
+ private handleTypeAndSend;
86
+ private handleTypeAndSendAt;
87
+ private handleScriptHints;
88
+ private handleValidate;
89
+ private handleAcpChat;
90
+ private handleCdpTargets;
91
+ private handleScaffold;
92
+ private handleDetectVersions;
93
+ private handleDomInspect;
94
+ private handleDomChildren;
95
+ private handleDomAnalyze;
96
+ private handleFindCommon;
97
+ private handleFindByText;
98
+ private handleDomContext;
99
+ getLatestScriptVersionDir(scriptsDir: string): string | null;
100
+ private resolveAutoImplWritableProviderDir;
101
+ private handleAutoImplement;
102
+ private buildAutoImplPrompt;
103
+ private buildCliAutoImplPrompt;
104
+ private handleAutoImplSSE;
105
+ private handleAutoImplCancel;
106
+ sendAutoImplSSE(msg: {
107
+ event: string;
108
+ data: any;
109
+ }): void;
110
+ /** Get CDP manager — matching IDE when ideType specified, first connected one otherwise.
111
+ * DevServer is a debugging tool so first-connected fallback is acceptable,
112
+ * but callers should pass ideType when possible. */
113
+ getCdp(ideType?: string): DaemonCdpManager | null;
114
+ json(res: http.ServerResponse, status: number, data: any): void;
115
+ readBody(req: http.IncomingMessage): Promise<any>;
116
+ /** GET /api/cli/status — list all running CLI/ACP instances with state */
117
+ private handleCliStatus;
118
+ /** POST /api/cli/launch — launch a CLI agent { type, workingDir?, args? } */
119
+ private handleCliLaunch;
120
+ /** POST /api/cli/send — send message to a running CLI { type, text } */
121
+ private handleCliSend;
122
+ /** POST /api/cli/exercise — launch/send/approve/wait helper for provider-fix loops */
123
+ private handleCliExercise;
124
+ private handleCliFixtureCapture;
125
+ private handleCliFixtureReplay;
126
+ /** POST /api/cli/stop — stop a running CLI { type } */
127
+ private handleCliStop;
128
+ /** GET /api/cli/events — SSE stream of CLI status events */
129
+ private handleCliSSE;
130
+ sendCliSSE(data: any): void;
131
+ /** GET /api/cli/debug/:type — full internal debug state of a CLI adapter */
132
+ private handleCliDebug;
133
+ /** GET /api/cli/trace/:type — recent CLI trace timeline plus current debug snapshot */
134
+ private handleCliTrace;
135
+ private handleCliFixtureList;
136
+ /** POST /api/cli/resolve — resolve an approval modal { type, buttonIndex } */
137
+ private handleCliResolve;
138
+ /** POST /api/cli/raw — send raw keystrokes to PTY { type, keys } */
139
+ private handleCliRaw;
140
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Provider scaffold template generator
3
+ * Generates provider.json + scripts/ directory structure (Antigravity pattern).
4
+ *
5
+ * New pattern:
6
+ * - Scripts WITHOUT params: self-invoking IIFE — (() => { ... })()
7
+ * - Scripts WITH params: function expression — (params) => { ... }
8
+ * Router invokes: `(${script})(${JSON.stringify(params)})`
9
+ * - Each function is a separate .js file in scripts/<version>/
10
+ * - scripts.js router loads + invokes individual files
11
+ */
12
+ export interface ScaffoldOptions {
13
+ cdpPorts?: [number, number];
14
+ cli?: string;
15
+ processName?: string;
16
+ installPath?: string;
17
+ binary?: string;
18
+ extensionId?: string;
19
+ version?: string;
20
+ osPaths?: Record<string, string[]>;
21
+ processNames?: Record<string, string>;
22
+ }
23
+ export interface ScaffoldResult {
24
+ 'provider.json': string;
25
+ files?: Record<string, string>;
26
+ }
27
+ export declare function generateTemplate(type: string, name: string, category: string, opts?: ScaffoldOptions): string;
28
+ /**
29
+ * Generate provider.json + per-function script files.
30
+ * Returns a map of relative paths -> file contents.
31
+ */
32
+ export declare function generateFiles(type: string, name: string, category: string, opts?: ScaffoldOptions): ScaffoldResult;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * DaemonCore — Core daemon orchestrator interface
3
+ *
4
+ * Provides the core daemon orchestrator interface consumed by daemon-standalone.
5
+ * Actual implementation extracted from launcher and placed in this package.
6
+ */
7
+ import type { StatusResponse, CommandResult, DaemonEvent } from './types.js';
8
+ import type { SessionEntry } from './shared-types.js';
9
+ export interface DaemonCoreOptions {
10
+ /** Data directory for config, logs */
11
+ dataDir?: string;
12
+ /** Custom provider directories */
13
+ providerDirs?: string[];
14
+ /** Enable/disable specific detectors */
15
+ enableIdeDetection?: boolean;
16
+ enableCliDetection?: boolean;
17
+ enableAcpDetection?: boolean;
18
+ /** Status report interval (ms) */
19
+ statusInterval?: number;
20
+ }
21
+ export interface IDaemonCore {
22
+ /** Initialize and start the daemon core */
23
+ start(): Promise<void>;
24
+ /** Gracefully stop the daemon */
25
+ stop(): Promise<void>;
26
+ /** Get current daemon status snapshot */
27
+ getStatus(): StatusResponse;
28
+ /** Subscribe to status changes. Returns unsubscribe function. */
29
+ onStatusChange(callback: (status: StatusResponse) => void): () => void;
30
+ /** Subscribe to all daemon events. Returns unsubscribe function. */
31
+ onEvent(callback: (event: DaemonEvent) => void): () => void;
32
+ /** Execute a command (send_chat, new_session, etc.) */
33
+ executeCommand(type: string, payload: any, target?: string): Promise<CommandResult>;
34
+ /** Get current canonical runtime sessions */
35
+ getSessions(): SessionEntry[];
36
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * CLI AI Agent Detector
3
+ *
4
+ * Dynamic CLI detection based on Provider.
5
+ * Reads spawn.command from cli/acp categories via ProviderLoader to check installation.
6
+ *
7
+ * Uses parallel execution for fast detection across many providers.
8
+ */
9
+ import type { ProviderLoader } from '../providers/provider-loader.js';
10
+ export interface CLIInfo {
11
+ id: string;
12
+ displayName: string;
13
+ icon: string;
14
+ command: string;
15
+ versionCommand?: string;
16
+ installed: boolean;
17
+ version?: string;
18
+ path?: string;
19
+ category?: string;
20
+ }
21
+ /**
22
+ * Detect all CLI/ACP agents (parallel)
23
+ * @param providerLoader ProviderLoader instance (dynamic list creation)
24
+ */
25
+ export declare function detectCLIs(providerLoader?: ProviderLoader, options?: {
26
+ includeVersion?: boolean;
27
+ }): Promise<CLIInfo[]>;
28
+ /** Detect specific CLI — only probes the one requested provider */
29
+ export declare function detectCLI(cliId: string, providerLoader?: ProviderLoader, options?: {
30
+ includeVersion?: boolean;
31
+ }): Promise<CLIInfo | null>;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * ADHDev — IDE Detector (canonical implementation)
3
+ *
4
+ * Detects installed IDEs on the user's local machine.
5
+ * Supports macOS, Windows, and Linux.
6
+ *
7
+ * Migrated from @adhdev/core — this is now the single source of truth.
8
+ */
9
+ import type { ProviderLoader } from '../providers/provider-loader.js';
10
+ export interface IDEInfo {
11
+ id: string;
12
+ name: string;
13
+ displayName: string;
14
+ installed: boolean;
15
+ path: string | null;
16
+ cliCommand: string | null;
17
+ version: string | null;
18
+ icon: string;
19
+ notes?: string;
20
+ }
21
+ export interface IDEDefinition {
22
+ id: string;
23
+ name: string;
24
+ displayName: string;
25
+ icon: string;
26
+ cli: string;
27
+ paths: {
28
+ darwin?: string[];
29
+ win32?: string[];
30
+ linux?: string[];
31
+ [key: string]: string[] | undefined;
32
+ };
33
+ }
34
+ export declare function registerIDEDefinition(def: IDEDefinition): void;
35
+ export declare function detectIDEs(providerLoader?: ProviderLoader): Promise<IDEInfo[]>;
package/src/index.d.ts ADDED
@@ -0,0 +1,83 @@
1
+ /**
2
+ * @adhdev/daemon-core — Public API
3
+ *
4
+ * Core logic for daemon: CDP, Provider, IDE detection, CLI/ACP adapters and more.
5
+ */
6
+ export type { ChatMessage, ExtensionInfo, CommandResult as CoreCommandResult, ProviderConfig, DaemonEvent, StatusResponse, SystemInfo, DetectedIde, ProviderInfo, AgentEntry, } from './types.js';
7
+ export type { SessionEntry, CompactSessionEntry, CompactDaemonEntry, 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 { RecentLaunchEntry as _RecentLaunchEntry } 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 RecentLaunchEntry = _RecentLaunchEntry;
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 { getSavedProviderSessions, upsertSavedProviderSession } from './config/saved-sessions.js';
24
+ export type { SavedProviderSessionEntry } from './config/saved-sessions.js';
25
+ export { loadState, saveState, resetState } from './config/state-store.js';
26
+ export type { DaemonState } from './config/state-store.js';
27
+ export { detectIDEs } from './detection/ide-detector.js';
28
+ export type { IDEInfo } from './detection/ide-detector.js';
29
+ export { detectCLIs } from './detection/cli-detector.js';
30
+ export { getHostMemorySnapshot } from './system/host-memory.js';
31
+ export type { HostMemorySnapshot } from './system/host-memory.js';
32
+ export { DaemonCdpManager } from './cdp/manager.js';
33
+ export { CdpDomHandlers } from './cdp/devtools.js';
34
+ export { setupIdeInstance, registerExtensionProviders, connectCdpManager, probeCdpPort } from './cdp/setup.js';
35
+ export type { CdpSetupContext, SetupIdeInstanceOptions } from './cdp/setup.js';
36
+ export { DaemonCdpScanner } from './cdp/scanner.js';
37
+ export type { CdpScannerOptions } from './cdp/scanner.js';
38
+ export { DaemonCdpInitializer } from './cdp/initializer.js';
39
+ export type { CdpInitializerConfig } from './cdp/initializer.js';
40
+ export { DaemonCommandHandler } from './commands/handler.js';
41
+ export type { CommandResult, CommandContext } from './commands/handler.js';
42
+ export { DaemonCommandRouter } from './commands/router.js';
43
+ export type { CommandRouterDeps, CommandRouterResult } from './commands/router.js';
44
+ export { maybeRunDaemonUpgradeHelperFromEnv, spawnDetachedDaemonUpgradeHelper } from './commands/upgrade-helper.js';
45
+ export type { DaemonUpgradeHelperPayload } from './commands/upgrade-helper.js';
46
+ export { DaemonStatusReporter } from './status/reporter.js';
47
+ export { buildSessionEntries, findCdpManager, hasCdpManager, isCdpConnected } from './status/builders.js';
48
+ export { buildStatusSnapshot } from './status/snapshot.js';
49
+ export { normalizeManagedStatus, isManagedStatusWorking, isManagedStatusWaiting, normalizeActiveChatData } from './status/normalize.js';
50
+ export type { ManagedStatus } from './status/normalize.js';
51
+ export type { StatusSnapshotOptions, StatusSnapshot } from './status/snapshot.js';
52
+ export { LOG, installGlobalInterceptor, setLogLevel, getLogLevel, getRecentLogs, getDaemonLogDir, getCurrentDaemonLogPath, } from './logging/logger.js';
53
+ export type { ScopedLogger, LogLevel, LogEntry } from './logging/logger.js';
54
+ export { logCommand, getRecentCommands } from './logging/command-log.js';
55
+ export { DaemonCliManager } from './commands/cli-manager.js';
56
+ export { launchWithCdp, getAvailableIdeIds, killIdeProcess, isIdeRunning } from './launch.js';
57
+ export { DEFAULT_DAEMON_PORT, DAEMON_WS_PATH } from './ipc-protocol.js';
58
+ export { readChatHistory } from './config/chat-history.js';
59
+ export { DaemonAgentStreamManager } from './agent-stream/index.js';
60
+ export { AgentStreamPoller } from './agent-stream/index.js';
61
+ export type { AgentStreamPollerDeps } from './agent-stream/index.js';
62
+ export { forwardAgentStreamsToIdeInstance } from './agent-stream/forward.js';
63
+ export { ProviderLoader } from './providers/provider-loader.js';
64
+ export { ProviderInstanceManager } from './providers/provider-instance-manager.js';
65
+ export { IdeProviderInstance } from './providers/ide-provider-instance.js';
66
+ export { CliProviderInstance } from './providers/cli-provider-instance.js';
67
+ export { AcpProviderInstance } from './providers/acp-provider-instance.js';
68
+ export type { ProviderModule, CdpTargetFilter, ProviderResumeCapability } from './providers/contracts.js';
69
+ export { VersionArchive, detectAllVersions } from './providers/version-archive.js';
70
+ export type { ProviderVersionInfo, VersionHistory } from './providers/version-archive.js';
71
+ export { DevServer } from './daemon/dev-server.js';
72
+ export { ProviderCliAdapter } from './cli-adapters/provider-cli-adapter.js';
73
+ export type { CliAdapter } from './cli-adapter-types.js';
74
+ export { NodePtyTransportFactory } from './cli-adapters/pty-transport.js';
75
+ export type { PtyRuntimeTransport, PtyTransportFactory, PtySpawnOptions } from './cli-adapters/pty-transport.js';
76
+ export { SessionHostPtyTransportFactory } from './cli-adapters/session-host-transport.js';
77
+ export type { HostedCliRuntimeDescriptor, CliTransportFactoryParams } from './commands/cli-manager.js';
78
+ export { ensureSessionHostReady, listHostedCliRuntimes } from './session-host/runtime-support.js';
79
+ export type { SessionHostEndpoint } from '@adhdev/session-host-core';
80
+ export { getAIExtensions, installExtensions, launchIDE, isExtensionInstalled } from './installer.js';
81
+ export type { ExtensionInfo as InstallerExtensionInfo } from './installer.js';
82
+ export { initDaemonComponents, startDaemonDevSupport, shutdownDaemonComponents } from './boot/daemon-lifecycle.js';
83
+ export type { DaemonInitConfig, DaemonComponents, DaemonDevSupportOptions } from './boot/daemon-lifecycle.js';
package/src/index.ts CHANGED
@@ -21,6 +21,8 @@ export type {
21
21
  // ── Shared Types (cross-package) ──
22
22
  export type {
23
23
  SessionEntry,
24
+ CompactSessionEntry,
25
+ CompactDaemonEntry,
24
26
  SessionTransport,
25
27
  SessionKind,
26
28
  SessionCapability,
@@ -0,0 +1,50 @@
1
+ /**
2
+ * ADHDev Launcher — Extension Installer
3
+ *
4
+ * Installs VS Code extensions via CLI commands.
5
+ * Supports installing user-selected AI extensions.
6
+ */
7
+ import { IDEInfo } from './detection/ide-detector.js';
8
+ export interface ExtensionInfo {
9
+ id: string;
10
+ name: string;
11
+ displayName: string;
12
+ marketplaceId: string;
13
+ description: string;
14
+ category: 'ai-agent' | 'utility';
15
+ icon: string;
16
+ recommended: boolean;
17
+ requiresApiKey?: boolean;
18
+ apiKeyName?: string;
19
+ website?: string;
20
+ vsixUrl?: string;
21
+ }
22
+ /** Available extensions catalog */
23
+ export declare const EXTENSION_CATALOG: ExtensionInfo[];
24
+ export interface InstallResult {
25
+ extensionId: string;
26
+ marketplaceId: string;
27
+ success: boolean;
28
+ alreadyInstalled: boolean;
29
+ error?: string;
30
+ }
31
+ /**
32
+ * Check if an extension is already installed
33
+ */
34
+ export declare function isExtensionInstalled(ide: IDEInfo, marketplaceId: string): boolean;
35
+ /**
36
+ * Install a single extension
37
+ */
38
+ export declare function installExtension(ide: IDEInfo, extension: ExtensionInfo): Promise<InstallResult>;
39
+ /**
40
+ * Install multiple extensions sequentially
41
+ */
42
+ export declare function installExtensions(ide: IDEInfo, extensions: ExtensionInfo[], onProgress?: (current: number, total: number, ext: ExtensionInfo, result: InstallResult) => void): Promise<InstallResult[]>;
43
+ /**
44
+ * Get AI agent extensions
45
+ */
46
+ export declare function getAIExtensions(): ExtensionInfo[];
47
+ /**
48
+ * Launch IDE after installation
49
+ */
50
+ export declare function launchIDE(ide: IDEInfo, workspacePath?: string): boolean;
@@ -0,0 +1,111 @@
1
+ /**
2
+ * ADHDev IPC Protocol — Extension ↔ Daemon communication protocol
3
+ *
4
+ * Message types used when Extension and Daemon communicate via localhost WS.
5
+ * Defined in core package for import from both sides.
6
+ */
7
+ /** Extension registers itself with Daemon on first connection */
8
+ export interface IpcExtRegister {
9
+ type: 'ext:register';
10
+ payload: {
11
+ ideType: string;
12
+ ideVersion: string;
13
+ extensionVersion: string;
14
+ instanceId: string;
15
+ machineId: string;
16
+ workspaceFolders: {
17
+ name: string;
18
+ path: string;
19
+ }[];
20
+ };
21
+ }
22
+ /** Extension periodically send vscode status data */
23
+ export interface IpcExtStatus {
24
+ type: 'ext:status';
25
+ payload: {
26
+ activeFile: string | null;
27
+ workspaceFolders: {
28
+ name: string;
29
+ path: string;
30
+ }[];
31
+ terminals: number;
32
+ aiAgents: {
33
+ id: string;
34
+ name: string;
35
+ status: string;
36
+ version?: string;
37
+ }[];
38
+ };
39
+ }
40
+ /** Return Extension vscode command execution result */
41
+ export interface IpcExtCommandResult {
42
+ type: 'ext:command_result';
43
+ payload: {
44
+ requestId: string;
45
+ success: boolean;
46
+ result?: unknown;
47
+ error?: string;
48
+ };
49
+ }
50
+ /** VSCode event occurring from Extension */
51
+ export interface IpcExtEvent {
52
+ type: 'ext:event';
53
+ payload: {
54
+ event: 'file_changed' | 'terminal_opened' | 'terminal_closed' | 'agent_status_changed';
55
+ data: Record<string, unknown>;
56
+ };
57
+ }
58
+ /** Welcome message on Daemon-Extension connection */
59
+ export interface IpcDaemonWelcome {
60
+ type: 'daemon:welcome';
61
+ payload: {
62
+ daemonVersion: string;
63
+ serverConnected: boolean;
64
+ cdpConnected: boolean;
65
+ localPort: number;
66
+ cliAgents: string[];
67
+ };
68
+ }
69
+ /** Daemon to Extension vscode Request command execution */
70
+ export interface IpcDaemonExecuteVscode {
71
+ type: 'daemon:execute_vscode';
72
+ payload: {
73
+ requestId: string;
74
+ command: string;
75
+ args?: unknown[];
76
+ };
77
+ }
78
+ /** Daemon to Extension status data request */
79
+ export interface IpcDaemonRequestStatus {
80
+ type: 'daemon:request_status';
81
+ payload: {};
82
+ }
83
+ /** Daemon notifies Extension about server connection status */
84
+ export interface IpcDaemonServerState {
85
+ type: 'daemon:server_state';
86
+ payload: {
87
+ connected: boolean;
88
+ serverUrl: string;
89
+ };
90
+ }
91
+ /** Daemon to Extension notification display request */
92
+ export interface IpcDaemonNotify {
93
+ type: 'daemon:notify';
94
+ payload: {
95
+ level: 'info' | 'warning' | 'error';
96
+ message: string;
97
+ };
98
+ }
99
+ /** Extension requests Daemon to execute command (e.g. CLI launch) */
100
+ export interface IpcExtCommand {
101
+ type: 'ext:command';
102
+ payload: {
103
+ command: string;
104
+ args?: any;
105
+ };
106
+ }
107
+ export type ExtToDaemonMessage = IpcExtRegister | IpcExtStatus | IpcExtCommandResult | IpcExtEvent | IpcExtCommand;
108
+ export type DaemonToExtMessage = IpcDaemonWelcome | IpcDaemonExecuteVscode | IpcDaemonRequestStatus | IpcDaemonServerState | IpcDaemonNotify;
109
+ export type IpcMessage = ExtToDaemonMessage | DaemonToExtMessage;
110
+ export declare const DEFAULT_DAEMON_PORT = 19222;
111
+ export declare const DAEMON_WS_PATH = "/ipc";
@@ -0,0 +1,46 @@
1
+ /**
2
+ * ADHDev Launcher — IDE Launch/Relaunch with CDP
3
+ *
4
+ * Launches IDE with Chrome DevTools Protocol (remote-debugging-port).
5
+ * If IDE is already running, terminates it and restarts with CDP option.
6
+ *
7
+ * Pipeline:
8
+ * 1. IDE process detection (already running?)
9
+ * 2. If already running with CDP → reuse as-is
10
+ * 3. If running without CDP → kill process → wait → restart with CDP
11
+ * 4. Not running → start fresh with CDP
12
+ *
13
+ * Usage:
14
+ * adhdev launch — Launch configured IDE with CDP port
15
+ * adhdev launch cursor — Launch Cursor with CDP port
16
+ * adhdev launch --workspace /path — Open specific workspace
17
+ */
18
+ /** Kill IDE process (graceful → force) */
19
+ export declare function killIdeProcess(ideId: string): Promise<boolean>;
20
+ /** Check if IDE process is running */
21
+ export declare function isIdeRunning(ideId: string): boolean;
22
+ export interface LaunchOptions {
23
+ ideId?: string;
24
+ workspace?: string;
25
+ newWindow?: boolean;
26
+ }
27
+ export interface LaunchResult {
28
+ success: boolean;
29
+ ideId: string;
30
+ ideName: string;
31
+ port: number;
32
+ action: 'started' | 'restarted' | 'reused' | 'failed';
33
+ message: string;
34
+ error?: string;
35
+ }
36
+ /**
37
+ * Execute IDE with CDP port (relaunch pipeline)
38
+ *
39
+ * 1. IDE detect
40
+ * 2. per-fixed IDE CDP port determine
41
+ * 3. CDP not active → reuse
42
+ * 4. IDE execute during but CDP none → terminate → restart with CDP
43
+ * 5. IDE not running → start fresh with CDP
44
+ */
45
+ export declare function launchWithCdp(options?: LaunchOptions): Promise<LaunchResult>;
46
+ export declare function getAvailableIdeIds(): string[];
@@ -0,0 +1,31 @@
1
+ /**
2
+ * ADHDev Daemon — Command History Logger
3
+ *
4
+ * Record all commands from dashboard/WS/P2P/Extension/API to local file.
5
+ * Per-date JSONL file, 7-day retention, 5MB limit.
6
+ *
7
+ * Purpose:
8
+ * - Debugging: track what command came and when
9
+ * - Audit: record all commands executed from remote
10
+ * - Stats: identify frequently used features
11
+ */
12
+ export interface CommandLogEntry {
13
+ ts: string;
14
+ cmd: string;
15
+ source: 'ws' | 'p2p' | 'ext' | 'api' | 'standalone' | 'unknown';
16
+ args?: Record<string, unknown>;
17
+ success?: boolean;
18
+ error?: string;
19
+ durationMs?: number;
20
+ }
21
+ /**
22
+ * Log a command received from the dashboard/WS/P2P/extension/API.
23
+ * Call this at the entry point of command handling.
24
+ */
25
+ export declare function logCommand(entry: CommandLogEntry): void;
26
+ /**
27
+ * Read recent command history (for dashboard display / debugging)
28
+ */
29
+ export declare function getRecentCommands(count?: number): CommandLogEntry[];
30
+ /** Current command log file path */
31
+ export declare function getCommandLogPath(): string;