@coze/realtime-api 1.0.5 → 1.1.0-beta.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/README.md CHANGED
@@ -56,6 +56,15 @@ const client = new RealtimeClient({
56
56
  voiceId: "your_voice_id", // Optional: Specify voice ID
57
57
  conversationId: "conversation_id", // Optional: For conversation continuity
58
58
  debug: true, // Optional: Enable debug logging
59
+ getRoomInfo: async () => {
60
+ // Customize get room info
61
+ return {
62
+ token: "your_token",
63
+ uid: "your_uid",
64
+ room_id: "your_room_id",
65
+ app_id: "your_app_id",
66
+ };
67
+ },
59
68
  allowPersonalAccessTokenInBrowser: true, // Optional: Enable PAT token usage in browser
60
69
  audioMutedDefault: false, // Optional: Initial audio state (default: false)
61
70
  suppressStationaryNoise: false, // Optional: Enable stationary noise suppression(default: false)
package/README.zh-CN.md CHANGED
@@ -56,6 +56,15 @@ const client = new RealtimeClient({
56
56
  voiceId: "your_voice_id", // 可选:指定音色 ID
57
57
  conversationId: "conversation_id", // 可选:用于对话连续性
58
58
  debug: true, // 可选:启用调试日志
59
+ getRoomInfo: async () => {
60
+ // 自定义获取房间信息
61
+ return {
62
+ token: "your_token",
63
+ uid: "your_uid",
64
+ room_id: "your_room_id",
65
+ app_id: "your_app_id",
66
+ };
67
+ },
59
68
  allowPersonalAccessTokenInBrowser: true, // 可选:在浏览器中启用 PAT 令牌使用
60
69
  audioMutedDefault: false, // 可选:初始音频状态(默认:false)
61
70
  suppressStationaryNoise: false, // 可选:启用静态噪声抑制(默认:false)
@@ -283,7 +283,7 @@ class error_APIError extends CozeError {
283
283
  }
284
284
  }
285
285
  class APIConnectionError extends error_APIError {
286
- constructor({ message, cause }){
286
+ constructor({ message }){
287
287
  super(void 0, void 0, message || 'Connection error.', void 0), this.status = void 0;
288
288
  // if (cause) {
289
289
  // this.cause = cause;
@@ -358,6 +358,12 @@ const handleAdditionalMessages = (additional_messages)=>null == additional_messa
358
358
  ...i,
359
359
  content: 'object' == typeof i.content ? JSON.stringify(i.content) : i.content
360
360
  }));
361
+ const handleParameters = (parameters)=>{
362
+ if (parameters) {
363
+ for (const [key, value] of Object.entries(parameters))if ('object' == typeof value) parameters[key] = JSON.stringify(value);
364
+ }
365
+ return parameters;
366
+ };
361
367
  class Chat extends APIResource {
362
368
  /**
363
369
  * Call the Chat API to send messages to a published Coze agent. | 调用此接口发起一次对话,支持添加上下文
@@ -380,6 +386,10 @@ class Chat extends APIResource {
380
386
  const payload = {
381
387
  ...rest,
382
388
  additional_messages: handleAdditionalMessages(params.additional_messages),
389
+ shortcut_command: params.shortcut_command ? {
390
+ ...params.shortcut_command,
391
+ parameters: handleParameters(params.shortcut_command.parameters)
392
+ } : void 0,
383
393
  stream: false
384
394
  };
385
395
  const result = await this._client.post(apiUrl, payload, false, options);
@@ -406,6 +416,10 @@ class Chat extends APIResource {
406
416
  const payload = {
407
417
  ...rest,
408
418
  additional_messages: handleAdditionalMessages(params.additional_messages),
419
+ shortcut_command: params.shortcut_command ? {
420
+ ...params.shortcut_command,
421
+ parameters: handleParameters(params.shortcut_command.parameters)
422
+ } : void 0,
409
423
  stream: false
410
424
  };
411
425
  const result = await this._client.post(apiUrl, payload, false, options);
@@ -444,6 +458,10 @@ class Chat extends APIResource {
444
458
  const payload = {
445
459
  ...rest,
446
460
  additional_messages: handleAdditionalMessages(params.additional_messages),
461
+ shortcut_command: params.shortcut_command ? {
462
+ ...params.shortcut_command,
463
+ parameters: handleParameters(params.shortcut_command.parameters)
464
+ } : void 0,
447
465
  stream: true
448
466
  };
449
467
  const result = await this._client.post(apiUrl, payload, true, options);
@@ -3518,6 +3536,17 @@ class Runs extends APIResource {
3518
3536
  const response = await this._client.post(apiUrl, params, false, options);
3519
3537
  return response;
3520
3538
  }
3539
+ /**
3540
+ * Get the workflow run history | 工作流异步运行后,查看执行结果
3541
+ * @docs zh: https://www.coze.cn/open/docs/developer_guides/workflow_history
3542
+ * @param workflowId - Required The ID of the workflow. | 必选 工作流 ID。
3543
+ * @param executeId - Required The ID of the workflow execution. | 必选 工作流执行 ID。
3544
+ * @returns WorkflowExecuteHistory[] | 工作流执行历史
3545
+ */ async history(workflowId, executeId, options) {
3546
+ const apiUrl = `/v1/workflows/${workflowId}/run_histories/${executeId}`;
3547
+ const response = await this._client.get(apiUrl, void 0, false, options);
3548
+ return response.data;
3549
+ }
3521
3550
  }
3522
3551
  class WorkflowEvent {
3523
3552
  constructor(id, event, data){
@@ -3679,7 +3708,7 @@ class documents_Documents extends APIResource {
3679
3708
  * @returns ListDocumentData | 知识库文件列表
3680
3709
  */ async list(params, options) {
3681
3710
  const apiUrl = '/open_api/knowledge/document/list';
3682
- const response = await this._client.get(apiUrl, params, false, mergeConfig(options, {
3711
+ const response = await this._client.post(apiUrl, params, false, mergeConfig(options, {
3683
3712
  headers: documents_documents_headers
3684
3713
  }));
3685
3714
  return response;
@@ -4596,6 +4625,8 @@ class WebSocketAPI {
4596
4625
  });
4597
4626
  this.rws.addEventListener('error', (event)=>{
4598
4627
  var _event_target__req_res, _event_target__req, _event_target, _event_target__req_res1, _event_target__req1, _event_target1, _this_onerror, _this;
4628
+ const { readyState } = this.rws;
4629
+ if (3 === readyState) return;
4599
4630
  const statusCode = null === (_event_target = event.target) || void 0 === _event_target ? void 0 : null === (_event_target__req = _event_target._req) || void 0 === _event_target__req ? void 0 : null === (_event_target__req_res = _event_target__req.res) || void 0 === _event_target__req_res ? void 0 : _event_target__req_res.statusCode;
4600
4631
  const rawHeaders = (null === (_event_target1 = event.target) || void 0 === _event_target1 ? void 0 : null === (_event_target__req1 = _event_target1._req) || void 0 === _event_target__req1 ? void 0 : null === (_event_target__req_res1 = _event_target__req1.res) || void 0 === _event_target__req_res1 ? void 0 : _event_target__req_res1.rawHeaders) || [];
4601
4632
  const logidIndex = rawHeaders.findIndex((header)=>'X-Tt-Logid' === header);
@@ -4619,7 +4650,8 @@ class WebSocketAPI {
4619
4650
  error.data.msg = 'Forbidden';
4620
4651
  } else {
4621
4652
  error.data.code = 500;
4622
- error.data.msg = String(null == event ? void 0 : event.error) || 'WebSocket error';
4653
+ var _event_error;
4654
+ error.data.msg = String(null !== (_event_error = null == event ? void 0 : event.error) && void 0 !== _event_error ? _event_error : '') || 'WebSocket error';
4623
4655
  }
4624
4656
  null === (_this_onerror = (_this = this).onerror) || void 0 === _this_onerror || _this_onerror.call(_this, error, event);
4625
4657
  });
@@ -4628,7 +4660,7 @@ class WebSocketAPI {
4628
4660
  // EXTERNAL MODULE: os (ignored)
4629
4661
  var os_ignored_ = __webpack_require__("?9050");
4630
4662
  var os_ignored_default = /*#__PURE__*/ __webpack_require__.n(os_ignored_);
4631
- var package_namespaceObject = JSON.parse('{"name":"@coze/api","version":"1.0.20","description":"Official Coze Node.js SDK for seamless AI integration into your applications | 扣子官方 Node.js SDK,助您轻松集成 AI 能力到应用中","keywords":["coze","ai","nodejs","sdk","chatbot","typescript"],"homepage":"https://github.com/coze-dev/coze-js/tree/main/packages/coze-js","bugs":{"url":"https://github.com/coze-dev/coze-js/issues"},"repository":{"type":"git","url":"https://github.com/coze-dev/coze-js.git","directory":"packages/coze-js"},"license":"MIT","author":"Leeight <leeight@gmail.com>","type":"module","exports":{".":"./src/index.ts"},"main":"src/index.ts","module":"src/index.ts","browser":{"crypto":false,"os":false,"jsonwebtoken":false,"node-fetch":false},"types":"src/index.ts","files":["dist","LICENSE","README.md","README.zh-CN.md"],"scripts":{"build":"rslib build","format":"prettier --write .","lint":"eslint ./ --cache --quiet","start":"rslib build -w","test":"vitest","test:cov":"vitest --coverage --run"},"dependencies":{"jsonwebtoken":"^9.0.2","node-fetch":"^2.x","reconnecting-websocket":"^4.4.0","ws":"^8.11.0"},"devDependencies":{"@coze-infra/eslint-config":"workspace:*","@coze-infra/ts-config":"workspace:*","@coze-infra/vitest-config":"workspace:*","@rslib/core":"0.0.18","@swc/core":"^1.3.14","@types/jsonwebtoken":"^9.0.0","@types/node":"^20","@types/node-fetch":"^2.x","@types/uuid":"^9.0.1","@types/whatwg-fetch":"^0.0.33","@types/ws":"^8.5.1","@vitest/coverage-v8":"~2.1.4","axios":"^1.7.7","typescript":"^5.5.3","vitest":"~2.1.4"},"peerDependencies":{"axios":"^1.7.1"},"cozePublishConfig":{"exports":{".":{"require":"./dist/cjs/index.cjs","import":"./dist/esm/index.js","types":"./dist/types/index.d.ts"}},"main":"dist/cjs/index.cjs","module":"dist/esm/index.js","types":"dist/types/index.d.ts"}}'); // CONCATENATED MODULE: ../coze-js/src/version.ts
4663
+ var package_namespaceObject = JSON.parse('{"name":"@coze/api","version":"1.1.0-beta.6","description":"Official Coze Node.js SDK for seamless AI integration into your applications | 扣子官方 Node.js SDK,助您轻松集成 AI 能力到应用中","keywords":["coze","ai","nodejs","sdk","chatbot","typescript"],"homepage":"https://github.com/coze-dev/coze-js/tree/main/packages/coze-js","bugs":{"url":"https://github.com/coze-dev/coze-js/issues"},"repository":{"type":"git","url":"https://github.com/coze-dev/coze-js.git","directory":"packages/coze-js"},"license":"MIT","author":"Leeight <leeight@gmail.com>","exports":{".":"./src/index.ts","./ws-tools":"./src/ws-tools/index.ts"},"main":"src/index.ts","module":"src/index.ts","browser":{"crypto":false,"os":false,"jsonwebtoken":false,"node-fetch":false},"typesVersions":{"*":{".":["dist/types/index.d.ts"],"ws-tools":["dist/types/ws-tools/ws-tools/index.d.ts"]}},"files":["dist","LICENSE","README.md","README.zh-CN.md"],"scripts":{"build":"rslib build","format":"prettier --write .","lint":"eslint ./ --cache --quiet","start":"rslib build -w","test":"vitest","test:cov":"vitest --coverage --run"},"dependencies":{"jsonwebtoken":"^9.0.2","node-fetch":"^2.x","reconnecting-websocket":"^4.4.0","uuid":"^10.0.0","ws":"^8.11.0"},"devDependencies":{"@coze-infra/eslint-config":"workspace:*","@coze-infra/ts-config":"workspace:*","@coze-infra/vitest-config":"workspace:*","@rslib/core":"0.0.18","@swc/core":"^1.3.14","@types/jsonwebtoken":"^9.0.0","@types/node":"^20","@types/node-fetch":"^2.x","@types/uuid":"^9.0.1","@types/whatwg-fetch":"^0.0.33","@types/ws":"^8.5.1","@vitest/coverage-v8":"~2.1.4","axios":"^1.7.7","typescript":"^5.5.3","vitest":"~2.1.4"},"peerDependencies":{"axios":"^1.7.1"},"cozePublishConfig":{"exports":{".":{"require":"./dist/cjs/index.cjs","import":"./dist/esm/index.js","types":"./dist/types/index.d.ts"},"./ws-tools":{"require":"./dist/cjs/ws-tools/index.cjs","import":"./dist/esm/ws-tools/index.js","types":"./dist/types/ws-tools/ws-tools/index.d.ts"}},"main":"dist/cjs/index.cjs","module":"dist/esm/index.js","types":"dist/types/index.d.ts"}}'); // CONCATENATED MODULE: ../coze-js/src/version.ts
4632
4664
  const { version: version_version } = package_namespaceObject;
4633
4665
  const getEnv = ()=>{
4634
4666
  const nodeVersion = process.version.slice(1); // Remove 'v' prefix
@@ -39477,6 +39509,10 @@ var event_handler_EventNames = /*#__PURE__*/ function(EventNames) {
39477
39509
  * zh: 客户端连接
39478
39510
  */ EventNames["CONNECTED"] = "client.connected";
39479
39511
  /**
39512
+ * en: Client connecting
39513
+ * zh: 客户端连接中
39514
+ */ EventNames["CONNECTING"] = "client.connecting";
39515
+ /**
39480
39516
  * en: Client interrupted
39481
39517
  * zh: 客户端中断
39482
39518
  */ EventNames["INTERRUPTED"] = "client.interrupted";
@@ -39529,6 +39565,10 @@ var event_handler_EventNames = /*#__PURE__*/ function(EventNames) {
39529
39565
  * zh: 视频输入设备改变
39530
39566
  */ EventNames["VIDEO_INPUT_DEVICE_CHANGED"] = "client.video.input.device.changed";
39531
39567
  /**
39568
+ * en: Network quality changed
39569
+ * zh: 网络质量改变
39570
+ */ EventNames["NETWORK_QUALITY"] = "client.network.quality";
39571
+ /**
39532
39572
  * en: Bot joined
39533
39573
  * zh: Bot 加入
39534
39574
  */ EventNames["BOT_JOIN"] = "server.bot.join";
@@ -39543,7 +39583,7 @@ var event_handler_EventNames = /*#__PURE__*/ function(EventNames) {
39543
39583
  /**
39544
39584
  * en: Audio speech stopped
39545
39585
  * zh: 停止说话
39546
- */ EventNames["AUDIO_SPEECH_STOPPED"] = "server.audio.speech_stopped";
39586
+ */ EventNames["AUDIO_AGENT_SPEECH_STOPPED"] = "server.audio.agent.speech_stopped";
39547
39587
  /**
39548
39588
  * en: Server error
39549
39589
  * zh: 服务端错误
@@ -39581,7 +39621,10 @@ class RealtimeEventHandler {
39581
39621
  const handlers = this.eventHandlers[eventName] || [];
39582
39622
  if (callback) {
39583
39623
  const index = handlers.indexOf(callback);
39584
- if (-1 === index) throw new RealtimeAPIError(error_RealtimeError.EVENT_HANDLER_ERROR, `Could not turn off specified event listener for "${eventName}": not found as a listener`);
39624
+ if (-1 === index) {
39625
+ console.warn(`Could not turn off specified event listener for "${eventName}": not found as a listener`);
39626
+ return;
39627
+ }
39585
39628
  handlers.splice(index, 1);
39586
39629
  } else delete this.eventHandlers[eventName];
39587
39630
  }
@@ -39595,7 +39638,7 @@ class RealtimeEventHandler {
39595
39638
  }
39596
39639
  dispatch(eventName, event) {
39597
39640
  let consoleLog = !(arguments.length > 2) || void 0 === arguments[2] || arguments[2];
39598
- if (consoleLog) this._log(`dispatch ${eventName} event`);
39641
+ if (consoleLog) this._log(`dispatch ${eventName} event`, event);
39599
39642
  const handlers = (this.eventHandlers[eventName] || []).slice();
39600
39643
  this._dispatchToHandlers(eventName, event, handlers);
39601
39644
  const allHandlers = (this.eventHandlers["realtime.event"] || []).slice();
@@ -39605,8 +39648,8 @@ class RealtimeEventHandler {
39605
39648
  const allServerHandlers = (this.eventHandlers["server.*"] || []).slice();
39606
39649
  this._dispatchToHandlers(eventName, event, allServerHandlers, 'server.');
39607
39650
  }
39608
- _log(message) {
39609
- if (this._debug) console.log(`[RealtimeClient] ${message}`);
39651
+ _log(message, event) {
39652
+ if (this._debug) console.log(`[RealtimeClient] ${message}`, event);
39610
39653
  }
39611
39654
  constructor(debug = false){
39612
39655
  this.eventHandlers = {};
@@ -42864,6 +42907,7 @@ class EngineClient extends RealtimeEventHandler {
42864
42907
  this.engine.on(index_esm_min_index.events.onUserJoined, this.handleUserJoin);
42865
42908
  this.engine.on(index_esm_min_index.events.onUserLeave, this.handleUserLeave);
42866
42909
  this.engine.on(index_esm_min_index.events.onError, this.handleEventError);
42910
+ this.engine.on(index_esm_min_index.events.onNetworkQuality, this.handleNetworkQuality);
42867
42911
  if (this._isSupportVideo) this.engine.on(index_esm_min_index.events.onPlayerEvent, this.handlePlayerEvent);
42868
42912
  if (this._debug) {
42869
42913
  this.engine.on(index_esm_min_index.events.onLocalAudioPropertiesReport, this.handleLocalAudioPropertiesReport);
@@ -42875,6 +42919,7 @@ class EngineClient extends RealtimeEventHandler {
42875
42919
  this.engine.off(index_esm_min_index.events.onUserJoined, this.handleUserJoin);
42876
42920
  this.engine.off(index_esm_min_index.events.onUserLeave, this.handleUserLeave);
42877
42921
  this.engine.off(index_esm_min_index.events.onError, this.handleEventError);
42922
+ this.engine.off(index_esm_min_index.events.onNetworkQuality, this.handleNetworkQuality);
42878
42923
  if (this._isSupportVideo) this.engine.off(index_esm_min_index.events.onPlayerEvent, this.handlePlayerEvent);
42879
42924
  if (this._debug) {
42880
42925
  this.engine.off(index_esm_min_index.events.onLocalAudioPropertiesReport, this.handleLocalAudioPropertiesReport);
@@ -42919,6 +42964,12 @@ class EngineClient extends RealtimeEventHandler {
42919
42964
  handlePlayerEvent(event) {
42920
42965
  this.dispatch(event_handler_EventNames.PLAYER_EVENT, event);
42921
42966
  }
42967
+ handleNetworkQuality(uplinkNetworkQuality, downlinkNetworkQuality) {
42968
+ this.dispatch(event_handler_EventNames.NETWORK_QUALITY, {
42969
+ uplinkNetworkQuality,
42970
+ downlinkNetworkQuality
42971
+ });
42972
+ }
42922
42973
  async joinRoom(options) {
42923
42974
  const { token, roomId, uid, audioMutedDefault, videoOnDefault, isAutoSubscribeAudio } = options;
42924
42975
  try {
@@ -42985,11 +43036,10 @@ class EngineClient extends RealtimeEventHandler {
42985
43036
  }
42986
43037
  async disconnect() {
42987
43038
  try {
42988
- if (this._isSupportVideo) await this.changeVideoState(false);
42989
- await this.changeAudioState(false);
42990
- await this.engine.unpublishStream(MediaType$1.AUDIO);
42991
43039
  await this.engine.leaveRoom();
42992
43040
  this.removeEventListener();
43041
+ this.clearEventHandlers();
43042
+ index_esm_min_index.destroyEngine(this.engine);
42993
43043
  } catch (e) {
42994
43044
  this.dispatch(event_handler_EventNames.ERROR, e);
42995
43045
  throw e;
@@ -43110,6 +43160,7 @@ class EngineClient extends RealtimeEventHandler {
43110
43160
  this.handleUserLeave = this.handleUserLeave.bind(this);
43111
43161
  this.handleEventError = this.handleEventError.bind(this);
43112
43162
  this.handlePlayerEvent = this.handlePlayerEvent.bind(this);
43163
+ this.handleNetworkQuality = this.handleNetworkQuality.bind(this);
43113
43164
  // Debug only
43114
43165
  this.handleLocalAudioPropertiesReport = this.handleLocalAudioPropertiesReport.bind(this);
43115
43166
  this.handleRemoteAudioPropertiesReport = this.handleRemoteAudioPropertiesReport.bind(this);
@@ -43117,6 +43168,8 @@ class EngineClient extends RealtimeEventHandler {
43117
43168
  this._videoConfig = videoConfig;
43118
43169
  }
43119
43170
  }
43171
+ // Only use for test
43172
+ const TEST_APP_ID = '6705332c79516e015e3e5f0c';
43120
43173
  class RealtimeClient extends RealtimeEventHandler {
43121
43174
  /**
43122
43175
  * en: Establish a connection to the Coze API and join the room
@@ -43124,22 +43177,38 @@ class RealtimeClient extends RealtimeEventHandler {
43124
43177
  * zh: 建立与 Coze API 的连接并加入房间
43125
43178
  */ async connect() {
43126
43179
  var _this__config_videoConfig;
43127
- const { botId, conversationId, voiceId } = this._config;
43180
+ const { botId, conversationId, voiceId, getRoomInfo } = this._config;
43181
+ this.dispatch(event_handler_EventNames.CONNECTING, {});
43128
43182
  let roomInfo;
43129
43183
  try {
43130
43184
  // Step1 get token
43131
- roomInfo = await this._api.audio.rooms.create({
43132
- bot_id: botId,
43133
- conversation_id: conversationId || void 0,
43134
- voice_id: voiceId && voiceId.length > 0 ? voiceId : void 0,
43135
- connector_id: this._config.connectorId,
43136
- uid: this._config.userId || void 0,
43137
- workflow_id: this._config.workflowId || void 0
43138
- });
43185
+ if (getRoomInfo) roomInfo = await getRoomInfo();
43186
+ else {
43187
+ let config;
43188
+ if (this._config.videoConfig) config = isScreenShareDevice(this._config.videoConfig.videoInputDeviceId) ? {
43189
+ video_config: {
43190
+ stream_video_type: 'screen'
43191
+ }
43192
+ } : {
43193
+ video_config: {
43194
+ stream_video_type: 'main'
43195
+ }
43196
+ };
43197
+ roomInfo = await this._api.audio.rooms.create({
43198
+ bot_id: botId,
43199
+ conversation_id: conversationId || void 0,
43200
+ voice_id: voiceId && voiceId.length > 0 ? voiceId : void 0,
43201
+ connector_id: this._config.connectorId,
43202
+ uid: this._config.userId || void 0,
43203
+ workflow_id: this._config.workflowId || void 0,
43204
+ config
43205
+ });
43206
+ }
43139
43207
  } catch (error) {
43140
43208
  this.dispatch(event_handler_EventNames.ERROR, error);
43141
43209
  throw new RealtimeAPIError(error_RealtimeError.CREATE_ROOM_ERROR, error instanceof Error ? error.message : 'Unknown error', error);
43142
43210
  }
43211
+ this._isTestEnv = TEST_APP_ID === roomInfo.app_id;
43143
43212
  // Step2 create engine
43144
43213
  this._client = new EngineClient(roomInfo.app_id, this._config.debug, this._isTestEnv, this._isSupportVideo, this._config.videoConfig);
43145
43214
  // Step3 bind engine events
@@ -43194,6 +43263,7 @@ class RealtimeClient extends RealtimeEventHandler {
43194
43263
  var _this__client;
43195
43264
  await (null === (_this__client = this._client) || void 0 === _this__client ? void 0 : _this__client.disconnect());
43196
43265
  this.isConnected = false;
43266
+ this._client = null;
43197
43267
  this.dispatch(event_handler_EventNames.DISCONNECTED, {});
43198
43268
  }
43199
43269
  /**
@@ -43346,7 +43416,6 @@ class RealtimeClient extends RealtimeEventHandler {
43346
43416
  baseURL: defaultBaseURL,
43347
43417
  allowPersonalAccessTokenInBrowser: this._config.allowPersonalAccessTokenInBrowser
43348
43418
  });
43349
- this._isTestEnv = 'https://api.coze.cn' !== defaultBaseURL;
43350
43419
  this._isSupportVideo = !!config.videoConfig;
43351
43420
  }
43352
43421
  }
package/dist/esm/index.js CHANGED
@@ -271,7 +271,7 @@ class error_APIError extends CozeError {
271
271
  }
272
272
  }
273
273
  class APIConnectionError extends error_APIError {
274
- constructor({ message, cause }){
274
+ constructor({ message }){
275
275
  super(void 0, void 0, message || 'Connection error.', void 0), this.status = void 0;
276
276
  // if (cause) {
277
277
  // this.cause = cause;
@@ -346,6 +346,12 @@ const handleAdditionalMessages = (additional_messages)=>null == additional_messa
346
346
  ...i,
347
347
  content: 'object' == typeof i.content ? JSON.stringify(i.content) : i.content
348
348
  }));
349
+ const handleParameters = (parameters)=>{
350
+ if (parameters) {
351
+ for (const [key, value] of Object.entries(parameters))if ('object' == typeof value) parameters[key] = JSON.stringify(value);
352
+ }
353
+ return parameters;
354
+ };
349
355
  class Chat extends APIResource {
350
356
  /**
351
357
  * Call the Chat API to send messages to a published Coze agent. | 调用此接口发起一次对话,支持添加上下文
@@ -368,6 +374,10 @@ class Chat extends APIResource {
368
374
  const payload = {
369
375
  ...rest,
370
376
  additional_messages: handleAdditionalMessages(params.additional_messages),
377
+ shortcut_command: params.shortcut_command ? {
378
+ ...params.shortcut_command,
379
+ parameters: handleParameters(params.shortcut_command.parameters)
380
+ } : void 0,
371
381
  stream: false
372
382
  };
373
383
  const result = await this._client.post(apiUrl, payload, false, options);
@@ -394,6 +404,10 @@ class Chat extends APIResource {
394
404
  const payload = {
395
405
  ...rest,
396
406
  additional_messages: handleAdditionalMessages(params.additional_messages),
407
+ shortcut_command: params.shortcut_command ? {
408
+ ...params.shortcut_command,
409
+ parameters: handleParameters(params.shortcut_command.parameters)
410
+ } : void 0,
397
411
  stream: false
398
412
  };
399
413
  const result = await this._client.post(apiUrl, payload, false, options);
@@ -432,6 +446,10 @@ class Chat extends APIResource {
432
446
  const payload = {
433
447
  ...rest,
434
448
  additional_messages: handleAdditionalMessages(params.additional_messages),
449
+ shortcut_command: params.shortcut_command ? {
450
+ ...params.shortcut_command,
451
+ parameters: handleParameters(params.shortcut_command.parameters)
452
+ } : void 0,
435
453
  stream: true
436
454
  };
437
455
  const result = await this._client.post(apiUrl, payload, true, options);
@@ -3506,6 +3524,17 @@ class Runs extends APIResource {
3506
3524
  const response = await this._client.post(apiUrl, params, false, options);
3507
3525
  return response;
3508
3526
  }
3527
+ /**
3528
+ * Get the workflow run history | 工作流异步运行后,查看执行结果
3529
+ * @docs zh: https://www.coze.cn/open/docs/developer_guides/workflow_history
3530
+ * @param workflowId - Required The ID of the workflow. | 必选 工作流 ID。
3531
+ * @param executeId - Required The ID of the workflow execution. | 必选 工作流执行 ID。
3532
+ * @returns WorkflowExecuteHistory[] | 工作流执行历史
3533
+ */ async history(workflowId, executeId, options) {
3534
+ const apiUrl = `/v1/workflows/${workflowId}/run_histories/${executeId}`;
3535
+ const response = await this._client.get(apiUrl, void 0, false, options);
3536
+ return response.data;
3537
+ }
3509
3538
  }
3510
3539
  class WorkflowEvent {
3511
3540
  constructor(id, event, data){
@@ -3667,7 +3696,7 @@ class documents_Documents extends APIResource {
3667
3696
  * @returns ListDocumentData | 知识库文件列表
3668
3697
  */ async list(params, options) {
3669
3698
  const apiUrl = '/open_api/knowledge/document/list';
3670
- const response = await this._client.get(apiUrl, params, false, mergeConfig(options, {
3699
+ const response = await this._client.post(apiUrl, params, false, mergeConfig(options, {
3671
3700
  headers: documents_documents_headers
3672
3701
  }));
3673
3702
  return response;
@@ -4584,6 +4613,8 @@ class WebSocketAPI {
4584
4613
  });
4585
4614
  this.rws.addEventListener('error', (event)=>{
4586
4615
  var _event_target__req_res, _event_target__req, _event_target, _event_target__req_res1, _event_target__req1, _event_target1, _this_onerror, _this;
4616
+ const { readyState } = this.rws;
4617
+ if (3 === readyState) return;
4587
4618
  const statusCode = null === (_event_target = event.target) || void 0 === _event_target ? void 0 : null === (_event_target__req = _event_target._req) || void 0 === _event_target__req ? void 0 : null === (_event_target__req_res = _event_target__req.res) || void 0 === _event_target__req_res ? void 0 : _event_target__req_res.statusCode;
4588
4619
  const rawHeaders = (null === (_event_target1 = event.target) || void 0 === _event_target1 ? void 0 : null === (_event_target__req1 = _event_target1._req) || void 0 === _event_target__req1 ? void 0 : null === (_event_target__req_res1 = _event_target__req1.res) || void 0 === _event_target__req_res1 ? void 0 : _event_target__req_res1.rawHeaders) || [];
4589
4620
  const logidIndex = rawHeaders.findIndex((header)=>'X-Tt-Logid' === header);
@@ -4607,7 +4638,8 @@ class WebSocketAPI {
4607
4638
  error.data.msg = 'Forbidden';
4608
4639
  } else {
4609
4640
  error.data.code = 500;
4610
- error.data.msg = String(null == event ? void 0 : event.error) || 'WebSocket error';
4641
+ var _event_error;
4642
+ error.data.msg = String(null !== (_event_error = null == event ? void 0 : event.error) && void 0 !== _event_error ? _event_error : '') || 'WebSocket error';
4611
4643
  }
4612
4644
  null === (_this_onerror = (_this = this).onerror) || void 0 === _this_onerror || _this_onerror.call(_this, error, event);
4613
4645
  });
@@ -4616,7 +4648,7 @@ class WebSocketAPI {
4616
4648
  // EXTERNAL MODULE: os (ignored)
4617
4649
  var os_ignored_ = __webpack_require__("?9050");
4618
4650
  var os_ignored_default = /*#__PURE__*/ __webpack_require__.n(os_ignored_);
4619
- var package_namespaceObject = JSON.parse('{"name":"@coze/api","version":"1.0.20","description":"Official Coze Node.js SDK for seamless AI integration into your applications | 扣子官方 Node.js SDK,助您轻松集成 AI 能力到应用中","keywords":["coze","ai","nodejs","sdk","chatbot","typescript"],"homepage":"https://github.com/coze-dev/coze-js/tree/main/packages/coze-js","bugs":{"url":"https://github.com/coze-dev/coze-js/issues"},"repository":{"type":"git","url":"https://github.com/coze-dev/coze-js.git","directory":"packages/coze-js"},"license":"MIT","author":"Leeight <leeight@gmail.com>","type":"module","exports":{".":"./src/index.ts"},"main":"src/index.ts","module":"src/index.ts","browser":{"crypto":false,"os":false,"jsonwebtoken":false,"node-fetch":false},"types":"src/index.ts","files":["dist","LICENSE","README.md","README.zh-CN.md"],"scripts":{"build":"rslib build","format":"prettier --write .","lint":"eslint ./ --cache --quiet","start":"rslib build -w","test":"vitest","test:cov":"vitest --coverage --run"},"dependencies":{"jsonwebtoken":"^9.0.2","node-fetch":"^2.x","reconnecting-websocket":"^4.4.0","ws":"^8.11.0"},"devDependencies":{"@coze-infra/eslint-config":"workspace:*","@coze-infra/ts-config":"workspace:*","@coze-infra/vitest-config":"workspace:*","@rslib/core":"0.0.18","@swc/core":"^1.3.14","@types/jsonwebtoken":"^9.0.0","@types/node":"^20","@types/node-fetch":"^2.x","@types/uuid":"^9.0.1","@types/whatwg-fetch":"^0.0.33","@types/ws":"^8.5.1","@vitest/coverage-v8":"~2.1.4","axios":"^1.7.7","typescript":"^5.5.3","vitest":"~2.1.4"},"peerDependencies":{"axios":"^1.7.1"},"cozePublishConfig":{"exports":{".":{"require":"./dist/cjs/index.cjs","import":"./dist/esm/index.js","types":"./dist/types/index.d.ts"}},"main":"dist/cjs/index.cjs","module":"dist/esm/index.js","types":"dist/types/index.d.ts"}}'); // CONCATENATED MODULE: ../coze-js/src/version.ts
4651
+ var package_namespaceObject = JSON.parse('{"name":"@coze/api","version":"1.1.0-beta.6","description":"Official Coze Node.js SDK for seamless AI integration into your applications | 扣子官方 Node.js SDK,助您轻松集成 AI 能力到应用中","keywords":["coze","ai","nodejs","sdk","chatbot","typescript"],"homepage":"https://github.com/coze-dev/coze-js/tree/main/packages/coze-js","bugs":{"url":"https://github.com/coze-dev/coze-js/issues"},"repository":{"type":"git","url":"https://github.com/coze-dev/coze-js.git","directory":"packages/coze-js"},"license":"MIT","author":"Leeight <leeight@gmail.com>","exports":{".":"./src/index.ts","./ws-tools":"./src/ws-tools/index.ts"},"main":"src/index.ts","module":"src/index.ts","browser":{"crypto":false,"os":false,"jsonwebtoken":false,"node-fetch":false},"typesVersions":{"*":{".":["dist/types/index.d.ts"],"ws-tools":["dist/types/ws-tools/ws-tools/index.d.ts"]}},"files":["dist","LICENSE","README.md","README.zh-CN.md"],"scripts":{"build":"rslib build","format":"prettier --write .","lint":"eslint ./ --cache --quiet","start":"rslib build -w","test":"vitest","test:cov":"vitest --coverage --run"},"dependencies":{"jsonwebtoken":"^9.0.2","node-fetch":"^2.x","reconnecting-websocket":"^4.4.0","uuid":"^10.0.0","ws":"^8.11.0"},"devDependencies":{"@coze-infra/eslint-config":"workspace:*","@coze-infra/ts-config":"workspace:*","@coze-infra/vitest-config":"workspace:*","@rslib/core":"0.0.18","@swc/core":"^1.3.14","@types/jsonwebtoken":"^9.0.0","@types/node":"^20","@types/node-fetch":"^2.x","@types/uuid":"^9.0.1","@types/whatwg-fetch":"^0.0.33","@types/ws":"^8.5.1","@vitest/coverage-v8":"~2.1.4","axios":"^1.7.7","typescript":"^5.5.3","vitest":"~2.1.4"},"peerDependencies":{"axios":"^1.7.1"},"cozePublishConfig":{"exports":{".":{"require":"./dist/cjs/index.cjs","import":"./dist/esm/index.js","types":"./dist/types/index.d.ts"},"./ws-tools":{"require":"./dist/cjs/ws-tools/index.cjs","import":"./dist/esm/ws-tools/index.js","types":"./dist/types/ws-tools/ws-tools/index.d.ts"}},"main":"dist/cjs/index.cjs","module":"dist/esm/index.js","types":"dist/types/index.d.ts"}}'); // CONCATENATED MODULE: ../coze-js/src/version.ts
4620
4652
  const { version: version_version } = package_namespaceObject;
4621
4653
  const getEnv = ()=>{
4622
4654
  const nodeVersion = process.version.slice(1); // Remove 'v' prefix
@@ -39465,6 +39497,10 @@ var event_handler_EventNames = /*#__PURE__*/ function(EventNames) {
39465
39497
  * zh: 客户端连接
39466
39498
  */ EventNames["CONNECTED"] = "client.connected";
39467
39499
  /**
39500
+ * en: Client connecting
39501
+ * zh: 客户端连接中
39502
+ */ EventNames["CONNECTING"] = "client.connecting";
39503
+ /**
39468
39504
  * en: Client interrupted
39469
39505
  * zh: 客户端中断
39470
39506
  */ EventNames["INTERRUPTED"] = "client.interrupted";
@@ -39517,6 +39553,10 @@ var event_handler_EventNames = /*#__PURE__*/ function(EventNames) {
39517
39553
  * zh: 视频输入设备改变
39518
39554
  */ EventNames["VIDEO_INPUT_DEVICE_CHANGED"] = "client.video.input.device.changed";
39519
39555
  /**
39556
+ * en: Network quality changed
39557
+ * zh: 网络质量改变
39558
+ */ EventNames["NETWORK_QUALITY"] = "client.network.quality";
39559
+ /**
39520
39560
  * en: Bot joined
39521
39561
  * zh: Bot 加入
39522
39562
  */ EventNames["BOT_JOIN"] = "server.bot.join";
@@ -39531,7 +39571,7 @@ var event_handler_EventNames = /*#__PURE__*/ function(EventNames) {
39531
39571
  /**
39532
39572
  * en: Audio speech stopped
39533
39573
  * zh: 停止说话
39534
- */ EventNames["AUDIO_SPEECH_STOPPED"] = "server.audio.speech_stopped";
39574
+ */ EventNames["AUDIO_AGENT_SPEECH_STOPPED"] = "server.audio.agent.speech_stopped";
39535
39575
  /**
39536
39576
  * en: Server error
39537
39577
  * zh: 服务端错误
@@ -39569,7 +39609,10 @@ class RealtimeEventHandler {
39569
39609
  const handlers = this.eventHandlers[eventName] || [];
39570
39610
  if (callback) {
39571
39611
  const index = handlers.indexOf(callback);
39572
- if (-1 === index) throw new RealtimeAPIError(error_RealtimeError.EVENT_HANDLER_ERROR, `Could not turn off specified event listener for "${eventName}": not found as a listener`);
39612
+ if (-1 === index) {
39613
+ console.warn(`Could not turn off specified event listener for "${eventName}": not found as a listener`);
39614
+ return;
39615
+ }
39573
39616
  handlers.splice(index, 1);
39574
39617
  } else delete this.eventHandlers[eventName];
39575
39618
  }
@@ -39583,7 +39626,7 @@ class RealtimeEventHandler {
39583
39626
  }
39584
39627
  dispatch(eventName, event) {
39585
39628
  let consoleLog = !(arguments.length > 2) || void 0 === arguments[2] || arguments[2];
39586
- if (consoleLog) this._log(`dispatch ${eventName} event`);
39629
+ if (consoleLog) this._log(`dispatch ${eventName} event`, event);
39587
39630
  const handlers = (this.eventHandlers[eventName] || []).slice();
39588
39631
  this._dispatchToHandlers(eventName, event, handlers);
39589
39632
  const allHandlers = (this.eventHandlers["realtime.event"] || []).slice();
@@ -39593,8 +39636,8 @@ class RealtimeEventHandler {
39593
39636
  const allServerHandlers = (this.eventHandlers["server.*"] || []).slice();
39594
39637
  this._dispatchToHandlers(eventName, event, allServerHandlers, 'server.');
39595
39638
  }
39596
- _log(message) {
39597
- if (this._debug) console.log(`[RealtimeClient] ${message}`);
39639
+ _log(message, event) {
39640
+ if (this._debug) console.log(`[RealtimeClient] ${message}`, event);
39598
39641
  }
39599
39642
  constructor(debug = false){
39600
39643
  this.eventHandlers = {};
@@ -42852,6 +42895,7 @@ class EngineClient extends RealtimeEventHandler {
42852
42895
  this.engine.on(index_esm_min_index.events.onUserJoined, this.handleUserJoin);
42853
42896
  this.engine.on(index_esm_min_index.events.onUserLeave, this.handleUserLeave);
42854
42897
  this.engine.on(index_esm_min_index.events.onError, this.handleEventError);
42898
+ this.engine.on(index_esm_min_index.events.onNetworkQuality, this.handleNetworkQuality);
42855
42899
  if (this._isSupportVideo) this.engine.on(index_esm_min_index.events.onPlayerEvent, this.handlePlayerEvent);
42856
42900
  if (this._debug) {
42857
42901
  this.engine.on(index_esm_min_index.events.onLocalAudioPropertiesReport, this.handleLocalAudioPropertiesReport);
@@ -42863,6 +42907,7 @@ class EngineClient extends RealtimeEventHandler {
42863
42907
  this.engine.off(index_esm_min_index.events.onUserJoined, this.handleUserJoin);
42864
42908
  this.engine.off(index_esm_min_index.events.onUserLeave, this.handleUserLeave);
42865
42909
  this.engine.off(index_esm_min_index.events.onError, this.handleEventError);
42910
+ this.engine.off(index_esm_min_index.events.onNetworkQuality, this.handleNetworkQuality);
42866
42911
  if (this._isSupportVideo) this.engine.off(index_esm_min_index.events.onPlayerEvent, this.handlePlayerEvent);
42867
42912
  if (this._debug) {
42868
42913
  this.engine.off(index_esm_min_index.events.onLocalAudioPropertiesReport, this.handleLocalAudioPropertiesReport);
@@ -42907,6 +42952,12 @@ class EngineClient extends RealtimeEventHandler {
42907
42952
  handlePlayerEvent(event) {
42908
42953
  this.dispatch(event_handler_EventNames.PLAYER_EVENT, event);
42909
42954
  }
42955
+ handleNetworkQuality(uplinkNetworkQuality, downlinkNetworkQuality) {
42956
+ this.dispatch(event_handler_EventNames.NETWORK_QUALITY, {
42957
+ uplinkNetworkQuality,
42958
+ downlinkNetworkQuality
42959
+ });
42960
+ }
42910
42961
  async joinRoom(options) {
42911
42962
  const { token, roomId, uid, audioMutedDefault, videoOnDefault, isAutoSubscribeAudio } = options;
42912
42963
  try {
@@ -42973,11 +43024,10 @@ class EngineClient extends RealtimeEventHandler {
42973
43024
  }
42974
43025
  async disconnect() {
42975
43026
  try {
42976
- if (this._isSupportVideo) await this.changeVideoState(false);
42977
- await this.changeAudioState(false);
42978
- await this.engine.unpublishStream(MediaType$1.AUDIO);
42979
43027
  await this.engine.leaveRoom();
42980
43028
  this.removeEventListener();
43029
+ this.clearEventHandlers();
43030
+ index_esm_min_index.destroyEngine(this.engine);
42981
43031
  } catch (e) {
42982
43032
  this.dispatch(event_handler_EventNames.ERROR, e);
42983
43033
  throw e;
@@ -43098,6 +43148,7 @@ class EngineClient extends RealtimeEventHandler {
43098
43148
  this.handleUserLeave = this.handleUserLeave.bind(this);
43099
43149
  this.handleEventError = this.handleEventError.bind(this);
43100
43150
  this.handlePlayerEvent = this.handlePlayerEvent.bind(this);
43151
+ this.handleNetworkQuality = this.handleNetworkQuality.bind(this);
43101
43152
  // Debug only
43102
43153
  this.handleLocalAudioPropertiesReport = this.handleLocalAudioPropertiesReport.bind(this);
43103
43154
  this.handleRemoteAudioPropertiesReport = this.handleRemoteAudioPropertiesReport.bind(this);
@@ -43105,6 +43156,8 @@ class EngineClient extends RealtimeEventHandler {
43105
43156
  this._videoConfig = videoConfig;
43106
43157
  }
43107
43158
  }
43159
+ // Only use for test
43160
+ const TEST_APP_ID = '6705332c79516e015e3e5f0c';
43108
43161
  class RealtimeClient extends RealtimeEventHandler {
43109
43162
  /**
43110
43163
  * en: Establish a connection to the Coze API and join the room
@@ -43112,22 +43165,38 @@ class RealtimeClient extends RealtimeEventHandler {
43112
43165
  * zh: 建立与 Coze API 的连接并加入房间
43113
43166
  */ async connect() {
43114
43167
  var _this__config_videoConfig;
43115
- const { botId, conversationId, voiceId } = this._config;
43168
+ const { botId, conversationId, voiceId, getRoomInfo } = this._config;
43169
+ this.dispatch(event_handler_EventNames.CONNECTING, {});
43116
43170
  let roomInfo;
43117
43171
  try {
43118
43172
  // Step1 get token
43119
- roomInfo = await this._api.audio.rooms.create({
43120
- bot_id: botId,
43121
- conversation_id: conversationId || void 0,
43122
- voice_id: voiceId && voiceId.length > 0 ? voiceId : void 0,
43123
- connector_id: this._config.connectorId,
43124
- uid: this._config.userId || void 0,
43125
- workflow_id: this._config.workflowId || void 0
43126
- });
43173
+ if (getRoomInfo) roomInfo = await getRoomInfo();
43174
+ else {
43175
+ let config;
43176
+ if (this._config.videoConfig) config = isScreenShareDevice(this._config.videoConfig.videoInputDeviceId) ? {
43177
+ video_config: {
43178
+ stream_video_type: 'screen'
43179
+ }
43180
+ } : {
43181
+ video_config: {
43182
+ stream_video_type: 'main'
43183
+ }
43184
+ };
43185
+ roomInfo = await this._api.audio.rooms.create({
43186
+ bot_id: botId,
43187
+ conversation_id: conversationId || void 0,
43188
+ voice_id: voiceId && voiceId.length > 0 ? voiceId : void 0,
43189
+ connector_id: this._config.connectorId,
43190
+ uid: this._config.userId || void 0,
43191
+ workflow_id: this._config.workflowId || void 0,
43192
+ config
43193
+ });
43194
+ }
43127
43195
  } catch (error) {
43128
43196
  this.dispatch(event_handler_EventNames.ERROR, error);
43129
43197
  throw new RealtimeAPIError(error_RealtimeError.CREATE_ROOM_ERROR, error instanceof Error ? error.message : 'Unknown error', error);
43130
43198
  }
43199
+ this._isTestEnv = TEST_APP_ID === roomInfo.app_id;
43131
43200
  // Step2 create engine
43132
43201
  this._client = new EngineClient(roomInfo.app_id, this._config.debug, this._isTestEnv, this._isSupportVideo, this._config.videoConfig);
43133
43202
  // Step3 bind engine events
@@ -43182,6 +43251,7 @@ class RealtimeClient extends RealtimeEventHandler {
43182
43251
  var _this__client;
43183
43252
  await (null === (_this__client = this._client) || void 0 === _this__client ? void 0 : _this__client.disconnect());
43184
43253
  this.isConnected = false;
43254
+ this._client = null;
43185
43255
  this.dispatch(event_handler_EventNames.DISCONNECTED, {});
43186
43256
  }
43187
43257
  /**
@@ -43334,7 +43404,6 @@ class RealtimeClient extends RealtimeEventHandler {
43334
43404
  baseURL: defaultBaseURL,
43335
43405
  allowPersonalAccessTokenInBrowser: this._config.allowPersonalAccessTokenInBrowser
43336
43406
  });
43337
- this._isTestEnv = 'https://api.coze.cn' !== defaultBaseURL;
43338
43407
  this._isSupportVideo = !!config.videoConfig;
43339
43408
  }
43340
43409
  }
@@ -1,4 +1,4 @@
1
- import { type AudioPropertiesConfig, type IRTCEngine, type onUserJoinedEvent, type onUserLeaveEvent, type UserMessageEvent } from '@volcengine/rtc';
1
+ import { type AudioPropertiesConfig, type IRTCEngine, type NetworkQuality, type onUserJoinedEvent, type onUserLeaveEvent, type UserMessageEvent } from '@volcengine/rtc';
2
2
  import { RealtimeEventHandler } from './event-handler';
3
3
  import { type VideoConfig } from '.';
4
4
  export declare class EngineClient extends RealtimeEventHandler {
@@ -18,6 +18,7 @@ export declare class EngineClient extends RealtimeEventHandler {
18
18
  handleUserJoin(event: onUserJoinedEvent): void;
19
19
  handleUserLeave(event: onUserLeaveEvent): void;
20
20
  handlePlayerEvent(event: unknown): void;
21
+ handleNetworkQuality(uplinkNetworkQuality: NetworkQuality, downlinkNetworkQuality: NetworkQuality): void;
21
22
  joinRoom(options: {
22
23
  token: string;
23
24
  roomId: string;
@@ -19,6 +19,11 @@ export declare enum EventNames {
19
19
  * zh: 客户端连接
20
20
  */
21
21
  CONNECTED = "client.connected",
22
+ /**
23
+ * en: Client connecting
24
+ * zh: 客户端连接中
25
+ */
26
+ CONNECTING = "client.connecting",
22
27
  /**
23
28
  * en: Client interrupted
24
29
  * zh: 客户端中断
@@ -84,6 +89,11 @@ export declare enum EventNames {
84
89
  * zh: 视频输入设备改变
85
90
  */
86
91
  VIDEO_INPUT_DEVICE_CHANGED = "client.video.input.device.changed",
92
+ /**
93
+ * en: Network quality changed
94
+ * zh: 网络质量改变
95
+ */
96
+ NETWORK_QUALITY = "client.network.quality",
87
97
  /**
88
98
  * en: Bot joined
89
99
  * zh: Bot 加入
@@ -103,7 +113,7 @@ export declare enum EventNames {
103
113
  * en: Audio speech stopped
104
114
  * zh: 停止说话
105
115
  */
106
- AUDIO_SPEECH_STOPPED = "server.audio.speech_stopped",
116
+ AUDIO_AGENT_SPEECH_STOPPED = "server.audio.agent.speech_stopped",
107
117
  /**
108
118
  * en: Server error
109
119
  * zh: 服务端错误
@@ -140,5 +150,5 @@ export declare class RealtimeEventHandler {
140
150
  off(eventName: string, callback: EventCallback): void;
141
151
  private _dispatchToHandlers;
142
152
  dispatch(eventName: string, event: unknown, consoleLog?: boolean): void;
143
- _log(message: string): void;
153
+ _log(message: string, event?: unknown): void;
144
154
  }
@@ -1,5 +1,5 @@
1
1
  import { type ScreenConfig, type AudioPropertiesConfig, type IRTCEngine } from '@volcengine/rtc';
2
- import { type GetToken } from '@coze/api';
2
+ import { type CreateRoomData, type GetToken } from '@coze/api';
3
3
  import * as RealtimeUtils from './utils';
4
4
  import { RealtimeEventHandler, EventNames } from './event-handler';
5
5
  import { RealtimeAPIError, RealtimeError } from './error';
@@ -18,6 +18,7 @@ export interface RealtimeClientConfig {
18
18
  workflowId?: string /** optional, Workflow Id */;
19
19
  baseURL?: string /** optional, defaults to "https://api.coze.cn" */;
20
20
  debug?: boolean /** optional, defaults to false */;
21
+ getRoomInfo?: () => Promise<CreateRoomData> /** optional, Customize get room info */;
21
22
  /** Whether Personal Access Tokens (PAT) are allowed in browser environments */
22
23
  allowPersonalAccessTokenInBrowser?: boolean;
23
24
  /** Whether to mute by default, defaults to false
@@ -30,7 +31,7 @@ export interface RealtimeClientConfig {
30
31
  isAutoSubscribeAudio?: boolean /** optional, Whether to automatically subscribe to bot reply audio streams, defaults to true */;
31
32
  }
32
33
  declare class RealtimeClient extends RealtimeEventHandler {
33
- private _config;
34
+ _config: RealtimeClientConfig;
34
35
  private _client;
35
36
  isConnected: boolean;
36
37
  private _api;
package/dist/umd/index.js CHANGED
@@ -289,7 +289,7 @@
289
289
  }
290
290
  }
291
291
  class APIConnectionError extends error_APIError {
292
- constructor({ message, cause }){
292
+ constructor({ message }){
293
293
  super(void 0, void 0, message || 'Connection error.', void 0), this.status = void 0;
294
294
  // if (cause) {
295
295
  // this.cause = cause;
@@ -364,6 +364,12 @@
364
364
  ...i,
365
365
  content: 'object' == typeof i.content ? JSON.stringify(i.content) : i.content
366
366
  }));
367
+ const handleParameters = (parameters)=>{
368
+ if (parameters) {
369
+ for (const [key, value] of Object.entries(parameters))if ('object' == typeof value) parameters[key] = JSON.stringify(value);
370
+ }
371
+ return parameters;
372
+ };
367
373
  class Chat extends APIResource {
368
374
  /**
369
375
  * Call the Chat API to send messages to a published Coze agent. | 调用此接口发起一次对话,支持添加上下文
@@ -386,6 +392,10 @@
386
392
  const payload = {
387
393
  ...rest,
388
394
  additional_messages: handleAdditionalMessages(params.additional_messages),
395
+ shortcut_command: params.shortcut_command ? {
396
+ ...params.shortcut_command,
397
+ parameters: handleParameters(params.shortcut_command.parameters)
398
+ } : void 0,
389
399
  stream: false
390
400
  };
391
401
  const result = await this._client.post(apiUrl, payload, false, options);
@@ -412,6 +422,10 @@
412
422
  const payload = {
413
423
  ...rest,
414
424
  additional_messages: handleAdditionalMessages(params.additional_messages),
425
+ shortcut_command: params.shortcut_command ? {
426
+ ...params.shortcut_command,
427
+ parameters: handleParameters(params.shortcut_command.parameters)
428
+ } : void 0,
415
429
  stream: false
416
430
  };
417
431
  const result = await this._client.post(apiUrl, payload, false, options);
@@ -450,6 +464,10 @@
450
464
  const payload = {
451
465
  ...rest,
452
466
  additional_messages: handleAdditionalMessages(params.additional_messages),
467
+ shortcut_command: params.shortcut_command ? {
468
+ ...params.shortcut_command,
469
+ parameters: handleParameters(params.shortcut_command.parameters)
470
+ } : void 0,
453
471
  stream: true
454
472
  };
455
473
  const result = await this._client.post(apiUrl, payload, true, options);
@@ -3524,6 +3542,17 @@
3524
3542
  const response = await this._client.post(apiUrl, params, false, options);
3525
3543
  return response;
3526
3544
  }
3545
+ /**
3546
+ * Get the workflow run history | 工作流异步运行后,查看执行结果
3547
+ * @docs zh: https://www.coze.cn/open/docs/developer_guides/workflow_history
3548
+ * @param workflowId - Required The ID of the workflow. | 必选 工作流 ID。
3549
+ * @param executeId - Required The ID of the workflow execution. | 必选 工作流执行 ID。
3550
+ * @returns WorkflowExecuteHistory[] | 工作流执行历史
3551
+ */ async history(workflowId, executeId, options) {
3552
+ const apiUrl = `/v1/workflows/${workflowId}/run_histories/${executeId}`;
3553
+ const response = await this._client.get(apiUrl, void 0, false, options);
3554
+ return response.data;
3555
+ }
3527
3556
  }
3528
3557
  class WorkflowEvent {
3529
3558
  constructor(id, event, data){
@@ -3685,7 +3714,7 @@
3685
3714
  * @returns ListDocumentData | 知识库文件列表
3686
3715
  */ async list(params, options) {
3687
3716
  const apiUrl = '/open_api/knowledge/document/list';
3688
- const response = await this._client.get(apiUrl, params, false, mergeConfig(options, {
3717
+ const response = await this._client.post(apiUrl, params, false, mergeConfig(options, {
3689
3718
  headers: documents_documents_headers
3690
3719
  }));
3691
3720
  return response;
@@ -4602,6 +4631,8 @@ and limitations under the License.
4602
4631
  });
4603
4632
  this.rws.addEventListener('error', (event)=>{
4604
4633
  var _event_target__req_res, _event_target__req, _event_target, _event_target__req_res1, _event_target__req1, _event_target1, _this_onerror, _this;
4634
+ const { readyState } = this.rws;
4635
+ if (3 === readyState) return;
4605
4636
  const statusCode = null === (_event_target = event.target) || void 0 === _event_target ? void 0 : null === (_event_target__req = _event_target._req) || void 0 === _event_target__req ? void 0 : null === (_event_target__req_res = _event_target__req.res) || void 0 === _event_target__req_res ? void 0 : _event_target__req_res.statusCode;
4606
4637
  const rawHeaders = (null === (_event_target1 = event.target) || void 0 === _event_target1 ? void 0 : null === (_event_target__req1 = _event_target1._req) || void 0 === _event_target__req1 ? void 0 : null === (_event_target__req_res1 = _event_target__req1.res) || void 0 === _event_target__req_res1 ? void 0 : _event_target__req_res1.rawHeaders) || [];
4607
4638
  const logidIndex = rawHeaders.findIndex((header)=>'X-Tt-Logid' === header);
@@ -4625,7 +4656,8 @@ and limitations under the License.
4625
4656
  error.data.msg = 'Forbidden';
4626
4657
  } else {
4627
4658
  error.data.code = 500;
4628
- error.data.msg = String(null == event ? void 0 : event.error) || 'WebSocket error';
4659
+ var _event_error;
4660
+ error.data.msg = String(null !== (_event_error = null == event ? void 0 : event.error) && void 0 !== _event_error ? _event_error : '') || 'WebSocket error';
4629
4661
  }
4630
4662
  null === (_this_onerror = (_this = this).onerror) || void 0 === _this_onerror || _this_onerror.call(_this, error, event);
4631
4663
  });
@@ -4634,7 +4666,7 @@ and limitations under the License.
4634
4666
  // EXTERNAL MODULE: os (ignored)
4635
4667
  var os_ignored_ = __webpack_require__("?9050");
4636
4668
  var os_ignored_default = /*#__PURE__*/ __webpack_require__.n(os_ignored_);
4637
- var package_namespaceObject = JSON.parse('{"name":"@coze/api","version":"1.0.20","description":"Official Coze Node.js SDK for seamless AI integration into your applications | 扣子官方 Node.js SDK,助您轻松集成 AI 能力到应用中","keywords":["coze","ai","nodejs","sdk","chatbot","typescript"],"homepage":"https://github.com/coze-dev/coze-js/tree/main/packages/coze-js","bugs":{"url":"https://github.com/coze-dev/coze-js/issues"},"repository":{"type":"git","url":"https://github.com/coze-dev/coze-js.git","directory":"packages/coze-js"},"license":"MIT","author":"Leeight <leeight@gmail.com>","type":"module","exports":{".":"./src/index.ts"},"main":"src/index.ts","module":"src/index.ts","browser":{"crypto":false,"os":false,"jsonwebtoken":false,"node-fetch":false},"types":"src/index.ts","files":["dist","LICENSE","README.md","README.zh-CN.md"],"scripts":{"build":"rslib build","format":"prettier --write .","lint":"eslint ./ --cache --quiet","start":"rslib build -w","test":"vitest","test:cov":"vitest --coverage --run"},"dependencies":{"jsonwebtoken":"^9.0.2","node-fetch":"^2.x","reconnecting-websocket":"^4.4.0","ws":"^8.11.0"},"devDependencies":{"@coze-infra/eslint-config":"workspace:*","@coze-infra/ts-config":"workspace:*","@coze-infra/vitest-config":"workspace:*","@rslib/core":"0.0.18","@swc/core":"^1.3.14","@types/jsonwebtoken":"^9.0.0","@types/node":"^20","@types/node-fetch":"^2.x","@types/uuid":"^9.0.1","@types/whatwg-fetch":"^0.0.33","@types/ws":"^8.5.1","@vitest/coverage-v8":"~2.1.4","axios":"^1.7.7","typescript":"^5.5.3","vitest":"~2.1.4"},"peerDependencies":{"axios":"^1.7.1"},"cozePublishConfig":{"exports":{".":{"require":"./dist/cjs/index.cjs","import":"./dist/esm/index.js","types":"./dist/types/index.d.ts"}},"main":"dist/cjs/index.cjs","module":"dist/esm/index.js","types":"dist/types/index.d.ts"}}'); // CONCATENATED MODULE: ../coze-js/src/version.ts
4669
+ var package_namespaceObject = JSON.parse('{"name":"@coze/api","version":"1.1.0-beta.6","description":"Official Coze Node.js SDK for seamless AI integration into your applications | 扣子官方 Node.js SDK,助您轻松集成 AI 能力到应用中","keywords":["coze","ai","nodejs","sdk","chatbot","typescript"],"homepage":"https://github.com/coze-dev/coze-js/tree/main/packages/coze-js","bugs":{"url":"https://github.com/coze-dev/coze-js/issues"},"repository":{"type":"git","url":"https://github.com/coze-dev/coze-js.git","directory":"packages/coze-js"},"license":"MIT","author":"Leeight <leeight@gmail.com>","exports":{".":"./src/index.ts","./ws-tools":"./src/ws-tools/index.ts"},"main":"src/index.ts","module":"src/index.ts","browser":{"crypto":false,"os":false,"jsonwebtoken":false,"node-fetch":false},"typesVersions":{"*":{".":["dist/types/index.d.ts"],"ws-tools":["dist/types/ws-tools/ws-tools/index.d.ts"]}},"files":["dist","LICENSE","README.md","README.zh-CN.md"],"scripts":{"build":"rslib build","format":"prettier --write .","lint":"eslint ./ --cache --quiet","start":"rslib build -w","test":"vitest","test:cov":"vitest --coverage --run"},"dependencies":{"jsonwebtoken":"^9.0.2","node-fetch":"^2.x","reconnecting-websocket":"^4.4.0","uuid":"^10.0.0","ws":"^8.11.0"},"devDependencies":{"@coze-infra/eslint-config":"workspace:*","@coze-infra/ts-config":"workspace:*","@coze-infra/vitest-config":"workspace:*","@rslib/core":"0.0.18","@swc/core":"^1.3.14","@types/jsonwebtoken":"^9.0.0","@types/node":"^20","@types/node-fetch":"^2.x","@types/uuid":"^9.0.1","@types/whatwg-fetch":"^0.0.33","@types/ws":"^8.5.1","@vitest/coverage-v8":"~2.1.4","axios":"^1.7.7","typescript":"^5.5.3","vitest":"~2.1.4"},"peerDependencies":{"axios":"^1.7.1"},"cozePublishConfig":{"exports":{".":{"require":"./dist/cjs/index.cjs","import":"./dist/esm/index.js","types":"./dist/types/index.d.ts"},"./ws-tools":{"require":"./dist/cjs/ws-tools/index.cjs","import":"./dist/esm/ws-tools/index.js","types":"./dist/types/ws-tools/ws-tools/index.d.ts"}},"main":"dist/cjs/index.cjs","module":"dist/esm/index.js","types":"dist/types/index.d.ts"}}'); // CONCATENATED MODULE: ../coze-js/src/version.ts
4638
4670
  const { version: version_version } = package_namespaceObject;
4639
4671
  const getEnv = ()=>{
4640
4672
  const nodeVersion = process.version.slice(1); // Remove 'v' prefix
@@ -39483,6 +39515,10 @@ and limitations under the License.
39483
39515
  * zh: 客户端连接
39484
39516
  */ EventNames["CONNECTED"] = "client.connected";
39485
39517
  /**
39518
+ * en: Client connecting
39519
+ * zh: 客户端连接中
39520
+ */ EventNames["CONNECTING"] = "client.connecting";
39521
+ /**
39486
39522
  * en: Client interrupted
39487
39523
  * zh: 客户端中断
39488
39524
  */ EventNames["INTERRUPTED"] = "client.interrupted";
@@ -39535,6 +39571,10 @@ and limitations under the License.
39535
39571
  * zh: 视频输入设备改变
39536
39572
  */ EventNames["VIDEO_INPUT_DEVICE_CHANGED"] = "client.video.input.device.changed";
39537
39573
  /**
39574
+ * en: Network quality changed
39575
+ * zh: 网络质量改变
39576
+ */ EventNames["NETWORK_QUALITY"] = "client.network.quality";
39577
+ /**
39538
39578
  * en: Bot joined
39539
39579
  * zh: Bot 加入
39540
39580
  */ EventNames["BOT_JOIN"] = "server.bot.join";
@@ -39549,7 +39589,7 @@ and limitations under the License.
39549
39589
  /**
39550
39590
  * en: Audio speech stopped
39551
39591
  * zh: 停止说话
39552
- */ EventNames["AUDIO_SPEECH_STOPPED"] = "server.audio.speech_stopped";
39592
+ */ EventNames["AUDIO_AGENT_SPEECH_STOPPED"] = "server.audio.agent.speech_stopped";
39553
39593
  /**
39554
39594
  * en: Server error
39555
39595
  * zh: 服务端错误
@@ -39587,7 +39627,10 @@ and limitations under the License.
39587
39627
  const handlers = this.eventHandlers[eventName] || [];
39588
39628
  if (callback) {
39589
39629
  const index = handlers.indexOf(callback);
39590
- if (-1 === index) throw new RealtimeAPIError(error_RealtimeError.EVENT_HANDLER_ERROR, `Could not turn off specified event listener for "${eventName}": not found as a listener`);
39630
+ if (-1 === index) {
39631
+ console.warn(`Could not turn off specified event listener for "${eventName}": not found as a listener`);
39632
+ return;
39633
+ }
39591
39634
  handlers.splice(index, 1);
39592
39635
  } else delete this.eventHandlers[eventName];
39593
39636
  }
@@ -39601,7 +39644,7 @@ and limitations under the License.
39601
39644
  }
39602
39645
  dispatch(eventName, event) {
39603
39646
  let consoleLog = !(arguments.length > 2) || void 0 === arguments[2] || arguments[2];
39604
- if (consoleLog) this._log(`dispatch ${eventName} event`);
39647
+ if (consoleLog) this._log(`dispatch ${eventName} event`, event);
39605
39648
  const handlers = (this.eventHandlers[eventName] || []).slice();
39606
39649
  this._dispatchToHandlers(eventName, event, handlers);
39607
39650
  const allHandlers = (this.eventHandlers["realtime.event"] || []).slice();
@@ -39611,8 +39654,8 @@ and limitations under the License.
39611
39654
  const allServerHandlers = (this.eventHandlers["server.*"] || []).slice();
39612
39655
  this._dispatchToHandlers(eventName, event, allServerHandlers, 'server.');
39613
39656
  }
39614
- _log(message) {
39615
- if (this._debug) console.log(`[RealtimeClient] ${message}`);
39657
+ _log(message, event) {
39658
+ if (this._debug) console.log(`[RealtimeClient] ${message}`, event);
39616
39659
  }
39617
39660
  constructor(debug = false){
39618
39661
  this.eventHandlers = {};
@@ -42870,6 +42913,7 @@ and limitations under the License.
42870
42913
  this.engine.on(index_esm_min_index.events.onUserJoined, this.handleUserJoin);
42871
42914
  this.engine.on(index_esm_min_index.events.onUserLeave, this.handleUserLeave);
42872
42915
  this.engine.on(index_esm_min_index.events.onError, this.handleEventError);
42916
+ this.engine.on(index_esm_min_index.events.onNetworkQuality, this.handleNetworkQuality);
42873
42917
  if (this._isSupportVideo) this.engine.on(index_esm_min_index.events.onPlayerEvent, this.handlePlayerEvent);
42874
42918
  if (this._debug) {
42875
42919
  this.engine.on(index_esm_min_index.events.onLocalAudioPropertiesReport, this.handleLocalAudioPropertiesReport);
@@ -42881,6 +42925,7 @@ and limitations under the License.
42881
42925
  this.engine.off(index_esm_min_index.events.onUserJoined, this.handleUserJoin);
42882
42926
  this.engine.off(index_esm_min_index.events.onUserLeave, this.handleUserLeave);
42883
42927
  this.engine.off(index_esm_min_index.events.onError, this.handleEventError);
42928
+ this.engine.off(index_esm_min_index.events.onNetworkQuality, this.handleNetworkQuality);
42884
42929
  if (this._isSupportVideo) this.engine.off(index_esm_min_index.events.onPlayerEvent, this.handlePlayerEvent);
42885
42930
  if (this._debug) {
42886
42931
  this.engine.off(index_esm_min_index.events.onLocalAudioPropertiesReport, this.handleLocalAudioPropertiesReport);
@@ -42925,6 +42970,12 @@ and limitations under the License.
42925
42970
  handlePlayerEvent(event) {
42926
42971
  this.dispatch(event_handler_EventNames.PLAYER_EVENT, event);
42927
42972
  }
42973
+ handleNetworkQuality(uplinkNetworkQuality, downlinkNetworkQuality) {
42974
+ this.dispatch(event_handler_EventNames.NETWORK_QUALITY, {
42975
+ uplinkNetworkQuality,
42976
+ downlinkNetworkQuality
42977
+ });
42978
+ }
42928
42979
  async joinRoom(options) {
42929
42980
  const { token, roomId, uid, audioMutedDefault, videoOnDefault, isAutoSubscribeAudio } = options;
42930
42981
  try {
@@ -42991,11 +43042,10 @@ and limitations under the License.
42991
43042
  }
42992
43043
  async disconnect() {
42993
43044
  try {
42994
- if (this._isSupportVideo) await this.changeVideoState(false);
42995
- await this.changeAudioState(false);
42996
- await this.engine.unpublishStream(MediaType$1.AUDIO);
42997
43045
  await this.engine.leaveRoom();
42998
43046
  this.removeEventListener();
43047
+ this.clearEventHandlers();
43048
+ index_esm_min_index.destroyEngine(this.engine);
42999
43049
  } catch (e) {
43000
43050
  this.dispatch(event_handler_EventNames.ERROR, e);
43001
43051
  throw e;
@@ -43116,6 +43166,7 @@ and limitations under the License.
43116
43166
  this.handleUserLeave = this.handleUserLeave.bind(this);
43117
43167
  this.handleEventError = this.handleEventError.bind(this);
43118
43168
  this.handlePlayerEvent = this.handlePlayerEvent.bind(this);
43169
+ this.handleNetworkQuality = this.handleNetworkQuality.bind(this);
43119
43170
  // Debug only
43120
43171
  this.handleLocalAudioPropertiesReport = this.handleLocalAudioPropertiesReport.bind(this);
43121
43172
  this.handleRemoteAudioPropertiesReport = this.handleRemoteAudioPropertiesReport.bind(this);
@@ -43123,6 +43174,8 @@ and limitations under the License.
43123
43174
  this._videoConfig = videoConfig;
43124
43175
  }
43125
43176
  }
43177
+ // Only use for test
43178
+ const TEST_APP_ID = '6705332c79516e015e3e5f0c';
43126
43179
  class RealtimeClient extends RealtimeEventHandler {
43127
43180
  /**
43128
43181
  * en: Establish a connection to the Coze API and join the room
@@ -43130,22 +43183,38 @@ and limitations under the License.
43130
43183
  * zh: 建立与 Coze API 的连接并加入房间
43131
43184
  */ async connect() {
43132
43185
  var _this__config_videoConfig;
43133
- const { botId, conversationId, voiceId } = this._config;
43186
+ const { botId, conversationId, voiceId, getRoomInfo } = this._config;
43187
+ this.dispatch(event_handler_EventNames.CONNECTING, {});
43134
43188
  let roomInfo;
43135
43189
  try {
43136
43190
  // Step1 get token
43137
- roomInfo = await this._api.audio.rooms.create({
43138
- bot_id: botId,
43139
- conversation_id: conversationId || void 0,
43140
- voice_id: voiceId && voiceId.length > 0 ? voiceId : void 0,
43141
- connector_id: this._config.connectorId,
43142
- uid: this._config.userId || void 0,
43143
- workflow_id: this._config.workflowId || void 0
43144
- });
43191
+ if (getRoomInfo) roomInfo = await getRoomInfo();
43192
+ else {
43193
+ let config;
43194
+ if (this._config.videoConfig) config = isScreenShareDevice(this._config.videoConfig.videoInputDeviceId) ? {
43195
+ video_config: {
43196
+ stream_video_type: 'screen'
43197
+ }
43198
+ } : {
43199
+ video_config: {
43200
+ stream_video_type: 'main'
43201
+ }
43202
+ };
43203
+ roomInfo = await this._api.audio.rooms.create({
43204
+ bot_id: botId,
43205
+ conversation_id: conversationId || void 0,
43206
+ voice_id: voiceId && voiceId.length > 0 ? voiceId : void 0,
43207
+ connector_id: this._config.connectorId,
43208
+ uid: this._config.userId || void 0,
43209
+ workflow_id: this._config.workflowId || void 0,
43210
+ config
43211
+ });
43212
+ }
43145
43213
  } catch (error) {
43146
43214
  this.dispatch(event_handler_EventNames.ERROR, error);
43147
43215
  throw new RealtimeAPIError(error_RealtimeError.CREATE_ROOM_ERROR, error instanceof Error ? error.message : 'Unknown error', error);
43148
43216
  }
43217
+ this._isTestEnv = TEST_APP_ID === roomInfo.app_id;
43149
43218
  // Step2 create engine
43150
43219
  this._client = new EngineClient(roomInfo.app_id, this._config.debug, this._isTestEnv, this._isSupportVideo, this._config.videoConfig);
43151
43220
  // Step3 bind engine events
@@ -43200,6 +43269,7 @@ and limitations under the License.
43200
43269
  var _this__client;
43201
43270
  await (null === (_this__client = this._client) || void 0 === _this__client ? void 0 : _this__client.disconnect());
43202
43271
  this.isConnected = false;
43272
+ this._client = null;
43203
43273
  this.dispatch(event_handler_EventNames.DISCONNECTED, {});
43204
43274
  }
43205
43275
  /**
@@ -43352,7 +43422,6 @@ and limitations under the License.
43352
43422
  baseURL: defaultBaseURL,
43353
43423
  allowPersonalAccessTokenInBrowser: this._config.allowPersonalAccessTokenInBrowser
43354
43424
  });
43355
- this._isTestEnv = 'https://api.coze.cn' !== defaultBaseURL;
43356
43425
  this._isSupportVideo = !!config.videoConfig;
43357
43426
  }
43358
43427
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coze/realtime-api",
3
- "version": "1.0.5",
3
+ "version": "1.1.0-beta.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",
@@ -49,7 +49,7 @@
49
49
  "test:cov": "vitest --coverage --run"
50
50
  },
51
51
  "dependencies": {
52
- "@coze/api": "1.0.20",
52
+ "@coze/api": "1.1.0-beta.6",
53
53
  "@volcengine/rtc": "^4.62.1"
54
54
  },
55
55
  "devDependencies": {