@ray-js/t-agent-plugin-aistream 0.2.8-beta.6 → 0.2.8-beta.8
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
CHANGED
|
@@ -704,7 +704,8 @@ export declare enum AIStreamAppErrorCode {
|
|
|
704
704
|
DATA_SEND_FAILED = 39010,// 发送数据失败
|
|
705
705
|
CONNECTION_CLOSED_BY_REMOTE = 39012,// Connection 被远端关闭
|
|
706
706
|
AUDIO_UNEXPECTEDLY_RESET = 39014,// 音频组件被重置
|
|
707
|
-
RECONNECT = 39016
|
|
707
|
+
RECONNECT = 39016,// 内部重连中
|
|
708
|
+
AUDIO_PACKET_INVALID = 39017
|
|
708
709
|
}
|
|
709
710
|
export declare enum AIStreamServerErrorCode {
|
|
710
711
|
OK = 200,
|
|
@@ -892,6 +893,10 @@ export type AudioBody = {
|
|
|
892
893
|
* 仅 streamFlag == 0 || == 1 时有值
|
|
893
894
|
*/
|
|
894
895
|
bitDepth?: number;
|
|
896
|
+
/**
|
|
897
|
+
* 错误码 仅最后一包时才有
|
|
898
|
+
*/
|
|
899
|
+
errorCode?: AIStreamAppErrorCode;
|
|
895
900
|
};
|
|
896
901
|
export declare enum AudioPlayChangedState {
|
|
897
902
|
/** 播放开始 */
|
package/dist/AIStreamTypes.js
CHANGED
|
@@ -150,6 +150,7 @@ export let AIStreamAppErrorCode = /*#__PURE__*/function (AIStreamAppErrorCode) {
|
|
|
150
150
|
AIStreamAppErrorCode[AIStreamAppErrorCode["CONNECTION_CLOSED_BY_REMOTE"] = 39012] = "CONNECTION_CLOSED_BY_REMOTE";
|
|
151
151
|
AIStreamAppErrorCode[AIStreamAppErrorCode["AUDIO_UNEXPECTEDLY_RESET"] = 39014] = "AUDIO_UNEXPECTEDLY_RESET";
|
|
152
152
|
AIStreamAppErrorCode[AIStreamAppErrorCode["RECONNECT"] = 39016] = "RECONNECT";
|
|
153
|
+
AIStreamAppErrorCode[AIStreamAppErrorCode["AUDIO_PACKET_INVALID"] = 39017] = "AUDIO_PACKET_INVALID";
|
|
153
154
|
return AIStreamAppErrorCode;
|
|
154
155
|
}({});
|
|
155
156
|
export let AIStreamServerErrorCode = /*#__PURE__*/function (AIStreamServerErrorCode) {
|
|
@@ -3,6 +3,7 @@ import "core-js/modules/esnext.iterator.for-each.js";
|
|
|
3
3
|
import "core-js/modules/web.dom-collections.iterator.js";
|
|
4
4
|
import { AudioPlayChangedState, BuildInSkillCode, ReceivedSmartHomeSkillAction, StreamFlag } from '../AIStreamTypes';
|
|
5
5
|
import { listenAudioPlayChanged, startPlayAudio, stopPlayAudio } from '../utils';
|
|
6
|
+
import logger from '../utils/logger';
|
|
6
7
|
|
|
7
8
|
/** 用于驱动 BubbleToolTile 播放的音频参数 */
|
|
8
9
|
|
|
@@ -154,7 +155,7 @@ export function withBuildIn(options) {
|
|
|
154
155
|
parts.forEach(i => {
|
|
155
156
|
if (i.attachmentType === 'image') {
|
|
156
157
|
const d = i.attachment;
|
|
157
|
-
if (d.streamFlag === StreamFlag.ONLY_ONE || d.streamFlag === StreamFlag.
|
|
158
|
+
if (d.streamFlag === StreamFlag.ONLY_ONE || d.streamFlag === StreamFlag.START || d.streamFlag === StreamFlag.IN_PROGRESS) {
|
|
158
159
|
respMsg.addTile('image', {
|
|
159
160
|
src: "".concat(prefix).concat(d.path)
|
|
160
161
|
});
|
|
@@ -198,16 +199,21 @@ export function withBuildIn(options) {
|
|
|
198
199
|
// 推送新的输入块(发送新消息)时,立即停止当前语音播放
|
|
199
200
|
onInputBlocksPush(() => {
|
|
200
201
|
stopCurrent();
|
|
201
|
-
});
|
|
202
|
-
onAttachmentCompose((part, respMsg) => {
|
|
202
|
+
}, 'before');
|
|
203
|
+
onAttachmentCompose(async (part, respMsg) => {
|
|
203
204
|
if (part.attachmentType === 'audio') {
|
|
204
205
|
const audio = part.attachment;
|
|
205
206
|
if (audio.streamFlag === StreamFlag.START) {
|
|
206
207
|
const audioAutoPlay = !!session.get('AIStream.audioAutoPlay');
|
|
207
208
|
if (audioAutoPlay) {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
209
|
+
try {
|
|
210
|
+
var _respMsg$id;
|
|
211
|
+
// 播放可能失败,这是正常的,忽略
|
|
212
|
+
await startPlayAudio(audio);
|
|
213
|
+
setPlayingMessage((_respMsg$id = respMsg === null || respMsg === void 0 ? void 0 : respMsg.id) !== null && _respMsg$id !== void 0 ? _respMsg$id : null);
|
|
214
|
+
} catch (e) {
|
|
215
|
+
logger.warn('withBuildIn startPlayAudio failed', e);
|
|
216
|
+
}
|
|
211
217
|
}
|
|
212
218
|
}
|
|
213
219
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/t-agent-plugin-aistream",
|
|
3
|
-
"version": "0.2.8-beta.
|
|
3
|
+
"version": "0.2.8-beta.8",
|
|
4
4
|
"author": "Tuya.inc",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/url-parse": "^1.4.11"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "98ec699238fdf0f1ad9c4404e46d0dca5583cebe"
|
|
40
40
|
}
|