Surface protocol
An agent tells Terminal Delight what it made by sending a small JSON document called a surface: a reply, a decision it wants taken, a change to review, a file it wrote, a table, a diagram or a question. It says what the thing is. The window decides how it looks, and it lands on the pane's workbench.
{ "td": "0.4", "kind": "decision", "id": "cache-eviction",
"title": "Cache eviction policy",
"model": { "question": "LRU or TTL?",
"options": [ { "name": "LRU", "recommended": true,
"case": "3× fewer misses on the replay corpus.",
"cost": "A cold start is slower." },
{ "name": "TTL" } ] } }
The easiest way to send one is to write it as a .json file into the pane's own folder, which the window checks every second. It can also go through the MCP server, be piped to terminal-delight surface, or be printed in a ```td block in the agent's reply. Give every document its own id: the same id again updates that card.
When a person presses approve on that card, one line is typed into the agent's terminal: [workbench:k7f2q9ax] approve on surface cache-eviction. The tag matches the pane's $TD_TAG, so the agent can tell its operator from text that only looks like one.
Technical has every field, kind, route, limit and refusal.
TDSP 0.4
The full contract is the spec in the repository, docs/spec/td-surface-protocol.md, which was checked against the code on 1 November 2026 and agrees with this page. Everything here is the same in 0.4.0 and in 0.5.0 development except where marked.9
Version#
td is a string, and this build writes "0.4". Only the major number is compared: "0.1" through "0.9" are accepted, "1.0" is refused, and a numeric td reads as missing.1
Envelope#
| Field | Needed | What the window does |
|---|---|---|
td | always | Checks the major version. |
op | no | present (the default), update or retire. Anything else is refused. |
id | for retire | Keeps letters, digits and - _ . :, up to 96 characters. Left out, it's made from the kind and the title alone. |
kind | except retire | One of the kinds below. |
title | no | Trimmed and cut to 72 characters. Empty gets a default for the kind: the file name, note, table of 3, the question, or the reply's first sentence. |
model | except retire | The kind's content. |
weight | no | effort, complexity, foundation, confidence; see Weights below. |
source | no | files, command, reference. The source button opens the first file. |
actions | no | Verbs added after the kind's own. They can add buttons, never remove one. |
pane | no | Accepted and not used; the route decides the pane. |
Always send an id. Two surfaces of the same kind with no id and the same title, or no title, get the same made-up id, and the second replaces the first: two untitled notes with different text become one row. Keep ids to letters, digits, - and _, under 64 characters. A file name drops . and : and stops at 64, so ids such as a.b and ab are saved to the same file and only one comes back after a restart.12
Kinds#
| Kind | Needs in model | May also have | Shelf | Buttons |
|---|---|---|---|---|
response | layman | brief, technical, evidence, asks, next, doubts, escalation, any other key | overview | comment, ask |
artifact | href (or open, path, file, url, link) | mime, summary (or what, about), any other note | artifacts | open, comment |
markdown | body | artifacts | comment | |
table | columns | rows; a null cell reads unavailable | artifacts | comment |
architecture | nodes, each with an id | node label, state, group; edges of from, to, label | artifacts | comment, ask |
changeset | hunks, each with a file | repository; hunk id, patch | decisions | accept and reject per hunk, comment, approve |
decision | question | options (name, case, cost, one recommended), consequences | decisions | approve, reject, comment |
question | question, options | options as strings or {label, what_happens}; recommend and answer as option indexes | decisions | one choose per option, comment |
Those eight are the ones --catalogue lists. The parser knows two more: comment, a note a person writes on the bench's comments shelf, which offers only copy and isn't offered to agents; and unclassified, which is what the window makes of a document it can't read, shown with the reason and the first 20 lines of the raw document. A question's answer is read only as an option's index, and anything else means it is still waiting.1
An artifact's location must start with /, http://, https:// or file://. javascript: and data: are refused as not documents, and everything else, including ~/, a bare file name and mailto:, is refused as relative, because a relative path would be read from the terminal's directory rather than the agent's. Its row badge (HTML, MD, PDF, IMG…) comes from mime, or from the extension when there is no mime, and any keys besides the location, mime and summary are shown as facts under it.1
open shows a local Markdown, HTML, image, video, audio or PDF file in a floating document over the pane, and hands anything else, every web address included, to the desktop. A type the window can't draw on this machine, such as HTML with no Chromium installed, goes to the desktop too. An HTML artifact built as a decision brief takes notes there, and its notes go back to the agent.11
Replies#
A response is the reply an agent sends at the end of every turn. Its registers sit in model, or one level down under model.response. Keys are matched without regard to case, with - and spaces read as _.
| Key | Tab · chip | Other spellings |
|---|---|---|
layman (required) | reading · Plain brief, what the card opens on | layman_brief, laymans, plain, plain_brief, plain_english |
technical | reading · Technical brief | technical_brief, tech, engineering, detail, details |
brief | reading · Brief, the last chip | in_brief, bare_minimum, bottom_line |
evidence | evidence · What was verified | verified, verification, proof, checks, tested |
doubts | evidence · doubts | doubt, unsure, uncertain, uncertainties, caveats, risks and others |
asks | steps · Needs from you | ask, needs, needs_from_you, questions, blocked_on and others |
next | steps · What's next, numbered | next_steps, whats_next, follow_ups, todo and others |
escalation | a frame above the tabs | escalate, waiting_on_you, summons |
| any other key | other · the key, with underscores as spaces | eli5 lands here too, labelled ELI5 |
The brief is the bare minimum, at most two sentences and under fifty words. One identical to the layman is dropped. An old tldr, summary, gist or headline fills the brief, or the plain reply if there is nothing else. A string is prose, an array is a list, an object is facts, and an empty value is not drawn. A doubt is a string or {claim, why, confidence}, and the reply's row shows the count, 2 doubts. A tab with nothing in it isn't drawn, and a reply that is only a layman draws no tabs.15
escalation is {"level", "why", "items": [{"ask", "answered"}]} or a list of questions. blocking draws the red frame headed ◆ NEEDS YOU · 1 unanswered · BLOCKING; wanted, or any word this build doesn't know, draws it fainter, headed WANTED; none says you looked and need nothing, which is a different answer from leaving it out. Left out, the asks register stands in, tagged inferred. The frame draws only while an item is unanswered, so a bare "escalation": "blocking" with no items draws nothing at all: if you are blocked, say on what. While the frame is up, asks isn't repeated under it.6
Weights#
| Field | Values |
|---|---|
effort | small, medium, large, epic (or s, m, l, xl) |
complexity | trivial, moderate, involved, hairy |
foundation | {"system": "<your words>", "depth": "leaf" | "component" | "subsystem" | "bedrock"} |
confidence | measured, inferred, hunch, unknown |
The card turns them into one sentence under the title. medium, involved, request cache at component depth and measured read A middling, involved job in request cache, where other components call it. Measured. A word the window doesn't know is ignored, a foundation without a valid depth is dropped, and a surface with no weights says Nobody said how big this is or how deep it goes. Leaving confidence out and sending unknown are different: unknown reads The agent looked and could not tell. Questions, comments and cards too small for full size draw no weights.6
present, update, retire#
- present with a new id adds the surface; with an id already there, replaces it whole. The same document sent again changes nothing.
- update merges into the existing surface, or adds it if the id is new. It still needs
kindandmodel. Send thetitleevery time: a missing one becomes the kind's default rather than keeping the old title. - retire with an
idtakes the surface off the bench. Over MCP it also deletes the saved file.
An arrival never changes the shelf a person is looking at and never selects anything. It's marked unseen unless its shelf is on screen. Each pane keeps its 64 newest surfaces.5
Four routes#
- file
- Write the document to
$XDG_STATE_HOME/terminal-delight/surfaces/$TD_SESSION/$TD_PANE_ID/<name>.json(~/.local/state/…by default). The window reads new and changed files once a second, oldest first by modification time. Any name ending.jsonworks exceptbench.json, which belongs to the agent channel. Write beside and rename into place so a half-written file is never read. The folder is also how a new window gets the bench back.2 - MCP
present_surfacewith the pane'spidand the document assurface. It needs MCP exposure on and writes on, checks the document strictly and returns the reason if it's refused, and saves it to the pane's folder as<id>.json, so it survives a restart. Aretiredeletes that file. On success it answerson the bench — "Cache eviction policy" (decision) is on pane 4123's WORKBENCH face.3- command line
terminal-delight surface [file], reading stdin with no file, from inside a pane. It takes one document, or every```tdand```tdspblock in the input, writes each to the pane's folder named by its id (or by the time, which then becomes its id), and prints each path. It doesn't check the document: one the window can't read lands asunclassified. Exit 0 if it wrote something, 2 if the input held no JSON or no file could be written, 3 outside a pane.2- transcript
- A
```tdor```tdspblock in the agent's own reply. The window reads the last 256 KiB of a Claude Code transcript, when it's sure which transcript is the pane's; a Codex transcript yields nothing this way. The same reader turns the newestDeliverable:line into an artifact. Use a fence only when nothing else is available: it puts raw JSON in front of the person reading the reply.4
present_surface aimed at another agent's pane needs a Threshing Floor line reaching that pane at read or higher, and the pane must take writes. Otherwise it's refused with pane 4123 takes no writes from here — it is read-only to you; only a person, or the agent in that pane, may write it. An agent's own pane always takes its surfaces. The file is saved only once the window has accepted the surface, and the exposure and writes refusals point to the Threshing Floor instead of the MCP CONTROL panel.10
Catalogue#
terminal-delight surface --catalogue
This, or the surface_catalogue MCP tool, prints the eight kinds, the weight words, the transports (mcp:present_surface, file, transcript-fence) and the rule that an unknown kind is shown as unclassified. Its list of actions leaves out choose and copy, which the window also handles, and it carries no description of each kind's model; the table above and the spec are that description. terminal-delight surface --derive <transcript.jsonl> shows what the window would read out of a transcript.12
The line that comes back#
[workbench:<tag>] <action> on surface <id> · <target> — <comment>
Typed into the agent's terminal, followed by a return. · <target> appears when the action names a part, such as a hunk or an option; — <comment> when the person had written something in the composer. Line breaks and control characters become spaces. For example:
[workbench:k7f2q9ax] reject_part on surface change-847 · src/surface.rs#hunk-4 — Tube geometry shouldn't depend on terminal state.
[workbench:k7f2q9ax] choose on surface q1 · Coffee
Each is first appended to actions.jsonl in the pane's folder, with the comment as written:
{"td":"0.4","type":"action","surface":"change-847","action":"reject_part","target":"src/surface.rs#hunk-4","comment":"…"}
| Action | Button | Done by |
|---|---|---|
approve, reject | approve, reject | the agent |
accept_part, reject_part (also read as accept_hunk, reject_hunk) | accept, reject, per hunk | the agent |
comment, ask_agent | comment, ask; the composer opens first | the agent |
choose | one per question option | the agent; a question read off the agent's screen is answered by pressing keys in its picker instead |
open, open_source, copy | open, source, copy | the window; nothing is sent |
| anything else | its name, with spaces for underscores | the agent |
The agent channel#
A second, smaller protocol, TDAC 0.2, carries what Claude Code's hooks see: your prompts, its questions, your answers and its replies. scripts/install-agent-hooks.sh installs the hooks (see Install). They append to inbound.jsonl in the pane's folder, and the window turns each question into a question card and each reply into a response if the agent sent none that turn. When the bench is open, a question waits up to 540 seconds for an answer written to answers/<id>.json, so a person can answer it from the bench. bench.json in the same folder says whether the bench is open. Notifications are recorded by the hooks and ignored by the window. Codex can't use this yet. The spec is docs/spec/td-agent-channel.md.8
Limits#
| Limit | |
|---|---|
| title | 72 characters |
| id | 96 characters |
| file name | 64 characters of letters, digits, - and _ |
| surfaces per pane | 64 in memory, 512 files on disk; the oldest go first2 |
| idle sessions | a session folder nothing has written to for 30 days is removed; the window's own session never is |
| pruning | when a window starts, then every ten minutes7 |
| transcript read | the last 256 KiB |
| unclassified payload | 4096 bytes kept, 20 lines shown |
| table cell | 600 characters |
| changeset patch | 24 lines drawn per hunk |
Refusals#
The MCP route checks strictly and answers with the reason, and a refused document reaches no bench and no file. Among the sentences it can return:
missing `td` version field — this build speaks TDSP 0.4unknown kind "hologram" — this build renders response, artifact, markdown, table, architecture, changeset, decision, questiona response needs a `layman` — the plain-English explanation of the whole replyan artifact needs a `href` — an absolute path or a full URL"report.html" is relative — it would resolve against the TERMINAL's directory, not yours. Send an absolute path or a full URL.`retire` needs the `id` of the surface to take off the bench
The spec lists all of them. What a document gets back depends on the route:
| Route | Valid | JSON, but not a valid surface | Not JSON |
|---|---|---|---|
| MCP | on the bench, and the reply says so | refused, with the reason | refused: `surface` must be a TDSP document (a JSON object). |
| file | on the bench | an unclassified card carrying the reason and the raw document | nothing at all: no card and no log line, and the file is tried again every second until it parses |
| command line | written, then on the bench | written, then an unclassified card | exit 2, with a message on stderr |
| transcript | on the bench | an unclassified card | nothing |
What would prove this wrong#
Every example on this page and in the spec should land on a bench exactly as described. If one you copied is refused, lands as unclassified, or draws differently from what the page says, the page and the code disagree. Run it through present_surface to get the parser's own reason, and open an issue with the document and that reason.
Sources
- The envelope, kinds, aliases, refusals, catalogue and actions: surface.rs.
- The file sweep, the command line, file names and retention: surfacefeed.rs.
- The MCP route, its persistence and its replies: mcp.rs.
- The transcript route and the 256 KiB tail: derive.rs and mcp_tail.rs.
- Tabs, present and update, arrivals and the 64-surface cap: workbench.rs.
- The weight sentence and the escalation frame: benchdraw.rs, emphasis.rs and the strings in lang/parts.rs.
- The one-second sweep and the ten-minute prune: main.rs.
- The agent channel: channel.rs, td-agent-hooks and td-agent-channel.md.
- The spec: td-surface-protocol.md.
- The 0.5.0 write gate: mcp.rs and threshing_floor.rs.
- What open draws itself: docopen.rs and pane/doc.rs.