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

@ajentify/voice

v0.5.0

Published

Thin React + WebRTC transport for realtime voice conversations with an Ajentify agent.

Downloads

263

Readme

@ajentify/voice

Thin React + WebRTC transport for talking to an Ajentify agent by voice.

The default (and recommended) transport is realtime: the SDK opens a WebSocket to the Ajentify connect server, negotiates a WebRTC session with the OpenAI realtime API through it, and streams your microphone in / the agent's voice out. It keeps only a minimal transcript (messages) and exposes the raw JSON-RPC events so you can shape your own UI.

Install

pnpm add @ajentify/voice

react and react-dom are peer dependencies.

Usage

import {
  AjentifyVoiceProvider,
  useRealtimeSession,
  useRealtimeEvent,
} from '@ajentify/voice';

function App() {
  return (
    <AjentifyVoiceProvider>
      <Call />
    </AjentifyVoiceProvider>
  );
}

function Call() {
  const initialize = useRealtimeSession((s) => s.initialize);
  const disconnect = useRealtimeSession((s) => s.disconnect);
  const toggleMute = useRealtimeSession((s) => s.toggleMute);
  const isConnected = useRealtimeSession((s) => s.isConnected);
  const messages = useRealtimeSession((s) => s.messages);

  useRealtimeEvent('on_agent_transcript', ({ transcript }) => {
    console.log('agent said:', transcript);
  });

  return (
    <>
      <button onClick={() => initialize('my-context-id', 'my-access-token')}>Start</button>
      <button onClick={() => disconnect()}>Stop</button>
      <button onClick={() => toggleMute()}>Mute</button>
      <p>{isConnected ? 'connected' : 'not connected'}</p>
      <ul>
        {messages.map((m) => (
          <li key={m.ts}>{m.role}: {m.text}</li>
        ))}
      </ul>
    </>
  );
}

contextId and accessToken come from the Ajentify API: create a context for your agent, then mint a client-scoped API key for it.

Provider config

interface AjentifyVoiceConfig {
  mode?: 'realtime' | 'agentRoom'; // default: 'realtime'
  tokenStreamingServerUrl?: string; // default: wss://connect.ajentify.com  (SDK appends /ws-realtime)

  // Legacy `agentRoom` mode only:
  signalingServerUrl?: string;      // default: wss://room-signaling-server.prod.rooms.ajentify.com
  agentServerUrl?: string;          // default: https://agent.ajentify.com
}

URLs only — no callbacks. The provider builds the stores once on mount and tears them down on unmount. Only the store for the selected mode is created, so the other transport is never contacted.

Realtime events

Subscribe with useRealtimeEvent(name, handler) or realtimeStore.getState().on(name, handler).

| Event | Payload | |---|---| | on_user_transcript | { transcript } — a completed user utterance | | on_agent_transcript | { transcript } — a completed agent response | | on_tool_call | { tool_call_id, tool_name, tool_input } | | on_tool_response | { tool_call_id, tool_name, tool_output } | | on_client_side_tool_calls | { tool_calls: ClientSideToolCall[] } |

Client-side tools

on_client_side_tool_calls is a notification. Run your handlers and send the results back over the same connection:

const realtime = useRealtimeStore();

useRealtimeEvent('on_client_side_tool_calls', async ({ tool_calls }) => {
  const tool_responses = await Promise.all(
    tool_calls.map(async (c) => ({
      tool_call_id: c.tool_call_id,
      response: await myTools[c.tool_name](c.tool_input),
    })),
  );
  await realtime.getState().send('client_side_tool_responses', { tool_responses }, true);
});

Public API

  • AjentifyVoiceProvider, AjentifyVoiceContext
  • useAjentifyVoiceStores(), useAjentifyVoiceConfig()
  • useRealtimeSession(selector), useRealtimeStore(), useRealtimeEvent(eventName, handler)
  • useMediaDevices(selector), useMediaDevicesStore()
  • monitorMicStream, monitorInboundMediaStream — Web Audio helpers for level animation
  • RealtimeEvents, RealtimeEventName, RealtimeMessage, ClientSideToolCall, ClientSideToolResponse
  • DEFAULT_TOKEN_STREAMING_SERVER_URL, DEFAULT_VOICE_MODE

Legacy: room transport (mode: 'agentRoom')

The original multi-peer flow — a signaling WebSocket, a WebRTC room, and an agent invited via the agent server's /invite-agent. It is kept in the package but is not the default and requires you to host the signaling and agent servers yourself.

<AjentifyVoiceProvider config={{ mode: 'agentRoom', signalingServerUrl, agentServerUrl }}>

Hooks: useAgentRoom(selector), useAgentRoomStore(), useAgentRoomEvent(eventName, handler); typed events in AgentDataChannelEvents. Client-side tool responses go via agentRoom.send('client_side_tool_responses', { tool_responses }). See examples/react-vite for a working client.