@adhdev/daemon-core 0.6.77 → 0.7.0

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.
@@ -0,0 +1,843 @@
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
+ terminalHistory?: string;
22
+ inputContent?: string;
23
+ }
24
+ /** Standardized error reasons across all provider categories */
25
+ type ProviderErrorReason = 'not_installed' | 'auth_failed' | 'spawn_error' | 'init_failed' | 'crash' | 'timeout' | 'cdp_error' | 'disconnected';
26
+ /** Common fields shared by all provider categories */
27
+ interface ProviderStateBase {
28
+ /** Provider type (e.g. 'gemini-cli', 'cursor', 'cline') */
29
+ type: string;
30
+ /** Provider Display name */
31
+ name: string;
32
+ /** current status */
33
+ status: ProviderStatus;
34
+ /** chat data */
35
+ activeChat: ActiveChatData | null;
36
+ /** Workspace — project path or name (all categories) */
37
+ workspace?: string | null;
38
+ /** Runtime info (real-time detection) */
39
+ currentModel?: string;
40
+ currentPlan?: string;
41
+ /** Error details (when status === 'error') */
42
+ errorMessage?: string;
43
+ errorReason?: ProviderErrorReason;
44
+ /** meta */
45
+ instanceId: string;
46
+ lastUpdated: number;
47
+ settings: Record<string, any>;
48
+ /** Event queue (cleared after daemon collects) */
49
+ pendingEvents: ProviderEvent[];
50
+ }
51
+ /** IDE provider state */
52
+ interface IdeProviderState extends ProviderStateBase {
53
+ category: 'ide';
54
+ cdpConnected: boolean;
55
+ /** IDE child Extension Instance status */
56
+ extensions: ProviderState[];
57
+ currentAutoApprove?: string;
58
+ }
59
+ /** CLI provider state */
60
+ interface CliProviderState extends ProviderStateBase {
61
+ category: 'cli';
62
+ /** terminal = PTY stream, chat = parsed conversation */
63
+ mode: 'terminal' | 'chat';
64
+ }
65
+ /** ACP provider state */
66
+ interface AcpProviderState extends ProviderStateBase {
67
+ category: 'acp';
68
+ mode: 'chat';
69
+ /** ACP config options (model/mode selection) */
70
+ acpConfigOptions?: AcpConfigOption[];
71
+ /** ACP available modes */
72
+ acpModes?: AcpMode[];
73
+ }
74
+ /** Extension provider state */
75
+ interface ExtensionProviderState extends ProviderStateBase {
76
+ category: 'extension';
77
+ agentStreams?: any[];
78
+ }
79
+ /** Discriminated union — switch on `.category` */
80
+ type ProviderState = IdeProviderState | CliProviderState | AcpProviderState | ExtensionProviderState;
81
+ interface ProviderEvent {
82
+ event: string;
83
+ timestamp: number;
84
+ [key: string]: any;
85
+ }
86
+ interface InstanceContext {
87
+ /** CDP connection (IDE/Extension) */
88
+ cdp?: {
89
+ isConnected: boolean;
90
+ evaluate(script: string, timeout?: number): Promise<unknown>;
91
+ evaluateInWebviewFrame?(expression: string, matchFn?: (bodyPreview: string) => boolean): Promise<string | null>;
92
+ discoverAgentWebviews?(): Promise<any[]>;
93
+ };
94
+ /** Server log transmit */
95
+ serverConn?: {
96
+ sendMessage(type: string, data: any): void;
97
+ };
98
+ /** P2P PTY output transmit */
99
+ onPtyData?: (data: string) => void;
100
+ /** Provider configvalue (resolved) */
101
+ settings: Record<string, any>;
102
+ }
103
+ interface ProviderInstance {
104
+ /** Provider type */
105
+ readonly type: string;
106
+ /** Provider category */
107
+ readonly category: 'cli' | 'ide' | 'extension' | 'acp';
108
+ /** initialize */
109
+ init(context: InstanceContext): Promise<void>;
110
+ /** Tick — periodic status refresh (IDE: readChat, Extension: stream collection) */
111
+ onTick(): Promise<void>;
112
+ /** Return current status */
113
+ getState(): ProviderState;
114
+ /** Receive event (external → Instance) */
115
+ onEvent(event: string, data?: any): void;
116
+ /** Update settings at runtime (called when user changes settings from dashboard) */
117
+ updateSettings?(newSettings: Record<string, any>): void;
118
+ /** cleanup */
119
+ dispose(): void;
120
+ }
121
+
122
+ /**
123
+ * Recent workspace activity — quick "pick up where you left off" (daemon-local).
124
+ */
125
+
126
+ interface WorkspaceActivityEntry {
127
+ path: string;
128
+ lastUsedAt: number;
129
+ /** `active` legacy — same meaning as default */
130
+ kind?: 'ide' | 'cli' | 'acp' | 'default' | 'active';
131
+ /** IDE id or CLI/ACP provider type */
132
+ agentType?: string;
133
+ }
134
+ declare function getWorkspaceActivity(config: ADHDevConfig, limit?: number): WorkspaceActivityEntry[];
135
+
136
+ /**
137
+ * ADHDev Launcher — Configuration
138
+ *
139
+ * Manages launcher config, server connection tokens, and user preferences.
140
+ */
141
+
142
+ interface ADHDevConfig {
143
+ serverUrl: string;
144
+ apiToken: string | null;
145
+ connectionToken: string | null;
146
+ selectedIde: string | null;
147
+ configuredIdes: string[];
148
+ installedExtensions: string[];
149
+ autoConnect: boolean;
150
+ /**
151
+ * @deprecated Not read at runtime. Notification preferences are now managed by:
152
+ * - Web UI layer: useNotificationPrefs (localStorage)
153
+ * - Daemon layer: per-provider settings (approvalAlert, longGeneratingAlert)
154
+ * Kept for backward config compat — will be removed in v0.7+.
155
+ */
156
+ notifications: boolean;
157
+ userEmail: string | null;
158
+ userName: string | null;
159
+ setupCompleted: boolean;
160
+ setupDate: string | null;
161
+ configuredCLIs: string[];
162
+ enabledIdes: string[];
163
+ recentCliWorkspaces: string[];
164
+ /** Saved workspaces for IDE/CLI/ACP launch (daemon-local) */
165
+ workspaces?: WorkspaceEntry[];
166
+ /** Default workspace id (from workspaces[]) — never used implicitly for launch */
167
+ defaultWorkspaceId?: string | null;
168
+ /** Recently used workspaces (IDE / CLI / ACP / default) for quick resume */
169
+ recentWorkspaceActivity?: WorkspaceActivityEntry[];
170
+ machineNickname: string | null;
171
+ /**
172
+ * Stable local machine ID (prefix: `mach_`) — generated locally on first run.
173
+ * Used as daemon instance key (`daemon_<machineId>`) and in status reports.
174
+ * NOT the same as the server-side D1 `machines.id` — see `registeredMachineId`.
175
+ */
176
+ machineId?: string;
177
+ machineSecret?: string | null;
178
+ /**
179
+ * Server-side D1 `machines.id` — the row ID assigned when daemon registers via
180
+ * `POST /cli/complete`. Corresponds to `machineId` in server DO context
181
+ * (`DaemonConnection.machineId`, `StatusContext.machineId`).
182
+ *
183
+ * Naming differs from server-side `machineId` to avoid confusion with the local
184
+ * `config.machineId` (mach_ prefix) which is a different value.
185
+ *
186
+ * @deprecated Legacy bridge field — will be removed after 2026-04-06.
187
+ * Modern auth flow uses `machineSecret` (adm_) to identify machines.
188
+ */
189
+ registeredMachineId?: string;
190
+ cliHistory: CliHistoryEntry[];
191
+ providerSettings: Record<string, Record<string, any>>;
192
+ ideSettings: Record<string, {
193
+ extensions?: Record<string, {
194
+ enabled: boolean;
195
+ }>;
196
+ }>;
197
+ disableUpstream?: boolean;
198
+ providerDir?: string;
199
+ }
200
+ interface CliHistoryEntry {
201
+ category?: 'ide' | 'cli' | 'acp';
202
+ cliType: string;
203
+ dir: string;
204
+ cliArgs?: string[];
205
+ workspace?: string;
206
+ newWindow?: boolean;
207
+ model?: string;
208
+ timestamp: number;
209
+ label?: string;
210
+ }
211
+ /**
212
+ * Load configuration from disk
213
+ */
214
+ declare function loadConfig(): ADHDevConfig;
215
+ /**
216
+ * Save configuration to disk
217
+ */
218
+ declare function saveConfig(config: ADHDevConfig): void;
219
+ /**
220
+ * Update specific config fields
221
+ */
222
+ declare function updateConfig(updates: Partial<ADHDevConfig>): ADHDevConfig;
223
+ /**
224
+ * Mark setup as completed
225
+ */
226
+ declare function markSetupComplete(ideId: string | string[], extensions: string[]): ADHDevConfig;
227
+ /**
228
+ * Check if setup has been completed before
229
+ */
230
+ declare function isSetupComplete(): boolean;
231
+ /**
232
+ * Reset configuration
233
+ */
234
+ declare function resetConfig(): void;
235
+ /**
236
+ * Add launch to history (max 20, dedup by category+type+dir+args+workspace+model)
237
+ */
238
+ declare function addCliHistory(entry: Omit<CliHistoryEntry, 'timestamp'>): void;
239
+
240
+ /**
241
+ * Saved workspaces — shared by IDE launch, CLI, ACP (daemon-local).
242
+ */
243
+
244
+ interface WorkspaceEntry {
245
+ id: string;
246
+ path: string;
247
+ label?: string;
248
+ addedAt: number;
249
+ }
250
+ declare function getWorkspaceState(config: ADHDevConfig): {
251
+ workspaces: WorkspaceEntry[];
252
+ defaultWorkspaceId: string | null;
253
+ defaultWorkspacePath: string | null;
254
+ };
255
+
256
+ /**
257
+ * ADHDev Shared Types — Cross-package type definitions
258
+ *
259
+ * Types used across daemon-core, web-core, and downstream consumers.
260
+ * Import via: import type { ... } from '@adhdev/daemon-core/types'
261
+ *
262
+ * IMPORTANT: This file must remain runtime-free (types only).
263
+ */
264
+
265
+ /** Agent stream snapshot carried by flattened UI entries. */
266
+ interface AgentSessionStream {
267
+ sessionId?: string;
268
+ parentSessionId?: string | null;
269
+ agentType: string;
270
+ agentName: string;
271
+ extensionId: string;
272
+ transport?: SessionTransport;
273
+ status: string;
274
+ messages: ChatMessage[];
275
+ inputContent: string;
276
+ model?: string;
277
+ activeModal: {
278
+ message: string;
279
+ buttons: string[];
280
+ } | null;
281
+ }
282
+ type SessionTransport = 'cdp-page' | 'cdp-webview' | 'pty' | 'acp';
283
+ type SessionKind = 'workspace' | 'agent';
284
+ type SessionCapability = 'read_chat' | 'send_message' | 'new_session' | 'list_sessions' | 'switch_session' | 'resolve_action' | 'terminal_io' | 'resize_terminal' | 'change_model' | 'set_mode' | 'set_thought_level';
285
+ interface SessionEntry {
286
+ id: string;
287
+ parentId: string | null;
288
+ providerType: string;
289
+ providerName: string;
290
+ kind: SessionKind;
291
+ transport: SessionTransport;
292
+ status: 'idle' | 'generating' | 'waiting_approval' | 'error' | 'stopped' | 'starting' | 'panel_hidden' | 'not_monitored' | 'disconnected';
293
+ title: string;
294
+ workspace: string | null;
295
+ activeChat: ActiveChatData | null;
296
+ capabilities: SessionCapability[];
297
+ cdpConnected?: boolean;
298
+ currentModel?: string;
299
+ currentPlan?: string;
300
+ currentAutoApprove?: string;
301
+ acpConfigOptions?: AcpConfigOption[];
302
+ acpModes?: AcpMode[];
303
+ errorMessage?: string;
304
+ errorReason?: ProviderErrorReason;
305
+ }
306
+ /** Available provider information */
307
+ interface AvailableProviderInfo {
308
+ type: string;
309
+ name: string;
310
+ category: 'ide' | 'extension' | 'cli' | 'acp';
311
+ displayName: string;
312
+ icon: string;
313
+ }
314
+ /** ACP config option (model/mode/thought_level selection) */
315
+ interface AcpConfigOption {
316
+ category: 'model' | 'mode' | 'thought_level' | 'other';
317
+ configId: string;
318
+ currentValue?: string;
319
+ options: {
320
+ value: string;
321
+ name: string;
322
+ description?: string;
323
+ group?: string;
324
+ }[];
325
+ }
326
+ /** ACP mode */
327
+ interface AcpMode {
328
+ id: string;
329
+ name: string;
330
+ description?: string;
331
+ }
332
+ /** Machine hardware/OS info (reported by daemon, displayed by web) */
333
+ interface MachineInfo {
334
+ hostname: string;
335
+ platform: string;
336
+ arch: string;
337
+ cpus: number;
338
+ totalMem: number;
339
+ freeMem: number;
340
+ /** macOS: reclaimable-inclusive; prefer for UI used% */
341
+ availableMem?: number;
342
+ loadavg: number[];
343
+ uptime: number;
344
+ release: string;
345
+ }
346
+ /** Detected IDE on a machine */
347
+ interface DetectedIdeInfo {
348
+ type: string;
349
+ id?: string;
350
+ name: string;
351
+ running: boolean;
352
+ path?: string;
353
+ }
354
+ /** Workspace recent activity */
355
+ interface WorkspaceActivity {
356
+ path: string;
357
+ lastUsedAt: number;
358
+ kind?: string;
359
+ agentType?: string;
360
+ }
361
+ interface StatusReportPayload {
362
+ /** Daemon instance ID */
363
+ instanceId: string;
364
+ /** Daemon version */
365
+ version: string;
366
+ /** Daemon mode flag */
367
+ daemonMode: boolean;
368
+ /** Machine info */
369
+ machine: MachineInfo;
370
+ /** Machine nickname (user-set) */
371
+ machineNickname?: string | null;
372
+ /** Timestamp */
373
+ timestamp: number;
374
+ /** Detected IDEs on this machine */
375
+ detectedIdes: DetectedIdeInfo[];
376
+ /** P2P state */
377
+ p2p?: {
378
+ available: boolean;
379
+ state: string;
380
+ peers: number;
381
+ screenshotActive?: boolean;
382
+ };
383
+ /** Canonical daemon runtime sessions */
384
+ sessions: SessionEntry[];
385
+ /** Saved workspaces */
386
+ workspaces?: WorkspaceEntry[];
387
+ defaultWorkspaceId?: string | null;
388
+ defaultWorkspacePath?: string | null;
389
+ workspaceActivity?: WorkspaceActivity[];
390
+ }
391
+
392
+ /**
393
+ * ContentBlock — ACP ContentBlock union type
394
+ * Represents displayable content in messages, tool call results, etc.
395
+ */
396
+ type ContentBlock = TextBlock | ImageBlock | AudioBlock | ResourceLinkBlock | ResourceBlock;
397
+ /** Text content — ACP TextContent */
398
+ interface TextBlock {
399
+ type: 'text';
400
+ text: string;
401
+ annotations?: ContentAnnotations;
402
+ }
403
+ /** Image content — ACP ImageContent */
404
+ interface ImageBlock {
405
+ type: 'image';
406
+ data: string;
407
+ mimeType: string;
408
+ uri?: string;
409
+ annotations?: ContentAnnotations;
410
+ }
411
+ /** Audio content — ACP AudioContent */
412
+ interface AudioBlock {
413
+ type: 'audio';
414
+ data: string;
415
+ mimeType: string;
416
+ annotations?: ContentAnnotations;
417
+ }
418
+ /** Resource link (file reference) — ACP ResourceLink */
419
+ interface ResourceLinkBlock {
420
+ type: 'resource_link';
421
+ uri: string;
422
+ name: string;
423
+ title?: string;
424
+ description?: string;
425
+ mimeType?: string;
426
+ size?: number;
427
+ annotations?: ContentAnnotations;
428
+ }
429
+ /** Embedded resource (inline file) — ACP EmbeddedResource */
430
+ interface ResourceBlock {
431
+ type: 'resource';
432
+ resource: TextResourceContents | BlobResourceContents;
433
+ annotations?: ContentAnnotations;
434
+ }
435
+ interface TextResourceContents {
436
+ uri: string;
437
+ text: string;
438
+ mimeType?: string | null;
439
+ }
440
+ interface BlobResourceContents {
441
+ uri: string;
442
+ blob: string;
443
+ mimeType?: string | null;
444
+ }
445
+ interface ContentAnnotations {
446
+ audience?: ('user' | 'assistant')[];
447
+ priority?: number;
448
+ }
449
+ /** Tool call info — ACP ToolCall */
450
+ interface ToolCallInfo {
451
+ toolCallId: string;
452
+ title: string;
453
+ kind?: ToolKind;
454
+ status?: ToolCallStatus;
455
+ rawInput?: unknown;
456
+ rawOutput?: unknown;
457
+ content?: ToolCallContent[];
458
+ locations?: ToolCallLocation[];
459
+ }
460
+ type ToolKind = 'read' | 'edit' | 'delete' | 'move' | 'search' | 'execute' | 'think' | 'fetch' | 'switch_mode' | 'other';
461
+ type ToolCallStatus = 'pending' | 'in_progress' | 'completed' | 'failed';
462
+ /** Content produced by a tool call — ACP ToolCallContent */
463
+ type ToolCallContent = {
464
+ type: 'content';
465
+ content: ContentBlock;
466
+ } | {
467
+ type: 'diff';
468
+ path: string;
469
+ oldText?: string;
470
+ newText: string;
471
+ } | {
472
+ type: 'terminal';
473
+ terminalId: string;
474
+ };
475
+ interface ToolCallLocation {
476
+ path: string;
477
+ line?: number | null;
478
+ }
479
+ type ProviderCategory = 'cli' | 'ide' | 'extension' | 'acp';
480
+ /**
481
+ * Type of object exported by module.exports in provider.js.
482
+ *
483
+ * Each provider.js is fully independent and does not import other providers.
484
+ * Helpers (_helpers/) can be optionally used.
485
+ */
486
+ /**
487
+ * Provider-configurable CDP target filter.
488
+ * Used by DaemonCdpManager to select the correct page/tab to connect to.
489
+ * Without this, the manager uses a hardcoded default filter.
490
+ */
491
+ interface CdpTargetFilter {
492
+ /** URL must include this string (e.g. 'workbench.html') */
493
+ urlIncludes?: string;
494
+ /** URL must NOT include any of these strings */
495
+ urlExcludes?: string[];
496
+ /** Page title regex pattern for titles to EXCLUDE (e.g. 'Debug Console|Output') */
497
+ titleExcludes?: string;
498
+ }
499
+ interface ProviderModule {
500
+ /** Unique identifier (e.g. 'cline', 'cursor', 'gemini-cli') */
501
+ type: string;
502
+ /** Display name (e.g. 'Cline', 'Cursor') */
503
+ name: string;
504
+ /** Category: determines execution method */
505
+ category: ProviderCategory;
506
+ /** Alias list — allows users to invoke by alternate names (e.g. ['claude', 'claude-code']) */
507
+ aliases?: string[];
508
+ /** CDP ports [primary, secondary] (IDE category only) */
509
+ cdpPorts?: [number, number];
510
+ /** CDP target filter — controls which page/tab to connect to (IDE category only) */
511
+ targetFilter?: CdpTargetFilter;
512
+ /** CLI command (e.g. 'cursor', 'code') */
513
+ cli?: string;
514
+ /** Display icon */
515
+ icon?: string;
516
+ /** Display name (short name) */
517
+ displayName?: string;
518
+ /** Install instructions (shown when command is missing) */
519
+ install?: string;
520
+ /** Custom version detection command (e.g. 'cursor --version', 'claude -v') */
521
+ versionCommand?: string;
522
+ /** Versions tested by provider maintainer (informational) */
523
+ testedVersions?: string[];
524
+ /** Per-OS process names — used by launch.ts to detect/kill IDE processes */
525
+ processNames?: {
526
+ darwin?: string;
527
+ win32?: string[];
528
+ linux?: string[];
529
+ [key: string]: string | string[] | undefined;
530
+ };
531
+ /** Per-OS install paths — used by detector.ts to detect IDE installation */
532
+ paths?: {
533
+ darwin?: string[];
534
+ win32?: string[];
535
+ linux?: string[];
536
+ [key: string]: string[] | undefined;
537
+ };
538
+ extensionId?: string;
539
+ extensionIdPattern?: RegExp;
540
+ binary?: string;
541
+ spawn?: {
542
+ command: string;
543
+ args?: string[];
544
+ shell?: boolean;
545
+ env?: Record<string, string>;
546
+ };
547
+ patterns?: {
548
+ prompt?: RegExp[];
549
+ generating?: RegExp[];
550
+ approval?: RegExp[];
551
+ ready?: RegExp[];
552
+ };
553
+ cleanOutput?: (raw: string, lastUserInput?: string) => string;
554
+ scripts?: ProviderScripts;
555
+ vscodeCommands?: {
556
+ focusPanel?: string;
557
+ openPanel?: string;
558
+ [key: string]: string | undefined;
559
+ };
560
+ inputMethod?: 'cdp-type-and-send' | 'script';
561
+ inputSelector?: string;
562
+ /** webview iframe match text (must be contained in body) */
563
+ webviewMatchText?: string;
564
+ os?: {
565
+ [platform: string]: Partial<Pick<ProviderModule, 'scripts' | 'inputMethod' | 'inputSelector'>>;
566
+ };
567
+ /** Key: semver range string (e.g. '< 1.107.0', '>= 2.0.0') */
568
+ versions?: {
569
+ [versionRange: string]: Partial<Pick<ProviderModule, 'scripts'>> & {
570
+ /**
571
+ * Load scripts from a subdirectory instead of scripts.js root.
572
+ * Path is relative to the provider directory (e.g. 'scripts/legacy').
573
+ * The subdirectory should contain its own scripts.js or individual .js files.
574
+ */
575
+ __dir?: string;
576
+ };
577
+ };
578
+ overrides?: Array<{
579
+ when: {
580
+ os?: string;
581
+ version?: string;
582
+ };
583
+ scripts?: Partial<ProviderScripts>;
584
+ /** Load scripts from a subdirectory for this OS+version combination */
585
+ __dir?: string;
586
+ }>;
587
+ settings?: Record<string, ProviderSettingDef>;
588
+ /** Static options used when agent does not provide configOptions */
589
+ staticConfigOptions?: Array<{
590
+ category: 'model' | 'mode' | 'thought_level' | 'other';
591
+ configId: string;
592
+ defaultValue?: string;
593
+ options: Array<{
594
+ value: string;
595
+ name: string;
596
+ description?: string;
597
+ group?: string;
598
+ }>;
599
+ }>;
600
+ /** Function to convert selected config values to spawn args (applied via process restart when config/* not supported) */
601
+ spawnArgBuilder?: (config: Record<string, string>) => string[];
602
+ /** ACP agent auth methods (multiple supported — in priority order) */
603
+ auth?: AcpAuthMethod[];
604
+ }
605
+ /** ACP auth method — based on ACP official spec */
606
+ type AcpAuthMethod = AcpAuthEnvVar | AcpAuthAgent | AcpAuthTerminal;
607
+ /** Environment variable-based auth (API keys etc) */
608
+ interface AcpAuthEnvVar {
609
+ type: 'env_var';
610
+ id: string;
611
+ name: string;
612
+ vars: Array<{
613
+ name: string;
614
+ label?: string;
615
+ secret?: boolean;
616
+ optional?: boolean;
617
+ }>;
618
+ link?: string;
619
+ }
620
+ /** Agent self-auth (OAuth, browser-based etc) */
621
+ interface AcpAuthAgent {
622
+ type: 'agent';
623
+ id: string;
624
+ name: string;
625
+ description?: string;
626
+ }
627
+ /** Terminal command-based auth (runs setup command) */
628
+ interface AcpAuthTerminal {
629
+ type: 'terminal';
630
+ id: string;
631
+ name: string;
632
+ description?: string;
633
+ args?: string[];
634
+ env?: Record<string, string>;
635
+ }
636
+ /**
637
+ * CDP script functions.
638
+ * Each function takes a params object and returns a JS code string for CDP evaluate.
639
+ * The JS execution result must conform to the Output Contract.
640
+ *
641
+ * Custom scripts can be added via index signature in addition to built-in scripts.
642
+ * All scripts can receive params: Record<string, any>,
643
+ * backward compatible with legacy single-argument style (e.g. sendMessage(text)).
644
+ */
645
+ interface ProviderScripts {
646
+ readChat?: (params?: Record<string, any>) => string;
647
+ sendMessage?: (params?: Record<string, any>) => string;
648
+ listSessions?: (params?: Record<string, any>) => string;
649
+ switchSession?: (params?: Record<string, any>) => string;
650
+ newSession?: (params?: Record<string, any>) => string;
651
+ focusEditor?: (params?: Record<string, any>) => string;
652
+ openPanel?: (params?: Record<string, any>) => string;
653
+ /** List available models → { models: string[], current: string } */
654
+ listModels?: (params?: Record<string, any>) => string;
655
+ /** Change model → { success: boolean } */
656
+ setModel?: (params?: Record<string, any>) => string;
657
+ /** List available modes → { modes: string[], current: string } */
658
+ listModes?: (params?: Record<string, any>) => string;
659
+ /** Change mode → { success: boolean } */
660
+ setMode?: (params?: Record<string, any>) => string;
661
+ /** params: { action: 'approve'|'reject'|'custom', button?: string } */
662
+ resolveAction?: (params?: Record<string, any>) => string;
663
+ webviewResolveAction?: (params?: Record<string, any>) => string;
664
+ listNotifications?: (params?: Record<string, any>) => string;
665
+ dismissNotification?: (params?: Record<string, any>) => string;
666
+ [scriptName: string]: ((params?: Record<string, any>) => string) | undefined;
667
+ }
668
+ /**
669
+ * ProviderLoader.resolve() result: Final provider with OS/version overrides applied
670
+ */
671
+ interface ResolvedProvider extends ProviderModule {
672
+ /** OS applied during resolve */
673
+ _resolvedOs?: string;
674
+ /** Version applied during resolve */
675
+ _resolvedVersion?: string;
676
+ /** Warning when detected version is not in compatibility matrix */
677
+ _versionWarning?: string;
678
+ }
679
+ /** Setting variable definition declared by provider */
680
+ interface ProviderSettingDef {
681
+ type: 'boolean' | 'number' | 'string' | 'select';
682
+ default: any;
683
+ /** true = controllable from dashboard UI */
684
+ public: boolean;
685
+ /** UI label */
686
+ label?: string;
687
+ /** UI description */
688
+ description?: string;
689
+ /** Minimum value for number type */
690
+ min?: number;
691
+ /** Maximum value for number type */
692
+ max?: number;
693
+ /** Options for select type */
694
+ options?: string[];
695
+ }
696
+ /** Public settings schema (for dashboard transmission) */
697
+ interface ProviderSettingSchema extends ProviderSettingDef {
698
+ key: string;
699
+ }
700
+
701
+ /**
702
+ * ADHDev Daemon Core — Shared Types
703
+ *
704
+ * Shared types referenced by daemon-core, daemon-standalone, and web-core.
705
+ * When modifying this file, also update interface contracts in AGENT_PROTOCOL.md.
706
+ */
707
+
708
+ /** Full status response from /api/v1/status and WS events */
709
+ interface StatusResponse extends StatusReportPayload {
710
+ /** For standalone API compat */
711
+ id: string;
712
+ type: string;
713
+ platform: string;
714
+ hostname: string;
715
+ /** User display name from config */
716
+ userName?: string;
717
+ /** Available providers */
718
+ availableProviders: ProviderInfo[];
719
+ /** System info (legacy compat) */
720
+ system?: SystemInfo;
721
+ }
722
+ interface ChatMessage {
723
+ role: string;
724
+ /** Plain text (legacy) or rich content blocks (ACP standard) */
725
+ content: string | ContentBlock[];
726
+ kind?: string;
727
+ id?: string;
728
+ index?: number;
729
+ timestamp?: number;
730
+ receivedAt?: number;
731
+ /** Tool calls associated with this message */
732
+ toolCalls?: ToolCallInfo[];
733
+ /** Optional: fiber metadata */
734
+ _type?: string;
735
+ _sub?: string;
736
+ /** Meta information for thought/terminal logs etc */
737
+ meta?: {
738
+ label?: string;
739
+ isRunning?: boolean;
740
+ } | Record<string, any>;
741
+ /** Sender name for shared sessions */
742
+ senderName?: string;
743
+ }
744
+
745
+ interface ExtensionInfo {
746
+ id: string;
747
+ type: string;
748
+ name: string;
749
+ isMonitored?: boolean;
750
+ agentStatus?: string;
751
+ }
752
+ interface CommandResult {
753
+ success: boolean;
754
+ data?: any;
755
+ error?: string;
756
+ }
757
+ interface ProviderConfig {
758
+ id: string;
759
+ type: 'ide' | 'extension' | 'cli' | 'acp';
760
+ name: string;
761
+ /** CDP port detection */
762
+ cdpDetect?: {
763
+ processName?: string;
764
+ portFlag?: string;
765
+ };
766
+ /** Capabilities */
767
+ capabilities?: string[];
768
+ }
769
+ type DaemonEvent = {
770
+ type: 'status';
771
+ data: StatusResponse;
772
+ } | {
773
+ type: 'chat_update';
774
+ data: {
775
+ ideId: string;
776
+ messages: ChatMessage[];
777
+ };
778
+ } | {
779
+ type: 'screenshot';
780
+ data: {
781
+ ideId: string;
782
+ base64: string;
783
+ };
784
+ } | {
785
+ type: 'action_log';
786
+ data: {
787
+ ideId: string;
788
+ text: string;
789
+ timestamp: number;
790
+ };
791
+ } | {
792
+ type: 'error';
793
+ data: {
794
+ message: string;
795
+ };
796
+ };
797
+ interface SystemInfo {
798
+ cpus: number;
799
+ totalMem: number;
800
+ freeMem: number;
801
+ /** macOS: reclaimable-inclusive; prefer for UI used% (see host-memory.ts) */
802
+ availableMem?: number;
803
+ loadavg: number[];
804
+ uptime: number;
805
+ arch: string;
806
+ }
807
+ interface DetectedIde {
808
+ id: string;
809
+ type: string;
810
+ name: string;
811
+ installed: boolean;
812
+ running: boolean;
813
+ }
814
+ interface ProviderInfo {
815
+ type: string;
816
+ icon: string;
817
+ displayName: string;
818
+ category: string;
819
+ }
820
+ /** Flattened agent entry from /api/v1/agents */
821
+ interface AgentEntry {
822
+ ideId: string;
823
+ type: string;
824
+ name: string;
825
+ status: string;
826
+ source: 'native' | 'extension';
827
+ }
828
+
829
+ type ManagedStatus = 'idle' | 'generating' | 'waiting_approval' | 'error' | 'stopped' | 'starting' | 'panel_hidden' | 'not_monitored' | 'disconnected';
830
+ declare function normalizeManagedStatus(status?: string | null, opts?: {
831
+ activeModal?: {
832
+ buttons?: unknown[] | null;
833
+ } | null;
834
+ }): ManagedStatus;
835
+ declare function isManagedStatusWorking(status?: string | null): boolean;
836
+ declare function isManagedStatusWaiting(status?: string | null, opts?: {
837
+ activeModal?: {
838
+ buttons?: unknown[] | null;
839
+ } | null;
840
+ }): boolean;
841
+ declare function normalizeActiveChatData<T extends ActiveChatData | null | undefined>(activeChat: T): T;
842
+
843
+ export { updateConfig as $, type AvailableProviderInfo as A, type ProviderStatus as B, type CommandResult as C, type DaemonEvent as D, type ExtensionInfo as E, type SessionCapability as F, type SessionKind as G, type SystemInfo as H, type InstanceContext as I, type WorkspaceEntry as J, addCliHistory as K, getWorkspaceActivity as L, type MachineInfo as M, getWorkspaceState as N, isManagedStatusWaiting as O, type ProviderCategory as P, isManagedStatusWorking as Q, type ResolvedProvider as R, type StatusResponse as S, isSetupComplete as T, loadConfig as U, markSetupComplete as V, type WorkspaceActivity as W, normalizeActiveChatData as X, normalizeManagedStatus as Y, resetConfig as Z, saveConfig as _, type SessionEntry as a, type ProviderModule as b, type ProviderSettingSchema as c, type CdpTargetFilter as d, type ProviderInstance as e, type ProviderState as f, type ProviderEvent as g, type SessionTransport as h, type StatusReportPayload as i, type AcpProviderState as j, type ContentBlock as k, type AcpConfigOption as l, type AcpMode as m, type ActiveChatData as n, type AgentEntry as o, type AgentSessionStream as p, type ChatMessage as q, type CliProviderState as r, type DetectedIde as s, type DetectedIdeInfo as t, type ExtensionProviderState as u, type IdeProviderState as v, type ManagedStatus as w, type ProviderConfig as x, type ProviderErrorReason as y, type ProviderInfo as z };