@ynhcj/xiaoyi-channel 0.0.123-beta → 0.0.124-beta
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/channel.js +2 -17
- package/dist/src/monitor.js +10 -1
- package/dist/src/provider.js +9 -5
- package/dist/src/tools/calendar-tool.d.ts +2 -1
- package/dist/src/tools/calendar-tool.js +112 -116
- package/dist/src/tools/call-device-tool.d.ts +2 -1
- package/dist/src/tools/call-device-tool.js +126 -103
- package/dist/src/tools/call-phone-tool.d.ts +2 -1
- package/dist/src/tools/call-phone-tool.js +109 -113
- package/dist/src/tools/create-alarm-tool.d.ts +2 -1
- package/dist/src/tools/create-alarm-tool.js +227 -231
- package/dist/src/tools/create-all-tools.d.ts +16 -0
- package/dist/src/tools/create-all-tools.js +50 -0
- package/dist/src/tools/delete-alarm-tool.d.ts +2 -1
- package/dist/src/tools/delete-alarm-tool.js +131 -135
- package/dist/src/tools/get-alarm-tool-schema.d.ts +2 -1
- package/dist/src/tools/get-alarm-tool-schema.js +16 -10
- package/dist/src/tools/get-calendar-tool-schema.d.ts +2 -1
- package/dist/src/tools/get-calendar-tool-schema.js +12 -8
- package/dist/src/tools/get-collection-tool-schema.d.ts +2 -1
- package/dist/src/tools/get-collection-tool-schema.js +11 -9
- package/dist/src/tools/get-contact-tool-schema.d.ts +2 -1
- package/dist/src/tools/get-contact-tool-schema.js +16 -10
- package/dist/src/tools/get-device-file-tool-schema.d.ts +2 -1
- package/dist/src/tools/get-device-file-tool-schema.js +13 -9
- package/dist/src/tools/get-email-tool-schema.d.ts +2 -1
- package/dist/src/tools/get-email-tool-schema.js +11 -8
- package/dist/src/tools/get-note-tool-schema.d.ts +2 -1
- package/dist/src/tools/get-note-tool-schema.js +14 -9
- package/dist/src/tools/get-photo-tool-schema.d.ts +2 -1
- package/dist/src/tools/get-photo-tool-schema.js +12 -9
- package/dist/src/tools/image-reading-tool.d.ts +2 -1
- package/dist/src/tools/image-reading-tool.js +86 -90
- package/dist/src/tools/location-tool.d.ts +2 -1
- package/dist/src/tools/location-tool.js +87 -91
- package/dist/src/tools/login-token-tool.d.ts +2 -1
- package/dist/src/tools/login-token-tool.js +113 -116
- package/dist/src/tools/modify-alarm-tool.d.ts +2 -1
- package/dist/src/tools/modify-alarm-tool.js +232 -236
- package/dist/src/tools/modify-note-tool.d.ts +2 -1
- package/dist/src/tools/modify-note-tool.js +104 -108
- package/dist/src/tools/note-tool.d.ts +2 -1
- package/dist/src/tools/note-tool.js +103 -107
- package/dist/src/tools/query-app-message-tool.d.ts +2 -1
- package/dist/src/tools/query-app-message-tool.js +108 -111
- package/dist/src/tools/query-memory-data-tool.d.ts +2 -1
- package/dist/src/tools/query-memory-data-tool.js +109 -112
- package/dist/src/tools/query-todo-task-tool.d.ts +2 -1
- package/dist/src/tools/query-todo-task-tool.js +103 -106
- package/dist/src/tools/save-file-to-phone-tool.d.ts +2 -1
- package/dist/src/tools/save-file-to-phone-tool.js +127 -131
- package/dist/src/tools/save-media-to-gallery-tool.d.ts +2 -1
- package/dist/src/tools/save-media-to-gallery-tool.js +134 -138
- package/dist/src/tools/save-self-evolution-skill-tool.d.ts +2 -1
- package/dist/src/tools/save-self-evolution-skill-tool.js +194 -196
- package/dist/src/tools/search-alarm-tool.d.ts +2 -1
- package/dist/src/tools/search-alarm-tool.js +171 -175
- package/dist/src/tools/search-calendar-tool.d.ts +2 -1
- package/dist/src/tools/search-calendar-tool.js +145 -149
- package/dist/src/tools/search-contact-tool.d.ts +2 -1
- package/dist/src/tools/search-contact-tool.js +98 -102
- package/dist/src/tools/search-email-tool.d.ts +2 -1
- package/dist/src/tools/search-email-tool.js +107 -111
- package/dist/src/tools/search-file-tool.d.ts +2 -1
- package/dist/src/tools/search-file-tool.js +99 -103
- package/dist/src/tools/search-message-tool.d.ts +2 -1
- package/dist/src/tools/search-message-tool.js +100 -104
- package/dist/src/tools/search-note-tool.d.ts +2 -1
- package/dist/src/tools/search-note-tool.js +95 -99
- package/dist/src/tools/search-photo-gallery-tool.d.ts +2 -1
- package/dist/src/tools/search-photo-gallery-tool.js +34 -38
- package/dist/src/tools/send-email-tool.d.ts +2 -1
- package/dist/src/tools/send-email-tool.js +105 -108
- package/dist/src/tools/send-file-to-user-tool.d.ts +2 -1
- package/dist/src/tools/send-file-to-user-tool.js +151 -155
- package/dist/src/tools/send-message-tool.d.ts +2 -1
- package/dist/src/tools/send-message-tool.js +119 -123
- package/dist/src/tools/session-manager.d.ts +18 -1
- package/dist/src/tools/session-manager.js +93 -11
- package/dist/src/tools/upload-file-tool.d.ts +2 -1
- package/dist/src/tools/upload-file-tool.js +78 -82
- package/dist/src/tools/upload-photo-tool.d.ts +2 -1
- package/dist/src/tools/upload-photo-tool.js +69 -73
- package/dist/src/tools/xiaoyi-add-collection-tool.d.ts +2 -1
- package/dist/src/tools/xiaoyi-add-collection-tool.js +143 -147
- package/dist/src/tools/xiaoyi-collection-tool.d.ts +2 -1
- package/dist/src/tools/xiaoyi-collection-tool.js +111 -115
- package/dist/src/tools/xiaoyi-delete-collection-tool.d.ts +2 -1
- package/dist/src/tools/xiaoyi-delete-collection-tool.js +124 -128
- package/dist/src/tools/xiaoyi-gui-tool.d.ts +2 -1
- package/dist/src/tools/xiaoyi-gui-tool.js +84 -88
- package/package.json +1 -1
|
@@ -1,126 +1,122 @@
|
|
|
1
1
|
import { getXYWebSocketManager } from "../client.js";
|
|
2
2
|
import { sendCommand } from "../formatter.js";
|
|
3
|
-
import { getCurrentSessionContext } from "./session-manager.js";
|
|
4
3
|
/**
|
|
5
4
|
* XY call phone tool - makes a phone call on user's device.
|
|
6
5
|
* Requires phoneNumber parameter and optional slotId (0 for primary SIM, 1 for secondary SIM).
|
|
7
6
|
*/
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
7
|
+
export function createCallPhoneTool(ctx) {
|
|
8
|
+
const { config, sessionId, taskId, messageId } = ctx;
|
|
9
|
+
return {
|
|
10
|
+
name: "call_phone",
|
|
11
|
+
label: "Call Phone",
|
|
12
|
+
description: "拨打电话。需要提供要拨打的电话号码。slotId参数可选,默认为0(主卡),如果用户明确要求使用副卡则设置为1。注意:操作超时时间为60秒,请勿重复调用此工具,如果超时或失败,最多重试一次。回复约束:如果工具返回没有授权或者其他报错,只需要完整描述没有授权或者其他报错内容即可,不需要主动给用户提供解决方案,例如告诉用户如何授权,如何解决报错等都是不需要的,请严格遵守。",
|
|
13
|
+
parameters: {
|
|
14
|
+
type: "object",
|
|
15
|
+
properties: {
|
|
16
|
+
phoneNumber: {
|
|
17
|
+
type: "string",
|
|
18
|
+
description: "要拨打的电话号码",
|
|
19
|
+
},
|
|
20
|
+
slotId: {
|
|
21
|
+
type: "number",
|
|
22
|
+
description: "SIM卡槽ID,默认为0(主卡),设置为1表示副卡。仅当用户明确要求使用副卡时才设置为1",
|
|
23
|
+
default: 0,
|
|
24
|
+
},
|
|
23
25
|
},
|
|
26
|
+
required: ["phoneNumber"],
|
|
24
27
|
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const { config, sessionId, taskId, messageId } = sessionContext;
|
|
44
|
-
// Get WebSocket manager
|
|
45
|
-
const wsManager = getXYWebSocketManager(config);
|
|
46
|
-
// Build StartCall command
|
|
47
|
-
const command = {
|
|
48
|
-
header: {
|
|
49
|
-
namespace: "Common",
|
|
50
|
-
name: "Action",
|
|
51
|
-
},
|
|
52
|
-
payload: {
|
|
53
|
-
cardParam: {},
|
|
54
|
-
executeParam: {
|
|
55
|
-
executeMode: "background",
|
|
56
|
-
intentName: "StartCall",
|
|
57
|
-
bundleName: "com.huawei.hmos.aidispatchservice",
|
|
58
|
-
dimension: "",
|
|
59
|
-
needUnlock: true,
|
|
60
|
-
actionResponse: true,
|
|
61
|
-
timeOut: 5,
|
|
62
|
-
intentParam: {
|
|
63
|
-
phoneNumber: params.phoneNumber.trim(),
|
|
64
|
-
slotId: slotId,
|
|
65
|
-
},
|
|
66
|
-
permissionId: [],
|
|
67
|
-
achieveType: "INTENT",
|
|
28
|
+
async execute(toolCallId, params) {
|
|
29
|
+
// Validate phoneNumber parameter
|
|
30
|
+
if (!params.phoneNumber || typeof params.phoneNumber !== "string" || params.phoneNumber.trim() === "") {
|
|
31
|
+
throw new Error("Missing required parameter: phoneNumber must be a non-empty string");
|
|
32
|
+
}
|
|
33
|
+
// Set default slotId if not provided
|
|
34
|
+
const slotId = params.slotId !== undefined && params.slotId !== null ? params.slotId : 0;
|
|
35
|
+
// Validate slotId (must be 0 or 1)
|
|
36
|
+
if (slotId !== 0 && slotId !== 1) {
|
|
37
|
+
throw new Error("Invalid slotId: must be 0 (primary SIM) or 1 (secondary SIM)");
|
|
38
|
+
}
|
|
39
|
+
// Get WebSocket manager
|
|
40
|
+
const wsManager = getXYWebSocketManager(config);
|
|
41
|
+
// Build StartCall command
|
|
42
|
+
const command = {
|
|
43
|
+
header: {
|
|
44
|
+
namespace: "Common",
|
|
45
|
+
name: "Action",
|
|
68
46
|
},
|
|
69
|
-
|
|
70
|
-
{
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
47
|
+
payload: {
|
|
48
|
+
cardParam: {},
|
|
49
|
+
executeParam: {
|
|
50
|
+
executeMode: "background",
|
|
51
|
+
intentName: "StartCall",
|
|
52
|
+
bundleName: "com.huawei.hmos.aidispatchservice",
|
|
53
|
+
dimension: "",
|
|
54
|
+
needUnlock: true,
|
|
55
|
+
actionResponse: true,
|
|
56
|
+
timeOut: 5,
|
|
57
|
+
intentParam: {
|
|
58
|
+
phoneNumber: params.phoneNumber.trim(),
|
|
59
|
+
slotId: slotId,
|
|
60
|
+
},
|
|
61
|
+
permissionId: [],
|
|
62
|
+
achieveType: "INTENT",
|
|
74
63
|
},
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
//
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
clearTimeout(timeout);
|
|
64
|
+
responses: [
|
|
65
|
+
{
|
|
66
|
+
resultCode: "",
|
|
67
|
+
displayText: "",
|
|
68
|
+
ttsText: "",
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
needUploadResult: true,
|
|
72
|
+
noHalfPage: false,
|
|
73
|
+
pageControlRelated: false,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
// Send command and wait for response (60 second timeout)
|
|
77
|
+
return new Promise((resolve, reject) => {
|
|
78
|
+
const timeout = setTimeout(() => {
|
|
91
79
|
wsManager.off("data-event", handler);
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
80
|
+
reject(new Error("拨打电话超时(60秒)"));
|
|
81
|
+
}, 60000);
|
|
82
|
+
// Listen for data events from WebSocket
|
|
83
|
+
const handler = (event) => {
|
|
84
|
+
if (event.intentName === "StartCall") {
|
|
85
|
+
clearTimeout(timeout);
|
|
86
|
+
wsManager.off("data-event", handler);
|
|
87
|
+
if (event.status === "success" && event.outputs) {
|
|
88
|
+
resolve({
|
|
89
|
+
content: [
|
|
90
|
+
{
|
|
91
|
+
type: "text",
|
|
92
|
+
text: JSON.stringify(event.outputs),
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
reject(new Error(`拨打电话失败: ${event.status}`));
|
|
99
|
+
}
|
|
101
100
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
clearTimeout(timeout);
|
|
121
|
-
wsManager.off("data-event", handler);
|
|
122
|
-
reject(error);
|
|
101
|
+
};
|
|
102
|
+
// Register event handler
|
|
103
|
+
wsManager.on("data-event", handler);
|
|
104
|
+
// Send the command
|
|
105
|
+
sendCommand({
|
|
106
|
+
config,
|
|
107
|
+
sessionId,
|
|
108
|
+
taskId,
|
|
109
|
+
messageId,
|
|
110
|
+
command,
|
|
111
|
+
})
|
|
112
|
+
.then(() => {
|
|
113
|
+
})
|
|
114
|
+
.catch((error) => {
|
|
115
|
+
clearTimeout(timeout);
|
|
116
|
+
wsManager.off("data-event", handler);
|
|
117
|
+
reject(error);
|
|
118
|
+
});
|
|
123
119
|
});
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { SessionContext } from "./session-manager.js";
|
|
1
2
|
/**
|
|
2
3
|
* XY create alarm tool - creates an alarm on user's device.
|
|
3
4
|
* Requires alarmTime parameter. Other parameters are optional with sensible defaults.
|
|
4
5
|
*
|
|
5
6
|
* Time format: YYYYMMDD hhmmss (e.g., 20240315 143000)
|
|
6
7
|
*/
|
|
7
|
-
export declare
|
|
8
|
+
export declare function makeAlarmTool(ctx: SessionContext): any;
|