@ynhcj/xiaoyi-channel 0.0.72-beta → 0.0.72-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.d.ts +0 -5
- package/dist/index.js +51 -14
- package/dist/src/bot.js +27 -3
- package/dist/src/channel.js +15 -23
- 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/login-token-handler.d.ts +8 -0
- package/dist/src/login-token-handler.js +60 -0
- package/dist/src/message-queue.d.ts +17 -0
- package/dist/src/message-queue.js +51 -0
- package/dist/src/monitor.js +54 -3
- package/dist/src/outbound.js +2 -7
- package/dist/src/provider.d.ts +1 -0
- package/dist/src/provider.js +442 -43
- package/dist/src/reply-dispatcher.js +6 -0
- package/dist/src/self-evolution-handler.d.ts +7 -0
- package/dist/src/self-evolution-handler.js +141 -0
- package/dist/src/self-evolution-keyword.d.ts +9 -0
- package/dist/src/self-evolution-keyword.js +145 -0
- package/dist/src/skill-retriever/config.d.ts +4 -0
- package/dist/src/skill-retriever/config.js +23 -0
- package/dist/src/skill-retriever/hooks.d.ts +22 -0
- package/dist/src/skill-retriever/hooks.js +91 -0
- package/dist/src/skill-retriever/tool-search.d.ts +16 -0
- package/dist/src/skill-retriever/tool-search.js +159 -0
- package/dist/src/skill-retriever/types.d.ts +34 -0
- package/dist/src/skill-retriever/types.js +1 -0
- package/dist/src/task-manager.d.ts +4 -0
- package/dist/src/task-manager.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.js +5 -1
- 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/login-token-tool.d.ts +5 -0
- package/dist/src/tools/login-token-tool.js +136 -0
- 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.js +3 -7
- package/dist/src/tools/save-self-evolution-skill-tool.d.ts +1 -0
- package/dist/src/tools/save-self-evolution-skill-tool.js +412 -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.js +2 -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.js +35 -6
- package/dist/src/tools/xiaoyi-collection-tool.js +2 -1
- package/dist/src/tools/xiaoyi-delete-collection-tool.js +1 -1
- package/dist/src/utils/runtime-manager.js +24 -2
- package/dist/src/utils/self-evolution-manager.d.ts +5 -0
- package/dist/src/utils/self-evolution-manager.js +47 -0
- package/dist/src/utils/tool-call-nudge-manager.d.ts +16 -0
- package/dist/src/utils/tool-call-nudge-manager.js +47 -0
- package/dist/src/websocket.d.ts +3 -0
- package/dist/src/websocket.js +71 -0
- package/openclaw.plugin.json +1 -0
- package/package.json +2 -2
|
@@ -48,6 +48,10 @@ export declare function hasActiveTask(sessionId: string): boolean;
|
|
|
48
48
|
* 获取完整的binding信息(用于调试)
|
|
49
49
|
*/
|
|
50
50
|
export declare function getTaskIdBinding(sessionId: string): TaskIdBinding | null;
|
|
51
|
+
/**
|
|
52
|
+
* 获取所有活跃的 task bindings(用于 gateway_stop 通知等场景)
|
|
53
|
+
*/
|
|
54
|
+
export declare function getAllActiveTaskBindings(): TaskIdBinding[];
|
|
51
55
|
/**
|
|
52
56
|
* 强制清理(错误恢复用)
|
|
53
57
|
*/
|
package/dist/src/task-manager.js
CHANGED
|
@@ -127,6 +127,12 @@ export function hasActiveTask(sessionId) {
|
|
|
127
127
|
export function getTaskIdBinding(sessionId) {
|
|
128
128
|
return activeTaskIds.get(sessionId) ?? null;
|
|
129
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* 获取所有活跃的 task bindings(用于 gateway_stop 通知等场景)
|
|
132
|
+
*/
|
|
133
|
+
export function getAllActiveTaskBindings() {
|
|
134
|
+
return Array.from(activeTaskIds.values());
|
|
135
|
+
}
|
|
130
136
|
/**
|
|
131
137
|
* 强制清理(错误恢复用)
|
|
132
138
|
*/
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { noteTool } from "./note-tool.js";
|
|
2
|
+
import { searchNoteTool } from "./search-note-tool.js";
|
|
3
|
+
import { modifyNoteTool } from "./modify-note-tool.js";
|
|
4
|
+
import { createAlarmTool } from "./create-alarm-tool.js";
|
|
5
|
+
import { searchAlarmTool } from "./search-alarm-tool.js";
|
|
6
|
+
import { modifyAlarmTool } from "./modify-alarm-tool.js";
|
|
7
|
+
import { deleteAlarmTool } from "./delete-alarm-tool.js";
|
|
8
|
+
import { searchContactTool } from "./search-contact-tool.js";
|
|
9
|
+
import { callPhoneTool } from "./call-phone-tool.js";
|
|
10
|
+
import { searchMessageTool } from "./search-message-tool.js";
|
|
11
|
+
import { sendMessageTool } from "./send-message-tool.js";
|
|
12
|
+
import { xiaoyiAddCollectionTool } from "./xiaoyi-add-collection-tool.js";
|
|
13
|
+
import { xiaoyiCollectionTool } from "./xiaoyi-collection-tool.js";
|
|
14
|
+
import { xiaoyiDeleteCollectionTool } from "./xiaoyi-delete-collection-tool.js";
|
|
15
|
+
import { calendarTool } from "./calendar-tool.js";
|
|
16
|
+
import { searchCalendarTool } from "./search-calendar-tool.js";
|
|
17
|
+
import { searchPhotoGalleryTool } from "./search-photo-gallery-tool.js";
|
|
18
|
+
import { uploadPhotoTool } from "./upload-photo-tool.js";
|
|
19
|
+
import { saveMediaToGalleryTool } from "./save-media-to-gallery-tool.js";
|
|
20
|
+
import { searchFileTool } from "./search-file-tool.js";
|
|
21
|
+
import { uploadFileTool } from "./upload-file-tool.js";
|
|
22
|
+
import { saveFileToPhoneTool } from "./save-file-to-phone-tool.js";
|
|
23
|
+
import { sendEmailTool } from "./send-email-tool.js";
|
|
24
|
+
import { searchEmailTool } from "./search-email-tool.js";
|
|
25
|
+
import { sendStatusUpdate } from "../formatter.js";
|
|
26
|
+
import { getCurrentSessionContext } from "./session-manager.js";
|
|
27
|
+
import { getCurrentTaskId, getCurrentMessageId } from "../task-manager.js";
|
|
28
|
+
/**
|
|
29
|
+
* 端工具注册表 —— 按 name 索引所有可通过 call_device_tool 调度的工具。
|
|
30
|
+
*/
|
|
31
|
+
const deviceToolRegistry = new Map([
|
|
32
|
+
[noteTool.name, noteTool],
|
|
33
|
+
[searchNoteTool.name, searchNoteTool],
|
|
34
|
+
[modifyNoteTool.name, modifyNoteTool],
|
|
35
|
+
[createAlarmTool.name, createAlarmTool],
|
|
36
|
+
[searchAlarmTool.name, searchAlarmTool],
|
|
37
|
+
[modifyAlarmTool.name, modifyAlarmTool],
|
|
38
|
+
[deleteAlarmTool.name, deleteAlarmTool],
|
|
39
|
+
[searchContactTool.name, searchContactTool],
|
|
40
|
+
[callPhoneTool.name, callPhoneTool],
|
|
41
|
+
[searchMessageTool.name, searchMessageTool],
|
|
42
|
+
[sendMessageTool.name, sendMessageTool],
|
|
43
|
+
[xiaoyiAddCollectionTool.name, xiaoyiAddCollectionTool],
|
|
44
|
+
[xiaoyiCollectionTool.name, xiaoyiCollectionTool],
|
|
45
|
+
[xiaoyiDeleteCollectionTool.name, xiaoyiDeleteCollectionTool],
|
|
46
|
+
[calendarTool.name, calendarTool],
|
|
47
|
+
[searchCalendarTool.name, searchCalendarTool],
|
|
48
|
+
[searchPhotoGalleryTool.name, searchPhotoGalleryTool],
|
|
49
|
+
[uploadPhotoTool.name, uploadPhotoTool],
|
|
50
|
+
[saveMediaToGalleryTool.name, saveMediaToGalleryTool],
|
|
51
|
+
[searchFileTool.name, searchFileTool],
|
|
52
|
+
[uploadFileTool.name, uploadFileTool],
|
|
53
|
+
[saveFileToPhoneTool.name, saveFileToPhoneTool],
|
|
54
|
+
[sendEmailTool.name, sendEmailTool],
|
|
55
|
+
[searchEmailTool.name, searchEmailTool],
|
|
56
|
+
]);
|
|
57
|
+
/**
|
|
58
|
+
* call_device_tool - 通用端工具调度器。
|
|
59
|
+
* LLM 必须先通过 get_xxx_tool_schema 获取具体工具 schema,再用本工具执行。
|
|
60
|
+
*/
|
|
61
|
+
export const callDeviceTool = {
|
|
62
|
+
name: "call_device_tool",
|
|
63
|
+
label: "Call Device Tool",
|
|
64
|
+
description: "用户设备侧工具调用。必须先调用get_xxx_tool_schema获取了具体的工具schema,才能使用本工具执行对应设备侧工具。",
|
|
65
|
+
parameters: {
|
|
66
|
+
type: "object",
|
|
67
|
+
properties: {
|
|
68
|
+
toolName: {
|
|
69
|
+
type: "string",
|
|
70
|
+
description: "要调用的具体端工具名称,即get_xxx_tool_schema返回的工具的name",
|
|
71
|
+
},
|
|
72
|
+
arguments: {
|
|
73
|
+
type: "object",
|
|
74
|
+
description: "工具所需的具体参数JSON键值对",
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
required: ["toolName", "arguments"],
|
|
78
|
+
},
|
|
79
|
+
async execute(toolCallId, params) {
|
|
80
|
+
const { toolName, arguments: toolArgs } = params;
|
|
81
|
+
// 向用户端发送具体工具名的状态更新
|
|
82
|
+
const ctx = getCurrentSessionContext();
|
|
83
|
+
if (ctx) {
|
|
84
|
+
const currentTaskId = getCurrentTaskId(ctx.sessionId) ?? ctx.taskId;
|
|
85
|
+
const currentMessageId = getCurrentMessageId(ctx.sessionId) ?? ctx.messageId;
|
|
86
|
+
try {
|
|
87
|
+
await sendStatusUpdate({
|
|
88
|
+
config: ctx.config,
|
|
89
|
+
sessionId: ctx.sessionId,
|
|
90
|
+
taskId: currentTaskId,
|
|
91
|
+
messageId: currentMessageId,
|
|
92
|
+
text: `正在使用工具: ${toolName}...`,
|
|
93
|
+
state: "working",
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
catch (_) {
|
|
97
|
+
// 状态更新失败不影响工具执行
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const tool = deviceToolRegistry.get(toolName);
|
|
101
|
+
if (!tool) {
|
|
102
|
+
return {
|
|
103
|
+
content: [
|
|
104
|
+
{
|
|
105
|
+
type: "text",
|
|
106
|
+
text: `端工具${toolName}不存在。请确保toolName为get_xxx_tool_schema返回的工具的name。`,
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
try {
|
|
112
|
+
return await tool.execute(toolCallId, toolArgs);
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
// ToolInputError (.name === "ToolInputError") 或其他参数校验错误
|
|
116
|
+
if (error.name === "ToolInputError") {
|
|
117
|
+
return {
|
|
118
|
+
content: [
|
|
119
|
+
{
|
|
120
|
+
type: "text",
|
|
121
|
+
text: `端工具参数错误:${error.message}。请确保arguments符合get_xxx_tool_schema返回的工具schema。`,
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
// 非参数错误(网络超时等),直接向上抛出
|
|
127
|
+
throw error;
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
};
|
|
@@ -17,18 +17,7 @@ export const createAlarmTool = {
|
|
|
17
17
|
name: "create_alarm",
|
|
18
18
|
label: "Create Alarm",
|
|
19
19
|
description: `在用户设备上创建闹钟。
|
|
20
|
-
|
|
21
|
-
必需参数:
|
|
22
|
-
- alarmTime: 闹钟时间,格式必须为:YYYYMMDD hhmmss(例如:20240315 143000,表示2024年3月15日14:30:00)
|
|
23
|
-
|
|
24
|
-
可选参数(针对用户没有提及的参数,如果有默认参数,则发送请求时使用默认参数):
|
|
25
|
-
- alarmTitle: 闹钟名称/标题,默认为"闹钟"
|
|
26
|
-
- alarmSnoozeDuration: 小睡间隔(分钟),枚举值:5,10,15,20,25,30,默认10
|
|
27
|
-
- alarmSnoozeTotal: 再响次数,枚举值:0,1,3,5,10,默认0(表示不再响)
|
|
28
|
-
- alarmRingDuration: 响铃时长(分钟),枚举值:1,5,10,15,20,30,默认5
|
|
29
|
-
- daysOfWakeType: 闹钟响铃类型,枚举值:0=单次响铃,1=法定节假日,2=每天,3=自定义时间,4=法定工作日,默认0
|
|
30
|
-
- daysOfWeek: 自定义响铃星期,仅当daysOfWakeType=3(自定义时间)时必需且有效,其他情况不要传递此参数。数组或JSON字符串,枚举值:Mon,Tues,Wed,Thur,Fri,Sat,Sun。
|
|
31
|
-
|
|
20
|
+
|
|
32
21
|
注意事项:
|
|
33
22
|
a. 操作超时时间为60秒,请勿重复调用此工具,如果超时或失败,最多重试一次。
|
|
34
23
|
b. 使用该工具之前需获取当前真实时间
|
|
@@ -39,7 +28,7 @@ b. 使用该工具之前需获取当前真实时间
|
|
|
39
28
|
properties: {
|
|
40
29
|
alarmTime: {
|
|
41
30
|
type: "string",
|
|
42
|
-
description: "闹钟时间,格式必须为:YYYYMMDD hhmmss(例如:20240315 143000)",
|
|
31
|
+
description: "闹钟时间,格式必须为:YYYYMMDD hhmmss(例如:20240315 143000,表示2024年3月15日14:30:00)",
|
|
43
32
|
},
|
|
44
33
|
alarmTitle: {
|
|
45
34
|
type: "string",
|
|
@@ -51,7 +40,7 @@ b. 使用该工具之前需获取当前真实时间
|
|
|
51
40
|
},
|
|
52
41
|
alarmSnoozeTotal: {
|
|
53
42
|
type: "number",
|
|
54
|
-
description: "再响次数,枚举值:0,1,3,5,10,默认0",
|
|
43
|
+
description: "再响次数,枚举值:0,1,3,5,10,默认0(表示不再响)",
|
|
55
44
|
},
|
|
56
45
|
alarmRingDuration: {
|
|
57
46
|
type: "number",
|
|
@@ -59,12 +48,12 @@ b. 使用该工具之前需获取当前真实时间
|
|
|
59
48
|
},
|
|
60
49
|
daysOfWakeType: {
|
|
61
50
|
type: "number",
|
|
62
|
-
description: "
|
|
51
|
+
description: "闹钟响铃类型,枚举值:0=单次响铃,1=法定节假日,2=每天,3=自定义时间,4=法定工作日,默认0",
|
|
63
52
|
},
|
|
64
53
|
daysOfWeek: {
|
|
65
54
|
// 不指定 type,允许传入数组或 JSON 字符串
|
|
66
55
|
// 具体的类型验证和转换在 execute 函数内部进行
|
|
67
|
-
description: "
|
|
56
|
+
description: "自定义响铃星期,仅当daysOfWakeType=3(自定义时间)时必需且有效,其他情况不要传递此参数。数组或JSON字符串,枚举值:Mon,Tues,Wed,Thur,Fri,Sat,Sun。",
|
|
68
57
|
},
|
|
69
58
|
},
|
|
70
59
|
required: ["alarmTime"],
|
|
@@ -16,9 +16,6 @@ export const deleteAlarmTool = {
|
|
|
16
16
|
label: "Delete Alarm",
|
|
17
17
|
description: `删除用户设备上的闹钟。使用前必须先调用 search_alarm 或 create_alarm 工具获取闹钟的 entityId。
|
|
18
18
|
|
|
19
|
-
工具参数:
|
|
20
|
-
- items: 要删除的闹钟列表,每个元素包含 entityId 字段。支持数组或 JSON 字符串格式。entityId 是闹钟的唯一标识符(从 search_alarm 或 create_alarm 工具获取)。
|
|
21
|
-
|
|
22
19
|
使用示例:
|
|
23
20
|
- 删除单个闹钟:{"items": [{"entityId": "6"}]}
|
|
24
21
|
- 删除多个闹钟:{"items": [{"entityId": "6"}, {"entityId": "8"}]}
|
|
@@ -35,7 +32,7 @@ export const deleteAlarmTool = {
|
|
|
35
32
|
items: {
|
|
36
33
|
// 不指定 type,允许传入数组或 JSON 字符串
|
|
37
34
|
// 具体的类型验证和转换在 execute 函数内部进行
|
|
38
|
-
description: "要删除的闹钟列表,每个元素包含 entityId 字段。支持数组或 JSON 字符串格式。",
|
|
35
|
+
description: "要删除的闹钟列表,每个元素包含 entityId 字段。支持数组或 JSON 字符串格式。entityId 是闹钟的唯一标识符(从 search_alarm 或 create_alarm 工具获取)。",
|
|
39
36
|
},
|
|
40
37
|
},
|
|
41
38
|
required: ["items"],
|
|
@@ -13,8 +13,12 @@ const DEVICE_TOOL_POLICY = {
|
|
|
13
13
|
"call_phone",
|
|
14
14
|
"send_message",
|
|
15
15
|
"search_message",
|
|
16
|
-
"send_command_to_car",
|
|
17
16
|
"search_contact",
|
|
17
|
+
"get_contact_tool_schema",
|
|
18
|
+
"query_collection",
|
|
19
|
+
"add_collection",
|
|
20
|
+
"delete_collection",
|
|
21
|
+
"get_collection_tool_schema",
|
|
18
22
|
],
|
|
19
23
|
},
|
|
20
24
|
};
|
|
@@ -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
|
},
|