diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 7a5b584b9..59399e013 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -24,6 +24,8 @@ jobs: timeout-minutes: 30 steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - uses: actions/setup-node@v4 with: node-version: 22 diff --git a/.github/workflows/cloudflare-check.yml b/.github/workflows/cloudflare-check.yml new file mode 100644 index 000000000..e78a608a5 --- /dev/null +++ b/.github/workflows/cloudflare-check.yml @@ -0,0 +1,37 @@ +name: Cloudflare Check + +on: + pull_request: + push: + branches: + - main + +permissions: + contents: read + +concurrency: + group: cloudflare-check-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + cloudflare-check: + name: package check + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: npm + cache-dependency-path: packages/runtime-cloudflare/npm-shrinkwrap.json + - name: Install Cloudflare package lock + run: npm ci --prefix packages/runtime-cloudflare --workspaces=false + - name: Check repository package boundaries + run: npm run test:runtime-package-boundaries + - name: Run Cloudflare package checks + run: npm --prefix packages/runtime-cloudflare run check + - name: Bundle installed Cloudflare package artifact + run: npm --prefix packages/runtime-cloudflare run test:packed-wrangler diff --git a/.gitignore b/.gitignore index e93054567..33803f22b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ node_modules/ vendor/ +!packages/runtime-cloudflare/vendor/ +!packages/runtime-cloudflare/vendor/** dist/ artifacts/ runtime-overlays/* diff --git a/docs/runtime-package-lanes.md b/docs/runtime-package-lanes.md new file mode 100644 index 000000000..776831aac --- /dev/null +++ b/docs/runtime-package-lanes.md @@ -0,0 +1,11 @@ +# Runtime Package Lanes + +The root package is the Node CLI lane. Its explicit workspace list excludes Cloudflare, so a default root `npm ci`, `npm run build`, `npm run check`, or `npm pack` does not install, compile, test, or package Cloudflare. The root's `cloudflare:*` commands only forward into the package with `npm --prefix packages/runtime-cloudflare run ...`. + +`packages/runtime-cloudflare` remains in the monorepo but has its own packed `npm-shrinkwrap.json`, runtime and development dependencies, install-time stream-compression patch, TypeScript check, tests, Wrangler dry runs, package dry run, generators, and local gates. Its operational commands resolve only package-owned scripts, assets, dependencies, and configs, and local gates provision their locked Playwright Chromium before use. The packed artifact bundles the selected contract surface and dependency closure reproducibly compiled from `@automattic/wp-codebox-core` `0.26.2` at commit `d3fac4ad4e4bbf6dd457ea2cd46aeb1a081b217b` using that release's locked install. Root boundary tests compare every generated JavaScript and declaration byte and cover positive and negative contract behavior. Install it reproducibly with: + +```sh +npm ci --prefix packages/runtime-cloudflare --workspaces=false +``` + +Run both independent lanes with `npm run check:all`. diff --git a/homeboy.json b/homeboy.json index 70b517ec2..7f9a5ca30 100644 --- a/homeboy.json +++ b/homeboy.json @@ -15,7 +15,7 @@ "provider": "cloudflare-workers.deploy", "policy": { "wrangler": { - "binary": "./node_modules/.bin/wrangler", + "binary": "./packages/runtime-cloudflare/node_modules/.bin/wrangler", "config": "packages/runtime-cloudflare/wrangler.d1.jsonc", "config_ref": "packages/runtime-cloudflare/wrangler.d1.jsonc" }, @@ -24,7 +24,9 @@ "WORDPRESS_STATE_BUCKET", "WORDPRESS_STATE_DATABASE" ], - "predeploy_commands": [], + "predeploy_commands": [ + "npm ci --omit=dev --engine-strict --prefix packages/runtime-cloudflare --workspaces=false" + ], "timeout_ms": 300000 } }, diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 039aec31a..c922d1db4 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -10,7 +10,10 @@ "hasInstallScript": true, "license": "ISC", "workspaces": [ - "packages/*" + "packages/cli", + "packages/runtime-core", + "packages/runtime-playground", + "packages/wordpress-plugin" ], "dependencies": { "@automattic/wp-codebox-cli": "file:packages/cli", @@ -208,10 +211,8 @@ "wp-codebox": "packages/cli/dist/index.js" }, "devDependencies": { - "@cloudflare/workers-types": "^5.20260718.1", "@types/node": "^24.0.0", - "tsx": "^4.20.0", - "wrangler": "^4.127.1" + "tsx": "^4.20.0" } }, "node_modules/@automattic/wp-codebox-cli": { @@ -226,137 +227,6 @@ "resolved": "packages/runtime-playground", "link": true }, - "node_modules/@automattic/wp-codebox-runtime-cloudflare": { - "resolved": "packages/runtime-cloudflare", - "link": true - }, - "node_modules/@cloudflare/kv-asset-handler": { - "version": "0.5.0", - "dev": true, - "license": "MIT OR Apache-2.0", - "engines": { - "node": ">=22.0.0" - } - }, - "node_modules/@cloudflare/unenv-preset": { - "version": "2.16.1", - "dev": true, - "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.20260828.1", - "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-64/-/workerd-darwin-64-1.20260828.1.tgz", - "integrity": "sha512-CVd+xPhqUESg8Xhq09TZx0wl4FSirfJGOzvbPz2yHhBIvmNHFFQkSN3rkd7wEwnhQQk37Xi0/aD6ykPLJbmGiQ==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=16" - } - }, - "node_modules/@cloudflare/workerd-darwin-arm64": { - "version": "1.20260828.1", - "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-arm64/-/workerd-darwin-arm64-1.20260828.1.tgz", - "integrity": "sha512-5HDPXRM152vU5JveByGFk34X57TVyIsfp4cabepAf45DC0MKvm52ucJqAjW1h8bvW4X+zRw9GU35OHF9FEC9Ww==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=16" - } - }, - "node_modules/@cloudflare/workerd-linux-64": { - "version": "1.20260828.1", - "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-64/-/workerd-linux-64-1.20260828.1.tgz", - "integrity": "sha512-MQ1Ll9P7F72HHUKizbb7BlDfbY8fRoNMpbIpZoU6uKsSkneFICWSKv6UlgU9EQZ+w0i7TMa12iUgJ8l29eRI9A==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=16" - } - }, - "node_modules/@cloudflare/workerd-linux-arm64": { - "version": "1.20260828.1", - "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-arm64/-/workerd-linux-arm64-1.20260828.1.tgz", - "integrity": "sha512-FBTaUQ1xcU9jcp4OyBPcH8x0QiFvc1iuZL2GkD8zp2q1WyTVHYOptRDQUU+cuHjt0rQ2EIKVPBjahPxfa0joBw==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=16" - } - }, - "node_modules/@cloudflare/workerd-windows-64": { - "version": "1.20260828.1", - "resolved": "https://registry.npmjs.org/@cloudflare/workerd-windows-64/-/workerd-windows-64-1.20260828.1.tgz", - "integrity": "sha512-yvr77hC7dUbvK5K+SCg062kkPq3sx+drV1PcgHslzHDYcJBtT0V3X80qLE49LW1vq2svaeNmsVQS+vHsqWu8cQ==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=16" - } - }, - "node_modules/@cloudflare/workers-types": { - "version": "5.20260829.1", - "resolved": "https://registry.npmjs.org/@cloudflare/workers-types/-/workers-types-5.20260829.1.tgz", - "integrity": "sha512-SsH4G9+JePvrBmz+b5Dl67LQ9w2/ycoIpAPcAkfg2aEs2SEisQHk7/AY0TymSXEBbDbWgcBqoLe4hNcuY3CxWA==", - "dev": true, - "license": "MIT OR Apache-2.0" - }, - "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==", - "dev": true, - "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", @@ -1279,34 +1149,6 @@ "url": "https://opencollective.com/libvips" } }, - "node_modules/@jridgewell/resolve-uri": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", - "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", - "dev": true, - "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==", - "dev": true, - "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==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/resolve-uri": "^3.0.3", - "@jridgewell/sourcemap-codec": "^1.4.10" - } - }, "node_modules/@nodable/entities": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/@nodable/entities/-/entities-3.0.0.tgz", @@ -1914,12 +1756,12 @@ } }, "node_modules/@php-wasm/stream-compression": { - "version": "3.1.45", - "resolved": "https://registry.npmjs.org/@php-wasm/stream-compression/-/stream-compression-3.1.45.tgz", - "integrity": "sha512-zLU1AGNEg1tuwm93LHrL8OcV24LyNglTg/CXV5CVZiMPpg1wfIDHJy11qqjZM8iCIJk87qYQhkKOjTnGinAVDg==", + "version": "3.1.46", + "resolved": "https://registry.npmjs.org/@php-wasm/stream-compression/-/stream-compression-3.1.46.tgz", + "integrity": "sha512-+oUw4CPX52FgYXEh5C+MgJAg7Cy5OeaVuh7HnQR6oxb69nU63/r8tHTLV/WrWRyjBYh321uJzLV7Gg29qmiUtg==", "license": "GPL-2.0-or-later", "dependencies": { - "@php-wasm/util": "3.1.45" + "@php-wasm/util": "3.1.46" } }, "node_modules/@php-wasm/universal": { @@ -1957,20 +1799,6 @@ "npm": ">=10.2.3" } }, - "node_modules/@php-wasm/web-8-5": { - "version": "3.1.46", - "resolved": "https://registry.npmjs.org/@php-wasm/web-8-5/-/web-8-5-3.1.46.tgz", - "integrity": "sha512-j9wwlY6aNXuKBr4JPJzqE+vkM3Onk+byJsxLqaJs4U0gYDUBLr8CuKuVr+p13apSTUosConePYTAs0214aNxYA==", - "license": "GPL-2.0-or-later", - "dependencies": { - "@php-wasm/universal": "3.1.46", - "wasm-feature-detect": "1.8.0" - }, - "engines": { - "node": ">=20.10.0", - "npm": ">=10.2.3" - } - }, "node_modules/@php-wasm/web-service-worker": { "version": "3.1.46", "resolved": "https://registry.npmjs.org/@php-wasm/web-service-worker/-/web-service-worker-3.1.46.tgz", @@ -2023,55 +1851,6 @@ "node": ">=12" } }, - "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==", - "dev": true, - "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==", - "dev": true, - "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==", - "dev": true, - "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==", - "dev": true, - "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==", - "dev": true, - "license": "CC0-1.0" - }, "node_modules/@types/aws-lambda": { "version": "8.10.162", "resolved": "https://registry.npmjs.org/@types/aws-lambda/-/aws-lambda-8.10.162.tgz", @@ -2533,11 +2312,6 @@ "integrity": "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==", "license": "Apache-2.0" }, - "node_modules/blake3-wasm": { - "version": "2.1.5", - "dev": true, - "license": "MIT" - }, "node_modules/body-parser": { "version": "1.20.6", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.6.tgz", @@ -2944,16 +2718,6 @@ "node": ">= 0.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==", - "dev": true, - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/antfu" - } - }, "node_modules/es-define-property": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", @@ -3754,16 +3518,6 @@ "graceful-fs": "^4.1.11" } }, - "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==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/lodash.includes": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", @@ -3914,708 +3668,80 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/miniflare": { - "version": "5.20260828.0-alpha", - "resolved": "https://registry.npmjs.org/miniflare/-/miniflare-5.20260828.0-alpha.tgz", - "integrity": "sha512-6nbxhZEcz/UET3Y1OnYPsrAUjUmuFoib3ynUqteRdn1YnDxsLg8cwgZJZCk9QmtOmGzXwzXzgE/d/C0dJAPtVw==", - "dev": true, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/minimisted": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/minimisted/-/minimisted-2.0.1.tgz", + "integrity": "sha512-1oPjfuLQa2caorJUM8HV8lGgWCc0qqAO1MNv/k05G4qslmsndV/5WdNZrqCiyqiz3wohia2Ij2B7w2Dr7/IyrA==", "license": "MIT", "dependencies": { - "@cspotcode/source-map-support": "0.8.1", - "sharp": "0.35.2", - "undici": "7.29.0", - "workerd": "1.20260828.1", - "ws": "8.21.0", - "youch": "4.1.0-beta.10" - }, + "minimist": "^1.2.5" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/nan": { + "version": "2.28.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.28.0.tgz", + "integrity": "sha512-fTsDz99OTq2sVePhGdp4qQhggZFtKr64ZNVyVajRKtMOkJxYekplBh577PiJB12v/D3s2E5cGtOI45LWp6rnLQ==", + "license": "MIT" + }, + "node_modules/negotiator": { + "version": "0.6.4", + "license": "MIT", "engines": { - "node": ">=22.0.0" + "node": ">= 0.6" } }, - "node_modules/miniflare/node_modules/@img/sharp-darwin-arm64": { - "version": "0.35.2", - "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.35.2.tgz", - "integrity": "sha512-eEieHsMksAW4IiO5NzauESRl2D2qz3J/kwUxUrSfV06A93eEaRfMpHXyUb1mAqrR7i8U9A0GRqE9pjn6u1Jjpg==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "darwin" - ], + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "license": "MIT", "engines": { - "node": ">=20.9.0" + "node": ">= 0.4" }, "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-libvips-darwin-arm64": "1.3.1" + "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/miniflare/node_modules/@img/sharp-darwin-x64": { - "version": "0.35.2", - "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.35.2.tgz", - "integrity": "sha512-BaktuGPCeHJMARpodR8jK4uKiZrPAy9WrfQW0sdI37clracq8Bp01AYS3SZgi5FS/y5twa9t4+LIuuxQjqRrWw==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "darwin" - ], + "node_modules/object-keys": { + "version": "1.1.1", + "license": "MIT", "engines": { - "node": ">=20.9.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-libvips-darwin-x64": "1.3.1" + "node": ">= 0.4" } }, - "node_modules/miniflare/node_modules/@img/sharp-freebsd-wasm32": { - "version": "0.35.2", - "resolved": "https://registry.npmjs.org/@img/sharp-freebsd-wasm32/-/sharp-freebsd-wasm32-0.35.2.tgz", - "integrity": "sha512-YoAxdnd8hPUkvLHd3bWY+YA8nw3xM/RyRopYucNsWHVSan8NLVM3X2volsfoRDcXdUJPg6tXahSd7HXPK7lRnw==", - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "freebsd" - ], + "node_modules/octokit": { + "version": "3.2.2", + "license": "MIT", "dependencies": { - "@img/sharp-wasm32": "0.35.2" + "@octokit/app": "^14.0.2", + "@octokit/core": "^5.0.0", + "@octokit/oauth-app": "^6.0.0", + "@octokit/plugin-paginate-graphql": "^4.0.0", + "@octokit/plugin-paginate-rest": "11.4.4-cjs.2", + "@octokit/plugin-rest-endpoint-methods": "13.3.2-cjs.1", + "@octokit/plugin-retry": "^6.0.0", + "@octokit/plugin-throttling": "^8.0.0", + "@octokit/request-error": "^5.0.0", + "@octokit/types": "^13.0.0", + "@octokit/webhooks": "^12.3.1" }, "engines": { - "node": ">=20.9.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/miniflare/node_modules/@img/sharp-libvips-darwin-arm64": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.3.1.tgz", - "integrity": "sha512-4V/M3roRMTYjiwZY9IOVQOE8OyeCxFAkYmyZDrZl51uOKjibm3oeEJ4WAmLxutAfzFbC9jqUiPs2gbnGflH+7g==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "darwin" - ], - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/miniflare/node_modules/@img/sharp-libvips-darwin-x64": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.3.1.tgz", - "integrity": "sha512-c0/DxItpJv2+dGhgycJBBgotdqruGYDvA79drdh0MD1dFpy7JzJ/PlXwi1H4rFf0eTy8tgbI91aHDnZIceY3jQ==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "darwin" - ], - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/miniflare/node_modules/@img/sharp-libvips-linux-arm": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.3.1.tgz", - "integrity": "sha512-aGGy9aWzXgHBG7HNyQPWorZthlp7+x6fDRoPAQbGO3ThcttuTyKIx3NuSHb6zb4gBNq6/yNn9f1cy9nFKS/Vmg==", - "cpu": [ - "arm" - ], - "dev": true, - "libc": [ - "glibc" - ], - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "linux" - ], - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/miniflare/node_modules/@img/sharp-libvips-linux-arm64": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.3.1.tgz", - "integrity": "sha512-JznefmcK9j1JKPz8AkQDh89kjojubyfOasWBPKfzMIhPwsgDy9evpE/naJTXXXmghS1iFwR8u/kTwh/I2/+GCw==", - "cpu": [ - "arm64" - ], - "dev": true, - "libc": [ - "glibc" - ], - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "linux" - ], - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/miniflare/node_modules/@img/sharp-libvips-linux-ppc64": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.3.1.tgz", - "integrity": "sha512-1EkwGNCZk6iWNCMWqrvdJ+r1j0PT1zIz60CNPhYnJlK/zyeWqlsPZIe+ocBVqPF8k/Ssee/NCk+tE9Ryrko6ng==", - "cpu": [ - "ppc64" - ], - "dev": true, - "libc": [ - "glibc" - ], - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "linux" - ], - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/miniflare/node_modules/@img/sharp-libvips-linux-riscv64": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-riscv64/-/sharp-libvips-linux-riscv64-1.3.1.tgz", - "integrity": "sha512-Ilays+w2bXdnxzxtQdmXR62u8o8GYa3eL4+Gr+1KiE4xperMZUslRaVPJwwPkzlHEjGfXAfRVAa/7CYCtSqsBw==", - "cpu": [ - "riscv64" - ], - "dev": true, - "libc": [ - "glibc" - ], - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "linux" - ], - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/miniflare/node_modules/@img/sharp-libvips-linux-s390x": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.3.1.tgz", - "integrity": "sha512-VfBwVHQTbRoj4XlpA/KLZ7ltgMpz+4WSejFzQ+GnoImjo1PtEJ59QB2qR1xQEeRPYIkNrPIm2L4cICMvz4C2ew==", - "cpu": [ - "s390x" - ], - "dev": true, - "libc": [ - "glibc" - ], - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "linux" - ], - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/miniflare/node_modules/@img/sharp-libvips-linux-x64": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.3.1.tgz", - "integrity": "sha512-+c8ukgwU62DS54nCAjw7keOfHUkmr0B5QHEdcOqRnodF/MNXJbVI8Eopoj4B/0H8Asr65I+A4Amrn7a85/md6A==", - "cpu": [ - "x64" - ], - "dev": true, - "libc": [ - "glibc" - ], - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "linux" - ], - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/miniflare/node_modules/@img/sharp-libvips-linuxmusl-arm64": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.3.1.tgz", - "integrity": "sha512-qlKb/pwbkAi1WMsJrYHk7CuDrd12s27U2QnRhFYUoJNrRCmkosMTttuRFat/DDB3IlDm5qE1TJgZ4JDnHX8Ldw==", - "cpu": [ - "arm64" - ], - "dev": true, - "libc": [ - "musl" - ], - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "linux" - ], - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/miniflare/node_modules/@img/sharp-libvips-linuxmusl-x64": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.3.1.tgz", - "integrity": "sha512-yO21HwoUVLN8Qa+/SBjQLMYwBWAVJjeGPNe+hc0OUeMeifEtJqu5a1c4HayE1nNpDih9y3/KkoltfkDodmKAlg==", - "cpu": [ - "x64" - ], - "dev": true, - "libc": [ - "musl" - ], - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "linux" - ], - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/miniflare/node_modules/@img/sharp-linux-arm": { - "version": "0.35.2", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.35.2.tgz", - "integrity": "sha512-SE4kzF2mepn6z+6E7L6lsV8FzuLL6IPQdyX8ZiwROAG/G8td+hP/m7FsFPwidtrF19gvajuC9l6TxAVcsA4S7A==", - "cpu": [ - "arm" - ], - "dev": true, - "libc": [ - "glibc" - ], - "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.1" - } - }, - "node_modules/miniflare/node_modules/@img/sharp-linux-arm64": { - "version": "0.35.2", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.35.2.tgz", - "integrity": "sha512-af12Pnd0ZGu2HfP8NayB0kk6eC/lrfbQE6HlR4jD+34wdJ1Vw9TF6TMn6ZvffT+WgqVsl0hRbmNvz2u/23VmwA==", - "cpu": [ - "arm64" - ], - "dev": true, - "libc": [ - "glibc" - ], - "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.1" - } - }, - "node_modules/miniflare/node_modules/@img/sharp-linux-ppc64": { - "version": "0.35.2", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-ppc64/-/sharp-linux-ppc64-0.35.2.tgz", - "integrity": "sha512-hYSBm7zcNtDCozCxQHYZJiu63b/bXsgRZuOxCIBZsStMM9Vap47iFHdbX4kCvQsblPB/k+clhELpdQJHQLSHvg==", - "cpu": [ - "ppc64" - ], - "dev": true, - "libc": [ - "glibc" - ], - "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.1" - } - }, - "node_modules/miniflare/node_modules/@img/sharp-linux-riscv64": { - "version": "0.35.2", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-riscv64/-/sharp-linux-riscv64-0.35.2.tgz", - "integrity": "sha512-qQt0Kc13+Hoan/Awq/qMSQw3L+RI1NCRPgD5cUJ/1WSSmIoysLOc72jlRM3E0OHN9Yr313jgeQ2T+zW+F03QFA==", - "cpu": [ - "riscv64" - ], - "dev": true, - "libc": [ - "glibc" - ], - "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.1" - } - }, - "node_modules/miniflare/node_modules/@img/sharp-linux-s390x": { - "version": "0.35.2", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.35.2.tgz", - "integrity": "sha512-E4fLLfRPzDLlEeDaTzI98OFLcv++WL5ChLLMwPoVd0CIoZQqupBSNbOisPL5am9XsbQ9T84+iiMpUvbFtkunbA==", - "cpu": [ - "s390x" - ], - "dev": true, - "libc": [ - "glibc" - ], - "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.1" - } - }, - "node_modules/miniflare/node_modules/@img/sharp-linux-x64": { - "version": "0.35.2", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.35.2.tgz", - "integrity": "sha512-gi0zFJJRLswfCZmHtJdikXPOc5u7qamSOS3NHedLqLd4W8Q0NqjdBr6TTRIgsfFjqfTsHFgdfvJ9LwqSgcHiAA==", - "cpu": [ - "x64" - ], - "dev": true, - "libc": [ - "glibc" - ], - "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.1" - } - }, - "node_modules/miniflare/node_modules/@img/sharp-linuxmusl-arm64": { - "version": "0.35.2", - "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.35.2.tgz", - "integrity": "sha512-siWbOW1u6HFnFLrp0waKyW7VEf7jYvcDWdrXEFa8AkdAQgEvuu5Fz8/Y70w9EeqAdwDtfU012BhEHHaDqvQNzg==", - "cpu": [ - "arm64" - ], - "dev": true, - "libc": [ - "musl" - ], - "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.1" - } - }, - "node_modules/miniflare/node_modules/@img/sharp-linuxmusl-x64": { - "version": "0.35.2", - "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.35.2.tgz", - "integrity": "sha512-YBqMMcjDi4QGYiSn4vNOYBhmlC4z5AXqkOUUqI2e0AFA4urNv4ESgOgwNl3K+4etQhha0twXlzeF20bbULm9Yg==", - "cpu": [ - "x64" - ], - "dev": true, - "libc": [ - "musl" - ], - "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.1" - } - }, - "node_modules/miniflare/node_modules/@img/sharp-wasm32": { - "version": "0.35.2", - "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.35.2.tgz", - "integrity": "sha512-Mrv4JQNYVQ94xH+jzZ9r+gowleN8mv2FTgKT+PI6bx5C0G8TdNYndu161pg2i7uoBwxy2ImPMHrJOM2LZef7Bw==", - "dev": true, - "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT", - "optional": true, - "dependencies": { - "@emnapi/runtime": "^1.11.1" - }, - "engines": { - "node": ">=20.9.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/miniflare/node_modules/@img/sharp-webcontainers-wasm32": { - "version": "0.35.2", - "resolved": "https://registry.npmjs.org/@img/sharp-webcontainers-wasm32/-/sharp-webcontainers-wasm32-0.35.2.tgz", - "integrity": "sha512-QNV27pxs9wpApEiCfvHM1RDoP1w1+2KrUWWDPEhEwg+latvOrfuhWrHWZKwdSFwU6jh3myjw/yOCRsUIuOft3g==", - "cpu": [ - "wasm32" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "dependencies": { - "@img/sharp-wasm32": "0.35.2" - }, - "engines": { - "node": ">=20.9.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/miniflare/node_modules/@img/sharp-win32-arm64": { - "version": "0.35.2", - "resolved": "https://registry.npmjs.org/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.35.2.tgz", - "integrity": "sha512-BiVRYc/t6/Vl3e1hBx0hugG4oN9Pydf4fgMSpxTQJmwGUg/YoXTWHiFeRymHfCZzifxu4F4rpk/I67D0LQ20wQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "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/miniflare/node_modules/@img/sharp-win32-ia32": { - "version": "0.35.2", - "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.35.2.tgz", - "integrity": "sha512-YYEhx9PImCC7T0tI8JDMi4DB9LwLCXCU5OWNYEXAxh5Q1ShKkyC6byxzoBJ3gEFDnH2lQckWuDe70G7mB2XJog==", - "cpu": [ - "ia32" - ], - "dev": true, - "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/miniflare/node_modules/@img/sharp-win32-x64": { - "version": "0.35.2", - "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.35.2.tgz", - "integrity": "sha512-imoOyBcoM/iiUr4J6VPpCNjPnjvP/Gks95898yB8YqoGGYmHYbOyCuNv9FMhFgtaiHFGbHW8bxKqRV6VjtXThQ==", - "cpu": [ - "x64" - ], - "dev": true, - "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/miniflare/node_modules/sharp": { - "version": "0.35.2", - "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.35.2.tgz", - "integrity": "sha512-FVtFjtBCMiJS6yb5CX7Sop45WFMpeGw6oRKuJnXYgf/f1ms/D7LE/ZUSNxnW7rZ/dbslQWYkoqFHGPaDBtaK4w==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "@img/colour": "^1.1.0", - "detect-libc": "^2.1.2", - "semver": "^7.8.4" - }, - "engines": { - "node": ">=20.9.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-darwin-arm64": "0.35.2", - "@img/sharp-darwin-x64": "0.35.2", - "@img/sharp-freebsd-wasm32": "0.35.2", - "@img/sharp-libvips-darwin-arm64": "1.3.1", - "@img/sharp-libvips-darwin-x64": "1.3.1", - "@img/sharp-libvips-linux-arm": "1.3.1", - "@img/sharp-libvips-linux-arm64": "1.3.1", - "@img/sharp-libvips-linux-ppc64": "1.3.1", - "@img/sharp-libvips-linux-riscv64": "1.3.1", - "@img/sharp-libvips-linux-s390x": "1.3.1", - "@img/sharp-libvips-linux-x64": "1.3.1", - "@img/sharp-libvips-linuxmusl-arm64": "1.3.1", - "@img/sharp-libvips-linuxmusl-x64": "1.3.1", - "@img/sharp-linux-arm": "0.35.2", - "@img/sharp-linux-arm64": "0.35.2", - "@img/sharp-linux-ppc64": "0.35.2", - "@img/sharp-linux-riscv64": "0.35.2", - "@img/sharp-linux-s390x": "0.35.2", - "@img/sharp-linux-x64": "0.35.2", - "@img/sharp-linuxmusl-arm64": "0.35.2", - "@img/sharp-linuxmusl-x64": "0.35.2", - "@img/sharp-webcontainers-wasm32": "0.35.2", - "@img/sharp-win32-arm64": "0.35.2", - "@img/sharp-win32-ia32": "0.35.2", - "@img/sharp-win32-x64": "0.35.2" - } - }, - "node_modules/minimist": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", - "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/minimisted": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/minimisted/-/minimisted-2.0.1.tgz", - "integrity": "sha512-1oPjfuLQa2caorJUM8HV8lGgWCc0qqAO1MNv/k05G4qslmsndV/5WdNZrqCiyqiz3wohia2Ij2B7w2Dr7/IyrA==", - "license": "MIT", - "dependencies": { - "minimist": "^1.2.5" - } - }, - "node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "license": "MIT" - }, - "node_modules/nan": { - "version": "2.28.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.28.0.tgz", - "integrity": "sha512-fTsDz99OTq2sVePhGdp4qQhggZFtKr64ZNVyVajRKtMOkJxYekplBh577PiJB12v/D3s2E5cGtOI45LWp6rnLQ==", - "license": "MIT" - }, - "node_modules/negotiator": { - "version": "0.6.4", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/object-inspect": { - "version": "1.13.4", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", - "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/object-keys": { - "version": "1.1.1", - "license": "MIT", - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/octokit": { - "version": "3.2.2", - "license": "MIT", - "dependencies": { - "@octokit/app": "^14.0.2", - "@octokit/core": "^5.0.0", - "@octokit/oauth-app": "^6.0.0", - "@octokit/plugin-paginate-graphql": "^4.0.0", - "@octokit/plugin-paginate-rest": "11.4.4-cjs.2", - "@octokit/plugin-rest-endpoint-methods": "13.3.2-cjs.1", - "@octokit/plugin-retry": "^6.0.0", - "@octokit/plugin-throttling": "^8.0.0", - "@octokit/request-error": "^5.0.0", - "@octokit/types": "^13.0.0", - "@octokit/webhooks": "^12.3.1" - }, - "engines": { - "node": ">= 18" + "node": ">= 18" } }, "node_modules/on-finished": { @@ -4735,11 +3861,6 @@ "integrity": "sha512-A/AGNMFN3c8bOlvV9RreMdrv7jsmF9XIfDeCd87+I8RNg6s78BhJxMu69NEMHBSJFxKidViTEdruRwEk/WIKqA==", "license": "MIT" }, - "node_modules/pathe": { - "version": "2.0.3", - "dev": true, - "license": "MIT" - }, "node_modules/picomatch": { "version": "2.3.2", "license": "MIT", @@ -5307,19 +4428,6 @@ "anynum": "^1.0.1" } }, - "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==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/chalk/supports-color?sponsor=1" - } - }, "node_modules/tmp": { "version": "0.2.7", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.7.tgz", @@ -5445,28 +4553,10 @@ "node": ">=14.17" } }, - "node_modules/undici": { - "version": "7.29.0", - "resolved": "https://registry.npmjs.org/undici/-/undici-7.29.0.tgz", - "integrity": "sha512-IDxfleLmmbSskfWSUATiN1nfn2rDuvnMOqb5CWR92iIfojA0Ud+ulOAAEQ57LPr9rWmsreUyf5lwyao+7GNNVw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=20.18.1" - } - }, "node_modules/undici-types": { "version": "7.26.0", "license": "MIT" }, - "node_modules/unenv": { - "version": "2.0.0-rc.24", - "dev": true, - "license": "MIT", - "dependencies": { - "pathe": "^2.0.3" - } - }, "node_modules/universal-github-app-jwt": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/universal-github-app-jwt/-/universal-github-app-jwt-1.2.0.tgz", @@ -5566,84 +4656,10 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/workerd": { - "version": "1.20260828.1", - "resolved": "https://registry.npmjs.org/workerd/-/workerd-1.20260828.1.tgz", - "integrity": "sha512-pB9yvt0kkwZDAGZHmpY59r0o3hM0DzdW6BJERqwZOhunZ3ssOyDSgQxOQer2cSZW4YCFeOTIQYN1qwhK5wv/Cw==", - "dev": true, - "hasInstallScript": true, - "license": "Apache-2.0", - "bin": { - "workerd": "bin/workerd" - }, - "engines": { - "node": ">=16" - }, - "optionalDependencies": { - "@cloudflare/workerd-darwin-64": "1.20260828.1", - "@cloudflare/workerd-darwin-arm64": "1.20260828.1", - "@cloudflare/workerd-linux-64": "1.20260828.1", - "@cloudflare/workerd-linux-arm64": "1.20260828.1", - "@cloudflare/workerd-windows-64": "1.20260828.1" - } - }, "node_modules/wp-codebox-wordpress-plugin": { "resolved": "packages/wordpress-plugin", "link": true }, - "node_modules/wrangler": { - "version": "4.127.1", - "resolved": "https://registry.npmjs.org/wrangler/-/wrangler-4.127.1.tgz", - "integrity": "sha512-OzsiNgaI8i681L/+KnAKc+uEZ5D57xK5JuNvCOpRKICF4/5Q3Cu1oTGuUiT/f3GDUqQb3gzXNT0tfOHGMEtknw==", - "dev": true, - "license": "MIT OR Apache-2.0", - "dependencies": { - "@cloudflare/kv-asset-handler": "0.5.0", - "@cloudflare/unenv-preset": "2.16.1", - "blake3-wasm": "2.1.5", - "esbuild": "0.28.1", - "miniflare": "5.20260828.0-alpha", - "path-to-regexp": "6.3.0", - "unenv": "2.0.0-rc.24", - "workerd": "1.20260828.1" - }, - "bin": { - "cf-wrangler": "bin/cf-wrangler.js", - "wrangler": "bin/wrangler.js", - "wrangler2": "bin/wrangler.js" - }, - "engines": { - "node": ">=22.0.0" - }, - "optionalDependencies": { - "fsevents": "2.3.3" - }, - "peerDependencies": { - "@cloudflare/workers-types": "^5.20260828.1" - }, - "peerDependenciesMeta": { - "@cloudflare/workers-types": { - "optional": true - } - } - }, - "node_modules/wrangler/node_modules/fsevents": { - "version": "2.3.3", - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, - "node_modules/wrangler/node_modules/path-to-regexp": { - "version": "6.3.0", - "dev": true, - "license": "MIT" - }, "node_modules/wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", @@ -5770,45 +4786,6 @@ "node": ">=12" } }, - "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==", - "dev": true, - "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==", - "dev": true, - "license": "MIT", - "dependencies": { - "@poppinss/exception": "^1.2.2", - "error-stack-parser-es": "^1.0.5" - } - }, - "node_modules/youch/node_modules/cookie": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-1.1.1.tgz", - "integrity": "sha512-ei8Aos7ja0weRpFzJnEA9UHJ/7XQmqglbRwnf2ATjcB9Wq874VKH9kfjjirM6UhU2/E5fFYadylyhFldcqSidQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, "node_modules/zstddec": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/zstddec/-/zstddec-0.2.0.tgz", @@ -5826,17 +4803,6 @@ "wp-codebox": "dist/index.js" } }, - "packages/runtime-cloudflare": { - "name": "@automattic/wp-codebox-runtime-cloudflare", - "version": "0.12.27", - "dependencies": { - "@automattic/wp-codebox-core": "file:../runtime-core", - "@php-wasm/stream-compression": "3.1.45", - "@php-wasm/universal": "3.1.46", - "@php-wasm/web-8-5": "3.1.46", - "@wp-playground/wordpress": "3.1.46" - } - }, "packages/runtime-core": { "name": "@automattic/wp-codebox-core", "version": "0.26.2", diff --git a/package.json b/package.json index b619c0920..e6d8cd027 100644 --- a/package.json +++ b/package.json @@ -90,19 +90,22 @@ "scripts": { "build": "node ./node_modules/typescript/bin/tsc -b packages/runtime-core packages/runtime-playground packages/cli && node scripts/ensure-cli-bin-executable.mjs && tsx scripts/write-cli-build-provenance.ts", "build:release": "node ./node_modules/typescript/bin/tsc -b --force packages/runtime-core packages/runtime-playground packages/cli && node scripts/ensure-cli-bin-executable.mjs && tsx scripts/write-cli-build-provenance.ts", - "cloudflare:dry-run": "npm exec -- wrangler deploy --dry-run --config packages/runtime-cloudflare/wrangler.jsonc", - "cloudflare:dry-run:d1": "npm exec -- wrangler deploy --dry-run --config packages/runtime-cloudflare/wrangler.d1.jsonc", - "cloudflare:dry-run:control": "npm exec -- wrangler deploy --dry-run --config packages/runtime-cloudflare/wrangler.control.jsonc", - "cloudflare:dry-run:public-reader": "npm exec -- wrangler deploy --dry-run --config packages/runtime-cloudflare/wrangler.public-reader.jsonc", - "cloudflare:local-gate": "node scripts/cloudflare-local-gate.mjs", - "cloudflare:local-gate:d1": "node scripts/cloudflare-local-gate.mjs --coordinator=d1", - "cloudflare:local-gate:provisioning": "node scripts/cloudflare-local-gate.mjs --coordinator=d1 --public-provisioning", - "cloudflare:remote-gate:principal-credentials": "node scripts/cloudflare-remote-principal-credential-gate.mjs", + "cloudflare:build": "npm --prefix packages/runtime-cloudflare run build", + "cloudflare:check": "npm --prefix packages/runtime-cloudflare run check", + "cloudflare:package-dry-run": "npm --prefix packages/runtime-cloudflare run package:dry-run", + "cloudflare:dry-run": "npm --prefix packages/runtime-cloudflare run dry-run", + "cloudflare:dry-run:d1": "npm --prefix packages/runtime-cloudflare run dry-run:d1", + "cloudflare:dry-run:control": "npm --prefix packages/runtime-cloudflare run dry-run:control", + "cloudflare:dry-run:public-reader": "npm --prefix packages/runtime-cloudflare run dry-run:public-reader", + "cloudflare:local-gate": "npm --prefix packages/runtime-cloudflare run local-gate", + "cloudflare:local-gate:d1": "npm --prefix packages/runtime-cloudflare run local-gate:d1", + "cloudflare:local-gate:provisioning": "npm --prefix packages/runtime-cloudflare run local-gate:provisioning", + "cloudflare:remote-gate:principal-credentials": "npm --prefix packages/runtime-cloudflare run remote-gate:principal-credentials", "postinstall": "node scripts/apply-development-patches.mjs", - "generate:cloudflare-wordpress-runtime-corpus": "tsx scripts/generate-cloudflare-wordpress-runtime-corpus.ts", - "provision:cloudflare-wordpress-runtime-corpus": "node scripts/provision-cloudflare-wordpress-runtime-corpus.mjs", - "provision:cloudflare-d1-coordinator": "node scripts/provision-cloudflare-d1-coordinator.mjs", - "operator:cloudflare-principal-credential": "tsx scripts/operator-cloudflare-principal-credential.ts", + "generate:cloudflare-wordpress-runtime-corpus": "npm --prefix packages/runtime-cloudflare run generate:wordpress-runtime-corpus", + "provision:cloudflare-wordpress-runtime-corpus": "npm --prefix packages/runtime-cloudflare run provision:wordpress-runtime-corpus", + "provision:cloudflare-d1-coordinator": "npm --prefix packages/runtime-cloudflare run provision:d1-coordinator", + "operator:cloudflare-principal-credential": "npm --prefix packages/runtime-cloudflare run operator:principal-credential", "prepare": "npm run build:release", "package:wordpress-plugin": "tsx scripts/build-wordpress-plugin-zip.ts", "release:package": "tsx scripts/package-release-artifact.ts", @@ -114,16 +117,17 @@ "wp-codebox:source": "node bin/wp-codebox-source.mjs", "generate:browser-fanout-aggregation-runtime": "tsx scripts/generate-browser-fanout-aggregation-runtime.ts", "generate:fanout-aggregation-contract": "tsx scripts/generate-fanout-aggregation-contract-fixture.ts", - "generate:cloudflare-mdi-runtime-bundle": "node scripts/build-cloudflare-mdi-runtime-bundle.mjs", - "generate:cloudflare-canonical-mdi-seed": "npm run generate:cloudflare-mdi-runtime-bundle && php scripts/build-cloudflare-canonical-mdi-seed.php", + "generate:cloudflare-mdi-runtime-bundle": "npm --prefix packages/runtime-cloudflare run generate:mdi-runtime-bundle", + "generate:cloudflare-canonical-mdi-seed": "npm --prefix packages/runtime-cloudflare run generate:canonical-mdi-seed", "smoke": "tsx scripts/run-smoke.ts", "test:redaction": "tsx tests/redaction.test.ts", "test:browser-preview-routing": "tsx --test tests/browser-preview-routing.test.ts", "test:browser-routed-command-security": "tsx --test tests/browser-routed-command-security.test.ts", - "test:cloudflare-runtime": "node --test tests/cloudflare-d1-provisioner.test.mjs tests/cloudflare-principal-credential-operator.test.mjs tests/cloudflare-remote-principal-credential-gate.test.mjs && tsx tests/cloudflare-site-context.test.ts && tsx tests/cloudflare-coordinator-site-partitioning.test.ts && tsx tests/cloudflare-d1-operation-repository.test.ts && tsx tests/cloudflare-allocation-lifecycle.test.ts && tsx tests/cloudflare-principal-credential-repository.test.ts && tsx tests/cloudflare-provisioning-api.test.ts && tsx tests/cloudflare-queue-batch.test.ts && tsx tests/cloudflare-phase-trace.test.ts && tsx tests/cloudflare-runtime.test.ts && tsx tests/cloudflare-public-reader.test.ts && node ./node_modules/typescript/bin/tsc -p packages/runtime-cloudflare --noEmit", - "test:cloudflare-queue": "tsx tests/cloudflare-queue-batch.test.ts && tsx tests/cloudflare-d1-operation-repository.test.ts && node ./node_modules/typescript/bin/tsc -p packages/runtime-cloudflare --noEmit", - "test:cloudflare-principal-credentials": "node --test tests/cloudflare-principal-credential-operator.test.mjs && tsx tests/cloudflare-principal-credential-repository.test.ts && tsx tests/cloudflare-provisioning-api.test.ts", - "test:cloudflare-remote-principal-credential-gate": "node --test tests/cloudflare-remote-principal-credential-gate.test.mjs", + "test:cloudflare-runtime": "npm --prefix packages/runtime-cloudflare run test", + "test:cloudflare-queue": "npm --prefix packages/runtime-cloudflare run test:queue", + "test:cloudflare-principal-credentials": "npm --prefix packages/runtime-cloudflare run test:principal-credentials", + "test:cloudflare-remote-principal-credential-gate": "npm --prefix packages/runtime-cloudflare run test:remote-principal-credential-gate", + "test:runtime-package-boundaries": "node --test tests/derive-cloudflare-core-contract-atomic.test.mjs && node tests/runtime-package-boundaries.test.mjs", "test:agent-task-contracts": "tsx tests/agent-task-contracts.test.ts && tsx tests/agent-task-canonical-evidence.test.ts && npm run test:agent-task-workflow-interface && npm run test:runtime-sources-materialization && tsx tests/agent-task-reusable-workflow.test.ts", "test:agent-task-workflow-interface": "tsx tests/run-agent-task-reusable-workflow-interface.test.ts", "test:agent-task-runtime-package-staging": "tsx tests/agent-task-runtime-package-staging.test.ts", @@ -169,16 +173,18 @@ "test:docs-boundary-language": "tsx tests/docs-boundary-language.test.ts", "test:production-boundary-enforcement": "tsx tests/production-boundary-enforcement.test.ts", "test:browser-viewport-replay": "node ./node_modules/typescript/bin/tsc -b packages/runtime-core --force && node ./node_modules/typescript/bin/tsc -b packages/runtime-playground packages/cli --force && node scripts/ensure-cli-bin-executable.mjs && tsx tests/browser-viewport-replay.test.ts", - "check": "npm run smoke -- --group=check" + "check": "npm run smoke -- --group=check", + "check:all": "npm run check && npm run cloudflare:check" }, "workspaces": [ - "packages/*" + "packages/cli", + "packages/runtime-core", + "packages/runtime-playground", + "packages/wordpress-plugin" ], "devDependencies": { - "@cloudflare/workers-types": "^5.20260718.1", "@types/node": "^24.0.0", - "tsx": "^4.20.0", - "wrangler": "^4.127.1" + "tsx": "^4.20.0" }, "description": "**WP Codebox unlocks secure WordPress code execution from anywhere.** Run agents, accept untrusted patches, evaluate plugins, reproduce bugs, or experiment freely — every sandbox is a disposable WordPress Playground that can't touch its caller. Your host can be a CLI, CI job, mobile app, Node service, WordPress plugin, or anything else that can shell out or hit an API.", "main": "index.js", @@ -380,7 +386,6 @@ "yargs-parser": "^21.1.1" }, "overrides": { - "@php-wasm/stream-compression": "3.1.45", "@php-wasm/util": "3.1.46", "ajv": "^8.20.0", "express": "^4.22.2", diff --git a/packages/runtime-cloudflare/README.md b/packages/runtime-cloudflare/README.md index 837aa40c8..b125f8740 100644 --- a/packages/runtime-cloudflare/README.md +++ b/packages/runtime-cloudflare/README.md @@ -2,9 +2,15 @@ This candidate integration for [wp-codebox#1838](https://github.com/Automattic/wp-codebox/issues/1838) runs WordPress through PHP-WASM and Playground in Cloudflare Workers. +## Package Lane + +This runtime owns a packed `npm-shrinkwrap.json`, dependencies, build, tests, Wrangler dry runs, package dry run, generators, and local gates. Its scripts resolve package-relative implementations, assets, configs, and dependencies; none require root `node_modules` or root build output. Each local gate provisions the exact Chromium revision owned by its locked Playwright dependency before running visual parity. The archive/profile/result contract surface and its dependency closure are reproducibly compiled from `@automattic/wp-codebox-core@0.26.2` at commit `d3fac4ad4e4bbf6dd457ea2cd46aeb1a081b217b` using that release's locked install; repository boundary tests compare every JavaScript and declaration byte and exercise positive and negative behavior. From this package directory, install and verify it with `npm ci --workspaces=false` and `npm run check`. See [runtime package lanes](https://github.com/Automattic/wp-codebox/blob/main/docs/runtime-package-lanes.md) for the repository package template and aggregate command. + +The package-owned `patches/@php-wasm+stream-compression+3.1.45.patch` is the built output of WordPress Playground PR [#4110](https://github.com/WordPress/wordpress-playground/pull/4110) at commit `afea9c042999c65f5b43bc049ca4b2bea9d8b361`. Its install hook applies the repaired bounded Range decoder required by this runtime. Remove the patch, install hook, and override after a published Playground package contains the same change. + ## Runtime Architecture -The optional `public-reader-worker.ts` entrypoint is an R2-only immutable publication reader. It never imports PHP-WASM, SQLite, D1, revision coordinators, or mutation execution. It serves only complete publication snapshots, WordPress core assets, and revision-bound `wp-content` or uploads; missing or building publication state returns a bounded response rather than falling through to dynamic WordPress. Build it without deployment using `npm run cloudflare:dry-run:public-reader`. +The optional `public-reader-worker.ts` entrypoint is an R2-only immutable publication reader. It never imports PHP-WASM, SQLite, D1, revision coordinators, or mutation execution. It serves only complete publication snapshots, WordPress core assets, and revision-bound `wp-content` or uploads; missing or building publication state returns a bounded response rather than falling through to dynamic WordPress. Build it without deployment using `npm run dry-run:public-reader`. The `worker-control.ts` entrypoint is a PHP-free provisioning and lifecycle control plane. It serves only `/v1`, owns D1/R2 API state, and produces durable execution messages without importing PHP-WASM, Playground, WordPress archives, SQLite seeds, runtime ZIPs, revision coordinators, or mutation execution. During mixed-version routing, `worker-d1.ts` retains its existing `/v1` path; callers can move to the control Worker without changing API, persisted-data, credential, or queue-message contracts. @@ -12,7 +18,7 @@ The execution Worker runs PHP-WASM and WordPress. Runtime behavior depends on th On cold start, the entry Worker uses the acquired pointer to rebuild PHP-WASM's disposable SQLite index from canonical MDI Markdown and JSON files. A missing pointer materializes the packaged canonical MDI seed and boots one PHP-WASM primary runtime. The build-time PHP CLI generator creates that archive from `wordpress-install-seed.sqlite` through MDI's public `bootstrap_existing_cache()` API, validates its pinned MDI revision and input digest, and never packages SQLite. The runtime updates `siteurl` and `home` through WordPress APIs using the request origin and sets the admin password from `WORDPRESS_ADMIN_PASSWORD`; only WordPress's password hash is canonical. Bootstrap persists and CAS-promotes this mutation before serving the next request. -Canonical browser, health, and mutation boots require the separately managed `WORDPRESS_AUTH_SECRET` Worker secret. The entry Worker derives the eight WordPress auth keys and salts from that secret with a versioned, site-scoped SHA-256 domain separator before `wp-load.php`. It never logs, persists, or returns the secret or derived values. Configure it independently from the bootstrap password with `wrangler secret put WORDPRESS_AUTH_SECRET --config packages/runtime-cloudflare/wrangler.jsonc`; rotating `WORDPRESS_ADMIN_PASSWORD` does not rotate authentication salts or invalidate sessions. +Canonical browser, health, and mutation boots require the separately managed `WORDPRESS_AUTH_SECRET` Worker secret. The entry Worker derives the eight WordPress auth keys and salts from that secret with a versioned, site-scoped SHA-256 domain separator before `wp-load.php`. It never logs, persists, or returns the secret or derived values. Configure it independently from the bootstrap password with `npm exec -- wrangler secret put WORDPRESS_AUTH_SECRET --config wrangler.jsonc`; rotating `WORDPRESS_ADMIN_PASSWORD` does not rotate authentication salts or invalidate sessions. After each mutating HTTP request, the entry runtime invokes MDI's explicit request-boundary flush, collects canonical files, stores immutable content-addressed R2 objects and a revision manifest, then commits the new pointer through the held lease. GET, HEAD, and asset requests release without promotion. Failed requests abort their leases; stale leases recover by token/version/expiry checks. The entry isolate can cache one runtime only for the exact acquired pointer revision and exits it after promotion or when another isolate advances the pointer. It does not persist SQLite. Existing manifests are reused when canonical file hashes have not changed. Canonical mutations such as login session-token writes do not rebuild a publication unless WordPress reports explicit affected routes or a global publication change. @@ -32,7 +38,7 @@ A minute Cloudflare Cron Trigger first drains at most one publication route, or The bundled MDI source is pinned to immutable commit `bf6d434d1673fdd86d777501f7eaec292d32ad1f`, including [MDI PR #141](https://github.com/Automattic/markdown-database-integration/pull/141). The bundle generator, worker provenance, and source-contract test use the same revision. -WordPress server files, browser assets, and pinned runtime dependencies are separate deployment artifacts, never Worker-module imports. `generate:cloudflare-wordpress-runtime-corpus` emits a deterministic server ZIP containing only `isWordPressRuntimeFile()` entries, one concatenated browser-asset blob containing the complete supported `wp-admin`, `wp-includes`, and bundled-theme surface, and the pinned SQLite integration ZIP. Checked-in manifests record content-addressed R2 keys, hashes, budgets, provenance, and each browser asset's exact byte range. Cold boot validates and streams the server ZIP into PHP MEMFS while loading SQLite integration from R2. Browser requests use one bounded R2 range read, validate the selected bytes, and populate an immutable artifact-versioned Worker cache. Runtime requests never fetch WordPress or SQLite integration release archives from third-party origins. +WordPress server files, browser assets, and pinned runtime dependencies are separate deployment artifacts, never Worker-module imports. `generate:wordpress-runtime-corpus` emits a deterministic server ZIP containing only `isWordPressRuntimeFile()` entries, one concatenated browser-asset blob containing the complete supported `wp-admin`, `wp-includes`, and bundled-theme surface, and the pinned SQLite integration ZIP. Checked-in manifests record content-addressed R2 keys, hashes, budgets, provenance, and each browser asset's exact byte range. Cold boot validates and streams the server ZIP into PHP MEMFS while loading SQLite integration from R2. Browser requests use one bounded R2 range read, validate the selected bytes, and populate an immutable artifact-versioned Worker cache. Runtime requests never fetch WordPress or SQLite integration release archives from third-party origins. Canonical Cloudflare boots patch only the assembled PHP MEMFS copy of `/wordpress/wp-settings.php` after the R2 WordPress corpus is materialized and before WordPress executes. The disabled-cron scheduling policy requires exactly one canonical `do_action( 'init' );` needle and fails closed otherwise. When `DISABLE_WP_CRON` is true, it removes only core's `wp_cron`, `wp_schedule_delete_old_privacy_export_files`, and `wp_schedule_update_checks` callbacks through public `remove_action()` before executing the original `init` call once. This prevents browser requests from recreating cron work outside the explicit scheduled-Worker transaction. @@ -64,19 +70,19 @@ SSI is extracted only for import requests, so normal browser, mutation, publicat ## Principal Credential Operations -`npm run operator:cloudflare-principal-credential -- issue` registers a durable principal credential in D1. Supply the bearer as exact stdin bytes and the non-secret identity and policy through `--config`, `--account-id`, `--credential-id`, `--version`, `--principal`, `--scopes`, `--expires-at`, and `--max-sites`; optional `--sites` restricts the credential to canonical site IDs. The API token defaults to `CLOUDFLARE_API_TOKEN`, or an explicit safe environment name can be selected with `--api-token-env`. The operator hashes at its stdin boundary, executes one parameterized D1 API batch transaction, and emits only redacted identity and policy evidence. It never places the bearer or digest in arguments, environments, output, or persistent artifacts. Exact issue replay converges, while version-policy conflicts and digest reuse fail closed. +`npm run operator:principal-credential -- issue` registers a durable principal credential in D1. Supply the bearer as exact stdin bytes and the non-secret identity and policy through `--config`, `--account-id`, `--credential-id`, `--version`, `--principal`, `--scopes`, `--expires-at`, and `--max-sites`; optional `--sites` restricts the credential to canonical site IDs. The API token defaults to `CLOUDFLARE_API_TOKEN`, or an explicit safe environment name can be selected with `--api-token-env`. The operator hashes at its stdin boundary, executes one parameterized D1 API batch transaction, and emits only redacted identity and policy evidence. It never places the bearer or digest in arguments, environments, output, or persistent artifacts. Exact issue replay converges, while version-policy conflicts and digest reuse fail closed. -Rotation uses explicit overlap: issue the new version, move callers to it, then run `npm run operator:cloudflare-principal-credential -- revoke` with the old `--credential-id` and `--version`. Revocation accepts no stdin and converges as `revoked` or `unchanged`. An authorized caller control plane can bind a private input directly to the issue command's stdin; Worker-bound secrets remain a separate deployment contract. `--local` and `--persist-to` are reserved for isolated verification. Remote mutation remains a separately authorized operator step. +Rotation uses explicit overlap: issue the new version, move callers to it, then run `npm run operator:principal-credential -- revoke` with the old `--credential-id` and `--version`. Revocation accepts no stdin and converges as `revoked` or `unchanged`. An authorized caller control plane can bind a private input directly to the issue command's stdin; Worker-bound secrets remain a separate deployment contract. `--local` and `--persist-to` are reserved for isolated verification. Remote mutation remains a separately authorized operator step. -For explicitly authorized remote transport evidence, run `npm run cloudflare:remote-gate:principal-credentials -- --confirm-remote-d1-gate --account-id ` with `CLOUDFLARE_API_TOKEN` set. The gate creates one UUID-named D1 database through the authenticated Cloudflare API and requires the exact requested name plus immutable UUID in the create receipt before proceeding. It invokes the credential operator through stdin-only generated bearers, verifies replay, conflict, digest uniqueness, version overlap, revoke replay, concurrent revoke convergence, bounded non-secret evidence, and REST batch rollback, then deletes only that immutable UUID in `finally`. It refuses to start without the confirmation flag, never deploys a Worker, and emits no token, bearer, digest, SQL, headers, paths, database name/UUID, or raw provider output. An ambiguous create produces one bounded exact-name remediation message and never triggers name-based cleanup; cleanup failure otherwise fails the gate with redacted diagnostics. +For explicitly authorized remote transport evidence, run `npm run remote-gate:principal-credentials -- --confirm-remote-d1-gate --account-id ` with `CLOUDFLARE_API_TOKEN` set. The gate creates one UUID-named D1 database through the authenticated Cloudflare API and requires the exact requested name plus immutable UUID in the create receipt before proceeding. It invokes the credential operator through stdin-only generated bearers, verifies replay, conflict, digest uniqueness, version overlap, revoke replay, concurrent revoke convergence, bounded non-secret evidence, and REST batch rollback, then deletes only that immutable UUID in `finally`. It refuses to start without the confirmation flag, never deploys a Worker, and emits no token, bearer, digest, SQL, headers, paths, database name/UUID, or raw provider output. An ambiguous create produces one bounded exact-name remediation message and never triggers name-based cleanup; cleanup failure otherwise fails the gate with redacted diagnostics. ## Verification -1. Run `npm run generate:cloudflare-canonical-mdi-seed` and `npm run generate:cloudflare-wordpress-runtime-corpus` to regenerate deterministic runtime artifacts and manifests. -2. Run `npm run provision:cloudflare-wordpress-runtime-corpus -- --local --persist-to ` to verify and upload all exact content-addressed artifacts into isolated local R2 storage. For an authorized deployment, run the provisioner with `--remote` and require every upload to succeed before deploying the Worker that imports their manifests. -3. Run `npm run test:cloudflare-runtime` for routing, coordinator composition, canonical-state, artifact validation, source contract, and TypeScript coverage. -4. Run `npm run cloudflare:dry-run`, `npm run cloudflare:dry-run:d1`, `npm run cloudflare:dry-run:control`, and `npm run cloudflare:dry-run:public-reader` to compile the Durable Object, D1 execution, PHP-free control, and R2-only public-reader profiles without creating Cloudflare resources. The D1 dry run must report only D1, R2, and queue bindings with no Durable Object; the control dry run must report only D1, R2, and queue-producer bindings; the public-reader dry run must report only its R2 binding. The placeholder D1 database ID is for local/dry-run verification; an implementation supplies its provisioned binding at deployment. - Use `npm run provision:cloudflare-d1-coordinator -- --output ` to idempotently create or resolve the named production database and emit a mode-`0600` deployment config from the checked-in template. Relative entrypoints are resolved from that template so the emitted config remains deployable outside the checkout. -5. Run `npm run cloudflare:local-gate` and `npm run cloudflare:local-gate:d1` for the isolated workerd workflow through both coordinator implementations. Each gate generates and provisions all artifacts, verifies the selected backend through the state envelope, injects stable test-only admin-password, auth-secret, and operator-token values, uploads and activates a real plugin ZIP, establishes an anonymous homepage and canonical-permalink publication, and updates a published post through authenticated REST without immediate rendering. The D1 profile proves queue-driven publication before restarting the local process, then proves the immutable R2 result survives restart; local Wrangler queues themselves are process-local rather than a durability substitute for deployed Cloudflare Queues. Wrangler's scheduled-test facade suppresses local queue consumers, so the D1 gate temporarily restarts against the same persisted state for scheduled WordPress cron assertions and returns to normal queue mode for import execution. The coordinator-only Durable Object profile proves the updated canonical state through authenticated REST while preserving its previous immutable publication. Both prove bounded scheduled WordPress cron, coordinator-free R2 reads, and canonical state across restart. A final two-host phase proves isolated mutations, coordinator versions, REST collections, credentials, publications, and caches plus fail-closed unknown-host routing. The remaining coverage includes login, concurrent canonical writes, media, representative frontend/admin/editor assets, PHP diagnostics, session recovery, and a fresh login after restart. +1. Run `npm run generate:canonical-mdi-seed` and `npm run generate:wordpress-runtime-corpus` to regenerate deterministic runtime artifacts and manifests. +2. Run `npm run provision:wordpress-runtime-corpus -- --local --persist-to ` to verify and upload all exact content-addressed artifacts into isolated local R2 storage. For an authorized deployment, run the provisioner with `--remote` and require every upload to succeed before deploying the Worker that imports their manifests. +3. Run `npm test` for routing, coordinator composition, canonical-state, artifact validation, source contract, and TypeScript coverage. +4. Run `npm run dry-run`, `npm run dry-run:d1`, `npm run dry-run:control`, and `npm run dry-run:public-reader` to compile the Durable Object, D1 execution, PHP-free control, and R2-only public-reader profiles without creating Cloudflare resources. The D1 dry run must report only D1, R2, and queue bindings with no Durable Object; the control dry run must report only D1, R2, and queue-producer bindings; the public-reader dry run must report only its R2 binding. The placeholder D1 database ID is for local/dry-run verification; an implementation supplies its provisioned binding at deployment. + Use `npm run provision:d1-coordinator -- --output ` to idempotently create or resolve the named production database and emit a mode-`0600` deployment config from the checked-in template. Relative entrypoints are resolved from that template so the emitted config remains deployable outside the package. +5. Run `npm run local-gate` and `npm run local-gate:d1` for the isolated workerd workflow through both coordinator implementations. Each gate generates and provisions all artifacts, verifies the selected backend through the state envelope, injects stable test-only admin-password, auth-secret, and operator-token values, uploads and activates a real plugin ZIP, establishes an anonymous homepage and canonical-permalink publication, and updates a published post through authenticated REST without immediate rendering. The D1 profile proves queue-driven publication before restarting the local process, then proves the immutable R2 result survives restart; local Wrangler queues themselves are process-local rather than a durability substitute for deployed Cloudflare Queues. Wrangler's scheduled-test facade suppresses local queue consumers, so the D1 gate temporarily restarts against the same persisted state for scheduled WordPress cron assertions and returns to normal queue mode for import execution. The coordinator-only Durable Object profile proves the updated canonical state through authenticated REST while preserving its previous immutable publication. Both prove bounded scheduled WordPress cron, coordinator-free R2 reads, and canonical state across restart. A final two-host phase proves isolated mutations, coordinator versions, REST collections, credentials, publications, and caches plus fail-closed unknown-host routing. The remaining coverage includes login, concurrent canonical writes, media, representative frontend/admin/editor assets, PHP diagnostics, session recovery, and a fresh login after restart. This document describes local candidate verification only. It does not claim remote deployment. diff --git a/packages/runtime-cloudflare/npm-shrinkwrap.json b/packages/runtime-cloudflare/npm-shrinkwrap.json new file mode 100644 index 000000000..62b0a9d9f --- /dev/null +++ b/packages/runtime-cloudflare/npm-shrinkwrap.json @@ -0,0 +1,3013 @@ +{ + "name": "@automattic/wp-codebox-runtime-cloudflare", + "version": "0.12.27", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@automattic/wp-codebox-runtime-cloudflare", + "version": "0.12.27", + "bundleDependencies": [ + "@automattic/wp-codebox-core", + "@php-wasm/stream-compression", + "@php-wasm/universal", + "@php-wasm/web-8-5", + "@wp-playground/wordpress", + "patch-package" + ], + "hasInstallScript": true, + "dependencies": { + "@automattic/wp-codebox-core": "file:vendor/wp-codebox-core", + "@php-wasm/stream-compression": "3.1.45", + "@php-wasm/universal": "3.1.46", + "@php-wasm/web-8-5": "3.1.46", + "@wp-playground/wordpress": "3.1.46", + "patch-package": "^8.0.1", + "wrangler": "4.127.1" + }, + "devDependencies": { + "@cloudflare/workers-types": "^5.20260718.1", + "@types/node": "^24.0.0", + "pixelmatch": "7.2.0", + "playwright": "1.61.1", + "pngjs": "7.0.0", + "tsx": "^4.20.0", + "typescript": "^5.8.0" + }, + "engines": { + "node": ">=22.0.0" + } + }, + "node_modules/@automattic/wp-codebox-core": { + "resolved": "vendor/wp-codebox-core", + "link": true + }, + "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/unenv-preset": { + "version": "2.16.1", + "resolved": "https://registry.npmjs.org/@cloudflare/unenv-preset/-/unenv-preset-2.16.1.tgz", + "integrity": "sha512-ECxObrMfyTl5bhQf/lZCXwo5G6xX9IAUo+nDMKK4SZ8m4Jvvxp52vilxyySSWh2YTZz8+HQ07qGH/2rEom1vDw==", + "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.20260828.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-64/-/workerd-darwin-64-1.20260828.1.tgz", + "integrity": "sha512-CVd+xPhqUESg8Xhq09TZx0wl4FSirfJGOzvbPz2yHhBIvmNHFFQkSN3rkd7wEwnhQQk37Xi0/aD6ykPLJbmGiQ==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workerd-darwin-arm64": { + "version": "1.20260828.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-arm64/-/workerd-darwin-arm64-1.20260828.1.tgz", + "integrity": "sha512-5HDPXRM152vU5JveByGFk34X57TVyIsfp4cabepAf45DC0MKvm52ucJqAjW1h8bvW4X+zRw9GU35OHF9FEC9Ww==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workerd-linux-64": { + "version": "1.20260828.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-64/-/workerd-linux-64-1.20260828.1.tgz", + "integrity": "sha512-MQ1Ll9P7F72HHUKizbb7BlDfbY8fRoNMpbIpZoU6uKsSkneFICWSKv6UlgU9EQZ+w0i7TMa12iUgJ8l29eRI9A==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workerd-linux-arm64": { + "version": "1.20260828.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-arm64/-/workerd-linux-arm64-1.20260828.1.tgz", + "integrity": "sha512-FBTaUQ1xcU9jcp4OyBPcH8x0QiFvc1iuZL2GkD8zp2q1WyTVHYOptRDQUU+cuHjt0rQ2EIKVPBjahPxfa0joBw==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workerd-windows-64": { + "version": "1.20260828.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-windows-64/-/workerd-windows-64-1.20260828.1.tgz", + "integrity": "sha512-yvr77hC7dUbvK5K+SCg062kkPq3sx+drV1PcgHslzHDYcJBtT0V3X80qLE49LW1vq2svaeNmsVQS+vHsqWu8cQ==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workers-types": { + "version": "5.20260831.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workers-types/-/workers-types-5.20260831.1.tgz", + "integrity": "sha512-yXg4pwfYjhsDH9rYc3qZ3K+z62DCSvO/aj7GiZo6AyDeWGZpyFRpPMYcQ6LF/zfaf1x0Ngw2gSqL8JjuUtMGlA==", + "devOptional": true, + "license": "MIT OR Apache-2.0" + }, + "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" + ], + "dev": true, + "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" + ], + "dev": true, + "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" + ], + "dev": true, + "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" + ], + "dev": true, + "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" + ], + "dev": true, + "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" + ], + "dev": true, + "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" + ], + "dev": true, + "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" + ], + "dev": true, + "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" + ], + "dev": true, + "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" + ], + "dev": true, + "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" + ], + "dev": true, + "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" + ], + "dev": true, + "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" + ], + "dev": true, + "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" + ], + "dev": true, + "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" + ], + "dev": true, + "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" + ], + "dev": true, + "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" + ], + "dev": true, + "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" + ], + "dev": true, + "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" + ], + "dev": true, + "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" + ], + "dev": true, + "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" + ], + "dev": true, + "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" + ], + "dev": true, + "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" + ], + "dev": true, + "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" + ], + "dev": true, + "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" + ], + "dev": true, + "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" + ], + "dev": true, + "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.2", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.35.2.tgz", + "integrity": "sha512-eEieHsMksAW4IiO5NzauESRl2D2qz3J/kwUxUrSfV06A93eEaRfMpHXyUb1mAqrR7i8U9A0GRqE9pjn6u1Jjpg==", + "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.1" + } + }, + "node_modules/@img/sharp-darwin-x64": { + "version": "0.35.2", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.35.2.tgz", + "integrity": "sha512-BaktuGPCeHJMARpodR8jK4uKiZrPAy9WrfQW0sdI37clracq8Bp01AYS3SZgi5FS/y5twa9t4+LIuuxQjqRrWw==", + "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.1" + } + }, + "node_modules/@img/sharp-freebsd-wasm32": { + "version": "0.35.2", + "resolved": "https://registry.npmjs.org/@img/sharp-freebsd-wasm32/-/sharp-freebsd-wasm32-0.35.2.tgz", + "integrity": "sha512-YoAxdnd8hPUkvLHd3bWY+YA8nw3xM/RyRopYucNsWHVSan8NLVM3X2volsfoRDcXdUJPg6tXahSd7HXPK7lRnw==", + "license": "Apache-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "dependencies": { + "@img/sharp-wasm32": "0.35.2" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-darwin-arm64": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.3.1.tgz", + "integrity": "sha512-4V/M3roRMTYjiwZY9IOVQOE8OyeCxFAkYmyZDrZl51uOKjibm3oeEJ4WAmLxutAfzFbC9jqUiPs2gbnGflH+7g==", + "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.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.3.1.tgz", + "integrity": "sha512-c0/DxItpJv2+dGhgycJBBgotdqruGYDvA79drdh0MD1dFpy7JzJ/PlXwi1H4rFf0eTy8tgbI91aHDnZIceY3jQ==", + "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.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.3.1.tgz", + "integrity": "sha512-aGGy9aWzXgHBG7HNyQPWorZthlp7+x6fDRoPAQbGO3ThcttuTyKIx3NuSHb6zb4gBNq6/yNn9f1cy9nFKS/Vmg==", + "cpu": [ + "arm" + ], + "libc": [ + "glibc" + ], + "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.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.3.1.tgz", + "integrity": "sha512-JznefmcK9j1JKPz8AkQDh89kjojubyfOasWBPKfzMIhPwsgDy9evpE/naJTXXXmghS1iFwR8u/kTwh/I2/+GCw==", + "cpu": [ + "arm64" + ], + "libc": [ + "glibc" + ], + "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.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.3.1.tgz", + "integrity": "sha512-1EkwGNCZk6iWNCMWqrvdJ+r1j0PT1zIz60CNPhYnJlK/zyeWqlsPZIe+ocBVqPF8k/Ssee/NCk+tE9Ryrko6ng==", + "cpu": [ + "ppc64" + ], + "libc": [ + "glibc" + ], + "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.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-riscv64/-/sharp-libvips-linux-riscv64-1.3.1.tgz", + "integrity": "sha512-Ilays+w2bXdnxzxtQdmXR62u8o8GYa3eL4+Gr+1KiE4xperMZUslRaVPJwwPkzlHEjGfXAfRVAa/7CYCtSqsBw==", + "cpu": [ + "riscv64" + ], + "libc": [ + "glibc" + ], + "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.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.3.1.tgz", + "integrity": "sha512-VfBwVHQTbRoj4XlpA/KLZ7ltgMpz+4WSejFzQ+GnoImjo1PtEJ59QB2qR1xQEeRPYIkNrPIm2L4cICMvz4C2ew==", + "cpu": [ + "s390x" + ], + "libc": [ + "glibc" + ], + "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.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.3.1.tgz", + "integrity": "sha512-+c8ukgwU62DS54nCAjw7keOfHUkmr0B5QHEdcOqRnodF/MNXJbVI8Eopoj4B/0H8Asr65I+A4Amrn7a85/md6A==", + "cpu": [ + "x64" + ], + "libc": [ + "glibc" + ], + "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.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.3.1.tgz", + "integrity": "sha512-qlKb/pwbkAi1WMsJrYHk7CuDrd12s27U2QnRhFYUoJNrRCmkosMTttuRFat/DDB3IlDm5qE1TJgZ4JDnHX8Ldw==", + "cpu": [ + "arm64" + ], + "libc": [ + "musl" + ], + "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.1", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.3.1.tgz", + "integrity": "sha512-yO21HwoUVLN8Qa+/SBjQLMYwBWAVJjeGPNe+hc0OUeMeifEtJqu5a1c4HayE1nNpDih9y3/KkoltfkDodmKAlg==", + "cpu": [ + "x64" + ], + "libc": [ + "musl" + ], + "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.2", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.35.2.tgz", + "integrity": "sha512-SE4kzF2mepn6z+6E7L6lsV8FzuLL6IPQdyX8ZiwROAG/G8td+hP/m7FsFPwidtrF19gvajuC9l6TxAVcsA4S7A==", + "cpu": [ + "arm" + ], + "libc": [ + "glibc" + ], + "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.1" + } + }, + "node_modules/@img/sharp-linux-arm64": { + "version": "0.35.2", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.35.2.tgz", + "integrity": "sha512-af12Pnd0ZGu2HfP8NayB0kk6eC/lrfbQE6HlR4jD+34wdJ1Vw9TF6TMn6ZvffT+WgqVsl0hRbmNvz2u/23VmwA==", + "cpu": [ + "arm64" + ], + "libc": [ + "glibc" + ], + "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.1" + } + }, + "node_modules/@img/sharp-linux-ppc64": { + "version": "0.35.2", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-ppc64/-/sharp-linux-ppc64-0.35.2.tgz", + "integrity": "sha512-hYSBm7zcNtDCozCxQHYZJiu63b/bXsgRZuOxCIBZsStMM9Vap47iFHdbX4kCvQsblPB/k+clhELpdQJHQLSHvg==", + "cpu": [ + "ppc64" + ], + "libc": [ + "glibc" + ], + "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.1" + } + }, + "node_modules/@img/sharp-linux-riscv64": { + "version": "0.35.2", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-riscv64/-/sharp-linux-riscv64-0.35.2.tgz", + "integrity": "sha512-qQt0Kc13+Hoan/Awq/qMSQw3L+RI1NCRPgD5cUJ/1WSSmIoysLOc72jlRM3E0OHN9Yr313jgeQ2T+zW+F03QFA==", + "cpu": [ + "riscv64" + ], + "libc": [ + "glibc" + ], + "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.1" + } + }, + "node_modules/@img/sharp-linux-s390x": { + "version": "0.35.2", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.35.2.tgz", + "integrity": "sha512-E4fLLfRPzDLlEeDaTzI98OFLcv++WL5ChLLMwPoVd0CIoZQqupBSNbOisPL5am9XsbQ9T84+iiMpUvbFtkunbA==", + "cpu": [ + "s390x" + ], + "libc": [ + "glibc" + ], + "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.1" + } + }, + "node_modules/@img/sharp-linux-x64": { + "version": "0.35.2", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.35.2.tgz", + "integrity": "sha512-gi0zFJJRLswfCZmHtJdikXPOc5u7qamSOS3NHedLqLd4W8Q0NqjdBr6TTRIgsfFjqfTsHFgdfvJ9LwqSgcHiAA==", + "cpu": [ + "x64" + ], + "libc": [ + "glibc" + ], + "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.1" + } + }, + "node_modules/@img/sharp-linuxmusl-arm64": { + "version": "0.35.2", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.35.2.tgz", + "integrity": "sha512-siWbOW1u6HFnFLrp0waKyW7VEf7jYvcDWdrXEFa8AkdAQgEvuu5Fz8/Y70w9EeqAdwDtfU012BhEHHaDqvQNzg==", + "cpu": [ + "arm64" + ], + "libc": [ + "musl" + ], + "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.1" + } + }, + "node_modules/@img/sharp-linuxmusl-x64": { + "version": "0.35.2", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.35.2.tgz", + "integrity": "sha512-YBqMMcjDi4QGYiSn4vNOYBhmlC4z5AXqkOUUqI2e0AFA4urNv4ESgOgwNl3K+4etQhha0twXlzeF20bbULm9Yg==", + "cpu": [ + "x64" + ], + "libc": [ + "musl" + ], + "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.1" + } + }, + "node_modules/@img/sharp-wasm32": { + "version": "0.35.2", + "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.35.2.tgz", + "integrity": "sha512-Mrv4JQNYVQ94xH+jzZ9r+gowleN8mv2FTgKT+PI6bx5C0G8TdNYndu161pg2i7uoBwxy2ImPMHrJOM2LZef7Bw==", + "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT", + "optional": true, + "dependencies": { + "@emnapi/runtime": "^1.11.1" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-webcontainers-wasm32": { + "version": "0.35.2", + "resolved": "https://registry.npmjs.org/@img/sharp-webcontainers-wasm32/-/sharp-webcontainers-wasm32-0.35.2.tgz", + "integrity": "sha512-QNV27pxs9wpApEiCfvHM1RDoP1w1+2KrUWWDPEhEwg+latvOrfuhWrHWZKwdSFwU6jh3myjw/yOCRsUIuOft3g==", + "cpu": [ + "wasm32" + ], + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "@img/sharp-wasm32": "0.35.2" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-arm64": { + "version": "0.35.2", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.35.2.tgz", + "integrity": "sha512-BiVRYc/t6/Vl3e1hBx0hugG4oN9Pydf4fgMSpxTQJmwGUg/YoXTWHiFeRymHfCZzifxu4F4rpk/I67D0LQ20wQ==", + "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.2", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.35.2.tgz", + "integrity": "sha512-YYEhx9PImCC7T0tI8JDMi4DB9LwLCXCU5OWNYEXAxh5Q1ShKkyC6byxzoBJ3gEFDnH2lQckWuDe70G7mB2XJog==", + "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.2", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.35.2.tgz", + "integrity": "sha512-imoOyBcoM/iiUr4J6VPpCNjPnjvP/Gks95898yB8YqoGGYmHYbOyCuNv9FMhFgtaiHFGbHW8bxKqRV6VjtXThQ==", + "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.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "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/@php-wasm/logger": { + "version": "3.1.46", + "resolved": "https://registry.npmjs.org/@php-wasm/logger/-/logger-3.1.46.tgz", + "integrity": "sha512-PfnDq5ammh5FXxkGX1TGEck9gmW3i76IvBCqtX4D45xnSBIuCeu8uf2oWuty2j/c8wTEO8vyRDdvCj5oow7bXw==", + "inBundle": true, + "license": "GPL-2.0-or-later", + "engines": { + "node": ">=20.10.0", + "npm": ">=10.2.3" + } + }, + "node_modules/@php-wasm/progress": { + "version": "3.1.46", + "resolved": "https://registry.npmjs.org/@php-wasm/progress/-/progress-3.1.46.tgz", + "integrity": "sha512-WmmgEm6yz322M3pzgAUjxckyhpVxr2WWlHyVYDyaMZWU6UIDUHfiRZRPzADohNyYvV3g0/zMNaDGmxz+TTXwQQ==", + "inBundle": true, + "license": "GPL-2.0-or-later", + "dependencies": { + "@php-wasm/logger": "3.1.46" + }, + "engines": { + "node": ">=20.10.0", + "npm": ">=10.2.3" + } + }, + "node_modules/@php-wasm/stream-compression": { + "version": "3.1.45", + "resolved": "https://registry.npmjs.org/@php-wasm/stream-compression/-/stream-compression-3.1.45.tgz", + "integrity": "sha512-zLU1AGNEg1tuwm93LHrL8OcV24LyNglTg/CXV5CVZiMPpg1wfIDHJy11qqjZM8iCIJk87qYQhkKOjTnGinAVDg==", + "inBundle": true, + "license": "GPL-2.0-or-later", + "dependencies": { + "@php-wasm/util": "3.1.45" + } + }, + "node_modules/@php-wasm/universal": { + "version": "3.1.46", + "resolved": "https://registry.npmjs.org/@php-wasm/universal/-/universal-3.1.46.tgz", + "integrity": "sha512-sx0KyN5kcsCMzwy+XJAyoOukSA5TEZYd0LK3l9kRP3I0CSd5h6JItkf5eZ42WltB+wD+aTRdqSwc/Mvkc7qBjQ==", + "inBundle": true, + "license": "GPL-2.0-or-later", + "dependencies": { + "@php-wasm/logger": "3.1.46", + "@php-wasm/progress": "3.1.46", + "@php-wasm/stream-compression": "3.1.46", + "@php-wasm/util": "3.1.46", + "ini": "4.1.2" + }, + "engines": { + "node": ">=20.10.0", + "npm": ">=10.2.3" + } + }, + "node_modules/@php-wasm/universal/node_modules/@php-wasm/stream-compression": { + "version": "3.1.46", + "resolved": "https://registry.npmjs.org/@php-wasm/stream-compression/-/stream-compression-3.1.46.tgz", + "integrity": "sha512-+oUw4CPX52FgYXEh5C+MgJAg7Cy5OeaVuh7HnQR6oxb69nU63/r8tHTLV/WrWRyjBYh321uJzLV7Gg29qmiUtg==", + "inBundle": true, + "license": "GPL-2.0-or-later", + "dependencies": { + "@php-wasm/util": "3.1.46" + } + }, + "node_modules/@php-wasm/util": { + "version": "3.1.46", + "resolved": "https://registry.npmjs.org/@php-wasm/util/-/util-3.1.46.tgz", + "integrity": "sha512-Yh9HNbx+rB2R1tScUvvAsbJVIB7msjWceWYogyR2YvAOqlDL0ymZyaQ65+K3QcHh/8HostTRwwgQh5oK4DLDrA==", + "inBundle": true, + "engines": { + "node": ">=20.10.0", + "npm": ">=10.2.3" + } + }, + "node_modules/@php-wasm/web-8-5": { + "version": "3.1.46", + "resolved": "https://registry.npmjs.org/@php-wasm/web-8-5/-/web-8-5-3.1.46.tgz", + "integrity": "sha512-j9wwlY6aNXuKBr4JPJzqE+vkM3Onk+byJsxLqaJs4U0gYDUBLr8CuKuVr+p13apSTUosConePYTAs0214aNxYA==", + "inBundle": true, + "license": "GPL-2.0-or-later", + "dependencies": { + "@php-wasm/universal": "3.1.46", + "wasm-feature-detect": "1.8.0" + }, + "engines": { + "node": ">=20.10.0", + "npm": ">=10.2.3" + } + }, + "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/@types/node": { + "version": "24.13.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.13.3.tgz", + "integrity": "sha512-Dh8vAsV36ig5wa9OX4pXvMc9D3Veibfw2wix0CUwYODLD8nkj9UsLjASr49nPg+2eKzxhBV+v7L8pXvT4e639Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~7.18.0" + } + }, + "node_modules/@wp-playground/common": { + "version": "3.1.46", + "resolved": "https://registry.npmjs.org/@wp-playground/common/-/common-3.1.46.tgz", + "integrity": "sha512-MZ4ZSsh9GG7oHYhe38T+9uW6mGDvlwoH8IyJWNJN/PgH5SPPUHnP1CtmiMTl/p+sOf4ELf4A/REa16OtoJ83Qg==", + "inBundle": true, + "license": "GPL-2.0-or-later", + "dependencies": { + "@php-wasm/universal": "3.1.46", + "@php-wasm/util": "3.1.46" + }, + "engines": { + "node": ">=20.10.0", + "npm": ">=10.2.3" + } + }, + "node_modules/@wp-playground/wordpress": { + "version": "3.1.46", + "resolved": "https://registry.npmjs.org/@wp-playground/wordpress/-/wordpress-3.1.46.tgz", + "integrity": "sha512-QGzxrSmlm3ewiyU6NB2VDMgqZ5ZPuuSsPg4YkRnQrX489v0ohqCLp/jUe/+5nvXKGNg4KnR/37QrerEtLryXcw==", + "inBundle": true, + "license": "GPL-2.0-or-later", + "dependencies": { + "@php-wasm/logger": "3.1.46", + "@php-wasm/universal": "3.1.46", + "@php-wasm/util": "3.1.46", + "@wp-playground/common": "3.1.46", + "zstddec": "^0.2.0" + }, + "engines": { + "node": ">=20.10.0", + "npm": ">=10.2.3" + } + }, + "node_modules/@yarnpkg/lockfile": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz", + "integrity": "sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ==", + "inBundle": true, + "license": "BSD-2-Clause" + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "inBundle": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "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/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "inBundle": true, + "license": "MIT", + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/call-bind": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.9.tgz", + "integrity": "sha512-a/hy+pNsFUTR+Iz8TCJvXudKVLAnz/DyeSUo10I5yvFDQJBFU2s9uqQpoSrJlroHUKoKqzg+epxyP9lqFdzfBQ==", + "inBundle": true, + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "get-intrinsic": "^1.3.0", + "set-function-length": "^1.2.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "inBundle": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "inBundle": true, + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "inBundle": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/chalk/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "inBundle": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/ci-info": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz", + "integrity": "sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/sibiraj-s" + } + ], + "inBundle": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "inBundle": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "inBundle": true, + "license": "MIT" + }, + "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/cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "inBundle": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/define-data-property": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", + "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", + "inBundle": true, + "license": "MIT", + "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "gopd": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "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/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "inBundle": true, + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "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/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "inBundle": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "inBundle": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz", + "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==", + "inBundle": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/esbuild": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.2.tgz", + "integrity": "sha512-HKVLS8dvII+xoKW9kmqxbRKrnWEXfJJr/FZhhJmiqIB0e053QNYFqOBouTMO/k5sID4MvCiUCvv8b9M4h32wIA==", + "dev": true, + "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/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "inBundle": true, + "license": "MIT", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/find-yarn-workspace-root": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/find-yarn-workspace-root/-/find-yarn-workspace-root-2.0.0.tgz", + "integrity": "sha512-1IMnbjt4KzsQfnhnzNd8wUEgXZ44IzZaZmnLYx7D5FZlaHt2gW20Cri8Q+E/t5tIj4+epTBub+2Zxu/vNILzqQ==", + "inBundle": true, + "license": "Apache-2.0", + "dependencies": { + "micromatch": "^4.0.2" + } + }, + "node_modules/fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "inBundle": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "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/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "inBundle": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "inBundle": true, + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "inBundle": true, + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "inBundle": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "inBundle": true, + "license": "ISC" + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "inBundle": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/has-property-descriptors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", + "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", + "inBundle": true, + "license": "MIT", + "dependencies": { + "es-define-property": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "inBundle": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz", + "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==", + "inBundle": true, + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/ini": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/ini/-/ini-4.1.2.tgz", + "integrity": "sha512-AMB1mvwR1pyBFY/nSevUX6y8nJWS63/SzUKD3JyQn97s4xgIdgQPT75IRouIiBAN4yLQBUShNYVW0+UG25daCw==", + "inBundle": true, + "license": "ISC", + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/is-docker": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", + "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==", + "inBundle": true, + "license": "MIT", + "bin": { + "is-docker": "cli.js" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "inBundle": true, + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-wsl": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", + "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", + "inBundle": true, + "license": "MIT", + "dependencies": { + "is-docker": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/isarray": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", + "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", + "inBundle": true, + "license": "MIT" + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "inBundle": true, + "license": "ISC" + }, + "node_modules/json-stable-stringify": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.3.0.tgz", + "integrity": "sha512-qtYiSSFlwot9XHtF9bD9c7rwKjr+RecWT//ZnPvSmEjpV5mmPOCN4j8UjY5hbjNkOwZ/jQv3J6R1/pL7RwgMsg==", + "inBundle": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.4", + "isarray": "^2.0.5", + "jsonify": "^0.0.1", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/jsonfile": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.1.tgz", + "integrity": "sha512-zwOTdL3rFQ/lRdBnntKVOX6k5cKJwEc1HdilT71BWEu7J41gXIB2MRp+vxduPSwZJPWBxEzv4yH1wYLJGUHX4Q==", + "inBundle": true, + "license": "MIT", + "dependencies": { + "universalify": "^2.0.0" + }, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/jsonify": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.1.tgz", + "integrity": "sha512-2/Ki0GcmuqSrgFyelQq9M05y7PS0mEwuIzrf3f1fPqkVDVRvZrPZtVSMHxdgo8Aq0sxAOb/cr2aqqA3LeWHVPg==", + "inBundle": true, + "license": "Public Domain", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/klaw-sync": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/klaw-sync/-/klaw-sync-6.0.0.tgz", + "integrity": "sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ==", + "inBundle": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.1.11" + } + }, + "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/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "inBundle": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/micromatch": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", + "inBundle": true, + "license": "MIT", + "dependencies": { + "braces": "^3.0.3", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/miniflare": { + "version": "5.20260828.0-alpha", + "resolved": "https://registry.npmjs.org/miniflare/-/miniflare-5.20260828.0-alpha.tgz", + "integrity": "sha512-6nbxhZEcz/UET3Y1OnYPsrAUjUmuFoib3ynUqteRdn1YnDxsLg8cwgZJZCk9QmtOmGzXwzXzgE/d/C0dJAPtVw==", + "license": "MIT", + "dependencies": { + "@cspotcode/source-map-support": "0.8.1", + "sharp": "0.35.2", + "undici": "7.29.0", + "workerd": "1.20260828.1", + "ws": "8.21.0", + "youch": "4.1.0-beta.10" + }, + "engines": { + "node": ">=22.0.0" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "inBundle": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "inBundle": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/open": { + "version": "7.4.2", + "resolved": "https://registry.npmjs.org/open/-/open-7.4.2.tgz", + "integrity": "sha512-MVHddDVweXZF3awtlAS+6pgKLlm/JgxZ90+/NBurBoQctVOOB/zDdVjcyPzQ+0laDGbsWgrRkflI65sQeOgT9Q==", + "inBundle": true, + "license": "MIT", + "dependencies": { + "is-docker": "^2.0.0", + "is-wsl": "^2.1.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/patch-package": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/patch-package/-/patch-package-8.0.1.tgz", + "integrity": "sha512-VsKRIA8f5uqHQ7NGhwIna6Bx6D9s/1iXlA1hthBVBEbkq+t4kXD0HHt+rJhf/Z+Ci0F/HCB2hvn0qLdLG+Qxlw==", + "inBundle": true, + "license": "MIT", + "dependencies": { + "@yarnpkg/lockfile": "^1.1.0", + "chalk": "^4.1.2", + "ci-info": "^3.7.0", + "cross-spawn": "^7.0.3", + "find-yarn-workspace-root": "^2.0.0", + "fs-extra": "^10.0.0", + "json-stable-stringify": "^1.0.2", + "klaw-sync": "^6.0.0", + "minimist": "^1.2.6", + "open": "^7.4.2", + "semver": "^7.5.3", + "slash": "^2.0.0", + "tmp": "^0.2.4", + "yaml": "^2.2.2" + }, + "bin": { + "patch-package": "index.js" + }, + "engines": { + "node": ">=14", + "npm": ">5" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "inBundle": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "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/picomatch": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz", + "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==", + "inBundle": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/pixelmatch": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/pixelmatch/-/pixelmatch-7.2.0.tgz", + "integrity": "sha512-xhcb4yHu9sM/G7foGzoLtXYcC0zHEaOXXjRKhGup0fw78Nf2Tkiapv4EQyMzrbcmQPsllAI7DbFY2UT7PlI9Pg==", + "dev": true, + "license": "ISC", + "dependencies": { + "pngjs": "^7.0.0" + }, + "bin": { + "pixelmatch": "bin/pixelmatch" + } + }, + "node_modules/playwright": { + "version": "1.61.1", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.61.1.tgz", + "integrity": "sha512-DWnY5o3YbLWK4GovuAVwpqL+1VwGNdUGrRr++8j8PtQQzvAVZUIMjKQ90fY689sEJZJBbZVw1rXaOKSTitkzPQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright-core": "1.61.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "fsevents": "2.3.2" + } + }, + "node_modules/playwright-core": { + "version": "1.61.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.61.1.tgz", + "integrity": "sha512-h7Qlt6m4REp25qvIdvbDtVmD4LqVXfpRxhORv9L0jzETM05p4fuPJ3dKyuSXQxDSbXnmS79HAgi9589lGSpLkg==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/playwright/node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/pngjs": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-7.0.0.tgz", + "integrity": "sha512-LKWqWJRhstyYo9pGvgor/ivk2w94eSjE3RGVuzLGlr3NmD8bf7RcYGze1mNdEHRP6TRP6rMuDHk5t44hnTRyow==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.19.0" + } + }, + "node_modules/semver": { + "version": "7.8.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", + "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "inBundle": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/set-function-length": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", + "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", + "inBundle": true, + "license": "MIT", + "dependencies": { + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/sharp": { + "version": "0.35.2", + "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.35.2.tgz", + "integrity": "sha512-FVtFjtBCMiJS6yb5CX7Sop45WFMpeGw6oRKuJnXYgf/f1ms/D7LE/ZUSNxnW7rZ/dbslQWYkoqFHGPaDBtaK4w==", + "license": "Apache-2.0", + "dependencies": { + "@img/colour": "^1.1.0", + "detect-libc": "^2.1.2", + "semver": "^7.8.4" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-darwin-arm64": "0.35.2", + "@img/sharp-darwin-x64": "0.35.2", + "@img/sharp-freebsd-wasm32": "0.35.2", + "@img/sharp-libvips-darwin-arm64": "1.3.1", + "@img/sharp-libvips-darwin-x64": "1.3.1", + "@img/sharp-libvips-linux-arm": "1.3.1", + "@img/sharp-libvips-linux-arm64": "1.3.1", + "@img/sharp-libvips-linux-ppc64": "1.3.1", + "@img/sharp-libvips-linux-riscv64": "1.3.1", + "@img/sharp-libvips-linux-s390x": "1.3.1", + "@img/sharp-libvips-linux-x64": "1.3.1", + "@img/sharp-libvips-linuxmusl-arm64": "1.3.1", + "@img/sharp-libvips-linuxmusl-x64": "1.3.1", + "@img/sharp-linux-arm": "0.35.2", + "@img/sharp-linux-arm64": "0.35.2", + "@img/sharp-linux-ppc64": "0.35.2", + "@img/sharp-linux-riscv64": "0.35.2", + "@img/sharp-linux-s390x": "0.35.2", + "@img/sharp-linux-x64": "0.35.2", + "@img/sharp-linuxmusl-arm64": "0.35.2", + "@img/sharp-linuxmusl-x64": "0.35.2", + "@img/sharp-webcontainers-wasm32": "0.35.2", + "@img/sharp-win32-arm64": "0.35.2", + "@img/sharp-win32-ia32": "0.35.2", + "@img/sharp-win32-x64": "0.35.2" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "inBundle": true, + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "inBundle": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/slash": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz", + "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==", + "inBundle": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "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/tmp": { + "version": "0.2.7", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.7.tgz", + "integrity": "sha512-e0votIpp4Uo2AJYSzVHV6xCcawuiez3DzqDAbrTc3YxBkplN6e+dM13ZeIcZnDg/QpSuU2zfZ3rzwY8ukEnaXw==", + "inBundle": true, + "license": "MIT", + "engines": { + "node": ">=14.14" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "inBundle": true, + "license": "MIT", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "license": "0BSD", + "optional": true + }, + "node_modules/tsx": { + "version": "4.23.13", + "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.23.13.tgz", + "integrity": "sha512-BL5MGkRln6aDYhb0xbQlEAGw743BaZYWdbWtdJOBriYJboKgUUYCadFp2/FpBBZquBC/ezNBn7wMMPx7FDZUDw==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "~0.28.0" + }, + "bin": { + "tsx": "dist/cli.mjs" + }, + "engines": { + "node": ">=18.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + } + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici": { + "version": "7.29.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-7.29.0.tgz", + "integrity": "sha512-IDxfleLmmbSskfWSUATiN1nfn2rDuvnMOqb5CWR92iIfojA0Ud+ulOAAEQ57LPr9rWmsreUyf5lwyao+7GNNVw==", + "license": "MIT", + "engines": { + "node": ">=20.18.1" + } + }, + "node_modules/undici-types": { + "version": "7.18.2", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.18.2.tgz", + "integrity": "sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w==", + "dev": true, + "license": "MIT" + }, + "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/universalify": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", + "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", + "inBundle": true, + "license": "MIT", + "engines": { + "node": ">= 10.0.0" + } + }, + "node_modules/wasm-feature-detect": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/wasm-feature-detect/-/wasm-feature-detect-1.8.0.tgz", + "integrity": "sha512-zksaLKM2fVlnB5jQQDqKXXwYHLQUVH9es+5TOOHwGOVJOCeRBCiPjwSg+3tN2AdTCzjgli4jijCH290kXb/zWQ==", + "inBundle": true, + "license": "Apache-2.0" + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "inBundle": true, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/workerd": { + "version": "1.20260828.1", + "resolved": "https://registry.npmjs.org/workerd/-/workerd-1.20260828.1.tgz", + "integrity": "sha512-pB9yvt0kkwZDAGZHmpY59r0o3hM0DzdW6BJERqwZOhunZ3ssOyDSgQxOQer2cSZW4YCFeOTIQYN1qwhK5wv/Cw==", + "hasInstallScript": true, + "license": "Apache-2.0", + "bin": { + "workerd": "bin/workerd" + }, + "engines": { + "node": ">=16" + }, + "optionalDependencies": { + "@cloudflare/workerd-darwin-64": "1.20260828.1", + "@cloudflare/workerd-darwin-arm64": "1.20260828.1", + "@cloudflare/workerd-linux-64": "1.20260828.1", + "@cloudflare/workerd-linux-arm64": "1.20260828.1", + "@cloudflare/workerd-windows-64": "1.20260828.1" + } + }, + "node_modules/wrangler": { + "version": "4.127.1", + "resolved": "https://registry.npmjs.org/wrangler/-/wrangler-4.127.1.tgz", + "integrity": "sha512-OzsiNgaI8i681L/+KnAKc+uEZ5D57xK5JuNvCOpRKICF4/5Q3Cu1oTGuUiT/f3GDUqQb3gzXNT0tfOHGMEtknw==", + "license": "MIT OR Apache-2.0", + "dependencies": { + "@cloudflare/kv-asset-handler": "0.5.0", + "@cloudflare/unenv-preset": "2.16.1", + "blake3-wasm": "2.1.5", + "esbuild": "0.28.1", + "miniflare": "5.20260828.0-alpha", + "path-to-regexp": "6.3.0", + "unenv": "2.0.0-rc.24", + "workerd": "1.20260828.1" + }, + "bin": { + "cf-wrangler": "bin/cf-wrangler.js", + "wrangler": "bin/wrangler.js", + "wrangler2": "bin/wrangler.js" + }, + "engines": { + "node": ">=22.0.0" + }, + "optionalDependencies": { + "fsevents": "2.3.3" + }, + "peerDependencies": { + "@cloudflare/workers-types": "^5.20260828.1" + }, + "peerDependenciesMeta": { + "@cloudflare/workers-types": { + "optional": true + } + } + }, + "node_modules/wrangler/node_modules/@esbuild/aix-ppc64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.1.tgz", + "integrity": "sha512-Svl7tq8k/08+p6CXPpRjQ1fKX+1odH/BQbb48fV6fj3CWHhsoIOoY87w1oHXm0qEpkIK3ZfVgp0hed3XBXzXMQ==", + "cpu": [ + "ppc64" + ], + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/android-arm": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.28.1.tgz", + "integrity": "sha512-0k2F129Xdio1TdJfzJ8sy1Q47vUD2NnwdhiAf7drUN1EBTfPf4hsFCtmMgu/6m8JSzsBrlmVjudMBQqOfG8usQ==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/android-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.28.1.tgz", + "integrity": "sha512-34EGEbCIAgosYz6goLcopX6Mo7NyGv9tfwEM2/7Ce2VcVRk568iSvniGWcUXIy7wEDR1wzolcxcriFVrWYcwBg==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/android-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.28.1.tgz", + "integrity": "sha512-dbwY7ltSMDWsRatcRpCnES4F+im88OCUgGZjy52shC7GqHRE/cYlxNbB4Z4UpJswpcc4Qxd2oE/ufM0p61IKng==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/darwin-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.28.1.tgz", + "integrity": "sha512-TZbWkQY7kvTAXbXUT7uVACR5cMHsDiSz9z7ZKAX/RTq/WJEk3QyRr0wZpNhBDX+/0CtdqUIJlOiodQcta6tY3Q==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/darwin-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.28.1.tgz", + "integrity": "sha512-zfdzgK9ACBNZLI/CyHTOx81SyNbM6YXn7rxSgX97VjyiPl9W1i4Ka4fgKECEoFCKGpvBj5qArWIGgQjOwkgskQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/freebsd-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.28.1.tgz", + "integrity": "sha512-wG2EA8ENdEI0qhkSZMjfqrdY+ziCYCPMmtZjjIwOmXFjmyzEHn+UUxk5of+SYsjtfs3VpnlC7QLzSI5hY/rOAw==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/freebsd-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.28.1.tgz", + "integrity": "sha512-i7dZ9vQgnvSCzi/rYCXNgtF/U+eKZNJBzu3eTQbRgHnM7tNSizLOkRFAl3qzVc/Op/u5YkHHa4pf/3DOYHthLQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/linux-arm": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.28.1.tgz", + "integrity": "sha512-qVXBOHQS+d5Y722GwJzJUtOLlX7km3CraOaGormF1pDtPd2C/l1SHRPgjLunLGe51Sh5YYWKMFDyV4SxgMQYTQ==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/linux-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.28.1.tgz", + "integrity": "sha512-yHs+0uc8+nvEAfAfxrWQKK5peSNzBc4PegcMO0EJ2hT71uA7vB8Ihg2e77R2P7SG5uYjPbHlLLmve4LLLRCf0g==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/linux-ia32": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.28.1.tgz", + "integrity": "sha512-d1z4ZuP0ajrfz/FhGT4vv278rX8KnPPJx8i5+AtK7TYbx9Le9F1hyzurZpkEyjkGa9dUGhQow4C1NmeGvqxN2w==", + "cpu": [ + "ia32" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/linux-loong64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.28.1.tgz", + "integrity": "sha512-M5sRjUVZrkm1OAPR3dlOYzNmN+loZKGVi1VUQGrwuqLcbR6qeAz+famMhjASeH3YVKvZz+zT1jlh/keC3Rj/lg==", + "cpu": [ + "loong64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/linux-mips64el": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.28.1.tgz", + "integrity": "sha512-mRObBZeHh2OxcBFPWE/FjylkRgZdYuiTR3vaTozquCGOH14iP9oN4x4Ge81CoIDYQrXmIxpFumJBu5MtZpnQJQ==", + "cpu": [ + "mips64el" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/linux-ppc64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.28.1.tgz", + "integrity": "sha512-slScBsMAb3GFDcdrCgLwZtPYRoH2H/youv10QiZyRjmsP48fznoveWytSgCI/R0ZcUgpc0ZhIUEx6LHts8yrfQ==", + "cpu": [ + "ppc64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/linux-riscv64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.28.1.tgz", + "integrity": "sha512-kw0owk1o0GFETUJyW0jc0G4Yzs0BHZn0JDZ8JRT088vjJYX777BAs1fDGxAC+q831qOs2DTC96mNsG2opdfyyQ==", + "cpu": [ + "riscv64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/linux-s390x": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.28.1.tgz", + "integrity": "sha512-/lAIjX8aYFRByhh6L5rYtPEDRqa9de/4V/juOXcta5frjvzXO4/sqEtyytse0g3zZFuWu5cDN0MkLz2qRDD2Ag==", + "cpu": [ + "s390x" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/linux-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.28.1.tgz", + "integrity": "sha512-u/anNYF2mmVOEDwLtnQ1wOr3EZ9sTNGLWrsYGYwHWzGA3Si84IOkHXlbWTD1NB+9/1lcnweYKO54uhxZydNzfA==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/netbsd-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.28.1.tgz", + "integrity": "sha512-oks0DYbLwWMmaakTsCb+zL4E+aHRVLom9IJZOAthMQEPiQmydXHkziYEsGYRx0uNV/IjEKGAV941JzH02pflqw==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/netbsd-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.28.1.tgz", + "integrity": "sha512-aeL6lAnN89Hz43Mlh1G8ARasbuoYvSITDEx0tHh5b7jJnHcssqgjy9Yx430GDpmCa6OyrKoS0aNRjKundRizGg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/openbsd-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.28.1.tgz", + "integrity": "sha512-MEFJe5C3R8pwXdZ5Y21oo6m7ePiS0d9pWucn99O/wvyJZChoIQKrQDxKrGeW8F5+T0okTHesAmDeiHDTIq0V/Q==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/openbsd-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.28.1.tgz", + "integrity": "sha512-i/ZLIOafE0Z8cI/XANJAixoJL/uRAoS2xOA3rb0xN+KK0K177cMAsQYkzHtBrtMXAKuAc7HGgcWiZ/sRC1Nxgw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/openharmony-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.1.tgz", + "integrity": "sha512-ge+Z7EXFNt2BO1oAMsVpiQ8EwndV9i1xXerAeTIK7AtPs3bKFXQM7nlRxDSIUIMeueR1CNXxqztLzdNeReKBJg==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/sunos-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.28.1.tgz", + "integrity": "sha512-BEjgtECkL3vY+SaSQ6nzVfiALUeFxpawyp8Jmf5PtYhf1Ug40N1h/hxlhts+f1FvSvarEigdxS3BlSMI2PJLcQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/win32-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.28.1.tgz", + "integrity": "sha512-lCv9eK/H6ZJWbE7bh2nw54CZ9M2nupBxJcTsdk/QQnWkdSjKGuxmmH8/GWrlT1eMmZfn4dGcCjRte397WqfQXA==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/win32-ia32": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.28.1.tgz", + "integrity": "sha512-zvb/mB2bSCoJOpoCBgYKKpX6YM6mJBlBUVUtVj41DlZJVEB6/0CKlRYxP5wWl1C1ILiCoAU5wZZ4q1P3qeS6Eg==", + "cpu": [ + "ia32" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/@esbuild/win32-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.28.1.tgz", + "integrity": "sha512-bm4Mowrv+GXMlpWX++EcXw/iLyd1o3+bJkC2DkWXYVvgZCqD/bSj9ctZeAMC3cIxgjRVR2Dufaiu4YPxr5gW1A==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/wrangler/node_modules/esbuild": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.1.tgz", + "integrity": "sha512-HrJrvZv5ayxBzPfwphOoNzkzOIIlifzk0KJrGK2c8R4+LKpMtpYLQeUdjnwjWv/LZlkH2laZk+4w78pi99D4Vw==", + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.28.1", + "@esbuild/android-arm": "0.28.1", + "@esbuild/android-arm64": "0.28.1", + "@esbuild/android-x64": "0.28.1", + "@esbuild/darwin-arm64": "0.28.1", + "@esbuild/darwin-x64": "0.28.1", + "@esbuild/freebsd-arm64": "0.28.1", + "@esbuild/freebsd-x64": "0.28.1", + "@esbuild/linux-arm": "0.28.1", + "@esbuild/linux-arm64": "0.28.1", + "@esbuild/linux-ia32": "0.28.1", + "@esbuild/linux-loong64": "0.28.1", + "@esbuild/linux-mips64el": "0.28.1", + "@esbuild/linux-ppc64": "0.28.1", + "@esbuild/linux-riscv64": "0.28.1", + "@esbuild/linux-s390x": "0.28.1", + "@esbuild/linux-x64": "0.28.1", + "@esbuild/netbsd-arm64": "0.28.1", + "@esbuild/netbsd-x64": "0.28.1", + "@esbuild/openbsd-arm64": "0.28.1", + "@esbuild/openbsd-x64": "0.28.1", + "@esbuild/openharmony-arm64": "0.28.1", + "@esbuild/sunos-x64": "0.28.1", + "@esbuild/win32-arm64": "0.28.1", + "@esbuild/win32-ia32": "0.28.1", + "@esbuild/win32-x64": "0.28.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/yaml": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.9.0.tgz", + "integrity": "sha512-2AvhNX3mb8zd6Zy7INTtSpl1F15HW6Wnqj0srWlkKLcpYl/gMIMJiyuGq2KeI2YFxUPjdlB+3Lc10seMLtL4cA==", + "inBundle": true, + "license": "ISC", + "bin": { + "yaml": "bin.mjs" + }, + "engines": { + "node": ">= 14.6" + }, + "funding": { + "url": "https://github.com/sponsors/eemeli" + } + }, + "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/zstddec": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/zstddec/-/zstddec-0.2.0.tgz", + "integrity": "sha512-oyPnDa1X5c13+Y7mA/FDMNJrn4S8UNBe0KCqtDmor40Re7ALrPN6npFwyYVRRh+PqozZQdeg23QtbcamZnG5rA==", + "inBundle": true, + "license": "MIT AND BSD-3-Clause" + }, + "vendor/wp-codebox-core": { + "name": "@automattic/wp-codebox-core", + "version": "0.26.2" + } + } +} diff --git a/packages/runtime-cloudflare/package.json b/packages/runtime-cloudflare/package.json index c7dd46049..f37064a37 100644 --- a/packages/runtime-cloudflare/package.json +++ b/packages/runtime-cloudflare/package.json @@ -3,11 +3,81 @@ "version": "0.12.27", "private": true, "type": "module", + "engines": { + "node": ">=22.0.0" + }, + "files": [ + "assets", + "components", + "patches", + "scripts", + "src", + "tests", + "vendor", + "README.md", + "npm-shrinkwrap.json", + "tsconfig.json", + "wrangler.jsonc", + "wrangler.d1.jsonc", + "wrangler.control.jsonc", + "wrangler.public-reader.jsonc" + ], + "scripts": { + "postinstall": "node scripts/apply-development-patch.mjs", + "build": "tsc -p tsconfig.json --noEmit", + "check": "npm run build && npm run test:package-boundaries && npm test && npm run dry-run:all && npm run package:dry-run", + "test:package-boundaries": "node --test tests/package-dependency-boundary.test.mjs tests/package-command-boundary.test.mjs", + "test": "npm run test:package-boundaries && tsx --test tests/cloudflare-*.test.*", + "test:queue": "tsx --test tests/cloudflare-queue-batch.test.ts tests/cloudflare-d1-operation-repository.test.ts && npm run build", + "test:principal-credentials": "tsx --test tests/cloudflare-principal-credential-operator.test.mjs tests/cloudflare-principal-credential-repository.test.ts tests/cloudflare-provisioning-api.test.ts", + "test:remote-principal-credential-gate": "node --test tests/cloudflare-remote-principal-credential-gate.test.mjs", + "test:packed-wrangler": "node tests/packed-wrangler-bundle.test.mjs", + "dry-run": "wrangler deploy --dry-run --config wrangler.jsonc", + "dry-run:d1": "wrangler deploy --dry-run --config wrangler.d1.jsonc", + "dry-run:control": "wrangler deploy --dry-run --config wrangler.control.jsonc", + "dry-run:public-reader": "wrangler deploy --dry-run --config wrangler.public-reader.jsonc", + "dry-run:all": "npm run dry-run && npm run dry-run:d1 && npm run dry-run:control && npm run dry-run:public-reader", + "package:dry-run": "npm pack . --dry-run --json --workspaces=false", + "local-gate": "playwright install chromium && node scripts/local-gate.mjs", + "local-gate:d1": "playwright install chromium && node scripts/local-gate.mjs --coordinator=d1", + "local-gate:provisioning": "playwright install chromium && node scripts/local-gate.mjs --coordinator=d1 --public-provisioning", + "remote-gate:principal-credentials": "node scripts/remote-principal-credential-gate.mjs", + "generate:wordpress-runtime-corpus": "tsx scripts/generate-wordpress-runtime-corpus.ts", + "provision:wordpress-runtime-corpus": "node scripts/provision-wordpress-runtime-corpus.mjs", + "provision:d1-coordinator": "node scripts/provision-d1-coordinator.mjs", + "operator:principal-credential": "tsx scripts/operator-principal-credential.ts", + "generate:mdi-runtime-bundle": "node scripts/build-mdi-runtime-bundle.mjs", + "generate:canonical-mdi-seed": "npm run generate:mdi-runtime-bundle && php scripts/build-canonical-mdi-seed.php" + }, "dependencies": { - "@automattic/wp-codebox-core": "file:../runtime-core", + "@automattic/wp-codebox-core": "file:vendor/wp-codebox-core", "@php-wasm/stream-compression": "3.1.45", "@php-wasm/universal": "3.1.46", "@php-wasm/web-8-5": "3.1.46", - "@wp-playground/wordpress": "3.1.46" - } + "@wp-playground/wordpress": "3.1.46", + "patch-package": "^8.0.1", + "wrangler": "4.127.1" + }, + "bundleDependencies": [ + "@automattic/wp-codebox-core", + "@php-wasm/stream-compression", + "@php-wasm/universal", + "@php-wasm/web-8-5", + "@wp-playground/wordpress", + "patch-package" + ], + "devDependencies": { + "@cloudflare/workers-types": "^5.20260718.1", + "@types/node": "^24.0.0", + "pixelmatch": "7.2.0", + "playwright": "1.61.1", + "pngjs": "7.0.0", + "tsx": "^4.20.0", + "typescript": "^5.8.0" + }, + "overrides": { + "@php-wasm/util": "3.1.46" + }, + "wpCodeboxCoreCompatibility": "0.26.2", + "wpCodeboxCoreSourceCommit": "d3fac4ad4e4bbf6dd457ea2cd46aeb1a081b217b" } diff --git a/patches/@php-wasm+stream-compression+3.1.45.patch b/packages/runtime-cloudflare/patches/@php-wasm+stream-compression+3.1.45.patch similarity index 100% rename from patches/@php-wasm+stream-compression+3.1.45.patch rename to packages/runtime-cloudflare/patches/@php-wasm+stream-compression+3.1.45.patch diff --git a/packages/runtime-cloudflare/scripts/apply-development-patch.mjs b/packages/runtime-cloudflare/scripts/apply-development-patch.mjs new file mode 100644 index 000000000..fd9481ab4 --- /dev/null +++ b/packages/runtime-cloudflare/scripts/apply-development-patch.mjs @@ -0,0 +1,14 @@ +import { execFileSync } from "node:child_process" +import { createRequire } from "node:module" +import { dirname, relative, resolve } from "node:path" + +const packageRoot = resolve(import.meta.dirname, "..") +const packageRequire = createRequire(resolve(packageRoot, "package.json")) +const dependencyRoot = dirname(packageRequire.resolve("@php-wasm/stream-compression/package.json")) +const installRoot = resolve(dependencyRoot, "../../..") +const patchDirectory = resolve(packageRoot, "patches") + +execFileSync(process.execPath, [packageRequire.resolve("patch-package"), "--patch-dir", relative(installRoot, patchDirectory)], { + cwd: installRoot, + stdio: "inherit", +}) diff --git a/scripts/build-cloudflare-canonical-mdi-seed.php b/packages/runtime-cloudflare/scripts/build-canonical-mdi-seed.php similarity index 99% rename from scripts/build-cloudflare-canonical-mdi-seed.php rename to packages/runtime-cloudflare/scripts/build-canonical-mdi-seed.php index 8e3525a08..b97d1534d 100644 --- a/scripts/build-cloudflare-canonical-mdi-seed.php +++ b/packages/runtime-cloudflare/scripts/build-canonical-mdi-seed.php @@ -60,7 +60,7 @@ function cloudflare_seed_files( string $root ): array { } $repository = dirname( __DIR__ ); -$assets = $repository . '/packages/runtime-cloudflare/assets'; +$assets = $repository . '/assets'; $runtime_zip = $assets . '/markdown-database-integration-runtime.zip'; $sqlite_seed = $assets . '/wordpress-install-seed.sqlite'; $output_zip = $assets . '/markdown-database-integration-canonical-seed.zip'; diff --git a/scripts/build-cloudflare-mdi-runtime-bundle.mjs b/packages/runtime-cloudflare/scripts/build-mdi-runtime-bundle.mjs similarity index 96% rename from scripts/build-cloudflare-mdi-runtime-bundle.mjs rename to packages/runtime-cloudflare/scripts/build-mdi-runtime-bundle.mjs index c30ee1010..edebc2d47 100644 --- a/scripts/build-cloudflare-mdi-runtime-bundle.mjs +++ b/packages/runtime-cloudflare/scripts/build-mdi-runtime-bundle.mjs @@ -6,7 +6,7 @@ const jsonMachineRevision = "8bf0b0ff6ff60ab480778eaa5ad7d505b442c2d4" const archiveUrl = `https://codeload.github.com/Automattic/markdown-database-integration/zip/${revision}` const jsonMachineArchiveUrl = `https://codeload.github.com/halaxa/json-machine/zip/${jsonMachineRevision}` const sourceDirectory = process.env.MDI_RUNTIME_SOURCE -const output = new URL("../packages/runtime-cloudflare/assets/markdown-database-integration-runtime.zip", import.meta.url) +const output = new URL("../assets/markdown-database-integration-runtime.zip", import.meta.url) const runtimePaths = new Set([ "db.php", diff --git a/scripts/generate-cloudflare-wordpress-runtime-corpus.ts b/packages/runtime-cloudflare/scripts/generate-wordpress-runtime-corpus.ts similarity index 85% rename from scripts/generate-cloudflare-wordpress-runtime-corpus.ts rename to packages/runtime-cloudflare/scripts/generate-wordpress-runtime-corpus.ts index 1b874fa36..96a0298ae 100644 --- a/scripts/generate-cloudflare-wordpress-runtime-corpus.ts +++ b/packages/runtime-cloudflare/scripts/generate-wordpress-runtime-corpus.ts @@ -2,26 +2,27 @@ import { createHash } from "node:crypto" import { mkdir, writeFile } from "node:fs/promises" import { dirname, resolve } from "node:path" import { decodeZip, encodeZip } from "@php-wasm/stream-compression" -import { isWordPressRuntimeFile, isWordPressStaticAsset } from "../packages/runtime-cloudflare/src/wordpress-runtime-corpus.js" -import { WORDPRESS_RUNTIME_ARTIFACT_SCHEMA, wordpressRuntimeArtifactKey, type WordPressRuntimeArtifactManifest } from "../packages/runtime-cloudflare/src/wordpress-runtime-artifact.js" -import { WORDPRESS_STATIC_ARTIFACT_SCHEMA, validateWordPressStaticArtifactManifest, wordpressStaticArtifactKey, type WordPressStaticArtifactManifest } from "../packages/runtime-cloudflare/src/wordpress-static-artifact.js" -import { RUNTIME_ARCHIVE_ARTIFACT_SCHEMA, runtimeArchiveArtifactKey, validateRuntimeArchiveArtifactManifest, type RuntimeArchiveArtifactManifest } from "../packages/runtime-cloudflare/src/runtime-archive-artifact.js" -import { runtimeArchiveComponentSource } from "../packages/runtime-core/src/runtime-archive-component.js" -import { parseRuntimePackageManifest, selectRuntimePackageProfileFiles } from "../packages/runtime-core/src/runtime-package-profile.js" -import websiteImporterSourceContract from "../packages/runtime-cloudflare/components/website-importer.json" with { type: "json" } +import { runtimeArchiveComponentSource } from "@automattic/wp-codebox-core/runtime-archive-component" +import { parseRuntimePackageManifest, selectRuntimePackageProfileFiles } from "@automattic/wp-codebox-core/runtime-package-profile" +import { isWordPressRuntimeFile, isWordPressStaticAsset } from "../src/wordpress-runtime-corpus.js" +import { WORDPRESS_RUNTIME_ARTIFACT_SCHEMA, wordpressRuntimeArtifactKey, type WordPressRuntimeArtifactManifest } from "../src/wordpress-runtime-artifact.js" +import { WORDPRESS_STATIC_ARTIFACT_SCHEMA, validateWordPressStaticArtifactManifest, wordpressStaticArtifactKey, type WordPressStaticArtifactManifest } from "../src/wordpress-static-artifact.js" +import { RUNTIME_ARCHIVE_ARTIFACT_SCHEMA, runtimeArchiveArtifactKey, validateRuntimeArchiveArtifactManifest, type RuntimeArchiveArtifactManifest } from "../src/runtime-archive-artifact.js" +import websiteImporterSourceContract from "../components/website-importer.json" with { type: "json" } +const packageRoot = resolve(import.meta.dirname, "..") const sourceUrl = process.env.WORDPRESS_RUNTIME_ARCHIVE_URL ?? "https://downloads.wordpress.org/release/wordpress-7.0.2.zip" const sourceVersion = process.env.WORDPRESS_RUNTIME_VERSION ?? "7.0.2" -const output = resolve(process.env.WORDPRESS_RUNTIME_ARTIFACT_OUTPUT ?? "artifacts/cloudflare-wordpress-runtime-corpus.zip") -const manifestOutput = resolve("packages/runtime-cloudflare/assets/wordpress-runtime-artifact.json") -const staticOutput = resolve(process.env.WORDPRESS_STATIC_ARTIFACT_OUTPUT ?? "artifacts/cloudflare-wordpress-static-corpus.bin") -const staticManifestOutput = resolve("packages/runtime-cloudflare/assets/wordpress-static-artifact.json") +const output = resolve(process.env.WORDPRESS_RUNTIME_ARTIFACT_OUTPUT ?? resolve(packageRoot, "artifacts/cloudflare-wordpress-runtime-corpus.zip")) +const manifestOutput = resolve(packageRoot, "assets/wordpress-runtime-artifact.json") +const staticOutput = resolve(process.env.WORDPRESS_STATIC_ARTIFACT_OUTPUT ?? resolve(packageRoot, "artifacts/cloudflare-wordpress-static-corpus.bin")) +const staticManifestOutput = resolve(packageRoot, "assets/wordpress-static-artifact.json") const sqliteSourceUrl = "https://github.com/WordPress/sqlite-database-integration/releases/download/v2.2.23/plugin-sqlite-database-integration.zip" -const sqliteOutput = resolve("artifacts/cloudflare-sqlite-database-integration.zip") -const sqliteManifestOutput = resolve("packages/runtime-cloudflare/assets/sqlite-database-integration-artifact.json") +const sqliteOutput = resolve(packageRoot, "artifacts/cloudflare-sqlite-database-integration.zip") +const sqliteManifestOutput = resolve(packageRoot, "assets/sqlite-database-integration-artifact.json") const websiteImporterSource = runtimeArchiveComponentSource(websiteImporterSourceContract) -const websiteImporterOutput = resolve(`artifacts/cloudflare-${websiteImporterSource.component.id}.zip`) -const websiteImporterManifestOutput = resolve(`packages/runtime-cloudflare/assets/${websiteImporterSource.component.id}-artifact.json`) +const websiteImporterOutput = resolve(packageRoot, `artifacts/cloudflare-${websiteImporterSource.component.id}.zip`) +const websiteImporterManifestOutput = resolve(packageRoot, `assets/${websiteImporterSource.component.id}-artifact.json`) const response = await fetch(sourceUrl) if (!response.ok || !response.body) throw new Error(`Unable to download WordPress archive: ${response.status}.`) const identity = response.headers.get("etag") ?? response.headers.get("last-modified") ?? undefined @@ -57,7 +58,7 @@ for (const file of staticSelected) { if (bytes.byteLength) staticChunks.push(bytes) staticOffset += bytes.byteLength } -const staticBlob = new Uint8Array(await new Blob(staticChunks).arrayBuffer()) +const staticBlob = new Uint8Array(Buffer.concat(staticChunks.map((chunk) => Buffer.from(chunk)))) const staticSha256 = sha256Hex(staticBlob) const staticManifest: WordPressStaticArtifactManifest = { schema: WORDPRESS_STATIC_ARTIFACT_SCHEMA, diff --git a/scripts/cloudflare-local-gate.mjs b/packages/runtime-cloudflare/scripts/local-gate.mjs similarity index 97% rename from scripts/cloudflare-local-gate.mjs rename to packages/runtime-cloudflare/scripts/local-gate.mjs index a736f7f83..73478c5b6 100644 --- a/scripts/cloudflare-local-gate.mjs +++ b/packages/runtime-cloudflare/scripts/local-gate.mjs @@ -3,12 +3,13 @@ import { createHash, createHmac } from "node:crypto" import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises" import { createServer } from "node:http" import { tmpdir } from "node:os" -import { join } from "node:path" +import { join, resolve } from "node:path" import { stripVTControlCharacters } from "node:util" import { encodeZip } from "@php-wasm/stream-compression" -import { runVisualCompareCommand } from "../packages/runtime-playground/dist/browser-visual-compare.js" -import publicationContract from "../packages/runtime-cloudflare/src/publication-contract.json" with { type: "json" } +import { assertVisualParity } from "./visual-parity.mjs" +import publicationContract from "../src/publication-contract.json" with { type: "json" } +const packageRoot = resolve(import.meta.dirname, "..") const port = 8792 const origin = `http://127.0.0.1:${port}` const password = "cloudflare-runtime-test-password" @@ -22,8 +23,8 @@ const runtimeDispatchAttempts = new Map() const coordinator = process.argv.includes("--coordinator=d1") ? "d1" : "durable-object" const publicProvisioning = process.argv.includes("--public-provisioning") const artifactPath = process.argv.find((argument) => argument.startsWith("--artifact="))?.slice("--artifact=".length) -const executionWranglerConfig = coordinator === "d1" ? "packages/runtime-cloudflare/wrangler.d1.jsonc" : "packages/runtime-cloudflare/wrangler.jsonc" -const controlWranglerConfig = "packages/runtime-cloudflare/wrangler.control.jsonc" +const executionWranglerConfig = resolve(packageRoot, coordinator === "d1" ? "wrangler.d1.jsonc" : "wrangler.jsonc") +const controlWranglerConfig = resolve(packageRoot, "wrangler.control.jsonc") const stateDirectory = await mkdtemp(join(tmpdir(), "wp-codebox-cloudflare-gate-")) const cookies = [] let siteContexts = [{ id: "default", hostname: "127.0.0.1", origin }] @@ -36,8 +37,8 @@ function siteCredential(rootCredential, siteId, purpose) { } try { - await run("npm", ["run", "generate:cloudflare-wordpress-runtime-corpus"]) - await run("npm", ["run", "provision:cloudflare-wordpress-runtime-corpus", "--", "--local", "--persist-to", stateDirectory]) + await run("npm", ["run", "generate:wordpress-runtime-corpus"]) + await run("npm", ["run", "provision:wordpress-runtime-corpus", "--", "--local", "--persist-to", stateDirectory]) const staticArtifactImport = await provisionStaticArtifact() await startWorker(!publicProvisioning && coordinator === "durable-object", publicProvisioning ? controlWranglerConfig : executionWranglerConfig) if (publicProvisioning) { @@ -150,7 +151,7 @@ try { async function run(command, args) { await new Promise((resolve, reject) => { - const childProcess = spawn(command, args, { cwd: process.cwd(), stdio: "inherit" }) + const childProcess = spawn(command, args, { cwd: packageRoot, env: childEnvironment(), stdio: "inherit" }) childProcess.on("error", reject) childProcess.on("exit", (code) => code === 0 ? resolve(undefined) : reject(new Error(`${command} ${args.join(" ")} failed with status ${code}.`))) }) @@ -234,7 +235,7 @@ h2{margin:0;font-size:34px;line-height:1.05;letter-spacing:-.035em}h3{margin:0 0 if (!publicProvisioning) { const path = join(stateDirectory, "static-site-artifact.json") await writeFile(path, serialized) - await run("npm", ["exec", "--", "wrangler", "r2", "object", "put", `wp-codebox-runtime-chubes/${key}`, "--file", path, "--local", "--persist-to", stateDirectory]) + await run("wrangler", ["r2", "object", "put", `wp-codebox-runtime-chubes/${key}`, "--file", path, "--local", "--persist-to", stateDirectory]) } const request = { schema: "wp-codebox/cloudflare-static-artifact-import-request/v1", @@ -369,31 +370,7 @@ async function assertStaticArtifactVisualParity(serialized, importedPages) { const route = new URL(page.route, origin).pathname if (!routes.has(route)) throw new Error(`Imported route ${route} has no exact source-artifact document.`) const artifactRoot = join(stateDirectory, "visual-parity", route === "/" ? "home" : route.replace(/^\/|\/$/g, "").replaceAll("/", "-")) - const comparison = await runVisualCompareCommand({ - artifactRoot, - server: { - serverUrl: sourceOrigin, - playground: { run: async () => ({ text: "" }) }, - async [Symbol.asyncDispose]() {}, - }, - spec: { - command: "wordpress.visual-compare", - args: [ - `source-url=${sourceOrigin}${route}`, - `candidate-url=${origin}${route}`, - "viewport=1280x720", - "full-page=true", - "threshold=0", - "include-aa=true", - "block-external-requests=true", - "timeout=120s", - ], - }, - }) - const summary = JSON.parse(comparison.output) - if (summary.status !== "identical" || summary.comparison?.mismatchPixels !== 0 || summary.comparison?.dimensionMismatch) { - throw new Error(`Static artifact visual parity failed for ${route}: ${JSON.stringify({ status: summary.status, comparison: summary.comparison, files: summary.files, artifactRoot })}.`) - } + await assertVisualParity({ sourceUrl: `${sourceOrigin}${route}`, candidateUrl: `${origin}${route}`, artifactRoot }) console.log(`Static artifact visual parity passed for ${route}: 0 mismatched pixels at 1280x720.`) } } finally { @@ -477,11 +454,11 @@ async function assertTwoSiteIsolation() { async function startWorker(testScheduled = coordinator === "durable-object", config = executionWranglerConfig) { output = "" const apiTokens = [{ id: "local-gate", principal: "local-gate", digest: createHash("sha256").update(apiToken).digest("hex"), scopes: ["sites:create", "sites:read", "sites:import", "operations:read"], expiresAt: "2099-01-01T00:00:00.000Z", maxSites: 1 }] - const args = ["exec", "--", "wrangler", "dev", ...(testScheduled ? ["--test-scheduled"] : []), "--config", config, "--port", String(port), "--persist-to", stateDirectory, "--var", `WORDPRESS_ADMIN_PASSWORD:${password}`, "--var", `WORDPRESS_ADMIN_CLAIM_SECRET:${administratorClaimSecret}`, "--var", `WORDPRESS_AUTH_SECRET:${authSecret}`, "--var", `WORDPRESS_OPERATOR_TOKEN:${operatorToken}`, "--var", `WORDPRESS_API_TOKENS:${JSON.stringify(apiTokens)}`, "--var", `WORDPRESS_SITE_CONTEXTS:${JSON.stringify(siteContexts)}`] - child = spawn("npm", args, { - cwd: process.cwd(), + const args = ["dev", ...(testScheduled ? ["--test-scheduled"] : []), "--config", config, "--port", String(port), "--persist-to", stateDirectory, "--var", `WORDPRESS_ADMIN_PASSWORD:${password}`, "--var", `WORDPRESS_ADMIN_CLAIM_SECRET:${administratorClaimSecret}`, "--var", `WORDPRESS_AUTH_SECRET:${authSecret}`, "--var", `WORDPRESS_OPERATOR_TOKEN:${operatorToken}`, "--var", `WORDPRESS_API_TOKENS:${JSON.stringify(apiTokens)}`, "--var", `WORDPRESS_SITE_CONTEXTS:${JSON.stringify(siteContexts)}`] + child = spawn("wrangler", args, { + cwd: packageRoot, // The host PAC resolves these public archive hosts through an unavailable local proxy. - env: { ...process.env, NO_PROXY: "wordpress.org,github.com,codeload.github.com", no_proxy: "wordpress.org,github.com,codeload.github.com" }, + env: { ...childEnvironment(), NO_PROXY: "wordpress.org,github.com,codeload.github.com", no_proxy: "wordpress.org,github.com,codeload.github.com" }, stdio: ["ignore", "pipe", "pipe"], }) child.stdout.on("data", (chunk) => { @@ -495,6 +472,8 @@ async function startWorker(testScheduled = coordinator === "durable-object", con await waitForServer() } +function childEnvironment() { return Object.fromEntries(Object.entries(process.env).filter(([name, value]) => name !== "NODE_OPTIONS" || !value?.includes("register-package-local-loader"))) } + async function stopWorker() { if (!child || child.exitCode !== null) return child.kill("SIGTERM") diff --git a/scripts/operator-cloudflare-principal-credential.ts b/packages/runtime-cloudflare/scripts/operator-principal-credential.ts similarity index 96% rename from scripts/operator-cloudflare-principal-credential.ts rename to packages/runtime-cloudflare/scripts/operator-principal-credential.ts index 8b7b3facd..b8606af0a 100644 --- a/scripts/operator-cloudflare-principal-credential.ts +++ b/packages/runtime-cloudflare/scripts/operator-principal-credential.ts @@ -3,12 +3,13 @@ import { createHash, randomUUID } from "node:crypto" import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises" import { tmpdir } from "node:os" import { join, resolve } from "node:path" -import { PRINCIPAL_CREDENTIAL_SCHEMA, validatePrincipalCredentialVersion, type PrincipalCredentialVersion } from "../packages/runtime-cloudflare/src/principal-credential-repository.js" +import { PRINCIPAL_CREDENTIAL_SCHEMA, validatePrincipalCredentialVersion, type PrincipalCredentialVersion } from "../src/principal-credential-repository.js" class OperatorError extends Error { constructor(message: string, readonly code = "operation-failed") { super(message) } } class ProviderError extends Error { constructor(readonly output: string) { super("Provider operation failed.") } } const PROVIDER_OUTPUT_LIMIT = 16_384 const PROVIDER_TIMEOUT_MS = 30_000 +const packageRoot = resolve(import.meta.dirname, "..") main().catch((error) => { const code = error instanceof OperatorError ? error.code : "operation-failed" @@ -25,7 +26,7 @@ async function main(): Promise { const config = flags.get("--config") const credentialId = flags.get("--credential-id") const version = flags.get("--version") - const wrangler = resolve(flags.get("--wrangler") ?? "node_modules/.bin/wrangler") + const wrangler = resolve(flags.get("--wrangler") ?? resolve(packageRoot, "node_modules/.bin/wrangler")) const local = flags.has("--local") const persistTo = flags.get("--persist-to") const accountId = flags.get("--account-id") @@ -159,7 +160,7 @@ async function readStdin(): Promise { function run(wrangler: string, command: string[]): Promise<{ stdout: string }> { return new Promise((resolveRun, reject) => { - const child = spawn(wrangler, command, { cwd: process.cwd(), stdio: ["ignore", "pipe", "pipe"] }) + const child = spawn(wrangler, command, { cwd: packageRoot, env: childEnvironment(), stdio: ["ignore", "pipe", "pipe"] }) let stdout = Buffer.alloc(0) let stderr = Buffer.alloc(0) let terminated = false @@ -174,6 +175,8 @@ function run(wrangler: string, command: string[]): Promise<{ stdout: string }> { }) } +function childEnvironment(): NodeJS.ProcessEnv { const environment = { ...process.env }; if (environment.NODE_OPTIONS?.includes("register-package-local-loader")) delete environment.NODE_OPTIONS; return environment } + function findMarker(value: unknown): string | undefined { if (!value || typeof value !== "object") return undefined if ("wp_codebox_operator_result" in value && typeof value.wp_codebox_operator_result === "string") return value.wp_codebox_operator_result diff --git a/scripts/provision-cloudflare-d1-coordinator.mjs b/packages/runtime-cloudflare/scripts/provision-d1-coordinator.mjs similarity index 87% rename from scripts/provision-cloudflare-d1-coordinator.mjs rename to packages/runtime-cloudflare/scripts/provision-d1-coordinator.mjs index f1773fa41..8498902e2 100644 --- a/scripts/provision-cloudflare-d1-coordinator.mjs +++ b/packages/runtime-cloudflare/scripts/provision-d1-coordinator.mjs @@ -2,6 +2,7 @@ import { spawn } from "node:child_process" import { readFile, writeFile } from "node:fs/promises" import { dirname, resolve } from "node:path" +const packageRoot = resolve(import.meta.dirname, "..") const args = process.argv.slice(2) const option = (name, fallback) => { const index = args.indexOf(name) @@ -9,9 +10,9 @@ const option = (name, fallback) => { } const databaseName = option("--database-name", "wp-codebox-runtime-state") const binding = option("--binding", "WORDPRESS_STATE_DATABASE") -const templatePath = resolve(option("--template", "packages/runtime-cloudflare/wrangler.d1.jsonc")) +const templatePath = resolve(option("--template", resolve(packageRoot, "wrangler.d1.jsonc"))) const outputPath = resolve(option("--output")) -const wrangler = option("--wrangler", resolve("node_modules/.bin/wrangler")) +const wrangler = option("--wrangler", resolve(packageRoot, "node_modules/.bin/wrangler")) if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(databaseName) || !/^[A-Z][A-Z0-9_]*$/.test(binding) || !option("--output")) throw new Error("A safe database name, binding, and --output path are required.") let databases = await listDatabases() @@ -42,7 +43,7 @@ async function listDatabases() { async function run(command) { return new Promise((resolveRun, reject) => { - const child = spawn(wrangler, command, { cwd: process.cwd(), stdio: ["ignore", "pipe", "pipe"] }) + const child = spawn(wrangler, command, { cwd: packageRoot, env: childEnvironment(), stdio: ["ignore", "pipe", "pipe"] }) let stdout = "" let stderr = "" child.stdout.setEncoding("utf8") @@ -54,6 +55,8 @@ async function run(command) { }) } +function childEnvironment() { return Object.fromEntries(Object.entries(process.env).filter(([name, value]) => name !== "NODE_OPTIONS" || !value?.includes("register-package-local-loader"))) } + function parseJsonc(value) { let output = "" let string = false diff --git a/scripts/provision-cloudflare-wordpress-runtime-corpus.mjs b/packages/runtime-cloudflare/scripts/provision-wordpress-runtime-corpus.mjs similarity index 57% rename from scripts/provision-cloudflare-wordpress-runtime-corpus.mjs rename to packages/runtime-cloudflare/scripts/provision-wordpress-runtime-corpus.mjs index 222101800..cf122aaf4 100644 --- a/scripts/provision-cloudflare-wordpress-runtime-corpus.mjs +++ b/packages/runtime-cloudflare/scripts/provision-wordpress-runtime-corpus.mjs @@ -1,6 +1,9 @@ import { createHash } from "node:crypto" import { readFile } from "node:fs/promises" import { spawn } from "node:child_process" +import { resolve } from "node:path" + +const packageRoot = resolve(import.meta.dirname, "..") const args = process.argv.slice(2) const local = args.includes("--local") @@ -9,35 +12,37 @@ const persistIndex = args.indexOf("--persist-to") const persistTo = persistIndex === -1 ? undefined : args[persistIndex + 1] if (local === remote || (local && !persistTo)) throw new Error("Use exactly one of --local --persist-to or --remote.") -const manifest = JSON.parse(await readFile("packages/runtime-cloudflare/assets/wordpress-runtime-artifact.json", "utf8")) -const archive = await readFile("artifacts/cloudflare-wordpress-runtime-corpus.zip") +const manifest = JSON.parse(await readFile(resolve(packageRoot, "assets/wordpress-runtime-artifact.json"), "utf8")) +const archive = await readFile(resolve(packageRoot, "artifacts/cloudflare-wordpress-runtime-corpus.zip")) const actual = createHash("sha256").update(archive).digest("hex") if (actual !== manifest.archive.sha256 || archive.byteLength !== manifest.archive.size || manifest.key !== `runtime/wordpress/${actual}.zip`) throw new Error("Local WordPress runtime artifact does not match its content-addressed manifest.") -const staticManifest = JSON.parse(await readFile("packages/runtime-cloudflare/assets/wordpress-static-artifact.json", "utf8")) -const staticBlob = await readFile("artifacts/cloudflare-wordpress-static-corpus.bin") +const staticManifest = JSON.parse(await readFile(resolve(packageRoot, "assets/wordpress-static-artifact.json"), "utf8")) +const staticBlob = await readFile(resolve(packageRoot, "artifacts/cloudflare-wordpress-static-corpus.bin")) const staticActual = createHash("sha256").update(staticBlob).digest("hex") if (staticActual !== staticManifest.blob.sha256 || staticBlob.byteLength !== staticManifest.blob.size || staticManifest.key !== `runtime/wordpress-static/${staticActual}.bin`) throw new Error("Local WordPress static artifact does not match its content-addressed manifest.") -const sqliteManifest = JSON.parse(await readFile("packages/runtime-cloudflare/assets/sqlite-database-integration-artifact.json", "utf8")) -const sqliteArchive = await readFile("artifacts/cloudflare-sqlite-database-integration.zip") +const sqliteManifest = JSON.parse(await readFile(resolve(packageRoot, "assets/sqlite-database-integration-artifact.json"), "utf8")) +const sqliteArchive = await readFile(resolve(packageRoot, "artifacts/cloudflare-sqlite-database-integration.zip")) const sqliteActual = createHash("sha256").update(sqliteArchive).digest("hex") if (sqliteActual !== sqliteManifest.archive.sha256 || sqliteArchive.byteLength !== sqliteManifest.archive.size || sqliteManifest.key !== `runtime/archives/sqlite-database-integration/${sqliteActual}.zip`) throw new Error("Local SQLite integration artifact does not match its content-addressed manifest.") -const websiteImporterManifest = JSON.parse(await readFile("packages/runtime-cloudflare/assets/website-importer-artifact.json", "utf8")) -const websiteImporterArchive = await readFile("artifacts/cloudflare-website-importer.zip") +const websiteImporterManifest = JSON.parse(await readFile(resolve(packageRoot, "assets/website-importer-artifact.json"), "utf8")) +const websiteImporterArchive = await readFile(resolve(packageRoot, "artifacts/cloudflare-website-importer.zip")) const websiteImporterActual = createHash("sha256").update(websiteImporterArchive).digest("hex") if (websiteImporterActual !== websiteImporterManifest.archive.sha256 || websiteImporterArchive.byteLength !== websiteImporterManifest.archive.size || websiteImporterManifest.key !== `runtime/archives/${websiteImporterManifest.name}/${websiteImporterActual}.zip`) throw new Error("Local website importer artifact does not match its content-addressed manifest.") for (const artifact of [ - { key: manifest.key, size: manifest.archive.size, file: "artifacts/cloudflare-wordpress-runtime-corpus.zip" }, - { key: staticManifest.key, size: staticManifest.blob.size, file: "artifacts/cloudflare-wordpress-static-corpus.bin" }, - { key: sqliteManifest.key, size: sqliteManifest.archive.size, file: "artifacts/cloudflare-sqlite-database-integration.zip" }, - { key: websiteImporterManifest.key, size: websiteImporterManifest.archive.size, file: "artifacts/cloudflare-website-importer.zip" }, + { key: manifest.key, size: manifest.archive.size, file: resolve(packageRoot, "artifacts/cloudflare-wordpress-runtime-corpus.zip") }, + { key: staticManifest.key, size: staticManifest.blob.size, file: resolve(packageRoot, "artifacts/cloudflare-wordpress-static-corpus.bin") }, + { key: sqliteManifest.key, size: sqliteManifest.archive.size, file: resolve(packageRoot, "artifacts/cloudflare-sqlite-database-integration.zip") }, + { key: websiteImporterManifest.key, size: websiteImporterManifest.archive.size, file: resolve(packageRoot, "artifacts/cloudflare-website-importer.zip") }, ]) { - const command = ["exec", "--", "wrangler", "r2", "object", "put", `wp-codebox-runtime-chubes/${artifact.key}`, "--file", artifact.file, local ? "--local" : "--remote"] + const command = ["r2", "object", "put", `wp-codebox-runtime-chubes/${artifact.key}`, "--file", artifact.file, local ? "--local" : "--remote"] if (persistTo) command.push("--persist-to", persistTo) await new Promise((resolve, reject) => { - const child = spawn("npm", command, { cwd: process.cwd(), stdio: "inherit" }) + const child = spawn("wrangler", command, { cwd: packageRoot, env: childEnvironment(), stdio: "inherit" }) child.on("error", reject) child.on("exit", (code) => code === 0 ? resolve(undefined) : reject(new Error(`Wrangler R2 provisioning failed with status ${code}.`))) }) console.log(`Provisioned ${artifact.key} (${artifact.size} bytes).`) } + +function childEnvironment() { return Object.fromEntries(Object.entries(process.env).filter(([name, value]) => name !== "NODE_OPTIONS" || !value?.includes("register-package-local-loader"))) } diff --git a/scripts/cloudflare-remote-principal-credential-gate.mjs b/packages/runtime-cloudflare/scripts/remote-principal-credential-gate.mjs similarity index 88% rename from scripts/cloudflare-remote-principal-credential-gate.mjs rename to packages/runtime-cloudflare/scripts/remote-principal-credential-gate.mjs index 495e19460..13063a720 100644 --- a/scripts/cloudflare-remote-principal-credential-gate.mjs +++ b/packages/runtime-cloudflare/scripts/remote-principal-credential-gate.mjs @@ -3,6 +3,7 @@ import { createHash, randomBytes, randomUUID } from "node:crypto" import { chmod, mkdtemp, rm, writeFile } from "node:fs/promises" import { tmpdir } from "node:os" import { join, resolve } from "node:path" +import { fileURLToPath } from "node:url" const CONFIRMATION = "--confirm-remote-d1-gate" const ACCOUNT_ID = /^[a-f0-9]{32}$/ @@ -11,6 +12,7 @@ const EXPIRY = "2099-01-01T00:00:00.000Z" const OUTPUT_LIMIT = 16_384 const CHILD_TIMEOUT_MS = 30_000 const FETCH_TIMEOUT_MS = 30_000 +const packageRoot = resolve(import.meta.dirname, "..") class AmbiguousCreateError extends Error {} @@ -30,7 +32,7 @@ export async function runRemotePrincipalCredentialGate(input = {}) { const resourceEndpoint = `https://api.cloudflare.com/client/v4/accounts/${accountId}/d1/database` const directory = await mkdtemp(join(tmpdir(), "wp-codebox-remote-d1-gate-")) const config = join(directory, "wrangler.json") - const operator = resolve(input.operator ?? "scripts/operator-cloudflare-principal-credential.ts") + const operator = resolve(input.operator ?? fileURLToPath(new URL("./operator-principal-credential.ts", import.meta.url))) let databaseId let primaryError let cleanupError @@ -135,6 +137,7 @@ async function batch(request, endpoint, token, queries, expectSuccess = true) { function results(value) { return value.result.map((entry) => Array.isArray(entry.results) ? entry.results : []) } function parseJson(value) { try { return JSON.parse(value) } catch { throw new Error("Remote D1 credential gate received invalid JSON.") } } function structuredErrorCode(value) { try { const parsed = JSON.parse(value); return parsed?.schema === "wp-codebox/principal-credential-operator-error/v1" && typeof parsed.code === "string" ? parsed.code : undefined } catch { return undefined } } -export function runChild(command, args, stdin, timeoutMs = CHILD_TIMEOUT_MS) { return new Promise((resolveRun) => { const child = spawn(command, args, { cwd: process.cwd(), stdio: ["pipe", "pipe", "pipe"] }); let stdout = Buffer.alloc(0); let stderr = Buffer.alloc(0); let outputTruncated = false; let settled = false; let killTimer; const finish = (status) => { if (settled) return; settled = true; clearTimeout(timeout); clearTimeout(killTimer); resolveRun({ status, stdout: stdout.toString("utf8"), stderr: stderr.toString("utf8"), outputTruncated }) }; const terminate = () => { child.kill("SIGTERM"); killTimer = setTimeout(() => child.kill("SIGKILL"), 1_000) }; const append = (target, chunk) => { const value = Buffer.from(chunk); const current = target === "stdout" ? stdout : stderr; if (current.byteLength + value.byteLength > OUTPUT_LIMIT) { const remaining = Math.max(0, OUTPUT_LIMIT - current.byteLength); if (target === "stdout") stdout = Buffer.concat([stdout, value.subarray(0, remaining)]); else stderr = Buffer.concat([stderr, value.subarray(0, remaining)]); outputTruncated = true; terminate(); return } if (target === "stdout") stdout = Buffer.concat([stdout, value]); else stderr = Buffer.concat([stderr, value]) }; const timeout = setTimeout(() => { outputTruncated = true; terminate() }, timeoutMs); child.stdout.on("data", (chunk) => append("stdout", chunk)); child.stderr.on("data", (chunk) => append("stderr", chunk)); child.on("error", () => finish(1)); child.on("exit", (status) => finish(status)); child.stdin.end(stdin) }) } +export function runChild(command, args, stdin, timeoutMs = CHILD_TIMEOUT_MS) { return new Promise((resolveRun) => { const child = spawn(command, args, { cwd: packageRoot, env: childEnvironment(), stdio: ["pipe", "pipe", "pipe"] }); let stdout = Buffer.alloc(0); let stderr = Buffer.alloc(0); let outputTruncated = false; let settled = false; let killTimer; const finish = (status) => { if (settled) return; settled = true; clearTimeout(timeout); clearTimeout(killTimer); resolveRun({ status, stdout: stdout.toString("utf8"), stderr: stderr.toString("utf8"), outputTruncated }) }; const terminate = () => { child.kill("SIGTERM"); killTimer = setTimeout(() => child.kill("SIGKILL"), 1_000) }; const append = (target, chunk) => { const value = Buffer.from(chunk); const current = target === "stdout" ? stdout : stderr; if (current.byteLength + value.byteLength > OUTPUT_LIMIT) { const remaining = Math.max(0, OUTPUT_LIMIT - current.byteLength); if (target === "stdout") stdout = Buffer.concat([stdout, value.subarray(0, remaining)]); else stderr = Buffer.concat([stderr, value.subarray(0, remaining)]); outputTruncated = true; terminate(); return } if (target === "stdout") stdout = Buffer.concat([stdout, value]); else stderr = Buffer.concat([stderr, value]) }; const timeout = setTimeout(() => { outputTruncated = true; terminate() }, timeoutMs); child.stdout.on("data", (chunk) => append("stdout", chunk)); child.stderr.on("data", (chunk) => append("stderr", chunk)); child.on("error", () => finish(1)); child.on("exit", (status) => finish(status)); child.stdin.end(stdin) }) } +function childEnvironment() { return Object.fromEntries(Object.entries(process.env).filter(([name, value]) => name !== "NODE_OPTIONS" || !value?.includes("register-package-local-loader"))) } if (import.meta.url === `file://${process.argv[1]}`) { const args = process.argv.slice(2); const accountIndex = args.indexOf("--account-id"); runRemotePrincipalCredentialGate({ confirmation: args.includes(CONFIRMATION), accountId: accountIndex === -1 ? undefined : args[accountIndex + 1] }).then((result) => process.stdout.write(`${JSON.stringify(result)}\n`)).catch((error) => { process.stderr.write(`${error.message}\n`); process.exitCode = 1 }) } diff --git a/packages/runtime-cloudflare/scripts/visual-parity.mjs b/packages/runtime-cloudflare/scripts/visual-parity.mjs new file mode 100644 index 000000000..97addee43 --- /dev/null +++ b/packages/runtime-cloudflare/scripts/visual-parity.mjs @@ -0,0 +1,45 @@ +import { mkdir, writeFile } from "node:fs/promises" +import { join } from "node:path" +import pixelmatch from "pixelmatch" +import { PNG } from "pngjs" +import { chromium } from "playwright" + +export async function assertVisualParity({ sourceUrl, candidateUrl, artifactRoot }) { + const browser = await chromium.launch({ headless: true }) + try { + await mkdir(artifactRoot, { recursive: true }) + const source = await screenshot(browser, sourceUrl) + const candidate = await screenshot(browser, candidateUrl) + await writeFile(join(artifactRoot, "source.png"), source) + await writeFile(join(artifactRoot, "candidate.png"), candidate) + const sourcePng = PNG.sync.read(source) + const candidatePng = PNG.sync.read(candidate) + if (sourcePng.width !== candidatePng.width || sourcePng.height !== candidatePng.height) throw new Error(`Static artifact visual parity dimensions differ: source=${sourcePng.width}x${sourcePng.height} candidate=${candidatePng.width}x${candidatePng.height}.`) + const difference = new PNG({ width: sourcePng.width, height: sourcePng.height }) + const mismatched = pixelmatch(sourcePng.data, candidatePng.data, difference.data, sourcePng.width, sourcePng.height, { threshold: 0, includeAA: true }) + if (mismatched !== 0) { + await writeFile(join(artifactRoot, "difference.png"), PNG.sync.write(difference)) + throw new Error(`Static artifact visual parity found ${mismatched} mismatched pixels; evidence: ${artifactRoot}.`) + } + } finally { + await browser.close() + } +} + +async function screenshot(browser, url) { + const context = await browser.newContext({ viewport: { width: 1280, height: 720 }, reducedMotion: "reduce" }) + try { + const page = await context.newPage() + await page.route("**/*", async (route) => { + const requestUrl = new URL(route.request().url()) + const pageUrl = new URL(url) + if (requestUrl.origin === pageUrl.origin) await route.continue() + else await route.abort("blockedbyclient") + }) + await page.goto(url, { waitUntil: "networkidle", timeout: 120_000 }) + await page.emulateMedia({ reducedMotion: "reduce" }) + return page.screenshot({ fullPage: true, animations: "disabled" }) + } finally { + await context.close() + } +} diff --git a/packages/runtime-cloudflare/src/health-envelope.ts b/packages/runtime-cloudflare/src/health-envelope.ts index e2af7b66d..43c300155 100644 --- a/packages/runtime-cloudflare/src/health-envelope.ts +++ b/packages/runtime-cloudflare/src/health-envelope.ts @@ -1,5 +1,3 @@ -import { createRuntimeCommandResultEnvelope } from "@automattic/wp-codebox-core/runtime-command-result" - export const CLOUDFLARE_RUNTIME_HEALTH_SCHEMA = "wp-codebox/cloudflare-runtime-health/v1" as const export const CLOUDFLARE_RUNTIME_HEALTH_MARKER = "wp-codebox-cloudflare-runtime-health" as const @@ -21,3 +19,4 @@ export function cloudflareRuntimeHealthResponse(health: CloudflareRuntimeHealth) return Response.json({ ...health, execution }) } +import { createRuntimeCommandResultEnvelope } from "@automattic/wp-codebox-core/runtime-command-result" diff --git a/packages/runtime-cloudflare/src/public-reader.ts b/packages/runtime-cloudflare/src/public-reader.ts index c493e4a5d..6c5badf5f 100644 --- a/packages/runtime-cloudflare/src/public-reader.ts +++ b/packages/runtime-cloudflare/src/public-reader.ts @@ -3,7 +3,7 @@ import { parseSiteContexts, previewDomain, resolvePreviewSiteContextFromRequest, import { isCanonicalWpContentPath, validateWpContentManifestFiles } from "./wp-content-persistence.js" import { validateUploadManifestFiles } from "./upload-persistence.js" import { servePublicWordPressStaticAsset } from "./wordpress-static-reader.js" -import { runtimeArchiveComponentOwnedWpContentPaths } from "../../runtime-core/src/runtime-archive-component.js" +import { runtimeArchiveComponentOwnedWpContentPaths } from "@automattic/wp-codebox-core/runtime-archive-component" import { validateRuntimeArchiveArtifactManifest, type RuntimeArchiveArtifactManifest } from "./runtime-archive-artifact.js" import websiteImporterArtifactManifest from "../assets/website-importer-artifact.json" with { type: "json" } diff --git a/packages/runtime-cloudflare/src/runtime-archive-artifact.ts b/packages/runtime-cloudflare/src/runtime-archive-artifact.ts index b76b1dfe5..e871cb5ca 100644 --- a/packages/runtime-cloudflare/src/runtime-archive-artifact.ts +++ b/packages/runtime-cloudflare/src/runtime-archive-artifact.ts @@ -41,4 +41,4 @@ async function sha256Hex(bytes: Uint8Array): Promise { const digest = await crypto.subtle.digest("SHA-256", Uint8Array.from(bytes).buffer) return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("") } -import { runtimeArchiveComponent, type RuntimeArchiveComponent } from "../../runtime-core/src/runtime-archive-component.js" +import { runtimeArchiveComponent, type RuntimeArchiveComponent } from "@automattic/wp-codebox-core/runtime-archive-component" diff --git a/packages/runtime-cloudflare/src/worker.ts b/packages/runtime-cloudflare/src/worker.ts index 110a92831..598f1dd3a 100644 --- a/packages/runtime-cloudflare/src/worker.ts +++ b/packages/runtime-cloudflare/src/worker.ts @@ -3,8 +3,8 @@ import { decodeZip } from "@php-wasm/stream-compression" import { bootWordPressAndRequestHandler, type WordPressInstallMode } from "@wp-playground/wordpress" // The PHP-WASM package publishes this Emscripten loader without TypeScript declarations. // @ts-expect-error The adjacent Wasm declaration covers the compiled binary import. -import { dependenciesTotalSize, init } from "../../../node_modules/@php-wasm/web-8-5/asyncify/php_8_5.js" -import phpWasmModule from "../../../node_modules/@php-wasm/web-8-5/asyncify/8_5_8/php_8_5.wasm" +import { dependenciesTotalSize, init } from "../node_modules/@php-wasm/web-8-5/asyncify/php_8_5.js" +import phpWasmModule from "../node_modules/@php-wasm/web-8-5/asyncify/8_5_8/php_8_5.wasm" import { CLOUDFLARE_RUNTIME_HEALTH_MARKER, CLOUDFLARE_RUNTIME_HEALTH_SCHEMA, cloudflareRuntimeHealthResponse } from "./health-envelope.js" import { leaseRetryDelayMs } from "./lease-retry.js" import { logMutationPhase, MutationRetainedBytes } from "./mutation-memory.js" @@ -27,7 +27,7 @@ import { isWordPressRuntimeFile, wordpressStaticArchivePath, wordpressStaticCont import { materializeWordPressRuntimeArtifact, type WordPressRuntimeArtifactManifest } from "./wordpress-runtime-artifact.js" import { validateWordPressStaticArtifactManifest, type WordPressStaticArtifactManifest } from "./wordpress-static-artifact.js" import { readRuntimeArchiveArtifact, validateRuntimeArchiveArtifactManifest, type RuntimeArchiveArtifactManifest } from "./runtime-archive-artifact.js" -import { runtimeArchiveComponentOwnedWpContentPaths, type RuntimeArchiveComponent } from "../../runtime-core/src/runtime-archive-component.js" +import { runtimeArchiveComponentOwnedWpContentPaths, type RuntimeArchiveComponent } from "@automattic/wp-codebox-core/runtime-archive-component" import { isCanonicalWpContentPath, MAX_WP_CONTENT_FILES, MAX_WP_CONTENT_FILE_BYTES, MAX_WP_CONTENT_TOTAL_BYTES, runtimeOwnedWpContentPaths, validateWpContentDeletedPaths, validateWpContentManifestFiles, validateWpContentMetadata } from "./wp-content-persistence.js" import markdownDatabaseIntegrationRuntime from "../assets/markdown-database-integration-runtime.zip" import canonicalMarkdownSeed from "../assets/markdown-database-integration-canonical-seed.zip" diff --git a/tests/cloudflare-allocation-lifecycle.test.ts b/packages/runtime-cloudflare/tests/cloudflare-allocation-lifecycle.test.ts similarity index 99% rename from tests/cloudflare-allocation-lifecycle.test.ts rename to packages/runtime-cloudflare/tests/cloudflare-allocation-lifecycle.test.ts index 2750fcfa2..f0f451702 100644 --- a/tests/cloudflare-allocation-lifecycle.test.ts +++ b/packages/runtime-cloudflare/tests/cloudflare-allocation-lifecycle.test.ts @@ -1,7 +1,7 @@ import assert from "node:assert/strict" import { DatabaseSync } from "node:sqlite" import test from "node:test" -import { AllocationLifecycleConflict, CloudflareAllocationLifecycle } from "../packages/runtime-cloudflare/src/allocation-lifecycle.js" +import { AllocationLifecycleConflict, CloudflareAllocationLifecycle } from "../src/allocation-lifecycle.js" function database(): D1Database { const sqlite = new DatabaseSync(":memory:") diff --git a/tests/cloudflare-coordinator-site-partitioning.test.ts b/packages/runtime-cloudflare/tests/cloudflare-coordinator-site-partitioning.test.ts similarity index 96% rename from tests/cloudflare-coordinator-site-partitioning.test.ts rename to packages/runtime-cloudflare/tests/cloudflare-coordinator-site-partitioning.test.ts index 0f8ab5f60..2f00e3506 100644 --- a/tests/cloudflare-coordinator-site-partitioning.test.ts +++ b/packages/runtime-cloudflare/tests/cloudflare-coordinator-site-partitioning.test.ts @@ -1,8 +1,8 @@ import assert from "node:assert/strict" import { DatabaseSync } from "node:sqlite" import test from "node:test" -import { D1RevisionCoordinator } from "../packages/runtime-cloudflare/src/d1-revision-coordinator.js" -import { WordPressStateCoordinator } from "../packages/runtime-cloudflare/src/state-coordinator.js" +import { D1RevisionCoordinator } from "../src/d1-revision-coordinator.js" +import { WordPressStateCoordinator } from "../src/state-coordinator.js" function d1Database(): D1Database { const database = new DatabaseSync(":memory:") diff --git a/tests/cloudflare-d1-operation-repository.test.ts b/packages/runtime-cloudflare/tests/cloudflare-d1-operation-repository.test.ts similarity index 97% rename from tests/cloudflare-d1-operation-repository.test.ts rename to packages/runtime-cloudflare/tests/cloudflare-d1-operation-repository.test.ts index da7f41704..a14de45ec 100644 --- a/tests/cloudflare-d1-operation-repository.test.ts +++ b/packages/runtime-cloudflare/tests/cloudflare-d1-operation-repository.test.ts @@ -1,9 +1,9 @@ import assert from "node:assert/strict" import { DatabaseSync } from "node:sqlite" import test from "node:test" -import { D1OperationRepository, OperationConflict, shouldRecoverPreparedCommit } from "../packages/runtime-cloudflare/src/d1-operation-repository.js" -import { CloudflareAllocationLifecycle } from "../packages/runtime-cloudflare/src/allocation-lifecycle.js" -import { DEFAULT_RUNTIME_QUEUE_POLICY, parseRuntimeQueueMessage, RUNTIME_QUEUE_MESSAGE_SCHEMA, runtimeQueueMessage } from "../packages/runtime-cloudflare/src/queue-dispatch.js" +import { D1OperationRepository, OperationConflict, shouldRecoverPreparedCommit } from "../src/d1-operation-repository.js" +import { CloudflareAllocationLifecycle } from "../src/allocation-lifecycle.js" +import { DEFAULT_RUNTIME_QUEUE_POLICY, parseRuntimeQueueMessage, RUNTIME_QUEUE_MESSAGE_SCHEMA, runtimeQueueMessage } from "../src/queue-dispatch.js" function database(): D1Database { const sqlite = new DatabaseSync(":memory:") diff --git a/tests/cloudflare-d1-provisioner.test.mjs b/packages/runtime-cloudflare/tests/cloudflare-d1-provisioner.test.mjs similarity index 97% rename from tests/cloudflare-d1-provisioner.test.mjs rename to packages/runtime-cloudflare/tests/cloudflare-d1-provisioner.test.mjs index 74bce771d..8142a7dee 100644 --- a/tests/cloudflare-d1-provisioner.test.mjs +++ b/packages/runtime-cloudflare/tests/cloudflare-d1-provisioner.test.mjs @@ -5,7 +5,7 @@ import { join, resolve } from "node:path" import { spawn } from "node:child_process" import test from "node:test" -const script = resolve("scripts/provision-cloudflare-d1-coordinator.mjs") +const script = resolve("scripts/provision-d1-coordinator.mjs") test("D1 provisioner creates once and emits a deployable config deterministically", async () => { const directory = await mkdtemp(join(tmpdir(), "wp-codebox-d1-provision-")) diff --git a/tests/cloudflare-phase-trace.test.ts b/packages/runtime-cloudflare/tests/cloudflare-phase-trace.test.ts similarity index 97% rename from tests/cloudflare-phase-trace.test.ts rename to packages/runtime-cloudflare/tests/cloudflare-phase-trace.test.ts index 6ee34c57e..b9677f26d 100644 --- a/tests/cloudflare-phase-trace.test.ts +++ b/packages/runtime-cloudflare/tests/cloudflare-phase-trace.test.ts @@ -1,6 +1,6 @@ import assert from "node:assert/strict" import test from "node:test" -import { attachServerTiming, CloudflarePhaseTrace, CLOUDFLARE_PHASE_TRACE_SCHEMA, serverTiming } from "../packages/runtime-cloudflare/src/phase-trace.js" +import { attachServerTiming, CloudflarePhaseTrace, CLOUDFLARE_PHASE_TRACE_SCHEMA, serverTiming } from "../src/phase-trace.js" test("Cloudflare phase traces use bounded, non-overlapping leaves and independent dimensions", async () => { let clock = 0 diff --git a/tests/cloudflare-principal-credential-operator.test.mjs b/packages/runtime-cloudflare/tests/cloudflare-principal-credential-operator.test.mjs similarity index 97% rename from tests/cloudflare-principal-credential-operator.test.mjs rename to packages/runtime-cloudflare/tests/cloudflare-principal-credential-operator.test.mjs index 1d1380b8d..c369a7b65 100644 --- a/tests/cloudflare-principal-credential-operator.test.mjs +++ b/packages/runtime-cloudflare/tests/cloudflare-principal-credential-operator.test.mjs @@ -6,8 +6,8 @@ import { join, resolve } from "node:path" import { spawn } from "node:child_process" import test from "node:test" -const script = resolve("scripts/operator-cloudflare-principal-credential.ts") -const base = ["--config", "packages/runtime-cloudflare/wrangler.d1.jsonc", "--credential-id", "deployer", "--version", "v1"] +const script = resolve("scripts/operator-principal-credential.ts") +const base = ["--config", "wrangler.d1.jsonc", "--credential-id", "deployer", "--version", "v1"] const policy = ["--principal", "ci:deploy", "--scopes", "sites:create,sites:read", "--expires-at", "2027-01-01T00:00:00.000Z", "--max-sites", "3"] test("credential operator passes only a digest to D1 and emits redacted evidence", async () => { diff --git a/tests/cloudflare-principal-credential-repository.test.ts b/packages/runtime-cloudflare/tests/cloudflare-principal-credential-repository.test.ts similarity index 98% rename from tests/cloudflare-principal-credential-repository.test.ts rename to packages/runtime-cloudflare/tests/cloudflare-principal-credential-repository.test.ts index 8fe2c2e94..29dac058b 100644 --- a/tests/cloudflare-principal-credential-repository.test.ts +++ b/packages/runtime-cloudflare/tests/cloudflare-principal-credential-repository.test.ts @@ -2,7 +2,7 @@ import assert from "node:assert/strict" import { createHash } from "node:crypto" import { DatabaseSync } from "node:sqlite" import test from "node:test" -import { D1PrincipalCredentialRepository } from "../packages/runtime-cloudflare/src/principal-credential-repository.js" +import { D1PrincipalCredentialRepository } from "../src/principal-credential-repository.js" const digest = (value: string) => createHash("sha256").update(value).digest("hex") function database(): D1Database & { sqlite: DatabaseSync } { diff --git a/tests/cloudflare-provisioning-api.test.ts b/packages/runtime-cloudflare/tests/cloudflare-provisioning-api.test.ts similarity index 97% rename from tests/cloudflare-provisioning-api.test.ts rename to packages/runtime-cloudflare/tests/cloudflare-provisioning-api.test.ts index deea9512b..6dab7f68d 100644 --- a/tests/cloudflare-provisioning-api.test.ts +++ b/packages/runtime-cloudflare/tests/cloudflare-provisioning-api.test.ts @@ -2,11 +2,11 @@ import assert from "node:assert/strict" import { createHash } from "node:crypto" import { DatabaseSync } from "node:sqlite" import test from "node:test" -import { D1OperationRepository } from "../packages/runtime-cloudflare/src/d1-operation-repository.js" -import { allocationIdentity, CloudflareAllocationLifecycle } from "../packages/runtime-cloudflare/src/allocation-lifecycle.js" -import { administratorPasswordForSite, PROVISIONING_ARTIFACT_RESOURCE_SCHEMA, PROVISIONING_CREATE_REQUEST_SCHEMA, resumeProvisioningAllocation, routeProvisioningApi } from "../packages/runtime-cloudflare/src/provisioning-api.js" -import { STATIC_ARTIFACT_IMPORT_REQUEST_SCHEMA } from "../packages/runtime-cloudflare/src/static-artifact-import.js" -import { D1PrincipalCredentialRepository } from "../packages/runtime-cloudflare/src/principal-credential-repository.js" +import { D1OperationRepository } from "../src/d1-operation-repository.js" +import { allocationIdentity, CloudflareAllocationLifecycle } from "../src/allocation-lifecycle.js" +import { administratorPasswordForSite, PROVISIONING_ARTIFACT_RESOURCE_SCHEMA, PROVISIONING_CREATE_REQUEST_SCHEMA, resumeProvisioningAllocation, routeProvisioningApi } from "../src/provisioning-api.js" +import { STATIC_ARTIFACT_IMPORT_REQUEST_SCHEMA } from "../src/static-artifact-import.js" +import { D1PrincipalCredentialRepository } from "../src/principal-credential-repository.js" const hash = (value: string | Uint8Array) => createHash("sha256").update(value).digest("hex") const artifactText = JSON.stringify({ schema: "blocks-engine/php-transformer/site-artifact/v1", root: "website", entrypoint: "website/index.html", files: [{ path: "website/index.html", content: "ok" }] }) @@ -167,7 +167,7 @@ test("active root changes preserve pinned claims and canonical bootstrap resolut r.env.WORDPRESS_ADMIN_SECRET_BINDINGS = bindings("v2") const replay = await (await create(r)).json() as { site: { administratorClaim: { token: string } } } assert.equal(replay.site.administratorClaim.token, first.site.administratorClaim.token) - assert.equal(await administratorPasswordForSite(r.env, first.site.id), await (await import("../packages/runtime-cloudflare/src/wordpress-auth.js")).deriveSiteCredential("admin-root-secret", first.site.id, "admin-password")) + assert.equal(await administratorPasswordForSite(r.env, first.site.id), await (await import("../src/wordpress-auth.js")).deriveSiteCredential("admin-root-secret", first.site.id, "admin-password")) r.db.sqlite.prepare("UPDATE wp_codebox_operations SET state = 'succeeded' WHERE site_id = ?").run(first.site.id) const redeemed = await routeProvisioningApi(new Request(`https://control.invalid/v1/sites/${first.site.id}/administrator-claim`, { method: "POST", headers: { authorization: `Bearer ${first.site.administratorClaim.token}` } }), r.env, r.operations) assert.equal(redeemed.status, 200) @@ -210,7 +210,7 @@ test("administrator claim failures are generic, not-ready preserves pending, and r.db.sqlite.prepare("UPDATE wp_codebox_api_admin_claims SET expires_at = 0").run(); assert.equal((await routeProvisioningApi(new Request(url, { method: "POST", headers: { authorization: `Bearer ${created.site.administratorClaim.token}` } }), r.env, r.operations)).status, 401); assert.equal((r.db.sqlite.prepare("SELECT state FROM wp_codebox_api_admin_claims").get() as { state: string }).state, "expired"); const resource = await (await routeProvisioningApi(new Request(`https://control.invalid/v1/sites/${created.site.id}`, { headers: { authorization: "Bearer good" } }), r.env, r.operations)).json() as { site: { administratorClaim: { state: string } } }; assert.equal(resource.site.administratorClaim.state, "expired"); const replay = await create(r); assert.equal(replay.status, 409); assert.doesNotMatch(await replay.text(), /"token"/); await assert.rejects(() => resumeProvisioningAllocation(r.env, { id: created.site.id, hostname: `${created.site.id}.example`, origin: `https://${created.site.id}.example` }, r.operations)) }) test("administrator claim consumes once after publication and returns the persistent site credential", async () => { - const r = runtime(); const created = await (await create(r)).json() as { site: { id: string; operation: string; administratorClaim: { token: string } } }; r.db.sqlite.prepare("UPDATE wp_codebox_operations SET state = 'succeeded' WHERE site_id = ?").run(created.site.id); const url = `https://control.invalid/v1/sites/${created.site.id}/administrator-claim`; const responses = await Promise.all([1, 2].map(() => routeProvisioningApi(new Request(url, { method: "POST", headers: { authorization: `Bearer ${created.site.administratorClaim.token}` } }), r.env, r.operations))); assert.equal(responses.filter((response) => response.status === 200).length, 1); const success = responses.find((response) => response.status === 200)!; assert.deepEqual(await success.json(), { schema: "wp-codebox/provisioning-api/v1", credential: { username: "admin", password: await (await import("../packages/runtime-cloudflare/src/wordpress-auth.js")).deriveSiteCredential(r.env.WORDPRESS_ADMIN_PASSWORD, created.site.id, "admin-password") } }); assert.equal(responses.find((response) => response.status !== 200)!.status, 401) + const r = runtime(); const created = await (await create(r)).json() as { site: { id: string; operation: string; administratorClaim: { token: string } } }; r.db.sqlite.prepare("UPDATE wp_codebox_operations SET state = 'succeeded' WHERE site_id = ?").run(created.site.id); const url = `https://control.invalid/v1/sites/${created.site.id}/administrator-claim`; const responses = await Promise.all([1, 2].map(() => routeProvisioningApi(new Request(url, { method: "POST", headers: { authorization: `Bearer ${created.site.administratorClaim.token}` } }), r.env, r.operations))); assert.equal(responses.filter((response) => response.status === 200).length, 1); const success = responses.find((response) => response.status === 200)!; assert.deepEqual(await success.json(), { schema: "wp-codebox/provisioning-api/v1", credential: { username: "admin", password: await (await import("../src/wordpress-auth.js")).deriveSiteCredential(r.env.WORDPRESS_ADMIN_PASSWORD, created.site.id, "admin-password") } }); assert.equal(responses.find((response) => response.status !== 200)!.status, 401) const replay = await (await create(r)).text(); assert.doesNotMatch(replay, new RegExp(created.site.administratorClaim.token)); const read = await (await routeProvisioningApi(new Request(`https://control.invalid/v1/sites/${created.site.id}`, { headers: { authorization: "Bearer good" } }), r.env, r.operations)).text(); assert.doesNotMatch(read, new RegExp(created.site.administratorClaim.token)) }) test("completed create replay remains idempotent after its root version is retired", async () => { diff --git a/tests/cloudflare-public-reader.test.ts b/packages/runtime-cloudflare/tests/cloudflare-public-reader.test.ts similarity index 95% rename from tests/cloudflare-public-reader.test.ts rename to packages/runtime-cloudflare/tests/cloudflare-public-reader.test.ts index 9ee6dbab8..77387122c 100644 --- a/tests/cloudflare-public-reader.test.ts +++ b/packages/runtime-cloudflare/tests/cloudflare-public-reader.test.ts @@ -1,9 +1,9 @@ import assert from "node:assert/strict" import test from "node:test" import { createHash } from "node:crypto" -import { PUBLISHED_PAGE_SCHEMA, PUBLISHED_REVISION_SCHEMA, publishedPageObjectKey } from "../packages/runtime-cloudflare/src/published-reader.js" -import { servePublicPublication } from "../packages/runtime-cloudflare/src/public-reader.js" -import { DEFAULT_SITE_CONTEXT, siteStorageKeys } from "../packages/runtime-cloudflare/src/site-context.js" +import { PUBLISHED_PAGE_SCHEMA, PUBLISHED_REVISION_SCHEMA, publishedPageObjectKey } from "../src/published-reader.js" +import { servePublicPublication } from "../src/public-reader.js" +import { DEFAULT_SITE_CONTEXT, siteStorageKeys } from "../src/site-context.js" const canonicalRevision = "11111111-1111-4111-8111-111111111111" const publicationRevision = "22222222-2222-4222-8222-222222222222" diff --git a/tests/cloudflare-queue-batch.test.ts b/packages/runtime-cloudflare/tests/cloudflare-queue-batch.test.ts similarity index 94% rename from tests/cloudflare-queue-batch.test.ts rename to packages/runtime-cloudflare/tests/cloudflare-queue-batch.test.ts index 2c2dd7c05..722290420 100644 --- a/tests/cloudflare-queue-batch.test.ts +++ b/packages/runtime-cloudflare/tests/cloudflare-queue-batch.test.ts @@ -1,7 +1,7 @@ import assert from "node:assert/strict" import test from "node:test" -import { dispatchQueueBatch, type QueueDelivery } from "../packages/runtime-cloudflare/src/queue-batch.js" -import { DEFAULT_RUNTIME_QUEUE_POLICY, parseRuntimeQueuePolicy, runtimeQueueMessage } from "../packages/runtime-cloudflare/src/queue-dispatch.js" +import { dispatchQueueBatch, type QueueDelivery } from "../src/queue-batch.js" +import { DEFAULT_RUNTIME_QUEUE_POLICY, parseRuntimeQueuePolicy, runtimeQueueMessage } from "../src/queue-dispatch.js" function delivery(siteId: string, kind: "operation" | "publication", identity: string): QueueDelivery & { result?: string; delaySeconds?: number } { return { body: runtimeQueueMessage({ id: siteId }, 1, kind, identity), attempts: 1, ack() { this.result = "ack" }, retry(options) { this.result = "retry"; this.delaySeconds = options?.delaySeconds } } diff --git a/tests/cloudflare-remote-principal-credential-gate.test.mjs b/packages/runtime-cloudflare/tests/cloudflare-remote-principal-credential-gate.test.mjs similarity index 99% rename from tests/cloudflare-remote-principal-credential-gate.test.mjs rename to packages/runtime-cloudflare/tests/cloudflare-remote-principal-credential-gate.test.mjs index 6653c195d..0162e772e 100644 --- a/tests/cloudflare-remote-principal-credential-gate.test.mjs +++ b/packages/runtime-cloudflare/tests/cloudflare-remote-principal-credential-gate.test.mjs @@ -1,7 +1,7 @@ import assert from "node:assert/strict" import { createHash } from "node:crypto" import test from "node:test" -import { runChild, runRemotePrincipalCredentialGate } from "../scripts/cloudflare-remote-principal-credential-gate.mjs" +import { runChild, runRemotePrincipalCredentialGate } from "../scripts/remote-principal-credential-gate.mjs" const accountId = "a".repeat(32) const token = "remote-gate-test-token" diff --git a/tests/cloudflare-runtime.test.ts b/packages/runtime-cloudflare/tests/cloudflare-runtime.test.ts similarity index 91% rename from tests/cloudflare-runtime.test.ts rename to packages/runtime-cloudflare/tests/cloudflare-runtime.test.ts index add9e9503..aacf26c39 100644 --- a/tests/cloudflare-runtime.test.ts +++ b/packages/runtime-cloudflare/tests/cloudflare-runtime.test.ts @@ -5,25 +5,26 @@ import { execFile } from "node:child_process" import { promisify } from "node:util" import test from "node:test" import { decodeZip, encodeZip } from "@php-wasm/stream-compression" -import { RUNTIME_COMMAND_RESULT_SCHEMA } from "../packages/runtime-core/src/runtime-contracts.js" -import { runtimeArchiveComponentOwnedWpContentPaths, runtimeArchiveComponentSource } from "../packages/runtime-core/src/runtime-archive-component.js" -import { parseRuntimePackageManifest, selectRuntimePackageProfileFiles } from "../packages/runtime-core/src/runtime-package-profile.js" -import { CLOUDFLARE_RUNTIME_HEALTH_MARKER, CLOUDFLARE_RUNTIME_HEALTH_SCHEMA, cloudflareRuntimeHealthResponse } from "../packages/runtime-cloudflare/src/health-envelope.js" -import { leaseRetryDelayMs } from "../packages/runtime-cloudflare/src/lease-retry.js" -import { CANONICAL_RESTORE_PACK_SCHEMA, createCanonicalRestorePack, decodeCanonicalRestorePack, readCanonicalRestorePack, type CanonicalRestorePackFile, type CanonicalRestorePackMetadata } from "../packages/runtime-cloudflare/src/canonical-restore-pack.js" -import { MUTATION_DIAGNOSTIC_SCHEMA, mutationRetentionContract } from "../packages/runtime-cloudflare/src/mutation-memory.js" -import { selectOperatorCoordinator } from "../packages/runtime-cloudflare/src/operator-coordinator.js" -import { canonicalPublicRoute, normalizePublishedRoutes, PUBLISHED_REVISION_SCHEMA, publishedPageObjectKey, publishedRevisionObjectKey, R2_PUBLISHED_CURRENT_KEY, validatePublishedRevision } from "../packages/runtime-cloudflare/src/published-reader.js" -import { routeWorkerRequest } from "../packages/runtime-cloudflare/src/request-routing.js" -import { toFetchResponse, toPHPRequest } from "../packages/runtime-cloudflare/src/request-translation.js" -import { readStaticArtifactImport, STATIC_ARTIFACT_IMPORT_REQUEST_SCHEMA } from "../packages/runtime-cloudflare/src/static-artifact-import.js" -import { WordPressStateCoordinator } from "../packages/runtime-cloudflare/src/state-coordinator.js" -import { MAX_UPLOAD_FILE_BYTES, R2_UPLOAD_OBJECT_PREFIX, validateUploadManifestFiles, validateUploadMetadata } from "../packages/runtime-cloudflare/src/upload-persistence.js" -import { isWordPressRuntimeFile, wordpressStaticArchivePath, wordpressStaticContentType } from "../packages/runtime-cloudflare/src/wordpress-runtime-corpus.js" -import { materializeWordPressRuntimeArtifact, WORDPRESS_RUNTIME_ARTIFACT_SCHEMA, wordpressRuntimeArtifactKey, type WordPressRuntimeArtifactManifest } from "../packages/runtime-cloudflare/src/wordpress-runtime-artifact.js" -import { validateWordPressStaticArtifactManifest, WORDPRESS_STATIC_ARTIFACT_SCHEMA, wordpressStaticArtifactKey, type WordPressStaticArtifactManifest } from "../packages/runtime-cloudflare/src/wordpress-static-artifact.js" -import { readRuntimeArchiveArtifact, RUNTIME_ARCHIVE_ARTIFACT_SCHEMA, RUNTIME_ARCHIVE_MAX_BYTES, runtimeArchiveArtifactKey, validateRuntimeArchiveArtifactManifest, type RuntimeArchiveArtifactManifest } from "../packages/runtime-cloudflare/src/runtime-archive-artifact.js" -import { MAX_WP_CONTENT_FILE_BYTES, R2_WP_CONTENT_OBJECT_PREFIX, validateWpContentDeletedPaths, validateWpContentManifestFiles, validateWpContentMetadata } from "../packages/runtime-cloudflare/src/wp-content-persistence.js" +import { runtimeArchiveComponentOwnedWpContentPaths, runtimeArchiveComponentSource } from "@automattic/wp-codebox-core/runtime-archive-component" +import { parseRuntimePackageManifest, selectRuntimePackageProfileFiles } from "@automattic/wp-codebox-core/runtime-package-profile" +import { CLOUDFLARE_RUNTIME_HEALTH_MARKER, CLOUDFLARE_RUNTIME_HEALTH_SCHEMA, cloudflareRuntimeHealthResponse } from "../src/health-envelope.js" +import { leaseRetryDelayMs } from "../src/lease-retry.js" +import { CANONICAL_RESTORE_PACK_SCHEMA, createCanonicalRestorePack, decodeCanonicalRestorePack, readCanonicalRestorePack, type CanonicalRestorePackFile, type CanonicalRestorePackMetadata } from "../src/canonical-restore-pack.js" +import { MUTATION_DIAGNOSTIC_SCHEMA, mutationRetentionContract } from "../src/mutation-memory.js" +import { selectOperatorCoordinator } from "../src/operator-coordinator.js" +import { canonicalPublicRoute, normalizePublishedRoutes, PUBLISHED_REVISION_SCHEMA, publishedPageObjectKey, publishedRevisionObjectKey, R2_PUBLISHED_CURRENT_KEY, validatePublishedRevision } from "../src/published-reader.js" +import { routeWorkerRequest } from "../src/request-routing.js" +import { toFetchResponse, toPHPRequest } from "../src/request-translation.js" +import { readStaticArtifactImport, STATIC_ARTIFACT_IMPORT_REQUEST_SCHEMA } from "../src/static-artifact-import.js" +import { WordPressStateCoordinator } from "../src/state-coordinator.js" +import { MAX_UPLOAD_FILE_BYTES, R2_UPLOAD_OBJECT_PREFIX, validateUploadManifestFiles, validateUploadMetadata } from "../src/upload-persistence.js" +import { isWordPressRuntimeFile, wordpressStaticArchivePath, wordpressStaticContentType } from "../src/wordpress-runtime-corpus.js" +import { materializeWordPressRuntimeArtifact, WORDPRESS_RUNTIME_ARTIFACT_SCHEMA, wordpressRuntimeArtifactKey, type WordPressRuntimeArtifactManifest } from "../src/wordpress-runtime-artifact.js" +import { validateWordPressStaticArtifactManifest, WORDPRESS_STATIC_ARTIFACT_SCHEMA, wordpressStaticArtifactKey, type WordPressStaticArtifactManifest } from "../src/wordpress-static-artifact.js" +import { readRuntimeArchiveArtifact, RUNTIME_ARCHIVE_ARTIFACT_SCHEMA, RUNTIME_ARCHIVE_MAX_BYTES, runtimeArchiveArtifactKey, validateRuntimeArchiveArtifactManifest, type RuntimeArchiveArtifactManifest } from "../src/runtime-archive-artifact.js" +import { MAX_WP_CONTENT_FILE_BYTES, R2_WP_CONTENT_OBJECT_PREFIX, validateWpContentDeletedPaths, validateWpContentManifestFiles, validateWpContentMetadata } from "../src/wp-content-persistence.js" + +const RUNTIME_COMMAND_RESULT_SCHEMA = "wp-codebox/runtime-command-result/v1" const execFileAsync = promisify(execFile) @@ -46,7 +47,7 @@ test("runtime package profiles select deployment-neutral capabilities determinis }) test("runtime archive components strictly validate source, materialization, abilities, and budgets", async () => { - const raw = JSON.parse(await readFile(new URL("../packages/runtime-cloudflare/components/website-importer.json", import.meta.url), "utf8")) + const raw = JSON.parse(await readFile(new URL("../components/website-importer.json", import.meta.url), "utf8")) const descriptor = runtimeArchiveComponentSource(raw) assert.equal(descriptor.component.id, "website-importer") assert.deepEqual(runtimeArchiveComponentOwnedWpContentPaths(descriptor.component), ["plugins/static-site-importer/", "mu-plugins/wp-codebox-runtime-component-website-importer.php"]) @@ -84,7 +85,7 @@ test("Cloudflare static artifact imports require bounded content-addressed R2 in }) test("Cloudflare static artifact imports invoke SSI with the canonical apply input", async () => { - const worker = await readFile(new URL("../packages/runtime-cloudflare/src/worker.ts", import.meta.url), "utf8") + const worker = await readFile(new URL("../src/worker.ts", import.meta.url), "utf8") assert.doesNotMatch(worker, /static-site-importer\/import-website-artifact/) assert.match(worker, /'operation' => 'apply'/) assert.match(worker, /'source' => array\(\s*'type' => 'files',\s*'entrypoint' => \(string\) \(\$artifact\['entrypoint'\] \?\? ''\),\s*'files' => isset\(\$artifact\['files'\]\)/) @@ -330,8 +331,8 @@ test("Cloudflare mutation persistence bounds retained JS bytes to one changed fi }) test("Cloudflare runtime declares bounded CPU and scheduled execution", async () => { - const config = JSON.parse((await readFile(new URL("../packages/runtime-cloudflare/wrangler.jsonc", import.meta.url), "utf8")).replace(/^\s*\/\/.*\n/, "")) as { main?: string; limits?: { cpu_ms?: number }; triggers?: { crons?: string[] } } - const d1Config = JSON.parse((await readFile(new URL("../packages/runtime-cloudflare/wrangler.d1.jsonc", import.meta.url), "utf8")).replace(/^\s*\/\/.*\n/, "")) as { + const config = JSON.parse((await readFile(new URL("../wrangler.jsonc", import.meta.url), "utf8")).replace(/^\s*\/\/.*\n/, "")) as { main?: string; limits?: { cpu_ms?: number }; triggers?: { crons?: string[] } } + const d1Config = JSON.parse((await readFile(new URL("../wrangler.d1.jsonc", import.meta.url), "utf8")).replace(/^\s*\/\/.*\n/, "")) as { main?: string limits?: { cpu_ms?: number } triggers?: { crons?: string[] } @@ -354,7 +355,7 @@ test("Cloudflare runtime declares bounded CPU and scheduled execution", async () }) test("Cloudflare control plane is PHP-free with only D1, R2, and queue production", async () => { - const config = JSON.parse((await readFile(new URL("../packages/runtime-cloudflare/wrangler.control.jsonc", import.meta.url), "utf8")).replace(/^\s*\/\/.*\n/, "")) as { + const config = JSON.parse((await readFile(new URL("../wrangler.control.jsonc", import.meta.url), "utf8")).replace(/^\s*\/\/.*\n/, "")) as { main?: string limits?: { cpu_ms?: number } triggers?: unknown @@ -374,7 +375,7 @@ test("Cloudflare control plane is PHP-free with only D1, R2, and queue productio assert.equal(config.durable_objects, undefined) assert.equal(config.rules, undefined) - const pending = [new URL("../packages/runtime-cloudflare/src/worker-control.ts", import.meta.url)] + const pending = [new URL("../src/worker-control.ts", import.meta.url)] const sources = new Map() while (pending.length) { const url = pending.pop()! @@ -413,17 +414,17 @@ test("Cloudflare lease contention honors Retry-After without exceeding the acqui }) test("Cloudflare runtime packages a provenanced canonical MDI seed", async () => { - const config = JSON.parse((await readFile(new URL("../packages/runtime-cloudflare/wrangler.jsonc", import.meta.url), "utf8")).replace(/^\s*\/\/.*\n/, "")) as { + const config = JSON.parse((await readFile(new URL("../wrangler.jsonc", import.meta.url), "utf8")).replace(/^\s*\/\/.*\n/, "")) as { rules?: Array<{ type?: string; globs?: string[] }> r2_buckets?: Array<{ binding?: string; bucket_name?: string }> durable_objects?: { bindings?: Array<{ name?: string; class_name?: string }> } migrations?: Array<{ new_sqlite_classes?: string[] }> } - const markdownIndex = await readFile(new URL("../packages/runtime-cloudflare/assets/markdown-primary-bootstrap-index.sqlite", import.meta.url)) - const markdownRuntime = await readFile(new URL("../packages/runtime-cloudflare/assets/markdown-database-integration-runtime.zip", import.meta.url)) - const canonicalSeed = await readFile(new URL("../packages/runtime-cloudflare/assets/markdown-database-integration-canonical-seed.zip", import.meta.url)) - const sqliteInput = await readFile(new URL("../packages/runtime-cloudflare/assets/wordpress-install-seed.sqlite", import.meta.url)) - const canonicalManifest = JSON.parse(await readFile(new URL("../packages/runtime-cloudflare/assets/markdown-database-integration-canonical-seed.json", import.meta.url), "utf8")) as { markdownDatabaseIntegrationRevision: string; wordpressInstallSeedSha256: string; archiveSha256: string; files: Array<{ path: string }> } + const markdownIndex = await readFile(new URL("../assets/markdown-primary-bootstrap-index.sqlite", import.meta.url)) + const markdownRuntime = await readFile(new URL("../assets/markdown-database-integration-runtime.zip", import.meta.url)) + const canonicalSeed = await readFile(new URL("../assets/markdown-database-integration-canonical-seed.zip", import.meta.url)) + const sqliteInput = await readFile(new URL("../assets/wordpress-install-seed.sqlite", import.meta.url)) + const canonicalManifest = JSON.parse(await readFile(new URL("../assets/markdown-database-integration-canonical-seed.json", import.meta.url), "utf8")) as { markdownDatabaseIntegrationRevision: string; wordpressInstallSeedSha256: string; archiveSha256: string; files: Array<{ path: string }> } assert.equal(markdownIndex.subarray(0, 16).toString(), "SQLite format 3\0") assert.equal(markdownRuntime.subarray(0, 4).toString("hex"), "504b0304") @@ -442,9 +443,9 @@ test("Cloudflare runtime packages a provenanced canonical MDI seed", async () => test("Cloudflare runtime pins and bundles the public constrained MDI runtime", async () => { const revision = "bf6d434d1673fdd86d777501f7eaec292d32ad1f" const jsonMachineRevision = "8bf0b0ff6ff60ab480778eaa5ad7d505b442c2d4" - const generator = await readFile(new URL("../scripts/build-cloudflare-mdi-runtime-bundle.mjs", import.meta.url), "utf8") - const worker = await readFile(new URL("../packages/runtime-cloudflare/src/worker.ts", import.meta.url), "utf8") - const runtime = await readFile(new URL("../packages/runtime-cloudflare/assets/markdown-database-integration-runtime.zip", import.meta.url)) + const generator = await readFile(new URL("../scripts/build-mdi-runtime-bundle.mjs", import.meta.url), "utf8") + const worker = await readFile(new URL("../src/worker.ts", import.meta.url), "utf8") + const runtime = await readFile(new URL("../assets/markdown-database-integration-runtime.zip", import.meta.url)) const names: string[] = [] let writeEngine = "" for await (const entry of decodeZip(new Blob([runtime]).stream())) { @@ -474,7 +475,7 @@ test("Cloudflare runtime pins and bundles the public constrained MDI runtime", a }) test("Cloudflare canonical runtime patches the unique init call with runtime persistence policies", async () => { - const worker = await readFile(new URL("../packages/runtime-cloudflare/src/worker.ts", import.meta.url), "utf8") + const worker = await readFile(new URL("../src/worker.ts", import.meta.url), "utf8") const patcher = worker.slice(worker.indexOf("function patchCanonicalRuntimePoliciesAtInit"), worker.indexOf("\nfunction collectRuntimeFiles")) assert.ok(patcher.startsWith("function patchCanonicalRuntimePoliciesAtInit"), "The canonical runtime policy patcher is present.") @@ -505,16 +506,16 @@ test("Cloudflare canonical runtime patches the unique init call with runtime per assert.match(worker, /canonicalBootstrapFlushCode/) }) test("Cloudflare runtime injects composable coordinators without moving PHP out of the Worker core", async () => { - const worker = await readFile(new URL("../packages/runtime-cloudflare/src/worker.ts", import.meta.url), "utf8") - const coordinator = await readFile(new URL("../packages/runtime-cloudflare/src/state-coordinator.ts", import.meta.url), "utf8") - const d1Coordinator = await readFile(new URL("../packages/runtime-cloudflare/src/d1-revision-coordinator.ts", import.meta.url), "utf8") - const contract = await readFile(new URL("../packages/runtime-cloudflare/src/revision-coordinator.ts", import.meta.url), "utf8") - const durableObjectEntry = await readFile(new URL("../packages/runtime-cloudflare/src/worker-do.ts", import.meta.url), "utf8") - const d1Entry = await readFile(new URL("../packages/runtime-cloudflare/src/worker-d1.ts", import.meta.url), "utf8") + const worker = await readFile(new URL("../src/worker.ts", import.meta.url), "utf8") + const coordinator = await readFile(new URL("../src/state-coordinator.ts", import.meta.url), "utf8") + const d1Coordinator = await readFile(new URL("../src/d1-revision-coordinator.ts", import.meta.url), "utf8") + const contract = await readFile(new URL("../src/revision-coordinator.ts", import.meta.url), "utf8") + const durableObjectEntry = await readFile(new URL("../src/worker-do.ts", import.meta.url), "utf8") + const d1Entry = await readFile(new URL("../src/worker-d1.ts", import.meta.url), "utf8") const materializer = worker.slice(worker.indexOf("async function materializeWordPressServerFiles"), worker.indexOf("async function serveWordPressStaticAsset")) const coordinatedRequest = worker.slice(worker.indexOf("async function runCoordinatedWordPressRequest"), worker.indexOf("async function matchWordPressPageCache")) const scheduledCron = worker.slice(worker.indexOf("async function runScheduledWordPressCron"), worker.indexOf("async function runNextCronEvent")) - const corpus = await readFile(new URL("../packages/runtime-cloudflare/src/wordpress-runtime-corpus.ts", import.meta.url), "utf8") + const corpus = await readFile(new URL("../src/wordpress-runtime-corpus.ts", import.meta.url), "utf8") assert.match(worker, /return await runCoordinatedWordPressRequest\(request, env, coordinator, site, route\.kind\)/) assert.doesNotMatch(d1Entry, /DurableObject|WORDPRESS_STATE\b|state-coordinator/) @@ -784,13 +785,13 @@ test("runtime archive dependencies are content-addressed and verified from R2", }) test("WordPress runtime corpus generator keeps the ZIP outside the Worker bundle", async () => { - const generator = await readFile(new URL("../scripts/generate-cloudflare-wordpress-runtime-corpus.ts", import.meta.url), "utf8") - const artifact = await readFile(new URL("../packages/runtime-cloudflare/src/wordpress-runtime-artifact.ts", import.meta.url), "utf8") - const manifest = JSON.parse(await readFile(new URL("../packages/runtime-cloudflare/assets/wordpress-runtime-artifact.json", import.meta.url), "utf8")) as WordPressRuntimeArtifactManifest - const staticManifest = JSON.parse(await readFile(new URL("../packages/runtime-cloudflare/assets/wordpress-static-artifact.json", import.meta.url), "utf8")) as WordPressStaticArtifactManifest - const sqliteManifest = JSON.parse(await readFile(new URL("../packages/runtime-cloudflare/assets/sqlite-database-integration-artifact.json", import.meta.url), "utf8")) as RuntimeArchiveArtifactManifest - const websiteImporterManifest = JSON.parse(await readFile(new URL("../packages/runtime-cloudflare/assets/website-importer-artifact.json", import.meta.url), "utf8")) as RuntimeArchiveArtifactManifest - const websiteImporterSource = runtimeArchiveComponentSource(JSON.parse(await readFile(new URL("../packages/runtime-cloudflare/components/website-importer.json", import.meta.url), "utf8"))) + const generator = await readFile(new URL("../scripts/generate-wordpress-runtime-corpus.ts", import.meta.url), "utf8") + const artifact = await readFile(new URL("../src/wordpress-runtime-artifact.ts", import.meta.url), "utf8") + const manifest = JSON.parse(await readFile(new URL("../assets/wordpress-runtime-artifact.json", import.meta.url), "utf8")) as WordPressRuntimeArtifactManifest + const staticManifest = JSON.parse(await readFile(new URL("../assets/wordpress-static-artifact.json", import.meta.url), "utf8")) as WordPressStaticArtifactManifest + const sqliteManifest = JSON.parse(await readFile(new URL("../assets/sqlite-database-integration-artifact.json", import.meta.url), "utf8")) as RuntimeArchiveArtifactManifest + const websiteImporterManifest = JSON.parse(await readFile(new URL("../assets/website-importer-artifact.json", import.meta.url), "utf8")) as RuntimeArchiveArtifactManifest + const websiteImporterSource = runtimeArchiveComponentSource(JSON.parse(await readFile(new URL("../components/website-importer.json", import.meta.url), "utf8"))) assert.match(generator, /const response = await fetch\(sourceUrl\)/) assert.match(generator, /decodeZip\(response\.body\)/) assert.doesNotMatch(generator, /decodeRemoteZip/) @@ -917,7 +918,7 @@ test("Cloudflare selects a dormant coordinator only for explicit operator cutove }) test("serialized Cloudflare mutations use MDI flush paths and complete canonical state", async () => { - const source = await readFile(new URL("../packages/runtime-cloudflare/src/worker.ts", import.meta.url), "utf8") + const source = await readFile(new URL("../src/worker.ts", import.meta.url), "utf8") const mutation = source.slice(source.indexOf("const SERIALIZED_MARKDOWN_MUTATION_CODE"), source.indexOf("export interface RuntimeEnv")) assert.match(mutation, /WP_Markdown_Primary_Storage_Runtime::bootstrap/) @@ -933,14 +934,14 @@ test("serialized Cloudflare mutations use MDI flush paths and complete canonical }) test("canonical reset preflights its pinned administrator root before mutation", async () => { - const source = await readFile(new URL("../packages/runtime-cloudflare/src/worker.ts", import.meta.url), "utf8") + const source = await readFile(new URL("../src/worker.ts", import.meta.url), "utf8") const reset = source.slice(source.indexOf("async function resetCanonicalWordPress"), source.indexOf("async function restoreCanonicalWordPress")) assert.ok(reset.indexOf("administratorPasswordForSite") < reset.indexOf("coordinator.reset()")) }) test("canonical MDI seed generator is reproducible and validates its pinned inputs", async () => { - const generator = new URL("../scripts/build-cloudflare-canonical-mdi-seed.php", import.meta.url) - const archive = new URL("../packages/runtime-cloudflare/assets/markdown-database-integration-canonical-seed.zip", import.meta.url) + const generator = new URL("../scripts/build-canonical-mdi-seed.php", import.meta.url) + const archive = new URL("../assets/markdown-database-integration-canonical-seed.zip", import.meta.url) const before = createHash("sha256").update(await readFile(archive)).digest("hex") await execFileAsync("php", [generator.pathname], { cwd: new URL("..", import.meta.url).pathname }) const after = createHash("sha256").update(await readFile(archive)).digest("hex") @@ -952,8 +953,8 @@ test("canonical MDI seed generator is reproducible and validates its pinned inpu }) test("canonical MDI seed owns the Cloudflare front page and its architecture explanation", async () => { - const generator = await readFile(new URL("../scripts/build-cloudflare-canonical-mdi-seed.php", import.meta.url), "utf8") - const archive = await readFile(new URL("../packages/runtime-cloudflare/assets/markdown-database-integration-canonical-seed.zip", import.meta.url)) + const generator = await readFile(new URL("../scripts/build-canonical-mdi-seed.php", import.meta.url), "utf8") + const archive = await readFile(new URL("../assets/markdown-database-integration-canonical-seed.zip", import.meta.url)) const files = new Map() for await (const entry of decodeZip(new Blob([archive]).stream())) files.set(entry.name, await entry.text()) const frontPage = files.get("page/cloudflare-wordpress-runtime.md") ?? "" diff --git a/tests/cloudflare-site-context.test.ts b/packages/runtime-cloudflare/tests/cloudflare-site-context.test.ts similarity index 98% rename from tests/cloudflare-site-context.test.ts rename to packages/runtime-cloudflare/tests/cloudflare-site-context.test.ts index c67106b17..6c70b8190 100644 --- a/tests/cloudflare-site-context.test.ts +++ b/packages/runtime-cloudflare/tests/cloudflare-site-context.test.ts @@ -1,6 +1,6 @@ import assert from "node:assert/strict" import test from "node:test" -import { allocatePreviewSiteContext, DEFAULT_SITE_CONTEXT, parseSiteContexts, previewDomain, resolvePreviewSiteContextFromRequest, resolveSiteContext, resolveSiteContextFromRequest, siteStorageKeys } from "../packages/runtime-cloudflare/src/site-context.js" +import { allocatePreviewSiteContext, DEFAULT_SITE_CONTEXT, parseSiteContexts, previewDomain, resolvePreviewSiteContextFromRequest, resolveSiteContext, resolveSiteContextFromRequest, siteStorageKeys } from "../src/site-context.js" test("site contexts preserve default storage paths and isolate configured sites", () => { assert.deepEqual(parseSiteContexts(undefined), [DEFAULT_SITE_CONTEXT]) diff --git a/tests/cloudflare-wordpress-archive-corpus.test.ts b/packages/runtime-cloudflare/tests/cloudflare-wordpress-archive-corpus.test.ts similarity index 93% rename from tests/cloudflare-wordpress-archive-corpus.test.ts rename to packages/runtime-cloudflare/tests/cloudflare-wordpress-archive-corpus.test.ts index 85154715b..9f45dbb41 100644 --- a/tests/cloudflare-wordpress-archive-corpus.test.ts +++ b/packages/runtime-cloudflare/tests/cloudflare-wordpress-archive-corpus.test.ts @@ -1,9 +1,9 @@ import assert from "node:assert/strict" import test from "node:test" import { decodeZip } from "@php-wasm/stream-compression" -import { isWordPressRuntimeFile, isWordPressStaticAsset, summarizeWordPressRuntimeCorpus, type WordPressArchiveEntry } from "../packages/runtime-cloudflare/src/wordpress-runtime-corpus.js" -import { WORDPRESS_RUNTIME_MAX_FILES, WORDPRESS_RUNTIME_MAX_UNCOMPRESSED_BYTES } from "../packages/runtime-cloudflare/src/wordpress-runtime-artifact.js" -import { WORDPRESS_STATIC_MAX_BYTES, WORDPRESS_STATIC_MAX_FILES } from "../packages/runtime-cloudflare/src/wordpress-static-artifact.js" +import { isWordPressRuntimeFile, isWordPressStaticAsset, summarizeWordPressRuntimeCorpus, type WordPressArchiveEntry } from "../src/wordpress-runtime-corpus.js" +import { WORDPRESS_RUNTIME_MAX_FILES, WORDPRESS_RUNTIME_MAX_UNCOMPRESSED_BYTES } from "../src/wordpress-runtime-artifact.js" +import { WORDPRESS_STATIC_MAX_BYTES, WORDPRESS_STATIC_MAX_FILES } from "../src/wordpress-static-artifact.js" const WORDPRESS_ARCHIVE_URL = "https://wordpress.org/latest.zip" diff --git a/tests/cloudflare-wordpress-auth.test.ts b/packages/runtime-cloudflare/tests/cloudflare-wordpress-auth.test.ts similarity index 95% rename from tests/cloudflare-wordpress-auth.test.ts rename to packages/runtime-cloudflare/tests/cloudflare-wordpress-auth.test.ts index 8cfb778df..33a011af0 100644 --- a/tests/cloudflare-wordpress-auth.test.ts +++ b/packages/runtime-cloudflare/tests/cloudflare-wordpress-auth.test.ts @@ -1,6 +1,6 @@ import assert from "node:assert/strict" import test from "node:test" -import { deriveSiteCredential, deriveWordPressAuthConstants, WORDPRESS_AUTH_CONSTANTS } from "../packages/runtime-cloudflare/src/wordpress-auth.js" +import { deriveSiteCredential, deriveWordPressAuthConstants, WORDPRESS_AUTH_CONSTANTS } from "../src/wordpress-auth.js" test("WordPress auth constants are deterministic, site-scoped, and domain-separated", async () => { const first = await deriveWordPressAuthConstants("test-root-secret", "default") diff --git a/packages/runtime-cloudflare/tests/package-command-boundary.test.mjs b/packages/runtime-cloudflare/tests/package-command-boundary.test.mjs new file mode 100644 index 000000000..ac5bec756 --- /dev/null +++ b/packages/runtime-cloudflare/tests/package-command-boundary.test.mjs @@ -0,0 +1,69 @@ +import assert from "node:assert/strict" +import { createRequire } from "node:module" +import { readFile } from "node:fs/promises" +import { resolve, sep } from "node:path" + +const packageRoot = resolve(import.meta.dirname, "..") +const packageJson = JSON.parse(await readFile(resolve(packageRoot, "package.json"), "utf8")) +const readme = await readFile(resolve(packageRoot, "README.md"), "utf8") +const packageRequire = createRequire(resolve(packageRoot, "package.json")) +const corePackagePath = packageRequire.resolve("@automattic/wp-codebox-core/package.json") +const corePackage = JSON.parse(await readFile(corePackagePath, "utf8")) + +assert.ok(corePackagePath.startsWith(`${packageRoot}${sep}vendor${sep}`), "the compatible core contract must resolve from package-owned vendored source") +assert.equal(packageJson.wpCodeboxCoreCompatibility, corePackage.version) +assert.equal(corePackage.version, "0.26.2") + +for (const name of [ + "test", + "test:queue", + "test:principal-credentials", + "test:remote-principal-credential-gate", + "local-gate", + "local-gate:d1", + "local-gate:provisioning", + "remote-gate:principal-credentials", + "generate:wordpress-runtime-corpus", + "provision:wordpress-runtime-corpus", + "provision:d1-coordinator", + "operator:principal-credential", + "generate:mdi-runtime-bundle", + "generate:canonical-mdi-seed", +]) { + const command = packageJson.scripts[name] + assert.ok(command, `missing package-owned command ${name}`) + assert.doesNotMatch(command, /cd \.\.\/\.\.|packages\/runtime-|\.\.\/\.\.\//, `${name} must not escape the package`) + if (name.startsWith("local-gate")) assert.match(command, /^playwright install chromium && /, `${name} must provision its pinned package-owned browser`) +} + +assert.doesNotMatch(packageJson.scripts.test, /register-package-local-loader/, "package tests must use normal package-local resolution") + +for (const [, command] of readme.matchAll(/`(npm (?:ci|test|run|exec)[^`]*)`/g)) { + const script = command.match(/^npm run ([a-z0-9:-]+)(?:\s|$)/)?.[1] + if (script) assert.ok(packageJson.scripts[script], `README advertises missing package script ${script}`) + else if (command === "npm test") assert.ok(packageJson.scripts.test, "README's npm test command must resolve to the package test script") + else if (command === "npm ci --workspaces=false") await readFile(resolve(packageRoot, "npm-shrinkwrap.json")) + else if (command.startsWith("npm exec -- wrangler ")) assert.ok(packageJson.dependencies.wrangler, "README's npm exec Wrangler command must resolve to a package dependency") + else assert.fail(`README advertises an unvalidated command: ${command}`) +} +for (const [, name] of readme.matchAll(/`((?:generate|provision|operator|remote-gate|dry-run|local-gate):[a-z0-9:-]+)`/g)) { + assert.ok(packageJson.scripts[name], `README references missing package script ${name}`) +} +assert.doesNotMatch(readme, /npm (?:--prefix|run cloudflare:)|packages\/runtime-cloudflare|\]\(\.\.\//, "README commands and links must work outside the repository checkout") +for (const [, config] of readme.matchAll(/--config ([a-z0-9.-]+\.jsonc)/g)) { + await readFile(resolve(packageRoot, config)) +} + +for (const path of [ + "scripts/local-gate.mjs", + "scripts/remote-principal-credential-gate.mjs", + "scripts/generate-wordpress-runtime-corpus.ts", + "scripts/provision-wordpress-runtime-corpus.mjs", + "scripts/provision-d1-coordinator.mjs", + "scripts/operator-principal-credential.ts", + "scripts/build-mdi-runtime-bundle.mjs", + "scripts/build-canonical-mdi-seed.php", +]) { + const source = await readFile(resolve(packageRoot, path), "utf8") + assert.doesNotMatch(source, /packages\/runtime-(?:core|playground|cloudflare)|runtime-playground\/dist|\.\.\/\.\.\//, `${path} must not resolve through the checkout root`) +} diff --git a/packages/runtime-cloudflare/tests/package-dependency-boundary.test.mjs b/packages/runtime-cloudflare/tests/package-dependency-boundary.test.mjs new file mode 100644 index 000000000..5351e6690 --- /dev/null +++ b/packages/runtime-cloudflare/tests/package-dependency-boundary.test.mjs @@ -0,0 +1,42 @@ +import assert from "node:assert/strict" +import { randomFillSync } from "node:crypto" +import { createRequire } from "node:module" +import { dirname, resolve, sep } from "node:path" +import { fileURLToPath, pathToFileURL } from "node:url" + +const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..") +const packageRequire = createRequire(resolve(packageRoot, "package.json")) +const dependencyPackage = packageRequire.resolve("@php-wasm/stream-compression/package.json") + +assert.ok(dependencyPackage.startsWith(`${packageRoot}${sep}node_modules${sep}`), "stream-compression must resolve from the Cloudflare package install") + +const { decodeRemoteZip, encodeZip } = await import(pathToFileURL(resolve(dirname(dependencyPackage), "index.js"))) +const payload = new Uint8Array(1024 * 1024 + 1) +randomFillSync(payload) +const archive = new Uint8Array(await new Response(encodeZip([new File([payload], "payload.txt", { lastModified: 0 })])).arrayBuffer()) +const originalFetch = globalThis.fetch + +globalThis.fetch = async (_input, init = {}) => { + if (init.method === "HEAD") return new Response(null, { headers: { "Content-Length": String(archive.byteLength) } }) + const range = new Headers(init.headers).get("Range") + assert.ok(range, "ranged ZIP decoding must request explicit byte ranges") + const match = /^bytes=(\d+)-(\d+)$/.exec(range) + assert.ok(match, `unexpected Range header: ${range}`) + const start = Number(match[1]) + const end = Number(match[2]) + return new Response(archive.slice(start, end + 1), { + status: 206, + headers: { "Content-Range": `bytes ${start}-${end}/${archive.byteLength}` }, + }) +} + +try { + const decoded = await decodeRemoteZip("https://example.test/archive.zip", () => true) + const files = [] + for await (const file of decoded) files.push(file) + assert.equal(files.length, 1) + assert.equal(new TextDecoder().decode(files[0].path), "payload.txt") + assert.deepEqual(files[0].bytes, payload, "the patched bounded range decoder must preserve file bytes") +} finally { + globalThis.fetch = originalFetch +} diff --git a/packages/runtime-cloudflare/tests/package-local-loader.mjs b/packages/runtime-cloudflare/tests/package-local-loader.mjs new file mode 100644 index 000000000..386447c85 --- /dev/null +++ b/packages/runtime-cloudflare/tests/package-local-loader.mjs @@ -0,0 +1,16 @@ +import { createRequire } from "node:module" +import { sep } from "node:path" +import { fileURLToPath, pathToFileURL } from "node:url" + +const packageRequire = createRequire(new URL("../package.json", import.meta.url)) +const packageNodeModules = `${fileURLToPath(new URL("../node_modules", import.meta.url))}${sep}` +const packageVendor = `${fileURLToPath(new URL("../vendor", import.meta.url))}${sep}` + +export async function resolve(specifier, context, nextResolve) { + const packageOwned = specifier === "tsx" || specifier.startsWith("tsx/") || specifier.startsWith("@automattic/wp-codebox-core/") || specifier.startsWith("@php-wasm/") || specifier.startsWith("@wp-playground/") + if (!packageOwned) return nextResolve(specifier, context) + + const resolved = packageRequire.resolve(specifier) + if (!resolved.startsWith(packageNodeModules) && !resolved.startsWith(packageVendor)) throw new Error(`${specifier} resolved outside runtime-cloudflare package dependencies`) + return nextResolve(pathToFileURL(resolved).href, context) +} diff --git a/packages/runtime-cloudflare/tests/packed-wrangler-bundle.test.mjs b/packages/runtime-cloudflare/tests/packed-wrangler-bundle.test.mjs new file mode 100644 index 000000000..daf9cacaa --- /dev/null +++ b/packages/runtime-cloudflare/tests/packed-wrangler-bundle.test.mjs @@ -0,0 +1,102 @@ +import assert from "node:assert/strict" +import { execFile } from "node:child_process" +import { mkdtemp, mkdir, readFile, rm } from "node:fs/promises" +import { tmpdir } from "node:os" +import { join, relative, resolve, sep } from "node:path" +import { promisify } from "node:util" + +const execFileAsync = promisify(execFile) +const packageRoot = resolve(import.meta.dirname, "..") +const repositoryRoot = resolve(packageRoot, "../..") +const temporaryRoot = await mkdtemp(join(tmpdir(), "wp-codebox-cloudflare-pack-")) +const tarballRoot = join(temporaryRoot, "tarballs") +const installRoot = join(temporaryRoot, "install") +const productionRoot = join(temporaryRoot, "production-install") +const unsupportedRoot = join(temporaryRoot, "unsupported-production-install") + +try { + await mkdir(tarballRoot) + await mkdir(installRoot) + await mkdir(productionRoot) + await mkdir(unsupportedRoot) + const { stdout } = await execFileAsync("npm", ["pack", ".", "--json", "--workspaces=false", "--pack-destination", tarballRoot], { + cwd: packageRoot, + maxBuffer: 1024 * 1024 * 20, + }) + const [packed] = JSON.parse(stdout) + const tarball = resolve(tarballRoot, packed.filename) + await execFileAsync("tar", ["-xzf", tarball, "-C", installRoot]) + await execFileAsync("tar", ["-xzf", tarball, "-C", productionRoot]) + await execFileAsync("tar", ["-xzf", tarball, "-C", unsupportedRoot]) + + const installedPackage = join(installRoot, "package") + assert.equal(installedPackage.startsWith(`${repositoryRoot}${sep}`), false, "packed runtime must be extracted outside the repository") + const shrinkwrap = JSON.parse(await readFile(join(installedPackage, "npm-shrinkwrap.json"), "utf8")) + const packedPackage = JSON.parse(await readFile(join(installedPackage, "package.json"), "utf8")) + assert.equal(packedPackage.engines?.node, ">=22.0.0", "the packed production runtime must retain its Node engine") + assert.deepEqual(shrinkwrap.packages?.[""]?.engines, packedPackage.engines, "the packed production lock must retain the Node engine") + assert.equal(shrinkwrap.packages?.[""]?.dependencies?.wrangler, "4.127.1", "the packed artifact must carry Wrangler as an exact production dependency") + await execFileAsync("npm", ["ci", "--include=dev", "--workspaces=false"], { cwd: installedPackage, maxBuffer: 1024 * 1024 * 20 }) + await execFileAsync("npm", ["ls", "--omit=dev"], { cwd: installedPackage, maxBuffer: 1024 * 1024 * 20 }) + await execFileAsync("npm", ["test"], { cwd: installedPackage, maxBuffer: 1024 * 1024 * 20 }) + await execFileAsync("npm", ["run", "build"], { cwd: installedPackage, maxBuffer: 1024 * 1024 * 20 }) + const streamCompression = await readFile(join(installedPackage, "node_modules/@php-wasm/stream-compression/index.js"), "utf8") + assert.match(streamCompression, /Expected a partial zip range response/, "packed runtime postinstall must apply its package-owned stream patch") + const universalStreamCompression = JSON.parse(await readFile(join(installedPackage, "node_modules/@php-wasm/universal/node_modules/@php-wasm/stream-compression/package.json"), "utf8")) + assert.equal(universalStreamCompression.version, "3.1.46", "Universal must retain its independently pinned stream-compression dependency") + const corePackage = JSON.parse(await readFile(join(installedPackage, "node_modules/@automattic/wp-codebox-core/package.json"), "utf8")) + assert.equal(corePackage.version, "0.26.2", "the packed runtime must install its explicit compatible core contract") + + for (const source of ["src/worker.ts", "src/runtime-archive-artifact.ts", "src/public-reader.ts"]) { + const contents = await readFile(join(installedPackage, source), "utf8") + assert.doesNotMatch(contents, /\.\.\/\.\.\/runtime-core\/src\//, `${source} must not import checkout-only sibling source`) + assert.match(contents, /@automattic\/wp-codebox-core\/runtime-archive-component/, `${source} must use the versioned shared contract`) + } + + const wranglerPackage = JSON.parse(await readFile(join(installedPackage, "node_modules/wrangler/package.json"), "utf8")) + assert.equal(wranglerPackage.version, "4.127.1") + const playwrightPackage = JSON.parse(await readFile(join(installedPackage, "node_modules/playwright/package.json"), "utf8")) + assert.equal(playwrightPackage.version, "1.61.1") + await execFileAsync(join(installedPackage, "node_modules/.bin/playwright"), ["install", "--dry-run", "chromium"], { cwd: installedPackage, maxBuffer: 1024 * 1024 * 20 }) + const wrangler = join(installedPackage, "node_modules/.bin/wrangler") + for (const config of ["wrangler.jsonc", "wrangler.d1.jsonc", "wrangler.control.jsonc", "wrangler.public-reader.jsonc"]) { + const outdir = join(temporaryRoot, "bundle", config.replace(/\.jsonc$/, "")) + await execFileAsync(wrangler, ["deploy", "--dry-run", "--config", join(installedPackage, config), "--outdir", outdir], { + cwd: installedPackage, + maxBuffer: 1024 * 1024 * 20, + }) + } + + const productionPackage = join(productionRoot, "package") + await execFileAsync("npm", ["ci", "--omit=dev", "--engine-strict", "--workspaces=false"], { + cwd: productionPackage, + env: { ...process.env, NODE_ENV: "production" }, + maxBuffer: 1024 * 1024 * 20, + }) + await execFileAsync("npm", ["ls", "--omit=dev"], { + cwd: productionPackage, + env: { ...process.env, NODE_ENV: "production" }, + maxBuffer: 1024 * 1024 * 20, + }) + const productionWrangler = join(productionPackage, "node_modules/.bin/wrangler") + const productionWranglerPackage = JSON.parse(await readFile(join(productionPackage, "node_modules/wrangler/package.json"), "utf8")) + assert.equal(productionWranglerPackage.version, "4.127.1") + await assert.rejects(readFile(join(productionPackage, "node_modules/playwright/package.json")), { code: "ENOENT" }) + await execFileAsync(productionWrangler, ["deploy", "--dry-run", "--config", join(productionPackage, "wrangler.d1.jsonc"), "--outdir", join(temporaryRoot, "production-bundle")], { + cwd: productionPackage, + env: { ...process.env, NODE_ENV: "production" }, + maxBuffer: 1024 * 1024 * 20, + }) + + const unsupportedPackage = join(unsupportedRoot, "package") + assert.ok(process.env.npm_execpath, "the packed install gate requires npm's CLI path") + await assert.rejects(execFileAsync("npm", ["exec", "--yes", "--package=node@20", "--", "node", process.env.npm_execpath, "ci", "--omit=dev", "--engine-strict", "--workspaces=false"], { + cwd: unsupportedPackage, + env: { ...process.env, NODE_ENV: "production" }, + maxBuffer: 1024 * 1024 * 20, + }), (error) => error?.code !== 0 && /EBADENGINE|Unsupported engine|not compatible with your version of node/i.test(`${error?.stdout ?? ""}\n${error?.stderr ?? ""}`)) + + console.log(`packed Cloudflare Wrangler bundle passed from ${relative(tmpdir(), installedPackage)}`) +} finally { + await rm(temporaryRoot, { recursive: true, force: true }) +} diff --git a/packages/runtime-cloudflare/tests/register-package-local-loader.mjs b/packages/runtime-cloudflare/tests/register-package-local-loader.mjs new file mode 100644 index 000000000..e65893c33 --- /dev/null +++ b/packages/runtime-cloudflare/tests/register-package-local-loader.mjs @@ -0,0 +1,3 @@ +import { register } from "node:module" + +register("./package-local-loader.mjs", import.meta.url) diff --git a/packages/runtime-cloudflare/tsconfig.json b/packages/runtime-cloudflare/tsconfig.json index d9c1ef61d..38b80502f 100644 --- a/packages/runtime-cloudflare/tsconfig.json +++ b/packages/runtime-cloudflare/tsconfig.json @@ -1,8 +1,13 @@ { - "extends": "../../tsconfig.base.json", "compilerOptions": { + "target": "ES2022", + "module": "NodeNext", + "moduleResolution": "NodeNext", + "strict": true, "noEmit": true, - "types": ["@cloudflare/workers-types"] + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "types": ["@cloudflare/workers-types", "node"] }, - "include": ["src/**/*.ts", "src/**/*.d.ts"] + "include": ["src/**/*.ts", "src/**/*.d.ts", "scripts/**/*.ts"] } diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/adversarial-campaign.d.ts b/packages/runtime-cloudflare/vendor/wp-codebox-core/adversarial-campaign.d.ts new file mode 100644 index 000000000..b284915b4 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/adversarial-campaign.d.ts @@ -0,0 +1,218 @@ +import type { TransportFaultModel } from "./transport-faults.js"; +export declare const ADVERSARIAL_CAMPAIGN_SCHEMA: "wp-codebox/adversarial-campaign/v1"; +export declare const ADVERSARIAL_CAMPAIGN_RESULT_SCHEMA: "wp-codebox/adversarial-campaign-result/v1"; +export declare const ADVERSARIAL_FINDING_SCHEMA: "wp-codebox/adversarial-finding/v1"; +export declare const ADVERSARIAL_REPLAY_SCHEMA: "wp-codebox/adversarial-replay/v1"; +export declare const ADVERSARIAL_ORACLE_SCHEMA: "wp-codebox/adversarial-oracle/v1"; +export declare const DIFFERENTIAL_RESULT_SCHEMA: "wp-codebox/differential-result/v1"; +export type AdversarialMutationKind = "scalar" | "structured" | "binary" | "sequence"; +export type AdversarialCaseStatus = "passed" | "failed" | "error" | "timed-out" | "resource-exhausted"; +export type AdversarialClockSurface = "runtime" | "wordpress" | "scheduler" | "database"; +export type AdversarialClockOperation = "freeze" | "advance" | "skew" | "restore"; +/** A portable, normalized clock instruction. Runtime adapters negotiate its fidelity. */ +export interface AdversarialClockScheduleEntry { + surface: AdversarialClockSurface; + operation: AdversarialClockOperation; + time?: number; + milliseconds?: number; +} +export interface AdversarialAction { + type: string; + input?: unknown; + /** Transitions applied immediately before this action's first declared phase. */ + clock?: AdversarialClockScheduleEntry[]; + metadata?: Record; +} +export interface AdversarialCorpusEntry { + id: string; + actions: AdversarialAction[]; + input?: unknown; + signals?: string[]; + metadata?: Record; +} +export interface AdversarialResourceBudget { + maxCases: number; + maxActionsPerCase: number; + maxInputBytes: number; + maxCaseTimeMs: number; + maxWallTimeMs: number; + maxArtifactBytes: number; + workers: number; +} +export interface AdversarialMatrixDimension { + name: string; + values: string[]; +} +export interface AdversarialOracleContract { + schema: typeof ADVERSARIAL_ORACLE_SCHEMA; + id: string; + severity: "low" | "medium" | "high" | "critical"; + description?: string; + metadata?: Record; +} +export interface AdversarialCampaign { + schema: typeof ADVERSARIAL_CAMPAIGN_SCHEMA; + id: string; + seed: string; + corpus: AdversarialCorpusEntry[]; + mutationKinds: AdversarialMutationKind[]; + budgets: AdversarialResourceBudget; + oracles: AdversarialOracleContract[]; + matrix?: AdversarialMatrixDimension[]; + faults?: TransportFaultModel; + provenance?: Record; + replayCommand?: string; + metadata?: Record; +} +export interface AdversarialCasePlan extends AdversarialCorpusEntry { + caseId: string; + corpusId: string; + iteration: number; + workerId: number; + matrix: Record; + mutation: { + kind: AdversarialMutationKind; + path: string; + description: string; + }; +} +export interface AdversarialExecutionObservation { + status: AdversarialCaseStatus; + signals?: string[]; + diagnostics?: Array<{ + code: string; + message: string; + severity?: string; + metadata?: Record; + }>; + artifacts?: Array<{ + path: string; + kind: string; + bytes?: number; + sha256?: string; + }>; + stateDigest?: string; + metrics?: { + durationMs?: number; + memoryBytes?: number; + cpuMs?: number; + [name: string]: number | undefined; + }; + metadata?: Record; +} +export interface AdversarialOracleResult { + oracleId: string; + failed: boolean; + code?: string; + message?: string; + evidence?: Record; +} +export interface AdversarialFinding { + schema: typeof ADVERSARIAL_FINDING_SCHEMA; + fingerprint: string; + caseId: string; + corpusId: string; + oracleIds: string[]; + status: AdversarialCaseStatus; + minimized: AdversarialCorpusEntry; + original: AdversarialCorpusEntry; + replay: AdversarialReplay; + diagnostics: AdversarialExecutionObservation["diagnostics"]; + artifactRefs: NonNullable; + secretScan: { + status: "passed" | "redacted"; + redactions: number; + }; + duplicates: number; + matrix: Record; +} +export interface AdversarialReplay { + schema: typeof ADVERSARIAL_REPLAY_SCHEMA; + campaignId: string; + seed: string; + caseId: string; + corpusId: string; + workerId: number; + iteration: number; + matrix: Record; + actions: AdversarialAction[]; + input?: unknown; + faultSchedule?: TransportFaultModel; + schedule: AdversarialScheduleEntry[]; + provenance?: Record; + command: string; + expectedFingerprint?: string; + expectedStateDigest?: string; +} +export interface AdversarialScheduleEntry { + round: number; + workerId: number; + caseId: string; + corpusId: string; + iteration: number; +} +export interface AdversarialCampaignResult { + schema: typeof ADVERSARIAL_CAMPAIGN_RESULT_SCHEMA; + campaignId: string; + seed: string; + status: "passed" | "findings" | "incomplete"; + summary: { + generated: number; + executed: number; + retained: number; + findings: number; + duplicates: number; + timedOut: number; + }; + corpus: AdversarialCorpusEntry[]; + findings: AdversarialFinding[]; + schedule: AdversarialScheduleEntry[]; + noveltySignals: string[]; + diagnostics: Array<{ + code: string; + message: string; + }>; + resourceUsage: { + wallTimeMs: number; + artifactBytes: number; + }; +} +export interface AdversarialCampaignRunnerOptions { + execute(plan: AdversarialCasePlan, signal: AbortSignal): Promise; + evaluate?(plan: AdversarialCasePlan, observation: AdversarialExecutionObservation, oracles: readonly AdversarialOracleContract[]): Promise | AdversarialOracleResult[]; + now?: () => number; + replayCommand?: (campaign: AdversarialCampaign, plan: AdversarialCasePlan, fingerprint: string) => string; + signal?: AbortSignal; + retainNovelty?: boolean; + minimize?: boolean; + /** Grace to wait for a cancelled case before terminalizing the campaign. */ + abortSettleGraceMs?: number; +} +export interface DifferentialCell { + id: string; + role?: "base" | "candidate"; + runtime?: Record; + fingerprint?: string; + status: AdversarialCaseStatus | "missing"; +} +export interface DifferentialResult { + schema: typeof DIFFERENTIAL_RESULT_SCHEMA; + classification: "candidate-regression" | "pre-existing" | "platform-difference" | "nondeterminism" | "equivalent"; + cells: DifferentialCell[]; + fingerprints: string[]; +} +export declare function adversarialCampaign(input: Omit & { + budgets?: Partial; + mutationKinds?: AdversarialMutationKind[]; + oracles?: AdversarialOracleContract[]; +}): AdversarialCampaign; +export declare function runAdversarialCampaign(campaignInput: AdversarialCampaign, options: AdversarialCampaignRunnerOptions): Promise; +export declare function mutateAdversarialValue(value: unknown, kind: AdversarialMutationKind, seed: string): { + value: unknown; + path: string; + description: string; +}; +export declare function adversarialFindingFingerprint(value: unknown): string; +export declare function classifyDifferentialResult(cells: DifferentialCell[]): DifferentialResult; +export declare function normalizeAdversarialClockSchedule(entries: readonly AdversarialClockScheduleEntry[]): AdversarialClockScheduleEntry[]; +//# sourceMappingURL=adversarial-campaign.d.ts.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/adversarial-campaign.d.ts.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/adversarial-campaign.d.ts.map new file mode 100644 index 000000000..73c630586 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/adversarial-campaign.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"adversarial-campaign.d.ts","sourceRoot":"","sources":["../src/adversarial-campaign.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAA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AAa,CAAC,EAAE,uBAAuB,EAAE,CAAC;IAAC,OAAO,CAAC,EAAE,yBAAyB,EAAE,CAAA;CAAE,GAAG,mBAAmB,CAsBlR;AAED,wBAAsB,sBAAsB,CAAC,aAAa,EAAE,mBAAmB,EAAE,OAAO,EAAE,gCAAgC,GAAG,OAAO,CAAC,yBAAyB,CAAC,CA4E9J;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,uBAAuB,EAAE,IAAI,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAUzJ;AAED,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEpE;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,gBAAgB,EAAE,GAAG,kBAAkB,CAUxF;AA2GD,wBAAgB,iCAAiC,CAAC,OAAO,EAAE,SAAS,6BAA6B,EAAE,GAAG,6BAA6B,EAAE,CAapI"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/adversarial-campaign.js b/packages/runtime-cloudflare/vendor/wp-codebox-core/adversarial-campaign.js new file mode 100644 index 000000000..d8a9fea07 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/adversarial-campaign.js @@ -0,0 +1,435 @@ +import { createHash } from "node:crypto"; +import { stableJson, stripUndefined } from "./object-utils.js"; +export const ADVERSARIAL_CAMPAIGN_SCHEMA = "wp-codebox/adversarial-campaign/v1"; +export const ADVERSARIAL_CAMPAIGN_RESULT_SCHEMA = "wp-codebox/adversarial-campaign-result/v1"; +export const ADVERSARIAL_FINDING_SCHEMA = "wp-codebox/adversarial-finding/v1"; +export const ADVERSARIAL_REPLAY_SCHEMA = "wp-codebox/adversarial-replay/v1"; +export const ADVERSARIAL_ORACLE_SCHEMA = "wp-codebox/adversarial-oracle/v1"; +export const DIFFERENTIAL_RESULT_SCHEMA = "wp-codebox/differential-result/v1"; +export function adversarialCampaign(input) { + if (!input.id || !input.seed) + throw new Error("Adversarial campaigns require non-empty id and seed values."); + if (input.corpus.length === 0) + throw new Error("Adversarial campaigns require at least one corpus entry."); + const ids = new Set(); + for (const entry of input.corpus) { + if (!entry.id || ids.has(entry.id)) + throw new Error(`Adversarial corpus ids must be non-empty and unique: ${entry.id}`); + ids.add(entry.id); + } + return stripUndefined({ + schema: ADVERSARIAL_CAMPAIGN_SCHEMA, + id: input.id, + seed: input.seed, + corpus: input.corpus.map(normalizeCorpusEntry), + mutationKinds: input.mutationKinds?.length ? [...new Set(input.mutationKinds)] : ["scalar", "structured", "binary", "sequence"], + budgets: normalizeBudgets(input.budgets), + oracles: input.oracles ?? [], + matrix: input.matrix, + faults: input.faults, + provenance: input.provenance, + replayCommand: input.replayCommand, + metadata: input.metadata, + }); +} +export async function runAdversarialCampaign(campaignInput, options) { + const campaign = adversarialCampaign(campaignInput); + const started = (options.now ?? Date.now)(); + const corpus = [...campaign.corpus]; + const novelty = new Set(corpus.flatMap((entry) => entry.signals ?? [])); + const findings = new Map(); + const schedule = []; + const diagnostics = []; + let executed = 0; + let generated = 0; + let artifactBytes = 0; + let timedOut = 0; + let incomplete = false; + for (let round = 0; generated < campaign.budgets.maxCases; round += 1) { + if (options.signal?.aborted) { + incomplete = true; + diagnostics.push({ code: "campaign-interrupted", message: "Campaign stopped after an interruption request." }); + break; + } + if ((options.now ?? Date.now)() - started >= campaign.budgets.maxWallTimeMs) { + incomplete = true; + diagnostics.push({ code: "campaign-wall-time-exhausted", message: "Campaign stopped at its wall-time budget." }); + break; + } + const roundPlans = []; + for (let workerId = 0; workerId < campaign.budgets.workers && generated < campaign.budgets.maxCases; workerId += 1) { + const corpusEntry = corpus[deterministicInteger(`${campaign.seed}:source:${generated}`, corpus.length)]; + const plan = mutateCorpusEntry(campaign, corpusEntry, generated, workerId); + roundPlans.push(plan); + schedule.push({ round, workerId, caseId: plan.caseId, corpusId: plan.corpusId, iteration: plan.iteration }); + generated += 1; + } + const observations = await Promise.all(roundPlans.map(async (plan) => await executeBoundedCase(campaign, plan, options))); + for (let index = 0; index < roundPlans.length; index += 1) { + const plan = roundPlans[index]; + const observation = observations[index]; + executed += 1; + if (observation.status === "timed-out") + timedOut += 1; + if (observation.status === "resource-exhausted") { + incomplete = true; + diagnostics.push({ code: "campaign-case-resource-exhausted", message: observation.diagnostics?.[0]?.message ?? `Campaign stopped because ${plan.caseId} exhausted a runtime resource before coverage completed.` }); + break; + } + if (observation.diagnostics?.some(({ code }) => code === "case-timeout-unsettled")) { + incomplete = true; + diagnostics.push({ code: "campaign-timeout-unsettled", message: `Campaign stopped because ${plan.caseId} did not settle after cancellation. The runtime must be torn down before further work.` }); + break; + } + artifactBytes += (observation.artifacts ?? []).reduce((total, artifact) => total + (artifact.bytes ?? 0), 0); + if (artifactBytes > campaign.budgets.maxArtifactBytes) { + incomplete = true; + diagnostics.push({ code: "campaign-artifact-budget-exhausted", message: "Campaign stopped before artifact evidence exceeded its byte budget." }); + break; + } + const newSignals = (observation.signals ?? []).filter((signal) => !novelty.has(signal)); + for (const signal of newSignals) + novelty.add(signal); + if (newSignals.length > 0 && options.retainNovelty !== false) + corpus.push({ id: plan.caseId, actions: plan.actions, input: plan.input, signals: [...new Set(observation.signals ?? [])], metadata: { retainedFrom: plan.corpusId, mutation: plan.mutation } }); + const oracleResults = options.evaluate ? await options.evaluate(plan, observation, campaign.oracles) : defaultOracleResults(observation); + const failedOracles = oracleResults.filter((result) => result.failed); + if (failedOracles.length > 0 || observation.status !== "passed") { + if (options.signal?.aborted) { + incomplete = true; + diagnostics.push({ code: "campaign-interrupted", message: "Campaign stopped before finding minimization after an interruption request." }); + break; + } + const fingerprint = observationFingerprint(plan, observation, failedOracles); + const minimized = options.minimize === false ? normalizeCorpusEntry({ id: plan.caseId, actions: plan.actions, input: plan.input }) : await minimizeAdversarialCase(campaign, plan, failedOracles, fingerprint, options); + const existing = findings.get(fingerprint); + if (existing) + existing.duplicates += 1; + else + findings.set(fingerprint, createFinding(campaign, plan, minimized, observation, failedOracles, schedule, options, fingerprint)); + } + } + if (incomplete) + break; + } + const duplicateCount = [...findings.values()].reduce((total, finding) => total + finding.duplicates, 0); + return { + schema: ADVERSARIAL_CAMPAIGN_RESULT_SCHEMA, + campaignId: campaign.id, + seed: campaign.seed, + status: incomplete ? "incomplete" : findings.size > 0 ? "findings" : "passed", + summary: { generated, executed, retained: corpus.length, findings: findings.size, duplicates: duplicateCount, timedOut }, + corpus, + findings: [...findings.values()].sort((left, right) => left.fingerprint.localeCompare(right.fingerprint)), + schedule, + noveltySignals: [...novelty].sort(), + diagnostics, + resourceUsage: { wallTimeMs: Math.max(0, (options.now ?? Date.now)() - started), artifactBytes }, + }; +} +export function mutateAdversarialValue(value, kind, seed) { + if (kind === "sequence") + return { value, path: "$", description: "sequence mutation is applied to actions" }; + const leaves = collectValueLeaves(value); + if (leaves.length === 0) + return { value: adversarialBoundaryValue(undefined, seed, kind), path: "$", description: `${kind} root boundary` }; + const leaf = leaves[deterministicInteger(seed, leaves.length)]; + const replacement = adversarialBoundaryValue(leaf.value, seed, kind); + if (leaf.path.length === 0) + return { value: replacement, path: "$", description: `${kind} root boundary mutation` }; + const mutated = cloneJsonValue(value); + setValueAtPath(mutated, leaf.path, replacement); + return { value: mutated, path: jsonPath(leaf.path), description: `${kind} boundary mutation` }; +} +export function adversarialFindingFingerprint(value) { + return createHash("sha256").update("wp-codebox/adversarial-finding-fingerprint/v1\n").update(stableJson(value)).digest("hex"); +} +export function classifyDifferentialResult(cells) { + const fingerprints = [...new Set(cells.map((cell) => cell.fingerprint).filter((value) => Boolean(value)))].sort(); + const base = cells.filter((cell) => cell.role === "base"); + const candidate = cells.filter((cell) => cell.role === "candidate"); + let classification = "equivalent"; + if (cells.some((cell) => cell.status === "missing") || cells.some((cell, index) => cells.findIndex((candidateCell) => candidateCell.id === cell.id) !== index)) + classification = "nondeterminism"; + else if (candidate.some(isDifferentialFailure) && base.every((cell) => !isDifferentialFailure(cell))) + classification = "candidate-regression"; + else if (candidate.some(isDifferentialFailure) && base.some(isDifferentialFailure)) + classification = "pre-existing"; + else if (fingerprints.length > 1 || new Set(cells.map((cell) => cell.status)).size > 1) + classification = "platform-difference"; + return { schema: DIFFERENTIAL_RESULT_SCHEMA, classification, cells, fingerprints }; +} +async function executeBoundedCase(campaign, plan, options) { + const controller = new AbortController(); + const abort = () => controller.abort(options.signal?.reason); + options.signal?.addEventListener("abort", abort, { once: true }); + let timer; + try { + const execution = options.execute(plan, controller.signal); + const completed = await Promise.race([ + execution.then((observation) => ({ kind: "completed", observation })), + new Promise((resolve) => { timer = setTimeout(() => { controller.abort(); resolve({ kind: "timed-out" }); }, campaign.budgets.maxCaseTimeMs); }), + ]); + if (completed.kind === "completed") + return completed.observation; + // Do not start another case while a timed-out case can still mutate shared state. + const settled = await Promise.race([ + execution.then(() => true, () => true), + new Promise((resolve) => setTimeout(() => resolve(false), boundedInteger(options.abortSettleGraceMs, 1_000, 1, 60_000))), + ]); + if (!settled) + return { status: "timed-out", diagnostics: [{ code: "case-timeout-unsettled", message: `Case exceeded ${campaign.budgets.maxCaseTimeMs}ms and did not settle during the abort grace period. Further cases require runtime teardown.` }], metadata: { cancellation: "runtime-teardown-required" } }; + return { status: "timed-out", diagnostics: [{ code: "case-time-budget-exhausted", message: `Case exceeded ${campaign.budgets.maxCaseTimeMs}ms and settled after cancellation.` }] }; + } + catch (error) { + return { status: "error", diagnostics: [{ code: "case-execution-error", message: error instanceof Error ? error.message : String(error) }] }; + } + finally { + if (timer) + clearTimeout(timer); + options.signal?.removeEventListener("abort", abort); + } +} +function mutateCorpusEntry(campaign, source, iteration, workerId) { + const kind = campaign.mutationKinds[deterministicInteger(`${campaign.seed}:kind:${iteration}`, campaign.mutationKinds.length)]; + let actions = source.actions.map((action) => ({ ...action, input: cloneJsonValue(action.input) })); + let input = cloneJsonValue(source.input); + let mutation = { kind, path: "$", description: `${kind} mutation` }; + if (kind === "sequence") { + actions = mutateActionSequence(actions, `${campaign.seed}:sequence:${iteration}`, campaign.budgets.maxActionsPerCase); + mutation = { kind, path: "$.actions", description: "stateful action schedule mutation" }; + } + else if (actions.length > 0 && deterministicInteger(`${campaign.seed}:target:${iteration}`, 2) === 0) { + const actionIndex = deterministicInteger(`${campaign.seed}:action:${iteration}`, actions.length); + const result = mutateAdversarialValue(actions[actionIndex]?.input, kind, `${campaign.seed}:value:${iteration}`); + actions[actionIndex] = { ...actions[actionIndex], input: result.value }; + mutation = { kind, path: `$.actions[${actionIndex}].input${result.path.slice(1)}`, description: result.description }; + } + else { + const result = mutateAdversarialValue(input, kind, `${campaign.seed}:value:${iteration}`); + input = result.value; + mutation = { kind, path: `$.input${result.path.slice(1)}`, description: result.description }; + } + actions = actions.slice(0, campaign.budgets.maxActionsPerCase); + if (jsonBytes(input) > campaign.budgets.maxInputBytes) + input = truncateJsonValue(input, campaign.budgets.maxInputBytes); + const matrix = matrixCell(campaign.matrix, iteration); + return { id: `${source.id}-mutation-${iteration}`, caseId: `${campaign.id}-${iteration}`, corpusId: source.id, iteration, workerId, matrix, actions, input, mutation, metadata: source.metadata }; +} +async function minimizeAdversarialCase(campaign, plan, originalOracles, expectedFingerprint, options) { + const oracleIds = new Set(originalOracles.filter((item) => item.failed).map((item) => item.oracleId)); + const preserves = async (candidate) => { + if (options.signal?.aborted) + return false; + const candidatePlan = { ...plan, actions: candidate.actions, input: candidate.input }; + const observation = await executeBoundedCase(campaign, candidatePlan, options); + const oracleResults = options.evaluate ? await options.evaluate(candidatePlan, observation, campaign.oracles) : defaultOracleResults(observation); + const preservesOracle = observation.status !== "passed" || oracleResults.some((item) => item.failed && (oracleIds.size === 0 || oracleIds.has(item.oracleId))); + return preservesOracle && observationFingerprint(candidatePlan, observation, oracleResults.filter((item) => item.failed)) === expectedFingerprint; + }; + let actions = [...plan.actions]; + let chunk = Math.max(1, Math.floor(actions.length / 2)); + while (actions.length > 1 && chunk >= 1) { + let reduced = false; + for (let start = 0; start < actions.length; start += chunk) { + const candidate = [...actions.slice(0, start), ...actions.slice(start + chunk)]; + if (candidate.length === 0) + continue; + if (await preserves({ id: plan.caseId, actions: candidate, input: plan.input })) { + actions = candidate; + reduced = true; + break; + } + } + if (!reduced) + chunk = Math.floor(chunk / 2); + } + for (let actionIndex = 0; actionIndex < actions.length; actionIndex += 1) { + for (const candidateInput of shrinkAdversarialValue(actions[actionIndex]?.input)) { + const candidateActions = actions.map((action, index) => index === actionIndex ? { ...action, input: candidateInput } : action); + if (await preserves({ id: plan.caseId, actions: candidateActions, input: plan.input })) + actions = candidateActions; + } + } + let input = plan.input; + for (const candidateInput of shrinkAdversarialValue(input)) { + if (await preserves({ id: plan.caseId, actions, input: candidateInput })) + input = candidateInput; + } + return stripUndefined({ id: plan.caseId, actions, input, metadata: { minimizedFrom: plan.corpusId } }); +} +function createFinding(campaign, plan, minimized, observation, oracles, schedule, options, fingerprint) { + const command = options.replayCommand?.(campaign, plan, fingerprint) ?? campaign.replayCommand ?? `wp-codebox adversarial replay --campaign ${campaign.id} --case ${plan.caseId}`; + return { + schema: ADVERSARIAL_FINDING_SCHEMA, + fingerprint, + caseId: plan.caseId, + corpusId: plan.corpusId, + oracleIds: oracles.filter((item) => item.failed).map((item) => item.oracleId).sort(), + status: observation.status, + minimized, + original: { id: plan.caseId, actions: plan.actions, input: plan.input }, + replay: stripUndefined({ schema: ADVERSARIAL_REPLAY_SCHEMA, campaignId: campaign.id, seed: campaign.seed, caseId: plan.caseId, corpusId: plan.corpusId, workerId: plan.workerId, iteration: plan.iteration, matrix: plan.matrix, actions: minimized.actions, input: minimized.input, faultSchedule: campaign.faults, schedule: [...schedule], provenance: campaign.provenance, command, expectedFingerprint: fingerprint, expectedStateDigest: observation.stateDigest }), + diagnostics: observation.diagnostics ?? [], + artifactRefs: observation.artifacts ?? [], + secretScan: { status: "passed", redactions: 0 }, + duplicates: 0, + matrix: plan.matrix, + }; +} +export function normalizeAdversarialClockSchedule(entries) { + return entries.map((entry, index) => { + if (!entry || !["runtime", "wordpress", "scheduler", "database"].includes(entry.surface)) + throw new Error(`Clock schedule entry ${index} has an invalid surface.`); + if (!entry || !["freeze", "advance", "skew", "restore"].includes(entry.operation)) + throw new Error(`Clock schedule entry ${index} has an invalid operation.`); + if ((entry.operation === "freeze" || entry.operation === "skew") && (!Number.isSafeInteger(entry.time) || entry.time < 0)) + throw new Error(`Clock schedule ${entry.operation} entry ${index} requires a non-negative Unix millisecond time.`); + if (entry.operation === "advance" && (!Number.isSafeInteger(entry.milliseconds) || entry.milliseconds < 0)) + throw new Error(`Clock schedule advance entry ${index} requires non-negative milliseconds.`); + if (entry.operation === "restore" && (entry.time !== undefined || entry.milliseconds !== undefined)) + throw new Error(`Clock schedule restore entry ${index} cannot include time values.`); + return entry.operation === "advance" + ? { surface: entry.surface, operation: entry.operation, milliseconds: entry.milliseconds } + : entry.operation === "freeze" || entry.operation === "skew" + ? { surface: entry.surface, operation: entry.operation, time: entry.time } + : { surface: entry.surface, operation: entry.operation }; + }); +} +function defaultOracleResults(observation) { + return observation.status === "passed" ? [] : [{ oracleId: "runtime-status", failed: true, code: observation.status, message: observation.diagnostics?.[0]?.message ?? `Runtime status was ${observation.status}.` }]; +} +function observationFingerprint(plan, observation, oracles) { + return adversarialFindingFingerprint({ + oracleIds: oracles.filter((result) => result.failed).map((result) => result.oracleId).sort(), + status: observation.status, + diagnosticCodes: (observation.diagnostics ?? []).map((item) => item.code).sort(), + stateDigest: observation.stateDigest, + matrix: plan.matrix, + }); +} +function normalizeBudgets(input) { + return { + maxCases: boundedInteger(input?.maxCases, 100, 1, 100_000), + maxActionsPerCase: boundedInteger(input?.maxActionsPerCase, 50, 1, 10_000), + maxInputBytes: boundedInteger(input?.maxInputBytes, 1_048_576, 1, 64 * 1_048_576), + maxCaseTimeMs: boundedInteger(input?.maxCaseTimeMs, 30_000, 1, 3_600_000), + maxWallTimeMs: boundedInteger(input?.maxWallTimeMs, 300_000, 1, 86_400_000), + maxArtifactBytes: boundedInteger(input?.maxArtifactBytes, 100 * 1_048_576, 1, 4 * 1024 * 1_048_576), + workers: boundedInteger(input?.workers, 1, 1, 128), + }; +} +function normalizeCorpusEntry(entry) { + return stripUndefined({ ...entry, actions: entry.actions.map((action) => stripUndefined({ ...action, input: cloneJsonValue(action.input), clock: action.clock ? normalizeAdversarialClockSchedule(action.clock) : undefined })), input: cloneJsonValue(entry.input), signals: entry.signals ? [...new Set(entry.signals)].sort() : undefined }); +} +function mutateActionSequence(actions, seed, maximum) { + if (actions.length === 0) + return [{ type: "noop", metadata: { generated: true } }]; + const operation = deterministicInteger(seed, 4); + const index = deterministicInteger(`${seed}:index`, actions.length); + if (operation === 0 && actions.length > 1) + return actions.filter((_, candidate) => candidate !== index); + if (operation === 1 && actions.length < maximum) + return [...actions.slice(0, index), actions[index], actions[index], ...actions.slice(index + 1)]; + if (operation === 2 && actions.length > 1) { + const reordered = [...actions]; + const target = (index + 1) % actions.length; + [reordered[index], reordered[target]] = [reordered[target], reordered[index]]; + return reordered; + } + return [...actions, actions[index]].slice(0, maximum); +} +function adversarialBoundaryValue(value, seed, kind) { + if (kind === "binary") { + const bytes = typeof value === "string" ? Buffer.from(value) : Buffer.from(stableJson(value)); + if (bytes.length === 0) + return { encoding: "base64", data: "/w==" }; + bytes[deterministicInteger(seed, bytes.length)] = (bytes[deterministicInteger(`${seed}:byte`, bytes.length)] ?? 0) ^ 0xff; + return { encoding: "base64", data: bytes.toString("base64") }; + } + if (typeof value === "string") { + const boundaries = ["", "\u0000", "'\"<>\\", "../".repeat(32), "A".repeat(4096), "\u202e\u2066hostile\u2069", "😀".repeat(256)]; + return boundaries[deterministicInteger(seed, boundaries.length)]; + } + if (typeof value === "number") + return [0, -1, Number.MAX_SAFE_INTEGER, Number.MIN_SAFE_INTEGER][deterministicInteger(seed, 4)]; + if (typeof value === "boolean") + return !value; + if (value === null || value === undefined) + return { unexpected: true }; + if (Array.isArray(value)) + return value.length === 0 ? [null] : [...value, cloneJsonValue(value[0])]; + if (typeof value === "object") + return { ...value, __unexpected: { nested: true } }; + return String(value); +} +function shrinkAdversarialValue(value) { + if (typeof value === "string") + return ["", value.slice(0, Math.floor(value.length / 2)), value.slice(0, 1)]; + if (typeof value === "number") + return [0, Math.sign(value)]; + if (Array.isArray(value)) + return [[], value.slice(0, Math.max(1, Math.floor(value.length / 2)))]; + if (value && typeof value === "object") { + const entries = Object.entries(value); + return entries.map(([key]) => Object.fromEntries(entries.filter(([candidate]) => candidate !== key))); + } + return []; +} +function collectValueLeaves(value, path = []) { + if (Array.isArray(value)) + return value.flatMap((item, index) => collectValueLeaves(item, [...path, index])); + if (value && typeof value === "object") + return Object.entries(value).flatMap(([key, item]) => collectValueLeaves(item, [...path, key])); + return [{ path, value }]; +} +function setValueAtPath(root, path, value) { + if (path.length === 0) + return; + let current = root; + for (const segment of path.slice(0, -1)) + current = current[segment]; + current[path[path.length - 1]] = value; +} +function matrixCell(dimensions, iteration) { + const cell = {}; + let divisor = 1; + for (const dimension of dimensions ?? []) { + if (dimension.values.length === 0) + continue; + cell[dimension.name] = dimension.values[Math.floor(iteration / divisor) % dimension.values.length]; + divisor *= dimension.values.length; + } + return cell; +} +function truncateJsonValue(value, maximumBytes) { + if (typeof value === "string") + return value.slice(0, maximumBytes); + const serialized = stableJson(value); + return { truncated: true, sha256: createHash("sha256").update(serialized).digest("hex"), originalBytes: Buffer.byteLength(serialized) }; +} +function cloneJsonValue(value) { + if (value === undefined) + return value; + return structuredClone(value); +} +function jsonBytes(value) { + return value === undefined ? 0 : Buffer.byteLength(stableJson(value)); +} +function jsonPath(path) { + return `$${path.map((segment) => typeof segment === "number" ? `[${segment}]` : `.${segment}`).join("")}`; +} +function deterministicInteger(seed, maximum) { + if (maximum <= 1) + return 0; + return createHash("sha256").update(seed).digest().readUInt32BE(0) % maximum; +} +function boundedInteger(value, fallback, minimum, maximum) { + if (!Number.isFinite(value)) + return fallback; + return Math.max(minimum, Math.min(maximum, Math.floor(value))); +} +function isDifferentialFailure(cell) { + return cell.status !== "passed" && cell.status !== "missing"; +} +//# sourceMappingURL=adversarial-campaign.js.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/adversarial-campaign.js.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/adversarial-campaign.js.map new file mode 100644 index 000000000..d684152fd --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/adversarial-campaign.js.map @@ -0,0 +1 @@ +{"version":3,"file":"adversarial-campaign.js","sourceRoot":"","sources":["../src/adversarial-campaign.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAG9D,MAAM,CAAC,MAAM,2BAA2B,GAAG,oCAA6C,CAAA;AACxF,MAAM,CAAC,MAAM,kCAAkC,GAAG,2CAAoD,CAAA;AACtG,MAAM,CAAC,MAAM,0BAA0B,GAAG,mCAA4C,CAAA;AACtF,MAAM,CAAC,MAAM,yBAAyB,GAAG,kCAA2C,CAAA;AACpF,MAAM,CAAC,MAAM,yBAAyB,GAAG,kCAA2C,CAAA;AACpF,MAAM,CAAC,MAAM,0BAA0B,GAAG,mCAA4C,CAAA;AAqLtF,MAAM,UAAU,mBAAmB,CAAC,KAAyN;IAC3P,IAAI,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAA;IAC5G,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAA;IAC1G,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAA;IAC7B,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;QACjC,IAAI,CAAC,KAAK,CAAC,EAAE,IAAI,GAAG,CAAC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,CAAC,IAA4B;IAC5C,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAA;AAC3G,CAAC;AAED,SAAS,oBAAoB,CAAC,IAAY,EAAE,OAAe;IACzD,IAAI,OAAO,IAAI,CAAC;QAAE,OAAO,CAAC,CAAA;IAC1B,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,OAAO,CAAA;AAC7E,CAAC;AAED,SAAS,cAAc,CAAC,KAAyB,EAAE,QAAgB,EAAE,OAAe,EAAE,OAAe;IACnG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAA;IAC5C,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,KAAe,CAAC,CAAC,CAAC,CAAA;AAC1E,CAAC;AAED,SAAS,qBAAqB,CAAC,IAAsB;IACnD,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,CAAA;AAC9D,CAAC"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-layout.d.ts b/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-layout.d.ts new file mode 100644 index 000000000..089cf3646 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-layout.d.ts @@ -0,0 +1,38 @@ +import { type ArtifactManifest, type ArtifactManifestFile, type ArtifactManifestFileOptions, type ArtifactViewerMetadata } from "./artifact-manifest.js"; +export interface ManifestedArtifactFileInput { + path: string; + kind: ArtifactManifestFile["kind"]; + contentType: string; + viewer?: ArtifactViewerMetadata; + redaction?: ArtifactManifestFileOptions["redaction"]; + provenance?: ArtifactManifestFileOptions["provenance"]; +} +export declare class ManifestedArtifactSet { + private readonly entries; + add(input: ManifestedArtifactFileInput): ArtifactManifestFile; + files(): ArtifactManifestFile[]; +} +export declare class ArtifactBundleWriter { + private readonly directory; + private readonly manifestPath; + readonly artifacts: ManifestedArtifactSet; + constructor(directory: string, manifestPath?: string); + path(path: string): string; + relativePath(path: string): string; + write(path: string, contents: string | Buffer, manifest: Omit): Promise; + writeJson(path: string, value: unknown, manifest: Omit & { + contentType?: string; + }): Promise; + writeJsonLines(path: string, records: unknown[], manifest: Omit & { + contentType?: string; + }): Promise; + writeGenerated(path: string, manifest: Omit, write: (absolutePath: string) => Promise): Promise; + importFile(path: string, sourcePath: string, manifest: Omit): Promise; + writeManifest(manifest: T): Promise; +} +export declare function artifactJson(value: unknown): string; +export declare function artifactJsonLines(records: unknown[]): string; +export declare function artifactManifestRelativePath(artifactRoot: string, path: string): string; +export declare function writeArtifactJson(path: string, value: unknown): Promise; +export declare function writeArtifactManifestJson(directory: string, manifestPath: string, manifest: ArtifactManifest): Promise; +//# sourceMappingURL=artifact-layout.d.ts.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-layout.d.ts.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-layout.d.ts.map new file mode 100644 index 000000000..a997a8c25 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-layout.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"artifact-layout.d.ts","sourceRoot":"","sources":["../src/artifact-layout.ts"],"names":[],"mappings":"AAGA,OAAO,EAA4D,KAAK,gBAAgB,EAAE,KAAK,oBAAoB,EAAE,KAAK,2BAA2B,EAAE,KAAK,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAGlN,MAAM,WAAW,2BAA2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WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAO/J,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,2BAA2B,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAMhJ,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,2BAA2B,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAMhH,aAAa,CAAC,CAAC,SAAS,gBAAgB,EAAE,QAAQ,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAMzE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEnD;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,CAE5D;AAED,wBAAgB,4BAA4B,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAQvF;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAGnF;AAED,wBAAsB,yBAAyB,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAKlI"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-layout.js b/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-layout.js new file mode 100644 index 000000000..f6bc2aa52 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-layout.js @@ -0,0 +1,93 @@ +import { copyFile, mkdir, writeFile } from "node:fs/promises"; +import { dirname, isAbsolute, relative, resolve } from "node:path"; +import { artifactManifestFile, refreshArtifactManifestFileSha256s } from "./artifact-manifest.js"; +import { resolveArtifactPath, safeArtifactRelativePath } from "./artifact-paths.js"; +export class ManifestedArtifactSet { + entries = new Map(); + add(input) { + const entry = artifactManifestFile(input.path, input.kind, input.contentType, undefined, { + viewer: input.viewer, + redaction: input.redaction, + provenance: input.provenance, + }); + this.entries.set(input.path, entry); + return entry; + } + files() { + return [...this.entries.values()]; + } +} +export class ArtifactBundleWriter { + directory; + manifestPath; + artifacts = new ManifestedArtifactSet(); + constructor(directory, manifestPath = "manifest.json") { + this.directory = directory; + this.manifestPath = manifestPath; + } + path(path) { + return resolveArtifactPath(this.directory, path).absolutePath; + } + relativePath(path) { + return artifactManifestRelativePath(this.directory, path); + } + async write(path, contents, manifest) { + this.artifacts.add({ path, ...manifest }); + await mkdir(dirname(this.path(path)), { recursive: true }); + await writeFile(this.path(path), contents); + } + async writeJson(path, value, manifest) { + await this.write(path, artifactJson(value), { + ...manifest, + contentType: manifest.contentType ?? "application/json", + }); + } + async writeJsonLines(path, records, manifest) { + await this.write(path, artifactJsonLines(records), { + ...manifest, + contentType: manifest.contentType ?? "application/x-ndjson", + }); + } + async writeGenerated(path, manifest, write) { + this.artifacts.add({ path, ...manifest }); + await mkdir(dirname(this.path(path)), { recursive: true }); + await write(this.path(path)); + } + async importFile(path, sourcePath, manifest) { + await this.writeGenerated(path, manifest, async (destinationPath) => { + await copyFile(sourcePath, destinationPath); + }); + } + async writeManifest(manifest) { + this.artifacts.add({ path: this.manifestPath, kind: "manifest", contentType: "application/json" }); + manifest.files = this.artifacts.files(); + await writeArtifactManifestJson(this.directory, this.manifestPath, manifest); + return manifest; + } +} +export function artifactJson(value) { + return `${JSON.stringify(value, null, 2)}\n`; +} +export function artifactJsonLines(records) { + return records.length > 0 ? `${records.map((record) => JSON.stringify(record)).join("\n")}\n` : ""; +} +export function artifactManifestRelativePath(artifactRoot, path) { + const root = resolve(artifactRoot); + const absolutePath = isAbsolute(path) ? resolve(path) : resolveArtifactPath(root, path).absolutePath; + const relativePath = relative(root, absolutePath).replace(/\\/g, "/"); + if (relativePath === "" || relativePath === ".." || relativePath.startsWith("../") || isAbsolute(relativePath)) { + throw new Error(`Artifact path must stay inside the artifact root: ${path}`); + } + return safeArtifactRelativePath(relativePath); +} +export async function writeArtifactJson(path, value) { + await mkdir(dirname(path), { recursive: true }); + await writeFile(path, artifactJson(value)); +} +export async function writeArtifactManifestJson(directory, manifestPath, manifest) { + await refreshArtifactManifestFileSha256s(directory, manifest, manifestPath); + await writeArtifactJson(resolveArtifactPath(directory, manifestPath).absolutePath, manifest); + await refreshArtifactManifestFileSha256s(directory, manifest, manifestPath); + await writeArtifactJson(resolveArtifactPath(directory, manifestPath).absolutePath, manifest); +} +//# sourceMappingURL=artifact-layout.js.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-layout.js.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-layout.js.map new file mode 100644 index 000000000..87cd443cd --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-layout.js.map @@ -0,0 +1 @@ +{"version":3,"file":"artifact-layout.js","sourceRoot":"","sources":["../src/artifact-layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC7D,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAElE,OAAO,EAAE,oBAAoB,EAAE,kCAAkC,EAAmH,MAAM,wBAAwB,CAAA;AAClN,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAWnF,MAAM,OAAO,qBAAqB;IACf,OAAO,GAAG,IAAI,GAAG,EAAgC,CAAA;IAElE,GAAG,CAAC,KAAkC;QACpC,MAAM,KAAK,GAAG,oBAAoB,CAAC,KAAK,CAA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E,CAAC,CAAA;IAC9E,CAAC;IACD,OAAO,wBAAwB,CAAC,YAAY,CAAC,CAAA;AAC/C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,IAAY,EAAE,KAAc;IAClE,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAC/C,MAAM,SAAS,CAAC,IAAI,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,CAAA;AAC5C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,SAAiB,EAAE,YAAoB,EAAE,QAA0B;IACjH,MAAM,kCAAkC,CAAC,SAAS,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAA;IAC3E,MAAM,iBAAiB,CAAC,mBAAmB,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAA;IAC5F,MAAM,kCAAkC,CAAC,SAAS,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAA;IAC3E,MAAM,iBAAiB,CAAC,mBAAmB,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAA;AAC9F,CAAC"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-manifest.d.ts b/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-manifest.d.ts new file mode 100644 index 000000000..cfe60a162 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-manifest.d.ts @@ -0,0 +1,108 @@ +import type { RuntimeInfo } from "./runtime-contracts.js"; +export interface ArtifactSpec { + includeFiles?: boolean; + includeLogs?: boolean; + includePatch?: boolean; + includeScreenshots?: boolean; + includeObservations?: boolean; + includeRuntimeSnapshotBundles?: boolean; + previewHoldSeconds?: number; +} +export interface ArtifactManifestFile { + path: string; + kind: "manifest" | "metadata" | "events" | "commands" | "observations" | "log" | "mounts" | "file" | "diagnostics" | "test-results" | "tool-call-transcript" | "tool-call-input" | "tool-call-output" | (string & {}); + contentType: string; + sha256: ArtifactFileDigest; + redaction?: ArtifactRedactionMetadata; + provenance?: ArtifactProvenanceMetadata; + viewer?: ArtifactViewerMetadata; +} +export interface ArtifactRedactionMetadata { + policy: "none" | "required" | "applied" | (string & {}); + reason?: string; + sensitive?: boolean; +} +export interface ArtifactProvenanceMetadata { + source: string; + operation?: string; + id?: string; + metadata?: Record; +} +export interface ArtifactViewerMetadata { + kind: string; + base: string; + query: { + parameter: string; + value: { + source: "public-artifact-url" | (string & {}); + path: string; + kind?: string; + contentType?: string; + sha256?: ArtifactFileDigest; + }; + encoding: "url" | (string & {}); + }; + replay: { + status: "full" | "partial" | "unavailable" | (string & {}); + limitations: string[]; + }; +} +export interface ArtifactManifestCaseArtifactRef { + path: string; + kind: string; + contentType?: string; + sha256?: ArtifactFileDigest; + publicUrl?: string; + redaction?: ArtifactRedactionMetadata; + provenance?: ArtifactProvenanceMetadata; + metadata?: Record; +} +export interface ArtifactManifestCaseVerificationMetadata { + status: "passed" | "failed" | "skipped" | "unknown" | (string & {}); + verifiedAt?: string; + verifier?: string; + diagnostics?: string[]; + metadata?: Record; +} +export interface ArtifactManifestCase { + id: string; + hash?: ArtifactFileDigest; + digest?: ArtifactFileDigest; + artifacts: ArtifactManifestCaseArtifactRef[]; + redaction?: ArtifactRedactionMetadata; + verification?: ArtifactManifestCaseVerificationMetadata; + metadata?: Record; +} +export interface ArtifactFileDigest { + algorithm: "sha256"; + value: string; +} +export interface ArtifactManifest { + id: string; + contentDigest: ArtifactContentDigest; + createdAt: string; + runtime: RuntimeInfo; + files: ArtifactManifestFile[]; + cases?: ArtifactManifestCase[]; +} +export interface ArtifactContentDigest { + algorithm: "sha256"; + inputs: string[]; + value: string; +} +export declare function artifactFileDigest(contents: string | Buffer): ArtifactFileDigest; +export interface ArtifactManifestFileOptions { + viewer?: ArtifactViewerMetadata; + redaction?: ArtifactRedactionMetadata; + provenance?: ArtifactProvenanceMetadata; +} +export declare function artifactManifestFile(path: string, kind: ArtifactManifestFile["kind"], contentType: string, sha256?: ArtifactFileDigest, viewerOrOptions?: ArtifactViewerMetadata | ArtifactManifestFileOptions): ArtifactManifestFile; +export declare function artifactManifestFileWithSha256(path: string, kind: ArtifactManifestFile["kind"], contentType: string, sha256: string): ArtifactManifestFile; +export declare function placeholderArtifactFileDigest(): ArtifactFileDigest; +export declare function calculateArtifactContentDigest(directory: string, inputs: string[]): Promise; +export declare function calculateArtifactManifestFileListDigest(files: ArtifactManifestFile[]): string; +export declare function calculateArtifactManifestFileSha256(directory: string, manifest: ArtifactManifest, file: ArtifactManifestFile, manifestFileName?: string): Promise; +export declare function calculateArtifactManifestSelfSha256(manifest: ArtifactManifest, manifestFileName?: string): string; +export declare function upsertArtifactManifestFiles(manifest: ArtifactManifest, files: ArtifactManifestFile[]): void; +export declare function refreshArtifactManifestFileSha256s(directory: string, manifest: ArtifactManifest, manifestFileName?: string): Promise; +//# sourceMappingURL=artifact-manifest.d.ts.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-manifest.d.ts.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-manifest.d.ts.map new file mode 100644 index 000000000..3f3fd1954 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-manifest.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"artifact-manifest.d.ts","sourceRoot":"","sources":["../src/artifact-manifest.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAIzD,MAAM,WAAW,YAAY;IAC3B,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,6BAA6B,CAAC,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,MAAM,CAAC,CAWzG;AAED,wBAAgB,uCAAuC,CAAC,KAAK,EAAE,oBAAoB,EAAE,GAAG,MAAM,CAK7F;AAED,wBAAsB,mCAAmC,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,oBAAoB,EAAE,gBAAgB,SAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CAMxL;AAED,wBAAgB,mCAAmC,CAAC,QAAQ,EAAE,gBAAgB,EAAE,gBAAgB,SAAkB,GAAG,MAAM,CAK1H;AAED,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,gBAAgB,EAAE,KAAK,EAAE,oBAAoB,EAAE,GAAG,IAAI,CAU3G;AAED,wBAAsB,kCAAkC,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,gBAAgB,SAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAWzJ"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-manifest.js b/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-manifest.js new file mode 100644 index 000000000..bf64eda6c --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-manifest.js @@ -0,0 +1,92 @@ +import { createHash } from "node:crypto"; +import { readFile } from "node:fs/promises"; +import { resolveArtifactPath } from "./artifact-paths.js"; +import { stableJson } from "./object-utils.js"; +const EMPTY_SHA256 = "0".repeat(64); +export function artifactFileDigest(contents) { + return { algorithm: "sha256", value: createHash("sha256").update(contents).digest("hex") }; +} +export function artifactManifestFile(path, kind, contentType, sha256 = placeholderArtifactFileDigest(), viewerOrOptions) { + const options = artifactManifestFileOptions(viewerOrOptions); + return stripUndefined({ path, kind, contentType, sha256, ...options }); +} +export function artifactManifestFileWithSha256(path, kind, contentType, sha256) { + return artifactManifestFile(path, kind, contentType, { algorithm: "sha256", value: sha256 }); +} +export function placeholderArtifactFileDigest() { + return { algorithm: "sha256", value: EMPTY_SHA256 }; +} +export async function calculateArtifactContentDigest(directory, inputs) { + const hash = createHash("sha256").update("wp-codebox/artifact-content/v1\n"); + for (const [index, input] of inputs.entries()) { + if (index > 0) { + hash.update("\n"); + } + hash.update(`${input}\n`); + hash.update(await readFile(resolveArtifactPath(directory, input).absolutePath)); + } + return hash.digest("hex"); +} +export function calculateArtifactManifestFileListDigest(files) { + return createHash("sha256") + .update("wp-codebox/artifact-manifest-file-list/v1\n") + .update(stableJson(files.map(({ path, kind, contentType, redaction, provenance, viewer }) => stripUndefined({ path, kind, contentType, redaction, provenance, viewer })))) + .digest("hex"); +} +export async function calculateArtifactManifestFileSha256(directory, manifest, file, manifestFileName = "manifest.json") { + if (file.path === manifestFileName) { + return calculateArtifactManifestSelfSha256(manifest, manifestFileName); + } + return artifactFileDigest(await readFile(resolveArtifactPath(directory, file.path).absolutePath)).value; +} +export function calculateArtifactManifestSelfSha256(manifest, manifestFileName = "manifest.json") { + return createHash("sha256") + .update("wp-codebox/artifact-manifest-self/v1\n") + .update(stableJson(manifestWithPlaceholderSelfHash(manifest, manifestFileName))) + .digest("hex"); +} +export function upsertArtifactManifestFiles(manifest, files) { + manifest.files = Array.isArray(manifest.files) ? manifest.files : []; + for (const file of files) { + const existing = manifest.files.find((entry) => entry.path === file.path); + if (existing) { + Object.assign(existing, file); + } + else { + manifest.files.push(file); + } + } +} +export async function refreshArtifactManifestFileSha256s(directory, manifest, manifestFileName = "manifest.json") { + for (const file of manifest.files) { + if (file.path !== manifestFileName) { + file.sha256 = { algorithm: "sha256", value: await calculateArtifactManifestFileSha256(directory, manifest, file, manifestFileName) }; + } + } + for (const file of manifest.files) { + if (file.path === manifestFileName) { + file.sha256 = { algorithm: "sha256", value: await calculateArtifactManifestFileSha256(directory, manifest, file, manifestFileName) }; + } + } +} +function manifestWithPlaceholderSelfHash(manifest, manifestFileName) { + return { + ...manifest, + files: manifest.files.map((file) => file.path === manifestFileName + ? { ...file, sha256: placeholderArtifactFileDigest() } + : file), + }; +} +function stripUndefined(value) { + return Object.fromEntries(Object.entries(value).filter(([, item]) => item !== undefined)); +} +function artifactManifestFileOptions(viewerOrOptions) { + if (!viewerOrOptions) { + return {}; + } + if ("base" in viewerOrOptions && "query" in viewerOrOptions && "replay" in viewerOrOptions) { + return { viewer: viewerOrOptions }; + } + return viewerOrOptions; +} +//# sourceMappingURL=artifact-manifest.js.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-manifest.js.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-manifest.js.map new file mode 100644 index 000000000..de4180e3e --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-manifest.js.map @@ -0,0 +1 @@ +{"version":3,"file":"artifact-manifest.js","sourceRoot":"","sources":["../src/artifact-manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAG3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAsH9C,MAAM,YAAY,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AAEnC,MAAM,UAAU,kBAAkB,CAAC,QAAyB;IAC1D,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAA;AAC5F,CAAC;AAQD,MAAM,UAAU,oBAAoB,CAAC,IAAY,EAAE,IAAkC,EAAE,WAAmB,EAAE,SAA6B,6BAA6B,EAAE,EAAE,eAAsE;IAC9O,MAAM,OAAO,GAAG,2BAA2B,CAAC,eAAe,CAAC,CAAA;IAC5D,OAAO,cAAc,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,MA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AAc,CAAmB,KAAQ;IAChD,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,CAAM,CAAA;AAChG,CAAC;AAED,SAAS,2BAA2B,CAAC,eAAiF;IACpH,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,OAAO,EAAE,CAAA;IACX,CAAC;IACD,IAAI,MAAM,IAAI,eAAe,IAAI,OAAO,IAAI,eAAe,IAAI,QAAQ,IAAI,eAAe,EAAE,CAAC;QAC3F,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,CAAA;IACpC,CAAC;IACD,OAAO,eAAe,CAAA;AACxB,CAAC"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-paths.d.ts b/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-paths.d.ts new file mode 100644 index 000000000..27e0b6e20 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-paths.d.ts @@ -0,0 +1,8 @@ +export interface ResolvedArtifactPath { + root: string; + relativePath: string; + absolutePath: string; +} +export declare function safeArtifactRelativePath(path: string): string; +export declare function resolveArtifactPath(root: string, path: string): ResolvedArtifactPath; +//# sourceMappingURL=artifact-paths.d.ts.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-paths.d.ts.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-paths.d.ts.map new file mode 100644 index 000000000..8ec2da0a0 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-paths.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"artifact-paths.d.ts","sourceRoot":"","sources":["../src/artifact-paths.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAY7D;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,oBAAoB,CAUpF"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-paths.js b/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-paths.js new file mode 100644 index 000000000..e915084b0 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-paths.js @@ -0,0 +1,26 @@ +import { isAbsolute, relative, resolve } from "node:path"; +export function safeArtifactRelativePath(path) { + const normalized = path.trim().replace(/\\/g, "/"); + if (!normalized || /^[A-Za-z]:($|\/)/.test(normalized)) { + throw new Error("Artifact path must be a relative path inside the artifact root"); + } + const segments = normalized.split("/").filter(Boolean); + if (segments.length === 0 || segments.some((segment) => segment === "." || segment === "..")) { + throw new Error("Artifact path must be a relative path without current-directory or parent-directory segments"); + } + return segments.join("/"); +} +export function resolveArtifactPath(root, path) { + const absoluteRoot = resolve(root); + const relativePath = safeArtifactRelativePath(path); + const absolutePath = resolve(absoluteRoot, relativePath); + if (!isPathInside(absoluteRoot, absolutePath)) { + throw new Error(`Artifact path must stay inside the artifact root: ${path}`); + } + return { root: absoluteRoot, relativePath, absolutePath }; +} +function isPathInside(root, path) { + const relativePath = relative(root, path); + return relativePath === "" || (!relativePath.startsWith("..") && !isAbsolute(relativePath)); +} +//# sourceMappingURL=artifact-paths.js.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-paths.js.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-paths.js.map new file mode 100644 index 000000000..e69d18c07 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-paths.js.map @@ -0,0 +1 @@ +{"version":3,"file":"artifact-paths.js","sourceRoot":"","sources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AAED,SAAS,YAAY,CAAC,IAAY,EAAE,IAAY;IAC9C,MAAM,YAAY,GAAG,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IACzC,OAAO,YAAY,KAAK,EAAE,IAAI,CAAC,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAA;AAC7F,CAAC"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-references.d.ts b/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-references.d.ts new file mode 100644 index 000000000..f7e7f485d --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-references.d.ts @@ -0,0 +1,126 @@ +import type { ArtifactBundle, RuntimeEpisodeContentDigest, RuntimeEpisodeTraceRef } from "./runtime-contracts.js"; +import type { ArtifactFileDigest, ArtifactManifestFile, ArtifactViewerMetadata } from "./artifact-manifest.js"; +import type { RuntimeReferenceManifestArtifactBundleRef, RuntimeReferenceManifestFileRef } from "./runtime-reference.js"; +import { BROWSER_SESSION_PRODUCT_DTO_SCHEMA, type RuntimeAccess } from "./runtime-boundary-contracts.js"; +export declare const METADATA_ARTIFACT_PATH: "metadata.json"; +export declare const REVIEW_ARTIFACT_PATH: "files/review.json"; +export declare const RUNTIME_EPISODE_TRACE_ARTIFACT_PATH: "files/runtime-episode-trace.json"; +export declare const RUNTIME_EPISODE_EVENTS_ARTIFACT_PATH: "files/runtime-episode.jsonl"; +export declare const RUNTIME_REFERENCE_MANIFEST_ARTIFACT_PATH: "files/runtime-reference-manifest.json"; +export declare const RUNTIME_REPLAY_REFERENCE_INDEX_ARTIFACT_PATH: "files/runtime-replay-index.json"; +export declare const RUNTIME_SNAPSHOT_ARTIFACT_PATH: "files/runtime-snapshot.json"; +export declare const CHANGED_FILES_ARTIFACT_PATH: "files/changed-files.json"; +export declare const PATCH_ARTIFACT_PATH: "files/patch.diff"; +export declare const ARTIFACT_MANIFEST_PATH: "manifest.json"; +export declare const PUBLIC_ARTIFACT_REF_DTO_SCHEMA: "wp-codebox/artifact-ref/v1"; +export interface ArtifactReferenceDigestInput { + algorithm?: string; + value?: string; + sha256?: string | ArtifactReferenceDigestInput; + digest?: string | ArtifactReferenceDigestInput; +} +export interface ArtifactReferenceFileInput { + path?: string; + kind?: string; + contentType?: string; + content_type?: string; + mimeType?: string; + mime?: string; + sha256?: string | ArtifactReferenceDigestInput; + digest?: string | ArtifactReferenceDigestInput; + viewer?: ArtifactViewerMetadata; +} +export interface ArtifactReferenceTraceInput extends ArtifactReferenceFileInput { + id?: string; + artifactId?: string; +} +export interface NormalizeRuntimeEpisodeTraceRefDefaults { + kind?: RuntimeEpisodeTraceRef["kind"]; + id?: string; + artifactId?: string; + path?: string; + digest?: string | ArtifactReferenceDigestInput; +} +export interface BrowserArtifactSummaryRef { + probeIndex: number; + field: string; + kind: string; + path: string; + contentType?: string; +} +export interface PublicArtifactRefDTO { + schema: typeof PUBLIC_ARTIFACT_REF_DTO_SCHEMA; + kind: string; + id?: string; + path?: string; + url?: string; + contentType?: string; + sha256?: string; + digest?: RuntimeEpisodeContentDigest; + size_bytes?: number; + label?: string; + metadata?: Record; +} +export interface PublicArtifactRefGroups { + all: PublicArtifactRefDTO[]; + artifact_bundles: PublicArtifactRefDTO[]; + changed_files: PublicArtifactRefDTO[]; + patches: PublicArtifactRefDTO[]; + browser: PublicArtifactRefDTO[]; + logs: PublicArtifactRefDTO[]; + transcripts: PublicArtifactRefDTO[]; +} +export interface BrowserSessionProductDTO { + schema: typeof BROWSER_SESSION_PRODUCT_DTO_SCHEMA; + source_schema?: string; + success: boolean; + status?: string; + execution?: string; + execution_scope?: string; + permission_model?: string; + session_id?: string; + contained_site?: Record; + task?: string; + target?: Record; + agent?: string; + provider?: string; + model?: string; + preview_boot?: Record; + runtime_access?: RuntimeAccess; + signals?: Record; + artifacts?: Record; + artifact_refs: PublicArtifactRefGroups; + error?: Record; +} +type BrowserArtifactProbeSummary = Record; +export declare function normalizeArtifactDigest(input: string | ArtifactReferenceDigestInput | undefined): RuntimeEpisodeContentDigest | undefined; +export declare function normalizeArtifactFileDigest(input: string | ArtifactReferenceDigestInput | undefined): ArtifactFileDigest | undefined; +export declare function normalizePublicArtifactRefDTO(input: unknown, defaults?: Partial): PublicArtifactRefDTO | undefined; +export declare function normalizePublicArtifactRefDTOs(input: unknown): PublicArtifactRefDTO[]; +export declare function publicArtifactRefGroups(input: unknown): PublicArtifactRefGroups; +export declare function changedFilesArtifactRefs(input: unknown): PublicArtifactRefDTO[]; +export declare function patchArtifactRefs(input: unknown): PublicArtifactRefDTO[]; +export declare function findChangedFilesArtifactRef(input: unknown): PublicArtifactRefDTO | undefined; +export declare function findPatchArtifactRef(input: unknown): PublicArtifactRefDTO | undefined; +export declare function normalizeBrowserSessionProductDTO(input: unknown): BrowserSessionProductDTO; +export declare function normalizeArtifactContentType(input: ArtifactReferenceFileInput | undefined, fallback?: string): string; +export declare function normalizeRuntimeReferenceManifestFileRef(input: ArtifactReferenceFileInput | ArtifactManifestFile): RuntimeReferenceManifestFileRef | undefined; +export declare function normalizeRuntimeReferenceManifestFileRefs(inputs: Array): RuntimeReferenceManifestFileRef[]; +export declare function runtimeReferenceManifestArtifactFiles(files: ArtifactManifestFile[]): ArtifactManifestFile[]; +export declare function runtimeReplayReferenceIndexArtifactFiles(files: ArtifactManifestFile[]): ArtifactManifestFile[]; +export declare function normalizeRuntimeEpisodeTraceRef(input: ArtifactReferenceTraceInput, defaults?: NormalizeRuntimeEpisodeTraceRefDefaults): RuntimeEpisodeTraceRef | undefined; +export declare function normalizeRuntimeEpisodeTraceRefs(inputs: ArtifactReferenceTraceInput[], defaults?: NormalizeRuntimeEpisodeTraceRefDefaults): RuntimeEpisodeTraceRef[]; +export declare function normalizeObservationArtifactRefs(input: { + artifactRefs?: ArtifactReferenceTraceInput[]; +} | ArtifactReferenceTraceInput[] | undefined): RuntimeEpisodeTraceRef[]; +export declare function normalizeArtifactBundleTraceRef(bundle: Pick | undefined): RuntimeEpisodeTraceRef | undefined; +export declare function normalizeRuntimeReferenceArtifactBundleRef(input: { + id?: string; + digest?: string | ArtifactReferenceDigestInput; + contentDigest?: string | ArtifactReferenceDigestInput; +} | Pick): RuntimeReferenceManifestArtifactBundleRef | undefined; +export declare function normalizeBrowserArtifactSummaryRefs(summary: { + probes?: BrowserArtifactProbeSummary[]; +} | undefined): BrowserArtifactSummaryRef[]; +export {}; +//# sourceMappingURL=artifact-references.d.ts.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-references.d.ts.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-references.d.ts.map new file mode 100644 index 000000000..372fcec1b --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-references.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"artifact-references.d.ts","sourceRoot":"","sources":["../src/artifact-references.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,2BAA2B,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AACjH,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAC9G,OAAO,KAAK,EAAE,yCAAyC,EAAE,+BAA+B,EAAE,MAAM,wBAAwB,CAAA;AAExH,OAAO,EAAE,kCAAkC,EAA0B,KAAK,aAAa,EAAE,MAAM,iCAAiC,CAAA;AAEhI,eAAO,MAAM,sBAAsB,EAAG,eAAwB,CAAA;AAC9D,eAAO,MAAM,oBAAoB,EAAG,mBAA4B,CAAA;AAChE,eAAO,MAAM,mCAAmC,EAAG,kCAA2C,CAAA;AAC9F,eAAO,MAAM,oCAAoC,EAAG,6BAAsC,CAAA;AAC1F,eAAO,MAAM,wCAAwC,EAAG,uCAAgD,CAAA;AACxG,eAAO,MAAM,4CAA4C,EAAG,iCAA0C,CAAA;AACtG,eAAO,MAAM,8BAA8B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BAAsB,GAAG,SAAS,CAYlK;AAED,wBAAgB,0CAA0C,CAAC,KAAK,EAAE;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,GAAG,4BAA4B,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,GAAG,4BAA4B,CAAA;CAAE,GAAG,IAAI,CAAC,cAAc,EAAE,IAAI,GAAG,eAAe,CAAC,GAAG,yCAAyC,GAAG,SAAS,CAW9R;AAED,wBAAgB,mCAAmC,CAAC,OAAO,EAAE;IAAE,MAAM,CAAC,EAAE,2BAA2B,EAAE,CAAA;CAAE,GAAG,SAAS,GAAG,yBAAyB,EAAE,CAahJ"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-references.js b/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-references.js new file mode 100644 index 000000000..ada44b772 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-references.js @@ -0,0 +1,407 @@ +import { redactJsonValue } from "./redaction.js"; +import { BROWSER_SESSION_PRODUCT_DTO_SCHEMA, normalizeRuntimeAccess } from "./runtime-boundary-contracts.js"; +export const METADATA_ARTIFACT_PATH = "metadata.json"; +export const REVIEW_ARTIFACT_PATH = "files/review.json"; +export const RUNTIME_EPISODE_TRACE_ARTIFACT_PATH = "files/runtime-episode-trace.json"; +export const RUNTIME_EPISODE_EVENTS_ARTIFACT_PATH = "files/runtime-episode.jsonl"; +export const RUNTIME_REFERENCE_MANIFEST_ARTIFACT_PATH = "files/runtime-reference-manifest.json"; +export const RUNTIME_REPLAY_REFERENCE_INDEX_ARTIFACT_PATH = "files/runtime-replay-index.json"; +export const RUNTIME_SNAPSHOT_ARTIFACT_PATH = "files/runtime-snapshot.json"; +export const CHANGED_FILES_ARTIFACT_PATH = "files/changed-files.json"; +export const PATCH_ARTIFACT_PATH = "files/patch.diff"; +export const ARTIFACT_MANIFEST_PATH = "manifest.json"; +export const PUBLIC_ARTIFACT_REF_DTO_SCHEMA = "wp-codebox/artifact-ref/v1"; +const RUNTIME_REFERENCE_MANIFEST_EXCLUDED_PATHS = new Set([ + ARTIFACT_MANIFEST_PATH, + METADATA_ARTIFACT_PATH, + REVIEW_ARTIFACT_PATH, + RUNTIME_REFERENCE_MANIFEST_ARTIFACT_PATH, + RUNTIME_REPLAY_REFERENCE_INDEX_ARTIFACT_PATH, +]); +const RUNTIME_REPLAY_REFERENCE_INDEX_EXCLUDED_PATHS = new Set([ + ARTIFACT_MANIFEST_PATH, + RUNTIME_REPLAY_REFERENCE_INDEX_ARTIFACT_PATH, +]); +const BROWSER_ARTIFACT_SUMMARY_FIELDS = { + actions: { kind: "browser-actions", contentType: "application/x-ndjson" }, + checkpoints: { kind: "browser-checkpoints", contentType: "application/x-ndjson" }, + console: { kind: "browser-console", contentType: "application/x-ndjson" }, + errorsFile: { kind: "browser-errors", contentType: "application/x-ndjson" }, + html: { kind: "browser-html-snapshot", contentType: "text/html; charset=utf-8" }, + memory: { kind: "browser-memory", contentType: "application/json" }, + network: { kind: "browser-network", contentType: "application/x-ndjson" }, + performance: { kind: "browser-performance", contentType: "application/json" }, + screenshot: { kind: "browser-screenshot", contentType: "image/png" }, + steps: { kind: "browser-steps", contentType: "application/x-ndjson" }, + summaryFile: { kind: "browser-summary", contentType: "application/json" }, +}; +export function normalizeArtifactDigest(input) { + if (typeof input === "string" && input.length > 0) { + return { algorithm: "sha256", value: input }; + } + if (!input || typeof input !== "object") { + return undefined; + } + if (input.algorithm === "sha256" && typeof input.value === "string" && input.value.length > 0) { + return { algorithm: "sha256", value: input.value }; + } + return normalizeArtifactDigest(input.sha256) + ?? normalizeArtifactDigest(input.digest); +} +export function normalizeArtifactFileDigest(input) { + return normalizeArtifactDigest(input); +} +export function normalizePublicArtifactRefDTO(input, defaults = {}) { + const record = asRecord(input); + if (!record) { + return undefined; + } + const digest = normalizeArtifactDigest(record.digest) + ?? normalizeArtifactDigest(record.sha256) + ?? defaults.digest; + const path = stringValue(record.path) + || defaults.path; + const kind = stringValue(record.kind) || defaults.kind || kindForArtifactPath(path) || "artifact"; + const sha256 = stringValue(record.sha256) || digest?.value || defaults.sha256; + const metadata = asRecord(record.metadata); + return stripUndefined({ + schema: PUBLIC_ARTIFACT_REF_DTO_SCHEMA, + kind, + id: stringValue(record.id) || defaults.id, + path, + url: stringValue(record.url) || defaults.url, + contentType: normalizeArtifactContentType(record, defaults.contentType), + sha256, + digest, + size_bytes: numberValue(record.size_bytes) ?? defaults.size_bytes, + label: stringValue(record.label) || defaults.label, + metadata: metadata && Object.keys(metadata).length > 0 ? metadata : defaults.metadata, + }); +} +export function normalizePublicArtifactRefDTOs(input) { + return uniquePublicArtifactRefs(collectArtifactRefCandidates(input) + .map(({ value, defaults }) => normalizePublicArtifactRefDTO(value, defaults)) + .filter((ref) => ref !== undefined)); +} +export function publicArtifactRefGroups(input) { + const all = normalizePublicArtifactRefDTOs(input); + return { + all, + artifact_bundles: all.filter(isArtifactBundleRef), + changed_files: all.filter(isChangedFilesArtifactRef), + patches: all.filter(isPatchArtifactRef), + browser: all.filter((ref) => ref.kind.startsWith("browser-") || pathIncludes(ref.path, "/browser/")), + logs: all.filter((ref) => ref.kind.includes("log") || pathEndsWith(ref.path, ".log") || pathEndsWith(ref.path, ".jsonl")), + transcripts: all.filter((ref) => ref.kind.includes("transcript")), + }; +} +export function changedFilesArtifactRefs(input) { + return publicArtifactRefGroups(input).changed_files; +} +export function patchArtifactRefs(input) { + return publicArtifactRefGroups(input).patches; +} +export function findChangedFilesArtifactRef(input) { + return changedFilesArtifactRefs(input)[0]; +} +export function findPatchArtifactRef(input) { + return patchArtifactRefs(input)[0]; +} +export function normalizeBrowserSessionProductDTO(input) { + const session = asRecord(input) ?? {}; + const sessionEnvelope = asRecord(session.session) ?? {}; + const taskInput = asRecord(session.task_input) ?? {}; + return stripUndefined({ + schema: BROWSER_SESSION_PRODUCT_DTO_SCHEMA, + source_schema: stringValue(session.schema), + success: session.success === true, + status: stringValue(session.status) || (session.success === true ? "ready" : undefined), + execution: stringValue(session.execution), + execution_scope: stringValue(session.execution_scope), + permission_model: stringValue(session.permission_model), + session_id: stringValue(sessionEnvelope.id) || stringValue(session.session_id), + contained_site: publicSessionRecord(session.contained_site), + task: stringValue(session.task) || stringValue(taskInput.goal), + target: publicSessionRecord(taskInput.target), + agent: stringValue(session.agent), + provider: stringValue(session.provider), + model: stringValue(session.model), + preview_boot: publicSessionRecord(session.preview_boot), + runtime_access: browserSessionRuntimeAccess(session), + signals: publicSessionRecord(session.signals), + artifacts: publicSessionRecord(session.artifacts), + artifact_refs: publicArtifactRefGroups(session), + error: publicSessionRecord(session.error), + }); +} +function browserSessionRuntimeAccess(session) { + const explicit = asRecord(session.runtime_access); + if (explicit) { + try { + return normalizeRuntimeAccess(explicit); + } + catch { + return undefined; + } + } + const previewBoot = asRecord(session.preview_boot); + const preview = asRecord(previewBoot?.preview); + if (!preview) + return undefined; + const reviewerAccess = asRecord(preview.reviewer_access) ?? asRecord(preview.reviewerAccess); + const reviewerUrl = stringValue(reviewerAccess?.openUrl) || stringValue(reviewerAccess?.targetUrl); + const publicUrl = stringValue(preview.public_url ?? preview.publicUrl ?? preview.preview_public_url ?? preview.previewPublicUrl); + const siteUrl = stringValue(preview.site_url ?? preview.siteUrl); + const directPreviewUrl = stringValue(preview.preview_url ?? preview.previewUrl); + const fallbackPreviewUrl = directPreviewUrl || (publicUrl || siteUrl || reviewerUrl ? "" : stringValue(preview.url)); + try { + return normalizeRuntimeAccess({ + preview_url: fallbackPreviewUrl, + public_url: publicUrl, + site_url: siteUrl, + local_url: preview.local_url ?? preview.localUrl, + lease: preview.schema === "wp-codebox/preview-lease/v1" ? preview : undefined, + reviewer_access: reviewerAccess, + }); + } + catch { + return undefined; + } +} +export function normalizeArtifactContentType(input, fallback = "application/octet-stream") { + const contentType = input?.contentType ?? input?.content_type ?? input?.mimeType ?? input?.mime; + return typeof contentType === "string" && contentType.trim().length > 0 ? contentType : fallback; +} +export function normalizeRuntimeReferenceManifestFileRef(input) { + if (!input.path || !input.kind) { + return undefined; + } + const sha256 = normalizeArtifactFileDigest(input.sha256 ?? ("digest" in input ? input.digest : undefined)); + if (!sha256) { + return undefined; + } + return { + path: input.path, + kind: input.kind, + contentType: normalizeArtifactContentType(input), + sha256, + ...(input.viewer ? { viewer: input.viewer } : {}), + }; +} +export function normalizeRuntimeReferenceManifestFileRefs(inputs) { + return inputs + .map((input) => normalizeRuntimeReferenceManifestFileRef(input)) + .filter((ref) => ref !== undefined); +} +export function runtimeReferenceManifestArtifactFiles(files) { + return files.filter((file) => !RUNTIME_REFERENCE_MANIFEST_EXCLUDED_PATHS.has(file.path)); +} +export function runtimeReplayReferenceIndexArtifactFiles(files) { + return files.filter((file) => !RUNTIME_REPLAY_REFERENCE_INDEX_EXCLUDED_PATHS.has(file.path)); +} +export function normalizeRuntimeEpisodeTraceRef(input, defaults = {}) { + const kind = input.kind ?? defaults.kind; + const id = input.id ?? defaults.id ?? input.artifactId ?? defaults.artifactId ?? input.path ?? defaults.path; + if (!kind || !id) { + return undefined; + } + const digest = normalizeArtifactDigest(input.digest ?? input.sha256 ?? defaults.digest); + return stripUndefined({ + kind, + id, + artifactId: input.artifactId ?? defaults.artifactId, + path: input.path ?? defaults.path, + digest, + }); +} +export function normalizeRuntimeEpisodeTraceRefs(inputs, defaults = {}) { + return inputs + .map((input) => normalizeRuntimeEpisodeTraceRef(input, defaults)) + .filter((ref) => ref !== undefined); +} +export function normalizeObservationArtifactRefs(input) { + const refs = Array.isArray(input) ? input : input?.artifactRefs; + return normalizeRuntimeEpisodeTraceRefs(refs ?? []); +} +export function normalizeArtifactBundleTraceRef(bundle) { + if (!bundle) { + return undefined; + } + return normalizeRuntimeEpisodeTraceRef({ + kind: "artifact-bundle", + id: bundle.id, + artifactId: bundle.id, + path: bundle.directory, + digest: bundle.contentDigest, + }); +} +export function normalizeRuntimeReferenceArtifactBundleRef(input) { + if (!input.id) { + return undefined; + } + const digest = normalizeArtifactFileDigest("contentDigest" in input ? input.contentDigest : input.digest); + if (!digest) { + return undefined; + } + return { kind: "artifact-bundle", id: input.id, digest }; +} +export function normalizeBrowserArtifactSummaryRefs(summary) { + const probes = Array.isArray(summary?.probes) ? summary.probes : []; + const refs = []; + for (const [probeIndex, probe] of probes.entries()) { + for (const [field, metadata] of Object.entries(BROWSER_ARTIFACT_SUMMARY_FIELDS)) { + const path = probe[field]; + if (typeof path === "string" && path.length > 0) { + refs.push(stripUndefined({ probeIndex, field, path, kind: metadata.kind, contentType: metadata.contentType })); + } + } + } + return refs; +} +function collectArtifactRefCandidates(input) { + if (Array.isArray(input)) { + return input.map((value) => ({ value })); + } + const record = asRecord(input); + if (!record) { + return []; + } + const candidates = []; + appendArtifactRefArrayCandidates(candidates, record.artifactRefs); + appendArtifactRefArrayCandidates(candidates, record.artifact_refs); + appendArtifactRefArrayCandidates(candidates, record.artifacts); + const refs = asRecord(record.refs); + appendArtifactRefArrayCandidates(candidates, refs?.artifact_bundles); + appendArtifactRefArrayCandidates(candidates, refs?.changed_files); + appendArtifactRefArrayCandidates(candidates, refs?.patches); + appendArtifactRefArrayCandidates(candidates, refs?.logs); + appendArtifactRefArrayCandidates(candidates, refs?.transcripts); + appendArtifactRefArrayCandidates(candidates, refs?.screenshots); + appendArtifactRefArrayCandidates(candidates, refs?.probe_json); + appendArtifactRefCandidate(candidates, record.artifactBundle ?? record.artifact_bundle ?? record.artifact_ref, { kind: "artifact-bundle" }); + appendPathCandidate(candidates, record.directory ?? record.artifacts_path, "codebox-artifact-bundle"); + appendPathCandidate(candidates, record.changedFilesPath ?? record.changed_files_path, "codebox-changed-files"); + appendPathCandidate(candidates, record.patchPath ?? record.patch_path, "codebox-patch"); + const artifacts = asRecord(record.artifacts); + if (artifacts) { + appendPathCandidate(candidates, artifacts.directory ?? artifacts.path, "codebox-artifact-bundle"); + appendPathCandidate(candidates, artifacts.changedFilesPath ?? artifacts.changed_files_path, "codebox-changed-files"); + appendPathCandidate(candidates, artifacts.patchPath ?? artifacts.patch_path, "codebox-patch"); + } + const result = asRecord(record.result); + if (result && result !== record) { + candidates.push(...collectArtifactRefCandidates(result)); + } + const agentTaskRunResult = asRecord(record.agent_task_run_result); + if (agentTaskRunResult) { + candidates.push(...collectArtifactRefCandidates(agentTaskRunResult)); + } + return candidates; +} +function appendArtifactRefArrayCandidates(candidates, value) { + if (!Array.isArray(value)) { + return; + } + for (const item of value) { + appendArtifactRefCandidate(candidates, item); + } +} +function appendArtifactRefCandidate(candidates, value, defaults) { + if (value !== undefined && value !== null) { + candidates.push({ value, defaults }); + } +} +function appendPathCandidate(candidates, value, kind) { + const path = stringValue(value); + if (path) { + candidates.push({ value: { path, kind }, defaults: { kind } }); + } +} +function uniquePublicArtifactRefs(refs) { + const seen = new Map(); + const normalized = []; + for (const ref of refs) { + const key = `${ref.kind}:${ref.id ?? ""}:${ref.path ?? ""}`; + const existingIndex = seen.get(key); + if (existingIndex !== undefined) { + normalized[existingIndex] = richerPublicArtifactRef(normalized[existingIndex], ref); + continue; + } + seen.set(key, normalized.length); + normalized.push(ref); + } + return normalized; +} +function richerPublicArtifactRef(existing, incoming) { + return stripUndefined({ + ...existing, + ...incoming, + digest: incoming.digest ?? existing.digest, + sha256: incoming.sha256 ?? existing.sha256, + metadata: existing.metadata && incoming.metadata ? { ...existing.metadata, ...incoming.metadata } : incoming.metadata ?? existing.metadata, + }); +} +function isArtifactBundleRef(ref) { + return ref.kind === "artifact-bundle" || ref.kind === "codebox-artifact-bundle"; +} +function isChangedFilesArtifactRef(ref) { + return ref.kind === "codebox-changed-files" || ref.kind === "changed-files" || pathEndsWith(ref.path, CHANGED_FILES_ARTIFACT_PATH); +} +function isPatchArtifactRef(ref) { + return ref.kind === "codebox-patch" || ref.kind === "patch" || pathEndsWith(ref.path, PATCH_ARTIFACT_PATH); +} +function kindForArtifactPath(path) { + if (pathEndsWith(path, CHANGED_FILES_ARTIFACT_PATH)) + return "codebox-changed-files"; + if (pathEndsWith(path, PATCH_ARTIFACT_PATH)) + return "codebox-patch"; + if (pathEndsWith(path, ARTIFACT_MANIFEST_PATH)) + return "artifact-manifest"; + return undefined; +} +function pathEndsWith(path, suffix) { + return typeof path === "string" && (path === suffix || path.endsWith(`/${suffix}`)); +} +function pathIncludes(path, fragment) { + return typeof path === "string" && path.includes(fragment); +} +function publicSessionRecord(value) { + const record = asRecord(value); + if (!record) { + return undefined; + } + return asRecord(compactPublicSessionValue(record)); +} +function compactPublicSessionValue(value, key = "") { + if (PUBLIC_SESSION_OMITTED_KEYS.has(key)) { + return undefined; + } + if (Array.isArray(value)) { + return value.map((item) => compactPublicSessionValue(item)).filter((item) => item !== undefined); + } + if (value && typeof value === "object") { + const compact = {}; + for (const [childKey, childValue] of Object.entries(value)) { + const childCompact = compactPublicSessionValue(childValue, childKey); + if (childCompact !== undefined) { + compact[childKey] = childCompact; + } + } + return redactJsonValue(compact, { profile: "public_session_dto" }); + } + return value; +} +const PUBLIC_SESSION_OMITTED_KEYS = new Set(["pluginData", "source", "content", "content_base64", "bundle", "plugins", "runtime"]); +function asRecord(value) { + return value && typeof value === "object" && !Array.isArray(value) ? value : undefined; +} +function stringValue(value) { + return typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined; +} +function numberValue(value) { + return typeof value === "number" && Number.isFinite(value) ? value : undefined; +} +function stripUndefined(value) { + return Object.fromEntries(Object.entries(value).filter(([, item]) => item !== undefined)); +} +//# sourceMappingURL=artifact-references.js.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-references.js.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-references.js.map new file mode 100644 index 000000000..2a334beea --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/artifact-references.js.map @@ -0,0 +1 @@ +{"version":3,"file":"artifact-references.js","sourceRoot":"","sources":["../src/artifact-references.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAA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CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAED,MAAM,2BAA2B,GAAG,IAAI,GAAG,CAAC,CAAC,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,gBAAgB,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAA;AAElI,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAgC,CAAC,CAAC,CAAC,SAAS,CAAA;AACnH,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AACxF,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAA;AAChF,CAAC;AAED,SAAS,cAAc,CAAmB,KAAQ;IAChD,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,CAAM,CAAA;AAChG,CAAC"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/browser-interaction.d.ts b/packages/runtime-cloudflare/vendor/wp-codebox-core/browser-interaction.d.ts new file mode 100644 index 000000000..e7c973f42 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/browser-interaction.d.ts @@ -0,0 +1,225 @@ +import type { JsonValue } from "./host-tool-registry.js"; +export declare const BROWSER_INTERACTION_SCRIPT_SCHEMA: "wp-codebox/browser-interaction-script/v1"; +export declare const BROWSER_TOOL_VERIFIER_RESULT_SCHEMA: "wp-codebox/browser-tool-verifier-result/v1"; +/** + * Backend-agnostic browser interaction step contract (issue #310). + * + * runtime-core declares the schema; a runtime backend (e.g. runtime-playground) + * implements the executor that maps each step onto its driver. Steps are a thin, + * stable mapping over locator-style actions — not a test-runner DSL. + * + * Layer purity: this type knows nothing about Playwright or Playground. It is the + * shared contract any backend can satisfy. + */ +export declare const BROWSER_INTERACTION_STEP_KINDS: readonly ["navigate", "click", "fill", "type", "press", "drag", "hover", "select", "waitFor", "evaluate", "expect", "assertObservation", "screenshot", "capture", "callTool"]; +export type BrowserInteractionStepKind = typeof BROWSER_INTERACTION_STEP_KINDS[number]; +export declare const BROWSER_RANDOM_WALK_SCHEMA: "wp-codebox/browser-random-walk/v1"; +export declare const BROWSER_ACTION_CORPUS_SCHEMA: "wp-codebox/browser-action-corpus/v1"; +export declare const BROWSER_ACTION_CORPUS_ARTIFACT_SCHEMA: "wp-codebox/browser-action-corpus-artifact/v1"; +export declare const BROWSER_RANDOM_WALK_CONTEXTS: readonly ["browser", "admin", "editor"]; +export type BrowserRandomWalkContext = typeof BROWSER_RANDOM_WALK_CONTEXTS[number]; +export declare const BROWSER_RANDOM_WALK_ACTION_FAMILIES: readonly ["click", "fill", "press", "select", "navigate", "capture"]; +export type BrowserRandomWalkActionFamily = typeof BROWSER_RANDOM_WALK_ACTION_FAMILIES[number]; +/** Locator/element state checked by an `expect` step. */ +export declare const BROWSER_INTERACTION_EXPECT_STATES: readonly ["visible", "hidden", "attached", "detached", "enabled", "disabled", "checked", "unchecked", "editable"]; +export type BrowserInteractionExpectState = typeof BROWSER_INTERACTION_EXPECT_STATES[number]; +/** Drop target for a `drag` step: an element selector or absolute viewport coordinates. */ +export type BrowserInteractionDragTarget = { + selector: string; +} | { + x: number; + y: number; +}; +export interface BrowserInteractionStep { + kind: BrowserInteractionStepKind; + /** Stable locator string (CSS, `text=`, `role=button[name='...']`, etc.). */ + selector?: string; + /** Navigation target for `navigate`. */ + url?: string; + /** Visible-text locator shortcut for `click`/`hover`. */ + text?: string; + /** Input value for `fill`/`type`, or option value for `select`. */ + value?: string; + /** Keyboard key for `press`. */ + key?: string; + /** Wait/load condition: domcontentloaded|load|networkidle|selector:|duration|painted|frame-painted:|frame-url-painted:. */ + waitFor?: string; + /** Drag source selector for `drag`. */ + from?: string; + /** Drag drop target for `drag`. */ + to?: BrowserInteractionDragTarget; + /** Option label/value(s) for `select`. */ + values?: string[]; + /** Arbitrary page JS for `evaluate` (policy-gated separately). */ + expression?: string; + /** Optional expected value an `evaluate` result must deep-equal to assert. */ + assert?: unknown; + /** Observation assertion for captured browser runtime evidence. */ + assertion?: string; + /** Expected locator state for `expect`. */ + state?: BrowserInteractionExpectState; + /** Optional screenshot name for `screenshot`; screenshot steps may also use waitFor for painted-readiness waits before capture. */ + name?: string; + /** Optional iframe selector for `screenshot`; captures the iframe document instead of the top page. */ + frameSelector?: string; + /** Optional iframe URL fragment for `screenshot`; captures the matching iframe document instead of the top page. */ + frameUrl?: string; + /** Optional wait duration (e.g. 500ms, 2s) for `waitFor`/`navigate`. */ + duration?: string; + /** Per-step timeout override (e.g. 5s). */ + timeout?: string; + /** Caller-provided host tool command name for `callTool`. */ + tool?: string; + /** JSON input passed to the caller-provided host tool. */ + input?: JsonValue; +} +export interface BrowserToolVerifierInputSummary { + type: "null" | "boolean" | "number" | "string" | "array" | "object"; + keys?: string[]; + itemCount?: number; +} +export interface BrowserToolVerifierResult { + schema: typeof BROWSER_TOOL_VERIFIER_RESULT_SCHEMA; + status: "unsupported" | "ok" | "error"; + step: { + index: number; + kind: "callTool"; + tool: string; + }; + tool: string; + inputSummary: BrowserToolVerifierInputSummary; + result?: JsonValue; + error?: { + code: string; + message: string; + }; + evidence: { + redaction: { + policy: "required"; + sensitive: true; + reason: string; + }; + rawInputSerialized: false; + rawSecretsSerialized: false; + }; + startedAt: string; + finishedAt: string; +} +export interface BrowserRandomWalkContract { + schema: typeof BROWSER_RANDOM_WALK_SCHEMA; + context: BrowserRandomWalkContext; + seed: string; + maxSteps: number; + actionFamilies: BrowserRandomWalkActionFamily[]; + startUrl?: string; + resetPolicy?: Record; + metadata?: Record; +} +export interface BrowserRandomWalkPlan { + schema: typeof BROWSER_RANDOM_WALK_SCHEMA; + status: "planned" | "unsupported"; + context: BrowserRandomWalkContext; + seed: string; + maxSteps: number; + actionFamilies: BrowserRandomWalkActionFamily[]; + steps: BrowserInteractionStep[]; + replay: Record; + diagnostics: { + code: string; + message: string; + metadata?: Record; + }[]; +} +export declare const BROWSER_ACTION_CORPUS_GENERATOR_KINDS: readonly ["text", "email", "url", "search", "number", "password", "textarea", "checkbox", "radio", "select"]; +export type BrowserActionCorpusGeneratorKind = typeof BROWSER_ACTION_CORPUS_GENERATOR_KINDS[number]; +export type BrowserActionCorpusDescriptorKind = "link" | "button" | "input" | "textarea" | "select"; +export interface BrowserActionCorpusDescriptor { + id: string; + kind: BrowserActionCorpusDescriptorKind; + selector: string; + label?: string; + name?: string; + role?: string; + type?: string; + formId?: string; + href?: string; + optionValues?: string[]; + disabled?: boolean; + readonly?: boolean; + /** Adaptive exploration frame identity. Omitted for the main document and one-shot corpus discovery. */ + frameId?: string; +} +export interface BrowserActionCorpusContract { + schema: typeof BROWSER_ACTION_CORPUS_SCHEMA; + context: BrowserRandomWalkContext; + seed: string; + maxSteps: number; + startUrl?: string; + includeFamilies: BrowserRandomWalkActionFamily[]; + generatorPrefix: string; + metadata?: Record; +} +export interface BrowserActionCorpusPlan { + schema: typeof BROWSER_ACTION_CORPUS_SCHEMA; + status: "planned" | "empty"; + context: BrowserRandomWalkContext; + seed: string; + maxSteps: number; + startUrl?: string; + descriptors: BrowserActionCorpusDescriptor[]; + steps: BrowserInteractionStep[]; + replay: { + schema: typeof BROWSER_ACTION_CORPUS_SCHEMA; + seed: string; + maxSteps: number; + context: BrowserRandomWalkContext; + startUrl?: string; + descriptorIds: string[]; + steps: BrowserInteractionStep[]; + }; + observations: { + descriptorsDiscovered: number; + descriptorsSelected: number; + stepsPlanned: number; + fillSteps: number; + clickSteps: number; + selectSteps: number; + }; + diagnostics: { + code: string; + message: string; + metadata?: Record; + }[]; +} +export interface BrowserActionCorpusArtifact { + schema: typeof BROWSER_ACTION_CORPUS_ARTIFACT_SCHEMA; + contract: BrowserActionCorpusContract; + plan: BrowserActionCorpusPlan; + capturedAt: string; +} +export interface BrowserInteractionStepValidationIssue { + index: number; + message: string; +} +export interface BrowserInteractionScriptValidationResult { + valid: boolean; + steps: BrowserInteractionStep[]; + issues: BrowserInteractionStepValidationIssue[]; +} +export declare function browserToolVerifierInputSummary(input: JsonValue): BrowserToolVerifierInputSummary; +/** + * Validate an ordered browser interaction script against the backend-agnostic + * step contract. Returns normalized steps plus per-index issues; backends call + * this before executing so every backend enforces the same contract. + */ +export declare function validateBrowserInteractionScript(input: unknown): BrowserInteractionScriptValidationResult; +/** True when an interaction script contains at least one policy-gated evaluate step. */ +export declare function browserInteractionScriptUsesEvaluate(steps: readonly BrowserInteractionStep[]): boolean; +/** Exact caller-provided tool command names referenced by `callTool` steps. */ +export declare function browserInteractionScriptToolCalls(steps: readonly BrowserInteractionStep[]): string[]; +export declare function browserRandomWalkContract(input: Record): BrowserRandomWalkContract; +export declare function planBrowserRandomWalk(input: Record): BrowserRandomWalkPlan; +export declare function browserActionCorpusContract(input: Record): BrowserActionCorpusContract; +export declare function planBrowserActionCorpus(contractInput: Record | BrowserActionCorpusContract, descriptorsInput: readonly BrowserActionCorpusDescriptor[]): BrowserActionCorpusPlan; +export declare function browserActionCorpusArtifact(contractInput: Record | BrowserActionCorpusContract, descriptors: readonly BrowserActionCorpusDescriptor[], capturedAt: string): BrowserActionCorpusArtifact; +//# sourceMappingURL=browser-interaction.d.ts.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/browser-interaction.d.ts.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/browser-interaction.d.ts.map new file mode 100644 index 000000000..63a19e312 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/browser-interaction.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"browser-interaction.d.ts","sourceRoot":"","sources":["../src/browser-interaction.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAExD,eAAO,MAAM,iCAAiC,EAAG,0CAAmD,CAAA;AACpG,eAAO,MAAM,mCAAmC,EAAG,4CAAqD,CAAA;AAExG;;;;;;;;;GASG;AACH,eAAO,MAAM,8BAA8B,+KAgBjC,CAAA;AAEV,MAAM,MAAM,0BAA0B,GAAG,OAAO,8BAA8B,CAAC,MAAM,CAAC,CAAA;AAEtF,eAAO,MAAM,0BAA0B,EAAG,mCAA4C,CAAA;AACtF,eAAO,MAAM,4BAA4B,EAAG,qCAA8C,CAAA;AAC1F,eAAO,MAAM,qCAAqC,EAAG,8CAAuD,CAAA;AAE5G,eAAO,MAAM,4BAA4B,yCAA0C,CAAA;AACnF,MAAM,MAAM,wBAAwB,GAAG,OAAO,4BAA4B,CAAC,MAAM,CAAC,CAAA;AAElF,eAAO,MAAM,mCAAmC,sEAAuE,CAAA;AACvH,MAAM,MAAM,6BAA6B,GAAG,OAAO,mCAAmC,CAAC,MAAM,CAAC,CAAA;AAE9F,yDAAyD;AACzD,eAAO,MAAM,iCAAiC,mHAAoH,CAAA;AAElK,MAAM,MAAM,6BAA6B,GAAG,OAAO,iCAAiC,CAAC,MAAM,CAAC,CAAA;AAE5F,2FAA2F;AAC3F,MAAM,MAAM,4BAA4B,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAE1F,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,0BAA0B,CAAA;IAChC,6EAA6E;IAC7E,QAA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E,EAAE,UAAU,EAAE,MAAM,GAAG,2BAA2B,CAQxN"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/browser-interaction.js b/packages/runtime-cloudflare/vendor/wp-codebox-core/browser-interaction.js new file mode 100644 index 000000000..5da6a7745 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/browser-interaction.js @@ -0,0 +1,449 @@ +import { isPlainObject } from "./object-utils.js"; +export const BROWSER_INTERACTION_SCRIPT_SCHEMA = "wp-codebox/browser-interaction-script/v1"; +export const BROWSER_TOOL_VERIFIER_RESULT_SCHEMA = "wp-codebox/browser-tool-verifier-result/v1"; +/** + * Backend-agnostic browser interaction step contract (issue #310). + * + * runtime-core declares the schema; a runtime backend (e.g. runtime-playground) + * implements the executor that maps each step onto its driver. Steps are a thin, + * stable mapping over locator-style actions — not a test-runner DSL. + * + * Layer purity: this type knows nothing about Playwright or Playground. It is the + * shared contract any backend can satisfy. + */ +export const BROWSER_INTERACTION_STEP_KINDS = [ + "navigate", + "click", + "fill", + "type", + "press", + "drag", + "hover", + "select", + "waitFor", + "evaluate", + "expect", + "assertObservation", + "screenshot", + "capture", + "callTool", +]; +export const BROWSER_RANDOM_WALK_SCHEMA = "wp-codebox/browser-random-walk/v1"; +export const BROWSER_ACTION_CORPUS_SCHEMA = "wp-codebox/browser-action-corpus/v1"; +export const BROWSER_ACTION_CORPUS_ARTIFACT_SCHEMA = "wp-codebox/browser-action-corpus-artifact/v1"; +export const BROWSER_RANDOM_WALK_CONTEXTS = ["browser", "admin", "editor"]; +export const BROWSER_RANDOM_WALK_ACTION_FAMILIES = ["click", "fill", "press", "select", "navigate", "capture"]; +/** Locator/element state checked by an `expect` step. */ +export const BROWSER_INTERACTION_EXPECT_STATES = ["visible", "hidden", "attached", "detached", "enabled", "disabled", "checked", "unchecked", "editable"]; +export const BROWSER_ACTION_CORPUS_GENERATOR_KINDS = ["text", "email", "url", "search", "number", "password", "textarea", "checkbox", "radio", "select"]; +function isBrowserInteractionDragTarget(value) { + if (!isPlainObject(value)) + return false; + if (typeof value.selector === "string" && value.selector.length > 0) + return true; + return typeof value.x === "number" && typeof value.y === "number"; +} +export function browserToolVerifierInputSummary(input) { + if (input === null) + return { type: "null" }; + if (Array.isArray(input)) + return { type: "array", itemCount: input.length }; + if (typeof input === "object") + return { type: "object", keys: Object.keys(input).sort() }; + return { type: inputType(input) }; +} +function inputType(input) { + if (typeof input === "string") + return "string"; + if (typeof input === "number") + return "number"; + return "boolean"; +} +/** + * Validate an ordered browser interaction script against the backend-agnostic + * step contract. Returns normalized steps plus per-index issues; backends call + * this before executing so every backend enforces the same contract. + */ +export function validateBrowserInteractionScript(input) { + const issues = []; + const steps = []; + if (!Array.isArray(input)) { + return { valid: false, steps, issues: [{ index: -1, message: "browser interaction script must be a JSON array of steps" }] }; + } + input.forEach((raw, index) => { + if (!isPlainObject(raw)) { + issues.push({ index, message: "step must be an object" }); + return; + } + const kind = raw.kind; + if (typeof kind !== "string" || !BROWSER_INTERACTION_STEP_KINDS.includes(kind)) { + issues.push({ index, message: `step kind must be one of ${BROWSER_INTERACTION_STEP_KINDS.join(", ")}` }); + return; + } + const step = raw; + const hasSelector = typeof step.selector === "string" && step.selector.length > 0; + const hasText = typeof step.text === "string" && step.text.length > 0; + switch (kind) { + case "navigate": + if (typeof step.url !== "string" || step.url.trim().length === 0) { + issues.push({ index, message: "navigate step requires url" }); + } + break; + case "click": + case "hover": + if (!hasSelector && !hasText) { + issues.push({ index, message: `${kind} step requires selector or text` }); + } + break; + case "fill": + case "type": + if (!hasSelector) + issues.push({ index, message: `${kind} step requires selector` }); + if (typeof step.value !== "string") + issues.push({ index, message: `${kind} step requires value` }); + break; + case "press": + if (typeof step.key !== "string" || step.key.length === 0) { + issues.push({ index, message: "press step requires key" }); + } + break; + case "drag": + if (typeof step.from !== "string" || step.from.length === 0) { + issues.push({ index, message: "drag step requires from selector" }); + } + if (!isBrowserInteractionDragTarget(step.to)) { + issues.push({ index, message: "drag step requires to as { selector } or { x, y }" }); + } + break; + case "select": + if (!hasSelector) + issues.push({ index, message: "select step requires selector" }); + if (typeof step.value !== "string" && !Array.isArray(step.values)) { + issues.push({ index, message: "select step requires value or values" }); + } + break; + case "waitFor": + if (!hasSelector && typeof step.waitFor !== "string") { + issues.push({ index, message: "waitFor step requires selector or waitFor condition" }); + } + break; + case "evaluate": + if (typeof step.expression !== "string" || step.expression.trim().length === 0) { + issues.push({ index, message: "evaluate step requires expression" }); + } + break; + case "expect": + if (!hasSelector) + issues.push({ index, message: "expect step requires selector" }); + if (step.state !== undefined && !BROWSER_INTERACTION_EXPECT_STATES.includes(step.state)) { + issues.push({ index, message: `expect step state must be one of ${BROWSER_INTERACTION_EXPECT_STATES.join(", ")}` }); + } + break; + case "assertObservation": + if (typeof step.assertion !== "string" || step.assertion.trim().length === 0) { + issues.push({ index, message: "assertObservation step requires assertion" }); + } + else if (!isBrowserInteractionObservationAssertion(step.assertion)) { + issues.push({ index, message: "assertObservation supports no-console-errors, no-page-errors, request-count-by-host:, and request-count-by-type:" }); + } + break; + case "screenshot": + case "capture": + break; + case "callTool": + if (typeof step.tool !== "string" || !/^[a-z][a-z0-9_-]*\/[a-z][a-z0-9_-]*$/i.test(step.tool)) { + issues.push({ index, message: "callTool step requires tool as a stable canonical tool id such as client/search_docs" }); + } + if (!Object.prototype.hasOwnProperty.call(step, "input")) { + issues.push({ index, message: "callTool step requires input" }); + } + else if (!isJsonValue(step.input)) { + issues.push({ index, message: "callTool step input must be JSON-serializable" }); + } + break; + } + steps.push(step); + }); + return { valid: issues.length === 0, steps, issues }; +} +/** True when an interaction script contains at least one policy-gated evaluate step. */ +export function browserInteractionScriptUsesEvaluate(steps) { + return steps.some((step) => step.kind === "evaluate"); +} +function isBrowserInteractionObservationAssertion(raw) { + const value = raw.trim(); + if (value === "no-console-errors" || value === "no-page-errors") + return true; + if (value.startsWith("request-count-by-host:")) + return /^.+(>=|<=|==|!=|=|>|<)\s*\d+$/.test(value.slice("request-count-by-host:".length).trim()); + if (value.startsWith("request-count-by-type:")) + return /^.+(>=|<=|==|!=|=|>|<)\s*\d+$/.test(value.slice("request-count-by-type:".length).trim()); + return false; +} +/** Exact caller-provided tool command names referenced by `callTool` steps. */ +export function browserInteractionScriptToolCalls(steps) { + return [...new Set(steps.filter((step) => step.kind === "callTool" && typeof step.tool === "string").map((step) => step.tool))].sort(); +} +function isJsonValue(value) { + if (value === null || typeof value === "boolean" || typeof value === "number" || typeof value === "string") { + return Number.isFinite(value) || typeof value !== "number"; + } + if (Array.isArray(value)) { + return value.every(isJsonValue); + } + if (!isPlainObject(value)) { + return false; + } + return Object.values(value).every(isJsonValue); +} +export function browserRandomWalkContract(input) { + const context = normalizeBrowserRandomWalkContext(input.context); + const seed = typeof input.seed === "string" && input.seed.length > 0 ? input.seed : "browser-random-walk"; + const maxSteps = normalizeBrowserRandomWalkMaxSteps(input.maxSteps ?? input.max_steps); + const families = normalizeBrowserRandomWalkActionFamilies(input.actionFamilies ?? input.action_families); + return { + schema: BROWSER_RANDOM_WALK_SCHEMA, + context, + seed, + maxSteps, + actionFamilies: families, + startUrl: typeof input.startUrl === "string" ? input.startUrl : typeof input.start_url === "string" ? input.start_url : undefined, + resetPolicy: isPlainObject(input.resetPolicy) ? input.resetPolicy : isPlainObject(input.reset_policy) ? input.reset_policy : undefined, + metadata: isPlainObject(input.metadata) ? input.metadata : undefined, + }; +} +export function planBrowserRandomWalk(input) { + const contract = browserRandomWalkContract(input); + const diagnostics = []; + const steps = []; + const startUrl = contract.startUrl ?? defaultBrowserRandomWalkStartUrl(contract.context); + if (!startUrl) { + diagnostics.push({ code: "browser_random_walk_start_url_required", message: `Random walk context ${contract.context} requires startUrl.` }); + } + else { + steps.push({ kind: "navigate", url: startUrl, waitFor: "load" }); + } + const budget = Math.max(contract.maxSteps - steps.length, 0); + for (let index = 0; index < budget; index += 1) { + const family = pickDeterministic(contract.actionFamilies, `${contract.seed}:${index}`); + const step = browserRandomWalkStep(family, contract, index); + if (step) + steps.push(step); + } + if (steps.length === 0) { + diagnostics.push({ code: "browser_random_walk_no_executable_steps", message: "Random walk planning produced no executable browser interaction steps." }); + } + return { + schema: BROWSER_RANDOM_WALK_SCHEMA, + status: diagnostics.length > 0 ? "unsupported" : "planned", + context: contract.context, + seed: contract.seed, + maxSteps: contract.maxSteps, + actionFamilies: contract.actionFamilies, + steps, + replay: { + schema: BROWSER_RANDOM_WALK_SCHEMA, + seed: contract.seed, + maxSteps: contract.maxSteps, + actionFamilies: contract.actionFamilies, + context: contract.context, + startUrl, + resetPolicy: contract.resetPolicy, + }, + diagnostics, + }; +} +export function browserActionCorpusContract(input) { + const context = normalizeBrowserRandomWalkContext(input.context); + const seed = typeof input.seed === "string" && input.seed.length > 0 ? input.seed : "browser-action-corpus"; + return { + schema: BROWSER_ACTION_CORPUS_SCHEMA, + context, + seed, + maxSteps: normalizeBrowserRandomWalkMaxSteps(input.maxSteps ?? input.max_steps), + startUrl: typeof input.startUrl === "string" ? input.startUrl : typeof input.start_url === "string" ? input.start_url : defaultBrowserRandomWalkStartUrl(context), + includeFamilies: normalizeBrowserRandomWalkActionFamilies(input.includeFamilies ?? input.include_families), + generatorPrefix: typeof input.generatorPrefix === "string" && input.generatorPrefix.length > 0 ? input.generatorPrefix : "wp-codebox", + metadata: isPlainObject(input.metadata) ? input.metadata : undefined, + }; +} +export function planBrowserActionCorpus(contractInput, descriptorsInput) { + const contract = isBrowserActionCorpusContract(contractInput) ? contractInput : browserActionCorpusContract(contractInput); + const diagnostics = []; + const descriptors = normalizeBrowserActionCorpusDescriptors(descriptorsInput); + const candidates = seededBrowserActionCorpusOrder(descriptors, contract.seed); + const steps = []; + const descriptorIds = []; + for (const descriptor of candidates) { + if (steps.length >= contract.maxSteps) + break; + const planned = browserActionCorpusStep(descriptor, contract, steps.length); + if (!planned || !contract.includeFamilies.includes(planned.family)) + continue; + steps.push(planned.step); + descriptorIds.push(descriptor.id); + } + if (steps.length === 0) { + diagnostics.push({ code: "browser_action_corpus_no_steps", message: "No actionable controls produced executable seeded browser steps.", metadata: { descriptors: descriptors.length } }); + } + const fillSteps = steps.filter((step) => step.kind === "fill" || step.kind === "press").length; + const clickSteps = steps.filter((step) => step.kind === "click").length; + const selectSteps = steps.filter((step) => step.kind === "select").length; + return { + schema: BROWSER_ACTION_CORPUS_SCHEMA, + status: steps.length > 0 ? "planned" : "empty", + context: contract.context, + seed: contract.seed, + maxSteps: contract.maxSteps, + startUrl: contract.startUrl, + descriptors, + steps, + replay: { + schema: BROWSER_ACTION_CORPUS_SCHEMA, + seed: contract.seed, + maxSteps: contract.maxSteps, + context: contract.context, + startUrl: contract.startUrl, + descriptorIds, + steps, + }, + observations: { + descriptorsDiscovered: descriptors.length, + descriptorsSelected: descriptorIds.length, + stepsPlanned: steps.length, + fillSteps, + clickSteps, + selectSteps, + }, + diagnostics, + }; +} +export function browserActionCorpusArtifact(contractInput, descriptors, capturedAt) { + const contract = isBrowserActionCorpusContract(contractInput) ? contractInput : browserActionCorpusContract(contractInput); + return { + schema: BROWSER_ACTION_CORPUS_ARTIFACT_SCHEMA, + contract, + plan: planBrowserActionCorpus(contract, descriptors), + capturedAt, + }; +} +function isBrowserActionCorpusContract(value) { + return value.schema === BROWSER_ACTION_CORPUS_SCHEMA; +} +function normalizeBrowserRandomWalkContext(value) { + return BROWSER_RANDOM_WALK_CONTEXTS.includes(String(value)) ? value : "browser"; +} +function normalizeBrowserRandomWalkMaxSteps(value) { + const numeric = typeof value === "number" ? value : Number(value); + if (!Number.isFinite(numeric)) + return 8; + return Math.max(1, Math.min(Math.floor(numeric), 50)); +} +function normalizeBrowserRandomWalkActionFamilies(value) { + const raw = Array.isArray(value) ? value : []; + const normalized = raw.filter((item) => BROWSER_RANDOM_WALK_ACTION_FAMILIES.includes(String(item))); + return normalized.length > 0 ? [...new Set(normalized)] : ["click", "fill", "press", "capture"]; +} +function defaultBrowserRandomWalkStartUrl(context) { + if (context === "admin") + return "/wp-admin/"; + if (context === "editor") + return "/wp-admin/post-new.php"; + return "/"; +} +function browserRandomWalkStep(family, contract, index) { + if (family === "navigate") + return { kind: "navigate", url: contract.startUrl ?? defaultBrowserRandomWalkStartUrl(contract.context), waitFor: "load" }; + if (family === "click") + return { kind: "click", selector: "a, button, input[type='submit'], .button" }; + if (family === "fill") + return { kind: "fill", selector: "input[type='search'], input[type='text'], textarea", value: `fuzz-${contract.seed}-${index}` }; + if (family === "press") + return { kind: "press", key: index % 2 === 0 ? "Tab" : "Escape" }; + if (family === "select") + return { kind: "select", selector: "select", value: "" }; + if (family === "capture") + return { kind: "capture" }; + return undefined; +} +function normalizeBrowserActionCorpusDescriptors(descriptors) { + const seen = new Set(); + const normalized = []; + for (const descriptor of descriptors) { + if (!descriptor || typeof descriptor.selector !== "string" || descriptor.selector.length === 0 || typeof descriptor.id !== "string" || descriptor.id.length === 0) + continue; + if (descriptor.disabled || descriptor.readonly || seen.has(descriptor.id)) + continue; + seen.add(descriptor.id); + normalized.push({ + id: descriptor.id, + kind: descriptor.kind, + selector: descriptor.selector, + ...(typeof descriptor.label === "string" && descriptor.label.length > 0 ? { label: descriptor.label } : {}), + ...(typeof descriptor.name === "string" && descriptor.name.length > 0 ? { name: descriptor.name } : {}), + ...(typeof descriptor.role === "string" && descriptor.role.length > 0 ? { role: descriptor.role } : {}), + ...(typeof descriptor.type === "string" && descriptor.type.length > 0 ? { type: descriptor.type.toLowerCase() } : {}), + ...(typeof descriptor.formId === "string" && descriptor.formId.length > 0 ? { formId: descriptor.formId } : {}), + ...(typeof descriptor.href === "string" && descriptor.href.length > 0 ? { href: descriptor.href } : {}), + ...(Array.isArray(descriptor.optionValues) ? { optionValues: descriptor.optionValues.filter((value) => typeof value === "string") } : {}), + }); + } + return normalized; +} +function seededBrowserActionCorpusOrder(descriptors, seed) { + return [...descriptors].sort((a, b) => deterministicHash(`${seed}:${a.id}`) - deterministicHash(`${seed}:${b.id}`) || a.id.localeCompare(b.id)); +} +function browserActionCorpusStep(descriptor, contract, index) { + if (descriptor.kind === "select") { + const values = descriptor.optionValues?.filter((value) => value.length > 0) ?? []; + if (values.length === 0) + return undefined; + return { family: "select", step: { kind: "select", selector: descriptor.selector, value: pickDeterministic(values, `${contract.seed}:${descriptor.id}`) } }; + } + if (descriptor.kind === "textarea" || descriptor.kind === "input") { + const type = normalizeBrowserActionCorpusGeneratorKind(descriptor.kind === "textarea" ? "textarea" : descriptor.type); + if (type === "checkbox" || type === "radio") + return { family: "click", step: { kind: "click", selector: descriptor.selector } }; + return { family: "fill", step: { kind: "fill", selector: descriptor.selector, value: browserActionCorpusGeneratedValue(type, contract, descriptor, index) } }; + } + if (descriptor.kind === "button") + return { family: "click", step: { kind: "click", selector: descriptor.selector } }; + if (descriptor.kind === "link") + return { family: "click", step: { kind: "click", selector: descriptor.selector } }; + return undefined; +} +function normalizeBrowserActionCorpusGeneratorKind(value) { + const normalized = String(value || "text").toLowerCase(); + if (BROWSER_ACTION_CORPUS_GENERATOR_KINDS.includes(normalized)) + return normalized; + return "text"; +} +function browserActionCorpusGeneratedValue(kind, contract, descriptor, index) { + const suffix = deterministicHash(`${contract.seed}:${descriptor.id}:${index}`).toString(36).slice(0, 8); + const prefix = contract.generatorPrefix.replace(/[^a-zA-Z0-9._-]+/g, "-") || "wp-codebox"; + if (kind === "email") + return `${prefix}-${suffix}@example.test`; + if (kind === "url") + return `https://example.test/${prefix}-${suffix}`; + if (kind === "number") + return String((deterministicHash(`${contract.seed}:${descriptor.id}`) % 900) + 100); + if (kind === "password") + return `${prefix}-${suffix}-Passw0rd!`; + if (kind === "search") + return `${prefix} search ${suffix}`; + if (kind === "textarea") + return `${prefix} generated text ${suffix}`; + return `${prefix}-${suffix}`; +} +function pickDeterministic(items, seed) { + return items[deterministicHash(seed) % items.length]; +} +function deterministicHash(input) { + let hash = 2166136261; + for (let index = 0; index < input.length; index += 1) { + hash ^= input.charCodeAt(index); + hash = Math.imul(hash, 16777619); + } + return hash >>> 0; +} +//# sourceMappingURL=browser-interaction.js.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/browser-interaction.js.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/browser-interaction.js.map new file mode 100644 index 000000000..36c36fa0e --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/browser-interaction.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser-interaction.js","sourceRoot":"","sources":["../src/browser-interaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAGjD,MAAM,CAAC,MAAM,iCAAiC,GAAG,0CAAmD,CAAA;AACpG,MAAM,CAAC,MAAM,mCAAmC,GAAG,4CAAqD,CAAA;AAExG;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG;IAC5C,UAAU;IACV,OAAO;IACP,MAAM;IACN,MAAM;IACN,OAAO;IACP,MAAM;IACN,OAAO;IACP,QAAQ;IACR,SAAS;IACT,UAAU;IACV,QAAQ;IACR,mBAAmB;IACnB,YAAY;IACZ,SAAS;IACT,UAAU;CACF,CAAA;AAIV,MAAM,CAAC,MAAM,0BAA0B,GAAG,mCAA4C,CAAA;AACtF,MAAM,CAAC,MAAM,4BAA4B,GAAG,qCAA8C,CAAA;AAC1F,MAAM,CAAC,MAAM,qCAAqC,GAAG,8CAAuD,CAAA;AAE5G,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,CAAU,CAAA;AAGnF,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,CAAU,CAAA;AAGvH,yDAAyD;AACzD,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,CAAU,CAAA;AAiGlK,MAA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IAAI,KAAK,QAAQ;QAAE,OAAO,GAAG,MAAM,WAAW,MAAM,EAAE,CAAA;IAC1D,IAAI,IAAI,KAAK,UAAU;QAAE,OAAO,GAAG,MAAM,mBAAmB,MAAM,EAAE,CAAA;IACpE,OAAO,GAAG,MAAM,IAAI,MAAM,EAAE,CAAA;AAC9B,CAAC;AAED,SAAS,iBAAiB,CAAI,KAAmB,EAAE,IAAY;IAC7D,OAAO,KAAK,CAAC,iBAAiB,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,CAAM,CAAA;AAC3D,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAa;IACtC,IAAI,IAAI,GAAG,UAAU,CAAA;IACrB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACrD,IAAI,IAAI,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;QAC/B,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;IAClC,CAAC;IACD,OAAO,IAAI,KAAK,CAAC,CAAA;AACnB,CAAC"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/file-tree-policy.d.ts b/packages/runtime-cloudflare/vendor/wp-codebox-core/file-tree-policy.d.ts new file mode 100644 index 000000000..67c6ba239 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/file-tree-policy.d.ts @@ -0,0 +1,12 @@ +export type NamedFileTreeSkipPolicy = "prepared-source" | "captured-mount"; +export declare function normalizeRelativePath(path: string): string; +export declare function normalizeRootedPath(path: string, root?: string): string; +export declare function pathIsWithinRoot(path: string, root: string): boolean; +export declare function relativePathIsWithinRoot(path: string, root: string): boolean; +export declare function namedFileTreeSkipPolicy(policy: NamedFileTreeSkipPolicy): Set; +export declare function namedFileTreeSkipPolicyNames(policy: NamedFileTreeSkipPolicy): string[]; +export declare function fileTreeEntryNameSkipped(name: string, skipNames: ReadonlySet | readonly string[]): boolean; +export declare function relativePathExcluded(relativePath: string, excludePaths: readonly string[]): boolean; +export declare function relativePathMatchesExcludePattern(relativePath: string, pattern: string): boolean; +export declare function phpStringArrayLiteral(values: readonly string[]): string; +//# sourceMappingURL=file-tree-policy.d.ts.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/file-tree-policy.d.ts.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/file-tree-policy.d.ts.map new file mode 100644 index 000000000..f3f3254df --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/file-tree-policy.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"file-tree-policy.d.ts","sourceRoot":"","sources":["../src/file-tree-policy.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,GAAG,gBAAgB,CAAA;AAO1E,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,SAAM,GAAG,MAAM,CAIpE;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAGpE;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAE5E;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,uBAAuB,GAAG,GAAG,CAAC,MAAM,CAAC,CAEpF;AAED,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,uBAAuB,GAAG,MAAM,EAAE,CAEtF;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,SAAS,MAAM,EAAE,GAAG,OAAO,CAMlH;AAED,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAGnG;AAED,wBAAgB,iCAAiC,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAYhG;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAEvE"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/file-tree-policy.js b/packages/runtime-cloudflare/vendor/wp-codebox-core/file-tree-policy.js new file mode 100644 index 000000000..350bf1029 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/file-tree-policy.js @@ -0,0 +1,51 @@ +import { isAbsolute, normalize, relative, sep } from "node:path"; +const FILE_TREE_SKIP_POLICIES = { + "prepared-source": [".git", "node_modules", "vendor"], + "captured-mount": [".git", "node_modules", "target"], +}; +export function normalizeRelativePath(path) { + return normalize(path.replaceAll("\\", "/")).replaceAll("\\", "/").replace(/^\.\//, ""); +} +export function normalizeRootedPath(path, root = "/") { + const absolutePath = path.startsWith("/") ? path : `${root.replace(/\/+$/, "")}/${path}`; + const normalized = normalize(absolutePath); + return normalized.startsWith("/") ? normalized : `/${normalized}`; +} +export function pathIsWithinRoot(path, root) { + const relativePath = relative(root, path); + return relativePath === "" || (relativePath !== ".." && !relativePath.startsWith(`..${sep}`) && !isAbsolute(relativePath)); +} +export function relativePathIsWithinRoot(path, root) { + return pathIsWithinRoot(normalizeRootedPath(path), normalizeRootedPath(root)); +} +export function namedFileTreeSkipPolicy(policy) { + return new Set(FILE_TREE_SKIP_POLICIES[policy]); +} +export function namedFileTreeSkipPolicyNames(policy) { + return [...FILE_TREE_SKIP_POLICIES[policy]]; +} +export function fileTreeEntryNameSkipped(name, skipNames) { + if (Array.isArray(skipNames)) { + return skipNames.includes(name); + } + return skipNames.has(name); +} +export function relativePathExcluded(relativePath, excludePaths) { + const normalized = normalizeRelativePath(relativePath).replace(/^\/+/, ""); + return excludePaths.some((pattern) => relativePathMatchesExcludePattern(normalized, pattern)); +} +export function relativePathMatchesExcludePattern(relativePath, pattern) { + const normalizedPattern = normalizeRelativePath(pattern).trim().replace(/^\/+/, "").replace(/\/+$/, ""); + if (!normalizedPattern) { + return false; + } + if (normalizedPattern.endsWith("/**")) { + const prefix = normalizedPattern.slice(0, -3).replace(/\/+$/, ""); + return relativePath === prefix || relativePath.startsWith(`${prefix}/`); + } + return relativePath === normalizedPattern || relativePath.startsWith(`${normalizedPattern}/`); +} +export function phpStringArrayLiteral(values) { + return `array(${values.map((value) => `'${value.replaceAll("\\", "\\\\").replaceAll("'", "\\'")}'`).join(", ")})`; +} +//# sourceMappingURL=file-tree-policy.js.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/file-tree-policy.js.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/file-tree-policy.js.map new file mode 100644 index 000000000..399f66035 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/file-tree-policy.js.map @@ -0,0 +1 @@ +{"version":3,"file":"file-tree-policy.js","sourceRoot":"","sources":["../src/file-tree-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAIhE,MAAM,uBAAuB,GAAG;IAC9B,iBAAiB,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,CAAC;IACrD,gBAAgB,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,CAAC;CACiB,CAAA;AAEvE,MAAM,UAAU,qBAAqB,CAAC,IAAY;IAChD,OAAO,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;AACzF,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,IAAY,EAAE,IAAI,GAAG,GAA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AAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAA;AACnH,CAAC"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/fuzz-coverage-plan-contracts.d.ts b/packages/runtime-cloudflare/vendor/wp-codebox-core/fuzz-coverage-plan-contracts.d.ts new file mode 100644 index 000000000..9f8418bd8 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/fuzz-coverage-plan-contracts.d.ts @@ -0,0 +1,65 @@ +import type { FuzzSuiteTargetRef } from "./fuzz-suite-contracts.js"; +export declare const FUZZ_COVERAGE_PLAN_SCHEMA: "wp-codebox/fuzz-coverage-plan/v1"; +export interface FuzzCoveragePlanReason { + code: string; + message: string; + data?: Record; +} +export interface FuzzCoveragePlanParameterGenerationHook { + id: string; + label?: string; + description?: string; + inputSchema?: Record; + metadata?: Record; +} +export interface FuzzCoveragePlanParameterGenerationPlaceholder { + hook: string; + requiredInputs?: string[]; + metadata?: Record; +} +export interface FuzzCoveragePlanItem { + id: string; + target?: FuzzSuiteTargetRef; + description?: string; + input?: unknown; + reason?: FuzzCoveragePlanReason; + parameterGeneration?: FuzzCoveragePlanParameterGenerationPlaceholder; + metadata?: Record; +} +export interface FuzzCoveragePlanSummary { + discovered: number; + generated: number; + executable: number; + executed: number; + skipped: number; + untested: number; + caseIds: string[]; + targetIds: string[]; +} +export interface FuzzCoveragePlanContract { + schema: typeof FUZZ_COVERAGE_PLAN_SCHEMA; + id: string; + version?: string; + discovered: FuzzCoveragePlanItem[]; + generated: FuzzCoveragePlanItem[]; + executable: FuzzCoveragePlanItem[]; + executed: FuzzCoveragePlanItem[]; + skipped: FuzzCoveragePlanItem[]; + untested: FuzzCoveragePlanItem[]; + parameterGenerationHooks?: FuzzCoveragePlanParameterGenerationHook[]; + summary: FuzzCoveragePlanSummary; + metadata?: Record; +} +export declare function fuzzCoveragePlanContract(input: { + id: string; + version?: string; + discovered?: FuzzCoveragePlanItem[]; + generated?: FuzzCoveragePlanItem[]; + executable?: FuzzCoveragePlanItem[]; + executed?: FuzzCoveragePlanItem[]; + skipped?: FuzzCoveragePlanItem[]; + untested?: FuzzCoveragePlanItem[]; + parameterGenerationHooks?: FuzzCoveragePlanParameterGenerationHook[]; + metadata?: Record; +}): FuzzCoveragePlanContract; +//# sourceMappingURL=fuzz-coverage-plan-contracts.d.ts.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/fuzz-coverage-plan-contracts.d.ts.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/fuzz-coverage-plan-contracts.d.ts.map new file mode 100644 index 000000000..1f06bf551 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/fuzz-coverage-plan-contracts.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"fuzz-coverage-plan-contracts.d.ts","sourceRoot":"","sources":["../src/fuzz-coverage-plan-contracts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAEnE,eAAO,MAAM,yBAAyB,EAAG,kCAA2C,CAAA;AAEpF,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC/B;AAED,MAAM,WAAW,uCAAuC;IACtD,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACrC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACnC;AAED,MAAM,WAAW,8CAA8C;IAC7D,IAAI,EAAE,MAAM,CAAA;IACZ,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;IACzB,QAA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AAE,EAAE,MAAM,CAAA;IACV,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,oBAAoB,EAAE,CAAA;IACnC,SAAS,CAAC,EAAE,oBAAoB,EAAE,CAAA;IAClC,UAAU,CAAC,EAAE,oBAAoB,EAAE,CAAA;IACnC,QAAQ,CAAC,EAAE,oBAAoB,EAAE,CAAA;IACjC,OAAO,CAAC,EAAE,oBAAoB,EAAE,CAAA;IAChC,QAAQ,CAAC,EAAE,oBAAoB,EAAE,CAAA;IACjC,wBAAwB,CAAC,EAAE,uCAAuC,EAAE,CAAA;IACpE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACnC,GAAG,wBAAwB,CAgC3B"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/fuzz-coverage-plan-contracts.js b/packages/runtime-cloudflare/vendor/wp-codebox-core/fuzz-coverage-plan-contracts.js new file mode 100644 index 000000000..76ffbd411 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/fuzz-coverage-plan-contracts.js @@ -0,0 +1,38 @@ +import { stripUndefined } from "./object-utils.js"; +export const FUZZ_COVERAGE_PLAN_SCHEMA = "wp-codebox/fuzz-coverage-plan/v1"; +export function fuzzCoveragePlanContract(input) { + const discovered = input.discovered ?? []; + const generated = input.generated ?? []; + const executable = input.executable ?? []; + const executed = input.executed ?? []; + const skipped = input.skipped ?? []; + const untested = input.untested ?? []; + const allItems = [...discovered, ...generated, ...executable, ...executed, ...skipped, ...untested]; + return stripUndefined({ + schema: FUZZ_COVERAGE_PLAN_SCHEMA, + id: input.id, + version: input.version, + discovered, + generated, + executable, + executed, + skipped, + untested, + parameterGenerationHooks: input.parameterGenerationHooks?.length ? input.parameterGenerationHooks : undefined, + summary: { + discovered: discovered.length, + generated: generated.length, + executable: executable.length, + executed: executed.length, + skipped: skipped.length, + untested: untested.length, + caseIds: uniqueStrings(allItems.map((item) => item.id)), + targetIds: uniqueStrings(allItems.map((item) => item.target?.id ?? item.target?.entrypoint ?? item.target?.kind)), + }, + metadata: input.metadata, + }); +} +function uniqueStrings(values) { + return [...new Set(values.filter((value) => Boolean(value)))]; +} +//# sourceMappingURL=fuzz-coverage-plan-contracts.js.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/fuzz-coverage-plan-contracts.js.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/fuzz-coverage-plan-contracts.js.map new file mode 100644 index 000000000..a2437f5fb --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/fuzz-coverage-plan-contracts.js.map @@ -0,0 +1 @@ +{"version":3,"file":"fuzz-coverage-plan-contracts.js","sourceRoot":"","sources":["../src/fuzz-coverage-plan-contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAGlD,MAAM,CAAC,MAAM,yBAAyB,GAAG,kCAA2C,CAAA;AA0DpF,MAAM,UAAU,wBAAwB,CAAC,KAWxC;IACC,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,IAAI,EAAE,CAAA;IACzC,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,IAAI,EAAE,CAAA;IACvC,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,IAAI,EAAE,CAAA;IACzC,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAA;IACrC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,IAAI,EAAE,CAAA;IACnC,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAA;IACrC,MAAM,QAAQ,GAAG,CAAC,GAAG,UAAU,EAAE,GAAG,SAAS,EAAE,GAAG,UAAU,EAAE,GAAG,QAAQ,EAAE,GAAG,OAAO,EAAE,GAAG,QAAQ,CAAC,CAAA;IAEnG,OAAO,cAAc,CAAC;QACpB,MAAM,EAAE,yBAAyB;QACjC,EAAE,EAAE,KAAK,CAAC,EAAE;QACZ,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,UAAU;QACV,SAAS;QACT,UAAU;QACV,QAAQ;QACR,OAAO;QACP,QAAQ;QACR,wBAAwB,EAAE,KAAK,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC,CAAC,SAAS;QAC7G,OAAO,EAAE;YACP,UAAU,EAAE,UAAU,CAAC,MAAM;YAC7B,SAAS,EAAE,SAAS,CAAC,MAAM;YAC3B,UAAU,EAAE,UAAU,CAAC,MAAM;YAC7B,QAAQ,EAAE,QAAQ,CAAC,MAAM;YACzB,OAAO,EAAE,OAAO,CAAC,MAAM;YACvB,QAAQ,EAAE,QAAQ,CAAC,MAAM;YACzB,OAAO,EAAE,aAAa,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACvD,SAAS,EAAE,aAAa,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,UAAU,IAAI,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;SAClH;QACD,QAAQ,EAAE,KAAK,CAAC,QAAQ;KACzB,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,MAAiC;IACtD,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAmB,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;AAChF,CAAC"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/fuzz-suite-contracts.d.ts b/packages/runtime-cloudflare/vendor/wp-codebox-core/fuzz-suite-contracts.d.ts new file mode 100644 index 000000000..457419d74 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/fuzz-suite-contracts.d.ts @@ -0,0 +1,352 @@ +import { type FuzzCoveragePlanContract } from "./fuzz-coverage-plan-contracts.js"; +export declare const FUZZ_SUITE_SCHEMA: "wp-codebox/fuzz-suite/v1"; +export declare const FUZZ_SUITE_RESULT_SCHEMA: "wp-codebox/fuzz-suite-result/v1"; +export declare const FUZZ_RUNNER_CAPABILITIES_SCHEMA: "wp-codebox/fuzz-runner-capabilities/v1"; +export declare const FUZZ_RUNNER_READINESS_SCHEMA: "wp-codebox/fuzz-runner-readiness/v1"; +export declare const FUZZ_ARTIFACT_BUNDLE_SCHEMA: "wp-codebox/fuzz-artifact-bundle/v1"; +export declare const FUZZ_REPLAY_CASE_REF_SCHEMA: "wp-codebox/fuzz-replay-case-ref/v1"; +export declare const FUZZ_MINIMIZE_CAPABILITY_SCHEMA: "wp-codebox/fuzz-minimize-capability/v1"; +export declare const WORDPRESS_FUZZ_RUNTIME_CONTRACT_SCHEMA: "wp-codebox/wordpress-fuzz-runtime-contract/v1"; +export type FuzzSuiteTargetKind = "ability" | "command" | "http" | "rest" | "runtime" | "runtime-action" | (string & {}); +export type FuzzSuiteCaseStatus = "passed" | "failed" | "error" | "skipped"; +export type FuzzSuiteDiagnosticSeverity = "error" | "warning" | "info"; +export type FuzzSuiteRunnerMode = "php-in-process" | "runtime-backed" | (string & {}); +export type FuzzSuiteResetMode = "none" | "checkpoint-per-case" | "restore-snapshot"; +export type FuzzSuiteResetStatus = "not-required" | "passed" | "failed" | "unsupported"; +export type FuzzSuiteMutationIntensity = "none" | "low" | "medium" | "high" | (string & {}); +export type FuzzSuiteMutationIntentKind = "read" | "write" | "delete" | "destructive" | (string & {}); +export type FuzzSuiteCasePhase = "setup" | "action" | "assert" | "teardown"; +export interface FuzzSuiteTargetRef { + kind: FuzzSuiteTargetKind; + id?: string; + entrypoint?: string; + label?: string; + metadata?: Record; +} +export interface FuzzSuiteCase { + id: string; + target?: FuzzSuiteTargetRef; + input?: unknown; + phases?: Partial>; + resetPolicy?: FuzzSuiteResetPolicy; + reset_policy?: FuzzSuiteResetPolicy | string; + mutation?: FuzzSuiteMutationIntent; + mutation_intent?: FuzzSuiteMutationIntent | string; + description?: string; + metadata?: Record; +} +export interface FuzzSuitePhaseStep { + command: string; + args?: string[]; + timeoutMs?: number; + timeout_ms?: number; + allowFailure?: boolean; + allow_failure?: boolean; + advisory?: boolean; + metadata?: Record; +} +export interface FuzzSuiteMutationIntent { + intent?: FuzzSuiteMutationIntentKind; + destructive?: boolean; + intensity?: FuzzSuiteMutationIntensity; + metadata?: Record; +} +export interface FuzzSuiteResetPolicy { + mode: FuzzSuiteResetMode | (string & {}); + checkpointName?: string; + checkpoint_name?: string; + snapshotRef?: string; + snapshot_ref?: string; + fixtureRefs?: string[]; + fixture_refs?: string[]; + metadata?: Record; +} +export interface FuzzSuiteCaseResetResult { + mode: FuzzSuiteResetMode | (string & {}); + status: FuzzSuiteResetStatus; + checkpointName?: string; + snapshotRef?: string; + fixtureRefs?: string[]; + artifactRefs?: FuzzSuiteArtifactRef[]; + diagnostics?: FuzzSuiteDiagnostic[]; + metadata?: Record; +} +export interface FuzzSuiteContract { + schema: typeof FUZZ_SUITE_SCHEMA; + id: string; + version?: string; + target?: FuzzSuiteTargetRef; + resetPolicy?: FuzzSuiteResetPolicy; + reset_policy?: FuzzSuiteResetPolicy | string; + mutation?: FuzzSuiteMutationIntent; + mutation_intent?: FuzzSuiteMutationIntent | string; + cases: FuzzSuiteCase[]; + coveragePlan?: FuzzCoveragePlanContract; + metadata?: Record; +} +export interface FuzzSuiteRunnerCapabilities { + schema?: typeof FUZZ_RUNNER_CAPABILITIES_SCHEMA; + mode: FuzzSuiteRunnerMode; + entrypoint?: string; + capabilities: string[]; + targetKinds: string[]; + operationKinds?: string[]; + runtimeActionTypes?: string[]; + commands?: string[]; + unsupportedRequiredCapabilities?: string[]; + metadata?: Record; +} +export interface FuzzRunnerCapabilitiesContract extends FuzzSuiteRunnerCapabilities { + schema: typeof FUZZ_RUNNER_CAPABILITIES_SCHEMA; + unsupportedRequiredCapabilities: string[]; +} +export interface FuzzRunnerReadinessContract { + schema: typeof FUZZ_RUNNER_READINESS_SCHEMA; + status: "ready" | "unsupported"; + entrypoint: string; + mode: FuzzSuiteRunnerMode; + capabilities: FuzzRunnerCapabilitiesContract; + operationKinds: string[]; + unsupportedRequiredCapabilities: string[]; + disposable?: boolean; + isolation?: { + runtime_backed: true; + disposable: true; + sandboxed: true; + }; + guardrails?: { + external_side_effect_guardrail: true; + external_http_guardrail: true; + }; + artifacts?: { + artifact_export: true; + }; + destructiveModeRequirements?: WordPressFuzzDestructiveModeRequirements; + metadata?: Record; +} +export interface WordPressFuzzRuntimeContract { + schema: typeof WORDPRESS_FUZZ_RUNTIME_CONTRACT_SCHEMA; + version: 1; + runtime: { + id: "wp-codebox"; + environment: "wordpress"; + }; + publicSurfaces: { + phpFacade: string; + ability: string; + wpCli: string; + nodeCli: string; + typescript: string; + }; + actionFamilies: WordPressFuzzActionFamily[]; + resetModes: WordPressFuzzResetMode[]; + artifactExpectations: WordPressFuzzArtifactExpectation[]; + destructiveModeRequirements: WordPressFuzzDestructiveModeRequirements; + unsupportedCapabilities: WordPressFuzzUnsupportedCapability[]; + hbex: { + schemaIds: Record; + }; +} +export interface WordPressFuzzActionFamily { + id: string; + label: string; + targetKinds: string[]; + runtimeActionTypes: string[]; + commands: string[]; + mutationIntents: FuzzSuiteMutationIntentKind[]; + supported: boolean; +} +export interface WordPressFuzzResetMode { + id: FuzzSuiteResetMode; + supported: boolean; + optionalForMutationIntents: FuzzSuiteMutationIntentKind[]; + artifactKinds: string[]; +} +export interface WordPressFuzzArtifactExpectation { + id: string; + required: boolean; + schema: string; + producedBy: string[]; + description: string; +} +export interface WordPressFuzzDestructiveModeRequirements { + supported: boolean; + destructiveMutationIntent: "destructive"; + requiredSandboxBoundary: { + disposable: true; + destructivePermission: true; + teardown: "discard"; + }; + requiredSandboxProof: { + schema: "wp-codebox/destructive-sandbox-proof/v1"; + boundarySource: "runtime-created"; + }; + optionalResetModes: FuzzSuiteResetMode[]; + requiredArtifacts: string[]; + deleteBoundaryCapability: string; + rawDeleteCapability: null; +} +export interface WordPressFuzzUnsupportedCapability { + id: string; + reason: string; + replacement?: string; +} +export interface FuzzRunnerRequiredCapabilities { + capabilities?: readonly string[]; + targetKinds?: readonly string[]; + target_kinds?: readonly string[]; + runtimeActionTypes?: readonly string[]; + runtime_action_types?: readonly string[]; + commands?: readonly string[]; +} +export declare const PHP_IN_PROCESS_FUZZ_SUITE_RUNNER_CAPABILITIES: FuzzSuiteRunnerCapabilities; +export declare const RUNTIME_BACKED_FUZZ_SUITE_RUNNER_CAPABILITIES: FuzzSuiteRunnerCapabilities; +export declare const WORDPRESS_FUZZ_RUNTIME_CONTRACT: WordPressFuzzRuntimeContract; +export declare function wordpressFuzzRuntimeContract(): WordPressFuzzRuntimeContract; +export interface FuzzSuiteDiagnostic { + severity: FuzzSuiteDiagnosticSeverity; + message: string; + code?: string; + caseId?: string; + target?: FuzzSuiteTargetRef; + metadata?: Record; +} +export interface FuzzSuiteArtifactRef { + path: string; + kind: string; + contentType?: string; + sha256?: string; + bytes?: number; + name?: string; + metadata?: Record; +} +export interface FuzzReplayCaseRef { + schema: typeof FUZZ_REPLAY_CASE_REF_SCHEMA; + caseId: string; + path: string; + kind: "fuzz-replay-case" | (string & {}); + contentType: "application/json" | (string & {}); + sha256?: string; + bytes?: number; + target?: FuzzSuiteTargetRef; + status?: FuzzSuiteCaseStatus; + metadata?: Record; +} +export interface FuzzMinimizeCapabilityContract { + schema: typeof FUZZ_MINIMIZE_CAPABILITY_SCHEMA; + status: "supported" | "unsupported"; + inputKind: "fuzz-replay-case" | (string & {}); + operation?: string; + reason?: string; + requiredArtifacts?: string[]; + metadata?: Record; +} +export interface FuzzArtifactBundleContract { + schema: typeof FUZZ_ARTIFACT_BUNDLE_SCHEMA; + suiteId: string; + path: string; + manifestPath: string; + resultRef: FuzzSuiteArtifactRef; + caseResultStreamRef: FuzzSuiteArtifactRef; + replayCaseRefs: FuzzReplayCaseRef[]; + hotspotRefs: FuzzSuiteArtifactRef[]; + minimize: FuzzMinimizeCapabilityContract; + artifactRefs: FuzzSuiteArtifactRef[]; + metadata?: Record; +} +export interface FuzzSuiteCaseResult { + id: string; + status: FuzzSuiteCaseStatus; + success: boolean; + target?: FuzzSuiteTargetRef; + reset?: FuzzSuiteCaseResetResult; + skipReason?: string; + diagnostics: FuzzSuiteDiagnostic[]; + artifactRefs?: FuzzSuiteArtifactRef[]; + metadata?: Record; +} +export interface FuzzSuiteSummary { + total: number; + passed: number; + failed: number; + error: number; + skipped: number; +} +export interface FuzzSuiteSkippedReasonSummary { + reason: string; + count: number; + caseIds?: string[]; +} +export interface FuzzSuiteCoverageSummary { + discovered: number; + generated: number; + executed: number; + skipped: number; + untested: number; + skippedReasons: FuzzSuiteSkippedReasonSummary[]; +} +export interface FuzzSuiteResultEnvelope { + schema: typeof FUZZ_SUITE_RESULT_SCHEMA; + suite: { + id: string; + version?: string; + }; + status: FuzzSuiteCaseStatus; + success: boolean; + summary: FuzzSuiteSummary; + coverageSummary?: FuzzSuiteCoverageSummary; + coveragePlan?: FuzzCoveragePlanContract; + cases: FuzzSuiteCaseResult[]; + diagnostics: FuzzSuiteDiagnostic[]; + artifactRefs: FuzzSuiteArtifactRef[]; + metadata?: Record; +} +export declare function fuzzSuiteContract(input: { + id: string; + version?: string; + target?: FuzzSuiteTargetRef; + resetPolicy?: FuzzSuiteResetPolicy; + reset_policy?: FuzzSuiteResetPolicy | string; + mutation?: FuzzSuiteMutationIntent; + mutation_intent?: FuzzSuiteMutationIntent | string; + cases?: FuzzSuiteCase[]; + coveragePlan?: FuzzCoveragePlanContract; + metadata?: Record; +}): FuzzSuiteContract; +export declare function fuzzSuiteResultEnvelope(input: { + suite: { + id: string; + version?: string; + } | FuzzSuiteContract; + cases?: FuzzSuiteCaseResult[]; + diagnostics?: FuzzSuiteDiagnostic[]; + artifactRefs?: FuzzSuiteArtifactRef[]; + coverageSummary?: FuzzSuiteCoverageSummary; + coveragePlan?: FuzzCoveragePlanContract; + metadata?: Record; +}): FuzzSuiteResultEnvelope; +export declare function fuzzReplayCaseRef(input: Omit & Partial>): FuzzReplayCaseRef; +export declare function fuzzMinimizeUnsupportedCapability(input: { + reason: string; + requiredArtifacts?: string[]; + metadata?: Record; +}): FuzzMinimizeCapabilityContract; +export declare function fuzzMinimizeSupportedCapability(input: { + operation: string; + requiredArtifacts?: string[]; + metadata?: Record; +}): FuzzMinimizeCapabilityContract; +export declare function fuzzArtifactBundleContract(input: Omit): FuzzArtifactBundleContract; +export declare function fuzzSuiteRequiredRunnerCapabilities(suite: FuzzSuiteContract): string[]; +export declare function fuzzRunnerCapabilitiesContract(input: FuzzSuiteRunnerCapabilities, required?: FuzzSuiteContract | FuzzRunnerRequiredCapabilities | readonly string[]): FuzzRunnerCapabilitiesContract; +export declare function fuzzRunnerReadinessContract(input: FuzzSuiteRunnerCapabilities, required?: FuzzSuiteContract | FuzzRunnerRequiredCapabilities | readonly string[]): FuzzRunnerReadinessContract; +export declare function unsupportedRequiredFuzzRunnerCapabilities(required: FuzzSuiteContract | FuzzRunnerRequiredCapabilities | readonly string[] | undefined, runnerCapabilities: FuzzSuiteRunnerCapabilities): string[]; +export declare function fuzzSuiteCaseResetPolicy(suite: FuzzSuiteContract, fuzzCase: FuzzSuiteCase): FuzzSuiteResetPolicy; +export declare function normalizeFuzzSuiteResetPolicy(input: unknown): FuzzSuiteResetPolicy; +export declare function fuzzSuiteResetPolicyDiagnostics(input: unknown, caseId?: string): FuzzSuiteDiagnostic[]; +export declare function summarizeFuzzCases(cases: readonly Pick[]): FuzzSuiteSummary; +export declare function summarizeFuzzCoverage(input: { + discovered: number; + cases: readonly Pick[]; +}): FuzzSuiteCoverageSummary; +//# sourceMappingURL=fuzz-suite-contracts.d.ts.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/fuzz-suite-contracts.d.ts.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/fuzz-suite-contracts.d.ts.map new file mode 100644 index 000000000..25dcdc3b6 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/fuzz-suite-contracts.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"fuzz-suite-contracts.d.ts","sourceRoot":"","sources":["../src/fuzz-suite-contracts.ts"],"names":[],"mappings":"AACA,OAAO,EAA4B,KAAK,wBAAwB,EAA6B,MAAM,mCAAmC,CAAA;AAEtI,eAAO,MAAM,iBAAiB,EAAG,0BAAmC,CAAA;AACpE,eAAO,MAAM,wBAAwB,EAAG,iCAA0C,CAAA;AAClF,eAAO,MAAM,+BAA+B,EAAG,wCAAiD,CAAA;AAChG,eAAO,MAAM,4BAA4B,EAAG,qCAA8C,CAAA;AAC1F,eAAO,MAAM,2BAA2B,EAAG,oCAA6C,CAAA;AACxF,eAAO,MAAM,2BAA2B,EAAG,oCAA6C,CAAA;AACxF,eAAO,MAAM,+BAA+B,EAAG,wCAAiD,CAAA;AAChG,eAAO,MAAM,sCAAsC,EAAG,+CAAwD,CAAA;AAE9G,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,gBAAgB,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AACxH,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAA;AAC3E,MAAM,MAAM,2BAA2B,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAA;AACtE,MAAM,MAAM,mBAAmB,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AACrF,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,qBAAqB,GAAG,kBAAkB,CAAA;AACpF,MAAM,MAAM,oBAAoB,GAAG,cAAc,GAAG,QAAQ,GAAG,QAAQ,GAAG,aAA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,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,mBAAmB,EAAE,CAqBtG;AAMD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,SAAS,IAAI,CAAC,mBAAmB,EAAE,QAAQ,CAAC,EAAE,GAAG,gBAAgB,CAS1G;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE;IAC3C,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,SAAS,IAAI,CAAC,mBAAmB,EAAE,IAAI,GAAG,QAAQ,GAAG,YAAY,GAAG,aAAa,CAAC,EAAE,CAAA;CAC5F,GAAG,wBAAwB,CA0B3B"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/fuzz-suite-contracts.js b/packages/runtime-cloudflare/vendor/wp-codebox-core/fuzz-suite-contracts.js new file mode 100644 index 000000000..d67255518 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/fuzz-suite-contracts.js @@ -0,0 +1,670 @@ +import { stripUndefined } from "./object-utils.js"; +import { fuzzCoveragePlanContract } from "./fuzz-coverage-plan-contracts.js"; +export const FUZZ_SUITE_SCHEMA = "wp-codebox/fuzz-suite/v1"; +export const FUZZ_SUITE_RESULT_SCHEMA = "wp-codebox/fuzz-suite-result/v1"; +export const FUZZ_RUNNER_CAPABILITIES_SCHEMA = "wp-codebox/fuzz-runner-capabilities/v1"; +export const FUZZ_RUNNER_READINESS_SCHEMA = "wp-codebox/fuzz-runner-readiness/v1"; +export const FUZZ_ARTIFACT_BUNDLE_SCHEMA = "wp-codebox/fuzz-artifact-bundle/v1"; +export const FUZZ_REPLAY_CASE_REF_SCHEMA = "wp-codebox/fuzz-replay-case-ref/v1"; +export const FUZZ_MINIMIZE_CAPABILITY_SCHEMA = "wp-codebox/fuzz-minimize-capability/v1"; +export const WORDPRESS_FUZZ_RUNTIME_CONTRACT_SCHEMA = "wp-codebox/wordpress-fuzz-runtime-contract/v1"; +export const PHP_IN_PROCESS_FUZZ_SUITE_RUNNER_CAPABILITIES = { + schema: FUZZ_RUNNER_CAPABILITIES_SCHEMA, + mode: "php-in-process", + entrypoint: "run-fuzz-suite", + capabilities: ["target:ability", "target:http", "target:rest"], + targetKinds: ["ability", "http", "rest"], + operationKinds: ["read"], + unsupportedRequiredCapabilities: [], +}; +export const RUNTIME_BACKED_FUZZ_SUITE_RUNNER_CAPABILITIES = { + schema: FUZZ_RUNNER_CAPABILITIES_SCHEMA, + mode: "runtime-backed", + entrypoint: "run-fuzz-suite --runner-mode=runtime-backed", + capabilities: [ + "target:ability", + "target:command", + "target:http", + "target:rest", + "target:runtime", + "target:runtime-action", + "runtime", + "disposable-runtime", + "runtime-isolation", + "disposable-sandbox-boundary", + "destructive-permission", + "runtime-action:admin_page", + "runtime-action:browser", + "runtime-action:browser_probe", + "runtime-action:random_walk", + "runtime-action:crud_operation", + "runtime-action:db_operation", + "runtime-action:editor_actions", + "runtime-action:editor_open", + "runtime-action:editor_validate_blocks", + "runtime-action:page", + "runtime-action:php", + "runtime-action:rest_request", + "runtime-action:sequence", + "runtime-action:wp_cli", + "runtime-action:wordpress_hook", + "runtime-action:wordpress_cron_event", + "db_operation", + "rest-mutation:fixture-opt-in", + "mutation-isolation-artifact", + "cache-churn-observation", + "delete-boundary-artifact", + "sandbox-isolation-proof", + "destructive-sandbox-proof", + "reset-evidence", + "external-http-guardrail", + "external-side-effect-guardrail", + "artifact-export", + "wordpress-db-write-set-artifact", + "rest-mutation:post:mutation-isolation-artifact", + "rest-mutation:put:mutation-isolation-artifact", + "rest-mutation:patch:mutation-isolation-artifact", + "rest-mutation:delete:delete-boundary-artifact", + ], + targetKinds: ["ability", "command", "http", "rest", "runtime", "runtime-action"], + operationKinds: ["read", "crud", "mutation-isolation", "delete-boundary"], + runtimeActionTypes: ["admin_page", "browser", "browser_probe", "crud_operation", "db_operation", "editor_actions", "editor_open", "editor_validate_blocks", "page", "php", "random_walk", "rest_request", "sequence", "wp_cli", "wordpress_hook", "wordpress_cron_event"], + commands: ["wp-codebox.checkpoint-create", "wp-codebox.checkpoint-list", "wp-codebox.checkpoint-restore", "wordpress.ability", "wordpress.browser-actions", "wordpress.browser-page-load", "wordpress.browser-probe", "wordpress.cache-churn-observation", "wordpress.collect-workload-result", "wordpress.crud-operation", "wordpress.db-operation", "wordpress.editor-actions", "wordpress.editor-open", "wordpress.editor-validate-blocks", "wordpress.execution-surfaces", "wordpress.fuzz-admin-pages", "wordpress.fuzz-plugin-module-state", "wordpress.http-request", "wordpress.inventory-plugin-module-options-tables", "wordpress.invoke-cron-event", "wordpress.invoke-hook", "wordpress.invoke-wp-cli", "wordpress.rest-performance-observation", "wordpress.rest-request", "wordpress.run-php", "wordpress.run-workload", "wordpress.server-page-load", "wordpress.simulated-admin-page-load", "wordpress.simulated-frontend-page-load", "wordpress.wp-cli"], + unsupportedRequiredCapabilities: [], +}; +export const WORDPRESS_FUZZ_RUNTIME_CONTRACT = { + schema: WORDPRESS_FUZZ_RUNTIME_CONTRACT_SCHEMA, + version: 1, + runtime: { + id: "wp-codebox", + environment: "wordpress", + }, + publicSurfaces: { + phpFacade: "WP_Codebox_API::wordpress_fuzz_runtime_contract()", + ability: "wp-codebox/run-fuzz-suite", + wpCli: "wp codebox wordpress-fuzz-runtime-contract", + nodeCli: "wp-codebox fuzz descriptor --format=json", + typescript: "@automattic/wp-codebox-core/contracts", + }, + actionFamilies: [ + { + id: "ability-http-rest-read", + label: "Ability, HTTP, and REST read coverage", + targetKinds: ["ability", "http", "rest"], + runtimeActionTypes: [], + commands: ["wordpress.ability", "wordpress.http-request", "wordpress.rest-request"], + mutationIntents: ["read"], + supported: true, + }, + { + id: "runtime-browser-admin", + label: "Runtime browser, admin page, editor, and page coverage", + targetKinds: ["runtime", "runtime-action"], + runtimeActionTypes: ["admin_page", "browser", "browser_probe", "editor_actions", "editor_open", "editor_validate_blocks", "page", "random_walk", "sequence"], + commands: ["wordpress.browser-actions", "wordpress.browser-page-load", "wordpress.browser-probe", "wordpress.editor-actions", "wordpress.editor-open", "wordpress.editor-validate-blocks", "wordpress.fuzz-admin-pages", "wordpress.page", "wordpress.simulated-admin-page-load", "wordpress.simulated-frontend-page-load"], + mutationIntents: ["read", "write"], + supported: true, + }, + { + id: "runtime-wordpress-operations", + label: "WordPress CLI, PHP, REST, CRUD, and database operation coverage", + targetKinds: ["command", "runtime", "runtime-action"], + runtimeActionTypes: ["crud_operation", "db_operation", "php", "rest_request", "wp_cli", "wordpress_hook", "wordpress_cron_event"], + commands: ["wordpress.cache-churn-observation", "wordpress.collect-workload-result", "wordpress.crud-operation", "wordpress.db-operation", "wordpress.execution-surfaces", "wordpress.inventory-plugin-module-options-tables", "wordpress.invoke-cron-event", "wordpress.invoke-hook", "wordpress.invoke-wp-cli", "wordpress.rest-performance-observation", "wordpress.rest-request", "wordpress.run-php", "wordpress.run-workload", "wordpress.wp-cli"], + mutationIntents: ["read", "write", "delete", "destructive"], + supported: true, + }, + ], + resetModes: [ + { + id: "none", + supported: true, + optionalForMutationIntents: ["read", "write", "delete", "destructive"], + artifactKinds: [], + }, + { + id: "checkpoint-per-case", + supported: true, + optionalForMutationIntents: ["write", "delete", "destructive"], + artifactKinds: ["mutation-isolation-artifact", "delete-boundary-artifact", "wordpress-db-write-set", "reset-evidence"], + }, + { + id: "restore-snapshot", + supported: false, + optionalForMutationIntents: ["write", "delete", "destructive"], + artifactKinds: ["reset-evidence"], + }, + ], + artifactExpectations: [ + { + id: "fuzz-suite-result", + required: true, + schema: FUZZ_SUITE_RESULT_SCHEMA, + producedBy: ["run-fuzz-suite"], + description: "Every fuzz run returns a structured suite result envelope with case summaries, diagnostics, and artifact references.", + }, + { + id: "mutation-isolation-artifact", + required: true, + schema: "wp-codebox/mutation-isolation-artifact/v1", + producedBy: ["rest-mutation:post", "rest-mutation:put", "rest-mutation:patch"], + description: "Mutating REST coverage records the explicit fixture or disposable sandbox boundary and artifact evidence for the mutation.", + }, + { + id: "delete-boundary-artifact", + required: true, + schema: "wp-codebox/delete-boundary-artifact/v1", + producedBy: ["rest-mutation:delete"], + description: "Delete coverage records the explicit delete boundary artifact inside a disposable sandbox instead of advertising unbounded raw delete support.", + }, + { + id: "wordpress-db-write-set", + required: true, + schema: "wp-codebox/wordpress-db-write-set/v1", + producedBy: ["rest-mutation", "crud-operation", "db-operation", "admin-action"], + description: "Destructive fuzz cases emit per-case database write ledgers for relative write-amplification and hotspot discovery.", + }, + { + id: "cache-churn-observation", + required: false, + schema: "wp-codebox/cache-churn-observation/v1", + producedBy: ["wordpress.cache-churn-observation"], + description: "Optional destructive fuzzing evidence that correlates a case/action with transient, site transient, option, autoload, and explicitly unsupported object-cache churn fields.", + }, + { + id: "destructive-sandbox-proof", + required: true, + schema: "wp-codebox/destructive-sandbox-proof/v1", + producedBy: ["run-fuzz-suite"], + description: "Destructive fuzz runs require runtime-created sandbox proof; caller metadata cannot satisfy destructive isolation by itself.", + }, + { + id: "reset-evidence", + required: false, + schema: "wp-codebox/fuzz-suite-reset-result/v1", + producedBy: ["checkpoint-per-case", "restore-snapshot"], + description: "Reset modes report passed, failed, or unsupported evidence explicitly; unsupported snapshot restore is a fail-closed result, not simulated reset success.", + }, + ], + destructiveModeRequirements: { + supported: true, + destructiveMutationIntent: "destructive", + requiredSandboxBoundary: { + disposable: true, + destructivePermission: true, + teardown: "discard", + }, + requiredSandboxProof: { + schema: "wp-codebox/destructive-sandbox-proof/v1", + boundarySource: "runtime-created", + }, + optionalResetModes: ["checkpoint-per-case", "restore-snapshot"], + requiredArtifacts: ["destructive-sandbox-proof", "mutation-isolation-artifact", "delete-boundary-artifact", "wordpress-db-write-set"], + deleteBoundaryCapability: "delete-boundary-artifact", + rawDeleteCapability: null, + }, + unsupportedCapabilities: [ + { + id: "raw-delete", + reason: "WordPress fuzz runtime delete coverage is only supported through explicit delete-boundary artifacts.", + replacement: "delete-boundary-artifact", + }, + { + id: "restore-snapshot-reset", + reason: "Snapshot restore is an optional reset convenience, not destructive fuzz correctness proof.", + replacement: "disposable-sandbox-boundary", + }, + { + id: "private-runtime-probing", + reason: "Consumers must read this descriptor instead of probing private runtime commands or implementation capabilities.", + }, + ], + hbex: { + schemaIds: { + descriptor: WORDPRESS_FUZZ_RUNTIME_CONTRACT_SCHEMA, + fuzzSuite: FUZZ_SUITE_SCHEMA, + fuzzSuiteResult: FUZZ_SUITE_RESULT_SCHEMA, + fuzzRunnerCapabilities: FUZZ_RUNNER_CAPABILITIES_SCHEMA, + fuzzRunnerReadiness: FUZZ_RUNNER_READINESS_SCHEMA, + fuzzCoveragePlan: "wp-codebox/fuzz-coverage-plan/v1", + fuzzMinimizeCaseInput: "wp-codebox/fuzz-minimize-case-input/v1", + fuzzMinimizeCaseResult: "wp-codebox/fuzz-minimize-case-result/v1", + fuzzFixturePlan: "wp-codebox/fuzz-fixture-plan/v1", + restMutationFixtureOptIn: "wp-codebox/rest-mutation-fixture-opt-in/v1", + restMutationGeneratedFixtures: "wp-codebox/rest-mutation-generated-fixtures/v1", + mutationIsolationArtifact: "wp-codebox/mutation-isolation-artifact/v1", + deleteBoundaryArtifact: "wp-codebox/delete-boundary-artifact/v1", + wordpressDbWriteSet: "wp-codebox/wordpress-db-write-set/v1", + cacheChurnObservation: "wp-codebox/cache-churn-observation/v1", + wordpressWorkloadRun: "wp-codebox/wordpress-workload-run/v1", + }, + }, +}; +export function wordpressFuzzRuntimeContract() { + return WORDPRESS_FUZZ_RUNTIME_CONTRACT; +} +export function fuzzSuiteContract(input) { + return stripUndefined({ + schema: FUZZ_SUITE_SCHEMA, + id: input.id, + version: input.version, + target: input.target, + resetPolicy: input.resetPolicy, + reset_policy: input.reset_policy, + mutation: input.mutation, + mutation_intent: input.mutation_intent, + cases: input.cases ?? [], + coveragePlan: input.coveragePlan, + metadata: input.metadata, + }); +} +export function fuzzSuiteResultEnvelope(input) { + const cases = (input.cases ?? []).map(normalizeCaseResult); + const diagnostics = [...(input.diagnostics ?? [])]; + const artifactRefs = dedupeArtifactRefs([...(input.artifactRefs ?? []), ...cases.flatMap((item) => [...(item.artifactRefs ?? []), ...(item.reset?.artifactRefs ?? [])])]); + const summary = summarizeFuzzCases(cases); + const coverageSummary = input.coverageSummary ?? summarizeFuzzCoverage({ discovered: fuzzSuiteDiscoveredCount(input.suite, cases.length), cases }); + const coveragePlan = input.coveragePlan ?? fuzzSuiteResultCoveragePlan(input.suite, cases); + const contractDiagnostics = fuzzSuiteContractDiagnostics({ suite: input.suite, cases, artifactRefs, coverageSummary }); + diagnostics.push(...contractDiagnostics); + const hasRequiredCoverageError = diagnostics.some((diagnostic) => diagnostic.code === "fuzz_suite_required_runner_capabilities_unsupported" || diagnostic.code === "fuzz_suite_required_coverage_unsupported"); + const status = summary.error > 0 || hasRequiredCoverageError || contractDiagnostics.length > 0 ? "error" : summary.failed > 0 ? "failed" : summary.skipped === summary.total && summary.total > 0 ? "skipped" : "passed"; + return stripUndefined({ + schema: FUZZ_SUITE_RESULT_SCHEMA, + suite: stripUndefined({ id: input.suite.id, version: input.suite.version }), + status, + success: status === "passed", + summary, + coverageSummary, + coveragePlan, + cases, + diagnostics, + artifactRefs, + metadata: input.metadata, + }); +} +export function fuzzReplayCaseRef(input) { + return stripUndefined({ + schema: FUZZ_REPLAY_CASE_REF_SCHEMA, + caseId: input.caseId, + path: input.path, + kind: input.kind ?? "fuzz-replay-case", + contentType: input.contentType ?? "application/json", + sha256: input.sha256, + bytes: input.bytes, + target: input.target, + status: input.status, + metadata: input.metadata, + }); +} +export function fuzzMinimizeUnsupportedCapability(input) { + return stripUndefined({ + schema: FUZZ_MINIMIZE_CAPABILITY_SCHEMA, + status: "unsupported", + inputKind: "fuzz-replay-case", + reason: input.reason, + requiredArtifacts: input.requiredArtifacts, + metadata: input.metadata, + }); +} +export function fuzzMinimizeSupportedCapability(input) { + return stripUndefined({ + schema: FUZZ_MINIMIZE_CAPABILITY_SCHEMA, + status: "supported", + inputKind: "fuzz-replay-case", + operation: input.operation, + requiredArtifacts: input.requiredArtifacts, + metadata: input.metadata, + }); +} +export function fuzzArtifactBundleContract(input) { + return stripUndefined({ + schema: FUZZ_ARTIFACT_BUNDLE_SCHEMA, + suiteId: input.suiteId, + path: input.path, + manifestPath: input.manifestPath, + resultRef: input.resultRef, + caseResultStreamRef: input.caseResultStreamRef, + replayCaseRefs: input.replayCaseRefs, + hotspotRefs: input.hotspotRefs, + minimize: input.minimize, + artifactRefs: input.artifactRefs, + metadata: input.metadata, + }); +} +export function fuzzSuiteRequiredRunnerCapabilities(suite) { + const metadata = fuzzSuiteMetadata(suite); + const required = recordField(metadata, "requiredRunnerCapabilities") ?? recordField(metadata, "required_runner_capabilities"); + return fuzzRunnerRequiredCapabilities(required, metadata); +} +export function fuzzRunnerCapabilitiesContract(input, required) { + const requiredCapabilities = Array.isArray(required) + ? [...required] + : isFuzzSuiteContract(required) + ? fuzzSuiteRequiredRunnerCapabilities(required) + : fuzzRunnerRequiredCapabilities(required); + return stripUndefined({ + schema: FUZZ_RUNNER_CAPABILITIES_SCHEMA, + mode: input.mode, + entrypoint: input.entrypoint, + capabilities: dedupeStrings(input.capabilities), + targetKinds: dedupeStrings(input.targetKinds), + operationKinds: input.operationKinds ? dedupeStrings(input.operationKinds) : undefined, + runtimeActionTypes: input.runtimeActionTypes ? dedupeStrings(input.runtimeActionTypes) : undefined, + commands: input.commands ? dedupeStrings(input.commands) : undefined, + unsupportedRequiredCapabilities: unsupportedRequiredFuzzRunnerCapabilities(requiredCapabilities, input), + metadata: input.metadata, + }); +} +export function fuzzRunnerReadinessContract(input, required) { + const capabilities = fuzzRunnerCapabilitiesContract(input, required); + const unsupportedRequiredCapabilities = capabilities.unsupportedRequiredCapabilities; + const status = unsupportedRequiredCapabilities.length > 0 ? "unsupported" : "ready"; + return stripUndefined({ + schema: FUZZ_RUNNER_READINESS_SCHEMA, + status, + entrypoint: input.entrypoint ?? "run-fuzz-suite", + mode: input.mode, + capabilities, + operationKinds: capabilities.operationKinds ?? [], + unsupportedRequiredCapabilities, + ...(input.mode === "runtime-backed" ? { + disposable: true, + isolation: { runtime_backed: true, disposable: true, sandboxed: true }, + guardrails: { external_side_effect_guardrail: true, external_http_guardrail: true }, + artifacts: { artifact_export: true }, + destructiveModeRequirements: WORDPRESS_FUZZ_RUNTIME_CONTRACT.destructiveModeRequirements, + } : {}), + metadata: input.metadata, + }); +} +export function unsupportedRequiredFuzzRunnerCapabilities(required, runnerCapabilities) { + const requiredCapabilities = Array.isArray(required) + ? [...required] + : isFuzzSuiteContract(required) + ? fuzzSuiteRequiredRunnerCapabilities(required) + : fuzzRunnerRequiredCapabilities(required); + const available = new Set([ + ...runnerCapabilities.capabilities, + ...runnerCapabilities.targetKinds.map((kind) => `target:${kind}`), + ...(runnerCapabilities.runtimeActionTypes ?? []).map((type) => `runtime-action:${type}`), + ...(runnerCapabilities.commands ?? []).map((command) => `command:${command}`), + ]); + return requiredCapabilities.filter((capability) => !available.has(capability)); +} +function fuzzRunnerRequiredCapabilities(required, metadata) { + const requiredRecord = isRecord(required) ? required : undefined; + return dedupeStrings([ + ...stringArrayField(requiredRecord, "capabilities"), + ...stringArrayField(requiredRecord, "targetKinds").map((kind) => `target:${kind}`), + ...stringArrayField(requiredRecord, "target_kinds").map((kind) => `target:${kind}`), + ...stringArrayField(requiredRecord, "runtimeActionTypes").map((type) => `runtime-action:${type}`), + ...stringArrayField(requiredRecord, "runtime_action_types").map((type) => `runtime-action:${type}`), + ...stringArrayField(requiredRecord, "commands").map((command) => `command:${command}`), + ...stringArrayField(metadata, "requiredCapabilities"), + ...stringArrayField(metadata, "required_capabilities"), + ]); +} +export function fuzzSuiteCaseResetPolicy(suite, fuzzCase) { + const candidate = fuzzCase.resetPolicy ?? fuzzCase.reset_policy ?? suite.resetPolicy ?? suite.reset_policy; + return normalizeFuzzSuiteResetPolicy(candidate); +} +export function normalizeFuzzSuiteResetPolicy(input) { + if (typeof input === "string") { + return normalizeFuzzSuiteResetPolicyRecord({ mode: input }); + } + if (isRecord(input)) { + return normalizeFuzzSuiteResetPolicyRecord(input); + } + return { mode: "none" }; +} +export function fuzzSuiteResetPolicyDiagnostics(input, caseId) { + const diagnostics = []; + const policy = normalizeFuzzSuiteResetPolicy(input); + if (!isFuzzSuiteResetMode(policy.mode)) { + diagnostics.push({ + severity: "error", + code: "fuzz_suite_reset_policy_invalid_mode", + caseId, + message: `Fuzz suite reset policy mode is not supported: ${String(policy.mode)}.`, + metadata: { supportedModes: ["none", "checkpoint-per-case", "restore-snapshot"] }, + }); + } + if (policy.mode === "restore-snapshot" && !policy.snapshotRef && !policy.snapshot_ref) { + diagnostics.push({ + severity: "error", + code: "fuzz_suite_reset_policy_snapshot_ref_required", + caseId, + message: "Fuzz suite reset policy mode restore-snapshot requires snapshotRef or snapshot_ref.", + }); + } + return diagnostics; +} +function isFuzzSuiteContract(value) { + return isRecord(value) && value.schema === FUZZ_SUITE_SCHEMA; +} +export function summarizeFuzzCases(cases) { + const summary = { total: cases.length, passed: 0, failed: 0, error: 0, skipped: 0 }; + for (const item of cases) { + if (item.status === "passed") + summary.passed += 1; + else if (item.status === "failed") + summary.failed += 1; + else if (item.status === "error") + summary.error += 1; + else if (item.status === "skipped") + summary.skipped += 1; + } + return summary; +} +export function summarizeFuzzCoverage(input) { + const skippedReasons = new Map(); + let executed = 0; + let skipped = 0; + for (const item of input.cases) { + if (item.status === "skipped") { + skipped += 1; + const reason = item.skipReason ?? item.diagnostics[0]?.code ?? item.diagnostics[0]?.message ?? "unspecified"; + const existing = skippedReasons.get(reason) ?? { count: 0, caseIds: [] }; + existing.count += 1; + existing.caseIds.push(item.id); + skippedReasons.set(reason, existing); + } + else { + executed += 1; + } + } + return { + discovered: input.discovered, + generated: input.cases.length, + executed, + skipped, + untested: Math.max(input.discovered - input.cases.length, 0), + skippedReasons: [...skippedReasons.entries()].map(([reason, value]) => ({ reason, count: value.count, caseIds: value.caseIds })), + }; +} +function normalizeCaseResult(input) { + return stripUndefined({ + id: input.id, + status: input.status, + success: input.status === "passed", + target: input.target, + reset: input.reset, + skipReason: input.status === "skipped" ? input.skipReason ?? input.diagnostics?.[0]?.code ?? input.diagnostics?.[0]?.message : undefined, + diagnostics: input.diagnostics ?? [], + artifactRefs: input.artifactRefs, + metadata: input.metadata, + }); +} +function fuzzSuiteResultCoveragePlan(suite, cases) { + const basePlan = fuzzSuiteCoveragePlan(suite); + const suiteCases = "cases" in suite && Array.isArray(suite.cases) ? suite.cases : []; + if (basePlan || suiteCases.length > 0 || cases.length > 0) { + const baseItems = new Map((basePlan?.generated.length ? basePlan.generated : basePlan?.discovered ?? []).map((item) => [item.id, item])); + const generated = basePlan?.generated.length ? basePlan.generated : suiteCases.map(fuzzSuiteCaseCoveragePlanItem); + const executed = cases.filter((item) => item.status !== "skipped").map((item) => fuzzSuiteCaseResultCoveragePlanItem(item, baseItems.get(item.id))); + const skipped = cases.filter((item) => item.status === "skipped").map((item) => fuzzSuiteCaseResultCoveragePlanItem(item, baseItems.get(item.id))); + return fuzzCoveragePlanContract({ + id: basePlan?.id ?? `${suite.id}-coverage-plan`, + version: basePlan?.version ?? suite.version, + discovered: basePlan?.discovered ?? generated, + generated, + executable: basePlan?.executable ?? generated, + executed, + skipped: [...(basePlan?.skipped ?? []), ...skipped.filter((item) => !basePlan?.skipped.some((baseItem) => baseItem.id === item.id))], + untested: basePlan?.untested, + parameterGenerationHooks: basePlan?.parameterGenerationHooks, + metadata: basePlan?.metadata, + }); + } + return undefined; +} +function fuzzSuiteCoveragePlan(suite) { + if ("coveragePlan" in suite && suite.coveragePlan?.schema === "wp-codebox/fuzz-coverage-plan/v1") + return suite.coveragePlan; + const metadataCoveragePlan = recordField(fuzzSuiteMetadata(suite), "coveragePlan") ?? recordField(fuzzSuiteMetadata(suite), "coverage_plan"); + return metadataCoveragePlan?.schema === "wp-codebox/fuzz-coverage-plan/v1" ? metadataCoveragePlan : undefined; +} +function fuzzSuiteCaseCoveragePlanItem(fuzzCase) { + return stripUndefined({ + id: fuzzCase.id, + target: fuzzCase.target, + description: fuzzCase.description, + input: fuzzCase.input, + metadata: stripUndefined({ ...fuzzCase.metadata, mutation: fuzzCase.mutation, mutation_intent: fuzzCase.mutation_intent }), + }); +} +function fuzzSuiteCaseResultCoveragePlanItem(result, base) { + return stripUndefined({ + ...base, + id: result.id, + target: result.target ?? base?.target, + reason: result.status === "skipped" ? { code: result.skipReason ?? result.diagnostics[0]?.code ?? "fuzz_suite_case_skipped", message: result.diagnostics[0]?.message ?? `Fuzz suite case ${result.id} was skipped.`, data: result.diagnostics[0]?.metadata } : base?.reason, + metadata: stripUndefined({ ...base?.metadata, status: result.status }), + }); +} +function normalizeFuzzSuiteResetPolicyRecord(input) { + const fixtureRefs = [...stringArrayField(input, "fixtureRefs"), ...stringArrayField(input, "fixture_refs")]; + return stripUndefined({ + mode: typeof input.mode === "string" ? input.mode : "none", + checkpointName: typeof input.checkpointName === "string" ? input.checkpointName : undefined, + checkpoint_name: typeof input.checkpoint_name === "string" ? input.checkpoint_name : undefined, + snapshotRef: typeof input.snapshotRef === "string" ? input.snapshotRef : undefined, + snapshot_ref: typeof input.snapshot_ref === "string" ? input.snapshot_ref : undefined, + fixtureRefs: fixtureRefs.length > 0 ? fixtureRefs : undefined, + metadata: recordField(input, "metadata"), + }); +} +function isFuzzSuiteResetMode(mode) { + return mode === "none" || mode === "checkpoint-per-case" || mode === "restore-snapshot"; +} +function fuzzSuiteDiscoveredCount(suite, fallback) { + return "cases" in suite && Array.isArray(suite.cases) ? suite.cases.length : fallback; +} +function fuzzSuiteContractDiagnostics(input) { + if (fuzzSuiteAllowsEmpty(input.suite)) { + return []; + } + const diagnostics = []; + const requiredArtifacts = fuzzSuiteRequiredArtifactDeclarations(input.suite); + const expectsCoverage = fuzzSuiteExpectsNonEmptyCoverage(input.suite, input.coverageSummary); + if (input.cases.length === 0 && (requiredArtifacts.length > 0 || expectsCoverage)) { + diagnostics.push({ + severity: "error", + code: "fuzz_suite_empty_cases_for_declared_contract", + message: `Fuzz suite ${input.suite.id} produced no cases for a contract that declares required artifacts or non-empty coverage.`, + metadata: stripUndefined({ requiredArtifacts: requiredArtifacts.map((artifact) => artifact.name ?? artifact.path ?? artifact.semantic_key ?? artifact.kind), expectsCoverage }), + }); + } + if (requiredArtifacts.length > 0 && input.artifactRefs.length === 0) { + diagnostics.push({ + severity: "error", + code: "fuzz_suite_required_artifacts_missing", + message: `Fuzz suite ${input.suite.id} produced no artifacts for a contract with required artifact declarations.`, + metadata: { requiredArtifacts: requiredArtifacts.map((artifact) => artifact.name ?? artifact.path ?? artifact.semantic_key ?? artifact.kind) }, + }); + } + return diagnostics; +} +function fuzzSuiteAllowsEmpty(suite) { + const metadata = fuzzSuiteMetadata(suite); + const readiness = recordField(metadata, "readiness"); + const genericPrimitive = recordField(metadata, "generic_primitive") ?? recordField(metadata, "genericPrimitive"); + return booleanField(metadata, "allow_empty") === true + || booleanField(metadata, "allowed_empty") === true + || booleanField(metadata, "allowEmpty") === true + || booleanField(metadata, "declared_only") === true + || booleanField(metadata, "declaredOnly") === true + || readiness?.level === "declared" + || readiness?.declared_only === true + || readiness?.declaredOnly === true + || genericPrimitive?.status === "blocked"; +} +function fuzzSuiteExpectsNonEmptyCoverage(suite, coverageSummary) { + if (coverageSummary.discovered > 0) { + return true; + } + const coverage = recordField(fuzzSuiteMetadata(suite), "coverage"); + return nonEmptyArrayField(coverage, "surface_ids") + || nonEmptyArrayField(coverage, "surfaceIds") + || nonEmptyArrayField(coverage, "operations") + || numberField(coverage, "expected") > 0 + || numberField(coverage, "discovered") > 0; +} +function fuzzSuiteRequiredArtifactDeclarations(suite) { + const metadata = fuzzSuiteMetadata(suite); + const artifacts = recordField(metadata, "artifacts"); + const candidates = [ + ...arrayField(artifacts, "expected"), + ...arrayField(artifacts, "required"), + ...arrayField(metadata, "artifact_declarations"), + ...arrayField(metadata, "artifactDeclarations"), + ...arrayField(metadata, "expected_artifacts"), + ...arrayField(metadata, "expectedArtifacts"), + ]; + return candidates.filter((item) => isRecord(item) && item.required === true); +} +function fuzzSuiteMetadata(suite) { + return "metadata" in suite && isRecord(suite.metadata) ? suite.metadata : undefined; +} +function recordField(source, key) { + const value = source?.[key]; + return isRecord(value) ? value : undefined; +} +function arrayField(source, key) { + const value = source?.[key]; + return Array.isArray(value) ? value : []; +} +function nonEmptyArrayField(source, key) { + return arrayField(source, key).length > 0; +} +function stringArrayField(source, key) { + return arrayField(source, key).filter((item) => typeof item === "string" && item.length > 0); +} +function dedupeStrings(values) { + return [...new Set(values)]; +} +function booleanField(source, key) { + const value = source?.[key]; + return typeof value === "boolean" ? value : undefined; +} +function numberField(source, key) { + const value = source?.[key]; + return typeof value === "number" ? value : 0; +} +function isRecord(value) { + return Boolean(value) && typeof value === "object" && !Array.isArray(value); +} +function dedupeArtifactRefs(refs) { + const seen = new Set(); + const output = []; + for (const ref of refs) { + const key = `${ref.kind}:${ref.path}:${ref.sha256 ?? ""}`; + if (seen.has(key)) + continue; + seen.add(key); + output.push(ref); + } + return output; +} +//# sourceMappingURL=fuzz-suite-contracts.js.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/fuzz-suite-contracts.js.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/fuzz-suite-contracts.js.map new file mode 100644 index 000000000..989d4b183 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/fuzz-suite-contracts.js.map @@ -0,0 +1 @@ +{"version":3,"file":"fuzz-suite-contracts.js","sourceRoot":"","sources":["../src/fuzz-suite-contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,wBAAwB,EAA4D,MAAM,mCAAmC,CAAA;AAEtI,MAAM,CAAC,MAAM,iBAAiB,GAAG,0BAAmC,CAAA;AACpE,MAAM,CAAC,MAAM,wBAAwB,GAAG,iCAA0C,CAAA;AAClF,MAAM,CAAC,MAAM,+BAA+B,GAAG,wCAAiD,CAAA;AAChG,MAAM,CAAC,MAAM,4BAA4B,GAAG,qCAA8C,CAAA;AAC1F,MAAM,CAAC,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;AACf,CAAC"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/host-tool-registry.d.ts b/packages/runtime-cloudflare/vendor/wp-codebox-core/host-tool-registry.d.ts new file mode 100644 index 000000000..6e603a41f --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/host-tool-registry.d.ts @@ -0,0 +1,121 @@ +export declare const HOST_TOOL_RESULT_SCHEMA: "wp-codebox/host-tool-result/v1"; +export type JsonValue = null | boolean | number | string | JsonValue[] | { + [key: string]: JsonValue; +}; +export type JsonObject = { + [key: string]: JsonValue; +}; +export interface HostToolJsonSchema { + type?: "object" | "array" | "string" | "number" | "integer" | "boolean" | "null"; + required?: string[]; + properties?: Record; + additionalProperties?: boolean; + items?: HostToolJsonSchema; +} +export interface HostToolPolicyMetadata { + capability?: string; + permissions?: string[]; + risk?: "read" | "write" | "external" | (string & {}); + description?: string; +} +export type HostToolRuntimeMetadata = JsonObject; +export interface HostToolCanonicalDeclaration { + name: string; + source?: string; + description: string; + parameters?: HostToolJsonSchema; + executor?: "client"; + scope?: "run"; + runtime?: HostToolRuntimeMetadata; +} +export interface HostToolCallContext { + tool: string; + policyCommand: string; + metadata?: Record; +} +export type HostToolHandler = (input: JsonValue, context: HostToolCallContext) => Promise | JsonValue; +export interface HostToolDefinition { + /** + * Canonical per-run tool declaration supplied by the caller. Codebox treats + * this as transport input; Agents API owns the generic declaration contract. + */ + declaration?: HostToolCanonicalDeclaration; + name: string; + description: string; + parameters?: HostToolJsonSchema; + inputSchema?: HostToolJsonSchema; + outputSchema: HostToolJsonSchema; + policy: HostToolPolicyMetadata; + runtime?: HostToolRuntimeMetadata; + handler: HostToolHandler; +} +export interface HostToolCanonicalResultOk { + success: true; + tool_name: string; + result: JsonValue; + metadata: JsonObject; + runtime?: HostToolRuntimeMetadata; +} +export interface HostToolCanonicalResultError { + success: false; + tool_name: string; + error: string; + metadata: JsonObject; + runtime?: HostToolRuntimeMetadata; +} +export type HostToolCanonicalResult = HostToolCanonicalResultOk | HostToolCanonicalResultError; +export interface HostToolResultOk { + schema: typeof HOST_TOOL_RESULT_SCHEMA; + tool: string; + status: "ok"; + output: JsonValue; + toolResult: HostToolCanonicalResultOk; + diagnostics: HostToolTransportDiagnostics; + startedAt: string; + finishedAt: string; +} +export interface HostToolResultError { + schema: typeof HOST_TOOL_RESULT_SCHEMA; + tool: string; + status: "error"; + error: { + code: string; + message: string; + details?: JsonValue; + }; + toolResult: HostToolCanonicalResultError; + diagnostics: HostToolTransportDiagnostics; + startedAt: string; + finishedAt: string; +} +export type HostToolResult = HostToolResultOk | HostToolResultError; +export interface HostToolCatalogEntry { + /** Agents API-shaped declaration exposed to sandbox agents. */ + declaration: HostToolCanonicalDeclaration; + name: string; + description: string; + parameters: HostToolJsonSchema; + inputSchema: HostToolJsonSchema; + outputSchema: HostToolJsonSchema; + policy: HostToolPolicyMetadata; +} +export interface HostToolTransportDiagnostics { + transport: "wp-codebox-host-tool"; + resultSchema: typeof HOST_TOOL_RESULT_SCHEMA; + policyCommand: string; + inputSchema: HostToolJsonSchema; + outputSchema: HostToolJsonSchema; + policy: HostToolPolicyMetadata; +} +export declare class HostToolRegistry { + private readonly tools; + constructor(definitions?: HostToolDefinition[]); + register(definition: HostToolDefinition): void; + get(name: string): HostToolDefinition | undefined; + has(name: string): boolean; + list(): HostToolCatalogEntry[]; +} +export declare function createHostToolRegistry(definitions?: HostToolDefinition[]): HostToolRegistry; +export declare function executeHostTool(definition: HostToolDefinition, input: JsonValue, context: HostToolCallContext): Promise; +export declare function createHostToolTransportError(definition: HostToolDefinition | string, policyCommand: string, startedAt: string, code: string, message: string, details?: JsonValue): HostToolResultError; +//# sourceMappingURL=host-tool-registry.d.ts.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/host-tool-registry.d.ts.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/host-tool-registry.d.ts.map new file mode 100644 index 000000000..4af85aa54 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/host-tool-registry.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"host-tool-registry.d.ts","sourceRoot":"","sources":["../src/host-tool-registry.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,EAAG,gCAAyC,CAAA;AAEhF,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,EAAE,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAA;AACrG,MAAM,MAAM,UAAU,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAA;AAErD,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,CAAA;IAChF,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAA;IAC/C,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,KAAK,CAAC,EAAE,kBAAkB,CAAA;CAC3B;AAED,MAAM,WAAW,sBAAsB;IACrC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;IACpD,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,MAAM,uBAAuB,GAAG,UAAU,CAAA;AAEhD,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,kBAAkB,CAAA;IAC/B,QAAQ,CAAC,EA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AAC,KAAK,CAAwC;gBAElD,WAAW,GAAE,kBAAkB,EAAO;IAMlD,QAAQ,CAAC,UAAU,EAAE,kBAAkB,GAAG,IAAI;IAQ9C,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAIjD,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B,IAAI,IAAI,oBAAoB,EAAE;CAc/B;AAED,wBAAgB,sBAAsB,CAAC,WAAW,GAAE,kBAAkB,EAAO,GAAG,gBAAgB,CAE/F;AAED,wBAAsB,eAAe,CAAC,UAAU,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,cAAc,CAAC,CA2B7I;AAED,wBAAgB,4BAA4B,CAAC,UAAU,EAAE,kBAAkB,GAAG,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,GAAG,mBAAmB,CAEvM"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/host-tool-registry.js b/packages/runtime-cloudflare/vendor/wp-codebox-core/host-tool-registry.js new file mode 100644 index 000000000..bbb4c66e3 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/host-tool-registry.js @@ -0,0 +1,236 @@ +export const HOST_TOOL_RESULT_SCHEMA = "wp-codebox/host-tool-result/v1"; +export class HostToolRegistry { + tools = new Map(); + constructor(definitions = []) { + for (const definition of definitions) { + this.register(definition); + } + } + register(definition) { + assertValidHostToolDefinition(definition); + if (this.tools.has(definition.name)) { + throw new Error(`Host tool is already registered: ${definition.name}`); + } + this.tools.set(definition.name, definition); + } + get(name) { + return this.tools.get(name); + } + has(name) { + return this.tools.has(name); + } + list() { + return [...this.tools.values()].map((definition) => { + const declaration = canonicalDeclarationForHostTool(definition); + return { + declaration, + name: declaration.name, + description: declaration.description, + parameters: declaration.parameters ?? {}, + inputSchema: inputSchemaForHostTool(definition), + outputSchema: definition.outputSchema, + policy: definition.policy, + }; + }); + } +} +export function createHostToolRegistry(definitions = []) { + return new HostToolRegistry(definitions); +} +export async function executeHostTool(definition, input, context) { + const startedAt = new Date().toISOString(); + const inputIssue = validateJsonValueAgainstSchema(input, inputSchemaForHostTool(definition), "input"); + if (inputIssue) { + return hostToolError(definition, context.policyCommand, startedAt, "host-tool-invalid-input", inputIssue); + } + try { + const output = await definition.handler(input, context); + const outputIssue = validateJsonValueAgainstSchema(output, definition.outputSchema, "output"); + if (outputIssue) { + return hostToolError(definition, context.policyCommand, startedAt, "host-tool-invalid-output", outputIssue); + } + return { + schema: HOST_TOOL_RESULT_SCHEMA, + tool: definition.name, + status: "ok", + output, + toolResult: hostToolCanonicalSuccess(definition, output), + diagnostics: hostToolDiagnostics(definition, context.policyCommand), + startedAt, + finishedAt: new Date().toISOString(), + }; + } + catch (error) { + return hostToolError(definition, context.policyCommand, startedAt, "host-tool-handler-error", error instanceof Error ? error.message : String(error)); + } +} +export function createHostToolTransportError(definition, policyCommand, startedAt, code, message, details) { + return hostToolError(definition, policyCommand, startedAt, code, message, details); +} +function hostToolError(definition, policyCommand, startedAt, code, message, details) { + const tool = typeof definition === "string" ? definition : definition.name; + return { + schema: HOST_TOOL_RESULT_SCHEMA, + tool, + status: "error", + error: { + code, + message, + ...(details === undefined ? {} : { details }), + }, + toolResult: typeof definition === "string" + ? hostToolCanonicalError(tool, message, code, details) + : hostToolCanonicalError(definition, message, code, details), + diagnostics: typeof definition === "string" + ? hostToolDiagnosticsForUnknown(policyCommand) + : hostToolDiagnostics(definition, policyCommand), + startedAt, + finishedAt: new Date().toISOString(), + }; +} +function assertValidHostToolDefinition(definition) { + const declaration = canonicalDeclarationForHostTool(definition); + if (!declaration.name || !/^[a-z][a-z0-9_-]*\/[a-z][a-z0-9_-]*$/i.test(declaration.name)) { + throw new Error("Host tool name must be a stable canonical tool id such as client/search_docs"); + } + if (declaration.source !== sourceFromToolName(declaration.name)) { + throw new Error(`Host tool ${declaration.name} source must match its canonical name prefix`); + } + if (declaration.executor !== "client") { + throw new Error(`Host tool ${declaration.name} executor must be client`); + } + if (declaration.scope !== "run") { + throw new Error(`Host tool ${declaration.name} scope must be run`); + } + if (!declaration.description) { + throw new Error(`Host tool ${declaration.name} is missing a description`); + } + if (typeof definition.handler !== "function") { + throw new Error(`Host tool ${declaration.name} is missing a handler`); + } + definition.name = declaration.name; + definition.description = declaration.description; + definition.inputSchema = inputSchemaForHostTool(definition); +} +function canonicalDeclarationForHostTool(definition) { + const name = definition.declaration?.name ?? definition.name; + const parameters = definition.declaration?.parameters ?? definition.parameters ?? definition.inputSchema; + const runtime = definition.declaration?.runtime ?? definition.runtime; + return { + name, + source: definition.declaration?.source ?? sourceFromToolName(name), + description: definition.declaration?.description ?? definition.description, + parameters, + executor: definition.declaration?.executor ?? "client", + scope: definition.declaration?.scope ?? "run", + ...(runtime ? { runtime } : {}), + }; +} +function hostToolCanonicalSuccess(definition, result) { + const runtime = canonicalDeclarationForHostTool(definition).runtime; + return { + success: true, + tool_name: definition.name, + result, + metadata: {}, + ...(runtime ? { runtime } : {}), + }; +} +function hostToolCanonicalError(definition, error, code, details) { + const toolName = typeof definition === "string" ? definition : definition.name; + const runtime = typeof definition === "string" ? undefined : canonicalDeclarationForHostTool(definition).runtime; + return { + success: false, + tool_name: toolName, + error, + metadata: { + code, + ...(details === undefined ? {} : { details }), + }, + ...(runtime ? { runtime } : {}), + }; +} +function hostToolDiagnostics(definition, policyCommand) { + return { + transport: "wp-codebox-host-tool", + resultSchema: HOST_TOOL_RESULT_SCHEMA, + policyCommand, + inputSchema: inputSchemaForHostTool(definition), + outputSchema: definition.outputSchema, + policy: definition.policy, + }; +} +function hostToolDiagnosticsForUnknown(policyCommand) { + return { + transport: "wp-codebox-host-tool", + resultSchema: HOST_TOOL_RESULT_SCHEMA, + policyCommand, + inputSchema: {}, + outputSchema: {}, + policy: {}, + }; +} +function sourceFromToolName(name) { + return name.includes("/") ? name.split("/", 1)[0] : "client"; +} +function inputSchemaForHostTool(definition) { + return definition.declaration?.parameters ?? definition.parameters ?? definition.inputSchema ?? {}; +} +function validateJsonValueAgainstSchema(value, schema, path) { + if (schema.type && !jsonValueMatchesType(value, schema.type)) { + return `${path} must be ${schema.type}`; + } + if (schema.type === "object" || schema.properties || schema.required) { + if (!isJsonObject(value)) { + return `${path} must be object`; + } + for (const key of schema.required ?? []) { + if (!(key in value)) { + return `${path}.${key} is required`; + } + } + for (const [key, childSchema] of Object.entries(schema.properties ?? {})) { + if (key in value) { + const issue = validateJsonValueAgainstSchema(value[key], childSchema, `${path}.${key}`); + if (issue) { + return issue; + } + } + } + if (schema.additionalProperties === false) { + const allowed = new Set(Object.keys(schema.properties ?? {})); + const extra = Object.keys(value).find((key) => !allowed.has(key)); + if (extra) { + return `${path}.${extra} is not allowed`; + } + } + } + if ((schema.type === "array" || schema.items) && Array.isArray(value) && schema.items) { + for (let index = 0; index < value.length; index++) { + const issue = validateJsonValueAgainstSchema(value[index], schema.items, `${path}[${index}]`); + if (issue) { + return issue; + } + } + } + return undefined; +} +function jsonValueMatchesType(value, type) { + if (type === "null") { + return value === null; + } + if (type === "array") { + return Array.isArray(value); + } + if (type === "object") { + return isJsonObject(value); + } + if (type === "integer") { + return typeof value === "number" && Number.isInteger(value); + } + return typeof value === type; +} +function isJsonObject(value) { + return Boolean(value) && typeof value === "object" && !Array.isArray(value); +} +//# sourceMappingURL=host-tool-registry.js.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/host-tool-registry.js.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/host-tool-registry.js.map new file mode 100644 index 000000000..1ddc15f42 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/host-tool-registry.js.map @@ -0,0 +1 @@ +{"version":3,"file":"host-tool-registry.js","sourceRoot":"","sources":["../src/host-tool-registry.ts"],"names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,CAAA;IAC5B,CAAC;IACD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IAC7D,CAAC;IACD,OAAO,OAAO,KAAK,KAAK,IAAI,CAAA;AAC9B,CAAC;AAED,SAAS,YAAY,CAAC,KAAgB;IACpC,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC7E,CAAC"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/object-utils.d.ts b/packages/runtime-cloudflare/vendor/wp-codebox-core/object-utils.d.ts new file mode 100644 index 000000000..8ba34b0fd --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/object-utils.d.ts @@ -0,0 +1,15 @@ +export declare function isPlainObject(value: unknown): value is Record; +export declare function objectValue(value: unknown): Record; +export declare function optionalObjectValue(value: unknown): Record | undefined; +export declare function stringValue(value: unknown): string; +export declare function numberValue(value: unknown): number | undefined; +export declare function errorMessage(error: unknown): string; +export declare function parseJsonObject(text: string): unknown; +export declare function now(): string; +export declare function sha256(contents: string | Buffer): string; +export declare function stableJson(value: unknown): string; +export declare function normalizeJsonValue(value: unknown, seen?: WeakSet, depth?: number): unknown; +export declare function sha256StableJson(value: unknown, trailingNewline?: boolean): string; +export declare function stripUndefined>(record: T): T; +export declare function stringList(value: unknown): string[]; +//# sourceMappingURL=object-utils.d.ts.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/object-utils.d.ts.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/object-utils.d.ts.map new file mode 100644 index 000000000..a6e7cd126 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/object-utils.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"object-utils.d.ts","sourceRoot":"","sources":["../src/object-utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAE9E;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEnE;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAEvF;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAElD;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAE9D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEnD;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAMrD;AAED,wBAAgB,GAAG,IAAI,MAAM,CAE5B;AAED,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAExD;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEjD;AAoCD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,kBAAwB,EAAE,KAAK,SAAI,GAAG,OAAO,CA6BnG;AAqBD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,eAAe,UAAQ,GAAG,MAAM,CAEhF;AAED,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAE9E;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,CAUnD"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/object-utils.js b/packages/runtime-cloudflare/vendor/wp-codebox-core/object-utils.js new file mode 100644 index 000000000..ce8f73c2b --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/object-utils.js @@ -0,0 +1,129 @@ +import { createHash } from "node:crypto"; +export function isPlainObject(value) { + return typeof value === "object" && value !== null && !Array.isArray(value); +} +export function objectValue(value) { + return isPlainObject(value) ? value : {}; +} +export function optionalObjectValue(value) { + return isPlainObject(value) ? value : undefined; +} +export function stringValue(value) { + return typeof value === "string" ? value.trim() : ""; +} +export function numberValue(value) { + return typeof value === "number" && Number.isFinite(value) ? value : undefined; +} +export function errorMessage(error) { + return error instanceof Error ? error.message : String(error); +} +export function parseJsonObject(text) { + try { + return JSON.parse(text); + } + catch { + return undefined; + } +} +export function now() { + return new Date().toISOString(); +} +export function sha256(contents) { + return createHash("sha256").update(contents).digest("hex"); +} +export function stableJson(value) { + return stableJsonValue(value, new WeakSet(), 0); +} +function stableJsonValue(value, seen, depth) { + if (depth > 30) { + return JSON.stringify("[max-depth]"); + } + if (value instanceof Error) { + return stableJsonValue(errorJsonRecord(value), seen, depth + 1); + } + if (value === null || typeof value !== "object") { + return JSON.stringify(value); + } + if (seen.has(value)) { + return JSON.stringify("[circular]"); + } + seen.add(value); + if (Array.isArray(value)) { + const json = `[${value.slice(0, 2000).map((item) => stableJsonValue(item, seen, depth + 1)).join(",")}]`; + seen.delete(value); + return json; + } + const json = `{${Object.keys(value) + .sort() + .slice(0, 300) + .map((key) => { + const item = value[key]; + return typeof item === "function" || typeof item === "symbol" ? undefined : `${JSON.stringify(key)}:${stableJsonValue(item, seen, depth + 1)}`; + }) + .filter((item) => Boolean(item)) + .join(",")}}`; + seen.delete(value); + return json; +} +export function normalizeJsonValue(value, seen = new WeakSet(), depth = 0) { + if (depth > 30) { + return "[max-depth]"; + } + if (value instanceof Error) { + return normalizeJsonValue(errorJsonRecord(value), seen, depth + 1); + } + if (!value || typeof value !== "object") { + return value; + } + if (seen.has(value)) { + return "[circular]"; + } + seen.add(value); + if (Array.isArray(value)) { + const normalized = value.slice(0, 2000).map((item) => normalizeJsonValue(item, seen, depth + 1)); + seen.delete(value); + return normalized; + } + const output = {}; + for (const [key, item] of Object.entries(value).sort(([a], [b]) => a.localeCompare(b)).slice(0, 300)) { + if (typeof item !== "function" && typeof item !== "symbol") { + output[key] = normalizeJsonValue(item, seen, depth + 1); + } + } + seen.delete(value); + return output; +} +function errorJsonRecord(error) { + const record = error; + const output = { + name: error.name, + message: error.message, + }; + for (const [key, item] of Object.entries(record)) { + if (key !== "name" && key !== "message" && key !== "stack" && typeof item !== "function" && typeof item !== "symbol") { + output[key] = item; + } + } + if (record.cause && !("cause" in output)) { + output.cause = record.cause; + } + return output; +} +export function sha256StableJson(value, trailingNewline = false) { + return createHash("sha256").update(`${stableJson(value)}${trailingNewline ? "\n" : ""}`).digest("hex"); +} +export function stripUndefined(record) { + return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined)); +} +export function stringList(value) { + if (!Array.isArray(value)) + return []; + const items = []; + for (const item of value) { + const normalized = String(item).trim(); + if (normalized !== "" && !items.includes(normalized)) + items.push(normalized); + } + return items; +} +//# sourceMappingURL=object-utils.js.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/object-utils.js.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/object-utils.js.map new file mode 100644 index 000000000..857bc5dd8 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/object-utils.js.map @@ -0,0 +1 @@ +{"version":3,"file":"object-utils.js","sourceRoot":"","sources":["../src/object-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC7E,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KA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-cloudflare/vendor/wp-codebox-core/package.json new file mode 100644 index 000000000..4549afb22 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/package.json @@ -0,0 +1,23 @@ +{ + "name": "@automattic/wp-codebox-core", + "version": "0.26.2", + "type": "module", + "exports": { + "./package.json": "./package.json", + "./runtime-archive-component": { + "types": "./runtime-archive-component.d.ts", + "import": "./runtime-archive-component.js", + "default": "./runtime-archive-component.js" + }, + "./runtime-package-profile": { + "types": "./runtime-package-profile.d.ts", + "import": "./runtime-package-profile.js", + "default": "./runtime-package-profile.js" + }, + "./runtime-command-result": { + "types": "./runtime-command-result.d.ts", + "import": "./runtime-command-result.js", + "default": "./runtime-command-result.js" + } + } +} diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/performance-observation.d.ts b/packages/runtime-cloudflare/vendor/wp-codebox-core/performance-observation.d.ts new file mode 100644 index 000000000..6882df6cb --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/performance-observation.d.ts @@ -0,0 +1,101 @@ +export declare const PERFORMANCE_OBSERVATION_SCHEMA: "wp-codebox/performance-observation/v1"; +export type PerformanceObservationCaptureStatus = "captured" | "unavailable" | "partial" | "uncaptured"; +export interface PerformanceObservationCaptureRequest { + queries?: boolean; +} +export interface PerformanceObservationCaptureReport { + requested: PerformanceObservationCaptureRequest; + queries: { + requested: boolean; + status: PerformanceObservationCaptureStatus; + reason?: string; + }; +} +export interface PerformanceObservationTiming { + status?: "captured" | "uncaptured" | "unsupported" | (string & {}); + reason?: string; + startedAt?: string; + finishedAt?: string; + durationMs?: number; +} +export interface PerformanceObservationMemory { + status?: "captured" | "uncaptured" | "unsupported" | (string & {}); + reason?: string; + startBytes?: number; + endBytes?: number; + deltaBytes?: number; + peakBytes?: number; +} +export interface PerformanceObservationQueryFingerprint { + fingerprint: string; + count: number; + totalTimeMs?: number; + sampleMs?: number; + caller?: string; +} +export interface PerformanceObservationRepeatedQuerySummary { + fingerprint: string; + count: number; + totalTimeMs?: number; + caller?: string; +} +export interface PerformanceObservationDatabase { + status?: "captured" | "uncaptured" | "unavailable" | "partial" | "unsupported" | (string & {}); + reason?: string; + queryCount?: number; + totalTimeMs?: number | null; + timingStatus?: "captured" | "unavailable" | "unsupported" | (string & {}); + timingReason?: string; + fingerprints?: PerformanceObservationQueryFingerprint[]; + repeatedQueries?: PerformanceObservationRepeatedQuerySummary[]; +} +export interface PerformanceObservationHookTiming { + hook: string; + count?: number; + totalTimeMs?: number; + maxTimeMs?: number; +} +export interface PerformanceObservationHooks { + status?: "captured" | "uncaptured" | "unsupported" | (string & {}); + reason?: string; + timings: PerformanceObservationHookTiming[]; +} +export interface PerformanceObservationNetwork { + status?: "captured" | "uncaptured" | "unsupported" | (string & {}); + reason?: string; + requests?: number; + responses?: number; + failures?: number; + transferSizeBytes?: number; +} +export interface PerformanceObservationBrowser { + status?: "captured" | "uncaptured" | "unsupported" | (string & {}); + reason?: string; + metrics?: Record; + admin?: Record; +} +export interface PerformanceObservationArtifactRef { + kind?: string; + id?: string; + path?: string; + digest?: unknown; +} +export interface PerformanceObservation { + schema: typeof PERFORMANCE_OBSERVATION_SCHEMA; + command?: string; + target?: string; + source?: "in-process" | "server-http" | "browser" | (string & {}); + kind?: "simulated-page-load" | "server-page-load" | "browser-page-load" | "rest-request" | (string & {}); + timing?: PerformanceObservationTiming; + memory?: PerformanceObservationMemory; + database?: PerformanceObservationDatabase; + hooks?: PerformanceObservationHooks; + network?: PerformanceObservationNetwork; + browser?: PerformanceObservationBrowser; + artifactRefs?: PerformanceObservationArtifactRef[]; + capture?: PerformanceObservationCaptureReport; + metadata?: Record; +} +export declare function performanceObservation(input?: Omit): PerformanceObservation; +export declare function performanceObservationCaptureRequest(input: unknown): PerformanceObservationCaptureRequest; +//# sourceMappingURL=performance-observation.d.ts.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/performance-observation.d.ts.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/performance-observation.d.ts.map new file mode 100644 index 000000000..3beb09bc4 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/performance-observation.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"performance-observation.d.ts","sourceRoot":"","sources":["../src/performance-observation.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,8BAA8B,EAAG,uCAAgD,CAAA;AAE9F,MAAM,MAAM,mCAAmC,GAAG,UAAU,GAAG,aAAa,GAAG,SAAS,GAAG,YAAY,CAAA;AAEvG,MAAM,WAAW,oCAAoC;IACnD,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,WAAW,mCAAmC;IAClD,SAAS,EAAE,oCAAoC,CAAA;IAC/C,OAAO,EAAE;QACP,SAAS,EAAE,OAAO,CAAA;QAClB,MAAM,EAAE,mCAAmC,CAAA;QAC3C,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;CACF;AAED,MAAM,WAAW,4BAA4B;IAC3C,MAAM,CAAC,EAAE,UAAU,GAAG,YAAY,GAAG,aAAa,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;IAClE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,4BAA4B;IAC3C,MAAM,CAAC,EAAE,UAAU,GAAG,YAAY,GAAG,aAAa,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;IAClE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,sCAAsC;IACrD,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA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,CAAA;IACvC,OAAO,CAAC,EAAE,6BAA6B,CAAA;IACvC,YAAY,CAAC,EAAE,iCAAiC,EAAE,CAAA;IAClD,OAAO,CAAC,EAAE,mCAAmC,CAAA;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACnC;AAED,wBAAgB,sBAAsB,CAAC,KAAK,GAAE,IAAI,CAAC,sBAAsB,EAAE,QAAQ,CAAM,GAAG,sBAAsB,CAiBjH;AAED,wBAAgB,oCAAoC,CAAC,KAAK,EAAE,OAAO,GAAG,oCAAoC,CAQzG"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/performance-observation.js b/packages/runtime-cloudflare/vendor/wp-codebox-core/performance-observation.js new file mode 100644 index 000000000..f2599c5d7 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/performance-observation.js @@ -0,0 +1,30 @@ +import { stripUndefined } from "./object-utils.js"; +export const PERFORMANCE_OBSERVATION_SCHEMA = "wp-codebox/performance-observation/v1"; +export function performanceObservation(input = {}) { + return stripUndefined({ + schema: PERFORMANCE_OBSERVATION_SCHEMA, + command: input.command, + target: input.target, + source: input.source, + kind: input.kind, + timing: input.timing, + memory: input.memory, + database: input.database, + hooks: input.hooks, + network: input.network, + browser: input.browser, + artifactRefs: input.artifactRefs, + capture: input.capture, + metadata: input.metadata, + }); +} +export function performanceObservationCaptureRequest(input) { + if (!input || typeof input !== "object" || Array.isArray(input)) { + return {}; + } + const record = input; + return stripUndefined({ + queries: typeof record.queries === "boolean" ? record.queries : undefined, + }); +} +//# sourceMappingURL=performance-observation.js.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/performance-observation.js.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/performance-observation.js.map new file mode 100644 index 000000000..c99f3261a --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/performance-observation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"performance-observation.js","sourceRoot":"","sources":["../src/performance-observation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAElD,MAAM,CAAC,MAAM,8BAA8B,GAAG,uCAAgD,CAAA;AAiH9F,MAAM,UAAU,sBAAsB,CAAC,QAAgD,EAAE;IACvF,OAAO,cAAc,CAAC;QACpB,MAAM,EAAE,8BAA8B;QACtC,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,QAAQ,EAAE,KAAK,CAAC,QAAQ;KACzB,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,UAAU,oCAAoC,CAAC,KAAc;IACjE,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAChE,OAAO,EAAE,CAAA;IACX,CAAC;IACD,MAAM,MAAM,GAAG,KAAgC,CAAA;IAC/C,OAAO,cAAc,CAAC;QACpB,OAAO,EAAE,OAAO,MAAM,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;KAC1E,CAAC,CAAA;AACJ,CAAC"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/redaction.d.ts b/packages/runtime-cloudflare/vendor/wp-codebox-core/redaction.d.ts new file mode 100644 index 000000000..691085b2f --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/redaction.d.ts @@ -0,0 +1,31 @@ +export declare const REDACTED_VALUE = "[redacted]"; +export type RedactionPolicyProfileName = "audit_metadata" | "provider_proxy" | "browser_event" | "public_session_dto"; +export interface RedactionPolicyProfile { + name: RedactionPolicyProfileName; + exactKeys: readonly string[]; + sensitiveKeyTokens: readonly string[]; + allowedKeys?: readonly string[]; +} +export interface SensitiveKeyOptions { + pattern?: RegExp; + extraPattern?: RegExp; + profile?: RedactionPolicyProfileName; +} +export interface RedactJsonOptions extends SensitiveKeyOptions { + redactStrings?: boolean; +} +export interface RedactStringOptions extends SensitiveKeyOptions { + redactAllUrlQueryValues?: boolean; + redactUrlHash?: boolean; + redactQueryAssignments?: boolean; +} +export declare function getRedactionPolicyProfile(profile: RedactionPolicyProfileName): RedactionPolicyProfile; +export declare function isSensitiveKey(key: string, options?: SensitiveKeyOptions): boolean; +export declare function isRedactedValue(value: string): boolean; +export declare function containsSecretLikeValue(value: string): boolean; +export declare function redactJsonValue(value: unknown, options?: RedactJsonOptions, key?: string): unknown; +export declare function redactJsonText(value: string, options?: RedactJsonOptions): string; +export declare function redactString(value: string, options?: RedactStringOptions): string; +export declare function redactError(error: unknown, options?: RedactStringOptions): Error; +export declare function redactUrl(value: string, options?: RedactStringOptions): string; +//# sourceMappingURL=redaction.d.ts.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/redaction.d.ts.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/redaction.d.ts.map new file mode 100644 index 000000000..af42db9be --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/redaction.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"redaction.d.ts","sourceRoot":"","sources":["../src/redaction.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,eAAe,CAAA;AAE1C,MAAM,MAAM,0BAA0B,GAAG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AW,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAE,mBAAwB,GAAG,KAAK,CAQpF;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAwB,GAAG,MAAM,CAWlF"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/redaction.js b/packages/runtime-cloudflare/vendor/wp-codebox-core/redaction.js new file mode 100644 index 000000000..c51d76979 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/redaction.js @@ -0,0 +1,101 @@ +export const REDACTED_VALUE = "[redacted]"; +const SENSITIVE_KEY_PATTERN = /(?:secret|token|credential|password|pass|api[_-]?key|private[_-]?key|authorization|auth|cookie|bearer|nonce|session|state|code|login)/i; +const SECRET_LIKE_VALUE_PATTERN = /\b(?:sk-[A-Za-z0-9_-]{20,}|github_pat_[A-Za-z0-9_]{20,}|gh[pousr]_[A-Za-z0-9_]{20,}|xox[baprs]-[A-Za-z0-9-]{20,}|AKIA[0-9A-Z]{16})\b/; +const SECRET_LIKE_VALUE_GLOBAL_PATTERN = /\b(?:sk-[A-Za-z0-9_-]{20,}|github_pat_[A-Za-z0-9_]{20,}|gh[pousr]_[A-Za-z0-9_]{20,}|xox[baprs]-[A-Za-z0-9-]{20,}|AKIA[0-9A-Z]{16})\b/g; +const REDACTION_POLICY_PROFILES = { + audit_metadata: { + name: "audit_metadata", + exactKeys: ["authorization", "key", "value"], + sensitiveKeyTokens: ["secret", "token", "password", "credential", "private_key", "api_key"], + }, + provider_proxy: { + name: "provider_proxy", + exactKeys: ["authorization", "key", "value"], + sensitiveKeyTokens: ["secret", "token", "password", "credential", "private_key", "api_key"], + }, + browser_event: { + name: "browser_event", + exactKeys: ["authorization"], + sensitiveKeyTokens: ["secret", "token", "password", "credential", "private_key", "api_key", "cookie"], + }, + public_session_dto: { + name: "public_session_dto", + exactKeys: [], + sensitiveKeyTokens: ["secret", "token", "password", "private_key", "api_key", "credential"], + allowedKeys: ["secret_env", "secretenv", "secret_env_names"], + }, +}; +export function getRedactionPolicyProfile(profile) { + return REDACTION_POLICY_PROFILES[profile]; +} +export function isSensitiveKey(key, options = {}) { + if (options.profile) { + const normalizedKey = key.toLowerCase(); + const profile = getRedactionPolicyProfile(options.profile); + if (profile.allowedKeys?.includes(normalizedKey)) { + return false; + } + return profile.exactKeys.includes(normalizedKey) || profile.sensitiveKeyTokens.some((token) => normalizedKey.includes(token)) || Boolean(options.extraPattern?.test(key)); + } + return (options.pattern ?? SENSITIVE_KEY_PATTERN).test(key) || Boolean(options.extraPattern?.test(key)); +} +export function isRedactedValue(value) { + return /^\[?redacted\]?$/i.test(value) || value === "" || value === "***"; +} +export function containsSecretLikeValue(value) { + return !isRedactedValue(value) && SECRET_LIKE_VALUE_PATTERN.test(value); +} +export function redactJsonValue(value, options = {}, key = "") { + if (isSensitiveKey(key, options)) { + return REDACTED_VALUE; + } + if (Array.isArray(value)) { + return value.map((entry) => redactJsonValue(entry, options)); + } + if (value && typeof value === "object") { + return Object.fromEntries(Object.entries(value).map(([entryKey, entryValue]) => [entryKey, redactJsonValue(entryValue, options, entryKey)])); + } + if (typeof value === "string" && options.redactStrings !== false) { + return redactString(value, options); + } + return value; +} +export function redactJsonText(value, options = {}) { + const redacted = redactJsonValue(JSON.parse(value), options); + return `${JSON.stringify(redacted, null, 2)}\n`; +} +export function redactString(value, options = {}) { + return value + .replace(/(^|\r?\n)([ \t]*([A-Za-z0-9_-]+)[ \t]*:[ \t]*)[^\r\n]*/g, (line, prefix, assignment, key) => (isSensitiveKey(key, options) ? `${prefix}${assignment}${REDACTED_VALUE}` : line)) + .replace(/https?:\/\/[^\s"'<>]+/gi, (match) => redactUrl(match, options)) + .replace(SECRET_LIKE_VALUE_GLOBAL_PATTERN, REDACTED_VALUE) + .replace(/([?&][^=&#\s"'<>]+)=([^&#\s"'<>]+)/g, options.redactQueryAssignments ? `$1=${REDACTED_VALUE}` : "$&") + .replace(/\b(Bearer[ \t]+)[^&#\s"'<>]+/gi, `$1${REDACTED_VALUE}`) + .replace(/((?:[A-Za-z0-9_-]*)(?:access[_-]?token|auth|bearer|code|cookie|credential|key|login|nonce|pass|password|secret|session|state|token)(?:[A-Za-z0-9_-]*)(?:["'\s]*[:=]["'\s]*))[^&#\s"'<>]+/gi, `$1${REDACTED_VALUE}`); +} +export function redactError(error, options = {}) { + const source = error instanceof Error ? error : new Error(String(error)); + const redacted = new Error(redactString(source.message, options)); + redacted.name = redactString(source.name, options); + if (source.stack) { + redacted.stack = redactString(source.stack, options); + } + return redacted; +} +export function redactUrl(value, options = {}) { + try { + const url = new URL(value); + const queryKeys = [...new Set([...url.searchParams.keys()])].sort(); + const query = queryKeys.length > 0 + ? `?${queryKeys.map((key) => `${encodeURIComponent(key)}=${shouldRedactUrlQueryKey(key, options) ? REDACTED_VALUE : encodeURIComponent(url.searchParams.get(key) ?? "")}`).join("&")}` + : ""; + return `${url.origin}${url.pathname}${query}${url.hash && options.redactUrlHash ? `#${REDACTED_VALUE}` : url.hash}`; + } + catch { + return value; + } +} +function shouldRedactUrlQueryKey(key, options) { + return Boolean(options.redactAllUrlQueryValues) || isSensitiveKey(key, options); +} +//# sourceMappingURL=redaction.js.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/redaction.js.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/redaction.js.map new file mode 100644 index 000000000..6d5789ac8 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/redaction.js.map @@ -0,0 +1 @@ +{"version":3,"file":"redaction.js","sourceRoot":"","sources":["../src/redaction.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,YAAY,CAAA;AA2B1C,MAAM,qBAAqB,GAAG,wIAAwI,CAAA;AACtK,MAAM,yBAAyB,GAAG,sIAAsI,CAAA;AACxK,MAAM,gCAAgC,GAAG,uIAAuI,CAAA;AAEhL,MAAM,yBAAyB,GAA+D;IAC5F,cAAc,EAA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CAAC,kBAAkB,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YACtL,CAAC,CAAC,EAAE,CAAA;QACN,OAAO,GAAG,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,QAAQ,GAAG,KAAK,GAAG,GAAG,CAAC,IAAI,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,cAAc,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;IACrH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC;AAED,SAAS,uBAAuB,CAAC,GAAW,EAAE,OAA4B;IACxE,OAAO,OAAO,CAAC,OAAO,CAAC,uBAAuB,CAAC,IAAI,cAAc,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;AACjF,CAAC"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-action-adapter.d.ts b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-action-adapter.d.ts new file mode 100644 index 000000000..061bf4ab6 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-action-adapter.d.ts @@ -0,0 +1,223 @@ +import { type PerformanceObservation, type PerformanceObservationCaptureRequest } from "./performance-observation.js"; +import type { RuntimePolicy } from "./runtime-policy.js"; +import type { MountSpec, RuntimeCommandDiagnosticsCaptureSpec, RuntimeEpisode, RuntimeEpisodeContentDigest, RuntimeEpisodeStepResult, RuntimeEpisodeTraceRef } from "./runtime-contracts.js"; +import { type WordPressCrudOperation } from "./wordpress-crud-contracts.js"; +import { type WordPressDbOperation } from "./wordpress-db-contracts.js"; +export declare const RUNTIME_ACTION_OBSERVATION_SCHEMA: "wp-codebox/runtime-action-observation/v1"; +export declare const SANDBOX_WORKSPACE_ROOT = "/workspace"; +export type RuntimeAction = RuntimeWpCliAction | RuntimePhpAction | RuntimeRestRequestAction | RuntimeWordPressCrudOperationAction | RuntimeWordPressDbOperationAction | RuntimeFilesystemAction | RuntimeBrowserAction | RuntimeBrowserRandomWalkAction | RuntimeBrowserProbeAction | RuntimeEditorOpenAction | RuntimeEditorActionsAction | RuntimeEditorValidateBlocksAction | RuntimeAdminPageAction | RuntimePageAction | RuntimeActionSequenceAction | RuntimeWordPressPluginSetupAction | RuntimeWordPressPluginStateAction | RuntimeWordPressThemeSetupAction | RuntimeWordPressHookAction | RuntimeWordPressCronEventAction; +export interface RuntimeWpCliAction { + type: "wp_cli"; + command: string; + timeout_ms?: number; +} +export interface RuntimePhpAction { + type: "php"; + code: string; + bootstrap?: "wordpress" | "none"; + diagnostics?: RuntimeCommandDiagnosticsCaptureSpec; + timeout_ms?: number; +} +export interface RuntimeRestRequestAction { + type: "rest_request"; + method?: string; + path: string; + headers?: Record; + params?: Record; + body?: string; + body_json?: unknown; + capture?: PerformanceObservationCaptureRequest; + enableQueryCapture?: boolean; + timeout_ms?: number; +} +export interface RuntimeWordPressCrudOperationAction extends Omit { + type: "crud_operation"; + timeout_ms?: number; +} +export interface RuntimeWordPressDbOperationAction extends Omit { + type: "db_operation"; + timeout_ms?: number; +} +export interface RuntimeFilesystemAction { + type: "filesystem"; + operation: "list" | "read" | "write" | "delete"; + path: string; + content?: string; +} +export interface RuntimeBrowserAction { + type: "browser"; + operation: "navigate" | "click" | "fill" | "press" | "select" | "wait" | "capture"; + url?: string; + selector?: string; + text?: string; + value?: string; + key?: string; + wait_for?: string; + duration?: string; + capture?: string[]; + timeout_ms?: number; +} +export interface RuntimeBrowserRandomWalkAction { + type: "random_walk"; + context?: "browser" | "admin" | "editor"; + seed?: string; + max_steps?: number; + maxSteps?: number; + action_families?: string[]; + actionFamilies?: string[]; + start_url?: string; + startUrl?: string; + reset_policy?: Record; + resetPolicy?: Record; + capture?: string[]; + timeout_ms?: number; + metadata?: Record; +} +export interface RuntimeBrowserProbeAction { + type: "browser_probe"; + url: string; + wait_for?: string; + duration?: string; + capture?: string[]; + viewport?: string; + timeout_ms?: number; +} +export interface RuntimeEditorOpenAction { + type: "editor_open"; + target?: "post-new" | "site"; + post_id?: number; + post_type?: string; + url?: string; + wait_selector?: string; + capture?: string[]; + timeout_ms?: number; +} +export interface RuntimeEditorActionsAction { + type: "editor_actions"; + steps: Array>; + target?: "post-new" | "site" | "front-page"; + post_id?: number; + post_type?: string; + url?: string; + wait_selector?: string; + wait_timeout_ms?: number; + step_timeout_ms?: number; + capture?: string[]; + timeout_ms?: number; +} +export interface RuntimeEditorValidateBlocksAction { + type: "editor_validate_blocks"; + content?: string; + content_file?: string; + target?: "post-new" | "site" | "front-page"; + post_id?: number; + post_type?: string; + url?: string; + validation_provider?: string; + wait_selector?: string; + timeout_ms?: number; +} +export interface RuntimeAdminPageAction { + type: "admin_page"; + path: string; + wait_for?: string; + capture?: string[]; + timeout_ms?: number; +} +export interface RuntimePageAction { + type: "page"; + path: string; + wait_for?: string; + capture?: string[]; + timeout_ms?: number; +} +export interface RuntimeActionSequenceAction { + type: "sequence"; + seed?: string; + max_steps?: number; + maxSteps?: number; + action_families?: string[]; + actionFamilies?: string[]; + reset_policy?: Record; + resetPolicy?: Record; + steps: RuntimeAction[]; + replay?: Record; + metadata?: Record; + timeout_ms?: number; +} +export interface RuntimeWordPressPluginSetupAction { + type: "wordpress_plugin_setup"; + action?: "install" | "list"; + plugin?: string; + slug?: string; + activate?: boolean; + network?: boolean; + timeout_ms?: number; +} +export interface RuntimeWordPressPluginStateAction { + type: "wordpress_plugin_state"; + action?: "report" | "status" | "activate" | "deactivate"; + plugin?: string; + slug?: string; + file?: string; + path?: string; + network?: boolean; + timeout_ms?: number; +} +export interface RuntimeWordPressThemeSetupAction { + type: "wordpress_theme_setup"; + action?: "install" | "switch" | "list"; + theme?: string; + slug?: string; + activate?: boolean; + timeout_ms?: number; +} +export interface RuntimeWordPressHookAction { + type: "wordpress_hook"; + hook: string; + args?: unknown[]; + mutates?: boolean; + capability?: string; + destructive_boundary?: string; + timeout_ms?: number; +} +export interface RuntimeWordPressCronEventAction { + type: "wordpress_cron_event"; + hook: string; + operation?: "run-hook" | "schedule-single"; + args?: unknown[]; + timestamp?: number; + mutates?: boolean; + capability?: string; + destructive_boundary?: string; + timeout_ms?: number; +} +export interface RuntimeActionAdapterPolicy { + mounts?: MountSpec[]; + writableRoots?: string[]; + filesystem?: RuntimePolicy["filesystem"]; + filesystemTraceCommand?: string | false; +} +export interface RuntimeActionObservation { + schema: typeof RUNTIME_ACTION_OBSERVATION_SCHEMA; + type: RuntimeAction["type"]; + status: "ok"; + action: RuntimeAction; + data: Record; + observedAt: string; + step?: RuntimeEpisodeStepResult; + performance?: PerformanceObservation; + artifactRefs?: RuntimeEpisodeTraceRef[]; + digest: RuntimeEpisodeContentDigest; +} +export declare class RuntimeActionPolicyError extends Error { + readonly action: RuntimeAction; + readonly code: "runtime-action-policy-violation"; + constructor(message: string, action: RuntimeAction); +} +export declare class RuntimeActionExecutionError extends Error { + readonly artifactRefs: RuntimeEpisodeTraceRef[]; + constructor(message: string, artifactRefs: RuntimeEpisodeTraceRef[]); +} +export declare function runRuntimeAction(episode: RuntimeEpisode, action: RuntimeAction, policy?: RuntimeActionAdapterPolicy): Promise; +//# sourceMappingURL=runtime-action-adapter.d.ts.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-action-adapter.d.ts.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-action-adapter.d.ts.map new file mode 100644 index 000000000..d98e3f3d8 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-action-adapter.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"runtime-action-adapter.d.ts","sourceRoot":"","sources":["../src/runtime-action-adapter.ts"],"names":[],"mappings":"AAIA,OAAO,EAA0B,KAAK,sBAAsB,EAAE,KAAK,oCAAoC,EAAE,MAAM,8BAA8B,CAAA;AAE7I,OAAO,KAAK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C,YAAY,CAAC,CAAA;IACxC,sBAAsB,CAAC,EAAE,MAAM,GAAG,KAAK,CAAA;CACxC;AAED,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,OAAO,iCAAiC,CAAA;IAChD,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IAC3B,MAAM,EAAE,IAAI,CAAA;IACZ,MAAM,EAAE,aAAa,CAAA;IACrB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,wBAAwB,CAAA;IAC/B,WAAW,CAAC,EAAE,sBAAsB,CAAA;IACpC,YAAY,CAAC,EAAE,sBAAsB,EAAE,CAAA;IACvC,MAAM,EAAE,2BAA2B,CAAA;CACpC;AAED,qBAAa,wBAAyB,SAAQ,KAAK;IAGpB,QAAQ,CAAC,MAAM,EAAE,aAAa;IAF3D,QAAQ,CAAC,IAAI,EAAG,iCAAiC,CAAS;gBAE9C,OAAO,EAAE,MAAM,EAAW,MAAM,EAAE,aAAa;CAI5D;AAED,qBAAa,2BAA4B,SAAQ,KAAK;IACvB,QAAQ,CAAC,YAAY,EAAE,sBAAsB,EAAE;gBAAhE,OAAO,EAAE,MAAM,EAAW,YAAY,EAAE,sBAAsB,EAAE;CAI7E;AAED,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,aAAa,EACrB,MAAM,GAAE,0BAA+B,GACtC,OAAO,CAAC,wBAAwB,CAAC,CA8EnC"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-action-adapter.js b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-action-adapter.js new file mode 100644 index 000000000..ca3686a23 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-action-adapter.js @@ -0,0 +1,799 @@ +import { mkdir, readdir, readFile, realpath, rm, writeFile } from "node:fs/promises"; +import { dirname, relative, resolve } from "node:path"; +import { normalizeRootedPath, pathIsWithinRoot, relativePathIsWithinRoot } from "./file-tree-policy.js"; +import { planBrowserRandomWalk } from "./browser-interaction.js"; +import { performanceObservation } from "./performance-observation.js"; +import { runtimeEpisodeDigest } from "./runtime-episode.js"; +import { WORDPRESS_CRUD_OPERATION_SCHEMA, normalizeWordPressCrudOperation } from "./wordpress-crud-contracts.js"; +import { WORDPRESS_DB_OPERATION_SCHEMA, normalizeWordPressDbOperation } from "./wordpress-db-contracts.js"; +export const RUNTIME_ACTION_OBSERVATION_SCHEMA = "wp-codebox/runtime-action-observation/v1"; +export const SANDBOX_WORKSPACE_ROOT = "/workspace"; +export class RuntimeActionPolicyError extends Error { + action; + code = "runtime-action-policy-violation"; + constructor(message, action) { + super(message); + this.action = action; + this.name = "RuntimeActionPolicyError"; + } +} +export class RuntimeActionExecutionError extends Error { + artifactRefs; + constructor(message, artifactRefs) { + super(message); + this.artifactRefs = artifactRefs; + this.name = "RuntimeActionExecutionError"; + } +} +export async function runRuntimeAction(episode, action, policy = {}) { + if (action.type === "wp_cli") { + return runRuntimeWpCliAction(episode, action); + } + if (action.type === "php") { + return runRuntimePhpAction(episode, action); + } + if (action.type === "rest_request") { + return runRuntimeRestRequestAction(episode, action); + } + if (action.type === "crud_operation") { + return runRuntimeWordPressCrudOperationAction(episode, action); + } + if (action.type === "db_operation") { + return runRuntimeWordPressDbOperationAction(episode, action); + } + if (action.type === "browser") { + return runRuntimeBrowserAction(episode, action); + } + if (action.type === "random_walk") { + return runRuntimeBrowserRandomWalkAction(episode, action); + } + if (action.type === "browser_probe") { + return runRuntimeBrowserProbeAction(episode, action); + } + if (action.type === "editor_open") { + return runRuntimeEditorOpenAction(episode, action); + } + if (action.type === "editor_actions") { + return runRuntimeEditorActionsAction(episode, action); + } + if (action.type === "editor_validate_blocks") { + return runRuntimeEditorValidateBlocksAction(episode, action); + } + if (action.type === "admin_page") { + return runRuntimeAdminPageAction(episode, action); + } + if (action.type === "page") { + return runRuntimePageAction(episode, action); + } + if (action.type === "sequence") { + throw new RuntimeActionPolicyError("Runtime action sequences must be expanded by the fuzz-suite runner before episode execution.", action); + } + if (action.type === "wordpress_plugin_setup") { + return runRuntimeMappedCommandAction(episode, action, "wordpress.plugin-setup"); + } + if (action.type === "wordpress_plugin_state") { + return runRuntimeMappedCommandAction(episode, action, "wordpress.plugin-state"); + } + if (action.type === "wordpress_theme_setup") { + return runRuntimeMappedCommandAction(episode, action, "wordpress.theme-setup"); + } + if (action.type === "wordpress_hook") { + return runRuntimeMappedCommandAction(episode, action, "wordpress.invoke-hook"); + } + if (action.type === "wordpress_cron_event") { + return runRuntimeMappedCommandAction(episode, action, "wordpress.invoke-cron-event"); + } + return runRuntimeFilesystemAction(episode, action, policy); +} +async function runRuntimePhpAction(episode, action) { + const args = [`code=${action.code}`]; + if (action.bootstrap) { + args.push(`bootstrap=${action.bootstrap}`); + } + const diagnostics = action.diagnostics ?? { capture: ["wpdb-queries"] }; + const step = await episode.step({ + kind: "command", + command: "wordpress.run-php", + args, + diagnostics, + ...(action.timeout_ms !== undefined ? { timeoutMs: action.timeout_ms } : {}), + }, { type: "command-result" }); + return runtimeActionObservation({ + type: action.type, + action, + step, + data: { + mappedCommand: step.execution.command, + args: step.execution.args, + exitCode: step.execution.exitCode, + stdout: step.execution.stdout, + stderr: step.execution.stderr, + executionId: step.execution.id, + stepId: step.id, + }, + artifactRefs: step.observation?.artifactRefs, + }); +} +async function runRuntimeWpCliAction(episode, action) { + const step = await episode.step({ + kind: "command", + command: "wordpress.wp-cli", + args: [`command=${normalizeWpCliRuntimeActionCommand(action.command)}`], + ...(action.timeout_ms !== undefined ? { timeoutMs: action.timeout_ms } : {}), + }, { type: "command-result" }); + return runtimeActionObservation({ + type: action.type, + action, + step, + data: { + command: action.command, + mappedCommand: step.execution.command, + args: step.execution.args, + exitCode: step.execution.exitCode, + stdout: step.execution.stdout, + stderr: step.execution.stderr, + executionId: step.execution.id, + stepId: step.id, + }, + artifactRefs: step.observation?.artifactRefs, + }); +} +async function runRuntimeMappedCommandAction(episode, action, command) { + const step = await episode.step({ + kind: "command", + command, + args: actionArgs(action), + ...(action.timeout_ms !== undefined ? { timeoutMs: action.timeout_ms } : {}), + }, { type: "command-result" }); + return runtimeActionObservation({ + type: action.type, + action, + step, + data: { + mappedCommand: step.execution.command, + args: step.execution.args, + exitCode: step.execution.exitCode, + stdout: step.execution.stdout, + stderr: step.execution.stderr, + executionId: step.execution.id, + stepId: step.id, + }, + artifactRefs: step.observation?.artifactRefs, + }); +} +function actionArgs(action) { + return Object.entries(action).flatMap(([key, value]) => { + if (value === undefined || key === "type" || key === "timeout_ms") { + return []; + } + if (key === "args" && Array.isArray(value)) { + return [`args-json=${JSON.stringify(value)}`]; + } + return [`${key.replace(/_/g, "-")}=${String(value)}`]; + }); +} +async function runRuntimeRestRequestAction(episode, action) { + const args = [`path=${action.path}`]; + if (action.method) { + args.push(`method=${action.method}`); + } + if (action.headers) { + args.push(`headers-json=${JSON.stringify(action.headers)}`); + } + if (action.params) { + args.push(`params-json=${JSON.stringify(action.params)}`); + } + if (action.body_json !== undefined) { + args.push(`body-json=${JSON.stringify(action.body_json)}`); + } + else if (action.body !== undefined) { + args.push(`body=${action.body}`); + } + args.push(...captureArgs(action)); + const step = await episode.step({ + kind: "http", + command: "wordpress.rest-request", + args, + method: action.method ?? "GET", + path: action.path, + ...(action.timeout_ms !== undefined ? { timeoutMs: action.timeout_ms } : {}), + }, { type: "command-result" }); + let stdout = step.execution.stdout; + try { + stdout = JSON.parse(step.execution.stdout); + } + catch { + // Keep raw stdout when a backend returns non-JSON diagnostics. + } + const normalized = normalizeRuntimeRestRequestResult(action, step, stdout); + return runtimeActionObservation({ + type: action.type, + action, + step, + data: normalized, + artifactRefs: step.observation?.artifactRefs, + }); +} +function captureArgs(action) { + return [ + ...(action.capture && Object.keys(action.capture).length > 0 ? [`capture-json=${JSON.stringify(action.capture)}`] : []), + ...(typeof action.enableQueryCapture === "boolean" ? [`enable-query-capture=${action.enableQueryCapture ? "true" : "false"}`] : []), + ]; +} +async function runRuntimeWordPressCrudOperationAction(episode, action) { + const operation = normalizeWordPressCrudOperation({ schema: WORDPRESS_CRUD_OPERATION_SCHEMA, ...action }); + const step = await episode.step({ + kind: "command", + command: "wordpress.crud-operation", + args: [`operation-json=${JSON.stringify(operation)}`], + ...(action.timeout_ms !== undefined ? { timeoutMs: action.timeout_ms } : {}), + }, { type: "command-result" }); + return runtimeActionObservation({ + type: action.type, + action, + step, + data: { + operation, + mappedCommand: step.execution.command, + args: step.execution.args, + exitCode: step.execution.exitCode, + stdout: step.execution.stdout, + stderr: step.execution.stderr, + executionId: step.execution.id, + stepId: step.id, + }, + artifactRefs: step.observation?.artifactRefs, + }); +} +async function runRuntimeWordPressDbOperationAction(episode, action) { + const operation = normalizeWordPressDbOperation({ schema: WORDPRESS_DB_OPERATION_SCHEMA, ...action, operation: action.operation ?? "read" }); + const step = await episode.step({ + kind: "command", + command: "wordpress.db-operation", + args: [`operation-json=${JSON.stringify(operation)}`], + ...(action.timeout_ms !== undefined ? { timeoutMs: action.timeout_ms } : {}), + }, { type: "command-result" }); + return runtimeActionObservation({ + type: action.type, + action, + step, + data: { + operation, + mappedCommand: step.execution.command, + args: step.execution.args, + exitCode: step.execution.exitCode, + stdout: step.execution.stdout, + stderr: step.execution.stderr, + executionId: step.execution.id, + stepId: step.id, + }, + artifactRefs: step.observation?.artifactRefs, + }); +} +function normalizeRuntimeRestRequestResult(action, step, stdout) { + const response = stdout && typeof stdout === "object" && !Array.isArray(stdout) ? stdout : {}; + const startedAt = Date.parse(step.execution.startedAt); + const finishedAt = Date.parse(step.execution.finishedAt); + const durationMs = Number.isFinite(startedAt) && Number.isFinite(finishedAt) ? Math.max(0, finishedAt - startedAt) : undefined; + const method = stringValue(response.method) ?? action.method ?? "GET"; + const path = stringValue(response.path) ?? action.path; + const route = stringValue(response.route) ?? path; + const headers = recordValue(response.headers) ?? {}; + const body = response.body ?? response.data ?? null; + const diagnostics = { + exitCode: step.execution.exitCode, + stderr: step.execution.stderr, + ...(recordValue(response.diagnostics) ?? {}), + }; + return { + method, + path, + route, + status: typeof response.status === "number" ? response.status : undefined, + headers, + body, + timing: { + startedAt: step.execution.startedAt, + finishedAt: step.execution.finishedAt, + ...(durationMs !== undefined ? { durationMs } : {}), + ...(recordValue(response.timing) ?? {}), + }, + diagnostics, + mappedCommand: step.execution.command, + args: step.execution.args, + stdout, + stderr: step.execution.stderr, + executionId: step.execution.id, + stepId: step.id, + }; +} +function stringValue(value) { + return typeof value === "string" ? value : undefined; +} +function recordValue(value) { + return value && typeof value === "object" && !Array.isArray(value) ? value : undefined; +} +async function runRuntimeFilesystemAction(episode, action, policy) { + const mountedPath = await resolveRuntimeActionMountedPath(action, policy); + const data = await executeRuntimeFilesystemAction(action, mountedPath); + const traceCommand = policy.filesystemTraceCommand ?? "inspect-mounted-inputs"; + const step = traceCommand + ? await episode.step({ + kind: "filesystem", + command: traceCommand, + path: mountedPath.sandboxPath, + operation: action.operation, + description: `filesystem.${action.operation}`, + metadata: { + mountTarget: mountedPath.mount.target, + mountMode: mountedPath.mount.mode, + }, + }, { type: "mounts" }) + : undefined; + return runtimeActionObservation({ + type: action.type, + action, + step, + data: { + operation: action.operation, + path: mountedPath.sandboxPath, + mountTarget: mountedPath.mount.target, + mountMode: mountedPath.mount.mode, + ...data, + }, + artifactRefs: step?.observation?.artifactRefs, + }); +} +async function runRuntimeBrowserAction(episode, action) { + const args = [`steps-json=${JSON.stringify([runtimeBrowserCommandStep(action)])}`]; + if (action.url && action.operation !== "navigate") { + args.unshift(`url=${action.url}`); + } + if (action.capture && action.capture.length > 0) { + args.push(`capture=${action.capture.join(",")}`); + } + const step = await episode.step({ + kind: "browser", + command: "wordpress.browser-actions", + args, + ...(action.timeout_ms !== undefined ? { timeoutMs: action.timeout_ms } : {}), + ...(action.selector ? { selector: action.selector } : {}), + ...(action.url ? { url: action.url } : {}), + operation: action.operation, + }, { type: "browser-result" }); + let stdout = step.execution.stdout; + try { + stdout = JSON.parse(step.execution.stdout); + } + catch { + // Keep raw stdout when a backend returns non-JSON diagnostics. + } + return runtimeActionObservation({ + type: action.type, + action, + step, + data: { + operation: action.operation, + mappedCommand: step.execution.command, + args: step.execution.args, + exitCode: step.execution.exitCode, + stdout, + stderr: step.execution.stderr, + executionId: step.execution.id, + stepId: step.id, + }, + artifactRefs: step.observation?.artifactRefs, + }); +} +async function runRuntimeBrowserRandomWalkAction(episode, action) { + const plan = planBrowserRandomWalk(action); + if (plan.status === "unsupported") { + throw new RuntimeActionPolicyError(`Browser random walk is unsupported: ${plan.diagnostics.map((diagnostic) => diagnostic.code).join(", ")}`, action); + } + const args = [`steps-json=${JSON.stringify(plan.steps)}`]; + if (action.capture && action.capture.length > 0) { + args.push(`capture=${action.capture.join(",")}`); + } + const step = await episode.step({ + kind: "browser", + command: "wordpress.browser-actions", + args, + ...(action.timeout_ms !== undefined ? { timeoutMs: action.timeout_ms } : {}), + operation: "random_walk", + }, { type: "browser-result" }); + let stdout = step.execution.stdout; + try { + stdout = JSON.parse(step.execution.stdout); + } + catch { + // Keep raw stdout when a backend returns non-JSON diagnostics. + } + return runtimeActionObservation({ + type: action.type, + action, + step, + data: { + operation: "random_walk", + mappedCommand: step.execution.command, + args: step.execution.args, + exitCode: step.execution.exitCode, + stdout, + stderr: step.execution.stderr, + executionId: step.execution.id, + stepId: step.id, + randomWalk: plan, + }, + artifactRefs: step.observation?.artifactRefs, + }); +} +function runtimeBrowserCommandStep(action) { + const commandAction = { kind: action.operation === "wait" ? "waitFor" : action.operation }; + for (const key of ["url", "selector", "text", "value", "key", "duration"]) { + if (typeof action[key] === "string") { + commandAction[key] = action[key]; + } + } + if (typeof action.wait_for === "string") { + commandAction.waitFor = action.wait_for; + } + if (action.operation === "capture" && Array.isArray(action.capture)) { + commandAction.capture = action.capture; + } + return commandAction; +} +async function runRuntimeBrowserProbeAction(episode, action) { + const args = [`url=${action.url}`]; + if (action.wait_for) { + args.push(`wait-for=${action.wait_for}`); + } + if (action.duration) { + args.push(`duration=${action.duration}`); + } + if (action.capture && action.capture.length > 0) { + args.push(`capture=${action.capture.join(",")}`); + } + if (action.viewport) { + args.push(`viewport=${action.viewport}`); + } + const step = await episode.step({ + kind: "browser", + command: "wordpress.browser-probe", + args, + ...(action.timeout_ms !== undefined ? { timeoutMs: action.timeout_ms } : {}), + url: action.url, + operation: "probe", + }, { type: "browser-result" }); + let stdout = step.execution.stdout; + try { + stdout = JSON.parse(step.execution.stdout); + } + catch { + // Keep raw stdout when a backend returns non-JSON diagnostics. + } + return runtimeActionObservation({ + type: action.type, + action, + step, + data: { + mappedCommand: step.execution.command, + args: step.execution.args, + exitCode: step.execution.exitCode, + stdout, + stderr: step.execution.stderr, + executionId: step.execution.id, + stepId: step.id, + }, + artifactRefs: step.observation?.artifactRefs, + }); +} +async function runRuntimeEditorOpenAction(episode, action) { + const args = runtimeEditorOpenArgs(action); + const step = await episode.step({ + kind: "browser", + command: "wordpress.editor-open", + args, + ...(action.timeout_ms !== undefined ? { timeoutMs: action.timeout_ms } : {}), + ...(action.url ? { url: action.url } : {}), + ...(action.target ? { target: action.target } : {}), + operation: "editor_open", + }, { type: "browser-result" }); + let stdout = step.execution.stdout; + try { + stdout = JSON.parse(step.execution.stdout); + } + catch { + // Keep raw stdout when a backend returns non-JSON diagnostics. + } + const summary = recordValue(stdout); + return runtimeActionObservation({ + type: action.type, + action, + step, + data: { + mappedCommand: step.execution.command, + args: step.execution.args, + exitCode: step.execution.exitCode, + stdout, + stderr: step.execution.stderr, + executionId: step.execution.id, + stepId: step.id, + diagnostics: { + exitCode: step.execution.exitCode, + stderr: step.execution.stderr, + }, + ...(summary?.target ? { target: summary.target } : {}), + ...(summary?.finalUrl ? { finalUrl: summary.finalUrl } : {}), + ...(summary?.files ? { files: summary.files } : {}), + ...(summary?.summary ? { summary: summary.summary } : {}), + ...(summary?.steps ? { steps: summary.steps } : {}), + artifactRefs: step.observation?.artifactRefs ?? [], + }, + artifactRefs: step.observation?.artifactRefs, + }); +} +async function runRuntimeEditorActionsAction(episode, action) { + return runRuntimeEditorCommandAction(episode, action, "wordpress.editor-actions", runtimeEditorActionsArgs(action)); +} +async function runRuntimeEditorValidateBlocksAction(episode, action) { + return runRuntimeEditorCommandAction(episode, action, "wordpress.editor-validate-blocks", runtimeEditorValidateBlocksArgs(action)); +} +async function runRuntimeEditorCommandAction(episode, action, command, args) { + const step = await episode.step({ kind: "browser", command, args, ...(action.timeout_ms !== undefined ? { timeoutMs: action.timeout_ms } : {}), operation: action.type }, { type: "browser-result" }); + let stdout = step.execution.stdout; + try { + stdout = JSON.parse(step.execution.stdout); + } + catch { + // Keep raw stdout when a backend returns non-JSON diagnostics. + } + return runtimeActionObservation({ + type: action.type, + action, + step, + data: { mappedCommand: step.execution.command, args: step.execution.args, exitCode: step.execution.exitCode, stdout, stderr: step.execution.stderr, executionId: step.execution.id, stepId: step.id }, + artifactRefs: step.observation?.artifactRefs, + }); +} +async function runRuntimeAdminPageAction(episode, action) { + const path = action.path.startsWith("/wp-admin/") ? action.path : `/wp-admin/${action.path.replace(/^\/+/, "")}`; + const observation = await runRuntimeBrowserProbeAction(episode, { + type: "browser_probe", + url: path, + wait_for: action.wait_for, + capture: action.capture, + timeout_ms: action.timeout_ms, + }); + return runtimeActionObservation({ + type: action.type, + action, + step: observation.step, + data: { ...observation.data, path }, + artifactRefs: observation.artifactRefs, + }); +} +async function runRuntimePageAction(episode, action) { + const observation = await runRuntimeBrowserProbeAction(episode, { + type: "browser_probe", + url: action.path, + wait_for: action.wait_for, + capture: action.capture, + timeout_ms: action.timeout_ms, + }); + return runtimeActionObservation({ + type: action.type, + action, + step: observation.step, + data: { ...observation.data, path: action.path }, + artifactRefs: observation.artifactRefs, + }); +} +function runtimeEditorOpenArgs(action) { + const args = []; + if (action.target) { + args.push(`target=${action.target}`); + } + if (action.post_id !== undefined) { + args.push(`post-id=${action.post_id}`); + } + if (action.post_type) { + args.push(`post-type=${action.post_type}`); + } + if (action.url) { + args.push(`url=${action.url}`); + } + if (action.wait_selector) { + args.push(`wait-selector=${action.wait_selector}`); + } + if (action.timeout_ms !== undefined) { + args.push(`wait-timeout=${action.timeout_ms}ms`); + } + if (action.capture && action.capture.length > 0) { + args.push(`capture=${action.capture.join(",")}`); + } + return args; +} +function runtimeEditorActionsArgs(action) { + return [ + ...runtimeEditorOpenArgs(action), + `steps-json=${JSON.stringify(action.steps)}`, + ...(action.wait_timeout_ms !== undefined ? [`wait-timeout=${action.wait_timeout_ms}ms`] : []), + ...(action.step_timeout_ms !== undefined ? [`step-timeout=${action.step_timeout_ms}ms`] : []), + ]; +} +function runtimeEditorValidateBlocksArgs(action) { + return [ + ...(action.content !== undefined ? [`content=${action.content}`] : []), + ...(action.content_file ? [`content-file=${action.content_file}`] : []), + ...runtimeEditorOpenArgs(action), + ...(action.validation_provider ? [`validation-provider=${action.validation_provider}`] : []), + ]; +} +function normalizeWpCliRuntimeActionCommand(command) { + const trimmed = command.trim(); + return trimmed.startsWith("wp ") ? trimmed.slice(3).trimStart() : trimmed; +} +async function resolveRuntimeActionMountedPath(action, policy) { + if (!action.path || action.path.includes("\0")) { + throw new RuntimeActionPolicyError("Filesystem action path must be a non-empty path without null bytes", action); + } + const mounts = policy.mounts ?? []; + const sandboxPath = normalizeSandboxRuntimeActionPath(action.path); + const mount = mounts.find((candidate) => isRuntimeActionPathWithinRoot(sandboxPath, candidate.target)); + if (!mount) { + throw new RuntimeActionPolicyError(`Filesystem action path is outside mounted workspace roots: ${action.path}`, action); + } + const hostPath = resolve(mount.source, relative(normalizeSandboxRuntimeActionPath(mount.target), sandboxPath)); + await assertRuntimeActionHostPathWithinMount(action, hostPath, mount.source); + if (action.operation === "write" || action.operation === "delete") { + assertRuntimeFilesystemWritable(action, sandboxPath, mount, policy); + } + return { mount, sandboxPath, hostPath }; +} +function normalizeSandboxRuntimeActionPath(path) { + return normalizeRootedPath(path, SANDBOX_WORKSPACE_ROOT); +} +function isRuntimeActionPathWithinRoot(path, root) { + return relativePathIsWithinRoot(normalizeSandboxRuntimeActionPath(path), normalizeSandboxRuntimeActionPath(root)); +} +async function assertRuntimeActionHostPathWithinMount(action, hostPath, source) { + const root = await realpath(source); + const existingPath = action.operation === "write" ? dirname(hostPath) : hostPath; + let real; + try { + real = await realpath(existingPath); + } + catch (error) { + if (action.operation !== "write") { + throw error; + } + real = await nearestExistingRuntimeActionParent(existingPath, root); + } + if (!pathIsWithinRoot(real, root)) { + throw new RuntimeActionPolicyError(`Filesystem action path resolves outside mounted workspace root: ${action.path}`, action); + } +} +async function nearestExistingRuntimeActionParent(path, root) { + let current = path; + while (current !== dirname(current)) { + try { + return await realpath(current); + } + catch { + current = dirname(current); + if (!current.startsWith(root)) { + return root; + } + } + } + return root; +} +function assertRuntimeFilesystemWritable(action, sandboxPath, mount, policy) { + if (policy.filesystem && policy.filesystem !== "readwrite-mounts") { + throw new RuntimeActionPolicyError(`Filesystem action requires readwrite-mounts policy: ${action.operation}`, action); + } + if (mount.mode !== "readwrite") { + throw new RuntimeActionPolicyError(`Filesystem action requires a readwrite mount: ${mount.target}`, action); + } + const writableRoots = policy.writableRoots ?? [mount.target]; + if (!writableRoots.some((root) => isRuntimeActionPathWithinRoot(sandboxPath, root))) { + throw new RuntimeActionPolicyError(`Filesystem action path is outside writable roots: ${action.path}`, action); + } +} +async function executeRuntimeFilesystemAction(action, mountedPath) { + if (action.operation === "list") { + const entries = await readdir(mountedPath.hostPath, { withFileTypes: true }); + return { + entries: entries + .map((entry) => ({ name: entry.name, type: entry.isDirectory() ? "directory" : entry.isFile() ? "file" : "other" })) + .sort((left, right) => left.name.localeCompare(right.name)), + }; + } + if (action.operation === "read") { + const content = await readFile(mountedPath.hostPath, "utf8"); + return { content, bytes: Buffer.byteLength(content, "utf8") }; + } + if (action.operation === "write") { + await mkdir(dirname(mountedPath.hostPath), { recursive: true }); + await writeFile(mountedPath.hostPath, action.content ?? ""); + return { bytes: Buffer.byteLength(action.content ?? "", "utf8") }; + } + await rm(mountedPath.hostPath, { recursive: true, force: true }); + return { deleted: true }; +} +function runtimeActionObservation(input) { + const observedAt = new Date().toISOString(); + const performance = normalizeRuntimeActionPerformanceObservation(input); + const observation = { + schema: RUNTIME_ACTION_OBSERVATION_SCHEMA, + type: input.type, + status: "ok", + action: input.action, + data: input.data, + observedAt, + performance, + ...(input.step ? { step: input.step } : {}), + ...(input.artifactRefs && input.artifactRefs.length > 0 ? { artifactRefs: input.artifactRefs } : {}), + }; + return { + ...observation, + digest: runtimeEpisodeDigest(observation), + }; +} +function normalizeRuntimeActionPerformanceObservation(input) { + const diagnostics = recordValue(input.step?.execution.diagnostics); + const explicit = recordValue(input.data.performance) ?? recordValue(diagnostics?.performance); + const startedAt = input.step?.execution.startedAt; + const finishedAt = input.step?.execution.finishedAt; + const startedMs = startedAt ? Date.parse(startedAt) : NaN; + const finishedMs = finishedAt ? Date.parse(finishedAt) : NaN; + const durationMs = Number.isFinite(startedMs) && Number.isFinite(finishedMs) ? Math.max(0, finishedMs - startedMs) : undefined; + const timing = recordValue(explicit?.timing) ?? recordValue(input.data.timing); + const browser = normalizeRuntimeActionBrowserPerformance(input.data); + return performanceObservation({ + command: input.step?.execution.command, + target: runtimeActionTarget(input.action), + timing: { + ...(startedAt ? { startedAt } : {}), + ...(finishedAt ? { finishedAt } : {}), + ...(durationMs !== undefined ? { durationMs } : {}), + ...timing, + }, + memory: recordValue(explicit?.memory), + database: recordValue(explicit?.database), + hooks: recordValue(explicit?.hooks), + network: recordValue(explicit?.network), + browser: recordValue(explicit?.browser) ?? browser, + ...(input.artifactRefs && input.artifactRefs.length > 0 ? { artifactRefs: input.artifactRefs } : {}), + metadata: { + actionType: input.action.type, + ...(input.step ? { stepId: input.step.id, executionId: input.step.execution.id } : {}), + }, + }); +} +function normalizeRuntimeActionBrowserPerformance(data) { + const stdout = recordValue(data.stdout); + const summary = recordValue(stdout?.summary) ?? recordValue(data.summary); + const files = recordValue(stdout?.files) ?? recordValue(data.files); + if (!summary && !files) { + return undefined; + } + return { + metrics: recordValue(summary?.metrics), + admin: { + ...(summary ?? {}), + ...(files ? { files } : {}), + }, + }; +} +function runtimeActionTarget(action) { + if ("path" in action) + return action.path; + if ("url" in action) + return action.url; + if ("command" in action) + return action.command; + if (action.type === "php") + return action.bootstrap ?? "php"; + return action.type; +} +//# sourceMappingURL=runtime-action-adapter.js.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-action-adapter.js.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-action-adapter.js.map new file mode 100644 index 000000000..78b342063 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-action-adapter.js.map @@ -0,0 +1 @@ +{"version":3,"file":"runtime-action-adapter.js","sourceRoot":"","sources":["../src/runtime-action-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACpF,OAAO,EAAE,OAAO,EAAQ,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAC5D,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AACvG,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAA;AAChE,OAAO,EAAE,sBAAsB,EAA0E,MAAM,8BAA8B,CAAA;AAC7I,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAG3D,OAAO,EAAE,+BAA+B,EAAE,+BAA+B,EAA+B,MAAM,+BAA+B,CAAA;AAC7I,OAAO,EAAE,6BAA6B,EAAE,6BAA6B,EAA6B,MAAM,6BAA6B,CAAA;AAErI,MAAM,CAAC,MAAM,iCAAiC,GAAG,0CAAmD,CAAA;AAEpG,MAAM,CAAC,MAAM,sBAAsB,GAAG,YAAY,CAAA;AAsOlD,MAAM,OAAO,wBAAyB,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AAC,SAAS,IAAI,KAAK,CAAA;IAC3D,OAAO,MAAM,CAAC,IAAI,CAAA;AACpB,CAAC"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-archive-component.d.ts b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-archive-component.d.ts new file mode 100644 index 000000000..607568da6 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-archive-component.d.ts @@ -0,0 +1,38 @@ +export declare const RUNTIME_ARCHIVE_COMPONENT_SCHEMA: "wp-codebox/runtime-archive-component/v1"; +export declare const RUNTIME_ARCHIVE_COMPONENT_SOURCE_SCHEMA: "wp-codebox/runtime-archive-component-source/v1"; +export interface RuntimeArchiveComponent { + schema: typeof RUNTIME_ARCHIVE_COMPONENT_SCHEMA; + id: string; + package: { + profile: string; + root: string; + }; + wordpress: { + install_path: string; + bootstrap_file: string; + load: { + mode: "mu-plugin-loader"; + loader_path: string; + }; + version_constant?: string; + }; + abilities: Record; + limits: { + files: number; + bytes: number; + }; +} +export interface RuntimeArchiveComponentSource { + schema: typeof RUNTIME_ARCHIVE_COMPONENT_SOURCE_SCHEMA; + source: { + url: string; + version: string; + identity: string; + sha256: string; + }; + component: RuntimeArchiveComponent; +} +export declare function runtimeArchiveComponent(value: unknown): RuntimeArchiveComponent; +export declare function runtimeArchiveComponentSource(value: unknown): RuntimeArchiveComponentSource; +export declare function runtimeArchiveComponentOwnedWpContentPaths(component: RuntimeArchiveComponent): string[]; +//# sourceMappingURL=runtime-archive-component.d.ts.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-archive-component.d.ts.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-archive-component.d.ts.map new file mode 100644 index 000000000..f24d342ac --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-archive-component.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"runtime-archive-component.d.ts","sourceRoot":"","sources":["../src/runtime-archive-component.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gCAAgC,EAAG,yCAAkD,CAAA;AAClG,eAAO,MAAM,uCAAuC,EAAG,gDAAyD,CAAA;AAEhH,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,OAAO,gCAAgC,CAAA;IAC/C,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;IAC1C,SAAS,EAAE;QACT,YAAY,EAAE,MAAM,CAAA;QACpB,cAAc,EAAE,MAAM,CAAA;QACtB,IAAI,EAAE;YAAE,IAAI,EAAE,kBAAkB,CAAC;YAAC,WAAW,EAAE,MAAM,CAAA;SAAE,CAAA;QACvD,gBAAgB,CAAC,EAAE,MAAM,CAAA;KAC1B,CAAA;IACD,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACjC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;CACzC;AAED,MAAM,WAAW,6BAA6B;IAC5C,MAAM,EAAE,OAAO,uCAAuC,CAAA;IACtD,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;IAC1E,SAAS,EAAE,uBAAuB,CAAA;CACnC;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,uBAAuB,CAqB/E;AAED,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,OAAO,GAAG,6BAA6B,CAU3F;AAED,wBAAgB,0CAA0C,CAAC,SAAS,EAAE,uBAAuB,GAAG,MAAM,EAAE,CAGvG"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-archive-component.js b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-archive-component.js new file mode 100644 index 000000000..8eb7cf1fb --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-archive-component.js @@ -0,0 +1,78 @@ +export const RUNTIME_ARCHIVE_COMPONENT_SCHEMA = "wp-codebox/runtime-archive-component/v1"; +export const RUNTIME_ARCHIVE_COMPONENT_SOURCE_SCHEMA = "wp-codebox/runtime-archive-component-source/v1"; +export function runtimeArchiveComponent(value) { + if (!isRecord(value) || value.schema !== RUNTIME_ARCHIVE_COMPONENT_SCHEMA || !isSlug(value.id)) + throw new Error("Runtime archive component identity is invalid."); + if (!isRecord(value.package) || !isSlug(value.package.profile) || !isSlug(value.package.root)) + throw new Error("Runtime archive component package is invalid."); + if (!isRecord(value.wordpress) || !isPluginInstallPath(value.wordpress.install_path) || !isSafeFilePath(value.wordpress.bootstrap_file)) + throw new Error("Runtime archive component WordPress contract is invalid."); + if (!isRecord(value.wordpress.load) || value.wordpress.load.mode !== "mu-plugin-loader" || !isMuPluginFilePath(value.wordpress.load.loader_path)) + throw new Error("Runtime archive component load contract is invalid."); + if (value.wordpress.version_constant !== undefined && (typeof value.wordpress.version_constant !== "string" || !/^[A-Z][A-Z0-9_]*$/.test(value.wordpress.version_constant))) + throw new Error("Runtime archive component version constant is invalid."); + if (!isRecord(value.abilities) || !Object.keys(value.abilities).length || Object.entries(value.abilities).some(([alias, ability]) => !isSlug(alias) || !isAbility(ability))) + throw new Error("Runtime archive component abilities are invalid."); + if (!isRecord(value.limits) || !Number.isSafeInteger(value.limits.files) || Number(value.limits.files) < 1 || Number(value.limits.files) > 100_000 || !Number.isSafeInteger(value.limits.bytes) || Number(value.limits.bytes) < 1 || Number(value.limits.bytes) > 256 * 1024 * 1024) + throw new Error("Runtime archive component limits are invalid."); + return { + schema: RUNTIME_ARCHIVE_COMPONENT_SCHEMA, + id: value.id, + package: { profile: value.package.profile, root: value.package.root }, + wordpress: { + install_path: value.wordpress.install_path, + bootstrap_file: value.wordpress.bootstrap_file, + load: { mode: "mu-plugin-loader", loader_path: value.wordpress.load.loader_path }, + ...(value.wordpress.version_constant ? { version_constant: value.wordpress.version_constant } : {}), + }, + abilities: Object.fromEntries(Object.entries(value.abilities).sort(([left], [right]) => left.localeCompare(right))), + limits: { files: Number(value.limits.files), bytes: Number(value.limits.bytes) }, + }; +} +export function runtimeArchiveComponentSource(value) { + if (!isRecord(value) || value.schema !== RUNTIME_ARCHIVE_COMPONENT_SOURCE_SCHEMA || !isRecord(value.source)) + throw new Error("Runtime archive component source is invalid."); + let url; + try { + url = new URL(String(value.source.url)); + } + catch { + throw new Error("Runtime archive component source URL is invalid."); + } + if (url.protocol !== "https:" || url.username || url.password || !url.hostname || !isBoundedIdentity(value.source.version) || !isBoundedIdentity(value.source.identity) || !isSha256(value.source.sha256)) + throw new Error("Runtime archive component source is invalid."); + return { + schema: RUNTIME_ARCHIVE_COMPONENT_SOURCE_SCHEMA, + source: { url: url.toString(), version: value.source.version, identity: value.source.identity, sha256: value.source.sha256 }, + component: runtimeArchiveComponent(value.component), + }; +} +export function runtimeArchiveComponentOwnedWpContentPaths(component) { + const validated = runtimeArchiveComponent(component); + return [`${validated.wordpress.install_path}/`, validated.wordpress.load.loader_path]; +} +function isRecord(value) { + return Boolean(value) && typeof value === "object" && !Array.isArray(value); +} +function isSlug(value) { + return typeof value === "string" && /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(value); +} +function isAbility(value) { + return typeof value === "string" && /^[a-z0-9]+(?:-[a-z0-9]+)*\/[a-z0-9]+(?:-[a-z0-9]+)*$/.test(value); +} +function isSha256(value) { + return typeof value === "string" && /^[a-f0-9]{64}$/.test(value); +} +function isBoundedIdentity(value) { + return typeof value === "string" && value.length > 0 && value.length <= 256 && value.trim() === value; +} +function isSafeFilePath(value) { + return typeof value === "string" && value.length > 0 && value.length <= 2_048 && !value.startsWith("/") && !value.endsWith("/") && !value.includes("\\") && value.split("/").every((segment) => segment !== "" && segment !== "." && segment !== ".."); +} +function isPluginInstallPath(value) { + return typeof value === "string" && /^plugins\/[a-z0-9]+(?:-[a-z0-9]+)*$/.test(value); +} +function isMuPluginFilePath(value) { + return isSafeFilePath(value) && /^mu-plugins\/[A-Za-z0-9._-]+\.php$/.test(value); +} +//# sourceMappingURL=runtime-archive-component.js.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-archive-component.js.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-archive-component.js.map new file mode 100644 index 000000000..0fb6eb76c --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-archive-component.js.map @@ -0,0 +1 @@ +{"version":3,"file":"runtime-archive-component.js","sourceRoot":"","sources":["../src/runtime-archive-component.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gCAAgC,GAAG,yCAAkD,CAAA;AAClG,MAAM,CAAC,MAAM,uCAAuC,GAAG,gDAAyD,CAAA;AAsBhH,MAAM,UAAU,uBAAuB,CAAC,KAAc;IACpD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,gCAAgC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAA;IACjK,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAA;IAC/J,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC;QAAE,MAAM,IAAI,K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C,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,KAAK,EAAE,IAAI,OAAO,KAAK,GAAG,IAAI,OAAO,KAAK,IAAI,CAAC,CAAA;AACxP,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAc;IACzC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,qCAAqC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AACvF,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAc;IACxC,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,oCAAoC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AAClF,CAAC"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-boundary-contracts.d.ts b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-boundary-contracts.d.ts new file mode 100644 index 000000000..75165489a --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-boundary-contracts.d.ts @@ -0,0 +1,239 @@ +export declare const RUNTIME_PROFILE_SCHEMA: "wp-codebox/runtime-profile/v1"; +export declare const PREVIEW_LEASE_SCHEMA: "wp-codebox/preview-lease/v1"; +export declare const PREVIEW_REVIEWER_ACCESS_SCHEMA: "wp-codebox/preview-reviewer-access/v1"; +export declare const RUNTIME_ACCESS_SCHEMA: "wp-codebox/runtime-access/v1"; +export declare const BROWSER_CONTAINED_SITE_STATUS_SCHEMA: "wp-codebox/browser-contained-site-status/v1"; +export declare const BROWSER_CONTAINED_SITE_OPEN_SCHEMA: "wp-codebox/browser-contained-site-open/v1"; +export declare const BROWSER_SESSION_PRODUCT_DTO_SCHEMA: "wp-codebox/browser-session-product-dto/v1"; +export declare const BROWSER_PREVIEW_BOOT_CONFIG_SCHEMA: "wp-codebox/browser-preview-boot-config/v1"; +export type RuntimeProfileDependencyKind = "component" | "plugin" | "mu_plugin" | "theme" | "bootstrap" | "overlay" | (string & {}); +export type RuntimeProfileReadinessStatus = "ready" | "pending" | "blocked" | "missing" | "unknown" | (string & {}); +export interface RuntimeProfileDependency { + kind: RuntimeProfileDependencyKind; + slug: string; + name?: string; + source?: string; + target?: string; + version?: string; + activate?: boolean; + required?: boolean; + readiness?: RuntimeProfileReadinessStatus; + provenance?: Record; + metadata?: Record; +} +export interface RuntimeProfileBootstrap { + mode?: string; + entrypoint?: string; + blueprint_ref?: string; + steps?: string[]; + provenance?: Record; +} +export interface RuntimeProfileReadiness { + status: RuntimeProfileReadinessStatus; + checks?: Record; + missing?: string[]; + evidence?: Record; +} +export interface RuntimeProfileDiagnostic { + code: string; + status?: RuntimeProfileReadinessStatus; + message?: string; + severity?: "info" | "warning" | "error" | (string & {}); + evidence?: Record; +} +export interface RuntimeProfile { + schema: typeof RUNTIME_PROFILE_SCHEMA; + id?: string; + capabilities?: string[]; + component_contracts?: Record[]; + extra_plugins?: Record[]; + provider_plugins?: Record[]; + components: RuntimeProfileDependency[]; + plugins?: RuntimeProfileDependency[]; + mu_plugins?: RuntimeProfileDependency[]; + themes?: RuntimeProfileDependency[]; + bootstrap?: RuntimeProfileBootstrap; + overlays?: RuntimeProfileDependency[]; + runtime_overlays?: Record[]; + runtime_state_mounts?: Record[]; + runtime_config_mounts?: Record[]; + env?: Record; + readiness?: RuntimeProfileReadiness; + diagnostics?: RuntimeProfileDiagnostic[]; + provenance?: Record; + metadata?: Record; +} +export interface PreviewLeaseMetadata { + id?: string; + status?: "active" | "expired" | "released" | "unknown" | (string & {}); + acquired_at?: string; + expires_at?: string; + owner?: string; + owner_id?: string; + provider?: string; + provenance?: Record; +} +export interface PreviewAlignmentEvidence { + status: "aligned" | "misaligned" | "unknown" | (string & {}); + checked_at?: string; + preview_matches_site?: boolean; + preview_matches_local?: boolean; + evidence?: Record; +} +export interface PreviewReachabilityEvidence { + status: "reachable" | "unreachable" | "unknown" | (string & {}); + checked_at?: string; + http_status?: number; + probes?: Record[]; + evidence_refs?: Record[]; + metadata?: Record; +} +export interface PreviewLease { + schema: typeof PREVIEW_LEASE_SCHEMA; + public_url?: string; + preview_public_url?: string; + site_url?: string; + local_url?: string; + lease?: PreviewLeaseMetadata; + reachability?: PreviewReachabilityEvidence; + alignment?: PreviewAlignmentEvidence; + evidence_refs?: Record[]; + provenance?: Record; + metadata?: Record; +} +export interface RuntimeAccess { + schema: typeof RUNTIME_ACCESS_SCHEMA; + preview_url?: string; + public_url?: string; + site_url?: string; + local_url?: string; + admin_url?: string; + lease?: PreviewLease; + reviewer_access?: Record; + metadata?: Record; +} +export type PreviewLeaseLifecycleStatus = "active" | "expired" | "released" | "unknown"; +export type BrowserContainedSiteLifecycleStatus = "recoverable_prepared_runtime" | "current" | "live" | "materialized" | "miss" | "expired" | "blocked" | "disabled" | "incompatible" | "unknown" | (string & {}); +export interface BrowserContainedSiteIdentity { + schema: "wp-codebox/browser-contained-site/v1"; + site_id: string; + preview_id?: string; + session_id?: string; + status?: BrowserContainedSiteLifecycleStatus; + source_digest?: { + algorithm: "sha256" | (string & {}); + value: string; + }; + resolution?: Record; + prepared_runtime?: Record; + blueprint_ref?: Record; + preview_boot?: BrowserPreviewBootConfig; + preview_lease?: PreviewLease; + runtime_access?: RuntimeAccess; + session?: Record; + recovery?: Record; + metadata?: Record; +} +export interface BrowserContainedSiteStatus { + schema: typeof BROWSER_CONTAINED_SITE_STATUS_SCHEMA; + success: boolean; + site_id: string; + status: BrowserContainedSiteLifecycleStatus; + source_digest: { + algorithm: "sha256" | (string & {}); + value: string; + }; + resolution?: Record; + prepared_runtime?: Record; + blueprint_ref?: Record; + metadata?: Record; +} +export interface BrowserPreviewBootConfig { + schema: typeof BROWSER_PREVIEW_BOOT_CONFIG_SCHEMA; + session_id?: string; + scope?: string; + client_module_url?: string; + remote_url?: string; + cors_proxy_url?: string; + blueprint_ref: BrowserBlueprintRef; + preview?: PreviewLease; + runtime_access?: RuntimeAccess; + contained_site?: Record; + artifacts?: Record; + provenance?: Record; +} +/** The sole executable blueprint handoff in the public preview boot DTO. */ +export interface BrowserBlueprintRef { + schema: "wp-codebox/browser-blueprint-ref/v1"; + ref: string; + hydratable: true; + hydrator_ability: string; + hydration_endpoint: string; +} +export interface BrowserSessionProductDto { + schema: typeof BROWSER_SESSION_PRODUCT_DTO_SCHEMA; + source_schema?: string; + success: boolean; + status?: string; + execution?: string; + execution_scope?: string; + permission_model?: string; + session_id?: string; + contained_site?: Record; + task?: string; + target?: Record; + agent?: string; + provider?: string; + model?: string; + preview_boot?: BrowserPreviewBootConfig; + runtime_access?: RuntimeAccess; + signals?: Record; + artifacts?: Record; + error?: Record; +} +export interface BrowserContainedSiteOpenEnvelope { + schema: typeof BROWSER_CONTAINED_SITE_OPEN_SCHEMA; + success: boolean; + site_id: string; + status: BrowserContainedSiteLifecycleStatus; + resolution?: Record; + contained_site?: BrowserContainedSiteIdentity; + source_digest?: { + algorithm: "sha256" | (string & {}); + value: string; + }; + prepared_runtime?: Record; + blueprint_ref?: Record; + preview_boot?: BrowserPreviewBootConfig; + preview_lease?: PreviewLease; + runtime_access?: RuntimeAccess; + preview_session?: BrowserSessionProductDto; + session?: Record; + recovery?: Record; +} +export declare function runtimeProfile(input: unknown): RuntimeProfile; +export declare function normalizeRuntimeProfile(input: unknown): RuntimeProfile; +export declare function previewLease(input: unknown): PreviewLease; +export declare function runtimeAccess(input: unknown): RuntimeAccess; +export declare function normalizeRuntimeAccess(input: unknown): RuntimeAccess; +export declare function previewLeaseStatus(input: PreviewLease | unknown, now?: Date): PreviewLeaseLifecycleStatus; +export declare function isPreviewLease(input: unknown): input is PreviewLease; +export declare function previewReviewerAccess(preview: { + status?: unknown; + lifecycle?: unknown; + publicUrl?: unknown; + localUrl?: unknown; + siteUrl?: unknown; + url?: unknown; + expiresAt?: unknown; + lease?: unknown; + reviewerAuthBootstrap?: unknown; + blockers?: unknown; +} | undefined): import("./runtime-contracts.js").ArtifactPreviewReviewerAccess; +export declare const normalizePreviewReviewerAccess: typeof previewReviewerAccess; +export declare function previewLeaseSummary(lease: PreviewLease | undefined): import("./runtime-contracts.js").ArtifactPreviewLeaseSummary | undefined; +export declare function browserContainedSiteStatus(input: unknown): BrowserContainedSiteStatus; +export declare function browserContainedSiteOpenEnvelope(input: unknown): BrowserContainedSiteOpenEnvelope; +export declare function browserPreviewBootConfig(input: unknown): BrowserPreviewBootConfig; +export declare function normalizePreviewBootConfig(input: unknown): BrowserPreviewBootConfig; +//# sourceMappingURL=runtime-boundary-contracts.d.ts.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-boundary-contracts.d.ts.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-boundary-contracts.d.ts.map new file mode 100644 index 000000000..20ae9b5f9 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-boundary-contracts.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"runtime-boundary-contracts.d.ts","sourceRoot":"","sources":["../src/runtime-boundary-contracts.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,sBAAsB,EAAG,+BAAwC,CAAA;AAC9E,eAAO,MAAM,oBAAoB,EAAG,6BAAsC,CAAA;AAC1E,eAAO,MAAM,8BAA8B,EAAG,uCAAgD,CAAA;AAC9F,eAAO,MAAM,qBAAqB,EAAG,8BAAuC,CAAA;AAC5E,eAAO,MAAM,oCAAoC,EAAG,6CAAsD,CAAA;AAC1G,eAAO,MAAM,kCAAkC,EAAG,2CAAoD,CAAA;AACtG,eAAO,MAAM,kCAAkC,EAAG,2CAAoD,CAAA;AACtG,eAAO,MAAM,kCAAkC,EAAG,2CAAoD,CAAA;AAEtG,MAAM,MAAM,4BAA4B,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,OAAO,GAAG,WAAW,GAAG,SAAS,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AACnI,MAAM,MAAM,6BAA6B,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AAEnH,MAAM,W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G,gCAAgC,CAoBjG;AAkCD,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,wBAAwB,CA6BjF;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,wBAAwB,CAEnF"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-boundary-contracts.js b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-boundary-contracts.js new file mode 100644 index 000000000..8758dfedb --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-boundary-contracts.js @@ -0,0 +1,568 @@ +import { stripUndefined } from "./object-utils.js"; +export const RUNTIME_PROFILE_SCHEMA = "wp-codebox/runtime-profile/v1"; +export const PREVIEW_LEASE_SCHEMA = "wp-codebox/preview-lease/v1"; +export const PREVIEW_REVIEWER_ACCESS_SCHEMA = "wp-codebox/preview-reviewer-access/v1"; +export const RUNTIME_ACCESS_SCHEMA = "wp-codebox/runtime-access/v1"; +export const BROWSER_CONTAINED_SITE_STATUS_SCHEMA = "wp-codebox/browser-contained-site-status/v1"; +export const BROWSER_CONTAINED_SITE_OPEN_SCHEMA = "wp-codebox/browser-contained-site-open/v1"; +export const BROWSER_SESSION_PRODUCT_DTO_SCHEMA = "wp-codebox/browser-session-product-dto/v1"; +export const BROWSER_PREVIEW_BOOT_CONFIG_SCHEMA = "wp-codebox/browser-preview-boot-config/v1"; +export function runtimeProfile(input) { + const value = requireObject(input, "Runtime profile"); + if (value.schema !== RUNTIME_PROFILE_SCHEMA) + throw new Error(`Runtime profile schema must be ${RUNTIME_PROFILE_SCHEMA}.`); + return { + schema: RUNTIME_PROFILE_SCHEMA, + id: optionalString(value.id, "id"), + capabilities: normalizeStringList(value.capabilities, "capabilities"), + component_contracts: normalizeObjectList(value.component_contracts, "component_contracts"), + extra_plugins: normalizeObjectList(value.extra_plugins, "extra_plugins"), + provider_plugins: normalizeObjectList(value.provider_plugins, "provider_plugins"), + components: normalizeDependencies(value.components, "components", true) ?? [], + plugins: normalizeDependencies(value.plugins, "plugins", true), + mu_plugins: normalizeDependencies(value.mu_plugins, "mu_plugins", true), + themes: normalizeDependencies(value.themes, "themes", true), + bootstrap: value.bootstrap === undefined ? undefined : normalizeBootstrap(value.bootstrap), + overlays: normalizeDependencies(value.overlays, "overlays", true), + runtime_overlays: normalizeObjectList(value.runtime_overlays, "runtime_overlays"), + runtime_state_mounts: normalizeObjectList(value.runtime_state_mounts, "runtime_state_mounts"), + runtime_config_mounts: normalizeObjectList(value.runtime_config_mounts, "runtime_config_mounts"), + env: normalizeEnv(value.env), + readiness: value.readiness === undefined ? undefined : normalizeReadiness(value.readiness), + diagnostics: normalizeDiagnostics(value.diagnostics), + provenance: normalizeOptionalObject(value.provenance, "Runtime profile provenance"), + metadata: normalizeOptionalObject(value.metadata, "Runtime profile metadata"), + }; +} +export function normalizeRuntimeProfile(input) { + return runtimeProfile(input); +} +export function previewLease(input) { + const value = requireObject(input, "Preview lease"); + const publicUrl = optionalString(value.public_url ?? value.publicUrl, "public_url") ?? optionalString(value.preview_public_url ?? value.previewPublicUrl, "preview_public_url"); + if (value.schema !== PREVIEW_LEASE_SCHEMA) + throw new Error(`Preview lease schema must be ${PREVIEW_LEASE_SCHEMA}.`); + const lease = { + schema: PREVIEW_LEASE_SCHEMA, + public_url: publicUrl, + preview_public_url: publicUrl, + site_url: optionalString(value.site_url ?? value.siteUrl, "site_url"), + local_url: optionalString(value.local_url ?? value.localUrl, "local_url"), + lease: value.lease === undefined ? undefined : normalizeOptionalObject(value.lease, "Preview lease metadata"), + reachability: value.reachability === undefined ? undefined : normalizeReachability(value.reachability), + alignment: value.alignment === undefined ? undefined : normalizeAlignment(value.alignment), + evidence_refs: normalizeObjectList(value.evidence_refs, "Preview lease evidence_refs"), + provenance: normalizeOptionalObject(value.provenance, "Preview lease provenance"), + metadata: normalizeOptionalObject(value.metadata, "Preview lease metadata"), + }; + if (!lease.public_url && !lease.site_url && !lease.local_url) { + throw new Error("Preview lease must include public_url, preview_public_url, site_url, or local_url."); + } + return lease; +} +export function runtimeAccess(input) { + const value = requireObject(input, "Runtime access"); + const schema = optionalString(value.schema, "runtime_access.schema"); + if (schema && schema !== RUNTIME_ACCESS_SCHEMA) + throw new Error(`Runtime access schema must be ${RUNTIME_ACCESS_SCHEMA}.`); + const lease = value.lease === undefined ? undefined : previewLease(value.lease); + const reviewerAccess = normalizeOptionalObject(value.reviewer_access ?? value.reviewerAccess, "runtime_access.reviewer_access"); + const previewUrl = optionalString(value.preview_url ?? value.previewUrl, "runtime_access.preview_url") + ?? optionalString(value.public_url ?? value.publicUrl, "runtime_access.public_url") + ?? optionalString(value.preview_public_url ?? value.previewPublicUrl, "runtime_access.preview_public_url") + ?? optionalString(value.site_url ?? value.siteUrl, "runtime_access.site_url") + ?? optionalString(reviewerAccess?.openUrl, "runtime_access.reviewer_access.openUrl") + ?? optionalString(reviewerAccess?.targetUrl, "runtime_access.reviewer_access.targetUrl") + ?? lease?.public_url + ?? lease?.preview_public_url + ?? lease?.site_url + ?? optionalString(value.local_url ?? value.localUrl, "runtime_access.local_url") + ?? lease?.local_url; + const publicUrl = optionalString(value.public_url ?? value.publicUrl, "runtime_access.public_url") + ?? optionalString(value.preview_public_url ?? value.previewPublicUrl, "runtime_access.preview_public_url") + ?? lease?.public_url + ?? lease?.preview_public_url; + const siteUrl = optionalString(value.site_url ?? value.siteUrl, "runtime_access.site_url") ?? lease?.site_url; + const localUrl = optionalString(value.local_url ?? value.localUrl, "runtime_access.local_url") ?? lease?.local_url; + const access = { + schema: RUNTIME_ACCESS_SCHEMA, + preview_url: previewUrl, + public_url: publicUrl, + site_url: siteUrl, + local_url: localUrl, + admin_url: optionalString(value.admin_url ?? value.adminUrl, "runtime_access.admin_url"), + lease, + reviewer_access: reviewerAccess, + metadata: normalizeOptionalObject(value.metadata, "runtime_access.metadata"), + }; + if (!access.preview_url && !access.public_url && !access.site_url && !access.local_url && !access.admin_url && !access.lease && !access.reviewer_access) { + throw new Error("Runtime access must include preview_url, public_url, site_url, local_url, admin_url, lease, or reviewer_access."); + } + return stripUndefined(access); +} +export function normalizeRuntimeAccess(input) { + return runtimeAccess(input); +} +export function previewLeaseStatus(input, now = new Date()) { + const lease = isPreviewLease(input) ? input : previewLease(input); + const declaredStatus = typeof lease.lease?.status === "string" ? lease.lease.status : ""; + if (declaredStatus === "released") + return "released"; + const expiresAt = lease.lease?.expires_at; + if (typeof expiresAt === "string" && expiresAt.trim() !== "") { + const expires = Date.parse(expiresAt); + if (!Number.isNaN(expires) && expires <= now.getTime()) + return "expired"; + } + if (declaredStatus === "active" || lease.public_url || lease.preview_public_url || lease.site_url || lease.local_url) + return "active"; + if (declaredStatus === "expired") + return "expired"; + return "unknown"; +} +export function isPreviewLease(input) { + return Boolean(input && typeof input === "object" && !Array.isArray(input) && input.schema === PREVIEW_LEASE_SCHEMA); +} +export function previewReviewerAccess(preview) { + const lease = normalizedPreviewAccessLease(preview?.lease); + const leaseSummary = previewLeaseSummary(lease); + const expiresAt = optionalString(preview?.expiresAt, "expiresAt") ?? leaseSummary?.expiresAt; + if (!preview || preview.status !== "available" || preview.lifecycle !== "held-after-run") { + return { + schema: PREVIEW_REVIEWER_ACCESS_SCHEMA, + status: "unavailable", + outcome: "blocked", + mode: "none", + reviewerSafe: false, + ...(leaseSummary ? { lease: { ...leaseSummary, reviewerSafe: false } } : {}), + reason: "preview-not-held", + }; + } + const reviewerAuthBootstrap = normalizeReviewerAuthBootstrap(preview.reviewerAuthBootstrap); + if (reviewerAuthBootstrap) { + return { + schema: PREVIEW_REVIEWER_ACCESS_SCHEMA, + status: "ready", + outcome: "bootstrap", + mode: "auth-bootstrap", + reviewerSafe: true, + openUrl: reviewerAuthBootstrap.bootstrapUrl, + targetUrl: reviewerAuthBootstrap.redirectUrl, + expiresAt: reviewerAuthBootstrap.expiresAt, + ...(leaseSummary ? { lease: { ...leaseSummary, reviewerSafe: true } } : {}), + bootstrap: reviewerAuthBootstrap, + }; + } + const blockers = normalizePreviewBlockers(preview.blockers); + if (blockers.length > 0) { + return { + schema: PREVIEW_REVIEWER_ACCESS_SCHEMA, + status: "blocked", + outcome: blockers.some((blocker) => blocker.code === "external-wordpress-admin-auth-unavailable") ? "auth-required" : "blocked", + mode: "none", + reviewerSafe: false, + blockers, + ...(expiresAt ? { expiresAt } : {}), + ...(leaseSummary ? { lease: { ...leaseSummary, reviewerSafe: false } } : {}), + reason: blockers[0]?.code, + }; + } + const safeUrl = safeNonLocalPreviewUrl(optionalString(preview.publicUrl, "publicUrl")) ?? safeNonLocalPreviewUrl(lease?.public_url) ?? safeNonLocalPreviewUrl(lease?.preview_public_url) ?? safeNonLocalPreviewUrl(optionalString(preview.url, "url")); + if (safeUrl) { + return { + schema: PREVIEW_REVIEWER_ACCESS_SCHEMA, + status: "ready", + outcome: "public", + mode: "direct-url", + reviewerSafe: true, + openUrl: safeUrl, + targetUrl: safeUrl, + ...(expiresAt ? { expiresAt } : {}), + ...(leaseSummary ? { lease: { ...leaseSummary, reviewerSafe: true } } : {}), + }; + } + return { + schema: PREVIEW_REVIEWER_ACCESS_SCHEMA, + status: "blocked", + outcome: "local", + mode: "none", + reviewerSafe: false, + ...(expiresAt ? { expiresAt } : {}), + ...(leaseSummary ? { lease: { ...leaseSummary, reviewerSafe: false } } : {}), + reason: "local-preview-requires-auth-bootstrap-or-public-url", + }; +} +export const normalizePreviewReviewerAccess = previewReviewerAccess; +function normalizedPreviewAccessLease(input) { + if (input === undefined) { + return undefined; + } + return previewLease(input); +} +export function previewLeaseSummary(lease) { + if (!lease) { + return undefined; + } + return { + schema: "wp-codebox/preview-lease-summary/v1", + status: previewLeaseStatus(lease), + ...(lease.public_url ? { publicUrl: lease.public_url } : {}), + ...(lease.local_url ? { localUrl: lease.local_url } : {}), + ...(lease.site_url ? { siteUrl: lease.site_url } : {}), + ...(lease.lease?.expires_at ? { expiresAt: lease.lease.expires_at } : {}), + ...(lease.lease?.owner ? { owner: lease.lease.owner } : {}), + ...(lease.lease?.provider ? { provider: lease.lease.provider } : {}), + ...(lease.alignment?.status ? { alignmentStatus: lease.alignment.status } : {}), + ...(lease.reachability?.status ? { reachabilityStatus: lease.reachability.status } : {}), + reviewerSafe: Boolean(safeNonLocalPreviewUrl(lease.public_url) || safeNonLocalPreviewUrl(lease.preview_public_url)), + }; +} +export function browserContainedSiteStatus(input) { + const value = requireObject(input, "Browser contained site status"); + if (value.schema !== BROWSER_CONTAINED_SITE_STATUS_SCHEMA) + throw new Error(`Browser contained site status schema must be ${BROWSER_CONTAINED_SITE_STATUS_SCHEMA}.`); + const digest = requireObject(value.source_digest, "Browser contained site status source_digest"); + const digestValue = optionalString(digest.value, "source_digest.value"); + if (!digestValue || !/^[a-f0-9]{64}$/.test(digestValue)) + throw new Error("source_digest.value must be a 64-character sha256 digest."); + return { + schema: BROWSER_CONTAINED_SITE_STATUS_SCHEMA, + success: value.success === true, + site_id: requiredIdentifier(value.site_id, "site_id"), + status: requiredIdentifier(value.status, "status"), + source_digest: { + algorithm: optionalString(digest.algorithm, "source_digest.algorithm") ?? "sha256", + value: digestValue, + }, + resolution: normalizeOptionalObject(value.resolution, "resolution"), + prepared_runtime: normalizeOptionalObject(value.prepared_runtime, "prepared_runtime"), + blueprint_ref: normalizeOptionalObject(value.blueprint_ref, "blueprint_ref"), + metadata: normalizeOptionalObject(value.metadata, "metadata"), + }; +} +export function browserContainedSiteOpenEnvelope(input) { + const value = requireObject(input, "Browser contained site open envelope"); + if (value.schema !== BROWSER_CONTAINED_SITE_OPEN_SCHEMA) + throw new Error(`Browser contained site open schema must be ${BROWSER_CONTAINED_SITE_OPEN_SCHEMA}.`); + return { + schema: BROWSER_CONTAINED_SITE_OPEN_SCHEMA, + success: value.success === true, + site_id: requiredIdentifier(value.site_id, "site_id"), + status: requiredIdentifier(value.status, "status"), + resolution: normalizeOptionalObject(value.resolution, "resolution"), + contained_site: value.contained_site === undefined ? undefined : normalizeContainedSiteIdentity(value.contained_site), + source_digest: value.source_digest === undefined ? undefined : normalizeSourceDigest(value.source_digest), + prepared_runtime: normalizeOptionalObject(value.prepared_runtime, "prepared_runtime"), + blueprint_ref: normalizeOptionalObject(value.blueprint_ref, "blueprint_ref"), + preview_boot: value.preview_boot === undefined ? undefined : normalizePreviewBootConfig(value.preview_boot), + preview_lease: value.preview_lease === undefined ? undefined : previewLease(value.preview_lease), + runtime_access: value.runtime_access === undefined ? undefined : runtimeAccess(value.runtime_access), + preview_session: value.preview_session === undefined ? undefined : normalizeBrowserSessionProductDto(value.preview_session), + session: normalizeOptionalObject(value.session, "session"), + recovery: normalizeOptionalObject(value.recovery, "recovery"), + }; +} +function normalizeContainedSiteIdentity(input) { + const value = requireObject(input, "Browser contained site identity"); + if (value.schema !== "wp-codebox/browser-contained-site/v1") + throw new Error("Browser contained site identity schema must be wp-codebox/browser-contained-site/v1."); + return { + schema: "wp-codebox/browser-contained-site/v1", + site_id: requiredIdentifier(value.site_id, "contained_site.site_id"), + preview_id: optionalString(value.preview_id, "contained_site.preview_id"), + session_id: optionalString(value.session_id, "contained_site.session_id"), + status: optionalString(value.status, "contained_site.status"), + source_digest: value.source_digest === undefined ? undefined : normalizeSourceDigest(value.source_digest), + resolution: normalizeOptionalObject(value.resolution, "contained_site.resolution"), + prepared_runtime: normalizeOptionalObject(value.prepared_runtime, "contained_site.prepared_runtime"), + blueprint_ref: normalizeOptionalObject(value.blueprint_ref, "contained_site.blueprint_ref"), + preview_boot: value.preview_boot === undefined ? undefined : normalizePreviewBootConfig(value.preview_boot), + preview_lease: value.preview_lease === undefined ? undefined : previewLease(value.preview_lease), + runtime_access: value.runtime_access === undefined ? undefined : runtimeAccess(value.runtime_access), + session: normalizeOptionalObject(value.session, "contained_site.session"), + recovery: normalizeOptionalObject(value.recovery, "contained_site.recovery"), + metadata: normalizeOptionalObject(value.metadata, "contained_site.metadata"), + }; +} +function normalizeSourceDigest(input) { + const digest = requireObject(input, "source_digest"); + const digestValue = optionalString(digest.value, "source_digest.value"); + if (!digestValue || !/^[a-f0-9]{64}$/.test(digestValue)) + throw new Error("source_digest.value must be a 64-character sha256 digest."); + return { + algorithm: optionalString(digest.algorithm, "source_digest.algorithm") ?? "sha256", + value: digestValue, + }; +} +export function browserPreviewBootConfig(input) { + const value = requireObject(input, "Browser preview boot config"); + if (value.schema !== BROWSER_PREVIEW_BOOT_CONFIG_SCHEMA) + throw new Error(`Browser preview boot config schema must be ${BROWSER_PREVIEW_BOOT_CONFIG_SCHEMA}.`); + const blueprintRef = requireObject(value.blueprint_ref, "preview_boot.blueprint_ref"); + if (blueprintRef.schema !== "wp-codebox/browser-blueprint-ref/v1") + throw new Error("preview_boot.blueprint_ref schema must be wp-codebox/browser-blueprint-ref/v1."); + if (!requiredIdentifier(blueprintRef.ref, "preview_boot.blueprint_ref.ref")) + throw new Error("preview_boot.blueprint_ref.ref is required."); + if (blueprintRef.hydratable !== true) + throw new Error("preview_boot.blueprint_ref must be hydratable."); + if (!requiredIdentifier(blueprintRef.hydrator_ability, "preview_boot.blueprint_ref.hydrator_ability")) + throw new Error("preview_boot.blueprint_ref.hydrator_ability is required."); + if (!requiredIdentifier(blueprintRef.hydration_endpoint, "preview_boot.blueprint_ref.hydration_endpoint")) + throw new Error("preview_boot.blueprint_ref.hydration_endpoint is required."); + return { + schema: BROWSER_PREVIEW_BOOT_CONFIG_SCHEMA, + session_id: optionalString(value.session_id, "preview_boot.session_id"), + scope: optionalString(value.scope, "preview_boot.scope"), + client_module_url: optionalString(value.client_module_url, "preview_boot.client_module_url"), + remote_url: optionalString(value.remote_url, "preview_boot.remote_url"), + cors_proxy_url: optionalString(value.cors_proxy_url, "preview_boot.cors_proxy_url"), + blueprint_ref: { + schema: "wp-codebox/browser-blueprint-ref/v1", + ref: requiredIdentifier(blueprintRef.ref, "preview_boot.blueprint_ref.ref"), + hydratable: true, + hydrator_ability: requiredIdentifier(blueprintRef.hydrator_ability, "preview_boot.blueprint_ref.hydrator_ability"), + hydration_endpoint: requiredIdentifier(blueprintRef.hydration_endpoint, "preview_boot.blueprint_ref.hydration_endpoint"), + }, + preview: value.preview === undefined ? undefined : previewLease(value.preview), + runtime_access: value.runtime_access === undefined ? undefined : runtimeAccess(value.runtime_access), + contained_site: normalizeOptionalObject(value.contained_site, "preview_boot.contained_site"), + artifacts: normalizeOptionalObject(value.artifacts, "preview_boot.artifacts"), + provenance: normalizeOptionalObject(value.provenance, "preview_boot.provenance"), + }; +} +export function normalizePreviewBootConfig(input) { + return browserPreviewBootConfig(input); +} +function normalizeReachability(input) { + const value = requireObject(input, "Preview reachability"); + return { + status: (optionalString(value.status, "reachability.status") ?? "unknown"), + checked_at: optionalString(value.checked_at, "reachability.checked_at"), + http_status: typeof value.http_status === "number" ? value.http_status : undefined, + probes: normalizeObjectList(value.probes, "reachability.probes"), + evidence_refs: normalizeObjectList(value.evidence_refs, "reachability.evidence_refs"), + metadata: normalizeOptionalObject(value.metadata, "reachability.metadata"), + }; +} +function normalizeBrowserSessionProductDto(input) { + const value = requireObject(input, "Browser session product DTO"); + if (value.schema !== BROWSER_SESSION_PRODUCT_DTO_SCHEMA) + throw new Error(`Browser session product DTO schema must be ${BROWSER_SESSION_PRODUCT_DTO_SCHEMA}.`); + return { + schema: BROWSER_SESSION_PRODUCT_DTO_SCHEMA, + source_schema: optionalString(value.source_schema, "preview_session.source_schema"), + success: value.success === true, + status: optionalString(value.status, "preview_session.status"), + execution: optionalString(value.execution, "preview_session.execution"), + execution_scope: optionalString(value.execution_scope, "preview_session.execution_scope"), + permission_model: optionalString(value.permission_model, "preview_session.permission_model"), + session_id: optionalString(value.session_id, "preview_session.session_id"), + contained_site: normalizeOptionalObject(value.contained_site, "preview_session.contained_site"), + task: optionalString(value.task, "preview_session.task"), + target: normalizeOptionalObject(value.target, "preview_session.target"), + agent: optionalString(value.agent, "preview_session.agent"), + provider: optionalString(value.provider, "preview_session.provider"), + model: optionalString(value.model, "preview_session.model"), + preview_boot: value.preview_boot === undefined ? undefined : normalizePreviewBootConfig(value.preview_boot), + runtime_access: value.runtime_access === undefined ? undefined : runtimeAccess(value.runtime_access), + signals: normalizeOptionalObject(value.signals, "preview_session.signals"), + artifacts: normalizeOptionalObject(value.artifacts, "preview_session.artifacts"), + error: normalizeOptionalObject(value.error, "preview_session.error"), + }; +} +function normalizeReviewerAuthBootstrap(input) { + if (input === undefined) + return undefined; + const value = requireObject(input, "reviewerAuthBootstrap"); + const evidence = requireObject(value.evidence, "reviewerAuthBootstrap.evidence"); + return { + schema: "wp-codebox/reviewer-auth-bootstrap/v1", + kind: "local-wordpress-admin-fixture", + reviewerSafe: true, + bootstrapUrl: requiredUrl(value.bootstrapUrl, "reviewerAuthBootstrap.bootstrapUrl"), + redirectUrl: requiredUrl(value.redirectUrl, "reviewerAuthBootstrap.redirectUrl"), + expiresAt: requiredIdentifier(value.expiresAt, "reviewerAuthBootstrap.expiresAt"), + evidence: { + command: requiredIdentifier(evidence.command, "reviewerAuthBootstrap.evidence.command"), + auth: "wordpress-admin", + userId: typeof evidence.userId === "number" ? evidence.userId : Number(evidence.userId), + }, + }; +} +function normalizePreviewBlockers(input) { + if (!Array.isArray(input)) + return []; + return input.map((entry, index) => { + const value = requireObject(entry, `preview.blockers[${index}]`); + const evidence = requireObject(value.evidence, `preview.blockers[${index}].evidence`); + return { + schema: "wp-codebox/preview-blocker/v1", + kind: "unsupported-preview", + code: requiredIdentifier(value.code, `preview.blockers[${index}].code`), + message: optionalString(value.message, `preview.blockers[${index}].message`) ?? value.code ?? "Preview is blocked.", + retryable: false, + reviewerSafe: false, + evidence: { + command: requiredIdentifier(evidence.command, `preview.blockers[${index}].evidence.command`), + auth: requiredIdentifier(evidence.auth, `preview.blockers[${index}].evidence.auth`), + }, + }; + }); +} +function safeNonLocalPreviewUrl(url) { + if (!url) + return undefined; + try { + const parsed = new URL(url); + if (parsed.protocol !== "http:" && parsed.protocol !== "https:") + return undefined; + return isLocalPreviewHost(parsed.hostname) ? undefined : url; + } + catch { + return undefined; + } +} +function isLocalPreviewHost(hostname) { + const normalized = hostname.toLowerCase().replace(/^\[|\]$/g, ""); + return normalized === "localhost" || normalized === "0.0.0.0" || normalized === "127.0.0.1" || normalized === "::1" || normalized.startsWith("127."); +} +function requiredUrl(value, label) { + const url = optionalString(value, label); + if (!url) + throw new Error(`${label} must be a URL.`); + try { + new URL(url); + return url; + } + catch { + throw new Error(`${label} must be a URL.`); + } +} +function normalizeDependencies(value, label, optional = false) { + if (value === undefined && optional) + return undefined; + if (!Array.isArray(value)) + throw new Error(`Runtime profile ${label} must be an array.`); + return value.map((entry, index) => normalizeDependency(entry, `${label}[${index}]`)); +} +function normalizeObjectList(value, label) { + if (value === undefined) + return undefined; + if (!Array.isArray(value)) + throw new Error(`Runtime profile ${label} must be an array.`); + return value.map((entry, index) => requireObject(entry, `Runtime profile ${label}[${index}]`)); +} +function normalizeDependency(input, label) { + const value = requireObject(input, `Runtime profile ${label}`); + const kind = requiredIdentifier(value.kind, `${label}.kind`); + const slug = requiredIdentifier(value.slug, `${label}.slug`); + return { + kind, + slug, + name: optionalString(value.name, `${label}.name`), + source: optionalString(value.source, `${label}.source`), + target: optionalString(value.target, `${label}.target`), + version: optionalString(value.version, `${label}.version`), + activate: typeof value.activate === "boolean" ? value.activate : undefined, + required: typeof value.required === "boolean" ? value.required : undefined, + readiness: optionalString(value.readiness, `${label}.readiness`), + provenance: normalizeOptionalObject(value.provenance, `${label}.provenance`), + metadata: normalizeOptionalObject(value.metadata, `${label}.metadata`), + }; +} +function normalizeBootstrap(input) { + const value = requireObject(input, "Runtime profile bootstrap"); + return { + mode: optionalString(value.mode, "bootstrap.mode"), + entrypoint: optionalString(value.entrypoint, "bootstrap.entrypoint"), + blueprint_ref: optionalString(value.blueprint_ref, "bootstrap.blueprint_ref"), + steps: normalizeStringList(value.steps, "bootstrap.steps"), + provenance: normalizeOptionalObject(value.provenance, "bootstrap.provenance"), + }; +} +function normalizeReadiness(input) { + const value = requireObject(input, "Runtime profile readiness"); + const checks = normalizeBooleanMap(value.checks, "readiness.checks"); + return { + status: requiredIdentifier(value.status, "readiness.status"), + checks, + missing: normalizeStringList(value.missing, "readiness.missing"), + evidence: normalizeOptionalObject(value.evidence, "readiness.evidence"), + }; +} +function normalizeDiagnostics(input) { + if (input === undefined) + return undefined; + if (!Array.isArray(input)) + throw new Error("Runtime profile diagnostics must be an array."); + return input.map((entry, index) => { + const value = requireObject(entry, `Runtime profile diagnostics[${index}]`); + return { + code: requiredIdentifier(value.code, `diagnostics[${index}].code`), + status: optionalString(value.status, `diagnostics[${index}].status`), + message: optionalString(value.message, `diagnostics[${index}].message`), + severity: optionalString(value.severity, `diagnostics[${index}].severity`), + evidence: normalizeOptionalObject(value.evidence, `diagnostics[${index}].evidence`), + }; + }); +} +function normalizeAlignment(input) { + const value = requireObject(input, "Preview alignment"); + return { + status: requiredIdentifier(value.status, "alignment.status"), + checked_at: optionalString(value.checked_at, "alignment.checked_at"), + preview_matches_site: typeof value.preview_matches_site === "boolean" ? value.preview_matches_site : undefined, + preview_matches_local: typeof value.preview_matches_local === "boolean" ? value.preview_matches_local : undefined, + evidence: normalizeOptionalObject(value.evidence, "alignment.evidence"), + }; +} +function normalizeEnv(value) { + if (value === undefined) + return undefined; + const env = requireObject(value, "Runtime profile env"); + return Object.fromEntries(Object.entries(env).map(([key, entry]) => { + if (!/^[A-Z_][A-Z0-9_]*$/.test(key)) + throw new Error(`Runtime profile env key is invalid: ${key}.`); + if (typeof entry !== "string") + throw new Error(`Runtime profile env ${key} must be a string.`); + return [key, entry]; + })); +} +function normalizeBooleanMap(value, label) { + if (value === undefined) + return undefined; + const map = requireObject(value, label); + return Object.fromEntries(Object.entries(map).map(([key, entry]) => [key, Boolean(entry)])); +} +function normalizeStringList(value, label) { + if (value === undefined) + return undefined; + if (!Array.isArray(value)) + throw new Error(`${label} must be an array.`); + return [...new Set(value.map((entry) => String(entry).trim()).filter(Boolean))]; +} +function normalizeOptionalObject(value, label) { + if (value === undefined) + return undefined; + return requireObject(value, label); +} +function requireObject(value, label) { + if (!value || typeof value !== "object" || Array.isArray(value)) + throw new Error(`${label} must be an object.`); + return value; +} +function requiredIdentifier(value, label) { + const normalized = optionalString(value, label); + if (!normalized || !/^[A-Za-z0-9][A-Za-z0-9_.:-]*$/.test(normalized)) + throw new Error(`${label} must be a stable identifier.`); + return normalized; +} +function optionalString(value, label) { + if (value === undefined) + return undefined; + if (typeof value !== "string") + throw new Error(`${label} must be a string.`); + const normalized = value.trim(); + return normalized === "" ? undefined : normalized; +} +//# sourceMappingURL=runtime-boundary-contracts.js.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-boundary-contracts.js.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-boundary-contracts.js.map new file mode 100644 index 000000000..57b0ac548 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-boundary-contracts.js.map @@ -0,0 +1 @@ +{"version":3,"file":"runtime-boundary-contracts.js","sourceRoot":"","sources":["../src/runtime-boundary-contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAElD,MAAM,CAAC,MAAM,sBAAsB,GAAG,+BAAwC,CAAA;AAC9E,MAAM,CAAC,MAAM,oBAAoB,GAAG,6BAAsC,CAAA;AAC1E,MAAM,CAAC,MAAM,8BAA8B,GAAG,uCAAgD,CAAA;AAC9F,MAAM,CAAC,MAAM,qBAAqB,GAAG,8BAAuC,CAAA;AAC5E,MAAM,CAAC,MAAM,oCAAoC,GAAG,6CAAsD,CAAA;AAC1G,MAAM,CAAC,MAAM,kCAAkC,GAAG,2CAAoD,CAAA;AACtG,MAAM,CAAC,MAAM,kCAAkC,GAAG,2CAAoD,CAAA;AACtG,MAAM,CAAC,MAAM,kCAAkC,GAAG,2CAAoD,CAAA;AAiOtG,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,EAAE,iBAAiB,CAA4B,CAAA;IAChF,IAAI,KAAK,CAAC,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C,KAAc,EAAE,KAAa;IAC5D,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IACzC,OAAO,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AACpC,CAAC;AAED,SAAS,aAAa,CAAC,KAAc,EAAE,KAAa;IAClD,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,qBAAqB,CAAC,CAAA;IAC/G,OAAO,KAAgC,CAAA;AACzC,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAc,EAAE,KAAa;IACvD,MAAM,UAAU,GAAG,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;IAC/C,IAAI,CAAC,UAAU,IAAI,CAAC,+BAA+B,CAAC,IAAI,CAAC,UAAU,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,+BAA+B,CAAC,CAAA;IAC9H,OAAO,UAAU,CAAA;AACnB,CAAC;AAED,SAAS,cAAc,CAAC,KAAc,EAAE,KAAa;IACnD,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IACzC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,oBAAoB,CAAC,CAAA;IAC5E,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAA;IAC/B,OAAO,UAAU,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAA;AACnD,CAAC"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-command-result.d.ts b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-command-result.d.ts new file mode 100644 index 000000000..9c9387f0f --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-command-result.d.ts @@ -0,0 +1,12 @@ +import { type RuntimeCommandResultEnvelope, type RuntimeCommandResultError, type RuntimeCommandResultStatus, type RuntimeEpisodeTraceRef } from "./runtime-contracts.js"; +export declare function createRuntimeCommandResultEnvelope(result: Omit): RuntimeCommandResultEnvelope; +export interface RuntimeCommandResultEnvelopeFromOutputInput { + status?: RuntimeCommandResultStatus; + stdout?: string; + stderr?: string; + diagnostics?: unknown; + artifactRefs?: RuntimeEpisodeTraceRef[]; + error?: RuntimeCommandResultError; +} +export declare function runtimeCommandResultEnvelopeFromOutput(input: RuntimeCommandResultEnvelopeFromOutputInput): RuntimeCommandResultEnvelope; +//# sourceMappingURL=runtime-command-result.d.ts.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-command-result.d.ts.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-command-result.d.ts.map new file mode 100644 index 000000000..3c5baff72 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-command-result.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"runtime-command-result.d.ts","sourceRoot":"","sources":["../src/runtime-command-result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,KAAK,4BAA4B,EAAE,KAAK,yBAAyB,EAAE,KAAK,0BAA0B,EAAE,KAAK,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAEvM,wBAAgB,kCAAkC,CAAC,MAAM,EAAE,IAAI,CAAC,4BAA4B,EAAE,QAAQ,CAAC,GAAG,4BAA4B,CAKrI;AAED,MAAM,WAAW,2CAA2C;IAC1D,MAAM,CAAC,EAAE,0BAA0B,CAAA;IACnC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,YAAY,CAAC,EAAE,sBAAsB,EAAE,CAAA;IACvC,KAAK,CAAC,EAAE,yBAAyB,CAAA;CAClC;AAED,wBAAgB,sCAAsC,CAAC,KAAK,EAAE,2CAA2C,GAAG,4BAA4B,CAYvI"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-command-result.js b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-command-result.js new file mode 100644 index 000000000..34af8ab20 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-command-result.js @@ -0,0 +1,33 @@ +import { RUNTIME_COMMAND_RESULT_SCHEMA } from "./runtime-contracts.js"; +export function createRuntimeCommandResultEnvelope(result) { + return { + schema: RUNTIME_COMMAND_RESULT_SCHEMA, + ...result, + }; +} +export function runtimeCommandResultEnvelopeFromOutput(input) { + const stdout = input.stdout ?? ""; + const json = parseRuntimeCommandJsonStdout(stdout); + return createRuntimeCommandResultEnvelope({ + status: input.status ?? "ok", + stdout, + stderr: input.stderr ?? "", + ...(json === undefined ? {} : { json }), + ...(input.diagnostics === undefined ? {} : { diagnostics: input.diagnostics }), + ...(input.artifactRefs?.length ? { artifactRefs: input.artifactRefs } : {}), + ...(input.error ? { error: input.error } : {}), + }); +} +function parseRuntimeCommandJsonStdout(stdout) { + const trimmed = stdout.trim(); + if (!trimmed || !(trimmed.startsWith("{") || trimmed.startsWith("["))) { + return undefined; + } + try { + return JSON.parse(trimmed); + } + catch { + return undefined; + } +} +//# sourceMappingURL=runtime-command-result.js.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-command-result.js.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-command-result.js.map new file mode 100644 index 000000000..461463916 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-command-result.js.map @@ -0,0 +1 @@ +{"version":3,"file":"runtime-command-result.js","sourceRoot":"","sources":["../src/runtime-command-result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAmI,MAAM,wBAAwB,CAAA;AAEvM,MAAM,UAAU,kCAAkC,CAAC,MAAoD;IACrG,OAAO;QACL,MAAM,EAAE,6BAA6B;QACr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P,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-contracts.d.ts b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-contracts.d.ts new file mode 100644 index 000000000..8a4fbf73e --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-contracts.d.ts @@ -0,0 +1,1261 @@ +import type { RuntimePolicy } from "./runtime-policy.js"; +import { SANDBOX_WORKSPACE_ROOT } from "./runtime-action-adapter.js"; +import type { ArtifactFileDigest, ArtifactManifestFile, ArtifactSpec, ArtifactViewerMetadata } from "./artifact-manifest.js"; +import type { HostToolDefinition, HostToolRegistry } from "./host-tool-registry.js"; +import type { BackendNeutralRuntimeProvenance, RuntimePHPWasmBundledExtension, RuntimePHPWasmExtensionManifest, RuntimeWorkerCount, RuntimeWordPressAssetSpec, RuntimeWordPressDatabaseSetupContract, RuntimeWordPressEnvironmentSpec, RuntimeWordPressInstallModeContract, RuntimeWordPressProvenance } from "./runtime-neutral-contracts.js"; +import type { RUNTIME_EPISODE_ACTION_SCHEMA, RUNTIME_EPISODE_OBSERVATION_SCHEMA, RUNTIME_EPISODE_SNAPSHOT_SCHEMA, RUNTIME_EPISODE_TRACE_SCHEMA } from "./runtime-episode-contracts.js"; +import type { PreviewLease, PreviewLeaseLifecycleStatus, PreviewReachabilityEvidence } from "./runtime-boundary-contracts.js"; +export type RuntimeBackendKind = "wordpress-playground" | (string & {}); +export type SandboxWorkspaceMode = "repo-backed" | "site-backed"; +export interface EnvironmentSpec extends RuntimeWordPressEnvironmentSpec { +} +export type RuntimeWordPressInstallMode = RuntimeWordPressInstallModeContract; +export type RuntimeWordPressDatabaseSetup = RuntimeWordPressDatabaseSetupContract; +export type { RuntimeWorkerCount }; +export interface RuntimeAssetSpec extends RuntimeWordPressAssetSpec { +} +export interface RuntimeCreateSpec { + backend: RuntimeBackendKind; + environment: EnvironmentSpec; + policy: RuntimePolicy; + hostTools?: HostToolRegistry | HostToolDefinition[]; + artifactsDirectory?: string; + runtimeEnv?: Record; + secretEnv?: Record; + /** Maps an environment target to the secretEnv name that supplies its value. */ + secretEnvTargets?: Record; + metadata?: Record; + preview?: RuntimePreviewSpec; + onBrowserStartupProgress?: BrowserStartupProgressListener; +} +export type BrowserStartupProgressPhase = "preview:start" | "preview:loading-client" | "preview:loading-wordpress" | "preview:applying-blueprint" | "preview:installing-dependencies" | "preview:activating-dependencies" | "preview:connecting-client" | "preview:ready" | "preview:error" | (string & {}); +export type BrowserStartupProgressStatus = "running" | "complete" | "failed"; +export interface BrowserStartupProgressEvent { + schema: "wp-codebox/browser-startup-progress/v1"; + phase: BrowserStartupProgressPhase; + status: BrowserStartupProgressStatus; + label?: string; + elapsed_ms?: number; + detail?: Record; + normalized_progress?: unknown; +} +export type BrowserStartupProgressListener = (event: BrowserStartupProgressEvent) => void | Promise; +export interface RuntimePreviewSpec { + publicUrl?: string; + siteUrl?: string; + port?: number; + bind?: string; + lease?: PreviewLease; + leaseProvider?: RuntimePreviewLeaseProvider; +} +export interface RuntimePreviewLeaseProvider { + acquire(request: RuntimePreviewLeaseAcquireRequest): Promise | PreviewLease; + probe?(lease: PreviewLease): Promise | RuntimePreviewLeaseProbeResult; + release?(lease: PreviewLease, request: RuntimePreviewLeaseReleaseRequest): Promise | RuntimePreviewLeaseReleaseResult | void; +} +export interface RuntimePreviewLeaseAcquireRequest { + localUrl: string; + requestedPublicUrl?: string; + requestedSiteUrl?: string; + metadata?: Record; +} +export interface RuntimePreviewLeaseProbeResult { + status: PreviewReachabilityEvidence["status"]; + lease?: PreviewLease; + reachability?: PreviewReachabilityEvidence; + evidence_refs?: Record[]; + metadata?: Record; +} +export interface RuntimePreviewLeaseReleaseRequest { + status: Extract | "failed"; + reason: "runtime-dispose" | "acquire-failed" | "probe-failed" | "startup-failed" | (string & {}); + error?: Record; +} +export interface RuntimePreviewLeaseReleaseResult { + status: Extract | "unknown"; + released_at?: string; + evidence_refs?: Record[]; + metadata?: Record; +} +export interface WorkspaceRecipeMount { + type?: "directory" | "file"; + source: string; + target: string; + mode?: "readonly" | "readwrite"; + captureArtifacts?: boolean; + /** Selects when a Playground mount becomes available relative to installation. */ + phase?: "pre-install" | "post-install"; + metadata?: Record; +} +export type WorkspaceRecipeExternalServiceEnvironment = "local" | "fixture" | "staging" | "production" | "external"; +export type WorkspaceRecipeExternalServiceWrites = "forbidden" | "record-only" | "allowed-with-approval"; +export type WorkspaceRecipeExternalServiceRedactionPolicy = "metadata-only" | "redact-fields" | "omit"; +export interface WorkspaceRecipeExternalServiceBoundary { + id: string; + label?: string; + environment: WorkspaceRecipeExternalServiceEnvironment; + allowedHosts?: string[]; + blockedHosts?: string[]; + writes: WorkspaceRecipeExternalServiceWrites; + secretEnv?: string[]; + redaction?: { + policy: WorkspaceRecipeExternalServiceRedactionPolicy; + fields?: string[]; + }; + metadata?: Record; +} +/** A short-lived host resource provisioned before the sandbox runtime starts. */ +export interface WorkspaceRecipeRuntimeService { + id: string; + kind: "mysql" | "redis" | "smtp" | "http" | (string & {}); + configuration?: { + provider?: "docker" | "external" | "native"; + externalService?: string; + engine?: "mysql" | "mariadb"; + storage?: "tmpfs" | "disk"; + rootAuthentication?: "generated-password" | "empty-password"; + foreignKeyTargetPolicy?: "unique-only" | "indexed"; + hostEnv?: string; + portEnv?: string; + usernameEnv?: string; + passwordEnv?: string; + image?: string; + responseStatus?: number; + responseBody?: string; + }; + /** Explicit map from a provider output (for example `port`) to one or more runtime env names. */ + outputs: Record; +} +export interface WorkspaceRecipeRuntimeStack { + mounts?: WorkspaceRecipeMount[]; +} +/** A bounded host V8 old-space budget for memory-heavy runtime profiles. */ +export interface WorkspaceRecipeHostNodeHeap { + minimumMiB: number; + maximumMiB: number; +} +export type WorkspaceRecipeRuntimeOverlayKind = string; +export type WorkspaceRecipeRuntimeOverlayLibrary = string; +export type WorkspaceRecipeRuntimeOverlayStrategy = string; +export interface WorkspaceRecipeRuntimeOverlay { + kind: WorkspaceRecipeRuntimeOverlayKind; + library: WorkspaceRecipeRuntimeOverlayLibrary; + source: string; + target?: string; + strategy: WorkspaceRecipeRuntimeOverlayStrategy; + bundle?: Record; + metadata?: Record; +} +export interface WorkspaceRecipeRuntimeBackendPackage { + kind: string; + source: string; + package?: string; + entrypoint?: string; + metadata?: Record; +} +/** A recipe-owned external PHP.wasm extension manifest loaded before PHP starts. */ +export interface WorkspaceRecipePHPWasmExtensionManifest extends RuntimePHPWasmExtensionManifest { +} +export interface WorkspaceRecipeDistributionSourceMount extends WorkspaceRecipeMount { + role?: "wordpress-root" | "dependency" | "fixtures" | (string & {}); + ref?: string; +} +export interface WorkspaceRecipeDistributionWordPress { + root: string; + bootstrap?: "standard" | "custom" | "external" | (string & {}); + config?: string; + bootstrapFile?: string; +} +export interface WorkspaceRecipeDistributionServiceFake { + name: string; + source: string; + load?: "pre-bootstrap" | "mu-plugin" | "manual"; + sideEffectsArtifact?: string; + metadata?: Record; +} +export interface WorkspaceRecipeDistributionRouteAlias { + name?: string; + host?: string; + path?: string; + target: string; + targetType?: "wordpress-rest" | "wordpress-route" | "local-url" | (string & {}); + metadata?: Record; +} +export interface WorkspaceRecipeDistributionStartupProbe { + name: string; + type: "http" | "browser" | "wp-cli" | "php"; + url?: string; + command?: string; + code?: string; + expectStatus?: number; + metadata?: Record; +} +export interface WorkspaceRecipeDistributionSetupArtifact { + name: string; + type: "sql"; + source: string; + metadata?: Record; +} +export interface WorkspaceRecipeDistributionArtifact { + path: string; + kind?: "logs" | "probe-results" | "fake-side-effects" | "runtime" | (string & {}); + metadata?: Record; +} +export interface WorkspaceRecipeDistributionSafety { + network?: "deny" | "declared"; + allowedHosts?: string[]; + secretEnv?: string[]; +} +export interface WorkspaceRecipeDistribution { + name: string; + sourceMounts?: WorkspaceRecipeDistributionSourceMount[]; + wordpress: WorkspaceRecipeDistributionWordPress; + env?: Record; + constants?: Record; + serviceFakes?: WorkspaceRecipeDistributionServiceFake[]; + routeAliases?: WorkspaceRecipeDistributionRouteAlias[]; + setupArtifacts?: WorkspaceRecipeDistributionSetupArtifact[]; + startupProbes?: WorkspaceRecipeDistributionStartupProbe[]; + artifacts?: WorkspaceRecipeDistributionArtifact[]; + safety?: WorkspaceRecipeDistributionSafety; +} +export interface WorkspaceRecipeStagedFile { + source: string; + target: string; + mode?: "readonly" | "readwrite"; + metadata?: Record; +} +export interface WorkspaceRecipeSourcePackageArtifact { + name?: string; + path?: string; + required?: boolean; +} +export interface WorkspaceRecipeSourcePackage { + name: string; + source: string; + target: string; + allow?: string[]; + deny?: string[]; + artifact?: boolean | WorkspaceRecipeSourcePackageArtifact; + metadata?: Record; +} +export interface WorkspaceRecipeStep { + command: string; + args?: string[]; + timeoutMs?: number; + continuation?: WorkspaceRecipeStepContinuation; + pluginInput?: WorkspaceRecipeStepPluginInput; + diagnostics?: RuntimeCommandDiagnosticsCaptureSpec; + metadata?: Record; + allowFailure?: boolean; + advisory?: boolean; +} +export interface WorkspaceRecipeStepPluginInput { + artifact: string; + packages: WorkspaceRecipePluginPackageProjection; +} +export interface WorkspaceRecipePluginPackageProjection { + resolver?: "immutable-archive" | "wordpress.org-latest-stable"; + items: string; + map: { + source?: string; + sha256?: string; + slug: string; + pluginFile?: string; + activate?: string; + loadAs?: string; + }; +} +export interface WorkspaceRecipeStepContinuation { + maxIterations: number; + while: WorkspaceRecipeStepContinuationPredicate; + inputMappings: WorkspaceRecipeStepContinuationInputMapping[]; +} +export interface WorkspaceRecipeStepContinuationPredicate { + pointer: string; + equals: unknown; +} +export interface WorkspaceRecipeStepContinuationInputMapping { + from: string; + to: { + arg: string; + pointer: string; + }; +} +export interface RuntimeCommandDiagnosticsCaptureSpec { + capture?: RuntimeCommandDiagnosticsCaptureKind[]; + maxItems?: number; + maxBytes?: number; +} +export type RuntimeCommandDiagnosticsCaptureKind = "wpdb-queries"; +export type WorkspaceRecipeFuzzCasePhase = "setup" | "action" | "assert" | "teardown"; +export interface WorkspaceRecipeFuzzCaseInputDigest { + algorithm: "sha256" | (string & {}); + value: string; +} +export interface WorkspaceRecipeFuzzCaseReplayMetadata { + seed?: string | number; + inputRef?: string; + notes?: string; + metadata?: Record; +} +export interface WorkspaceRecipeFuzzCase { + case_id: string; + input?: Record; + inputHash?: WorkspaceRecipeFuzzCaseInputDigest; + metadata?: Record; + phases: Partial>; + artifacts?: WorkspaceRecipeDeclaredArtifact[]; + replay?: WorkspaceRecipeFuzzCaseReplayMetadata; +} +export interface WorkspaceRecipeFuzzRun { + schema: "wp-codebox/fuzz-run/v1"; + cases: WorkspaceRecipeFuzzCase[]; + metadata?: Record; +} +export interface WorkspaceRecipeAdversarialCaseTemplate { + id: string; + phases: Partial>; +} +export interface WorkspaceRecipeAdversarialCampaign { + schema: "wp-codebox/adversarial-recipe-campaign/v1"; + id: string; + seed: string; + corpus: Array<{ + id: string; + actions: Array<{ + type: string; + input?: unknown; + clock?: import("./adversarial-campaign.js").AdversarialClockScheduleEntry[]; + metadata?: Record; + }>; + input?: unknown; + signals?: string[]; + metadata?: Record; + }>; + caseTemplates: WorkspaceRecipeAdversarialCaseTemplate[]; + mutators: Array<"scalar" | "structured" | "binary" | "sequence">; + oracles: Array<{ + id: "runtime-status"; + severity: "low" | "medium" | "high" | "critical"; + description?: string; + metadata?: Record; + }>; + matrix?: Array<{ + name: string; + values: string[]; + }>; + concurrency?: number; + budgets?: Partial<{ + maxCases: number; + maxActionsPerCase: number; + maxInputBytes: number; + maxCaseTimeMs: number; + maxWallTimeMs: number; + maxArtifactBytes: number; + }>; + faultSchedule?: import("./transport-faults.js").TransportFaultModel; + resetPolicy?: import("./fuzz-suite-contracts.js").FuzzSuiteResetPolicy; + requiredCapabilities?: string[]; + optionalCapabilities?: string[]; + novelty?: { + retainSignals?: boolean; + }; + shrinking?: { + enabled?: boolean; + }; + replay?: { + selection?: "findings" | "all"; + }; + metadata?: Record; +} +export interface WorkspaceRecipeFixtureDatabaseReset { + strategy?: "none" | "truncate-tables"; + tables?: string[]; +} +export interface WorkspaceRecipeFixtureDatabase { + name: string; + version: string; + source: string; + format?: "sql"; + reset?: WorkspaceRecipeFixtureDatabaseReset; + metadata?: Record; +} +export interface WorkspaceRecipeFixtureUser { + name: string; + userId?: number; + username?: string; + email?: string; + role?: string; + displayName?: string; + password?: string; + metadata?: Record; +} +export interface WorkspaceRecipeSessionArtifact { + kind: "browser-storage-state" | "cookie-jar" | "token" | (string & {}); + path?: string; + redactionRequired: true; + metadata?: Record; +} +export interface WorkspaceRecipeUserSession { + name: string; + user: string; + artifacts?: WorkspaceRecipeSessionArtifact[]; + metadata?: Record; +} +export interface WorkspaceRecipeBrowserActor { + name: string; + userSession: string; + metadata?: Record; +} +export interface WorkspaceRecipeProbe { + name: string; + step: WorkspaceRecipeStep; + expectJson?: boolean; + allowFailure?: boolean; + metadata?: Record; +} +export interface WorkspaceRecipeDeclaredArtifact { + name: string; + path: string; + required?: boolean; + parseJson?: boolean; + metadata?: Record; +} +export interface WorkspaceRecipeTypedArtifact { + name: string; + type: string; + path: string; + required?: boolean; + contentType?: string; + parseJson?: boolean; + payloadSchema?: string | Record; + metadata?: Record; +} +export interface WorkspaceRecipePluginRuntimePhp { + memoryLimit?: string; + maxExecutionTime?: number; + iniEntries?: Record; + bootstrapIniEntries?: Record; +} +export interface WorkspaceRecipePluginRuntimeHealthProbe { + name: string; + type: "plugin-active" | "php" | "wp-cli"; + pluginFile?: string; + code?: string; + command?: string; +} +export interface WorkspaceRecipePluginRuntime { + label?: string; + php?: WorkspaceRecipePluginRuntimePhp; + wpConfigDefines?: Record; + setup?: WorkspaceRecipeStep[]; + healthProbes?: WorkspaceRecipePluginRuntimeHealthProbe[]; +} +export interface WorkspaceRecipeAgentBundle { + source?: string; + bundle?: Record; + slug?: string; + on_conflict?: "error" | "skip" | "upgrade"; + owner_id?: number; + token_env?: string; +} +export interface WorkspaceRecipeExtraPlugin { + source?: string; + sourcePath?: string; + sourceRoot?: string; + sourceSubpath?: string; + sourceSubdir?: string; + originalSource?: string; + slug?: string; + mountSlug?: string; + pluginFile?: string; + activate?: boolean; + sha256?: string; + loadAs?: "plugin" | "mu-plugin"; + composer?: "install"; + metadata?: Record; +} +export interface ProjectedPluginPackageDescriptor { + source?: string; + sha256?: string; + slug: string; + pluginFile?: string; + activate?: boolean; + loadAs?: "plugin" | "mu-plugin"; + metadata?: Record; +} +export interface WorkspaceRecipeComponentManifestEntry { + slug?: string; + source?: string; + mountedPath?: string; + entrypoint?: string; + pluginFile?: string; + loadAs?: "plugin" | "mu-plugin"; + activate?: boolean; + contractIndex?: number; + requestedPath?: string; + provenance?: Record; +} +export interface WorkspaceRecipeComponentManifest { + schema: "wp-codebox/component-manifest/v1"; + components?: WorkspaceRecipeComponentManifestEntry[]; + providers?: WorkspaceRecipeComponentManifestEntry[]; +} +export interface WorkspaceRecipeDependencyOverlay { + kind: "composer-package"; + package: string; + source: string; + reference?: string; + consumer: string; + metadata?: Record; +} +export type WorkspaceRecipeSiteSeedType = "fixture" | "parent_site"; +export type WorkspaceRecipeSiteSeedFormat = "json" | (string & {}); +export type WorkspaceRecipeSiteSeedDeterministicIdStrategy = "platform-identifiers" | "numeric"; +export type WorkspaceRecipeUnsupportedDeterministicIdPolicy = "block" | "warn"; +export interface WorkspaceRecipeSiteSeedDeterministicIds { + strategy: WorkspaceRecipeSiteSeedDeterministicIdStrategy; + onUnsupported: WorkspaceRecipeUnsupportedDeterministicIdPolicy; +} +export interface WorkspaceRecipeSiteSeedBootstrapSite { + domain: string; + path?: string; + title?: string; +} +export interface WorkspaceRecipeSiteSeedBootstrapDomain { + domain: string; + path?: string; + primary?: boolean; +} +export interface WorkspaceRecipeSiteSeedBootstrap { + multisite?: { + enabled: boolean; + install?: "subdomain" | "subdirectory"; + sites?: WorkspaceRecipeSiteSeedBootstrapSite[]; + }; + domains?: WorkspaceRecipeSiteSeedBootstrapDomain[]; +} +export interface WorkspaceRecipeSiteSeedScopeSelector { + ids?: number[]; + slugs?: string[]; + names?: string[]; + postTypes?: string[]; + taxonomies?: string[]; + roles?: string[]; + statuses?: string[]; + includeFiles?: boolean; + anonymize?: boolean; + maxRecords?: number; +} +export interface WorkspaceRecipeSiteSeed { + type: WorkspaceRecipeSiteSeedType; + name: string; + source?: string; + format?: WorkspaceRecipeSiteSeedFormat; + deterministicIds?: WorkspaceRecipeSiteSeedDeterministicIds; + bootstrap?: WorkspaceRecipeSiteSeedBootstrap; + scopes: { + posts?: WorkspaceRecipeSiteSeedScopeSelector; + terms?: WorkspaceRecipeSiteSeedScopeSelector; + options?: WorkspaceRecipeSiteSeedScopeSelector; + users?: WorkspaceRecipeSiteSeedScopeSelector; + media?: WorkspaceRecipeSiteSeedScopeSelector; + activePlugins?: boolean; + activeTheme?: boolean; + }; +} +export type WorkspaceRecipeSeedType = "plugin_scaffold" | "theme_scaffold" | "directory"; +export interface WorkspaceRecipeWorkspaceSeed { + type: WorkspaceRecipeSeedType; + slug?: string; + name?: string; + source?: string; + excludePaths?: string[]; +} +export interface WorkspaceRecipeWorkspace { + target?: string; + mode?: "readonly" | "readwrite"; + sourceMode?: SandboxWorkspaceMode; + seed: WorkspaceRecipeWorkspaceSeed; +} +export interface WorkspaceRecipeWorkspacePreloadRepository { + name: string; + url: string; + ref?: string; +} +export interface WorkspaceRecipeWorkspacePreload { + type: "agent-runtime/workspace-preload"; + slug?: string; + source?: string; + payload: { + schema: "agent-runtime/workspace-preload/v1"; + repositories: WorkspaceRecipeWorkspacePreloadRepository[]; + meta?: Record; + }; + provenance?: Record; +} +export interface SandboxWorkspaceMountRef { + target: string; + mode: "readonly" | "readwrite"; + sourceMode: SandboxWorkspaceMode; + workspaceRef?: string; + mountRole?: string; + component?: string; + repo?: string; + gitRef?: string; + defaultBranch?: string; + wpContentPath?: string; +} +export interface SandboxWorkspaceContract { + schema: "wp-codebox/sandbox-workspace/v1"; + root: typeof SANDBOX_WORKSPACE_ROOT | (string & {}); + defaultMode: SandboxWorkspaceMode; + mounts: SandboxWorkspaceMountRef[]; + toolPolicy?: unknown; +} +export interface WorkspaceRecipe { + schema: "wp-codebox/workspace-recipe/v1"; + distribution?: WorkspaceRecipeDistribution; + runtime?: { + backend?: RuntimeBackendKind; + name?: string; + wp?: string; + phpVersion?: string; + workers?: RuntimeWorkerCount; + wordpressInstallMode?: RuntimeWordPressInstallMode; + databaseSetup?: RuntimeWordPressDatabaseSetup; + blueprint?: unknown; + preview?: RuntimePreviewSpec; + assets?: RuntimeAssetSpec; + extensions?: WorkspaceRecipePHPWasmExtensionManifest[]; + bundledExtensions?: RuntimePHPWasmBundledExtension[]; + backendPackage?: WorkspaceRecipeRuntimeBackendPackage; + stack?: WorkspaceRecipeRuntimeStack; + overlays?: WorkspaceRecipeRuntimeOverlay[]; + hostNodeHeap?: WorkspaceRecipeHostNodeHeap; + }; + inputs?: { + workspaces?: WorkspaceRecipeWorkspace[]; + workspace_preloads?: WorkspaceRecipeWorkspacePreload[]; + mounts?: WorkspaceRecipeMount[]; + extra_plugins?: WorkspaceRecipeExtraPlugin[]; + component_manifest?: WorkspaceRecipeComponentManifest; + dependency_overlays?: WorkspaceRecipeDependencyOverlay[]; + runtimeEnv?: Record; + secretEnv?: string[]; + services?: WorkspaceRecipeRuntimeService[]; + externalServices?: WorkspaceRecipeExternalServiceBoundary[]; + pluginRuntime?: WorkspaceRecipePluginRuntime; + fixtureDatabases?: WorkspaceRecipeFixtureDatabase[]; + fixtureUsers?: WorkspaceRecipeFixtureUser[]; + userSessions?: WorkspaceRecipeUserSession[]; + browserActors?: WorkspaceRecipeBrowserActor[]; + siteSeeds?: WorkspaceRecipeSiteSeed[]; + stagedFiles?: WorkspaceRecipeStagedFile[]; + sourcePackages?: WorkspaceRecipeSourcePackage[]; + agent_bundles?: WorkspaceRecipeAgentBundle[]; + inherit?: WorkspaceRecipeInheritanceRequest; + inheritance?: WorkspaceRecipeInheritanceResolution; + }; + workflow: { + before?: WorkspaceRecipeStep[]; + steps: WorkspaceRecipeStep[]; + after?: WorkspaceRecipeStep[]; + }; + fuzzRun?: WorkspaceRecipeFuzzRun; + adversarialCampaigns?: WorkspaceRecipeAdversarialCampaign[]; + artifacts?: { + directory?: string; + verify?: boolean | WorkspaceRecipeArtifactVerifier; + workspacePolicy?: boolean | WorkspaceRecipeWorkspacePolicyArtifact; + paths?: WorkspaceRecipeDeclaredArtifact[]; + typed?: WorkspaceRecipeTypedArtifact[]; + }; + probes?: WorkspaceRecipeProbe[]; + metadata?: Record; +} +export interface WorkspaceRecipeArtifactVerifier { + enabled?: boolean; + strict?: boolean; +} +export interface WorkspaceRecipeWorkspacePolicyArtifact { + enabled?: boolean; + strict?: boolean; + writableRoots?: string[]; + hiddenPaths?: string[]; + gitBacked?: boolean; +} +export interface WorkspaceRecipeInheritanceRequest { + connectors?: string[]; + settings?: string[]; +} +export interface WorkspaceRecipeInheritanceConnector { + name: string; + status: "resolved" | "unresolved" | "skipped" | (string & {}); + provider?: string; + model?: string; + providerPluginPaths?: string[]; + secretEnv?: string[]; + credentials?: ConnectorCredentialEnvelope; +} +export type ConnectorCredentialStatus = "available" | "missing" | "denied"; +export interface ConnectorCredentialSecret { + name: string; + status: ConnectorCredentialStatus; + scope?: string; + source?: "parent-env" | "connector" | (string & {}); + reason?: string; +} +export interface ConnectorCredentialEnvelope { + schema: "wp-codebox/connector-credentials/v1"; + connector: string; + scope: "connector"; + status: ConnectorCredentialStatus; + secrets: ConnectorCredentialSecret[]; + reason?: string; +} +export interface WorkspaceRecipeInheritanceSetting { + name: string; + status: "resolved" | "unresolved" | "skipped" | (string & {}); + scope?: string; +} +export interface WorkspaceRecipeInheritanceResolution { + connectors?: WorkspaceRecipeInheritanceConnector[]; + settings?: WorkspaceRecipeInheritanceSetting[]; +} +export interface RuntimeInfo { + id: string; + backend: RuntimeBackendKind; + environment: EnvironmentSpec; + createdAt: string; + status: "created" | "destroyed"; + previewUrl?: string; +} +export interface MountSpec { + type: "directory" | "file" | (string & {}); + source: string; + target: string; + mode: "readonly" | "readwrite"; + captureArtifacts?: boolean; + /** Selects when a Playground mount becomes available relative to installation. */ + phase?: "pre-install" | "post-install"; + metadata?: Record; +} +export interface ExecutionSpec { + command: string; + args?: string[]; + environment?: Record; + processIdentity?: string; + artifactNamespace?: string; + diagnostics?: RuntimeCommandDiagnosticsCaptureSpec; + cwd?: string; + timeoutMs?: number; + signal?: AbortSignal; +} +export type RuntimeEpisodeActionKind = "command" | "filesystem" | "http" | "browser"; +export interface RuntimeEpisodeActionSpec extends ExecutionSpec { + kind?: RuntimeEpisodeActionKind; + method?: string; + url?: string; + path?: string; + operation?: string; + selector?: string; + description?: string; + metadata?: Record; +} +export interface RuntimeEpisodeContentDigest { + algorithm: "sha256"; + value: string; +} +export interface RuntimeEpisodeTraceRef { + kind: "action" | "execution" | "observation" | "snapshot" | "artifact-bundle" | (string & {}); + id: string; + digest?: RuntimeEpisodeContentDigest; + artifactId?: string; + path?: string; + sourcePath?: string; + contentType?: string; +} +export interface RuntimeEpisodeActionRecord { + schema: typeof RUNTIME_EPISODE_ACTION_SCHEMA; + id: string; + kind: RuntimeEpisodeActionKind; + command: string; + args: string[]; + cwd?: string; + timeoutMs?: number; + method?: string; + url?: string; + path?: string; + operation?: string; + selector?: string; + description?: string; + metadata?: Record; + digest: RuntimeEpisodeContentDigest; +} +export interface ExecutionResult { + id: string; + command: string; + args: string[]; + exitCode: number; + stdout: string; + stderr: string; + result?: RuntimeCommandResultEnvelope; + diagnostics?: unknown; + artifactRefs?: RuntimeEpisodeTraceRef[]; + startedAt: string; + finishedAt: string; +} +export declare const RUNTIME_COMMAND_RESULT_SCHEMA: "wp-codebox/runtime-command-result/v1"; +export type RuntimeCommandResultStatus = "ok" | "error" | (string & {}); +export interface RuntimeCommandResultError { + code: string; + message: string; + data?: unknown; +} +export interface RuntimeCommandResultEnvelope { + schema: typeof RUNTIME_COMMAND_RESULT_SCHEMA; + status: RuntimeCommandResultStatus; + stdout?: string; + stderr?: string; + json?: unknown; + diagnostics?: unknown; + artifactRefs?: RuntimeEpisodeTraceRef[]; + error?: RuntimeCommandResultError; +} +export interface ObservationSpec { + type: "runtime-info" | "mounts" | "files" | "command-result" | "wordpress-state" | "http-response" | "browser-result" | "runtime-events" | "runtime-logs" | (string & {}); + path?: string; + commandId?: string; + url?: string; + method?: string; + headers?: Record; + body?: string; + includeBody?: boolean; + sections?: string[]; + redaction?: "safe" | "none" | (string & {}); + includeContent?: boolean; + optionNames?: string[]; + userFields?: string[]; +} +export interface ObservationResult { + schema?: typeof RUNTIME_EPISODE_OBSERVATION_SCHEMA; + id?: string; + type: string; + data: unknown; + observedAt: string; + artifactRefs?: RuntimeEpisodeTraceRef[]; + artifactManifestFiles?: ArtifactManifestFile[]; + digest?: RuntimeEpisodeContentDigest; +} +export interface LifecycleEvent { + id: string; + type: "runtime.created" | "runtime.mounted" | "runtime.command.started" | "runtime.command.finished" | "runtime.observed" | "runtime.snapshot.created" | "runtime.artifacts.collected" | "runtime.browser-startup-progress" | "runtime.destroyed" | (string & {}); + timestamp: string; + data?: Record; +} +export interface Snapshot { + schema?: typeof RUNTIME_EPISODE_SNAPSHOT_SCHEMA; + id: string; + createdAt: string; + semantics?: "metadata-only" | "partial-replay" | "replayable-runtime-state" | "runtime-state-artifact" | (string & {}); + metadata: Record; + artifactRefs?: RuntimeEpisodeTraceRef[]; + digest?: RuntimeEpisodeContentDigest; +} +export type RuntimeCheckpointOperation = "create" | "restore" | "list"; +export interface RuntimeCheckpointSpec { + name: string; + metadata?: Record; + snapshotOptions?: unknown; +} +export interface RuntimeCheckpointMetadata { + name: string; + snapshotId: string; + createdAt: string; + restoredAt?: string; + metadata?: Record; + summary?: Record; +} +export interface RuntimeCheckpointResult { + schema: "wp-codebox/runtime-checkpoint-result/v1"; + status: "created" | "restored" | "listed"; + operation: RuntimeCheckpointOperation; + checkpoint?: RuntimeCheckpointMetadata; + checkpoints?: RuntimeCheckpointMetadata[]; +} +export interface RuntimeCheckpointFailureDiagnostic { + schema: "wp-codebox/runtime-checkpoint-failure/v1"; + status: "unsupported" | "not-found" | "invalid-request" | "failed"; + operation: RuntimeCheckpointOperation; + backend?: RuntimeBackendKind; + name?: string; + code: string; + message: string; + supported: false; +} +export declare class RuntimeCheckpointError extends Error { + readonly diagnostic: RuntimeCheckpointFailureDiagnostic; + constructor(diagnostic: RuntimeCheckpointFailureDiagnostic); + toJSON(): RuntimeCheckpointFailureDiagnostic & { + name: string; + }; +} +export declare function runtimeCheckpointUnsupportedDiagnostic(operation: RuntimeCheckpointOperation, runtime?: RuntimeInfo, name?: string): RuntimeCheckpointFailureDiagnostic; +export interface RuntimeRestoreSpec { + runtime?: RuntimeCreateSpec; + mounts?: MountSpec[]; +} +export interface ArtifactProvenance { + task?: Record; + workspace?: SandboxWorkspaceContract; + packages?: ArtifactPackageProvenance; + runtime: RuntimeWordPressProvenance; + agent?: Record; + mounts: Array<{ + type: MountSpec["type"]; + source: string; + target: string; + mode: MountSpec["mode"]; + metadata?: Record; + }>; +} +export interface ArtifactPackageProvenance { + schema: "wp-codebox/package-provenance/v1"; + wpCodebox?: ArtifactPackageIdentity; + cli?: ArtifactPackageIdentity; + runtimeCore?: ArtifactPackageIdentity; + runtimePlayground?: ArtifactPackageIdentity; + playground?: { + cli?: ArtifactPackageIdentity; + wordpressBuilds?: ArtifactPackageIdentity; + }; + environment?: { + wordpressVersion?: string; + phpVersion?: string; + nodeVersion?: string; + }; +} +export interface BackendNeutralArtifactProvenance extends Omit { + runtime: BackendNeutralRuntimeProvenance; +} +export interface ArtifactPackageIdentity { + name: string; + version?: string; + source?: { + ref?: string; + sha?: string; + digest?: ArtifactFileDigest; + }; +} +export interface ArtifactEvidenceRef { + path: string; + kind: string; + contentType?: string; + sha256?: ArtifactFileDigest; +} +export interface ArtifactPreviewSessionEvidence { + schema: "wp-codebox/preview-session-evidence/v1"; + artifactId: string; + createdAt: string; + session: { + runtimeId: string; + backend: RuntimeBackendKind; + createdAt: string; + status: RuntimeInfo["status"]; + environment: { + kind: string; + name?: string; + version?: string; + phpVersion?: string; + }; + }; + preview?: { + status: ArtifactPreview["status"]; + lifecycle: ArtifactPreview["lifecycle"]; + source: ArtifactPreview["source"]; + createdAt: string; + expiresAt?: string; + holdSeconds?: number; + hasPublicUrl: boolean; + hasSiteUrl: boolean; + lease?: ArtifactPreviewLeaseSummary; + hasReviewerAuthBootstrap?: boolean; + reviewerAccess: ArtifactPreviewReviewerAccess; + blockers?: ArtifactPreviewBlocker[]; + }; + refs: { + artifactBundle: { + kind: "artifact-bundle"; + id: string; + digest: RuntimeEpisodeContentDigest; + }; + manifest: ArtifactEvidenceRef; + review: ArtifactEvidenceRef; + runtimeEvents: ArtifactEvidenceRef; + runtimeLog: ArtifactEvidenceRef; + runtimeReferenceManifest: ArtifactEvidenceRef; + runtimeReplayReferenceIndex: ArtifactEvidenceRef; + browserSummary?: ArtifactEvidenceRef; + durablePreview?: ArtifactEvidenceRef; + }; + components?: ArtifactPackageProvenance; +} +export interface ArtifactPreview { + url: string; + localUrl?: string; + publicUrl?: string; + siteUrl?: string; + lease?: PreviewLease; + status: "available" | "expired-on-completion"; + lifecycle: "held-after-run" | "destroyed-on-completion"; + source: "live-playground" | "public-url-override"; + createdAt: string; + expiresAt?: string; + holdSeconds?: number; + blockers?: ArtifactPreviewBlocker[]; + reviewerAuthBootstrap?: ArtifactReviewerAuthBootstrap; + reviewerAccess?: ArtifactPreviewReviewerAccess; +} +export interface ArtifactPreviewReviewerAccess { + schema: "wp-codebox/preview-reviewer-access/v1"; + status: "ready" | "blocked" | "unavailable"; + outcome: "public" | "local" | "bootstrap" | "blocked" | "auth-required"; + mode: "direct-url" | "auth-bootstrap" | "none"; + reviewerSafe: boolean; + openUrl?: string; + targetUrl?: string; + expiresAt?: string; + lease?: ArtifactPreviewLeaseSummary; + bootstrap?: ArtifactReviewerAuthBootstrap; + blockers?: ArtifactPreviewBlocker[]; + reason?: string; +} +export interface ArtifactPreviewLeaseSummary { + schema: "wp-codebox/preview-lease-summary/v1"; + status: PreviewLeaseLifecycleStatus; + publicUrl?: string; + localUrl?: string; + siteUrl?: string; + expiresAt?: string; + owner?: string; + provider?: string; + alignmentStatus?: string; + reachabilityStatus?: string; + reviewerSafe: boolean; +} +export interface ArtifactReviewerAuthBootstrap { + schema: "wp-codebox/reviewer-auth-bootstrap/v1"; + kind: "local-wordpress-admin-fixture"; + reviewerSafe: true; + bootstrapUrl: string; + redirectUrl: string; + expiresAt: string; + evidence: { + command: string; + auth: "wordpress-admin"; + userId: number; + }; +} +export interface ArtifactPreviewBlocker { + schema: "wp-codebox/preview-blocker/v1"; + kind: "unsupported-preview"; + code: "external-wordpress-admin-auth-unavailable" | (string & {}); + message: string; + retryable: false; + reviewerSafe: false; + evidence: { + command: string; + auth: "wordpress-admin" | (string & {}); + }; +} +export interface ArtifactPreviewUrlRef { + kind: "preview-url"; + availability: "reviewer-safe" | "local-only" | "unavailable"; + reviewerSafe: boolean; + url?: string; + reason?: string; +} +export interface ArtifactDurablePreviewRef { + kind: "artifact-preview"; + reviewerSafe: true; + durable: true; + entrypoint: string; + manifest: ArtifactEvidenceRef; + source: { + kind: "browser-runtime-artifact-bundle"; + probe: number; + schema?: string; + root?: string; + entrypoint?: string; + }; + files: ArtifactEvidenceRef[]; +} +export interface ArtifactPreviewEvidence { + schema: "wp-codebox/preview-evidence/v1"; + createdAt: string; + session: { + kind: "browser-playground-session"; + id: string; + runtimeId: string; + backend: RuntimeBackendKind; + environment: { + kind: EnvironmentSpec["kind"]; + name: string; + version: string; + }; + }; + run: RuntimeEpisodeTraceRef; + preview: { + status: ArtifactPreview["status"] | "unavailable"; + lifecycle: ArtifactPreview["lifecycle"] | "not-started"; + source?: ArtifactPreview["source"]; + createdAt?: string; + expiresAt?: string; + holdSeconds?: number; + lease?: ArtifactPreviewLeaseSummary; + url: ArtifactPreviewUrlRef; + publicUrl?: ArtifactPreviewUrlRef; + localUrl?: ArtifactPreviewUrlRef; + siteUrl?: ArtifactPreviewUrlRef; + durablePreview?: ArtifactDurablePreviewRef; + reviewerAccess: ArtifactPreviewReviewerAccess; + }; + readiness: { + ready: boolean; + status: BrowserStartupProgressEvent["status"] | "not-started"; + phase?: BrowserStartupProgressEvent["phase"]; + events: Array<{ + id: string; + phase: BrowserStartupProgressEvent["phase"]; + status: BrowserStartupProgressEvent["status"]; + label?: string; + elapsed_ms?: number; + timestamp: string; + }>; + }; + components: { + packages?: ArtifactPackageProvenance; + runtime: { + backend: RuntimeBackendKind; + wordpressVersion?: string; + }; + }; +} +export interface ArtifactBundle { + id: string; + directory: string; + manifestPath: string; + metadataPath: string; + blueprintAfterPath: string; + blueprintAfterViewer?: ArtifactViewerMetadata; + blueprintAfterNotesPath: string; + eventsPath: string; + commandsPath: string; + observationsPath: string; + runtimeLogPath: string; + commandsLogPath: string; + mountsPath: string; + capturedMountsPath: string; + diffsPath: string; + workspacePatchPath: string; + changedFilesPath: string; + patchPath: string; + diagnosticsPath: string; + testResultsPath: string; + reviewPath: string; + runAttestationPath?: string; + runtimeEpisodeTracePath?: string; + runtimeEpisodeEventsPath?: string; + artifactVerificationPath?: string; + workspacePolicyPath?: string; + runtimeReferenceManifestPath?: string; + runtimeReferenceIndexPath?: string; + runtimeReplayReferenceIndexPath?: string; + previewEvidencePath?: string; + previewSessionEvidencePath?: string; + previewSessionEvidenceRef?: ArtifactEvidenceRef; + durablePreviewPath?: string; + durablePreview?: ArtifactDurablePreviewRef; + preview?: ArtifactPreview; + contentDigest: string; + createdAt: string; +} +export interface Runtime { + info(): Promise; + mount(spec: MountSpec): Promise; + materializeStagedInputs?(mounts: MountSpec[]): Promise; + materializeMounts?(mounts: MountSpec[]): Promise; + execute(spec: ExecutionSpec): Promise; + observe(spec: ObservationSpec): Promise; + snapshot(options?: unknown): Promise; + restoreSnapshot?(snapshot: Snapshot): Promise; + createCheckpoint?(spec: RuntimeCheckpointSpec): Promise; + restoreCheckpoint?(name: string): Promise; + listCheckpoints?(): Promise; + collectArtifacts(spec?: ArtifactSpec): Promise; + destroy(): Promise; +} +export interface RuntimeEpisodeSpec { + runtime: RuntimeCreateSpec; + mounts?: MountSpec[]; + resetObservations?: ObservationSpec[]; + stepObservation?: ObservationSpec | false; + artifactSpec?: ArtifactSpec; +} +export interface RuntimeEpisodeResetResult { + id: string; + runtime: RuntimeInfo; + observations: ObservationResult[]; + observationRefs: RuntimeEpisodeTraceRef[]; +} +export interface RuntimeEpisodeStepResult { + id: string; + index: number; + action: RuntimeEpisodeActionRecord; + actionRef: RuntimeEpisodeTraceRef; + execution: ExecutionResult; + executionRef: RuntimeEpisodeTraceRef; + observation?: ObservationResult; + observationRef?: RuntimeEpisodeTraceRef; +} +export interface RuntimeEpisodeTrace { + schema: typeof RUNTIME_EPISODE_TRACE_SCHEMA; + version: 1; + id: string; + createdAt: string; + runtime: RuntimeInfo; + reset: RuntimeEpisodeResetResult; + steps: RuntimeEpisodeStepResult[]; + snapshots: Snapshot[]; + artifacts?: ArtifactBundle; + artifactRef?: RuntimeEpisodeTraceRef; +} +export interface RuntimeEpisodeTraceValidationIssue { + path: string; + message: string; +} +export interface RuntimeEpisodeTraceValidationResult { + valid: boolean; + schema: typeof RUNTIME_EPISODE_TRACE_SCHEMA; + issues: RuntimeEpisodeTraceValidationIssue[]; +} +export interface RuntimeEpisode { + reset(): Promise; + step(action: RuntimeEpisodeActionSpec, observation?: ObservationSpec | false): Promise; + observe(spec: ObservationSpec): Promise; + snapshot(): Promise; + restoreSnapshot(snapshot: Snapshot | string): Promise; + collectArtifacts(spec?: ArtifactSpec): Promise; + trace(): Promise; + close(): Promise; +} +export interface RuntimeBackend { + readonly kind: RuntimeBackendKind; + create(spec: RuntimeCreateSpec): Promise; + restore?(snapshot: Snapshot, spec?: RuntimeRestoreSpec): Promise; +} +export declare function createRuntime(spec: RuntimeCreateSpec, backend: RuntimeBackend): Promise; +export declare function restoreRuntime(snapshot: Snapshot, backend: RuntimeBackend, spec?: RuntimeRestoreSpec): Promise; +//# sourceMappingURL=runtime-contracts.d.ts.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-contracts.d.ts.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-contracts.d.ts.map new file mode 100644 index 000000000..f45244db3 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-contracts.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"runtime-contracts.d.ts","sourceRoot":"","sources":["../src/runtime-contracts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAC5H,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AACnF,OAAO,KAAK,EAAE,+BAA+B,EAAE,8BAA8B,EAAE,+BAA+B,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,qCAAqC,EAAE,+BAA+B,EAAE,mCAAmC,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAA;AAC9U,OAAO,KAAK,EACV,6BAA6B,EAC7B,kCAAkC,EAClC,+BAA+B,EAC/B,4BAA4B,EAC7B,MAAM,gCAAgC,CAAA;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,2BAA2B,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAA;AAE7H,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AAEvE,MAAM,MAAM,oBAAoB,GAAG,aAAa,GAAG,aAAa,CAAA;AAEhE,MAAM,WAAW,eAAgB,SAAQ,+BAA+B;CAAG;AAE3E,MAAM,MAAM,2BAA2B,GAAG,mCAAmC,CAAA;AAC7E,MAAM,MAAM,6BAA6B,GAAG,qCAAqC,CAAA;AACjF,YAAY,EAAE,kBAAkB,EAAE,CAAA;AAElC,MAAM,WAAW,gBAAiB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AC,QAAQ,CAAC,CAAA;IAC/D,gBAAgB,CAAC,IAAI,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;IAC9D,KAAK,IAAI,OAAO,CAAC,mBAAmB,CAAC,CAAA;IACrC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACvB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAA;IACjC,MAAM,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IACjD,OAAO,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CAC1E;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAQtG;AAED,wBAAsB,cAAc,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,cAAc,EAAE,IAAI,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC,CAM7H"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-contracts.js b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-contracts.js new file mode 100644 index 000000000..d50d4c53d --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-contracts.js @@ -0,0 +1,40 @@ +import { assertRuntimePolicy } from "./runtime-policy.js"; +export const RUNTIME_COMMAND_RESULT_SCHEMA = "wp-codebox/runtime-command-result/v1"; +export class RuntimeCheckpointError extends Error { + diagnostic; + constructor(diagnostic) { + super(diagnostic.message); + this.name = "RuntimeCheckpointError"; + this.diagnostic = diagnostic; + } + toJSON() { + return { ...this.diagnostic, name: this.name }; + } +} +export function runtimeCheckpointUnsupportedDiagnostic(operation, runtime, name) { + const backend = runtime?.backend; + return { + schema: "wp-codebox/runtime-checkpoint-failure/v1", + status: "unsupported", + operation, + ...(backend ? { backend } : {}), + ...(name ? { name } : {}), + code: "runtime-checkpoints-unsupported", + message: backend ? `Runtime backend does not support checkpoints: ${backend}` : "Runtime backend does not support checkpoints.", + supported: false, + }; +} +export async function createRuntime(spec, backend) { + assertRuntimePolicy(spec.policy); + if (backend.kind !== spec.backend) { + throw new Error(`Backend ${backend.kind} cannot create runtime ${spec.backend}`); + } + return backend.create(spec); +} +export async function restoreRuntime(snapshot, backend, spec) { + if (!backend.restore) { + throw new Error(`Backend ${backend.kind} does not support runtime snapshot restore`); + } + return backend.restore(snapshot, spec); +} +//# sourceMappingURL=runtime-contracts.js.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-contracts.js.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-contracts.js.map new file mode 100644 index 000000000..b7fe0b67c --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-contracts.js.map @@ -0,0 +1 @@ +{"version":3,"file":"runtime-contracts.js","sourceRoot":"","sources":["../src/runtime-contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAi5BzD,MAAM,CAAC,MAAM,6BAA6B,GAAG,sCAA+C,CAAA;AAyH5F,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IACtC,UAAU,CAAoC;IAEvD,YAAY,UAA8C;QACxD,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;QACzB,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAA;QACpC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;IAED,MAAM;QACJ,OAAO,EAAE,GAAG,IAAI,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAA;IAChD,CAAC;CACF;AAED,MAAM,UAAU,sCAAsC,CAAC,SAAqC,EAAE,OAAqB,EAAE,IAAa;IAChI,MAAM,OAAO,GAAG,OAAO,EAAE,OAAO,CAAA;IAChC,OAAO;QACL,MAAM,EAAE,0CAA0C;QAClD,MAAM,EAAE,aAAa;QACrB,SAAS;QACT,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/B,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzB,IAAI,EAAE,iCAAiC;QACvC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,iDAAiD,OAAO,EAAE,CAAC,CAAC,CAAC,+CAA+C;QAC/H,SAAS,EAAE,KAAK;KACjB,CAAA;AACH,CAAC;AA4XD,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,IAAuB,EAAE,OAAuB;IAClF,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAEhC,IAAI,OAAO,CAAC,IAAI,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CAAC,WAAW,OAAO,CAAC,IAAI,0BAA0B,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;IAClF,CAAC;IAED,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;AAC7B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,QAAkB,EAAE,OAAuB,EAAE,IAAyB;IACzG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,WAAW,OAAO,CAAC,IAAI,4CAA4C,CAAC,CAAA;IACtF,CAAC;IAED,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;AACxC,CAAC"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-episode-contracts.d.ts b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-episode-contracts.d.ts new file mode 100644 index 000000000..dc102ad7d --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-episode-contracts.d.ts @@ -0,0 +1,143 @@ +import type { ObservationResult, RuntimeEpisodeActionRecord, RuntimeEpisodeActionSpec, RuntimeEpisodeContentDigest, RuntimeEpisodeTraceValidationResult, Snapshot } from "./runtime-contracts.js"; +export declare const RUNTIME_EPISODE_TRACE_SCHEMA: "wp-codebox/runtime-episode-trace/v1"; +export declare const RUNTIME_EPISODE_ACTION_SCHEMA: "wp-codebox/runtime-episode-action/v1"; +export declare const RUNTIME_EPISODE_OBSERVATION_SCHEMA: "wp-codebox/runtime-episode-observation/v1"; +export declare const RUNTIME_EPISODE_SNAPSHOT_SCHEMA: "wp-codebox/runtime-episode-snapshot/v1"; +export declare const RUNTIME_EPISODE_TRACE_JSON_SCHEMA: { + readonly $id: "wp-codebox/runtime-episode-trace/v1"; + readonly type: "object"; + readonly required: readonly ["schema", "version", "id", "createdAt", "runtime", "reset", "steps", "snapshots"]; + readonly properties: { + readonly schema: { + readonly const: "wp-codebox/runtime-episode-trace/v1"; + }; + readonly version: { + readonly const: 1; + }; + readonly id: { + readonly type: "string"; + readonly minLength: 1; + }; + readonly createdAt: { + readonly type: "string"; + readonly minLength: 1; + }; + readonly runtime: { + readonly type: "object"; + readonly required: readonly ["id", "backend", "environment", "createdAt", "status"]; + }; + readonly reset: { + readonly type: "object"; + readonly required: readonly ["id", "runtime", "observations", "observationRefs"]; + }; + readonly steps: { + readonly type: "array"; + readonly items: { + readonly type: "object"; + readonly required: readonly ["id", "index", "action", "actionRef", "execution", "executionRef"]; + readonly properties: { + readonly action: { + readonly type: "object"; + readonly required: readonly ["schema", "id", "kind", "command", "args", "digest"]; + readonly properties: { + readonly schema: { + readonly const: "wp-codebox/runtime-episode-action/v1"; + }; + readonly id: { + readonly type: "string"; + readonly minLength: 1; + }; + readonly kind: { + readonly enum: readonly ["command", "filesystem", "http", "browser"]; + }; + readonly command: { + readonly type: "string"; + readonly minLength: 1; + }; + readonly args: { + readonly type: "array"; + readonly items: { + readonly type: "string"; + }; + }; + readonly cwd: { + readonly type: "string"; + }; + readonly timeoutMs: { + readonly type: "number"; + readonly minimum: 0; + }; + readonly method: { + readonly type: "string"; + readonly minLength: 1; + }; + readonly url: { + readonly type: "string"; + readonly minLength: 1; + }; + readonly path: { + readonly type: "string"; + readonly minLength: 1; + }; + readonly operation: { + readonly type: "string"; + readonly minLength: 1; + }; + readonly selector: { + readonly type: "string"; + readonly minLength: 1; + }; + readonly description: { + readonly type: "string"; + readonly minLength: 1; + }; + readonly metadata: { + readonly type: "object"; + }; + readonly digest: { + readonly type: "object"; + readonly required: readonly ["algorithm", "value"]; + readonly properties: { + readonly algorithm: { + readonly const: "sha256"; + }; + readonly value: { + readonly type: "string"; + readonly pattern: "^[a-f0-9]{64}$"; + }; + }; + readonly additionalProperties: false; + }; + }; + readonly additionalProperties: false; + }; + readonly observation: { + readonly type: "object"; + readonly required: readonly ["schema", "id", "type", "data", "observedAt", "digest"]; + }; + }; + }; + }; + readonly snapshots: { + readonly type: "array"; + readonly items: { + readonly type: "object"; + readonly required: readonly ["schema", "id", "createdAt", "semantics", "metadata", "digest"]; + }; + }; + readonly artifacts: { + readonly type: "object"; + }; + readonly artifactRef: { + readonly type: "object"; + readonly required: readonly ["kind", "id"]; + }; + }; + readonly additionalProperties: true; +}; +export declare function runtimeEpisodeDigest(value: unknown): RuntimeEpisodeContentDigest; +export declare function runtimeEpisodeActionDigestPayload(action: RuntimeEpisodeActionRecord | RuntimeEpisodeActionSpec): Record; +export declare function runtimeEpisodeObservationDigestPayload(observation: ObservationResult): Record; +export declare function runtimeEpisodeSnapshotDigestPayload(snapshot: Snapshot): Record; +export declare function validateRuntimeEpisodeTrace(trace: unknown): RuntimeEpisodeTraceValidationResult; +//# sourceMappingURL=runtime-episode-contracts.d.ts.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-episode-contracts.d.ts.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-episode-contracts.d.ts.map new file mode 100644 index 000000000..448788acf --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-episode-contracts.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"runtime-episode-contracts.d.ts","sourceRoot":"","sources":["../src/runtime-episode-contracts.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,iBAAiB,EACjB,0BAA0B,EAC1B,wBAAwB,EACxB,2BAA2B,EAK3B,mCAAmC,EACnC,QAAQ,EACT,MAAM,wBAAwB,CAAA;AAE/B,eAAO,MAAM,4BAA4B,EAAG,qCAA8C,CAAA;AAC1F,eAAO,MAAM,6BAA6B,EAAG,sCAA+C,CAAA;AAC5F,eAAO,MAAM,kCAAkC,EAAG,2CAAoD,CAAA;AACtG,eAAO,MAAM,+BAA+B,EAAG,wCAAiD,CAAA;AAEhG,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8DpC,CAAA;AAgBV,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,2BAA2B,CAKhF;AAED,wBAAgB,iCAAiC,CAAC,MAAM,EAAE,0BAA0B,GAAG,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAqBxI;AAED,wBAAgB,sCAAsC,CAAC,WAAW,EAAE,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQ9G;AAED,wBAAgB,mCAAmC,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAS/F;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,mCAAmC,CA0D/F"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-episode-contracts.js b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-episode-contracts.js new file mode 100644 index 000000000..6b2073db4 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-episode-contracts.js @@ -0,0 +1,400 @@ +import { createHash } from "node:crypto"; +import { isPlainObject as isRecord, stableJson } from "./object-utils.js"; +export const RUNTIME_EPISODE_TRACE_SCHEMA = "wp-codebox/runtime-episode-trace/v1"; +export const RUNTIME_EPISODE_ACTION_SCHEMA = "wp-codebox/runtime-episode-action/v1"; +export const RUNTIME_EPISODE_OBSERVATION_SCHEMA = "wp-codebox/runtime-episode-observation/v1"; +export const RUNTIME_EPISODE_SNAPSHOT_SCHEMA = "wp-codebox/runtime-episode-snapshot/v1"; +export const RUNTIME_EPISODE_TRACE_JSON_SCHEMA = { + $id: RUNTIME_EPISODE_TRACE_SCHEMA, + type: "object", + required: ["schema", "version", "id", "createdAt", "runtime", "reset", "steps", "snapshots"], + properties: { + schema: { const: RUNTIME_EPISODE_TRACE_SCHEMA }, + version: { const: 1 }, + id: { type: "string", minLength: 1 }, + createdAt: { type: "string", minLength: 1 }, + runtime: { type: "object", required: ["id", "backend", "environment", "createdAt", "status"] }, + reset: { type: "object", required: ["id", "runtime", "observations", "observationRefs"] }, + steps: { + type: "array", + items: { + type: "object", + required: ["id", "index", "action", "actionRef", "execution", "executionRef"], + properties: { + action: { + type: "object", + required: ["schema", "id", "kind", "command", "args", "digest"], + properties: { + schema: { const: RUNTIME_EPISODE_ACTION_SCHEMA }, + id: { type: "string", minLength: 1 }, + kind: { enum: ["command", "filesystem", "http", "browser"] }, + command: { type: "string", minLength: 1 }, + args: { type: "array", items: { type: "string" } }, + cwd: { type: "string" }, + timeoutMs: { type: "number", minimum: 0 }, + method: { type: "string", minLength: 1 }, + url: { type: "string", minLength: 1 }, + path: { type: "string", minLength: 1 }, + operation: { type: "string", minLength: 1 }, + selector: { type: "string", minLength: 1 }, + description: { type: "string", minLength: 1 }, + metadata: { type: "object" }, + digest: { + type: "object", + required: ["algorithm", "value"], + properties: { + algorithm: { const: "sha256" }, + value: { type: "string", pattern: "^[a-f0-9]{64}$" }, + }, + additionalProperties: false, + }, + }, + additionalProperties: false, + }, + observation: { + type: "object", + required: ["schema", "id", "type", "data", "observedAt", "digest"], + }, + }, + }, + }, + snapshots: { + type: "array", + items: { type: "object", required: ["schema", "id", "createdAt", "semantics", "metadata", "digest"] }, + }, + artifacts: { type: "object" }, + artifactRef: { type: "object", required: ["kind", "id"] }, + }, + additionalProperties: true, +}; +const RUNTIME_EPISODE_TRACE_FORBIDDEN_FIELDS = new Set([ + "reward", + "success", + "grader", + "scenario", + "task-set", + "task_set", + "taskSet", + "benchmark", + "model-eval", + "model_eval", + "modelEval", +]); +export function runtimeEpisodeDigest(value) { + return { + algorithm: "sha256", + value: createHash("sha256").update("wp-codebox/runtime-episode-trace/v1\n").update(stableJson(value)).digest("hex"), + }; +} +export function runtimeEpisodeActionDigestPayload(action) { + const payload = { + schema: RUNTIME_EPISODE_ACTION_SCHEMA, + kind: action.kind ?? "command", + command: action.command, + args: Array.isArray(action.args) ? action.args : [], + }; + for (const key of ["cwd", "method", "url", "path", "operation", "selector", "description"]) { + if (typeof action[key] === "string") { + payload[key] = action[key]; + } + } + if (typeof action.timeoutMs === "number") { + payload.timeoutMs = action.timeoutMs; + } + if (isRecord(action.metadata)) { + payload.metadata = action.metadata; + } + return payload; +} +export function runtimeEpisodeObservationDigestPayload(observation) { + return { + schema: RUNTIME_EPISODE_OBSERVATION_SCHEMA, + type: observation.type, + data: observation.data, + observedAt: observation.observedAt, + artifactRefs: observation.artifactRefs ?? [], + }; +} +export function runtimeEpisodeSnapshotDigestPayload(snapshot) { + return { + schema: RUNTIME_EPISODE_SNAPSHOT_SCHEMA, + id: snapshot.id, + createdAt: snapshot.createdAt, + semantics: snapshot.semantics, + metadata: snapshot.metadata, + artifactRefs: snapshot.artifactRefs ?? [], + }; +} +export function validateRuntimeEpisodeTrace(trace) { + const issues = []; + const candidate = trace; + if (!candidate || typeof candidate !== "object") { + return { valid: false, schema: RUNTIME_EPISODE_TRACE_SCHEMA, issues: [{ path: "$", message: "trace must be an object" }] }; + } + if (candidate.schema !== RUNTIME_EPISODE_TRACE_SCHEMA) { + issues.push({ path: "$.schema", message: `schema must be ${RUNTIME_EPISODE_TRACE_SCHEMA}` }); + } + if (candidate.version !== 1) { + issues.push({ path: "$.version", message: "version must be 1" }); + } + if (!nonEmptyString(candidate.id)) { + issues.push({ path: "$.id", message: "id must be a non-empty string" }); + } + if (!nonEmptyString(candidate.createdAt)) { + issues.push({ path: "$.createdAt", message: "createdAt must be a non-empty string" }); + } + if (!candidate.runtime || typeof candidate.runtime !== "object" || !nonEmptyString(candidate.runtime.id)) { + issues.push({ path: "$.runtime.id", message: "runtime id is required" }); + } + if (!candidate.reset || typeof candidate.reset !== "object" || !nonEmptyString(candidate.reset.id)) { + issues.push({ path: "$.reset.id", message: "reset id is required" }); + } + if (!Array.isArray(candidate.reset?.observations)) { + issues.push({ path: "$.reset.observations", message: "reset observations must be an array" }); + } + else { + candidate.reset.observations.forEach((observation, index) => { + validateRuntimeEpisodeObservation(observation, `$.reset.observations[${index}]`, issues); + }); + } + if (!Array.isArray(candidate.reset?.observationRefs)) { + issues.push({ path: "$.reset.observationRefs", message: "reset observationRefs must be an array" }); + } + else { + candidate.reset.observationRefs.forEach((ref, index) => { + validateRuntimeEpisodeTraceRef(ref, `$.reset.observationRefs[${index}]`, "observation", issues); + const observation = candidate.reset?.observations?.[index]; + if (observation) { + validateRuntimeEpisodeRefDigest(ref, observation.digest, `$.reset.observationRefs[${index}]`, issues); + } + }); + } + if (!Array.isArray(candidate.steps)) { + issues.push({ path: "$.steps", message: "steps must be an array" }); + } + else { + candidate.steps.forEach((step, index) => validateRuntimeEpisodeStep(step, index, issues)); + } + if (!Array.isArray(candidate.snapshots)) { + issues.push({ path: "$.snapshots", message: "snapshots must be an array" }); + } + else { + candidate.snapshots.forEach((snapshot, index) => validateRuntimeEpisodeSnapshot(snapshot, `$.snapshots[${index}]`, issues)); + } + collectForbiddenRuntimeEpisodeTraceFields(candidate, "$", issues); + return { valid: issues.length === 0, schema: RUNTIME_EPISODE_TRACE_SCHEMA, issues }; +} +function validateRuntimeEpisodeStep(step, index, issues) { + const path = `$.steps[${index}]`; + if (!nonEmptyString(step.id)) { + issues.push({ path: `${path}.id`, message: "step id is required" }); + } + if (step.index !== index) { + issues.push({ path: `${path}.index`, message: "step index must match array position" }); + } + if (!nonEmptyString(step.action?.id)) { + issues.push({ path: `${path}.action.id`, message: "action id is required" }); + } + else { + validateRuntimeEpisodeAction(step.action, `${path}.action`, issues); + } + if (!nonEmptyString(step.actionRef?.id)) { + issues.push({ path: `${path}.actionRef.id`, message: "actionRef id is required" }); + } + else { + validateRuntimeEpisodeTraceRef(step.actionRef, `${path}.actionRef`, "action", issues); + validateRuntimeEpisodeRefDigest(step.actionRef, step.action?.digest, `${path}.actionRef`, issues); + } + if (!nonEmptyString(step.execution?.id)) { + issues.push({ path: `${path}.execution.id`, message: "execution id is required" }); + } + if (!nonEmptyString(step.executionRef?.id)) { + issues.push({ path: `${path}.executionRef.id`, message: "executionRef id is required" }); + } + else { + validateRuntimeEpisodeTraceRef(step.executionRef, `${path}.executionRef`, "execution", issues); + validateRuntimeEpisodeRefDigest(step.executionRef, step.execution ? runtimeEpisodeDigest(step.execution) : undefined, `${path}.executionRef`, issues); + } + if (step.observation && !nonEmptyString(step.observation.id)) { + issues.push({ path: `${path}.observation.id`, message: "observation id is required" }); + } + else if (step.observation) { + validateRuntimeEpisodeObservation(step.observation, `${path}.observation`, issues); + } + if (step.observationRef) { + validateRuntimeEpisodeTraceRef(step.observationRef, `${path}.observationRef`, "observation", issues); + if (step.observation) { + validateRuntimeEpisodeRefDigest(step.observationRef, step.observation.digest, `${path}.observationRef`, issues); + } + } +} +function validateRuntimeEpisodeAction(action, path, issues) { + if (!isRecord(action)) { + issues.push({ path, message: "action must be an object" }); + return; + } + if (action.schema !== RUNTIME_EPISODE_ACTION_SCHEMA) { + issues.push({ path: `${path}.schema`, message: `action schema must be ${RUNTIME_EPISODE_ACTION_SCHEMA}` }); + } + if (!["command", "filesystem", "http", "browser"].includes(`${action.kind}`)) { + issues.push({ path: `${path}.kind`, message: "action kind must be command, filesystem, http, or browser" }); + } + if (!nonEmptyString(action.command)) { + issues.push({ path: `${path}.command`, message: "action command is required" }); + } + if (!Array.isArray(action.args) || !action.args.every((arg) => typeof arg === "string")) { + issues.push({ path: `${path}.args`, message: "action args must be an array of strings" }); + } + if (action.cwd !== undefined && typeof action.cwd !== "string") { + issues.push({ path: `${path}.cwd`, message: "action cwd must be a string when present" }); + } + for (const key of ["method", "url", "path", "operation", "selector", "description"]) { + if (action[key] !== undefined && !nonEmptyString(action[key])) { + issues.push({ path: `${path}.${key}`, message: `action ${key} must be a non-empty string when present` }); + } + } + if (action.metadata !== undefined && !isRecord(action.metadata)) { + issues.push({ path: `${path}.metadata`, message: "action metadata must be an object when present" }); + } + const timeoutMs = action.timeoutMs; + if (timeoutMs !== undefined && (typeof timeoutMs !== "number" || !Number.isFinite(timeoutMs) || timeoutMs < 0)) { + issues.push({ path: `${path}.timeoutMs`, message: "action timeoutMs must be a non-negative number when present" }); + } + if (!validDigest(action.digest)) { + issues.push({ path: `${path}.digest`, message: "action digest must be a sha256 digest" }); + return; + } + const expected = runtimeEpisodeDigest(runtimeEpisodeActionDigestPayload(action)); + if (action.digest.value !== expected.value) { + issues.push({ path: `${path}.digest`, message: "action digest must match the canonical replay payload" }); + } +} +function validateRuntimeEpisodeObservation(observation, path, issues) { + if (!isRecord(observation)) { + issues.push({ path, message: "observation must be an object" }); + return; + } + if (observation.schema !== RUNTIME_EPISODE_OBSERVATION_SCHEMA) { + issues.push({ path: `${path}.schema`, message: `observation schema must be ${RUNTIME_EPISODE_OBSERVATION_SCHEMA}` }); + } + if (!nonEmptyString(observation.id)) { + issues.push({ path: `${path}.id`, message: "observation id is required" }); + } + if (!nonEmptyString(observation.type)) { + issues.push({ path: `${path}.type`, message: "observation type is required" }); + } + if (!("data" in observation)) { + issues.push({ path: `${path}.data`, message: "observation data is required" }); + } + if (!nonEmptyString(observation.observedAt)) { + issues.push({ path: `${path}.observedAt`, message: "observation observedAt is required" }); + } + if (!validDigest(observation.digest)) { + issues.push({ path: `${path}.digest`, message: "observation digest must be a sha256 digest" }); + return; + } + if (observation.artifactRefs !== undefined) { + if (!Array.isArray(observation.artifactRefs)) { + issues.push({ path: `${path}.artifactRefs`, message: "observation artifactRefs must be an array when present" }); + } + else { + observation.artifactRefs.forEach((ref, index) => validateRuntimeEpisodeTraceRef(ref, `${path}.artifactRefs[${index}]`, undefined, issues)); + } + } + const expected = runtimeEpisodeDigest(runtimeEpisodeObservationDigestPayload(observation)); + if (observation.digest.value !== expected.value) { + issues.push({ path: `${path}.digest`, message: "observation digest must match the canonical observation payload" }); + } +} +function validateRuntimeEpisodeSnapshot(snapshot, path, issues) { + if (!isRecord(snapshot)) { + issues.push({ path, message: "snapshot must be an object" }); + return; + } + if (snapshot.schema !== RUNTIME_EPISODE_SNAPSHOT_SCHEMA) { + issues.push({ path: `${path}.schema`, message: `snapshot schema must be ${RUNTIME_EPISODE_SNAPSHOT_SCHEMA}` }); + } + if (!nonEmptyString(snapshot.id)) { + issues.push({ path: `${path}.id`, message: "snapshot id is required" }); + } + if (!nonEmptyString(snapshot.createdAt)) { + issues.push({ path: `${path}.createdAt`, message: "snapshot createdAt is required" }); + } + if (!nonEmptyString(snapshot.semantics)) { + issues.push({ path: `${path}.semantics`, message: "snapshot semantics are required" }); + } + if (!isRecord(snapshot.metadata)) { + issues.push({ path: `${path}.metadata`, message: "snapshot metadata must be an object" }); + } + if (snapshot.artifactRefs !== undefined) { + if (!Array.isArray(snapshot.artifactRefs)) { + issues.push({ path: `${path}.artifactRefs`, message: "snapshot artifactRefs must be an array when present" }); + } + else { + snapshot.artifactRefs.forEach((ref, index) => validateRuntimeEpisodeTraceRef(ref, `${path}.artifactRefs[${index}]`, undefined, issues)); + } + } + if (!validDigest(snapshot.digest)) { + issues.push({ path: `${path}.digest`, message: "snapshot digest must be a sha256 digest" }); + return; + } + const expected = runtimeEpisodeDigest(runtimeEpisodeSnapshotDigestPayload(snapshot)); + if (snapshot.digest.value !== expected.value) { + issues.push({ path: `${path}.digest`, message: "snapshot digest must match the canonical snapshot payload" }); + } +} +function validateRuntimeEpisodeTraceRef(ref, path, kind, issues) { + if (!isRecord(ref)) { + issues.push({ path, message: "ref must be an object" }); + return; + } + if (kind !== undefined && ref.kind !== kind) { + issues.push({ path: `${path}.kind`, message: `ref kind must be ${kind}` }); + } + if (!nonEmptyString(ref.kind)) { + issues.push({ path: `${path}.kind`, message: "ref kind is required" }); + } + if (!nonEmptyString(ref.id)) { + issues.push({ path: `${path}.id`, message: "ref id is required" }); + } + if (!validDigest(ref.digest)) { + issues.push({ path: `${path}.digest`, message: "ref digest must be a sha256 digest" }); + } +} +function validateRuntimeEpisodeRefDigest(ref, targetDigest, path, issues) { + if (!validDigest(ref.digest) || !validDigest(targetDigest)) { + return; + } + if (ref.digest.value !== targetDigest.value) { + issues.push({ path: `${path}.digest`, message: "ref digest must match the referenced envelope digest" }); + } +} +function validDigest(value) { + return isRecord(value) && value.algorithm === "sha256" && typeof value.value === "string" && /^[a-f0-9]{64}$/.test(value.value); +} +function collectForbiddenRuntimeEpisodeTraceFields(value, path, issues) { + if (!value || typeof value !== "object") { + return; + } + if (isRuntimeEpisodeFreeformPayloadPath(path)) { + return; + } + if (Array.isArray(value)) { + value.forEach((item, index) => collectForbiddenRuntimeEpisodeTraceFields(item, `${path}[${index}]`, issues)); + return; + } + for (const [key, child] of Object.entries(value)) { + const childPath = `${path}.${key}`; + if (RUNTIME_EPISODE_TRACE_FORBIDDEN_FIELDS.has(key)) { + issues.push({ path: childPath, message: `${key} is not part of the generic runtime episode trace contract` }); + } + collectForbiddenRuntimeEpisodeTraceFields(child, childPath, issues); + } +} +function isRuntimeEpisodeFreeformPayloadPath(path) { + return path === "$.artifacts" || path.endsWith(".data") || path.endsWith(".metadata"); +} +function nonEmptyString(value) { + return typeof value === "string" && value.length > 0; +} +//# sourceMappingURL=runtime-episode-contracts.js.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-episode-contracts.js.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-episode-contracts.js.map new file mode 100644 index 000000000..5c56b7488 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-episode-contracts.js.map @@ -0,0 +1 @@ +{"version":3,"file":"runtime-episode-contracts.js","sourceRoot":"","sources":["../src/runtime-episode-contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,EAAE,aAAa,IAAI,QAAQ,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAczE,MAAM,CAAC,MAAM,4BAA4B,GAAG,qCAA8C,CAAA;AAC1F,MAAM,CAAC,MAAM,6BAA6B,GAAG,sCAA+C,CAAA;AAC5F,MAAM,CAAC,MAAM,kCAAkC,GAAG,2CAAoD,CAAA;AACtG,MAAM,CAAC,MAAM,+BAA+B,GAAG,wCAAiD,CAAA;AAEhG,MAAM,CAAC,MAAM,iCAAiC,GAAG;IAC/C,GAAG,EAAE,4BAA4B;IACjC,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC;IAC5F,UAAU,EAAE;QACV,MAAM,EAAE,EAAE,KAAK,EAAE,4BAA4B,EAAE;QAC/C,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE;QACrB,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE;QACpC,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,E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AAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,yCAAyC,CAAC,IAAI,EAAE,GAAG,IAAI,IAAI,KAAK,GAAG,EAAE,MAAM,CAAC,CAAC,CAAA;QAC5G,OAAM;IACR,CAAC;IAED,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,MAAM,SAAS,GAAG,GAAG,IAAI,IAAI,GAAG,EAAE,CAAA;QAClC,IAAI,sCAAsC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACpD,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,GAAG,4DAA4D,EAAE,CAAC,CAAA;QAC/G,CAAC;QACD,yCAAyC,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,CAAA;IACrE,CAAC;AACH,CAAC;AAED,SAAS,mCAAmC,CAAC,IAAY;IACvD,OAAO,IAAI,KAAK,aAAa,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;AACvF,CAAC;AAED,SAAS,cAAc,CAAC,KAAc;IACpC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAA;AACtD,CAAC"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-episode.d.ts b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-episode.d.ts new file mode 100644 index 000000000..f3296a386 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-episode.d.ts @@ -0,0 +1,4 @@ +import type { RuntimeBackend, RuntimeEpisode, RuntimeEpisodeSpec } from "./runtime-contracts.js"; +export { RUNTIME_EPISODE_ACTION_SCHEMA, RUNTIME_EPISODE_OBSERVATION_SCHEMA, RUNTIME_EPISODE_SNAPSHOT_SCHEMA, RUNTIME_EPISODE_TRACE_JSON_SCHEMA, RUNTIME_EPISODE_TRACE_SCHEMA, runtimeEpisodeDigest, validateRuntimeEpisodeTrace, } from "./runtime-episode-contracts.js"; +export declare function createRuntimeEpisode(spec: RuntimeEpisodeSpec, backend: RuntimeBackend): Promise; +//# sourceMappingURL=runtime-episode.d.ts.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-episode.d.ts.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-episode.d.ts.map new file mode 100644 index 000000000..962a1bbcd --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-episode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"runtime-episode.d.ts","sourceRoot":"","sources":["../src/runtime-episode.ts"],"names":[],"mappings":"AAiCA,OAAO,KAAK,EAKV,cAAc,EACd,cAAc,EAGd,kBAAkB,EAKnB,MAAM,wBAAwB,CAAA;AAE/B,OAAO,EACL,6BAA6B,EAC7B,kCAAkC,EAClC,+BAA+B,EAC/B,iCAAiC,EACjC,4BAA4B,EAC5B,oBAAoB,EACpB,2BAA2B,GAC5B,MAAM,gCAAgC,CAAA;AAiGvC,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAErH"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-episode.js b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-episode.js new file mode 100644 index 000000000..2e75977cb --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-episode.js @@ -0,0 +1,428 @@ +import { mkdir, readFile, writeFile } from "node:fs/promises"; +import { join } from "node:path"; +import { artifactFileDigest, artifactManifestFile, refreshArtifactManifestFileSha256s, upsertArtifactManifestFiles } from "./artifact-manifest.js"; +import { writeArtifactJson, writeArtifactManifestJson } from "./artifact-layout.js"; +import { ARTIFACT_MANIFEST_PATH, RUNTIME_EPISODE_EVENTS_ARTIFACT_PATH, RUNTIME_EPISODE_TRACE_ARTIFACT_PATH, RUNTIME_REFERENCE_MANIFEST_ARTIFACT_PATH, RUNTIME_REPLAY_REFERENCE_INDEX_ARTIFACT_PATH, normalizeArtifactBundleTraceRef, normalizeRuntimeReferenceArtifactBundleRef, normalizeRuntimeReferenceManifestFileRefs, runtimeReferenceManifestArtifactFiles, runtimeReplayReferenceIndexArtifactFiles, } from "./artifact-references.js"; +import { isPlainObject as isRecord } from "./object-utils.js"; +import { RUNTIME_EPISODE_ACTION_SCHEMA, RUNTIME_EPISODE_OBSERVATION_SCHEMA, RUNTIME_EPISODE_SNAPSHOT_SCHEMA, RUNTIME_EPISODE_TRACE_SCHEMA, runtimeEpisodeActionDigestPayload, runtimeEpisodeDigest, runtimeEpisodeObservationDigestPayload, runtimeEpisodeSnapshotDigestPayload, } from "./runtime-episode-contracts.js"; +import { buildRuntimeReferenceManifest, buildRuntimeReplayReferenceIndex } from "./runtime-reference.js"; +import { assertRuntimePolicy } from "./runtime-policy.js"; +export { RUNTIME_EPISODE_ACTION_SCHEMA, RUNTIME_EPISODE_OBSERVATION_SCHEMA, RUNTIME_EPISODE_SNAPSHOT_SCHEMA, RUNTIME_EPISODE_TRACE_JSON_SCHEMA, RUNTIME_EPISODE_TRACE_SCHEMA, runtimeEpisodeDigest, validateRuntimeEpisodeTrace, } from "./runtime-episode-contracts.js"; +function observationRef(observation, fallbackId) { + return { kind: "observation", id: observation.id || fallbackId, digest: observation.digest ?? runtimeEpisodeDigest(runtimeEpisodeObservationDigestPayload(observation)) }; +} +function observationWithId(observation, fallbackId) { + const enveloped = { + ...observation, + schema: RUNTIME_EPISODE_OBSERVATION_SCHEMA, + id: observation.id || fallbackId, + }; + return { ...enveloped, digest: runtimeEpisodeDigest(runtimeEpisodeObservationDigestPayload(enveloped)) }; +} +function snapshotWithSemantics(snapshot) { + const enveloped = { + ...snapshot, + schema: RUNTIME_EPISODE_SNAPSHOT_SCHEMA, + semantics: snapshot.semantics ?? "metadata-only", + }; + return { ...enveloped, digest: runtimeEpisodeDigest(runtimeEpisodeSnapshotDigestPayload(enveloped)) }; +} +function runtimeSnapshotReplaySemantics(semantics) { + if (semantics === "replayable-runtime-state") { + return { status: "replayable-runtime-state", limitations: [] }; + } + if (semantics === "runtime-state-artifact") { + return { status: "runtime-state-artifact", limitations: [] }; + } + if (semantics === "partial-replay") { + return { + status: "partial-replay", + limitations: [ + "Snapshot bundle contains replay instructions and artifact references, but not a complete WordPress database checkpoint.", + "Replay consumers can restore mounted files and inspect runtime evidence; posts, options, terms, users, uploads, active theme/plugins, and browser/editor state may require external capture.", + ], + }; + } + if (semantics === "metadata-only") { + return { + status: "metadata-only", + limitations: [ + "Snapshot records runtime metadata only; it is not a WordPress database or filesystem checkpoint.", + "Replay consumers must use trace actions and artifact bundle files to reconstruct supported state.", + ], + }; + } + return { + status: "not-replayable", + limitations: [`Snapshot semantics are not recognized by this WP Codebox version: ${semantics}`], + }; +} +function runtimeEpisodeJsonLines(trace) { + const records = [ + { + type: "episode.reset", + id: trace.reset.id, + runtime: trace.reset.runtime, + observations: trace.reset.observationRefs, + }, + ...trace.steps.map((step) => ({ + type: "episode.step", + id: step.id, + index: step.index, + actionRef: step.actionRef, + executionRef: step.executionRef, + ...(step.observationRef ? { observationRef: step.observationRef } : {}), + })), + ...trace.snapshots.map((snapshot) => ({ + type: "episode.snapshot", + id: snapshot.id, + createdAt: snapshot.createdAt, + semantics: snapshot.semantics, + artifactRefs: snapshot.artifactRefs ?? [], + })), + ]; + if (trace.artifactRef) { + records.push({ + type: "episode.artifacts", + id: trace.artifactRef.id, + artifactRef: trace.artifactRef, + }); + } + return `${records.map((record) => JSON.stringify(record)).join("\n")}\n`; +} +export async function createRuntimeEpisode(spec, backend) { + return RuntimeEpisodeRunner.create(spec, backend); +} +class RuntimeEpisodeRunner { + spec; + backend; + runtime; + resetResult; + resetCount = 0; + steps = []; + snapshots = []; + artifacts; + traceCreatedAt; + constructor(spec, backend) { + this.spec = spec; + this.backend = backend; + } + static async create(spec, backend) { + const episode = new RuntimeEpisodeRunner(spec, backend); + await episode.reset(); + return episode; + } + async reset() { + await this.runtime?.destroy(); + this.runtime = await createEpisodeRuntime(this.spec, this.backend); + this.steps.length = 0; + this.snapshots.length = 0; + this.artifacts = undefined; + this.traceCreatedAt = undefined; + for (const mount of this.spec.mounts ?? []) { + await this.runtime.mount(mount); + } + const runtime = await this.runtime.info(); + const resetId = `${runtime.id}:reset:${this.resetCount++}`; + const observations = []; + for (const [index, observation] of (this.spec.resetObservations ?? [{ type: "runtime-info" }, { type: "mounts" }]).entries()) { + observations.push(observationWithId(await this.runtime.observe(observation), `${resetId}:observation:${index}`)); + } + this.resetResult = { + id: resetId, + runtime, + observations, + observationRefs: observations.map((observation, index) => observationRef(observation, `${resetId}:observation:${index}`)), + }; + return this.resetResult; + } + async step(action, observation = this.spec.stepObservation ?? false) { + const runtime = this.assertRuntime(); + const execution = await runtime.execute(action); + const index = this.steps.length; + const stepId = `${execution.id}:step:${index}`; + const actionRecord = { + schema: RUNTIME_EPISODE_ACTION_SCHEMA, + id: `${stepId}:action`, + kind: action.kind ?? "command", + command: action.command, + args: action.args ?? [], + ...(action.cwd ? { cwd: action.cwd } : {}), + ...(action.timeoutMs !== undefined ? { timeoutMs: action.timeoutMs } : {}), + ...(action.method ? { method: action.method } : {}), + ...(action.url ? { url: action.url } : {}), + ...(action.path ? { path: action.path } : {}), + ...(action.operation ? { operation: action.operation } : {}), + ...(action.selector ? { selector: action.selector } : {}), + ...(action.description ? { description: action.description } : {}), + ...(action.metadata ? { metadata: action.metadata } : {}), + digest: runtimeEpisodeDigest(runtimeEpisodeActionDigestPayload(action)), + }; + const stepObservation = observation ? observationWithId(await runtime.observe(observation), `${stepId}:observation`) : undefined; + const result = { + id: stepId, + index, + action: actionRecord, + actionRef: { kind: "action", id: actionRecord.id, digest: actionRecord.digest }, + execution, + executionRef: { kind: "execution", id: execution.id, digest: runtimeEpisodeDigest(execution) }, + ...(stepObservation + ? { observation: stepObservation, observationRef: observationRef(stepObservation, `${stepId}:observation`) } + : {}), + }; + this.steps.push(result); + return result; + } + async observe(spec) { + return this.assertRuntime().observe(spec); + } + async snapshot() { + const snapshot = snapshotWithSemantics(await this.assertRuntime().snapshot()); + this.snapshots.push(snapshot); + return snapshot; + } + async restoreSnapshot(snapshotOrRef) { + const snapshot = typeof snapshotOrRef === "string" + ? this.snapshots.find((candidate) => candidate.id === snapshotOrRef) + : snapshotOrRef; + if (!snapshot) { + throw new Error(`Runtime episode snapshot not found: ${snapshotOrRef}`); + } + const runtime = this.assertRuntime(); + if (!runtime.restoreSnapshot) { + const runtimeInfo = await runtime.info(); + throw new Error(`Runtime backend does not support same-runtime snapshot restore: ${runtimeInfo.backend}`); + } + const restored = snapshotWithSemantics(await runtime.restoreSnapshot(snapshot)); + if (!this.snapshots.some((candidate) => candidate.id === restored.id)) { + this.snapshots.push(restored); + } + return restored; + } + async collectArtifacts(spec = this.spec.artifactSpec ?? {}) { + const artifacts = await this.assertRuntime().collectArtifacts(spec); + this.artifacts = { + ...artifacts, + runtimeEpisodeTracePath: join(artifacts.directory, RUNTIME_EPISODE_TRACE_ARTIFACT_PATH), + runtimeEpisodeEventsPath: join(artifacts.directory, RUNTIME_EPISODE_EVENTS_ARTIFACT_PATH), + runtimeReplayReferenceIndexPath: join(artifacts.directory, RUNTIME_REPLAY_REFERENCE_INDEX_ARTIFACT_PATH), + }; + if (spec.includeRuntimeSnapshotBundles) { + await this.persistRuntimeSnapshotBundles(); + } + await this.persistRuntimeEpisodeTraceArtifacts(); + return this.artifacts; + } + async persistRuntimeSnapshotBundles() { + if (!this.artifacts || this.snapshots.length === 0) { + return; + } + const manifest = JSON.parse(await readFile(this.artifacts.manifestPath, "utf8")); + const snapshotDirectory = join(this.artifacts.directory, "files/runtime-snapshots"); + await mkdir(snapshotDirectory, { recursive: true }); + const baseRefs = runtimeReferenceManifestArtifactFiles(manifest.files); + const snapshotRefs = normalizeRuntimeReferenceManifestFileRefs(baseRefs); + for (const [index, snapshot] of this.snapshots.entries()) { + const semantics = snapshot.semantics === "replayable-runtime-state" || snapshot.semantics === "runtime-state-artifact" + ? snapshot.semantics + : "partial-replay"; + const replay = runtimeSnapshotReplaySemantics(semantics); + const relativePath = `files/runtime-snapshots/${snapshot.id}.json`; + const bundleId = `${snapshot.id}:runtime-snapshot-bundle`; + const bundle = { + schema: "wp-codebox/runtime-snapshot-bundle/v1", + version: 1, + id: bundleId, + snapshot: { + id: snapshot.id, + createdAt: snapshot.createdAt, + originalSemantics: snapshot.semantics ?? "metadata-only", + semantics, + metadata: snapshot.metadata, + }, + replay: { + status: replay.status, + limitations: replay.limitations, + instructions: [ + "Verify every referenced artifact SHA-256 before replay.", + "Use blueprint.after.json and blueprint.after-notes.json as generated Playground replay guidance when present.", + "Restore mounted file artifacts from files/mounted-files.json where replayable file contents are available.", + "Use files/runtime-episode-trace.json and files/runtime-episode.jsonl to inspect actions, observations, and snapshot refs after the episode trace is persisted.", + ], + }, + refs: snapshotRefs, + }; + await writeArtifactJson(join(this.artifacts.directory, relativePath), bundle); + const digest = artifactFileDigest(await readFile(join(this.artifacts.directory, relativePath))); + const artifactRef = { + kind: "runtime-snapshot-bundle", + id: bundleId, + path: relativePath, + digest, + }; + this.snapshots[index] = snapshotWithSemantics({ + ...snapshot, + semantics, + artifactRefs: [ + ...(snapshot.artifactRefs ?? []).filter((ref) => ref.path !== relativePath), + artifactRef, + ], + }); + upsertArtifactManifestFiles(manifest, [artifactManifestFile(relativePath, "runtime-snapshot-bundle", "application/json")]); + } + await writeArtifactManifestJson(this.artifacts.directory, ARTIFACT_MANIFEST_PATH, manifest); + } + async persistRuntimeEpisodeTraceArtifacts() { + if (!this.artifacts?.runtimeEpisodeTracePath || !this.artifacts.runtimeEpisodeEventsPath || !this.artifacts.runtimeReferenceManifestPath || !this.artifacts.runtimeReplayReferenceIndexPath) { + return; + } + const trace = await this.trace(); + const traceRelativePath = RUNTIME_EPISODE_TRACE_ARTIFACT_PATH; + const eventsRelativePath = RUNTIME_EPISODE_EVENTS_ARTIFACT_PATH; + await writeFile(this.artifacts.runtimeEpisodeTracePath, `${JSON.stringify(trace, null, 2)}\n`); + await writeFile(this.artifacts.runtimeEpisodeEventsPath, `${runtimeEpisodeJsonLines(trace)}`); + await this.updateArtifactMetadataForRuntimeEpisodeTrace(traceRelativePath, eventsRelativePath); + await this.updateArtifactReviewForRuntimeEpisodeTrace(traceRelativePath); + await this.updateArtifactManifestForRuntimeEpisodeTrace(traceRelativePath, eventsRelativePath); + await this.updateRuntimeReferenceManifestForRuntimeEpisodeTrace(traceRelativePath, eventsRelativePath); + await this.updateRuntimeReplayReferenceIndexForRuntimeEpisodeTrace(trace, traceRelativePath, eventsRelativePath); + } + async updateRuntimeReferenceManifestForRuntimeEpisodeTrace(traceRelativePath, eventsRelativePath) { + if (!this.artifacts?.runtimeReferenceManifestPath) { + return; + } + const manifest = JSON.parse(await readFile(this.artifacts.manifestPath, "utf8")); + const fileRefs = runtimeReferenceManifestArtifactFiles(manifest.files); + const referenceFiles = normalizeRuntimeReferenceManifestFileRefs(fileRefs); + const traceRef = referenceFiles.find((file) => file.path === traceRelativePath); + const eventsRef = referenceFiles.find((file) => file.path === eventsRelativePath); + const artifactBundle = normalizeRuntimeReferenceArtifactBundleRef(manifest); + if (!artifactBundle) { + return; + } + const referenceManifest = buildRuntimeReferenceManifest({ + createdAt: this.artifacts.createdAt, + runtime: manifest.runtime, + artifactBundle, + files: referenceFiles, + ...(traceRef ? { trace: traceRef } : {}), + ...(eventsRef ? { events: eventsRef } : {}), + snapshots: this.snapshots, + }); + await writeArtifactJson(this.artifacts.runtimeReferenceManifestPath, referenceManifest); + await refreshArtifactManifestFileSha256s(this.artifacts.directory, manifest); + await writeArtifactJson(this.artifacts.manifestPath, manifest); + } + async updateRuntimeReplayReferenceIndexForRuntimeEpisodeTrace(trace, traceRelativePath, eventsRelativePath) { + if (!this.artifacts?.runtimeReplayReferenceIndexPath) { + return; + } + const manifest = JSON.parse(await readFile(this.artifacts.manifestPath, "utf8")); + const fileRefs = runtimeReplayReferenceIndexArtifactFiles(manifest.files); + const referenceFiles = normalizeRuntimeReferenceManifestFileRefs(fileRefs); + const traceRef = referenceFiles.find((file) => file.path === traceRelativePath); + const eventsRef = referenceFiles.find((file) => file.path === eventsRelativePath); + const runtimeReferenceManifestRef = referenceFiles.find((file) => file.path === RUNTIME_REFERENCE_MANIFEST_ARTIFACT_PATH); + const artifactBundle = normalizeRuntimeReferenceArtifactBundleRef(manifest); + if (!artifactBundle) { + return; + } + const replayIndex = buildRuntimeReplayReferenceIndex({ + createdAt: this.artifacts.createdAt, + runtime: manifest.runtime, + artifactBundle, + files: referenceFiles, + ...(traceRef ? { trace: traceRef } : {}), + ...(eventsRef ? { events: eventsRef } : {}), + ...(runtimeReferenceManifestRef ? { runtimeReferenceManifest: runtimeReferenceManifestRef } : {}), + snapshots: this.snapshots, + episodeTrace: trace, + }); + await writeArtifactJson(this.artifacts.runtimeReplayReferenceIndexPath, replayIndex); + await refreshArtifactManifestFileSha256s(this.artifacts.directory, manifest); + await writeArtifactJson(this.artifacts.manifestPath, manifest); + } + async updateArtifactManifestForRuntimeEpisodeTrace(traceRelativePath, eventsRelativePath) { + if (!this.artifacts) { + return; + } + const manifest = JSON.parse(await readFile(this.artifacts.manifestPath, "utf8")); + upsertArtifactManifestFiles(manifest, [ + artifactManifestFile(traceRelativePath, "runtime-episode-trace", "application/json"), + artifactManifestFile(eventsRelativePath, "runtime-episode-events", "application/x-ndjson"), + artifactManifestFile(RUNTIME_REPLAY_REFERENCE_INDEX_ARTIFACT_PATH, "runtime-replay-index", "application/json"), + ]); + await refreshArtifactManifestFileSha256s(this.artifacts.directory, manifest); + await writeArtifactManifestJson(this.artifacts.directory, ARTIFACT_MANIFEST_PATH, manifest); + } + async updateArtifactMetadataForRuntimeEpisodeTrace(traceRelativePath, eventsRelativePath) { + if (!this.artifacts) { + return; + } + const metadata = JSON.parse(await readFile(this.artifacts.metadataPath, "utf8")); + metadata.artifacts = { + ...(isRecord(metadata.artifacts) ? metadata.artifacts : {}), + runtimeEpisodeTrace: traceRelativePath, + runtimeEpisodeEvents: eventsRelativePath, + runtimeReplayReferenceIndex: RUNTIME_REPLAY_REFERENCE_INDEX_ARTIFACT_PATH, + }; + await writeArtifactJson(this.artifacts.metadataPath, metadata); + } + async updateArtifactReviewForRuntimeEpisodeTrace(traceRelativePath) { + if (!this.artifacts) { + return; + } + const review = JSON.parse(await readFile(this.artifacts.reviewPath, "utf8")); + review.evidence.runtimeEpisodeTrace = traceRelativePath; + review.evidence.runtimeReplayReferenceIndex = RUNTIME_REPLAY_REFERENCE_INDEX_ARTIFACT_PATH; + if (!review.progress.some((event) => event.type === "artifact" && event.component === "runtime-episode")) { + review.progress.push({ + type: "artifact", + component: "runtime-episode", + label: "Runtime episode trace persisted", + timestamp: new Date().toISOString(), + }); + } + await writeArtifactJson(this.artifacts.reviewPath, review); + } + async trace() { + const runtime = this.assertRuntime(); + const reset = this.resetResult ?? { + id: `${(await runtime.info()).id}:reset:unrecorded`, + runtime: await runtime.info(), + observations: [], + observationRefs: [], + }; + const artifactRef = normalizeArtifactBundleTraceRef(this.artifacts); + return { + schema: RUNTIME_EPISODE_TRACE_SCHEMA, + version: 1, + id: `trace-${reset.runtime.id}`, + createdAt: this.traceCreatedAt ??= new Date().toISOString(), + runtime: await runtime.info(), + reset, + steps: [...this.steps], + snapshots: [...this.snapshots], + ...(this.artifacts ? { artifacts: this.artifacts } : {}), + ...(artifactRef ? { artifactRef } : {}), + }; + } + async close() { + await this.runtime?.destroy(); + this.runtime = undefined; + } + assertRuntime() { + if (!this.runtime) { + throw new Error("Runtime episode is closed"); + } + return this.runtime; + } +} +async function createEpisodeRuntime(spec, backend) { + assertRuntimePolicy(spec.runtime.policy); + if (backend.kind !== spec.runtime.backend) { + throw new Error(`Backend ${backend.kind} cannot create runtime ${spec.runtime.backend}`); + } + return backend.create(spec.runtime); +} +//# sourceMappingURL=runtime-episode.js.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-episode.js.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-episode.js.map new file mode 100644 index 000000000..4c96d6d8c --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-episode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"runtime-episode.js","sourceRoot":"","sources":["../src/runtime-episode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,kCAAkC,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAA;AAElJ,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AACnF,OAAO,EACL,sBAAsB,EACtB,oCAAoC,EACpC,mCAAmC,EACnC,wCAAwC,EACxC,4CAA4C,EAC5C,+BAA+B,EAC/B,0CAA0C,EAC1C,yCAAyC,EACzC,qCAAqC,EACrC,wCAAwC,GACzC,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC7D,OAAO,EACL,6BAA6B,EAC7B,kCAAkC,EAClC,+BAA+B,EAC/B,4BAA4B,EAC5B,iCAAiC,EACjC,oBAAoB,EACpB,sCAAsC,EACtC,mCAAmC,GACpC,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAAE,6BAA6B,EAAE,gCAAgC,EAAE,MAAM,wBAAwB,CAAA;AAExG,OAAO,EAAE,mBAAmB,EAAE,MAAM,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IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;CACF;AAED,KAAK,UAAU,oBAAoB,CAAC,IAAwB,EAAE,OAAuB;IACnF,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAExC,IAAI,OAAO,CAAC,IAAI,KAAK,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,WAAW,OAAO,CAAC,IAAI,0BAA0B,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;IAC1F,CAAC;IAED,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;AACrC,CAAC"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-neutral-contracts.d.ts b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-neutral-contracts.d.ts new file mode 100644 index 000000000..310e1f01f --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-neutral-contracts.d.ts @@ -0,0 +1,106 @@ +export type BackendNeutralRuntimeBackendKind = string & {}; +export type RuntimeWordPressComponentIntentKind = "wordpress-core" | "plugin" | "mu-plugin" | "theme" | "runtime-overlay" | (string & {}); +export type RuntimeWordPressFilesystemIntentType = "directory" | "file" | (string & {}); +export type RuntimeWordPressFilesystemIntentMode = "readonly" | "readwrite" | "generated" | (string & {}); +export interface RuntimeWordPressComponentIntent { + kind: RuntimeWordPressComponentIntentKind; + slug?: string; + source?: string; + target?: string; + activate?: boolean; + capabilities?: string[]; + metadata?: Record; +} +export interface RuntimeWordPressFilesystemIntent { + type?: RuntimeWordPressFilesystemIntentType; + source?: string; + target: string; + mode?: RuntimeWordPressFilesystemIntentMode; + purpose?: string; + metadata?: Record; +} +/** + * Bytes materialized into a WordPress runtime before caller-provided Blueprint + * steps execute. Backends must reject targets outside the WordPress root. + */ +export interface RuntimeWordPressFilesystemOverlay { + target: string; + content?: string; + contentBase64?: string; + overwrite: boolean; + purpose?: string; + metadata?: Record; +} +export interface RuntimeWordPressSetupPlanIntent { + schema: "wp-codebox/wordpress-runtime-setup-plan/v1"; + backend?: BackendNeutralRuntimeBackendKind; + components?: RuntimeWordPressComponentIntent[]; + filesystem?: RuntimeWordPressFilesystemIntent[]; + filesystemOverlays?: RuntimeWordPressFilesystemOverlay[]; + metadata?: Record; +} +export interface BackendNeutralRuntimeAssetSpec { + directory?: string; + archive?: string; + metadata?: Record; +} +export interface BackendNeutralEnvironmentSpec { + kind: string; + name?: string; + version?: string; + assets?: BackendNeutralRuntimeAssetSpec; + metadata?: Record; +} +export type RuntimeWordPressInstallModeContract = "install-from-existing-files" | "install-from-existing-files-if-needed" | "do-not-attempt-installing"; +export type RuntimeWordPressDatabaseSetupContract = "runtime-managed" | "external" | "custom-drop-in"; +export type RuntimeWorkerCount = number | "auto"; +export interface RuntimeWordPressAssetSpec extends BackendNeutralRuntimeAssetSpec { + wordpressDirectory?: string; + wordpressZip?: string; +} +/** A startup-time PHP.wasm extension manifest. External extensions are JSPI-only. */ +export interface RuntimePHPWasmExtensionManifest { + manifest: string; +} +export declare const RUNTIME_PHP_WASM_BUNDLED_EXTENSIONS: readonly ["intl", "redis", "memcached", "xdebug"]; +export type RuntimePHPWasmBundledExtension = typeof RUNTIME_PHP_WASM_BUNDLED_EXTENSIONS[number]; +export interface RuntimeWordPressEnvironmentSpec extends BackendNeutralEnvironmentSpec { + blueprint?: unknown; + phpVersion?: string; + workers?: RuntimeWorkerCount; + assets?: RuntimeWordPressAssetSpec; + wordpressInstallMode?: RuntimeWordPressInstallModeContract; + databaseSetup?: RuntimeWordPressDatabaseSetupContract; + extensions?: RuntimePHPWasmExtensionManifest[]; + bundledExtensions?: RuntimePHPWasmBundledExtension[]; +} +export type BackendNeutralReplayStatus = "metadata-only" | "partial-replay" | "replayable-runtime-state" | "runtime-state-artifact" | "not-replayable" | (string & {}); +export interface BackendNeutralReplaySpec { + status: BackendNeutralReplayStatus; + environment?: BackendNeutralEnvironmentSpec; + artifactRefs?: BackendNeutralArtifactRef[]; + metadata?: Record; +} +export interface BackendNeutralArtifactRef { + path: string; + kind: string; + contentType?: string; + sha256?: string; + metadata?: Record; +} +export interface BackendNeutralRuntimeProvenance { + backend: BackendNeutralRuntimeBackendKind; + version?: string; + backendPackage?: Record; + environment?: BackendNeutralEnvironmentSpec; + metadata?: Record; +} +export interface RuntimeWordPressProvenance extends BackendNeutralRuntimeProvenance { + wordpressVersion?: string; +} +export declare function normalizeBackendNeutralEnvironmentSpec(input: unknown): BackendNeutralEnvironmentSpec; +export declare function normalizeRuntimeWordPressEnvironmentSpec(input: unknown): RuntimeWordPressEnvironmentSpec; +export declare function normalizeBackendNeutralReplaySpec(input: unknown): BackendNeutralReplaySpec; +export declare function wordpressEnvironmentToBackendNeutral(input: RuntimeWordPressEnvironmentSpec): BackendNeutralEnvironmentSpec; +export declare const normalizeEnvironmentSpec: typeof normalizeRuntimeWordPressEnvironmentSpec; +//# sourceMappingURL=runtime-neutral-contracts.d.ts.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-neutral-contracts.d.ts.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-neutral-contracts.d.ts.map new file mode 100644 index 000000000..8bf6e4ec4 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-neutral-contracts.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"runtime-neutral-contracts.d.ts","sourceRoot":"","sources":["../src/runtime-neutral-contracts.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gCAAgC,GAAG,MAAM,GAAG,EAAE,CAAA;AAE1D,MAAM,MAAM,mCAAmC,GAAG,gBAAgB,GAAG,QAAQ,GAAG,WAAW,GAAG,OAAO,GAAG,iBAAiB,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AACzI,MAAM,MAAM,oCAAoC,GAAG,WAAW,GAAG,MAAM,GAAG,CAAC,MAAM,GA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cxG;AAiCD,wBAAgB,iCAAiC,CAAC,KAAK,EAAE,OAAO,GAAG,wBAAwB,CAQ1F;AAED,wBAAgB,oCAAoC,CAAC,KAAK,EAAE,+BAA+B,GAAG,6BAA6B,CAE1H;AAED,eAAO,MAAM,wBAAwB,iDAA2C,CAAA"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-neutral-contracts.js b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-neutral-contracts.js new file mode 100644 index 000000000..c3c8d0f9a --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-neutral-contracts.js @@ -0,0 +1,141 @@ +export const RUNTIME_PHP_WASM_BUNDLED_EXTENSIONS = ["intl", "redis", "memcached", "xdebug"]; +export function normalizeBackendNeutralEnvironmentSpec(input) { + const value = requireObject(input, "Runtime environment"); + const assets = normalizeBackendNeutralAssetSpec(value.assets); + return stripUndefined({ + kind: requiredString(value.kind, "environment.kind"), + name: optionalString(value.name, "environment.name"), + version: optionalString(value.version, "environment.version"), + assets, + metadata: normalizeOptionalObject(value.metadata, "environment.metadata"), + }); +} +export function normalizeRuntimeWordPressEnvironmentSpec(input) { + const value = requireObject(input, "Runtime environment"); + const neutral = normalizeBackendNeutralEnvironmentSpec(value); + return stripUndefined({ + ...neutral, + blueprint: value.blueprint, + phpVersion: optionalString(value.phpVersion, "environment.phpVersion"), + workers: normalizeRuntimeWorkerCount(value.workers), + assets: normalizeRuntimeWordPressAssetSpec(value.assets), + wordpressInstallMode: optionalString(value.wordpressInstallMode, "environment.wordpressInstallMode"), + databaseSetup: optionalString(value.databaseSetup, "environment.databaseSetup"), + extensions: normalizeRuntimePHPWasmExtensionManifests(value.extensions), + bundledExtensions: normalizeRuntimePHPWasmBundledExtensions(value.bundledExtensions), + }); +} +function normalizeRuntimeWorkerCount(value) { + if (value === undefined) + return undefined; + if (value === "auto") + return value; + if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 1 || value > 64) { + throw new Error("environment.workers must be an integer from 1 to 64 or auto."); + } + return value; +} +function normalizeRuntimePHPWasmExtensionManifests(input) { + if (input === undefined) + return undefined; + if (!Array.isArray(input)) + throw new Error("environment.extensions must be an array."); + return input.map((entry, index) => { + const value = requireObject(entry, `environment.extensions[${index}]`); + const manifest = requiredString(value.manifest, `environment.extensions[${index}].manifest`); + if (manifest.includes("\0")) + throw new Error(`environment.extensions[${index}].manifest must not contain a null byte.`); + return { manifest }; + }); +} +function normalizeRuntimePHPWasmBundledExtensions(input) { + if (input === undefined) + return undefined; + if (!Array.isArray(input)) + throw new Error("environment.bundledExtensions must be an array."); + return input.map((extension, index) => { + if (!RUNTIME_PHP_WASM_BUNDLED_EXTENSIONS.includes(extension)) { + throw new Error(`environment.bundledExtensions[${index}] must be one of: ${RUNTIME_PHP_WASM_BUNDLED_EXTENSIONS.join(", ")}.`); + } + return extension; + }); +} +export function normalizeBackendNeutralReplaySpec(input) { + const value = requireObject(input, "Runtime replay"); + return stripUndefined({ + status: requiredString(value.status, "replay.status"), + environment: value.environment === undefined ? undefined : normalizeBackendNeutralEnvironmentSpec(value.environment), + artifactRefs: normalizeArtifactRefs(value.artifactRefs, "replay.artifactRefs"), + metadata: normalizeOptionalObject(value.metadata, "replay.metadata"), + }); +} +export function wordpressEnvironmentToBackendNeutral(input) { + return normalizeBackendNeutralEnvironmentSpec(input); +} +export const normalizeEnvironmentSpec = normalizeRuntimeWordPressEnvironmentSpec; +function normalizeRuntimeWordPressAssetSpec(input) { + const value = normalizeBackendNeutralAssetSpec(input); + if (input === undefined) + return value; + const source = requireObject(input, "environment.assets"); + return stripUndefined({ + ...value, + wordpressDirectory: optionalString(source.wordpressDirectory, "environment.assets.wordpressDirectory"), + wordpressZip: optionalString(source.wordpressZip, "environment.assets.wordpressZip"), + }); +} +function normalizeBackendNeutralAssetSpec(input) { + if (input === undefined) + return undefined; + const value = requireObject(input, "environment.assets"); + return stripUndefined({ + directory: optionalString(value.directory, "environment.assets.directory"), + archive: optionalString(value.archive, "environment.assets.archive"), + metadata: normalizeOptionalObject(value.metadata, "environment.assets.metadata"), + }); +} +function normalizeArtifactRefs(input, label) { + if (input === undefined) + return undefined; + if (!Array.isArray(input)) + throw new Error(`${label} must be an array.`); + return input.map((entry, index) => normalizeArtifactRef(entry, `${label}[${index}]`)); +} +function normalizeArtifactRef(input, label) { + const value = requireObject(input, label); + return stripUndefined({ + path: requiredString(value.path, `${label}.path`), + kind: requiredString(value.kind, `${label}.kind`), + contentType: optionalString(value.contentType, `${label}.contentType`), + sha256: optionalString(value.sha256, `${label}.sha256`), + metadata: normalizeOptionalObject(value.metadata, `${label}.metadata`), + }); +} +function normalizeOptionalObject(value, label) { + if (value === undefined) + return undefined; + return requireObject(value, label); +} +function requireObject(value, label) { + if (!value || typeof value !== "object" || Array.isArray(value)) + throw new Error(`${label} must be an object.`); + return value; +} +function requiredString(value, label) { + const normalized = optionalString(value, label); + if (!normalized) + throw new Error(`${label} must be a non-empty string.`); + return normalized; +} +function optionalString(value, label) { + if (value === undefined) + return undefined; + if (typeof value !== "string") + throw new Error(`${label} must be a string.`); + const normalized = value.trim(); + return normalized === "" ? undefined : normalized; +} +function stripUndefined(value) { + return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== undefined)); +} +//# sourceMappingURL=runtime-neutral-contracts.js.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-neutral-contracts.js.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-neutral-contracts.js.map new file mode 100644 index 000000000..b78fb1210 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-neutral-contracts.js.map @@ -0,0 +1 @@ +{"version":3,"file":"runtime-neutral-contracts.js","sourceRoot":"","sources":["../src/runtime-neutral-contracts.ts"],"names":[],"mappings":"AA2EA,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,CAAU,CAAA;AA2CpG,M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AAC,CAAC,UAAU,CAAA;AACnD,CAAC;AAED,SAAS,cAAc,CAAoC,KAAQ;IACjE,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAM,CAAA;AAClG,CAAC"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-package-profile.d.ts b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-package-profile.d.ts new file mode 100644 index 000000000..ba21df8fe --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-package-profile.d.ts @@ -0,0 +1,22 @@ +export interface RuntimePackageManifest { + schema: string; + package: string; + package_root: string; + profiles: Record; +} +export interface RuntimePackageProfile { + description?: string; + abilities: string[]; + selectors: Array<{ + type: "file" | "prefix"; + path: string; + }>; + required_files: string[]; +} +export interface RuntimePackageFileSelection { + sourcePath: string; + targetPath: string; +} +export declare function parseRuntimePackageManifest(source: string): RuntimePackageManifest; +export declare function selectRuntimePackageProfileFiles(manifest: RuntimePackageManifest, profileName: string, archivePaths: string[], manifestPath: string): RuntimePackageFileSelection[]; +//# sourceMappingURL=runtime-package-profile.d.ts.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-package-profile.d.ts.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-package-profile.d.ts.map new file mode 100644 index 000000000..d00677ad2 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-package-profile.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"runtime-package-profile.d.ts","sourceRoot":"","sources":["../src/runtime-package-profile.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAA;CAChD;AAED,MAAM,WAAW,qBAAqB;IACpC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,SAAS,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IAC3D,cAAc,EAAE,MAAM,EAAE,CAAA;CACzB;AAED,MAAM,WAAW,2BAA2B;IAC1C,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,MAAM,GAAG,sBAAsB,CAQlF;AAED,wBAAgB,gCAAgC,CAAC,QAAQ,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,YAAY,EAAE,MAAM,GAAG,2BAA2B,EAAE,CAmBnL"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-package-profile.js b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-package-profile.js new file mode 100644 index 000000000..a05e13595 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-package-profile.js @@ -0,0 +1,77 @@ +export function parseRuntimePackageManifest(source) { + let value; + try { + value = JSON.parse(source); + } + catch { + throw new Error("Runtime package manifest is not valid JSON."); + } + if (!isRecord(value) || typeof value.schema !== "string" || !/^[a-z0-9]+(?:-[a-z0-9]+)*\/runtime-package-manifest\/v1$/.test(value.schema)) + throw new Error("Runtime package manifest schema is invalid."); + if (!isSlug(value.package) || !isSlug(value.package_root) || !isRecord(value.profiles) || !Object.keys(value.profiles).length) + throw new Error("Runtime package manifest identity is invalid."); + const profiles = {}; + for (const [name, profile] of Object.entries(value.profiles)) + profiles[name] = parseProfile(name, profile); + return { schema: value.schema, package: value.package, package_root: value.package_root, profiles }; +} +export function selectRuntimePackageProfileFiles(manifest, profileName, archivePaths, manifestPath) { + if (!isSlug(profileName)) + throw new Error("Runtime package profile name is invalid."); + const profile = manifest.profiles[profileName]; + if (!profile) + throw new Error(`Runtime package profile is unavailable: ${profileName}`); + if (!isSafeFilePath(manifestPath) || !manifestPath.endsWith("/runtime-package-manifest.json")) + throw new Error("Runtime package manifest archive path is invalid."); + if (archivePaths.some((path) => !isSafeFilePath(path)) || new Set(archivePaths).size !== archivePaths.length) + throw new Error("Runtime package archive paths are invalid or duplicated."); + const archiveRoot = manifestPath.slice(0, -"runtime-package-manifest.json".length); + if (archiveRoot !== `${manifest.package_root}/`) + throw new Error("Runtime package manifest root does not match its package root."); + const selected = archivePaths + .filter((path) => path.startsWith(archiveRoot)) + .map((sourcePath) => ({ sourcePath, relativePath: sourcePath.slice(archiveRoot.length) })) + .filter(({ relativePath }) => profile.selectors.some((selector) => selector.type === "file" ? relativePath === selector.path : relativePath.startsWith(selector.path))) + .map(({ sourcePath, relativePath }) => ({ sourcePath, targetPath: `${manifest.package_root}/${relativePath}` })) + .sort((left, right) => left.targetPath.localeCompare(right.targetPath)); + if (!selected.length) + throw new Error(`Runtime package profile selected no files: ${profileName}`); + const selectedRelative = new Set(selected.map(({ targetPath }) => targetPath.slice(manifest.package_root.length + 1))); + for (const required of profile.required_files) + if (!selectedRelative.has(required)) + throw new Error(`Runtime package profile is missing required file: ${required}`); + if (new Set(selected.map(({ targetPath }) => targetPath)).size !== selected.length) + throw new Error("Runtime package profile produced duplicate target paths."); + return selected; +} +function parseProfile(name, value) { + if (!isSlug(name) || !isRecord(value) || !Array.isArray(value.abilities) || !value.abilities.length || value.abilities.some((ability) => typeof ability !== "string" || !/^[a-z0-9]+(?:-[a-z0-9]+)*\/[a-z0-9]+(?:-[a-z0-9]+)*$/.test(ability)) || new Set(value.abilities).size !== value.abilities.length) + throw new Error(`Runtime package profile abilities are invalid: ${name}`); + if (!Array.isArray(value.selectors) || !value.selectors.length) + throw new Error(`Runtime package profile selectors are invalid: ${name}`); + const selectors = value.selectors.map((selector) => { + if (!isRecord(selector) || (selector.type !== "file" && selector.type !== "prefix") || !isSafeRelativePath(selector.path) || (selector.type === "prefix") !== selector.path.endsWith("/")) + throw new Error(`Runtime package profile selector is invalid: ${name}`); + return { type: selector.type, path: selector.path }; + }); + if (new Set(selectors.map(({ type, path }) => `${type}:${path}`)).size !== selectors.length) + throw new Error(`Runtime package profile selectors are duplicated: ${name}`); + if (!Array.isArray(value.required_files) || !value.required_files.length || value.required_files.some((path) => !isSafeFilePath(path)) || new Set(value.required_files).size !== value.required_files.length) + throw new Error(`Runtime package profile required files are invalid: ${name}`); + return { ...(typeof value.description === "string" ? { description: value.description } : {}), abilities: [...value.abilities], selectors, required_files: [...value.required_files] }; +} +function isRecord(value) { + return Boolean(value) && typeof value === "object" && !Array.isArray(value); +} +function isSlug(value) { + return typeof value === "string" && /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(value); +} +function isSafeRelativePath(value) { + if (typeof value !== "string" || !value || value.length > 2_048 || value.startsWith("/") || value.includes("\\") || !/^[A-Za-z0-9._/-]+$/.test(value)) + return false; + return value.split("/").every((segment, index, segments) => (segment !== "" || index === segments.length - 1) && segment !== "." && segment !== ".."); +} +function isSafeFilePath(value) { + return isSafeRelativePath(value) && !value.endsWith("/"); +} +//# sourceMappingURL=runtime-package-profile.js.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-package-profile.js.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-package-profile.js.map new file mode 100644 index 000000000..03f4c7e14 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-package-profile.js.map @@ -0,0 +1 @@ +{"version":3,"file":"runtime-package-profile.js","sourceRoot":"","sources":["../src/runtime-package-profile.ts"],"names":[],"mappings":"AAmBA,MAAM,UAAU,2BAA2B,CAAC,MAAc;IACxD,IAAI,KAAc,C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U,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAA;IACnK,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC,OAAO,KAAK,EAAE,IAAI,KAAK,KAAK,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,OAAO,KAAK,GAAG,IAAI,OAAO,KAAK,IAAI,CAAC,CAAA;AACvJ,CAAC;AAED,SAAS,cAAc,CAAC,KAAc;IACpC,OAAO,kBAAkB,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;AAC1D,CAAC"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-policy.d.ts b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-policy.d.ts new file mode 100644 index 000000000..e3f109231 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-policy.d.ts @@ -0,0 +1,52 @@ +export interface RuntimePolicy { + network: "allow" | "deny" | { + allowHosts: string[]; + }; + filesystem: "sandbox" | "readonly-mounts" | "readwrite-mounts"; + commands: string[]; + secrets: "none" | "connector-scoped"; + approvals: "never" | "on-write" | "on-command"; +} +export type RuntimePolicyField = keyof RuntimePolicy; +export type RuntimePolicyValidationIssueCode = "invalid-network" | "invalid-filesystem" | "invalid-command" | "invalid-secrets" | "invalid-approvals"; +export interface RuntimePolicyValidationIssue { + code: RuntimePolicyValidationIssueCode; + field: RuntimePolicyField; + message: string; +} +export interface RuntimePolicyValidationResult { + valid: boolean; + issues: RuntimePolicyValidationIssue[]; +} +export interface RuntimeCommandPolicyViolationDetails { + code: "runtime-command-disallowed"; + command: string; + allowedCommands: string[]; + policy: RuntimePolicy; +} +export declare class RuntimePolicyValidationError extends Error { + readonly issues: RuntimePolicyValidationIssue[]; + readonly code: "runtime-policy-invalid"; + constructor(issues: RuntimePolicyValidationIssue[]); + toJSON(): { + code: "runtime-policy-invalid"; + issues: RuntimePolicyValidationIssue[]; + message: string; + name: string; + }; +} +export declare class RuntimeCommandPolicyViolationError extends Error { + readonly code: "runtime-command-disallowed"; + readonly command: string; + readonly allowedCommands: string[]; + readonly policy: RuntimePolicy; + constructor(command: string, policy: RuntimePolicy); + toJSON(): RuntimeCommandPolicyViolationDetails & { + message: string; + name: string; + }; +} +export declare function validateRuntimePolicy(policy: unknown): RuntimePolicyValidationResult; +export declare function assertRuntimePolicy(policy: unknown): asserts policy is RuntimePolicy; +export declare function assertRuntimeCommandAllowed(command: string, policy: RuntimePolicy): void; +//# sourceMappingURL=runtime-policy.d.ts.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-policy.d.ts.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-policy.d.ts.map new file mode 100644 index 000000000..49705be65 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-policy.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"runtime-policy.d.ts","sourceRoot":"","sources":["../src/runtime-policy.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG;QAAE,UAAU,EAAE,MAAM,EAAE,CAAA;KAAE,CAAA;IACpD,UAAU,EAAE,SAAS,GAAG,iBAAiB,GAAG,kBAAkB,CAAA;IAC9D,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,OAAO,EAAE,MAAM,GAAG,kBAAkB,CAAA;IACpC,SAAS,EAAE,OAAO,GAAG,UAAU,GAAG,YAAY,CAAA;CAC/C;AAED,MAAM,MAAM,kBAAkB,GAAG,MAAM,aAAa,CAAA;AAEpD,MAAM,MAAM,gCAAgC,GACxC,iBAAiB,GACjB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AmB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,IAAI,aAAa,CAMpF;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CAIxF"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-policy.js b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-policy.js new file mode 100644 index 000000000..4ad93980c --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-policy.js @@ -0,0 +1,109 @@ +export class RuntimePolicyValidationError extends Error { + issues; + code = "runtime-policy-invalid"; + constructor(issues) { + super(`Runtime policy is invalid: ${issues.map((issue) => issue.message).join("; ")}`); + this.issues = issues; + this.name = "RuntimePolicyValidationError"; + } + toJSON() { + return { + code: this.code, + issues: this.issues, + message: this.message, + name: this.name, + }; + } +} +export class RuntimeCommandPolicyViolationError extends Error { + code = "runtime-command-disallowed"; + command; + allowedCommands; + policy; + constructor(command, policy) { + super(`Command is not allowed by runtime policy: ${command}`); + this.name = "RuntimeCommandPolicyViolationError"; + this.command = command; + this.allowedCommands = [...policy.commands]; + this.policy = policy; + } + toJSON() { + return { + code: this.code, + command: this.command, + allowedCommands: this.allowedCommands, + policy: this.policy, + message: this.message, + name: this.name, + }; + } +} +export function validateRuntimePolicy(policy) { + const issues = []; + const candidate = policy; + if (!candidate || typeof candidate !== "object") { + return { + valid: false, + issues: [ + { code: "invalid-network", field: "network", message: "policy must be an object with v0 policy fields" }, + { code: "invalid-filesystem", field: "filesystem", message: "policy must be an object with v0 policy fields" }, + { code: "invalid-command", field: "commands", message: "policy must be an object with v0 policy fields" }, + { code: "invalid-secrets", field: "secrets", message: "policy must be an object with v0 policy fields" }, + { code: "invalid-approvals", field: "approvals", message: "policy must be an object with v0 policy fields" }, + ], + }; + } + if (candidate.network !== "allow" && + candidate.network !== "deny" && + (!candidate.network || + typeof candidate.network !== "object" || + !Array.isArray(candidate.network.allowHosts) || + !candidate.network.allowHosts.every((host) => typeof host === "string" && host.length > 0))) { + issues.push({ + code: "invalid-network", + field: "network", + message: "network must be allow, deny, or an allowHosts list", + }); + } + if (!["sandbox", "readonly-mounts", "readwrite-mounts"].includes(candidate.filesystem ?? "")) { + issues.push({ + code: "invalid-filesystem", + field: "filesystem", + message: "filesystem must be sandbox, readonly-mounts, or readwrite-mounts", + }); + } + if (!Array.isArray(candidate.commands) || !candidate.commands.every((command) => typeof command === "string" && command.length > 0)) { + issues.push({ + code: "invalid-command", + field: "commands", + message: "commands must be a list of non-empty command names", + }); + } + if (!["none", "connector-scoped"].includes(candidate.secrets ?? "")) { + issues.push({ + code: "invalid-secrets", + field: "secrets", + message: "secrets must be none or connector-scoped", + }); + } + if (!["never", "on-write", "on-command"].includes(candidate.approvals ?? "")) { + issues.push({ + code: "invalid-approvals", + field: "approvals", + message: "approvals must be never, on-write, or on-command", + }); + } + return { valid: issues.length === 0, issues }; +} +export function assertRuntimePolicy(policy) { + const result = validateRuntimePolicy(policy); + if (!result.valid) { + throw new RuntimePolicyValidationError(result.issues); + } +} +export function assertRuntimeCommandAllowed(command, policy) { + if (!policy.commands.includes(command)) { + throw new RuntimeCommandPolicyViolationError(command, policy); + } +} +//# sourceMappingURL=runtime-policy.js.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-policy.js.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-policy.js.map new file mode 100644 index 000000000..50b79030b --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-policy.js.map @@ -0,0 +1 @@ +{"version":3,"file":"runtime-policy.js","sourceRoot":"","sources":["../src/runtime-policy.ts"],"names":[],"mappings":"AAmCA,MAAM,OAAO,4BAA6B,SAAQ,KAAK;IAGhC;IAFZ,IAAI,GAAG,wBAAiC,CAAA;IAEjD,YAAqB,MAAsC;QACzD,KAAK,CAAC,8BAA8B,MAAM,CAAC,GAAG,CAAC,CA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CAAC,KAAK,EAAE,CAAC;QAClB,MAAM,IAAI,4BAA4B,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IACvD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,OAAe,EAAE,MAAqB;IAChF,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,kCAAkC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IAC/D,CAAC;AACH,CAAC"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-reference.d.ts b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-reference.d.ts new file mode 100644 index 000000000..fa1243c1d --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-reference.d.ts @@ -0,0 +1,110 @@ +import type { ArtifactFileDigest, ArtifactViewerMetadata } from "./artifact-manifest.js"; +import type { RuntimeEpisodeContentDigest, RuntimeEpisodeTrace, RuntimeEpisodeTraceRef, RuntimeInfo, Snapshot } from "./runtime-contracts.js"; +export declare const RUNTIME_REFERENCE_MANIFEST_SCHEMA: "wp-codebox/runtime-reference-manifest/v1"; +export declare const RUNTIME_REPLAY_REFERENCE_INDEX_SCHEMA: "wp-codebox/runtime-replay-reference-index/v1"; +export type RuntimeSnapshotReplayStatus = "metadata-only" | "partial-replay" | "replayable-runtime-state" | "runtime-state-artifact" | "not-replayable" | (string & {}); +export interface RuntimeReferenceManifestFileRef { + path: string; + kind: string; + contentType: string; + sha256: ArtifactFileDigest; + viewer?: ArtifactViewerMetadata; +} +export interface RuntimeReferenceManifestArtifactBundleRef { + kind: "artifact-bundle"; + id: string; + digest: ArtifactFileDigest; +} +export interface RuntimeReferenceManifestSnapshotRef { + id: string; + semantics: string; + digest: RuntimeEpisodeContentDigest; + replay: { + status: RuntimeSnapshotReplayStatus; + limitations: string[]; + }; + artifactRefs: RuntimeEpisodeTraceRef[]; +} +export interface RuntimeReferenceManifest { + schema: typeof RUNTIME_REFERENCE_MANIFEST_SCHEMA; + version: 1; + id: string; + createdAt: string; + digest: RuntimeEpisodeContentDigest; + runtime: RuntimeInfo; + artifactBundle: RuntimeReferenceManifestArtifactBundleRef; + files: RuntimeReferenceManifestFileRef[]; + trace?: RuntimeReferenceManifestFileRef; + events?: RuntimeReferenceManifestFileRef; + snapshots: RuntimeReferenceManifestSnapshotRef[]; +} +export interface RuntimeReplayReferenceIndexActionRef { + index: number; + id: string; + actionRef: RuntimeEpisodeTraceRef; + executionRef: RuntimeEpisodeTraceRef; + observationRef?: RuntimeEpisodeTraceRef; +} +export interface RuntimeReplayReferenceIndexObservationRef { + id: string; + type: string; + ref: RuntimeEpisodeTraceRef; + artifactRefs: RuntimeEpisodeTraceRef[]; +} +export interface RuntimeReplayReferenceIndex { + schema: typeof RUNTIME_REPLAY_REFERENCE_INDEX_SCHEMA; + version: 1; + id: string; + createdAt: string; + digest: RuntimeEpisodeContentDigest; + runtime: RuntimeInfo; + artifactBundle: RuntimeReferenceManifestArtifactBundleRef; + references: { + trace?: RuntimeReferenceManifestFileRef; + events?: RuntimeReferenceManifestFileRef; + runtimeReferenceManifest?: RuntimeReferenceManifestFileRef; + observations?: RuntimeReferenceManifestFileRef; + commands?: RuntimeReferenceManifestFileRef; + runtimeEvents?: RuntimeReferenceManifestFileRef; + blueprintAfter?: RuntimeReferenceManifestFileRef; + blueprintAfterNotes?: RuntimeReferenceManifestFileRef; + mountedFiles?: RuntimeReferenceManifestFileRef; + mountDiffs?: RuntimeReferenceManifestFileRef; + changedFiles?: RuntimeReferenceManifestFileRef; + patch?: RuntimeReferenceManifestFileRef; + testResults?: RuntimeReferenceManifestFileRef; + }; + actions: RuntimeReplayReferenceIndexActionRef[]; + observations: RuntimeReplayReferenceIndexObservationRef[]; + snapshots: RuntimeReferenceManifestSnapshotRef[]; + replay: { + status: "partial" | "runtime-state-artifact" | "metadata-only"; + instructions: string[]; + limitations: string[]; + }; +} +export interface BuildRuntimeReferenceManifestInput { + createdAt: string; + runtime: RuntimeInfo; + artifactBundle: RuntimeReferenceManifestArtifactBundleRef; + files: RuntimeReferenceManifestFileRef[]; + trace?: RuntimeReferenceManifestFileRef; + events?: RuntimeReferenceManifestFileRef; + snapshots?: Snapshot[]; +} +export interface BuildRuntimeReplayReferenceIndexInput { + createdAt: string; + runtime: RuntimeInfo; + artifactBundle: RuntimeReferenceManifestArtifactBundleRef; + files: RuntimeReferenceManifestFileRef[]; + trace?: RuntimeReferenceManifestFileRef; + events?: RuntimeReferenceManifestFileRef; + runtimeReferenceManifest?: RuntimeReferenceManifestFileRef; + snapshots?: Snapshot[]; + episodeTrace?: RuntimeEpisodeTrace; +} +export declare function buildRuntimeReferenceManifest(input: BuildRuntimeReferenceManifestInput): RuntimeReferenceManifest; +export declare function runtimeReferenceManifestDigest(manifest: RuntimeReferenceManifest): RuntimeEpisodeContentDigest; +export declare function buildRuntimeReplayReferenceIndex(input: BuildRuntimeReplayReferenceIndexInput): RuntimeReplayReferenceIndex; +export declare function runtimeReplayReferenceIndexDigest(index: RuntimeReplayReferenceIndex): RuntimeEpisodeContentDigest; +//# sourceMappingURL=runtime-reference.d.ts.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-reference.d.ts.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-reference.d.ts.map new file mode 100644 index 000000000..9fb46ad14 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-reference.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"runtime-reference.d.ts","sourceRoot":"","sources":["../src/runtime-reference.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AASxF,OAAO,KAAK,EAEV,2BAA2B,EAC3B,mBAAmB,EACnB,sBAAsB,EACtB,WAAW,EACX,QAAQ,EACT,MAAM,wBAAwB,CAAA;AAE/B,eAA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AAE,CAAA;IAChD,MAAM,EAAE;QACN,MAAM,EAAE,SAAS,GAAG,wBAAwB,GAAG,eAAe,CAAA;QAC9D,YAAY,EAAE,MAAM,EAAE,CAAA;QACtB,WAAW,EAAE,MAAM,EAAE,CAAA;KACtB,CAAA;CACF;AAED,MAAM,WAAW,kCAAkC;IACjD,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,WAAW,CAAA;IACpB,cAAc,EAAE,yCAAyC,CAAA;IACzD,KAAK,EAAE,+BAA+B,EAAE,CAAA;IACxC,KAAK,CAAC,EAAE,+BAA+B,CAAA;IACvC,MAAM,CAAC,EAAE,+BAA+B,CAAA;IACxC,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAA;CACvB;AAED,MAAM,WAAW,qCAAqC;IACpD,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,WAAW,CAAA;IACpB,cAAc,EAAE,yCAAyC,CAAA;IACzD,KAAK,EAAE,+BAA+B,EAAE,CAAA;IACxC,KAAK,CAAC,EAAE,+BAA+B,CAAA;IACvC,MAAM,CAAC,EAAE,+BAA+B,CAAA;IACxC,wBAAwB,CAAC,EAAE,+BAA+B,CAAA;IAC1D,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAA;IACtB,YAAY,CAAC,EAAE,mBAAmB,CAAA;CACnC;AAED,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,kCAAkC,GAAG,wBAAwB,CAqBjH;AAED,wBAAgB,8BAA8B,CAAC,QAAQ,EAAE,wBAAwB,GAAG,2BAA2B,CAQ9G;AAED,wBAAgB,gCAAgC,CAAC,KAAK,EAAE,qCAAqC,GAAG,2BAA2B,CAuC1H;AAED,wBAAgB,iCAAiC,CAAC,KAAK,EAAE,2BAA2B,GAAG,2BAA2B,CAQjH"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-reference.js b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-reference.js new file mode 100644 index 000000000..fdd5df450 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-reference.js @@ -0,0 +1,229 @@ +import { createHash } from "node:crypto"; +import { RUNTIME_EPISODE_EVENTS_ARTIFACT_PATH, RUNTIME_EPISODE_TRACE_ARTIFACT_PATH, RUNTIME_REFERENCE_MANIFEST_ARTIFACT_PATH, normalizeObservationArtifactRefs, normalizeRuntimeReferenceManifestFileRef, } from "./artifact-references.js"; +import { stableJson } from "./object-utils.js"; +export const RUNTIME_REFERENCE_MANIFEST_SCHEMA = "wp-codebox/runtime-reference-manifest/v1"; +export const RUNTIME_REPLAY_REFERENCE_INDEX_SCHEMA = "wp-codebox/runtime-replay-reference-index/v1"; +export function buildRuntimeReferenceManifest(input) { + const manifest = { + schema: RUNTIME_REFERENCE_MANIFEST_SCHEMA, + version: 1, + id: "runtime-reference-manifest-pending", + createdAt: input.createdAt, + digest: { algorithm: "sha256", value: "0".repeat(64) }, + runtime: input.runtime, + artifactBundle: input.artifactBundle, + files: input.files.map(runtimeReferenceManifestFileRef).sort((left, right) => left.path.localeCompare(right.path)), + ...(input.trace ? { trace: runtimeReferenceManifestFileRef(input.trace) } : {}), + ...(input.events ? { events: runtimeReferenceManifestFileRef(input.events) } : {}), + snapshots: (input.snapshots ?? []).map(runtimeReferenceManifestSnapshotRef), + }; + const digest = runtimeReferenceManifestDigest(manifest); + return { + ...manifest, + id: `runtime-reference-manifest-sha256-${digest.value}`, + digest, + }; +} +export function runtimeReferenceManifestDigest(manifest) { + return { + algorithm: "sha256", + value: createHash("sha256") + .update("wp-codebox/runtime-reference-manifest/v1\n") + .update(stableJson(runtimeReferenceManifestDigestPayload(manifest))) + .digest("hex"), + }; +} +export function buildRuntimeReplayReferenceIndex(input) { + const filesByPath = new Map(input.files.map((file) => [file.path, runtimeReferenceManifestFileRef(file)])); + const references = compactUndefined({ + trace: input.trace ? runtimeReferenceManifestFileRef(input.trace) : filesByPath.get(RUNTIME_EPISODE_TRACE_ARTIFACT_PATH), + events: input.events ? runtimeReferenceManifestFileRef(input.events) : filesByPath.get(RUNTIME_EPISODE_EVENTS_ARTIFACT_PATH), + runtimeReferenceManifest: input.runtimeReferenceManifest ? runtimeReferenceManifestFileRef(input.runtimeReferenceManifest) : filesByPath.get(RUNTIME_REFERENCE_MANIFEST_ARTIFACT_PATH), + observations: filesByPath.get("observations.jsonl"), + commands: filesByPath.get("commands.jsonl"), + runtimeEvents: filesByPath.get("events.jsonl"), + blueprintAfter: filesByPath.get("blueprint.after.json"), + blueprintAfterNotes: filesByPath.get("blueprint.after-notes.json"), + mountedFiles: filesByPath.get("files/mounted-files.json"), + mountDiffs: filesByPath.get("files/diffs.json"), + changedFiles: filesByPath.get("files/changed-files.json"), + patch: filesByPath.get("files/patch.diff"), + testResults: filesByPath.get("files/test-results.json"), + }); + const snapshots = (input.snapshots ?? []).map(runtimeReferenceManifestSnapshotRef); + const index = { + schema: RUNTIME_REPLAY_REFERENCE_INDEX_SCHEMA, + version: 1, + id: "runtime-replay-reference-index-pending", + createdAt: input.createdAt, + digest: { algorithm: "sha256", value: "0".repeat(64) }, + runtime: input.runtime, + artifactBundle: input.artifactBundle, + references, + actions: runtimeReplayActionRefs(input.episodeTrace), + observations: runtimeReplayObservationRefs(input.episodeTrace), + snapshots, + replay: runtimeReplayInstructions(references, snapshots), + }; + const digest = runtimeReplayReferenceIndexDigest(index); + return { + ...index, + id: `runtime-replay-reference-index-sha256-${digest.value}`, + digest, + }; +} +export function runtimeReplayReferenceIndexDigest(index) { + return { + algorithm: "sha256", + value: createHash("sha256") + .update("wp-codebox/runtime-replay-reference-index/v1\n") + .update(stableJson(runtimeReplayReferenceIndexDigestPayload(index))) + .digest("hex"), + }; +} +function runtimeReplayReferenceIndexDigestPayload(index) { + return { + schema: index.schema, + version: index.version, + runtime: index.runtime, + artifactBundle: index.artifactBundle, + references: index.references, + actions: index.actions, + observations: index.observations, + snapshots: index.snapshots, + replay: index.replay, + }; +} +function runtimeReplayActionRefs(trace) { + return (trace?.steps ?? []).map((step) => compactUndefined({ + index: step.index, + id: step.id, + actionRef: step.actionRef, + executionRef: step.executionRef, + observationRef: step.observationRef, + })); +} +function runtimeReplayObservationRefs(trace) { + const observations = [ + ...(trace?.reset.observations ?? []), + ...(trace?.steps.flatMap((step) => step.observation ? [step.observation] : []) ?? []), + ]; + return observations.map((observation, index) => ({ + id: observation.id ?? `observation:${index}`, + type: observation.type, + ref: observationRef(observation, observation.id ?? `observation:${index}`), + artifactRefs: normalizeObservationArtifactRefs(observation), + })); +} +function runtimeReplayInstructions(references, snapshots) { + const limitations = [...new Set(snapshots.flatMap((snapshot) => snapshot.replay.limitations))]; + if (snapshots.some((snapshot) => snapshot.replay.status === "runtime-state-artifact")) { + return { + status: "runtime-state-artifact", + instructions: [ + "Use references.runtimeReferenceManifest for hashed runtime files and snapshot artifact refs.", + "Use references.trace and references.events to replay recorded actions and lifecycle events.", + ], + limitations, + }; + } + return { + status: snapshots.length > 0 ? "metadata-only" : "partial", + instructions: [ + "Use references.trace for ordered runtime actions and execution records.", + "Use references.observations plus observation artifact refs for captured runtime observations.", + "Use references.blueprintAfter, references.mountedFiles, references.changedFiles, and references.patch for filesystem and mount-state evidence.", + "Use references.runtimeReferenceManifest for snapshot metadata and replay limitations.", + ], + limitations: limitations.length > 0 ? limitations : [ + "This index points to replay evidence; it is not a complete WordPress database or filesystem checkpoint.", + ], + }; +} +function runtimeReferenceManifestDigestPayload(manifest) { + return { + schema: manifest.schema, + version: manifest.version, + runtime: manifest.runtime, + artifactBundle: manifest.artifactBundle, + files: manifest.files, + ...(manifest.trace ? { trace: manifest.trace } : {}), + ...(manifest.events ? { events: manifest.events } : {}), + snapshots: manifest.snapshots, + }; +} +function runtimeReferenceManifestFileRef(file) { + return normalizeRuntimeReferenceManifestFileRef(file) ?? file; +} +function runtimeReferenceManifestSnapshotRef(snapshot) { + const semantics = snapshot.semantics ?? "metadata-only"; + return { + id: snapshot.id, + semantics, + digest: snapshot.digest ?? runtimeEpisodeDigest(runtimeEpisodeSnapshotDigestPayload({ ...snapshot, semantics })), + replay: runtimeSnapshotReplaySemantics(semantics), + artifactRefs: normalizeObservationArtifactRefs(snapshot), + }; +} +function runtimeSnapshotReplaySemantics(semantics) { + if (semantics === "replayable-runtime-state") { + return { status: "replayable-runtime-state", limitations: [] }; + } + if (semantics === "runtime-state-artifact") { + return { status: "runtime-state-artifact", limitations: [] }; + } + if (semantics === "partial-replay") { + return { + status: "partial-replay", + limitations: [ + "Snapshot bundle contains replay instructions and artifact references, but not a complete WordPress database checkpoint.", + "Replay consumers can restore mounted files and inspect runtime evidence; posts, options, terms, users, uploads, active theme/plugins, and browser/editor state may require external capture.", + ], + }; + } + if (semantics === "metadata-only") { + return { + status: "metadata-only", + limitations: [ + "Snapshot records runtime metadata only; it is not a WordPress database or filesystem checkpoint.", + "Replay consumers must use trace actions and artifact bundle files to reconstruct supported state.", + ], + }; + } + return { + status: "not-replayable", + limitations: [`Snapshot semantics are not recognized by this WP Codebox version: ${semantics}`], + }; +} +function observationRef(observation, fallbackId) { + return { kind: "observation", id: observation.id || fallbackId, digest: observation.digest ?? runtimeEpisodeDigest(runtimeEpisodeObservationDigestPayload(observation)) }; +} +function runtimeEpisodeDigest(value) { + return { + algorithm: "sha256", + value: createHash("sha256").update("wp-codebox/runtime-episode-trace/v1\n").update(stableJson(value)).digest("hex"), + }; +} +function runtimeEpisodeObservationDigestPayload(observation) { + return { + schema: "wp-codebox/runtime-episode-observation/v1", + type: observation.type, + data: observation.data, + observedAt: observation.observedAt, + artifactRefs: observation.artifactRefs ?? [], + }; +} +function runtimeEpisodeSnapshotDigestPayload(snapshot) { + return { + schema: "wp-codebox/runtime-episode-snapshot/v1", + id: snapshot.id, + createdAt: snapshot.createdAt, + semantics: snapshot.semantics, + metadata: snapshot.metadata, + artifactRefs: snapshot.artifactRefs ?? [], + }; +} +function compactUndefined(value) { + return Object.fromEntries(Object.entries(value).filter(([, item]) => item !== undefined)); +} +//# sourceMappingURL=runtime-reference.js.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-reference.js.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-reference.js.map new file mode 100644 index 000000000..b01f2195b --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/runtime-reference.js.map @@ -0,0 +1 @@ +{"version":3,"file":"runtime-reference.js","sourceRoot":"","sources":["../src/runtime-reference.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAGxC,OAAO,EACL,oCAAoC,EACpC,mCAAmC,EACnC,wCAAwC,EACxC,gCAAgC,EAChC,wCAAwC,GACzC,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAU9C,MAAM,CAAC,MAAM,iCAAiC,GAAG,0CAAmD,CAAA;AACpG,MAAM,CAAC,MAAM,qCAAqC,GAAG,8CAAuD,CAAA;AAiH5G,MAAM,UAAU,6BAA6B,CAAC,KAAyC;IACrF,MAAM,QAAQ,GAAG;QACf,MAAM,EAAE,iCAAiC;QACzC,OAAO,EAAE,CAAU;QACnB,EAAE,EAAE,oCAAoC;QACxC,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,MAAM,EAAE,EAAE,SAAS,EAAE,QAAiB,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE;QAC/D,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAClH,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,+BAA+B,CAAC,KAAK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oBAAoB,CAAC,KAAc;IAC1C,OAAO;QACL,SAAS,EAAE,QAAQ;QACnB,KAAK,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,uCAAuC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;KACpH,CAAA;AACH,CAAC;AAED,SAAS,sCAAsC,CAAC,WAA8B;IAC5E,OAAO;QACL,MAAM,EAAE,2CAA2C;QACnD,IAAI,EAAE,WAAW,CAAC,IAAI;QACtB,IAAI,EAAE,WAAW,CAAC,IAAI;QACtB,UAAU,EAAE,WAAW,CAAC,UAAU;QAClC,YAAY,EAAE,WAAW,CAAC,YAAY,IAAI,EAAE;KAC7C,CAAA;AACH,CAAC;AAED,SAAS,mCAAmC,CAAC,QAAkB;IAC7D,OAAO;QACL,MAAM,EAAE,wCAAwC;QAChD,EAAE,EAAE,QAAQ,CAAC,EAAE;QACf,SAAS,EAAE,QAAQ,CAAC,SAAS;QAC7B,SAAS,EAAE,QAAQ,CAAC,SAAS;QAC7B,QAAQ,EAAE,QAAQ,CAAC,QAAQ;QAC3B,YAAY,EAAE,QAAQ,CAAC,YAAY,IAAI,EAAE;KAC1C,CAAA;AACH,CAAC;AAED,SAAS,gBAAgB,CAAmB,KAAQ;IAClD,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,CAAM,CAAA;AAChG,CAAC"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/transport-faults.d.ts b/packages/runtime-cloudflare/vendor/wp-codebox-core/transport-faults.d.ts new file mode 100644 index 000000000..55c47b9ba --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/transport-faults.d.ts @@ -0,0 +1,147 @@ +export declare const TRANSPORT_FAULT_MODEL_SCHEMA: "wp-codebox/transport-fault-model/v1"; +export declare const TRANSPORT_FAULT_CAPABILITIES_SCHEMA: "wp-codebox/transport-fault-capabilities/v1"; +export declare const TRANSPORT_FAULT_EVIDENCE_SCHEMA: "wp-codebox/transport-fault-evidence/v1"; +export declare const TRANSPORT_FAULT_SAFE_SCHEDULE_SCHEMA: "wp-codebox/transport-fault-safe-schedule/v1"; +export type TransportFaultSemantic = "response-substitution" | "malformed-response" | "truncated-response" | "chunked-response" | "delay" | "jitter" | "bandwidth" | "timeout" | "connection-refusal" | "connection-reset" | "half-close" | "disconnect-after-bytes" | "host-remap" | "request-corruption" | "response-corruption"; +export type TransportFaultFidelity = "exact" | "emulated" | "unsupported"; +export interface TransportRequestMatcher { + host?: string; + method?: string; + path?: string; + pathPattern?: string; + headers?: Record; +} +export interface TransportFaultOutcome { + passthrough?: true; + status?: number; + headers?: Record; + body?: string; + bodyBase64?: string; + malformed?: boolean; + truncateAfterBytes?: number; + chunkBytes?: number; + delayMs?: number; + jitterMs?: number; + bandwidthBytesPerSecond?: number; + timeoutMs?: number; + connection?: "refuse" | "reset" | "half-close"; + disconnectAfterBytes?: number; + remapHost?: string; + requestCorruption?: "truncate" | "flip-byte" | "invalid-encoding"; + responseCorruption?: "flip-byte" | "invalid-encoding"; + metadata?: Record; +} +export interface TransportFaultRule { + id: string; + match: TransportRequestMatcher; + sequence: TransportFaultOutcome[]; + repeat?: "last" | "cycle" | "none"; + metadata?: Record; +} +export interface TransportFaultModel { + schema: typeof TRANSPORT_FAULT_MODEL_SCHEMA; + seed: string; + rules: TransportFaultRule[]; + redactHeaders?: string[]; + metadata?: Record; +} +export interface TransportFaultCapability { + semantic: TransportFaultSemantic; + fidelity: TransportFaultFidelity; + reason?: string; +} +export interface TransportFaultCapabilities { + schema: typeof TRANSPORT_FAULT_CAPABILITIES_SCHEMA; + adapter: string; + capabilities: TransportFaultCapability[]; +} +export interface TransportFaultNegotiation { + supported: boolean; + required: TransportFaultSemantic[]; + unsupported: TransportFaultCapability[]; + capabilities: TransportFaultCapabilities; +} +export interface TransportFaultRequest { + url: string; + method: string; + headers?: Record; + body?: Uint8Array | string; +} +export interface TransportFaultDecision { + ruleId: string; + sequenceIndex: number; + invocation: number; + outcome: TransportFaultOutcome; + semantics: TransportFaultSemantic[]; + delayMs: number; +} +export interface TransportFaultEvidence { + schema: typeof TRANSPORT_FAULT_EVIDENCE_SCHEMA; + fingerprint: string; + adapter: string; + fidelity: TransportFaultCapability[]; + request: { + url: string; + method: string; + headers: Record; + bodyBytes?: number; + }; + fault?: { + ruleId: string; + sequenceIndex: number; + invocation: number; + semantics: TransportFaultSemantic[]; + delayMs: number; + }; + response?: { + status?: number; + headers?: Record; + bodyBytes?: number; + connection?: string; + }; +} +export interface TransportFaultSafeSchedule { + schema: typeof TRANSPORT_FAULT_SAFE_SCHEDULE_SCHEMA; + seed: string; + structuralFingerprint: string; + rules: Array<{ + id: string; + match: Omit & { + headerNames?: string[]; + }; + sequence: Array & { + headerNames?: string[]; + body?: { + encoding: "utf8" | "base64"; + bytes: number; + redacted: true; + }; + metadataRedacted?: true; + }>; + repeat?: TransportFaultRule["repeat"]; + metadataRedacted?: true; + }>; + redactHeaders?: string[]; + metadataRedacted?: true; +} +export declare class TransportFaultEngine { + #private; + readonly model: TransportFaultModel; + readonly capabilities: TransportFaultCapabilities; + readonly evidence: TransportFaultEvidence[]; + constructor(model: TransportFaultModel, capabilities: TransportFaultCapabilities); + decide(request: TransportFaultRequest): TransportFaultDecision | undefined; + record(request: TransportFaultRequest, decision: TransportFaultDecision | undefined, response?: TransportFaultEvidence["response"]): TransportFaultEvidence; +} +export declare function transportFaultModel(input: Omit & { + schema?: string; +}): TransportFaultModel; +export declare function transportFaultCapabilities(adapter: string, capabilities: readonly TransportFaultCapability[]): TransportFaultCapabilities; +export declare function transportFaultSafeSchedule(modelInput: TransportFaultModel): TransportFaultSafeSchedule; +export declare function negotiateTransportFaults(model: TransportFaultModel, capabilities: TransportFaultCapabilities): TransportFaultNegotiation; +export declare function transportRequestMatches(matcher: TransportRequestMatcher, request: TransportFaultRequest): boolean; +export declare function transportFaultOutcomeSemantics(outcome: TransportFaultOutcome): TransportFaultSemantic[]; +export declare function transportFaultFingerprint(value: unknown): string; +export declare function redactTransportHeaders(headers: Record, extra?: readonly string[]): Record; +export declare function redactTransportUrl(raw: string): string; +//# sourceMappingURL=transport-faults.d.ts.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/transport-faults.d.ts.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/transport-faults.d.ts.map new file mode 100644 index 000000000..65d48d502 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/transport-faults.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"transport-faults.d.ts","sourceRoot":"","sources":["../src/transport-faults.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,4BAA4B,EAAG,qCAA8C,CAAA;AAC1F,eAAO,MAAM,mCAAmC,EAAG,4CAAqD,CAAA;AACxG,eAAO,MAAM,+BAA+B,EAAG,wCAAiD,CAAA;AAChG,eAAO,MAAM,oCAAoC,EAAG,6CAAsD,CAAA;AAE1G,MAAM,MAAM,sBAAsB,GAC9B,uBAAuB,GACvB,oBAAoB,GACpB,oBAAoB,GACpB,kBAAkB,GAClB,OAAO,GACP,QAAQ,GACR,WAAW,GACX,SAAS,GACT,oBAAoB,GACpB,kBAAkB,GAClB,YAAY,GACZ,wBAAwB,GACxB,YAAY,GACZ,oBAAoB,GACpB,qBAAqB,CAAA;AAEzB,MAAM,MAAM,sBAAsB,GAAG,OAAO,GAAG,UAAU,GAAG,aAAa,CAAA;AAEzE,MAAM,WAAW,uBAAuB;IACtC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,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EAAE,OAAO,GAAG,MAAM,CAEhE;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK,GAAE,SAAS,MAAM,EAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAG7H;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAYtD"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/transport-faults.js b/packages/runtime-cloudflare/vendor/wp-codebox-core/transport-faults.js new file mode 100644 index 000000000..879bdc559 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/transport-faults.js @@ -0,0 +1,239 @@ +import { createHash } from "node:crypto"; +import { stableJson, stripUndefined } from "./object-utils.js"; +export const TRANSPORT_FAULT_MODEL_SCHEMA = "wp-codebox/transport-fault-model/v1"; +export const TRANSPORT_FAULT_CAPABILITIES_SCHEMA = "wp-codebox/transport-fault-capabilities/v1"; +export const TRANSPORT_FAULT_EVIDENCE_SCHEMA = "wp-codebox/transport-fault-evidence/v1"; +export const TRANSPORT_FAULT_SAFE_SCHEDULE_SCHEMA = "wp-codebox/transport-fault-safe-schedule/v1"; +export class TransportFaultEngine { + model; + capabilities; + evidence = []; + #counts = new Map(); + constructor(model, capabilities) { + this.model = transportFaultModel(model); + this.capabilities = capabilities; + } + decide(request) { + const rule = this.model.rules.find((candidate) => transportRequestMatches(candidate.match, request)); + if (!rule) + return undefined; + const invocation = this.#counts.get(rule.id) ?? 0; + this.#counts.set(rule.id, invocation + 1); + const sequenceIndex = faultSequenceIndex(rule, invocation); + if (sequenceIndex === undefined) + return undefined; + const outcome = rule.sequence[sequenceIndex]; + const jitter = outcome.jitterMs ? deterministicRange(`${this.model.seed}:${rule.id}:${invocation}`, outcome.jitterMs) : 0; + return { + ruleId: rule.id, + sequenceIndex, + invocation, + outcome, + semantics: transportFaultOutcomeSemantics(outcome), + delayMs: Math.max(0, (outcome.delayMs ?? 0) + jitter), + }; + } + record(request, decision, response) { + const fidelity = decision + ? decision.semantics.map((semantic) => this.capabilities.capabilities.find((item) => item.semantic === semantic) ?? { semantic, fidelity: "unsupported", reason: "Adapter did not declare this semantic." }) + : []; + const rule = decision ? this.model.rules.find(({ id }) => id === decision.ruleId) : undefined; + const declaredHeaders = [...Object.keys(rule?.match.headers ?? {}), ...Object.keys(decision?.outcome.headers ?? {})]; + const redactedHeaders = [...(this.model.redactHeaders ?? []), ...declaredHeaders]; + const requestHeaders = redactTransportHeaders(request.headers ?? {}, redactedHeaders); + const responseHeaders = response?.headers ? redactTransportHeaders(response.headers, redactedHeaders) : undefined; + const evidence = stripUndefined({ + schema: TRANSPORT_FAULT_EVIDENCE_SCHEMA, + fingerprint: transportFaultFingerprint({ adapter: this.capabilities.adapter, request: { url: redactTransportUrl(request.url), method: request.method.toUpperCase() }, fault: decision ? { ruleId: decision.ruleId, sequenceIndex: decision.sequenceIndex, semantics: decision.semantics } : undefined, response: response ? { status: response.status, connection: response.connection } : undefined }), + adapter: this.capabilities.adapter, + fidelity, + request: { + url: redactTransportUrl(request.url), + method: request.method.toUpperCase(), + headers: requestHeaders, + bodyBytes: transportBodyBytes(request.body), + }, + fault: decision ? { ruleId: decision.ruleId, sequenceIndex: decision.sequenceIndex, invocation: decision.invocation, semantics: decision.semantics, delayMs: decision.delayMs } : undefined, + response: response ? { ...response, headers: responseHeaders } : undefined, + }); + this.evidence.push(evidence); + return evidence; + } +} +export function transportFaultModel(input) { + if (input.schema !== undefined && input.schema !== TRANSPORT_FAULT_MODEL_SCHEMA) + throw new Error(`Transport fault model schema must be ${TRANSPORT_FAULT_MODEL_SCHEMA}.`); + if (!input.seed) + throw new Error("Transport fault model requires a non-empty seed."); + const ids = new Set(); + const rules = input.rules.map((rule) => { + if (!rule.id || ids.has(rule.id)) + throw new Error(`Transport fault rule ids must be non-empty and unique: ${rule.id}`); + if (rule.sequence.length === 0) + throw new Error(`Transport fault rule ${rule.id} requires at least one outcome.`); + ids.add(rule.id); + if (rule.match.pathPattern) + new RegExp(rule.match.pathPattern); + return { ...rule, sequence: rule.sequence.map(normalizeTransportFaultOutcome) }; + }); + return stripUndefined({ schema: TRANSPORT_FAULT_MODEL_SCHEMA, seed: input.seed, rules, redactHeaders: input.redactHeaders, metadata: input.metadata }); +} +export function transportFaultCapabilities(adapter, capabilities) { + const bySemantic = new Map(); + for (const capability of capabilities) + bySemantic.set(capability.semantic, capability); + return { schema: TRANSPORT_FAULT_CAPABILITIES_SCHEMA, adapter, capabilities: [...bySemantic.values()].sort((left, right) => left.semantic.localeCompare(right.semantic)) }; +} +export function transportFaultSafeSchedule(modelInput) { + const model = transportFaultModel(modelInput); + const safe = stripUndefined({ + schema: TRANSPORT_FAULT_SAFE_SCHEDULE_SCHEMA, + seed: model.seed, + rules: model.rules.map((rule) => stripUndefined({ + id: rule.id, + match: stripUndefined({ + host: rule.match.host, + method: rule.match.method, + path: rule.match.path, + pathPattern: rule.match.pathPattern, + headerNames: rule.match.headers ? Object.keys(rule.match.headers).map((name) => name.toLowerCase()).sort() : undefined, + }), + sequence: rule.sequence.map((outcome) => safeTransportFaultOutcome(outcome)), + repeat: rule.repeat, + metadataRedacted: rule.metadata ? true : undefined, + })), + redactHeaders: model.redactHeaders ? [...model.redactHeaders].map((name) => name.toLowerCase()).sort() : undefined, + metadataRedacted: model.metadata ? true : undefined, + }); + return { ...safe, structuralFingerprint: transportFaultFingerprint(safe) }; +} +export function negotiateTransportFaults(model, capabilities) { + const required = [...new Set(model.rules.flatMap((rule) => rule.sequence.flatMap(transportFaultOutcomeSemantics)))].sort(); + const unsupported = required.map((semantic) => capabilities.capabilities.find((item) => item.semantic === semantic) ?? { semantic, fidelity: "unsupported", reason: "Adapter did not declare this semantic." }).filter((item) => item.fidelity === "unsupported"); + return { supported: unsupported.length === 0, required, unsupported, capabilities }; +} +export function transportRequestMatches(matcher, request) { + let url; + try { + url = new URL(request.url); + } + catch { + return false; + } + if (matcher.host && url.host.toLowerCase() !== matcher.host.toLowerCase() && url.hostname.toLowerCase() !== matcher.host.toLowerCase()) + return false; + if (matcher.method && request.method.toUpperCase() !== matcher.method.toUpperCase()) + return false; + if (matcher.path && url.pathname !== matcher.path) + return false; + if (matcher.pathPattern && !new RegExp(matcher.pathPattern).test(url.pathname)) + return false; + const headers = normalizeHeaders(request.headers ?? {}); + return Object.entries(matcher.headers ?? {}).every(([name, value]) => headers[name.toLowerCase()] === value); +} +export function transportFaultOutcomeSemantics(outcome) { + const semantics = []; + if (outcome.status !== undefined || outcome.headers || outcome.body !== undefined || outcome.bodyBase64 !== undefined) + semantics.push("response-substitution"); + if (outcome.malformed) + semantics.push("malformed-response"); + if (outcome.truncateAfterBytes !== undefined) + semantics.push("truncated-response"); + if (outcome.chunkBytes !== undefined) + semantics.push("chunked-response"); + if (outcome.delayMs !== undefined) + semantics.push("delay"); + if (outcome.jitterMs !== undefined) + semantics.push("jitter"); + if (outcome.bandwidthBytesPerSecond !== undefined) + semantics.push("bandwidth"); + if (outcome.timeoutMs !== undefined) + semantics.push("timeout"); + if (outcome.connection === "refuse") + semantics.push("connection-refusal"); + if (outcome.connection === "reset") + semantics.push("connection-reset"); + if (outcome.connection === "half-close") + semantics.push("half-close"); + if (outcome.disconnectAfterBytes !== undefined) + semantics.push("disconnect-after-bytes"); + if (outcome.remapHost) + semantics.push("host-remap"); + if (outcome.requestCorruption) + semantics.push("request-corruption"); + if (outcome.responseCorruption) + semantics.push("response-corruption"); + return [...new Set(semantics)]; +} +export function transportFaultFingerprint(value) { + return createHash("sha256").update("wp-codebox/transport-fault-fingerprint/v1\n").update(stableJson(value)).digest("hex"); +} +export function redactTransportHeaders(headers, extra = []) { + const sensitive = new Set(["authorization", "cookie", "proxy-authorization", "set-cookie", "x-api-key", ...extra.map((name) => name.toLowerCase())]); + return Object.fromEntries(Object.entries(headers).map(([name, value]) => [name, sensitive.has(name.toLowerCase()) ? "[redacted]" : value])); +} +export function redactTransportUrl(raw) { + try { + const url = new URL(raw); + url.username = ""; + url.password = ""; + for (const key of [...url.searchParams.keys()]) { + if (/token|secret|nonce|password|passwd|pwd|key|signature|authorization/i.test(key)) + url.searchParams.set(key, "[redacted]"); + } + return url.toString(); + } + catch { + return raw.replace(/([?&](?:token|secret|nonce|password|key)=[^&#]*)/gi, "$1[redacted]"); + } +} +function normalizeTransportFaultOutcome(outcome) { + if (outcome.passthrough !== undefined && outcome.passthrough !== true) + throw new Error("Transport fault outcome passthrough must be true when declared."); + if (outcome.passthrough && Object.entries(outcome).some(([name, value]) => value !== undefined && name !== "passthrough" && name !== "metadata")) + throw new Error("Transport fault passthrough outcomes cannot declare another fault effect."); + for (const [name, value] of Object.entries(outcome)) { + if ((name.endsWith("Ms") || name.endsWith("Bytes") || name === "bandwidthBytesPerSecond") && typeof value === "number" && (!Number.isFinite(value) || value < 0)) { + throw new Error(`Transport fault outcome ${name} must be a finite non-negative number.`); + } + } + if (outcome.status !== undefined && (!Number.isInteger(outcome.status) || outcome.status < 100 || outcome.status > 599)) + throw new Error("Transport fault status must be between 100 and 599."); + return { ...outcome, headers: outcome.headers ? normalizeHeaders(outcome.headers) : undefined }; +} +function safeTransportFaultOutcome(outcome) { + const { headers, body, bodyBase64, metadata, remapHost, ...safe } = outcome; + return stripUndefined({ + ...safe, + remapHost: remapHost ? redactTransportUrl(remapHost) : undefined, + headerNames: headers ? Object.keys(headers).map((name) => name.toLowerCase()).sort() : undefined, + body: body !== undefined + ? { encoding: "utf8", bytes: Buffer.byteLength(body), redacted: true } + : bodyBase64 !== undefined + ? { encoding: "base64", bytes: Buffer.from(bodyBase64, "base64").byteLength, redacted: true } + : undefined, + metadataRedacted: metadata ? true : undefined, + }); +} +function faultSequenceIndex(rule, invocation) { + if (invocation < rule.sequence.length) + return invocation; + if ((rule.repeat ?? "last") === "cycle") + return invocation % rule.sequence.length; + if ((rule.repeat ?? "last") === "last") + return rule.sequence.length - 1; + return undefined; +} +function deterministicRange(seed, maximum) { + const digest = createHash("sha256").update(seed).digest(); + return digest.readUInt32BE(0) % (Math.floor(maximum) + 1); +} +function normalizeHeaders(headers) { + return Object.fromEntries(Object.entries(headers).map(([name, value]) => [name.toLowerCase(), value])); +} +function transportBodyBytes(body) { + if (body === undefined) + return undefined; + return typeof body === "string" ? Buffer.byteLength(body) : body.byteLength; +} +//# sourceMappingURL=transport-faults.js.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/transport-faults.js.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/transport-faults.js.map new file mode 100644 index 000000000..1bee729d8 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/transport-faults.js.map @@ -0,0 +1 @@ +{"version":3,"file":"transport-faults.js","sourceRoot":"","sources":["../src/transport-faults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAE9D,MAAM,CAAC,MAAM,4BAA4B,GAAG,qCAA8C,CAAA;AAC1F,MAAM,CAAC,MAAM,mCAAmC,GAAG,4CAAqD,CAAA;AACxG,MAAM,CAAC,MAAM,+BAA+B,GAAG,wCAAiD,CAAA;AAChG,MAAM,CAAC,MAAM,oCAAoC,GAAG,6CAAsD,CAAA;AAkJ1G,MAAM,OAAO,oBAAoB;IACtB,KAAK,CAAqB;IAC1B,YAAY,CAA4B;IACxC,QAAQ,GAA6B,EAAE,CAAA;IACvC,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAA;IAE5C,YAAY,KAA0B,EAAE,YAAwC;QAC9E,IAAI,CAAC,KAAK,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAA;QACvC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;IAClC,CAAC;IAED,MAAM,CAAC,OAA8B;QACnC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,SAAS,EA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C,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,CAAA;AACxG,CAAC;AAED,SAAS,kBAAkB,CAAC,IAAmC;IAC7D,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IACxC,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAA;AAC7E,CAAC"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/wordpress-crud-contracts.d.ts b/packages/runtime-cloudflare/vendor/wp-codebox-core/wordpress-crud-contracts.d.ts new file mode 100644 index 000000000..bc06ecea0 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/wordpress-crud-contracts.d.ts @@ -0,0 +1,220 @@ +import type { BackendNeutralArtifactRef } from "./runtime-neutral-contracts.js"; +export declare const WORDPRESS_CRUD_OPERATION_SCHEMA: "wp-codebox/wordpress-crud-operation/v1"; +export declare const WORDPRESS_CRUD_RESULT_SCHEMA: "wp-codebox/wordpress-crud-result/v1"; +export type WordPressCrudVerb = "create" | "read" | "update" | "delete" | "list"; +export type WordPressCrudResultStatus = "ok" | "unsupported" | "error"; +export interface WordPressCrudResourceRef { + kind: string; + type?: string; + id?: string | number; + path?: string; + route?: string; + identifiers?: Record; +} +export interface WordPressCrudOperation { + schema: typeof WORDPRESS_CRUD_OPERATION_SCHEMA; + operation: WordPressCrudVerb; + resource: WordPressCrudResourceRef; + data?: Record; + query?: Record; + options?: Record; + metadata?: Record; +} +export interface WordPressCrudDiagnostic { + code: string; + message: string; + severity?: "info" | "warning" | "error"; + metadata?: Record; +} +export interface WordPressCrudEffect { + kind: string; + resource?: WordPressCrudResourceRef; + before?: unknown; + after?: unknown; + metadata?: Record; +} +export interface WordPressCrudResult { + schema: typeof WORDPRESS_CRUD_RESULT_SCHEMA; + command: "wordpress.crud-operation"; + status: WordPressCrudResultStatus; + operation: WordPressCrudOperation; + item?: unknown; + items?: unknown[]; + effects?: WordPressCrudEffect[]; + diagnostics?: WordPressCrudDiagnostic[]; + errors?: WordPressCrudDiagnostic[]; + artifactRefs?: BackendNeutralArtifactRef[]; + metadata?: Record; +} +export declare const WORDPRESS_CRUD_OPERATION_JSON_SCHEMA: { + readonly $id: "wp-codebox/wordpress-crud-operation/v1"; + readonly type: "object"; + readonly additionalProperties: false; + readonly required: readonly ["schema", "operation", "resource"]; + readonly properties: { + readonly schema: { + readonly const: "wp-codebox/wordpress-crud-operation/v1"; + }; + readonly operation: { + readonly enum: readonly ["create", "read", "update", "delete", "list"]; + }; + readonly resource: { + readonly type: "object"; + readonly additionalProperties: false; + readonly required: readonly ["kind"]; + readonly properties: { + readonly kind: { + readonly type: "string"; + readonly minLength: 1; + }; + readonly type: { + readonly type: "string"; + readonly minLength: 1; + }; + readonly id: { + readonly anyOf: readonly [{ + readonly type: "string"; + }, { + readonly type: "number"; + }]; + }; + readonly path: { + readonly type: "string"; + readonly minLength: 1; + }; + readonly route: { + readonly type: "string"; + readonly minLength: 1; + }; + readonly identifiers: { + readonly type: "object"; + readonly additionalProperties: { + readonly type: readonly ["string", "number", "boolean", "null"]; + }; + }; + }; + }; + readonly data: { + readonly type: "object"; + readonly additionalProperties: true; + }; + readonly query: { + readonly type: "object"; + readonly additionalProperties: true; + }; + readonly options: { + readonly type: "object"; + readonly additionalProperties: true; + }; + readonly metadata: { + readonly type: "object"; + readonly additionalProperties: true; + }; + }; +}; +export declare const WORDPRESS_CRUD_RESULT_JSON_SCHEMA: { + readonly $id: "wp-codebox/wordpress-crud-result/v1"; + readonly type: "object"; + readonly additionalProperties: true; + readonly required: readonly ["schema", "command", "status", "operation"]; + readonly properties: { + readonly schema: { + readonly const: "wp-codebox/wordpress-crud-result/v1"; + }; + readonly command: { + readonly const: "wordpress.crud-operation"; + }; + readonly status: { + readonly enum: readonly ["ok", "unsupported", "error"]; + }; + readonly operation: { + readonly $id: "wp-codebox/wordpress-crud-operation/v1"; + readonly type: "object"; + readonly additionalProperties: false; + readonly required: readonly ["schema", "operation", "resource"]; + readonly properties: { + readonly schema: { + readonly const: "wp-codebox/wordpress-crud-operation/v1"; + }; + readonly operation: { + readonly enum: readonly ["create", "read", "update", "delete", "list"]; + }; + readonly resource: { + readonly type: "object"; + readonly additionalProperties: false; + readonly required: readonly ["kind"]; + readonly properties: { + readonly kind: { + readonly type: "string"; + readonly minLength: 1; + }; + readonly type: { + readonly type: "string"; + readonly minLength: 1; + }; + readonly id: { + readonly anyOf: readonly [{ + readonly type: "string"; + }, { + readonly type: "number"; + }]; + }; + readonly path: { + readonly type: "string"; + readonly minLength: 1; + }; + readonly route: { + readonly type: "string"; + readonly minLength: 1; + }; + readonly identifiers: { + readonly type: "object"; + readonly additionalProperties: { + readonly type: readonly ["string", "number", "boolean", "null"]; + }; + }; + }; + }; + readonly data: { + readonly type: "object"; + readonly additionalProperties: true; + }; + readonly query: { + readonly type: "object"; + readonly additionalProperties: true; + }; + readonly options: { + readonly type: "object"; + readonly additionalProperties: true; + }; + readonly metadata: { + readonly type: "object"; + readonly additionalProperties: true; + }; + }; + }; + readonly item: {}; + readonly items: { + readonly type: "array"; + }; + readonly effects: { + readonly type: "array"; + }; + readonly diagnostics: { + readonly type: "array"; + }; + readonly errors: { + readonly type: "array"; + }; + readonly artifactRefs: { + readonly type: "array"; + }; + readonly metadata: { + readonly type: "object"; + readonly additionalProperties: true; + }; + }; +}; +export declare function normalizeWordPressCrudOperation(input: unknown): WordPressCrudOperation; +export declare function createUnsupportedWordPressCrudResult(operation: WordPressCrudOperation, message?: string): WordPressCrudResult; +//# sourceMappingURL=wordpress-crud-contracts.d.ts.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/wordpress-crud-contracts.d.ts.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/wordpress-crud-contracts.d.ts.map new file mode 100644 index 000000000..058edd805 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/wordpress-crud-contracts.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"wordpress-crud-contracts.d.ts","sourceRoot":"","sources":["../src/wordpress-crud-contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAE/E,eAAO,MAAM,+BAA+B,EAAG,wCAAiD,CAAA;AAChG,eAAO,MAAM,4BAA4B,EAAG,qCAA8C,CAAA;AAE1F,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAA;AAChF,MAAM,MAAM,yBAAyB,GAAG,IAAI,GAAG,aAAa,GAAG,OAAO,CAAA;AAEtE,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC,CAAA;CAC/D;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,OAAO,+BAA+B,CAAA;IAC9C,SAAS,EAAE,iBAAiB,CAAA;IAC5B,QAAQ,EAAE,wBAAwB,CAAA;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACnC;AAED,MAAM,WAAW,uBAAuB;IACtC,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K,EAAE,OAAO,GAAG,sBAAsB,CAgBtF;AAED,wBAAgB,oCAAoC,CAAC,SAAS,EAAE,sBAAsB,EAAE,OAAO,SAAyE,GAAG,mBAAmB,CAU7L"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/wordpress-crud-contracts.js b/packages/runtime-cloudflare/vendor/wp-codebox-core/wordpress-crud-contracts.js new file mode 100644 index 000000000..8ad9fa75d --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/wordpress-crud-contracts.js @@ -0,0 +1,140 @@ +export const WORDPRESS_CRUD_OPERATION_SCHEMA = "wp-codebox/wordpress-crud-operation/v1"; +export const WORDPRESS_CRUD_RESULT_SCHEMA = "wp-codebox/wordpress-crud-result/v1"; +export const WORDPRESS_CRUD_OPERATION_JSON_SCHEMA = { + $id: WORDPRESS_CRUD_OPERATION_SCHEMA, + type: "object", + additionalProperties: false, + required: ["schema", "operation", "resource"], + properties: { + schema: { const: WORDPRESS_CRUD_OPERATION_SCHEMA }, + operation: { enum: ["create", "read", "update", "delete", "list"] }, + resource: { + type: "object", + additionalProperties: false, + required: ["kind"], + properties: { + kind: { type: "string", minLength: 1 }, + type: { type: "string", minLength: 1 }, + id: { anyOf: [{ type: "string" }, { type: "number" }] }, + path: { type: "string", minLength: 1 }, + route: { type: "string", minLength: 1 }, + identifiers: { + type: "object", + additionalProperties: { type: ["string", "number", "boolean", "null"] }, + }, + }, + }, + data: { type: "object", additionalProperties: true }, + query: { type: "object", additionalProperties: true }, + options: { type: "object", additionalProperties: true }, + metadata: { type: "object", additionalProperties: true }, + }, +}; +export const WORDPRESS_CRUD_RESULT_JSON_SCHEMA = { + $id: WORDPRESS_CRUD_RESULT_SCHEMA, + type: "object", + additionalProperties: true, + required: ["schema", "command", "status", "operation"], + properties: { + schema: { const: WORDPRESS_CRUD_RESULT_SCHEMA }, + command: { const: "wordpress.crud-operation" }, + status: { enum: ["ok", "unsupported", "error"] }, + operation: WORDPRESS_CRUD_OPERATION_JSON_SCHEMA, + item: {}, + items: { type: "array" }, + effects: { type: "array" }, + diagnostics: { type: "array" }, + errors: { type: "array" }, + artifactRefs: { type: "array" }, + metadata: { type: "object", additionalProperties: true }, + }, +}; +export function normalizeWordPressCrudOperation(input) { + const value = requireObject(input, "wordpress.crud-operation"); + const operation = requiredString(value.operation, "wordpress.crud-operation.operation"); + if (!isWordPressCrudVerb(operation)) { + throw new Error("wordpress.crud-operation.operation must be create, read, update, delete, or list."); + } + return stripUndefined({ + schema: WORDPRESS_CRUD_OPERATION_SCHEMA, + operation, + resource: normalizeWordPressCrudResourceRef(value.resource), + data: normalizeOptionalObject(value.data, "wordpress.crud-operation.data"), + query: normalizeOptionalObject(value.query, "wordpress.crud-operation.query"), + options: normalizeOptionalObject(value.options, "wordpress.crud-operation.options"), + metadata: normalizeOptionalObject(value.metadata, "wordpress.crud-operation.metadata"), + }); +} +export function createUnsupportedWordPressCrudResult(operation, message = "wordpress.crud-operation is not implemented by this runtime backend.") { + return { + schema: WORDPRESS_CRUD_RESULT_SCHEMA, + command: "wordpress.crud-operation", + status: "unsupported", + operation, + diagnostics: [{ code: "crud-operation-unsupported", message, severity: "warning" }], + effects: [], + artifactRefs: [], + }; +} +function normalizeWordPressCrudResourceRef(input) { + const value = requireObject(input, "wordpress.crud-operation.resource"); + return stripUndefined({ + kind: requiredString(value.kind, "wordpress.crud-operation.resource.kind"), + type: optionalString(value.type, "wordpress.crud-operation.resource.type"), + id: normalizeOptionalStringOrNumber(value.id, "wordpress.crud-operation.resource.id"), + path: optionalString(value.path, "wordpress.crud-operation.resource.path"), + route: optionalString(value.route, "wordpress.crud-operation.resource.route"), + identifiers: normalizeCrudIdentifiers(value.identifiers), + }); +} +function normalizeCrudIdentifiers(input) { + if (input === undefined) + return undefined; + const value = requireObject(input, "wordpress.crud-operation.resource.identifiers"); + return Object.fromEntries(Object.entries(value).map(([key, entry]) => { + if (typeof entry !== "string" && typeof entry !== "number" && typeof entry !== "boolean" && entry !== null) { + throw new Error(`wordpress.crud-operation.resource.identifiers.${key} must be a scalar value.`); + } + return [key, entry]; + })); +} +function isWordPressCrudVerb(value) { + return value === "create" || value === "read" || value === "update" || value === "delete" || value === "list"; +} +function normalizeOptionalStringOrNumber(value, label) { + if (value === undefined) + return undefined; + if (typeof value === "string") + return value.trim() === "" ? undefined : value.trim(); + if (typeof value === "number") + return value; + throw new Error(`${label} must be a string or number.`); +} +function normalizeOptionalObject(value, label) { + if (value === undefined) + return undefined; + return requireObject(value, label); +} +function requireObject(value, label) { + if (!value || typeof value !== "object" || Array.isArray(value)) + throw new Error(`${label} must be an object.`); + return value; +} +function requiredString(value, label) { + const normalized = optionalString(value, label); + if (!normalized) + throw new Error(`${label} must be a non-empty string.`); + return normalized; +} +function optionalString(value, label) { + if (value === undefined) + return undefined; + if (typeof value !== "string") + throw new Error(`${label} must be a string.`); + const normalized = value.trim(); + return normalized === "" ? undefined : normalized; +} +function stripUndefined(value) { + return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== undefined)); +} +//# sourceMappingURL=wordpress-crud-contracts.js.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/wordpress-crud-contracts.js.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/wordpress-crud-contracts.js.map new file mode 100644 index 000000000..539742cc9 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/wordpress-crud-contracts.js.map @@ -0,0 +1 @@ +{"version":3,"file":"wordpress-crud-contracts.js","sourceRoot":"","sources":["../src/wordpress-crud-contracts.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,+BAA+B,GAAG,wCAAiD,CAAA;AAChG,MAAM,CAAC,MAAM,4BAA4B,GAAG,qCAA8C,CAAA;AAqD1F,MAAM,CAAC,MAAM,oCAAoC,GAAG;IAClD,GAAG,EAAE,+BAA+B;IACpC,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE,KAAK;IAC3B,QAAQ,EAAE,CAAC,QAA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SAAS,CAAA;IACzC,OAAO,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AACpC,CAAC;AAED,SAAS,aAAa,CAAC,KAAc,EAAE,KAAa;IAClD,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,qBAAqB,CAAC,CAAA;IAC/G,OAAO,KAAgC,CAAA;AACzC,CAAC;AAED,SAAS,cAAc,CAAC,KAAc,EAAE,KAAa;IACnD,MAAM,UAAU,GAAG,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;IAC/C,IAAI,CAAC,UAAU;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,8BAA8B,CAAC,CAAA;IACxE,OAAO,UAAU,CAAA;AACnB,CAAC;AAED,SAAS,cAAc,CAAC,KAAc,EAAE,KAAa;IACnD,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IACzC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,oBAAoB,CAAC,CAAA;IAC5E,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAA;IAC/B,OAAO,UAAU,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAA;AACnD,CAAC;AAED,SAAS,cAAc,CAAoC,KAAQ;IACjE,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAM,CAAA;AAClG,CAAC"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/wordpress-db-contracts.d.ts b/packages/runtime-cloudflare/vendor/wp-codebox-core/wordpress-db-contracts.d.ts new file mode 100644 index 000000000..c49ba1cf4 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/wordpress-db-contracts.d.ts @@ -0,0 +1,220 @@ +import type { BackendNeutralArtifactRef } from "./runtime-neutral-contracts.js"; +export declare const WORDPRESS_DB_OPERATION_SCHEMA: "wp-codebox/wordpress-db-operation/v1"; +export declare const WORDPRESS_DB_RESULT_SCHEMA: "wp-codebox/wordpress-db-result/v1"; +export type WordPressDbVerb = "schema" | "read" | "inspect" | "query-summary" | "write"; +export type WordPressDbResultStatus = "ok" | "unsupported" | "error"; +export interface WordPressDbResourceRef { + table?: string; + identifiers?: Record; +} +export interface WordPressDbOperation { + schema: typeof WORDPRESS_DB_OPERATION_SCHEMA; + operation: WordPressDbVerb; + resource?: WordPressDbResourceRef; + query?: WordPressDbQuery; + options?: Record; + metadata?: Record; +} +export interface WordPressDbQuery { + table?: string; + columns?: string[]; + where?: Record; + limit?: number; + sql?: string; + [key: string]: unknown; +} +export interface WordPressDbDiagnostic { + code: string; + message: string; + severity?: "info" | "warning" | "error"; + metadata?: Record; +} +export interface WordPressDbResult { + schema: typeof WORDPRESS_DB_RESULT_SCHEMA; + command: "wordpress.db-operation"; + status: WordPressDbResultStatus; + operation: WordPressDbOperation; + item?: unknown; + items?: unknown[]; + diagnostics?: WordPressDbDiagnostic[]; + errors?: WordPressDbDiagnostic[]; + artifactRefs?: BackendNeutralArtifactRef[]; + metadata?: Record; +} +export declare const WORDPRESS_DB_OPERATION_JSON_SCHEMA: { + readonly $id: "wp-codebox/wordpress-db-operation/v1"; + readonly type: "object"; + readonly additionalProperties: false; + readonly required: readonly ["schema", "operation"]; + readonly properties: { + readonly schema: { + readonly const: "wp-codebox/wordpress-db-operation/v1"; + }; + readonly operation: { + readonly enum: readonly ["schema", "read", "inspect", "query-summary", "write"]; + }; + readonly resource: { + readonly type: "object"; + readonly additionalProperties: false; + readonly properties: { + readonly table: { + readonly type: "string"; + readonly minLength: 1; + }; + readonly identifiers: { + readonly type: "object"; + readonly additionalProperties: { + readonly type: readonly ["string", "number", "boolean", "null"]; + }; + }; + }; + }; + readonly query: { + readonly type: "object"; + readonly additionalProperties: true; + readonly properties: { + readonly table: { + readonly type: "string"; + readonly minLength: 1; + }; + readonly columns: { + readonly type: "array"; + readonly items: { + readonly type: "string"; + readonly minLength: 1; + }; + }; + readonly where: { + readonly type: "object"; + readonly additionalProperties: { + readonly type: readonly ["string", "number", "boolean", "null"]; + }; + }; + readonly limit: { + readonly type: "integer"; + readonly minimum: 1; + readonly maximum: 100; + }; + readonly sql: { + readonly type: "string"; + readonly minLength: 1; + }; + }; + }; + readonly options: { + readonly type: "object"; + readonly additionalProperties: true; + }; + readonly metadata: { + readonly type: "object"; + readonly additionalProperties: true; + }; + }; +}; +export declare const WORDPRESS_DB_RESULT_JSON_SCHEMA: { + readonly $id: "wp-codebox/wordpress-db-result/v1"; + readonly type: "object"; + readonly additionalProperties: true; + readonly required: readonly ["schema", "command", "status", "operation"]; + readonly properties: { + readonly schema: { + readonly const: "wp-codebox/wordpress-db-result/v1"; + }; + readonly command: { + readonly const: "wordpress.db-operation"; + }; + readonly status: { + readonly enum: readonly ["ok", "unsupported", "error"]; + }; + readonly operation: { + readonly $id: "wp-codebox/wordpress-db-operation/v1"; + readonly type: "object"; + readonly additionalProperties: false; + readonly required: readonly ["schema", "operation"]; + readonly properties: { + readonly schema: { + readonly const: "wp-codebox/wordpress-db-operation/v1"; + }; + readonly operation: { + readonly enum: readonly ["schema", "read", "inspect", "query-summary", "write"]; + }; + readonly resource: { + readonly type: "object"; + readonly additionalProperties: false; + readonly properties: { + readonly table: { + readonly type: "string"; + readonly minLength: 1; + }; + readonly identifiers: { + readonly type: "object"; + readonly additionalProperties: { + readonly type: readonly ["string", "number", "boolean", "null"]; + }; + }; + }; + }; + readonly query: { + readonly type: "object"; + readonly additionalProperties: true; + readonly properties: { + readonly table: { + readonly type: "string"; + readonly minLength: 1; + }; + readonly columns: { + readonly type: "array"; + readonly items: { + readonly type: "string"; + readonly minLength: 1; + }; + }; + readonly where: { + readonly type: "object"; + readonly additionalProperties: { + readonly type: readonly ["string", "number", "boolean", "null"]; + }; + }; + readonly limit: { + readonly type: "integer"; + readonly minimum: 1; + readonly maximum: 100; + }; + readonly sql: { + readonly type: "string"; + readonly minLength: 1; + }; + }; + }; + readonly options: { + readonly type: "object"; + readonly additionalProperties: true; + }; + readonly metadata: { + readonly type: "object"; + readonly additionalProperties: true; + }; + }; + }; + readonly item: {}; + readonly items: { + readonly type: "array"; + }; + readonly diagnostics: { + readonly type: "array"; + }; + readonly errors: { + readonly type: "array"; + }; + readonly artifactRefs: { + readonly type: "array"; + }; + readonly metadata: { + readonly type: "object"; + readonly additionalProperties: true; + }; + }; +}; +export declare function normalizeWordPressDbOperation(input: unknown): WordPressDbOperation; +export declare function createUnsupportedWordPressDbResult(operation: WordPressDbOperation, message?: string): WordPressDbResult; +//# sourceMappingURL=wordpress-db-contracts.d.ts.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/wordpress-db-contracts.d.ts.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/wordpress-db-contracts.d.ts.map new file mode 100644 index 000000000..b57677f81 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/wordpress-db-contracts.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"wordpress-db-contracts.d.ts","sourceRoot":"","sources":["../src/wordpress-db-contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAE/E,eAAO,MAAM,6BAA6B,EAAG,sCAA+C,CAAA;AAC5F,eAAO,MAAM,0BAA0B,EAAG,mCAA4C,CAAA;AAEtF,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,eAAe,GAAG,OAAO,CAAA;AACvF,MAAM,MAAM,uBAAuB,GAAG,IAAI,GAAG,aAAa,GAAG,OAAO,CAAA;AAEpE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d,KAAK,CAAC,EAAE,OAAO,EAAE,CAAA;IACjB,WAAW,CAAC,EAAE,qBAAqB,EAAE,CAAA;IACrC,MAAM,CAAC,EAAE,qBAAqB,EAAE,CAAA;IAChC,YAAY,CAAC,EAAE,yBAAyB,EAAE,CAAA;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACnC;AAED,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiCrC,CAAA;AAEV,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiBlC,CAAA;AAEV,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,OAAO,GAAG,oBAAoB,CAelF;AAED,wBAAgB,kCAAkC,CAAC,SAAS,EAAE,oBAAoB,EAAE,OAAO,SAAuE,GAAG,iBAAiB,CASrL"} \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/wordpress-db-contracts.js b/packages/runtime-cloudflare/vendor/wp-codebox-core/wordpress-db-contracts.js new file mode 100644 index 000000000..15999affd --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/wordpress-db-contracts.js @@ -0,0 +1,168 @@ +export const WORDPRESS_DB_OPERATION_SCHEMA = "wp-codebox/wordpress-db-operation/v1"; +export const WORDPRESS_DB_RESULT_SCHEMA = "wp-codebox/wordpress-db-result/v1"; +export const WORDPRESS_DB_OPERATION_JSON_SCHEMA = { + $id: WORDPRESS_DB_OPERATION_SCHEMA, + type: "object", + additionalProperties: false, + required: ["schema", "operation"], + properties: { + schema: { const: WORDPRESS_DB_OPERATION_SCHEMA }, + operation: { enum: ["schema", "read", "inspect", "query-summary", "write"] }, + resource: { + type: "object", + additionalProperties: false, + properties: { + table: { type: "string", minLength: 1 }, + identifiers: { + type: "object", + additionalProperties: { type: ["string", "number", "boolean", "null"] }, + }, + }, + }, + query: { + type: "object", + additionalProperties: true, + properties: { + table: { type: "string", minLength: 1 }, + columns: { type: "array", items: { type: "string", minLength: 1 } }, + where: { type: "object", additionalProperties: { type: ["string", "number", "boolean", "null"] } }, + limit: { type: "integer", minimum: 1, maximum: 100 }, + sql: { type: "string", minLength: 1 }, + }, + }, + options: { type: "object", additionalProperties: true }, + metadata: { type: "object", additionalProperties: true }, + }, +}; +export const WORDPRESS_DB_RESULT_JSON_SCHEMA = { + $id: WORDPRESS_DB_RESULT_SCHEMA, + type: "object", + additionalProperties: true, + required: ["schema", "command", "status", "operation"], + properties: { + schema: { const: WORDPRESS_DB_RESULT_SCHEMA }, + command: { const: "wordpress.db-operation" }, + status: { enum: ["ok", "unsupported", "error"] }, + operation: WORDPRESS_DB_OPERATION_JSON_SCHEMA, + item: {}, + items: { type: "array" }, + diagnostics: { type: "array" }, + errors: { type: "array" }, + artifactRefs: { type: "array" }, + metadata: { type: "object", additionalProperties: true }, + }, +}; +export function normalizeWordPressDbOperation(input) { + const value = requireObject(input, "wordpress.db-operation"); + const operation = requiredString(value.operation, "wordpress.db-operation.operation"); + if (!isWordPressDbVerb(operation)) { + throw new Error("wordpress.db-operation.operation must be schema, read, inspect, query-summary, or write."); + } + return stripUndefined({ + schema: WORDPRESS_DB_OPERATION_SCHEMA, + operation, + resource: normalizeOptionalDbResourceRef(value.resource), + query: normalizeOptionalDbQuery(value.query), + options: normalizeOptionalObject(value.options, "wordpress.db-operation.options"), + metadata: normalizeOptionalObject(value.metadata, "wordpress.db-operation.metadata"), + }); +} +export function createUnsupportedWordPressDbResult(operation, message = "wordpress.db-operation is not implemented by this runtime backend.") { + return { + schema: WORDPRESS_DB_RESULT_SCHEMA, + command: "wordpress.db-operation", + status: "unsupported", + operation, + diagnostics: [{ code: "db-operation-unsupported", message, severity: "warning" }], + artifactRefs: [], + }; +} +function normalizeOptionalDbResourceRef(input) { + if (input === undefined) + return undefined; + const value = requireObject(input, "wordpress.db-operation.resource"); + return stripUndefined({ + table: optionalString(value.table, "wordpress.db-operation.resource.table"), + identifiers: normalizeDbIdentifiers(value.identifiers), + }); +} +function normalizeDbIdentifiers(input) { + if (input === undefined) + return undefined; + const value = requireObject(input, "wordpress.db-operation.resource.identifiers"); + return Object.fromEntries(Object.entries(value).map(([key, entry]) => { + if (typeof entry !== "string" && typeof entry !== "number" && typeof entry !== "boolean" && entry !== null) { + throw new Error(`wordpress.db-operation.resource.identifiers.${key} must be a scalar value.`); + } + return [key, entry]; + })); +} +function normalizeOptionalDbQuery(input) { + if (input === undefined) + return undefined; + const value = requireObject(input, "wordpress.db-operation.query"); + const where = value.where === undefined ? undefined : normalizeDbScalars(value.where, "wordpress.db-operation.query.where"); + return stripUndefined({ + ...value, + table: optionalString(value.table, "wordpress.db-operation.query.table"), + columns: normalizeOptionalStringList(value.columns, "wordpress.db-operation.query.columns"), + where, + limit: normalizeOptionalLimit(value.limit), + sql: optionalString(value.sql, "wordpress.db-operation.query.sql"), + }); +} +function normalizeDbScalars(input, label) { + const value = requireObject(input, label); + return Object.fromEntries(Object.entries(value).map(([key, entry]) => { + if (typeof entry !== "string" && typeof entry !== "number" && typeof entry !== "boolean" && entry !== null) { + throw new Error(`${label}.${key} must be a scalar value.`); + } + return [key, entry]; + })); +} +function normalizeOptionalStringList(input, label) { + if (input === undefined) + return undefined; + if (!Array.isArray(input)) + throw new Error(`${label} must be an array.`); + const normalized = input.map((entry, index) => requiredString(entry, `${label}.${index}`)); + return normalized.length ? normalized : undefined; +} +function normalizeOptionalLimit(input) { + if (input === undefined) + return undefined; + if (typeof input !== "number" || !Number.isInteger(input)) + throw new Error("wordpress.db-operation.query.limit must be an integer."); + return Math.max(1, Math.min(100, input)); +} +function isWordPressDbVerb(value) { + return value === "schema" || value === "read" || value === "inspect" || value === "query-summary" || value === "write"; +} +function normalizeOptionalObject(value, label) { + if (value === undefined) + return undefined; + return requireObject(value, label); +} +function requireObject(value, label) { + if (!value || typeof value !== "object" || Array.isArray(value)) + throw new Error(`${label} must be an object.`); + return value; +} +function requiredString(value, label) { + const normalized = optionalString(value, label); + if (!normalized) + throw new Error(`${label} must be a non-empty string.`); + return normalized; +} +function optionalString(value, label) { + if (value === undefined) + return undefined; + if (typeof value !== "string") + throw new Error(`${label} must be a string.`); + const normalized = value.trim(); + return normalized === "" ? undefined : normalized; +} +function stripUndefined(value) { + return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== undefined)); +} +//# sourceMappingURL=wordpress-db-contracts.js.map \ No newline at end of file diff --git a/packages/runtime-cloudflare/vendor/wp-codebox-core/wordpress-db-contracts.js.map b/packages/runtime-cloudflare/vendor/wp-codebox-core/wordpress-db-contracts.js.map new file mode 100644 index 000000000..ee7756cb9 --- /dev/null +++ b/packages/runtime-cloudflare/vendor/wp-codebox-core/wordpress-db-contracts.js.map @@ -0,0 +1 @@ +{"version":3,"file":"wordpress-db-contracts.js","sourceRoot":"","sources":["../src/wordpress-db-contracts.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,6BAA6B,GAAG,sCAA+C,CAAA;AAC5F,MAAM,CAAC,MAAM,0BAA0B,GAAG,mCAA4C,CAAA;AAgDtF,MAAM,CAAC,MAAM,kCAAkC,GAAG;IAChD,GAAG,EAAE,6BAA6B;IAClC,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE,KAAK;IAC3B,QAAQ,EAAE,CAAC,QAAQ,EAAE,WAAW,CAAC;IACjC,UAAU,EAAE;QACV,MAAM,EAAE,EAAE,KAAK,EAAE,6BAA6B,EAAE;QAChD,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE;QAC5E,QAAQ,EAAE;YACR,IAAI,EAAE,QAAQ;YACd,oBAAoB,EAAE,KAAK;YAC3B,UAAU,EAAE;gBACV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,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,qBAAqB,CAAC,CAAA;IAC/G,OAAO,KAAgC,CAAA;AACzC,CAAC;AAED,SAAS,cAAc,CAAC,KAAc,EAAE,KAAa;IACnD,MAAM,UAAU,GAAG,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;IAC/C,IAAI,CAAC,UAAU;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,8BAA8B,CAAC,CAAA;IACxE,OAAO,UAAU,CAAA;AACnB,CAAC;AAED,SAAS,cAAc,CAAC,KAAc,EAAE,KAAa;IACnD,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IACzC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,oBAAoB,CAAC,CAAA;IAC5E,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAA;IAC/B,OAAO,UAAU,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAA;AACnD,CAAC;AAED,SAAS,cAAc,CAAoC,KAAQ;IACjE,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAM,CAAA;AAClG,CAAC"} \ No newline at end of file diff --git a/patches/README.md b/patches/README.md index 94eeca6c5..12b528c8e 100644 --- a/patches/README.md +++ b/patches/README.md @@ -1,14 +1,5 @@ # Temporary Playground Overlay -`@php-wasm+stream-compression+3.1.45.patch` is the built output of -WordPress Playground PR [#4110](https://github.com/WordPress/wordpress-playground/pull/4110) -at commit `afea9c042999c65f5b43bc049ca4b2bea9d8b361`. - -WP Codebox needs the repaired bounded Range decoder for the Cloudflare dev rig -and browser asset path before that upstream change can be merged and released. -Remove this patch and the package override after a published Playground package -contains the same change. - `@wp-playground+cli+3.1.46.patch` makes blueprint worker threads rethrow fatal `WebAssembly.RuntimeError` rejections originating from `php.wasm` after logging them. Detection uses the error name because PHP-WASM errors may cross JavaScript diff --git a/scripts/atomic-directory-exchange.c b/scripts/atomic-directory-exchange.c new file mode 100644 index 000000000..968f2f839 --- /dev/null +++ b/scripts/atomic-directory-exchange.c @@ -0,0 +1,1429 @@ +#if defined(__linux__) +#define _GNU_SOURCE +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(__linux__) +#include +#ifndef RENAME_EXCHANGE +#define RENAME_EXCHANGE (1 << 1) +#endif +#elif defined(__APPLE__) +#include +#else +#error "Atomic directory exchange is supported only on Linux and macOS" +#endif + +#ifndef O_NOFOLLOW +#define O_NOFOLLOW 0 +#endif + +/* A small self-contained SHA-256 keeps the helper dependency-free. */ +typedef struct { + uint32_t h[8]; + uint64_t bits; + unsigned char block[64]; + size_t used; +} sha256; +static const uint32_t k[64] = { + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, + 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, + 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, + 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, + 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, + 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2}; +static uint32_t rr(uint32_t x, int n) { + return (x >> n) | (x << (32 - n)); +} +static void sha_block(sha256 *s, const unsigned char *p) { + uint32_t w[64], a, b, c, d, e, f, g, h; + int i; + for (i = 0; i < 16; i++) { + w[i] = + ((uint32_t)p[i * 4] << 24) | ((uint32_t)p[i * 4 + 1] << 16) | ((uint32_t)p[i * 4 + 2] << 8) | p[i * 4 + 3]; + } + for (; i < 64; i++) { + uint32_t x = w[i - 15], y = w[i - 2]; + w[i] = (rr(x, 7) ^ rr(x, 18) ^ (x >> 3)) + w[i - 16] + (rr(y, 17) ^ rr(y, 19) ^ (y >> 10)) + w[i - 7]; + } + a = s->h[0]; + b = s->h[1]; + c = s->h[2]; + d = s->h[3]; + e = s->h[4]; + f = s->h[5]; + g = s->h[6]; + h = s->h[7]; + for (i = 0; i < 64; i++) { + uint32_t s1 = rr(e, 6) ^ rr(e, 11) ^ rr(e, 25), ch = (e & f) ^ ((~e) & g), t1 = h + s1 + ch + k[i] + w[i], + s0 = rr(a, 2) ^ rr(a, 13) ^ rr(a, 22), maj = (a & b) ^ (a & c) ^ (b & c), t2 = s0 + maj; + h = g; + g = f; + f = e; + e = d + t1; + d = c; + c = b; + b = a; + a = t1 + t2; + } + s->h[0] += a; + s->h[1] += b; + s->h[2] += c; + s->h[3] += d; + s->h[4] += e; + s->h[5] += f; + s->h[6] += g; + s->h[7] += h; +} +static void sha_init(sha256 *s) { + uint32_t h[8] = {0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19}; + memcpy(s->h, h, sizeof(h)); + s->bits = 0; + s->used = 0; +} +static void sha_add(sha256 *s, const void *data, size_t n) { + const unsigned char *p = data; + s->bits += (uint64_t)n * 8; + while (n) { + size_t take = 64 - s->used; + if (take > n) { + take = n; + } + memcpy(s->block + s->used, p, take); + s->used += take; + p += take; + n -= take; + if (s->used == 64) { + sha_block(s, s->block); + s->used = 0; + } + } +} +static void sha_final(sha256 *s, char out[65]) { + unsigned char pad[128] = {0x80}, digest[32]; + uint64_t bits = s->bits; + size_t n = s->used < 56 ? 56 - s->used : 120 - s->used; + sha_add(s, pad, n); + for (int i = 0; i < 8; i++) { + pad[i] = (unsigned char)(bits >> (56 - i * 8)); + } + sha_add(s, pad, 8); + for (int i = 0; i < 8; i++) { + digest[i * 4] = s->h[i] >> 24; + digest[i * 4 + 1] = s->h[i] >> 16; + digest[i * 4 + 2] = s->h[i] >> 8; + digest[i * 4 + 3] = s->h[i]; + } + for (int i = 0; i < 32; i++) { + sprintf(out + i * 2, "%02x", digest[i]); + } + out[64] = 0; +} + +typedef struct { + dev_t dev; + ino_t ino; +} identity; +static int same(identity a, identity b) { + return a.dev == b.dev && a.ino == b.ino; +} +static identity identity_of(struct stat st) { + identity x = {st.st_dev, st.st_ino}; + return x; +} +static int stable_metadata(struct stat a, struct stat b) { +#if defined(__APPLE__) + return same(identity_of(a), identity_of(b)) && a.st_mode == b.st_mode && a.st_size == b.st_size && + a.st_mtimespec.tv_sec == b.st_mtimespec.tv_sec && a.st_mtimespec.tv_nsec == b.st_mtimespec.tv_nsec && + a.st_ctimespec.tv_sec == b.st_ctimespec.tv_sec && a.st_ctimespec.tv_nsec == b.st_ctimespec.tv_nsec; +#else + return same(identity_of(a), identity_of(b)) && a.st_mode == b.st_mode && a.st_size == b.st_size && + a.st_mtim.tv_sec == b.st_mtim.tv_sec && a.st_mtim.tv_nsec == b.st_mtim.tv_nsec && + a.st_ctim.tv_sec == b.st_ctim.tv_sec && a.st_ctim.tv_nsec == b.st_ctim.tv_nsec; +#endif +} +static int write_status(const char *s) { + return dprintf(STDOUT_FILENO, "%s\n", s) < 0 ? -1 : 0; +} +static int read_command(char *line, size_t size) { + if (!fgets(line, (int)size, stdin)) { + return -1; + } + line[strcspn(line, "\r\n")] = 0; + return 0; +} +static void file_barrier(const char *environment) { + const char *barrier = getenv(environment); + if (!barrier || !*barrier) { + return; + } + int marker = open(barrier, O_CREAT | O_EXCL | O_WRONLY | O_NOFOLLOW, 0600); + if (marker < 0) { + return; + } + close(marker); + while (access(barrier, F_OK) == 0) { + usleep(1000); + } +} + +static int compare_names(const void *a, const void *b) { + return strcmp(*(const char *const *)a, *(const char *const *)b); +} +static int sync_directory(int fd); +static int manifest_dir(int fd, const char *prefix, sha256 *hash, int synchronize) { + int scan = openat(fd, ".", O_RDONLY | O_DIRECTORY | O_NOFOLLOW), result = -1; + DIR *dir; + struct dirent *entry; + char **names = NULL; + size_t count = 0; + struct stat before, after; + if (scan < 0 || fstat(fd, &before) != 0 || !S_ISDIR(before.st_mode) || !(dir = fdopendir(scan))) { + if (scan >= 0) { + close(scan); + } + return -1; + } + while ((entry = readdir(dir))) { + if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, "..")) { + continue; + } + if (!strcmp(entry->d_name, ".wp-codebox-cleanup-token")) { + continue; + } + char **grown = realloc(names, (count + 1) * sizeof(*names)); + if (!grown) { + goto done; + } + names = grown; + if (!(names[count] = strdup(entry->d_name))) { + goto done; + } + count++; + } + qsort(names, count, sizeof(*names), compare_names); + for (size_t i = 0; i < count; i++) { + struct stat st; + int child; + char path[4096], header[8192]; + if (snprintf(path, sizeof(path), "%s%s%s", prefix, *prefix ? "/" : "", names[i]) >= (int)sizeof(path)) { + goto done; + } + if (fstatat(fd, names[i], &st, AT_SYMLINK_NOFOLLOW) != 0 || S_ISLNK(st.st_mode)) { + goto done; + } + if (S_ISDIR(st.st_mode)) { + int n = snprintf(header, sizeof(header), "d%c%s%c%u%c", 0, path, 0, (unsigned)st.st_mode, 0); + sha_add(hash, header, (size_t)n); + child = openat(fd, names[i], O_RDONLY | O_DIRECTORY | O_NOFOLLOW); + if (child < 0) { + goto done; + } + struct stat opened, current; + if (fstat(child, &opened) != 0 || !stable_metadata(st, opened) || + manifest_dir(child, path, hash, synchronize) != 0 || (synchronize && sync_directory(child) != 0) || + fstat(child, ¤t) != 0 || !stable_metadata(opened, current) || + fstatat(fd, names[i], ¤t, AT_SYMLINK_NOFOLLOW) != 0 || !stable_metadata(opened, current)) { + close(child); + goto done; + } + close(child); + } else if (S_ISREG(st.st_mode)) { + child = openat(fd, names[i], O_RDONLY | O_NOFOLLOW); + if (child < 0) { + goto done; + } + struct stat opened; + if (fstat(child, &opened) != 0 || !S_ISREG(opened.st_mode) || !stable_metadata(st, opened)) { + close(child); + goto done; + } + int n = snprintf(header, sizeof(header), "f%c%s%c%u%c%llu%c", 0, path, 0, (unsigned)opened.st_mode, 0, + (unsigned long long)opened.st_size, 0); + sha_add(hash, header, (size_t)n); + if (synchronize && fsync(child) != 0) { + close(child); + goto done; + } + unsigned char buffer[65536]; + ssize_t got; + while ((got = read(child, buffer, sizeof(buffer))) > 0) { + sha_add(hash, buffer, (size_t)got); + } + if (got < 0 || fstat(child, &after) != 0 || !stable_metadata(opened, after)) { + close(child); + goto done; + } + close(child); + if (fstatat(fd, names[i], &after, AT_SYMLINK_NOFOLLOW) != 0 || !stable_metadata(opened, after)) { + goto done; + } + } else { + goto done; + } + } + if (fstat(fd, &after) == 0 && stable_metadata(before, after)) { + result = 0; + } +done: + for (size_t i = 0; i < count; i++) { + free(names[i]); + } + free(names); + closedir(dir); + return result; +} +static int tree_manifest(int root, char out[65], int synchronize) { + sha256 hash; + sha_init(&hash); + if (manifest_dir(root, "", &hash, synchronize) != 0 || (synchronize && sync_directory(root) != 0)) { + return -1; + } + sha_final(&hash, out); + return 0; +} +static int manifest(int root, char out[65]) { + return tree_manifest(root, out, 0); +} +static int sync_manifest(int root, char out[65]) { + return tree_manifest(root, out, 1); +} + +static int sync_directory(int fd) { + return fsync(fd); +} +static int sync_failure(const char *point) { + static int injected; + const char *wanted = getenv("WP_CODEBOX_SYNC_FAILURE"); + if (!injected && wanted && *wanted && !strcmp(wanted, point)) { + injected = 1; + errno = EIO; + return -1; + } + return 0; +} +static int copy_snapshot_dir(int source, int destination) { + int scan = openat(source, ".", O_RDONLY | O_DIRECTORY | O_NOFOLLOW), result = -1; + DIR *dir; + struct dirent *entry; + struct stat source_before, source_after; + if (scan < 0 || fstat(source, &source_before) != 0 || !S_ISDIR(source_before.st_mode) || !(dir = fdopendir(scan))) { + if (scan >= 0) { + close(scan); + } + return -1; + } + while ((entry = readdir(dir))) { + int input = -1, output = -1; + struct stat path_stat, opened; + unsigned char buffer[65536]; + ssize_t got; + if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, "..")) { + continue; + } + if (!strcmp(entry->d_name, ".wp-codebox-cleanup-token")) { + continue; + } + if (fstatat(source, entry->d_name, &path_stat, AT_SYMLINK_NOFOLLOW) != 0 || S_ISLNK(path_stat.st_mode)) { + goto done; + } + if (S_ISDIR(path_stat.st_mode)) { + if (mkdirat(destination, entry->d_name, 0700) != 0 || sync_directory(destination) != 0) { + goto done; + } + input = openat(source, entry->d_name, O_RDONLY | O_DIRECTORY | O_NOFOLLOW); + output = openat(destination, entry->d_name, O_RDONLY | O_DIRECTORY | O_NOFOLLOW); + if (input < 0 || output < 0 || fstat(input, &opened) != 0 || !S_ISDIR(opened.st_mode) || + !stable_metadata(path_stat, opened) || fchmod(output, path_stat.st_mode & 07777) != 0 || + copy_snapshot_dir(input, output) != 0 || fstat(input, &source_after) != 0 || + !stable_metadata(opened, source_after) || + fstatat(source, entry->d_name, &source_after, AT_SYMLINK_NOFOLLOW) != 0 || + !stable_metadata(opened, source_after)) { + if (input >= 0) { + close(input); + } + if (output >= 0) { + close(output); + } + goto done; + } + close(input); + close(output); + } else if (S_ISREG(path_stat.st_mode)) { + input = openat(source, entry->d_name, O_RDONLY | O_NOFOLLOW); + output = openat(destination, entry->d_name, O_CREAT | O_EXCL | O_WRONLY | O_NOFOLLOW, 0600); + if (input < 0 || output < 0 || fstat(input, &opened) != 0 || !S_ISREG(opened.st_mode) || + !stable_metadata(path_stat, opened) || fchmod(output, path_stat.st_mode & 07777) != 0) { + if (input >= 0) { + close(input); + } + if (output >= 0) { + close(output); + } + goto done; + } + while ((got = read(input, buffer, sizeof(buffer))) > 0) { + ssize_t sent = 0; + while (sent < got) { + ssize_t n = write(output, buffer + sent, (size_t)(got - sent)); + if (n <= 0) { + close(input); + close(output); + goto done; + } + sent += n; + } + } + if (got < 0 || fsync(output) != 0 || fstat(input, &source_after) != 0 || + !stable_metadata(opened, source_after) || + fstatat(source, entry->d_name, &source_after, AT_SYMLINK_NOFOLLOW) != 0 || + !stable_metadata(opened, source_after)) { + close(input); + close(output); + goto done; + } + close(input); + close(output); + } else { + goto done; + } + } + { + const char *barrier = getenv("WP_CODEBOX_SNAPSHOT_BARRIER"); + if (barrier && *barrier) { + int marker = open(barrier, O_CREAT | O_EXCL | O_WRONLY | O_NOFOLLOW, 0600); + if (marker >= 0) { + close(marker); + while (access(barrier, F_OK) == 0) { + usleep(1000); + } + } + } + } + if (fstat(source, &source_after) == 0 && stable_metadata(source_before, source_after) && + sync_directory(destination) == 0) { + result = 0; + } +done: + closedir(dir); + return result; +} + +static int split_path(const char *path, char **parent, char **name) { + char *copy = strdup(path), *slash; + if (!copy) { + return -1; + } + slash = strrchr(copy, '/'); + if (!slash || !slash[1]) { + free(copy); + return -1; + } + *name = strdup(slash + 1); + if (slash == copy) { + slash[1] = 0; + } else { + *slash = 0; + } + *parent = copy; + return *name ? 0 : -1; +} +static int open_absolute_directory(const char *path) { + if (!path || path[0] != '/') { + return -1; + } + int fd = open("/", O_RDONLY | O_DIRECTORY | O_NOFOLLOW); + char *copy = strdup(path), *save = NULL, *part; + if (fd < 0 || !copy) { + if (fd >= 0) { + close(fd); + } + free(copy); + return -1; + } + for (part = strtok_r(copy, "/", &save); part; part = strtok_r(NULL, "/", &save)) { + if (!strcmp(part, ".") || !strcmp(part, "..")) { + close(fd); + free(copy); + return -1; + } + int next = openat(fd, part, O_RDONLY | O_DIRECTORY | O_NOFOLLOW); + close(fd); + if (next < 0) { + free(copy); + return -1; + } + fd = next; + } + free(copy); + return fd; +} +static int open_relative_file(int root, const char *path) { + if (!path || !*path || path[0] == '/') { + return -1; + } + int fd = dup(root); + char *copy = strdup(path), *save = NULL, *part, *next; + if (fd < 0 || !copy) { + if (fd >= 0) { + close(fd); + } + free(copy); + return -1; + } + part = strtok_r(copy, "/", &save); + while (part) { + if (!strcmp(part, ".") || !strcmp(part, "..")) { + close(fd); + free(copy); + return -1; + } + next = strtok_r(NULL, "/", &save); + int opened = openat(fd, part, O_RDONLY | O_NOFOLLOW | (next ? O_DIRECTORY : 0)); + close(fd); + if (opened < 0) { + free(copy); + return -1; + } + fd = opened; + part = next; + } + free(copy); + struct stat st; + if (fstat(fd, &st) || !S_ISREG(st.st_mode)) { + close(fd); + return -1; + } + return fd; +} +static int relative_file_identity(int root, const char *path, identity expected) { + int file = open_relative_file(root, path); + struct stat st; + if (file < 0) { + return 0; + } + int result = fstat(file, &st) == 0 && same(identity_of(st), expected); + close(file); + return result; +} +static int entry_identity(int parent, const char *name, identity expected) { + struct stat st; + return fstatat(parent, name, &st, AT_SYMLINK_NOFOLLOW) == 0 && S_ISDIR(st.st_mode) && !S_ISLNK(st.st_mode) && + same(identity_of(st), expected); +} +static int any_entry_identity(int parent, const char *name, identity expected) { + struct stat st; + return fstatat(parent, name, &st, AT_SYMLINK_NOFOLLOW) == 0 && same(identity_of(st), expected); +} +static int exchange_at(int lp, const char *ln, int rp, const char *rn) { +#if defined(__linux__) + return (int)syscall(SYS_renameat2, lp, ln, rp, rn, RENAME_EXCHANGE); +#else + return renameatx_np(lp, ln, rp, rn, RENAME_SWAP); +#endif +} + +typedef struct { + int file; + int parent; + char *name; + identity directory; +} secure_lock_handle; +static secure_lock_handle secure_lock(const char *path) { + secure_lock_handle result = {-1, -1, NULL, {0, 0}}; + struct stat st, after, directory; + int fd; + char *parent_path = NULL; + if (split_path(path, &parent_path, &result.name)) { + return result; + } + result.parent = open_absolute_directory(parent_path); + free(parent_path); + if (result.parent < 0) { + return result; + } + if (mkdirat(result.parent, result.name, 0700) == 0) { + if (sync_directory(result.parent) != 0) { + return result; + } + } else if (errno != EEXIST) { + return result; + } + fd = openat(result.parent, result.name, O_RDONLY | O_DIRECTORY | O_NOFOLLOW); + if (fd < 0) { + return result; + } + if (fstat(fd, &directory) != 0 || directory.st_uid != geteuid()) { + close(fd); + return result; + } + if ((directory.st_mode & 0777) != 0500 && fchmod(fd, 0500) != 0) { + close(fd); + return result; + } + if (fstat(fd, &directory) != 0 || directory.st_uid != geteuid() || (directory.st_mode & 0777) != 0500) { + close(fd); + return result; + } + int lock = openat(fd, "lock", O_CREAT | O_RDWR | O_NOFOLLOW, 0600); + if (lock < 0 && errno == EACCES) { + if (fchmod(fd, 0700) != 0) { + close(fd); + return result; + } + lock = openat(fd, "lock", O_CREAT | O_RDWR | O_NOFOLLOW, 0600); + if (fchmod(fd, 0500) != 0) { + if (lock >= 0) { + close(lock); + } + close(fd); + return result; + } + } + if (lock < 0 || fstat(lock, &st) != 0 || !S_ISREG(st.st_mode) || st.st_uid != geteuid() || + (st.st_mode & 0777) != 0600 || flock(lock, LOCK_EX) != 0) { + if (lock >= 0) { + close(lock); + } + close(fd); + return result; + } + if (fstatat(fd, "lock", &after, AT_SYMLINK_NOFOLLOW) != 0 || !same(identity_of(st), identity_of(after))) { + close(lock); + close(fd); + return result; + } + result.file = lock; + result.directory = identity_of(directory); + close(fd); + return result; +} +static int lock_continuous(secure_lock_handle lock) { + struct stat directory, file, path_file; + int directory_fd = openat(lock.parent, lock.name, O_RDONLY | O_DIRECTORY | O_NOFOLLOW); + if (directory_fd < 0 || fstat(directory_fd, &directory) || !same(identity_of(directory), lock.directory) || + (directory.st_mode & 0777) != 0500 || directory.st_uid != geteuid()) { + if (directory_fd >= 0) { + close(directory_fd); + } + return 0; + } + if (fstat(lock.file, &file) || fstatat(directory_fd, "lock", &path_file, AT_SYMLINK_NOFOLLOW) || + !same(identity_of(file), identity_of(path_file)) || !S_ISREG(file.st_mode) || file.st_uid != geteuid() || + (file.st_mode & 0777) != 0600) { + close(directory_fd); + return 0; + } + close(directory_fd); + return 1; +} + +enum cleanup_result { CLEAN_OK = 0, CLEAN_IDENTITY = 1, CLEAN_PENDING = 2 }; + +static enum cleanup_result remove_contents(int fd); +static enum cleanup_result remove_child(int parent, const char *name, struct stat before, unsigned long sequence) { + char temporary[128]; + struct stat st; + identity expected = identity_of(before), placeholder; + int child = -1; + snprintf(temporary, sizeof(temporary), ".wp-codebox-child-%ld-%lu", (long)getpid(), sequence); + if (S_ISDIR(before.st_mode)) { + if (mkdirat(parent, temporary, 0700) != 0 || sync_directory(parent) != 0) { + return CLEAN_PENDING; + } + } else { + int file = openat(parent, temporary, O_CREAT | O_EXCL | O_WRONLY | O_NOFOLLOW, 0600); + if (file < 0) { + return CLEAN_PENDING; + } + close(file); + if (sync_directory(parent) != 0) { + return CLEAN_PENDING; + } + } + if (fstatat(parent, temporary, &st, AT_SYMLINK_NOFOLLOW) != 0) { + goto pending; + } + placeholder = identity_of(st); + if (exchange_at(parent, name, parent, temporary) != 0 || sync_directory(parent) != 0) { + goto pending; + } + if (fstatat(parent, temporary, &st, AT_SYMLINK_NOFOLLOW) != 0) { + goto pending; + } + if (!same(identity_of(st), expected)) { + if (any_entry_identity(parent, name, placeholder)) { + exchange_at(parent, name, parent, temporary); + } + goto pending; + } + if (S_ISDIR(before.st_mode)) { + child = openat(parent, temporary, O_RDONLY | O_DIRECTORY | O_NOFOLLOW); + if (child < 0 || fstat(child, &st) != 0 || !same(identity_of(st), expected) || + remove_contents(child) != CLEAN_OK || fstat(child, &st) != 0 || !same(identity_of(st), expected)) { + if (child >= 0) { + close(child); + } + goto restore; + } + close(child); + child = -1; + if (!entry_identity(parent, temporary, expected) || unlinkat(parent, temporary, AT_REMOVEDIR) != 0 || + sync_directory(parent) != 0) { + goto restore; + } + } else { + child = openat(parent, temporary, O_RDONLY | O_NOFOLLOW | O_NONBLOCK); + if (child < 0 || fstat(child, &st) != 0 || !same(identity_of(st), expected)) { + if (child >= 0) { + close(child); + } + goto restore; + } + close(child); + child = -1; + if (fstatat(parent, temporary, &st, AT_SYMLINK_NOFOLLOW) != 0 || !same(identity_of(st), expected) || + unlinkat(parent, temporary, 0) != 0 || sync_directory(parent) != 0) { + goto restore; + } + } + if (S_ISDIR(before.st_mode)) { + if (!entry_identity(parent, name, placeholder) || unlinkat(parent, name, AT_REMOVEDIR) != 0 || + sync_directory(parent) != 0) { + return CLEAN_PENDING; + } + } else { + if (fstatat(parent, name, &st, AT_SYMLINK_NOFOLLOW) != 0 || !same(identity_of(st), placeholder) || + unlinkat(parent, name, 0) != 0 || sync_directory(parent) != 0) { + return CLEAN_PENDING; + } + } + return CLEAN_OK; +restore: + if (child >= 0) { + close(child); + } + if (S_ISDIR(before.st_mode)) { + if (entry_identity(parent, name, placeholder) && entry_identity(parent, temporary, expected) && + exchange_at(parent, name, parent, temporary) == 0) { + sync_directory(parent); + } + } else if (any_entry_identity(parent, name, placeholder) && any_entry_identity(parent, temporary, expected) && + exchange_at(parent, name, parent, temporary) == 0) { + sync_directory(parent); + } +pending: + if (S_ISDIR(before.st_mode)) { + if (entry_identity(parent, temporary, placeholder) && unlinkat(parent, temporary, AT_REMOVEDIR) == 0) { + sync_directory(parent); + } + } else if (fstatat(parent, temporary, &st, AT_SYMLINK_NOFOLLOW) == 0 && same(identity_of(st), placeholder) && + unlinkat(parent, temporary, 0) == 0) { + sync_directory(parent); + } + return CLEAN_PENDING; +} + +static enum cleanup_result remove_contents(int fd) { + static unsigned long sequence; + int scan = openat(fd, ".", O_RDONLY | O_DIRECTORY | O_NOFOLLOW); + DIR *dir; + struct dirent *e; + char **names = NULL; + size_t count = 0; + enum cleanup_result result = CLEAN_OK; + if (scan < 0 || !(dir = fdopendir(scan))) { + if (scan >= 0) { + close(scan); + } + return CLEAN_PENDING; + } + while ((e = readdir(dir))) { + if (!strcmp(e->d_name, ".") || !strcmp(e->d_name, "..")) { + continue; + } + char **grown = realloc(names, (count + 1) * sizeof(*names)); + if (!grown) { + result = CLEAN_PENDING; + break; + } + names = grown; + names[count] = strdup(e->d_name); + if (!names[count]) { + result = CLEAN_PENDING; + break; + } + count++; + } + closedir(dir); + if (result == CLEAN_OK) { + for (size_t i = 0; i < count; i++) { + struct stat before; + if (fstatat(fd, names[i], &before, AT_SYMLINK_NOFOLLOW) != 0 || + remove_child(fd, names[i], before, sequence++) != CLEAN_OK) { + result = CLEAN_PENDING; + break; + } + } + } + for (size_t i = 0; i < count; i++) { + free(names[i]); + } + free(names); + return result; +} + +static void cleanup_barrier(const char *point) { + const char *barrier = getenv("WP_CODEBOX_CLEANUP_BARRIER"), *wanted = getenv("WP_CODEBOX_CLEANUP_BARRIER_POINT"); + if (barrier && *barrier && + (((!wanted || !*wanted) && !strcmp(point, "quarantined")) || (wanted && *wanted && !strcmp(wanted, point)))) { + int marker = open(barrier, O_CREAT | O_EXCL | O_WRONLY | O_NOFOLLOW, 0600); + if (marker >= 0) { + dprintf(marker, "%ld\n", (long)getpid()); + close(marker); + while (1) { + pause(); + } + } + } +} +static int valid_token(const char *token) { + if (!token || !*token || strlen(token) > 80) { + return 0; + } + for (const char *p = token; *p; p++) { + if (!((*p >= 'a' && *p <= 'z') || (*p >= 'A' && *p <= 'Z') || (*p >= '0' && *p <= '9') || *p == '-')) { + return 0; + } + } + return 1; +} +static const char cleanup_token_file[] = ".wp-codebox-cleanup-token"; +static int write_target_token(int target, const char *token) { + int fd = openat(target, cleanup_token_file, O_CREAT | O_EXCL | O_WRONLY | O_NOFOLLOW, 0600); + if (fd < 0) { + return -1; + } + int ok = dprintf(fd, "%s\n", token) > 0 && fsync(fd) == 0; + close(fd); + if (ok && sync_directory(target) == 0) { + return 0; + } + unlinkat(target, cleanup_token_file, 0); + sync_directory(target); + return -1; +} +static int target_token(int target, const char *token) { + char data[82], saved[81], extra; + struct stat st, path; + ssize_t n; + int fd = openat(target, cleanup_token_file, O_RDONLY | O_NOFOLLOW); + if (fd < 0) { + return 0; + } + if (fstat(fd, &st) != 0 || !S_ISREG(st.st_mode) || (st.st_mode & 0777) != 0600 || + fstatat(target, cleanup_token_file, &path, AT_SYMLINK_NOFOLLOW) != 0 || + !same(identity_of(st), identity_of(path)) || (n = read(fd, data, sizeof(data) - 1)) <= 0) { + close(fd); + return 0; + } + close(fd); + data[n] = 0; + return sscanf(data, "%80s %c", saved, &extra) == 1 && !strcmp(saved, token); +} +static int remove_target_token(int target, const char *token) { + struct stat st; + if (!target_token(target, token)) { + if (fstatat(target, cleanup_token_file, &st, AT_SYMLINK_NOFOLLOW) != 0 && errno == ENOENT) { + return 0; + } + errno = EPERM; + return -1; + } + return unlinkat(target, cleanup_token_file, 0) == 0 && sync_directory(target) == 0 ? 0 : -1; +} +static int ensure_target_token(int target, const char *token) { + return target_token(target, token) ? 0 : write_target_token(target, token); +} +static int write_cleanup_state(int qfd, const char *token, identity expected, identity placeholder) { + int fd = openat(qfd, "owner", O_CREAT | O_EXCL | O_WRONLY | O_NOFOLLOW, 0600); + if (fd < 0) { + return -1; + } + int ok = dprintf(fd, "%s %llu %llu %llu %llu\n", token, (unsigned long long)expected.dev, + (unsigned long long)expected.ino, (unsigned long long)placeholder.dev, + (unsigned long long)placeholder.ino) > 0 && + fsync(fd) == 0; + close(fd); + return ok && sync_directory(qfd) == 0 ? 0 : -1; +} +static int read_cleanup_state(int qfd, const char *token, identity expected, identity *placeholder) { + char data[256], saved[81], extra; + unsigned long long ed, ei, pd, pi; + int fd = openat(qfd, "owner", O_RDONLY | O_NOFOLLOW), result = 0; + struct stat st; + ssize_t n; + if (fd < 0 || fstat(fd, &st) || !S_ISREG(st.st_mode) || (st.st_mode & 0777) != 0600 || + (n = read(fd, data, sizeof(data) - 1)) <= 0) { + if (fd >= 0) { + close(fd); + } + return 0; + } + close(fd); + data[n] = 0; + if (sscanf(data, "%80s %llu %llu %llu %llu %c", saved, &ed, &ei, &pd, &pi, &extra) == 5 && !strcmp(saved, token) && + (dev_t)ed == expected.dev && (ino_t)ei == expected.ino) { + placeholder->dev = (dev_t)pd; + placeholder->ino = (ino_t)pi; + result = 1; + } + return result; +} +static int directory_empty(int fd) { + int scan = openat(fd, ".", O_RDONLY | O_DIRECTORY | O_NOFOLLOW), empty = 0; + DIR *dir; + struct dirent *entry; + if (scan < 0 || !(dir = fdopendir(scan))) { + if (scan >= 0) { + close(scan); + } + return 0; + } + empty = 1; + while ((entry = readdir(dir))) { + if (strcmp(entry->d_name, ".") && strcmp(entry->d_name, "..")) { + empty = 0; + break; + } + } + closedir(dir); + return empty; +} +static enum cleanup_result cleanup_entry(int parent, const char *name, identity expected, const char *token) { + char quarantine[256]; + int qfd = -1, root = -1, created = 0; + struct stat st; + identity placeholder = {0, 0}; + enum cleanup_result result = CLEAN_PENDING; + if (!valid_token(token)) { + return CLEAN_PENDING; + } + snprintf(quarantine, sizeof(quarantine), ".wp-codebox-cleanup-%llu-%llu-%s", (unsigned long long)expected.dev, + (unsigned long long)expected.ino, token); + if (mkdirat(parent, quarantine, 0700) == 0) { + created = 1; + if (sync_directory(parent) != 0) { + goto done; + } + } else if (errno != EEXIST) { + return CLEAN_PENDING; + } + qfd = openat(parent, quarantine, O_RDONLY | O_DIRECTORY | O_NOFOLLOW); + if (qfd < 0) { + return CLEAN_PENDING; + } + if (created) { + int target = openat(parent, name, O_RDONLY | O_DIRECTORY | O_NOFOLLOW); + if (target < 0 || !target_token(target, token)) { + if (target >= 0) { + close(target); + } + result = CLEAN_IDENTITY; + goto done; + } + close(target); + if (mkdirat(qfd, "root", 0700) != 0 || sync_directory(qfd) != 0 || + fstatat(qfd, "root", &st, AT_SYMLINK_NOFOLLOW) != 0) { + goto done; + } + placeholder = identity_of(st); + if (write_cleanup_state(qfd, token, expected, placeholder) != 0) { + goto done; + } + } else if (!read_cleanup_state(qfd, token, expected, &placeholder)) { + if (directory_empty(qfd)) { + goto done; + } + if (entry_identity(parent, name, expected) && fstatat(qfd, "root", &st, AT_SYMLINK_NOFOLLOW) == 0 && + S_ISDIR(st.st_mode)) { + int orphan = openat(qfd, "root", O_RDONLY | O_DIRECTORY | O_NOFOLLOW); + if (orphan >= 0 && directory_empty(orphan)) { + close(orphan); + if (unlinkat(qfd, "root", AT_REMOVEDIR) == 0 && sync_directory(qfd) == 0) { + close(qfd); + qfd = -1; + if (unlinkat(parent, quarantine, AT_REMOVEDIR) == 0 && sync_directory(parent) == 0) { + return cleanup_entry(parent, name, expected, token); + } + } + } else if (orphan >= 0) { + close(orphan); + } + } + goto done; + } + if (entry_identity(qfd, "root", placeholder)) { + if (!entry_identity(parent, name, expected)) { + if (unlinkat(qfd, "root", AT_REMOVEDIR) == 0 && sync_directory(qfd) == 0 && + unlinkat(qfd, "owner", 0) == 0 && sync_directory(qfd) == 0) { + close(qfd); + qfd = -1; + if (unlinkat(parent, quarantine, AT_REMOVEDIR) == 0) { + sync_directory(parent); + } + } + return CLEAN_IDENTITY; + } + cleanup_barrier("before-exchange"); + if (exchange_at(parent, name, qfd, "root") != 0 || sync_directory(parent) != 0 || sync_directory(qfd) != 0) { + goto done; + } + } + if (!entry_identity(qfd, "root", expected)) { + if (fstatat(qfd, "root", &st, AT_SYMLINK_NOFOLLOW) != 0 && errno == ENOENT && unlinkat(qfd, "owner", 0) == 0 && + sync_directory(qfd) == 0) { + close(qfd); + qfd = -1; + if (unlinkat(parent, quarantine, AT_REMOVEDIR) == 0 && sync_directory(parent) == 0) { + return CLEAN_OK; + } + } + goto done; + } + cleanup_barrier("after-exchange"); + root = openat(qfd, "root", O_RDONLY | O_DIRECTORY | O_NOFOLLOW); + if (root < 0 || !target_token(root, token)) { + goto done; + } + close(root); + root = -1; + if (entry_identity(parent, name, placeholder) && + (unlinkat(parent, name, AT_REMOVEDIR) != 0 || sync_directory(parent) != 0)) { + goto done; + } + cleanup_barrier("quarantined"); + root = openat(qfd, "root", O_RDONLY | O_DIRECTORY | O_NOFOLLOW); + if (root < 0 || fstat(root, &st) != 0 || !same(identity_of(st), expected)) { + goto done; + } + result = remove_contents(root); + close(root); + root = -1; + if (result != CLEAN_OK) { + goto done; + } + if (!entry_identity(qfd, "root", expected) || unlinkat(qfd, "root", AT_REMOVEDIR) != 0 || + sync_directory(qfd) != 0) { + goto done; + } + if (unlinkat(qfd, "owner", 0) != 0 || sync_directory(qfd) != 0) { + goto done; + } + if (unlinkat(parent, quarantine, AT_REMOVEDIR) != 0 || sync_directory(parent) != 0) { + goto done; + } + close(qfd); + return CLEAN_OK; +done: + if (root >= 0) { + close(root); + } + if (qfd >= 0) { + close(qfd); + } + return result; +} + +static int rollback_failure(const char *status) { + write_status(status); + return 5; +} +static int rollback_with_status(int lp, const char *ln, int rp, const char *rn, int staged_fd, int displaced_fd, + identity old_left, identity old_right, const char *token, const char *status) { + file_barrier("WP_CODEBOX_ROLLBACK_BARRIER"); + if (!entry_identity(rp, rn, old_left)) { + write_status("RIGHT_OWNERSHIP_CHANGED"); + return 4; + } + if (!entry_identity(lp, ln, old_right)) { + char quarantine[192]; + struct stat st; + identity empty, removed; + snprintf(quarantine, sizeof(quarantine), ".wp-codebox-failed-promotion-%llu-%llu", + (unsigned long long)old_left.dev, (unsigned long long)old_left.ino); + if (remove_target_token(displaced_fd, token) != 0) { + return rollback_failure("ROLLBACK_IO_FAILED"); + } + if (mkdirat(rp, quarantine, 0700) != 0 || fstatat(rp, quarantine, &st, AT_SYMLINK_NOFOLLOW) != 0) { + return rollback_failure("ROLLBACK_IO_FAILED"); + } + if (sync_directory(rp) != 0) { + return rollback_failure("ROLLBACK_SYNC_FAILED"); + } + empty = identity_of(st); + if (!entry_identity(rp, rn, old_left)) { + write_status("RIGHT_OWNERSHIP_CHANGED"); + return 4; + } + if (exchange_at(rp, quarantine, rp, rn) != 0) { + return rollback_failure("ROLLBACK_EXCHANGE_FAILED"); + } + if (sync_directory(rp) != 0) { + return rollback_failure("ROLLBACK_SYNC_FAILED"); + } + if (fstatat(rp, quarantine, &st, AT_SYMLINK_NOFOLLOW) != 0) { + return rollback_failure("ROLLBACK_IO_FAILED"); + } + removed = identity_of(st); + if (!same(removed, old_left) || !entry_identity(rp, rn, empty)) { + if (entry_identity(rp, rn, empty) && entry_identity(rp, quarantine, removed)) { + if (exchange_at(rp, rn, rp, quarantine) != 0) { + return rollback_failure("ROLLBACK_EXCHANGE_FAILED"); + } + if (sync_directory(rp) != 0) { + return rollback_failure("ROLLBACK_SYNC_FAILED"); + } + if (!entry_identity(rp, rn, removed) || !entry_identity(rp, quarantine, empty)) { + return rollback_failure("ROLLBACK_OWNERSHIP_CHANGED"); + } + } + return rollback_failure("ROLLBACK_OWNERSHIP_CHANGED"); + } + return rollback_failure("ROLLBACK_FAILED_LEFT_OWNERSHIP_CHANGED"); + } + if (remove_target_token(displaced_fd, token) != 0) { + return rollback_failure("ROLLBACK_IO_FAILED"); + } + if (!entry_identity(rp, rn, old_left)) { + write_status("RIGHT_OWNERSHIP_CHANGED"); + return 4; + } + if (!entry_identity(lp, ln, old_right)) { + return rollback_failure("ROLLBACK_FAILED_LEFT_OWNERSHIP_CHANGED"); + } + if (exchange_at(lp, ln, rp, rn) != 0) { + return rollback_failure("ROLLBACK_EXCHANGE_FAILED"); + } + if (sync_directory(lp) != 0 || (rp != lp && sync_directory(rp) != 0)) { + return rollback_failure("ROLLBACK_SYNC_FAILED"); + } + if (!entry_identity(rp, rn, old_right) || !entry_identity(lp, ln, old_left)) { + return rollback_failure("ROLLBACK_OWNERSHIP_CHANGED"); + } + if (ensure_target_token(staged_fd, token) != 0) { + return rollback_failure("ROLLBACK_IO_FAILED"); + } + write_status(status); + return 0; +} +static int rollback(int lp, const char *ln, int rp, const char *rn, int staged_fd, int displaced_fd, identity old_left, + identity old_right, const char *token) { + return rollback_with_status(lp, ln, rp, rn, staged_fd, displaced_fd, old_left, old_right, token, "ROLLED_BACK"); +} + +int main(int argc, char **argv) { + signal(SIGPIPE, SIG_IGN); + if (argc == 5 && !strcmp(argv[1], "--manifest")) { + int root = open_absolute_directory(argv[2]); + char digest[65]; + struct stat st; + identity expected = {(dev_t)strtoull(argv[3], NULL, 10), (ino_t)strtoull(argv[4], NULL, 10)}; + if (root < 0 || fstat(root, &st) || !same(identity_of(st), expected) || manifest(root, digest) != 0) { + if (root >= 0) { + close(root); + } + write_status("INVALID_STAGING"); + return 6; + } + dprintf(STDOUT_FILENO, "MANIFEST %s\n", digest); + close(root); + return 0; + } + if (argc == 6 && !strcmp(argv[1], "--snapshot")) { + int source = open_absolute_directory(argv[2]), destination = open_absolute_directory(argv[3]); + char digest[65]; + struct stat before, after; + identity expected = {(dev_t)strtoull(argv[4], NULL, 10), (ino_t)strtoull(argv[5], NULL, 10)}; + if (source < 0 || destination < 0 || fstat(source, &before) || !same(identity_of(before), expected) || + copy_snapshot_dir(source, destination) != 0 || fstat(source, &after) || !stable_metadata(before, after) || + manifest(destination, digest) != 0) { + if (source >= 0) { + close(source); + } + if (destination >= 0) { + close(destination); + } + write_status("INVALID_STAGING"); + return 6; + } + dprintf(STDOUT_FILENO, "SNAPSHOT %s\n", digest); + close(source); + close(destination); + return 0; + } + if (argc == 6 && !strcmp(argv[1], "--read")) { + int root = open_absolute_directory(argv[2]); + int file = root < 0 ? -1 : open_relative_file(root, argv[3]); + unsigned char buffer[65536]; + ssize_t got; + struct stat root_before, root_after, file_before, file_after; + identity expected = {(dev_t)strtoull(argv[4], NULL, 10), (ino_t)strtoull(argv[5], NULL, 10)}; + if (root < 0 || fstat(root, &root_before) || !same(identity_of(root_before), expected) || file < 0 || + fstat(file, &file_before) || !S_ISREG(file_before.st_mode)) { + return 8; + } + while ((got = read(file, buffer, sizeof(buffer))) > 0) { + ssize_t sent = 0; + while (sent < got) { + ssize_t n = write(STDOUT_FILENO, buffer + sent, (size_t)(got - sent)); + if (n <= 0) { + return 8; + } + sent += n; + } + } + { + const char *barrier = getenv("WP_CODEBOX_READ_BARRIER"); + if (barrier && *barrier) { + int marker = open(barrier, O_CREAT | O_EXCL | O_WRONLY | O_NOFOLLOW, 0600); + if (marker >= 0) { + close(marker); + while (access(barrier, F_OK) == 0) { + usleep(1000); + } + } + } + } + if (got < 0 || fstat(file, &file_after) || !stable_metadata(file_before, file_after) || + fstat(root, &root_after) || !stable_metadata(root_before, root_after) || + !relative_file_identity(root, argv[3], identity_of(file_before))) { + return 8; + } + return 0; + } + if (argc == 6 && !strcmp(argv[1], "--cleanup")) { + char *parent_path = NULL, *name = NULL; + identity expected = {(dev_t)strtoull(argv[3], NULL, 10), (ino_t)strtoull(argv[4], NULL, 10)}; + if (split_path(argv[2], &parent_path, &name)) { + return 2; + } + int parent = open_absolute_directory(parent_path); + enum cleanup_result cleaned = parent < 0 ? CLEAN_PENDING : cleanup_entry(parent, name, expected, argv[5]); + free(parent_path); + free(name); + if (parent >= 0) { + close(parent); + } + if (cleaned == CLEAN_IDENTITY) { + write_status("RIGHT_OWNERSHIP_CHANGED"); + return 4; + } + if (cleaned == CLEAN_PENDING) { + write_status("CLEANUP_PENDING"); + return 7; + } + write_status("CLEANED"); + return 0; + } + if (argc != 5 || strcmp(argv[1], "--transaction")) { + fprintf(stderr, "usage: atomic-directory-exchange --transaction \n"); + return 2; + } + secure_lock_handle lock = secure_lock(argv[2]); + if (lock.file < 0) { + perror("secure promotion lock"); + return 1; + } + char *lparent_path = NULL, *rparent_path = NULL, *ln = NULL, *rn = NULL; + if (split_path(argv[3], &lparent_path, &ln) || split_path(argv[4], &rparent_path, &rn)) { + return 2; + } + int lp = open_absolute_directory(lparent_path), rp = open_absolute_directory(rparent_path); + int left_fd = lp < 0 ? -1 : openat(lp, ln, O_RDONLY | O_DIRECTORY | O_NOFOLLOW), + right_fd = rp < 0 ? -1 : openat(rp, rn, O_RDONLY | O_DIRECTORY | O_NOFOLLOW); + struct stat ls, rs; + if (lp < 0 || rp < 0 || left_fd < 0 || right_fd < 0 || fstat(left_fd, &ls) || fstat(right_fd, &rs)) { + write_status("INVALID_DIRECTORY_ENTRY"); + return 6; + } + identity old_left = identity_of(ls), old_right = identity_of(rs); + char line[256], digest[65], current[65], token[81]; + dprintf(STDOUT_FILENO, "LOCKED %llu %llu %llu %llu\n", (unsigned long long)old_left.dev, + (unsigned long long)old_left.ino, (unsigned long long)old_right.dev, (unsigned long long)old_right.ino); + while (read_command(line, sizeof(line)) == 0) { + if (!strcmp(line, "MANIFEST")) { + if (manifest(left_fd, current)) { + write_status("INVALID_STAGING"); + } else { + dprintf(STDOUT_FILENO, "MANIFEST %s\n", current); + } + continue; + } + if (!strncmp(line, "SNAPSHOT ", 9)) { + int snapshot = open_absolute_directory(line + 9); + if (snapshot < 0 || copy_snapshot_dir(left_fd, snapshot) != 0 || manifest(snapshot, current) != 0) { + write_status("STAGING_CONTENT_CHANGED"); + } else { + dprintf(STDOUT_FILENO, "SNAPSHOT %s\n", current); + } + if (snapshot >= 0) { + close(snapshot); + } + continue; + } + if (!strncmp(line, "PROMOTE ", 8)) { + char extra; + if (sscanf(line + 8, "%64s %80s %c", digest, token, &extra) != 2 || strlen(digest) != 64 || + !valid_token(token)) { + write_status("INVALID_STAGING"); + continue; + } + if (!lock_continuous(lock)) { + write_status("DIRECTORY_LOCK_LOST"); + continue; + } + if (!entry_identity(lp, ln, old_left)) { + write_status("LEFT_OWNERSHIP_CHANGED"); + continue; + } + if (!entry_identity(rp, rn, old_right)) { + write_status("RIGHT_OWNERSHIP_CHANGED"); + continue; + } + if (manifest(left_fd, current) || strcmp(current, digest)) { + write_status("STAGING_CONTENT_CHANGED"); + continue; + } + if (ensure_target_token(left_fd, token) != 0) { + write_status("IO_FAILED"); + continue; + } + write_status("CHECKED"); + if (read_command(line, sizeof(line)) || strcmp(line, "EXCHANGE")) { + return 2; + } + if (!lock_continuous(lock)) { + write_status("DIRECTORY_LOCK_LOST"); + continue; + } + if (!entry_identity(lp, ln, old_left)) { + write_status("LEFT_OWNERSHIP_CHANGED"); + continue; + } + if (!entry_identity(rp, rn, old_right)) { + write_status("RIGHT_OWNERSHIP_CHANGED"); + continue; + } + if (sync_failure("staged-tree") || sync_manifest(left_fd, current) != 0) { + write_status("SYNC_FAILED"); + continue; + } + if (strcmp(current, digest) || !lock_continuous(lock) || !entry_identity(lp, ln, old_left) || + !entry_identity(rp, rn, old_right)) { + write_status("STAGING_CONTENT_CHANGED"); + continue; + } + if (exchange_at(lp, ln, rp, rn) != 0) { + write_status("EXCHANGE_FAILED"); + continue; + } + if (sync_failure("exchange-parent") || sync_directory(lp) != 0 || (rp != lp && sync_directory(rp) != 0)) { + return rollback_with_status(lp, ln, rp, rn, left_fd, right_fd, old_left, old_right, token, + "ROLLED_BACK SYNC_FAILED"); + } + if (!entry_identity(rp, rn, old_left) || !entry_identity(lp, ln, old_right) || manifest(left_fd, current) || + strcmp(current, digest)) { + return rollback_with_status(lp, ln, rp, rn, left_fd, right_fd, old_left, old_right, token, + "ROLLED_BACK STAGING_CONTENT_CHANGED"); + } + if (remove_target_token(left_fd, token) != 0 || write_target_token(right_fd, token) != 0) { + return rollback_with_status(lp, ln, rp, rn, left_fd, right_fd, old_left, old_right, token, + "ROLLED_BACK IO_FAILED"); + } + if (write_status("PROMOTED") != 0) { + return rollback(lp, ln, rp, rn, left_fd, right_fd, old_left, old_right, token); + } + if (read_command(line, sizeof(line))) { + return rollback(lp, ln, rp, rn, left_fd, right_fd, old_left, old_right, token); + } + if (!strcmp(line, "ROLLBACK")) { + return rollback(lp, ln, rp, rn, left_fd, right_fd, old_left, old_right, token); + } + if (strcmp(line, "COMMIT")) { + return 2; + } + if (!lock_continuous(lock)) { + return rollback_with_status(lp, ln, rp, rn, left_fd, right_fd, old_left, old_right, token, + "ROLLED_BACK DIRECTORY_LOCK_LOST"); + } + if (!entry_identity(rp, rn, old_left)) { + write_status("RIGHT_OWNERSHIP_CHANGED"); + return 4; + } + if (!entry_identity(lp, ln, old_right) || manifest(left_fd, current) || strcmp(current, digest)) { + return rollback(lp, ln, rp, rn, left_fd, right_fd, old_left, old_right, token); + } + write_status("FINAL_MANIFEST"); + if (read_command(line, sizeof(line)) || strcmp(line, "FINALIZE")) { + return rollback(lp, ln, rp, rn, left_fd, right_fd, old_left, old_right, token); + } + if (manifest(left_fd, current) || strcmp(current, digest)) { + return rollback(lp, ln, rp, rn, left_fd, right_fd, old_left, old_right, token); + } + file_barrier("WP_CODEBOX_FINALIZE_BARRIER"); + if (manifest(left_fd, current) || strcmp(current, digest)) { + return rollback(lp, ln, rp, rn, left_fd, right_fd, old_left, old_right, token); + } + if (!lock_continuous(lock)) { + return rollback_with_status(lp, ln, rp, rn, left_fd, right_fd, old_left, old_right, token, + "ROLLED_BACK DIRECTORY_LOCK_LOST"); + } + if (!entry_identity(rp, rn, old_left)) { + write_status("RIGHT_OWNERSHIP_CHANGED"); + return 4; + } + if (!entry_identity(lp, ln, old_right)) { + return rollback(lp, ln, rp, rn, left_fd, right_fd, old_left, old_right, token); + } + write_status("COMMITTED"); + if (read_command(line, sizeof(line)) || strncmp(line, "CLEANUP ", 8)) { + write_status("CLEANUP_PENDING"); + return 7; + } + enum cleanup_result cleaned = cleanup_entry(lp, ln, old_right, line + 8); + if (cleaned == CLEAN_IDENTITY) { + write_status("RIGHT_OWNERSHIP_CHANGED"); + return 4; + } + if (cleaned == CLEAN_PENDING) { + write_status("CLEANUP_PENDING"); + return 7; + } + write_status("CLEANED"); + return 0; + } + if (!strcmp(line, "ABORT")) { + return 0; + } + return 2; + } + close(lock.file); + close(lock.parent); + free(lock.name); + return 0; +} diff --git a/scripts/derive-cloudflare-core-contract.mjs b/scripts/derive-cloudflare-core-contract.mjs new file mode 100644 index 000000000..230b6b077 --- /dev/null +++ b/scripts/derive-cloudflare-core-contract.mjs @@ -0,0 +1,713 @@ +import assert from "node:assert/strict" +import { createHash, randomUUID } from "node:crypto" +import { execFile, spawn } from "node:child_process" +import { constants } from "node:fs" +import { access, lstat, mkdir, mkdtemp, open, readFile, readdir, realpath, rename, rm, stat, writeFile } from "node:fs/promises" +import { tmpdir } from "node:os" +import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path" +import { fileURLToPath, pathToFileURL } from "node:url" +import { promisify } from "node:util" + +const execFileAsync = promisify(execFile) +const repositoryRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..") +const cloudflareRoot = resolve(repositoryRoot, "packages/runtime-cloudflare") +const vendorRoot = resolve(cloudflareRoot, "vendor/wp-codebox-core") +const stagePrefix = ".runtime-cloudflare-core-stage-" +const stageLeasePrefix = ".runtime-cloudflare-core-stage-lease-" +const staleStageAgeMs = 24 * 60 * 60 * 1_000 +export const cloudflareStageParent = dirname(cloudflareRoot) +let fileReaderHelper + +export async function deriveCloudflareCoreContract({ write = false } = {}) { + const cloudflarePackage = JSON.parse(await readFile(resolve(cloudflareRoot, "package.json"), "utf8")) + const version = cloudflarePackage.wpCodeboxCoreCompatibility + const sourceCommit = cloudflarePackage.wpCodeboxCoreSourceCommit + assert.match(version, /^\d+\.\d+\.\d+$/, "Cloudflare core compatibility must be an exact release version") + assert.match(sourceCommit, /^[a-f0-9]{40}$/, "Cloudflare core source must be pinned to an exact commit") + const tag = `v${version}` + const tagCommit = (await git(["rev-parse", `${tag}^{commit}`])).trim() + assert.equal(tagCommit, sourceCommit, `${tag} must resolve to the pinned source commit`) + const tagPackage = JSON.parse(await git(["show", `${tag}:packages/runtime-core/package.json`])) + const tagLock = JSON.parse(await git(["show", `${tag}:npm-shrinkwrap.json`])) + const compilerVersion = tagLock.packages?.["node_modules/typescript"]?.version + assert.equal(tagPackage.name, "@automattic/wp-codebox-core") + assert.equal(tagPackage.version, version, `${tag} must own the configured core version`) + assert.match(compilerVersion, /^\d+\.\d+\.\d+$/, `${tag} must lock its TypeScript compiler`) + + const temporaryRoot = await mkdtemp(join(tmpdir(), "wp-codebox-core-contract-")) + const sourceRoot = resolve(temporaryRoot, "source") + let generatedSnapshotRoot + try { + await git(["worktree", "add", "--detach", sourceRoot, tagCommit]) + await execFileAsync("npm", ["ci", "--ignore-scripts"], { cwd: sourceRoot, maxBuffer: 1024 * 1024 * 20 }) + const installedCompiler = JSON.parse(await readFile(resolve(sourceRoot, "node_modules/typescript/package.json"), "utf8")) + assert.equal(installedCompiler.version, compilerVersion, `${tag} must be derived with its locked TypeScript compiler`) + await execFileAsync(process.execPath, [resolve(sourceRoot, "node_modules/typescript/bin/tsc"), "-p", resolve(sourceRoot, "packages/runtime-core/tsconfig.json"), "--pretty", "false"], { + cwd: sourceRoot, + maxBuffer: 1024 * 1024 * 20, + }) + + const generatedRoot = resolve(sourceRoot, "packages/runtime-core/dist") + const generatedGeneration = await snapshotGeneratedTree(generatedRoot) + generatedSnapshotRoot = generatedGeneration.root + const pinnedGeneratedRoot = generatedGeneration.root + const generatedFiles = await contractFilesFromSnapshot(pinnedGeneratedRoot, generatedGeneration.manifest) + let promotion + assert.ok(generatedFiles.includes("runtime-archive-component.js")) + assert.ok(generatedFiles.includes("runtime-archive-component.d.ts")) + assert.ok(generatedFiles.includes("runtime-package-profile.js")) + assert.ok(generatedFiles.includes("runtime-package-profile.d.ts")) + assert.ok(generatedFiles.includes("runtime-command-result.js")) + assert.ok(generatedFiles.includes("runtime-command-result.d.ts")) + + if (write) { + await reclaimStaleStages(cloudflareStageParent) + const stagedRoot = await mkdtemp(resolve(cloudflareStageParent, `${stagePrefix}${process.pid}-`)) + const stageLease = await createStageLease(stagedRoot) + try { + for (const file of generatedFiles) { + const target = resolve(stagedRoot, file) + await mkdir(dirname(target), { recursive: true }) + await copyContainedRegularFile(pinnedGeneratedRoot, file, target) + } + await writeFile(resolve(stagedRoot, "package.json"), `${JSON.stringify(compatibilityPackage(version), null, 2)}\n`) + promotion = await promoteValidatedDirectory({ + stagedRoot, + destinationRoot: vendorRoot, + stageLease, + validate: (validatedRoot, candidateManifest) => assertContractTree(validatedRoot, pinnedGeneratedRoot, generatedFiles, version, tag, { candidateManifest, generatedManifest: generatedGeneration.manifest }), + }) + if (promotion.outcome === "committed") await removeLease(stageLease.cleanupLease) + else promotion = { ...promotion, cleanupLease: stageLease.cleanupLease } + } finally { + if (!promotion) { + await resumePromotedCleanup(stageLease) + } + } + } else { + await assertContractTree(vendorRoot, pinnedGeneratedRoot, generatedFiles, version, tag, { generatedManifest: generatedGeneration.manifest }) + } + return { tag, tagCommit, compilerVersion, generatedRoot, promotion } + } finally { + if (generatedSnapshotRoot) await rm(generatedSnapshotRoot, { recursive: true, force: true }) + await git(["worktree", "remove", "--force", sourceRoot], true) + await rm(temporaryRoot, { recursive: true, force: true }) + } +} + +function cleanupPendingResult(cleanupPath, dev, ino, stageLease, cleanupToken = stageLease?.cleanupToken ?? randomUUID()) { + return { + outcome: "promoted_cleanup_pending", + cleanupPath, + cleanupIdentity: { dev, ino }, + ...(stageLease?.cleanupFallbackIdentity ? { cleanupFallbackIdentity: stageLease.cleanupFallbackIdentity } : {}), + ...(stageLease?.cleanupLease ? { cleanupLease: stageLease.cleanupLease } : {}), + cleanupToken, + } +} + +export async function promoteValidatedDirectory({ stagedRoot, destinationRoot, stageLease, validate, fault = async () => {}, nativeFault = async () => {}, snapshotBarrier, finalizeBarrier, syncFailure }) { + const helperRoot = await mkdtemp(join(tmpdir(), "wp-codebox-atomic-exchange-")) + const helper = resolve(helperRoot, "atomic-directory-exchange") + let transaction + let validationRoot + try { + await execFileAsync("cc", ["-Wall", "-Wextra", "-Werror", resolve(repositoryRoot, "scripts/atomic-directory-exchange.c"), "-o", helper]) + await fault("before-lock") + const canonicalDestinationRoot = await canonicalDestinationPath(destinationRoot) + const canonicalStagedRoot = await canonicalExistingDirectoryPath(stagedRoot, "staging") + const lockDirectory = resolve(await realpath(tmpdir()), `wp-codebox-directory-exchange-${process.getuid?.() ?? "user"}-${createHash("sha256").update(canonicalDestinationRoot).digest("hex")}`) + transaction = nativeTransaction(helper, lockDirectory, canonicalStagedRoot, canonicalDestinationRoot, { snapshotBarrier, finalizeBarrier, syncFailure }) + const locked = await expectNative(transaction, "LOCKED") + const [, stageDev, stageIno, cleanupDev, cleanupIno] = locked.split(" ") + if (stageLease) { + stageLease.cleanupIdentity = { dev: cleanupDev, ino: cleanupIno } + stageLease.cleanupFallbackIdentity = { dev: stageDev, ino: stageIno } + await persistStageLease(stageLease) + } + + const beforeValidation = await nativeManifest(transaction, stagedRoot) + validationRoot = await mkdtemp(join(tmpdir(), "wp-codebox-validation-generation-")) + validationRoot = await realpath(validationRoot) + transaction.send(`SNAPSHOT ${validationRoot}`) + const snapshotOutcome = await expectNative(transaction, "SNAPSHOT", { stagedRoot, destinationRoot }) + const snapshotManifest = snapshotOutcome.slice(9) + if (!/^[a-f0-9]{64}$/.test(snapshotManifest)) throw nativeOutcomeError(snapshotOutcome, stagedRoot, destinationRoot) + if (await treeManifest(validationRoot) !== snapshotManifest) throw new DirectoryPromotionError("STAGING_CONTENT_CHANGED", `validation snapshot changed before validation: ${stagedRoot}`) + await validate(validationRoot, snapshotManifest) + if (await treeManifest(validationRoot) !== snapshotManifest) throw new DirectoryPromotionError("STAGING_CONTENT_CHANGED", `validation snapshot changed during validation: ${stagedRoot}`) + const validatedManifest = await nativeManifest(transaction, stagedRoot) + if (validatedManifest !== beforeValidation) throw new DirectoryPromotionError("STAGING_CONTENT_CHANGED", `staging contents changed during validation: ${stagedRoot}`) + if (snapshotManifest !== validatedManifest) throw new DirectoryPromotionError("STAGING_CONTENT_CHANGED", `validated snapshot does not match staging contents: ${stagedRoot}`) + await fault("after-validation") + await fault("before-promotion") + + const cleanupToken = stageLease?.cleanupToken ?? randomUUID() + transaction.send(`PROMOTE ${validatedManifest} ${cleanupToken}`) + await expectNative(transaction, "CHECKED") + await nativeFault("helper-checked") + transaction.send("EXCHANGE") + await expectNative(transaction, "PROMOTED", { stagedRoot, destinationRoot }) + await nativeFault("after-promoted") + try { + await fault("after-promotion") + } catch (cause) { + transaction.send("ROLLBACK") + const outcome = await transaction.next() + if (outcome === "ROLLED_BACK") throw cause + throw nativeOutcomeError(outcome, stagedRoot, destinationRoot, cause) + } + + transaction.send("COMMIT") + await expectNative(transaction, "FINAL_MANIFEST", { stagedRoot, destinationRoot }) + await nativeFault("after-final-manifest") + transaction.send("FINALIZE") + const commitOutcome = await transaction.next() + if (commitOutcome === "ROLLED_BACK") throw new DirectoryPromotionError("STAGING_CONTENT_CHANGED", `promoted contents changed before commit: ${destinationRoot}`) + if (commitOutcome !== "COMMITTED") throw nativeOutcomeError(commitOutcome, stagedRoot, destinationRoot) + + try { + await nativeFault("before-cleanup") + } catch { + transaction.send("LEAVE") + await expectNative(transaction, "CLEANUP_PENDING") + return cleanupPendingResult(canonicalStagedRoot, cleanupDev, cleanupIno, stageLease, cleanupToken) + } + transaction.send(`CLEANUP ${cleanupToken}`) + const cleanupOutcome = await transaction.next() + if (cleanupOutcome === "CLEANUP_PENDING") return cleanupPendingResult(canonicalStagedRoot, cleanupDev, cleanupIno, stageLease, cleanupToken) + if (cleanupOutcome !== "CLEANED") throw nativeOutcomeError(cleanupOutcome, stagedRoot, destinationRoot) + return { outcome: "committed" } + } finally { + await transaction?.close() + if (validationRoot) await rm(validationRoot, { recursive: true, force: true }) + await rm(helperRoot, { recursive: true, force: true }) + } +} + +export async function resumePromotedCleanup({ cleanupPath, cleanupIdentity, cleanupFallbackIdentity, cleanupLease, cleanupToken, cleanupBarrier, cleanupBarrierPoint }) { + const helperRoot = await mkdtemp(join(tmpdir(), "wp-codebox-atomic-cleanup-")) + const helper = resolve(helperRoot, "atomic-directory-exchange") + try { + await execFileAsync("cc", ["-Wall", "-Wextra", "-Werror", resolve(repositoryRoot, "scripts/atomic-directory-exchange.c"), "-o", helper]) + const canonicalCleanupPath = resolve(await realpath(dirname(cleanupPath)), basename(cleanupPath)) + try { + if (!cleanupToken) throw new DirectoryPromotionError("CLEANUP_PENDING", `cleanup ownership token is required: ${canonicalCleanupPath}`) + const { stdout } = await execFileAsync(helper, ["--cleanup", canonicalCleanupPath, String(cleanupIdentity.dev), String(cleanupIdentity.ino), cleanupToken], { + env: { ...process.env, ...(cleanupBarrier ? { WP_CODEBOX_CLEANUP_BARRIER: cleanupBarrier } : {}), ...(cleanupBarrierPoint ? { WP_CODEBOX_CLEANUP_BARRIER_POINT: cleanupBarrierPoint } : {}) }, + }) + if (stdout.trim() !== "CLEANED") throw nativeOutcomeError(stdout.trim(), canonicalCleanupPath, "") + if (cleanupLease) await removeLease(cleanupLease) + return { outcome: "cleaned" } + } catch (cause) { + if (cause.stdout?.trim() === "RIGHT_OWNERSHIP_CHANGED" && cleanupFallbackIdentity) { + const resumed = await resumePromotedCleanup({ cleanupPath: canonicalCleanupPath, cleanupIdentity: cleanupFallbackIdentity, cleanupLease, cleanupToken, cleanupBarrier, cleanupBarrierPoint }) + return resumed.outcome === "promoted_cleanup_pending" ? { ...resumed, cleanupFallbackIdentity } : resumed + } + if (cause.stdout?.trim() === "RIGHT_OWNERSHIP_CHANGED") throw nativeOutcomeError("RIGHT_OWNERSHIP_CHANGED", canonicalCleanupPath, "", cause) + if (cause.stdout?.trim() === "CLEANUP_PENDING") return { outcome: "promoted_cleanup_pending", cleanupPath: canonicalCleanupPath, cleanupIdentity, ...(cleanupFallbackIdentity ? { cleanupFallbackIdentity } : {}), ...(cleanupLease ? { cleanupLease } : {}), cleanupToken } + throw cause + } + } finally { + await rm(helperRoot, { recursive: true, force: true }) + } +} + +function nativeTransaction(helper, lock, stagedRoot, destinationRoot, { snapshotBarrier, finalizeBarrier, syncFailure }) { + const holder = spawn(helper, ["--transaction", lock, stagedRoot, destinationRoot], { + stdio: ["pipe", "pipe", "pipe"], + env: { + ...process.env, + ...(snapshotBarrier ? { WP_CODEBOX_SNAPSHOT_BARRIER: snapshotBarrier } : {}), + ...(finalizeBarrier ? { WP_CODEBOX_FINALIZE_BARRIER: finalizeBarrier } : {}), + ...(syncFailure ? { WP_CODEBOX_SYNC_FAILURE: syncFailure } : {}), + }, + }) + let stderr = "" + holder.stderr.setEncoding("utf8") + holder.stderr.on("data", (chunk) => { stderr += chunk }) + const lines = [] + const waiters = [] + let buffer = "" + let closed + holder.stdout.setEncoding("utf8") + holder.stdout.on("data", (chunk) => { + buffer += chunk + while (buffer.includes("\n")) { + const line = buffer.slice(0, buffer.indexOf("\n")) + buffer = buffer.slice(buffer.indexOf("\n") + 1) + const waiter = waiters.shift() + if (waiter) waiter.resolve(line) + else lines.push(line) + } + }) + const closePromise = new Promise((resolveClose) => holder.once("close", (code) => { + closed = code + for (const waiter of waiters.splice(0)) waiter.reject(new Error(`native promotion transaction exited with ${code}: ${stderr}`)) + resolveClose(code) + })) + return { + send(command) { holder.stdin.write(`${command}\n`) }, + next() { + if (lines.length) return Promise.resolve(lines.shift()) + if (closed !== undefined) return Promise.reject(new Error(`native promotion transaction exited with ${closed}: ${stderr}`)) + return new Promise((resolveLine, rejectLine) => waiters.push({ resolve: resolveLine, reject: rejectLine })) + }, + async close() { + if (closed === undefined) holder.stdin.end() + await closePromise + }, + } +} + +async function nativeManifest(transaction, stagedRoot) { + transaction.send("MANIFEST") + const outcome = await transaction.next() + if (outcome.startsWith("MANIFEST ")) return outcome.slice(9) + throw nativeOutcomeError(outcome, stagedRoot, "") +} + +async function expectNative(transaction, expected, paths = {}) { + const outcome = await transaction.next() + if (outcome === expected || outcome.startsWith(`${expected} `)) return outcome + throw nativeOutcomeError(outcome, paths.stagedRoot, paths.destinationRoot) +} + +function nativeOutcomeError(outcome, stagedRoot, destinationRoot, cause) { + const nativeCode = outcome.split(" ").at(-1) + const codes = { + LEFT_OWNERSHIP_CHANGED: "STAGING_OWNERSHIP_CHANGED", + RIGHT_OWNERSHIP_CHANGED: "RIGHT_OWNERSHIP_CHANGED", + STAGING_CONTENT_CHANGED: "STAGING_CONTENT_CHANGED", + INVALID_STAGING: "INVALID_DIRECTORY_ENTRY", + INVALID_DIRECTORY_ENTRY: "INVALID_DIRECTORY_ENTRY", + ROLLBACK_FAILED: "ROLLBACK_FAILED", + ROLLBACK_FAILED_LEFT_OWNERSHIP_CHANGED: "ROLLBACK_FAILED_LEFT_OWNERSHIP_CHANGED", + ROLLBACK_OWNERSHIP_CHANGED: "ROLLBACK_OWNERSHIP_CHANGED", + ROLLBACK_IO_FAILED: "ROLLBACK_IO_FAILED", + ROLLBACK_SYNC_FAILED: "ROLLBACK_SYNC_FAILED", + ROLLBACK_EXCHANGE_FAILED: "ROLLBACK_EXCHANGE_FAILED", + SYNC_FAILED: "SYNC_FAILED", + IO_FAILED: "IO_FAILED", + DIRECTORY_LOCK_LOST: "DIRECTORY_LOCK_LOST", + CLEANUP_PENDING: "CLEANUP_PENDING", + } + const code = codes[nativeCode] ?? "ATOMIC_EXCHANGE_FAILED" + return new DirectoryPromotionError(code, `native directory promotion reported ${outcome}${cause?.message ? ` after ${cause.message}` : ""}: ${stagedRoot ?? ""} -> ${destinationRoot ?? ""}`, { cause }) +} + +async function canonicalDestinationPath(path) { + const absolute = resolve(path) + try { + const entry = await lstat(absolute) + if (entry.isSymbolicLink() || !entry.isDirectory()) { + throw new DirectoryPromotionError("INVALID_DIRECTORY_ENTRY", `destination entry must be a directory and not a symlink: ${path}`) + } + return await realpath(absolute) + } catch (cause) { + if (cause instanceof DirectoryPromotionError) throw cause + if (cause?.code !== "ENOENT") throw cause + const parent = dirname(absolute) + const canonicalParent = await realpath(parent) + const parentEntry = await stat(canonicalParent) + if (!parentEntry.isDirectory()) throw new DirectoryPromotionError("INVALID_DIRECTORY_ENTRY", `destination parent must resolve to a directory: ${parent}`, { cause }) + return resolve(canonicalParent, basename(absolute)) + } +} + +async function canonicalExistingDirectoryPath(path, role) { + await directoryIdentity(path, role) + return realpath(path) +} + +export class DirectoryPromotionError extends Error { + constructor(code, message, options) { + super(message, options) + this.name = "DirectoryPromotionError" + this.code = code + } +} + +async function directoryIdentity(path, role) { + let stat + try { + stat = await lstat(path, { bigint: true }) + } catch (cause) { + throw new DirectoryPromotionError("INVALID_DIRECTORY_ENTRY", `${role} entry must be an existing directory: ${path}`, { cause }) + } + if (stat.isSymbolicLink() || !stat.isDirectory()) { + throw new DirectoryPromotionError("INVALID_DIRECTORY_ENTRY", `${role} entry must be a directory and not a symlink: ${path}`) + } + return { dev: stat.dev, ino: stat.ino } +} + +function sameIdentity(left, right) { + return left.dev === right.dev && left.ino === right.ino +} + +async function copyContainedRegularFile(root, file, target) { + await writeFile(target, await readContainedRegularFile(root, file)) +} + +async function openContainedRegularFile(root, file) { + const canonicalRoot = await realpath(root) + let current = canonicalRoot + for (const component of file.split(/[\\/]/)) { + if (!component || component === "." || component === "..") { + throw new DirectoryPromotionError("GENERATED_IMPORT_ESCAPE", `generated file path is not canonical: ${file}`) + } + current = resolve(current, component) + const entry = await lstat(current) + if (entry.isSymbolicLink()) throw new DirectoryPromotionError("GENERATED_SOURCE_SYMLINK", `generated source must not use symlinks: ${file}`) + } + const canonicalSource = await realpath(current) + if (!isContainedPath(canonicalRoot, canonicalSource)) { + throw new DirectoryPromotionError("GENERATED_IMPORT_ESCAPE", `generated source escapes its canonical root: ${file}`) + } + const sourceEntry = await lstat(current, { bigint: true }) + if (!sourceEntry.isFile()) throw new DirectoryPromotionError("INVALID_DIRECTORY_ENTRY", `generated source must be a regular file: ${file}`) + const handle = await open(current, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0)) + const openedEntry = await handle.stat({ bigint: true }) + if (!openedEntry.isFile() || !sameIdentity(sourceEntry, openedEntry)) { + await handle.close() + throw new DirectoryPromotionError("GENERATED_SOURCE_CHANGED", `generated source changed while it was opened: ${file}`) + } + return handle +} + +async function readContainedRegularFile(root, file, encoding, expectedRootIdentity) { + try { + const helper = await fileReader() + const canonicalRoot = await realpath(root) + const options = typeof expectedRootIdentity === "object" && "identity" in expectedRootIdentity ? expectedRootIdentity : { identity: expectedRootIdentity } + const rootIdentity = options.identity ?? await directoryIdentity(canonicalRoot, "generated source root") + const { stdout } = await execFileAsync(helper, ["--read", canonicalRoot, file, String(rootIdentity.dev), String(rootIdentity.ino)], { + encoding: encoding ?? null, + maxBuffer: 1024 * 1024 * 20, + env: { ...process.env, ...(options.readBarrier ? { WP_CODEBOX_READ_BARRIER: options.readBarrier } : {}) }, + }) + return stdout + } catch (cause) { + if (cause instanceof DirectoryPromotionError) throw cause + throw new DirectoryPromotionError("GENERATED_SOURCE_CHANGED", `generated source could not be read without following links: ${file}`, { cause }) + } +} + +async function fileReader() { + fileReaderHelper ??= (async () => { + const root = await mkdtemp(join(tmpdir(), "wp-codebox-file-reader-")) + const helper = resolve(root, "atomic-directory-exchange") + await execFileAsync("cc", ["-Wall", "-Wextra", "-Werror", resolve(repositoryRoot, "scripts/atomic-directory-exchange.c"), "-o", helper]) + return helper + })() + return fileReaderHelper +} + +function isContainedPath(root, candidate) { + const path = relative(root, candidate) + return path !== ".." && !path.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) && !isAbsolute(path) +} + +export async function reclaimStaleStages(parent) { + for (const entry of await readdir(parent, { withFileTypes: true })) { + if (!entry.name.startsWith(stageLeasePrefix) || !entry.isFile()) continue + const cleanupLease = resolve(parent, entry.name) + const leaseStat = await lstat(cleanupLease) + if (!leaseStat.isFile() || leaseStat.isSymbolicLink() || leaseStat.uid !== process.getuid?.() || (leaseStat.mode & 0o777) !== 0o600) continue + let lease + try { lease = JSON.parse(await readFile(cleanupLease, "utf8")) } catch { continue } + if (typeof lease.name !== "string" || basename(lease.name) !== lease.name || !lease.name.startsWith(stagePrefix) || typeof lease.token !== "string" || !/^[A-Za-z0-9-]{1,80}$/.test(lease.token)) continue + const pid = Number(lease.pid) + const age = Date.now() - Number(lease.createdAt) + if (age < staleStageAgeMs && (pid === process.pid || processIsAlive(pid))) continue + try { + await resumePromotedCleanup({ + cleanupPath: resolve(parent, lease.name), + cleanupIdentity: { dev: lease.displacedDev ?? lease.dev, ino: lease.displacedIno ?? lease.ino }, + cleanupFallbackIdentity: lease.displacedDev ? { dev: lease.dev, ino: lease.ino } : undefined, + cleanupLease, + cleanupToken: lease.token, + }) + } catch (error) { + if (!(error instanceof DirectoryPromotionError) || error.code !== "RIGHT_OWNERSHIP_CHANGED") throw error + } + } +} + +export async function createStageLease(stagePath, { createdAt = Date.now(), pid = process.pid } = {}) { + const canonicalParent = await realpath(dirname(stagePath)) + const name = basename(stagePath) + if (!name.startsWith(stagePrefix)) throw new DirectoryPromotionError("INVALID_DIRECTORY_ENTRY", `stage name is not owned by the derivation: ${stagePath}`) + const cleanupIdentity = await directoryIdentity(resolve(canonicalParent, name), "staging") + const cleanupLease = resolve(canonicalParent, `${stageLeasePrefix}${randomUUID()}`) + const stageLease = { cleanupPath: resolve(canonicalParent, name), cleanupIdentity, cleanupLease, cleanupToken: randomUUID(), pid, createdAt } + const tokenPath = resolve(stageLease.cleanupPath, ".wp-codebox-cleanup-token") + const token = await open(tokenPath, constants.O_CREAT | constants.O_EXCL | constants.O_WRONLY | (constants.O_NOFOLLOW ?? 0), 0o600) + try { + await token.writeFile(`${stageLease.cleanupToken}\n`) + await token.sync() + } finally { + await token.close() + } + await syncParent(tokenPath) + await persistStageLease(stageLease, true) + return stageLease +} + +async function persistStageLease(stageLease, exclusive = false) { + const temporary = `${stageLease.cleanupLease}.tmp-${randomUUID()}` + const record = { + name: basename(stageLease.cleanupPath), + dev: String(stageLease.cleanupFallbackIdentity?.dev ?? stageLease.cleanupIdentity.dev), + ino: String(stageLease.cleanupFallbackIdentity?.ino ?? stageLease.cleanupIdentity.ino), + ...(stageLease.cleanupFallbackIdentity ? { displacedDev: String(stageLease.cleanupIdentity.dev), displacedIno: String(stageLease.cleanupIdentity.ino) } : {}), + token: stageLease.cleanupToken, + pid: stageLease.pid ?? process.pid, + createdAt: stageLease.createdAt ?? Date.now(), + } + if (exclusive && await exists(stageLease.cleanupLease)) throw new DirectoryPromotionError("INVALID_DIRECTORY_ENTRY", `stage lease already exists: ${stageLease.cleanupLease}`) + const lease = await open(temporary, constants.O_CREAT | constants.O_EXCL | constants.O_WRONLY, 0o600) + try { + await lease.writeFile(`${JSON.stringify(record)}\n`) + await lease.sync() + } finally { + await lease.close() + } + await rename(temporary, stageLease.cleanupLease) + await syncParent(stageLease.cleanupLease) +} + +async function syncParent(path) { + const parent = await open(dirname(path), constants.O_RDONLY) + try { await parent.sync() } finally { await parent.close() } +} + +async function removeLease(path) { + await rm(path) + await syncParent(path) +} + +function processIsAlive(pid) { + if (!Number.isSafeInteger(pid) || pid <= 0) return false + try { + process.kill(pid, 0) + return true + } catch (error) { + return error?.code === "EPERM" + } +} + +async function assertContractTree(candidateRoot, generatedRoot, generatedFiles, version, tag, { candidateManifest, generatedManifest } = {}) { + const candidateBefore = await treeManifest(candidateRoot) + const generatedBefore = await treeManifest(generatedRoot) + if (candidateManifest && candidateBefore !== candidateManifest) throw new DirectoryPromotionError("STAGING_CONTENT_CHANGED", `candidate snapshot changed before validation: ${candidateRoot}`) + if (generatedManifest && generatedBefore !== generatedManifest) throw new DirectoryPromotionError("GENERATED_SOURCE_CHANGED", `generated snapshot changed before validation: ${generatedRoot}`) + const candidateFiles = (await filesBelow(candidateRoot)).filter((file) => file !== "package.json") + assert.deepEqual(candidateFiles, generatedFiles, "vendored core files must be the complete generated contract dependency closure") + for (const file of generatedFiles) { + assert.deepEqual(await readContainedRegularFile(candidateRoot, file), await readContainedRegularFile(generatedRoot, file), `vendored core contract drifted from ${tag}: ${file}`) + } + const candidatePackage = JSON.parse(await readContainedRegularFile(candidateRoot, "package.json", "utf8")) + assert.deepEqual(candidatePackage, compatibilityPackage(version), "vendored package metadata must expose only the selected generated release contracts") + await assertContractBehavior(candidateRoot, generatedRoot) + if (await treeManifest(candidateRoot) !== candidateBefore) throw new DirectoryPromotionError("STAGING_CONTENT_CHANGED", `candidate snapshot changed during validation: ${candidateRoot}`) + if (await treeManifest(generatedRoot) !== generatedBefore) throw new DirectoryPromotionError("GENERATED_SOURCE_CHANGED", `generated snapshot changed during validation: ${generatedRoot}`) +} + +function compatibilityPackage(version) { + const contract = (file) => ({ types: `./${file}.d.ts`, import: `./${file}.js`, default: `./${file}.js` }) + return { + name: "@automattic/wp-codebox-core", + version, + type: "module", + exports: { + "./package.json": "./package.json", + "./runtime-archive-component": contract("runtime-archive-component"), + "./runtime-package-profile": contract("runtime-package-profile"), + "./runtime-command-result": contract("runtime-command-result"), + }, + } +} + +async function filesBelow(root) { + const files = [] + async function visit(directory) { + for (const entry of await readdir(directory)) { + const path = resolve(directory, entry) + const stat = await lstat(path) + if (stat.isDirectory()) await visit(path) + else files.push(relative(root, path)) + } + } + await visit(root) + return files.sort() +} + +export async function contractFiles(root, options = {}) { + const generation = await snapshotGeneratedTree(root, options) + try { + return await contractFilesFromSnapshot(generation.root, generation.manifest) + } finally { + await rm(generation.root, { recursive: true, force: true }) + } +} + +async function snapshotGeneratedTree(root, { fault = async () => {}, readBarrier } = {}) { + const canonicalRoot = await realpath(root) + const rootIdentity = await directoryIdentity(canonicalRoot, "generated source root") + await assertNoGeneratedSymlinks(canonicalRoot, canonicalRoot) + await fault("source-root-opened") + const snapshotRoot = await mkdtemp(join(tmpdir(), "wp-codebox-generated-generation-")) + try { + const helper = await fileReader() + const canonicalSnapshotRoot = await realpath(snapshotRoot) + const { stdout } = await execFileAsync(helper, ["--snapshot", canonicalRoot, canonicalSnapshotRoot, String(rootIdentity.dev), String(rootIdentity.ino)], { + encoding: "utf8", + maxBuffer: 1024 * 1024 * 20, + env: { ...process.env, ...(readBarrier ? { WP_CODEBOX_SNAPSHOT_BARRIER: readBarrier } : {}) }, + }) + const outcome = stdout.trim() + if (!/^SNAPSHOT [a-f0-9]{64}$/.test(outcome)) throw nativeOutcomeError(outcome, canonicalRoot, snapshotRoot) + await fault("source-snapshotted") + return { root: canonicalSnapshotRoot, manifest: outcome.slice(9) } + } catch (cause) { + await rm(snapshotRoot, { recursive: true, force: true }) + if (cause instanceof DirectoryPromotionError) throw cause + throw new DirectoryPromotionError("GENERATED_SOURCE_CHANGED", `generated source changed while its operation snapshot was created: ${root}`, { cause }) + } +} + +async function assertNoGeneratedSymlinks(root, directory) { + for (const entry of await readdir(directory)) { + const path = resolve(directory, entry) + const metadata = await lstat(path) + if (metadata.isSymbolicLink()) throw new DirectoryPromotionError("GENERATED_SOURCE_SYMLINK", `generated source must not use symlinks: ${relative(root, path)}`) + if (metadata.isDirectory()) await assertNoGeneratedSymlinks(root, path) + } +} + +async function contractFilesFromSnapshot(root, expectedManifest) { + const before = await treeManifest(root) + if (before !== expectedManifest) throw new DirectoryPromotionError("GENERATED_SOURCE_CHANGED", `generated source snapshot changed before dependency discovery: ${root}`) + const files = new Set([ + "runtime-archive-component.js", + "runtime-archive-component.d.ts", + "runtime-package-profile.js", + "runtime-package-profile.d.ts", + "runtime-command-result.js", + "runtime-command-result.d.ts", + ]) + const pending = [...files] + while (pending.length) { + const file = pending.pop() + const source = await readContainedRegularFile(root, file, "utf8") + for (const match of source.matchAll(/(?:from\s+|import\s*\(\s*|import\s+)["'](\.[^"']+)["']/g)) { + const importedPath = resolve(root, dirname(file), match[1]) + const imported = relative(root, importedPath) + if (imported === ".." || imported.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`)) { + throw new DirectoryPromotionError("GENERATED_IMPORT_ESCAPE", `generated relative import escapes the generated/source roots: ${file} imports ${match[1]}`) + } + for (const candidate of imported.endsWith(".js") ? [imported, imported.replace(/\.js$/, ".d.ts")] : [imported]) { + if (!files.has(candidate) && await entryExists(resolve(root, candidate))) { + const handle = await openContainedRegularFile(root, candidate) + await handle.close() + files.add(candidate) + pending.push(candidate) + } + } + } + } + for (const file of [...files]) { + if (await entryExists(resolve(root, `${file}.map`))) { + const handle = await openContainedRegularFile(root, `${file}.map`) + await handle.close() + files.add(`${file}.map`) + } + } + if (await treeManifest(root) !== before) throw new DirectoryPromotionError("GENERATED_SOURCE_CHANGED", `generated source snapshot changed during dependency discovery: ${root}`) + return [...files].sort() +} + +async function treeManifest(root) { + const canonicalRoot = await realpath(root) + const identity = await directoryIdentity(canonicalRoot, "manifest root") + const helper = await fileReader() + const { stdout } = await execFileAsync(helper, ["--manifest", canonicalRoot, String(identity.dev), String(identity.ino)], { encoding: "utf8", maxBuffer: 1024 * 1024 * 20 }) + const outcome = stdout.trim() + if (!/^MANIFEST [a-f0-9]{64}$/.test(outcome)) throw nativeOutcomeError(outcome, canonicalRoot, "") + return outcome.slice(9) +} + +async function assertContractBehavior(candidateRoot, generatedRoot) { + const generation = randomUUID() + const generatedArchive = await import(`${pathToFileURL(resolve(generatedRoot, "runtime-archive-component.js")).href}?generated=${generation}`) + const vendorArchive = await import(`${pathToFileURL(resolve(candidateRoot, "runtime-archive-component.js")).href}?candidate=${generation}`) + const generatedProfile = await import(`${pathToFileURL(resolve(generatedRoot, "runtime-package-profile.js")).href}?generated=${generation}`) + const vendorProfile = await import(`${pathToFileURL(resolve(candidateRoot, "runtime-package-profile.js")).href}?candidate=${generation}`) + const generatedResult = await import(`${pathToFileURL(resolve(generatedRoot, "runtime-command-result.js")).href}?generated=${generation}`) + const vendorResult = await import(`${pathToFileURL(resolve(candidateRoot, "runtime-command-result.js")).href}?candidate=${generation}`) + const component = { schema: generatedArchive.RUNTIME_ARCHIVE_COMPONENT_SCHEMA, id: "website-importer", package: { profile: "cloudflare", root: "static-site-importer" }, wordpress: { install_path: "plugins/static-site-importer", bootstrap_file: "plugin.php", load: { mode: "mu-plugin-loader", loader_path: "mu-plugins/loader.php" } }, abilities: { import: "sites/import" }, limits: { files: 100, bytes: 1_000_000 } } + assert.deepEqual(vendorArchive.runtimeArchiveComponent(component), generatedArchive.runtimeArchiveComponent(component)) + for (const invalid of [null, { ...component, id: "../escape" }, { ...component, limits: { files: 0, bytes: 1 } }, { ...component, wordpress: { ...component.wordpress, bootstrap_file: "../plugin.php" } }]) { + assertSameRejection(() => vendorArchive.runtimeArchiveComponent(invalid), () => generatedArchive.runtimeArchiveComponent(invalid)) + } + const source = { schema: generatedArchive.RUNTIME_ARCHIVE_COMPONENT_SOURCE_SCHEMA, source: { url: "https://example.com/component.zip", version: "1.0.0", identity: "revision", sha256: "a".repeat(64) }, component } + assert.deepEqual(vendorArchive.runtimeArchiveComponentSource(source), generatedArchive.runtimeArchiveComponentSource(source)) + assertSameRejection(() => vendorArchive.runtimeArchiveComponentSource({ ...source, source: { ...source.source, url: "http://example.com/component.zip" } }), () => generatedArchive.runtimeArchiveComponentSource({ ...source, source: { ...source.source, url: "http://example.com/component.zip" } })) + + const manifestSource = JSON.stringify({ schema: "example/runtime-package-manifest/v1", package: "example", package_root: "example", profiles: { cloudflare: { abilities: ["sites/import"], selectors: [{ type: "file", path: "plugin.php" }], required_files: ["plugin.php"] } } }) + const generatedManifest = generatedProfile.parseRuntimePackageManifest(manifestSource) + const vendorManifest = vendorProfile.parseRuntimePackageManifest(manifestSource) + assert.deepEqual(vendorManifest, generatedManifest) + assert.deepEqual(vendorProfile.selectRuntimePackageProfileFiles(vendorManifest, "cloudflare", ["example/runtime-package-manifest.json", "example/plugin.php"], "example/runtime-package-manifest.json"), generatedProfile.selectRuntimePackageProfileFiles(generatedManifest, "cloudflare", ["example/runtime-package-manifest.json", "example/plugin.php"], "example/runtime-package-manifest.json")) + for (const invalid of ["not-json", JSON.stringify({ package: "../escape" }), JSON.stringify({ schema: "example/runtime-package-manifest/v1", package: "example", package_root: "example", profiles: {} })]) { + assertSameRejection(() => vendorProfile.parseRuntimePackageManifest(invalid), () => generatedProfile.parseRuntimePackageManifest(invalid)) + } + assertSameRejection(() => vendorProfile.selectRuntimePackageProfileFiles(vendorManifest, "cloudflare", ["example/../plugin.php"], "example/runtime-package-manifest.json"), () => generatedProfile.selectRuntimePackageProfileFiles(generatedManifest, "cloudflare", ["example/../plugin.php"], "example/runtime-package-manifest.json")) + for (const input of [{ status: "ok", stdout: "{\"passed\":true}\n" }, { status: "error", stdout: "{invalid", stderr: "failure" }, { stdout: "[1,2,3]" }]) { + assert.deepEqual(vendorResult.runtimeCommandResultEnvelopeFromOutput(input), generatedResult.runtimeCommandResultEnvelopeFromOutput(input)) + } +} + +function assertSameRejection(vendor, generated) { + assert.throws(vendor, (vendorError) => { + assert.throws(generated, (generatedError) => { + assert.equal(vendorError.message, generatedError.message) + return true + }) + return true + }) +} + +async function exists(path) { + try { + await access(path) + return true + } catch { + return false + } +} + +async function entryExists(path) { + try { + await lstat(path) + return true + } catch (error) { + if (error?.code === "ENOENT") return false + throw error + } +} + +async function git(args, tolerateFailure = false) { + try { + return (await execFileAsync("git", args, { cwd: repositoryRoot, encoding: "utf8", maxBuffer: 1024 * 1024 * 20 })).stdout + } catch (error) { + if (tolerateFailure) return "" + throw error + } +} + +if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) { + await deriveCloudflareCoreContract({ write: process.argv.includes("--write") }) + console.log(`Cloudflare core contract ${process.argv.includes("--write") ? "generated" : "verified"}`) +} diff --git a/scripts/smoke-discovery.ts b/scripts/smoke-discovery.ts index 44831a274..79808dd53 100644 --- a/scripts/smoke-discovery.ts +++ b/scripts/smoke-discovery.ts @@ -24,6 +24,8 @@ export const DISCOVERY_EXCLUSIONS: readonly Exclusion[] = [ { file: "tests/mysqli-poll.integration.test.ts", reason: "requires Docker; runs in the agent-task-contracts workflow" }, { file: "tests/runtime-sources-playground-integration.test.ts", reason: "exceeds the per-file budget; runs in the agent-task-contracts workflow" }, { file: "tests/release-package-coverage.test.ts", reason: "needs the 427 MB plugin zip from package:wordpress-plugin; runs in the Homeboy gate" }, + { file: "tests/derive-cloudflare-core-contract-atomic.test.mjs", reason: "covers the Cloudflare-owned derivation writer; runs with package boundaries in the Cloudflare Check workflow" }, + { file: "tests/runtime-package-boundaries.test.mjs", reason: "requires the independent Cloudflare package install; runs in the Cloudflare Check workflow" }, { file: "tests/prepare-declaration-rebuild.test.ts", reason: @@ -73,19 +75,6 @@ export const CHAIN_OWNED_FILES: readonly string[] = [ "tests/bench-command-step-behavior.test.ts", "tests/browser-callback-materialization-contracts.test.ts", "tests/browser-canonical-preview-origin.test.ts", - "tests/cloudflare-allocation-lifecycle.test.ts", - "tests/cloudflare-coordinator-site-partitioning.test.ts", - "tests/cloudflare-d1-operation-repository.test.ts", - "tests/cloudflare-d1-provisioner.test.mjs", - "tests/cloudflare-phase-trace.test.ts", - "tests/cloudflare-principal-credential-operator.test.mjs", - "tests/cloudflare-principal-credential-repository.test.ts", - "tests/cloudflare-provisioning-api.test.ts", - "tests/cloudflare-public-reader.test.ts", - "tests/cloudflare-queue-batch.test.ts", - "tests/cloudflare-remote-principal-credential-gate.test.mjs", - "tests/cloudflare-runtime.test.ts", - "tests/cloudflare-site-context.test.ts", "tests/external-mysql-runtime-service.test.ts", "tests/generic-ability-runtime-run.test.ts", "tests/native-mariadb-runtime-service.test.ts", diff --git a/scripts/smoke-manifest.ts b/scripts/smoke-manifest.ts index 2099b50ab..ac225d5d3 100644 --- a/scripts/smoke-manifest.ts +++ b/scripts/smoke-manifest.ts @@ -38,8 +38,6 @@ export const smokeGroups = { // CHAIN_OWNED_FILES in smoke-discovery.ts. npmScript("test:generic-primitives"), npmScript("test:runtime-services"), - // Also carries `tsc -p packages/runtime-cloudflare --noEmit`. - npmScript("test:cloudflare-runtime"), ], }, } satisfies Record diff --git a/tests/derive-cloudflare-core-contract-atomic.test.mjs b/tests/derive-cloudflare-core-contract-atomic.test.mjs new file mode 100644 index 000000000..b32b2f2d4 --- /dev/null +++ b/tests/derive-cloudflare-core-contract-atomic.test.mjs @@ -0,0 +1,922 @@ +import assert from "node:assert/strict" +import { execFile } from "node:child_process" +import { createHash } from "node:crypto" +import { access, chmod, lstat, mkdtemp, mkdir, readFile, readdir, realpath, rename, rm, symlink, writeFile } from "node:fs/promises" +import { tmpdir } from "node:os" +import { dirname, join, relative, resolve } from "node:path" +import test from "node:test" +import { promisify } from "node:util" + +import { cloudflareStageParent, contractFiles, createStageLease, DirectoryPromotionError, promoteValidatedDirectory, reclaimStaleStages, resumePromotedCleanup } from "../scripts/derive-cloudflare-core-contract.mjs" + +const execFileAsync = promisify(execFile) + +for (const faultPoint of ["before-lock", "validation", "after-validation", "before-promotion", "after-promotion"]) { + test(`derivation preserves the live tree after ${faultPoint} failure`, async () => { + const root = await mkdtemp(join(tmpdir(), "wp-codebox-core-promotion-")) + const destinationRoot = join(root, "live") + const stagedRoot = join(root, "staged") + try { + await writeTree(destinationRoot, "previous") + await writeTree(stagedRoot, "replacement") + await assert.rejects( + promoteValidatedDirectory({ + stagedRoot, + destinationRoot, + validate: async () => { + if (faultPoint === "validation") throw new Error("injected validation failure") + }, + fault: async (point) => { + if (point === faultPoint) throw new Error(`injected ${point} failure`) + }, + }), + /injected/, + ) + assert.equal(await readFile(join(destinationRoot, "contract.js"), "utf8"), "previous") + } finally { + await rm(root, { recursive: true, force: true }) + } + }) +} + +test("derivation promotes a fully validated staged tree", async () => { + const root = await mkdtemp(join(tmpdir(), "wp-codebox-core-promotion-")) + const destinationRoot = join(root, "live") + const stagedRoot = join(root, "staged") + try { + await writeTree(destinationRoot, "previous") + await writeTree(stagedRoot, "replacement") + let validated = false + await promoteValidatedDirectory({ + stagedRoot, + destinationRoot, + validate: async () => { + assert.equal(await readFile(join(stagedRoot, "contract.js"), "utf8"), "replacement") + validated = true + }, + fault: async (point) => { if (point !== "before-lock") assert.equal(validated, true, `${point} must occur after validation`) }, + }) + assert.equal(await readFile(join(destinationRoot, "contract.js"), "utf8"), "replacement") + assert.deepEqual(await readdir(root), ["live"]) + } finally { + await rm(root, { recursive: true, force: true }) + } +}) + +test("physical, relative, and symlink-parent destination aliases serialize two writers", async () => { + const root = await mkdtemp(join(tmpdir(), "wp-codebox-core-concurrent-promotion-")) + const destinationRoot = join(root, "live") + const firstStage = join(root, "first") + const secondStage = join(root, "second") + const firstValidated = join(root, "first-validated") + const secondBeforeLock = join(root, "second-before-lock") + const secondValidated = join(root, "second-validated") + const releaseFirst = join(root, "release-first") + try { + await writeTree(destinationRoot, "previous") + await writeTree(firstStage, "first") + await writeTree(secondStage, "second") + await symlink(root, join(root, "alias"), "dir") + const source = ` + import { access, writeFile } from "node:fs/promises" + import { setTimeout as delay } from "node:timers/promises" + import { promoteValidatedDirectory } from ${JSON.stringify(resolve(import.meta.dirname, "../scripts/derive-cloudflare-core-contract.mjs"))} + await promoteValidatedDirectory({ + stagedRoot: process.argv[1], + destinationRoot: process.argv[2], + validate: async () => { await writeFile(process.argv[3], "ready") }, + fault: async (point) => { + if (point === "before-lock" && process.argv[5]) await writeFile(process.argv[5], "ready") + if (point !== "after-validation" || !process.argv[4]) return + while (true) { try { await access(process.argv[4]); break } catch { await delay(5) } } + }, + }) + ` + const firstResult = execFileAsync(process.execPath, ["--input-type=module", "--eval", source, firstStage, destinationRoot, firstValidated, releaseFirst, ""], { cwd: root }) + await waitFor(firstValidated) + const secondResult = execFileAsync(process.execPath, ["--input-type=module", "--eval", source, secondStage, "alias/live", secondValidated, "", secondBeforeLock], { cwd: root }) + await waitFor(secondBeforeLock) + await assert.rejects(access(secondValidated), { code: "ENOENT" }) + await writeFile(releaseFirst, "continue") + await firstResult + await secondResult + assert.equal(await readFile(join(destinationRoot, "contract.js"), "utf8"), "second") + } finally { + await rm(root, { recursive: true, force: true }) + } +}) + +test("native rollback reports exact left ownership loss and removes the failed replacement from live", async () => { + const root = await mkdtemp(join(tmpdir(), "wp-codebox-core-left-rollback-")) + const destinationRoot = join(root, "live") + const stagedRoot = join(root, "staged") + const savedPrevious = join(root, "saved-previous") + try { + await writeTree(destinationRoot, "previous") + await writeTree(stagedRoot, "failed-replacement") + await assert.rejects( + promoteValidatedDirectory({ + stagedRoot, + destinationRoot, + validate: async () => {}, + fault: async (point) => { + if (point !== "after-promotion") return + await rename(stagedRoot, savedPrevious) + await writeTree(stagedRoot, "foreign-left") + throw new Error("injected promotion failure") + }, + }), + (error) => error instanceof DirectoryPromotionError && error.code === "ROLLBACK_FAILED_LEFT_OWNERSHIP_CHANGED" && error.cause?.message === "injected promotion failure" && !(error.cause instanceof AggregateError), + ) + await assert.rejects(readFile(join(destinationRoot, "contract.js")), { code: "ENOENT" }) + assert.equal(await readFile(join(savedPrevious, "contract.js"), "utf8"), "previous") + } finally { + await rm(root, { recursive: true, force: true }) + } +}) + +test("rollback suppresses exact right ownership loss without overwriting its new owner", async () => { + const root = await mkdtemp(join(tmpdir(), "wp-codebox-core-right-rollback-")) + const destinationRoot = join(root, "live") + const stagedRoot = join(root, "staged") + const displacedReplacement = join(root, "displaced-replacement") + try { + await writeTree(destinationRoot, "previous") + await writeTree(stagedRoot, "failed-replacement") + await assert.rejects( + promoteValidatedDirectory({ + stagedRoot, + destinationRoot, + validate: async () => {}, + fault: async (point) => { + if (point !== "after-promotion") return + await rename(destinationRoot, displacedReplacement) + await writeTree(destinationRoot, "new-right-owner") + throw new Error("injected promotion failure") + }, + }), + (error) => error instanceof DirectoryPromotionError && error.code === "RIGHT_OWNERSHIP_CHANGED", + ) + assert.equal(await readFile(join(destinationRoot, "contract.js"), "utf8"), "new-right-owner") + } finally { + await rm(root, { recursive: true, force: true }) + } +}) + +test("rollback classification leaves an exact post-exchange destination replacement untouched", async () => { + const root = await mkdtemp(join(tmpdir(), "wp-codebox-core-rollback-fallback-race-")) + const destinationRoot = join(root, "live") + const stagedRoot = join(root, "staged") + const displacedPromotion = join(root, "displaced-promotion") + const barrier = join(root, "rollback-barrier") + try { + await writeTree(destinationRoot, "previous") + await writeTree(stagedRoot, "failed-replacement") + const source = ` + import { promoteValidatedDirectory } from ${JSON.stringify(resolve(import.meta.dirname, "../scripts/derive-cloudflare-core-contract.mjs"))} + await promoteValidatedDirectory({ + stagedRoot: process.argv[1], + destinationRoot: process.argv[2], + validate: async () => {}, + fault: async (point) => { + if (point !== "after-promotion") return + throw new Error("force rollback") + }, + }) + ` + const promotion = execFileAsync(process.execPath, ["--input-type=module", "--eval", source, stagedRoot, destinationRoot], { + env: { ...process.env, WP_CODEBOX_ROLLBACK_BARRIER: barrier }, + }) + await waitFor(barrier) + await rename(destinationRoot, displacedPromotion) + await writeTree(destinationRoot, "foreign-right") + const foreignIdentity = await lstat(destinationRoot, { bigint: true }) + await rm(barrier) + await assert.rejects(promotion, /RIGHT_OWNERSHIP_CHANGED/) + const afterIdentity = await lstat(destinationRoot, { bigint: true }) + assert.equal(afterIdentity.dev, foreignIdentity.dev) + assert.equal(afterIdentity.ino, foreignIdentity.ino) + assert.equal(await readFile(join(destinationRoot, "contract.js"), "utf8"), "foreign-right") + assert.equal(await readFile(join(displacedPromotion, "contract.js"), "utf8"), "failed-replacement") + assert.equal(await readFile(join(stagedRoot, "contract.js"), "utf8"), "previous") + } finally { + await rm(root, { recursive: true, force: true }) + } +}) + +test("a descendant rewrite after validation cannot promote unvalidated bytes", async () => { + const root = await mkdtemp(join(tmpdir(), "wp-codebox-core-content-generation-")) + const destinationRoot = join(root, "live") + const stagedRoot = join(root, "staged") + try { + await writeTree(destinationRoot, "previous") + await writeTree(stagedRoot, "validated") + await assert.rejects( + promoteValidatedDirectory({ + stagedRoot, + destinationRoot, + validate: async () => assert.equal(await readFile(join(stagedRoot, "contract.js"), "utf8"), "validated"), + fault: async (point) => { if (point === "after-validation") await writeFile(join(stagedRoot, "contract.js"), "unvalidated") }, + }), + (error) => error instanceof DirectoryPromotionError && error.code === "STAGING_CONTENT_CHANGED", + ) + assert.equal(await readFile(join(destinationRoot, "contract.js"), "utf8"), "previous") + } finally { + await rm(root, { recursive: true, force: true }) + } +}) + +test("validation reads the pinned generation when the staging pathname is swapped", async () => { + const root = await mkdtemp(join(tmpdir(), "wp-codebox-core-validation-swap-")) + const destinationRoot = join(root, "live") + const stagedRoot = join(root, "staged") + const pinnedRoot = join(root, "pinned") + try { + await writeTree(destinationRoot, "previous") + await writeTree(stagedRoot, "validated") + let validated + await assert.rejects(promoteValidatedDirectory({ + stagedRoot, + destinationRoot, + validate: async (validationRoot) => { + await rename(stagedRoot, pinnedRoot) + await writeTree(stagedRoot, "foreign") + validated = await readFile(join(validationRoot, "contract.js"), "utf8") + }, + }), (error) => error instanceof DirectoryPromotionError && error.code === "STAGING_OWNERSHIP_CHANGED") + assert.equal(validated, "validated") + assert.equal(await readFile(join(stagedRoot, "contract.js"), "utf8"), "foreign") + assert.equal(await readFile(join(destinationRoot, "contract.js"), "utf8"), "previous") + } finally { + await rm(root, { recursive: true, force: true }) + } +}) + +test("a staging write racing the native snapshot cannot validate torn bytes", async () => { + const root = await mkdtemp(join(tmpdir(), "wp-codebox-core-snapshot-race-")) + const destinationRoot = join(root, "live") + const stagedRoot = join(root, "staged") + const barrier = join(root, "snapshot-barrier") + try { + await writeTree(destinationRoot, "previous") + await writeTree(stagedRoot, "validated") + const promotion = promoteValidatedDirectory({ stagedRoot, destinationRoot, snapshotBarrier: barrier, validate: async () => {} }) + await waitFor(barrier) + await writeFile(join(stagedRoot, "contract.js"), "raced") + await rm(barrier) + await assert.rejects(promotion, (error) => error instanceof DirectoryPromotionError && error.code === "STAGING_CONTENT_CHANGED") + assert.equal(await readFile(join(destinationRoot, "contract.js"), "utf8"), "previous") + } finally { + await rm(root, { recursive: true, force: true }) + } +}) + +test("validation cannot mutate its snapshot away from the promoted manifest", async () => { + const root = await mkdtemp(join(tmpdir(), "wp-codebox-core-validation-mutation-")) + const destinationRoot = join(root, "live") + const stagedRoot = join(root, "staged") + try { + await writeTree(destinationRoot, "previous") + await writeTree(stagedRoot, "validated") + await assert.rejects(promoteValidatedDirectory({ + stagedRoot, + destinationRoot, + validate: async (validationRoot) => writeFile(join(validationRoot, "contract.js"), "different"), + }), (error) => error instanceof DirectoryPromotionError && error.code === "STAGING_CONTENT_CHANGED") + assert.equal(await readFile(join(destinationRoot, "contract.js"), "utf8"), "previous") + } finally { + await rm(root, { recursive: true, force: true }) + } +}) + +test("staged-tree and exchange-parent sync failures retain the prior live tree", async () => { + for (const syncFailure of ["staged-tree", "exchange-parent"]) { + const root = await mkdtemp(join(tmpdir(), `wp-codebox-core-${syncFailure}-failure-`)) + const destinationRoot = join(root, "live") + const stagedRoot = join(root, "staged") + try { + await writeTree(destinationRoot, "previous") + await writeTree(stagedRoot, "replacement") + await assert.rejects(promoteValidatedDirectory({ + stagedRoot, + destinationRoot, + validate: async () => {}, + syncFailure, + }), (error) => error instanceof DirectoryPromotionError && error.code === "SYNC_FAILED") + assert.equal(await readFile(join(destinationRoot, "contract.js"), "utf8"), "previous") + assert.equal(await readFile(join(stagedRoot, "contract.js"), "utf8"), "replacement") + } finally { + await rm(root, { recursive: true, force: true }) + } + } +}) + +test("the final native linearization point rejects content mutation after manifest traversal", async () => { + const root = await mkdtemp(join(tmpdir(), "wp-codebox-core-final-manifest-")) + const destinationRoot = join(root, "live") + const stagedRoot = join(root, "staged") + const barrier = join(root, "finalize-barrier") + try { + await writeTree(destinationRoot, "previous") + await writeTree(stagedRoot, "validated") + const promotion = promoteValidatedDirectory({ + stagedRoot, + destinationRoot, + validate: async () => {}, + finalizeBarrier: barrier, + }) + await waitFor(barrier) + await writeFile(join(destinationRoot, "contract.js"), "mutated") + await rm(barrier) + await assert.rejects(promotion, (error) => error instanceof DirectoryPromotionError && error.code === "STAGING_CONTENT_CHANGED") + assert.equal(await readFile(join(destinationRoot, "contract.js"), "utf8"), "previous") + assert.equal(await readFile(join(stagedRoot, "contract.js"), "utf8"), "mutated") + } finally { + await rm(root, { recursive: true, force: true }) + } +}) + +test("destination replacement in the helper check/exchange barrier is rejected", async () => { + const root = await mkdtemp(join(tmpdir(), "wp-codebox-core-helper-race-")) + const destinationRoot = join(root, "live") + const stagedRoot = join(root, "staged") + const savedPrevious = join(root, "saved-previous") + try { + await writeTree(destinationRoot, "previous") + await writeTree(stagedRoot, "replacement") + await assert.rejects(promoteValidatedDirectory({ + stagedRoot, + destinationRoot, + validate: async () => {}, + nativeFault: async (point) => { + if (point !== "helper-checked") return + await rename(destinationRoot, savedPrevious) + await writeTree(destinationRoot, "foreign") + }, + }), (error) => error instanceof DirectoryPromotionError && error.code === "RIGHT_OWNERSHIP_CHANGED") + assert.equal(await readFile(join(destinationRoot, "contract.js"), "utf8"), "foreign") + } finally { + await rm(root, { recursive: true, force: true }) + } +}) + +test("staging replacement in the helper check/exchange barrier restores live and preserves foreign staging", async () => { + const root = await mkdtemp(join(tmpdir(), "wp-codebox-core-helper-left-race-")) + const destinationRoot = join(root, "live") + const stagedRoot = join(root, "staged") + const savedStage = join(root, "saved-stage") + try { + await writeTree(destinationRoot, "previous") + await writeTree(stagedRoot, "replacement") + await assert.rejects(promoteValidatedDirectory({ + stagedRoot, + destinationRoot, + validate: async () => {}, + nativeFault: async (point) => { + if (point !== "helper-checked") return + await rename(stagedRoot, savedStage) + await writeTree(stagedRoot, "foreign-stage") + }, + }), (error) => error instanceof DirectoryPromotionError && error.code === "STAGING_OWNERSHIP_CHANGED") + assert.equal(await readFile(join(destinationRoot, "contract.js"), "utf8"), "previous") + assert.equal(await readFile(join(stagedRoot, "contract.js"), "utf8"), "foreign-stage") + assert.equal(await readFile(join(savedStage, "contract.js"), "utf8"), "replacement") + } finally { + await rm(root, { recursive: true, force: true }) + } +}) + +test("a destination parent symlink swap cannot redirect the native exchange", async () => { + const root = await mkdtemp(join(tmpdir(), "wp-codebox-core-parent-swap-")) + const physical = join(root, "physical") + const decoy = join(root, "decoy") + const alias = join(root, "alias") + const stagedRoot = join(root, "staged") + try { + await mkdir(physical) + await mkdir(decoy) + await writeTree(join(physical, "live"), "previous") + await writeTree(join(decoy, "live"), "decoy") + await writeTree(stagedRoot, "replacement") + await symlink(physical, alias, "dir") + await promoteValidatedDirectory({ + stagedRoot, + destinationRoot: join(alias, "live"), + validate: async () => {}, + nativeFault: async (point) => { + if (point !== "helper-checked") return + await rename(alias, join(root, "old-alias")) + await symlink(decoy, alias, "dir") + }, + }) + assert.equal(await readFile(join(physical, "live/contract.js"), "utf8"), "replacement") + assert.equal(await readFile(join(decoy, "live/contract.js"), "utf8"), "decoy") + } finally { + await rm(root, { recursive: true, force: true }) + } +}) + +test("an intermediate destination ancestor swap cannot redirect descriptor-relative exchange", async () => { + const root = await mkdtemp(join(tmpdir(), "wp-codebox-core-ancestor-swap-")) + const ancestor = join(root, "ancestor") + const movedAncestor = join(root, "moved-ancestor") + const destinationRoot = join(ancestor, "parent/live") + const stagedRoot = join(root, "staged") + try { + await mkdir(join(ancestor, "parent"), { recursive: true }) + await writeTree(destinationRoot, "previous") + await writeTree(stagedRoot, "replacement") + await promoteValidatedDirectory({ + stagedRoot, + destinationRoot, + validate: async () => {}, + nativeFault: async (point) => { + if (point !== "helper-checked") return + await rename(ancestor, movedAncestor) + await mkdir(join(ancestor, "parent"), { recursive: true }) + await writeTree(join(ancestor, "parent/live"), "decoy") + }, + }) + assert.equal(await readFile(join(movedAncestor, "parent/live/contract.js"), "utf8"), "replacement") + assert.equal(await readFile(join(ancestor, "parent/live/contract.js"), "utf8"), "decoy") + } finally { + await rm(root, { recursive: true, force: true }) + } +}) + +test("a generated source parent swap cannot redirect descriptor-relative reads", async () => { + const root = await mkdtemp(join(tmpdir(), "wp-codebox-core-source-parent-swap-")) + const physical = join(root, "physical") + const movedPhysical = join(root, "moved-physical") + const generatedRoot = join(physical, "dist") + try { + await mkdir(physical) + await writeContractRoots(generatedRoot) + await assert.rejects(contractFiles(generatedRoot, { + fault: async (point) => { + if (point !== "source-root-opened") return + await rename(physical, movedPhysical) + await mkdir(physical) + await writeContractRoots(join(physical, "dist")) + }, + }), (error) => error instanceof DirectoryPromotionError && error.code === "GENERATED_SOURCE_CHANGED") + assert.equal(await readFile(join(movedPhysical, "dist/runtime-archive-component.js"), "utf8"), "export {}\n") + } finally { + await rm(root, { recursive: true, force: true }) + } +}) + +test("unlinking and recreating the protected lock generation aborts the writer", async () => { + const root = await mkdtemp(join(tmpdir(), "wp-codebox-core-lock-continuity-")) + const destinationRoot = join(root, "live") + const stagedRoot = join(root, "staged") + try { + await writeTree(destinationRoot, "previous") + await writeTree(stagedRoot, "replacement") + const protectedLockDirectory = join(await realpath(tmpdir()), `wp-codebox-directory-exchange-${process.getuid()}-${createHash("sha256").update(await realpath(destinationRoot)).digest("hex")}`) + await assert.rejects(promoteValidatedDirectory({ + stagedRoot, + destinationRoot, + validate: async () => {}, + fault: async (point) => { + if (point !== "after-validation") return + await chmod(protectedLockDirectory, 0o700) + await rm(protectedLockDirectory, { recursive: true }) + await mkdir(protectedLockDirectory, { mode: 0o500 }) + }, + }), (error) => error instanceof DirectoryPromotionError && error.code === "DIRECTORY_LOCK_LOST") + assert.equal(await readFile(join(destinationRoot, "contract.js"), "utf8"), "previous") + await chmod(protectedLockDirectory, 0o700) + await rm(protectedLockDirectory, { recursive: true }) + } finally { + await rm(root, { recursive: true, force: true }) + } +}) + +for (const faultPoint of ["after-promoted", "after-final-manifest"]) { + test(`lock continuity loss at ${faultPoint} rolls back before reporting`, async () => { + const root = await mkdtemp(join(tmpdir(), "wp-codebox-core-post-exchange-lock-")) + const destinationRoot = join(root, "live") + const stagedRoot = join(root, "staged") + let protectedLockDirectory + try { + await writeTree(destinationRoot, "previous") + await writeTree(stagedRoot, "replacement") + protectedLockDirectory = join(await realpath(tmpdir()), `wp-codebox-directory-exchange-${process.getuid()}-${createHash("sha256").update(await realpath(destinationRoot)).digest("hex")}`) + await assert.rejects(promoteValidatedDirectory({ + stagedRoot, + destinationRoot, + validate: async () => {}, + nativeFault: async (point) => { + if (point !== faultPoint) return + await chmod(protectedLockDirectory, 0o700) + await rm(protectedLockDirectory, { recursive: true }) + await mkdir(protectedLockDirectory, { mode: 0o500 }) + }, + }), (error) => error instanceof DirectoryPromotionError && error.code === "DIRECTORY_LOCK_LOST") + assert.equal(await readFile(join(destinationRoot, "contract.js"), "utf8"), "previous") + assert.equal(await readFile(join(stagedRoot, "contract.js"), "utf8"), "replacement") + } finally { + if (protectedLockDirectory) { + await chmod(protectedLockDirectory, 0o700).catch(() => {}) + await rm(protectedLockDirectory, { recursive: true, force: true }) + } + await rm(root, { recursive: true, force: true }) + } + }) +} + +test("failed displaced-tree cleanup is explicit and resumable", async () => { + const root = await mkdtemp(join(tmpdir(), "wp-codebox-core-cleanup-pending-")) + const destinationRoot = join(root, "live") + const stagedRoot = join(root, "staged") + try { + await writeTree(destinationRoot, "previous") + await writeTree(stagedRoot, "replacement") + const result = await promoteValidatedDirectory({ + stagedRoot, + destinationRoot, + validate: async () => {}, + nativeFault: async (point) => { if (point === "before-cleanup") throw new Error("injected cleanup failure") }, + }) + assert.equal(result.outcome, "promoted_cleanup_pending") + assert.equal(await readFile(join(destinationRoot, "contract.js"), "utf8"), "replacement") + assert.equal(await readFile(join(stagedRoot, "contract.js"), "utf8"), "previous") + assert.deepEqual(await resumePromotedCleanup(result), { outcome: "cleaned" }) + await assert.rejects(access(stagedRoot), { code: "ENOENT" }) + } finally { + await rm(root, { recursive: true, force: true }) + } +}) + +test("resumable cleanup never deletes a foreign replacement", async () => { + const root = await mkdtemp(join(tmpdir(), "wp-codebox-core-cleanup-foreign-")) + const destinationRoot = join(root, "live") + const stagedRoot = join(root, "staged") + const displacedRoot = join(root, "displaced") + try { + await writeTree(destinationRoot, "previous") + await writeTree(stagedRoot, "replacement") + const result = await promoteValidatedDirectory({ + stagedRoot, + destinationRoot, + validate: async () => {}, + nativeFault: async (point) => { if (point === "before-cleanup") throw new Error("injected cleanup failure") }, + }) + await rename(stagedRoot, displacedRoot) + await writeTree(stagedRoot, "foreign") + await assert.rejects(resumePromotedCleanup(result), (error) => error instanceof DirectoryPromotionError && error.code === "RIGHT_OWNERSHIP_CHANGED") + assert.equal(await readFile(join(stagedRoot, "contract.js"), "utf8"), "foreign") + assert.equal(await readFile(join(displacedRoot, "contract.js"), "utf8"), "previous") + } finally { + await rm(root, { recursive: true, force: true }) + } +}) + +test("cleanup quarantine survives native helper termination and resumes by leased identity", async () => { + const root = await mkdtemp(join(tmpdir(), "wp-codebox-core-cleanup-death-")) + const destinationRoot = join(root, "live") + const stagedRoot = join(root, ".runtime-cloudflare-core-stage-99999999-cleanup-death") + const barrier = join(root, "cleanup-barrier") + try { + await writeTree(destinationRoot, "previous") + await writeTree(stagedRoot, "replacement") + const stageLease = await createStageLease(stagedRoot, { pid: 99999999, createdAt: Date.now() - 25 * 60 * 60 * 1_000 }) + const result = await promoteValidatedDirectory({ + stagedRoot, + destinationRoot, + stageLease, + validate: async () => {}, + nativeFault: async (point) => { if (point === "before-cleanup") throw new Error("defer cleanup") }, + }) + const interrupted = resumePromotedCleanup({ ...result, cleanupLease: stageLease.cleanupLease, cleanupBarrier: barrier }) + await waitFor(barrier) + process.kill(Number((await readFile(barrier, "utf8")).trim()), "SIGKILL") + await assert.rejects(interrupted, (error) => error?.signal === "SIGKILL") + await writeTree(stagedRoot, "foreign") + await reclaimStaleStages(root) + assert.equal(await readFile(join(stagedRoot, "contract.js"), "utf8"), "foreign") + await assert.rejects(access(stageLease.cleanupLease), { code: "ENOENT" }) + assert.equal((await readdir(root)).some((name) => name.startsWith(".wp-codebox-cleanup-")), false) + } finally { + await rm(root, { recursive: true, force: true }) + } +}) + +for (const cleanupBarrierPoint of ["before-exchange", "after-exchange"]) { + test(`cleanup resumes after termination ${cleanupBarrierPoint}`, async () => { + const root = await mkdtemp(join(tmpdir(), `wp-codebox-core-cleanup-${cleanupBarrierPoint}-`)) + const destinationRoot = join(root, "live") + const stagedRoot = join(root, "staged") + const barrier = join(root, "cleanup-barrier") + try { + await writeTree(destinationRoot, "previous") + await writeTree(stagedRoot, "replacement") + const result = await promoteValidatedDirectory({ + stagedRoot, + destinationRoot, + validate: async () => {}, + nativeFault: async (point) => { if (point === "before-cleanup") throw new Error("defer cleanup") }, + }) + const interrupted = resumePromotedCleanup({ ...result, cleanupBarrier: barrier, cleanupBarrierPoint }) + await waitFor(barrier) + process.kill(Number((await readFile(barrier, "utf8")).trim()), "SIGKILL") + await assert.rejects(interrupted, (error) => error?.signal === "SIGKILL") + assert.deepEqual(await resumePromotedCleanup(result), { outcome: "cleaned" }) + await assert.rejects(access(stagedRoot), { code: "ENOENT" }) + assert.equal((await readdir(root)).some((name) => name.startsWith(".wp-codebox-cleanup-")), false) + } finally { + await rm(root, { recursive: true, force: true }) + } + }) +} + +test("cleanup preserves an exact foreign native quarantine-token collision", async () => { + const root = await mkdtemp(join(tmpdir(), "wp-codebox-core-foreign-quarantine-")) + const destinationRoot = join(root, "live") + const stagedRoot = join(root, "staged") + try { + await writeTree(destinationRoot, "previous") + await writeTree(stagedRoot, "replacement") + const result = await promoteValidatedDirectory({ + stagedRoot, + destinationRoot, + validate: async () => {}, + nativeFault: async (point) => { if (point === "before-cleanup") throw new Error("defer cleanup") }, + }) + const foreign = join(root, `.wp-codebox-cleanup-${result.cleanupIdentity.dev}-${result.cleanupIdentity.ino}-${result.cleanupToken}`) + await mkdir(foreign) + const foreignIdentity = await lstat(foreign, { bigint: true }) + const resumed = await resumePromotedCleanup(result) + assert.equal(resumed.outcome, "promoted_cleanup_pending") + assert.deepEqual(resumed.cleanupIdentity, result.cleanupIdentity) + assert.equal(resumed.cleanupToken, result.cleanupToken) + const afterIdentity = await lstat(foreign, { bigint: true }) + assert.equal(afterIdentity.dev, foreignIdentity.dev) + assert.equal(afterIdentity.ino, foreignIdentity.ino) + assert.deepEqual(await readdir(foreign), []) + assert.equal(await readFile(join(stagedRoot, "contract.js"), "utf8"), "previous") + } finally { + await rm(root, { recursive: true, force: true }) + } +}) + +test("cleanup traversal failures remain resumable rather than becoming ownership errors", async () => { + const root = await mkdtemp(join(tmpdir(), "wp-codebox-core-cleanup-traversal-")) + const destinationRoot = join(root, "live") + const stagedRoot = join(root, ".runtime-cloudflare-core-stage-traversal") + try { + await writeTree(destinationRoot, "previous") + await symlink("contract.js", join(destinationRoot, "linked.js"), "file") + await writeTree(stagedRoot, "replacement") + const stageLease = await createStageLease(stagedRoot) + const result = await promoteValidatedDirectory({ stagedRoot, destinationRoot, stageLease, validate: async () => {} }) + assert.equal(result.outcome, "promoted_cleanup_pending") + const resumed = await resumePromotedCleanup(result) + assert.equal(resumed.outcome, "promoted_cleanup_pending") + assert.deepEqual(resumed.cleanupIdentity, result.cleanupIdentity) + assert.deepEqual(resumed.cleanupFallbackIdentity, result.cleanupFallbackIdentity) + assert.equal(resumed.cleanupLease, result.cleanupLease) + assert.equal(resumed.cleanupToken, result.cleanupToken) + } finally { + await rm(root, { recursive: true, force: true }) + } +}) + +test("a symlink destination is rejected without touching its target", async () => { + const root = await mkdtemp(join(tmpdir(), "wp-codebox-core-symlink-promotion-")) + const targetRoot = join(root, "target") + const destinationRoot = join(root, "live") + const stagedRoot = join(root, "staged") + try { + await writeTree(targetRoot, "target") + await writeTree(stagedRoot, "replacement") + await symlink(targetRoot, destinationRoot, "dir") + await assert.rejects( + promoteValidatedDirectory({ stagedRoot, destinationRoot, validate: async () => {} }), + (error) => error instanceof DirectoryPromotionError && error.code === "INVALID_DIRECTORY_ENTRY", + ) + assert.equal(await readFile(join(targetRoot, "contract.js"), "utf8"), "target") + assert.equal(await readFile(join(stagedRoot, "contract.js"), "utf8"), "replacement") + } finally { + await rm(root, { recursive: true, force: true }) + } +}) + +test("a missing destination below a symlink parent is canonicalized but rejected without creation", async () => { + const root = await mkdtemp(join(tmpdir(), "wp-codebox-core-missing-promotion-")) + const physicalParent = join(root, "physical") + const stagedRoot = join(root, "staged") + try { + await mkdir(physicalParent) + await symlink(physicalParent, join(root, "alias"), "dir") + await writeTree(stagedRoot, "replacement") + await assert.rejects( + promoteValidatedDirectory({ stagedRoot, destinationRoot: join(root, "alias/missing"), validate: async () => {} }), + (error) => error instanceof DirectoryPromotionError && error.code === "INVALID_DIRECTORY_ENTRY", + ) + await assert.rejects(access(join(physicalParent, "missing")), { code: "ENOENT" }) + } finally { + await rm(root, { recursive: true, force: true }) + } +}) + +test("generated relative imports cannot escape before contract files are copied", async () => { + const root = await mkdtemp(join(tmpdir(), "wp-codebox-core-import-escape-")) + const generatedRoot = join(root, "dist") + try { + await mkdir(generatedRoot) + await writeFile(join(root, "outside.js"), "export const escaped = true\n") + for (const file of ["runtime-archive-component.js", "runtime-archive-component.d.ts", "runtime-package-profile.js", "runtime-package-profile.d.ts", "runtime-command-result.js", "runtime-command-result.d.ts"]) { + await writeFile(join(generatedRoot, file), file === "runtime-archive-component.js" ? 'export { escaped } from "../outside.js"\n' : "export {}\n") + } + await assert.rejects( + contractFiles(generatedRoot), + (error) => error instanceof DirectoryPromotionError && error.code === "GENERATED_IMPORT_ESCAPE", + ) + assert.deepEqual(await readdir(generatedRoot), [ + "runtime-archive-component.d.ts", + "runtime-archive-component.js", + "runtime-command-result.d.ts", + "runtime-command-result.js", + "runtime-package-profile.d.ts", + "runtime-package-profile.js", + ]) + } finally { + await rm(root, { recursive: true, force: true }) + } +}) + +for (const symlinkKind of ["file", "directory"]) { + test(`generated imports reject a symlinked ${symlinkKind} inside the source root`, async () => { + const root = await mkdtemp(join(tmpdir(), `wp-codebox-core-import-symlink-${symlinkKind}-`)) + const generatedRoot = join(root, "dist") + try { + await writeContractRoots(generatedRoot) + if (symlinkKind === "file") { + await writeFile(join(generatedRoot, "real.js"), "export const linked = true\n") + await symlink("real.js", join(generatedRoot, "linked.js"), "file") + await writeFile(join(generatedRoot, "runtime-archive-component.js"), 'export { linked } from "./linked.js"\n') + } else { + await mkdir(join(generatedRoot, "real")) + await writeFile(join(generatedRoot, "real/value.js"), "export const linked = true\n") + await symlink("real", join(generatedRoot, "linked"), "dir") + await writeFile(join(generatedRoot, "runtime-archive-component.js"), 'export { linked } from "./linked/value.js"\n') + } + await assert.rejects( + contractFiles(generatedRoot), + (error) => error instanceof DirectoryPromotionError && error.code === "GENERATED_SOURCE_SYMLINK", + ) + } finally { + await rm(root, { recursive: true, force: true }) + } + }) +} + +test("only exact persisted stage leases are reclaimed and foreign replacements survive", async () => { + const root = await mkdtemp(join(tmpdir(), "wp-codebox-core-stale-stages-")) + const deadStage = join(root, ".runtime-cloudflare-core-stage-99999999-dead") + const liveStage = join(root, `.runtime-cloudflare-core-stage-${process.pid}-live`) + const reusedPidStage = join(root, `.runtime-cloudflare-core-stage-${process.pid}-stale`) + const unleasedStage = join(root, ".runtime-cloudflare-core-stage-99999999-unleased") + const displacedStage = join(root, "displaced-owned-stage") + try { + await mkdir(deadStage) + await mkdir(liveStage) + await mkdir(reusedPidStage) + await mkdir(unleasedStage) + await writeFile(join(deadStage, "partial-secret.txt"), "dead") + await writeFile(join(liveStage, "active.txt"), "live") + await writeFile(join(reusedPidStage, "owned.txt"), "owned") + await writeFile(join(unleasedStage, "foreign.txt"), "unleased") + await createStageLease(deadStage, { pid: 99999999, createdAt: Date.now() - 25 * 60 * 60 * 1_000 }) + await createStageLease(liveStage) + const replacedLease = await createStageLease(reusedPidStage, { pid: 99999999, createdAt: Date.now() - 25 * 60 * 60 * 1_000 }) + await rename(reusedPidStage, displacedStage) + await mkdir(reusedPidStage) + await writeFile(join(reusedPidStage, "foreign.txt"), "replacement") + await reclaimStaleStages(root) + await assert.rejects(access(deadStage), { code: "ENOENT" }) + assert.equal(await readFile(join(liveStage, "active.txt"), "utf8"), "live") + assert.equal(await readFile(join(unleasedStage, "foreign.txt"), "utf8"), "unleased") + assert.equal(await readFile(join(reusedPidStage, "foreign.txt"), "utf8"), "replacement") + assert.equal(await readFile(join(displacedStage, "owned.txt"), "utf8"), "owned") + await access(replacedLease.cleanupLease) + } finally { + await rm(root, { recursive: true, force: true }) + } +}) + +test("generated reads reject a file replaced after descriptor EOF", async () => { + const root = await mkdtemp(join(tmpdir(), "wp-codebox-core-read-replacement-")) + const generatedRoot = join(root, "dist") + const barrier = join(root, "read-barrier") + try { + await writeContractRoots(generatedRoot) + const reading = contractFiles(generatedRoot, { readBarrier: barrier }) + await waitFor(barrier) + const target = join(generatedRoot, "runtime-command-result.d.ts") + await rename(target, `${target}.old`) + await writeFile(target, "export const torn = true\n") + await rm(barrier) + await assert.rejects(reading, (error) => error instanceof DirectoryPromotionError && error.code === "GENERATED_SOURCE_CHANGED") + } finally { + await rm(root, { recursive: true, force: true }) + } +}) + +test("dependency discovery stays on one generated generation after the source mutates", async () => { + const root = await mkdtemp(join(tmpdir(), "wp-codebox-core-generated-generation-")) + const generatedRoot = join(root, "dist") + try { + await writeContractRoots(generatedRoot) + const files = await contractFiles(generatedRoot, { + fault: async (point) => { + if (point !== "source-snapshotted") return + await writeFile(join(generatedRoot, "runtime-archive-component.js"), 'export { changed } from "./changed.js"\n') + await writeFile(join(generatedRoot, "changed.js"), "export const changed = true\n") + }, + }) + assert.equal(files.includes("changed.js"), false) + } finally { + await rm(root, { recursive: true, force: true }) + } +}) + +test("a stale partial derivation stage cannot enter the Cloudflare package", async () => { + const packageRoot = resolve(import.meta.dirname, "../packages/runtime-cloudflare") + assert.equal(cloudflareStageParent, dirname(packageRoot)) + assert.equal(relative(packageRoot, cloudflareStageParent).startsWith(".."), true, "production stages must remain outside the package root") + const staleStage = join(cloudflareStageParent, ".runtime-cloudflare-core-stage-stale-test") + try { + await mkdir(staleStage) + await writeFile(join(staleStage, "partial-secret.txt"), "must not pack") + const { stdout } = await execFileAsync("npm", ["pack", ".", "--dry-run", "--json", "--workspaces=false"], { + cwd: packageRoot, + maxBuffer: 1024 * 1024 * 20, + }) + const [packed] = JSON.parse(stdout) + assert.equal(packed.files.some(({ path }) => path.includes(relative(packageRoot, staleStage)) || path.includes("partial-secret.txt")), false) + } finally { + await rm(staleStage, { recursive: true, force: true }) + } +}) + +for (const faultPoint of ["before-lock", "after-validation", "before-promotion", "after-promotion", "after-final-manifest"]) { + test(`abrupt termination at ${faultPoint} leaves a complete live tree`, async () => { + const root = await mkdtemp(join(tmpdir(), "wp-codebox-core-interruption-")) + const destinationRoot = join(root, "live") + const stagedRoot = join(root, "staged") + try { + await writeTree(destinationRoot, "previous") + await writeTree(stagedRoot, "replacement") + const source = ` + import { promoteValidatedDirectory } from ${JSON.stringify(resolve(import.meta.dirname, "../scripts/derive-cloudflare-core-contract.mjs"))} + await promoteValidatedDirectory({ + stagedRoot: process.argv[1], + destinationRoot: process.argv[2], + validate: async () => {}, + fault: async (point) => { if (point === process.argv[3]) process.kill(process.pid, "SIGKILL") }, + nativeFault: async (point) => { if (point === process.argv[3]) process.kill(process.pid, "SIGKILL") }, + }) + ` + await assert.rejects(execFileAsync(process.execPath, ["--input-type=module", "--eval", source, stagedRoot, destinationRoot, faultPoint]), (error) => error?.signal === "SIGKILL") + if (["after-promotion", "after-final-manifest"].includes(faultPoint)) await waitForContents(join(destinationRoot, "contract.js"), "previous") + const live = await readFile(join(destinationRoot, "contract.js"), "utf8") + assert.equal(live, "previous") + } finally { + await rm(root, { recursive: true, force: true }) + } + }) +} + +async function writeTree(root, contents) { + await mkdir(root) + await writeFile(join(root, "contract.js"), contents) +} + +async function writeContractRoots(root) { + await mkdir(root) + for (const file of ["runtime-archive-component.js", "runtime-archive-component.d.ts", "runtime-package-profile.js", "runtime-package-profile.d.ts", "runtime-command-result.js", "runtime-command-result.d.ts"]) { + await writeFile(join(root, file), "export {}\n") + } +} + +async function waitFor(path) { + for (let attempt = 0; attempt < 2_000; attempt++) { + try { + await access(path) + return + } catch {} + await new Promise((resolveDelay) => setTimeout(resolveDelay, 5)) + } + throw new Error(`timed out waiting for ${path}`) +} + +async function waitForContents(path, expected) { + for (let attempt = 0; attempt < 2_000; attempt++) { + if (await readFile(path, "utf8") === expected) return + await new Promise((resolveDelay) => setTimeout(resolveDelay, 5)) + } + throw new Error(`timed out waiting for ${path} contents`) +} diff --git a/tests/root-package-boundary.test.mjs b/tests/root-package-boundary.test.mjs new file mode 100644 index 000000000..cfdbc6749 --- /dev/null +++ b/tests/root-package-boundary.test.mjs @@ -0,0 +1,31 @@ +import assert from "node:assert/strict" +import { execFile } from "node:child_process" +import { readFile } from "node:fs/promises" +import { resolve } from "node:path" +import { promisify } from "node:util" + +const execFileAsync = promisify(execFile) +const root = resolve(import.meta.dirname, "..") +const rootPackage = JSON.parse(await readFile(resolve(root, "package.json"), "utf8")) +const rootLock = JSON.parse(await readFile(resolve(root, "npm-shrinkwrap.json"), "utf8")) + +assert.deepEqual(rootPackage.workspaces, ["packages/cli", "packages/runtime-core", "packages/runtime-playground", "packages/wordpress-plugin"]) +assert.equal(rootPackage.workspaces.includes("packages/runtime-cloudflare"), false, "runtime-cloudflare must not join the default install lane") +assert.equal(rootLock.packages?.["packages/runtime-cloudflare"], undefined, "the root shrinkwrap must not retain Cloudflare package metadata") +for (const dependency of ["@cloudflare/workers-types", "wrangler"]) { + assert.equal(rootPackage.dependencies?.[dependency], undefined, `${dependency} must not be a root production dependency`) + assert.equal(rootPackage.devDependencies?.[dependency], undefined, `${dependency} must not be a root development dependency`) +} + +const { stdout } = await execFileAsync("npm", ["pack", "--dry-run", "--ignore-scripts", "--json", "--workspaces=false"], { + cwd: root, + maxBuffer: 1024 * 1024 * 20, +}) +const jsonStart = stdout.indexOf("[") +assert.notEqual(jsonStart, -1, "npm pack must emit a JSON file manifest") +const [packed] = JSON.parse(stdout.slice(jsonStart)) +const files = new Set(packed.files.map(({ path }) => path)) +assert.ok(files.has("npm-shrinkwrap.json"), "root CLI artifact must retain its reproducible dependency manifest") +assert.equal([...files].some((path) => path.includes("runtime-cloudflare") || path.includes("wrangler")), false, "root CLI artifact must exclude Cloudflare code and assets") + +console.log("root package boundary passed") diff --git a/tests/runtime-package-boundaries.test.mjs b/tests/runtime-package-boundaries.test.mjs new file mode 100644 index 000000000..863d79373 --- /dev/null +++ b/tests/runtime-package-boundaries.test.mjs @@ -0,0 +1,99 @@ +import assert from "node:assert/strict" +import { execFile } from "node:child_process" +import { readFile } from "node:fs/promises" +import { resolve } from "node:path" +import { promisify } from "node:util" + +import { deriveCloudflareCoreContract } from "../scripts/derive-cloudflare-core-contract.mjs" + +const execFileAsync = promisify(execFile) +const root = resolve(import.meta.dirname, "..") +const cloudflareRoot = resolve(root, "packages/runtime-cloudflare") +const rootPackage = JSON.parse(await readFile(resolve(root, "package.json"), "utf8")) +const cloudflarePackage = JSON.parse(await readFile(resolve(cloudflareRoot, "package.json"), "utf8")) +const cloudflareLock = JSON.parse(await readFile(resolve(cloudflareRoot, "npm-shrinkwrap.json"), "utf8")) +const compatibleCorePackage = JSON.parse(await readFile(resolve(cloudflareRoot, "vendor/wp-codebox-core/package.json"), "utf8")) +const cloudflareWorkflow = await readFile(resolve(root, ".github/workflows/cloudflare-check.yml"), "utf8") +const homeboy = JSON.parse(await readFile(resolve(root, "homeboy.json"), "utf8")) + +assert.equal(rootPackage.overrides?.["@php-wasm/stream-compression"], undefined, "the Cloudflare-only stream patch must not retain root override ownership") +for (const dependency of ["@cloudflare/workers-types"]) { + assert.equal(rootPackage.devDependencies?.[dependency], undefined, `${dependency} must not be installed by the main lane`) + assert.ok(cloudflarePackage.devDependencies?.[dependency], `${dependency} must be owned by runtime-cloudflare`) +} +assert.equal(cloudflarePackage.dependencies?.wrangler, "4.127.1", "Homeboy must install the exact Wrangler binary in production mode") +assert.equal(cloudflarePackage.devDependencies?.wrangler, undefined) +assert.equal(cloudflarePackage.dependencies?.["@php-wasm/stream-compression"], "3.1.45", "the patched direct stream dependency must remain pinned") +assert.equal(cloudflarePackage.dependencies?.["@php-wasm/universal"], "3.1.46", "Universal must retain its independent pin") +assert.equal(cloudflarePackage.overrides?.["@php-wasm/stream-compression"], undefined, "the direct patch must not invalidate Universal's transitive dependency graph") +assert.equal(cloudflareLock.packages?.["node_modules/@php-wasm/universal/node_modules/@php-wasm/stream-compression"]?.version, "3.1.46", "Universal must install its own npm-valid stream dependency") +assert.equal(cloudflarePackage.dependencies?.["@automattic/wp-codebox-core"], "file:vendor/wp-codebox-core", "the packed runtime must own an explicit compatible core contract dependency") +assert.equal(cloudflarePackage.peerDependencies?.["@automattic/wp-codebox-core"], undefined, "package-owned runtime assets must not retain an optional core peer") +assert.equal(cloudflareLock.packages?.[""]?.dependencies?.["@automattic/wp-codebox-core"], "file:vendor/wp-codebox-core") +assert.equal(cloudflarePackage.wpCodeboxCoreCompatibility, compatibleCorePackage.version) +assert.equal(cloudflarePackage.wpCodeboxCoreSourceCommit, "d3fac4ad4e4bbf6dd457ea2cd46aeb1a081b217b") +assert.equal(cloudflarePackage.engines?.node, ">=22.0.0", "the production Cloudflare runtime must declare its Node 22 floor") +assert.deepEqual(cloudflareLock.packages?.[""]?.engines, cloudflarePackage.engines, "the independent production lock must retain the package engine contract") + +for (const script of ["build", "check", "test", "test:packed-wrangler", "package:dry-run", "local-gate", "local-gate:d1", "local-gate:provisioning"]) { + assert.ok(cloudflarePackage.scripts?.[script], `runtime-cloudflare must own ${script}`) +} +assert.equal(cloudflarePackage.scripts?.postinstall, "node scripts/apply-development-patch.mjs", "the package install must apply its required stream-compression patch") +assert.ok(cloudflarePackage.dependencies?.["patch-package"], "packed installs must receive the package-owned patch tool used by postinstall") +assert.deepEqual(cloudflarePackage.bundleDependencies, ["@automattic/wp-codebox-core", "@php-wasm/stream-compression", "@php-wasm/universal", "@php-wasm/web-8-5", "@wp-playground/wordpress", "patch-package"], "packed installs must carry the shared contract, every required runtime dependency, and patch tool") +assert.doesNotMatch(cloudflarePackage.scripts?.test ?? "", /cd \.\.\/\.\.|packages\/runtime-cloudflare|register-package-local-loader/, "package tests must remain rootless") +assert.equal(homeboy.deployment_provider?.policy?.wrangler?.binary, "./packages/runtime-cloudflare/node_modules/.bin/wrangler") +assert.deepEqual(homeboy.deployment_provider?.policy?.predeploy_commands, ["npm ci --omit=dev --engine-strict --prefix packages/runtime-cloudflare --workspaces=false"]) +assert.match(cloudflareWorkflow, /npm ci --prefix packages\/runtime-cloudflare --workspaces=false/, "Cloudflare CI must install the independent package lock") +assert.match(cloudflareWorkflow, /npm run test:runtime-package-boundaries/, "Cloudflare CI must run repository package boundaries after the independent install") +assert.ok(cloudflareWorkflow.indexOf("npm ci --prefix packages/runtime-cloudflare --workspaces=false") < cloudflareWorkflow.indexOf("npm run test:runtime-package-boundaries"), "Cloudflare CI must install the package before checking repository boundaries") +assert.match(cloudflareWorkflow, /npm --prefix packages\/runtime-cloudflare run check/, "Cloudflare CI must run the package-owned check") +assert.match(cloudflareWorkflow, /npm --prefix packages\/runtime-cloudflare run test:packed-wrangler/, "Cloudflare CI must bundle a clean installed package artifact") +for (const script of ["cloudflare:build", "cloudflare:check", "cloudflare:package-dry-run", "cloudflare:dry-run", "cloudflare:local-gate", "test:cloudflare-runtime"]) { + assert.match(rootPackage.scripts?.[script] ?? "", /^npm --prefix packages\/runtime-cloudflare run /, `${script} must remain a thin package alias`) +} + +const cloudflarePack = await packList(cloudflareRoot, true) +for (const path of [ + "README.md", + "package.json", + "tsconfig.json", + "wrangler.jsonc", + "wrangler.d1.jsonc", + "wrangler.control.jsonc", + "wrangler.public-reader.jsonc", + "components/website-importer.json", + "patches/@php-wasm+stream-compression+3.1.45.patch", + "src/worker-do.ts", + "src/worker-d1.ts", + "src/worker-control.ts", + "src/public-reader-worker.ts", + "npm-shrinkwrap.json", + "scripts/local-gate.mjs", + "scripts/generate-wordpress-runtime-corpus.ts", + "vendor/wp-codebox-core/package.json", + "node_modules/@automattic/wp-codebox-core/runtime-archive-component.js", + "assets/wordpress-runtime-artifact.json", + "assets/wordpress-static-artifact.json", +]) { + assert.ok(cloudflarePack.has(path), `runtime-cloudflare package is missing ${path}`) +} +assert.equal([...cloudflarePack].some((path) => path.startsWith("../") || path.startsWith("packages/runtime-playground") || path.startsWith("packages/cli")), false) + +await assertCoreContractDrift() + +console.log("runtime package boundaries passed") + +async function packList(cwd, explicitPackage = false) { + const args = ["pack", ...(explicitPackage ? ["."] : []), "--dry-run", "--ignore-scripts", "--json", "--workspaces=false"] + const { stdout } = await execFileAsync("npm", args, { + cwd, + maxBuffer: 1024 * 1024 * 20, + }) + const [result] = JSON.parse(stdout) + return new Set(result.files.map(({ path }) => path)) +} + +async function assertCoreContractDrift() { + await deriveCloudflareCoreContract() +}