Skip to content

Architecture

Alper Sarıtaş edited this page Dec 4, 2026 · 3 revisions

omo is TypeScript. From a checkout, Node 26 runs src/ directly; the npm package carries dist/, compiled by tsc, because Node does not strip types from files under node_modules. It is built on the libraries of pi, pinned to exact versions. It does not use the pi app or pi-coding-agent.

Library Supplies
@earendil-works/pi-ai Model providers, the built-in model list, sign-ins, streaming, retry policy
@earendil-works/pi-agent-core The agent loop, tool hooks (beforeToolCall, afterToolCall) and events
@earendil-works/pi-tui Terminal components: editor with completion, selectors, images, renderLatex

omo owns the screen: nothing is rendered unless omo's code prints it.

How a query flows

flowchart LR
    P[Prompt<br/>tui.ts] -->|query| S[Session<br/>session.ts]
    S -->|record query| L[(Ledger<br/>ledger.ts)]
    S -->|map task| G[Guide<br/>guide.ts]
    G -->|read, grep, find, ls| R[Reading room<br/>tools.ts, room.ts]
    G -->|search_map, assume_reader,<br/>offer_paths| T[Guide tools<br/>guide-tools.ts]
    T -->|widen pointers| U[Units<br/>units.ts]
    T -->|map| S
    S -->|record map| L
    L -->|rebuild| K[Understanding graph<br/>graph.ts]
    K -->|fringe| S
    S -->|paths| V[View<br/>view.ts] --> P
Loading
  1. The TUI passes the query to the session. The session records the query, reusing its id if the same text was typed in this folder before.
  2. The session asks the guide to map it, giving it the model, the thinking level, the record (ledger.forGuide) and, when they are on, the outside tools.
  3. The guide runs a fresh pi-agent-core agent with omo's tools. omo's hooks count tool calls against the budget, end the turn when the finishing tool returns a result, and emit one event per tool call. The TUI shows those events with only the sources each call looked at.
  4. offer_paths widens each pointer to whole units, checks it against the catalogue, and refuses circular links. Its first call returns a preview, and the second returns the map.
  5. The session records the map in the ledger, updates the understanding graph, and computes the fringe: the next steps to show.
  6. The view turns passages into what the terminal shows, printed from the source files.

A note follows the same route through the judge task. Its judgement is recorded, then put to you through an approval step (Approve). Your answer is recorded as a separate verdict, and only then does the judgement count in the graph.

Modules

File Responsibility
src/main.ts Entry point: opens the folder given and starts the interface
src/tui.ts Terminal interface, built from pi-tui's components and omo's own
src/components.ts omo's selectors, sign-in dialog and message boxes
src/theme.ts Colours, light and dark
src/commands.ts The prompt's commands and their completion
src/view.ts How passages, marks and the record's counts are put in front of you
src/session.ts What every frontend uses: opens the folder and the record, runs one task at a time, keeps what to show next, and is the only writer of the record
src/guide.ts The hidden guide: its instructions, one task on a fresh agent, retry, the tool budget, usage, and the events the TUI shows
src/guide-tools.ts search_map, assume_reader, offer_paths, judge_claim, give_transcript, and the outside search and add tools
src/tools.ts The guide's read-only file tools (read, grep, find, ls) in plain Node, confined to the reading room
src/graph.ts The understanding graph: walked and understood, fading, circle refusal, the fringe
src/ledger.ts The append-only record and what the guide is told of it
src/units.ts Cutting reading copies into units, widening pointers, finding units again after an edit
src/sources.ts Turning a pointer into verbatim lines, or refusing it; quoting and re-finding passages
src/room.ts Keeping the reading copies in step with the sources folder; adding web sources and dropped files
src/pdf.ts PDF text per page and page-region images (mupdf)
src/web.ts Fetching a page with a timeout and size limit, extracting its content, linking to a passage
src/math.ts Drawing display formulas (MathJax, resvg) and writing short ones in Unicode
src/media.ts Reading your files whole for a model, rewriting requests to carry PDFs and audio, stripping photo metadata
src/search.ts Searching arXiv, Wikipedia, OpenAlex and Brave; search keys
src/models.ts The models omo can use and the sign-ins to them (auth.json, models.json, environment, keychain)
src/choices.ts Which model and thinking level each task uses
src/auth.ts /login and /logout
src/credentials.ts Locked, atomic writes of auth.json
src/config.ts The settings folder, the store's location, config.json and its limits
src/store.ts What the store holds and its size; setting a ledger aside; deleting, for /data
src/identity.ts The name and version omo gives providers

Design rules the code keeps

  • The model's text never reaches the screen. Finishing tools take pointers, and the program prints the lines. Tool-call lines are worked out by omo from the call's arguments, never from model prose. Transcripts are the only model output shown, and they go into your prompt for you to correct.
  • The session is the only writer of the ledger. The graph and the history are derived from the ledger, never stored apart from it.
  • The guide sees one folder. Its tools are confined to the reading room, and passages from other folders reach it only as a place and a short quote.
  • No process is started except the browser opener (for sign-in) and, on macOS, the keychain lookup. A test enforces this.
  • Nothing is written outside omo's own folders, and nothing into the sources folder except a file you add.

Clone this wiki locally