Docs · static mirror — the interactive version loads with JavaScript.

@rnsk/tui

Terminal UI for Runstack — chat with your toolkits from the terminal via AI SDK TUI and DefaultChatTransport.

Source: https://runstack.engineer/docs/rnsk-tui

@rnsk/tui is the Runstack terminal app. It renders the same chat you get in the browser — markdown, tool cards, reasoning, approvals — in your terminal via @ai-sdk/tui + DefaultChatTransport. It talks to dedicated TUI endpoints on the Runstack server (POST /api/tui/chat, GET /api/tui/config), so tool execution, OAuth, and secrets stay server-side — the same execution layer as MCP, @rnsk/bot and @rnsk/tools. /api/bot/* is kept for backwards-compat.

Install

npm i -g @rnsk/tui
# now `rnsk` is on your PATH
rnsk --help

Or run without installing:

npx @rnsk/tui --help

Peer: Node ^20 or ^22+ recommended. The package ships dist/cli.js as bin: rnsk.

Auth — paste-only

Create an API key (rnsk_…) at https://runstack.engineer → Settings → Workspace → API Keys (API Keys).

rnsk auth login
# Paste your Runstack API key (rnsk_…): rnsk_…
# Validating against https://app.runstack.engineer ...
# ✔ Authenticated — key rnsk_abc… saved.

Keys are stored in ~/.config/rnsk/config.json (0600, respects XDG_CONFIG_HOME, legacy ~/.rnsk/config.json also read) or via RNSK_API_KEY env. Validation hits GET /api/tui/config with Authorization: Bearer rnsk_….

One-off without saving:

RNSK_API_KEY=rnsk_… rnsk chat

Chat

rnsk chat
rnsk chat --toolkit github --toolkit notion
rnsk chat --agent agent_abc123 --title "Support Agent"
rnsk chat --system-prompt "Be concise"
FlagDescription
--api-base <url>Override API base (default https://app.runstack.engineer)
--api-key <key>Override API key for this run
--agent <id>Scope to Studio agent (repeatable, same ids as @rnsk/bot)
--toolkit <id>Scope to toolkit ids (same as @rnsk/toolkits, e.g. github, gmail)
--system-prompt <text>Extra system instructions
--title <text>TUI header title (default Runstack)

Controls

From @ai-sdk/tui: Enter submit, y/n approve tools, ↑/↓ and PgUp/PgDn scroll, Ctrl+L repaint, Esc/Ctrl+C exit.

Connecting toolkits in the terminal

When a tool needs OAuth, the assistant calls initiateConnection and the tool output contains a connection URL. Open it in your browser, connect the provider, then type connected in the TUI and re-ask.

Programmatic

Use the package as a library with runAgentTUI:


await runRunstackTUI({ apiKey: "rnsk_…", toolkitIds: ["github"] })

// custom
const transport = createRunstackTransport({ apiKey: "rnsk_…", agentIds: ["agent_xxx"] })
await runAgentTUI({ title: "Runstack", transport })

How it works

  • DefaultChatTransport → POST {apiBase}/api/tui/chat with Authorization: Bearer rnsk_… + {messages: UIMessage[], agentIds?, toolkitIds?, systemPrompt?}.
  • Server creates a ToolLoopAgent with searchTool/checkAuthentication/initiateConnection/executeTool and streams back UIMessage chunks via pipeUIMessageStreamToResponse.
  • runAgentTUI renders markdown, tool cards, reasoning, and approvals. No browser needed.

/api/bot/* uses the same handler and is kept for existing widget installs — prefer /api/tui/* for terminal use.

Troubleshooting

SymptomFix
Missing API keyrnsk auth login or RNSK_API_KEY=… rnsk chat
401Key invalid — recreate at https://runstack.engineer → Settings → Workspace → API Keys
429Usage limit — upgrade plan (see API Keys)
Network errorCheck apiBase reachable: curl -H "Authorization: Bearer rnsk_…" https://app.runstack.engineer/api/tui/config
Tool keeps asking to connectComplete OAuth in browser, then retry the same prompt

Related

SurfaceBest for
@rnsk/tuiTerminal chat (this page)
@rnsk/botEmbeddable React widget
@rnsk/toolsAI SDK apps in Node/Edge
@rnsk/mcpstdio bridge for Cursor, Claude Desktop, etc.
MCP ToolsRemote HTTP /mcp