@coze/realtime-api 1.0.1 → 1.0.3-beta.1
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 → index.js} +1610 -1351
- package/dist/esm/{index.js → index.mjs} +1610 -1351
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types/client.d.ts +1 -0
- package/dist/types/event-handler.d.ts +38 -4
- package/dist/types/index.d.ts +4 -1
- package/dist/types/utils.d.ts +10 -2
- package/dist/umd/index.js +1609 -1350
- package/package.json +27 -19
- package/assets/api-overview.png +0 -0
- /package/dist/{esm → cjs}/index.js.LICENSE.txt +0 -0
- /package/dist/{cjs/index.cjs.LICENSE.txt → esm/index.mjs.LICENSE.txt} +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
{"version":"5.6.3"}
|
package/dist/types/client.d.ts
CHANGED
@@ -21,6 +21,7 @@ export declare class EngineClient extends RealtimeEventHandler {
|
|
21
21
|
uid: string;
|
22
22
|
audioMutedDefault?: boolean;
|
23
23
|
videoOnDefault?: boolean;
|
24
|
+
isAutoSubscribeAudio?: boolean;
|
24
25
|
}): Promise<void>;
|
25
26
|
setAudioInputDevice(deviceId: string): Promise<void>;
|
26
27
|
setAudioOutputDevice(deviceId: string): Promise<void>;
|
@@ -88,9 +88,44 @@ export declare enum EventNames {
|
|
88
88
|
* en: Bot left
|
89
89
|
* zh: Bot 离开
|
90
90
|
*/
|
91
|
-
BOT_LEAVE = "server.bot.leave"
|
91
|
+
BOT_LEAVE = "server.bot.leave",
|
92
|
+
/**
|
93
|
+
* en: Audio speech started
|
94
|
+
* zh: 开始说话
|
95
|
+
*/
|
96
|
+
AUDIO_AGENT_SPEECH_STARTED = "server.audio.agent.speech_started",
|
97
|
+
/**
|
98
|
+
* en: Audio speech stopped
|
99
|
+
* zh: 停止说话
|
100
|
+
*/
|
101
|
+
AUDIO_SPEECH_STOPPED = "server.audio.speech_stopped",
|
102
|
+
/**
|
103
|
+
* en: Server error
|
104
|
+
* zh: 服务端错误
|
105
|
+
*/
|
106
|
+
SERVER_ERROR = "server.error",
|
107
|
+
/**
|
108
|
+
* en: User speech started
|
109
|
+
* zh: 用户开始说话
|
110
|
+
*/
|
111
|
+
AUDIO_USER_SPEECH_STARTED = "server.audio.user.speech_started",
|
112
|
+
/**
|
113
|
+
* en: User speech stopped
|
114
|
+
* zh: 用户停止说话
|
115
|
+
*/
|
116
|
+
AUDIO_USER_SPEECH_STOPPED = "server.audio.user.speech_stopped",
|
117
|
+
/**
|
118
|
+
* en: User successfully enters the room
|
119
|
+
* zh: 用户成功进入房间后,会收到该事件
|
120
|
+
*/
|
121
|
+
SESSION_CREATED = "server.session.created",
|
122
|
+
/**
|
123
|
+
* en: Session updated
|
124
|
+
* zh: 会话更新
|
125
|
+
*/
|
126
|
+
SESSION_UPDATE = "server.session.update"
|
92
127
|
}
|
93
|
-
type EventCallback = (eventName: string, event: unknown) => void;
|
128
|
+
export type EventCallback = (eventName: string, event: unknown) => void;
|
94
129
|
export declare class RealtimeEventHandler {
|
95
130
|
private eventHandlers;
|
96
131
|
protected _debug: boolean;
|
@@ -99,7 +134,6 @@ export declare class RealtimeEventHandler {
|
|
99
134
|
on(eventName: string, callback: EventCallback): EventCallback;
|
100
135
|
off(eventName: string, callback: EventCallback): void;
|
101
136
|
private _dispatchToHandlers;
|
102
|
-
dispatch(eventName: string, event: unknown): void;
|
137
|
+
dispatch(eventName: string, event: unknown, consoleLog?: boolean): void;
|
103
138
|
_log(message: string): void;
|
104
139
|
}
|
105
|
-
export {};
|
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 */;
|
@@ -22,6 +23,7 @@ export interface RealtimeClientConfig {
|
|
22
23
|
suppressStationaryNoise?: boolean /** optional, Suppress stationary noise, defaults to false */;
|
23
24
|
suppressNonStationaryNoise?: boolean /** optional, Suppress non-stationary noise, defaults to false */;
|
24
25
|
videoConfig?: VideoConfig /** optional, Video configuration */;
|
26
|
+
isAutoSubscribeAudio?: boolean /** optional, Whether to automatically subscribe to bot reply audio streams, defaults to true */;
|
25
27
|
}
|
26
28
|
declare class RealtimeClient extends RealtimeEventHandler {
|
27
29
|
private _config;
|
@@ -59,6 +61,7 @@ declare class RealtimeClient extends RealtimeEventHandler {
|
|
59
61
|
* 可选,默认是否抑制静态噪声,默认值为 false。
|
60
62
|
* @param config.suppressNonStationaryNoise - Optional, suppress non-stationary noise, defaults to false. |
|
61
63
|
* 可选,默认是否抑制非静态噪声,默认值为 false。
|
64
|
+
* @param config.isAutoSubscribeAudio - Optional, whether to automatically subscribe to bot reply audio streams, defaults to true. |
|
62
65
|
*/
|
63
66
|
constructor(config: RealtimeClientConfig);
|
64
67
|
/**
|
package/dist/types/utils.d.ts
CHANGED
@@ -6,19 +6,27 @@
|
|
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
|
18
25
|
*/
|
19
|
-
export declare const getAudioDevices: (
|
26
|
+
export declare const getAudioDevices: ({ video, }?: {
|
27
|
+
video?: boolean;
|
28
|
+
}) => Promise<{
|
20
29
|
audioInputs: MediaDeviceInfo[];
|
21
30
|
audioOutputs: MediaDeviceInfo[];
|
22
31
|
videoInputs: MediaDeviceInfo[];
|
23
|
-
videoOutputs: MediaDeviceInfo[];
|
24
32
|
}>;
|