@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.
@@ -1,11 +1,11 @@
1
1
  /*! For license information please see index.cjs.LICENSE.txt */
2
2
  "use strict";
3
3
  var __webpack_modules__ = {
4
- "?de24": function() {
4
+ "?c628": function() {
5
5
  /* (ignored) */ },
6
- "?2a9f": function() {
6
+ "?9452": function() {
7
7
  /* (ignored) */ },
8
- "?d039": function() {
8
+ "?e2b1": function() {
9
9
  /* (ignored) */ }
10
10
  };
11
11
  /************************************************************************/ // The module cache
@@ -73,7 +73,7 @@ __webpack_require__.d(__webpack_exports__, {
73
73
  EventNames: ()=>/* reexport */ event_handler_EventNames,
74
74
  RealtimeClient: ()=>/* binding */ RealtimeClient
75
75
  });
76
- // NAMESPACE OBJECT: ../../common/temp/default/node_modules/.pnpm/axios@1.7.7/node_modules/axios/lib/platform/common/utils.js
76
+ // NAMESPACE OBJECT: ../../common/temp/default/node_modules/.pnpm/axios@1.7.7_debug@4.3.7/node_modules/axios/lib/platform/common/utils.js
77
77
  var common_utils_namespaceObject = {};
78
78
  __webpack_require__.r(common_utils_namespaceObject);
79
79
  __webpack_require__.d(common_utils_namespaceObject, {
@@ -87,6 +87,7 @@ __webpack_require__.d(common_utils_namespaceObject, {
87
87
  var src_utils_namespaceObject = {};
88
88
  __webpack_require__.r(src_utils_namespaceObject);
89
89
  __webpack_require__.d(src_utils_namespaceObject, {
90
+ checkDevicePermission: ()=>checkDevicePermission,
90
91
  checkPermission: ()=>checkPermission,
91
92
  getAudioDevices: ()=>getAudioDevices,
92
93
  sleep: ()=>utils_sleep
@@ -2135,7 +2136,7 @@ const trackStream = (stream, chunkSize, onProgress, onFinish)=>{
2135
2136
  }, {
2136
2137
  highWaterMark: 2
2137
2138
  });
2138
- }; // CONCATENATED MODULE: ../../common/temp/default/node_modules/.pnpm/axios@1.7.7/node_modules/axios/lib/adapters/fetch.js
2139
+ }; // CONCATENATED MODULE: ../../common/temp/default/node_modules/.pnpm/axios@1.7.7_debug@4.3.7/node_modules/axios/lib/adapters/fetch.js
2139
2140
  const isFetchSupported = 'function' == typeof fetch && 'function' == typeof Request && 'function' == typeof Response;
2140
2141
  const isReadableStreamSupported = isFetchSupported && 'function' == typeof ReadableStream;
2141
2142
  // used only inside the fetch adapter
@@ -2857,11 +2858,11 @@ axios.default = axios;
2857
2858
  // so that it can keep same with es module or cjs
2858
2859
  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;
2859
2860
  // EXTERNAL MODULE: os (ignored)
2860
- var os_ignored_ = __webpack_require__("?d039");
2861
+ var os_ignored_ = __webpack_require__("?e2b1");
2861
2862
  // EXTERNAL MODULE: crypto (ignored)
2862
- __webpack_require__("?de24");
2863
+ __webpack_require__("?c628");
2863
2864
  // EXTERNAL MODULE: jsonwebtoken (ignored)
2864
- __webpack_require__("?2a9f");
2865
+ __webpack_require__("?9452");
2865
2866
  class APIResource {
2866
2867
  constructor(client){
2867
2868
  this._client = client;
@@ -3103,6 +3104,10 @@ class Messages extends APIResource {
3103
3104
  }
3104
3105
  }
3105
3106
  const uuid = ()=>(Math.random() * new Date().getTime()).toString();
3107
+ const handleAdditionalMessages = (additional_messages)=>null == additional_messages ? void 0 : additional_messages.map((i)=>({
3108
+ ...i,
3109
+ content: 'object' == typeof i.content ? JSON.stringify(i.content) : i.content
3110
+ }));
3106
3111
  class Chat extends APIResource {
3107
3112
  /**
3108
3113
  * Call the Chat API to send messages to a published Coze agent. | 调用此接口发起一次对话,支持添加上下文
@@ -3124,6 +3129,7 @@ class Chat extends APIResource {
3124
3129
  const apiUrl = `/v3/chat${conversation_id ? `?conversation_id=${conversation_id}` : ''}`;
3125
3130
  const payload = {
3126
3131
  ...rest,
3132
+ additional_messages: handleAdditionalMessages(params.additional_messages),
3127
3133
  stream: false
3128
3134
  };
3129
3135
  const result = await this._client.post(apiUrl, payload, false, options);
@@ -3149,6 +3155,7 @@ class Chat extends APIResource {
3149
3155
  const apiUrl = `/v3/chat${conversation_id ? `?conversation_id=${conversation_id}` : ''}`;
3150
3156
  const payload = {
3151
3157
  ...rest,
3158
+ additional_messages: handleAdditionalMessages(params.additional_messages),
3152
3159
  stream: false
3153
3160
  };
3154
3161
  const result = await this._client.post(apiUrl, payload, false, options);
@@ -3186,6 +3193,7 @@ class Chat extends APIResource {
3186
3193
  const apiUrl = `/v3/chat${conversation_id ? `?conversation_id=${conversation_id}` : ''}`;
3187
3194
  const payload = {
3188
3195
  ...rest,
3196
+ additional_messages: handleAdditionalMessages(params.additional_messages),
3189
3197
  stream: true
3190
3198
  };
3191
3199
  const result = await this._client.post(apiUrl, payload, true, options);
@@ -3276,6 +3284,19 @@ class Chat extends APIResource {
3276
3284
  super(...args), this.messages = new Messages(this._client);
3277
3285
  }
3278
3286
  }
3287
+ var chat_ChatEventType = /*#__PURE__*/ function(ChatEventType) {
3288
+ ChatEventType["CONVERSATION_CHAT_CREATED"] = "conversation.chat.created";
3289
+ ChatEventType["CONVERSATION_CHAT_IN_PROGRESS"] = "conversation.chat.in_progress";
3290
+ ChatEventType["CONVERSATION_CHAT_COMPLETED"] = "conversation.chat.completed";
3291
+ ChatEventType["CONVERSATION_CHAT_FAILED"] = "conversation.chat.failed";
3292
+ ChatEventType["CONVERSATION_CHAT_REQUIRES_ACTION"] = "conversation.chat.requires_action";
3293
+ ChatEventType["CONVERSATION_MESSAGE_DELTA"] = "conversation.message.delta";
3294
+ ChatEventType["CONVERSATION_MESSAGE_COMPLETED"] = "conversation.message.completed";
3295
+ ChatEventType["CONVERSATION_AUDIO_DELTA"] = "conversation.audio.delta";
3296
+ ChatEventType["DONE"] = "done";
3297
+ ChatEventType["ERROR"] = "error";
3298
+ return ChatEventType;
3299
+ }({});
3279
3300
  class messages_Messages extends APIResource {
3280
3301
  /**
3281
3302
  * Create a message and add it to the specified conversation. | 创建一条消息,并将其添加到指定的会话中。
@@ -3360,6 +3381,7 @@ class Conversations extends APIResource {
3360
3381
  * @param params - Required The parameters for creating a conversation | 创建会话所需的参数
3361
3382
  * @param params.messages - Optional Messages in the conversation. | 会话中的消息内容。
3362
3383
  * @param params.meta_data - Optional Additional information when creating a message. | 创建消息时的附加消息。
3384
+ * @param params.bot_id - Optional Bind and isolate conversation on different bots. | 绑定和隔离不同Bot的会话。
3363
3385
  * @returns Information about the created conversation. | 会话的基础信息。
3364
3386
  */ async create(params, options) {
3365
3387
  const apiUrl = '/v1/conversation/create';
@@ -3377,6 +3399,27 @@ class Conversations extends APIResource {
3377
3399
  const response = await this._client.get(apiUrl, null, false, options);
3378
3400
  return response.data;
3379
3401
  }
3402
+ /**
3403
+ * List all conversations. | 列出 Bot 下所有会话。
3404
+ * @param params
3405
+ * @param params.bot_id - Required Bot ID. | Bot ID。
3406
+ * @param params.page_num - Optional The page number. | 页码,默认值为 1。
3407
+ * @param params.page_size - Optional The number of conversations per page. | 每页的会话数量,默认值为 50。
3408
+ * @returns Information about the conversations. | 会话的信息。
3409
+ */ async list(params, options) {
3410
+ const apiUrl = '/v1/conversations';
3411
+ const response = await this._client.get(apiUrl, params, false, options);
3412
+ return response.data;
3413
+ }
3414
+ /**
3415
+ * Clear a conversation. | 清空会话。
3416
+ * @param conversation_id - Required The ID of the conversation. | Conversation ID,即会话的唯一标识。
3417
+ * @returns Information about the conversation session. | 会话的会话 ID。
3418
+ */ async clear(conversation_id, options) {
3419
+ const apiUrl = `/v1/conversations/${conversation_id}/clear`;
3420
+ const response = await this._client.post(apiUrl, null, false, options);
3421
+ return response.data;
3422
+ }
3380
3423
  constructor(...args){
3381
3424
  super(...args), this.messages = new messages_Messages(this._client);
3382
3425
  }
@@ -3415,6 +3458,9 @@ class Runs extends APIResource {
3415
3458
  * @param params.bot_id - Optional The ID of the bot associated with the workflow. | 可选 与工作流关联的机器人 ID。
3416
3459
  * @param params.parameters - Optional Parameters for the workflow execution. | 可选 工作流执行的参数。
3417
3460
  * @param params.ext - Optional Additional information for the workflow execution. | 可选 工作流执行的附加信息。
3461
+ * @param params.execute_mode - Optional The mode in which to execute the workflow. | 可选 工作流执行的模式。
3462
+ * @param params.connector_id - Optional The ID of the connector to use for the workflow. | 可选 用于工作流的连接器 ID。
3463
+ * @param params.app_id - Optional The ID of the app. | 可选 要进行会话聊天的 App ID
3418
3464
  * @returns RunWorkflowData | 工作流运行数据
3419
3465
  */ async create(params, options) {
3420
3466
  const apiUrl = '/v1/workflow/run';
@@ -3429,6 +3475,9 @@ class Runs extends APIResource {
3429
3475
  * @param params.bot_id - Optional The ID of the bot associated with the workflow. | 可选 与工作流关联的机器人 ID。
3430
3476
  * @param params.parameters - Optional Parameters for the workflow execution. | 可选 工作流执行的参数。
3431
3477
  * @param params.ext - Optional Additional information for the workflow execution. | 可选 工作流执行的附加信息。
3478
+ * @param params.execute_mode - Optional The mode in which to execute the workflow. | 可选 工作流执行的模式。
3479
+ * @param params.connector_id - Optional The ID of the connector to use for the workflow. | 可选 用于工作流的连接器 ID。
3480
+ * @param params.app_id - Optional The ID of the app. | 可选 要进行会话聊天的 App ID
3432
3481
  * @returns Stream<WorkflowEvent, { id: string; event: string; data: string }> | 工作流事件流
3433
3482
  */ async *stream(params, options) {
3434
3483
  const apiUrl = '/v1/workflow/stream_run';
@@ -3462,9 +3511,46 @@ class WorkflowEvent {
3462
3511
  this.data = data;
3463
3512
  }
3464
3513
  }
3514
+ class WorkflowChat extends APIResource {
3515
+ /**
3516
+ * Execute a chat workflow. | 执行对话流
3517
+ * @docs en: https://www.coze.cn/docs/developer_guides/workflow_chat?_lang=en
3518
+ * @docs zh: https://www.coze.cn/docs/developer_guides/workflow_chat?_lang=zh
3519
+ * @param params.workflow_id - Required The ID of the workflow to chat with. | 必选 要对话的工作流 ID。
3520
+ * @param params.additional_messages - Required Array of messages for the chat. | 必选 对话的消息数组。
3521
+ * @param params.parameters - Required Parameters for the workflow execution. | 必选 工作流执行的参数。
3522
+ * @param params.app_id - Optional The ID of the app. | 可选 应用 ID。
3523
+ * @param params.bot_id - Optional The ID of the bot. | 可选 Bot ID。
3524
+ * @param params.conversation_id - Optional The ID of the conversation. | 可选 会话 ID。
3525
+ * @param params.ext - Optional Additional information for the chat. | 可选 对话的附加信息。
3526
+ * @returns AsyncGenerator<StreamChatData> | 对话数据流
3527
+ */ async *stream(params, options) {
3528
+ const apiUrl = '/v1/workflows/chat';
3529
+ const payload = {
3530
+ ...params,
3531
+ additional_messages: handleAdditionalMessages(params.additional_messages)
3532
+ };
3533
+ const result = await this._client.post(apiUrl, payload, true, options);
3534
+ for await (const message of result)if (message.event === chat_ChatEventType.DONE) {
3535
+ const ret = {
3536
+ event: message.event,
3537
+ data: '[DONE]'
3538
+ };
3539
+ yield ret;
3540
+ } else try {
3541
+ const ret = {
3542
+ event: message.event,
3543
+ data: JSON.parse(message.data)
3544
+ };
3545
+ yield ret;
3546
+ } catch (error) {
3547
+ throw new CozeError(`Could not parse message into JSON:${message.data}`);
3548
+ }
3549
+ }
3550
+ }
3465
3551
  class Workflows extends APIResource {
3466
3552
  constructor(...args){
3467
- super(...args), this.runs = new Runs(this._client);
3553
+ super(...args), this.runs = new Runs(this._client), this.chat = new WorkflowChat(this._client);
3468
3554
  }
3469
3555
  }
3470
3556
  class WorkSpaces extends APIResource {
@@ -3488,6 +3574,8 @@ const documents_headers = {
3488
3574
  };
3489
3575
  class Documents extends APIResource {
3490
3576
  /**
3577
+ * @deprecated The method is deprecated and will be removed in a future version. Please use 'client.datasets.documents.list' instead.
3578
+ *
3491
3579
  * View the file list of a specified knowledge base, which includes lists of documents, spreadsheets, or images.
3492
3580
  * | 调用接口查看指定知识库的内容列表,即文件、表格或图像列表。
3493
3581
  * @docs en: https://www.coze.com/docs/developer_guides/list_knowledge_files?_lang=en
@@ -3504,6 +3592,8 @@ class Documents extends APIResource {
3504
3592
  return response;
3505
3593
  }
3506
3594
  /**
3595
+ * @deprecated The method is deprecated and will be removed in a future version. Please use 'client.datasets.documents.create' instead.
3596
+ *
3507
3597
  * Upload files to the specific knowledge. | 调用此接口向指定知识库中上传文件。
3508
3598
  * @docs en: https://www.coze.com/docs/developer_guides/create_knowledge_files?_lang=en
3509
3599
  * @docs zh: https://www.coze.cn/docs/developer_guides/create_knowledge_files?_lang=zh
@@ -3520,6 +3610,8 @@ class Documents extends APIResource {
3520
3610
  return response.document_infos;
3521
3611
  }
3522
3612
  /**
3613
+ * @deprecated The method is deprecated and will be removed in a future version. Please use 'client.datasets.documents.delete' instead.
3614
+ *
3523
3615
  * Delete text, images, sheets, and other files in the knowledge base, supporting batch deletion.
3524
3616
  * | 删除知识库中的文本、图像、表格等文件,支持批量删除。
3525
3617
  * @docs en: https://www.coze.com/docs/developer_guides/delete_knowledge_files?_lang=en
@@ -3533,6 +3625,8 @@ class Documents extends APIResource {
3533
3625
  }));
3534
3626
  }
3535
3627
  /**
3628
+ * @deprecated The method is deprecated and will be removed in a future version. Please use 'client.datasets.documents.update' instead.
3629
+ *
3536
3630
  * Modify the knowledge base file name and update strategy. | 调用接口修改知识库文件名称和更新策略。
3537
3631
  * @docs en: https://www.coze.com/docs/developer_guides/modify_knowledge_files?_lang=en
3538
3632
  * @docs zh: https://www.coze.cn/docs/developer_guides/modify_knowledge_files?_lang=zh
@@ -3549,7 +3643,79 @@ class Documents extends APIResource {
3549
3643
  }
3550
3644
  class Knowledge extends APIResource {
3551
3645
  constructor(...args){
3552
- super(...args), this.documents = new Documents(this._client);
3646
+ super(...args), /**
3647
+ * @deprecated
3648
+ */ this.documents = new Documents(this._client);
3649
+ }
3650
+ }
3651
+ // Required header for knowledge APIs
3652
+ const documents_documents_headers = {
3653
+ 'agw-js-conv': 'str'
3654
+ };
3655
+ class documents_Documents extends APIResource {
3656
+ /**
3657
+ * View the file list of a specified knowledge base, which includes lists of documents, spreadsheets, or images.
3658
+ * | 调用接口查看指定知识库的内容列表,即文件、表格或图像列表。
3659
+ * @docs en: https://www.coze.com/docs/developer_guides/list_knowledge_files?_lang=en
3660
+ * @docs zh: https://www.coze.cn/docs/developer_guides/list_knowledge_files?_lang=zh
3661
+ * @param params.dataset_id - Required The ID of the knowledge base. | 必选 待查看文件的知识库 ID。
3662
+ * @param params.page - Optional The page number for paginated queries. Default is 1. | 可选 分页查询时的页码。默认为 1。
3663
+ * @param params.page_size - Optional The size of pagination. Default is 10. | 可选 分页大小。默认为 10。
3664
+ * @returns ListDocumentData | 知识库文件列表
3665
+ */ list(params, options) {
3666
+ const apiUrl = '/open_api/knowledge/document/list';
3667
+ const response = this._client.get(apiUrl, params, false, esm_mergeConfig(options, {
3668
+ headers: documents_documents_headers
3669
+ }));
3670
+ return response;
3671
+ }
3672
+ /**
3673
+ * Upload files to the specific knowledge. | 调用此接口向指定知识库中上传文件。
3674
+ * @docs en: https://www.coze.com/docs/developer_guides/create_knowledge_files?_lang=en
3675
+ * @docs zh: https://www.coze.cn/docs/developer_guides/create_knowledge_files?_lang=zh
3676
+ * @param params.dataset_id - Required The ID of the knowledge. | 必选 知识库 ID。
3677
+ * @param params.document_bases - Required The metadata information of the files awaiting upload. | 必选 待上传文件的元数据信息。
3678
+ * @param params.chunk_strategy - Required when uploading files to a new knowledge for the first time. Chunk strategy.
3679
+ * | 向新知识库首次上传文件时必选 分段规则。
3680
+ * @returns DocumentInfo[] | 已上传文件的基本信息
3681
+ */ async create(params, options) {
3682
+ const apiUrl = '/open_api/knowledge/document/create';
3683
+ const response = await this._client.post(apiUrl, params, false, esm_mergeConfig(options, {
3684
+ headers: documents_documents_headers
3685
+ }));
3686
+ return response.document_infos;
3687
+ }
3688
+ /**
3689
+ * Delete text, images, sheets, and other files in the knowledge base, supporting batch deletion.
3690
+ * | 删除知识库中的文本、图像、表格等文件,支持批量删除。
3691
+ * @docs en: https://www.coze.com/docs/developer_guides/delete_knowledge_files?_lang=en
3692
+ * @docs zh: https://www.coze.cn/docs/developer_guides/delete_knowledge_files?_lang=zh
3693
+ * @param params.document_ids - Required The list of knowledge base files to be deleted. | 必选 待删除的文件 ID。
3694
+ * @returns void | 无返回
3695
+ */ async delete(params, options) {
3696
+ const apiUrl = '/open_api/knowledge/document/delete';
3697
+ await this._client.post(apiUrl, params, false, esm_mergeConfig(options, {
3698
+ headers: documents_documents_headers
3699
+ }));
3700
+ }
3701
+ /**
3702
+ * Modify the knowledge base file name and update strategy. | 调用接口修改知识库文件名称和更新策略。
3703
+ * @docs en: https://www.coze.com/docs/developer_guides/modify_knowledge_files?_lang=en
3704
+ * @docs zh: https://www.coze.cn/docs/developer_guides/modify_knowledge_files?_lang=zh
3705
+ * @param params.document_id - Required The ID of the knowledge base file. | 必选 待修改的知识库文件 ID。
3706
+ * @param params.document_name - Optional The new name of the knowledge base file. | 可选 知识库文件的新名称。
3707
+ * @param params.update_rule - Optional The update strategy for online web pages. | 可选 在线网页更新策略。
3708
+ * @returns void | 无返回
3709
+ */ async update(params, options) {
3710
+ const apiUrl = '/open_api/knowledge/document/update';
3711
+ await this._client.post(apiUrl, params, false, esm_mergeConfig(options, {
3712
+ headers: documents_documents_headers
3713
+ }));
3714
+ }
3715
+ }
3716
+ class Datasets extends APIResource {
3717
+ constructor(...args){
3718
+ super(...args), this.documents = new documents_Documents(this._client);
3553
3719
  }
3554
3720
  }
3555
3721
  class Voices extends APIResource {
@@ -3624,7 +3790,7 @@ class esm_Audio extends APIResource {
3624
3790
  super(...args), this.rooms = new Rooms(this._client), this.voices = new Voices(this._client), this.speech = new Speech(this._client);
3625
3791
  }
3626
3792
  }
3627
- 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
3793
+ 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
3628
3794
  const { version: esm_version } = package_namespaceObject;
3629
3795
  const getEnv = ()=>{
3630
3796
  const nodeVersion = process.version.slice(1); // Remove 'v' prefix
@@ -3687,6 +3853,11 @@ const getNodeClientUserAgent = ()=>{
3687
3853
  async function fetchAPI(url) {
3688
3854
  let options = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
3689
3855
  const axiosInstance = options.axiosInstance || lib_axios;
3856
+ // Add version check for streaming requests
3857
+ if (options.isStreaming && isAxiosStatic(axiosInstance)) {
3858
+ const axiosVersion = axiosInstance.VERSION || lib_axios.VERSION;
3859
+ 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.');
3860
+ }
3690
3861
  const response = await axiosInstance({
3691
3862
  url,
3692
3863
  responseType: options.isStreaming ? 'stream' : 'json',
@@ -3699,12 +3870,12 @@ async function fetchAPI(url) {
3699
3870
  async *stream () {
3700
3871
  try {
3701
3872
  const stream = response.data;
3702
- const reader = stream[Symbol.asyncIterator]();
3873
+ const reader = stream[Symbol.asyncIterator] ? stream[Symbol.asyncIterator]() : stream.getReader();
3703
3874
  const decoder = new TextDecoder();
3704
3875
  const fieldValues = {};
3705
3876
  let buffer = '';
3706
3877
  while(true){
3707
- const { done, value } = await reader.next();
3878
+ const { done, value } = await (reader.next ? reader.next() : reader.read());
3708
3879
  if (done) {
3709
3880
  if (buffer) {
3710
3881
  // If the stream ends without a newline, it means an error occurred
@@ -3738,13 +3909,33 @@ async function fetchAPI(url) {
3738
3909
  response
3739
3910
  };
3740
3911
  }
3912
+ // Add version comparison utility
3913
+ function compareVersions(v1, v2) {
3914
+ const v1Parts = v1.split('.').map(Number);
3915
+ const v2Parts = v2.split('.').map(Number);
3916
+ for(let i = 0; i < 3; i++){
3917
+ const part1 = v1Parts[i] || 0;
3918
+ const part2 = v2Parts[i] || 0;
3919
+ if (part1 > part2) return 1;
3920
+ if (part1 < part2) return -1;
3921
+ }
3922
+ return 0;
3923
+ }
3924
+ function isAxiosStatic(instance) {
3925
+ return !!(null == instance ? void 0 : instance.Axios);
3926
+ }
3741
3927
  /**
3742
3928
  * default coze base URL is api.coze.com
3743
3929
  */ const COZE_COM_BASE_URL = 'https://api.coze.com';
3744
3930
  /* eslint-disable max-params */ class APIClient {
3745
- buildOptions(method, body, options) {
3931
+ async getToken() {
3932
+ if ('function' == typeof this.token) return await this.token();
3933
+ return this.token;
3934
+ }
3935
+ async buildOptions(method, body, options) {
3936
+ const token = await this.getToken();
3746
3937
  const headers = {
3747
- authorization: `Bearer ${this.token}`
3938
+ authorization: `Bearer ${token}`
3748
3939
  };
3749
3940
  if (!isBrowser()) {
3750
3941
  headers['User-Agent'] = getUserAgent();
@@ -3759,14 +3950,17 @@ async function fetchAPI(url) {
3759
3950
  }
3760
3951
  async makeRequest(apiUrl, method, body, isStream, options) {
3761
3952
  const fullUrl = `${this.baseURL}${apiUrl}`;
3762
- const fetchOptions = this.buildOptions(method, body, options);
3953
+ const fetchOptions = await this.buildOptions(method, body, options);
3763
3954
  fetchOptions.isStreaming = isStream;
3955
+ fetchOptions.axiosInstance = this.axiosInstance;
3764
3956
  this.debugLog(`--- request url: ${fullUrl}`);
3765
3957
  this.debugLog('--- request options:', fetchOptions);
3766
3958
  const { response, stream, json } = await fetchAPI(fullUrl, fetchOptions);
3767
3959
  this.debugLog(`--- response status: ${response.status}`);
3768
3960
  this.debugLog('--- response headers: ', response.headers);
3769
- const contentType = response.headers['content-type'];
3961
+ var _response_headers;
3962
+ // Taro use `header`
3963
+ const contentType = (null !== (_response_headers = response.headers) && void 0 !== _response_headers ? _response_headers : response.header)['content-type'];
3770
3964
  if (isStream) {
3771
3965
  if (contentType && contentType.includes('application/json')) {
3772
3966
  const result = await json();
@@ -3814,10 +4008,11 @@ async function fetchAPI(url) {
3814
4008
  this.baseURL = config.baseURL || COZE_COM_BASE_URL;
3815
4009
  this.token = config.token;
3816
4010
  this.axiosOptions = config.axiosOptions || {};
4011
+ this.axiosInstance = config.axiosInstance;
3817
4012
  this.debug = config.debug || false;
3818
4013
  this.allowPersonalAccessTokenInBrowser = config.allowPersonalAccessTokenInBrowser || false;
3819
4014
  this.headers = config.headers;
3820
- 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');
4015
+ 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');
3821
4016
  }
3822
4017
  }
3823
4018
  APIClient.APIError = APIError;
@@ -3832,7 +4027,9 @@ APIClient.TimeoutError = TimeoutError;
3832
4027
  APIClient.UserAbortError = APIUserAbortError;
3833
4028
  class CozeAPI extends APIClient {
3834
4029
  constructor(...args){
3835
- 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);
4030
+ super(...args), this.bots = new Bots(this), this.chat = new Chat(this), this.conversations = new Conversations(this), this.files = new Files(this), /**
4031
+ * @deprecated
4032
+ */ 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);
3836
4033
  }
3837
4034
  }
3838
4035
  /**
@@ -12637,8 +12834,8 @@ function getBrowser() {
12637
12834
  }
12638
12835
  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]);
12639
12836
  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]);
12640
- var v2 = !isSSR2() && (null === (_userAgentString$matc2 = userAgentString.match(/Firefox\/(\d+)/i)) || void 0 === _userAgentString$matc2 ? void 0 : _userAgentString$matc2[1]);
12641
- isFirefox && v2 && (sv = Number(v2));
12837
+ var index_esm_min_v2 = !isSSR2() && (null === (_userAgentString$matc2 = userAgentString.match(/Firefox\/(\d+)/i)) || void 0 === _userAgentString$matc2 ? void 0 : _userAgentString$matc2[1]);
12838
+ isFirefox && index_esm_min_v2 && (sv = Number(index_esm_min_v2));
12642
12839
  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) {
12643
12840
  return _parseInt$7(e);
12644
12841
  }))) && 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]);
@@ -38222,6 +38419,7 @@ var VERTC = _createClass(function e() {
38222
38419
  return new Promise((resolve)=>setTimeout(resolve, milliseconds));
38223
38420
  };
38224
38421
  /**
38422
+ * @deprecated use checkDevicePermission instead
38225
38423
  * Check microphone permission,return boolean
38226
38424
  */ const checkPermission = async function() {
38227
38425
  let { audio = true, video = false } = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
@@ -38236,22 +38434,32 @@ var VERTC = _createClass(function e() {
38236
38434
  return false;
38237
38435
  }
38238
38436
  };
38437
+ const checkDevicePermission = async function() {
38438
+ let checkVideo = arguments.length > 0 && void 0 !== arguments[0] && arguments[0];
38439
+ return await index_esm_min_index.enableDevices({
38440
+ audio: true,
38441
+ video: checkVideo
38442
+ });
38443
+ };
38239
38444
  /**
38240
38445
  * Get audio devices
38241
38446
  * @returns Promise<AudioDevices> Object containing arrays of audio input and output devices
38242
- */ const getAudioDevices = async ()=>{
38243
- const devices = await index_esm_min_index.enumerateDevices();
38447
+ */ const getAudioDevices = async function() {
38448
+ let { video = false } = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
38449
+ let devices = [];
38450
+ devices = video ? await index_esm_min_index.enumerateDevices() : await [
38451
+ ...await index_esm_min_index.enumerateAudioCaptureDevices(),
38452
+ ...await index_esm_min_index.enumerateAudioPlaybackDevices()
38453
+ ];
38244
38454
  if (!(null == devices ? void 0 : devices.length)) return {
38245
38455
  audioInputs: [],
38246
38456
  audioOutputs: [],
38247
- videoInputs: [],
38248
- videoOutputs: []
38457
+ videoInputs: []
38249
38458
  };
38250
38459
  return {
38251
38460
  audioInputs: devices.filter((i)=>i.deviceId && 'audioinput' === i.kind),
38252
38461
  audioOutputs: devices.filter((i)=>i.deviceId && 'audiooutput' === i.kind),
38253
- videoInputs: devices.filter((i)=>i.deviceId && 'videoinput' === i.kind),
38254
- videoOutputs: devices.filter((i)=>i.deviceId && 'videooutput' === i.kind)
38462
+ videoInputs: devices.filter((i)=>i.deviceId && 'videoinput' === i.kind)
38255
38463
  };
38256
38464
  };
38257
38465
  var error_RealtimeError = /*#__PURE__*/ function(RealtimeError) {
@@ -38354,6 +38562,34 @@ var event_handler_EventNames = /*#__PURE__*/ function(EventNames) {
38354
38562
  * en: Bot left
38355
38563
  * zh: Bot 离开
38356
38564
  */ EventNames["BOT_LEAVE"] = "server.bot.leave";
38565
+ /**
38566
+ * en: Audio speech started
38567
+ * zh: 开始说话
38568
+ */ EventNames["AUDIO_AGENT_SPEECH_STARTED"] = "server.audio.agent.speech_started";
38569
+ /**
38570
+ * en: Audio speech stopped
38571
+ * zh: 停止说话
38572
+ */ EventNames["AUDIO_SPEECH_STOPPED"] = "server.audio.speech_stopped";
38573
+ /**
38574
+ * en: Server error
38575
+ * zh: 服务端错误
38576
+ */ EventNames["SERVER_ERROR"] = "server.error";
38577
+ /**
38578
+ * en: User speech started
38579
+ * zh: 用户开始说话
38580
+ */ EventNames["AUDIO_USER_SPEECH_STARTED"] = "server.audio.user.speech_started";
38581
+ /**
38582
+ * en: User speech stopped
38583
+ * zh: 用户停止说话
38584
+ */ EventNames["AUDIO_USER_SPEECH_STOPPED"] = "server.audio.user.speech_stopped";
38585
+ /**
38586
+ * en: User successfully enters the room
38587
+ * zh: 用户成功进入房间后,会收到该事件
38588
+ */ EventNames["SESSION_CREATED"] = "server.session.created";
38589
+ /**
38590
+ * en: Session updated
38591
+ * zh: 会话更新
38592
+ */ EventNames["SESSION_UPDATE"] = "server.session.update";
38357
38593
  return EventNames;
38358
38594
  }({});
38359
38595
  class RealtimeEventHandler {
@@ -38384,7 +38620,8 @@ class RealtimeEventHandler {
38384
38620
  }
38385
38621
  }
38386
38622
  dispatch(eventName, event) {
38387
- this._log(`dispatch ${eventName} event`);
38623
+ let consoleLog = !(arguments.length > 2) || void 0 === arguments[2] || arguments[2];
38624
+ if (consoleLog) this._log(`dispatch ${eventName} event`);
38388
38625
  const handlers = (this.eventHandlers[eventName] || []).slice();
38389
38626
  this._dispatchToHandlers(eventName, event, handlers);
38390
38627
  const allHandlers = (this.eventHandlers["realtime.event"] || []).slice();
@@ -41653,7 +41890,7 @@ class EngineClient extends RealtimeEventHandler {
41653
41890
  this.engine.on(index_esm_min_index.events.onUserJoined, this.handleUserJoin);
41654
41891
  this.engine.on(index_esm_min_index.events.onUserLeave, this.handleUserLeave);
41655
41892
  this.engine.on(index_esm_min_index.events.onError, this.handleEventError);
41656
- this.engine.on(index_esm_min_index.events.onPlayerEvent, this.handlePlayerEvent);
41893
+ if (this._isSupportVideo) this.engine.on(index_esm_min_index.events.onPlayerEvent, this.handlePlayerEvent);
41657
41894
  if (this._debug) {
41658
41895
  this.engine.on(index_esm_min_index.events.onLocalAudioPropertiesReport, this.handleLocalAudioPropertiesReport);
41659
41896
  this.engine.on(index_esm_min_index.events.onRemoteAudioPropertiesReport, this.handleRemoteAudioPropertiesReport);
@@ -41664,7 +41901,7 @@ class EngineClient extends RealtimeEventHandler {
41664
41901
  this.engine.off(index_esm_min_index.events.onUserJoined, this.handleUserJoin);
41665
41902
  this.engine.off(index_esm_min_index.events.onUserLeave, this.handleUserLeave);
41666
41903
  this.engine.off(index_esm_min_index.events.onError, this.handleEventError);
41667
- this.engine.off(index_esm_min_index.events.onPlayerEvent, this.handlePlayerEvent);
41904
+ if (this._isSupportVideo) this.engine.off(index_esm_min_index.events.onPlayerEvent, this.handlePlayerEvent);
41668
41905
  if (this._debug) {
41669
41906
  this.engine.off(index_esm_min_index.events.onLocalAudioPropertiesReport, this.handleLocalAudioPropertiesReport);
41670
41907
  this.engine.off(index_esm_min_index.events.onRemoteAudioPropertiesReport, this.handleRemoteAudioPropertiesReport);
@@ -41709,13 +41946,13 @@ class EngineClient extends RealtimeEventHandler {
41709
41946
  this.dispatch(event_handler_EventNames.PLAYER_EVENT, event);
41710
41947
  }
41711
41948
  async joinRoom(options) {
41712
- const { token, roomId, uid, audioMutedDefault, videoOnDefault } = options;
41949
+ const { token, roomId, uid, audioMutedDefault, videoOnDefault, isAutoSubscribeAudio } = options;
41713
41950
  try {
41714
41951
  await this.engine.joinRoom(token, roomId, {
41715
41952
  userId: uid
41716
41953
  }, {
41717
41954
  isAutoPublish: !audioMutedDefault,
41718
- isAutoSubscribeAudio: true,
41955
+ isAutoSubscribeAudio,
41719
41956
  isAutoSubscribeVideo: this._isSupportVideo && videoOnDefault
41720
41957
  });
41721
41958
  } catch (e) {
@@ -41729,14 +41966,18 @@ class EngineClient extends RealtimeEventHandler {
41729
41966
  await this.engine.startAudioCapture(deviceId);
41730
41967
  }
41731
41968
  async setAudioOutputDevice(deviceId) {
41732
- const devices = await getAudioDevices();
41969
+ const devices = await getAudioDevices({
41970
+ video: false
41971
+ });
41733
41972
  if (-1 === devices.audioOutputs.findIndex((i)=>i.deviceId === deviceId)) throw new RealtimeAPIError(error_RealtimeError.DEVICE_ACCESS_ERROR, `Audio output device not found: ${deviceId}`);
41734
41973
  await this.engine.setAudioPlaybackDevice(deviceId);
41735
41974
  }
41736
41975
  async createLocalStream(userId, videoConfig) {
41737
- const devices = await getAudioDevices();
41738
- if (!devices.audioInputs.length) throw new RealtimeAPIError(error_RealtimeError.DEVICE_ACCESS_ERROR, 'Failed to get devices');
41739
- if (this._isSupportVideo && !devices.videoInputs.length) throw new RealtimeAPIError(error_RealtimeError.DEVICE_ACCESS_ERROR, 'Failed to get devices');
41976
+ const devices = await getAudioDevices({
41977
+ video: this._isSupportVideo
41978
+ });
41979
+ if (!devices.audioInputs.length) throw new RealtimeAPIError(error_RealtimeError.DEVICE_ACCESS_ERROR, 'Failed to get audio devices');
41980
+ if (this._isSupportVideo && !devices.videoInputs.length) throw new RealtimeAPIError(error_RealtimeError.DEVICE_ACCESS_ERROR, 'Failed to get video devices');
41740
41981
  await this.engine.startAudioCapture(devices.audioInputs[0].deviceId);
41741
41982
  if (this._isSupportVideo && (null == videoConfig ? void 0 : videoConfig.videoOnDefault)) await this.engine.startVideoCapture(devices.videoInputs[0].deviceId);
41742
41983
  if (this._isSupportVideo) this.engine.setLocalVideoPlayer(StreamIndex$1.STREAM_INDEX_MAIN, {
@@ -41889,7 +42130,7 @@ class RealtimeClient extends RealtimeEventHandler {
41889
42130
  // Step3 bind engine events
41890
42131
  this._client.bindEngineEvents();
41891
42132
  this._client.on(event_handler_EventNames.ALL, (eventName, data)=>{
41892
- this.dispatch(eventName, data);
42133
+ this.dispatch(eventName, data, false);
41893
42134
  });
41894
42135
  if (this._config.suppressStationaryNoise) {
41895
42136
  await this._client.enableAudioNoiseReduction();
@@ -41900,14 +42141,15 @@ class RealtimeClient extends RealtimeEventHandler {
41900
42141
  this._client.changeAIAnsExtension(true);
41901
42142
  this.dispatch(event_handler_EventNames.SUPPRESS_NON_STATIONARY_NOISE, {});
41902
42143
  }
41903
- var _this__config_audioMutedDefault, _this__config_videoConfig_videoOnDefault;
42144
+ var _this__config_audioMutedDefault, _this__config_videoConfig_videoOnDefault, _this__config_isAutoSubscribeAudio;
41904
42145
  // Step4 join room
41905
42146
  await this._client.joinRoom({
41906
42147
  token: roomInfo.token,
41907
42148
  roomId: roomInfo.room_id,
41908
42149
  uid: roomInfo.uid,
41909
42150
  audioMutedDefault: null !== (_this__config_audioMutedDefault = this._config.audioMutedDefault) && void 0 !== _this__config_audioMutedDefault && _this__config_audioMutedDefault,
41910
- 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
42151
+ 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,
42152
+ isAutoSubscribeAudio: null === (_this__config_isAutoSubscribeAudio = this._config.isAutoSubscribeAudio) || void 0 === _this__config_isAutoSubscribeAudio || _this__config_isAutoSubscribeAudio
41911
42153
  });
41912
42154
  // Step5 create local stream
41913
42155
  await this._client.createLocalStream(roomInfo.uid, this._config.videoConfig);
@@ -41919,7 +42161,6 @@ class RealtimeClient extends RealtimeEventHandler {
41919
42161
  token: roomInfo.token,
41920
42162
  appId: roomInfo.app_id
41921
42163
  });
41922
- this._log('dispatch client.connected event');
41923
42164
  }
41924
42165
  /**
41925
42166
  * en: Interrupt the current conversation
@@ -41929,7 +42170,6 @@ class RealtimeClient extends RealtimeEventHandler {
41929
42170
  var _this__client;
41930
42171
  await (null === (_this__client = this._client) || void 0 === _this__client ? void 0 : _this__client.stop());
41931
42172
  this.dispatch(event_handler_EventNames.INTERRUPTED, {});
41932
- this._log('dispatch client.interrupted event');
41933
42173
  }
41934
42174
  /**
41935
42175
  * en: Disconnect from the current session
@@ -42051,6 +42291,7 @@ class RealtimeClient extends RealtimeEventHandler {
42051
42291
  * 可选,默认是否抑制静态噪声,默认值为 false。
42052
42292
  * @param config.suppressNonStationaryNoise - Optional, suppress non-stationary noise, defaults to false. |
42053
42293
  * 可选,默认是否抑制非静态噪声,默认值为 false。
42294
+ * @param config.isAutoSubscribeAudio - Optional, whether to automatically subscribe to bot reply audio streams, defaults to true. |
42054
42295
  */ constructor(config){
42055
42296
  super(config.debug), this._client = null, this.isConnected = false, this._isTestEnv = false, this._isSupportVideo = false;
42056
42297
  this._config = config;