tui-use

v1.1.0
io.github.pavanmanishd/tui-use Checked 8 hours ago Published 9 days ago

Drive interactive terminal programs (vim, git rebase -i, ssh, REPLs, htop) from an agent.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

tui_start

Start an interactive program (vim, git rebase -i, npm init, ssh, python, psql, htop, an installer...) in a real terminal and return its screen. Use this instead of the shell tool whenever a command prompts for input, opens an editor or pager, or draws a full-screen UI. The session stays open across calls; drive it with tui_send.

ParameterTypeDescription
command *stringCommand line, run through your shell.
colsintegerTerminal width, default 120.
cwdstringWorking directory. Defaults to the server's cwd.
envobjectExtra environment variables.
namestringOptional name to refer to the session by.
rowsintegerTerminal height, default 40.
waitobjectWhen to return. Conditions are OR-ed. Without one, the tool waits until the screen stops changing (300 ms quiet), which is fine for most steps; use text/regex/gone for slow programs.

tui_send

Type into a session, wait for it to respond, and return the new screen (as a diff by default). The screen shows row numbers, the cursor as [x], and highlighted items as «…». text is typed first, then secret_env, then keys. Use input for interleaving, e.g. save and quit vim: input=[{key:'esc'},{text:':wq'},{key:'enter'}]. Edits that depend on where the cursor lands can go wrong when batched; prefer commands that do not (e.g. vim :2,3s/^pick/squash/) or check the screen between steps. Key names: enter, tab, esc, backspace, delete, up, down, left, right, home, end, pageup, pagedown, space, f1…

ParameterTypeDescription
session *stringSession id (s1) or the name given to tui_start.
inputarrayOrdered mix of text, keys, secrets and mouse events. When given, text/keys/secret_env are ignored. A mouse event clicks or scrolls at a screen row and column as numbered in the snapshot, e.g. {mouse:{…
keysarrayKeys pressed after text, in order.
modestringDefault diff.
pastebooleanSend text as a bracketed paste: use for multi-line input into editors and REPLs.
secret_envstringName of an environment variable of the tui-use server whose value is typed (e.g. a password). The value never appears in responses or recordings.
textstringText typed literally. \n is sent as Enter.
waitobjectWhen to return. Conditions are OR-ed. Without one, the tool waits until the screen stops changing (300 ms quiet), which is fine for most steps; use text/regex/gone for slow programs.

tui_snapshot

Return the current screen of a session without sending input. Use image: true to also get a PNG of the screen with its colours, for when layout or colour matters more than text.

ParameterTypeDescription
session *stringSession id (s1) or the name given to tui_start.
imagebooleanAlso return a PNG screenshot of the screen.
modestringDefault full.
stylesstringmarks (default) wraps highlighted text such as the selected menu item in «…».

tui_wait

Wait without sending input, for slow work like builds, installs and downloads, then return the screen. Prefer text/regex/gone conditions with a generous timeout_ms.

ParameterTypeDescription
session *stringSession id (s1) or the name given to tui_start.
wait *objectWhen to return. Conditions are OR-ed. Without one, the tool waits until the screen stops changing (300 ms quiet), which is fine for most steps; use text/regex/gone for slow programs.
modestringDefault diff.

tui_scrollback

Read output that scrolled off the screen. Pass lines=[from, to] (1-based, negative counts from the end, e.g. [-50, -1]) or search='text' for matching lines with 2 lines of context. Defaults to the last 40 lines.

ParameterTypeDescription
session *stringSession id (s1) or the name given to tui_start.
linesarray
searchstring

tui_manage

Session housekeeping. action=list shows all sessions; kill ends one (signal defaults to SIGTERM, then SIGKILL after 2 s); resize changes its size; recording returns the path of its asciinema recording.

ParameterTypeDescription
action *string
colsintegerFor resize.
rowsintegerFor resize.
sessionstringRequired for kill, resize and recording.
signalstringFor kill, e.g. SIGINT or SIGKILL.