#!/usr/bin/env sh # VCN #44 The Loop - get a machine ready to build a coding-agent loop by hand. # Doctor first, then wire. Idempotent and safe: it never deletes anything, never # touches global config, and never installs a system package for you (it prints # the one line to run instead). # # Run: curl -fsSL https://vcn-44-the-loop.vercel.app/wire.sh | sh # Doctor only, changes nothing: # curl -fsSL https://vcn-44-the-loop.vercel.app/wire.sh | sh -s -- --check # # Options (append after -s --): # --check doctor only, change nothing # --dir

where to set up (default ./vcn44) # --no-lab skip downloading the lab files # -y assume yes, no prompts # # There are NO credentials in this file. It never prints your key. ASCII only. # Uninstall: delete the directory it created. Nothing else was touched. set -u BASE="https://vcn-44-the-loop.vercel.app" DIR="vcn44" CHECK=0 NOLAB=0 YES=0 while [ $# -gt 0 ]; do case "$1" in --check) CHECK=1 ;; --no-lab) NOLAB=1 ;; -y) YES=1 ;; --dir) shift; DIR="${1:-vcn44}" ;; -h|--help) sed -n '2,18p' "$0" 2>/dev/null || echo "see $BASE/wire.sh"; exit 0 ;; *) echo "unknown option: $1 (ignored)" ;; esac shift done ok() { printf ' OK %s\n' "$1"; } warn() { printf ' WARN %s\n' "$1"; } bad() { printf ' FAIL %s\n' "$1"; } say() { printf '%s\n' "$1"; } say "" say "VCN #44 The Loop - setup doctor" say "-------------------------------" # ---------------------------------------------------------------- 1. python PY="" for c in python3 python; do if command -v "$c" >/dev/null 2>&1; then v=$("$c" -c 'import sys;print("%d.%d"%sys.version_info[:2])' 2>/dev/null) || continue case "$v" in 3.1[0-9]*|3.[2-9][0-9]*) PY="$c"; ok "python $v ($c)"; break ;; *) warn "$c is $v, need 3.10 or newer" ;; esac fi done if [ -z "$PY" ]; then bad "no python 3.10+ on PATH" say "" say " Install one, then re-run:" say " macOS: brew install python@3.12" say " Debian: sudo apt install python3 python3-venv python3-pip" say " Fedora: sudo dnf install python3 python3-pip" say " Or the installer from https://python.org" exit 1 fi # ---------------------------------------------------------------- 2. key KEYSET=0 if [ -n "${ZAI_API_KEY:-}" ]; then KEYSET=1; ok "ZAI_API_KEY is set in this shell"; else warn "ZAI_API_KEY is not set (you get the key at the event, see $BASE/setup.txt section 4)" fi # ---------------------------------------------------------------- 3. network if command -v curl >/dev/null 2>&1; then if curl -fsS -m 10 -o /dev/null "$BASE/setup.txt" 2>/dev/null; then ok "can reach $BASE" else warn "cannot reach $BASE (offline? the lab still runs without network)"; fi else bad "curl not found; install curl or follow $BASE/setup.txt by hand"; exit 1 fi if [ "$CHECK" -eq 1 ]; then say "" say "Doctor only. Nothing was changed." say "To actually set up: curl -fsSL $BASE/wire.sh | sh" exit 0 fi # ---------------------------------------------------------------- 4. confirm if [ "$YES" -ne 1 ]; then say "" say "About to create ./$DIR, make a virtualenv inside it, and pip install" say "anthropic + openai + pyyaml into that virtualenv only." say "Nothing global is modified. Ctrl-C to stop." printf "Continue? [y/N] " read ans /dev/null || ans="y" case "$ans" in y|Y|yes|YES) ;; *) say "Stopped. Nothing changed."; exit 0 ;; esac fi # ---------------------------------------------------------------- 5. venv mkdir -p "$DIR" || { bad "cannot create $DIR"; exit 1; } cd "$DIR" || exit 1 if [ -d .venv ]; then ok "reusing existing .venv" else "$PY" -m venv .venv && ok "created .venv" || { bad "venv failed; try: $PY -m pip install --user virtualenv"; exit 1; } fi VPY=".venv/bin/python" [ -x "$VPY" ] || VPY=".venv/Scripts/python.exe" [ -x "$VPY" ] || { bad "cannot find the venv python"; exit 1; } "$VPY" -m pip install --quiet --upgrade pip >/dev/null 2>&1 if "$VPY" -m pip install --quiet anthropic openai pyyaml; then ok "installed anthropic, openai, pyyaml" else bad "pip install failed; re-run without --quiet to see why"; exit 1; fi # ---------------------------------------------------------------- 6. lab if [ "$NOLAB" -eq 0 ]; then mkdir -p lab/fixtures lab/loops for f in README.md requirements.txt agent.py nebius.py safety.py verify.py verify_loop.py \ stage0_skeleton.py stage1_tools.py stage2_toolcall.py stage3_stop.py stage4_context.py; do curl -fsS -m 20 -o "lab/$f" "$BASE/lab/$f" 2>/dev/null || true done for f in mathlib.py test_math.py; do curl -fsS -m 20 -o "lab/fixtures/$f" "$BASE/lab/fixtures/$f" 2>/dev/null || true done curl -fsS -m 20 -o "lab/loops/README.md" "$BASE/lab/loops/README.md" 2>/dev/null || true n=$(find lab -type f 2>/dev/null | wc -l | tr -d ' ') ok "downloaded $n lab files into ./$DIR/lab" fi # ---------------------------------------------------------------- 7. smoke say "" if [ "$KEYSET" -eq 1 ]; then "$VPY" - <<'PYEOF' import os, sys try: from anthropic import Anthropic except ImportError: sys.exit("FAIL: anthropic did not install") key = os.environ.get("ZAI_API_KEY") try: c = Anthropic(base_url="https://api.z.ai/api/anthropic", api_key=key) r = c.messages.create( model="glm-4.6", max_tokens=32, messages=[{"role": "user", "content": "Reply with exactly: LOOP OK"}], ) print(" model replied:", "".join(b.text for b in r.content if b.type == "text").strip()) print("") print("VCN44 SETUP READY") except Exception as e: print(" FAIL: the call did not go through:", str(e)[:180]) print(" If this says malformed token, see setup.txt section 4: the gateway reads") print(" Authorization Bearer, so the SDK arg is auth_token=, not api_key=.") sys.exit(1) PYEOF else say " Skipping the smoke test: ZAI_API_KEY is not set." say " Set it, then run: cd $DIR && $VPY lab/verify_loop.py" say " (verify_loop.py needs no key and no network, so you can test the loop now.)" fi say "" say "Done. Everything lives in ./$DIR - delete that folder to undo all of this." say "Deck: $BASE Lab: ./$DIR/lab Guide: $BASE/setup.txt"