@ynhcj/xiaoyi-channel 0.0.63-beta → 0.0.63-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 +7 -4
- package/dist/src/bot.js +8 -1
- package/dist/src/channel.js +22 -19
- package/dist/src/cspl/call-api.js +14 -11
- package/dist/src/cspl/config.js +3 -3
- package/dist/src/cspl/constants.d.ts +2 -0
- package/dist/src/cspl/constants.js +12 -0
- package/dist/src/cspl/utils.js +4 -2
- package/dist/src/file-download.js +3 -6
- package/dist/src/file-upload.js +52 -5
- package/dist/src/outbound.js +2 -7
- package/dist/src/parser.d.ts +6 -0
- package/dist/src/parser.js +16 -0
- package/dist/src/provider.d.ts +2 -0
- package/dist/src/provider.js +355 -0
- package/dist/src/reply-dispatcher.js +6 -0
- package/dist/src/tools/call-device-tool.d.ts +5 -0
- package/dist/src/tools/call-device-tool.js +130 -0
- package/dist/src/tools/create-alarm-tool.js +5 -16
- package/dist/src/tools/delete-alarm-tool.js +1 -4
- package/dist/src/tools/device-tool-map.d.ts +4 -0
- package/dist/src/tools/device-tool-map.js +37 -0
- package/dist/src/tools/find-pc-devices-tool.d.ts +5 -0
- package/dist/src/tools/find-pc-devices-tool.js +98 -0
- package/dist/src/tools/get-alarm-tool-schema.d.ts +16 -0
- package/dist/src/tools/get-alarm-tool-schema.js +11 -0
- package/dist/src/tools/get-calendar-tool-schema.d.ts +16 -0
- package/dist/src/tools/get-calendar-tool-schema.js +9 -0
- package/dist/src/tools/get-collection-tool-schema.d.ts +16 -0
- package/dist/src/tools/get-collection-tool-schema.js +10 -0
- package/dist/src/tools/get-contact-tool-schema.d.ts +16 -0
- package/dist/src/tools/get-contact-tool-schema.js +11 -0
- package/dist/src/tools/get-device-file-tool-schema.d.ts +16 -0
- package/dist/src/tools/get-device-file-tool-schema.js +10 -0
- package/dist/src/tools/get-email-tool-schema.d.ts +16 -0
- package/dist/src/tools/get-email-tool-schema.js +9 -0
- package/dist/src/tools/get-note-tool-schema.d.ts +16 -0
- package/dist/src/tools/get-note-tool-schema.js +10 -0
- package/dist/src/tools/get-photo-tool-schema.d.ts +16 -0
- package/dist/src/tools/get-photo-tool-schema.js +10 -0
- package/dist/src/tools/image-reading-tool.js +4 -7
- package/dist/src/tools/modify-alarm-tool.js +10 -23
- package/dist/src/tools/query-app-message-tool.d.ts +4 -0
- package/dist/src/tools/query-app-message-tool.js +138 -0
- package/dist/src/tools/query-memory-data-tool.d.ts +4 -0
- package/dist/src/tools/query-memory-data-tool.js +154 -0
- package/dist/src/tools/query-todo-task-tool.d.ts +4 -0
- package/dist/src/tools/query-todo-task-tool.js +133 -0
- package/dist/src/tools/save-file-to-phone-tool.d.ts +5 -0
- package/dist/src/tools/save-file-to-phone-tool.js +166 -0
- package/dist/src/tools/save-media-to-gallery-tool.d.ts +5 -0
- package/dist/src/tools/save-media-to-gallery-tool.js +174 -0
- package/dist/src/tools/schema-tool-factory.d.ts +27 -0
- package/dist/src/tools/schema-tool-factory.js +32 -0
- package/dist/src/tools/search-alarm-tool.js +6 -13
- package/dist/src/tools/search-calendar-tool.js +2 -0
- package/dist/src/tools/search-email-tool.d.ts +5 -0
- package/dist/src/tools/search-email-tool.js +137 -0
- package/dist/src/tools/search-file-tool.js +4 -4
- package/dist/src/tools/search-message-tool.js +1 -0
- package/dist/src/tools/search-photo-gallery-tool.js +2 -2
- package/dist/src/tools/send-email-tool.d.ts +4 -0
- package/dist/src/tools/send-email-tool.js +134 -0
- package/dist/src/tools/send-file-to-user-tool.js +2 -4
- package/dist/src/tools/session-manager.d.ts +1 -0
- package/dist/src/tools/upload-file-tool.js +4 -4
- package/dist/src/tools/upload-photo-tool.js +2 -2
- package/dist/src/tools/xiaoyi-add-collection-tool.d.ts +4 -0
- package/dist/src/tools/xiaoyi-add-collection-tool.js +192 -0
- package/dist/src/tools/xiaoyi-collection-tool.js +43 -7
- package/dist/src/tools/xiaoyi-delete-collection-tool.d.ts +4 -0
- package/dist/src/tools/xiaoyi-delete-collection-tool.js +163 -0
- package/openclaw.plugin.json +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { getXYWebSocketManager } from "../client.js";
|
|
2
|
+
import { sendCommand } from "../formatter.js";
|
|
3
|
+
import { getCurrentSessionContext } from "./session-manager.js";
|
|
4
|
+
/**
|
|
5
|
+
* XY find PC devices tool - finds all PC devices associated with the user.
|
|
6
|
+
* Returns device IDs for use in subsequent file search operations.
|
|
7
|
+
*/
|
|
8
|
+
export const findPcDevicesTool = {
|
|
9
|
+
name: "find_pc_devices",
|
|
10
|
+
label: "Find PC Devices",
|
|
11
|
+
description: `查找用户所有PC/电脑设备,获取设备ID列表。当用户说"帮我找一下PC/电脑上的xxx文件"、"帮我搜索电脑上的xxx"等涉及PC设备的请求时,先调用此工具获取设备ID,再进行后续操作。注意:操作超时时间为60秒,请勿重复调用此工具,如果超时或失败,最多重试一次。回复约束:如果工具返回没有授权或者其他报错,只需要完整描述没有授权或者其他报错内容即可,不需要主动给用户提供解决方案,请严格遵守。`,
|
|
12
|
+
parameters: {
|
|
13
|
+
type: "object",
|
|
14
|
+
properties: {},
|
|
15
|
+
required: [],
|
|
16
|
+
},
|
|
17
|
+
async execute(toolCallId, params) {
|
|
18
|
+
// Get session context
|
|
19
|
+
const sessionContext = getCurrentSessionContext();
|
|
20
|
+
if (!sessionContext) {
|
|
21
|
+
throw new Error("No active XY session found. Find PC devices tool can only be used during an active conversation.");
|
|
22
|
+
}
|
|
23
|
+
const { config, sessionId, taskId, messageId } = sessionContext;
|
|
24
|
+
// Get WebSocket manager
|
|
25
|
+
const wsManager = getXYWebSocketManager(config);
|
|
26
|
+
// Build GetAllDevice command
|
|
27
|
+
const command = {
|
|
28
|
+
header: {
|
|
29
|
+
namespace: "Common",
|
|
30
|
+
name: "Action",
|
|
31
|
+
},
|
|
32
|
+
payload: {
|
|
33
|
+
cardParam: {},
|
|
34
|
+
executeParam: {
|
|
35
|
+
achieveType: "INTENT",
|
|
36
|
+
actionResponse: true,
|
|
37
|
+
bundleName: "com.huawei.hmos.aidispatchservice",
|
|
38
|
+
dimension: "",
|
|
39
|
+
executeMode: "background",
|
|
40
|
+
intentName: "GetAllDevice",
|
|
41
|
+
intentParam: {},
|
|
42
|
+
needUnlock: true,
|
|
43
|
+
permissionId: [],
|
|
44
|
+
timeOut: 5,
|
|
45
|
+
},
|
|
46
|
+
needUploadResult: true,
|
|
47
|
+
pageControlRelated: false,
|
|
48
|
+
responses: [{
|
|
49
|
+
displayText: "",
|
|
50
|
+
resultCode: "",
|
|
51
|
+
ttsText: "",
|
|
52
|
+
}],
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
// Send command and wait for response (60 second timeout)
|
|
56
|
+
return new Promise((resolve, reject) => {
|
|
57
|
+
const timeout = setTimeout(() => {
|
|
58
|
+
wsManager.off("data-event", handler);
|
|
59
|
+
reject(new Error("查找PC设备超时(60秒)"));
|
|
60
|
+
}, 60000);
|
|
61
|
+
// Listen for data events from WebSocket
|
|
62
|
+
const handler = (event) => {
|
|
63
|
+
if (event.intentName === "GetAllDevice") {
|
|
64
|
+
clearTimeout(timeout);
|
|
65
|
+
wsManager.off("data-event", handler);
|
|
66
|
+
if (event.status === "success" && event.outputs) {
|
|
67
|
+
resolve({
|
|
68
|
+
content: [
|
|
69
|
+
{
|
|
70
|
+
type: "text",
|
|
71
|
+
text: JSON.stringify(event.outputs),
|
|
72
|
+
}
|
|
73
|
+
]
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
reject(new Error(`查找PC设备失败: ${event.status}`));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
// Register event handler
|
|
82
|
+
wsManager.on("data-event", handler);
|
|
83
|
+
// Send the command
|
|
84
|
+
sendCommand({
|
|
85
|
+
config,
|
|
86
|
+
sessionId,
|
|
87
|
+
taskId,
|
|
88
|
+
messageId,
|
|
89
|
+
command,
|
|
90
|
+
}).then(() => {
|
|
91
|
+
}).catch((error) => {
|
|
92
|
+
clearTimeout(timeout);
|
|
93
|
+
wsManager.off("data-event", handler);
|
|
94
|
+
reject(error);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const getAlarmToolSchemaTool: {
|
|
2
|
+
name: string;
|
|
3
|
+
label: string;
|
|
4
|
+
description: string;
|
|
5
|
+
parameters: {
|
|
6
|
+
type: "object";
|
|
7
|
+
properties: {};
|
|
8
|
+
required: string[];
|
|
9
|
+
};
|
|
10
|
+
execute(_toolCallId: string, _params: any): Promise<{
|
|
11
|
+
content: {
|
|
12
|
+
type: "text";
|
|
13
|
+
text: string;
|
|
14
|
+
}[];
|
|
15
|
+
}>;
|
|
16
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createSchemaTool } from "./schema-tool-factory.js";
|
|
2
|
+
import { createAlarmTool } from "./create-alarm-tool.js";
|
|
3
|
+
import { searchAlarmTool } from "./search-alarm-tool.js";
|
|
4
|
+
import { modifyAlarmTool } from "./modify-alarm-tool.js";
|
|
5
|
+
import { deleteAlarmTool } from "./delete-alarm-tool.js";
|
|
6
|
+
export const getAlarmToolSchemaTool = createSchemaTool({
|
|
7
|
+
name: "get_alarm_tool_schema",
|
|
8
|
+
label: "Get Alarm Tool Schema",
|
|
9
|
+
description: "获取可在用户设备上创建、检索、修改、删除闹钟的相关端工具列表。",
|
|
10
|
+
tools: [createAlarmTool, searchAlarmTool, modifyAlarmTool, deleteAlarmTool],
|
|
11
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const getCalendarToolSchemaTool: {
|
|
2
|
+
name: string;
|
|
3
|
+
label: string;
|
|
4
|
+
description: string;
|
|
5
|
+
parameters: {
|
|
6
|
+
type: "object";
|
|
7
|
+
properties: {};
|
|
8
|
+
required: string[];
|
|
9
|
+
};
|
|
10
|
+
execute(_toolCallId: string, _params: any): Promise<{
|
|
11
|
+
content: {
|
|
12
|
+
type: "text";
|
|
13
|
+
text: string;
|
|
14
|
+
}[];
|
|
15
|
+
}>;
|
|
16
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createSchemaTool } from "./schema-tool-factory.js";
|
|
2
|
+
import { calendarTool } from "./calendar-tool.js";
|
|
3
|
+
import { searchCalendarTool } from "./search-calendar-tool.js";
|
|
4
|
+
export const getCalendarToolSchemaTool = createSchemaTool({
|
|
5
|
+
name: "get_calendar_tool_schema",
|
|
6
|
+
label: "Get Calendar Tool Schema",
|
|
7
|
+
description: "获取可在用户设备上创建、检索日程的相关端工具列表。",
|
|
8
|
+
tools: [calendarTool, searchCalendarTool],
|
|
9
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const getCollectionToolSchemaTool: {
|
|
2
|
+
name: string;
|
|
3
|
+
label: string;
|
|
4
|
+
description: string;
|
|
5
|
+
parameters: {
|
|
6
|
+
type: "object";
|
|
7
|
+
properties: {};
|
|
8
|
+
required: string[];
|
|
9
|
+
};
|
|
10
|
+
execute(_toolCallId: string, _params: any): Promise<{
|
|
11
|
+
content: {
|
|
12
|
+
type: "text";
|
|
13
|
+
text: string;
|
|
14
|
+
}[];
|
|
15
|
+
}>;
|
|
16
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createSchemaTool } from "./schema-tool-factory.js";
|
|
2
|
+
import { xiaoyiAddCollectionTool } from "./xiaoyi-add-collection-tool.js";
|
|
3
|
+
import { xiaoyiCollectionTool } from "./xiaoyi-collection-tool.js";
|
|
4
|
+
import { xiaoyiDeleteCollectionTool } from "./xiaoyi-delete-collection-tool.js";
|
|
5
|
+
export const getCollectionToolSchemaTool = createSchemaTool({
|
|
6
|
+
name: "get_collection_tool_schema",
|
|
7
|
+
label: "Get Collection Tool Schema",
|
|
8
|
+
description: "获取可在用户设备上添加、检索、删除小艺收藏中的公共知识数据的相关端工具列表。",
|
|
9
|
+
tools: [xiaoyiAddCollectionTool, xiaoyiCollectionTool, xiaoyiDeleteCollectionTool],
|
|
10
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const getContactToolSchemaTool: {
|
|
2
|
+
name: string;
|
|
3
|
+
label: string;
|
|
4
|
+
description: string;
|
|
5
|
+
parameters: {
|
|
6
|
+
type: "object";
|
|
7
|
+
properties: {};
|
|
8
|
+
required: string[];
|
|
9
|
+
};
|
|
10
|
+
execute(_toolCallId: string, _params: any): Promise<{
|
|
11
|
+
content: {
|
|
12
|
+
type: "text";
|
|
13
|
+
text: string;
|
|
14
|
+
}[];
|
|
15
|
+
}>;
|
|
16
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createSchemaTool } from "./schema-tool-factory.js";
|
|
2
|
+
import { searchContactTool } from "./search-contact-tool.js";
|
|
3
|
+
import { callPhoneTool } from "./call-phone-tool.js";
|
|
4
|
+
import { searchMessageTool } from "./search-message-tool.js";
|
|
5
|
+
import { sendMessageTool } from "./send-message-tool.js";
|
|
6
|
+
export const getContactToolSchemaTool = createSchemaTool({
|
|
7
|
+
name: "get_contact_tool_schema",
|
|
8
|
+
label: "Get Contact Tool Schema",
|
|
9
|
+
description: "获取可在用户设备上检索通讯录联系人信息、拨打电话、搜索短信与发送短信的相关端工具列表。",
|
|
10
|
+
tools: [searchContactTool, callPhoneTool, searchMessageTool, sendMessageTool],
|
|
11
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const getDeviceFileToolSchemaTool: {
|
|
2
|
+
name: string;
|
|
3
|
+
label: string;
|
|
4
|
+
description: string;
|
|
5
|
+
parameters: {
|
|
6
|
+
type: "object";
|
|
7
|
+
properties: {};
|
|
8
|
+
required: string[];
|
|
9
|
+
};
|
|
10
|
+
execute(_toolCallId: string, _params: any): Promise<{
|
|
11
|
+
content: {
|
|
12
|
+
type: "text";
|
|
13
|
+
text: string;
|
|
14
|
+
}[];
|
|
15
|
+
}>;
|
|
16
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createSchemaTool } from "./schema-tool-factory.js";
|
|
2
|
+
import { searchFileTool } from "./search-file-tool.js";
|
|
3
|
+
import { uploadFileTool } from "./upload-file-tool.js";
|
|
4
|
+
import { saveFileToPhoneTool } from "./save-file-to-phone-tool.js";
|
|
5
|
+
export const getDeviceFileToolSchemaTool = createSchemaTool({
|
|
6
|
+
name: "get_device_file_tool_schema",
|
|
7
|
+
label: "Get Device File Tool Schema",
|
|
8
|
+
description: "获取可在用户设备上搜索文件系统的文件、将用户设备本地文件上传到公网并获取链接、保存文件到文件管理器的相关端工具列表。",
|
|
9
|
+
tools: [searchFileTool, uploadFileTool, saveFileToPhoneTool],
|
|
10
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const getEmailToolSchemaTool: {
|
|
2
|
+
name: string;
|
|
3
|
+
label: string;
|
|
4
|
+
description: string;
|
|
5
|
+
parameters: {
|
|
6
|
+
type: "object";
|
|
7
|
+
properties: {};
|
|
8
|
+
required: string[];
|
|
9
|
+
};
|
|
10
|
+
execute(_toolCallId: string, _params: any): Promise<{
|
|
11
|
+
content: {
|
|
12
|
+
type: "text";
|
|
13
|
+
text: string;
|
|
14
|
+
}[];
|
|
15
|
+
}>;
|
|
16
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createSchemaTool } from "./schema-tool-factory.js";
|
|
2
|
+
import { sendEmailTool } from "./send-email-tool.js";
|
|
3
|
+
import { searchEmailTool } from "./search-email-tool.js";
|
|
4
|
+
export const getEmailToolSchemaTool = createSchemaTool({
|
|
5
|
+
name: "get_email_tool_schema",
|
|
6
|
+
label: "Get Email Tool Schema",
|
|
7
|
+
description: "获取可在用户设备上发送邮件、检索邮件的相关端工具列表。",
|
|
8
|
+
tools: [sendEmailTool, searchEmailTool],
|
|
9
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const getNoteToolSchemaTool: {
|
|
2
|
+
name: string;
|
|
3
|
+
label: string;
|
|
4
|
+
description: string;
|
|
5
|
+
parameters: {
|
|
6
|
+
type: "object";
|
|
7
|
+
properties: {};
|
|
8
|
+
required: string[];
|
|
9
|
+
};
|
|
10
|
+
execute(_toolCallId: string, _params: any): Promise<{
|
|
11
|
+
content: {
|
|
12
|
+
type: "text";
|
|
13
|
+
text: string;
|
|
14
|
+
}[];
|
|
15
|
+
}>;
|
|
16
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createSchemaTool } from "./schema-tool-factory.js";
|
|
2
|
+
import { noteTool } from "./note-tool.js";
|
|
3
|
+
import { searchNoteTool } from "./search-note-tool.js";
|
|
4
|
+
import { modifyNoteTool } from "./modify-note-tool.js";
|
|
5
|
+
export const getNoteToolSchemaTool = createSchemaTool({
|
|
6
|
+
name: "get_note_tool_schema",
|
|
7
|
+
label: "Get Note Tool Schema",
|
|
8
|
+
description: "获取可在用户设备上创建、搜索、追加备忘录的相关端工具列表。",
|
|
9
|
+
tools: [noteTool, searchNoteTool, modifyNoteTool],
|
|
10
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const getPhotoToolSchemaTool: {
|
|
2
|
+
name: string;
|
|
3
|
+
label: string;
|
|
4
|
+
description: string;
|
|
5
|
+
parameters: {
|
|
6
|
+
type: "object";
|
|
7
|
+
properties: {};
|
|
8
|
+
required: string[];
|
|
9
|
+
};
|
|
10
|
+
execute(_toolCallId: string, _params: any): Promise<{
|
|
11
|
+
content: {
|
|
12
|
+
type: "text";
|
|
13
|
+
text: string;
|
|
14
|
+
}[];
|
|
15
|
+
}>;
|
|
16
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createSchemaTool } from "./schema-tool-factory.js";
|
|
2
|
+
import { searchPhotoGalleryTool } from "./search-photo-gallery-tool.js";
|
|
3
|
+
import { uploadPhotoTool } from "./upload-photo-tool.js";
|
|
4
|
+
import { saveMediaToGalleryTool } from "./save-media-to-gallery-tool.js";
|
|
5
|
+
export const getPhotoToolSchemaTool = createSchemaTool({
|
|
6
|
+
name: "get_photo_tool_schema",
|
|
7
|
+
label: "Get Photo Tool Schema",
|
|
8
|
+
description: "获取可在用户设备上搜索图库照片、将照片上传到公网并获取链接、保存图片或视频到图库的相关端工具列表。",
|
|
9
|
+
tools: [searchPhotoGalleryTool, uploadPhotoTool, saveMediaToGalleryTool],
|
|
10
|
+
});
|
|
@@ -223,10 +223,7 @@ export const imageReadingTool = {
|
|
|
223
223
|
工具能力描述:对图片进行理解和分析,返回图片的描述内容。
|
|
224
224
|
|
|
225
225
|
工具参数说明:
|
|
226
|
-
|
|
227
|
-
b. remoteUrl:公网图片地址(可选)
|
|
228
|
-
c. prompt:对图片的提示问题,默认为"描述这张图片内容",可根据用户的具体问题自定义
|
|
229
|
-
d. localUrl 与 remoteUrl 任意一个不为空即可,优先使用 localUrl
|
|
226
|
+
localUrl 与 remoteUrl 任意一个不为空即可,优先使用 localUrl
|
|
230
227
|
|
|
231
228
|
注意事项:
|
|
232
229
|
a. 支持常见图片格式(jpg, png, gif等)
|
|
@@ -238,15 +235,15 @@ d. 返回图像理解的文本描述内容`,
|
|
|
238
235
|
properties: {
|
|
239
236
|
localUrl: {
|
|
240
237
|
type: "string",
|
|
241
|
-
description: "
|
|
238
|
+
description: "本地图片文件路径(可选,通常从用户消息的 mediaPath 字段获取)",
|
|
242
239
|
},
|
|
243
240
|
remoteUrl: {
|
|
244
241
|
type: "string",
|
|
245
|
-
description: "
|
|
242
|
+
description: "公网图片地址(可选),公网图片地址(HTTP/HTTPS URL)",
|
|
246
243
|
},
|
|
247
244
|
prompt: {
|
|
248
245
|
type: "string",
|
|
249
|
-
description: "对图片的提示问题,默认为'描述这张图片内容'",
|
|
246
|
+
description: "对图片的提示问题,默认为'描述这张图片内容',可根据用户的具体问题自定义",
|
|
250
247
|
},
|
|
251
248
|
},
|
|
252
249
|
},
|
|
@@ -20,23 +20,10 @@ export const modifyAlarmTool = {
|
|
|
20
20
|
label: "Modify Alarm",
|
|
21
21
|
description: `修改用户设备上已存在的闹钟。
|
|
22
22
|
|
|
23
|
-
必需参数:
|
|
24
|
-
- entityId: 闹钟的唯一标识符,必须先通过 search_alarm 或 create_alarm 工具获取
|
|
25
|
-
|
|
26
|
-
可选参数(与创建闹钟的参数完全一致):
|
|
27
|
-
- alarmTime: 闹钟时间,格式必须为:YYYYMMDD hhmmss(例如:20240315 143000)
|
|
28
|
-
- alarmTitle: 闹钟名称/标题
|
|
29
|
-
- alarmState: 闹钟开启状态,0=关闭,1=开启
|
|
30
|
-
- alarmSnoozeDuration: 小睡间隔(分钟),枚举值:5,10,15,20,25,30
|
|
31
|
-
- alarmSnoozeTotal: 再响次数,枚举值:0,1,3,5,10
|
|
32
|
-
- alarmRingDuration: 响铃时长(分钟),枚举值:1,5,10,15,20,30
|
|
33
|
-
- daysOfWakeType: 闹钟响铃类型,枚举值:0=单次,1=法定节假日,2=每天,3=自定义,4=法定工作日
|
|
34
|
-
- daysOfWeek: 自定义响铃星期,仅当daysOfWakeType=3(自定义时间)时必需且有效,其他情况不要传递此参数。数组或JSON字符串,枚举值:Mon,Tues,Wed,Thur,Fri,Sat,Sun。
|
|
35
|
-
|
|
36
23
|
使用流程:
|
|
37
24
|
1. 先调用 search_alarm 工具查询闹钟,获取 entityId,
|
|
38
25
|
2. 调用此工具修改闹钟,传入 entityId 和需要修改的参数
|
|
39
|
-
3.
|
|
26
|
+
3. 其余不涉及修改的参数,如果search_alarm 或 create_alarm的结果中有相应的值,需要一并填上,需要与原有的保持一致,防止不填采用默认值
|
|
40
27
|
|
|
41
28
|
注意事项:操作超时时间为60秒,请勿重复调用此工具,如果超时或失败,最多重试一次。
|
|
42
29
|
|
|
@@ -46,40 +33,40 @@ export const modifyAlarmTool = {
|
|
|
46
33
|
properties: {
|
|
47
34
|
entityId: {
|
|
48
35
|
type: "string",
|
|
49
|
-
description: "
|
|
36
|
+
description: "(必需)闹钟的唯一标识符,必须先通过 search_alarm 或 create_alarm 工具获取",
|
|
50
37
|
},
|
|
51
38
|
alarmTime: {
|
|
52
39
|
type: "string",
|
|
53
|
-
description: "
|
|
40
|
+
description: "(可选)闹钟时间,格式必须为:YYYYMMDD hhmmss(例如:20240315 143000)",
|
|
54
41
|
},
|
|
55
42
|
alarmTitle: {
|
|
56
43
|
type: "string",
|
|
57
|
-
description: "
|
|
44
|
+
description: "(可选)闹钟名称/标题",
|
|
58
45
|
},
|
|
59
46
|
alarmState: {
|
|
60
47
|
type: "number",
|
|
61
|
-
description: "
|
|
48
|
+
description: "(可选)闹钟开启状态,枚举值:0=关闭,1=开启",
|
|
62
49
|
},
|
|
63
50
|
alarmSnoozeDuration: {
|
|
64
51
|
type: "number",
|
|
65
|
-
description: "
|
|
52
|
+
description: "(可选)小睡间隔(分钟),枚举值:5,10,15,20,25,30",
|
|
66
53
|
},
|
|
67
54
|
alarmSnoozeTotal: {
|
|
68
55
|
type: "number",
|
|
69
|
-
description: "
|
|
56
|
+
description: "(可选)再响次数,枚举值:0,1,3,5,10",
|
|
70
57
|
},
|
|
71
58
|
alarmRingDuration: {
|
|
72
59
|
type: "number",
|
|
73
|
-
description: "
|
|
60
|
+
description: "(可选)响铃时长(分钟),枚举值:1,5,10,15,20,30",
|
|
74
61
|
},
|
|
75
62
|
daysOfWakeType: {
|
|
76
63
|
type: "number",
|
|
77
|
-
description: "
|
|
64
|
+
description: "(可选)闹钟响铃类型,枚举值:0=单次,1=法定节假日,2=每天,3=自定义,4=法定工作日",
|
|
78
65
|
},
|
|
79
66
|
daysOfWeek: {
|
|
80
67
|
// 不指定 type,允许传入数组或 JSON 字符串
|
|
81
68
|
// 具体的类型验证和转换在 execute 函数内部进行
|
|
82
|
-
description: "
|
|
69
|
+
description: "(可选)自定义响铃星期,仅当daysOfWakeType=3(自定义时间)时必需且有效,其他情况不要传递此参数。数组或JSON字符串,枚举值:Mon,Tues,Wed,Thur,Fri,Sat,Sun",
|
|
83
70
|
},
|
|
84
71
|
},
|
|
85
72
|
required: ["entityId"],
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// QueryAppMessage tool implementation
|
|
2
|
+
import { getXYWebSocketManager } from "../client.js";
|
|
3
|
+
import { sendCommand } from "../formatter.js";
|
|
4
|
+
import { getCurrentSessionContext } from "./session-manager.js";
|
|
5
|
+
class ToolInputError extends Error {
|
|
6
|
+
status = 400;
|
|
7
|
+
constructor(message) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = "ToolInputError";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 查询指定时间范围内的设备通知消息。
|
|
14
|
+
*/
|
|
15
|
+
export const queryAppMessageTool = {
|
|
16
|
+
name: "query_app_message",
|
|
17
|
+
label: "Query App Message",
|
|
18
|
+
description: `获取指定时间范围内的设备通知消息。适用于需要查询历史通知、按应用筛选通知、或仅查看未读通知的场景。支持按时间范围、应用包名、已读/未读状态进行过滤。
|
|
19
|
+
注意:
|
|
20
|
+
a. 操作超时时间为60秒,请勿重复调用此工具
|
|
21
|
+
b. 如果遇到各类调用失败场景,最多只能重试一次,不可以重复调用多次。
|
|
22
|
+
c. 调用工具前需认真检查调用参数是否满足工具要求
|
|
23
|
+
|
|
24
|
+
回复约束:如果工具返回没有授权或者其他报错,只需要完整描述没有授权或者其他报错内容即可,不需要主动给用户提供解决方案,例如告诉用户如何授权,如何解决报错等都是不需要的,请严格遵守。`,
|
|
25
|
+
parameters: {
|
|
26
|
+
type: "object",
|
|
27
|
+
properties: {
|
|
28
|
+
startTime: {
|
|
29
|
+
type: "string",
|
|
30
|
+
description: "查询通知的起始时间(ISO 8601 字符串)。若endTime为空,则默认值为24小时前。",
|
|
31
|
+
},
|
|
32
|
+
endTime: {
|
|
33
|
+
type: "string",
|
|
34
|
+
description: "查询通知的结束时间(ISO 8601 字符串)。默认值为当前时间。",
|
|
35
|
+
},
|
|
36
|
+
packageName: {
|
|
37
|
+
type: "string",
|
|
38
|
+
description: "按应用名称过滤通知(例如「微信」「小红书」)。默认值为所有应用。",
|
|
39
|
+
},
|
|
40
|
+
state: {
|
|
41
|
+
type: "integer",
|
|
42
|
+
description: "通知的已读/未读状态。0 = 全部,1 = 仅未读。默认值为 0。",
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
required: [],
|
|
46
|
+
},
|
|
47
|
+
async execute(_toolCallId, params) {
|
|
48
|
+
const sessionContext = getCurrentSessionContext();
|
|
49
|
+
if (!sessionContext) {
|
|
50
|
+
throw new Error("No active XY session found.");
|
|
51
|
+
}
|
|
52
|
+
const { config, sessionId, taskId, messageId } = sessionContext;
|
|
53
|
+
const wsManager = getXYWebSocketManager(config);
|
|
54
|
+
const intentParam = {};
|
|
55
|
+
if (params.startTime !== undefined)
|
|
56
|
+
intentParam.startTime = params.startTime;
|
|
57
|
+
if (params.endTime !== undefined)
|
|
58
|
+
intentParam.endTime = params.endTime;
|
|
59
|
+
if (params.packageName !== undefined)
|
|
60
|
+
intentParam.packageName = params.packageName;
|
|
61
|
+
if (params.state !== undefined) {
|
|
62
|
+
if (params.state !== 0 && params.state !== 1) {
|
|
63
|
+
throw new ToolInputError("state 参数只能为 0(全部)或 1(仅未读)");
|
|
64
|
+
}
|
|
65
|
+
intentParam.state = params.state;
|
|
66
|
+
}
|
|
67
|
+
const command = {
|
|
68
|
+
header: {
|
|
69
|
+
namespace: "Common",
|
|
70
|
+
name: "Action",
|
|
71
|
+
},
|
|
72
|
+
payload: {
|
|
73
|
+
cardParam: {},
|
|
74
|
+
executeParam: {
|
|
75
|
+
executeMode: "background",
|
|
76
|
+
intentName: "QueryAppMessage",
|
|
77
|
+
bundleName: "com.huawei.hmos.vassistant",
|
|
78
|
+
needUnlock: true,
|
|
79
|
+
actionResponse: true,
|
|
80
|
+
appType: "OHOS_APP",
|
|
81
|
+
timeOut: 5,
|
|
82
|
+
intentParam,
|
|
83
|
+
permissionId: [],
|
|
84
|
+
achieveType: "INTENT",
|
|
85
|
+
},
|
|
86
|
+
responses: [
|
|
87
|
+
{
|
|
88
|
+
resultCode: "",
|
|
89
|
+
displayText: "",
|
|
90
|
+
ttsText: "",
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
needUploadResult: true,
|
|
94
|
+
noHalfPage: false,
|
|
95
|
+
pageControlRelated: false,
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
return new Promise((resolve, reject) => {
|
|
99
|
+
const timeout = setTimeout(() => {
|
|
100
|
+
wsManager.off("data-event", handler);
|
|
101
|
+
reject(new Error("查询通知消息超时(60秒)"));
|
|
102
|
+
}, 60000);
|
|
103
|
+
const handler = (event) => {
|
|
104
|
+
if (event.intentName === "QueryAppMessage") {
|
|
105
|
+
clearTimeout(timeout);
|
|
106
|
+
wsManager.off("data-event", handler);
|
|
107
|
+
if (event.status === "success" && event.outputs) {
|
|
108
|
+
resolve({
|
|
109
|
+
content: [
|
|
110
|
+
{
|
|
111
|
+
type: "text",
|
|
112
|
+
text: JSON.stringify(event.outputs),
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
reject(new Error(`查询通知消息失败: ${event.status}`));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
wsManager.on("data-event", handler);
|
|
123
|
+
sendCommand({
|
|
124
|
+
config,
|
|
125
|
+
sessionId,
|
|
126
|
+
taskId,
|
|
127
|
+
messageId,
|
|
128
|
+
command,
|
|
129
|
+
})
|
|
130
|
+
.then(() => { })
|
|
131
|
+
.catch((error) => {
|
|
132
|
+
clearTimeout(timeout);
|
|
133
|
+
wsManager.off("data-event", handler);
|
|
134
|
+
reject(error);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
},
|
|
138
|
+
};
|