Autonomous Website Builder on Durable Objects, Workflows & Sandboxed Builds
An AI-cofounder / autonomous-startup-builder SaaS
Overview
The website-building engine of an AI-cofounder / autonomous-startup-builder SaaS: a single dispatch turns a written brief into a planned, generated, verified and deployed site with no human in the loop. A Durable Object owns each run, a Cloudflare Workflow gives it a spine that survives isolate death, the build itself happens inside a Sandbox container, and the run inspects real screenshots of its own output before shipping. Three modes, build, revise and repair, share the same machinery.
Why It Exists
Every company the platform spins up needs a real, working web presence, and producing it with a free-roaming agentic tool loop proved expensive and unpredictable: the model spent most of its budget exploring rather than writing code. Forge replaces that with a fixed sequence in which only two things require judgement, deciding direction and structure, and writing the code, while everything mechanical (scaffolding, theme application, typechecking, gates, smoke tests) is done by code that cannot skip a step. It also had to be durable: a run that lasts many minutes across containers, browsers and model calls must survive dead isolates and dead containers without starting over.
What We Built
A Worker (src/server.ts) that admits runs through a CapacityGate Durable Object, then hands each to a ForgeAgent Durable Object (src/agent.ts, built on the Agents SDK and Cloudflare Think) holding persisted, broadcast state and a silence watchdog. BuildWorkflow and RepairWorkflow (src/build-workflow.ts, src/repair-workflow.ts) drive src/pipeline.ts as memoized Workflow steps across three phases: Prepare (slug reservation, clone/scaffold, plan, mechanical theme/meta/route application, codegen, per-component stories), Verify (typecheck, gates, per-section screenshot frames, model review, functional probes against real forms, fix laps) and Ship (build, publish, whole-page review, smoke test, commit, deploy, manifest).
Supporting modules include a src/gates/ library of pure-function quality gates (contrast, class contrast, placeholders, anchors, presence, conventions, form wiring, commerce, coherence, contracts, SEO, JSON-LD, orphan routes, mounted components), a src/capture/ layer that drives Browser Rendering to shoot section frames, tile them, grade interactions and audit pages, a scoped repair-agent.ts tool loop invoked once per fix lap, and operational pieces such as capacity leases, step leases, run liveness, resume points, review deadlines, a decision memory, a spend ledger, escalation and container-fault handling. A template/ directory ships the React Router 7 + Vite + Tailwind + Ladle starter every site is scaffolded from, and docs/ records design decisions on review honesty and futility guards. The codebase carries an extensive co-located bun test suite.
Technologies & Approach
TypeScript end to end on Cloudflare: Durable Objects (SQLite-backed) for run ownership and admission control, Workflows for durable, replayable steps, the Sandbox SDK and a Docker image for an isolated build container running Bun, tsc, Vite and Ladle, Browser Rendering via @cloudflare/puppeteer for in-loop visual verification, and a wildcard-routed preview hostname proxied into the sandbox. Model access goes through the Vercel AI SDK with Anthropic and Google providers, wrapped in tracing and prompt caching, with the builder model tier configurable per deployment. The design principle throughout: state is written by the pipeline, never by a model; gates return every failure at once and print the fix rather than the complaint; and the repair agent only acts, the deterministic harness re-shoots, re-reviews and decides whether a lap helped.
Outcome / Impact
Forge is the build-and-revise engine the platform uses to give each autonomous company a live site, integrated with the sibling site-deployer, image-generator, email-inbox and analytics services. The repository’s own planning notes record the migration from an exploratory agentic loop to the fixed pipeline, the move to a React Router 7 template, platform integration and the revise mode as completed baseline, with orchestrator routing and a higher-level project agent as the next phases. Active development continued through the most recent commits.
Capabilities Demonstrated
- Autonomous brief-to-deployed-website pipeline with no human in the loop
- Durable, replayable long-running agent runs on Durable Objects and Cloudflare Workflows
- Sandboxed container builds with git checkpoints that survive isolate and container death
- Screenshot-driven LLM review of real rendered output inside the build loop
- Library of deterministic quality gates that report every defect and emit the fix
- Scoped repair agent governed by a deterministic harness with budgets and futility guards
- Admission control, watchdogs, leases and spend ledgers for fleet-scale agent jobs
- Multi-provider model access via the AI SDK with tracing and prompt caching