const http = require('http');

// Try different RPC methods to see what's available
const methods = [
    { method: "antigravity.workbench.GetDiagnostics", args: {} },
    { method: "GetDiagnostics", args: {} },
];

async function tryRPC(method, args) {
    return new Promise((resolve) => {
        const payload = JSON.stringify({ method, args });
        const req = http.request({
            hostname: '127.0.0.1',
            port: 34332,
            path: '/test-rpc',
            method: 'POST',
            headers: { 'Content-Type': 'application/json' }
        }, (res) => {
            let data = '';
            res.on('data', c => data += c);
            res.on('end', () => {
                console.log(`\n=== ${method} (${res.statusCode}) ===`);
                if (data.length > 2000) {
                    console.log(data.substring(0, 2000) + '\n... (truncated)');
                } else {
                    console.log(data);
                }
                resolve();
            });
        });
        req.on('error', e => { console.log(`${method}: ERROR ${e.message}`); resolve(); });
        req.write(payload);
        req.end();
    });
}

(async () => {
    for (const m of methods) {
        await tryRPC(m.method, m.args);
    }
    
    // Also try the /status endpoint for full state
    const statusReq = http.get('http://127.0.0.1:34332/status', (res) => {
        let d = '';
        res.on('data', c => d += c);
        res.on('end', () => {
            console.log('\n=== /status ===');
            console.log(d);
        });
    });
    statusReq.on('error', e => console.log('Status error:', e.message));
})();
