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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@trillet-ai/web-sdk

v1.5.8

Published

Trillet Web SDK for real-time audio communication with AI agents

Readme

Trillet AI Web Calls SDK

The Trillet AI Web Calls SDK enables seamless integration of AI-powered voice and text interactions into web applications. This SDK provides a simple interface to connect with Trillet AI agents for real-time communication.

Features

  • 🎙️ Real-time voice interactions with AI agents
  • 💬 Text-based conversations
  • 🔒 Secure authentication options
  • 📊 Audio visualization capabilities
  • 🎯 Event-driven architecture
  • 🔄 Real-time transcription
  • 🌐 Browser compatibility checks

Installation

npm install @trillet-ai/web-sdk
# or
yarn add @trillet-ai/web-sdk

Quick Start

import { TrilletAgent } from '@trillet-ai/web-sdk';

// Initialize the agent with API Key (Standard Method)
const agent = new TrilletAgent({
  apiKey: 'your-api-key',
  workspaceId: 'your-workspace-id',
  agentId: 'your-agent-id',
  mode: 'voice', // 'voice' or 'text'

  // Optional parameters
  variables: {
    customVar1: 'value1',
    customVar2: 'value2'
  },
  callbackUrl: 'https://your-callback-url.com'
});

// Start a regular call
await agent.startCall();

// Or start a public call
await agent.startPublicCall();

// Listen for events
agent.on('connected', (details) => {
  console.log('Connected to call:', details);
});

agent.on('transcriptionReceived', (transcript) => {
  console.log('New voice transcript:', transcript);
});

agent.on('message', (message) => {
    console.log('New text message from agent:', message);
});

agent.on('transcriptUpdate', (transcripts) => {
    console.log('Transcript updated:', transcripts);
});

// Control the call
agent.toggleMicrophone(true); // Enable/disable microphone in voice mode
agent.sendTextMessage("Hello, agent!"); // Send a text message in text mode
agent.endCall(); // End the call

Authentication

The SDK supports two authentication methods:

  1. API Key Authentication (Standard Method)

    const agent = new TrilletAgent({
      apiKey: 'your-api-key',
      workspaceId: 'your-workspace-id',
      agentId: 'your-agent-id'
    });
  2. Public Access

    • For public-facing applications
    • Uses startPublicCall() method
    const agent = new TrilletAgent({
      workspaceId: 'your-workspace-id',
      agentId: 'your-agent-id',
      mode: 'text' // Or 'voice'
    });
    await agent.startPublicCall();

Call Types

The SDK supports two types of calls:

  1. Regular Call - Using startCall()

    • Requires full authentication with API Key
    • Suitable for authenticated users
  2. Public Call - Using startPublicCall()

    • Requires workspace ID and agent ID
    • Suitable for public-facing applications
    • No API key needed in client-side code
    • Example:
      const agent = new TrilletAgent({
        workspaceId: 'your-workspace-id',
        agentId: 'your-agent-id',  // Required for both public and regular calls
        mode: 'text' // Or 'voice'
      });
      await agent.startPublicCall();

Events

The SDK emits various events that you can listen to:

agent.on('connected', (details) => {
  // Called when successfully connected to a call
});

agent.on('disconnected', () => {
  // Called when the call ends
});

agent.on('error', (error) => {
  // Called when an error occurs
});

agent.on('transcriptionReceived', (segments, participant) => {
  // Called when new transcription is available (voice mode)
});

agent.on('assistantStartedSpeaking', () => {
  // Called when the AI agent starts speaking (voice mode)
});

agent.on('assistantStoppedSpeaking', () => {
  // Called when the AI agent stops speaking (voice mode)
});

agent.on('audioData', (data) => {
  // Raw audio data for visualization (voice mode)
});

agent.on('message', (message) => {
    // Called when a text message is received from the agent (text mode)
});

agent.on('transcriptUpdate', (transcripts) => {
    // Called whenever the transcript is updated (voice or text)
});

Voice Mode Features

When using voice mode, the SDK provides additional audio-related features:

// Check if the assistant is currently speaking
const isSpeaking = agent.isAssistantSpeaking;

// Access transcripts
const allTranscripts = agent.getTranscripts();
const currentTranscript = agent.getCurrentTranscript();

Text Mode Features

When using text mode, you can send and receive text messages.

// Send a message to the agent
agent.sendTextMessage("Hello, how are you?");

// Listen for messages from the agent
agent.on('message', (message) => {
  console.log('Agent says:', message.text);
});

// The full conversation transcript is available for both modes
const fullConversation = agent.getTranscripts();
console.log(fullConversation);

Requirements

  • Modern web browser with secure context (HTTPS or localhost)
  • WebRTC support
  • Microphone access (for voice mode)

Browser Support

The SDK is compatible with modern browsers that support WebRTC:

  • Chrome (recommended)
  • Firefox
  • Safari
  • Edge

Error Handling

The SDK includes comprehensive error handling:

agent.on('error', (error) => {
  console.error('Trillet SDK Error:', error);
});

License

[License details here]

Support

For support, please contact [support contact information].