@ray-js/t-agent-plugin-aistream 0.2.0-beta-15 → 0.2.0-beta-16
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/AIStreamTypes.d.ts +31 -17
- package/dist/AIStreamTypes.js +5 -0
- package/dist/buildIn/withBuildIn.js +40 -2
- package/package.json +2 -2
package/dist/AIStreamTypes.d.ts
CHANGED
|
@@ -1434,24 +1434,38 @@ export type ReceivedTextNlgPacket = ReceivedTextPacketBase<ReceivedTextPacketTyp
|
|
|
1434
1434
|
finish: boolean;
|
|
1435
1435
|
}>;
|
|
1436
1436
|
export declare enum BuildInSkillCode {
|
|
1437
|
-
SEARCH_KNOWLEDGE = "searchKnowledge"
|
|
1437
|
+
SEARCH_KNOWLEDGE = "searchKnowledge",
|
|
1438
|
+
SMART_HOME = "smart_home"
|
|
1438
1439
|
}
|
|
1439
|
-
export type ReceivedTextSkillPacketBody<
|
|
1440
|
-
code:
|
|
1441
|
-
|
|
1442
|
-
|
|
1440
|
+
export type ReceivedTextSkillPacketBody<Code = BuildInSkillCode | string, G = any, C = any> = {
|
|
1441
|
+
code: Code;
|
|
1442
|
+
general?: G;
|
|
1443
|
+
custom?: C;
|
|
1443
1444
|
};
|
|
1444
|
-
export type ReceivedTextSkillPacket<
|
|
1445
|
+
export type ReceivedTextSkillPacket<Code = BuildInSkillCode | string, G = any, C = any> = ReceivedTextPacketBase<ReceivedTextPacketType.SKILL, ReceivedTextSkillPacketBody<Code, G, C>>;
|
|
1445
1446
|
export type ReceivedTextPacket = ReceivedTextAsrPacket | ReceivedTextNlgPacket | ReceivedTextSkillPacket;
|
|
1446
|
-
export type
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1447
|
+
export type ReceivedSearchKnowledgeSkill = ReceivedTextSkillPacketBody<BuildInSkillCode.SEARCH_KNOWLEDGE, any, {
|
|
1448
|
+
documents: Array<{
|
|
1449
|
+
libCode: string;
|
|
1450
|
+
itemId: string;
|
|
1451
|
+
itemType: 'KNOWLEDGE';
|
|
1452
|
+
title: string;
|
|
1453
|
+
url: string;
|
|
1454
|
+
contentBody: string;
|
|
1455
|
+
}>;
|
|
1456
|
+
}>;
|
|
1457
|
+
export interface ReceivedSmartHomeSkillDevice {
|
|
1458
|
+
devId: string;
|
|
1459
|
+
devIcon: string;
|
|
1460
|
+
dps: Record<string, string>;
|
|
1461
|
+
devName: string;
|
|
1462
|
+
}
|
|
1463
|
+
export declare enum ReceivedSmartHomeSkillAction {
|
|
1464
|
+
CONTROL_DEVICE = "control_device"
|
|
1465
|
+
}
|
|
1466
|
+
export type ReceivedSmartHomeSkill = ReceivedTextSkillPacketBody<BuildInSkillCode.SEARCH_KNOWLEDGE, {
|
|
1467
|
+
data: {
|
|
1468
|
+
devices: ReceivedSmartHomeSkillDevice[];
|
|
1456
1469
|
};
|
|
1457
|
-
|
|
1470
|
+
action: ReceivedSmartHomeSkillAction;
|
|
1471
|
+
}, any>;
|
package/dist/AIStreamTypes.js
CHANGED
|
@@ -217,5 +217,10 @@ export let ReceivedTextPacketEof = /*#__PURE__*/function (ReceivedTextPacketEof)
|
|
|
217
217
|
}({});
|
|
218
218
|
export let BuildInSkillCode = /*#__PURE__*/function (BuildInSkillCode) {
|
|
219
219
|
BuildInSkillCode["SEARCH_KNOWLEDGE"] = "searchKnowledge";
|
|
220
|
+
BuildInSkillCode["SMART_HOME"] = "smart_home";
|
|
220
221
|
return BuildInSkillCode;
|
|
222
|
+
}({});
|
|
223
|
+
export let ReceivedSmartHomeSkillAction = /*#__PURE__*/function (ReceivedSmartHomeSkillAction) {
|
|
224
|
+
ReceivedSmartHomeSkillAction["CONTROL_DEVICE"] = "control_device";
|
|
225
|
+
return ReceivedSmartHomeSkillAction;
|
|
221
226
|
}({});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "core-js/modules/web.dom-collections.iterator.js";
|
|
2
2
|
import { getMiniAppConfig } from '../utils';
|
|
3
3
|
import logger from '../utils/logger';
|
|
4
|
-
import { BuildInSkillCode } from '../AIStreamTypes';
|
|
4
|
+
import { BuildInSkillCode, ReceivedSmartHomeSkillAction } from '../AIStreamTypes';
|
|
5
5
|
export function withBuildIn() {
|
|
6
6
|
return _agent => {
|
|
7
7
|
if (!_agent.plugins.aiStream || !_agent.plugins.ui) {
|
|
@@ -54,7 +54,7 @@ export function withBuildIn() {
|
|
|
54
54
|
if (skill.code !== BuildInSkillCode.SEARCH_KNOWLEDGE) {
|
|
55
55
|
continue;
|
|
56
56
|
}
|
|
57
|
-
const content = skill
|
|
57
|
+
const content = skill;
|
|
58
58
|
if (!((_content$custom = content.custom) !== null && _content$custom !== void 0 && _content$custom.documents)) {
|
|
59
59
|
continue;
|
|
60
60
|
}
|
|
@@ -70,6 +70,44 @@ export function withBuildIn() {
|
|
|
70
70
|
}
|
|
71
71
|
});
|
|
72
72
|
})();
|
|
73
|
+
(() => {
|
|
74
|
+
const intentMap = {
|
|
75
|
+
[ReceivedSmartHomeSkillAction.CONTROL_DEVICE]: 'controlDevice'
|
|
76
|
+
};
|
|
77
|
+
onSkillsEnd((skills, responseMessage) => {
|
|
78
|
+
if (!responseMessage) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const data = {
|
|
82
|
+
deviceInfo: [],
|
|
83
|
+
sceneInfo: [],
|
|
84
|
+
changeInfo: []
|
|
85
|
+
};
|
|
86
|
+
for (const skill of skills) {
|
|
87
|
+
var _content$general;
|
|
88
|
+
if (skill.code !== BuildInSkillCode.SMART_HOME) {
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
const content = skill;
|
|
92
|
+
if (!(content !== null && content !== void 0 && (_content$general = content.general) !== null && _content$general !== void 0 && (_content$general = _content$general.data) !== null && _content$general !== void 0 && (_content$general = _content$general.devices) !== null && _content$general !== void 0 && _content$general.length)) {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
const intent = intentMap[content.general.action] || 'controlDevice';
|
|
96
|
+
for (const dev of content.general.data.devices) {
|
|
97
|
+
data.deviceInfo.push({
|
|
98
|
+
icon: dev.devIcon,
|
|
99
|
+
name: dev.devName,
|
|
100
|
+
deviceId: dev.devId,
|
|
101
|
+
intent,
|
|
102
|
+
success: null
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (data.deviceInfo.length) {
|
|
107
|
+
responseMessage.bubble.addTile('operateCard', data);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
})();
|
|
73
111
|
return {};
|
|
74
112
|
};
|
|
75
113
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/t-agent-plugin-aistream",
|
|
3
|
-
"version": "0.2.0-beta-
|
|
3
|
+
"version": "0.2.0-beta-16",
|
|
4
4
|
"author": "Tuya.inc",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/url-parse": "^1.4.11"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "d9abc8e193dc1db6a7f9fca9ebeba2ff6462b713"
|
|
39
39
|
}
|