Files
coredesktop/configure.d/32-hermes.sh
T
davidandClaude Opus 5.5 e991264ddc Let Hermes' gateway reach only a Matrix server you've allowed
sandbox/setup.sh allowed Hermes' gateway the host in MATRIX_HOMESERVER
from ~/.hermes/.env, which Hermes can write from inside its sandbox. On
the next update, Hermes could have opened the way out to any host it
chose.

The allowed server is now in ~/.config/coredesktop/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; update says so.
Only a plain host name counts, so it can't be a wildcard or carry escape
codes into the question. A migration carries over the server the
gateway's systemd drop-in allows now, so a working gateway keeps
working. sandbox/agent no longer takes domains from
COREDESKTOP_SANDBOX_DOMAINS, which nothing else used.

The security checks skill now records step 3 as done.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 16:13:32 -07:00

65 lines
2.0 KiB
Bash

#!/bin/bash
# configure reads TITLE and DESCRIPTION
# shellcheck disable=SC2034
TITLE="Hermes Agent"
# shellcheck disable=SC2034
DESCRIPTION="Choose a model provider and tools"
source "$COREDESKTOP/sandbox/hermes-homeserver.sh"
is_installed() {
[ -x "$HOME/.local/bin/hermes" ]
}
# Signed in with OAuth (e.g. Nous Portal), or an API key is set
has_provider() {
[ -s "$HOME/.hermes/auth.json" ] || grep -qE '^[A-Z_]*API_KEY=.+' "$HERMES_ENV" 2> /dev/null
}
# The Matrix server in Hermes' settings that its sandbox may not reach yet
pending_homeserver() {
local host
host="$(hermes_homeserver)"
[ -n "$host" ] && ! hermes_homeserver_allowed "$host" && echo "$host"
}
is_configured() {
has_provider && [ -z "$(pending_homeserver)" ]
}
choose_provider() {
echo " 1) Nous Portal (one sign-in covers the model, web search, images and more)"
echo " 2) Another provider (OpenRouter, OpenAI, Anthropic or your own endpoint)"
local choice
read -rp "Which provider? [1] " choice
case "$choice" in
""|1) unsandboxed hermes setup --portal ;;
2) unsandboxed hermes setup ;;
*) echo "Choose 1 or 2."; return 1 ;;
esac
}
# Hermes can name a Matrix server in its settings from inside its sandbox, so
# its gateway reaches only one you've said yes to here
allow_homeserver() {
local host
host="$(pending_homeserver)" || return 0
echo "Hermes' settings say its gateway talks to the Matrix server $host."
echo "Hermes can change those settings itself, so it can't reach a server until you allow it."
if confirm "Is $host your Matrix server, and may Hermes reach it?"; then
hermes_allow_homeserver "$host" || return 1
echo "Hermes can reach $host. Restart its gateway to use it: systemctl --user restart hermes-gateway"
else
echo "Hermes can't reach $host. If you didn't set it, check MATRIX_HOMESERVER in $HERMES_ENV."
fi
}
run_configure() {
# Only the server is new: don't ask about the provider again
if ! has_provider || [ -z "$(pending_homeserver)" ]; then
choose_provider || return 1
fi
allow_homeserver
}