@coze/realtime-api 1.3.1 → 1.3.2
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/cjs/index.js +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/types/event-names/index.d.ts +2 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/live/index.d.ts +139 -60
- package/dist/umd/index.js +1 -0
- package/package.json +2 -2
package/dist/cjs/index.js
CHANGED
|
@@ -702,6 +702,7 @@ class RealtimeClient extends RealtimeEventHandler {
|
|
|
702
702
|
};
|
|
703
703
|
}
|
|
704
704
|
if (this._config.translateConfig) config.translate_config = this._config.translateConfig;
|
|
705
|
+
if (this._config.turnDetection) config.turn_detection = this._config.turnDetection;
|
|
705
706
|
const params = {
|
|
706
707
|
bot_id: botId,
|
|
707
708
|
conversation_id: conversationId || void 0,
|
package/dist/esm/index.js
CHANGED
|
@@ -673,6 +673,7 @@ class RealtimeClient extends RealtimeEventHandler {
|
|
|
673
673
|
};
|
|
674
674
|
}
|
|
675
675
|
if (this._config.translateConfig) config.translate_config = this._config.translateConfig;
|
|
676
|
+
if (this._config.turnDetection) config.turn_detection = this._config.turnDetection;
|
|
676
677
|
const params = {
|
|
677
678
|
bot_id: botId,
|
|
678
679
|
conversation_id: conversationId || void 0,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ScreenConfig, type AudioPropertiesConfig, type IRTCEngine } from '@volcengine/rtc';
|
|
2
|
-
import { RoomMode, type CreateRoomData, type GetToken, type TranslateConfig } from '@coze/api';
|
|
2
|
+
import { RoomMode, type CreateRoomData, type GetToken, type TranslateConfig, type CreateRoomTurnDetection } from '@coze/api';
|
|
3
3
|
import * as RealtimeUtils from './utils';
|
|
4
4
|
import EventNames from './event-names';
|
|
5
5
|
import { RealtimeEventHandler } from './event-handler';
|
|
@@ -33,6 +33,7 @@ export interface RealtimeClientConfig {
|
|
|
33
33
|
prologueContent?: string /** optional, Prologue content */;
|
|
34
34
|
roomMode?: RoomMode /** optional, Room mode */;
|
|
35
35
|
translateConfig?: TranslateConfig /** optional, Translation configuration */;
|
|
36
|
+
turnDetection?: CreateRoomTurnDetection /** optional, Turn detection */;
|
|
36
37
|
}
|
|
37
38
|
declare class RealtimeClient extends RealtimeEventHandler {
|
|
38
39
|
_config: RealtimeClientConfig;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ScreenConfig, type AudioPropertiesConfig, type IRTCEngine } from '@volcengine/rtc';
|
|
2
|
-
import { RoomMode, type CreateRoomData, type GetToken, type TranslateConfig } from '@coze/api';
|
|
2
|
+
import { RoomMode, type CreateRoomData, type GetToken, type TranslateConfig, type CreateRoomTurnDetection } from '@coze/api';
|
|
3
3
|
import * as RealtimeUtils from './utils';
|
|
4
4
|
import EventNames from './event-names';
|
|
5
5
|
import { RealtimeEventHandler } from './event-handler';
|
|
@@ -33,6 +33,7 @@ export interface RealtimeClientConfig {
|
|
|
33
33
|
prologueContent?: string /** optional, Prologue content */;
|
|
34
34
|
roomMode?: RoomMode /** optional, Room mode */;
|
|
35
35
|
translateConfig?: TranslateConfig /** optional, Translation configuration */;
|
|
36
|
+
turnDetection?: CreateRoomTurnDetection /** optional, Turn detection */;
|
|
36
37
|
}
|
|
37
38
|
declare class RealtimeClient extends RealtimeEventHandler {
|
|
38
39
|
_config: RealtimeClientConfig;
|
|
@@ -1,86 +1,165 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { type ScreenConfig, type AudioPropertiesConfig, type IRTCEngine } from '@volcengine/rtc';
|
|
2
|
+
import { RoomMode, type CreateRoomData, type GetToken, type TranslateConfig, type CreateRoomTurnDetection } from '@coze/api';
|
|
3
|
+
import * as RealtimeUtils from './utils';
|
|
4
|
+
import EventNames from './event-names';
|
|
5
|
+
import { RealtimeEventHandler } from './event-handler';
|
|
6
|
+
import { RealtimeAPIError, RealtimeError } from './error';
|
|
7
|
+
export interface VideoConfig {
|
|
8
|
+
videoOnDefault?: boolean /** optional, Whether to turn on video by default, defaults to true */;
|
|
9
|
+
renderDom?: string /** optional, The DOM element to render the video stream to */;
|
|
10
|
+
videoInputDeviceId?: string /** optional, The device ID of the video input device to use */;
|
|
11
|
+
screenConfig?: ScreenConfig;
|
|
11
12
|
}
|
|
12
|
-
export
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
export interface RealtimeClientConfig {
|
|
14
|
+
accessToken: GetToken /** required, Access Token */;
|
|
15
|
+
botId: string /** required, Bot Id */;
|
|
16
|
+
voiceId?: string /** optional, Voice Id */;
|
|
17
|
+
conversationId?: string /** optional, Conversation Id */;
|
|
18
|
+
userId?: string /** optional, User Id */;
|
|
19
|
+
workflowId?: string /** optional, Workflow Id */;
|
|
20
|
+
baseURL?: string /** optional, defaults to "https://api.coze.cn" */;
|
|
21
|
+
debug?: boolean /** optional, defaults to false */;
|
|
22
|
+
getRoomInfo?: () => Promise<CreateRoomData> /** optional, Customize get room info */;
|
|
23
|
+
/** Whether Personal Access Tokens (PAT) are allowed in browser environments */
|
|
24
|
+
allowPersonalAccessTokenInBrowser?: boolean;
|
|
25
|
+
/** Whether to mute by default, defaults to false
|
|
26
|
+
* If set to true, audio streams will not be automatically published and subscribed */
|
|
27
|
+
audioMutedDefault?: boolean;
|
|
28
|
+
connectorId: string /** required, Connector Id */;
|
|
29
|
+
suppressStationaryNoise?: boolean /** optional, Suppress stationary noise, defaults to false */;
|
|
30
|
+
suppressNonStationaryNoise?: boolean /** optional, Suppress non-stationary noise, defaults to false */;
|
|
31
|
+
videoConfig?: VideoConfig /** optional, Video configuration */;
|
|
32
|
+
isAutoSubscribeAudio?: boolean /** optional, Whether to automatically subscribe to bot reply audio streams, defaults to true */;
|
|
33
|
+
prologueContent?: string /** optional, Prologue content */;
|
|
34
|
+
roomMode?: RoomMode /** optional, Room mode */;
|
|
35
|
+
translateConfig?: TranslateConfig /** optional, Translation configuration */;
|
|
36
|
+
turnDetection?: CreateRoomTurnDetection /** optional, Turn detection */;
|
|
37
|
+
}
|
|
38
|
+
declare class RealtimeClient extends RealtimeEventHandler {
|
|
39
|
+
_config: RealtimeClientConfig;
|
|
40
|
+
private _client;
|
|
41
|
+
isConnected: boolean;
|
|
42
|
+
private _api;
|
|
43
|
+
private _isTestEnv;
|
|
44
|
+
_isSupportVideo: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Constructor for initializing a RealtimeClient instance.
|
|
47
|
+
*
|
|
48
|
+
* 构造函数,初始化RealtimeClient实例。
|
|
49
|
+
*
|
|
50
|
+
* @param config
|
|
51
|
+
* @param config.accessToken - Required, Access Token. |
|
|
52
|
+
* 必填,Access Token。
|
|
53
|
+
* @param config.botId - Required, Bot Id. |
|
|
54
|
+
* 必填,Bot Id。
|
|
55
|
+
* @param config.voiceId - Optional, Voice Id. |
|
|
56
|
+
* 可选,音色Id。
|
|
57
|
+
* @param config.conversationId - Optional, Conversation Id. |
|
|
58
|
+
* 可选,会话Id。
|
|
59
|
+
* @param config.userId - Optional, User Id. |
|
|
60
|
+
* 可选,用户Id。
|
|
61
|
+
* @param config.baseURL - Optional, defaults to "https://api.coze.cn". |
|
|
62
|
+
* 可选,默认值为 "https://api.coze.cn"。
|
|
63
|
+
* @param config.debug - Optional, defaults to false.
|
|
64
|
+
* 可选,默认值为 false。
|
|
65
|
+
* @param config.allowPersonalAccessTokenInBrowser
|
|
66
|
+
* - Optional, whether to allow personal access tokens in browser environment. |
|
|
67
|
+
* 可选,是否允许在浏览器环境中使用个人访问令牌。
|
|
68
|
+
* @param config.audioMutedDefault - Optional, whether audio is muted by default, defaults to false. |
|
|
69
|
+
* 可选,默认是否静音,默认值为 false。
|
|
70
|
+
* @param config.connectorId - Required, Connector Id. |
|
|
71
|
+
* 必填,渠道 Id。
|
|
72
|
+
* @param config.suppressStationaryNoise - Optional, suppress stationary noise, defaults to false. |
|
|
73
|
+
* 可选,默认是否抑制静态噪声,默认值为 false。
|
|
74
|
+
* @param config.suppressNonStationaryNoise - Optional, suppress non-stationary noise, defaults to false. |
|
|
75
|
+
* 可选,默认是否抑制非静态噪声,默认值为 false。
|
|
76
|
+
* @param config.isAutoSubscribeAudio - Optional, whether to automatically subscribe to bot reply audio streams, defaults to true. |
|
|
77
|
+
* @param config.videoConfig - Optional, Video configuration. |
|
|
78
|
+
* 可选,视频配置。
|
|
79
|
+
* @param config.videoConfig.videoOnDefault - Optional, Whether to turn on video by default, defaults to true. |
|
|
80
|
+
* 可选,默认是否开启视频,默认值为 true。
|
|
81
|
+
* @param config.videoConfig.renderDom - Optional, The DOM element to render the video stream to. |
|
|
82
|
+
* 可选,渲染视频流的 DOM 元素。
|
|
83
|
+
* @param config.videoConfig.videoInputDeviceId - Optional, The device ID of the video input device to use. |
|
|
84
|
+
* 可选,视频输入设备的设备 ID。
|
|
85
|
+
* @param config.videoConfig.screenConfig - Optional, Screen share configuration if videoInputDeviceId is 'screenShare' see https://www.volcengine.com/docs/6348/104481#screenconfig for more details. |
|
|
86
|
+
* 可选,屏幕共享配置,如果 videoInputDeviceId 是 'screenShare',请参考 https://www.volcengine.com/docs/6348/104481#screenconfig 了解更多详情。
|
|
87
|
+
* @param config.prologueContent - Optional, Prologue content. | 可选,开场白内容。
|
|
88
|
+
* @param config.roomMode - Optional, Room mode. | 可选,房间模式。
|
|
89
|
+
*/
|
|
90
|
+
constructor(config: RealtimeClientConfig);
|
|
24
91
|
/**
|
|
25
|
-
*
|
|
92
|
+
* en: Establish a connection to the Coze API and join the room
|
|
93
|
+
*
|
|
94
|
+
* zh: 建立与 Coze API 的连接并加入房间
|
|
26
95
|
*/
|
|
27
|
-
|
|
96
|
+
connect(): Promise<void>;
|
|
28
97
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
98
|
+
* en: Interrupt the current conversation
|
|
99
|
+
*
|
|
100
|
+
* zh: 中断当前对话
|
|
31
101
|
*/
|
|
32
|
-
|
|
102
|
+
interrupt(): Promise<void>;
|
|
33
103
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
104
|
+
* en: Disconnect from the current session
|
|
105
|
+
*
|
|
106
|
+
* zh: 断开与当前会话的连接
|
|
36
107
|
*/
|
|
37
|
-
|
|
108
|
+
disconnect(): Promise<void>;
|
|
38
109
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
110
|
+
* en: Send a message to the bot
|
|
111
|
+
*
|
|
112
|
+
* zh: 发送消息给Bot
|
|
41
113
|
*/
|
|
42
|
-
|
|
114
|
+
sendMessage(message: Record<string, unknown>): Promise<void>;
|
|
43
115
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* @param clientId 客户端ID
|
|
116
|
+
* en: Enable or disable audio
|
|
117
|
+
*
|
|
118
|
+
* zh: 启用或禁用音频
|
|
48
119
|
*/
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
peerConnection: RTCPeerConnection;
|
|
52
|
-
}>;
|
|
120
|
+
setAudioEnable(isEnable: boolean): Promise<void>;
|
|
121
|
+
setVideoEnable(isEnable: boolean): Promise<void>;
|
|
53
122
|
/**
|
|
54
|
-
*
|
|
123
|
+
* en: Enable audio properties reporting (debug mode only)
|
|
124
|
+
*
|
|
125
|
+
* zh: 启用音频属性报告(仅限调试模式)
|
|
55
126
|
*/
|
|
56
|
-
|
|
127
|
+
enableAudioPropertiesReport(config?: AudioPropertiesConfig): boolean;
|
|
57
128
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
129
|
+
* en: Start audio playback device test (debug mode only)
|
|
130
|
+
*
|
|
131
|
+
* zh: 开始音频播放设备测试(仅限调试模式)
|
|
60
132
|
*/
|
|
61
|
-
|
|
133
|
+
startAudioPlaybackDeviceTest(): Promise<void>;
|
|
62
134
|
/**
|
|
63
|
-
*
|
|
135
|
+
* en: Stop audio playback device test (debug mode only)
|
|
136
|
+
*
|
|
137
|
+
* zh: 停止音频播放设备测试(仅限调试模式)
|
|
64
138
|
*/
|
|
65
|
-
|
|
139
|
+
stopAudioPlaybackDeviceTest(): void;
|
|
66
140
|
/**
|
|
67
|
-
*
|
|
141
|
+
* en: Set the audio input device
|
|
142
|
+
*
|
|
143
|
+
* zh: 设置音频输入设备
|
|
68
144
|
*/
|
|
69
|
-
|
|
145
|
+
setAudioInputDevice(deviceId: string): Promise<void>;
|
|
70
146
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
147
|
+
* en: Set the audio output device
|
|
148
|
+
*
|
|
149
|
+
* zh: 设置音频输出设备
|
|
73
150
|
*/
|
|
74
|
-
|
|
75
|
-
private setupPeerConnectionListeners;
|
|
151
|
+
setAudioOutputDevice(deviceId: string): Promise<void>;
|
|
76
152
|
/**
|
|
77
|
-
*
|
|
153
|
+
* en: Set the video input device
|
|
154
|
+
*
|
|
155
|
+
* zh: 设置视频输入设备
|
|
78
156
|
*/
|
|
79
|
-
|
|
157
|
+
setVideoInputDevice(deviceId: string | 'screenShare' | 'user' | 'environment'): Promise<void>;
|
|
80
158
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
159
|
+
* en: Get the RTC engine instance, for detail visit https://www.volcengine.com/docs/6348/104481
|
|
160
|
+
*
|
|
161
|
+
* zh: 获取 RTC 引擎实例,详情请访问 https://www.volcengine.com/docs/6348/104481
|
|
84
162
|
*/
|
|
85
|
-
|
|
163
|
+
getRtcEngine(): IRTCEngine | undefined;
|
|
86
164
|
}
|
|
165
|
+
export { RealtimeUtils, RealtimeClient, RealtimeAPIError, RealtimeError, EventNames, };
|
package/dist/umd/index.js
CHANGED
|
@@ -740,6 +740,7 @@
|
|
|
740
740
|
};
|
|
741
741
|
}
|
|
742
742
|
if (this._config.translateConfig) config.translate_config = this._config.translateConfig;
|
|
743
|
+
if (this._config.turnDetection) config.turn_detection = this._config.turnDetection;
|
|
743
744
|
const params = {
|
|
744
745
|
bot_id: botId,
|
|
745
746
|
conversation_id: conversationId || void 0,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coze/realtime-api",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "A powerful real-time communication SDK for voice interactions with Coze AI bots | 扣子官方实时通信 SDK,用于与 Coze AI bots 进行语音交互",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"coze",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"test:cov": "vitest --coverage --run"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@coze/api": "1.3.
|
|
62
|
+
"@coze/api": "1.3.7",
|
|
63
63
|
"@volcengine/rtc": "~4.62.11"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|