npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@realtalk-ai/core

v0.2.0

Published

Core utilities for Real Talk SDKs

Readme

@realtalk-ai/core

CI npm

Transport, types, and utilities for Real Talk SDKs. This package provides the low-level building blocks — the React SDK and other framework bindings are built on top of it.

Install

npm install @realtalk-ai/core

Quick start

Connect to a conversation over WebSocket and handle events:

import { WebSocketTransport, EventType } from "@realtalk-ai/core";

const transport = new WebSocketTransport();

transport.onEvent((event) => {
  switch (event.type) {
    case EventType.MessageCreated:
      console.log("New message:", event.data.text);
      break;
    case EventType.ConversationFinished:
      transport.disconnect();
      break;
  }
});

transport.onStatusChange((connectionStatus) => {
  console.log("Connection status:", connectionStatus);
});

await transport.connect({
  url: "wss://api.realtalk.ml/api/v1/ws/conversations/audio/a1b2c3d4-e5f6-7890-abcd-ef1234567890/",
  token: "",
  sdkInfo: { name: "my-app", version: "1.0.0", context: "web" },
});

transport.sendEvent({
  type: "start",
  agent_id: "f47ac10b-58cc-4372-a567-0e02b2c3d479",
});

Reconnection

Opt into automatic reconnection by passing a policy:

import { WebSocketTransport, DefaultReconnectPolicy } from "@realtalk-ai/core";

const transport = new WebSocketTransport({
  reconnectPolicy: new DefaultReconnectPolicy(), // retries at 300ms, 1s, 3s, 5s, 10s
  connectionTimeout: 10_000,
});

You can write your own policy by implementing the ReconnectPolicy interface.

Error handling

All errors extend RealtalkError:

| Error class | Properties | Description | | ----------------- | --------------------- | --------------------------------------------- | | ConnectionError | reason | WebSocket connection or reconnection failures | | ApiError | statusCode, body? | HTTP errors from token endpoints | | ProtocolError | rawData? | Server-side protocol or backend errors | | ValidationError | — | Invalid arguments or missing configuration |

import { ConnectionError, ValidationError } from "@realtalk-ai/core";

try {
  await transport.connect({ url, token, sdkInfo });
} catch (err) {
  if (err instanceof ConnectionError) {
    console.log(err.reason); // "timeout" | "websocket_failed"
  }
}

Debugging

Logging is silent by default. Turn it on when you need it:

import { setLogLevel } from "@realtalk-ai/core";

setLogLevel("debug"); // "trace" | "debug" | "info" | "warn" | "error" | "silent"

Events

The SDK communicates over WebSocket using typed events. Use onEvent to receive server events and sendEvent to send client events.

Server events (onEvent)

Events received from the server during a conversation:

| Event | EventType constant | Data | Description | | ----------------------- | -------------------------------- | ---------------------------------- | -------------------------------------- | | existing_messages | EventType.ExistingMessages | Message[] | All prior messages, sent on connection | | message_created | EventType.MessageCreated | Message | New message from the agent or user | | message_updated | EventType.MessageUpdated | Message | An existing message was updated | | vad | EventType.Vad | { state: "speech" \| "silence" } | Voice activity detection state changed | | clear | EventType.Clear | — | Audio buffer should be cleared | | conversation_finished | EventType.ConversationFinished | — | The conversation session has ended | | close | EventType.Close | { code: number; reason: string } | WebSocket connection closed | | error | EventType.Error | { message?: string } | A protocol or backend error occurred |

Client events (sendEvent)

Events you can send to the server:

| Event | Payload | Description | | --------- | ------------------------------------ | ---------------------------------- | | message | { type: "message"; data: string } | Send a text message | | dtmf | { event: "dtmf"; data: DTMFDigit } | Send a DTMF tone (0–9, *, #, A–D) |

You can also send arbitrary custom events — any object with a type string field will be forwarded.

API overview

| Export | Description | | ----------------------------- | ------------------------------------------------------------------------------ | | WebSocketTransport | WebSocket connection with status tracking, timeouts, and optional reconnection | | normalizeMessage | Convert a backend message (snake_case) to a typed Message (camelCase) | | sortChronological | Sort messages by createdAt timestamp | | pcmToBase64 / base64ToPcm | PCM audio encoding utilities | | DefaultReconnectPolicy | Configurable retry-delay policy | | RealtalkError | Base error class for all SDK errors | | ConnectionError | WebSocket connection or reconnection failures | | ApiError | HTTP errors from token endpoints | | ProtocolError | Server-side protocol or backend errors | | ValidationError | Invalid arguments or missing configuration | | setLogLevel | Control debug log output | | DEFAULT_WS_URL | Default WebSocket endpoint URL |

Types

All TypeScript types are exported — Message, ConversationEvent, ConnectionStatus, ConversationStatus, and others. See src/types.ts for the full list.

Development

pnpm test         # run tests

License

MIT