agentgui 1.0.991 → 1.0.993
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/lib/acp-sdk-manager.js +0 -6
- package/lib/acp-server-machine.js +0 -4
- package/lib/agent-descriptors.js +0 -3
- package/lib/asset-server.js +0 -37
- package/lib/claude-runner-run.js +0 -2
- package/lib/execution-machine.js +0 -11
- package/lib/gm-agent-configs.js +0 -11
- package/package.json +1 -1
- package/lib/plugins/files-plugin.js +0 -114
package/lib/acp-sdk-manager.js
CHANGED
|
@@ -179,12 +179,6 @@ export function getPort(agentId) {
|
|
|
179
179
|
return acpMachine.isHealthy(agentId) ? (ACP_TOOLS.find(t => t.id === agentId)?.port || null) : null;
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
-
export function getRunningPorts() {
|
|
183
|
-
const ports = {};
|
|
184
|
-
for (const tool of ACP_TOOLS) { if (acpMachine.isHealthy(tool.id)) ports[tool.id] = tool.port; }
|
|
185
|
-
return ports;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
182
|
export async function restart(agentId) {
|
|
189
183
|
const tool = ACP_TOOLS.find(t => t.id === agentId);
|
|
190
184
|
if (!tool) return false;
|
|
@@ -160,10 +160,6 @@ export function getBackoffDelay(toolId) {
|
|
|
160
160
|
return calcBackoff(purgeOldRestarts(s.context.restarts));
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
export function getMachineActors() {
|
|
164
|
-
return actors;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
163
|
export function stopAll() {
|
|
168
164
|
for (const [, actor] of actors) actor.stop();
|
|
169
165
|
actors.clear();
|
package/lib/agent-descriptors.js
CHANGED
package/lib/asset-server.js
CHANGED
|
@@ -124,40 +124,3 @@ export function serveFile(filePath, res, req, { compressAndSend, acceptsEncoding
|
|
|
124
124
|
});
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
|
-
|
|
128
|
-
export function createChunkBatcher(queries, debugLog) {
|
|
129
|
-
const pending = [];
|
|
130
|
-
let timer = null;
|
|
131
|
-
const BATCH_SIZE = 10;
|
|
132
|
-
const BATCH_INTERVAL = 50;
|
|
133
|
-
|
|
134
|
-
function flush() {
|
|
135
|
-
if (pending.length === 0) return;
|
|
136
|
-
const batch = pending.splice(0);
|
|
137
|
-
try {
|
|
138
|
-
const tx = queries._db ? queries._db.transaction(() => {
|
|
139
|
-
for (const c of batch) queries.createChunk(c.sessionId, c.conversationId, c.sequence, c.type, c.data);
|
|
140
|
-
}) : null;
|
|
141
|
-
if (tx) { tx(); } else {
|
|
142
|
-
for (const c of batch) {
|
|
143
|
-
try { queries.createChunk(c.sessionId, c.conversationId, c.sequence, c.type, c.data); } catch (e) { debugLog(`[chunk] ${e.message}`); }
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
} catch (err) {
|
|
147
|
-
debugLog(`[chunk-batch] Batch write failed: ${err.message}`);
|
|
148
|
-
for (const c of batch) {
|
|
149
|
-
try { queries.createChunk(c.sessionId, c.conversationId, c.sequence, c.type, c.data); } catch (_) {}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function add(sessionId, conversationId, sequence, blockType, blockData) {
|
|
155
|
-
pending.push({ sessionId, conversationId, sequence, type: blockType, data: blockData });
|
|
156
|
-
if (pending.length >= BATCH_SIZE) { if (timer) { clearTimeout(timer); timer = null; } flush(); }
|
|
157
|
-
else if (!timer) { timer = setTimeout(() => { timer = null; flush(); }, BATCH_INTERVAL); }
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function drain() { if (timer) { clearTimeout(timer); timer = null; } flush(); }
|
|
161
|
-
|
|
162
|
-
return { add, drain };
|
|
163
|
-
}
|
package/lib/claude-runner-run.js
CHANGED
|
@@ -43,6 +43,4 @@ export async function runClaudeWithStreaming(prompt, cwd, agentId = 'claude-code
|
|
|
43
43
|
return agent.run(prompt, cwd, enhancedConfig);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
export function getRegisteredAgents() { return registry.list(); }
|
|
47
|
-
export function isAgentRegistered(agentId) { return registry.has(agentId); }
|
|
48
46
|
export default runClaudeWithStreaming;
|
package/lib/execution-machine.js
CHANGED
|
@@ -140,17 +140,6 @@ export function snapshot(convId) {
|
|
|
140
140
|
return actor ? actor.getSnapshot() : null;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
export function isStreaming(convId) {
|
|
144
|
-
const s = snapshot(convId);
|
|
145
|
-
return s ? s.value === 'streaming' || s.value === 'rate_limited' : false;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export function isActive(convId) {
|
|
149
|
-
const s = snapshot(convId);
|
|
150
|
-
if (!s) return false;
|
|
151
|
-
return s.value === 'streaming' || s.value === 'rate_limited' || s.value === 'draining';
|
|
152
|
-
}
|
|
153
|
-
|
|
154
143
|
export function getContext(convId) {
|
|
155
144
|
const s = snapshot(convId);
|
|
156
145
|
return s ? s.context : null;
|
package/lib/gm-agent-configs.js
CHANGED
|
@@ -64,14 +64,3 @@ export async function installGMAgentConfigs() {
|
|
|
64
64
|
});
|
|
65
65
|
log('results: ' + summary.join(', '));
|
|
66
66
|
}
|
|
67
|
-
|
|
68
|
-
export async function forceReinstallGMAgentConfigs() {
|
|
69
|
-
log('force reinstalling all agent configs');
|
|
70
|
-
const results = await Promise.allSettled(GM_PACKAGES.map(p => runInstaller(p.pkg)));
|
|
71
|
-
const summary = GM_PACKAGES.map((p, i) => {
|
|
72
|
-
const r = results[i];
|
|
73
|
-
const ok = r.status === 'fulfilled' && r.value;
|
|
74
|
-
return p.pkg + ': ' + (ok ? 'ok' : 'failed');
|
|
75
|
-
});
|
|
76
|
-
log('results: ' + summary.join(', '));
|
|
77
|
-
}
|
package/package.json
CHANGED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
// Files plugin - file browser, upload handler, drag-drop support
|
|
2
|
-
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import fs from 'fs';
|
|
5
|
-
import { confineToRoots, fsAllowRoots } from '../http-handler.js';
|
|
6
|
-
|
|
7
|
-
export default {
|
|
8
|
-
name: 'files',
|
|
9
|
-
version: '1.0.0',
|
|
10
|
-
dependencies: ['database'],
|
|
11
|
-
|
|
12
|
-
async init(config, plugins) {
|
|
13
|
-
const db = plugins.get('database');
|
|
14
|
-
const uploadedFiles = new Map();
|
|
15
|
-
|
|
16
|
-
const browseDirectory = (dir) => {
|
|
17
|
-
const conf = confineToRoots(dir, fsAllowRoots());
|
|
18
|
-
if (!conf.ok) return [];
|
|
19
|
-
try {
|
|
20
|
-
const entries = fs.readdirSync(conf.realPath);
|
|
21
|
-
return entries.map(entry => {
|
|
22
|
-
const fullPath = path.join(conf.realPath, entry);
|
|
23
|
-
try {
|
|
24
|
-
const stat = fs.statSync(fullPath);
|
|
25
|
-
return {
|
|
26
|
-
name: entry,
|
|
27
|
-
path: fullPath,
|
|
28
|
-
isDirectory: stat.isDirectory(),
|
|
29
|
-
size: stat.size,
|
|
30
|
-
};
|
|
31
|
-
} catch (_) {
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
}).filter(Boolean);
|
|
35
|
-
} catch (e) {
|
|
36
|
-
return [];
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
return {
|
|
41
|
-
routes: [
|
|
42
|
-
{
|
|
43
|
-
method: 'GET',
|
|
44
|
-
path: '/files/:conversationId',
|
|
45
|
-
handler: (req, res) => {
|
|
46
|
-
const { conversationId } = req.params;
|
|
47
|
-
const { dir } = req.query;
|
|
48
|
-
const requestedDir = dir || process.cwd();
|
|
49
|
-
const conf = confineToRoots(requestedDir, fsAllowRoots());
|
|
50
|
-
if (!conf.ok) {
|
|
51
|
-
return res.status(403).json({ error: 'Path not allowed' });
|
|
52
|
-
}
|
|
53
|
-
const entries = browseDirectory(conf.realPath);
|
|
54
|
-
res.json({ entries, currentDir: conf.realPath });
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
method: 'POST',
|
|
59
|
-
path: '/api/upload/:conversationId',
|
|
60
|
-
handler: async (req, res) => {
|
|
61
|
-
const { conversationId } = req.params;
|
|
62
|
-
uploadedFiles.set(conversationId, Date.now());
|
|
63
|
-
res.json({ success: true, conversationId });
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
method: 'POST',
|
|
68
|
-
path: '/api/folders',
|
|
69
|
-
handler: async (req, res) => {
|
|
70
|
-
const { path: folderPath } = req.body;
|
|
71
|
-
if (!folderPath || typeof folderPath !== 'string') {
|
|
72
|
-
return res.status(400).json({ error: 'path is required' });
|
|
73
|
-
}
|
|
74
|
-
// Sanitize each path component - reject traversal attempts
|
|
75
|
-
const parts = folderPath.split(/[/\\]/);
|
|
76
|
-
for (const part of parts) {
|
|
77
|
-
if (part === '..' || part === '.' || /[<>:"|?*\x00-\x1f]/.test(part)) {
|
|
78
|
-
return res.status(400).json({ error: 'Invalid path component' });
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
const conf = confineToRoots(folderPath, fsAllowRoots());
|
|
82
|
-
if (!conf.ok && conf.reason !== 'not found') {
|
|
83
|
-
return res.status(403).json({ error: 'Path not allowed' });
|
|
84
|
-
}
|
|
85
|
-
// For mkdir, path may not exist yet; re-check parent is confined
|
|
86
|
-
const parentConf = confineToRoots(path.dirname(folderPath), fsAllowRoots());
|
|
87
|
-
if (!parentConf.ok) {
|
|
88
|
-
return res.status(403).json({ error: 'Path not allowed' });
|
|
89
|
-
}
|
|
90
|
-
try {
|
|
91
|
-
fs.mkdirSync(folderPath, { recursive: true });
|
|
92
|
-
res.json({ success: true, path: folderPath });
|
|
93
|
-
} catch (e) {
|
|
94
|
-
res.status(400).json({ error: e.message });
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
],
|
|
99
|
-
wsHandlers: {},
|
|
100
|
-
api: {
|
|
101
|
-
browseDirectory,
|
|
102
|
-
},
|
|
103
|
-
stop: async () => {
|
|
104
|
-
uploadedFiles.clear();
|
|
105
|
-
},
|
|
106
|
-
};
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
async reload(state) {
|
|
110
|
-
return state;
|
|
111
|
-
},
|
|
112
|
-
|
|
113
|
-
async stop() {},
|
|
114
|
-
};
|