|
1 | 1 | #!/usr/bin/env bash |
| 2 | +# shellcheck disable=SC2016 # single-quoted scripts expand in the agent's shell |
2 | 3 | # Provisions an fctl agent sandbox: the tools agents need, Claude Code and |
3 | 4 | # fctl. Used by the Dockerfile (container sandboxes) and by `fctl host image |
4 | 5 | # build --driver lima` (the fctl-base VM). Runs as root. |
|
9 | 10 | set -euo pipefail |
10 | 11 |
|
11 | 12 | AGENT_USER="${AGENT_USER:-agent}" |
| 13 | +# Toolchain versions. Rust is the release this repository builds with |
| 14 | +# (rust-toolchain.toml; a test in crates/fctl-host/src/image.rs keeps the two |
| 15 | +# in step), so sessions working on fctl have nothing to download. |
12 | 16 | NODE_MAJOR="${NODE_MAJOR:-22}" |
| 17 | +TYPESCRIPT_VERSION="${TYPESCRIPT_VERSION:-7.0.2}" |
| 18 | +BUN_VERSION="${BUN_VERSION:-1.4.3}" |
| 19 | +UV_VERSION="${UV_VERSION:-0.13.1}" |
| 20 | +PYTHON_VERSION="${PYTHON_VERSION:-3.15.0}" |
| 21 | +RUST_VERSION="${RUST_VERSION:-1.99.0}" |
13 | 22 | FCTL_VERSION="${FCTL_VERSION:-}" |
14 | 23 | FCTL_DOWNLOAD="${FCTL_DOWNLOAD:-}" |
15 | 24 | export DEBIAN_FRONTEND=noninteractive |
16 | 25 |
|
17 | 26 | apt-get update |
18 | 27 | apt-get install -y --no-install-recommends \ |
19 | | - ca-certificates curl git gnupg less openssh-client procps sudo unzip xz-utils zip \ |
20 | | - build-essential pkg-config jq ripgrep fd-find tree file \ |
21 | | - python3 python3-venv python3-pip |
| 28 | + ca-certificates curl wget git gnupg less openssh-client procps psmisc lsof sudo \ |
| 29 | + rsync unzip xz-utils zip zstd \ |
| 30 | + build-essential cmake pkg-config libssl-dev \ |
| 31 | + jq ripgrep fd-find tree file shellcheck sqlite3 |
| 32 | +# Debian calls fd `fdfind`. |
| 33 | +ln -sf /usr/bin/fdfind /usr/local/bin/fd |
22 | 34 |
|
23 | 35 | # GitHub CLI |
24 | 36 | curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg -o /usr/share/keyrings/githubcli-archive-keyring.gpg |
25 | 37 | echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" \ |
26 | 38 | > /etc/apt/sources.list.d/github-cli.list |
27 | 39 |
|
28 | | -# Node.js |
| 40 | +# Node.js and TypeScript. npm leaves out its funding and audit notices and |
| 41 | +# its update check, which only lengthen agents' output. |
29 | 42 | curl -fsSL "https://deb.nodesource.com/setup_${NODE_MAJOR}.x" | bash - |
30 | 43 | apt-get install -y --no-install-recommends gh nodejs |
31 | 44 | corepack enable || true |
| 45 | +npm config set --location=global fund=false audit=false update-notifier=false |
| 46 | +npm install -g "typescript@$TYPESCRIPT_VERSION" |
| 47 | +npm cache clean --force |
32 | 48 |
|
33 | | -# uv (Python) |
34 | | -curl -LsSf https://astral.sh/uv/install.sh | env UV_INSTALL_DIR=/usr/local/bin UV_NO_MODIFY_PATH=1 sh |
| 49 | +# uv, and Python for everyone: uv's build of CPython in /opt/uv/python, as |
| 50 | +# python3 and python in /usr/local/bin. |
| 51 | +curl -LsSf "https://astral.sh/uv/$UV_VERSION/install.sh" | env UV_INSTALL_DIR=/usr/local/bin UV_NO_MODIFY_PATH=1 sh |
| 52 | +env UV_PYTHON_INSTALL_DIR=/opt/uv/python UV_PYTHON_BIN_DIR=/usr/local/bin UV_NO_CACHE=1 \ |
| 53 | + uv python install --default --preview-features python-install-default "$PYTHON_VERSION" |
35 | 54 |
|
36 | 55 | rm -rf /var/lib/apt/lists/* |
37 | 56 |
|
@@ -64,6 +83,32 @@ rm -f /usr/local/bin/fctl-agent-*-linux |
64 | 83 | AGENT_HOME="$(getent passwd "$AGENT_USER" | cut -d: -f6)" |
65 | 84 | sudo -u "$AGENT_USER" -H bash -c 'curl -fsSL https://claude.ai/install.sh | bash' |
66 | 85 | sudo -u "$AGENT_USER" -H mkdir -p "$AGENT_HOME/workspace" |
67 | | -grep -q '.local/bin' "$AGENT_HOME/.profile" 2>/dev/null || echo 'export PATH="$HOME/.local/bin:/opt/fctl/bin:$PATH"' >> "$AGENT_HOME/.profile" |
68 | | -"$AGENT_HOME/.local/bin/claude" --version |
69 | | -/usr/local/bin/fctl --version |
| 86 | + |
| 87 | +# The agent's PATH: Claude Code and uv's tools in ~/.local/bin, Rust's and |
| 88 | +# Bun's tools, then fctl's supervisor. The Dockerfile sets the same; login |
| 89 | +# shells (setup scripts, the Lima driver's) get it from here. |
| 90 | +cat > /etc/profile.d/fctl.sh <<'EOF' |
| 91 | +PATH="$HOME/.local/bin:$HOME/.cargo/bin:$HOME/.bun/bin:/opt/fctl/bin:$PATH" |
| 92 | +EOF |
| 93 | + |
| 94 | +# Runs a script as the agent user in a login shell; it gets the arguments |
| 95 | +# after the script as $1…. |
| 96 | +as_agent() { |
| 97 | + local script="$1" |
| 98 | + shift |
| 99 | + sudo -u "$AGENT_USER" -H bash -lc "set -euo pipefail; $script" bash "$@" |
| 100 | +} |
| 101 | + |
| 102 | +# Rust, with the components and targets that rust-toolchain.toml lists, and |
| 103 | +# Bun, in the agent's home: they find their files through HOME alone |
| 104 | +# (fctl-agent passes Claude no RUSTUP_HOME or the like), and agents add |
| 105 | +# toolchains, targets and global tools without sudo. |
| 106 | +as_agent 'curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | |
| 107 | + sh -s -- -y --no-modify-path --profile minimal --default-toolchain "$1" \ |
| 108 | + --component rustfmt,clippy --target wasm32-unknown-unknown' "$RUST_VERSION" |
| 109 | +as_agent 'curl -fsSL https://bun.sh/install | bash -s "bun-v$1"' "$BUN_VERSION" |
| 110 | +as_agent 'ln -sf bun "$HOME/.bun/bin/bunx"' |
| 111 | + |
| 112 | +# What sessions find on the PATH. |
| 113 | +as_agent 'claude --version; fctl --version; python3 --version; uv --version |
| 114 | + rustc --version; cargo --version; node --version; tsc --version; bun --version' |
0 commit comments