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 | # ╔══════════════════════════════════════════════════════════════════════════╗ |
| #3 | # ║ Leviathan Runtime Bootstrap ║ |
| #4 | # ║ Sovereign AI Lobster Runtime — Solana-native agent stack ║ |
| #5 | # ║ $CLAWD: 8cHzQHUS2s2h8TzCmfqPKYiM4dSt4roa3n7MyRLApump ║ |
| #6 | # ║ Usage: bash leviathan.sh [--full] ║ |
| #7 | # ╚══════════════════════════════════════════════════════════════════════════╝ |
| #8 | set -euo pipefail |
| #9 | |
| #10 | RESET="\033[0m" |
| #11 | BOLD="\033[1m" |
| #12 | GREEN="\033[32m" |
| #13 | YELLOW="\033[33m" |
| #14 | RED="\033[31m" |
| #15 | CYAN="\033[36m" |
| #16 | MAGENTA="\033[35m" |
| #17 | |
| #18 | ok() { printf "${GREEN}✅ %s${RESET}\n" "$*"; } |
| #19 | info() { printf "${CYAN}ℹ %s${RESET}\n" "$*"; } |
| #20 | warn() { printf "${YELLOW}⚠️ %s${RESET}\n" "$*"; } |
| #21 | die() { printf "${RED}❌ %s${RESET}\n" "$*" >&2; exit 1; } |
| #22 | step() { printf "\n${BOLD}${MAGENTA}▶ %s${RESET}\n" "$*"; } |
| #23 | |
| #24 | # ── Banner ──────────────────────────────────────────────────────────────── |
| #25 | printf "${CYAN}${BOLD}" |
| #26 | cat << 'BANNER' |
| #27 | |
| #28 | ██████╗██╗ █████╗ ██╗ ██╗██████╗ |
| #29 | ██╔════╝██║ ██╔══██╗██║ ██║██╔══██╗ |
| #30 | ██║ ██║ ███████║██║ █╗ ██║██║ ██║ |
| #31 | ██║ ██║ ██╔══██║██║███╗██║██║ ██║ |
| #32 | ╚██████╗███████╗██║ ██║╚███╔███╔╝██████╔╝ |
| #33 | ╚═════╝╚══════╝╚═╝ ╚═╝ ╚══╝╚══╝ ╚═════╝ |
| #34 | |
| #35 | 🦞 Leviathan Runtime Bootstrap — Crustacean Automation |
| #36 | ⚠ $CLAWD CA: 8cHzQHUS2s2h8TzCmfqPKYiM4dSt4roa3n7MyRLApump |
| #37 | 🌐 x402.wtf/automation | @clawddevs |
| #38 | |
| #39 | BANNER |
| #40 | printf "${RESET}" |
| #41 | |
| #42 | # ── Config ──────────────────────────────────────────────────────────────── |
| #43 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| #44 | REPO_ROOT="${SCRIPT_DIR}" |
| #45 | LOCAL_BIN_DIR="${HOME}/.local/bin" |
| #46 | LOCAL_BIN_TARGET="${LOCAL_BIN_DIR}/clawd-automaton" |
| #47 | FULL_MODE=false |
| #48 | NO_PERPS=false |
| #49 | PERPS_PACKAGE="${PERPS_PACKAGE:-@openclawdsolana/clawd-perps}" |
| #50 | CLAWD_DIR="${CLAWD_DIR:-$HOME/.clawd}" |
| #51 | CLAWD_BACKROOM_URL="${CLAWD_BACKROOM_URL:-https://backrooms.x402.wtf}" |
| #52 | for arg in "$@"; do |
| #53 | case "$arg" in |
| #54 | --full) FULL_MODE=true ;; |
| #55 | --no-perps) NO_PERPS=true ;; |
| #56 | esac |
| #57 | done |
| #58 | |
| #59 | ensure_env_line() { |
| #60 | local file="$1" key="$2" value="$3" |
| #61 | if [ ! -f "$file" ] || ! grep -q "^${key}=" "$file" 2>/dev/null; then |
| #62 | printf "%s=%s\n" "$key" "$value" >> "$file" |
| #63 | fi |
| #64 | } |
| #65 | |
| #66 | relay_perps_install() { |
| #67 | [ "${CLAWD_PERPS_NO_RELAY:-0}" = "1" ] && return 0 |
| #68 | command -v curl >/dev/null 2>&1 || return 0 |
| #69 | local msg |
| #70 | msg="🦞👑 LEVIATHAN AUTOMATION PERPS RELAY |
| #71 | Local Leviathan bootstrap connected Phoenix/Vulcan perps. |
| #72 | Surface: clawd-perps perps vulcan context |
| #73 | Imperial strategy loop armed: TWAP · grid · TA." |
| #74 | curl -fsS -m 5 -X POST "${CLAWD_BACKROOM_URL%/}/stream/human" \ |
| #75 | -H "Content-Type: application/json" \ |
| #76 | -d "$(node -e 'const msg=process.argv[1]; console.log(JSON.stringify({name:"leviathan-automation-perps",content:msg}))' "$msg")" \ |
| #77 | >/dev/null 2>&1 || true |
| #78 | } |
| #79 | |
| #80 | bootstrap_perps() { |
| #81 | $NO_PERPS && { ok "Skipping Phoenix/Vulcan perps (--no-perps)"; return 0; } |
| #82 | step "Bootstrapping Phoenix/Vulcan perps" |
| #83 | mkdir -p "$LOCAL_BIN_DIR" "$CLAWD_DIR" |
| #84 | |
| #85 | npm install -g "$PERPS_PACKAGE" --no-audit --no-fund >/dev/null 2>&1 \ |
| #86 | && ok "Installed $PERPS_PACKAGE" \ |
| #87 | || warn "$PERPS_PACKAGE install failed; fallback: npx $PERPS_PACKAGE" |
| #88 | |
| #89 | if [ -d "${REPO_ROOT}/../vulcan-cli-master" ] && command -v cargo >/dev/null 2>&1; then |
| #90 | ( cd "${REPO_ROOT}/../vulcan-cli-master" && cargo build -p vulcan >/dev/null 2>&1 ) \ |
| #91 | && { |
| #92 | install -m 0755 "${REPO_ROOT}/../vulcan-cli-master/target/debug/vulcan" "${LOCAL_BIN_DIR}/vulcan" |
| #93 | ok "Installed Vulcan CLI at ${LOCAL_BIN_DIR}/vulcan" |
| #94 | } \ |
| #95 | || warn "Vulcan build failed; set VULCAN_BIN later" |
| #96 | elif command -v vulcan >/dev/null 2>&1; then |
| #97 | ok "Using existing Vulcan CLI at $(command -v vulcan)" |
| #98 | else |
| #99 | warn "Vulcan not found; set VULCAN_BIN later" |
| #100 | fi |
| #101 | |
| #102 | local env_file="$CLAWD_DIR/.env" |
| #103 | touch "$env_file" |
| #104 | chmod 0600 "$env_file" 2>/dev/null || true |
| #105 | ensure_env_line "$env_file" "CLAWD_PERPS_API_URL" "https://perp-api.phoenix.trade" |
| #106 | ensure_env_line "$env_file" "CLAWD_PERPS_RPC_URL" "https://api.mainnet-beta.solana.com" |
| #107 | ensure_env_line "$env_file" "CLAWD_PERPS_AGENT_PATH" "${REPO_ROOT}/../solana-python-agent/perps_agent.py" |
| #108 | ensure_env_line "$env_file" "CLAWD_PERPS_TS_AGENT_CLI" "${REPO_ROOT}/../Perps/clawd-agents-perps/dist/cli.js" |
| #109 | ensure_env_line "$env_file" "VULCAN_BIN" "${LOCAL_BIN_DIR}/vulcan" |
| #110 | ensure_env_line "$env_file" "PHOENIX_DEFAULT_MODE" "paper" |
| #111 | ensure_env_line "$env_file" "CLAWD_ONCHAIN_MM_ROOT" "${REPO_ROOT}/../Perps/phoenix-onchain-market-maker-master" |
| #112 | ensure_env_line "$env_file" "CLAWD_ONCHAIN_MM_MARKET" "" |
| #113 | ensure_env_line "$env_file" "CLAWD_ONCHAIN_MM_TICKER" "SOL-USD" |
| #114 | ensure_env_line "$env_file" "CLAWD_ONCHAIN_MM_RPC_URL" "local" |
| #115 | ensure_env_line "$env_file" "CLAWD_ONCHAIN_MM_LIVE" "false" |
| #116 | ensure_env_line "$env_file" "CLAWD_PERPS_EXTRA_RELAY_URLS" "" |
| #117 | ensure_env_line "$env_file" "CLAWD_FLY_BACKROOMS_URL" "" |
| #118 | ensure_env_line "$env_file" "CLAWD_PUMPFUN_WS_URL" "" |
| #119 | ensure_env_line "$env_file" "CLAWD_PUMPFUN_UI_URL" "" |
| #120 | ensure_env_line "$env_file" "IMPERIAL_API_BASE" "https://api.imperial.space/api/v1" |
| #121 | ensure_env_line "$env_file" "IMPERIAL_API_KEY" "" |
| #122 | ensure_env_line "$env_file" "IMPERIAL_WALLET" "" |
| #123 | ensure_env_line "$env_file" "IMPERIAL_PROFILE_INDEX" "0" |
| #124 | ok "Phoenix perps env defaults ready at $env_file" |
| #125 | |
| #126 | relay_perps_install |
| #127 | } |
| #128 | |
| #129 | # ── Check Node.js ───────────────────────────────────────────────────────── |
| #130 | step "Checking Node.js" |
| #131 | if ! command -v node &>/dev/null; then |
| #132 | die "Node.js not found. Install v20+ from https://nodejs.org" |
| #133 | fi |
| #134 | NODE_MAJOR=$(node --version | sed 's/v//' | cut -d. -f1) |
| #135 | if [ "${NODE_MAJOR}" -lt 20 ]; then |
| #136 | die "Node.js v20+ required (found v${NODE_MAJOR}). Update at https://nodejs.org" |
| #137 | fi |
| #138 | ok "Node.js $(node --version)" |
| #139 | |
| #140 | # ── Check pnpm ──────────────────────────────────────────────────────────── |
| #141 | if ! command -v pnpm &>/dev/null; then |
| #142 | step "Installing pnpm" |
| #143 | npm install -g pnpm 2>&1 | tail -1 |
| #144 | fi |
| #145 | PNPM_VER="$(cd "${REPO_ROOT}" && pnpm --version 2>/dev/null)" |
| #146 | ok "pnpm ${PNPM_VER}" |
| #147 | |
| #148 | # ── Install dependencies ───────────────────────────────────────────────── |
| #149 | step "Installing dependencies" |
| #150 | cd "${REPO_ROOT}" |
| #151 | pnpm install --frozen-lockfile 2>&1 | tail -2 |
| #152 | ok "Dependencies installed" |
| #153 | |
| #154 | # ── Build TypeScript ────────────────────────────────────────────────────── |
| #155 | step "Compiling TypeScript (dist/)" |
| #156 | pnpm build 2>&1 | tail -3 |
| #157 | ok "TypeScript compiled" |
| #158 | |
| #159 | mkdir -p "${LOCAL_BIN_DIR}" |
| #160 | ln -sf "${REPO_ROOT}/dist/index.js" "${LOCAL_BIN_TARGET}" |
| #161 | ok "CLI shim linked at ${LOCAL_BIN_TARGET}" |
| #162 | |
| #163 | bootstrap_perps |
| #164 | |
| #165 | # ── Verify constitution ────────────────────────────────────────────────── |
| #166 | step "Verifying constitution integrity" |
| #167 | if [ ! -f "${REPO_ROOT}/three-laws.md" ]; then |
| #168 | die "three-laws.md not found — constitution missing" |
| #169 | fi |
| #170 | CONSTITUTION_HASH=$(sha256sum "${REPO_ROOT}/three-laws.md" 2>/dev/null || shasum -a 256 "${REPO_ROOT}/three-laws.md" | cut -d' ' -f1) |
| #171 | ok "Constitution hash: ${CONSTITUTION_HASH:0:16}…" |
| #172 | |
| #173 | # ── Full mode ───────────────────────────────────────────────────────────── |
| #174 | if $FULL_MODE; then |
| #175 | step "Full mode: spawn identity + initialize runtime" |
| #176 | echo "" |
| #177 | |
| #178 | if [ -z "${CREATOR_PUBKEY:-}" ]; then |
| #179 | warn "CREATOR_PUBKEY not set — spawn will require --creator flag" |
| #180 | fi |
| #181 | |
| #182 | # Build workspace sub-packages if they exist |
| #183 | info "Building workspace packages…" |
| #184 | for pkg in packages/*/; do |
| #185 | if [ -f "${REPO_ROOT}/${pkg}package.json" ]; then |
| #186 | info "Building ${pkg}…" |
| #187 | pnpm --filter "${pkg}" build 2>&1 | tail -1 && ok "${pkg} built" || warn "${pkg} build failed (non-fatal)" |
| #188 | fi |
| #189 | done |
| #190 | |
| #191 | echo "" |
| #192 | printf " ${BOLD}Run now:${RESET}\n" |
| #193 | printf " ${CYAN}clawd-automaton --run${RESET} — start the OODA agent loop\n" |
| #194 | printf " ${CYAN}clawd-automaton --status${RESET} — check depth + balances\n" |
| #195 | printf " ${CYAN}clawd-automaton --goblin${RESET} — devnet paper trading (Goblin mode)\n" |
| #196 | printf " ${CYAN}pnpm ooda${RESET} — run OODA loop directly\n" |
| #197 | printf " ${CYAN}pnpm dashboard:dev${RESET} — launch dashboard UI\n" |
| #198 | printf " ${CYAN}../agents/agents-catalog.json${RESET} — agent registry catalog\n" |
| #199 | printf " ${CYAN}../agents/templates/index.json${RESET} — template registry\n" |
| #200 | printf " ${CYAN}../agents/skills/index.json${RESET} — formal skill hub\n" |
| #201 | echo "" |
| #202 | fi |
| #203 | |
| #204 | # ── Done ───────────────────────────────────────────────────────────────── |
| #205 | echo "" |
| #206 | printf "${BOLD}${GREEN}🦞 Crustacean Automation ready!${RESET}\n" |
| #207 | printf " ${CYAN}clawd-automaton --run${RESET} — start the agent loop\n" |
| #208 | printf " ${CYAN}clawd-automaton --status${RESET} — check depth + balances\n" |
| #209 | printf " ${CYAN}clawd-automaton --goblin${RESET} — devnet paper Goblin mode\n" |
| #210 | printf " ${CYAN}clawd-automaton --provision${RESET} — provision API key via SIWE\n" |
| #211 | printf " ${CYAN}clawd-perps perps vulcan context${RESET} — Phoenix/Vulcan perps health\n" |
| #212 | printf " ${CYAN}clawd-perps perps tui --relay${RESET} — Lobster King realtime perps TUI\n" |
| #213 | printf " ${CYAN}clawd-perps perps onchain-mm status${RESET} — Phoenix on-chain MM bridge\n" |
| #214 | printf " ${CYAN}clawd-perps perps grid SOL --center-on-mark --width-pct 2.5 --levels-per-side 5 --tokens-per-level 0.5${RESET}\n" |
| #215 | printf " ${CYAN}pnpm ooda${RESET} — run OODA loop\n" |
| #216 | printf " ${CYAN}pnpm dashboard:dev${RESET} — launch dashboard\n" |
| #217 | printf " ${CYAN}../agents/skills/README.md${RESET} — full local skill library\n" |
| #218 | echo "" |
| #219 | printf " ${YELLOW}The shell molts. The laws do not. 🦞${RESET}\n" |
| #220 | printf " ${YELLOW}Add ${LOCAL_BIN_DIR} to PATH if needed.${RESET}\n" |
| #221 | echo "" |
| #222 |