@ynhcj/xiaoyi-channel 0.0.44-next → 0.0.45-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.
@@ -1,24 +1,33 @@
1
1
  // Device type to tool name mapping.
2
- // Only tools listed under a device type are available for that device.
3
- // Tools NOT listed here are available to ALL devices (no restriction).
2
+ // Supports two modes:
3
+ // - allowlist: only listed tools are available (used for restrictive devices like car)
4
+ // - denylist: listed tools are blocked, everything else is available (used for permissive devices like pc)
5
+ // Tools NOT listed in any device entry → available to all devices (no restriction).
4
6
  /** Known device type enum. */
5
7
  export const DEVICE_TYPES = ["car", "pc", "phone"];
6
- /**
7
- * Map: deviceType tool names allowed for that device.
8
- * undefined / empty deviceType → all tools available.
9
- * Unrecognized deviceType → all tools available.
10
- * Tool not listed in any device entry → available to all devices.
11
- */
12
- const DEVICE_TOOL_ALLOWLIST = {
13
- car: ["send_command_to_car"],
14
- pc: ["location"],
15
- phone: ["location"],
8
+ const DEVICE_TOOL_POLICY = {
9
+ car: { allowlist: true, tools: ["send_command_to_car"] },
10
+ pc: {
11
+ allowlist: false,
12
+ tools: [
13
+ "xiaoyi_gui_agent",
14
+ "call_phone",
15
+ "send_message",
16
+ "search_contact",
17
+ ],
18
+ },
19
+ phone: { allowlist: true, tools: ["get_user_location"] },
16
20
  };
17
21
  export function filterToolsByDevice(tools, deviceType) {
18
22
  if (!deviceType)
19
23
  return tools;
20
- const allowedTools = DEVICE_TOOL_ALLOWLIST[deviceType];
21
- if (!allowedTools)
24
+ const policy = DEVICE_TOOL_POLICY[deviceType];
25
+ if (!policy)
22
26
  return tools; // unrecognized device → no filtering
23
- return tools.filter((tool) => allowedTools.includes(tool.name));
27
+ if (policy.allowlist) {
28
+ return tools.filter((tool) => policy.tools.includes(tool.name));
29
+ }
30
+ else {
31
+ return tools.filter((tool) => !policy.tools.includes(tool.name));
32
+ }
24
33
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ynhcj/xiaoyi-channel",
3
- "version": "0.0.44-next",
3
+ "version": "0.0.45-next",
4
4
  "description": "OpenClaw Xiaoyi Channel plugin - Xiaoyi A2A protocol integration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",