claw-subagent-service 0.0.103 → 0.0.105
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
|
@@ -389,6 +389,11 @@ class OpenClawClient {
|
|
|
389
389
|
this.log?.error(`[OpenClawClient] 修改后请重启 OpenClaw gateway: openclaw gateway`);
|
|
390
390
|
} else {
|
|
391
391
|
this.log?.error(`[OpenClawClient] SSE 请求失败: ${err.message}`);
|
|
392
|
+
// 打印详细错误响应
|
|
393
|
+
if (err.response) {
|
|
394
|
+
this.log?.error(`[OpenClawClient] 错误状态码: ${err.response.status}`);
|
|
395
|
+
this.log?.error(`[OpenClawClient] 错误响应数据: ${JSON.stringify(err.response.data)}`);
|
|
396
|
+
}
|
|
392
397
|
}
|
|
393
398
|
// 不再内部调用 onError,让错误通过 Promise reject 向上传播,便于调用方回退
|
|
394
399
|
throw err;
|
|
@@ -405,11 +410,30 @@ class OpenClawClient {
|
|
|
405
410
|
headers['Authorization'] = `Bearer ${gatewayToken}`;
|
|
406
411
|
}
|
|
407
412
|
|
|
413
|
+
// 检测消息是否包含图片 URL
|
|
414
|
+
const imageUrlMatch = message.match(/\[图片\]\s*(https?:\/\/[^\s]+)/);
|
|
415
|
+
let messages;
|
|
416
|
+
|
|
417
|
+
if (imageUrlMatch) {
|
|
418
|
+
// 多模态格式:图片 + 文本
|
|
419
|
+
const imageUrl = imageUrlMatch[1];
|
|
420
|
+
const textContent = message.replace(/\[图片\]\s*https?:\/\/[^\s]+/, '').trim();
|
|
421
|
+
|
|
422
|
+
messages = [{
|
|
423
|
+
role: 'user',
|
|
424
|
+
content: [
|
|
425
|
+
{ type: 'text', text: textContent || '描述这张图片' },
|
|
426
|
+
{ type: 'image_url', image_url: { url: imageUrl } }
|
|
427
|
+
]
|
|
428
|
+
}];
|
|
429
|
+
} else {
|
|
430
|
+
// 纯文本格式
|
|
431
|
+
messages = [{ role: 'user', content: message }];
|
|
432
|
+
}
|
|
433
|
+
|
|
408
434
|
const payload = {
|
|
409
435
|
model: 'openclaw',
|
|
410
|
-
messages:
|
|
411
|
-
{ role: 'user', content: message }
|
|
412
|
-
],
|
|
436
|
+
messages: messages,
|
|
413
437
|
stream: true,
|
|
414
438
|
max_tokens: 2048
|
|
415
439
|
};
|