@ynhcj/xiaoyi-channel 0.0.97-beta → 0.0.97-next
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/dist/index.d.ts +6 -9
- package/dist/index.js +26 -21
- package/dist/provider-discovery.d.ts +2 -0
- package/dist/provider-discovery.js +4 -0
- package/dist/src/bot.js +29 -4
- package/dist/src/channel.js +2 -19
- package/dist/src/client.js +31 -22
- package/dist/src/cspl/call-api.js +6 -5
- package/dist/src/file-download.js +4 -3
- package/dist/src/file-upload.js +19 -18
- package/dist/src/formatter.d.ts +2 -0
- package/dist/src/formatter.js +9 -28
- package/dist/src/heartbeat.js +1 -1
- package/dist/src/login-token-handler.d.ts +8 -0
- package/dist/src/login-token-handler.js +60 -0
- package/dist/src/message-queue.d.ts +17 -0
- package/dist/src/message-queue.js +51 -0
- package/dist/src/monitor.js +70 -14
- package/dist/src/outbound.js +19 -18
- package/dist/src/provider.d.ts +2 -1
- package/dist/src/provider.js +245 -38
- package/dist/src/push.js +16 -15
- package/dist/src/reply-dispatcher.js +12 -3
- package/dist/src/runtime.d.ts +3 -11
- package/dist/src/runtime.js +6 -18
- package/dist/src/self-evolution-handler.d.ts +6 -0
- package/dist/src/self-evolution-handler.js +100 -7
- package/dist/src/self-evolution-keyword.d.ts +9 -0
- package/dist/src/self-evolution-keyword.js +147 -0
- package/dist/src/self-evolution-tool-result-nudge.d.ts +3 -0
- package/dist/src/self-evolution-tool-result-nudge.js +96 -0
- package/dist/src/skill-retriever/config.d.ts +4 -0
- package/dist/src/skill-retriever/config.js +23 -0
- package/dist/src/skill-retriever/hooks.d.ts +22 -0
- package/dist/src/skill-retriever/hooks.js +83 -0
- package/dist/src/skill-retriever/tool-search.d.ts +16 -0
- package/dist/src/skill-retriever/tool-search.js +173 -0
- package/dist/src/skill-retriever/types.d.ts +36 -0
- package/dist/src/skill-retriever/types.js +1 -0
- package/dist/src/steer-injector.js +1 -1
- package/dist/src/task-manager.d.ts +4 -0
- package/dist/src/task-manager.js +12 -1
- package/dist/src/tools/calendar-tool.d.ts +2 -1
- package/dist/src/tools/calendar-tool.js +112 -116
- package/dist/src/tools/call-device-tool.d.ts +2 -1
- package/dist/src/tools/call-device-tool.js +126 -103
- package/dist/src/tools/call-phone-tool.d.ts +2 -1
- package/dist/src/tools/call-phone-tool.js +109 -113
- package/dist/src/tools/create-alarm-tool.d.ts +2 -1
- package/dist/src/tools/create-alarm-tool.js +227 -231
- package/dist/src/tools/create-all-tools.d.ts +16 -0
- package/dist/src/tools/create-all-tools.js +50 -0
- package/dist/src/tools/delete-alarm-tool.d.ts +2 -1
- package/dist/src/tools/delete-alarm-tool.js +131 -135
- package/dist/src/tools/get-alarm-tool-schema.d.ts +2 -1
- package/dist/src/tools/get-alarm-tool-schema.js +16 -10
- package/dist/src/tools/get-calendar-tool-schema.d.ts +2 -1
- package/dist/src/tools/get-calendar-tool-schema.js +12 -8
- package/dist/src/tools/get-collection-tool-schema.d.ts +2 -1
- package/dist/src/tools/get-collection-tool-schema.js +11 -9
- package/dist/src/tools/get-contact-tool-schema.d.ts +2 -1
- package/dist/src/tools/get-contact-tool-schema.js +16 -10
- package/dist/src/tools/get-device-file-tool-schema.d.ts +2 -1
- package/dist/src/tools/get-device-file-tool-schema.js +13 -9
- package/dist/src/tools/get-email-tool-schema.d.ts +2 -1
- package/dist/src/tools/get-email-tool-schema.js +11 -8
- package/dist/src/tools/get-note-tool-schema.d.ts +2 -1
- package/dist/src/tools/get-note-tool-schema.js +14 -9
- package/dist/src/tools/get-photo-tool-schema.d.ts +2 -1
- package/dist/src/tools/get-photo-tool-schema.js +12 -9
- package/dist/src/tools/image-reading-tool.d.ts +2 -1
- package/dist/src/tools/image-reading-tool.js +86 -90
- package/dist/src/tools/location-tool.d.ts +2 -1
- package/dist/src/tools/location-tool.js +87 -91
- package/dist/src/tools/login-token-tool.d.ts +6 -0
- package/dist/src/tools/login-token-tool.js +133 -0
- package/dist/src/tools/modify-alarm-tool.d.ts +2 -1
- package/dist/src/tools/modify-alarm-tool.js +232 -236
- package/dist/src/tools/modify-note-tool.d.ts +2 -1
- package/dist/src/tools/modify-note-tool.js +104 -108
- package/dist/src/tools/note-tool.d.ts +2 -1
- package/dist/src/tools/note-tool.js +103 -107
- package/dist/src/tools/query-app-message-tool.d.ts +2 -1
- package/dist/src/tools/query-app-message-tool.js +108 -111
- package/dist/src/tools/query-memory-data-tool.d.ts +2 -1
- package/dist/src/tools/query-memory-data-tool.js +109 -112
- package/dist/src/tools/query-todo-task-tool.d.ts +2 -1
- package/dist/src/tools/query-todo-task-tool.js +103 -106
- package/dist/src/tools/save-file-to-phone-tool.d.ts +2 -1
- package/dist/src/tools/save-file-to-phone-tool.js +127 -131
- package/dist/src/tools/save-media-to-gallery-tool.d.ts +2 -1
- package/dist/src/tools/save-media-to-gallery-tool.js +134 -138
- package/dist/src/tools/save-self-evolution-skill-tool.d.ts +2 -0
- package/dist/src/tools/save-self-evolution-skill-tool.js +410 -0
- package/dist/src/tools/search-alarm-tool.d.ts +2 -1
- package/dist/src/tools/search-alarm-tool.js +171 -175
- package/dist/src/tools/search-calendar-tool.d.ts +2 -1
- package/dist/src/tools/search-calendar-tool.js +145 -149
- package/dist/src/tools/search-contact-tool.d.ts +2 -1
- package/dist/src/tools/search-contact-tool.js +98 -102
- package/dist/src/tools/search-email-tool.d.ts +2 -1
- package/dist/src/tools/search-email-tool.js +107 -111
- package/dist/src/tools/search-file-tool.d.ts +2 -1
- package/dist/src/tools/search-file-tool.js +99 -103
- package/dist/src/tools/search-message-tool.d.ts +2 -1
- package/dist/src/tools/search-message-tool.js +100 -104
- package/dist/src/tools/search-note-tool.d.ts +2 -1
- package/dist/src/tools/search-note-tool.js +95 -99
- package/dist/src/tools/search-photo-gallery-tool.d.ts +2 -1
- package/dist/src/tools/search-photo-gallery-tool.js +34 -38
- package/dist/src/tools/send-email-tool.d.ts +2 -1
- package/dist/src/tools/send-email-tool.js +105 -108
- package/dist/src/tools/send-file-to-user-tool.d.ts +2 -1
- package/dist/src/tools/send-file-to-user-tool.js +154 -155
- package/dist/src/tools/send-message-tool.d.ts +2 -1
- package/dist/src/tools/send-message-tool.js +119 -123
- package/dist/src/tools/session-manager.d.ts +21 -6
- package/dist/src/tools/session-manager.js +147 -18
- package/dist/src/tools/upload-file-tool.d.ts +2 -1
- package/dist/src/tools/upload-file-tool.js +78 -82
- package/dist/src/tools/upload-photo-tool.d.ts +2 -1
- package/dist/src/tools/upload-photo-tool.js +69 -73
- package/dist/src/tools/xiaoyi-add-collection-tool.d.ts +2 -1
- package/dist/src/tools/xiaoyi-add-collection-tool.js +143 -147
- package/dist/src/tools/xiaoyi-collection-tool.d.ts +2 -1
- package/dist/src/tools/xiaoyi-collection-tool.js +111 -115
- package/dist/src/tools/xiaoyi-delete-collection-tool.d.ts +2 -1
- package/dist/src/tools/xiaoyi-delete-collection-tool.js +124 -128
- package/dist/src/tools/xiaoyi-gui-tool.d.ts +2 -1
- package/dist/src/tools/xiaoyi-gui-tool.js +84 -88
- package/dist/src/utils/logger.js +20 -18
- package/dist/src/utils/runtime-manager.js +24 -2
- package/dist/src/utils/self-evolution-manager.d.ts +10 -0
- package/dist/src/utils/self-evolution-manager.js +69 -0
- package/dist/src/utils/tool-call-nudge-manager.d.ts +16 -0
- package/dist/src/utils/tool-call-nudge-manager.js +47 -0
- package/dist/src/websocket.d.ts +3 -0
- package/dist/src/websocket.js +91 -26
- package/openclaw.plugin.json +22 -0
- package/package.json +3 -3
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { getXYWebSocketManager } from "../client.js";
|
|
2
2
|
import { sendCommand } from "../formatter.js";
|
|
3
|
-
import { getCurrentSessionContext } from "./session-manager.js";
|
|
4
3
|
/**
|
|
5
4
|
* XY upload file tool - uploads local files to get publicly accessible URLs.
|
|
6
5
|
* Requires file URIs from search_file tool as prerequisite.
|
|
@@ -13,10 +12,12 @@ import { getCurrentSessionContext } from "./session-manager.js";
|
|
|
13
12
|
* - After getting public URLs, if further processing is needed, download the file first
|
|
14
13
|
* - URLs returned are publicly accessible
|
|
15
14
|
*/
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
export function createUploadFileTool(ctx) {
|
|
16
|
+
const { config, sessionId, taskId, messageId } = ctx;
|
|
17
|
+
return {
|
|
18
|
+
name: "upload_file",
|
|
19
|
+
label: "Upload File",
|
|
20
|
+
description: `工具能力描述:将用户本地设备文件上传并获取可公网访问的 URL。
|
|
20
21
|
|
|
21
22
|
前置工具调用:此工具使用前必须先通过call_device_tool调用 search_file 或者 query_collection 工具获取文件的 uri
|
|
22
23
|
|
|
@@ -28,92 +29,87 @@ export const uploadFileTool = {
|
|
|
28
29
|
注意事项:
|
|
29
30
|
a. 操作超时时间为60秒,请勿重复调用此工具,如果超时或失败,最多重试一次。
|
|
30
31
|
b. 此工具返回的文件链接为用户公网可访问的链接,如果需要对文件进行额外的操作,需要先根据返回的url下载文件,然后进行下一步处理。`,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
parameters: {
|
|
33
|
+
type: "object",
|
|
34
|
+
properties: {
|
|
35
|
+
fileInfos: {
|
|
36
|
+
// 不指定 type,允许传入数组或 JSON 字符串
|
|
37
|
+
// 具体的类型验证和转换在 execute 函数内部进行
|
|
38
|
+
description: "文件信息数组,每个元素包含mediaUri(必需)和timeout(可选,默认20000)。必须先通过 search_file 工具获取。每次最多支持 5 条文件信息。",
|
|
39
|
+
},
|
|
38
40
|
},
|
|
41
|
+
required: ["fileInfos"],
|
|
39
42
|
},
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
43
|
+
async execute(toolCallId, params) {
|
|
44
|
+
// ===== 参数规范化:兼容数组和 JSON 字符串 =====
|
|
45
|
+
let fileInfos = null;
|
|
46
|
+
if (!params.fileInfos) {
|
|
47
|
+
throw new Error("Missing required parameter: fileInfos");
|
|
48
|
+
}
|
|
49
|
+
// 情况1: 已经是数组
|
|
50
|
+
if (Array.isArray(params.fileInfos)) {
|
|
51
|
+
fileInfos = params.fileInfos;
|
|
52
|
+
}
|
|
53
|
+
// 情况2: 是字符串,尝试解析为 JSON 数组
|
|
54
|
+
else if (typeof params.fileInfos === 'string') {
|
|
55
|
+
try {
|
|
56
|
+
const parsed = JSON.parse(params.fileInfos);
|
|
57
|
+
if (Array.isArray(parsed)) {
|
|
58
|
+
fileInfos = parsed;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
throw new Error("fileInfos must be an array or a JSON string representing an array");
|
|
62
|
+
}
|
|
58
63
|
}
|
|
59
|
-
|
|
60
|
-
throw new Error(
|
|
64
|
+
catch (parseError) {
|
|
65
|
+
throw new Error(`fileInfos must be a valid JSON array string. Parse error: ${parseError instanceof Error ? parseError.message : String(parseError)}`);
|
|
61
66
|
}
|
|
62
67
|
}
|
|
63
|
-
|
|
64
|
-
|
|
68
|
+
// 情况3: 其他类型,报错
|
|
69
|
+
else {
|
|
70
|
+
throw new Error(`fileInfos must be an array or a JSON string, got ${typeof params.fileInfos}`);
|
|
65
71
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
throw new Error(`fileInfos must be an array or a JSON string, got ${typeof params.fileInfos}`);
|
|
70
|
-
}
|
|
71
|
-
// 验证数组非空
|
|
72
|
-
if (!fileInfos || fileInfos.length === 0) {
|
|
73
|
-
throw new Error("fileInfos array cannot be empty");
|
|
74
|
-
}
|
|
75
|
-
// Validate maximum 5 file infos
|
|
76
|
-
if (fileInfos.length > 5) {
|
|
77
|
-
throw new Error(`最多支持 5 条文件信息,当前提供了 ${fileInfos.length} 条。请分批处理。`);
|
|
78
|
-
}
|
|
79
|
-
// Validate each fileInfo has required mediaUri field
|
|
80
|
-
for (let i = 0; i < fileInfos.length; i++) {
|
|
81
|
-
const fileInfo = fileInfos[i];
|
|
82
|
-
if (!fileInfo || typeof fileInfo !== 'object') {
|
|
83
|
-
throw new Error(`fileInfos[${i}] must be an object with mediaUri property`);
|
|
72
|
+
// 验证数组非空
|
|
73
|
+
if (!fileInfos || fileInfos.length === 0) {
|
|
74
|
+
throw new Error("fileInfos array cannot be empty");
|
|
84
75
|
}
|
|
85
|
-
|
|
86
|
-
|
|
76
|
+
// Validate maximum 5 file infos
|
|
77
|
+
if (fileInfos.length > 5) {
|
|
78
|
+
throw new Error(`最多支持 5 条文件信息,当前提供了 ${fileInfos.length} 条。请分批处理。`);
|
|
87
79
|
}
|
|
88
|
-
//
|
|
89
|
-
|
|
90
|
-
fileInfo
|
|
80
|
+
// Validate each fileInfo has required mediaUri field
|
|
81
|
+
for (let i = 0; i < fileInfos.length; i++) {
|
|
82
|
+
const fileInfo = fileInfos[i];
|
|
83
|
+
if (!fileInfo || typeof fileInfo !== 'object') {
|
|
84
|
+
throw new Error(`fileInfos[${i}] must be an object with mediaUri property`);
|
|
85
|
+
}
|
|
86
|
+
if (!fileInfo.mediaUri || typeof fileInfo.mediaUri !== 'string') {
|
|
87
|
+
throw new Error(`fileInfos[${i}] must have a valid mediaUri string property`);
|
|
88
|
+
}
|
|
89
|
+
// Set default timeout if not provided
|
|
90
|
+
if (!fileInfo.timeout) {
|
|
91
|
+
fileInfo.timeout = "20000";
|
|
92
|
+
}
|
|
91
93
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}),
|
|
112
|
-
},
|
|
113
|
-
],
|
|
114
|
-
};
|
|
115
|
-
},
|
|
116
|
-
};
|
|
94
|
+
// Get WebSocket manager
|
|
95
|
+
const wsManager = getXYWebSocketManager(config);
|
|
96
|
+
// Get public URLs for the files
|
|
97
|
+
const fileUrls = await getFileUrls(wsManager, config, sessionId, taskId, messageId, fileInfos);
|
|
98
|
+
return {
|
|
99
|
+
content: [
|
|
100
|
+
{
|
|
101
|
+
type: "text",
|
|
102
|
+
text: JSON.stringify({
|
|
103
|
+
fileUrls,
|
|
104
|
+
count: fileUrls.length,
|
|
105
|
+
message: `成功获取 ${fileUrls.length} 个文件的公网访问 URL`
|
|
106
|
+
}),
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
};
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
}
|
|
117
113
|
/**
|
|
118
114
|
* Get public URLs for files using fileInfos
|
|
119
115
|
* Returns array of publicly accessible file URLs
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SessionContext } from "./session-manager.js";
|
|
1
2
|
/**
|
|
2
3
|
* XY upload photo tool - uploads local photos to get publicly accessible URLs.
|
|
3
4
|
* Requires mediaUris from search_photo_gallery tool as prerequisite.
|
|
@@ -6,4 +7,4 @@
|
|
|
6
7
|
* 1. Call search_photo_gallery tool first to get mediaUris of photos
|
|
7
8
|
* 2. Use the mediaUris (maximum 5 at a time) to get public URLs
|
|
8
9
|
*/
|
|
9
|
-
export declare
|
|
10
|
+
export declare function createUploadPhotoTool(ctx: SessionContext): any;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { getXYWebSocketManager } from "../client.js";
|
|
2
2
|
import { sendCommand } from "../formatter.js";
|
|
3
|
-
import { getCurrentSessionContext } from "./session-manager.js";
|
|
4
3
|
/**
|
|
5
4
|
* XY upload photo tool - uploads local photos to get publicly accessible URLs.
|
|
6
5
|
* Requires mediaUris from search_photo_gallery tool as prerequisite.
|
|
@@ -9,92 +8,89 @@ import { getCurrentSessionContext } from "./session-manager.js";
|
|
|
9
8
|
* 1. Call search_photo_gallery tool first to get mediaUris of photos
|
|
10
9
|
* 2. Use the mediaUris (maximum 5 at a time) to get public URLs
|
|
11
10
|
*/
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
export function createUploadPhotoTool(ctx) {
|
|
12
|
+
const { config, sessionId, taskId, messageId } = ctx;
|
|
13
|
+
return {
|
|
14
|
+
name: "upload_photo",
|
|
15
|
+
label: "Upload Photo",
|
|
16
|
+
description: `工具能力描述:将用户本地设备文件回传并获取可公网访问的 URL。
|
|
17
|
+
|
|
17
18
|
前置工具调用:此工具使用前必须先通过call_device_tool工具调用 search_photo_gallery 工具获取照片的 mediaUri或者thumbnailUri
|
|
18
19
|
工具参数说明:
|
|
19
20
|
a. 入参中的mediaUris中的mediaUri必须与search_photo_gallery结果中对应的mediaUri或者thumbnailUri完全保持一致,不要自行修改,必须是file:://开头的路径。
|
|
20
21
|
b. 优先使用search_photo_gallery结果中的thumbnailUri作为入参,thumbnailUri是缩略图,清晰度与文件大小都非常合适展示给用户,如果thumbnailUri不存在或者用户要求使用原图,则使用search_photo_gallery结果中对应的mediaUri
|
|
21
22
|
c. mediaUris 是照片在手机本地的 URI 数组(从 search_photo_gallery 工具响应中获取)。限制:每次最多支持传入 3 条 mediaUri。
|
|
22
|
-
|
|
23
|
+
|
|
23
24
|
注意事项:
|
|
24
25
|
a. 操作超时时间为60秒,请勿重复调用此工具,如果超时或失败,最多重试一次。
|
|
25
26
|
b. 此工具返回的图片链接为用户公网可访问的链接,如果需要后续操作需要下载到本地,如果需要返回给用户查看则直接以图片markdown的形式返回给用户`,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
parameters: {
|
|
28
|
+
type: "object",
|
|
29
|
+
properties: {
|
|
30
|
+
mediaUris: {
|
|
31
|
+
// 不指定 type,允许传入数组或 JSON 字符串
|
|
32
|
+
// 具体的类型验证和转换在 execute 函数内部进行
|
|
33
|
+
description: "照片在手机本地的 URI 数组,必须先通过 search_photo_gallery 工具获取。每次最多支持 3 条 URI。",
|
|
34
|
+
},
|
|
33
35
|
},
|
|
36
|
+
required: ["mediaUris"],
|
|
34
37
|
},
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
38
|
+
async execute(toolCallId, params) {
|
|
39
|
+
// ===== 参数规范化:兼容数组和 JSON 字符串 =====
|
|
40
|
+
let mediaUris = null;
|
|
41
|
+
if (!params.mediaUris) {
|
|
42
|
+
throw new Error("Missing required parameter: mediaUris");
|
|
43
|
+
}
|
|
44
|
+
// 情况1: 已经是数组
|
|
45
|
+
if (Array.isArray(params.mediaUris)) {
|
|
46
|
+
mediaUris = params.mediaUris;
|
|
47
|
+
}
|
|
48
|
+
// 情况2: 是字符串,尝试解析为 JSON 数组
|
|
49
|
+
else if (typeof params.mediaUris === 'string') {
|
|
50
|
+
try {
|
|
51
|
+
const parsed = JSON.parse(params.mediaUris);
|
|
52
|
+
if (Array.isArray(parsed)) {
|
|
53
|
+
mediaUris = parsed;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
throw new Error("mediaUris must be an array or a JSON string representing an array");
|
|
57
|
+
}
|
|
53
58
|
}
|
|
54
|
-
|
|
55
|
-
throw new Error(
|
|
59
|
+
catch (parseError) {
|
|
60
|
+
throw new Error(`mediaUris must be a valid JSON array string. Parse error: ${parseError instanceof Error ? parseError.message : String(parseError)}`);
|
|
56
61
|
}
|
|
57
62
|
}
|
|
58
|
-
|
|
59
|
-
|
|
63
|
+
// 情况3: 其他类型,报错
|
|
64
|
+
else {
|
|
65
|
+
throw new Error(`mediaUris must be an array or a JSON string, got ${typeof params.mediaUris}`);
|
|
60
66
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
text: JSON.stringify({
|
|
89
|
-
imageUrls,
|
|
90
|
-
count: imageUrls.length,
|
|
91
|
-
message: `成功获取 ${imageUrls.length} 张照片的公网访问 URL`
|
|
92
|
-
}),
|
|
93
|
-
},
|
|
94
|
-
],
|
|
95
|
-
};
|
|
96
|
-
},
|
|
97
|
-
};
|
|
67
|
+
// 验证数组非空
|
|
68
|
+
if (!mediaUris || mediaUris.length === 0) {
|
|
69
|
+
throw new Error("mediaUris array cannot be empty");
|
|
70
|
+
}
|
|
71
|
+
// Validate maximum 5 URIs
|
|
72
|
+
if (mediaUris.length > 5) {
|
|
73
|
+
throw new Error(`最多支持 5 条 mediaUri,当前提供了 ${mediaUris.length} 条。请分批处理。`);
|
|
74
|
+
}
|
|
75
|
+
// Get WebSocket manager
|
|
76
|
+
const wsManager = getXYWebSocketManager(config);
|
|
77
|
+
// Get public URLs for the photos
|
|
78
|
+
const imageUrls = await getPhotoUrls(wsManager, config, sessionId, taskId, messageId, mediaUris);
|
|
79
|
+
return {
|
|
80
|
+
content: [
|
|
81
|
+
{
|
|
82
|
+
type: "text",
|
|
83
|
+
text: JSON.stringify({
|
|
84
|
+
imageUrls,
|
|
85
|
+
count: imageUrls.length,
|
|
86
|
+
message: `成功获取 ${imageUrls.length} 张照片的公网访问 URL`
|
|
87
|
+
}),
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
};
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
}
|
|
98
94
|
/**
|
|
99
95
|
* Get public URLs for photos using mediaUris
|
|
100
96
|
* Returns array of publicly accessible image URLs
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import type { SessionContext } from "./session-manager.js";
|
|
1
2
|
/**
|
|
2
3
|
* XY add collection tool - adds data to user's XiaoYi collection.
|
|
3
4
|
*/
|
|
4
|
-
export declare
|
|
5
|
+
export declare function createXiaoyiAddCollectionTool(ctx: SessionContext): any;
|