@ynhcj/xiaoyi-channel 0.0.30-beta → 0.0.32-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,7 +26,7 @@ export const createAlarmTool = {
26
26
  - alarmTitle: 闹钟名称/标题,默认为"闹钟"
27
27
  - alarmSnoozeDuration: 小睡间隔(分钟),枚举值:5,10,15,20,25,30,默认10
28
28
  - alarmSnoozeTotal: 再响次数,枚举值:0,1,3,5,10,默认0(表示不再响)
29
- - alarmRingDuration: 响铃时长(分钟),枚举值:1,5,10,15,20,30,默认20
29
+ - alarmRingDuration: 响铃时长(分钟),枚举值:1,5,10,15,20,30,默认5
30
30
  - daysOfWakeType: 闹钟响铃类型,枚举值:0=单次响铃,1=法定节假日,2=每天,3=自定义时间,4=法定工作日,默认0
31
31
  - daysOfWeek: 自定义响铃星期,仅当daysOfWakeType=3(自定义时间)时必需且有效,其他情况不要传递此参数。数组或JSON字符串,枚举值:Mon,Tue,Wed,Thu,Fri,Sat,Sun。注意:仅支持长度为1的数组,如果需要一周中不同的几天,需要多次调用此工具
32
32
 
@@ -2,6 +2,18 @@ import { getXYWebSocketManager } from "../client.js";
2
2
  import { sendCommand } from "../formatter.js";
3
3
  import { getCurrentSessionContext } from "./session-manager.js";
4
4
  import { logger } from "../utils/logger.js";
5
+ /**
6
+ * Duck-typed ToolInputError: openclaw 按 .name 字段匹配,不用 instanceof。
7
+ * 抛出此错误会让 openclaw 返回 HTTP 400 而非 500,
8
+ * LLM 会将其识别为参数错误而非瞬时故障,不会触发重试。
9
+ */
10
+ class ToolInputError extends Error {
11
+ status = 400;
12
+ constructor(message) {
13
+ super(message);
14
+ this.name = "ToolInputError";
15
+ }
16
+ }
5
17
  /**
6
18
  * XY note tool - creates a note on user's device.
7
19
  * Requires title and content parameters.
@@ -9,26 +21,35 @@ import { logger } from "../utils/logger.js";
9
21
  export const noteTool = {
10
22
  name: "create_note",
11
23
  label: "Create Note",
12
- description: "在用户设备上创建备忘录。需要提供备忘录标题和内容。注意:操作超时时间为60秒,请勿重复调用此工具,如果超时或失败,最多重试一次。",
24
+ description: `在用户设备上创建备忘录。需要提供备忘录标题和内容。
25
+ 注意:
26
+ a. 操作超时时间为60秒,请勿重复调用此工具
27
+ b. 如果遇到各类调用失败场景,最多只能重试一次,不可以重复调用多次。
28
+ c. 调用工具前需认真检查调用参数是否满足工具要求
29
+ `,
13
30
  parameters: {
14
31
  type: "object",
15
32
  properties: {
16
33
  title: {
17
34
  type: "string",
18
- description: "备忘录标题",
35
+ description: "备忘录标题,必填",
19
36
  },
20
37
  content: {
21
38
  type: "string",
22
- description: "备忘录内容",
39
+ description: "备忘录内容,必填",
23
40
  },
24
41
  },
25
42
  required: ["title", "content"],
26
43
  },
27
44
  async execute(toolCallId, params) {
28
45
  logger.debug("Executing note tool, toolCallId:", toolCallId);
29
- // Validate parameters
30
- if (!params.title || !params.content) {
31
- throw new Error("Missing required parameters: title and content are required");
46
+ // Validate parameters — 抛 ToolInputError 而非普通 Error,
47
+ // openclaw 返回 400 而非 500,明确告知 LLM 这是参数错误,不应重试。
48
+ if (typeof params.title !== "string" || !params.title) {
49
+ throw new ToolInputError("缺少必填参数 title(备忘录标题)");
50
+ }
51
+ if (typeof params.content !== "string" || !params.content) {
52
+ throw new ToolInputError("缺少必填参数 content(备忘录内容)");
32
53
  }
33
54
  // Get session context
34
55
  const sessionContext = getCurrentSessionContext();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ynhcj/xiaoyi-channel",
3
- "version": "0.0.30-beta",
3
+ "version": "0.0.32-beta",
4
4
  "description": "OpenClaw Xiaoyi Channel plugin - Xiaoyi A2A protocol integration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",