Worker Setup
The Cloudflare Worker is the global evaluator. It runs on a cron schedule (every 1 minute) to detect offline agents, create incidents, and dispatch notifications.
Install Wrangler CLI
npm install -g wrangler
wrangler loginNavigate to the worker directory
cd apps/workerSet Worker secrets
npx wrangler secret put DATABASE_URL
# Paste your Neon connection string when prompted
npx wrangler secret put WORKER_SECRET
# Set a strong random string for manual trigger authDeploy
npx wrangler deployVerify the Worker
After deployment, you can trigger the evaluator manually for testing:
curl -X POST https://your-worker.YOUR_SUBDOMAIN.workers.dev/trigger \
-H "Authorization: Bearer YOUR_WORKER_SECRET"The cron schedule is configured in apps/worker/wrangler.toml. Default: every 1 minute (* * * * *).
What the Worker Does
Each cron run executes these steps in order:
- Detect overdue agents β
SELECT agents WHERE offline_deadline_at < NOW() AND status != 'offline' - Mark offline + create incident β update status, insert incident if none open
- Dispatch offline notifications β Telegram, Discord, or Webhook
- Detect recovered agents β
SELECT agents WHERE offline_deadline_at >= NOW() AND status = 'offline' - Mark online + resolve incident β update status, set resolved_at
- Dispatch recovery notifications
- Run cloud monitor checks β parallel HTTP/TLS/Keyword checks
- Retention cleanup β delete metric_buckets > 7 days, cloud results > 30 days
Last updated on