@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.
- package/dist/index.d.mts +2342 -0
- package/dist/index.d.ts +86 -932
- package/dist/index.js +879 -664
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14702 -0
- package/dist/index.mjs.map +1 -0
- package/dist/normalize-S2PmiRgB.d.mts +843 -0
- package/dist/normalize-S2PmiRgB.d.ts +843 -0
- package/dist/status/normalize.d.mts +1 -0
- package/dist/status/normalize.d.ts +1 -0
- package/dist/status/normalize.js +73 -0
- package/dist/status/normalize.js.map +1 -0
- package/dist/status/normalize.mjs +45 -0
- package/dist/status/normalize.mjs.map +1 -0
- package/package.json +8 -1
- package/src/agent-stream/manager.ts +213 -150
- package/src/agent-stream/poller.ts +57 -45
- package/src/boot/daemon-lifecycle.ts +30 -12
- package/src/cdp/initializer.ts +47 -0
- package/src/cdp/manager.ts +45 -4
- package/src/cdp/setup.ts +26 -11
- package/src/commands/chat-commands.ts +136 -88
- package/src/commands/cli-manager.ts +31 -6
- package/src/commands/handler.ts +71 -109
- package/src/commands/router.ts +4 -20
- package/src/commands/stream-commands.ts +34 -156
- package/src/daemon-core.ts +3 -9
- package/src/index.ts +8 -5
- package/src/logging/command-log.ts +1 -1
- package/src/providers/acp-provider-instance.ts +4 -0
- package/src/providers/provider-instance-manager.ts +1 -0
- package/src/sessions/registry.ts +76 -0
- package/src/shared-types.ts +45 -54
- package/src/status/builders.ts +157 -120
- package/src/status/normalize.ts +64 -0
- package/src/status/reporter.ts +16 -15
- package/src/status/snapshot.ts +3 -11
|
@@ -259,6 +259,10 @@ export class AcpProviderInstance implements ProviderInstance {
|
|
|
259
259
|
}
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
+
getInstanceId(): string {
|
|
263
|
+
return this.instanceId;
|
|
264
|
+
}
|
|
265
|
+
|
|
262
266
|
// ─── ACP Config Options & Modes ─────────────────────
|
|
263
267
|
|
|
264
268
|
private parseConfigOptions(raw: any): void {
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { SessionTransport } from '../shared-types.js';
|
|
2
|
+
|
|
3
|
+
export interface SessionRuntimeTarget {
|
|
4
|
+
sessionId: string;
|
|
5
|
+
parentSessionId: string | null;
|
|
6
|
+
providerType: string;
|
|
7
|
+
providerCategory: 'ide' | 'extension' | 'cli' | 'acp';
|
|
8
|
+
transport: SessionTransport;
|
|
9
|
+
cdpManagerKey?: string;
|
|
10
|
+
adapterKey?: string;
|
|
11
|
+
instanceKey?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class SessionRegistry {
|
|
15
|
+
private readonly bySessionId = new Map<string, SessionRuntimeTarget>();
|
|
16
|
+
private readonly byManagerKey = new Map<string, Set<string>>();
|
|
17
|
+
private readonly byInstanceKey = new Map<string, Set<string>>();
|
|
18
|
+
private readonly byParentSessionId = new Map<string, Set<string>>();
|
|
19
|
+
|
|
20
|
+
register(target: SessionRuntimeTarget): void {
|
|
21
|
+
this.unregister(target.sessionId);
|
|
22
|
+
this.bySessionId.set(target.sessionId, target);
|
|
23
|
+
if (target.cdpManagerKey) this.addIndex(this.byManagerKey, target.cdpManagerKey, target.sessionId);
|
|
24
|
+
if (target.instanceKey) this.addIndex(this.byInstanceKey, target.instanceKey, target.sessionId);
|
|
25
|
+
if (target.parentSessionId) this.addIndex(this.byParentSessionId, target.parentSessionId, target.sessionId);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
get(sessionId: string | undefined | null): SessionRuntimeTarget | undefined {
|
|
29
|
+
if (!sessionId) return undefined;
|
|
30
|
+
return this.bySessionId.get(sessionId);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
unregister(sessionId: string | undefined | null): void {
|
|
34
|
+
if (!sessionId) return;
|
|
35
|
+
const target = this.bySessionId.get(sessionId);
|
|
36
|
+
if (!target) return;
|
|
37
|
+
this.bySessionId.delete(sessionId);
|
|
38
|
+
if (target.cdpManagerKey) this.removeIndex(this.byManagerKey, target.cdpManagerKey, sessionId);
|
|
39
|
+
if (target.instanceKey) this.removeIndex(this.byInstanceKey, target.instanceKey, sessionId);
|
|
40
|
+
if (target.parentSessionId) this.removeIndex(this.byParentSessionId, target.parentSessionId, sessionId);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
unregisterByManagerKey(managerKey: string): void {
|
|
44
|
+
for (const sessionId of [...(this.byManagerKey.get(managerKey) || [])]) {
|
|
45
|
+
this.unregister(sessionId);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
unregisterByInstanceKey(instanceKey: string): void {
|
|
50
|
+
for (const sessionId of [...(this.byInstanceKey.get(instanceKey) || [])]) {
|
|
51
|
+
this.unregister(sessionId);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
listChildren(parentSessionId: string): SessionRuntimeTarget[] {
|
|
56
|
+
const ids = this.byParentSessionId.get(parentSessionId);
|
|
57
|
+
if (!ids) return [];
|
|
58
|
+
return [...ids].map((id) => this.bySessionId.get(id)).filter(Boolean) as SessionRuntimeTarget[];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private addIndex(index: Map<string, Set<string>>, key: string, sessionId: string): void {
|
|
62
|
+
let set = index.get(key);
|
|
63
|
+
if (!set) {
|
|
64
|
+
set = new Set<string>();
|
|
65
|
+
index.set(key, set);
|
|
66
|
+
}
|
|
67
|
+
set.add(sessionId);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private removeIndex(index: Map<string, Set<string>>, key: string, sessionId: string): void {
|
|
71
|
+
const set = index.get(key);
|
|
72
|
+
if (!set) return;
|
|
73
|
+
set.delete(sessionId);
|
|
74
|
+
if (set.size === 0) index.delete(key);
|
|
75
|
+
}
|
|
76
|
+
}
|
package/src/shared-types.ts
CHANGED
|
@@ -41,7 +41,7 @@ export type {
|
|
|
41
41
|
export type { ProviderErrorReason } from './providers/provider-instance.js';
|
|
42
42
|
|
|
43
43
|
// Local import for use in Managed*Entry types below
|
|
44
|
-
import type { ActiveChatData as _ActiveChatData } from './providers/provider-instance.js';
|
|
44
|
+
import type { ActiveChatData as _ActiveChatData, ProviderErrorReason as _ProviderErrorReason } from './providers/provider-instance.js';
|
|
45
45
|
import type { WorkspaceEntry } from './config/workspaces.js';
|
|
46
46
|
|
|
47
47
|
// Re-export WorkspaceEntry for downstream consumers
|
|
@@ -51,63 +51,58 @@ export type { WorkspaceEntry } from './config/workspaces.js';
|
|
|
51
51
|
// These define the shape of data sent by DaemonStatusReporter
|
|
52
52
|
// and consumed by web-core and downstream consumers.
|
|
53
53
|
|
|
54
|
-
/**
|
|
55
|
-
export interface
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
activeChat: _ActiveChatData | null;
|
|
63
|
-
chats: unknown[];
|
|
64
|
-
agentStreams: ManagedAgentStream[];
|
|
65
|
-
cdpConnected: boolean;
|
|
66
|
-
currentModel?: string;
|
|
67
|
-
currentPlan?: string;
|
|
68
|
-
currentAutoApprove?: string;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/** CLI entry as reported by daemon to dashboard */
|
|
72
|
-
export interface ManagedCliEntry {
|
|
73
|
-
id: string;
|
|
74
|
-
instanceId: string;
|
|
75
|
-
cliType: string;
|
|
76
|
-
cliName: string;
|
|
54
|
+
/** Agent stream snapshot carried by flattened UI entries. */
|
|
55
|
+
export interface AgentSessionStream {
|
|
56
|
+
sessionId?: string;
|
|
57
|
+
parentSessionId?: string | null;
|
|
58
|
+
agentType: string;
|
|
59
|
+
agentName: string;
|
|
60
|
+
extensionId: string;
|
|
61
|
+
transport?: SessionTransport;
|
|
77
62
|
status: string;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
63
|
+
messages: ChatMessage[];
|
|
64
|
+
inputContent: string;
|
|
65
|
+
model?: string;
|
|
66
|
+
activeModal: { message: string; buttons: string[] } | null;
|
|
81
67
|
}
|
|
82
68
|
|
|
83
|
-
|
|
84
|
-
|
|
69
|
+
export type SessionTransport = 'cdp-page' | 'cdp-webview' | 'pty' | 'acp';
|
|
70
|
+
|
|
71
|
+
export type SessionKind = 'workspace' | 'agent';
|
|
72
|
+
|
|
73
|
+
export type SessionCapability =
|
|
74
|
+
| 'read_chat'
|
|
75
|
+
| 'send_message'
|
|
76
|
+
| 'new_session'
|
|
77
|
+
| 'list_sessions'
|
|
78
|
+
| 'switch_session'
|
|
79
|
+
| 'resolve_action'
|
|
80
|
+
| 'terminal_io'
|
|
81
|
+
| 'resize_terminal'
|
|
82
|
+
| 'change_model'
|
|
83
|
+
| 'set_mode'
|
|
84
|
+
| 'set_thought_level';
|
|
85
|
+
|
|
86
|
+
export interface SessionEntry {
|
|
85
87
|
id: string;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
parentId: string | null;
|
|
89
|
+
providerType: string;
|
|
90
|
+
providerName: string;
|
|
91
|
+
kind: SessionKind;
|
|
92
|
+
transport: SessionTransport;
|
|
93
|
+
status: 'idle' | 'generating' | 'waiting_approval' | 'error' | 'stopped' | 'starting' | 'panel_hidden' | 'not_monitored' | 'disconnected';
|
|
94
|
+
title: string;
|
|
95
|
+
workspace: string | null;
|
|
91
96
|
activeChat: _ActiveChatData | null;
|
|
97
|
+
capabilities: SessionCapability[];
|
|
98
|
+
cdpConnected?: boolean;
|
|
92
99
|
currentModel?: string;
|
|
93
100
|
currentPlan?: string;
|
|
101
|
+
currentAutoApprove?: string;
|
|
94
102
|
acpConfigOptions?: AcpConfigOption[];
|
|
95
103
|
acpModes?: AcpMode[];
|
|
96
|
-
/** Error details */
|
|
97
104
|
errorMessage?: string;
|
|
98
|
-
errorReason?:
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/** Agent stream within an IDE (extension status) */
|
|
102
|
-
export interface ManagedAgentStream {
|
|
103
|
-
agentType: string;
|
|
104
|
-
agentName: string;
|
|
105
|
-
extensionId: string;
|
|
106
|
-
status: string;
|
|
107
|
-
messages: ChatMessage[];
|
|
108
|
-
inputContent: string;
|
|
109
|
-
model?: string;
|
|
110
|
-
activeModal: { message: string; buttons: string[] } | null;
|
|
105
|
+
errorReason?: _ProviderErrorReason;
|
|
111
106
|
}
|
|
112
107
|
|
|
113
108
|
/** Available provider information */
|
|
@@ -188,12 +183,8 @@ export interface StatusReportPayload {
|
|
|
188
183
|
detectedIdes: DetectedIdeInfo[];
|
|
189
184
|
/** P2P state */
|
|
190
185
|
p2p?: { available: boolean; state: string; peers: number; screenshotActive?: boolean };
|
|
191
|
-
/**
|
|
192
|
-
|
|
193
|
-
/** Managed CLI instances */
|
|
194
|
-
managedClis: ManagedCliEntry[];
|
|
195
|
-
/** Managed ACP instances */
|
|
196
|
-
managedAcps: ManagedAcpEntry[];
|
|
186
|
+
/** Canonical daemon runtime sessions */
|
|
187
|
+
sessions: SessionEntry[];
|
|
197
188
|
/** Saved workspaces */
|
|
198
189
|
workspaces?: WorkspaceEntry[];
|
|
199
190
|
defaultWorkspaceId?: string | null;
|
package/src/status/builders.ts
CHANGED
|
@@ -9,13 +9,15 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import type { DaemonCdpManager } from '../cdp/manager.js';
|
|
12
|
-
import type {
|
|
12
|
+
import type { SessionEntry, SessionCapability } from '../shared-types.js';
|
|
13
13
|
import type {
|
|
14
14
|
IdeProviderState,
|
|
15
15
|
CliProviderState,
|
|
16
16
|
AcpProviderState,
|
|
17
|
+
ExtensionProviderState,
|
|
17
18
|
ProviderState,
|
|
18
19
|
} from '../providers/provider-instance.js';
|
|
20
|
+
import { normalizeActiveChatData, normalizeManagedStatus } from './normalize.js';
|
|
19
21
|
|
|
20
22
|
// ─── CDP Manager lookup helpers ──────────────────────
|
|
21
23
|
|
|
@@ -73,137 +75,172 @@ export function isCdpConnected(
|
|
|
73
75
|
return m?.isConnected ?? false;
|
|
74
76
|
}
|
|
75
77
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
78
|
+
const IDE_SESSION_CAPABILITIES: SessionCapability[] = [
|
|
79
|
+
'read_chat',
|
|
80
|
+
'send_message',
|
|
81
|
+
'new_session',
|
|
82
|
+
'list_sessions',
|
|
83
|
+
'switch_session',
|
|
84
|
+
'resolve_action',
|
|
85
|
+
'change_model',
|
|
86
|
+
'set_mode',
|
|
87
|
+
'set_thought_level',
|
|
88
|
+
];
|
|
89
|
+
|
|
90
|
+
const EXTENSION_SESSION_CAPABILITIES: SessionCapability[] = [
|
|
91
|
+
'read_chat',
|
|
92
|
+
'send_message',
|
|
93
|
+
'new_session',
|
|
94
|
+
'list_sessions',
|
|
95
|
+
'switch_session',
|
|
96
|
+
'resolve_action',
|
|
97
|
+
'change_model',
|
|
98
|
+
'set_mode',
|
|
99
|
+
];
|
|
100
|
+
|
|
101
|
+
const PTY_SESSION_CAPABILITIES: SessionCapability[] = [
|
|
102
|
+
'read_chat',
|
|
103
|
+
'send_message',
|
|
104
|
+
'resolve_action',
|
|
105
|
+
'terminal_io',
|
|
106
|
+
'resize_terminal',
|
|
107
|
+
];
|
|
108
|
+
|
|
109
|
+
const ACP_SESSION_CAPABILITIES: SessionCapability[] = [
|
|
110
|
+
'read_chat',
|
|
111
|
+
'send_message',
|
|
112
|
+
'new_session',
|
|
113
|
+
'resolve_action',
|
|
114
|
+
'change_model',
|
|
115
|
+
'set_mode',
|
|
116
|
+
'set_thought_level',
|
|
117
|
+
];
|
|
118
|
+
|
|
119
|
+
function buildIdeWorkspaceSession(
|
|
120
|
+
state: IdeProviderState,
|
|
87
121
|
cdpManagers: Map<string, DaemonCdpManager>,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
})),
|
|
114
|
-
cdpConnected,
|
|
115
|
-
currentModel: state.currentModel,
|
|
116
|
-
currentPlan: state.currentPlan,
|
|
117
|
-
currentAutoApprove: state.currentAutoApprove,
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// Include CDPs with no ProviderInstance yet (newly detected IDEs)
|
|
122
|
-
if (opts?.detectedIdes) {
|
|
123
|
-
const coveredTypes = new Set(ideStates.map((s) => s.type));
|
|
124
|
-
for (const ide of opts.detectedIdes) {
|
|
125
|
-
if (!ide.installed || coveredTypes.has(ide.id)) continue;
|
|
126
|
-
if (!isCdpConnected(cdpManagers, ide.id)) continue;
|
|
127
|
-
result.push({
|
|
128
|
-
ideType: ide.id,
|
|
129
|
-
ideVersion: '',
|
|
130
|
-
instanceId: ide.id,
|
|
131
|
-
workspace: null,
|
|
132
|
-
terminals: 0,
|
|
133
|
-
aiAgents: [],
|
|
134
|
-
activeChat: null,
|
|
135
|
-
chats: [],
|
|
136
|
-
agentStreams: [],
|
|
137
|
-
cdpConnected: true,
|
|
138
|
-
currentModel: undefined,
|
|
139
|
-
currentPlan: undefined,
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
}
|
|
122
|
+
): SessionEntry {
|
|
123
|
+
const activeChat = normalizeActiveChatData(state.activeChat);
|
|
124
|
+
const title = activeChat?.title || state.name;
|
|
125
|
+
return {
|
|
126
|
+
id: state.instanceId || state.type,
|
|
127
|
+
parentId: null,
|
|
128
|
+
providerType: state.type,
|
|
129
|
+
providerName: state.name,
|
|
130
|
+
kind: 'workspace',
|
|
131
|
+
transport: 'cdp-page',
|
|
132
|
+
status: normalizeManagedStatus(activeChat?.status || state.status, {
|
|
133
|
+
activeModal: activeChat?.activeModal || null,
|
|
134
|
+
}),
|
|
135
|
+
title,
|
|
136
|
+
workspace: state.workspace || null,
|
|
137
|
+
activeChat,
|
|
138
|
+
capabilities: IDE_SESSION_CAPABILITIES,
|
|
139
|
+
cdpConnected: state.cdpConnected ?? isCdpConnected(cdpManagers, state.type),
|
|
140
|
+
currentModel: state.currentModel,
|
|
141
|
+
currentPlan: state.currentPlan,
|
|
142
|
+
currentAutoApprove: state.currentAutoApprove,
|
|
143
|
+
errorMessage: state.errorMessage,
|
|
144
|
+
errorReason: state.errorReason,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
143
147
|
|
|
144
|
-
|
|
148
|
+
function buildExtensionAgentSession(
|
|
149
|
+
parent: IdeProviderState,
|
|
150
|
+
ext: ExtensionProviderState,
|
|
151
|
+
): SessionEntry {
|
|
152
|
+
const activeChat = normalizeActiveChatData(ext.activeChat);
|
|
153
|
+
return {
|
|
154
|
+
id: ext.instanceId || `${parent.instanceId}:${ext.type}`,
|
|
155
|
+
parentId: parent.instanceId || parent.type,
|
|
156
|
+
providerType: ext.type,
|
|
157
|
+
providerName: ext.name,
|
|
158
|
+
kind: 'agent',
|
|
159
|
+
transport: 'cdp-webview',
|
|
160
|
+
status: normalizeManagedStatus(activeChat?.status || ext.status, {
|
|
161
|
+
activeModal: activeChat?.activeModal || null,
|
|
162
|
+
}),
|
|
163
|
+
title: activeChat?.title || ext.name,
|
|
164
|
+
workspace: parent.workspace || null,
|
|
165
|
+
activeChat,
|
|
166
|
+
capabilities: EXTENSION_SESSION_CAPABILITIES,
|
|
167
|
+
currentModel: ext.currentModel,
|
|
168
|
+
currentPlan: ext.currentPlan,
|
|
169
|
+
errorMessage: ext.errorMessage,
|
|
170
|
+
errorReason: ext.errorReason,
|
|
171
|
+
};
|
|
145
172
|
}
|
|
146
173
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
workspace:
|
|
161
|
-
activeChat
|
|
162
|
-
|
|
174
|
+
function buildCliSession(state: CliProviderState): SessionEntry {
|
|
175
|
+
const activeChat = normalizeActiveChatData(state.activeChat);
|
|
176
|
+
return {
|
|
177
|
+
id: state.instanceId,
|
|
178
|
+
parentId: null,
|
|
179
|
+
providerType: state.type,
|
|
180
|
+
providerName: state.name,
|
|
181
|
+
kind: 'agent',
|
|
182
|
+
transport: 'pty',
|
|
183
|
+
status: normalizeManagedStatus(activeChat?.status || state.status, {
|
|
184
|
+
activeModal: activeChat?.activeModal || null,
|
|
185
|
+
}),
|
|
186
|
+
title: activeChat?.title || state.name,
|
|
187
|
+
workspace: state.workspace || null,
|
|
188
|
+
activeChat,
|
|
189
|
+
capabilities: PTY_SESSION_CAPABILITIES,
|
|
190
|
+
errorMessage: state.errorMessage,
|
|
191
|
+
errorReason: state.errorReason,
|
|
192
|
+
};
|
|
163
193
|
}
|
|
164
194
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
195
|
+
function buildAcpSession(state: AcpProviderState): SessionEntry {
|
|
196
|
+
const activeChat = normalizeActiveChatData(state.activeChat);
|
|
197
|
+
return {
|
|
198
|
+
id: state.instanceId,
|
|
199
|
+
parentId: null,
|
|
200
|
+
providerType: state.type,
|
|
201
|
+
providerName: state.name,
|
|
202
|
+
kind: 'agent',
|
|
203
|
+
transport: 'acp',
|
|
204
|
+
status: normalizeManagedStatus(activeChat?.status || state.status, {
|
|
205
|
+
activeModal: activeChat?.activeModal || null,
|
|
206
|
+
}),
|
|
207
|
+
title: activeChat?.title || state.name,
|
|
208
|
+
workspace: state.workspace || null,
|
|
209
|
+
activeChat,
|
|
210
|
+
capabilities: ACP_SESSION_CAPABILITIES,
|
|
211
|
+
currentModel: state.currentModel,
|
|
212
|
+
currentPlan: state.currentPlan,
|
|
213
|
+
acpConfigOptions: state.acpConfigOptions,
|
|
214
|
+
acpModes: state.acpModes,
|
|
215
|
+
errorMessage: state.errorMessage,
|
|
216
|
+
errorReason: state.errorReason,
|
|
217
|
+
};
|
|
186
218
|
}
|
|
187
219
|
|
|
188
|
-
|
|
189
|
-
* Convenience: collect & build all managed entries from instanceManager
|
|
190
|
-
*/
|
|
191
|
-
export function buildAllManagedEntries(
|
|
220
|
+
export function buildSessionEntries(
|
|
192
221
|
allStates: ProviderState[],
|
|
193
222
|
cdpManagers: Map<string, DaemonCdpManager>,
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
managedClis: ManagedCliEntry[];
|
|
198
|
-
managedAcps: ManagedAcpEntry[];
|
|
199
|
-
} {
|
|
223
|
+
): SessionEntry[] {
|
|
224
|
+
const sessions: SessionEntry[] = [];
|
|
225
|
+
|
|
200
226
|
const ideStates = allStates.filter((s): s is IdeProviderState => s.category === 'ide');
|
|
201
227
|
const cliStates = allStates.filter((s): s is CliProviderState => s.category === 'cli');
|
|
202
228
|
const acpStates = allStates.filter((s): s is AcpProviderState => s.category === 'acp');
|
|
203
229
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
230
|
+
for (const state of ideStates) {
|
|
231
|
+
sessions.push(buildIdeWorkspaceSession(state, cdpManagers));
|
|
232
|
+
for (const ext of state.extensions as ExtensionProviderState[]) {
|
|
233
|
+
sessions.push(buildExtensionAgentSession(state, ext));
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
for (const state of cliStates) {
|
|
238
|
+
sessions.push(buildCliSession(state));
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
for (const state of acpStates) {
|
|
242
|
+
sessions.push(buildAcpSession(state));
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return sessions;
|
|
209
246
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { ActiveChatData } from '../providers/provider-instance.js';
|
|
2
|
+
|
|
3
|
+
export type ManagedStatus =
|
|
4
|
+
| 'idle'
|
|
5
|
+
| 'generating'
|
|
6
|
+
| 'waiting_approval'
|
|
7
|
+
| 'error'
|
|
8
|
+
| 'stopped'
|
|
9
|
+
| 'starting'
|
|
10
|
+
| 'panel_hidden'
|
|
11
|
+
| 'not_monitored'
|
|
12
|
+
| 'disconnected';
|
|
13
|
+
|
|
14
|
+
const WORKING_STATUSES = new Set([
|
|
15
|
+
'generating',
|
|
16
|
+
'streaming',
|
|
17
|
+
'loading',
|
|
18
|
+
'loading_reference',
|
|
19
|
+
'thinking',
|
|
20
|
+
'active',
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
function hasApprovalButtons(activeModal?: { buttons?: unknown[] | null } | null): boolean {
|
|
24
|
+
return (activeModal?.buttons?.length ?? 0) > 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function normalizeManagedStatus(
|
|
28
|
+
status?: string | null,
|
|
29
|
+
opts?: { activeModal?: { buttons?: unknown[] | null } | null },
|
|
30
|
+
): ManagedStatus {
|
|
31
|
+
if (hasApprovalButtons(opts?.activeModal)) return 'waiting_approval';
|
|
32
|
+
|
|
33
|
+
const normalized = String(status || 'idle').trim().toLowerCase();
|
|
34
|
+
if (normalized === 'waiting_approval') return 'waiting_approval';
|
|
35
|
+
if (WORKING_STATUSES.has(normalized)) return 'generating';
|
|
36
|
+
if (normalized === 'error') return 'error';
|
|
37
|
+
if (normalized === 'stopped') return 'stopped';
|
|
38
|
+
if (normalized === 'starting') return 'starting';
|
|
39
|
+
if (normalized === 'panel_hidden') return 'panel_hidden';
|
|
40
|
+
if (normalized === 'not_monitored') return 'not_monitored';
|
|
41
|
+
if (normalized === 'disconnected') return 'disconnected';
|
|
42
|
+
return 'idle';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function isManagedStatusWorking(status?: string | null): boolean {
|
|
46
|
+
return normalizeManagedStatus(status) === 'generating';
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function isManagedStatusWaiting(
|
|
50
|
+
status?: string | null,
|
|
51
|
+
opts?: { activeModal?: { buttons?: unknown[] | null } | null },
|
|
52
|
+
): boolean {
|
|
53
|
+
return normalizeManagedStatus(status, opts) === 'waiting_approval';
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function normalizeActiveChatData<T extends ActiveChatData | null | undefined>(
|
|
57
|
+
activeChat: T,
|
|
58
|
+
): T {
|
|
59
|
+
if (!activeChat) return activeChat;
|
|
60
|
+
return {
|
|
61
|
+
...activeChat,
|
|
62
|
+
status: normalizeManagedStatus(activeChat.status, { activeModal: activeChat.activeModal }),
|
|
63
|
+
} as T;
|
|
64
|
+
}
|
package/src/status/reporter.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { LOG } from '../logging/logger.js';
|
|
9
|
-
import {
|
|
9
|
+
import { buildSessionEntries } from './builders.js';
|
|
10
10
|
import { buildStatusSnapshot } from './snapshot.js';
|
|
11
11
|
import type {
|
|
12
12
|
ProviderState,
|
|
@@ -152,7 +152,7 @@ export class DaemonStatusReporter {
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
// IDE/CLI/ACP states → managed entries (shared builder)
|
|
155
|
-
const
|
|
155
|
+
const sessions = buildSessionEntries(
|
|
156
156
|
allStates,
|
|
157
157
|
this.deps.cdpManagers as Map<string, any>,
|
|
158
158
|
);
|
|
@@ -189,19 +189,20 @@ export class DaemonStatusReporter {
|
|
|
189
189
|
if (opts?.p2pOnly) return;
|
|
190
190
|
const wsPayload = {
|
|
191
191
|
daemonMode: true,
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
192
|
+
sessions: sessions.map((session) => ({
|
|
193
|
+
id: session.id,
|
|
194
|
+
parentId: session.parentId,
|
|
195
|
+
providerType: session.providerType,
|
|
196
|
+
providerName: session.providerName,
|
|
197
|
+
kind: session.kind,
|
|
198
|
+
transport: session.transport,
|
|
199
|
+
status: session.status,
|
|
200
|
+
workspace: session.workspace,
|
|
201
|
+
title: session.title,
|
|
202
|
+
cdpConnected: session.cdpConnected,
|
|
203
|
+
currentModel: session.currentModel,
|
|
204
|
+
currentPlan: session.currentPlan,
|
|
205
|
+
currentAutoApprove: session.currentAutoApprove,
|
|
205
206
|
})),
|
|
206
207
|
p2p: payload.p2p,
|
|
207
208
|
timestamp: now,
|