@hamsa-ai/voice-agents-sdk 0.6.0-beta.1 → 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/package.json
CHANGED
|
@@ -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
|
*
|