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>
96 lines
3.3 KiB
Bash
96 lines
3.3 KiB
Bash
#!/bin/bash
|
|
|
|
# configure reads TITLE and DESCRIPTION
|
|
# shellcheck disable=SC2034
|
|
TITLE="Agent sandbox"
|
|
# shellcheck disable=SC2034
|
|
DESCRIPTION="Choose what agents may read, e.g. iCloud Drive"
|
|
|
|
# Your own sandbox config, which every sandboxed agent reads after
|
|
# sandbox/config/base.json (see sandbox/agent)
|
|
SANDBOX_CONF="$CONF_DIR/sandbox/base.json"
|
|
source "$CONNECTOR/configure.d/lib/json.sh"
|
|
source "$CONNECTOR/configure.d/lib/agents.sh"
|
|
|
|
# Folders the sandbox hides from agents (sandbox/config/base.json) that you
|
|
# may let them read: "path|what it is". Your SSH keys, keychains, password
|
|
# managers, browsers, mail and messages aren't here; they're always hidden.
|
|
# A path in allowRead can be read even inside one in denyRead, so letting
|
|
# agents read one is adding it to allowRead in your own config.
|
|
# Cloud drives are hidden because they hold everything you've put in them,
|
|
# and reading a file macOS keeps only in the cloud downloads it.
|
|
# The paths are written as in base.json, with ~ for srt to expand
|
|
# shellcheck disable=SC2088
|
|
OPTIONAL_HIDDEN=(
|
|
"~/Library/Mobile Documents|iCloud Drive"
|
|
"~/Library/CloudStorage|Nextcloud's and other cloud drives' files"
|
|
)
|
|
|
|
# Offered once the sandbox is installed and one of the folders is on this Mac
|
|
is_installed() {
|
|
local entry path
|
|
srt_path > /dev/null || return 1
|
|
for entry in "${OPTIONAL_HIDDEN[@]}"; do
|
|
path="${entry%%|*}"
|
|
[ -e "${path/#\~/$HOME}" ] && return 0
|
|
done
|
|
return 1
|
|
}
|
|
|
|
# Hiding them is the default, so there's nothing you need to do
|
|
is_configured() {
|
|
true
|
|
}
|
|
|
|
# True if agents may read $1 (it's in your config's allowRead)
|
|
readable() {
|
|
[ -f "$SANDBOX_CONF" ] \
|
|
&& json_get '(d.filesystem && d.filesystem.allowRead || []).indexOf(a[0]) >= 0' "$1" \
|
|
< "$SANDBOX_CONF" > /dev/null
|
|
}
|
|
|
|
let_read() {
|
|
json_edit "$SANDBOX_CONF" '
|
|
d.filesystem = d.filesystem || {};
|
|
var list = (d.filesystem.allowRead || []).filter(function (p) { return p !== a[0]; });
|
|
list.push(a[0]);
|
|
d.filesystem.allowRead = list;' "$1"
|
|
}
|
|
|
|
hide() {
|
|
[ -f "$SANDBOX_CONF" ] || return 0
|
|
json_edit "$SANDBOX_CONF" '
|
|
if (d.filesystem && d.filesystem.allowRead) {
|
|
d.filesystem.allowRead = d.filesystem.allowRead.filter(function (p) { return p !== a[0]; });
|
|
}' "$1"
|
|
}
|
|
|
|
run_configure() {
|
|
local choice i path what state
|
|
echo "Agents in the sandbox can't read these unless you let them. Changes apply the next"
|
|
echo "time you start an agent. Claude Code's own sandbox doesn't use this list."
|
|
|
|
while true; do
|
|
echo
|
|
for i in "${!OPTIONAL_HIDDEN[@]}"; do
|
|
IFS='|' read -r path what <<< "${OPTIONAL_HIDDEN[$i]}"
|
|
if readable "$path"; then state="${YELLOW}agents can read it$RESET"; else state="${GREEN}hidden$RESET"; fi
|
|
printf " %d) %-28s %s %s\n" $((i + 1)) "$path" "$state" "$what"
|
|
done
|
|
echo " q) Done"
|
|
echo
|
|
read -rp "Choose one to switch: " choice || return 0
|
|
if ! [[ "$choice" =~ ^[0-9]+$ ]] || [ "$choice" -lt 1 ] || [ "$choice" -gt ${#OPTIONAL_HIDDEN[@]} ]; then
|
|
return 0
|
|
fi
|
|
IFS='|' read -r path what <<< "${OPTIONAL_HIDDEN[$((choice - 1))]}"
|
|
if readable "$path"; then
|
|
hide "$path" || return 1
|
|
echo "$path is hidden from agents again."
|
|
elif confirm "Let agents read $path ($what)?"; then
|
|
let_read "$path" || return 1
|
|
echo "Agents can read $path."
|
|
fi
|
|
done
|
|
}
|