Skip to content

About

Agent eXperience Interface for the waterbus SFU — token-efficient TOON output, browser peers, stack lifecycle

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

waterbus-axi

Agent ergonomic interface for the waterbus SFU. Bring the stack up reliably, put real browser participants in a room, and answer "is media actually flowing, at what quality, to whom" in one command — with TOON output that costs roughly 40% fewer tokens than JSON.

Built to the AXI design principles, in the same shape as deepseek-axi.

Install

curl -fsSL https://raw.githubusercontent.com/waterbustech/waterbus-axi/main/install.sh | bash

Detects your platform, downloads the matching binary from the latest release, and installs to ~/.local/bin (override with WATERBUS_AXI_INSTALL_DIR).

From source:

git clone https://github.com/waterbustech/waterbus-axi && cd waterbus-axi
cargo build --release
ln -sf "$(pwd)/target/release/waterbus-axi" ~/.local/bin/waterbus-axi

Then register the ambient-context hook so every session starts oriented:

waterbus-axi setup hooks

waterbus-axi update upgrades in place. Confirm any setup with a bare waterbus-axi, which prints live state rather than help.

Why

An agent working on waterbus spends most of its budget on scaffolding, not on the change:

  • cargo build -p waterbus-relay succeeds, builds nothing runnable, and leaves the old binary in place — every runnable binary lives in a *-bin package while the obvious name is a library. The failure surfaces later as a wrong benchmark number or a flag that "does not exist".
  • Bringing five services up in the right order, with readiness waits, is reliably three attempts of shell incantations.
  • Reading getStats() from a real browser means hand-building a Chrome DevTools Protocol harness, including the non-obvious detail that Chrome emits only two VP8 simulcast layers below 960px of capture width.
  • Finding the RUST_LOG filter that reveals a code path is guesswork.

This encodes all of it once.

Home view

$ waterbus-axi
repo: "/Users/you/waterbus-rs (wip, 31 uncommitted)"
stack[4]{service,port,state}:
  nats,4222,up
  edge,5998,up
  relay,25998,up
  dashboard,15998,down
binaries[4]{name,state}:
  wb,STALE (src 4m newer than binary)
  "waterbus-relay",ok
peers: 0 (none joined)
help[3]: "Run `waterbus-axi build wb --release` to rebuild the stale binary", …

STALE is the highest-value token here: it turns a silent wrong-result failure into a visible one.

Commands

Tier A is advisory — read-only and safe at any time. Tier W spawns processes or mutates local state.

Orientation

Command Tier Returns
waterbus-axi A Home view: repo, stack, binary freshness, peers
status A Service, port and state, one row each
doctor A Every prerequisite with its fix
stale A Binaries older than their sources
setup hooks W Idempotent SessionStart registration
update W Self-upgrade from the latest release

Build correctness

Command Tier Returns
build [edge|relay|dashboard|wb|all] [--release] W Maps the name to its real *-bin package, builds, then proves the binary is newer than its sources

Stack lifecycle

Command Tier Returns
up [--with dashboard] [--rust-log F] [--allow-stale] W Ordered start with observed readiness; idempotent
down [--all] W Stops only what this axi started; reports what it left alone
restart <service> [--rust-log F] W Exactly one service

Rooms and tokens

Command Tier Returns
room create [--with-token N] [--capacity N] W Edge room id plus ready-to-use tokens in one call; capacity defaults to 16 because a room created without one is born full
room list A Active rooms with participant counts
room state <code> A Participants, ids
token --room <id> --identity <s> W A JWT

Browser peers

Command Tier Returns
peer join <room> [--count N] [--capture 720] [--url T] W Headless Chrome participants with fake media; stable handles
peer list A Handle, room, port, pid
peer stats <handle|all> [--publisher] [--fields …] A Per track: which simulcast layer is arriving, fps, freezes; --fields bytes,rid,width,active widens
peer resize <handle> --tile N --height PX W Drives adaptive viewer quality; tiles are the remote videos, not the local self-view
peer hide|show <handle> --tile N W Drives pause and publisher dynacast
peer reset [handle] W Restores every tile
peer eval <handle> <js> W Escape hatch
peer leave [handle|all] W Closes peers, removes profiles

Verification

Command Tier Returns
media <room> [--peers N] [--settle S] [--keep] W Joins peers, asserts everyone receives everyone, reports the layer matrix, exits 1 naming the failing peer
check [--fast] W fmt → clippy → tests → tsc → vitest, reporting only the first failure
load [--publishers N] [--subscribers N] [--simulcast] W Synthetic load via wb
abr [args…] W ABR layer-switching simulation via wb
bench [--against PATH] [--rounds N] W Interleaved A/B with CPU and RSS sampling

Investigation

Command Tier Returns
logs <service> [--topic T] [--restart] [--lines N] A Tail with the right RUST_LOG filter, ANSI stripped
events [--room C] [--limit N] A Observer SSE stream as TOON rows

Topics: simulcast, dynacast, ice, bwe, cascade.

Global flags

--json (real JSON) · --full (no truncation) · --query PAT (keep matching lines) · --repo PATH (target another checkout).

Schemas are minimal by default (axi principle 2); peer stats --fields is the one place with more to show, and names what it can add.

Room codes

The edge knows rooms by numeric id only. The Google-Meet-style codes browser clients join by (igc-nfyz-ful) are minted by the example server, which maps code to id in memory. So room create is for wb-driven flows, while peer join <code> takes a code from whatever client you are pointing at. Set WATERBUS_CLIENT_URL to that client, e.g. http://localhost:3001/room/{room}.

Worked example

Verifying adaptive viewer quality end to end:

waterbus-axi up
waterbus-axi room create --with-token 3
waterbus-axi peer join <code> --count 2 --capture 720
waterbus-axi media <code>                      # everyone sees everyone?
waterbus-axi peer resize p1 --tile 0 --height 100
waterbus-axi peer stats p1                     # expect layer q
waterbus-axi peer hide p1 --tile 0
waterbus-axi peer stats p2 --publisher         # expect f and h stopped
waterbus-axi down

Nine commands with pre-classified answers, none of which require knowing about Chrome's simulcast threshold.

Safety

The developer's own servers are never at risk:

  • Every process this tool spawns is recorded in a run manifest (~/.config/waterbus-axi/run.json) with pid, port, service and checkout.
  • down acts only on manifest entries, verifying the pid still matches the recorded service before signalling. There is no pattern-based pkill anywhere in the codebase.
  • A port that is occupied but not in the manifest is reported and left alone: port 3000 occupied by foreign pid 812 — refusing to touch it.
  • A recycled pid, or a foreign process that grabbed a port we once used, is classified foreign. This is unit-tested.

Design notes

Nothing is hardcoded about the repo. The binary is installed once and discovers the checkout at runtime — walking up for the workspace that owns crates/relay-core, or taking --repo. Ports come from that checkout's .env, binary names from cargo metadata. One install serves every waterbus checkout on the machine and stays honest when the repo moves a port.

It delegates rather than reimplements. Rooms, tokens, load tests and ABR go through wb --json; the axi adds combination, classification and TOON. The only waterbus domain logic it owns is mapping getStats() to a simulcast tier, kept in one module.

Synchronous. No async runtime: ureq for HTTP, blocking tungstenite for the DevTools protocol, one thread per browser. A session hook runs on every session, so start-up time is a feature.

Configuration

Variable Purpose
WATERBUS_URL, WATERBUS_API_KEY Passed through to wb; otherwise read from the checkout's .env
WATERBUS_CLIENT_URL Example-client URL template, {room} substituted
CHROME_PATH Chrome binary, when it is not in a standard location
WATERBUS_AXI_CONFIG_DIR Manifest, logs and browser profiles (default ~/.config/waterbus-axi)
WATERBUS_AXI_INSTALL_DIR Install target (default ~/.local/bin)

Exit codes

0 success · 2 validation error (bad argument, unknown flag — the command did nothing) · 1 everything else, including a completed check whose verdict is failure. A failing verdict still prints its full report before exiting.

Benchmark

bench/ measures the token cost of the TOON output against the equivalent JSON. See bench/RESULTS.md.

Development

cargo test              # 125 unit tests, no cluster required
cargo clippy --all-targets --all-features -- -D warnings
cargo fmt --all -- --check

Tests are pure-data wherever possible: layer classification runs against recorded getStats() fixtures, port ownership against a synthetic manifest, so the suite needs neither a browser nor a running stack.

License

MIT

About

Agent eXperience Interface for the waterbus SFU — token-efficient TOON output, browser peers, stack lifecycle

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages