diff --git a/cabinet-lite/architecture.md b/cabinet-lite/architecture.md new file mode 100644 index 0000000..eacc181 --- /dev/null +++ b/cabinet-lite/architecture.md @@ -0,0 +1,102 @@ +--- +title: Architecture +description: Process layout, modules, routes, and data flow of cabinet-lite. +sidebar_position: 3 +--- + + + +## 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. diff --git a/cabinet-lite/configuration.md b/cabinet-lite/configuration.md new file mode 100644 index 0000000..93c63d3 --- /dev/null +++ b/cabinet-lite/configuration.md @@ -0,0 +1,164 @@ +--- +title: Configuration +description: Full environment variable and roster file reference for cabinet-lite. +sidebar_position: 8 +--- + + + +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": "", + "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": "", + "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. diff --git a/cabinet-lite/getting-started.md b/cabinet-lite/getting-started.md new file mode 100644 index 0000000..57b6b62 --- /dev/null +++ b/cabinet-lite/getting-started.md @@ -0,0 +1,72 @@ +--- +title: Getting started +description: Prerequisites, install, run, and first-run checklist for cabinet-lite. +sidebar_position: 2 +--- + + + +## 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: ` 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. diff --git a/cabinet-lite/intro.md b/cabinet-lite/intro.md new file mode 100644 index 0000000..63df0f9 --- /dev/null +++ b/cabinet-lite/intro.md @@ -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 +--- + + + +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. diff --git a/cabinet-lite/invoke-panel.md b/cabinet-lite/invoke-panel.md new file mode 100644 index 0000000..58a64c3 --- /dev/null +++ b/cabinet-lite/invoke-panel.md @@ -0,0 +1,47 @@ +--- +title: Invoke panel +description: The invoke panel is wired in the UI but GO-gated OFF in v1. What flipping it would mean. +sidebar_position: 7 +--- + + + +## v1 state: GO-gated OFF + +The invoke panel sits at the bottom of the main column: an agent picker, a +prompt input ("pull a lever — prompt…"), and a PULL button. All of it is +present but inert in v1: + +- The PULL button renders with the `disabled` attribute and the title + `GO-gated — v2`; its cursor is `not-allowed`. +- The server exposes no endpoint a submission could hit. The route table is + `/`, `/ui/app.js`, `/api/snapshot` (GET), `/api/stream` (GET), and 404 + for everything else. There is no POST handler anywhere in the codebase. +- `ui/app.js` wires no submit listener — it only renders the agent picker + options from the OpenClaw roster slice. + +**There is no gate flag or env var to flip in v1.** The gate is structural: +the disabled button plus the absence of an invoke route. Nothing in +`server.ts`, `plates.ts`, or the environment reads a toggle for it, so +documented overrides would be invented — if you find a config that "enables +invoke," it does not exist. + +## What flipping it would mean + +The GO-gate is a deliberate line between the two kinds of state the box +could touch: + +- **Reads (v1):** the box watches fleet state and cabinet state. Degrading + a plate or a probe writes nothing. +- **Writes (v2, gated):** pulling a lever would issue an action to an + agent gateway — an invocation of a named agent with a prompt. That is a + write against the fleet, not against the box's own state. Cabinet state + stays off-limits even then (see the write-off-limits rule in + [plates](./plates.md)). + +Enabling invoke in a future version requires three things the codebase has +already reserved for: the `busy` tile state and lever-throw animation +(styled but unassigned), the roster `token` field (loaded, but stripped +from every API response — "used only server-side if invoke lands in v2"), +and the Hermes `ssh_user` / `binary` fields (loaded, stripped, documented +as v2). Until all three are wired, the panel stays gated. diff --git a/cabinet-lite/lever-tiles.md b/cabinet-lite/lever-tiles.md new file mode 100644 index 0000000..4fb809d --- /dev/null +++ b/cabinet-lite/lever-tiles.md @@ -0,0 +1,67 @@ +--- +title: Lever tiles +description: Tile states, runtime tags, the lever-throw animation, and hover behavior. +sidebar_position: 5 +--- + + + +Lever tiles are the "who's free" surface: one tile per roster entry, laid +out in an auto-fill grid (`minmax(112px, 1fr)`). Each tile shows the agent +name, its role, a lever slot graphic, and a runtime tag. + +## State dots + +The state dot in the tile's top-right corner is driven by the health cache: + +| State | Dot | When | +|---|---|---| +| `live` | solid green (`#00C853`) | health result has no `error` and `ok` is true | +| `down` | red (`#E5484D`) plus a red-tinted tile border | health result carries an `error` (probe failed, timed out, non-JSON) | +| `idle` | gray, 40 percent opacity | no health result yet, or the entry is not health-displayed (see below) | + +Health semantics come from `fleet.ts`: each OpenClaw and generic entry is +polled with HTTP GET at its `healthPath` (default `/health`), 5 s timeout, +and the JSON body is used as-is — a probe is `live` when the response is +JSON with `ok: true`. + +Probed slices are OpenClaw + generic. Hermes entries always render `idle`: +`fleet.ts` reports them as static `"ssh"` status in v1 (no HTTP probe +exists for Hermes). Entries labeled `mcp` are probed server-side, but their +health is deliberately not displayed — they render static `idle` too. + +Before the first poll completes, every probed tile is `idle`. + +## Runtime tags + +The small tag in the tile's bottom-right corner is the runtime label, +lowercased and truncated to 2 characters: `oc` for openclaw, `he` for +hermes, `mcp` for mcp. Labels come from each roster entry's `runtime` +field, defaulting by roster kind (`openclaw` for OpenClaw/generic entries, +`hermes` for Hermes entries). A generic entry with `runtime: "khoj"` +renders the tag `ko`. + +## Lever-throw animation + +Each tile contains the lever slot graphic: a steel lever arm in a dark +slot, with a ball riding it. + +- Normal tiles render the arm static (bright steel for `live`, dark steel + otherwise). +- The `busy` tile class is armed for v2: it would turn the arm amber + (`#FFB000`) and run the throw animation — a 2.2 s cubic-bezier loop that + pivots the lever through the slot (width 12 percent to 82 percent and + back) while the ball rides it. In v1, no renderer ever assigns `busy`, + so the animation is dormant. "Busy = animated" is the v2 contract: a + lever being pulled is a lever in motion. + +## Hover behavior + +Hovering a tile brightens its border from `#1F1F1F` to `#C2C7CC`. The v2 +`busy` class would brighten to amber on hover. Tiles have no click +handlers in v1. + +## Empty roster + +With no entries at all, the tile grid renders a single line: +"no levers in the frame — roster empty." diff --git a/cabinet-lite/plates.md b/cabinet-lite/plates.md new file mode 100644 index 0000000..b40774d --- /dev/null +++ b/cabinet-lite/plates.md @@ -0,0 +1,70 @@ +--- +title: Plates +description: The plate contract and the two v1 plates — needs_you (Cabinet) and fleet_health. +sidebar_position: 4 +--- + + + +## The plate contract + +A plate is one bolted-in instrument backed by one backend subsystem. The +contract, from `plates.ts`: + +- Each plate is a discriminated union: an `ok: true` variant carrying data, + or an `ok: false` variant carrying a single `error` string. +- Every fetch is bounded by a timeout (5 s default, `AbortController`). +- A non-2xx response becomes `HTTP `. +- A response whose JSON shape does not match the expected schema becomes + `unexpected shape` — the plate does not trust the backend. +- Any transport failure (DNS, refused, timeout) becomes the error message. + +**Degrade behavior:** an unset URL, an unreachable backend, a timeout, or a +bad shape degrades the plate to an error state. The server never crashes on +plate failure; it keeps the last plate object and retries on the next cycle +(every 30 s, `PLATE_INTERVAL_MS = 30_000` in `server.ts`). Before the first +completed poll both plates read `not polled yet`. + +The UI renders a degraded plate as a bordered empty slot with the error +text — never a crash, never a blank wall. Everything else keeps rendering. + +## needs_you (Cabinet) + +- Backend: the Cabinet task queue, read-only. +- URL: `CABINET_URL` env var (or the `cabinetUrl` server option). Unset = + plate degrades with `CABINET_URL not configured`. +- What it reads: `GET {CABINET_URL}/api/tasks?state=active`. Accepts either + a bare task array or `{"tasks": [...]}`. +- Task shape (`CabinetTask` in `plates.ts`): `id`, `title`, + `assigned_to`, `priority`, `state`, `claimed_by`, `created_at`, + `due_at`, `fail_count`. +- What renders: the NEEDS YOU attention banner at the top of the box. + - Tasks present: up to 6 chips (`assigned_to` or `unassigned` plus the + task title), then `+N more`, then the total count CTA. Banner is amber. + - Zero tasks: the clear message — "nothing. interlock clear — N levers + healthy, 0 conflicts." Banner goes gray. + - Degraded: "cabinet offline — \". + +### Write-off-limits + +cabinet-lite reads the Cabinet production instance and never writes to it. +The only request it ever makes is the `GET /api/tasks?state=active` above. +Claiming, completing, or editing cabinet tasks stays in Cabinet itself — +"supervisors supervise" means the box watches the queue, it does not touch +it. There is no POST path in the v1 codebase at all. + +## fleet_health + +- Backend: the fleet-health aggregate endpoint. +- URL: `FLEET_HEALTH_URL` env var (or the `fleetHealthUrl` server option). + Unset = plate degrades with `FLEET_HEALTH_URL not configured`. +- What it reads: `GET {FLEET_HEALTH_URL}/fleet-health`. +- Required response shape: `healthy` (number), `total` (number), + `threshold` (number), `status` (string). Anything else is + `unexpected /fleet-health shape`. +- What renders: the plate surface in the header area reflects the + aggregate — e.g. 18 of 20 healthy against threshold 18 with status `ok`. + A degraded render shows the error string instead. + +Both plates are included verbatim in every snapshot and SSE frame under +`plates.needs_you` and `plates.fleet_health`. diff --git a/cabinet-lite/pull-feed.md b/cabinet-lite/pull-feed.md new file mode 100644 index 0000000..a6e8bd8 --- /dev/null +++ b/cabinet-lite/pull-feed.md @@ -0,0 +1,73 @@ +--- +title: Pull feed +description: Feed entries, runtime provenance badges, error entries, and the while-you-were-away digest. +sidebar_position: 6 +--- + + + +## Feed entries + +The feed is the "what happened" journal. Each entry (`FeedEntry` in +`feed.ts`) carries: + +| Field | Meaning | +|---|---| +| `ts` | timestamp, stamped by the server at insertion | +| `runtime` | provenance label — `openclaw` / `hermes` / `mcp` today, any roster label in general | +| `agent` | agent name | +| `summary` | one-line description | +| `ms` | latency in milliseconds (`0` renders as an em dash) | +| `ok` | success flag | + +Storage is an in-memory ring buffer capped at 500 entries, newest first. +Restarts reset the feed — it is a journal, not a store. + +**What lands in the feed in v1:** health transitions. When any HTTP-probeable +agent (OpenClaw or generic) flips between live and down, `server.ts` adds +one entry: summary `health recovered` (`ok: true`) or +`health degraded: \` (`ok: false`), with `ms: 0`. The first poll +seeds the health cache without emitting entries. The feed surface is the +same one v2 lever pulls will land in, which is why every entry already +carries runtime provenance. + +## Runtime provenance badges + +Each row renders a badge after the agent name: + +| Label | Badge style | +|---|---| +| `openclaw` | amber (`b-oc`) | +| `hermes` | steel (`b-he`) | +| `mcp` | muted gray (`b-mcp`) | +| anything else | generic steel badge (`b-x`) with the label uppercased — e.g. a generic roster entry labeled `khoj` renders `KHOJ` | + +The RUNTIMES side-rail in the sidebar counts every distinct label across +the roster plus any label seen in feed traffic (max 6 rows, then a +`+N more` line). + +## Error entries + +Failed entries (`ok: false`) get a dark red-tinted row background, the +summary text in red, and a `context →` link stub on the right. In v1 the +stub is not wired to anything — it marks where failure context will open. + +## While you were away + +Two digest behaviors, both computed client-side in `ui/app.js`: + +- **Session digest.** On load, the client records the session start time. + If any feed entries newer than that are failures, a dashed-border + digest box appears above the feed: "while you were away — N failures + since you opened this box." Zero failures keeps it hidden. It counts + the whole live session, not just reconnections. +- **Top-line digest.** The header line computes, since local ET midnight: + total pulls, failures, and escalations — an escalation is a failed entry + whose summary matches `needs_human` or `escalat` (case-insensitive). + Rendered as "since 00:00 — N pulls · N failures · N escalations". + +Feed rows also feed the PULL RHYTHM strip: 48 half-hour buckets covering +24 h; bar height is relative to the busiest bucket, and any bucket +containing a failure renders amber. + +Empty feed renders: "no pulls yet — the box is quiet." diff --git a/cabinet-lite/self-hosting.md b/cabinet-lite/self-hosting.md new file mode 100644 index 0000000..f5ad688 --- /dev/null +++ b/cabinet-lite/self-hosting.md @@ -0,0 +1,84 @@ +--- +title: Self-hosting +description: Deploying cabinet-lite as a bare Node process — what the repo provides and what it does not. +sidebar_position: 9 +--- + + + +## What the repo ships + +The repo ships no deployment artifacts: no Dockerfile, no systemd unit, no +compose file. Deployment is a bare Node process, and this page documents +that honestly rather than inventing container definitions. + +## Bare Node process + +```bash +npm ci +npm run build +npm start # node dist/index.js +``` + +Facts that matter for a deployment: + +- The process listens on `127.0.0.1:9100` (or `PORT`). It will not accept + external connections directly — put a reverse proxy in front if you need + remote access, and note that no route authenticates. +- `index.ts` handles SIGINT and SIGTERM: both trigger `instance.stop()` + (fleet poller and plate loop stop, SSE clients are destroyed, the HTTP + server closes) and then exit 0. It shuts down cleanly under systemd. +- A bind failure (port taken) logs `cabinet-lite: ` and exits 1 + at startup. +- Runtime dependencies: none beyond Node built-ins. Node >= 24 required + (`engines` in `package.json`). +- State: none on disk. Roster files and env vars are the only inputs; the + feed is an in-memory ring buffer that resets on restart. + +## Process supervision + +Because there is no unit file in the repo, use your supervisor of choice. +A minimal systemd shape (adjust paths and environment to your host): + +```ini +[Unit] +Description=cabinet-lite signal box +After=network-online.target + +[Service] +WorkingDirectory=/opt/cabinet-lite +Environment=FLEET_BRIDGE_AGENTS=/etc/cabinet-lite/agents.json +Environment=FLEET_BRIDGE_HERMES=/etc/cabinet-lite/hermes.json +Environment=CABINET_URL=http://cabinet-internal:18900 +Environment=FLEET_HEALTH_URL=http://fleet-health-internal:9150 +ExecStart=/usr/bin/node dist/index.js +Restart=on-failure + +[Install] +WantedBy=multi-user.target +``` + +Run it as an unprivileged user. The rosters contain gateway tokens — keep +them outside the repo working tree and readable only by the service user. + +## Docker + +Not provided by the repo. Nothing in the code prevents containerizing it +(static build output in `dist/`, static UI in `ui/`, loopback bind — +remember a container would need the proxy or a port mapping, and the +hardcoded `127.0.0.1` bind means `EXPOSE` alone will not publish it). +Any Dockerfile you add is your own. + +## CI + +GitHub Actions builds and tests on every push/PR to `main` +(`.github/workflows/ci.yml`): Node 24, `npm ci`, `npm run build`, +`npm test`. Green CI is the deploy gate the repo itself defines. + +## Resource profile + +The box polls every roster entry every 10 s (5 s timeout per probe, 250 ms +stagger) plus two plate URLs every 30 s, and holds one ring buffer of up +to 500 feed entries. Memory and CPU scale linearly with roster size and +stay small for typical fleets. Each browser client holds one SSE +connection open. diff --git a/cabinet-lite/troubleshooting.md b/cabinet-lite/troubleshooting.md new file mode 100644 index 0000000..10f318b --- /dev/null +++ b/cabinet-lite/troubleshooting.md @@ -0,0 +1,97 @@ +--- +title: Troubleshooting +description: Plate degradation, SSE disconnects, roster load failures, and other failure modes. +sidebar_position: 10 +--- + + + +## Plate degradation cases + +The `needs_you` and `fleet_health` plates degrade to a bordered error slot +rather than crashing. The error strings in the slot map to causes: + +| Error text | Cause | Fix | +|---|---|---| +| `CABINET_URL not configured` / `FLEET_HEALTH_URL not configured` | env var unset | set the URL and restart (URLs are read at startup) | +| `HTTP ` | backend answered non-2xx | check the backend's own health and auth | +| `unexpected /api/tasks shape` / `unexpected /fleet-health shape` | backend returned JSON that does not match the plate schema | verify the backend version; the plate trusts nothing it cannot validate | +| timeout message | backend slower than the 5 s abort timeout | check network path or backend latency | +| DNS / ECONNREFUSED text | backend unreachable | check host, port, and routing from the box host | + +Degraded plates retry every 30 s and recover on their own — no restart +needed once the backend is healthy again. Before the first completed poll +both plates read `not polled yet`. The rest of the box keeps rendering +through any plate failure. + +## SSE disconnect behavior + +- Each client gets a full snapshot as its first `event: snapshot` frame, + then periodic frames every 10 s, plus an immediate broadcast on every + health transition. +- Client disconnects are handled: the response's `error` and `close` + events evict it from the broadcast set, and error handlers are attached + before the first write (a client that resets immediately cannot crash + the server). A dead client never poisons later writes — the test suite + covers mid-stream disconnect followed by continued serving. +- Server-side restart drops all connections; the browser's + `EventSource` reconnects on its own and the next frame re-renders + everything. +- If the clock's `LIVE` indicator is the only thing updating but data is + stale, check that `/api/stream` still responds — frames stop only if + the process is wedged (which would also stop `/api/snapshot`). + +A malformed frame is ignored client-side (render is wrapped in +try/catch); the next snapshot re-renders. Frames identical to the previous +one are skipped. + +## Roster load failures + +Roster loading is deliberately non-fatal (`fleet.ts` `loadJson`): a +missing path, unreadable file, JSON parse error, or a document without an +`agents` array all load as an empty list. Symptoms: + +- Tiles missing entirely with "no levers in the frame — roster empty.": + the roster file did not load. Check the path in + `FLEET_BRIDGE_AGENTS` / `FLEET_BRIDGE_HERMES` / `FLEET_BRIDGE_GENERIC` + and validate the JSON. +- A single agent missing while others render: that entry failed schema + expectations or points at a wrong `host`/`port`. Roster entries are used + as-is — there is no per-entry validation or error surface in v1. +- Note there is no file watching: roster edits require a process restart. + +## Tiles stuck idle or down + +- Stuck `idle` on an OpenClaw or generic entry: the poll has not produced + a health result. Check that the gateway answers HTTP GET at + `http://host:port/healthPath` (default `/health`) and returns JSON. +- Stuck `down` right after a deploy: down persists until a poll succeeds — + polls run every 10 s per agent with a 5 s timeout, so recovery is + bounded by roughly one poll cycle after the gateway is healthy. +- `down` from non-JSON endpoints: a plain-text endpoint (for example a + Prometheus-style metrics page) will never go `live` — the probe expects + JSON with an `ok` field. Point `healthPath` at a JSON status route. +- Hermes tiles are always `idle` by design (no HTTP probe in v1); so are + entries labeled `mcp`. + +## Feed anomalies + +- Feed empty but the fleet is clearly active: in v1 only health + transitions generate entries — a quiet fleet genuinely produces no + entries. The first poll after startup seeds without emitting anything. +- Feed lost after restart: the buffer is memory-only (500-entry cap). + This is intended; the feed is a journal, not a store. +- Transition subscriber errors are logged to the server console + (`[fleet] transition subscriber threw ...`) and do not stop polling. + +## Other failure modes + +- Startup exit code 1 with `cabinet-lite: `: the listen failed — + usually port 9100 already taken. Change `PORT` or free the port. +- Snapshot exposes nothing sensitive by construction (`token`, + `ssh_user`, `binary` are stripped before any response); if you ever see + a token in snapshot output, that is a bug — verify against + `fleet.ts` `publicRoster()`. +- Use `npm test` (build plus Node's built-in test runner over + `dist/test/*.test.js`) to exercise server, fleet, plates, and feed + behaviors against mock gateways. diff --git a/docusaurus.config.mjs b/docusaurus.config.mjs index 87b7fb3..a2afe3c 100644 --- a/docusaurus.config.mjs +++ b/docusaurus.config.mjs @@ -4,6 +4,7 @@ const productInstances = [ { id: 'fleet-bridge', path: 'fleet-bridge', routeBasePath: 'fleet-bridge' }, { id: 'wranglebot', path: 'wranglebot', routeBasePath: 'wranglebot' }, { id: 'tractum', path: 'tractum', routeBasePath: 'tractum' }, + { id: 'cabinet-lite', path: 'cabinet-lite', routeBasePath: 'cabinet-lite' }, ]; export default { @@ -57,6 +58,7 @@ export default { { to: '/fleet-bridge', label: 'fleet-bridge', position: 'left' }, { to: '/wranglebot', label: 'wranglebot', position: 'left' }, { to: '/tractum', label: 'tractum', position: 'left' }, + { to: '/cabinet-lite', label: 'cabinet-lite', position: 'left' }, { href: 'https://github.com/leverframe', position: 'right', diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 8e8aa36..86f7df9 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -29,6 +29,14 @@ const products = [ license: 'BUSL-1.1', meta: ['Ed25519 + BIP-340', 'NIP-78 on Nostr', 'v1/v2 payloads'], }, + { + name: 'cabinet-lite', + tag: 'SIGNAL-BOX · UI', + desc: 'The cross-runtime fleet dashboard. Read-only v1: what needs you, who is free, what happened — plates bolted into the frame, invoke GO-gated off.', + to: '/cabinet-lite', + license: 'MIT', + meta: ['SSE live feed', 'plate contract', 'read-only v1'], + }, ]; const tickerItems = [ @@ -37,13 +45,14 @@ const tickerItems = [ 'fleet-bridge v0.1.1 — MIT', 'wranglebot v0.1.1 — BUSL-1.1', 'tractum v0.5.0 — BUSL-1.1', + 'cabinet-lite — the signal box, read-only v1', 'PULL = INVOKE AN AGENT', 'INTERLOCK CLEAR', ]; const stats = [ - { label: 'PAGES', value: '31' }, - { label: 'PRODUCTS', value: '3' }, + { label: 'PAGES', value: '41' }, + { label: 'PRODUCTS', value: '4' }, { label: 'MCP TOOLS', value: '6' }, { label: 'GUARDRAILS', value: '5' }, { label: 'RECEIPTS', value: 'K-OF-N' }, @@ -217,6 +226,14 @@ export default function Home() { API reference Verify a receipt +
+

cabinet-lite

+ Getting started + Architecture + Plates + Pull feed + Configuration +