capnweb
Skill9.5k starsChanged 3 months agoMITView on GitHub
capnweb RPC patterns for this repo, with a heavy focus on stub lifecycle and disposal. Load when touching anything that crosses the Durable Object ↔ computerd boundary: packages/rpc, packages/computer, the computerd client, or the Durable Object server. Triggers include "capnweb", "RpcTarget", "stub", "RPC wire", "promise pipelining", "stub disposal", "RpcPromise".
Trending
Less talk lately.about the whole repository
Who's talking about cloudflare/computer
- A Hacker News story“Cloudflare Computer”Hacker News · Aug 3, 2026 · 10 points
- @jeremymorrell.dev“Pulling on this thread, and you pretty much immediately run into needing a file-system abstraction separate …”Bluesky · Aug 16, 2026 · 2 likes
- @github-trending-js.bsky.social“💎 Hidden Gem! 💎 (1000+ new stars) 📦 cloudflare / computer ⭐ 6,822 (+1,045) 🗒 TypeScript Give your agent …”Bluesky · Aug 10, 2026 · 2 likes
- @latreon.bsky.social“computer: Give your agent a computer. github.com/cloudflare/computer #TypeScript #AI #AIAgents”Bluesky · Aug 24, 2026 · 1 likes
- @epicvibecoder.bsky.social“cloudflare just gave every ai agent its own computer. a real sandboxed machine, browser and shell, that …”Bluesky · Aug 12, 2026 · 1 likes
The biggest 5 of 52 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 52
Talked about on GitHub, Bluesky and Hacker News (52 times).
On GitHub · 41
- Aug 6, 2026Add Docker Image CI workflow — crystalsconsultingllc3-coder/computer1 reaction
- Oct 7, 2026deps: bump the npm-minor-patch group across 1 directory with 5 updates — skyphusion-labs/straightedge0 reactions
- Sep 30, 2026idea — coolplayagent/agent-computer0 reactions
- Sep 26, 2026[Candidate] cloudflare/computer/.agents/skills/debugging-computerd-fuse - debugging-computerd-fuse — ProSkillsMD/proskills0 reactions · 1 comment
- Sep 26, 2026[Candidate] cloudflare/computer/.agents/skills/cloudflare - cloudflare — ProSkillsMD/proskills0 reactions · 2 comments
36 more on GitHub
- Sep 26, 2026[Candidate] cloudflare/computer/.agents/skills/capnweb - capnweb — ProSkillsMD/proskills0 reactions · 1 comment
- Sep 24, 2026deps: bump the npm-minor-patch group in /agent with 4 updates — skyphusion-labs/straightedge0 reactions · 2 comments
- Sep 23, 2026Bump the cloudflare-runtime group across 1 directory with 5 updates — scuffi/gardener0 reactions · 1 comment
- Sep 23, 2026Bump the cloudflare-runtime group across 1 directory with 6 updates — scuffi/gardener0 reactions · 1 comment
- Sep 16, 2026Bump the cloudflare-runtime group across 1 directory with 4 updates — scuffi/gardener0 reactions · 1 comment
- Sep 15, 2026v0.1.7: Cloudflare Computer study — Durable Object virtual filesystem: architecture, implementation, interface, and what LayerFS can learn — Ephemeral-AI-Lab/layerfs0 reactions · 2 comments
- Sep 7, 2026spike: cloudflare computer — soulinkfoundation/me3-core0 reactions
- Sep 7, 2026CREW-DESKTOP-QUIET: one Act; prefer CF; do not thrash founder desktop — Netie-AI/Cortex0 reactions
- Sep 7, 2026CREW-EXCEL-ACT: one-Act Excel open+chart after certified envelope — Netie-AI/Cortex0 reactions
- Sep 4, 2026CREW-RUNTIME: laptop local-exec OR Cloudflare Computer isolate — Netie-AI/Cortex0 reactions
- Aug 25, 2026Bump @cloudflare/computer from 0.1.1 to 0.2.1 — anotb/driftglass0 reactions
- Aug 20, 2026chore(deps): bump @cloudflare/computer from 0.2.0 to 0.2.1 in /apps/dsh-edge/standalone — pawaca/dsh-edge0 reactions · 3 comments
- Aug 18, 2026Bump @cloudflare/computer from 0.1.1 to 0.2.0 — anotb/driftglass0 reactions · 1 comment
- Aug 18, 2026Bump the computer-lab group in /labs/deep-dive-lab with 3 updates — anotb/driftglass0 reactions
- Aug 17, 2026Evaluate @cloudflare/computer for the studio agent door — skyphusion-labs/vivijure-cf0 reactions · 1 comment
- Aug 9, 2026use open sourced tools like Cloudflare computer — sakibsadmanshajib/hive0 reactions · 2 comments
- Aug 8, 2026dofs: Resolve relative symlink targets — HosniBelfeki/computer0 reactions
- Aug 8, 2026Spike a client-side metadata mirror and durability fences for small-file workloads — liu1700/orlop0 reactions · 1 comment
- Aug 8, 2026Github trending [cloudflare/computer] 三合一虚拟文件系统 — web1992/github-trending0 reactions
- Aug 7, 2026🔥 GitHub Trending AI 早报 · 2026-08-08 · Top 6 项目 — happydog-intj/ai-xiaohongshu-daily0 reactions
- Aug 7, 2026🔥 GitHub Trending AI 早报 · 2026-08-08 · Top 6 项目 — Mystery406/ai-xiaohongshu-daily0 reactions
- Aug 7, 2026think: Extract the legacy Shell workspace — cloudflare/agents0 reactions · 2 comments
- Aug 7, 2026🔥 GitHub Trending AI 晚报 · 2026-08-07 · Top 6 项目 — Mystery406/ai-xiaohongshu-daily0 reactions
- Aug 7, 2026🔥 GitHub Trending AI 晚报 · 2026-08-07 · Top 6 项目 — happydog-intj/ai-xiaohongshu-daily0 reactions
- Aug 7, 2026🔥 GitHub Trending AI 早报 · 2026-08-07 · Top 7 项目 — happydog-intj/ai-xiaohongshu-daily0 reactions
- Aug 7, 2026🔥 GitHub Trending AI 早报 · 2026-08-07 · Top 7 项目 — Mystery406/ai-xiaohongshu-daily0 reactions
- Aug 7, 2026Github trending [cloudflare/computer] 虚拟文件系统多后端执行 — web1992/github-trending0 reactions
- Aug 6, 2026🔥 GitHub Trending AI 晚报 · 2026-08-06 · Top 7 项目 — Mystery406/ai-xiaohongshu-daily0 reactions
- Aug 6, 2026🔥 GitHub Trending AI 晚报 · 2026-08-06 · Top 7 项目 — happydog-intj/ai-xiaohongshu-daily0 reactions
- Aug 6, 2026Github trending [cloudflare/computer] 虚拟文件系统+多后端执行 — web1992/github-trending0 reactions
- Aug 5, 2026🔥 GitHub Trending AI 早报 · 2026-08-06 · Top 7 项目 — happydog-intj/ai-xiaohongshu-daily0 reactions
- Aug 5, 2026🔥 GitHub Trending AI 早报 · 2026-08-06 · Top 7 项目 — Mystery406/ai-xiaohongshu-daily0 reactions
- Aug 5, 2026🔥 GitHub Trending AI 晚报 · 2026-08-05 · Top 7 项目 — Mystery406/ai-xiaohongshu-daily0 reactions
- Aug 5, 2026🔥 GitHub Trending AI 晚报 · 2026-08-05 · Top 7 项目 — happydog-intj/ai-xiaohongshu-daily0 reactions
- Aug 4, 2026Feature: Persistent workspace and lazy sandbox execution inspired by Cloudflare Computer — jellydn/flowly0 reactions
- Aug 3, 2026PARKED: @cloudflare/computer as a persistent planner working directory -- revisit if it stabilises — skyphusion-labs/vivijure-cf0 reactions · 2 comments
On Bluesky · 10
- Aug 16, 2026Pulling on this thread, and you pretty much immediately run into needing a file-system abstraction separate from the execution environment,… — @jeremymorrell.dev2 likes and reposts · 1 reply
- Aug 10, 2026💎 Hidden Gem! 💎 (1000+ new stars) 📦 cloudflare / computer ⭐ 6,822 (+1,045) 🗒 TypeScript Give your agent a computer 👾 — @github-trending-js.bsky.social2 likes and reposts · 1 reply
- Aug 24, 2026computer: Give your agent a computer. github.com/cloudflare/computer #TypeScript #AI #AIAgents — @latreon.bsky.social1 likes and repost
- Aug 12, 2026cloudflare just gave every ai agent its own computer. a real sandboxed machine, browser and shell, that your agent drives. no vm to… — @epicvibecoder.bsky.social1 likes and repost
- Aug 8, 2026AIエージェントに仮想ファイルシステムや実行環境を提供するランタイムツールっぽい エージェント向けの環境構築がぐっと楽になりそうかも yug1224 starred cloudflare/computer… — @yug1224.com1 likes and repost
5 more on Bluesky
- Aug 6, 2026📈 Today's GitHub Trending: 1. https://github.com/TencentCloud/TencentDB-Agent-Memory - TypeScript, 1053 stars today 2.… — @ghtrend.newsmast.social.ap.brid.gy1 likes and repost
- Aug 6, 2026🎉 Celebrating! 🎉 (500+ new stars) 📦 cloudflare / computer ⭐ 1,820 (+796) 🗒 TypeScript Give your agent a computer 👾 — @github-trending-js.bsky.social1 likes and repost · 1 reply
- Aug 5, 2026🎉 Celebrating! 🎉 (500+ new stars) 📦 cloudflare / computer ⭐ 1,819 (+796) 🗒 TypeScript Give your agent a computer 👾 — @github-trending.bsky.social1 likes and repost · 1 reply
- Aug 5, 2026📈 Today's GitHub Trending: 1. https://github.com/cloudflare/computer - TypeScript, 796 stars today 2.… — @ghtrend.newsmast.social.ap.brid.gy1 likes and repost
- Aug 7, 2026📈 Today's GitHub Trending: 1. https://github.com/PrimeIntellect-ai/prime-agent - TypeScript, 2271 stars today 2.… — @ghtrend.newsmast.social.ap.brid.gy0 likes and reposts · 1 reply
On Hacker News · 1
- Aug 3, 2026Cloudflare Computer10 points
In this repository7 other files it gives its agents.
- AGENTS.mdAGENTS.md
- cloudflareSkill
- debugging-computerd-fuseSkill
- proseSkill
- pull-requestsSkill
- test-driven-developmentSkill
- gardener-tasksSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 2 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 114
Direct streaming calls own their result: If you reach into client.sync / client.shell directly to call fetchChanges, fetchObjects, …
- Very specific: line 130
If you need to pass a stub somewhere that will dispose it but also want to keep using it locally, call stub.dup().
- Very specific: line 159
If you pass the same target to RPC multiple times, you get one dispose call per stub.
- Distinctive: line 219
When you receive a streaming result, the envelope owns the stream.
- Distinctive: line 227
Do treat stubs as capabilities.
- Very specific: line 235
Do call .dup() rather than awaiting twice when you need a stub copy to outlive a callee's auto-dispose.
- Very specific: line 237
Do run the leak harness (script/computerd-stub-soak) when you change anything around RPC lifecycle, and check session.getStats() for drift.
- Very specific: line 252
Use enableStubTracking() + stubSnapshot() in a test to assert no stub survives a round trip you expected to clean up.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
capnweb in this repo
capnweb is the RPC framing
between the Durable Object and computerd. It's an object-capability RPC
system with promise pipelining, structured-clone-style transfer of
stubs, and bidirectional calls. The wire format used here is text
JSON over a long-lived WebSocket. That is the only carrier: capnweb's
HTTP batch transport cannot deliver a stream returned from a call,
which is what every read on this interface is.
Where things live
packages/rpc/src/interface.ts— typed wire surface.WorkspaceRPCis the root stub and composesSyncRPCandShellRPC. Add new methods here first.packages/rpc/src/server.ts—Database-backed implementation. Imported by the Durable Object and the in-container computerd.packages/rpc/src/client.ts— typed stubs over a WebSocket carrier. The Durable Object uses a deferred transport so the stub can be created before the upgrade completes.packages/rpc/src/sync-driver.ts—pullOnce,pushOnce,tick. These wrap streaming methods and handle disposal internally.packages/rpc/src/debug.ts—enableStubTracking,stubSnapshotfor leak hunting.docs/08_capnweb_interface.md— design intent for the wire.docs/11_lifecycle.md— the repo's stub disposal contract.
The mental model
A stub is a capability: holding it is the right to call the remote object. Stubs are not garbage-collected across the network — the local GC has no visibility into the remote object graph, and the remote runtime has no idea whether you're under memory pressure. If you don't explicitly dispose stubs, you leak resources on the other side of the connection.
This matters more here than in many capnweb deployments because the
connection is long-lived. A short-lived session disposes everything
when it ends; our WebSocket between the Durable Object and computerd
stays up for the lifetime of the workspace, so every undisposed stub
stays alive until that connection drops.
The caller-disposes rule
The fundamental principle, from the capnweb spec:
The caller is responsible for disposing all stubs.
Concretely:
- Stubs passed in parameters remain owned by the caller. The callee receives duplicates that the RPC system auto-disposes when the call completes. You can dispose your originals immediately after the call — they were duplicated at send time.
- Stubs returned in results transfer ownership to the caller. The caller must dispose them. The RPC system disposes the callee's duplicates once it knows no more pipelined calls will land.
- Result envelopes always have a disposer, even if you don't think they contain stubs. Dispose them anyway — a future API change may add stubs and your caller will silently leak.
How to dispose
Three patterns, in order of preference:
// 1. `using` declaration — preferred when the stub is scope-local.
using result = await client.sync.fetchChanges({ sinceRev });
for await (const entry of result.stream) {
// ...
}
// result is disposed when the block exits.// 2. try/finally — when `using` isn't available or the scope is awkward.
const result = await client.sync.fetchChanges({ sinceRev });
try {
for await (const entry of result.stream) {
// ...
}
} finally {
result[Symbol.dispose]();
}// 3. Explicit dispose — when ownership crosses a boundary.
const stub = api.getThing();
// ... pass `stub` somewhere ...
stub[Symbol.dispose]();Repo-specific disposal contract
- Drivers own their stubs.
pullOnceandpushOncedispose every envelope they touch. Code that goes through the driver doesn't need to think about it. - Direct streaming calls own their result. If you reach into
client.sync/client.shelldirectly to callfetchChanges,fetchObjects,shell.exec, orshell.getExec, you own the envelope. Bind it withusingor dispose infinally. The stream on the envelope is the body; draining it does not release the envelope itself. - Closing disposes the root.
createSyncClient/createWorkspaceClientdispose the root stub when you callclient.close(). Don't tear down the underlying WebSocket yourself; letclose()cascade. - Don't await a stub just to inspect it. Awaiting an
RpcPromiseresolves it; if it resolves to a stub, you now own that stub and must dispose it.
Duplicating stubs with .dup()
If you need to pass a stub somewhere that will dispose it but also
want to keep using it locally, call stub.dup(). The underlying
target stays alive until every duplicate is disposed.
.dup() also works on a property of a stub or promise. This is the
idiomatic way to grab a stub-shaped property without an extra round
trip:
// Grab `authedApi` as a stub immediately, without awaiting.
using authedApi = api.authenticate(token).dup();
// Use it for pipelined calls right away.
const userId = await authedApi.getUserId();Listening for disposal on the server
An RpcTarget may declare a Symbol.dispose method. capnweb calls
it once every stub pointing at the target has been disposed.
class SessionTarget extends RpcTarget {
// ...
[Symbol.dispose]() {
// Release any per-session resources.
}
}If you pass the same target to RPC multiple times, you get one
dispose call per stub. To collapse them into one, wrap the target in
new RpcStub(target) once and pass that stub around instead.
Listening for disconnect
stub.onRpcBroken(cb) fires when the stub becomes unusable —
typically because the underlying connection dropped or, for a
promise, because the promise rejected. After the callback runs every
method call on that stub will throw. packages/computer already
folds onRpcBroken into the workspace's closed promise; reuse that
plumbing rather than wiring up a parallel listener.
Promise pipelining
An RpcPromise is also a stub for its eventual result. Don't await
unless you actually need the value locally:
// Three calls, one round trip.
using authed = api.authenticate(token).dup();
const profile = await api.getUserProfile(authed.getUserId());You can pass an RpcPromise as an argument to another RPC. capnweb
substitutes the resolved value on the receiver side before
delivering the call.
Property access on a stub or promise returns an RpcPromise that
does not have its own disposer — you must dispose the stub or
promise it came from. You can pass a property in params or returns,
but doing so never causes anything to be implicitly disposed.
The magic .map()
.map() runs a sync callback on the remote resolution of a promise,
in one round trip:
const idsPromise = api.listUserIds();
const names = await idsPromise.map(id => [id, api.getUserName(id)]);Restrictions:
- The callback must be synchronous (no
await). - The callback runs in record mode locally first, so it must have no side effects beyond RPC calls.
- Any stubs captured by the callback are sent to the peer along with the recording. Treat captured stubs as exposed to the peer; only use stubs that originated from the same peer.
Streams are first-class
ReadableStream<T> is a regular capnweb value. The wire never
inlines blob bytes — change streams carry content-addressed
(hash, size) records and the receiver calls back via hasObjects
/ pushObjects for the missing subset. Prefer streaming over single
large payloads when adding new RPCs.
When you receive a streaming result, the envelope owns the stream. Draining the stream does not dispose the envelope; dispose the envelope to release every stub it contains.
Do / don't
- Do define new methods on
WorkspaceRPCininterface.tsbefore implementing them on either side. - Do treat stubs as capabilities. Don't pass them across session boundaries unless you mean to grant access.
- Do drive sync rounds through
pullOnce/pushOncewhen you can. - Do declare
usingon every awaited result envelope from a direct streaming call. - Do dispose result envelopes even when you don't think they contain stubs — futureproofing is cheap.
- Do call
.dup()rather than awaiting twice when you need a stub copy to outlive a callee's auto-dispose. - Do run the leak harness (
script/computerd-stub-soak) when you change anything around RPC lifecycle, and checksession.getStats()for drift. - Don't send binary WebSocket frames. The wire is text JSON.
- Don't tear down the underlying carrier directly. Always go
through
client.close()so the root stub disposes first. - Don't mutate the
WorkspaceRPCinterface without updating both sides — the wire contract is shared. - Don't declare a method
privatein TypeScript and assume it's hidden from RPC. Use a#-prefixed name to actually make it private at runtime. - Don't rely on garbage collection to clean up stubs. It won't.
Testing for leaks
- Use
enableStubTracking()+stubSnapshot()in a test to assert no stub survives a round trip you expected to clean up. - Soak the boundary with
script/computerd-stub-soakfor disposal-sensitive changes; it readssession.getStats()to detect drift. - Server-side RPC behavior is tested against the real
Databaseand real driver helpers inpackages/rpcandpackages/computer.
Further reading
- capnweb on GitHub — the
upstream README is the authoritative reference for stub
ownership,
.dup(),.map(), and transport semantics. docs/08_capnweb_interface.mddocs/11_lifecycle.mdpackages/rpc/README.md
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

