open-index/open-npm huggingface dataset:
npm package: @krytabo/ai-chat-core
Description: Framework-agnostic core for AI Chat WebSocket communication.
Latest version: 0.1.2

# @krytabo/ai-chat-core

Framework-agnostic core for AI Chat WebSocket communication.

## Install

```sh
yarn add @krytabo/ai-chat-core
```

## Usage

```js
import { VoiceAgentClient } from "@krytabo/ai-chat-core";

const client = new VoiceAgentClient({
  basePath: "/ws/audio",
  // host: "your-host",
  // port: 8000,
  // url: "wss://example.com/ws/audio"
});

client.on("state_update", (payload) => {
  console.log(payload.state);
});

client.on("text", (payload) => {
  console.log(payload.source, payload.text);
});

client.on("audio", (buffer) => {
  console.log("tts audio", buffer.byteLength);
});

client.connect();

client.sendText("hello");
```

## Supported Events

- state_update
- text
- trace
- llm_delta
- agent_response
- audio
- tts_stop
- error