AgentServer

View as MarkdownOpen in Claude

AgentServer hosts multiple AgentBase instances on a single Hono HTTP server. Each agent registers at its own URL route, and the server provides unified health monitoring and static file serving. Use AgentServer when you have several related agents (sales, support, billing) that share the same deployment.

For a single agent, use AgentBase.serve() or AgentBase.run() instead.

Constructor

1import { AgentServer } from '@signalwire/sdk';
2
3const server = new AgentServer({ host: '0.0.0.0', port: 3000 });

Constructor Parameters

opts
object

Optional server configuration.

opts.host
stringDefaults to 0.0.0.0

Hostname the server binds to.

opts.port
numberDefaults to 3000

Port the server listens on. Also reads from the PORT environment variable.

Properties

host
string

The hostname the server binds to.

port
number

The port the server listens on.

Methods

Example

1import { AgentBase, AgentServer } from '@signalwire/sdk';
2
3const salesAgent = new AgentBase({ name: 'sales-agent', route: '/sales' });
4salesAgent.addLanguage({ name: 'English', code: 'en-US', voice: 'rime.spore' });
5salesAgent.promptAddSection('Role', { body: 'You are a sales representative.' });
6
7const supportAgent = new AgentBase({ name: 'support-agent', route: '/support' });
8supportAgent.addLanguage({ name: 'English', code: 'en-US', voice: 'rime.spore' });
9supportAgent.promptAddSection('Role', { body: 'You are a support specialist.' });
10
11const server = new AgentServer({ host: '0.0.0.0', port: 3000 });
12server.register(salesAgent, '/sales');
13server.register(supportAgent, '/support');
14await server.run();

After starting, agents are available at:

EndpointDescription
http://localhost:3000/salesSales agent
http://localhost:3000/supportSupport agent
http://localhost:3000/healthHealth check
http://localhost:3000/readyReadiness check