fix(extension): bypass 10-item limit of GetAllCascadeTrajectories by utilizing GetDiagnostics
This commit is contained in:
@@ -126,6 +126,22 @@ export function startHttpBridge(ctx: HttpBridgeContext, sdk: any): Promise<numbe
|
||||
return;
|
||||
}
|
||||
|
||||
if (req.method === 'POST' && url.pathname === '/test-rpc') {
|
||||
let rpcBody = '';
|
||||
req.on('data', (c: string) => rpcBody += c);
|
||||
req.on('end', async () => {
|
||||
try {
|
||||
const params = JSON.parse(rpcBody);
|
||||
const result = await sdk.ls.rawRPC(params.method, params.args || {});
|
||||
res.writeHead(200, {'Content-Type': 'application/json'});
|
||||
res.end(typeof result === 'string' ? result : JSON.stringify(result));
|
||||
} catch(e: any) {
|
||||
res.writeHead(500); res.end(e.message);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// GET /ping — health check
|
||||
if (url.pathname === '/ping') {
|
||||
res.writeHead(200); res.end('pong');
|
||||
|
||||
@@ -208,10 +208,44 @@ function setupMonitor() {
|
||||
ctx.logToFile(`[POLL#${pollCount}] alive`);
|
||||
}
|
||||
try {
|
||||
// Fix (v0.5.14): Reverted 100-limit DoS but restored descending: true with a safe limit of 30
|
||||
const allTraj = await ctx.sdk.ls.rawRPC('GetAllCascadeTrajectories', { limit: 30, descending: true });
|
||||
if (!allTraj?.trajectorySummaries) {
|
||||
if (pollCount <= 3) ctx.logToFile('[POLL] no trajectorySummaries');
|
||||
// Fix (v0.5.15): Bypass 10-Item Hard Limit of GetAllCascadeTrajectories.
|
||||
// We fetch GetDiagnostics to discover ALL recent sessions regardless of pagination.
|
||||
let allTraj: any = { trajectorySummaries: {} };
|
||||
try {
|
||||
// Primary: Try fetching 100 trajectories (backend might ignore this and give 10)
|
||||
const apiResult = await ctx.sdk.ls.rawRPC('GetAllCascadeTrajectories', { limit: 100, maxResults: 100, pageSize: 100, page_size: 100, descending: true });
|
||||
if (apiResult?.trajectorySummaries) {
|
||||
allTraj.trajectorySummaries = { ...apiResult.trajectorySummaries };
|
||||
}
|
||||
} catch (e: any) {
|
||||
if (pollCount <= 3) ctx.logToFile(`[POLL] GetAllCascadeTrajectories failed: ${e.message}`);
|
||||
}
|
||||
|
||||
try {
|
||||
// Fallback / Augment: GetDiagnostics provides ALL recent sessions bypassing the hard limit
|
||||
const diagRaw = await ctx.sdk.ls.rawRPC('GetDiagnostics', {});
|
||||
const diag = typeof diagRaw === 'string' ? JSON.parse(diagRaw) : diagRaw;
|
||||
const recent = diag.recentTrajectories || [];
|
||||
for (const entry of recent) {
|
||||
const sid = entry.googleAgentId;
|
||||
if (sid && !allTraj.trajectorySummaries[sid]) {
|
||||
allTraj.trajectorySummaries[sid] = {
|
||||
status: entry.status || '',
|
||||
stepCount: entry.lastStepIndex || 0,
|
||||
lastModifiedTime: entry.lastModifiedTime || '',
|
||||
summary: entry.summary || 'Untitled',
|
||||
trajectoryMetadata: entry.trajectoryMetadata || {
|
||||
workspaces: [{ workspaceFolderAbsoluteUri: entry.workspaceUri || '' }]
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
} catch (e: any) {
|
||||
if (pollCount <= 3) ctx.logToFile(`[POLL] GetDiagnostics fallback failed: ${e.message}`);
|
||||
}
|
||||
|
||||
if (!allTraj?.trajectorySummaries || Object.keys(allTraj.trajectorySummaries).length === 0) {
|
||||
if (pollCount <= 3) ctx.logToFile('[POLL] no trajectorySummaries found from any source');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user