garage44.eu/jeroen/pinnacle

logclone: git clone https://garage44.eu/jeroen/pinnacle.git

.. /docs/terminal-and-agent.md

raw

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

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.

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.

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

  1. The record protocol (records) and the terminal: Text, Table, Progress and Status drawn; commands started with the std start message; Stop. (built)
  2. 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) describe in 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 as PWD, records::start::resolve reads paths by it), a cursor that moves, Up and Down through history, Tab completing commands, contacts and paths, Ctrl+C to stop; the file commands ls, cat, mkdir, rm, cp, mv, touch (one program, files; rm asks 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; b and a && b run one after the other (the rest of a line kept on its entry, so a second line typed meanwhile runs beside it), and > file or >> file at a line's end, which becomes a last stage save writing what comes in as text (a table tab-separated under its header). In where Size > 1 MB the > compares: a filter's operator is its third word. New filters last, count, unique; head, tail, grep and wc read files, and after a | are first, last, where and count. The file commands gained find, du, df and hex (tail reads 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, env and restart (after a yes). The kernel gives programs a number, a name and a start time for this (calls PROCESSES, KILL_ID, LOG), to system programs only. cargo xtask admin-demo. (built) As built: ping times 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 to cp).
  3. The display server's UI tree and act protocol, with the synthetic-input mark (also a test instrument for xtask).
  4. The model service and Settings → Agent. (built 2026-11-26)
  5. The agent gatekeeper: 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)
  6. The taint rule. (built 2026-11-26)