@ray-js/t-agent-plugin-aistream 0.2.0-beta.18 → 0.2.0-beta.20
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 +5 -5
- package/dist/buildIn/withBuildIn.js +10 -10
- package/dist/utils/observer.d.ts +1 -5
- package/dist/utils/observer.js +14 -21
- package/dist/withAIStream.js +2 -20
- package/package.json +2 -2
package/dist/AIStreamTypes.d.ts
CHANGED
|
@@ -1601,17 +1601,17 @@ export type ReceivedSearchKnowledgeSkill = ReceivedTextSkillPacketBody<BuildInSk
|
|
|
1601
1601
|
};
|
|
1602
1602
|
}>;
|
|
1603
1603
|
export interface ReceivedSmartHomeSkillDevice {
|
|
1604
|
-
|
|
1605
|
-
|
|
1604
|
+
deviceId: string;
|
|
1605
|
+
icon: string;
|
|
1606
1606
|
dps?: Record<string, string>;
|
|
1607
|
-
|
|
1607
|
+
name: string;
|
|
1608
1608
|
room: string;
|
|
1609
1609
|
success: boolean;
|
|
1610
1610
|
}
|
|
1611
1611
|
export interface ReceivedSmartHomeSkillScene {
|
|
1612
1612
|
sceneId: string;
|
|
1613
|
-
|
|
1614
|
-
|
|
1613
|
+
name: string;
|
|
1614
|
+
icon: string;
|
|
1615
1615
|
type: number;
|
|
1616
1616
|
valid: boolean;
|
|
1617
1617
|
displayColor: string;
|
|
@@ -90,8 +90,8 @@ export function withBuildIn() {
|
|
|
90
90
|
data.sceneInfo.push({
|
|
91
91
|
type: scene.type,
|
|
92
92
|
enabled: scene.enable,
|
|
93
|
-
icon: scene.
|
|
94
|
-
name: scene.
|
|
93
|
+
icon: scene.icon,
|
|
94
|
+
name: scene.name,
|
|
95
95
|
sceneId: scene.sceneId,
|
|
96
96
|
intent: 'queryScene',
|
|
97
97
|
valid: scene.valid,
|
|
@@ -103,8 +103,8 @@ export function withBuildIn() {
|
|
|
103
103
|
for (const scene of content.general.data.scenes) {
|
|
104
104
|
data.sceneInfo.push({
|
|
105
105
|
type: scene.type,
|
|
106
|
-
icon: scene.
|
|
107
|
-
name: scene.
|
|
106
|
+
icon: scene.icon,
|
|
107
|
+
name: scene.name,
|
|
108
108
|
sceneId: scene.sceneId,
|
|
109
109
|
intent: 'controlScene',
|
|
110
110
|
valid: scene.valid,
|
|
@@ -115,9 +115,9 @@ export function withBuildIn() {
|
|
|
115
115
|
} else if (content.general.action === ReceivedSmartHomeSkillAction.QUERY_DEVICE) {
|
|
116
116
|
for (const dev of content.general.data.devices) {
|
|
117
117
|
data.deviceInfo.push({
|
|
118
|
-
icon: dev.
|
|
119
|
-
name: dev.
|
|
120
|
-
deviceId: dev.
|
|
118
|
+
icon: dev.icon,
|
|
119
|
+
name: dev.name,
|
|
120
|
+
deviceId: dev.deviceId,
|
|
121
121
|
intent: 'queryDevice',
|
|
122
122
|
room: dev.room,
|
|
123
123
|
success: dev.success
|
|
@@ -126,9 +126,9 @@ export function withBuildIn() {
|
|
|
126
126
|
} else if (content.general.action === ReceivedSmartHomeSkillAction.CONTROL_DEVICE) {
|
|
127
127
|
for (const dev of content.general.data.devices) {
|
|
128
128
|
data.deviceInfo.push({
|
|
129
|
-
icon: dev.
|
|
130
|
-
name: dev.
|
|
131
|
-
deviceId: dev.
|
|
129
|
+
icon: dev.icon,
|
|
130
|
+
name: dev.name,
|
|
131
|
+
deviceId: dev.deviceId,
|
|
132
132
|
intent: 'controlDevice',
|
|
133
133
|
success: null
|
|
134
134
|
});
|
package/dist/utils/observer.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AudioBody, ConnectStateBody, EventBody, FileBody, ImageBody,
|
|
1
|
+
import { AudioBody, ConnectStateBody, EventBody, FileBody, ImageBody, SessionStateBody, TextBody, VideoBody } from '../AIStreamTypes';
|
|
2
2
|
export type AIStreamDataEntry = {
|
|
3
3
|
type: 'text';
|
|
4
4
|
body: TextBody;
|
|
@@ -23,9 +23,6 @@ export type AIStreamDataEntry = {
|
|
|
23
23
|
} | {
|
|
24
24
|
type: 'sessionState';
|
|
25
25
|
body: SessionStateBody;
|
|
26
|
-
} | {
|
|
27
|
-
type: 'amplitudes';
|
|
28
|
-
body: RecordAmplitudesBody;
|
|
29
26
|
};
|
|
30
27
|
export interface AIStreamObserverOptions {
|
|
31
28
|
sessionState?: boolean;
|
|
@@ -38,7 +35,6 @@ export interface AIStreamObserverOptions {
|
|
|
38
35
|
image?: boolean;
|
|
39
36
|
dataChannels?: string[];
|
|
40
37
|
sessionId?: string;
|
|
41
|
-
amplitudes?: boolean;
|
|
42
38
|
}
|
|
43
39
|
export declare class AIStreamObserverPool {
|
|
44
40
|
isStarted: boolean;
|
package/dist/utils/observer.js
CHANGED
|
@@ -3,9 +3,9 @@ import "core-js/modules/esnext.iterator.constructor.js";
|
|
|
3
3
|
import "core-js/modules/esnext.iterator.for-each.js";
|
|
4
4
|
import "core-js/modules/web.dom-collections.iterator.js";
|
|
5
5
|
import { ConnectState, EventType, SessionState, StreamFlag } from '../AIStreamTypes';
|
|
6
|
-
import { listenAudioReceived, listenConnectStateChanged, listenEventReceived, listenImageReceived,
|
|
6
|
+
import { listenAudioReceived, listenConnectStateChanged, listenEventReceived, listenImageReceived, listenSessionStateChanged, listenTextReceived } from './ttt';
|
|
7
7
|
import logger from './logger';
|
|
8
|
-
const types = ['connectionState', 'sessionState', 'event', 'text', 'audio', 'video', 'file', 'image'
|
|
8
|
+
const types = ['connectionState', 'sessionState', 'event', 'text', 'audio', 'video', 'file', 'image'];
|
|
9
9
|
export class AIStreamObserverPool {
|
|
10
10
|
constructor() {
|
|
11
11
|
_defineProperty(this, "isStarted", false);
|
|
@@ -18,8 +18,7 @@ export class AIStreamObserverPool {
|
|
|
18
18
|
audio: new Set(),
|
|
19
19
|
video: new Set(),
|
|
20
20
|
file: new Set(),
|
|
21
|
-
image: new Set()
|
|
22
|
-
amplitudes: new Set()
|
|
21
|
+
image: new Set()
|
|
23
22
|
};
|
|
24
23
|
}
|
|
25
24
|
start() {
|
|
@@ -27,21 +26,19 @@ export class AIStreamObserverPool {
|
|
|
27
26
|
return;
|
|
28
27
|
}
|
|
29
28
|
const handle = entry => {
|
|
29
|
+
var _entry$body;
|
|
30
30
|
const observers = this.observerMap[entry.type];
|
|
31
31
|
let state = '';
|
|
32
|
-
if (entry.type
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
} else if ((_entry$body = entry.body) !== null && _entry$body !== void 0 && _entry$body.streamFlag) {
|
|
41
|
-
state = "".concat(StreamFlag[entry.body.streamFlag]);
|
|
42
|
-
}
|
|
43
|
-
logger.debug("Pool received: %c".concat(observers.size ? '⊕' : '×').concat(entry.type, " ").concat(state), 'background: black; color: white', entry);
|
|
32
|
+
if (entry.type === 'connectionState') {
|
|
33
|
+
state = "".concat(ConnectState[entry.body.connectState], " ").concat(entry.body.code || '');
|
|
34
|
+
} else if (entry.type === 'sessionState') {
|
|
35
|
+
state = "".concat(SessionState[entry.body.sessionState], " ").concat(entry.body.code || '');
|
|
36
|
+
} else if (entry.type === 'event') {
|
|
37
|
+
state = "".concat(EventType[entry.body.eventType]);
|
|
38
|
+
} else if ((_entry$body = entry.body) !== null && _entry$body !== void 0 && _entry$body.streamFlag) {
|
|
39
|
+
state = "".concat(StreamFlag[entry.body.streamFlag]);
|
|
44
40
|
}
|
|
41
|
+
logger.debug("Pool received: %c".concat(observers.size ? '⊕' : '×').concat(entry.type, " ").concat(state), 'background: black; color: white', entry);
|
|
45
42
|
observers.forEach(observer => {
|
|
46
43
|
if (entry.type === 'text' || entry.type === 'audio' || entry.type === 'video' || entry.type === 'file' || entry.type === 'image') {
|
|
47
44
|
const {
|
|
@@ -81,9 +78,6 @@ export class AIStreamObserverPool {
|
|
|
81
78
|
})), listenImageReceived(body => handle({
|
|
82
79
|
type: 'image',
|
|
83
80
|
body
|
|
84
|
-
})), listenRecordAmplitudes(body => handle({
|
|
85
|
-
type: 'amplitudes',
|
|
86
|
-
body
|
|
87
81
|
}))
|
|
88
82
|
// listenVideoReceived(body => handle({ type: 'video', body })),
|
|
89
83
|
// listenFileReceived(body => handle({ type: 'file', body })),
|
|
@@ -102,8 +96,7 @@ export class AIStreamObserverPool {
|
|
|
102
96
|
audio: new Set(),
|
|
103
97
|
video: new Set(),
|
|
104
98
|
file: new Set(),
|
|
105
|
-
image: new Set()
|
|
106
|
-
amplitudes: new Set()
|
|
99
|
+
image: new Set()
|
|
107
100
|
};
|
|
108
101
|
}
|
|
109
102
|
connect(observer) {
|
package/dist/withAIStream.js
CHANGED
|
@@ -9,8 +9,8 @@ import "core-js/modules/esnext.iterator.map.js";
|
|
|
9
9
|
import "core-js/modules/web.dom-collections.iterator.js";
|
|
10
10
|
import { BubbleTileStatus, ChatMessageStatus, createHooks, EmitterEvent } from '@ray-js/t-agent';
|
|
11
11
|
import { messageAppraise } from './utils/apis';
|
|
12
|
-
import {
|
|
13
|
-
import { BizCode, ConnectClientType
|
|
12
|
+
import { getAccountInfo, getCurrentHomeInfo, runTTTAction, sendBlocksToAIStream } from './utils';
|
|
13
|
+
import { BizCode, ConnectClientType } from './AIStreamTypes';
|
|
14
14
|
import { ChatHistoryLocalStore } from './ChatHistoryStore';
|
|
15
15
|
import { DEFAULT_TOKEN_API, DEFAULT_TOKEN_API_VERSION, globalAIStreamClient } from './global';
|
|
16
16
|
import logger from './utils/logger';
|
|
@@ -110,20 +110,6 @@ export function withAIStream() {
|
|
|
110
110
|
logger.error('earlyStart failed', error);
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
|
-
const observer = new AIStreamObserver(data => {
|
|
114
|
-
if (data.type === 'amplitudes') {
|
|
115
|
-
ui.emitEvent('amplitudes', data);
|
|
116
|
-
} else if (data.type === 'connectionState') {
|
|
117
|
-
ui.emitEvent('networkChange', {
|
|
118
|
-
online: data.body.connectState === ConnectState.CONNECTED
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
}, globalAIStreamClient.pool);
|
|
122
|
-
observer.observe({
|
|
123
|
-
connectionState: true,
|
|
124
|
-
amplitudes: true
|
|
125
|
-
});
|
|
126
|
-
await session.set('AIStream.observer', observer);
|
|
127
113
|
});
|
|
128
114
|
const getHistoryStore = () => {
|
|
129
115
|
const historyStore = session.get('AIStream.historyStore');
|
|
@@ -405,10 +391,6 @@ export function withAIStream() {
|
|
|
405
391
|
};
|
|
406
392
|
});
|
|
407
393
|
onAgentDispose(async () => {
|
|
408
|
-
const observer = session.get('AIStream.observer');
|
|
409
|
-
if (observer) {
|
|
410
|
-
observer.disconnect();
|
|
411
|
-
}
|
|
412
394
|
const streamSession = session.get('AIStream.streamSession');
|
|
413
395
|
|
|
414
396
|
/**
|
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.20",
|
|
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": "517ce9d6aec8ac6a1ade692df773750d0c7738cf"
|
|
39
39
|
}
|