@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.
- package/dist/index.d.ts +6 -9
- package/dist/index.js +26 -21
- package/dist/provider-discovery.d.ts +2 -0
- package/dist/provider-discovery.js +4 -0
- package/dist/src/bot.js +29 -4
- package/dist/src/channel.js +2 -19
- package/dist/src/client.js +31 -22
- package/dist/src/cspl/call-api.js +6 -5
- package/dist/src/file-download.js +4 -3
- package/dist/src/file-upload.js +19 -18
- package/dist/src/formatter.d.ts +2 -0
- package/dist/src/formatter.js +9 -28
- package/dist/src/heartbeat.js +1 -1
- package/dist/src/login-token-handler.d.ts +8 -0
- package/dist/src/login-token-handler.js +60 -0
- package/dist/src/message-queue.d.ts +17 -0
- package/dist/src/message-queue.js +51 -0
- package/dist/src/monitor.js +70 -14
- package/dist/src/outbound.js +19 -18
- package/dist/src/provider.d.ts +2 -1
- package/dist/src/provider.js +245 -38
- package/dist/src/push.js +16 -15
- package/dist/src/reply-dispatcher.js +12 -3
- package/dist/src/runtime.d.ts +3 -11
- package/dist/src/runtime.js +6 -18
- package/dist/src/self-evolution-handler.d.ts +6 -0
- package/dist/src/self-evolution-handler.js +100 -7
- package/dist/src/self-evolution-keyword.d.ts +9 -0
- package/dist/src/self-evolution-keyword.js +147 -0
- package/dist/src/self-evolution-tool-result-nudge.d.ts +3 -0
- package/dist/src/self-evolution-tool-result-nudge.js +96 -0
- package/dist/src/skill-retriever/config.d.ts +4 -0
- package/dist/src/skill-retriever/config.js +23 -0
- package/dist/src/skill-retriever/hooks.d.ts +22 -0
- package/dist/src/skill-retriever/hooks.js +83 -0
- package/dist/src/skill-retriever/tool-search.d.ts +16 -0
- package/dist/src/skill-retriever/tool-search.js +173 -0
- package/dist/src/skill-retriever/types.d.ts +36 -0
- package/dist/src/skill-retriever/types.js +1 -0
- package/dist/src/steer-injector.js +1 -1
- package/dist/src/task-manager.d.ts +4 -0
- package/dist/src/task-manager.js +12 -1
- package/dist/src/tools/calendar-tool.d.ts +2 -1
- package/dist/src/tools/calendar-tool.js +112 -116
- package/dist/src/tools/call-device-tool.d.ts +2 -1
- package/dist/src/tools/call-device-tool.js +126 -103
- package/dist/src/tools/call-phone-tool.d.ts +2 -1
- package/dist/src/tools/call-phone-tool.js +109 -113
- package/dist/src/tools/create-alarm-tool.d.ts +2 -1
- package/dist/src/tools/create-alarm-tool.js +227 -231
- package/dist/src/tools/create-all-tools.d.ts +16 -0
- package/dist/src/tools/create-all-tools.js +50 -0
- package/dist/src/tools/delete-alarm-tool.d.ts +2 -1
- package/dist/src/tools/delete-alarm-tool.js +131 -135
- package/dist/src/tools/get-alarm-tool-schema.d.ts +2 -1
- package/dist/src/tools/get-alarm-tool-schema.js +16 -10
- package/dist/src/tools/get-calendar-tool-schema.d.ts +2 -1
- package/dist/src/tools/get-calendar-tool-schema.js +12 -8
- package/dist/src/tools/get-collection-tool-schema.d.ts +2 -1
- package/dist/src/tools/get-collection-tool-schema.js +11 -9
- package/dist/src/tools/get-contact-tool-schema.d.ts +2 -1
- package/dist/src/tools/get-contact-tool-schema.js +16 -10
- package/dist/src/tools/get-device-file-tool-schema.d.ts +2 -1
- package/dist/src/tools/get-device-file-tool-schema.js +13 -9
- package/dist/src/tools/get-email-tool-schema.d.ts +2 -1
- package/dist/src/tools/get-email-tool-schema.js +11 -8
- package/dist/src/tools/get-note-tool-schema.d.ts +2 -1
- package/dist/src/tools/get-note-tool-schema.js +14 -9
- package/dist/src/tools/get-photo-tool-schema.d.ts +2 -1
- package/dist/src/tools/get-photo-tool-schema.js +12 -9
- package/dist/src/tools/image-reading-tool.d.ts +2 -1
- package/dist/src/tools/image-reading-tool.js +86 -90
- package/dist/src/tools/location-tool.d.ts +2 -1
- package/dist/src/tools/location-tool.js +87 -91
- package/dist/src/tools/login-token-tool.d.ts +6 -0
- package/dist/src/tools/login-token-tool.js +133 -0
- package/dist/src/tools/modify-alarm-tool.d.ts +2 -1
- package/dist/src/tools/modify-alarm-tool.js +232 -236
- package/dist/src/tools/modify-note-tool.d.ts +2 -1
- package/dist/src/tools/modify-note-tool.js +104 -108
- package/dist/src/tools/note-tool.d.ts +2 -1
- package/dist/src/tools/note-tool.js +103 -107
- package/dist/src/tools/query-app-message-tool.d.ts +2 -1
- package/dist/src/tools/query-app-message-tool.js +108 -111
- package/dist/src/tools/query-memory-data-tool.d.ts +2 -1
- package/dist/src/tools/query-memory-data-tool.js +109 -112
- package/dist/src/tools/query-todo-task-tool.d.ts +2 -1
- package/dist/src/tools/query-todo-task-tool.js +103 -106
- package/dist/src/tools/save-file-to-phone-tool.d.ts +2 -1
- package/dist/src/tools/save-file-to-phone-tool.js +127 -131
- package/dist/src/tools/save-media-to-gallery-tool.d.ts +2 -1
- package/dist/src/tools/save-media-to-gallery-tool.js +134 -138
- package/dist/src/tools/save-self-evolution-skill-tool.d.ts +2 -0
- package/dist/src/tools/save-self-evolution-skill-tool.js +410 -0
- package/dist/src/tools/search-alarm-tool.d.ts +2 -1
- package/dist/src/tools/search-alarm-tool.js +171 -175
- package/dist/src/tools/search-calendar-tool.d.ts +2 -1
- package/dist/src/tools/search-calendar-tool.js +145 -149
- package/dist/src/tools/search-contact-tool.d.ts +2 -1
- package/dist/src/tools/search-contact-tool.js +98 -102
- package/dist/src/tools/search-email-tool.d.ts +2 -1
- package/dist/src/tools/search-email-tool.js +107 -111
- package/dist/src/tools/search-file-tool.d.ts +2 -1
- package/dist/src/tools/search-file-tool.js +99 -103
- package/dist/src/tools/search-message-tool.d.ts +2 -1
- package/dist/src/tools/search-message-tool.js +100 -104
- package/dist/src/tools/search-note-tool.d.ts +2 -1
- package/dist/src/tools/search-note-tool.js +95 -99
- package/dist/src/tools/search-photo-gallery-tool.d.ts +2 -1
- package/dist/src/tools/search-photo-gallery-tool.js +34 -38
- package/dist/src/tools/send-email-tool.d.ts +2 -1
- package/dist/src/tools/send-email-tool.js +105 -108
- package/dist/src/tools/send-file-to-user-tool.d.ts +2 -1
- package/dist/src/tools/send-file-to-user-tool.js +154 -155
- package/dist/src/tools/send-message-tool.d.ts +2 -1
- package/dist/src/tools/send-message-tool.js +119 -123
- package/dist/src/tools/session-manager.d.ts +21 -6
- package/dist/src/tools/session-manager.js +147 -18
- package/dist/src/tools/upload-file-tool.d.ts +2 -1
- package/dist/src/tools/upload-file-tool.js +78 -82
- package/dist/src/tools/upload-photo-tool.d.ts +2 -1
- package/dist/src/tools/upload-photo-tool.js +69 -73
- package/dist/src/tools/xiaoyi-add-collection-tool.d.ts +2 -1
- package/dist/src/tools/xiaoyi-add-collection-tool.js +143 -147
- package/dist/src/tools/xiaoyi-collection-tool.d.ts +2 -1
- package/dist/src/tools/xiaoyi-collection-tool.js +111 -115
- package/dist/src/tools/xiaoyi-delete-collection-tool.d.ts +2 -1
- package/dist/src/tools/xiaoyi-delete-collection-tool.js +124 -128
- package/dist/src/tools/xiaoyi-gui-tool.d.ts +2 -1
- package/dist/src/tools/xiaoyi-gui-tool.js +84 -88
- package/dist/src/utils/logger.js +20 -18
- package/dist/src/utils/runtime-manager.js +24 -2
- package/dist/src/utils/self-evolution-manager.d.ts +10 -0
- package/dist/src/utils/self-evolution-manager.js +69 -0
- package/dist/src/utils/tool-call-nudge-manager.d.ts +16 -0
- package/dist/src/utils/tool-call-nudge-manager.js +47 -0
- package/dist/src/websocket.d.ts +3 -0
- package/dist/src/websocket.js +91 -26
- package/openclaw.plugin.json +22 -0
- 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
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
75
|
-
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
-
|
|
84
|
-
|
|
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
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
|
|
93
|
-
|
|
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
|
-
|
|
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 (
|
|
109
|
-
|
|
128
|
+
if (hasDaysOfWakeType) {
|
|
129
|
+
intentParam.daysOfWakeType = params.daysOfWakeType;
|
|
110
130
|
}
|
|
111
|
-
if (
|
|
112
|
-
|
|
131
|
+
if (timeInterval) {
|
|
132
|
+
intentParam.timeInterval = timeInterval;
|
|
113
133
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
-
|
|
159
|
-
{
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
//
|
|
177
|
-
|
|
178
|
-
|
|
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
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
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
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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
|
|
13
|
+
export declare function createSearchCalendarTool(ctx: SessionContext): any;
|