@coze/realtime-api 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  /*! For license information please see index.js.LICENSE.txt */
2
2
  var __webpack_modules__ = {
3
- "?de24": function() {
3
+ "?c628": function() {
4
4
  /* (ignored) */ },
5
- "?2a9f": function() {
5
+ "?9452": function() {
6
6
  /* (ignored) */ },
7
- "?d039": function() {
7
+ "?e2b1": function() {
8
8
  /* (ignored) */ }
9
9
  };
10
10
  /************************************************************************/ // The module cache
@@ -61,7 +61,7 @@ function __webpack_require__(moduleId) {
61
61
  });
62
62
  };
63
63
  })();
64
- /************************************************************************/ // NAMESPACE OBJECT: ../../common/temp/default/node_modules/.pnpm/axios@1.7.7/node_modules/axios/lib/platform/common/utils.js
64
+ /************************************************************************/ // NAMESPACE OBJECT: ../../common/temp/default/node_modules/.pnpm/axios@1.7.7_debug@4.3.7/node_modules/axios/lib/platform/common/utils.js
65
65
  var common_utils_namespaceObject = {};
66
66
  __webpack_require__.r(common_utils_namespaceObject);
67
67
  __webpack_require__.d(common_utils_namespaceObject, {
@@ -75,6 +75,7 @@ __webpack_require__.d(common_utils_namespaceObject, {
75
75
  var src_utils_namespaceObject = {};
76
76
  __webpack_require__.r(src_utils_namespaceObject);
77
77
  __webpack_require__.d(src_utils_namespaceObject, {
78
+ checkDevicePermission: ()=>checkDevicePermission,
78
79
  checkPermission: ()=>checkPermission,
79
80
  getAudioDevices: ()=>getAudioDevices,
80
81
  sleep: ()=>utils_sleep
@@ -2123,7 +2124,7 @@ const trackStream = (stream, chunkSize, onProgress, onFinish)=>{
2123
2124
  }, {
2124
2125
  highWaterMark: 2
2125
2126
  });
2126
- }; // CONCATENATED MODULE: ../../common/temp/default/node_modules/.pnpm/axios@1.7.7/node_modules/axios/lib/adapters/fetch.js
2127
+ }; // CONCATENATED MODULE: ../../common/temp/default/node_modules/.pnpm/axios@1.7.7_debug@4.3.7/node_modules/axios/lib/adapters/fetch.js
2127
2128
  const isFetchSupported = 'function' == typeof fetch && 'function' == typeof Request && 'function' == typeof Response;
2128
2129
  const isReadableStreamSupported = isFetchSupported && 'function' == typeof ReadableStream;
2129
2130
  // used only inside the fetch adapter
@@ -2845,11 +2846,11 @@ axios.default = axios;
2845
2846
  // so that it can keep same with es module or cjs
2846
2847
  const { Axios: axios_Axios, AxiosError: axios_AxiosError, CanceledError: axios_CanceledError, isCancel: axios_isCancel, CancelToken: axios_CancelToken, VERSION: axios_VERSION, all: axios_all, Cancel, isAxiosError: axios_isAxiosError, spread: axios_spread, toFormData: axios_toFormData, AxiosHeaders: axios_AxiosHeaders, HttpStatusCode: axios_HttpStatusCode, formToJSON, getAdapter, mergeConfig: axios_mergeConfig } = lib_axios;
2847
2848
  // EXTERNAL MODULE: os (ignored)
2848
- var os_ignored_ = __webpack_require__("?d039");
2849
+ var os_ignored_ = __webpack_require__("?e2b1");
2849
2850
  // EXTERNAL MODULE: crypto (ignored)
2850
- __webpack_require__("?de24");
2851
+ __webpack_require__("?c628");
2851
2852
  // EXTERNAL MODULE: jsonwebtoken (ignored)
2852
- __webpack_require__("?2a9f");
2853
+ __webpack_require__("?9452");
2853
2854
  class APIResource {
2854
2855
  constructor(client){
2855
2856
  this._client = client;
@@ -3091,6 +3092,10 @@ class Messages extends APIResource {
3091
3092
  }
3092
3093
  }
3093
3094
  const uuid = ()=>(Math.random() * new Date().getTime()).toString();
3095
+ const handleAdditionalMessages = (additional_messages)=>null == additional_messages ? void 0 : additional_messages.map((i)=>({
3096
+ ...i,
3097
+ content: 'object' == typeof i.content ? JSON.stringify(i.content) : i.content
3098
+ }));
3094
3099
  class Chat extends APIResource {
3095
3100
  /**
3096
3101
  * Call the Chat API to send messages to a published Coze agent. | 调用此接口发起一次对话,支持添加上下文
@@ -3112,6 +3117,7 @@ class Chat extends APIResource {
3112
3117
  const apiUrl = `/v3/chat${conversation_id ? `?conversation_id=${conversation_id}` : ''}`;
3113
3118
  const payload = {
3114
3119
  ...rest,
3120
+ additional_messages: handleAdditionalMessages(params.additional_messages),
3115
3121
  stream: false
3116
3122
  };
3117
3123
  const result = await this._client.post(apiUrl, payload, false, options);
@@ -3137,6 +3143,7 @@ class Chat extends APIResource {
3137
3143
  const apiUrl = `/v3/chat${conversation_id ? `?conversation_id=${conversation_id}` : ''}`;
3138
3144
  const payload = {
3139
3145
  ...rest,
3146
+ additional_messages: handleAdditionalMessages(params.additional_messages),
3140
3147
  stream: false
3141
3148
  };
3142
3149
  const result = await this._client.post(apiUrl, payload, false, options);
@@ -3174,6 +3181,7 @@ class Chat extends APIResource {
3174
3181
  const apiUrl = `/v3/chat${conversation_id ? `?conversation_id=${conversation_id}` : ''}`;
3175
3182
  const payload = {
3176
3183
  ...rest,
3184
+ additional_messages: handleAdditionalMessages(params.additional_messages),
3177
3185
  stream: true
3178
3186
  };
3179
3187
  const result = await this._client.post(apiUrl, payload, true, options);
@@ -3264,6 +3272,19 @@ class Chat extends APIResource {
3264
3272
  super(...args), this.messages = new Messages(this._client);
3265
3273
  }
3266
3274
  }
3275
+ var chat_ChatEventType = /*#__PURE__*/ function(ChatEventType) {
3276
+ ChatEventType["CONVERSATION_CHAT_CREATED"] = "conversation.chat.created";
3277
+ ChatEventType["CONVERSATION_CHAT_IN_PROGRESS"] = "conversation.chat.in_progress";
3278
+ ChatEventType["CONVERSATION_CHAT_COMPLETED"] = "conversation.chat.completed";
3279
+ ChatEventType["CONVERSATION_CHAT_FAILED"] = "conversation.chat.failed";
3280
+ ChatEventType["CONVERSATION_CHAT_REQUIRES_ACTION"] = "conversation.chat.requires_action";
3281
+ ChatEventType["CONVERSATION_MESSAGE_DELTA"] = "conversation.message.delta";
3282
+ ChatEventType["CONVERSATION_MESSAGE_COMPLETED"] = "conversation.message.completed";
3283
+ ChatEventType["CONVERSATION_AUDIO_DELTA"] = "conversation.audio.delta";
3284
+ ChatEventType["DONE"] = "done";
3285
+ ChatEventType["ERROR"] = "error";
3286
+ return ChatEventType;
3287
+ }({});
3267
3288
  class messages_Messages extends APIResource {
3268
3289
  /**
3269
3290
  * Create a message and add it to the specified conversation. | 创建一条消息,并将其添加到指定的会话中。
@@ -3348,6 +3369,7 @@ class Conversations extends APIResource {
3348
3369
  * @param params - Required The parameters for creating a conversation | 创建会话所需的参数
3349
3370
  * @param params.messages - Optional Messages in the conversation. | 会话中的消息内容。
3350
3371
  * @param params.meta_data - Optional Additional information when creating a message. | 创建消息时的附加消息。
3372
+ * @param params.bot_id - Optional Bind and isolate conversation on different bots. | 绑定和隔离不同Bot的会话。
3351
3373
  * @returns Information about the created conversation. | 会话的基础信息。
3352
3374
  */ async create(params, options) {
3353
3375
  const apiUrl = '/v1/conversation/create';
@@ -3365,6 +3387,27 @@ class Conversations extends APIResource {
3365
3387
  const response = await this._client.get(apiUrl, null, false, options);
3366
3388
  return response.data;
3367
3389
  }
3390
+ /**
3391
+ * List all conversations. | 列出 Bot 下所有会话。
3392
+ * @param params
3393
+ * @param params.bot_id - Required Bot ID. | Bot ID。
3394
+ * @param params.page_num - Optional The page number. | 页码,默认值为 1。
3395
+ * @param params.page_size - Optional The number of conversations per page. | 每页的会话数量,默认值为 50。
3396
+ * @returns Information about the conversations. | 会话的信息。
3397
+ */ async list(params, options) {
3398
+ const apiUrl = '/v1/conversations';
3399
+ const response = await this._client.get(apiUrl, params, false, options);
3400
+ return response.data;
3401
+ }
3402
+ /**
3403
+ * Clear a conversation. | 清空会话。
3404
+ * @param conversation_id - Required The ID of the conversation. | Conversation ID,即会话的唯一标识。
3405
+ * @returns Information about the conversation session. | 会话的会话 ID。
3406
+ */ async clear(conversation_id, options) {
3407
+ const apiUrl = `/v1/conversations/${conversation_id}/clear`;
3408
+ const response = await this._client.post(apiUrl, null, false, options);
3409
+ return response.data;
3410
+ }
3368
3411
  constructor(...args){
3369
3412
  super(...args), this.messages = new messages_Messages(this._client);
3370
3413
  }
@@ -3403,6 +3446,9 @@ class Runs extends APIResource {
3403
3446
  * @param params.bot_id - Optional The ID of the bot associated with the workflow. | 可选 与工作流关联的机器人 ID。
3404
3447
  * @param params.parameters - Optional Parameters for the workflow execution. | 可选 工作流执行的参数。
3405
3448
  * @param params.ext - Optional Additional information for the workflow execution. | 可选 工作流执行的附加信息。
3449
+ * @param params.execute_mode - Optional The mode in which to execute the workflow. | 可选 工作流执行的模式。
3450
+ * @param params.connector_id - Optional The ID of the connector to use for the workflow. | 可选 用于工作流的连接器 ID。
3451
+ * @param params.app_id - Optional The ID of the app. | 可选 要进行会话聊天的 App ID
3406
3452
  * @returns RunWorkflowData | 工作流运行数据
3407
3453
  */ async create(params, options) {
3408
3454
  const apiUrl = '/v1/workflow/run';
@@ -3417,6 +3463,9 @@ class Runs extends APIResource {
3417
3463
  * @param params.bot_id - Optional The ID of the bot associated with the workflow. | 可选 与工作流关联的机器人 ID。
3418
3464
  * @param params.parameters - Optional Parameters for the workflow execution. | 可选 工作流执行的参数。
3419
3465
  * @param params.ext - Optional Additional information for the workflow execution. | 可选 工作流执行的附加信息。
3466
+ * @param params.execute_mode - Optional The mode in which to execute the workflow. | 可选 工作流执行的模式。
3467
+ * @param params.connector_id - Optional The ID of the connector to use for the workflow. | 可选 用于工作流的连接器 ID。
3468
+ * @param params.app_id - Optional The ID of the app. | 可选 要进行会话聊天的 App ID
3420
3469
  * @returns Stream<WorkflowEvent, { id: string; event: string; data: string }> | 工作流事件流
3421
3470
  */ async *stream(params, options) {
3422
3471
  const apiUrl = '/v1/workflow/stream_run';
@@ -3450,9 +3499,46 @@ class WorkflowEvent {
3450
3499
  this.data = data;
3451
3500
  }
3452
3501
  }
3502
+ class WorkflowChat extends APIResource {
3503
+ /**
3504
+ * Execute a chat workflow. | 执行对话流
3505
+ * @docs en: https://www.coze.cn/docs/developer_guides/workflow_chat?_lang=en
3506
+ * @docs zh: https://www.coze.cn/docs/developer_guides/workflow_chat?_lang=zh
3507
+ * @param params.workflow_id - Required The ID of the workflow to chat with. | 必选 要对话的工作流 ID。
3508
+ * @param params.additional_messages - Required Array of messages for the chat. | 必选 对话的消息数组。
3509
+ * @param params.parameters - Required Parameters for the workflow execution. | 必选 工作流执行的参数。
3510
+ * @param params.app_id - Optional The ID of the app. | 可选 应用 ID。
3511
+ * @param params.bot_id - Optional The ID of the bot. | 可选 Bot ID。
3512
+ * @param params.conversation_id - Optional The ID of the conversation. | 可选 会话 ID。
3513
+ * @param params.ext - Optional Additional information for the chat. | 可选 对话的附加信息。
3514
+ * @returns AsyncGenerator<StreamChatData> | 对话数据流
3515
+ */ async *stream(params, options) {
3516
+ const apiUrl = '/v1/workflows/chat';
3517
+ const payload = {
3518
+ ...params,
3519
+ additional_messages: handleAdditionalMessages(params.additional_messages)
3520
+ };
3521
+ const result = await this._client.post(apiUrl, payload, true, options);
3522
+ for await (const message of result)if (message.event === chat_ChatEventType.DONE) {
3523
+ const ret = {
3524
+ event: message.event,
3525
+ data: '[DONE]'
3526
+ };
3527
+ yield ret;
3528
+ } else try {
3529
+ const ret = {
3530
+ event: message.event,
3531
+ data: JSON.parse(message.data)
3532
+ };
3533
+ yield ret;
3534
+ } catch (error) {
3535
+ throw new CozeError(`Could not parse message into JSON:${message.data}`);
3536
+ }
3537
+ }
3538
+ }
3453
3539
  class Workflows extends APIResource {
3454
3540
  constructor(...args){
3455
- super(...args), this.runs = new Runs(this._client);
3541
+ super(...args), this.runs = new Runs(this._client), this.chat = new WorkflowChat(this._client);
3456
3542
  }
3457
3543
  }
3458
3544
  class WorkSpaces extends APIResource {
@@ -3476,6 +3562,8 @@ const documents_headers = {
3476
3562
  };
3477
3563
  class Documents extends APIResource {
3478
3564
  /**
3565
+ * @deprecated The method is deprecated and will be removed in a future version. Please use 'client.datasets.documents.list' instead.
3566
+ *
3479
3567
  * View the file list of a specified knowledge base, which includes lists of documents, spreadsheets, or images.
3480
3568
  * | 调用接口查看指定知识库的内容列表,即文件、表格或图像列表。
3481
3569
  * @docs en: https://www.coze.com/docs/developer_guides/list_knowledge_files?_lang=en
@@ -3492,6 +3580,8 @@ class Documents extends APIResource {
3492
3580
  return response;
3493
3581
  }
3494
3582
  /**
3583
+ * @deprecated The method is deprecated and will be removed in a future version. Please use 'client.datasets.documents.create' instead.
3584
+ *
3495
3585
  * Upload files to the specific knowledge. | 调用此接口向指定知识库中上传文件。
3496
3586
  * @docs en: https://www.coze.com/docs/developer_guides/create_knowledge_files?_lang=en
3497
3587
  * @docs zh: https://www.coze.cn/docs/developer_guides/create_knowledge_files?_lang=zh
@@ -3508,6 +3598,8 @@ class Documents extends APIResource {
3508
3598
  return response.document_infos;
3509
3599
  }
3510
3600
  /**
3601
+ * @deprecated The method is deprecated and will be removed in a future version. Please use 'client.datasets.documents.delete' instead.
3602
+ *
3511
3603
  * Delete text, images, sheets, and other files in the knowledge base, supporting batch deletion.
3512
3604
  * | 删除知识库中的文本、图像、表格等文件,支持批量删除。
3513
3605
  * @docs en: https://www.coze.com/docs/developer_guides/delete_knowledge_files?_lang=en
@@ -3521,6 +3613,8 @@ class Documents extends APIResource {
3521
3613
  }));
3522
3614
  }
3523
3615
  /**
3616
+ * @deprecated The method is deprecated and will be removed in a future version. Please use 'client.datasets.documents.update' instead.
3617
+ *
3524
3618
  * Modify the knowledge base file name and update strategy. | 调用接口修改知识库文件名称和更新策略。
3525
3619
  * @docs en: https://www.coze.com/docs/developer_guides/modify_knowledge_files?_lang=en
3526
3620
  * @docs zh: https://www.coze.cn/docs/developer_guides/modify_knowledge_files?_lang=zh
@@ -3537,7 +3631,79 @@ class Documents extends APIResource {
3537
3631
  }
3538
3632
  class Knowledge extends APIResource {
3539
3633
  constructor(...args){
3540
- super(...args), this.documents = new Documents(this._client);
3634
+ super(...args), /**
3635
+ * @deprecated
3636
+ */ this.documents = new Documents(this._client);
3637
+ }
3638
+ }
3639
+ // Required header for knowledge APIs
3640
+ const documents_documents_headers = {
3641
+ 'agw-js-conv': 'str'
3642
+ };
3643
+ class documents_Documents extends APIResource {
3644
+ /**
3645
+ * View the file list of a specified knowledge base, which includes lists of documents, spreadsheets, or images.
3646
+ * | 调用接口查看指定知识库的内容列表,即文件、表格或图像列表。
3647
+ * @docs en: https://www.coze.com/docs/developer_guides/list_knowledge_files?_lang=en
3648
+ * @docs zh: https://www.coze.cn/docs/developer_guides/list_knowledge_files?_lang=zh
3649
+ * @param params.dataset_id - Required The ID of the knowledge base. | 必选 待查看文件的知识库 ID。
3650
+ * @param params.page - Optional The page number for paginated queries. Default is 1. | 可选 分页查询时的页码。默认为 1。
3651
+ * @param params.page_size - Optional The size of pagination. Default is 10. | 可选 分页大小。默认为 10。
3652
+ * @returns ListDocumentData | 知识库文件列表
3653
+ */ list(params, options) {
3654
+ const apiUrl = '/open_api/knowledge/document/list';
3655
+ const response = this._client.get(apiUrl, params, false, esm_mergeConfig(options, {
3656
+ headers: documents_documents_headers
3657
+ }));
3658
+ return response;
3659
+ }
3660
+ /**
3661
+ * Upload files to the specific knowledge. | 调用此接口向指定知识库中上传文件。
3662
+ * @docs en: https://www.coze.com/docs/developer_guides/create_knowledge_files?_lang=en
3663
+ * @docs zh: https://www.coze.cn/docs/developer_guides/create_knowledge_files?_lang=zh
3664
+ * @param params.dataset_id - Required The ID of the knowledge. | 必选 知识库 ID。
3665
+ * @param params.document_bases - Required The metadata information of the files awaiting upload. | 必选 待上传文件的元数据信息。
3666
+ * @param params.chunk_strategy - Required when uploading files to a new knowledge for the first time. Chunk strategy.
3667
+ * | 向新知识库首次上传文件时必选 分段规则。
3668
+ * @returns DocumentInfo[] | 已上传文件的基本信息
3669
+ */ async create(params, options) {
3670
+ const apiUrl = '/open_api/knowledge/document/create';
3671
+ const response = await this._client.post(apiUrl, params, false, esm_mergeConfig(options, {
3672
+ headers: documents_documents_headers
3673
+ }));
3674
+ return response.document_infos;
3675
+ }
3676
+ /**
3677
+ * Delete text, images, sheets, and other files in the knowledge base, supporting batch deletion.
3678
+ * | 删除知识库中的文本、图像、表格等文件,支持批量删除。
3679
+ * @docs en: https://www.coze.com/docs/developer_guides/delete_knowledge_files?_lang=en
3680
+ * @docs zh: https://www.coze.cn/docs/developer_guides/delete_knowledge_files?_lang=zh
3681
+ * @param params.document_ids - Required The list of knowledge base files to be deleted. | 必选 待删除的文件 ID。
3682
+ * @returns void | 无返回
3683
+ */ async delete(params, options) {
3684
+ const apiUrl = '/open_api/knowledge/document/delete';
3685
+ await this._client.post(apiUrl, params, false, esm_mergeConfig(options, {
3686
+ headers: documents_documents_headers
3687
+ }));
3688
+ }
3689
+ /**
3690
+ * Modify the knowledge base file name and update strategy. | 调用接口修改知识库文件名称和更新策略。
3691
+ * @docs en: https://www.coze.com/docs/developer_guides/modify_knowledge_files?_lang=en
3692
+ * @docs zh: https://www.coze.cn/docs/developer_guides/modify_knowledge_files?_lang=zh
3693
+ * @param params.document_id - Required The ID of the knowledge base file. | 必选 待修改的知识库文件 ID。
3694
+ * @param params.document_name - Optional The new name of the knowledge base file. | 可选 知识库文件的新名称。
3695
+ * @param params.update_rule - Optional The update strategy for online web pages. | 可选 在线网页更新策略。
3696
+ * @returns void | 无返回
3697
+ */ async update(params, options) {
3698
+ const apiUrl = '/open_api/knowledge/document/update';
3699
+ await this._client.post(apiUrl, params, false, esm_mergeConfig(options, {
3700
+ headers: documents_documents_headers
3701
+ }));
3702
+ }
3703
+ }
3704
+ class Datasets extends APIResource {
3705
+ constructor(...args){
3706
+ super(...args), this.documents = new documents_Documents(this._client);
3541
3707
  }
3542
3708
  }
3543
3709
  class Voices extends APIResource {
@@ -3612,7 +3778,7 @@ class esm_Audio extends APIResource {
3612
3778
  super(...args), this.rooms = new Rooms(this._client), this.voices = new Voices(this._client), this.speech = new Speech(this._client);
3613
3779
  }
3614
3780
  }
3615
- var package_namespaceObject = JSON.parse('{"name":"@coze/api","version":"1.0.11","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":{".":{"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","browser":{"crypto":false,"os":false,"jsonwebtoken":false},"types":"dist/types/index.d.ts","files":["dist","LICENSE","README.md","!**/*.tsbuildinfo"],"scripts":{"build":"rm -rf dist && rslib build","format":"prettier --write .","lint":"eslint ./ --cache --quiet","prepublishOnly":"npm run build","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"}}'); // CONCATENATED MODULE: ./src/version.ts
3781
+ var package_namespaceObject = JSON.parse('{"name":"@coze/api","version":"1.0.15","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":{".":{"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","browser":{"crypto":false,"os":false,"jsonwebtoken":false},"types":"dist/types/index.d.ts","files":["dist","LICENSE","README.md","!**/*.tsbuildinfo"],"scripts":{"build":"rm -rf dist && rslib build","format":"prettier --write .","lint":"eslint ./ --cache --quiet","prepublishOnly":"npm run build","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"}}'); // CONCATENATED MODULE: ./src/version.ts
3616
3782
  const { version: esm_version } = package_namespaceObject;
3617
3783
  const getEnv = ()=>{
3618
3784
  const nodeVersion = process.version.slice(1); // Remove 'v' prefix
@@ -3675,6 +3841,11 @@ const getNodeClientUserAgent = ()=>{
3675
3841
  async function fetchAPI(url) {
3676
3842
  let options = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
3677
3843
  const axiosInstance = options.axiosInstance || lib_axios;
3844
+ // Add version check for streaming requests
3845
+ if (options.isStreaming && isAxiosStatic(axiosInstance)) {
3846
+ const axiosVersion = axiosInstance.VERSION || lib_axios.VERSION;
3847
+ if (!axiosVersion || compareVersions(axiosVersion, '1.7.1') < 0) throw new CozeError('Streaming requests require axios version 1.7.1 or higher. Please upgrade your axios version.');
3848
+ }
3678
3849
  const response = await axiosInstance({
3679
3850
  url,
3680
3851
  responseType: options.isStreaming ? 'stream' : 'json',
@@ -3687,12 +3858,12 @@ async function fetchAPI(url) {
3687
3858
  async *stream () {
3688
3859
  try {
3689
3860
  const stream = response.data;
3690
- const reader = stream[Symbol.asyncIterator]();
3861
+ const reader = stream[Symbol.asyncIterator] ? stream[Symbol.asyncIterator]() : stream.getReader();
3691
3862
  const decoder = new TextDecoder();
3692
3863
  const fieldValues = {};
3693
3864
  let buffer = '';
3694
3865
  while(true){
3695
- const { done, value } = await reader.next();
3866
+ const { done, value } = await (reader.next ? reader.next() : reader.read());
3696
3867
  if (done) {
3697
3868
  if (buffer) {
3698
3869
  // If the stream ends without a newline, it means an error occurred
@@ -3726,13 +3897,33 @@ async function fetchAPI(url) {
3726
3897
  response
3727
3898
  };
3728
3899
  }
3900
+ // Add version comparison utility
3901
+ function compareVersions(v1, v2) {
3902
+ const v1Parts = v1.split('.').map(Number);
3903
+ const v2Parts = v2.split('.').map(Number);
3904
+ for(let i = 0; i < 3; i++){
3905
+ const part1 = v1Parts[i] || 0;
3906
+ const part2 = v2Parts[i] || 0;
3907
+ if (part1 > part2) return 1;
3908
+ if (part1 < part2) return -1;
3909
+ }
3910
+ return 0;
3911
+ }
3912
+ function isAxiosStatic(instance) {
3913
+ return !!(null == instance ? void 0 : instance.Axios);
3914
+ }
3729
3915
  /**
3730
3916
  * default coze base URL is api.coze.com
3731
3917
  */ const COZE_COM_BASE_URL = 'https://api.coze.com';
3732
3918
  /* eslint-disable max-params */ class APIClient {
3733
- buildOptions(method, body, options) {
3919
+ async getToken() {
3920
+ if ('function' == typeof this.token) return await this.token();
3921
+ return this.token;
3922
+ }
3923
+ async buildOptions(method, body, options) {
3924
+ const token = await this.getToken();
3734
3925
  const headers = {
3735
- authorization: `Bearer ${this.token}`
3926
+ authorization: `Bearer ${token}`
3736
3927
  };
3737
3928
  if (!isBrowser()) {
3738
3929
  headers['User-Agent'] = getUserAgent();
@@ -3747,14 +3938,17 @@ async function fetchAPI(url) {
3747
3938
  }
3748
3939
  async makeRequest(apiUrl, method, body, isStream, options) {
3749
3940
  const fullUrl = `${this.baseURL}${apiUrl}`;
3750
- const fetchOptions = this.buildOptions(method, body, options);
3941
+ const fetchOptions = await this.buildOptions(method, body, options);
3751
3942
  fetchOptions.isStreaming = isStream;
3943
+ fetchOptions.axiosInstance = this.axiosInstance;
3752
3944
  this.debugLog(`--- request url: ${fullUrl}`);
3753
3945
  this.debugLog('--- request options:', fetchOptions);
3754
3946
  const { response, stream, json } = await fetchAPI(fullUrl, fetchOptions);
3755
3947
  this.debugLog(`--- response status: ${response.status}`);
3756
3948
  this.debugLog('--- response headers: ', response.headers);
3757
- const contentType = response.headers['content-type'];
3949
+ var _response_headers;
3950
+ // Taro use `header`
3951
+ const contentType = (null !== (_response_headers = response.headers) && void 0 !== _response_headers ? _response_headers : response.header)['content-type'];
3758
3952
  if (isStream) {
3759
3953
  if (contentType && contentType.includes('application/json')) {
3760
3954
  const result = await json();
@@ -3802,10 +3996,11 @@ async function fetchAPI(url) {
3802
3996
  this.baseURL = config.baseURL || COZE_COM_BASE_URL;
3803
3997
  this.token = config.token;
3804
3998
  this.axiosOptions = config.axiosOptions || {};
3999
+ this.axiosInstance = config.axiosInstance;
3805
4000
  this.debug = config.debug || false;
3806
4001
  this.allowPersonalAccessTokenInBrowser = config.allowPersonalAccessTokenInBrowser || false;
3807
4002
  this.headers = config.headers;
3808
- if (isBrowser() && isPersonalAccessToken(this.token) && !this.allowPersonalAccessTokenInBrowser) throw new CozeError('Browser environments do not support authentication using Personal Access Token (PAT) by default.\nas it may expose secret API keys. \n\nPlease use OAuth2.0 authentication mechanism. see:\nhttps://www.coze.com/docs/developer_guides/oauth_apps?_lang=en \n\nIf you need to force use, please set the `allowPersonalAccessTokenInBrowser` option to `true`. \n\ne.g new CozeAPI({ token, allowPersonalAccessTokenInBrowser: true });\n\n');
4003
+ if (isBrowser() && 'function' != typeof this.token && isPersonalAccessToken(this.token) && !this.allowPersonalAccessTokenInBrowser) throw new CozeError('Browser environments do not support authentication using Personal Access Token (PAT) by default.\nas it may expose secret API keys. \n\nPlease use OAuth2.0 authentication mechanism. see:\nhttps://www.coze.com/docs/developer_guides/oauth_apps?_lang=en \n\nIf you need to force use, please set the `allowPersonalAccessTokenInBrowser` option to `true`. \n\ne.g new CozeAPI({ token, allowPersonalAccessTokenInBrowser: true });\n\n');
3809
4004
  }
3810
4005
  }
3811
4006
  APIClient.APIError = APIError;
@@ -3820,7 +4015,9 @@ APIClient.TimeoutError = TimeoutError;
3820
4015
  APIClient.UserAbortError = APIUserAbortError;
3821
4016
  class CozeAPI extends APIClient {
3822
4017
  constructor(...args){
3823
- super(...args), this.bots = new Bots(this), this.chat = new Chat(this), this.conversations = new Conversations(this), this.files = new Files(this), this.knowledge = new Knowledge(this), this.workflows = new Workflows(this), this.workspaces = new WorkSpaces(this), this.audio = new esm_Audio(this);
4018
+ super(...args), this.bots = new Bots(this), this.chat = new Chat(this), this.conversations = new Conversations(this), this.files = new Files(this), /**
4019
+ * @deprecated
4020
+ */ this.knowledge = new Knowledge(this), this.datasets = new Datasets(this), this.workflows = new Workflows(this), this.workspaces = new WorkSpaces(this), this.audio = new esm_Audio(this);
3824
4021
  }
3825
4022
  }
3826
4023
  /**
@@ -12625,8 +12822,8 @@ function getBrowser() {
12625
12822
  }
12626
12823
  var _navigator$userAgent$, isFirefox = "mozilla" === getBrowser(), isSafari = "safari" === getBrowser(), isChrome = "chrome-stable" === getBrowser(), isCriOS = !isSSR2() && /CriOS/i.test(userAgentString), isEdgeForDesktop = !isSSR2() && /Edg\//i.test(userAgentString), isEdgeForAndroid = !isSSR2() && /EdgA/i.test(userAgentString), isEdgeForIOS = !isSSR2() && /EdgiOS/i.test(userAgentString), isEdge = isEdgeForDesktop || isEdgeForAndroid || isEdgeForIOS, isDingTalk = !isSSR2() && /DingTalk/i.test(navigator.userAgent), isOpera = !isSSR2() && /OPR\//.test(navigator.userAgent), isIPad = !isSSR2() && (!!/(iPad)/i.exec(userAgentString) || /Macintosh/i.test(userAgentString) && "ontouchend" in document), isMac = !isSSR2() && /Macintosh/i.test(userAgentString), isWeChat = !isSSR2() && /MicroMessenger/i.test(userAgentString), isMobile = !isSSR2() && _includesInstanceProperty(_context$3 = userAgentString.toLowerCase()).call(_context$3, "mobile"), isIOS = !isSSR2() && !!/(iPhone|iPad|iPod)/i.exec(userAgentString), isAndroid = !isSSR2() && /Android/i.test(userAgentString), isWindows = !isSSR2() && /Windows/i.test(userAgentString), isOpenHarmony = !isSSR2() && /OpenHarmony/i.test(userAgentString), sv = 0, sv2 = "0", index_esm_min_v = !isSSR2() && (null === (_userAgentString$matc = userAgentString.match(/version\/(\d+)/i)) || void 0 === _userAgentString$matc ? void 0 : _userAgentString$matc[1]);
12627
12824
  isSafari && index_esm_min_v && (sv = Number(index_esm_min_v), sv2 = null === (_navigator$userAgent$ = navigator.userAgent.match(/version\/(\d+\.\d+)/i)) || void 0 === _navigator$userAgent$ ? void 0 : _navigator$userAgent$[1]);
12628
- var v2 = !isSSR2() && (null === (_userAgentString$matc2 = userAgentString.match(/Firefox\/(\d+)/i)) || void 0 === _userAgentString$matc2 ? void 0 : _userAgentString$matc2[1]);
12629
- isFirefox && v2 && (sv = Number(v2));
12825
+ var index_esm_min_v2 = !isSSR2() && (null === (_userAgentString$matc2 = userAgentString.match(/Firefox\/(\d+)/i)) || void 0 === _userAgentString$matc2 ? void 0 : _userAgentString$matc2[1]);
12826
+ isFirefox && index_esm_min_v2 && (sv = Number(index_esm_min_v2));
12630
12827
  var safariVersion = sv, firefoxVersion = sv, safariMinorVersion = sv2, iOSVersion = null !== (_ref = !isSSR2() && (null === (_userAgentString$matc3 = userAgentString.match(/ ([\d_]+) like Mac OS X/i)) || void 0 === _userAgentString$matc3 || null === (_userAgentString$matc4 = _userAgentString$matc3[1]) || void 0 === _userAgentString$matc4 ? void 0 : _mapInstanceProperty(_context2 = _userAgentString$matc4.split("_")).call(_context2, function(e) {
12631
12828
  return _parseInt$7(e);
12632
12829
  }))) && void 0 !== _ref ? _ref : [], cv = 0, cvs = !isSSR2() && (null === (_userAgentString$matc5 = userAgentString.match(/Chrome\/(\d+)/i)) || void 0 === _userAgentString$matc5 ? void 0 : _userAgentString$matc5[1]);
@@ -38210,6 +38407,7 @@ var VERTC = _createClass(function e() {
38210
38407
  return new Promise((resolve)=>setTimeout(resolve, milliseconds));
38211
38408
  };
38212
38409
  /**
38410
+ * @deprecated use checkDevicePermission instead
38213
38411
  * Check microphone permission,return boolean
38214
38412
  */ const checkPermission = async function() {
38215
38413
  let { audio = true, video = false } = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
@@ -38224,22 +38422,32 @@ var VERTC = _createClass(function e() {
38224
38422
  return false;
38225
38423
  }
38226
38424
  };
38425
+ const checkDevicePermission = async function() {
38426
+ let checkVideo = arguments.length > 0 && void 0 !== arguments[0] && arguments[0];
38427
+ return await index_esm_min_index.enableDevices({
38428
+ audio: true,
38429
+ video: checkVideo
38430
+ });
38431
+ };
38227
38432
  /**
38228
38433
  * Get audio devices
38229
38434
  * @returns Promise<AudioDevices> Object containing arrays of audio input and output devices
38230
- */ const getAudioDevices = async ()=>{
38231
- const devices = await index_esm_min_index.enumerateDevices();
38435
+ */ const getAudioDevices = async function() {
38436
+ let { video = false } = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
38437
+ let devices = [];
38438
+ devices = video ? await index_esm_min_index.enumerateDevices() : await [
38439
+ ...await index_esm_min_index.enumerateAudioCaptureDevices(),
38440
+ ...await index_esm_min_index.enumerateAudioPlaybackDevices()
38441
+ ];
38232
38442
  if (!(null == devices ? void 0 : devices.length)) return {
38233
38443
  audioInputs: [],
38234
38444
  audioOutputs: [],
38235
- videoInputs: [],
38236
- videoOutputs: []
38445
+ videoInputs: []
38237
38446
  };
38238
38447
  return {
38239
38448
  audioInputs: devices.filter((i)=>i.deviceId && 'audioinput' === i.kind),
38240
38449
  audioOutputs: devices.filter((i)=>i.deviceId && 'audiooutput' === i.kind),
38241
- videoInputs: devices.filter((i)=>i.deviceId && 'videoinput' === i.kind),
38242
- videoOutputs: devices.filter((i)=>i.deviceId && 'videooutput' === i.kind)
38450
+ videoInputs: devices.filter((i)=>i.deviceId && 'videoinput' === i.kind)
38243
38451
  };
38244
38452
  };
38245
38453
  var error_RealtimeError = /*#__PURE__*/ function(RealtimeError) {
@@ -38342,6 +38550,34 @@ var event_handler_EventNames = /*#__PURE__*/ function(EventNames) {
38342
38550
  * en: Bot left
38343
38551
  * zh: Bot 离开
38344
38552
  */ EventNames["BOT_LEAVE"] = "server.bot.leave";
38553
+ /**
38554
+ * en: Audio speech started
38555
+ * zh: 开始说话
38556
+ */ EventNames["AUDIO_AGENT_SPEECH_STARTED"] = "server.audio.agent.speech_started";
38557
+ /**
38558
+ * en: Audio speech stopped
38559
+ * zh: 停止说话
38560
+ */ EventNames["AUDIO_SPEECH_STOPPED"] = "server.audio.speech_stopped";
38561
+ /**
38562
+ * en: Server error
38563
+ * zh: 服务端错误
38564
+ */ EventNames["SERVER_ERROR"] = "server.error";
38565
+ /**
38566
+ * en: User speech started
38567
+ * zh: 用户开始说话
38568
+ */ EventNames["AUDIO_USER_SPEECH_STARTED"] = "server.audio.user.speech_started";
38569
+ /**
38570
+ * en: User speech stopped
38571
+ * zh: 用户停止说话
38572
+ */ EventNames["AUDIO_USER_SPEECH_STOPPED"] = "server.audio.user.speech_stopped";
38573
+ /**
38574
+ * en: User successfully enters the room
38575
+ * zh: 用户成功进入房间后,会收到该事件
38576
+ */ EventNames["SESSION_CREATED"] = "server.session.created";
38577
+ /**
38578
+ * en: Session updated
38579
+ * zh: 会话更新
38580
+ */ EventNames["SESSION_UPDATE"] = "server.session.update";
38345
38581
  return EventNames;
38346
38582
  }({});
38347
38583
  class RealtimeEventHandler {
@@ -38372,7 +38608,8 @@ class RealtimeEventHandler {
38372
38608
  }
38373
38609
  }
38374
38610
  dispatch(eventName, event) {
38375
- this._log(`dispatch ${eventName} event`);
38611
+ let consoleLog = !(arguments.length > 2) || void 0 === arguments[2] || arguments[2];
38612
+ if (consoleLog) this._log(`dispatch ${eventName} event`);
38376
38613
  const handlers = (this.eventHandlers[eventName] || []).slice();
38377
38614
  this._dispatchToHandlers(eventName, event, handlers);
38378
38615
  const allHandlers = (this.eventHandlers["realtime.event"] || []).slice();
@@ -41641,7 +41878,7 @@ class EngineClient extends RealtimeEventHandler {
41641
41878
  this.engine.on(index_esm_min_index.events.onUserJoined, this.handleUserJoin);
41642
41879
  this.engine.on(index_esm_min_index.events.onUserLeave, this.handleUserLeave);
41643
41880
  this.engine.on(index_esm_min_index.events.onError, this.handleEventError);
41644
- this.engine.on(index_esm_min_index.events.onPlayerEvent, this.handlePlayerEvent);
41881
+ if (this._isSupportVideo) this.engine.on(index_esm_min_index.events.onPlayerEvent, this.handlePlayerEvent);
41645
41882
  if (this._debug) {
41646
41883
  this.engine.on(index_esm_min_index.events.onLocalAudioPropertiesReport, this.handleLocalAudioPropertiesReport);
41647
41884
  this.engine.on(index_esm_min_index.events.onRemoteAudioPropertiesReport, this.handleRemoteAudioPropertiesReport);
@@ -41652,7 +41889,7 @@ class EngineClient extends RealtimeEventHandler {
41652
41889
  this.engine.off(index_esm_min_index.events.onUserJoined, this.handleUserJoin);
41653
41890
  this.engine.off(index_esm_min_index.events.onUserLeave, this.handleUserLeave);
41654
41891
  this.engine.off(index_esm_min_index.events.onError, this.handleEventError);
41655
- this.engine.off(index_esm_min_index.events.onPlayerEvent, this.handlePlayerEvent);
41892
+ if (this._isSupportVideo) this.engine.off(index_esm_min_index.events.onPlayerEvent, this.handlePlayerEvent);
41656
41893
  if (this._debug) {
41657
41894
  this.engine.off(index_esm_min_index.events.onLocalAudioPropertiesReport, this.handleLocalAudioPropertiesReport);
41658
41895
  this.engine.off(index_esm_min_index.events.onRemoteAudioPropertiesReport, this.handleRemoteAudioPropertiesReport);
@@ -41697,13 +41934,13 @@ class EngineClient extends RealtimeEventHandler {
41697
41934
  this.dispatch(event_handler_EventNames.PLAYER_EVENT, event);
41698
41935
  }
41699
41936
  async joinRoom(options) {
41700
- const { token, roomId, uid, audioMutedDefault, videoOnDefault } = options;
41937
+ const { token, roomId, uid, audioMutedDefault, videoOnDefault, isAutoSubscribeAudio } = options;
41701
41938
  try {
41702
41939
  await this.engine.joinRoom(token, roomId, {
41703
41940
  userId: uid
41704
41941
  }, {
41705
41942
  isAutoPublish: !audioMutedDefault,
41706
- isAutoSubscribeAudio: true,
41943
+ isAutoSubscribeAudio,
41707
41944
  isAutoSubscribeVideo: this._isSupportVideo && videoOnDefault
41708
41945
  });
41709
41946
  } catch (e) {
@@ -41717,14 +41954,18 @@ class EngineClient extends RealtimeEventHandler {
41717
41954
  await this.engine.startAudioCapture(deviceId);
41718
41955
  }
41719
41956
  async setAudioOutputDevice(deviceId) {
41720
- const devices = await getAudioDevices();
41957
+ const devices = await getAudioDevices({
41958
+ video: false
41959
+ });
41721
41960
  if (-1 === devices.audioOutputs.findIndex((i)=>i.deviceId === deviceId)) throw new RealtimeAPIError(error_RealtimeError.DEVICE_ACCESS_ERROR, `Audio output device not found: ${deviceId}`);
41722
41961
  await this.engine.setAudioPlaybackDevice(deviceId);
41723
41962
  }
41724
41963
  async createLocalStream(userId, videoConfig) {
41725
- const devices = await getAudioDevices();
41726
- if (!devices.audioInputs.length) throw new RealtimeAPIError(error_RealtimeError.DEVICE_ACCESS_ERROR, 'Failed to get devices');
41727
- if (this._isSupportVideo && !devices.videoInputs.length) throw new RealtimeAPIError(error_RealtimeError.DEVICE_ACCESS_ERROR, 'Failed to get devices');
41964
+ const devices = await getAudioDevices({
41965
+ video: this._isSupportVideo
41966
+ });
41967
+ if (!devices.audioInputs.length) throw new RealtimeAPIError(error_RealtimeError.DEVICE_ACCESS_ERROR, 'Failed to get audio devices');
41968
+ if (this._isSupportVideo && !devices.videoInputs.length) throw new RealtimeAPIError(error_RealtimeError.DEVICE_ACCESS_ERROR, 'Failed to get video devices');
41728
41969
  await this.engine.startAudioCapture(devices.audioInputs[0].deviceId);
41729
41970
  if (this._isSupportVideo && (null == videoConfig ? void 0 : videoConfig.videoOnDefault)) await this.engine.startVideoCapture(devices.videoInputs[0].deviceId);
41730
41971
  if (this._isSupportVideo) this.engine.setLocalVideoPlayer(StreamIndex$1.STREAM_INDEX_MAIN, {
@@ -41877,7 +42118,7 @@ class RealtimeClient extends RealtimeEventHandler {
41877
42118
  // Step3 bind engine events
41878
42119
  this._client.bindEngineEvents();
41879
42120
  this._client.on(event_handler_EventNames.ALL, (eventName, data)=>{
41880
- this.dispatch(eventName, data);
42121
+ this.dispatch(eventName, data, false);
41881
42122
  });
41882
42123
  if (this._config.suppressStationaryNoise) {
41883
42124
  await this._client.enableAudioNoiseReduction();
@@ -41888,14 +42129,15 @@ class RealtimeClient extends RealtimeEventHandler {
41888
42129
  this._client.changeAIAnsExtension(true);
41889
42130
  this.dispatch(event_handler_EventNames.SUPPRESS_NON_STATIONARY_NOISE, {});
41890
42131
  }
41891
- var _this__config_audioMutedDefault, _this__config_videoConfig_videoOnDefault;
42132
+ var _this__config_audioMutedDefault, _this__config_videoConfig_videoOnDefault, _this__config_isAutoSubscribeAudio;
41892
42133
  // Step4 join room
41893
42134
  await this._client.joinRoom({
41894
42135
  token: roomInfo.token,
41895
42136
  roomId: roomInfo.room_id,
41896
42137
  uid: roomInfo.uid,
41897
42138
  audioMutedDefault: null !== (_this__config_audioMutedDefault = this._config.audioMutedDefault) && void 0 !== _this__config_audioMutedDefault && _this__config_audioMutedDefault,
41898
- videoOnDefault: null === (_this__config_videoConfig_videoOnDefault = null === (_this__config_videoConfig = this._config.videoConfig) || void 0 === _this__config_videoConfig ? void 0 : _this__config_videoConfig.videoOnDefault) || void 0 === _this__config_videoConfig_videoOnDefault || _this__config_videoConfig_videoOnDefault
42139
+ videoOnDefault: null === (_this__config_videoConfig_videoOnDefault = null === (_this__config_videoConfig = this._config.videoConfig) || void 0 === _this__config_videoConfig ? void 0 : _this__config_videoConfig.videoOnDefault) || void 0 === _this__config_videoConfig_videoOnDefault || _this__config_videoConfig_videoOnDefault,
42140
+ isAutoSubscribeAudio: null === (_this__config_isAutoSubscribeAudio = this._config.isAutoSubscribeAudio) || void 0 === _this__config_isAutoSubscribeAudio || _this__config_isAutoSubscribeAudio
41899
42141
  });
41900
42142
  // Step5 create local stream
41901
42143
  await this._client.createLocalStream(roomInfo.uid, this._config.videoConfig);
@@ -41907,7 +42149,6 @@ class RealtimeClient extends RealtimeEventHandler {
41907
42149
  token: roomInfo.token,
41908
42150
  appId: roomInfo.app_id
41909
42151
  });
41910
- this._log('dispatch client.connected event');
41911
42152
  }
41912
42153
  /**
41913
42154
  * en: Interrupt the current conversation
@@ -41917,7 +42158,6 @@ class RealtimeClient extends RealtimeEventHandler {
41917
42158
  var _this__client;
41918
42159
  await (null === (_this__client = this._client) || void 0 === _this__client ? void 0 : _this__client.stop());
41919
42160
  this.dispatch(event_handler_EventNames.INTERRUPTED, {});
41920
- this._log('dispatch client.interrupted event');
41921
42161
  }
41922
42162
  /**
41923
42163
  * en: Disconnect from the current session
@@ -42039,6 +42279,7 @@ class RealtimeClient extends RealtimeEventHandler {
42039
42279
  * 可选,默认是否抑制静态噪声,默认值为 false。
42040
42280
  * @param config.suppressNonStationaryNoise - Optional, suppress non-stationary noise, defaults to false. |
42041
42281
  * 可选,默认是否抑制非静态噪声,默认值为 false。
42282
+ * @param config.isAutoSubscribeAudio - Optional, whether to automatically subscribe to bot reply audio streams, defaults to true. |
42042
42283
  */ constructor(config){
42043
42284
  super(config.debug), this._client = null, this.isConnected = false, this._isTestEnv = false, this._isSupportVideo = false;
42044
42285
  this._config = config;