How cloudflare/computer works
Purpose and Public Entry Points
Cloudflare Computer is a preview TypeScript monorepo for Durable Object–hosted workspaces: an authoritative SQLite-backed virtual filesystem plus pluggable execution runtimes. Consumers primarily use @cloudflare/computer through packages/computer/src/index.ts, construct a Workspace, use filesystem APIs, and invoke workspace.runtime.exec(source, { backend }). The underlying filesystem is independently usable through packages/dofs/src/index.ts.
Workspace Orchestration
@cloudflare/computer is the Durable Object-facing integration layer. It owns Workspace lifecycle, client/proxy boundaries, runtime registration, heartbeat/observation, and the uniform execution interface.
• packages/computer/src/workspace.ts
• packages/computer/src/runtime/runtime.ts
• packages/computer/src/client.ts
Execution is selected by stable backend ID and connected lazily. The uniform runtime boundary hides whether source is shell text or an ECMAScript module.
Authoritative Durable Object Filesystem
@cloudflare/dofs supplies the durable virtual filesystem, backed by Durable Object SQLite. Its filesystem implementation provides POSIX-like operations over a schema/revision model; blobs, metadata, and path resolution remain authoritative here rather than in execution environments.
• packages/dofs/src/fs/filesystem.ts
• packages/dofs/src/schema/core.ts
• packages/dofs/src/storage.ts
The sync subsystem computes, transfers, applies, and coalesces changes between this store and remote projections, including blob and watermark handling.
• packages/dofs/src/sync/push.ts
• packages/dofs/src/sync/fetch.ts
• packages/dofs/src/sync/apply.ts
Runtime Backends
Three execution paths implement the runtime abstraction:
• Container: projects the workspace into a sandbox container with a real FUSE filesystem and Linux userland. packages/computer/src/backends/container/cloudflare-container.ts, packages/computer/src/backends/container/container-lifecycle.ts
• Isolate shell: runs just-bash in a Cloudflare Dynamic Worker and accesses Workspace directly over Workers RPC. packages/computer/src/backends/worker-shell/worker-shell.ts, packages/computer/src/backends/worker-shell/adapter.ts
• Isolate JavaScript: evaluates modules in fresh Dynamic Workers, supplying Workspace-backed filesystem support and curated modules/imports. packages/computer/src/backends/worker-javascript/worker-javascript.ts, packages/computer/src/backends/worker-javascript/module-graph.ts
Container Daemon and RPC Boundary
computerd runs inside the container as a Node daemon. It exposes HTTP/WebSocket RPC, mounts the remote filesystem through FUSE, and executes local processes against that mount. This creates the principal distributed boundary: container-side filesystem operations synchronize to the Durable Object store over Cap’n Web RPC.
• packages/computerd/src/cli/computerd.ts
• packages/computerd/src/fuse/vfs.ts
• packages/computerd/src/exec/runner.ts
@cloudflare/computer-rpc defines shared client/server and wire interfaces used across that boundary.
• packages/rpc/src/interface.ts
• packages/rpc/src/client.ts
• packages/rpc/src/server.ts
Integrated Services and Capability Surfaces
Computer exposes workspace-aware Git, artifacts, asset upload, mounts, and agent-oriented tools as higher-level capability surfaces. These sit above the authoritative filesystem and runtime selection rather than replacing either.
• packages/computer/src/git/index.ts
• packages/computer/src/artifacts/index.ts
• packages/computer/src/assets/index.ts
External infrastructure includes Cloudflare Durable Objects with SQLite, Workers RPC and Dynamic Workers, Cloudflare Containers, R2-backed mounts, Workers AI, and Cloudflare Artifacts. The container release image is assembled around a prebuilt Linux x64 daemon in packages/computer-computerd-linux-x64/Dockerfile.
Consumer Shapes
Runnable Workers under examples/ are integration entry points rather than core services: HTTP workspace demos start at examples/container/src/index.ts, examples/worker-shell/src/index.ts, and examples/worker-javascript/src/index.ts. The comparison application combines a browser UI with a Worker orchestrator for side-by-side container and isolate agent runs: examples/think-compare-runtimes/worker/index.ts.
Main entry points: workspace.ts Workspace lifecycle · filesystem.ts DO filesystem · runtime.ts Runtime abstraction · index.ts Computer package
Components 19
Public APIs
- Consumers & examples · Workers construct and operate workspaces.
examples/container/src/index.ts - Computer package · Workspace-facing public package.
packages/computer/src/index.ts - Workspace capabilities · Higher-level services built over Workspace state.
packages/computer/src/git/index.ts
Durable Workspace
- Workspace lifecycle · Owns lifecycle, runtime registration, and observation.
packages/computer/src/workspace.ts - Workspace client · Client/proxy access to a Workspace.
packages/computer/src/client.ts - Runtime abstraction · Lazily selects a backend by stable ID.
packages/computer/src/runtime/runtime.ts - DO filesystem · POSIX-like filesystem over durable SQLite state.
packages/dofs/src/fs/filesystem.ts - Filesystem schema · Revision and metadata model.
packages/dofs/src/schema/core.ts - DO storage · Durable Object-backed storage.
packages/dofs/src/storage.ts - Filesystem sync · Transfers, applies, and coalesces blobs and watermarks.
packages/dofs/src/sync/apply.ts
Execution Backends
- Container backend · Projects the workspace into a Linux container.
packages/computer/src/backends/container/cloudflare-container.ts - Isolate shell backend · Runs just-bash in a Dynamic Worker.
packages/computer/src/backends/worker-shell/worker-shell.ts - Shell RPC adapter · Connects the shell to Workspace APIs.
packages/computer/src/backends/worker-shell/adapter.ts - Isolate JavaScript backend · Evaluates modules in fresh Dynamic Workers.
packages/computer/src/backends/worker-javascript/worker-javascript.ts - Module graph · Curates imports and Workspace-backed modules.
packages/computer/src/backends/worker-javascript/module-graph.ts
Container Boundary
- computerd daemon · HTTP/WebSocket RPC daemon inside the container.
packages/computerd/src/cli/computerd.ts - FUSE virtual filesystem · Mounts the Durable Object filesystem in the container.
packages/computerd/src/fuse/vfs.ts - Process runner · Runs Linux processes against the FUSE mount.
packages/computerd/src/exec/runner.ts - Computer RPC · Client, server, and interfaces for the distributed boundary.
packages/rpc/src/interface.ts
Connections 21
- Consumers & examples → Computer package: uses
- Computer package → Workspace lifecycle: creates
- Computer package → Workspace client: exposes
- Workspace lifecycle → DO filesystem: authoritative files
- DO filesystem → Filesystem schema: uses
- DO filesystem → DO storage: persists to
- Filesystem sync → DO filesystem: applies projections
- Workspace lifecycle → Runtime abstraction: exec delegates to
- Workspace capabilities → Workspace lifecycle: workspace-aware services
- Runtime abstraction → Container backend: backend: container
- Runtime abstraction → Isolate shell backend: backend: shell
- Runtime abstraction → Isolate JavaScript backend: backend: javascript
- Isolate shell backend → Shell RPC adapter: accesses Workspace via
- Shell RPC adapter → Workspace lifecycle: Workers RPC
- Isolate JavaScript backend → Module graph: loads modules through
- Isolate JavaScript backend → Workspace lifecycle: filesystem support
- Container backend → computerd daemon: starts
- computerd daemon → Process runner: executes
- Process runner → FUSE virtual filesystem: uses mount
- FUSE virtual filesystem → Computer RPC: remote filesystem RPC
- Computer RPC → DO filesystem: Cap'n Web RPC