fc86edd94c
- .claude/CLAUDE.md - .claude/rules/create_agent.md - agents/_specials/father-bot/prompts/system.md - agents/_template/config.yaml - agents/_template_robot/config.yaml - cmd/agentctl/autoavatar.go - cmd/launcher/sqlite.go - dev-scripts/_common.sh - dev-scripts/agent/create-full.sh - dev-scripts/agent/delete-full.sh - ... Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
120 lines
4.0 KiB
Bash
Executable File
120 lines
4.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# setup-agent-wsl-lucas.sh — preflight for the agent-wsl-lucas e2e suite.
|
|
#
|
|
# Verifies all upstream deps before letting Playwright run. Exits non-zero
|
|
# with actionable guidance when something is missing.
|
|
#
|
|
# Used by: e2e/tests/agent-wsl-lucas.spec.ts (issue 0144 / flow 0009).
|
|
|
|
set -uo pipefail
|
|
|
|
OK="\033[0;32m✓\033[0m"
|
|
BAD="\033[0;31m✗\033[0m"
|
|
WARN="\033[0;33m!\033[0m"
|
|
fails=0
|
|
|
|
say_ok() { printf " %b %s\n" "$OK" "$*"; }
|
|
say_bad() { printf " %b %s\n" "$BAD" "$*"; fails=$((fails+1)); }
|
|
say_warn() { printf " %b %s\n" "$WARN" "$*"; }
|
|
|
|
echo "[setup-agent-wsl-lucas] preflight check"
|
|
echo
|
|
|
|
# 1) device_agent listening on 10.42.0.10:7474
|
|
echo "1) device_agent /health on 10.42.0.10:7474"
|
|
if curl -fsS --max-time 5 "http://10.42.0.10:7474/health" >/dev/null 2>&1; then
|
|
say_ok "device_agent reachable on http://10.42.0.10:7474"
|
|
else
|
|
say_bad "device_agent not reachable on 10.42.0.10:7474."
|
|
cat <<'EOF'
|
|
Start it:
|
|
cd projects/element_agents/apps/device_agent
|
|
go build -o device_agent ./...
|
|
./device_agent --listen 10.42.0.10:7474 \
|
|
--manifest ~/.config/device_agent/manifest.yaml \
|
|
--audit /tmp/device_audit.db &
|
|
|
|
EOF
|
|
fi
|
|
|
|
# 2) audit DB exists and is readable
|
|
echo "2) /tmp/device_audit.db exists and is queryable"
|
|
DB="${DEVICE_AUDIT_DB:-/tmp/device_audit.db}"
|
|
if [ -f "$DB" ] && sqlite3 "$DB" "SELECT COUNT(*) FROM audit_log;" >/dev/null 2>&1; then
|
|
n=$(sqlite3 "$DB" "SELECT COUNT(*) FROM audit_log;")
|
|
say_ok "$DB OK ($n rows)"
|
|
else
|
|
say_bad "$DB missing or unreadable."
|
|
cat <<'EOF'
|
|
Restart device_agent (see step 1) — it auto-creates the DB.
|
|
If it persists, check write perms on /tmp.
|
|
|
|
EOF
|
|
fi
|
|
|
|
# 3) ssh to VPS works (key-based)
|
|
echo "3) ssh ${AGENT_LOG_SSH_TARGET:-organic-machine.com} (key-based, no password)"
|
|
SSH_TARGET="${AGENT_LOG_SSH_TARGET:-organic-machine.com}"
|
|
if ssh -o BatchMode=yes -o ConnectTimeout=5 "$SSH_TARGET" true 2>/dev/null; then
|
|
say_ok "ssh $SSH_TARGET works"
|
|
else
|
|
say_bad "ssh $SSH_TARGET failed (requires key-based auth)."
|
|
cat <<'EOF'
|
|
Add your public key to the VPS's ~/.ssh/authorized_keys, or set
|
|
AGENT_LOG_SSH_TARGET to another alias in your ~/.ssh/config.
|
|
|
|
EOF
|
|
fi
|
|
|
|
# 4) systemd service active on VPS
|
|
echo "4) agents_and_robots.service active on $SSH_TARGET"
|
|
if ssh -o BatchMode=yes -o ConnectTimeout=5 "$SSH_TARGET" \
|
|
'systemctl is-active agents_and_robots.service' 2>/dev/null | grep -q '^active$'; then
|
|
say_ok "agents_and_robots.service is active"
|
|
else
|
|
say_warn "agents_and_robots.service not active or unreachable (V1 test will skip)."
|
|
fi
|
|
|
|
# 5) per-agent log present
|
|
echo "5) /home/ubuntu/CodeProyects/agents_and_robots/logs/agent-wsl-lucas/<today>.jsonl"
|
|
TODAY=$(date -u +%F)
|
|
if ssh -o BatchMode=yes -o ConnectTimeout=5 "$SSH_TARGET" \
|
|
"test -f /home/ubuntu/CodeProyects/agents_and_robots/logs/agent-wsl-lucas/${TODAY}.jsonl" 2>/dev/null; then
|
|
say_ok "today's agent log exists"
|
|
else
|
|
say_warn "today's log not found; M2/M3 may need wider window."
|
|
fi
|
|
|
|
# 6) e2e/.env present
|
|
echo "6) e2e/.env"
|
|
ENV_FILE="$(dirname "$0")/../.env"
|
|
if [ -f "$ENV_FILE" ]; then
|
|
say_ok "$ENV_FILE present"
|
|
else
|
|
say_warn "$ENV_FILE missing — copy from .env.example and fill in."
|
|
fi
|
|
|
|
# 7) node + playwright present
|
|
echo "7) node + npx playwright"
|
|
if command -v node >/dev/null && node --version >/dev/null 2>&1; then
|
|
say_ok "node $(node --version)"
|
|
else
|
|
say_bad "node not installed."
|
|
fi
|
|
|
|
# 8) sqlite3 CLI (fallback for the device-audit fixture)
|
|
echo "8) sqlite3 CLI (used as fallback if better-sqlite3 missing)"
|
|
if command -v sqlite3 >/dev/null; then
|
|
say_ok "sqlite3 $(sqlite3 --version | awk '{print $1}')"
|
|
else
|
|
say_warn "sqlite3 CLI missing; install better-sqlite3 via npm or apt install sqlite3."
|
|
fi
|
|
|
|
echo
|
|
if [ "$fails" -gt 0 ]; then
|
|
echo "[setup-agent-wsl-lucas] $fails blocking issue(s). Fix the above first."
|
|
exit 1
|
|
fi
|
|
echo "[setup-agent-wsl-lucas] all green — you can run:"
|
|
echo " cd e2e && npx playwright test agent-wsl-lucas.spec.ts"
|