@adhdev/daemon-core 0.5.3

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 (217) hide show
  1. package/dist/index.d.ts +2662 -0
  2. package/dist/index.js +11341 -0
  3. package/dist/index.js.map +1 -0
  4. package/package.json +48 -0
  5. package/providers/_builtin/.github/workflows/generate-registry.yml +57 -0
  6. package/providers/_builtin/COMPATIBILITY.md +217 -0
  7. package/providers/_builtin/CONTRIBUTING.md +200 -0
  8. package/providers/_builtin/README.md +119 -0
  9. package/providers/_builtin/_helpers/index.js +188 -0
  10. package/providers/_builtin/acp/agentpool/provider.json +54 -0
  11. package/providers/_builtin/acp/amp/provider.json +52 -0
  12. package/providers/_builtin/acp/auggie/provider.json +57 -0
  13. package/providers/_builtin/acp/autodev/provider.json +54 -0
  14. package/providers/_builtin/acp/autohand/provider.json +52 -0
  15. package/providers/_builtin/acp/blackbox-ai/provider.json +54 -0
  16. package/providers/_builtin/acp/claude-agent/provider.json +57 -0
  17. package/providers/_builtin/acp/cline-acp/provider.json +54 -0
  18. package/providers/_builtin/acp/codebuddy/provider.json +54 -0
  19. package/providers/_builtin/acp/codex-cli/provider.json +57 -0
  20. package/providers/_builtin/acp/corust-agent/provider.json +52 -0
  21. package/providers/_builtin/acp/crow-cli/provider.json +54 -0
  22. package/providers/_builtin/acp/cursor-acp/provider.json +54 -0
  23. package/providers/_builtin/acp/deepagents/provider.json +52 -0
  24. package/providers/_builtin/acp/dimcode/provider.json +54 -0
  25. package/providers/_builtin/acp/docker-cagent/provider.json +57 -0
  26. package/providers/_builtin/acp/factory-droid/provider.json +60 -0
  27. package/providers/_builtin/acp/fast-agent/provider.json +52 -0
  28. package/providers/_builtin/acp/gemini-cli/provider.json +114 -0
  29. package/providers/_builtin/acp/github-copilot/provider.json +54 -0
  30. package/providers/_builtin/acp/goose/provider.json +57 -0
  31. package/providers/_builtin/acp/junie/provider.json +52 -0
  32. package/providers/_builtin/acp/kilo/provider.json +54 -0
  33. package/providers/_builtin/acp/kimi-cli/provider.json +57 -0
  34. package/providers/_builtin/acp/minion-code/provider.json +52 -0
  35. package/providers/_builtin/acp/mistral-vibe/provider.json +57 -0
  36. package/providers/_builtin/acp/nova/provider.json +54 -0
  37. package/providers/_builtin/acp/openclaw/provider.json +54 -0
  38. package/providers/_builtin/acp/opencode/provider.json +52 -0
  39. package/providers/_builtin/acp/openhands/provider.json +54 -0
  40. package/providers/_builtin/acp/pi-acp/provider.json +52 -0
  41. package/providers/_builtin/acp/qoder/provider.json +54 -0
  42. package/providers/_builtin/acp/qwen-code/provider.json +60 -0
  43. package/providers/_builtin/acp/stakpak/provider.json +54 -0
  44. package/providers/_builtin/acp/vtcode/provider.json +54 -0
  45. package/providers/_builtin/cli/claude-cli/provider.json +100 -0
  46. package/providers/_builtin/cli/codex-cli/provider.json +89 -0
  47. package/providers/_builtin/cli/gemini-cli/provider.json +93 -0
  48. package/providers/_builtin/docs/CDP_SELECTOR_GUIDE.md +370 -0
  49. package/providers/_builtin/docs/PROVIDER_GUIDE.md +916 -0
  50. package/providers/_builtin/extension/cline/provider.json +35 -0
  51. package/providers/_builtin/extension/cline/scripts/focus_editor.js +48 -0
  52. package/providers/_builtin/extension/cline/scripts/list_chats.js +100 -0
  53. package/providers/_builtin/extension/cline/scripts/list_models.js +43 -0
  54. package/providers/_builtin/extension/cline/scripts/list_modes.js +35 -0
  55. package/providers/_builtin/extension/cline/scripts/new_session.js +85 -0
  56. package/providers/_builtin/extension/cline/scripts/open_panel.js +25 -0
  57. package/providers/_builtin/extension/cline/scripts/read_chat.js +257 -0
  58. package/providers/_builtin/extension/cline/scripts/resolve_action.js +83 -0
  59. package/providers/_builtin/extension/cline/scripts/send_message.js +95 -0
  60. package/providers/_builtin/extension/cline/scripts/set_mode.js +36 -0
  61. package/providers/_builtin/extension/cline/scripts/set_model.js +36 -0
  62. package/providers/_builtin/extension/cline/scripts/switch_session.js +206 -0
  63. package/providers/_builtin/extension/cline/scripts.js +73 -0
  64. package/providers/_builtin/extension/roo-code/provider.json +35 -0
  65. package/providers/_builtin/extension/roo-code/scripts.js +659 -0
  66. package/providers/_builtin/ide/antigravity/provider.json +68 -0
  67. package/providers/_builtin/ide/antigravity/scripts/1.106/focus_editor.js +20 -0
  68. package/providers/_builtin/ide/antigravity/scripts/1.106/list_chats.js +137 -0
  69. package/providers/_builtin/ide/antigravity/scripts/1.106/list_models.js +38 -0
  70. package/providers/_builtin/ide/antigravity/scripts/1.106/list_modes.js +48 -0
  71. package/providers/_builtin/ide/antigravity/scripts/1.106/new_session.js +75 -0
  72. package/providers/_builtin/ide/antigravity/scripts/1.106/read_chat.js +262 -0
  73. package/providers/_builtin/ide/antigravity/scripts/1.106/resolve_action.js +68 -0
  74. package/providers/_builtin/ide/antigravity/scripts/1.106/scripts.js +57 -0
  75. package/providers/_builtin/ide/antigravity/scripts/1.106/send_message.js +56 -0
  76. package/providers/_builtin/ide/antigravity/scripts/1.106/set_mode.js +34 -0
  77. package/providers/_builtin/ide/antigravity/scripts/1.106/set_model.js +47 -0
  78. package/providers/_builtin/ide/antigravity/scripts/1.106/switch_session.js +114 -0
  79. package/providers/_builtin/ide/antigravity/scripts/1.107/focus_editor.js +20 -0
  80. package/providers/_builtin/ide/antigravity/scripts/1.107/list_chats.js +137 -0
  81. package/providers/_builtin/ide/antigravity/scripts/1.107/list_models.js +61 -0
  82. package/providers/_builtin/ide/antigravity/scripts/1.107/list_modes.js +72 -0
  83. package/providers/_builtin/ide/antigravity/scripts/1.107/new_session.js +75 -0
  84. package/providers/_builtin/ide/antigravity/scripts/1.107/read_chat.js +262 -0
  85. package/providers/_builtin/ide/antigravity/scripts/1.107/resolve_action.js +68 -0
  86. package/providers/_builtin/ide/antigravity/scripts/1.107/scripts.js +67 -0
  87. package/providers/_builtin/ide/antigravity/scripts/1.107/send_message.js +56 -0
  88. package/providers/_builtin/ide/antigravity/scripts/1.107/set_mode.js +67 -0
  89. package/providers/_builtin/ide/antigravity/scripts/1.107/set_model.js +72 -0
  90. package/providers/_builtin/ide/antigravity/scripts/1.107/switch_session.js +114 -0
  91. package/providers/_builtin/ide/cursor/provider.json +70 -0
  92. package/providers/_builtin/ide/cursor/scripts/0.49/dismiss_notification.js +30 -0
  93. package/providers/_builtin/ide/cursor/scripts/0.49/focus_editor.js +13 -0
  94. package/providers/_builtin/ide/cursor/scripts/0.49/list_models.js +78 -0
  95. package/providers/_builtin/ide/cursor/scripts/0.49/list_modes.js +40 -0
  96. package/providers/_builtin/ide/cursor/scripts/0.49/list_notifications.js +23 -0
  97. package/providers/_builtin/ide/cursor/scripts/0.49/list_sessions.js +42 -0
  98. package/providers/_builtin/ide/cursor/scripts/0.49/new_session.js +20 -0
  99. package/providers/_builtin/ide/cursor/scripts/0.49/open_panel.js +23 -0
  100. package/providers/_builtin/ide/cursor/scripts/0.49/read_chat.js +75 -0
  101. package/providers/_builtin/ide/cursor/scripts/0.49/resolve_action.js +19 -0
  102. package/providers/_builtin/ide/cursor/scripts/0.49/scripts.js +78 -0
  103. package/providers/_builtin/ide/cursor/scripts/0.49/send_message.js +23 -0
  104. package/providers/_builtin/ide/cursor/scripts/0.49/set_mode.js +38 -0
  105. package/providers/_builtin/ide/cursor/scripts/0.49/set_model.js +81 -0
  106. package/providers/_builtin/ide/cursor/scripts/0.49/switch_session.js +28 -0
  107. package/providers/_builtin/ide/kiro/provider.json +67 -0
  108. package/providers/_builtin/ide/kiro/scripts/focus_editor.js +20 -0
  109. package/providers/_builtin/ide/kiro/scripts/open_panel.js +47 -0
  110. package/providers/_builtin/ide/kiro/scripts/resolve_action.js +54 -0
  111. package/providers/_builtin/ide/kiro/scripts/send_message.js +29 -0
  112. package/providers/_builtin/ide/kiro/scripts/webview_list_models.js +39 -0
  113. package/providers/_builtin/ide/kiro/scripts/webview_list_modes.js +39 -0
  114. package/providers/_builtin/ide/kiro/scripts/webview_list_sessions.js +21 -0
  115. package/providers/_builtin/ide/kiro/scripts/webview_new_session.js +34 -0
  116. package/providers/_builtin/ide/kiro/scripts/webview_read_chat.js +68 -0
  117. package/providers/_builtin/ide/kiro/scripts/webview_send_message.js +72 -0
  118. package/providers/_builtin/ide/kiro/scripts/webview_set_mode.js +15 -0
  119. package/providers/_builtin/ide/kiro/scripts/webview_set_model.js +15 -0
  120. package/providers/_builtin/ide/kiro/scripts/webview_switch_session.js +26 -0
  121. package/providers/_builtin/ide/kiro/scripts.js +62 -0
  122. package/providers/_builtin/ide/pearai/provider.json +67 -0
  123. package/providers/_builtin/ide/pearai/scripts/focus_editor.js +20 -0
  124. package/providers/_builtin/ide/pearai/scripts/list_sessions.js +38 -0
  125. package/providers/_builtin/ide/pearai/scripts/new_session.js +55 -0
  126. package/providers/_builtin/ide/pearai/scripts/open_panel.js +46 -0
  127. package/providers/_builtin/ide/pearai/scripts/resolve_action.js +54 -0
  128. package/providers/_builtin/ide/pearai/scripts/send_message.js +29 -0
  129. package/providers/_builtin/ide/pearai/scripts/webview_list_models.js +43 -0
  130. package/providers/_builtin/ide/pearai/scripts/webview_list_modes.js +35 -0
  131. package/providers/_builtin/ide/pearai/scripts/webview_list_sessions.js +62 -0
  132. package/providers/_builtin/ide/pearai/scripts/webview_new_session.js +49 -0
  133. package/providers/_builtin/ide/pearai/scripts/webview_read_chat.js +92 -0
  134. package/providers/_builtin/ide/pearai/scripts/webview_resolve_action.js +59 -0
  135. package/providers/_builtin/ide/pearai/scripts/webview_send_message.js +72 -0
  136. package/providers/_builtin/ide/pearai/scripts/webview_set_mode.js +36 -0
  137. package/providers/_builtin/ide/pearai/scripts/webview_set_model.js +36 -0
  138. package/providers/_builtin/ide/pearai/scripts/webview_switch_session.js +34 -0
  139. package/providers/_builtin/ide/pearai/scripts.js +74 -0
  140. package/providers/_builtin/ide/trae/provider.json +66 -0
  141. package/providers/_builtin/ide/trae/scripts/focus_editor.js +20 -0
  142. package/providers/_builtin/ide/trae/scripts/list_chats.js +24 -0
  143. package/providers/_builtin/ide/trae/scripts/list_models.js +39 -0
  144. package/providers/_builtin/ide/trae/scripts/list_modes.js +39 -0
  145. package/providers/_builtin/ide/trae/scripts/new_session.js +30 -0
  146. package/providers/_builtin/ide/trae/scripts/open_panel.js +44 -0
  147. package/providers/_builtin/ide/trae/scripts/read_chat.js +113 -0
  148. package/providers/_builtin/ide/trae/scripts/resolve_action.js +54 -0
  149. package/providers/_builtin/ide/trae/scripts/send_message.js +69 -0
  150. package/providers/_builtin/ide/trae/scripts/set_mode.js +15 -0
  151. package/providers/_builtin/ide/trae/scripts/set_model.js +15 -0
  152. package/providers/_builtin/ide/trae/scripts/switch_session.js +23 -0
  153. package/providers/_builtin/ide/trae/scripts.js +57 -0
  154. package/providers/_builtin/ide/vscode/provider.json +64 -0
  155. package/providers/_builtin/ide/vscode-insiders/provider.json +62 -0
  156. package/providers/_builtin/ide/vscodium/provider.json +63 -0
  157. package/providers/_builtin/ide/windsurf/provider.json +53 -0
  158. package/providers/_builtin/ide/windsurf/scripts/focus_editor.js +30 -0
  159. package/providers/_builtin/ide/windsurf/scripts/list_chats.js +117 -0
  160. package/providers/_builtin/ide/windsurf/scripts/list_models.js +39 -0
  161. package/providers/_builtin/ide/windsurf/scripts/list_modes.js +39 -0
  162. package/providers/_builtin/ide/windsurf/scripts/new_session.js +69 -0
  163. package/providers/_builtin/ide/windsurf/scripts/open_panel.js +58 -0
  164. package/providers/_builtin/ide/windsurf/scripts/read_chat.js +297 -0
  165. package/providers/_builtin/ide/windsurf/scripts/resolve_action.js +68 -0
  166. package/providers/_builtin/ide/windsurf/scripts/send_message.js +87 -0
  167. package/providers/_builtin/ide/windsurf/scripts/set_mode.js +15 -0
  168. package/providers/_builtin/ide/windsurf/scripts/set_model.js +15 -0
  169. package/providers/_builtin/ide/windsurf/scripts/switch_session.js +58 -0
  170. package/providers/_builtin/ide/windsurf/scripts.js +57 -0
  171. package/providers/_builtin/registry.json +266 -0
  172. package/providers/_builtin/validate.js +156 -0
  173. package/src/agent-stream/index.ts +6 -0
  174. package/src/agent-stream/manager.ts +286 -0
  175. package/src/agent-stream/poller.ts +154 -0
  176. package/src/agent-stream/provider-adapter.ts +138 -0
  177. package/src/agent-stream/types.ts +61 -0
  178. package/src/boot/daemon-lifecycle.ts +252 -0
  179. package/src/cdp/devtools.ts +335 -0
  180. package/src/cdp/initializer.ts +191 -0
  181. package/src/cdp/manager.ts +897 -0
  182. package/src/cdp/scanner.ts +185 -0
  183. package/src/cdp/setup.ts +150 -0
  184. package/src/cli-adapter-types.ts +25 -0
  185. package/src/cli-adapters/provider-cli-adapter.ts +448 -0
  186. package/src/commands/cdp-commands.ts +208 -0
  187. package/src/commands/chat-commands.ts +675 -0
  188. package/src/commands/cli-manager.ts +353 -0
  189. package/src/commands/handler.ts +328 -0
  190. package/src/commands/router.ts +258 -0
  191. package/src/commands/stream-commands.ts +325 -0
  192. package/src/config/chat-history.ts +211 -0
  193. package/src/config/config.ts +219 -0
  194. package/src/daemon/dev-server.ts +2378 -0
  195. package/src/daemon/scaffold-template.ts +394 -0
  196. package/src/daemon-core.ts +50 -0
  197. package/src/detection/cli-detector.ts +89 -0
  198. package/src/detection/ide-detector.ts +157 -0
  199. package/src/index.ts +103 -0
  200. package/src/installer.ts +263 -0
  201. package/src/ipc-protocol.ts +133 -0
  202. package/src/launch.ts +433 -0
  203. package/src/logging/command-log.ts +180 -0
  204. package/src/logging/logger.ts +316 -0
  205. package/src/providers/acp-provider-instance.ts +1140 -0
  206. package/src/providers/cli-provider-instance.ts +207 -0
  207. package/src/providers/contracts.ts +524 -0
  208. package/src/providers/extension-provider-instance.ts +156 -0
  209. package/src/providers/ide-provider-instance.ts +377 -0
  210. package/src/providers/index.ts +18 -0
  211. package/src/providers/provider-instance-manager.ts +182 -0
  212. package/src/providers/provider-instance.ts +112 -0
  213. package/src/providers/provider-loader.ts +1031 -0
  214. package/src/providers/status-monitor.ts +125 -0
  215. package/src/providers/version-archive.ts +266 -0
  216. package/src/status/reporter.ts +294 -0
  217. package/src/types.ts +206 -0
@@ -0,0 +1,2662 @@
1
+ /**
2
+ * ContentBlock — ACP ContentBlock union type
3
+ * Represents displayable content in messages, tool call results, etc.
4
+ */
5
+ type ContentBlock = TextBlock | ImageBlock | AudioBlock | ResourceLinkBlock | ResourceBlock;
6
+ /** Text content — ACP TextContent */
7
+ interface TextBlock {
8
+ type: 'text';
9
+ text: string;
10
+ annotations?: ContentAnnotations;
11
+ }
12
+ /** Image content — ACP ImageContent */
13
+ interface ImageBlock {
14
+ type: 'image';
15
+ data: string;
16
+ mimeType: string;
17
+ uri?: string;
18
+ annotations?: ContentAnnotations;
19
+ }
20
+ /** Audio content — ACP AudioContent */
21
+ interface AudioBlock {
22
+ type: 'audio';
23
+ data: string;
24
+ mimeType: string;
25
+ annotations?: ContentAnnotations;
26
+ }
27
+ /** Resource link (file reference) — ACP ResourceLink */
28
+ interface ResourceLinkBlock {
29
+ type: 'resource_link';
30
+ uri: string;
31
+ name: string;
32
+ title?: string;
33
+ description?: string;
34
+ mimeType?: string;
35
+ size?: number;
36
+ annotations?: ContentAnnotations;
37
+ }
38
+ /** Embedded resource (inline file) — ACP EmbeddedResource */
39
+ interface ResourceBlock {
40
+ type: 'resource';
41
+ resource: TextResourceContents | BlobResourceContents;
42
+ annotations?: ContentAnnotations;
43
+ }
44
+ interface TextResourceContents {
45
+ uri: string;
46
+ text: string;
47
+ mimeType?: string;
48
+ }
49
+ interface BlobResourceContents {
50
+ uri: string;
51
+ blob: string;
52
+ mimeType?: string;
53
+ }
54
+ interface ContentAnnotations {
55
+ audience?: ('user' | 'assistant')[];
56
+ priority?: number;
57
+ }
58
+ /** Tool call info — ACP ToolCall */
59
+ interface ToolCallInfo {
60
+ toolCallId: string;
61
+ title: string;
62
+ kind?: ToolKind;
63
+ status?: ToolCallStatus;
64
+ rawInput?: unknown;
65
+ rawOutput?: unknown;
66
+ content?: ToolCallContent[];
67
+ locations?: ToolCallLocation[];
68
+ }
69
+ type ToolKind = 'read' | 'edit' | 'delete' | 'move' | 'search' | 'execute' | 'think' | 'fetch' | 'switch_mode' | 'other';
70
+ type ToolCallStatus = 'pending' | 'in_progress' | 'completed' | 'failed';
71
+ /** Content produced by a tool call — ACP ToolCallContent */
72
+ type ToolCallContent = {
73
+ type: 'content';
74
+ content: ContentBlock;
75
+ } | {
76
+ type: 'diff';
77
+ path: string;
78
+ oldText?: string;
79
+ newText: string;
80
+ } | {
81
+ type: 'terminal';
82
+ terminalId: string;
83
+ };
84
+ interface ToolCallLocation {
85
+ path: string;
86
+ line?: number;
87
+ }
88
+ type ProviderCategory = 'cli' | 'ide' | 'extension' | 'acp';
89
+ /**
90
+ * Type of object exported by module.exports in provider.js.
91
+ *
92
+ * Each provider.js is fully independent and does not import other providers.
93
+ * Helpers (_helpers/) can be optionally used.
94
+ */
95
+ /**
96
+ * Provider-configurable CDP target filter.
97
+ * Used by DaemonCdpManager to select the correct page/tab to connect to.
98
+ * Without this, the manager uses a hardcoded default filter.
99
+ */
100
+ interface CdpTargetFilter {
101
+ /** URL must include this string (e.g. 'workbench.html') */
102
+ urlIncludes?: string;
103
+ /** URL must NOT include any of these strings */
104
+ urlExcludes?: string[];
105
+ /** Page title regex pattern for titles to EXCLUDE (e.g. 'Debug Console|Output') */
106
+ titleExcludes?: string;
107
+ }
108
+ interface ProviderModule {
109
+ /** Unique identifier (e.g. 'cline', 'cursor', 'gemini-cli') */
110
+ type: string;
111
+ /** Display name (e.g. 'Cline', 'Cursor') */
112
+ name: string;
113
+ /** Category: determines execution method */
114
+ category: ProviderCategory;
115
+ /** Alias list — allows users to invoke by alternate names (e.g. ['claude', 'claude-code']) */
116
+ aliases?: string[];
117
+ /** CDP ports [primary, secondary] (IDE category only) */
118
+ cdpPorts?: [number, number];
119
+ /** CDP target filter — controls which page/tab to connect to (IDE category only) */
120
+ targetFilter?: CdpTargetFilter;
121
+ /** CLI command (e.g. 'cursor', 'code') */
122
+ cli?: string;
123
+ /** Display icon */
124
+ icon?: string;
125
+ /** Display name (short name) */
126
+ displayName?: string;
127
+ /** Install instructions (shown when command is missing) */
128
+ install?: string;
129
+ /** Custom version detection command (e.g. 'cursor --version', 'claude -v') */
130
+ versionCommand?: string;
131
+ /** Versions tested by provider maintainer (informational) */
132
+ testedVersions?: string[];
133
+ /** Per-OS process names — used by launch.ts to detect/kill IDE processes */
134
+ processNames?: {
135
+ darwin?: string;
136
+ win32?: string[];
137
+ linux?: string[];
138
+ [key: string]: string | string[] | undefined;
139
+ };
140
+ /** Per-OS install paths — used by detector.ts to detect IDE installation */
141
+ paths?: {
142
+ darwin?: string[];
143
+ win32?: string[];
144
+ linux?: string[];
145
+ [key: string]: string[] | undefined;
146
+ };
147
+ extensionId?: string;
148
+ extensionIdPattern?: RegExp;
149
+ binary?: string;
150
+ spawn?: {
151
+ command: string;
152
+ args?: string[];
153
+ shell?: boolean;
154
+ env?: Record<string, string>;
155
+ };
156
+ patterns?: {
157
+ prompt?: RegExp[];
158
+ generating?: RegExp[];
159
+ approval?: RegExp[];
160
+ ready?: RegExp[];
161
+ };
162
+ cleanOutput?: (raw: string, lastUserInput?: string) => string;
163
+ scripts?: ProviderScripts;
164
+ vscodeCommands?: {
165
+ focusPanel?: string;
166
+ openPanel?: string;
167
+ [key: string]: string | undefined;
168
+ };
169
+ inputMethod?: 'cdp-type-and-send' | 'script';
170
+ inputSelector?: string;
171
+ /** webview iframe match text (must be contained in body) */
172
+ webviewMatchText?: string;
173
+ os?: {
174
+ [platform: string]: Partial<Pick<ProviderModule, 'scripts' | 'inputMethod' | 'inputSelector'>>;
175
+ };
176
+ /** Key: semver range string (e.g. '< 1.107.0', '>= 2.0.0') */
177
+ versions?: {
178
+ [versionRange: string]: Partial<Pick<ProviderModule, 'scripts'>> & {
179
+ /**
180
+ * Load scripts from a subdirectory instead of scripts.js root.
181
+ * Path is relative to the provider directory (e.g. 'scripts/legacy').
182
+ * The subdirectory should contain its own scripts.js or individual .js files.
183
+ */
184
+ __dir?: string;
185
+ };
186
+ };
187
+ overrides?: Array<{
188
+ when: {
189
+ os?: string;
190
+ version?: string;
191
+ };
192
+ scripts?: Partial<ProviderScripts>;
193
+ /** Load scripts from a subdirectory for this OS+version combination */
194
+ __dir?: string;
195
+ }>;
196
+ settings?: Record<string, ProviderSettingDef>;
197
+ /** Static options used when agent does not provide configOptions */
198
+ staticConfigOptions?: Array<{
199
+ category: 'model' | 'mode' | 'thought_level' | 'other';
200
+ configId: string;
201
+ defaultValue?: string;
202
+ options: Array<{
203
+ value: string;
204
+ name: string;
205
+ description?: string;
206
+ group?: string;
207
+ }>;
208
+ }>;
209
+ /** Function to convert selected config values to spawn args (applied via process restart when config/* not supported) */
210
+ spawnArgBuilder?: (config: Record<string, string>) => string[];
211
+ /** ACP agent auth methods (multiple supported — in priority order) */
212
+ auth?: AcpAuthMethod[];
213
+ }
214
+ /** ACP auth method — based on ACP official spec */
215
+ type AcpAuthMethod = AcpAuthEnvVar | AcpAuthAgent | AcpAuthTerminal;
216
+ /** Environment variable-based auth (API keys etc) */
217
+ interface AcpAuthEnvVar {
218
+ type: 'env_var';
219
+ id: string;
220
+ name: string;
221
+ vars: Array<{
222
+ name: string;
223
+ label?: string;
224
+ secret?: boolean;
225
+ optional?: boolean;
226
+ }>;
227
+ link?: string;
228
+ }
229
+ /** Agent self-auth (OAuth, browser-based etc) */
230
+ interface AcpAuthAgent {
231
+ type: 'agent';
232
+ id: string;
233
+ name: string;
234
+ description?: string;
235
+ }
236
+ /** Terminal command-based auth (runs setup command) */
237
+ interface AcpAuthTerminal {
238
+ type: 'terminal';
239
+ id: string;
240
+ name: string;
241
+ description?: string;
242
+ args?: string[];
243
+ env?: Record<string, string>;
244
+ }
245
+ /**
246
+ * CDP script functions.
247
+ * Each function takes a params object and returns a JS code string for CDP evaluate.
248
+ * The JS execution result must conform to the Output Contract.
249
+ *
250
+ * Custom scripts can be added via index signature in addition to built-in scripts.
251
+ * All scripts can receive params: Record<string, any>,
252
+ * backward compatible with legacy single-argument style (e.g. sendMessage(text)).
253
+ */
254
+ interface ProviderScripts {
255
+ readChat?: (params?: Record<string, any>) => string;
256
+ sendMessage?: (params?: Record<string, any>) => string;
257
+ listSessions?: (params?: Record<string, any>) => string;
258
+ switchSession?: (params?: Record<string, any>) => string;
259
+ newSession?: (params?: Record<string, any>) => string;
260
+ focusEditor?: (params?: Record<string, any>) => string;
261
+ openPanel?: (params?: Record<string, any>) => string;
262
+ /** List available models → { models: string[], current: string } */
263
+ listModels?: (params?: Record<string, any>) => string;
264
+ /** Change model → { success: boolean } */
265
+ setModel?: (params?: Record<string, any>) => string;
266
+ /** List available modes → { modes: string[], current: string } */
267
+ listModes?: (params?: Record<string, any>) => string;
268
+ /** Change mode → { success: boolean } */
269
+ setMode?: (params?: Record<string, any>) => string;
270
+ /** params: { action: 'approve'|'reject'|'custom', button?: string } */
271
+ resolveAction?: (params?: Record<string, any>) => string;
272
+ listNotifications?: (params?: Record<string, any>) => string;
273
+ dismissNotification?: (params?: Record<string, any>) => string;
274
+ [scriptName: string]: ((params?: Record<string, any>) => string) | undefined;
275
+ }
276
+ /**
277
+ * ProviderLoader.resolve() result: Final provider with OS/version overrides applied
278
+ */
279
+ interface ResolvedProvider extends ProviderModule {
280
+ /** OS applied during resolve */
281
+ _resolvedOs?: string;
282
+ /** Version applied during resolve */
283
+ _resolvedVersion?: string;
284
+ /** Warning when detected version is not in compatibility matrix */
285
+ _versionWarning?: string;
286
+ }
287
+ /** Setting variable definition declared by provider */
288
+ interface ProviderSettingDef {
289
+ type: 'boolean' | 'number' | 'string' | 'select';
290
+ default: any;
291
+ /** true = controllable from dashboard UI */
292
+ public: boolean;
293
+ /** UI label */
294
+ label?: string;
295
+ /** UI description */
296
+ description?: string;
297
+ /** Minimum value for number type */
298
+ min?: number;
299
+ /** Maximum value for number type */
300
+ max?: number;
301
+ /** Options for select type */
302
+ options?: string[];
303
+ }
304
+ /** Public settings schema (for dashboard transmission) */
305
+ interface ProviderSettingSchema extends ProviderSettingDef {
306
+ key: string;
307
+ }
308
+
309
+ /**
310
+ * ADHDev Daemon Core — Shared Types
311
+ *
312
+ * Shared types referenced by daemon-core, daemon-standalone, daemon-cloud, web-core.
313
+ * When modifying this file, also update interface contracts in AGENT_PROTOCOL.md.
314
+ */
315
+ interface DaemonStatus {
316
+ id: string;
317
+ type: string;
318
+ platform?: string;
319
+ hostname?: string;
320
+ nickname?: string;
321
+ cdpConnected?: boolean;
322
+ timestamp: number;
323
+ ides: IdeEntry[];
324
+ clis: CliEntry[];
325
+ acps?: AcpEntry[];
326
+ }
327
+ interface IdeEntry {
328
+ /** Format: "{daemonId}:ide:{instanceId}" */
329
+ id: string;
330
+ instanceId: string;
331
+ /** IDE type: "cursor", "windsurf", "vscode", etc. */
332
+ type: string;
333
+ name?: string;
334
+ cdpConnected?: boolean;
335
+ cdpPort?: number;
336
+ /** Current chat messages (live) */
337
+ chats?: ChatMessage[];
338
+ /** Active chat session */
339
+ activeChat?: Record<string, unknown> | null;
340
+ /** Chat history (legacy) */
341
+ chatHistory?: unknown[];
342
+ /** Agent status: 'idle' | 'working' */
343
+ agentStatus?: string;
344
+ /** Agent streams from extensions */
345
+ agentStreams?: AgentStreamEntry[];
346
+ /** Extension agents monitored via CDP */
347
+ extensions?: ExtensionInfo$1[];
348
+ /** Workspace folders */
349
+ workspaceFolders?: {
350
+ name: string;
351
+ path: string;
352
+ }[];
353
+ /** Active file path */
354
+ activeFile?: string | null;
355
+ /** Current AI model */
356
+ currentModel?: string;
357
+ /** Current AI mode/plan */
358
+ currentPlan?: string;
359
+ /** Managed agents list */
360
+ agents?: unknown[];
361
+ }
362
+ interface CliEntry {
363
+ /** Format: "{daemonId}:cli:{cliId}" */
364
+ id: string;
365
+ cliId: string;
366
+ /** CLI type: "gemini-cli", "claude-code", "codex-cli", etc. */
367
+ type: string;
368
+ name?: string;
369
+ /** Whether the CLI process is running */
370
+ isRunning?: boolean;
371
+ /** Active session info */
372
+ sessionId?: string;
373
+ }
374
+ interface AcpEntry {
375
+ /** Format: "{daemonId}:acp:{acpId}" */
376
+ id: string;
377
+ acpId: string;
378
+ /** Agent type: "gemini-acp", "cline-acp", etc. */
379
+ type: string;
380
+ name?: string;
381
+ /** Process running state */
382
+ isRunning?: boolean;
383
+ /** Error state */
384
+ errorReason?: string;
385
+ errorMessage?: string;
386
+ }
387
+ interface ChatMessage {
388
+ role: string;
389
+ /** Plain text (legacy) or rich content blocks (ACP standard) */
390
+ content: string | ContentBlock[];
391
+ kind?: string;
392
+ id?: string;
393
+ timestamp?: number;
394
+ /** Tool calls associated with this message */
395
+ toolCalls?: ToolCallInfo[];
396
+ }
397
+
398
+ interface ExtensionInfo$1 {
399
+ id: string;
400
+ type: string;
401
+ name: string;
402
+ isMonitored?: boolean;
403
+ agentStatus?: string;
404
+ }
405
+ interface CommandResult$2 {
406
+ success: boolean;
407
+ data?: any;
408
+ error?: string;
409
+ }
410
+ interface ProviderConfig {
411
+ id: string;
412
+ type: 'ide' | 'extension' | 'cli' | 'acp';
413
+ name: string;
414
+ /** CDP port detection */
415
+ cdpDetect?: {
416
+ processName?: string;
417
+ portFlag?: string;
418
+ };
419
+ /** Capabilities */
420
+ capabilities?: string[];
421
+ }
422
+ type DaemonEvent = {
423
+ type: 'status';
424
+ data: DaemonStatus;
425
+ } | {
426
+ type: 'chat_update';
427
+ data: {
428
+ ideId: string;
429
+ messages: ChatMessage[];
430
+ };
431
+ } | {
432
+ type: 'screenshot';
433
+ data: {
434
+ ideId: string;
435
+ base64: string;
436
+ };
437
+ } | {
438
+ type: 'action_log';
439
+ data: {
440
+ ideId: string;
441
+ text: string;
442
+ timestamp: number;
443
+ };
444
+ } | {
445
+ type: 'error';
446
+ data: {
447
+ message: string;
448
+ };
449
+ };
450
+ interface SystemInfo {
451
+ cpus: number;
452
+ totalMem: number;
453
+ freeMem: number;
454
+ loadavg: number[];
455
+ uptime: number;
456
+ arch: string;
457
+ }
458
+ interface DetectedIde {
459
+ id: string;
460
+ type: string;
461
+ name: string;
462
+ installed: boolean;
463
+ running: boolean;
464
+ }
465
+ interface ProviderInfo {
466
+ type: string;
467
+ icon: string;
468
+ displayName: string;
469
+ category: string;
470
+ }
471
+ /** Full status response from /api/v1/status */
472
+ interface StatusResponse {
473
+ id: string;
474
+ type: string;
475
+ platform: string;
476
+ hostname: string;
477
+ timestamp: number;
478
+ ides: IdeEntry[];
479
+ clis: CliEntry[];
480
+ cdpConnected: boolean;
481
+ detectedIdes: DetectedIde[];
482
+ availableProviders: ProviderInfo[];
483
+ system: SystemInfo;
484
+ }
485
+ /** Agent stream entry within an IDE */
486
+ interface AgentStreamEntry {
487
+ agentType: string;
488
+ agentName: string;
489
+ extensionId: string;
490
+ status: string;
491
+ messages: unknown[];
492
+ inputContent: string;
493
+ activeModal: {
494
+ message: string;
495
+ buttons: string[];
496
+ } | null;
497
+ }
498
+ /** Flattened agent entry from /api/v1/agents */
499
+ interface AgentEntry {
500
+ ideId: string;
501
+ type: string;
502
+ name: string;
503
+ status: string;
504
+ source: 'native' | 'extension';
505
+ }
506
+
507
+ /**
508
+ * DaemonCore — Core daemon orchestrator interface
509
+ *
510
+ * Both daemon-standalone and daemon-cloud use this interface via daemon-core.
511
+ * Actual implementation extracted from launcher and placed in this package.
512
+ */
513
+
514
+ interface DaemonCoreOptions {
515
+ /** Data directory for config, logs */
516
+ dataDir?: string;
517
+ /** Custom provider directories */
518
+ providerDirs?: string[];
519
+ /** Enable/disable specific detectors */
520
+ enableIdeDetection?: boolean;
521
+ enableCliDetection?: boolean;
522
+ enableAcpDetection?: boolean;
523
+ /** Status report interval (ms) */
524
+ statusInterval?: number;
525
+ }
526
+ interface IDaemonCore {
527
+ /** Initialize and start the daemon core */
528
+ start(): Promise<void>;
529
+ /** Gracefully stop the daemon */
530
+ stop(): Promise<void>;
531
+ /** Get current daemon status snapshot */
532
+ getStatus(): DaemonStatus;
533
+ /** Subscribe to status changes. Returns unsubscribe function. */
534
+ onStatusChange(callback: (status: DaemonStatus) => void): () => void;
535
+ /** Subscribe to all daemon events. Returns unsubscribe function. */
536
+ onEvent(callback: (event: DaemonEvent) => void): () => void;
537
+ /** Execute a command (send_chat, new_session, etc.) */
538
+ executeCommand(type: string, payload: any, target?: string): Promise<CommandResult$2>;
539
+ /** Get currently detected/managed IDEs */
540
+ getManagedIdes(): IdeEntry[];
541
+ /** Get currently detected/managed CLIs */
542
+ getManagedClis(): CliEntry[];
543
+ /** Get currently detected/managed ACP agents */
544
+ getManagedAcps(): AcpEntry[];
545
+ }
546
+
547
+ /**
548
+ * ADHDev Launcher — Configuration
549
+ *
550
+ * Manages launcher config, server connection tokens, and user preferences.
551
+ */
552
+ interface ADHDevConfig {
553
+ serverUrl: string;
554
+ apiToken: string | null;
555
+ connectionToken: string | null;
556
+ selectedIde: string | null;
557
+ configuredIdes: string[];
558
+ installedExtensions: string[];
559
+ autoConnect: boolean;
560
+ notifications: boolean;
561
+ userEmail: string | null;
562
+ userName: string | null;
563
+ setupCompleted: boolean;
564
+ setupDate: string | null;
565
+ configuredCLIs: string[];
566
+ enabledIdes: string[];
567
+ recentCliWorkspaces: string[];
568
+ machineNickname: string | null;
569
+ cliHistory: CliHistoryEntry[];
570
+ providerSettings: Record<string, Record<string, any>>;
571
+ ideSettings: Record<string, {
572
+ extensions?: Record<string, {
573
+ enabled: boolean;
574
+ }>;
575
+ }>;
576
+ }
577
+ interface CliHistoryEntry {
578
+ cliType: string;
579
+ dir: string;
580
+ cliArgs?: string[];
581
+ timestamp: number;
582
+ label?: string;
583
+ }
584
+ /**
585
+ * Load configuration from disk
586
+ */
587
+ declare function loadConfig(): ADHDevConfig;
588
+ /**
589
+ * Save configuration to disk
590
+ */
591
+ declare function saveConfig(config: ADHDevConfig): void;
592
+ /**
593
+ * Update specific config fields
594
+ */
595
+ declare function updateConfig(updates: Partial<ADHDevConfig>): ADHDevConfig;
596
+ /**
597
+ * Mark setup as completed
598
+ */
599
+ declare function markSetupComplete(ideId: string | string[], extensions: string[]): ADHDevConfig;
600
+ /**
601
+ * Check if setup has been completed before
602
+ */
603
+ declare function isSetupComplete(): boolean;
604
+ /**
605
+ * Reset configuration
606
+ */
607
+ declare function resetConfig(): void;
608
+ /**
609
+ * Add CLI launch to history (max 20, dedup by cliType+dir+args)
610
+ */
611
+ declare function addCliHistory(entry: Omit<CliHistoryEntry, 'timestamp'>): void;
612
+
613
+ /**
614
+ * ADHDev — IDE Detector (canonical implementation)
615
+ *
616
+ * Detects installed IDEs on the user's local machine.
617
+ * Supports macOS, Windows, and Linux.
618
+ *
619
+ * Migrated from @adhdev/core — this is now the single source of truth.
620
+ */
621
+ interface IDEInfo {
622
+ id: string;
623
+ name: string;
624
+ displayName: string;
625
+ installed: boolean;
626
+ path: string | null;
627
+ cliCommand: string | null;
628
+ version: string | null;
629
+ icon: string;
630
+ extensionSupport: 'full' | 'partial' | 'none';
631
+ notes?: string;
632
+ }
633
+ declare function detectIDEs(): Promise<IDEInfo[]>;
634
+
635
+ /**
636
+ * Provider Version Detection & Archiving
637
+ *
638
+ * Detects installed versions for all provider categories (IDE, CLI, ACP, Extension).
639
+ * Archives version history to ~/.adhdev/version-history.json for compatibility tracking.
640
+ *
641
+ * Usage:
642
+ * const archive = new VersionArchive();
643
+ * const results = await detectAllVersions(providerLoader, archive);
644
+ */
645
+
646
+ interface ProviderVersionInfo {
647
+ type: string;
648
+ name: string;
649
+ category: string;
650
+ installed: boolean;
651
+ version: string | null;
652
+ path: string | null;
653
+ binary: string | null;
654
+ detectedAt: string;
655
+ /**
656
+ * Set when the detected version is NOT listed in provider.json testedVersions.
657
+ * Means scripts may not work correctly with this version.
658
+ */
659
+ warning?: string;
660
+ }
661
+ interface VersionHistoryEntry {
662
+ version: string;
663
+ detectedAt: string;
664
+ os: string;
665
+ }
666
+ interface VersionHistory {
667
+ [providerType: string]: VersionHistoryEntry[];
668
+ }
669
+ declare class VersionArchive {
670
+ private history;
671
+ constructor();
672
+ private load;
673
+ /** Record a detected version (deduplicates same version) */
674
+ record(type: string, version: string): void;
675
+ /** Get version history for a provider */
676
+ getHistory(type: string): VersionHistoryEntry[];
677
+ /** Get latest known version for a provider */
678
+ getLatest(type: string): string | null;
679
+ /** Get full archive */
680
+ getAll(): VersionHistory;
681
+ private save;
682
+ }
683
+ /**
684
+ * Detect versions for all loaded providers
685
+ */
686
+ declare function detectAllVersions(loader: ProviderLoader, archive?: VersionArchive): Promise<ProviderVersionInfo[]>;
687
+
688
+ /**
689
+ * ProviderLoader — Provider discovery + OS/version override resolution
690
+ *
691
+ * Role:
692
+ * 1. Load provider.js from _builtin/ directory
693
+ * 2. Load user custom from ~/.adhdev/providers/ (overrides)
694
+ * 3. Apply OS/version overrides (process.platform + detected IDE version)
695
+ * 4. Hot-reload support (fs.watch)
696
+ *
697
+ * Design principles:
698
+ * - Load JS files via require() (CJS compatible)
699
+ * - User custom can override builtin
700
+ * - provider.js files are independent, so load order doesn't matter
701
+ */
702
+
703
+ declare class ProviderLoader {
704
+ private providers;
705
+ private builtinDirs;
706
+ private userDir;
707
+ private upstreamDir;
708
+ private watchers;
709
+ private logFn;
710
+ private versionArchive;
711
+ private scriptsCache;
712
+ /** Inject VersionArchive so resolve() can auto-detect installed versions */
713
+ setVersionArchive(archive: VersionArchive): void;
714
+ private static readonly GITHUB_TARBALL_URL;
715
+ private static readonly META_FILE;
716
+ constructor(options?: {
717
+ builtinDir?: string | string[];
718
+ userDir?: string;
719
+ logFn?: (msg: string) => void;
720
+ });
721
+ private log;
722
+ /**
723
+ * Load all providers (3-tier priority)
724
+ * 1. _builtin/ (bundled fallback, or multiple array dirs)
725
+ * 2. .upstream/ (GitHub auto-download)
726
+ * 3. User custom (~/.adhdev/providers/ excluding _upstream)
727
+ * Later loads override earlier ones, so user custom always wins.
728
+ */
729
+ loadAll(): void;
730
+ /**
731
+ * Get raw provider metadata by type (NO scripts loaded).
732
+ * Use resolve() when you need scripts (readChat, listModels, etc).
733
+ * @deprecated Use getMeta() for metadata or resolve() for scripts.
734
+ */
735
+ get(type: string): ProviderModule | undefined;
736
+ /**
737
+ * Get raw provider metadata by type (NO scripts loaded).
738
+ * Safe for: category checks, icon, displayName, targetFilter, cdpPorts.
739
+ * NOT safe for: script execution (readChat, listModels, sendMessage).
740
+ * Use resolve() when scripts are needed.
741
+ */
742
+ getMeta(type: string): ProviderModule | undefined;
743
+ /**
744
+ * Resolve provider type by alias
745
+ * 'claude' → 'claude-cli', 'codex' → 'codex-cli' etc
746
+ * Returns input as-is if no match found.
747
+ */
748
+ resolveAlias(input: string): string;
749
+ /**
750
+ * Get provider with alias resolution (get + alias fallback)
751
+ */
752
+ getByAlias(input: string): ProviderModule | undefined;
753
+ /**
754
+ * Build CLI/ACP detection list (replaces cli-detector)
755
+ * Dynamically generated from provider.js spawn.command.
756
+ */
757
+ getCliDetectionList(): {
758
+ id: string;
759
+ displayName: string;
760
+ icon: string;
761
+ command: string;
762
+ category: string;
763
+ }[];
764
+ /**
765
+ * List providers by category
766
+ */
767
+ getByCategory(cat: ProviderCategory): ProviderModule[];
768
+ /**
769
+ * Extension Extension providers with extensionIdPattern only
770
+ * (used by discoverAgentWebviews in daemon-cdp.ts)
771
+ */
772
+ getExtensionProviders(): ProviderModule[];
773
+ /**
774
+ * All loaded providers
775
+ */
776
+ getAll(): ProviderModule[];
777
+ /**
778
+ * Check if a provider is enabled (per-IDE)
779
+ * Checks ideSettings[ideType].extensions[type].enabled.
780
+ * Default false (disabled) — user must explicitly enable.
781
+ * Always returns true when called without ideType.
782
+ */
783
+ isEnabled(type: string, ideType?: string): boolean;
784
+ /**
785
+ * Save IDE extension enabled setting
786
+ */
787
+ setIdeExtensionEnabled(ideType: string, extensionType: string, enabled: boolean): boolean;
788
+ /**
789
+ * Return only enabled providers by category (per-IDE)
790
+ */
791
+ getEnabledByCategory(cat: ProviderCategory, ideType?: string): ProviderModule[];
792
+ /**
793
+ * Extension Enabled extension providers with extensionIdPattern only (per-IDE)
794
+ */
795
+ getEnabledExtensionProviders(ideType?: string): ProviderModule[];
796
+ /**
797
+ * Return CDP port map for IDE providers
798
+ * Used by launch.ts, adhdev-daemon.ts
799
+ */
800
+ getCdpPortMap(): Record<string, [number, number]>;
801
+ /**
802
+ * Return IDE process name map (macOS)
803
+ */
804
+ getMacAppIdentifiers(): Record<string, string>;
805
+ /**
806
+ * Return IDE process name map (Windows)
807
+ */
808
+ getWinProcessNames(): Record<string, string[]>;
809
+ /**
810
+ * Available IDE types (only those with cdpPorts)
811
+ */
812
+ getAvailableIdeTypes(): string[];
813
+ /**
814
+ * Register IDE providers to core/detector registry
815
+ * → Enables detectIDEs() to detect provider.js-based IDEs
816
+ */
817
+ registerToDetector(): number;
818
+ /**
819
+ * Return final provider with OS/version overrides applied.
820
+ *
821
+ * Script resolution order:
822
+ * 1. compatibility array (new format — preferred)
823
+ * Provider.json defines: "compatibility": [{ "ideVersion": ">=1.107.0", "scriptDir": "scripts/1.107" }]
824
+ * First matching range wins. Fallback: defaultScriptDir.
825
+ * 2. versions field (legacy format — backward compat)
826
+ * "versions": { "< 1.107.0": { "__dir": "scripts/legacy" } }
827
+ * 3. Root scripts.js (original format — no versioning)
828
+ *
829
+ * Version source: context.version → VersionArchive → undefined
830
+ */
831
+ resolve(type: string, context?: {
832
+ os?: string;
833
+ version?: string;
834
+ }): ResolvedProvider | undefined;
835
+ /**
836
+ * Load scripts from a scriptDir within a provider directory.
837
+ * Tries scripts.js first, then individual .js files.
838
+ */
839
+ private loadScriptsFromDir;
840
+ /**
841
+ * Hot-reload: start watching for file changes
842
+ */
843
+ watch(): void;
844
+ /**
845
+ * Stop hot-reload
846
+ */
847
+ stopWatch(): void;
848
+ /**
849
+ * Full reload
850
+ */
851
+ reload(): void;
852
+ /**
853
+ * Download latest providers tarball from GitHub → extract to .upstream/
854
+ * - ETag-based change detection (skip if unchanged)
855
+ * - Never touches user custom files in ~/.adhdev/providers/
856
+ * - Runs in background; existing providers are kept on failure
857
+ *
858
+ * @returns Whether an update occurred
859
+ */
860
+ fetchLatest(): Promise<{
861
+ updated: boolean;
862
+ error?: string;
863
+ }>;
864
+ /** HTTP(S) file download (follows redirects) */
865
+ private downloadFile;
866
+ /** Recursive directory copy */
867
+ private copyDirRecursive;
868
+ /** .meta.json save */
869
+ private writeMeta;
870
+ /** Count provider files (provider.js or provider.json) */
871
+ private countProviders;
872
+ /**
873
+ * Get public settings schema for a provider (for dashboard UI rendering)
874
+ */
875
+ getPublicSettings(type: string): ProviderSettingSchema[];
876
+ /**
877
+ * Get public settings schema for all providers
878
+ */
879
+ getAllPublicSettings(): Record<string, ProviderSettingSchema[]>;
880
+ /**
881
+ * Resolved setting value for a provider (default + user override)
882
+ */
883
+ getSettingValue(type: string, key: string): any;
884
+ /**
885
+ * All resolved settings for a provider (default + user override)
886
+ */
887
+ getSettings(type: string): Record<string, any>;
888
+ /**
889
+ * Save provider setting value (writes to config.json)
890
+ */
891
+ setSetting(type: string, key: string, value: any): boolean;
892
+ /**
893
+ * Find the on-disk directory for a provider by type.
894
+ * Checks builtinDir, upstreamDir, userDir in order.
895
+ */
896
+ private findProviderDir;
897
+ /**
898
+ * Build a scripts function map from individual .js files in a directory.
899
+ * Each file is wrapped as: (params?) => fs.readFileSync(filePath, 'utf-8')
900
+ * (template substitution is NOT applied here — scripts.js handles that)
901
+ */
902
+ private buildScriptWrappersFromDir;
903
+ /**
904
+ * Recursively scan directory to load provider files
905
+ * Supports two formats:
906
+ * 1. provider.json (metadata) + scripts.js (optional CDP scripts)
907
+ * 2. provider.js (legacy — everything in one file)
908
+ * Structure: dir/category/agent-name/provider.{json,js}
909
+ */
910
+ private loadDir;
911
+ /**
912
+ * Simple semver range matching
913
+ * Supported formats: '>=4.0.0', '<3.0.0', '>=2.1.0'
914
+ */
915
+ private matchesVersion;
916
+ private compareVersions;
917
+ }
918
+
919
+ /**
920
+ * CLI AI Agent Detector
921
+ *
922
+ * Dynamic CLI detection based on Provider.
923
+ * Reads spawn.command from cli/acp categories via ProviderLoader to check installation.
924
+ *
925
+ * Uses parallel execution for fast detection across many providers.
926
+ */
927
+
928
+ interface CLIInfo {
929
+ id: string;
930
+ displayName: string;
931
+ icon: string;
932
+ command: string;
933
+ installed: boolean;
934
+ version?: string;
935
+ path?: string;
936
+ category?: string;
937
+ }
938
+ /**
939
+ * Detect all CLI/ACP agents (parallel)
940
+ * @param providerLoader ProviderLoader instance (dynamic list creation)
941
+ */
942
+ declare function detectCLIs(providerLoader?: ProviderLoader): Promise<CLIInfo[]>;
943
+
944
+ /**
945
+ * CDP Manager for ADHDev Daemon
946
+ *
947
+ * Ported cdp.ts from Extension for Daemon use.
948
+ * vscode dependencies removed — works in pure Node.js environment.
949
+ *
950
+ * Connects to IDE CDP port (9222, 9333 etc) to:
951
+ * - Execute JS via Runtime.evaluate
952
+ * - Agent webview iframe search & session connection
953
+ * - DOM query
954
+ */
955
+
956
+ interface CdpTarget {
957
+ id: string;
958
+ type: string;
959
+ title: string;
960
+ url: string;
961
+ webSocketDebuggerUrl: string;
962
+ }
963
+ interface AgentWebviewTarget {
964
+ targetId: string;
965
+ extensionId: string;
966
+ agentType: string;
967
+ url: string;
968
+ }
969
+ declare class DaemonCdpManager {
970
+ private ws;
971
+ private browserWs;
972
+ private browserMsgId;
973
+ private browserPending;
974
+ private msgId;
975
+ private pending;
976
+ private port;
977
+ private _connected;
978
+ private _browserConnected;
979
+ private targetUrl;
980
+ private reconnectTimer;
981
+ private contexts;
982
+ private connectPromise;
983
+ private failureCount;
984
+ private readonly MAX_FAILURES;
985
+ private agentSessions;
986
+ private logFn;
987
+ private extensionProviders;
988
+ private _lastDiscoverSig;
989
+ private _targetId;
990
+ private _pageTitle;
991
+ private _targetFilter;
992
+ constructor(port?: number, logFn?: (msg: string) => void, targetId?: string, targetFilter?: CdpTargetFilter);
993
+ /** Set target filter (can be updated after construction) */
994
+ setTargetFilter(filter: CdpTargetFilter): void;
995
+ /**
996
+ * Check if a page title should be excluded (non-main page).
997
+ * Uses provider-configured titleExcludes, falls back to default pattern.
998
+ */
999
+ private isNonMainTitle;
1000
+ /**
1001
+ * Check if a page URL matches the main window criteria.
1002
+ * Uses provider-configured urlIncludes/urlExcludes.
1003
+ */
1004
+ private isMainPageUrl;
1005
+ /** Connected page title (includes workspace name) */
1006
+ get pageTitle(): string;
1007
+ /**
1008
+ * Query all workbench pages on port (static)
1009
+ * Returns multiple entries if multiple IDE windows are open on same port
1010
+ */
1011
+ static listAllTargets(port: number): Promise<CdpTarget[]>;
1012
+ setPort(port: number): void;
1013
+ getPort(): number;
1014
+ private log;
1015
+ connect(): Promise<boolean>;
1016
+ private doConnect;
1017
+ private findTargetOnPort;
1018
+ private findTarget;
1019
+ setExtensionProviders(providers: {
1020
+ agentType: string;
1021
+ extensionId: string;
1022
+ extensionIdPattern: RegExp;
1023
+ }[]): void;
1024
+ private connectToTarget;
1025
+ /** Browser-level CDP connection — needed for Target discovery */
1026
+ private connectBrowserWs;
1027
+ private getBrowserWsUrl;
1028
+ private sendBrowser;
1029
+ private scheduleReconnect;
1030
+ disconnect(): void;
1031
+ get isConnected(): boolean;
1032
+ private sendInternal;
1033
+ send(method: string, params?: Record<string, unknown>, timeoutMs?: number): Promise<any>;
1034
+ sendCdpCommand(method: string, params?: Record<string, unknown>): Promise<any>;
1035
+ evaluate(expression: string, timeoutMs?: number): Promise<unknown>;
1036
+ querySelector(selector: string): Promise<string | null>;
1037
+ /**
1038
+ * Input text via CDP protocol then send Enter
1039
+ * Used for editors where execCommand does not work (e.g. Lexical).
1040
+ *
1041
+ * 1. Find editor by selector, focus + click
1042
+ * 2. Insert text via Input.insertText
1043
+ * 3. Send Enter via Input.dispatchKeyEvent
1044
+ */
1045
+ typeAndSend(selector: string, text: string): Promise<boolean>;
1046
+ /**
1047
+ * Coordinate-based typeAndSend — for input fields inside webview iframe
1048
+ * Receives coordinates directly instead of selector for click+input+Enter
1049
+ */
1050
+ typeAndSendAt(x: number, y: number, text: string): Promise<boolean>;
1051
+ /**
1052
+ * Evaluate JS from inside Webview iframe
1053
+ * Kiro, PearAI etc Used for IDEs where chat UI is inside webview iframe.
1054
+ *
1055
+ * 1. Query Target.getTargets via browser WS → find vscode-webview iframes
1056
+ * 2. Target.attachToTarget → session acquire
1057
+ * 3. Page.getFrameTree → nested iframe find
1058
+ * 4. Page.createIsolatedWorld → contextId acquire
1059
+ * 5. Runtime.evaluate → result return
1060
+ *
1061
+ * @param expression JS expression to execute
1062
+ * @param matchFn webview iframe URL match function (optional, all webview attempt)
1063
+ * @returns evaluate result or null
1064
+ */
1065
+ evaluateInWebviewFrame(expression: string, matchFn?: (bodyPreview: string) => boolean): Promise<string | null>;
1066
+ discoverAgentWebviews(): Promise<AgentWebviewTarget[]>;
1067
+ attachToAgent(target: AgentWebviewTarget): Promise<string | null>;
1068
+ evaluateInSession(sessionId: string, expression: string, timeoutMs?: number): Promise<unknown>;
1069
+ detachAgent(sessionId: string): Promise<void>;
1070
+ detachAllAgents(): Promise<void>;
1071
+ getAgentSessions(): Map<string, AgentWebviewTarget>;
1072
+ captureScreenshot(opts?: {
1073
+ quality?: number;
1074
+ }): Promise<Buffer | null>;
1075
+ }
1076
+
1077
+ /**
1078
+ * ProviderInstance — Provider runtime lifecycle
1079
+ *
1080
+ * provider.js = static config/scripts
1081
+ * ProviderInstance = runtime status management + lifecycle
1082
+ *
1083
+ * Daemon only collects via ProviderInstance.getState(),
1084
+ * Each Instance manages its own status.
1085
+ */
1086
+ interface ProviderState {
1087
+ /** Provider type (e.g. 'gemini-cli', 'cursor', 'cline') */
1088
+ type: string;
1089
+ /** Provider Display name */
1090
+ name: string;
1091
+ /** category */
1092
+ category: 'cli' | 'ide' | 'extension' | 'acp';
1093
+ /** current status */
1094
+ status: 'idle' | 'generating' | 'waiting_approval' | 'error' | 'stopped' | 'starting';
1095
+ /** CLI mode: terminal = PTY stream, chat = parsed conversation */
1096
+ mode?: 'terminal' | 'chat';
1097
+ /** chat data */
1098
+ activeChat: {
1099
+ id: string;
1100
+ title: string;
1101
+ status: string;
1102
+ messages: {
1103
+ role: string;
1104
+ content: string;
1105
+ timestamp?: number;
1106
+ }[];
1107
+ activeModal: {
1108
+ message: string;
1109
+ buttons: string[];
1110
+ } | null;
1111
+ inputContent?: string;
1112
+ } | null;
1113
+ /** IDE/Extension -only */
1114
+ workspaceFolders?: {
1115
+ name: string;
1116
+ path: string;
1117
+ }[];
1118
+ activeFile?: string | null;
1119
+ agentStreams?: any[];
1120
+ cdpConnected?: boolean;
1121
+ /** IDE child Extension Instance status */
1122
+ extensions?: ProviderState[];
1123
+ /** CLI -only */
1124
+ workingDir?: string;
1125
+ /** Runtime info (real-time detection from IDE/CLI) */
1126
+ currentModel?: string;
1127
+ currentPlan?: string;
1128
+ currentAutoApprove?: string;
1129
+ /** meta */
1130
+ instanceId: string;
1131
+ lastUpdated: number;
1132
+ settings: Record<string, any>;
1133
+ /** Event queue (cleared after daemon collects) */
1134
+ pendingEvents: ProviderEvent[];
1135
+ }
1136
+ interface ProviderEvent {
1137
+ event: string;
1138
+ timestamp: number;
1139
+ [key: string]: any;
1140
+ }
1141
+ interface InstanceContext {
1142
+ /** CDP connection (IDE/Extension) */
1143
+ cdp?: {
1144
+ isConnected: boolean;
1145
+ evaluate(script: string, timeout?: number): Promise<unknown>;
1146
+ evaluateInWebviewFrame?(expression: string, matchFn?: (bodyPreview: string) => boolean): Promise<string | null>;
1147
+ discoverAgentWebviews?(): Promise<any[]>;
1148
+ };
1149
+ /** Server log transmit */
1150
+ serverConn?: {
1151
+ sendMessage(type: string, data: any): void;
1152
+ };
1153
+ /** P2P PTY output transmit */
1154
+ onPtyData?: (data: string) => void;
1155
+ /** Provider configvalue (resolved) */
1156
+ settings: Record<string, any>;
1157
+ }
1158
+ interface ProviderInstance {
1159
+ /** Provider type */
1160
+ readonly type: string;
1161
+ /** Provider category */
1162
+ readonly category: 'cli' | 'ide' | 'extension' | 'acp';
1163
+ /** initialize */
1164
+ init(context: InstanceContext): Promise<void>;
1165
+ /** Tick — periodic status refresh (IDE: readChat, Extension: stream collection) */
1166
+ onTick(): Promise<void>;
1167
+ /** Return current status */
1168
+ getState(): ProviderState;
1169
+ /** Receive event (external → Instance) */
1170
+ onEvent(event: string, data?: any): void;
1171
+ /** Update settings at runtime (called when user changes settings from dashboard) */
1172
+ updateSettings?(newSettings: Record<string, any>): void;
1173
+ /** cleanup */
1174
+ dispose(): void;
1175
+ }
1176
+
1177
+ /**
1178
+ * ProviderInstanceManager — lifecycle management for all ProviderInstances
1179
+ *
1180
+ * Role:
1181
+ * 1. Instance create/delete
1182
+ * 2. Tick engine (periodic onTick calls)
1183
+ * 3. Collect overall state
1184
+ * 4. Event collection and propagation
1185
+ */
1186
+
1187
+ declare class ProviderInstanceManager {
1188
+ private instances;
1189
+ private tickTimer;
1190
+ private tickInterval;
1191
+ private eventListeners;
1192
+ /**
1193
+ * Instance add and initialize
1194
+ */
1195
+ addInstance(id: string, instance: ProviderInstance, context: InstanceContext): Promise<void>;
1196
+ /**
1197
+ * Instance remove
1198
+ */
1199
+ removeInstance(id: string): void;
1200
+ /**
1201
+ * Import by Instance ID
1202
+ */
1203
+ getInstance(id: string): ProviderInstance | undefined;
1204
+ /**
1205
+ * Per-category Instance list
1206
+ */
1207
+ getByCategory(category: 'cli' | 'ide' | 'extension' | 'acp'): ProviderInstance[];
1208
+ /**
1209
+ * All Instance count
1210
+ */
1211
+ get size(): number;
1212
+ /**
1213
+ * all Instance's current status collect
1214
+ * + Propagate pending events to event listeners
1215
+ */
1216
+ collectAllStates(): ProviderState[];
1217
+ /**
1218
+ * Per-category status collect
1219
+ */
1220
+ collectStatesByCategory(category: 'cli' | 'ide' | 'extension' | 'acp'): ProviderState[];
1221
+ /**
1222
+ * Start tick — periodically call all Instance.onTick() call
1223
+ */
1224
+ startTicking(intervalMs?: number): void;
1225
+ /**
1226
+ * Stop tick
1227
+ */
1228
+ stopTicking(): void;
1229
+ /**
1230
+ * Register event listener (used for daemon status_event transmission)
1231
+ */
1232
+ onEvent(listener: (event: ProviderEvent & {
1233
+ providerType: string;
1234
+ }) => void): void;
1235
+ /**
1236
+ * Forward event to specific Instance
1237
+ */
1238
+ sendEvent(id: string, event: string, data?: any): void;
1239
+ /**
1240
+ * Broadcast event to all Instances
1241
+ */
1242
+ broadcast(event: string, data?: any): void;
1243
+ /**
1244
+ * Update settings for all instances of a given provider type.
1245
+ * Called when user changes settings from dashboard.
1246
+ */
1247
+ updateInstanceSettings(providerType: string, settings: Record<string, any>): number;
1248
+ /**
1249
+ * All terminate
1250
+ */
1251
+ disposeAll(): void;
1252
+ }
1253
+
1254
+ /**
1255
+ * Agent Stream Types — ported for Daemon (identical to original)
1256
+ *
1257
+ * Agent stream types.
1258
+ * No vscode dependency — can be used as-is.
1259
+ */
1260
+ /** Agent chat message */
1261
+ interface AgentChatMessage {
1262
+ role: 'user' | 'assistant' | 'system';
1263
+ content: string;
1264
+ timestamp?: number;
1265
+ }
1266
+ /** Agent chat history item */
1267
+ interface AgentChatListItem {
1268
+ title: string;
1269
+ id: string;
1270
+ status?: string;
1271
+ time?: string;
1272
+ cost?: string;
1273
+ }
1274
+ /** Agent stream status */
1275
+ interface AgentStreamState {
1276
+ agentType: string;
1277
+ agentName: string;
1278
+ extensionId: string;
1279
+ status: 'idle' | 'streaming' | 'waiting_approval' | 'error' | 'disconnected' | 'panel_hidden' | 'not_monitored';
1280
+ messages: AgentChatMessage[];
1281
+ inputContent: string;
1282
+ model?: string;
1283
+ activeModal?: {
1284
+ message: string;
1285
+ buttons: string[];
1286
+ };
1287
+ }
1288
+ /** Agent stream adapter interface */
1289
+ interface IAgentStreamAdapter {
1290
+ readonly agentType: string;
1291
+ readonly agentName: string;
1292
+ readonly extensionId: string;
1293
+ readonly extensionIdPattern: RegExp;
1294
+ readChat(evaluate: AgentEvaluateFn): Promise<AgentStreamState>;
1295
+ sendMessage(evaluate: AgentEvaluateFn, text: string): Promise<void>;
1296
+ resolveAction(evaluate: AgentEvaluateFn, action: string, button?: string): Promise<boolean>;
1297
+ newSession(evaluate: AgentEvaluateFn): Promise<void>;
1298
+ listChats?(evaluate: AgentEvaluateFn): Promise<AgentChatListItem[]>;
1299
+ switchSession?(evaluate: AgentEvaluateFn, sessionId: string): Promise<boolean>;
1300
+ focusEditor?(evaluate: AgentEvaluateFn): Promise<void>;
1301
+ setProvider?(provider: any): void;
1302
+ }
1303
+ type AgentEvaluateFn = (expression: string, timeoutMs?: number) => Promise<unknown>;
1304
+
1305
+ /**
1306
+ * DaemonAgentStreamManager — manage agent streams (ported for Daemon)
1307
+ *
1308
+ * Agent stream manager for extension data collection.
1309
+ * All vscode dependencies removed — pure Node.js environment.
1310
+ *
1311
+ * Panel focus is delegated to Extension via IPC.
1312
+ * CDP session management uses DaemonCdpManager directly.
1313
+ */
1314
+
1315
+ interface ManagedAgent {
1316
+ adapter: IAgentStreamAdapter;
1317
+ sessionId: string;
1318
+ target: AgentWebviewTarget;
1319
+ lastState: AgentStreamState | null;
1320
+ lastError: string | null;
1321
+ lastHiddenCheckTime: number;
1322
+ }
1323
+ declare class DaemonAgentStreamManager {
1324
+ private allAdapters;
1325
+ private managed;
1326
+ private enabled;
1327
+ private logFn;
1328
+ private lastDiscoveryTime;
1329
+ private discoveryIntervalMs;
1330
+ private _activeAgentType;
1331
+ constructor(logFn?: (msg: string) => void, providerLoader?: ProviderLoader);
1332
+ setEnabled(enabled: boolean): void;
1333
+ get isEnabled(): boolean;
1334
+ get activeAgentType(): string | null;
1335
+ /** Panel focus based on provider.js focusPanel or extensionId (currently no-op) */
1336
+ ensureAgentPanelOpen(agentType: string, targetIdeType?: string): Promise<void>;
1337
+ switchActiveAgent(cdp: DaemonCdpManager, agentType: string | null): Promise<void>;
1338
+ /** Agent webview discovery + session connection */
1339
+ syncAgentSessions(cdp: DaemonCdpManager): Promise<void>;
1340
+ /** Collect active agent status */
1341
+ collectAgentStreams(cdp: DaemonCdpManager): Promise<AgentStreamState[]>;
1342
+ sendToAgent(cdp: DaemonCdpManager, agentType: string, text: string, targetIdeType?: string): Promise<boolean>;
1343
+ resolveAgentAction(cdp: DaemonCdpManager, agentType: string, action: 'approve' | 'reject', targetIdeType?: string): Promise<boolean>;
1344
+ newAgentSession(cdp: DaemonCdpManager, agentType: string, targetIdeType?: string): Promise<boolean>;
1345
+ listAgentChats(cdp: DaemonCdpManager, agentType: string): Promise<AgentChatListItem[]>;
1346
+ switchAgentSession(cdp: DaemonCdpManager, agentType: string, sessionId: string): Promise<boolean>;
1347
+ focusAgentEditor(cdp: DaemonCdpManager, agentType: string): Promise<boolean>;
1348
+ getConnectedAgents(): string[];
1349
+ getManagedAgent(agentType: string): ManagedAgent | undefined;
1350
+ dispose(cdp: DaemonCdpManager): Promise<void>;
1351
+ }
1352
+
1353
+ /**
1354
+ * AgentStreamPoller — Periodic agent stream polling + extension dynamic management
1355
+ *
1356
+ * Extracted from cloud daemon's startAgentStreamPolling() logic.
1357
+ * Used by both daemon-cloud and daemon-standalone.
1358
+ *
1359
+ * Responsibilities:
1360
+ * 1. Refresh extension providers in CDP managers (config changes take effect immediately)
1361
+ * 2. Dynamically add/remove IDE instance extensions based on enabled state
1362
+ * 3. Sync agent sessions + collect agent streams
1363
+ * 4. Auto-discover agents in connected IDEs
1364
+ */
1365
+
1366
+ interface AgentStreamPollerDeps {
1367
+ agentStreamManager: DaemonAgentStreamManager;
1368
+ providerLoader: ProviderLoader;
1369
+ instanceManager: ProviderInstanceManager;
1370
+ cdpManagers: Map<string, DaemonCdpManager>;
1371
+ /** Callback when agent streams are updated */
1372
+ onStreamsUpdated?: (ideType: string, streams: AgentStreamState[]) => void;
1373
+ }
1374
+ declare class AgentStreamPoller {
1375
+ private deps;
1376
+ private _activeIdeType;
1377
+ private timer;
1378
+ constructor(deps: AgentStreamPollerDeps);
1379
+ /** Currently active IDE type for agent streaming */
1380
+ get activeIde(): string | null;
1381
+ /** Reset active IDE tracking (e.g., when IDE is stopped) */
1382
+ resetActiveIde(ideType: string): void;
1383
+ /** Start polling (idempotent — ignored if already started) */
1384
+ start(intervalMs?: number): void;
1385
+ /** Stop polling */
1386
+ stop(): void;
1387
+ /** Single poll tick — can also be called manually */
1388
+ private tick;
1389
+ }
1390
+
1391
+ /**
1392
+ * Chat History Persistence — Persist completed chat messages to local disk
1393
+ *
1394
+ * Design:
1395
+ * - ~/.adhdev/history/{agentType}/YYYY-MM-DD.jsonl
1396
+ * - JSONL format (one line = one message, append-friendly)
1397
+ * - Track only new messages (hash comparison with previous)
1398
+ * - Auto-rotation (delete files older than 30 days)
1399
+ * - Async/non-blocking (no impact on chat collection)
1400
+ */
1401
+ interface HistoryMessage {
1402
+ ts: string;
1403
+ receivedAt: number;
1404
+ role: 'user' | 'assistant' | 'system';
1405
+ content: string;
1406
+ agent: string;
1407
+ instanceId?: string;
1408
+ sessionTitle?: string;
1409
+ }
1410
+ declare class ChatHistoryWriter {
1411
+ /** Last seen message count per agent (deduplication) */
1412
+ private lastSeenCounts;
1413
+ /** Last seen message hash per agent (deduplication) */
1414
+ private lastSeenHashes;
1415
+ private rotated;
1416
+ /**
1417
+ * Append new messages to history
1418
+ *
1419
+ * @param agentType agent type (e.g. 'antigravity', 'cursor')
1420
+ * @param messages Message array received from readChat
1421
+ * @param sessionTitle Current session title
1422
+ * @param instanceId IDE instance UUID (distinguishes windows of the same agent)
1423
+ */
1424
+ appendNewMessages(agentType: string, messages: Array<{
1425
+ role: string;
1426
+ content: string;
1427
+ receivedAt?: number;
1428
+ }>, sessionTitle?: string, instanceId?: string): void;
1429
+ /** Called when agent session is explicitly changed */
1430
+ onSessionChange(agentType: string): void;
1431
+ /** Delete history files older than 30 days */
1432
+ private rotateOldFiles;
1433
+ /** Allow only filename-safe characters */
1434
+ private sanitize;
1435
+ }
1436
+ /**
1437
+ * Read history (static — called from P2P commands)
1438
+ *
1439
+ * Read JSONL files in reverse order, returning most recent messages first.
1440
+ * When instanceId is specified, reads only that instance file.
1441
+ * Offset/limit-based paging.
1442
+ */
1443
+ declare function readChatHistory(agentType: string, offset?: number, limit?: number, instanceId?: string): {
1444
+ messages: HistoryMessage[];
1445
+ hasMore: boolean;
1446
+ };
1447
+
1448
+ /**
1449
+ * Daemon Commands — unified command handler
1450
+ *
1451
+ * Routes all functionality from legacy Extension commands.ts to Daemon.
1452
+ *
1453
+ * Command implementations are split into sub-modules:
1454
+ * - chat-commands.ts — Chat I/O, session management, mode/model control
1455
+ * - cdp-commands.ts — CDP eval, screenshot, batch, remote actions, file ops
1456
+ * - stream-commands.ts — Agent stream, PTY I/O, provider settings, extension scripts
1457
+ */
1458
+
1459
+ interface CommandResult$1 {
1460
+ success: boolean;
1461
+ [key: string]: unknown;
1462
+ }
1463
+ interface CommandContext {
1464
+ cdpManagers: Map<string, DaemonCdpManager>;
1465
+ ideType: string;
1466
+ adapters: Map<string, any>;
1467
+ providerLoader?: ProviderLoader;
1468
+ /** ProviderInstanceManager — for runtime settings propagation */
1469
+ instanceManager?: ProviderInstanceManager;
1470
+ /** UUID instanceId → CDP manager key (ideType) mapping */
1471
+ instanceIdMap?: Map<string, string>;
1472
+ }
1473
+ /**
1474
+ * Shared helpers interface — passed to sub-module command functions
1475
+ * for accessing CDP, providers, agent streams, and other handler-owned state.
1476
+ */
1477
+ interface CommandHelpers {
1478
+ getCdp(ideType?: string): DaemonCdpManager | null;
1479
+ getProvider(overrideType?: string): ProviderModule | undefined;
1480
+ getProviderScript(scriptName: string, params?: Record<string, string>, ideType?: string): string | null;
1481
+ evaluateProviderScript(scriptName: string, params?: Record<string, string>, timeout?: number): Promise<{
1482
+ result: any;
1483
+ category: string;
1484
+ } | null>;
1485
+ getCliAdapter(type?: string): any | null;
1486
+ readonly currentIdeType: string | undefined;
1487
+ readonly currentProviderType: string | undefined;
1488
+ readonly agentStream: DaemonAgentStreamManager | null;
1489
+ readonly ctx: CommandContext;
1490
+ readonly historyWriter: ChatHistoryWriter;
1491
+ }
1492
+ declare class DaemonCommandHandler implements CommandHelpers {
1493
+ private _ctx;
1494
+ private _agentStream;
1495
+ private domHandlers;
1496
+ private _historyWriter;
1497
+ /** Current IDE type extracted from command args (per-request) */
1498
+ private _currentIdeType;
1499
+ /** Current provider type — agentType priority, ideType use */
1500
+ private _currentProviderType;
1501
+ constructor(ctx: CommandContext);
1502
+ get ctx(): CommandContext;
1503
+ get agentStream(): DaemonAgentStreamManager | null;
1504
+ get historyWriter(): ChatHistoryWriter;
1505
+ get currentIdeType(): string | undefined;
1506
+ get currentProviderType(): string | undefined;
1507
+ /** Get CDP manager for a specific ideType.
1508
+ * Returns null if no match — never falls back to another IDE. */
1509
+ getCdp(ideType?: string): DaemonCdpManager | null;
1510
+ /**
1511
+ * Get provider module — _currentProviderType (agentType priority) use.
1512
+ */
1513
+ getProvider(overrideType?: string): ProviderModule | undefined;
1514
+ /** Get a provider script by name from ProviderLoader. */
1515
+ getProviderScript(scriptName: string, params?: Record<string, string>, ideType?: string): string | null;
1516
+ /**
1517
+ * per-category CDP script execute:
1518
+ * IDE → cdp.evaluate(script) (main window)
1519
+ * Extension → cdp.evaluateInSession(sessionId, script) (webview)
1520
+ */
1521
+ evaluateProviderScript(scriptName: string, params?: Record<string, string>, timeout?: number): Promise<{
1522
+ result: any;
1523
+ category: string;
1524
+ } | null>;
1525
+ /** CLI adapter search */
1526
+ getCliAdapter(type?: string): any | null;
1527
+ private getExtensionSessionId;
1528
+ /** Extract ideType from _targetInstance */
1529
+ private extractIdeType;
1530
+ setAgentStreamManager(manager: DaemonAgentStreamManager): void;
1531
+ handle(cmd: string, args: any): Promise<CommandResult$1>;
1532
+ private dispatch;
1533
+ private handleGetRecentWorkspaces;
1534
+ private handleRefreshScripts;
1535
+ }
1536
+
1537
+ /**
1538
+ * CDP DOM Analysis Tools — DOM dump, query, debug
1539
+ *
1540
+ * Separated from daemon-commands.ts.
1541
+ * Tools for analyzing DOM structure when developing new IDE scripts.
1542
+ */
1543
+
1544
+ type CdpGetter = (ideType?: string) => DaemonCdpManager | null;
1545
+ /**
1546
+ * CDP DOM analysis handler
1547
+ *
1548
+ * Uses getCdp from DaemonCommandHandler.
1549
+ */
1550
+ declare class CdpDomHandlers {
1551
+ private getCdp;
1552
+ constructor(getCdp: CdpGetter);
1553
+ /**
1554
+ * CDP DOM Dump — IDE's DOM tree retrieve
1555
+ *
1556
+ * args:
1557
+ * selector?: string — CSS selector to dump specific area only (default: All)
1558
+ * depth?: number — Dump depth limit (default: 10)
1559
+ * attrs?: boolean — Whether to include properties (default: true)
1560
+ * maxLength?: number — Max character count (default: 200000)
1561
+ * format?: 'html' | 'tree' | 'summary' — Output format (default: 'html')
1562
+ * sessionId?: string — Agent webview session ID (if provided, match webview DOM)
1563
+ */
1564
+ handleDomDump(args: any): Promise<CommandResult$1>;
1565
+ /**
1566
+ * CDP DOM Query — CSS Test selector
1567
+ * Check how many elements match selector and what elements they are
1568
+ *
1569
+ * args:
1570
+ * selector: string — CSS selector
1571
+ * limit?: number — Max element count to return (default: 20)
1572
+ * content?: boolean — Whether to include text content (default: true)
1573
+ * sessionId?: string — agent webview session ID
1574
+ */
1575
+ handleDomQuery(args: any): Promise<CommandResult$1>;
1576
+ /**
1577
+ * CDP DOM Debug — IDE AI panel specialized analysis
1578
+ * Collect all essential info at once when supporting new IDE
1579
+ *
1580
+ * args:
1581
+ * ideType?: string — IDE type hint
1582
+ * sessionId?: string — agent webview session ID
1583
+ */
1584
+ handleDomDebug(args: any): Promise<CommandResult$1>;
1585
+ }
1586
+
1587
+ /**
1588
+ * ExtensionProviderInstance — Runtime instance for Extension Provider
1589
+ *
1590
+ * Manages IDE extensions (Cline, Roo Code, etc).
1591
+ * CDP webview discovery + agent stream collection moved here.
1592
+ */
1593
+
1594
+ declare class ExtensionProviderInstance implements ProviderInstance {
1595
+ readonly type: string;
1596
+ readonly category: "extension";
1597
+ private provider;
1598
+ private context;
1599
+ private settings;
1600
+ private events;
1601
+ private currentStatus;
1602
+ private agentStreams;
1603
+ private messages;
1604
+ private activeModal;
1605
+ private lastAgentStatus;
1606
+ private generatingStartedAt;
1607
+ private monitor;
1608
+ private instanceId;
1609
+ private ideType;
1610
+ constructor(provider: ProviderModule);
1611
+ init(context: InstanceContext): Promise<void>;
1612
+ onTick(): Promise<void>;
1613
+ getState(): ProviderState;
1614
+ onEvent(event: string, data?: any): void;
1615
+ dispose(): void;
1616
+ /** Query UUID instanceId */
1617
+ getInstanceId(): string;
1618
+ private detectTransition;
1619
+ private pushEvent;
1620
+ private flushEvents;
1621
+ }
1622
+
1623
+ /**
1624
+ * IdeProviderInstance — Runtime instance for IDE Provider
1625
+ *
1626
+ * Within a single IDE:
1627
+ * 1. Native chat (readChat via CDP)
1628
+ * 2. Extension agents (Cline, Roo Code etc)
1629
+ *
1630
+ * IDE Instance manages child Extension Instances.
1631
+ * Daemon collects all via a single IDE Instance.getState() call.
1632
+ */
1633
+
1634
+ declare class IdeProviderInstance implements ProviderInstance {
1635
+ readonly type: string;
1636
+ readonly category: "ide";
1637
+ private provider;
1638
+ private context;
1639
+ private settings;
1640
+ private events;
1641
+ private tickErrorCount;
1642
+ private cachedChat;
1643
+ private currentStatus;
1644
+ private lastAgentStatuses;
1645
+ private generatingStartedAt;
1646
+ private tickBusy;
1647
+ private monitor;
1648
+ private historyWriter;
1649
+ private ideVersion;
1650
+ private instanceId;
1651
+ private workspaceFolders;
1652
+ private activeFile;
1653
+ private extensions;
1654
+ constructor(provider: ProviderModule, instanceKey?: string);
1655
+ init(context: InstanceContext): Promise<void>;
1656
+ onTick(): Promise<void>;
1657
+ getState(): ProviderState;
1658
+ onEvent(event: string, data?: any): void;
1659
+ dispose(): void;
1660
+ /** Extension Instance add */
1661
+ addExtension(provider: ProviderModule, settings?: Record<string, any>): Promise<void>;
1662
+ /** Extension Instance remove */
1663
+ removeExtension(type: string): void;
1664
+ /** Extension Instance Import */
1665
+ getExtension(type: string): ExtensionProviderInstance | undefined;
1666
+ /** Child Extension list */
1667
+ getExtensionTypes(): string[];
1668
+ /** Query UUID instanceId */
1669
+ getInstanceId(): string;
1670
+ /** all Extension Instance list */
1671
+ getExtensionInstances(): ExtensionProviderInstance[];
1672
+ private readChat;
1673
+ private getReadChatScript;
1674
+ private detectAgentTransitions;
1675
+ private pushEvent;
1676
+ private flushEvents;
1677
+ updateCdp(cdp: InstanceContext['cdp']): void;
1678
+ }
1679
+
1680
+ /**
1681
+ * DaemonCdpSetup — Shared CDP initialization helpers
1682
+ *
1683
+ * Extracted from daemon-cloud/adhdev-daemon.ts setupCdpManager()
1684
+ * and daemon-standalone/index.ts inline CDP setup logic.
1685
+ *
1686
+ * Used by both daemon-cloud and daemon-standalone to ensure
1687
+ * consistent CDP → ProviderInstance registration.
1688
+ */
1689
+
1690
+ interface CdpSetupContext {
1691
+ providerLoader: ProviderLoader;
1692
+ instanceManager: ProviderInstanceManager;
1693
+ cdpManagers: Map<string, DaemonCdpManager>;
1694
+ /** UUID instanceId → CDP manager key mapping */
1695
+ instanceIdMap: Map<string, string>;
1696
+ /** Server connection (optional, cloud-only) */
1697
+ serverConn?: any;
1698
+ }
1699
+ interface SetupIdeInstanceOptions {
1700
+ /** Provider-based IDE type (e.g., 'antigravity', 'cursor') */
1701
+ ideType: string;
1702
+ /** Connected CDP manager */
1703
+ manager: DaemonCdpManager;
1704
+ /** CDP manager key (for multi-window: 'antigravity_remote_vs', single: 'antigravity') */
1705
+ managerKey?: string;
1706
+ /** Provider settings override */
1707
+ settings?: Record<string, any>;
1708
+ }
1709
+ /**
1710
+ * Register extension providers on a CDP manager.
1711
+ * Common pattern used during CDP init and periodic scans.
1712
+ */
1713
+ declare function registerExtensionProviders(providerLoader: ProviderLoader, manager: DaemonCdpManager, ideType: string): void;
1714
+ /**
1715
+ * Setup a CDP-connected IDE as a ProviderInstance.
1716
+ *
1717
+ * Performs:
1718
+ * 1. providerLoader.resolve() to get scripts
1719
+ * 2. Create IdeProviderInstance
1720
+ * 3. Register in InstanceManager
1721
+ * 4. Register enabled extensions
1722
+ * 5. Update instanceIdMap (IDE + extension UUIDs)
1723
+ *
1724
+ * @returns The created IdeProviderInstance, or null if provider not found
1725
+ */
1726
+ declare function setupIdeInstance(ctx: CdpSetupContext, opts: SetupIdeInstanceOptions): Promise<IdeProviderInstance | null>;
1727
+ /**
1728
+ * Create and connect a DaemonCdpManager for a given port.
1729
+ *
1730
+ * @returns Connected manager or null if connection failed
1731
+ */
1732
+ declare function connectCdpManager(port: number, ideType: string, logFn: (msg: string) => void, providerLoader: ProviderLoader, targetId?: string): Promise<DaemonCdpManager | null>;
1733
+ /**
1734
+ * Probe a CDP port to check if it's listening.
1735
+ * @returns true if CDP is available on this port
1736
+ */
1737
+ declare function probeCdpPort(port: number, timeoutMs?: number): Promise<boolean>;
1738
+
1739
+ /**
1740
+ * DaemonCdpScanner — Periodic CDP port scanning & auto-connect
1741
+ *
1742
+ * Extracted from daemon-cloud initCdp() and daemon-standalone initCdp().
1743
+ * Provides a unified approach to:
1744
+ * 1. Initial CDP port discovery
1745
+ * 2. Periodic scanning for newly launched IDEs
1746
+ * 3. Multi-window support (multiple pages on same port)
1747
+ */
1748
+
1749
+ interface CdpScannerOptions {
1750
+ /** Context for setup operations */
1751
+ ctx: CdpSetupContext;
1752
+ /** Log function for per-IDE CDP logs */
1753
+ logFn?: (ideType: string) => (msg: string) => void;
1754
+ /** Whether to support multi-window (multiple pages per port) */
1755
+ multiWindow?: boolean;
1756
+ /** Scan interval in ms (default: 30000) */
1757
+ scanIntervalMs?: number;
1758
+ /** Callback when a new CDP connection is established */
1759
+ onConnected?: (ideType: string, managerKey: string, manager: DaemonCdpManager) => void;
1760
+ }
1761
+ declare class DaemonCdpScanner {
1762
+ private ctx;
1763
+ private opts;
1764
+ private scanTimer;
1765
+ private discoveryTimer;
1766
+ constructor(opts: CdpScannerOptions);
1767
+ /**
1768
+ * Initial CDP discovery — connect to all available IDEs.
1769
+ * Supports both single-window and multi-window modes.
1770
+ */
1771
+ initialScan(enabledIdes?: string[]): Promise<void>;
1772
+ /**
1773
+ * Start periodic scanning for newly launched IDEs.
1774
+ */
1775
+ startPeriodicScan(): void;
1776
+ /**
1777
+ * Start periodic agent webview discovery on all connected CDPs.
1778
+ */
1779
+ startWebviewDiscovery(intervalMs?: number): void;
1780
+ /**
1781
+ * Stop all timers.
1782
+ */
1783
+ stop(): void;
1784
+ private getLogFn;
1785
+ /**
1786
+ * Single-window connection (standalone mode).
1787
+ * One CDP manager per IDE, first working port wins.
1788
+ */
1789
+ private connectSingleWindow;
1790
+ /**
1791
+ * Multi-window connection (cloud mode).
1792
+ * Multiple CDP managers per IDE — one per workbench page.
1793
+ */
1794
+ private connectMultiWindow;
1795
+ }
1796
+
1797
+ /**
1798
+ * DaemonCdpInitializer — Unified CDP initialization + periodic scanning
1799
+ *
1800
+ * Replaces initCdp() in both cloud and standalone daemons.
1801
+ *
1802
+ * Features:
1803
+ * 1. Initial connection: connectAll() — multi-window aware
1804
+ * 2. Periodic scan: startPeriodicScan() — auto-detect newly opened IDEs
1805
+ * 3. Discovery: startDiscovery() — periodic agent webview discovery
1806
+ */
1807
+
1808
+ interface CdpInitializerConfig {
1809
+ providerLoader: ProviderLoader;
1810
+ cdpManagers: Map<string, DaemonCdpManager>;
1811
+ /** Filter: only connect these IDEs (empty/undefined = all) */
1812
+ enabledIdes?: string[];
1813
+ /** Callback when a new CDP manager is connected */
1814
+ onConnected?: (ideType: string, manager: DaemonCdpManager, managerKey: string) => void | Promise<void>;
1815
+ }
1816
+ declare class DaemonCdpInitializer {
1817
+ private config;
1818
+ private scanTimer;
1819
+ private discoveryTimer;
1820
+ constructor(config: CdpInitializerConfig);
1821
+ /**
1822
+ * Connect to all detected IDEs.
1823
+ * Multi-window aware: creates separate CdpManager per workbench page.
1824
+ */
1825
+ connectAll(detectedIdes: any[]): Promise<void>;
1826
+ /**
1827
+ * Connect to a single IDE port.
1828
+ * Tries multi-window first (listAllTargets), falls back to direct connect.
1829
+ */
1830
+ private connectIdePort;
1831
+ /**
1832
+ * Start periodic scanning for newly opened IDEs.
1833
+ * Idempotent — ignored if already started.
1834
+ */
1835
+ startPeriodicScan(intervalMs?: number): void;
1836
+ /**
1837
+ * Start periodic agent webview discovery.
1838
+ */
1839
+ startDiscovery(intervalMs?: number): void;
1840
+ /** Stop all timers */
1841
+ stop(): void;
1842
+ }
1843
+
1844
+ /**
1845
+ * CliAdapter — common interface for CLI agents
1846
+ *
1847
+ * Contract implemented by all CLI adapters (ProviderCliAdapter etc).
1848
+ */
1849
+ interface CliAdapter {
1850
+ cliType: string;
1851
+ cliName: string;
1852
+ workingDir: string;
1853
+ spawn(): Promise<void>;
1854
+ sendMessage(text: string): Promise<void>;
1855
+ getStatus(): any;
1856
+ getPartialResponse(): string;
1857
+ shutdown(): void;
1858
+ cancel(): void;
1859
+ isProcessing(): boolean;
1860
+ isReady(): boolean;
1861
+ setOnStatusChange(callback: () => void): void;
1862
+ setServerConn?(serverConn: any): void;
1863
+ setOnPtyData?(callback: (data: string) => void): void;
1864
+ writeRaw?(data: string): void;
1865
+ resize?(cols: number, rows: number): void;
1866
+ }
1867
+
1868
+ /**
1869
+ * DaemonCliManager — CLI session creation, management, and command handling
1870
+ *
1871
+ * Separated from adhdev-daemon.ts.
1872
+ * CLI cases of createAdapter, startCliSession, stopCliSession, executeDaemonCommand extracted to independent module extract.
1873
+ */
1874
+
1875
+ interface CliManagerDeps {
1876
+ /** Server connection — injected into adapter */
1877
+ getServerConn(): any | null;
1878
+ /** P2P — PTY output transmit */
1879
+ getP2p(): {
1880
+ broadcastPtyOutput(key: string, data: string): void;
1881
+ } | null;
1882
+ /** StatusReporter callback */
1883
+ onStatusChange(): void;
1884
+ removeAgentTracking(key: string): void;
1885
+ /** InstanceManager — register in CLI unified status */
1886
+ getInstanceManager(): ProviderInstanceManager | null;
1887
+ }
1888
+ type CommandResult = {
1889
+ success: boolean;
1890
+ [key: string]: unknown;
1891
+ };
1892
+ declare class DaemonCliManager {
1893
+ readonly adapters: Map<string, CliAdapter>;
1894
+ private deps;
1895
+ private providerLoader;
1896
+ constructor(deps: CliManagerDeps, providerLoader: ProviderLoader);
1897
+ getCliKey(cliType: string, dir: string): string;
1898
+ private createAdapter;
1899
+ startSession(cliType: string, workingDir: string, cliArgs?: string[], initialModel?: string): Promise<void>;
1900
+ stopSession(key: string): Promise<void>;
1901
+ shutdownAll(): void;
1902
+ /**
1903
+ * Search for CLI adapter. Priority order:
1904
+ * 0. instanceKey (UUID direct match) — extracted from _targetInstance / composite ID
1905
+ * 1. agentType + dir (iteration match)
1906
+ * 2. agentType fuzzy match (⚠ returns first match when multiple sessions exist)
1907
+ */
1908
+ findAdapter(agentType: string, opts?: {
1909
+ dir?: string;
1910
+ instanceKey?: string;
1911
+ }): {
1912
+ adapter: CliAdapter;
1913
+ key: string;
1914
+ } | null;
1915
+ handleCliCommand(cmd: string, args: any): Promise<CommandResult | null>;
1916
+ }
1917
+
1918
+ /**
1919
+ * DaemonCommandRouter — Unified command routing for daemon-level commands
1920
+ *
1921
+ * Extracted from cloud daemon's executeDaemonCommand() logic.
1922
+ * Used by both daemon-cloud and daemon-standalone.
1923
+ *
1924
+ * Routing flow:
1925
+ * 1. Daemon-level commands (launch_ide, stop_ide, restart_ide, etc.) → handled here
1926
+ * 2. CLI/ACP commands → delegated to cliManager
1927
+ * 3. Everything else → delegated to commandHandler.handle()
1928
+ */
1929
+
1930
+ interface CommandRouterDeps {
1931
+ commandHandler: DaemonCommandHandler;
1932
+ cliManager: DaemonCliManager;
1933
+ cdpManagers: Map<string, DaemonCdpManager>;
1934
+ providerLoader: ProviderLoader;
1935
+ instanceManager: ProviderInstanceManager;
1936
+ /** Reference to detected IDEs array (mutable — router updates it) */
1937
+ detectedIdes: {
1938
+ value: any[];
1939
+ };
1940
+ /** UUID instanceId → CDP manager key mapping */
1941
+ instanceIdMap: Map<string, string>;
1942
+ /** Callback for CDP manager creation after launch_ide (cloud: setupCdpManager, standalone: no-op) */
1943
+ onCdpManagerCreated?: (ideType: string, manager: DaemonCdpManager) => void;
1944
+ /** Callback after IDE connected (e.g., startAgentStreamPolling) */
1945
+ onIdeConnected?: () => void;
1946
+ /** Callback after status change (stop_ide, restart) */
1947
+ onStatusChange?: () => void;
1948
+ /** Callback after chat-related commands (cloud: throttled report) */
1949
+ onPostChatCommand?: () => void;
1950
+ /** Get a connected CDP manager (for agent stream reset check) */
1951
+ getCdpLogFn?: (ideType: string) => (msg: string) => void;
1952
+ }
1953
+ interface CommandRouterResult {
1954
+ success: boolean;
1955
+ [key: string]: unknown;
1956
+ }
1957
+ declare class DaemonCommandRouter {
1958
+ private deps;
1959
+ constructor(deps: CommandRouterDeps);
1960
+ /**
1961
+ * Unified command routing.
1962
+ * Returns result for all commands:
1963
+ * 1. Daemon-level commands (launch_ide, stop_ide, etc.)
1964
+ * 2. CLI commands (launch_cli, stop_cli, agent_command)
1965
+ * 3. DaemonCommandHandler delegation (CDP/agent-stream/file commands)
1966
+ *
1967
+ * @param cmd Command name
1968
+ * @param args Command arguments
1969
+ * @param source Log source ('ws' | 'p2p' | 'standalone' | etc.)
1970
+ */
1971
+ execute(cmd: string, args: any, source?: string): Promise<CommandRouterResult>;
1972
+ /**
1973
+ * Daemon-level command execution (IDE start/stop/restart, CLI, detect, logs).
1974
+ * Returns null if not handled at this level → caller delegates to CommandHandler.
1975
+ */
1976
+ private executeDaemonCommand;
1977
+ /**
1978
+ * IDE stop: CDP disconnect + remove from InstanceManager + clean instanceIdMap
1979
+ */
1980
+ private stopIde;
1981
+ }
1982
+
1983
+ /**
1984
+ * DaemonStatusReporter — status collect & transmit (StatusReport / P2P / StatusEvent)
1985
+ *
1986
+ * Collect status from ProviderInstanceManager → assemble payload → transmit
1987
+ * Each Instance manages its own status/transition. This module only assembles + transmits.
1988
+ */
1989
+ interface StatusReporterDeps {
1990
+ serverConn: {
1991
+ isConnected(): boolean;
1992
+ sendMessage(type: string, data: any): void;
1993
+ getUserPlan(): string;
1994
+ } | null;
1995
+ cdpManagers: Map<string, {
1996
+ isConnected: boolean;
1997
+ }>;
1998
+ p2p: {
1999
+ isConnected: boolean;
2000
+ isAvailable: boolean;
2001
+ connectionState: string;
2002
+ connectedPeerCount: number;
2003
+ screenshotActive: boolean;
2004
+ sendStatus(data: any): void;
2005
+ } | null;
2006
+ providerLoader: {
2007
+ resolve(type: string): any;
2008
+ getAll(): any[];
2009
+ };
2010
+ adapters: Map<string, {
2011
+ cliType: string;
2012
+ cliName: string;
2013
+ workingDir: string;
2014
+ getStatus(): any;
2015
+ getPartialResponse(): string;
2016
+ }>;
2017
+ detectedIdes: any[];
2018
+ ideType: string;
2019
+ instanceManager: {
2020
+ collectAllStates(): any[];
2021
+ collectStatesByCategory(cat: string): any[];
2022
+ };
2023
+ }
2024
+ declare class DaemonStatusReporter {
2025
+ private deps;
2026
+ private log;
2027
+ private lastStatusSentAt;
2028
+ private statusPendingThrottle;
2029
+ private lastP2PStatusHash;
2030
+ private lastStatusSummary;
2031
+ private statusTimer;
2032
+ private p2pTimer;
2033
+ constructor(deps: StatusReporterDeps, opts?: {
2034
+ logFn?: (msg: string) => void;
2035
+ });
2036
+ startReporting(): void;
2037
+ stopReporting(): void;
2038
+ onStatusChange(): void;
2039
+ throttledReport(): void;
2040
+ emitStatusEvent(event: Record<string, unknown>): void;
2041
+ removeAgentTracking(_key: string): void;
2042
+ updateAgentStreams(_ideType: string, _streams: any[]): void;
2043
+ private ts;
2044
+ sendUnifiedStatusReport(opts?: {
2045
+ p2pOnly?: boolean;
2046
+ }): Promise<void>;
2047
+ private sendP2PPayload;
2048
+ private simpleHash;
2049
+ }
2050
+
2051
+ /**
2052
+ * ADHDev Daemon — unified logger (v2)
2053
+ *
2054
+ * log level: DEBUG < INFO < WARN < ERROR
2055
+ *
2056
+ * Features:
2057
+ * 1. daemonLog(category, msg, level) — explicit per-category logging
2058
+ * 2. installGlobalInterceptor() — Auto-intercept console.log (once on daemon start)
2059
+ * 3. Recent log ring buffer — for remote transmission via P2P/WS
2060
+ * 4. File logging — ~/Library/Logs/adhdev/daemon.log (10MB rolling)
2061
+ *
2062
+ * use:
2063
+ * import { daemonLog, LOG } from './daemon-logger';
2064
+ * LOG.info('CDP', 'Connected to cursor on port 9333');
2065
+ * LOG.debug('StatusReport', 'P2P heartbeat sent');
2066
+ * LOG.warn('IdeInstance', 'onTick error: ...');
2067
+ * LOG.error('Server', 'WebSocket disconnected');
2068
+ */
2069
+ type LogLevel = 'debug' | 'info' | 'warn' | 'error';
2070
+ declare function setLogLevel(level: LogLevel): void;
2071
+ declare function getLogLevel(): LogLevel;
2072
+ interface LogEntry {
2073
+ ts: number;
2074
+ level: LogLevel;
2075
+ category: string;
2076
+ message: string;
2077
+ }
2078
+ /** Get recent N logs (for remote transmission) */
2079
+ declare function getRecentLogs(count?: number, minLevel?: LogLevel): LogEntry[];
2080
+ /**
2081
+ * Scoped logger instance for a specific component.
2082
+ * Created via LOG.forComponent('CDP:cursor').
2083
+ */
2084
+ interface ScopedLogger {
2085
+ debug: (msg: string) => void;
2086
+ info: (msg: string) => void;
2087
+ warn: (msg: string) => void;
2088
+ error: (msg: string) => void;
2089
+ /** Returns a plain (msg: string) => void function at the given level.
2090
+ * Useful as logFn callback for ProviderLoader, DaemonStatusReporter, etc. */
2091
+ asLogFn: (level?: LogLevel) => (msg: string) => void;
2092
+ }
2093
+ /**
2094
+ * LOG — unified logging API
2095
+ *
2096
+ * Usage:
2097
+ * LOG.info('CDP', 'Connected to cursor on port 9333');
2098
+ * LOG.debug('StatusReport', 'P2P heartbeat sent');
2099
+ *
2100
+ * Component-scoped logger:
2101
+ * const log = LOG.forComponent('ACP:cursor');
2102
+ * log.info('Session created');
2103
+ * log.debug('Heartbeat');
2104
+ *
2105
+ * As callback for external components:
2106
+ * new ProviderLoader({ logFn: LOG.forComponent('Provider').asLogFn() });
2107
+ * new DaemonStatusReporter({ logFn: LOG.forComponent('Status').asLogFn() });
2108
+ */
2109
+ declare const LOG: {
2110
+ debug: (category: string, msg: string) => void;
2111
+ info: (category: string, msg: string) => void;
2112
+ warn: (category: string, msg: string) => void;
2113
+ error: (category: string, msg: string) => void;
2114
+ /**
2115
+ * Create a scoped logger for a specific component.
2116
+ * Category is baked in so callers only pass the message.
2117
+ */
2118
+ forComponent(category: string): ScopedLogger;
2119
+ };
2120
+ /**
2121
+ * console.log/warn/error global interceptor install
2122
+ * Prevent recording in places not using daemonLog.
2123
+ * daemon start when 1time call.
2124
+ */
2125
+ declare function installGlobalInterceptor(): void;
2126
+
2127
+ /**
2128
+ * ADHDev Daemon — Command History Logger
2129
+ *
2130
+ * Record all commands from dashboard/WS/P2P/Extension/API to local file.
2131
+ * Per-date JSONL file, 7-day retention, 5MB limit.
2132
+ *
2133
+ * Purpose:
2134
+ * - Debugging: track what command came and when
2135
+ * - Audit: record all commands executed from remote
2136
+ * - Stats: identify frequently used features
2137
+ */
2138
+ interface CommandLogEntry {
2139
+ ts: string;
2140
+ cmd: string;
2141
+ source: 'ws' | 'p2p' | 'ext' | 'api' | 'standalone' | 'unknown';
2142
+ args?: Record<string, unknown>;
2143
+ success?: boolean;
2144
+ error?: string;
2145
+ durationMs?: number;
2146
+ }
2147
+ /**
2148
+ * Log a command received from the dashboard/WS/P2P/extension/API.
2149
+ * Call this at the entry point of command handling.
2150
+ */
2151
+ declare function logCommand(entry: CommandLogEntry): void;
2152
+ /**
2153
+ * Read recent command history (for dashboard display / debugging)
2154
+ */
2155
+ declare function getRecentCommands(count?: number): CommandLogEntry[];
2156
+
2157
+ /**
2158
+ * ADHDev Launcher — IDE Launch/Relaunch with CDP
2159
+ *
2160
+ * Launches IDE with Chrome DevTools Protocol (remote-debugging-port).
2161
+ * If IDE is already running, terminates it and restarts with CDP option.
2162
+ *
2163
+ * Pipeline:
2164
+ * 1. IDE process detection (already running?)
2165
+ * 2. If already running with CDP → reuse as-is
2166
+ * 3. If running without CDP → kill process → wait → restart with CDP
2167
+ * 4. Not running → start fresh with CDP
2168
+ *
2169
+ * Usage:
2170
+ * adhdev launch — Launch configured IDE with CDP port
2171
+ * adhdev launch cursor — Launch Cursor with CDP port
2172
+ * adhdev launch --workspace /path — Open specific workspace
2173
+ */
2174
+ interface LaunchOptions {
2175
+ ideId?: string;
2176
+ workspace?: string;
2177
+ newWindow?: boolean;
2178
+ }
2179
+ interface LaunchResult {
2180
+ success: boolean;
2181
+ ideId: string;
2182
+ ideName: string;
2183
+ port: number;
2184
+ action: 'started' | 'restarted' | 'reused' | 'failed';
2185
+ message: string;
2186
+ error?: string;
2187
+ }
2188
+ /**
2189
+ * Execute IDE with CDP port (relaunch pipeline)
2190
+ *
2191
+ * 1. IDE detect
2192
+ * 2. per-fixed IDE CDP port determine
2193
+ * 3. CDP not active → reuse
2194
+ * 4. IDE execute during but CDP none → terminate → restart with CDP
2195
+ * 5. IDE not running → start fresh with CDP
2196
+ */
2197
+ declare function launchWithCdp(options?: LaunchOptions): Promise<LaunchResult>;
2198
+ declare function getAvailableIdeIds(): string[];
2199
+
2200
+ declare const DEFAULT_DAEMON_PORT = 19222;
2201
+ declare const DAEMON_WS_PATH = "/ipc";
2202
+
2203
+ /**
2204
+ * ProviderCliAdapter — generic CLI Adapter based on provider.js
2205
+ *
2206
+ * Replaces individual adapters (gemini-cli.ts, claude-cli.ts, codex-cli.ts).
2207
+ * Single engine driven by provider.js patterns, spawn, and cleanOutput.
2208
+ *
2209
+ * provider.js contract:
2210
+ * type: string — 'gemini-cli', 'claude-cli', 'codex-cli', ...
2211
+ * name: string — 'Gemini CLI', 'Claude Code', ...
2212
+ * category: 'cli'
2213
+ * binary: string — binary name
2214
+ * spawn: { command, args, shell, env }
2215
+ * patterns: { prompt, generating, approval, ready }
2216
+ * timeouts?: { idleFinish, generatingIdle, maxResponse, approvalCooldown, ... }
2217
+ * cleanOutput(raw, lastUserInput): string
2218
+ */
2219
+
2220
+ interface CliChatMessage {
2221
+ role: 'user' | 'assistant';
2222
+ content: string;
2223
+ timestamp?: number;
2224
+ }
2225
+ interface CliSessionStatus {
2226
+ status: 'idle' | 'generating' | 'waiting_approval' | 'error' | 'stopped' | 'starting';
2227
+ messages: CliChatMessage[];
2228
+ workingDir: string;
2229
+ activeModal: {
2230
+ message: string;
2231
+ buttons: string[];
2232
+ } | null;
2233
+ }
2234
+ interface CliProviderModule {
2235
+ type: string;
2236
+ name: string;
2237
+ category: 'cli';
2238
+ binary: string;
2239
+ spawn: {
2240
+ command: string;
2241
+ args: string[];
2242
+ shell: boolean;
2243
+ env: Record<string, string>;
2244
+ };
2245
+ patterns: {
2246
+ prompt: RegExp[];
2247
+ generating: RegExp[];
2248
+ approval: RegExp[];
2249
+ ready: RegExp[];
2250
+ };
2251
+ timeouts?: {
2252
+ /** PTY output batch transmit interval (default 50ms) */
2253
+ ptyFlush?: number;
2254
+ /** Wait for startup dialog auto-proceed (default 300ms) */
2255
+ dialogAccept?: number;
2256
+ /** Approval detect cooldown (default 2000ms) */
2257
+ approvalCooldown?: number;
2258
+ /** Check for completion on no-response during generating (default 6000ms) */
2259
+ generatingIdle?: number;
2260
+ /** Check for completion on no-response (default 5000ms) */
2261
+ idleFinish?: number;
2262
+ /** Max response wait (default 300000ms = 5min) */
2263
+ maxResponse?: number;
2264
+ /** shutdown after kill wait (default 1000ms) */
2265
+ shutdownGrace?: number;
2266
+ };
2267
+ cleanOutput(raw: string, lastUserInput?: string): string;
2268
+ }
2269
+ declare class ProviderCliAdapter implements CliAdapter {
2270
+ private extraArgs;
2271
+ readonly cliType: string;
2272
+ readonly cliName: string;
2273
+ workingDir: string;
2274
+ private provider;
2275
+ private ptyProcess;
2276
+ private messages;
2277
+ private currentStatus;
2278
+ private onStatusChange;
2279
+ private responseBuffer;
2280
+ private recentOutputBuffer;
2281
+ private isWaitingForResponse;
2282
+ private activeModal;
2283
+ private responseTimeout;
2284
+ private idleTimeout;
2285
+ private ready;
2286
+ private startupBuffer;
2287
+ private onPtyDataCallback;
2288
+ private ptyOutputBuffer;
2289
+ private ptyOutputFlushTimer;
2290
+ private serverConn;
2291
+ private logBuffer;
2292
+ private lastApprovalResolvedAt;
2293
+ private readonly timeouts;
2294
+ constructor(provider: CliProviderModule, workingDir: string, extraArgs?: string[]);
2295
+ setServerConn(serverConn: any): void;
2296
+ setOnStatusChange(callback: () => void): void;
2297
+ setOnPtyData(callback: (data: string) => void): void;
2298
+ spawn(): Promise<void>;
2299
+ private handleOutput;
2300
+ private finishResponse;
2301
+ getStatus(): CliSessionStatus;
2302
+ sendMessage(text: string): Promise<void>;
2303
+ getPartialResponse(): string;
2304
+ cancel(): void;
2305
+ shutdown(): void;
2306
+ clearHistory(): void;
2307
+ isProcessing(): boolean;
2308
+ isReady(): boolean;
2309
+ writeRaw(data: string): void;
2310
+ resize(cols: number, rows: number): void;
2311
+ }
2312
+
2313
+ /**
2314
+ * CliProviderInstance — Runtime instance for CLI Provider
2315
+ *
2316
+ * Lifecycle layer on top of ProviderCliAdapter.
2317
+ * collectCliData() + status transition logic from daemon-status.ts moved here.
2318
+ */
2319
+
2320
+ declare class CliProviderInstance implements ProviderInstance {
2321
+ private provider;
2322
+ private workingDir;
2323
+ private cliArgs;
2324
+ readonly type: string;
2325
+ readonly category: "cli";
2326
+ private adapter;
2327
+ private context;
2328
+ private events;
2329
+ private lastStatus;
2330
+ private generatingStartedAt;
2331
+ private settings;
2332
+ private monitor;
2333
+ private historyWriter;
2334
+ readonly instanceId: string;
2335
+ constructor(provider: ProviderModule, workingDir: string, cliArgs?: string[], instanceId?: string);
2336
+ init(context: InstanceContext): Promise<void>;
2337
+ onTick(): Promise<void>;
2338
+ getState(): ProviderState;
2339
+ onEvent(event: string, data?: any): void;
2340
+ dispose(): void;
2341
+ private detectStatusTransition;
2342
+ private pushEvent;
2343
+ private flushEvents;
2344
+ getAdapter(): ProviderCliAdapter;
2345
+ get cliType(): string;
2346
+ get cliName(): string;
2347
+ }
2348
+
2349
+ /**
2350
+ * AcpProviderInstance — ACP (Agent Client Protocol) Provider runtime instance
2351
+ *
2352
+ * Spawns ACP agent process and communicates via the official ACP SDK.
2353
+ * Uses ClientSideConnection + ndJsonStream for structured protocol communication.
2354
+ *
2355
+ * ACP spec: https://agentclientprotocol.com
2356
+ * ACP SDK: @agentclientprotocol/sdk@0.16.1
2357
+ *
2358
+ * lifecycle:
2359
+ * 1. init() → Spawn agent process + ACP initialize handshake
2360
+ * 2. onTick() → no-op (ACP event based)
2361
+ * 3. getState() → ProviderState return (dashboard for display)
2362
+ * 4. onEvent('send_message') → session/prompt transmit
2363
+ * 5. dispose() → kill process
2364
+ */
2365
+
2366
+ declare class AcpProviderInstance implements ProviderInstance {
2367
+ private cliArgs;
2368
+ readonly type: string;
2369
+ readonly category: "acp";
2370
+ private readonly log;
2371
+ private provider;
2372
+ private context;
2373
+ private settings;
2374
+ private events;
2375
+ private monitor;
2376
+ private process;
2377
+ private connection;
2378
+ private sessionId;
2379
+ private messages;
2380
+ private currentStatus;
2381
+ private lastStatus;
2382
+ private generatingStartedAt;
2383
+ private agentCapabilities;
2384
+ private currentModel;
2385
+ private currentMode;
2386
+ private activeToolCalls;
2387
+ private stopReason;
2388
+ private partialContent;
2389
+ /** Rich content blocks accumulated during streaming */
2390
+ private partialBlocks;
2391
+ /** Tool calls collected during current turn */
2392
+ private turnToolCalls;
2393
+ private errorMessage;
2394
+ private errorReason;
2395
+ private stderrBuffer;
2396
+ private spawnedAt;
2397
+ private configOptions;
2398
+ private availableModes;
2399
+ /** Static config mode — agent doesn't support config/* methods */
2400
+ private useStaticConfig;
2401
+ /** Current config selections (for spawnArgBuilder) */
2402
+ private selectedConfig;
2403
+ private workingDir;
2404
+ private instanceId;
2405
+ constructor(provider: ProviderModule, workingDir: string, cliArgs?: string[]);
2406
+ init(context: InstanceContext): Promise<void>;
2407
+ onTick(): Promise<void>;
2408
+ getState(): ProviderState;
2409
+ onEvent(event: string, data?: any): void;
2410
+ private parseConfigOptions;
2411
+ private parseModes;
2412
+ setConfigOption(category: string, value: string): Promise<void>;
2413
+ setMode(modeId: string): Promise<void>;
2414
+ /** Static config: kill process and restart with new args */
2415
+ private restartWithNewConfig;
2416
+ /** Update settings at runtime (called when user changes settings from dashboard) */
2417
+ updateSettings(newSettings: Record<string, any>): void;
2418
+ dispose(): void;
2419
+ private spawnAgent;
2420
+ private createClient;
2421
+ private initialize;
2422
+ private createSession;
2423
+ sendPrompt(text: string, contentBlocks?: ContentBlock[]): Promise<void>;
2424
+ private cancelSession;
2425
+ private permissionResolvers;
2426
+ private resolvePermission;
2427
+ private handleSessionUpdate;
2428
+ /** Handle legacy session/update formats (pre-standardization compat) */
2429
+ private handleLegacyUpdate;
2430
+ /** Map SDK ToolCallStatus to internal status */
2431
+ private mapToolCallStatus;
2432
+ /** Truncate content for transport (text: 2000 chars, images preserved) */
2433
+ private truncateContent;
2434
+ /** Build ContentBlock[] from current partial state */
2435
+ private buildPartialBlocks;
2436
+ /** Finalize streaming content into an assistant message */
2437
+ private finalizeAssistantMessage;
2438
+ /** Convert ACP ToolCallContent[] to our ToolCallContent[] */
2439
+ private convertToolCallContent;
2440
+ private detectStatusTransition;
2441
+ private pushEvent;
2442
+ private flushEvents;
2443
+ get cliType(): string;
2444
+ get cliName(): string;
2445
+ /** ACP Agent capabilities (available after initialize) */
2446
+ getCapabilities(): Record<string, any>;
2447
+ }
2448
+
2449
+ /**
2450
+ * Dev Server — HTTP API for Provider debugging + script development
2451
+ *
2452
+ * Enabled with `adhdev daemon --dev`
2453
+ * Port: 19280 (fixed)
2454
+ *
2455
+ * API list:
2456
+ * GET /api/providers — loaded provider list
2457
+ * POST /api/providers/:type/script — specific script execute
2458
+ * POST /api/cdp/evaluate — Execute JS expression
2459
+ * POST /api/cdp/dom/query — Test selector
2460
+ * GET /api/cdp/screenshot — screenshot
2461
+ * POST /api/scripts/run — Execute provider script (name + params)
2462
+ * GET /api/status — All status (CDP connection, provider etc)
2463
+ */
2464
+
2465
+ declare class DevServer {
2466
+ private server;
2467
+ private providerLoader;
2468
+ private cdpManagers;
2469
+ private logFn;
2470
+ private sseClients;
2471
+ private watchScriptPath;
2472
+ private watchScriptName;
2473
+ private watchTimer;
2474
+ private autoImplProcess;
2475
+ private autoImplSSEClients;
2476
+ private autoImplStatus;
2477
+ constructor(options: {
2478
+ providerLoader: ProviderLoader;
2479
+ cdpManagers: Map<string, DaemonCdpManager>;
2480
+ logFn?: (msg: string) => void;
2481
+ });
2482
+ private log;
2483
+ private readonly routes;
2484
+ private matchRoute;
2485
+ private getEndpointList;
2486
+ start(port?: number): Promise<void>;
2487
+ stop(): void;
2488
+ private handleListProviders;
2489
+ private handleProviderConfig;
2490
+ private handleSpawnTest;
2491
+ private handleRunScript;
2492
+ private handleCdpEvaluate;
2493
+ private handleCdpDomQuery;
2494
+ private handleScreenshot;
2495
+ private handleScriptsRun;
2496
+ private handleStatus;
2497
+ private handleReload;
2498
+ private getConsoleDistDir;
2499
+ private serveConsole;
2500
+ private static MIME_MAP;
2501
+ private serveStaticAsset;
2502
+ private handleSSE;
2503
+ private sendSSE;
2504
+ private handleWatchStart;
2505
+ private handleWatchStop;
2506
+ /** Find the provider directory on disk */
2507
+ private findProviderDir;
2508
+ /** GET /api/providers/:type/files — list all files in provider directory */
2509
+ private handleListFiles;
2510
+ /** GET /api/providers/:type/file?path=scripts.js — read a file */
2511
+ private handleReadFile;
2512
+ /** POST /api/providers/:type/file — write a file { path, content } */
2513
+ private handleWriteFile;
2514
+ private handleSource;
2515
+ private handleSave;
2516
+ private handleScriptHints;
2517
+ private handleValidate;
2518
+ private handleAcpChat;
2519
+ private handleCdpTargets;
2520
+ private handleScaffold;
2521
+ private handleDetectVersions;
2522
+ private handleDomInspect;
2523
+ private handleDomChildren;
2524
+ private handleDomAnalyze;
2525
+ private handleFindCommon;
2526
+ private handleFindByText;
2527
+ private handleDomContext;
2528
+ private handleAutoImplement;
2529
+ private buildAutoImplPrompt;
2530
+ private handleAutoImplSSE;
2531
+ private handleAutoImplCancel;
2532
+ private sendAutoImplSSE;
2533
+ /** Get CDP manager — matching IDE when ideType specified, first connected one otherwise */
2534
+ private getCdp;
2535
+ private getAnyCdp;
2536
+ private json;
2537
+ private readBody;
2538
+ }
2539
+
2540
+ /**
2541
+ * ADHDev Launcher — Extension Installer
2542
+ *
2543
+ * Installs VS Code extensions via CLI commands.
2544
+ * Supports installing user-selected AI extensions.
2545
+ */
2546
+
2547
+ interface ExtensionInfo {
2548
+ id: string;
2549
+ name: string;
2550
+ displayName: string;
2551
+ marketplaceId: string;
2552
+ description: string;
2553
+ category: 'ai-agent' | 'utility';
2554
+ icon: string;
2555
+ recommended: boolean;
2556
+ requiresApiKey?: boolean;
2557
+ apiKeyName?: string;
2558
+ website?: string;
2559
+ vsixUrl?: string;
2560
+ }
2561
+ interface InstallResult {
2562
+ extensionId: string;
2563
+ marketplaceId: string;
2564
+ success: boolean;
2565
+ alreadyInstalled: boolean;
2566
+ error?: string;
2567
+ }
2568
+ /**
2569
+ * Check if an extension is already installed
2570
+ */
2571
+ declare function isExtensionInstalled(ide: IDEInfo, marketplaceId: string): boolean;
2572
+ /**
2573
+ * Install multiple extensions sequentially
2574
+ */
2575
+ declare function installExtensions(ide: IDEInfo, extensions: ExtensionInfo[], onProgress?: (current: number, total: number, ext: ExtensionInfo, result: InstallResult) => void): Promise<InstallResult[]>;
2576
+ /**
2577
+ * Get AI agent extensions
2578
+ */
2579
+ declare function getAIExtensions(): ExtensionInfo[];
2580
+ /**
2581
+ * Launch IDE after installation
2582
+ */
2583
+ declare function launchIDE(ide: IDEInfo, workspacePath?: string): boolean;
2584
+
2585
+ /**
2586
+ * Daemon Lifecycle — Shared init + shutdown for cloud/standalone
2587
+ *
2588
+ * initDaemonComponents(): Creates all core daemon components in correct order.
2589
+ * shutdownDaemonComponents(): Graceful shutdown of all components.
2590
+ *
2591
+ * Transport-specific setup (ServerConnection, P2P, HTTP/WS) remains in each daemon.
2592
+ */
2593
+
2594
+ interface DaemonInitConfig {
2595
+ /** ProviderLoader log function */
2596
+ providerLogFn?: (msg: string) => void;
2597
+ /** CLI Manager deps (transport-specific) */
2598
+ cliManagerDeps: {
2599
+ getServerConn: () => any;
2600
+ getP2p: () => any;
2601
+ onStatusChange: () => void;
2602
+ removeAgentTracking: (key: string) => void;
2603
+ };
2604
+ /** CDP config */
2605
+ enabledIdes?: string[];
2606
+ /** Router transport-specific callbacks */
2607
+ onStatusChange?: () => void;
2608
+ onPostChatCommand?: () => void;
2609
+ getCdpLogFn?: (ideType: string) => (msg: string) => void;
2610
+ /** Additional callback after CDP manager created (transport-specific extras) */
2611
+ onCdpManagerSetup?: (ideType: string, manager: DaemonCdpManager, managerKey: string) => void | Promise<void>;
2612
+ /** Poller callback (transport-specific) */
2613
+ onStreamsUpdated?: (ideType: string, streams: any[]) => void;
2614
+ /** Instance ticking interval (ms), default 5000 */
2615
+ tickIntervalMs?: number;
2616
+ /** CDP scan interval (ms), default 30000 */
2617
+ cdpScanIntervalMs?: number;
2618
+ }
2619
+ interface DaemonComponents {
2620
+ providerLoader: ProviderLoader;
2621
+ instanceManager: ProviderInstanceManager;
2622
+ cliManager: DaemonCliManager;
2623
+ commandHandler: DaemonCommandHandler;
2624
+ agentStreamManager: DaemonAgentStreamManager;
2625
+ router: DaemonCommandRouter;
2626
+ poller: AgentStreamPoller;
2627
+ cdpInitializer: DaemonCdpInitializer;
2628
+ cdpManagers: Map<string, DaemonCdpManager>;
2629
+ instanceIdMap: Map<string, string>;
2630
+ detectedIdes: {
2631
+ value: any[];
2632
+ };
2633
+ }
2634
+ /**
2635
+ * Initialize all daemon core components.
2636
+ * Shared by both cloud and standalone daemons.
2637
+ *
2638
+ * Order:
2639
+ * 1. Global log interceptor
2640
+ * 2. ProviderLoader
2641
+ * 3. InstanceManager + CliManager
2642
+ * 4. Detect IDEs
2643
+ * 5. CdpInitializer → connectAll + periodic scan + discovery
2644
+ * 6. CommandHandler + AgentStreamManager
2645
+ * 7. Router + Poller
2646
+ * 8. Start instance ticking
2647
+ */
2648
+ declare function initDaemonComponents(config: DaemonInitConfig): Promise<DaemonComponents>;
2649
+ /**
2650
+ * Graceful shutdown of all daemon components.
2651
+ * Shared by both cloud and standalone daemons.
2652
+ *
2653
+ * Order:
2654
+ * 1. Stop timers (poller, cdpInitializer)
2655
+ * 2. Dispose agent stream
2656
+ * 3. Shutdown CLIs
2657
+ * 4. Dispose instances
2658
+ * 5. Disconnect CDPs
2659
+ */
2660
+ declare function shutdownDaemonComponents(components: DaemonComponents): Promise<void>;
2661
+
2662
+ export { type AcpEntry, AcpProviderInstance, type AgentEntry, type AgentStreamEntry, AgentStreamPoller, type AgentStreamPollerDeps, CdpDomHandlers, type CdpInitializerConfig, type CdpScannerOptions, type CdpSetupContext, type CdpTargetFilter, type ChatMessage, type CliAdapter, type CliEntry, CliProviderInstance, 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, type DaemonStatus, DaemonStatusReporter, type DetectedIde, DevServer, type ExtensionInfo$1 as ExtensionInfo, type IDEInfo, type IDaemonCore, type IdeEntry, IdeProviderInstance, type ExtensionInfo as InstallerExtensionInfo, LOG, type LogEntry, type LogLevel, ProviderCliAdapter, type ProviderConfig, type ProviderInfo, ProviderInstanceManager, ProviderLoader, type ProviderModule, type ProviderVersionInfo, type ScopedLogger, type SetupIdeInstanceOptions, type StatusResponse, type SystemInfo, VersionArchive, type VersionHistory, addCliHistory, connectCdpManager, detectAllVersions, detectCLIs, detectIDEs, getAIExtensions, getAvailableIdeIds, getLogLevel, getRecentCommands, getRecentLogs, initDaemonComponents, installExtensions, installGlobalInterceptor, isExtensionInstalled, isSetupComplete, launchIDE, launchWithCdp, loadConfig, logCommand, markSetupComplete, probeCdpPort, readChatHistory, registerExtensionProviders, resetConfig, saveConfig, setLogLevel, setupIdeInstance, shutdownDaemonComponents, updateConfig };