For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Log inSign up
Support
GuidesReference
GuidesReference
    • Core
      • Overview
    • Agents
      • Overview
      • AgentBase
      • AgentServer
        • getAgent
        • getAgents
        • getApp
        • register
        • registerGlobalRoutingCallback
        • run
        • serveStaticFiles
        • setupSipRouting
        • unregister
      • Configuration
      • ContextBuilder
      • DataMap
      • FunctionResult
      • Helper Functions & Utilities
      • LiveWire
      • PomBuilder
      • Prefabs
      • SkillBase
      • SkillManager
      • SkillRegistry
      • Skills
      • SwaigFunction
      • SwmlBuilder
      • SWMLService
    • RELAY
      • Overview
      • Actions
      • Call
      • Constants
      • Events
      • Message
      • RelayClient
      • RelayError
    • REST Client
      • Overview
      • Addresses
      • Calling
      • ChatResource
      • Compat
      • Datasphere
      • Fabric
      • ImportedNumbersResource
      • Logs
      • LookupResource
      • MFA
      • Number Groups
      • Phone Numbers
      • Project
      • PubSubResource
      • Queues
      • Recordings
      • Registry
      • RestClient
      • RestError
      • Short Codes
      • SIP Profile
      • Verified Callers
      • Video
LogoLogoSignalWire Docs
Log inSign up
Support
On this page
  • Parameters
  • Returns
  • Example
AgentsAgentServer

serveStaticFiles

|View as Markdown|Open in Claude|
Was this page helpful?
Edit this page
Previous

setupSipRouting

Next
Built with

Serve static files (HTML, CSS, JS, images) from a local directory. Includes path traversal protection, MIME type detection, and security headers (Cache-Control, X-Content-Type-Options).

This method is useful for serving a web frontend alongside your agents — for example, an admin dashboard or a configuration UI.

Parameters

directory
stringRequired

Path to the directory containing static files. Can be absolute or relative (resolved via path.resolve() at registration time).

route
stringDefaults to /

URL path prefix for static files. Trailing slashes are stripped; '/' serves from the root.

Returns

void

Example

1import { AgentBase, AgentServer } from '@signalwire/sdk';
2
3const support = new AgentBase({ name: 'support', route: '/support' });
4support.setPromptText('You are a helpful assistant.');
5
6const server = new AgentServer({ port: 3000 });
7server.register(support);
8server.serveStaticFiles('./web', '/static');
9await server.run();

With this configuration:

Request PathServed By
/supportSupportAgent
/support/swaigSupportAgent SWAIG endpoint
/static/style.css./web/style.css
/static/logo.png./web/logo.png

Path traversal attempts (e.g., /../etc/passwd) are blocked. The resolved file path must remain within the configured static directory.