@ynhcj/xiaoyi-channel 0.0.154-beta → 0.0.154-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.
Files changed (76) hide show
  1. package/dist/src/bot.js +13 -5
  2. package/dist/src/cron-command.d.ts +4 -5
  3. package/dist/src/cron-command.js +19 -34
  4. package/dist/src/cron-query-handler.d.ts +7 -0
  5. package/dist/src/cron-query-handler.js +188 -0
  6. package/dist/src/cspl/call_api.d.ts +1 -1
  7. package/dist/src/cspl/call_api.js +2 -2
  8. package/dist/src/cspl/config.js +30 -10
  9. package/dist/src/cspl/constants.d.ts +3 -0
  10. package/dist/src/cspl/constants.js +5 -0
  11. package/dist/src/cspl/sentinel_hook.js +26 -7
  12. package/dist/src/cspl/utils.d.ts +9 -3
  13. package/dist/src/cspl/utils.js +17 -11
  14. package/dist/src/file-upload.d.ts +5 -0
  15. package/dist/src/file-upload.js +101 -0
  16. package/dist/src/formatter.d.ts +32 -0
  17. package/dist/src/formatter.js +62 -6
  18. package/dist/src/monitor.js +44 -23
  19. package/dist/src/parser.d.ts +6 -0
  20. package/dist/src/parser.js +47 -1
  21. package/dist/src/provider.js +25 -17
  22. package/dist/src/push.d.ts +11 -1
  23. package/dist/src/push.js +93 -2
  24. package/dist/src/reply-dispatcher.js +51 -19
  25. package/dist/src/self-evolution-handler.d.ts +1 -1
  26. package/dist/src/self-evolution-handler.js +13 -2
  27. package/dist/src/tools/agent-as-skill-tool.js +55 -4
  28. package/dist/src/tools/calendar-tool.js +1 -1
  29. package/dist/src/tools/call-device-tool.js +0 -3
  30. package/dist/src/tools/call-phone-tool.js +1 -1
  31. package/dist/src/tools/check-plugin-privilege-tool.d.ts +6 -0
  32. package/dist/src/tools/check-plugin-privilege-tool.js +182 -0
  33. package/dist/src/tools/create-alarm-tool.js +1 -1
  34. package/dist/src/tools/create-all-tools.js +8 -4
  35. package/dist/src/tools/delete-alarm-tool.js +1 -1
  36. package/dist/src/tools/device-tool-map.js +1 -0
  37. package/dist/src/tools/discover-cross-devices-tool.js +1 -1
  38. package/dist/src/tools/display-a2ui-card-tool.d.ts +2 -0
  39. package/dist/src/tools/display-a2ui-card-tool.js +85 -0
  40. package/dist/src/tools/get-collection-tool-schema.js +1 -1
  41. package/dist/src/tools/get-device-file-tool-schema.js +2 -3
  42. package/dist/src/tools/location-tool.js +1 -1
  43. package/dist/src/tools/modify-alarm-tool.js +1 -1
  44. package/dist/src/tools/modify-note-tool.js +1 -1
  45. package/dist/src/tools/note-tool.js +1 -1
  46. package/dist/src/tools/query-app-message-tool.js +1 -1
  47. package/dist/src/tools/query-memory-data-tool.js +1 -1
  48. package/dist/src/tools/query-todo-task-tool.js +1 -1
  49. package/dist/src/tools/save-file-to-phone-tool.js +1 -1
  50. package/dist/src/tools/save-media-to-gallery-tool.js +1 -1
  51. package/dist/src/tools/schema-tool-factory.js +1 -1
  52. package/dist/src/tools/search-alarm-tool.js +1 -1
  53. package/dist/src/tools/search-calendar-tool.js +1 -1
  54. package/dist/src/tools/search-contact-tool.js +1 -1
  55. package/dist/src/tools/search-email-tool.js +1 -1
  56. package/dist/src/tools/search-file-tool.js +5 -10
  57. package/dist/src/tools/search-note-tool.js +1 -1
  58. package/dist/src/tools/search-photo-gallery-tool.js +1 -1
  59. package/dist/src/tools/send-cross-device-task-tool.js +18 -22
  60. package/dist/src/tools/send-email-tool.js +1 -1
  61. package/dist/src/tools/send-file-to-user-tool.d.ts +1 -1
  62. package/dist/src/tools/send-file-to-user-tool.js +35 -6
  63. package/dist/src/tools/send-html-card-tool.d.ts +7 -0
  64. package/dist/src/tools/send-html-card-tool.js +113 -0
  65. package/dist/src/tools/session-manager.d.ts +6 -2
  66. package/dist/src/tools/session-manager.js +42 -7
  67. package/dist/src/tools/upload-file-tool.d.ts +1 -1
  68. package/dist/src/tools/upload-file-tool.js +3 -17
  69. package/dist/src/tools/upload-photo-tool.js +1 -1
  70. package/dist/src/tools/xiaoyi-add-collection-tool.js +3 -2
  71. package/dist/src/tools/xiaoyi-collection-tool.js +2 -2
  72. package/dist/src/tools/xiaoyi-delete-collection-tool.js +2 -2
  73. package/dist/src/tools/xiaoyi-gui-tool.js +5 -0
  74. package/dist/src/types.d.ts +10 -3
  75. package/dist/src/websocket.js +44 -5
  76. package/package.json +1 -2
@@ -0,0 +1,182 @@
1
+ // Check plugin privilege tool implementation
2
+ import { getXYWebSocketManager } from "../client.js";
3
+ import { sendCommand } from "../formatter.js";
4
+ import { getCurrentTaskId } from "../task-manager.js";
5
+ import { logger } from "../utils/logger.js";
6
+ /**
7
+ * Mapping from intent name to required permission IDs.
8
+ */
9
+ const INTENT_PERMISSION_MAP = {
10
+ GetCurrentLocation: ["ohos.permission.LOCATION", "ohos.permission.APPROXIMATELY_LOCATION"],
11
+ SearchCalendarEvent: ["ohos.permission.READ_WHOLE_CALENDAR"],
12
+ CreateCalendarEvent: ["ohos.permission.WRITE_WHOLE_CALENDAR"],
13
+ DeleteCalendarEvent: ["ohos.permission.WRITE_WHOLE_CALENDAR"],
14
+ ModifyCalendarEvent: ["ohos.permission.WRITE_WHOLE_CALENDAR"],
15
+ SearchNote: ["ohos.permission.READ_NOTE"],
16
+ CreateNote: ["ohos.permission.WRITE_NOTE"],
17
+ ModifyNote: ["ohos.permission.WRITE_NOTE"],
18
+ SearchContactLocal: ["ohos.permission.READ_CONTACTS"],
19
+ SearchPhotoVideo: ["ohos.permission.READ_IMAGEVIDEO"],
20
+ SaveMediaToGallery: ["ohos.permission.WRITE_IMAGEVIDEO"],
21
+ SearchFile: ["ohos.permission.FILE_ACCESS_MANAGER"],
22
+ SaveFileToFileManager: ["ohos.permission.FILE_SAVE_MANAGER"],
23
+ SearchAlarm: ["ohos.permission.READ_ALARM"],
24
+ CreateAlarm: ["ohos.permission.WRITE_ALARM"],
25
+ ModifyAlarm: ["ohos.permission.WRITE_ALARM"],
26
+ DeleteAlarm: ["ohos.permission.WRITE_ALARM"],
27
+ SearchMessage: ["ohos.permission.READ_SMS"],
28
+ SendShortMessage: ["ohos.permission.SEND_MESSAGES"],
29
+ StartCall: ["ohos.permission.PLACE_CALL"],
30
+ };
31
+ /**
32
+ * XY check plugin privilege tool - checks user authorization for device-side tools
33
+ * used in scheduled tasks.
34
+ */
35
+ export function createCheckPluginPrivilegeTool(ctx) {
36
+ const { config, sessionId, taskId, messageId } = ctx;
37
+ return {
38
+ name: "check_plugin_privilege",
39
+ label: "Check Plugin Privilege",
40
+ description: "定时任务权限检查工具。" +
41
+ "【使用场景】仅在创建定时任务时使用,严禁在其他场景调用。当识别到定时任务中需要使用用户设备侧工具时,必须调用此工具进行权限检查。" +
42
+ "【调用前提】调用此工具前,必须确认用户定时任务中提到的工具在当前模型可使用的工具列表中存在。如果当前工具列表中不存在符合用户诉求的工具定义,则不要调用此工具,而是直接告知用户当前设备不支持该功能。" +
43
+ "【支持的意图名称及对应权限】" +
44
+ "GetCurrentLocation(获取用户位置), " +
45
+ "SearchCalendarEvent(搜索用户日程), " +
46
+ "CreateCalendarEvent(新建用户日程), " +
47
+ "DeleteCalendarEvent(删除用户日程), " +
48
+ "ModifyCalendarEvent(修改用户日程), " +
49
+ "SearchNote(搜索用户备忘录), " +
50
+ "CreateNote(新建用户备忘录), " +
51
+ "ModifyNote(修改用户备忘录), " +
52
+ "SearchContactLocal(搜索用户联系人), " +
53
+ "SearchPhotoVideo(搜索用户图库照片或视频), " +
54
+ "SaveMediaToGallery(保存图片/视频到图库), " +
55
+ "SearchFile(搜索用户文件管理里面的文件), " +
56
+ "SaveFileToFileManager(保存文件到文件管理), " +
57
+ "SearchAlarm(搜索闹钟), " +
58
+ "CreateAlarm(新建闹钟), " +
59
+ "ModifyAlarm(修改闹钟), " +
60
+ "DeleteAlarm(删除闹钟), " +
61
+ "SearchMessage(搜索短信), " +
62
+ "SendShortMessage(发送短信), " +
63
+ "StartCall(打电话)。" +
64
+ "【多次调用】如果用户的定时任务指令中涉及多个端侧工具,则依次分别调用此工具检查每个工具的权限。如果调用超时失败,最多重试一次。" +
65
+ "【回复约束】如果工具返回没有授权或其他报错,只需要完整描述没有授权或其他报错内容即可,不需要主动给用户提供解决方案。" +
66
+ "【使用约束1】只要是创建定时任务且涉及端插件的使用,则必须调用此工具检查权限" +
67
+ "【使用约束2】如果是定时任务执行过程中,禁止调用此工具,此工具仅在创建定时任务时按需调用",
68
+ parameters: {
69
+ type: "object",
70
+ properties: {
71
+ checkIntentName: {
72
+ type: "string",
73
+ description: "需要检查权限的意图名称,必须是支持的意图名称之一,例如:GetCurrentLocation、SearchCalendarEvent、CreateCalendarEvent 等。",
74
+ },
75
+ },
76
+ required: ["checkIntentName"],
77
+ },
78
+ async execute(toolCallId, params) {
79
+ const { checkIntentName } = params;
80
+ // Look up permission IDs for the given intent name
81
+ const permissionId = INTENT_PERMISSION_MAP[checkIntentName];
82
+ if (!permissionId) {
83
+ return {
84
+ content: [
85
+ {
86
+ type: "text",
87
+ text: `不支持的工具意图名称: ${checkIntentName}。请确认该意图名称在支持列表中。`,
88
+ },
89
+ ],
90
+ };
91
+ }
92
+ // Get WebSocket manager
93
+ const wsManager = getXYWebSocketManager(config);
94
+ // Build CheckPlugInPrivilege command
95
+ const command = {
96
+ header: {
97
+ namespace: "Common",
98
+ name: "Action",
99
+ },
100
+ payload: {
101
+ cardParam: {},
102
+ executeParam: {
103
+ achieveType: "INTENT",
104
+ actionResponse: true,
105
+ bundleName: "com.huawei.hmos.vassistant",
106
+ dimension: "",
107
+ executeMode: "background",
108
+ intentName: "CheckPlugInPrivilege",
109
+ intentParam: {
110
+ checkIntentName: "CheckPluginPrivilege",
111
+ permissionId,
112
+ },
113
+ needUnlock: false,
114
+ permissionId: [],
115
+ timeOut: 5,
116
+ },
117
+ needUploadResult: true,
118
+ pageControlRelated: false,
119
+ responses: [
120
+ {
121
+ displayText: "",
122
+ resultCode: "",
123
+ ttsText: "",
124
+ },
125
+ ],
126
+ },
127
+ };
128
+ // Send command and wait for response (60 second timeout)
129
+ return new Promise((resolve, reject) => {
130
+ const timeout = setTimeout(() => {
131
+ wsManager.off("data-event", handler);
132
+ logger.error("超时: 检查插件权限超时(60秒)", { toolCallId, checkIntentName });
133
+ reject(new Error(`检查插件权限超时(60秒), intentName: ${checkIntentName}`));
134
+ }, 60000);
135
+ // Listen for data events from WebSocket
136
+ const handler = (event) => {
137
+ if (event.intentName === "CheckPlugInPrivilege") {
138
+ clearTimeout(timeout);
139
+ wsManager.off("data-event", handler);
140
+ if (event.status === "success" && event.outputs) {
141
+ resolve({
142
+ content: [
143
+ {
144
+ type: "text",
145
+ text: JSON.stringify(event.outputs),
146
+ },
147
+ ],
148
+ });
149
+ }
150
+ else {
151
+ resolve({
152
+ content: [
153
+ {
154
+ type: "text",
155
+ text: JSON.stringify(event.outputs),
156
+ },
157
+ ],
158
+ });
159
+ }
160
+ }
161
+ };
162
+ // Register event handler
163
+ wsManager.on("data-event", handler);
164
+ // Send the command
165
+ const currentTaskId = getCurrentTaskId(sessionId) ?? taskId;
166
+ sendCommand({
167
+ config,
168
+ sessionId,
169
+ taskId: currentTaskId,
170
+ messageId,
171
+ command,
172
+ toolCallId,
173
+ }).then(() => {
174
+ }).catch((error) => {
175
+ clearTimeout(timeout);
176
+ wsManager.off("data-event", handler);
177
+ reject(error);
178
+ });
179
+ });
180
+ },
181
+ };
182
+ }
@@ -244,7 +244,7 @@ b. 使用该工具之前需获取当前真实时间
244
244
  });
245
245
  }
246
246
  else {
247
- reject(new Error(`创建闹钟失败: ${event.status}`));
247
+ reject(new Error(`创建闹钟失败: ${JSON.stringify(event.outputs)}`));
248
248
  }
249
249
  }
250
250
  };
@@ -1,6 +1,7 @@
1
1
  import { createLocationTool } from "./location-tool.js";
2
2
  import { createXiaoyiGuiTool } from "./xiaoyi-gui-tool.js";
3
3
  import { createSendFileToUserTool } from "./send-file-to-user-tool.js";
4
+ import { createSendHtmlCardTool } from "./send-html-card-tool.js";
4
5
  import { viewPushResultTool } from "./view-push-result-tool.js";
5
6
  import { createImageReadingTool } from "./image-reading-tool.js";
6
7
  import { timestampToUtc8Tool } from "./timestamp-to-utc8-tool.js";
@@ -13,12 +14,13 @@ import { createGetPhotoToolSchemaTool } from "./get-photo-tool-schema.js";
13
14
  import { createGetDeviceFileToolSchemaTool } from "./get-device-file-tool-schema.js";
14
15
  import { createGetAlarmToolSchemaTool } from "./get-alarm-tool-schema.js";
15
16
  import { createGetCollectionToolSchemaTool } from "./get-collection-tool-schema.js";
16
- import { createGetEmailToolSchemaTool } from "./get-email-tool-schema.js";
17
+ // import { createGetEmailToolSchemaTool } from "./get-email-tool-schema.js";
17
18
  import { createLoginTokenTool } from "./login-token-tool.js";
18
19
  import { createAgentAsSkillTool } from "./agent-as-skill-tool.js";
19
- import { createFindPcDevicesTool } from "./find-pc-devices-tool.js";
20
20
  import { createDiscoverCrossDevicesTool } from "./discover-cross-devices-tool.js";
21
21
  import { createSendCrossDeviceTaskTool } from "./send-cross-device-task-tool.js";
22
+ import { createDisplayA2UICardTool } from "./display-a2ui-card-tool.js";
23
+ import { createCheckPluginPrivilegeTool } from "./check-plugin-privilege-tool.js";
22
24
  import { logger } from "../utils/logger.js";
23
25
  /**
24
26
  * Create all XY channel tools for the given session context.
@@ -36,6 +38,7 @@ export function createAllTools(ctx) {
36
38
  createLocationTool(ctx),
37
39
  createDiscoverCrossDevicesTool(ctx),
38
40
  createSendCrossDeviceTaskTool(ctx),
41
+ createDisplayA2UICardTool(ctx),
39
42
  createCallDeviceTool(ctx),
40
43
  createGetNoteToolSchemaTool(ctx),
41
44
  createGetCalendarToolSchemaTool(ctx),
@@ -46,13 +49,14 @@ export function createAllTools(ctx) {
46
49
  createGetAlarmToolSchemaTool(ctx),
47
50
  createGetCollectionToolSchemaTool(ctx),
48
51
  createSendFileToUserTool(ctx),
49
- createGetEmailToolSchemaTool(ctx),
52
+ createSendHtmlCardTool(ctx),
53
+ // createGetEmailToolSchemaTool(ctx),
50
54
  viewPushResultTool,
51
55
  createImageReadingTool(ctx),
52
56
  timestampToUtc8Tool,
53
57
  createSaveSelfEvolutionSkillTool(ctx),
54
58
  createLoginTokenTool(ctx),
55
59
  createAgentAsSkillTool(ctx),
56
- createFindPcDevicesTool(ctx),
60
+ createCheckPluginPrivilegeTool(ctx),
57
61
  ];
58
62
  }
@@ -143,7 +143,7 @@ export function createDeleteAlarmTool(ctx) {
143
143
  });
144
144
  }
145
145
  else {
146
- reject(new Error(`删除闹钟失败: ${event.status}`));
146
+ reject(new Error(`删除闹钟失败: ${JSON.stringify(event.outputs)}`));
147
147
  }
148
148
  }
149
149
  };
@@ -25,6 +25,7 @@ const DEVICE_TOOL_POLICY = {
25
25
  "image_reading",
26
26
  "convert_time_to_utc8_time",
27
27
  "save_self_evolution_skill",
28
+ "displayA2UICard",
28
29
  ],
29
30
  },
30
31
  };
@@ -106,7 +106,7 @@ export function createDiscoverCrossDevicesTool(ctx) {
106
106
 
107
107
  当用户明确表达要从另一台设备获取、查找、使用或操作内容时,必须优先调用本工具,例如从 PC、电脑、平板、手机等设备获取文件或查找内容。
108
108
 
109
- 本工具只做设备发现和目标设备推荐,不会读取副设备文件内容,不会上传文件,也不会真正下发跨端执行任务。`,
109
+ 本工具只做设备发现和目标设备推荐,不会读取副设备文件内容,不会上传文件,也不会真正下发跨端执行任务。下发跨端执行任务需要使用SendCrossDeviceTaskTool`,
110
110
  parameters: {
111
111
  type: "object",
112
112
  properties: {
@@ -0,0 +1,2 @@
1
+ import type { SessionContext } from "./session-manager.js";
2
+ export declare function createDisplayA2UICardTool(ctx: SessionContext): any;
@@ -0,0 +1,85 @@
1
+ import { sendCommand } from "../formatter.js";
2
+ import { getCurrentMessageId, getCurrentTaskId } from "../task-manager.js";
3
+ import { logger } from "../utils/logger.js";
4
+ class ToolInputError extends Error {
5
+ status = 400;
6
+ constructor(message) {
7
+ super(message);
8
+ this.name = "ToolInputError";
9
+ }
10
+ }
11
+ function isJsonObjectOrArray(value) {
12
+ return !!value && typeof value === "object";
13
+ }
14
+ export function createDisplayA2UICardTool(ctx) {
15
+ const { config, sessionId, taskId, messageId } = ctx;
16
+ return {
17
+ name: "displayA2UICard",
18
+ label: "Display A2UI Card",
19
+ description: "当模型根据 MCP 工具返回结果判断需要向端侧下发 A2UI card 时调用。参数 cardId 和 cardData 由模型根据 MCP 工具返回结果传入,本工具只负责下发卡片展示指令。",
20
+ parameters: {
21
+ type: "object",
22
+ properties: {
23
+ cardId: {
24
+ type: "string",
25
+ description: "A2UI card 的唯一标识。",
26
+ },
27
+ cardData: {
28
+ oneOf: [
29
+ { type: "object" },
30
+ { type: "array" },
31
+ ],
32
+ description: "A2UI card 渲染所需的 JSON 对象或 JSON 数组,由模型根据 MCP 工具返回结果填充。",
33
+ },
34
+ },
35
+ required: ["cardId", "cardData"],
36
+ },
37
+ async execute(toolCallId, params) {
38
+ const cardId = typeof params?.cardId === "string" ? params.cardId.trim() : "";
39
+ const cardData = params?.cardData;
40
+ if (!cardId) {
41
+ throw new ToolInputError("缺少必填参数: cardId");
42
+ }
43
+ if (!isJsonObjectOrArray(cardData)) {
44
+ throw new ToolInputError("缺少必填参数: cardData,且必须是 JSON 对象或 JSON 数组");
45
+ }
46
+ const currentTaskId = getCurrentTaskId(sessionId) ?? taskId;
47
+ const currentMessageId = getCurrentMessageId(sessionId) ?? messageId;
48
+ const command = {
49
+ header: {
50
+ namespace: "Common",
51
+ name: "DisplayFACard",
52
+ },
53
+ payload: {
54
+ isA2ui: true,
55
+ a2uiParam: {
56
+ cardId,
57
+ cardData,
58
+ },
59
+ },
60
+ };
61
+ logger.log(`[DISPLAY-A2UI-CARD] sending card, cardId=${cardId}`);
62
+ await sendCommand({
63
+ config,
64
+ sessionId,
65
+ taskId: currentTaskId,
66
+ messageId: currentMessageId,
67
+ command,
68
+ toolCallId,
69
+ });
70
+ logger.log(`[DISPLAY-A2UI-CARD] card sent successfully, cardId=${cardId}`);
71
+ return {
72
+ content: [
73
+ {
74
+ type: "text",
75
+ text: JSON.stringify({
76
+ success: true,
77
+ cardId,
78
+ message: "A2UI card display command sent successfully.",
79
+ }),
80
+ },
81
+ ],
82
+ };
83
+ },
84
+ };
85
+ }
@@ -6,7 +6,7 @@ export function createGetCollectionToolSchemaTool(ctx) {
6
6
  return createSchemaTool({
7
7
  name: "get_collection_tool_schema",
8
8
  label: "Get Collection Tool Schema",
9
- description: "获取可在用户设备上添加、检索、删除小艺收藏中的公共知识数据的相关端工具列表。",
9
+ description: "获取可在用户设备上添加、检索、删除小艺收藏(也叫小艺帮记)中的公共知识数据的相关端工具列表。",
10
10
  tools: [createXiaoyiAddCollectionTool(ctx), createXiaoyiCollectionTool(ctx), createXiaoyiDeleteCollectionTool(ctx)],
11
11
  });
12
12
  }
@@ -2,14 +2,13 @@ import { createSchemaTool } from "./schema-tool-factory.js";
2
2
  import { createSearchFileTool } from "./search-file-tool.js";
3
3
  import { createUploadFileTool } from "./upload-file-tool.js";
4
4
  import { createSaveFileToPhoneTool } from "./save-file-to-phone-tool.js";
5
- import { createFindPcDevicesTool } from "./find-pc-devices-tool.js";
6
5
  export function createGetDeviceFileToolSchemaTool(ctx) {
7
6
  const searchFileTool = createSearchFileTool(ctx);
8
7
  const saveFileToPhoneTool = createSaveFileToPhoneTool(ctx);
9
8
  return createSchemaTool({
10
9
  name: "get_device_file_tool_schema",
11
10
  label: "Get Device File Tool Schema",
12
- description: "获取可在用户设备上搜索文件系统的文件、将用户设备本地文件上传到公网并获取链接、保存文件到文件管理器、查找PC设备的相关端工具列表。",
13
- tools: [searchFileTool, createUploadFileTool(ctx), saveFileToPhoneTool, createFindPcDevicesTool(ctx)],
11
+ description: "获取可在用户设备上搜索文件系统的文件、将用户设备本地文件上传到公网并获取链接、保存文件到文件管理器的相关端工具列表。",
12
+ tools: [searchFileTool, createUploadFileTool(ctx), saveFileToPhoneTool],
14
13
  });
15
14
  }
@@ -75,7 +75,7 @@ export function createLocationTool(ctx) {
75
75
  });
76
76
  }
77
77
  else {
78
- reject(new Error(`获取位置失败: ${event.status}`));
78
+ reject(new Error(`获取位置失败: ${JSON.stringify(event.outputs)}`));
79
79
  }
80
80
  }
81
81
  };
@@ -256,7 +256,7 @@ export function createModifyAlarmTool(ctx) {
256
256
  });
257
257
  }
258
258
  else {
259
- reject(new Error(`修改闹钟失败: ${event.status}`));
259
+ reject(new Error(`修改闹钟失败: ${JSON.stringify(event.outputs)}`));
260
260
  }
261
261
  }
262
262
  };
@@ -97,7 +97,7 @@ export function createModifyNoteTool(ctx) {
97
97
  });
98
98
  }
99
99
  else {
100
- reject(new Error(`修改备忘录失败: ${event.status}`));
100
+ reject(new Error(`修改备忘录失败: ${JSON.stringify(event.outputs)}`));
101
101
  }
102
102
  }
103
103
  };
@@ -114,7 +114,7 @@ export function createNoteTool(ctx) {
114
114
  });
115
115
  }
116
116
  else {
117
- reject(new Error(`创建备忘录失败: ${event.status}`));
117
+ reject(new Error(`创建备忘录失败: ${JSON.stringify(event.outputs)}`));
118
118
  }
119
119
  }
120
120
  };
@@ -114,7 +114,7 @@ c. 调用工具前需认真检查调用参数是否满足工具要求
114
114
  });
115
115
  }
116
116
  else {
117
- reject(new Error(`查询通知消息失败: ${event.status}`));
117
+ reject(new Error(`查询通知消息失败: ${JSON.stringify(event.outputs)}`));
118
118
  }
119
119
  }
120
120
  };
@@ -130,7 +130,7 @@ c. 调用工具前需认真检查调用参数是否满足工具要求
130
130
  });
131
131
  }
132
132
  else {
133
- reject(new Error(`查询记忆数据失败: ${event.status}`));
133
+ reject(new Error(`查询记忆数据失败: ${JSON.stringify(event.outputs)}`));
134
134
  }
135
135
  }
136
136
  };
@@ -109,7 +109,7 @@ d. 当只传入 startTime 时,返回该时间点之后的所有任务;当只
109
109
  });
110
110
  }
111
111
  else {
112
- reject(new Error(`查询待办任务失败: ${event.status}`));
112
+ reject(new Error(`查询待办任务失败: ${JSON.stringify(event.outputs)}`));
113
113
  }
114
114
  }
115
115
  };
@@ -138,7 +138,7 @@ export function createSaveFileToPhoneTool(ctx) {
138
138
  });
139
139
  }
140
140
  else {
141
- reject(new Error(`保存文件到手机失败: ${event.status}`));
141
+ reject(new Error(`保存文件到手机失败: ${JSON.stringify(event.outputs)}`));
142
142
  }
143
143
  }
144
144
  };
@@ -146,7 +146,7 @@ export function createSaveMediaToGalleryTool(ctx) {
146
146
  });
147
147
  }
148
148
  else {
149
- reject(new Error(`保存媒体到图库失败: ${event.status}`));
149
+ reject(new Error(`保存媒体到图库失败: ${JSON.stringify(event.outputs)}`));
150
150
  }
151
151
  }
152
152
  };
@@ -23,7 +23,7 @@ export function createSchemaTool(options) {
23
23
  content: [
24
24
  {
25
25
  type: "text",
26
- text: JSON.stringify(schemas, null, 2),
26
+ text: "以下为工具列表。请仔细阅读,使用call_device_tool进行调用:\n" + JSON.stringify(schemas, null, 2),
27
27
  },
28
28
  ],
29
29
  };
@@ -188,7 +188,7 @@ b. 使用该工具之前需获取当前真实时间
188
188
  });
189
189
  }
190
190
  else {
191
- reject(new Error(`检索闹钟失败: ${event.status}`));
191
+ reject(new Error(`检索闹钟失败: ${JSON.stringify(event.outputs)}`));
192
192
  }
193
193
  }
194
194
  };
@@ -159,7 +159,7 @@ d. 如果查询结果返回-303,代表查询结果为空
159
159
  });
160
160
  }
161
161
  else {
162
- reject(new Error(`检索日程失败: ${event.status}`));
162
+ reject(new Error(`检索日程失败: ${JSON.stringify(event.outputs)}`));
163
163
  }
164
164
  }
165
165
  };
@@ -87,7 +87,7 @@ export function createSearchContactTool(ctx) {
87
87
  });
88
88
  }
89
89
  else {
90
- reject(new Error(`搜索联系人失败: ${event.status}`));
90
+ reject(new Error(`搜索联系人失败: ${JSON.stringify(event.outputs)}`));
91
91
  }
92
92
  }
93
93
  };
@@ -110,7 +110,7 @@ b. 使用该工具之前需获取当前真实时间
110
110
  });
111
111
  }
112
112
  else {
113
- reject(new Error(`检索邮件失败: ${event.status}`));
113
+ reject(new Error(`检索邮件失败: ${JSON.stringify(event.outputs)}`));
114
114
  }
115
115
  }
116
116
  };
@@ -11,13 +11,12 @@ export function createSearchFileTool(ctx) {
11
11
  return {
12
12
  name: "search_file",
13
13
  label: "Search File",
14
- description: `搜索手机或PC/电脑文件系统的文件。
14
+ description: `搜索用户设备的文件系统的文件,用户设备可以是手机或者鸿蒙PC等。
15
15
 
16
- 【重要】使用场景与调用流程:
17
- 1. 搜索手机文件:当用户明确说明要从手机搜索时(如"从手机里面搜索xxxx"、"在手机上查找文件xxxx"),直接调用此工具,无需传入 udid。
18
- 2. 搜索PC/电脑文件:当用户要求搜索PC/电脑上的文件时(如"帮我找一下PC上的xxx文件"、"搜索电脑上的xxx"),必须先调用 find_pc_devices 工具获取设备ID(udid),然后将 udid 传入此工具进行搜索。
16
+ 使用场景与调用流程:
17
+ 当用户明确说明要从设备搜索时(如"从手机里面搜索xxxx"、"在手机上查找文件xxxx","查找我电脑上的xxxx文件","查找我鸿蒙PC上的xxx文件"),直接调用此工具。
19
18
 
20
- 如果用户没有明确说明从手机或PC搜索(如仅说"搜索文件"、"找一下xxxx"),应默认从当前runtime运行环境的本地文件系统查询,不要调用此工具。
19
+ 如果用户没有明确说明从设备搜索(如仅说"搜索文件"、"找一下xxxx"),应默认从当前runtime运行环境的本地文件系统查询,不要调用此工具。
21
20
 
22
21
  功能说明:根据关键词搜索文件名称或内容,返回匹配的文件列表(包括文件名、路径、大小、修改时间等信息)。
23
22
 
@@ -28,11 +27,7 @@ export function createSearchFileTool(ctx) {
28
27
  query: {
29
28
  type: "string",
30
29
  description: "搜索关键词,用于匹配文件名称、后缀名或文件内容",
31
- },
32
- udid: {
33
- type: "string",
34
- description: "PC/电脑设备ID。当搜索PC/电脑上的文件时,需要先通过 find_pc_devices 工具获取设备ID后传入。搜索手机文件时不需要传入此参数。",
35
- },
30
+ }
36
31
  },
37
32
  required: ["query"],
38
33
  },
@@ -86,7 +86,7 @@ export function createSearchNoteTool(ctx) {
86
86
  });
87
87
  }
88
88
  else {
89
- reject(new Error(`搜索备忘录失败: ${event.status}`));
89
+ reject(new Error(`搜索备忘录失败: ${JSON.stringify(event.outputs)}`));
90
90
  }
91
91
  }
92
92
  };
@@ -140,7 +140,7 @@ async function searchPhotos(wsManager, config, sessionId, taskId, messageId, too
140
140
  resolve(event.outputs);
141
141
  }
142
142
  else {
143
- reject(new Error(`搜索照片失败: ${event.status}`));
143
+ reject(new Error(`搜索照片失败: ${JSON.stringify(event.outputs)}`));
144
144
  }
145
145
  }
146
146
  };