@ynhcj/xiaoyi-channel 0.0.152-beta → 0.0.152-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 (80) hide show
  1. package/dist/index.js +23 -0
  2. package/dist/src/bot.js +21 -5
  3. package/dist/src/channel.js +59 -5
  4. package/dist/src/cron-command.d.ts +15 -0
  5. package/dist/src/cron-command.js +49 -0
  6. package/dist/src/cron-query-handler.d.ts +7 -0
  7. package/dist/src/cron-query-handler.js +188 -0
  8. package/dist/src/cspl/call_api.d.ts +1 -1
  9. package/dist/src/cspl/call_api.js +2 -2
  10. package/dist/src/cspl/config.js +30 -10
  11. package/dist/src/cspl/constants.d.ts +3 -0
  12. package/dist/src/cspl/constants.js +5 -0
  13. package/dist/src/cspl/sentinel_hook.js +26 -7
  14. package/dist/src/cspl/utils.d.ts +9 -3
  15. package/dist/src/cspl/utils.js +17 -11
  16. package/dist/src/formatter.d.ts +14 -1
  17. package/dist/src/formatter.js +31 -8
  18. package/dist/src/monitor.js +44 -23
  19. package/dist/src/parser.d.ts +8 -1
  20. package/dist/src/parser.js +71 -0
  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 +118 -14
  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 +56 -4
  28. package/dist/src/tools/calendar-tool.js +2 -1
  29. package/dist/src/tools/call-device-tool.js +0 -3
  30. package/dist/src/tools/call-phone-tool.js +2 -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 +2 -1
  34. package/dist/src/tools/create-all-tools.js +10 -4
  35. package/dist/src/tools/delete-alarm-tool.js +2 -1
  36. package/dist/src/tools/device-tool-map.d.ts +1 -1
  37. package/dist/src/tools/device-tool-map.js +12 -5
  38. package/dist/src/tools/discover-cross-devices-tool.d.ts +2 -0
  39. package/dist/src/tools/discover-cross-devices-tool.js +235 -0
  40. package/dist/src/tools/display-a2ui-card-tool.d.ts +2 -0
  41. package/dist/src/tools/display-a2ui-card-tool.js +85 -0
  42. package/dist/src/tools/find-pc-devices-tool.js +1 -0
  43. package/dist/src/tools/get-collection-tool-schema.js +1 -1
  44. package/dist/src/tools/get-device-file-tool-schema.js +2 -3
  45. package/dist/src/tools/location-tool.js +2 -1
  46. package/dist/src/tools/modify-alarm-tool.js +2 -1
  47. package/dist/src/tools/modify-note-tool.js +2 -1
  48. package/dist/src/tools/note-tool.js +2 -1
  49. package/dist/src/tools/query-app-message-tool.js +4 -3
  50. package/dist/src/tools/query-memory-data-tool.js +4 -3
  51. package/dist/src/tools/query-todo-task-tool.js +4 -3
  52. package/dist/src/tools/save-file-to-phone-tool.js +2 -1
  53. package/dist/src/tools/save-media-to-gallery-tool.js +2 -1
  54. package/dist/src/tools/schema-tool-factory.js +1 -1
  55. package/dist/src/tools/search-alarm-tool.js +2 -1
  56. package/dist/src/tools/search-calendar-tool.js +2 -1
  57. package/dist/src/tools/search-contact-tool.js +2 -1
  58. package/dist/src/tools/search-email-tool.js +4 -3
  59. package/dist/src/tools/search-file-tool.js +6 -10
  60. package/dist/src/tools/search-message-tool.js +1 -0
  61. package/dist/src/tools/search-note-tool.js +2 -1
  62. package/dist/src/tools/search-photo-gallery-tool.js +4 -3
  63. package/dist/src/tools/send-cross-device-task-tool.d.ts +2 -0
  64. package/dist/src/tools/send-cross-device-task-tool.js +299 -0
  65. package/dist/src/tools/send-email-tool.js +4 -3
  66. package/dist/src/tools/send-file-to-user-tool.d.ts +1 -1
  67. package/dist/src/tools/send-file-to-user-tool.js +35 -6
  68. package/dist/src/tools/send-message-tool.js +1 -0
  69. package/dist/src/tools/session-manager.d.ts +17 -1
  70. package/dist/src/tools/session-manager.js +73 -0
  71. package/dist/src/tools/upload-file-tool.js +6 -14
  72. package/dist/src/tools/upload-photo-tool.js +4 -3
  73. package/dist/src/tools/xiaoyi-add-collection-tool.js +4 -2
  74. package/dist/src/tools/xiaoyi-collection-tool.js +3 -2
  75. package/dist/src/tools/xiaoyi-delete-collection-tool.js +3 -2
  76. package/dist/src/tools/xiaoyi-gui-tool.js +6 -0
  77. package/dist/src/types.d.ts +25 -1
  78. package/dist/src/websocket.d.ts +3 -0
  79. package/dist/src/websocket.js +207 -15
  80. package/package.json +1 -1
@@ -13,10 +13,13 @@ import { createGetPhotoToolSchemaTool } from "./get-photo-tool-schema.js";
13
13
  import { createGetDeviceFileToolSchemaTool } from "./get-device-file-tool-schema.js";
14
14
  import { createGetAlarmToolSchemaTool } from "./get-alarm-tool-schema.js";
15
15
  import { createGetCollectionToolSchemaTool } from "./get-collection-tool-schema.js";
16
- import { createGetEmailToolSchemaTool } from "./get-email-tool-schema.js";
16
+ // import { createGetEmailToolSchemaTool } from "./get-email-tool-schema.js";
17
17
  import { createLoginTokenTool } from "./login-token-tool.js";
18
18
  import { createAgentAsSkillTool } from "./agent-as-skill-tool.js";
19
- import { createFindPcDevicesTool } from "./find-pc-devices-tool.js";
19
+ import { createDiscoverCrossDevicesTool } from "./discover-cross-devices-tool.js";
20
+ import { createSendCrossDeviceTaskTool } from "./send-cross-device-task-tool.js";
21
+ import { createDisplayA2UICardTool } from "./display-a2ui-card-tool.js";
22
+ import { createCheckPluginPrivilegeTool } from "./check-plugin-privilege-tool.js";
20
23
  import { logger } from "../utils/logger.js";
21
24
  /**
22
25
  * Create all XY channel tools for the given session context.
@@ -32,6 +35,9 @@ export function createAllTools(ctx) {
32
35
  logger.log(`[CREATE-ALL-TOOLS] creating tools`);
33
36
  return [
34
37
  createLocationTool(ctx),
38
+ createDiscoverCrossDevicesTool(ctx),
39
+ createSendCrossDeviceTaskTool(ctx),
40
+ createDisplayA2UICardTool(ctx),
35
41
  createCallDeviceTool(ctx),
36
42
  createGetNoteToolSchemaTool(ctx),
37
43
  createGetCalendarToolSchemaTool(ctx),
@@ -42,13 +48,13 @@ export function createAllTools(ctx) {
42
48
  createGetAlarmToolSchemaTool(ctx),
43
49
  createGetCollectionToolSchemaTool(ctx),
44
50
  createSendFileToUserTool(ctx),
45
- createGetEmailToolSchemaTool(ctx),
51
+ // createGetEmailToolSchemaTool(ctx),
46
52
  viewPushResultTool,
47
53
  createImageReadingTool(ctx),
48
54
  timestampToUtc8Tool,
49
55
  createSaveSelfEvolutionSkillTool(ctx),
50
56
  createLoginTokenTool(ctx),
51
57
  createAgentAsSkillTool(ctx),
52
- createFindPcDevicesTool(ctx),
58
+ createCheckPluginPrivilegeTool(ctx),
53
59
  ];
54
60
  }
@@ -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
  };
@@ -157,6 +157,7 @@ export function createDeleteAlarmTool(ctx) {
157
157
  taskId: currentTaskId,
158
158
  messageId,
159
159
  command,
160
+ toolCallId,
160
161
  })
161
162
  .then(() => {
162
163
  })
@@ -1,4 +1,4 @@
1
1
  /** Known device type enum. */
2
- export declare const DEVICE_TYPES: readonly ["car", "2in1", "phone"];
2
+ export declare const DEVICE_TYPES: readonly ["car", "2in1", "phone", "web"];
3
3
  export type DeviceType = (typeof DEVICE_TYPES)[number];
4
4
  export declare function filterToolsByDevice(tools: any[], deviceType?: string): any[];
@@ -4,7 +4,7 @@
4
4
  // - denylist: listed tools are blocked, everything else is available (used for permissive devices like pc)
5
5
  // Tools NOT listed in any device entry → available to all devices (no restriction).
6
6
  /** Known device type enum. */
7
- export const DEVICE_TYPES = ["car", "2in1", "phone"];
7
+ export const DEVICE_TYPES = ["car", "2in1", "phone", "web"];
8
8
  const DEVICE_TOOL_POLICY = {
9
9
  "2in1": {
10
10
  allowlist: false,
@@ -15,10 +15,17 @@ const DEVICE_TOOL_POLICY = {
15
15
  "search_message",
16
16
  "search_contact",
17
17
  "get_contact_tool_schema",
18
- "query_collection",
19
- "add_collection",
20
- "delete_collection",
21
- "get_collection_tool_schema",
18
+ ],
19
+ },
20
+ "web": {
21
+ allowlist: true,
22
+ tools: [
23
+ "send_file_to_user",
24
+ "view_push_result",
25
+ "image_reading",
26
+ "convert_time_to_utc8_time",
27
+ "save_self_evolution_skill",
28
+ "displayA2UICard",
22
29
  ],
23
30
  },
24
31
  };
@@ -0,0 +1,2 @@
1
+ import type { SessionContext } from "./session-manager.js";
2
+ export declare function createDiscoverCrossDevicesTool(ctx: SessionContext): any;
@@ -0,0 +1,235 @@
1
+ import { sendCommand, sendStatusUpdate } from "../formatter.js";
2
+ import { getXYWebSocketManager } from "../client.js";
3
+ import { getCurrentMessageId, getCurrentTaskId } from "../task-manager.js";
4
+ import { logger } from "../utils/logger.js";
5
+ const DISCOVER_DEVICES_INTENT = "SearchAllDeviceInfo";
6
+ const DISCOVER_DEVICES_BUNDLE = "com.huawei.hmos.vassistant";
7
+ const DISCOVER_DEVICES_TIMEOUT_MS = 30_000;
8
+ const LOG_TAG = "[GetPCDeviceList]";
9
+ const DISCOVER_DEVICES_STATUS_TEXT = "正在查询设备列表...";
10
+ const DEVICE_TYPE_LABELS = {
11
+ "14": "phone",
12
+ "17": "pad",
13
+ "131": "car",
14
+ "2607": "PC",
15
+ };
16
+ function buildResultText(result) {
17
+ return {
18
+ content: [
19
+ {
20
+ type: "text",
21
+ text: JSON.stringify(result),
22
+ },
23
+ ],
24
+ };
25
+ }
26
+ function normalizeDevices(rawDevices) {
27
+ if (!Array.isArray(rawDevices)) {
28
+ return [];
29
+ }
30
+ return rawDevices
31
+ .filter((item) => Boolean(item) && typeof item === "object")
32
+ .map((device) => {
33
+ const networkId = typeof device.networkId === "string"
34
+ ? device.networkId
35
+ : typeof device.deviceId === "string"
36
+ ? device.deviceId
37
+ : "";
38
+ const deviceTypeId = typeof device.deviceTypeId === "string"
39
+ ? device.deviceTypeId
40
+ : typeof device.deviceType === "string"
41
+ ? device.deviceType
42
+ : "";
43
+ return {
44
+ networkId,
45
+ deviceName: typeof device.deviceName === "string" ? device.deviceName : "",
46
+ deviceTypeId,
47
+ deviceTypeLabel: DEVICE_TYPE_LABELS[deviceTypeId] ?? "unknown",
48
+ nearby: device.nearby === true,
49
+ rawDevice: device,
50
+ };
51
+ });
52
+ }
53
+ function inferDesiredDeviceTypes(query) {
54
+ const normalized = query.toLowerCase();
55
+ if (/(pc|computer|desktop|laptop|notebook)/iu.test(normalized) || /电脑|台式机|笔记本/iu.test(query)) {
56
+ return ["2607"];
57
+ }
58
+ if (/(tablet|pad|ipad)/iu.test(normalized) || /平板/iu.test(query)) {
59
+ return ["17"];
60
+ }
61
+ if (/(phone|mobile)/iu.test(normalized) || /手机/iu.test(query)) {
62
+ return ["14"];
63
+ }
64
+ return [];
65
+ }
66
+ function sortByNearby(devices) {
67
+ return [...devices].sort((a, b) => Number(b.nearby) - Number(a.nearby));
68
+ }
69
+ function recommendDevices(query, devices) {
70
+ const desiredTypes = inferDesiredDeviceTypes(query);
71
+ if (desiredTypes.length === 0) {
72
+ return {
73
+ recommendedDevices: [],
74
+ recommendationReason: "No explicit target device type was detected in the query.",
75
+ needsUserSelection: devices.length > 1,
76
+ selectionPrompt: devices.length > 1
77
+ ? "The query does not identify a unique device type. Ask the user to choose a target device by deviceName or networkId before sending a cross-device task."
78
+ : "",
79
+ };
80
+ }
81
+ const matches = devices.filter((device) => desiredTypes.includes(device.deviceTypeId));
82
+ if (matches.length === 0) {
83
+ return {
84
+ recommendedDevices: [],
85
+ recommendationReason: `No discovered device matches requested type(s): ${desiredTypes.join(", ")}.`,
86
+ needsUserSelection: false,
87
+ selectionPrompt: "",
88
+ };
89
+ }
90
+ const sortedMatches = sortByNearby(matches);
91
+ return {
92
+ recommendedDevices: sortedMatches,
93
+ recommendationReason: `Matched requested device type(s): ${desiredTypes.join(", ")}. Nearby devices are ranked first.`,
94
+ needsUserSelection: sortedMatches.length > 1,
95
+ selectionPrompt: sortedMatches.length > 1
96
+ ? "Multiple candidate devices match the user request. Ask the user to choose one target device by deviceName or networkId before calling send_cross_device_task."
97
+ : "",
98
+ };
99
+ }
100
+ export function createDiscoverCrossDevicesTool(ctx) {
101
+ const { config, sessionId, taskId, messageId } = ctx;
102
+ return {
103
+ name: "discover_cross_devices",
104
+ label: "发现跨设备协作设备",
105
+ description: `跨设备协作的设备发现工具。
106
+
107
+ 当用户明确表达要从另一台设备获取、查找、使用或操作内容时,必须优先调用本工具,例如从 PC、电脑、平板、手机等设备获取文件或查找内容。
108
+
109
+ 本工具只做设备发现和目标设备推荐,不会读取副设备文件内容,不会上传文件,也不会真正下发跨端执行任务。下发跨端执行任务需要使用SendCrossDeviceTaskTool`,
110
+ parameters: {
111
+ type: "object",
112
+ properties: {
113
+ query: {
114
+ type: "string",
115
+ description: "The user's original cross-device request, used to recommend the target device type.",
116
+ },
117
+ },
118
+ required: ["query"],
119
+ },
120
+ async execute(_toolCallId, params) {
121
+ const query = typeof params.query === "string" ? params.query.trim() : "";
122
+ logger.log(`${LOG_TAG} tool invoked`);
123
+ if (!query) {
124
+ return buildResultText({
125
+ success: false,
126
+ rawOutputs: null,
127
+ devices: [],
128
+ recommendedDevices: [],
129
+ recommendationReason: "",
130
+ message: "Missing required parameter: query.",
131
+ });
132
+ }
133
+ const currentTaskId = getCurrentTaskId(sessionId) ?? taskId;
134
+ const currentMessageId = getCurrentMessageId(sessionId) ?? messageId;
135
+ const wsManager = getXYWebSocketManager(config);
136
+ const command = {
137
+ header: {
138
+ namespace: "Common",
139
+ name: "Action",
140
+ },
141
+ payload: {
142
+ needUploadResult: true,
143
+ actionResponseConfig: {},
144
+ response: [],
145
+ executeParam: {
146
+ executeMode: "background",
147
+ intentName: DISCOVER_DEVICES_INTENT,
148
+ intentParam: {},
149
+ bundleName: DISCOVER_DEVICES_BUNDLE,
150
+ },
151
+ },
152
+ };
153
+ return new Promise((resolve) => {
154
+ let timeout;
155
+ let handler;
156
+ let settled = false;
157
+ const cleanup = () => {
158
+ clearTimeout(timeout);
159
+ wsManager.off("data-event", handler);
160
+ };
161
+ const finish = (result) => {
162
+ if (settled) {
163
+ return;
164
+ }
165
+ settled = true;
166
+ cleanup();
167
+ resolve(buildResultText(result));
168
+ };
169
+ handler = (event) => {
170
+ if (event.intentName !== DISCOVER_DEVICES_INTENT) {
171
+ return;
172
+ }
173
+ const rawOutputs = event.outputs ?? {};
174
+ const code = rawOutputs.code;
175
+ const success = event.status === "success" && String(code) === "0";
176
+ const devices = normalizeDevices(rawOutputs.result?.devices);
177
+ const recommendation = recommendDevices(query, devices);
178
+ logger.log(`${LOG_TAG} completed, success=${success}, deviceCount=${devices.length}, recommendedCount=${recommendation.recommendedDevices.length}`);
179
+ finish({
180
+ success,
181
+ rawOutputs,
182
+ devices,
183
+ recommendedDevices: recommendation.recommendedDevices,
184
+ recommendationReason: recommendation.recommendationReason,
185
+ needsUserSelection: recommendation.needsUserSelection,
186
+ selectionPrompt: recommendation.selectionPrompt,
187
+ message: success
188
+ ? recommendation.needsUserSelection
189
+ ? `Discovered ${devices.length} device(s). Multiple candidates may match; ask the user to choose the target device before sending a cross-device task.`
190
+ : `Discovered ${devices.length} device(s). The model should choose the final target device based on the user request.`
191
+ : "Device discovery failed on the device side.",
192
+ });
193
+ };
194
+ timeout = setTimeout(() => {
195
+ logger.log(`${LOG_TAG} timeout waiting UploadExeResult after ${DISCOVER_DEVICES_TIMEOUT_MS}ms`);
196
+ finish({
197
+ success: false,
198
+ rawOutputs: null,
199
+ devices: [],
200
+ recommendedDevices: [],
201
+ recommendationReason: "",
202
+ message: `Device discovery timed out after ${DISCOVER_DEVICES_TIMEOUT_MS / 1000} seconds.`,
203
+ });
204
+ }, DISCOVER_DEVICES_TIMEOUT_MS);
205
+ wsManager.on("data-event", handler);
206
+ sendStatusUpdate({
207
+ config,
208
+ sessionId,
209
+ taskId: currentTaskId,
210
+ messageId: currentMessageId,
211
+ text: DISCOVER_DEVICES_STATUS_TEXT,
212
+ state: "working",
213
+ })
214
+ .then(() => sendCommand({
215
+ config,
216
+ sessionId,
217
+ taskId: currentTaskId,
218
+ messageId: currentMessageId,
219
+ command,
220
+ }))
221
+ .catch((error) => {
222
+ logger.error(`${LOG_TAG} failed to send device discovery command: ${error instanceof Error ? error.message : String(error)}`);
223
+ finish({
224
+ success: false,
225
+ rawOutputs: null,
226
+ devices: [],
227
+ recommendedDevices: [],
228
+ recommendationReason: "",
229
+ message: `Failed to send device discovery command: ${error instanceof Error ? error.message : String(error)}`,
230
+ });
231
+ });
232
+ });
233
+ },
234
+ };
235
+ }
@@ -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
+ }
@@ -82,6 +82,7 @@ export function createFindPcDevicesTool(ctx) {
82
82
  taskId,
83
83
  messageId,
84
84
  command,
85
+ toolCallId,
85
86
  }).then(() => {
86
87
  }).catch((error) => {
87
88
  clearTimeout(timeout);
@@ -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
  };
@@ -90,6 +90,7 @@ export function createLocationTool(ctx) {
90
90
  taskId: currentTaskId,
91
91
  messageId,
92
92
  command,
93
+ toolCallId,
93
94
  }).then(() => {
94
95
  }).catch((error) => {
95
96
  clearTimeout(timeout);
@@ -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
  };
@@ -270,6 +270,7 @@ export function createModifyAlarmTool(ctx) {
270
270
  taskId: currentTaskId,
271
271
  messageId,
272
272
  command,
273
+ toolCallId,
273
274
  })
274
275
  .then(() => {
275
276
  })
@@ -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
  };
@@ -111,6 +111,7 @@ export function createModifyNoteTool(ctx) {
111
111
  taskId: currentTaskId,
112
112
  messageId,
113
113
  command,
114
+ toolCallId,
114
115
  })
115
116
  .then(() => {
116
117
  })
@@ -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
  };
@@ -128,6 +128,7 @@ export function createNoteTool(ctx) {
128
128
  taskId: currentTaskId,
129
129
  messageId,
130
130
  command,
131
+ toolCallId,
131
132
  }).catch((error) => {
132
133
  clearTimeout(timeout);
133
134
  wsManager.off("data-event", handler);
@@ -47,7 +47,7 @@ c. 调用工具前需认真检查调用参数是否满足工具要求
47
47
  },
48
48
  required: [],
49
49
  },
50
- async execute(_toolCallId, params) {
50
+ async execute(toolCallId, params) {
51
51
  const wsManager = getXYWebSocketManager(config);
52
52
  const intentParam = {};
53
53
  if (params.startTime !== undefined)
@@ -96,7 +96,7 @@ c. 调用工具前需认真检查调用参数是否满足工具要求
96
96
  return new Promise((resolve, reject) => {
97
97
  const timeout = setTimeout(() => {
98
98
  wsManager.off("data-event", handler);
99
- logger.error("超时: 查询通知消息超时(60秒)", { toolCallId: _toolCallId });
99
+ logger.error("超时: 查询通知消息超时(60秒)", { toolCallId: toolCallId });
100
100
  reject(new Error("查询通知消息超时(60秒)"));
101
101
  }, 60000);
102
102
  const handler = (event) => {
@@ -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
  };
@@ -126,6 +126,7 @@ c. 调用工具前需认真检查调用参数是否满足工具要求
126
126
  taskId: currentTaskId,
127
127
  messageId,
128
128
  command,
129
+ toolCallId,
129
130
  })
130
131
  .then(() => { })
131
132
  .catch((error) => {
@@ -56,7 +56,7 @@ c. 调用工具前需认真检查调用参数是否满足工具要求
56
56
  },
57
57
  required: [],
58
58
  },
59
- async execute(_toolCallId, params) {
59
+ async execute(toolCallId, params) {
60
60
  const { category, subCategory } = params;
61
61
  // Validate category
62
62
  if (category && !VALID_CATEGORIES.includes(category)) {
@@ -112,7 +112,7 @@ c. 调用工具前需认真检查调用参数是否满足工具要求
112
112
  return new Promise((resolve, reject) => {
113
113
  const timeout = setTimeout(() => {
114
114
  wsManager.off("data-event", handler);
115
- logger.error("超时: 查询记忆数据超时(60秒)", { toolCallId: _toolCallId });
115
+ logger.error("超时: 查询记忆数据超时(60秒)", { toolCallId: toolCallId });
116
116
  reject(new Error("查询记忆数据超时(60秒)"));
117
117
  }, 60000);
118
118
  const handler = (event) => {
@@ -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
  };
@@ -142,6 +142,7 @@ c. 调用工具前需认真检查调用参数是否满足工具要求
142
142
  taskId: currentTaskId,
143
143
  messageId,
144
144
  command,
145
+ toolCallId,
145
146
  })
146
147
  .then(() => { })
147
148
  .catch((error) => {
@@ -44,7 +44,7 @@ d. 当只传入 startTime 时,返回该时间点之后的所有任务;当只
44
44
  },
45
45
  required: [],
46
46
  },
47
- async execute(_toolCallId, params) {
47
+ async execute(toolCallId, params) {
48
48
  const { status } = params;
49
49
  if (status && !["all", "completed", "pending"].includes(status)) {
50
50
  throw new ToolInputError('status 参数只能为 "all"、"completed" 或 "pending"');
@@ -91,7 +91,7 @@ d. 当只传入 startTime 时,返回该时间点之后的所有任务;当只
91
91
  return new Promise((resolve, reject) => {
92
92
  const timeout = setTimeout(() => {
93
93
  wsManager.off("data-event", handler);
94
- logger.error("超时: 查询待办任务超时(60秒)", { toolCallId: _toolCallId });
94
+ logger.error("超时: 查询待办任务超时(60秒)", { toolCallId: toolCallId });
95
95
  reject(new Error("查询待办任务超时(60秒)"));
96
96
  }, 60000);
97
97
  const handler = (event) => {
@@ -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
  };
@@ -121,6 +121,7 @@ d. 当只传入 startTime 时,返回该时间点之后的所有任务;当只
121
121
  taskId: currentTaskId,
122
122
  messageId,
123
123
  command,
124
+ toolCallId,
124
125
  })
125
126
  .then(() => { })
126
127
  .catch((error) => {
@@ -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
  };
@@ -152,6 +152,7 @@ export function createSaveFileToPhoneTool(ctx) {
152
152
  taskId: currentTaskId,
153
153
  messageId,
154
154
  command,
155
+ toolCallId,
155
156
  })
156
157
  .then(() => {
157
158
  })