@hamsa-ai/voice-agents-sdk 0.5.0-beta.1 → 0.5.1-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hamsa-ai/voice-agents-sdk",
3
- "version": "0.5.0-beta.1",
3
+ "version": "0.5.1-beta.1",
4
4
  "description": "Hamsa AI - Voice Agents JavaScript SDK",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -60,7 +60,7 @@
60
60
  },
61
61
  "repository": {
62
62
  "type": "git",
63
- "url": "https://github.com/hamsa-ai/voice-agents-sdk.git"
63
+ "url": "git+https://github.com/hamsa-ai/voice-agents-sdk.git"
64
64
  },
65
65
  "keywords": [
66
66
  "arab",
@@ -187,10 +187,16 @@ import type { Tool } from './types';
187
187
  * agent responses, transcriptions, and custom events from voice agents.
188
188
  */
189
189
  export declare class LiveKitToolRegistry extends EventEmitter {
190
+ /** Maximum length for text preview in debug logs */
191
+ private static readonly TEXT_PREVIEW_LENGTH;
192
+ /** Maximum length for decoded payload preview in debug logs */
193
+ private static readonly PAYLOAD_PREVIEW_LENGTH;
190
194
  /** Reference to the LiveKit room for RPC method registration */
191
195
  private room;
192
196
  /** Array of client-side tools available for agent execution */
193
197
  private tools;
198
+ /** Debug logger instance for conditional logging */
199
+ private readonly logger;
194
200
  /**
195
201
  * Creates a new LiveKitToolRegistry instance
196
202
  *
@@ -199,6 +205,7 @@ export declare class LiveKitToolRegistry extends EventEmitter {
199
205
  * added later using setTools() or updated dynamically based on context.
200
206
  *
201
207
  * @param tools - Initial array of tools to register (optional)
208
+ * @param debug - Enable debug logging for troubleshooting (optional)
202
209
  *
203
210
  * @example
204
211
  * ```typescript
@@ -216,7 +223,7 @@ export declare class LiveKitToolRegistry extends EventEmitter {
216
223
  * registry.setRoom(liveKitRoom);
217
224
  * ```
218
225
  */
219
- constructor(tools?: Tool[]);
226
+ constructor(tools?: Tool[], debug?: boolean);
220
227
  /**
221
228
  * Configures the LiveKit room for tool registration and RPC setup
222
229
  *
@@ -388,48 +395,42 @@ export declare class LiveKitToolRegistry extends EventEmitter {
388
395
  * Processes real-time transcription data from LiveKit's speech-to-text system
389
396
  *
390
397
  * Handles transcription segments received from LiveKit's built-in speech recognition,
391
- * extracting text content and emitting structured transcription events. This method
392
- * processes both partial and final transcription segments, enabling real-time
393
- * speech-to-text display and conversation logging.
398
+ * extracting text content and routing to the appropriate event based on the participant.
399
+ * This method intelligently differentiates between agent and user speech:
400
+ *
401
+ * - **Agent speech** → Emits `answerReceived` event
402
+ * - **User speech** → Emits `transcriptionReceived` event
403
+ *
404
+ * The participant is identified by checking if their identity contains "agent".
394
405
  *
395
406
  * @param transcriptions - Array of transcription segments from LiveKit
396
407
  * @param transcriptions[].text - Transcribed text content
397
408
  * @param transcriptions[].final - Whether this is a final transcription segment
409
+ * @param participantIdentity - Identity of the participant who spoke (optional)
398
410
  *
399
- * @fires transcriptionReceived When valid text content is extracted
411
+ * @fires answerReceived When agent speech is transcribed
412
+ * @fires transcriptionReceived When user speech is transcribed
400
413
  *
401
414
  * @example
402
415
  * ```typescript
403
416
  * // This method is called automatically by LiveKitManager
404
417
  * // when RoomEvent.TranscriptionReceived is triggered
405
418
  *
406
- * // Listen for transcription updates
419
+ * // Listen for USER transcriptions
407
420
  * registry.on('transcriptionReceived', (text) => {
408
- * console.log('Transcription:', text);
409
- *
410
- * // Update real-time transcript display
411
- * updateTranscriptDisplay(text);
412
- *
413
- * // Log conversation for analytics
414
- * conversationLogger.logUserSpeech(text, Date.now());
415
- *
416
- * // Trigger intent recognition
417
- * if (text.length > 10) {
418
- * intentRecognizer.analyze(text);
419
- * }
421
+ * console.log('USER said:', text);
422
+ * updateUserMessage(text);
420
423
  * });
421
424
  *
422
- * // Handle transcription processing
423
- * let transcriptBuffer = '';
424
- * registry.on('transcriptionReceived', (text) => {
425
- * transcriptBuffer += text + ' ';
426
- *
427
- * // Process complete sentences
428
- * if (text.endsWith('.') || text.endsWith('?') || text.endsWith('!')) {
429
- * processCompleteSentence(transcriptBuffer.trim());
430
- * transcriptBuffer = '';
431
- * }
425
+ * // Listen for AGENT responses
426
+ * registry.on('answerReceived', (text) => {
427
+ * console.log('AGENT said:', text);
428
+ * updateAgentMessage(text);
432
429
  * });
430
+ *
431
+ * // The routing happens automatically based on participant identity:
432
+ * // - If participant.identity includes "agent" → answerReceived
433
+ * // - Otherwise → transcriptionReceived
433
434
  * ```
434
435
  *
435
436
  * LiveKit Transcription Format:
@@ -444,7 +445,7 @@ export declare class LiveKitToolRegistry extends EventEmitter {
444
445
  handleTranscriptionReceived(transcriptions: Array<{
445
446
  text?: string;
446
447
  final?: boolean;
447
- }>): void;
448
+ }>, participantIdentity?: string): void;
448
449
  /**
449
450
  * Returns the count of currently registered tools
450
451
  *