Multi-Agent Collaboration for Team and Friends
TypeScript agent-automationagent-orchestrationagent-workflowai-agentsai-collaborationai-memoryai-workforceautonomous-agentsclaude-codeclaude-code-skillscodexcoding-agentmulti-agentmultiple-agentone-person-businessone-person-companyone-person-teamopencodesolopreneur
test(workers): run Cloudflare modules in workerd (#521)
Generf599f18b55e6
diff --git a/package.json b/package.jsonindex c2ae39601..5de9289f7 100644--- a/package.json+++ b/package.json@@ -51,12 +51,12 @@"pre-commit": "pnpm typecheck && pnpm lint && pnpm test && pnpm typegrep:ws && pnpm typegrep:agent-driver && pnpm knip"},"devDependencies": {- "@vitest/coverage-v8": "^4.1.10",+ "@vitest/coverage-istanbul": "4.1.10","simple-git-hooks": "^2.13.1","turbo": "^2.10.9","typescript": "^6.0.3","vitest": "^4.1.10",- "wrangler": "^4.122.0"+ "wrangler": "^4.125.0"},"pnpm": {"patchedDependencies": {diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 7bece65c4..00f5b9b76 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -13,8 +13,8 @@ importers:.:devDependencies:- '@vitest/coverage-v8':- specifier: ^4.1.10+ '@vitest/coverage-istanbul':+ specifier: 4.1.10version: 4.1.10([email protected])simple-git-hooks:specifier: ^2.13.1@@ -27,10 +27,10 @@ importers:version: 6.0.3vitest:specifier: ^4.1.10- version: 4.1.10(@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))+ version: 4.1.10(@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))wrangler:- specifier: ^4.122.0- version: 4.122.0(@cloudflare/[email protected])+ specifier: ^4.125.0+ version: 4.125.0(@cloudflare/[email protected])src/app:dependencies:@@ -41,8 +41,8 @@ importers:specifier: ^0.35.0version: 0.35.3(@types/[email protected])wrangler:- specifier: ^4.122.0- version: 4.122.0(@cloudflare/[email protected])+ specifier: ^4.125.0+ version: 4.125.0(@cloudflare/[email protected])ws:specifier: ^8.21.3version: 8.21.3@@ -67,7 +67,7 @@ importers:vitest:specifier: ^4.1.10- version: 4.1.10(@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))+ version: 4.1.10(@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))src/cli:dependencies:@@ -107,7 +107,7 @@ importers:vitest:specifier: ^4.1.10- version: 4.1.10(@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))+ version: 4.1.10(@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))src/daemon:dependencies:@@ -147,7 +147,7 @@ importers:vitest:specifier: ^4.1.10- version: 4.1.10(@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))+ version: 4.1.10(@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))src/daemon/agent-driver:devDependencies:@@ -171,7 +171,7 @@ importers:vitest:specifier: ^4.1.10- version: 4.1.10(@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))+ version: 4.1.10(@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))src/desktop:devDependencies:@@ -194,6 +194,9 @@ importers:specifier: ^1.2.1version: 1.2.1devDependencies:+ '@cloudflare/vitest-plugin':+ specifier: 1.0.0+ version: 1.0.0(@cloudflare/[email protected])(@vitest/[email protected])(@vitest/[email protected])([email protected])'@cloudflare/workers-types':specifier: ^4.20260702.1version: 4.20260702.1@@ -208,10 +211,10 @@ importers:version: 6.0.3vitest:specifier: ^4.1.10- version: 4.1.10(@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))+ version: 4.1.10(@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))wrangler:- specifier: ^4.122.0- version: 4.122.0(@cloudflare/[email protected])+ specifier: ^4.125.0+ version: 4.125.0(@cloudflare/[email protected])src/shared:dependencies:@@ -248,7 +251,7 @@ importers:version: 6.0.3vitest:specifier: ^4.1.10- version: 4.1.10(@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))+ version: 4.1.10(@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))src/wake-worker:dependencies:@@ -256,6 +259,9 @@ importers:specifier: workspace:*version: link:../shareddevDependencies:+ '@cloudflare/vitest-plugin':+ specifier: 1.0.0+ version: 1.0.0(@cloudflare/[email protected])(@vitest/[email protected])(@vitest/[email protected])([email protected])'@cloudflare/workers-types':specifier: ^4.20260702.1version: 4.20260702.1@@ -270,10 +276,10 @@ importers:version: 6.0.3vitest:specifier: ^4.1.10- version: 4.1.10(@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))+ version: 4.1.10(@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))wrangler:- specifier: ^4.122.0- version: 4.122.0(@cloudflare/[email protected])+ specifier: ^4.125.0+ version: 4.125.0(@cloudflare/[email protected])src/web:dependencies:@@ -327,7 +333,7 @@ importers:'@opennextjs/cloudflare':specifier: ^1.20.2- version: 1.20.2([email protected](@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])(@types/[email protected])([email protected]([email protected]))([email protected]))([email protected](@cloudflare/[email protected]))+ version: 1.20.2([email protected](@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])(@types/[email protected])([email protected]([email protected]))([email protected]))([email protected](@cloudflare/[email protected]))'@streamdown/cjk':specifier: ^1.0.3version: 1.0.3(@types/[email protected])([email protected])([email protected])([email protected])([email protected])@@ -521,6 +527,9 @@ importers:'@alook/test-utils':specifier: workspace:*version: link:../../tests/utils+ '@cloudflare/vitest-plugin':+ specifier: 1.0.0+ version: 1.0.0(@cloudflare/[email protected])(@vitest/[email protected])(@vitest/[email protected])([email protected])'@lhci/cli':specifier: ^0.15.1version: 0.15.1@@ -589,10 +598,10 @@ importers:version: 11.0.5vitest:specifier: ^4.1.10- version: 4.1.10(@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))+ version: 4.1.10(@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))wrangler:- specifier: ^4.122.0- version: 4.122.0(@cloudflare/[email protected])+ specifier: ^4.125.0+ version: 4.125.0(@cloudflare/[email protected])src/ws-do:dependencies:@@ -600,6 +609,9 @@ importers:specifier: workspace:*version: link:../shareddevDependencies:+ '@cloudflare/vitest-plugin':+ specifier: 1.0.0+ version: 1.0.0(@cloudflare/[email protected])(@vitest/[email protected])(@vitest/[email protected])([email protected])'@cloudflare/workers-types':specifier: ^4.20260702.1version: 4.20260702.1@@ -614,10 +626,10 @@ importers:version: 6.0.3vitest:specifier: ^4.1.10- version: 4.1.10(@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))+ version: 4.1.10(@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))wrangler:- specifier: ^4.122.0- version: 4.122.0(@cloudflare/[email protected])+ specifier: ^4.125.0+ version: 4.125.0(@cloudflare/[email protected])tests/utils:dependencies:@@ -639,7 +651,7 @@ importers:version: 6.0.3vitest:specifier: ^4.1.10- version: 4.1.10(@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))+ version: 4.1.10(@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))packages:@@ -1186,32 +1198,39 @@ packages:workerd:optional: true- '@cloudflare/[email protected]':- resolution: {integrity: sha512-i5jqz+ywtOefr0AJbiAc8qxBLfSim/B0WJG7aW3B+pWnoVfMJdUQvi+BWcFKZJ0MoCci3KadTx6g31VfuEEqpQ==}+ '@cloudflare/[email protected]':+ resolution: {integrity: sha512-AhOD/JysC15kYw25uwdkcpbsbN86jjiv0crHobViU3U/34ImWHXIiTnwqr3ZU0gXO+dIC30LUWS6bL/N+BaDbQ==}+ peerDependencies:+ '@vitest/runner': ^4.1.0+ '@vitest/snapshot': ^4.1.0+ vitest: ^4.1.0++ '@cloudflare/[email protected]':+ resolution: {integrity: sha512-5F2/t7SVnugG3rscSe9da1LoHst+GiuVGPaE9BP6j5AonlFpiYi0eoJrl3wof9zDBIIgJZ87NjRj9TKjbbYgHg==}engines: {node: '>=16'}cpu: [x64]os: [darwin]- '@cloudflare/[email protected]':- resolution: {integrity: sha512-NoOUM/nvaDdm2Onlnz33FikWjtatzulNtvwvy4xs0IrHaTCHwC0c8NwIt6s+AI13FkDs02/vm2I3GTPLCT9+hQ==}+ '@cloudflare/[email protected]':+ resolution: {integrity: sha512-jFnG7715+r9FXRZPpuWWe5Ayd9v/IJKDODARg56ffFJWWtte6bFNi5VY3GazBM04hEmxny6OjXQBh3j2E/wNZw==}engines: {node: '>=16'}cpu: [arm64]os: [darwin]- '@cloudflare/[email protected]':- resolution: {integrity: sha512-sdYq2jL1AD1supa3fsi5O4zTB28wSjvTHj7Migh6/ts8EROPdvrSwv+rdGHhv8HJNAz/wbIAY3wZsi1Rw4uUIg==}+ '@cloudflare/[email protected]':+ resolution: {integrity: sha512-TbTYaCBht0OaOWmnVpg43hXVYtIti/Kg6lvO819H2DwbxPpK1BH0z2C+Y7ySrVJLlxZQeic5eN7/noqbP80hJg==}engines: {node: '>=16'}cpu: [x64]os: [linux]- '@cloudflare/[email protected]':- resolution: {integrity: sha512-RIRv4shbu1kg05sD+DHTpSFCNnb5Dl2SkPDMUykqZa508tkPqe7VVw7gO0Q5msTBGyL0FfFrLuRxwwfA8u5Sow==}+ '@cloudflare/[email protected]':+ resolution: {integrity: sha512-FQmri1UF7hBnnpeyC5SZJCAnsSRs3+Ykn9wlO5zxmE2qIgKfbJZ+toJ6qrQyugWlxE65juT33HU6aYLtutLJHw==}engines: {node: '>=16'}cpu: [arm64]os: [linux]- '@cloudflare/[email protected]':- resolution: {integrity: sha512-g6VquwjASlYAibcNW/0E6Zszht4qLkmnXOGwIjjRHl2A0Qz48kVeMcGvyH6eA0G9U3OzZojjYFpP+YeyQmmdjw==}+ '@cloudflare/[email protected]':+ resolution: {integrity: sha512-BPvCuMxIQfA47wtYsGbBG6Bcar57Qs7yHqU2jWkT1+sRnL/741/ZbQGP9kVRMQ5fwBMuqNFmQRzAu8gSm7ri/w==}engines: {node: '>=16'}cpu: [x64]os: [win32]@@ -2258,6 +2277,10 @@ packages:resolution: {integrity: sha512-AokJm4tuBHillT+FpMtxQ60n8ObyXBatq7jD2/JA9dxbDDokKQm8KMht5ibGzLVU9IJDIKK4TPKgMHEYMn3lMg==}engines: {node: '>=18'}+ '@istanbuljs/[email protected]':+ resolution: {integrity: sha512-+Sg6GCR/wy1oSmQDFq4LQDAhm3ETKnorxN+y5nbLULOR3P0c14f2Wurzj3/xqPXtasLFfHd5iRFQ7AJt4KH2cw==}+ engines: {node: '>=8'}+'@jridgewell/[email protected]':resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==}@@ -4181,6 +4204,11 @@ packages:'@upsetjs/[email protected]':resolution: {integrity: sha512-WbBhLrooyePuQ1VZxrJjtLvTc4NVfpOyKx0sKqioq9bX1C1m7Jgykkn8gLrtwumBioXIqam8DLxp88Adbue6Hw==}+ '@vitest/[email protected]':+ resolution: {integrity: sha512-AyNJ5pQRFqCX7pwB9PSTmoVKPaZ4H5IEVJfJsT+q1DYkXvZMEFYgJlyk5sfStmt9rVYRyYYRRsuBeImCOc39ww==}+ peerDependencies:+ vitest: 4.1.10+'@vitest/[email protected]':resolution: {integrity: sha512-IM49HmthevbgAO4anp1hwtoT9wYe59w0LR00gr+eagHE+ZJ5lK4sLPeO0ubgoJcwLk6dehU3R24N+FbEEKDc8g==}peerDependencies:@@ -4762,6 +4790,9 @@ packages:resolution: {integrity: sha512-+6vJA3L98yv+IdfKGZHBNiGW5KHn22e/JwID0Strsz8h4S/csAu/OuICwxrg44k5MRiZHWIo8XXuJgQTriRP4w==}+ resolution: {integrity: sha512-0TNiGstbQmCFwt4akjjBg5pLRTSyj/PkWQ1ZoO2zntmg9yLqSRxwEa4iCfQLGjqhiqBfOJa7W/E8wfGrTDmlZQ==}+resolution: {integrity: sha512-Ca8swihM+/4yKecYHY52kgJd300hi2lADU/a1RxNTRe+RJ9jvqQlESpbz9DnG9mowez8qwXHB8qYdIUw9e+F5Q==}@@ -7233,8 +7264,8 @@ packages:resolution: {integrity: sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==}engines: {node: '>=10'}- resolution: {integrity: sha512-sypXsD5fjY88fZNedPqnwrwR1dwfnfbfW7MfvMyIfPJdtRiCCOpUnjWGeFVYYZ+0fQVICye6Juu+vZgzTEx8XA==}+ resolution: {integrity: sha512-Bv1j2kcKKNwXLWuCx+j0xGt7z318mqQkJmEN6ellM9sCESbPBDTM9ofZMbKqx47jSnoGA3CiaUkAmzGVXUa/wQ==}engines: {node: '>=22.0.0'}@@ -9123,17 +9154,17 @@ packages:resolution: {integrity: sha512-gS2ei/mrpRqNs+AHmqxhT6vFPwCLw2qnz5ShmyGD0ULaU0Q9hxnFAcx9jhAip/MnD6+MjgnQu6hQQgA8mlOkVA==}- resolution: {integrity: sha512-kh+FFm55JQ4ssxhHZV9VPdMQq3D1nHxNJgwxMtWGD4dGppJvLySdguTRDKgeNTvgq6heSz+6TTXyPSDGj8Yllw==}+ resolution: {integrity: sha512-/wk4rFNHH6IVMXFe6aPEZsT5YWpWtfKTUMt7+rFkyeGbXcGCy4yxODmJatbqYj0jmqHETdz0+m2mT+vNjXnF7w==}engines: {node: '>=16'}hasBin: true- resolution: {integrity: sha512-qkskzgQ76Y1qvVe5JARgvc3RISq6BC2rPoxQhFoKH1dKIwQc3GDFttQ/7m2OfeQ+tmQRzynv2dy/DXnxFCj2Lw==}+ resolution: {integrity: sha512-yFpvggu+xk1Hdm/Uxwaqa19bb7GArME4CrCS3Vov68a2TZq2MPO+wLocKbbnIC9K0oLowcdau7/ycxbbNHKCEg==}engines: {node: '>=22.0.0'}hasBin: truepeerDependencies:- '@cloudflare/workers-types': ^5.20260811.1+ '@cloudflare/workers-types': ^5.20260820.1peerDependenciesMeta:'@cloudflare/workers-types':optional: true@@ -10125,7 +10156,8 @@ snapshots:optionalDependencies:'@types/react': 19.2.18- '@bcoe/[email protected]': {}+ '@bcoe/[email protected]':+ optional: true'@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected])':dependencies:@@ -10206,25 +10238,40 @@ snapshots:'@cloudflare/[email protected]': {}dependencies:unenv: 2.0.0-rc.24optionalDependencies:- workerd: 1.20260811.1+ workerd: 1.20260820.1++ '@cloudflare/[email protected](@cloudflare/[email protected])(@vitest/[email protected])(@vitest/[email protected])([email protected])':+ dependencies:+ '@vitest/runner': 4.1.10+ '@vitest/snapshot': 4.1.10+ cjs-module-lexer: 1.2.3+ esbuild: 0.28.1+ miniflare: 5.20260820.0-alpha+ vitest: 4.1.10(@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))+ wrangler: 4.125.0(@cloudflare/[email protected])+ zod: 4.4.3+ transitivePeerDependencies:+ - '@cloudflare/workers-types'+ - bufferutil+ - utf-8-validate- '@cloudflare/[email protected]':+ '@cloudflare/[email protected]':optional: true- '@cloudflare/[email protected]':+ '@cloudflare/[email protected]':optional: true- '@cloudflare/[email protected]':+ '@cloudflare/[email protected]':optional: true- '@cloudflare/[email protected]':+ '@cloudflare/[email protected]':optional: true- '@cloudflare/[email protected]':+ '@cloudflare/[email protected]':optional: true'@cloudflare/[email protected]': {}@@ -11031,6 +11078,8 @@ snapshots:'@isaacs/[email protected]': {}+ '@istanbuljs/[email protected]': {}+'@jridgewell/[email protected]':dependencies:'@jridgewell/sourcemap-codec': 1.5.5@@ -11369,7 +11418,7 @@ snapshots:transitivePeerDependencies:- supports-color- '@opennextjs/[email protected]([email protected](@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])(@types/[email protected])([email protected]([email protected]))([email protected]))([email protected](@cloudflare/[email protected]))':+ '@opennextjs/[email protected]([email protected](@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])(@types/[email protected])([email protected]([email protected]))([email protected]))([email protected](@cloudflare/[email protected]))':dependencies:'@ast-grep/napi': 0.40.5'@dotenvx/dotenvx': 1.31.0@@ -11381,7 +11430,7 @@ snapshots:glob: 12.0.0next: 16.3.0(@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])(@types/[email protected])([email protected]([email protected]))([email protected])ts-tqdm: 0.8.6- wrangler: 4.122.0(@cloudflare/[email protected])+ wrangler: 4.125.0(@cloudflare/[email protected])yargs: 18.0.0transitivePeerDependencies:- encoding@@ -12904,6 +12953,22 @@ snapshots:d3-selection: 3.0.0d3-transition: 3.0.1([email protected])+ '@vitest/[email protected]([email protected])':+ dependencies:+ '@babel/core': 7.29.7+ '@istanbuljs/schema': 0.1.6+ '@jridgewell/gen-mapping': 0.3.13+ '@jridgewell/trace-mapping': 0.3.31+ istanbul-lib-coverage: 3.2.2+ istanbul-lib-report: 3.0.1+ istanbul-reports: 3.2.0+ magicast: 0.5.4+ obug: 2.1.3+ tinyrainbow: 3.1.0+ vitest: 4.1.10(@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))+ transitivePeerDependencies:+ - supports-color+'@vitest/[email protected]([email protected])':dependencies:'@bcoe/v8-coverage': 1.0.2@@ -12916,7 +12981,8 @@ snapshots:obug: 2.1.3std-env: 4.2.0tinyrainbow: 3.1.0- vitest: 4.1.10(@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))+ vitest: 4.1.10(@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))+ optional: true'@vitest/[email protected]':dependencies:@@ -13204,6 +13270,7 @@ snapshots:'@jridgewell/trace-mapping': 0.3.31estree-walker: 3.0.3js-tokens: 10.0.0+ optional: true@@ -13303,7 +13370,7 @@ snapshots:next: 16.3.0(@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])(@types/[email protected])([email protected]([email protected]))([email protected])react: 19.2.8react-dom: 19.2.8([email protected])- vitest: 4.1.10(@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))+ vitest: 4.1.10(@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))transitivePeerDependencies:- '@cloudflare/workers-types'- '@opentelemetry/api'@@ -13518,6 +13585,8 @@ snapshots:+ [email protected]: {}+@@ -15631,7 +15700,8 @@ snapshots:- [email protected]: {}+ optional: true@@ -15987,7 +16057,7 @@ snapshots:dependencies:'@babel/parser': 7.29.8- '@babel/types': 7.29.7+ '@babel/types': 7.29.8source-map-js: 1.2.1@@ -16573,12 +16643,12 @@ snapshots:dependencies:'@cspotcode/source-map-support': 0.8.1sharp: 0.35.2undici: 7.29.0- workerd: 1.20260811.1+ workerd: 1.20260820.1ws: 8.21.0youch: 4.1.0-beta.10transitivePeerDependencies:@@ -18943,7 +19013,7 @@ snapshots:tsx: 4.23.12yaml: 2.9.0- [email protected](@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])):+ [email protected](@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])):dependencies:'@vitest/expect': 4.1.10'@vitest/mocker': 4.1.10([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))@@ -18968,11 +19038,12 @@ snapshots:optionalDependencies:'@opentelemetry/api': 1.9.1'@types/node': 20.19.43+ '@vitest/coverage-istanbul': 4.1.10([email protected])'@vitest/coverage-v8': 4.1.10([email protected])transitivePeerDependencies:- msw- [email protected](@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])):+ [email protected](@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])):dependencies:'@vitest/expect': 4.1.10'@vitest/mocker': 4.1.10([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))@@ -18997,11 +19068,12 @@ snapshots:optionalDependencies:'@opentelemetry/api': 1.9.1'@types/node': 25.9.4+ '@vitest/coverage-istanbul': 4.1.10([email protected])'@vitest/coverage-v8': 4.1.10([email protected])transitivePeerDependencies:- msw- [email protected](@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])):+ [email protected](@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])(@vitest/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])):dependencies:'@vitest/expect': 4.1.10'@vitest/mocker': 4.1.10([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))@@ -19026,6 +19098,7 @@ snapshots:optionalDependencies:'@opentelemetry/api': 1.9.1'@types/node': 26.0.0+ '@vitest/coverage-istanbul': 4.1.10([email protected])'@vitest/coverage-v8': 4.1.10([email protected])transitivePeerDependencies:- msw@@ -19131,24 +19204,24 @@ snapshots:optionalDependencies:- '@cloudflare/workerd-darwin-64': 1.20260811.1- '@cloudflare/workerd-darwin-arm64': 1.20260811.1- '@cloudflare/workerd-linux-64': 1.20260811.1- '@cloudflare/workerd-linux-arm64': 1.20260811.1- '@cloudflare/workerd-windows-64': 1.20260811.1+ '@cloudflare/workerd-darwin-64': 1.20260820.1+ '@cloudflare/workerd-darwin-arm64': 1.20260820.1+ '@cloudflare/workerd-linux-64': 1.20260820.1+ '@cloudflare/workerd-linux-arm64': 1.20260820.1+ '@cloudflare/workerd-windows-64': 1.20260820.1- [email protected](@cloudflare/[email protected]):+ [email protected](@cloudflare/[email protected]):dependencies:'@cloudflare/kv-asset-handler': 0.5.0- '@cloudflare/unenv-preset': 2.16.1([email protected])([email protected])+ '@cloudflare/unenv-preset': 2.16.1([email protected])([email protected])blake3-wasm: 2.1.5esbuild: 0.28.1- miniflare: 5.20260811.0-alpha+ miniflare: 5.20260820.0-alphapath-to-regexp: 6.3.0unenv: 2.0.0-rc.24- workerd: 1.20260811.1+ workerd: 1.20260820.1optionalDependencies:'@cloudflare/workers-types': 4.20260702.1fsevents: 2.3.3diff --git a/scripts/ci/workflow-contract.test.ts b/scripts/ci/workflow-contract.test.tsindex 4fa9460ca..3bdcebc7e 100644--- a/scripts/ci/workflow-contract.test.ts+++ b/scripts/ci/workflow-contract.test.ts@@ -10,13 +10,39 @@ function normalizeWorkflow(text: string): string {const workflow = normalizeWorkflow(readFileSync(resolve(workflowRoot, "e2e-ui.yml"), "utf8"))const ciWorkflow = normalizeWorkflow(readFileSync(resolve(workflowRoot, "ci.yml"), "utf8"))-const wsDoPackage = JSON.parse(- readFileSync(resolve(import.meta.dirname, "../../src/ws-do/package.json"), "utf8"),-) as { scripts: Record<string, string> }+type WorkerModuleContract = {+ name: string+ packageJson: {+ scripts: Record<string, string>+ devDependencies: Record<string, string>+ }+ nodeConfig: string+ runtimeConfig: string+ workspaceConfig: string+ wranglerConfig: string+}++const directWorkerModules = ["ws-do", "email-worker", "wake-worker", "web"].map((name): WorkerModuleContract => {+ const moduleRoot = resolve(import.meta.dirname, `../../src/${name}`)+ return {+ name,+ packageJson: JSON.parse(readFileSync(resolve(moduleRoot, "package.json"), "utf8")),+ nodeConfig: readFileSync(resolve(moduleRoot, "vitest.config.ts"), "utf8"),+ runtimeConfig: readFileSync(resolve(moduleRoot, "vitest.runtime.config.mts"), "utf8"),+ workspaceConfig: readFileSync(resolve(moduleRoot, "vitest.workspace.config.ts"), "utf8"),+ wranglerConfig: readFileSync(resolve(moduleRoot, "wrangler.toml"), "utf8"),+ }+})const rootVitestConfig = readFileSync(resolve(import.meta.dirname, "../../vitest.config.ts"),"utf8",)+const rootPackageJson = JSON.parse(+ readFileSync(resolve(import.meta.dirname, "../../package.json"), "utf8"),+) as {+ scripts: Record<string, string>+ devDependencies: Record<string, string>+}const autoTagReleaseWorkflow = normalizeWorkflow(readFileSync(resolve(workflowRoot, "auto-tag-release.yml"), "utf8"),)@@ -251,15 +277,90 @@ describe("Turbo CI execution", () => {)})- it("runs the ordinary ws-do Vitest suite through the standard test task", () => {- expect(wsDoPackage.scripts.test).toBe("vitest run --passWithNoTests")- expect(wsDoPackage.scripts).not.toHaveProperty("test:workers")+ it("runs each direct Worker Node and runtime project once through its standard test task", () => {+ const projectNames: string[] = []+ for (const module of directWorkerModules) {+ expect(module.packageJson.scripts.test).toBe("vitest run --config vitest.workspace.config.ts")+ expect(module.packageJson.scripts).not.toHaveProperty("test:workers")+ expect(module.packageJson.devDependencies["@cloudflare/vitest-plugin"]).toBe("1.0.0")+ expect(module.workspaceConfig.match(/vitest\.config\.ts/g)).toHaveLength(1)+ expect(module.workspaceConfig.match(/vitest\.runtime\.config\.mts/g)).toHaveLength(1)++ const nodeProject = `${module.name}-node`+ const runtimeProject = `${module.name}-runtime`+ expect(module.nodeConfig).toContain(`name: "${nodeProject}"`)+ expect(module.runtimeConfig).toContain(`name: "${runtimeProject}"`)+ expect(module.runtimeConfig).toContain("cloudflareTest({")+ expect(module.runtimeConfig).toContain('wrangler: { configPath: "./wrangler.toml" }')+ expect(module.wranglerConfig).not.toContain("service_binding_extra_handlers")+ projectNames.push(nodeProject, runtimeProject)+ }+ expect(new Set(projectNames).size).toBe(projectNames.length)expect(ciJob("test-linux")).toContain("pnpm turbo run test --filter='!@alook/daemon'")})- it("does not exclude ws-do product source from Node coverage", () => {- expect(rootVitestConfig).not.toContain('"src/ws-do/src/**"')- expect(rootVitestConfig).not.toContain('"src/ws-do/src/**/*.ts"')+ it("collects Node and workerd projects in one Istanbul report", () => {+ expect(rootPackageJson.devDependencies["@vitest/coverage-istanbul"]).toBe("4.1.10")+ expect(rootPackageJson.devDependencies).not.toHaveProperty("@vitest/coverage-v8")+ expect(rootVitestConfig).toContain('provider: "istanbul"')+ expect(rootVitestConfig).toContain('"src/**/*.{ts,tsx,js,jsx}"')+ expect(rootVitestConfig).toContain('"**/test-runtime/**"')+ expect(rootVitestConfig).toContain('"**/test-harness.ts"')+ for (const [index, module] of directWorkerModules.entries()) {+ expect(rootVitestConfig).toContain(`"src/${module.name}"`)+ expect(+ rootVitestConfig.match(+ new RegExp(`src/${module.name}/vitest\\.runtime\\.config\\.mts`, "g"),+ ),+ ).toHaveLength(1)+ expect(module.runtimeConfig).toContain(`sequence: { groupOrder: ${index + 10} }`)+ }+ expect(directWorkerModules[3].runtimeConfig).toContain('main: "./custom-worker.ts"')+ expect(directWorkerModules[3].runtimeConfig).toContain(+ '"test-runtime/open-next-worker-stub.ts"',+ )+ })++ it("uploads the single Istanbul report through the existing Codecov step", () => {+ const coverageJob = ciJob("coverage")+ expect(coverageJob.match(/pnpm vitest run --coverage/g)).toHaveLength(1)+ expect(coverageJob.match(/codecov\/codecov-action/g)).toHaveLength(1)+ expect(coverageJob).toContain("files: ./coverage/coverage-final.json")+ expect(coverageJob).not.toContain("coverage:workers")+ expect(coverageJob).not.toContain("workers-runtime")+ expect(rootPackageJson.scripts).not.toHaveProperty("coverage:workers")+ })++ it("replaces platform mocks only after stronger workerd coverage exists", () => {+ const readRepo = (path: string) => readFileSync(+ resolve(import.meta.dirname, `../../${path}`),+ "utf8",+ )+ const wsRuntime = readRepo("src/ws-do/test-runtime/worker.runtime.test.ts")+ const webRuntime = readRepo("src/web/test-runtime/worker.runtime.test.ts")+ const emailNode = readRepo("src/email-worker/src/index.test.ts")+ const emailRuntime = readRepo("src/email-worker/test-runtime/worker.runtime.test.ts")+ const wakeNode = readRepo("src/wake-worker/src/index.test.ts")+ const wakeRuntime = readRepo("src/wake-worker/test-runtime/worker.runtime.test.ts")++ expect(existsSync(resolve(import.meta.dirname, "../../src/ws-do/src/rate-limit-do.test.ts"))).toBe(false)+ expect(wsRuntime).toContain("persists the counter across stubs for the same Durable Object id")+ expect(wsRuntime).toContain("resets expired storage and rejects invalid Durable Object requests")++ expect(existsSync(resolve(import.meta.dirname, "../../src/web/src/lib/worker-runtime.test.ts"))).toBe(false)+ expect(webRuntime).toContain("adds browser and CDN revalidation headers to public route %s")+ expect(webRuntime).toContain("forwards WebSocket upgrade %s through the configured service binding")++ expect(emailNode).not.toContain('describe("fetch() routing"')+ expect(emailNode).not.toContain('describe("IMAP management routes"')+ expect(emailRuntime).toContain("forwards status and sync routes to the real IMAP Durable Object")+ expect(emailRuntime).toContain("rejects unsupported methods, paths, and missing IMAP account ids")++ expect(wakeNode).not.toContain("returns 400 on invalid JSON body")+ expect(wakeNode).not.toContain("returns 405 for non-POST methods")+ expect(wakeNode).not.toContain("returns 200 { status: ok } for GET /health")+ expect(wakeRuntime).toContain("rejects invalid JSON and non-POST dev requests at the real entrypoint")+ expect(wakeRuntime).toContain("loads production migrations and serves the production entrypoint")})})diff --git a/src/app/package.json b/src/app/package.jsonindex af8ccce9d..aa6f25539 100644--- a/src/app/package.json+++ b/src/app/package.json@@ -42,7 +42,7 @@"commander": "^15.0.0","sharp": "^0.35.0","ws": "^8.21.3",- "wrangler": "^4.122.0"+ "wrangler": "^4.125.0"},"devDependencies": {"@alook/shared": "workspace:*",diff --git a/src/cli/daemon/meeting-runner.ts b/src/cli/daemon/meeting-runner.tsindex 5f0de34ac..ebe9afcdb 100644--- a/src/cli/daemon/meeting-runner.ts+++ b/src/cli/daemon/meeting-runner.ts@@ -87,6 +87,7 @@ async function tryJoinAndRecord(input: MeetingRunnerInput, chromePath: string):const browser = await launchBrowser(chromePath)const context = browser.contexts()[0]if (context) {+ /* istanbul ignore next -- this callback is serialized into the browser */await context.addInitScript(() => {Object.defineProperty(navigator, "webdriver", { get: () => false })})@@ -102,6 +103,7 @@ async function tryJoinAndRecord(input: MeetingRunnerInput, chromePath: string):log.info("joined meeting, waiting for UI ready...", { meeting: input.meetingId })await waitForMeetingReady(page)+ /* istanbul ignore next -- this callback is serialized into the browser */await page.evaluate(() => {for (const btn of document.querySelectorAll('button')) {const label = (btn.getAttribute('aria-label') || '').toLowerCase()diff --git a/src/daemon/agent-driver/package.json b/src/daemon/agent-driver/package.jsonindex 3683bba66..a67c278a7 100644--- a/src/daemon/agent-driver/package.json+++ b/src/daemon/agent-driver/package.json@@ -1,6 +1,6 @@{"name": "@alook/agent-driver",- "version": "0.1.14",+ "version": "0.1.15","private": true,"description": "Private workspace logical-session drivers for supported AI coding agents.","license": "Apache-2.0",diff --git a/src/email-worker/knip.json b/src/email-worker/knip.jsonindex 915fad04a..b0e1b6107 100644--- a/src/email-worker/knip.json+++ b/src/email-worker/knip.json@@ -1,11 +1,11 @@{"$schema": "https://unpkg.com/knip@6/schema.json",- "project": ["src/**/*.ts"],+ "project": ["src/**/*.ts", "test-runtime/**/*.ts"],"includeEntryExports": true,"ignoreDependencies": ["cloudflare"],"vitest": {- "entry": ["src/**/*.test.ts"]+ "entry": ["src/**/*.test.ts", "test-runtime/**/*.test.ts"]}}diff --git a/src/email-worker/package.json b/src/email-worker/package.jsonindex 8d40ad8b7..dabad70b1 100644--- a/src/email-worker/package.json+++ b/src/email-worker/package.json@@ -6,7 +6,7 @@"dev": "node ../../scripts/dev-with-wrangler-registry.mjs ../../.wrangler/registry wrangler dev --persist-to ../web/.wrangler/state","deploy": "wrangler deploy","knip": "knip",- "test": "vitest run",+ "test": "vitest run --config vitest.workspace.config.ts","typecheck": "tsc --noEmit"},"dependencies": {@@ -16,11 +16,12 @@"worker-mailer": "^1.2.1"},"devDependencies": {+ "@cloudflare/vitest-plugin": "1.0.0","@cloudflare/workers-types": "^4.20260702.1","@types/node": "^25.9.4","knip": "^6.32.2","typescript": "^6.0.3","vitest": "^4.1.10",- "wrangler": "^4.122.0"+ "wrangler": "^4.125.0"}}diff --git a/src/email-worker/src/index.test.ts b/src/email-worker/src/index.test.tsindex e5f735ca8..809f5c269 100644--- a/src/email-worker/src/index.test.ts+++ b/src/email-worker/src/index.test.ts@@ -929,109 +929,3 @@ describe("POST /send/agent with custom SMTP", () => {expect(json.error).toContain("SMTP send failed")})})--// ─── Group 8: fetch() routing ───--describe("fetch() routing", () => {- function routingEnv() {- const { bucket } = createMockR2()- const { fetcher } = createMockFetcher()- const { sendEmail } = createMockSendEmail()- return { DB: {} as D1Database, EMAIL_BUCKET: bucket, WEB_SERVICE: fetcher, SEND_EMAIL: sendEmail, IMAP_POLLER: {} as DurableObjectNamespace, ENCRYPTION_KEY: "test-secret" }- }-- it("returns 404 for unknown paths", async () => {- const res = await handler.fetch(- new Request("http://localhost/unknown", { method: "POST" }),- routingEnv(),- )- expect(res.status).toBe(404)- })-- it("returns 405 for non-POST methods", async () => {- const res = await handler.fetch(- new Request("http://localhost/send/otp", { method: "GET" }),- routingEnv(),- )- expect(res.status).toBe(405)- })-})--// ─── Group 8: IMAP management routes ───--describe("IMAP management routes", () => {- function imapEnv() {- const { bucket } = createMockR2()- const { fetcher } = createMockFetcher()- const { sendEmail } = createMockSendEmail()- const doFetch = vi.fn().mockResolvedValue(Response.json({ ok: true }))- const mockStub = { fetch: doFetch }- const mockIdFromName = vi.fn().mockReturnValue("do-id-1")- const mockGet = vi.fn().mockReturnValue(mockStub)- const imapPoller = { idFromName: mockIdFromName, get: mockGet } as unknown as DurableObjectNamespace- return {- env: { DB: {} as D1Database, EMAIL_BUCKET: bucket, WEB_SERVICE: fetcher, SEND_EMAIL: sendEmail, IMAP_POLLER: imapPoller, ENCRYPTION_KEY: "test-secret" },- doFetch,- mockIdFromName,- mockGet,- }- }-- it("POST /imap/start forwards to DO with accountId", async () => {- const { env, doFetch, mockIdFromName } = imapEnv()- const res = await handler.fetch(- new Request("http://localhost/imap/start?accountId=acc-1", { method: "POST" }),- env,- )- expect(res.status).toBe(200)- expect(mockIdFromName).toHaveBeenCalledWith("acc-1")- expect(doFetch).toHaveBeenCalledOnce()- const [req] = doFetch.mock.calls[0] as [Request]- expect(new URL(req.url).pathname).toBe("/start")- const body = await req.json()- expect(body).toEqual({ accountId: "acc-1" })- })-- it("POST /imap/stop forwards to DO", async () => {- const { env, doFetch } = imapEnv()- const res = await handler.fetch(- new Request("http://localhost/imap/stop?accountId=acc-1", { method: "POST" }),- env,- )- expect(res.status).toBe(200)- const [req] = doFetch.mock.calls[0] as [Request]- expect(new URL(req.url).pathname).toBe("/stop")- })-- it("POST /imap/sync forwards to DO", async () => {- const { env, doFetch } = imapEnv()- const res = await handler.fetch(- new Request("http://localhost/imap/sync?accountId=acc-1", { method: "POST" }),- env,- )- expect(res.status).toBe(200)- const [req] = doFetch.mock.calls[0] as [Request]- expect(new URL(req.url).pathname).toBe("/sync")- })-- it("GET /imap/status forwards to DO", async () => {- const { env, doFetch } = imapEnv()- const res = await handler.fetch(- new Request("http://localhost/imap/status?accountId=acc-1", { method: "GET" }),- env,- )- expect(res.status).toBe(200)- const [req] = doFetch.mock.calls[0] as [Request]- expect(new URL(req.url).pathname).toBe("/status")- expect(req.method).toBe("GET")- })-- it("returns 400 when accountId is missing", async () => {- const { env } = imapEnv()- const res = await handler.fetch(- new Request("http://localhost/imap/start", { method: "POST" }),- env,- )- expect(res.status).toBe(400)- })-})diff --git a/src/email-worker/test-runtime/apply-migrations.ts b/src/email-worker/test-runtime/apply-migrations.tsnew file mode 100644index 000000000..61bb6b068--- /dev/null+++ b/src/email-worker/test-runtime/apply-migrations.ts@@ -0,0 +1,15 @@+/// <reference types="@cloudflare/vitest-plugin/types" />++import type { D1Migration } from "@cloudflare/vitest-plugin"+import { applyD1Migrations } from "cloudflare:test"+import { env } from "cloudflare:workers"+import { beforeAll } from "vitest"++const runtimeEnv = env as unknown as {+ DB: D1Database+ TEST_MIGRATIONS: D1Migration[]+}++beforeAll(async () => {+ await applyD1Migrations(runtimeEnv.DB, runtimeEnv.TEST_MIGRATIONS)+})diff --git a/src/email-worker/test-runtime/worker.runtime.test.ts b/src/email-worker/test-runtime/worker.runtime.test.tsnew file mode 100644index 000000000..8862ae26b--- /dev/null+++ b/src/email-worker/test-runtime/worker.runtime.test.ts@@ -0,0 +1,98 @@+/// <reference types="@cloudflare/vitest-plugin/types" />++import { runInDurableObject } from "cloudflare:test"+import { env, exports } from "cloudflare:workers"+import { describe, expect, it } from "vitest"++const runtimeEnv = env as unknown as {+ DB: D1Database+ EMAIL_BUCKET: R2Bucket+ IMAP_POLLER: DurableObjectNamespace+}++const worker = (exports as unknown as {+ default: { fetch(request: Request): Promise<Response> }+}).default++describe("email-worker workerd runtime", () => {+ it("loads production migrations and serves the production entrypoint", async () => {+ const schema = await runtimeEnv.DB.prepare(+ "SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?",+ ).bind("agent_email_account").first<{ name: string }>()+ expect(schema?.name).toBe("agent_email_account")++ const response = await worker.fetch(new Request("https://worker.test/health"))+ expect(response.status).toBe(200)+ await expect(response.json()).resolves.toEqual({ status: "ok" })+ })++ it("reads and writes through the real email R2 binding", async () => {+ const key = `runtime/${crypto.randomUUID()}`+ await runtimeEnv.EMAIL_BUCKET.put(key, "runtime email")++ const stored = await runtimeEnv.EMAIL_BUCKET.get(key)+ expect(stored).not.toBeNull()+ await expect(stored!.text()).resolves.toBe("runtime email")++ await runtimeEnv.EMAIL_BUCKET.delete(key)+ await expect(runtimeEnv.EMAIL_BUCKET.get(key)).resolves.toBeNull()+ })++ it("rejects unsupported methods, paths, and missing IMAP account ids", async () => {+ const unknown = await worker.fetch(new Request("https://worker.test/unknown", {+ method: "POST",+ }))+ expect(unknown.status).toBe(404)++ const method = await worker.fetch(new Request("https://worker.test/send/otp"))+ expect(method.status).toBe(405)++ const missingAccount = await worker.fetch(new Request("https://worker.test/imap/start", {+ method: "POST",+ }))+ expect(missingAccount.status).toBe(400)+ })++ it("forwards status and sync routes to the real IMAP Durable Object", async () => {+ const accountId = `runtime-${crypto.randomUUID()}`+ const status = await worker.fetch(new Request(+ `https://worker.test/imap/status?accountId=${encodeURIComponent(accountId)}`,+ ))+ expect(status.status).toBe(200)+ await expect(status.json()).resolves.toEqual({ status: "stopped" })++ const sync = await worker.fetch(new Request(+ `https://worker.test/imap/sync?accountId=${encodeURIComponent(accountId)}`,+ { method: "POST" },+ ))+ expect(sync.status).toBe(200)+ await expect(sync.json()).resolves.toEqual({ ok: true })+ })++ it("persists and clears state through the real IMAP Durable Object", async () => {+ const accountId = `runtime-${crypto.randomUUID()}`+ const start = await worker.fetch(new Request(+ `https://worker.test/imap/start?accountId=${encodeURIComponent(accountId)}`,+ { method: "POST" },+ ))+ expect(start.status).toBe(200)++ const id = runtimeEnv.IMAP_POLLER.idFromName(accountId)+ const stub = runtimeEnv.IMAP_POLLER.get(id)+ await runInDurableObject(stub, async (_instance, state) => {+ await expect(state.storage.get("accountId")).resolves.toBe(accountId)+ await expect(state.storage.getAlarm()).resolves.not.toBeNull()+ })++ const stop = await worker.fetch(new Request(+ `https://worker.test/imap/stop?accountId=${encodeURIComponent(accountId)}`,+ { method: "POST" },+ ))+ expect(stop.status).toBe(200)++ await runInDurableObject(stub, async (_instance, state) => {+ await expect(state.storage.get("accountId")).resolves.toBeUndefined()+ await expect(state.storage.getAlarm()).resolves.toBeNull()+ })+ })+})diff --git a/src/email-worker/tsconfig.json b/src/email-worker/tsconfig.jsonindex 518648f89..78de84a31 100644--- a/src/email-worker/tsconfig.json+++ b/src/email-worker/tsconfig.json@@ -3,5 +3,5 @@"target": "ES2022", "module": "ESNext", "moduleResolution": "bundler","strict": true, "skipLibCheck": true, "types": ["@cloudflare/workers-types", "node"], "lib": ["ES2022"]},- "include": ["src"]+ "include": ["src", "test-runtime"]}diff --git a/src/email-worker/vitest.config.ts b/src/email-worker/vitest.config.tsindex 5a8caddbb..0f2dbe865 100644--- a/src/email-worker/vitest.config.ts+++ b/src/email-worker/vitest.config.ts@@ -3,6 +3,8 @@ import shared from "../../vitest.shared"export default mergeConfig(shared, defineConfig({test: {+ name: "email-worker-node",include: ["src/**/*.test.ts"],+ sequence: { groupOrder: 1 },},}))diff --git a/src/email-worker/vitest.runtime.config.mts b/src/email-worker/vitest.runtime.config.mtsnew file mode 100644index 000000000..4c6d141be--- /dev/null+++ b/src/email-worker/vitest.runtime.config.mts@@ -0,0 +1,28 @@+import path from "node:path"+import { cloudflareTest, readD1Migrations } from "@cloudflare/vitest-plugin"+import { defineProject } from "vitest/config"++const migrations = await readD1Migrations(path.resolve(import.meta.dirname, "../web/migrations"))++export default defineProject({+ plugins: [+ cloudflareTest({+ wrangler: { configPath: "./wrangler.toml" },+ miniflare: {+ bindings: {+ ENCRYPTION_KEY: "runtime-test-encryption-key",+ TEST_MIGRATIONS: migrations,+ },+ serviceBindings: {+ WEB_SERVICE: () => new Response("ok"),+ },+ },+ }),+ ],+ test: {+ name: "email-worker-runtime",+ include: ["test-runtime/**/*.runtime.test.ts"],+ setupFiles: ["test-runtime/apply-migrations.ts"],+ sequence: { groupOrder: 11 },+ },+})diff --git a/src/email-worker/vitest.workspace.config.ts b/src/email-worker/vitest.workspace.config.tsnew file mode 100644index 000000000..0a2898afa--- /dev/null+++ b/src/email-worker/vitest.workspace.config.ts@@ -0,0 +1,7 @@+import { defineConfig } from "vitest/config"++export default defineConfig({+ test: {+ projects: ["./vitest.config.ts", "./vitest.runtime.config.mts"],+ },+})diff --git a/src/shared/src/browser/meet-navigator.ts b/src/shared/src/browser/meet-navigator.tsindex 2fd7ce9dc..f5e10e0a7 100644--- a/src/shared/src/browser/meet-navigator.ts+++ b/src/shared/src/browser/meet-navigator.ts@@ -25,6 +25,7 @@ async function dismissDialogs(page: BrowserPage): Promise<void> {}async function detectBlocked(page: BrowserPage): Promise<void> {+ /* istanbul ignore next -- this callback is serialized into the browser */const blocked = await page.evaluate(() => {const text = document.body?.innerText || ""if (text.includes("can't join") || text.includes("unable to join") || text.includes("无法加入")) {@@ -59,6 +60,7 @@ export async function joinMeeting(page: BrowserPage, meetingUrl: string, botName}// Mute mic and camera — try both pre-join (data-is-muted) and in-meeting (aria-label) patterns+ /* istanbul ignore next -- this callback is serialized into the browser */await page.evaluate(() => {const btns = document.querySelectorAll('button');for (const btn of btns) {@@ -77,6 +79,7 @@ export async function joinMeeting(page: BrowserPage, meetingUrl: string, botName})// "Ask to join" / "Join now" — find by text content, language-independent via evaluate+ /* istanbul ignore next -- this callback is serialized into the browser */const joined = await page.evaluate(() => {const deadline = Date.now() + 15_000;return new Promise((resolve) => {@@ -106,6 +109,7 @@ export async function joinMeeting(page: BrowserPage, meetingUrl: string, botNameexport async function enableCaptions(page: BrowserPage): Promise<void> {// Click the captions button to open the transcript side panel.// The button contains a "closed_caption" icon text — find it by that.+ /* istanbul ignore next -- this callback is serialized into the browser */const clicked = await page.evaluate(() => {const btns = document.querySelectorAll('button');for (const btn of btns) {@@ -127,6 +131,7 @@ export async function enableCaptions(page: BrowserPage): Promise<void> {export async function waitForMeetingReady(page: BrowserPage, timeoutMs = 60_000): Promise<void> {const deadline = Date.now() + timeoutMswhile (Date.now() < deadline) {+ /* istanbul ignore next -- this callback is serialized into the browser */const state = await page.evaluate(() => {const text = document.body?.innerText || ""if (text.includes("Please wait") || text.includes("请等待")) return "waiting"@@ -175,6 +180,7 @@ export function buildAloneDetectorScript(): string {export async function isMeetingActive(page: BrowserPage): Promise<boolean> {try {+ /* istanbul ignore next -- this callback is serialized into the browser */return await page.evaluate(() => {const leaveBtn = document.querySelector('button[aria-label="Leave call" i], button[aria-label*="hang up" i]')if (!leaveBtn) return falsediff --git a/src/wake-worker/knip.json b/src/wake-worker/knip.jsonindex d768344ce..e027ee325 100644--- a/src/wake-worker/knip.json+++ b/src/wake-worker/knip.json@@ -1,12 +1,17 @@{"$schema": "https://unpkg.com/knip@6/schema.json","project": [- "src/**/*.ts"+ "src/**/*.ts",+ "test-runtime/**/*.ts"],"includeEntryExports": true,+ "ignoreDependencies": [+ "cloudflare"+ ],"vitest": {"entry": [- "src/**/*.test.ts"+ "src/**/*.test.ts",+ "test-runtime/**/*.test.ts"]}-}\ No newline at end of file+}diff --git a/src/wake-worker/package.json b/src/wake-worker/package.jsonindex d38b4708f..8fb50705f 100644--- a/src/wake-worker/package.json+++ b/src/wake-worker/package.json@@ -6,18 +6,19 @@"dev": "node ../../scripts/dev-with-wrangler-registry.mjs ../../.wrangler/registry wrangler dev --persist-to ../web/.wrangler/state","deploy": "wrangler deploy","knip": "knip",- "test": "vitest run",+ "test": "vitest run --config vitest.workspace.config.ts","typecheck": "tsc --noEmit"},"dependencies": {"@alook/shared": "workspace:*"},"devDependencies": {+ "@cloudflare/vitest-plugin": "1.0.0","@cloudflare/workers-types": "^4.20260702.1","@types/node": "^25.9.4","knip": "^6.32.2","typescript": "^6.0.3","vitest": "^4.1.10",- "wrangler": "^4.122.0"+ "wrangler": "^4.125.0"}}diff --git a/src/wake-worker/src/index.test.ts b/src/wake-worker/src/index.test.tsindex 0f141052a..01d52e5b2 100644--- a/src/wake-worker/src/index.test.ts+++ b/src/wake-worker/src/index.test.ts@@ -219,27 +219,6 @@ describe("wake-worker dev-only HTTP entrypoint (fetch)", () => {]))})- it("returns 400 on invalid JSON body", async () => {- const res = await handler.fetch!(new Request("http://internal/", { method: "POST", body: "not json" }), env)-- expect(res.status).toBe(400)- expect(mockDispatchOneUnreadWake).not.toHaveBeenCalled()- })-- it("returns 405 for non-POST methods", async () => {- const res = await handler.fetch!(makeRequest("GET"), env)-- expect(res.status).toBe(405)- expect(mockDispatchOneUnreadWake).not.toHaveBeenCalled()- })-- it("returns 200 { status: ok } for GET /health without touching dispatch", async () => {- const res = await handler.fetch!(new Request("http://internal/health", { method: "GET" }), env)-- expect(res.status).toBe(200)- expect(await res.json()).toEqual({ status: "ok" })- expect(mockDispatchOneUnreadWake).not.toHaveBeenCalled()- })})/**diff --git a/src/wake-worker/test-runtime/apply-migrations.ts b/src/wake-worker/test-runtime/apply-migrations.tsnew file mode 100644index 000000000..61bb6b068--- /dev/null+++ b/src/wake-worker/test-runtime/apply-migrations.ts@@ -0,0 +1,15 @@+/// <reference types="@cloudflare/vitest-plugin/types" />++import type { D1Migration } from "@cloudflare/vitest-plugin"+import { applyD1Migrations } from "cloudflare:test"+import { env } from "cloudflare:workers"+import { beforeAll } from "vitest"++const runtimeEnv = env as unknown as {+ DB: D1Database+ TEST_MIGRATIONS: D1Migration[]+}++beforeAll(async () => {+ await applyD1Migrations(runtimeEnv.DB, runtimeEnv.TEST_MIGRATIONS)+})diff --git a/src/wake-worker/test-runtime/worker.runtime.test.ts b/src/wake-worker/test-runtime/worker.runtime.test.tsnew file mode 100644index 000000000..0e3fe4df8--- /dev/null+++ b/src/wake-worker/test-runtime/worker.runtime.test.ts@@ -0,0 +1,67 @@+/// <reference types="@cloudflare/vitest-plugin/types" />++import type { WakePayload } from "@alook/shared"+import { env, exports } from "cloudflare:workers"+import { describe, expect, it } from "vitest"++type RuntimeQueueMessage<T> = {+ id: string+ timestamp: Date+ attempts: number+ body: T+}++type RuntimeQueueResult = {+ outcome: string+ explicitAcks: string[]+ retryMessages: Array<{ msgId: string }>+}++const runtimeEnv = env as unknown as { DB: D1Database }+const worker = (exports as unknown as {+ default: {+ fetch(request: Request): Promise<Response>+ queue(queueName: string, messages: RuntimeQueueMessage<WakePayload>[]): Promise<RuntimeQueueResult>+ }+}).default++describe("wake-worker workerd runtime", () => {+ it("loads production migrations and serves the production entrypoint", async () => {+ const schema = await runtimeEnv.DB.prepare(+ "SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?",+ ).bind("community_message").first<{ name: string }>()+ expect(schema?.name).toBe("community_message")++ const response = await worker.fetch(new Request("https://worker.test/health"))+ expect(response.status).toBe(200)+ await expect(response.json()).resolves.toEqual({ status: "ok" })+ })++ it("rejects invalid JSON and non-POST dev requests at the real entrypoint", async () => {+ const malformed = await worker.fetch(new Request("https://worker.test/", {+ method: "POST",+ body: "not json",+ }))+ expect(malformed.status).toBe(400)++ const method = await worker.fetch(new Request("https://worker.test/"))+ expect(method.status).toBe(405)+ })++ it("acks a permanent D1 miss through the real queue entrypoint", async () => {+ const id = `runtime-${crypto.randomUUID()}`+ const result = await worker.queue("alook-wake", [{+ id,+ timestamp: new Date(),+ attempts: 1,+ body: {+ messageId: `missing-message-${crypto.randomUUID()}`,+ botUserId: `missing-bot-${crypto.randomUUID()}`,+ },+ }])++ expect(result.outcome).toBe("ok")+ expect(result.explicitAcks).toContain(id)+ expect(result.retryMessages).toEqual([])+ })+})diff --git a/src/wake-worker/tsconfig.json b/src/wake-worker/tsconfig.jsonindex d7bbb48cd..a24d423b4 100644--- a/src/wake-worker/tsconfig.json+++ b/src/wake-worker/tsconfig.json@@ -14,6 +14,7 @@]},"include": [- "src"+ "src",+ "test-runtime"]-}\ No newline at end of file+}diff --git a/src/wake-worker/vitest.config.ts b/src/wake-worker/vitest.config.tsindex 5a8caddbb..ba2cf9ee6 100644--- a/src/wake-worker/vitest.config.ts+++ b/src/wake-worker/vitest.config.ts@@ -3,6 +3,8 @@ import shared from "../../vitest.shared"export default mergeConfig(shared, defineConfig({test: {+ name: "wake-worker-node",include: ["src/**/*.test.ts"],+ sequence: { groupOrder: 1 },},}))diff --git a/src/wake-worker/vitest.runtime.config.mts b/src/wake-worker/vitest.runtime.config.mtsnew file mode 100644index 000000000..37a5bfc17--- /dev/null+++ b/src/wake-worker/vitest.runtime.config.mts@@ -0,0 +1,26 @@+import path from "node:path"+import { cloudflareTest, readD1Migrations } from "@cloudflare/vitest-plugin"+import { defineProject } from "vitest/config"++const migrations = await readD1Migrations(path.resolve(import.meta.dirname, "../web/migrations"))++export default defineProject({+ plugins: [+ cloudflareTest({+ wrangler: { configPath: "./wrangler.toml" },+ miniflare: {+ bindings: { TEST_MIGRATIONS: migrations },+ compatibilityFlags: ["nodejs_compat", "service_binding_extra_handlers"],+ serviceBindings: {+ WS_DO_WORKER: () => Response.json({ delivered: 0 }),+ },+ },+ }),+ ],+ test: {+ name: "wake-worker-runtime",+ include: ["test-runtime/**/*.runtime.test.ts"],+ setupFiles: ["test-runtime/apply-migrations.ts"],+ sequence: { groupOrder: 12 },+ },+})diff --git a/src/wake-worker/vitest.workspace.config.ts b/src/wake-worker/vitest.workspace.config.tsnew file mode 100644index 000000000..0a2898afa--- /dev/null+++ b/src/wake-worker/vitest.workspace.config.ts@@ -0,0 +1,7 @@+import { defineConfig } from "vitest/config"++export default defineConfig({+ test: {+ projects: ["./vitest.config.ts", "./vitest.runtime.config.mts"],+ },+})diff --git a/src/web/custom-worker.ts b/src/web/custom-worker.tsindex d9d2b94d6..68bcd886e 100644--- a/src/web/custom-worker.ts+++ b/src/web/custom-worker.ts@@ -2,42 +2,9 @@// exist at typecheck time. The build step creates it before wrangler bundles.// @ts-ignore — generated at build time, may not exist yetimport openNextHandler from "./.open-next/worker.js"+import { createWebWorkerHandler } from "./src/lib/worker-runtime"// @ts-ignore — generated at build time, may not exist yetexport { DOQueueHandler } from "./.open-next/worker.js"-const PRIVATE_PREFIXES = ["/w/", "/workspaces", "/dashboard", "/invite/", "/api/", "/_next/"]--function isPublicRoute(pathname: string): boolean {- return !PRIVATE_PREFIXES.some((p) => pathname.startsWith(p))-}--const handler: ExportedHandler<CloudflareEnv> = {- async fetch(request, env, ctx) {- const url = new URL(request.url)- const isWsUpgrade = request.headers.get("Upgrade")?.toLowerCase() === "websocket"- const isWsPath = url.pathname === "/api/ws" || url.pathname.startsWith("/api/ws/")-- // Forward WebSocket upgrades on /api/ws/* directly to the ws-do worker.- // OpenNext drops Response.webSocket when wrapping Next.js route handlers- // (opennextjs-cloudflare#784), so we intercept before Next.js sees it.- // /api/ws/token is a plain HTTP endpoint — it has no Upgrade header and- // falls through to OpenNext.- if (isWsUpgrade && isWsPath) {- return env.WS_DO_WORKER.fetch(request)- }-- const response = await (openNextHandler as ExportedHandler<CloudflareEnv>).fetch!(request, env, ctx)-- if (isPublicRoute(url.pathname) && response.status === 200) {- const res = new Response(response.body, response)- res.headers.set("Cache-Control", "public, max-age=0, must-revalidate")- res.headers.set("CDN-Cache-Control", "public, s-maxage=3600, stale-while-revalidate=86400")- return res- }-- return response- },-}--export default handler+export default createWebWorkerHandler(openNextHandler as ExportedHandler<CloudflareEnv>)diff --git a/src/web/knip.json b/src/web/knip.jsonindex a1404278f..20bf820fd 100644--- a/src/web/knip.json+++ b/src/web/knip.json@@ -7,12 +7,15 @@"src/app/**/error.tsx","src/app/**/not-found.tsx","src/app/globals.css",+ "src/test-runtime/open-next-node-stub.ts",+ "test-runtime/open-next-worker-stub.ts","open-next.config.ts","scripts/**/*.{ts,mjs}"],- "project": ["src/**/*.{ts,tsx}", "scripts/**/*.{ts,mjs}"],+ "project": ["src/**/*.{ts,tsx}", "scripts/**/*.{ts,mjs}", "test-runtime/**/*.ts"],"ignoreDependencies": [- "@tailwindcss/node"+ "@tailwindcss/node",+ "cloudflare"],"ignoreBinaries": ["lsof"@@ -22,7 +25,7 @@"src/app/(app)/workspaces/client.tsx"],"vitest": {- "entry": ["src/**/*.test.{ts,tsx}", "src/test/**/*.{ts,tsx}"]+ "entry": ["src/**/*.test.{ts,tsx}", "src/test/**/*.{ts,tsx}", "test-runtime/**/*.test.ts"]},"eslint": {"entry": ["eslint.config.mjs"]diff --git a/src/web/package.json b/src/web/package.jsonindex e7e63ac4c..a6798475b 100644--- a/src/web/package.json+++ b/src/web/package.json@@ -13,7 +13,7 @@"upload": "opennextjs-cloudflare build && opennextjs-cloudflare upload","preview": "opennextjs-cloudflare build && opennextjs-cloudflare preview","cf-typegen": "wrangler types --env-interface CloudflareEnv ./cloudflare-env.d.ts",- "test": "vitest run",+ "test": "vitest run --config vitest.workspace.config.ts","test:watch": "vitest","test:e2e": "vitest run --config vitest.e2e.config.ts","test:e2e-ui": "playwright test",@@ -108,6 +108,7 @@},"devDependencies": {"@alook/test-utils": "workspace:*",+ "@cloudflare/vitest-plugin": "1.0.0","@lhci/cli": "^0.15.1","@playwright/test": "^1.62.1","@tailwindcss/node": "^4.3.3",@@ -131,6 +132,6 @@"typescript": "^6.0.3","unified": "^11.0.5","vitest": "^4.1.10",- "wrangler": "^4.122.0"+ "wrangler": "^4.125.0"}}diff --git a/src/web/src/lib/worker-runtime.ts b/src/web/src/lib/worker-runtime.tsnew file mode 100644index 000000000..1b3a3e2f2--- /dev/null+++ b/src/web/src/lib/worker-runtime.ts@@ -0,0 +1,34 @@+const PRIVATE_PREFIXES = ["/w/", "/workspaces", "/dashboard", "/invite/", "/api/", "/_next/"]++function isPublicRoute(pathname: string): boolean {+ return !PRIVATE_PREFIXES.some((prefix) => pathname.startsWith(prefix))+}++export function createWebWorkerHandler(+ openNextHandler: ExportedHandler<CloudflareEnv>,+): ExportedHandler<CloudflareEnv> {+ return {+ async fetch(request, env, ctx) {+ const url = new URL(request.url)+ const isWsUpgrade = request.headers.get("Upgrade")?.toLowerCase() === "websocket"+ const isWsPath = url.pathname === "/api/ws" || url.pathname.startsWith("/api/ws/")++ if (isWsUpgrade && isWsPath) {+ return env.WS_DO_WORKER.fetch(request)+ }++ const response = await openNextHandler.fetch!(request, env, ctx)+ if (isPublicRoute(url.pathname) && response.status === 200) {+ const cacheableResponse = new Response(response.body, response)+ cacheableResponse.headers.set("Cache-Control", "public, max-age=0, must-revalidate")+ cacheableResponse.headers.set(+ "CDN-Cache-Control",+ "public, s-maxage=3600, stale-while-revalidate=86400",+ )+ return cacheableResponse+ }++ return response+ },+ }+}diff --git a/src/web/src/test-runtime/custom-worker.test.ts b/src/web/src/test-runtime/custom-worker.test.tsnew file mode 100644index 000000000..8c46e2308--- /dev/null+++ b/src/web/src/test-runtime/custom-worker.test.ts@@ -0,0 +1,21 @@+import handler, { DOQueueHandler } from "../../custom-worker"+import { describe, expect, it, vi } from "vitest"++describe("custom Worker composition", () => {+ it("composes the generated OpenNext module with the production runtime seam", async () => {+ const wsFetch = vi.fn(async () => new Response("ws"))+ const env = { WS_DO_WORKER: { fetch: wsFetch } } as unknown as CloudflareEnv++ const response = await handler.fetch!(+ new Request("https://worker.test/pricing"),+ env,+ {} as ExecutionContext,+ )++ expect(DOQueueHandler).toBeDefined()+ expect(await response.text()).toBe("node-open-next")+ expect(response.headers.get("x-open-next")).toBe("node-stub")+ expect(response.headers.get("Cache-Control")).toBe("public, max-age=0, must-revalidate")+ expect(wsFetch).not.toHaveBeenCalled()+ })+})diff --git a/src/web/src/test-runtime/open-next-node-stub.ts b/src/web/src/test-runtime/open-next-node-stub.tsnew file mode 100644index 000000000..2ba416557--- /dev/null+++ b/src/web/src/test-runtime/open-next-node-stub.ts@@ -0,0 +1,11 @@+export class DOQueueHandler {}++const openNextNodeStub = {+ async fetch(): Promise<Response> {+ return new Response("node-open-next", {+ headers: { "x-open-next": "node-stub" },+ })+ },+}++export default openNextNodeStubdiff --git a/src/web/test-runtime/apply-migrations.ts b/src/web/test-runtime/apply-migrations.tsnew file mode 100644index 000000000..e7fef164d--- /dev/null+++ b/src/web/test-runtime/apply-migrations.ts@@ -0,0 +1,14 @@+/// <reference types="@cloudflare/vitest-plugin/types" />++import type { D1Migration } from "@cloudflare/vitest-plugin"+import { applyD1Migrations } from "cloudflare:test"+import { env } from "cloudflare:workers"+import { beforeAll } from "vitest"++const runtimeEnv = env as unknown as CloudflareEnv & {+ TEST_MIGRATIONS: D1Migration[]+}++beforeAll(async () => {+ await applyD1Migrations(runtimeEnv.DB, runtimeEnv.TEST_MIGRATIONS)+})diff --git a/src/web/test-runtime/assets/fixture.txt b/src/web/test-runtime/assets/fixture.txtnew file mode 100644index 000000000..90b11b744--- /dev/null+++ b/src/web/test-runtime/assets/fixture.txt@@ -0,0 +1 @@+workerd asset fixturediff --git a/src/web/test-runtime/open-next-worker-stub.ts b/src/web/test-runtime/open-next-worker-stub.tsnew file mode 100644index 000000000..fb68707ae--- /dev/null+++ b/src/web/test-runtime/open-next-worker-stub.ts@@ -0,0 +1,15 @@+import { DurableObject } from "cloudflare:workers"++export class DOQueueHandler extends DurableObject<CloudflareEnv> {}++const openNextHandler: ExportedHandler<CloudflareEnv> = {+ async fetch(request) {+ const url = new URL(request.url)+ return new Response(`open-next:${url.pathname}`, {+ status: url.pathname === "/missing" ? 404 : 200,+ headers: { "x-open-next": "test-entry" },+ })+ },+}++export default openNextHandlerdiff --git a/src/web/test-runtime/worker.runtime.test.ts b/src/web/test-runtime/worker.runtime.test.tsnew file mode 100644index 000000000..649c765f7--- /dev/null+++ b/src/web/test-runtime/worker.runtime.test.ts@@ -0,0 +1,101 @@+/// <reference types="@cloudflare/vitest-plugin/types" />++import { runInDurableObject } from "cloudflare:test"+import { env, exports } from "cloudflare:workers"+import { describe, expect, it } from "vitest"++const runtimeEnv = env as unknown as CloudflareEnv+const worker = (exports as unknown as {+ default: { fetch(request: Request): Promise<Response> }+}).default++describe("Web workerd runtime", () => {+ it("loads production migrations and local storage bindings", async () => {+ const schema = await runtimeEnv.DB.prepare(+ "SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?",+ ).bind("community_machine").first<{ name: string }>()+ expect(schema?.name).toBe("community_machine")++ const r2Key = `runtime/${crypto.randomUUID()}`+ await runtimeEnv.COMMUNITY_MEDIA.put(r2Key, "runtime media")+ await expect((await runtimeEnv.COMMUNITY_MEDIA.get(r2Key))!.text()).resolves.toBe("runtime media")+ await runtimeEnv.COMMUNITY_MEDIA.delete(r2Key)++ const kvKey = `runtime:${crypto.randomUUID()}`+ await runtimeEnv.CACHE_KV.put(kvKey, "runtime cache")+ await expect(runtimeEnv.CACHE_KV.get(kvKey)).resolves.toBe("runtime cache")+ await runtimeEnv.CACHE_KV.delete(kvKey)+ })++ it.each(["/", "/pricing", "/apiary"])(+ "adds browser and CDN revalidation headers to public route %s",+ async (pathname) => {+ const publicResponse = await worker.fetch(new Request(`https://worker.test${pathname}`))+ expect(await publicResponse.text()).toBe(`open-next:${pathname}`)+ expect(publicResponse.headers.get("x-open-next")).toBe("test-entry")+ expect(publicResponse.headers.get("Cache-Control")).toBe(+ "public, max-age=0, must-revalidate",+ )+ expect(publicResponse.headers.get("CDN-Cache-Control")).toBe(+ "public, s-maxage=3600, stale-while-revalidate=86400",+ )+ },+ )++ it.each(["/w/one", "/workspaces", "/dashboard/one", "/invite/one", "/api/one", "/_next/one"])(+ "does not add public cache headers to private route %s",+ async (pathname) => {+ const privateResponse = await worker.fetch(new Request(`https://worker.test${pathname}`))+ expect(await privateResponse.text()).toBe(`open-next:${pathname}`)+ expect(privateResponse.headers.get("Cache-Control")).toBeNull()+ expect(privateResponse.headers.get("CDN-Cache-Control")).toBeNull()+ },+ )++ it("returns a non-200 public response unchanged", async () => {+ const response = await worker.fetch(new Request("https://worker.test/missing"))+ expect(response.status).toBe(404)+ expect(await response.text()).toBe("open-next:/missing")+ expect(response.headers.get("Cache-Control")).toBeNull()+ expect(response.headers.get("CDN-Cache-Control")).toBeNull()+ })++ it.each(["/api/ws", "/api/ws/socket"])(+ "forwards WebSocket upgrade %s through the configured service binding",+ async (pathname) => {+ const response = await worker.fetch(new Request(`https://worker.test${pathname}`, {+ headers: { Upgrade: "websocket" },+ }))++ expect(response.status).toBe(101)+ expect(response.headers.get("x-runtime-pathname")).toBe(pathname)+ expect(response.headers.get("x-runtime-upgrade")).toBe("websocket")+ expect(response.webSocket).not.toBeNull()+ response.webSocket?.accept()+ response.webSocket?.close(1000, "runtime test complete")+ },+ )++ it.each([+ ["plain token request", "/api/ws/token", undefined],+ ["upgrade outside the ws route", "/socket", { Upgrade: "websocket" }],+ ])("keeps %s in the OpenNext path", async (_name, pathname, headers) => {+ const response = await worker.fetch(new Request(`https://worker.test${pathname}`, { headers }))+ expect(response.status).toBe(200)+ expect(await response.text()).toBe(`open-next:${pathname}`)+ expect(response.headers.get("x-open-next")).toBe("test-entry")+ })++ it("exposes the production asset and Durable Object bindings locally", async () => {+ const asset = await runtimeEnv.ASSETS.fetch(new Request("https://assets.test/fixture.txt"))+ expect(asset.status).toBe(200)+ expect((await asset.text()).trim()).toBe("workerd asset fixture")++ const id = runtimeEnv.NEXT_CACHE_DO_QUEUE.idFromName(`runtime-${crypto.randomUUID()}`)+ const stub = runtimeEnv.NEXT_CACHE_DO_QUEUE.get(id)+ await runInDurableObject(stub, async (_instance, state) => {+ await state.storage.put("runtime", "durable")+ await expect(state.storage.get("runtime")).resolves.toBe("durable")+ })+ })+})diff --git a/src/web/vitest.config.ts b/src/web/vitest.config.tsindex 91a9b008e..1611bb4c4 100644--- a/src/web/vitest.config.ts+++ b/src/web/vitest.config.ts@@ -6,9 +6,11 @@ export default mergeConfig(shared, defineConfig({resolve: {alias: {"@": path.resolve(__dirname, "src"),+ "./.open-next/worker.js": path.resolve(__dirname, "src/test-runtime/open-next-node-stub.ts"),},},test: {+ name: "web-node",testTimeout: 30_000,hookTimeout: 30_000,include: ["src/**/*.test.ts", "scripts/**/*.test.ts", "readme-capture/**/*.test.ts"],diff --git a/src/web/vitest.runtime.config.mts b/src/web/vitest.runtime.config.mtsnew file mode 100644index 000000000..f960e98fa--- /dev/null+++ b/src/web/vitest.runtime.config.mts@@ -0,0 +1,59 @@+import path from "node:path"+import { cloudflareTest, readD1Migrations } from "@cloudflare/vitest-plugin"+import { defineProject } from "vitest/config"++const migrations = await readD1Migrations(path.resolve(import.meta.dirname, "migrations"))++export default defineProject({+ resolve: {+ alias: {+ "./.open-next/worker.js": path.resolve(+ import.meta.dirname,+ "test-runtime/open-next-worker-stub.ts",+ ),+ },+ },+ plugins: [+ cloudflareTest({+ main: "./custom-worker.ts",+ wrangler: { configPath: "./wrangler.toml" },+ miniflare: {+ assets: {+ binding: "ASSETS",+ directory: path.resolve(import.meta.dirname, "test-runtime/assets"),+ },+ bindings: { TEST_MIGRATIONS: migrations },+ workers: [{+ name: "ws-do-runtime-stub",+ modules: true,+ script: `export default {+ fetch(request) {+ const pair = new WebSocketPair()+ pair[1].accept()+ return new Response(null, {+ status: 101,+ headers: {+ "x-runtime-pathname": new URL(request.url).pathname,+ "x-runtime-upgrade": request.headers.get("Upgrade") ?? "",+ },+ webSocket: pair[0],+ })+ },+ }`,+ }],+ serviceBindings: {+ WORKER_SELF_REFERENCE: () => new Response("self"),+ WS_DO_WORKER: "ws-do-runtime-stub",+ EMAIL_WORKER: () => new Response("email"),+ WAKE_WORKER: () => new Response("wake"),+ },+ },+ }),+ ],+ test: {+ name: "web-runtime",+ include: ["test-runtime/**/*.runtime.test.ts"],+ setupFiles: ["test-runtime/apply-migrations.ts"],+ sequence: { groupOrder: 13 },+ },+})diff --git a/src/web/vitest.workspace.config.ts b/src/web/vitest.workspace.config.tsnew file mode 100644index 000000000..0a2898afa--- /dev/null+++ b/src/web/vitest.workspace.config.ts@@ -0,0 +1,7 @@+import { defineConfig } from "vitest/config"++export default defineConfig({+ test: {+ projects: ["./vitest.config.ts", "./vitest.runtime.config.mts"],+ },+})diff --git a/src/ws-do/knip.json b/src/ws-do/knip.jsonindex a55d83df0..10076c589 100644--- a/src/ws-do/knip.json+++ b/src/ws-do/knip.json@@ -1,12 +1,12 @@{"$schema": "https://unpkg.com/knip@6/schema.json",- "project": ["src/**/*.ts"],+ "project": ["src/**/*.ts", "test-runtime/**/*.ts"],"ignore": ["src/__mocks__/**"],"includeEntryExports": true,"ignoreDependencies": ["cloudflare"],"vitest": {- "entry": ["src/**/*.test.ts"]+ "entry": ["src/**/*.test.ts", "test-runtime/**/*.test.ts"]}}diff --git a/src/ws-do/package.json b/src/ws-do/package.jsonindex 772e6049a..2d90a27b5 100644--- a/src/ws-do/package.json+++ b/src/ws-do/package.json@@ -6,18 +6,19 @@"dev": "node ../../scripts/dev-with-wrangler-registry.mjs ../../.wrangler/registry wrangler dev --persist-to ../web/.wrangler/state","deploy": "wrangler deploy","knip": "knip",- "test": "vitest run --passWithNoTests",+ "test": "vitest run --config vitest.workspace.config.ts","typecheck": "tsc --noEmit -p tsconfig.typecheck.json"},"dependencies": {"@alook/shared": "workspace:*"},"devDependencies": {+ "@cloudflare/vitest-plugin": "1.0.0","@cloudflare/workers-types": "^4.20260702.1","@types/node": "^25.9.4","knip": "^6.32.2","typescript": "^6.0.3","vitest": "^4.1.10",- "wrangler": "^4.122.0"+ "wrangler": "^4.125.0"}}diff --git a/src/ws-do/src/rate-limit-do.test.ts b/src/ws-do/src/rate-limit-do.test.tsdeleted file mode 100644index 69ebd4c8e..000000000--- a/src/ws-do/src/rate-limit-do.test.ts+++ /dev/null@@ -1,109 +0,0 @@-import { describe, it, expect, vi, beforeEach } from "vitest"-import { createMockCtx } from "./__mocks__/cf"--vi.mock("cloudflare:workers", () => ({- DurableObject: class {- ctx: unknown- env: unknown- constructor(ctx: unknown, env: unknown) {- this.ctx = ctx- this.env = env- }- },-}))--import { RateLimitDurableObject } from "./rate-limit-do"--function makeDO() {- const mock = createMockCtx()- const doInstance = new RateLimitDurableObject(mock.ctx, {} as Env)- return { doInstance, ...mock }-}--async function check(- doInstance: RateLimitDurableObject,- windowMs: number,- max: number,-) {- const res = await doInstance.fetch(- new Request("http://internal/check", {- method: "POST",- headers: { "content-type": "application/json" },- body: JSON.stringify({ windowMs, max }),- }),- )- return (await res.json()) as { allowed: boolean; retryAfterSec?: number }-}--describe("RateLimitDurableObject", () => {- beforeEach(() => {- vi.useRealTimers()- })-- it("allows the first request when no state exists", async () => {- const { doInstance } = makeDO()- expect((await check(doInstance, 10_000, 30)).allowed).toBe(true)- })-- it("allows up to `max` sends within one window", async () => {- const { doInstance } = makeDO()- for (let i = 0; i < 30; i++) {- expect((await check(doInstance, 10_000, 30)).allowed).toBe(true)- }- })-- it("blocks the (max+1)th send with a positive retryAfter", async () => {- const { doInstance } = makeDO()- for (let i = 0; i < 30; i++) await check(doInstance, 10_000, 30)- const blocked = await check(doInstance, 10_000, 30)- expect(blocked.allowed).toBe(false)- expect(blocked.retryAfterSec).toBeGreaterThan(0)- })-- it("honours the caller-supplied window+max — the DO is policy-agnostic", async () => {- const { doInstance } = makeDO()- // Different caller with a tiny 3/1s policy- for (let i = 0; i < 3; i++) {- expect((await check(doInstance, 1_000, 3)).allowed).toBe(true)- }- expect((await check(doInstance, 1_000, 3)).allowed).toBe(false)- })-- it("resets the window once WINDOW has elapsed", async () => {- vi.useFakeTimers()- vi.setSystemTime(new Date("2026-01-01T00:00:00Z"))- const { doInstance } = makeDO()- for (let i = 0; i < 30; i++) await check(doInstance, 10_000, 30)- expect((await check(doInstance, 10_000, 30)).allowed).toBe(false)- vi.advanceTimersByTime(10_001)- expect((await check(doInstance, 10_000, 30)).allowed).toBe(true)- })-- it("returns 400 when windowMs/max is missing or non-positive", async () => {- const { doInstance } = makeDO()- const res = await doInstance.fetch(- new Request("http://internal/check", {- method: "POST",- headers: { "content-type": "application/json" },- body: JSON.stringify({ windowMs: 0, max: -1 }),- }),- )- expect(res.status).toBe(400)- })-- it("returns 404 for unknown paths", async () => {- const { doInstance } = makeDO()- const res = await doInstance.fetch(- new Request("http://internal/nope", { method: "POST" }),- )- expect(res.status).toBe(404)- })-- it("persists the counter across DO instances (survives eviction)", async () => {- const mock = createMockCtx()- const a = new RateLimitDurableObject(mock.ctx, {} as Env)- for (let i = 0; i < 30; i++) await check(a, 10_000, 30)- const b = new RateLimitDurableObject(mock.ctx, {} as Env)- expect((await check(b, 10_000, 30)).allowed).toBe(false)- })-})diff --git a/src/ws-do/test-runtime/apply-migrations.ts b/src/ws-do/test-runtime/apply-migrations.tsnew file mode 100644index 000000000..61bb6b068--- /dev/null+++ b/src/ws-do/test-runtime/apply-migrations.ts@@ -0,0 +1,15 @@+/// <reference types="@cloudflare/vitest-plugin/types" />++import type { D1Migration } from "@cloudflare/vitest-plugin"+import { applyD1Migrations } from "cloudflare:test"+import { env } from "cloudflare:workers"+import { beforeAll } from "vitest"++const runtimeEnv = env as unknown as {+ DB: D1Database+ TEST_MIGRATIONS: D1Migration[]+}++beforeAll(async () => {+ await applyD1Migrations(runtimeEnv.DB, runtimeEnv.TEST_MIGRATIONS)+})diff --git a/src/ws-do/test-runtime/worker.runtime.test.ts b/src/ws-do/test-runtime/worker.runtime.test.tsnew file mode 100644index 000000000..7ac4ab94c--- /dev/null+++ b/src/ws-do/test-runtime/worker.runtime.test.ts@@ -0,0 +1,107 @@+/// <reference types="@cloudflare/vitest-plugin/types" />++import { runInDurableObject } from "cloudflare:test"+import { env, exports } from "cloudflare:workers"+import { describe, expect, it } from "vitest"++const runtimeEnv = env as unknown as {+ DB: D1Database+ RATE_LIMIT_DO: DurableObjectNamespace+ WS_DO: DurableObjectNamespace+}++const worker = (exports as unknown as {+ default: { fetch(request: Request): Promise<Response> }+}).default++describe("ws-do workerd runtime", () => {+ it("loads production migrations and serves the production entrypoint", async () => {+ const schema = await runtimeEnv.DB.prepare(+ "SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?",+ ).bind("community_machine").first<{ name: string }>()+ expect(schema?.name).toBe("community_machine")++ const response = await worker.fetch(new Request("https://worker.test/health"))+ expect(response.status).toBe(200)+ await expect(response.json()).resolves.toEqual({ status: "ok" })+ })++ it("uses a real Durable Object for strongly consistent rate limits", async () => {+ const key = crypto.randomUUID()+ const check = () => worker.fetch(new Request("https://worker.test/rate-limit/check", {+ method: "POST",+ headers: { "content-type": "application/json" },+ body: JSON.stringify({ name: "runtime-test", key, windowMs: 60_000, max: 2 }),+ }))++ await expect((await check()).json()).resolves.toEqual({ allowed: true })+ await expect((await check()).json()).resolves.toEqual({ allowed: true })+ await expect((await check()).json()).resolves.toMatchObject({ allowed: false })+ })++ it("persists the counter across stubs for the same Durable Object id", async () => {+ const id = runtimeEnv.RATE_LIMIT_DO.idFromName(`runtime-${crypto.randomUUID()}`)+ const request = () => new Request("https://worker.test/check", {+ method: "POST",+ headers: { "content-type": "application/json" },+ body: JSON.stringify({ windowMs: 60_000, max: 1 }),+ })++ const first = await runtimeEnv.RATE_LIMIT_DO.get(id).fetch(request())+ await expect(first.json()).resolves.toEqual({ allowed: true })++ const second = await runtimeEnv.RATE_LIMIT_DO.get(id).fetch(request())+ expect(second.status).toBe(200)+ await expect(second.json()).resolves.toMatchObject({+ allowed: false,+ retryAfterSec: expect.any(Number),+ })+ })++ it("resets expired storage and rejects invalid Durable Object requests", async () => {+ const id = runtimeEnv.RATE_LIMIT_DO.idFromName(`runtime-${crypto.randomUUID()}`)+ const stub = runtimeEnv.RATE_LIMIT_DO.get(id)+ const check = () => stub.fetch(new Request("https://worker.test/check", {+ method: "POST",+ headers: { "content-type": "application/json" },+ body: JSON.stringify({ windowMs: 60_000, max: 1 }),+ }))++ await expect((await check()).json()).resolves.toEqual({ allowed: true })+ await runInDurableObject(stub, async (_instance, state) => {+ await state.storage.put("state", { count: 1, windowStart: Date.now() - 60_001 })+ })+ await expect((await check()).json()).resolves.toEqual({ allowed: true })++ const invalid = await stub.fetch(new Request("https://worker.test/check", {+ method: "POST",+ headers: { "content-type": "application/json" },+ body: JSON.stringify({ windowMs: 0, max: -1 }),+ }))+ expect(invalid.status).toBe(400)++ const malformed = await stub.fetch(new Request("https://worker.test/check", {+ method: "POST",+ body: "not json",+ }))+ expect(malformed.status).toBe(400)++ const missing = await stub.fetch(new Request("https://worker.test/missing", {+ method: "POST",+ }))+ expect(missing.status).toBe(404)+ })++ it("upgrades through the real WebSocket Durable Object", async () => {+ const id = runtimeEnv.WS_DO.idFromName(`runtime-${crypto.randomUUID()}`)+ const response = await runtimeEnv.WS_DO.get(id).fetch(new Request(+ "https://worker.test/?userId=runtime-user",+ { headers: { Upgrade: "websocket" } },+ ))++ expect(response.status).toBe(101)+ expect(response.webSocket).not.toBeNull()+ response.webSocket?.accept()+ response.webSocket?.close(1000, "runtime test complete")+ })+})diff --git a/src/ws-do/tsconfig.json b/src/ws-do/tsconfig.jsonindex 518648f89..78de84a31 100644--- a/src/ws-do/tsconfig.json+++ b/src/ws-do/tsconfig.json@@ -3,5 +3,5 @@"target": "ES2022", "module": "ESNext", "moduleResolution": "bundler","strict": true, "skipLibCheck": true, "types": ["@cloudflare/workers-types", "node"], "lib": ["ES2022"]},- "include": ["src"]+ "include": ["src", "test-runtime"]}diff --git a/src/ws-do/vitest.config.ts b/src/ws-do/vitest.config.tsindex dc311cedf..d400d4c1f 100644--- a/src/ws-do/vitest.config.ts+++ b/src/ws-do/vitest.config.ts@@ -3,7 +3,9 @@ import shared from "../../vitest.shared"export default mergeConfig(shared, defineConfig({test: {+ name: "ws-do-node",include: ["src/**/*.test.ts"],exclude: ["src/test-integration/**"],+ sequence: { groupOrder: 1 },},}))diff --git a/src/ws-do/vitest.runtime.config.mts b/src/ws-do/vitest.runtime.config.mtsnew file mode 100644index 000000000..ba21d4021--- /dev/null+++ b/src/ws-do/vitest.runtime.config.mts@@ -0,0 +1,25 @@+import path from "node:path"+import { cloudflareTest, readD1Migrations } from "@cloudflare/vitest-plugin"+import { defineProject } from "vitest/config"++const migrations = await readD1Migrations(path.resolve(import.meta.dirname, "../web/migrations"))++export default defineProject({+ plugins: [+ cloudflareTest({+ wrangler: { configPath: "./wrangler.toml" },+ miniflare: {+ bindings: { TEST_MIGRATIONS: migrations },+ },+ }),+ ],+ test: {+ name: "ws-do-runtime",+ include: ["test-runtime/**/*.runtime.test.ts"],+ setupFiles: ["test-runtime/apply-migrations.ts"],+ fileParallelism: false,+ isolate: false,+ maxWorkers: 1,+ sequence: { groupOrder: 10 },+ },+})diff --git a/src/ws-do/vitest.workspace.config.ts b/src/ws-do/vitest.workspace.config.tsnew file mode 100644index 000000000..0a2898afa--- /dev/null+++ b/src/ws-do/vitest.workspace.config.ts@@ -0,0 +1,7 @@+import { defineConfig } from "vitest/config"++export default defineConfig({+ test: {+ projects: ["./vitest.config.ts", "./vitest.runtime.config.mts"],+ },+})diff --git a/vitest.config.ts b/vitest.config.tsindex caa2f5ad7..8025a4187 100644--- a/vitest.config.ts+++ b/vitest.config.ts@@ -2,9 +2,25 @@ import { defineConfig } from "vitest/config"export default defineConfig({test: {- projects: ["src/shared", "src/web", "src/cli", "src/daemon", "src/daemon/agent-driver", "src/email-worker", "src/ws-do", "src/app", "tests/utils", "scripts/ci"],+ projects: [+ "src/shared",+ "src/web",+ "src/cli",+ "src/daemon",+ "src/daemon/agent-driver",+ "src/email-worker",+ "src/ws-do",+ "src/wake-worker",+ "src/app",+ "tests/utils",+ "scripts/ci",+ "src/ws-do/vitest.runtime.config.mts",+ "src/email-worker/vitest.runtime.config.mts",+ "src/wake-worker/vitest.runtime.config.mts",+ "src/web/vitest.runtime.config.mts",+ ],coverage: {- provider: "v8",+ provider: "istanbul",include: ["src/**/*.{ts,tsx,js,jsx}", "scripts/ci/**/*.mjs"],exclude: ["**/*.test.*",@@ -16,7 +32,9 @@ export default defineConfig({"**/dist/**","**/bundled/**","**/__mocks__/**",+ "**/test-harness.ts","**/*.d.ts",+ "**/test-runtime/**","src/cli/src/index.ts","src/web/scripts/**","src/web/readme-capture/**",