register

View as MarkdownOpen in Claude

Register an AgentBase instance at a URL route on the server. The agent’s Hono app is mounted at the specified prefix so all of its endpoints (SWML, SWAIG, debug, post-prompt) become available under that path.

Throws Error if the route is already occupied by another agent.

Parameters

agent
AgentBaseRequired

The agent instance to register.

route
string

URL path prefix for this agent (e.g., "/sales"). If omitted, the agent’s own route property is used. Leading slashes are added and trailing slashes are stripped automatically.

Returns

void

Example

1import { AgentBase, AgentServer } from '@signalwire/sdk';
2
3const salesAgent = new AgentBase({ name: 'sales-agent', route: '/sales' });
4salesAgent.promptAddSection('Role', { body: 'You are a sales rep.' });
5
6const server = new AgentServer({ port: 3000 });
7server.register(salesAgent, '/sales');
8await server.run();