@ynhcj/xiaoyi-channel 0.0.151-beta → 0.0.151-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/index.js +23 -0
  2. package/dist/src/bot.js +9 -1
  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 +17 -3
  14. package/dist/src/cspl/utils.js +2 -2
  15. package/dist/src/formatter.d.ts +14 -1
  16. package/dist/src/formatter.js +31 -8
  17. package/dist/src/monitor.js +13 -1
  18. package/dist/src/parser.d.ts +2 -1
  19. package/dist/src/parser.js +55 -0
  20. package/dist/src/provider.js +19 -17
  21. package/dist/src/push.d.ts +11 -1
  22. package/dist/src/push.js +93 -2
  23. package/dist/src/reply-dispatcher.js +113 -14
  24. package/dist/src/self-evolution-handler.js +1 -1
  25. package/dist/src/tools/agent-as-skill-tool.js +56 -4
  26. package/dist/src/tools/calendar-tool.js +2 -1
  27. package/dist/src/tools/call-device-tool.js +0 -3
  28. package/dist/src/tools/call-phone-tool.js +2 -1
  29. package/dist/src/tools/create-alarm-tool.js +2 -1
  30. package/dist/src/tools/create-all-tools.js +8 -4
  31. package/dist/src/tools/delete-alarm-tool.js +2 -1
  32. package/dist/src/tools/device-tool-map.d.ts +1 -1
  33. package/dist/src/tools/device-tool-map.js +12 -5
  34. package/dist/src/tools/discover-cross-devices-tool.d.ts +2 -0
  35. package/dist/src/tools/discover-cross-devices-tool.js +235 -0
  36. package/dist/src/tools/display-a2ui-card-tool.d.ts +2 -0
  37. package/dist/src/tools/display-a2ui-card-tool.js +85 -0
  38. package/dist/src/tools/find-pc-devices-tool.js +1 -0
  39. package/dist/src/tools/get-collection-tool-schema.js +1 -1
  40. package/dist/src/tools/get-device-file-tool-schema.js +2 -3
  41. package/dist/src/tools/location-tool.js +2 -1
  42. package/dist/src/tools/modify-alarm-tool.js +2 -1
  43. package/dist/src/tools/modify-note-tool.js +2 -1
  44. package/dist/src/tools/note-tool.js +2 -1
  45. package/dist/src/tools/query-app-message-tool.js +4 -3
  46. package/dist/src/tools/query-memory-data-tool.js +4 -3
  47. package/dist/src/tools/query-todo-task-tool.js +4 -3
  48. package/dist/src/tools/save-file-to-phone-tool.js +2 -1
  49. package/dist/src/tools/save-media-to-gallery-tool.js +2 -1
  50. package/dist/src/tools/schema-tool-factory.js +1 -1
  51. package/dist/src/tools/search-alarm-tool.js +2 -1
  52. package/dist/src/tools/search-calendar-tool.js +2 -1
  53. package/dist/src/tools/search-contact-tool.js +2 -1
  54. package/dist/src/tools/search-email-tool.js +4 -3
  55. package/dist/src/tools/search-file-tool.js +6 -10
  56. package/dist/src/tools/search-message-tool.js +1 -0
  57. package/dist/src/tools/search-note-tool.js +2 -1
  58. package/dist/src/tools/search-photo-gallery-tool.js +4 -3
  59. package/dist/src/tools/send-cross-device-task-tool.d.ts +2 -0
  60. package/dist/src/tools/send-cross-device-task-tool.js +299 -0
  61. package/dist/src/tools/send-email-tool.js +4 -3
  62. package/dist/src/tools/send-file-to-user-tool.d.ts +1 -1
  63. package/dist/src/tools/send-file-to-user-tool.js +35 -6
  64. package/dist/src/tools/send-message-tool.js +1 -0
  65. package/dist/src/tools/session-manager.d.ts +14 -1
  66. package/dist/src/tools/session-manager.js +73 -0
  67. package/dist/src/tools/upload-file-tool.js +6 -14
  68. package/dist/src/tools/upload-photo-tool.js +4 -3
  69. package/dist/src/tools/xiaoyi-add-collection-tool.js +4 -2
  70. package/dist/src/tools/xiaoyi-collection-tool.js +3 -2
  71. package/dist/src/tools/xiaoyi-delete-collection-tool.js +3 -2
  72. package/dist/src/tools/xiaoyi-gui-tool.js +6 -0
  73. package/dist/src/types.d.ts +22 -0
  74. package/dist/src/websocket.d.ts +3 -0
  75. package/dist/src/websocket.js +207 -15
  76. package/package.json +1 -1
@@ -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
  })
@@ -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
  };
@@ -160,6 +160,7 @@ export function createSaveMediaToGalleryTool(ctx) {
160
160
  taskId: currentTaskId,
161
161
  messageId,
162
162
  command,
163
+ toolCallId,
163
164
  })
164
165
  .then(() => {
165
166
  })
@@ -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
  };
@@ -202,6 +202,7 @@ b. 使用该工具之前需获取当前真实时间
202
202
  taskId: currentTaskId,
203
203
  messageId,
204
204
  command,
205
+ toolCallId,
205
206
  })
206
207
  .then(() => {
207
208
  })
@@ -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
  };
@@ -173,6 +173,7 @@ d. 如果查询结果返回-303,代表查询结果为空
173
173
  taskId: currentTaskId,
174
174
  messageId,
175
175
  command,
176
+ toolCallId,
176
177
  })
177
178
  .then(() => {
178
179
  })
@@ -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
  };
@@ -101,6 +101,7 @@ export function createSearchContactTool(ctx) {
101
101
  taskId: currentTaskId,
102
102
  messageId,
103
103
  command,
104
+ toolCallId,
104
105
  })
105
106
  .then(() => {
106
107
  })
@@ -40,7 +40,7 @@ b. 使用该工具之前需获取当前真实时间
40
40
  },
41
41
  required: ["queryText"],
42
42
  },
43
- async execute(_toolCallId, params) {
43
+ async execute(toolCallId, params) {
44
44
  // ===== Validate queryText =====
45
45
  if (!params.queryText || typeof params.queryText !== "string" || !params.queryText.trim()) {
46
46
  throw new Error("queryText 为必填参数,且不能为空字符串");
@@ -91,7 +91,7 @@ b. 使用该工具之前需获取当前真实时间
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
  // Listen for data events from WebSocket
@@ -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
  };
@@ -124,6 +124,7 @@ b. 使用该工具之前需获取当前真实时间
124
124
  taskId: currentTaskId,
125
125
  messageId,
126
126
  command,
127
+ toolCallId,
127
128
  })
128
129
  .then(() => { })
129
130
  .catch((error) => {
@@ -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
  },
@@ -117,6 +112,7 @@ export function createSearchFileTool(ctx) {
117
112
  taskId: currentTaskId,
118
113
  messageId,
119
114
  command,
115
+ toolCallId,
120
116
  })
121
117
  .then(() => {
122
118
  })
@@ -103,6 +103,7 @@ export function createSearchMessageTool(ctx) {
103
103
  taskId: currentTaskId,
104
104
  messageId,
105
105
  command,
106
+ toolCallId,
106
107
  })
107
108
  .then(() => {
108
109
  })
@@ -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
  };
@@ -100,6 +100,7 @@ export function createSearchNoteTool(ctx) {
100
100
  taskId: currentTaskId,
101
101
  messageId,
102
102
  command,
103
+ toolCallId,
103
104
  }).then(() => {
104
105
  }).catch((error) => {
105
106
  clearTimeout(timeout);
@@ -75,7 +75,7 @@ export function createSearchPhotoGalleryTool(ctx) {
75
75
  const wsManager = getXYWebSocketManager(config);
76
76
  // Search for photos
77
77
  const currentTaskId = getCurrentTaskId(sessionId) ?? taskId;
78
- const outputs = await searchPhotos(wsManager, config, sessionId, currentTaskId, messageId, params.query);
78
+ const outputs = await searchPhotos(wsManager, config, sessionId, currentTaskId, messageId, toolCallId, params.query);
79
79
  return {
80
80
  content: [
81
81
  {
@@ -91,7 +91,7 @@ export function createSearchPhotoGalleryTool(ctx) {
91
91
  * Search for photos using query description
92
92
  * Returns complete event.outputs object
93
93
  */
94
- async function searchPhotos(wsManager, config, sessionId, taskId, messageId, query) {
94
+ async function searchPhotos(wsManager, config, sessionId, taskId, messageId, toolCallId, query) {
95
95
  const command = {
96
96
  header: {
97
97
  namespace: "Common",
@@ -140,7 +140,7 @@ async function searchPhotos(wsManager, config, sessionId, taskId, messageId, que
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
  };
@@ -151,6 +151,7 @@ async function searchPhotos(wsManager, config, sessionId, taskId, messageId, que
151
151
  taskId,
152
152
  messageId,
153
153
  command,
154
+ toolCallId,
154
155
  })
155
156
  .then(() => {
156
157
  })
@@ -0,0 +1,2 @@
1
+ import type { SessionContext } from "./session-manager.js";
2
+ export declare function createSendCrossDeviceTaskTool(ctx: SessionContext): any;