agentgui 1.0.993 → 1.0.994
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.
|
@@ -5,13 +5,9 @@ import { WebSocketServer } from 'ws';
|
|
|
5
5
|
export default {
|
|
6
6
|
name: 'websocket',
|
|
7
7
|
version: '1.0.0',
|
|
8
|
-
dependencies: ['database', 'stream'
|
|
8
|
+
dependencies: ['database', 'stream'],
|
|
9
9
|
|
|
10
10
|
async init(config, plugins) {
|
|
11
|
-
const db = plugins.get('database');
|
|
12
|
-
const stream = plugins.get('stream');
|
|
13
|
-
const agents = plugins.get('agents');
|
|
14
|
-
|
|
15
11
|
const subscribers = new Map(); // sessionId/conversationId => Set<client>
|
|
16
12
|
const routingTable = new Map(); // eventType => handler
|
|
17
13
|
|
package/package.json
CHANGED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
name: 'agents',
|
|
5
|
-
version: '1.0.0',
|
|
6
|
-
dependencies: ['database', 'stream'],
|
|
7
|
-
|
|
8
|
-
async init(config, plugins) {
|
|
9
|
-
const db = plugins.get('database');
|
|
10
|
-
const stream = plugins.get('stream');
|
|
11
|
-
const discoveredAgents = new Map();
|
|
12
|
-
const activeExecutions = new Map();
|
|
13
|
-
|
|
14
|
-
// Discover agents on startup
|
|
15
|
-
const discoverAgents = async () => {
|
|
16
|
-
const agents = [
|
|
17
|
-
{ id: 'gm-cc', name: 'Claude Code', bin: 'claude', installed: true },
|
|
18
|
-
{ id: 'gm-oc', name: 'OpenCode', bin: 'opencode', installed: false },
|
|
19
|
-
{ id: 'gm-gc', name: 'Gemini CLI', bin: 'gemini', installed: false },
|
|
20
|
-
{ id: 'gm-kilo', name: 'Kilo', bin: 'kilo', installed: false },
|
|
21
|
-
];
|
|
22
|
-
agents.forEach(a => discoveredAgents.set(a.id, a));
|
|
23
|
-
return agents;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
await discoverAgents();
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
routes: [
|
|
30
|
-
{
|
|
31
|
-
method: 'GET',
|
|
32
|
-
path: '/api/agents',
|
|
33
|
-
handler: (req, res) => {
|
|
34
|
-
res.json({ agents: Array.from(discoveredAgents.values()) });
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
method: 'POST',
|
|
39
|
-
path: '/api/conversations/:id/stream',
|
|
40
|
-
handler: async (req, res) => {
|
|
41
|
-
const { id } = req.params;
|
|
42
|
-
const { agentId, message } = req.body;
|
|
43
|
-
|
|
44
|
-
try {
|
|
45
|
-
const agent = discoveredAgents.get(agentId);
|
|
46
|
-
if (!agent) return res.status(404).json({ error: 'Agent not found' });
|
|
47
|
-
|
|
48
|
-
const session = stream.api.createSession(id);
|
|
49
|
-
activeExecutions.set(id, { sessionId: session.id });
|
|
50
|
-
|
|
51
|
-
res.json({ sessionId: session.id });
|
|
52
|
-
} catch (e) {
|
|
53
|
-
res.status(500).json({ error: e.message });
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
],
|
|
58
|
-
wsHandlers: {},
|
|
59
|
-
api: {
|
|
60
|
-
getAgents: () => Array.from(discoveredAgents.values()),
|
|
61
|
-
discoverAgents,
|
|
62
|
-
},
|
|
63
|
-
stop: async () => {
|
|
64
|
-
for (const proc of activeExecutions.values()) {
|
|
65
|
-
if (proc && !proc.killed) proc.kill();
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
async reload(state) {
|
|
72
|
-
return state;
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
async stop() {},
|
|
76
|
-
};
|