Expand description
install.start / install.cancel RPC handlers.
Phase α of SPEC_AGENT_INSTALL_STAGE_2026_05_17.md. Spawns
npm install <package> for the requested provider, streams every
line of stdout+stderr to install_chunk MPS events scoped to
install:<sessionId>, and emits a terminal { op: "done", ok, error? } event when the child exits (or the user cancels).
Phase α scope:
- npm-only install (existing per-version layout at
~/.agentmux/<version>/cli/<provider>/). - Plain piped stdio (no PTY) — npm doesn’t isatty-gate its output line-by-line, so pipes are fine here. PTY would be required for interactive post-install steps (Phase δ).
- Single in-flight install per session id. The frontend modal owns the session id and prevents parallel installs at the UI layer.
- Cancel kills the child via
kill_on_dropwhen the abort handle fires. The partialnode_modulesdir is rm-rf’d best-effort. - No verify / doctor / post-install steps yet — those land in Phase β.
Structs§
- Install
Cancel Req - Install
Cancel Result - Result of
install.cancel. - Install
Check Req - Install
Check Result - Result of
install.check. - Install
Session Registry - Per-session abort handle so
install.cancelcan kill an in-flight install. Also tracksactive_providersso concurrent sessions for the same provider directory are rejected — without that, cancel of one wouldrm_rfthe shared dir mid-install for the other.parking_lot::Mutexsince the engine is sync at the handler boundary. - Install
Start Req - Install
Start Result - Result of
install.start. Was an inlinejson!({ "sessionId": .. }). - Prereq
Tool Resolution - One tool’s resolution in
resolve.prereqs. - Resolve
Prereqs Req - Request for
resolve.prereqs. Was a function-local anonymous struct. - Resolve
Prereqs Result - Result of
resolve.prereqs.
Enums§
- Install
Chunk Event install_chunk: one line of an install’s output, or its end. Scopedinstall:<sessionId>;system.installsends the same events.- Install
Done Op - The
opof the last event of an install. - Install
Stream
Constants§
- COMMAND_
INSTALL_ CANCEL - COMMAND_
INSTALL_ CHECK - COMMAND_
INSTALL_ START - COMMAND_
RESOLVE_ PREREQS - INSTALL_
LOG_ 🔒TAIL_ LINES - How many lines of npm output a failed install logs.
Functions§
- effective_
pin 🔒 - The pinned CLI version an install of
provider_iduses: the backend provider registry’s pin (the source of truth), else the caller’s. - find_
on_ 🔒path tool’s absolute path in the directories ofpath(a PATH-style list).- installed_
bin_ 🔒in - installed_
dir_ 🔒among - The first of
dirsholdingcli_command’s shim — the install a launch would use. Pure overdirs, for tests. - installed_
version_ 🔒in - Version of a managed provider install, read from the installed package’s
own
package.json.Nonefor anything unreadable — a missing directory, a partial install, unparseable JSON — all of which mean “we do not know”, which is a distinct answer from “up to date” and must stay distinct. - is_
safe_ 🔒cli_ command - CLI command names are joined into the bin-resolution path; same
allowlist as provider ids, plus
.(some real CLIs include dots, e.g.eslint.cmd). - is_
safe_ 🔒provider_ id - Provider ids feed into the install dir path; reject anything that
could escape
~/.agentmux/<version>/cli/<provider>/. - manifest_
version 🔒 - probe_
prereq_ 🔒version - Version of the prereq binary at
path(already resolved on PATH), via--version, bounded so a hung binary can’t stall the launch check. - provider_
install_ 🔒dir - Where a new install of
provider_idgoes: the shared, pinned-version dir (backend::cli_install), which is also whatresolvecliand the launch path look in first. Honors portable / installed mode + theAGENTMUX_HOME_OVERRIDEtest override viaDataPaths::from_env(). - provider_
installed_ 🔒dirs - Every dir an existing install of
provider_idmay be in, in lookup order: the shared pinned-version dir, then the legacy per-AgentMux-version one. - push_
tail 🔒 - register_
install_ handlers - resolve_
installed_ 🔒dir - resolve_
tool_ 🔒path - Returns the path to the installed CLI binary if present in the
per-version cache, else None. Used by
install.check. Locate a system tool (e.g.git,gh) on this process’s PATH and return its absolute path; None when it isn’t there. - spawn_
install_ 🔒task