Skip to content

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 pending fix 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):

EndpointUsed byPurpose
POST /api/scripts/registerbrowserRegister a script on launch()
POST /api/errorsbrowserReport a failure (dedup + queue)
PATCH /api/errors/:scriptId/:fixRequestIdfixerUpdate a job’s status and result
POST /api/scripts/:id/unblockoperatorReset a script’s failure tracking

Read endpoints (used by the fixer, the dashboard, and you):

EndpointPurpose
GET /api/errors?status=pendingThe fixer’s work queue
GET /api/errors/:scriptIdAll incidents for one script
GET /api/errors/:scriptId/:fixRequestIdOne incident in full
GET /api/scripts/:id/statusA script’s registration and failure state
GET /api/statsAggregate counts and costs for the dashboard overview
GET /api/fixesFix history for the dashboard table
GET /api/fixes/:idOne fix with cost, outcome, and artifact links

A quick health check:

Terminal window
curl http://localhost:4400/api/stats

Configuration

VariableDefaultPurpose
PORT / SERVICE_PORT4400Listen port
AUTOWRIGHT_DB_PATH/data/autowright.dbSQLite location
AUTOWRIGHT_DEDUPE_TTL_MS86400000Dedupe window

Only the service needs to be reachable from your scripts — see Self-Hosting for the network layout.