The terminal and the agent
A design, agreed 2026-11-24 from two discussions (sessions s837 and s838, brought together in s841). The terminal's first steps are built; the agent is not. The roadmap has the steps and their state.
What a Unix terminal lumps together, and what we keep
A Unix terminal is three things at once: a command language (the shell), a transport (a PTY carrying escape codes in its byte stream) and a display (an emulator of a 1978 character grid). Programs know the screen's width, move the cursor, and any byte can be a control code. Pinnacle keeps the first and the last apart and drops the middle: no VT100, no PTY, no line discipline, no signals, UTF-8 only.
The terminal
- Output is records, not bytes. A program sends typed messages on a
channel: text, a table, progress, a file, an image, a question, a status.
The terminal draws each itself with
gfxandlayout: text wraps to the window, a table gets as many columns as fit, an image sits in the output. - No control codes in band. A program can add records, or update one it owns by id (a progress bar); it cannot clear the screen and does not know its width. The terminal decides font, wrapping, theme and touch.
- Arguments are handles where they can be. The person picks a file in the terminal and the command gets that one file as a handle. A pipe is a channel of typed records between two programs and can pass handles on.
- Many commands are verbs of services that already run (network, settings, store, p2p). A service answers a describe message with its verbs and their parameters' types, so the terminal can complete, check before sending, and draw the same command as a form on a narrow screen.
- A question is a record, not raw mode. A program that needs an answer
sends
Ask(text, a choice, yes/no, a file); the terminal draws a widget. A program that wants the whole screen asksdisplayfor a window: the terminal never becomes a second window system. - Stopping is a handle, not a signal. The terminal spawns the program, holds its Process handle, and puts a Stop button by it that KILLs it.
- The session is a document, kept in the data vault, searchable, drawn afresh at any width; a record is what is copied or shared.
- Responsive like Messages: one column on a phone; on a wide screen the history beside the selected record, opened out.
- Remote is the same protocol: a terminal to another Pinnacle is a
channel to an
execservice there, over the encrypted p2p session, authenticated by the contact's key. No separate ssh.
Remote (agreed 2026-11-24, session s844)
What ssh and mosh do, on what the p2p layer already is. Built: sessions that
heal themselves (a device that moves is followed, two that both moved find
each other again through the DHT), reliable streams that outlive any one
session (p2p crate docs), and on them the terminal's remote <contact>
(pinnacle_ui::remote, cargo xtask remote). As built, it differs from the
plan below in two places: the person's consent is the switch in Settings
itself, with a notice on their screen for every command run, rather than a
confirmation at first use; and a command survives a network break of up to
five minutes (the stream's), but is not yet resumed by record id after the
terminal closes.
- A stream per command to the
execservice of the other device: the record protocol on it both ways, a file handle a stream of its own. - Resumed, not reconnected, as mosh and unlike ssh: the device that runs the command keeps its session document; after a break (a train tunnel, a laptop closed) the terminal asks for the records after the last it has, by id. Records are state, not a byte stream, so nothing is replayed twice or lost.
- A right of its own, "manage": being a contact opens a session, not a
shell. The person gives it per contact in Settings, offered for their own
devices only; the target's screen confirms the first use, and every
remote session is kept in its vault. No passwords or
known_hosts: the contact's key, exchanged in person, is the host key. - Later: forwarding a port (a stream to a
tcpservice there), relaying through a shared contact (still end to end) where hole punching fails, and IPv6. (NAT hole punching, a DHT node introducing both sides, is built.)
The record protocol (records)
A record is one channel message: 0xFE, its kind, two bytes of padding, then
its body. 0xFE never occurs in UTF-8, so one stdout channel carries both a
record-speaking program's records and a plain std program's text: any message
not starting with it is bytes, shown as text lines. A plain println!
therefore appears, and can do nothing else.
Text { body } running text
Table { columns, rows } the terminal picks column widths
Progress { id, done, total, label } sent again with the same id to update
File { name, size } + a file handle tap: open, share, pass on
Image { width, height } + memory drawn inline
Ask { id, kind, prompt, options } text, choice, yes/no, file
Status { code, summary } the last record
Answer { id, text } terminal → program, to an Ask
Commands are started as std programs are (abi::STD_START, a start message
on handle 1: arguments, environment, standard streams), so one way of
starting serves both kinds; records::start writes and reads that message.
The protocol belongs to the system, not the terminal: Messages and Settings
can carry the same records.
The command language
Pipelines of verbs with typed arguments and fields picked from records, no loops or conditions: control belongs in programs, which on Pinnacle are Rust. A scripting language is a separate decision that can come later without rebuilding the terminal.
It came as such (2026-11-27): Frits, as the command frits
(programs/src/bin/frits.rs), not as a second command language. A script
speaks records through its platform (programs/frits/terminal.frits), so
its tables and questions are the terminal's own, and the effects on its
first line, which frits check lists, are what it can touch.
What is lost: text as the universal interface. Tools from outside expect bytes; the adapter catches half, and the rest is the price of output that cannot lie about what it is.
The agent
The principle: assume the model is hijacked, and make that not matter. Everything the model says is a request, never an act. agent-environment.md (2026-11-26) works this section out against the tree, the vendors' 2025–2026 systems and the standalone agents, and refines the order below.
- A
modelservice owns the connection to one host the person chooses (an API provider over TLS first; later their own machine found through the DHT; one day a model on the device, behind the same interface). It is the only part with the network, so what leaves the device is the prompt, and Settings → Agent shows what was sent. Off by default: with no host set there is no agent, and everything works. - An
agentgatekeeper, small and deterministic, started per task with that task's handles and no network. It turns a request of the model into a message to a service, checks it against what the person gave, and writes every action to an append-only log in the vault. Model output never holds a handle. A task starts with apfssnapshot, so undoing what the agent did is one act, and has a budget (actions, bytes to the model). - The display server is the trusted path. It draws the agent's confirmation dialog, as it draws the lock screen: no app or agent sees or can fake it. Input the agent synthesises (the act protocol on the UI tree) carries a mark physical input does not; an app can demand physical input for what cannot be undone. The status bar shows when, and in which app, the agent acts.
- Taint. A task that read untrusted text (the network, a message from a non-contact, a file another program wrote) may send nothing out without the person confirming: private data, untrusted content and a way out never meet in one task unchecked. This is the defence against prompt injection that holds; Pinnacle can enforce it because all IO is channels.
Where it lives: in the system's surfaces, not in its rights. The three are system programs that come with the system and register names (anyone can reach the agent), with an off switch, never in the kernel. Its rights come per action as handles from the person, never from its standing, so being part of the system buys it no power.
How it meets the terminal. The agent speaks records like any program:
the terminal is the shared space where the person and the agent write in one
session, and the person sees every action as a record. describe is its tool
schema; Ask is how it asks the person; the Process handle is the Stop
button. The same stream in another window makes it a contact in Messages.
What is not reinvented: the model's API, context compaction, the system prompt with tool schemas. What is given up: a shell for development on the device, and MCP servers as code.
Order
- The record protocol (
records) and the terminal: Text, Table, Progress and Status drawn; commands started with the std start message; Stop. (built) - Images drawn (their pixels as shared memory); questions answered in the
field or by buttons, the answer on the command's stdin; the session kept
in the vault (its last 50 commands, images by their size). (built)
describein the services, each verb with its effect, a service's name a command (p2p send contact=Anna text="Hi"). (built 2026-11-26) A terminal to type in (2026-11-27): Adwaita Mono edge to edge, the prompt under the output with the working folder (cd,pwd; commands get it asPWD,records::start::resolvereads paths by it), a cursor that moves, Up and Down throughhistory, Tab completing commands, contacts and paths, Ctrl+C to stop; the file commandsls,cat,mkdir,rm,cp,mv,touch(one program,files;rmasks before a folder or anything on the system disk); on a touch screen a row of the keys the on-screen keyboard lacks. (built) Pipelines (2026-11-28):ls | where Size > 1 MB | sort Size down | pick Name Size, each command's stdout the next one's stdin, and four filters (where,sort,first,pick;pinnacle_records::pipe) that read a table, or text as rows of one column, and give it on changed. (built) Looking after a device (2026-11-29): words in quotes kept whole (grep "no address" log.txt),a; banda && brun one after the other (the rest of a line kept on its entry, so a second line typed meanwhile runs beside it), and> fileor>> fileat a line's end, which becomes a last stagesavewriting what comes in as text (a table tab-separated under its header). Inwhere Size > 1 MBthe>compares: a filter's operator is its third word. New filterslast,count,unique;head,tail,grepandwcread files, and after a|arefirst,last,whereandcount. The file commands gainedfind,du,dfandhex(tailreads a large file from its end); a program of its own,admin, has the system's:ps,kill(by number or name; a system program only after a yes, never the display server),services,log(the kernel keeps the last 64 KiB of what it and the programs wrote),apps,net(net on,net off),lookup,ping,fetch(a URL's text, or saved to a file),date,envandrestart(after a yes). The kernel gives programs a number, a name and a start time for this (callsPROCESSES,KILL_ID,LOG), to system programs only.cargo xtask admin-demo. (built) As built:pingtimes four HTTP(S) requests, not ICMP echoes (a program sends no ICMP, and the kernel does not say when a bare TCP connection opens);ps's memory is what a program asked for and the shared memory it maps, not its code; there are no variables, and a pasted text is still one line. Still to come: files picked as handles (the kernel has one now), forms, and a command that is not a filter reading the records piped to it (a file record tocp). - The display server's UI tree and act protocol, with the synthetic-input
mark (also a test instrument for
xtask). - The
modelservice and Settings → Agent. (built 2026-11-26) - The
agentgatekeeper: per-task handles, log, an inverse log for undo instead of a snapshot, budget, the confirmation dialog. (built 2026-11-26;agent-environment.md, "As built", has how it differs) - The taint rule. (built 2026-11-26)