Reiki

Security proxy for agent and LLM traffic: isolates keys, filters what leaves, keeps access reliable

View the Project on GitHub ddproxy/reiki

reiki top

reiki top is a live terminal view of key health for every instance under [peers.NAME]. It reads the same /v1/health and /v1/health/stream as reiki peers, with the same per-peer token and CA rules.

The default screen is a peers-by-providers matrix: one row per peer, one column per provider, then host load, disk and sessions. Problem peers sort first. Around it the screen has a header, a row of provider tabs, a cooling panel when something is cooling, and at 28 rows or more a chart row. The selected peer’s detail card (keys, cooldowns, class, last error) opens in a bordered pane where the chart row is.

It is read-only: nothing here changes a key or serves traffic.

Build

Release binaries and make install include reiki top. A plain cargo build leaves it out: it is the top cargo feature, not in the default set, and implies peers:

cargo build --features top

Without the feature the subcommand and its --help entry are absent.

Configure

It needs [peers] enabled = true and at least one [peers.NAME] table, exactly as reiki peers; each entry must point at an instance that publishes health and at a token file that instance issued (see peers).

Use

reiki top                 # live matrix; q quits
reiki top --full          # live per-peer text view instead
reiki top --once          # poll every peer once, print the matrix as text and exit
reiki top --once --full   # poll once, print the per-peer text view
reiki top --provider zen  # show only the zen column and peers that have it
reiki top --interval 2    # redraw every two seconds instead of every second

The screen

╭reiki top v0.10.3─────────────────────────────────────────12:00:00Z╮
│live · 3 of 3 peers fresh                                          │
│q quit  j/k peer  Enter detail  f filter  u metric  w window  m ...│
╰───────────────────────────────────────────────────────────────────╯
 All │ gemini │ zen │ openrouter
╭Peers──────────────────────────────────────────────────────────────╮
│Fleet 3/3 fresh   gemini 2/2   zen 1/2   openrouter 0/1   [req 1h] │
│          gemini        zen           openrouter  load  disk  sess │
│  peer-b  ■ ······      ·             ◐ ▁▂▃▄▅▆      -     -     -  │
│> peer-c  ■ ······+2    ■ ▂▃▄▅▆▇ 45s  ·             -     -     -  │
╰───────────────────────────────────────────────────────────────────╯
╭Cooling────────────────────────────────────────────────────────────╮
│  peer-c  zen  ◐ cooling  [▅▅▅░░]  45s  last 429                   │
╰───────────────────────────────────────────────────────────────────╯
╭Load · fleet──────────────────────────╮╭Keys─────────────────────╮
│  (line chart of the fleet's load)    ││ healthy cooling disab  │
╰──────────────────────────────────────╯╰────────────────────────╯
                       [□ detail] [req 1h] [chart: load]

The matrix

Inside the Peers panel:

Failures

Every peer’s health document carries a failures object: counts of recent key failures by class over an in-memory ring of at most 64. The detail card prints those counts as failures: rate_limited 2 transient 1; names, streams and bodies are never published, so a remote peer can only be compared, not investigated.

The full recent-failure list is shown only for the local instance, and only when REIKI_ADMIN_TOKEN holds its admin token (together with [admin] listen in the config). reiki top finds the local peer by matching its published instance to [peers] instance, or reiki when that is not set. For that peer the card adds one line per failure: time, stream, key, status, class, cooldown left and the scrubbed body snippet. A remote peer’s card keeps the counts, even when the local admin listener is configured. If the admin listener is missing, unreachable or refuses the token, the counts still appear and only the rows are absent.

See GET /failures for the fields and the reiki failures command.

Keys

In the matrix:

In the full view (v or --full):

Live mode needs stdout to be a terminal; otherwise it prints one line and exits 2, so use --once.

The frame’s widgets come from the fw-tui crate, pinned by revision in crates/reiki-top/Cargo.toml. Colour follows NO_COLOR.

Names and columns

Peer and provider names come from the network. Control characters and invisible format characters (bidi overrides, zero-width marks) are shown as ?, and widths are measured in terminal columns, so wide characters stay aligned. At most 32 provider columns are drawn; the fleet line adds +N more for the rest.

Narrow terminals

The matrix drops the Ver column first, then the last-hour gauge, then shortens provider headers to six, then three characters, drops the sparkline, and as a last resort prints one chip line per peer with only the providers it uses. Below 20 columns it draws the fleet line and peer names. It never draws past the terminal width.

The screen gives up its panels before it cuts the matrix. As the height drops it loses, in order: the chart row (below 28 rows), the cooling panel (when the bare matrix would no longer fit beside it), the tab row, and then the header folds to one line. The Peers panel shrinks last, and only when even the bare matrix does not fit does it clip rows. The detail pane keeps its bottom third of the screen as before. Widths below 20 columns still draw the names-only matrix. Any size down to 0 by 0 draws without panicking.

--once

--once polls each peer once and prints the matrix as plain text, 100 columns wide and without colour. --once --full prints the per-peer text view instead. It exits 0 when at least one peer answered, 1 when none did, and 2 on a config problem.