@coze/realtime-api 1.2.1-beta.9 → 1.3.1

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/README.md CHANGED
@@ -117,3 +117,6 @@ function setupEventListeners() {
117
117
 
118
118
  ## Example
119
119
  For a complete working example, check out our [realtime console demo](../../examples/realtime-console).
120
+
121
+ ## Simultaneous Interpretation
122
+ [Documentation](./live.md)
package/README.zh-CN.md CHANGED
@@ -113,3 +113,6 @@ function setupEventListeners() {
113
113
 
114
114
  ## 示例
115
115
  查看完整的示例,请参考我们的[实时语音控制台DEMO](../../examples/realtime-console)。
116
+
117
+ ## 同声传译
118
+ [使用文档](./live.md)
@@ -156,6 +156,54 @@ var EventNames = /*#__PURE__*/ function(EventNames) {
156
156
  * en: Session updated
157
157
  * zh: 会话更新
158
158
  */ EventNames["SESSION_UPDATED"] = "server.session.updated";
159
+ /**
160
+ * en: Conversation created
161
+ * zh: 会话创建
162
+ */ EventNames["CONVERSATION_CREATED"] = "server.conversation.created";
163
+ /**
164
+ * en: Conversation chat created
165
+ * zh: 会话对话创建
166
+ */ EventNames["CONVERSATION_CHAT_CREATED"] = "server.conversation.chat.created";
167
+ /**
168
+ * en: Conversation chat in progress
169
+ * zh: 对话正在处理中
170
+ */ EventNames["CONVERSATION_CHAT_IN_PROGRESS"] = "server.conversation.chat.in_progress";
171
+ /**
172
+ * en: Conversation message delta received
173
+ * zh: 文本消息增量返回
174
+ */ EventNames["CONVERSATION_MESSAGE_DELTA"] = "server.conversation.message.delta";
175
+ /**
176
+ * en: Conversation message completed
177
+ * zh: 文本消息完成
178
+ */ EventNames["CONVERSATION_MESSAGE_COMPLETED"] = "server.conversation.message.completed";
179
+ /**
180
+ * en: Conversation chat completed
181
+ * zh: 对话完成
182
+ */ EventNames["CONVERSATION_CHAT_COMPLETED"] = "server.conversation.chat.completed";
183
+ /**
184
+ * en: Conversation chat requires action
185
+ * zh: 对话需要插件
186
+ */ EventNames["CONVERSATION_CHAT_REQUIRES_ACTION"] = "server.conversation.chat.requires_action";
187
+ /**
188
+ * en: Conversation chat failed
189
+ * zh: 对话失败
190
+ */ EventNames["CONVERSATION_CHAT_FAILED"] = "server.conversation.chat.failed";
191
+ /**
192
+ * en: Session pre answer updated
193
+ * zh: 安抚配置更新成功
194
+ */ EventNames["SESSION_PRE_ANSWER_UPDATED"] = "server.session.pre_answer.updated";
195
+ /**
196
+ * en: Conversation audio transcript delta
197
+ * zh: 用户语音识别字幕
198
+ */ EventNames["CONVERSATION_AUDIO_TRANSCRIPT_DELTA"] = "server.conversation.audio_transcript.delta";
199
+ /**
200
+ * en: Mode updated
201
+ * zh: 更新房间模式成功
202
+ */ EventNames["MODE_UPDATED"] = "server.mode.updated";
203
+ /**
204
+ * en: Live created
205
+ * zh: 直播创建
206
+ */ EventNames["LIVE_CREATED"] = "server.live.created";
159
207
  return EventNames;
160
208
  }(EventNames || {});
161
209
  /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = EventNames;
package/dist/cjs/index.js CHANGED
@@ -269,6 +269,54 @@ var event_names_EventNames = /*#__PURE__*/ function(EventNames) {
269
269
  * en: Session updated
270
270
  * zh: 会话更新
271
271
  */ EventNames["SESSION_UPDATED"] = "server.session.updated";
272
+ /**
273
+ * en: Conversation created
274
+ * zh: 会话创建
275
+ */ EventNames["CONVERSATION_CREATED"] = "server.conversation.created";
276
+ /**
277
+ * en: Conversation chat created
278
+ * zh: 会话对话创建
279
+ */ EventNames["CONVERSATION_CHAT_CREATED"] = "server.conversation.chat.created";
280
+ /**
281
+ * en: Conversation chat in progress
282
+ * zh: 对话正在处理中
283
+ */ EventNames["CONVERSATION_CHAT_IN_PROGRESS"] = "server.conversation.chat.in_progress";
284
+ /**
285
+ * en: Conversation message delta received
286
+ * zh: 文本消息增量返回
287
+ */ EventNames["CONVERSATION_MESSAGE_DELTA"] = "server.conversation.message.delta";
288
+ /**
289
+ * en: Conversation message completed
290
+ * zh: 文本消息完成
291
+ */ EventNames["CONVERSATION_MESSAGE_COMPLETED"] = "server.conversation.message.completed";
292
+ /**
293
+ * en: Conversation chat completed
294
+ * zh: 对话完成
295
+ */ EventNames["CONVERSATION_CHAT_COMPLETED"] = "server.conversation.chat.completed";
296
+ /**
297
+ * en: Conversation chat requires action
298
+ * zh: 对话需要插件
299
+ */ EventNames["CONVERSATION_CHAT_REQUIRES_ACTION"] = "server.conversation.chat.requires_action";
300
+ /**
301
+ * en: Conversation chat failed
302
+ * zh: 对话失败
303
+ */ EventNames["CONVERSATION_CHAT_FAILED"] = "server.conversation.chat.failed";
304
+ /**
305
+ * en: Session pre answer updated
306
+ * zh: 安抚配置更新成功
307
+ */ EventNames["SESSION_PRE_ANSWER_UPDATED"] = "server.session.pre_answer.updated";
308
+ /**
309
+ * en: Conversation audio transcript delta
310
+ * zh: 用户语音识别字幕
311
+ */ EventNames["CONVERSATION_AUDIO_TRANSCRIPT_DELTA"] = "server.conversation.audio_transcript.delta";
312
+ /**
313
+ * en: Mode updated
314
+ * zh: 更新房间模式成功
315
+ */ EventNames["MODE_UPDATED"] = "server.mode.updated";
316
+ /**
317
+ * en: Live created
318
+ * zh: 直播创建
319
+ */ EventNames["LIVE_CREATED"] = "server.live.created";
272
320
  return EventNames;
273
321
  }(event_names_EventNames || {});
274
322
  /* ESM default export */ const event_names = event_names_EventNames;
@@ -610,6 +658,7 @@ class EngineClient extends RealtimeEventHandler {
610
658
  if (isTestEnv) rtc_default().setParameter('ICE_CONFIG_REQUEST_URLS', [
611
659
  'rtc-test.bytedance.com'
612
660
  ]);
661
+ else localStorage.removeItem('RTC_ACCESS_URLS-VolcEngine');
613
662
  this.engine = rtc_default().createEngine(appId);
614
663
  this.handleMessage = this.handleMessage.bind(this);
615
664
  this.handleUserJoin = this.handleUserJoin.bind(this);
@@ -643,7 +692,7 @@ class RealtimeClient extends RealtimeEventHandler {
643
692
  else {
644
693
  const config = {};
645
694
  if (this._config.prologueContent) config.prologue_content = this._config.prologueContent;
646
- if (void 0 !== this._config.roomMode && null !== this._config.roomMode) config.room_mode = this._config.roomMode;
695
+ if (void 0 !== this._config.roomMode && null !== this._config.roomMode) config.room_mode = this._config.roomMode || api_namespaceObject.RoomMode.Default;
647
696
  if (this._config.videoConfig) {
648
697
  if (isScreenShareDevice(this._config.videoConfig.videoInputDeviceId)) config.video_config = {
649
698
  stream_video_type: 'screen'
@@ -652,7 +701,8 @@ class RealtimeClient extends RealtimeEventHandler {
652
701
  stream_video_type: 'main'
653
702
  };
654
703
  }
655
- roomInfo = await this._api.audio.rooms.create({
704
+ if (this._config.translateConfig) config.translate_config = this._config.translateConfig;
705
+ const params = {
656
706
  bot_id: botId,
657
707
  conversation_id: conversationId || void 0,
658
708
  voice_id: voiceId && voiceId.length > 0 ? voiceId : void 0,
@@ -660,7 +710,8 @@ class RealtimeClient extends RealtimeEventHandler {
660
710
  uid: this._config.userId || void 0,
661
711
  workflow_id: this._config.workflowId || void 0,
662
712
  config
663
- });
713
+ };
714
+ roomInfo = await this._api.audio.rooms.create(params);
664
715
  }
665
716
  } catch (error) {
666
717
  this.dispatch(event_names.ERROR, error);
@@ -0,0 +1,292 @@
1
+ "use strict";
2
+ // The require scope
3
+ var __webpack_require__ = {};
4
+ /************************************************************************/ // webpack/runtime/define_property_getters
5
+ (()=>{
6
+ __webpack_require__.d = function(exports1, definition) {
7
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
8
+ enumerable: true,
9
+ get: definition[key]
10
+ });
11
+ };
12
+ })();
13
+ // webpack/runtime/has_own_property
14
+ (()=>{
15
+ __webpack_require__.o = function(obj, prop) {
16
+ return Object.prototype.hasOwnProperty.call(obj, prop);
17
+ };
18
+ })();
19
+ // webpack/runtime/make_namespace_object
20
+ (()=>{
21
+ // define __esModule on exports
22
+ __webpack_require__.r = function(exports1) {
23
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
24
+ value: 'Module'
25
+ });
26
+ Object.defineProperty(exports1, '__esModule', {
27
+ value: true
28
+ });
29
+ };
30
+ })();
31
+ /************************************************************************/ var __webpack_exports__ = {};
32
+ // ESM COMPAT FLAG
33
+ __webpack_require__.r(__webpack_exports__);
34
+ // EXPORTS
35
+ __webpack_require__.d(__webpack_exports__, {
36
+ WebLiveClient: ()=>/* binding */ WebLiveClient,
37
+ ResourceStatus: ()=>/* binding */ live_ResourceStatus
38
+ });
39
+ const api_namespaceObject = require("@coze/api");
40
+ // WTN服务基础URL
41
+ const WTN_BASE_URL = 'https://wtn.volcvideo.com';
42
+ /**
43
+ * WebRTC资源状态
44
+ */ var live_ResourceStatus = /*#__PURE__*/ function(ResourceStatus) {
45
+ ResourceStatus["IDLE"] = "idle";
46
+ ResourceStatus["CONNECTING"] = "connecting";
47
+ ResourceStatus["CONNECTED"] = "connected";
48
+ ResourceStatus["FAILED"] = "failed";
49
+ ResourceStatus["CLOSING"] = "closing";
50
+ ResourceStatus["CLOSED"] = "closed";
51
+ return ResourceStatus;
52
+ }({});
53
+ /**
54
+ * 同声传译客户端
55
+ */ class WebLiveClient {
56
+ /**
57
+ * 获取当前连接状态
58
+ */ getStatus() {
59
+ return this.status;
60
+ }
61
+ /**
62
+ * 添加状态变化监听器
63
+ * @param callback 状态变化回调函数
64
+ */ onStatusChange(callback) {
65
+ this.statusListeners.push(callback);
66
+ }
67
+ /**
68
+ * 移除状态变化监听器
69
+ * @param callback 要移除的回调函数
70
+ */ offStatusChange(callback) {
71
+ this.removeStatusListener(callback);
72
+ }
73
+ /**
74
+ * 移除状态变化监听器
75
+ * @param callback 要移除的回调函数
76
+ */ removeStatusListener(callback) {
77
+ const index = this.statusListeners.indexOf(callback);
78
+ if (-1 !== index) this.statusListeners.splice(index, 1);
79
+ }
80
+ /**
81
+ * 订阅音频资源
82
+ * @param appId 应用ID
83
+ * @param streamId 流ID
84
+ * @param clientId 客户端ID
85
+ */ async subscribe(appId, streamId) {
86
+ let clientId = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : '';
87
+ try {
88
+ var _pc_localDescription;
89
+ // 先清理现有连接
90
+ if (this.peerConnection) {
91
+ this.peerConnection.close();
92
+ this.peerConnection = null;
93
+ }
94
+ this.setStatus("connecting");
95
+ // 1. 创建RTCPeerConnection
96
+ const rtcConfig = {};
97
+ const pc = new RTCPeerConnection(rtcConfig);
98
+ pc.ontrack = (event)=>{
99
+ // 音频流
100
+ this.player.onloadeddata = ()=>{
101
+ this.player.play();
102
+ };
103
+ this.player.srcObject = event.streams[0];
104
+ };
105
+ this.peerConnection = pc;
106
+ this.setupPeerConnectionListeners();
107
+ pc.addTransceiver('audio', {
108
+ direction: 'recvonly'
109
+ });
110
+ // 2. 创建Offer (SDP)
111
+ const offer = await pc.createOffer();
112
+ // 设置本地描述
113
+ await pc.setLocalDescription(offer);
114
+ // 等待ICE收集完成再继续
115
+ await this.waitForIceGathering(pc);
116
+ if (!(null === (_pc_localDescription = pc.localDescription) || void 0 === _pc_localDescription ? void 0 : _pc_localDescription.sdp)) throw new Error('Failed to create SDP offer');
117
+ // 3. 发送Offer到WTN服务订阅资源
118
+ let subscribeUrl = `${WTN_BASE_URL}/sub/${appId}/${streamId}?MuteVideo=true`;
119
+ if (clientId) subscribeUrl += `&clientid=${clientId}`;
120
+ const response = await fetch(subscribeUrl, {
121
+ method: 'POST',
122
+ headers: {
123
+ 'Content-Type': 'application/sdp'
124
+ },
125
+ body: offer.sdp
126
+ });
127
+ if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
128
+ // 4. 保存资源URL (用于销毁资源)
129
+ this.resourceUrl = response.headers.get('location') || '';
130
+ // 5. 设置远程SDP (Answer)
131
+ // 直接获取文本响应,因为服务器返回的是application/sdp格式而非json
132
+ const answerSdp = await response.text();
133
+ const answer = new RTCSessionDescription({
134
+ type: 'answer',
135
+ sdp: answerSdp
136
+ });
137
+ await this.peerConnection.setRemoteDescription(answer);
138
+ // 7. 返回结果
139
+ return {
140
+ status: this.status,
141
+ peerConnection: this.peerConnection
142
+ };
143
+ } catch (error) {
144
+ this.status = "failed";
145
+ console.error('Failed to subscribe WebRTC stream:', error);
146
+ return Promise.reject(error);
147
+ }
148
+ }
149
+ /**
150
+ * 销毁订阅资源
151
+ */ async unsubscribe() {
152
+ try {
153
+ // 销毁订阅资源
154
+ if (!this.resourceUrl) throw new Error('No valid subscription resource URL to unsubscribe');
155
+ this.setStatus("closing");
156
+ const response = await fetch(this.resourceUrl, {
157
+ method: 'DELETE'
158
+ });
159
+ if (!response.ok) throw new Error(`Failed to unsubscribe: ${response.status} ${response.statusText}`);
160
+ // 关闭RTC连接
161
+ if (this.peerConnection) {
162
+ this.peerConnection.close();
163
+ this.peerConnection = null;
164
+ }
165
+ this.resourceUrl = '';
166
+ this.status = "closed";
167
+ return true;
168
+ } catch (error) {
169
+ console.error('Error unsubscribing resource:', error);
170
+ this.status = "failed";
171
+ return Promise.reject(error);
172
+ }
173
+ }
174
+ /**
175
+ * 静音/取消静音
176
+ * @param muted 是否静音
177
+ */ setMuted(muted) {
178
+ this.player.muted = muted;
179
+ }
180
+ /**
181
+ * 关闭并清理资源
182
+ */ close() {
183
+ // 关闭PeerConnection
184
+ this.closePeerConnection();
185
+ // Clean up audio element
186
+ if (this.player) {
187
+ this.player.pause();
188
+ this.player.srcObject = null;
189
+ this.player.remove();
190
+ }
191
+ // 重置状态
192
+ this.resourceUrl = '';
193
+ this.setStatus("idle");
194
+ }
195
+ /**
196
+ * 等待ICE收集完成
197
+ * @param pc RTCPeerConnection实例
198
+ */ waitForIceGathering(pc) {
199
+ return new Promise((resolve)=>{
200
+ // 如果已经收集完成,直接返回
201
+ if ('complete' === pc.iceGatheringState) {
202
+ resolve();
203
+ return;
204
+ }
205
+ // 设置收集完成时的回调
206
+ const checkState = ()=>{
207
+ if ('complete' === pc.iceGatheringState) {
208
+ pc.removeEventListener('icegatheringstatechange', checkState);
209
+ resolve();
210
+ }
211
+ };
212
+ // 监听收集状态变化
213
+ pc.addEventListener('icegatheringstatechange', checkState);
214
+ // 添加超时处理,防止永远等待
215
+ setTimeout(()=>resolve(), 5000);
216
+ });
217
+ }
218
+ setupPeerConnectionListeners() {
219
+ if (!this.peerConnection) return;
220
+ this.peerConnection.oniceconnectionstatechange = ()=>{
221
+ var _this_peerConnection, _this_peerConnection1;
222
+ console.log('ICE connection state changed:', null === (_this_peerConnection = this.peerConnection) || void 0 === _this_peerConnection ? void 0 : _this_peerConnection.iceConnectionState);
223
+ switch(null === (_this_peerConnection1 = this.peerConnection) || void 0 === _this_peerConnection1 ? void 0 : _this_peerConnection1.iceConnectionState){
224
+ case 'connected':
225
+ case 'completed':
226
+ this.setStatus("connected");
227
+ break;
228
+ case 'failed':
229
+ case 'disconnected':
230
+ this.setStatus("failed");
231
+ break;
232
+ case 'closed':
233
+ this.setStatus("closed");
234
+ break;
235
+ default:
236
+ var _this_peerConnection2;
237
+ console.log('ICE connection state changed:', null === (_this_peerConnection2 = this.peerConnection) || void 0 === _this_peerConnection2 ? void 0 : _this_peerConnection2.iceConnectionState);
238
+ break;
239
+ }
240
+ };
241
+ this.peerConnection.onicecandidate = (event)=>{
242
+ if (event.candidate) console.log('New ICE candidate:', event.candidate);
243
+ };
244
+ }
245
+ /**
246
+ * 关闭PeerConnection
247
+ */ closePeerConnection() {
248
+ if (this.peerConnection) {
249
+ this.peerConnection.close();
250
+ this.peerConnection = null;
251
+ }
252
+ }
253
+ /**
254
+ * 设置状态并触发监听回调
255
+ * @param newStatus 新状态
256
+ * @private 私有方法,仅内部使用
257
+ */ setStatus(newStatus) {
258
+ const oldStatus = this.status;
259
+ if (oldStatus !== newStatus) {
260
+ this.status = newStatus;
261
+ // 触发所有监听器
262
+ for (const listener of this.statusListeners)try {
263
+ listener(newStatus);
264
+ } catch (error) {
265
+ console.error('Error in status listener:', error);
266
+ }
267
+ }
268
+ }
269
+ constructor(liveId){
270
+ this.peerConnection = null;
271
+ this.resourceUrl = '';
272
+ this.status = "idle";
273
+ this.statusListeners = [];
274
+ /**
275
+ * 获取直播信息
276
+ */ this.getLiveData = async ()=>{
277
+ const api = new api_namespaceObject.CozeAPI({
278
+ baseURL: api_namespaceObject.COZE_CN_BASE_URL,
279
+ token: ''
280
+ });
281
+ return await api.audio.live.retrieve(this.liveId);
282
+ };
283
+ this.setupPeerConnectionListeners();
284
+ this.player = document.createElement('audio');
285
+ this.liveId = liveId;
286
+ }
287
+ }
288
+ var __webpack_export_target__ = exports;
289
+ for(var i in __webpack_exports__)__webpack_export_target__[i] = __webpack_exports__[i];
290
+ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
291
+ value: true
292
+ });
@@ -119,6 +119,54 @@ var event_names_EventNames = /*#__PURE__*/ function(EventNames) {
119
119
  * en: Session updated
120
120
  * zh: 会话更新
121
121
  */ EventNames["SESSION_UPDATED"] = "server.session.updated";
122
+ /**
123
+ * en: Conversation created
124
+ * zh: 会话创建
125
+ */ EventNames["CONVERSATION_CREATED"] = "server.conversation.created";
126
+ /**
127
+ * en: Conversation chat created
128
+ * zh: 会话对话创建
129
+ */ EventNames["CONVERSATION_CHAT_CREATED"] = "server.conversation.chat.created";
130
+ /**
131
+ * en: Conversation chat in progress
132
+ * zh: 对话正在处理中
133
+ */ EventNames["CONVERSATION_CHAT_IN_PROGRESS"] = "server.conversation.chat.in_progress";
134
+ /**
135
+ * en: Conversation message delta received
136
+ * zh: 文本消息增量返回
137
+ */ EventNames["CONVERSATION_MESSAGE_DELTA"] = "server.conversation.message.delta";
138
+ /**
139
+ * en: Conversation message completed
140
+ * zh: 文本消息完成
141
+ */ EventNames["CONVERSATION_MESSAGE_COMPLETED"] = "server.conversation.message.completed";
142
+ /**
143
+ * en: Conversation chat completed
144
+ * zh: 对话完成
145
+ */ EventNames["CONVERSATION_CHAT_COMPLETED"] = "server.conversation.chat.completed";
146
+ /**
147
+ * en: Conversation chat requires action
148
+ * zh: 对话需要插件
149
+ */ EventNames["CONVERSATION_CHAT_REQUIRES_ACTION"] = "server.conversation.chat.requires_action";
150
+ /**
151
+ * en: Conversation chat failed
152
+ * zh: 对话失败
153
+ */ EventNames["CONVERSATION_CHAT_FAILED"] = "server.conversation.chat.failed";
154
+ /**
155
+ * en: Session pre answer updated
156
+ * zh: 安抚配置更新成功
157
+ */ EventNames["SESSION_PRE_ANSWER_UPDATED"] = "server.session.pre_answer.updated";
158
+ /**
159
+ * en: Conversation audio transcript delta
160
+ * zh: 用户语音识别字幕
161
+ */ EventNames["CONVERSATION_AUDIO_TRANSCRIPT_DELTA"] = "server.conversation.audio_transcript.delta";
162
+ /**
163
+ * en: Mode updated
164
+ * zh: 更新房间模式成功
165
+ */ EventNames["MODE_UPDATED"] = "server.mode.updated";
166
+ /**
167
+ * en: Live created
168
+ * zh: 直播创建
169
+ */ EventNames["LIVE_CREATED"] = "server.live.created";
122
170
  return EventNames;
123
171
  }(event_names_EventNames || {});
124
172
  /* ESM default export */ const event_names = event_names_EventNames;
package/dist/esm/index.js CHANGED
@@ -242,6 +242,54 @@ var event_names_EventNames = /*#__PURE__*/ function(EventNames) {
242
242
  * en: Session updated
243
243
  * zh: 会话更新
244
244
  */ EventNames["SESSION_UPDATED"] = "server.session.updated";
245
+ /**
246
+ * en: Conversation created
247
+ * zh: 会话创建
248
+ */ EventNames["CONVERSATION_CREATED"] = "server.conversation.created";
249
+ /**
250
+ * en: Conversation chat created
251
+ * zh: 会话对话创建
252
+ */ EventNames["CONVERSATION_CHAT_CREATED"] = "server.conversation.chat.created";
253
+ /**
254
+ * en: Conversation chat in progress
255
+ * zh: 对话正在处理中
256
+ */ EventNames["CONVERSATION_CHAT_IN_PROGRESS"] = "server.conversation.chat.in_progress";
257
+ /**
258
+ * en: Conversation message delta received
259
+ * zh: 文本消息增量返回
260
+ */ EventNames["CONVERSATION_MESSAGE_DELTA"] = "server.conversation.message.delta";
261
+ /**
262
+ * en: Conversation message completed
263
+ * zh: 文本消息完成
264
+ */ EventNames["CONVERSATION_MESSAGE_COMPLETED"] = "server.conversation.message.completed";
265
+ /**
266
+ * en: Conversation chat completed
267
+ * zh: 对话完成
268
+ */ EventNames["CONVERSATION_CHAT_COMPLETED"] = "server.conversation.chat.completed";
269
+ /**
270
+ * en: Conversation chat requires action
271
+ * zh: 对话需要插件
272
+ */ EventNames["CONVERSATION_CHAT_REQUIRES_ACTION"] = "server.conversation.chat.requires_action";
273
+ /**
274
+ * en: Conversation chat failed
275
+ * zh: 对话失败
276
+ */ EventNames["CONVERSATION_CHAT_FAILED"] = "server.conversation.chat.failed";
277
+ /**
278
+ * en: Session pre answer updated
279
+ * zh: 安抚配置更新成功
280
+ */ EventNames["SESSION_PRE_ANSWER_UPDATED"] = "server.session.pre_answer.updated";
281
+ /**
282
+ * en: Conversation audio transcript delta
283
+ * zh: 用户语音识别字幕
284
+ */ EventNames["CONVERSATION_AUDIO_TRANSCRIPT_DELTA"] = "server.conversation.audio_transcript.delta";
285
+ /**
286
+ * en: Mode updated
287
+ * zh: 更新房间模式成功
288
+ */ EventNames["MODE_UPDATED"] = "server.mode.updated";
289
+ /**
290
+ * en: Live created
291
+ * zh: 直播创建
292
+ */ EventNames["LIVE_CREATED"] = "server.live.created";
245
293
  return EventNames;
246
294
  }(event_names_EventNames || {});
247
295
  /* ESM default export */ const event_names = event_names_EventNames;
@@ -581,6 +629,7 @@ class EngineClient extends RealtimeEventHandler {
581
629
  if (isTestEnv) __WEBPACK_EXTERNAL_MODULE__volcengine_rtc__["default"].setParameter('ICE_CONFIG_REQUEST_URLS', [
582
630
  'rtc-test.bytedance.com'
583
631
  ]);
632
+ else localStorage.removeItem('RTC_ACCESS_URLS-VolcEngine');
584
633
  this.engine = __WEBPACK_EXTERNAL_MODULE__volcengine_rtc__["default"].createEngine(appId);
585
634
  this.handleMessage = this.handleMessage.bind(this);
586
635
  this.handleUserJoin = this.handleUserJoin.bind(this);
@@ -614,7 +663,7 @@ class RealtimeClient extends RealtimeEventHandler {
614
663
  else {
615
664
  const config = {};
616
665
  if (this._config.prologueContent) config.prologue_content = this._config.prologueContent;
617
- if (void 0 !== this._config.roomMode && null !== this._config.roomMode) config.room_mode = this._config.roomMode;
666
+ if (void 0 !== this._config.roomMode && null !== this._config.roomMode) config.room_mode = this._config.roomMode || __WEBPACK_EXTERNAL_MODULE__coze_api__.RoomMode.Default;
618
667
  if (this._config.videoConfig) {
619
668
  if (isScreenShareDevice(this._config.videoConfig.videoInputDeviceId)) config.video_config = {
620
669
  stream_video_type: 'screen'
@@ -623,7 +672,8 @@ class RealtimeClient extends RealtimeEventHandler {
623
672
  stream_video_type: 'main'
624
673
  };
625
674
  }
626
- roomInfo = await this._api.audio.rooms.create({
675
+ if (this._config.translateConfig) config.translate_config = this._config.translateConfig;
676
+ const params = {
627
677
  bot_id: botId,
628
678
  conversation_id: conversationId || void 0,
629
679
  voice_id: voiceId && voiceId.length > 0 ? voiceId : void 0,
@@ -631,7 +681,8 @@ class RealtimeClient extends RealtimeEventHandler {
631
681
  uid: this._config.userId || void 0,
632
682
  workflow_id: this._config.workflowId || void 0,
633
683
  config
634
- });
684
+ };
685
+ roomInfo = await this._api.audio.rooms.create(params);
635
686
  }
636
687
  } catch (error) {
637
688
  this.dispatch(event_names.ERROR, error);