#!/bin/sh set -eu root=$(cd "$(dirname "$0")/.." && pwd) tmp=$(mktemp -d) trap 'kill $srv 2>/dev/null; rm -rf "$tmp"' EXIT port=$((20000 + ($$ + 13) % 20000)) python3 "$root/tests/fake_anthropic.py" $port & srv=$! mkdir -p "$tmp/home/.hx" "$tmp/repo" echo '{"claude":{"access":"fake-token","refresh":"r","expires":99999999999999}}' > "$tmp/home/.hx/auth.json" sleep 0.5 cd "$tmp/repo" export HOME="$tmp/home" HX_BASE_URL="http://127.0.0.1:$port" python3 "$root/tests/rpc_ask_client.py" "$root/target/debug/hx" > "$tmp/out" || { echo "FAIL: rpc ask"; cat "$tmp/out"; exit 1; } [ "$(cat hello.txt)" = "hi from hx" ] || { echo "FAIL: allowed write did not run"; exit 1; } echo "rpc ask e2e ok"