Skip to navigation

Start the HTTP server and begin listening for requests. Uses @hono/node-server to serve the Hono application with all registered agents. Handles server mode only — for serverless deployments (AWS Lambda, Google Cloud Functions, Azure Functions), use ServerlessAdapter instead.

Set SWML_SSL_ENABLED, SWML_SSL_CERT_PATH, and SWML_SSL_KEY_PATH to serve HTTPS; webhook URLs then use https, on SWML_SSL_DOMAIN when it’s set. When the certificate or key file is missing, it warns and serves HTTP. See environment variables.

Parameters

host
string

Override the configured hostname.

port
number

Override the configured port.

Returns

Promise<void> — Resolves after starting the HTTP server.

For custom server setups — such as embedding the agents into an existing Hono application — use getApp() to retrieve the underlying Hono app and pass its fetch handler to your own @hono/node-server serve() call instead of using run().

When the environment variable SWAIG_CLI_MODE=true is set (used by the swaig-test CLI tool), run() returns immediately without starting the server so only the agent configuration is loaded.

Example

import { AgentBase, AgentServer } from '@signalwire/sdk';
const agent = new AgentBase({ name: 'my-agent', route: '/agent' });
agent.setPromptText('You are a helpful assistant.');
const server = new AgentServer({ host: '0.0.0.0', port: 3000 });
server.register(agent);
await server.run();