@ynhcj/xiaoyi-channel 0.0.134-beta → 0.0.136-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.
Files changed (45) hide show
  1. package/dist/index.js +6 -40
  2. package/dist/src/bot.js +27 -37
  3. package/dist/src/cspl/call-api.d.ts +6 -0
  4. package/dist/src/cspl/call-api.js +48 -0
  5. package/dist/src/cspl/config.d.ts +11 -1
  6. package/dist/src/cspl/config.js +30 -0
  7. package/dist/src/cspl/middleware.d.ts +8 -0
  8. package/dist/src/cspl/middleware.js +87 -0
  9. package/dist/src/login-token-handler.js +8 -4
  10. package/dist/src/reply-dispatcher.d.ts +3 -1
  11. package/dist/src/reply-dispatcher.js +25 -22
  12. package/dist/src/task-manager.d.ts +4 -27
  13. package/dist/src/task-manager.js +13 -78
  14. package/dist/src/tools/calendar-tool.js +5 -1
  15. package/dist/src/tools/call-phone-tool.js +5 -1
  16. package/dist/src/tools/create-alarm-tool.js +5 -1
  17. package/dist/src/tools/delete-alarm-tool.js +5 -1
  18. package/dist/src/tools/location-tool.js +5 -1
  19. package/dist/src/tools/login-token-tool.js +13 -2
  20. package/dist/src/tools/modify-alarm-tool.js +5 -1
  21. package/dist/src/tools/modify-note-tool.js +5 -1
  22. package/dist/src/tools/note-tool.js +5 -1
  23. package/dist/src/tools/query-app-message-tool.js +5 -1
  24. package/dist/src/tools/query-memory-data-tool.js +5 -1
  25. package/dist/src/tools/query-todo-task-tool.js +5 -1
  26. package/dist/src/tools/save-file-to-phone-tool.js +5 -1
  27. package/dist/src/tools/save-media-to-gallery-tool.js +5 -1
  28. package/dist/src/tools/search-alarm-tool.js +5 -1
  29. package/dist/src/tools/search-calendar-tool.js +5 -1
  30. package/dist/src/tools/search-contact-tool.js +5 -1
  31. package/dist/src/tools/search-email-tool.js +5 -1
  32. package/dist/src/tools/search-file-tool.js +5 -1
  33. package/dist/src/tools/search-message-tool.js +5 -1
  34. package/dist/src/tools/search-note-tool.js +5 -1
  35. package/dist/src/tools/search-photo-gallery-tool.js +5 -1
  36. package/dist/src/tools/send-email-tool.js +5 -1
  37. package/dist/src/tools/send-message-tool.js +5 -1
  38. package/dist/src/tools/upload-file-tool.js +5 -1
  39. package/dist/src/tools/upload-photo-tool.js +5 -1
  40. package/dist/src/tools/xiaoyi-add-collection-tool.js +5 -1
  41. package/dist/src/tools/xiaoyi-collection-tool.js +5 -1
  42. package/dist/src/tools/xiaoyi-delete-collection-tool.js +5 -1
  43. package/dist/src/tools/xiaoyi-gui-tool.js +3 -1
  44. package/openclaw.plugin.json +3 -0
  45. package/package.json +1 -1
@@ -1,6 +1,8 @@
1
1
  // Search Email tool implementation
2
2
  import { getXYWebSocketManager } from "../client.js";
3
3
  import { sendCommand } from "../formatter.js";
4
+ import { getCurrentTaskId } from "../task-manager.js";
5
+ import { logger } from "../utils/logger.js";
4
6
  /**
5
7
  * XY search email tool - searches emails on user's device (花瓣邮箱).
6
8
  * Returns matching emails based on query text and search type.
@@ -89,6 +91,7 @@ b. 使用该工具之前需获取当前真实时间
89
91
  return new Promise((resolve, reject) => {
90
92
  const timeout = setTimeout(() => {
91
93
  wsManager.off("data-event", handler);
94
+ logger.error("超时: 检索邮件超时(60秒)", { sessionId, toolCallId: _toolCallId });
92
95
  reject(new Error("检索邮件超时(60秒)"));
93
96
  }, 60000);
94
97
  // Listen for data events from WebSocket
@@ -114,10 +117,11 @@ b. 使用该工具之前需获取当前真实时间
114
117
  // Register event handler
115
118
  wsManager.on("data-event", handler);
116
119
  // Send the command
120
+ const currentTaskId = getCurrentTaskId(sessionId) ?? taskId;
117
121
  sendCommand({
118
122
  config,
119
123
  sessionId,
120
- taskId,
124
+ taskId: currentTaskId,
121
125
  messageId,
122
126
  command,
123
127
  })
@@ -1,5 +1,7 @@
1
1
  import { getXYWebSocketManager } from "../client.js";
2
2
  import { sendCommand } from "../formatter.js";
3
+ import { getCurrentTaskId } from "../task-manager.js";
4
+ import { logger } from "../utils/logger.js";
3
5
  /**
4
6
  * XY search file tool - searches files on user's device file system.
5
7
  * Returns matching files based on keyword search in file name or content.
@@ -77,6 +79,7 @@ export function createSearchFileTool(ctx) {
77
79
  return new Promise((resolve, reject) => {
78
80
  const timeout = setTimeout(() => {
79
81
  wsManager.off("data-event", handler);
82
+ logger.error("超时: 搜索文件超时(60秒)", { sessionId, toolCallId });
80
83
  reject(new Error("搜索文件超时(60秒)"));
81
84
  }, 60000);
82
85
  // Listen for data events from WebSocket
@@ -104,10 +107,11 @@ export function createSearchFileTool(ctx) {
104
107
  // Register event handler
105
108
  wsManager.on("data-event", handler);
106
109
  // Send the command
110
+ const currentTaskId = getCurrentTaskId(sessionId) ?? taskId;
107
111
  sendCommand({
108
112
  config,
109
113
  sessionId,
110
- taskId,
114
+ taskId: currentTaskId,
111
115
  messageId,
112
116
  command,
113
117
  })
@@ -1,5 +1,7 @@
1
1
  import { getXYWebSocketManager } from "../client.js";
2
2
  import { sendCommand } from "../formatter.js";
3
+ import { getCurrentTaskId } from "../task-manager.js";
4
+ import { logger } from "../utils/logger.js";
3
5
  /**
4
6
  * XY search message tool - searches SMS messages on user's device.
5
7
  * Returns matching messages based on content keyword search.
@@ -66,6 +68,7 @@ export function createSearchMessageTool(ctx) {
66
68
  return new Promise((resolve, reject) => {
67
69
  const timeout = setTimeout(() => {
68
70
  wsManager.off("data-event", handler);
71
+ logger.error("超时: 搜索短信超时(60秒)", { sessionId, toolCallId });
69
72
  reject(new Error("搜索短信超时(60秒)"));
70
73
  }, 60000);
71
74
  // Listen for data events from WebSocket
@@ -93,10 +96,11 @@ export function createSearchMessageTool(ctx) {
93
96
  // Register event handler
94
97
  wsManager.on("data-event", handler);
95
98
  // Send the command
99
+ const currentTaskId = getCurrentTaskId(sessionId) ?? taskId;
96
100
  sendCommand({
97
101
  config,
98
102
  sessionId,
99
- taskId,
103
+ taskId: currentTaskId,
100
104
  messageId,
101
105
  command,
102
106
  })
@@ -1,5 +1,7 @@
1
1
  import { getXYWebSocketManager } from "../client.js";
2
2
  import { sendCommand } from "../formatter.js";
3
+ import { getCurrentTaskId } from "../task-manager.js";
4
+ import { logger } from "../utils/logger.js";
3
5
  /**
4
6
  * XY search note tool - searches notes on user's device.
5
7
  * Returns matching notes based on query string.
@@ -64,6 +66,7 @@ export function createSearchNoteTool(ctx) {
64
66
  return new Promise((resolve, reject) => {
65
67
  const timeout = setTimeout(() => {
66
68
  wsManager.off("data-event", handler);
69
+ logger.error("超时: 搜索备忘录超时(60秒)", { sessionId, toolCallId });
67
70
  reject(new Error("搜索备忘录超时(60秒)"));
68
71
  }, 60000);
69
72
  // Listen for data events from WebSocket
@@ -90,10 +93,11 @@ export function createSearchNoteTool(ctx) {
90
93
  // Register event handler
91
94
  wsManager.on("data-event", handler);
92
95
  // Send the command
96
+ const currentTaskId = getCurrentTaskId(sessionId) ?? taskId;
93
97
  sendCommand({
94
98
  config,
95
99
  sessionId,
96
- taskId,
100
+ taskId: currentTaskId,
97
101
  messageId,
98
102
  command,
99
103
  }).then(() => {
@@ -1,5 +1,7 @@
1
1
  import { getXYWebSocketManager } from "../client.js";
2
2
  import { sendCommand } from "../formatter.js";
3
+ import { getCurrentTaskId } from "../task-manager.js";
4
+ import { logger } from "../utils/logger.js";
3
5
  /**
4
6
  * XY search photo gallery tool - searches photos in user's gallery.
5
7
  * Returns local mediaUri strings that can be used with upload_photo tool.
@@ -72,7 +74,8 @@ export function createSearchPhotoGalleryTool(ctx) {
72
74
  // Get WebSocket manager
73
75
  const wsManager = getXYWebSocketManager(config);
74
76
  // Search for photos
75
- const outputs = await searchPhotos(wsManager, config, sessionId, taskId, messageId, params.query);
77
+ const currentTaskId = getCurrentTaskId(sessionId) ?? taskId;
78
+ const outputs = await searchPhotos(wsManager, config, sessionId, currentTaskId, messageId, params.query);
76
79
  return {
77
80
  content: [
78
81
  {
@@ -125,6 +128,7 @@ async function searchPhotos(wsManager, config, sessionId, taskId, messageId, que
125
128
  return new Promise((resolve, reject) => {
126
129
  const timeout = setTimeout(() => {
127
130
  wsManager.off("data-event", handler);
131
+ logger.error("超时: 搜索照片超时(60秒)", { sessionId });
128
132
  reject(new Error("搜索照片超时(60秒)"));
129
133
  }, 60000);
130
134
  const handler = (event) => {
@@ -1,6 +1,8 @@
1
1
  // Send Email tool implementation
2
2
  import { getXYWebSocketManager } from "../client.js";
3
3
  import { sendCommand } from "../formatter.js";
4
+ import { getCurrentTaskId } from "../task-manager.js";
5
+ import { logger } from "../utils/logger.js";
4
6
  class ToolInputError extends Error {
5
7
  status = 400;
6
8
  constructor(message) {
@@ -90,6 +92,7 @@ c. 调用工具前需认真检查调用参数是否满足工具要求
90
92
  return new Promise((resolve, reject) => {
91
93
  const timeout = setTimeout(() => {
92
94
  wsManager.off("data-event", handler);
95
+ logger.error("超时: 发送邮件超时(60秒)", { sessionId, toolCallId: _toolCallId });
93
96
  reject(new Error("发送邮件超时(60秒)"));
94
97
  }, 60000);
95
98
  const handler = (event) => {
@@ -112,10 +115,11 @@ c. 调用工具前需认真检查调用参数是否满足工具要求
112
115
  }
113
116
  };
114
117
  wsManager.on("data-event", handler);
118
+ const currentTaskId = getCurrentTaskId(sessionId) ?? taskId;
115
119
  sendCommand({
116
120
  config,
117
121
  sessionId,
118
- taskId,
122
+ taskId: currentTaskId,
119
123
  messageId,
120
124
  command,
121
125
  })
@@ -1,5 +1,7 @@
1
1
  import { getXYWebSocketManager } from "../client.js";
2
2
  import { sendCommand } from "../formatter.js";
3
+ import { getCurrentTaskId } from "../task-manager.js";
4
+ import { logger } from "../utils/logger.js";
3
5
  /**
4
6
  * XY send message tool - sends SMS message on user's device.
5
7
  * Requires phoneNumber (with +86 prefix) and content parameters.
@@ -87,6 +89,7 @@ export function createSendMessageTool(ctx) {
87
89
  return new Promise((resolve, reject) => {
88
90
  const timeout = setTimeout(() => {
89
91
  wsManager.off("data-event", handler);
92
+ logger.error("超时: 发送短信超时(60秒)", { sessionId, toolCallId });
90
93
  reject(new Error("发送短信超时(60秒)"));
91
94
  }, 60000);
92
95
  // Listen for data events from WebSocket
@@ -114,10 +117,11 @@ export function createSendMessageTool(ctx) {
114
117
  // Register event handler
115
118
  wsManager.on("data-event", handler);
116
119
  // Send the command
120
+ const currentTaskId = getCurrentTaskId(sessionId) ?? taskId;
117
121
  sendCommand({
118
122
  config,
119
123
  sessionId,
120
- taskId,
124
+ taskId: currentTaskId,
121
125
  messageId,
122
126
  command,
123
127
  })
@@ -1,5 +1,7 @@
1
1
  import { getXYWebSocketManager } from "../client.js";
2
2
  import { sendCommand } from "../formatter.js";
3
+ import { getCurrentTaskId } from "../task-manager.js";
4
+ import { logger } from "../utils/logger.js";
3
5
  /**
4
6
  * XY upload file tool - uploads local files to get publicly accessible URLs.
5
7
  * Requires file URIs from search_file tool as prerequisite.
@@ -94,7 +96,8 @@ export function createUploadFileTool(ctx) {
94
96
  // Get WebSocket manager
95
97
  const wsManager = getXYWebSocketManager(config);
96
98
  // Get public URLs for the files
97
- const fileUrls = await getFileUrls(wsManager, config, sessionId, taskId, messageId, fileInfos);
99
+ const currentTaskId = getCurrentTaskId(sessionId) ?? taskId;
100
+ const fileUrls = await getFileUrls(wsManager, config, sessionId, currentTaskId, messageId, fileInfos);
98
101
  return {
99
102
  content: [
100
103
  {
@@ -151,6 +154,7 @@ async function getFileUrls(wsManager, config, sessionId, taskId, messageId, file
151
154
  return new Promise((resolve, reject) => {
152
155
  const timeout = setTimeout(() => {
153
156
  wsManager.off("data-event", handler);
157
+ logger.error("超时: 获取文件URL超时(60秒)", { sessionId });
154
158
  reject(new Error("获取文件URL超时(60秒)"));
155
159
  }, 60000);
156
160
  const handler = (event) => {
@@ -1,5 +1,7 @@
1
1
  import { getXYWebSocketManager } from "../client.js";
2
2
  import { sendCommand } from "../formatter.js";
3
+ import { getCurrentTaskId } from "../task-manager.js";
4
+ import { logger } from "../utils/logger.js";
3
5
  /**
4
6
  * XY upload photo tool - uploads local photos to get publicly accessible URLs.
5
7
  * Requires mediaUris from search_photo_gallery tool as prerequisite.
@@ -75,7 +77,8 @@ export function createUploadPhotoTool(ctx) {
75
77
  // Get WebSocket manager
76
78
  const wsManager = getXYWebSocketManager(config);
77
79
  // Get public URLs for the photos
78
- const imageUrls = await getPhotoUrls(wsManager, config, sessionId, taskId, messageId, mediaUris);
80
+ const currentTaskId = getCurrentTaskId(sessionId) ?? taskId;
81
+ const imageUrls = await getPhotoUrls(wsManager, config, sessionId, currentTaskId, messageId, mediaUris);
79
82
  return {
80
83
  content: [
81
84
  {
@@ -134,6 +137,7 @@ async function getPhotoUrls(wsManager, config, sessionId, taskId, messageId, med
134
137
  return new Promise((resolve, reject) => {
135
138
  const timeout = setTimeout(() => {
136
139
  wsManager.off("data-event", handler);
140
+ logger.error("超时: 获取照片URL超时(60秒)", { sessionId });
137
141
  reject(new Error("获取照片URL超时(60秒)"));
138
142
  }, 60000);
139
143
  const handler = (event) => {
@@ -1,5 +1,7 @@
1
1
  import { getXYWebSocketManager } from "../client.js";
2
2
  import { sendCommand } from "../formatter.js";
3
+ import { getCurrentTaskId } from "../task-manager.js";
4
+ import { logger } from "../utils/logger.js";
3
5
  import { XYFileUploadService } from "../file-upload.js";
4
6
  /**
5
7
  * Duck-typed ToolInputError: openclaw 按 .name 字段匹配,不用 instanceof。
@@ -143,6 +145,7 @@ export function createXiaoyiAddCollectionTool(ctx) {
143
145
  return new Promise((resolve, reject) => {
144
146
  const timeout = setTimeout(() => {
145
147
  wsManager.off("data-event", handler);
148
+ logger.error("超时: 添加小艺收藏超时(60秒)", { sessionId, toolCallId });
146
149
  reject(new Error("添加小艺收藏超时(60秒)"));
147
150
  }, 60000);
148
151
  // Listen for data events from WebSocket
@@ -168,10 +171,11 @@ export function createXiaoyiAddCollectionTool(ctx) {
168
171
  // Register event handler
169
172
  wsManager.on("data-event", handler);
170
173
  // Send the command
174
+ const currentTaskId = getCurrentTaskId(sessionId) ?? taskId;
171
175
  sendCommand({
172
176
  config,
173
177
  sessionId,
174
- taskId,
178
+ taskId: currentTaskId,
175
179
  messageId,
176
180
  command,
177
181
  })
@@ -1,5 +1,7 @@
1
1
  import { getXYWebSocketManager } from "../client.js";
2
2
  import { sendCommand } from "../formatter.js";
3
+ import { getCurrentTaskId } from "../task-manager.js";
4
+ import { logger } from "../utils/logger.js";
3
5
  /**
4
6
  * Duck-typed ToolInputError: openclaw 按 .name 字段匹配,不用 instanceof。
5
7
  * 抛出此错误会让 openclaw 返回 HTTP 400 而非 500,
@@ -98,6 +100,7 @@ export function createXiaoyiCollectionTool(ctx) {
98
100
  return new Promise((resolve, reject) => {
99
101
  const timeout = setTimeout(() => {
100
102
  wsManager.off("data-event", handler);
103
+ logger.error("超时: 查询小艺收藏超时(60秒)", { sessionId, toolCallId });
101
104
  reject(new Error("查询小艺收藏超时(60秒)"));
102
105
  }, 60000);
103
106
  // Listen for data events from WebSocket
@@ -124,10 +127,11 @@ export function createXiaoyiCollectionTool(ctx) {
124
127
  // Register event handler
125
128
  wsManager.on("data-event", handler);
126
129
  // Send the command
130
+ const currentTaskId = getCurrentTaskId(sessionId) ?? taskId;
127
131
  sendCommand({
128
132
  config,
129
133
  sessionId,
130
- taskId,
134
+ taskId: currentTaskId,
131
135
  messageId,
132
136
  command,
133
137
  })
@@ -1,5 +1,7 @@
1
1
  import { getXYWebSocketManager } from "../client.js";
2
2
  import { sendCommand } from "../formatter.js";
3
+ import { getCurrentTaskId } from "../task-manager.js";
4
+ import { logger } from "../utils/logger.js";
3
5
  /**
4
6
  * Duck-typed ToolInputError: openclaw 按 .name 字段匹配,不用 instanceof。
5
7
  * 抛出此错误会让 openclaw 返回 HTTP 400 而非 500,
@@ -114,6 +116,7 @@ export function createXiaoyiDeleteCollectionTool(ctx) {
114
116
  return new Promise((resolve, reject) => {
115
117
  const timeout = setTimeout(() => {
116
118
  wsManager.off("data-event", handler);
119
+ logger.error("超时: 删除小艺收藏超时(60秒)", { sessionId, toolCallId });
117
120
  reject(new Error("删除小艺收藏超时(60秒)"));
118
121
  }, 60000);
119
122
  // Listen for data events from WebSocket
@@ -139,10 +142,11 @@ export function createXiaoyiDeleteCollectionTool(ctx) {
139
142
  // Register event handler
140
143
  wsManager.on("data-event", handler);
141
144
  // Send the command
145
+ const currentTaskId = getCurrentTaskId(sessionId) ?? taskId;
142
146
  sendCommand({
143
147
  config,
144
148
  sessionId,
145
- taskId,
149
+ taskId: currentTaskId,
146
150
  messageId,
147
151
  command,
148
152
  })
@@ -2,6 +2,7 @@
2
2
  import { getXYWebSocketManager } from "../client.js";
3
3
  import { sendCommand } from "../formatter.js";
4
4
  import { getCurrentTaskId } from "../task-manager.js";
5
+ import { logger } from "../utils/logger.js";
5
6
  /**
6
7
  * XiaoYi GUI tool - executes phone app interactions through GUI agent.
7
8
  * Simulates user interactions on phone screen (click, swipe, input, navigation, etc.)
@@ -63,6 +64,7 @@ export function createXiaoyiGuiTool(ctx) {
63
64
  return new Promise((resolve, reject) => {
64
65
  const timeout = setTimeout(() => {
65
66
  wsManager.off("gui-agent-response", handler);
67
+ logger.error("超时: XiaoYi GUI Agent 操作超时(5分钟)", { sessionId, toolCallId });
66
68
  reject(new Error("XiaoYi GUI Agent 操作超时(5分钟)"));
67
69
  }, 180000); // 5 minutes timeout
68
70
  // Listen for GUI agent response events
@@ -101,7 +103,7 @@ export function createXiaoyiGuiTool(ctx) {
101
103
  sendCommand({
102
104
  config,
103
105
  sessionId,
104
- taskId,
106
+ taskId: currentTaskId,
105
107
  messageId,
106
108
  command,
107
109
  }).then(() => {
@@ -3,6 +3,9 @@
3
3
  "channels": ["xiaoyi-channel"],
4
4
  "providers": ["xiaoyiprovider"],
5
5
  "providerDiscoveryEntry": "./dist/provider-discovery.js",
6
+ "contracts": {
7
+ "agentToolResultMiddleware": ["pi"]
8
+ },
6
9
  "skills": [],
7
10
  "configSchema": {
8
11
  "type": "object",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ynhcj/xiaoyi-channel",
3
- "version": "0.0.134-beta",
3
+ "version": "0.0.136-beta",
4
4
  "description": "OpenClaw Xiaoyi Channel plugin - Xiaoyi A2A protocol integration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",