@gencode/console 0.0.1
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/client/assets/main-ACHOM3RY.css +1 -0
- package/dist/client/assets/main-BC36yw7y.js +131 -0
- package/dist/client/index.html +13 -0
- package/dist/server/callback-server.d.ts +56 -0
- package/dist/server/callback-server.d.ts.map +1 -0
- package/dist/server/callback-server.js +284 -0
- package/dist/server/callback-server.js.map +1 -0
- package/dist/server/cli-runner.d.ts +55 -0
- package/dist/server/cli-runner.d.ts.map +1 -0
- package/dist/server/cli-runner.js +191 -0
- package/dist/server/cli-runner.js.map +1 -0
- package/dist/server/config.d.ts +48 -0
- package/dist/server/config.d.ts.map +1 -0
- package/dist/server/config.js +82 -0
- package/dist/server/config.js.map +1 -0
- package/dist/server/index.d.ts +8 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +45 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/server.d.ts +17 -0
- package/dist/server/server.d.ts.map +1 -0
- package/dist/server/server.js +168 -0
- package/dist/server/server.js.map +1 -0
- package/dist/server/ws-handler.d.ts +59 -0
- package/dist/server/ws-handler.d.ts.map +1 -0
- package/dist/server/ws-handler.js +262 -0
- package/dist/server/ws-handler.js.map +1 -0
- package/dist/shared/protocol.d.ts +287 -0
- package/dist/shared/protocol.d.ts.map +1 -0
- package/dist/shared/protocol.js +8 -0
- package/dist/shared/protocol.js.map +1 -0
- package/package.json +60 -0
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebSocket message handler.
|
|
3
|
+
*
|
|
4
|
+
* Routes incoming WebSocket messages and manages agent execution state.
|
|
5
|
+
*/
|
|
6
|
+
import { CliRunner, runCommandsList } from './cli-runner.js';
|
|
7
|
+
/**
|
|
8
|
+
* Manages WebSocket connections and agent executions.
|
|
9
|
+
*/
|
|
10
|
+
export class WsHandler {
|
|
11
|
+
config;
|
|
12
|
+
callbackServer;
|
|
13
|
+
activeRuns = new Map();
|
|
14
|
+
constructor(config, callbackServer) {
|
|
15
|
+
this.config = config;
|
|
16
|
+
this.callbackServer = callbackServer;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Handle a new WebSocket connection.
|
|
20
|
+
*/
|
|
21
|
+
handleConnection(ws) {
|
|
22
|
+
ws.on('message', async (data) => {
|
|
23
|
+
try {
|
|
24
|
+
const msg = JSON.parse(data.toString());
|
|
25
|
+
await this.handleMessage(ws, msg);
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
this.sendError(ws, err.message);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
ws.on('close', () => {
|
|
32
|
+
// Abort all active runs for this connection
|
|
33
|
+
for (const runner of this.activeRuns.values()) {
|
|
34
|
+
runner.abort();
|
|
35
|
+
}
|
|
36
|
+
this.activeRuns.clear();
|
|
37
|
+
});
|
|
38
|
+
ws.on('error', (err) => {
|
|
39
|
+
console.error('WebSocket error:', err);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Handle incoming C2S messages.
|
|
44
|
+
*/
|
|
45
|
+
async handleMessage(ws, msg) {
|
|
46
|
+
switch (msg.type) {
|
|
47
|
+
case 'agent.send':
|
|
48
|
+
await this.handleAgentSend(ws, msg);
|
|
49
|
+
break;
|
|
50
|
+
case 'agent.abort':
|
|
51
|
+
this.handleAgentAbort(msg.sessionId);
|
|
52
|
+
break;
|
|
53
|
+
case 'sessions.list':
|
|
54
|
+
await this.handleSessionsList(ws, msg.dataDir);
|
|
55
|
+
break;
|
|
56
|
+
case 'session.get':
|
|
57
|
+
await this.handleSessionGet(ws, msg.sessionId, msg.dataDir);
|
|
58
|
+
break;
|
|
59
|
+
case 'commands.list':
|
|
60
|
+
await this.handleCommandsList(ws, msg.dataDir);
|
|
61
|
+
break;
|
|
62
|
+
default:
|
|
63
|
+
// Exhaustive check
|
|
64
|
+
const _exhaustive = msg;
|
|
65
|
+
this.sendError(ws, 'Unknown message type');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Handle commands.list message - list available slash commands.
|
|
70
|
+
*/
|
|
71
|
+
async handleCommandsList(ws, dataDir) {
|
|
72
|
+
try {
|
|
73
|
+
const result = await runCommandsList({ dataDir, config: this.config });
|
|
74
|
+
if (result.exitCode !== 0) {
|
|
75
|
+
this.sendError(ws, `CLI exited with code ${result.exitCode}: ${result.stderr}`);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const payload = extractJsonPayload(result.stdout);
|
|
79
|
+
if (!payload) {
|
|
80
|
+
this.sendError(ws, `Failed to parse commands list: ${result.stdout.trim() || 'empty output'}`);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
this.send(ws, {
|
|
84
|
+
type: 'commands.list',
|
|
85
|
+
commands: payload,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
catch (err) {
|
|
89
|
+
this.sendError(ws, err.message);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Handle agent.send message - start a new agent execution.
|
|
94
|
+
*/
|
|
95
|
+
async handleAgentSend(ws, msg) {
|
|
96
|
+
const callbackUrl = this.callbackServer.getCallbackUrl();
|
|
97
|
+
// Debug log
|
|
98
|
+
console.log('[WsHandler] Received agent.send message');
|
|
99
|
+
console.log('[WsHandler] sessionId from client:', msg.sessionId || 'NONE (will create new session)');
|
|
100
|
+
const runner = new CliRunner({
|
|
101
|
+
dataDir: msg.dataDir,
|
|
102
|
+
message: msg.message,
|
|
103
|
+
sessionId: msg.sessionId,
|
|
104
|
+
messageId: msg.messageId,
|
|
105
|
+
callbackUrl,
|
|
106
|
+
config: this.config,
|
|
107
|
+
});
|
|
108
|
+
// Use 'pending' internally for tracking new sessions
|
|
109
|
+
const tempSessionId = msg.sessionId ?? 'pending';
|
|
110
|
+
// Store runner
|
|
111
|
+
this.activeRuns.set(tempSessionId, runner);
|
|
112
|
+
try {
|
|
113
|
+
// Run CLI and wait for completion
|
|
114
|
+
const result = await runner.run();
|
|
115
|
+
// Update session ID if it was generated
|
|
116
|
+
if (result.sessionId !== tempSessionId) {
|
|
117
|
+
this.activeRuns.delete(tempSessionId);
|
|
118
|
+
this.activeRuns.set(result.sessionId, runner);
|
|
119
|
+
}
|
|
120
|
+
// Clean up
|
|
121
|
+
this.activeRuns.delete(result.sessionId);
|
|
122
|
+
this.callbackServer.cleanupSession(result.sessionId);
|
|
123
|
+
// If CLI failed, send error
|
|
124
|
+
if (result.exitCode !== 0) {
|
|
125
|
+
this.send(ws, {
|
|
126
|
+
type: 'agent.error',
|
|
127
|
+
sessionId: result.sessionId,
|
|
128
|
+
message: `CLI exited with code ${result.exitCode}: ${result.stderr}`,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
catch (err) {
|
|
133
|
+
this.activeRuns.delete(tempSessionId);
|
|
134
|
+
this.send(ws, {
|
|
135
|
+
type: 'agent.error',
|
|
136
|
+
sessionId: tempSessionId,
|
|
137
|
+
message: err.message,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Handle agent.abort message - abort a running agent.
|
|
143
|
+
*/
|
|
144
|
+
handleAgentAbort(sessionId) {
|
|
145
|
+
const runner = this.activeRuns.get(sessionId);
|
|
146
|
+
if (runner) {
|
|
147
|
+
runner.abort();
|
|
148
|
+
this.activeRuns.delete(sessionId);
|
|
149
|
+
this.callbackServer.cleanupSession(sessionId);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Handle sessions.list message - list all sessions.
|
|
154
|
+
*/
|
|
155
|
+
async handleSessionsList(ws, dataDir) {
|
|
156
|
+
try {
|
|
157
|
+
// Call CLI to list sessions
|
|
158
|
+
const runner = new CliRunner({
|
|
159
|
+
dataDir,
|
|
160
|
+
message: '', // Not used for sessions command
|
|
161
|
+
callbackUrl: '',
|
|
162
|
+
config: this.config,
|
|
163
|
+
});
|
|
164
|
+
// We need to spawn a different command - sessions list
|
|
165
|
+
// For now, send empty list (will implement later with proper CLI command)
|
|
166
|
+
this.send(ws, {
|
|
167
|
+
type: 'sessions.list',
|
|
168
|
+
sessions: [],
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
catch (err) {
|
|
172
|
+
this.sendError(ws, err.message);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Handle session.get message - get session details.
|
|
177
|
+
*/
|
|
178
|
+
async handleSessionGet(ws, sessionId, dataDir) {
|
|
179
|
+
try {
|
|
180
|
+
// Call CLI to get session
|
|
181
|
+
// For now, send empty response (will implement later with proper CLI command)
|
|
182
|
+
this.send(ws, {
|
|
183
|
+
type: 'session.get',
|
|
184
|
+
sessionId,
|
|
185
|
+
transcript: [],
|
|
186
|
+
metadata: {
|
|
187
|
+
title: 'Session',
|
|
188
|
+
createdAt: new Date().toISOString(),
|
|
189
|
+
lastModified: new Date().toISOString(),
|
|
190
|
+
},
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
catch (err) {
|
|
194
|
+
this.sendError(ws, err.message);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Send a message to the WebSocket client.
|
|
199
|
+
*/
|
|
200
|
+
send(ws, msg) {
|
|
201
|
+
if (ws.readyState === ws.OPEN) {
|
|
202
|
+
ws.send(JSON.stringify(msg));
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Send an error message to the WebSocket client.
|
|
207
|
+
*/
|
|
208
|
+
sendError(ws, message) {
|
|
209
|
+
this.send(ws, {
|
|
210
|
+
type: 'server.error',
|
|
211
|
+
message,
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Register a callback handler to forward messages from CLI to WebSocket.
|
|
216
|
+
*/
|
|
217
|
+
registerCallbackHandler(broadcast) {
|
|
218
|
+
this.callbackServer.setHandler((sessionId, message) => {
|
|
219
|
+
if (message.type === 'agent.start' && this.activeRuns.has('pending')) {
|
|
220
|
+
// Update the activeRuns mapping when the real sessionId arrives
|
|
221
|
+
const runner = this.activeRuns.get('pending');
|
|
222
|
+
if (runner) {
|
|
223
|
+
this.activeRuns.delete('pending');
|
|
224
|
+
this.activeRuns.set(sessionId, runner);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
broadcast(message);
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
function extractJsonPayload(raw) {
|
|
232
|
+
const trimmed = raw.trim();
|
|
233
|
+
if (!trimmed)
|
|
234
|
+
return null;
|
|
235
|
+
// Try last non-empty line first
|
|
236
|
+
const lines = trimmed.split('\n').filter(Boolean);
|
|
237
|
+
for (let i = lines.length - 1; i >= 0; i -= 1) {
|
|
238
|
+
const line = lines[i].trim();
|
|
239
|
+
if (!line)
|
|
240
|
+
continue;
|
|
241
|
+
try {
|
|
242
|
+
return JSON.parse(line);
|
|
243
|
+
}
|
|
244
|
+
catch {
|
|
245
|
+
// continue
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
// Fallback: find JSON object boundaries
|
|
249
|
+
const start = trimmed.indexOf('{');
|
|
250
|
+
const end = trimmed.lastIndexOf('}');
|
|
251
|
+
if (start >= 0 && end > start) {
|
|
252
|
+
const slice = trimmed.slice(start, end + 1);
|
|
253
|
+
try {
|
|
254
|
+
return JSON.parse(slice);
|
|
255
|
+
}
|
|
256
|
+
catch {
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
//# sourceMappingURL=ws-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ws-handler.js","sourceRoot":"","sources":["../../src/server/ws-handler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,EAAE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I,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;QAAC,MAAM,CAAC;YACP,WAAW;QACb,CAAC;IACH,CAAC;IACD,wCAAwC;IACxC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACnC,MAAM,GAAG,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACrC,IAAI,KAAK,IAAI,CAAC,IAAI,GAAG,GAAG,KAAK,EAAE,CAAC;QAC9B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC;QAC5C,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebSocket communication protocol between client and server.
|
|
3
|
+
*
|
|
4
|
+
* This protocol maps directly to AgentProgressEvent types from @gencode/agents,
|
|
5
|
+
* maintaining semantic consistency while enabling real-time streaming to the browser.
|
|
6
|
+
*/
|
|
7
|
+
export type AgentSendMessage = {
|
|
8
|
+
type: 'agent.send';
|
|
9
|
+
sessionId?: string;
|
|
10
|
+
messageId?: string;
|
|
11
|
+
dataDir: string;
|
|
12
|
+
message: string;
|
|
13
|
+
};
|
|
14
|
+
export type AgentAbortMessage = {
|
|
15
|
+
type: 'agent.abort';
|
|
16
|
+
sessionId: string;
|
|
17
|
+
};
|
|
18
|
+
export type SessionsListMessage = {
|
|
19
|
+
type: 'sessions.list';
|
|
20
|
+
dataDir: string;
|
|
21
|
+
};
|
|
22
|
+
export type SessionGetMessage = {
|
|
23
|
+
type: 'session.get';
|
|
24
|
+
sessionId: string;
|
|
25
|
+
dataDir: string;
|
|
26
|
+
};
|
|
27
|
+
export type CommandsListMessage = {
|
|
28
|
+
type: 'commands.list';
|
|
29
|
+
dataDir: string;
|
|
30
|
+
};
|
|
31
|
+
export type C2SMessage = AgentSendMessage | AgentAbortMessage | SessionsListMessage | SessionGetMessage | CommandsListMessage;
|
|
32
|
+
export type AgentStartMessage = {
|
|
33
|
+
type: 'agent.start';
|
|
34
|
+
sessionId: string;
|
|
35
|
+
messageId?: string;
|
|
36
|
+
message: string;
|
|
37
|
+
};
|
|
38
|
+
export type AgentTextMessage = {
|
|
39
|
+
type: 'agent.text';
|
|
40
|
+
sessionId: string;
|
|
41
|
+
messageId?: string;
|
|
42
|
+
delta: string;
|
|
43
|
+
};
|
|
44
|
+
export type AgentBootstrapMessage = {
|
|
45
|
+
type: 'agent.bootstrap';
|
|
46
|
+
sessionId: string;
|
|
47
|
+
messageId?: string;
|
|
48
|
+
phase: 'checking' | 'initializing' | 'initialized' | 'ready';
|
|
49
|
+
dataDir: string;
|
|
50
|
+
};
|
|
51
|
+
export type AgentToolStartMessage = {
|
|
52
|
+
type: 'agent.tool_start';
|
|
53
|
+
sessionId: string;
|
|
54
|
+
messageId?: string;
|
|
55
|
+
toolCallId: string;
|
|
56
|
+
name: string;
|
|
57
|
+
input: unknown;
|
|
58
|
+
};
|
|
59
|
+
export type AgentToolEndMessage = {
|
|
60
|
+
type: 'agent.tool_end';
|
|
61
|
+
sessionId: string;
|
|
62
|
+
messageId?: string;
|
|
63
|
+
toolCallId: string;
|
|
64
|
+
name: string;
|
|
65
|
+
output: string;
|
|
66
|
+
isError: boolean;
|
|
67
|
+
};
|
|
68
|
+
export type AgentCompactionMessage = {
|
|
69
|
+
type: 'agent.compaction';
|
|
70
|
+
sessionId: string;
|
|
71
|
+
messageId?: string;
|
|
72
|
+
reason: string;
|
|
73
|
+
};
|
|
74
|
+
export type AgentMemoryChangedMessage = {
|
|
75
|
+
type: 'agent.memory_changed';
|
|
76
|
+
sessionId: string;
|
|
77
|
+
messageId?: string;
|
|
78
|
+
reason: string;
|
|
79
|
+
files: string[];
|
|
80
|
+
source: 'memory' | 'sessions';
|
|
81
|
+
providerId?: string;
|
|
82
|
+
timestamp: string;
|
|
83
|
+
};
|
|
84
|
+
export type AgentSubagentSpawnMessage = {
|
|
85
|
+
type: 'agent.subagent_spawn';
|
|
86
|
+
sessionId: string;
|
|
87
|
+
messageId?: string;
|
|
88
|
+
childSessionId: string;
|
|
89
|
+
task: string;
|
|
90
|
+
label?: string;
|
|
91
|
+
};
|
|
92
|
+
export type AgentSubagentCompleteMessage = {
|
|
93
|
+
type: 'agent.subagent_complete';
|
|
94
|
+
sessionId: string;
|
|
95
|
+
messageId?: string;
|
|
96
|
+
childSessionId: string;
|
|
97
|
+
task: string;
|
|
98
|
+
status: 'done' | 'error' | 'killed';
|
|
99
|
+
};
|
|
100
|
+
export type AgentTurnEndMessage = {
|
|
101
|
+
type: 'agent.turn_end';
|
|
102
|
+
sessionId: string;
|
|
103
|
+
messageId?: string;
|
|
104
|
+
};
|
|
105
|
+
export type AgentDoneMessage = {
|
|
106
|
+
type: 'agent.done';
|
|
107
|
+
sessionId: string;
|
|
108
|
+
messageId?: string;
|
|
109
|
+
result: AgentRunResult;
|
|
110
|
+
};
|
|
111
|
+
export type AgentErrorMessage = {
|
|
112
|
+
type: 'agent.error';
|
|
113
|
+
sessionId: string;
|
|
114
|
+
messageId?: string;
|
|
115
|
+
message: string;
|
|
116
|
+
};
|
|
117
|
+
export type SessionsListResponseMessage = {
|
|
118
|
+
type: 'sessions.list';
|
|
119
|
+
sessions: SessionSummary[];
|
|
120
|
+
};
|
|
121
|
+
export type SessionGetResponseMessage = {
|
|
122
|
+
type: 'session.get';
|
|
123
|
+
sessionId: string;
|
|
124
|
+
transcript: TranscriptEntry[];
|
|
125
|
+
metadata: SessionMetadata;
|
|
126
|
+
};
|
|
127
|
+
export type SlashCommandSpec = {
|
|
128
|
+
name: string;
|
|
129
|
+
description: string;
|
|
130
|
+
};
|
|
131
|
+
export type SlashCommandList = {
|
|
132
|
+
builtin: SlashCommandSpec[];
|
|
133
|
+
skillCommands: SlashCommandSpec[];
|
|
134
|
+
all: SlashCommandSpec[];
|
|
135
|
+
};
|
|
136
|
+
export type CommandsListResponseMessage = {
|
|
137
|
+
type: 'commands.list';
|
|
138
|
+
commands: SlashCommandList;
|
|
139
|
+
};
|
|
140
|
+
export type ServerErrorMessage = {
|
|
141
|
+
type: 'server.error';
|
|
142
|
+
message: string;
|
|
143
|
+
};
|
|
144
|
+
export type ServerInfoMessage = {
|
|
145
|
+
type: 'server.info';
|
|
146
|
+
message: string;
|
|
147
|
+
};
|
|
148
|
+
export type SessionResetMessage = {
|
|
149
|
+
type: 'session.reset';
|
|
150
|
+
sessionId: string;
|
|
151
|
+
messageId?: string;
|
|
152
|
+
action: 'new' | 'reset';
|
|
153
|
+
previousSessionId?: string;
|
|
154
|
+
message: string;
|
|
155
|
+
};
|
|
156
|
+
export type S2CMessage = AgentStartMessage | AgentTextMessage | AgentBootstrapMessage | AgentToolStartMessage | AgentToolEndMessage | AgentCompactionMessage | AgentMemoryChangedMessage | AgentSubagentSpawnMessage | AgentSubagentCompleteMessage | AgentTurnEndMessage | AgentDoneMessage | AgentErrorMessage | SessionResetMessage | SessionsListResponseMessage | SessionGetResponseMessage | CommandsListResponseMessage | ServerInfoMessage | ServerErrorMessage;
|
|
157
|
+
/**
|
|
158
|
+
* Payload sent by CLI to the callback URL.
|
|
159
|
+
* Maps to CallbackPayload from @gencode/agents.
|
|
160
|
+
*/
|
|
161
|
+
export type CliCallbackPayload = {
|
|
162
|
+
sessionId: string;
|
|
163
|
+
channel: Channel;
|
|
164
|
+
messageId?: string;
|
|
165
|
+
type: 'start';
|
|
166
|
+
message: string;
|
|
167
|
+
} | {
|
|
168
|
+
sessionId: string;
|
|
169
|
+
channel: Channel;
|
|
170
|
+
messageId?: string;
|
|
171
|
+
type: 'progress';
|
|
172
|
+
event: AgentProgressEvent;
|
|
173
|
+
} | {
|
|
174
|
+
sessionId: string;
|
|
175
|
+
channel: Channel;
|
|
176
|
+
messageId?: string;
|
|
177
|
+
type: 'done';
|
|
178
|
+
result: AgentRunResult;
|
|
179
|
+
} | {
|
|
180
|
+
sessionId: string;
|
|
181
|
+
channel: Channel;
|
|
182
|
+
messageId?: string;
|
|
183
|
+
type: 'error';
|
|
184
|
+
message: string;
|
|
185
|
+
} | {
|
|
186
|
+
sessionId: string;
|
|
187
|
+
channel: Channel;
|
|
188
|
+
messageId?: string;
|
|
189
|
+
type: 'session_reset';
|
|
190
|
+
action: 'new' | 'reset';
|
|
191
|
+
previousSessionId?: string;
|
|
192
|
+
message: string;
|
|
193
|
+
};
|
|
194
|
+
/** Supported channel types */
|
|
195
|
+
export type Channel = 'H5' | 'WEB' | 'KLPA' | 'CRON';
|
|
196
|
+
/**
|
|
197
|
+
* Agent progress event types from @gencode/agents.
|
|
198
|
+
* Redefined here to avoid direct dependency.
|
|
199
|
+
*/
|
|
200
|
+
type AgentProgressEventBase = {
|
|
201
|
+
messageId?: string;
|
|
202
|
+
};
|
|
203
|
+
export type AgentProgressEvent = (AgentProgressEventBase & {
|
|
204
|
+
type: 'text';
|
|
205
|
+
text: string;
|
|
206
|
+
}) | (AgentProgressEventBase & {
|
|
207
|
+
type: 'bootstrap';
|
|
208
|
+
phase: 'checking' | 'initializing' | 'initialized' | 'ready';
|
|
209
|
+
dataDir: string;
|
|
210
|
+
}) | (AgentProgressEventBase & {
|
|
211
|
+
type: 'tool_start';
|
|
212
|
+
name: string;
|
|
213
|
+
input: unknown;
|
|
214
|
+
}) | (AgentProgressEventBase & {
|
|
215
|
+
type: 'tool_end';
|
|
216
|
+
name: string;
|
|
217
|
+
output: string;
|
|
218
|
+
isError: boolean;
|
|
219
|
+
}) | (AgentProgressEventBase & {
|
|
220
|
+
type: 'compaction';
|
|
221
|
+
reason: string;
|
|
222
|
+
}) | (AgentProgressEventBase & {
|
|
223
|
+
type: 'memory_changed';
|
|
224
|
+
reason: string;
|
|
225
|
+
files: string[];
|
|
226
|
+
source: 'memory' | 'sessions';
|
|
227
|
+
providerId?: string;
|
|
228
|
+
timestamp: string;
|
|
229
|
+
}) | (AgentProgressEventBase & {
|
|
230
|
+
type: 'error';
|
|
231
|
+
message: string;
|
|
232
|
+
}) | (AgentProgressEventBase & {
|
|
233
|
+
type: 'subagent_spawn';
|
|
234
|
+
childSessionId: string;
|
|
235
|
+
task: string;
|
|
236
|
+
label?: string;
|
|
237
|
+
}) | (AgentProgressEventBase & {
|
|
238
|
+
type: 'subagent_complete';
|
|
239
|
+
childSessionId: string;
|
|
240
|
+
task: string;
|
|
241
|
+
status: 'done' | 'error' | 'killed';
|
|
242
|
+
});
|
|
243
|
+
/**
|
|
244
|
+
* Agent run result from @gencode/agents.
|
|
245
|
+
*/
|
|
246
|
+
export type AgentRunResult = {
|
|
247
|
+
sessionId: string;
|
|
248
|
+
text?: string;
|
|
249
|
+
usage?: {
|
|
250
|
+
input: number;
|
|
251
|
+
output: number;
|
|
252
|
+
total: number;
|
|
253
|
+
};
|
|
254
|
+
durationMs?: number;
|
|
255
|
+
error?: string;
|
|
256
|
+
aborted?: boolean;
|
|
257
|
+
};
|
|
258
|
+
/**
|
|
259
|
+
* Session summary for listing.
|
|
260
|
+
*/
|
|
261
|
+
export type SessionSummary = {
|
|
262
|
+
sessionId: string;
|
|
263
|
+
title: string;
|
|
264
|
+
createdAt: string;
|
|
265
|
+
lastModified: string;
|
|
266
|
+
messageCount: number;
|
|
267
|
+
};
|
|
268
|
+
/**
|
|
269
|
+
* Session metadata.
|
|
270
|
+
*/
|
|
271
|
+
export type SessionMetadata = {
|
|
272
|
+
title: string;
|
|
273
|
+
createdAt: string;
|
|
274
|
+
lastModified: string;
|
|
275
|
+
};
|
|
276
|
+
/**
|
|
277
|
+
* Transcript entry.
|
|
278
|
+
*/
|
|
279
|
+
export type TranscriptEntry = {
|
|
280
|
+
role: 'user' | 'assistant' | 'tool_result';
|
|
281
|
+
content: string;
|
|
282
|
+
timestamp: string;
|
|
283
|
+
toolCallId?: string;
|
|
284
|
+
toolName?: string;
|
|
285
|
+
};
|
|
286
|
+
export {};
|
|
287
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/shared/protocol.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,YAAY,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,aAAa,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,eAAe,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,aAAa,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,eAAe,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,UAAU,GAClB,gBAAgB,GAChB,iBAAiB,GACjB,mBAAmB,GACnB,iBAAiB,GACjB,mBAAmB,CAAC;AAQxB,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,aAAa,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,YAAY,CAAC;IACnB,SAAS,EAA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AAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;CACrC,CAAC,CAAC;AAEL;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACzD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,aAAa,CAAC;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebSocket communication protocol between client and server.
|
|
3
|
+
*
|
|
4
|
+
* This protocol maps directly to AgentProgressEvent types from @gencode/agents,
|
|
5
|
+
* maintaining semantic consistency while enabling real-time streaming to the browser.
|
|
6
|
+
*/
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/shared/protocol.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gencode/console",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"bin": {
|
|
6
|
+
"aimax-console": "./dist/server/index.js"
|
|
7
|
+
},
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/server/index.d.ts",
|
|
11
|
+
"default": "./dist/server/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./protocol": {
|
|
14
|
+
"types": "./dist/shared/protocol.d.ts",
|
|
15
|
+
"default": "./dist/shared/protocol.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"ws": "^8.18.0",
|
|
26
|
+
"react": "^18.3.1",
|
|
27
|
+
"react-dom": "^18.3.1",
|
|
28
|
+
"@gencode/cli": "0.0.1"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/ws": "^8.5.13",
|
|
32
|
+
"@types/node": "^22.0.0",
|
|
33
|
+
"@types/react": "^18.3.12",
|
|
34
|
+
"@types/react-dom": "^18.3.1",
|
|
35
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
36
|
+
"typescript": "^5.9.3",
|
|
37
|
+
"vite": "^6.0.0",
|
|
38
|
+
"vitest": "^4.0.18",
|
|
39
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
40
|
+
"happy-dom": "^18.0.0",
|
|
41
|
+
"tailwindcss": "^3.4.17",
|
|
42
|
+
"autoprefixer": "^10.4.20",
|
|
43
|
+
"postcss": "^8.4.49",
|
|
44
|
+
"lucide-react": "^0.468.0",
|
|
45
|
+
"date-fns": "^4.1.0",
|
|
46
|
+
"clsx": "^2.1.1",
|
|
47
|
+
"tailwind-merge": "^2.6.0"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "pnpm build:server && pnpm build:client",
|
|
51
|
+
"build:server": "tsc --project tsconfig.json",
|
|
52
|
+
"build:client": "vite build",
|
|
53
|
+
"dev": "pnpm build:server && node dist/server/index.js",
|
|
54
|
+
"dev:client": "vite",
|
|
55
|
+
"start": "node dist/server/index.js",
|
|
56
|
+
"test": "vitest run",
|
|
57
|
+
"test:coverage": "vitest run --coverage",
|
|
58
|
+
"typecheck": "tsc --noEmit && tsc --project tsconfig.client.json --noEmit"
|
|
59
|
+
}
|
|
60
|
+
}
|