Install
npm install --global @xsaf/cli@xsaf/cli requires Node.js 22.19 or newer.
Expose streaming chat
Register the authenticated HTTP channel on the server-owned agent:
import { agent } from "@xsaf/agent";
import http from "@xsaf/agent/channel/http";
const bot = agent(config).channel(
http({
path: "/chat",
apiKey: process.env.API_KEY,
}),
);
await bot.start();The channel streams response chunks and tool/delegate lifecycle events over one SSE response. The agent remains entirely inside the server process.
Open the standalone client
API_KEY=asd123 xsaf -u http://localhost:3000The CLI uses API_KEY as a bearer token. It owns stdin and stdout independently from the HTTP server, so server logs and reloads cannot corrupt terminal rendering.
Useful options:
-u, --url XSAF server base URL
-s, --session Session identifier (default: tui)
--name Agent name shown in the terminalThe UI provides a multiline editor, prompt history, Markdown responses, throttled streaming, bounded history, and live tool/delegate statuses.
Embedded rendering
Applications that intentionally run an agent in the terminal process can still use the rendering factory:
import tui from "@xsaf/cli";
const chat = tui({ agent });
chat.start();The controller exposes start(), stop(), submit(), addMessage(), and setStatus() without exposing Pi TUI internals.