@sanoma-ai/connector-cloudflare 0.6.4 → 0.11.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @sanoma-ai/connector-cloudflare
2
2
 
3
- [Cloudflare Containers](https://developers.cloudflare.com/containers/) as a host that stops when quiet, and its [Durable Object](https://developers.cloudflare.com/durable-objects/)'s [alarm](https://developers.cloudflare.com/durable-objects/api/alarms/) as the wakeup that starts it again, for [`@sanoma-ai/workflows`](https://www.npmjs.com/package/@sanoma-ai/workflows). Both are one Worker per company, `sanoma-<name>`, on the account's workers.dev subdomain. And a set of [DNS records](#dns-records) in one of the account's zones, such as the ones a sending domain asks for.
3
+ [Cloudflare Containers](https://developers.cloudflare.com/containers/) as a host that stops when quiet, and its [Durable Object](https://developers.cloudflare.com/durable-objects/)'s [alarm](https://developers.cloudflare.com/durable-objects/api/alarms/) as the wakeup that starts it again, for [`sanoma/workflows`](https://github.com/Sanoma-AI/sanoma/blob/main/packages/sanoma/workflows/README.md). Both are one Worker per company, `sanoma-<name>`, on the account's workers.dev subdomain. And a set of [DNS records](#dns-records) in one of the account's zones, such as the ones a sending domain asks for.
4
4
 
5
5
  ## Usage
6
6
 
@@ -8,7 +8,7 @@
8
8
  npm install @sanoma-ai/connector-cloudflare
9
9
  ```
10
10
 
11
- The four types are writable: `read` and `import` (effect `read`), and the change operations only the apply workflow may call, `plan` (effect `read`), `create`, `update` and `delete` (effect `write`). The host is a host ([Hosts](https://github.com/Sanoma-AI/sanoma/blob/main/packages/workflows/README.md#hosts)) and the alarm a wakeup, with one more operation, `register`, which the worker calls. `container` is the host's earlier form, deprecated, the same Worker with every field declared:
11
+ The four types are writable: `read` and `import` (effect `read`), and the change operations only the apply workflow may call, `plan` (effect `read`), `create`, `update` and `delete` (effect `write`). The host is a host ([Hosts](https://github.com/Sanoma-AI/sanoma/blob/main/packages/sanoma/workflows/README.md#hosts)) and the alarm a wakeup, with one more operation, `register`, which the worker calls. `container` is the host's earlier form, deprecated, the same Worker with every field declared:
12
12
 
13
13
  | Type | Operations | Import id |
14
14
  | ----------- | ----------------------------------------------------------------------------------------- | --------------- |
@@ -33,7 +33,7 @@ export const host = cloudflare.host({
33
33
  export const wakeup = cloudflare.alarm({ host });
34
34
  ```
35
35
 
36
- Apply gives the host the rest before it plans (`deriveHosts` in `@sanoma-ai/workflows`), and a data file never writes it:
36
+ Apply gives the host the rest before it plans (`deriveHosts` in `sanoma/workflows`), and a data file never writes it:
37
37
 
38
38
  | Derived | From |
39
39
  | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -76,19 +76,19 @@ An explicit `host.update` or `container.update` waits for startup readiness even
76
76
 
77
77
  `configurationRevision` participates in plans and reads. Change it when delivering new secret values without changing the source or image; for example, a managed lifecycle can derive it from its deployment and credential generation (`d1-g2`). The connector sends it as the reserved plain-text binding `SANOMA_CONFIG_REVISION`, and startup waits for that configuration revision as well as the source revision. It must contain no secret value. Secret values remain write-only: changing a stored value alone with the same configuration revision is not detected by a plan.
78
78
 
79
- The alarm's field is `host`, the container it wakes (its URL); its state is `{ host, at, rang, healthy }`, the wake it holds, when its alarm last rang the host's `/wake` for it, and whether the host's Worker took the company's token. Its optional `token`, a `secret("NAME")`, names the secret that holds the host's wakeup token, by default `SANOMA_WAKEUP_TOKEN`: a workflow that makes a host and its alarm for each of several companies, outside any data file, gives each its own (`token: secret("CLOUD_ACME_WAKEUP_TOKEN")`, the secret the host's `secrets` give as `SANOMA_WAKEUP_TOKEN`). `create` mints the token there when none is stored, and its state then carries the name as `token`, so a `read`, `update` or `delete` given that state sends the same token; one given only an id uses the default. A data file leaves `token` out: apply reads and deletes an alarm by its id alone, so `plan` refuses another name. `register` takes `{ at }`, an ISO 8601 time, which replaces the wake the Worker held: a wake is "resume if stopped", so one that rings late, twice or for a replaced registration starts a worker that finds nothing to do and stops again. It names no host: on the host, the worker reads the host's URL from `SANOMA_HOST_URL`, which the Worker gives the container; off it, from the credential `alarm.create` stored. A runtime whose data files declare no wakeup, but whose environment has both `SANOMA_HOST_URL` and `SANOMA_WAKEUP_TOKEN` (a host Sanoma Cloud made), registers at the same route itself, with no connector call (`envWakeup` in `@sanoma-ai/workflows`).
79
+ The alarm's field is `host`, the container it wakes (its URL); its state is `{ host, at, rang, healthy }`, the wake it holds, when its alarm last rang the host's `/wake` for it, and whether the host's Worker took the company's token. Its optional `token`, a `secret("NAME")`, names the secret that holds the host's wakeup token, by default `SANOMA_WAKEUP_TOKEN`: a workflow that makes a host and its alarm for each of several companies, outside any data file, gives each its own (`token: secret("CLOUD_ACME_WAKEUP_TOKEN")`, the secret the host's `secrets` give as `SANOMA_WAKEUP_TOKEN`). `create` mints the token there when none is stored, and its state then carries the name as `token`, so a `read`, `update` or `delete` given that state sends the same token; one given only an id uses the default. A data file leaves `token` out: apply reads and deletes an alarm by its id alone, so `plan` refuses another name. `register` takes `{ at }`, an ISO 8601 time, which replaces the wake the Worker held: a wake is "resume if stopped", so one that rings late, twice or for a replaced registration starts a worker that finds nothing to do and stops again. It names no host: on the host and off it, it sends to the host's URL that the default token's `alarm.create` stored as `SANOMA_HOST_URL` beside the token, never the process environment's. A `plan` that finds another URL stored there, or none, is an `update` that stores the alarm's again. A runtime whose data files declare no wakeup, but whose environment has both `SANOMA_HOST_URL` and `SANOMA_WAKEUP_TOKEN` (a host Sanoma Cloud made), registers at the same route itself, with no connector call (`envWakeup` in `sanoma/workflows`).
80
80
 
81
81
  The logo is Cloudflare's cloud from [Simple Icons](https://simpleicons.org/?q=cloudflare) (CC0), there only to identify the service an operation calls.
82
82
 
83
83
  ## The Worker
84
84
 
85
- The Worker script is the company's app. The package ships what it uploads, `worker/`: `index.js`, the entry, and `instance.js`, its logic with no imports (typed by `instance.d.ts`), which the fake runs in Node so both kits check the code Cloudflare runs. Beside them goes the app bundle under `app/` ([The deploy](#the-deploy)), or, until a create's first bundle, `no-app.js` in its place, which answers 503 "being set up". The entry's fetch:
85
+ The Worker script is the company's app. The package ships what it uploads, `worker/`: `index.js`, the entry, and `instance.js`, its logic with no imports (typed by `instance.d.ts`), which the fake runs in Node so both kits check the code Cloudflare runs. Beside them goes the app bundle under `app/` ([The deploy](#the-deploy)), or, on a Worker that never served an app (a create's uploads before its first bundle), `no-app.js` in its place, which answers 503 "being set up": nobody was served there yet. The entry's fetch:
86
86
 
87
87
  - sends `/__sanoma/health`, `/__sanoma/wake` and `/__sanoma/app-bundle` to the Worker's one Durable Object, `SanomaInstance` (`DurableObject` from `cloudflare:workers`);
88
88
  - answers `GET /wake`, the Host contract's wake, by having the object start the container now (204);
89
89
  - hands every other request to the app bundle's `fetch(request, env, ctx, host)`, imported on the first request, with `x-sanoma-client-ip` set from `cf-connecting-ip` over any copy the client sent, and `host.startNow()` the object's, over RPC (the app's call when it queues a run). A page, an API call, a webhook and a sign-in are all the app's, on the Worker, so a visitor never waits for a cold container (forty seconds to minutes), and the app reaches the company's database through [Hyperdrive](#the-database).
90
90
 
91
- The object runs the company's worker in its container and never sees a visitor's request. It:
91
+ The object runs the company's worker in its container and never sees a visitor's request. It marks each of its answers with `x-sanoma-deployment`, the id of the Worker version that answered (its `CF_VERSION_METADATA` binding's, the `deployment_id` an upload answers with), so a deploy tells the version it uploaded from an earlier one still answering, and the object's answers from anyone else's. It:
92
92
 
93
93
  - starts the container at the Worker's source revision, configuration revision and uploaded image (`ctx.container.images.runtime`: the copy, pinned by digest), as a `standard-1` instance (½ vCPU, 4 GiB: the policy refuses `basic`), with the Worker's text bindings (plain and secret) as its environment, and waits for its `/healthz` (up to ten minutes, the clone and install included). Container labels hold the two non-secret revisions, an image hash and a hash of `SANOMA_DOMAINS`; secret values never enter them. A container running with other labels is drained: sent SIGTERM, so its worker stops dequeuing and exits, given thirty seconds, then destroyed if it still runs, and started again at the Worker's labels;
94
94
  - answers `GET /__sanoma/health` with the source revision, configuration revision when set, and whether the container runs and answered, without starting it. With `?start=1` and `Authorization: Bearer <SANOMA_WAKEUP_TOKEN>`, it starts the container at the Worker's revisions, answering 202 until it answers, then 200;
@@ -105,16 +105,111 @@ The application is of the `durable_object` scheduling policy (public beta, the o
105
105
 
106
106
  A create, in Wrangler's order, copies and pins the image and waits until Cloudflare prepared it ([The image](#the-image)), makes or updates the [database's config](#the-database), and, the first time, uploads the Worker without an app (`no-app.js`) with the object's migration (`new_sqlite_classes`) and its class as a container's with that image (`containers: [{ name, class_name, images: { runtime } }]`), turns its workers.dev URL on, makes the application for the object's namespace (`{ name, scheduling_policy: "durable_object", durable_objects: { namespace_id } }`), and uploads that Worker once more: the object learns which application backs its namespace only from a deployment made after the application exists (without it every start answers "There is no container application assigned to this Durable Object namespace", found on the first real deploy, 2026-10-29). Then every create and update deploys in three steps:
107
107
 
108
- 1. **The bundle.** `GET /__sanoma/app-bundle?revision=R` on the workers.dev URL with the instance token, asked every poll: the object starts the container at the Worker's current revision if it is stopped (202, unmarked), and the worker there checks out `R` and builds the app bundle for `workerd` (`@sanoma-ai/app`'s `AppBundle`: its modules, its assets, its compatibility date and flags), answering 202 until it is built, then 200 with it, each answer marked `x-sanoma-app-bundle`. The bundle has its own budget, `startTimeoutMs` (ten minutes): still none after it fails the apply retryably, "still building the app bundle at R after 600 s", saying what the last ask saw. A marked answer other than 200 or 202 (a failed build, a revision the route refuses) is a refusal. A deployment that cannot build it, a 401 (the deployed Worker or its container holds another token), an `exit` (its worker ends at startup) or an unmarked 404 (a runtime without the route), is recovered once: the Worker at R without its app (`no-app.js`) is uploaded, so the object starts the container at R, and the bundle is asked of it, the app's pages saying it is being set up until step 2; the same answer again is a refusal. Anything else (no answer, an error of Cloudflare's, a body cut off, a workers.dev URL not routed yet) is asked again; one ask may take the whole budget, as a bundle is large. Its assets (the client build and the prerendered pages) then go in through an [assets upload session](https://developers.cloudflare.com/workers/static-assets/direct-upload/) (`POST …/scripts/{name}/assets-upload-session { manifest }`, then each bucket it asks for, one after another, to `POST …/workers/assets/upload?base64=true` with the session's jwt).
109
- 2. **One upload.** The domains no longer declared are detached, then the Worker is uploaded once with everything: `index.js`, `instance.js` and the bundle's modules under `app/`, its compatibility date and flags, the bindings (the declared ones, the namespace, `DATABASE` as Hyperdrive, `ASSETS`) and `assets: { jwt, config }` (`run_worker_first: ["/*", "!/assets/*"]`, the client build straight from the assets; `html_handling` and `not_found_handling` `none`). From here visitors get the new app; the container is still the old revision's. Then the missing domains are attached.
110
- 3. **The restart.** `GET /__sanoma/health?start=1` with the token, asked every poll until the object answers 200 at `R` and the configuration revision: the object drains the old container (SIGTERM, thirty seconds, then destroyed) and starts one at `R`. Its own budget, the same `startTimeoutMs`: still not after it fails the apply retryably, "still starting at R after 600 s". The step is idempotent: the next apply plans none, and an explicit update whose plan is none runs it alone, uploading nothing.
108
+ 1. **The database and the bundle.** The Worker at R is uploaded first (R's bindings and image, this package's `index.js` and `instance.js`), serving visitors what they are served now: the app deployed, its modules read back (`GET …/scripts/{name}/content/v2`), its compatibility date and flags and its assets kept (`keep_assets`), untagged; a Worker that never served an app gets `no-app.js`. Once that version is [live](#live-before-asked), `GET /__sanoma/app-bundle?revision=R` on the workers.dev URL with the instance token, asked every poll: its object drains a container at another revision or image (SIGTERM, thirty seconds, then destroyed) and starts one at `R` (202, unmarked), whose worker prepares the database at its start (R's migrations) before its port answers, then checks out `R` and builds the app bundle for `workerd` (`sanoma/app`'s `AppBundle`: its modules, its assets, its compatibility date and flags), answering 202 until it is built, then 200 with it, each answer marked `x-sanoma-app-bundle`. The database moves before the app: the app on the Worker never migrates and refuses a database without its migrations, while a database a newer release migrated serves the app deployed. So the container deployed never builds it, though it may run the declared image: R's app would go live over R-1's database, and answer every request that opens it 500 until the restart (found live on 2026-11-07, a release adding a migration). An answer without the uploaded version's id is an earlier version's, asked again whatever its status, and an `exit` (R's worker ends at startup) is a refusal. A marked answer other than 200 or 202 (a failed build, a revision the route refuses) is a refusal. Anything else (no answer, an error of Cloudflare's, a body cut off, a workers.dev URL not routed yet) is asked again; one ask may take the whole budget, as a bundle is large. The bundle has its own budget, `startTimeoutMs` (ten minutes): still none after it fails the apply retryably, "still building the app bundle at R after 600 s", saying what the last ask saw. Its assets (the client build and the prerendered pages) then go in through an [assets upload session](https://developers.cloudflare.com/workers/static-assets/direct-upload/) (`POST …/scripts/{name}/assets-upload-session { manifest }`, then each bucket it asks for, one after another, to `POST …/workers/assets/upload?base64=true` with the session's jwt).
109
+ 2. **One upload.** The Worker is uploaded once with everything: `index.js`, `instance.js` and the bundle's modules under `app/`, its compatibility date and flags, the bindings (the declared ones, the namespace, `CF_VERSION_METADATA`, `DATABASE` as Hyperdrive, `ASSETS`), `assets: { jwt, config }` (`run_worker_first: ["/*", "!/assets/*"]`, the client build straight from the assets; `html_handling` and `not_found_handling` `none`) and its version tagged with `R` (`annotations: { "workers/tag": R }`). From here visitors get the new app. Then the missing domains are attached, and the upload is waited for until it is [live](#live-before-asked).
110
+ 3. **The restart.** `GET /__sanoma/health?start=1` with the token, asked every poll until the object answers 200 at `R` and the configuration revision: the container the bundle's ask started at `R` is kept, and one at another revision or image (a deploy cut off, a container stopped meanwhile) is drained and started again at `R`. Its own budget, the same `startTimeoutMs`: still not after it fails the apply retryably, "still starting at R after 600 s". The step is idempotent: the next apply plans none, and an explicit update whose plan is none runs it alone, uploading nothing.
111
111
 
112
- No step answers a visitor 503 (but a recovered deployment's, above): the old app answers until the upload, the new one after it, and neither needs the container. A built-in workflow's runs on R-1 carry to R when its code is unchanged (`builtInCode` in `@sanoma-ai/workflows`), so the restart strands none of them. A plan compares secret binding names, never values: the Worker's settings never show them. Advance `configurationRevision` to upload rotated values and restart a running container with them; a value change alone does not trigger an update. A delete detaches the custom domains the Worker was declared to serve (its `hostname` too), deletes the application, the Worker with its object's storage, then the database's config.
112
+ ### Live before asked
113
+
114
+ An upload takes a while to reach every Cloudflare location, and until then the version before answers (on a new Worker, workers.dev's 404). After its last upload before a step asks the object, a deploy asks `GET /__sanoma/health`, without `start` so an earlier version starts nothing, every poll until the object answers with the uploaded version's id in `x-sanoma-deployment`, within the step's `startTimeoutMs`: any other answer, a 401, a 404 or a 503 among them, is "not yet", never "stale". The step's own asks then count only that version's answers.
115
+
116
+ No step answers a visitor 503 or an error: the app deployed answers until the upload of the new one, while R's container prepares the database and builds the bundle, and the new one after it, over a database with its migrations, and neither needs the container; only a Worker that never served an app answers `no-app.js`. A domain declared before and no longer is detached before the first upload of R's bindings, while they still record it, and a missing one attached once the upload with the app records it: whatever fails in between, none is left attached and unrecorded. A plan compares the version's tag with the revision, so a deploy that ended between its two uploads (the app deployed still served under R's bindings, untagged) plans an update, and one whose version was not tagged (a deploy before tags) plans one once. A built-in workflow's runs on R-1 carry to R when its code is unchanged (`builtInCode` in `sanoma/workflows`), so the restart strands none of them. A plan compares secret binding names, never values: the Worker's settings never show them. Advance `configurationRevision` to upload rotated values and restart a running container with them; a value change alone does not trigger an update. A delete detaches the custom domains the Worker was declared to serve (its `hostname` too), deletes the application, the Worker with its object's storage, then the database's config.
113
117
 
114
118
  ## The database
115
119
 
116
120
  Every host needs `SANOMA_DATABASE_URL` among its secrets: a create or an update without it, or with a URL that is not `postgres://` or `postgresql://`, is refused before anything changes, and the error never shows the URL. The container keeps the direct URL in its environment. The app on the Worker reaches the database through a [Hyperdrive](https://developers.cloudflare.com/hyperdrive/) config of the Worker's name, one per host, made or updated at every deploy from the URL (`{ scheme, host, port, database, user, password }`, port 5432 unless the URL names one, user and password decoded) with query caching off, `caching: { disabled: true }`: the app's reads must see its own writes. The upload binds it as `DATABASE`, whose `connectionString` the app connects with. Hyperdrive must reach the database from Cloudflare's network: a host on `localhost` or a private address is refused by Cloudflare at the config's write. The token needs Hyperdrive Edit.
117
121
 
122
+ ## Secrets
123
+
124
+ A host's secrets are read-only startup values. Apply resolves them on the machine that applies it, the Worker holds them, and the container receives them when it starts. Nothing on the host writes them back, and they are not a secret store.
125
+
126
+ **What the host is given.** A `cloudflare.host` is given its `secrets` by apply ([Hosts](https://github.com/Sanoma-AI/sanoma/blob/main/packages/sanoma/workflows/README.md#hosts)), as markers, never values:
127
+
128
+ | Under | From |
129
+ | ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
130
+ | `SANOMA_DATABASE_URL` | The declared `database`'s URL |
131
+ | `SANOMA_SIGNING_KEY` | The config's `SANOMA_SIGNING_KEY` binding (`{ bootstrap }` or `{ env }`), else a key of the host's own, generated at its create |
132
+ | `SANOMA_SECRETS_KEY` | The config's binding of it, only with the built-in store |
133
+ | `SANOMA_WAKEUP_TOKEN`, `SANOMA_SOURCE_KEY` | The wakeup's token, and the deploy key it clones a private repository with |
134
+ | Its vendors' credentials | Those stored on the connector pages of its data file's vendors, its repository's and the sign-in sender's, so it can deploy itself (`CLOUDFLARE_API_TOKEN` among them when it is stored), and the company's GitHub App keys that are stored |
135
+ | Each `{ env, host: true }` binding | That binding's value, under its variable's name: `PROVISIONING: { env: "SANOMA_PROVISIONING_CREDENTIAL", host: true }` is given as `SANOMA_PROVISIONING_CREDENTIAL` |
136
+
137
+ A `host: true` binding whose variable has no value is refused before the deploy. A variable the driver reads from this machine's environment with no binding is a problem the plan names, since the host would not be given it. A `{ path }` binding is never delivered: it is read from the store.
138
+
139
+ **How they reach the Worker.** The driver resolves each marker through the applying runtime's own bindings, so a `SANOMA_SECRETS_KEY_FILE` there is read on that machine and the host receives the key's value, never the path. The [one upload](#the-deploy) binds each as `secret_text`, beside the non-secret `plain_text` bindings (`SANOMA_REVISION`, `SANOMA_CONFIG_REVISION`, `SANOMA_HOST_URL`, `SANOMA_DOMAINS` and the rest). Cloudflare keeps them encrypted and shows their names, never their values, so a plan compares names only. The app on the Worker reads them as its environment (`nodejs_compat` fills `process.env` from the text bindings), and its database through the `DATABASE` binding, not the URL.
140
+
141
+ **How they reach the container.** The object starts the container with the Worker's text bindings, plain and secret, as its environment, and `sanoma worker` there resolves the company's bindings from it: an `{ env }` binding reads that variable, a `{ bootstrap }` binding the key. The process keeps its startup environment: a changed value reaches it only at its next start. To roll out a changed value, advance `configurationRevision` and apply the host: the upload carries the new values and the restart starts a container with them. A value changed alone plans no update.
142
+
143
+ **Mounted files.** `SANOMA_SIGNING_KEY_FILE` and `SANOMA_SECRETS_KEY_FILE` name a file on the machine reading them. Neither is delivered: Cloudflare mounts no files into the container, and the app on the Worker refuses a `_FILE` input, as `workerd` has no file system. Use them on the applying machine or a host of your own.
144
+
145
+ **Read-only.** On the host, a value from the environment or a bootstrap binding cannot be replaced or deleted through Sanoma: a write, a delete or an `ensure` of one fails `read_only`. A binding whose variable the host was not given reads as missing; it never falls back to the store's value of that name.
146
+
147
+ **In the environment is delivery, not encryption at rest.** Cloudflare encrypts Worker secrets at rest. In the running Worker and container they are plain values in the environment, readable by all code there: the app, the company's workflows, its sites' server code and the connectors' drivers. Deliver only what the host's runtime needs.
148
+
149
+ **Limits.** A Worker holds 128 variables on the Paid plan (64 on Free), secrets and plain text together, each at most 5 KB ([Workers limits](https://developers.cloudflare.com/workers/platform/limits/), page updated 2026-10-29).
150
+
151
+ ### The token: deploying and running
152
+
153
+ `CLOUDFLARE_API_TOKEN` is management authority. A host's runtime needs none of it to read its own secrets, which arrive in its environment.
154
+
155
+ | Who | Needs |
156
+ | -------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
157
+ | Apply of a host (here, or on the host) | Workers Scripts Edit, Workers Containers Edit, Hyperdrive Edit; Zone Read for `domains` and `hostname`; Zone → DNS → Edit on the zones of [DNS records](#dns-records) |
158
+ | The runtime on the host | None for its secrets, its wakeup's register or its wake route, which use `SANOMA_WAKEUP_TOKEN`. A host is given the API token only when it is stored for its vendor, so the host can deploy itself after a push |
159
+ | Anything here | Never Secrets Store Write or Secrets Store Read: Sanoma does not use the account's Secrets Store ([below](#the-account-secrets-store)) |
160
+
161
+ A host given the token holds it in its environment with everything else, so code on the host can deploy Workers with it. Give such a host a token scoped to the permissions above and this account. Without the token stored for `cloudflare`, the host is not given it, and deploys are applied from elsewhere.
162
+
163
+ ### The account Secrets Store
164
+
165
+ Cloudflare's account-wide [Secrets Store](https://developers.cloudflare.com/secrets-store/) is not one of Sanoma's secret stores: there is no adapter for it. Cloudflare documents (pages read 2026-11-06):
166
+
167
+ - It is in open beta: one store per account, up to 100 production secrets per account, each value at most 65,536 bytes ([manage account secrets](https://developers.cloudflare.com/secrets-store/manage-secrets/), updated 2026-10-22).
168
+ - Once stored, a value cannot be read through the API or the dashboard; only a bound service reads it. Locally created secrets are kept unencrypted in `.wrangler/state` (same page).
169
+ - A Worker reads one through a `secrets_store_secret` binding (`store_id`, `secret_name`) with `await env.BINDING.get()`. The binding reads only; it has no write or delete ([Workers integration](https://developers.cloudflare.com/secrets-store/integrations/workers/), updated 2026-10-12; [script upload](https://developers.cloudflare.com/api/resources/workers/subresources/scripts/methods/update/) for the binding's type).
170
+ - Writing is management: `PATCH …/secrets_store/stores/{store_id}/secrets/{secret_id}` with `value`, `scopes` and `comment`, under the Secrets Store Write permission. Its result carries `created`, `modified` and `status`, and no version; the API documents no ETag or conditional write ([edit a secret](https://developers.cloudflare.com/api/resources/secrets_store/subresources/stores/subresources/secrets/methods/edit/)). Creating secrets needs the Super Administrator or Secrets Store Admin role, binding them Super Administrator or Secrets Store Deployer.
171
+ - A container receives a Secrets Store value only as the Worker passes it at the container's start, and keeps it until its next start ([containers' environment](https://developers.cloudflare.com/containers/examples/env-vars-and-secrets/), updated 2026-10-12).
172
+
173
+ Against the `SecretStore` contract this is a store that only a Worker's binding reads, that the container where workflows run cannot read, that cannot report a version for a read, and whose only write is an unconditional replace by a management token: `writable: false` at runtime, `conditionalWrites: "none"`, `changeDetection: "read"`. Such a store cannot keep credentials Sanoma writes (an OAuth refresh, a generated secret), which is what a store adapter is for, and a value it holds reaches the runtime only as a startup value, as a host's secrets already do. A method that writes its credentials is refused against a read-only binding or a store without conditional writes before anyone consents, on the connector page and by `sanoma check` ([Credentials](https://github.com/Sanoma-AI/sanoma/blob/main/packages/sanoma/workflows/README.md#credentials)), never kept somewhere else instead. The store's list (`GET …/secrets_store/stores`) answered on Sanoma's account on 2026-11-06 with no store; nothing was made there.
174
+
175
+ ### Setups
176
+
177
+ **Supabase and Cloudflare, with the built-in store.** The company's database is Supabase Postgres; the built-in store encrypts credentials in it. Bind both keys as bootstrap and give the host the database:
178
+
179
+ ```ts
180
+ // sanoma.config.ts
181
+ secrets: {
182
+ bindings: {
183
+ SANOMA_SIGNING_KEY: { bootstrap: "SANOMA_SIGNING_KEY" },
184
+ SANOMA_SECRETS_KEY: { bootstrap: "SANOMA_SECRETS_KEY" },
185
+ },
186
+ },
187
+ ```
188
+
189
+ ```ts
190
+ // resources/infra.ts: `store` a declared `supabase.project`
191
+ export const host = cloudflare.host({ database: store });
192
+ ```
193
+
194
+ Apply gives the Worker `SANOMA_DATABASE_URL`, `SANOMA_SIGNING_KEY` and `SANOMA_SECRETS_KEY` as secrets, and the container receives them at its start. Back up the encryption key apart from the database: a database backup alone cannot decrypt the credentials.
195
+
196
+ **Supabase and Cloudflare, with Supabase Vault.** The [Vault adapter](../supabase/README.md#supabase-vault-as-the-secret-store) keeps and encrypts the credentials, so there is no `SANOMA_SECRETS_KEY`. Bind `SANOMA_SIGNING_KEY` as above, and deliver the adapter's scoped login to the host:
197
+
198
+ ```ts
199
+ // sanoma.config.ts
200
+ secrets: {
201
+ store: supabaseVault(),
202
+ bindings: {
203
+ SANOMA_SIGNING_KEY: { bootstrap: "SANOMA_SIGNING_KEY" },
204
+ VAULT_LOGIN: { env: "SUPABASE_VAULT_DATABASE_URL", host: true },
205
+ },
206
+ },
207
+ ```
208
+
209
+ The login authenticates to the store, so it is a host secret, never a value in the store it unlocks.
210
+
211
+ **The account Secrets Store.** Not a setup Sanoma supports, for the reasons above. Keep the company's credentials in the built-in store or Supabase Vault, and what the host's runtime needs at its start as host secrets. Sanoma reads nothing from the account store and copies nothing into it.
212
+
118
213
  ## The image
119
214
 
120
215
  A container of the `durable_object` policy runs an image of its own account's registry pinned by digest, `registry.cloudflare.com/<account id>/<repository>@sha256:<digest>`, never a tag, which Cloudflare stores and pulls without a limit (Docker Hub's pulls are not cached and are limited per address). So a create or an update first copies the declared image there and pins the copy by its manifest's digest, and the object starts that: `ghcr.io/sanoma-ai/runtime:0.8.1` becomes `registry.cloudflare.com/<account id>/sanoma-ai-runtime@sha256:…` (the path with `-` for `/`, copied as `:0.8.1`). An image in the account's registry by a tag is not copied: its manifest's digest is asked for (`docker-content-digest`); one there pinned by digest runs as it is, with no registry request. The copy is registry to registry in Node, no Docker: the source pulled anonymously (a public image; the token its registry's challenge names), the target pushed to with temporary credentials from `containers.registries.credentials.generate` (push and pull, an hour, never stored or logged). Each blob the account lacks is streamed across in one request of its known length, then the manifest, unchanged; when the account's manifest for that tag already has the source's digest, nothing is copied, and a digest-pinned source must answer that digest. Docker Hub is not copied from: declare `ghcr.io/sanoma-ai/runtime`. The source must be one image manifest (OCI or Docker v2), not an index: the release pushes one (`provenance: false`). Then the account prepares the pinned image to run (`POST …/containers/image-preparations { image }`, `containers.images.prepare`), asked again every two seconds until it is `ready`, as Wrangler does: an `error` fails the apply with Cloudflare's `reason`, not retryable, and fifteen minutes without `ready` fails it as retryable. Both come before the upload, so a copy or a preparation that fails leaves the Worker as it was.
@@ -138,7 +233,7 @@ Each hostname in `domains` is attached to the Worker as a [Workers custom domain
138
233
 
139
234
  ## DNS records
140
235
 
141
- `cloudflare.records({ zone, name, records })` is a set of DNS records in one of the account's zones, compared as a set, in no order. A sending domain's records are the case it is made for: `records` names a declared `resend.domain`, whose `dns_records` it then takes ([a field taken from another resource's state](https://github.com/Sanoma-AI/sanoma/blob/main/packages/workflows/README.md#resources)), or is a list written out.
236
+ `cloudflare.records({ zone, name, records })` is a set of DNS records in one of the account's zones, compared as a set, in no order. A sending domain's records are the case it is made for: `records` names a declared `resend.domain`, whose `dns_records` it then takes ([a field taken from another resource's state](https://github.com/Sanoma-AI/sanoma/blob/main/packages/sanoma/workflows/README.md#resources)), or is a list written out.
142
237
 
143
238
  ```ts
144
239
  // resources/infra.ts
@@ -149,12 +244,12 @@ export const mail = resend.domain({ name: "sanoma.work" });
149
244
  export const mailDns = cloudflare.records({ zone: "sanoma.work", name: "resend", records: mail });
150
245
  ```
151
246
 
152
- | Field | What it is |
153
- | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
154
- | `zone` | The zone's name, as the account holds it (`sanoma.work`); changing it replaces the set |
155
- | `name` | The set's label (`resend`): lower case letters, digits, `-` and `_`. Its identity is `<zone>/<name>`; changing it replaces the set |
156
- | `records` | The records, at least one: `{ type, name, content, priority?, ttl? }` each (`dnsRecord` from `@sanoma-ai/workflows`): TXT, MX, CNAME or CAA, the full name in lower case (the zone's name or one ending in it), a TXT record's text unquoted, a priority for MX, a ttl in seconds (1, automatic, when left out). One type, name and content declared twice with another ttl or priority, a name outside the zone, or a CNAME declared beside another record of its name, or two SPF policies (`v=spf1` TXT records) declared at one name, is refused, `invalid` |
157
- | `zone_id`, `record_ids` | Cloudflare's: the zone's id, and each record's, in the order of `records` as a read gives them |
247
+ | Field | What it is |
248
+ | ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
249
+ | `zone` | The zone's name, as the account holds it (`sanoma.work`); changing it replaces the set |
250
+ | `name` | The set's label (`resend`): lower case letters, digits, `-` and `_`. Its identity is `<zone>/<name>`; changing it replaces the set |
251
+ | `records` | The records, at least one: `{ type, name, content, priority?, ttl? }` each (`dnsRecord` from `sanoma/workflows`): TXT, MX, CNAME or CAA, the full name in lower case (the zone's name or one ending in it), a TXT record's text unquoted, a priority for MX, a ttl in seconds (1, automatic, when left out). One type, name and content declared twice with another ttl or priority, a name outside the zone, or a CNAME declared beside another record of its name, or two SPF policies (`v=spf1` TXT records) declared at one name, is refused, `invalid` |
252
+ | `zone_id`, `record_ids` | Cloudflare's: the zone's id, and each record's, in the order of `records` as a read gives them |
158
253
 
159
254
  **Ownership.** Every record the set writes carries the comment `sanoma:<zone>/<name>` (`sanoma:sanoma.work/resend`), in that case exactly, which is how a read finds its records (`GET /zones/{id}/dns_records?comment.exact=`): the set is the records that carry it, and none is gone. A record's comment holds 100 characters on a Free zone, so a set whose mark is longer is refused, `invalid`. A record without that comment is never changed or deleted, whoever added it, with one exception: a record identical to a declared one in type, name and content, and an MX record's priority (one added by hand before the set was declared), is adopted, patched to carry the comment and the declared ttl; so is one a changed record would be patched to, whose marked one is then deleted. An adopted record is the set's from then on: it carries the mark, so it changes with the set and is **deleted with it**, and the comment it had is replaced by the mark (the set finds its records by the exact comment, so it keeps no other). A record in the way of a declared one is refused, `conflict`, naming it, before anything is written, whether the declared one is to be posted or a marked one patched to it: a CNAME at the name (or a declared CNAME beside any record), another SPF policy (a `v=spf1` TXT) at the name, an MX record to the same server at another priority, a record identical to a declared one that another set's comment marks, or one identical to it that is proxied (a set's records are DNS only, and adopting it would turn its proxy off). Every page of a lookup is read, so a busy name hides nothing.
160
255
 
@@ -166,11 +261,11 @@ export const mailDns = cloudflare.records({ zone: "sanoma.work", name: "resend",
166
261
 
167
262
  ## Driver
168
263
 
169
- `@sanoma-ai/connector-cloudflare/driver` calls Cloudflare through its official SDK, [`cloudflare`](https://www.npmjs.com/package/cloudflare) (Stainless), with its own retries off (the runtime retries what is retryable), and calls the company's Worker with `fetch`. The `cloudflare` connector the package root exports carries it and its fake (`withSetup` from `@sanoma-ai/workflows`), so a config names the connector alone and workflows never import the driver (the lint refuses that).
264
+ `@sanoma-ai/connector-cloudflare/driver` calls Cloudflare through its official SDK, [`cloudflare`](https://www.npmjs.com/package/cloudflare) (Stainless), with its own retries off (the runtime retries what is retryable), and calls the company's Worker with `fetch`. The `cloudflare` connector the package root exports carries it and its fake (`withSetup` from `sanoma/workflows`), so a config names the connector alone and workflows never import the driver (the lint refuses that).
170
265
 
171
- `./driver` (`cloudflareDriver`; `cloudflareDriver({ timeoutMs, startTimeoutMs, pollMs })`: 30 s a request, ten minutes for each of the deploy's two waits, the bundle and the restart, two seconds between tries; each request of the image's copy may take ten minutes) and `./fake` (`fakeCloudflare`) are internal entries, for tests.
266
+ `./driver` (`cloudflareDriver`; `cloudflareDriver({ timeoutMs, startTimeoutMs, pollMs })`: 30 s a request, ten minutes for each of the deploy's waits (an upload live, the bundle, the restart), two seconds between tries; each request of the image's copy may take ten minutes) and `./fake` (`fakeCloudflare`) are internal entries, for tests.
172
267
 
173
- A read is the Worker's settings (its bindings: what it runs is its plain-text bindings, never a secret's value), the application of its name (whether it exists, its id) and the account's subdomain (its URL); a plan compares the declared image, source, ref, revision, port, domains and hostname (each left out too) and secret names with them, and plans an update for a Worker that serves no app yet (no `DATABASE` binding: a create cut off before its upload). The requests are made one after another, in the order the fixtures hold.
268
+ A read is the Worker's settings (its bindings: what it runs is its plain-text bindings, never a secret's value), the application of its name (whether it exists, its id) and the account's subdomain (its URL); a plan compares the declared image, source, ref, revision, port, domains and hostname (each left out too) and secret names with them, and plans an update for a Worker whose version is not tagged with its revision (`workers/tag`: a create cut off before its upload with the app, a deploy cut off between its two uploads, or a Worker deployed before tags, once). The requests are made one after another, in the order the fixtures hold.
174
269
 
175
270
  ### Environment
176
271
 
@@ -181,7 +276,7 @@ It reads these on every call, never when the config loads:
181
276
  | `CLOUDFLARE_API_TOKEN` | An API token with Workers Scripts Edit and Workers Containers Edit (Write, in the API's terms), Zone Read for `domains` (custom domains are attached and detached with Workers Scripts Edit) and DNS records, and Zone → DNS → Edit on the zones of [DNS records](#dns-records) |
182
277
  | `CLOUDFLARE_ACCOUNT_ID` | The account's id, 32 hexadecimal digits, on its dashboard's overview |
183
278
 
184
- When either is unset, a call fails, not retryable, naming it. The driver declares both in its `env` ([Credentials](https://www.npmjs.com/package/@sanoma-ai/workflows#credentials)): the worker starts without them, and the app's connector page shows their status and lets you set them. The alarm's operations need neither: they call the Worker with `SANOMA_WAKEUP_TOKEN` (`alarm.create` mints it when none is stored), and `alarm.create` stores `SANOMA_HOST_URL` once the host answered, for a register made off the host; it keeps the first one stored, which the Worker's own binding overrides on the host. A read without the token reads the alarm as unhealthy, so a plan to delete it still goes on.
279
+ When either is unset, a call fails, not retryable, naming it. The driver declares both in its `env` ([Credentials](https://github.com/Sanoma-AI/sanoma/blob/main/packages/sanoma/workflows/README.md#credentials)): the worker starts without them, and the app's connector page shows their status and lets you set them. The alarm's operations need neither: they call the Worker with `SANOMA_WAKEUP_TOKEN` (`alarm.create` mints it when none is stored), and `alarm.create` stores `SANOMA_HOST_URL` once the host answered, replacing an earlier host's. `register` sends to the stored URL, beside the stored token, on the host as off it: it reads nothing from the process environment. A read without the token reads the alarm as unhealthy, so a plan to delete it still goes on.
185
280
 
186
281
  ### Errors and retries
187
282
 
@@ -193,7 +288,7 @@ Containers need the Workers Paid plan. An instance is billed while it runs, by i
193
288
 
194
289
  ### Testing the driver
195
290
 
196
- `test/driver.test.ts`, `test/records.test.ts` and the features replay Cloudflare's replies (`test/fixtures`) with [`@sanoma-ai/testing/replay`](https://github.com/Sanoma-AI/sanoma/blob/main/packages/testing/README.md#replaying-a-vendors-api): `pnpm vitest run connectors/cloudflare` needs no account. The fixtures are **written from Cloudflare's API reference, not recorded**: no account was at hand when the connector was written. A recording replaces them (`SANOMA_LIVE=1 SANOMA_RECORD=1` on the features test), losing the account's id and subdomain, ids and tokens; until then, a reply the reference gets wrong is wrong here too. The upload's `containers` field (its `name`, `class_name` and `images`) is Wrangler's and not in the reference or the SDK's types, and the object's `ctx.container.images` and `start({ image, instance })` are the policy's: the live run is what checks them. The DNS records' fixtures (`records-*`) are written from the [DNS records reference](https://developers.cloudflare.com/api/resources/dns/subresources/records/) the same way, on `sanoma.work` with a set named `check` (`check-*.sanoma.work`), to be recorded on their first live run: Cloudflare's TXT content is quoted in them, which a read takes off. That Cloudflare shows a TXT record written unquoted with quotes is the reference's examples', not checked; a read compares it either way. The `sites` fixture's assets session and bucket upload are written from the [direct upload guide](https://developers.cloudflare.com/workers/static-assets/direct-upload/) and the SDK's types the same way, with the guide's example hash (sha256 over an asset's base64 and its extension, 32 hex digits) and each part's type from its extension; that Cloudflare takes them, and serves `/assets/*` before the Worker, is the live run's to check. The image's copy is tested against two small registries in this process (`test/registry.test.ts`), and the driver's call for its credentials over replies written from the SDK's types and the OCI distribution spec; that Cloudflare's registry takes the copy as written is what the live run checks. The driver tests only replay.
291
+ `test/driver.test.ts`, `test/records.test.ts` and the features replay Cloudflare's replies (`test/fixtures`) with [`sanoma/testing/replay`](https://github.com/Sanoma-AI/sanoma/blob/main/packages/sanoma/testing/README.md#replaying-a-vendors-api): `pnpm vitest run connectors/cloudflare` needs no account. The fixtures are **written from Cloudflare's API reference, not recorded**: no account was at hand when the connector was written. A recording replaces them (`SANOMA_LIVE=1 SANOMA_RECORD=1` on the features test), losing the account's id and subdomain, ids and tokens; until then, a reply the reference gets wrong is wrong here too. The upload's `containers` field (its `name`, `class_name` and `images`) is Wrangler's and not in the reference or the SDK's types, and the object's `ctx.container.images` and `start({ image, instance })` are the policy's: the live run is what checks them. The DNS records' fixtures (`records-*`) are written from the [DNS records reference](https://developers.cloudflare.com/api/resources/dns/subresources/records/) the same way, on `sanoma.work` with a set named `check` (`check-*.sanoma.work`), to be recorded on their first live run: Cloudflare's TXT content is quoted in them, which a read takes off. That Cloudflare shows a TXT record written unquoted with quotes is the reference's examples', not checked; a read compares it either way. The `sites` fixture's assets session and bucket upload are written from the [direct upload guide](https://developers.cloudflare.com/workers/static-assets/direct-upload/) and the SDK's types the same way, with the guide's example hash (sha256 over an asset's base64 and its extension, 32 hex digits) and each part's type from its extension; that Cloudflare takes them, and serves `/assets/*` before the Worker, is the live run's to check. The image's copy is tested against two small registries in this process (`test/registry.test.ts`), and the driver's call for its credentials over replies written from the SDK's types and the OCI distribution spec; that Cloudflare's registry takes the copy as written is what the live run checks. The driver tests only replay.
197
292
 
198
293
  ### Running it live
199
294
 
@@ -219,21 +314,21 @@ It needs:
219
314
 
220
315
  ## Steps and features
221
316
 
222
- The connector carries steps for [scenarios](https://github.com/Sanoma-AI/sanoma/blob/main/packages/workflows/README.md#steps-a-connector-ships) (`cloudflareSteps`, attached with `withSetup`):
317
+ The connector carries steps for [scenarios](https://github.com/Sanoma-AI/sanoma/blob/main/packages/sanoma/workflows/README.md#steps-a-connector-ships) (`cloudflareSteps`, attached with `withSetup`):
223
318
 
224
319
  | Keyword | Step | What it does |
225
320
  | ------- | ---------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
226
321
  | Given | `a Cloudflare container for {string} at revision {string}` | Creates the company's container through `cloudflare.container.create`, its token generated, named `host` (`$host.state.url`) |
227
322
 
228
- `features/cloudflare.feature` creates, reads, plans and deletes a container, and creates an alarm and registers with it, and `features/records.feature` creates a record set, reads it, plans it unchanged, updates it with a changed record and one dropped, and deletes it, on the fake and on the replies in `test/fixtures` (named after each scenario): `test/features.test.ts` runs them with [`describeFeatures`](https://github.com/Sanoma-AI/sanoma/blob/main/packages/testing/README.md#a-connectors-own-features). The package ships `features/`.
323
+ `features/cloudflare.feature` creates, reads, plans and deletes a container, and creates an alarm and registers with it, and `features/records.feature` creates a record set, reads it, plans it unchanged, updates it with a changed record and one dropped, and deletes it, on the fake and on the replies in `test/fixtures` (named after each scenario): `test/features.test.ts` runs them with [`describeFeatures`](https://github.com/Sanoma-AI/sanoma/blob/main/packages/sanoma/testing/README.md#a-connectors-own-features). The package ships `features/`.
229
324
 
230
325
  ## Testing
231
326
 
232
- `@sanoma-ai/connector-cloudflare/fake` is an in-memory Cloudflare account, the fake the connector carries: each sandbox run makes one of its own. Its registry is in memory too: a copy records the image under its reference there and pulls nothing. Its custom domains are in `state.domains` (hostname, Worker and zone), each zone's DNS records in `state.dns`, by the zone's name (a test adds one by hand there; a batch is all or nothing, and refuses a record identical to one the zone holds (its type, content and priority) or one beside a CNAME, as Cloudflare does), and it holds every zone asked for unless `fakeCloudflare({ zones })` names the ones it holds. A copy pins the image by a made-up digest, and a preparation answers ready for an image pinned in its registry. Its Workers answer on ports of this machine, one per Worker name, and run the package's own object code over a `ctx` in this process: storage in memory, an alarm on a timer (again after a throw), `ctx.container.images` from the upload's `containers[].images`, and a container that runs what `start` returns for the image (the one its pinned copy was copied from) and revision it was started at (by default a stub that answers `/healthz` and `/wake`); `start` refuses an image the upload did not name or an instance type that is not Cloudflare's. An upload restarts the object over its new bindings and images: a new image starts the container again at the next request, as the object finds its label changed. Its assets upload session asks, in one bucket, for the hashes `state.assets` lacks, and an upload that redeems the completion jwt keeps each path's hash on the Worker (`state.scripts[name].assets`, beside its `main_module`, `modules` and `compatibility_flags`). Its Hyperdrive configs are in `state.hyperdrives`, their passwords left out, and its `DATABASE` binding's `connectionString` is the direct URL. Its Workers run the package's own `serve` over the upload's modules, written to a folder and `app/index.js` imported from there; the bundle the container's worker answers is `fakeCloudflare({ bundle })`'s, by default `stubAppBundle`, a plain ES module that answers pages and `/healthz` and serves `/assets/`, since the real bundle is built for `workerd` (`nodejs_compat`, WebAssembly) and Node cannot import it.
327
+ `@sanoma-ai/connector-cloudflare/fake` is an in-memory Cloudflare account, the fake the connector carries: each sandbox run makes one of its own. Its registry is in memory too: a copy records the image under its reference there and pulls nothing. Its custom domains are in `state.domains` (hostname, Worker and zone), each zone's DNS records in `state.dns`, by the zone's name (a test adds one by hand there; a batch is all or nothing, and refuses a record identical to one the zone holds (its type, content and priority) or one beside a CNAME, as Cloudflare does), and it holds every zone asked for unless `fakeCloudflare({ zones })` names the ones it holds. A copy pins the image by a made-up digest, and a preparation answers ready for an image pinned in its registry. Its Workers answer on ports of this machine, one per Worker name, and run the package's own object code over a `ctx` in this process: storage in memory, an alarm on a timer (again after a throw), `ctx.container.images` from the upload's `containers[].images`, and a container that runs what `start` returns for the image (the one its pinned copy was copied from) and revision it was started at (by default `stubContainer`, a stub that answers `/healthz` and `/wake`); `start` refuses an image the upload did not name or an instance type that is not Cloudflare's. An upload answers with its version's id (its object's `CF_VERSION_METADATA.id`), and is live at once, or after `fakeCloudflare({ propagation: N })` more requests to the version before (workers.dev's 404 for a new Worker), as Cloudflare's takes a while to reach every location; it then restarts the object over its new bindings and images: a new image starts the container again at the next request, as the object finds its label changed. Its settings and content give the latest upload back (its bindings, compatibility date and flags, version tag and modules), and an upload with `keep_assets` serves the assets of the version before. Its assets upload session asks, in one bucket, for the hashes `state.assets` lacks, and an upload that redeems the completion jwt keeps each path's hash on the Worker (`state.scripts[name].assets`, beside its `main_module`, `modules`, compatibility date and flags and `tag`). Its Hyperdrive configs are in `state.hyperdrives`, their passwords left out, and its `DATABASE` binding's `connectionString` is the direct URL, beside the fake's own `prepared(revision)`: whether a container's worker at that revision started over the database (its `SANOMA_DATABASE_URL`), as each prepares it at its start. Its Workers run the package's own `serve` over the upload's modules, written to a folder and `app/index.js` imported from there; the bundle the container's worker answers is `fakeCloudflare({ bundle })`'s, by default `stubAppBundle`, a plain ES module that answers pages and `/healthz` and serves `/assets/`, and answers 500 while its database lacks its revision's migrations, since the real bundle is built for `workerd` (`nodejs_compat`, WebAssembly) and Node cannot import it.
233
328
 
234
329
  ```ts
235
330
  import { fakeCloudflare } from "@sanoma-ai/connector-cloudflare/fake";
236
- import { inProcessHost } from "@sanoma-ai/testing/host";
331
+ import { inProcessHost } from "sanoma/testing/host";
237
332
 
238
333
  const fake = fakeCloudflare({
239
334
  start: ({ revision, env }) => inProcessHost(config, databaseUrl)({ port: 0, revision, secrets: env }),
@@ -1,4 +1,4 @@
1
- import { type Connector, type DnsRecord } from "@sanoma-ai/workflows";
1
+ import { type Connector, type DnsRecord } from "sanoma/workflows";
2
2
  import { z } from "zod";
3
3
  /**
4
4
  * `cloudflare.container`: the company's Worker, `sanoma-<name>`, on the account's workers.dev
@@ -12,7 +12,7 @@ import { z } from "zod";
12
12
  * Deprecated: declare `cloudflare.host`, the same Worker, which takes the decisions alone. A
13
13
  * declaration renamed to it keeps its lockfile binding, and nothing is made again.
14
14
  */
15
- export declare const container: import("@sanoma-ai/workflows").Resource<z.ZodObject<{
15
+ export declare const container: import("sanoma/workflows").Resource<z.ZodObject<{
16
16
  id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
17
17
  name: z.ZodString;
18
18
  image: z.ZodString;
@@ -43,7 +43,7 @@ export declare const container: import("@sanoma-ai/workflows").Resource<z.ZodObj
43
43
  * as secrets its database's URL, its keys, the source key it clones with (whose public half apply
44
44
  * declares on the repository) and the credentials it deploys itself with: names only, never a value.
45
45
  */
46
- export declare const host: import("@sanoma-ai/workflows").Resource<z.ZodObject<{
46
+ export declare const host: import("sanoma/workflows").Resource<z.ZodObject<{
47
47
  id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
48
48
  revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
49
49
  configurationRevision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -77,7 +77,7 @@ export declare const host: import("@sanoma-ai/workflows").Resource<z.ZodObject<{
77
77
  * `SANOMA_WAKEUP_TOKEN`: a workflow that makes hosts for several companies names one per company.
78
78
  * The state keeps that name, so a `read`, `update` or `delete` given the state sends the same token.
79
79
  */
80
- export declare const alarm: import("@sanoma-ai/workflows").Resource<z.ZodObject<{
80
+ export declare const alarm: import("sanoma/workflows").Resource<z.ZodObject<{
81
81
  host: z.ZodString;
82
82
  at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
83
83
  rang: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -126,7 +126,7 @@ export declare const canonicalRecord: ({ type, name, content, priority, ttl }: A
126
126
  * `records` may name a `resend.domain`, whose `dns_records` it then takes (`from`): a sending
127
127
  * domain's records go to the zone that holds them.
128
128
  */
129
- export declare const records: import("@sanoma-ai/workflows").Resource<z.ZodObject<{
129
+ export declare const records: import("sanoma/workflows").Resource<z.ZodObject<{
130
130
  zone: z.ZodString;
131
131
  name: z.ZodString;
132
132
  records: z.ZodArray<z.ZodObject<{
package/dist/connector.js CHANGED
@@ -1,5 +1,5 @@
1
- import { compareDeclared, RUNTIME_PORT, UNNAMED, defineConnector, defineResource, dnsRecord, vendorInfo, } from "@sanoma-ai/workflows";
2
- import { DOMAIN_NAME, SITE_KEY } from "@sanoma-ai/workflows/shared";
1
+ import { compareDeclared, RUNTIME_PORT, UNNAMED, defineConnector, defineResource, dnsRecord, vendorInfo, } from "sanoma/workflows";
2
+ import { DOMAIN_NAME, SITE_KEY } from "sanoma/workflows/shared";
3
3
  import { z } from "zod";
4
4
  /*
5
5
  * Cloudflare, over its official SDK (`cloudflare`): one Worker per company that runs the company
@@ -1 +1 @@
1
- {"version":3,"file":"connector.js","sourceRoot":"","sources":["../src/connector.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,YAAY,EACZ,OAAO,EAEP,eAAe,EACf,cAAc,EAEd,SAAS,EAGT,UAAU,GACX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;GAMG;AAEH,8GAA8G;AAC9G,MAAM,IAAI,GAAG,wCAAwC,CAAC;AAEtD,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,uDAAuD,CAAC;IAC1F,IAAI,EAAE,CAAC;SACJ,MAAM,EAAE;SACR,KAAK,CAAC,IAAI,EAAE,mDAAmD,CAAC;SAChE,QAAQ,CACP,0GAA0G,CAC3G;IACH,KAAK,EAAE,CAAC;SACL,MAAM,EAAE;SACR,KAAK,CAAC,oDAAoD,EAAE,oCAAoC,CAAC;SACjG,MAAM,CAAC,CAAC,KAAK,EAAE,EA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,EAAE,CAAC,eAAe,CAAC,aAAa,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;IACzG,QAAQ,EAAE,IAAI;IACd,+EAA+E;IAC/E,SAAS,EAAE,IAAI;CAChB,CAAC,CAAC;AAEH,MAAM,KAAK,GAAG,eAAe,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE9G,uFAAuF;AACvF,MAAM,YAAY,GAAG;IACnB,QAAQ,EAAE;QACR,MAAM,EAAE,OAAO;QACf,qEAAqE;QACrE,UAAU,EAAE,IAAI;QAChB,WAAW,EAAE,+EAA+E;QAC5F,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,iCAAiC,CAAC,EAAE,CAAC;QACrG,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;KACrB;CAC+B,CAAC;AAEnC,MAAM,QAAQ,GAAG,eAAe,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;AAUxE;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,GAAG,KAAK;IACR,KAAK,EAAE,EAAE,GAAG,KAAK,CAAC,KAAK,EAAE,GAAG,QAAQ,CAAC,KAAK,EAAE;CACU,CAAC"}
package/dist/deploy.d.ts CHANGED
@@ -1,9 +1,11 @@
1
- import type { AppBundle } from "@sanoma-ai/app";
1
+ import type { AppBundle } from "sanoma/app";
2
2
  import type { CloudflareApi, ContainerOptions } from "./ops.ts";
3
3
  /** The Worker's entry module, which imports `cloudflare:workers`, `instance.js` and `app/index.js`. */
4
4
  export declare const MAIN_MODULE = "index.js";
5
5
  /** The Durable Object class the Worker exports, which the container application runs behind. */
6
6
  export declare const OBJECT_CLASS = "SanomaInstance";
7
+ /** Where the app bundle's modules go in the upload: the entry imports `app/index.js`. */
8
+ export declare const APP = "app/";
7
9
  /** One module of the Worker: its name in the upload, its source, and its kind (an ES module unless it says). */
8
10
  export interface WorkerModule {
9
11
  name: string;
@@ -41,26 +43,25 @@ export declare function waitFor<T>(doing: string, { startTimeoutMs, pollMs }: Po
41
43
  } | {
42
44
  last: string;
43
45
  }>): Promise<T>;
44
- /**
45
- * The app bundle at `revision`, asked of the Worker at `url` with the instance token until it
46
- * gives it: the object starts its container when it is stopped, and both it and the worker answer
47
- * 202 meanwhile. A failed build or a revision the route refuses is a refusal. A deployment that
48
- * cannot build it is `{ stale }`, why: a token refused (the deployed Worker or its container holds
49
- * another), a container that ended, or, from an earlier deployment (`earlier`), a 404 the route
50
- * did not mark (a runtime without it). Any other answer (no answer, an error of Cloudflare's, a
51
- * body cut off, a workers.dev URL not routed yet) is asked again. Still none
52
- * after `startTimeoutMs` is a retryable `DriverError` that says what the last ask saw. One ask
53
- * may take the whole budget: a bundle is large.
54
- */
55
- export declare function appBundle(cf: CloudflareApi, { script, url, token, revision, earlier, }: {
46
+ interface BundleAsk {
56
47
  script: string;
57
48
  url: string;
58
49
  token: string;
59
50
  revision: string;
60
- earlier: boolean;
61
- }, polling: Polling): Promise<AppBundle | {
62
- stale: string;
63
- }>;
51
+ /** The id of the Worker version this deploy uploaded at the revision, whose answers alone count. */
52
+ deployment: string;
53
+ }
54
+ /**
55
+ * The app bundle at `revision`, asked of the Worker at `url` with the instance token until it
56
+ * gives it: the object starts its container at the revision when it is stopped or runs another,
57
+ * and both it and the worker answer 202 meanwhile. An answer without the version `deployment` is an
58
+ * earlier version's, still answering while the upload reaches every location: asked again,
59
+ * whatever its status. A failed build, a revision the route refuses, a container that ended or the
60
+ * version uploaded refusing the ask (any 4xx of its own, such as another token's 401) is a refusal. Any other answer (no answer, an error of Cloudflare's, a body cut off, a workers.dev URL
61
+ * not routed yet) is asked again. Still none after `startTimeoutMs` is a retryable `DriverError`
62
+ * that says what the last ask saw. One ask may take the whole budget: a bundle is large.
63
+ */
64
+ export declare function appBundle(cf: CloudflareApi, { script, url, token, revision, deployment }: BundleAsk, polling: Polling): Promise<AppBundle>;
64
65
  /** Puts the bundle's assets in through an upload session for `script`'s next upload: the completion jwt that upload redeems. */
65
66
  export declare function uploadAssets(cf: CloudflareApi, script: string, assets: AppBundle["assets"]): Promise<string>;
66
67
  export {};
package/dist/deploy.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import { readFile } from "node:fs/promises";
2
2
  import { setTimeout as delay } from "node:timers/promises";
3
- import { DriverError, errorMessage } from "@sanoma-ai/workflows";
4
- import { APP_BUNDLE_HEADER, APP_BUNDLE_PATH } from "@sanoma-ai/workflows/shared";
3
+ import { DriverError, errorMessage } from "sanoma/workflows";
4
+ import { APP_BUNDLE_HEADER, APP_BUNDLE_PATH } from "sanoma/workflows/shared";
5
5
  import mime from "mime";
6
6
  import { refused } from "./errors.js";
7
+ import { DEPLOYMENT_HEADER } from "../worker/instance.js";
7
8
  // What a deploy uploads as the company's Worker script: the package's `worker/` (the entry and the
8
9
  // object's code) and the app bundle under `app/`, which the worker at the new revision's checkout
9
10
  // builds and the object passes on (`appBundle`), its assets through an upload session.
@@ -13,7 +14,7 @@ export const MAIN_MODULE = "index.js";
13
14
  /** The Durable Object class the Worker exports, which the container application runs behind. */
14
15
  export const OBJECT_CLASS = "SanomaInstance";
15
16
  /** Where the app bundle's modules go in the upload: the entry imports `app/index.js`. */
16
- const APP = "app/";
17
+ export const APP = "app/";
17
18
  let modules;
18
19
  const read = (file, name = file) => readFile(new URL(file, WORKER), "utf8").then((content) => ({ name, content }));
19
20
  /**
@@ -71,16 +72,15 @@ export async function waitFor(doing, { startTimeoutMs, pollMs }, ask) {
71
72
  }
72
73
  /**
73
74
  * The app bundle at `revision`, asked of the Worker at `url` with the instance token until it
74
- * gives it: the object starts its container when it is stopped, and both it and the worker answer
75
- * 202 meanwhile. A failed build or a revision the route refuses is a refusal. A deployment that
76
- * cannot build it is `{ stale }`, why: a token refused (the deployed Worker or its container holds
77
- * another), a container that ended, or, from an earlier deployment (`earlier`), a 404 the route
78
- * did not mark (a runtime without it). Any other answer (no answer, an error of Cloudflare's, a
79
- * body cut off, a workers.dev URL not routed yet) is asked again. Still none
80
- * after `startTimeoutMs` is a retryable `DriverError` that says what the last ask saw. One ask
81
- * may take the whole budget: a bundle is large.
75
+ * gives it: the object starts its container at the revision when it is stopped or runs another,
76
+ * and both it and the worker answer 202 meanwhile. An answer without the version `deployment` is an
77
+ * earlier version's, still answering while the upload reaches every location: asked again,
78
+ * whatever its status. A failed build, a revision the route refuses, a container that ended or the
79
+ * version uploaded refusing the ask (any 4xx of its own, such as another token's 401) is a refusal. Any other answer (no answer, an error of Cloudflare's, a body cut off, a workers.dev URL
80
+ * not routed yet) is asked again. Still none after `startTimeoutMs` is a retryable `DriverError`
81
+ * that says what the last ask saw. One ask may take the whole budget: a bundle is large.
82
82
  */
83
- export async function appBundle(cf, { script, url, token, revision, earlier, }, polling) {
83
+ export function appBundle(cf, { script, url, token, revision, deployment }, polling) {
84
84
  return waitFor(`${script}: still building the app bundle at ${revision}`, polling, async () => {
85
85
  try {
86
86
  const res = await cf.send(`${url}${APP_BUNDLE_PATH}?revision=${encodeURIComponent(revision)}`, {
@@ -88,17 +88,21 @@ export async function appBundle(cf, { script, url, token, revision, earlier, },
88
88
  headers: { authorization: `Bearer ${token}` },
89
89
  signal: AbortSignal.timeout(polling.startTimeoutMs),
90
90
  });
91
+ const by = res.headers.get(DEPLOYMENT_HEADER);
92
+ if (by !== deployment) {
93
+ await res.body?.cancel();
94
+ return { last: `an earlier version (${by || "unmarked"}) answered ${res.status}` };
95
+ }
91
96
  const route = res.headers.has(APP_BUNDLE_HEADER);
92
97
  // Undefined when it is none (a body cut off where the JSON is).
93
98
  const body = (await res.json().catch(() => undefined));
94
99
  if (route && res.status === 200 && body !== undefined)
95
100
  return { value: body };
96
101
  const said = typeof body?.error === "string" ? body.error : `${APP_BUNDLE_PATH} answered ${res.status}`;
97
- if (res.status === 401 || typeof body?.exit === "string" || (earlier && !route && res.status === 404)) {
98
- return { value: { stale: said } };
99
- }
100
- // The worker's own refusal: the build's failure, a revision it refuses.
101
- if (route && res.status !== 200 && res.status !== 202)
102
+ // The worker's own refusal (the build's failure, a revision it refuses), the container ended, or
103
+ // the version uploaded refuses the ask (the token its bindings hold is another): none passes on asking.
104
+ const own4xx = res.status >= 400 && res.status < 500;
105
+ if (typeof body?.exit === "string" || own4xx || (route && res.status !== 200 && res.status !== 202))
102
106
  throw refused(`${script}: no app bundle at ${revision}: ${said}`);
103
107
  return {
104
108
  last: res.status === 202 ? (route ? "the worker is building it" : "its container is starting") : said,