@hamsa-ai/voice-agents-sdk 0.6.0-beta.4 → 0.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hamsa-ai/voice-agents-sdk",
3
- "version": "0.6.0-beta.4",
3
+ "version": "0.6.0",
4
4
  "description": "Hamsa AI - Voice Agents JavaScript SDK",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -189,6 +189,17 @@ import type { Tool } from './types';
189
189
  * as `messageReceived` events.
190
190
  */
191
191
  export declare const LIVEKIT_CHAT_TOPIC = "lk.chat";
192
+ /**
193
+ * LiveKit text-stream topic the agent uses for transcription/response text.
194
+ *
195
+ * In chat-only sessions there is no audio subscription, so the normal
196
+ * `RoomEvent.TranscriptionReceived` event never fires — but the agent still
197
+ * publishes its text on this topic as a data-stream. The registry registers a
198
+ * text-stream handler here (chat-only) so those messages surface as
199
+ * `chatMessageReceived`. Voice sessions keep using `RoomEvent.TranscriptionReceived`
200
+ * and do NOT register this handler (it would double-emit).
201
+ */
202
+ export declare const LIVEKIT_TRANSCRIPTION_TOPIC = "lk.transcription";
192
203
  /**
193
204
  * LiveKitToolRegistry class for client-side tool management and RPC handling
194
205
  *
@@ -210,8 +221,10 @@ export declare class LiveKitToolRegistry extends EventEmitter {
210
221
  private readonly logger;
211
222
  /** Monotonic counter for synthesizing message ids when a segment lacks one */
212
223
  private fallbackMessageIdCounter;
213
- /** Whether the chat text-stream handler is currently registered on the room */
214
- private chatStreamRegistered;
224
+ /** Whether the session is text/chat-only (gates the lk.transcription handler) */
225
+ private readonly isChatOnly;
226
+ /** Topics whose chat text-stream handler is currently registered on the room */
227
+ private readonly registeredChatTopics;
215
228
  /**
216
229
  * Creates a new LiveKitToolRegistry instance
217
230
  *
@@ -238,7 +251,7 @@ export declare class LiveKitToolRegistry extends EventEmitter {
238
251
  * registry.setRoom(liveKitRoom);
239
252
  * ```
240
253
  */
241
- constructor(tools?: Tool[], debug?: boolean);
254
+ constructor(tools?: Tool[], debug?: boolean, isChatOnly?: boolean);
242
255
  /**
243
256
  * Configures the LiveKit room for tool registration and RPC setup
244
257
  *
@@ -268,19 +281,29 @@ export declare class LiveKitToolRegistry extends EventEmitter {
268
281
  */
269
282
  setRoom(room: Room | null): void;
270
283
  /**
271
- * Registers a text-stream handler on {@link LIVEKIT_CHAT_TOPIC} to receive the
272
- * agent's chat replies.
284
+ * Registers text-stream handlers to receive the agent's chat replies.
273
285
  *
274
- * The agent publishes its responses as LiveKit text streams on this topic.
275
- * Each stream's chunks are concatenated and emitted via `messageReceived`,
286
+ * The agent publishes its responses as LiveKit text streams. This registers a
287
+ * handler on {@link LIVEKIT_CHAT_TOPIC}, and for chat-only sessions —
288
+ * additionally on {@link LIVEKIT_TRANSCRIPTION_TOPIC}, because chat-only never
289
+ * subscribes to audio and so never receives `RoomEvent.TranscriptionReceived`.
290
+ * Voice sessions skip the transcription topic (it would double-emit alongside
291
+ * the existing `RoomEvent.TranscriptionReceived` path).
292
+ *
293
+ * Each stream's chunks are concatenated and emitted via `chatMessageReceived`,
276
294
  * streaming partials (`isFinal: false`) followed by a final message
277
295
  * (`isFinal: true`). The stream id is reused as the message id so a chat UI
278
296
  * can update the same bubble in place.
279
297
  *
280
- * Guarded so it registers at most once per room — `registerTextStreamHandler`
281
- * throws if a handler already exists for the topic.
298
+ * Guarded per topic `registerTextStreamHandler` throws if a handler already
299
+ * exists for the topic.
282
300
  */
283
301
  private registerChatStreamHandler;
302
+ /**
303
+ * Builds a text-stream handler that concatenates streamed chunks and emits
304
+ * them as `chatMessageReceived` (streaming partials then a final message).
305
+ */
306
+ private createChatStreamHandler;
284
307
  /**
285
308
  * Updates the available tools and re-registers them with the room
286
309
  *