agentgui 1.0.405 → 1.0.407
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/claude-runner.js +5 -0
- package/package.json +1 -1
- package/readme.md +2 -0
- package/server.js +59 -24
package/lib/claude-runner.js
CHANGED
|
@@ -86,6 +86,8 @@ class AgentRunner {
|
|
|
86
86
|
proc.stdin.end();
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
proc.stdout.on('error', () => {});
|
|
90
|
+
proc.stderr.on('error', () => {});
|
|
89
91
|
proc.stdout.on('data', (chunk) => {
|
|
90
92
|
if (timedOut) return;
|
|
91
93
|
|
|
@@ -269,6 +271,8 @@ class AgentRunner {
|
|
|
269
271
|
}
|
|
270
272
|
};
|
|
271
273
|
|
|
274
|
+
proc.stdout.on('error', () => {});
|
|
275
|
+
proc.stderr.on('error', () => {});
|
|
272
276
|
let buffer = '';
|
|
273
277
|
proc.stdout.on('data', (chunk) => {
|
|
274
278
|
if (timedOut) return;
|
|
@@ -315,6 +319,7 @@ class AgentRunner {
|
|
|
315
319
|
}
|
|
316
320
|
}
|
|
317
321
|
};
|
|
322
|
+
proc.stdin.on('error', () => {});
|
|
318
323
|
proc.stdin.write(JSON.stringify(initRequest) + '\n');
|
|
319
324
|
|
|
320
325
|
let sessionCreated = false;
|
package/package.json
CHANGED
package/readme.md
CHANGED
package/server.js
CHANGED
|
@@ -23,6 +23,17 @@ import { register as registerSessionHandlers } from './lib/ws-handlers-session.j
|
|
|
23
23
|
import { register as registerRunHandlers } from './lib/ws-handlers-run.js';
|
|
24
24
|
import { register as registerUtilHandlers } from './lib/ws-handlers-util.js';
|
|
25
25
|
|
|
26
|
+
|
|
27
|
+
process.on('uncaughtException', (err, origin) => {
|
|
28
|
+
console.error('[FATAL] Uncaught exception (contained):', err.message, '| origin:', origin);
|
|
29
|
+
console.error(err.stack);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
process.on('unhandledRejection', (reason, promise) => {
|
|
33
|
+
console.error('[FATAL] Unhandled rejection (contained):', reason instanceof Error ? reason.message : reason);
|
|
34
|
+
if (reason instanceof Error) console.error(reason.stack);
|
|
35
|
+
});
|
|
36
|
+
|
|
26
37
|
const ttsTextAccumulators = new Map();
|
|
27
38
|
|
|
28
39
|
let speechModule = null;
|
|
@@ -1673,6 +1684,8 @@ const server = http.createServer(async (req, res) => {
|
|
|
1673
1684
|
};
|
|
1674
1685
|
child.stdout.on('data', onData('stdout'));
|
|
1675
1686
|
child.stderr.on('data', onData('stderr'));
|
|
1687
|
+
child.stdout.on('error', () => {});
|
|
1688
|
+
child.stderr.on('error', () => {});
|
|
1676
1689
|
child.on('error', (err) => {
|
|
1677
1690
|
activeScripts.delete(conversationId);
|
|
1678
1691
|
broadcastSync({ type: 'script_stopped', conversationId, code: 1, error: err.message, timestamp: Date.now() });
|
|
@@ -2442,6 +2455,8 @@ const server = http.createServer(async (req, res) => {
|
|
|
2442
2455
|
};
|
|
2443
2456
|
child.stdout.on('data', onData('stdout'));
|
|
2444
2457
|
child.stderr.on('data', onData('stderr'));
|
|
2458
|
+
child.stdout.on('error', () => {});
|
|
2459
|
+
child.stderr.on('error', () => {});
|
|
2445
2460
|
child.on('error', (err) => {
|
|
2446
2461
|
activeScripts.delete(conversationId);
|
|
2447
2462
|
broadcastSync({ type: 'script_stopped', conversationId, code: 1, error: err.message, timestamp: Date.now() });
|
|
@@ -2476,6 +2491,8 @@ const server = http.createServer(async (req, res) => {
|
|
|
2476
2491
|
};
|
|
2477
2492
|
child.stdout.on('data', onData('stdout'));
|
|
2478
2493
|
child.stderr.on('data', onData('stderr'));
|
|
2494
|
+
child.stdout.on('error', () => {});
|
|
2495
|
+
child.stderr.on('error', () => {});
|
|
2479
2496
|
child.on('error', (err) => {
|
|
2480
2497
|
activeScripts.delete(conversationId);
|
|
2481
2498
|
broadcastSync({ type: 'script_stopped', conversationId, code: 1, error: err.message, timestamp: Date.now() });
|
|
@@ -3790,6 +3807,9 @@ const wss = new WebSocketServer({
|
|
|
3790
3807
|
threshold: 256
|
|
3791
3808
|
}
|
|
3792
3809
|
});
|
|
3810
|
+
wss.on('error', (err) => {
|
|
3811
|
+
console.error('[WSS] WebSocket server error (contained):', err.message);
|
|
3812
|
+
});
|
|
3793
3813
|
const hotReloadClients = [];
|
|
3794
3814
|
const syncClients = new Set();
|
|
3795
3815
|
const subscriptionIndex = new Map();
|
|
@@ -3813,8 +3833,11 @@ wss.on('connection', (ws, req) => {
|
|
|
3813
3833
|
timestamp: Date.now()
|
|
3814
3834
|
}));
|
|
3815
3835
|
|
|
3836
|
+
ws.on('error', (err) => {
|
|
3837
|
+
console.error('[WS] Client error (contained):', ws.clientId, err.message);
|
|
3838
|
+
});
|
|
3816
3839
|
ws.on('message', (msg) => {
|
|
3817
|
-
wsRouter.onMessage(ws, msg);
|
|
3840
|
+
try { wsRouter.onMessage(ws, msg); } catch (e) { console.error('[WS] Message handler error (contained):', e.message); }
|
|
3818
3841
|
});
|
|
3819
3842
|
|
|
3820
3843
|
ws.on('pong', () => { ws.isAlive = true; });
|
|
@@ -3842,31 +3865,33 @@ const BROADCAST_TYPES = new Set([
|
|
|
3842
3865
|
const wsOptimizer = new WSOptimizer();
|
|
3843
3866
|
|
|
3844
3867
|
function broadcastSync(event) {
|
|
3845
|
-
|
|
3868
|
+
try {
|
|
3869
|
+
const isBroadcast = BROADCAST_TYPES.has(event.type);
|
|
3846
3870
|
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3871
|
+
if (syncClients.size > 0) {
|
|
3872
|
+
if (isBroadcast) {
|
|
3873
|
+
for (const ws of syncClients) { try { wsOptimizer.sendToClient(ws, event); } catch (e) {} }
|
|
3874
|
+
} else {
|
|
3875
|
+
const targets = new Set();
|
|
3876
|
+
if (event.sessionId) {
|
|
3877
|
+
const subs = subscriptionIndex.get(event.sessionId);
|
|
3878
|
+
if (subs) for (const ws of subs) targets.add(ws);
|
|
3879
|
+
}
|
|
3880
|
+
if (event.conversationId) {
|
|
3881
|
+
const subs = subscriptionIndex.get(`conv-${event.conversationId}`);
|
|
3882
|
+
if (subs) for (const ws of subs) targets.add(ws);
|
|
3883
|
+
}
|
|
3884
|
+
for (const ws of targets) { try { wsOptimizer.sendToClient(ws, event); } catch (e) {} }
|
|
3860
3885
|
}
|
|
3861
|
-
for (const ws of targets) wsOptimizer.sendToClient(ws, event);
|
|
3862
3886
|
}
|
|
3863
|
-
}
|
|
3864
3887
|
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3888
|
+
if (sseStreamHandlers.size > 0) {
|
|
3889
|
+
for (const [runId, handler] of sseStreamHandlers.entries()) {
|
|
3890
|
+
try { handler(event); } catch (e) {}
|
|
3891
|
+
}
|
|
3869
3892
|
}
|
|
3893
|
+
} catch (err) {
|
|
3894
|
+
console.error('[BROADCAST] Error (contained):', err.message);
|
|
3870
3895
|
}
|
|
3871
3896
|
}
|
|
3872
3897
|
|
|
@@ -3898,6 +3923,7 @@ registerUtilHandlers(wsRouter, {
|
|
|
3898
3923
|
});
|
|
3899
3924
|
|
|
3900
3925
|
wsRouter.onLegacy((data, ws) => {
|
|
3926
|
+
try {
|
|
3901
3927
|
if (data.type === 'subscribe') {
|
|
3902
3928
|
if (data.sessionId) {
|
|
3903
3929
|
ws.subscriptions.add(data.sessionId);
|
|
@@ -3968,10 +3994,18 @@ wsRouter.onLegacy((data, ws) => {
|
|
|
3968
3994
|
if (ws.readyState === 1) ws.send(JSON.stringify({ type: 'terminal_exit', code }));
|
|
3969
3995
|
ws.terminalProc = null;
|
|
3970
3996
|
});
|
|
3997
|
+
proc.on('error', (err) => {
|
|
3998
|
+
console.error('[TERMINAL] Spawn error (contained):', err.message);
|
|
3999
|
+
if (ws.readyState === 1) ws.send(JSON.stringify({ type: 'terminal_exit', code: 1, error: err.message }));
|
|
4000
|
+
ws.terminalProc = null;
|
|
4001
|
+
});
|
|
4002
|
+
proc.stdin.on('error', () => {});
|
|
4003
|
+
proc.stdout.on('error', () => {});
|
|
4004
|
+
proc.stderr.on('error', () => {});
|
|
3971
4005
|
ws.send(JSON.stringify({ type: 'terminal_started', timestamp: Date.now() }));
|
|
3972
4006
|
} else if (data.type === 'terminal_input') {
|
|
3973
4007
|
if (ws.terminalProc && ws.terminalProc.stdin.writable) {
|
|
3974
|
-
ws.terminalProc.stdin.write(Buffer.from(data.data, 'base64'));
|
|
4008
|
+
try { ws.terminalProc.stdin.write(Buffer.from(data.data, 'base64')); } catch (e) {}
|
|
3975
4009
|
}
|
|
3976
4010
|
} else if (data.type === 'terminal_stop') {
|
|
3977
4011
|
if (ws.terminalProc) {
|
|
@@ -3979,6 +4013,8 @@ wsRouter.onLegacy((data, ws) => {
|
|
|
3979
4013
|
ws.terminalProc = null;
|
|
3980
4014
|
}
|
|
3981
4015
|
}
|
|
4016
|
+
|
|
4017
|
+
} catch (err) { console.error('[WS-LEGACY] Handler error (contained):', err.message); }
|
|
3982
4018
|
});
|
|
3983
4019
|
|
|
3984
4020
|
// Heartbeat interval to detect stale connections
|
|
@@ -4019,8 +4055,7 @@ server.on('error', (err) => {
|
|
|
4019
4055
|
server.listen(PORT, onServerReady);
|
|
4020
4056
|
}, 3000);
|
|
4021
4057
|
} else {
|
|
4022
|
-
console.error('
|
|
4023
|
-
process.exit(1);
|
|
4058
|
+
console.error('[SERVER] Error (contained):', err.message);
|
|
4024
4059
|
}
|
|
4025
4060
|
});
|
|
4026
4061
|
|