Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Shells: terminal, web, native and hardware

A shell is a client surface for ID: it presents a node’s files and worlds to a person and turns that person’s actions back into protocol frames. ID has four shells, and they share one contract. The machine-readable form of that contract is pkgs/id/contract/shell-contract.v1.json — contract name id-shell, version 1, revision 15 — defining the /id-world/1 ALPN protocol: three transports (an Iroh QUIC stream, WebSocket at /ws/world, and SSH exec id-world/1), a 1 MiB maximum frame, session phases (opening, query, install, joined), six frame classes (event, ephemeral, query, control, admin, delegation), and the full client and server frame vocabulary. A companion conformance suite, shell-suite.v1.json, names the four shells — terminal, browser, native, hardware — with each shell’s presented and sent frame sets, and golden session transcripts (sessions/terminal.jsonl, 5 frames; sessions/native.jsonl, 7 frames) that shells are checked against. Host-side, the contract is owned by id_worlds::shell_contract.

The four shells differ in what they can present. The rule that keeps them one system is the fallback rule: a shell without a renderer for a surface uses that surface’s text projection. No shell invents frame kinds; the native and hardware shells below both state that explicitly in their own terms.

The terminal shell: CLI and REPL

The terminal shell is the id binary itself: 2 binaries in the workspace produce the command surface (the id binary and the id-native-shell binary below), with 32 top-level commands and 113 leaf commands in the surveyed CLI. The command chapters of the reference section cover that surface; the concept is that the terminal is a full shell, not a debug tool — it joins worlds, administers them, and speaks the same session protocol as every other shell.

Running id with no subcommand starts the REPL (in src/main.rs, the no-command case calls run_repl). The REPL is also reachable as id repl [NODE], with the hidden alias id shell. It has its own parser, in crates/id-cli/src/repl/ — dispatch in runner.rs, line preprocessing in input.rs, context in crates/id-cli/src/commands/repl.rs — and 20 command groups in the surveyed surface. Its modes are auto-detected and printed in the banner as id repl (<mode>): a local mode against the node’s own store, and RemoteNode mode when started as id repl <NODE_ID> against a running serve.

REPL behaviour differs from the one-shot CLI in ways a user feels. A failed command prints error: <e> and the REPL continues; the REPL never exits non-zero because a command failed. An unrecognised line prints unknown command: <line> plus type 'help' for available commands. History is rustyline, in memory only — no history file is configured. Some commands exist only in the REPL (delete, rename among them), and the REPL has no serve, world, group, doc, claim or key groups; those are one-shot CLI commands, started before entering the REPL. World sessions from the terminal use the world session protocol directly: the client frame vocabulary has 43 kinds and the server’s 35, shared with the web shell’s world bridge and the Iroh transport.

The web shell

The web shell is the id-web crate served by id serve: an Axum server whose frontend (pkgs/id/web, Bun and TypeScript) is embedded into the binary at compile time with rust-embed. It is off by default (--web off), binds 127.0.0.1 by default, and serves on port 3000 by default. Every router passes through the security layer in crates/id-web/src/security.rs: a loopback bind by default, a Host allow-list on loopback binds (localhost, 127.0.0.1, ::1, plus operator extras), a same-origin check on any request carrying an Origin header, and an optional gate token accepted as the id_token cookie, an Authorization: Bearer header, or a ?token= parameter that sets the cookie and redirects to the clean path.

The web shell has two faces. The Explorer face is the file and document UI: 54 distinct paths and 58 method bindings in the main router — file browser, ProseMirror collaborative editor over the /ws/collab/{doc_id} WebSocket (binary MessagePack, tags 0–11), tag editing with the /ws/tags broadcast socket, identity registration, the groups and peers pages, and the program gallery. The world face is the world bridge: an HTTP surface (/api/world/invite, /api/world/host-view, /api/world/metrics, /api/world/directory) plus the world session WebSocket at the socket named by the app’s [interfaces.web] binding — default /ws/world, default page route /world. A program-only router (10 paths) serves one world pinned to one listener, and publication mounts serve that same router under a mounted prefix.

The frontend renders in exactly three DaisyUI themes, all on #000000: sneak (the default, blue #00aaff), arch (green #00ff00) and mech (orange #ff6600), stored in the localStorage key id-theme and cycled with Alt+T. The older WEB.md manual describes only the file and editor face of this shell; it never mentions the world or gallery surfaces, and its route table covers less than half of the shipped router (survey disagreements WEB-2, WEB-3, WEB-15).

The native shell: id-native-shell

The native shell is the F13.6 native reference shell (design #788), shipped as the id-native-shell binary in crates/id-native-shell. It is a Bevy desktop client for the F13.1 shell contract. It is a workspace member but not a default member, so a plain cargo build in pkgs/id/ never acquires Bevy or the desktop system libraries. Its production dependency is the facade crate alone (id, with default-features = false, features = ["world"]), plus Bevy 0.19 and Iroh; it is, with the hardware shell, one of only two production consumers of the facade outside the workspace’s internal graph (survey disagreement LIB-12 records that the architecture table hides this edge direction).

The native shell is a client only. It connects to a world host over the existing session protocol — its session code calls id::world_net::WorldClient::connect — renders the host’s view frames, and emits only the client frames the contract already names: input, paste, resize, chat. It adds no frame kinds, needs no host change, and no shell frame depends on the guest ABI. Its library surface includes the frame builders (input_frame, input_frame_with_revision, paste_frame, resize_frame, chat_frame, agent_join_frame, screen_subscribe_frame), the present(data, surface) view fallback, and run_session, the live WorldClient session loop.

Its modules are render (a styled model and Bevy UI renderer for validated surfaces), scene (validated scene/1 surfaces as 3D entities via bevy_pbr), audio (validated audio/1 surfaces as scheduled cue entities — presentation state only; the crate’s feature set carries no audio output backend), widget (validated widget/1 surfaces as placed control entities), events, form, providers and session. Shells without a renderer for a surface keep the surface’s text projection; that fallback rule is uniform across scene, audio and widget.

Current state, from the library survey: steps 1 and 2 of design #788 are in the code. Step 1 is the isolated package, identity and connection bootstrap, contract frame builders, view fallback, and a transcript fixture checked against the machine-readable contract. Step 2 is the window and render plugin set and the live session loop; tests/live_session.rs proves the durable-outcome half of the parity criterion against a live host. The binary parses --node and --capability and exits with code 2 on bad arguments or a failed session spawn. One environment variable is specific to this shell: ID_SHELL_FILE_READ_ROOT, read in crates/id-native-shell/src/main.rs; unset, the native shell’s file-read root is not additionally restricted or configured by environment. The native shell also declares the only client provider in the conformance suite: client.file.read.

The hardware shell: id-hw-shell

The hardware shell is crates/id-hw-shell: an ESP32-class hardware shell spike (more-shells v1 slice 3, #10929; design doc/2026-11-10T20-40-00Z_design_more_shells_v1, section 3). It is one file, src/lib.rs at 996 lines, with no submodules. Like the native shell it is a workspace member but not a default member, and its production dependency is the facade alone (id, features = ["world"]); id-worlds with the sandbox appears only in dev-dependencies, for the in-process host harness in its tests.

The hardware shell is the F13.1 contract reduced to exactly the subset that survives at ESP32-class device size:

  • Presence: a wake-time read of the snapshot’s participant list, with journal joined and left events folded on top.
  • Journal-head state in compressed form: the newest durable sequence folded, nothing else.
  • Confirm and act: answer a presented form choice with a form_result frame — submit or cancel, choice selections, yes/no.

Rich rendering, free text and world hosting are excluded by name in its capability_statement(), and the code makes the exclusions real: the only client frames the crate can build are join and form_result, and a form requiring free text is refused with HwError::FreeTextExcluded. Every built frame is checked against the embedded F13.1 contract before it is returned, and every folded frame is checked on the way in. Its API is HwShell (new, head, presence, diverged, last_status, choice), with PresentedChoice and SelectableField describing a presented choice, and the constants CONTRACT_NAME = "shell" and CONTRACT_VERSION = 1.

The shell is transport-free by design: the frame builders and the fold are pure functions, so the same code runs over a real Iroh session on a device — or on the paired full node the design names — and over recorded frames in tests. It builds no frames for any transport because it owns no transport. Its power posture follows: no live session is held open. The device wakes, joins, folds to the journal head, acts if a choice is presented, and disconnects. If a resume replay does not continue contiguously from the recorded head, continuity is unprovable, and the shell discards its folded presence and waits for a fresh snapshot.

Its state must be stated as plainly as the hosted edition’s: it is a spike, complete at its stated subset — not a port in progress. The exclusions are the deliverable.

One contract, four sizes

The four shells are one conformance story at four sizes: the terminal and web shells carry the full surface; the native shell carries the full session protocol with rich surfaces and a text fallback; the hardware shell carries presence, head and confirm/act only, and says so in its capability statement. The forward design for shells — presentation tiers, the rendering pipeline, input models, Android and further embedded surfaces (43 records in the survey’s mapping) — is carried by the design chapter shells and client surfaces.