@voxket-ai/voxket-live 1.0.158 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/{deep-analysis.d.ts → common/deep-analysis.d.ts} +2 -2
- package/dist/components/common/index.d.ts +12 -0
- package/dist/components/{interactive-component.d.ts → common/interactive-component.d.ts} +2 -2
- package/dist/components/{session-timer.d.ts → common/session-timer.d.ts} +1 -1
- package/dist/components/common/unified-control-bar.d.ts +58 -0
- package/dist/components/{welcome.d.ts → common/welcome.d.ts} +2 -2
- package/dist/components/{chat-view.d.ts → modalities/chat/chat-view.d.ts} +3 -3
- package/dist/components/{chat → modalities/chat/components}/attachment-message.d.ts +2 -2
- package/dist/components/{chat → modalities/chat/components}/chat-message.d.ts +2 -2
- package/dist/components/modalities/chat/components/index.d.ts +10 -0
- package/dist/components/{chat → modalities/chat/components}/markdown-utils.d.ts +1 -1
- package/dist/components/{chat → modalities/chat/components}/thinking-indicator.d.ts +1 -1
- package/dist/components/{chat → modalities/chat/components}/tool-execution-indicator.d.ts +2 -2
- package/dist/components/modalities/chat/index.d.ts +5 -0
- package/dist/components/modalities/index.d.ts +6 -0
- package/dist/components/{video → modalities/video/components}/index.d.ts +1 -1
- package/dist/components/{video → modalities/video/components}/video-controls.d.ts +1 -1
- package/dist/components/{video → modalities/video/components}/video-grid.d.ts +1 -1
- package/dist/components/{video → modalities/video/components}/video-tile.d.ts +1 -1
- package/dist/components/modalities/video/index.d.ts +5 -0
- package/dist/components/{video-view.d.ts → modalities/video/video-view.d.ts} +3 -3
- package/dist/components/modalities/voice/index.d.ts +4 -0
- package/dist/components/{session-view.d.ts → modalities/voice/session-view.d.ts} +2 -2
- package/dist/core/agent-manager.d.ts +50 -0
- package/dist/core/chat-manager.d.ts +72 -0
- package/dist/core/client.d.ts +80 -190
- package/dist/core/connection-manager.d.ts +81 -0
- package/dist/core/index.d.ts +9 -1
- package/dist/core/media-manager.d.ts +177 -0
- package/dist/core/stream-handler-manager.d.ts +91 -0
- package/dist/core/ui-renderer.d.ts +76 -0
- package/dist/index.cjs +54 -54
- package/dist/index.css +1 -1
- package/dist/index.d.ts +8 -7
- package/dist/index.js +10265 -9714
- package/package.json +1 -1
- package/dist/components/chat/chat-input-panel.d.ts +0 -11
- /package/dist/components/{alert-toast.d.ts → common/alert-toast.d.ts} +0 -0
- /package/dist/components/{common-popup-trigger.d.ts → common/common-popup-trigger.d.ts} +0 -0
- /package/dist/components/{error-boundary.d.ts → common/error-boundary.d.ts} +0 -0
- /package/dist/components/{session-logger.d.ts → common/session-logger.d.ts} +0 -0
- /package/dist/components/{chat → modalities/chat/components}/default-views.d.ts +0 -0
- /package/dist/components/{chat → modalities/chat/components}/streaming-text.d.ts +0 -0
package/dist/core/client.d.ts
CHANGED
|
@@ -1,46 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Room, RemoteParticipant, LocalParticipant, ConnectionState, Track } from 'livekit-client';
|
|
1
|
+
import { Room, ConnectionState } from 'livekit-client';
|
|
3
2
|
import { VoxketEventEmitter } from './event-emitter';
|
|
4
3
|
import { PluginManager } from '../plugins/plugin-system';
|
|
4
|
+
import { RenderUIOptions } from './ui-renderer';
|
|
5
5
|
import { VoxketConfig, SessionConfig, VoxketSession, VoxketEvents, SessionState, SessionMetrics, AgentInfo, ParticipantInfo, ChatMessage, TranscriptionSegment, SessionModality } from '../types/core';
|
|
6
6
|
import { VoxketInteractiveView, ViewPresentationMode, InteractiveUIState, RpcEvents } from '../types/rpc';
|
|
7
|
-
import { WidgetTheme } from '../styles';
|
|
8
|
-
import { DisplayType, PopupPosition } from '../components/widget';
|
|
9
|
-
export interface RenderUIOptions {
|
|
10
|
-
target?: string | HTMLElement;
|
|
11
|
-
modality?: SessionModality[];
|
|
12
|
-
theme?: WidgetTheme | 'dark' | 'light' | 'vox';
|
|
13
|
-
component?: 'widget' | 'session' | 'chat-only' | 'voice-only';
|
|
14
|
-
className?: string;
|
|
15
|
-
style?: React.CSSProperties;
|
|
16
|
-
autoStart?: boolean;
|
|
17
|
-
agentId?: string;
|
|
18
|
-
participantName?: string;
|
|
19
|
-
displayType?: DisplayType;
|
|
20
|
-
popupPosition?: PopupPosition;
|
|
21
|
-
popupTriggerText?: string;
|
|
22
|
-
popupModalityMode?: 'all' | 'voice' | 'chat' | 'video';
|
|
23
|
-
width?: string;
|
|
24
|
-
height?: string;
|
|
25
|
-
/**
|
|
26
|
-
* Callback function to handle display type changes (e.g., when user clicks expand button).
|
|
27
|
-
* Required for expand/fullscreen functionality to work properly.
|
|
28
|
-
* @param displayType - The new display type ('widget', 'fullscreen', 'popup')
|
|
29
|
-
* @example
|
|
30
|
-
* onDisplayTypeChange: (newDisplayType) => {
|
|
31
|
-
* console.log('Display type changed to:', newDisplayType);
|
|
32
|
-
* // Handle the display type change in your app
|
|
33
|
-
* }
|
|
34
|
-
*/
|
|
35
|
-
onDisplayTypeChange?: (displayType: DisplayType) => void;
|
|
36
|
-
prompts?: string[];
|
|
37
|
-
statusMessage?: string;
|
|
38
|
-
welcomeTitle?: string;
|
|
39
|
-
welcomeSubTitle?: string;
|
|
40
|
-
loadingText?: string;
|
|
41
|
-
/** Participant metadata to be sent with session creation */
|
|
42
|
-
participantMetadata?: Record<string, any>;
|
|
43
|
-
}
|
|
44
7
|
export interface VoxketClientConfig extends VoxketConfig {
|
|
45
8
|
agentId?: string;
|
|
46
9
|
participantName?: string;
|
|
@@ -57,34 +20,40 @@ export interface VoxketClientConfig extends VoxketConfig {
|
|
|
57
20
|
onUserJoined?: (userId: string) => void;
|
|
58
21
|
onUserLeft?: (userId: string) => void;
|
|
59
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* VoxketClient
|
|
25
|
+
*
|
|
26
|
+
* Main client class that orchestrates all Voxket functionality.
|
|
27
|
+
* Uses specialized managers for different concerns:
|
|
28
|
+
* - ChatManager: Chat messages and attachments
|
|
29
|
+
* - MediaManager: Camera, microphone, screen share
|
|
30
|
+
* - ConnectionManager: Room connection and participants
|
|
31
|
+
* - StreamHandlerManager: Text/byte stream handlers
|
|
32
|
+
* - UIRenderer: React UI rendering
|
|
33
|
+
* - AgentManager: Agent state and info
|
|
34
|
+
* - RpcManager: RPC method handling
|
|
35
|
+
* - PluginManager: Plugin system
|
|
36
|
+
*/
|
|
60
37
|
export declare class VoxketClient extends VoxketEventEmitter<VoxketEvents & RpcEvents> {
|
|
61
38
|
private config;
|
|
62
|
-
private room;
|
|
63
39
|
private pluginManager;
|
|
64
40
|
private rpcManager;
|
|
65
|
-
private
|
|
41
|
+
private chatManager;
|
|
42
|
+
private mediaManager;
|
|
43
|
+
private connectionManager;
|
|
44
|
+
private streamHandlerManager;
|
|
45
|
+
private uiRenderer;
|
|
46
|
+
private agentManager;
|
|
66
47
|
private currentSession;
|
|
67
|
-
private connectionState;
|
|
68
|
-
private renderedComponents;
|
|
69
|
-
private textStreamHandlersRegistered;
|
|
70
|
-
private currentAgentInfo;
|
|
71
|
-
private chatMessages;
|
|
72
|
-
private activeTranscriptions;
|
|
73
|
-
private isAgentConnected;
|
|
74
|
-
private agentState;
|
|
75
|
-
private _eventEmitters;
|
|
76
48
|
constructor(config: VoxketClientConfig);
|
|
49
|
+
/**
|
|
50
|
+
* Setup event listeners for various events
|
|
51
|
+
*/
|
|
77
52
|
private setupEventListeners;
|
|
53
|
+
/**
|
|
54
|
+
* Setup RPC event forwarding from RpcManager
|
|
55
|
+
*/
|
|
78
56
|
private setupRpcEventForwarding;
|
|
79
|
-
private initializeClient;
|
|
80
|
-
private setupRoomEventListeners;
|
|
81
|
-
private setupTextStreamHandlers;
|
|
82
|
-
fetchConnectionDetails(agentId?: string, participantName?: string, modalities?: SessionModality[], participantMetadata?: Record<string, any>): Promise<{
|
|
83
|
-
serverUrl: string;
|
|
84
|
-
participantToken: string;
|
|
85
|
-
voxketSessionId: string;
|
|
86
|
-
agentInfo?: AgentInfo;
|
|
87
|
-
}>;
|
|
88
57
|
connect(agentId?: string, participantName?: string, modalities?: SessionModality[], participantMetadata?: Record<string, any>): Promise<{
|
|
89
58
|
serverUrl: string;
|
|
90
59
|
participantToken: string;
|
|
@@ -101,66 +70,15 @@ export declare class VoxketClient extends VoxketEventEmitter<VoxketEvents & RpcE
|
|
|
101
70
|
}): Promise<VoxketSession>;
|
|
102
71
|
endSession(): Promise<SessionMetrics | null>;
|
|
103
72
|
getCurrentSession(): VoxketSession | null;
|
|
104
|
-
|
|
105
|
-
getIsAgentConnected(): boolean;
|
|
106
|
-
/**
|
|
107
|
-
* Force mark agent as connected - useful when agent should be visible
|
|
108
|
-
* even without receiving agent_state_changed events
|
|
109
|
-
*/
|
|
110
|
-
forceAgentConnected(): void;
|
|
111
|
-
getAgentState(): 'idle' | 'thinking' | 'speaking';
|
|
112
|
-
private setAgentState;
|
|
113
|
-
/**
|
|
114
|
-
* Get agent tracks from remote participants
|
|
115
|
-
*/
|
|
116
|
-
getAgentAudioTrack(): {
|
|
117
|
-
source: Track.Source;
|
|
118
|
-
participant: RemoteParticipant;
|
|
119
|
-
publication: import('livekit-client').RemoteTrackPublication;
|
|
120
|
-
} | null;
|
|
121
|
-
getAgentVideoTrack(): {
|
|
122
|
-
source: Track.Source;
|
|
123
|
-
participant: RemoteParticipant;
|
|
124
|
-
publication: import('livekit-client').RemoteTrackPublication;
|
|
125
|
-
} | null;
|
|
126
|
-
/**
|
|
127
|
-
* Get all video track references (camera and screen share) from all participants
|
|
128
|
-
*/
|
|
129
|
-
getVideoTrackRefs(): Array<{
|
|
130
|
-
source: Track.Source;
|
|
131
|
-
participant: any;
|
|
132
|
-
publication: any;
|
|
133
|
-
}>;
|
|
134
|
-
/**
|
|
135
|
-
* Get camera track references only
|
|
136
|
-
*/
|
|
137
|
-
getCameraTrackRefs(): Array<{
|
|
138
|
-
source: Track.Source;
|
|
139
|
-
participant: any;
|
|
140
|
-
publication: any;
|
|
141
|
-
}>;
|
|
142
|
-
/**
|
|
143
|
-
* Get screen share track references only
|
|
144
|
-
*/
|
|
145
|
-
getScreenShareTrackRefs(): Array<{
|
|
146
|
-
source: Track.Source;
|
|
147
|
-
participant: any;
|
|
148
|
-
publication: any;
|
|
149
|
-
}>;
|
|
150
|
-
getChatMessages(): ChatMessage[];
|
|
151
|
-
addChatMessage(message: ChatMessage): void;
|
|
152
|
-
updateChatMessage(updatedMessage: ChatMessage): void;
|
|
153
|
-
clearChatMessages(): void;
|
|
154
|
-
renderUI(options?: RenderUIOptions): void;
|
|
155
|
-
removeUI(target?: string | HTMLElement): void;
|
|
156
|
-
removeAllUI(): void;
|
|
157
|
-
private forceCleanupFullscreenOverlays;
|
|
158
|
-
private resolveTarget;
|
|
159
|
-
private getTargetKey;
|
|
73
|
+
getSessionMetrics(): SessionMetrics | null;
|
|
160
74
|
sendMessage(message: string, metadata?: Record<string, any>): Promise<void>;
|
|
161
75
|
sendChatMessage(message: string, metadata?: Record<string, any>): Promise<void>;
|
|
162
76
|
sendAttachments(files: File[], metadata?: Record<string, any>): Promise<void>;
|
|
163
77
|
sendAttachment(file: File, metadata?: Record<string, any>): Promise<void>;
|
|
78
|
+
getChatMessages(): ChatMessage[];
|
|
79
|
+
addChatMessage(message: ChatMessage): void;
|
|
80
|
+
updateChatMessage(updatedMessage: ChatMessage): void;
|
|
81
|
+
clearChatMessages(): void;
|
|
164
82
|
toggleMicrophone(enabled?: boolean): Promise<void>;
|
|
165
83
|
setMicrophoneEnabled(enabled: boolean): Promise<void>;
|
|
166
84
|
toggleCamera(enabled?: boolean): Promise<void>;
|
|
@@ -173,8 +91,37 @@ export declare class VoxketClient extends VoxketEventEmitter<VoxketEvents & RpcE
|
|
|
173
91
|
getVideoInputDevices(): Promise<MediaDeviceInfo[]>;
|
|
174
92
|
setAudioInputDevice(deviceId: string): Promise<void>;
|
|
175
93
|
setVideoInputDevice(deviceId: string): Promise<void>;
|
|
176
|
-
|
|
177
|
-
|
|
94
|
+
get isMicrophoneEnabled(): boolean;
|
|
95
|
+
get isCameraEnabled(): boolean;
|
|
96
|
+
get isScreenShareEnabled(): boolean;
|
|
97
|
+
getMicrophoneTrack(): import('livekit-client').LocalTrack<import("livekit-client").Track.Kind> | null | undefined;
|
|
98
|
+
getCameraTrack(): import('livekit-client').LocalTrack<import("livekit-client").Track.Kind> | null | undefined;
|
|
99
|
+
getScreenShareTrack(): import('livekit-client').LocalTrack<import("livekit-client").Track.Kind> | null | undefined;
|
|
100
|
+
getAgentAudioTrack(): {
|
|
101
|
+
source: import("livekit-client").Track.Source;
|
|
102
|
+
participant: import('livekit-client').RemoteParticipant;
|
|
103
|
+
publication: import('livekit-client').RemoteTrackPublication;
|
|
104
|
+
} | null;
|
|
105
|
+
getAgentVideoTrack(): {
|
|
106
|
+
source: import("livekit-client").Track.Source;
|
|
107
|
+
participant: import('livekit-client').RemoteParticipant;
|
|
108
|
+
publication: import('livekit-client').RemoteTrackPublication;
|
|
109
|
+
} | null;
|
|
110
|
+
getVideoTrackRefs(): {
|
|
111
|
+
source: import("livekit-client").Track.Source;
|
|
112
|
+
participant: any;
|
|
113
|
+
publication: any;
|
|
114
|
+
}[];
|
|
115
|
+
getCameraTrackRefs(): {
|
|
116
|
+
source: import("livekit-client").Track.Source;
|
|
117
|
+
participant: any;
|
|
118
|
+
publication: any;
|
|
119
|
+
}[];
|
|
120
|
+
getScreenShareTrackRefs(): {
|
|
121
|
+
source: import("livekit-client").Track.Source;
|
|
122
|
+
participant: any;
|
|
123
|
+
publication: any;
|
|
124
|
+
}[];
|
|
178
125
|
getPublishPermissions(): {
|
|
179
126
|
camera: boolean;
|
|
180
127
|
microphone: boolean;
|
|
@@ -182,89 +129,32 @@ export declare class VoxketClient extends VoxketEventEmitter<VoxketEvents & RpcE
|
|
|
182
129
|
data: boolean;
|
|
183
130
|
};
|
|
184
131
|
canPublishSource(source: 'camera' | 'microphone' | 'screenShare'): boolean;
|
|
132
|
+
getLocalParticipant(): import('livekit-client').LocalParticipant | null;
|
|
133
|
+
getRemoteParticipants(): import('livekit-client').RemoteParticipant[];
|
|
134
|
+
getParticipants(): ParticipantInfo[];
|
|
185
135
|
getRoom(): Room | null;
|
|
186
136
|
getConnectionState(): ConnectionState;
|
|
187
137
|
get connected(): boolean;
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
registerPlugin(plugin: any): void;
|
|
195
|
-
getPluginManager(): PluginManager;
|
|
196
|
-
getParticipants(): ParticipantInfo[];
|
|
197
|
-
getSessionMetrics(): SessionMetrics | null;
|
|
198
|
-
updateConfig(updates: Partial<VoxketClientConfig>): void;
|
|
199
|
-
startRecording(): Promise<void>;
|
|
200
|
-
stopRecording(): Promise<void>;
|
|
201
|
-
/**
|
|
202
|
-
* Register a frontend RPC method with a React component
|
|
203
|
-
* @param methodName The RPC method name to register
|
|
204
|
-
* @param component React component that implements VoxketInteractiveView
|
|
205
|
-
* @param presentationMode How the component should be displayed
|
|
206
|
-
*/
|
|
138
|
+
getCurrentAgentInfo(): AgentInfo | null;
|
|
139
|
+
getIsAgentConnected(): boolean;
|
|
140
|
+
getAgentState(): 'idle' | 'thinking' | 'speaking';
|
|
141
|
+
renderUI(options?: RenderUIOptions): void;
|
|
142
|
+
removeUI(target?: string | HTMLElement): void;
|
|
143
|
+
removeAllUI(): void;
|
|
207
144
|
registerFrontendRPC(methodName: string, component: VoxketInteractiveView, presentationMode?: ViewPresentationMode): Promise<void>;
|
|
208
|
-
/**
|
|
209
|
-
* Get the current interactive RPC component state
|
|
210
|
-
*/
|
|
211
145
|
getCurrentInteraction(): InteractiveUIState | null;
|
|
212
|
-
/**
|
|
213
|
-
* Dismiss the current interactive component
|
|
214
|
-
*/
|
|
215
146
|
dismissCurrentInteraction(): void;
|
|
216
|
-
/**
|
|
217
|
-
* Get all registered RPC methods
|
|
218
|
-
*/
|
|
219
147
|
getRegisteredRpcMethods(): string[];
|
|
220
|
-
/**
|
|
221
|
-
* Unregister an RPC method
|
|
222
|
-
*/
|
|
223
148
|
unregisterRpcMethod(methodName: string): void;
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
* This is useful for passing business-specific user information to the API.
|
|
227
|
-
* @param metadata Object containing participant metadata (e.g., userId, customerType, etc.)
|
|
228
|
-
*/
|
|
229
|
-
setParticipantMetadata(metadata: Record<string, any>): void;
|
|
230
|
-
/**
|
|
231
|
-
* Get the current participant metadata
|
|
232
|
-
*/
|
|
233
|
-
getParticipantMetadata(): Record<string, any> | undefined;
|
|
234
|
-
/**
|
|
235
|
-
* Register a custom event listener for VoxketClient events.
|
|
236
|
-
* This is a business-friendly alias for the inherited `on` method.
|
|
237
|
-
* @param eventName The event name to listen for (string)
|
|
238
|
-
* @param callback The callback function to invoke with event data
|
|
239
|
-
* @returns Unsubscribe function
|
|
240
|
-
*
|
|
241
|
-
* Example:
|
|
242
|
-
* client.registerEventListener('chat.message.received', (msg) => { ... });
|
|
243
|
-
*/
|
|
149
|
+
registerPlugin(plugin: any): void;
|
|
150
|
+
getPluginManager(): PluginManager;
|
|
244
151
|
registerEventListener<K extends keyof (VoxketEvents & RpcEvents)>(eventName: K, callback: (data: any) => void): () => void;
|
|
245
|
-
/**
|
|
246
|
-
* Register a custom event emitter for a LiveKit text stream topic.
|
|
247
|
-
* This allows business/consumer code to listen for custom events sent via text stream.
|
|
248
|
-
* @param topic The topic name to listen for (string)
|
|
249
|
-
* @param handler The callback function to invoke with (data, participantInfo)
|
|
250
|
-
* @returns void
|
|
251
|
-
*
|
|
252
|
-
* Example:
|
|
253
|
-
* client.registerEventEmitter('custom_event', (data) => { ... });
|
|
254
|
-
*/
|
|
255
152
|
registerEventEmitter(topic: string, handler: (data: string) => void): void;
|
|
256
|
-
/**
|
|
257
|
-
* Get the list of registered custom event emitters (for debugging)
|
|
258
|
-
*/
|
|
259
153
|
getRegisteredEventEmitters(): string[];
|
|
260
|
-
/**
|
|
261
|
-
* Check if a custom event emitter is registered for a topic
|
|
262
|
-
*/
|
|
263
154
|
hasEventEmitter(topic: string): boolean;
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
private convertMarkdownToText;
|
|
155
|
+
updateConfig(updates: Partial<VoxketClientConfig>): void;
|
|
156
|
+
setParticipantMetadata(metadata: Record<string, any>): void;
|
|
157
|
+
getParticipantMetadata(): Record<string, any> | undefined;
|
|
158
|
+
startRecording(): Promise<void>;
|
|
159
|
+
stopRecording(): Promise<void>;
|
|
270
160
|
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Room, ConnectionState } from 'livekit-client';
|
|
2
|
+
import { VoxketEventEmitter } from './event-emitter';
|
|
3
|
+
import { VoxketEvents, AgentInfo, ParticipantInfo, SessionModality } from '../types/core';
|
|
4
|
+
export interface ConnectionConfig {
|
|
5
|
+
baseUrl: string;
|
|
6
|
+
appId: string;
|
|
7
|
+
appSecret: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* ConnectionManager
|
|
11
|
+
*
|
|
12
|
+
* Manages all connection-related functionality including:
|
|
13
|
+
* - Room connection and disconnection
|
|
14
|
+
* - Connection state management
|
|
15
|
+
* - Participant tracking
|
|
16
|
+
* - Connection details fetching
|
|
17
|
+
* - Room event handling
|
|
18
|
+
*/
|
|
19
|
+
export declare class ConnectionManager {
|
|
20
|
+
private room;
|
|
21
|
+
private config;
|
|
22
|
+
private eventEmitter;
|
|
23
|
+
private connectionState;
|
|
24
|
+
private isConnected;
|
|
25
|
+
private currentAgentInfo;
|
|
26
|
+
constructor(config: ConnectionConfig, eventEmitter: VoxketEventEmitter<VoxketEvents>);
|
|
27
|
+
/**
|
|
28
|
+
* Initialize or reinitialize the room
|
|
29
|
+
*/
|
|
30
|
+
private initializeRoom;
|
|
31
|
+
/**
|
|
32
|
+
* Setup event listeners for the room
|
|
33
|
+
*/
|
|
34
|
+
private setupRoomEventListeners;
|
|
35
|
+
/**
|
|
36
|
+
* Fetch connection details from the server
|
|
37
|
+
*/
|
|
38
|
+
fetchConnectionDetails(agentId: string, participantName: string, modalities: SessionModality[], participantMetadata?: Record<string, any>): Promise<{
|
|
39
|
+
serverUrl: string;
|
|
40
|
+
participantToken: string;
|
|
41
|
+
voxketSessionId: string;
|
|
42
|
+
agentInfo?: AgentInfo;
|
|
43
|
+
}>;
|
|
44
|
+
/**
|
|
45
|
+
* Connect to the room
|
|
46
|
+
*/
|
|
47
|
+
connect(agentId: string, participantName: string, modalities: SessionModality[], participantMetadata?: Record<string, any>): Promise<{
|
|
48
|
+
serverUrl: string;
|
|
49
|
+
participantToken: string;
|
|
50
|
+
voxketSessionId: string;
|
|
51
|
+
agentInfo?: AgentInfo;
|
|
52
|
+
}>;
|
|
53
|
+
/**
|
|
54
|
+
* Disconnect from the room
|
|
55
|
+
*/
|
|
56
|
+
disconnect(): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Get the current room instance
|
|
59
|
+
*/
|
|
60
|
+
getRoom(): Room | null;
|
|
61
|
+
/**
|
|
62
|
+
* Get the connection state
|
|
63
|
+
*/
|
|
64
|
+
getConnectionState(): ConnectionState;
|
|
65
|
+
/**
|
|
66
|
+
* Check if connected
|
|
67
|
+
*/
|
|
68
|
+
get connected(): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Get current agent info
|
|
71
|
+
*/
|
|
72
|
+
getCurrentAgentInfo(): AgentInfo | null;
|
|
73
|
+
/**
|
|
74
|
+
* Get all participants
|
|
75
|
+
*/
|
|
76
|
+
getParticipants(): ParticipantInfo[];
|
|
77
|
+
/**
|
|
78
|
+
* Update configuration
|
|
79
|
+
*/
|
|
80
|
+
updateConfig(updates: Partial<ConnectionConfig>): void;
|
|
81
|
+
}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -4,6 +4,14 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export { VoxketClient } from './client';
|
|
6
6
|
export { VoxketEventEmitter } from './event-emitter';
|
|
7
|
+
export { RpcManager } from './rpc-manager';
|
|
8
|
+
export { ChatManager } from './chat-manager';
|
|
9
|
+
export { MediaManager } from './media-manager';
|
|
10
|
+
export { ConnectionManager } from './connection-manager';
|
|
11
|
+
export { StreamHandlerManager } from './stream-handler-manager';
|
|
12
|
+
export { UIRenderer } from './ui-renderer';
|
|
13
|
+
export { AgentManager } from './agent-manager';
|
|
7
14
|
export { VoxketClient as VoxketSDK } from './client';
|
|
8
15
|
export type * from '../types/core';
|
|
9
|
-
export type {
|
|
16
|
+
export type { VoxketClientConfig } from './client';
|
|
17
|
+
export type { RenderUIOptions } from './ui-renderer';
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { Room, LocalParticipant, RemoteParticipant, Track } from 'livekit-client';
|
|
2
|
+
import { VoxketEventEmitter } from './event-emitter';
|
|
3
|
+
import { VoxketEvents } from '../types/core';
|
|
4
|
+
/**
|
|
5
|
+
* MediaManager
|
|
6
|
+
*
|
|
7
|
+
* Manages all media-related functionality including:
|
|
8
|
+
* - Camera control
|
|
9
|
+
* - Microphone control
|
|
10
|
+
* - Screen share control
|
|
11
|
+
* - Device enumeration
|
|
12
|
+
* - Track management
|
|
13
|
+
* - Media permissions
|
|
14
|
+
*/
|
|
15
|
+
export declare class MediaManager {
|
|
16
|
+
private room;
|
|
17
|
+
private eventEmitter;
|
|
18
|
+
private silencePreventionNode;
|
|
19
|
+
private silencePreventionOscillator;
|
|
20
|
+
private audioContext;
|
|
21
|
+
constructor(eventEmitter: VoxketEventEmitter<VoxketEvents>);
|
|
22
|
+
/**
|
|
23
|
+
* Initialize AudioContext and ensure it's running
|
|
24
|
+
* This must be called on user interaction to comply with browser autoplay policies
|
|
25
|
+
*/
|
|
26
|
+
private initializeAudioContext;
|
|
27
|
+
/**
|
|
28
|
+
* Ensure AudioContext is running (call before any audio operations)
|
|
29
|
+
*/
|
|
30
|
+
ensureAudioContextRunning(): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Set the room instance for media management
|
|
33
|
+
*/
|
|
34
|
+
setRoom(room: Room | null): void;
|
|
35
|
+
/**
|
|
36
|
+
* Get local participant
|
|
37
|
+
*/
|
|
38
|
+
getLocalParticipant(): LocalParticipant | null;
|
|
39
|
+
/**
|
|
40
|
+
* Get remote participants
|
|
41
|
+
*/
|
|
42
|
+
getRemoteParticipants(): RemoteParticipant[];
|
|
43
|
+
/**
|
|
44
|
+
* Toggle microphone (if enabled is not specified, it will toggle)
|
|
45
|
+
*/
|
|
46
|
+
toggleMicrophone(enabled?: boolean): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Set microphone enabled state
|
|
49
|
+
*/
|
|
50
|
+
setMicrophoneEnabled(enabled: boolean): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Start silence prevention by injecting a very low-volume tone
|
|
53
|
+
* This prevents LiveKit's silence detection from restarting the microphone track
|
|
54
|
+
*/
|
|
55
|
+
private startSilencePrevention;
|
|
56
|
+
/**
|
|
57
|
+
* Stop silence prevention
|
|
58
|
+
*/
|
|
59
|
+
private stopSilencePrevention;
|
|
60
|
+
/**
|
|
61
|
+
* Toggle camera (if enabled is not specified, it will toggle)
|
|
62
|
+
*/
|
|
63
|
+
toggleCamera(enabled?: boolean): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Set camera enabled state
|
|
66
|
+
*/
|
|
67
|
+
setCameraEnabled(enabled: boolean): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Enable camera
|
|
70
|
+
*/
|
|
71
|
+
enableCamera(): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Disable camera
|
|
74
|
+
*/
|
|
75
|
+
disableCamera(): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Start screen share
|
|
78
|
+
*/
|
|
79
|
+
startScreenShare(): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Stop screen share
|
|
82
|
+
*/
|
|
83
|
+
stopScreenShare(): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Get available audio input devices
|
|
86
|
+
*/
|
|
87
|
+
getAudioInputDevices(): Promise<MediaDeviceInfo[]>;
|
|
88
|
+
/**
|
|
89
|
+
* Get available video input devices
|
|
90
|
+
*/
|
|
91
|
+
getVideoInputDevices(): Promise<MediaDeviceInfo[]>;
|
|
92
|
+
/**
|
|
93
|
+
* Set audio input device
|
|
94
|
+
*/
|
|
95
|
+
setAudioInputDevice(deviceId: string): Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* Set video input device
|
|
98
|
+
*/
|
|
99
|
+
setVideoInputDevice(deviceId: string): Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* Get microphone track
|
|
102
|
+
*/
|
|
103
|
+
getMicrophoneTrack(): import('livekit-client').LocalTrack<Track.Kind> | null | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* Get camera track
|
|
106
|
+
*/
|
|
107
|
+
getCameraTrack(): import('livekit-client').LocalTrack<Track.Kind> | null | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* Get screen share track
|
|
110
|
+
*/
|
|
111
|
+
getScreenShareTrack(): import('livekit-client').LocalTrack<Track.Kind> | null | undefined;
|
|
112
|
+
/**
|
|
113
|
+
* Check if microphone is enabled
|
|
114
|
+
*/
|
|
115
|
+
get isMicrophoneEnabled(): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Check if camera is enabled
|
|
118
|
+
*/
|
|
119
|
+
get isCameraEnabled(): boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Check if screen share is enabled
|
|
122
|
+
*/
|
|
123
|
+
get isScreenShareEnabled(): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Get agent audio track
|
|
126
|
+
*/
|
|
127
|
+
getAgentAudioTrack(): {
|
|
128
|
+
source: Track.Source;
|
|
129
|
+
participant: RemoteParticipant;
|
|
130
|
+
publication: import('livekit-client').RemoteTrackPublication;
|
|
131
|
+
} | null;
|
|
132
|
+
/**
|
|
133
|
+
* Get agent video track
|
|
134
|
+
*/
|
|
135
|
+
getAgentVideoTrack(): {
|
|
136
|
+
source: Track.Source;
|
|
137
|
+
participant: RemoteParticipant;
|
|
138
|
+
publication: import('livekit-client').RemoteTrackPublication;
|
|
139
|
+
} | null;
|
|
140
|
+
/**
|
|
141
|
+
* Get all video track refs (local and remote, camera and screen share)
|
|
142
|
+
*/
|
|
143
|
+
getVideoTrackRefs(): Array<{
|
|
144
|
+
source: Track.Source;
|
|
145
|
+
participant: any;
|
|
146
|
+
publication: any;
|
|
147
|
+
}>;
|
|
148
|
+
/**
|
|
149
|
+
* Get camera track refs only
|
|
150
|
+
*/
|
|
151
|
+
getCameraTrackRefs(): Array<{
|
|
152
|
+
source: Track.Source;
|
|
153
|
+
participant: any;
|
|
154
|
+
publication: any;
|
|
155
|
+
}>;
|
|
156
|
+
/**
|
|
157
|
+
* Get screen share track refs only
|
|
158
|
+
*/
|
|
159
|
+
getScreenShareTrackRefs(): Array<{
|
|
160
|
+
source: Track.Source;
|
|
161
|
+
participant: any;
|
|
162
|
+
publication: any;
|
|
163
|
+
}>;
|
|
164
|
+
/**
|
|
165
|
+
* Get publish permissions for various media sources
|
|
166
|
+
*/
|
|
167
|
+
getPublishPermissions(): {
|
|
168
|
+
camera: boolean;
|
|
169
|
+
microphone: boolean;
|
|
170
|
+
screenShare: boolean;
|
|
171
|
+
data: boolean;
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* Check if a specific source can be published
|
|
175
|
+
*/
|
|
176
|
+
canPublishSource(source: 'camera' | 'microphone' | 'screenShare'): boolean;
|
|
177
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Room } from 'livekit-client';
|
|
2
|
+
import { VoxketEventEmitter } from './event-emitter';
|
|
3
|
+
import { ChatManager } from './chat-manager';
|
|
4
|
+
import { AgentManager } from './agent-manager';
|
|
5
|
+
import { VoxketEvents } from '../types/core';
|
|
6
|
+
/**
|
|
7
|
+
* StreamHandlerManager
|
|
8
|
+
*
|
|
9
|
+
* Manages all text and byte stream handlers including:
|
|
10
|
+
* - Chat message streams (lk.chat)
|
|
11
|
+
* - Transcription streams (lk.transcription)
|
|
12
|
+
* - Agent state change streams
|
|
13
|
+
* - Tool execution streams
|
|
14
|
+
* - Image attachment streams
|
|
15
|
+
* - Custom event emitter streams
|
|
16
|
+
* - Suggested response streams
|
|
17
|
+
*/
|
|
18
|
+
export declare class StreamHandlerManager {
|
|
19
|
+
private room;
|
|
20
|
+
private eventEmitter;
|
|
21
|
+
private chatManager;
|
|
22
|
+
private agentManager;
|
|
23
|
+
private textStreamHandlersRegistered;
|
|
24
|
+
private _eventEmitters;
|
|
25
|
+
constructor(eventEmitter: VoxketEventEmitter<VoxketEvents>, chatManager: ChatManager, agentManager: AgentManager);
|
|
26
|
+
/**
|
|
27
|
+
* Set the room instance for stream handling
|
|
28
|
+
* Automatically registers handlers when room is set and not already registered
|
|
29
|
+
*/
|
|
30
|
+
setRoom(room: Room | null): void;
|
|
31
|
+
/**
|
|
32
|
+
* Check if stream handlers are registered
|
|
33
|
+
*/
|
|
34
|
+
areHandlersRegistered(): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Reset handlers registration flag
|
|
37
|
+
*/
|
|
38
|
+
resetHandlersFlag(): void;
|
|
39
|
+
/**
|
|
40
|
+
* Setup all text stream handlers
|
|
41
|
+
*/
|
|
42
|
+
setupTextStreamHandlers(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Register chat message handler (lk.chat)
|
|
45
|
+
*/
|
|
46
|
+
private registerChatHandler;
|
|
47
|
+
/**
|
|
48
|
+
* Register transcription handler (lk.transcription)
|
|
49
|
+
*/
|
|
50
|
+
private registerTranscriptionHandler;
|
|
51
|
+
/**
|
|
52
|
+
* Register suggested response handler
|
|
53
|
+
*/
|
|
54
|
+
private registerSuggestedResponseHandler;
|
|
55
|
+
/**
|
|
56
|
+
* Register agent state change handler
|
|
57
|
+
*/
|
|
58
|
+
private registerAgentStateHandler;
|
|
59
|
+
/**
|
|
60
|
+
* Register function tools execution handler
|
|
61
|
+
*/
|
|
62
|
+
private registerFunctionToolsHandler;
|
|
63
|
+
/**
|
|
64
|
+
* Register image text stream handler
|
|
65
|
+
*/
|
|
66
|
+
private registerImageTextStreamHandler;
|
|
67
|
+
/**
|
|
68
|
+
* Register image byte stream handler
|
|
69
|
+
*/
|
|
70
|
+
private registerImageByteStreamHandler;
|
|
71
|
+
/**
|
|
72
|
+
* Register handlers for common topics
|
|
73
|
+
*/
|
|
74
|
+
private registerCommonTopicHandlers;
|
|
75
|
+
/**
|
|
76
|
+
* Register wildcard handler for unhandled topics
|
|
77
|
+
*/
|
|
78
|
+
private registerWildcardHandler;
|
|
79
|
+
/**
|
|
80
|
+
* Register a custom event emitter for a specific topic
|
|
81
|
+
*/
|
|
82
|
+
registerEventEmitter(topic: string, handler: (data: string) => void): void;
|
|
83
|
+
/**
|
|
84
|
+
* Get all registered event emitters
|
|
85
|
+
*/
|
|
86
|
+
getRegisteredEventEmitters(): string[];
|
|
87
|
+
/**
|
|
88
|
+
* Check if an event emitter is registered for a topic
|
|
89
|
+
*/
|
|
90
|
+
hasEventEmitter(topic: string): boolean;
|
|
91
|
+
}
|