@sisu-ai/server
v8.0.0
Published
Serve Sisu agents over HTTP/HTTPS with a thin, framework-friendly server adapter.
Downloads
406
Readme
@sisu-ai/server
Serve Sisu agents over HTTP/HTTPS with a thin, framework-friendly server adapter.
Setup
npm i @sisu-ai/serverUsage
import { Agent } from '@sisu-ai/core';
import { Server } from '@sisu-ai/server';
import { agentRunApi } from '@sisu-ai/mw-agent-run-api';
const app = new Agent().use(agentRunApi());
const server = new Server(app, {
port: 3000,
// Optional banner (enabled by default). Add endpoints to list them.
bannerEndpoints: [
'POST /api/runs/start',
'GET /api/runs/:id/status',
'GET /api/runs/:id/stream',
'POST /api/runs/:id/cancel',
],
createCtx: (req, res) => ({ req, res, messages: [], signal: new AbortController().signal })
});
server.listen();Options
- port/host/backlog/path/tls: standard Node listen options.
- basePath: base URL path for your agent routes. Default:
/api. - healthPath: health endpoint or
falseto disable. Default:/health. - createCtx(req, res): build your per-request context;
Serverinjectsagentand a defaultlogif missing. - logBanner: print a startup banner. Default:
true. - bannerEndpoints: string lines printed under the banner (e.g.,
GET /api/runs/:id/status). - logLevel:
'debug' | 'info' | 'warn' | 'error'; sets the default console logger level. - logger: provide a custom logger implementing Sisu
Logger. - redactLogKeys: additional keys to redact in logs (merged with built-ins).
Request Logging
The server emits basic structured logs for every request and response using the default logger (or your logger).
- Request:
[server] request { method, url } - Response:
[server] response { method, url, status, duration_ms }
Control verbosity via logLevel or LOG_LEVEL.
Events API
Subscribe to server lifecycle and per-request events without using the listen callback.
const server = new Server(app, { port: 3000 });
server
.on('listening', ({ url }) => {
console.log('ready at', url);
})
.on('request', ({ method, url }) => {
// e.g., metrics, audit
})
.on('response', ({ method, url, status, duration_ms }) => {
// e.g., record duration_ms to your metrics system
})
.on('error', (err) => {
console.error('server error', err);
})
.on('close', () => {
console.log('server closed');
});
server.listen();Features
- Health endpoint (
/healthby default) - Attach to existing
http/httpsserver or listen directly - Supports TLS and UNIX sockets
- Injects the agent into each request context so middleware can spawn runs
- Startup banner: prints listen address, health path, base path, and optional endpoints
- Request logs: per-request/response lines, redaction support
- Events API:
listening,request,response,error,close
Community & Support
Discover what you can do through examples or documentation. Check it out at https://github.com/finger-gun/sisu. Example projects live under examples/ in the repo.
Documentation
Core — Package docs · Error types
Adapters — OpenAI · Anthropic · Ollama
- @sisu-ai/mw-agent-run-api
- @sisu-ai/mw-context-compressor
- @sisu-ai/mw-control-flow
- @sisu-ai/mw-conversation-buffer
- @sisu-ai/mw-cors
- @sisu-ai/mw-error-boundary
- @sisu-ai/mw-guardrails
- @sisu-ai/mw-invariants
- @sisu-ai/mw-orchestration
- @sisu-ai/mw-rag
- @sisu-ai/mw-react-parser
- @sisu-ai/mw-register-tools
- @sisu-ai/mw-tool-calling
- @sisu-ai/mw-trace-viewer
- @sisu-ai/mw-usage-tracker
- @sisu-ai/tool-aws-s3
- @sisu-ai/tool-azure-blob
- @sisu-ai/tool-extract-urls
- @sisu-ai/tool-github-projects
- @sisu-ai/tool-rag
- @sisu-ai/tool-summarize-text
- @sisu-ai/tool-terminal
- @sisu-ai/tool-web-fetch
- @sisu-ai/tool-web-search-duckduckgo
- @sisu-ai/tool-web-search-google
- @sisu-ai/tool-web-search-openai
- @sisu-ai/tool-wikipedia
Anthropic — hello · control-flow · stream · weather
Ollama — hello · stream · vision · weather · web-search
OpenAI — hello · weather · stream · vision · reasoning · react · control-flow · branch · parallel · graph · orchestration · orchestration-adaptive · guardrails · error-handling · rag-chroma · web-search · web-fetch · wikipedia · terminal · github-projects · server · aws-s3 · azure-blob
Contributing
We build Sisu in the open. Contributions welcome.
Contributing Guide · Report a Bug · Request a Feature · Code of Conduct
Star on GitHub if Sisu helps you build better agents.
Quiet, determined, relentlessly useful.
