claw-subagent-service 0.0.113 → 0.0.114
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -545,6 +545,44 @@ class MessageHandler {
|
|
|
545
545
|
return '[图片](无法获取图片地址)';
|
|
546
546
|
}
|
|
547
547
|
|
|
548
|
+
// 检查是否有文字内容(从 content 或 extra 中提取)
|
|
549
|
+
let textContent = '';
|
|
550
|
+
|
|
551
|
+
// 1. 从 content 对象中提取文字
|
|
552
|
+
if (typeof content === 'object' && content !== null && content.content) {
|
|
553
|
+
textContent = content.content;
|
|
554
|
+
} else if (typeof content === 'string') {
|
|
555
|
+
// 尝试解析 content 是否为 JSON
|
|
556
|
+
try {
|
|
557
|
+
const contentObj = JSON.parse(content);
|
|
558
|
+
if (contentObj.content) {
|
|
559
|
+
textContent = contentObj.content;
|
|
560
|
+
}
|
|
561
|
+
} catch (e) {
|
|
562
|
+
// content 不是 JSON,可能是纯文本
|
|
563
|
+
if (content && !content.startsWith('data:image')) {
|
|
564
|
+
textContent = content;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
// 2. 从 extra 字段中提取文字
|
|
570
|
+
if (!textContent && msg.extra) {
|
|
571
|
+
try {
|
|
572
|
+
const extraData = JSON.parse(msg.extra);
|
|
573
|
+
if (extraData.textContent) {
|
|
574
|
+
textContent = extraData.textContent;
|
|
575
|
+
}
|
|
576
|
+
} catch (e) {
|
|
577
|
+
// extra 不是 JSON,忽略
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
// 构建返回内容:如果有文字,返回文字+图片;否则只返回图片
|
|
582
|
+
if (textContent) {
|
|
583
|
+
return `${textContent}\n[图片] ${imageUri}`;
|
|
584
|
+
}
|
|
585
|
+
|
|
548
586
|
return `[图片] ${imageUri}`;
|
|
549
587
|
}
|
|
550
588
|
|