Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions cabinet-lite/architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
title: Architecture
description: Process layout, modules, routes, and data flow of cabinet-lite.
sidebar_position: 3
---

<!-- sources: index.ts, server.ts, feed.ts, fleet.ts, plates.ts, ui/app.js, ui/index.html, tsconfig.json -->

## Process layout

cabinet-lite is one Node (>= 24, ESM) process. TypeScript compiles to
`dist/` (`tsc`, `module: nodenext`, strict). No framework, no dependencies
at runtime — `node:http`, `node:fs`, and `fetch` only.

| Module | Role |
|---|---|
| `index.ts` | entrypoint: starts the server, logs the listen line, handles SIGINT/SIGTERM via `instance.stop()` |
| `server.ts` | HTTP server, snapshot assembly, SSE broadcast, plate refresh loop |
| `fleet.ts` | roster loading, health polling, transition detection |
| `plates.ts` | plate fetchers (`fetchCabinetTasks`, `fetchFleetHealth`) and their types |
| `feed.ts` | in-memory ring buffer (`Feed`, cap 500, newest first) |
| `ui/index.html` | static shell: all CSS inline, no build step |
| `ui/app.js` | browser client: SSE listener + renderers |

## HTTP surface

Exactly four routes, served by a plain `http.createServer` handler.
Everything else is `404 not found`.

| Route | Method | Meaning |
|---|---|---|
| `/` | GET | `ui/index.html` |
| `/ui/app.js` | GET | `ui/app.js` |
| `/api/snapshot` | GET | full snapshot as JSON |
| `/api/stream` | GET | SSE; each event is `event: snapshot` with the full snapshot as data |

The server listens on `127.0.0.1` only. There are no POST/PUT/DELETE
handlers anywhere in v1 — read-only by absence.

## Snapshot shape

`server.ts` assembles one `Snapshot` object per render:

- `roster` — the public roster projection (`fleet.ts` `publicRoster()`):
OpenClaw, Hermes, and generic slices with `token`, `ssh_user`, and
`binary` stripped.
- `health` — name to health result for every probed agent (OpenClaw +
generic; `ok`/`status` or `error`).
- `hermes` — name to `"ssh"` for Hermes entries (no HTTP probe exists for
them in v1).
- `plates` — `needs_you` and `fleet_health` plate objects (see
[plates](./plates.md)).
- `feed` — the ring buffer contents, newest first.

`/api/snapshot` serves this from cache only — no polling happens inside a
request (the test suite budgets it under 50 ms).

## Data flow

```text
roster files agent gateways Cabinet / fleet-health
(env-pointed) (OpenClaw + generic) (env-pointed URLs)
| | |
v v v
+--------------------------------------------------------------+
| fleet.ts plates.ts |
| loadRosters() fetchCabinetTasks() |
| poll every 10s fetchFleetHealth() |
| (250ms stagger, 5s timeout) every 30s |
| | | |
| v v |
| healthCache() + onTransition cabinetPlate/fleetHealthPlate|
| | | |
| +------------+--------------+ |
| v |
| server.ts snapshot() |
| v |
| feed.ts (ring buffer, 500 cap) <--- transition entries |
| v |
| broadcast: every 10s + immediately on each transition |
+--------------------------------------------------------------+
|
| SSE (event: snapshot) / GET /api/snapshot
v
browser (ui/app.js)
EventSource("/api/stream")
renders banner, tiles, rhythm, feed, side rail
```

## UI client

`ui/app.js` opens one `EventSource("/api/stream")` and re-renders on every
`snapshot` event. It skips identical frames (`lastRaw` check) and wraps its
render pass in a try/catch: a bad frame never takes the box down — the next
snapshot re-renders. All dynamic strings are HTML-escaped before insertion.
The clock renders in `America/New_York`.

## Shutdown

`index.ts` registers SIGINT/SIGTERM handlers that call `instance.stop()`:
stops the fleet poller and plate loop, clears the broadcast interval,
destroys connected SSE clients, and closes the server.
164 changes: 164 additions & 0 deletions cabinet-lite/configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
---
title: Configuration
description: Full environment variable and roster file reference for cabinet-lite.
sidebar_position: 8
---

<!-- sources: server.ts, fleet.ts, plates.ts, docs/CONFIG.md -->

cabinet-lite is configured entirely through environment variables and
roster files. It has no config file of its own.

## Environment variables

| Var | Default | Meaning |
|---|---|---|
| `FLEET_BRIDGE_AGENTS` | (unset) | path to the OpenClaw roster JSON |
| `FLEET_BRIDGE_HERMES` | (unset) | path to the Hermes roster JSON |
| `FLEET_BRIDGE_GENERIC` | (unset) | path to the generic-runtime roster JSON |
| `CABINET_URL` | (unset) | Cabinet base URL, read-only; unset degrades the `needs_you` plate |
| `FLEET_HEALTH_URL` | (unset) | fleet-health aggregate base URL; unset degrades the `fleet_health` plate |
| `PORT` | `9100` | listen port (read once at startup) |

All roster paths are read at startup into memory; the files are re-read
only on process restart. URLs accept any base the Node `fetch` can reach
(`new URL(path, base)` resolution). The server always binds `127.0.0.1` —
there is no host/interface option.

Programmatic alternatives: `startServer()` accepts `port`, `agentsPath`,
`hermesPath`, `genericPath`, `cabinetUrl`, `fleetHealthUrl`, `uiDir`,
`pollIntervalMs`, and `plateIntervalMs` directly, overriding the env vars.
Fixed intervals in code: fleet poll 10 s, plate refresh 30 s, SSE broadcast
10 s.

## Roster files

All rosters are `{"agents": [...]}` documents in the same shape as
fleet-bridge's `agents.json` / `hermes-agents.json`.

### OpenClaw roster (`FLEET_BRIDGE_AGENTS`)

```json
{
"agents": [
{
"name": "<openclaw-agent>",
"role": "repo janitor",
"tier": "worker",
"model": "glm-5.3-flash",
"port": 18800,
"host": "agent-host-1",
"token": "gateway-token-here"
}
]
}
```

| Field | Required | Meaning |
|---|---|---|
| `name` | yes | agent name — key for health lookups and feed entries |
| `role` | yes | one-line role, shown on the lever tile |
| `tier` | no | fleet tier (e.g. `worker`) |
| `model` | no | model the agent runs |
| `host` | yes | hostname reachable from the box |
| `port` | yes | gateway port — polled at the health path |
| `token` | yes | gateway token; never leaves the box (v2 use) |
| `runtime` | no | display label; defaults to `openclaw` |
| `healthPath` | no | probe path; defaults to `/health` |

### Hermes roster (`FLEET_BRIDGE_HERMES`)

```json
{
"agents": [
{
"name": "<hermes-agent>",
"role": "PM",
"model": "gemini-flash",
"host": "agent-host-1",
"ssh_user": "deploy-user",
"binary": "hermes"
}
]
}
```

| Field | Required | Meaning |
|---|---|---|
| `name` | yes | agent name |
| `role` | yes | one-line role, shown on the lever tile |
| `model` | no | model the agent runs |
| `host` | yes | host the agent lives on |
| `ssh_user` | yes | SSH user for Hermes invocations (v2) |
| `binary` | yes | Hermes binary path/name on the host (v2) |
| `runtime` | no | display label; defaults to `hermes` |

Hermes entries are not polled in v1 — they render static `idle` tiles and
report `"ssh"` status in the snapshot.

### Generic runtime roster (`FLEET_BRIDGE_GENERIC`)

Any HTTP-probeable agent joins the box as a roster line — the runtime label
is data, not a code branch. Generic entries poll exactly like OpenClaw
entries (same timeout, stagger, cache, live-down transitions) at their own
`healthPath`. Tokens are optional; gateways may be unauthenticated.

```json
{
"agents": [
{
"name": "search-agent",
"role": "search",
"host": "agent-host-1",
"port": 18080,
"runtime": "khoj",
"healthPath": "/status"
},
{
"name": "collector",
"role": "otel collector",
"host": "agent-host-1",
"port": 14317,
"healthPath": "/api/status"
}
]
}
```

| Field | Required | Meaning |
|---|---|---|
| `name` | yes | agent name |
| `role` | yes | one-line role, shown on the lever tile |
| `host` | yes | hostname reachable from the box |
| `port` | yes | port on the host |
| `healthPath` | yes in practice | probe path; omitting polls `/health`. Must return JSON (e.g. an object with `ok: true`) — text endpoints render the tile `down` |
| `runtime` | no | display label; defaults to `openclaw` |
| `model` | no | model the agent runs |
| `token` | no | optional gateway token (never leaves the box) |

Entries without `runtime` default by file: OpenClaw and generic lines to
`openclaw`, Hermes lines to `hermes`. The UI badge map styles
`openclaw`/`hermes`/`mcp`; any other label renders in the generic steel
badge style, and the RUNTIMES side-rail lists every distinct label present.

## Plate enablement

Plates are enabled by URL, not by flags. Setting `CABINET_URL` /
`FLEET_HEALTH_URL` turns the corresponding plate on; leaving them unset
degrades it to its error state (the UI renders a bordered empty slot).
There is no separate enable/disable toggle. See
[plates](./plates.md) for the full degrade contract.

## Secrets never reach the browser

`token`, `ssh_user`, and `binary` are stripped from every API response.
The server builds the public roster projection before any snapshot or SSE
frame leaves the process. The test suite asserts the raw snapshot JSON
never contains these values.

## Port and host options

- Port: `PORT` env var or the `port` server option; default `9100`.
- Bind address: hardcoded `127.0.0.1`. To expose the box beyond loopback,
front it with a reverse proxy — the process itself will never listen on
an external interface. Note there is no authentication on any route.
72 changes: 72 additions & 0 deletions cabinet-lite/getting-started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
title: Getting started
description: Prerequisites, install, run, and first-run checklist for cabinet-lite.
sidebar_position: 2
---

<!-- sources: package.json, server.ts, index.ts, README.md, docs/CONFIG.md -->

## Prerequisites

- Node.js >= 24 (enforced by `engines` in `package.json`)
- Two roster files, same shape as fleet-bridge's `agents.json` /
`hermes-agents.json`. See [configuration](./configuration.md) for the
schemas. A third generic-runtime roster is optional.
- Reachable backends if you want both plates live: a Cabinet instance and a
fleet-health aggregate (both optional — unset URLs degrade the plates, see
[plates](./plates.md)).

## Install, build, run

```bash
npm ci
npm run build
npm start
```

`package.json` scripts:

| Script | Command | Meaning |
|---|---|---|
| `build` | `tsc` | compile TypeScript to `dist/` |
| `start` | `node dist/index.js` | run the box |
| `dev` | `tsc --watch` | rebuild on change |
| `test` | build + `node --test "dist/test/*.test.js"` | run the test suite |

## Environment variables

| Var | Required | Default | Meaning |
|---|---|---|---|
| `FLEET_BRIDGE_AGENTS` | yes (for OpenClaw agents) | unset | path to the OpenClaw roster JSON |
| `FLEET_BRIDGE_HERMES` | yes (for Hermes agents) | unset | path to the Hermes roster JSON |
| `FLEET_BRIDGE_GENERIC` | no | unset | path to the generic-runtime roster JSON |
| `CABINET_URL` | no | unset | Cabinet base URL, consumed read-only; unset = `needs_you` plate degrades |
| `FLEET_HEALTH_URL` | no | unset | fleet-health aggregate base URL; unset = `fleet_health` plate degrades |
| `PORT` | no | `9100` | listen port |

Notes:

- With both roster vars unset, the box starts with an empty roster — valid,
but the tile wall renders its empty state.
- A missing or malformed roster file is not a startup error: it loads as an
empty agent list. See [troubleshooting](./troubleshooting.md).
- `PORT` is read at startup only (`server.ts` falls back to `9100`).

## First run

The box binds to loopback only — it listens on `127.0.0.1`, never on all
interfaces.

1. Start the process. On success it logs
`cabinet-lite: listening on port 9100` (or your `PORT`). On a bind error
it logs `cabinet-lite: <message>` and exits 1.
2. Open `http://127.0.0.1:9100`.
3. Checklist:
- Top-right clock ticks and shows `LIVE` (SSE connected).
- NEEDS YOU banner shows either chips, the clear message, or the
offline message — never "connecting…" for more than a few seconds.
- Lever tiles appear for every roster entry; each has a state dot.
- The PULL button in the invoke panel is disabled with title
`GO-gated — v2`.
- `GET /api/snapshot` returns JSON and does not contain any roster
`token`, `ssh_user`, or `binary` values.
57 changes: 57 additions & 0 deletions cabinet-lite/intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
slug: /
title: cabinet-lite
description: The Leverframe signal box — a read-only cross-runtime fleet dashboard for OpenClaw, Hermes, and MCP agents.
sidebar_position: 1
---

<!-- sources: README.md, package.json, server.ts, plates.ts, ui/app.js, docs/CONFIG.md -->

cabinet-lite is a read-only dashboard for an agent fleet. It is the
"Leverframe signal box": one page, rendered as a flat industrial panel, that
shows what a fleet of OpenClaw, Hermes, and MCP agents is doing right now.

It is a single Node process that loads roster files, polls agent health
endpoints, polls two backend plates, and pushes a snapshot to any connected
browser over Server-Sent Events. There is no database, no auth layer, and no
write path.

## The four questions

The box is organized around four questions:

| Question | Surface | Status in v1 |
|---|---|---|
| What needs me? | The `needs_you` plate (attention banner) | live |
| Who's free? | Lever tiles with live/down/idle states | live |
| What happened? | The pull feed with runtime provenance | live |
| Act from here? | The invoke panel | wired, GO-gated OFF |

See [plates](./plates.md), [lever tiles](./lever-tiles.md), the
[pull feed](./pull-feed.md), and the [invoke panel](./invoke-panel.md).

## Read-only v1

v1 ships no invoke endpoint. The HTTP surface is exactly four routes:
`/` (the UI shell), `/ui/app.js` (the client), `/api/snapshot` (GET), and
`/api/stream` (SSE). There is nothing to POST to — read-only by absence,
not by policy check.

The GO-gate concept: the invoke panel exists in the UI (agent picker, prompt
box, PULL button) but the button is rendered disabled with the title
`GO-gated — v2`. Flipping it on in a later version means the box starts
issuing writes to agent gateways; v1 does neither.

## Relationship to fleet-bridge

cabinet-lite reuses
[fleet-bridge](https://github.com/leverframe/fleet-bridge)'s roster file
shapes directly — the same `agents.json` (OpenClaw) and `hermes-agents.json`
(Hermes) documents, plus an optional third generic-runtime roster. It does
not run fleet-bridge or depend on it at runtime; it only shares the file
format, so the same rosters feed both. Roster schemas are documented in
[configuration](./configuration.md).

## License

cabinet-lite is [MIT](https://github.com/leverframe/cabinet-lite/blob/main/LICENSE)-licensed.
Loading