From 1cf0f04ee4757880415ff626808f5b236246cacf Mon Sep 17 00:00:00 2001 From: "fctl-sh[bot]" <343971779+fctl-sh[bot]@users.noreply.github.com> Date: Sun, 18 Oct 2026 02:53:05 +0000 Subject: [PATCH 1/2] feat: add Python 3.15, Rust, Bun and TypeScript to the sandbox image The default image had Node.js and Debian's Python 3.11, so sessions installed everything else themselves: a session working on fctl spent minutes and gigabytes on rustup before it could build. provision.sh now installs, at versions set at its top: - uv 0.13.1 and Python 3.15.0 (uv's CPython) as python3 and python; - Rust 1.99.0 with rustfmt, Clippy and wasm32-unknown-unknown, the toolchain rust-toolchain.toml pins (a test keeps the two in step); - TypeScript 7.0.2 and Bun 1.4.3 beside Node.js 22; - cmake, libssl-dev, wget, rsync, lsof, psmisc, zstd, ShellCheck and sqlite3, and an `fd` link to Debian's `fdfind`. Python, Rust and Bun live in the agent's home: fctl-agent starts Claude with only PATH, HOME and the locale, so tools that need RUSTUP_HOME and the like would not work, and agents can add versions without sudo. The PATH is the Dockerfile's, and /etc/profile.d/fctl.sh gives login shells (setup scripts, Lima) the same one; the ~/.profile line it replaces was never written, because Debian's skeleton .profile already mentions .local/bin. npm stops printing funding and audit notices. Co-Authored-By: Claude Opus 5.5 --- crates/fctl-host/src/image.rs | 35 +++++++++++++++++++- docs/architecture.md | 2 +- docs/getting-started.md | 10 +++--- images/agent/Dockerfile | 8 +++-- images/agent/README.md | 37 ++++++++++++++++++--- images/agent/provision.sh | 61 +++++++++++++++++++++++++++++------ 6 files changed, 130 insertions(+), 23 deletions(-) diff --git a/crates/fctl-host/src/image.rs b/crates/fctl-host/src/image.rs index 14ff2340..3630cdda 100644 --- a/crates/fctl-host/src/image.rs +++ b/crates/fctl-host/src/image.rs @@ -135,7 +135,7 @@ async fn run_inherit(program: &str, args: &[&str]) -> Result<()> { #[cfg(test)] mod tests { - use super::shell_quote; + use super::{PROVISION, shell_quote}; #[test] fn quotes_values_for_sh() { @@ -145,4 +145,37 @@ mod tests { ); assert_eq!(shell_quote("it's"), "'it'\\''s'"); } + + /// Sessions working on fctl find its toolchain already installed, rather + /// than having rustup download a second one. + #[test] + fn installs_the_rust_this_repository_builds_with() -> anyhow::Result<()> { + #[derive(serde::Deserialize)] + struct File { + toolchain: Toolchain, + } + #[derive(serde::Deserialize)] + struct Toolchain { + channel: String, + #[serde(default)] + components: Vec, + #[serde(default)] + targets: Vec, + } + let File { toolchain } = toml::from_str(include_str!("../../../rust-toolchain.toml"))?; + let mut wanted = vec![format!("RUST_VERSION:-{}}}", toolchain.channel)]; + if !toolchain.components.is_empty() { + wanted.push(format!("--component {}", toolchain.components.join(","))); + } + if !toolchain.targets.is_empty() { + wanted.push(format!("--target {}", toolchain.targets.join(","))); + } + for w in wanted { + assert!( + PROVISION.contains(&w), + "images/agent/provision.sh should have `{w}`, as rust-toolchain.toml says" + ); + } + Ok(()) + } } diff --git a/docs/architecture.md b/docs/architecture.md index bde1d789..0a4b89f2 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -42,7 +42,7 @@ before changing anything that crosses a component boundary. | `crates/fake-claude` | A scripted stand-in for `claude` that speaks stream-json. Used by tests and `cargo xtask dev`. | dev, CI | | `xtask` | Development automation (`cargo xtask dev`, `check`, `gen`, `deploy`, `dist`, `publish`). | dev, CI | | `web/` | The web app (React, Vite, TypeScript, WebGL). Served by fctl-control. | browser | -| `images/agent` | The default sandbox image (Debian, git, gh, node, python, claude, fctl). | sandboxes | +| `images/agent` | The default sandbox image (Debian, git, gh, Python, Rust, Node.js, Bun, claude, fctl). | sandboxes | Two more repositories complete the picture: [hyperstructure/design](https://github.com/hyperstructure/design) diff --git a/docs/getting-started.md b/docs/getting-started.md index 96343eec..ecbafe27 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -72,11 +72,11 @@ Any Mac with Apple silicon (or a Linux box) can be a host. On the Mac: fctl host install --build-image ``` - This builds the sandbox image (Debian with git, gh, Node, Python, uv and - Claude Code), writes `~/.config/fctl/host.toml`, and installs a launchd - agent (`sh.fctl.host`) that starts at login, restarts if it stops, and - keeps the Mac from sleeping while it is plugged in, so it can start work - at any hour. + This builds the sandbox image (Debian with git, gh, Python, uv, Rust, + Node, TypeScript, Bun and Claude Code), writes + `~/.config/fctl/host.toml`, and installs a launchd agent (`sh.fctl.host`) + that starts at login, restarts if it stops, and keeps the Mac from + sleeping while it is plugged in, so it can start work at any hour. 3. Check it: diff --git a/images/agent/Dockerfile b/images/agent/Dockerfile index e6c3a36c..b976b5e3 100644 --- a/images/agent/Dockerfile +++ b/images/agent/Dockerfile @@ -1,5 +1,6 @@ -# The default fctl sandbox image: Debian with git, gh, Node.js, Python (uv), -# build tools, Claude Code and fctl. Sessions run as the `agent` user. +# The default fctl sandbox image: Debian with git, gh, build tools, Python and +# uv, Rust, Node.js, TypeScript, Bun, Claude Code and fctl (README.md lists +# the versions). Sessions run as the `agent` user. # # fctl host image build # builds it with your driver (apple or docker) # docker build -t fctl-agent:latest images/agent @@ -16,5 +17,6 @@ RUN bash /tmp/provision.sh && rm /tmp/provision.sh USER agent WORKDIR /home/agent -ENV PATH=/home/agent/.local/bin:/opt/fctl/bin:$PATH +# As /etc/profile.d/fctl.sh (provision.sh) sets it for login shells. +ENV PATH=/home/agent/.local/bin:/home/agent/.cargo/bin:/home/agent/.bun/bin:/opt/fctl/bin:$PATH CMD ["tail", "-f", "/dev/null"] diff --git a/images/agent/README.md b/images/agent/README.md index df9bc4f3..b92e0a38 100644 --- a/images/agent/README.md +++ b/images/agent/README.md @@ -1,10 +1,39 @@ # Agent image -The default sandbox for fctl sessions: Debian bookworm with git, the GitHub -CLI, Node.js 22, Python 3 with uv, build tools, ripgrep, Claude Code -(installed for the `agent` user, who has passwordless sudo: the sandbox is -the boundary) and fctl (in `/usr/local/bin`). +The default sandbox for fctl sessions: Debian bookworm with the toolchains +agents build and test with, Claude Code (installed for the `agent` user, who +has passwordless sudo: the sandbox is the boundary) and fctl (in +`/usr/local/bin`). +- Python 3.15.0 as `python3` and `python` (uv's build of CPython), and uv + 0.13.1. +- Rust 1.99.0 through rustup, with rustfmt, Clippy and the + `wasm32-unknown-unknown` target: the toolchain in this repository's + `rust-toolchain.toml`, so sessions working on fctl have nothing to + download. +- Node.js 22 with npm, TypeScript 7.0.2 (`tsc`) and Bun 1.4.3. +- build-essential (gcc, make), cmake, pkg-config and OpenSSL's headers. +- git, the GitHub CLI, ripgrep, fd, jq, ShellCheck, sqlite3, curl, wget, + rsync, lsof, fuser, tree, file, zip, xz and zstd. + +The versions are set at the top of `provision.sh`. A test in +`crates/fctl-host/src/image.rs` fails when Rust's differs from +`rust-toolchain.toml`. + +- Python, Rust and Bun are installed for the agent user (in + `~/.local/share/uv`, `~/.rustup` and `~/.cargo`, and `~/.bun`), so agents + add Python versions, toolchains, targets and global tools (`uv tool + install`, `cargo install`, `bun add -g`) without sudo. uv's Python is + marked externally managed: packages go into a virtual environment (`uv + venv`, `python3 -m venv`) or come with `uv run --with`. Debian's Python + 3.11 stays in `/usr/bin` for system tools. +- `~/.local/bin`, `~/.cargo/bin`, `~/.bun/bin` and `/opt/fctl/bin` lead the + PATH. The Dockerfile sets it, and `/etc/profile.d/fctl.sh` sets it for + login shells (setup scripts, the Lima VM). fctl-agent passes Claude the + PATH, HOME and locale but not the image's other environment variables, so + every tool here works from the PATH alone. +- npm leaves out its funding and audit notices and its update check + (`/usr/etc/npmrc`); `npm audit` still runs when asked. - `fctl host image build` builds it locally as `fctl-agent:latest` with the host's driver (Apple `container build` or `docker build`), or provisions the `fctl-base` Lima VM with the same `provision.sh`. It installs the diff --git a/images/agent/provision.sh b/images/agent/provision.sh index e68261ee..047d4b49 100644 --- a/images/agent/provision.sh +++ b/images/agent/provision.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +# shellcheck disable=SC2016 # single-quoted scripts expand in the agent's shell # Provisions an fctl agent sandbox: the tools agents need, Claude Code and # fctl. Used by the Dockerfile (container sandboxes) and by `fctl host image # build --driver lima` (the fctl-base VM). Runs as root. @@ -9,29 +10,44 @@ set -euo pipefail AGENT_USER="${AGENT_USER:-agent}" +# Toolchain versions. Rust is the release this repository builds with +# (rust-toolchain.toml; a test in crates/fctl-host/src/image.rs keeps the two +# in step), so sessions working on fctl have nothing to download. NODE_MAJOR="${NODE_MAJOR:-22}" +TYPESCRIPT_VERSION="${TYPESCRIPT_VERSION:-7.0.2}" +BUN_VERSION="${BUN_VERSION:-1.4.3}" +UV_VERSION="${UV_VERSION:-0.13.1}" +PYTHON_VERSION="${PYTHON_VERSION:-3.15.0}" +RUST_VERSION="${RUST_VERSION:-1.99.0}" FCTL_VERSION="${FCTL_VERSION:-}" FCTL_DOWNLOAD="${FCTL_DOWNLOAD:-}" export DEBIAN_FRONTEND=noninteractive apt-get update apt-get install -y --no-install-recommends \ - ca-certificates curl git gnupg less openssh-client procps sudo unzip xz-utils zip \ - build-essential pkg-config jq ripgrep fd-find tree file \ - python3 python3-venv python3-pip + ca-certificates curl wget git gnupg less openssh-client procps psmisc lsof sudo \ + rsync unzip xz-utils zip zstd \ + build-essential cmake pkg-config libssl-dev python3 \ + jq ripgrep fd-find tree file shellcheck sqlite3 +# Debian calls fd `fdfind`. +ln -sf /usr/bin/fdfind /usr/local/bin/fd # GitHub CLI curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg -o /usr/share/keyrings/githubcli-archive-keyring.gpg echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" \ > /etc/apt/sources.list.d/github-cli.list -# Node.js +# Node.js and TypeScript. npm leaves out its funding and audit notices and +# its update check, which only lengthen agents' output. curl -fsSL "https://deb.nodesource.com/setup_${NODE_MAJOR}.x" | bash - apt-get install -y --no-install-recommends gh nodejs corepack enable || true +npm config set --location=global fund=false audit=false update-notifier=false +npm install -g "typescript@$TYPESCRIPT_VERSION" +npm cache clean --force -# uv (Python) -curl -LsSf https://astral.sh/uv/install.sh | env UV_INSTALL_DIR=/usr/local/bin UV_NO_MODIFY_PATH=1 sh +# uv, which also installs the agent's Python below +curl -LsSf "https://astral.sh/uv/$UV_VERSION/install.sh" | env UV_INSTALL_DIR=/usr/local/bin UV_NO_MODIFY_PATH=1 sh rm -rf /var/lib/apt/lists/* @@ -64,6 +80,33 @@ rm -f /usr/local/bin/fctl-agent-*-linux AGENT_HOME="$(getent passwd "$AGENT_USER" | cut -d: -f6)" sudo -u "$AGENT_USER" -H bash -c 'curl -fsSL https://claude.ai/install.sh | bash' sudo -u "$AGENT_USER" -H mkdir -p "$AGENT_HOME/workspace" -grep -q '.local/bin' "$AGENT_HOME/.profile" 2>/dev/null || echo 'export PATH="$HOME/.local/bin:/opt/fctl/bin:$PATH"' >> "$AGENT_HOME/.profile" -"$AGENT_HOME/.local/bin/claude" --version -/usr/local/bin/fctl --version + +# The agent's PATH: Claude Code and Python in ~/.local/bin, then Rust's and +# Bun's tools and fctl's supervisor. The Dockerfile sets the same; login +# shells (setup scripts, the Lima driver's) get it from here. +cat > /etc/profile.d/fctl.sh <<'EOF' +PATH="$HOME/.local/bin:$HOME/.cargo/bin:$HOME/.bun/bin:/opt/fctl/bin:$PATH" +EOF + +# Runs a script as the agent user in a login shell; it gets the arguments +# after the script as $1…. +as_agent() { + local script="$1" + shift + sudo -u "$AGENT_USER" -H bash -lc "set -euo pipefail; $script" bash "$@" +} + +# Toolchains installed for the agent user, who can then add Python versions, +# Rust toolchains and global packages without sudo: CPython as python3 and +# python (uv's build), Rust with the components and targets that +# rust-toolchain.toml lists, and Bun. +as_agent 'uv python install --default --preview-features python-install-default "$1"' "$PYTHON_VERSION" +as_agent 'curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | + sh -s -- -y --no-modify-path --profile minimal --default-toolchain "$1" \ + --component rustfmt,clippy --target wasm32-unknown-unknown' "$RUST_VERSION" +as_agent 'curl -fsSL https://bun.sh/install | bash -s "bun-v$1"' "$BUN_VERSION" +as_agent 'ln -sf bun "$HOME/.bun/bin/bunx"' + +# What sessions find on the PATH. +as_agent 'claude --version; fctl --version; python3 --version; uv --version + rustc --version; cargo --version; node --version; tsc --version; bun --version' From 7892b48b2b025a8ae1f1dfc999ab966d10af6268 Mon Sep 17 00:00:00 2001 From: "fctl-sh[bot]" <343971779+fctl-sh[bot]@users.noreply.github.com> Date: Sun, 18 Oct 2026 02:57:29 +0000 Subject: [PATCH 2/2] feat: install Python 3.15 for every user of the sandbox image uv's CPython goes to /opt/uv/python with python3 and python in /usr/local/bin, instead of the agent's home: root and images built from this one (which run apt and pip steps as root) get the same Python, with venv and pip, as the agent. Debian's python3-pip and python3-venv go; its python3 stays because NodeSource's nodejs depends on it. Co-Authored-By: Claude Opus 5.5 --- images/agent/README.md | 20 +++++++++++--------- images/agent/provision.sh | 20 +++++++++++--------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/images/agent/README.md b/images/agent/README.md index b92e0a38..039cee3d 100644 --- a/images/agent/README.md +++ b/images/agent/README.md @@ -5,8 +5,8 @@ agents build and test with, Claude Code (installed for the `agent` user, who has passwordless sudo: the sandbox is the boundary) and fctl (in `/usr/local/bin`). -- Python 3.15.0 as `python3` and `python` (uv's build of CPython), and uv - 0.13.1. +- Python 3.15.0 as `python3` and `python` for every user (uv's build of + CPython, in `/opt/uv/python`), and uv 0.13.1. - Rust 1.99.0 through rustup, with rustfmt, Clippy and the `wasm32-unknown-unknown` target: the toolchain in this repository's `rust-toolchain.toml`, so sessions working on fctl have nothing to @@ -20,13 +20,15 @@ The versions are set at the top of `provision.sh`. A test in `crates/fctl-host/src/image.rs` fails when Rust's differs from `rust-toolchain.toml`. -- Python, Rust and Bun are installed for the agent user (in - `~/.local/share/uv`, `~/.rustup` and `~/.cargo`, and `~/.bun`), so agents - add Python versions, toolchains, targets and global tools (`uv tool - install`, `cargo install`, `bun add -g`) without sudo. uv's Python is - marked externally managed: packages go into a virtual environment (`uv - venv`, `python3 -m venv`) or come with `uv run --with`. Debian's Python - 3.11 stays in `/usr/bin` for system tools. +- Rust and Bun are installed for the agent user (in `~/.rustup` and + `~/.cargo`, and `~/.bun`), so agents add toolchains, targets and global + tools without sudo: `cargo install`, `bun add -g`, and for Python `uv + tool install` and `uv python install`. Images built from this one run + cargo as `agent`. +- Python is marked externally managed: packages go into a virtual + environment (`uv venv`, `python3 -m venv`) or come with `uv run --with`. + Debian's Python 3.11, which Node.js depends on, stays in `/usr/bin`, + after `/usr/local/bin` on the PATH. - `~/.local/bin`, `~/.cargo/bin`, `~/.bun/bin` and `/opt/fctl/bin` lead the PATH. The Dockerfile sets it, and `/etc/profile.d/fctl.sh` sets it for login shells (setup scripts, the Lima VM). fctl-agent passes Claude the diff --git a/images/agent/provision.sh b/images/agent/provision.sh index 047d4b49..d93f1367 100644 --- a/images/agent/provision.sh +++ b/images/agent/provision.sh @@ -27,7 +27,7 @@ apt-get update apt-get install -y --no-install-recommends \ ca-certificates curl wget git gnupg less openssh-client procps psmisc lsof sudo \ rsync unzip xz-utils zip zstd \ - build-essential cmake pkg-config libssl-dev python3 \ + build-essential cmake pkg-config libssl-dev \ jq ripgrep fd-find tree file shellcheck sqlite3 # Debian calls fd `fdfind`. ln -sf /usr/bin/fdfind /usr/local/bin/fd @@ -46,8 +46,11 @@ npm config set --location=global fund=false audit=false update-notifier=false npm install -g "typescript@$TYPESCRIPT_VERSION" npm cache clean --force -# uv, which also installs the agent's Python below +# uv, and Python for everyone: uv's build of CPython in /opt/uv/python, as +# python3 and python in /usr/local/bin. curl -LsSf "https://astral.sh/uv/$UV_VERSION/install.sh" | env UV_INSTALL_DIR=/usr/local/bin UV_NO_MODIFY_PATH=1 sh +env UV_PYTHON_INSTALL_DIR=/opt/uv/python UV_PYTHON_BIN_DIR=/usr/local/bin UV_NO_CACHE=1 \ + uv python install --default --preview-features python-install-default "$PYTHON_VERSION" rm -rf /var/lib/apt/lists/* @@ -81,8 +84,8 @@ AGENT_HOME="$(getent passwd "$AGENT_USER" | cut -d: -f6)" sudo -u "$AGENT_USER" -H bash -c 'curl -fsSL https://claude.ai/install.sh | bash' sudo -u "$AGENT_USER" -H mkdir -p "$AGENT_HOME/workspace" -# The agent's PATH: Claude Code and Python in ~/.local/bin, then Rust's and -# Bun's tools and fctl's supervisor. The Dockerfile sets the same; login +# The agent's PATH: Claude Code and uv's tools in ~/.local/bin, Rust's and +# Bun's tools, then fctl's supervisor. The Dockerfile sets the same; login # shells (setup scripts, the Lima driver's) get it from here. cat > /etc/profile.d/fctl.sh <<'EOF' PATH="$HOME/.local/bin:$HOME/.cargo/bin:$HOME/.bun/bin:/opt/fctl/bin:$PATH" @@ -96,11 +99,10 @@ as_agent() { sudo -u "$AGENT_USER" -H bash -lc "set -euo pipefail; $script" bash "$@" } -# Toolchains installed for the agent user, who can then add Python versions, -# Rust toolchains and global packages without sudo: CPython as python3 and -# python (uv's build), Rust with the components and targets that -# rust-toolchain.toml lists, and Bun. -as_agent 'uv python install --default --preview-features python-install-default "$1"' "$PYTHON_VERSION" +# Rust, with the components and targets that rust-toolchain.toml lists, and +# Bun, in the agent's home: they find their files through HOME alone +# (fctl-agent passes Claude no RUSTUP_HOME or the like), and agents add +# toolchains, targets and global tools without sudo. as_agent 'curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --profile minimal --default-toolchain "$1" \ --component rustfmt,clippy --target wasm32-unknown-unknown' "$RUST_VERSION"