@adhdev/daemon-core 0.7.6 → 0.7.9

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 (41) hide show
  1. package/dist/index.d.mts +158 -38
  2. package/dist/index.d.ts +158 -38
  3. package/dist/index.js +3965 -2521
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +3455 -2011
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/{normalize-tKg8IiDk.d.mts → normalize-auJAPmKy.d.mts} +669 -629
  8. package/dist/{normalize-tKg8IiDk.d.ts → normalize-auJAPmKy.d.ts} +669 -629
  9. package/dist/status/normalize.d.mts +1 -1
  10. package/dist/status/normalize.d.ts +1 -1
  11. package/package.json +5 -1
  12. package/src/boot/daemon-lifecycle.ts +7 -4
  13. package/src/cli-adapter-types.ts +2 -0
  14. package/src/cli-adapters/provider-cli-adapter.ts +148 -11
  15. package/src/cli-adapters/pty-transport.ts +100 -0
  16. package/src/cli-adapters/session-host-transport.ts +392 -0
  17. package/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts +126 -0
  18. package/src/cli-adapters/terminal-backends/types.ts +17 -0
  19. package/src/cli-adapters/terminal-backends/xterm-backend.ts +87 -0
  20. package/src/cli-adapters/terminal-screen.ts +40 -53
  21. package/src/commands/cli-manager.ts +184 -55
  22. package/src/config/config.d.ts +116 -0
  23. package/src/config/workspace-activity.d.ts +22 -0
  24. package/src/config/workspaces.d.ts +84 -0
  25. package/src/daemon/dev-auto-implement.ts +1087 -0
  26. package/src/daemon/dev-cdp-handlers.ts +1003 -0
  27. package/src/daemon/dev-cli-debug.ts +288 -0
  28. package/src/daemon/dev-server-types.ts +45 -0
  29. package/src/daemon/dev-server.ts +121 -1698
  30. package/src/index.ts +5 -1
  31. package/src/providers/cli-provider-instance.ts +13 -1
  32. package/src/providers/contracts.d.ts +408 -0
  33. package/src/providers/contracts.ts +9 -0
  34. package/src/providers/provider-instance-manager.ts +21 -0
  35. package/src/providers/provider-instance.d.ts +142 -0
  36. package/src/providers/provider-instance.ts +23 -1
  37. package/src/shared-types.d.ts +157 -0
  38. package/src/shared-types.ts +14 -0
  39. package/src/status/builders.ts +6 -0
  40. package/src/status/normalize.d.ts +14 -0
  41. package/src/types.d.ts +127 -0
@@ -8,7 +8,7 @@
8
8
  * Each Instance manages its own status.
9
9
  */
10
10
 
11
- import type { ProviderModule, ProviderSettingDef } from './contracts.js';
11
+ import type { ProviderModule, ProviderSettingDef, ProviderResumeCapability } from './contracts.js';
12
12
  import type { AcpConfigOption, AcpMode } from '../shared-types.js';
13
13
  import type { ChatMessage } from '../types.js';
14
14
 
@@ -16,6 +16,26 @@ import type { ChatMessage } from '../types.js';
16
16
 
17
17
  export type ProviderStatus = 'idle' | 'generating' | 'waiting_approval' | 'error' | 'stopped' | 'starting';
18
18
 
19
+ export interface ProviderRuntimeWriteOwner {
20
+ clientId: string;
21
+ ownerType: 'agent' | 'user';
22
+ }
23
+
24
+ export interface ProviderRuntimeClient {
25
+ clientId: string;
26
+ type: 'daemon' | 'web' | 'local-terminal';
27
+ readOnly: boolean;
28
+ }
29
+
30
+ export interface ProviderRuntimeInfo {
31
+ runtimeId: string;
32
+ runtimeKey?: string;
33
+ displayName?: string;
34
+ workspaceLabel?: string;
35
+ writeOwner?: ProviderRuntimeWriteOwner | null;
36
+ attachedClients?: ProviderRuntimeClient[];
37
+ }
38
+
19
39
  export interface ActiveChatData {
20
40
  id: string;
21
41
  title: string;
@@ -61,6 +81,8 @@ interface ProviderStateBase {
61
81
  settings: Record<string, any>;
62
82
  /** Event queue (cleared after daemon collects) */
63
83
  pendingEvents: ProviderEvent[];
84
+ runtime?: ProviderRuntimeInfo;
85
+ resume?: ProviderResumeCapability;
64
86
  }
65
87
 
66
88
  /** IDE provider state */
@@ -0,0 +1,157 @@
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
+ export interface SessionEntry {
40
+ id: string;
41
+ parentId: string | null;
42
+ providerType: string;
43
+ providerName: string;
44
+ kind: SessionKind;
45
+ transport: SessionTransport;
46
+ status: 'idle' | 'generating' | 'waiting_approval' | 'error' | 'stopped' | 'starting' | 'panel_hidden' | 'not_monitored' | 'disconnected';
47
+ title: string;
48
+ workspace: string | null;
49
+ runtimeKey?: string;
50
+ runtimeDisplayName?: string;
51
+ runtimeWorkspaceLabel?: string;
52
+ runtimeWriteOwner?: {
53
+ clientId: string;
54
+ ownerType: 'agent' | 'user';
55
+ } | null;
56
+ runtimeAttachedClients?: {
57
+ clientId: string;
58
+ type: 'daemon' | 'web' | 'local-terminal';
59
+ readOnly: boolean;
60
+ }[];
61
+ resume?: ProviderResumeCapability;
62
+ activeChat: _ActiveChatData | null;
63
+ capabilities: SessionCapability[];
64
+ cdpConnected?: boolean;
65
+ currentModel?: string;
66
+ currentPlan?: string;
67
+ currentAutoApprove?: string;
68
+ acpConfigOptions?: AcpConfigOption[];
69
+ acpModes?: AcpMode[];
70
+ errorMessage?: string;
71
+ errorReason?: _ProviderErrorReason;
72
+ }
73
+ /** Available provider information */
74
+ export interface AvailableProviderInfo {
75
+ type: string;
76
+ name: string;
77
+ category: 'ide' | 'extension' | 'cli' | 'acp';
78
+ displayName: string;
79
+ icon: string;
80
+ }
81
+ /** ACP config option (model/mode/thought_level selection) */
82
+ export interface AcpConfigOption {
83
+ category: 'model' | 'mode' | 'thought_level' | 'other';
84
+ configId: string;
85
+ currentValue?: string;
86
+ options: {
87
+ value: string;
88
+ name: string;
89
+ description?: string;
90
+ group?: string;
91
+ }[];
92
+ }
93
+ /** ACP mode */
94
+ export interface AcpMode {
95
+ id: string;
96
+ name: string;
97
+ description?: string;
98
+ }
99
+ /** Machine hardware/OS info (reported by daemon, displayed by web) */
100
+ export interface MachineInfo {
101
+ hostname: string;
102
+ platform: string;
103
+ arch: string;
104
+ cpus: number;
105
+ totalMem: number;
106
+ freeMem: number;
107
+ /** macOS: reclaimable-inclusive; prefer for UI used% */
108
+ availableMem?: number;
109
+ loadavg: number[];
110
+ uptime: number;
111
+ release: string;
112
+ }
113
+ /** Detected IDE on a machine */
114
+ export interface DetectedIdeInfo {
115
+ type: string;
116
+ id?: string;
117
+ name: string;
118
+ running: boolean;
119
+ path?: string;
120
+ }
121
+ /** Workspace recent activity */
122
+ export interface WorkspaceActivity {
123
+ path: string;
124
+ lastUsedAt: number;
125
+ kind?: string;
126
+ agentType?: string;
127
+ }
128
+ export interface StatusReportPayload {
129
+ /** Daemon instance ID */
130
+ instanceId: string;
131
+ /** Daemon version */
132
+ version: string;
133
+ /** Daemon mode flag */
134
+ daemonMode: boolean;
135
+ /** Machine info */
136
+ machine: MachineInfo;
137
+ /** Machine nickname (user-set) */
138
+ machineNickname?: string | null;
139
+ /** Timestamp */
140
+ timestamp: number;
141
+ /** Detected IDEs on this machine */
142
+ detectedIdes: DetectedIdeInfo[];
143
+ /** P2P state */
144
+ p2p?: {
145
+ available: boolean;
146
+ state: string;
147
+ peers: number;
148
+ screenshotActive?: boolean;
149
+ };
150
+ /** Canonical daemon runtime sessions */
151
+ sessions: SessionEntry[];
152
+ /** Saved workspaces */
153
+ workspaces?: WorkspaceEntry[];
154
+ defaultWorkspaceId?: string | null;
155
+ defaultWorkspacePath?: string | null;
156
+ workspaceActivity?: WorkspaceActivity[];
157
+ }
@@ -43,6 +43,7 @@ export type { ProviderErrorReason } from './providers/provider-instance.js';
43
43
  // Local import for use in Managed*Entry types below
44
44
  import type { ActiveChatData as _ActiveChatData, ProviderErrorReason as _ProviderErrorReason } from './providers/provider-instance.js';
45
45
  import type { WorkspaceEntry } from './config/workspaces.js';
46
+ import type { ProviderResumeCapability } from './providers/contracts.js';
46
47
 
47
48
  // Re-export WorkspaceEntry for downstream consumers
48
49
  export type { WorkspaceEntry } from './config/workspaces.js';
@@ -95,6 +96,19 @@ export interface SessionEntry {
95
96
  status: 'idle' | 'generating' | 'waiting_approval' | 'error' | 'stopped' | 'starting' | 'panel_hidden' | 'not_monitored' | 'disconnected';
96
97
  title: string;
97
98
  workspace: string | null;
99
+ runtimeKey?: string;
100
+ runtimeDisplayName?: string;
101
+ runtimeWorkspaceLabel?: string;
102
+ runtimeWriteOwner?: {
103
+ clientId: string;
104
+ ownerType: 'agent' | 'user';
105
+ } | null;
106
+ runtimeAttachedClients?: {
107
+ clientId: string;
108
+ type: 'daemon' | 'web' | 'local-terminal';
109
+ readOnly: boolean;
110
+ }[];
111
+ resume?: ProviderResumeCapability;
98
112
  activeChat: _ActiveChatData | null;
99
113
  capabilities: SessionCapability[];
100
114
  cdpConnected?: boolean;
@@ -185,6 +185,12 @@ function buildCliSession(state: CliProviderState): SessionEntry {
185
185
  }),
186
186
  title: activeChat?.title || state.name,
187
187
  workspace: state.workspace || null,
188
+ runtimeKey: state.runtime?.runtimeKey,
189
+ runtimeDisplayName: state.runtime?.displayName,
190
+ runtimeWorkspaceLabel: state.runtime?.workspaceLabel,
191
+ runtimeWriteOwner: state.runtime?.writeOwner || null,
192
+ runtimeAttachedClients: state.runtime?.attachedClients || [],
193
+ resume: state.resume,
188
194
  activeChat,
189
195
  capabilities: PTY_SESSION_CAPABILITIES,
190
196
  errorMessage: state.errorMessage,
@@ -0,0 +1,14 @@
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;
package/src/types.d.ts ADDED
@@ -0,0 +1,127 @@
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 } 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: ProviderInfo[];
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 {
115
+ type: string;
116
+ icon: string;
117
+ displayName: string;
118
+ category: string;
119
+ }
120
+ /** Flattened agent entry from /api/v1/agents */
121
+ export interface AgentEntry {
122
+ ideId: string;
123
+ type: string;
124
+ name: string;
125
+ status: string;
126
+ source: 'native' | 'extension';
127
+ }