#!/bin/bash
# Quick health check for prospector
cd /Users/claw/.openclaw/workspace/agents/sales-prospector

# Check if running
if ! pgrep -f prospector-v8.py > /dev/null; then
    echo "ALERT: Prospector not running!"
    echo "Restarting..."
    python3 prospector-v8.py > /dev/null 2>&1 &
    exit 1
fi

# Check recent activity (last 10 min)
LEADS=$(cat state/prospector-v8-state.json 2>/dev/null | jq -r '.leads // 0')
CYLETIME=$(stat -c %Y logs/prospector-v8-$(date +%Y%m%d).log 2>/dev/null || echo 0)
NOW=$(date +%s)
DIFF=$((NOW - CYLETIME))

if [ $DIFF -gt 600 ]; then
    echo "ALERT: No activity in ${DIFF}s"
    echo "Leads: $LEADS"
fi

echo "OK: $LEADS leads, last activity ${DIFF}s ago"
