claw-subagent-service 0.0.101 → 0.0.103

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claw-subagent-service",
3
- "version": "0.0.101",
3
+ "version": "0.0.103",
4
4
  "description": "虾说智能助手",
5
5
  "main": "cli.js",
6
6
  "bin": {
@@ -507,17 +507,36 @@ class MessageHandler {
507
507
 
508
508
  // 图片消息
509
509
  if (msgType === 'RC:ImgMsg') {
510
- // content 可能是对象(包含 imageUri)或字符串(base64 缩略图)
510
+ // content 可能是对象(包含 imageUri)或字符串(base64 缩略图或 JSON)
511
511
  let imageUri = '';
512
512
 
513
513
  if (typeof content === 'string') {
514
- // content base64 缩略图,需要查找其他字段获取 URL
515
- imageUri = msg.imageUri || msg.imageUrl || msg.url || msg.localPath || '';
514
+ // 尝试解析 content 是否为 JSON(包含 imageUri)
515
+ try {
516
+ const contentObj = JSON.parse(content);
517
+ if (contentObj.imageUri) {
518
+ imageUri = contentObj.imageUri;
519
+ }
520
+ } catch (e) {
521
+ // content 不是 JSON,可能是 base64 缩略图
522
+ // 从 msg 其他字段查找 URL
523
+ imageUri = msg.imageUri || msg.imageUrl || msg.url || msg.localPath || '';
524
+ }
516
525
  } else if (typeof content === 'object' && content !== null) {
517
526
  // content 是对象,包含 imageUri
518
527
  imageUri = content.imageUri || content.imageUrl || content.url || '';
519
528
  }
520
529
 
530
+ // 如果还是没有找到 URL,尝试从 extra 字段获取
531
+ if (!imageUri && msg.extra) {
532
+ try {
533
+ const extraData = JSON.parse(msg.extra);
534
+ imageUri = extraData.imageUrl || extraData.imageUri || '';
535
+ } catch (e) {
536
+ // extra 不是 JSON,忽略
537
+ }
538
+ }
539
+
521
540
  this.log?.info(`[_extractMessageContent] 图片消息: imageUri=${imageUri}`);
522
541
 
523
542
  if (!imageUri) {