An instance is where Releases run. It is private: one Cloudflare account, one hostname, a run token for callers and a deployer token for deploys. @scwrap/platform-cloudflare is the package that implements it.
The parts
| Part | What it is | Job |
|---|---|---|
| Release Worker | scwrap-instance-<stage> | Serves the catalog, runs Worker releases, checks every item, stores results and serves the MCP server. It serves no pages; any other GET answers 404 or a redirect (Other paths). It has no route of its own. |
| Controller Worker | scwrap-instance-<stage>-controller, owner of the hostname | Its Durable Object accepts Releases, serializes deploys and activates new release Worker versions with the instance's Cloudflare token. Every other request goes on to the release Worker. |
| Run owner | A Runner Durable Object named run-<resultId>, one per Run | Executes one Run after its caller has gone, stores its items and final record, ends the Run at its maximum duration, marks the Run failed if it dies, and stops the Browser Use sessions the Run left open. |
| Idempotency keeper | A Runner Durable Object named idempotency-<hash>, one per run token name, Scraper and Idempotency-Key | Holds the first Run's resultId and input digest for 24 hours, so a repeat request returns that Run (Idempotency-Key). |
| Results bucket | A private R2 bucket | Holds every Run's record, items and listing index. A lifecycle rule deletes each object when the instance's result retention runs out, 30 days after it was written by default. |
| Artifacts bucket | A private R2 bucket | Holds Release artifacts and platform manifests. Nothing expires. |
There is nothing else. An instance has no database, no queue and no scheduling.
What happens in a Run
- A caller sends
POST /scrapers/<id>/runwith the run token and a JSON input. - The Worker looks up the installed Release for that ID, hands the Run to a new Run owner, which writes a result record with status
running, and answers 202 with that record. - The Run owner runs the Release's Stream from its alarm, in the Release's own Dynamic Worker sandbox (Each Release in its own sandbox).
- The sandbox checks each item against the Definition's output schema, and the Run owner writes it to R2.
- When the Stream ends, the Run owner writes the final record,
completedorfailed.
Every Run starts as soon as it is accepted, in its own Run owner: there are no slots and no queue to wait in. A Run lasts at most its Release's maximum duration, 10 minutes unless the Release sets maxRunDuration, and never more than 14 minutes. At the limit the Release's sandbox stops the Stream, which closes its scope and with it the Run's browser session, and the Run owner keeps the items checked so far and ends the Run failed with RunTimeout (Run duration).
The caller reads the record by result ID until it is no longer running, then reads the items. Leaving does not stop the Run, and neither does a deploy: a Run active during one finishes on the version it started on (Runs during a deploy). A Run whose owner dies ends failed with the error Run abandoned: its owner stopped before the Run ended.
What an instance does not have
Knowing the limits saves time.
| It has no | So |
|---|---|
| Triggers or schedules | A Run starts only when a caller starts it. Scheduling belongs to the caller, by design (Scheduling Runs). |
| Completion webhooks | A finished Run is not pushed to anyone, by design (Non-goals). The caller reads the record by result ID. |
| Rate limiter | Every authenticated request is served until a Cloudflare limit stops it (Rate limits). |
| Capabilities of its own | A Release provides every Capability itself. |
| User accounts | Access is by bearer token: the default run and deployer tokens reach everything, and named tokens give each caller or deployer its own, optionally limited to some Scrapers. Every result record names the run token that started it in tokenName. |
Known gaps lists everything an instance does not do yet.
Production
| Stack | ScwrapInstance/production |
| Worker | scwrap-instance-production |
| URL | https://scwrap.j4k4.dev |
| MCP | https://scwrap.j4k4.dev/mcp |
| Deployed by | CI, on every push to main, after the tests pass |
| Releases | The example Scrapers from instance-scrapers.ts, plus the Releases other repositories deploy to it |
In this section
| Page | Read it for |
|---|---|
| HTTP API | Every route, its request and its answers. |
| MCP server | The tools an agent gets. |
| Tracing | Where a Run's spans go and how to find its trace. |
| Deployment service | How the instance installs Releases and recovers from interrupted deploys. |
| Credentials | The front desk that holds vendor credentials and hands Releases capabilities under the owner's grants. |
| Infrastructure | The Stack, its bindings and credentials, and how to set up a new instance. |
| Known gaps | What an instance does not do yet. |
Source
- runtime.ts: catalog, run and result routes
- runtime-entry.ts: the Worker's entry and the
RunnerDurable Object class of Run owners and idempotency keepers - alchemy.instance.ts: the
ScwrapInstanceStack