@ynhcj/xiaoyi-channel 0.0.185-beta → 0.0.185-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 +141 -1
- package/dist/src/acp-session-binding.d.ts +37 -0
- package/dist/src/acp-session-binding.js +237 -0
- package/dist/src/bot.js +62 -33
- package/dist/src/channel.js +68 -64
- package/dist/src/client.d.ts +5 -0
- package/dist/src/client.js +10 -0
- package/dist/src/cron-command.d.ts +2 -0
- package/dist/src/cron-command.js +14 -8
- package/dist/src/cron-query-handler.js +36 -0
- package/dist/src/cspl/call_api.js +4 -2
- package/dist/src/cspl/sentinel_hook.js +9 -8
- package/dist/src/cspl/upload_file.js +2 -2
- package/dist/src/formatter.js +72 -36
- package/dist/src/log-reporter/config-loader.d.ts +11 -0
- package/dist/src/log-reporter/config-loader.js +68 -0
- package/dist/src/log-reporter/cursor-store.d.ts +5 -0
- package/dist/src/log-reporter/cursor-store.js +26 -0
- package/dist/src/log-reporter/index.d.ts +10 -0
- package/dist/src/log-reporter/index.js +77 -0
- package/dist/src/log-reporter/reporter.d.ts +6 -0
- package/dist/src/log-reporter/reporter.js +17 -0
- package/dist/src/log-reporter/scanner.d.ts +6 -0
- package/dist/src/log-reporter/scanner.js +82 -0
- package/dist/src/log-reporter/types.d.ts +59 -0
- package/dist/src/log-reporter/types.js +2 -0
- package/dist/src/log-reporter/uploader.d.ts +6 -0
- package/dist/src/log-reporter/uploader.js +32 -0
- package/dist/src/memory-query-handler.d.ts +1 -0
- package/dist/src/memory-query-handler.js +283 -0
- package/dist/src/monitor.js +29 -9
- package/dist/src/outbound.js +5 -0
- package/dist/src/parser.d.ts +12 -0
- package/dist/src/parser.js +39 -13
- package/dist/src/provider.js +79 -16
- package/dist/src/reply-dispatcher.d.ts +3 -0
- package/dist/src/reply-dispatcher.js +166 -164
- package/dist/src/self-evolution-handler.js +2 -1
- package/dist/src/task-manager.d.ts +5 -6
- package/dist/src/task-manager.js +5 -9
- package/dist/src/tools/agent-as-skill-tool.d.ts +41 -2
- package/dist/src/tools/agent-as-skill-tool.js +144 -151
- package/dist/src/tools/calendar-tool.d.ts +24 -2
- package/dist/src/tools/calendar-tool.js +115 -117
- package/dist/src/tools/call-device-tool.d.ts +20 -6
- package/dist/src/tools/call-device-tool.js +116 -138
- package/dist/src/tools/call-phone-tool.d.ts +21 -2
- package/dist/src/tools/call-phone-tool.js +112 -114
- package/dist/src/tools/check-plugin-privilege-tool.d.ts +16 -2
- package/dist/src/tools/check-plugin-privilege-tool.js +141 -143
- package/dist/src/tools/create-alarm-tool.d.ts +39 -2
- package/dist/src/tools/create-alarm-tool.js +229 -231
- package/dist/src/tools/create-all-tools.js +8 -4
- package/dist/src/tools/delete-alarm-tool.d.ts +15 -2
- package/dist/src/tools/delete-alarm-tool.js +134 -136
- package/dist/src/tools/device-tool-map.d.ts +1 -1
- package/dist/src/tools/device-tool-map.js +9 -2
- package/dist/src/tools/discover-cross-devices-tool.d.ts +16 -2
- package/dist/src/tools/discover-cross-devices-tool.js +121 -124
- package/dist/src/tools/display-a2ui-card-bypath-tool.d.ts +21 -0
- package/dist/src/tools/display-a2ui-card-bypath-tool.js +65 -0
- package/dist/src/tools/get-alarm-tool-schema.d.ts +1 -2
- package/dist/src/tools/get-alarm-tool-schema.js +10 -16
- package/dist/src/tools/get-calendar-tool-schema.d.ts +1 -2
- package/dist/src/tools/get-calendar-tool-schema.js +8 -12
- package/dist/src/tools/get-collection-tool-schema.d.ts +1 -2
- package/dist/src/tools/get-collection-tool-schema.js +9 -11
- package/dist/src/tools/get-contact-tool-schema.d.ts +1 -2
- package/dist/src/tools/get-contact-tool-schema.js +10 -16
- package/dist/src/tools/get-device-file-tool-schema.d.ts +1 -2
- package/dist/src/tools/get-device-file-tool-schema.js +9 -13
- package/dist/src/tools/get-email-tool-schema.d.ts +1 -2
- package/dist/src/tools/get-email-tool-schema.js +8 -11
- package/dist/src/tools/get-note-tool-schema.d.ts +1 -2
- package/dist/src/tools/get-note-tool-schema.js +9 -14
- package/dist/src/tools/get-photo-tool-schema.d.ts +1 -2
- package/dist/src/tools/get-photo-tool-schema.js +9 -12
- package/dist/src/tools/image-reading-tool.d.ts +28 -2
- package/dist/src/tools/image-reading-tool.js +76 -76
- package/dist/src/tools/location-tool.d.ts +11 -2
- package/dist/src/tools/location-tool.js +93 -92
- package/dist/src/tools/login-token-tool.d.ts +20 -2
- package/dist/src/tools/login-token-tool.js +123 -125
- package/dist/src/tools/modify-alarm-tool.d.ts +47 -2
- package/dist/src/tools/modify-alarm-tool.js +250 -252
- package/dist/src/tools/modify-note-tool.d.ts +20 -2
- package/dist/src/tools/modify-note-tool.js +107 -109
- package/dist/src/tools/note-tool.d.ts +20 -2
- package/dist/src/tools/note-tool.js +106 -108
- package/dist/src/tools/query-app-message-tool.d.ts +28 -2
- package/dist/src/tools/query-app-message-tool.js +111 -113
- package/dist/src/tools/query-memory-data-tool.d.ts +28 -2
- package/dist/src/tools/query-memory-data-tool.js +112 -114
- package/dist/src/tools/query-todo-task-tool.d.ts +24 -2
- package/dist/src/tools/query-todo-task-tool.js +106 -108
- package/dist/src/tools/save-file-to-phone-tool.d.ts +24 -2
- package/dist/src/tools/save-file-to-phone-tool.js +130 -132
- package/dist/src/tools/save-media-to-gallery-tool.d.ts +24 -2
- package/dist/src/tools/save-media-to-gallery-tool.js +137 -139
- package/dist/src/tools/save-self-evolution-skill-tool.d.ts +54 -2
- package/dist/src/tools/save-self-evolution-skill-tool.js +194 -194
- package/dist/src/tools/search-alarm-tool.d.ts +34 -2
- package/dist/src/tools/search-alarm-tool.js +174 -176
- package/dist/src/tools/search-calendar-tool.d.ts +24 -2
- package/dist/src/tools/search-calendar-tool.js +148 -150
- package/dist/src/tools/search-contact-tool.d.ts +16 -2
- package/dist/src/tools/search-contact-tool.js +101 -103
- package/dist/src/tools/search-email-tool.d.ts +21 -2
- package/dist/src/tools/search-email-tool.js +110 -112
- package/dist/src/tools/search-file-tool.d.ts +16 -2
- package/dist/src/tools/search-file-tool.js +104 -106
- package/dist/src/tools/search-message-tool.d.ts +16 -2
- package/dist/src/tools/search-message-tool.js +103 -105
- package/dist/src/tools/search-note-tool.d.ts +16 -2
- package/dist/src/tools/search-note-tool.js +98 -100
- package/dist/src/tools/search-photo-gallery-tool.d.ts +21 -2
- package/dist/src/tools/search-photo-gallery-tool.js +35 -37
- package/dist/src/tools/send-cross-device-task-tool.d.ts +35 -2
- package/dist/src/tools/send-cross-device-task-tool.js +216 -150
- package/dist/src/tools/send-email-tool.d.ts +24 -2
- package/dist/src/tools/send-email-tool.js +108 -110
- package/dist/src/tools/send-file-to-user-tool.d.ts +20 -2
- package/dist/src/tools/send-file-to-user-tool.js +174 -178
- package/dist/src/tools/send-html-card-tool.d.ts +20 -2
- package/dist/src/tools/send-html-card-tool.js +85 -87
- package/dist/src/tools/send-message-tool.d.ts +20 -2
- package/dist/src/tools/send-message-tool.js +122 -124
- package/dist/src/tools/session-manager.d.ts +19 -52
- package/dist/src/tools/session-manager.js +95 -247
- package/dist/src/tools/upload-file-tool.d.ts +20 -2
- package/dist/src/tools/upload-file-tool.js +80 -82
- package/dist/src/tools/upload-photo-tool.d.ts +20 -2
- package/dist/src/tools/upload-photo-tool.js +68 -70
- package/dist/src/tools/xiaoyi-add-collection-tool.d.ts +32 -2
- package/dist/src/tools/xiaoyi-add-collection-tool.js +146 -148
- package/dist/src/tools/xiaoyi-collection-tool.d.ts +20 -2
- package/dist/src/tools/xiaoyi-collection-tool.js +114 -116
- package/dist/src/tools/xiaoyi-delete-collection-tool.d.ts +15 -2
- package/dist/src/tools/xiaoyi-delete-collection-tool.js +127 -129
- package/dist/src/tools/xiaoyi-gui-tool.d.ts +16 -2
- package/dist/src/tools/xiaoyi-gui-tool.js +92 -95
- package/dist/src/types.d.ts +6 -6
- package/dist/src/utils/config-manager.d.ts +3 -2
- package/dist/src/utils/config-manager.js +22 -2
- package/dist/src/utils/cron-push-map.d.ts +26 -0
- package/dist/src/utils/cron-push-map.js +131 -0
- package/dist/src/utils/logger.js +3 -14
- package/dist/src/websocket.d.ts +1 -1
- package/dist/src/websocket.js +29 -13
- package/package.json +1 -1
|
@@ -1,118 +1,116 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getCachedXYWebSocketManager } from "../client.js";
|
|
2
2
|
import { sendCommand } from "../formatter.js";
|
|
3
|
-
import {
|
|
3
|
+
import { getCurrentSessionContext } from './session-manager.js';
|
|
4
4
|
import { logger } from "../utils/logger.js";
|
|
5
5
|
/**
|
|
6
6
|
* XY search message tool - searches SMS messages on user's device.
|
|
7
7
|
* Returns matching messages based on content keyword search.
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
type: "string",
|
|
20
|
-
description: "搜索关键词,用于在短信内容中进行匹配",
|
|
21
|
-
},
|
|
9
|
+
export const searchMessageTool = {
|
|
10
|
+
name: "search_message",
|
|
11
|
+
label: "Search Message",
|
|
12
|
+
description: "搜索手机短信。根据关键词搜索短信内容。注意:操作超时时间为60秒,请勿重复调用此工具,如果超时或失败,最多重试一次。",
|
|
13
|
+
parameters: {
|
|
14
|
+
type: "object",
|
|
15
|
+
properties: {
|
|
16
|
+
content: {
|
|
17
|
+
type: "string",
|
|
18
|
+
description: "搜索关键词,用于在短信内容中进行匹配",
|
|
22
19
|
},
|
|
23
|
-
required: ["content"],
|
|
24
20
|
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
21
|
+
required: ["content"],
|
|
22
|
+
},
|
|
23
|
+
async execute(toolCallId, params) {
|
|
24
|
+
const _c = getCurrentSessionContext();
|
|
25
|
+
const { config, sessionId, taskId, messageId } = _c;
|
|
26
|
+
// Validate content parameter
|
|
27
|
+
if (!params.content || typeof params.content !== "string" || params.content.trim() === "") {
|
|
28
|
+
throw new Error("Missing required parameter: content must be a non-empty string");
|
|
29
|
+
}
|
|
30
|
+
// Get WebSocket manager
|
|
31
|
+
const wsManager = getCachedXYWebSocketManager();
|
|
32
|
+
// Build SearchMessage command
|
|
33
|
+
const command = {
|
|
34
|
+
header: {
|
|
35
|
+
namespace: "Common",
|
|
36
|
+
name: "Action",
|
|
37
|
+
},
|
|
38
|
+
payload: {
|
|
39
|
+
cardParam: {},
|
|
40
|
+
executeParam: {
|
|
41
|
+
executeMode: "background",
|
|
42
|
+
intentName: "SearchMessage",
|
|
43
|
+
bundleName: "com.huawei.hmos.aidispatchservice",
|
|
44
|
+
needUnlock: true,
|
|
45
|
+
actionResponse: true,
|
|
46
|
+
appType: "OHOS_APP",
|
|
47
|
+
timeOut: 5,
|
|
48
|
+
intentParam: {
|
|
49
|
+
content: params.content.trim(),
|
|
50
|
+
size: 50
|
|
54
51
|
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
resultCode: "",
|
|
58
|
-
displayText: "",
|
|
59
|
-
ttsText: "",
|
|
60
|
-
},
|
|
61
|
-
],
|
|
62
|
-
needUploadResult: true,
|
|
63
|
-
noHalfPage: false,
|
|
64
|
-
pageControlRelated: false,
|
|
52
|
+
permissionId: [],
|
|
53
|
+
achieveType: "INTENT",
|
|
65
54
|
},
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
const errorDetail = event.outputs ? JSON.stringify(event.outputs) : event.status;
|
|
92
|
-
reject(new Error(`搜索短信失败: ${errorDetail}`));
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
// Register event handler
|
|
97
|
-
wsManager.on("data-event", handler);
|
|
98
|
-
// Send the command
|
|
99
|
-
const currentTaskId = getCurrentTaskId(sessionId) ?? taskId;
|
|
100
|
-
sendCommand({
|
|
101
|
-
config,
|
|
102
|
-
sessionId,
|
|
103
|
-
taskId: currentTaskId,
|
|
104
|
-
messageId,
|
|
105
|
-
command,
|
|
106
|
-
toolCallId,
|
|
107
|
-
})
|
|
108
|
-
.then(() => {
|
|
109
|
-
})
|
|
110
|
-
.catch((error) => {
|
|
55
|
+
responses: [
|
|
56
|
+
{
|
|
57
|
+
resultCode: "",
|
|
58
|
+
displayText: "",
|
|
59
|
+
ttsText: "",
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
needUploadResult: true,
|
|
63
|
+
noHalfPage: false,
|
|
64
|
+
pageControlRelated: false,
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
// Send command and wait for response (60 second timeout)
|
|
68
|
+
return new Promise((resolve, reject) => {
|
|
69
|
+
const timeout = setTimeout(() => {
|
|
70
|
+
wsManager.off("data-event", handler);
|
|
71
|
+
logger.error("超时: 搜索短信超时(60秒)", { toolCallId });
|
|
72
|
+
reject(new Error("搜索短信超时(60秒)"));
|
|
73
|
+
}, 60000);
|
|
74
|
+
// Listen for data events from WebSocket
|
|
75
|
+
const handler = (event) => {
|
|
76
|
+
if (event.intentName === "SearchMessage") {
|
|
111
77
|
clearTimeout(timeout);
|
|
112
78
|
wsManager.off("data-event", handler);
|
|
113
|
-
|
|
114
|
-
|
|
79
|
+
if (event.status === "success" && event.outputs) {
|
|
80
|
+
// 成功,直接返回完整的 event.outputs JSON 字符串
|
|
81
|
+
resolve({
|
|
82
|
+
content: [
|
|
83
|
+
{
|
|
84
|
+
type: "text",
|
|
85
|
+
text: JSON.stringify(event.outputs),
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
const errorDetail = event.outputs ? JSON.stringify(event.outputs) : event.status;
|
|
92
|
+
reject(new Error(`搜索短信失败: ${errorDetail}`));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
// Register event handler
|
|
97
|
+
wsManager.on("data-event", handler);
|
|
98
|
+
// Send the command
|
|
99
|
+
sendCommand({
|
|
100
|
+
config,
|
|
101
|
+
sessionId,
|
|
102
|
+
taskId,
|
|
103
|
+
messageId,
|
|
104
|
+
command,
|
|
105
|
+
toolCallId,
|
|
106
|
+
})
|
|
107
|
+
.then(() => {
|
|
108
|
+
})
|
|
109
|
+
.catch((error) => {
|
|
110
|
+
clearTimeout(timeout);
|
|
111
|
+
wsManager.off("data-event", handler);
|
|
112
|
+
reject(error);
|
|
115
113
|
});
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
114
|
+
});
|
|
115
|
+
},
|
|
116
|
+
};
|
|
@@ -1,6 +1,20 @@
|
|
|
1
|
-
import type { SessionContext } from "./session-manager.js";
|
|
2
1
|
/**
|
|
3
2
|
* XY search note tool - searches notes on user's device.
|
|
4
3
|
* Returns matching notes based on query string.
|
|
5
4
|
*/
|
|
6
|
-
export declare
|
|
5
|
+
export declare const searchNoteTool: {
|
|
6
|
+
name: string;
|
|
7
|
+
label: string;
|
|
8
|
+
description: string;
|
|
9
|
+
parameters: {
|
|
10
|
+
type: string;
|
|
11
|
+
properties: {
|
|
12
|
+
query: {
|
|
13
|
+
type: string;
|
|
14
|
+
description: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
required: string[];
|
|
18
|
+
};
|
|
19
|
+
execute(toolCallId: string, params: any): Promise<unknown>;
|
|
20
|
+
};
|
|
@@ -1,113 +1,111 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getCachedXYWebSocketManager } from "../client.js";
|
|
2
2
|
import { sendCommand } from "../formatter.js";
|
|
3
|
-
import {
|
|
3
|
+
import { getCurrentSessionContext } from './session-manager.js';
|
|
4
4
|
import { logger } from "../utils/logger.js";
|
|
5
5
|
/**
|
|
6
6
|
* XY search note tool - searches notes on user's device.
|
|
7
7
|
* Returns matching notes based on query string.
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
type: "string",
|
|
20
|
-
description: "搜索关键词,用于在备忘录中检索相关内容",
|
|
21
|
-
},
|
|
9
|
+
export const searchNoteTool = {
|
|
10
|
+
name: "search_notes",
|
|
11
|
+
label: "Search Notes",
|
|
12
|
+
description: "搜索用户设备上的备忘录内容。根据关键词在备忘录的标题、内容和附件名称中进行检索。注意:操作超时时间为60秒,请勿重复调用此工具,如果超时或失败,最多重试一次。回复约束:如果工具返回没有授权或者其他报错,只需要完整描述没有授权或者其他报错内容即可,不需要主动给用户提供解决方案,例如告诉用户如何授权,如何解决报错等都是不需要的,请严格遵守。",
|
|
13
|
+
parameters: {
|
|
14
|
+
type: "object",
|
|
15
|
+
properties: {
|
|
16
|
+
query: {
|
|
17
|
+
type: "string",
|
|
18
|
+
description: "搜索关键词,用于在备忘录中检索相关内容",
|
|
22
19
|
},
|
|
23
|
-
required: ["query"],
|
|
24
20
|
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
21
|
+
required: ["query"],
|
|
22
|
+
},
|
|
23
|
+
async execute(toolCallId, params) {
|
|
24
|
+
const _c = getCurrentSessionContext();
|
|
25
|
+
const { config, sessionId, taskId, messageId } = _c;
|
|
26
|
+
// Validate parameters
|
|
27
|
+
if (!params.query) {
|
|
28
|
+
throw new Error("Missing required parameter: query is required");
|
|
29
|
+
}
|
|
30
|
+
// Get WebSocket manager
|
|
31
|
+
const wsManager = getCachedXYWebSocketManager();
|
|
32
|
+
// Build SearchNote command
|
|
33
|
+
const command = {
|
|
34
|
+
header: {
|
|
35
|
+
namespace: "Common",
|
|
36
|
+
name: "Action",
|
|
37
|
+
},
|
|
38
|
+
payload: {
|
|
39
|
+
cardParam: {},
|
|
40
|
+
executeParam: {
|
|
41
|
+
executeMode: "background",
|
|
42
|
+
intentName: "SearchNote",
|
|
43
|
+
bundleName: "com.huawei.hmos.notepad",
|
|
44
|
+
dimension: "",
|
|
45
|
+
needUnlock: true,
|
|
46
|
+
actionResponse: true,
|
|
47
|
+
timeOut: 5,
|
|
48
|
+
intentParam: {
|
|
49
|
+
query: params.query,
|
|
52
50
|
},
|
|
53
|
-
|
|
54
|
-
{
|
|
55
|
-
resultCode: "",
|
|
56
|
-
displayText: "",
|
|
57
|
-
ttsText: "",
|
|
58
|
-
},
|
|
59
|
-
],
|
|
60
|
-
needUploadResult: true,
|
|
61
|
-
noHalfPage: false,
|
|
62
|
-
pageControlRelated: false,
|
|
51
|
+
achieveType: "INTENT",
|
|
63
52
|
},
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
reject(new Error(`搜索备忘录失败: ${JSON.stringify(event.outputs)}`));
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
// Register event handler
|
|
94
|
-
wsManager.on("data-event", handler);
|
|
95
|
-
// Send the command
|
|
96
|
-
const currentTaskId = getCurrentTaskId(sessionId) ?? taskId;
|
|
97
|
-
sendCommand({
|
|
98
|
-
config,
|
|
99
|
-
sessionId,
|
|
100
|
-
taskId: currentTaskId,
|
|
101
|
-
messageId,
|
|
102
|
-
command,
|
|
103
|
-
toolCallId,
|
|
104
|
-
}).then(() => {
|
|
105
|
-
}).catch((error) => {
|
|
53
|
+
responses: [
|
|
54
|
+
{
|
|
55
|
+
resultCode: "",
|
|
56
|
+
displayText: "",
|
|
57
|
+
ttsText: "",
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
needUploadResult: true,
|
|
61
|
+
noHalfPage: false,
|
|
62
|
+
pageControlRelated: false,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
// Send command and wait for response (60 second timeout)
|
|
66
|
+
return new Promise((resolve, reject) => {
|
|
67
|
+
const timeout = setTimeout(() => {
|
|
68
|
+
wsManager.off("data-event", handler);
|
|
69
|
+
logger.error("超时: 搜索备忘录超时(60秒)", { toolCallId });
|
|
70
|
+
reject(new Error("搜索备忘录超时(60秒)"));
|
|
71
|
+
}, 60000);
|
|
72
|
+
// Listen for data events from WebSocket
|
|
73
|
+
const handler = (event) => {
|
|
74
|
+
if (event.intentName === "SearchNote") {
|
|
106
75
|
clearTimeout(timeout);
|
|
107
76
|
wsManager.off("data-event", handler);
|
|
108
|
-
|
|
109
|
-
|
|
77
|
+
if (event.status === "success" && event.outputs) {
|
|
78
|
+
// 成功,直接返回完整的 event.outputs JSON 字符串
|
|
79
|
+
resolve({
|
|
80
|
+
content: [
|
|
81
|
+
{
|
|
82
|
+
type: "text",
|
|
83
|
+
text: JSON.stringify(event.outputs),
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
reject(new Error(`搜索备忘录失败: ${JSON.stringify(event.outputs)}`));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
// Register event handler
|
|
94
|
+
wsManager.on("data-event", handler);
|
|
95
|
+
// Send the command
|
|
96
|
+
sendCommand({
|
|
97
|
+
config,
|
|
98
|
+
sessionId,
|
|
99
|
+
taskId,
|
|
100
|
+
messageId,
|
|
101
|
+
command,
|
|
102
|
+
toolCallId,
|
|
103
|
+
}).then(() => {
|
|
104
|
+
}).catch((error) => {
|
|
105
|
+
clearTimeout(timeout);
|
|
106
|
+
wsManager.off("data-event", handler);
|
|
107
|
+
reject(error);
|
|
110
108
|
});
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
109
|
+
});
|
|
110
|
+
},
|
|
111
|
+
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { SessionContext } from "./session-manager.js";
|
|
2
1
|
/**
|
|
3
2
|
* XY search photo gallery tool - searches photos in user's gallery.
|
|
4
3
|
* Returns local mediaUri strings that can be used with upload_photo tool.
|
|
@@ -6,4 +5,24 @@ import type { SessionContext } from "./session-manager.js";
|
|
|
6
5
|
* IMPORTANT: The returned mediaUris are LOCAL URIs that cannot be downloaded directly.
|
|
7
6
|
* To get publicly accessible URLs, use the upload_photo tool with these URIs.
|
|
8
7
|
*/
|
|
9
|
-
export declare
|
|
8
|
+
export declare const searchPhotoGalleryTool: {
|
|
9
|
+
name: string;
|
|
10
|
+
label: string;
|
|
11
|
+
description: string;
|
|
12
|
+
parameters: {
|
|
13
|
+
type: string;
|
|
14
|
+
properties: {
|
|
15
|
+
query: {
|
|
16
|
+
type: string;
|
|
17
|
+
description: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
required: string[];
|
|
21
|
+
};
|
|
22
|
+
execute(toolCallId: string, params: any): Promise<{
|
|
23
|
+
content: {
|
|
24
|
+
type: string;
|
|
25
|
+
text: string;
|
|
26
|
+
}[];
|
|
27
|
+
}>;
|
|
28
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getCachedXYWebSocketManager } from "../client.js";
|
|
2
2
|
import { sendCommand } from "../formatter.js";
|
|
3
|
-
import {
|
|
3
|
+
import { getCurrentSessionContext } from './session-manager.js';
|
|
4
4
|
import { logger } from "../utils/logger.js";
|
|
5
5
|
/**
|
|
6
6
|
* XY search photo gallery tool - searches photos in user's gallery.
|
|
@@ -9,12 +9,10 @@ import { logger } from "../utils/logger.js";
|
|
|
9
9
|
* IMPORTANT: The returned mediaUris are LOCAL URIs that cannot be downloaded directly.
|
|
10
10
|
* To get publicly accessible URLs, use the upload_photo tool with these URIs.
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
label: "Search Photo Gallery",
|
|
17
|
-
description: `插件功能描述:搜索用户设备图库中的照片
|
|
12
|
+
export const searchPhotoGalleryTool = {
|
|
13
|
+
name: "search_photo_gallery",
|
|
14
|
+
label: "Search Photo Gallery",
|
|
15
|
+
description: `插件功能描述:搜索用户设备图库中的照片
|
|
18
16
|
|
|
19
17
|
工具使用约束:如果用户说从手机/鸿蒙PC图库中或者从相册中查询xx图片时调用此工具,注意此工具仅支持从本地图库检索,不支持云空间相册检索。
|
|
20
18
|
|
|
@@ -48,12 +46,12 @@ export function createSearchPhotoGalleryTool(ctx) {
|
|
|
48
46
|
|
|
49
47
|
回复约束:如果工具返回没有授权或者其他报错,只需要完整描述没有授权或者其他报错内容即可,不需要主动给用户提供解决方案,例如告诉用户如何授权,如何解决报错等都是不需要的,请严格遵守。
|
|
50
48
|
`,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
49
|
+
parameters: {
|
|
50
|
+
type: "object",
|
|
51
|
+
properties: {
|
|
52
|
+
query: {
|
|
53
|
+
type: "string",
|
|
54
|
+
description: `图像描述语料,用于检索匹配的照片。支持口语化输入,会自动提取姓名、种类、地点等实体。
|
|
57
55
|
|
|
58
56
|
使用示例:
|
|
59
57
|
- 正确:"小狗的照片"、"南京拍的风景"、"张三的照片"、"西安之行相册的照片"、"2024年的照片"
|
|
@@ -62,31 +60,31 @@ export function createSearchPhotoGalleryTool(ctx) {
|
|
|
62
60
|
- 错误:"近三年的照片"(需拆分成"2023年的照片"、"2024年的照片"、"2025年的照片")
|
|
63
61
|
|
|
64
62
|
重要:每次查询只能包含一个原子实体(单个地点、单个人名、单个年份等),不支持多实体或"或"逻辑。`,
|
|
65
|
-
},
|
|
66
63
|
},
|
|
67
|
-
required: ["query"],
|
|
68
|
-
},
|
|
69
|
-
async execute(toolCallId, params) {
|
|
70
|
-
// Validate parameters
|
|
71
|
-
if (!params.query) {
|
|
72
|
-
throw new Error("Missing required parameter: query is required");
|
|
73
|
-
}
|
|
74
|
-
// Get WebSocket manager
|
|
75
|
-
const wsManager = getXYWebSocketManager(config);
|
|
76
|
-
// Search for photos
|
|
77
|
-
const currentTaskId = getCurrentTaskId(sessionId) ?? taskId;
|
|
78
|
-
const outputs = await searchPhotos(wsManager, config, sessionId, currentTaskId, messageId, toolCallId, params.query);
|
|
79
|
-
return {
|
|
80
|
-
content: [
|
|
81
|
-
{
|
|
82
|
-
type: "text",
|
|
83
|
-
text: JSON.stringify(outputs),
|
|
84
|
-
},
|
|
85
|
-
],
|
|
86
|
-
};
|
|
87
64
|
},
|
|
88
|
-
|
|
89
|
-
}
|
|
65
|
+
required: ["query"],
|
|
66
|
+
},
|
|
67
|
+
async execute(toolCallId, params) {
|
|
68
|
+
const _c = getCurrentSessionContext();
|
|
69
|
+
const { config, sessionId, taskId, messageId } = _c;
|
|
70
|
+
// Validate parameters
|
|
71
|
+
if (!params.query) {
|
|
72
|
+
throw new Error("Missing required parameter: query is required");
|
|
73
|
+
}
|
|
74
|
+
// Get WebSocket manager
|
|
75
|
+
const wsManager = getCachedXYWebSocketManager();
|
|
76
|
+
// Search for photos
|
|
77
|
+
const outputs = await searchPhotos(wsManager, config, sessionId, taskId, messageId, toolCallId, params.query);
|
|
78
|
+
return {
|
|
79
|
+
content: [
|
|
80
|
+
{
|
|
81
|
+
type: "text",
|
|
82
|
+
text: JSON.stringify(outputs),
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
};
|
|
86
|
+
},
|
|
87
|
+
};
|
|
90
88
|
/**
|
|
91
89
|
* Search for photos using query description
|
|
92
90
|
* Returns complete event.outputs object
|
|
@@ -1,2 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export declare const sendCrossDeviceTaskTool: {
|
|
2
|
+
name: string;
|
|
3
|
+
label: string;
|
|
4
|
+
description: string;
|
|
5
|
+
parameters: {
|
|
6
|
+
type: string;
|
|
7
|
+
properties: {
|
|
8
|
+
query: {
|
|
9
|
+
type: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
targetDeviceInfo: {
|
|
13
|
+
type: string;
|
|
14
|
+
description: string;
|
|
15
|
+
properties: {
|
|
16
|
+
networkId: {
|
|
17
|
+
type: string;
|
|
18
|
+
description: string;
|
|
19
|
+
};
|
|
20
|
+
deviceName: {
|
|
21
|
+
type: string;
|
|
22
|
+
description: string;
|
|
23
|
+
};
|
|
24
|
+
deviceTypeId: {
|
|
25
|
+
type: string;
|
|
26
|
+
description: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
required: string[];
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
required: string[];
|
|
33
|
+
};
|
|
34
|
+
execute(_toolCallId: string, params: any): Promise<unknown>;
|
|
35
|
+
};
|