← back to Re Coverage Dashboard

fill.sh

22 lines

#!/usr/bin/env bash
# $0/local contact-coverage filler. Alternates CRCP + usre agent-site discovery in
# SMALL batches with long cooldowns so the free SERP doesn't stay bot-walled (it
# throttle-walls after ~9 rapid queries). Runs forever; fully resumable — each tool
# skips already-attempted rows, so a kill/restart just continues. No metered spend.
set -uo pipefail
export OLLAMA_MODEL=${OLLAMA_MODEL:-qwen3:14b}
CRCP="$HOME/Projects/commercialrealestate"
USRE="$HOME/Projects/nationalrealestate"
COOLDOWN=${COOLDOWN:-420}   # 7 min between batches — lets DDG/Brave cool down
BATCH=${BATCH:-8}           # small: stops just under the ~9-query throttle wall

echo "[filler] starting — batch=$BATCH cooldown=${COOLDOWN}s model=$OLLAMA_MODEL ($0/local)"
while true; do
  echo "[$(date '+%F %H:%M:%S')] CRCP batch"
  ( cd "$CRCP" && node scripts/discover-agent-sites.js --limit="$BATCH" ) 2>&1 | grep -E '✓|done|throttl' | tail -4 || true
  sleep "$COOLDOWN"
  echo "[$(date '+%F %H:%M:%S')] usre batch"
  ( cd "$USRE" && npx tsx src/enrich/broker_website_discovery.ts --limit="$BATCH" ) 2>&1 | grep -E '✓|done|throttl' | tail -4 || true
  sleep "$COOLDOWN"
done