a2a_send posts SendMessage with a text part and, when a path is given, a file part: base64 bytes, a name (the path's last component) and a media type guessed from the name, at most 8 MiB -- the same cap the server enforces on the way in. The answer is text; a file the other side sends back is saved by collect_parts and named by path, which the tool returns. sp_b64_encode is the missing direction of the base64 helper, with vectors of its own in test_b64: empty input, one and two trailing bytes, a NUL. test_a2a: a real PNG is attached, the request carries name, mimeType and the base64 bytes, and the other side names it in the answer; a missing path is an error, not a silent empty message.
splinter
Named after Master Splinter: the one who knows which tools exist, who may use them, and what happened — and trains the ones that do the fighting.
A C99/POSIX agent harness with a curses interface: chat on three quarters of the screen, a sidebar on one quarter, plugins that can put tools and widgets into both.
make # libsplinter.so, the binary, the plugins
make check # every test binary (35), no network, no model
splinter # starts the chat from ~/.config/splinter/config
What it does
splinter -p "list the C files" --endpoint http://127.0.0.1:8080/turn sends a
prompt, runs the tools the transport asks for, and prints the answer. Every turn
is appended to ~/.splinter/<id>.jsonl as one JSON object per line.
What it refuses to do
- Send a request that exceeds the configured byte budget (nothing is sent; the turn fails instead of letting an endpoint truncate silently).
- Run a tool that is not in the registry (the model is told, not guessed at).
- Run a mutating or destructive tool without operator consent, unless
--autonomouswas given. - Skip a denial silently: the denial becomes the observation the model sees.
Protocol
The harness speaks a line protocol with its transport, not a vendor API:
request user <text>
request observe <tool> <output>
reply answer <text>
reply tool <name> <arguments>
A provider adapter translates an OpenAI-compatible endpoint into this shape and
back. That is why make check needs no network, no key and no model: the mock
transport replays replies.
Layout
libsplinter.so every symbol, once; binary and plugins link to it
include/splinter.h the core interface
include/splinter_plugin.h plugin ABI and host API
src/plugin.c dlopen loader, widget registry, worker threads
src/conv.c the conversation (owned messages, no sharing)
src/openai.c request shaping + reply parsing, pure functions
src/transport_openai.c HTTP to /v1/chat/completions via curl(1)
src/json.c libmcp's JSON, instantiated once
src/ui.c curses UI: chat 3/4, sidebar 1/4, status bar
src/md.c markdown tables as aligned text
src/theme.c CDE palettes -> terminal colours
src/palettes.c generated from CDE's *.dp files
tools/genpalettes.py the generator
plugins/clock/ example plugin: sidebar clock + a tool
vendor/netbsd-curses/ NetBSD curses and terminfo, vendored
docs/PLUGINS.md the ABI, the threading rules
src/buf.c growable buffer, JSON escaping
src/tool.c registry
src/session.c append-only JSONL session
src/transport.c deterministic mock transport
src/builtin.c read/write/edit/search/list/run/web tools
src/agent.c the loop
src/main.c CLI
tests/ the test binaries, run by `make check`
docs/splinter.1 manual page
src/www/index.html HTML 4.01 static page
Plugins and themes
A plugin is a .so against libsplinter.so, exporting
sp_plugin_describe(). It can register tools (with authorization classes the
loop enforces) and widgets (rendered in the sidebar). A widget's tick() runs
on its own thread and publishes text; only the UI thread draws. See
docs/PLUGINS.md.
Themes are CDE palettes: 42 of them, generated from the desktop's own .dp
files. Roles are derived from the eight colour sets — darkest is the
background, lightest the foreground, the most saturated the accent. Default is
Delphinium. --list-themes prints the names, --theme NAME picks one.
Talking to a model
./splinter -p "say hi" --endpoint http://127.0.0.1:8080/v1/chat/completions \
--model qwen2.5-coder-7b --api-key-env SPLINTER_API_KEY
The adapter shapes the whole conversation into one chat/completions request,
including the tool table, and parses content and tool_calls back. The
provider's raw tool_calls array is stored verbatim in the conversation and
sent back unchanged on the next round: re-encoding it would be a silently
different JSON. content: null is an empty answer, not an error; a reply
without choices, or a provider error object, is an error that quotes the
provider's own message.
Any program as the model
SPLINTER_CLI_CMD="claude -p" ./splinter -p "hi" --plugin plugins/cli/cli.so --transport cli
The cli transport runs a program and takes its stdout as the answer, so
claude -p, opencode run, ollama run or a script can be the brains. The
OpenAI adapter stays the default for local endpoints.
Another agent: A2A
SPLINTER_A2A_URL=https://agent.example/rpc \
SPLINTER_A2A_TOKEN=... \
./splinter -p "hi" --plugin plugins/a2a/a2a.so --transport a2a
The client half of Agent2Agent: one SendMessage over JSON-RPC 2.0 with a text
part, blocking, and a direct Message or a completed Task as the answer. In
the UI the turn streams: SendStreamingMessage, artifact text appearing as it
arrives. The task and context ids are kept for the session, so the next turn
continues the same A2A context. SPLINTER_A2A_CARD discovers the JSON-RPC
endpoint from an agent card; SPLINTER_A2A_URL sets it directly. One-shot mode
streams by default; --no-stream asks for the blocking send.
The transport sends text. A file goes with a2a_send — a message plus a file
part (base64, 8 MiB cap, media type guessed from the name) — and a file the
other side sends back is saved (SPLINTER_A2A_INBOX, default
$TMPDIR/splinter-a2a-inbox) and named by path in the answer. a2a_get_task,
a2a_cancel_task and a2a_subscribe (the SSE events of a task, as one text)
use the same endpoint. Push notifications are not sent by the client.
The other direction: splinter as an A2A server
SPLINTER_A2A_SERVER_TOKEN=... \
./splinter --a2a-server-listen 127.0.0.1 --a2a-listen-port 8099
Another agent can send SendMessage to POST /a2a and read GetTask or
ListTasks; the
agent card is served at /.well-known/agent-card.json. SendStreamingMessage
streams the answer as SSE artifact updates, then a completed status. A
contextId is a conversation: the next message with it continues. Without one
the server creates a context and returns it in the task. A
taskPushNotificationConfig in the request posts the completed task to a
webhook: loopback is always allowed, other hosts need
SPLINTER_A2A_PUSH_ALLOW; the config's token travels as
X-A2A-Notification-Token, its authentication as Authorization. Binary
file/raw parts are written into the session's inbox/ and described to the
model by path (a text model cannot read a PNG, the agent around it can); URL
parts are fetched from loopback or a host in SPLINTER_A2A_URL_ALLOW.
SubscribeToTask replays the stored task state once and ends the stream — the
server answers one request at a time, so there is no progress to watch. Beyond loopback the bearer token is required;
there is no TLS, so put it behind ssh or a tunnel.
Configuration
splinter alone starts the chat: endpoint, model, plugins, theme and session
directory come from ~/.config/splinter/config (or $SPLINTER_CONFIG).
Command line wins over the file, the file wins over the built-in default, and
an unknown key is an error with its line number. Keys and examples in
docs/CONFIG.md; splinter --init-config writes a commented starter.
Streaming
Answers arrive as they are produced, not as one block: the adapter reads SSE,
turns text deltas into the chat pane and tool-call starts into the sidebar, and
a reasoning model's own reasoning_content is shown dimmed one line above the
answer instead of being hidden. In one-shot mode the text goes straight to
stdout as it comes.
Both directions are covered by test_sse, which feeds recorded lines: plain
text, a tool call split across three chunks, two calls in one turn, a broken
data line, and the keepalive lines that carry nothing.
Colour, measured
A CDE palette is eight mid-tones; painted literally, the accent sat 8% away
from the background and nothing was readable. Two fixes, both in init_colors:
the background is darkened until it is a terminal background, and every role is
pushed away from it until it is legible. Delphinium ends up with a white-on-slate
text contrast of 14:1, accents at 7.7:1 and labels at 4.7:1 instead of ~1.1:1.
The other half was a real bug: COLORS was read before start_color(), so it
was 0, the code took the eight-basic-colour path, and the whole palette
collapsed to white on black.
Screen encoding, measured
The vendored NetBSD curses emits Latin-1 bytes for wide characters (ü becomes
0xFC); ncurses passes UTF-8 through. So the UI transliterates for display
(gruen), while the conversation and the session log keep the exact UTF-8.
That is a defect in the ported library, recorded here instead of being papered
over with a claim that it works.
Input history
Up and Down walk through what was typed before, like a shell. The list is kept
in <session_dir>/history, so the next session starts with it.
Steering while a turn runs
The turn runs on its own thread, so the keyboard stays live. Every tool call is
written into the transcript with its name and arguments - werkzeug: run {"command":"echo a"} - because "it did something" is not information. The
reasoning is inserted before those lines: it came first, and the log should read
in the order things happened. The live area has
a fixed height (reasoning 8 rows, answer 5, tool line 1): a region that grows
with the text moves everything else around it, and text that jumps around the
screen is unreadable. While it runs, the
input line shows running Ns | Enter steers, Ctrl-C cancels. A steer is picked
up at the next step boundary; in a single-step turn it becomes the next message
instead of being dropped. Curses is only ever touched by the UI thread.
Compaction
focus keeps the session's goal in front of the model every five turns, the
way Claude Code's recap does — one inserted system message, never twice in a
turn, nothing until a goal is set. /goal <text> sets it, /recap forces a
reminder, both in the TUI and with -p.
Languages
UI strings live in share/locale/<lang>.msg, plain key = text files read at
startup — no gettext, no .mo, nothing to build. The language comes from
locale in the config, else SPLINTER_LOCALE, LC_ALL, LC_MESSAGES, LANG.
A missing translation falls back to English; a key that exists nowhere is shown
as itself, so nothing is silently empty. test_i18n fails if de.msg misses a
key that en.msg has.
Ships with en and de. Plugins translate their own strings with sp_t().
Hosts: one fleet
A delegate may name a host. The whole invocation then goes through ssh, so claude, opencode or another splinter run where the model or the network is:
delegate = olivia | auf olivia | tags=remote | host=172.25.206.16 |
endpoint=http://172.25.206.2:18082/v1/chat/completions | model=...
delegate and delegate_parallel both honour it, and the report names the host like any other model. The remote needs splinter at the same path and its own keys - nothing crosses the jump except the task.
Proven: a delegate with host=172.25.206.16 ran on olivia and answered from a provider reachable only over the wireguard link.
A failing delegate can be run without a model, which is how the child's own error text and exit status are inspected:
./splinter --delegate claude0 -p "sage nur: beta"
The observation carries the delegate line, the child's exit status and the task or job state; no model turn, no transport.
A fleet in one directory
src/swarm.c is the local variant. The first splinter started in a directory
binds .splinter-swarm.sock and becomes the master; later ones join as slaves.
/swarm <text> sends a line to the least busy peer, /swarm <id> <text> picks
one, /swarm ls lists them, and a routed command runs there. It is IPC between
processes that share a working directory — not A2A, and not a network protocol.
First run: the interview
splinter --interview
Six questions - language, who you are, stack, answering style, what never to
do, which paths are sacred - written to ~/.splinter/profile/<user>.md. The
questions come from the catalogue: the default is English, locale = de (or
SPLINTER_LOCALE) makes them German. Enter
skips a question and the skip is recorded as such: an empty line would be a lie.
Starting the chat without a profile prints a hint, once.
Piped input
cat /etc/passwd | splinter "explain the file"
Anything on standard input becomes context, framed and labelled with its size:
[stdin: 12 bytes]
...
[/stdin]
The question and the bytes are kept apart, so the model knows which is which. A
binary input is reported as binary instead of being sprayed into the request, the
size is capped at 192 KiB (with [truncated]), and --no-stdin ignores the pipe
entirely. With no prompt at all, the input becomes the prompt.
Gateway mode
--daemon turns splinter into a Telegram bot: long-poll getUpdates, one turn
per message, reply. No curses, no terminal.
~/.splinter/telegram.token the token, mode 0600 (or SPLINTER_TELEGRAM_TOKEN)
telegram_allow = 8300935 who is answered, comma separated; nobody by default
The token is read from a file or the environment and never from an argument, and the message loop keeps no state on disk beyond the session: a restart re-delivers the last update, which costs one duplicated answer and never a lost message. Signature handling is the session's business, not the gateway's.
A bot cannot start a conversation - the user has to write first, otherwise the
API answers chat not found. That is Telegram, not the harness.
The bot registers the commands that actually exist with setMyCommands:
/start, /help, /interview, /new, /model, /connect, every command a
loaded plugin registers
(/goal, /recap, /tasks, /quota, /tmux, ...) and every program in
~/.splinter/commands/ whose name is a valid Telegram command (lower-case,
digits, underscore, at most 32). /start and /help answer with the short
text plus that live list. An approval arrives as a message with Yes/No
buttons; the callback answers the button, removes the buttons and writes the
ack file. The text form ok <id> / no <id> still works.
The model's markdown is rendered as Telegram HTML: bold, italic, strike,
inline code, fenced blocks, links (also <https://…>) and quotes become tags,
everything else is escaped. An image is sent as a photo with the alt text as
caption:  is fetched by Telegram,  (or
file:///…) is uploaded from this machine. A local file that is not an image
goes out as a document (sendDocument, at most 50 MiB). The photo guard still
checks the bytes — PNG/JPEG/GIF/WebP up to 10 MiB — so a text file cannot ride
in as a photo; a missing or unreadable file stays a reference in the chat.
Images inside code or a table stay text. Tables are laid out as columns inside a <pre> block. A long answer
is split at tag boundaries, with the open tags closed and reopened per
message, and a piece Telegram refuses to parse is sent as plain text instead.
SPLINTER_TG_MARKDOWN=0 turns the rendering off.
/new (or /reset) starts a fresh conversation and a fresh session file; the
old one stays on disk, and the system prompt is put back.
/model lists the models the config names (the main endpoint, every delegate
with a model, every exit) as buttons and points the running transport at the
one you press. The choice is written to <config>.d/90-model.conf, so the next
start uses it too; picking main deletes that file. /model <name> keeps the
endpoint and takes another model from it. /model probe asks every endpoint
/v1/models and offers what it really serves. The TUI has the same /model
(list, or /model <id|name>), without buttons.
/connect works the same in the TUI, one answer per line. It adds a provider
in four answers — name, endpoint, model, key
variable (or - for none); ollama and opencode stand for their usual
endpoint. It writes the line to <config>.d/20-connect.conf, so the next start
has the provider too, runs one tiny turn against it to prove endpoint, model
and key work, and offers to use it right away.
/interview asks the same six questions as splinter --interview, one
message per answer; /skip skips one and /cancel stops. A program in
commands/ answers in the chat: its output is the reply. In the
TUI the same program's output becomes context for the model instead. A typo
such as /nosuch is answered with the command list, not sent to the model.
docs/splinter-gateway.service is a systemd user unit if it should survive a
logout.
The exit ring
plugins/ring/ring.so holds several ways to reach a model and walks them in
order when one is rate limited:
exit = go | OpenCode Go | endpoint=... | model=...
exit = groq | Groq free tier | endpoint=... | model=... | key_env=GROQ_KEY
exit = local | kontron, lokal | endpoint=... | model=...
Run it with --transport ring. Only pressure moves the ring: 429, 5xx, "rate
limit", "quota". A dead host or a bad key stops the turn where it is - a ring
that treats every failure as "try the next" hides real breakage behind a random
provider. Proven against two fake providers: the first answered 429, the ring
moved on and the second answered; a dead port did not move it.
Providers from the environment
Nothing to configure if the keys are already there:
OLLAMA_KEY OLLAMA_KEY_0 .. OLLAMA_KEY_N
CLAUDE_CODE_OAUTH_TOKEN CLAUDE_CODE_OAUTH_TOKEN_0 .. _N
Each Ollama key becomes a delegate and an exit in the ring, with the endpoint
from OLLAMA_ENDPOINT (default https://ollama.com/v1/chat/completions) and the
model from OLLAMA_MODEL. Each Claude token becomes a cli delegate that runs
claude -p. Several keys mean several accounts, and the ring uses them in order.
The keys are copied into memory and passed to children through the environment - never on a command line, never into a log.
$ OLLAMA_KEY=... CLAUDE_CODE_OAUTH_TOKEN=... splinter --choose "plane die arbeit"
claude-3 score=4 prio=10 task mentions 'plan'
$ OLLAMA_KEY=... splinter --choose "implementier das"
ollama-2 score=3 prio=0 task mentions 'implement'
Parallel handover uses delegate_parallel with a list of tasks - each picks its
own model, up to eight run at once, and the answers come back labelled:
[parallel: 2 task(s), 12018 ms wall]
## task 1 | model slow | score 5 | 12018 ms | exit 0 | 75 B | requested tag 'slow'
> sag A
...
## task 2 | model fast | score 5 | 16 ms | exit 0 | 74 B | requested tag 'fast'
...
## summary
- slow: 1 task(s), 12018 ms total
- fast: 1 task(s), 16 ms total
The planner gets who did what, how long it took and whether it worked - not a wall of answers. A delegate that is slow or failing is visible in the header before anybody reads its prose.
max_parallel still applies: a delegate that is full skips the task with a note
instead of queueing it.
That is the workflow the tool is built for: a strong model plans and defines the
work, the local models implement it, and delegate is the handover.
Delegation
Work can be handed to another model. A delegate is one line in the config - no profiles, no directories, nothing to keep in sync:
delegate = coder | C99, POSIX, kennt den Quellbaum | tags=code,c99,review |
prio=5 | max_parallel=2 |
endpoint=http://kontron.local:8080/v1/chat/completions |
model=Qwen3.6-35B
delegate = quick | kurze Antworten, Chat | tags=chat,cheap |
endpoint=... | model=...
prio breaks ties (higher wins), max_parallel caps how many calls may run on
one delegate at once - a busy delegate answers "busy", it does not queue
silently. kind=cli and cmd=claude -p turn a delegate into a program instead
of an endpoint.
The delegate tool takes a task and, optionally, tags. splinter picks the model
itself: a requested tag counts 5, a tag found in the task 3, a word of the
description 1. The observation starts with the choice and the reason, so a wrong
pick is visible instead of mysterious:
[delegate coder, score 7: task mentions 'code']
--choose "text" prints that decision without running anything:
coder 7 task mentions 'code'. The child is splinter in one-shot mode with its
own context; the tool is classed destructive, so the operator approves the
delegation once.
Resuming
--resume loads the newest session in the session directory back into the
conversation and puts it on screen. It continues that session id rather than
opening a fresh one beside it - the first version did the latter, which looked
like a resume and was none.
MCP
plugins/mcp/mcp.so speaks to an MCP server over stdio and registers its tools:
SPLINTER_MCP_CMD="npx -y @modelcontextprotocol/server-filesystem /home" \
splinter --plugin plugins/mcp/mcp.so
Each tool keeps the schema the server published, so the model sees its
parameters; the class is mutate, because a server can do anything and the
harness does not pretend to know better. Proven against a test server: the model
called mcp_add(17, 25) and answered 42.
The other direction, splinter as the server, is --mcp-server-listen IP:
newline-delimited JSON-RPC over TCP, read tools only unless --autonomous.
On 127.x it needs nothing; on any other address it refuses to start without
SPLINTER_MCP_TOKEN, and every connection must begin with the line
AUTH <token>. There is no TLS: across a network you do not own, tunnel it.
SPLINTER_MCP_TOKEN=$(cat ~/.splinter/mcp.token) \
splinter --mcp-server-listen 0.0.0.0
(echo "AUTH $(cat ~/.splinter/mcp.token)"; cat requests.jsonl) | nc host 8098
Tools
Every tool declares its class, and the loop enforces it - never the model, never the prompt.
read(read): numbered lines, offset and limit, refuses binary files, says where it stopped.search(read): literal string over a directory tree, capped at 100 hits.list(read): a directory.write(mutate): writes a file, up to 4 MiB.edit(mutate): replaces exactly one occurrence; a non-uniqueoldis an error, because an ambiguous edit is a wrong edit waiting to happen.run(destructive): a shell command; the exit status is an observation. Its own process group, stdin/dev/null, killed afterSPLINTER_RUN_TIMEOUTseconds (default 600) orrun_timeoutin the config, and an environment without splinter's API keys and tokens, sorun envcannot hand them to the model.webfetch(mutate): http(s) only, curl started without a shell. Not read: a URL the model picks is a message out of the machine.echo(read),clock(read).
Mutate and destructive tools ask first, unless --autonomous is set. In the
chat the question sits where the prompt is - run (destructive) touch x? y/N -
and the turn waits on it; n or Esc denies, and the model is told
error: denied by operator. This used to be dead code in the TUI: the prompt
read stdin behind curses' back, so with --autonomous off every such tool was
silently denied.
Shell escape
!command runs it here and puts the output into the conversation, so the model
sees what the operator saw. Capped at 4 KiB: a runaway command must not eat the
budget in one keystroke.
Slash commands
A leading / never reaches the model: the UI asks the host, the host asks the
plugins. A plugin registers what it handles (/goal, /recap today); an
unknown command lists what exists instead of being sent as a prompt.
Compaction is a plugin, not a switch in the loop. Two ship here: lcm
(deterministic front-trim with an in-band system message saying what went) and
cps (continuous parallel compression: plans are prepared on a worker thread
from an index of the conversation, then spliced in instantly). Details and the
ABI in docs/PLUGINS.md.
Limits, stated
- Tool arguments reach the tool as one string; each tool validates its own.
- MCP tools are all
mutate, so they ask before they run. - The ring only retries on rate limits; a 500 from a broken endpoint also counts as pressure, so a provider that fails hard gets skipped rather than fixed.
- No retrieval tiers over old sessions. Compaction is a plugin (lcm); it cuts the conversation, it does not remember what it cut.
- A
tick()that never returns hangs the exit: the host can stop a thread only between ticks, not inside one. - Plugins are not sandboxed. They run in the process with full rights; the authorization classes protect the harness from the model, not from code you chose to load.
License
BSD-3-Clause.