@hamsa-ai/voice-agents-sdk 0.4.3-beta.2 → 0.4.3

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.4.3-beta.2",
3
+ "version": "0.4.3",
4
4
  "description": "Hamsa AI - Voice Agents JavaScript SDK",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -188,8 +188,8 @@ export declare class LiveKitConnection extends EventEmitter {
188
188
  private reconnectionAttempts;
189
189
  /** Whether we've already emitted a 'connected' event for the current session */
190
190
  private hasEmittedConnected;
191
- /** Enable debug logging for troubleshooting */
192
- private readonly debug;
191
+ /** Debug logger instance for conditional logging */
192
+ private readonly logger;
193
193
  /**
194
194
  * Creates a new LiveKitConnection instance
195
195
  *
@@ -33,6 +33,7 @@
33
33
  */
34
34
  import { EventEmitter } from 'events';
35
35
  import type { Room } from 'livekit-client';
36
+ import { type DebugLogger } from '../utils';
36
37
  import { LiveKitAnalytics } from './livekit-analytics';
37
38
  import { LiveKitAudioManager } from './livekit-audio-manager';
38
39
  import { LiveKitConnection } from './livekit-connection';
@@ -59,6 +60,8 @@ export default class LiveKitManager extends EventEmitter {
59
60
  lkUrl: string;
60
61
  /** JWT access token for authentication */
61
62
  accessToken: string;
63
+ /** Debug logger instance for conditional logging */
64
+ logger: DebugLogger;
62
65
  /**
63
66
  * Creates a new LiveKitManager instance
64
67
  *
package/types/main.d.ts CHANGED
@@ -320,6 +320,8 @@ declare class HamsaVoiceAgent extends EventEmitter {
320
320
  wakeLockManager: ScreenWakeLock;
321
321
  /** Flag to track if the user initiated the call end to prevent duplicate disconnection logic */
322
322
  private userInitiatedEnd;
323
+ /** Debug logger instance for conditional logging */
324
+ private readonly logger;
323
325
  /**
324
326
  * Creates a new HamsaVoiceAgent instance
325
327
  *
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Debug utility for conditional logging throughout the SDK
3
+ *
4
+ * This utility provides a centralized way to handle debug logging without
5
+ * needing biome-ignore comments for console statements. It only logs when
6
+ * debug mode is enabled.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * const logger = createDebugLogger(this.debug);
11
+ * logger.log('Connection established', { source: 'LiveKitConnection' });
12
+ * logger.error('Failed to connect', { source: 'LiveKitConnection', error });
13
+ * ```
14
+ */
15
+ type LogLevel = 'debug' | 'info' | 'warn' | 'error';
16
+ type LogOptions = {
17
+ source?: string;
18
+ level?: LogLevel;
19
+ error?: unknown;
20
+ };
21
+ /**
22
+ * Debug logger interface
23
+ */
24
+ export type DebugLogger = {
25
+ /**
26
+ * Log a debug message (only when debug mode is enabled)
27
+ */
28
+ log: (message: unknown, options?: LogOptions) => void;
29
+ /**
30
+ * Log an info message (only when debug mode is enabled)
31
+ */
32
+ info: (message: unknown, options?: LogOptions) => void;
33
+ /**
34
+ * Log a warning message (only when debug mode is enabled)
35
+ */
36
+ warn: (message: unknown, options?: LogOptions) => void;
37
+ /**
38
+ * Log an error message (always logs, regardless of debug mode)
39
+ */
40
+ error: (message: unknown, options?: LogOptions) => void;
41
+ };
42
+ /**
43
+ * Creates a debug logger instance
44
+ *
45
+ * @param debug - Whether debug mode is enabled
46
+ * @returns A debug logger instance
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * const logger = createDebugLogger(true);
51
+ * logger.log('Starting connection', { source: 'LiveKitConnection' });
52
+ * logger.error('Connection failed', { source: 'LiveKitConnection', error });
53
+ * ```
54
+ */
55
+ export declare const createDebugLogger: (debug: boolean) => DebugLogger;
56
+ export {};
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Utility functions for the Voice Agents SDK
3
+ */
4
+ export type { DebugLogger } from './debug';
5
+ export { createDebugLogger } from './debug';