@ray-js/t-agent-plugin-aistream 0.2.0-beta-17 → 0.2.0-beta.18
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 +200 -38
- package/dist/AIStreamTypes.js +57 -20
- package/dist/buildIn/withBuildIn.js +50 -18
- package/dist/global.d.ts +1 -1
- package/dist/global.js +1 -1
- package/dist/utils/AIStream.d.ts +4 -3
- package/dist/utils/AIStream.js +117 -56
- package/dist/utils/createAsrAgent.d.ts +1 -1
- package/dist/utils/createAsrAgent.js +11 -10
- package/dist/utils/defaultMock.js +35 -28
- package/dist/utils/errors.d.ts +4 -11
- package/dist/utils/errors.js +77 -14
- package/dist/utils/sendMessage.d.ts +1 -4
- package/dist/utils/sendMessage.js +31 -48
- package/dist/utils/ttt.d.ts +10 -1
- package/dist/utils/ttt.js +7 -3
- package/dist/withAIStream.d.ts +2 -0
- package/dist/withAIStream.js +8 -3
- package/package.json +2 -2
package/dist/AIStreamTypes.d.ts
CHANGED
|
@@ -628,7 +628,9 @@ export declare enum EventType {
|
|
|
628
628
|
/** 聊天中断 */
|
|
629
629
|
CHAT_BREAK = 4,
|
|
630
630
|
/** 服务端 VAD */
|
|
631
|
-
SERVER_VAD = 5
|
|
631
|
+
SERVER_VAD = 5,
|
|
632
|
+
/** 服务端错误 */
|
|
633
|
+
SERVER_ERROR = 6
|
|
632
634
|
}
|
|
633
635
|
export declare enum StreamFlag {
|
|
634
636
|
/** 仅一包 */
|
|
@@ -655,19 +657,47 @@ export declare enum FileFormat {
|
|
|
655
657
|
SWEEPER_MAP = 6
|
|
656
658
|
}
|
|
657
659
|
export declare enum AIStreamErrorCode {
|
|
658
|
-
|
|
660
|
+
UNKNOWN_ERROR = "unknown-error",
|
|
661
|
+
NETWORK_OFFLINE = "network-offline",
|
|
662
|
+
INVALID_PARAMS = "invalid-params",
|
|
663
|
+
SESSION_CREATE_FAILED = "session-create-failed",
|
|
664
|
+
CONNECTION_CLOSED = "connection-closed",
|
|
665
|
+
EVENT_EXISTS = "event-exists",
|
|
666
|
+
EVENT_DISPOSED = "event-disposed",
|
|
667
|
+
EVENT_CLOSED = "event-closed",
|
|
668
|
+
EVENT_ABORTED = "event-aborted",
|
|
669
|
+
EVENT_WRITE_FAILED = "event-write-failed",
|
|
670
|
+
EVENT_NO_DATA_CODE = "event-no-data-code",
|
|
671
|
+
STREAM_EXISTS = "stream-exists",
|
|
672
|
+
TIMEOUT = "timeout",
|
|
673
|
+
ASR_EMPTY = "asr-empty"
|
|
674
|
+
}
|
|
675
|
+
export declare enum AIStreamAppErrorCode {
|
|
676
|
+
GENERIC_ERROR = 39001,
|
|
677
|
+
INVALID_PARAMS = 39002,
|
|
678
|
+
HTTP_REQUEST_FAILED = 39003,
|
|
679
|
+
CONNECTION_INVALID = 39004,
|
|
680
|
+
SESSION_ID_INVALID = 39005,
|
|
681
|
+
EVENT_ID_INVALID = 39006,
|
|
682
|
+
DATA_CHANNEL_NOT_FOUND = 39007,
|
|
683
|
+
INVALID_DATA_PACKET = 39008,
|
|
684
|
+
FILE_DATA_READ_ERROR = 39009,
|
|
685
|
+
DATA_SEND_FAILED = 39010,
|
|
686
|
+
CONNECTION_CLOSED_BY_REMOTE = 39012
|
|
687
|
+
}
|
|
688
|
+
export declare enum AIStreamServerErrorCode {
|
|
659
689
|
OK = 200,
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
690
|
+
BAD_REQUEST = 400,
|
|
691
|
+
UNAUTHENTICATED = 401,
|
|
692
|
+
NOT_FOUND = 404,
|
|
693
|
+
REQUEST_TIMEOUT = 408,
|
|
694
|
+
INTERNAL_SERVER_ERROR = 500,
|
|
695
|
+
GATEWAY_TIMEOUT = 504,
|
|
696
|
+
CLOSE_BY_CLIENT = 601,
|
|
697
|
+
CLOSE_BY_REUSE = 602,
|
|
698
|
+
CLOSE_BY_IO = 603,
|
|
699
|
+
CLOSE_BY_KEEPALIVE = 604,
|
|
700
|
+
CLOSE_BY_EXPIRE = 605
|
|
671
701
|
}
|
|
672
702
|
export declare enum BizCode {
|
|
673
703
|
CHAT = 65537
|
|
@@ -690,7 +720,9 @@ export type BizConfig = {
|
|
|
690
720
|
revData: string[];
|
|
691
721
|
};
|
|
692
722
|
export declare enum AIStreamAttributeType {
|
|
693
|
-
AI_CHAT = 1003
|
|
723
|
+
AI_CHAT = 1003,
|
|
724
|
+
ERROR_MESSAGE = 1006,
|
|
725
|
+
ERROR_CODE = 1007
|
|
694
726
|
}
|
|
695
727
|
export declare enum AIStreamAttributePayloadType {
|
|
696
728
|
U_INT8 = 1,
|
|
@@ -700,19 +732,65 @@ export declare enum AIStreamAttributePayloadType {
|
|
|
700
732
|
BYTES = 5,
|
|
701
733
|
STRING = 6
|
|
702
734
|
}
|
|
703
|
-
export declare enum AIStreamChatSysWorkflow {
|
|
704
|
-
ASR_LLM_TTS = "asr-llm-tts",
|
|
705
|
-
ASR_LLM = "asr-llm",
|
|
706
|
-
ASR = "asr",
|
|
707
|
-
LLM = "llm",
|
|
708
|
-
LLM_TTS = "llm-tts"
|
|
709
|
-
}
|
|
710
735
|
export interface AIStreamChatAttribute {
|
|
711
736
|
'asr.enableVad'?: 'true' | 'false';
|
|
712
737
|
'processing.interrupt'?: 'true' | 'false';
|
|
713
|
-
'sys.workflow'?: AIStreamChatSysWorkflow;
|
|
714
738
|
[key: string]: string;
|
|
715
739
|
}
|
|
740
|
+
export type StartPlayAudioParams = {
|
|
741
|
+
/** 音频缓存路径 */
|
|
742
|
+
path: string;
|
|
743
|
+
/**
|
|
744
|
+
* 音频编码类型,表示音频数据的编码格式(目前仅支持 PCM 播放)
|
|
745
|
+
* - 100: ADPCM
|
|
746
|
+
* - 101: PCM
|
|
747
|
+
* - 102: AACRaw
|
|
748
|
+
* - 103: AACADTS
|
|
749
|
+
* - 104: AACLATM
|
|
750
|
+
* - 105: G711U
|
|
751
|
+
* - 106: G711A
|
|
752
|
+
* - 107: G726
|
|
753
|
+
* - 108: SPEEX
|
|
754
|
+
* - 109: MP3
|
|
755
|
+
* - 110: G722
|
|
756
|
+
* - 111: Opus
|
|
757
|
+
*/
|
|
758
|
+
codecType: number;
|
|
759
|
+
/**
|
|
760
|
+
* 音频采样率,单位Hz
|
|
761
|
+
* 表示每秒采样次数,常见值:8000, 16000, 44100等
|
|
762
|
+
* 数据类型:uint32,最大值:2^32-1
|
|
763
|
+
*/
|
|
764
|
+
sampleRate: number;
|
|
765
|
+
/**
|
|
766
|
+
* 音频通道数
|
|
767
|
+
* - 0: 单声道
|
|
768
|
+
* - 1: 立体声
|
|
769
|
+
* 数据类型:uint16
|
|
770
|
+
*/
|
|
771
|
+
channels: number;
|
|
772
|
+
/**
|
|
773
|
+
* 音频位深,表示每个采样点的位数
|
|
774
|
+
* 常见值:8, 16, 24, 32等
|
|
775
|
+
* 数据类型:uint16,最大值:2^16-1
|
|
776
|
+
*/
|
|
777
|
+
bitDepth: number;
|
|
778
|
+
/**
|
|
779
|
+
* 微秒级时间戳
|
|
780
|
+
* 用于音频回放时的同步
|
|
781
|
+
*/
|
|
782
|
+
pts?: number;
|
|
783
|
+
success?: (params: null) => void;
|
|
784
|
+
fail?: (params: {
|
|
785
|
+
errorMsg: string;
|
|
786
|
+
errorCode: string | number;
|
|
787
|
+
innerError: {
|
|
788
|
+
errorCode: string | number;
|
|
789
|
+
errorMsg: string;
|
|
790
|
+
};
|
|
791
|
+
}) => void;
|
|
792
|
+
complete?: () => void;
|
|
793
|
+
};
|
|
716
794
|
export type Attribute = {
|
|
717
795
|
/** Attribute 类型 */
|
|
718
796
|
type: AIStreamAttributeType;
|
|
@@ -732,16 +810,57 @@ export type EventBody = {
|
|
|
732
810
|
userData?: Attribute[];
|
|
733
811
|
};
|
|
734
812
|
export type AudioBody = {
|
|
735
|
-
/** 接收数据通道 */
|
|
813
|
+
/** 接收数据通道 Code */
|
|
736
814
|
dataChannel: string;
|
|
737
815
|
/** 数据流类型: 0-仅一包, 1-传输开始, 2-传输中, 3-传输结束 */
|
|
738
|
-
streamFlag:
|
|
739
|
-
/**
|
|
816
|
+
streamFlag: number;
|
|
817
|
+
/** 音频缓存路径 */
|
|
740
818
|
path: string;
|
|
741
819
|
/** 扩展属性 */
|
|
742
820
|
userData?: Attribute[];
|
|
743
821
|
/** SessionId 列表, 云端返回,可能为空 */
|
|
744
822
|
sessionIdList?: string[];
|
|
823
|
+
/**
|
|
824
|
+
* 微秒级时间戳
|
|
825
|
+
* 用于音频回放时的同步
|
|
826
|
+
*/
|
|
827
|
+
pts?: number;
|
|
828
|
+
/**
|
|
829
|
+
* 音频编码类型,表示音频数据的编码格式
|
|
830
|
+
* - 100: ADPCM
|
|
831
|
+
* - 101: PCM
|
|
832
|
+
* - 102: AACRaw
|
|
833
|
+
* - 103: AACADTS
|
|
834
|
+
* - 104: AACLATM
|
|
835
|
+
* - 105: G711U
|
|
836
|
+
* - 106: G711A
|
|
837
|
+
* - 107: G726
|
|
838
|
+
* - 108: SPEEX
|
|
839
|
+
* - 109: MP3
|
|
840
|
+
* - 110: G722
|
|
841
|
+
* - 111: Opus
|
|
842
|
+
* 仅 streamFlag == 0 || == 1 时有值
|
|
843
|
+
*/
|
|
844
|
+
codecType?: number;
|
|
845
|
+
/**
|
|
846
|
+
* 音频采样率,单位Hz
|
|
847
|
+
* 表示每秒采样次数,常见值:8000, 16000, 44100等
|
|
848
|
+
* 仅 streamFlag == 0 || == 1 时有值
|
|
849
|
+
*/
|
|
850
|
+
sampleRate?: number;
|
|
851
|
+
/**
|
|
852
|
+
* 音频通道数
|
|
853
|
+
* - 0: 单声道
|
|
854
|
+
* - 1: 立体声
|
|
855
|
+
* 仅 streamFlag == 0 || == 1 时有值
|
|
856
|
+
*/
|
|
857
|
+
channels?: number;
|
|
858
|
+
/**
|
|
859
|
+
* 音频位深,表示每个采样点的位数
|
|
860
|
+
* 常见值:8, 16, 24, 32等
|
|
861
|
+
* 仅 streamFlag == 0 || == 1 时有值
|
|
862
|
+
*/
|
|
863
|
+
bitDepth?: number;
|
|
745
864
|
};
|
|
746
865
|
export type VideoBody = {
|
|
747
866
|
/** 接收数据通道 */
|
|
@@ -803,7 +922,7 @@ export type ConnectStateBody = {
|
|
|
803
922
|
/** 连接状态: 0-初始化,1-连接中,2-鉴权中,3-已连接,4-被云端断开,5-主动关闭 */
|
|
804
923
|
connectState: ConnectState;
|
|
805
924
|
/** 被云端断开错误码 */
|
|
806
|
-
code?:
|
|
925
|
+
code?: AIStreamServerErrorCode;
|
|
807
926
|
};
|
|
808
927
|
export type SessionStateBody = {
|
|
809
928
|
/** 会话 id */
|
|
@@ -811,12 +930,37 @@ export type SessionStateBody = {
|
|
|
811
930
|
/** 会话状态: 0-会话创建成功, 1-会话创建失败, 2-会话被云端关闭 */
|
|
812
931
|
sessionState: SessionState;
|
|
813
932
|
/** 会话被关闭原因 */
|
|
814
|
-
code?:
|
|
933
|
+
code?: AIStreamServerErrorCode;
|
|
815
934
|
};
|
|
816
935
|
export type RecordAmplitudesBody = {
|
|
817
936
|
/** 振幅数据 */
|
|
818
937
|
amplitudes: number[];
|
|
819
938
|
};
|
|
939
|
+
export declare enum NetworkType {
|
|
940
|
+
NONE = "none",
|
|
941
|
+
CELL_2G = "2g",
|
|
942
|
+
CELL_3G = "3g",
|
|
943
|
+
CELL_4G = "4g",
|
|
944
|
+
CELL_5G = "5g",
|
|
945
|
+
WIFI = "wifi"
|
|
946
|
+
}
|
|
947
|
+
export type GetNetworkTypeParams = {
|
|
948
|
+
complete?: () => void;
|
|
949
|
+
success?: (params: {
|
|
950
|
+
/** 网络类型 */
|
|
951
|
+
networkType: NetworkType;
|
|
952
|
+
/** 信号强弱,单位 dbm */
|
|
953
|
+
signalStrength: number;
|
|
954
|
+
}) => void;
|
|
955
|
+
fail?: (params: {
|
|
956
|
+
errorMsg: string;
|
|
957
|
+
errorCode: string | number;
|
|
958
|
+
innerError: {
|
|
959
|
+
errorCode: string | number;
|
|
960
|
+
errorMsg: string;
|
|
961
|
+
};
|
|
962
|
+
}) => void;
|
|
963
|
+
};
|
|
820
964
|
export type CheckConnectParams = {
|
|
821
965
|
/** client 类型: 1-作为设备代理, 2-作为 App */
|
|
822
966
|
clientType: ConnectClientType;
|
|
@@ -956,7 +1100,7 @@ export type CloseSessionParams = {
|
|
|
956
1100
|
/** 会话 id */
|
|
957
1101
|
sessionId: string;
|
|
958
1102
|
/** 关闭原因, 非异常则使用 200 来关闭 */
|
|
959
|
-
code:
|
|
1103
|
+
code: AIStreamServerErrorCode;
|
|
960
1104
|
success?: (params: null) => void;
|
|
961
1105
|
fail?: (params: {
|
|
962
1106
|
errorMsg: string;
|
|
@@ -1445,27 +1589,45 @@ export type ReceivedTextSkillPacketBody<Code = BuildInSkillCode | string, G = an
|
|
|
1445
1589
|
export type ReceivedTextSkillPacket<Code = BuildInSkillCode | string, G = any, C = any> = ReceivedTextPacketBase<ReceivedTextPacketType.SKILL, ReceivedTextSkillPacketBody<Code, G, C>>;
|
|
1446
1590
|
export type ReceivedTextPacket = ReceivedTextAsrPacket | ReceivedTextNlgPacket | ReceivedTextSkillPacket;
|
|
1447
1591
|
export type ReceivedSearchKnowledgeSkill = ReceivedTextSkillPacketBody<BuildInSkillCode.SEARCH_KNOWLEDGE, any, {
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1592
|
+
data: {
|
|
1593
|
+
documents: Array<{
|
|
1594
|
+
libCode: string;
|
|
1595
|
+
itemId: string;
|
|
1596
|
+
itemType: 'KNOWLEDGE';
|
|
1597
|
+
title: string;
|
|
1598
|
+
url: string;
|
|
1599
|
+
contentBody: string;
|
|
1600
|
+
}>;
|
|
1601
|
+
};
|
|
1456
1602
|
}>;
|
|
1457
1603
|
export interface ReceivedSmartHomeSkillDevice {
|
|
1458
1604
|
devId: string;
|
|
1459
1605
|
devIcon: string;
|
|
1460
|
-
dps
|
|
1606
|
+
dps?: Record<string, string>;
|
|
1461
1607
|
devName: string;
|
|
1608
|
+
room: string;
|
|
1609
|
+
success: boolean;
|
|
1610
|
+
}
|
|
1611
|
+
export interface ReceivedSmartHomeSkillScene {
|
|
1612
|
+
sceneId: string;
|
|
1613
|
+
sceneName: string;
|
|
1614
|
+
sceneIcon: string;
|
|
1615
|
+
type: number;
|
|
1616
|
+
valid: boolean;
|
|
1617
|
+
displayColor: string;
|
|
1618
|
+
enable?: boolean;
|
|
1619
|
+
success?: boolean;
|
|
1462
1620
|
}
|
|
1463
1621
|
export declare enum ReceivedSmartHomeSkillAction {
|
|
1464
|
-
|
|
1622
|
+
QUERY_DEVICE = "query_device",
|
|
1623
|
+
CONTROL_DEVICE = "control_device",
|
|
1624
|
+
QUERY_SCENE = "query_scene",
|
|
1625
|
+
CONTROL_SCENE = "control_scene"
|
|
1465
1626
|
}
|
|
1466
1627
|
export type ReceivedSmartHomeSkill = ReceivedTextSkillPacketBody<BuildInSkillCode.SEARCH_KNOWLEDGE, {
|
|
1467
1628
|
data: {
|
|
1468
1629
|
devices: ReceivedSmartHomeSkillDevice[];
|
|
1630
|
+
scenes: ReceivedSmartHomeSkillScene[];
|
|
1469
1631
|
};
|
|
1470
1632
|
action: ReceivedSmartHomeSkillAction;
|
|
1471
1633
|
}, any>;
|
package/dist/AIStreamTypes.js
CHANGED
|
@@ -99,6 +99,7 @@ export let EventType = /*#__PURE__*/function (EventType) {
|
|
|
99
99
|
EventType[EventType["ONE_SHOT"] = 3] = "ONE_SHOT";
|
|
100
100
|
EventType[EventType["CHAT_BREAK"] = 4] = "CHAT_BREAK";
|
|
101
101
|
EventType[EventType["SERVER_VAD"] = 5] = "SERVER_VAD";
|
|
102
|
+
EventType[EventType["SERVER_ERROR"] = 6] = "SERVER_ERROR";
|
|
102
103
|
return EventType;
|
|
103
104
|
}({});
|
|
104
105
|
export let StreamFlag = /*#__PURE__*/function (StreamFlag) {
|
|
@@ -118,21 +119,51 @@ export let FileFormat = /*#__PURE__*/function (FileFormat) {
|
|
|
118
119
|
return FileFormat;
|
|
119
120
|
}({});
|
|
120
121
|
export let AIStreamErrorCode = /*#__PURE__*/function (AIStreamErrorCode) {
|
|
121
|
-
AIStreamErrorCode[
|
|
122
|
-
AIStreamErrorCode[
|
|
123
|
-
AIStreamErrorCode[
|
|
124
|
-
AIStreamErrorCode[
|
|
125
|
-
AIStreamErrorCode[
|
|
126
|
-
AIStreamErrorCode[
|
|
127
|
-
AIStreamErrorCode[
|
|
128
|
-
AIStreamErrorCode[
|
|
129
|
-
AIStreamErrorCode[
|
|
130
|
-
AIStreamErrorCode[
|
|
131
|
-
AIStreamErrorCode[
|
|
132
|
-
AIStreamErrorCode[
|
|
133
|
-
AIStreamErrorCode[
|
|
122
|
+
AIStreamErrorCode["UNKNOWN_ERROR"] = "unknown-error";
|
|
123
|
+
AIStreamErrorCode["NETWORK_OFFLINE"] = "network-offline";
|
|
124
|
+
AIStreamErrorCode["INVALID_PARAMS"] = "invalid-params";
|
|
125
|
+
AIStreamErrorCode["SESSION_CREATE_FAILED"] = "session-create-failed";
|
|
126
|
+
AIStreamErrorCode["CONNECTION_CLOSED"] = "connection-closed";
|
|
127
|
+
AIStreamErrorCode["EVENT_EXISTS"] = "event-exists";
|
|
128
|
+
AIStreamErrorCode["EVENT_DISPOSED"] = "event-disposed";
|
|
129
|
+
AIStreamErrorCode["EVENT_CLOSED"] = "event-closed";
|
|
130
|
+
AIStreamErrorCode["EVENT_ABORTED"] = "event-aborted";
|
|
131
|
+
AIStreamErrorCode["EVENT_WRITE_FAILED"] = "event-write-failed";
|
|
132
|
+
AIStreamErrorCode["EVENT_NO_DATA_CODE"] = "event-no-data-code";
|
|
133
|
+
AIStreamErrorCode["STREAM_EXISTS"] = "stream-exists";
|
|
134
|
+
AIStreamErrorCode["TIMEOUT"] = "timeout";
|
|
135
|
+
AIStreamErrorCode["ASR_EMPTY"] = "asr-empty";
|
|
134
136
|
return AIStreamErrorCode;
|
|
135
137
|
}({});
|
|
138
|
+
export let AIStreamAppErrorCode = /*#__PURE__*/function (AIStreamAppErrorCode) {
|
|
139
|
+
AIStreamAppErrorCode[AIStreamAppErrorCode["GENERIC_ERROR"] = 39001] = "GENERIC_ERROR";
|
|
140
|
+
AIStreamAppErrorCode[AIStreamAppErrorCode["INVALID_PARAMS"] = 39002] = "INVALID_PARAMS";
|
|
141
|
+
AIStreamAppErrorCode[AIStreamAppErrorCode["HTTP_REQUEST_FAILED"] = 39003] = "HTTP_REQUEST_FAILED";
|
|
142
|
+
AIStreamAppErrorCode[AIStreamAppErrorCode["CONNECTION_INVALID"] = 39004] = "CONNECTION_INVALID";
|
|
143
|
+
AIStreamAppErrorCode[AIStreamAppErrorCode["SESSION_ID_INVALID"] = 39005] = "SESSION_ID_INVALID";
|
|
144
|
+
AIStreamAppErrorCode[AIStreamAppErrorCode["EVENT_ID_INVALID"] = 39006] = "EVENT_ID_INVALID";
|
|
145
|
+
AIStreamAppErrorCode[AIStreamAppErrorCode["DATA_CHANNEL_NOT_FOUND"] = 39007] = "DATA_CHANNEL_NOT_FOUND";
|
|
146
|
+
AIStreamAppErrorCode[AIStreamAppErrorCode["INVALID_DATA_PACKET"] = 39008] = "INVALID_DATA_PACKET";
|
|
147
|
+
AIStreamAppErrorCode[AIStreamAppErrorCode["FILE_DATA_READ_ERROR"] = 39009] = "FILE_DATA_READ_ERROR";
|
|
148
|
+
AIStreamAppErrorCode[AIStreamAppErrorCode["DATA_SEND_FAILED"] = 39010] = "DATA_SEND_FAILED";
|
|
149
|
+
AIStreamAppErrorCode[AIStreamAppErrorCode["CONNECTION_CLOSED_BY_REMOTE"] = 39012] = "CONNECTION_CLOSED_BY_REMOTE";
|
|
150
|
+
return AIStreamAppErrorCode;
|
|
151
|
+
}({});
|
|
152
|
+
export let AIStreamServerErrorCode = /*#__PURE__*/function (AIStreamServerErrorCode) {
|
|
153
|
+
AIStreamServerErrorCode[AIStreamServerErrorCode["OK"] = 200] = "OK";
|
|
154
|
+
AIStreamServerErrorCode[AIStreamServerErrorCode["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
|
155
|
+
AIStreamServerErrorCode[AIStreamServerErrorCode["UNAUTHENTICATED"] = 401] = "UNAUTHENTICATED";
|
|
156
|
+
AIStreamServerErrorCode[AIStreamServerErrorCode["NOT_FOUND"] = 404] = "NOT_FOUND";
|
|
157
|
+
AIStreamServerErrorCode[AIStreamServerErrorCode["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
|
|
158
|
+
AIStreamServerErrorCode[AIStreamServerErrorCode["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
|
|
159
|
+
AIStreamServerErrorCode[AIStreamServerErrorCode["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
|
|
160
|
+
AIStreamServerErrorCode[AIStreamServerErrorCode["CLOSE_BY_CLIENT"] = 601] = "CLOSE_BY_CLIENT";
|
|
161
|
+
AIStreamServerErrorCode[AIStreamServerErrorCode["CLOSE_BY_REUSE"] = 602] = "CLOSE_BY_REUSE";
|
|
162
|
+
AIStreamServerErrorCode[AIStreamServerErrorCode["CLOSE_BY_IO"] = 603] = "CLOSE_BY_IO";
|
|
163
|
+
AIStreamServerErrorCode[AIStreamServerErrorCode["CLOSE_BY_KEEPALIVE"] = 604] = "CLOSE_BY_KEEPALIVE";
|
|
164
|
+
AIStreamServerErrorCode[AIStreamServerErrorCode["CLOSE_BY_EXPIRE"] = 605] = "CLOSE_BY_EXPIRE";
|
|
165
|
+
return AIStreamServerErrorCode;
|
|
166
|
+
}({});
|
|
136
167
|
export let BizCode = /*#__PURE__*/function (BizCode) {
|
|
137
168
|
BizCode[BizCode["CHAT"] = 65537] = "CHAT";
|
|
138
169
|
return BizCode;
|
|
@@ -143,6 +174,8 @@ export let BizTag = /*#__PURE__*/function (BizTag) {
|
|
|
143
174
|
}({});
|
|
144
175
|
export let AIStreamAttributeType = /*#__PURE__*/function (AIStreamAttributeType) {
|
|
145
176
|
AIStreamAttributeType[AIStreamAttributeType["AI_CHAT"] = 1003] = "AI_CHAT";
|
|
177
|
+
AIStreamAttributeType[AIStreamAttributeType["ERROR_MESSAGE"] = 1006] = "ERROR_MESSAGE";
|
|
178
|
+
AIStreamAttributeType[AIStreamAttributeType["ERROR_CODE"] = 1007] = "ERROR_CODE";
|
|
146
179
|
return AIStreamAttributeType;
|
|
147
180
|
}({});
|
|
148
181
|
export let AIStreamAttributePayloadType = /*#__PURE__*/function (AIStreamAttributePayloadType) {
|
|
@@ -154,13 +187,14 @@ export let AIStreamAttributePayloadType = /*#__PURE__*/function (AIStreamAttribu
|
|
|
154
187
|
AIStreamAttributePayloadType[AIStreamAttributePayloadType["STRING"] = 6] = "STRING";
|
|
155
188
|
return AIStreamAttributePayloadType;
|
|
156
189
|
}({});
|
|
157
|
-
export let
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
190
|
+
export let NetworkType = /*#__PURE__*/function (NetworkType) {
|
|
191
|
+
NetworkType["NONE"] = "none";
|
|
192
|
+
NetworkType["CELL_2G"] = "2g";
|
|
193
|
+
NetworkType["CELL_3G"] = "3g";
|
|
194
|
+
NetworkType["CELL_4G"] = "4g";
|
|
195
|
+
NetworkType["CELL_5G"] = "5g";
|
|
196
|
+
NetworkType["WIFI"] = "wifi";
|
|
197
|
+
return NetworkType;
|
|
164
198
|
}({});
|
|
165
199
|
|
|
166
200
|
/**
|
|
@@ -221,6 +255,9 @@ export let BuildInSkillCode = /*#__PURE__*/function (BuildInSkillCode) {
|
|
|
221
255
|
return BuildInSkillCode;
|
|
222
256
|
}({});
|
|
223
257
|
export let ReceivedSmartHomeSkillAction = /*#__PURE__*/function (ReceivedSmartHomeSkillAction) {
|
|
258
|
+
ReceivedSmartHomeSkillAction["QUERY_DEVICE"] = "query_device";
|
|
224
259
|
ReceivedSmartHomeSkillAction["CONTROL_DEVICE"] = "control_device";
|
|
260
|
+
ReceivedSmartHomeSkillAction["QUERY_SCENE"] = "query_scene";
|
|
261
|
+
ReceivedSmartHomeSkillAction["CONTROL_SCENE"] = "control_scene";
|
|
225
262
|
return ReceivedSmartHomeSkillAction;
|
|
226
263
|
}({});
|
|
@@ -55,10 +55,10 @@ export function withBuildIn() {
|
|
|
55
55
|
continue;
|
|
56
56
|
}
|
|
57
57
|
const content = skill;
|
|
58
|
-
if (!((_content$custom = content.custom) !== null && _content$custom !== void 0 && _content$custom.documents)) {
|
|
58
|
+
if (!((_content$custom = content.custom) !== null && _content$custom !== void 0 && (_content$custom = _content$custom.data) !== null && _content$custom !== void 0 && _content$custom.documents)) {
|
|
59
59
|
continue;
|
|
60
60
|
}
|
|
61
|
-
for (const doc of content.custom.documents) {
|
|
61
|
+
for (const doc of content.custom.data.documents) {
|
|
62
62
|
data.documents.push({
|
|
63
63
|
title: doc.title,
|
|
64
64
|
url: doc.url
|
|
@@ -71,9 +71,6 @@ export function withBuildIn() {
|
|
|
71
71
|
});
|
|
72
72
|
})();
|
|
73
73
|
(() => {
|
|
74
|
-
const intentMap = {
|
|
75
|
-
[ReceivedSmartHomeSkillAction.CONTROL_DEVICE]: 'controlDevice'
|
|
76
|
-
};
|
|
77
74
|
onSkillsEnd((skills, responseMessage) => {
|
|
78
75
|
if (!responseMessage) {
|
|
79
76
|
return;
|
|
@@ -84,23 +81,58 @@ export function withBuildIn() {
|
|
|
84
81
|
changeInfo: []
|
|
85
82
|
};
|
|
86
83
|
for (const skill of skills) {
|
|
87
|
-
var _content$general;
|
|
88
84
|
if (skill.code !== BuildInSkillCode.SMART_HOME) {
|
|
89
85
|
continue;
|
|
90
86
|
}
|
|
91
87
|
const content = skill;
|
|
92
|
-
if (
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
88
|
+
if (content.general.action === ReceivedSmartHomeSkillAction.QUERY_SCENE) {
|
|
89
|
+
for (const scene of content.general.data.scenes) {
|
|
90
|
+
data.sceneInfo.push({
|
|
91
|
+
type: scene.type,
|
|
92
|
+
enabled: scene.enable,
|
|
93
|
+
icon: scene.sceneIcon,
|
|
94
|
+
name: scene.sceneName,
|
|
95
|
+
sceneId: scene.sceneId,
|
|
96
|
+
intent: 'queryScene',
|
|
97
|
+
valid: scene.valid,
|
|
98
|
+
displayColor: scene.displayColor,
|
|
99
|
+
success: null
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
} else if (content.general.action === ReceivedSmartHomeSkillAction.CONTROL_SCENE) {
|
|
103
|
+
for (const scene of content.general.data.scenes) {
|
|
104
|
+
data.sceneInfo.push({
|
|
105
|
+
type: scene.type,
|
|
106
|
+
icon: scene.sceneIcon,
|
|
107
|
+
name: scene.sceneName,
|
|
108
|
+
sceneId: scene.sceneId,
|
|
109
|
+
intent: 'controlScene',
|
|
110
|
+
valid: scene.valid,
|
|
111
|
+
displayColor: scene.displayColor,
|
|
112
|
+
success: scene.success
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
} else if (content.general.action === ReceivedSmartHomeSkillAction.QUERY_DEVICE) {
|
|
116
|
+
for (const dev of content.general.data.devices) {
|
|
117
|
+
data.deviceInfo.push({
|
|
118
|
+
icon: dev.devIcon,
|
|
119
|
+
name: dev.devName,
|
|
120
|
+
deviceId: dev.devId,
|
|
121
|
+
intent: 'queryDevice',
|
|
122
|
+
room: dev.room,
|
|
123
|
+
success: dev.success
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
} else if (content.general.action === ReceivedSmartHomeSkillAction.CONTROL_DEVICE) {
|
|
127
|
+
for (const dev of content.general.data.devices) {
|
|
128
|
+
data.deviceInfo.push({
|
|
129
|
+
icon: dev.devIcon,
|
|
130
|
+
name: dev.devName,
|
|
131
|
+
deviceId: dev.devId,
|
|
132
|
+
intent: 'controlDevice',
|
|
133
|
+
success: null
|
|
134
|
+
});
|
|
135
|
+
}
|
|
104
136
|
}
|
|
105
137
|
}
|
|
106
138
|
if (data.deviceInfo.length) {
|
package/dist/global.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { AIStreamClient } from './utils';
|
|
2
2
|
export declare const globalAIStreamClient: AIStreamClient;
|
|
3
|
-
export declare const DEFAULT_TOKEN_API = "m.
|
|
3
|
+
export declare const DEFAULT_TOKEN_API = "m.life.ai.token.get";
|
|
4
4
|
export declare const DEFAULT_TOKEN_API_VERSION = "1.0";
|
package/dist/global.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { AIStreamClient } from './utils';
|
|
2
2
|
export const globalAIStreamClient = new AIStreamClient();
|
|
3
|
-
export const DEFAULT_TOKEN_API = 'm.
|
|
3
|
+
export const DEFAULT_TOKEN_API = 'm.life.ai.token.get';
|
|
4
4
|
export const DEFAULT_TOKEN_API_VERSION = '1.0';
|
package/dist/utils/AIStream.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Attribute, BizTag, ConnectClientType, ConnectState, FileFormat, VideoCameraType } from '../AIStreamTypes';
|
|
2
2
|
import { AIStreamDataEntry, AIStreamObserverPool } from './observer';
|
|
3
|
+
import { AIStreamError } from './errors';
|
|
3
4
|
interface AIStreamConnectionOptions {
|
|
4
5
|
/** client 类型: 1-作为设备代理, 2-作为 App */
|
|
5
6
|
clientType: ConnectClientType;
|
|
@@ -124,15 +125,15 @@ export declare class AIStreamEvent {
|
|
|
124
125
|
}): void;
|
|
125
126
|
on(name: 'close', callback: () => void): void;
|
|
126
127
|
on(name: 'finish', callback: () => void): void;
|
|
127
|
-
on(name: 'error', callback: (error:
|
|
128
|
+
on(name: 'error', callback: (error: AIStreamError) => void): void;
|
|
128
129
|
on(name: 'data', callback: (entry: AIStreamDataEntry) => void): void;
|
|
129
130
|
off(name: 'finish', callback: () => void): void;
|
|
130
131
|
off(name: 'close', callback: () => void): void;
|
|
131
|
-
off(name: 'error', callback: (error:
|
|
132
|
+
off(name: 'error', callback: (error: AIStreamError) => void): void;
|
|
132
133
|
off(name: 'data', callback: (entry: AIStreamDataEntry) => void): void;
|
|
133
134
|
emit(name: 'finish'): void;
|
|
134
135
|
emit(name: 'close'): void;
|
|
135
|
-
emit(name: 'error', data:
|
|
136
|
+
emit(name: 'error', data: AIStreamError): void;
|
|
136
137
|
emit(name: 'data', data: AIStreamDataEntry): void;
|
|
137
138
|
private dispose;
|
|
138
139
|
}
|