@adhdev/daemon-core 0.5.8 → 0.5.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,384 @@
1
+ /**
2
+ * ProviderInstance — Provider runtime lifecycle
3
+ *
4
+ * provider.js = static config/scripts
5
+ * ProviderInstance = runtime status management + lifecycle
6
+ *
7
+ * Daemon only collects via ProviderInstance.getState(),
8
+ * Each Instance manages its own status.
9
+ */
10
+
11
+ type ProviderStatus = 'idle' | 'generating' | 'waiting_approval' | 'error' | 'stopped' | 'starting';
12
+ interface ActiveChatData {
13
+ id: string;
14
+ title: string;
15
+ status: string;
16
+ messages: ChatMessage[];
17
+ activeModal: {
18
+ message: string;
19
+ buttons: string[];
20
+ } | null;
21
+ inputContent?: string;
22
+ }
23
+ /** Standardized error reasons across all provider categories */
24
+ type ProviderErrorReason = 'not_installed' | 'auth_failed' | 'spawn_error' | 'init_failed' | 'crash' | 'timeout' | 'cdp_error' | 'disconnected';
25
+ /** Common fields shared by all provider categories */
26
+ interface ProviderStateBase {
27
+ /** Provider type (e.g. 'gemini-cli', 'cursor', 'cline') */
28
+ type: string;
29
+ /** Provider Display name */
30
+ name: string;
31
+ /** current status */
32
+ status: ProviderStatus;
33
+ /** chat data */
34
+ activeChat: ActiveChatData | null;
35
+ /** Workspace — project path or name (all categories) */
36
+ workspace?: string | null;
37
+ /** Runtime info (real-time detection) */
38
+ currentModel?: string;
39
+ currentPlan?: string;
40
+ /** Error details (when status === 'error') */
41
+ errorMessage?: string;
42
+ errorReason?: ProviderErrorReason;
43
+ /** meta */
44
+ instanceId: string;
45
+ lastUpdated: number;
46
+ settings: Record<string, any>;
47
+ /** Event queue (cleared after daemon collects) */
48
+ pendingEvents: ProviderEvent[];
49
+ }
50
+ /** IDE provider state */
51
+ interface IdeProviderState extends ProviderStateBase {
52
+ category: 'ide';
53
+ cdpConnected: boolean;
54
+ /** IDE child Extension Instance status */
55
+ extensions: ProviderState[];
56
+ currentAutoApprove?: string;
57
+ }
58
+ /** CLI provider state */
59
+ interface CliProviderState extends ProviderStateBase {
60
+ category: 'cli';
61
+ /** terminal = PTY stream, chat = parsed conversation */
62
+ mode: 'terminal' | 'chat';
63
+ }
64
+ /** ACP provider state */
65
+ interface AcpProviderState extends ProviderStateBase {
66
+ category: 'acp';
67
+ mode: 'chat';
68
+ /** ACP config options (model/mode selection) */
69
+ acpConfigOptions?: AcpConfigOption[];
70
+ /** ACP available modes */
71
+ acpModes?: AcpMode[];
72
+ }
73
+ /** Extension provider state */
74
+ interface ExtensionProviderState extends ProviderStateBase {
75
+ category: 'extension';
76
+ agentStreams?: any[];
77
+ }
78
+ /** Discriminated union — switch on `.category` */
79
+ type ProviderState = IdeProviderState | CliProviderState | AcpProviderState | ExtensionProviderState;
80
+ interface ProviderEvent {
81
+ event: string;
82
+ timestamp: number;
83
+ [key: string]: any;
84
+ }
85
+ interface InstanceContext {
86
+ /** CDP connection (IDE/Extension) */
87
+ cdp?: {
88
+ isConnected: boolean;
89
+ evaluate(script: string, timeout?: number): Promise<unknown>;
90
+ evaluateInWebviewFrame?(expression: string, matchFn?: (bodyPreview: string) => boolean): Promise<string | null>;
91
+ discoverAgentWebviews?(): Promise<any[]>;
92
+ };
93
+ /** Server log transmit */
94
+ serverConn?: {
95
+ sendMessage(type: string, data: any): void;
96
+ };
97
+ /** P2P PTY output transmit */
98
+ onPtyData?: (data: string) => void;
99
+ /** Provider configvalue (resolved) */
100
+ settings: Record<string, any>;
101
+ }
102
+ interface ProviderInstance {
103
+ /** Provider type */
104
+ readonly type: string;
105
+ /** Provider category */
106
+ readonly category: 'cli' | 'ide' | 'extension' | 'acp';
107
+ /** initialize */
108
+ init(context: InstanceContext): Promise<void>;
109
+ /** Tick — periodic status refresh (IDE: readChat, Extension: stream collection) */
110
+ onTick(): Promise<void>;
111
+ /** Return current status */
112
+ getState(): ProviderState;
113
+ /** Receive event (external → Instance) */
114
+ onEvent(event: string, data?: any): void;
115
+ /** Update settings at runtime (called when user changes settings from dashboard) */
116
+ updateSettings?(newSettings: Record<string, any>): void;
117
+ /** cleanup */
118
+ dispose(): void;
119
+ }
120
+
121
+ /**
122
+ * Recent workspace activity — quick "pick up where you left off" (daemon-local).
123
+ */
124
+
125
+ interface WorkspaceActivityEntry {
126
+ path: string;
127
+ lastUsedAt: number;
128
+ /** `active` legacy — same meaning as default */
129
+ kind?: 'ide' | 'cli' | 'acp' | 'default' | 'active';
130
+ /** IDE id or CLI/ACP provider type */
131
+ agentType?: string;
132
+ }
133
+ declare function getWorkspaceActivity(config: ADHDevConfig, limit?: number): WorkspaceActivityEntry[];
134
+
135
+ /**
136
+ * ADHDev Launcher — Configuration
137
+ *
138
+ * Manages launcher config, server connection tokens, and user preferences.
139
+ */
140
+
141
+ interface ADHDevConfig {
142
+ serverUrl: string;
143
+ apiToken: string | null;
144
+ connectionToken: string | null;
145
+ selectedIde: string | null;
146
+ configuredIdes: string[];
147
+ installedExtensions: string[];
148
+ autoConnect: boolean;
149
+ notifications: boolean;
150
+ userEmail: string | null;
151
+ userName: string | null;
152
+ setupCompleted: boolean;
153
+ setupDate: string | null;
154
+ configuredCLIs: string[];
155
+ enabledIdes: string[];
156
+ recentCliWorkspaces: string[];
157
+ /** Saved workspaces for IDE/CLI/ACP launch (daemon-local) */
158
+ workspaces?: WorkspaceEntry[];
159
+ /** Default workspace id (from workspaces[]) — never used implicitly for launch */
160
+ defaultWorkspaceId?: string | null;
161
+ /** Recently used workspaces (IDE / CLI / ACP / default) for quick resume */
162
+ recentWorkspaceActivity?: WorkspaceActivityEntry[];
163
+ machineNickname: string | null;
164
+ cliHistory: CliHistoryEntry[];
165
+ providerSettings: Record<string, Record<string, any>>;
166
+ ideSettings: Record<string, {
167
+ extensions?: Record<string, {
168
+ enabled: boolean;
169
+ }>;
170
+ }>;
171
+ }
172
+ interface CliHistoryEntry {
173
+ cliType: string;
174
+ dir: string;
175
+ cliArgs?: string[];
176
+ timestamp: number;
177
+ label?: string;
178
+ }
179
+ /**
180
+ * Load configuration from disk
181
+ */
182
+ declare function loadConfig(): ADHDevConfig;
183
+ /**
184
+ * Save configuration to disk
185
+ */
186
+ declare function saveConfig(config: ADHDevConfig): void;
187
+ /**
188
+ * Update specific config fields
189
+ */
190
+ declare function updateConfig(updates: Partial<ADHDevConfig>): ADHDevConfig;
191
+ /**
192
+ * Mark setup as completed
193
+ */
194
+ declare function markSetupComplete(ideId: string | string[], extensions: string[]): ADHDevConfig;
195
+ /**
196
+ * Check if setup has been completed before
197
+ */
198
+ declare function isSetupComplete(): boolean;
199
+ /**
200
+ * Reset configuration
201
+ */
202
+ declare function resetConfig(): void;
203
+ /**
204
+ * Add CLI launch to history (max 20, dedup by cliType+dir+args)
205
+ */
206
+ declare function addCliHistory(entry: Omit<CliHistoryEntry, 'timestamp'>): void;
207
+
208
+ /**
209
+ * Saved workspaces — shared by IDE launch, CLI, ACP (daemon-local).
210
+ */
211
+
212
+ interface WorkspaceEntry {
213
+ id: string;
214
+ path: string;
215
+ label?: string;
216
+ addedAt: number;
217
+ }
218
+ declare function getWorkspaceState(config: ADHDevConfig): {
219
+ workspaces: WorkspaceEntry[];
220
+ defaultWorkspaceId: string | null;
221
+ defaultWorkspacePath: string | null;
222
+ };
223
+
224
+ /**
225
+ * ADHDev Shared Types — Cross-package type definitions
226
+ *
227
+ * Types used across daemon-core, web-core, web-cloud, server, etc.
228
+ * Import via: import type { ... } from '@adhdev/daemon-core/types'
229
+ *
230
+ * IMPORTANT: This file must remain runtime-free (types only).
231
+ * Cloudflare Workers (server) can import type-only modules safely.
232
+ */
233
+
234
+ /** IDE entry as reported by daemon to server/dashboard */
235
+ interface ManagedIdeEntry {
236
+ ideType: string;
237
+ ideVersion: string;
238
+ instanceId: string;
239
+ workspace: string | null;
240
+ terminals: number;
241
+ aiAgents: unknown[];
242
+ activeChat: ActiveChatData | null;
243
+ chats: unknown[];
244
+ agentStreams: ManagedAgentStream[];
245
+ cdpConnected: boolean;
246
+ currentModel?: string;
247
+ currentPlan?: string;
248
+ currentAutoApprove?: string;
249
+ }
250
+ /** CLI entry as reported by daemon to server/dashboard */
251
+ interface ManagedCliEntry {
252
+ id: string;
253
+ instanceId: string;
254
+ cliType: string;
255
+ cliName: string;
256
+ status: string;
257
+ mode: 'terminal' | 'chat';
258
+ workspace: string;
259
+ activeChat: ActiveChatData | null;
260
+ }
261
+ /** ACP entry as reported by daemon to server/dashboard */
262
+ interface ManagedAcpEntry {
263
+ id: string;
264
+ acpType: string;
265
+ acpName: string;
266
+ status: string;
267
+ mode: 'chat';
268
+ workspace: string;
269
+ activeChat: ActiveChatData | null;
270
+ currentModel?: string;
271
+ currentPlan?: string;
272
+ acpConfigOptions?: AcpConfigOption[];
273
+ acpModes?: AcpMode[];
274
+ /** Error details */
275
+ errorMessage?: string;
276
+ errorReason?: 'not_installed' | 'auth_failed' | 'spawn_error' | 'init_failed' | 'crash' | 'timeout' | 'cdp_error' | 'disconnected';
277
+ }
278
+ /** Agent stream within an IDE (extension status) */
279
+ interface ManagedAgentStream {
280
+ agentType: string;
281
+ agentName: string;
282
+ extensionId: string;
283
+ status: string;
284
+ messages: ChatMessage[];
285
+ inputContent: string;
286
+ model?: string;
287
+ activeModal: {
288
+ message: string;
289
+ buttons: string[];
290
+ } | null;
291
+ }
292
+ /** Available provider information */
293
+ interface AvailableProviderInfo {
294
+ type: string;
295
+ name: string;
296
+ category: 'ide' | 'extension' | 'cli' | 'acp';
297
+ displayName: string;
298
+ icon: string;
299
+ }
300
+ /** ACP config option (model/mode/thought_level selection) */
301
+ interface AcpConfigOption {
302
+ category: 'model' | 'mode' | 'thought_level' | 'other';
303
+ configId: string;
304
+ currentValue?: string;
305
+ options: {
306
+ value: string;
307
+ name: string;
308
+ description?: string;
309
+ group?: string;
310
+ }[];
311
+ }
312
+ /** ACP mode */
313
+ interface AcpMode {
314
+ id: string;
315
+ name: string;
316
+ description?: string;
317
+ }
318
+ /** Machine hardware/OS info (reported by daemon, displayed by web) */
319
+ interface MachineInfo {
320
+ hostname: string;
321
+ platform: string;
322
+ arch: string;
323
+ cpus: number;
324
+ totalMem: number;
325
+ freeMem: number;
326
+ /** macOS: reclaimable-inclusive; prefer for UI used% */
327
+ availableMem?: number;
328
+ loadavg: number[];
329
+ uptime: number;
330
+ release: string;
331
+ }
332
+ /** Detected IDE on a machine */
333
+ interface DetectedIdeInfo {
334
+ type: string;
335
+ id?: string;
336
+ name: string;
337
+ running: boolean;
338
+ path?: string;
339
+ }
340
+ /** Workspace recent activity */
341
+ interface WorkspaceActivity {
342
+ path: string;
343
+ lastUsedAt: number;
344
+ kind?: string;
345
+ agentType?: string;
346
+ }
347
+ interface StatusReportPayload {
348
+ /** Daemon instance ID */
349
+ instanceId: string;
350
+ /** Daemon version */
351
+ version: string;
352
+ /** Daemon mode flag */
353
+ daemonMode: boolean;
354
+ /** Machine info */
355
+ machine: MachineInfo;
356
+ /** Machine nickname (user-set) */
357
+ machineNickname?: string | null;
358
+ /** Timestamp */
359
+ timestamp: number;
360
+ /** Detected IDEs on this machine */
361
+ detectedIdes: DetectedIdeInfo[];
362
+ /** P2P state */
363
+ p2p?: {
364
+ available: boolean;
365
+ state: string;
366
+ peers: number;
367
+ screenshotActive?: boolean;
368
+ };
369
+ /** Managed IDE instances */
370
+ managedIdes: ManagedIdeEntry[];
371
+ /** Managed CLI instances */
372
+ managedClis: ManagedCliEntry[];
373
+ /** Managed ACP instances */
374
+ managedAcps: ManagedAcpEntry[];
375
+ /** Saved workspaces */
376
+ workspaces?: WorkspaceEntry[];
377
+ defaultWorkspaceId?: string | null;
378
+ defaultWorkspacePath?: string | null;
379
+ workspaceActivity?: WorkspaceActivity[];
380
+ }
381
+
1
382
  /**
2
383
  * ContentBlock — ACP ContentBlock union type
3
384
  * Represents displayable content in messages, tool call results, etc.
@@ -44,12 +425,12 @@ interface ResourceBlock {
44
425
  interface TextResourceContents {
45
426
  uri: string;
46
427
  text: string;
47
- mimeType?: string;
428
+ mimeType?: string | null;
48
429
  }
49
430
  interface BlobResourceContents {
50
431
  uri: string;
51
432
  blob: string;
52
- mimeType?: string;
433
+ mimeType?: string | null;
53
434
  }
54
435
  interface ContentAnnotations {
55
436
  audience?: ('user' | 'assistant')[];
@@ -83,7 +464,7 @@ type ToolCallContent = {
83
464
  };
84
465
  interface ToolCallLocation {
85
466
  path: string;
86
- line?: number;
467
+ line?: number | null;
87
468
  }
88
469
  type ProviderCategory = 'cli' | 'ide' | 'extension' | 'acp';
89
470
  /**
@@ -312,77 +693,20 @@ interface ProviderSettingSchema extends ProviderSettingDef {
312
693
  * Shared types referenced by daemon-core, daemon-standalone, daemon-cloud, web-core.
313
694
  * When modifying this file, also update interface contracts in AGENT_PROTOCOL.md.
314
695
  */
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
- /** IDE-reported workspace roots (name + path) */
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}" */
696
+
697
+ /** Full status response from /api/v1/status and WS events */
698
+ interface StatusResponse extends StatusReportPayload {
699
+ /** For standalone API compat */
376
700
  id: string;
377
- acpId: string;
378
- /** Agent type: "gemini-acp", "cline-acp", etc. */
379
701
  type: string;
380
- name?: string;
381
- /** Process running state */
382
- isRunning?: boolean;
383
- /** Error state */
384
- errorReason?: string;
385
- errorMessage?: string;
702
+ platform: string;
703
+ hostname: string;
704
+ /** User display name from config */
705
+ userName?: string;
706
+ /** Available providers */
707
+ availableProviders: ProviderInfo[];
708
+ /** System info (legacy compat) */
709
+ system?: SystemInfo;
386
710
  }
387
711
  interface ChatMessage {
388
712
  role: string;
@@ -390,9 +714,21 @@ interface ChatMessage {
390
714
  content: string | ContentBlock[];
391
715
  kind?: string;
392
716
  id?: string;
717
+ index?: number;
393
718
  timestamp?: number;
719
+ receivedAt?: number;
394
720
  /** Tool calls associated with this message */
395
721
  toolCalls?: ToolCallInfo[];
722
+ /** Optional: fiber metadata */
723
+ _type?: string;
724
+ _sub?: string;
725
+ /** Meta information for thought/terminal logs etc */
726
+ meta?: {
727
+ label?: string;
728
+ isRunning?: boolean;
729
+ } | Record<string, any>;
730
+ /** Sender name for shared sessions */
731
+ senderName?: string;
396
732
  }
397
733
 
398
734
  interface ExtensionInfo$1 {
@@ -421,7 +757,7 @@ interface ProviderConfig {
421
757
  }
422
758
  type DaemonEvent = {
423
759
  type: 'status';
424
- data: DaemonStatus;
760
+ data: StatusResponse;
425
761
  } | {
426
762
  type: 'chat_update';
427
763
  data: {
@@ -470,48 +806,6 @@ interface ProviderInfo {
470
806
  displayName: string;
471
807
  category: string;
472
808
  }
473
- /** Full status response from /api/v1/status */
474
- interface StatusResponse {
475
- id: string;
476
- type: string;
477
- platform: string;
478
- hostname: string;
479
- timestamp: number;
480
- ides: IdeEntry[];
481
- clis: CliEntry[];
482
- cdpConnected: boolean;
483
- detectedIdes: DetectedIde[];
484
- availableProviders: ProviderInfo[];
485
- system: SystemInfo;
486
- /** Saved workspaces (standalone WS / HTTP status) */
487
- workspaces?: {
488
- id: string;
489
- path: string;
490
- label?: string;
491
- addedAt: number;
492
- }[];
493
- defaultWorkspaceId?: string | null;
494
- defaultWorkspacePath?: string | null;
495
- workspaceActivity?: {
496
- path: string;
497
- lastUsedAt: number;
498
- kind?: string;
499
- agentType?: string;
500
- }[];
501
- }
502
- /** Agent stream entry within an IDE */
503
- interface AgentStreamEntry {
504
- agentType: string;
505
- agentName: string;
506
- extensionId: string;
507
- status: string;
508
- messages: unknown[];
509
- inputContent: string;
510
- activeModal: {
511
- message: string;
512
- buttons: string[];
513
- } | null;
514
- }
515
809
  /** Flattened agent entry from /api/v1/agents */
516
810
  interface AgentEntry {
517
811
  ideId: string;
@@ -546,123 +840,20 @@ interface IDaemonCore {
546
840
  /** Gracefully stop the daemon */
547
841
  stop(): Promise<void>;
548
842
  /** Get current daemon status snapshot */
549
- getStatus(): DaemonStatus;
843
+ getStatus(): StatusResponse;
550
844
  /** Subscribe to status changes. Returns unsubscribe function. */
551
- onStatusChange(callback: (status: DaemonStatus) => void): () => void;
845
+ onStatusChange(callback: (status: StatusResponse) => void): () => void;
552
846
  /** Subscribe to all daemon events. Returns unsubscribe function. */
553
847
  onEvent(callback: (event: DaemonEvent) => void): () => void;
554
848
  /** Execute a command (send_chat, new_session, etc.) */
555
849
  executeCommand(type: string, payload: any, target?: string): Promise<CommandResult$2>;
556
850
  /** Get currently detected/managed IDEs */
557
- getManagedIdes(): IdeEntry[];
851
+ getManagedIdes(): ManagedIdeEntry[];
558
852
  /** Get currently detected/managed CLIs */
559
- getManagedClis(): CliEntry[];
853
+ getManagedClis(): ManagedCliEntry[];
560
854
  /** Get currently detected/managed ACP agents */
561
- getManagedAcps(): AcpEntry[];
562
- }
563
-
564
- /**
565
- * Saved workspaces — shared by IDE launch, CLI, ACP (daemon-local).
566
- */
567
-
568
- interface WorkspaceEntry {
569
- id: string;
570
- path: string;
571
- label?: string;
572
- addedAt: number;
573
- }
574
- declare function getWorkspaceState(config: ADHDevConfig): {
575
- workspaces: WorkspaceEntry[];
576
- defaultWorkspaceId: string | null;
577
- defaultWorkspacePath: string | null;
578
- };
579
-
580
- /**
581
- * Recent workspace activity — quick "pick up where you left off" (daemon-local).
582
- */
583
-
584
- interface WorkspaceActivityEntry {
585
- path: string;
586
- lastUsedAt: number;
587
- /** `active` legacy — same meaning as default */
588
- kind?: 'ide' | 'cli' | 'acp' | 'default' | 'active';
589
- /** IDE id or CLI/ACP provider type */
590
- agentType?: string;
591
- }
592
- declare function getWorkspaceActivity(config: ADHDevConfig, limit?: number): WorkspaceActivityEntry[];
593
-
594
- /**
595
- * ADHDev Launcher — Configuration
596
- *
597
- * Manages launcher config, server connection tokens, and user preferences.
598
- */
599
-
600
- interface ADHDevConfig {
601
- serverUrl: string;
602
- apiToken: string | null;
603
- connectionToken: string | null;
604
- selectedIde: string | null;
605
- configuredIdes: string[];
606
- installedExtensions: string[];
607
- autoConnect: boolean;
608
- notifications: boolean;
609
- userEmail: string | null;
610
- userName: string | null;
611
- setupCompleted: boolean;
612
- setupDate: string | null;
613
- configuredCLIs: string[];
614
- enabledIdes: string[];
615
- recentCliWorkspaces: string[];
616
- /** Saved workspaces for IDE/CLI/ACP launch (daemon-local) */
617
- workspaces?: WorkspaceEntry[];
618
- /** Default workspace id (from workspaces[]) — never used implicitly for launch */
619
- defaultWorkspaceId?: string | null;
620
- /** Recently used workspaces (IDE / CLI / ACP / default) for quick resume */
621
- recentWorkspaceActivity?: WorkspaceActivityEntry[];
622
- machineNickname: string | null;
623
- cliHistory: CliHistoryEntry[];
624
- providerSettings: Record<string, Record<string, any>>;
625
- ideSettings: Record<string, {
626
- extensions?: Record<string, {
627
- enabled: boolean;
628
- }>;
629
- }>;
855
+ getManagedAcps(): ManagedAcpEntry[];
630
856
  }
631
- interface CliHistoryEntry {
632
- cliType: string;
633
- dir: string;
634
- cliArgs?: string[];
635
- timestamp: number;
636
- label?: string;
637
- }
638
- /**
639
- * Load configuration from disk
640
- */
641
- declare function loadConfig(): ADHDevConfig;
642
- /**
643
- * Save configuration to disk
644
- */
645
- declare function saveConfig(config: ADHDevConfig): void;
646
- /**
647
- * Update specific config fields
648
- */
649
- declare function updateConfig(updates: Partial<ADHDevConfig>): ADHDevConfig;
650
- /**
651
- * Mark setup as completed
652
- */
653
- declare function markSetupComplete(ideId: string | string[], extensions: string[]): ADHDevConfig;
654
- /**
655
- * Check if setup has been completed before
656
- */
657
- declare function isSetupComplete(): boolean;
658
- /**
659
- * Reset configuration
660
- */
661
- declare function resetConfig(): void;
662
- /**
663
- * Add CLI launch to history (max 20, dedup by cliType+dir+args)
664
- */
665
- declare function addCliHistory(entry: Omit<CliHistoryEntry, 'timestamp'>): void;
666
857
 
667
858
  /**
668
859
  * ADHDev — IDE Detector (canonical implementation)
@@ -1148,106 +1339,6 @@ declare class DaemonCdpManager {
1148
1339
  }): Promise<Buffer | null>;
1149
1340
  }
1150
1341
 
1151
- /**
1152
- * ProviderInstance — Provider runtime lifecycle
1153
- *
1154
- * provider.js = static config/scripts
1155
- * ProviderInstance = runtime status management + lifecycle
1156
- *
1157
- * Daemon only collects via ProviderInstance.getState(),
1158
- * Each Instance manages its own status.
1159
- */
1160
- interface ProviderState {
1161
- /** Provider type (e.g. 'gemini-cli', 'cursor', 'cline') */
1162
- type: string;
1163
- /** Provider Display name */
1164
- name: string;
1165
- /** category */
1166
- category: 'cli' | 'ide' | 'extension' | 'acp';
1167
- /** current status */
1168
- status: 'idle' | 'generating' | 'waiting_approval' | 'error' | 'stopped' | 'starting';
1169
- /** CLI mode: terminal = PTY stream, chat = parsed conversation */
1170
- mode?: 'terminal' | 'chat';
1171
- /** chat data */
1172
- activeChat: {
1173
- id: string;
1174
- title: string;
1175
- status: string;
1176
- messages: {
1177
- role: string;
1178
- content: string;
1179
- timestamp?: number;
1180
- }[];
1181
- activeModal: {
1182
- message: string;
1183
- buttons: string[];
1184
- } | null;
1185
- inputContent?: string;
1186
- } | null;
1187
- /** IDE/Extension -only */
1188
- workspaceFolders?: {
1189
- name: string;
1190
- path: string;
1191
- }[];
1192
- activeFile?: string | null;
1193
- agentStreams?: any[];
1194
- cdpConnected?: boolean;
1195
- /** IDE child Extension Instance status */
1196
- extensions?: ProviderState[];
1197
- /** CLI -only */
1198
- workingDir?: string;
1199
- /** Runtime info (real-time detection from IDE/CLI) */
1200
- currentModel?: string;
1201
- currentPlan?: string;
1202
- currentAutoApprove?: string;
1203
- /** meta */
1204
- instanceId: string;
1205
- lastUpdated: number;
1206
- settings: Record<string, any>;
1207
- /** Event queue (cleared after daemon collects) */
1208
- pendingEvents: ProviderEvent[];
1209
- }
1210
- interface ProviderEvent {
1211
- event: string;
1212
- timestamp: number;
1213
- [key: string]: any;
1214
- }
1215
- interface InstanceContext {
1216
- /** CDP connection (IDE/Extension) */
1217
- cdp?: {
1218
- isConnected: boolean;
1219
- evaluate(script: string, timeout?: number): Promise<unknown>;
1220
- evaluateInWebviewFrame?(expression: string, matchFn?: (bodyPreview: string) => boolean): Promise<string | null>;
1221
- discoverAgentWebviews?(): Promise<any[]>;
1222
- };
1223
- /** Server log transmit */
1224
- serverConn?: {
1225
- sendMessage(type: string, data: any): void;
1226
- };
1227
- /** P2P PTY output transmit */
1228
- onPtyData?: (data: string) => void;
1229
- /** Provider configvalue (resolved) */
1230
- settings: Record<string, any>;
1231
- }
1232
- interface ProviderInstance {
1233
- /** Provider type */
1234
- readonly type: string;
1235
- /** Provider category */
1236
- readonly category: 'cli' | 'ide' | 'extension' | 'acp';
1237
- /** initialize */
1238
- init(context: InstanceContext): Promise<void>;
1239
- /** Tick — periodic status refresh (IDE: readChat, Extension: stream collection) */
1240
- onTick(): Promise<void>;
1241
- /** Return current status */
1242
- getState(): ProviderState;
1243
- /** Receive event (external → Instance) */
1244
- onEvent(event: string, data?: any): void;
1245
- /** Update settings at runtime (called when user changes settings from dashboard) */
1246
- updateSettings?(newSettings: Record<string, any>): void;
1247
- /** cleanup */
1248
- dispose(): void;
1249
- }
1250
-
1251
1342
  /**
1252
1343
  * ProviderInstanceManager — lifecycle management for all ProviderInstances
1253
1344
  *
@@ -1722,8 +1813,7 @@ declare class IdeProviderInstance implements ProviderInstance {
1722
1813
  private historyWriter;
1723
1814
  private ideVersion;
1724
1815
  private instanceId;
1725
- private workspaceFolders;
1726
- private activeFile;
1816
+ private workspace;
1727
1817
  private extensions;
1728
1818
  constructor(provider: ProviderModule, instanceKey?: string);
1729
1819
  init(context: InstanceContext): Promise<void>;
@@ -1743,6 +1833,8 @@ declare class IdeProviderInstance implements ProviderInstance {
1743
1833
  getInstanceId(): string;
1744
1834
  /** all Extension Instance list */
1745
1835
  getExtensionInstances(): ExtensionProviderInstance[];
1836
+ /** Set workspace from daemon launch context */
1837
+ setWorkspace(workspace: string): void;
1746
1838
  private readChat;
1747
1839
  private getReadChatScript;
1748
1840
  private detectAgentTransitions;
@@ -2050,7 +2142,7 @@ declare class DaemonCommandRouter {
2050
2142
  */
2051
2143
  private executeDaemonCommand;
2052
2144
  /**
2053
- * IDE stop: CDP disconnect + remove from InstanceManager + clean instanceIdMap
2145
+ * IDE stop: CDP disconnect + InstanceManager cleanup + optionally kill OS process
2054
2146
  */
2055
2147
  private stopIde;
2056
2148
  }
@@ -2061,6 +2153,7 @@ declare class DaemonCommandRouter {
2061
2153
  * Collect status from ProviderInstanceManager → assemble payload → transmit
2062
2154
  * Each Instance manages its own status/transition. This module only assembles + transmits.
2063
2155
  */
2156
+
2064
2157
  interface StatusReporterDeps {
2065
2158
  serverConn: {
2066
2159
  isConnected(): boolean;
@@ -2091,9 +2184,10 @@ interface StatusReporterDeps {
2091
2184
  }>;
2092
2185
  detectedIdes: any[];
2093
2186
  ideType: string;
2187
+ daemonVersion?: string;
2094
2188
  instanceManager: {
2095
- collectAllStates(): any[];
2096
- collectStatesByCategory(cat: string): any[];
2189
+ collectAllStates(): ProviderState[];
2190
+ collectStatesByCategory(cat: string): ProviderState[];
2097
2191
  };
2098
2192
  }
2099
2193
  declare class DaemonStatusReporter {
@@ -2248,6 +2342,10 @@ declare function getRecentCommands(count?: number): CommandLogEntry[];
2248
2342
  * adhdev launch cursor — Launch Cursor with CDP port
2249
2343
  * adhdev launch --workspace /path — Open specific workspace
2250
2344
  */
2345
+ /** Kill IDE process (graceful → force) */
2346
+ declare function killIdeProcess(ideId: string): Promise<boolean>;
2347
+ /** Check if IDE process is running */
2348
+ declare function isIdeRunning(ideId: string): boolean;
2251
2349
  interface LaunchOptions {
2252
2350
  ideId?: string;
2253
2351
  workspace?: string;
@@ -2370,7 +2468,10 @@ declare class ProviderCliAdapter implements CliAdapter {
2370
2468
  private approvalTransitionBuffer;
2371
2469
  private approvalExitTimeout;
2372
2470
  private resizeSuppressUntil;
2471
+ private statusHistory;
2472
+ private setStatus;
2373
2473
  private readonly timeouts;
2474
+ private readonly approvalKeys;
2374
2475
  constructor(provider: CliProviderModule, workingDir: string, extraArgs?: string[]);
2375
2476
  setServerConn(serverConn: any): void;
2376
2477
  setOnStatusChange(callback: () => void): void;
@@ -2394,6 +2495,11 @@ declare class ProviderCliAdapter implements CliAdapter {
2394
2495
  */
2395
2496
  resolveModal(buttonIndex: number): void;
2396
2497
  resize(cols: number, rows: number): void;
2498
+ /**
2499
+ * Full debug state — exposes all internal buffers, status, and patterns for debugging.
2500
+ * Used by DevServer /api/cli/debug endpoint.
2501
+ */
2502
+ getDebugState(): Record<string, any>;
2397
2503
  }
2398
2504
 
2399
2505
  /**
@@ -2416,6 +2522,8 @@ declare class CliProviderInstance implements ProviderInstance {
2416
2522
  private generatingStartedAt;
2417
2523
  private settings;
2418
2524
  private monitor;
2525
+ private generatingDebounceTimer;
2526
+ private generatingDebouncePending;
2419
2527
  private historyWriter;
2420
2528
  readonly instanceId: string;
2421
2529
  constructor(provider: ProviderModule, workingDir: string, cliArgs?: string[], instanceId?: string);
@@ -2491,7 +2599,7 @@ declare class AcpProviderInstance implements ProviderInstance {
2491
2599
  constructor(provider: ProviderModule, workingDir: string, cliArgs?: string[]);
2492
2600
  init(context: InstanceContext): Promise<void>;
2493
2601
  onTick(): Promise<void>;
2494
- getState(): ProviderState;
2602
+ getState(): AcpProviderState;
2495
2603
  onEvent(event: string, data?: any): void;
2496
2604
  private parseConfigOptions;
2497
2605
  private parseModes;
@@ -2552,6 +2660,8 @@ declare class DevServer {
2552
2660
  private server;
2553
2661
  private providerLoader;
2554
2662
  private cdpManagers;
2663
+ private instanceManager;
2664
+ private cliManager;
2555
2665
  private logFn;
2556
2666
  private sseClients;
2557
2667
  private watchScriptPath;
@@ -2560,9 +2670,12 @@ declare class DevServer {
2560
2670
  private autoImplProcess;
2561
2671
  private autoImplSSEClients;
2562
2672
  private autoImplStatus;
2673
+ private cliSSEClients;
2563
2674
  constructor(options: {
2564
2675
  providerLoader: ProviderLoader;
2565
2676
  cdpManagers: Map<string, DaemonCdpManager>;
2677
+ instanceManager?: ProviderInstanceManager;
2678
+ cliManager?: DaemonCliManager;
2566
2679
  logFn?: (msg: string) => void;
2567
2680
  });
2568
2681
  private log;
@@ -2621,6 +2734,23 @@ declare class DevServer {
2621
2734
  private getAnyCdp;
2622
2735
  private json;
2623
2736
  private readBody;
2737
+ /** GET /api/cli/status — list all running CLI/ACP instances with state */
2738
+ private handleCliStatus;
2739
+ /** POST /api/cli/launch — launch a CLI agent { type, workingDir?, args? } */
2740
+ private handleCliLaunch;
2741
+ /** POST /api/cli/send — send message to a running CLI { type, text } */
2742
+ private handleCliSend;
2743
+ /** POST /api/cli/stop — stop a running CLI { type } */
2744
+ private handleCliStop;
2745
+ /** GET /api/cli/events — SSE stream of CLI status events */
2746
+ private handleCliSSE;
2747
+ private sendCliSSE;
2748
+ /** GET /api/cli/debug/:type — full internal debug state of a CLI adapter */
2749
+ private handleCliDebug;
2750
+ /** POST /api/cli/resolve — resolve an approval modal { type, buttonIndex } */
2751
+ private handleCliResolve;
2752
+ /** POST /api/cli/raw — send raw keystrokes to PTY { type, keys } */
2753
+ private handleCliRaw;
2624
2754
  }
2625
2755
 
2626
2756
  /**
@@ -2745,4 +2875,4 @@ declare function initDaemonComponents(config: DaemonInitConfig): Promise<DaemonC
2745
2875
  */
2746
2876
  declare function shutdownDaemonComponents(components: DaemonComponents): Promise<void>;
2747
2877
 
2748
- 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 HostMemorySnapshot, 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, type WorkspaceEntry, addCliHistory, connectCdpManager, detectAllVersions, detectCLIs, detectIDEs, getAIExtensions, getAvailableIdeIds, getHostMemorySnapshot, getLogLevel, getRecentCommands, getRecentLogs, getWorkspaceActivity, getWorkspaceState, initDaemonComponents, installExtensions, installGlobalInterceptor, isExtensionInstalled, isSetupComplete, launchIDE, launchWithCdp, loadConfig, logCommand, markSetupComplete, probeCdpPort, readChatHistory, registerExtensionProviders, resetConfig, saveConfig, setLogLevel, setupIdeInstance, shutdownDaemonComponents, updateConfig };
2878
+ export { type AcpConfigOption, type AcpMode, AcpProviderInstance, type AcpProviderState, type ActiveChatData, type AgentEntry, AgentStreamPoller, type AgentStreamPollerDeps, type AvailableProviderInfo, CdpDomHandlers, type CdpInitializerConfig, type CdpScannerOptions, type CdpSetupContext, type CdpTargetFilter, type ChatMessage, type CliAdapter, CliProviderInstance, type CliProviderState, type CommandContext, type CommandResult$1 as CommandResult, type CommandRouterDeps, type CommandRouterResult, type CommandResult$2 as CoreCommandResult, DAEMON_WS_PATH, DEFAULT_DAEMON_PORT, DaemonAgentStreamManager, DaemonCdpInitializer, DaemonCdpManager, DaemonCdpScanner, DaemonCliManager, DaemonCommandHandler, DaemonCommandRouter, type DaemonComponents, type DaemonCoreOptions, type DaemonEvent, type DaemonInitConfig, DaemonStatusReporter, type DetectedIde, type DetectedIdeInfo, DevServer, type ExtensionInfo$1 as ExtensionInfo, type ExtensionProviderState, type HostMemorySnapshot, type IDEInfo, type IDaemonCore, IdeProviderInstance, type IdeProviderState, type ExtensionInfo as InstallerExtensionInfo, LOG, type LogEntry, type LogLevel, type MachineInfo, type ManagedAcpEntry, type ManagedAgentStream, type ManagedCliEntry, type ManagedIdeEntry, ProviderCliAdapter, type ProviderConfig, type ProviderErrorReason, type ProviderInfo, ProviderInstanceManager, ProviderLoader, type ProviderModule, type ProviderStatus, type ProviderVersionInfo, type ScopedLogger, type SetupIdeInstanceOptions, type StatusReportPayload, type StatusResponse, type SystemInfo, VersionArchive, type VersionHistory, type WorkspaceActivity, type WorkspaceEntry, addCliHistory, connectCdpManager, detectAllVersions, detectCLIs, detectIDEs, getAIExtensions, getAvailableIdeIds, getHostMemorySnapshot, getLogLevel, getRecentCommands, getRecentLogs, getWorkspaceActivity, getWorkspaceState, initDaemonComponents, installExtensions, installGlobalInterceptor, isExtensionInstalled, isIdeRunning, isSetupComplete, killIdeProcess, launchIDE, launchWithCdp, loadConfig, logCommand, markSetupComplete, probeCdpPort, readChatHistory, registerExtensionProviders, resetConfig, saveConfig, setLogLevel, setupIdeInstance, shutdownDaemonComponents, updateConfig };