@ynhcj/xiaoyi-channel 0.0.97-beta → 0.0.97-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 (140) hide show
  1. package/dist/index.d.ts +6 -9
  2. package/dist/index.js +26 -21
  3. package/dist/provider-discovery.d.ts +2 -0
  4. package/dist/provider-discovery.js +4 -0
  5. package/dist/src/bot.js +29 -4
  6. package/dist/src/channel.js +2 -19
  7. package/dist/src/client.js +31 -22
  8. package/dist/src/cspl/call-api.js +6 -5
  9. package/dist/src/file-download.js +4 -3
  10. package/dist/src/file-upload.js +19 -18
  11. package/dist/src/formatter.d.ts +2 -0
  12. package/dist/src/formatter.js +9 -28
  13. package/dist/src/heartbeat.js +1 -1
  14. package/dist/src/login-token-handler.d.ts +8 -0
  15. package/dist/src/login-token-handler.js +60 -0
  16. package/dist/src/message-queue.d.ts +17 -0
  17. package/dist/src/message-queue.js +51 -0
  18. package/dist/src/monitor.js +70 -14
  19. package/dist/src/outbound.js +19 -18
  20. package/dist/src/provider.d.ts +2 -1
  21. package/dist/src/provider.js +245 -38
  22. package/dist/src/push.js +16 -15
  23. package/dist/src/reply-dispatcher.js +12 -3
  24. package/dist/src/runtime.d.ts +3 -11
  25. package/dist/src/runtime.js +6 -18
  26. package/dist/src/self-evolution-handler.d.ts +6 -0
  27. package/dist/src/self-evolution-handler.js +100 -7
  28. package/dist/src/self-evolution-keyword.d.ts +9 -0
  29. package/dist/src/self-evolution-keyword.js +147 -0
  30. package/dist/src/self-evolution-tool-result-nudge.d.ts +3 -0
  31. package/dist/src/self-evolution-tool-result-nudge.js +96 -0
  32. package/dist/src/skill-retriever/config.d.ts +4 -0
  33. package/dist/src/skill-retriever/config.js +23 -0
  34. package/dist/src/skill-retriever/hooks.d.ts +22 -0
  35. package/dist/src/skill-retriever/hooks.js +83 -0
  36. package/dist/src/skill-retriever/tool-search.d.ts +16 -0
  37. package/dist/src/skill-retriever/tool-search.js +173 -0
  38. package/dist/src/skill-retriever/types.d.ts +36 -0
  39. package/dist/src/skill-retriever/types.js +1 -0
  40. package/dist/src/steer-injector.js +1 -1
  41. package/dist/src/task-manager.d.ts +4 -0
  42. package/dist/src/task-manager.js +12 -1
  43. package/dist/src/tools/calendar-tool.d.ts +2 -1
  44. package/dist/src/tools/calendar-tool.js +112 -116
  45. package/dist/src/tools/call-device-tool.d.ts +2 -1
  46. package/dist/src/tools/call-device-tool.js +126 -103
  47. package/dist/src/tools/call-phone-tool.d.ts +2 -1
  48. package/dist/src/tools/call-phone-tool.js +109 -113
  49. package/dist/src/tools/create-alarm-tool.d.ts +2 -1
  50. package/dist/src/tools/create-alarm-tool.js +227 -231
  51. package/dist/src/tools/create-all-tools.d.ts +16 -0
  52. package/dist/src/tools/create-all-tools.js +50 -0
  53. package/dist/src/tools/delete-alarm-tool.d.ts +2 -1
  54. package/dist/src/tools/delete-alarm-tool.js +131 -135
  55. package/dist/src/tools/get-alarm-tool-schema.d.ts +2 -1
  56. package/dist/src/tools/get-alarm-tool-schema.js +16 -10
  57. package/dist/src/tools/get-calendar-tool-schema.d.ts +2 -1
  58. package/dist/src/tools/get-calendar-tool-schema.js +12 -8
  59. package/dist/src/tools/get-collection-tool-schema.d.ts +2 -1
  60. package/dist/src/tools/get-collection-tool-schema.js +11 -9
  61. package/dist/src/tools/get-contact-tool-schema.d.ts +2 -1
  62. package/dist/src/tools/get-contact-tool-schema.js +16 -10
  63. package/dist/src/tools/get-device-file-tool-schema.d.ts +2 -1
  64. package/dist/src/tools/get-device-file-tool-schema.js +13 -9
  65. package/dist/src/tools/get-email-tool-schema.d.ts +2 -1
  66. package/dist/src/tools/get-email-tool-schema.js +11 -8
  67. package/dist/src/tools/get-note-tool-schema.d.ts +2 -1
  68. package/dist/src/tools/get-note-tool-schema.js +14 -9
  69. package/dist/src/tools/get-photo-tool-schema.d.ts +2 -1
  70. package/dist/src/tools/get-photo-tool-schema.js +12 -9
  71. package/dist/src/tools/image-reading-tool.d.ts +2 -1
  72. package/dist/src/tools/image-reading-tool.js +86 -90
  73. package/dist/src/tools/location-tool.d.ts +2 -1
  74. package/dist/src/tools/location-tool.js +87 -91
  75. package/dist/src/tools/login-token-tool.d.ts +6 -0
  76. package/dist/src/tools/login-token-tool.js +133 -0
  77. package/dist/src/tools/modify-alarm-tool.d.ts +2 -1
  78. package/dist/src/tools/modify-alarm-tool.js +232 -236
  79. package/dist/src/tools/modify-note-tool.d.ts +2 -1
  80. package/dist/src/tools/modify-note-tool.js +104 -108
  81. package/dist/src/tools/note-tool.d.ts +2 -1
  82. package/dist/src/tools/note-tool.js +103 -107
  83. package/dist/src/tools/query-app-message-tool.d.ts +2 -1
  84. package/dist/src/tools/query-app-message-tool.js +108 -111
  85. package/dist/src/tools/query-memory-data-tool.d.ts +2 -1
  86. package/dist/src/tools/query-memory-data-tool.js +109 -112
  87. package/dist/src/tools/query-todo-task-tool.d.ts +2 -1
  88. package/dist/src/tools/query-todo-task-tool.js +103 -106
  89. package/dist/src/tools/save-file-to-phone-tool.d.ts +2 -1
  90. package/dist/src/tools/save-file-to-phone-tool.js +127 -131
  91. package/dist/src/tools/save-media-to-gallery-tool.d.ts +2 -1
  92. package/dist/src/tools/save-media-to-gallery-tool.js +134 -138
  93. package/dist/src/tools/save-self-evolution-skill-tool.d.ts +2 -0
  94. package/dist/src/tools/save-self-evolution-skill-tool.js +410 -0
  95. package/dist/src/tools/search-alarm-tool.d.ts +2 -1
  96. package/dist/src/tools/search-alarm-tool.js +171 -175
  97. package/dist/src/tools/search-calendar-tool.d.ts +2 -1
  98. package/dist/src/tools/search-calendar-tool.js +145 -149
  99. package/dist/src/tools/search-contact-tool.d.ts +2 -1
  100. package/dist/src/tools/search-contact-tool.js +98 -102
  101. package/dist/src/tools/search-email-tool.d.ts +2 -1
  102. package/dist/src/tools/search-email-tool.js +107 -111
  103. package/dist/src/tools/search-file-tool.d.ts +2 -1
  104. package/dist/src/tools/search-file-tool.js +99 -103
  105. package/dist/src/tools/search-message-tool.d.ts +2 -1
  106. package/dist/src/tools/search-message-tool.js +100 -104
  107. package/dist/src/tools/search-note-tool.d.ts +2 -1
  108. package/dist/src/tools/search-note-tool.js +95 -99
  109. package/dist/src/tools/search-photo-gallery-tool.d.ts +2 -1
  110. package/dist/src/tools/search-photo-gallery-tool.js +34 -38
  111. package/dist/src/tools/send-email-tool.d.ts +2 -1
  112. package/dist/src/tools/send-email-tool.js +105 -108
  113. package/dist/src/tools/send-file-to-user-tool.d.ts +2 -1
  114. package/dist/src/tools/send-file-to-user-tool.js +154 -155
  115. package/dist/src/tools/send-message-tool.d.ts +2 -1
  116. package/dist/src/tools/send-message-tool.js +119 -123
  117. package/dist/src/tools/session-manager.d.ts +21 -6
  118. package/dist/src/tools/session-manager.js +147 -18
  119. package/dist/src/tools/upload-file-tool.d.ts +2 -1
  120. package/dist/src/tools/upload-file-tool.js +78 -82
  121. package/dist/src/tools/upload-photo-tool.d.ts +2 -1
  122. package/dist/src/tools/upload-photo-tool.js +69 -73
  123. package/dist/src/tools/xiaoyi-add-collection-tool.d.ts +2 -1
  124. package/dist/src/tools/xiaoyi-add-collection-tool.js +143 -147
  125. package/dist/src/tools/xiaoyi-collection-tool.d.ts +2 -1
  126. package/dist/src/tools/xiaoyi-collection-tool.js +111 -115
  127. package/dist/src/tools/xiaoyi-delete-collection-tool.d.ts +2 -1
  128. package/dist/src/tools/xiaoyi-delete-collection-tool.js +124 -128
  129. package/dist/src/tools/xiaoyi-gui-tool.d.ts +2 -1
  130. package/dist/src/tools/xiaoyi-gui-tool.js +84 -88
  131. package/dist/src/utils/logger.js +20 -18
  132. package/dist/src/utils/runtime-manager.js +24 -2
  133. package/dist/src/utils/self-evolution-manager.d.ts +10 -0
  134. package/dist/src/utils/self-evolution-manager.js +69 -0
  135. package/dist/src/utils/tool-call-nudge-manager.d.ts +16 -0
  136. package/dist/src/utils/tool-call-nudge-manager.js +47 -0
  137. package/dist/src/websocket.d.ts +3 -0
  138. package/dist/src/websocket.js +91 -26
  139. package/openclaw.plugin.json +22 -0
  140. package/package.json +3 -3
@@ -1,6 +1,5 @@
1
1
  import { getXYWebSocketManager } from "../client.js";
2
2
  import { sendCommand } from "../formatter.js";
3
- import { getCurrentSessionContext } from "./session-manager.js";
4
3
  // Enum definitions for alarm search parameters
5
4
  const RANGE_TYPE_VALUES = ["all", "next", "current"];
6
5
  const ALARM_STATE_VALUES = [0, 1];
@@ -12,10 +11,12 @@ const DAYS_OF_WAKE_TYPE_VALUES = [0, 1, 2, 3, 4];
12
11
  * At least one search criterion must be provided.
13
12
  * Multiple criteria can be combined.
14
13
  */
15
- export const searchAlarmTool = {
16
- name: "search_alarm",
17
- label: "Search Alarm",
18
- description: `检索用户设备上的闹钟。至少需要提供一个检索条件,多个条件可以组合使用。
14
+ export function createSearchAlarmTool(ctx) {
15
+ const { config, sessionId, taskId, messageId } = ctx;
16
+ return {
17
+ name: "search_alarm",
18
+ label: "Search Alarm",
19
+ description: `检索用户设备上的闹钟。至少需要提供一个检索条件,多个条件可以组合使用。
19
20
 
20
21
  使用示例:
21
22
  - 查询所有闹钟:{"rangeType": "all"}
@@ -28,192 +29,187 @@ a. 操作超时时间为60秒,请勿重复调用此工具,如果超时或失
28
29
  b. 使用该工具之前需获取当前真实时间
29
30
 
30
31
  回复约束:如果工具返回没有授权或者其他报错,只需要完整描述没有授权或者其他报错内容即可,不需要主动给用户提供解决方案,例如告诉用户如何授权,如何解决报错等都是不需要的,请严格遵守。`,
31
- parameters: {
32
- type: "object",
33
- properties: {
34
- rangeType: {
35
- type: "string",
36
- enum: ["all", "next", "current"],
37
- description: "(检索条件之一)查询范围,枚举值:all=查询所有闹钟,next=查找下一个响铃闹钟,current=一小时内最近一次增查改的闹钟",
38
- },
39
- alarmState: {
40
- type: "number",
41
- enum: [0, 1],
42
- description: "(检索条件之一)闹钟开启状态,枚举值:0=关闭,1=开启",
43
- },
44
- daysOfWakeType: {
45
- type: "number",
46
- enum: [0, 1, 2, 3, 4],
47
- description: "(检索条件之一)闹钟响铃类型,枚举值:0=单次响铃,1=法定节假日,2=每天,3=自定义时间,4=法定工作日",
48
- },
49
- startTime: {
50
- type: "string",
51
- description: "(检索条件之一)时间间隔开始,格式 YYYYMMDD hhmmss(例如:20240315 000000),必须与 endTime 一起使用",
52
- },
53
- endTime: {
54
- type: "string",
55
- description: "(检索条件之一)时间间隔结束,格式 YYYYMMDD hhmmss(例如:20240315 235959),必须与 startTime 一起使用",
32
+ parameters: {
33
+ type: "object",
34
+ properties: {
35
+ rangeType: {
36
+ type: "string",
37
+ enum: ["all", "next", "current"],
38
+ description: "(检索条件之一)查询范围,枚举值:all=查询所有闹钟,next=查找下一个响铃闹钟,current=一小时内最近一次增查改的闹钟",
39
+ },
40
+ alarmState: {
41
+ type: "number",
42
+ enum: [0, 1],
43
+ description: "(检索条件之一)闹钟开启状态,枚举值:0=关闭,1=开启",
44
+ },
45
+ daysOfWakeType: {
46
+ type: "number",
47
+ enum: [0, 1, 2, 3, 4],
48
+ description: "(检索条件之一)闹钟响铃类型,枚举值:0=单次响铃,1=法定节假日,2=每天,3=自定义时间,4=法定工作日",
49
+ },
50
+ startTime: {
51
+ type: "string",
52
+ description: "(检索条件之一)时间间隔开始,格式 YYYYMMDD hhmmss(例如:20240315 000000),必须与 endTime 一起使用",
53
+ },
54
+ endTime: {
55
+ type: "string",
56
+ description: "(检索条件之一)时间间隔结束,格式 YYYYMMDD hhmmss(例如:20240315 235959),必须与 startTime 一起使用",
57
+ },
56
58
  },
57
59
  },
58
- },
59
- async execute(toolCallId, params) {
60
- // ===== Validate at least one search criterion is provided =====
61
- const hasRangeType = params.rangeType !== undefined && params.rangeType !== null;
62
- const hasAlarmState = params.alarmState !== undefined && params.alarmState !== null;
63
- const hasDaysOfWakeType = params.daysOfWakeType !== undefined && params.daysOfWakeType !== null;
64
- const hasStartTime = params.startTime !== undefined && params.startTime !== null;
65
- const hasEndTime = params.endTime !== undefined && params.endTime !== null;
66
- if (!hasRangeType && !hasAlarmState && !hasDaysOfWakeType && !hasStartTime && !hasEndTime) {
67
- throw new Error("至少需要提供一个检索条件:rangeType、alarmState、daysOfWakeType 或时间范围(startTime + endTime)");
68
- }
69
- // ===== Validate rangeType =====
70
- if (hasRangeType) {
71
- if (typeof params.rangeType !== "string") {
72
- throw new Error("rangeType must be a string");
60
+ async execute(toolCallId, params) {
61
+ // ===== Validate at least one search criterion is provided =====
62
+ const hasRangeType = params.rangeType !== undefined && params.rangeType !== null;
63
+ const hasAlarmState = params.alarmState !== undefined && params.alarmState !== null;
64
+ const hasDaysOfWakeType = params.daysOfWakeType !== undefined && params.daysOfWakeType !== null;
65
+ const hasStartTime = params.startTime !== undefined && params.startTime !== null;
66
+ const hasEndTime = params.endTime !== undefined && params.endTime !== null;
67
+ if (!hasRangeType && !hasAlarmState && !hasDaysOfWakeType && !hasStartTime && !hasEndTime) {
68
+ throw new Error("至少需要提供一个检索条件:rangeType、alarmState、daysOfWakeType 或时间范围(startTime + endTime)");
73
69
  }
74
- if (!RANGE_TYPE_VALUES.includes(params.rangeType)) {
75
- throw new Error(`rangeType must be one of: ${RANGE_TYPE_VALUES.join(", ")}`);
70
+ // ===== Validate rangeType =====
71
+ if (hasRangeType) {
72
+ if (typeof params.rangeType !== "string") {
73
+ throw new Error("rangeType must be a string");
74
+ }
75
+ if (!RANGE_TYPE_VALUES.includes(params.rangeType)) {
76
+ throw new Error(`rangeType must be one of: ${RANGE_TYPE_VALUES.join(", ")}`);
77
+ }
76
78
  }
77
- }
78
- // ===== Validate alarmState =====
79
- if (hasAlarmState) {
80
- if (typeof params.alarmState !== "number") {
81
- throw new Error("alarmState must be a number");
79
+ // ===== Validate alarmState =====
80
+ if (hasAlarmState) {
81
+ if (typeof params.alarmState !== "number") {
82
+ throw new Error("alarmState must be a number");
83
+ }
84
+ if (!ALARM_STATE_VALUES.includes(params.alarmState)) {
85
+ throw new Error(`alarmState must be one of: ${ALARM_STATE_VALUES.join(", ")}`);
86
+ }
87
+ }
88
+ // ===== Validate daysOfWakeType =====
89
+ if (hasDaysOfWakeType) {
90
+ if (typeof params.daysOfWakeType !== "number") {
91
+ throw new Error("daysOfWakeType must be a number");
92
+ }
93
+ if (!DAYS_OF_WAKE_TYPE_VALUES.includes(params.daysOfWakeType)) {
94
+ throw new Error(`daysOfWakeType must be one of: ${DAYS_OF_WAKE_TYPE_VALUES.join(", ")}`);
95
+ }
82
96
  }
83
- if (!ALARM_STATE_VALUES.includes(params.alarmState)) {
84
- throw new Error(`alarmState must be one of: ${ALARM_STATE_VALUES.join(", ")}`);
97
+ // ===== Validate time interval (startTime and endTime must be provided together) =====
98
+ if (hasStartTime !== hasEndTime) {
99
+ throw new Error("startTime 和 endTime 必须一起提供");
85
100
  }
86
- }
87
- // ===== Validate daysOfWakeType =====
88
- if (hasDaysOfWakeType) {
89
- if (typeof params.daysOfWakeType !== "number") {
90
- throw new Error("daysOfWakeType must be a number");
101
+ let timeInterval = null;
102
+ if (hasStartTime && hasEndTime) {
103
+ // Parse and convert startTime and endTime to timestamps
104
+ const startTimeMs = parseAlarmTimeToTimestamp(params.startTime);
105
+ const endTimeMs = parseAlarmTimeToTimestamp(params.endTime);
106
+ if (startTimeMs === null) {
107
+ throw new Error("Invalid startTime format. Required format: YYYYMMDD hhmmss (e.g., 20240315 000000)");
108
+ }
109
+ if (endTimeMs === null) {
110
+ throw new Error("Invalid endTime format. Required format: YYYYMMDD hhmmss (e.g., 20240315 235959)");
111
+ }
112
+ if (startTimeMs >= endTimeMs) {
113
+ throw new Error("startTime 必须早于 endTime");
114
+ }
115
+ timeInterval = [startTimeMs, endTimeMs];
91
116
  }
92
- if (!DAYS_OF_WAKE_TYPE_VALUES.includes(params.daysOfWakeType)) {
93
- throw new Error(`daysOfWakeType must be one of: ${DAYS_OF_WAKE_TYPE_VALUES.join(", ")}`);
117
+ // Get WebSocket manager
118
+ const wsManager = getXYWebSocketManager(config);
119
+ // Build SearchAlarm command
120
+ // Build intentParam with provided search criteria
121
+ const intentParam = {};
122
+ if (hasRangeType) {
123
+ intentParam.rangeType = params.rangeType;
94
124
  }
95
- }
96
- // ===== Validate time interval (startTime and endTime must be provided together) =====
97
- if (hasStartTime !== hasEndTime) {
98
- throw new Error("startTime 和 endTime 必须一起提供");
99
- }
100
- let timeInterval = null;
101
- if (hasStartTime && hasEndTime) {
102
- // Parse and convert startTime and endTime to timestamps
103
- const startTimeMs = parseAlarmTimeToTimestamp(params.startTime);
104
- const endTimeMs = parseAlarmTimeToTimestamp(params.endTime);
105
- if (startTimeMs === null) {
106
- throw new Error("Invalid startTime format. Required format: YYYYMMDD hhmmss (e.g., 20240315 000000)");
125
+ if (hasAlarmState) {
126
+ intentParam.alarmState = params.alarmState;
107
127
  }
108
- if (endTimeMs === null) {
109
- throw new Error("Invalid endTime format. Required format: YYYYMMDD hhmmss (e.g., 20240315 235959)");
128
+ if (hasDaysOfWakeType) {
129
+ intentParam.daysOfWakeType = params.daysOfWakeType;
110
130
  }
111
- if (startTimeMs >= endTimeMs) {
112
- throw new Error("startTime 必须早于 endTime");
131
+ if (timeInterval) {
132
+ intentParam.timeInterval = timeInterval;
113
133
  }
114
- timeInterval = [startTimeMs, endTimeMs];
115
- }
116
- // Get session context
117
- const sessionContext = getCurrentSessionContext();
118
- if (!sessionContext) {
119
- throw new Error("No active XY session found. Search alarm tool can only be used during an active conversation.");
120
- }
121
- const { config, sessionId, taskId, messageId } = sessionContext;
122
- // Get WebSocket manager
123
- const wsManager = getXYWebSocketManager(config);
124
- // Build SearchAlarm command
125
- // Build intentParam with provided search criteria
126
- const intentParam = {};
127
- if (hasRangeType) {
128
- intentParam.rangeType = params.rangeType;
129
- }
130
- if (hasAlarmState) {
131
- intentParam.alarmState = params.alarmState;
132
- }
133
- if (hasDaysOfWakeType) {
134
- intentParam.daysOfWakeType = params.daysOfWakeType;
135
- }
136
- if (timeInterval) {
137
- intentParam.timeInterval = timeInterval;
138
- }
139
- const command = {
140
- header: {
141
- namespace: "Common",
142
- name: "Action",
143
- },
144
- payload: {
145
- cardParam: {},
146
- executeParam: {
147
- executeMode: "background",
148
- intentName: "SearchAlarm",
149
- bundleName: "com.huawei.hmos.clock",
150
- needUnlock: true,
151
- actionResponse: true,
152
- appType: "OHOS_APP",
153
- timeOut: 5,
154
- intentParam,
155
- permissionId: [],
156
- achieveType: "INTENT",
134
+ const command = {
135
+ header: {
136
+ namespace: "Common",
137
+ name: "Action",
157
138
  },
158
- responses: [
159
- {
160
- resultCode: "",
161
- displayText: "",
162
- ttsText: "",
139
+ payload: {
140
+ cardParam: {},
141
+ executeParam: {
142
+ executeMode: "background",
143
+ intentName: "SearchAlarm",
144
+ bundleName: "com.huawei.hmos.clock",
145
+ needUnlock: true,
146
+ actionResponse: true,
147
+ appType: "OHOS_APP",
148
+ timeOut: 5,
149
+ intentParam,
150
+ permissionId: [],
151
+ achieveType: "INTENT",
163
152
  },
164
- ],
165
- needUploadResult: true,
166
- noHalfPage: false,
167
- pageControlRelated: false,
168
- },
169
- };
170
- // Send command and wait for response (60 second timeout)
171
- return new Promise((resolve, reject) => {
172
- const timeout = setTimeout(() => {
173
- wsManager.off("data-event", handler);
174
- reject(new Error("检索闹钟超时(60秒)"));
175
- }, 60000);
176
- // Listen for data events from WebSocket
177
- const handler = (event) => {
178
- if (event.intentName === "SearchAlarm") {
179
- clearTimeout(timeout);
153
+ responses: [
154
+ {
155
+ resultCode: "",
156
+ displayText: "",
157
+ ttsText: "",
158
+ },
159
+ ],
160
+ needUploadResult: true,
161
+ noHalfPage: false,
162
+ pageControlRelated: false,
163
+ },
164
+ };
165
+ // Send command and wait for response (60 second timeout)
166
+ return new Promise((resolve, reject) => {
167
+ const timeout = setTimeout(() => {
180
168
  wsManager.off("data-event", handler);
181
- if (event.status === "success" && event.outputs) {
182
- // 成功,直接返回完整的 event.outputs JSON 字符串
183
- resolve({
184
- content: [
185
- {
186
- type: "text",
187
- text: JSON.stringify(event.outputs),
188
- },
189
- ],
190
- });
169
+ reject(new Error("检索闹钟超时(60秒)"));
170
+ }, 60000);
171
+ // Listen for data events from WebSocket
172
+ const handler = (event) => {
173
+ if (event.intentName === "SearchAlarm") {
174
+ clearTimeout(timeout);
175
+ wsManager.off("data-event", handler);
176
+ if (event.status === "success" && event.outputs) {
177
+ // 成功,直接返回完整的 event.outputs JSON 字符串
178
+ resolve({
179
+ content: [
180
+ {
181
+ type: "text",
182
+ text: JSON.stringify(event.outputs),
183
+ },
184
+ ],
185
+ });
186
+ }
187
+ else {
188
+ reject(new Error(`检索闹钟失败: ${event.status}`));
189
+ }
191
190
  }
192
- else {
193
- reject(new Error(`检索闹钟失败: ${event.status}`));
194
- }
195
- }
196
- };
197
- // Register event handler
198
- wsManager.on("data-event", handler);
199
- // Send the command
200
- sendCommand({
201
- config,
202
- sessionId,
203
- taskId,
204
- messageId,
205
- command,
206
- })
207
- .then(() => {
208
- })
209
- .catch((error) => {
210
- clearTimeout(timeout);
211
- wsManager.off("data-event", handler);
212
- reject(error);
191
+ };
192
+ // Register event handler
193
+ wsManager.on("data-event", handler);
194
+ // Send the command
195
+ sendCommand({
196
+ config,
197
+ sessionId,
198
+ taskId,
199
+ messageId,
200
+ command,
201
+ })
202
+ .then(() => {
203
+ })
204
+ .catch((error) => {
205
+ clearTimeout(timeout);
206
+ wsManager.off("data-event", handler);
207
+ reject(error);
208
+ });
213
209
  });
214
- });
215
- },
216
- };
210
+ },
211
+ };
212
+ }
217
213
  /**
218
214
  * Parse alarmTime string (YYYYMMDD hhmmss) to timestamp in milliseconds
219
215
  * @param alarmTime - Time string in format "YYYYMMDD hhmmss" (e.g., "20240315 143000")
@@ -1,3 +1,4 @@
1
+ import type { SessionContext } from "./session-manager.js";
1
2
  /**
2
3
  * XY search calendar event tool - searches calendar events on user's device.
3
4
  * Returns matching events based on time range and optional title filter.
@@ -9,4 +10,4 @@
9
10
  * - For evening: 18:00:00 to 24:00:00
10
11
  * - For a specific time: use ±1 hour range (e.g., for 3PM, use 14:00:00 to 16:00:00)
11
12
  */
12
- export declare const searchCalendarTool: any;
13
+ export declare function createSearchCalendarTool(ctx: SessionContext): any;