@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,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* schema-tool-factory: 创建 get_xxx_tool_schema 工具。
|
|
3
|
+
* 每个工具在被 LLM 调用时,返回其所包含的子工具的 name / description / parameters schema。
|
|
4
|
+
*/
|
|
5
|
+
export function createSchemaTool(options) {
|
|
6
|
+
const { name, label, description, tools } = options;
|
|
7
|
+
return {
|
|
8
|
+
name,
|
|
9
|
+
label,
|
|
10
|
+
description,
|
|
11
|
+
parameters: {
|
|
12
|
+
type: "object",
|
|
13
|
+
properties: {},
|
|
14
|
+
required: [],
|
|
15
|
+
},
|
|
16
|
+
async execute(_toolCallId, _params) {
|
|
17
|
+
const schemas = tools.map((t) => ({
|
|
18
|
+
name: t.name,
|
|
19
|
+
description: t.description,
|
|
20
|
+
parameters: t.parameters,
|
|
21
|
+
}));
|
|
22
|
+
return {
|
|
23
|
+
content: [
|
|
24
|
+
{
|
|
25
|
+
type: "text",
|
|
26
|
+
text: JSON.stringify(schemas, null, 2),
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -15,14 +15,7 @@ const DAYS_OF_WAKE_TYPE_VALUES = [0, 1, 2, 3, 4];
|
|
|
15
15
|
export const searchAlarmTool = {
|
|
16
16
|
name: "search_alarm",
|
|
17
17
|
label: "Search Alarm",
|
|
18
|
-
description:
|
|
19
|
-
|
|
20
|
-
检索条件(至少提供一个):
|
|
21
|
-
- rangeType: 查询范围,枚举值:all=查询所有闹钟,next=查找下一个响铃闹钟,current=一小时内最近一次增查改的闹钟
|
|
22
|
-
- alarmState: 闹钟开启状态,0=关闭,1=开启
|
|
23
|
-
- daysOfWakeType: 闹钟响铃类型,0=单次响铃,1=法定节假日,2=每天,3=自定义时间,4=法定工作日
|
|
24
|
-
- startTime: 时间间隔开始,格式 YYYYMMDD hhmmss(例如:20240315 000000),需要与 endTime 一起使用
|
|
25
|
-
- endTime: 时间间隔结束,格式 YYYYMMDD hhmmss(例如:20240315 235959),需要与 startTime 一起使用
|
|
18
|
+
description: `检索用户设备上的闹钟。至少需要提供一个检索条件,多个条件可以组合使用。
|
|
26
19
|
|
|
27
20
|
使用示例:
|
|
28
21
|
- 查询所有闹钟:{"rangeType": "all"}
|
|
@@ -41,25 +34,25 @@ b. 使用该工具之前需获取当前真实时间
|
|
|
41
34
|
rangeType: {
|
|
42
35
|
type: "string",
|
|
43
36
|
enum: ["all", "next", "current"],
|
|
44
|
-
description: "
|
|
37
|
+
description: "(检索条件之一)查询范围,枚举值:all=查询所有闹钟,next=查找下一个响铃闹钟,current=一小时内最近一次增查改的闹钟",
|
|
45
38
|
},
|
|
46
39
|
alarmState: {
|
|
47
40
|
type: "number",
|
|
48
41
|
enum: [0, 1],
|
|
49
|
-
description: "
|
|
42
|
+
description: "(检索条件之一)闹钟开启状态,枚举值:0=关闭,1=开启",
|
|
50
43
|
},
|
|
51
44
|
daysOfWakeType: {
|
|
52
45
|
type: "number",
|
|
53
46
|
enum: [0, 1, 2, 3, 4],
|
|
54
|
-
description: "
|
|
47
|
+
description: "(检索条件之一)闹钟响铃类型,枚举值:0=单次响铃,1=法定节假日,2=每天,3=自定义时间,4=法定工作日",
|
|
55
48
|
},
|
|
56
49
|
startTime: {
|
|
57
50
|
type: "string",
|
|
58
|
-
description: "
|
|
51
|
+
description: "(检索条件之一)时间间隔开始,格式 YYYYMMDD hhmmss(例如:20240315 000000),必须与 endTime 一起使用",
|
|
59
52
|
},
|
|
60
53
|
endTime: {
|
|
61
54
|
type: "string",
|
|
62
|
-
description: "
|
|
55
|
+
description: "(检索条件之一)时间间隔结束,格式 YYYYMMDD hhmmss(例如:20240315 235959),必须与 startTime 一起使用",
|
|
63
56
|
},
|
|
64
57
|
},
|
|
65
58
|
},
|
|
@@ -27,6 +27,8 @@ export const searchCalendarTool = {
|
|
|
27
27
|
注意:
|
|
28
28
|
a. 该工具执行时间较长(最多60秒),请勿重复调用,超时或失败时最多重试一次。
|
|
29
29
|
b. 使用该工具之前需获取当前真实时间
|
|
30
|
+
c. 该工具仅支持不超过28天时间范围的日程查询,如果时间区间大于该窗口需要拆分多个时间窗口进行多次查询
|
|
31
|
+
d. 如果查询结果返回-303,代表查询结果为空
|
|
30
32
|
|
|
31
33
|
回复约束:如果工具返回没有授权或者其他报错,只需要完整描述没有授权或者其他报错内容即可,不需要主动给用户提供解决方案,例如告诉用户如何授权,如何解决报错等都是不需要的,请严格遵守。
|
|
32
34
|
`,
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
// Search Email tool implementation
|
|
2
|
+
import { getXYWebSocketManager } from "../client.js";
|
|
3
|
+
import { sendCommand } from "../formatter.js";
|
|
4
|
+
import { getCurrentSessionContext } from "./session-manager.js";
|
|
5
|
+
/**
|
|
6
|
+
* XY search email tool - searches emails on user's device (花瓣邮箱).
|
|
7
|
+
* Returns matching emails based on query text and search type.
|
|
8
|
+
*/
|
|
9
|
+
export const searchEmailTool = {
|
|
10
|
+
name: "search_email",
|
|
11
|
+
label: "Search Email",
|
|
12
|
+
description: `检索用户花瓣邮箱中的邮件。根据查询语料和搜索类型检索邮件。
|
|
13
|
+
|
|
14
|
+
使用示例:
|
|
15
|
+
- 通用搜索:{"queryText": "个人所得税邮件", "type": 0}
|
|
16
|
+
- 按主题搜索:{"queryText": "会议纪要", "type": 1}
|
|
17
|
+
- 按发件人搜索:{"queryText": "张三", "type": 2}
|
|
18
|
+
- 按收件人搜索:{"queryText": "李四", "type": 3}
|
|
19
|
+
|
|
20
|
+
注意:
|
|
21
|
+
a. 操作超时时间为60秒,请勿重复调用此工具,如果超时或失败,最多重试一次。
|
|
22
|
+
b. 使用该工具之前需获取当前真实时间
|
|
23
|
+
|
|
24
|
+
回复约束:如果工具返回没有授权或者其他报错,只需要完整描述没有授权或者其他报错内容即可,不需要主动给用户提供解决方案,例如告诉用户如何授权,如何解决报错等都是不需要的,请严格遵守。`,
|
|
25
|
+
parameters: {
|
|
26
|
+
type: "object",
|
|
27
|
+
properties: {
|
|
28
|
+
queryText: {
|
|
29
|
+
type: "string",
|
|
30
|
+
description: "查询语料,用于搜索邮件的关键词或语句",
|
|
31
|
+
},
|
|
32
|
+
type: {
|
|
33
|
+
type: "number",
|
|
34
|
+
enum: [0, 1, 2, 3],
|
|
35
|
+
description: "搜索类型:0=全部(all),1=主题(subject),2=发件人(fromList),3=收件人(toList)。默认为0",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
required: ["queryText"],
|
|
39
|
+
},
|
|
40
|
+
async execute(_toolCallId, params) {
|
|
41
|
+
// ===== Validate queryText =====
|
|
42
|
+
if (!params.queryText || typeof params.queryText !== "string" || !params.queryText.trim()) {
|
|
43
|
+
throw new Error("queryText 为必填参数,且不能为空字符串");
|
|
44
|
+
}
|
|
45
|
+
// ===== Validate type =====
|
|
46
|
+
const searchType = params.type ?? 0;
|
|
47
|
+
if (typeof searchType !== "number" || ![0, 1, 2, 3].includes(searchType)) {
|
|
48
|
+
throw new Error("type 必须是 0-3 的整数:0=全部,1=主题,2=发件人,3=收件人");
|
|
49
|
+
}
|
|
50
|
+
// Get session context
|
|
51
|
+
const sessionContext = getCurrentSessionContext();
|
|
52
|
+
if (!sessionContext) {
|
|
53
|
+
throw new Error("No active XY session found. Search email tool can only be used during an active conversation.");
|
|
54
|
+
}
|
|
55
|
+
const { config, sessionId, taskId, messageId } = sessionContext;
|
|
56
|
+
// Get WebSocket manager
|
|
57
|
+
const wsManager = getXYWebSocketManager(config);
|
|
58
|
+
// Build SearchEmails command
|
|
59
|
+
const command = {
|
|
60
|
+
header: {
|
|
61
|
+
namespace: "Common",
|
|
62
|
+
name: "Action",
|
|
63
|
+
},
|
|
64
|
+
payload: {
|
|
65
|
+
cardParam: {},
|
|
66
|
+
executeParam: {
|
|
67
|
+
executeMode: "background",
|
|
68
|
+
intentName: "SearchEmails",
|
|
69
|
+
bundleName: "com.huawei.hmos.email",
|
|
70
|
+
needUnlock: true,
|
|
71
|
+
actionResponse: true,
|
|
72
|
+
appType: "OHOS_APP",
|
|
73
|
+
timeOut: 5,
|
|
74
|
+
intentParam: {
|
|
75
|
+
type: searchType,
|
|
76
|
+
queryText: params.queryText.trim(),
|
|
77
|
+
},
|
|
78
|
+
permissionId: [],
|
|
79
|
+
achieveType: "INTENT",
|
|
80
|
+
},
|
|
81
|
+
responses: [
|
|
82
|
+
{
|
|
83
|
+
resultCode: "",
|
|
84
|
+
displayText: "",
|
|
85
|
+
ttsText: "",
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
needUploadResult: true,
|
|
89
|
+
noHalfPage: false,
|
|
90
|
+
pageControlRelated: false,
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
// Send command and wait for response (60 second timeout)
|
|
94
|
+
return new Promise((resolve, reject) => {
|
|
95
|
+
const timeout = setTimeout(() => {
|
|
96
|
+
wsManager.off("data-event", handler);
|
|
97
|
+
reject(new Error("检索邮件超时(60秒)"));
|
|
98
|
+
}, 60000);
|
|
99
|
+
// Listen for data events from WebSocket
|
|
100
|
+
const handler = (event) => {
|
|
101
|
+
if (event.intentName === "SearchEmails") {
|
|
102
|
+
clearTimeout(timeout);
|
|
103
|
+
wsManager.off("data-event", handler);
|
|
104
|
+
if (event.status === "success" && event.outputs) {
|
|
105
|
+
resolve({
|
|
106
|
+
content: [
|
|
107
|
+
{
|
|
108
|
+
type: "text",
|
|
109
|
+
text: JSON.stringify(event.outputs),
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
reject(new Error(`检索邮件失败: ${event.status}`));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
// Register event handler
|
|
120
|
+
wsManager.on("data-event", handler);
|
|
121
|
+
// Send the command
|
|
122
|
+
sendCommand({
|
|
123
|
+
config,
|
|
124
|
+
sessionId,
|
|
125
|
+
taskId,
|
|
126
|
+
messageId,
|
|
127
|
+
command,
|
|
128
|
+
})
|
|
129
|
+
.then(() => { })
|
|
130
|
+
.catch((error) => {
|
|
131
|
+
clearTimeout(timeout);
|
|
132
|
+
wsManager.off("data-event", handler);
|
|
133
|
+
reject(error);
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
},
|
|
137
|
+
};
|
|
@@ -8,15 +8,15 @@ import { getCurrentSessionContext } from "./session-manager.js";
|
|
|
8
8
|
export const searchFileTool = {
|
|
9
9
|
name: "search_file",
|
|
10
10
|
label: "Search File",
|
|
11
|
-
description:
|
|
11
|
+
description: `搜索用户设备文件系统的文件。
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
- "
|
|
13
|
+
【重要】使用约束:此工具仅在用户显著说明要从手机/PC等用户设备搜索时才执行,例如:
|
|
14
|
+
- "从我手机/鸿蒙PC里面搜索xxxx"
|
|
15
15
|
- "从手机文件系统找一下xxxx"
|
|
16
16
|
- "在手机上查找文件xxxx"
|
|
17
17
|
- "搜索手机里的文件"
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
如果用户没有明确说明从手机或者PC搜索(如仅说"搜索文件"、"找一下xxxx"),应默认从当前runtime运行环境的本地的文件系统查询,不要调用此工具。
|
|
20
20
|
|
|
21
21
|
功能说明:根据关键词搜索文件名称或内容,返回匹配的文件列表(包括文件名、路径、大小、修改时间等信息)。
|
|
22
22
|
|
|
@@ -11,9 +11,9 @@ import { getCurrentSessionContext } from "./session-manager.js";
|
|
|
11
11
|
export const searchPhotoGalleryTool = {
|
|
12
12
|
name: "search_photo_gallery",
|
|
13
13
|
label: "Search Photo Gallery",
|
|
14
|
-
description:
|
|
14
|
+
description: `插件功能描述:搜索用户设备图库中的照片
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
工具使用约束:如果用户说从手机/鸿蒙PC图库中或者从相册中查询xx图片时调用此工具,注意此工具仅支持从本地图库检索,不支持云空间相册检索。
|
|
17
17
|
|
|
18
18
|
工具输入输出简介:
|
|
19
19
|
a. 根据图像描述语料检索匹配的照片,返回照片在手机本地的 mediaUri以及thumbnailUri。
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// Send Email 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
|
+
* XY send email tool - sends an email via 花瓣邮箱 on user's device.
|
|
14
|
+
*/
|
|
15
|
+
export const sendEmailTool = {
|
|
16
|
+
name: "send_email",
|
|
17
|
+
label: "Send Email",
|
|
18
|
+
description: `在用户设备上通过花瓣邮箱发送邮件。
|
|
19
|
+
注意:
|
|
20
|
+
a. 操作超时时间为60秒,请勿重复调用此工具
|
|
21
|
+
b. 如果遇到各类调用失败场景,最多只能重试一次,不可以重复调用多次。
|
|
22
|
+
c. 调用工具前需认真检查调用参数是否满足工具要求
|
|
23
|
+
|
|
24
|
+
回复约束:如果工具返回没有授权或者其他报错,只需要完整描述没有授权或者其他报错内容即可,不需要主动给用户提供解决方案,例如告诉用户如何授权,如何解决报错等都是不需要的,请严格遵守。`,
|
|
25
|
+
parameters: {
|
|
26
|
+
type: "object",
|
|
27
|
+
properties: {
|
|
28
|
+
subject: {
|
|
29
|
+
type: "string",
|
|
30
|
+
description: "邮件主题,必填",
|
|
31
|
+
},
|
|
32
|
+
to: {
|
|
33
|
+
type: "string",
|
|
34
|
+
description: "收件人邮箱地址,必填",
|
|
35
|
+
},
|
|
36
|
+
body: {
|
|
37
|
+
type: "string",
|
|
38
|
+
description: "邮件内容,必填",
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
required: ["subject", "to", "body"],
|
|
42
|
+
},
|
|
43
|
+
async execute(_toolCallId, params) {
|
|
44
|
+
if (typeof params.subject !== "string" || !params.subject.trim()) {
|
|
45
|
+
throw new ToolInputError("缺少必填参数 subject(邮件主题)");
|
|
46
|
+
}
|
|
47
|
+
if (typeof params.to !== "string" || !params.to.trim()) {
|
|
48
|
+
throw new ToolInputError("缺少必填参数 to(收件人邮箱地址)");
|
|
49
|
+
}
|
|
50
|
+
if (typeof params.body !== "string" || !params.body.trim()) {
|
|
51
|
+
throw new ToolInputError("缺少必填参数 body(邮件内容)");
|
|
52
|
+
}
|
|
53
|
+
const sessionContext = getCurrentSessionContext();
|
|
54
|
+
if (!sessionContext) {
|
|
55
|
+
throw new Error("No active XY session found. Send email tool can only be used during an active conversation.");
|
|
56
|
+
}
|
|
57
|
+
const { config, sessionId, taskId, messageId } = sessionContext;
|
|
58
|
+
const wsManager = getXYWebSocketManager(config);
|
|
59
|
+
const command = {
|
|
60
|
+
header: {
|
|
61
|
+
namespace: "Common",
|
|
62
|
+
name: "Action",
|
|
63
|
+
},
|
|
64
|
+
payload: {
|
|
65
|
+
cardParam: {},
|
|
66
|
+
executeParam: {
|
|
67
|
+
executeMode: "background",
|
|
68
|
+
intentName: "SendEmail",
|
|
69
|
+
bundleName: "com.huawei.hmos.email",
|
|
70
|
+
needUnlock: true,
|
|
71
|
+
actionResponse: true,
|
|
72
|
+
appType: "OHOS_APP",
|
|
73
|
+
timeOut: 5,
|
|
74
|
+
intentParam: {
|
|
75
|
+
subject: params.subject.trim(),
|
|
76
|
+
to: [params.to.trim()],
|
|
77
|
+
body: params.body.trim(),
|
|
78
|
+
},
|
|
79
|
+
permissionId: [],
|
|
80
|
+
achieveType: "INTENT",
|
|
81
|
+
},
|
|
82
|
+
responses: [
|
|
83
|
+
{
|
|
84
|
+
resultCode: "",
|
|
85
|
+
displayText: "",
|
|
86
|
+
ttsText: "",
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
needUploadResult: true,
|
|
90
|
+
noHalfPage: false,
|
|
91
|
+
pageControlRelated: false,
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
return new Promise((resolve, reject) => {
|
|
95
|
+
const timeout = setTimeout(() => {
|
|
96
|
+
wsManager.off("data-event", handler);
|
|
97
|
+
reject(new Error("发送邮件超时(60秒)"));
|
|
98
|
+
}, 60000);
|
|
99
|
+
const handler = (event) => {
|
|
100
|
+
if (event.intentName === "SendEmail") {
|
|
101
|
+
clearTimeout(timeout);
|
|
102
|
+
wsManager.off("data-event", handler);
|
|
103
|
+
if (event.status === "success" && event.outputs) {
|
|
104
|
+
resolve({
|
|
105
|
+
content: [
|
|
106
|
+
{
|
|
107
|
+
type: "text",
|
|
108
|
+
text: JSON.stringify(event.outputs),
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
reject(new Error(`发送邮件失败: ${event.status}`));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
wsManager.on("data-event", handler);
|
|
119
|
+
sendCommand({
|
|
120
|
+
config,
|
|
121
|
+
sessionId,
|
|
122
|
+
taskId,
|
|
123
|
+
messageId,
|
|
124
|
+
command,
|
|
125
|
+
})
|
|
126
|
+
.then(() => { })
|
|
127
|
+
.catch((error) => {
|
|
128
|
+
clearTimeout(timeout);
|
|
129
|
+
wsManager.off("data-event", handler);
|
|
130
|
+
reject(error);
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
},
|
|
134
|
+
};
|
|
@@ -99,12 +99,10 @@ async function downloadRemoteFile(url) {
|
|
|
99
99
|
export const sendFileToUserTool = {
|
|
100
100
|
name: "send_file_to_user",
|
|
101
101
|
label: "Send File to User",
|
|
102
|
-
description:
|
|
102
|
+
description: `工具能力描述:帮助用户把本地的文件或者公网地址的文件传到用户设备。
|
|
103
103
|
|
|
104
104
|
工具参数说明:
|
|
105
|
-
a. fileLocalUrls
|
|
106
|
-
b. fileRemoteUrls:公网地址数组,包含用户需要回传的文件的公网地址(会先下载到本地再发送)
|
|
107
|
-
c. fileLocalUrls 与 fileRemoteUrls 任意一个不为空即可,两者都提供时都会处理
|
|
105
|
+
a. fileLocalUrls 与 fileRemoteUrls 任意一个不为空即可,两者都提供时都会处理
|
|
108
106
|
|
|
109
107
|
注意事项:
|
|
110
108
|
a. 支持传入数组或 JSON 字符串格式
|
|
@@ -16,14 +16,14 @@ import { getCurrentSessionContext } from "./session-manager.js";
|
|
|
16
16
|
export const uploadFileTool = {
|
|
17
17
|
name: "upload_file",
|
|
18
18
|
label: "Upload File",
|
|
19
|
-
description:
|
|
19
|
+
description: `工具能力描述:将用户本地设备文件上传并获取可公网访问的 URL。
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
前置工具调用:此工具使用前必须先通过call_device_tool调用 search_file 或者 query_collection 工具获取文件的 uri
|
|
22
22
|
|
|
23
23
|
工具参数说明:
|
|
24
|
-
a. 入参中的fileInfos数组,每个元素必须包含mediaUri字段(对应于search_file
|
|
24
|
+
a. 入参中的fileInfos数组,每个元素必须包含mediaUri字段(对应于search_file工具或者query_collection返回结果中的uri),必须与search_file或者query_collection结果中对应的uri完全保持一致,不要自行修改。
|
|
25
25
|
b. fileInfos中的timeout字段是可选的,表示上传文件超时时间,单位是毫秒,默认是20000(20秒)。
|
|
26
|
-
c. fileInfos
|
|
26
|
+
c. fileInfos 是文件在用户设备本地的信息数组(从 search_file 工具或者query_collection 工具响应中获取)。限制:每次最多支持传入 5 条文件信息。
|
|
27
27
|
|
|
28
28
|
注意事项:
|
|
29
29
|
a. 操作超时时间为60秒,请勿重复调用此工具,如果超时或失败,最多重试一次。
|
|
@@ -12,9 +12,9 @@ import { getCurrentSessionContext } from "./session-manager.js";
|
|
|
12
12
|
export const uploadPhotoTool = {
|
|
13
13
|
name: "upload_photo",
|
|
14
14
|
label: "Upload Photo",
|
|
15
|
-
description:
|
|
15
|
+
description: `工具能力描述:将用户本地设备文件回传并获取可公网访问的 URL。
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
前置工具调用:此工具使用前必须先通过call_device_tool工具调用 search_photo_gallery 工具获取照片的 mediaUri或者thumbnailUri
|
|
18
18
|
工具参数说明:
|
|
19
19
|
a. 入参中的mediaUris中的mediaUri必须与search_photo_gallery结果中对应的mediaUri或者thumbnailUri完全保持一致,不要自行修改,必须是file:://开头的路径。
|
|
20
20
|
b. 优先使用search_photo_gallery结果中的thumbnailUri作为入参,thumbnailUri是缩略图,清晰度与文件大小都非常合适展示给用户,如果thumbnailUri不存在或者用户要求使用原图,则使用search_photo_gallery结果中对应的mediaUri
|