@adhdev/daemon-core 0.7.38 → 0.7.40

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 (95) hide show
  1. package/dist/agent-stream/forward.d.ts +8 -0
  2. package/dist/agent-stream/index.d.ts +6 -0
  3. package/dist/agent-stream/manager.d.ts +59 -0
  4. package/dist/agent-stream/poller.d.ts +41 -0
  5. package/dist/agent-stream/provider-adapter.d.ts +29 -0
  6. package/dist/agent-stream/types.d.ts +62 -0
  7. package/dist/boot/daemon-lifecycle.d.ts +97 -0
  8. package/dist/cdp/devtools.d.ts +51 -0
  9. package/dist/cdp/initializer.d.ts +50 -0
  10. package/dist/cdp/manager.d.ts +145 -0
  11. package/dist/cdp/scanner.d.ts +58 -0
  12. package/dist/cdp/setup.d.ts +58 -0
  13. package/dist/cli-adapter-types.d.ts +25 -0
  14. package/dist/cli-adapters/provider-cli-adapter.d.ts +229 -0
  15. package/dist/cli-adapters/pty-transport.d.ts +43 -0
  16. package/dist/cli-adapters/session-host-transport.d.ts +19 -0
  17. package/dist/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +12 -0
  18. package/dist/cli-adapters/terminal-backends/types.d.ts +14 -0
  19. package/dist/cli-adapters/terminal-backends/xterm-backend.d.ts +13 -0
  20. package/dist/cli-adapters/terminal-screen.d.ts +27 -0
  21. package/dist/commands/cdp-commands.d.ts +15 -0
  22. package/dist/commands/chat-commands.d.ts +15 -0
  23. package/dist/commands/cli-manager.d.ts +82 -0
  24. package/dist/commands/handler.d.ts +101 -0
  25. package/dist/commands/router.d.ts +69 -0
  26. package/dist/commands/stream-commands.d.ts +13 -0
  27. package/dist/commands/workspace-commands.d.ts +11 -0
  28. package/dist/config/chat-history.d.ts +60 -0
  29. package/dist/config/config.d.ts +103 -0
  30. package/dist/config/recent-activity.d.ts +27 -0
  31. package/dist/config/workspaces.d.ts +82 -0
  32. package/dist/daemon/dev-auto-implement.d.ts +26 -0
  33. package/dist/daemon/dev-cdp-handlers.d.ts +22 -0
  34. package/dist/daemon/dev-cli-debug.d.ts +24 -0
  35. package/dist/daemon/dev-server-types.d.ts +43 -0
  36. package/dist/daemon/dev-server.d.ts +133 -0
  37. package/dist/daemon/scaffold-template.d.ts +32 -0
  38. package/dist/daemon-core.d.ts +36 -0
  39. package/dist/detection/cli-detector.d.ts +27 -0
  40. package/dist/detection/ide-detector.d.ts +34 -0
  41. package/dist/index.d.ts +72 -2499
  42. package/dist/index.js +673 -879
  43. package/dist/index.js.map +1 -1
  44. package/dist/index.mjs +680 -884
  45. package/dist/index.mjs.map +1 -1
  46. package/dist/installer.d.ts +50 -0
  47. package/dist/ipc-protocol.d.ts +111 -0
  48. package/dist/launch.d.ts +46 -0
  49. package/dist/logging/command-log.d.ts +31 -0
  50. package/dist/logging/logger.d.ts +87 -0
  51. package/dist/providers/acp-provider-instance.d.ts +101 -0
  52. package/dist/providers/cli-provider-instance.d.ts +43 -0
  53. package/dist/providers/contracts.d.ts +483 -0
  54. package/dist/providers/extension-provider-instance.d.ts +44 -0
  55. package/dist/providers/ide-provider-instance.d.ts +61 -0
  56. package/dist/providers/index.d.ts +5 -0
  57. package/dist/providers/provider-instance-manager.d.ts +84 -0
  58. package/dist/providers/provider-instance.d.ts +148 -0
  59. package/dist/providers/provider-loader.d.ts +270 -0
  60. package/dist/providers/status-monitor.d.ts +48 -0
  61. package/dist/providers/version-archive.d.ts +52 -0
  62. package/dist/session-host/runtime-support.d.ts +8 -0
  63. package/dist/sessions/registry.d.ts +24 -0
  64. package/dist/shared-types-extra.d.ts +29 -0
  65. package/dist/shared-types.d.ts +205 -0
  66. package/dist/status/builders.d.ts +33 -0
  67. package/dist/status/normalize.d.ts +14 -1
  68. package/dist/status/reporter.d.ts +69 -0
  69. package/dist/status/snapshot.d.ts +51 -0
  70. package/dist/system/host-memory.d.ts +19 -0
  71. package/dist/types.d.ts +123 -0
  72. package/node_modules/@adhdev/session-host-core/package.json +1 -1
  73. package/package.json +3 -2
  74. package/src/commands/cli-manager.ts +1 -26
  75. package/src/commands/handler.ts +0 -31
  76. package/src/commands/router.ts +27 -34
  77. package/src/commands/stream-commands.ts +2 -4
  78. package/src/commands/workspace-commands.ts +9 -23
  79. package/src/config/config.ts +7 -81
  80. package/src/config/recent-activity.ts +24 -12
  81. package/src/config/workspaces.ts +0 -24
  82. package/src/index.ts +16 -15
  83. package/src/providers/provider-loader.ts +13 -5
  84. package/src/shared-types-extra.ts +34 -0
  85. package/src/shared-types.d.ts +4 -6
  86. package/src/shared-types.ts +17 -38
  87. package/src/status/builders.ts +12 -0
  88. package/src/status/reporter.ts +2 -1
  89. package/src/status/snapshot.ts +70 -87
  90. package/src/types.ts +3 -8
  91. package/dist/index.d.mts +0 -2504
  92. package/dist/normalize-DVI4Lo5I.d.mts +0 -947
  93. package/dist/normalize-DVI4Lo5I.d.ts +0 -947
  94. package/dist/status/normalize.d.mts +0 -1
  95. package/src/config/workspace-activity.ts +0 -65
@@ -0,0 +1,205 @@
1
+ /**
2
+ * ADHDev Shared Types — Cross-package type definitions
3
+ *
4
+ * Types used across daemon-core, web-core, and downstream consumers.
5
+ * Import via: import type { ... } from '@adhdev/daemon-core/types'
6
+ *
7
+ * IMPORTANT: This file must remain runtime-free (types only).
8
+ */
9
+ import type { StatusResponse, ChatMessage, ExtensionInfo, SystemInfo, DetectedIde, AgentEntry } from './types.js';
10
+ export type { StatusResponse, ChatMessage, ExtensionInfo, SystemInfo, DetectedIde, AgentEntry, };
11
+ export type { ProviderState, ProviderStatus, ActiveChatData, IdeProviderState, CliProviderState, AcpProviderState, ExtensionProviderState, ProviderEvent, } from './providers/provider-instance.js';
12
+ export type { ProviderErrorReason } from './providers/provider-instance.js';
13
+ import type { ActiveChatData as _ActiveChatData, ProviderErrorReason as _ProviderErrorReason } from './providers/provider-instance.js';
14
+ import type { WorkspaceEntry } from './config/workspaces.js';
15
+ import type { ProviderResumeCapability } from './providers/contracts.js';
16
+ export type { WorkspaceEntry } from './config/workspaces.js';
17
+ /** Agent stream snapshot carried by flattened UI entries. */
18
+ export interface AgentSessionStream {
19
+ sessionId?: string;
20
+ instanceId?: string;
21
+ parentSessionId?: string | null;
22
+ agentType: string;
23
+ agentName: string;
24
+ extensionId: string;
25
+ transport?: SessionTransport;
26
+ status: string;
27
+ title?: string;
28
+ messages: ChatMessage[];
29
+ inputContent: string;
30
+ model?: string;
31
+ activeModal: {
32
+ message: string;
33
+ buttons: string[];
34
+ } | null;
35
+ }
36
+ export type SessionTransport = 'cdp-page' | 'cdp-webview' | 'pty' | 'acp';
37
+ export type SessionKind = 'workspace' | 'agent';
38
+ export 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';
39
+ import type { RuntimeWriteOwner, RuntimeAttachedClient, SessionStatus } from './shared-types-extra.js';
40
+ export type { RuntimeWriteOwner, RuntimeAttachedClient, SessionStatus } from './shared-types-extra.js';
41
+ export interface SessionEntry {
42
+ id: string;
43
+ parentId: string | null;
44
+ providerType: string;
45
+ providerName: string;
46
+ kind: SessionKind;
47
+ transport: SessionTransport;
48
+ status: SessionStatus;
49
+ title: string;
50
+ workspace: string | null;
51
+ runtimeKey?: string;
52
+ runtimeDisplayName?: string;
53
+ runtimeWorkspaceLabel?: string;
54
+ runtimeWriteOwner?: RuntimeWriteOwner | null;
55
+ runtimeAttachedClients?: RuntimeAttachedClient[];
56
+ resume?: ProviderResumeCapability;
57
+ activeChat: _ActiveChatData | null;
58
+ capabilities: SessionCapability[];
59
+ cdpConnected?: boolean;
60
+ currentModel?: string;
61
+ currentPlan?: string;
62
+ currentAutoApprove?: string;
63
+ acpConfigOptions?: AcpConfigOption[];
64
+ acpModes?: AcpMode[];
65
+ /** Dynamic control current values (generic key-value) */
66
+ controlValues?: Record<string, string | number | boolean>;
67
+ /** Provider-declared controls schema (transmitted once, cached by frontend) */
68
+ providerControls?: ProviderControlSchema[];
69
+ errorMessage?: string;
70
+ errorReason?: _ProviderErrorReason;
71
+ lastUpdated?: number;
72
+ unread?: boolean;
73
+ lastSeenAt?: number;
74
+ inboxBucket?: RecentSessionBucket;
75
+ surfaceHidden?: boolean;
76
+ }
77
+ /** Available provider information */
78
+ export interface AvailableProviderInfo {
79
+ type: string;
80
+ name: string;
81
+ category: 'ide' | 'extension' | 'cli' | 'acp';
82
+ displayName: string;
83
+ icon: string;
84
+ }
85
+ /** ACP config option (model/mode/thought_level selection) */
86
+ export interface AcpConfigOption {
87
+ category: 'model' | 'mode' | 'thought_level' | 'other';
88
+ configId: string;
89
+ currentValue?: string;
90
+ options: {
91
+ value: string;
92
+ name: string;
93
+ description?: string;
94
+ group?: string;
95
+ }[];
96
+ }
97
+ /** ACP mode */
98
+ export interface AcpMode {
99
+ id: string;
100
+ name: string;
101
+ description?: string;
102
+ }
103
+ /** Provider control schema transmitted to frontend */
104
+ export interface ProviderControlSchema {
105
+ id: string;
106
+ type: 'select' | 'toggle' | 'cycle' | 'slider' | 'action';
107
+ label: string;
108
+ icon?: string;
109
+ placement: 'bar' | 'header' | 'menu';
110
+ /** Static options (for select/cycle) */
111
+ options?: {
112
+ value: string;
113
+ label: string;
114
+ description?: string;
115
+ group?: string;
116
+ }[];
117
+ /** Dynamic options — frontend should call listScript to load */
118
+ dynamic?: boolean;
119
+ /** Script name to list options */
120
+ listScript?: string;
121
+ /** Script name to change value (value-based controls) */
122
+ setScript?: string;
123
+ /** Field name in readChat result for current value */
124
+ readFrom?: string;
125
+ /** Default value */
126
+ defaultValue?: string | number | boolean;
127
+ /** Script name to invoke (action type) */
128
+ invokeScript?: string;
129
+ /** How to display action result */
130
+ resultDisplay?: 'toast' | 'inline' | 'none';
131
+ /** Slider range */
132
+ min?: number;
133
+ max?: number;
134
+ step?: number;
135
+ /** Sort order */
136
+ order?: number;
137
+ }
138
+ /** Machine hardware/OS info (reported by daemon, displayed by web) */
139
+ export interface MachineInfo {
140
+ hostname: string;
141
+ platform: string;
142
+ arch: string;
143
+ cpus: number;
144
+ totalMem: number;
145
+ freeMem: number;
146
+ /** macOS: reclaimable-inclusive; prefer for UI used% */
147
+ availableMem?: number;
148
+ loadavg: number[];
149
+ uptime: number;
150
+ release: string;
151
+ }
152
+ /** Detected IDE on a machine */
153
+ export interface DetectedIdeInfo {
154
+ type: string;
155
+ id?: string;
156
+ name: string;
157
+ running: boolean;
158
+ path?: string;
159
+ }
160
+ export type { RecentSessionBucket, TerminalBackendStatus } from './shared-types-extra.js';
161
+ import type { RecentSessionBucket } from './shared-types-extra.js';
162
+ import type { TerminalBackendStatus } from './shared-types-extra.js';
163
+ export interface RecentLaunchEntry {
164
+ id: string;
165
+ providerType: string;
166
+ providerName: string;
167
+ kind: 'ide' | 'cli' | 'acp';
168
+ title?: string;
169
+ workspace?: string | null;
170
+ currentModel?: string;
171
+ lastLaunchedAt: number;
172
+ }
173
+ export interface StatusReportPayload {
174
+ /** Unique daemon instance identifier */
175
+ instanceId: string;
176
+ /** Daemon version */
177
+ version: string;
178
+ /** Daemon mode flag */
179
+ daemonMode: boolean;
180
+ /** Machine info */
181
+ machine: MachineInfo;
182
+ /** Machine nickname (user-set) */
183
+ machineNickname?: string | null;
184
+ /** Timestamp */
185
+ timestamp: number;
186
+ /** Detected IDEs on this machine */
187
+ detectedIdes: DetectedIdeInfo[];
188
+ /** P2P state */
189
+ p2p?: {
190
+ available: boolean;
191
+ state: string;
192
+ peers: number;
193
+ screenshotActive?: boolean;
194
+ };
195
+ /** Canonical daemon runtime sessions */
196
+ sessions: SessionEntry[];
197
+ /** Saved workspaces */
198
+ workspaces?: WorkspaceEntry[];
199
+ defaultWorkspaceId?: string | null;
200
+ defaultWorkspacePath?: string | null;
201
+ recentLaunches?: RecentLaunchEntry[];
202
+ terminalBackend?: TerminalBackendStatus;
203
+ /** Available providers (present in StatusSnapshot, optional in raw payload) */
204
+ availableProviders?: AvailableProviderInfo[];
205
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Status Builders — shared conversion functions for ProviderState → ManagedEntry
3
+ *
4
+ * Used by:
5
+ * - daemon-standalone (StandaloneServer.getStatus)
6
+ * - DaemonStatusReporter
7
+ *
8
+ * Consolidates ProviderState→ManagedEntry mapping logic.
9
+ */
10
+ import type { DaemonCdpManager } from '../cdp/manager.js';
11
+ import type { SessionEntry } from '../shared-types.js';
12
+ import type { ProviderState } from '../providers/provider-instance.js';
13
+ /**
14
+ * Find a CDP manager by key, with prefix matching for multi-window support.
15
+ *
16
+ * Lookup order:
17
+ * 1. Exact match: cdpManagers.get(key)
18
+ * 2. Prefix match: key starts with `${ideType}_` (multi-window: "cursor_remote_vs")
19
+ * 3. null
20
+ *
21
+ * This replaces raw `cdpManagers.get(ideType)` calls that broke when
22
+ * multi-window keys like "cursor_remote_vs" were used.
23
+ */
24
+ export declare function findCdpManager(cdpManagers: Map<string, DaemonCdpManager>, key: string): DaemonCdpManager | null;
25
+ /**
26
+ * Check if any CDP manager matches the given key (exact or prefix).
27
+ */
28
+ export declare function hasCdpManager(cdpManagers: Map<string, DaemonCdpManager>, key: string): boolean;
29
+ /**
30
+ * Check if any CDP manager matching the key is connected.
31
+ */
32
+ export declare function isCdpConnected(cdpManagers: Map<string, DaemonCdpManager>, key: string): boolean;
33
+ export declare function buildSessionEntries(allStates: ProviderState[], cdpManagers: Map<string, DaemonCdpManager>): SessionEntry[];
@@ -1 +1,14 @@
1
- export { x as ManagedStatus, X as isManagedStatusWaiting, Y as isManagedStatusWorking, a0 as normalizeActiveChatData, a1 as normalizeManagedStatus } from '../normalize-DVI4Lo5I.js';
1
+ import type { ActiveChatData } from '../providers/provider-instance.js';
2
+ export type ManagedStatus = 'idle' | 'generating' | 'waiting_approval' | 'error' | 'stopped' | 'starting' | 'panel_hidden' | 'not_monitored' | 'disconnected';
3
+ export declare function normalizeManagedStatus(status?: string | null, opts?: {
4
+ activeModal?: {
5
+ buttons?: unknown[] | null;
6
+ } | null;
7
+ }): ManagedStatus;
8
+ export declare function isManagedStatusWorking(status?: string | null): boolean;
9
+ export declare function isManagedStatusWaiting(status?: string | null, opts?: {
10
+ activeModal?: {
11
+ buttons?: unknown[] | null;
12
+ } | null;
13
+ }): boolean;
14
+ export declare function normalizeActiveChatData<T extends ActiveChatData | null | undefined>(activeChat: T): T;
@@ -0,0 +1,69 @@
1
+ /**
2
+ * DaemonStatusReporter — status collect & transmit (StatusReport / P2P / StatusEvent)
3
+ *
4
+ * Collect status from ProviderInstanceManager → assemble payload → transmit
5
+ * Each Instance manages its own status/transition. This module only assembles + transmits.
6
+ */
7
+ import type { ProviderState } from '../providers/provider-instance.js';
8
+ export interface StatusReporterDeps {
9
+ serverConn: {
10
+ isConnected(): boolean;
11
+ sendMessage(type: string, data: any): void;
12
+ getUserPlan(): string;
13
+ } | null;
14
+ cdpManagers: Map<string, {
15
+ isConnected: boolean;
16
+ }>;
17
+ p2p: {
18
+ isConnected: boolean;
19
+ isAvailable: boolean;
20
+ connectionState: string;
21
+ connectedPeerCount: number;
22
+ screenshotActive: boolean;
23
+ sendStatus(data: any): void;
24
+ } | null;
25
+ providerLoader: {
26
+ resolve(type: string): any;
27
+ getAll(): any[];
28
+ };
29
+ detectedIdes: any[];
30
+ instanceId: string;
31
+ daemonVersion?: string;
32
+ instanceManager: {
33
+ collectAllStates(): ProviderState[];
34
+ collectStatesByCategory(cat: string): ProviderState[];
35
+ };
36
+ getScreenshotUsage?: () => {
37
+ dailyUsedMinutes: number;
38
+ dailyBudgetMinutes: number;
39
+ budgetExhausted: boolean;
40
+ } | null;
41
+ }
42
+ export declare class DaemonStatusReporter {
43
+ private deps;
44
+ private log;
45
+ private lastStatusSentAt;
46
+ private statusPendingThrottle;
47
+ private lastP2PStatusHash;
48
+ private lastStatusSummary;
49
+ private statusTimer;
50
+ private p2pTimer;
51
+ constructor(deps: StatusReporterDeps, opts?: {
52
+ logFn?: (msg: string) => void;
53
+ });
54
+ startReporting(): void;
55
+ stopReporting(): void;
56
+ onStatusChange(): void;
57
+ throttledReport(): void;
58
+ emitStatusEvent(event: Record<string, unknown>): void;
59
+ removeAgentTracking(_key: string): void;
60
+ updateAgentStreams(_ideType: string, _streams: any[]): void;
61
+ /** Reset P2P dedup hash — forces next send to transmit even if content unchanged */
62
+ resetP2PHash(): void;
63
+ private ts;
64
+ sendUnifiedStatusReport(opts?: {
65
+ p2pOnly?: boolean;
66
+ }): Promise<void>;
67
+ private sendP2PPayload;
68
+ private simpleHash;
69
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Shared status snapshot builders.
3
+ *
4
+ * Used by:
5
+ * - DaemonStatusReporter (cloud)
6
+ * - daemon-standalone HTTP/WS status responses
7
+ */
8
+ import type { ProviderState } from '../providers/provider-instance.js';
9
+ import type { AvailableProviderInfo, StatusReportPayload } from '../shared-types.js';
10
+ export interface StatusSnapshotOptions {
11
+ allStates: ProviderState[];
12
+ cdpManagers: Map<string, unknown>;
13
+ providerLoader: {
14
+ getAll(): Array<{
15
+ type: string;
16
+ icon?: string;
17
+ displayName?: string;
18
+ category: 'ide' | 'extension' | 'cli' | 'acp';
19
+ }>;
20
+ };
21
+ detectedIdes: Array<{
22
+ id: string;
23
+ name?: string;
24
+ displayName?: string;
25
+ installed?: boolean;
26
+ path?: string;
27
+ }>;
28
+ instanceId: string;
29
+ version: string;
30
+ daemonMode: boolean;
31
+ timestamp?: number;
32
+ p2p?: StatusReportPayload['p2p'];
33
+ machineNickname?: string | null;
34
+ }
35
+ export interface StatusSnapshot extends StatusReportPayload {
36
+ availableProviders: AvailableProviderInfo[];
37
+ }
38
+ export declare function getSessionCompletionMarker(session: {
39
+ activeChat?: {
40
+ messages?: Array<{
41
+ role?: string;
42
+ id?: string;
43
+ index?: number;
44
+ timestamp?: number | string;
45
+ receivedAt?: number | string;
46
+ createdAt?: number | string;
47
+ _turnKey?: string;
48
+ }> | null;
49
+ } | null;
50
+ }): string;
51
+ export declare function buildStatusSnapshot(options: StatusSnapshotOptions): StatusSnapshot;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Host memory metrics — macOS-aware "available" memory.
3
+ *
4
+ * Node's os.freemem() on darwin reports only the tiny truly-free pool; most RAM
5
+ * sits in inactive/file-backed cache that the OS can reclaim. Dashboard "used %"
6
+ * based on (total - freemem) looks ~99% almost always — misleading.
7
+ *
8
+ * On macOS we parse `vm_stat` and approximate available bytes as:
9
+ * (free + inactive + speculative + purgeable [+ file_backed]) × page size
10
+ * (aligned with common Activity Monitor–style interpretations.)
11
+ */
12
+ export interface HostMemorySnapshot {
13
+ totalMem: number;
14
+ /** Raw kernel "free" — small on macOS; kept for debugging / API compat */
15
+ freeMem: number;
16
+ /** Use this for UI "used %" — on darwin from vm_stat; else equals freeMem */
17
+ availableMem: number;
18
+ }
19
+ export declare function getHostMemorySnapshot(): HostMemorySnapshot;
@@ -0,0 +1,123 @@
1
+ /**
2
+ * ADHDev Daemon Core — Shared Types
3
+ *
4
+ * Shared types referenced by daemon-core, daemon-standalone, and web-core.
5
+ * When modifying this file, also update interface contracts in AGENT_PROTOCOL.md.
6
+ */
7
+ import type { StatusReportPayload, AvailableProviderInfo } from './shared-types.js';
8
+ /** Full status response from /api/v1/status and WS events */
9
+ export interface StatusResponse extends StatusReportPayload {
10
+ /** For standalone API compat */
11
+ id: string;
12
+ type: string;
13
+ platform: string;
14
+ hostname: string;
15
+ /** User display name from config */
16
+ userName?: string;
17
+ /** Available providers */
18
+ availableProviders: AvailableProviderInfo[];
19
+ /** System info (legacy compat) */
20
+ system?: SystemInfo;
21
+ }
22
+ export interface ChatMessage {
23
+ role: string;
24
+ /** Plain text (legacy) or rich content blocks (ACP standard) */
25
+ content: string | ContentBlock[];
26
+ kind?: string;
27
+ id?: string;
28
+ index?: number;
29
+ timestamp?: number;
30
+ receivedAt?: number;
31
+ /** Tool calls associated with this message */
32
+ toolCalls?: ToolCallInfo[];
33
+ /** Optional: fiber metadata */
34
+ _type?: string;
35
+ _sub?: string;
36
+ /** Meta information for thought/terminal logs etc */
37
+ meta?: {
38
+ label?: string;
39
+ isRunning?: boolean;
40
+ } | Record<string, any>;
41
+ /** Sender name for shared sessions */
42
+ senderName?: string;
43
+ }
44
+ import type { ContentBlock, ToolCallInfo } from './providers/contracts.js';
45
+ export interface ExtensionInfo {
46
+ id: string;
47
+ type: string;
48
+ name: string;
49
+ isMonitored?: boolean;
50
+ agentStatus?: string;
51
+ }
52
+ export interface CommandResult {
53
+ success: boolean;
54
+ data?: any;
55
+ error?: string;
56
+ }
57
+ export interface ProviderConfig {
58
+ id: string;
59
+ type: 'ide' | 'extension' | 'cli' | 'acp';
60
+ name: string;
61
+ /** CDP port detection */
62
+ cdpDetect?: {
63
+ processName?: string;
64
+ portFlag?: string;
65
+ };
66
+ /** Capabilities */
67
+ capabilities?: string[];
68
+ }
69
+ export type DaemonEvent = {
70
+ type: 'status';
71
+ data: StatusResponse;
72
+ } | {
73
+ type: 'chat_update';
74
+ data: {
75
+ ideId: string;
76
+ messages: ChatMessage[];
77
+ };
78
+ } | {
79
+ type: 'screenshot';
80
+ data: {
81
+ ideId: string;
82
+ base64: string;
83
+ };
84
+ } | {
85
+ type: 'action_log';
86
+ data: {
87
+ ideId: string;
88
+ text: string;
89
+ timestamp: number;
90
+ };
91
+ } | {
92
+ type: 'error';
93
+ data: {
94
+ message: string;
95
+ };
96
+ };
97
+ export interface SystemInfo {
98
+ cpus: number;
99
+ totalMem: number;
100
+ freeMem: number;
101
+ /** macOS: reclaimable-inclusive; prefer for UI used% (see host-memory.ts) */
102
+ availableMem?: number;
103
+ loadavg: number[];
104
+ uptime: number;
105
+ arch: string;
106
+ }
107
+ export interface DetectedIde {
108
+ id: string;
109
+ type: string;
110
+ name: string;
111
+ installed: boolean;
112
+ running: boolean;
113
+ }
114
+ export interface ProviderInfo extends AvailableProviderInfo {
115
+ }
116
+ /** Flattened agent entry from /api/v1/agents */
117
+ export interface AgentEntry {
118
+ ideId: string;
119
+ type: string;
120
+ name: string;
121
+ status: string;
122
+ source: 'native' | 'extension';
123
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/session-host-core",
3
- "version": "0.7.38",
3
+ "version": "0.7.40",
4
4
  "description": "ADHDev local session host core — session registry, protocol, buffers",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/daemon-core",
3
- "version": "0.7.38",
3
+ "version": "0.7.40",
4
4
  "description": "ADHDev daemon core — CDP, IDE detection, providers, command execution",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -19,7 +19,8 @@
19
19
  }
20
20
  },
21
21
  "scripts": {
22
- "build": "tsup",
22
+ "build": "tsup && npm run build:types",
23
+ "build:types": "tsc -p tsconfig.json --emitDeclarationOnly --declaration --declarationMap false",
23
24
  "dev": "tsup --watch",
24
25
  "typecheck": "tsc --noEmit -p tsconfig.json"
25
26
  },
@@ -11,9 +11,8 @@ import * as crypto from 'crypto';
11
11
  import chalk from 'chalk';
12
12
  import { ProviderCliAdapter } from '../cli-adapters/provider-cli-adapter.js';
13
13
  import { detectCLI } from '../detection/cli-detector.js';
14
- import { loadConfig, saveConfig, addCliHistory } from '../config/config.js';
14
+ import { loadConfig, saveConfig } from '../config/config.js';
15
15
  import { getWorkspaceState, resolveLaunchDirectory } from '../config/workspaces.js';
16
- import { appendWorkspaceActivity } from '../config/workspace-activity.js';
17
16
  import { appendRecentActivity } from '../config/recent-activity.js';
18
17
  import { CliProviderInstance } from '../providers/cli-provider-instance.js';
19
18
  import { AcpProviderInstance } from '../providers/acp-provider-instance.js';
@@ -91,25 +90,6 @@ export class DaemonCliManager {
91
90
  return `${cliType}_${hash}`;
92
91
  }
93
92
 
94
- private persistRecentDir(cliType: string, dir: string): void {
95
- try {
96
- const normalizedType = this.providerLoader.resolveAlias(cliType);
97
- const provider = this.providerLoader.getByAlias(cliType);
98
- const actKind = provider?.category === 'acp' ? 'acp' : 'cli';
99
- let next = loadConfig();
100
- console.log(colorize('cyan', ` 📂 Saving recent workspace: ${dir}`));
101
- const recent = next.recentCliWorkspaces || [];
102
- if (!recent.includes(dir)) {
103
- next = { ...next, recentCliWorkspaces: [dir, ...recent].slice(0, 10) };
104
- }
105
- next = appendWorkspaceActivity(next, dir, { kind: actKind, agentType: normalizedType });
106
- saveConfig(next);
107
- console.log(colorize('green', ` ✓ Recent workspace saved: ${dir}`));
108
- } catch (e) {
109
- console.error(colorize('red', ` ✗ Failed to save recent workspace: ${e}`));
110
- }
111
- }
112
-
113
93
  private persistRecentActivity(entry: {
114
94
  kind: 'ide' | 'cli' | 'acp';
115
95
  providerType: string;
@@ -316,7 +296,6 @@ export class DaemonCliManager {
316
296
  }
317
297
  }
318
298
 
319
- try { addCliHistory({ category: 'acp', cliType: normalizedType, dir: resolvedDir, workspace: resolvedDir, cliArgs, model: initialModel }); } catch (e) { LOG.warn('CLI', `ACP history save failed: ${(e as Error)?.message}`); }
320
299
  this.persistRecentActivity({
321
300
  kind: 'acp',
322
301
  providerType: normalizedType,
@@ -393,7 +372,6 @@ export class DaemonCliManager {
393
372
  console.log(colorize('green', ` ✓ CLI started: ${cliInfo.displayName} v${cliInfo.version || 'unknown'} in ${resolvedDir}`));
394
373
  }
395
374
 
396
- try { addCliHistory({ category: 'cli', cliType, dir: resolvedDir, workspace: resolvedDir, cliArgs, model: initialModel }); } catch (e) { LOG.warn('CLI', `CLI history save failed: ${(e as Error)?.message}`); }
397
375
  this.persistRecentActivity({
398
376
  kind: 'cli',
399
377
  providerType: normalizedType,
@@ -569,8 +547,6 @@ export class DaemonCliManager {
569
547
  }
570
548
  }
571
549
 
572
- this.persistRecentDir(cliType, dir);
573
-
574
550
  return { success: true, cliType, dir, id: newKey, launchSource };
575
551
  }
576
552
  case 'stop_cli': {
@@ -614,7 +590,6 @@ export class DaemonCliManager {
614
590
  const found = this.findAdapter(cliType, { instanceKey: args?.targetSessionId, dir });
615
591
  if (found) await this.stopSession(found.key);
616
592
  await this.startSession(cliType, dir);
617
- this.persistRecentDir(cliType, dir);
618
593
  return { success: true, restarted: true };
619
594
  }
620
595
  case 'agent_command': {
@@ -29,7 +29,6 @@ import * as Cdp from './cdp-commands.js';
29
29
  import * as Stream from './stream-commands.js';
30
30
  import * as WorkspaceCmd from './workspace-commands.js';
31
31
  import { getWorkspaceState } from '../config/workspaces.js';
32
- import { getWorkspaceActivity } from '../config/workspace-activity.js';
33
32
 
34
33
  export interface CommandResult {
35
34
  success: boolean;
@@ -416,27 +415,11 @@ export class DaemonCommandHandler implements CommandHelpers {
416
415
  case 'file_list': return Cdp.handleFileList(this, args);
417
416
  case 'file_list_browse': return Cdp.handleFileListBrowse(this, args);
418
417
 
419
- // ─── VSCode API commands (not available) ────
420
- case 'vscode_command_exec':
421
- case 'execute_vscode_command': {
422
- const resolvedCmd = args?.commandId || args?.command;
423
- if (resolvedCmd === 'adhdev.captureCdpScreenshot') {
424
- return Cdp.handleScreenshot(this, args);
425
- }
426
- return { success: false, error: `VSCode command not available: ${resolvedCmd || cmd}` };
427
- }
428
418
  // ─── Workspace cmds ──────────────
429
- case 'get_recent_workspaces': return this.handleGetRecentWorkspaces(args);
430
- case 'get_cli_history': {
431
- const config = loadConfig();
432
- return { success: true, history: config.cliHistory || [] };
433
- }
434
-
435
419
  case 'workspace_list': return WorkspaceCmd.handleWorkspaceList();
436
420
  case 'workspace_add': return WorkspaceCmd.handleWorkspaceAdd(args);
437
421
  case 'workspace_remove': return WorkspaceCmd.handleWorkspaceRemove(args);
438
422
  case 'workspace_set_default':
439
- case 'workspace_set_active':
440
423
  return WorkspaceCmd.handleWorkspaceSetDefault(args);
441
424
 
442
425
  // ─── Script manage ───────────────────
@@ -476,20 +459,6 @@ export class DaemonCommandHandler implements CommandHelpers {
476
459
 
477
460
  // ─── Misc (kept in handler — too small to extract) ───────
478
461
 
479
- private async handleGetRecentWorkspaces(_args: any): Promise<CommandResult> {
480
- const config = loadConfig();
481
- const cliRecent = config.recentCliWorkspaces || [];
482
- const ws = getWorkspaceState(config);
483
- return {
484
- success: true,
485
- result: cliRecent,
486
- workspaces: ws.workspaces,
487
- defaultWorkspaceId: ws.defaultWorkspaceId,
488
- defaultWorkspacePath: ws.defaultWorkspacePath,
489
- activity: getWorkspaceActivity(config, 25),
490
- };
491
- }
492
-
493
462
  private async handleRefreshScripts(_args: any): Promise<CommandResult> {
494
463
  if (this._ctx.providerLoader) {
495
464
  await this._ctx.providerLoader.fetchLatest().catch(() => {});