open-index/open-npm huggingface dataset:
npm package: @sable-ai/voice-agent
Description: Voice agent implementation for Sable AI
Latest version: 0.1.0

# @sable-ai/voice-agent

A TypeScript library for integrating with Sable's voice agent, providing a simple interface for voice agent interactions.

## Installation

```bash
npm install @sable-ai/voice-agent
# or
yarn add @sable-ai/voice-agent
```

## Prerequisites

- Node.js 18.0.0 or higher
- `@sable-ai/core` peer dependency

## Quick Start

```typescript
import { VoiceAgent, ToolRegistry } from '@sable-ai/voice-agent';

// Initialize the tool registry
const toolRegistry = new ToolRegistry();

// Create a voice agent instance
const agent = new VoiceAgent({
  debug: process.env.NODE_ENV !== 'production',
  autoConnect: false,
  onStatusChange: (status) => console.log('Status:', status),
  onTranscript: (transcript) => console.log('Transcript:', transcript),
  onError: (error) => console.error('Error:', error)
}, toolRegistry);

// Start a call
async function startCall() {
  try {
    await agent.startCall({
      systemPrompt: 'You are a helpful assistant',
      model: 'gpt-4',
      voice: 'en-US-Studio-O'
    });
    
    // Send a text message
    agent.sendText({
      text: 'Hello, how can I help you today?',
      deferResponse: false
    });
    
    // End the call after 30 seconds
    setTimeout(() => agent.endCall(), 30000);
  } catch (error) {
    console.error('Failed to start call:', error);
  }
}

startCall();
```

## API Reference

### `VoiceAgent`

#### Constructor
```typescript
new VoiceAgent(options: VoiceAgentOptions, toolRegistry: ToolRegistry)
```

#### Methods
- `startCall(callConfig: CallConfig): Promise<void>` - Initiates a new voice call
- `endCall(): Promise<void>` - Ends the current call
- `sendText(options: SendTextOptions): void` - Sends a text message
- `toggleMute(role: Role): void` - Toggles mute for mic or speaker

### `ToolRegistry`

#### Methods
- `registerTool(name: string, implementation: Function): void` - Registers a new tool
- `getTools(): Map<string, Function>` - Returns all registered tools

## Tool Integration

You can extend the voice agent's capabilities by registering custom tools:

```typescript
// Define a tool
function getWeather(location: string): Promise<string> {
  // Implementation to fetch weather
  return Promise.resolve(`The weather in ${location} is sunny.`);
}

// Register the tool
toolRegistry.registerTool('get_weather', getWeather);

// The agent can now use this tool when appropriate
```

## Error Handling

The `VoiceAgent` emits errors through the `onError` callback. Always implement this to handle potential issues:

```typescript
const agent = new VoiceAgent({
  onError: (error) => {
    console.error('Voice Agent Error:', error);
    // Handle error appropriately
  }
}, toolRegistry);
```

## TypeScript Support

This package includes TypeScript type definitions. All types are exported for your convenience:

```typescript
import type {
  VoiceAgentOptions,
  CallConfig,
  JoinUrlResponse,
  SendTextOptions
} from '@sable-ai/voice-agent';
```
npm package: @sableclient/sable-call-embedded
Description: An embedded build of [sable-call](https://github.com/SableClient/SableCall), a fork of [element-call](https://github.com/element-hq/element-call) that will one day be stable.
Latest version: 1.1.4

# @sableclient/sable-call-embedded

An embedded build of [sable-call](https://github.com/SableClient/SableCall), a fork of [element-call](https://github.com/element-hq/element-call) that will one day be stable.

## Installation

```
npm install @sableclient/sable-call-embedded
```