Debug command. (#23851)

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
Jacob Richman
2026-03-27 14:05:22 -07:00
committed by GitHub
parent ba71ffa736
commit ebe98fdee9
4 changed files with 153 additions and 21 deletions

View File

@@ -177,7 +177,41 @@ export class DevTools extends EventEmitter {
}
// API routes
if (req.url === '/events') {
if (req.url === '/api/trigger-debugger' && req.method === 'POST') {
let body = '';
req.on('data', (chunk) => {
body += chunk;
});
req.on('end', () => {
try {
const parsed: unknown = JSON.parse(body);
if (
typeof parsed !== 'object' ||
parsed === null ||
!('sessionId' in parsed) ||
typeof parsed.sessionId !== 'string'
) {
res.writeHead(400, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ error: 'Invalid request' }));
return;
}
const sessionId = parsed.sessionId;
const session = this.sessions.get(sessionId);
if (session) {
session.ws.send(JSON.stringify({ type: 'trigger-debugger' }));
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ success: true }));
} else {
res.writeHead(404, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ error: 'Session not found' }));
}
} catch (_err) {
res.writeHead(400, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ error: 'Invalid request' }));
}
});
} else if (req.url === '/events') {
res.writeHead(200, {
'Content-Type': 'text/event-stream',
'Cache-Control': 'no-cache',