StrimzStrimz
Self-hosting

Self-hosting the agent

The AutoPay Agent process.

The agent is a Nest cron app + BullMQ worker. It runs scheduled jobs (recovery emails, cashflow digests, anomaly detection, monthly reports). It also has a worker for the CCTP V2 routing queue, but cross-chain payments aren't live, so nothing feeds that queue today.

Build

cd apps/agent
pnpm build
pnpm start:prod

Configuration

NODE_ENV=production
PORT=4300
DATABASE_URL=postgresql://...
REDIS_URL=redis://...

ARC_ENVIRONMENT=mainnet

# Cron schedules
RECOVERY_TICK_CRON=0 0 * * * *
CASHFLOW_DIGEST_CRON=0 0 9 * * *
CASHFLOW_ANOMALY_CRON=0 0 * * * *
CASHFLOW_YIELD_CRON=0 30 9 * * *
COMMERCE_MONTHLY_CRON=0 0 9 1 * *
PRICING_MONTHLY_CRON=0 0 9 1 * *

# Anomaly thresholds (standard deviations)
ANOMALY_THRESHOLD_LOW=3.0
ANOMALY_THRESHOLD_MEDIUM=2.0
ANOMALY_THRESHOLD_HIGH=1.0

# CCTP V2 attestation API
CIRCLE_ATTESTATION_BASE_URL=https://iris-api-sandbox.circle.com
CIRCLE_API_KEY=

# Email
RESEND_API_KEY=...
RESEND_FROM_EMAIL=noreply@your-domain.com

What runs when

CapabilityCronNotes
recoveryhourlyIdempotent per (subId, attempt)
cashflow.digestdaily 9am UTCIdempotent per UTC day
cashflow.anomalyhourlyz-score over trailing 30d
cashflow.yielddaily 9:30am UTCRecommendation only. No signing.
commercefirst of each monthPer-month dedup
pricing_intelligencefirst of each monthPer-month dedup
routingqueue-drivenNot live. Nothing enqueues jobs.

The agent reads AgentMerchantConfig on every tick, so config changes in the dashboard take effect on the next firing.

Single-instance recommendation

Unlike the scheduler, the agent has no built-in multi-instance safety. Two agent instances will fire each cron twice. The dedup logic inside each capability stops the visible side effects from duplicating (the same email won't be sent twice inside the dedup window), but you're burning compute for nothing.

Observability

  • /healthz (process is up), /readyz (Postgres and Redis answer; 503 otherwise)
  • Activity log written to AgentActivityLog for every action
  • AuditLog entries for cashflow.anomaly_detected, merchant.fee_bps_changed_onchain, fees.accrued

Failure modes

  • Resend API outage. Emails fail. The agent retries on the next tick. No state is lost.
  • Postgres outage. Capabilities skip. The next tick retries.

Source

github.com/StrimzLab/strimz/tree/main/apps/agent

On this page