@ynhcj/xiaoyi-channel 0.0.154-beta → 0.0.154-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/src/bot.js +13 -5
- package/dist/src/cron-command.d.ts +4 -5
- package/dist/src/cron-command.js +19 -34
- package/dist/src/cron-query-handler.d.ts +7 -0
- package/dist/src/cron-query-handler.js +188 -0
- package/dist/src/cspl/call_api.d.ts +1 -1
- package/dist/src/cspl/call_api.js +2 -2
- package/dist/src/cspl/config.js +30 -10
- package/dist/src/cspl/constants.d.ts +3 -0
- package/dist/src/cspl/constants.js +5 -0
- package/dist/src/cspl/sentinel_hook.js +26 -7
- package/dist/src/cspl/utils.d.ts +9 -3
- package/dist/src/cspl/utils.js +17 -11
- package/dist/src/file-upload.d.ts +5 -0
- package/dist/src/file-upload.js +101 -0
- package/dist/src/formatter.d.ts +32 -0
- package/dist/src/formatter.js +62 -6
- package/dist/src/monitor.js +44 -23
- package/dist/src/parser.d.ts +6 -0
- package/dist/src/parser.js +47 -1
- package/dist/src/provider.js +25 -17
- package/dist/src/push.d.ts +11 -1
- package/dist/src/push.js +93 -2
- package/dist/src/reply-dispatcher.js +51 -19
- package/dist/src/self-evolution-handler.d.ts +1 -1
- package/dist/src/self-evolution-handler.js +13 -2
- package/dist/src/tools/agent-as-skill-tool.js +55 -4
- package/dist/src/tools/calendar-tool.js +1 -1
- package/dist/src/tools/call-device-tool.js +0 -3
- package/dist/src/tools/call-phone-tool.js +1 -1
- package/dist/src/tools/check-plugin-privilege-tool.d.ts +6 -0
- package/dist/src/tools/check-plugin-privilege-tool.js +182 -0
- package/dist/src/tools/create-alarm-tool.js +1 -1
- package/dist/src/tools/create-all-tools.js +8 -4
- package/dist/src/tools/delete-alarm-tool.js +1 -1
- package/dist/src/tools/device-tool-map.js +1 -0
- package/dist/src/tools/discover-cross-devices-tool.js +1 -1
- package/dist/src/tools/display-a2ui-card-tool.d.ts +2 -0
- package/dist/src/tools/display-a2ui-card-tool.js +85 -0
- package/dist/src/tools/get-collection-tool-schema.js +1 -1
- package/dist/src/tools/get-device-file-tool-schema.js +2 -3
- package/dist/src/tools/location-tool.js +1 -1
- package/dist/src/tools/modify-alarm-tool.js +1 -1
- package/dist/src/tools/modify-note-tool.js +1 -1
- package/dist/src/tools/note-tool.js +1 -1
- package/dist/src/tools/query-app-message-tool.js +1 -1
- package/dist/src/tools/query-memory-data-tool.js +1 -1
- package/dist/src/tools/query-todo-task-tool.js +1 -1
- package/dist/src/tools/save-file-to-phone-tool.js +1 -1
- package/dist/src/tools/save-media-to-gallery-tool.js +1 -1
- package/dist/src/tools/schema-tool-factory.js +1 -1
- package/dist/src/tools/search-alarm-tool.js +1 -1
- package/dist/src/tools/search-calendar-tool.js +1 -1
- package/dist/src/tools/search-contact-tool.js +1 -1
- package/dist/src/tools/search-email-tool.js +1 -1
- package/dist/src/tools/search-file-tool.js +5 -10
- package/dist/src/tools/search-note-tool.js +1 -1
- package/dist/src/tools/search-photo-gallery-tool.js +1 -1
- package/dist/src/tools/send-cross-device-task-tool.js +18 -22
- package/dist/src/tools/send-email-tool.js +1 -1
- package/dist/src/tools/send-file-to-user-tool.d.ts +1 -1
- package/dist/src/tools/send-file-to-user-tool.js +35 -6
- package/dist/src/tools/send-html-card-tool.d.ts +7 -0
- package/dist/src/tools/send-html-card-tool.js +113 -0
- package/dist/src/tools/session-manager.d.ts +6 -2
- package/dist/src/tools/session-manager.js +42 -7
- package/dist/src/tools/upload-file-tool.d.ts +1 -1
- package/dist/src/tools/upload-file-tool.js +3 -17
- package/dist/src/tools/upload-photo-tool.js +1 -1
- package/dist/src/tools/xiaoyi-add-collection-tool.js +3 -2
- package/dist/src/tools/xiaoyi-collection-tool.js +2 -2
- package/dist/src/tools/xiaoyi-delete-collection-tool.js +2 -2
- package/dist/src/tools/xiaoyi-gui-tool.js +5 -0
- package/dist/src/types.d.ts +10 -3
- package/dist/src/websocket.js +44 -5
- package/package.json +1 -2
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
// Check plugin privilege tool implementation
|
|
2
|
+
import { getXYWebSocketManager } from "../client.js";
|
|
3
|
+
import { sendCommand } from "../formatter.js";
|
|
4
|
+
import { getCurrentTaskId } from "../task-manager.js";
|
|
5
|
+
import { logger } from "../utils/logger.js";
|
|
6
|
+
/**
|
|
7
|
+
* Mapping from intent name to required permission IDs.
|
|
8
|
+
*/
|
|
9
|
+
const INTENT_PERMISSION_MAP = {
|
|
10
|
+
GetCurrentLocation: ["ohos.permission.LOCATION", "ohos.permission.APPROXIMATELY_LOCATION"],
|
|
11
|
+
SearchCalendarEvent: ["ohos.permission.READ_WHOLE_CALENDAR"],
|
|
12
|
+
CreateCalendarEvent: ["ohos.permission.WRITE_WHOLE_CALENDAR"],
|
|
13
|
+
DeleteCalendarEvent: ["ohos.permission.WRITE_WHOLE_CALENDAR"],
|
|
14
|
+
ModifyCalendarEvent: ["ohos.permission.WRITE_WHOLE_CALENDAR"],
|
|
15
|
+
SearchNote: ["ohos.permission.READ_NOTE"],
|
|
16
|
+
CreateNote: ["ohos.permission.WRITE_NOTE"],
|
|
17
|
+
ModifyNote: ["ohos.permission.WRITE_NOTE"],
|
|
18
|
+
SearchContactLocal: ["ohos.permission.READ_CONTACTS"],
|
|
19
|
+
SearchPhotoVideo: ["ohos.permission.READ_IMAGEVIDEO"],
|
|
20
|
+
SaveMediaToGallery: ["ohos.permission.WRITE_IMAGEVIDEO"],
|
|
21
|
+
SearchFile: ["ohos.permission.FILE_ACCESS_MANAGER"],
|
|
22
|
+
SaveFileToFileManager: ["ohos.permission.FILE_SAVE_MANAGER"],
|
|
23
|
+
SearchAlarm: ["ohos.permission.READ_ALARM"],
|
|
24
|
+
CreateAlarm: ["ohos.permission.WRITE_ALARM"],
|
|
25
|
+
ModifyAlarm: ["ohos.permission.WRITE_ALARM"],
|
|
26
|
+
DeleteAlarm: ["ohos.permission.WRITE_ALARM"],
|
|
27
|
+
SearchMessage: ["ohos.permission.READ_SMS"],
|
|
28
|
+
SendShortMessage: ["ohos.permission.SEND_MESSAGES"],
|
|
29
|
+
StartCall: ["ohos.permission.PLACE_CALL"],
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* XY check plugin privilege tool - checks user authorization for device-side tools
|
|
33
|
+
* used in scheduled tasks.
|
|
34
|
+
*/
|
|
35
|
+
export function createCheckPluginPrivilegeTool(ctx) {
|
|
36
|
+
const { config, sessionId, taskId, messageId } = ctx;
|
|
37
|
+
return {
|
|
38
|
+
name: "check_plugin_privilege",
|
|
39
|
+
label: "Check Plugin Privilege",
|
|
40
|
+
description: "定时任务权限检查工具。" +
|
|
41
|
+
"【使用场景】仅在创建定时任务时使用,严禁在其他场景调用。当识别到定时任务中需要使用用户设备侧工具时,必须调用此工具进行权限检查。" +
|
|
42
|
+
"【调用前提】调用此工具前,必须确认用户定时任务中提到的工具在当前模型可使用的工具列表中存在。如果当前工具列表中不存在符合用户诉求的工具定义,则不要调用此工具,而是直接告知用户当前设备不支持该功能。" +
|
|
43
|
+
"【支持的意图名称及对应权限】" +
|
|
44
|
+
"GetCurrentLocation(获取用户位置), " +
|
|
45
|
+
"SearchCalendarEvent(搜索用户日程), " +
|
|
46
|
+
"CreateCalendarEvent(新建用户日程), " +
|
|
47
|
+
"DeleteCalendarEvent(删除用户日程), " +
|
|
48
|
+
"ModifyCalendarEvent(修改用户日程), " +
|
|
49
|
+
"SearchNote(搜索用户备忘录), " +
|
|
50
|
+
"CreateNote(新建用户备忘录), " +
|
|
51
|
+
"ModifyNote(修改用户备忘录), " +
|
|
52
|
+
"SearchContactLocal(搜索用户联系人), " +
|
|
53
|
+
"SearchPhotoVideo(搜索用户图库照片或视频), " +
|
|
54
|
+
"SaveMediaToGallery(保存图片/视频到图库), " +
|
|
55
|
+
"SearchFile(搜索用户文件管理里面的文件), " +
|
|
56
|
+
"SaveFileToFileManager(保存文件到文件管理), " +
|
|
57
|
+
"SearchAlarm(搜索闹钟), " +
|
|
58
|
+
"CreateAlarm(新建闹钟), " +
|
|
59
|
+
"ModifyAlarm(修改闹钟), " +
|
|
60
|
+
"DeleteAlarm(删除闹钟), " +
|
|
61
|
+
"SearchMessage(搜索短信), " +
|
|
62
|
+
"SendShortMessage(发送短信), " +
|
|
63
|
+
"StartCall(打电话)。" +
|
|
64
|
+
"【多次调用】如果用户的定时任务指令中涉及多个端侧工具,则依次分别调用此工具检查每个工具的权限。如果调用超时失败,最多重试一次。" +
|
|
65
|
+
"【回复约束】如果工具返回没有授权或其他报错,只需要完整描述没有授权或其他报错内容即可,不需要主动给用户提供解决方案。" +
|
|
66
|
+
"【使用约束1】只要是创建定时任务且涉及端插件的使用,则必须调用此工具检查权限" +
|
|
67
|
+
"【使用约束2】如果是定时任务执行过程中,禁止调用此工具,此工具仅在创建定时任务时按需调用",
|
|
68
|
+
parameters: {
|
|
69
|
+
type: "object",
|
|
70
|
+
properties: {
|
|
71
|
+
checkIntentName: {
|
|
72
|
+
type: "string",
|
|
73
|
+
description: "需要检查权限的意图名称,必须是支持的意图名称之一,例如:GetCurrentLocation、SearchCalendarEvent、CreateCalendarEvent 等。",
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
required: ["checkIntentName"],
|
|
77
|
+
},
|
|
78
|
+
async execute(toolCallId, params) {
|
|
79
|
+
const { checkIntentName } = params;
|
|
80
|
+
// Look up permission IDs for the given intent name
|
|
81
|
+
const permissionId = INTENT_PERMISSION_MAP[checkIntentName];
|
|
82
|
+
if (!permissionId) {
|
|
83
|
+
return {
|
|
84
|
+
content: [
|
|
85
|
+
{
|
|
86
|
+
type: "text",
|
|
87
|
+
text: `不支持的工具意图名称: ${checkIntentName}。请确认该意图名称在支持列表中。`,
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
// Get WebSocket manager
|
|
93
|
+
const wsManager = getXYWebSocketManager(config);
|
|
94
|
+
// Build CheckPlugInPrivilege command
|
|
95
|
+
const command = {
|
|
96
|
+
header: {
|
|
97
|
+
namespace: "Common",
|
|
98
|
+
name: "Action",
|
|
99
|
+
},
|
|
100
|
+
payload: {
|
|
101
|
+
cardParam: {},
|
|
102
|
+
executeParam: {
|
|
103
|
+
achieveType: "INTENT",
|
|
104
|
+
actionResponse: true,
|
|
105
|
+
bundleName: "com.huawei.hmos.vassistant",
|
|
106
|
+
dimension: "",
|
|
107
|
+
executeMode: "background",
|
|
108
|
+
intentName: "CheckPlugInPrivilege",
|
|
109
|
+
intentParam: {
|
|
110
|
+
checkIntentName: "CheckPluginPrivilege",
|
|
111
|
+
permissionId,
|
|
112
|
+
},
|
|
113
|
+
needUnlock: false,
|
|
114
|
+
permissionId: [],
|
|
115
|
+
timeOut: 5,
|
|
116
|
+
},
|
|
117
|
+
needUploadResult: true,
|
|
118
|
+
pageControlRelated: false,
|
|
119
|
+
responses: [
|
|
120
|
+
{
|
|
121
|
+
displayText: "",
|
|
122
|
+
resultCode: "",
|
|
123
|
+
ttsText: "",
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
// Send command and wait for response (60 second timeout)
|
|
129
|
+
return new Promise((resolve, reject) => {
|
|
130
|
+
const timeout = setTimeout(() => {
|
|
131
|
+
wsManager.off("data-event", handler);
|
|
132
|
+
logger.error("超时: 检查插件权限超时(60秒)", { toolCallId, checkIntentName });
|
|
133
|
+
reject(new Error(`检查插件权限超时(60秒), intentName: ${checkIntentName}`));
|
|
134
|
+
}, 60000);
|
|
135
|
+
// Listen for data events from WebSocket
|
|
136
|
+
const handler = (event) => {
|
|
137
|
+
if (event.intentName === "CheckPlugInPrivilege") {
|
|
138
|
+
clearTimeout(timeout);
|
|
139
|
+
wsManager.off("data-event", handler);
|
|
140
|
+
if (event.status === "success" && event.outputs) {
|
|
141
|
+
resolve({
|
|
142
|
+
content: [
|
|
143
|
+
{
|
|
144
|
+
type: "text",
|
|
145
|
+
text: JSON.stringify(event.outputs),
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
resolve({
|
|
152
|
+
content: [
|
|
153
|
+
{
|
|
154
|
+
type: "text",
|
|
155
|
+
text: JSON.stringify(event.outputs),
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
// Register event handler
|
|
163
|
+
wsManager.on("data-event", handler);
|
|
164
|
+
// Send the command
|
|
165
|
+
const currentTaskId = getCurrentTaskId(sessionId) ?? taskId;
|
|
166
|
+
sendCommand({
|
|
167
|
+
config,
|
|
168
|
+
sessionId,
|
|
169
|
+
taskId: currentTaskId,
|
|
170
|
+
messageId,
|
|
171
|
+
command,
|
|
172
|
+
toolCallId,
|
|
173
|
+
}).then(() => {
|
|
174
|
+
}).catch((error) => {
|
|
175
|
+
clearTimeout(timeout);
|
|
176
|
+
wsManager.off("data-event", handler);
|
|
177
|
+
reject(error);
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createLocationTool } from "./location-tool.js";
|
|
2
2
|
import { createXiaoyiGuiTool } from "./xiaoyi-gui-tool.js";
|
|
3
3
|
import { createSendFileToUserTool } from "./send-file-to-user-tool.js";
|
|
4
|
+
import { createSendHtmlCardTool } from "./send-html-card-tool.js";
|
|
4
5
|
import { viewPushResultTool } from "./view-push-result-tool.js";
|
|
5
6
|
import { createImageReadingTool } from "./image-reading-tool.js";
|
|
6
7
|
import { timestampToUtc8Tool } from "./timestamp-to-utc8-tool.js";
|
|
@@ -13,12 +14,13 @@ import { createGetPhotoToolSchemaTool } from "./get-photo-tool-schema.js";
|
|
|
13
14
|
import { createGetDeviceFileToolSchemaTool } from "./get-device-file-tool-schema.js";
|
|
14
15
|
import { createGetAlarmToolSchemaTool } from "./get-alarm-tool-schema.js";
|
|
15
16
|
import { createGetCollectionToolSchemaTool } from "./get-collection-tool-schema.js";
|
|
16
|
-
import { createGetEmailToolSchemaTool } from "./get-email-tool-schema.js";
|
|
17
|
+
// import { createGetEmailToolSchemaTool } from "./get-email-tool-schema.js";
|
|
17
18
|
import { createLoginTokenTool } from "./login-token-tool.js";
|
|
18
19
|
import { createAgentAsSkillTool } from "./agent-as-skill-tool.js";
|
|
19
|
-
import { createFindPcDevicesTool } from "./find-pc-devices-tool.js";
|
|
20
20
|
import { createDiscoverCrossDevicesTool } from "./discover-cross-devices-tool.js";
|
|
21
21
|
import { createSendCrossDeviceTaskTool } from "./send-cross-device-task-tool.js";
|
|
22
|
+
import { createDisplayA2UICardTool } from "./display-a2ui-card-tool.js";
|
|
23
|
+
import { createCheckPluginPrivilegeTool } from "./check-plugin-privilege-tool.js";
|
|
22
24
|
import { logger } from "../utils/logger.js";
|
|
23
25
|
/**
|
|
24
26
|
* Create all XY channel tools for the given session context.
|
|
@@ -36,6 +38,7 @@ export function createAllTools(ctx) {
|
|
|
36
38
|
createLocationTool(ctx),
|
|
37
39
|
createDiscoverCrossDevicesTool(ctx),
|
|
38
40
|
createSendCrossDeviceTaskTool(ctx),
|
|
41
|
+
createDisplayA2UICardTool(ctx),
|
|
39
42
|
createCallDeviceTool(ctx),
|
|
40
43
|
createGetNoteToolSchemaTool(ctx),
|
|
41
44
|
createGetCalendarToolSchemaTool(ctx),
|
|
@@ -46,13 +49,14 @@ export function createAllTools(ctx) {
|
|
|
46
49
|
createGetAlarmToolSchemaTool(ctx),
|
|
47
50
|
createGetCollectionToolSchemaTool(ctx),
|
|
48
51
|
createSendFileToUserTool(ctx),
|
|
49
|
-
|
|
52
|
+
createSendHtmlCardTool(ctx),
|
|
53
|
+
// createGetEmailToolSchemaTool(ctx),
|
|
50
54
|
viewPushResultTool,
|
|
51
55
|
createImageReadingTool(ctx),
|
|
52
56
|
timestampToUtc8Tool,
|
|
53
57
|
createSaveSelfEvolutionSkillTool(ctx),
|
|
54
58
|
createLoginTokenTool(ctx),
|
|
55
59
|
createAgentAsSkillTool(ctx),
|
|
56
|
-
|
|
60
|
+
createCheckPluginPrivilegeTool(ctx),
|
|
57
61
|
];
|
|
58
62
|
}
|
|
@@ -106,7 +106,7 @@ export function createDiscoverCrossDevicesTool(ctx) {
|
|
|
106
106
|
|
|
107
107
|
当用户明确表达要从另一台设备获取、查找、使用或操作内容时,必须优先调用本工具,例如从 PC、电脑、平板、手机等设备获取文件或查找内容。
|
|
108
108
|
|
|
109
|
-
|
|
109
|
+
本工具只做设备发现和目标设备推荐,不会读取副设备文件内容,不会上传文件,也不会真正下发跨端执行任务。下发跨端执行任务需要使用SendCrossDeviceTaskTool`,
|
|
110
110
|
parameters: {
|
|
111
111
|
type: "object",
|
|
112
112
|
properties: {
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { sendCommand } from "../formatter.js";
|
|
2
|
+
import { getCurrentMessageId, getCurrentTaskId } from "../task-manager.js";
|
|
3
|
+
import { logger } from "../utils/logger.js";
|
|
4
|
+
class ToolInputError extends Error {
|
|
5
|
+
status = 400;
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = "ToolInputError";
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function isJsonObjectOrArray(value) {
|
|
12
|
+
return !!value && typeof value === "object";
|
|
13
|
+
}
|
|
14
|
+
export function createDisplayA2UICardTool(ctx) {
|
|
15
|
+
const { config, sessionId, taskId, messageId } = ctx;
|
|
16
|
+
return {
|
|
17
|
+
name: "displayA2UICard",
|
|
18
|
+
label: "Display A2UI Card",
|
|
19
|
+
description: "当模型根据 MCP 工具返回结果判断需要向端侧下发 A2UI card 时调用。参数 cardId 和 cardData 由模型根据 MCP 工具返回结果传入,本工具只负责下发卡片展示指令。",
|
|
20
|
+
parameters: {
|
|
21
|
+
type: "object",
|
|
22
|
+
properties: {
|
|
23
|
+
cardId: {
|
|
24
|
+
type: "string",
|
|
25
|
+
description: "A2UI card 的唯一标识。",
|
|
26
|
+
},
|
|
27
|
+
cardData: {
|
|
28
|
+
oneOf: [
|
|
29
|
+
{ type: "object" },
|
|
30
|
+
{ type: "array" },
|
|
31
|
+
],
|
|
32
|
+
description: "A2UI card 渲染所需的 JSON 对象或 JSON 数组,由模型根据 MCP 工具返回结果填充。",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
required: ["cardId", "cardData"],
|
|
36
|
+
},
|
|
37
|
+
async execute(toolCallId, params) {
|
|
38
|
+
const cardId = typeof params?.cardId === "string" ? params.cardId.trim() : "";
|
|
39
|
+
const cardData = params?.cardData;
|
|
40
|
+
if (!cardId) {
|
|
41
|
+
throw new ToolInputError("缺少必填参数: cardId");
|
|
42
|
+
}
|
|
43
|
+
if (!isJsonObjectOrArray(cardData)) {
|
|
44
|
+
throw new ToolInputError("缺少必填参数: cardData,且必须是 JSON 对象或 JSON 数组");
|
|
45
|
+
}
|
|
46
|
+
const currentTaskId = getCurrentTaskId(sessionId) ?? taskId;
|
|
47
|
+
const currentMessageId = getCurrentMessageId(sessionId) ?? messageId;
|
|
48
|
+
const command = {
|
|
49
|
+
header: {
|
|
50
|
+
namespace: "Common",
|
|
51
|
+
name: "DisplayFACard",
|
|
52
|
+
},
|
|
53
|
+
payload: {
|
|
54
|
+
isA2ui: true,
|
|
55
|
+
a2uiParam: {
|
|
56
|
+
cardId,
|
|
57
|
+
cardData,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
logger.log(`[DISPLAY-A2UI-CARD] sending card, cardId=${cardId}`);
|
|
62
|
+
await sendCommand({
|
|
63
|
+
config,
|
|
64
|
+
sessionId,
|
|
65
|
+
taskId: currentTaskId,
|
|
66
|
+
messageId: currentMessageId,
|
|
67
|
+
command,
|
|
68
|
+
toolCallId,
|
|
69
|
+
});
|
|
70
|
+
logger.log(`[DISPLAY-A2UI-CARD] card sent successfully, cardId=${cardId}`);
|
|
71
|
+
return {
|
|
72
|
+
content: [
|
|
73
|
+
{
|
|
74
|
+
type: "text",
|
|
75
|
+
text: JSON.stringify({
|
|
76
|
+
success: true,
|
|
77
|
+
cardId,
|
|
78
|
+
message: "A2UI card display command sent successfully.",
|
|
79
|
+
}),
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
};
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
@@ -6,7 +6,7 @@ export function createGetCollectionToolSchemaTool(ctx) {
|
|
|
6
6
|
return createSchemaTool({
|
|
7
7
|
name: "get_collection_tool_schema",
|
|
8
8
|
label: "Get Collection Tool Schema",
|
|
9
|
-
description: "
|
|
9
|
+
description: "获取可在用户设备上添加、检索、删除小艺收藏(也叫小艺帮记)中的公共知识数据的相关端工具列表。",
|
|
10
10
|
tools: [createXiaoyiAddCollectionTool(ctx), createXiaoyiCollectionTool(ctx), createXiaoyiDeleteCollectionTool(ctx)],
|
|
11
11
|
});
|
|
12
12
|
}
|
|
@@ -2,14 +2,13 @@ import { createSchemaTool } from "./schema-tool-factory.js";
|
|
|
2
2
|
import { createSearchFileTool } from "./search-file-tool.js";
|
|
3
3
|
import { createUploadFileTool } from "./upload-file-tool.js";
|
|
4
4
|
import { createSaveFileToPhoneTool } from "./save-file-to-phone-tool.js";
|
|
5
|
-
import { createFindPcDevicesTool } from "./find-pc-devices-tool.js";
|
|
6
5
|
export function createGetDeviceFileToolSchemaTool(ctx) {
|
|
7
6
|
const searchFileTool = createSearchFileTool(ctx);
|
|
8
7
|
const saveFileToPhoneTool = createSaveFileToPhoneTool(ctx);
|
|
9
8
|
return createSchemaTool({
|
|
10
9
|
name: "get_device_file_tool_schema",
|
|
11
10
|
label: "Get Device File Tool Schema",
|
|
12
|
-
description: "
|
|
13
|
-
tools: [searchFileTool, createUploadFileTool(ctx), saveFileToPhoneTool
|
|
11
|
+
description: "获取可在用户设备上搜索文件系统的文件、将用户设备本地文件上传到公网并获取链接、保存文件到文件管理器的相关端工具列表。",
|
|
12
|
+
tools: [searchFileTool, createUploadFileTool(ctx), saveFileToPhoneTool],
|
|
14
13
|
});
|
|
15
14
|
}
|
|
@@ -11,13 +11,12 @@ export function createSearchFileTool(ctx) {
|
|
|
11
11
|
return {
|
|
12
12
|
name: "search_file",
|
|
13
13
|
label: "Search File",
|
|
14
|
-
description:
|
|
14
|
+
description: `搜索用户设备的文件系统的文件,用户设备可以是手机或者鸿蒙PC等。
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
2. 搜索PC/电脑文件:当用户要求搜索PC/电脑上的文件时(如"帮我找一下PC上的xxx文件"、"搜索电脑上的xxx"),必须先调用 find_pc_devices 工具获取设备ID(udid),然后将 udid 传入此工具进行搜索。
|
|
16
|
+
使用场景与调用流程:
|
|
17
|
+
当用户明确说明要从设备搜索时(如"从手机里面搜索xxxx"、"在手机上查找文件xxxx","查找我电脑上的xxxx文件","查找我鸿蒙PC上的xxx文件"),直接调用此工具。
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
如果用户没有明确说明从设备搜索(如仅说"搜索文件"、"找一下xxxx"),应默认从当前runtime运行环境的本地文件系统查询,不要调用此工具。
|
|
21
20
|
|
|
22
21
|
功能说明:根据关键词搜索文件名称或内容,返回匹配的文件列表(包括文件名、路径、大小、修改时间等信息)。
|
|
23
22
|
|
|
@@ -28,11 +27,7 @@ export function createSearchFileTool(ctx) {
|
|
|
28
27
|
query: {
|
|
29
28
|
type: "string",
|
|
30
29
|
description: "搜索关键词,用于匹配文件名称、后缀名或文件内容",
|
|
31
|
-
}
|
|
32
|
-
udid: {
|
|
33
|
-
type: "string",
|
|
34
|
-
description: "PC/电脑设备ID。当搜索PC/电脑上的文件时,需要先通过 find_pc_devices 工具获取设备ID后传入。搜索手机文件时不需要传入此参数。",
|
|
35
|
-
},
|
|
30
|
+
}
|
|
36
31
|
},
|
|
37
32
|
required: ["query"],
|
|
38
33
|
},
|
|
@@ -140,7 +140,7 @@ async function searchPhotos(wsManager, config, sessionId, taskId, messageId, too
|
|
|
140
140
|
resolve(event.outputs);
|
|
141
141
|
}
|
|
142
142
|
else {
|
|
143
|
-
reject(new Error(`搜索照片失败: ${event.
|
|
143
|
+
reject(new Error(`搜索照片失败: ${JSON.stringify(event.outputs)}`));
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
};
|