A macOS counterpart of CoreDesktop's configure, with the same drop-in items in configure.d/: - core: Mail, Calendar and Contacts through a configuration profile, Superpanel as an app, Nextcloud files through the Nextcloud app, and Element; with test-and-fix, password change and removal - tailscale: join the Core's network through headscale - backup: restic to Nextcloud through rclone, run by launchd through an app that can be given Full Disk Access - storage: SMB shares mounted the way Finder does, again at login and on network changes - agents, claude, opencode, hermes, sandbox: install the agents and run them in Anthropic's sandbox runtime (Seatbelt on macOS) - ai-servers: LLM servers on this Mac or the network, for the agents Apps and tools macOS lacks are offered for download, checked against their makers' Team IDs and notarization, or published SHA-256 sums. Everything runs on macOS' bash 3.2 with only built-in tools. smoketest/ runs scenarios in fresh macOS VMs with Tart. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
72 lines
3.2 KiB
Bash
72 lines
3.2 KiB
Bash
# shellcheck shell=bash
|
|
DESCRIPTION="Installs Node.js and srt, and the sandbox keeps a (fake) agent in: files, network, local servers"
|
|
TIER=quick
|
|
|
|
source "$CONNECTOR/configure.d/30-agents.sh"
|
|
source "$CONNECTOR/configure.d/50-ai-servers.sh"
|
|
PROJECT="$HOME/proj"
|
|
|
|
# Run a command as the "opencode" agent, in the sandbox, from a project
|
|
sandboxed() {
|
|
(cd "$PROJECT" && "$CONNECTOR/sandbox/bin/opencode" "$@")
|
|
}
|
|
|
|
fetch() {
|
|
sandboxed /usr/bin/curl -fsS -o /dev/null --max-time 20 "$1"
|
|
}
|
|
|
|
zsh_finds_sandboxed() {
|
|
[ "$(zsh -ic 'command -v opencode' 2> /dev/null)" = "$CONNECTOR/sandbox/bin/opencode" ]
|
|
}
|
|
|
|
scenario() {
|
|
local node server
|
|
step "Installing Node.js and srt"
|
|
check "tool_ensure node srt" tool_ensure node srt
|
|
check "Node.js is 22.12 or later" node_ok
|
|
check "srt is found" srt_path
|
|
|
|
# The agent is a stand-in that runs what it's given, so commands can be
|
|
# tried in its sandbox
|
|
mkdir -p "$HOME/.local/bin" "$PROJECT" "$HOME/.ssh"
|
|
printf '#!/bin/bash\nexec "$@"\n' > "$HOME/.local/bin/opencode"
|
|
chmod +x "$HOME/.local/bin/opencode"
|
|
echo secret > "$HOME/.ssh/smoke-secret"
|
|
|
|
step "Files"
|
|
check "the agent runs in the sandbox" sandboxed /usr/bin/true
|
|
check_not "it can't read ~/.ssh" sandboxed /bin/cat "$HOME/.ssh/smoke-secret"
|
|
check_not "it can't read the keychains" sandboxed /bin/ls "$HOME/Library/Keychains"
|
|
check "it can write in its project" sandboxed /usr/bin/touch "$PROJECT/written"
|
|
check_not "it can't write elsewhere in your home folder" sandboxed /usr/bin/touch "$HOME/outside"
|
|
check "it can write in /tmp" sandboxed /usr/bin/touch /tmp/smoke-written
|
|
check "it can make temp files (mktemp)" sandboxed /usr/bin/mktemp
|
|
check "it can open a pty (allowPty)" sandboxed /usr/bin/script -q /dev/null /usr/bin/true
|
|
check_not "it won't start in your home folder" bash -c "cd ~ && '$CONNECTOR/sandbox/bin/opencode' /usr/bin/true"
|
|
check "unsandboxed runs it outside" bash -c "cd '$PROJECT' && '$CONNECTOR/sandbox/bin/unsandboxed' opencode /bin/cat '$HOME/.ssh/smoke-secret'"
|
|
|
|
step "Network"
|
|
check "it reaches an allowed site (registry.npmjs.org)" fetch https://registry.npmjs.org/
|
|
check_not "it doesn't reach others (example.com)" fetch https://example.com/
|
|
|
|
step "An LLM server on this Mac"
|
|
node="$(tool_path node)"
|
|
"$node" -e 'require("http").createServer((q, s) => { s.setHeader("content-type", "application/json");
|
|
s.end(JSON.stringify({data: [{id: "smoke-model"}]})); }).listen(11434, "127.0.0.1")' &
|
|
server=$!
|
|
sleep 2
|
|
check_eq "server_models reads its models" smoke-model "$(server_models localhost:11434)"
|
|
check_not "the agent can't reach it before it's allowed" fetch http://localhost:11434/v1/models
|
|
check "sandbox_allow localhost:11434" sandbox_allow localhost:11434
|
|
check "...then it can, through srt's proxy" fetch http://localhost:11434/v1/models
|
|
check "sandbox_disallow" sandbox_disallow localhost:11434
|
|
check_not "...then it can't again" fetch http://localhost:11434/v1/models
|
|
kill "$server" 2> /dev/null
|
|
|
|
step "Shell and Claude Code"
|
|
check "put_on_path" put_on_path
|
|
check "a new zsh finds sandbox/bin's opencode first" zsh_finds_sandboxed
|
|
check "turn_on_claude_sandbox" turn_on_claude_sandbox
|
|
check "Claude Code's sandbox is on" claude_sandbox_on
|
|
}
|