Coordination Service
@autowright/service is the hub the other two layers talk through. It’s a
small Express server (port 4400 by default) with SQLite state — no message
broker, no external database. Scripts register with it, failures flow into it,
and the fixer polls it for work.
One rule shapes the whole design: the service never touches artifact bytes. Evidence bundles go from the browser package straight to S3-compatible storage; only URLs and metadata pass through the service. That keeps it fast, cheap, and safe to run anywhere.
State
State lives in a single SQLite database (better-sqlite3) at
AUTOWRIGHT_DB_PATH (/data/autowright.db in Docker, persisted to a volume).
Fix history survives restarts; there is nothing else to back up.
Error intake and dedup
POST /api/errors receives an ErrorContext from a failing script. The
service checks the error hash — SHA-256 over script ID, classification, failed
step, and normalized message — against known incidents:
- New hash → stored and queued as a
pendingfix job. - Seen within the dedupe window (
AUTOWRIGHT_DEDUPE_TTL_MS, default 24 hours) → counted against the incident, but no new job. A scraper on a cron that hits the same broken selector all night produces one fix, not a hundred.
See Fix Lifecycle for the full path from intake to pull request.
API
Write endpoints (used by the browser package and fixer):
| Endpoint | Used by | Purpose |
|---|---|---|
POST /api/scripts/register | browser | Register a script on launch() |
POST /api/errors | browser | Report a failure (dedup + queue) |
PATCH /api/errors/:scriptId/:fixRequestId | fixer | Update a job’s status and result |
POST /api/scripts/:id/unblock | operator | Reset a script’s failure tracking |
Read endpoints (used by the fixer, the dashboard, and you):
| Endpoint | Purpose |
|---|---|
GET /api/errors?status=pending | The fixer’s work queue |
GET /api/errors/:scriptId | All incidents for one script |
GET /api/errors/:scriptId/:fixRequestId | One incident in full |
GET /api/scripts/:id/status | A script’s registration and failure state |
GET /api/stats | Aggregate counts and costs for the dashboard overview |
GET /api/fixes | Fix history for the dashboard table |
GET /api/fixes/:id | One fix with cost, outcome, and artifact links |
A quick health check:
curl http://localhost:4400/api/statsConfiguration
| Variable | Default | Purpose |
|---|---|---|
PORT / SERVICE_PORT | 4400 | Listen port |
AUTOWRIGHT_DB_PATH | /data/autowright.db | SQLite location |
AUTOWRIGHT_DEDUPE_TTL_MS | 86400000 | Dedupe window |
Only the service needs to be reachable from your scripts — see Self-Hosting for the network layout.