@coze/realtime-api 1.0.5-beta.2 → 1.1.0

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,15 +56,6 @@ 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
- },
68
59
  allowPersonalAccessTokenInBrowser: true, // Optional: Enable PAT token usage in browser
69
60
  audioMutedDefault: false, // Optional: Initial audio state (default: false)
70
61
  suppressStationaryNoise: false, // Optional: Enable stationary noise suppression(default: false)
package/README.zh-CN.md CHANGED
@@ -56,15 +56,6 @@ 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
- },
68
59
  allowPersonalAccessTokenInBrowser: true, // 可选:在浏览器中启用 PAT 令牌使用
69
60
  audioMutedDefault: false, // 可选:初始音频状态(默认:false)
70
61
  suppressStationaryNoise: false, // 可选:启用静态噪声抑制(默认:false)
@@ -3518,6 +3518,17 @@ class Runs extends APIResource {
3518
3518
  const response = await this._client.post(apiUrl, params, false, options);
3519
3519
  return response;
3520
3520
  }
3521
+ /**
3522
+ * Get the workflow run history | 工作流异步运行后,查看执行结果
3523
+ * @docs zh: https://www.coze.cn/open/docs/developer_guides/workflow_history
3524
+ * @param workflowId - Required The ID of the workflow. | 必选 工作流 ID。
3525
+ * @param executeId - Required The ID of the workflow execution. | 必选 工作流执行 ID。
3526
+ * @returns WorkflowExecuteHistory[] | 工作流执行历史
3527
+ */ async history(workflowId, executeId, options) {
3528
+ const apiUrl = `/v1/workflows/${workflowId}/run_histories/${executeId}`;
3529
+ const response = await this._client.get(apiUrl, void 0, false, options);
3530
+ return response.data;
3531
+ }
3521
3532
  }
3522
3533
  class WorkflowEvent {
3523
3534
  constructor(id, event, data){
@@ -4628,7 +4639,7 @@ class WebSocketAPI {
4628
4639
  // EXTERNAL MODULE: os (ignored)
4629
4640
  var os_ignored_ = __webpack_require__("?9050");
4630
4641
  var os_ignored_default = /*#__PURE__*/ __webpack_require__.n(os_ignored_);
4631
- var package_namespaceObject = JSON.parse('{"name":"@coze/api","version":"1.0.20-beta.1","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
4642
+ var package_namespaceObject = JSON.parse('{"name":"@coze/api","version":"1.1.0","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","./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
4643
  const { version: version_version } = package_namespaceObject;
4633
4644
  const getEnv = ()=>{
4634
4645
  const nodeVersion = process.version.slice(1); // Remove 'v' prefix
@@ -43124,16 +43135,28 @@ class RealtimeClient extends RealtimeEventHandler {
43124
43135
  * zh: 建立与 Coze API 的连接并加入房间
43125
43136
  */ async connect() {
43126
43137
  var _this__config_videoConfig;
43127
- const { botId, conversationId, voiceId, getRoomInfo } = this._config;
43138
+ const { botId, conversationId, voiceId } = this._config;
43128
43139
  let roomInfo;
43129
43140
  try {
43130
- roomInfo = getRoomInfo ? await getRoomInfo() : await this._api.audio.rooms.create({
43141
+ // Step1 get token
43142
+ let config;
43143
+ if (this._config.videoConfig) config = isScreenShareDevice(this._config.videoConfig.videoInputDeviceId) ? {
43144
+ video_config: {
43145
+ stream_video_type: 'screen'
43146
+ }
43147
+ } : {
43148
+ video_config: {
43149
+ stream_video_type: 'main'
43150
+ }
43151
+ };
43152
+ roomInfo = await this._api.audio.rooms.create({
43131
43153
  bot_id: botId,
43132
43154
  conversation_id: conversationId || void 0,
43133
43155
  voice_id: voiceId && voiceId.length > 0 ? voiceId : void 0,
43134
43156
  connector_id: this._config.connectorId,
43135
43157
  uid: this._config.userId || void 0,
43136
- workflow_id: this._config.workflowId || void 0
43158
+ workflow_id: this._config.workflowId || void 0,
43159
+ config
43137
43160
  });
43138
43161
  } catch (error) {
43139
43162
  this.dispatch(event_handler_EventNames.ERROR, error);
package/dist/esm/index.js CHANGED
@@ -3506,6 +3506,17 @@ class Runs extends APIResource {
3506
3506
  const response = await this._client.post(apiUrl, params, false, options);
3507
3507
  return response;
3508
3508
  }
3509
+ /**
3510
+ * Get the workflow run history | 工作流异步运行后,查看执行结果
3511
+ * @docs zh: https://www.coze.cn/open/docs/developer_guides/workflow_history
3512
+ * @param workflowId - Required The ID of the workflow. | 必选 工作流 ID。
3513
+ * @param executeId - Required The ID of the workflow execution. | 必选 工作流执行 ID。
3514
+ * @returns WorkflowExecuteHistory[] | 工作流执行历史
3515
+ */ async history(workflowId, executeId, options) {
3516
+ const apiUrl = `/v1/workflows/${workflowId}/run_histories/${executeId}`;
3517
+ const response = await this._client.get(apiUrl, void 0, false, options);
3518
+ return response.data;
3519
+ }
3509
3520
  }
3510
3521
  class WorkflowEvent {
3511
3522
  constructor(id, event, data){
@@ -4616,7 +4627,7 @@ class WebSocketAPI {
4616
4627
  // EXTERNAL MODULE: os (ignored)
4617
4628
  var os_ignored_ = __webpack_require__("?9050");
4618
4629
  var os_ignored_default = /*#__PURE__*/ __webpack_require__.n(os_ignored_);
4619
- var package_namespaceObject = JSON.parse('{"name":"@coze/api","version":"1.0.20-beta.1","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
4630
+ var package_namespaceObject = JSON.parse('{"name":"@coze/api","version":"1.1.0","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","./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
4631
  const { version: version_version } = package_namespaceObject;
4621
4632
  const getEnv = ()=>{
4622
4633
  const nodeVersion = process.version.slice(1); // Remove 'v' prefix
@@ -43112,16 +43123,28 @@ class RealtimeClient extends RealtimeEventHandler {
43112
43123
  * zh: 建立与 Coze API 的连接并加入房间
43113
43124
  */ async connect() {
43114
43125
  var _this__config_videoConfig;
43115
- const { botId, conversationId, voiceId, getRoomInfo } = this._config;
43126
+ const { botId, conversationId, voiceId } = this._config;
43116
43127
  let roomInfo;
43117
43128
  try {
43118
- roomInfo = getRoomInfo ? await getRoomInfo() : await this._api.audio.rooms.create({
43129
+ // Step1 get token
43130
+ let config;
43131
+ if (this._config.videoConfig) config = isScreenShareDevice(this._config.videoConfig.videoInputDeviceId) ? {
43132
+ video_config: {
43133
+ stream_video_type: 'screen'
43134
+ }
43135
+ } : {
43136
+ video_config: {
43137
+ stream_video_type: 'main'
43138
+ }
43139
+ };
43140
+ roomInfo = await this._api.audio.rooms.create({
43119
43141
  bot_id: botId,
43120
43142
  conversation_id: conversationId || void 0,
43121
43143
  voice_id: voiceId && voiceId.length > 0 ? voiceId : void 0,
43122
43144
  connector_id: this._config.connectorId,
43123
43145
  uid: this._config.userId || void 0,
43124
- workflow_id: this._config.workflowId || void 0
43146
+ workflow_id: this._config.workflowId || void 0,
43147
+ config
43125
43148
  });
43126
43149
  } catch (error) {
43127
43150
  this.dispatch(event_handler_EventNames.ERROR, error);
@@ -1,5 +1,5 @@
1
1
  import { type ScreenConfig, type AudioPropertiesConfig, type IRTCEngine } from '@volcengine/rtc';
2
- import { type CreateRoomData, type GetToken } from '@coze/api';
2
+ import { 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,7 +18,6 @@ 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 */;
22
21
  /** Whether Personal Access Tokens (PAT) are allowed in browser environments */
23
22
  allowPersonalAccessTokenInBrowser?: boolean;
24
23
  /** Whether to mute by default, defaults to false
@@ -31,7 +30,7 @@ export interface RealtimeClientConfig {
31
30
  isAutoSubscribeAudio?: boolean /** optional, Whether to automatically subscribe to bot reply audio streams, defaults to true */;
32
31
  }
33
32
  declare class RealtimeClient extends RealtimeEventHandler {
34
- private _config;
33
+ _config: RealtimeClientConfig;
35
34
  private _client;
36
35
  isConnected: boolean;
37
36
  private _api;
package/dist/umd/index.js CHANGED
@@ -3524,6 +3524,17 @@
3524
3524
  const response = await this._client.post(apiUrl, params, false, options);
3525
3525
  return response;
3526
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
+ }
3527
3538
  }
3528
3539
  class WorkflowEvent {
3529
3540
  constructor(id, event, data){
@@ -4634,7 +4645,7 @@ and limitations under the License.
4634
4645
  // EXTERNAL MODULE: os (ignored)
4635
4646
  var os_ignored_ = __webpack_require__("?9050");
4636
4647
  var os_ignored_default = /*#__PURE__*/ __webpack_require__.n(os_ignored_);
4637
- var package_namespaceObject = JSON.parse('{"name":"@coze/api","version":"1.0.20-beta.1","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
4648
+ var package_namespaceObject = JSON.parse('{"name":"@coze/api","version":"1.1.0","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","./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
4649
  const { version: version_version } = package_namespaceObject;
4639
4650
  const getEnv = ()=>{
4640
4651
  const nodeVersion = process.version.slice(1); // Remove 'v' prefix
@@ -43130,16 +43141,28 @@ and limitations under the License.
43130
43141
  * zh: 建立与 Coze API 的连接并加入房间
43131
43142
  */ async connect() {
43132
43143
  var _this__config_videoConfig;
43133
- const { botId, conversationId, voiceId, getRoomInfo } = this._config;
43144
+ const { botId, conversationId, voiceId } = this._config;
43134
43145
  let roomInfo;
43135
43146
  try {
43136
- roomInfo = getRoomInfo ? await getRoomInfo() : await this._api.audio.rooms.create({
43147
+ // Step1 get token
43148
+ let config;
43149
+ if (this._config.videoConfig) config = isScreenShareDevice(this._config.videoConfig.videoInputDeviceId) ? {
43150
+ video_config: {
43151
+ stream_video_type: 'screen'
43152
+ }
43153
+ } : {
43154
+ video_config: {
43155
+ stream_video_type: 'main'
43156
+ }
43157
+ };
43158
+ roomInfo = await this._api.audio.rooms.create({
43137
43159
  bot_id: botId,
43138
43160
  conversation_id: conversationId || void 0,
43139
43161
  voice_id: voiceId && voiceId.length > 0 ? voiceId : void 0,
43140
43162
  connector_id: this._config.connectorId,
43141
43163
  uid: this._config.userId || void 0,
43142
- workflow_id: this._config.workflowId || void 0
43164
+ workflow_id: this._config.workflowId || void 0,
43165
+ config
43143
43166
  });
43144
43167
  } catch (error) {
43145
43168
  this.dispatch(event_handler_EventNames.ERROR, error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coze/realtime-api",
3
- "version": "1.0.5-beta.2",
3
+ "version": "1.1.0",
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-beta.1",
52
+ "@coze/api": "1.1.0",
53
53
  "@volcengine/rtc": "^4.62.1"
54
54
  },
55
55
  "devDependencies": {