| 1 | #!/bin/sh |
| 2 | |
| 3 | |
| 4 | |
| 5 | set -eu |
| 6 | if ! command -v node >/dev/null 2>&1 || ! command -v curl >/dev/null 2>&1; then |
| 7 | printf '%s\n' '{"protocol":1,"status":"error","error":{"code":"dependency_missing","message":"Cage bootstrap requires Node.js 20+ and curl. Read https://lee-xeo.github.io/Claude-Cage/agent.md","next_action":"install_dependencies"}}' |
| 8 | exit 1 |
| 9 | fi |
| 10 | cage_bootstrap_tmp=$(mktemp -d) |
| 11 | trap 'rm -rf "$cage_bootstrap_tmp"' EXIT |
| 12 | trap 'exit 1' HUP INT TERM |
| 13 | if ! curl --proto '=https' --proto-redir '=https' --tlsv1.2 -fsSL --connect-timeout 15 --max-time 120 \ |
| 14 | https://lee-xeo.github.io/Claude-Cage/agent-bootstrap.mjs -o "$cage_bootstrap_tmp/bootstrap.mjs"; then |
| 15 | printf '%s\n' '{"protocol":1,"status":"error","error":{"code":"download_failed","message":"Could not download the public Cage bootstrap. No application or profile was changed.","next_action":"check_connectivity"}}' |
| 16 | exit 1 |
| 17 | fi |
| 18 | node "$cage_bootstrap_tmp/bootstrap.mjs" "$@" |