feat: try LoadTrajectory + multiple RPCs for actual AI response text, summary as fallback
This commit is contained in:
Binary file not shown.
@@ -332,13 +332,39 @@ function activate(context) {
|
|||||||
console.log(`Gravity Bridge: [LS] init ${key.substring(0, 8)} at step ${stepIdx} "${summary.substring(0, 30)}"`);
|
console.log(`Gravity Bridge: [LS] init ${key.substring(0, 8)} at step ${stepIdx} "${summary.substring(0, 30)}"`);
|
||||||
}
|
}
|
||||||
else if (stepIdx > 0) {
|
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)}"`);
|
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
|
// Try multiple methods to get actual AI response text
|
||||||
if (summary) {
|
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})`);
|
writeChatSnapshot(`**${summary}**\n\n(새 대화, step ${stepIdx})`);
|
||||||
lastStepIndex[key + '_summary'] = summary;
|
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;
|
continue;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -311,13 +311,41 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
if (isFirstPoll) {
|
if (isFirstPoll) {
|
||||||
console.log(`Gravity Bridge: [LS] init ${key.substring(0, 8)} at step ${stepIdx} "${summary.substring(0, 30)}"`);
|
console.log(`Gravity Bridge: [LS] init ${key.substring(0, 8)} at step ${stepIdx} "${summary.substring(0, 30)}"`);
|
||||||
} else if (stepIdx > 0) {
|
} 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)}"`);
|
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})`);
|
writeChatSnapshot(`**${summary}**\n\n(새 대화, step ${stepIdx})`);
|
||||||
lastStepIndex[key + '_summary'] = summary;
|
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;
|
continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user