fix /state paths: sub-agents use /agents/<name>/state, not /state

sub-agent containers post-refactor bind their state at
/agents/<name>/state (manager keeps the legacy /state — see
lifecycle.rs:751). agent.md still said /state/forge-token; corrected
to /agents/{label}/state/forge-token (template-substituted at
boot). tea-login systemd unit now walks both candidates so the same
harness module works for the manager and sub-agents.
This commit is contained in:
müde 2026-05-16 23:37:49 +02:00
parent 9fc7cae132
commit 4a06615c5c
2 changed files with 13 additions and 5 deletions

View file

@ -160,10 +160,18 @@
path = [ pkgs.tea pkgs.coreutils ];
script = ''
set -eu
TOKEN_FILE=/state/forge-token
CONFIG=/root/.config/tea/config.yml
if [ ! -f "$TOKEN_FILE" ]; then
echo "tea-login: no $TOKEN_FILE (hive-forge not seeded); skipping"
# Manager keeps the legacy /state bind; sub-agents have
# /agents/<name>/state. Glob covers both — there's exactly one
# hit either way (manager: /state, sub-agent: its own
# /agents/* mount), since each container only sees its own
# state dir.
TOKEN_FILE=""
for f in /state/forge-token /agents/*/state/forge-token; do
[ -f "$f" ] && TOKEN_FILE="$f" && break
done
if [ -z "$TOKEN_FILE" ]; then
echo "tea-login: no forge-token (hive-forge not seeded); skipping"
exit 0
fi
if [ -f "$CONFIG" ]; then
@ -175,7 +183,7 @@
--name forge \
--url ${lib.escapeShellArg config.hyperhive.forge.url} \
--token "$(cat "$TOKEN_FILE")"
echo "tea-login: configured for ${config.hyperhive.forge.url}"
echo "tea-login: configured for ${config.hyperhive.forge.url} from $TOKEN_FILE"
'';
};