给 AI 智能体一台虚拟电脑:Durable Object 上的可插拔文件系统
Cloudflare Computer 是一个运行在 Durable Object 内的虚拟文件系统:权威状态存于 SQLite,并通过一个插拔式执行接口 workspace.runtime.exec 对外暴露。项目目前提供三种后端——容器后端用 FUSE 把状态挂载成真实目录,可在沙箱内运行完整 Linux 用户态和真实二进制;Isolate shell 在 Dynamic Worker 中执行 bash,通过 Workers RPC 直连权威状态;Isolate JavaScript 则运行 ECMAScript 模块,支持结构化输入输出、持久化相对导入和受限的 node:fs/promises。Workspace 也可以脱离后端单独作为文件系统使用。项目目前是 preview 阶段,明确不适合生产,适合关注 Agent 基础设施、沙箱执行和云端文件系统设计的一线工程师阅读和实验。
Cloudflare Computer is a virtual filesystem that lives inside a Durable Object. It keeps authoritative state in SQLite and exposes a pluggable execution surface through workspace.runtime, giving AI agents a unified working directory and runtime environment. The project is currently a preview, good for prototyping, not for production.
Cloudflare Computer 是一个虚拟文件系统,跑在 Durable Object 内部。它把权威状态存在 SQLite 中,并通过 workspace.runtime 暴露一个可插拔的执行表面,让 AI agent 拥有统一的工作目录和运行环境。这个项目目前是预览版,适合原型验证,不适合生产。
AI agents often need to read and write files, run shell commands, or execute JavaScript across different environments—containers, Workers, local machines—each with its own quirks and state-sync pain. Cloudflare Computer consolidates all file state into a Durable Object's SQLite, then dispatches execution to different backends through a single workspace.runtime.exec entry point. Backends connect lazily on first use, so there is one source of truth and no second store or sync round-trip.
AI agent 经常需要读写文件、执行 shell 命令或运行 JavaScript 代码,而不同环境(容器、Worker、本地)往往各搞一套,状态难以同步。Cloudflare Computer 把所有文件状态收口到 Durable Object 的 SQLite 里,再通过统一的 workspace.runtime.exec 入口分发到不同的后端执行。后端按需懒连接,保证只有一个数据源,没有第二份存储或同步往返。
Three backends ship with the repo. The container backend projects SQLite state into a sandbox container as a real FUSE mount; a daemon called computerd syncs changes back over a capnweb RPC channel, giving you a full Linux userland, real binaries, and real network. The Isolate shell runs just-bash inside a Dynamic Worker and reaches the authoritative Workspace over Workers RPC, so there is no second store or sync round trip. The Isolate JavaScript backend evaluates an ECMAScript module in a fresh Dynamic Worker, with structured input/results, durable relative imports, configured libraries, Workspace-backed node:fs/promises, and trusted ws:git and ws:artifacts modules. You can also register custom backends under stable IDs, or construct a Workspace with no backend at all and use it purely as a filesystem.
仓库内置三种后端。容器后端把 SQLite 状态以真实 FUSE 挂载映射进沙箱容器,由 computerd 守护进程同步变更,支持完整 Linux 用户态、真实二进制和网络。Isolate shell 在 Dynamic Worker 里跑 just-bash,通过 Workers RPC 直连权威 Workspace,无需额外存储。Isolate JavaScript 则在全新的 Dynamic Worker 里执行 ECMAScript 模块,提供结构化输入输出、可靠的相对导入、配置好的库,以及基于 Workspace 的 node:fs/promises 和受信任的 ws:git、ws:artifacts 模块。你还可以注册自定义后端,或干脆不带后端只当文件系统用。
The repo is a small monorepo, with each package carrying its own README. @cloudflare/dofs provides the Durable Object SQLite-backed virtual filesystem and sync protocol building blocks; @cloudflare/computer-rpc defines the capnweb wire types plus server/client helpers; @cloudflare/computerd is the daemon that mounts FUSE and serves HTTP/WebSocket RPC inside the sandbox container; @cloudflare/computer is the top-level package consumed by Durable Objects, still a work in progress. There is also a private Docker image context that publishes the prebuilt computerd linux-x64 binary.
仓库是一个小型 monorepo,每个包有独立 README。@cloudflare/dofs 提供 Durable Object SQLite 虚拟文件系统和同步协议;@cloudflare/computer-rpc 是 capnweb 线格式和客户端/服务端帮助;@cloudflare/computerd 是运行在沙箱容器里的 FUSE 挂载和 HTTP/WebSocket RPC 守护进程;@cloudflare/computer 是顶层包,供 Durable Object 使用,目前仍在开发中。另外还有一个私有 Docker 镜像上下文,用于发布预构建的 computerd linux-x64 二进制。
To get started, install @cloudflare/computer and follow that package's README—it has installation steps, the entrypoint map, and worked examples for the fs and runtime surfaces. The examples/ directory contains runnable consumers: the container example runs computerd inside a container, mounts a workspace, and talks to the Durable Object over capnweb; worker-shell runs just-bash in a Dynamic Worker; worker-javascript evaluates an ECMAScript module instead. There are also a think chat agent that uses the workspace as its working directory, a web UI that compares container vs worker runtimes side by side, a step-by-step tutorial that generates a markdown recipe and runs pandoc to produce a PDF, an artifacts example that publishes a Worker project to Cloudflare Artifacts, and an assets example that turns a prompt into an image via Workers AI and returns a shareable link.
想上手的话,安装 @cloudflare/computer 并阅读它的 README,里面有安装步骤、入口点映射以及文件系统和运行时表面的实例。仓库的 examples/ 目录提供了可直接运行的消费者:container 示例演示 computerd 在容器内挂载 workspace 并通过 capnweb 通信;worker-shell 在 Dynamic Worker 里跑 just-bash;worker-javascript 则执行 ECMAScript 模块。另外还有 think 聊天 agent、并排对比不同运行时的 web UI、逐步教程(生成 markdown 并用 pandoc 转 PDF)、通过 Artifacts 发布 Worker 项目、以及用 Workers AI 生成图片并返回分享链接等示例。
This package is provided as a preview for feedback only. APIs are unstable and the design is subject to change; docs/ is forward-looking, so read it for intent rather than as a description of the current code. It is suitable for experiments, exploration, and prototypes—not for production. On performance, computerd's FUSE mount beats real disk on metadata-heavy work but trails on large sequential I/O; see docs/19_performance.md for full fs-bench numbers. Also note that the repo accepts bug reports, fix proposals, and feature requests via issues and discussions, but does not accept unsolicited pull requests.
这个包目前仅作为预览提供,API 不稳定,设计可能调整,文档 docs/ 也是前瞻性的,表示意图而非当前代码的说明。它适合实验、探索和原型,不适合生产使用。性能方面,computerd 的 FUSE 挂载在元数据密集的操作上优于真实磁盘,而在大型顺序 I/O 上则落后;具体数据可以看 docs/19_performance.md 的 fs-bench 结果。另外,仓库只接受 issue 和讨论中的 bug 报告、修复提案等,不接受未经请求的 pull request。