The Problem
Developers building Cloudflare Workers need a mutable, versioned filesystem that can be accessed from Durable Objects, containers, or isolated JavaScript shells. Implementing such a virtual FS from scratch requires handling SQLite state, FUSE‑style mounts, and cross‑runtime RPC, which is error‑prone and hard to test.
What This Does
The repo delivers Cloudflare Computer, a monorepo that exposes a workspace.runtime.exec(source, { backend }) API. Core logic lives in packages/computer/src/ (e.g., workspace.ts, git/index.ts, artifacts/cli.ts). The Durable Object stores state in SQLite via the dofs layer (packages/dofs/src/), with storage.ts acting as the primary hub (54 inbound imports).
Example consumers are in examples/:
examples/container/src/index.ts– builds a container, runscomputerd, and mounts the workspace.examples/worker-shell/src/index.ts– runs a Bash shell in a Dynamic Worker.examples/think/src/agent.ts– a chat agent that treats the workspace as its file system.
How It Is Wired
- Entry point – each example’s
src/index.tsimports@cloudflare/computer(via the workspace package). workspace.tscreates aWorkspaceobject that lazily loads a backend (backendFactory.ts).- The backend calls into dofs:
packages/dofs/src/fs/writeFile.tswrites throughstorage.ts, which forwards to SQLite via the Durable Object RPC layer (packages/computer/src/rpc.ts). storage.tsis the largest hub (Ca = 54, Ce = 1) – any change here propagates to most of the code base.- A circular import exists among
workspace.ts,git/index.ts, andstub.ts; each pulls types or helpers from the others, increasing the blast‑radius for refactors. - Execution ultimately reaches the durable object’s SQLite store, then returns results over the Cap’n Proto RPC channel (
packages/computer/src/rpc.ts).
The call graph shows eight modules in cycles, and the most branching logic lives in packages/dofs/src/schema/index.ts (24 branches over 59 lines). Deep nesting (max depth = 6) appears in packages/computer/src/artifacts/cli.ts.
How To Use It
# Clone the repo
git clone https://github.com/moses-y/computer
cd computer
# Install the monorepo (npm is the manager)
npm ci
# Build all packages
npm run build # defined in root package.json scripts
# Run a concrete example – container backend
cd examples/container
npm ci
npm run dev # starts a local worker that mounts the workspace
Configuration files are in each example’s root (wrangler.jsonc, worker-configuration.d.ts). No additional secrets are required for local runs; production deployments need CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID as documented in README.md.
Real‑World Use
A SaaS platform can store user‑generated scripts in a Cloudflare Computer workspace, then execute them in isolated containers for PDF generation or image processing. The platform calls workspace.runtime.exec('pandoc input.md -o output.pdf', { backend: 'container' }); the container backend mounts the SQLite state, runs pandoc, and writes the PDF back to the same workspace, all without persisting any intermediate files on the host.
Code Health & Issues
- Critical – Secrets in workflow allow a forked PR to exfiltrate
CLOUDFLARE_API_TOKEN(.github/workflows/release.yml). - High – GitHub Actions not pinned to commit SHAs (
.github/workflows/*). - High –
eval/execon runtime‑computed strings inpackages/rpc/src/server.ts. - High – Oversized files (
writeFile.ts,workspace.ts,git/index.ts≈ 917 lines each). - High – Hub module (
packages/dofs/src/storage.ts) with 54 dependents; changes have wide impact. - High – Import cycle among
workspace.ts,git/index.ts,stub.ts. - High – Duplicated 6‑line blocks across many example entry points.
- Medium – High branching density in schema and resolve‑cache modules.
- Medium – Deep nesting (max depth = 6) in CLI and test files.
- Medium – No Dependabot/Renovate configured for 6 manifests.
- Medium – Dockerfiles use mutable base tags (
debian:stable-slim). - Medium – CI lacks a dependency‑vulnerability gate.
- Medium – Container images run as root; no
USERdirective. - Low – Workflow jobs missing
timeout-minutes(close-unrequested-prs.yml).
The Bottom Line
Cloudflare Computer provides a functional prototype for a durable, multi‑backend virtual filesystem, with a clear separation between workspace management and backend execution. However, the codebase suffers from large, highly coupled modules, an import cycle, and several security/maintenance gaps that must be addressed before production use. It is best suited for experimental projects or teams willing to invest in refactoring and hardening the core.