Expand description
abtop — AI agent monitor.
This crate is both a binary (the TUI, entered via run) and a library.
The library surface exists so a separate local tool (e.g. a web UI) can
reuse the data-collection layer in-process and serialize it via
snapshot::Snapshot / app::App::to_snapshot, without reimplementing
session discovery and without depending on the terminal frontend.
§Public API for library consumers
The stable surface for in-process consumers is app (notably
App::to_snapshot and
App::tick_no_summaries), snapshot,
config, demo, host_info, and the data types in model. The
collector, locale, setup, theme, and ui modules are
published mainly to support the bundled TUI binary and may change without a
semver-major bump — depend on them at your own risk.
Enum wire formats are part of the snapshot contract: variants such as
model::SessionStatus serialize as their CamelCase names ("Thinking",
"Executing", …) and chat roles serialize as "user" / "assistant".
These strings are stable and won’t be renamed without a major version bump.
§Threading model
App is not Send: it owns boxed collector trait objects
and must stay on the thread that created it. Don’t move it between threads
or share it with request handlers — instead, run the collector loop on one
thread, serialize each snapshot::Snapshot to JSON, and hand the string
to other threads.
§Typical usage
use abtop::app::App;
use abtop::{config, theme::Theme};
let cfg = config::load_config();
let mut app = App::new_with_config_and_claude_dirs(
Theme::default(),
&cfg.hidden_agents,
cfg.panels,
&cfg.claude_config_dirs,
);
loop {
app.tick_no_summaries(); // refresh without spawning `claude --print`
let snap = app.to_snapshot(2_000); // pure read → JSON-friendly DTO
let json = serde_json::to_string(&snap).unwrap();
// ... serve `json`, sleep for the interval, repeat ...
}Modules§
- app
- collector
- config
- demo
- host_
info - Lightweight host vitals: CPU%, MEM%, 1-min load average.
- jump
- Terminal “jump to session” backends.
- locale
- model
- setup
- snapshot
- Serializable snapshot of live monitor state for the JSON / Web API.
- theme
- ui