@hamsa-ai/voice-agents-sdk 0.6.0-beta.0 → 0.6.0-beta.2
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/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/types/classes/livekit-connection.d.ts +4 -1
- package/types/classes/livekit-manager.d.ts +2 -1
- package/types/classes/livekit-tool-registry.d.ts +25 -0
package/package.json
CHANGED
|
@@ -190,6 +190,8 @@ export declare class LiveKitConnection extends EventEmitter {
|
|
|
190
190
|
private hasEmittedConnected;
|
|
191
191
|
/** Debug logger instance for conditional logging */
|
|
192
192
|
private readonly logger;
|
|
193
|
+
/** When true, the session is text/chat-only and the microphone is never enabled */
|
|
194
|
+
private readonly isChatOnly;
|
|
193
195
|
/**
|
|
194
196
|
* Creates a new LiveKitConnection instance
|
|
195
197
|
*
|
|
@@ -200,6 +202,7 @@ export declare class LiveKitConnection extends EventEmitter {
|
|
|
200
202
|
* @param lkUrl - LiveKit WebSocket URL (e.g., 'wss://livekit.example.com')
|
|
201
203
|
* @param accessToken - JWT token for room authentication and authorization
|
|
202
204
|
* @param debug - Enable debug logging (defaults to false)
|
|
205
|
+
* @param isChatOnly - When true, the microphone is never enabled (text/chat-only session)
|
|
203
206
|
*
|
|
204
207
|
* @example
|
|
205
208
|
* ```typescript
|
|
@@ -213,7 +216,7 @@ export declare class LiveKitConnection extends EventEmitter {
|
|
|
213
216
|
* await connection.connect();
|
|
214
217
|
* ```
|
|
215
218
|
*/
|
|
216
|
-
constructor(lkUrl: string, accessToken: string, debug?: boolean);
|
|
219
|
+
constructor(lkUrl: string, accessToken: string, debug?: boolean, isChatOnly?: boolean);
|
|
217
220
|
/**
|
|
218
221
|
* Provides access to the underlying LiveKit room instance
|
|
219
222
|
*
|
|
@@ -90,9 +90,10 @@ export default class LiveKitManager extends EventEmitter {
|
|
|
90
90
|
* );
|
|
91
91
|
* ```
|
|
92
92
|
*/
|
|
93
|
-
constructor(lkUrl: string, accessToken: string, tools?: Tool[], { debug, avatarContainerSelector, }?: {
|
|
93
|
+
constructor(lkUrl: string, accessToken: string, tools?: Tool[], { debug, avatarContainerSelector, isChatOnly, }?: {
|
|
94
94
|
debug?: boolean;
|
|
95
95
|
avatarContainerSelector?: string;
|
|
96
|
+
isChatOnly?: boolean;
|
|
96
97
|
});
|
|
97
98
|
/**
|
|
98
99
|
* Establishes connection to the LiveKit room and initializes voice agent communication
|
|
@@ -180,6 +180,15 @@
|
|
|
180
180
|
import { EventEmitter } from 'events';
|
|
181
181
|
import type { Room } from 'livekit-client';
|
|
182
182
|
import type { Tool } from './types';
|
|
183
|
+
/**
|
|
184
|
+
* LiveKit text-stream topic used for chat messages.
|
|
185
|
+
*
|
|
186
|
+
* Both directions use this topic: the SDK publishes user messages here via
|
|
187
|
+
* `sendText`, and the agent publishes its replies here as text streams. The
|
|
188
|
+
* registry registers a handler on this topic to surface inbound agent messages
|
|
189
|
+
* as `messageReceived` events.
|
|
190
|
+
*/
|
|
191
|
+
export declare const LIVEKIT_CHAT_TOPIC = "lk.chat";
|
|
183
192
|
/**
|
|
184
193
|
* LiveKitToolRegistry class for client-side tool management and RPC handling
|
|
185
194
|
*
|
|
@@ -201,6 +210,8 @@ export declare class LiveKitToolRegistry extends EventEmitter {
|
|
|
201
210
|
private readonly logger;
|
|
202
211
|
/** Monotonic counter for synthesizing message ids when a segment lacks one */
|
|
203
212
|
private fallbackMessageIdCounter;
|
|
213
|
+
/** Whether the chat text-stream handler is currently registered on the room */
|
|
214
|
+
private chatStreamRegistered;
|
|
204
215
|
/**
|
|
205
216
|
* Creates a new LiveKitToolRegistry instance
|
|
206
217
|
*
|
|
@@ -256,6 +267,20 @@ export declare class LiveKitToolRegistry extends EventEmitter {
|
|
|
256
267
|
* ```
|
|
257
268
|
*/
|
|
258
269
|
setRoom(room: Room | null): void;
|
|
270
|
+
/**
|
|
271
|
+
* Registers a text-stream handler on {@link LIVEKIT_CHAT_TOPIC} to receive the
|
|
272
|
+
* agent's chat replies.
|
|
273
|
+
*
|
|
274
|
+
* The agent publishes its responses as LiveKit text streams on this topic.
|
|
275
|
+
* Each stream's chunks are concatenated and emitted via `messageReceived`,
|
|
276
|
+
* streaming partials (`isFinal: false`) followed by a final message
|
|
277
|
+
* (`isFinal: true`). The stream id is reused as the message id so a chat UI
|
|
278
|
+
* can update the same bubble in place.
|
|
279
|
+
*
|
|
280
|
+
* Guarded so it registers at most once per room — `registerTextStreamHandler`
|
|
281
|
+
* throws if a handler already exists for the topic.
|
|
282
|
+
*/
|
|
283
|
+
private registerChatStreamHandler;
|
|
259
284
|
/**
|
|
260
285
|
* Updates the available tools and re-registers them with the room
|
|
261
286
|
*
|