Rebuilt from scratch after the previous attempt left no code behind: what exists here is what compiles and what the tests prove, and nothing else is claimed. What is in it: - a turn loop that refuses an over-budget request before sending it, reports unknown tools instead of guessing, and honours authorization classes (read runs, mutate/destructive ask unless --autonomous); - a registry that is authoritative - the model names a tool, the registry decides whether it exists; - an append-only JSONL session (O_APPEND, fsync per record), where a crash can only truncate the tail and the tail is skipped, not repaired; - two transports: a deterministic mock (queue of replies, last request kept) and HTTP via curl(1) with the request body in a temp file; - two builtins that exist to prove the classes: echo (read) and run (destructive, reports its exit status as an observation). Five test binaries, no external framework, no network: mock driver covers the answer path, a tool round, an unknown tool, a denial, autonomy, a failing tool, the step limit, the byte budget (asserting that nothing was sent) and a non-2xx reply. The wire format is splinter's own line protocol (user/observe out, answer/tool in); provider adapters translate. That is why the loop is testable without a model, and why no vendor JSON is parsed in the core.
126 lines
3.1 KiB
Groff
126 lines
3.1 KiB
Groff
.Dd November 7, 2026
|
|
.Dt SPLINTER 1
|
|
.Os
|
|
.Sh NAME
|
|
.Nm splinter
|
|
.Nd a small C99/POSIX agent harness
|
|
.Sh SYNOPSIS
|
|
.Nm
|
|
.Fl p Ar prompt
|
|
.Fl -endpoint Ar url
|
|
.Op Fl -autonomous
|
|
.Op Fl -steps Ar n
|
|
.Op Fl -session Ar dir
|
|
.Op Fl -session-id Ar id
|
|
.Nm
|
|
.Fl p Ar prompt
|
|
.Fl -script Ar file
|
|
.Op Ar options
|
|
.Nm
|
|
.Fl V
|
|
.Sh DESCRIPTION
|
|
.Nm
|
|
runs one turn of an agent loop against a transport.
|
|
It sends a prompt, executes the tools the transport asks for, and prints the
|
|
final answer.
|
|
Every turn is appended to a session log as JSON Lines.
|
|
.Pp
|
|
The loop enforces, in this order, before any tool runs:
|
|
.Bl -enum -compact
|
|
.It
|
|
the request fits the configured byte budget; otherwise nothing is sent;
|
|
.It
|
|
the tool exists in the registry; otherwise the model is told it does not;
|
|
.It
|
|
the tool's authorization class allows the call; a mutating or destructive
|
|
tool asks the operator unless
|
|
.Fl -autonomous
|
|
was given.
|
|
.El
|
|
.Pp
|
|
A denied tool is not skipped silently: the denial is the observation the model
|
|
receives.
|
|
.Sh OPTIONS
|
|
.Bl -tag -width Ds
|
|
.It Fl p , -prompt Ar TEXT
|
|
The user message for this turn.
|
|
Required.
|
|
.It Fl -endpoint Ar URL
|
|
Transport: POST the line protocol to
|
|
.Ar URL
|
|
using
|
|
.Xr curl 1 .
|
|
.It Fl -script Ar FILE
|
|
Transport: replay one reply per line from
|
|
.Ar FILE .
|
|
This needs no network and is how the test suite drives the loop.
|
|
.It Fl -autonomous
|
|
Run mutating tools without asking.
|
|
Read-only tools never ask.
|
|
.It Fl -steps Ar N
|
|
Maximum tool rounds per turn (default 8).
|
|
.It Fl -max-bytes Ar N
|
|
Request budget in bytes; 0 means no limit.
|
|
.It Fl -session Ar DIR
|
|
Session directory (default
|
|
.Pa ~/.splinter ) .
|
|
.It Fl -session-id Ar ID
|
|
Session id (default
|
|
.Pa sess-<time>-<pid> ) .
|
|
.It Fl V , -version
|
|
Print the version and exit.
|
|
.El
|
|
.Sh PROTOCOL
|
|
.Nm
|
|
speaks a line protocol with its transport, not a vendor API:
|
|
.Bd -literal -offset indent
|
|
request user <text>
|
|
request observe <tool> <output>
|
|
reply answer <text>
|
|
reply tool <name> <arguments>
|
|
.Ed
|
|
.Pp
|
|
A provider adapter translates an OpenAI-compatible endpoint into this shape
|
|
and back.
|
|
The harness itself never parses vendor JSON, which is why the loop is testable
|
|
with no network at all.
|
|
.Sh EXIT STATUS
|
|
.Bl -tag -width Ds -compact
|
|
.It 0
|
|
The turn produced an answer.
|
|
.It 1
|
|
The turn failed.
|
|
The reason is printed on standard error.
|
|
.It 2
|
|
Usage or configuration error.
|
|
.It 3
|
|
The environment could not be set up, for example the session directory.
|
|
.El
|
|
.Sh FILES
|
|
.Bl -tag -width Ds
|
|
.It Pa ~/.splinter/<id>.jsonl
|
|
Append-only session log, one JSON object per line.
|
|
A crash can only truncate the tail.
|
|
.El
|
|
.Sh EXAMPLES
|
|
Run a scripted turn with no network:
|
|
.Bd -literal -offset indent
|
|
$ printf 'answer hello\\n' > /tmp/r.txt
|
|
$ splinter -p "say hello" --script /tmp/r.txt
|
|
hello
|
|
.Ed
|
|
.Pp
|
|
Talk to an adapter:
|
|
.Bd -literal -offset indent
|
|
$ splinter -p "list the C files" --endpoint http://127.0.0.1:8080/turn
|
|
.Ed
|
|
.Sh SEE ALSO
|
|
.Xr curl 1
|
|
.Sh CAVEATS
|
|
The transport is responsible for anything the model says; the harness trusts
|
|
only the registry and the authorization classes.
|
|
Tool arguments are passed as a single string and are not validated beyond the
|
|
tool's own checks.
|
|
.Sh AUTHORS
|
|
.An Konrad Lother
|