@ynhcj/xiaoyi-channel 0.0.72-beta → 0.0.74-beta
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.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getXYWebSocketManager } from "../client.js";
|
|
2
2
|
import { sendCommand } from "../formatter.js";
|
|
3
3
|
import { getCurrentSessionContext } from "./session-manager.js";
|
|
4
|
+
import { XYFileUploadService } from "../file-upload.js";
|
|
4
5
|
/**
|
|
5
6
|
* Duck-typed ToolInputError: openclaw 按 .name 字段匹配,不用 instanceof。
|
|
6
7
|
* 抛出此错误会让 openclaw 返回 HTTP 400 而非 500,
|
|
@@ -36,7 +37,7 @@ export const xiaoyiAddCollectionTool = {
|
|
|
36
37
|
},
|
|
37
38
|
uri: {
|
|
38
39
|
type: "string",
|
|
39
|
-
description: "必填字段(IMAGE/FILE
|
|
40
|
+
description: "必填字段(IMAGE/FILE类型时)。图片或文件的地址链接。",
|
|
40
41
|
},
|
|
41
42
|
sourceAppBundleName: {
|
|
42
43
|
type: "string",
|
|
@@ -70,6 +71,15 @@ export const xiaoyiAddCollectionTool = {
|
|
|
70
71
|
const { config, sessionId, taskId, messageId } = sessionContext;
|
|
71
72
|
// Get WebSocket manager
|
|
72
73
|
const wsManager = getXYWebSocketManager(config);
|
|
74
|
+
// Handle uri: upload local paths to get public URL
|
|
75
|
+
let publicUri = uri;
|
|
76
|
+
if (uri && !uri.startsWith("http://") && !uri.startsWith("https://") && !uri.startsWith("file://")) {
|
|
77
|
+
const uploadService = new XYFileUploadService(config.fileUploadUrl, config.apiKey, config.uid);
|
|
78
|
+
publicUri = await uploadService.uploadFileAndGetUrl(uri);
|
|
79
|
+
if (!publicUri) {
|
|
80
|
+
throw new Error("本地文件上传失败,无法获取公网URL");
|
|
81
|
+
}
|
|
82
|
+
}
|
|
73
83
|
// Build intentParam
|
|
74
84
|
const intentParam = {
|
|
75
85
|
dataType,
|
|
@@ -77,8 +87,8 @@ export const xiaoyiAddCollectionTool = {
|
|
|
77
87
|
if (content) {
|
|
78
88
|
intentParam.content = content;
|
|
79
89
|
}
|
|
80
|
-
if (
|
|
81
|
-
intentParam.uri =
|
|
90
|
+
if (publicUri) {
|
|
91
|
+
intentParam.uri = publicUri;
|
|
82
92
|
}
|
|
83
93
|
if (sourceAppBundleName) {
|
|
84
94
|
intentParam.sourceAppBundleName = sourceAppBundleName;
|