Skip to main content

Wire

Source of truth: the //! header of engine/crates/taji/src/wire/mod.rs, served as GET /read/routes; every_dispatched_route_literal_is_in_the_header (engine/crates/taji/src/wire/tests.rs) fails when the router dispatches a route the header omits. This page holds the conventions.

The kernel's one interface is HTTP and WebSockets on loopback, used by the window, the MCP bridge (agent/), taji ui and scripts.

Listeners​

  • One listener, 127.0.0.1:<port>, opened only when TAJI_WIRE=<port> is set; 0 takes a free port. A non-port value or a taken port ends the boot. Unset, clients use 7780 (configuration).
  • Files. Once bound, the kernel writes wire-port, then wire-token and agent-token (mode 0600 on Unix; Windows: the state dir's ACL), in the state dir (configuration). A connection made before the kernel serves waits rather than being refused.
  • Protocol. HTTP/1.1, one request per connection, bodies up to 16 MiB (413 too_large), a request head up to 64 KiB (431 head_too_large). Every answer carries x-taji-version.
  • Tokenless: the web page and sheet (/app/) and a plugin's window half (/plugin/<id>/...).
  • Refused before any work: a Host other than 127.0.0.1 or localhost (421 host); a proxy ask (405 not_a_proxy); a missing or wrong token (401 unauthorized).
  • A process plugin never dials it: it speaks taji-plugin/1 (protocol); the sandbox's limits are in security.

Token scopes​

The token in x-taji-token names the caller: 32 random bytes in hex, new each launch.

  • local: the window's main process, taji-link, taji ui, scripts; <state dir>/wire-token.
  • agent: the MCP bridge; <state dir>/agent-token. Budgeted at 600 GETs and 120 other requests in a sliding minute (429 rate_limited, naming budget and rest_after).
  • page: the window's page; bought once with a nonce at POST /app/token, kept in memory. A ui/open nonce with the window key buys the by-hand token.
  • sheet: the sheet (keys, vault, installs); bought the same way, from ui/sheet's nonce.

Reads answer every scope, except GET /read/plugins/index and GET /read/agent/search (not agent), GET /read/ui/capture (not sheet), and /ws/agent and /ws/voice (local and page only); POST /fetch refuses sheet. Each refusal is 403 scope, and GETS in engine/crates/taji/src/wire/routes.rs is the list. Every POST is admitted by its route's scopes in the same file before any handler (403 scope; 404 unknown_route). schema/wire.json names each route's scopes. Gates may hold every send but the by-hand token's, which alone approves (approvals/<id>/approve).

Requests and answers​

  • GET / is the root snapshot. GET /read/<node> reads a node of the state tree, GET /describe/<node> answers {"line"}.
  • GET /get/<product>?... reads market data (data), GET /held what the store holds, POST /fetch buys. An item is kind:text (equity:AAPL).
  • POST /verb/<node>/<verb> takes a JSON object. A plain verb answers 200 Changed, {"node", "seq"?}; a route that names its own type answers that; 202 is an outcome that arrives later on /ws/live, or Awaiting, a verb parked for approval.
  • Times are UTC seconds in a field ending _utc; a price or size is a decimal string; absent is null.

A read with the local token, the port and token taken from the state dir:

curl -s -H "x-taji-token: $(cat "$TAJI_STATE_DIR/wire-token")" "http://127.0.0.1:$(cat "$TAJI_STATE_DIR/wire-port")/read/ui"
ui.json
{
"display_tz": "America/New_York",
"stage": "paper"
}

Captured 2026-12-03 on a keyless headless kernel.

Refusals​

Every refusal is {"error": <code>, "reason": <prose>} plus the fields a row names. error matches ^[a-z_]+$, one per condition; reason is for a person. 400 bad_ask is a bad word or body; 404 not found (no_node); 409 an ask the held state refuses (declined); 422 not_linked; 429 rate_limited; 500 io. A data read keeps its ReadError codes. The codes are a closed set, each answered with one status: schema Code in schema/wire.json (the Code union in @taji/wire) lists them, and GET /read/routes names the ones each route answers. A plugin's own refusal, marked by plugin, carries the plugin's own code and status.

Arrow answers​

The typed data products (the header's GET /get/<word> rows, one per product) answer 200 application/vnd.apache.arrow.stream: one IPC stream of one batch, an empty answer a zero-row batch. Prices, sizes and volumes are Decimal128(38,10). Schema metadata carries source and provider per item, summary, missing beside served rows, and cursor on a clamped page, read again as GET /get/<product>?cursor=<id>; get/bars adds timeframe and adjustment. engine/crates/taji/scripts/wirearrow.py is a pyarrow reader.

WebSocket feeds​

Every socket refuses a foreign Origin (403). The first message, within 5 s, is {"type":"auth","token":...}, else the socket closes 4401. Every kernel frame is binary: a u32 little-endian header length, the header's JSON, then Arrow IPC bytes where there are rows. A frame unread for 30 s closes the socket 4409. Past its auth, /ws/live, /ws/agent and /ws/market ping every 15 s (/ws/market every second) and close 4408 a client unheard for 45 s.

  • /ws/live is the change feed. hello carries seq; then changed frames (at most every 16 ms) name the paths that moved, for a client to reread with GET; failed and lagged frames follow, and a beat every 10 s. Auth may carry since, the last seq heard: the kernel answers the paths changed after it, or resync.
  • /ws/agent carries the conversation's chats; /ws/voice the page's audio to a voice provider, and its dispatch and replies back. An agent or sheet token closes either 4403 scope after its auth.
  • /ws/market carries rows. It also takes x-taji-token on the upgrade, then needs no auth message. The client sends stream, unsubscribe and get; the kernel answers Arrow rows frames (history first, then live) and status frames.

Plugin routes​

A plugin's verbs are rows in the same catalog: each manifest verb names a route and the scopes that may call it (local and page where it names none). A route that could bind a core verb's is refused at registration. GET /read/plugins lists the plugins (manifest).

Stability​

The wire is schema/wire.json, an OpenAPI 3.1 document a kernel serves at GET /read/openapi; the plugin contract is schema/taji.json. What may change, and how a client learns of it, is Compatibility.

The MCP tools​

agent/src/mcp/stdio.ts serves nine tools. A catalog row's effect names the tool that sends it (TOOL_OF in agent/src/mcp/catalog.ts); a plugin's verbs are asks rows and its products read rows, never tools of their own.

ToolRoute kind
describeGET /read/routes, the catalog
readany GET route, effect read
callPOST, effect write
commitPOST, effect asks
stagePOST, effect stage (trading routes no venue hears)
orderPOST, effect order (trading routes a venue hears)
wait/ws/live, a change under a path
link_chooseGET /read/link; the bridge's own, no wire route
ui_openGET /read/flows; starts taji ui, no post