fix: extract text from plannerResponse field for Discord relay

This commit is contained in:
2026-03-10 09:02:16 +09:00
parent e586bb6d41
commit 1089c6ce61
3 changed files with 73 additions and 11 deletions

View File

@@ -1806,13 +1806,48 @@ function setupMonitor() {
const s = steps[ri];
const sType = s?.type || '';
if (sType.includes('PLANNER_RESPONSE') || sType.includes('MESSAGE')) {
const parts = s?.content?.parts || s?.parts || [];
let textContent = '';
for (const p of parts) {
if (p?.text)
textContent += p.text;
else if (typeof p === 'string')
textContent += p;
// Extract from plannerResponse field
const pr = s?.plannerResponse;
if (pr) {
if (typeof pr === 'string')
textContent = pr;
else if (pr.rawText)
textContent = pr.rawText;
else if (pr.message)
textContent = typeof pr.message === 'string' ? pr.message : JSON.stringify(pr.message);
else if (pr.content?.parts) {
for (const p of pr.content.parts) {
if (p?.text)
textContent += p.text;
}
}
else if (pr.parts) {
for (const p of pr.parts) {
if (p?.text)
textContent += p.text;
}
}
if (!textContent)
textContent = JSON.stringify(pr).substring(0, 500);
}
// Extract from ephemeralMessage field
const em = s?.ephemeralMessage;
if (!textContent && em) {
if (typeof em === 'string')
textContent = em;
else if (em.message)
textContent = em.message;
else if (em.content)
textContent = typeof em.content === 'string' ? em.content : JSON.stringify(em.content);
}
// Fallback: metadata, content, rawOutput
if (!textContent) {
const parts = s?.content?.parts || s?.parts || [];
for (const p of parts) {
if (p?.text)
textContent += p.text;
}
}
if (!textContent && s?.metadata?.text)
textContent = s.metadata.text;

File diff suppressed because one or more lines are too long