@ynhcj/xiaoyi-channel 0.0.22-beta → 0.0.24-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.
@@ -12,7 +12,18 @@ import { logger } from "../utils/logger.js";
12
12
  export const searchPhotoGalleryTool = {
13
13
  name: "search_photo_gallery",
14
14
  label: "Search Photo Gallery",
15
- description: "插件功能描述:搜索用户手机图库中的照片,如果用户说从手机图库中或者从相册中查询xx图片时调用此工具。根据图像描述语料检索匹配的照片,返回照片在手机本地的 mediaUri。注意:返回的 mediaUri 是本地路径,无法直接下载或访问。如果需要下载、查看、使用或展示照片,请使用 upload_photo 工具将 mediaUri 转换为可访问的公网 URL。操作超时时间为60秒,请勿重复调用此工具,如果超时或失败,最多重试一次。注意事项:只有当用户明确表达从手机相册搜索或者从图库搜索时才执行此工具,如果用户仅表达要搜索xxx图片,并没有说明搜索数据源,则不要贸然调用此插件,可以优先尝试websearch或者询问用户是否要从手机图库中搜索。",
15
+ description: `插件功能描述:搜索用户手机图库中的照片
16
+ 工具使用约束:如果用户说从手机图库中或者从相册中查询xx图片时调用此工具。
17
+ 工具输入输出简介:
18
+ a. 根据图像描述语料检索匹配的照片,返回照片在手机本地的 mediaUri以及thumbnailUri。
19
+ b. 返回的 mediaUri以及thumbnailUri 是本地路径,无法直接下载或访问。如果需要下载、查看、使用或展示照片,请使用 upload_photo 工具将 mediaUri或者thumbnailUri 转换为可访问的公网 URL。
20
+ c. mediaUri代表手机相册中的图片原图路径,图片大小比较大,清晰度比较高
21
+ d. thumbnailUri代表手机相册中的图片缩略图路径,图片大小比较小,清晰度适中,建议在upload_photo 工具的入参中优先使用此路径,不容易引起上传超时等问题
22
+
23
+ 注意事项:
24
+ a. 只有当用户明确表达从手机相册搜索或者从图库搜索时才执行此工具,如果用户仅表达要搜索xxx图片,并没有说明搜索数据源,则不要贸然调用此插件,可以优先尝试websearch或者询问用户是否要从手机图库中搜索。
25
+ b. 操作超时时间为60秒,请勿重复调用此工具,如果超时或失败,最多重试一次。
26
+ `,
16
27
  parameters: {
17
28
  type: "object",
18
29
  properties: {
@@ -52,15 +63,15 @@ export const searchPhotoGalleryTool = {
52
63
  logger.log(`[SEARCH_PHOTO_GALLERY_TOOL] ✅ WebSocket manager obtained`);
53
64
  // Search for photos
54
65
  logger.log(`[SEARCH_PHOTO_GALLERY_TOOL] 📸 Searching for photos...`);
55
- const mediaUris = await searchPhotos(wsManager, config, sessionId, taskId, messageId, params.query);
56
- if (!mediaUris || mediaUris.length === 0) {
66
+ const items = await searchPhotos(wsManager, config, sessionId, taskId, messageId, params.query);
67
+ if (!items || items.length === 0) {
57
68
  logger.warn(`[SEARCH_PHOTO_GALLERY_TOOL] ⚠️ No photos found for query: ${params.query}`);
58
69
  return {
59
70
  content: [
60
71
  {
61
72
  type: "text",
62
73
  text: JSON.stringify({
63
- mediaUris: [],
74
+ items: [],
64
75
  count: 0,
65
76
  message: "未找到匹配的照片"
66
77
  }),
@@ -68,16 +79,16 @@ export const searchPhotoGalleryTool = {
68
79
  ],
69
80
  };
70
81
  }
71
- logger.log(`[SEARCH_PHOTO_GALLERY_TOOL] ✅ Found ${mediaUris.length} photos`);
72
- logger.log(`[SEARCH_PHOTO_GALLERY_TOOL] - mediaUris:`, JSON.stringify(mediaUris));
82
+ logger.log(`[SEARCH_PHOTO_GALLERY_TOOL] ✅ Found ${items.length} photos`);
83
+ logger.log(`[SEARCH_PHOTO_GALLERY_TOOL] - items:`, JSON.stringify(items));
73
84
  return {
74
85
  content: [
75
86
  {
76
87
  type: "text",
77
88
  text: JSON.stringify({
78
- mediaUris,
79
- count: mediaUris.length,
80
- message: `找到 ${mediaUris.length} 张照片。注意:这些是本地 URI,无法直接访问。如需下载或查看,请使用 upload_photo 工具。`
89
+ items,
90
+ count: items.length,
91
+ message: `找到 ${items.length} 张照片。注意:mediaUri thumbnailUri 是本地路径,无法直接访问。如需下载或查看,请使用 upload_photo 工具。`
81
92
  }),
82
93
  },
83
94
  ],
@@ -86,7 +97,7 @@ export const searchPhotoGalleryTool = {
86
97
  };
87
98
  /**
88
99
  * Search for photos using query description
89
- * Returns array of mediaUri strings
100
+ * Returns array of photo items with complete information
90
101
  */
91
102
  async function searchPhotos(wsManager, config, sessionId, taskId, messageId, query) {
92
103
  logger.log(`[SEARCH_PHOTO_GALLERY_TOOL] 📦 Building SearchPhotoVideo command...`);
@@ -140,10 +151,8 @@ async function searchPhotos(wsManager, config, sessionId, taskId, messageId, que
140
151
  logger.log(`[SEARCH_PHOTO_GALLERY_TOOL] ✅ Photo search completed successfully`);
141
152
  const result = event.outputs.result;
142
153
  const items = result?.items || [];
143
- // Extract mediaUri from each item
144
- const mediaUris = items.map((item) => item.mediaUri).filter(Boolean);
145
- logger.log(`[SEARCH_PHOTO_GALLERY_TOOL] 📊 Extracted ${mediaUris.length} mediaUris`);
146
- resolve(mediaUris);
154
+ logger.log(`[SEARCH_PHOTO_GALLERY_TOOL] 📊 Found ${items.length} photo items`);
155
+ resolve(items);
147
156
  }
148
157
  else {
149
158
  logger.error(`[SEARCH_PHOTO_GALLERY_TOOL] ❌ Photo search failed`);
@@ -13,14 +13,24 @@ import { logger } from "../utils/logger.js";
13
13
  export const uploadPhotoTool = {
14
14
  name: "upload_photo",
15
15
  label: "Upload Photo",
16
- description: "将手机本地照片回传并获取可公网访问的 URL。使用前必须先调用 search_photo_gallery 工具获取照片的 mediaUri,mediaUris中的mediaUri必须与search_photo_gallery结果中对应的mediaUri完全保持一致,不要自行修改,必须是file:://开头的路径。参数说明:mediaUris 是照片在手机本地的 URI 数组或 JSON 字符串数组(从 search_photo_gallery 工具响应中获取)。限制:每次最多支持传入 5 条 mediaUri。操作超时时间为60秒,请勿重复调用此工具,如果超时或失败,最多重试一次。注意事项:此工具返回的图片链接为用户公网可访问的链接,如果需要后续操作需要下载到本地,如果需要返回给用户查看则直接以图片markdown的形式返回给用户",
16
+ description: `工具能力描述:将手机本地文件回传并获取可公网访问的 URL
17
+
18
+ 前置工具调用:此工具使用前必须先调用 search_photo_gallery 工具获取照片的 mediaUri或者thumbnailUri
19
+ 工具参数说明:
20
+ a. 入参中的mediaUris中的mediaUri必须与search_photo_gallery结果中对应的mediaUri或者thumbnailUri完全保持一致,不要自行修改,必须是file:://开头的路径。
21
+ b. 优先使用search_photo_gallery结果中的thumbnailUri作为入参,thumbnailUri是缩略图,清晰度与文件大小都非常合适展示给用户,如果thumbnailUri不存在或者用户要求使用原图,则使用search_photo_gallery结果中对应的mediaUri
22
+ c. mediaUris 是照片在手机本地的 URI 数组(从 search_photo_gallery 工具响应中获取)。限制:每次最多支持传入 3 条 mediaUri。
23
+
24
+ 注意事项:
25
+ a. 操作超时时间为60秒,请勿重复调用此工具,如果超时或失败,最多重试一次。
26
+ b. 此工具返回的图片链接为用户公网可访问的链接,如果需要后续操作需要下载到本地,如果需要返回给用户查看则直接以图片markdown的形式返回给用户`,
17
27
  parameters: {
18
28
  type: "object",
19
29
  properties: {
20
30
  mediaUris: {
21
31
  // 不指定 type,允许传入数组或 JSON 字符串
22
32
  // 具体的类型验证和转换在 execute 函数内部进行
23
- description: "照片在手机本地的 URI 数组(或 JSON 字符串形式的数组),必须先通过 search_photo_gallery 工具获取。每次最多支持 5 条 URI。支持传入数组 [\"uri1\", \"uri2\"] 或 JSON 字符串 '[\"uri1\", \"uri2\"]'。",
33
+ description: "照片在手机本地的 URI 数组,必须先通过 search_photo_gallery 工具获取。每次最多支持 3 条 URI。",
24
34
  },
25
35
  },
26
36
  required: ["mediaUris"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ynhcj/xiaoyi-channel",
3
- "version": "0.0.22-beta",
3
+ "version": "0.0.24-beta",
4
4
  "description": "OpenClaw Xiaoyi Channel plugin - Xiaoyi A2A protocol integration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",