How it works
terminal.config() spawns the standalone tuichat binary as a subprocess and drives it over JSON-RPC. The binary auto-downloads from GitHub Releases the first time you run it.
In a TTY it boots the rich UI. In a non-TTY context, such as CI or piped input, it falls back to a synchronous readline loop, so the same agent code works for scripted integration tests.
Config
| Option | Type | Default | Description |
|---|---|---|---|
commands | { name: string; description?: string }[] | [] | Slash commands surfaced in the TUI’s command picker. Names must match /^\/[A-Za-z0-9_-]+$/. |
for await loop the same way you’d handle any text.
Working with multiple spaces
By default the TUI starts onchat-1. New chats opened with Ctrl+N get chat-2, chat-3, and so on. To open a named space programmatically, pass an id:
space.get() ensures the chat exists in the sidebar. This is useful for kicking off a conversation before any user input.
When to use it
- Iterating on agent logic: every Spectrum API works exactly as it would in production, so behavior you build here ships unchanged.
- Integration tests: pipe stdin in non-TTY mode and assert on stdout. CI does not need a TUI.
- CLI tools: use the same handler shape as any multi-platform deployment, with reactions and replies as first-class events.