Ports CoreDesktop's e991264, 05b13b2 and d974b91. configure agents allowed Hermes' gateway the host in MATRIX_HOMESERVER from ~/.hermes/.env, which Hermes can write from inside its sandbox, so it could open the way out to any host it chose. The allowed server is now in ~/.config/federated-connector/sandbox/hermes.json, which no sandbox can write. configure hermes is to do while Hermes names a server you haven't allowed, and asks about only that; configure agents says so. Only a plain host name counts, so it can't be a wildcard or carry escape codes into the question. sandbox/agent no longer reads FEDERATED_SANDBOX_DOMAINS. The server an old drop-in allows is carried over, read from the drop-in itself, when the gateway starts and when configure agents rewrites it, so a working gateway keeps working. Agents could read ~/.config/federated-connector, which has the Core's domain and user name; base.json now hides it. edit_json treats an empty settings file like a missing one: jq reads no JSON from an empty file and writes nothing back, so configure ai-servers said a server was added while the sandbox still blocked it. agent_path joined the last folder on PATH to ~/.local/bin, so an agent there wasn't found when ~/.local/bin wasn't on PATH (e.g. in a service). Smoketest: 55-hermes-homeserver, and 50-sandbox checks that an agent can't read the connector's settings. PLAN.md drops what's done. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
49 lines
1.5 KiB
Bash
49 lines
1.5 KiB
Bash
#!/bin/bash
|
|
#
|
|
# Purpose : Find the AI agents' real commands, outside the sandbox's own
|
|
# (sandbox/bin), and the sandbox runtime. Sourced by configure and
|
|
# sandbox/agent. Needs CONNECTOR.
|
|
|
|
SANDBOX_BIN="$CONNECTOR/sandbox/bin"
|
|
FC_TOOLS="$HOME/.local/share/federated-connector"
|
|
|
|
# Where the agents' installers put them, in case your shell's PATH doesn't
|
|
# have them yet (e.g. right after installing)
|
|
AGENT_DIRS="$HOME/.local/bin:$HOME/.opencode/bin:$HOME/.hermes/bin:/usr/local/bin:/usr/bin"
|
|
|
|
# The real command for an agent: the first on PATH, or in AGENT_DIRS, that
|
|
# isn't in sandbox/bin
|
|
agent_path() {
|
|
local dir bin_dir search="$PATH:$AGENT_DIRS" IFS=:
|
|
bin_dir="$(realpath "$SANDBOX_BIN" 2> /dev/null)"
|
|
# Split one variable: the ":" between two would join their neighbouring folders
|
|
for dir in $search; do
|
|
[ -n "$dir" ] && [ -d "$dir" ] || continue
|
|
[ "$(realpath "$dir")" = "$bin_dir" ] && continue
|
|
if [ -x "$dir/$1" ] && [ ! -d "$dir/$1" ]; then
|
|
echo "$dir/$1"
|
|
return 0
|
|
fi
|
|
done
|
|
return 1
|
|
}
|
|
|
|
agent_installed() {
|
|
agent_path "$1" > /dev/null
|
|
}
|
|
|
|
# Run an agent's real command rather than its sandboxed one: setting an agent
|
|
# up writes outside its sandbox
|
|
unsandboxed() {
|
|
local agent="$1" real
|
|
shift
|
|
real="$(agent_path "$agent")" || { echo "$agent isn't installed."; return 127; }
|
|
"$real" "$@"
|
|
}
|
|
|
|
# srt, and the Node.js it runs with: Federated Connector's own, or one
|
|
# already installed
|
|
srt_path() {
|
|
PATH="$FC_TOOLS/srt/bin:$FC_TOOLS/node/bin:$PATH" command -v srt
|
|
}
|