mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-31 16:31:08 -07:00
Debug command. (#23851)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user