@coze/realtime-api 1.0.2 → 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/README.md +7 -2
- package/dist/cjs/index.cjs +160 -14
- package/dist/esm/index.js +160 -14
- package/dist/types/index.d.ts +2 -1
- package/dist/types/utils.d.ts +7 -0
- package/dist/umd/index.js +160 -14
- package/package.json +2 -2
package/README.md
CHANGED
@@ -45,6 +45,11 @@ import { RealtimeClient, EventNames, RealtimeUtils } from "@coze/realtime-api";
|
|
45
45
|
const client = new RealtimeClient({
|
46
46
|
baseURL: "https://api.coze.cn",
|
47
47
|
accessToken: "your_access_token",
|
48
|
+
// or
|
49
|
+
// accessToken: async () => {
|
50
|
+
// // refresh token if expired
|
51
|
+
// return 'your_oauth_token';
|
52
|
+
// },
|
48
53
|
botId: "your_bot_id",
|
49
54
|
voiceId: "your_voice_id", // Optional: Specify voice ID
|
50
55
|
conversationId: "conversation_id", // Optional: For conversation continuity
|
@@ -58,8 +63,8 @@ const client = new RealtimeClient({
|
|
58
63
|
// Essential Setup
|
59
64
|
async function initializeVoiceChat() {
|
60
65
|
// 1. Verify device permissions
|
61
|
-
const
|
62
|
-
if (!
|
66
|
+
const result = await RealtimeUtils.checkDevicePermission();
|
67
|
+
if (!result.audio) {
|
63
68
|
throw new Error("Microphone access required");
|
64
69
|
}
|
65
70
|
|
package/dist/cjs/index.cjs
CHANGED
@@ -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
|
-
"?
|
4
|
+
"?c628": function() {
|
5
5
|
/* (ignored) */ },
|
6
|
-
"?
|
6
|
+
"?9452": function() {
|
7
7
|
/* (ignored) */ },
|
8
|
-
"?
|
8
|
+
"?e2b1": function() {
|
9
9
|
/* (ignored) */ }
|
10
10
|
};
|
11
11
|
/************************************************************************/ // The module cache
|
@@ -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
|
@@ -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__("?
|
2861
|
+
var os_ignored_ = __webpack_require__("?e2b1");
|
2861
2862
|
// EXTERNAL MODULE: crypto (ignored)
|
2862
|
-
__webpack_require__("?
|
2863
|
+
__webpack_require__("?c628");
|
2863
2864
|
// EXTERNAL MODULE: jsonwebtoken (ignored)
|
2864
|
-
__webpack_require__("?
|
2865
|
+
__webpack_require__("?9452");
|
2865
2866
|
class APIResource {
|
2866
2867
|
constructor(client){
|
2867
2868
|
this._client = client;
|
@@ -3283,6 +3284,19 @@ class Chat extends APIResource {
|
|
3283
3284
|
super(...args), this.messages = new Messages(this._client);
|
3284
3285
|
}
|
3285
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
|
+
}({});
|
3286
3300
|
class messages_Messages extends APIResource {
|
3287
3301
|
/**
|
3288
3302
|
* Create a message and add it to the specified conversation. | 创建一条消息,并将其添加到指定的会话中。
|
@@ -3497,9 +3511,46 @@ class WorkflowEvent {
|
|
3497
3511
|
this.data = data;
|
3498
3512
|
}
|
3499
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
|
+
}
|
3500
3551
|
class Workflows extends APIResource {
|
3501
3552
|
constructor(...args){
|
3502
|
-
super(...args), this.runs = new Runs(this._client);
|
3553
|
+
super(...args), this.runs = new Runs(this._client), this.chat = new WorkflowChat(this._client);
|
3503
3554
|
}
|
3504
3555
|
}
|
3505
3556
|
class WorkSpaces extends APIResource {
|
@@ -3523,6 +3574,8 @@ const documents_headers = {
|
|
3523
3574
|
};
|
3524
3575
|
class Documents extends APIResource {
|
3525
3576
|
/**
|
3577
|
+
* @deprecated The method is deprecated and will be removed in a future version. Please use 'client.datasets.documents.list' instead.
|
3578
|
+
*
|
3526
3579
|
* View the file list of a specified knowledge base, which includes lists of documents, spreadsheets, or images.
|
3527
3580
|
* | 调用接口查看指定知识库的内容列表,即文件、表格或图像列表。
|
3528
3581
|
* @docs en: https://www.coze.com/docs/developer_guides/list_knowledge_files?_lang=en
|
@@ -3539,6 +3592,8 @@ class Documents extends APIResource {
|
|
3539
3592
|
return response;
|
3540
3593
|
}
|
3541
3594
|
/**
|
3595
|
+
* @deprecated The method is deprecated and will be removed in a future version. Please use 'client.datasets.documents.create' instead.
|
3596
|
+
*
|
3542
3597
|
* Upload files to the specific knowledge. | 调用此接口向指定知识库中上传文件。
|
3543
3598
|
* @docs en: https://www.coze.com/docs/developer_guides/create_knowledge_files?_lang=en
|
3544
3599
|
* @docs zh: https://www.coze.cn/docs/developer_guides/create_knowledge_files?_lang=zh
|
@@ -3555,6 +3610,8 @@ class Documents extends APIResource {
|
|
3555
3610
|
return response.document_infos;
|
3556
3611
|
}
|
3557
3612
|
/**
|
3613
|
+
* @deprecated The method is deprecated and will be removed in a future version. Please use 'client.datasets.documents.delete' instead.
|
3614
|
+
*
|
3558
3615
|
* Delete text, images, sheets, and other files in the knowledge base, supporting batch deletion.
|
3559
3616
|
* | 删除知识库中的文本、图像、表格等文件,支持批量删除。
|
3560
3617
|
* @docs en: https://www.coze.com/docs/developer_guides/delete_knowledge_files?_lang=en
|
@@ -3568,6 +3625,8 @@ class Documents extends APIResource {
|
|
3568
3625
|
}));
|
3569
3626
|
}
|
3570
3627
|
/**
|
3628
|
+
* @deprecated The method is deprecated and will be removed in a future version. Please use 'client.datasets.documents.update' instead.
|
3629
|
+
*
|
3571
3630
|
* Modify the knowledge base file name and update strategy. | 调用接口修改知识库文件名称和更新策略。
|
3572
3631
|
* @docs en: https://www.coze.com/docs/developer_guides/modify_knowledge_files?_lang=en
|
3573
3632
|
* @docs zh: https://www.coze.cn/docs/developer_guides/modify_knowledge_files?_lang=zh
|
@@ -3584,7 +3643,79 @@ class Documents extends APIResource {
|
|
3584
3643
|
}
|
3585
3644
|
class Knowledge extends APIResource {
|
3586
3645
|
constructor(...args){
|
3587
|
-
super(...args),
|
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);
|
3588
3719
|
}
|
3589
3720
|
}
|
3590
3721
|
class Voices extends APIResource {
|
@@ -3659,7 +3790,7 @@ class esm_Audio extends APIResource {
|
|
3659
3790
|
super(...args), this.rooms = new Rooms(this._client), this.voices = new Voices(this._client), this.speech = new Speech(this._client);
|
3660
3791
|
}
|
3661
3792
|
}
|
3662
|
-
var package_namespaceObject = JSON.parse('{"name":"@coze/api","version":"1.0.
|
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
|
3663
3794
|
const { version: esm_version } = package_namespaceObject;
|
3664
3795
|
const getEnv = ()=>{
|
3665
3796
|
const nodeVersion = process.version.slice(1); // Remove 'v' prefix
|
@@ -3797,9 +3928,14 @@ function isAxiosStatic(instance) {
|
|
3797
3928
|
* default coze base URL is api.coze.com
|
3798
3929
|
*/ const COZE_COM_BASE_URL = 'https://api.coze.com';
|
3799
3930
|
/* eslint-disable max-params */ class APIClient {
|
3800
|
-
|
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();
|
3801
3937
|
const headers = {
|
3802
|
-
authorization: `Bearer ${
|
3938
|
+
authorization: `Bearer ${token}`
|
3803
3939
|
};
|
3804
3940
|
if (!isBrowser()) {
|
3805
3941
|
headers['User-Agent'] = getUserAgent();
|
@@ -3814,7 +3950,7 @@ function isAxiosStatic(instance) {
|
|
3814
3950
|
}
|
3815
3951
|
async makeRequest(apiUrl, method, body, isStream, options) {
|
3816
3952
|
const fullUrl = `${this.baseURL}${apiUrl}`;
|
3817
|
-
const fetchOptions = this.buildOptions(method, body, options);
|
3953
|
+
const fetchOptions = await this.buildOptions(method, body, options);
|
3818
3954
|
fetchOptions.isStreaming = isStream;
|
3819
3955
|
fetchOptions.axiosInstance = this.axiosInstance;
|
3820
3956
|
this.debugLog(`--- request url: ${fullUrl}`);
|
@@ -3876,7 +4012,7 @@ function isAxiosStatic(instance) {
|
|
3876
4012
|
this.debug = config.debug || false;
|
3877
4013
|
this.allowPersonalAccessTokenInBrowser = config.allowPersonalAccessTokenInBrowser || false;
|
3878
4014
|
this.headers = config.headers;
|
3879
|
-
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');
|
3880
4016
|
}
|
3881
4017
|
}
|
3882
4018
|
APIClient.APIError = APIError;
|
@@ -3891,7 +4027,9 @@ APIClient.TimeoutError = TimeoutError;
|
|
3891
4027
|
APIClient.UserAbortError = APIUserAbortError;
|
3892
4028
|
class CozeAPI extends APIClient {
|
3893
4029
|
constructor(...args){
|
3894
|
-
super(...args), this.bots = new Bots(this), this.chat = new Chat(this), this.conversations = new Conversations(this), this.files = new Files(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);
|
3895
4033
|
}
|
3896
4034
|
}
|
3897
4035
|
/**
|
@@ -38281,6 +38419,7 @@ var VERTC = _createClass(function e() {
|
|
38281
38419
|
return new Promise((resolve)=>setTimeout(resolve, milliseconds));
|
38282
38420
|
};
|
38283
38421
|
/**
|
38422
|
+
* @deprecated use checkDevicePermission instead
|
38284
38423
|
* Check microphone permission,return boolean
|
38285
38424
|
*/ const checkPermission = async function() {
|
38286
38425
|
let { audio = true, video = false } = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
|
@@ -38295,6 +38434,13 @@ var VERTC = _createClass(function e() {
|
|
38295
38434
|
return false;
|
38296
38435
|
}
|
38297
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
|
+
};
|
38298
38444
|
/**
|
38299
38445
|
* Get audio devices
|
38300
38446
|
* @returns Promise<AudioDevices> Object containing arrays of audio input and output devices
|
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
|
-
"?
|
3
|
+
"?c628": function() {
|
4
4
|
/* (ignored) */ },
|
5
|
-
"?
|
5
|
+
"?9452": function() {
|
6
6
|
/* (ignored) */ },
|
7
|
-
"?
|
7
|
+
"?e2b1": function() {
|
8
8
|
/* (ignored) */ }
|
9
9
|
};
|
10
10
|
/************************************************************************/ // The module cache
|
@@ -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
|
@@ -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__("?
|
2849
|
+
var os_ignored_ = __webpack_require__("?e2b1");
|
2849
2850
|
// EXTERNAL MODULE: crypto (ignored)
|
2850
|
-
__webpack_require__("?
|
2851
|
+
__webpack_require__("?c628");
|
2851
2852
|
// EXTERNAL MODULE: jsonwebtoken (ignored)
|
2852
|
-
__webpack_require__("?
|
2853
|
+
__webpack_require__("?9452");
|
2853
2854
|
class APIResource {
|
2854
2855
|
constructor(client){
|
2855
2856
|
this._client = client;
|
@@ -3271,6 +3272,19 @@ class Chat extends APIResource {
|
|
3271
3272
|
super(...args), this.messages = new Messages(this._client);
|
3272
3273
|
}
|
3273
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
|
+
}({});
|
3274
3288
|
class messages_Messages extends APIResource {
|
3275
3289
|
/**
|
3276
3290
|
* Create a message and add it to the specified conversation. | 创建一条消息,并将其添加到指定的会话中。
|
@@ -3485,9 +3499,46 @@ class WorkflowEvent {
|
|
3485
3499
|
this.data = data;
|
3486
3500
|
}
|
3487
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
|
+
}
|
3488
3539
|
class Workflows extends APIResource {
|
3489
3540
|
constructor(...args){
|
3490
|
-
super(...args), this.runs = new Runs(this._client);
|
3541
|
+
super(...args), this.runs = new Runs(this._client), this.chat = new WorkflowChat(this._client);
|
3491
3542
|
}
|
3492
3543
|
}
|
3493
3544
|
class WorkSpaces extends APIResource {
|
@@ -3511,6 +3562,8 @@ const documents_headers = {
|
|
3511
3562
|
};
|
3512
3563
|
class Documents extends APIResource {
|
3513
3564
|
/**
|
3565
|
+
* @deprecated The method is deprecated and will be removed in a future version. Please use 'client.datasets.documents.list' instead.
|
3566
|
+
*
|
3514
3567
|
* View the file list of a specified knowledge base, which includes lists of documents, spreadsheets, or images.
|
3515
3568
|
* | 调用接口查看指定知识库的内容列表,即文件、表格或图像列表。
|
3516
3569
|
* @docs en: https://www.coze.com/docs/developer_guides/list_knowledge_files?_lang=en
|
@@ -3527,6 +3580,8 @@ class Documents extends APIResource {
|
|
3527
3580
|
return response;
|
3528
3581
|
}
|
3529
3582
|
/**
|
3583
|
+
* @deprecated The method is deprecated and will be removed in a future version. Please use 'client.datasets.documents.create' instead.
|
3584
|
+
*
|
3530
3585
|
* Upload files to the specific knowledge. | 调用此接口向指定知识库中上传文件。
|
3531
3586
|
* @docs en: https://www.coze.com/docs/developer_guides/create_knowledge_files?_lang=en
|
3532
3587
|
* @docs zh: https://www.coze.cn/docs/developer_guides/create_knowledge_files?_lang=zh
|
@@ -3543,6 +3598,8 @@ class Documents extends APIResource {
|
|
3543
3598
|
return response.document_infos;
|
3544
3599
|
}
|
3545
3600
|
/**
|
3601
|
+
* @deprecated The method is deprecated and will be removed in a future version. Please use 'client.datasets.documents.delete' instead.
|
3602
|
+
*
|
3546
3603
|
* Delete text, images, sheets, and other files in the knowledge base, supporting batch deletion.
|
3547
3604
|
* | 删除知识库中的文本、图像、表格等文件,支持批量删除。
|
3548
3605
|
* @docs en: https://www.coze.com/docs/developer_guides/delete_knowledge_files?_lang=en
|
@@ -3556,6 +3613,8 @@ class Documents extends APIResource {
|
|
3556
3613
|
}));
|
3557
3614
|
}
|
3558
3615
|
/**
|
3616
|
+
* @deprecated The method is deprecated and will be removed in a future version. Please use 'client.datasets.documents.update' instead.
|
3617
|
+
*
|
3559
3618
|
* Modify the knowledge base file name and update strategy. | 调用接口修改知识库文件名称和更新策略。
|
3560
3619
|
* @docs en: https://www.coze.com/docs/developer_guides/modify_knowledge_files?_lang=en
|
3561
3620
|
* @docs zh: https://www.coze.cn/docs/developer_guides/modify_knowledge_files?_lang=zh
|
@@ -3572,7 +3631,79 @@ class Documents extends APIResource {
|
|
3572
3631
|
}
|
3573
3632
|
class Knowledge extends APIResource {
|
3574
3633
|
constructor(...args){
|
3575
|
-
super(...args),
|
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);
|
3576
3707
|
}
|
3577
3708
|
}
|
3578
3709
|
class Voices extends APIResource {
|
@@ -3647,7 +3778,7 @@ class esm_Audio extends APIResource {
|
|
3647
3778
|
super(...args), this.rooms = new Rooms(this._client), this.voices = new Voices(this._client), this.speech = new Speech(this._client);
|
3648
3779
|
}
|
3649
3780
|
}
|
3650
|
-
var package_namespaceObject = JSON.parse('{"name":"@coze/api","version":"1.0.
|
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
|
3651
3782
|
const { version: esm_version } = package_namespaceObject;
|
3652
3783
|
const getEnv = ()=>{
|
3653
3784
|
const nodeVersion = process.version.slice(1); // Remove 'v' prefix
|
@@ -3785,9 +3916,14 @@ function isAxiosStatic(instance) {
|
|
3785
3916
|
* default coze base URL is api.coze.com
|
3786
3917
|
*/ const COZE_COM_BASE_URL = 'https://api.coze.com';
|
3787
3918
|
/* eslint-disable max-params */ class APIClient {
|
3788
|
-
|
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();
|
3789
3925
|
const headers = {
|
3790
|
-
authorization: `Bearer ${
|
3926
|
+
authorization: `Bearer ${token}`
|
3791
3927
|
};
|
3792
3928
|
if (!isBrowser()) {
|
3793
3929
|
headers['User-Agent'] = getUserAgent();
|
@@ -3802,7 +3938,7 @@ function isAxiosStatic(instance) {
|
|
3802
3938
|
}
|
3803
3939
|
async makeRequest(apiUrl, method, body, isStream, options) {
|
3804
3940
|
const fullUrl = `${this.baseURL}${apiUrl}`;
|
3805
|
-
const fetchOptions = this.buildOptions(method, body, options);
|
3941
|
+
const fetchOptions = await this.buildOptions(method, body, options);
|
3806
3942
|
fetchOptions.isStreaming = isStream;
|
3807
3943
|
fetchOptions.axiosInstance = this.axiosInstance;
|
3808
3944
|
this.debugLog(`--- request url: ${fullUrl}`);
|
@@ -3864,7 +4000,7 @@ function isAxiosStatic(instance) {
|
|
3864
4000
|
this.debug = config.debug || false;
|
3865
4001
|
this.allowPersonalAccessTokenInBrowser = config.allowPersonalAccessTokenInBrowser || false;
|
3866
4002
|
this.headers = config.headers;
|
3867
|
-
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');
|
3868
4004
|
}
|
3869
4005
|
}
|
3870
4006
|
APIClient.APIError = APIError;
|
@@ -3879,7 +4015,9 @@ APIClient.TimeoutError = TimeoutError;
|
|
3879
4015
|
APIClient.UserAbortError = APIUserAbortError;
|
3880
4016
|
class CozeAPI extends APIClient {
|
3881
4017
|
constructor(...args){
|
3882
|
-
super(...args), this.bots = new Bots(this), this.chat = new Chat(this), this.conversations = new Conversations(this), this.files = new Files(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);
|
3883
4021
|
}
|
3884
4022
|
}
|
3885
4023
|
/**
|
@@ -38269,6 +38407,7 @@ var VERTC = _createClass(function e() {
|
|
38269
38407
|
return new Promise((resolve)=>setTimeout(resolve, milliseconds));
|
38270
38408
|
};
|
38271
38409
|
/**
|
38410
|
+
* @deprecated use checkDevicePermission instead
|
38272
38411
|
* Check microphone permission,return boolean
|
38273
38412
|
*/ const checkPermission = async function() {
|
38274
38413
|
let { audio = true, video = false } = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
|
@@ -38283,6 +38422,13 @@ var VERTC = _createClass(function e() {
|
|
38283
38422
|
return false;
|
38284
38423
|
}
|
38285
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
|
+
};
|
38286
38432
|
/**
|
38287
38433
|
* Get audio devices
|
38288
38434
|
* @returns Promise<AudioDevices> Object containing arrays of audio input and output devices
|
package/dist/types/index.d.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import { type AudioPropertiesConfig } from '@volcengine/rtc';
|
2
|
+
import { type GetToken } from '@coze/api';
|
2
3
|
import * as RealtimeUtils from './utils';
|
3
4
|
import { RealtimeEventHandler, EventNames } from './event-handler';
|
4
5
|
import { RealtimeAPIError, RealtimeError } from './error';
|
@@ -7,7 +8,7 @@ export interface VideoConfig {
|
|
7
8
|
renderDom?: string /** optional, The DOM element to render the video stream to */;
|
8
9
|
}
|
9
10
|
export interface RealtimeClientConfig {
|
10
|
-
accessToken:
|
11
|
+
accessToken: GetToken /** required, Access Token */;
|
11
12
|
botId: string /** required, Bot Id */;
|
12
13
|
voiceId?: string /** optional, Voice Id */;
|
13
14
|
conversationId?: string /** optional, Conversation Id */;
|
package/dist/types/utils.d.ts
CHANGED
@@ -6,12 +6,19 @@
|
|
6
6
|
+ */
|
7
7
|
export declare const sleep: (milliseconds: number) => Promise<void>;
|
8
8
|
/**
|
9
|
+
* @deprecated use checkDevicePermission instead
|
9
10
|
* Check microphone permission,return boolean
|
10
11
|
*/
|
11
12
|
export declare const checkPermission: ({ audio, video, }?: {
|
12
13
|
audio?: boolean;
|
13
14
|
video?: boolean;
|
14
15
|
}) => Promise<boolean>;
|
16
|
+
export declare const checkDevicePermission: (checkVideo?: boolean) => Promise<{
|
17
|
+
video: boolean;
|
18
|
+
audio: boolean;
|
19
|
+
videoExceptionError?: DOMException | undefined;
|
20
|
+
audioExceptionError?: DOMException | undefined;
|
21
|
+
}>;
|
15
22
|
/**
|
16
23
|
* Get audio devices
|
17
24
|
* @returns Promise<AudioDevices> Object containing arrays of audio input and output devices
|
package/dist/umd/index.js
CHANGED
@@ -7,11 +7,11 @@
|
|
7
7
|
})(self, ()=>(()=>{
|
8
8
|
"use strict";
|
9
9
|
var __webpack_modules__ = {
|
10
|
-
"?
|
10
|
+
"?c628": function() {
|
11
11
|
/* (ignored) */ },
|
12
|
-
"?
|
12
|
+
"?9452": function() {
|
13
13
|
/* (ignored) */ },
|
14
|
-
"?
|
14
|
+
"?e2b1": function() {
|
15
15
|
/* (ignored) */ }
|
16
16
|
};
|
17
17
|
/************************************************************************/ // The module cache
|
@@ -93,6 +93,7 @@
|
|
93
93
|
var src_utils_namespaceObject = {};
|
94
94
|
__webpack_require__.r(src_utils_namespaceObject);
|
95
95
|
__webpack_require__.d(src_utils_namespaceObject, {
|
96
|
+
checkDevicePermission: ()=>checkDevicePermission,
|
96
97
|
checkPermission: ()=>checkPermission,
|
97
98
|
getAudioDevices: ()=>getAudioDevices,
|
98
99
|
sleep: ()=>utils_sleep
|
@@ -2863,11 +2864,11 @@
|
|
2863
2864
|
// so that it can keep same with es module or cjs
|
2864
2865
|
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;
|
2865
2866
|
// EXTERNAL MODULE: os (ignored)
|
2866
|
-
var os_ignored_ = __webpack_require__("?
|
2867
|
+
var os_ignored_ = __webpack_require__("?e2b1");
|
2867
2868
|
// EXTERNAL MODULE: crypto (ignored)
|
2868
|
-
__webpack_require__("?
|
2869
|
+
__webpack_require__("?c628");
|
2869
2870
|
// EXTERNAL MODULE: jsonwebtoken (ignored)
|
2870
|
-
__webpack_require__("?
|
2871
|
+
__webpack_require__("?9452");
|
2871
2872
|
class APIResource {
|
2872
2873
|
constructor(client){
|
2873
2874
|
this._client = client;
|
@@ -3289,6 +3290,19 @@
|
|
3289
3290
|
super(...args), this.messages = new Messages(this._client);
|
3290
3291
|
}
|
3291
3292
|
}
|
3293
|
+
var chat_ChatEventType = /*#__PURE__*/ function(ChatEventType) {
|
3294
|
+
ChatEventType["CONVERSATION_CHAT_CREATED"] = "conversation.chat.created";
|
3295
|
+
ChatEventType["CONVERSATION_CHAT_IN_PROGRESS"] = "conversation.chat.in_progress";
|
3296
|
+
ChatEventType["CONVERSATION_CHAT_COMPLETED"] = "conversation.chat.completed";
|
3297
|
+
ChatEventType["CONVERSATION_CHAT_FAILED"] = "conversation.chat.failed";
|
3298
|
+
ChatEventType["CONVERSATION_CHAT_REQUIRES_ACTION"] = "conversation.chat.requires_action";
|
3299
|
+
ChatEventType["CONVERSATION_MESSAGE_DELTA"] = "conversation.message.delta";
|
3300
|
+
ChatEventType["CONVERSATION_MESSAGE_COMPLETED"] = "conversation.message.completed";
|
3301
|
+
ChatEventType["CONVERSATION_AUDIO_DELTA"] = "conversation.audio.delta";
|
3302
|
+
ChatEventType["DONE"] = "done";
|
3303
|
+
ChatEventType["ERROR"] = "error";
|
3304
|
+
return ChatEventType;
|
3305
|
+
}({});
|
3292
3306
|
class messages_Messages extends APIResource {
|
3293
3307
|
/**
|
3294
3308
|
* Create a message and add it to the specified conversation. | 创建一条消息,并将其添加到指定的会话中。
|
@@ -3503,9 +3517,46 @@
|
|
3503
3517
|
this.data = data;
|
3504
3518
|
}
|
3505
3519
|
}
|
3520
|
+
class WorkflowChat extends APIResource {
|
3521
|
+
/**
|
3522
|
+
* Execute a chat workflow. | 执行对话流
|
3523
|
+
* @docs en: https://www.coze.cn/docs/developer_guides/workflow_chat?_lang=en
|
3524
|
+
* @docs zh: https://www.coze.cn/docs/developer_guides/workflow_chat?_lang=zh
|
3525
|
+
* @param params.workflow_id - Required The ID of the workflow to chat with. | 必选 要对话的工作流 ID。
|
3526
|
+
* @param params.additional_messages - Required Array of messages for the chat. | 必选 对话的消息数组。
|
3527
|
+
* @param params.parameters - Required Parameters for the workflow execution. | 必选 工作流执行的参数。
|
3528
|
+
* @param params.app_id - Optional The ID of the app. | 可选 应用 ID。
|
3529
|
+
* @param params.bot_id - Optional The ID of the bot. | 可选 Bot ID。
|
3530
|
+
* @param params.conversation_id - Optional The ID of the conversation. | 可选 会话 ID。
|
3531
|
+
* @param params.ext - Optional Additional information for the chat. | 可选 对话的附加信息。
|
3532
|
+
* @returns AsyncGenerator<StreamChatData> | 对话数据流
|
3533
|
+
*/ async *stream(params, options) {
|
3534
|
+
const apiUrl = '/v1/workflows/chat';
|
3535
|
+
const payload = {
|
3536
|
+
...params,
|
3537
|
+
additional_messages: handleAdditionalMessages(params.additional_messages)
|
3538
|
+
};
|
3539
|
+
const result = await this._client.post(apiUrl, payload, true, options);
|
3540
|
+
for await (const message of result)if (message.event === chat_ChatEventType.DONE) {
|
3541
|
+
const ret = {
|
3542
|
+
event: message.event,
|
3543
|
+
data: '[DONE]'
|
3544
|
+
};
|
3545
|
+
yield ret;
|
3546
|
+
} else try {
|
3547
|
+
const ret = {
|
3548
|
+
event: message.event,
|
3549
|
+
data: JSON.parse(message.data)
|
3550
|
+
};
|
3551
|
+
yield ret;
|
3552
|
+
} catch (error) {
|
3553
|
+
throw new CozeError(`Could not parse message into JSON:${message.data}`);
|
3554
|
+
}
|
3555
|
+
}
|
3556
|
+
}
|
3506
3557
|
class Workflows extends APIResource {
|
3507
3558
|
constructor(...args){
|
3508
|
-
super(...args), this.runs = new Runs(this._client);
|
3559
|
+
super(...args), this.runs = new Runs(this._client), this.chat = new WorkflowChat(this._client);
|
3509
3560
|
}
|
3510
3561
|
}
|
3511
3562
|
class WorkSpaces extends APIResource {
|
@@ -3529,6 +3580,8 @@
|
|
3529
3580
|
};
|
3530
3581
|
class Documents extends APIResource {
|
3531
3582
|
/**
|
3583
|
+
* @deprecated The method is deprecated and will be removed in a future version. Please use 'client.datasets.documents.list' instead.
|
3584
|
+
*
|
3532
3585
|
* View the file list of a specified knowledge base, which includes lists of documents, spreadsheets, or images.
|
3533
3586
|
* | 调用接口查看指定知识库的内容列表,即文件、表格或图像列表。
|
3534
3587
|
* @docs en: https://www.coze.com/docs/developer_guides/list_knowledge_files?_lang=en
|
@@ -3545,6 +3598,8 @@
|
|
3545
3598
|
return response;
|
3546
3599
|
}
|
3547
3600
|
/**
|
3601
|
+
* @deprecated The method is deprecated and will be removed in a future version. Please use 'client.datasets.documents.create' instead.
|
3602
|
+
*
|
3548
3603
|
* Upload files to the specific knowledge. | 调用此接口向指定知识库中上传文件。
|
3549
3604
|
* @docs en: https://www.coze.com/docs/developer_guides/create_knowledge_files?_lang=en
|
3550
3605
|
* @docs zh: https://www.coze.cn/docs/developer_guides/create_knowledge_files?_lang=zh
|
@@ -3561,6 +3616,8 @@
|
|
3561
3616
|
return response.document_infos;
|
3562
3617
|
}
|
3563
3618
|
/**
|
3619
|
+
* @deprecated The method is deprecated and will be removed in a future version. Please use 'client.datasets.documents.delete' instead.
|
3620
|
+
*
|
3564
3621
|
* Delete text, images, sheets, and other files in the knowledge base, supporting batch deletion.
|
3565
3622
|
* | 删除知识库中的文本、图像、表格等文件,支持批量删除。
|
3566
3623
|
* @docs en: https://www.coze.com/docs/developer_guides/delete_knowledge_files?_lang=en
|
@@ -3574,6 +3631,8 @@
|
|
3574
3631
|
}));
|
3575
3632
|
}
|
3576
3633
|
/**
|
3634
|
+
* @deprecated The method is deprecated and will be removed in a future version. Please use 'client.datasets.documents.update' instead.
|
3635
|
+
*
|
3577
3636
|
* Modify the knowledge base file name and update strategy. | 调用接口修改知识库文件名称和更新策略。
|
3578
3637
|
* @docs en: https://www.coze.com/docs/developer_guides/modify_knowledge_files?_lang=en
|
3579
3638
|
* @docs zh: https://www.coze.cn/docs/developer_guides/modify_knowledge_files?_lang=zh
|
@@ -3590,7 +3649,79 @@
|
|
3590
3649
|
}
|
3591
3650
|
class Knowledge extends APIResource {
|
3592
3651
|
constructor(...args){
|
3593
|
-
super(...args),
|
3652
|
+
super(...args), /**
|
3653
|
+
* @deprecated
|
3654
|
+
*/ this.documents = new Documents(this._client);
|
3655
|
+
}
|
3656
|
+
}
|
3657
|
+
// Required header for knowledge APIs
|
3658
|
+
const documents_documents_headers = {
|
3659
|
+
'agw-js-conv': 'str'
|
3660
|
+
};
|
3661
|
+
class documents_Documents extends APIResource {
|
3662
|
+
/**
|
3663
|
+
* View the file list of a specified knowledge base, which includes lists of documents, spreadsheets, or images.
|
3664
|
+
* | 调用接口查看指定知识库的内容列表,即文件、表格或图像列表。
|
3665
|
+
* @docs en: https://www.coze.com/docs/developer_guides/list_knowledge_files?_lang=en
|
3666
|
+
* @docs zh: https://www.coze.cn/docs/developer_guides/list_knowledge_files?_lang=zh
|
3667
|
+
* @param params.dataset_id - Required The ID of the knowledge base. | 必选 待查看文件的知识库 ID。
|
3668
|
+
* @param params.page - Optional The page number for paginated queries. Default is 1. | 可选 分页查询时的页码。默认为 1。
|
3669
|
+
* @param params.page_size - Optional The size of pagination. Default is 10. | 可选 分页大小。默认为 10。
|
3670
|
+
* @returns ListDocumentData | 知识库文件列表
|
3671
|
+
*/ list(params, options) {
|
3672
|
+
const apiUrl = '/open_api/knowledge/document/list';
|
3673
|
+
const response = this._client.get(apiUrl, params, false, esm_mergeConfig(options, {
|
3674
|
+
headers: documents_documents_headers
|
3675
|
+
}));
|
3676
|
+
return response;
|
3677
|
+
}
|
3678
|
+
/**
|
3679
|
+
* Upload files to the specific knowledge. | 调用此接口向指定知识库中上传文件。
|
3680
|
+
* @docs en: https://www.coze.com/docs/developer_guides/create_knowledge_files?_lang=en
|
3681
|
+
* @docs zh: https://www.coze.cn/docs/developer_guides/create_knowledge_files?_lang=zh
|
3682
|
+
* @param params.dataset_id - Required The ID of the knowledge. | 必选 知识库 ID。
|
3683
|
+
* @param params.document_bases - Required The metadata information of the files awaiting upload. | 必选 待上传文件的元数据信息。
|
3684
|
+
* @param params.chunk_strategy - Required when uploading files to a new knowledge for the first time. Chunk strategy.
|
3685
|
+
* | 向新知识库首次上传文件时必选 分段规则。
|
3686
|
+
* @returns DocumentInfo[] | 已上传文件的基本信息
|
3687
|
+
*/ async create(params, options) {
|
3688
|
+
const apiUrl = '/open_api/knowledge/document/create';
|
3689
|
+
const response = await this._client.post(apiUrl, params, false, esm_mergeConfig(options, {
|
3690
|
+
headers: documents_documents_headers
|
3691
|
+
}));
|
3692
|
+
return response.document_infos;
|
3693
|
+
}
|
3694
|
+
/**
|
3695
|
+
* Delete text, images, sheets, and other files in the knowledge base, supporting batch deletion.
|
3696
|
+
* | 删除知识库中的文本、图像、表格等文件,支持批量删除。
|
3697
|
+
* @docs en: https://www.coze.com/docs/developer_guides/delete_knowledge_files?_lang=en
|
3698
|
+
* @docs zh: https://www.coze.cn/docs/developer_guides/delete_knowledge_files?_lang=zh
|
3699
|
+
* @param params.document_ids - Required The list of knowledge base files to be deleted. | 必选 待删除的文件 ID。
|
3700
|
+
* @returns void | 无返回
|
3701
|
+
*/ async delete(params, options) {
|
3702
|
+
const apiUrl = '/open_api/knowledge/document/delete';
|
3703
|
+
await this._client.post(apiUrl, params, false, esm_mergeConfig(options, {
|
3704
|
+
headers: documents_documents_headers
|
3705
|
+
}));
|
3706
|
+
}
|
3707
|
+
/**
|
3708
|
+
* Modify the knowledge base file name and update strategy. | 调用接口修改知识库文件名称和更新策略。
|
3709
|
+
* @docs en: https://www.coze.com/docs/developer_guides/modify_knowledge_files?_lang=en
|
3710
|
+
* @docs zh: https://www.coze.cn/docs/developer_guides/modify_knowledge_files?_lang=zh
|
3711
|
+
* @param params.document_id - Required The ID of the knowledge base file. | 必选 待修改的知识库文件 ID。
|
3712
|
+
* @param params.document_name - Optional The new name of the knowledge base file. | 可选 知识库文件的新名称。
|
3713
|
+
* @param params.update_rule - Optional The update strategy for online web pages. | 可选 在线网页更新策略。
|
3714
|
+
* @returns void | 无返回
|
3715
|
+
*/ async update(params, options) {
|
3716
|
+
const apiUrl = '/open_api/knowledge/document/update';
|
3717
|
+
await this._client.post(apiUrl, params, false, esm_mergeConfig(options, {
|
3718
|
+
headers: documents_documents_headers
|
3719
|
+
}));
|
3720
|
+
}
|
3721
|
+
}
|
3722
|
+
class Datasets extends APIResource {
|
3723
|
+
constructor(...args){
|
3724
|
+
super(...args), this.documents = new documents_Documents(this._client);
|
3594
3725
|
}
|
3595
3726
|
}
|
3596
3727
|
class Voices extends APIResource {
|
@@ -3665,7 +3796,7 @@
|
|
3665
3796
|
super(...args), this.rooms = new Rooms(this._client), this.voices = new Voices(this._client), this.speech = new Speech(this._client);
|
3666
3797
|
}
|
3667
3798
|
}
|
3668
|
-
var package_namespaceObject = JSON.parse('{"name":"@coze/api","version":"1.0.
|
3799
|
+
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
|
3669
3800
|
const { version: esm_version } = package_namespaceObject;
|
3670
3801
|
const getEnv = ()=>{
|
3671
3802
|
const nodeVersion = process.version.slice(1); // Remove 'v' prefix
|
@@ -3803,9 +3934,14 @@
|
|
3803
3934
|
* default coze base URL is api.coze.com
|
3804
3935
|
*/ const COZE_COM_BASE_URL = 'https://api.coze.com';
|
3805
3936
|
/* eslint-disable max-params */ class APIClient {
|
3806
|
-
|
3937
|
+
async getToken() {
|
3938
|
+
if ('function' == typeof this.token) return await this.token();
|
3939
|
+
return this.token;
|
3940
|
+
}
|
3941
|
+
async buildOptions(method, body, options) {
|
3942
|
+
const token = await this.getToken();
|
3807
3943
|
const headers = {
|
3808
|
-
authorization: `Bearer ${
|
3944
|
+
authorization: `Bearer ${token}`
|
3809
3945
|
};
|
3810
3946
|
if (!isBrowser()) {
|
3811
3947
|
headers['User-Agent'] = getUserAgent();
|
@@ -3820,7 +3956,7 @@
|
|
3820
3956
|
}
|
3821
3957
|
async makeRequest(apiUrl, method, body, isStream, options) {
|
3822
3958
|
const fullUrl = `${this.baseURL}${apiUrl}`;
|
3823
|
-
const fetchOptions = this.buildOptions(method, body, options);
|
3959
|
+
const fetchOptions = await this.buildOptions(method, body, options);
|
3824
3960
|
fetchOptions.isStreaming = isStream;
|
3825
3961
|
fetchOptions.axiosInstance = this.axiosInstance;
|
3826
3962
|
this.debugLog(`--- request url: ${fullUrl}`);
|
@@ -3882,7 +4018,7 @@
|
|
3882
4018
|
this.debug = config.debug || false;
|
3883
4019
|
this.allowPersonalAccessTokenInBrowser = config.allowPersonalAccessTokenInBrowser || false;
|
3884
4020
|
this.headers = config.headers;
|
3885
|
-
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');
|
4021
|
+
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');
|
3886
4022
|
}
|
3887
4023
|
}
|
3888
4024
|
APIClient.APIError = APIError;
|
@@ -3897,7 +4033,9 @@
|
|
3897
4033
|
APIClient.UserAbortError = APIUserAbortError;
|
3898
4034
|
class CozeAPI extends APIClient {
|
3899
4035
|
constructor(...args){
|
3900
|
-
super(...args), this.bots = new Bots(this), this.chat = new Chat(this), this.conversations = new Conversations(this), this.files = new Files(this),
|
4036
|
+
super(...args), this.bots = new Bots(this), this.chat = new Chat(this), this.conversations = new Conversations(this), this.files = new Files(this), /**
|
4037
|
+
* @deprecated
|
4038
|
+
*/ 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);
|
3901
4039
|
}
|
3902
4040
|
}
|
3903
4041
|
/**
|
@@ -38287,6 +38425,7 @@
|
|
38287
38425
|
return new Promise((resolve)=>setTimeout(resolve, milliseconds));
|
38288
38426
|
};
|
38289
38427
|
/**
|
38428
|
+
* @deprecated use checkDevicePermission instead
|
38290
38429
|
* Check microphone permission,return boolean
|
38291
38430
|
*/ const checkPermission = async function() {
|
38292
38431
|
let { audio = true, video = false } = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
|
@@ -38301,6 +38440,13 @@
|
|
38301
38440
|
return false;
|
38302
38441
|
}
|
38303
38442
|
};
|
38443
|
+
const checkDevicePermission = async function() {
|
38444
|
+
let checkVideo = arguments.length > 0 && void 0 !== arguments[0] && arguments[0];
|
38445
|
+
return await index_esm_min_index.enableDevices({
|
38446
|
+
audio: true,
|
38447
|
+
video: checkVideo
|
38448
|
+
});
|
38449
|
+
};
|
38304
38450
|
/**
|
38305
38451
|
* Get audio devices
|
38306
38452
|
* @returns Promise<AudioDevices> Object containing arrays of audio input and output devices
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@coze/realtime-api",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.3",
|
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",
|
@@ -51,7 +51,7 @@
|
|
51
51
|
"test:cov": "vitest --coverage --run"
|
52
52
|
},
|
53
53
|
"dependencies": {
|
54
|
-
"@coze/api": "1.0.
|
54
|
+
"@coze/api": "1.0.15",
|
55
55
|
"@volcengine/rtc": "^4.62.1"
|
56
56
|
},
|
57
57
|
"devDependencies": {
|