agentknit-tui
A Textual TUI front-end for agentknit coding agents.
Features:
- one always-visible conversation pane
- a multiline prompt at the bottom,
- tool calls / results / token accounting rendered inline
- a live status bar.
the TUI is a pure subscriber to the event stream from agentknit.
Install
pip install agentknit-tui
It depends on agentknit, textual, and rich.
Usage
agentknit-tui # default: glm-5.2 via z.ai
agentknit-tui glm-5.2
agentknit-tui "qwen3-8b" "https://openrouter.ai/api/v1"
agentknit-tui --session <id> # resume a previous trajectory
agentknit-tui --non-interactive # drop ask_user* tools from the schema
agentknit-tui --no-strict-cache-proof
Key bindings
| key | action |
|---|---|
Enter |
submit the prompt |
Shift/Ctrl/Alt+Enter |
insert a newline |
↑ / ↓ |
recall past prompts (same folder, shared with the REPL) |
Esc / Ctrl+C |
cancel the running turn (or quit when idle) |
Ctrl+Shift+C |
copy the mouse selection in the log |
Ctrl+L |
clear the on-screen conversation log only |
Mouse
- Drag over the conversation log selects text in place (highlighted as
you drag);
Ctrl+Shift+Cthen copies the selection (plainCtrl+Calso works when your terminal delivers it).Escclears the selection. - Paste into the prompt with the terminal's own paste (
Ctrl+Shift+V,Shift+Insert, or middle-click) —Ctrl+Vinside the TUI only reads text copied within the TUI. - Copying tries the platform clipboard tool first (
xclip/xsel,wl-copy,pbcopy,clip.exe) and also emits OSC 52; one of the two reaches the system clipboard even in VTE terminals that ignore OSC 52 (Terminator, older gnome-terminal). - Copying out of a bordered block (your prompt, replies, tool output) strips
the Rich panel chrome first, so the clipboard gets the payload text — no
leading
│gutter, no border rows.
Ctrl+L (and the TUI's built-in /clear alias) wipes the displayed log
and zeroes the token counters in the status bar; the agent's message
history — the context sent to the model — is untouched, and /usage
still reports the session's full totals.
Status bar
The line under the prompt shows the model, session id, token usage, and —
while a turn is running — the task the agent is working on, wrapped over
two terminal-width lines so long prompts stay readable.
To reset the LLM context (session history, keeping the system prompt), run
/reset-context in the TUI; it forwards to agentknit's /clear handler.
Slash commands (/help, /usage, /clear, /compact, /model, /reset-context, /exit)
are forwarded to agentknit's command registry; their printed output is
captured and shown inline.
On exit the TUI prints the command to resume the session on the console, exactly like the end of the agentknit REPL:
Resume: agentknit-tui glm-5.2 --session <session-id>
Set AGENTKNIT_RESUME_COMMAND to override the program prefix (wrappers
embedding the model already do this); the --session <id> suffix is always
appended.
Design notes
- The agent loop (
agentknit.run_turn) is synchronous and blocking and emits typed events through a sessionon_eventcallback. The TUI runs each turn in a Textual worker thread and forwards every event onto a thread-safe queue; a 50 ms UI-thread timer drains the queue and renders each event's pre-formatted ANSI string into a Rich renderable. - agentknit's
fmtstrings are raw\033[…]ANSI escapes (not Rich markup), so they are decoded withrich.ansi.AnsiDecoderfor faithful colour/style reproduction. - Multi-line input uses
TextArea, so users can paste and edit freely. ACancelTokenis wired to the cancel bindings so a turn can be interrupted cooperatively, exactly like Ctrl+C in the REPL. - Prompt history is per-folder and shared with the REPL: both read and
write agentknit's readline history file
(
~/.local/share/agent_probe/repl_history/<md5(cwd)>.hist), so arrow-up recalls instructions typed in either front-end, scoped to the folder they were typed in.↑on the first prompt line walks back,↓forward, and any edit drops back to normal typing. - On exit the TUI mirrors the REPL's teardown: the trajectory snapshot is
saved (if the session has any messages), a
session_endrecord is appended to the session log, and — after Textual restores the plain console — the same dimResume: …line the REPL prints is echoed so the session can be continued with--session <id>. - agentknit installs a module-level SIGINT handler (meant for the
foreground REPL) that kills the active tool subprocess. The TUI
neutralises it for each turn's duration and drives cancellation through
the
CancelTokeninstead.
License
MIT.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agentknit_tui-0.3.0-py3-none-any.whl.
File metadata
- Download URL: agentknit_tui-0.3.0-py3-none-any.whl
- Upload date:
- Size: 23.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe3fcfbd2171dbd69d9e2ab63ff649698236bb0d358cd9b65ca5f350f24a2366
|
|
| MD5 |
b31dc3a29f0b66453347f441d7284711
|
|
| BLAKE2b-256 |
ebd53972d14e2ec3e732b4d95a83a4dea0dfae9d68f50d4434a3cf9f81b5bac2
|
Provenance
The following attestation bundles were made for agentknit_tui-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on monperrus/agentknit-tui
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agentknit_tui-0.3.0-py3-none-any.whl -
Subject digest:
fe3fcfbd2171dbd69d9e2ab63ff649698236bb0d358cd9b65ca5f350f24a2366 - Sigstore transparency entry: 2514477103
- Sigstore integration time:
-
Permalink:
monperrus/agentknit-tui@dd648f68bcd46d7c4ce7dc5dde9735a2f32ade2c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/monperrus
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@dd648f68bcd46d7c4ce7dc5dde9735a2f32ade2c -
Trigger Event:
push
-
Statement type: