probe: Trial D2 — fixed protobuf encoding (protocol_version=1, cascadeId, ConnectRPC framing)
This commit is contained in:
@@ -429,41 +429,92 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
|
||||
|
||||
|
||||
// ========== Trial D: Streaming RPC + JSON retry ==========
|
||||
// ========== Trial D2: Streaming RPC with protocol_version=1 ==========
|
||||
setTimeout(async () => {
|
||||
if (!lsPort || !lsCsrf) { console.log('Gravity Bridge: [Trial D] Skipped — no LS'); return; }
|
||||
console.log(`Gravity Bridge: [Trial D] Probing streaming RPCs on port ${lsPort}...`);
|
||||
if (!lsPort || !lsCsrf) { console.log('Gravity Bridge: [Trial D2] Skipped — no LS'); return; }
|
||||
console.log(`Gravity Bridge: [Trial D2] Streaming RPCs with proto_version=1...`);
|
||||
const http = require('http');
|
||||
function tryRPC(method: string, bodyStr?: string): Promise<string> {
|
||||
|
||||
function tryProtoRPC(method: string, protoBody: Buffer, timeout: number = 12000): Promise<string> {
|
||||
return new Promise((resolve) => {
|
||||
const isJson = !!bodyStr;
|
||||
const body = isJson ? Buffer.from(bodyStr!) : Buffer.from([0, 0, 0, 0, 0]);
|
||||
const req = http.request({ hostname: '127.0.0.1', port: lsPort, path: `/exa.language_server_pb.LanguageServerService/${method}`, method: 'POST', headers: { 'Content-Type': isJson ? 'application/json' : 'application/connect+proto', 'Connect-Protocol-Version': '1', 'x-codeium-csrf-token': lsCsrf }, timeout: 8000 }, (res: any) => {
|
||||
// ConnectRPC frame: [flag(1)] [length(4 big-endian)] [message]
|
||||
const frame = Buffer.alloc(5 + protoBody.length);
|
||||
frame[0] = 0x00; // no compression
|
||||
frame.writeUInt32BE(protoBody.length, 1);
|
||||
protoBody.copy(frame, 5);
|
||||
|
||||
const req = http.request({
|
||||
hostname: '127.0.0.1', port: lsPort,
|
||||
path: `/exa.language_server_pb.LanguageServerService/${method}`,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/connect+proto',
|
||||
'Connect-Protocol-Version': '1',
|
||||
'x-codeium-csrf-token': lsCsrf,
|
||||
},
|
||||
timeout: timeout
|
||||
}, (res: any) => {
|
||||
const chunks: Buffer[] = [];
|
||||
res.on('data', (c: Buffer) => chunks.push(c));
|
||||
res.on('end', () => resolve(Buffer.concat(chunks).toString('utf-8')));
|
||||
res.on('end', () => {
|
||||
const buf = Buffer.concat(chunks);
|
||||
// Skip ConnectRPC frame header (5 bytes) to get proto/JSON content
|
||||
const text = buf.toString('utf-8');
|
||||
resolve(text);
|
||||
});
|
||||
});
|
||||
req.on('error', (e: any) => resolve(`err:${e.message}`));
|
||||
req.on('timeout', () => { req.destroy(); resolve('timeout'); });
|
||||
req.write(body); req.end();
|
||||
req.on('timeout', () => { req.destroy(); resolve('timeout(stream open)'); });
|
||||
req.write(frame); req.end();
|
||||
});
|
||||
}
|
||||
for (const m of ['StreamCascadeReactiveUpdates', 'StreamCascadeSummariesReactiveUpdates', 'StreamAgentStateUpdates', 'GetBrowserOpenConversation']) {
|
||||
const r = await tryRPC(m);
|
||||
console.log(`Gravity Bridge: [Trial D] ${m}: ${r.substring(0, 400)}`);
|
||||
}
|
||||
|
||||
// protobuf: field 1 (protocol_version) = 1 → 0x08 0x01
|
||||
const versionOnly = Buffer.from([0x08, 0x01]);
|
||||
|
||||
// Try StreamCascadeReactiveUpdates with version=1
|
||||
let r = await tryProtoRPC('StreamCascadeReactiveUpdates', versionOnly);
|
||||
console.log(`Gravity Bridge: [Trial D2] StreamCascade(v1): ${r.substring(0, 600)}`);
|
||||
|
||||
// Try StreamCascadeSummariesReactiveUpdates with version=1
|
||||
r = await tryProtoRPC('StreamCascadeSummariesReactiveUpdates', versionOnly);
|
||||
console.log(`Gravity Bridge: [Trial D2] StreamSummaries(v1): ${r.substring(0, 600)}`);
|
||||
|
||||
// Get latest trajectory ID and try StreamAgentStateUpdates with cascadeId
|
||||
try {
|
||||
const dRaw = await vscode.commands.executeCommand('antigravity.getDiagnostics');
|
||||
const d = typeof dRaw === 'string' ? JSON.parse(dRaw) : dRaw;
|
||||
const ts = d?.recentTrajectories || [];
|
||||
if (ts.length > 0) {
|
||||
const t = ts[ts.length - 1];
|
||||
const gid = t.googleAgentId || '';
|
||||
console.log(`Gravity Bridge: [Trial D] Latest: ${gid.substring(0, 8)} step=${t.lastStepIndex}`);
|
||||
const r = await tryRPC('GetCascadeTrajectorySteps', JSON.stringify({ trajectoryId: gid, startStepIndex: Math.max(0, t.lastStepIndex - 1) }));
|
||||
console.log(`Gravity Bridge: [Trial D] Steps(json): ${r.substring(0, 500)}`);
|
||||
const latest = ts[ts.length - 1];
|
||||
const gid = latest.googleAgentId || '';
|
||||
console.log(`Gravity Bridge: [Trial D2] Using trajectory ${gid.substring(0, 8)}`);
|
||||
|
||||
// Build protobuf with cascadeId string: field 1 = gid
|
||||
// string field: tag=0x0A (field 1 wire type 2), length, bytes
|
||||
const gidBuf = Buffer.from(gid, 'utf-8');
|
||||
const cascadeProto = Buffer.alloc(2 + gidBuf.length);
|
||||
cascadeProto[0] = 0x0A; // field 1, wire type 2 (length-delimited)
|
||||
cascadeProto[1] = gidBuf.length;
|
||||
gidBuf.copy(cascadeProto, 2);
|
||||
|
||||
r = await tryProtoRPC('StreamAgentStateUpdates', cascadeProto);
|
||||
console.log(`Gravity Bridge: [Trial D2] AgentState(${gid.substring(0, 8)}): ${r.substring(0, 600)}`);
|
||||
|
||||
// Also try GetCascadeTrajectorySteps with proto encoding
|
||||
// field 1 = trajectoryId (string), field 2 = startStepIndex (varint)
|
||||
const stepIdx = Math.max(0, latest.lastStepIndex - 1);
|
||||
const stepsProto = Buffer.alloc(2 + gidBuf.length + 2);
|
||||
stepsProto[0] = 0x0A;
|
||||
stepsProto[1] = gidBuf.length;
|
||||
gidBuf.copy(stepsProto, 2);
|
||||
stepsProto[2 + gidBuf.length] = 0x10; // field 2 varint
|
||||
stepsProto[3 + gidBuf.length] = stepIdx;
|
||||
|
||||
r = await tryProtoRPC('GetCascadeTrajectorySteps', stepsProto);
|
||||
console.log(`Gravity Bridge: [Trial D2] Steps(proto): ${r.substring(0, 800)}`);
|
||||
}
|
||||
} catch (e: any) { console.log(`Gravity Bridge: [Trial D] err: ${e.message}`); }
|
||||
} catch (e: any) { console.log(`Gravity Bridge: [Trial D2] err: ${e.message}`); }
|
||||
}, 15000);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user