repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources15d ago| #1 | #!/usr/bin/env bash |
| #2 | # automaton-main/automation/leviathan.sh — Leviathan runtime bootstrap |
| #3 | # |
| #4 | # This is the canonical build-the-runtime entrypoint inside automaton-main. |
| #5 | # Served through https://x402.wtf/automation/install.sh. |
| #6 | # |
| #7 | # Usage (one-liner): |
| #8 | # curl -fsSL https://x402.wtf/automation/install.sh | bash |
| #9 | # |
| #10 | # Or run locally from this repo: |
| #11 | # bash automaton-main/automation/leviathan.sh [flags] |
| #12 | # |
| #13 | # Flags: |
| #14 | # --spawn Hatch a new Leviathan identity + keypair |
| #15 | # --run Start the OODA pulse loop |
| #16 | # --status Show depth, balances, spawnlings |
| #17 | # --hermes Launch the HERMES x402 terminal (TUI) |
| #18 | # --brain Init + start Clawd memory subsystem |
| #19 | # --mcp Start the MCP tool server |
| #20 | # --full Spawn + run + hermes + brain + mcp (full stack) |
| #21 | # --ci Type-check, lint, build (non-interactive CI mode) |
| #22 | # --no-install Skip npm install |
| #23 | # --no-perps Skip Phoenix/Vulcan perps bootstrap |
| #24 | # --quiet Suppress banners; keep ✓/✗ lines only |
| #25 | # -h | --help Show this message and exit |
| #26 | |
| #27 | set -euo pipefail |
| #28 | umask 022 |
| #29 | |
| #30 | # ── Colors (Solana brand: green #14F195, purple #9945FF) ────────────────────── |
| #31 | BOLD="\033[1m" |
| #32 | DIM="\033[2m" |
| #33 | GREEN="\033[38;2;20;241;149m" |
| #34 | PURPLE="\033[38;2;153;69;255m" |
| #35 | CYAN="\033[36m" |
| #36 | YELLOW="\033[33m" |
| #37 | RED="\033[31m" |
| #38 | RESET="\033[0m" |
| #39 | |
| #40 | # ── Defaults ────────────────────────────────────────────────────────────────── |
| #41 | DO_SPAWN=0 |
| #42 | DO_RUN=0 |
| #43 | DO_STATUS=0 |
| #44 | DO_HERMES=0 |
| #45 | DO_BRAIN=0 |
| #46 | DO_MCP=0 |
| #47 | DO_FULL=0 |
| #48 | DO_CI=0 |
| #49 | NO_INSTALL=0 |
| #50 | NO_PERPS=0 |
| #51 | QUIET=0 |
| #52 | CLAWD_DIR="${CLAWD_DIR:-$HOME/.clawd}" |
| #53 | LOCAL_BIN_DIR="${LOCAL_BIN_DIR:-$HOME/.local/bin}" |
| #54 | PERPS_PACKAGE="${PERPS_PACKAGE:-@openclawdsolana/clawd-perps}" |
| #55 | CLAWD_BACKROOM_URL="${CLAWD_BACKROOM_URL:-https://backrooms.x402.wtf}" |
| #56 | |
| #57 | banner() { |
| #58 | [ "$QUIET" -eq 1 ] && return 0 |
| #59 | echo -e "${BOLD}${PURPLE}" |
| #60 | cat <<'EOF' |
| #61 | ██╗ ███████╗██╗ ██╗██╗ █████╗ ████████╗██╗ ██╗ █████╗ ███╗ ██╗ |
| #62 | ██║ ██╔════╝██║ ██║██║██╔══██╗╚══██╔══╝██║ ██║██╔══██╗████╗ ██║ |
| #63 | ██║ █████╗ ██║ ██║██║███████║ ██║ ███████║███████║██╔██╗ ██║ |
| #64 | ██║ ██╔══╝ ╚██╗ ██╔╝██║██╔══██║ ██║ ██╔══██║██╔══██║██║╚██╗██║ |
| #65 | ███████╗███████╗ ╚████╔╝ ██║██║ ██║ ██║ ██║ ██║██║ ██║██║ ╚████║ |
| #66 | ╚══════╝╚══════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═══╝ |
| #67 | EOF |
| #68 | echo -e "${GREEN} Sovereign On-Chain Agent Runtime :: x402.wtf/automation${RESET}" |
| #69 | echo -e "${DIM} automaton-main/automation/leviathan.sh — runtime bootstrap${RESET}" |
| #70 | echo "" |
| #71 | } |
| #72 | |
| #73 | ok() { echo -e " ${GREEN}✓${RESET} $*"; } |
| #74 | warn() { echo -e " ${YELLOW}!${RESET} $*"; } |
| #75 | fail() { echo -e " ${RED}✗${RESET} $*"; exit 1; } |
| #76 | step() { [ "$QUIET" -eq 0 ] && echo -e "\n${BOLD}${CYAN}▶ $*${RESET}"; } |
| #77 | |
| #78 | usage() { |
| #79 | echo "Usage: bash automaton-main/automation/leviathan.sh [flags]" |
| #80 | echo " curl -fsSL https://x402.wtf/automation/install.sh | bash" |
| #81 | echo "" |
| #82 | echo "Flags:" |
| #83 | echo " --spawn Hatch a new Leviathan identity" |
| #84 | echo " --run Start the OODA pulse loop" |
| #85 | echo " --status Show depth, balances, spawnlings" |
| #86 | echo " --hermes Launch HERMES x402 terminal (TUI)" |
| #87 | echo " --brain Init Clawd memory subsystem" |
| #88 | echo " --mcp Start MCP tool server" |
| #89 | echo " --full Full stack: spawn + run + hermes + brain + mcp" |
| #90 | echo " --ci CI mode: typecheck + lint + build" |
| #91 | echo " --no-install Skip npm install" |
| #92 | echo " --no-perps Skip Phoenix/Vulcan perps bootstrap" |
| #93 | echo " --quiet Suppress banners" |
| #94 | echo " -h|--help Show this message" |
| #95 | exit 0 |
| #96 | } |
| #97 | |
| #98 | # ── Argument parsing ────────────────────────────────────────────────────────── |
| #99 | for arg in "$@"; do |
| #100 | case "$arg" in |
| #101 | --spawn) DO_SPAWN=1 ;; |
| #102 | --run) DO_RUN=1 ;; |
| #103 | --status) DO_STATUS=1 ;; |
| #104 | --hermes) DO_HERMES=1 ;; |
| #105 | --brain) DO_BRAIN=1 ;; |
| #106 | --mcp) DO_MCP=1 ;; |
| #107 | --full) DO_FULL=1 ;; |
| #108 | --ci) DO_CI=1 ;; |
| #109 | --no-install) NO_INSTALL=1 ;; |
| #110 | --no-perps) NO_PERPS=1 ;; |
| #111 | --quiet) QUIET=1 ;; |
| #112 | -h|--help) usage ;; |
| #113 | *) warn "Unknown flag: $arg" ;; |
| #114 | esac |
| #115 | done |
| #116 | |
| #117 | # ── When invoked via curl pipe with no args: default to --full ───────────────── |
| #118 | if [ "$DO_SPAWN" -eq 0 ] && [ "$DO_RUN" -eq 0 ] && [ "$DO_STATUS" -eq 0 ] && \ |
| #119 | [ "$DO_HERMES" -eq 0 ] && [ "$DO_BRAIN" -eq 0 ] && [ "$DO_MCP" -eq 0 ] && \ |
| #120 | [ "$DO_FULL" -eq 0 ] && [ "$DO_CI" -eq 0 ]; then |
| #121 | DO_FULL=1 |
| #122 | fi |
| #123 | |
| #124 | if [ "$DO_FULL" -eq 1 ]; then |
| #125 | DO_SPAWN=1; DO_RUN=1; DO_HERMES=1; DO_BRAIN=1; DO_MCP=1 |
| #126 | fi |
| #127 | |
| #128 | banner |
| #129 | |
| #130 | # ── Environment checks ──────────────────────────────────────────────────────── |
| #131 | step "Checking environment" |
| #132 | |
| #133 | if ! command -v node >/dev/null 2>&1; then |
| #134 | fail "Node.js not found. Install Node 20+: https://nodejs.org/" |
| #135 | fi |
| #136 | NODE_MAJOR="$(node -p "process.versions.node.split('.')[0]")" |
| #137 | if [ "${NODE_MAJOR}" -lt 20 ]; then |
| #138 | fail "Node >= 20 required. Current: $(node --version)" |
| #139 | fi |
| #140 | ok "Node $(node --version)" |
| #141 | |
| #142 | if ! command -v npm >/dev/null 2>&1; then |
| #143 | fail "npm not found." |
| #144 | fi |
| #145 | ok "npm $(npm --version)" |
| #146 | |
| #147 | # ── Resolve repo root ───────────────────────────────────────────────────────── |
| #148 | # Works whether run from the repo or piped from curl (cwd = download target) |
| #149 | if [ -f "package.json" ] && grep -q "solana-clawd" package.json 2>/dev/null; then |
| #150 | REPO_ROOT="$(pwd)" |
| #151 | elif [ -f "$(dirname "$0")/../../package.json" ]; then |
| #152 | REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)" |
| #153 | elif [ -f "$(dirname "$0")/../package.json" ]; then |
| #154 | REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)" |
| #155 | else |
| #156 | # Piped from curl — clone the repo first |
| #157 | step "Cloning solana-clawd" |
| #158 | REPO_ROOT="$HOME/.solana-clawd" |
| #159 | if [ ! -d "$REPO_ROOT/.git" ]; then |
| #160 | git clone https://github.com/x402agent/solana-clawd.git "$REPO_ROOT" |
| #161 | ok "Cloned to $REPO_ROOT" |
| #162 | else |
| #163 | git -C "$REPO_ROOT" pull --ff-only |
| #164 | ok "Updated $REPO_ROOT" |
| #165 | fi |
| #166 | fi |
| #167 | |
| #168 | cd "$REPO_ROOT" |
| #169 | |
| #170 | relay_perps_install() { |
| #171 | [ "${CLAWD_PERPS_NO_RELAY:-0}" = "1" ] && return 0 |
| #172 | command -v curl >/dev/null 2>&1 || return 0 |
| #173 | local msg |
| #174 | msg="🦞👑 AUTOMATION PERPS RELAY |
| #175 | One-shot automation installed Phoenix/Vulcan perps. |
| #176 | Surface: clawd-perps perps vulcan context |
| #177 | Strategies: TWAP · grid · TA · monitor · finalize |
| #178 | Law: paper first; live only with explicit --yes." |
| #179 | curl -fsS -m 5 -X POST "${CLAWD_BACKROOM_URL%/}/stream/human" \ |
| #180 | -H "Content-Type: application/json" \ |
| #181 | -d "$(node -e 'const msg=process.argv[1]; console.log(JSON.stringify({name:"automation-perps-installer",content:msg}))' "$msg")" \ |
| #182 | >/dev/null 2>&1 || true |
| #183 | } |
| #184 | |
| #185 | ensure_env_line() { |
| #186 | local file="$1" key="$2" value="$3" |
| #187 | if [ ! -f "$file" ] || ! grep -q "^${key}=" "$file" 2>/dev/null; then |
| #188 | printf "%s=%s\n" "$key" "$value" >> "$file" |
| #189 | fi |
| #190 | } |
| #191 | |
| #192 | bootstrap_perps() { |
| #193 | [ "$NO_PERPS" -eq 1 ] && { ok "Skipping Phoenix/Vulcan perps (--no-perps)"; return 0; } |
| #194 | [ "$DO_CI" -eq 1 ] && { ok "Skipping Phoenix/Vulcan perps in CI mode"; return 0; } |
| #195 | |
| #196 | step "Bootstrapping Phoenix/Vulcan perps" |
| #197 | mkdir -p "$LOCAL_BIN_DIR" "$CLAWD_DIR" |
| #198 | |
| #199 | if command -v npm >/dev/null 2>&1; then |
| #200 | npm install -g "$PERPS_PACKAGE" --no-audit --no-fund >/dev/null 2>&1 \ |
| #201 | && ok "Installed $PERPS_PACKAGE" \ |
| #202 | || warn "$PERPS_PACKAGE global install failed; fallback: npx $PERPS_PACKAGE" |
| #203 | fi |
| #204 | |
| #205 | if [ -d "$REPO_ROOT/packages/clawd-perps" ]; then |
| #206 | npm --prefix "$REPO_ROOT/packages/clawd-perps" install --no-audit --no-fund --legacy-peer-deps >/dev/null 2>&1 \ |
| #207 | && npm --prefix "$REPO_ROOT/packages/clawd-perps" run build >/dev/null 2>&1 \ |
| #208 | && ok "Built local packages/clawd-perps" \ |
| #209 | || warn "Local clawd-perps build skipped" |
| #210 | fi |
| #211 | |
| #212 | if command -v cargo >/dev/null 2>&1 && [ -f "$REPO_ROOT/vulcan-cli-master/Cargo.toml" ]; then |
| #213 | ( cd "$REPO_ROOT/vulcan-cli-master" && cargo build -p vulcan >/dev/null 2>&1 ) \ |
| #214 | && { |
| #215 | install -m 0755 "$REPO_ROOT/vulcan-cli-master/target/debug/vulcan" "$LOCAL_BIN_DIR/vulcan" |
| #216 | ok "Installed Vulcan CLI at $LOCAL_BIN_DIR/vulcan" |
| #217 | } \ |
| #218 | || warn "Vulcan build failed; install Rust/Cargo or set VULCAN_BIN" |
| #219 | elif command -v vulcan >/dev/null 2>&1; then |
| #220 | ok "Using existing Vulcan CLI at $(command -v vulcan)" |
| #221 | else |
| #222 | warn "Vulcan CLI not found; set VULCAN_BIN or install Vulcan later" |
| #223 | fi |
| #224 | |
| #225 | local env_file="$CLAWD_DIR/.env" |
| #226 | touch "$env_file" |
| #227 | chmod 0600 "$env_file" 2>/dev/null || true |
| #228 | ensure_env_line "$env_file" "CLAWD_PERPS_API_URL" "https://perp-api.phoenix.trade" |
| #229 | ensure_env_line "$env_file" "CLAWD_PERPS_RPC_URL" "https://api.mainnet-beta.solana.com" |
| #230 | ensure_env_line "$env_file" "CLAWD_PERPS_AGENT_PATH" "$REPO_ROOT/solana-python-agent/perps_agent.py" |
| #231 | ensure_env_line "$env_file" "VULCAN_BIN" "$LOCAL_BIN_DIR/vulcan" |
| #232 | ensure_env_line "$env_file" "PHOENIX_DEFAULT_MODE" "paper" |
| #233 | ensure_env_line "$env_file" "IMPERIAL_API_BASE" "https://api.imperial.space/api/v1" |
| #234 | ensure_env_line "$env_file" "IMPERIAL_API_KEY" "" |
| #235 | ensure_env_line "$env_file" "IMPERIAL_WALLET" "" |
| #236 | ensure_env_line "$env_file" "IMPERIAL_PROFILE_INDEX" "0" |
| #237 | ok "Wrote Phoenix perps defaults to $env_file" |
| #238 | |
| #239 | relay_perps_install |
| #240 | ok "Perps ready: clawd-perps perps vulcan context" |
| #241 | } |
| #242 | |
| #243 | # ── npm install ─────────────────────────────────────────────────────────────── |
| #244 | if [ "$NO_INSTALL" -eq 0 ]; then |
| #245 | step "Installing dependencies" |
| #246 | npm install --silent |
| #247 | ok "Dependencies installed" |
| #248 | fi |
| #249 | |
| #250 | bootstrap_perps |
| #251 | |
| #252 | # ── CI mode ─────────────────────────────────────────────────────────────────── |
| #253 | if [ "$DO_CI" -eq 1 ]; then |
| #254 | step "Running CI checks" |
| #255 | npm run typecheck && ok "typecheck passed" |
| #256 | npm run lint && ok "lint passed" |
| #257 | npm run build && ok "build passed" |
| #258 | ok "CI green" |
| #259 | exit 0 |
| #260 | fi |
| #261 | |
| #262 | # ── Automation runtime build (node side) ───────────────────────────────────── |
| #263 | step "Building automation runtime" |
| #264 | pnpm --dir "$REPO_ROOT/automaton-main" exec tsx automation/index.ts --build --no-install 2>/dev/null || \ |
| #265 | npm run build --silent 2>/dev/null || \ |
| #266 | warn "Build step skipped (tsx/dist not available; run npm run build manually)" |
| #267 | |
| #268 | # ── Spawn ───────────────────────────────────────────────────────────────────── |
| #269 | if [ "$DO_SPAWN" -eq 1 ]; then |
| #270 | step "Spawning Leviathan identity" |
| #271 | npm run leviathan:spawn |
| #272 | fi |
| #273 | |
| #274 | # ── Status ──────────────────────────────────────────────────────────────────── |
| #275 | if [ "$DO_STATUS" -eq 1 ]; then |
| #276 | step "Leviathan status" |
| #277 | npm run leviathan:status |
| #278 | fi |
| #279 | |
| #280 | # ── Brain ───────────────────────────────────────────────────────────────────── |
| #281 | if [ "$DO_BRAIN" -eq 1 ]; then |
| #282 | step "Initializing Clawd memory (MemeBRain)" |
| #283 | npm run brain:init 2>/dev/null || warn "brain:init skipped (Python/mnemosyne not installed)" |
| #284 | fi |
| #285 | |
| #286 | # ── MCP ─────────────────────────────────────────────────────────────────────── |
| #287 | if [ "$DO_MCP" -eq 1 ]; then |
| #288 | step "Starting MCP server (background)" |
| #289 | npm run mcp:start & |
| #290 | MCP_PID=$! |
| #291 | ok "MCP server PID $MCP_PID" |
| #292 | fi |
| #293 | |
| #294 | # ── Run / HERMES ───────────────────────────────────────────────────────────── |
| #295 | if [ "$DO_HERMES" -eq 1 ]; then |
| #296 | step "Launching HERMES x402 terminal" |
| #297 | npm run hermes |
| #298 | elif [ "$DO_RUN" -eq 1 ]; then |
| #299 | step "Starting Leviathan OODA loop" |
| #300 | npm run leviathan |
| #301 | fi |
| #302 | |
| #303 | echo "" |
| #304 | ok "Leviathan runtime ready. x402.wtf/automation" |
| #305 |