Set up Pop!_OS for a Federated Core, like CoreDesktop's configure

A port of CoreDesktop's configure to Pop!_OS 24.04 with COSMIC, in the shape
of connector-macos: its own install.sh, update and configure, installed in
~/.local/share/federated-connector/connector.

Every configure item is ported: the Core (email, calendars and contacts
through GNOME Online Accounts and Evolution, as COSMIC has no accounts of its
own; Superpanel; files over davfs2; Element; Tally; the email watcher),
Tailscale, backups, AI agents in the sandbox and their sign-ins, languages
with mise, AI servers, printers, network storage and the agent sandbox.
Folders go in the COSMIC Files sidebar. Each item installs what it needs
from apt, Flathub or the tool's own apt repository when you set it up.

smoketest/run checks it in Ubuntu 24.04 containers with Docker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-11 14:20:47 -07:00
co-authored by Claude Opus 5.5
commit bc07e1d3e3
60 changed files with 5626 additions and 0 deletions
Executable
+145
View File
@@ -0,0 +1,145 @@
#!/bin/bash
#
# Purpose : Run an AI agent inside Anthropic's sandbox runtime (srt). srt uses
# bubblewrap to limit which files the agent can read and write, and
# removes its network; socat links it to a proxy outside the sandbox
# that only lets through the domains in its config.
#
# sandbox/bin/<agent> links here and `configure agents` puts sandbox/bin first
# on PATH (in ~/.bashrc), so typing an agent's name runs it sandboxed.
# `unsandboxed <agent>` runs the agent's real command instead.
#
# The config is sandbox/config/base.json, then sandbox/config/<agent>.json,
# then your own ~/.config/federated-connector/sandbox/base.json and
# <agent>.json, in the same format. Later files add to the lists in earlier
# ones. Domains in FEDERATED_SANDBOX_DOMAINS (space-separated) are allowed too;
# `configure agents` uses it for Hermes' gateway, whose messaging server
# differs on each machine.
# Wrapped in { ...; exit; } so bash reads the whole script up front; update
# replaces this file (git pull) while agents are running.
{
SANDBOX="$(dirname "$(realpath "$0")")"
CONNECTOR="$(dirname "$SANDBOX")"
USER_CONFIG="$HOME/.config/federated-connector/sandbox"
name="$(basename "$0")"
source "$CONNECTOR/configure.d/lib/agents.sh"
# The agent's real command: the first one on PATH outside sandbox/bin
real_command() {
agent_path "$1"
}
if [ "$name" = "unsandboxed" ]; then
if [ $# -eq 0 ]; then
echo "Usage: unsandboxed <agent> [arguments]"
exit 2
fi
agent="$1"
shift
real="$(real_command "$agent")" || { echo "$agent isn't installed."; exit 127; }
exec "$real" "$@"
fi
agent="$name"
real="$(real_command "$agent")" || { echo "$agent isn't installed."; exit 127; }
# Commands that share another agent's sandbox config
case "$agent" in
hermes-agent) profile=hermes ;;
*) profile="$agent" ;;
esac
# Cline Desktop is a window, usually opened from the app menu in your home
# directory, so it always starts in ~/Projects and can change projects there.
# Its profile hides /run/user, where your session's D-Bus and keyring sockets
# are, except the Wayland socket it draws through. The sandbox has no GPU, and
# WebKit can't start its own sandbox (bubblewrap) inside this one.
gui_socket=""
case "$profile" in
cline-desktop)
mkdir -p "$HOME/Projects" && cd "$HOME/Projects" || exit 1
gui_socket="$XDG_RUNTIME_DIR/${WAYLAND_DISPLAY:-wayland-0}"
export GDK_BACKEND=wayland WEBKIT_DISABLE_DMABUF_RENDERER=1 WEBKIT_DISABLE_SANDBOX_THIS_IS_DANGEROUS=1 ;;
esac
if ! srt="$(srt_path)"; then
echo "The sandbox (srt) isn't installed; run: configure agents. To run $agent without it: unsandboxed $agent"
exit 1
fi
# srt runs on the Node.js configure agents found or installed for it
PATH="$FC_TOOLS/srt/bin:$FC_TOOLS/node/bin:$PATH"
# The agent can change anything in the directory it starts in
case "$PWD" in
"$HOME"|/)
echo "Start $agent from a project directory. In the sandbox it can change anything in the directory it starts in, and this is $PWD."
exit 1 ;;
esac
configs=("$SANDBOX/config/base.json")
[ -f "$SANDBOX/config/$profile.json" ] && configs+=("$SANDBOX/config/$profile.json")
ours=("${configs[@]}")
for file in "$USER_CONFIG/base.json" "$USER_CONFIG/$profile.json"; do
[ -f "$file" ] && configs+=("$file")
done
# Objects are merged and lists joined, so later files only add to earlier ones
MERGE='
def merge(a; b):
reduce (b | to_entries[]) as $e (a;
.[$e.key] |= (
if type == "object" and ($e.value | type) == "object" then merge(.; $e.value)
elif type == "array" and ($e.value | type) == "array" then . + $e.value | unique
else $e.value end));
reduce .[] as $config ({}; merge(.; $config))'
# srt runs in place of this script (exec below), so a stop signal, e.g. from
# systemd, reaches it and it passes it on to the agent. That leaves nothing to
# remove the settings file afterwards, so it's named after this process, and
# files whose process has ended are removed here.
SETTINGS_DIR="${XDG_RUNTIME_DIR:-/tmp}/federated-sandbox"
mkdir -p -m 700 "$SETTINGS_DIR" || exit 1
for old in "$SETTINGS_DIR"/*.json; do
pid="${old%.json}"
pid="${pid##*.}"
[[ "$pid" =~ ^[0-9]+$ ]] && ! kill -0 "$pid" 2> /dev/null && rm -f "$old"
done
# Outside the sandbox's writable paths, so the agent can't change its own rules
settings="$SETTINGS_DIR/$agent.$$.json"
if ! jq -s --arg domains "$FEDERATED_SANDBOX_DOMAINS" --arg socket "$gui_socket" \
"$MERGE"' | .network.allowedDomains += ($domains | split(" ") | map(select(. != "")))
| if $socket != "" then .filesystem.allowRead += [$socket] else . end' \
"${configs[@]}" > "$settings"; then
echo "Couldn't read the sandbox config: ${configs[*]}"
exit 1
fi
# Bubblewrap can only make writable a directory that exists, and the agent
# can't create one itself in a parent it may not write to
while IFS= read -r path; do
path="${path/#\~/$HOME}"
case "$path" in "$HOME"/*) mkdir -p "$path" ;; esac
done < <(jq -rs "$MERGE | .filesystem.allowWrite[]? | strings" "${ours[@]}")
# srt sets TMPDIR to /tmp/claude, which nothing creates, unless told otherwise;
# temp files then fail, and GTK aborts. /tmp is writable in every profile.
export CLAUDE_CODE_TMPDIR=/tmp
# srt tells the agent to connect directly to private addresses (192.168.x.x
# and so on), but the sandbox has no network to do it with, so a server on
# your local network that the config allows by IP, e.g. an Ollama server from
# `configure ai-servers`, couldn't be reached. Only loopback is direct here;
# everything else goes through the proxy, which still allows only the config's
# domains and addresses.
NO_PROXY_DIRECT=localhost,127.0.0.1,::1
direct=(env "NO_PROXY=$NO_PROXY_DIRECT" "no_proxy=$NO_PROXY_DIRECT")
# Hermes' terminal reaches its gateway, in another sandbox, through a relay
case "$profile" in
hermes) exec "$srt" --settings "$settings" -- "${direct[@]}" bash "$SANDBOX/hermes-bridge" "$real" "$@" ;;
esac
exec "$srt" --settings "$settings" -- "${direct[@]}" "$real" "$@"
}
+1
View File
@@ -0,0 +1 @@
../agent
+1
View File
@@ -0,0 +1 @@
../agent
+1
View File
@@ -0,0 +1 @@
../agent
+1
View File
@@ -0,0 +1 @@
../agent
+1
View File
@@ -0,0 +1 @@
../agent
+96
View File
@@ -0,0 +1,96 @@
{
"network": {
"allowedDomains": [
"anthropic.com",
"*.anthropic.com",
"openai.com",
"*.openai.com",
"chatgpt.com",
"*.chatgpt.com",
"openrouter.ai",
"*.openrouter.ai",
"nousresearch.com",
"*.nousresearch.com",
"generativelanguage.googleapis.com",
"api.mistral.ai",
"api.deepseek.com",
"api.x.ai",
"api.groq.com",
"api.together.xyz",
"*.githubcopilot.com",
"github.com",
"*.github.com",
"*.githubusercontent.com",
"gitea.federated.computer",
"registry.npmjs.org",
"registry.yarnpkg.com",
"pypi.org",
"files.pythonhosted.org",
"crates.io",
"*.crates.io",
"rubygems.org",
"*.rubygems.org",
"proxy.golang.org",
"sum.golang.org",
"ubuntu.com",
"*.ubuntu.com",
"pop-os.org",
"*.pop-os.org",
"system76.com",
"*.system76.com"
],
"deniedDomains": []
},
"filesystem": {
"denyRead": [
"~/.ssh",
"~/.gnupg",
"~/.password-store",
"~/.local/share/keyrings",
"~/.netrc",
"~/.git-credentials",
"~/.aws",
"~/.azure",
"~/.config/gcloud",
"~/.kube",
"~/.docker",
"~/.config/gh",
"~/.config/tea",
"~/.config/borg",
"~/.config/Bitwarden",
"~/.config/Element",
"~/.mozilla",
"~/.config/chromium",
"~/.config/google-chrome",
"~/.config/BraveSoftware",
"~/.config/net.imput.helium",
"~/.var/app",
"~/.davfs2",
"~/.winboat",
"~/.claude",
"~/.claude.json",
"~/.hermes",
"~/.config/opencode",
"~/.local/share/opencode",
"~/.cline",
"~/.config/bot.cline.app",
"~/.local/share/bot.cline.app",
"~/.config/evolution",
"~/.local/share/evolution",
"~/.cache/evolution",
"~/.config/goa-1.0",
"~/.thunderbird"
],
"allowRead": [],
"allowWrite": [
".",
"/tmp",
"~/.npm",
"~/.cache/pip",
"~/.cargo/registry",
"~/.cargo/git",
"~/go/pkg/mod"
],
"denyWrite": []
}
}
+35
View File
@@ -0,0 +1,35 @@
{
"network": {
"allowedDomains": [
"cline.bot",
"*.cline.bot"
],
"allowAllUnixSockets": true
},
"filesystem": {
"denyRead": [
"/run/user",
"/run/dbus",
"/run/docker.sock",
"/run/podman",
"/run/tailscale",
"/run/ssh-unix-local",
"/tmp/.X11-unix",
"/tmp/tmux-*",
"/tmp/ssh-*",
"/tmp/*/SingletonSocket"
],
"allowRead": [
"~/.cline",
"~/.config/bot.cline.app",
"~/.local/share/bot.cline.app",
"~/.cache/bot.cline.app"
],
"allowWrite": [
"~/.cline",
"~/.config/bot.cline.app",
"~/.local/share/bot.cline.app",
"~/.cache/bot.cline.app"
]
}
}
+26
View File
@@ -0,0 +1,26 @@
{
"network": {
"allowedDomains": [],
"allowAllUnixSockets": true
},
"filesystem": {
"denyRead": [
"/run/user",
"/run/dbus",
"/run/docker.sock",
"/run/podman",
"/run/tailscale",
"/run/ssh-unix-local",
"/tmp/.X11-unix",
"/tmp/tmux-*",
"/tmp/ssh-*",
"/tmp/*/SingletonSocket"
],
"allowRead": [
"~/.hermes"
],
"allowWrite": [
"~/.hermes"
]
}
}
+21
View File
@@ -0,0 +1,21 @@
{
"network": {
"allowedDomains": [
"opencode.ai",
"*.opencode.ai",
"models.dev"
]
},
"filesystem": {
"allowRead": [
"~/.config/opencode",
"~/.local/share/opencode"
],
"allowWrite": [
"~/.config/opencode",
"~/.local/share/opencode",
"~/.local/state/opencode",
"~/.cache/opencode"
]
}
}
+81
View File
@@ -0,0 +1,81 @@
#!/bin/bash
#
# Purpose : Run Hermes inside its sandbox (sandbox/agent runs this there) and
# connect its terminal to its gateway.
#
# Hermes' gateway runs the agent; `hermes` in a terminal only talks to it, over
# the gateway's control socket and then a WebSocket on 127.0.0.1:<port>. Each
# sandbox has its own network, so that port can't be reached from another one.
# The gateway's sandbox relays the port to API_SOCKET, and a terminal's sandbox
# listens on the same port and relays to API_SOCKET, so `hermes` reaches the
# gateway as if they shared a network.
#
# Usage: hermes-bridge <hermes command> [arguments]
real="$1"
shift
HERMES_HOME="${HERMES_HOME:-$HOME/.hermes}"
API_SOCKET="$HERMES_HOME/federated-api.sock"
# The gateway's answer to `identify` on its control socket, or nothing if no
# gateway is running
identify() {
local control="$HERMES_HOME/gateway.sock"
[ -S "$control" ] || control="$(cat "$HERMES_HOME/gateway.sock.path" 2> /dev/null)"
[ -S "$control" ] || return 1
printf '{"protocol":1,"verb":"identify","id":1}\n' \
| socat -t 5 - "UNIX-CONNECT:$control" 2> /dev/null | grep .
}
# The port the gateway's API listens on, once the gateway is ready. Only an
# IPv4 loopback origin is relayed, which is what Hermes uses by default.
api_port() {
local origin
origin="$(identify | jq -r 'select(.result.state == "ready") | .result.api_origin // empty' 2> /dev/null)"
[[ "$origin" =~ ^http://127\.0\.0\.1:([0-9]+)$ ]] || return 1
echo "${BASH_REMATCH[1]}"
}
if [ "$1" = "gateway" ] && [ "$2" = "run" ]; then
# A terminal finds no relay, rather than the last gateway's, until this one
# is up
rm -f "$API_SOCKET"
# The relay waits for the gateway, which runs in this process once exec'd;
# the sandbox ends both together
(
for _ in $(seq 480); do
if port="$(api_port)"; then
exec socat "UNIX-LISTEN:$API_SOCKET,unlink-early,mode=600,fork" "TCP:127.0.0.1:$port"
fi
sleep 0.25
done
echo "hermes-bridge: the gateway's API didn't come up; terminals can't reach it" >&2
) &
exec "$real" "$@"
fi
# A terminal: relay the gateway's port, if a gateway is running or its service
# is turned on, waiting for one that is still starting. Without one, hermes
# starts its own gateway inside this sandbox, which needs no relay.
if [ -e "$HOME/.config/systemd/user/default.target.wants/hermes-gateway.service" ] \
|| identify > /dev/null; then
[ -S "$API_SOCKET" ] && api_port > /dev/null || echo "Waiting for Hermes' gateway..." >&2
for _ in $(seq 240); do
[ -S "$API_SOCKET" ] && port="$(api_port)" && break
port=""
sleep 0.25
done
if [ -n "$port" ]; then
socat "TCP-LISTEN:$port,bind=127.0.0.1,reuseaddr,fork" "UNIX-CONNECT:$API_SOCKET" &
# Wait for the listener (state 0A, LISTEN, in /proc/net/tcp) so hermes'
# first connection doesn't fail
hex="$(printf ':%04X ' "$port")"
for _ in $(seq 50); do
grep -q "$hex.* 0A " /proc/net/tcp && break
sleep 0.05
done
else
echo "hermes-bridge: Hermes' gateway is running but its API isn't reachable; try: systemctl --user restart hermes-gateway" >&2
fi
fi
exec "$real" "$@"