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

agent-server-sdk

v1.0.1

Published

[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2FShengwang-Community%2Fagent-server-sdk-ts)

Downloads

230

Readme

Agent Server SDK for TypeScript

fern shield npm shield

Conversational AI SDK for TypeScript, enabling you to build voice-powered AI agents with support for cascading flows (ASR -> LLM -> TTS) using domestic (China) vendors.

Installation

npm i -s agent-server-sdk

Quick Start

Use the builder pattern with Agent and AgentSession:

import {
  AgentClient,
  Area,
  Agent,
  ExpiresIn,
  AliyunLLM,
  MiniMaxTTS,
  FengmingSTT,
} from 'agent-server-sdk';

const client = new AgentClient({
  area: Area.CN,
  appId: 'your-app-id',
  appCertificate: 'your-app-certificate',
});

const agent = new Agent({
  name: 'support-assistant',
  instructions: '你是一个有用的语音助手。',
  greeting: '你好!有什么可以帮助你的?',
  maxHistory: 10,
})
  .withStt(new FengmingSTT({ language: 'zh-CN' }))
  .withLlm(new AliyunLLM({
    url: 'https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions',
    apiKey: 'your-aliyun-key',
    model: 'qwen-max',
  }))
  .withTts(new MiniMaxTTS({
    key: 'your-minimax-key',
    model: 'speech-01-turbo',
    voiceSetting: { voice_id: 'male-qn-qingse' },
  }));

const session = agent.createSession(client, {
  channel: 'support-room-123',
  agentUid: '1',
  remoteUids: ['100'],
  idleTimeout: 120,
  expiresIn: ExpiresIn.hours(12),
});

const agentSessionId = await session.start();
await session.stop();

Session lifecycle

start() joins the agent to the channel and returns a session ID. The session stays active until stop() is called.

Option 1 — Hold the session in memory:

const agentSessionId = await session.start();
await session.stop();

Option 2 — Store the session ID and stop by ID (stateless servers):

const agentSessionId = await session.start();
res.json({ agentSessionId });

// stop-session handler
const client = new AgentClient({
  area: Area.CN,
  appId: '...',
  appCertificate: '...',
});
await client.stopAgent(agentSessionId);

Supported Vendors

LLM

  • AliyunLLM — Alibaba Cloud (Qwen)
  • BytedanceLLM — Volcengine (Doubao)
  • DeepSeekLLM — DeepSeek
  • TencentLLM — Tencent (Hunyuan)
  • CustomLLM — Custom LLM endpoint

TTS

  • MiniMaxTTS — MiniMax
  • TencentTTS — Tencent Cloud
  • BytedanceTTS — Volcengine
  • MicrosoftTTS — Microsoft Azure
  • CosyVoiceTTS — Alibaba Cloud CosyVoice
  • BytedanceDuplexTTS — Volcengine Duplex Streaming
  • StepFunTTS — StepFun

STT

  • FengmingSTT — Fengming ASR
  • TencentSTT — Tencent Cloud ASR
  • MicrosoftSTT — Microsoft Azure Speech
  • XfyunSTT — iFlytek traditional ASR
  • XfyunBigModelSTT — iFlytek Big Model ASR
  • XfyunDialectSTT — iFlytek Dialect ASR

Avatar

  • SensetimeAvatar — Sensetime digital human

Documentation

API reference documentation is available here.

Reference

A full reference for this library is available here.

Exception Handling

import { AgoraError } from "agent-server-sdk";

try {
    await client.agents.start(...);
} catch (err) {
    if (err instanceof AgoraError) {
        console.log(err.statusCode);
        console.log(err.message);
        console.log(err.body);
    }
}

Contributing

While we value open-source contributions to this SDK, this library is generated programmatically. Additions made directly to this library would have to be moved over to our generation code, otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!