@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.
Files changed (150) hide show
  1. package/dist/index.js +141 -1
  2. package/dist/src/acp-session-binding.d.ts +37 -0
  3. package/dist/src/acp-session-binding.js +237 -0
  4. package/dist/src/bot.js +62 -33
  5. package/dist/src/channel.js +68 -64
  6. package/dist/src/client.d.ts +5 -0
  7. package/dist/src/client.js +10 -0
  8. package/dist/src/cron-command.d.ts +2 -0
  9. package/dist/src/cron-command.js +14 -8
  10. package/dist/src/cron-query-handler.js +36 -0
  11. package/dist/src/cspl/call_api.js +4 -2
  12. package/dist/src/cspl/sentinel_hook.js +9 -8
  13. package/dist/src/cspl/upload_file.js +2 -2
  14. package/dist/src/formatter.js +72 -36
  15. package/dist/src/log-reporter/config-loader.d.ts +11 -0
  16. package/dist/src/log-reporter/config-loader.js +68 -0
  17. package/dist/src/log-reporter/cursor-store.d.ts +5 -0
  18. package/dist/src/log-reporter/cursor-store.js +26 -0
  19. package/dist/src/log-reporter/index.d.ts +10 -0
  20. package/dist/src/log-reporter/index.js +77 -0
  21. package/dist/src/log-reporter/reporter.d.ts +6 -0
  22. package/dist/src/log-reporter/reporter.js +17 -0
  23. package/dist/src/log-reporter/scanner.d.ts +6 -0
  24. package/dist/src/log-reporter/scanner.js +82 -0
  25. package/dist/src/log-reporter/types.d.ts +59 -0
  26. package/dist/src/log-reporter/types.js +2 -0
  27. package/dist/src/log-reporter/uploader.d.ts +6 -0
  28. package/dist/src/log-reporter/uploader.js +32 -0
  29. package/dist/src/memory-query-handler.d.ts +1 -0
  30. package/dist/src/memory-query-handler.js +283 -0
  31. package/dist/src/monitor.js +29 -9
  32. package/dist/src/outbound.js +5 -0
  33. package/dist/src/parser.d.ts +12 -0
  34. package/dist/src/parser.js +39 -13
  35. package/dist/src/provider.js +79 -16
  36. package/dist/src/reply-dispatcher.d.ts +3 -0
  37. package/dist/src/reply-dispatcher.js +166 -164
  38. package/dist/src/self-evolution-handler.js +2 -1
  39. package/dist/src/task-manager.d.ts +5 -6
  40. package/dist/src/task-manager.js +5 -9
  41. package/dist/src/tools/agent-as-skill-tool.d.ts +41 -2
  42. package/dist/src/tools/agent-as-skill-tool.js +144 -151
  43. package/dist/src/tools/calendar-tool.d.ts +24 -2
  44. package/dist/src/tools/calendar-tool.js +115 -117
  45. package/dist/src/tools/call-device-tool.d.ts +20 -6
  46. package/dist/src/tools/call-device-tool.js +116 -138
  47. package/dist/src/tools/call-phone-tool.d.ts +21 -2
  48. package/dist/src/tools/call-phone-tool.js +112 -114
  49. package/dist/src/tools/check-plugin-privilege-tool.d.ts +16 -2
  50. package/dist/src/tools/check-plugin-privilege-tool.js +141 -143
  51. package/dist/src/tools/create-alarm-tool.d.ts +39 -2
  52. package/dist/src/tools/create-alarm-tool.js +229 -231
  53. package/dist/src/tools/create-all-tools.js +8 -4
  54. package/dist/src/tools/delete-alarm-tool.d.ts +15 -2
  55. package/dist/src/tools/delete-alarm-tool.js +134 -136
  56. package/dist/src/tools/device-tool-map.d.ts +1 -1
  57. package/dist/src/tools/device-tool-map.js +9 -2
  58. package/dist/src/tools/discover-cross-devices-tool.d.ts +16 -2
  59. package/dist/src/tools/discover-cross-devices-tool.js +121 -124
  60. package/dist/src/tools/display-a2ui-card-bypath-tool.d.ts +21 -0
  61. package/dist/src/tools/display-a2ui-card-bypath-tool.js +65 -0
  62. package/dist/src/tools/get-alarm-tool-schema.d.ts +1 -2
  63. package/dist/src/tools/get-alarm-tool-schema.js +10 -16
  64. package/dist/src/tools/get-calendar-tool-schema.d.ts +1 -2
  65. package/dist/src/tools/get-calendar-tool-schema.js +8 -12
  66. package/dist/src/tools/get-collection-tool-schema.d.ts +1 -2
  67. package/dist/src/tools/get-collection-tool-schema.js +9 -11
  68. package/dist/src/tools/get-contact-tool-schema.d.ts +1 -2
  69. package/dist/src/tools/get-contact-tool-schema.js +10 -16
  70. package/dist/src/tools/get-device-file-tool-schema.d.ts +1 -2
  71. package/dist/src/tools/get-device-file-tool-schema.js +9 -13
  72. package/dist/src/tools/get-email-tool-schema.d.ts +1 -2
  73. package/dist/src/tools/get-email-tool-schema.js +8 -11
  74. package/dist/src/tools/get-note-tool-schema.d.ts +1 -2
  75. package/dist/src/tools/get-note-tool-schema.js +9 -14
  76. package/dist/src/tools/get-photo-tool-schema.d.ts +1 -2
  77. package/dist/src/tools/get-photo-tool-schema.js +9 -12
  78. package/dist/src/tools/image-reading-tool.d.ts +28 -2
  79. package/dist/src/tools/image-reading-tool.js +76 -76
  80. package/dist/src/tools/location-tool.d.ts +11 -2
  81. package/dist/src/tools/location-tool.js +93 -92
  82. package/dist/src/tools/login-token-tool.d.ts +20 -2
  83. package/dist/src/tools/login-token-tool.js +123 -125
  84. package/dist/src/tools/modify-alarm-tool.d.ts +47 -2
  85. package/dist/src/tools/modify-alarm-tool.js +250 -252
  86. package/dist/src/tools/modify-note-tool.d.ts +20 -2
  87. package/dist/src/tools/modify-note-tool.js +107 -109
  88. package/dist/src/tools/note-tool.d.ts +20 -2
  89. package/dist/src/tools/note-tool.js +106 -108
  90. package/dist/src/tools/query-app-message-tool.d.ts +28 -2
  91. package/dist/src/tools/query-app-message-tool.js +111 -113
  92. package/dist/src/tools/query-memory-data-tool.d.ts +28 -2
  93. package/dist/src/tools/query-memory-data-tool.js +112 -114
  94. package/dist/src/tools/query-todo-task-tool.d.ts +24 -2
  95. package/dist/src/tools/query-todo-task-tool.js +106 -108
  96. package/dist/src/tools/save-file-to-phone-tool.d.ts +24 -2
  97. package/dist/src/tools/save-file-to-phone-tool.js +130 -132
  98. package/dist/src/tools/save-media-to-gallery-tool.d.ts +24 -2
  99. package/dist/src/tools/save-media-to-gallery-tool.js +137 -139
  100. package/dist/src/tools/save-self-evolution-skill-tool.d.ts +54 -2
  101. package/dist/src/tools/save-self-evolution-skill-tool.js +194 -194
  102. package/dist/src/tools/search-alarm-tool.d.ts +34 -2
  103. package/dist/src/tools/search-alarm-tool.js +174 -176
  104. package/dist/src/tools/search-calendar-tool.d.ts +24 -2
  105. package/dist/src/tools/search-calendar-tool.js +148 -150
  106. package/dist/src/tools/search-contact-tool.d.ts +16 -2
  107. package/dist/src/tools/search-contact-tool.js +101 -103
  108. package/dist/src/tools/search-email-tool.d.ts +21 -2
  109. package/dist/src/tools/search-email-tool.js +110 -112
  110. package/dist/src/tools/search-file-tool.d.ts +16 -2
  111. package/dist/src/tools/search-file-tool.js +104 -106
  112. package/dist/src/tools/search-message-tool.d.ts +16 -2
  113. package/dist/src/tools/search-message-tool.js +103 -105
  114. package/dist/src/tools/search-note-tool.d.ts +16 -2
  115. package/dist/src/tools/search-note-tool.js +98 -100
  116. package/dist/src/tools/search-photo-gallery-tool.d.ts +21 -2
  117. package/dist/src/tools/search-photo-gallery-tool.js +35 -37
  118. package/dist/src/tools/send-cross-device-task-tool.d.ts +35 -2
  119. package/dist/src/tools/send-cross-device-task-tool.js +216 -150
  120. package/dist/src/tools/send-email-tool.d.ts +24 -2
  121. package/dist/src/tools/send-email-tool.js +108 -110
  122. package/dist/src/tools/send-file-to-user-tool.d.ts +20 -2
  123. package/dist/src/tools/send-file-to-user-tool.js +174 -178
  124. package/dist/src/tools/send-html-card-tool.d.ts +20 -2
  125. package/dist/src/tools/send-html-card-tool.js +85 -87
  126. package/dist/src/tools/send-message-tool.d.ts +20 -2
  127. package/dist/src/tools/send-message-tool.js +122 -124
  128. package/dist/src/tools/session-manager.d.ts +19 -52
  129. package/dist/src/tools/session-manager.js +95 -247
  130. package/dist/src/tools/upload-file-tool.d.ts +20 -2
  131. package/dist/src/tools/upload-file-tool.js +80 -82
  132. package/dist/src/tools/upload-photo-tool.d.ts +20 -2
  133. package/dist/src/tools/upload-photo-tool.js +68 -70
  134. package/dist/src/tools/xiaoyi-add-collection-tool.d.ts +32 -2
  135. package/dist/src/tools/xiaoyi-add-collection-tool.js +146 -148
  136. package/dist/src/tools/xiaoyi-collection-tool.d.ts +20 -2
  137. package/dist/src/tools/xiaoyi-collection-tool.js +114 -116
  138. package/dist/src/tools/xiaoyi-delete-collection-tool.d.ts +15 -2
  139. package/dist/src/tools/xiaoyi-delete-collection-tool.js +127 -129
  140. package/dist/src/tools/xiaoyi-gui-tool.d.ts +16 -2
  141. package/dist/src/tools/xiaoyi-gui-tool.js +92 -95
  142. package/dist/src/types.d.ts +6 -6
  143. package/dist/src/utils/config-manager.d.ts +3 -2
  144. package/dist/src/utils/config-manager.js +22 -2
  145. package/dist/src/utils/cron-push-map.d.ts +26 -0
  146. package/dist/src/utils/cron-push-map.js +131 -0
  147. package/dist/src/utils/logger.js +3 -14
  148. package/dist/src/websocket.d.ts +1 -1
  149. package/dist/src/websocket.js +29 -13
  150. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
- import { getXYWebSocketManager } from "../client.js";
1
+ import { getCachedXYWebSocketManager } from "../client.js";
2
2
  import { sendCommand } from "../formatter.js";
3
- import { getCurrentTaskId } from "../task-manager.js";
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 function makeAlarmTool(ctx) {
18
- const { config, sessionId, taskId, messageId } = ctx;
19
- return {
20
- name: "create_alarm",
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
- parameters: {
30
- type: "object",
31
- properties: {
32
- alarmTime: {
33
- type: "string",
34
- description: "闹钟时间,格式必须为:YYYYMMDD hhmmss(例如:20240315 143000,表示2024年3月15日14:30:00)",
35
- },
36
- alarmTitle: {
37
- type: "string",
38
- description: "闹钟名称/标题,默认为'闹钟'",
39
- },
40
- alarmSnoozeDuration: {
41
- type: "number",
42
- description: "小睡间隔(分钟),枚举值:5,10,15,20,25,30,默认10",
43
- },
44
- alarmSnoozeTotal: {
45
- type: "number",
46
- description: "再响次数,枚举值:0,1,3,5,10,默认0(表示不再响)",
47
- },
48
- alarmRingDuration: {
49
- type: "number",
50
- description: "响铃时长(分钟),枚举值:1,5,10,15,20,30,默认5",
51
- },
52
- daysOfWakeType: {
53
- type: "number",
54
- description: "闹钟响铃类型,枚举值:0=单次响铃,1=法定节假日,2=每天,3=自定义时间,4=法定工作日,默认0",
55
- },
56
- daysOfWeek: {
57
- // 不指定 type,允许传入数组或 JSON 字符串
58
- // 具体的类型验证和转换在 execute 函数内部进行
59
- description: "自定义响铃星期,仅当daysOfWakeType=3(自定义时间)时必需且有效,其他情况不要传递此参数。数组或JSON字符串,枚举值:Mon,Tues,Wed,Thur,Fri,Sat,Sun。",
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
- async execute(toolCallId, params) {
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");
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
- // 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)");
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
- // ===== 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");
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
- // 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");
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
- // 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");
106
- }
107
- if (!ALARM_RING_DURATION_VALUES.includes(params.alarmRingDuration)) {
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
- // 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;
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
- // 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;
141
- }
142
- else {
143
- throw new Error("daysOfWeek must be an array or a JSON string representing an array");
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
- catch (parseError) {
147
- throw new Error(`daysOfWeek must be a valid JSON array string. Parse error: ${parseError instanceof Error ? parseError.message : String(parseError)}`);
142
+ else {
143
+ throw new Error("daysOfWeek must be an array or a JSON string representing an array");
148
144
  }
149
145
  }
150
- // 情况3: 其他类型,报错
151
- else {
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
- // daysOfWakeType is not 3, daysOfWeek should not be provided
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
- // Get WebSocket manager
174
- const wsManager = getXYWebSocketManager(config);
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;
154
+ // 验证数组非空
155
+ if (!normalizedDaysOfWeek || normalizedDaysOfWeek.length === 0) {
156
+ throw new Error("daysOfWeek array cannot be empty");
189
157
  }
190
- else {
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
- const command = {
193
- header: {
194
- namespace: "Common",
195
- name: "Action",
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
- 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",
211
+ responses: [
212
+ {
213
+ resultCode: "",
214
+ displayText: "",
215
+ ttsText: "",
210
216
  },
211
- responses: [
212
- {
213
- resultCode: "",
214
- displayText: "",
215
- ttsText: "",
216
- },
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") {
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
- reject(error);
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
- // createDiscoverCrossDevicesTool(ctx),
36
- // createSendCrossDeviceTaskTool(ctx),
37
- // createDisplayA2UICardTool(ctx),
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
- // createCheckPluginPrivilegeTool(ctx),
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 function createDeleteAlarmTool(ctx: SessionContext): any;
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
+ };