#!/usr/bin/env bash # Rebuild and run the agent daemon in the foreground. # # This terminal shows each context that asks for an identity, and what it was # given. # # Foreground on purpose, for the reason dev-pds.sh is: the log is the point. set -euo pipefail cd "$(dirname "$0")/.." . "$(dirname "$0")/dev-profile.sh" . "$(dirname "$0")/dev-watch.sh" . "$(dirname "$0")/dev-pidfile.sh" . "$(dirname "$0")/dev-build.sh" read_build_flags "$@" set -- "${DIDBOT_ARGV[@]}" # Where accounts come from. The dev server, unless this shell says otherwise. PDS="${DIDBOT_PDS:-http://localhost:${DIDBOT_PDS_PORT:-3000}}" # The path a plugin looks for with nothing configured, so the two ends meet # without either being told. Point it elsewhere to put something in front: # # DIDBOT_SOCK="${XDG_RUNTIME_DIR:-/tmp}/didbot-agent/daemon.sock" \ # ./scripts/dev-agentd.sh # # and didbot-claude's `./scripts/dev-feed.sh` takes the path this vacated, # narrating every record on its way through. SOCK="${DIDBOT_SOCK:-${XDG_RUNTIME_DIR:-/tmp}/didbot-agent/agent.sock}" say() { printf '\033[1m%s\033[0m\n' "$*"; } # Nothing here survives a restart, so a watch costs the build and nothing # else: the accounts it hands out live in the server, and it asks again for # any context it has forgotten. watch_or_continue "$@" # By the socket's own name rather than a port, so two stacks on one machine # do not stop each other's daemon. claim_port agentd "$(basename "$SOCK" .sock)" didbot-agentd build_before_running -p didbot-agentd say "agent daemon on ${SOCK}" echo " accounts from ${PDS}" echo " reachable by anything running as $(id -un); the socket's directory is the gate" echo exec env DIDBOT_PDS="$PDS" DIDBOT_SOCK="$SOCK" \ cargo run --quiet -p didbot-agentd --bin didbot-agentd -- "$@"