feat: try LoadTrajectory + multiple RPCs for actual AI response text, summary as fallback

This commit is contained in:
2026-03-07 20:15:27 +09:00
parent 7415ab7890
commit b0c2f865c8
4 changed files with 63 additions and 9 deletions

View File

@@ -332,13 +332,39 @@ function activate(context) {
console.log(`Gravity Bridge: [LS] init ${key.substring(0, 8)} at step ${stepIdx} "${summary.substring(0, 30)}"`);
}
else if (stepIdx > 0) {
// New trajectory appeared after first poll with steps = new conversation with AI response!
// New conversation with AI response! Try to get actual text
console.log(`Gravity Bridge: [LS] NEW conversation ${key.substring(0, 8)} at step ${stepIdx} "${summary.substring(0, 40)}"`);
// Immediately relay the summary as the AI response
if (summary) {
// Try multiple methods to get actual AI response text
const rpcAttempts = [
{ m: 'LoadTrajectory', p: { trajectoryId: trajId } },
{ m: 'LoadTrajectory', p: { googleAgentId: agentId } },
{ m: 'GetCascadeTrajectory', p: { googleAgentId: agentId } },
{ m: 'GetCascadeTrajectorySteps', p: { googleAgentId: agentId } },
];
let gotText = false;
for (const a of rpcAttempts) {
const res = await lsRPC(a.m, a.p);
if (res && !res.code) {
console.log(`Gravity Bridge: [LS] ✅ ${a.m}(${Object.keys(a.p)[0]}) → keys: ${Object.keys(res).join(', ')}`);
console.log(`Gravity Bridge: [LS] sample: ${JSON.stringify(res).substring(0, 1000)}`);
// Try to extract text
const steps = res.steps || res.cortexSteps || [];
if (Array.isArray(steps) && steps.length > 0) {
extractAndRelaySteps(steps.slice(-3)); // last 3 steps
gotText = true;
}
break;
}
else {
const err = res?.message || res?.code || 'empty';
console.log(`Gravity Bridge: [LS] ❌ ${a.m}(${Object.keys(a.p)[0]}): ${typeof err === 'string' ? err.substring(0, 60) : err}`);
}
}
// Fallback: relay summary
if (!gotText && summary) {
writeChatSnapshot(`**${summary}**\n\n(새 대화, step ${stepIdx})`);
lastStepIndex[key + '_summary'] = summary;
console.log(`Gravity Bridge: [LS] → relayed new conversation summary to Discord`);
console.log(`Gravity Bridge: [LS] → summary fallback to Discord`);
}
}
continue;

File diff suppressed because one or more lines are too long