Expand description
Which installed provider CLIs can go, decided by disuse and never by version number (docs/specs/SPEC_RUNTIME_MENU_REMAINING_GAPS_2026_10_01.md §5).
shared/cli/<provider>/<pin>/ is shared by every AgentMux version and
channel on the machine, and they can run at the same time: an older build
pins an older CLI, so “everything but the newest” would pull a CLI out from
under a live agent. A directory is removable only when ALL hold:
- it is not the current pin of any provider in this build’s registry;
- nothing has used it for
max_idle(seerecord_use); - no live controller’s command and no running process’s command line
mentions it (a scan that FAILS means “in use”: see
InUse); - the install lock can be taken without waiting.
Legacy per-version folders (instances/v<version>/cli/<provider>) go by the
same rules, except that their age is their install time and the running
version’s own folder is never touched.
Nothing here runs by itself: plan_prune only reads, and prune is
called by whoever decides it is time (§5.8 is an open owner decision on
automatic vs opt-in).
Structs§
- Candidate
- InUse
- What is running right now, as text to search for install paths in.
- Plan
- Report
- Run
- The outcome of one
run.
Enums§
Constants§
- DEFAULT_
MAX_ IDLE - The default line (spec §5.4): 30 days without use.
- LAST_
USED_ MARKER - Touched whenever an install is handed out; only its mtime matters.
- RECORD_
USE_ EVERY - How often
record_useactually writes: the marker is on the path that resolves a CLI for every spawn, so it must stay cheap.
Functions§
- current_
pins (provider, pin)of every provider in this build’s registry that has a pin.- dir_
size 🔒 - Total size of the files under
dir, never following a symlink. - gather_
in_ use - What running things mention, for
plan_prune/prune: the commands of every block that records one (live_commands: open panes AND panes restored from a layout, which hold the absolute CLI path until they mount) and every running process’s command line. - last_
activity 🔒 - The latest sign of life: the newest of the last-used marker and the install marker; the directory’s own mtime when neither exists.
- plan_
prune - Decide what could be removed. Reads only; nothing is touched.
- prune
- Remove what
plan_prunefound, re-checking each directory at the last moment:in_useis asked again (a CLI may have started since the plan), and a shared install’s lock must be free. The completion marker goes FIRST, so a directory half removed by a crash is already “not an install” and the next install into it clears the rest. - record_
use - Note that
dirwas just used. Best effort, throttled toRECORD_USE_EVERYby the marker’s own mtime; an error is ignored (a failure to record can only make the directory look older, and the other guards still apply). - run
- Plan, and unless
dry_run, carry out, a prune.dry_runis the caller’s explicit choice to delete: nothing in AgentMux calls this withfalseexcept a user action. - safe_
children 🔒 - Immediate subdirectories of
diras(name, path), skipping symlinks and unsafe names (reported throughkept). - scan_
process_ commands - The running processes’ command lines. Unix:
ps; Windows is not scanned (None, so nothing is pruned there until it is).