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 WPS 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
Check 🔒Req - 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
Constants§
Functions§
- 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>/. - provider_
install_ 🔒dir - Canonical install directory for a provider —
<agentmux_home>/instances/v<version>/cli/<provider>/. This is the same path the frontend uses to launch the agent (agent-model.ts::resolveCliDir), so the bin we drop innode_modules/.bin/is what the launch path will execute. Honors portable / installed mode + theAGENTMUX_HOME_OVERRIDEtest override viaDataPaths::from_env(). - register_
install_ handlers - resolve_
installed_ 🔒bin - 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 PATH. Uses the platform equivalent ofwhichand returns the resolved absolute path. None when the tool isn’t on PATH or the lookup itself failed. - spawn_
install_ 🔒task