Skip to content
FormalSnakePublic

About

Live resource usage, connections and coding agents across your machines, in one terminal

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

36 Commits

Folders and files

Repository files navigation

meshtop

Live resource usage, connections and coding agents across all your machines, in one terminal.

meshtop runs meshtop agent on every host over ssh and draws what comes back: a card per machine, a map of who is connected to whom, and every coding agent running anywhere, with the ones waiting for input at the top. There is no daemon and no open port; if you can ssh host without a password prompt, meshtop can watch it.

meshtop: the 3D map of three hosts, then the agents view with plan usage

 laptop (TUI)                         each host
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   ssh, JSON lines  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ meshtop        β”‚ ◀───────────────── β”‚ meshtop agent --interval 1β”‚
β”‚ cards, map,    β”‚                    β”‚ sysinfo, sockets, GPU,    β”‚
β”‚ agents         β”‚                    β”‚ herdr agent list          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The machine meshtop runs on is sampled in process instead.

What it shows

CPU, per core, load usage with history, core grid in the host view
Memory, swap used of total, history
GPU NVIDIA through nvidia-smi, AMD through sysfs, Apple Silicon through IORegistry
Network rates per interface, total over physical links
Disks, temperatures, battery per mount, hottest sensors, charge and power source
Processes top by CPU or memory, with user and command line
Activity counts per rule: running nix builds, builds served, rustc, mosh sessions, your own
Agents Claude, Codex and other coding agents, with state and task title from Herdr, or by process outside it
Mesh TCP links between your hosts, labelled ssh, nix build, syncthing, rdp, http or your own port names
Plan usage 5 hour and weekly limits of each signed-in Claude Code and Codex account

The map is a 3D scene you can turn. Hosts stand on a grid, raised by their CPU load, with a ring that fills with memory use. Links run from client to server with one moving dot per kind of traffic. Drag to turn it, scroll to zoom; it spins slowly until you touch it, and selecting a host turns it to the front.

A remote nix build shows up as a nix build link from the machine that asked for it to the builder. Both ends of a connection are merged into one link, so the map is complete even where one side cannot see the socket's owner (macOS hides root's sockets from other users).

Install

Nix

nix run github:FormalSnake/meshtop

Home Manager

{
  inputs.meshtop = {
    url = "github:FormalSnake/meshtop";
    inputs.nixpkgs.follows = "nixpkgs";
  };

  # in your home configuration
  imports = [ inputs.meshtop.homeModules.default ];

  programs.meshtop = {
    enable = true;
    hosts = [
      { name = "macbook"; role = "dev"; hostname = "MacBook-Pro-2"; }
      { name = "g815"; role = "builder"; }
      { name = "e1504g"; role = "client"; }
    ];
    ports."1234" = "bluebubbles";
    usage = [
      { kind = "claude"; name = "personal"; }
      { kind = "claude"; name = "work"; dir = "~/.claude-work"; }
      { kind = "codex"; }
    ];
  };
}

Import the module on every host you list: the remote side needs the binary, and the agent reads its activity rules from the same config. The default remote command is the absolute path under home.profileDirectory, so a non-interactive ssh shell with a short PATH still finds it.

Cargo

Needs Rust 1.88+.

cargo install --git https://github.com/FormalSnake/meshtop

Usage

meshtop                  # the TUI
meshtop hosts            # config path, and how each host is reached
meshtop snapshot         # one reading of this machine, pretty JSON
meshtop agent -i 1       # JSON lines on stdout, what the TUI runs over ssh
meshtop who              # each account on this machine and what it runs
meshtop reap             # what agent sessions left behind; --apply to close it
Key
1 2 3 4, tab overview, map, agents, host
← β†’, h l select host
enter open the selected host
↑ ↓, j k scroll processes or agents, tilt the map
+ - zoom the map
r stop or start the map spinning, and reset the tilt
s sort processes by CPU or memory
p, space pause
esc back, or quit from the overview
q quit

The mouse works too: click a host anywhere (header, card, map node, agent row) to select it, click it again to open it, click the tabs, scroll lists with the wheel, drag the map to turn it.

Managing the mesh

The same binary also answers the questions agents keep asking by hand: is that host up, which OS is it in, where should this build run, did the job finish. Roles, holds, services and skills come from an agent-config registry (registry.toml plus hosts.toml); state lives in $MESHTOP_STATE, else $XDG_STATE_HOME/meshtop, else ~/.local/state/meshtop. Every command takes --json.

$ meshtop hosts status
e1504g   unreachable (0s ago)
         linux: tailscale reports e1504g offline, last seen 2026-10-27T13:50:00.1Z
g815     ready linux via g815 (0s ago)
         can take builder, linux-test, gpu, dev-client, vm-host
macbook  ready macos via local (0s ago)
         can take dev-server, agent-host, service-host, apple-build

$ meshtop hosts pick builder
g815

hosts wait HOST --os linux --timeout 600 blocks until the host is up in that OS and exits 0 ready, 1 blocked (rejected key, wrong machine), 75 at the deadline, 130 cancelled. Nothing here powers a host on or reboots it. hosts hold HOST --hours 3 --reason gaming keeps it out of pick.

Jobs are detached commands that survive the shell that started them:

meshtop job start --id g815-switch --host g815 -- sudo -n nixos-rebuild switch --flake .#g815
meshtop job wait g815-switch --timeout 1800   # 0 ok, 1 failed, 74 lost, 75 still running, 76 host unreachable, 77 needs authorization
meshtop job logs g815-switch

Starting an id that exists reports the existing job, so retrying after a lost reply never runs the command twice.

Jobs run without a terminal, so a prompt fails instead of waiting: git and ssh are told not to ask. A job that failed on a refused password, key or permission, or that sits silent while macOS shows an authorization dialog, says so in its status and wait exits 77. Nothing retries it on its own.

A delivery is a build that waits for its target. It builds as soon as a builder is free, then installs when the target is back in the right OS, however long that takes (default limit 72 hours):

meshtop deliver start --id e1504g-shell --target e1504g --os linux \
  --build 'nix build .#e1504g --print-out-paths' \
  --install 'fspec apply "$ARTIFACT"'
meshtop deliver status e1504g-shell   # 0 done, 1 failed, 74 unknown, 75 still going

The install sees MESHTOP_DELIVERY, TARGET, REV, ARTIFACT (last line of the build log), BUILD_HOST and TARGET_BOOT. The target is probed again right before the install starts. An install whose outcome was lost is never replayed on its own: the delivery goes to unknown until deliver resume ID --retry-install. deliver cancel stops the driver and keeps the phase.

worktrees list shows every linked worktree with its owner and why it has to stay; worktrees clean --dry-run lists what clean would remove (clean, integrated, idle, unowned, never forced, branch kept).

skills update pulls the registry (fast-forward only), syncs every skill target and rewrites the memory views Claude and Codex load. It never adopts foreign entries or overwrites edited copies, so a timer can run it.

meshtop serve puts all of this in a browser at 127.0.0.1:7314. Listening anywhere but loopback needs the token from meshtop serve --token. Behind a reverse proxy that does its own access control, stay on loopback and name the proxy's host instead:

meshtop serve --allow-host mac.tailnet.ts.net
tailscale serve --bg --https=8314 http://127.0.0.1:7314

A shared dev server

One Mac (or Linux box) with an account per person, each running its own coding agents, T3 server and desktop session. meshtop records the account (name and uid) on every job, hold, resource lock, worktree marker and live agent, so job list, hosts status and the web UI say whose a thing is. State written before accounts were recorded still loads, without one.

Shared state

By default every account keeps its own state, and two people's agents never see each other's jobs or locks. To share the machine-wide part, an admin creates the shared dir once: root's, writable by root alone, with three sticky subdirs a group of every person can write into:

D="/Library/Application Support/meshtop"                 # /var/lib/meshtop on Linux
sudo mkdir -p "$D/locks" "$D/jobs" "$D/holds"
sudo chown root:staff "$D" "$D/locks" "$D/jobs" "$D/holds"  # staff: a group of all users
sudo chmod 755 "$D"
sudo chmod 1775 "$D/locks" "$D/jobs" "$D/holds"

meshtop checks this layout every time it opens the shared dir. If the dir or a subdir is not root's, the top dir is group or world writable, or a subdir is not sticky, it prints one warning and keeps everything per account. MESHTOP_SHARED=/some/dir picks another dir (held to the same rules), and MESHTOP_SHARED= (set, empty) turns sharing off. Each account writes only its own files there, mode 0644, never through a symlink, and the sticky bit stops anyone but their owner (or root) replacing them:

In the shared dir Stays per account
resource locks (job start --lock): one account's lock stops the other's job serve-token and every other secret
holds (hosts hold), one file per account under holds/ (per account they stay in holds.json); an account releases only its own job logs, job.json, notifications
the job index: each job published as jobs/<uid>.<id>.json with a lock beside it the host probe cache, leases, the reaper's own state

An index entry holds status only (id, owner label, pids, times, and the outcome as succeeded, failed with its exit code, blocked or lost, never error text); the command, its environment, cwd, locks and notify URL stay in the account's own job.json. An entry or hold counts only when the account that owns the file is the one its name gives, and the account shown is resolved from that owner, never read from the file. Every account lists every job, with its owner and state; a running job is told apart from a lost one by the lock beside its index entry, which the supervisor holds. A job's log stays in its account's state dir, readable by others only if that account's permissions allow it. job cancel on another account's job is refused unless run as root, which runs the cancel as that account against its own job.json. The cancel signals the job only while its pid still has the start time recorded at spawn, or, for a job an older meshtop started, while it is the child of its live supervisor.

meshtop who

$ meshtop who
ana (uid 501)  gui, on the console
  agents claude 5, opencode 1; t3 pid 16556 port 3773
  jobs running 2; worktrees 122; 1271 processes, 24G resident, 592% cpu
bob (uid 502)  gui
  agents codex 2; t3 not running
  jobs running unknown; worktrees unknown; 310 processes, 3.1G resident, 4% cpu

Per account: a GUI login session (a loginwindow running as that user on macOS, an x11 or wayland session in logind on Linux) and whether it has the screen, agent processes by kind, the T3 server and its port (from its command line, else its runtime file), running jobs, linked worktrees under ~/Developer and ~/.config (counted from git's admin dirs, no sizes), and the resident memory and CPU of the account's processes. Process figures come from the setuid ps, so they cover every account. What one account cannot read about another (its jobs without a shared dir, its home) says unknown. who --json and /api/who (the Who tab of the web UI) give the same data.

meshtop reap

Agents leave things running: dev servers their shell backgrounded, MCP servers whose client died, headless browsers, fixture apps, booted simulators, finished worktrees. meshtop reap lists them, one line each with its owner and the reason; nothing is touched without --apply.

$ meshtop reap
would terminate: orphan pid 5940 node /usr/local/bin/yarn dev | ana: claude pid 25837 gone, t3 thread "improve site usability" settled 27h ago | started by claude pid 25837; orphaned since 27h ago with 8 descendants
report: orphan pid 79502 tail -n +1 -f ~/Developer/FormalShell-wt/s2h-v/artifacts/h/progress.txt | ana: claude pid 30329 gone | started by claude pid 30329; first seen orphaned now, grace 30m
would remove: worktree ~/Developer/lynk-wt/live-pages live-pages | ana: unowned | clean, integrated, idle, no live owner
report: worktree ~/.t3/worktrees/FormalShell/t3-6795c838 t3/gpu | ana: t3 thread "auto stays on the cpu" settled | owner finished but kept: 1 changed files
would quit: lease window-20261201-150542 window 72155 | ana: claude pid 68503 | ttl passed 2s ago
report (shutdown needs --include-unleased): leftover sim 6118F44F-... iPhone 18 Pro | ana: unknown | booted 3d ago, no Simulator.app and no process names it
would forget: job e1504g-untangle bash -c ... | ana: ana@macbook | lost 19d ago, its outcome will never be known
59 findings, 24 to act on, 35 report only (dry run, nothing touched; --apply acts)
Class Found by --apply does
orphan a process reparented to launchd (or init) whose process group leader is gone and whose environment names the agent session that started it (CLAUDE_PID, T3CODE_THREAD_ID), now over. An agent-shaped process without that (an MCP server command line, a headless Chromium on a temp profile, a Playwright driver, a cwd in an agent dir) is reported only TERM to it and to each descendant whose own environment names a finished session, or names none and started after its parent; a descendant with an unknown session, an unreadable environment or an earlier start is left out with its subtree. KILL to what is left after 10s
worktree worktrees list rules: clean, integrated, idle --min-idle-hours (24), no process inside, owner gone; a T3 thread settled or archived past the grace period stops counting as an owner git worktree remove <path> after a fresh re-check, for a missing checkout too, never forced, never a repo-wide prune, branch kept
lease a lease whose ttl passed, or whose owner (T3 thread, else pid) has been gone for the grace period quit the app or close the window, close the tab, shut down the simulator, TERM then KILL the process
leftover an app an orphaned agent process started directly, a window app launched during a run of a T3 thread that is now over, a booted simulator with no Simulator.app and no process naming it nothing, unless --include-unleased: quit, or simctl shutdown
job this account's lost jobs older than --job-ttl (7d) delete the job's dir

--grace (30m) is how long an owner must be gone. It counts from the T3 thread's settle or archive time when there is a thread, else from the first time reap saw the process orphaned (kept in $STATE/reap/seen.json), so on a fresh machine an orphan with no thread is acted on by the second run past the grace period. --only orphans,worktrees,... limits the classes, --match TEXT limits the findings to a pid, lease id or path, --root DIR scans other dirs for worktrees, --force force quits apps that refuse to quit, --json prints meshtop.reap/1.

The leftover class is a heuristic. An app opened during an agent run may have been opened by the person watching it, and a simulator can have a client meshtop does not recognise (a streaming tool, a test runner between runs). That is why it reports by default.

What reap never touches, on any run:

  • anything of another account, unless it runs as root (below);
  • a process whose agent is alive: its CLAUDE_PID runs (and started before the process, so a reused pid does not count), or its T3 thread is live: working, waiting on a person, or done but not settled;
  • a process whose owner cannot be read (its thread is not in this account's T3 state, or the state is unreadable): reported, kept;
  • a process whose environment names no agent session, however agent-like its command line, and any descendant that is itself protected (another account's, a live session's, a group leader, on a live terminal);
  • a launchd job or systemd user unit, a process group or session leader (daemons, tmux new -d, setsid), a process on a terminal that has a live shell, and the supervisor and command of a running meshtop job;
  • reap itself and its ancestors;
  • a worktree with changes, untracked files, ignored files that are not build output, commits not in its base, a detached HEAD no branch or tag contains, a process inside, or a live owner, or any worktree while T3 state cannot be read: it is only ever reported. Owners and working directories are read again right before removal;
  • a pid that was reused between the scan (or the lease) and the action, or during the wait between TERM and KILL: every pid carries its start time to the microsecond, read from the kernel in the same read as its parent, group, account and terminal, at discovery or lease creation, and compared exactly right before each signal. A process whose kernel info or environment cannot be read is reported, never signalled. Only a pid that is absent or now names another process counts as gone; an unreadable one or a refused signal keeps the lease and is reported;
  • the registration of a missing worktree whose detached HEAD no branch or tag contains.

A dry run writes only observations: the first-seen times and when a lease's owner was first seen gone.

For every account, run it as root. Root runs one reaper per person's account (uid in the login range, a login shell), as that account (launchctl asuser <uid> sudo -u <name> -H meshtop reap --json ..., sudo -u on Linux), so each run reads that account's processes, T3 state, leases and worktrees and acts with its rights, inside its GUI session where windows and tabs live. --user NAME limits it to one account (never root). A recommended LaunchDaemon, every 15 minutes, leftovers left to people:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key><string>dev.meshtop.reap</string>
  <key>ProgramArguments</key>
  <array>
    <string>/opt/fspec/current/bin/meshtop</string>
    <string>reap</string>
    <string>--apply</string>
  </array>
  <key>StartInterval</key><integer>900</integer>
  <key>RunAtLoad</key><false/>
  <key>LowPriorityIO</key><true/>
  <key>Nice</key><integer>10</integer>
  <key>StandardOutPath</key><string>/var/log/meshtop-reap.log</string>
  <key>StandardErrorPath</key><string>/var/log/meshtop-reap.log</string>
</dict>
</plist>

Run it without --apply for a few days first and read the log.

Closing a tab or a window by title sends Apple events, and macOS refuses those from a root job without asking anyone (tccd: "unable to create attribution chain"): the daemon stops processes and removes worktrees for everyone, and reports each tab lease as failed. To close tabs, each person also runs meshtop reap --apply as a LaunchAgent in their own session. Its first Apple event asks for the Automation permission on that person's screen; a prompt nobody answers fails after 20 seconds and the lease is kept. macOS asks again after a meshtop update, since the grant is tied to the binary's path.

Leases

Ancestry cannot tie a window, a browser tab or a simulator to the agent that opened it, since open hands them to launchd. A lease does:

meshtop lease run --kind window -- open -a TextEdit          # leases the app the command started
meshtop lease run --kind tab --app Helium -- open -a Helium https://localhost:5173
meshtop lease run --kind sim -- xcrun simctl boot <udid>      # only a boot it saw happen
meshtop lease run --kind process --ttl 2h -- bun run dev      # starts it detached, log beside the lease
meshtop lease add --kind window --ref '<pid>:<window title>' --ttl 1h
meshtop lease list
meshtop lease release <id>

The owner defaults to the nearest agent process above the caller (claude, codex, ...) and the T3 thread in $T3CODE_THREAD_ID; --owner takes a thread id or a pid. With a thread, the thread decides: T3 runs a new agent process per turn, so the lease holds while the thread is live and goes once it is settled or archived for the grace period. With only a pid, it goes once that process has been gone for the grace period. --ttl closes it then regardless. lease run takes only what the command opened and names: the app after open -a or a .app path, a new tab with the URL it passes, a simulator whose udid it passes, and only when the command exits 0. Something that appeared meanwhile without being named (or two matches) is listed and not leased, since a person or another agent may have opened it. A simulator lease made with lease add is only shut down with --booted. A window is closed politely: the app is asked to quit (it may refuse over unsaved work; reap --force force quits), a <pid>:<title> lease presses that window's close button. Tabs are matched by id or URL in any Chromium-family browser's AppleScript dictionary.

For agent instructions:

## Things you open outside your shell

When you open a GUI app, a browser tab or a simulator, or start a server that
should outlive your shell, wrap it in `meshtop lease run` so it is closed
after your thread is settled:

- `meshtop lease run --kind window -- open -a <App>`
- `meshtop lease run --kind tab -- open -a Helium <url>`
- `meshtop lease run --kind sim -- xcrun simctl boot <udid>`
- `meshtop lease run --kind process -- <command>` (detached; prints the pid and log)

Add `--ttl 2h` when it should go sooner. `meshtop lease list` shows yours;
`meshtop lease release <id>` keeps something open for good.

Config

$XDG_CONFIG_HOME/meshtop/config.toml, which the Home Manager module writes. Without one, meshtop shows only the machine it runs on.

interval = 1.0   # seconds between samples
history = 120    # samples kept for the graphs

[[hosts]]
name = "macbook"            # shown in the TUI, and the ssh destination
ssh = "[email protected]"  # optional, when the destination differs
command = "meshtop"         # optional, meshtop on the remote side
role = "dev"                # optional, shown next to the name
hostname = "MacBook-Pro-2"  # optional, the machine's own hostname

[[activity]]                 # replaces the built-in rules when present
label = "nix build"
user = "nixbld"              # with user set, distinct users are counted

[[activity]]
label = "xcodebuild"
name = ["xcodebuild"]        # exact process names
# cmd = "nix-daemon --stdio" # or a command line substring

[ports]
"1234" = "bluebubbles"

[[usage]]                    # replaces the default ~/.claude and ~/.codex
kind = "claude"              # or "codex"
name = "work"                # optional, defaults to the dir name
dir = "~/.claude-work"       # CLAUDE_CONFIG_DIR or CODEX_HOME

Plan usage is read on the machine the TUI runs on, once a minute, and an account only shows while it is signed in. Claude numbers come from the endpoint behind Claude Code's /usage, with the token Claude Code keeps in the keychain (or .credentials.json on Linux). Codex numbers come from Codex's own session logs, so they are as fresh as your last Codex turn. The β”‚ in each gauge marks how much of the window has passed: usage past it is ahead of pace.

ssh runs with BatchMode=yes, so key auth (or an agent) has to work without a prompt. A host that drops out is retried every 3 seconds.

License

MIT

About

Live resource usage, connections and coding agents across your machines, in one terminal

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages