From 099d09d904d9c971549ae2db5fd68f31a1390763 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Sun, 22 Nov 2026 14:11:39 +0000 Subject: [PATCH 1/2] ci(lab-ops-hub): release Worker versions through cf --- .github/workflows/container-images.yml | 1 - .github/workflows/lab-ops-hub-promote.yml | 75 + .../workflows/lab-ops-hub-worker-release.yml | 78 + .github/workflows/lab-ops-hub.yml | 28 +- lib/default.nix | 6 +- pkgs/deploy/default.nix | 2 +- pkgs/deploy/services.nix | 10 +- pkgs/lab-ops-hub/.gitignore | 1 + pkgs/lab-ops-hub/README.md | 61 +- pkgs/lab-ops-hub/cloudflare.config.ts | 43 + pkgs/lab-ops-hub/container-image.nix | 2 +- pkgs/lab-ops-hub/deploy.mjs | 150 -- pkgs/lab-ops-hub/deploy.nix | 33 - pkgs/lab-ops-hub/image-push.mjs | 122 ++ pkgs/lab-ops-hub/image-push.nix | 29 + pkgs/lab-ops-hub/{deploy.sh => image-push.sh} | 8 +- pkgs/lab-ops-hub/package.json | 1 - .../release-tools/package-lock.json | 1653 +++++++++++++++++ pkgs/lab-ops-hub/release-tools/package.json | 13 + .../release-tools/verify-build.mjs | 121 ++ pkgs/lab-ops-hub/wrangler.config.ts | 5 + 21 files changed, 2219 insertions(+), 223 deletions(-) create mode 100644 .github/workflows/lab-ops-hub-promote.yml create mode 100644 .github/workflows/lab-ops-hub-worker-release.yml create mode 100644 pkgs/lab-ops-hub/.gitignore create mode 100644 pkgs/lab-ops-hub/cloudflare.config.ts delete mode 100644 pkgs/lab-ops-hub/deploy.mjs delete mode 100644 pkgs/lab-ops-hub/deploy.nix create mode 100644 pkgs/lab-ops-hub/image-push.mjs create mode 100644 pkgs/lab-ops-hub/image-push.nix rename pkgs/lab-ops-hub/{deploy.sh => image-push.sh} (61%) create mode 100644 pkgs/lab-ops-hub/release-tools/package-lock.json create mode 100644 pkgs/lab-ops-hub/release-tools/package.json create mode 100644 pkgs/lab-ops-hub/release-tools/verify-build.mjs create mode 100644 pkgs/lab-ops-hub/wrangler.config.ts diff --git a/.github/workflows/container-images.yml b/.github/workflows/container-images.yml index 6a01dd7d07..d472cfa3a0 100644 --- a/.github/workflows/container-images.yml +++ b/.github/workflows/container-images.yml @@ -10,7 +10,6 @@ on: - "pkgs/identity/**" - "pkgs/lab-ops-hub/container-image.nix" - "pkgs/lab-ops-hub/container/**" - - "pkgs/lab-ops-hub/wrangler.jsonc" - "pkgs/generic-containers/**" - "lib/default.nix" - "flake.nix" diff --git a/.github/workflows/lab-ops-hub-promote.yml b/.github/workflows/lab-ops-hub-promote.yml new file mode 100644 index 0000000000..07b72d8713 --- /dev/null +++ b/.github/workflows/lab-ops-hub-promote.yml @@ -0,0 +1,75 @@ +name: Lab Ops Hub Worker promotion + +on: + workflow_dispatch: + inputs: + version_id: + description: "Exact Worker Version UUID printed by the upload workflow" + required: true + type: string + confirm_promotion: + description: "Confirm promotion of this exact version to 100% of traffic" + required: true + default: false + type: boolean + +permissions: + contents: read + +concurrency: + group: lab-ops-hub-worker-promotion + cancel-in-progress: false + +jobs: + promote: + if: github.ref == 'refs/heads/main' + runs-on: ubuntu-24.04 + timeout-minutes: 10 + env: + CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }} + VERSION_ID: ${{ inputs.version_id }} + steps: + - name: Keep promotion held until explicitly confirmed + if: ${{ !inputs.confirm_promotion }} + run: echo "::notice::Promotion held. Review the uploaded version UUID, then dispatch again with confirmation." + + - name: Checkout + if: ${{ inputs.confirm_promotion }} + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + + - name: Set up Node 24.22.0 + if: ${{ inputs.confirm_promotion }} + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 + with: + node-version: 24.22.0 + + - name: Install pinned cf and Wrangler toolchain + if: ${{ inputs.confirm_promotion }} + working-directory: pkgs/lab-ops-hub + run: | + npm ci --prefix release-tools + ln -s release-tools/node_modules node_modules + + - name: Validate exact version UUID + if: ${{ inputs.confirm_promotion }} + working-directory: pkgs/lab-ops-hub + run: | + node --input-type=module <<'NODE' + import { writeFileSync } from "node:fs"; + const id = process.env.VERSION_ID; + if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(id ?? "")) { + throw new Error("version_id must be a UUID printed by the upload workflow"); + } + writeFileSync("versions.json", JSON.stringify([{ version_id: id, percentage: 100 }])); + NODE + + - name: Promote the selected version to 100% + if: ${{ inputs.confirm_promotion }} + working-directory: pkgs/lab-ops-hub + env: + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + run: >- + ./node_modules/.bin/cf workers deployments create + --worker lab-ops-hub + --strategy percentage + --versions @versions.json diff --git a/.github/workflows/lab-ops-hub-worker-release.yml b/.github/workflows/lab-ops-hub-worker-release.yml new file mode 100644 index 0000000000..63b33e76c9 --- /dev/null +++ b/.github/workflows/lab-ops-hub-worker-release.yml @@ -0,0 +1,78 @@ +name: Lab Ops Hub Worker version upload + +on: + workflow_dispatch: + inputs: + confirm_migration_tag_v2: + description: "Confirm Cloudflare reports v2 as the active Durable Object migration tag" + required: true + default: false + type: boolean + confirm_container_image_v5_available: + description: "Confirm the pinned crawler container image :v5 is already published" + required: true + default: false + type: boolean + +permissions: + contents: read + +jobs: + upload: + if: github.ref == 'refs/heads/main' + runs-on: ubuntu-24.04 + timeout-minutes: 20 + concurrency: + group: lab-ops-hub-worker-version-upload + cancel-in-progress: false + env: + CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }} + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + + - name: Set up Node 24.22.0 + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 + with: + node-version: 24.22.0 + + - name: Install pinned cf and Wrangler toolchain + working-directory: pkgs/lab-ops-hub + run: | + npm ci --prefix release-tools + ln -s release-tools/node_modules node_modules + + - name: Build Build Output v1 + working-directory: pkgs/lab-ops-hub + run: ./node_modules/.bin/cf build + + - name: Verify Wrangler-to-cf binding and migration parity + working-directory: pkgs/lab-ops-hub + run: node release-tools/verify-build.mjs + + - name: Dry-run Worker Version upload + working-directory: pkgs/lab-ops-hub + run: >- + ./node_modules/.bin/cf workers versions create + --prebuilt + --worker lab-ops-hub + --tag "git-${GITHUB_SHA::12}" + --message "git ${GITHUB_SHA}" + --dry-run + + - name: Keep upload held until cutover checks are confirmed + if: ${{ !inputs.confirm_migration_tag_v2 || !inputs.confirm_container_image_v5_available }} + run: | + echo "::notice::Worker Version upload held. Confirm active migration tag v2 and published image :v5, then dispatch again." + + - name: Upload Worker Version without promoting it + if: ${{ inputs.confirm_migration_tag_v2 && inputs.confirm_container_image_v5_available }} + working-directory: pkgs/lab-ops-hub + env: + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + run: >- + ./node_modules/.bin/cf workers versions create + --prebuilt + --worker lab-ops-hub + --tag "git-${GITHUB_SHA::12}" + --message "git ${GITHUB_SHA}" diff --git a/.github/workflows/lab-ops-hub.yml b/.github/workflows/lab-ops-hub.yml index cdff7bcf9d..768bdbe1d2 100644 --- a/.github/workflows/lab-ops-hub.yml +++ b/.github/workflows/lab-ops-hub.yml @@ -49,12 +49,12 @@ jobs: timeout-minutes: 10 steps: - name: Checkout - uses: actions/checkout@v7 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 - name: Set up Node - uses: actions/setup-node@v7 + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 with: - node-version: 24 + node-version: 24.22.0 - name: Set up Python uses: actions/setup-python@v7 @@ -68,3 +68,25 @@ jobs: - name: Run both crawl-validator suites working-directory: pkgs/lab-ops-hub run: npm test + + - name: Install pinned Worker release toolchain + working-directory: pkgs/lab-ops-hub + run: | + npm ci --prefix release-tools + ln -s release-tools/node_modules node_modules + + - name: Build and verify Build Output v1 parity + working-directory: pkgs/lab-ops-hub + run: | + ./node_modules/.bin/cf build + node release-tools/verify-build.mjs + + - name: Dry-run Worker Version upload + working-directory: pkgs/lab-ops-hub + run: >- + ./node_modules/.bin/cf workers versions create + --prebuilt + --worker lab-ops-hub + --tag git-offlinecheck + --message offline-check + --dry-run diff --git a/lib/default.nix b/lib/default.nix index f885143a23..d5ba4eab1d 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -749,7 +749,7 @@ let coldStoreRehydratorBundle = coldStoreRehydrator; }; labOpsHub = pkgs.callPackage ../pkgs/lab-ops-hub/package.nix { }; - labOpsHubDeploy = pkgs.callPackage ../pkgs/lab-ops-hub/deploy.nix { + labOpsHubImagePush = pkgs.callPackage ../pkgs/lab-ops-hub/image-push.nix { inherit labOpsHub; }; cfContainerHello = pkgs.callPackage ../pkgs/cf-container-hello/package.nix { }; @@ -780,7 +780,7 @@ let coldStoreRehydrator coldStoreRehydratorDeploy labOpsHub - labOpsHubDeploy + labOpsHubImagePush cfContainerHello cfContainerHelloDeploy queueTransportAlert @@ -865,7 +865,7 @@ let pkarr-deploy = mkApp pkarrDeploy "Deploy the pkarr Worker via the cf versions flow (needs Bitwarden and sops access)"; developing-today-backup-deploy = mkApp developingTodayBackupDeploy "Deploy the developing-today-backup Worker (github-backup webhook receiver) via the wrangler versions flow (needs Bitwarden and sops access)"; cold-store-rehydrator-deploy = mkApp coldStoreRehydratorDeploy "Deploy the cold-store-rehydrator Worker from its flake bundle via the wrangler versions flow (needs Bitwarden and sops access)"; - lab-ops-hub-deploy = mkApp labOpsHubDeploy "Deploy the lab-ops-hub Worker and push its crawler container image as one command (needs Bitwarden and sops access)"; + lab-ops-hub-image-push = mkApp labOpsHubImagePush "Build and push the Lab Ops Hub crawler container image only (needs Bitwarden and sops access); Worker releases use the GHA cf Versions workflow"; cf-container-hello-deploy = mkApp cfContainerHelloDeploy "Deploy the cf-container-hello Worker from its flake package (needs Bitwarden and sops access)"; queue-transport-alert-deploy = mkApp queueTransportAlertDeploy "Deploy the queue-transport-alert Worker (broker outage alert, code#6369) from its flake package via the cf versions flow (needs Bitwarden and sops access)"; message-bridge-deploy = mkApp messageBridgeDeploy "Deploy the message-bridge Worker (Claude custom connector that sends and receives messages, plus history page) through the cf versions flow (tagged version, then deployment) and set its access token; --code-only uploads code with Cloudflare env vars (CI), --deploy-version rolls back, --print-urls prints the connector URL (needs Bitwarden and sops access)"; diff --git a/pkgs/deploy/default.nix b/pkgs/deploy/default.nix index e04528c9c4..415d5e2d1d 100644 --- a/pkgs/deploy/default.nix +++ b/pkgs/deploy/default.nix @@ -39,7 +39,7 @@ let coldStoreRehydratorDeploy = callPackage ../../pkgs/cold-store-reaper/worker/deploy.nix { coldStoreRehydratorBundle = callPackage ../../pkgs/cold-store-reaper/worker/package.nix { }; }; - labOpsHubDeploy = callPackage ../../pkgs/lab-ops-hub/deploy.nix { + labOpsHubImagePush = callPackage ../../pkgs/lab-ops-hub/image-push.nix { labOpsHub = callPackage ../../pkgs/lab-ops-hub/package.nix { }; }; cfContainerHelloDeploy = callPackage ../../pkgs/cf-container-hello/deploy.nix { diff --git a/pkgs/deploy/services.nix b/pkgs/deploy/services.nix index 5e53ca8ada..6c8436944d 100644 --- a/pkgs/deploy/services.nix +++ b/pkgs/deploy/services.nix @@ -19,7 +19,7 @@ pkarrDeploy, developingTodayBackupDeploy, coldStoreRehydratorDeploy, - labOpsHubDeploy, + labOpsHubImagePush, cfContainerHelloDeploy, queueTransportAlertDeploy, messageBridgeDeploy, @@ -193,9 +193,11 @@ class = "cloudflare"; }; - lab-ops-hub = { - package = labOpsHubDeploy; - entryPoint = "bin/lab-ops-hub-deploy"; + # Keep the crawler image publisher as a separate operator action. The + # Worker's cf Version upload and promotion live in GitHub Actions. + lab-ops-hub-image = { + package = labOpsHubImagePush; + entryPoint = "bin/lab-ops-hub-image-push"; args = [ ]; environment = { }; secrets = [ ]; # resolved by the deploy app itself at deploy time diff --git a/pkgs/lab-ops-hub/.gitignore b/pkgs/lab-ops-hub/.gitignore new file mode 100644 index 0000000000..e233a391c1 --- /dev/null +++ b/pkgs/lab-ops-hub/.gitignore @@ -0,0 +1 @@ +.cloudflare/ diff --git a/pkgs/lab-ops-hub/README.md b/pkgs/lab-ops-hub/README.md index d87dadd497..d76785dbff 100644 --- a/pkgs/lab-ops-hub/README.md +++ b/pkgs/lab-ops-hub/README.md @@ -79,7 +79,7 @@ needs `npm install`. CI installs that Python dependency and runs the same test command on every pull request touching `pkgs/lab-ops-hub/**` (`.github/workflows/lab-ops-hub.yml`). -## Develop / deploy +## Develop / release ```bash npm install @@ -89,29 +89,44 @@ wrangler r2 bucket create labops-files wrangler kv namespace create CACHE wrangler queues create labops-jobs npm run db:init # remote D1 schema -npm run deploy # deploys the Worker; build/push the Nix image below first npm run dev # local dev (containers run via workerd locally too) ``` -**Preferred (issue #5767 phase 2):** `nix run .#lab-ops-hub-deploy` -does the whole deploy as one command — builds + pushes the Nix -container image below, then deploys the Worker from the flake package -(`package.nix`, lockfile-pinned deps incl. the pinned wrangler; no -deploy-time `npm install`). It is registered as the `lab-ops-hub` -target of the `deploy` CLI. `-- --dry-run` validates the Worker -config only. The manual sequence below remains the reference for how -the image push works (registry credentials need the account-wide -token — see the known-behaviour notes). - -Deploy auth: set `CLOUDFLARE_API_TOKEN` (scoped day-to-day token from -Bitwarden) or use the repo-standard wrapper — never commit a token. -Runtime API auth is separate: the `API_TOKEN` Worker secret above gates -the deployed API itself. +Worker releases use the two manually dispatched workflows from `main`: + +- `lab-ops-hub-worker-release.yml` builds Build Output v1, checks the + mapped config against `wrangler.jsonc`, and uploads a tagged Worker + Version with `cf workers versions create`. It does not route traffic. +- `lab-ops-hub-promote.yml` takes an uploaded version UUID and a separate + confirmation, then explicitly deploys that version at 100% with + `cf workers deployments create`. + +Both workflows use Node `24.22.0`, `cf@1.0.0-rc.1`, and Wrangler +`4.163.0`. The upload workflow keeps a default hold: dispatch it from +`main`, review the offline build and dry run, then affirm both that the +existing Worker reports migration tag `v2` and that the pinned crawler +image is available. It needs the repository variable +`CLOUDFLARE_ACCOUNT_ID` and secret `CLOUDFLARE_API_TOKEN`; scope the token +to Cloudflare `Workers Scripts Write`. The secret is present only on the +version-upload step, never on pull-request workflows. The promotion +workflow requires the exact version UUID and its own explicit confirmation. + +Cutover prerequisites: the `lab-ops-hub` Worker must already exist, +Cloudflare must report migration tag `v2` as current, and the pinned +`lab-ops-hub-crawlercontainer:v5` image must already be present in the +configured registry. `cf workers versions create` refuses a pending +Durable Object migration and cannot create a Worker that does not exist. +The existing `v1` and `v2` migration records stay in `wrangler.jsonc`; +this release path does not apply them. If any prerequisite is unknown or +false, keep the upload held and resolve it before promotion. + +Runtime API auth is separate: the existing `API_TOKEN` Worker secret +gates the deployed API itself. ## Container image without a Docker daemon (what this sandbox does) -The Wrangler target references the pre-pushed registry image, so deployment -does not build a Dockerfile. Build and push the image daemon-less: +The Worker config references a pre-pushed registry image; the Worker release +does not build or publish a container. Build and push the image separately: ```bash # 1. Build the OCI image with Nix (dockerTools) — pinned nixpkgs in container-image.nix @@ -124,14 +139,16 @@ wrangler containers registries credentials --push # prints a JWT # (docker config auth entry for registry.cloudflare.com) nix run nixpkgs#crane -- push \ registry.cloudflare.com//lab-ops-hub-crawlercontainer:v5 -# 4. wrangler.jsonc references the registry image (not ./Dockerfile), -# so `wrangler deploy` needs no Docker at all. +# 4. wrangler.jsonc references the registry image (not ./Dockerfile); +# the separate GHA Worker release then uploads code referencing this pin. ``` The Nix-built `container-image.nix` artifact is the only image build path. `wrangler.jsonc` points `CrawlerContainerV2` at the matching `:v5` registry -image; `npm run deploy` deploys the Worker configuration but does not build or -push that image. +image. The operator app `nix run .#lab-ops-hub-image-push` builds and pushes +only that image (use `-- --dry-run` to build without pushing). It does not +upload or promote a Worker Version. `wrangler.jsonc` and the Build Output +mapping both pin `CrawlerContainerV2` to the matching `:v5` image. ### Known behaviour (observed 2026-10-20, D1-verified) diff --git a/pkgs/lab-ops-hub/cloudflare.config.ts b/pkgs/lab-ops-hub/cloudflare.config.ts new file mode 100644 index 0000000000..fd60dc83e9 --- /dev/null +++ b/pkgs/lab-ops-hub/cloudflare.config.ts @@ -0,0 +1,43 @@ +import { bindings, defineConfig, triggers } from "cf/config"; + +// The Wrangler config remains authoritative for deployment migrations. The +// Build Output config below mirrors its non-migration Worker settings; `cf +// workers versions create` refuses to apply a pending migration. +export default defineConfig({ + worker: { + name: "lab-ops-hub", + compatibilityDate: "2025-09-01", + compatibilityFlags: ["nodejs_compat"], + entrypoint: "src/index.ts", + observability: { enabled: true }, + assets: { runWorkerFirst: ["/api/*"] }, + triggers: [ + triggers.scheduled({ schedule: "23 4 * * *" }), + triggers.queue({ maxBatchSize: 10, maxRetries: 3, name: "labops-jobs" }), + ], + env: { + DB: bindings.d1({ name: "labops-db", id: "3115e67f-150e-4ee8-8b11-216127901ae8" }), + FILES: bindings.r2({ name: "labops-files" }), + CACHE: bindings.kv({ id: "ac69d54d9e3f455d99a940b3fced4b76" }), + JOBS: bindings.queue({ name: "labops-jobs" }), + LIVE: bindings.durableObject({ worker: "lab-ops-hub", exportName: "LiveRoom" }), + CRAWLER: bindings.durableObject({ worker: "lab-ops-hub", exportName: "CrawlerContainerV2" }), + AI: bindings.ai({}), + ASSETS: bindings.assets(), + }, + unsafe: { + metadata: { + // `cf migrate` does not migrate Containers. Keep this manual mapping + // aligned with wrangler.jsonc and container-image.nix's immutable v5. + containers: [ + { + class_name: "CrawlerContainerV2", + image: "registry.cloudflare.com/234b866b99ce2b142d7963d8d139cbfa/lab-ops-hub-crawlercontainer:v5", + max_instances: 2, + instance_type: "lite", + }, + ], + }, + }, + }, +}); diff --git a/pkgs/lab-ops-hub/container-image.nix b/pkgs/lab-ops-hub/container-image.nix index 6786fd6f02..c46201f419 100644 --- a/pkgs/lab-ops-hub/container-image.nix +++ b/pkgs/lab-ops-hub/container-image.nix @@ -2,7 +2,7 @@ # nixpkgs is pinned to the same rev as dezren39/nix's flake.lock. # Build: nix build -f container-image.nix -> store path is a docker-archive tar # Push: crane push registry.cloudflare.com//lab-ops-hub-crawlercontainer:v5 -# (or load it anywhere with docker/podman and `wrangler deploy` from there) +# (the Worker release workflow separately uploads code referencing this pin) # # Image shape matters (learned 2026-10-25): the v3 shape — relative Cmd # ("python3 app.py"), no PATH env, no shell — stopped starting after diff --git a/pkgs/lab-ops-hub/deploy.mjs b/pkgs/lab-ops-hub/deploy.mjs deleted file mode 100644 index 0526855622..0000000000 --- a/pkgs/lab-ops-hub/deploy.mjs +++ /dev/null @@ -1,150 +0,0 @@ -// Deploys the lab-ops-hub Worker AND its crawler container image as -// one command — issue #5767, phase 2 ("worker deploy + its container -// image push become one `deploy lab-ops-hub`"). Previously: build the -// Nix image by hand, mint registry credentials by hand, crane push by -// hand, then a raw `npm run deploy` in a checkout. -// -// The Worker tree is a flake package (package.nix, lockfile-pinned -// deps including the pinned wrangler 4.152.0); this script stages that -// package (or, run directly from a checkout, the checkout itself) and -// runs the package's own wrangler from the staged copy. No -// deploy-time `npm install`. -// -// Steps (full deploy): -// 1. nix build -f container-image.nix (the only image build path; -// pinned nixpkgs inside that file) -> docker-archive tar. -// 2. Mint temporary registry push credentials with -// `wrangler containers registries credentials --push`. This -// needs the ACCOUNT-WIDE Cloudflare token — the day-to-day token -// gets Forbidden (README, observed 2026-10-20). Name the -// Bitwarden secret holding it with LOH_CF_ACCOUNT_TOKEN_SECRET; -// without one, the day-to-day token is tried and the failure -// message names the remedy. -// 3. crane push the tar to the registry image wrangler.jsonc -// references (lab-ops-hub-crawlercontainer:v5 — keep in step -// with container-image.nix's tag). -// 4. wrangler deploy from the staged package. -// -// Usage: -// deploy.mjs [--dry-run] validate the Worker config -// only (no image push, no -// upload) -// -// Needs CLOUDFLARE_ACCOUNT_ID and BWS_ACCESS_TOKEN; deploy.sh sets -// them. API tokens come from Bitwarden by name (deploy token default -// cloudflare.api-token-day-to-day; override with LOH_CF_TOKEN_SECRET). -// No secret is ever printed; the registry JWT passes to crane through -// a temporary docker config directory, never argv or logs. -import { execFileSync } from "node:child_process"; -import { cpSync, existsSync, mkdtempSync, writeFileSync } from "node:fs"; -import { tmpdir } from "node:os"; -import { dirname, join } from "node:path"; -import { fileURLToPath } from "node:url"; - -const here = dirname(fileURLToPath(import.meta.url)); -const WORKER = "lab-ops-hub"; -const IMAGE = "lab-ops-hub-crawlercontainer:v5"; // container-image.nix tag - -const args = process.argv.slice(2); -// Strict argument validation, following the sibling deploy scripts -// (#3287): the only accepted invocation is `deploy.mjs [--dry-run]`. -function usageError(message) { - console.error(`${message}\nusage: deploy.mjs [--dry-run]`); - process.exit(2); -} -let dryRun = false; -for (const arg of args) { - if (arg === "--dry-run") { - if (dryRun) usageError("duplicate argument: --dry-run"); - dryRun = true; - } else { - usageError(`unrecognized argument: ${arg}`); - } -} - -requireEnv("CLOUDFLARE_ACCOUNT_ID"); -const accountId = process.env.CLOUDFLARE_ACCOUNT_ID; -const secrets = JSON.parse(execFileSync("bws", ["secret", "list", "-o", "json"], { encoding: "utf8" })); -const byName = (name) => secrets.find((secret) => secret.key === name)?.value; -const tokenSecretName = process.env.LOH_CF_TOKEN_SECRET ?? "cloudflare.api-token-day-to-day"; -const apiToken = byName(tokenSecretName); -if (!apiToken) { - throw new Error(`no Bitwarden secret named ${tokenSecretName}`); -} -const env = { ...process.env, CLOUDFLARE_API_TOKEN: apiToken }; - -// Stage a writable copy of the Worker package (the store path is -// read-only; wrangler writes .wrangler state next to the config). -const pkgDir = process.env.LAB_OPS_HUB_PKG ?? here; -const stage = mkdtempSync(join(tmpdir(), "lab-ops-hub-deploy-")); -cpSync(pkgDir, stage, { recursive: true }); -if (!existsSync(join(stage, "wrangler.jsonc"))) { - throw new Error(`no wrangler.jsonc in staged Worker package at ${pkgDir}`); -} -const wranglerBin = existsSync(join(stage, "node_modules", ".bin", "wrangler")) - ? join(stage, "node_modules", ".bin", "wrangler") - : "wrangler"; - -if (dryRun) { - runWrangler(["deploy", "--dry-run"]); - console.log("dry run: config builds, nothing uploaded, image not pushed"); - process.exit(0); -} - -// 1. Build the crawler container image (daemon-less, dockerTools). -console.log("building crawler container image (container-image.nix)"); -const imageTar = execFileSync( - "nix", - ["build", "-f", join(here, "container-image.nix"), "--no-link", "--print-out-paths"], - { encoding: "utf8" } -).trim().split("\n").pop(); - -// 2. Mint temporary registry push credentials (account-wide token). -const pushTokenName = process.env.LOH_CF_ACCOUNT_TOKEN_SECRET; -const pushToken = pushTokenName ? byName(pushTokenName) : apiToken; -if (pushTokenName && !pushToken) { - throw new Error(`no Bitwarden secret named ${pushTokenName} (LOH_CF_ACCOUNT_TOKEN_SECRET)`); -} -let registryJwt; -try { - const out = execFileSync(wranglerBin, ["containers", "registries", "credentials", "--push"], { - cwd: stage, - env: { ...env, CLOUDFLARE_API_TOKEN: pushToken }, - encoding: "utf8", - }); - registryJwt = out.trim().split(/\s+/).pop(); -} catch { - throw new Error( - "could not mint registry push credentials: `wrangler containers registries credentials --push` " + - "requires the ACCOUNT-WIDE Cloudflare token (the day-to-day token gets Forbidden — see " + - "pkgs/lab-ops-hub/README.md). Name the Bitwarden secret holding it via " + - "LOH_CF_ACCOUNT_TOKEN_SECRET and retry." - ); -} - -// 3. Push the image with crane, username = account id, password = JWT -// (via a temporary docker config dir; the JWT never reaches argv). -const dockerConfig = mkdtempSync(join(tmpdir(), "lab-ops-hub-docker-config-")); -const auth = Buffer.from(`${accountId}:${registryJwt}`).toString("base64"); -writeFileSync( - join(dockerConfig, "config.json"), - JSON.stringify({ auths: { "registry.cloudflare.com": { auth } } }) -); -const imageRef = `registry.cloudflare.com/${accountId}/${IMAGE}`; -console.log(`pushing container image ${imageRef}`); -execFileSync("crane", ["push", imageTar, imageRef], { - env: { ...process.env, DOCKER_CONFIG: dockerConfig }, - stdio: "inherit", -}); - -// 4. Deploy the Worker from the staged flake package. -runWrangler(["deploy"]); -console.log(`deployed: ${WORKER} (image ${imageRef} pushed, wrangler deploy from the flake package)`); - -function runWrangler(wranglerArgs) { - execFileSync(wranglerBin, wranglerArgs, { cwd: stage, env, stdio: "inherit" }); -} - -function requireEnv(name) { - if (!process.env[name]) throw new Error(`${name} is not set; run deploy.sh`); -} diff --git a/pkgs/lab-ops-hub/deploy.nix b/pkgs/lab-ops-hub/deploy.nix deleted file mode 100644 index 79d13a951a..0000000000 --- a/pkgs/lab-ops-hub/deploy.nix +++ /dev/null @@ -1,33 +0,0 @@ -{ - writeShellApplication, - bws, - crane, - git, - jq, - nix, - nodejs, - sops, - labOpsHub, -}: -# Issue #5767, phase 2: one `deploy lab-ops-hub` — the deploy app -# carries the flake package (package.nix: Worker tree + lockfile- -# pinned deps incl. wrangler) by store path; deploy.mjs stages it, -# builds + pushes the crawler container image (container-image.nix), -# and runs the pinned wrangler deploy from the staged copy. -writeShellApplication { - name = "lab-ops-hub-deploy"; - runtimeInputs = [ - bws - crane - git - jq - nix - nodejs - sops - ]; - text = '' - export LAB_OPS_HUB_PKG="${labOpsHub}" - repo_root=$(git rev-parse --show-toplevel) - exec bash "$repo_root/pkgs/lab-ops-hub/deploy.sh" "$@" - ''; -} diff --git a/pkgs/lab-ops-hub/image-push.mjs b/pkgs/lab-ops-hub/image-push.mjs new file mode 100644 index 0000000000..3ec16da33e --- /dev/null +++ b/pkgs/lab-ops-hub/image-push.mjs @@ -0,0 +1,122 @@ +// Build and push only the Lab Ops Hub crawler image. Worker versions are +// uploaded and promoted by the separate, explicitly dispatched GHA workflows. +// Keep this immutable image pin aligned with container-image.nix and +// wrangler.jsonc; changing it requires publishing the image before a Worker +// release can reference it. +// +// Usage: image-push.mjs [--dry-run] +// --dry-run builds the Nix image but skips Cloudflare credentials and push. +// +// Needs CLOUDFLARE_ACCOUNT_ID and BWS_ACCESS_TOKEN; image-push.sh sets them. +// The account-wide push token comes from Bitwarden by name. It is passed to +// Wrangler only in the child environment; registry JWT is held in a temporary +// Docker config and is never passed in argv or printed. +import { execFileSync } from "node:child_process"; +import { + cpSync, + existsSync, + mkdtempSync, + rmSync, + writeFileSync, +} from "node:fs"; +import { tmpdir } from "node:os"; +import { dirname, join } from "node:path"; +import { fileURLToPath } from "node:url"; + +const here = dirname(fileURLToPath(import.meta.url)); +const IMAGE = "lab-ops-hub-crawlercontainer:v5"; + +const args = process.argv.slice(2); +function usageError(message) { + console.error(`${message}\nusage: image-push.mjs [--dry-run]`); + process.exit(2); +} +let dryRun = false; +for (const arg of args) { + if (arg === "--dry-run") { + if (dryRun) usageError("duplicate argument: --dry-run"); + dryRun = true; + } else { + usageError(`unrecognized argument: ${arg}`); + } +} +if (process.env.LOH_CHECK_ARGS_ONLY === "1") process.exit(0); + +// The build path is intentionally shared with container-images.yml. The +// Worker release workflow never builds or pushes this image. +console.log("building crawler container image (container-image.nix)"); +const imageTar = execFileSync( + "nix", + ["build", "-f", join(here, "container-image.nix"), "--no-link", "--print-out-paths"], + { encoding: "utf8" }, +).trim().split("\n").pop(); +if (dryRun) { + console.log("dry run: image built, nothing pushed; Worker version unchanged"); + process.exit(0); +} + +requireEnv("CLOUDFLARE_ACCOUNT_ID"); +const accountId = process.env.CLOUDFLARE_ACCOUNT_ID; +const secrets = JSON.parse(execFileSync("bws", ["secret", "list", "-o", "json"], { encoding: "utf8" })); +const byName = (name) => secrets.find((secret) => secret.key === name)?.value; +const tokenSecretName = process.env.LOH_CF_TOKEN_SECRET ?? "cloudflare.api-token-day-to-day"; +const apiToken = byName(tokenSecretName); +if (!apiToken) throw new Error(`no Bitwarden secret named ${tokenSecretName}`); +const pushTokenName = process.env.LOH_CF_ACCOUNT_TOKEN_SECRET; +const pushToken = pushTokenName ? byName(pushTokenName) : apiToken; +if (pushTokenName && !pushToken) { + throw new Error(`no Bitwarden secret named ${pushTokenName} (LOH_CF_ACCOUNT_TOKEN_SECRET)`); +} + +const pkgDir = process.env.LAB_OPS_HUB_PKG ?? here; +const stage = mkdtempSync(join(tmpdir(), "lab-ops-hub-image-push-")); +const dockerConfig = mkdtempSync(join(tmpdir(), "lab-ops-hub-docker-config-")); +try { + // Wrangler may create local state, so stage the read-only flake package. + cpSync(pkgDir, stage, { recursive: true }); + if (!existsSync(join(stage, "wrangler.jsonc"))) { + throw new Error(`no wrangler.jsonc in staged Worker package at ${pkgDir}`); + } + const wranglerBin = existsSync(join(stage, "node_modules", ".bin", "wrangler")) + ? join(stage, "node_modules", ".bin", "wrangler") + : "wrangler"; + + let registryJwt; + try { + const out = execFileSync(wranglerBin, ["containers", "registries", "credentials", "--push"], { + cwd: stage, + env: { ...process.env, CLOUDFLARE_API_TOKEN: pushToken }, + encoding: "utf8", + }); + registryJwt = out.trim().split(/\s+/).pop(); + } catch { + throw new Error( + "could not mint registry push credentials: `wrangler containers registries credentials --push` " + + "requires the account-wide Cloudflare token (the day-to-day token gets Forbidden). Name the " + + "Bitwarden secret holding it via LOH_CF_ACCOUNT_TOKEN_SECRET and retry.", + ); + } + + // Push with crane, username = account id, password = JWT. The JWT never + // reaches argv and the temporary Docker auth file is removed after push. + const auth = Buffer.from(`${accountId}:${registryJwt}`).toString("base64"); + writeFileSync( + join(dockerConfig, "config.json"), + JSON.stringify({ auths: { "registry.cloudflare.com": { auth } } }), + { mode: 0o600 }, + ); + const imageRef = `registry.cloudflare.com/${accountId}/${IMAGE}`; + console.log(`pushing container image ${imageRef}`); + execFileSync("crane", ["push", imageTar, imageRef], { + env: { ...process.env, DOCKER_CONFIG: dockerConfig }, + stdio: "inherit", + }); + console.log(`image published: ${imageRef}; Worker version unchanged`); +} finally { + rmSync(dockerConfig, { recursive: true, force: true }); + rmSync(stage, { recursive: true, force: true }); +} + +function requireEnv(name) { + if (!process.env[name]) throw new Error(`${name} is not set; run image-push.sh`); +} diff --git a/pkgs/lab-ops-hub/image-push.nix b/pkgs/lab-ops-hub/image-push.nix new file mode 100644 index 0000000000..d6c9854fc2 --- /dev/null +++ b/pkgs/lab-ops-hub/image-push.nix @@ -0,0 +1,29 @@ +{ + writeShellApplication, + bws, + crane, + git, + nix, + nodejs, + sops, + labOpsHub, +}: +# Operator-only crawler image build and push. Worker code is released by +# the separate GHA cf Workers Versions flow. +writeShellApplication { + name = "lab-ops-hub-image-push"; + runtimeInputs = [ + bws + crane + git + nix + nodejs + sops + ]; + text = '' + LOH_CHECK_ARGS_ONLY=1 node ${./image-push.mjs} "$@" + export LAB_OPS_HUB_PKG="${labOpsHub}" + repo_root=$(git rev-parse --show-toplevel) + exec bash "$repo_root/pkgs/lab-ops-hub/image-push.sh" "$@" + ''; +} diff --git a/pkgs/lab-ops-hub/deploy.sh b/pkgs/lab-ops-hub/image-push.sh similarity index 61% rename from pkgs/lab-ops-hub/deploy.sh rename to pkgs/lab-ops-hub/image-push.sh index 845c5f51e4..737bcb8fb9 100755 --- a/pkgs/lab-ops-hub/deploy.sh +++ b/pkgs/lab-ops-hub/image-push.sh @@ -1,12 +1,12 @@ #!/usr/bin/env bash -# Deploys the lab-ops-hub Worker + its crawler container image as one -# command (see deploy.mjs). Pass --dry-run to validate the Worker -# config without pushing the image or deploying. +# Builds and pushes only the lab-ops-hub crawler container image +# (see image-push.mjs). The separate GHA version workflow releases Worker code. set -euo pipefail cd "$(dirname "${BASH_SOURCE[0]}")" +LOH_CHECK_ARGS_ONLY=1 node image-push.mjs "$@" repo_root=$(git rev-parse --show-toplevel) # shellcheck source=/dev/null source "${repo_root}/lib/bitwarden-env.sh" >/dev/null CLOUDFLARE_ACCOUNT_ID=$(sops decrypt --extract '["cloudflare_account_id"]' "${repo_root}/secrets/sops/common/cloudflare.yaml") export CLOUDFLARE_ACCOUNT_ID -exec node deploy.mjs "$@" +exec node image-push.mjs "$@" diff --git a/pkgs/lab-ops-hub/package.json b/pkgs/lab-ops-hub/package.json index 3dbb893f09..9764a406de 100644 --- a/pkgs/lab-ops-hub/package.json +++ b/pkgs/lab-ops-hub/package.json @@ -12,7 +12,6 @@ "scripts": { "db:init": "wrangler d1 execute labops-db --remote --file=./schema.sql", "db:init:local": "wrangler d1 execute labops-db --local --file=./schema.sql", - "deploy": "wrangler deploy", "dev": "wrangler dev", "test": "npm run test:ts && npm run test:py", "test:py": "python3 -m unittest discover -s test -p \"test_*.py\"", diff --git a/pkgs/lab-ops-hub/release-tools/package-lock.json b/pkgs/lab-ops-hub/release-tools/package-lock.json new file mode 100644 index 0000000000..7642bbdd8d --- /dev/null +++ b/pkgs/lab-ops-hub/release-tools/package-lock.json @@ -0,0 +1,1653 @@ +{ + "name": "lab-ops-hub-release-tools", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "lab-ops-hub-release-tools", + "dependencies": { + "@cloudflare/containers": "0.3.7", + "cf": "1.0.0-rc.1", + "wrangler": "4.163.0" + }, + "engines": { + "node": "24.22.x" + } + }, + "node_modules/@cloudflare/build-output-utils": { + "version": "1.0.0-rc.1", + "resolved": "https://registry.npmjs.org/@cloudflare/build-output-utils/-/build-output-utils-1.0.0-rc.1.tgz", + "integrity": "sha512-IrzZL1UEdVMZPRarrKu2VpnL3MIeNVhCItTebB88SwQ1YJ4mLAe1kQtXmIH7MpdgDYnxAsTZXMtuw9q5jRWCcw==", + "license": "MIT", + "dependencies": { + "@cloudflare/config": "1.0.0-rc.1" + } + }, + "node_modules/@cloudflare/config": { + "version": "1.0.0-rc.1", + "resolved": "https://registry.npmjs.org/@cloudflare/config/-/config-1.0.0-rc.1.tgz", + "integrity": "sha512-NQgB+fQbk8IU0iJ6/G9LCSQjJ7JuyRn5CALrPKnQ8vxqayOJlX+av9adhLCMYBeC80ocncW1Gy7quv00uLV3LQ==", + "license": "MIT", + "dependencies": { + "zod": "4.6.6" + } + }, + "node_modules/@cloudflare/containers": { + "version": "0.3.7", + "resolved": "https://registry.npmjs.org/@cloudflare/containers/-/containers-0.3.7.tgz", + "integrity": "sha512-DM9dm3FnIBSyiSJ1FLavKwl/lk3oAmTaynCzZQ9pZR0ncRPquSxkxd8Nu2MFILxmDDsPkxKsSNEh9mHHMty4Fw==", + "license": "MIT OR Apache-2.0" + }, + "node_modules/@cloudflare/kv-asset-handler": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/@cloudflare/kv-asset-handler/-/kv-asset-handler-0.5.0.tgz", + "integrity": "sha512-jxQYkj8dSIzc0cD6cMMNdOc1UVjqSqu8BZdor5s8cGjW2I8BjODt/kWPVdY+u9zj3ms75Q5qaZgnxUad83+eAg==", + "license": "MIT OR Apache-2.0", + "engines": { + "node": ">=22.0.0" + } + }, + "node_modules/@cloudflare/runtime-types": { + "version": "0.1.30", + "resolved": "https://registry.npmjs.org/@cloudflare/runtime-types/-/runtime-types-0.1.30.tgz", + "integrity": "sha512-p68T70lDZT7Vyv5c2SDzB0uqVRVCtj/3WMgXVQESnWVyTybcCwXRM9Ekmh2rQ+aPGhtIWiACvd8pX2yGA9Z5mw==", + "license": "MIT", + "dependencies": { + "miniflare": "5.20261117.0-beta", + "workerd": "1.20261117.1" + } + }, + "node_modules/@cloudflare/unenv-preset": { + "version": "2.16.2", + "resolved": "https://registry.npmjs.org/@cloudflare/unenv-preset/-/unenv-preset-2.16.2.tgz", + "integrity": "sha512-JBP1+Z7ZSNG/d4mRP+y8VC5dka3tZVMLEZRvS+rzQ4DGV1EoxRFQckcJTTkXbHSQiTj0DtNI01Zwb/V2fX0mvQ==", + "license": "MIT OR Apache-2.0", + "peerDependencies": { + "unenv": "2.0.0-rc.24", + "workerd": ">1.20260305.0 <2.0.0-0" + }, + "peerDependenciesMeta": { + "workerd": { + "optional": true + } + } + }, + "node_modules/@cloudflare/workerd-darwin-64": { + "version": "1.20261117.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-64/-/workerd-darwin-64-1.20261117.1.tgz", + "integrity": "sha512-qfAYw6iPoey0BmPsp4z5ARWOa+XSBD3gQzmcBI2ql9pKTSA5eEC8F1oI6BIk/FVguhomfSn5gS4RzbWhTd/EpQ==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workerd-darwin-arm64": { + "version": "1.20261117.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-arm64/-/workerd-darwin-arm64-1.20261117.1.tgz", + "integrity": "sha512-cInx5Cr9O27oW+ujyI49lTRQZra/lMgWUFiKmGY3jxDncATSxzfQ6udXHkVvK4//1/PfxQTDyMjdQUIN8m6Aqg==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workerd-linux-64": { + "version": "1.20261117.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-64/-/workerd-linux-64-1.20261117.1.tgz", + "integrity": "sha512-gZLA8X11m/luZwn+YA3+mDu61vdxNJzpksP/QZqjydKTQ+VUCulsK5gtn9Bqst1p3KJu2kafQpJ1nDQv4B23jA==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workerd-linux-arm64": { + "version": "1.20261117.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-arm64/-/workerd-linux-arm64-1.20261117.1.tgz", + "integrity": "sha512-gxWngFojq41ULKNKb9rpWYvKotN5hT2I/xot+Bpy31cXzrwcTgtDLSMb2t75sW5BJxH7hihFvikgYb577kB3Zg==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workerd-windows-64": { + "version": "1.20261117.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-windows-64/-/workerd-windows-64-1.20261117.1.tgz", + "integrity": "sha512-0OR2Btx5EDonOKvvuGDq8rxBSggxoF1ThQjbZN3vsu3GlaF/oXW5f9/iB78OgV0CzMPTi+hZgzc1NR95UJCURA==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@emnapi/runtime": { + "version": "1.11.3", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.3.tgz", + "integrity": "sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==", + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.2.tgz", + "integrity": "sha512-XExcO+dvLKvVtNTibSTBej1NCAbaGhWn9Ww1ZPx80qsahhPFe/8jgWP0IchNe0F3HwkU7n8ejhH8bjonqht8mQ==", + "cpu": [ + "ppc64" + ], + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.28.2.tgz", + "integrity": "sha512-kXXoiPVVGQcnIYGOeaovwOURpniDBpSq4A03qkQ+BMQqtGG6HYap3xne9C1O1yo4TR3qxlCX5IqqmX6fFo2Lqg==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.28.2.tgz", + "integrity": "sha512-5YfKeeI8qWfBZIX+u2xZC3Zlb3Os/gLS2sbEKM+I4ZOcsWmHS2WLysCcQZDAFRslDUU5Oiq44gf6PYN1vGwG5A==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.28.2.tgz", + "integrity": "sha512-O387ite7SzUyCcy3JQX4P4bLtEA7bLLkx+esve5JHnyYfNTxcVpXZo9jhdB0lTKN44gztELTdU7nS8Nr16Fs1Q==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.28.2.tgz", + "integrity": "sha512-n4KqkOQrraxHJcgjM1RvwbigfQKIKJVpM7xp+KsxiyUSrRdIXnt73VhrPAx0fV44hgfmIVKjxMN9J1t5jySVkw==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.28.2.tgz", + "integrity": "sha512-uq6suIWYP37qzGddBKPw5QEQPi6HiLGsO7UmkpfyaYNQ3D+rN6w6WfwH+nuqcGXWvawGwxOEroO4YGnFh95azw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.28.2.tgz", + "integrity": "sha512-n+I0BTSRIoy+d6RPKnEVwql5UwBJolytvY4mAOIEJorKlqgPII8ix6slVVrfZ5Tnj7glIZvloylbB/EJPMWEXw==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.28.2.tgz", + "integrity": "sha512-78XJTJkvPs0kz2w61301PJjXl4g7q3JqiYMZ/M/yVI73EHBrCRTgkhu9oqG7vPqq+a/yadEW8aD+agKlk5xrmg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.28.2.tgz", + "integrity": "sha512-XlDnu2q5yoqems+xay6wSAcg9DDD7K9RLKZEBOMZm3ckNpJBvOX20tSfby8KfrrhINDyv9V2YVZKY/SpoGJI8w==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.28.2.tgz", + "integrity": "sha512-pW4AC0P3it8c7do9MVM4p51FzHzdM/TZrerurgRcHJ2WTa1VQ1CIq18xncfpBJw4ojkiZZrKW2yIBWBP92j6Ug==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.28.2.tgz", + "integrity": "sha512-CYbnj78HsIeA+DhgUKgFCfvNsTHFhMMrinUrMZpDXJXKN8T3XViTZ/+wtHeVxEWY8ewSzTFN+nRmSwO2tZaLUQ==", + "cpu": [ + "ia32" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.28.2.tgz", + "integrity": "sha512-buwkd8nsph4R+ajRvw0qM5Hja/TXQow3ptzWO2EbG/cqcIkHloRrdlBtQlshyYGTNFvfkfJ5tpPLVkY4DtsPfQ==", + "cpu": [ + "loong64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.28.2.tgz", + "integrity": "sha512-ZVykbDyk7519VwiNb9Lcj9m8XM6v5V9uKPvrEMkkEedVewf+0itkhahp4HDpgERXhwLRpWFypsGbG/J8s0QjJA==", + "cpu": [ + "mips64el" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.28.2.tgz", + "integrity": "sha512-CAXl+Dtd9UUuJd8pKKdwh6MLm3MUMiqMPmhZ3tTSXPqfyQ3vDl6R5hZdZ/kYojK4ofXtdfSv1tFq8XzWx3heNQ==", + "cpu": [ + "ppc64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.28.2.tgz", + "integrity": "sha512-GeXCej4IQtU1B+QlDV8W/RRvbzI3O/Stss+/bCXv4lZls5WGRtu2a+3JkA3i4qIUlMXpcHebWpF8AkJhATowuA==", + "cpu": [ + "riscv64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.28.2.tgz", + "integrity": "sha512-3H1weTYZPxt/WOhByszQZybS9w5lKzUn1FDMsgEChbHWQwHYQQRfBxgCcZvPhjHfKyJjIievvMmEUawJrdY9Dg==", + "cpu": [ + "s390x" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.28.2.tgz", + "integrity": "sha512-4xTZr1FUmSoQW4XIWmit3tzQrUTZM+N3P0XV8xROKYF50XfI7xeO90+1bZvNwxIufQ9hDQVRJH5YhgPVF8A/HQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.28.2.tgz", + "integrity": "sha512-sSATRjPeDBg3pdgHoQfoYBob11Kk1FGa9lui5RIHZCoCkJa9QKlvl3/vKz2usCmYYjs7ymJR/2Nnsqe+Hjt5nw==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.28.2.tgz", + "integrity": "sha512-lqnzCV+mM0gIADaKihiCg6ifgfU2L3h5E33rNQBN1Y4MaVGnzryzmvvf7UHxprpQdE8hpqLolJ9Rl+SkIRDpyw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.28.2.tgz", + "integrity": "sha512-AL2qJILH7lNjrDmCQDvdxMfAUIv8KMNZOvrwAQ8i8//ntL9FflhOyMJ8OZSMBb8/AWXe3/5v5S20y3zCoZWKoQ==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.28.2.tgz", + "integrity": "sha512-QtiuPytchRyC4rwUKhexJdQKvDuZ6hWloi3igqPQNUJCS1/v9EiO3UTOXR6A3FoMo4fnAKbWJdqaIwhOzh8qEw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.2.tgz", + "integrity": "sha512-WkhYDmpTjLvGlScA1rwjRUmhl4k8oXR3cIbtqWmELgU/dFeHHlEllxDvdWcNJV9rbzCexB5vz8gtNewWLgCT7Q==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.28.2.tgz", + "integrity": "sha512-GPMSkTOtMnv2U2F8gxe4Io6qmVs+YKyp832Etqqxr0hFngmXQ3rzwytelm3GIn7T4VviRUlf3sOgBOiTdvaf7g==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.28.2.tgz", + "integrity": "sha512-PIhhEkE9uPBleRBrQEJpUn7MBnibZzbGzYWPmY3x+YoVg/95zbjB4CxPPOQ8l5tYYM4mMaCthF8/1DIfBQQyWQ==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.28.2.tgz", + "integrity": "sha512-YmJbfTlvU7Sdn9BB+4PRES4oB6pxgS37MAONj+hBr/cpXS1aBPKXxNnDbu+QCWPj0o9dgyxeq79g6c5P8KeuYA==", + "cpu": [ + "ia32" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.28.2.tgz", + "integrity": "sha512-5ebpxr3nWMzrL/rnUI755Jkuee0bHL/Gq0WTF9lvcpv73wAp5eu8MfBUgWK9bhWvZjj7yX8etf/8tI8Ney695g==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@img/colour": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@img/colour/-/colour-1.1.0.tgz", + "integrity": "sha512-Td76q7j57o/tLVdgS746cYARfSyxk8iEfRxewL9h4OMzYhbW4TAcppl0mT4eyqXddh6L/jwoM75mo7ixa/pCeQ==", + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/@img/sharp-darwin-arm64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.35.5.tgz", + "integrity": "sha512-QRUlFQ0WxvdWyqqG/WtI3iupfD5rBzmCHXSdPsY91sAtVtTo7Q4cb6zOccZ3gqEqkr0f1As1ehLqmEpDsRf+lg==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-arm64": "1.3.4" + } + }, + "node_modules/@img/sharp-darwin-x64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.35.5.tgz", + "integrity": "sha512-+BR255RhDlpygUpOc/Jdt1nT6DQ3XG/ERo5wbcdOf5Q320dKtPCKPLR1LJs9VGXRaMa8l1uUa0tkCNOXiAxZUw==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-x64": "1.3.4" + } + }, + "node_modules/@img/sharp-freebsd-wasm32": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-freebsd-wasm32/-/sharp-freebsd-wasm32-0.35.5.tgz", + "integrity": "sha512-Y/z91nEZ4uIBX5X3nfTovjU9lHNKFYbL2lpHCLVNmXQK03VIZvXBBt0KxbPGp2SdGSF+2mQU4e+hQaWOt86iAw==", + "license": "Apache-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "dependencies": { + "@img/sharp-wasm32": "0.35.5" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-darwin-arm64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.3.4.tgz", + "integrity": "sha512-5R89nBYiRdUlSWJxPhO+GVtaXzXSxKnRu/xqMn3KTA3L9EB9Oy/P+Nn2f2vlhPuUdy/Zusb2DarbyTpGCfEDuw==", + "cpu": [ + "arm64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "darwin" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-darwin-x64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.3.4.tgz", + "integrity": "sha512-iR2OKH80yi0U+dUplyh3/xdpFvps6YkCwsXenIJxqxR1v9o+xtKTGbS9H7cps+2Vxjc8B1j96p75NmTGjIhtpQ==", + "cpu": [ + "x64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "darwin" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.3.4.tgz", + "integrity": "sha512-LmRtTsOHuvM2+wlO2Db37dx5MiZhB0FvSunciw48YjdOkZz9KAiRbm8ujeMOA1INqmei5NapFxYEK1D1ZSidmw==", + "cpu": [ + "arm" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.3.4.tgz", + "integrity": "sha512-Y3dgX/6lE2QhQb+Gxy0WZxfg9MEm/JBjamZpS2IklP7xIQoKN4hzAm7KcMVGtaVDt3neE9OKBC7vAfonA/Lr1A==", + "cpu": [ + "arm64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-ppc64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.3.4.tgz", + "integrity": "sha512-Le6boB8Tai0Nis+gIxIpKx68UDVVIqdR8Tin5Yf1z2LJJQLDJvCDRqRu+jC2qCoD+eIomonmOwB4smBRxfVpYQ==", + "cpu": [ + "ppc64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-riscv64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-riscv64/-/sharp-libvips-linux-riscv64-1.3.4.tgz", + "integrity": "sha512-aHkkIEHPRdQEegJN20MLmGtxYD9R2wQr3Cwpddnu5+YKMt6Uzax7S9h5gpZTo8wyrGuZSlfQ63OevL5mTyOC7Q==", + "cpu": [ + "riscv64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-s390x": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.3.4.tgz", + "integrity": "sha512-ra/mB6MikESDUO7Yg+Mi95bFBb9GsObURuhnOv3OqknjGe9sZrG8tCe9q0xSIGrtLgvgw0gKnFWcK4blSgQOuQ==", + "cpu": [ + "s390x" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-x64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.3.4.tgz", + "integrity": "sha512-GJ//SSXbnwSDes02umB3nDJLFcQzw8a18V8fyhqr6tV515tOEMdImjjxj1AoafMRz56F3PHgftnj1QEKSU1zkw==", + "cpu": [ + "x64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-arm64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.3.4.tgz", + "integrity": "sha512-hvulFwtjUcagsis6BBxHwGFwWoNZjgYmULGVrZcyfNbjA8hKILbRxGg15/7w5HDyXHXUos/j6baAWqnCyQ2DWA==", + "cpu": [ + "arm64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-x64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.3.4.tgz", + "integrity": "sha512-6zXKeE/p39I1AmA3cJG35eyBGNqNddLnUXjhwBnsGjFPWqf5VKkDBEqaEkPDoTEtkxwi2vv8Tcr2mDyP4So7Fg==", + "cpu": [ + "x64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-linux-arm": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.35.5.tgz", + "integrity": "sha512-LEaXK2WdXVK5ykcw0buWyPMsmLLL2vpHLD6yrNSW+JGEL3BZPA4tpKN6iaMc4AxTTAoaX/sU1rOL51lcIz48ZQ==", + "cpu": [ + "arm" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm": "1.3.4" + } + }, + "node_modules/@img/sharp-linux-arm64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.35.5.tgz", + "integrity": "sha512-LYVx5JTsOM2CBzmxreh+nl64/3H6Xb09iSLknqH47z2T2DFFxDeFLP5y4dJwe6H7uGQlHPyEEtIqyo3DYsRwdQ==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm64": "1.3.4" + } + }, + "node_modules/@img/sharp-linux-ppc64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-ppc64/-/sharp-linux-ppc64-0.35.5.tgz", + "integrity": "sha512-QVxAAq8evVRI9ia2vqgwrmWucn5Dfv+JdWzj75pD8omHLPSP7f8p20O8jxzjCcuCEQEOtYOZUmX1hkiZ0kdevA==", + "cpu": [ + "ppc64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-ppc64": "1.3.4" + } + }, + "node_modules/@img/sharp-linux-riscv64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-riscv64/-/sharp-linux-riscv64-0.35.5.tgz", + "integrity": "sha512-LtdreXguaavKODPIfzJ4kffx7UNt1omwtK0rch4EBbbSTXPnxWmYSayXdLJw0fJzQ97kHt1gL/yh4tvU+nCyRQ==", + "cpu": [ + "riscv64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-riscv64": "1.3.4" + } + }, + "node_modules/@img/sharp-linux-s390x": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.35.5.tgz", + "integrity": "sha512-UZasTOFiYzotTsGOCu42BfUzP6Tu6Do/947iRm1RsLKvlllxwGcn4RN27LibGWceix4Y+Pmw3jsnTcCQIgWjqA==", + "cpu": [ + "s390x" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-s390x": "1.3.4" + } + }, + "node_modules/@img/sharp-linux-x64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.35.5.tgz", + "integrity": "sha512-SxFtLTeJInhAA9Q836kux2vZNeOBQEx658qvbboZScr0wIARym3IcGmW7KpVD5sbVg0Ojy+udFQdayYIZyoNog==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-x64": "1.3.4" + } + }, + "node_modules/@img/sharp-linuxmusl-arm64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.35.5.tgz", + "integrity": "sha512-9HbMclmI1zlNkFRs3z9/eBtDjfD0sGlrX1z6b1qwmiFY5ElDLh4BC0LPBdVp7z1DXFiKlIcznf+ZlsuZzLxQqg==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-arm64": "1.3.4" + } + }, + "node_modules/@img/sharp-linuxmusl-x64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.35.5.tgz", + "integrity": "sha512-4KOphqB035HrVdqLZfCgMzzERrQkkzOwRhl4OAkRO1YCldbaFjySXMaK534Mo0V+LndnlJk+sbUyLeU0ULyD1A==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-x64": "1.3.4" + } + }, + "node_modules/@img/sharp-wasm32": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.35.5.tgz", + "integrity": "sha512-Ptsga1su4tQx+LLF1ECS9U6nz5kmrXKo6XVbtR48Ke3ZRxxgaWBu7IDtEe1quo8hiupwm6WFqxVlXaSf7IINGQ==", + "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT", + "optional": true, + "dependencies": { + "@emnapi/runtime": "^1.11.3" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-webcontainers-wasm32": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-webcontainers-wasm32/-/sharp-webcontainers-wasm32-0.35.5.tgz", + "integrity": "sha512-hfhF/FmoQyTUkA0bIKFOtw536BQSeBMe6BF6QyWlrPxT754+TFLaZ7sKKTfvvM0yJgKgaYTwnFCIZ/GuDw5SUA==", + "cpu": [ + "wasm32" + ], + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "@img/sharp-wasm32": "0.35.5" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-arm64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.35.5.tgz", + "integrity": "sha512-X4t7g+7ZA5DKblCBEXGjUqqemj4vczING/5viFwAL8h4N3qYeyjwdCvRLHi4EdOUI+2Z7UFlp1VM+p/AuEtm6Q==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-ia32": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.35.5.tgz", + "integrity": "sha512-5Zm82LoBc43nhwNybZlG7Y1KO//Zhsn306fQl29ZOuStHLGTo3BWL83q3cznX0poxSAMuYL1On/BHBxkBeKr6A==", + "cpu": [ + "ia32" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-x64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.35.5.tgz", + "integrity": "sha512-x76eH0vEiHlcMQu8Y8IenntaACtddpT6W0wmXtWrnKcnKI7ME5DdgqhAD6SEWOEl1v2zDvkZDhFA9KnURwpfqg==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.3.tgz", + "integrity": "sha512-lhTtjtoEArWBjismtfS761S9Hlyn+nIZqOZVYoZ1Xn82PMNMVnk+jj/NhC4fAXGTs7ydONcJiR5vyQBTMDu27g==", + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, + "node_modules/@poppinss/colors": { + "version": "4.1.6", + "resolved": "https://registry.npmjs.org/@poppinss/colors/-/colors-4.1.6.tgz", + "integrity": "sha512-H9xkIdFswbS8n1d6vmRd8+c10t2Qe+rZITbbDHHkQixH5+2x1FDGmi/0K+WgWiqQFKPSlIYB7jlH6Kpfn6Fleg==", + "license": "MIT", + "dependencies": { + "kleur": "^4.1.5" + } + }, + "node_modules/@poppinss/dumper": { + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/@poppinss/dumper/-/dumper-0.6.5.tgz", + "integrity": "sha512-NBdYIb90J7LfOI32dOewKI1r7wnkiH6m920puQ3qHUeZkxNkQiFnXVWoE6YtFSv6QOiPPf7ys6i+HWWecDz7sw==", + "license": "MIT", + "dependencies": { + "@poppinss/colors": "^4.1.5", + "@sindresorhus/is": "^7.0.2", + "supports-color": "^10.0.0" + } + }, + "node_modules/@poppinss/exception": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@poppinss/exception/-/exception-1.2.3.tgz", + "integrity": "sha512-dCED+QRChTVatE9ibtoaxc+WkdzOSjYTKi/+uacHWIsfodVfpsueo3+DKpgU5Px8qXjgmXkSvhXvSCz3fnP9lw==", + "license": "MIT" + }, + "node_modules/@sindresorhus/is": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-7.2.0.tgz", + "integrity": "sha512-P1Cz1dWaFfR4IR+U13mqqiGsLFf1KbayybWwdd2vfctdV6hDpUkgCY0nKOLLTMSoRd/jJNjtbqzf13K8DCCXQw==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sindresorhus/is?sponsor=1" + } + }, + "node_modules/@speed-highlight/core": { + "version": "1.2.24", + "resolved": "https://registry.npmjs.org/@speed-highlight/core/-/core-1.2.24.tgz", + "integrity": "sha512-qeW2e1l78afw8VhRPfPQ1Gjj+KU5XFQ/OFV5ti6eTa9bruO7mJyZtA4vw0ofqmA3tKCkROE9xLk3VZoeRc98nw==", + "license": "CC0-1.0" + }, + "node_modules/blake3-wasm": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/blake3-wasm/-/blake3-wasm-2.1.5.tgz", + "integrity": "sha512-F1+K8EbfOZE49dtoPtmxUQrpXaBIl3ICvasLh+nJta0xkz+9kF/7uet9fLnwKqhDrmj6g+6K3Tw9yQPUg2ka5g==", + "license": "MIT" + }, + "node_modules/cf": { + "version": "1.0.0-rc.1", + "resolved": "https://registry.npmjs.org/cf/-/cf-1.0.0-rc.1.tgz", + "integrity": "sha512-mQ9X/FVE1QP2ebXVF/9tlbqoO0TB3tKxUJocaWsic6IuNvThmJc/Ou/4ABJNB/Sj8HxEzvrjT1PRqjySVO5YoA==", + "license": "MIT OR Apache-2.0", + "dependencies": { + "@cloudflare/build-output-utils": "1.0.0-rc.1", + "@cloudflare/config": "1.0.0-rc.1", + "@cloudflare/runtime-types": "0.1.30", + "blake3-wasm": "2.1.5", + "miniflare": "5.20261117.0-beta" + }, + "bin": { + "cf": "bin/cf", + "cloudflare": "bin/cf" + }, + "engines": { + "node": "^22.23.0 || ^24.22.0 || ^26.12.0" + } + }, + "node_modules/cookie": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-1.1.1.tgz", + "integrity": "sha512-ei8Aos7ja0weRpFzJnEA9UHJ/7XQmqglbRwnf2ATjcB9Wq874VKH9kfjjirM6UhU2/E5fFYadylyhFldcqSidQ==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/detect-libc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", + "license": "Apache-2.0", + "engines": { + "node": ">=8" + } + }, + "node_modules/error-stack-parser-es": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/error-stack-parser-es/-/error-stack-parser-es-1.0.5.tgz", + "integrity": "sha512-5qucVt2XcuGMcEGgWI7i+yZpmpByQ8J1lHhcL7PwqCwu9FPP3VUXzT4ltHe5i2z9dePwEHcDVOAfSnHsOlCXRA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/esbuild": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.2.tgz", + "integrity": "sha512-HKVLS8dvII+xoKW9kmqxbRKrnWEXfJJr/FZhhJmiqIB0e053QNYFqOBouTMO/k5sID4MvCiUCvv8b9M4h32wIA==", + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.28.2", + "@esbuild/android-arm": "0.28.2", + "@esbuild/android-arm64": "0.28.2", + "@esbuild/android-x64": "0.28.2", + "@esbuild/darwin-arm64": "0.28.2", + "@esbuild/darwin-x64": "0.28.2", + "@esbuild/freebsd-arm64": "0.28.2", + "@esbuild/freebsd-x64": "0.28.2", + "@esbuild/linux-arm": "0.28.2", + "@esbuild/linux-arm64": "0.28.2", + "@esbuild/linux-ia32": "0.28.2", + "@esbuild/linux-loong64": "0.28.2", + "@esbuild/linux-mips64el": "0.28.2", + "@esbuild/linux-ppc64": "0.28.2", + "@esbuild/linux-riscv64": "0.28.2", + "@esbuild/linux-s390x": "0.28.2", + "@esbuild/linux-x64": "0.28.2", + "@esbuild/netbsd-arm64": "0.28.2", + "@esbuild/netbsd-x64": "0.28.2", + "@esbuild/openbsd-arm64": "0.28.2", + "@esbuild/openbsd-x64": "0.28.2", + "@esbuild/openharmony-arm64": "0.28.2", + "@esbuild/sunos-x64": "0.28.2", + "@esbuild/win32-arm64": "0.28.2", + "@esbuild/win32-ia32": "0.28.2", + "@esbuild/win32-x64": "0.28.2" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/kleur": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz", + "integrity": "sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/miniflare": { + "version": "5.20261117.0-beta", + "resolved": "https://registry.npmjs.org/miniflare/-/miniflare-5.20261117.0-beta.tgz", + "integrity": "sha512-D2ygY04wQUmbpwgBhj828piErZoj7UMlXNGr4EWQp/c1PNGHyYOh0dMIyobjwOXiD5Ifl1EaEVAoNuBHK+qtkw==", + "license": "MIT", + "dependencies": { + "@cspotcode/source-map-support": "0.8.1", + "sharp": "0.35.5", + "undici": "7.30.1", + "workerd": "1.20261117.1", + "ws": "8.21.0", + "youch": "4.1.0-beta.10" + }, + "engines": { + "node": ">=22.12.0" + }, + "peerDependencies": { + "kerberos": "^2.0.0" + }, + "peerDependenciesMeta": { + "kerberos": { + "optional": true + } + } + }, + "node_modules/path-to-regexp": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.3.0.tgz", + "integrity": "sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==", + "license": "MIT" + }, + "node_modules/pathe": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", + "integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==", + "license": "MIT" + }, + "node_modules/semver": { + "version": "7.8.6", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.6.tgz", + "integrity": "sha512-9lpSSU4Mly3mrtruwLs1eLK6+gzbzqeBFwRNjIjE+9LuDpWdYctrQlQ3ej1Ilgi7gknpsTRnPoLP8DpCHqHIJw==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/sharp": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.35.5.tgz", + "integrity": "sha512-Ywn4OnzGukp7CDMrp08RQ50YKmuwG47brZgIVPTvBaaAfQlRlygrRqSrxdCiL9M+LlzLBiJ68IR1QqvzHyjC7g==", + "license": "Apache-2.0", + "dependencies": { + "@img/colour": "^1.1.0", + "detect-libc": "^2.1.2", + "semver": "^7.8.5" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-darwin-arm64": "0.35.5", + "@img/sharp-darwin-x64": "0.35.5", + "@img/sharp-freebsd-wasm32": "0.35.5", + "@img/sharp-libvips-darwin-arm64": "1.3.4", + "@img/sharp-libvips-darwin-x64": "1.3.4", + "@img/sharp-libvips-linux-arm": "1.3.4", + "@img/sharp-libvips-linux-arm64": "1.3.4", + "@img/sharp-libvips-linux-ppc64": "1.3.4", + "@img/sharp-libvips-linux-riscv64": "1.3.4", + "@img/sharp-libvips-linux-s390x": "1.3.4", + "@img/sharp-libvips-linux-x64": "1.3.4", + "@img/sharp-libvips-linuxmusl-arm64": "1.3.4", + "@img/sharp-libvips-linuxmusl-x64": "1.3.4", + "@img/sharp-linux-arm": "0.35.5", + "@img/sharp-linux-arm64": "0.35.5", + "@img/sharp-linux-ppc64": "0.35.5", + "@img/sharp-linux-riscv64": "0.35.5", + "@img/sharp-linux-s390x": "0.35.5", + "@img/sharp-linux-x64": "0.35.5", + "@img/sharp-linuxmusl-arm64": "0.35.5", + "@img/sharp-linuxmusl-x64": "0.35.5", + "@img/sharp-webcontainers-wasm32": "0.35.5", + "@img/sharp-win32-arm64": "0.35.5", + "@img/sharp-win32-ia32": "0.35.5", + "@img/sharp-win32-x64": "0.35.5" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } + } + }, + "node_modules/supports-color": { + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-10.2.2.tgz", + "integrity": "sha512-SS+jx45GF1QjgEXQx4NJZV9ImqmO2NPz5FNsIHrsDjh2YsHnawpan7SNQ1o8NuhrbHZy9AZhIoCUiCeaW/C80g==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/tslib": { + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.9.1.tgz", + "integrity": "sha512-a4Ux9VKuIMHsOS7ENbEq6hK2ZGYIT27Rtl0E4eD9KqwxhKiQeMZE/9xb3IdYwWaSOyIBQLExhQgXDTYoiCxnWA==", + "license": "0BSD", + "optional": true + }, + "node_modules/undici": { + "version": "7.30.1", + "resolved": "https://registry.npmjs.org/undici/-/undici-7.30.1.tgz", + "integrity": "sha512-03KrMbjIFDWQR5RNPrSw3bd1r12JpyFQl9/yxjUbJtqkjmllqC5lFjZh6ujeuJCKr8EOQvRW872Oy/az+nLYxg==", + "license": "MIT", + "engines": { + "node": ">=20.18.1" + } + }, + "node_modules/unenv": { + "version": "2.0.0-rc.24", + "resolved": "https://registry.npmjs.org/unenv/-/unenv-2.0.0-rc.24.tgz", + "integrity": "sha512-i7qRCmY42zmCwnYlh9H2SvLEypEFGye5iRmEMKjcGi7zk9UquigRjFtTLz0TYqr0ZGLZhaMHl/foy1bZR+Cwlw==", + "license": "MIT", + "dependencies": { + "pathe": "^2.0.3" + } + }, + "node_modules/workerd": { + "version": "1.20261117.1", + "resolved": "https://registry.npmjs.org/workerd/-/workerd-1.20261117.1.tgz", + "integrity": "sha512-iakDbGVtJRiErpWSM5fYT0z3spJ2Mo1x/POsEajBNLqUbTRwm8vMqbB7g8zPN2tzs6eZYNiO5ECyEnAXO9Foxw==", + "hasInstallScript": true, + "license": "Apache-2.0", + "bin": { + "workerd": "bin/workerd" + }, + "engines": { + "node": ">=16" + }, + "optionalDependencies": { + "@cloudflare/workerd-darwin-64": "1.20261117.1", + "@cloudflare/workerd-darwin-arm64": "1.20261117.1", + "@cloudflare/workerd-linux-64": "1.20261117.1", + "@cloudflare/workerd-linux-arm64": "1.20261117.1", + "@cloudflare/workerd-windows-64": "1.20261117.1" + } + }, + "node_modules/wrangler": { + "version": "4.163.0", + "resolved": "https://registry.npmjs.org/wrangler/-/wrangler-4.163.0.tgz", + "integrity": "sha512-EBM/QOpQsce6LenEDv1nXsK+AX9BYfAhE5yHosriPhFZPj47Z0usk6oGYWgPpLPa5qYDzhm9EDzaDD/WI5lzOA==", + "license": "MIT OR Apache-2.0", + "dependencies": { + "@cloudflare/kv-asset-handler": "0.5.0", + "@cloudflare/unenv-preset": "2.16.2", + "@cspotcode/source-map-support": "0.8.1", + "blake3-wasm": "2.1.5", + "esbuild": "0.28.2", + "miniflare": "5.20261116.0-beta", + "path-to-regexp": "6.3.0", + "unenv": "2.0.0-rc.24", + "workerd": "1.20261116.1" + }, + "bin": { + "cf-wrangler": "bin/cf-wrangler.js", + "wrangler": "bin/wrangler.js", + "wrangler2": "bin/wrangler.js" + }, + "engines": { + "node": ">=22.12.0" + }, + "optionalDependencies": { + "fsevents": "2.3.3" + }, + "peerDependencies": { + "@cloudflare/workers-types": "^5.20261116.1" + }, + "peerDependenciesMeta": { + "@cloudflare/workers-types": { + "optional": true + } + } + }, + "node_modules/wrangler/node_modules/@cloudflare/workerd-darwin-64": { + "version": "1.20261116.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-64/-/workerd-darwin-64-1.20261116.1.tgz", + "integrity": "sha512-+zzaR7CQXcT10Tbor784vI80+rO0NEy/jkTL7ZJP6PYmwjdDj2udk+sN9Ui1nqDs+frYYUtB+7nI7kycONFb0Q==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/wrangler/node_modules/@cloudflare/workerd-darwin-arm64": { + "version": "1.20261116.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-arm64/-/workerd-darwin-arm64-1.20261116.1.tgz", + "integrity": "sha512-jOZBuQL3FdFC9FcVzfSDEWu1/jx3/asrQAU7TydMop8kdZWhqT4dslE3rC6cMait6w32XaglzEtV6OM1Ove9ZA==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/wrangler/node_modules/@cloudflare/workerd-linux-64": { + "version": "1.20261116.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-64/-/workerd-linux-64-1.20261116.1.tgz", + "integrity": "sha512-/HnEV29Ykg3t9X6llrnlOJ9+N+cXFNsuPTTdRiE1L/hXIkI39o1RZVjEgj3GtyWtpuhsJ1mNLrNshrEjCvzk0w==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/wrangler/node_modules/@cloudflare/workerd-linux-arm64": { + "version": "1.20261116.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-arm64/-/workerd-linux-arm64-1.20261116.1.tgz", + "integrity": "sha512-hH73ERVfyoQ19DzbjPv/Gp4klU6F7gpx99JIlkmelC3vfsXPpsJdJsNAJA8LIxILa+gfH7tfxSSciCzr+0vqOQ==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/wrangler/node_modules/@cloudflare/workerd-windows-64": { + "version": "1.20261116.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-windows-64/-/workerd-windows-64-1.20261116.1.tgz", + "integrity": "sha512-eUxFymDyGt3jYjE3/OsNZlSYM5jjCKx8h4nlGRdljtK1fRUT+llI8COE/1gaqMppS6x8qN6tc8vcyRXT4pxqxw==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/wrangler/node_modules/miniflare": { + "version": "5.20261116.0-beta", + "resolved": "https://registry.npmjs.org/miniflare/-/miniflare-5.20261116.0-beta.tgz", + "integrity": "sha512-vQozfXz0eh4VlXJPsn/sxV3siRHmhl5kghZplFsTAt7+8gSPmjbZkYQEA4VudmcN9HTbI8pOqPynckIaIenwPg==", + "license": "MIT", + "dependencies": { + "@cspotcode/source-map-support": "0.8.1", + "sharp": "0.35.5", + "undici": "7.30.1", + "workerd": "1.20261116.1", + "ws": "8.21.0", + "youch": "4.1.0-beta.10" + }, + "engines": { + "node": ">=22.12.0" + }, + "peerDependencies": { + "kerberos": "^2.0.0" + }, + "peerDependenciesMeta": { + "kerberos": { + "optional": true + } + } + }, + "node_modules/wrangler/node_modules/workerd": { + "version": "1.20261116.1", + "resolved": "https://registry.npmjs.org/workerd/-/workerd-1.20261116.1.tgz", + "integrity": "sha512-w3uPBuALjYs4n/p6x5SodorOe5y1bsBZ3RYeH1g0W5l73vT+yPGI7/WtxfzXbxZqpeCZ0/RfEwgD8Pc43uzu+w==", + "hasInstallScript": true, + "license": "Apache-2.0", + "bin": { + "workerd": "bin/workerd" + }, + "engines": { + "node": ">=16" + }, + "optionalDependencies": { + "@cloudflare/workerd-darwin-64": "1.20261116.1", + "@cloudflare/workerd-darwin-arm64": "1.20261116.1", + "@cloudflare/workerd-linux-64": "1.20261116.1", + "@cloudflare/workerd-linux-arm64": "1.20261116.1", + "@cloudflare/workerd-windows-64": "1.20261116.1" + } + }, + "node_modules/ws": { + "version": "8.21.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.21.0.tgz", + "integrity": "sha512-Vsp28b7DRcimFQvrqu2Wek3z1iYxDCWqHYB8Qsnk/S4RfaCQzPGPyBNuVjJV3cd6UiKtUtp6sNM77gWvzcCH+g==", + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/youch": { + "version": "4.1.0-beta.10", + "resolved": "https://registry.npmjs.org/youch/-/youch-4.1.0-beta.10.tgz", + "integrity": "sha512-rLfVLB4FgQneDr0dv1oddCVZmKjcJ6yX6mS4pU82Mq/Dt9a3cLZQ62pDBL4AUO+uVrCvtWz3ZFUL2HFAFJ/BXQ==", + "license": "MIT", + "dependencies": { + "@poppinss/colors": "^4.1.5", + "@poppinss/dumper": "^0.6.4", + "@speed-highlight/core": "^1.2.7", + "cookie": "^1.0.2", + "youch-core": "^0.3.3" + } + }, + "node_modules/youch-core": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/youch-core/-/youch-core-0.3.3.tgz", + "integrity": "sha512-ho7XuGjLaJ2hWHoK8yFnsUGy2Y5uDpqSTq1FkHLK4/oqKtyUU1AFbOOxY4IpC9f0fTLjwYbslUz0Po5BpD1wrA==", + "license": "MIT", + "dependencies": { + "@poppinss/exception": "^1.2.2", + "error-stack-parser-es": "^1.0.5" + } + }, + "node_modules/zod": { + "version": "4.6.6", + "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.6.tgz", + "integrity": "sha512-4UmzQUF5fxvfcYHlbjBmejU+w+hbDnWFx4aS8kBx7nPBHcO2SqPbpAG8snbdg+Xse4pRefR98hgjFgIMCI/UhA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } + } + } +} diff --git a/pkgs/lab-ops-hub/release-tools/package.json b/pkgs/lab-ops-hub/release-tools/package.json new file mode 100644 index 0000000000..111ebc8497 --- /dev/null +++ b/pkgs/lab-ops-hub/release-tools/package.json @@ -0,0 +1,13 @@ +{ + "name": "lab-ops-hub-release-tools", + "private": true, + "type": "module", + "engines": { + "node": "24.22.x" + }, + "dependencies": { + "@cloudflare/containers": "0.3.7", + "cf": "1.0.0-rc.1", + "wrangler": "4.163.0" + } +} diff --git a/pkgs/lab-ops-hub/release-tools/verify-build.mjs b/pkgs/lab-ops-hub/release-tools/verify-build.mjs new file mode 100644 index 0000000000..5ea34ccf78 --- /dev/null +++ b/pkgs/lab-ops-hub/release-tools/verify-build.mjs @@ -0,0 +1,121 @@ +import assert from "node:assert/strict"; +import { existsSync, readFileSync, readdirSync } from "node:fs"; +import { dirname, join } from "node:path"; +import { fileURLToPath } from "node:url"; + +const packageDir = dirname(dirname(fileURLToPath(import.meta.url))); +const readJsonc = (path) => + JSON.parse(readFileSync(join(packageDir, path), "utf8").replace(/^\s*\/\/.*$/gm, "")); +const wrangler = readJsonc("wrangler.jsonc"); +const outputPath = join(packageDir, ".cloudflare/output/v1/workers/default/worker.config.json"); +assert.ok(existsSync(outputPath), "cf build must produce the v1 default Worker config"); +const output = JSON.parse(readFileSync(outputPath, "utf8")); + +assert.equal(wrangler.name, "lab-ops-hub"); +assert.equal(wrangler.main, "src/index.ts"); +assert.equal(wrangler.routes, undefined); +assert.equal(wrangler.workers_dev, undefined); +assert.deepEqual(wrangler.assets, { + directory: "./public", + binding: "ASSETS", + run_worker_first: ["/api/*"], +}); +assert.equal(output.name, wrangler.name); +assert.equal(output.compatibilityDate, wrangler.compatibility_date); +assert.deepEqual(output.compatibilityFlags, wrangler.compatibility_flags); +assert.deepEqual(output.observability, wrangler.observability); +assert.deepEqual(output.assets, { runWorkerFirst: wrangler.assets.run_worker_first }); +assert.equal(output.manifest.type, "complete"); +assert.equal(output.manifest.mainModule, "index.js"); +assert.equal(output.routes, undefined); +assert.equal(output.workersDev, undefined); +const filesUnder = (directory, prefix = "") => + readdirSync(directory, { withFileTypes: true }).flatMap((entry) => { + const relative = join(prefix, entry.name); + return entry.isDirectory() + ? filesUnder(join(directory, entry.name), relative) + : [relative]; + }).sort(); +assert.deepEqual( + filesUnder(join(packageDir, "public")), + filesUnder(join(packageDir, ".cloudflare/output/v1/workers/default/assets")), + "all public assets must be carried into Build Output", +); +assert.match(readFileSync(join(packageDir, "wrangler.config.ts"), "utf8"), /assetsDirectory:\s*"\.\/public"/); + +assert.deepEqual(wrangler.migrations, [ + { tag: "v1", new_sqlite_classes: ["LiveRoom", "CrawlerContainer"] }, + { tag: "v2", new_sqlite_classes: ["CrawlerContainerV2"] }, +]); +assert.deepEqual(wrangler.durable_objects.bindings, [ + { name: "LIVE", class_name: "LiveRoom" }, + { name: "CRAWLER", class_name: "CrawlerContainerV2" }, +]); +assert.deepEqual(wrangler.d1_databases, [ + { binding: "DB", database_name: "labops-db", database_id: "3115e67f-150e-4ee8-8b11-216127901ae8" }, +]); +assert.deepEqual(wrangler.r2_buckets, [{ binding: "FILES", bucket_name: "labops-files" }]); +assert.deepEqual(wrangler.kv_namespaces, [{ binding: "CACHE", id: "ac69d54d9e3f455d99a940b3fced4b76" }]); +assert.deepEqual(wrangler.queues, { + producers: [{ binding: "JOBS", queue: "labops-jobs" }], + consumers: [{ queue: "labops-jobs", max_batch_size: 10, max_retries: 3 }], +}); +assert.deepEqual(wrangler.ai, { binding: "AI" }); +assert.deepEqual(wrangler.triggers, { crons: ["23 4 * * *"] }); +assert.deepEqual(output.env.LIVE, { + type: "durable-object", + worker: wrangler.name, + exportName: "LiveRoom", +}); +assert.deepEqual(output.env.CRAWLER, { + type: "durable-object", + worker: wrangler.name, + exportName: "CrawlerContainerV2", +}); + +const d1 = wrangler.d1_databases[0]; +assert.deepEqual(output.env.DB, { type: "d1", name: d1.database_name, id: d1.database_id }); +const r2 = wrangler.r2_buckets[0]; +assert.deepEqual(output.env.FILES, { type: "r2", name: r2.bucket_name }); +const kv = wrangler.kv_namespaces[0]; +assert.deepEqual(output.env.CACHE, { type: "kv", id: kv.id }); +const producer = wrangler.queues.producers[0]; +assert.deepEqual(output.env.JOBS, { type: "queue", name: producer.queue }); +assert.deepEqual(output.env.AI, { type: "ai" }); +assert.deepEqual(output.env.ASSETS, { type: "assets" }); + +const consumer = wrangler.queues.consumers[0]; +assert.deepEqual(output.triggers, [ + { type: "scheduled", schedule: wrangler.triggers.crons[0] }, + { + type: "queue", + name: consumer.queue, + maxBatchSize: consumer.max_batch_size, + maxRetries: consumer.max_retries, + }, +]); + +assert.deepEqual(output.env, { + DB: { type: "d1", name: "labops-db", id: "3115e67f-150e-4ee8-8b11-216127901ae8" }, + FILES: { type: "r2", name: "labops-files" }, + CACHE: { type: "kv", id: "ac69d54d9e3f455d99a940b3fced4b76" }, + JOBS: { type: "queue", name: "labops-jobs" }, + LIVE: { type: "durable-object", worker: "lab-ops-hub", exportName: "LiveRoom" }, + CRAWLER: { type: "durable-object", worker: "lab-ops-hub", exportName: "CrawlerContainerV2" }, + AI: { type: "ai" }, + ASSETS: { type: "assets" }, +}); + +const container = wrangler.containers[0]; +assert.equal(container.class_name, "CrawlerContainerV2"); +assert.equal(container.image, "registry.cloudflare.com/234b866b99ce2b142d7963d8d139cbfa/lab-ops-hub-crawlercontainer:v5"); +assert.match(readFileSync(join(packageDir, "container-image.nix"), "utf8"), /tag\s*=\s*"v5";/); +assert.match(readFileSync(join(packageDir, "image-push.mjs"), "utf8"), /const IMAGE = "lab-ops-hub-crawlercontainer:v5";/); +assert.deepEqual(output.unsafe.metadata.containers, [container]); + +const releaseTools = JSON.parse(readFileSync(join(packageDir, "release-tools/package.json"), "utf8")); +assert.equal(releaseTools.dependencies.cf, "1.0.0-rc.1"); +assert.equal(releaseTools.dependencies.wrangler, "4.163.0"); +assert.equal(releaseTools.engines.node, "24.22.x"); + +console.log("Lab Ops Hub Build Output v1 matches Wrangler target, bindings, migrations, triggers, assets, and pinned container image"); diff --git a/pkgs/lab-ops-hub/wrangler.config.ts b/pkgs/lab-ops-hub/wrangler.config.ts new file mode 100644 index 0000000000..bcaef18655 --- /dev/null +++ b/pkgs/lab-ops-hub/wrangler.config.ts @@ -0,0 +1,5 @@ +import { defineWranglerConfig } from "wrangler/experimental-config"; + +export default defineWranglerConfig({ + assetsDirectory: "./public", +}); From 0728f307cc8d5339ba945ccc64a234493adb3857 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Sun, 22 Nov 2026 14:55:13 +0000 Subject: [PATCH 2/2] fix(lab-ops-hub): bind promotion to trusted upload receipt --- .github/workflows/lab-ops-hub-promote.yml | 135 ++++++--- .../workflows/lab-ops-hub-worker-release.yml | 99 +++--- lib/default.nix | 5 + pkgs/lab-ops-hub/README.md | 70 +++-- pkgs/lab-ops-hub/deploy.mjs | 158 ++++++++++ pkgs/lab-ops-hub/deploy.nix | 34 +++ pkgs/lab-ops-hub/deploy.sh | 14 + .../release-tools/release-safety.mjs | 283 ++++++++++++++++++ .../release-tools/release-safety.test.mjs | 161 ++++++++++ 9 files changed, 867 insertions(+), 92 deletions(-) create mode 100644 pkgs/lab-ops-hub/deploy.mjs create mode 100644 pkgs/lab-ops-hub/deploy.nix create mode 100755 pkgs/lab-ops-hub/deploy.sh create mode 100644 pkgs/lab-ops-hub/release-tools/release-safety.mjs create mode 100644 pkgs/lab-ops-hub/release-tools/release-safety.test.mjs diff --git a/.github/workflows/lab-ops-hub-promote.yml b/.github/workflows/lab-ops-hub-promote.yml index 07b72d8713..c3f3ea3e35 100644 --- a/.github/workflows/lab-ops-hub-promote.yml +++ b/.github/workflows/lab-ops-hub-promote.yml @@ -1,75 +1,138 @@ -name: Lab Ops Hub Worker promotion +name: Lab Ops Hub Worker Version promotion on: workflow_dispatch: inputs: - version_id: - description: "Exact Worker Version UUID printed by the upload workflow" + upload_run_id: + description: "Successful trusted upload workflow run ID containing the Worker Version receipt" required: true type: string - confirm_promotion: - description: "Confirm promotion of this exact version to 100% of traffic" - required: true - default: false - type: boolean permissions: + actions: read contents: read concurrency: - group: lab-ops-hub-worker-promotion + group: lab-ops-hub-cloudflare-release cancel-in-progress: false jobs: promote: - if: github.ref == 'refs/heads/main' + if: github.repository == 'developing-today/code' && github.ref == 'refs/heads/main' runs-on: ubuntu-24.04 - timeout-minutes: 10 - env: - CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }} - VERSION_ID: ${{ inputs.version_id }} + timeout-minutes: 20 + environment: lab-ops-hub-cloudflare-release steps: - - name: Keep promotion held until explicitly confirmed - if: ${{ !inputs.confirm_promotion }} - run: echo "::notice::Promotion held. Review the uploaded version UUID, then dispatch again with confirmation." + - name: Validate upload run ID + env: + UPLOAD_RUN_ID: ${{ inputs.upload_run_id }} + run: | + set -euo pipefail + [[ "$UPLOAD_RUN_ID" =~ ^[1-9][0-9]{0,19}$ ]] || { + echo "::error::upload_run_id must be a numeric GitHub Actions run ID, not a Worker Version UUID" + exit 2 + } - - name: Checkout - if: ${{ inputs.confirm_promotion }} + - name: Checkout the dispatched main commit for trusted receipt validation uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + with: + ref: ${{ github.sha }} - name: Set up Node 24.22.0 - if: ${{ inputs.confirm_promotion }} uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 with: node-version: 24.22.0 + - name: Download the receipt from the selected upload run + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8 + with: + name: lab-ops-hub-version-receipt + run-id: ${{ inputs.upload_run_id }} + github-token: ${{ github.token }} + path: ${{ runner.temp }}/loh-receipt + + - name: Verify the exact successful trusted upload run + id: receipt + env: + GH_TOKEN: ${{ github.token }} + UPLOAD_RUN_ID: ${{ inputs.upload_run_id }} + run: | + set -euo pipefail + gh api "repos/$GITHUB_REPOSITORY/actions/runs/$UPLOAD_RUN_ID" > "$RUNNER_TEMP/loh-upload-run.json" + node pkgs/lab-ops-hub/release-tools/release-safety.mjs trust-receipt \ + "$RUNNER_TEMP/loh-receipt/receipt.json" \ + "$RUNNER_TEMP/loh-upload-run.json" >> "$GITHUB_OUTPUT" + + - name: Checkout the exact uploaded source commit + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + with: + ref: ${{ steps.receipt.outputs.source_sha }} + - name: Install pinned cf and Wrangler toolchain - if: ${{ inputs.confirm_promotion }} working-directory: pkgs/lab-ops-hub run: | - npm ci --prefix release-tools + npm ci --prefix release-tools --no-audit --no-fund + test ! -e node_modules ln -s release-tools/node_modules node_modules + node -e 'const p=require("./release-tools/package-lock.json"); if(p.packages["node_modules/cf"].version!=="1.0.0-rc.1" || p.packages["node_modules/wrangler"].version!=="4.163.0") process.exit(1)' + test "$(./node_modules/.bin/cf --version)" = "1.0.0-rc.1" - - name: Validate exact version UUID - if: ${{ inputs.confirm_promotion }} + - name: Rebuild the uploaded source and verify configuration parity working-directory: pkgs/lab-ops-hub run: | - node --input-type=module <<'NODE' - import { writeFileSync } from "node:fs"; - const id = process.env.VERSION_ID; - if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(id ?? "")) { - throw new Error("version_id must be a UUID printed by the upload workflow"); - } - writeFileSync("versions.json", JSON.stringify([{ version_id: id, percentage: 100 }])); - NODE + ./node_modules/.bin/cf build + node release-tools/verify-build.mjs + node --test release-tools/release-safety.test.mjs - - name: Promote the selected version to 100% - if: ${{ inputs.confirm_promotion }} + - name: Verify receipt baseline, v2 metadata, and exact image pin working-directory: pkgs/lab-ops-hub env: - CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_LAB_OPS_HUB_ACCOUNT_ID }} + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_LAB_OPS_HUB_API_TOKEN }} + BASELINE_VERSION_ID: ${{ steps.receipt.outputs.baseline_version_id }} + VERSION_ID: ${{ steps.receipt.outputs.version_id }} + VERSION_TAG: ${{ steps.receipt.outputs.version_tag }} + run: | + set -euo pipefail + test -n "$CLOUDFLARE_ACCOUNT_ID" || { echo "::error::missing environment variable CLOUDFLARE_LAB_OPS_HUB_ACCOUNT_ID"; exit 1; } + test -n "$CLOUDFLARE_API_TOKEN" || { echo "::error::missing protected environment secret CLOUDFLARE_LAB_OPS_HUB_API_TOKEN"; exit 1; } + ./node_modules/.bin/cf workers deployments list --worker lab-ops-hub > "$RUNNER_TEMP/loh-current-deployments.json" + node release-tools/release-safety.mjs verify-current "$RUNNER_TEMP/loh-current-deployments.json" "$BASELINE_VERSION_ID" + ./node_modules/.bin/cf workers versions get "$BASELINE_VERSION_ID" --worker lab-ops-hub > "$RUNNER_TEMP/loh-baseline-version.json" + node release-tools/release-safety.mjs verify-version "$RUNNER_TEMP/loh-baseline-version.json" "$BASELINE_VERSION_ID" + ./node_modules/.bin/cf workers versions get "$VERSION_ID" --worker lab-ops-hub > "$RUNNER_TEMP/loh-version.json" + node release-tools/release-safety.mjs verify-version "$RUNNER_TEMP/loh-version.json" "$VERSION_ID" "$VERSION_TAG" + node release-tools/release-safety.mjs deployment-versions "$RUNNER_TEMP/loh-receipt/receipt.json" "$RUNNER_TEMP/loh-versions.json" + + - name: Recheck the serving baseline immediately before promotion + working-directory: pkgs/lab-ops-hub + env: + CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_LAB_OPS_HUB_ACCOUNT_ID }} + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_LAB_OPS_HUB_API_TOKEN }} + BASELINE_VERSION_ID: ${{ steps.receipt.outputs.baseline_version_id }} + run: | + set -euo pipefail + ./node_modules/.bin/cf workers deployments list --worker lab-ops-hub > "$RUNNER_TEMP/loh-final-baseline.json" + node release-tools/release-safety.mjs verify-current "$RUNNER_TEMP/loh-final-baseline.json" "$BASELINE_VERSION_ID" + + - name: Promote the receipt-bound version to 100% + working-directory: pkgs/lab-ops-hub + env: + CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_LAB_OPS_HUB_ACCOUNT_ID }} + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_LAB_OPS_HUB_API_TOKEN }} run: >- ./node_modules/.bin/cf workers deployments create --worker lab-ops-hub --strategy percentage - --versions @versions.json + --versions @${{ runner.temp }}/loh-versions.json + + - name: Confirm the promoted version is the only version serving + working-directory: pkgs/lab-ops-hub + env: + CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_LAB_OPS_HUB_ACCOUNT_ID }} + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_LAB_OPS_HUB_API_TOKEN }} + VERSION_ID: ${{ steps.receipt.outputs.version_id }} + run: | + set -euo pipefail + ./node_modules/.bin/cf workers deployments list --worker lab-ops-hub > "$RUNNER_TEMP/loh-promoted-deployments.json" + node release-tools/release-safety.mjs verify-deployed "$RUNNER_TEMP/loh-promoted-deployments.json" "$VERSION_ID" diff --git a/.github/workflows/lab-ops-hub-worker-release.yml b/.github/workflows/lab-ops-hub-worker-release.yml index 63b33e76c9..b1feb049b7 100644 --- a/.github/workflows/lab-ops-hub-worker-release.yml +++ b/.github/workflows/lab-ops-hub-worker-release.yml @@ -1,35 +1,27 @@ -name: Lab Ops Hub Worker version upload +name: Lab Ops Hub Worker Version upload on: workflow_dispatch: - inputs: - confirm_migration_tag_v2: - description: "Confirm Cloudflare reports v2 as the active Durable Object migration tag" - required: true - default: false - type: boolean - confirm_container_image_v5_available: - description: "Confirm the pinned crawler container image :v5 is already published" - required: true - default: false - type: boolean permissions: + actions: read contents: read +concurrency: + group: lab-ops-hub-cloudflare-release + cancel-in-progress: false + jobs: upload: - if: github.ref == 'refs/heads/main' + if: github.repository == 'developing-today/code' && github.ref == 'refs/heads/main' runs-on: ubuntu-24.04 timeout-minutes: 20 - concurrency: - group: lab-ops-hub-worker-version-upload - cancel-in-progress: false - env: - CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }} + environment: lab-ops-hub-cloudflare-release steps: - - name: Checkout + - name: Checkout the dispatched main commit uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + with: + ref: ${{ github.sha }} - name: Set up Node 24.22.0 uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 @@ -39,16 +31,18 @@ jobs: - name: Install pinned cf and Wrangler toolchain working-directory: pkgs/lab-ops-hub run: | - npm ci --prefix release-tools + npm ci --prefix release-tools --no-audit --no-fund + test ! -e node_modules ln -s release-tools/node_modules node_modules + node -e 'const p=require("./release-tools/package-lock.json"); if(p.packages["node_modules/cf"].version!=="1.0.0-rc.1" || p.packages["node_modules/wrangler"].version!=="4.163.0") process.exit(1)' + test "$(./node_modules/.bin/cf --version)" = "1.0.0-rc.1" - - name: Build Build Output v1 - working-directory: pkgs/lab-ops-hub - run: ./node_modules/.bin/cf build - - - name: Verify Wrangler-to-cf binding and migration parity + - name: Build Build Output v1 and verify Wrangler parity working-directory: pkgs/lab-ops-hub - run: node release-tools/verify-build.mjs + run: | + ./node_modules/.bin/cf build + node release-tools/verify-build.mjs + node --test release-tools/release-safety.test.mjs - name: Dry-run Worker Version upload working-directory: pkgs/lab-ops-hub @@ -60,19 +54,50 @@ jobs: --message "git ${GITHUB_SHA}" --dry-run - - name: Keep upload held until cutover checks are confirmed - if: ${{ !inputs.confirm_migration_tag_v2 || !inputs.confirm_container_image_v5_available }} + - name: Read the exact serving baseline and verify v2 plus the image pin + id: baseline + working-directory: pkgs/lab-ops-hub + env: + CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_LAB_OPS_HUB_ACCOUNT_ID }} + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_LAB_OPS_HUB_API_TOKEN }} run: | - echo "::notice::Worker Version upload held. Confirm active migration tag v2 and published image :v5, then dispatch again." + set -euo pipefail + test -n "$CLOUDFLARE_ACCOUNT_ID" || { echo "::error::missing environment variable CLOUDFLARE_LAB_OPS_HUB_ACCOUNT_ID"; exit 1; } + test -n "$CLOUDFLARE_API_TOKEN" || { echo "::error::missing protected environment secret CLOUDFLARE_LAB_OPS_HUB_API_TOKEN"; exit 1; } + ./node_modules/.bin/cf workers deployments list --worker lab-ops-hub > "$RUNNER_TEMP/loh-deployments.json" + baseline_id=$(node release-tools/release-safety.mjs baseline-id "$RUNNER_TEMP/loh-deployments.json") + ./node_modules/.bin/cf workers versions get "$baseline_id" --worker lab-ops-hub > "$RUNNER_TEMP/loh-baseline-version.json" + node release-tools/release-safety.mjs verify-version "$RUNNER_TEMP/loh-baseline-version.json" "$baseline_id" + echo "baseline_version_id=$baseline_id" >> "$GITHUB_OUTPUT" - name: Upload Worker Version without promoting it - if: ${{ inputs.confirm_migration_tag_v2 && inputs.confirm_container_image_v5_available }} + id: upload working-directory: pkgs/lab-ops-hub env: - CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} - run: >- - ./node_modules/.bin/cf workers versions create - --prebuilt - --worker lab-ops-hub - --tag "git-${GITHUB_SHA::12}" - --message "git ${GITHUB_SHA}" + CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_LAB_OPS_HUB_ACCOUNT_ID }} + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_LAB_OPS_HUB_API_TOKEN }} + run: | + set -euo pipefail + ./node_modules/.bin/cf workers versions create \ + --prebuilt \ + --worker lab-ops-hub \ + --tag "git-${GITHUB_SHA::12}" \ + --message "git ${GITHUB_SHA}" \ + > "$RUNNER_TEMP/loh-upload.json" + version_id=$(node release-tools/release-safety.mjs upload-id "$RUNNER_TEMP/loh-upload.json") + ./node_modules/.bin/cf workers versions get "$version_id" --worker lab-ops-hub > "$RUNNER_TEMP/loh-version.json" + node release-tools/release-safety.mjs verify-version "$RUNNER_TEMP/loh-version.json" "$version_id" "git-${GITHUB_SHA::12}" + mkdir -p "$RUNNER_TEMP/loh-receipt" + node release-tools/release-safety.mjs receipt \ + "$RUNNER_TEMP/loh-upload.json" \ + "$RUNNER_TEMP/loh-version.json" \ + "${{ steps.baseline.outputs.baseline_version_id }}" \ + "$RUNNER_TEMP/loh-receipt/receipt.json" + + - name: Save the exact upload receipt for a later promotion + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7 + with: + name: lab-ops-hub-version-receipt + path: ${{ runner.temp }}/loh-receipt/receipt.json + if-no-files-found: error + retention-days: 14 diff --git a/lib/default.nix b/lib/default.nix index d5ba4eab1d..5be294f0d1 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -749,6 +749,9 @@ let coldStoreRehydratorBundle = coldStoreRehydrator; }; labOpsHub = pkgs.callPackage ../pkgs/lab-ops-hub/package.nix { }; + labOpsHubDeploy = pkgs.callPackage ../pkgs/lab-ops-hub/deploy.nix { + inherit labOpsHub; + }; labOpsHubImagePush = pkgs.callPackage ../pkgs/lab-ops-hub/image-push.nix { inherit labOpsHub; }; @@ -780,6 +783,7 @@ let coldStoreRehydrator coldStoreRehydratorDeploy labOpsHub + labOpsHubDeploy labOpsHubImagePush cfContainerHello cfContainerHelloDeploy @@ -866,6 +870,7 @@ let developing-today-backup-deploy = mkApp developingTodayBackupDeploy "Deploy the developing-today-backup Worker (github-backup webhook receiver) via the wrangler versions flow (needs Bitwarden and sops access)"; cold-store-rehydrator-deploy = mkApp coldStoreRehydratorDeploy "Deploy the cold-store-rehydrator Worker from its flake bundle via the wrangler versions flow (needs Bitwarden and sops access)"; lab-ops-hub-image-push = mkApp labOpsHubImagePush "Build and push the Lab Ops Hub crawler container image only (needs Bitwarden and sops access); Worker releases use the GHA cf Versions workflow"; + lab-ops-hub-deploy = mkApp labOpsHubDeploy "Legacy Lab Ops Hub operator recovery: build/push the pinned crawler image and deploy the Worker with pinned Wrangler (needs Bitwarden, sops, and Cloudflare registry access)"; cf-container-hello-deploy = mkApp cfContainerHelloDeploy "Deploy the cf-container-hello Worker from its flake package (needs Bitwarden and sops access)"; queue-transport-alert-deploy = mkApp queueTransportAlertDeploy "Deploy the queue-transport-alert Worker (broker outage alert, code#6369) from its flake package via the cf versions flow (needs Bitwarden and sops access)"; message-bridge-deploy = mkApp messageBridgeDeploy "Deploy the message-bridge Worker (Claude custom connector that sends and receives messages, plus history page) through the cf versions flow (tagged version, then deployment) and set its access token; --code-only uploads code with Cloudflare env vars (CI), --deploy-version rolls back, --print-urls prints the connector URL (needs Bitwarden and sops access)"; diff --git a/pkgs/lab-ops-hub/README.md b/pkgs/lab-ops-hub/README.md index d76785dbff..8ff1d5b408 100644 --- a/pkgs/lab-ops-hub/README.md +++ b/pkgs/lab-ops-hub/README.md @@ -95,30 +95,52 @@ npm run dev # local dev (containers run via workerd locally too) Worker releases use the two manually dispatched workflows from `main`: - `lab-ops-hub-worker-release.yml` builds Build Output v1, checks the - mapped config against `wrangler.jsonc`, and uploads a tagged Worker - Version with `cf workers versions create`. It does not route traffic. -- `lab-ops-hub-promote.yml` takes an uploaded version UUID and a separate - confirmation, then explicitly deploys that version at 100% with + mapped config against `wrangler.jsonc`, checks the current single-version + 100% baseline and uploads a tagged Worker Version with + `cf workers versions create`. It does not route traffic. +- `lab-ops-hub-promote.yml` takes the successful upload workflow's numeric + GitHub Actions run ID. It verifies that run and its receipt, including the + uploaded version and baseline IDs, then rechecks the current 100% baseline + before explicitly deploying the receipt-bound version at 100% with `cf workers deployments create`. Both workflows use Node `24.22.0`, `cf@1.0.0-rc.1`, and Wrangler -`4.163.0`. The upload workflow keeps a default hold: dispatch it from -`main`, review the offline build and dry run, then affirm both that the -existing Worker reports migration tag `v2` and that the pinned crawler -image is available. It needs the repository variable -`CLOUDFLARE_ACCOUNT_ID` and secret `CLOUDFLARE_API_TOKEN`; scope the token -to Cloudflare `Workers Scripts Write`. The secret is present only on the -version-upload step, never on pull-request workflows. The promotion -workflow requires the exact version UUID and its own explicit confirmation. +`4.163.0`, and share a GitHub concurrency group. The upload and promotion +jobs use the protected environment `lab-ops-hub-cloudflare-release`, with +the environment variable `CLOUDFLARE_LAB_OPS_HUB_ACCOUNT_ID` and secret +`CLOUDFLARE_LAB_OPS_HUB_API_TOKEN`. The token must have Cloudflare's +Workers `Editor` role scoped to the individual `lab-ops-hub` Worker +(`Individual Workers Editor` API permission). See Cloudflare's [Workers +roles and permissions](https://developers.cloudflare.com/workers/authorization/). +The +secret is used only by the manually dispatched trusted workflows; there is +no pull-request trigger or pull-request credential path. Configure the +environment protection and credentials out of band before cutover; this +change does not edit GitHub settings. + +**Current fail-closed hold:** Cloudflare's documented Worker Version GET +includes the migration tag and container class, but omits the container image +URI. The documented Containers application read schema also omits the image +for this Durable Object-managed container. The workflows therefore can check +`v2` but deliberately stop before upload or promotion when they cannot prove +the exact `:v5` pin from read-only metadata. Do not grant broader account or +registry permissions to bypass this check. Cutover needs a read-only image +metadata field or a separately trusted image-publish attestation that binds +the immutable image digest to the Worker release receipt. Cutover prerequisites: the `lab-ops-hub` Worker must already exist, -Cloudflare must report migration tag `v2` as current, and the pinned -`lab-ops-hub-crawlercontainer:v5` image must already be present in the -configured registry. `cf workers versions create` refuses a pending -Durable Object migration and cannot create a Worker that does not exist. -The existing `v1` and `v2` migration records stay in `wrangler.jsonc`; -this release path does not apply them. If any prerequisite is unknown or -false, keep the upload held and resolve it before promotion. +Cloudflare must report migration tag `v2` as current, the exact pinned +`lab-ops-hub-crawlercontainer:v5` image must be verified, and the protected +environment/token must be configured. Keep the prior operator recovery +available until this workflow has passed those checks. Pause all other +Worker releases, including operator deploys, during the GHA promotion +window: Cloudflare's deployment create API does not expose a compare-and-swap +condition, so the repeated baseline checks and GitHub concurrency group +cannot serialize deployments made outside these workflows. `cf workers +versions create` refuses a pending Durable Object migration and cannot +create a Worker that does not exist. The existing `v1` and `v2` migration +records stay in `wrangler.jsonc`; this release path does not apply them. If +any prerequisite is unknown or false, keep upload and promotion held. Runtime API auth is separate: the existing `API_TOKEN` Worker secret gates the deployed API itself. @@ -150,6 +172,16 @@ only that image (use `-- --dry-run` to build without pushing). It does not upload or promote a Worker Version. `wrangler.jsonc` and the Build Output mapping both pin `CrawlerContainerV2` to the matching `:v5` image. +### Legacy operator recovery + +Until the GHA release path has passed its cutover checks, keep +`nix run .#lab-ops-hub-deploy` available as the prior operator recovery. +It uses the pinned Wrangler from the Worker package, rebuilds and pushes +the already-pinned `:v5` image, then runs `wrangler deploy`. This fallback +is separate from the GHA Worker Version upload/promotion flow and retains +its existing Bitwarden/SOPS and Cloudflare registry credential boundary; +it is not a CI credential path. Use `-- --dry-run` for config validation. + ### Known behaviour (observed 2026-10-20, D1-verified) - **Root cause #1 (fixed): `:latest` tags are rejected.** Cloudflare diff --git a/pkgs/lab-ops-hub/deploy.mjs b/pkgs/lab-ops-hub/deploy.mjs new file mode 100644 index 0000000000..15582cdfca --- /dev/null +++ b/pkgs/lab-ops-hub/deploy.mjs @@ -0,0 +1,158 @@ +// Legacy operator recovery: deploys the lab-ops-hub Worker AND its +// crawler container image as one command — issue #5767, phase 2 +// ("worker deploy + its container image push become one `deploy +// lab-ops-hub`"). The GHA cf Versions path is the separate normal +// Worker release path; this operator command is retained until cutover. +// Previously: build the +// Nix image by hand, mint registry credentials by hand, crane push by +// hand, then a raw `npm run deploy` in a checkout. +// +// The Worker tree is a flake package (package.nix, lockfile-pinned +// deps including the pinned wrangler 4.152.0); this script stages that +// package (or, run directly from a checkout, the checkout itself) and +// runs the package's own wrangler from the staged copy. No +// deploy-time `npm install`. +// +// Steps (full deploy): +// 1. nix build -f container-image.nix (the only image build path; +// pinned nixpkgs inside that file) -> docker-archive tar. +// 2. Mint temporary registry push credentials with +// `wrangler containers registries credentials --push`. This +// needs the ACCOUNT-WIDE Cloudflare token — the day-to-day token +// gets Forbidden (README, observed 2026-10-20). Name the +// Bitwarden secret holding it with LOH_CF_ACCOUNT_TOKEN_SECRET; +// without one, the day-to-day token is tried and the failure +// message names the remedy. +// 3. crane push the tar to the registry image wrangler.jsonc +// references (lab-ops-hub-crawlercontainer:v5 — keep in step +// with container-image.nix's tag). +// 4. wrangler deploy from the staged package. +// +// Usage: +// deploy.mjs [--dry-run] validate the Worker config +// only (no image push, no +// upload) +// +// Needs CLOUDFLARE_ACCOUNT_ID and BWS_ACCESS_TOKEN; deploy.sh sets +// them. API tokens come from Bitwarden by name (deploy token default +// cloudflare.api-token-day-to-day; override with LOH_CF_TOKEN_SECRET). +// No secret is ever printed; the registry JWT passes to crane through +// a temporary docker config directory, never argv or logs. +import { execFileSync } from "node:child_process"; +import { cpSync, existsSync, mkdtempSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { dirname, join } from "node:path"; +import { fileURLToPath } from "node:url"; + +const here = dirname(fileURLToPath(import.meta.url)); +const WORKER = "lab-ops-hub"; +const IMAGE = "lab-ops-hub-crawlercontainer:v5"; // container-image.nix tag + +const args = process.argv.slice(2); +// Strict argument validation, following the sibling deploy scripts +// (#3287): the only accepted invocation is `deploy.mjs [--dry-run]`. +function usageError(message) { + console.error(`${message}\nusage: deploy.mjs [--dry-run]`); + process.exit(2); +} +let dryRun = false; +for (const arg of args) { + if (arg === "--dry-run") { + if (dryRun) usageError("duplicate argument: --dry-run"); + dryRun = true; + } else { + usageError(`unrecognized argument: ${arg}`); + } +} + +// The shell and Nix wrappers call this before reading Bitwarden/SOPS +// credentials. It validates the complete command line without touching +// the environment, filesystem, or network. +if (process.env.LOH_CHECK_ARGS_ONLY === "1") process.exit(0); + +requireEnv("CLOUDFLARE_ACCOUNT_ID"); +const accountId = process.env.CLOUDFLARE_ACCOUNT_ID; +const secrets = JSON.parse(execFileSync("bws", ["secret", "list", "-o", "json"], { encoding: "utf8" })); +const byName = (name) => secrets.find((secret) => secret.key === name)?.value; +const tokenSecretName = process.env.LOH_CF_TOKEN_SECRET ?? "cloudflare.api-token-day-to-day"; +const apiToken = byName(tokenSecretName); +if (!apiToken) { + throw new Error(`no Bitwarden secret named ${tokenSecretName}`); +} +const env = { ...process.env, CLOUDFLARE_API_TOKEN: apiToken }; + +// Stage a writable copy of the Worker package (the store path is +// read-only; wrangler writes .wrangler state next to the config). +const pkgDir = process.env.LAB_OPS_HUB_PKG ?? here; +const stage = mkdtempSync(join(tmpdir(), "lab-ops-hub-deploy-")); +cpSync(pkgDir, stage, { recursive: true }); +if (!existsSync(join(stage, "wrangler.jsonc"))) { + throw new Error(`no wrangler.jsonc in staged Worker package at ${pkgDir}`); +} +const wranglerBin = existsSync(join(stage, "node_modules", ".bin", "wrangler")) + ? join(stage, "node_modules", ".bin", "wrangler") + : "wrangler"; + +if (dryRun) { + runWrangler(["deploy", "--dry-run"]); + console.log("dry run: config builds, nothing uploaded, image not pushed"); + process.exit(0); +} + +// 1. Build the crawler container image (daemon-less, dockerTools). +console.log("building crawler container image (container-image.nix)"); +const imageTar = execFileSync( + "nix", + ["build", "-f", join(here, "container-image.nix"), "--no-link", "--print-out-paths"], + { encoding: "utf8" } +).trim().split("\n").pop(); + +// 2. Mint temporary registry push credentials (account-wide token). +const pushTokenName = process.env.LOH_CF_ACCOUNT_TOKEN_SECRET; +const pushToken = pushTokenName ? byName(pushTokenName) : apiToken; +if (pushTokenName && !pushToken) { + throw new Error(`no Bitwarden secret named ${pushTokenName} (LOH_CF_ACCOUNT_TOKEN_SECRET)`); +} +let registryJwt; +try { + const out = execFileSync(wranglerBin, ["containers", "registries", "credentials", "--push"], { + cwd: stage, + env: { ...env, CLOUDFLARE_API_TOKEN: pushToken }, + encoding: "utf8", + }); + registryJwt = out.trim().split(/\s+/).pop(); +} catch { + throw new Error( + "could not mint registry push credentials: `wrangler containers registries credentials --push` " + + "requires the ACCOUNT-WIDE Cloudflare token (the day-to-day token gets Forbidden — see " + + "pkgs/lab-ops-hub/README.md). Name the Bitwarden secret holding it via " + + "LOH_CF_ACCOUNT_TOKEN_SECRET and retry." + ); +} + +// 3. Push the image with crane, username = account id, password = JWT +// (via a temporary docker config dir; the JWT never reaches argv). +const dockerConfig = mkdtempSync(join(tmpdir(), "lab-ops-hub-docker-config-")); +const auth = Buffer.from(`${accountId}:${registryJwt}`).toString("base64"); +writeFileSync( + join(dockerConfig, "config.json"), + JSON.stringify({ auths: { "registry.cloudflare.com": { auth } } }) +); +const imageRef = `registry.cloudflare.com/${accountId}/${IMAGE}`; +console.log(`pushing container image ${imageRef}`); +execFileSync("crane", ["push", imageTar, imageRef], { + env: { ...process.env, DOCKER_CONFIG: dockerConfig }, + stdio: "inherit", +}); + +// 4. Deploy the Worker from the staged flake package. +runWrangler(["deploy"]); +console.log(`deployed: ${WORKER} (image ${imageRef} pushed, wrangler deploy from the flake package)`); + +function runWrangler(wranglerArgs) { + execFileSync(wranglerBin, wranglerArgs, { cwd: stage, env, stdio: "inherit" }); +} + +function requireEnv(name) { + if (!process.env[name]) throw new Error(`${name} is not set; run deploy.sh`); +} diff --git a/pkgs/lab-ops-hub/deploy.nix b/pkgs/lab-ops-hub/deploy.nix new file mode 100644 index 0000000000..49cdc8adfc --- /dev/null +++ b/pkgs/lab-ops-hub/deploy.nix @@ -0,0 +1,34 @@ +{ + writeShellApplication, + bws, + crane, + git, + jq, + nix, + nodejs, + sops, + labOpsHub, +}: +# Issue #5767, phase 2: one `deploy lab-ops-hub` — the deploy app +# carries the flake package (package.nix: Worker tree + lockfile- +# pinned deps incl. wrangler) by store path; deploy.mjs stages it, +# builds + pushes the crawler container image (container-image.nix), +# and runs the pinned wrangler deploy from the staged copy. +writeShellApplication { + name = "lab-ops-hub-deploy"; + runtimeInputs = [ + bws + crane + git + jq + nix + nodejs + sops + ]; + text = '' + LOH_CHECK_ARGS_ONLY=1 node ${./deploy.mjs} "$@" + export LAB_OPS_HUB_PKG="${labOpsHub}" + repo_root=$(git rev-parse --show-toplevel) + exec bash "$repo_root/pkgs/lab-ops-hub/deploy.sh" "$@" + ''; +} diff --git a/pkgs/lab-ops-hub/deploy.sh b/pkgs/lab-ops-hub/deploy.sh new file mode 100755 index 0000000000..e2098f27ff --- /dev/null +++ b/pkgs/lab-ops-hub/deploy.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# Deploys the lab-ops-hub Worker + its crawler container image as one +# command (see deploy.mjs). Pass --dry-run to validate the Worker +# config without pushing the image or deploying. +set -euo pipefail +cd "$(dirname "${BASH_SOURCE[0]}")" +# Reject malformed arguments before sourcing Bitwarden/SOPS credentials. +LOH_CHECK_ARGS_ONLY=1 node deploy.mjs "$@" +repo_root=$(git rev-parse --show-toplevel) +# shellcheck source=/dev/null +source "${repo_root}/lib/bitwarden-env.sh" >/dev/null +CLOUDFLARE_ACCOUNT_ID=$(sops decrypt --extract '["cloudflare_account_id"]' "${repo_root}/secrets/sops/common/cloudflare.yaml") +export CLOUDFLARE_ACCOUNT_ID +exec node deploy.mjs "$@" diff --git a/pkgs/lab-ops-hub/release-tools/release-safety.mjs b/pkgs/lab-ops-hub/release-tools/release-safety.mjs new file mode 100644 index 0000000000..0cfd01795c --- /dev/null +++ b/pkgs/lab-ops-hub/release-tools/release-safety.mjs @@ -0,0 +1,283 @@ +import assert from "node:assert/strict"; +import { readFileSync, writeFileSync } from "node:fs"; +import { dirname, join, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; + +export const WORKER = "lab-ops-hub"; +export const UPLOAD_WORKFLOW = ".github/workflows/lab-ops-hub-worker-release.yml"; +export const RECEIPT_ARTIFACT = "lab-ops-hub-version-receipt"; + +const packageDir = dirname(dirname(fileURLToPath(import.meta.url))); +const uuidPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i; +const shaPattern = /^[0-9a-f]{40}$/i; + +function readJson(path) { + return JSON.parse(readFileSync(path, "utf8")); +} + +function cfResult(response) { + if (!response || typeof response !== "object" || Array.isArray(response)) { + throw new Error("Cloudflare CLI output must be a JSON object"); + } + if (response.success === false || (Array.isArray(response.errors) && response.errors.length > 0)) { + throw new Error("Cloudflare CLI returned an unsuccessful API response"); + } + return Object.hasOwn(response, "result") ? response.result : response; +} + +export function readExpectedWorkerConfig(configText) { + const config = JSON.parse(configText.replace(/^\s*\/\/.*$/gm, "")); + const migrations = config.migrations; + const containers = config.containers; + assert.equal(config.name, WORKER, "unexpected Worker name in wrangler.jsonc"); + assert.ok(Array.isArray(migrations) && migrations.length > 0, "Worker migration history is required"); + assert.ok(Array.isArray(containers) && containers.length > 0, "Worker container metadata is required"); + assert.equal(migrations.at(-1).tag, "v2", "release gate is intentionally pinned to migration tag v2"); + return { + worker: config.name, + migrationTag: migrations.at(-1).tag, + containers: containers.map(({ class_name, image }) => ({ class_name, image })), + }; +} + +export function latestServingVersionId(deploymentsResponse) { + const result = cfResult(deploymentsResponse); + const deployments = Array.isArray(result) ? result : result?.deployments; + if (!Array.isArray(deployments) || deployments.length === 0) { + throw new Error("Cloudflare returned no current Worker deployment; refusing release"); + } + const active = deployments[0]; + if (!Array.isArray(active?.versions) || active.versions.length !== 1) { + throw new Error("current Worker deployment is not a single-version deployment; refusing release"); + } + const [version] = active.versions; + if (version?.percentage !== 100 || typeof version.version_id !== "string" || !uuidPattern.test(version.version_id)) { + throw new Error("current Worker deployment is not exactly one version at 100%; refusing release"); + } + return version.version_id; +} + +export function assertCurrentBaseline(deploymentsResponse, expectedVersionId) { + if (!uuidPattern.test(expectedVersionId ?? "")) { + throw new Error("expected baseline version ID is not a UUID"); + } + const servingVersionId = latestServingVersionId(deploymentsResponse); + if (servingVersionId !== expectedVersionId) { + throw new Error(`serving baseline changed: expected ${expectedVersionId}, found ${servingVersionId}`); + } + return servingVersionId; +} + +export function assertWorkerVersion(response, { + versionId, + versionTag, + expectedConfig, +} = {}) { + const version = cfResult(response); + if (!version || typeof version !== "object" || Array.isArray(version)) { + throw new Error("Cloudflare returned no Worker version metadata"); + } + if (!uuidPattern.test(versionId ?? "") || version.id !== versionId) { + throw new Error("Worker Version response ID does not match the requested exact version ID"); + } + + const config = expectedConfig ?? readExpectedWorkerConfig(readFileSync(join(packageDir, "wrangler.jsonc"), "utf8")); + if (version.migration_tag !== config.migrationTag) { + throw new Error( + `Worker migration metadata is ${JSON.stringify(version.migration_tag)}; expected active tag ${config.migrationTag}`, + ); + } + if (versionTag !== undefined && version.annotations?.["workers/tag"] !== versionTag) { + throw new Error("Worker Version tag metadata does not match the trusted upload receipt"); + } + + if (!Array.isArray(version.containers) || version.containers.length !== config.containers.length) { + throw new Error("Worker Version container metadata is missing or does not match the configured container count"); + } + for (const expected of config.containers) { + const match = version.containers.find((container) => container?.class_name === expected.class_name); + if (!match) { + throw new Error(`Worker Version metadata is missing container class ${expected.class_name}`); + } + if (typeof match.image !== "string") { + throw new Error( + "Cloudflare Workers Versions GET exposes the container class but not its image URI; " + + "cannot verify the pinned image with the Worker-only token. Failing closed before release.", + ); + } + if (match.image !== expected.image) { + throw new Error(`Worker Version container image ${match.image} does not match the pinned image ${expected.image}`); + } + } + return version; +} + +export function versionIdFromUpload(response) { + const result = cfResult(response); + if (!result || typeof result !== "object" || !uuidPattern.test(result.id ?? "")) { + throw new Error("cf workers versions create did not return an exact Worker Version UUID"); + } + return result.id; +} + +export function makeUploadReceipt({ uploadResponse, versionResponse, baselineVersionId, context }) { + const versionId = versionIdFromUpload(uploadResponse); + const config = readExpectedWorkerConfig(readFileSync(join(packageDir, "wrangler.jsonc"), "utf8")); + const sourceSha = context?.sourceSha; + if (!shaPattern.test(sourceSha ?? "")) throw new Error("upload source SHA must be a full 40-character commit SHA"); + if (!uuidPattern.test(baselineVersionId ?? "")) throw new Error("baseline version ID must be a UUID"); + const expectedTag = `git-${sourceSha.slice(0, 12)}`; + assertWorkerVersion(versionResponse, { versionId, versionTag: expectedTag, expectedConfig: config }); + + const runId = String(context.runId ?? ""); + const runAttempt = Number(context.runAttempt); + if (!/^[1-9][0-9]{0,19}$/.test(runId) || !Number.isSafeInteger(runAttempt) || runAttempt < 1) { + throw new Error("upload run ID and attempt must identify a real GitHub Actions run"); + } + if ( + context.repository !== "developing-today/code" || + context.ref !== "refs/heads/main" || + context.event !== "workflow_dispatch" + ) { + throw new Error("upload receipt may only be made by a trusted main-branch workflow_dispatch run"); + } + return { + schema_version: 1, + worker: WORKER, + version_id: versionId, + version_tag: expectedTag, + migration_tag: config.migrationTag, + image: config.containers[0].image, + baseline_version_id: baselineVersionId, + source_sha: sourceSha, + upload_run_id: runId, + upload_run_attempt: runAttempt, + repository: context.repository, + ref: context.ref, + event: context.event, + workflow_path: UPLOAD_WORKFLOW, + }; +} + +export function assertTrustedUploadReceipt(receipt, run) { + const fields = [ + "schema_version", "worker", "version_id", "version_tag", "migration_tag", "image", + "baseline_version_id", "source_sha", "upload_run_id", "upload_run_attempt", + "repository", "ref", "event", "workflow_path", + ]; + if (!receipt || typeof receipt !== "object" || fields.some((field) => !Object.hasOwn(receipt, field))) { + throw new Error("upload receipt is incomplete or has an unsupported schema"); + } + const config = readExpectedWorkerConfig(readFileSync(join(packageDir, "wrangler.jsonc"), "utf8")); + const expectedTag = `git-${receipt.source_sha?.slice(0, 12)}`; + if ( + receipt.schema_version !== 1 || receipt.worker !== WORKER || + !uuidPattern.test(receipt.version_id ?? "") || !uuidPattern.test(receipt.baseline_version_id ?? "") || + !shaPattern.test(receipt.source_sha ?? "") || receipt.version_tag !== expectedTag || + receipt.migration_tag !== config.migrationTag || receipt.image !== config.containers[0].image || + receipt.repository !== "developing-today/code" || receipt.ref !== "refs/heads/main" || + receipt.event !== "workflow_dispatch" || receipt.workflow_path !== UPLOAD_WORKFLOW + ) { + throw new Error("upload receipt does not match the configured Worker release target"); + } + if (!run || typeof run !== "object") throw new Error("GitHub Actions upload run metadata is missing"); + const runRepository = run.repository?.full_name; + if ( + String(run.id) !== receipt.upload_run_id || Number(run.run_attempt) !== receipt.upload_run_attempt || + run.status !== "completed" || run.conclusion !== "success" || run.event !== "workflow_dispatch" || + run.head_branch !== "main" || run.head_sha !== receipt.source_sha || run.path !== UPLOAD_WORKFLOW || + runRepository !== receipt.repository + ) { + throw new Error("receipt is not from the exact successful trusted main-branch upload run"); + } + return receipt; +} + +function requireArgs(args, count, usage) { + if (args.length !== count) throw new Error(`usage: ${usage}`); +} + +function writeDeployVersions(receiptPath, outputPath) { + const receipt = readJson(receiptPath); + if (!uuidPattern.test(receipt.version_id ?? "")) throw new Error("receipt version ID is not a UUID"); + writeFileSync(outputPath, `${JSON.stringify([{ version_id: receipt.version_id, percentage: 100 }], null, 2)}\n`); +} + +function cli(args) { + const [command, ...rest] = args; + if (command === "baseline-id") { + requireArgs(rest, 1, "release-safety.mjs baseline-id "); + console.log(latestServingVersionId(readJson(rest[0]))); + return; + } + if (command === "verify-current") { + requireArgs(rest, 2, "release-safety.mjs verify-current "); + assertCurrentBaseline(readJson(rest[0]), rest[1]); + console.log(`current serving version matches ${rest[1]} at 100%`); + return; + } + if (command === "verify-version") { + if (rest.length < 2 || rest.length > 3) { + throw new Error("usage: release-safety.mjs verify-version [version-tag]"); + } + assertWorkerVersion(readJson(rest[0]), { versionId: rest[1], versionTag: rest[2] }); + console.log(`Worker version ${rest[1]} migration and container metadata verified`); + return; + } + if (command === "upload-id") { + requireArgs(rest, 1, "release-safety.mjs upload-id "); + console.log(versionIdFromUpload(readJson(rest[0]))); + return; + } + if (command === "receipt") { + requireArgs(rest, 4, "release-safety.mjs receipt "); + const receipt = makeUploadReceipt({ + uploadResponse: readJson(rest[0]), + versionResponse: readJson(rest[1]), + baselineVersionId: rest[2], + context: { + sourceSha: process.env.GITHUB_SHA, + runId: process.env.GITHUB_RUN_ID, + runAttempt: process.env.GITHUB_RUN_ATTEMPT, + repository: process.env.GITHUB_REPOSITORY, + ref: process.env.GITHUB_REF, + event: process.env.GITHUB_EVENT_NAME, + }, + }); + writeFileSync(rest[3], `${JSON.stringify(receipt, null, 2)}\n`); + console.log(`wrote receipt for ${receipt.worker} version ${receipt.version_id}`); + return; + } + if (command === "trust-receipt") { + requireArgs(rest, 2, "release-safety.mjs trust-receipt "); + const receipt = assertTrustedUploadReceipt(readJson(rest[0]), readJson(rest[1])); + console.log(`source_sha=${receipt.source_sha}`); + console.log(`baseline_version_id=${receipt.baseline_version_id}`); + console.log(`version_id=${receipt.version_id}`); + console.log(`version_tag=${receipt.version_tag}`); + return; + } + if (command === "deployment-versions") { + requireArgs(rest, 2, "release-safety.mjs deployment-versions "); + writeDeployVersions(rest[0], rest[1]); + return; + } + if (command === "verify-deployed") { + requireArgs(rest, 2, "release-safety.mjs verify-deployed "); + assertCurrentBaseline(readJson(rest[0]), rest[1]); + console.log(`confirmed ${rest[1]} is the only version serving at 100%`); + return; + } + throw new Error( + "usage: release-safety.mjs ...", + ); +} + +if (process.argv[1] && fileURLToPath(import.meta.url) === resolve(process.argv[1])) { + try { + cli(process.argv.slice(2)); + } catch (error) { + console.error(error instanceof Error ? error.message : String(error)); + process.exitCode = 1; + } +} diff --git a/pkgs/lab-ops-hub/release-tools/release-safety.test.mjs b/pkgs/lab-ops-hub/release-tools/release-safety.test.mjs new file mode 100644 index 0000000000..a02871fe41 --- /dev/null +++ b/pkgs/lab-ops-hub/release-tools/release-safety.test.mjs @@ -0,0 +1,161 @@ +import assert from "node:assert/strict"; +import { spawnSync } from "node:child_process"; +import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { dirname, join, relative, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; +import test from "node:test"; +import { + assertCurrentBaseline, + assertTrustedUploadReceipt, + assertWorkerVersion, + latestServingVersionId, + makeUploadReceipt, + readExpectedWorkerConfig, + versionIdFromUpload, +} from "./release-safety.mjs"; + +const idA = "51a5a667-13c2-46e5-9aad-b9e756763b62"; +const idB = "fb7f5708-0cc5-4bc4-a501-6e9be05de249"; +const sha = "a".repeat(40); +const workerConfig = { + name: "lab-ops-hub", + migrations: [{ tag: "v1" }, { tag: "v2" }], + containers: [{ + class_name: "CrawlerContainerV2", + image: "registry.cloudflare.com/234b866b99ce2b142d7963d8d139cbfa/lab-ops-hub-crawlercontainer:v5", + }], +}; +const expectedConfig = readExpectedWorkerConfig(JSON.stringify(workerConfig)); + +function deployment(versionId, percentage = 100) { + return { versions: [{ version_id: versionId, percentage }] }; +} + +function version(id, { image = expectedConfig.containers[0].image, tag } = {}) { + return { + result: { + id, + migration_tag: "v2", + ...(tag ? { annotations: { "workers/tag": tag } } : {}), + containers: [{ class_name: "CrawlerContainerV2", image }], + }, + success: true, + }; +} + +test("uses the first documented active deployment and requires exactly one 100% version", () => { + const response = { + result: { + deployments: [deployment(idA), deployment(idB, 50)], + }, + success: true, + }; + assert.equal(latestServingVersionId(response), idA); + assert.equal(assertCurrentBaseline(response, idA), idA); + assert.throws(() => assertCurrentBaseline(response, idB), /serving baseline changed/); + assert.throws(() => latestServingVersionId({ result: { deployments: [] } }), /no current Worker deployment/); + assert.throws(() => latestServingVersionId({ result: { deployments: [deployment(idA, 99)] } }), /exactly one version at 100%/); + assert.throws(() => latestServingVersionId({ result: { deployments: [{ versions: [ + { version_id: idA, percentage: 50 }, { version_id: idB, percentage: 50 }, + ] }] } }), /single-version deployment/); +}); + +test("requires exact ID, active v2 migration, container class, image pin, and upload tag", () => { + const candidateTag = `git-${sha.slice(0, 12)}`; + assert.equal(assertWorkerVersion(version(idA, { tag: candidateTag }), { + versionId: idA, + versionTag: candidateTag, + expectedConfig, + }).id, idA); + assert.throws(() => assertWorkerVersion(version(idB), { versionId: idA, expectedConfig }), /does not match/); + assert.throws(() => assertWorkerVersion({ result: { ...version(idA).result, migration_tag: "v1" } }, { + versionId: idA, + expectedConfig, + }), /expected active tag v2/); + assert.throws(() => assertWorkerVersion(version(idA, { image: "registry.cloudflare.com/account/other:v5" }), { + versionId: idA, + expectedConfig, + }), /does not match the pinned image/); + assert.throws(() => assertWorkerVersion(version(idA), { + versionId: idA, + versionTag: "git-wrongtag", + expectedConfig, + }), /tag metadata does not match/); +}); + +test("fails closed on the Cloudflare-documented Worker Version shape without an image URI", () => { + const documentedShape = version(idA).result; + delete documentedShape.containers[0].image; + assert.throws(() => assertWorkerVersion({ result: documentedShape }, { + versionId: idA, + expectedConfig, + }), /exposes the container class but not its image URI.*Failing closed/); +}); + +test("only parses exact UUIDs from cf upload results", () => { + assert.equal(versionIdFromUpload({ result: { id: idA }, success: true }), idA); + assert.throws(() => versionIdFromUpload({ result: { id: "51a5a667" }, success: true }), /exact Worker Version UUID/); +}); + +test("promotion JSON is generated only from a receipt version and CLI works from the repository root", () => { + const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), "../../.."); + const script = relative(repoRoot, fileURLToPath(new URL("./release-safety.mjs", import.meta.url))); + const tempDir = mkdtempSync(join(tmpdir(), "loh-release-safety-")); + const receiptPath = join(tempDir, "receipt.json"); + const versionsPath = join(tempDir, "versions.json"); + try { + writeFileSync(receiptPath, JSON.stringify({ version_id: idB })); + const result = spawnSync(process.execPath, [script, "deployment-versions", receiptPath, versionsPath], { + cwd: repoRoot, + encoding: "utf8", + }); + assert.equal(result.status, 0, result.stderr); + assert.deepEqual(JSON.parse(readFileSync(versionsPath, "utf8")), [{ version_id: idB, percentage: 100 }]); + } finally { + rmSync(tempDir, { recursive: true, force: true }); + } +}); + +test("receipt is tied to the exact successful trusted upload run and baseline", () => { + const tag = `git-${sha.slice(0, 12)}`; + const receipt = makeUploadReceipt({ + uploadResponse: { result: { id: idB }, success: true }, + versionResponse: version(idB, { tag }), + baselineVersionId: idA, + context: { + sourceSha: sha, + runId: "987654321", + runAttempt: "2", + repository: "developing-today/code", + ref: "refs/heads/main", + event: "workflow_dispatch", + }, + }); + const run = { + id: 987654321, + run_attempt: 2, + status: "completed", + conclusion: "success", + event: "workflow_dispatch", + head_branch: "main", + head_sha: sha, + path: ".github/workflows/lab-ops-hub-worker-release.yml", + repository: { full_name: "developing-today/code" }, + }; + assert.equal(assertTrustedUploadReceipt(receipt, run).version_id, idB); + for (const change of [ + { run_attempt: 1 }, + { status: "in_progress" }, + { conclusion: "failure" }, + { event: "pull_request" }, + { head_branch: "feature" }, + { head_sha: "b".repeat(40) }, + { path: "other.yml" }, + { repository: { full_name: "attacker/other" } }, + { repository: { name: "code" } }, + ]) { + assert.throws(() => assertTrustedUploadReceipt(receipt, { ...run, ...change }), /exact successful trusted main-branch upload run/); + } + assert.throws(() => assertTrustedUploadReceipt({ ...receipt, baseline_version_id: "not-a-uuid" }, run), /does not match/); +});