@hamsa-ai/voice-agents-sdk 0.5.5-beta.1 → 0.5.5

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.5-beta.1",
3
+ "version": "0.5.5",
4
4
  "description": "Hamsa AI - Voice Agents JavaScript SDK",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -299,7 +299,8 @@ export declare class LiveKitToolRegistry extends EventEmitter {
299
299
  * wrapped with error handling and JSON serialization for secure, reliable
300
300
  * execution. Registration only occurs when both room and tools are available.
301
301
  *
302
- * @fires toolsRegistered When tools are successfully registered with count
302
+ * @fires toolsRegistered When tools are successfully registered with the list of tools
303
+ * @fires rpcError When a tool execution fails
303
304
  *
304
305
  * @example
305
306
  * ```typescript
@@ -307,14 +308,14 @@ export declare class LiveKitToolRegistry extends EventEmitter {
307
308
  * registry.registerTools();
308
309
  *
309
310
  * // Listen for registration confirmation
310
- * registry.on('toolsRegistered', (count) => {
311
- * console.log(`${count} tools registered successfully`);
311
+ * registry.on('toolsRegistered', (tools) => {
312
+ * console.log(`${tools.length} tools registered successfully`);
312
313
  *
313
314
  * // Notify agent about available tools
314
315
  * sendAgentMessage({
315
316
  * type: 'tools_ready',
316
- * count: count,
317
- * tools: registry.getTools().map(t => ({
317
+ * count: tools.length,
318
+ * tools: tools.map(t => ({
318
319
  * name: t.function_name,
319
320
  * description: t.description
320
321
  * }))
@@ -326,7 +327,7 @@ export declare class LiveKitToolRegistry extends EventEmitter {
326
327
  * 1. Validates tool structure (function_name, fn)
327
328
  * 2. Creates RPC method wrapper with error handling
328
329
  * 3. Registers with LiveKit room's local participant
329
- * 4. Emits toolsRegistered event with count
330
+ * 4. Emits toolsRegistered event with tools list
330
331
  * 5. Tools become immediately available for agent calls
331
332
  */
332
333
  registerTools(): void;
package/types/main.d.ts CHANGED
@@ -3,6 +3,8 @@ import type { ConnectionState, LocalTrack, LocalTrackPublication, Participant, R
3
3
  import LiveKitManager, { type AgentState, type AudioLevelsResult, type CallAnalyticsResult, type ConnectionStatsResult, type ParticipantData, type PerformanceMetricsResult, type TrackStatsResult } from './classes/livekit-manager';
4
4
  import ScreenWakeLock from './classes/screen-wake-lock';
5
5
  import type { AudioCaptureCallback, AudioCaptureOptions, ConnectionQualityData, DTMFDigit, TrackSubscriptionData, TrackUnsubscriptionData } from './classes/types';
6
+ export type { RpcInvocationData } from 'livekit-client';
7
+ export { RpcError } from 'livekit-client';
6
8
  export type { AgentState } from './classes/livekit-manager';
7
9
  export type { AudioCaptureCallback, AudioCaptureFormat, AudioCaptureMetadata, AudioCaptureOptions, AudioCaptureSource, DTMFDigit, } from './classes/types';
8
10
  /**
@@ -105,6 +107,8 @@ type Tool = {
105
107
  required?: string[];
106
108
  /** Internal function mapping (used for tool execution) */
107
109
  func_map?: Record<string, unknown>;
110
+ /** The implementation function to execute when the agent calls this tool */
111
+ fn?: (...args: unknown[]) => unknown | Promise<unknown>;
108
112
  };
109
113
  /**
110
114
  * Definition of a parameter for a client-side tool
@@ -225,6 +229,10 @@ type HamsaVoiceAgentEvents = {
225
229
  customEvent: (eventType: string, eventData: unknown, metadata?: Record<string, unknown>) => void;
226
230
  /** Emitted for informational messages */
227
231
  info: (info: string) => void;
232
+ /** Emitted when tools are registered with the agent */
233
+ toolsRegistered: (tools: Tool[]) => void;
234
+ /** Emitted when a client-side tool execution fails */
235
+ rpcError: (functionName: string, error: unknown) => void;
228
236
  };
229
237
  /**
230
238
  * HamsaVoiceAgent - Main SDK class for voice agent integration