@coze/realtime-api 1.0.4-alpha.aea086 → 1.0.4-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
@@ -83,7 +83,9 @@ const operations = {
83
83
  disconnect: () => client.disconnect(),
84
84
  interrupt: () => client.interrupt(),
85
85
  toggleMicrophone: (enabled: boolean) => client.setAudioEnable(enabled),
86
- checkConnection: () => client.isConnected
86
+ checkConnection: () => client.isConnected,
87
+ // get rtc engine instance, for detail visit https://www.volcengine.com/docs/6348/104478#rtcengine
88
+ getRtcEngine: () => client.getRtcEngine(),
87
89
  };
88
90
 
89
91
  // Event Handling
package/README.zh-CN.md CHANGED
@@ -79,7 +79,9 @@ const operations = {
79
79
  disconnect: () => client.disconnect(),
80
80
  interrupt: () => client.interrupt(),
81
81
  toggleMicrophone: (enabled: boolean) => client.setAudioEnable(enabled),
82
- checkConnection: () => client.isConnected
82
+ checkConnection: () => client.isConnected,
83
+ // 获取 RTC 引擎实例,详情请访问 https://www.volcengine.com/docs/6348/104478#rtcengine
84
+ getRtcEngine: () => client.getRtcEngine(),
83
85
  };
84
86
 
85
87
  // 事件处理
@@ -3841,6 +3841,8 @@ class Voices extends APIResource {
3841
3841
  * | 如果传入会基于该文本生成预览音频,否则使用默认的文本
3842
3842
  * @param params.text - Optional. Users can read this text, service will compare audio with text. Returns error if difference is too large
3843
3843
  * | 可以让用户按照该文本念诵,服务会对比音频与该文本的差异。若差异过大会返回错误
3844
+ * @param params.space_id - Optional. The space id of the voice. | 空间ID
3845
+ * @param params.description- Optional. The description of the voice. | 音色描述
3844
3846
  * @param options - Request options
3845
3847
  * @returns Clone voice data
3846
3848
  */ async clone(params, options) {
@@ -3865,6 +3867,17 @@ class Voices extends APIResource {
3865
3867
  return response.data;
3866
3868
  }
3867
3869
  }
3870
+ class Transcriptions extends APIResource {
3871
+ /**
3872
+ * ASR voice to text | ASR 语音转文本
3873
+ * @param params - Required The parameters for file upload | 上传文件所需的参数
3874
+ * @param params.file - Required The audio file to be uploaded. | 需要上传的音频文件。
3875
+ */ async create(params, options) {
3876
+ const apiUrl = '/v1/audio/transcriptions';
3877
+ const response = await this._client.post(apiUrl, axios_toFormData(params), false, options);
3878
+ return response.data;
3879
+ }
3880
+ }
3868
3881
  class Speech extends APIResource {
3869
3882
  /**
3870
3883
  * @description Speech synthesis | 语音合成
@@ -3896,7 +3909,7 @@ class Rooms extends APIResource {
3896
3909
  }
3897
3910
  class audio_Audio extends APIResource {
3898
3911
  constructor(...args){
3899
- super(...args), this.rooms = new Rooms(this._client), this.voices = new Voices(this._client), this.speech = new Speech(this._client);
3912
+ super(...args), this.rooms = new Rooms(this._client), this.voices = new Voices(this._client), this.speech = new Speech(this._client), this.transcriptions = new Transcriptions(this._client);
3900
3913
  }
3901
3914
  }
3902
3915
  class Templates extends APIResource {
@@ -3916,7 +3929,7 @@ class Templates extends APIResource {
3916
3929
  // EXTERNAL MODULE: os (ignored)
3917
3930
  var os_ignored_ = __webpack_require__("?9050");
3918
3931
  var os_ignored_default = /*#__PURE__*/ __webpack_require__.n(os_ignored_);
3919
- var package_namespaceObject = JSON.parse('{"name":"@coze/api","version":"1.0.16-alpha.aea086","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},"types":"src/index.ts","files":["dist","LICENSE","README.md","README.zh-CN.md"],"scripts":{"build":"rm -rf dist && rslib build","format":"prettier --write .","lint":"eslint ./ --cache --quiet","start":"rm -rf dist && rslib build -w","test":"vitest","test:cov":"vitest --coverage --run"},"dependencies":{"jsonwebtoken":"^9.0.2"},"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/uuid":"^9.0.1","@types/whatwg-fetch":"^0.0.33","@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
3932
+ var package_namespaceObject = JSON.parse('{"name":"@coze/api","version":"1.0.16","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},"types":"src/index.ts","files":["dist","LICENSE","README.md","README.zh-CN.md"],"scripts":{"build":"rm -rf dist && rslib build","format":"prettier --write .","lint":"eslint ./ --cache --quiet","start":"rm -rf dist && rslib build -w","test":"vitest","test:cov":"vitest --coverage --run"},"dependencies":{"jsonwebtoken":"^9.0.2"},"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/uuid":"^9.0.1","@types/whatwg-fetch":"^0.0.33","@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
3920
3933
  const { version: version_version } = package_namespaceObject;
3921
3934
  const getEnv = ()=>{
3922
3935
  const nodeVersion = process.version.slice(1); // Remove 'v' prefix
@@ -4121,6 +4134,8 @@ function isAxiosStatic(instance) {
4121
4134
  }
4122
4135
  const config = mergeConfig(this.axiosOptions, options, {
4123
4136
  headers
4137
+ }, {
4138
+ headers: this.headers || {}
4124
4139
  });
4125
4140
  config.method = method;
4126
4141
  config.data = body;
@@ -4131,11 +4146,11 @@ function isAxiosStatic(instance) {
4131
4146
  const fetchOptions = await this.buildOptions(method, body, options);
4132
4147
  fetchOptions.isStreaming = isStream;
4133
4148
  fetchOptions.axiosInstance = this.axiosInstance;
4134
- this.debugLog(`--- request url: ${fullUrl}`);
4135
- this.debugLog('--- request options:', fetchOptions);
4149
+ this.debugLog(null == options ? void 0 : options.debug, `--- request url: ${fullUrl}`);
4150
+ this.debugLog(null == options ? void 0 : options.debug, '--- request options:', fetchOptions);
4136
4151
  const { response, stream, json } = await fetchAPI(fullUrl, fetchOptions);
4137
- this.debugLog(`--- response status: ${response.status}`);
4138
- this.debugLog('--- response headers: ', response.headers);
4152
+ this.debugLog(null == options ? void 0 : options.debug, `--- response status: ${response.status}`);
4153
+ this.debugLog(null == options ? void 0 : options.debug, '--- response headers: ', response.headers);
4139
4154
  var _response_headers;
4140
4155
  // Taro use `header`
4141
4156
  const contentType = (null !== (_response_headers = response.headers) && void 0 !== _response_headers ? _response_headers : response.header)['content-type'];
@@ -4178,8 +4193,9 @@ function isAxiosStatic(instance) {
4178
4193
  }
4179
4194
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
4180
4195
  debugLog() {
4181
- for(var _len = arguments.length, msgs = new Array(_len), _key = 0; _key < _len; _key++)msgs[_key] = arguments[_key];
4182
- if (this.debug) console.debug(...msgs);
4196
+ let forceDebug = arguments.length > 0 && void 0 !== arguments[0] && arguments[0];
4197
+ for(var _len = arguments.length, msgs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++)msgs[_key - 1] = arguments[_key];
4198
+ if (this.debug || forceDebug) console.debug(...msgs);
4183
4199
  }
4184
4200
  constructor(config){
4185
4201
  this._config = config;
@@ -42328,6 +42344,9 @@ class EngineClient extends RealtimeEventHandler {
42328
42344
  throw e;
42329
42345
  }
42330
42346
  }
42347
+ getRtcEngine() {
42348
+ return this.engine;
42349
+ }
42331
42350
  // eslint-disable-next-line max-params
42332
42351
  constructor(appId, debug = false, isTestEnv = false, isSupportVideo = false, videoConfig){
42333
42352
  super(debug), this.joinUserId = '', this._AIAnsExtension = null, this._isSupportVideo = false;
@@ -42360,9 +42379,10 @@ class RealtimeClient extends RealtimeEventHandler {
42360
42379
  // Step1 get token
42361
42380
  roomInfo = await this._api.audio.rooms.create({
42362
42381
  bot_id: botId,
42363
- conversation_id: conversationId,
42382
+ conversation_id: conversationId || void 0,
42364
42383
  voice_id: voiceId && voiceId.length > 0 ? voiceId : void 0,
42365
- connector_id: this._config.connectorId
42384
+ connector_id: this._config.connectorId,
42385
+ uid: this._config.userId || void 0
42366
42386
  });
42367
42387
  } catch (error) {
42368
42388
  this.dispatch(event_handler_EventNames.ERROR, error);
@@ -42513,6 +42533,14 @@ class RealtimeClient extends RealtimeEventHandler {
42513
42533
  });
42514
42534
  }
42515
42535
  /**
42536
+ * en: Get the RTC engine instance, for detail visit https://www.volcengine.com/docs/6348/104481
42537
+ *
42538
+ * zh: 获取 RTC 引擎实例,详情请访问 https://www.volcengine.com/docs/6348/104481
42539
+ */ getRtcEngine() {
42540
+ var _this__client;
42541
+ return null === (_this__client = this._client) || void 0 === _this__client ? void 0 : _this__client.getRtcEngine();
42542
+ }
42543
+ /**
42516
42544
  * Constructor for initializing a RealtimeClient instance.
42517
42545
  *
42518
42546
  * 构造函数,初始化RealtimeClient实例。
@@ -42526,6 +42554,8 @@ class RealtimeClient extends RealtimeEventHandler {
42526
42554
  * 可选,音色Id。
42527
42555
  * @param config.conversationId - Optional, Conversation Id. |
42528
42556
  * 可选,会话Id。
42557
+ * @param config.userId - Optional, User Id. |
42558
+ * 可选,用户Id。
42529
42559
  * @param config.baseURL - Optional, defaults to "https://api.coze.cn". |
42530
42560
  * 可选,默认值为 "https://api.coze.cn"。
42531
42561
  * @param config.debug - Optional, defaults to false.
package/dist/esm/index.js CHANGED
@@ -3829,6 +3829,8 @@ class Voices extends APIResource {
3829
3829
  * | 如果传入会基于该文本生成预览音频,否则使用默认的文本
3830
3830
  * @param params.text - Optional. Users can read this text, service will compare audio with text. Returns error if difference is too large
3831
3831
  * | 可以让用户按照该文本念诵,服务会对比音频与该文本的差异。若差异过大会返回错误
3832
+ * @param params.space_id - Optional. The space id of the voice. | 空间ID
3833
+ * @param params.description- Optional. The description of the voice. | 音色描述
3832
3834
  * @param options - Request options
3833
3835
  * @returns Clone voice data
3834
3836
  */ async clone(params, options) {
@@ -3853,6 +3855,17 @@ class Voices extends APIResource {
3853
3855
  return response.data;
3854
3856
  }
3855
3857
  }
3858
+ class Transcriptions extends APIResource {
3859
+ /**
3860
+ * ASR voice to text | ASR 语音转文本
3861
+ * @param params - Required The parameters for file upload | 上传文件所需的参数
3862
+ * @param params.file - Required The audio file to be uploaded. | 需要上传的音频文件。
3863
+ */ async create(params, options) {
3864
+ const apiUrl = '/v1/audio/transcriptions';
3865
+ const response = await this._client.post(apiUrl, axios_toFormData(params), false, options);
3866
+ return response.data;
3867
+ }
3868
+ }
3856
3869
  class Speech extends APIResource {
3857
3870
  /**
3858
3871
  * @description Speech synthesis | 语音合成
@@ -3884,7 +3897,7 @@ class Rooms extends APIResource {
3884
3897
  }
3885
3898
  class audio_Audio extends APIResource {
3886
3899
  constructor(...args){
3887
- super(...args), this.rooms = new Rooms(this._client), this.voices = new Voices(this._client), this.speech = new Speech(this._client);
3900
+ super(...args), this.rooms = new Rooms(this._client), this.voices = new Voices(this._client), this.speech = new Speech(this._client), this.transcriptions = new Transcriptions(this._client);
3888
3901
  }
3889
3902
  }
3890
3903
  class Templates extends APIResource {
@@ -3904,7 +3917,7 @@ class Templates extends APIResource {
3904
3917
  // EXTERNAL MODULE: os (ignored)
3905
3918
  var os_ignored_ = __webpack_require__("?9050");
3906
3919
  var os_ignored_default = /*#__PURE__*/ __webpack_require__.n(os_ignored_);
3907
- var package_namespaceObject = JSON.parse('{"name":"@coze/api","version":"1.0.16-alpha.aea086","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},"types":"src/index.ts","files":["dist","LICENSE","README.md","README.zh-CN.md"],"scripts":{"build":"rm -rf dist && rslib build","format":"prettier --write .","lint":"eslint ./ --cache --quiet","start":"rm -rf dist && rslib build -w","test":"vitest","test:cov":"vitest --coverage --run"},"dependencies":{"jsonwebtoken":"^9.0.2"},"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/uuid":"^9.0.1","@types/whatwg-fetch":"^0.0.33","@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
3920
+ var package_namespaceObject = JSON.parse('{"name":"@coze/api","version":"1.0.16","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},"types":"src/index.ts","files":["dist","LICENSE","README.md","README.zh-CN.md"],"scripts":{"build":"rm -rf dist && rslib build","format":"prettier --write .","lint":"eslint ./ --cache --quiet","start":"rm -rf dist && rslib build -w","test":"vitest","test:cov":"vitest --coverage --run"},"dependencies":{"jsonwebtoken":"^9.0.2"},"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/uuid":"^9.0.1","@types/whatwg-fetch":"^0.0.33","@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
3908
3921
  const { version: version_version } = package_namespaceObject;
3909
3922
  const getEnv = ()=>{
3910
3923
  const nodeVersion = process.version.slice(1); // Remove 'v' prefix
@@ -4109,6 +4122,8 @@ function isAxiosStatic(instance) {
4109
4122
  }
4110
4123
  const config = mergeConfig(this.axiosOptions, options, {
4111
4124
  headers
4125
+ }, {
4126
+ headers: this.headers || {}
4112
4127
  });
4113
4128
  config.method = method;
4114
4129
  config.data = body;
@@ -4119,11 +4134,11 @@ function isAxiosStatic(instance) {
4119
4134
  const fetchOptions = await this.buildOptions(method, body, options);
4120
4135
  fetchOptions.isStreaming = isStream;
4121
4136
  fetchOptions.axiosInstance = this.axiosInstance;
4122
- this.debugLog(`--- request url: ${fullUrl}`);
4123
- this.debugLog('--- request options:', fetchOptions);
4137
+ this.debugLog(null == options ? void 0 : options.debug, `--- request url: ${fullUrl}`);
4138
+ this.debugLog(null == options ? void 0 : options.debug, '--- request options:', fetchOptions);
4124
4139
  const { response, stream, json } = await fetchAPI(fullUrl, fetchOptions);
4125
- this.debugLog(`--- response status: ${response.status}`);
4126
- this.debugLog('--- response headers: ', response.headers);
4140
+ this.debugLog(null == options ? void 0 : options.debug, `--- response status: ${response.status}`);
4141
+ this.debugLog(null == options ? void 0 : options.debug, '--- response headers: ', response.headers);
4127
4142
  var _response_headers;
4128
4143
  // Taro use `header`
4129
4144
  const contentType = (null !== (_response_headers = response.headers) && void 0 !== _response_headers ? _response_headers : response.header)['content-type'];
@@ -4166,8 +4181,9 @@ function isAxiosStatic(instance) {
4166
4181
  }
4167
4182
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
4168
4183
  debugLog() {
4169
- for(var _len = arguments.length, msgs = new Array(_len), _key = 0; _key < _len; _key++)msgs[_key] = arguments[_key];
4170
- if (this.debug) console.debug(...msgs);
4184
+ let forceDebug = arguments.length > 0 && void 0 !== arguments[0] && arguments[0];
4185
+ for(var _len = arguments.length, msgs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++)msgs[_key - 1] = arguments[_key];
4186
+ if (this.debug || forceDebug) console.debug(...msgs);
4171
4187
  }
4172
4188
  constructor(config){
4173
4189
  this._config = config;
@@ -42316,6 +42332,9 @@ class EngineClient extends RealtimeEventHandler {
42316
42332
  throw e;
42317
42333
  }
42318
42334
  }
42335
+ getRtcEngine() {
42336
+ return this.engine;
42337
+ }
42319
42338
  // eslint-disable-next-line max-params
42320
42339
  constructor(appId, debug = false, isTestEnv = false, isSupportVideo = false, videoConfig){
42321
42340
  super(debug), this.joinUserId = '', this._AIAnsExtension = null, this._isSupportVideo = false;
@@ -42348,9 +42367,10 @@ class RealtimeClient extends RealtimeEventHandler {
42348
42367
  // Step1 get token
42349
42368
  roomInfo = await this._api.audio.rooms.create({
42350
42369
  bot_id: botId,
42351
- conversation_id: conversationId,
42370
+ conversation_id: conversationId || void 0,
42352
42371
  voice_id: voiceId && voiceId.length > 0 ? voiceId : void 0,
42353
- connector_id: this._config.connectorId
42372
+ connector_id: this._config.connectorId,
42373
+ uid: this._config.userId || void 0
42354
42374
  });
42355
42375
  } catch (error) {
42356
42376
  this.dispatch(event_handler_EventNames.ERROR, error);
@@ -42501,6 +42521,14 @@ class RealtimeClient extends RealtimeEventHandler {
42501
42521
  });
42502
42522
  }
42503
42523
  /**
42524
+ * en: Get the RTC engine instance, for detail visit https://www.volcengine.com/docs/6348/104481
42525
+ *
42526
+ * zh: 获取 RTC 引擎实例,详情请访问 https://www.volcengine.com/docs/6348/104481
42527
+ */ getRtcEngine() {
42528
+ var _this__client;
42529
+ return null === (_this__client = this._client) || void 0 === _this__client ? void 0 : _this__client.getRtcEngine();
42530
+ }
42531
+ /**
42504
42532
  * Constructor for initializing a RealtimeClient instance.
42505
42533
  *
42506
42534
  * 构造函数,初始化RealtimeClient实例。
@@ -42514,6 +42542,8 @@ class RealtimeClient extends RealtimeEventHandler {
42514
42542
  * 可选,音色Id。
42515
42543
  * @param config.conversationId - Optional, Conversation Id. |
42516
42544
  * 可选,会话Id。
42545
+ * @param config.userId - Optional, User Id. |
42546
+ * 可选,用户Id。
42517
42547
  * @param config.baseURL - Optional, defaults to "https://api.coze.cn". |
42518
42548
  * 可选,默认值为 "https://api.coze.cn"。
42519
42549
  * @param config.debug - Optional, defaults to false.
@@ -1,4 +1,4 @@
1
- import { type AudioPropertiesConfig, type onUserJoinedEvent, type onUserLeaveEvent, type UserMessageEvent } from '@volcengine/rtc';
1
+ import { type AudioPropertiesConfig, type IRTCEngine, 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 {
@@ -43,4 +43,5 @@ export declare class EngineClient extends RealtimeEventHandler {
43
43
  changeAIAnsExtension(enable: boolean): void;
44
44
  startAudioPlaybackDeviceTest(): Promise<void>;
45
45
  stopAudioPlaybackDeviceTest(): void;
46
+ getRtcEngine(): IRTCEngine;
46
47
  }
@@ -1,4 +1,4 @@
1
- import { type ScreenConfig, type AudioPropertiesConfig } from '@volcengine/rtc';
1
+ import { type ScreenConfig, type AudioPropertiesConfig, type IRTCEngine } from '@volcengine/rtc';
2
2
  import { type GetToken } from '@coze/api';
3
3
  import * as RealtimeUtils from './utils';
4
4
  import { RealtimeEventHandler, EventNames } from './event-handler';
@@ -14,6 +14,7 @@ export interface RealtimeClientConfig {
14
14
  botId: string /** required, Bot Id */;
15
15
  voiceId?: string /** optional, Voice Id */;
16
16
  conversationId?: string /** optional, Conversation Id */;
17
+ userId?: string /** optional, User Id */;
17
18
  baseURL?: string /** optional, defaults to "https://api.coze.cn" */;
18
19
  debug?: boolean /** optional, defaults to false */;
19
20
  /** Whether Personal Access Tokens (PAT) are allowed in browser environments */
@@ -48,6 +49,8 @@ declare class RealtimeClient extends RealtimeEventHandler {
48
49
  * 可选,音色Id。
49
50
  * @param config.conversationId - Optional, Conversation Id. |
50
51
  * 可选,会话Id。
52
+ * @param config.userId - Optional, User Id. |
53
+ * 可选,用户Id。
51
54
  * @param config.baseURL - Optional, defaults to "https://api.coze.cn". |
52
55
  * 可选,默认值为 "https://api.coze.cn"。
53
56
  * @param config.debug - Optional, defaults to false.
@@ -138,5 +141,11 @@ declare class RealtimeClient extends RealtimeEventHandler {
138
141
  */
139
142
  setAudioOutputDevice(deviceId: string): Promise<void>;
140
143
  setVideoInputDevice(deviceId: string): Promise<void>;
144
+ /**
145
+ * en: Get the RTC engine instance, for detail visit https://www.volcengine.com/docs/6348/104481
146
+ *
147
+ * zh: 获取 RTC 引擎实例,详情请访问 https://www.volcengine.com/docs/6348/104481
148
+ */
149
+ getRtcEngine(): IRTCEngine | undefined;
141
150
  }
142
151
  export { RealtimeUtils, RealtimeClient, RealtimeAPIError, RealtimeError, EventNames, };
package/dist/umd/index.js CHANGED
@@ -3847,6 +3847,8 @@
3847
3847
  * | 如果传入会基于该文本生成预览音频,否则使用默认的文本
3848
3848
  * @param params.text - Optional. Users can read this text, service will compare audio with text. Returns error if difference is too large
3849
3849
  * | 可以让用户按照该文本念诵,服务会对比音频与该文本的差异。若差异过大会返回错误
3850
+ * @param params.space_id - Optional. The space id of the voice. | 空间ID
3851
+ * @param params.description- Optional. The description of the voice. | 音色描述
3850
3852
  * @param options - Request options
3851
3853
  * @returns Clone voice data
3852
3854
  */ async clone(params, options) {
@@ -3871,6 +3873,17 @@
3871
3873
  return response.data;
3872
3874
  }
3873
3875
  }
3876
+ class Transcriptions extends APIResource {
3877
+ /**
3878
+ * ASR voice to text | ASR 语音转文本
3879
+ * @param params - Required The parameters for file upload | 上传文件所需的参数
3880
+ * @param params.file - Required The audio file to be uploaded. | 需要上传的音频文件。
3881
+ */ async create(params, options) {
3882
+ const apiUrl = '/v1/audio/transcriptions';
3883
+ const response = await this._client.post(apiUrl, axios_toFormData(params), false, options);
3884
+ return response.data;
3885
+ }
3886
+ }
3874
3887
  class Speech extends APIResource {
3875
3888
  /**
3876
3889
  * @description Speech synthesis | 语音合成
@@ -3902,7 +3915,7 @@
3902
3915
  }
3903
3916
  class audio_Audio extends APIResource {
3904
3917
  constructor(...args){
3905
- super(...args), this.rooms = new Rooms(this._client), this.voices = new Voices(this._client), this.speech = new Speech(this._client);
3918
+ super(...args), this.rooms = new Rooms(this._client), this.voices = new Voices(this._client), this.speech = new Speech(this._client), this.transcriptions = new Transcriptions(this._client);
3906
3919
  }
3907
3920
  }
3908
3921
  class Templates extends APIResource {
@@ -3922,7 +3935,7 @@
3922
3935
  // EXTERNAL MODULE: os (ignored)
3923
3936
  var os_ignored_ = __webpack_require__("?9050");
3924
3937
  var os_ignored_default = /*#__PURE__*/ __webpack_require__.n(os_ignored_);
3925
- var package_namespaceObject = JSON.parse('{"name":"@coze/api","version":"1.0.16-alpha.aea086","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},"types":"src/index.ts","files":["dist","LICENSE","README.md","README.zh-CN.md"],"scripts":{"build":"rm -rf dist && rslib build","format":"prettier --write .","lint":"eslint ./ --cache --quiet","start":"rm -rf dist && rslib build -w","test":"vitest","test:cov":"vitest --coverage --run"},"dependencies":{"jsonwebtoken":"^9.0.2"},"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/uuid":"^9.0.1","@types/whatwg-fetch":"^0.0.33","@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
3938
+ var package_namespaceObject = JSON.parse('{"name":"@coze/api","version":"1.0.16","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},"types":"src/index.ts","files":["dist","LICENSE","README.md","README.zh-CN.md"],"scripts":{"build":"rm -rf dist && rslib build","format":"prettier --write .","lint":"eslint ./ --cache --quiet","start":"rm -rf dist && rslib build -w","test":"vitest","test:cov":"vitest --coverage --run"},"dependencies":{"jsonwebtoken":"^9.0.2"},"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/uuid":"^9.0.1","@types/whatwg-fetch":"^0.0.33","@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
3926
3939
  const { version: version_version } = package_namespaceObject;
3927
3940
  const getEnv = ()=>{
3928
3941
  const nodeVersion = process.version.slice(1); // Remove 'v' prefix
@@ -4127,6 +4140,8 @@
4127
4140
  }
4128
4141
  const config = mergeConfig(this.axiosOptions, options, {
4129
4142
  headers
4143
+ }, {
4144
+ headers: this.headers || {}
4130
4145
  });
4131
4146
  config.method = method;
4132
4147
  config.data = body;
@@ -4137,11 +4152,11 @@
4137
4152
  const fetchOptions = await this.buildOptions(method, body, options);
4138
4153
  fetchOptions.isStreaming = isStream;
4139
4154
  fetchOptions.axiosInstance = this.axiosInstance;
4140
- this.debugLog(`--- request url: ${fullUrl}`);
4141
- this.debugLog('--- request options:', fetchOptions);
4155
+ this.debugLog(null == options ? void 0 : options.debug, `--- request url: ${fullUrl}`);
4156
+ this.debugLog(null == options ? void 0 : options.debug, '--- request options:', fetchOptions);
4142
4157
  const { response, stream, json } = await fetchAPI(fullUrl, fetchOptions);
4143
- this.debugLog(`--- response status: ${response.status}`);
4144
- this.debugLog('--- response headers: ', response.headers);
4158
+ this.debugLog(null == options ? void 0 : options.debug, `--- response status: ${response.status}`);
4159
+ this.debugLog(null == options ? void 0 : options.debug, '--- response headers: ', response.headers);
4145
4160
  var _response_headers;
4146
4161
  // Taro use `header`
4147
4162
  const contentType = (null !== (_response_headers = response.headers) && void 0 !== _response_headers ? _response_headers : response.header)['content-type'];
@@ -4184,8 +4199,9 @@
4184
4199
  }
4185
4200
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
4186
4201
  debugLog() {
4187
- for(var _len = arguments.length, msgs = new Array(_len), _key = 0; _key < _len; _key++)msgs[_key] = arguments[_key];
4188
- if (this.debug) console.debug(...msgs);
4202
+ let forceDebug = arguments.length > 0 && void 0 !== arguments[0] && arguments[0];
4203
+ for(var _len = arguments.length, msgs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++)msgs[_key - 1] = arguments[_key];
4204
+ if (this.debug || forceDebug) console.debug(...msgs);
4189
4205
  }
4190
4206
  constructor(config){
4191
4207
  this._config = config;
@@ -42334,6 +42350,9 @@
42334
42350
  throw e;
42335
42351
  }
42336
42352
  }
42353
+ getRtcEngine() {
42354
+ return this.engine;
42355
+ }
42337
42356
  // eslint-disable-next-line max-params
42338
42357
  constructor(appId, debug = false, isTestEnv = false, isSupportVideo = false, videoConfig){
42339
42358
  super(debug), this.joinUserId = '', this._AIAnsExtension = null, this._isSupportVideo = false;
@@ -42366,9 +42385,10 @@
42366
42385
  // Step1 get token
42367
42386
  roomInfo = await this._api.audio.rooms.create({
42368
42387
  bot_id: botId,
42369
- conversation_id: conversationId,
42388
+ conversation_id: conversationId || void 0,
42370
42389
  voice_id: voiceId && voiceId.length > 0 ? voiceId : void 0,
42371
- connector_id: this._config.connectorId
42390
+ connector_id: this._config.connectorId,
42391
+ uid: this._config.userId || void 0
42372
42392
  });
42373
42393
  } catch (error) {
42374
42394
  this.dispatch(event_handler_EventNames.ERROR, error);
@@ -42519,6 +42539,14 @@
42519
42539
  });
42520
42540
  }
42521
42541
  /**
42542
+ * en: Get the RTC engine instance, for detail visit https://www.volcengine.com/docs/6348/104481
42543
+ *
42544
+ * zh: 获取 RTC 引擎实例,详情请访问 https://www.volcengine.com/docs/6348/104481
42545
+ */ getRtcEngine() {
42546
+ var _this__client;
42547
+ return null === (_this__client = this._client) || void 0 === _this__client ? void 0 : _this__client.getRtcEngine();
42548
+ }
42549
+ /**
42522
42550
  * Constructor for initializing a RealtimeClient instance.
42523
42551
  *
42524
42552
  * 构造函数,初始化RealtimeClient实例。
@@ -42532,6 +42560,8 @@
42532
42560
  * 可选,音色Id。
42533
42561
  * @param config.conversationId - Optional, Conversation Id. |
42534
42562
  * 可选,会话Id。
42563
+ * @param config.userId - Optional, User Id. |
42564
+ * 可选,用户Id。
42535
42565
  * @param config.baseURL - Optional, defaults to "https://api.coze.cn". |
42536
42566
  * 可选,默认值为 "https://api.coze.cn"。
42537
42567
  * @param config.debug - Optional, defaults to false.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coze/realtime-api",
3
- "version": "1.0.4-alpha.aea086",
3
+ "version": "1.0.4-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.16-alpha.aea086",
52
+ "@coze/api": "1.0.16",
53
53
  "@volcengine/rtc": "^4.62.1"
54
54
  },
55
55
  "devDependencies": {