@ynhcj/xiaoyi-channel 0.0.185-beta → 0.0.185-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.js +141 -1
- package/dist/src/acp-session-binding.d.ts +37 -0
- package/dist/src/acp-session-binding.js +237 -0
- package/dist/src/bot.js +62 -33
- package/dist/src/channel.js +68 -64
- package/dist/src/client.d.ts +5 -0
- package/dist/src/client.js +10 -0
- package/dist/src/cron-command.d.ts +2 -0
- package/dist/src/cron-command.js +14 -8
- package/dist/src/cron-query-handler.js +36 -0
- package/dist/src/cspl/call_api.js +4 -2
- package/dist/src/cspl/sentinel_hook.js +9 -8
- package/dist/src/cspl/upload_file.js +2 -2
- package/dist/src/formatter.js +72 -36
- package/dist/src/log-reporter/config-loader.d.ts +11 -0
- package/dist/src/log-reporter/config-loader.js +68 -0
- package/dist/src/log-reporter/cursor-store.d.ts +5 -0
- package/dist/src/log-reporter/cursor-store.js +26 -0
- package/dist/src/log-reporter/index.d.ts +10 -0
- package/dist/src/log-reporter/index.js +77 -0
- package/dist/src/log-reporter/reporter.d.ts +6 -0
- package/dist/src/log-reporter/reporter.js +17 -0
- package/dist/src/log-reporter/scanner.d.ts +6 -0
- package/dist/src/log-reporter/scanner.js +82 -0
- package/dist/src/log-reporter/types.d.ts +59 -0
- package/dist/src/log-reporter/types.js +2 -0
- package/dist/src/log-reporter/uploader.d.ts +6 -0
- package/dist/src/log-reporter/uploader.js +32 -0
- package/dist/src/memory-query-handler.d.ts +1 -0
- package/dist/src/memory-query-handler.js +283 -0
- package/dist/src/monitor.js +29 -9
- package/dist/src/outbound.js +5 -0
- package/dist/src/parser.d.ts +12 -0
- package/dist/src/parser.js +39 -13
- package/dist/src/provider.js +79 -16
- package/dist/src/reply-dispatcher.d.ts +3 -0
- package/dist/src/reply-dispatcher.js +166 -164
- package/dist/src/self-evolution-handler.js +2 -1
- package/dist/src/task-manager.d.ts +5 -6
- package/dist/src/task-manager.js +5 -9
- package/dist/src/tools/agent-as-skill-tool.d.ts +41 -2
- package/dist/src/tools/agent-as-skill-tool.js +144 -151
- package/dist/src/tools/calendar-tool.d.ts +24 -2
- package/dist/src/tools/calendar-tool.js +115 -117
- package/dist/src/tools/call-device-tool.d.ts +20 -6
- package/dist/src/tools/call-device-tool.js +116 -138
- package/dist/src/tools/call-phone-tool.d.ts +21 -2
- package/dist/src/tools/call-phone-tool.js +112 -114
- package/dist/src/tools/check-plugin-privilege-tool.d.ts +16 -2
- package/dist/src/tools/check-plugin-privilege-tool.js +141 -143
- package/dist/src/tools/create-alarm-tool.d.ts +39 -2
- package/dist/src/tools/create-alarm-tool.js +229 -231
- package/dist/src/tools/create-all-tools.js +8 -4
- package/dist/src/tools/delete-alarm-tool.d.ts +15 -2
- package/dist/src/tools/delete-alarm-tool.js +134 -136
- package/dist/src/tools/device-tool-map.d.ts +1 -1
- package/dist/src/tools/device-tool-map.js +9 -2
- package/dist/src/tools/discover-cross-devices-tool.d.ts +16 -2
- package/dist/src/tools/discover-cross-devices-tool.js +121 -124
- package/dist/src/tools/display-a2ui-card-bypath-tool.d.ts +21 -0
- package/dist/src/tools/display-a2ui-card-bypath-tool.js +65 -0
- package/dist/src/tools/get-alarm-tool-schema.d.ts +1 -2
- package/dist/src/tools/get-alarm-tool-schema.js +10 -16
- package/dist/src/tools/get-calendar-tool-schema.d.ts +1 -2
- package/dist/src/tools/get-calendar-tool-schema.js +8 -12
- package/dist/src/tools/get-collection-tool-schema.d.ts +1 -2
- package/dist/src/tools/get-collection-tool-schema.js +9 -11
- package/dist/src/tools/get-contact-tool-schema.d.ts +1 -2
- package/dist/src/tools/get-contact-tool-schema.js +10 -16
- package/dist/src/tools/get-device-file-tool-schema.d.ts +1 -2
- package/dist/src/tools/get-device-file-tool-schema.js +9 -13
- package/dist/src/tools/get-email-tool-schema.d.ts +1 -2
- package/dist/src/tools/get-email-tool-schema.js +8 -11
- package/dist/src/tools/get-note-tool-schema.d.ts +1 -2
- package/dist/src/tools/get-note-tool-schema.js +9 -14
- package/dist/src/tools/get-photo-tool-schema.d.ts +1 -2
- package/dist/src/tools/get-photo-tool-schema.js +9 -12
- package/dist/src/tools/image-reading-tool.d.ts +28 -2
- package/dist/src/tools/image-reading-tool.js +76 -76
- package/dist/src/tools/location-tool.d.ts +11 -2
- package/dist/src/tools/location-tool.js +93 -92
- package/dist/src/tools/login-token-tool.d.ts +20 -2
- package/dist/src/tools/login-token-tool.js +123 -125
- package/dist/src/tools/modify-alarm-tool.d.ts +47 -2
- package/dist/src/tools/modify-alarm-tool.js +250 -252
- package/dist/src/tools/modify-note-tool.d.ts +20 -2
- package/dist/src/tools/modify-note-tool.js +107 -109
- package/dist/src/tools/note-tool.d.ts +20 -2
- package/dist/src/tools/note-tool.js +106 -108
- package/dist/src/tools/query-app-message-tool.d.ts +28 -2
- package/dist/src/tools/query-app-message-tool.js +111 -113
- package/dist/src/tools/query-memory-data-tool.d.ts +28 -2
- package/dist/src/tools/query-memory-data-tool.js +112 -114
- package/dist/src/tools/query-todo-task-tool.d.ts +24 -2
- package/dist/src/tools/query-todo-task-tool.js +106 -108
- package/dist/src/tools/save-file-to-phone-tool.d.ts +24 -2
- package/dist/src/tools/save-file-to-phone-tool.js +130 -132
- package/dist/src/tools/save-media-to-gallery-tool.d.ts +24 -2
- package/dist/src/tools/save-media-to-gallery-tool.js +137 -139
- package/dist/src/tools/save-self-evolution-skill-tool.d.ts +54 -2
- package/dist/src/tools/save-self-evolution-skill-tool.js +194 -194
- package/dist/src/tools/search-alarm-tool.d.ts +34 -2
- package/dist/src/tools/search-alarm-tool.js +174 -176
- package/dist/src/tools/search-calendar-tool.d.ts +24 -2
- package/dist/src/tools/search-calendar-tool.js +148 -150
- package/dist/src/tools/search-contact-tool.d.ts +16 -2
- package/dist/src/tools/search-contact-tool.js +101 -103
- package/dist/src/tools/search-email-tool.d.ts +21 -2
- package/dist/src/tools/search-email-tool.js +110 -112
- package/dist/src/tools/search-file-tool.d.ts +16 -2
- package/dist/src/tools/search-file-tool.js +104 -106
- package/dist/src/tools/search-message-tool.d.ts +16 -2
- package/dist/src/tools/search-message-tool.js +103 -105
- package/dist/src/tools/search-note-tool.d.ts +16 -2
- package/dist/src/tools/search-note-tool.js +98 -100
- package/dist/src/tools/search-photo-gallery-tool.d.ts +21 -2
- package/dist/src/tools/search-photo-gallery-tool.js +35 -37
- package/dist/src/tools/send-cross-device-task-tool.d.ts +35 -2
- package/dist/src/tools/send-cross-device-task-tool.js +216 -150
- package/dist/src/tools/send-email-tool.d.ts +24 -2
- package/dist/src/tools/send-email-tool.js +108 -110
- package/dist/src/tools/send-file-to-user-tool.d.ts +20 -2
- package/dist/src/tools/send-file-to-user-tool.js +174 -178
- package/dist/src/tools/send-html-card-tool.d.ts +20 -2
- package/dist/src/tools/send-html-card-tool.js +85 -87
- package/dist/src/tools/send-message-tool.d.ts +20 -2
- package/dist/src/tools/send-message-tool.js +122 -124
- package/dist/src/tools/session-manager.d.ts +19 -52
- package/dist/src/tools/session-manager.js +95 -247
- package/dist/src/tools/upload-file-tool.d.ts +20 -2
- package/dist/src/tools/upload-file-tool.js +80 -82
- package/dist/src/tools/upload-photo-tool.d.ts +20 -2
- package/dist/src/tools/upload-photo-tool.js +68 -70
- package/dist/src/tools/xiaoyi-add-collection-tool.d.ts +32 -2
- package/dist/src/tools/xiaoyi-add-collection-tool.js +146 -148
- package/dist/src/tools/xiaoyi-collection-tool.d.ts +20 -2
- package/dist/src/tools/xiaoyi-collection-tool.js +114 -116
- package/dist/src/tools/xiaoyi-delete-collection-tool.d.ts +15 -2
- package/dist/src/tools/xiaoyi-delete-collection-tool.js +127 -129
- package/dist/src/tools/xiaoyi-gui-tool.d.ts +16 -2
- package/dist/src/tools/xiaoyi-gui-tool.js +92 -95
- package/dist/src/types.d.ts +6 -6
- package/dist/src/utils/config-manager.d.ts +3 -2
- package/dist/src/utils/config-manager.js +22 -2
- package/dist/src/utils/cron-push-map.d.ts +26 -0
- package/dist/src/utils/cron-push-map.js +131 -0
- package/dist/src/utils/logger.js +3 -14
- package/dist/src/websocket.d.ts +1 -1
- package/dist/src/websocket.js +29 -13
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getCachedXYWebSocketManager } from "../client.js";
|
|
2
2
|
import { sendCommand } from "../formatter.js";
|
|
3
|
-
import {
|
|
3
|
+
import { getCurrentSessionContext } from './session-manager.js';
|
|
4
4
|
import { logger } from "../utils/logger.js";
|
|
5
5
|
// Enum definitions for alarm parameters
|
|
6
6
|
const ALARM_SNOOZE_DURATION_VALUES = [5, 10, 15, 20, 25, 30];
|
|
@@ -14,263 +14,261 @@ const DAYS_OF_WEEK_VALUES = ["Mon", "Tues", "Wed", "Thur", "Fri", "Sat", "Sun"];
|
|
|
14
14
|
*
|
|
15
15
|
* Time format: YYYYMMDD hhmmss (e.g., 20240315 143000)
|
|
16
16
|
*/
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
label: "Create Alarm",
|
|
22
|
-
description: `在用户设备上创建闹钟。
|
|
17
|
+
export const createAlarmTool = {
|
|
18
|
+
name: "create_alarm",
|
|
19
|
+
label: "Create Alarm",
|
|
20
|
+
description: `在用户设备上创建闹钟。
|
|
23
21
|
|
|
24
22
|
注意事项:
|
|
25
23
|
a. 操作超时时间为60秒,请勿重复调用此工具,如果超时或失败,最多重试一次。
|
|
26
24
|
b. 使用该工具之前需获取当前真实时间
|
|
27
25
|
|
|
28
26
|
回复约束:如果工具返回没有授权或者其他报错,只需要完整描述没有授权或者其他报错内容即可,不需要主动给用户提供解决方案,例如告诉用户如何授权,如何解决报错等都是不需要的,请严格遵守。`,
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
},
|
|
27
|
+
parameters: {
|
|
28
|
+
type: "object",
|
|
29
|
+
properties: {
|
|
30
|
+
alarmTime: {
|
|
31
|
+
type: "string",
|
|
32
|
+
description: "闹钟时间,格式必须为:YYYYMMDD hhmmss(例如:20240315 143000,表示2024年3月15日14:30:00)",
|
|
33
|
+
},
|
|
34
|
+
alarmTitle: {
|
|
35
|
+
type: "string",
|
|
36
|
+
description: "闹钟名称/标题,默认为'闹钟'",
|
|
37
|
+
},
|
|
38
|
+
alarmSnoozeDuration: {
|
|
39
|
+
type: "number",
|
|
40
|
+
description: "小睡间隔(分钟),枚举值:5,10,15,20,25,30,默认10",
|
|
41
|
+
},
|
|
42
|
+
alarmSnoozeTotal: {
|
|
43
|
+
type: "number",
|
|
44
|
+
description: "再响次数,枚举值:0,1,3,5,10,默认0(表示不再响)",
|
|
45
|
+
},
|
|
46
|
+
alarmRingDuration: {
|
|
47
|
+
type: "number",
|
|
48
|
+
description: "响铃时长(分钟),枚举值:1,5,10,15,20,30,默认5",
|
|
49
|
+
},
|
|
50
|
+
daysOfWakeType: {
|
|
51
|
+
type: "number",
|
|
52
|
+
description: "闹钟响铃类型,枚举值:0=单次响铃,1=法定节假日,2=每天,3=自定义时间,4=法定工作日,默认0",
|
|
53
|
+
},
|
|
54
|
+
daysOfWeek: {
|
|
55
|
+
// 不指定 type,允许传入数组或 JSON 字符串
|
|
56
|
+
// 具体的类型验证和转换在 execute 函数内部进行
|
|
57
|
+
description: "自定义响铃星期,仅当daysOfWakeType=3(自定义时间)时必需且有效,其他情况不要传递此参数。数组或JSON字符串,枚举值:Mon,Tues,Wed,Thur,Fri,Sat,Sun。",
|
|
61
58
|
},
|
|
62
|
-
required: ["alarmTime"],
|
|
63
59
|
},
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
60
|
+
required: ["alarmTime"],
|
|
61
|
+
},
|
|
62
|
+
async execute(toolCallId, params) {
|
|
63
|
+
const _c = getCurrentSessionContext();
|
|
64
|
+
const { config, sessionId, taskId, messageId } = _c;
|
|
65
|
+
// ===== Validate required parameter: alarmTime =====
|
|
66
|
+
if (!params.alarmTime || typeof params.alarmTime !== "string") {
|
|
67
|
+
throw new Error("Missing required parameter: alarmTime must be a string in format YYYYMMDD hhmmss");
|
|
68
|
+
}
|
|
69
|
+
// Parse and convert alarmTime to timestamp
|
|
70
|
+
const alarmTimeMs = parseAlarmTimeToTimestamp(params.alarmTime);
|
|
71
|
+
if (alarmTimeMs === null) {
|
|
72
|
+
throw new Error("Invalid alarmTime format. Required format: YYYYMMDD hhmmss (e.g., 20240315 143000)");
|
|
73
|
+
}
|
|
74
|
+
// ===== Validate and set optional parameters with defaults =====
|
|
75
|
+
// alarmTitle - default to "闹钟"
|
|
76
|
+
const alarmTitle = params.alarmTitle && typeof params.alarmTitle === "string"
|
|
77
|
+
? params.alarmTitle
|
|
78
|
+
: "闹钟";
|
|
79
|
+
// alarmSnoozeDuration - default 10
|
|
80
|
+
let alarmSnoozeDuration = 10;
|
|
81
|
+
if (params.alarmSnoozeDuration !== undefined && params.alarmSnoozeDuration !== null) {
|
|
82
|
+
if (typeof params.alarmSnoozeDuration !== "number") {
|
|
83
|
+
throw new Error("alarmSnoozeDuration must be a number");
|
|
68
84
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (alarmTimeMs === null) {
|
|
72
|
-
throw new Error("Invalid alarmTime format. Required format: YYYYMMDD hhmmss (e.g., 20240315 143000)");
|
|
85
|
+
if (!ALARM_SNOOZE_DURATION_VALUES.includes(params.alarmSnoozeDuration)) {
|
|
86
|
+
throw new Error(`alarmSnoozeDuration must be one of: ${ALARM_SNOOZE_DURATION_VALUES.join(", ")}`);
|
|
73
87
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (params.alarmSnoozeDuration !== undefined && params.alarmSnoozeDuration !== null) {
|
|
82
|
-
if (typeof params.alarmSnoozeDuration !== "number") {
|
|
83
|
-
throw new Error("alarmSnoozeDuration must be a number");
|
|
84
|
-
}
|
|
85
|
-
if (!ALARM_SNOOZE_DURATION_VALUES.includes(params.alarmSnoozeDuration)) {
|
|
86
|
-
throw new Error(`alarmSnoozeDuration must be one of: ${ALARM_SNOOZE_DURATION_VALUES.join(", ")}`);
|
|
87
|
-
}
|
|
88
|
-
alarmSnoozeDuration = params.alarmSnoozeDuration;
|
|
88
|
+
alarmSnoozeDuration = params.alarmSnoozeDuration;
|
|
89
|
+
}
|
|
90
|
+
// alarmSnoozeTotal - default 0
|
|
91
|
+
let alarmSnoozeTotal = 0;
|
|
92
|
+
if (params.alarmSnoozeTotal !== undefined && params.alarmSnoozeTotal !== null) {
|
|
93
|
+
if (typeof params.alarmSnoozeTotal !== "number") {
|
|
94
|
+
throw new Error("alarmSnoozeTotal must be a number");
|
|
89
95
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if (params.alarmSnoozeTotal !== undefined && params.alarmSnoozeTotal !== null) {
|
|
93
|
-
if (typeof params.alarmSnoozeTotal !== "number") {
|
|
94
|
-
throw new Error("alarmSnoozeTotal must be a number");
|
|
95
|
-
}
|
|
96
|
-
if (!ALARM_SNOOZE_TOTAL_VALUES.includes(params.alarmSnoozeTotal)) {
|
|
97
|
-
throw new Error(`alarmSnoozeTotal must be one of: ${ALARM_SNOOZE_TOTAL_VALUES.join(", ")}`);
|
|
98
|
-
}
|
|
99
|
-
alarmSnoozeTotal = params.alarmSnoozeTotal;
|
|
96
|
+
if (!ALARM_SNOOZE_TOTAL_VALUES.includes(params.alarmSnoozeTotal)) {
|
|
97
|
+
throw new Error(`alarmSnoozeTotal must be one of: ${ALARM_SNOOZE_TOTAL_VALUES.join(", ")}`);
|
|
100
98
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
throw new Error(`alarmRingDuration must be one of: ${ALARM_RING_DURATION_VALUES.join(", ")}`);
|
|
109
|
-
}
|
|
110
|
-
alarmRingDuration = params.alarmRingDuration;
|
|
99
|
+
alarmSnoozeTotal = params.alarmSnoozeTotal;
|
|
100
|
+
}
|
|
101
|
+
// alarmRingDuration - default 20
|
|
102
|
+
let alarmRingDuration = 20;
|
|
103
|
+
if (params.alarmRingDuration !== undefined && params.alarmRingDuration !== null) {
|
|
104
|
+
if (typeof params.alarmRingDuration !== "number") {
|
|
105
|
+
throw new Error("alarmRingDuration must be a number");
|
|
111
106
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
if (params.daysOfWakeType !== undefined && params.daysOfWakeType !== null) {
|
|
115
|
-
if (typeof params.daysOfWakeType !== "number") {
|
|
116
|
-
throw new Error("daysOfWakeType must be a number");
|
|
117
|
-
}
|
|
118
|
-
if (!DAYS_OF_WAKE_TYPE_VALUES.includes(params.daysOfWakeType)) {
|
|
119
|
-
throw new Error(`daysOfWakeType must be one of: ${DAYS_OF_WAKE_TYPE_VALUES.join(", ")}`);
|
|
120
|
-
}
|
|
121
|
-
daysOfWakeType = params.daysOfWakeType;
|
|
107
|
+
if (!ALARM_RING_DURATION_VALUES.includes(params.alarmRingDuration)) {
|
|
108
|
+
throw new Error(`alarmRingDuration must be one of: ${ALARM_RING_DURATION_VALUES.join(", ")}`);
|
|
122
109
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
110
|
+
alarmRingDuration = params.alarmRingDuration;
|
|
111
|
+
}
|
|
112
|
+
// daysOfWakeType - default 0
|
|
113
|
+
let daysOfWakeType = 0;
|
|
114
|
+
if (params.daysOfWakeType !== undefined && params.daysOfWakeType !== null) {
|
|
115
|
+
if (typeof params.daysOfWakeType !== "number") {
|
|
116
|
+
throw new Error("daysOfWakeType must be a number");
|
|
117
|
+
}
|
|
118
|
+
if (!DAYS_OF_WAKE_TYPE_VALUES.includes(params.daysOfWakeType)) {
|
|
119
|
+
throw new Error(`daysOfWakeType must be one of: ${DAYS_OF_WAKE_TYPE_VALUES.join(", ")}`);
|
|
120
|
+
}
|
|
121
|
+
daysOfWakeType = params.daysOfWakeType;
|
|
122
|
+
}
|
|
123
|
+
// daysOfWeek - only required when daysOfWakeType is 3
|
|
124
|
+
let daysOfWeek = [];
|
|
125
|
+
if (daysOfWakeType === 3) {
|
|
126
|
+
if (!params.daysOfWeek) {
|
|
127
|
+
throw new Error("daysOfWeek is required when daysOfWakeType is 3 (custom)");
|
|
128
|
+
}
|
|
129
|
+
// ===== 参数规范化:兼容数组和 JSON 字符串 =====
|
|
130
|
+
let normalizedDaysOfWeek = null;
|
|
131
|
+
// 情况1: 已经是数组
|
|
132
|
+
if (Array.isArray(params.daysOfWeek)) {
|
|
133
|
+
normalizedDaysOfWeek = params.daysOfWeek;
|
|
134
|
+
}
|
|
135
|
+
// 情况2: 是字符串,尝试解析为 JSON 数组
|
|
136
|
+
else if (typeof params.daysOfWeek === 'string') {
|
|
137
|
+
try {
|
|
138
|
+
const parsed = JSON.parse(params.daysOfWeek);
|
|
139
|
+
if (Array.isArray(parsed)) {
|
|
140
|
+
normalizedDaysOfWeek = parsed;
|
|
145
141
|
}
|
|
146
|
-
|
|
147
|
-
throw new Error(
|
|
142
|
+
else {
|
|
143
|
+
throw new Error("daysOfWeek must be an array or a JSON string representing an array");
|
|
148
144
|
}
|
|
149
145
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
throw new Error(`daysOfWeek must be an array or a JSON string, got ${typeof params.daysOfWeek}`);
|
|
153
|
-
}
|
|
154
|
-
// 验证数组非空
|
|
155
|
-
if (!normalizedDaysOfWeek || normalizedDaysOfWeek.length === 0) {
|
|
156
|
-
throw new Error("daysOfWeek array cannot be empty");
|
|
157
|
-
}
|
|
158
|
-
// Validate each day
|
|
159
|
-
for (const day of normalizedDaysOfWeek) {
|
|
160
|
-
if (typeof day !== "string" || !DAYS_OF_WEEK_VALUES.includes(day)) {
|
|
161
|
-
throw new Error(`daysOfWeek must contain only: ${DAYS_OF_WEEK_VALUES.join(", ")}`);
|
|
162
|
-
}
|
|
146
|
+
catch (parseError) {
|
|
147
|
+
throw new Error(`daysOfWeek must be a valid JSON array string. Parse error: ${parseError instanceof Error ? parseError.message : String(parseError)}`);
|
|
163
148
|
}
|
|
164
|
-
daysOfWeek = normalizedDaysOfWeek;
|
|
165
149
|
}
|
|
150
|
+
// 情况3: 其他类型,报错
|
|
166
151
|
else {
|
|
167
|
-
|
|
168
|
-
if (params.daysOfWeek) {
|
|
169
|
-
}
|
|
170
|
-
// Explicitly set to empty array
|
|
171
|
-
daysOfWeek = [];
|
|
152
|
+
throw new Error(`daysOfWeek must be an array or a JSON string, got ${typeof params.daysOfWeek}`);
|
|
172
153
|
}
|
|
173
|
-
//
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
// Build intentParam - only include daysOfWeek when daysOfWakeType is 3
|
|
177
|
-
const intentParam = {
|
|
178
|
-
entityName: "Alarm",
|
|
179
|
-
alarmTime: alarmTimeMs,
|
|
180
|
-
alarmTitle: alarmTitle,
|
|
181
|
-
alarmSnoozeDuration: alarmSnoozeDuration,
|
|
182
|
-
alarmSnoozeTotal: alarmSnoozeTotal,
|
|
183
|
-
alarmRingDuration: alarmRingDuration,
|
|
184
|
-
daysOfWakeType: daysOfWakeType,
|
|
185
|
-
};
|
|
186
|
-
// Only include daysOfWeek when daysOfWakeType is 3
|
|
187
|
-
if (daysOfWakeType === 3 && daysOfWeek.length > 0) {
|
|
188
|
-
intentParam.daysOfWeek = daysOfWeek;
|
|
154
|
+
// 验证数组非空
|
|
155
|
+
if (!normalizedDaysOfWeek || normalizedDaysOfWeek.length === 0) {
|
|
156
|
+
throw new Error("daysOfWeek array cannot be empty");
|
|
189
157
|
}
|
|
190
|
-
|
|
158
|
+
// Validate each day
|
|
159
|
+
for (const day of normalizedDaysOfWeek) {
|
|
160
|
+
if (typeof day !== "string" || !DAYS_OF_WEEK_VALUES.includes(day)) {
|
|
161
|
+
throw new Error(`daysOfWeek must contain only: ${DAYS_OF_WEEK_VALUES.join(", ")}`);
|
|
162
|
+
}
|
|
191
163
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
164
|
+
daysOfWeek = normalizedDaysOfWeek;
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
// daysOfWakeType is not 3, daysOfWeek should not be provided
|
|
168
|
+
if (params.daysOfWeek) {
|
|
169
|
+
}
|
|
170
|
+
// Explicitly set to empty array
|
|
171
|
+
daysOfWeek = [];
|
|
172
|
+
}
|
|
173
|
+
// Get WebSocket manager
|
|
174
|
+
const wsManager = getCachedXYWebSocketManager();
|
|
175
|
+
// Build CreateAlarm command
|
|
176
|
+
// Build intentParam - only include daysOfWeek when daysOfWakeType is 3
|
|
177
|
+
const intentParam = {
|
|
178
|
+
entityName: "Alarm",
|
|
179
|
+
alarmTime: alarmTimeMs,
|
|
180
|
+
alarmTitle: alarmTitle,
|
|
181
|
+
alarmSnoozeDuration: alarmSnoozeDuration,
|
|
182
|
+
alarmSnoozeTotal: alarmSnoozeTotal,
|
|
183
|
+
alarmRingDuration: alarmRingDuration,
|
|
184
|
+
daysOfWakeType: daysOfWakeType,
|
|
185
|
+
};
|
|
186
|
+
// Only include daysOfWeek when daysOfWakeType is 3
|
|
187
|
+
if (daysOfWakeType === 3 && daysOfWeek.length > 0) {
|
|
188
|
+
intentParam.daysOfWeek = daysOfWeek;
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
}
|
|
192
|
+
const command = {
|
|
193
|
+
header: {
|
|
194
|
+
namespace: "Common",
|
|
195
|
+
name: "Action",
|
|
196
|
+
},
|
|
197
|
+
payload: {
|
|
198
|
+
cardParam: {},
|
|
199
|
+
executeParam: {
|
|
200
|
+
executeMode: "background",
|
|
201
|
+
intentName: "CreateAlarm",
|
|
202
|
+
bundleName: "com.huawei.hmos.clock",
|
|
203
|
+
needUnlock: true,
|
|
204
|
+
actionResponse: true,
|
|
205
|
+
appType: "OHOS_APP",
|
|
206
|
+
timeOut: 5,
|
|
207
|
+
intentParam: intentParam,
|
|
208
|
+
permissionId: [],
|
|
209
|
+
achieveType: "INTENT",
|
|
196
210
|
},
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
bundleName: "com.huawei.hmos.clock",
|
|
203
|
-
needUnlock: true,
|
|
204
|
-
actionResponse: true,
|
|
205
|
-
appType: "OHOS_APP",
|
|
206
|
-
timeOut: 5,
|
|
207
|
-
intentParam: intentParam,
|
|
208
|
-
permissionId: [],
|
|
209
|
-
achieveType: "INTENT",
|
|
211
|
+
responses: [
|
|
212
|
+
{
|
|
213
|
+
resultCode: "",
|
|
214
|
+
displayText: "",
|
|
215
|
+
ttsText: "",
|
|
210
216
|
},
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
logger.error("超时: 创建闹钟超时(60秒)", { toolCallId });
|
|
228
|
-
reject(new Error("创建闹钟超时(60秒)"));
|
|
229
|
-
}, 60000);
|
|
230
|
-
// Listen for data events from WebSocket
|
|
231
|
-
const handler = (event) => {
|
|
232
|
-
if (event.intentName === "CreateAlarm") {
|
|
233
|
-
clearTimeout(timeout);
|
|
234
|
-
wsManager.off("data-event", handler);
|
|
235
|
-
if (event.status === "success" && event.outputs) {
|
|
236
|
-
// 成功,直接返回完整的 event.outputs JSON 字符串
|
|
237
|
-
resolve({
|
|
238
|
-
content: [
|
|
239
|
-
{
|
|
240
|
-
type: "text",
|
|
241
|
-
text: JSON.stringify(event.outputs),
|
|
242
|
-
},
|
|
243
|
-
],
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
else {
|
|
247
|
-
reject(new Error(`创建闹钟失败: ${JSON.stringify(event.outputs)}`));
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
};
|
|
251
|
-
// Register event handler
|
|
252
|
-
wsManager.on("data-event", handler);
|
|
253
|
-
// Send the command
|
|
254
|
-
const currentTaskId = getCurrentTaskId(sessionId) ?? taskId;
|
|
255
|
-
sendCommand({
|
|
256
|
-
config,
|
|
257
|
-
sessionId,
|
|
258
|
-
taskId: currentTaskId,
|
|
259
|
-
messageId,
|
|
260
|
-
command,
|
|
261
|
-
toolCallId,
|
|
262
|
-
})
|
|
263
|
-
.then(() => {
|
|
264
|
-
})
|
|
265
|
-
.catch((error) => {
|
|
217
|
+
],
|
|
218
|
+
needUploadResult: true,
|
|
219
|
+
noHalfPage: false,
|
|
220
|
+
pageControlRelated: false,
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
// Send command and wait for response (60 second timeout)
|
|
224
|
+
return new Promise((resolve, reject) => {
|
|
225
|
+
const timeout = setTimeout(() => {
|
|
226
|
+
wsManager.off("data-event", handler);
|
|
227
|
+
logger.error("超时: 创建闹钟超时(60秒)", { toolCallId });
|
|
228
|
+
reject(new Error("创建闹钟超时(60秒)"));
|
|
229
|
+
}, 60000);
|
|
230
|
+
// Listen for data events from WebSocket
|
|
231
|
+
const handler = (event) => {
|
|
232
|
+
if (event.intentName === "CreateAlarm") {
|
|
266
233
|
clearTimeout(timeout);
|
|
267
234
|
wsManager.off("data-event", handler);
|
|
268
|
-
|
|
269
|
-
|
|
235
|
+
if (event.status === "success" && event.outputs) {
|
|
236
|
+
// 成功,直接返回完整的 event.outputs JSON 字符串
|
|
237
|
+
resolve({
|
|
238
|
+
content: [
|
|
239
|
+
{
|
|
240
|
+
type: "text",
|
|
241
|
+
text: JSON.stringify(event.outputs),
|
|
242
|
+
},
|
|
243
|
+
],
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
reject(new Error(`创建闹钟失败: ${JSON.stringify(event.outputs)}`));
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
// Register event handler
|
|
252
|
+
wsManager.on("data-event", handler);
|
|
253
|
+
// Send the command
|
|
254
|
+
sendCommand({
|
|
255
|
+
config,
|
|
256
|
+
sessionId,
|
|
257
|
+
taskId,
|
|
258
|
+
messageId,
|
|
259
|
+
command,
|
|
260
|
+
toolCallId,
|
|
261
|
+
})
|
|
262
|
+
.then(() => {
|
|
263
|
+
})
|
|
264
|
+
.catch((error) => {
|
|
265
|
+
clearTimeout(timeout);
|
|
266
|
+
wsManager.off("data-event", handler);
|
|
267
|
+
reject(error);
|
|
270
268
|
});
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
}
|
|
269
|
+
});
|
|
270
|
+
},
|
|
271
|
+
};
|
|
274
272
|
/**
|
|
275
273
|
* Parse alarmTime string (YYYYMMDD hhmmss) to timestamp in milliseconds
|
|
276
274
|
* @param alarmTime - Time string in format "YYYYMMDD hhmmss" (e.g., "20240315 143000")
|
|
@@ -17,6 +17,10 @@ import { createGetCollectionToolSchemaTool } from "./get-collection-tool-schema.
|
|
|
17
17
|
// import { createGetEmailToolSchemaTool } from "./get-email-tool-schema.js";
|
|
18
18
|
import { createLoginTokenTool } from "./login-token-tool.js";
|
|
19
19
|
import { createAgentAsSkillTool } from "./agent-as-skill-tool.js";
|
|
20
|
+
import { createDiscoverCrossDevicesTool } from "./discover-cross-devices-tool.js";
|
|
21
|
+
import { createSendCrossDeviceTaskTool } from "./send-cross-device-task-tool.js";
|
|
22
|
+
import { createDisplayA2UICardByPathTool } from "./display-a2ui-card-bypath-tool.js";
|
|
23
|
+
import { createCheckPluginPrivilegeTool } from "./check-plugin-privilege-tool.js";
|
|
20
24
|
import { logger } from "../utils/logger.js";
|
|
21
25
|
/**
|
|
22
26
|
* Create all XY channel tools for the given session context.
|
|
@@ -32,9 +36,9 @@ export function createAllTools(ctx) {
|
|
|
32
36
|
logger.log(`[CREATE-ALL-TOOLS] creating tools`);
|
|
33
37
|
return [
|
|
34
38
|
createLocationTool(ctx),
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
createDiscoverCrossDevicesTool(ctx),
|
|
40
|
+
createSendCrossDeviceTaskTool(ctx),
|
|
41
|
+
createDisplayA2UICardByPathTool(ctx),
|
|
38
42
|
createCallDeviceTool(ctx),
|
|
39
43
|
createGetNoteToolSchemaTool(ctx),
|
|
40
44
|
createGetCalendarToolSchemaTool(ctx),
|
|
@@ -53,6 +57,6 @@ export function createAllTools(ctx) {
|
|
|
53
57
|
createSaveSelfEvolutionSkillTool(ctx),
|
|
54
58
|
createLoginTokenTool(ctx),
|
|
55
59
|
createAgentAsSkillTool(ctx),
|
|
56
|
-
|
|
60
|
+
createCheckPluginPrivilegeTool(ctx),
|
|
57
61
|
];
|
|
58
62
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { SessionContext } from "./session-manager.js";
|
|
2
1
|
/**
|
|
3
2
|
* XY delete alarm tool - deletes existing alarms on user's device.
|
|
4
3
|
* Requires entityId(s) from search_alarm or create_alarm tool as prerequisite.
|
|
@@ -9,4 +8,18 @@ import type { SessionContext } from "./session-manager.js";
|
|
|
9
8
|
*
|
|
10
9
|
* Supports deleting single or multiple alarms in one call.
|
|
11
10
|
*/
|
|
12
|
-
export declare
|
|
11
|
+
export declare const deleteAlarmTool: {
|
|
12
|
+
name: string;
|
|
13
|
+
label: string;
|
|
14
|
+
description: string;
|
|
15
|
+
parameters: {
|
|
16
|
+
type: string;
|
|
17
|
+
properties: {
|
|
18
|
+
items: {
|
|
19
|
+
description: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
required: string[];
|
|
23
|
+
};
|
|
24
|
+
execute(toolCallId: string, params: any): Promise<unknown>;
|
|
25
|
+
};
|