npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@substrat-run/adapter-cloudflare

v0.83.0

Published

Cloudflare Durable-Object scope host (D-14): DO-per-scope, real kernel semantics on Workers

Downloads

11,215

Readme

@substrat-run/adapter-cloudflare

The Durable-Object scope host for Substrat — the production backing for the same scope-host contract the pure-SQLite adapter implements.

One SQLite-backed Durable Object per scope, a durable control-plane DO for the directory, and a stateless coordinator that mints capability stubs. Both adapters pass the same conformance suite unchanged (decision 14), so a vertical developed and CI-tested on pure SQLite runs on Cloudflare with no code change.

Full documentation: https://substrat.net/reference/adapter-cloudflare

pnpm add @substrat-run/adapter-cloudflare

The pieces

  • ScopeDO — one scope = one SQLite-backed Durable Object. defineScopeDO([…modules]) bundles the kernel, engines, and the vertical's modules into the DO at build time (a DO cannot receive handler closures over RPC). Each operation runs inside ctx.storage.transaction(async …) — the DO analogue of BEGIN IMMEDIATE … COMMIT, which rolls back on a throw across awaits — with strict per-scope serialization, lazy migrations on wake, manifest guards, and the outbox→consumer dispatch loop.
  • ControlPlaneDO — the durable directory: tenants, scope lifecycle, roles, entitlements, identities, tenant-level tuples, and the append-only admin audit log.
  • CloudflareScopeHost — the coordinator. Stateless (rebuilt per request); it validates and gates against the control plane, then mints a ScopeStub that RPCs invoke into the scope's DO. Implements the same ScopeHost contract as the pure adapter.

Usage (a Worker)

import { defineScopeDO, ControlPlaneDO, CloudflareScopeHost } from '@substrat-run/adapter-cloudflare';
import { workorderModule } from '@substrat-run/engine-workorder';

export const ScopeDO = defineScopeDO([workorderModule /*, …engines, vertical */]);
export { ControlPlaneDO };

export default {
  async fetch(req, env) {
    const host = new CloudflareScopeHost({ scope: env.SCOPE, controlPlane: env.CONTROL_PLANE });
    // authenticate → getScope → invoke
    const stub = await host.getScope(principal, tenantId, scopeId);
    return Response.json(await stub.invoke('workorder/list', {}));
  },
};

wrangler.jsonc binds SCOPE + CONTROL_PLANE as SQLite-backed Durable Objects (new_sqlite_classes). Run it on real workerd with wrangler dev (no account needed); deploy with wrangler deploy (DO SQLite needs a Workers Paid plan).

A demo vertical — Callout — runs deployed on it today, behind Better Auth.

How the semantics map

| Contract guarantee | Implementation here | |---|---| | strict serialization per scope (K-6) | per-DO operation queue — the DO input gate over-delivers, so serialization is enforced explicitly | | scope storage isolation | one SQLite-backed DO per scope | | transactional operation + rollback (K-4) | ctx.storage.transaction(async …) — commits on success, rolls back on a throw across awaits | | structured-clone boundary | the coordinator→DO RPC boundary itself | | fail-closed addressing + lifecycle gates | validated in the ControlPlaneDO before the stub is minted | | permission checks | tuple checker — scope tuples local to the DO, tenant tuples + roles via the control plane |

Related packages

Status

Milestone 1: the shared contract suites run green in workerd against real Durable Objects (one runtime-late-registration test is skipped — a deployed DO bundle is code-time), the control plane is durable, and a vertical is deployed. Deferred, honestly:

  • the directory is a single control-plane DO; the tenant-root-DO + global-D1 split is a later scaling/blast-radius refinement;
  • per-jurisdiction DO ids (K-7) and the hostname → (tenant, scope, vertical) router / Workers-for-Platforms multi-vertical dispatch are not built yet;
  • Shape B (DO control plane fronting per-tenant D1) is not built.

Pre-release (0.x): surfaces change without notice until the first vertical ships.