const INSTALL_SCRIPT: &str = r#"set -eu
DIR="$1"; MARKER="$2"; BIN="$3"; LIMIT="$4"; shift 4
STAGE="$DIR/.staging"
mkdir -p "$DIR"
rm -rf "$STAGE"
mkdir -p "$STAGE"
export npm_config_cache=/tmp/agentmux-npm-cache npm_config_update_notifier=false
trap 'rm -rf /tmp/agentmux-npm-cache "$STAGE"' EXIT
timeout -k 15 "$LIMIT" npm install --prefix "$STAGE" --no-audit --no-fund --no-progress --loglevel=error "$@"
"$STAGE/node_modules/.bin/$BIN" --version >/dev/null
rm -f "$DIR"/.installed-*
rm -rf "$DIR/node_modules"
mv "$STAGE/node_modules" "$DIR/node_modules"
"$DIR/node_modules/.bin/$BIN" --version >/dev/null
: > "$DIR/$MARKER""#;Expand description
$1 install dir, $2 marker, $3 command, $4 seconds npm may run, the
rest name@version.
npm installs into a staging directory inside the volume, so an attempt that
dies half-way never leaves a half-written node_modules where the CLI is
looked up. Only a verified install replaces the live tree, and the marker is
written last, so “marker present” always means “complete”. The marker of an
older pin goes before the swap for the same reason.