Repository navigation
AA1: the app on Workers - #2
Merged
Merged
Conversation
E2B's Fragments in apps/web, on one Cloudflare Worker + Static Assets built by @opennextjs/cloudflare, on the reference stack (Next.js 16, React 19, AI SDK 7 with @ai-sdk/react 4 — streamObject and experimental_useObject unchanged). - Models: Workers AI through the Worker's own AI binding (workers-ai-provider, the fragment's schema sent as JSON mode) is the default and needs no key; upstream's vendor models stay, sent with the visitor's key or a server key (an optional Worker secret). A vendor model with neither is refused with the key to add. Vertex and Ollama are left out (a service-account file and a local server do not fit a Worker). - E2B: the sandbox route runs fragments with E2B_API_KEY, an optional Worker secret; without it the fragment is still written and shown, and the page says what running it needs. - Upstash rate limiting and the Vercel KV share links become a fixed window and fragment:<id> keys in the KV binding; /s/<id> is a route handler instead of middleware; a published link uses the visitor's own origin. - Supabase sign-in, PostHog, Vercel Analytics and Google Tag Manager are left out; the account menu keeps its links. - /api/health (read-only) is what the deploy's smoke reads. - wrangler.template.jsonc + wiring.fixture.json render wrangler.jsonc per environment from the cloudflare-kv root's wiring document; component.yaml carries the deploy contract, pushing each stored key to the Worker as a secret (worker-secrets.mjs) with none reaching the bundle. - tests/web: upstream's model, request-schema and route tests ported to vitest, plus the KV rate limit, the links, the sandbox, health and short-link routes, against in-memory bindings and no network (98 tests). Upstream's code is kept as written; the lint rules eslint-config-next 16 added after it are turned off by name. The Worker is 1875 KiB gzipped. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019PcpNVpFBcbeiX3EHdXfmn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
E2B's Fragments in
apps/web, on one Cloudflare Worker with Static Assets built by@opennextjs/cloudflare. It runs on the reference stack: Next.js 16, React 19, and AI SDK 7 with@ai-sdk/react4.streamObjectandexperimental_useObjectare unchanged.AIbinding (workers-ai-provider, the fragment's schema sent as JSON mode) is the default and needs no key. Upstream's vendor models stay, sent with the visitor's key or a server key (an optional Worker secret). A vendor model with neither is refused, naming the key to add.E2B_API_KEYenvKVbinding (same variables).fragment:<id>keys inKV./s/<id>is a route handler, and the link uses the visitor's own origin.The PR also adds:
/api/health, which the deploy's smoke reads. It is read-only, so a public route can't spend KV writes.wrangler.template.jsoncandwiring.fixture.json, which renderwrangler.jsonc(committed as the fixture render).component.yaml, the deploy contract. The enforced edge oncloudflare-kvlands in AA2. Each stored key goes to the Worker as a secret, and none reaches the bundle.tests/web: upstream's model, request-schema and route tests ported to vitest, plus the KV rate limit, the links, and the sandbox, health and short-link routes. They run against in-memory bindings with no network: 98 tests.Checked locally:
pnpm install --frozen-lockfile,wire:fixture(no diff),typecheck,lint(0 errors) andtestall pass.buildpasses. The Worker is 9073 KiB, 1875 KiB gzipped, so it fits Workers Free.wrangler dev, with theAIbinding pointed at a Workers AI stand-in, serves the page and health. It also streams a fragment, answers that E2B isn't connected, refuses an unkeyed vendor model, rate-limits on the 11th request and redirects an unknown short link home.Upstream's code is kept as written. The lint rules that eslint-config-next 16 added after it was written are turned off by name, as the reference starters do.
Generated by Claude Code