@parcha/agentrun-computer 0.0.0-stage → 0.1.0-beta.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +8 -0
  3. package/README.md +2401 -2
  4. package/box/Dockerfile +69 -0
  5. package/box/agentrun-archil +168 -0
  6. package/box/build-daytona.py +26 -0
  7. package/box/build-e2b.mjs +32 -0
  8. package/box/build-modal.py +17 -0
  9. package/dist/actions.d.ts +18 -0
  10. package/dist/actions.js +139 -0
  11. package/dist/browser.d.ts +151 -0
  12. package/dist/browser.js +305 -0
  13. package/dist/browserbase.d.ts +139 -0
  14. package/dist/browserbase.js +408 -0
  15. package/dist/child.d.ts +40 -0
  16. package/dist/child.js +127 -0
  17. package/dist/client.d.ts +22 -0
  18. package/dist/client.js +136 -0
  19. package/dist/computerd-linux-amd64 +0 -0
  20. package/dist/computerd-linux-arm64 +0 -0
  21. package/dist/conformance/archil.d.ts +68 -0
  22. package/dist/conformance/archil.js +152 -0
  23. package/dist/conformance/browserbase.d.ts +35 -0
  24. package/dist/conformance/browserbase.js +45 -0
  25. package/dist/conformance/cases/apps.d.ts +2 -0
  26. package/dist/conformance/cases/apps.js +155 -0
  27. package/dist/conformance/cases/browser.d.ts +4 -0
  28. package/dist/conformance/cases/browser.js +105 -0
  29. package/dist/conformance/cases/drift.d.ts +2 -0
  30. package/dist/conformance/cases/drift.js +64 -0
  31. package/dist/conformance/cases/exec.d.ts +2 -0
  32. package/dist/conformance/cases/exec.js +125 -0
  33. package/dist/conformance/cases/files.d.ts +2 -0
  34. package/dist/conformance/cases/files.js +294 -0
  35. package/dist/conformance/cases/health.d.ts +2 -0
  36. package/dist/conformance/cases/health.js +71 -0
  37. package/dist/conformance/cases/index.d.ts +9 -0
  38. package/dist/conformance/cases/index.js +37 -0
  39. package/dist/conformance/cases/input.d.ts +12 -0
  40. package/dist/conformance/cases/input.js +109 -0
  41. package/dist/conformance/cases/isolation.d.ts +21 -0
  42. package/dist/conformance/cases/isolation.js +92 -0
  43. package/dist/conformance/cases/lifetime.d.ts +2 -0
  44. package/dist/conformance/cases/lifetime.js +64 -0
  45. package/dist/conformance/cases/mount.d.ts +2 -0
  46. package/dist/conformance/cases/mount.js +252 -0
  47. package/dist/conformance/cases/process.d.ts +2 -0
  48. package/dist/conformance/cases/process.js +240 -0
  49. package/dist/conformance/cases/provider.d.ts +2 -0
  50. package/dist/conformance/cases/provider.js +302 -0
  51. package/dist/conformance/cases/screen.d.ts +9 -0
  52. package/dist/conformance/cases/screen.js +230 -0
  53. package/dist/conformance/cases/settings.d.ts +57 -0
  54. package/dist/conformance/cases/settings.js +142 -0
  55. package/dist/conformance/cases/touch.d.ts +2 -0
  56. package/dist/conformance/cases/touch.js +117 -0
  57. package/dist/conformance/cases/util.d.ts +7 -0
  58. package/dist/conformance/cases/util.js +8 -0
  59. package/dist/conformance/cdp.d.ts +13 -0
  60. package/dist/conformance/cdp.js +88 -0
  61. package/dist/conformance/cli.d.ts +29 -0
  62. package/dist/conformance/cli.js +231 -0
  63. package/dist/conformance/daytona-sweep.d.ts +18 -0
  64. package/dist/conformance/daytona-sweep.js +118 -0
  65. package/dist/conformance/daytona.d.ts +83 -0
  66. package/dist/conformance/daytona.js +107 -0
  67. package/dist/conformance/docker.d.ts +38 -0
  68. package/dist/conformance/docker.js +70 -0
  69. package/dist/conformance/drift-daemon.d.ts +8 -0
  70. package/dist/conformance/drift-daemon.js +41 -0
  71. package/dist/conformance/e2b-diagnose.d.ts +16 -0
  72. package/dist/conformance/e2b-diagnose.js +61 -0
  73. package/dist/conformance/e2b-sweep.d.ts +18 -0
  74. package/dist/conformance/e2b-sweep.js +125 -0
  75. package/dist/conformance/e2b.d.ts +74 -0
  76. package/dist/conformance/e2b.js +111 -0
  77. package/dist/conformance/fixture.d.ts +65 -0
  78. package/dist/conformance/fixture.js +98 -0
  79. package/dist/conformance/index.d.ts +8 -0
  80. package/dist/conformance/index.js +8 -0
  81. package/dist/conformance/kernel.d.ts +31 -0
  82. package/dist/conformance/kernel.js +40 -0
  83. package/dist/conformance/kind.d.ts +23 -0
  84. package/dist/conformance/kind.js +58 -0
  85. package/dist/conformance/modal-sweep.d.ts +22 -0
  86. package/dist/conformance/modal-sweep.js +190 -0
  87. package/dist/conformance/modal.d.ts +69 -0
  88. package/dist/conformance/modal.js +76 -0
  89. package/dist/conformance/orgo.d.ts +41 -0
  90. package/dist/conformance/orgo.js +69 -0
  91. package/dist/conformance/phone-harness.d.ts +61 -0
  92. package/dist/conformance/phone-harness.js +241 -0
  93. package/dist/conformance/png.d.ts +16 -0
  94. package/dist/conformance/png.js +132 -0
  95. package/dist/conformance/report.d.ts +2 -0
  96. package/dist/conformance/report.js +86 -0
  97. package/dist/conformance/runner.d.ts +11 -0
  98. package/dist/conformance/runner.js +585 -0
  99. package/dist/conformance/tar.d.ts +13 -0
  100. package/dist/conformance/tar.js +105 -0
  101. package/dist/conformance/types.d.ts +257 -0
  102. package/dist/conformance/types.js +24 -0
  103. package/dist/daemon-copy.d.ts +40 -0
  104. package/dist/daemon-copy.js +259 -0
  105. package/dist/daytona.d.ts +178 -0
  106. package/dist/daytona.js +1484 -0
  107. package/dist/desktop.d.ts +24 -0
  108. package/dist/desktop.js +68 -0
  109. package/dist/docker/egress-main.d.ts +1 -0
  110. package/dist/docker/egress-main.js +68 -0
  111. package/dist/docker/egress-proxy.d.ts +53 -0
  112. package/dist/docker/egress-proxy.js +450 -0
  113. package/dist/docker/egress-table.d.ts +39 -0
  114. package/dist/docker/egress-table.js +197 -0
  115. package/dist/docker/egress.d.ts +109 -0
  116. package/dist/docker/egress.js +318 -0
  117. package/dist/docker/image.d.ts +49 -0
  118. package/dist/docker/image.js +302 -0
  119. package/dist/docker/stage.d.ts +21 -0
  120. package/dist/docker/stage.js +290 -0
  121. package/dist/docker/volume.d.ts +24 -0
  122. package/dist/docker/volume.js +67 -0
  123. package/dist/docker.d.ts +150 -0
  124. package/dist/docker.js +1200 -0
  125. package/dist/drift.d.ts +200 -0
  126. package/dist/drift.js +416 -0
  127. package/dist/e2b.d.ts +335 -0
  128. package/dist/e2b.js +1515 -0
  129. package/dist/entry.d.ts +2 -0
  130. package/dist/entry.js +24 -0
  131. package/dist/files.d.ts +50 -0
  132. package/dist/files.js +208 -0
  133. package/dist/index.d.ts +27 -0
  134. package/dist/index.js +26 -0
  135. package/dist/isolation.d.ts +29 -0
  136. package/dist/isolation.js +71 -0
  137. package/dist/janitor.d.ts +50 -0
  138. package/dist/janitor.js +135 -0
  139. package/dist/kernel.d.ts +113 -0
  140. package/dist/kernel.js +358 -0
  141. package/dist/kinds.d.ts +79 -0
  142. package/dist/kinds.js +133 -0
  143. package/dist/labels.d.ts +23 -0
  144. package/dist/labels.js +50 -0
  145. package/dist/modal.d.ts +302 -0
  146. package/dist/modal.js +1374 -0
  147. package/dist/mount-archil.d.ts +164 -0
  148. package/dist/mount-archil.js +471 -0
  149. package/dist/mount.d.ts +57 -0
  150. package/dist/mount.js +104 -0
  151. package/dist/orgo-channel.d.ts +96 -0
  152. package/dist/orgo-channel.js +391 -0
  153. package/dist/orgo.d.ts +139 -0
  154. package/dist/orgo.js +1006 -0
  155. package/dist/phone-harness.d.ts +185 -0
  156. package/dist/phone-harness.js +1420 -0
  157. package/dist/processes.d.ts +24 -0
  158. package/dist/processes.js +40 -0
  159. package/dist/protocol.d.ts +729 -0
  160. package/dist/protocol.js +54 -0
  161. package/dist/provider.d.ts +245 -0
  162. package/dist/provider.js +37 -0
  163. package/dist/providers.d.ts +68 -0
  164. package/dist/providers.js +25 -0
  165. package/dist/result.d.ts +15 -0
  166. package/dist/result.js +2 -0
  167. package/dist/screen-watch.d.ts +150 -0
  168. package/dist/screen-watch.js +490 -0
  169. package/dist/test-connection.d.ts +17 -0
  170. package/dist/test-connection.js +26 -0
  171. package/dist/wait.d.ts +23 -0
  172. package/dist/wait.js +65 -0
  173. package/package.json +62 -4
package/README.md CHANGED
@@ -1,3 +1,2402 @@
1
- # Temporary Holding Version
1
+ # @parcha/agentrun-computer
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Published from the next release; nothing else in the repository uses it yet.
4
+
5
+ ```sh
6
+ npm install @parcha/agentrun-computer@latest
7
+ ```
8
+
9
+ ```ts
10
+ import { DockerProvider, providerModule } from "@parcha/agentrun-computer";
11
+ // The mount rule alone: loads no provider, no vendor SDK and no conformance code.
12
+ import { checkMount, readBackOf, WORKSPACE, type MountSpec } from "@parcha/agentrun-computer/mount";
13
+ ```
14
+
15
+ The package carries the daemon for Linux amd64 and arm64 in `dist/`, so a provider runs it with no Go on the host. A
16
+ vendor's SDK is the host's: Modal's `modal` package is imported only when the Modal provider is built, and the package
17
+ depends on nothing. A provider's mount kinds are its file's `MOUNT`, read with `(await providerModule(id)).MOUNT`,
18
+ which loads that one provider's file and the protocol modules it uses, and no other provider.
19
+
20
+ Every install carries all of `dist/`, whatever the host's architecture and whichever provider it uses: both daemons
21
+ (a Docker host on either architecture and every remote provider use one of them, and the archive does not know which),
22
+ every provider's module, and the conformance CLI and suite with the Daytona sweep. At 0.1.0-beta.31 (`npm pack
23
+ --dry-run --json`) that is 122 files, 3,688,167 bytes packed and 9,234,731 unpacked; the two daemons are 8,216,900 of
24
+ the unpacked bytes (4,219,042 amd64, 3,997,858 arm64) and the conformance code 238,421. The trade: no Go, no download
25
+ and no install script on the host, for one daemon more than the host runs: about 4 MB unpacked and 1.6 MB compressed.
26
+
27
+ The open platform's computer protocol. A computer is anything an agent can run commands on: a container, a microVM, a
28
+ full VM, a machine. The protocol has two layers:
29
+
30
+ - **A daemon in every computer.** `computerd` is one small static Go program (Linux, amd64 and arm64, no cgo). It speaks
31
+ JSON-RPC 2.0, one JSON object per line, over stdin and stdout, so it works in a computer with no network.
32
+ - **One provisioner per vendor.** A provisioner makes, finds and ends computers, and opens a stream to the daemon
33
+ inside. It never runs commands itself: the daemon does. This package has four: Docker, Modal's VM runtime, Daytona
34
+ and E2B (desktops), each one line of the provider registry (see [Adding a computer](#adding-a-computer)).
35
+
36
+ ## What it does today
37
+
38
+ The daemon answers `hello`, `ping`, `exec.run`, the `files.*` methods, `tar.*`, the `process.*` methods and
39
+ `deadline.extend`; hello reports kind `linux` and groups `["exec", "files", "processes"]` (see [The protocol
40
+ extension](#the-protocol-extension-kind-daemon-modes-screen-input-apps-lifetime)). With an X display it also answers
41
+ `screen.shot`, `screen.read` and `input.actions`, and reports kind `desktop` with `screen`, `input.pointer` and
42
+ `input.keys` (see [The X11 shim](#the-x11-shim)).
43
+
44
+ ```text
45
+ → {"jsonrpc":"2.0","id":1,"method":"hello","params":{"client":"me"}}
46
+ ← {"jsonrpc":"2.0","id":1,"result":{"version":"0.1.0-beta.30","os":"linux","kind":"linux","arch":"arm64","groups":["exec","files","processes"]}}
47
+ → {"jsonrpc":"2.0","id":2,"method":"exec.run","params":{"argv":["uname","-m"],"timeoutMs":5000}}
48
+ ← {"jsonrpc":"2.0","id":2,"result":{"exitCode":0,"stdout":"YWFyY2g2NAo=","stderr":"","timedOut":false,"truncated":false}}
49
+ ```
50
+
51
+ - `exec.run` takes argv, never a shell string. A shell is the caller's choice: `["sh", "-c", "..."]`.
52
+ - Each run has a guard: the daemon starts itself again as `computerd guard`, a child subreaper for that one run, and
53
+ the guard starts the program in a process group of its own. Whatever the program starts stays under the guard, even
54
+ a child that calls `setsid` or double-forks, since the kernel hands an orphan to its nearest subreaper. When the
55
+ program ends, the guard kills and reaps every process left under it, then reports the program's exit code or signal.
56
+ A signal is named without `SIG`, here and in `process.wait` and `process.list`: `"TERM"`, `"KILL"` (a signal with no
57
+ name is its number, `"63"`).
58
+ On timeout, or when the call is cancelled with `$/cancelRequest {id}`, the guard sends SIGTERM to the group and
59
+ every process under it, then SIGKILL 2 s later. A timeout is a result with `timedOut: true`; a cancel is an
60
+ `aborted` error. Nothing a run starts outlives it. `timeoutMs` counts from the call, the start included: a guard that
61
+ never reports the program's start (its exec stalled on a filesystem) is killed with everything under it, and the run
62
+ times out.
63
+ - `stdout` and `stderr` come back apart, in base64. Each keeps at most 360 KiB (`maxOutput`, the default and the most):
64
+ both, in base64, fit one 1 MiB line. The rest is read and dropped, and `truncated` is true.
65
+ - The environment is PATH (the daemon's), HOME, USER and LOGNAME for the user, then, when init relays to an egress
66
+ proxy (`init --egress`, [below](#an-allowlist-the-egress-proxy)), `HTTP_PROXY`, `HTTPS_PROXY`, their lowercase forms
67
+ and `NO_PROXY`, then `env` over them. Nothing else of the daemon's environment is passed on.
68
+ - `user` is a name or `uid[:gid]`. A daemon without CAP_SETUID and CAP_SETGID cannot switch users and answers `denied`.
69
+ Init leaves itself no capability (below), so a command runs as the daemon's own user.
70
+ - Requests run at once; replies may come in any order. A line over 1 MiB gets an error reply and the connection goes
71
+ on. When the input ends, what still runs on that connection is cancelled: an `exec.run`, never a process.
72
+ - Errors are `{code, message, data: {kind}}`, with kind `not_found`, `invalid`, `timeout`, `aborted`, `denied`, `limit`,
73
+ `unsupported`, `exists`, `not_dir` or `is_dir`.
74
+
75
+ ### Init, the socket and the bridge
76
+
77
+ - `computerd init --deadline <time> [--max-deadline <time>]` is the computer's first process. It listens on a unix socket,
78
+ `/run/agentrun/computerd.sock` (or `AGENTRUN_COMPUTERD_SOCKET`); the socket is 0600, so only the daemon's user can
79
+ connect. Init does not make the socket's directory, since a non-root init cannot write under `/run`: the provider
80
+ gives it, the daemon's user's alone (mode 0700). Init exits 1, saying why, when the directory is missing, is not the
81
+ user's alone, or is not writable by it.
82
+ Every connection is served by the same daemon with one process table, which is how a process outlives the call and
83
+ the connection that started it. A socket left by an init that is gone is replaced; a live one is refused.
84
+ - `computerd init --deadline <time> --user <uid:gid>` is for a vendor that runs every computer as root and has no user
85
+ of its own to give (Modal), or whose images' privilege tools cannot be relied on (Daytona). Init starts as root,
86
+ makes `$HOME` and the socket's directory that user's alone (0700, never through a symbolic link), and becomes uid:gid
87
+ with no supplementary groups, dropping its privileges on the way as below: from there it is the daemon a Docker
88
+ computer runs. `--user 0:0` is root with no capability. Without
89
+ root, init refuses `--user` in words; a Docker computer is given its user by `docker run --user` and never passes it.
90
+ - `computerd init ... --user <uid:gid> --own-network` is how every remote provider starts init (Daytona, E2B, Modal).
91
+ A remote vendor runs its own agent in the computer beside the daemon's programs (Daytona's toolbox on 2280, E2B's
92
+ envd on 49983), listening on the loopback and on every address the computer has and running commands as root, or as
93
+ a user with sudo, for whoever reaches it: without this, any program could ask it for root. Init, still root:
94
+ refuses uid 0 for its programs (root shares its uid with every root process of the vendor's); refuses to start while
95
+ any other process holds that uid (one could be signalled, traced or written to by them, and a vendor's agent among
96
+ them would be theirs to command), naming each; moves every one of its threads into a new network namespace and
97
+ brings its loopback up, reading back that no thread stayed behind and that the loopback alone is up or addressed
98
+ (a kernel with the tunnel modules loaded gives every new namespace its fallback tunnels, tunl0, gre0, sit0 and the
99
+ rest, down with no address: they stay so, since no program holds CAP_NET_ADMIN, and computerd's probe reports any
100
+ it could bring up, which every read-back refuses); then drops as below, and installs a seccomp filter on every thread that refuses (EPERM) a socket of family
101
+ `AF_VSOCK` (a network namespace does not cut vsock, where a virtual machine's agent may listen) and `io_uring_setup`
102
+ (its rings open sockets past a filter on `socket(2)`), and gives `ENOSYS` to every call of another architecture or
103
+ table (32-bit x86, x32). So init and every program it starts reach their own loopback and nothing else: no address of
104
+ the computer's, no listener on its loopback, no abstract unix socket outside, no vsock. The vendor's exec of
105
+ `computerd stdio` stays outside and still reaches init's socket: a unix socket with a path is not in a network
106
+ namespace. It needs root with CAP_SYS_ADMIN and CAP_NET_ADMIN (a VM's root, a privileged container); without them, or
107
+ with any read-back short, init refuses to start in words and the computer fails closed. `--own-network` takes no
108
+ `--egress`: such a computer's network is `none` (open and allowlists wait for a proxy out of that namespace, which
109
+ is not built yet). The code is `daemon/internal/isolate`; `test/docker/loopback-block.docker.test.mjs` runs each
110
+ provider's start in a root container beside a stand-in agent on 2280 and 49983.
111
+ - **Init drops its privileges itself, as any user, root included,** before it listens, so the line holds on every
112
+ vendor and not only where the provider drops capabilities (Docker: `--cap-drop ALL`). On every thread it sets
113
+ `no_new_privs`; drops from the bounding set each capability up to the kernel's last
114
+ (`/proc/sys/kernel/cap_last_cap`) that is still there; makes the uid change, with `--user`; empties the ambient set
115
+ and, by `capset`, the effective, permitted and inheritable sets (a uid of 0 keeps them through any uid change); and
116
+ reads all of it back. So init, every program it starts and every program those start hold no capability in any set
117
+ (`CapInh`, `CapPrm`, `CapEff`, `CapBnd` and `CapAmb` all `0000000000000000`, `NoNewPrivs` 1), and with the bounding
118
+ set empty not even a program root starts gains one. Root without a capability is root to the file system's
119
+ permission bits only: it owns what uid 0 owns. Emptying the bounding set needs CAP_SETPCAP; a capability already
120
+ gone is not dropped again, so a process started with an empty bounding set needs none. When a capability cannot be
121
+ dropped (EPERM, such as a user with a bounding set and no CAP_SETPCAP, as `go test` runs on a host), or the binary
122
+ links cgo (one call cannot reach every thread), init refuses to start, in words, and exits 1.
123
+ - **That refusal is policy: init fails closed.** A vendor that starts the daemon as a non-root user with a bounding
124
+ set it cannot empty (a Kubernetes `runAsUser` without `capabilities: drop: ["ALL"]`, say, or `docker run --user`
125
+ without `--cap-drop ALL`) gets no computer, not a computer that runs anyway. The line this package holds is that
126
+ every set reads back zero, so no program in a computer holds a capability or can gain one. `no_new_privs` already
127
+ stops a gain through `exec` (a setuid-root file, file capabilities); the empty bounding set is the second,
128
+ independent limit on the same gain, and init cannot prove from inside that a bounding set it was handed is harmless
129
+ on every kernel and vendor it runs on. So it does not run with capabilities it cannot prove gone. A refusal is said, in words naming the capability and EPERM, and is
130
+ fixed where it starts: drop every capability for the user, or start init as root holding CAP_SETPCAP so it drops
131
+ them itself. A start that went on would be silent, and every program in the computer would inherit it.
132
+ - **The daemon's Go tests run without cgo, as computerd is built.** Go builds with cgo wherever it finds a C compiler,
133
+ so a plain `go test ./...` makes test binaries that link cgo, and in one of those init refuses to start for cgo
134
+ (ENOTSUP) alone. The test entry of `cmd/computerd` and `internal/daemon` (`internal/nocgo`, from `TestMain`) builds
135
+ such a package's test binary again with `CGO_ENABLED=0 go test -c` and the `-tags` and `-ldflags` the first was
136
+ built with (read from its build info), runs it with the same arguments and
137
+ environment, and exits with its code; a binary without cgo runs its tests itself, and a `-race` build (which needs
138
+ cgo) skips the tests of the drop. On a host as another user the refusal for EPERM and both deadline tests run (init
139
+ takes its deadline and refuses for the bounding set). The root path (`TestBecome...`, `TestUnprivilegedLeavesRoot...`)
140
+ needs root with capabilities and skips there; CI's `computer-docker` job covers it with the Modal commands matrix
141
+ (`test/docker/modal-commands.docker.test.mjs`: root containers with Docker's default capabilities and the two
142
+ `--own-network` needs, or `--cap-add ALL`, as 1000:1000, the refusal of 0:0 and the refusal without CAP_SETPCAP), and
143
+ computerd's end at its deadline with the Docker live tests. The test binaries (`CGO_ENABLED=0 go test -c`) also run
144
+ as root in a container by hand: `internal/isolate`'s and the isolated `TestBecome...` need CAP_SYS_ADMIN and
145
+ CAP_NET_ADMIN (`docker run --cap-add SYS_ADMIN --cap-add NET_ADMIN`), and the refusal without them a container
146
+ with Docker's defaults.
147
+ - `computerd probe [--connect <host:port>[/udp]]...` prints one JSON line: the uid and gid it runs as, the kernel's
148
+ release, `interfaces` (the network interfaces its network namespace holds: `["lo"]` alone under `--own-network`),
149
+ `reached` (the targets that answered), `accepted` (the targets that accepted a TCP connection and sent nothing back)
150
+ and `results`, each target's `protocol`, `outcome` (`refused`, `accepted` or `answered`), `bytes` and `detail` in
151
+ words. A provider whose vendor reads nothing back runs it through `exec.run` (below, Modal), under the rule in
152
+ [Network none, read from inside](#network-none-read-from-inside-nothing-answers). `computerd probe --diagnose` asks
153
+ more: for 1.1.1.1, 8.8.8.8, 9.9.9.9 and 151.101.1.57 (Fastly's anycast edge, which is no resolver) on 443/tcp,
154
+ 80/tcp and 53/udp it reports `refused` (no TCP accept, no UDP answer), `accepted` (an accept, no answer) or
155
+ `answered` (a TLS ServerHello, an `HTTP/1.` status line, a DNS response with the query's id), with 3 s to connect and
156
+ 3 s to answer, 15 s in all and at most 4 KiB read per check, and a `verdict`: `egress`, `accepted-only` or `none`.
157
+ It sends nothing of the computer's: a ClientHello with a random nonce, `HEAD / HTTP/1.0`, a query for `example.com`.
158
+ - `computerd stdio` is a thin bridge: it connects to the socket (waiting up to 3 s for a computer that has just
159
+ started) and copies bytes both ways until either side ends. With no daemon to reach it says so on stderr and exits 1;
160
+ it never serves on its own.
161
+ - Init is a child subreaper (PID 1 in Docker is one anyway) and reaps every orphan. It also sweeps, on each SIGCHLD and
162
+ once a second: a child of its own that is not one of its guards can only be an orphan whose guard died (a program can
163
+ kill its own guard, since both run as the same user), so it is killed with everything under it. A process orphaned by
164
+ something run with `docker exec`, outside the daemon, is ended the same way.
165
+ - On SIGTERM or SIGINT (`docker stop`), and at its deadline, init first stops taking new programs: from then on
166
+ `process.start` and `exec.run` are refused as `unsupported` ("the computer is shutting down"). It waits (up to 3 s)
167
+ for the starts already under way to start their program, then sends SIGTERM to every guard, each of which ends its
168
+ program's group and descendants with SIGKILL 2 s later; whatever is still under init 5 s after the SIGTERM is killed,
169
+ and init exits 0. So every program that started gets SIGTERM before any SIGKILL. Connections stay open until init
170
+ exits, so reads, waits and lists still answer. One shutdown serves all three.
171
+ - A guard also ends its program when its control pipe from the daemon closes, so no program outlives the daemon.
172
+ - `deadline.extend({ at })` moves init's deadline to `at` (an ISO time) and answers `{ at }`, the deadline it holds
173
+ after. It refuses in words an earlier time (`invalid`), one past `--max-deadline`, the most the provider allowed at
174
+ start (`limit`), and any move when init got no `--max-deadline` (`unsupported`); a refusal moves nothing. Init
175
+ refuses to start with a maximum before its deadline.
176
+
177
+ ### Network none, read from inside: nothing answers
178
+
179
+ Where a vendor reads no network policy back, `computerd probe` stands for one, and network none holds only when
180
+ **nothing answers within 10 s**: a target counts as reached only when bytes come back from it. One rule for every
181
+ provider.
182
+
183
+ - **Targets.** `host:port` is tried over TCP; `host:port/udp` (the `/udp` suffix, on `--connect` and in a provider's
184
+ `probeTargets`) is sent a DNS query over UDP. Modal's and E2B's defaults are TCP to `1.1.1.1:443`, `8.8.8.8:443`
185
+ and `[2606:4700:4700::1111]:443`, and DNS over UDP to `1.1.1.1:53/udp` and `[2606:4700:4700::1111]:53/udp`: DNS over
186
+ UDP is the classic path out of a sandbox that drops TCP.
187
+ - **Each TCP target gets a request by its port**, so a server that waits for its client speaks: 443 a TLS 1.2
188
+ ClientHello, 80 an HTTP/1.0 `HEAD /`, 53 a DNS query for example.com (behind its 2-byte length), and any other port
189
+ an HTTP `HEAD /` (the most common protocol where the client speaks first; a server that speaks first, as SSH and SMTP
190
+ do, answers whatever is sent). The ClientHello names the server (SNI) only when the target's host is a name: an IP
191
+ literal is no server name (RFC 6066, section 3), so `1.1.1.1:443` gets none. The HTTP request's `Host` is the
192
+ target's host. **A UDP target**, whatever its port, gets one datagram: a recursive DNS query for example.com's A
193
+ records with a random id.
194
+ - **Bounds:** 10 s to connect, 10 s from the request to the answer, at most 4 KiB read per target, every target at once.
195
+ The probe runs once per create (and per attach and `network(ref)`), so its window is wide: a transparent proxy that
196
+ connects onward lazily, under load, still answers within it. Modal's and E2B's 30 s bound on the probe's `exec.run`
197
+ covers the longest a probe can take (20 s).
198
+ - **Outcomes.** `refused`: no connection, or for UDP no reply (UDP has no accept, so a datagram that brings nothing back
199
+ is refused, as is one the far side's ICMP port-unreachable answers). `answered`: any byte came back, whatever it is: a
200
+ ServerHello, a TLS alert (a server that will not serve the hello still spoke), an HTTP status line, a DNS response
201
+ with the query's id and the response bit, a banner, or bytes of no expected protocol (the detail says which; over UDP
202
+ a datagram that is not the DNS response still came back, and is an answer). Only `answered` is `reached`, and a
203
+ provider refuses network none on any. `accepted`: a TCP connection, then nothing back within the bound, closed or
204
+ held open.
205
+ - **An accepted-but-silent connection is recorded, never refused and never hidden.** Some firewalls accept every
206
+ outbound connection first and decide after, closing a denied one with nothing sent back (E2B documents exactly this).
207
+ Such a connection shows that nothing came back, so it is not counted as reached. The provider keeps the computer and
208
+ names the targets in its read-back's words: `notes` on what `create` returns and on what `attach` finds, such as
209
+ `network: none; accepted with no answer (no bytes came back): 1.1.1.1:443, 8.8.8.8:443`. `network(ref)` reads back
210
+ none. The conformance report carries create's notes too, each naming its computer (see
211
+ [Conformance](#conformance)).
212
+ - **What the rule can and cannot detect.** It detects a TCP or UDP path that carries bytes back within 10 s on a probed
213
+ host:port. It cannot detect:
214
+ - a one-way leak: a path that forwards outbound bytes and drops every reply reads accepted or refused, never answered;
215
+ - a port that is not probed: the probe shows its own targets are blocked, not every address;
216
+ - a client-first server that silently drops what it is sent: a TCP target whose server waits for its own protocol and
217
+ drops a first message it cannot parse (an HTTP `HEAD` sent to a port that speaks something else) reads `accepted`.
218
+ The defaults never meet this (443 gets TLS, 53 DNS); only an operator's own `probeTargets` can.
219
+ - **What it changes.** Only a provider that probes, on a vendor whose firewall accepts first, reads differently: E2B
220
+ ([below](#network)), whose computers with network none the accept-counts rule refused, and are now kept with notes.
221
+ Docker reads its network back from `docker inspect` (`--network none` leaves no interface but `lo`, so a TCP
222
+ connection is refused outright and a UDP datagram has no route, which `test/docker/modal-commands.docker.test.mjs`
223
+ pins with the probe itself, every default target refused); Daytona reads `networkBlockAll` back from its API and runs
224
+ no probe; Modal's live run with `blockNetwork` read back no TCP accept at any target under the earlier accept-counts
225
+ rule, so nothing it accepted is newly let through. The UDP targets have not yet run live on Modal.
226
+
227
+ ### Processes
228
+
229
+ A process is a program started under its own guard, as `exec.run`'s are, that keeps running after its call returns.
230
+ Its whole tree ends when the program ends or is signalled to its end. Ids are `p1`, `p2`, ...; data is base64.
231
+
232
+ | Method | Params | Result |
233
+ | --- | --- | --- |
234
+ | `process.start` | `argv, cwd?, env?, user?, pty?: {cols, rows}, stdin?, log?, waitGroup?, orphans?: "keep"` | `{id, pid}`: `pid` is the program's. `cwd`, `env` and `user` are as for `exec.run`. Without `stdin` (and without a pty) stdin is /dev/null. `log`, `waitGroup` and `orphans` are below |
235
+ | `process.read` | `id, stream, offset, maxBytes?, waitMs?` | `{data, nextOffset, dropped, exited, size, capped?, logError?}`: `stream` is `stdout` or `stderr`, or `pty`, or `log`; at most 512 KiB a call (more is `limit`); `size` is the stream's bytes so far, kept or dropped |
236
+ | `process.write` | `id, data?, close?` | `{}`: to stdin, or the terminal; `close` closes stdin after the data |
237
+ | `process.signal` | `id, signal` | `{}`: `TERM`, `INT`, `KILL` or `HUP`, to the program's process group, except `INT` with a pty (below); to a process that has ended it does nothing |
238
+ | `process.resize` | `id, cols, rows` | `{}`: the terminal's new size; the program gets SIGWINCH |
239
+ | `process.list` | `from?` | `{processes, truncated, next}`: `processes` are `{id, pid, argv, argvClipped, pty, running, exitCode, signal, startedAt, endedAt}` in start order, times in milliseconds since the epoch; at most 768 KiB a reply: when `truncated`, list again with `from` set to `next`. Pages follow start order, not places in the table, so a process dropped between two pages makes the next skip none |
240
+ | `process.wait` | `id, timeoutMs` | `{running, exitCode, signal}`: waits up to `timeoutMs` (0 to a day) for the end; `running` is true on timeout |
241
+
242
+ - Each stream keeps its last 8 MiB in a ring. Offsets count bytes since the process started; `nextOffset` is where the
243
+ next read starts. A read below the ring's start begins at its start, and `dropped` says how many bytes were lost; an
244
+ offset past the end is `invalid`. `exited` is true once the process has ended and nothing is left past `nextOffset`.
245
+ - `waitMs` (at most 30 000) makes a read wait, when nothing past `offset` has come yet, until bytes come, the process
246
+ ends, or the time is up. So a client follows a process with one call in flight and no busy loop.
247
+ - A process whose guard was killed reports the guard's end; one whose guard init's shutdown reaped first reports `KILL`.
248
+ - A listing holds at most 64 KiB of each argv, in JSON. A longer one is listed by its first arguments that fit, with
249
+ `argvClipped` set; the caller that started it has the whole of it.
250
+ - With `pty`, stdout and stderr are one `pty` stream, and the program runs in a session of its own with the terminal
251
+ as its controlling terminal (setsid and TIOCSCTTY in the guard). A terminal has no stdin to close: write `"\x04"`
252
+ for the end of input, or signal `HUP`.
253
+ - `INT` to a process with a pty is ^C: it goes to the terminal's foreground process group, as the terminal driver
254
+ sends it, so it ends the job a shell runs in the foreground and the shell reads on. The daemon reads that group on
255
+ the terminal it holds (TIOCGPGRP) and has the guard signal it only when it is in the program's own session (and so
256
+ under the guard); a terminal the program handed to another session is refused as `denied`, and nothing is
257
+ signalled. The group can end between that check and the signal, and its id go to a group in another session, so the
258
+ guard checks again right before it signals: a group with no process left in the program's session is not signalled,
259
+ and the reply says `INT` was not sent: `{note}`. A terminal with no foreground group left (the program let go of it, or is ending) has `INT` go to the
260
+ program's group, and the reply says so: `{note}`. `TERM`, `KILL` and `HUP` always go to the program's group.
261
+ - Starts take turns. A `process.start` cancelled while it waits for its turn, or before its program runs, is `aborted`,
262
+ and nothing it started is left.
263
+ - Writes to one process take turns. A write waits at most 10 s, its turn included, for the program to read; the rest is
264
+ a `timeout` error that says how much was written. A cancelled write, waiting for its turn or writing, is `aborted`.
265
+ - The guard keeps no copy of a program's stdin, stdout or stderr pipes once the program runs. So when the program, and
266
+ everything it started, have closed stdin (`exec 0<&-`), a write fails at once as `invalid`, while the program runs
267
+ on. A terminal is kept open by the guard until the program ends.
268
+ - The table holds at most 256 processes, running or ended. A start into a full table drops the process that ended
269
+ first (its output with it) once the new program runs; a start that is refused drops nothing. When all 256 run, the
270
+ start is refused as `limit`.
271
+ - The rings, of running and ended processes alike, hold at most 256 MiB of output together (256 entries' full rings
272
+ would be 4 GiB, the default box's memory). Past that, the daemon first lets go of the rings of the processes that
273
+ ended first until it is back under. Such a process stays listed with its exit status; a read of its streams returns
274
+ no data, `dropped` counts every byte from `offset` on, and `exited` is true. When no ended ring is left and running
275
+ processes still hold more, each running process's ring stops growing and keeps at most an equal share of the budget
276
+ (never under 64 KiB), dropping its oldest bytes; a read from an offset it dropped reports them in `dropped`.
277
+ - `log` is an absolute path for a new file the daemon makes and writes the first 16 MiB of the output to, stdout and
278
+ stderr (or the terminal's) as they come; later output is dropped there while the process runs on. The daemon makes
279
+ the missing directories and the file itself, never through a link: each directory is entered from the one above it
280
+ with `O_NOFOLLOW|O_DIRECTORY`, and the file is made with `O_CREAT|O_EXCL|O_NOFOLLOW`, mode 0644, the daemon's. A
281
+ link at the path or at any directory on its way is refused as `denied`, a file already there as `exists`, and the
282
+ program never starts; a start that fails after the file was made removes it. The `log` stream reads it through the
283
+ daemon's own open file, never by the path, so a rename or removal under it changes nothing read: `size` is the bytes
284
+ the log holds, `capped` says output past them was dropped, and `dropped` is 0. A write to the log that fails or
285
+ writes short (a full disk) stops the log for good: nothing after it is written, so the file stays a true prefix of
286
+ the output, and `logError` says why. The log holds all of the output once its stream reads `exited`; the process's
287
+ end can come before that.
288
+ - `waitGroup`: the process runs until its program and every live process left in its process group (with a pty, its
289
+ session) have ended, and reports the program's own exit. A signal goes once to each process group of the run: the
290
+ program's, and every other group its live processes are in (a terminal session's jobs), by the group's id. On a pty,
291
+ the program's exit hangs up the terminal's foreground group, as a terminal does.
292
+ - `orphans: "keep"`: when the process ends, what it started that still runs (a daemon in its own session) is not ended:
293
+ it runs on under the guard, unsignalled, until it ends or the computer does. Without it, it is ended with the process.
294
+
295
+ `src/processes.ts` has `readAll(client, id, stream, {offset?, waitMs?, signal?})`, which pages a stream by offset
296
+ until the process ends and returns its bytes, where it ended and what the ring dropped, and `listProcesses(client)`,
297
+ which pages `process.list` and returns every process.
298
+
299
+ ### Files
300
+
301
+ Every path is absolute, and the daemon cleans it; a relative path is `invalid`. Files are read and written as the
302
+ daemon's user, and data is base64. In a Docker computer that is the computer's user, non-root by default, so it writes
303
+ in `/work` (its home) and `/tmp`; the image's root-owned directories are `denied`.
304
+
305
+ | Method | Params | Result |
306
+ | --- | --- | --- |
307
+ | `files.read` | `path, offset?, length?` | `{data, eof, size}`: at most 512 KiB a call; a larger `length` is `limit` |
308
+ | `files.write` | `path, data, offset?, append?, mode?, parents?` | `{size}`: replaces the file unless `offset` or `append`; makes it if missing (through a dangling symlink too); `mode` is set when given (a new file gets 0644); `parents` makes missing directories |
309
+ | `files.stat` | `path, follow?` | `{type, size, mode, mtimeMs, uid, gid, target?}`: `type` is `file`, `dir`, `symlink` or `other`; a symlink is reported as one unless `follow` |
310
+ | `files.list` | `path, depth?, offset?` | `{entries, truncated}`: entries carry the stat fields and `path`, in walk order (by name, a directory before its contents); `depth` 1 (default) to 16; symlinks are listed, never entered; at most 1000 entries (and 768 KiB) a reply: when `truncated`, list again with `offset` plus the entries read |
311
+ | `files.mkdir` | `path, parents?, mode?` | `{}`: mode 0755 unless given; a directory already there is `exists`, or fine with `parents` |
312
+ | `files.move` | `from, to, overwrite?` | `{}`: a rename; without `overwrite` it never replaces what is at `to` (`exists`), checked in the same step as the rename (renameat2 with RENAME_NOREPLACE; a file is linked and unlinked where that is missing, a directory refused); across filesystems is `unsupported` |
313
+ | `files.remove` | `path, recursive?` | `{}`: a directory with entries is `is_dir` unless `recursive`; a symlink is removed, never followed; `/` is `denied` |
314
+
315
+ Tar archives move whole trees without holding an archive in memory, and no line passes 1 MiB:
316
+
317
+ - `tar.pull.begin {path}` returns `{id}` for the tar of a file (one entry, its name) or a directory (entries relative
318
+ to it); `tar.pull.read {id, maxBytes?}` returns `{data, eof}`, the next `maxBytes` (default and most 512 KiB) of the
319
+ archive, fewer only at its end; `tar.pull.end {id}` returns `{}`, stops the pull and frees it, and may be sent
320
+ again. The daemon writes the archive only as it is read, so a pull holds at most one read's bytes. Symlinks are
321
+ archived as links; sockets, devices and pipes are left out. A connection has at most 8 pulls open, and those still
322
+ open when it ends are ended with it.
323
+ - `tar.push.begin {path}` makes the directory if missing and returns `{id}`; `tar.push.write {id, data}` hands it the
324
+ next bytes (send each after the last one's reply), and extraction runs as they come; `tar.push.end {id}` returns
325
+ `{entries}`. Files, directories and symlinks are extracted with their modes and never chowned; a directory keeps
326
+ owner access until the archive ends, then gets its mode, deepest first, whether the push made it or found it. An
327
+ entry that is absolute, has a `..` part, or has a symlink or a file on its way is `denied`, and ends the push;
328
+ entries before it stay. A symlink at an entry's own name is replaced, never followed. A file is written beside its
329
+ target and renamed into place, so a failed or abandoned push leaves no half file. Hard links, devices and pipes are
330
+ `invalid`. A connection has at most 8 pushes open, and those still open when it ends are ended with it.
331
+
332
+ `src/files.ts` has the helpers that go past one call: `readFile(client, path)`, `writeFile(client, path, bytes)` (a
333
+ `mode` is set with the last chunk, so a read-only file over 512 KiB can be written),
334
+ `pushTar(client, dir, bytes | AsyncIterable<Uint8Array>)`, `pullTar(client, path)` (the archive's bytes) and
335
+ `pullTarStream(client, path, {signal})` (`{chunks, done}`: one `tar.pull.read` each time the loop asks for a chunk,
336
+ and how the pull ended). Every call is a request and its reply: a slow reader holds back only its own pull, so
337
+ `pushTar(client, dir, pullTarStream(client, path).chunks)` copies a tree on one connection. A push or pull that began
338
+ is always ended, whether it finished, failed, was left or was aborted. `pushTar` owns its source: unless the source is
339
+ read to its end, the push calls its `return()` however it ends, so a pull piped into a push that fails is ended too.
340
+
341
+ ### Security
342
+
343
+ - A push confines every write to its directory at the moment of the write, even while other pushes, or programs in
344
+ the computer running as another user, change the tree under it. The daemon opens the directory once and reaches
345
+ each entry from that descriptor one name at a time, never following a symlink (`openat` with `O_NOFOLLOW`, `mkdirat`,
346
+ `renameat`, `symlinkat`, `fchmod` on a descriptor). No path is checked and then used by name, so a directory swapped
347
+ for a symlink between two steps refuses the entry instead of redirecting it.
348
+ - `files.write`, `files.mkdir`, `files.move` and `files.remove` act on the absolute path the caller chose and make no
349
+ promise to confine it: they resolve it by name, as any program in the computer would, and follow a symlink on the
350
+ way. The daemon does not confine them: the container is the only boundary. A provider that runs the daemon as root
351
+ and programs as a lesser user must confine these calls first. A caller that needs a write held inside one directory
352
+ against a concurrent actor pushes a tar into that directory.
353
+ - `files.read`, `files.write` and a pull open a file first and then check what they opened (`fstat` on the
354
+ descriptor), never a path checked and then opened by name. The open carries `O_NONBLOCK`, so a FIFO or a device,
355
+ there from the start or swapped in by another program, never makes it wait: `files.read` and `files.write` refuse
356
+ it as `invalid` (a directory is `is_dir`), and a pull leaves it out. A pull opens each file with `O_NOFOLLOW` and
357
+ writes its tar header from that descriptor's `fstat`, so the header matches the bytes it reads; a file that became
358
+ a symlink is left out too.
359
+
360
+ `src/protocol.ts` and `daemon/internal/methods` are the two definitions of these methods, TypeScript and Go (the Go
361
+ params and results of `files.*` and `tar.*` sit beside their code in `daemon/internal/files`).
362
+
363
+ ## Kinds: the computer an agent is given
364
+
365
+ Two axes. The machine kind is the protocol's, `capabilities().kind` (`linux`, `desktop`, `android`, `ios`, `browser`;
366
+ below). The setting kind is what an agent is given in Settings, `computer: { kind, provider? }`: one of five, each a
367
+ set of machine kinds and capability groups (`src/kinds.ts`, `SETTING_KINDS`). The model's tools are not here: they live
368
+ in the kernel's tool registry, keyed by these groups.
369
+
370
+ | setting kind | machine kinds | required groups | optional groups |
371
+ | --- | --- | --- | --- |
372
+ | `none` | | | (the run's folder only: no computer) |
373
+ | `sandbox` | `linux` | `exec`, `files`, `processes` | |
374
+ | `desktop` | `desktop` | `screen`, `input.pointer`, `input.keys` | `exec`, `files`, `processes`, `apps`, `stream` |
375
+ | `phone` | `android`, `ios` | `screen`, `input.touch`, `apps` | `input.keys`, `apps.install`, `apps.ui_tree`, `stream` |
376
+ | `browser` | `browser` | `cdp` | `stream`, `downloads` |
377
+
378
+ - `serves(capabilities, kind)` is true when `capabilities().kind` is one of the kind's machine kinds and every required
379
+ group is declared, so a provider that drops a group stops serving the kind; `servingRefusals` says why not in words,
380
+ and `kindOf` names the setting kind capabilities serve (machine kinds are apart, so at most one).
381
+ - `PROVIDERS` is what Settings offers: each entry's `id`, `label`, `keys` (the serve-side names Settings accepts, each
382
+ required or not; never a value), `mounts` (the mount kinds its computers take; `[]` cannot mount the run's folder),
383
+ `metered` (the vendor bills by time), and `capabilities`, the machine kind and groups of each configuration it
384
+ offers. Its `kinds` are derived from those by `serves`, never written by hand.
385
+ - An entry's `defaultImage` names the image a computer of each setting kind starts from when its setting names none,
386
+ each the constant its provider module owns. A kind with no entry has no default, and the caller refuses the setting in
387
+ words. Docker has none: serve builds its image itself.
388
+
389
+ | id | defaultImage |
390
+ | --- | --- |
391
+ | docker | none |
392
+ | daytona | sandbox: `DAYTONA_DEFAULT_SNAPSHOT` ("default") |
393
+ | modal | sandbox: `MODAL_DEFAULT_IMAGE` ("debian:bookworm-slim") |
394
+ | e2b | sandbox: `E2B_BASE_TEMPLATE` ("base"); desktop: `E2B_DESKTOP_TEMPLATE` ("desktop") |
395
+ | orgo | desktop: `ORGO_BASE_IMAGE` ("linux") |
396
+ | phone-harness | phone: `PHONE_IMAGE` ("android") |
397
+ | browserbase, kernel | browser: `BROWSER_IMAGE` ("chromium") |
398
+
399
+ | id | label | kinds | keys (required unless marked) | mounts | metered |
400
+ | --- | --- | --- | --- | --- | --- |
401
+ | docker | Docker | sandbox, desktop | none | bind | no |
402
+ | daytona | Daytona | sandbox | `DAYTONA_API_KEY`; `DAYTONA_API_URL`, `DAYTONA_TARGET` (optional) | archil | yes |
403
+ | modal | Modal | sandbox | `MODAL_TOKEN_ID`, `MODAL_TOKEN_SECRET` | archil | yes |
404
+ | e2b | E2B | sandbox, desktop | `E2B_API_KEY` | archil | yes |
405
+ | orgo | Orgo | desktop | `ORGO_API_KEY` | none | yes |
406
+ | phone-harness | Phone harness | phone | `PHONE_HARNESS_API_KEY` | none | yes |
407
+ | browserbase | Browserbase | browser | `BROWSERBASE_API_KEY`, `BROWSERBASE_PROJECT_ID` | none | yes |
408
+ | kernel | Kernel | browser | `KERNEL_API_KEY` | none | yes |
409
+
410
+ - Each provider module exports `CAPABILITIES` beside `MOUNT` (the registry's contract, `ProviderModule`). A unit test
411
+ holds every registry provider's `CAPABILITIES` and `MOUNT` to its entry, and each provider built from the test fakes,
412
+ in each configuration, to its entry's capabilities. browserbase and kernel are data until their provider file joins
413
+ the registry; that test then holds each to its file.
414
+ - `testConnection()` (optional on `ComputerProvider`) is Settings' test of a provider's keys: ONE account-level read
415
+ that never creates a computer, so it never spends. Docker (one `docker ps`), Daytona and E2B (one listing page) count
416
+ the provider's own computers by its label from that one answer, never reading each back, so a busy account answers as
417
+ fast and one computer's read never fails a working key; a further page reads "or more". Orgo reads its workspace's
418
+ computers; Modal reads its app without making it (an app not made yet is still a connection). It answers `{ detail }` in words, or an
419
+ error: `unauthorized` for a key the vendor refused, `unreachable` for a vendor not reached in time, else the read's
420
+ own code; no message carries a key. A full live check (create, then the kind's conformance) is the QA board's.
421
+ `TestConnection` is the serve side's signature, `(providerId, { keys, signal })`, keys by their serve-side names.
422
+ - A browser computer's connection carries `cdp: { url }`, its CDP target: a secret, never logged and never in a
423
+ result, a report or an error.
424
+ - A provider passes a setting kind's conformance with `--kind` (see [Conformance](#conformance)).
425
+
426
+ ## The protocol extension: kind, daemon modes, screen, input, apps, lifetime
427
+
428
+ The types and the conformance cases for computers past a Linux shell: desktops, Android and iOS phones. This package
429
+ has the types, the cases, the daemon's screen and input on X11 ([The X11 shim](#the-x11-shim)), the desktop fixture and
430
+ a Docker desktop; a phone provider comes in a later change. Docker declares `linux` with computerd as PID 1 unless it is
431
+ made a desktop, so on a plain Docker computer every new case skips in words.
432
+
433
+ **Kind.** `capabilities().kind` is `"linux" | "desktop" | "android" | "ios" | "browser"`, and hello repeats it. `os` stays: it names
434
+ the platform the key table and exec need; kind names the shape the tools need. Only these pairs are valid
435
+ (`kindRefusals(capabilities)` names any other in words, and the case `health.kind-consistent` fails it):
436
+
437
+ | kind | os | daemon | Core groups, besides health, provider and drift |
438
+ | --- | --- | --- | --- |
439
+ | `linux` | linux | `pid1` or `child` | `exec`, `files`, `processes`; network `none` |
440
+ | `desktop` | linux (windows, macos later) | `pid1`, `child` or `none` | linux's, when daemon is not `none`; and `screen`, `input.pointer`, `input.keys` |
441
+ | `android` | android | `none` | `screen`, `input.touch`; exec and files only when declared |
442
+ | `ios` | ios | `none` | `screen`, `input.touch` |
443
+ | `browser` | linux | `none` | `cdp`: its connection's CDP target (see [Browsers](#browsers-browserbase-and-kernel)) |
444
+
445
+ The groups `cdp`, `stream` and `downloads` are the provider's (`PROVIDER_GROUPS`): a browser's CDP target, a live view of
446
+ the screen (`provider.stream()`), the files a browser saved. A computerd hello never lists them.
447
+
448
+ **Daemon mode.** `capabilities().daemon` says who answers the methods. `pid1`: computerd init is the computer's main
449
+ process, so its exit ends the computer (Docker). `child`: the vendor's own agent is the main process and starts init at
450
+ boot; init's exit does not end the computer (Daytona, whose toolbox daemon runs init as a session command), and it
451
+ must not run under a supervisor that restarts it. `none`: no computerd runs, and the provider answers the same methods
452
+ itself, from our server (adb, a vendor API). Either way a connection's `client` is a `ComputerClient` (`call(method,
453
+ params, { signal })` and `close()`): `DaemonClient` over a stream, or a provider's in-process client.
454
+
455
+ **Groups.** `capabilities().groups` is one flat list, repeated in hello's `groups`: `exec`, `files`, `processes`,
456
+ `screen`, `input.pointer`, `input.keys`, `input.touch`, `apps`, `apps.install`, `apps.ui_tree`, and the provider's
457
+ `cdp`, `stream`, `downloads`. Each is optional unless kind makes it Core. The drift check and Docker's `connect` refuse a hello whose kind or groups differ from what the
458
+ provider declares, either way.
459
+
460
+ | group | methods |
461
+ | --- | --- |
462
+ | `screen` | `screen.shot({ region? })`: a PNG (8-bit, non-interlaced), its first `MAX_CHUNK_BYTES` in `data`, with `width`, `height` (the image's pixels, the input coordinate space, never downscaled), `scale` and `cursor?`; `screen.read({ id, offset })` for the rest. One shot is held, until its eof or the next shot. `screen.watch({ after, waitMs?, maxWidth?, quality? })`: the live view's frames, paced by the caller's ack (`after`, the seq of the last frame it has whole; an older one gets the newest frame at once): the next frame once the screen or the pointer changed, else `changed: false` when `waitMs` (default 2000, at most 10000) is over. A frame is `{ seq, changed, format, frameWidth, frameHeight, width, height, cursor? }` and its bytes as a shot's (`data`, `id` and `screen.read`); `format` is `jpeg` from computerd (scaled to `maxWidth`, default 1280, at `quality`, default 60) and `png` from the phone client. One watch per connection. |
463
+ | `input.pointer` | `input.actions`: `move`, `down`, `up`, `click` (`count` 1-3, held `keys`), `drag` (a path of 2 or more points), `scroll` (`unit` clicks or px) |
464
+ | `input.keys` | `input.actions`: `key` (one key pressed, or a combo released in reverse; `repeat`), `hold` (`ms`), `type` |
465
+ | `input.touch` | `input.actions`: `tap`, `long_press`, `swipe`, `pinch` (`scale` above 1 apart, below together), `button` (back, home, app_switch) |
466
+ | `apps`, `apps.install` | `apps.list` (`{ apps, foreground }`), `apps.launch`, `apps.terminate`; `apps.install({ path })` of a file already in the computer |
467
+ | `apps.ui_tree` | `apps.ui_tree`: `{ root: UiNode, nodes, truncated }`, at most 5000 nodes; a node has `role`, `id?`, `text?`, `label?`, `bounds` in screenshot pixels, `enabled`, the optional booleans and `children` |
468
+
469
+ **The live view's seam** (`src/screen-watch.ts`). The runner's viewer reads a computer through
470
+ `provider.watch?(ref, handlers, { signal?, maxWidth?, quality? })`:
471
+ - `handlers.frame(frame, ack)` gets each whole `ScreenFrame` (`{ seq, format, bytes, width, height, frameWidth,
472
+ frameHeight, cursor? }`), and the next frame is asked for only once `ack()` is called. `width` and `height` are the
473
+ screen's real pixels, the input space; only `frameWidth` and `frameHeight` scale to `maxWidth`.
474
+ - `handlers.ended(error)` is called once if the computer goes, with the code `gone`, `unreachable`, `refused` or
475
+ `unsupported`, in words with no URL. `close()` and the signal end the watch with no `ended()`.
476
+ - The answer's `input(actions)` sends `input.actions` on the watch's own connection, and `close()` lets that
477
+ connection go. After the end, `input()` refuses in words.
478
+
479
+ `daemonWatch` is the one implementation behind every provider's `watch()` (Docker, Daytona, Modal, E2B, Orgo, the
480
+ phone harness): a computer whose hello has no `screen` is refused as `unsupported`. It adapts the internal seam,
481
+ `watchScreen(connection, options)`: pull-paced `frames` (each `next()` the ack), `act(actions)` and `close()`, whose
482
+ failures are `ScreenWatchError`s. `toAction(event, kind)` maps the viewer's `ViewerEvent`s, in the screen's upright
483
+ pixels, to input actions, or to a `Refusal` (`{ field, message }`) for what a kind cannot take:
484
+ - a desktop takes the mouse (a move, and a button down or up at a point; with a modifier held, the up is one click
485
+ with its keys and the down only moves; each up is one click, so a double-click is two and never a `count`), the
486
+ wheel (in clicks, about 120 px a notch, 20 clicks at most an event),
487
+ keys (combos with the modifiers held, Shift kept: ctrl+shift+s) and typed text; never ctrl+alt+backspace or
488
+ ctrl+alt+F1 to F12, which end or switch the X display;
489
+ - a phone (`android`, `ios`) takes taps, swipes (0 to 1000 ms, clamped), back, home and recents (`app_switch`), keys
490
+ and typed text;
491
+ - a typed text holds 65,536 characters at most (`checkActions` refuses more as `limit` too, as computerd does);
492
+ - anything else, and an event whose fields are not what its type says, is refused in words: `toAction` never throws.
493
+
494
+ `toAction` is stateless. A viewer maps through `createActionMapper(kind)`, one per take-over: its `map(event)` answers
495
+ as `toAction` does, but a desktop's mouse press decides the strategy for the press and its release together (a
496
+ modifier let go before the up still clicks once, with the keys held at the down; a plain press stays plain), and its
497
+ `release()` gives the ups for every button it pressed and has not released, then forgets them (on blur, or when the
498
+ take-over ends). No key is ever among them: the protocol presses and releases a key within its action.
499
+
500
+ The seam reads a frame by the size it says (never past it, never over 64 MiB, and whole at the end), keeps 8 inputs
501
+ in flight at most on a watch (one more is refused as `limit`), and redacts every error and a failed action's words
502
+ (`redactWords`: URLs, logins, bearers, secret-named parameters, key and token shapes, and host or IPv4 endpoints).
503
+
504
+ No error in this seam holds a URL or a secret (`redactWords`). A phone's frames are upright with no rotation of ours:
505
+ screencap gives the display in its current orientation, and `input tap` takes the same space.
506
+
507
+ Points are `[x, y]` in the full screenshot's pixels, origin top left; a region shot never changes that space. A key is a
508
+ name in `KEYS` (enter, tab, space, backspace, delete, escape, insert, the arrows, home, end, pageup, pagedown, f1-f12,
509
+ shift, ctrl, alt, super, capslock) or one printable ASCII character (0x21-0x7e); the daemon's Go table
510
+ (`daemon/internal/keys`) mirrors it, and a Go test keeps the two equal.
511
+ Model vocabularies (Anthropic's `Return` or `ctrl+s`, OpenAI's keypress) are mapped to these by a tool adapter on the
512
+ server, once per model family, never per vendor.
513
+
514
+ `input.actions` rules: the whole batch is checked first (its shape, at most `MAX_ACTIONS` = 100 actions, every key
515
+ against `KEYS`, each action's group against what is declared, a px scroll where only clicks exist, and wait plus hold at
516
+ most `MAX_BATCH_WAIT_MS` = 300 s); a failure returns `{ done: 0, failed: { index, kind, message } }` and nothing runs.
517
+ `checkActions(actions, groups, { pixelScroll? })` is that check, for an implementer, an early caller, or an in-process
518
+ client. Then the actions run in order and stop at the first failure (a point off the display, a display gone) with
519
+ `done` = its index, and every button and key the batch pressed and did not release is released. A success keeps state:
520
+ a `down` with no `up` stays down into the next batch. A cancel stops before the next action and releases as a failure
521
+ does.
522
+
523
+ **Lifetime.** `capabilities().maxLifetimeMs` is the vendor's hard cap for the provider instance (Docker: 30 days).
524
+ `checkLifetime(lifetimeMs, capabilities)` is the one rule every `check()` shares: a whole number of milliseconds above
525
+ 0, at most the cap, refused in words with no vendor call. A provider may offer `extend(ref, ttlMs)`, which sets the
526
+ deadline to now + ttlMs (never earlier than the current deadline, never past create + maxLifetimeMs: either is refused
527
+ in words with the deadline unchanged, so an extend never shortens a computer's life) by moving the vendor's timer, the
528
+ deadline label and init's own deadline (`deadline.extend`, up to the `--max-deadline` the provider gave init at start),
529
+ and `stream(ref)`, the vendor's live screen URL. Docker
530
+ has neither: its deadline is a container label, which cannot change after create, so ask for the whole lifetime at
531
+ create. The janitor counts a deadline more than maxLifetimeMs (and a minute of clock skew) past now as unreadable, and
532
+ deletes it.
533
+
534
+ Brains never run inside the computer: a computer only takes tool calls. There is no duplex group and no "brain and
535
+ hands" placement.
536
+
537
+ ### The X11 shim
538
+
539
+ computerd drives the X display named by `DISPLAY` when init started, in pure Go (`daemon/internal/x11`, written against
540
+ the X protocol with no cgo and no dependency, so the daemon stays one static binary): pixels from `GetImage` on the
541
+ root window, input from the XTEST extension's `FakeInput`, with no program started for any action. The image needs
542
+ only an X server. Only a display in this computer is driven: the unix socket, or TCP to a loopback address; any other
543
+ `DISPLAY` is refused before anything is sent to it, so this host's cookie never goes elsewhere. Neither the X server
544
+ nor the Xauthority file is trusted (any program of the computer's user can replace either): the cookie is read from
545
+ `$XAUTHORITY` or `~/.Xauthority` only when that is a regular file of at most 64 KiB, and a symbolic link, a FIFO or a
546
+ device there is refused in words without being read; a setup with a scanline pad other than 8, 16 or 32, or keycodes
547
+ that are not a range from 8 up, is refused; and each reply is bounded by what its request can get back (a `GetImage`
548
+ by its rectangle), so a longer one ends the connection before anything is allocated for it. A `screen.shot` or
549
+ `input.actions` waiting for another to finish with the display waits no longer than its own request, then answers
550
+ `aborted`.
551
+
552
+ - The display is reached when it is first asked for, and again after it goes: hello declares `screen`,
553
+ `input.pointer` and `input.keys`, and kind `desktop`, only while the display answers with XTEST. So a provider may
554
+ start its X server through `process.start` after init is up. With no display (`DISPLAY` unset, nothing answering, no
555
+ XTEST) nothing is declared, and each method is `unsupported`, saying why.
556
+ - Programs get no `DISPLAY` from the daemon (exec and process environments stay minimal): one that should show on the
557
+ display is given it in `env`.
558
+ - `screen.shot` is a PNG of the root window or a region inside it (one outside is `invalid`), with `scale` 1 and
559
+ `cursor` from `QueryPointer`. A connection holds one shot, until it is read to its end or the next shot; a
560
+ `screen.read` of another id is `not_found`.
561
+ - `input.actions` checks the whole batch first, as `checkActions` does, and on X11 also refuses: a touch action
562
+ (`unsupported`: X11 has no touch), a pixel scroll (`unsupported`: the wheel turns in clicks), a point or click count
563
+ that is not whole (`invalid`), an unknown field, and text with a character no key types (a control character other
564
+ than newline and tab, `invalid`). Its own bounds are `limit`: 64 Ki characters a `type`, 10,000 clicks a scroll,
565
+ 1000 points a drag, 16 keys at once; and `repeat` is at most 100 (`MAX_KEY_REPEAT`), checked after the action's
566
+ group as `checkActions` does. Then the batch runs; a point off the display stops it there
567
+ (`invalid`, naming the display's size), and an X error from the server stops it at the action that sent it: the
568
+ batch waits for the server (one round trip) after each action with a button, a key or a keyboard map change, so no
569
+ later action runs, and `done` and `failed` say what did. A cancel stops it at the next key, click or point, releases
570
+ what the batch held, and answers `aborted`.
571
+ - Scroll: `dy` above 0 turns down, below 0 up, `dx` right and left, one wheel click each, vertical first. A key or
572
+ character that needs shift gets it, pressed before and released after. `type` gives exactly its text whatever
573
+ Caps Lock is: when it is on, it is turned off for the typing and back on after, as xdotool does. A `key` action
574
+ presses keys as a keyboard does, so Caps Lock applies to it.
575
+ - Typing a character the keyboard map has no key for (é on a US map, any CJK character, an emoji) uses the keysym remap
576
+ xdotool does: the character is bound to a keycode with no keysym (`ChangeKeyboardMapping`), then typed with it.
577
+ Unlike xdotool the binding is not undone, which would race a client still reading the map; it stays, so the
578
+ character has a key from then on. When no keycode is free, the binding used longest ago is moved once it has
579
+ settled (250 ms after its last key, so clients have read the events bound to it). A `type` needing more keycodes at
580
+ once than the map can give is refused as `limit`, before any key, saying to type it in parts.
581
+
582
+ ## Settings
583
+
584
+ The library takes options only. Every provider is built by its file's `create(options)` (or its class), and every
585
+ setting, a vendor key included, is an option: no provider reads an environment variable for a setting, and no provider
586
+ file names one. A key is never logged or echoed in an error. Whoever builds a provider owns the names its settings
587
+ live under:
588
+
589
+ - **serve**, at the cutover, reads its own existing names and passes them in, so an owner's settings keep working:
590
+
591
+ | serve's name | becomes |
592
+ | --- | --- |
593
+ | `DAYTONA_API_KEY` | Daytona's `apiKey` |
594
+ | `DAYTONA_API_URL` | Daytona's `apiUrl` (unset: Daytona's own, `https://app.daytona.io/api`) |
595
+ | `DAYTONA_TARGET` | Daytona's `target` |
596
+ | `MODAL_TOKEN_ID`, `MODAL_TOKEN_SECRET` | Modal's `tokenId`, `tokenSecret` |
597
+ | `AGENTRUN_BOX_APP` | Modal's `app` (serve's default, `agentrun`, when unset) |
598
+ | `AGENTRUN_DOCKER_IMAGE` | Docker's `image` option, `{ image: <name> }` (unset: the provider's own recipe); `docker.image()` makes it ready and gives the tag a computer's spec names |
599
+ | `E2B_API_KEY` | E2B's `apiKey`: serve's new name for the E2B box |
600
+ | `BROWSERBASE_API_KEY`, `BROWSERBASE_PROJECT_ID` | Browserbase's `apiKey`, `projectId`: the names pi-browser reads today |
601
+ | `KERNEL_API_KEY` | Kernel's `apiKey`: the name pi-browser reads today |
602
+
603
+ - **the conformance CLI and the live harness** (`src/conformance/`: the CLI, each provider's conformance module and the
604
+ sweeps) read their own `COMPUTER_<ID>_*` names, the ones the live scripts set, through each module's
605
+ `settingsFromEnv(env)`, and pass them in. Each provider's section lists its names. They never read serve's names or a
606
+ vendor's bare variable, which on a shared host may hold another account's key.
607
+
608
+ A default never comes from the environment either: Docker's `daemonCache` defaults to `~/.cache/agentrun-computer`
609
+ whatever `XDG_CACHE_HOME` says, and a caller that keeps its cache elsewhere passes `daemonCache`.
610
+
611
+ Two lines of the library touch the environment, each a guard against a vendor SDK that reads it on its own, not a
612
+ setting:
613
+
614
+ - **Modal, `MODAL_SERVER_URL`** (`modalClient` in `src/modal.ts`). The SDK takes its server from `MODAL_SERVER_URL` and
615
+ has no option for it, so the provider refuses to start while it is set, and sets it to `options.serverUrl` only
616
+ while it constructs the client, putting back what was there after. `process.env` is the whole process's, so
617
+ constructions run one at a time: none sees another's server.
618
+ - **E2B, `E2B_SANDBOX_URL`** (`ambientProblem` in `src/e2b.ts`). The SDK sends every sandbox call to it when it is set,
619
+ and no option clears it, so the provider refuses to start while it is set. It only reads.
620
+
621
+ `scripts/check-env.mjs` holds the library to this: it reads every file under `src/` outside `src/conformance/`, those
622
+ in its directories (`src/docker/`) included, with TypeScript's parser and fails on any use of `process.env` (dotted,
623
+ bracketed, destructured, aliased, through `globalThis` or an import of `node:process`) but these two, each by its
624
+ variable, its file and its function. `test/providers.test.mjs` runs it, checks the files it read, and runs it on
625
+ fixtures of every evasion it catches.
626
+
627
+ ## Docker
628
+
629
+ ```ts
630
+ import { DockerProvider } from "@parcha/agentrun-computer";
631
+
632
+ const docker = new DockerProvider({ daemonPath: "dist/computerd-linux-amd64" });
633
+ const made = await docker.create({ image: "debian:bookworm-slim", lifetimeMs: 600_000, network: "none" });
634
+ if (!made.ok) throw new Error(made.error.message);
635
+ const connected = await docker.connect(made.value);
636
+ if (connected.ok) {
637
+ const ran = await connected.value.client.call("exec.run", { argv: ["uname", "-m"], timeoutMs: 5000 });
638
+ await connected.value.close();
639
+ }
640
+ await docker.release(made.value, "delete");
641
+ ```
642
+
643
+ - `capabilities()` declares kind `linux`, daemon `pid1`, groups `exec`, `files` and `processes`, `maxLifetimeMs`
644
+ of 30 days, and `mount: ["bind"]` (below); there is no `extend()` or `stream()`, and init gets no `--max-deadline`.
645
+ - `new DockerProvider({ daemonPath, desktop: {} })` makes desktops: kind `desktop`, with `screen`, `input.pointer` and
646
+ `input.keys` too, on an image with an X server (`test/fixtures/desktop/Dockerfile` is Alpine and Xvfb, 48 MB).
647
+ `create` gives the daemon `DISPLAY` (`display`, default `:0`), then starts the X server through it with
648
+ `process.start` (`server`, default `Xvfb :0 -screen 0 1280x800x24 -nolisten tcp`), as the computer's user and as any
649
+ program: computerd stays PID 1 and starts nothing itself, and the server is one process in its table that ends with
650
+ the computer. `create` waits (`timeoutMs`, default 30 s) until hello declares the display, then runs the drift check;
651
+ a server that ends first, with its last words on stderr, or a display that is not up in time deletes the computer in
652
+ words.
653
+ - `check(spec)` refuses in words, with no Docker call: no image, no or a bad `lifetimeMs` (`checkLifetime`: at most
654
+ 30 days), a network that is not `none`, `open` or an allowlist the egress proxy takes
655
+ ([below](#an-allowlist-the-egress-proxy)), a NUL byte in any string, and any field Docker does not support. Once the host has been read (below), it also refuses with `field: "host"` for each enforcement
656
+ the host lacks. `create` never throws on a spec `check` passes.
657
+ - Before `docker run`, `create` reads the host's enforcement once per provider (`host()`, from `docker info`; see
658
+ below), and refuses a host that lacks any of it in words, having made nothing.
659
+ - `create` runs `docker run` as a non-root user (`--user`, below), with every capability dropped (`--cap-drop ALL`),
660
+ `--security-opt no-new-privileges`, `--ipc private --cgroupns private` (never the daemon's defaults, which a host can
661
+ set to `shareable` or, on cgroup v1, the host's cgroup namespace), `--network bridge` for `open` and `--network none`
662
+ for `none` and an allowlist, serve's sizes unless the spec gives its own (2
663
+ CPUs as a quota, `--cpu-period 100000 --cpu-quota 200000`, so a host with fewer CPUs still runs one; 4 GiB with swap
664
+ the same; 1024 pids), and the daemon (its copy, next) bind-mounted read-only at `/opt/agentrun/computerd` as
665
+ the entrypoint, `computerd init --deadline <time>`, which is PID 1, holds every process and reaps orphans. The label
666
+ `agentrun.computer.deadline` holds the time `lifetimeMs` ends, and init gets the same time: then it ends every
667
+ process as on SIGTERM (below) and exits 0, which stops the container. Init refuses to start with no deadline.
668
+ Deleting a stopped computer is the janitor's (`lifetime: "janitor"`). A container that is not running after its
669
+ start is removed. The lifetime counts from just before the proxy (for an allowlist) and `docker run`, so a Docker host
670
+ that holds the start eats into it: a computer whose init exited 0 because its deadline passed before `docker run`
671
+ finished fails `create` as `timeout`, with the lifetime and how long the start took ("its lifetime of 45 s ended
672
+ before docker run finished (it took 101.2 s)").
673
+ - **A computer binds the provider's own copy of the daemon, never `daemonPath`.** `daemonPath` may have any mode this
674
+ process can read (npm installs it 0700 under `umask 077`). `create` copies it to `computerd-<sha256 of its bytes>`,
675
+ mode 0755, in `daemonCache` (default `~/.cache/agentrun-computer`; `XDG_CACHE_HOME` is not read), so every computer
676
+ user may run it, and binds that copy. The copy is written to a temporary file and renamed into place, then hashed
677
+ again before each bind. The directory is made 0700 if missing and is never changed: a link, another user's
678
+ directory, a mode other than 0700, or a directory above it another user may write is refused in words. The drift
679
+ check and `attach` compare the copy's path, which the same daemon bytes give in every process.
680
+ - **A computer runs as a non-root user by default; root must be asked for in the spec.** `user` is a uid or uid:gid
681
+ in numbers (a name is refused: the image may not have it; a uid alone is its own gid). The spec's `user` wins, then
682
+ the provider's `user` option, then this process's uid:gid, or `1000:1000` when this process's uid or gid is 0. The
683
+ provider option refuses root and root's group (`"1000:0"` throws); only a spec's `user: "0"` runs a computer as
684
+ root, and only a spec's gid 0 (such as `"1000:0"`) puts it in root's group. That root has no capability either.
685
+ - `/run/agentrun`, init's socket directory, is a tmpfs owned by the computer's user, mode 700, with `noexec`, `nosuid`
686
+ and `nodev`, and `size=1m`: it holds only the socket.
687
+ - `/work` is the computer's home (`HOME=/work`) and its workdir unless the spec names one: a tmpfs owned by the
688
+ computer's user, mode 700, the one place a non-root user can surely write. It is memory: what it holds counts against
689
+ the memory limit, and it does not survive a stop. So it holds at most half of `memoryMb` (`size=2048m` by default): a
690
+ full `/work` fails a write with "No space left on device" instead of letting the memory limit OOM-kill a process,
691
+ PID 1 included. What lasts is the run's folder, bound at `/workspace` when the spec asks (below).
692
+ - `create` ends with the drift check (below): a computer that is not what was declared is deleted, and `create`
693
+ refuses with every mismatch in words.
694
+ - `create(spec, { signal })` passes the signal to every step: `docker info` before `docker run` (an abort there makes
695
+ nothing), `docker run`, and after it inspect and hello (hello also has its own 30 s limit). An abort at any step after `docker run` deletes the computer and returns
696
+ `aborted`; `create` never returns ok once its signal has aborted.
697
+ - `connect` runs `docker exec -i <name> /opt/agentrun/computerd stdio`, the bridge to init's socket, and says hello.
698
+ Each `connect` is a connection of its own; processes are shared by all of them. A daemon whose version is not the
699
+ provider's, or that lacks a capability the provider declares, is refused (`refused`) and the stream closed.
700
+ - `attach({ id })` finds a computer by its name (`computer-<12 hex digits>`) or its container id (12 to 64 hex digits);
701
+ `attach({ labels })` by labels, which must match exactly one computer: none is `not_found`, more is `invalid`
702
+ ("2 computers match ..."). Then `attach` runs the drift check on what it found: the spec is read back from the
703
+ computer's own report (image, network, sizes, user, workdir, deadline) and held to what `check` allows (and the
704
+ deadline to the ISO time create writes, at most 30 days away), then the whole inspect is checked as at create, and,
705
+ when the computer runs, its daemon's hello. A computer that drifts is refused (`refused`) with every mismatch, and
706
+ left as it is: attach did not make it, so it does not delete it. A stopped computer is checked by inspect alone. A
707
+ computer that passes is returned as its ref with `spec`, the spec read back (`{ image, user, network, cpus,
708
+ memoryMb, pids, workdir, deadline, mount? }`), so a caller sees what it attached to: `user` is `uid:gid` (`"0:0"` for a
709
+ computer whose spec asked for root), `network` the policy read back, and `mount` the run's folder bound at
710
+ `/workspace`, when one is. `list` keeps its own shape (`ComputerInfo`).
711
+ - `list(labels)` runs `docker ps -a --filter label=agentrun.computer=1 --filter label=k=v ...`, then inspects the
712
+ matches 50 at a time, reading only the fields it reports, so any number of computers is listed (a computer gone
713
+ between the two is left out). It returns each computer's `ref`, `labels`, `deadline` (a `Date`, or `undefined` when the label is missing or is not
714
+ the ISO time the provider writes), `state` (`running` or `stopped`), `network` as read back, and `mount` when
715
+ something is mounted at `/workspace`.
716
+ - `network(ref)` reads the network back: `none` (network mode none, on no network but Docker's own `none`), `open`
717
+ (the default bridge alone), `{ allow: [...] }` (below), or `{ other: "<words>" }` for anything else, which is never
718
+ reported as a policy. `network(ref, policy)` returns the policy when it is the computer's (an allowlist with the same
719
+ entries, normalized, in any order); any change is refused: a Docker computer's network is fixed at create, since
720
+ Docker cannot move a container with no network onto one, and an allowlist needs its volume mounted at create.
721
+ - `release(ref, "stop" | "delete")` runs `docker stop`, or `docker rm --force --volumes`, then stops or removes the
722
+ computer's egress proxy and, on delete, its volume, each found by its label (below); `capabilities().release`
723
+ declares both, and `stopDeletes` is false: a stopped container is kept until it is deleted. A computer already gone is
724
+ ok.
725
+ - Only containers with the label `agentrun.computer=1` and a computer's name count for `attach`, `list` and `network`;
726
+ any other container is `not_found`.
727
+
728
+ Expected failures are results (`{ ok: false, error: { code, message } }`), not throws.
729
+
730
+ What a Docker computer cannot do: run as root or in root's group unless its spec asks, switch users, gain a capability, reach any network
731
+ when asked for `none`, reach anything but its list, through its own proxy, when asked for an allowlist, write the
732
+ daemon, or run past its deadline.
733
+
734
+ ### An allowlist: the egress proxy
735
+
736
+ ```ts
737
+ const made = await docker.create({ image: "debian:bookworm-slim", lifetimeMs: 600_000, network: { allow: ["pypi.org", "*.pythonhosted.org", "93.184.215.0/24"] } });
738
+ // In the computer, HTTP_PROXY and HTTPS_PROXY name port 3128 on its own loopback for every program computerd starts.
739
+ ```
740
+
741
+ A computer whose network is an allowlist stays `--network none`: its own loopback, no route, no resolver. Its one way
742
+ out is its own egress proxy, in a second container the provider makes, reads back and removes with it. The proxy is
743
+ serve's (`src/docker/egress-proxy.ts`, with its address table in `src/docker/egress-table.ts`), moved here; it holds no
744
+ key.
745
+
746
+ - **The volume** `computer-<hex>-egress`: a tmpfs of 1 MiB, mode 0700, owned by the computer's uid:gid. The proxy
747
+ makes its Unix socket there (0600); the computer mounts it read-only at `/opt/agentrun/egress` (`EGRESS_MOUNT`).
748
+ - **The proxy container** `computer-<hex>-egress`: `node` in `EGRESS_IMAGE` (node:22.23.4-bookworm-slim, pinned by
749
+ digest; `new DockerProvider({ daemonPath, egress: { image } })` replaces it) runs `dist/docker/egress-main.js`, this
750
+ package's own build, bound read-only with its `package.json`. It is on Docker's default bridge alone, publishes no
751
+ port, and runs as the computer's uid:gid with a read-only root, `--cap-drop ALL`, `no-new-privileges`, 256 MiB, 64
752
+ pids, half a CPU (a fixed quota, not the computer's own cpus), 1024 open files and a bounded log. Its argv holds the list, the computer's deadline (it ends itself then), this machine's own
753
+ public addresses (refused as `this-host`), and `egress.hint`, the words a refusal adds (printable ASCII).
754
+ `EGRESS_IMAGE` is the one place its digest is written. `create` pulls it at the first allow computer when the host
755
+ lacks it (see Lifetime), so a host with no registry access pulls it ahead, reading the name from this package:
756
+ `docker pull "$(node --input-type=module -e 'import { EGRESS_IMAGE } from "@parcha/agentrun-computer"; console.log(EGRESS_IMAGE)')"`
757
+ (in this repository, from `packages/computer` after a build: `node -e 'import("./dist/index.js").then((m) => console.log(m.EGRESS_IMAGE))'`).
758
+ - **The computer**: init gets `--egress /opt/agentrun/egress/egress.sock`, listens on port 3128 of its own loopback,
759
+ carries each connection to the socket, and gives every program it starts `HTTP_PROXY` and `HTTPS_PROXY` (and their
760
+ lowercase forms) naming that port, with `NO_PROXY` naming the loopback itself. A program that ignores them reaches
761
+ nothing; one that dials the socket itself meets the same proxy. Init refuses to start when it cannot listen.
762
+ - **What a list holds** (`capabilities().allow`): names, exact or `*.suffix` (two labels or more), and CIDRs, IPv4 or
763
+ IPv6, with host bits zero and over no range the address rule refuses; both in one list, at most 256 of each, each on
764
+ ports 80 and 443. `check` refuses anything else in words: an empty list (ask for `none`), an address with no prefix, a
765
+ port, a URL, a private range. On a Docker host that remaps user ids (userns-remap or rootless Docker), an allowlist
766
+ is refused before anything is made, as a bind is: the volume's owner and the proxy's code are host ids the computer's
767
+ user does not map to, and the provider does not guess the mapping.
768
+ - **The Docker host's own addresses.** The proxy refuses them as `this-host`, so it must know them. Docker does not
769
+ report them; the provider passes this machine's public interface addresses, which are the Docker host's only when
770
+ the provider runs on it. When it runs in a container (`/.dockerenv`, `/run/.containerenv`, or a container's cgroup in
771
+ `/proc/self/cgroup`), or its docker CLI talks to a daemon that is not a local unix socket (`docker context inspect`,
772
+ which resolves the context and `DOCKER_HOST` as the CLI does), an allowlist is refused in words before anything is
773
+ made, and `check` says so once it knows, unless `egress.hostAddresses` names the host's addresses (IP addresses),
774
+ which then go to the proxy beside this machine's own. A plain local host is as before. `egress.hostRoot` (default
775
+ `/`) is the root those container signs are read under, for tests and embedders. An address that is not on any
776
+ interface is never seen: a cloud machine's NAT'd or elastic public IP. Put those in `egress.hostAddresses` too. The
777
+ read-back holds every proxy to the addresses as they are now, so a host that gains an address after create reads its
778
+ older proxies back as `other` (fail closed).
779
+ - **What the proxy refuses**, each before any socket opens: a name off the list, before any lookup, so it never
780
+ leaves the host; an IP literal outside a listed CIDR of its own family; any port but 80 and 443; a listed name or
781
+ address that is private, loopback, link-local, metadata, multicast or reserved, in any form it is written (decimal,
782
+ octal, hex, IPv4-mapped, NAT64, 6to4), or one of this machine's own; a Host header that names another host than the
783
+ URI; SOCKS5 BIND and UDP ASSOCIATE; an HTTP upgrade; past 64 connections open at once or 20,000 in all. A name is
784
+ resolved once, every answer is checked, and the checked address is the one dialled, so rebinding a name between the
785
+ check and the dial reaches nothing new; a redirect reaches the client as sent and is never followed. A log line holds
786
+ the host, port, address and class, never a path, query or header. A refusal reads `403 <host> is not on this box's
787
+ network list: <hint>`, the words serve's model sees today. The proxy does not open TLS, so a CONNECT to a listed CDN
788
+ name can carry an SNI for any other tenant of that CDN (domain fronting); listing a CDN's shared name lists every site
789
+ behind it. That is inherent to a CONNECT proxy, and the same as serve.
790
+ - **Lifetime.** `create` first makes sure the computer's image and the proxy's are on the host (`docker image inspect`,
791
+ then `docker pull` for one that is not; a failed pull fails create in words, with nothing made). It then makes the
792
+ volume, starts the proxy and waits for its ready line (`egress.readyMs`, 10 s), then runs the computer; both runs
793
+ take `--pull never`, so no pull happens between the volume and the computer. A proxy that ends first, or is not ready in time, fails create in its own words; the proxy and the
794
+ volume are removed, and the computer is never run. `release` removes the proxy and the volume after the computer, each
795
+ found by the label `agentrun.computer.egress=<computer>`, never by name alone, so the janitor's sweep and
796
+ `releaseOlder` remove them too. Parts left with no computer (one removed by hand, or a provider that died between its
797
+ proxy and its computer) the sweep removes too (`sweepLeftovers`): a proxy or volume with the egress label, and the
798
+ sweep's labels, whose deadline label has passed, or whose computer is gone and that is older than a create could
799
+ take (its ready wait and two minutes), removed by what the label found. The volume carries the computer's deadline
800
+ and the spec's labels for this. Until then the proxy stops forwarding at its deadline.
801
+ - **Read-back.** `network`, `list` and `attach` read the allowlist from Docker: network mode none, the egress volume
802
+ read-only at its path, init's relay in its command, and a proxy container that carries the computer's label and
803
+ deadline, runs while the computer runs, is hardened and bounded as above (its memory and swap, pids limit, private
804
+ IPC and cgroup namespaces, and json-file log of 1m and 2 files included) with exactly its volume and code, and whose
805
+ argv holds the list and refuses every one of the Docker host's own addresses the provider requires now (more is
806
+ fine). Anything less is `{ other: "network allow, but its egress proxy ... <why>" }`. **A crashed proxy** is not
807
+ restarted: the computer then reaches nothing, its network reads back `other` ("is not running"), and `attach` refuses
808
+ it, so a caller makes a new computer. `list` reads every listed computer's proxy in one more inspect.
809
+
810
+ ### Mounting the run's folder
811
+
812
+ A computer mounts the run's folder; tools then run inside it. The spec has one field for it, `mount`, and every
813
+ computer has the folder at one path, `/workspace` (`WORKSPACE`). `HOME` stays where the provider puts it (`/work` on
814
+ Docker): `/workspace` is only the mount.
815
+
816
+ ```ts
817
+ import { DockerProvider, WORKSPACE } from "@parcha/agentrun-computer";
818
+
819
+ const docker = new DockerProvider({ daemonPath: "dist/computerd-linux-amd64" });
820
+ // The run folder must exist, by its canonical path, and be writable by docker.user (below).
821
+ const made = await docker.create({ image: "debian:bookworm-slim", lifetimeMs: 600_000, network: "none", mount: { kind: "bind", path: "/data/runs/r1/work" } });
822
+ // In the computer: files.read({ path: `${WORKSPACE}/notes.md` }), exec.run({ argv: ["make"], cwd: WORKSPACE, ... })
823
+ ```
824
+
825
+ - `ComputerSpec.mount` is `{ kind: "bind", path }`, a folder on the provider's host bound in (the local Docker
826
+ computer), or `{ kind: "archil", disk, region, folder, token }`, the run's folder (such as
827
+ `agents/<a>/runs/<r>/work`) inside an Archil disk in its region, mounted in a remote computer.
828
+ `capabilities().mount` lists the kinds a provider takes; absent, it takes none. Each provider file also exports
829
+ `MOUNT` beside its `create`, the same kinds (Docker `["bind"]`; Modal and Daytona `[]` for now), so a caller tells which
830
+ provider binds a local folder from the registry (`providerModule(id)`) without building one.
831
+ - `checkMount(mount, declared)` (`src/mount.ts`) is the one rule every provider's `check` runs, with no vendor call: a
832
+ kind the provider does not declare is refused in words (`this provider does not take a mount of kind archil; it takes
833
+ bind`); a bind's `path` is absolute, canonical (its own realpath, so what is read back is what is bound: Docker
834
+ reports a bind's source as given, a symlink included), an existing directory on the host, with no NUL; an Archil
835
+ mount's `disk`, `region`, `folder` and `token` are non-empty strings with no NUL, the `folder` relative to the disk's root and
836
+ with no `..` part. A field the kind does not have is refused.
837
+ - **The token is a secret.** No refusal names an Archil field's value (a token put in the wrong field is not echoed),
838
+ and what a provider reads back of a mount, `MountReadBack` (`readBackOf(mount, epoch)`), is its kind and source
839
+ alone: `{ kind: "bind", path }` or `{ kind: "archil", disk, region, folder, exclusive, epoch }`, or
840
+ `{ other: "<words>" }` for a mount at `/workspace` the provider never makes. An Archil mount's `epoch` is the
841
+ computer's `agentrun.epoch` label (Archil's hold on a folder carries none); an Archil mount with no epoch reads back
842
+ as `{ other }`, in words. The token is never in a label, a read-back or an error.
843
+ - **Docker takes a bind.** `create` adds `--mount type=bind,src=<path>,dst=/workspace` after the daemon's mount:
844
+ read-write, propagation `rprivate`. A path Docker's `--mount` cannot hold (a comma, a double quote, a line break) is
845
+ refused by `check`.
846
+ - **The run folder must be writable by the computer's user.** The provider binds the folder as it is and never chowns
847
+ or chmods it: whoever makes the run folder gives it that user, the spec's `user` or the provider's (`docker.user`,
848
+ this process's uid:gid by default). `create` checks it after reading the host (`docker info`) and before
849
+ `docker run`, as the kernel will: the owner's, the group's or others' bits of the folder's mode, by the user's uid
850
+ and gid, must allow write and search; else it refuses in words (`the run folder /data/runs/r1/work is not writable
851
+ by the computer's user 1000:1000: it is owned by 0:0 with mode 0755; ...`). A computer's user has no capabilities,
852
+ root included, so no other way in. On an SELinux host the folder needs a label containers may use; the provider
853
+ does not relabel it.
854
+ - **No bind on a host that remaps user ids.** Under userns-remap or rootless Docker (`docker info`'s
855
+ `SecurityOptions` holds `name=userns` or `name=rootless`; `host().remap`), a computer's uid is another uid on the
856
+ host, so the folder's owner says nothing about whether the computer can write it. The provider does not guess the
857
+ mapping from `/etc/subuid`: `create` with a bind on such a host is refused in words before any `docker run`
858
+ (`this Docker host remaps user ids (rootless Docker), so the run folder's owner on the host is not the computer's
859
+ user, ...`), and `check` refuses it too once the host is read. A computer with no mount is made there as before.
860
+ The conformance case `mount.run-folder-bind` fails on such a host, in those words: the provider declares a bind this
861
+ host cannot give.
862
+ - `attach` and `list` read the mount back from `docker inspect` (`mountOf(inspected)`): a read-write bind at
863
+ `/workspace` is `{ kind: "bind", path }`; a read-only one, a volume or two mounts there is `{ other }`, and `attach`
864
+ refuses such a computer. The drift check (below) holds a computer to the mount it was asked for: the bind there, from
865
+ that path, read-write, `rprivate`, and no other mount.
866
+
867
+ ### A provider in a container: the `volume` option
868
+
869
+ A provider that runs in a container of the Docker it drives, given that Docker's socket (the server under
870
+ `docker compose`), has paths the Docker daemon does not: its files are on a named volume the daemon mounted into its
871
+ container. A bind of its daemon copy or of a run folder names a path that exists only inside that container, so every
872
+ `docker run` would fail. The `volume` option says where its files are:
873
+
874
+ ```ts
875
+ // The server's container has the named volume agentrun_agentrun-data mounted at /data.
876
+ const docker = new DockerProvider({
877
+ daemonPath: "dist/computerd-linux-amd64",
878
+ daemonCache: "/data/computer-cache", // at or below volume.root
879
+ volume: { name: "agentrun_agentrun-data", root: "/data" },
880
+ });
881
+ await docker.create({ image: "debian:bookworm-slim", lifetimeMs: 600_000, network: "none", mount: { kind: "bind", path: "/data/disk/agents/a1/runs/r1/work" } });
882
+ ```
883
+
884
+ - `volume: { name, root }`: `name` is the named volume, as `docker volume ls` names it; `root` is where this process
885
+ has it mounted, an absolute path. Without the option, nothing changes: every path is bound as it is.
886
+ - With it, the daemon and the run's folder are mounted as the volume's subpaths, never binds of this process's paths
887
+ and never the volume's root, and every subpath is a directory (Docker mounts a directory subpath on every engine that
888
+ has `volume-subpath`; nothing leans on a file). The daemon is staged in `daemonCache` as `daemon-<sha256>/`, holding
889
+ `computerd` (0755) and an empty `egress/`, written in a temporary directory and renamed into place, reused when the
890
+ same; that directory is mounted read-only at `/opt/agentrun`, so the daemon is `/opt/agentrun/computerd` as on every
891
+ computer and an allowlist's egress volume has its mount point. `--mount type=volume,src=<name>,dst=/opt/agentrun,
892
+ volume-subpath=<daemon dir below root>,volume-nocopy,readonly`, and `--mount type=volume,src=<name>,dst=/workspace,
893
+ volume-subpath=<folder below root>,volume-nocopy`. `volume-nocopy`: Docker never copies the image's files at the
894
+ destination into the volume.
895
+ - `daemonCache` must be at or below `root`; the provider throws in words when it is made with one that is not. A run
896
+ folder must be below `root`; `check` and `create` refuse one that is not, or the root itself, in words, before any
897
+ `docker run`.
898
+ - `volume-subpath` takes Docker Engine 26 or later (API 1.45). The provider reads the engine with `docker info`
899
+ (`host().engine`); `create` refuses an older one, or one that reports no version, in words before anything is made,
900
+ and `check` does too once the host is read.
901
+ - `attach` and `list` read the run's folder back from the volume's subpath (`HostConfig.Mounts`) as the path below
902
+ `root` that `create` was given, `{ kind: "bind", path }`. The drift check holds the daemon's and the folder's mounts to
903
+ the volume, its subpaths, read-only and read-write, and no bind.
904
+ - The run folder is still checked for the computer's user as above: the provider reads it at its own path.
905
+ - **An allowlist's proxy too.** The egress proxy's code (`dist/docker/egress-main.js`, `egress-proxy.js`,
906
+ `egress-table.js` and the package's `package.json`) is bound from this package's build, a path the Docker daemon does
907
+ not have either. With the option, `create` stages those four files below the volume's root first, as it stages the
908
+ daemon: in `daemonCache`, in `egress-<sha256 of the files>/` (`docker/` holding the three modules, `package.json`
909
+ beside it; 0755 directories, 0644 files), written in a temporary directory and renamed into place, and reused when
910
+ one with the same bytes and modes is there. A published tree, the daemon's or the proxy's, is never removed or written
911
+ over, since a running computer may have it mounted: providers sharing `daemonCache` that stage at once use the tree
912
+ the first one renamed into place, and a tree at that name that no longer holds the same (a hand edit) is left as it
913
+ is, the new one published beside it as `<name>-<random>`. The read-back (`attach`, `list`, `network`, the drift
914
+ check) takes a computer mounted on `<name>` or any `<name>-<anything>` in that directory whose contents verify, byte
915
+ for byte and mode for mode: two providers that repaired the same tree at once each mounted their own copy, and both
916
+ are as `create` makes one. A source that is not a regular file (a named pipe) is
917
+ refused in words, never waited on. The proxy then mounts that one
918
+ directory, the layout it runs from, whole at `/code` as the volume's subpath, read-only, and the read-back holds it to
919
+ it. The egress volume is a named volume of its own, as before. In a container the provider still needs
920
+ `egress.hostAddresses` for an allowlist (see the egress proxy).
921
+
922
+ ### The image: `ensureImage`
923
+
924
+ The provider owns the image its computers start from and makes it ready in its own process. There is no state file and
925
+ no other process to wait on: Docker's own tag is the shared state.
926
+
927
+ ```ts
928
+ import { DockerProvider } from "@parcha/agentrun-computer";
929
+
930
+ const docker = new DockerProvider({ daemonPath: "dist/computerd-linux-amd64" }); // image: the default recipe
931
+ const image = await docker.image({ signal }); // built once; one inspect when Docker has it
932
+ if (!image.ok) throw new Error(image.error.message);
933
+ const made = await docker.create({ image: image.value, lifetimeMs: 600_000, network: "none" });
934
+ ```
935
+
936
+ - `ensureImage(source, { docker?, signal?, timeoutMs?, onWait? })` (`src/docker/image.ts`) gives the tag. `source` is
937
+ `{ recipe }`, a Dockerfile with no build context, or `{ image }`, an image by name.
938
+ - A recipe is built with `docker build --quiet --label agentrun.computer.recipe=<sha256> --tag
939
+ agentrun-computer:<first 12 hex digits> -`, the recipe on stdin (`recipeTag(recipe)`, `recipeHash(recipe)`,
940
+ `RECIPE_LABEL`). It is built only when `docker image inspect` finds no image under the tag, or one whose label is
941
+ not this recipe's whole sha256: a changed recipe is a new tag, and the same recipe is never built twice.
942
+ - An image by name is ready when Docker has it, and pulled once (`docker pull --quiet`) when it has none. It is never
943
+ built.
944
+ - `DockerProvider`'s `image` option is that source; the default is `{ recipe: DOCKER_RECIPE }`, the provider's own
945
+ image (`DEFAULT_DOCKER_IMAGE`): `python:3.12-slim` pinned by its index digest (`DOCKER_BASE`), with git, curl,
946
+ nodejs, npm, ripgrep and socat from apt. `docker.image({ signal?, timeoutMs?, onWait? })` is `ensureImage` of it with the
947
+ provider's docker CLI. A source that is neither throws at construction, in words.
948
+ - **The image is an option only; there is no env name for it.** Another image is named with the `image` option, to
949
+ `new DockerProvider(...)` or to `create({ image: { image: "..." } })`. The library reads no environment (see
950
+ [Settings](#settings)), and Docker's conformance module reads no image name either: a `COMPUTER_DOCKER_IMAGE` in its
951
+ environment is ignored. serve keeps its own setting, `AGENTRUN_DOCKER_IMAGE`,
952
+ and at the cutover passes it in as the `image` option, so there is one name and the owner's setting keeps working.
953
+ - **One build per process.** Concurrent callers share one flight per docker CLI and recipe (or image): the first starts
954
+ it, the rest wait on it and ask Docker nothing. A flight is forgotten once it settles, so the next call inspects
955
+ again, and a failure is never kept: the next call tries again.
956
+ - **Two processes need no state file.** Same recipe, same tag, same label, so a build is idempotent. Two processes
957
+ that both miss the tag both build, BuildKit sharing its cache. With Docker 29's containerd image store the first to
958
+ tag wins and the others fail with `already exists`; with the classic store the last one wins. Either way a build or
959
+ pull that fails asks Docker once more, and the tag on an image of this recipe is the answer, so every process ends
960
+ with the tag. A computer made from an image that lost its tag keeps it, as Docker holds an image by its id.
961
+ - `onWait(making, tag)` is told once, before a caller waits on a build or pull (`"build"` or `"pull"`), its own or one
962
+ it joined, and never when Docker has the image: a caller shows its own "preparing" row with it
963
+ (`DOCKER_RECIPE_HAS` is the default image's contents in words). `docker.image()` takes it too.
964
+ - **One bound, the caller's signal.** `timeoutMs` (default `IMAGE_TIMEOUT_MS`, 10 minutes) covers a flight's inspect and
965
+ its build or pull, and the first caller's bound is the flight's; past it the docker CLI is killed (`timeout`). A
966
+ caller's `signal` ends its own wait (`aborted`); when the last caller waiting aborts, the build or pull is killed.
967
+ - **The words hold none of Docker's output**, only what happened and the next step: Docker not answering ("is it
968
+ running, and may this user reach it?"); a build that could not reach the network, could not pull its base, ran out
969
+ of disk space, or could not install a package; a recipe Docker could not parse (`at line 2`) or whose step failed
970
+ (``failed at the step `RUN make` with exit code 2``), the recipe's own words; a registry that refused a pull, has no
971
+ such image, or could not be reached. A source that is neither a recipe with a `FROM` line nor an image name, or a
972
+ bound that is not one, is `invalid` before Docker is called.
973
+
974
+ ### The drift check
975
+
976
+ After `docker run`, `create` reads the computer's own report and compares it with the spec, in `drift(spec, inspected,
977
+ hello, expected)`, a pure function that returns one sentence per mismatch (`inspectDrift` is its inspect half). The
978
+ check is closed: every field of `HostConfig` and `Config` is either one create asks for, one with a stated default,
979
+ or one that widens nothing the box bounds; any other field, one a later Docker adds included, must be empty (absent,
980
+ null, `""`, 0, false, `[]` or `{}`), or it is drift naming it. The table below was made from `docker inspect` of a
981
+ computer this provider made on Docker 29.
982
+
983
+ From `docker inspect`, what create asks for:
984
+
985
+ | Field | Must be |
986
+ | --- | --- |
987
+ | network (`HostConfig.NetworkMode`, `NetworkSettings.Networks`, and for an allowlist the egress volume, init's relay and the proxy container) | `none`, `open` or the allowlist as declared, read back as `network(ref)` does |
988
+ | `HostConfig.CapDrop`, `CapAdd`, `Privileged` | `["ALL"]`, nothing added, false |
989
+ | `HostConfig.SecurityOpt` | exactly `["no-new-privileges"]`: `seccomp=unconfined`, `apparmor=unconfined`, `label=disable`, `systempaths=unconfined` or any other option is drift |
990
+ | `HostConfig.IpcMode`, `CgroupnsMode` | `private`, `private` |
991
+ | `HostConfig.Runtime` | `runc` |
992
+ | `HostConfig.MaskedPaths`, `ReadonlyPaths` | hold Docker's own since 20.10 (`/proc/acpi`, `/proc/asound`, `/proc/kcore`, `/proc/keys`, `/proc/latency_stats`, `/proc/sched_debug`, `/proc/scsi`, `/proc/timer_list`, `/proc/timer_stats`, `/sys/firmware`; `/proc/bus`, `/proc/fs`, `/proc/irq`, `/proc/sys`, `/proc/sysrq-trigger`); a newer Docker's extra masked paths are fine |
993
+ | `HostConfig.PidsLimit` | `pids`, or 1024 |
994
+ | `HostConfig.Memory`, `MemorySwap` | both `memoryMb` MiB, or 4096 MiB |
995
+ | `HostConfig.CpuPeriod`, `CpuQuota` | 100000, and `cpus` (or 2) times 100000 |
996
+ | `HostConfig.Tmpfs` | exactly `/work` and `/run/agentrun`, each with that uid and gid, `mode=0700`, `nosuid` and `nodev` (`/work` `exec` and `size=` half of `memoryMb` in MiB, `/run/agentrun` `noexec` and `size=1m`); options in any order; a missing or other size, or another tmpfs, is drift |
997
+ | `HostConfig.Mounts`, `Mounts` | the provider's daemon binary bound read-only at `/opt/agentrun/computerd` (propagation `rprivate`); when the spec has a `mount`, then the run's folder bound read-write at `/workspace` from exactly that path (propagation `rprivate`); for an allowlist, then the computer's own egress volume read-only at `/opt/agentrun/egress`; and no other mount of any type: an image's `VOLUME` is drift too, so an image that declares one is refused |
998
+ | `Config.User` | the uid:gid asked for: the spec's, the provider's, or the default |
999
+ | `Config.Image`, `WorkingDir` | the spec's image; its `workdir`, or `/work` |
1000
+ | `Config.Env` | one `HOME`, `HOME=/work`; the image's other variables are its own |
1001
+ | `Config.Entrypoint`, `Cmd` | `["/opt/agentrun/computerd"]`, `["init", "--deadline", <the deadline label's value>]`, and for an allowlist `"--egress", "/opt/agentrun/egress/egress.sock"` after it |
1002
+ | `Config.Labels` | `agentrun.computer=1`, the deadline as written, and every label the spec asked for; others are the image's |
1003
+ | `AppArmorProfile` | `docker-default` when the host has AppArmor, else empty |
1004
+ | `ProcessLabel` | of type `container_t` when the host has SELinux, else empty |
1005
+
1006
+ Defaults other than empty: `HostConfig.RestartPolicy` no restart (`{"Name": "no"}`; a restart policy would bring a
1007
+ computer back after its deadline), `Isolation` empty or `default`, `MemorySwappiness` null or -1.
1008
+
1009
+ Must be empty, each a mismatch by name: `Binds`, `VolumeDriver`, `VolumesFrom`, `PortBindings`, `PublishAllPorts`,
1010
+ `Links`, `ExtraHosts`, `Dns`, `DnsOptions`, `DnsSearch`, `PidMode`, `UTSMode`, `UsernsMode`, `Cgroup`, `CgroupParent`,
1011
+ `GroupAdd`, `Devices`, `DeviceCgroupRules`, `DeviceRequests`, `Sysctls`, `OomKillDisable`, `OomScoreAdj`,
1012
+ `CpuShares`, `NanoCpus`, `CpuRealtimePeriod`, `CpuRealtimeRuntime`, `CpusetCpus`, `CpusetMems`, `CpuCount`,
1013
+ `CpuPercent`, `MemoryReservation`, `KernelMemory`, `KernelMemoryTCP`, `BlkioWeight`, `BlkioWeightDevice`,
1014
+ `BlkioDeviceReadBps`, `BlkioDeviceWriteBps`, `BlkioDeviceReadIOps`, `BlkioDeviceWriteIOps`, `IOMaximumIOps`,
1015
+ `IOMaximumBandwidth`, `StorageOpt`, `Init`, `Annotations`, `AutoRemove`, `ReadonlyRootfs`; `Config.Volumes`; and
1016
+ every field not named in this section.
1017
+
1018
+ Irrelevant, not checked: `HostConfig.LogConfig` (the host's log driver), `ConsoleSize`, `ContainerIDFile` (a
1019
+ client-side file), `ShmSize` (`/dev/shm` is charged to the computer's memory), `Ulimits` (an rlimit cannot raise a
1020
+ cgroup limit); `Config.Hostname`, `Domainname`, `AttachStdin`, `AttachStdout`, `AttachStderr`, `Tty`, `OpenStdin`,
1021
+ `StdinOnce`, `ExposedPorts` (nothing is published), `Healthcheck`, `ArgsEscaped`, `OnBuild`, `StopSignal`,
1022
+ `StopTimeout`, `Shell`, `MacAddress`, `NetworkDisabled`: the image's settings, which act only inside the computer.
1023
+ The rest of the report (`State`, `NetworkSettings` past its networks, paths, `Driver`) is Docker's own bookkeeping.
1024
+
1025
+ From the daemon's `hello`, over one short connection: the provider's version, `os` linux, `kind` linux, exactly the
1026
+ groups in `capabilities().groups` (in any order; one more or one fewer is drift), and `arch` the Docker host's
1027
+ architecture (`docker info`, x86_64 as amd64, aarch64 as arm64). `attach` also reports the hello's `kind` in the spec
1028
+ it reads back, when the computer is running.
1029
+
1030
+ Any mismatch, or a computer that cannot be inspected or whose daemon does not answer, and the computer is deleted
1031
+ before `create` returns `refused` with every mismatch. A computer is never left running wider than it was declared.
1032
+ `attach` runs the same check and refuses, but never deletes.
1033
+
1034
+ ### The host's enforcement
1035
+
1036
+ A computer's sizes are cgroup limits, which only a host that enforces them makes real. `host()` reads `docker info`
1037
+ once per provider (a failed read is not kept, so the next call reads again), and `hostOf(info)` turns it into the
1038
+ host's architecture, its security modules, and each enforcement it lacks:
1039
+
1040
+ | `docker info` | Required | Refusal |
1041
+ | --- | --- | --- |
1042
+ | `MemoryLimit` | true | this Docker host does not enforce memory limits, so a computer's memory size is only configuration |
1043
+ | `SwapLimit` | true | ... swap limits, so a computer could swap past its memory size |
1044
+ | `PidsLimit` | true | ... pids limits, so a computer's pids limit is only configuration |
1045
+ | `CPUCfsQuota`, `CPUCfsPeriod` | true | ... CPU quotas (periods), so a computer's cpus are only configuration |
1046
+ | `SecurityOptions` seccomp | present, its profile not `unconfined` | this Docker host has no seccomp (its default seccomp profile is unconfined), so a computer could make any system call |
1047
+ | `SecurityOptions` apparmor, selinux | reported | none: the drift check expects the profile or label Docker then gives every container |
1048
+
1049
+ Seccomp is required: it is a computer's only system call filter, and every Linux Docker has it. AppArmor and SELinux
1050
+ are reported, not required: a host has the one its distribution ships, or neither, and a computer's confinement does
1051
+ not rest on them (no capabilities, no-new-privileges, seccomp, its own namespaces); where the host has one, a computer
1052
+ without its profile or label is drift. `create` and `attach` refuse on a host that lacks any requirement, before any
1053
+ other Docker call; `check` refuses too once the host has been read.
1054
+
1055
+ ### The janitor
1056
+
1057
+ A Docker computer stops itself at its deadline (init exits), but Docker deletes nothing, so the provider declares
1058
+ `lifetime: "janitor"` and `sweep(provider, { labels?, now?, signal? })` (in `src/janitor.ts`) deletes computers instead. It works for any provider that declares `lifetime: "janitor"`
1059
+ and refuses one that declares `"vendor"`. It lists the provider's computers with `labels` (all of them by default) and
1060
+ deletes each whose deadline is at or before `now`, or whose deadline is missing or unreadable, stopped or running (a
1061
+ computer past its deadline has usually stopped itself already). A deadline more than the provider's `maxLifetimeMs`
1062
+ past `now` (and a minute of clock skew) counts as unreadable: no computer the provider made carries one. It keeps the
1063
+ rest and
1064
+ returns `{ deleted, kept }`. It never touches a container the provider does not list: on Docker, one without
1065
+ `agentrun.computer=1` and a computer's name. A computer it cannot delete does not stop it; the result is then an error
1066
+ naming it and what was deleted.
1067
+
1068
+ This package does not schedule the janitor. Whoever runs computers runs `sweep` on a schedule (a cron job, or a timer
1069
+ in a long-lived service), with Docker's CLI on its PATH. A computer stops at its deadline whether the janitor runs or not;
1070
+ its stopped container may stay up to one interval longer.
1071
+
1072
+ ```ts
1073
+ import { DockerProvider, sweep } from "@parcha/agentrun-computer";
1074
+
1075
+ const swept = await sweep(new DockerProvider({ daemonPath: "dist/computerd-linux-amd64" }));
1076
+ if (swept.ok) console.log(`deleted ${swept.value.deleted.join(", ") || "none"}; kept ${swept.value.kept}`);
1077
+ ```
1078
+
1079
+ ### Run and epoch labels: `releaseOlder`
1080
+
1081
+ The claim epoch is the one fence for runs and computers. Every computer of a run carries two labels, set in one place
1082
+ (`src/labels.ts`): `agentrun.run` (`RUN_LABEL`), the run's id, and `agentrun.epoch` (`EPOCH_LABEL`), the claim epoch of
1083
+ the runner that made it, in decimal. A new claim is epoch + 1, and its first step is to release the run's computers of
1084
+ a lower epoch. The labels sit outside each provider's own `agentrun.computer` namespace, so every provider takes them
1085
+ as a caller's labels, with no code of its own: Docker writes them with `--label` and lists them with `--filter`.
1086
+
1087
+ - `runLabels(run, epoch)` gives the two labels for `ComputerSpec.labels`. A run id is a non-empty string with no NUL
1088
+ byte, the strictest rule the providers share for a label's value (`runProblem`); an epoch is a whole number from 0
1089
+ to 2^53 - 1 (`epochProblem`). Anything else throws, in words.
1090
+ - `epochOf(labels)` reads a computer's epoch: decimal digits with no sign, leading zero or space, up to 2^53 - 1. A
1091
+ missing label is `not_found`; anything else is `invalid`, in words naming what the label reads.
1092
+ - `releaseOlder(provider, run, epoch, { signal? })` (in `src/janitor.ts`) lists the run's computers by
1093
+ `agentrun.run` and deletes each with a lower epoch, and each whose epoch label is missing or unreadable, since it
1094
+ cannot prove it is current (named in `unproven`, with why). It keeps the run's computers of this epoch. It holds
1095
+ each listed computer to the run's label again, so a computer of another run is never touched, whatever `list` gives.
1096
+ It returns `{ released, kept, unproven }`.
1097
+ - **Fenced.** A computer of the run with a higher epoch means a later claim holds the run: `releaseOlder` is refused
1098
+ (`refused`, `fenced: run "r1" has computer-… at epoch 4, above this claim's epoch 3; …`) before it releases
1099
+ anything.
1100
+ - **A partial cleanup is a failure.** Every release is attempted; when any fails, the result is an error naming each
1101
+ computer left and why, and what was released. A takeover goes on (revoke, then mount) only on `ok`. An aborted call
1102
+ starts no further release and says which ran.
1103
+ - It revokes no mount: there is no `unmount` on the provider. Revoking an Archil mount is the root helper's, run inside
1104
+ the computer through the provider's own exec, and a deleted computer holds no mount.
1105
+
1106
+ ```ts
1107
+ import { DockerProvider, releaseOlder, runLabels } from "@parcha/agentrun-computer";
1108
+
1109
+ const docker = new DockerProvider({ daemonPath: "dist/computerd-linux-amd64" });
1110
+ // A claim at epoch 3 takes the run over: the computers of epochs 1 and 2 go first.
1111
+ const older = await releaseOlder(docker, "r1", 3);
1112
+ if (!older.ok) throw new Error(older.error.message); // fenced, or a computer that could not be released
1113
+ await docker.create({ image: "debian:bookworm-slim", lifetimeMs: 600_000, network: "none", labels: runLabels("r1", 3) });
1114
+ ```
1115
+
1116
+ ### Waiting for a vendor: `waitUntil`
1117
+
1118
+ `waitUntil(read, done, { boundMs, signal?, minMs?, maxMs?, what?, describe? })` (in `src/wait.ts`) is the one bounded
1119
+ wait a provider uses when the vendor reads a state back later than it acted, such as a computer ended by a release. It
1120
+ reads at once, then after pauses that double from `minMs` (250 ms) to `maxMs` (5 s), never past `boundMs`, and
1121
+ returns the first state `done` accepts. Each read gets a signal that aborts at the bound or on the caller's abort; a
1122
+ read still pending then is not waited for, and one that throws is not done. Past the bound it returns a `timeout`, on
1123
+ the caller's abort an `aborted`, each naming `what` was waited for and the last state read (`describe`). It has no
1124
+ vendor's types: Modal's `untilFinished`, its one wait after a terminate, is built on it, and Modal's release, a create
1125
+ that refuses its sandbox, and the Modal sweep all wait through that; Daytona's release, a create that deletes its
1126
+ sandbox, and the Daytona sweep wait through it too.
1127
+
1128
+ ## Modal
1129
+
1130
+ ```ts
1131
+ import { ModalClient } from "modal"; // the host's own client: this package imports nothing from the SDK
1132
+ import { ModalProvider } from "@parcha/agentrun-computer";
1133
+
1134
+ const modal = new ModalProvider({
1135
+ sdk: new ModalClient(),
1136
+ app: "computers",
1137
+ // daemonPath: the daemon to upload; default this package's dist/computerd-linux-amd64 (npm run build:daemon)
1138
+ });
1139
+ const made = await modal.create({ image: "debian:bookworm-slim", lifetimeMs: 600_000, network: "none" });
1140
+ ```
1141
+
1142
+ `ModalProvider` makes Modal sandboxes on the VM runtime only, through the slice of Modal's JS SDK named by `ModalSdk`
1143
+ (apps, images, sandboxes and five methods of a sandbox). It has not yet run against real Modal: every test uses a fake
1144
+ of that slice, and the live conformance file waits for a key (below).
1145
+
1146
+ - **Capabilities.** Kind `linux`, daemon `pid1`, groups `exec`, `files` and `processes`, `maxLifetimeMs` the
1147
+ instance's cap (24 hours, or less with the `maxLifetimeMs` option), and user `uid` only, never `root` (below). Daemon
1148
+ `pid1` because init is the sandbox's main process and its exit ends the computer (next item); no `extend` or
1149
+ `stream`. Network `none` alone, and `vendorAgentPorts` empty: no listener of Modal's inside a sandbox is documented,
1150
+ and isolation.vendor-agent checks the interfaces alone.
1151
+ - **The loopback block.** Init starts with `--own-network` (see [Init, the socket and the
1152
+ bridge](#init-the-socket-and-the-bridge)) whatever Modal runs inside the sandbox: the daemon's programs reach their
1153
+ own loopback and nothing else, and the default computer user is 2510:2510 (`user` option or spec.user for another;
1154
+ init refuses one another process holds). Modal's root holds every capability, so the namespace is made there. Known
1155
+ gap: network `open` is refused in words until a proxy carries it out of the daemon's own network, the next feature
1156
+ after this one; a computer that needs pip, npm or git from the internet cannot be made on Modal until then.
1157
+ - **The daemon is uploaded at create.** The sandbox's command is a small POSIX sh entrypoint (BusyBox and coreutils
1158
+ alike): it waits for `/opt/agentrun/computerd` to be there and executable, then `exec`s `computerd init --deadline
1159
+ <iso> --user <uid:gid> --own-network` with `HOME=/work`. Modal runs the command as the sandbox's main process and finishes the
1160
+ sandbox when it exits, so after the `exec`, init is that process and the sandbox lives as long as init does. Whether
1161
+ that process is PID 1 is not documented; init reaps as a subreaper either way. The wait is bounded (`uploadMs` plus
1162
+ one call, 360 s by default): if no daemon arrives by then, the entrypoint says so on stderr and exits 3, which ends
1163
+ the sandbox.
1164
+
1165
+ Right after create the provider runs `sh -c '<upload>' sh /opt/agentrun/computerd <sha256>` through
1166
+ `sandbox.exec([...], { mode: "binary" })` and streams `dist/computerd-linux-amd64` into its stdin, in the SDK's own
1167
+ 256 KiB stdin chunks, then closes it. The script `cat`s stdin to `/opt/agentrun/.computerd.part`, makes it 0755,
1168
+ prints `sha256 <hex>` (`sha256sum`, BusyBox's is fine), and only when that is the sha256 it was given moves the part
1169
+ into place with `mv -f`. The rename is what the entrypoint waits for, so it never starts a half-written daemon or the
1170
+ wrong one. The provider compares the printed sha256 with its own, as the Daytona provider does. A failed, aborted,
1171
+ nonzero or mismatched upload, or one past `uploadMs` (5 min), terminates the sandbox and refuses in words. Then the
1172
+ drift check connects as below, trying the bridge again until init listens, within `helloMs`. Exec's stdin goes
1173
+ through Modal's command router, not the sandbox's network, so network none still works. The binary cannot go as an
1174
+ argument: the SDK refuses more than 64 KiB of argv. `modalCommands()` (in `dist/modal.js`) returns the entrypoint,
1175
+ upload and bridge exactly as sent. A Docker-gated test runs them in a root container with no network.
1176
+ - **Or as an image layer**, with `daemonImage`: `create` gives the spec's image `COPY --from=<daemonImage> /computerd
1177
+ /opt/agentrun/computerd`, and the command is `computerd init` itself. The JS SDK refuses a COPY from local files but
1178
+ takes `COPY --from` an image, so `daemonImage` is a registry image holding this version's daemon for linux/amd64 at
1179
+ `/computerd`, pinned by digest (the constructor refuses a tag, and `daemonImage` with `daemonPath`). One is two
1180
+ lines:
1181
+
1182
+ ```dockerfile
1183
+ FROM scratch
1184
+ COPY dist/computerd-linux-amd64 /computerd
1185
+ ```
1186
+
1187
+ Either way the image also gets `ENV HOME=/work` and `WORKDIR <workdir>`, and the computer needs no network to get
1188
+ its daemon.
1189
+ - **The daemon becomes the computer's user.** Modal containers always run as root and ignore an image's `USER`, so
1190
+ `--user` is how a Modal computer gets the non-root default the protocol asks for (`1000:1000`, or the `user` option),
1191
+ or the uid its spec asks for. Init leaves itself and every program no capability in any set (see Init, above): Modal
1192
+ starts the container with every one, and a live run read `CapEff` `000001ffffffffff` from a root computer before the
1193
+ daemon dropped them itself.
1194
+ - **A Modal computer never runs as root.** `check()` and `create()` refuse a spec whose `user` is root (`"0"`,
1195
+ `"0:<gid>"`, `"root"`, `"root:<gid>"`) in words, before any Modal call, and `connect`, `attach` and `network`
1196
+ refuse a computer whose spec tag records root before they run anything in it. Every connection is Modal's own exec
1197
+ of `/opt/agentrun/computerd stdio`, outside the daemon, with Modal's root capabilities. A computer's user without
1198
+ root cannot touch that path: after the upload `/opt/agentrun/computerd` is `0:0 755` (the part file is `chmod
1199
+ 0755` by the root upload, then renamed into place), `/opt/agentrun` is made by the root upload's `mkdir -p`, `0:0
1200
+ 755`, and `/` and `/opt` are the image's, `0:0 755` in Debian and Alpine; with `daemonImage`, `COPY --from` makes
1201
+ `/opt/agentrun` and the daemon owned by root (COPY's default; the daemon keeps its mode from the daemon image), not
1202
+ yet read back on Modal. Root with no capability still owns every one of them, so it could rename another program over
1203
+ the daemon and the next connection would run it with Modal's capabilities; no file mode closes that for the owner
1204
+ of every directory above the path. The Docker-gated `modal-commands` test shows uid 1000 cannot write the daemon,
1205
+ `/opt/agentrun`, `/opt` or `/`, and that init `--own-network` refuses uid 0 for its programs outright.
1206
+ - **The stream** is `computerd stdio` through `sandbox.exec([...], { mode: "binary" })`: its stdin and stdout are the
1207
+ `DaemonClient`'s stream. Modal has no kill for an exec, so `close()` ends the bridge's stdin and waits up to 5 s for
1208
+ it to exit. One deadline, `helloMs`, covers the exec's start (at most `callMs` of it) and the hello after it, so a
1209
+ connection fails at `helloMs` in all. An exec given up on (past its bound, or on the caller's abort) goes on at
1210
+ Modal; a bridge that lands after that has its stdin closed as it lands, so it ends.
1211
+ - **Lifetime is Modal's.** Every sandbox's `timeoutMs` is its lifetime, rounded up to whole seconds, so Modal ends it
1212
+ then whatever runs in it. The longest is 24 hours, or less with the `maxLifetimeMs` option, declared as
1213
+ `capabilities().maxLifetimeMs`; `check` refuses a longer one with `checkLifetime`, the rule every provider shares. The daemon's deadline ends it first. `sweep` refuses a Modal provider.
1214
+ - **Network.** `none` is `blockNetwork: true`, and the daemon's programs have their own loopback alone besides (the
1215
+ loopback block); `open` and an allowlist are refused in words for now, and a computer recorded open (made before)
1216
+ reads back open. The probe's `interfaces` must read `["lo"]`, or the computer is refused as drift. Modal has no read-back of a sandbox's
1217
+ policy, so `networkReadBack` is false and the daemon's probe stands for one: `create`, `attach` and `network(ref)` run
1218
+ `computerd probe` through `exec.run`, as the computer's user, against public addresses (`1.1.1.1:443`,
1219
+ `8.8.8.8:443`, `[2606:4700:4700::1111]:443`, and DNS over UDP to `1.1.1.1:53/udp` and
1220
+ `[2606:4700:4700::1111]:53/udp`, or the `probeTargets` option). A computer with network none that any of
1221
+ them answers is terminated at create, refused by attach, and reads back as another network in words; one that only
1222
+ accepted, sending nothing back, is kept, the targets named in `notes` (see
1223
+ [Network none, read from inside](#network-none-read-from-inside-nothing-answers)). This shows those addresses are
1224
+ blocked, not every one. An allowlist is refused: Modal's CIDR allowlist (any protocol,
1225
+ every port) and its domain allowlist (beta, TLS on 443 by SNI only) cannot be read back, so per ruling 9 an
1226
+ allowlist counts only once the live bypass cases pass. A change of network is refused: blockNetwork cannot be
1227
+ updated, and an allowlist only if one was set at create.
1228
+ - **The drift check** after create: `poll()` is null (it runs), `getTags()` reads back exactly the tags given, hello's
1229
+ version, os, arch (`amd64`), kind (`linux`) and exact groups match, and the probe's uid:gid is the computer's user, its kernel is
1230
+ not gVisor's (`4.19.0-gvisor`), and with network none none of its targets answered. A mismatch, an abort or a timeout
1231
+ terminates the sandbox and refuses in words. The SDK reads back no runtime, image or size: the probe's kernel is the
1232
+ only runtime read-back, and image and sizes are what create recorded in a tag only the host's token writes.
1233
+ - **Sizes are limits**, as in Docker: `cpus` (at least 0.25) becomes `cpuLimit` in physical cores (2 CPUs each) and
1234
+ `memoryMb` becomes `memoryLimitMiB`, each with Modal's default request (0.125 cores, 128 MiB) or less. `pids` is
1235
+ refused: Modal has no pids limit.
1236
+ - **Tags.** A sandbox carries `agentrun.computer`, `agentrun.computer.name`, `agentrun.computer.deadline` and
1237
+ `agentrun.computer.spec` (what create recorded), so a computer takes at most 6 labels of its own. `list(labels)` is
1238
+ `sandboxes.list({ appId, tags })` over the provider's app: running sandboxes only, so every one is `running`, and its
1239
+ network is the one create recorded (`network(ref)` probes it). Modal still lists a sandbox for a while after its
1240
+ terminate, so each one listed is polled, and one `poll()` reads finished, or that Modal no longer knows, is left out.
1241
+ - **attach** by id or labels runs the same drift check on what it finds and refuses a drifted computer in words, left
1242
+ running. Its `spec.user` is the probe's uid:gid and its `spec.kind` hello's; the rest is as recorded.
1243
+ - **release** `delete` is `terminate()`, idempotent: a sandbox that has finished, or that Modal no longer knows, is ok.
1244
+ Modal ends a sandbox asynchronously, so after the terminate `release` polls (`untilFinished`, on `waitUntil` above) until `poll()` reads
1245
+ an exit code or Modal no longer knows the sandbox, with pauses that double from `releasePollMs` (500 ms) to 5 s,
1246
+ within `releaseMs` (120 s) and the caller's signal. Past the bound it is a `timeout` that says what `poll()` last
1247
+ read; it never reports a delete done that it did not read back. A caller that bounds release (the conformance
1248
+ runner's `cleanupTimeoutMs`) gives it more than 120 s: the live suite passes 150 s.
1249
+ `capabilities().release` is `["delete"]`, so `stop` is refused as `unsupported`, in words, and the sandbox runs on:
1250
+ terminate is a sandbox's only end, and Modal has no stopped state. `release`, `connect` and
1251
+ `network` act only on a sandbox whose tags name it as this provider's, with the ref's name.
1252
+ - **Every call is bounded** (`timeouts`: create 10 min, which covers the layer's build and scheduling; the upload 5
1253
+ min; other calls 60 s; a connection, from the bridge's exec to hello, and the probe 30 s; a whole list 120 s; release's wait 120 s) and takes the caller's
1254
+ signal. A create that gives up has its
1255
+ sandbox terminated if one lands later. A create that refuses its sandbox (drift, an abort, a failed upload)
1256
+ terminates it and waits as release does, within `releaseMs`, so nothing is left listed when it returns. The terminate
1257
+ is sent whatever the caller's signal; the wait takes it, so an aborted create returns at once, and a wait past the
1258
+ bound or cut short by an abort says the sandbox may still be ending and what `poll()` last read.
1259
+ - **GPU** is refused: this provider makes VM sandboxes, and Modal offers GPUs on gVisor only.
1260
+
1261
+ ### What every Modal fact rests on
1262
+
1263
+ SDK: `modal-labs/modal-client@64880502f2ac3d39750c028b7ccfe21e10adbb45` (npm `modal` 0.11.1): paths are under `js/src/`
1264
+ unless they start with `modal_proto/`. Docs: modal.com, read 2026-11-05.
1265
+
1266
+ | Fact | Citation |
1267
+ | --- | --- |
1268
+ | `sandboxes.create(app, image, params)`; `runtime`, `command`, `timeoutMs` (default 5 min), `workdir`, `cpu`, `cpuLimit`, `memoryMiB`, `memoryLimitMiB`, `blockNetwork`, `tags` | `sandbox.ts:356-474`, `808-867` |
1269
+ | `timeoutMs` must be a whole number of seconds; `cpuLimit` needs `cpu` and is at least it; the same for memory | `sandbox.ts:534-542`, `654-698` |
1270
+ | `timeoutMs` is the sandbox's maximum lifetime, sent as `timeoutSecs` (300 when unset) | `sandbox.ts:375-376`, `730-733` |
1271
+ | Runtime `"gvisor" \| "vm"`; unset lets Modal choose, so it is always sent | `sandbox.ts:242-258`; [guide/sandboxes#runtimes](https://modal.com/docs/guide/sandboxes#runtimes) |
1272
+ | VM: its own Linux kernel under KVM | [guide/sandbox-networking#security-model](https://modal.com/docs/guide/sandbox-networking#security-model) |
1273
+ | GPU sandboxes only with `runtime="gvisor"` | [guide/sandboxes#runtimes](https://modal.com/docs/guide/sandboxes#runtimes); [guide/sandbox-resources#gpu-sandboxes](https://modal.com/docs/guide/sandbox-resources#gpu-sandboxes) |
1274
+ | gVisor reports kernel `4.19.0-gvisor`; a VM's `uname -srn` reads `Linux modal 7.2.6` | [guide/troubleshooting](https://modal.com/docs/guide/troubleshooting); [guide/sandboxes#runtimes](https://modal.com/docs/guide/sandboxes#runtimes) |
1275
+ | Lifetime: default 5 minutes, up to 24 hours | [guide/sandboxes#timeouts](https://modal.com/docs/guide/sandboxes#timeouts) |
1276
+ | A sandbox finishes when its entrypoint exits, on terminate, at its timeout or idle timeout, or out of memory; no command runs after | [guide/sandboxes#lifecycle](https://modal.com/docs/guide/sandboxes#lifecycle) |
1277
+ | The command is the sandbox's entrypoint, "the main process" (default `sleep 48h`), sent as `entrypointArgs` | `sandbox.ts:384-388`, `730`; [guide/sandboxes#running-a-sandbox-with-an-entrypoint](https://modal.com/docs/guide/sandboxes#running-a-sandbox-with-an-entrypoint) |
1278
+ | Whether the main process is PID 1 | not documented (searched `modal-docs`, `js/src`, `modal-libmodal`: none) |
1279
+ | Modal containers always run as root; `USER` is ignored | [guide/existing-images#user](https://modal.com/docs/guide/existing-images#user) |
1280
+ | Images must be `linux/amd64` | [guide/existing-images](https://modal.com/docs/guide/existing-images) |
1281
+ | `images.fromRegistry(tag)`; `dockerfileCommands(commands)` adds a layer; a COPY from local context is refused, `COPY --from=` is not | `image.ts:196-210`, `351-401` |
1282
+ | Modal's Dockerfile lacks only `EXPOSE`, `HEALTHCHECK`, `LABEL`, `ONBUILD`, `STOPSIGNAL`, `VOLUME` | [guide/existing-images](https://modal.com/docs/guide/existing-images) |
1283
+ | `sandbox.exec(argv, { mode: "binary" })` gives `stdin` (`writeBytes`, `close`), `stdout`, `stderr` and `wait()` | `sandbox.ts:1272-1290`, `1881-1949`, `2774-2914`; `streams.ts:13-39`, `114-140` |
1284
+ | exec starts through the task command router; each stdin write is one `TaskExecStdinWrite` at the running offset, and close sends EOF | `sandbox.ts:1915-1926`, `3126-3154`; `modal_proto/task_command_router.proto:420-421` |
1285
+ | The SDK's own stdin chunk when it streams: 256 KiB | `task_command_router_client.ts:187-193` |
1286
+ | exec refuses more than 2^16 bytes of argv (ARG_MAX) | `sandbox.ts:1440-1458` |
1287
+ | No kill or signal for an exec | `modal_proto/task_command_router.proto:397-448` (no kill or signal RPC; exit status fields only) |
1288
+ | exec on a finished sandbox throws `ConflictError` ("has already finished") | `sandbox.ts:2062-2064`, `2149-2154` |
1289
+ | `sandboxes.fromId(id)` makes a handle with no call | `sandbox.ts:960-962` |
1290
+ | `sandboxes.list({ appId, tags })`: running sandboxes only (`includeFinished: false`), with at least those tags | `sandbox.ts:1116-1159`, `1223-1230` |
1291
+ | `getTags()`, `poll()` (null while running, else the exit code), `terminate()` | `sandbox.ts:1813-1838`, `2761-2772`, `2238-2252` |
1292
+ | `terminate()` returns once the request is sent; it waits for the sandbox to finish only with `{ wait: true }` | `sandbox.ts:1292-1296`, `2238-2251` |
1293
+ | `poll()` is `SandboxWait` with timeout 0: null until the server reports a result, then its exit code (137 when terminated) | `sandbox.ts:1491-1511`, `1974-1980`, `2761-2771` |
1294
+ | `sandboxes.fromId(id)` makes a handle with no call | `sandbox.ts:960-962` |
1295
+ | terminate sends SIGKILL: a terminated sandbox's code is 137 | [guide/sandboxes#return-codes](https://modal.com/docs/guide/sandboxes#return-codes) |
1296
+ | A sandbox carries up to 10 tags | [guide/sandboxes#tagging](https://modal.com/docs/guide/sandboxes#tagging) |
1297
+ | `apps.fromName(name, { createIfMissing })` | `app.ts:32-61` |
1298
+ | SDK errors are named (`NotFoundError`, `InvalidError`, `ConflictError`) | `errors.ts:94-123` |
1299
+ | `cpu` is physical cores, 1 core = 2 vCPUs; default request 0.125 cores and 128 MiB; limits cap the burst | [guide/sandbox-resources](https://modal.com/docs/guide/sandbox-resources) |
1300
+ | No pids limit in the SDK's params | `sandbox.ts:356-474` (searched: none) |
1301
+ | `blockNetwork` drops all outbound traffic, DNS included | [guide/sandbox-networking#outbound-access-control](https://modal.com/docs/guide/sandbox-networking#outbound-access-control) |
1302
+ | CIDR allowlist: any protocol, every port; domain allowlist: beta, TLS on 443 only, matched by SNI; the two combine | [guide/sandbox-networking](https://modal.com/docs/guide/sandbox-networking); `sandbox.ts:416-420` |
1303
+ | No count limit on CIDR entries is documented | [guide/sandbox-networking](https://modal.com/docs/guide/sandbox-networking) (searched: none) |
1304
+ | No read-back of a sandbox's network policy | `modal_proto/task_command_router.proto:434-437`, `modal_proto/api.proto:5936-5937` (setters only; searched both for a getter: none) |
1305
+ | `updateNetworkPolicy` cannot change a sandbox made with `blockNetwork`, and updates only an allowlist set at create | [guide/sandbox-networking#dynamic-policy-limitations](https://modal.com/docs/guide/sandbox-networking#dynamic-policy-limitations); `sandbox.ts:2631` |
1306
+ | No stopped state: terminate is the only end, so `release` declares `["delete"]` and refuses `stop` | `sandbox.ts:2238-2262`; [guide/sandboxes#lifecycle](https://modal.com/docs/guide/sandboxes#lifecycle) |
1307
+ | The client reads `MODAL_TOKEN_ID` and `MODAL_TOKEN_SECRET`, else the active `~/.modal.toml` profile, itself | `config.ts:125-145`; `client.ts:123` |
1308
+ | A `tokenId` and `tokenSecret` passed to `ModalClient` replace both, and clear any OAuth credentials | `client.ts:124-148` |
1309
+ | The server is `MODAL_SERVER_URL`, else the profile's `server_url`, else `https://api.modal.com:443`; the profile is `MODAL_PROFILE`'s or the active one in `MODAL_CONFIG_PATH` or `~/.modal.toml` | `config.ts:76-82`, `126-143` |
1310
+ | `ModalClient` declares `endpoint` and never reads it; `getProfile` runs once, at construction, and the control-plane client is made then | `client.ts:51`, `123`, `175`, `281` |
1311
+ | With a profile's `sandboxV2`, create and list go to the V2 backend, and list then covers both | `sandbox.ts:808-815`, `884-889`, `1116-1122`, `1161-1175` |
1312
+
1313
+ ### What waits for a live probe
1314
+
1315
+ Nothing here has run against Modal. Once the lead OKs a key by name, `AGENTRUN_COMPUTER_LIVE_MODAL=1 npm run test:modal
1316
+ -w @parcha/agentrun-computer` runs the conformance suite (`test/modal/`), and should settle:
1317
+
1318
+ - that the image's `sh` runs the entrypoint as the main process, and the upload streams in through exec's stdin with
1319
+ network none, within `uploadMs`, and its sha256 reads back;
1320
+ - with `COMPUTER_MODAL_DAEMON_IMAGE` only: that Modal's builder takes `COPY --from=<registry image>@sha256:...` and
1321
+ keeps the file's mode 0755;
1322
+ - that `computerd init` starts as root and `--user` drops as it does under Docker; whether it is PID 1 on the VM runtime
1323
+ (init says so on stderr when it is not, and still reaps as a subreaper);
1324
+ - that a workdir other than `/work` exists before the command starts, and `/run` is writable there;
1325
+ - the tag value's longest length (the spec tag is JSON) and whether `getTags` answers for a terminated sandbox;
1326
+ - that `terminate` of a finished sandbox does not throw; a live run saw `list` still yield a sandbox right after its
1327
+ terminate, which `release` and `list` now wait out and leave out (above);
1328
+ - the probe's view of `blockNetwork`, and the bypass cases before any allowlist is declared.
1329
+
1330
+ Core `provider.stop` expects Modal's refusal (it declares no stop), and the Full `provider.janitor` case is skipped
1331
+ (`lifetime:janitor`, `release:stop`).
1332
+
1333
+ `create(options)` in `dist/modal.js` builds a real client from `options.tokenId` and `options.tokenSecret`, and the
1334
+ provider in `options.app` (required: without it, it refuses in words naming the option, before any client). It reads no
1335
+ setting from the environment (see [Settings](#settings)) and passes the token to `ModalClient` explicitly, so a
1336
+ `MODAL_TOKEN_ID` or `MODAL_TOKEN_SECRET` on the host is never used. The key goes only to `options.serverUrl`, else the
1337
+ SDK's default `https://api.modal.com:443`: since the client cannot take a server, it refuses while `MODAL_SERVER_URL`
1338
+ is set, and sets it to its choice only while it constructs the client, one construction at a time and put back after
1339
+ each, so neither `MODAL_PROFILE` nor a profile in `MODAL_CONFIG_PATH` or `~/.modal.toml` can redirect the key. With
1340
+ `options.daemonImage` the daemon is copied from that image (given `options.daemonPath` too, the image wins and nothing
1341
+ is uploaded); without it, it is uploaded from `options.daemonPath`, else `dist/computerd-linux-amd64`, so a run
1342
+ publishes nothing.
1343
+
1344
+ The conformance module, `dist/conformance/modal.js` (`--provider modal`), reads the run's settings from its own names
1345
+ (`settingsFromEnv`) and passes each to `create()` as its option: `COMPUTER_MODAL_TOKEN_ID` and
1346
+ `COMPUTER_MODAL_TOKEN_SECRET` (never `MODAL_TOKEN_ID` or `MODAL_TOKEN_SECRET`: a host may hold a production token under
1347
+ those names, and with only them set it refuses, naming the `COMPUTER_MODAL_` pair), `COMPUTER_MODAL_APP`, and, if set,
1348
+ `COMPUTER_MODAL_SERVER_URL` and `COMPUTER_MODAL_DAEMON_IMAGE`. It builds its provider only with
1349
+ `AGENTRUN_COMPUTER_LIVE_MODAL=1` set, checked before anything else. Its
1350
+ `createDriftedProvider()` uploads a daemon it builds with Go as version `<version>-drift` into a
1351
+ temporary directory, so Go must be on PATH. Every computer of a run gets `maxLifetimeMs` 30 minutes: Modal's timeout
1352
+ is its lifetime, and a longer one is refused in words. The modal package is the host's; it is imported only when a
1353
+ provider is made.
1354
+
1355
+ A live run is wrapped in the sweep, `dist/conformance/modal-sweep.js`. It reads only `COMPUTER_MODAL_TOKEN_ID`,
1356
+ `COMPUTER_MODAL_TOKEN_SECRET`, `COMPUTER_MODAL_APP` and `COMPUTER_MODAL_SERVER_URL`, through the conformance module's
1357
+ `settingsFromEnv`, and makes its client the same pinned way (an ambient `MODAL_SERVER_URL` is refused; it needs no live switch, since it makes nothing):
1358
+
1359
+ ```sh
1360
+ node packages/computer/dist/conformance/modal-sweep.js --before /tmp/modal-before.json
1361
+ AGENTRUN_COMPUTER_LIVE_MODAL=1 npm run test:modal -w @parcha/agentrun-computer
1362
+ node packages/computer/dist/conformance/modal-sweep.js --after /tmp/modal-before.json
1363
+ ```
1364
+
1365
+ `--before` records the app, the server (`COMPUTER_MODAL_SERVER_URL`, else the SDK's default) and the id of every
1366
+ sandbox in the app carrying `agentrun.computer=1` (`sandboxes.list({ appId, tags })`, which lists running sandboxes
1367
+ only, so a finished one needs no sweep). `--after` refuses, exit 2, before it lists anything, a file whose app or
1368
+ server is not the one the environment names now, or that names none: every computer of another app would read as
1369
+ new. Otherwise it terminates every such sandbox not in that file, reads each back through `sandboxes.fromId` and `poll()` until it reports an exit code or Modal no
1370
+ longer knows it (up to 60 s each), and prints one line, `{"swept":n,"gone":m,"stillThere":[ids]}`. It exits 0 when
1371
+ every swept sandbox has finished, 1 when one still runs, and 2 on a usage error, an unreadable before file or one of
1372
+ another app or server, a missing token or app, or a listing Modal refused, having terminated nothing. A sandbox in the before file is never
1373
+ named by any call.
1374
+
1375
+ ## Daytona
1376
+
1377
+ ```ts
1378
+ import { DaytonaProvider } from "@parcha/agentrun-computer";
1379
+
1380
+ const daytona = new DaytonaProvider({ apiKey, daemonPath: "dist/computerd-linux-amd64" });
1381
+ const made = await daytona.create({ image: "my-snapshot", lifetimeMs: 600_000, network: "none" });
1382
+ ```
1383
+
1384
+ A Daytona computer is a sandbox made through Daytona's v0 REST API with `fetch`, as pi-transport's Daytona box does:
1385
+ no SDK, and no package beyond this one. `fetch` and the WebSocket factory are options, so the tests run against a fake.
1386
+ The key is the caller's to pass: the provider never reads the environment, never sends the key over a redirect or to a
1387
+ toolbox URL that is not https, and never puts it in a computer. `image` is a Daytona snapshot, by id or name: the
1388
+ snapshot gives the sandbox its class and its size. `image: "default"` sends no snapshot field at all, and Daytona makes
1389
+ the sandbox from its default snapshot; the provider never guesses a snapshot's name. (A snapshot that is itself named
1390
+ `default` is reached by its id.) Daytona reports only the snapshot it resolved, by its own name, so create records the
1391
+ image it was asked for in the label `agentrun.computer.image`, beside the deadline's in the provider's own namespace,
1392
+ and attach reports that as `image` and the resolved snapshot apart, as `snapshot`.
1393
+
1394
+ ### Lifetimes
1395
+
1396
+ Every sandbox ends at its TTL (`ttlMinutes`, from `lifetimeMs`). Two options bound it further, each sent on every create
1397
+ and read back by the drift check:
1398
+
1399
+ | Option | Daytona field | Meaning | Unset |
1400
+ | --- | --- | --- | --- |
1401
+ | `autoStopMinutes` | `autoStopInterval` | Daytona stops the sandbox after this many minutes with no outside activity, whatever runs inside it; 0 is never | 0 |
1402
+ | `autoDeleteMinutes` | `autoDeleteInterval` | Daytona deletes the sandbox after it has been stopped this long; 0 deletes it as soon as it stops | never (`-1` is sent) |
1403
+
1404
+ Each is a whole number, 0 or more; the constructor refuses anything else in words. Daytona's idle timer counts toolbox
1405
+ calls (the daemon's connections are toolbox calls) but not the daemon's own work, so a computer left with no connection
1406
+ for `autoStopMinutes` stops. With `autoDeleteMinutes: 0` a stop deletes: the provider then keeps no stopped computer,
1407
+ declares `stopDeletes: true`, `release(ref, "stop")` returns once the sandbox is gone, and `list()` never shows a
1408
+ stopped one.
1409
+
1410
+ ### How the daemon gets in, and how it is reached
1411
+
1412
+ Daytona runs its own toolbox daemon as the sandbox's first process, and a snapshot we do not build has no `computerd`.
1413
+ So the provider pushes it in at create and starts it as a long-lived command, and reaches it the same way:
1414
+
1415
+ 1. Upload the static binary through the toolbox's file upload, to `/tmp/agentrun-computerd-<random>`.
1416
+ 2. Install it with `/process/execute` (the command is piped to the sandbox's shell): root-owned, mode 755, at
1417
+ `/opt/agentrun/computerd`, and make `/work` (its home) and `/run/agentrun` (its socket's directory). As root, or
1418
+ through passwordless `sudo`; a sandbox with neither is refused in the script's words. The script prints the
1419
+ installed binary's sha256 (`sha256sum`, BusyBox's or coreutils'), which must be the uploaded one's. It makes
1420
+ `/opt/agentrun` root's, mode 755, even when the snapshot already had it, removes whatever was at the daemon's path
1421
+ first, and then holds the whole path to one rule: the binary, `/opt/agentrun`, `/opt` and `/` each owned by root
1422
+ and writable by no group and no other user (read with `ls -ldn`, so a symbolic link or an ACL on the way fails it).
1423
+ A path that fails is refused in words, with nothing installed. Only root can change an owner or a mode, so the
1424
+ rule, once it holds, holds until root changes it.
1425
+ 3. Start `computerd init --deadline <time> --user 2510:2510 --own-network` (`--user` is the `daemonUser` option) as a
1426
+ session command (`runAsync`) in the session `agentrun-computerd`, as root (through `sudo -n` when the session's user
1427
+ is not root), in a clean environment and with `/work` as its directory. Init cuts itself and its programs off from
1428
+ the toolbox (below), then drops itself: it gives `/work` and `/run/agentrun` to the daemon's user (mode 700, never
1429
+ through a symbolic link), sets `no_new_privs` and empties the capability bounding set on every thread, so a setuid
1430
+ program such as `sudo` cannot raise it, then becomes uid and gid 2510 with no supplementary groups and empties the
1431
+ inheritable set. The provider relies on no privilege tool of the
1432
+ snapshot's: the first live start failed on the snapshot's `setpriv`, and the daemon's own drop replaced it. The provider never deletes
1433
+ that session: deleting it ends init.
1434
+ 4. `connect()` starts `computerd stdio` as root the same way, in a session of its own, to reach a socket in a
1435
+ directory that is the daemon's user's alone; it only carries bytes. Init and the bridge each check the daemon's
1436
+ path against the same rule before they run it as root, and refuse in words when it fails, so a binary a user
1437
+ other than root could have swapped is never run, even on a computer attached from an older install. Its stdin is the command's input
1438
+ (`POST .../input`, whole lines, one call after another), and its stdout is the command's log stream, a WebSocket
1439
+ with `follow=true`, in which Daytona prefixes each stdout line with `01 01 01` and each stderr line with `02 02 02`
1440
+ (split output, asked for with `X-Daytona-Split-Output: true`). Input is sent with `suppressInputEcho`; a line that
1441
+ is a request or a notification, never a reply, is dropped in case a toolbox echoes input anyway. `close()` deletes
1442
+ the session, which ends the bridge and nothing else.
1443
+
1444
+ This is the protocol's first binding, stdio over the vendor's exec stream, assembled from two halves: the session
1445
+ command's input and its log stream are each one-way, and together they are the duplex byte stream `DaemonClient`
1446
+ needs. The PTY WebSocket is one duplex stream, but a terminal: echo and line discipline would have to be turned off by
1447
+ the shell before the bridge starts, and the PTY starts a shell, not a command. Daytona's V2 API (alpha) adds argv
1448
+ processes with `writeStdin` and replayable logs, which would replace the two halves when it is GA.
1449
+
1450
+ ### Security
1451
+
1452
+ The sandbox is the outer boundary, and the toolbox inside it is a way to root that the daemon's programs are cut off
1453
+ from (the loopback block):
1454
+
1455
+ - Daytona's toolbox daemon, the sandbox's first process, listens on port 2280 on every interface and checks no
1456
+ credential: its only middlewares are recovery, tracing, logging and errors, and its token is sent only with its
1457
+ telemetry. Its `/process/execute` runs any command as the toolbox's user. That user in the default snapshot has
1458
+ passwordless `sudo` for every command (`daytona ALL=(ALL) NOPASSWD:ALL`). So whatever reaches the toolbox reaches
1459
+ root inside the sandbox.
1460
+ - So init starts with `--own-network` (see [Init, the socket and the bridge](#init-the-socket-and-the-bridge)): the
1461
+ daemon and every program it starts run in a network namespace of their own, with their loopback alone, and reach
1462
+ neither port 2280 on the loopback nor the sandbox's own address; vsock and io_uring are refused to them; and init
1463
+ refuses to start while another process holds their uid, so a toolbox (or a session shell of its) that runs as the
1464
+ daemon's user is refused, not shared. `capabilities().vendorAgentPorts` declares 2280, and the Core case
1465
+ isolation.vendor-agent probes it from a program of the computer's user, on both loopbacks. A runner whose root may
1466
+ not make a network namespace (no CAP_SYS_ADMIN: a container class on a runner that is not privileged) fails closed:
1467
+ init refuses to start, in words, and create deletes the sandbox.
1468
+ - The provider still installs and starts the daemon through that toolbox, as root or through passwordless `sudo`, and
1469
+ refuses a sandbox with neither; anyone with the API key can run a command as root in the sandbox the same way.
1470
+ - The daemon's user (2510:2510, no capabilities, `no_new_privs` and the seccomp filter on every thread) stops a
1471
+ program from raising itself through `sudo` or a setuid file. The rule that keeps the daemon's path root's alone
1472
+ holds the binary root runs.
1473
+ - Network `none` is `networkBlockAll` (Daytona drops what leaves the sandbox on the host) and, beside it, the
1474
+ daemon's own namespace. Known gap: `open` and allowlists are refused in words until a proxy carries them out of the
1475
+ daemon's own network, the next feature after this one; a computer that needs pip, npm or git from the internet
1476
+ cannot be made on Daytona until then. `network()` refuses a change to them, and still narrows a computer made
1477
+ before (open or a list) to none.
1478
+ - From outside, anyone with the API key can run a command as root in the sandbox through the same toolbox.
1479
+
1480
+ Daytona's container class runs code as root, and the open runner runs it privileged.
1481
+
1482
+ What a Daytona computer's programs cannot do: reach any network but their own loopback, reach the toolbox, or outlive
1483
+ the TTL.
1484
+
1485
+ ### Capabilities
1486
+
1487
+ | Capability | Declared | Why |
1488
+ | --- | --- | --- |
1489
+ | `kind` | `linux` | a Linux shell with computerd: exec, files and processes |
1490
+ | `lifetime` | `vendor` | `ttlMinutes` destroys the sandbox in any state once it elapses; set to the lifetime in whole minutes, rounded up. Init also ends every process at the deadline itself. |
1491
+ | `network` | `none` | `networkBlockAll`, read back from the sandbox, and the daemon's own network namespace; open and allowlists wait for a proxy out of it (known gap) |
1492
+ | `vendorAgentPorts` | `[2280]` | the toolbox's port, on every interface; isolation.vendor-agent checks a program of the computer's user reaches it on neither loopback |
1493
+ | `isolation` | `container`, or `vm` with `sandboxClass: "linux-vm"` | the class comes from the snapshot, and is read back |
1494
+ | `os` | `linux` | Linux classes only; Windows and macOS are not offered here |
1495
+ | `daemon` | `child` | Daytona's toolbox daemon is the sandbox's first process, and init is a session command it runs (below): deleting the session ends init, not the sandbox |
1496
+ | `groups` | `exec`, `files`, `processes` | the daemon's own, checked against its hello's `groups`, as is its `kind` |
1497
+ | `maxLifetimeMs` | 30 days | the cap `check` gives, through the shared `checkLifetime`; Daytona's TTL is whole minutes and documents no cap of its own |
1498
+ | `user` | none | the daemon runs as the provider's `daemonUser`; a spec cannot name a user |
1499
+ | `release` | `stop`, `delete` | `POST /sandbox/{id}/stop` and `DELETE /sandbox/{id}` |
1500
+ | `stopDeletes` | `true` with `autoDeleteMinutes: 0`, else `false` | `autoDeleteInterval` 0 deletes a sandbox as soon as it stops |
1501
+
1502
+ ### What the provider does
1503
+
1504
+ - `check(spec)` refuses in words, with no request: no snapshot, a lifetime that is not 1 ms to 30 days, a network
1505
+ that is not `none` (open and every allowlist alike), a label in the provider's own
1506
+ namespace (`agentrun.computer`), `cpus`, `memoryMb` or `pids` (a snapshot's size is its own), `user`, `workdir`
1507
+ (the daemon works in `/work`), and any other field.
1508
+ - `create` sends `POST /sandbox` with the name `computer-<12 hex digits>`, the snapshot (none for `"default"`), the
1509
+ labels with `agentrun.computer=1`, `agentrun.computer.deadline=<ISO time>` and `agentrun.computer.image=<the image>`, `public: false`, `ttlMinutes`,
1510
+ `autoStopInterval` (`autoStopMinutes`; unset, 0, since Daytona's idle timer counts only outside traffic and a daemon
1511
+ at work would be stopped), and `autoDeleteInterval` (`autoDeleteMinutes`; unset, -1: a stop keeps the sandbox, which
1512
+ the TTL then ends). `POST /sandbox` is never retried. A
1513
+ create that fails without a 4xx answer, or is aborted, may still have made the sandbox, so the provider deletes the
1514
+ name it chose. Then it waits for `started` (polling `GET /sandbox/{id}`), runs the drift check on that read, pushes
1515
+ in and starts the daemon, checks the daemon, and waits until the label listing shows the new computer steadily
1516
+ (Daytona's listing trails a create). Any failure, mismatch or abort after the sandbox exists deletes it, and create
1517
+ never returns ok once its signal has aborted.
1518
+ - `attach({ id })` takes a sandbox id or a computer's name; `attach({ labels })` must match exactly one computer. Only
1519
+ a sandbox with `agentrun.computer=1` and a computer's name counts. Attach runs the same drift check, with the spec
1520
+ read back from the sandbox, and, when it is started, the daemon's; a computer that drifts is refused and left as it
1521
+ is. It returns `spec`: `image`, the image create was asked for (`"default"` stays `"default"`), from its label;
1522
+ `snapshot`, the snapshot Daytona reports; the daemon's user, the network, `cpus`, `memoryMb` (Daytona's GiB times
1523
+ 1024), `/work` when the daemon was checked, and the deadline. A computer with no image label (made before create
1524
+ wrote it) reports its snapshot as `image`, and is not refused for the missing label.
1525
+ - `list(labels)` asks Daytona for `agentrun.computer=1` alone, every page, and filters the other labels itself. A
1526
+ sandbox that is `destroying` or `destroyed`, or whose desired state is `destroyed`, is going and left out.
1527
+ `started`, the states on the way to it, and `stopping` and `pausing` (on the way from it) are `running`: a stopping
1528
+ computer is reported stopped only once Daytona reads it `stopped`. The rest (`stopped`, `archived`, `paused`,
1529
+ `error`, ...) are `stopped`. A listed sandbox with no network fields is read on its own.
1530
+ - `network(ref)` reads the network back. `network(ref, policy)` refuses open and an allowlist in words, with no
1531
+ request; a change to none (of a computer made open or with a list before the loopback block) sends `POST
1532
+ /sandbox/{id}/network-settings` and reads it back whatever the answer: as asked, it is returned; unchanged, the
1533
+ change is refused in Daytona's words; anything else is put back, or, if that fails, the network is blocked, and the
1534
+ change is refused. A network is never left wider than asked.
1535
+ - `release(ref, "delete")` deletes as pi-transport does: retried on a 5xx, checked against the sandbox, with a forced
1536
+ stop before the last attempt. `release(ref, "stop")` stops. Both are idempotent, and both refuse a sandbox that is
1537
+ not this provider's.
1538
+ - Daytona is asynchronous: it answers a delete by setting the sandbox's desired state to `destroyed` and a stop by
1539
+ setting it to `stopped`, and the sandbox gets there later, through `destroying` or `stopping`. Its listing trails
1540
+ both: in the first live run, `list()` still showed a computer right after its delete returned, and showed a stopped
1541
+ one `running`. So release waits until Daytona reads the computer as release left it, twice running, by
1542
+ `GET /sandbox/{id}` and by the label listing alike: after a delete, a 404 and no listed computer; after a stop, a
1543
+ `stopped` read and a computer listed `stopped`, or, when the stop deletes (`autoDeleteMinutes: 0`), a 404 and no
1544
+ listed computer. A stop that is not under way is asked for again. It polls through `waitUntil`, with pauses that
1545
+ double from `pollMs` up to 5 s, bounded by the `goneMs` timeout for a delete and `stopMs` for a stop (120 s each, unset), and by the signal
1546
+ `release(ref, how, { signal })` takes. When the bound runs out, or the sandbox goes to `error`, release fails in
1547
+ words naming the last state Daytona read: it never reports a release it has not seen done. A create that deletes
1548
+ the sandbox it made (a failure, a mismatch, an abort) waits the same way before it returns.
1549
+ - `connect(ref)` refuses a computer that is not `started`, and a daemon whose hello is not the provider's.
1550
+ - Every call has its own timeout and takes the caller's signal; reads, the upload and deletes are retried (three tries,
1551
+ backoff), as in pi-transport; creates, session commands, input and network changes are not.
1552
+
1553
+ ### The drift check
1554
+
1555
+ From Daytona's read of the sandbox:
1556
+
1557
+ | Field | Must be |
1558
+ | --- | --- |
1559
+ | `snapshot` | the spec's image; for `"default"`, whatever Daytona names, unchecked |
1560
+ | `networkBlockAll`, `networkAllowList`, `domainAllowList`, `outboundProxyUrl` | the network declared; an outbound proxy, both lists, or block-all with a list is drift |
1561
+ | `labels` | `agentrun.computer=1`, the deadline and the image as written, every label the spec asked for |
1562
+ | `autoStopInterval`, `autoDeleteInterval` | `autoStopMinutes` (0 unset), `autoDeleteMinutes` (-1 unset), exactly |
1563
+ | `autoDestroyAt` | set, and no later than the deadline plus the TTL's minute and 2 minutes of clock skew |
1564
+ | `sandboxClass` | the provider's class |
1565
+ | `public`, `kvm`, `gpu`, `volumes`, `linkedSandboxId` | false, not true, 0, none, none |
1566
+
1567
+ From the daemon, over one connection: hello (the provider's version, `linux`, the `arch` option, every daemon
1568
+ capability), `/proc/self/status` (Uid and Gid the daemon user's four times, no groups, `NoNewPrivs: 1`, `CapInh`,
1569
+ `CapPrm`, `CapEff`, `CapBnd` and `CapAmb` all zero), `/proc/self/cwd` (`/work`) and `/proc/self/exe`
1570
+ (`/opt/agentrun/computerd`); and the installed binary's sha256 from the install.
1571
+
1572
+ ### Conformance on Daytona
1573
+
1574
+ `create(options)` in `dist/daytona.js` builds the provider from its options alone and reads no environment (see
1575
+ [Settings](#settings)): `apiKey` (required), `apiUrl` (default `https://app.daytona.io/api`), `target` (default the
1576
+ organization's), `daemonPath`, `arch` (`amd64` or `arm64`), `sandboxClass` (`container` or `linux-vm`) and `daemonUser`.
1577
+ The conformance module, `dist/conformance/daytona.js` (`--provider daytona`), reads the run's settings by these names
1578
+ when it runs (`settingsFromEnv`) and passes each to `create()` as the option in brackets: `COMPUTER_DAYTONA_API_KEY`
1579
+ (`apiKey`, required), `COMPUTER_DAYTONA_API_URL` (`apiUrl`), `COMPUTER_DAYTONA_DAEMON` (`daemonPath`),
1580
+ `COMPUTER_DAYTONA_ARCH` (`arch`), `COMPUTER_DAYTONA_TARGET` (`target`), `COMPUTER_DAYTONA_CLASS` (`sandboxClass`) and
1581
+ `COMPUTER_DAYTONA_USER` (`daemonUser`). It exports `createProvider()` and `createDriftedProvider()` (which builds a
1582
+ daemon of another version with Go), and reads `COMPUTER_DAYTONA_SNAPSHOT` (the run's image; unset, `"default"`,
1583
+ Daytona's default snapshot). It never reads `DAYTONA_API_KEY`, `DAYTONA_API_URL` or `DAYTONA_TARGET`, not even as a
1584
+ fallback: on a host that runs other Daytona work they may hold another organization's key. Those are serve's names,
1585
+ which serve passes in itself.
1586
+
1587
+ Every sandbox of a run has a bounded life besides its TTL: the module always sets `autoStopMinutes: 30` and
1588
+ `autoDeleteMinutes: 0`, whatever the environment says. A stop therefore deletes, and the provider declares it
1589
+ (`stopDeletes: true`): Core `provider.stop` holds it to that and passes when the stopped computer is gone, neither
1590
+ listed nor attachable. Full `provider.janitor`, which needs a stopped computer kept, is skipped (the lifetime is
1591
+ `vendor`, and a stop keeps none). The module exports `conformanceImage()` and `conformanceNotes`; the CLI takes the
1592
+ image from it when `--image` names none, and prints the note above the verdict (`notes` in `--json`).
1593
+
1594
+ ```sh
1595
+ npm run conformance -w @parcha/agentrun-computer -- --provider daytona [--image <snapshot>]
1596
+ ```
1597
+
1598
+ ### The sweep around a live run
1599
+
1600
+ `dist/conformance/daytona-sweep.js` reads the same `COMPUTER_DAYTONA_API_KEY` and `COMPUTER_DAYTONA_API_URL`, through
1601
+ the conformance module:
1602
+
1603
+ ```sh
1604
+ node packages/computer/dist/conformance/daytona-sweep.js --before /tmp/daytona-before.json # before the run
1605
+ node packages/computer/dist/conformance/daytona-sweep.js --after /tmp/daytona-before.json # after it
1606
+ ```
1607
+
1608
+ `--before <file>` writes the id of every sandbox carrying `agentrun.computer=1`, whatever its name or state, into the
1609
+ file. `--after <file>` lists them again and deletes (`release(ref, "delete")`) every one whose id is not in the file,
1610
+ then reads each with `GET /sandbox/{id}` until Daytona answers 404, up to 60 s each, and prints one JSON line,
1611
+ `{"swept":n,"notFound":m,"stillThere":[ids]}`, where `swept` counts the sandboxes not there before and `notFound` plus
1612
+ `stillThere`'s length is `swept`. A sandbox in the file is never named by any call. A new sandbox without a computer's
1613
+ name is not this provider's: release refuses it, and it is reported still there. Exit 0 when every swept sandbox reads
1614
+ 404, 1 when one is still there, 2 on a usage error, a before file it cannot read, no key, or a listing Daytona refused
1615
+ (nothing is deleted then). Anything else that creates a labelled sandbox between the two runs is swept too.
1616
+
1617
+ ### Not yet known
1618
+
1619
+ Four live runs reached the default snapshot. The first failed at the start, in the privilege tool init's own drop now
1620
+ replaces; the second passed Core 48 of 52, its failures a delete or a stop Daytona had answered but not done (release
1621
+ now waits for both) and the resolved snapshot reported as the image (the image label now answers it); the third passed
1622
+ Core 52/52. The fourth, after the re-stack, passed Core 53/53 with the 9 optional cases of groups a linux computer does
1623
+ not declare skipped, Full 4/10, and the sweep after it found nothing to delete. Since then the report files those 9
1624
+ under `optional` (a wording change), and the daemon's path is held root's alone (above), which has not run live: a
1625
+ default snapshot whose `/opt` another user can write would now be refused at create. These need a live probe:
1626
+
1627
+ - whether the production toolbox honors `suppressInputEcho` and `X-Daytona-Split-Output`, and keeps a session's
1628
+ command running between calls;
1629
+ - whether a session's labeller (a shell `read` per line) carries 1 MiB lines at a usable speed, and how big a
1630
+ connection's log may grow: every reply stays in the session's log on the sandbox's disk until `close()`;
1631
+ - `autoStopInterval` and `autoDeleteInterval` as read back, how soon after a stop `autoDeleteInterval: 0` deletes,
1632
+ which snapshot Daytona names for a sandbox made with none, and how soon after `autoDestroyAt` Daytona destroys;
1633
+ - how long `GET /sandbox/{id}` takes to answer 404 after a delete, and the listing to hide the sandbox (release waits
1634
+ for both, up to `goneMs`); how long a stop takes to read `stopped`;
1635
+ - how soon the label listing shows a new sandbox;
1636
+ - the ports a CIDR list opens on the production runner, and whether a domain list blocks every port but 80 and 443;
1637
+ - `network: none` against the live bypass cases (ruling 9), on each class;
1638
+ - the linux-vm class end to end.
1639
+
1640
+ ### Sources
1641
+
1642
+ Every Daytona path, field and limit above. `daytona/clients@8006f63e` is the v0 SDKs and OpenAPI specs at v0.230.0;
1643
+ `daytonaio/daytona@b5a5d9e7` is the open platform at v0.190.0, frozen in June 2026; `agentrun@7907382ed` is this
1644
+ repository's main; the docs were read on 2026-11-05.
1645
+
1646
+ | Fact | Citation |
1647
+ | --- | --- |
1648
+ | `POST /sandbox`, `GET` and `DELETE /sandbox/{sandboxIdOrName}` | `daytona/clients@8006f63e:openapi-specs/api.json:2702`, `daytona/clients@8006f63e:openapi-specs/api.json:3163` |
1649
+ | `CreateSandbox`: `name`, `snapshot`, `env`, `labels`, `public`, `networkBlockAll`, `networkAllowList`, `domainAllowList`, `target`, `autoStopInterval`, `autoDeleteInterval`, `ttlMinutes` | `daytona/clients@8006f63e:openapi-specs/api.json:12069-12208` |
1650
+ | `Sandbox` read back: `snapshot`, `labels`, `public`, `networkBlockAll`, `kvm`, `networkAllowList`, `domainAllowList`, `outboundProxyUrl`, `cpu`, `gpu`, `memory`, `state`, `errorReason`, `autoStopInterval`, `autoDeleteInterval`, `autoDestroyAt`, `volumes`, `sandboxClass`, `linkedSandboxId`, `toolboxProxyUrl` | `daytona/clients@8006f63e:openapi-specs/api.json:12295-12593` |
1651
+ | `SandboxState` values, among them `stopping`, `pausing`, `destroying`, `destroyed` and `error` | `daytona/clients@8006f63e:openapi-specs/api.json:11704` |
1652
+ | a delete sets the desired state `destroyed` and leaves the state to change later; a stop sets the desired state `stopped`, or, with `autoDeleteInterval` 0, deletes the same way | `daytonaio/daytona@b5a5d9e7:apps/api/src/sandbox/services/sandbox.service.ts:2013-2039`, `daytonaio/daytona@b5a5d9e7:apps/api/src/sandbox/services/sandbox.service.ts:2151-2185`, `daytonaio/daytona@b5a5d9e7:apps/api/src/sandbox/entities/sandbox.entity.ts:317-324`, `daytonaio/daytona@b5a5d9e7:apps/api/src/sandbox/utils/ephemeral.util.ts:6-8` |
1653
+ | a read by id or name may come from a lookup cache of 10 s | `daytonaio/daytona@b5a5d9e7:apps/api/src/sandbox/services/sandbox.service.ts:1755-1758`, `daytonaio/daytona@b5a5d9e7:apps/api/src/sandbox/utils/sandbox-lookup-cache.util.ts:6` |
1654
+ | `GET /sandbox?labels=<JSON>&limit&cursor`, a page of `items` and `nextCursor` | `daytona/clients@8006f63e:openapi-specs/api.json:2702`, `daytona/clients@8006f63e:openapi-specs/api.json:2717`, `daytona/clients@8006f63e:openapi-specs/api.json:2756`, `daytona/clients@8006f63e:openapi-specs/api.json:12000` |
1655
+ | `POST /sandbox/{sandboxIdOrName}/stop`, `force` | `daytona/clients@8006f63e:openapi-specs/api.json:3393`, `daytona/clients@8006f63e:openapi-specs/api.json:3416` |
1656
+ | `POST /sandbox/{sandboxIdOrName}/network-settings` | `daytona/clients@8006f63e:openapi-specs/api.json:4573`, `daytona/clients@8006f63e:openapi-specs/api.json:12721` |
1657
+ | `GET /sandbox/{sandboxId}/toolbox-proxy-url`; the toolbox at `toolboxProxyUrl` + `/` + id | `daytona/clients@8006f63e:openapi-specs/api.json:5235`; `daytona/clients@8006f63e:sdk-typescript/src/Sandbox.ts:1566-1573` |
1658
+ | `Authorization: Bearer <key>` | `daytona/clients@8006f63e:sdk-typescript/src/Daytona.ts:444` |
1659
+ | `POST /files/upload-v2?path=`, multipart field `file` | `daytona/clients@8006f63e:openapi-specs/toolbox.json:2031` |
1660
+ | `POST /process/execute` `{command, timeout}` to `{exitCode, result}`; the command piped to the shell | `daytona/clients@8006f63e:openapi-specs/toolbox.json:3234`, `daytona/clients@8006f63e:openapi-specs/toolbox.json:4679`, `daytona/clients@8006f63e:openapi-specs/toolbox.json:4703`; `daytonaio/daytona@b5a5d9e7:apps/daemon/pkg/toolbox/process/execute.go:55-57` |
1661
+ | `POST /process/session` `{sessionId}`; a session's shell runs as the toolbox's own user | `daytona/clients@8006f63e:openapi-specs/toolbox.json:3636`, `daytona/clients@8006f63e:openapi-specs/toolbox.json:4525`; `daytonaio/daytona@b5a5d9e7:apps/daemon/pkg/session/create.go:20-24` |
1662
+ | `POST /process/session/{sessionId}/exec` `{command, runAsync, suppressInputEcho}` to `{cmdId}` | `daytona/clients@8006f63e:openapi-specs/toolbox.json:4017`, `daytona/clients@8006f63e:openapi-specs/toolbox.json:5922`, `daytona/clients@8006f63e:openapi-specs/toolbox.json:5935` |
1663
+ | `POST .../command/{commandId}/input` `{data}`; a newline added to data without one, and input echoed to stdout unless suppressed | `daytona/clients@8006f63e:openapi-specs/toolbox.json:3891`, `daytona/clients@8006f63e:openapi-specs/toolbox.json:5961`; `daytonaio/daytona@b5a5d9e7:apps/daemon/pkg/session/input.go:47-71` |
1664
+ | `GET .../command/{commandId}/logs?follow=true` as a WebSocket | `daytona/clients@8006f63e:openapi-specs/toolbox.json:3954`, `daytona/clients@8006f63e:openapi-specs/toolbox.json:3979`; `daytona/clients@8006f63e:sdk-typescript/src/Process.ts:437` |
1665
+ | stdout and stderr lines prefixed `01 01 01` and `02 02 02`, one prefix a line | `daytona/clients@8006f63e:sdk-typescript/src/Process.ts:26-27`; `daytonaio/daytona@b5a5d9e7:apps/daemon/pkg/session/execute.go:196-236` |
1666
+ | split output with `X-Daytona-Split-Output: true` | `daytonaio/daytona@b5a5d9e7:apps/daemon/pkg/session/common.go:17-19` |
1667
+ | `DELETE /process/session/{sessionId}` ends the session's process group and tree | `daytona/clients@8006f63e:openapi-specs/toolbox.json:3770`; `daytonaio/daytona@b5a5d9e7:apps/daemon/pkg/session/delete.go:18-70` |
1668
+ | `ttlMinutes` destroys in any state; `autoStopInterval: 0` runs indefinitely and keeps the TTL | https://www.daytona.io/docs/en/sandboxes.md#wall-clock-ttl, https://www.daytona.io/docs/en/sandboxes.md#running-indefinitely |
1669
+ | the idle timer ignores processes inside the sandbox | https://www.daytona.io/docs/en/sandboxes.md#auto-stop-sandboxes ("What does not reset the timer") |
1670
+ | `autoDeleteInterval` negative is disabled, 0 deletes as soon as the sandbox stops; in minutes | `daytona/clients@8006f63e:openapi-specs/api.json:12199`; https://www.daytona.io/docs/en/sandboxes.md#auto-delete-interval |
1671
+ | `autoStopInterval` in minutes, 0 is disabled; a negative one is refused | `daytona/clients@8006f63e:openapi-specs/api.json:12184`; `daytonaio/daytona@b5a5d9e7:apps/api/src/sandbox/services/sandbox.service.ts:3290-3295` |
1672
+ | auto-stop triggers even with processes running inside; toolbox requests reset the timer | https://www.daytona.io/docs/en/sandboxes.md#auto-stop-interval |
1673
+ | both intervals are kept as sent | `daytonaio/daytona@b5a5d9e7:apps/api/src/sandbox/services/sandbox.service.ts:663-673` |
1674
+ | a create with no snapshot uses the default snapshot | https://www.daytona.io/docs/en/linux-sandboxes.md#create-a-linux-sandbox; `daytonaio/daytona@b5a5d9e7:apps/api/src/sandbox/services/sandbox.service.ts:471-475` |
1675
+ | `GET /sandbox/{id}` of a destroyed sandbox is a 404 | `daytonaio/daytona@b5a5d9e7:apps/api/src/sandbox/services/sandbox.service.ts:1744`, `daytonaio/daytona@b5a5d9e7:apps/api/src/sandbox/services/sandbox.service.ts:1777-1783` |
1676
+ | block-all, the CIDR list and the domain list are mutually exclusive, a conflict is a 400 | https://www.daytona.io/docs/en/network-limits.md#create-sandboxes-with-network-restrictions |
1677
+ | at most 10 IPv4 CIDRs, `A.B.C.D/N`, N 0 to 32 | https://www.daytona.io/docs/en/network-limits.md#network-allow-list-format |
1678
+ | at most 100 domains, `*.` wildcards, no scheme, path or port | https://www.daytona.io/docs/en/network-limits.md#domain-allow-list-format |
1679
+ | the domain list covers web ports 80 and 443 | `daytona/clients@8006f63e:openapi-specs/api.json:12135` |
1680
+ | the domain list's proxy re-signs TLS with a Daytona CA | https://www.daytona.io/docs/en/network-limits.md#https-traffic |
1681
+ | a CIDR allowed on every protocol and port, in the open runner | `daytonaio/daytona@b5a5d9e7:apps/runner/pkg/netrules/set.go:33-41` |
1682
+ | Tier 1 and 2 cannot override the network per sandbox | https://www.daytona.io/docs/en/network-limits.md#tier-based-network-restrictions |
1683
+ | a change: block-all clears both lists, `false` alone clears both, an empty list clears one | https://www.daytona.io/docs/en/network-limits.md#update-network-settings-while-a-sandbox-is-running |
1684
+ | the container class runs code as root; classes `linux-vm`, `container`, `windows` | https://www.daytona.io/docs/en/isolation.md#runtime-isolation; `daytona/clients@8006f63e:openapi-specs/api.json:10473` |
1685
+ | the toolbox listens on `:2280`, every interface; its middlewares are recovery, tracing, logging and errors; `/process/execute` | `daytonaio/daytona@b5a5d9e7:apps/daemon/pkg/toolbox/server.go:136-158`, `daytonaio/daytona@b5a5d9e7:apps/daemon/pkg/toolbox/server.go:199-203`, `daytonaio/daytona@b5a5d9e7:apps/daemon/pkg/toolbox/server.go:374-388`, `daytonaio/daytona@b5a5d9e7:apps/daemon/pkg/toolbox/config/config.go:6`; `apps/daemon/pkg/toolbox/middlewares/` holds only `error.go` |
1686
+ | the toolbox's token is set by `/init` and sent only as a telemetry header | `daytonaio/daytona@b5a5d9e7:apps/daemon/pkg/toolbox/controller.go:33`, `daytonaio/daytona@b5a5d9e7:apps/daemon/pkg/toolbox/telemetry.go:46` |
1687
+ | the default snapshot's user `daytona` has `NOPASSWD:ALL` sudo | `daytonaio/daytona@b5a5d9e7:images/sandbox/Dockerfile:78`, `daytonaio/daytona@b5a5d9e7:images/sandbox/Dockerfile:96`, `daytonaio/daytona@b5a5d9e7:images/sandbox/README.md:3`; the same `RUN` line in the history of `daytonaio/sandbox:0.11.0` (config `sha256:f6b4fc1ac093`), the snapshot a create with none resolved to in a live run |
1688
+ | `networkBlockAll` drops the sandbox's outgoing packets on the host (`DOCKER-USER`, by source address) | `daytonaio/daytona@b5a5d9e7:apps/runner/pkg/docker/create.go:242-248`, `daytonaio/daytona@b5a5d9e7:apps/runner/pkg/netrules/set.go:40-49` |
1689
+ | non-GPU containers run privileged in the open runner | `daytonaio/daytona@b5a5d9e7:apps/runner/pkg/docker/container_configs.go:200-206` |
1690
+ | memory in GiB | https://www.daytona.io/docs/en/sandboxes.md#resources |
1691
+ | a snapshot's size is its own; delete with retries and a forced stop; the listing trails a create; no redirect followed; three tries with backoff | `agentrun@7907382ed:packages/pi-transport/src/box/daytona.ts:913`, `agentrun@7907382ed:packages/pi-transport/src/box/daytona.ts:799-817`, `agentrun@7907382ed:packages/pi-transport/src/box/daytona.ts:819-824`, `agentrun@7907382ed:packages/pi-transport/src/box/daytona.ts:343`, `agentrun@7907382ed:packages/pi-transport/src/box/daytona.ts:35-36` |
1692
+ | auto-delete off with `-1` | `agentrun@7907382ed:packages/serve/src/daytona-api.ts:37` |
1693
+
1694
+ ## E2B
1695
+
1696
+ ```ts
1697
+ import { providerFor } from "@parcha/agentrun-computer";
1698
+
1699
+ // The key is the caller's to pass (serve's E2B_API_KEY), and the e2b package is the host's own (npm e2b 2.63.0).
1700
+ const e2b = await providerFor("e2b", { apiKey });
1701
+ const made = await e2b.create({ image: "desktop", lifetimeMs: 600_000, network: "none" });
1702
+ ```
1703
+
1704
+ An E2B computer is a sandbox made from an E2B template, by default `desktop`, E2B Desktop's (Ubuntu 22.04 with Xvfb,
1705
+ Xfce, x11vnc and noVNC, e2b-dev/desktop `template/template.py:3-65`). It is kind `desktop`: computerd starts the X
1706
+ server itself, as on a Docker desktop, and its X11 shim drives it. With `kind: "linux"` it is kind `linux`
1707
+ on any template, `base` by default, with no display: the same provider, minus the X server, so it costs nothing to
1708
+ offer. Every call goes through the host's E2B JS SDK, the `e2b` package's `Sandbox` class, of which `src/e2b.ts` names
1709
+ only the slice it calls (`E2BSandboxClass`) and imports nothing at load; the package is the host's to install, as
1710
+ Modal's is. `@e2b/desktop` is not used: it starts Xvfb and Xfce with `commands.run`, outside computerd's process table
1711
+ and with no bound or abort (`@e2b/desktop@2.5.0` `dist/index.mjs:387-415`), and the provider needs none of its other
1712
+ calls.
1713
+
1714
+ ### The key
1715
+
1716
+ `create(options)` takes the key as `options.apiKey` and nowhere else; without it, it refuses in words that name the
1717
+ option, never the key. It reads no setting from the environment (see [Settings](#settings)): serve passes its own
1718
+ `E2B_API_KEY`, and the conformance module the `COMPUTER_E2B_API_KEY` it reads, never `E2B_API_KEY`, whose value may be
1719
+ another team's on a shared host. The SDK reads `E2B_API_KEY`, `E2B_DOMAIN`, `E2B_API_URL` and `E2B_DEBUG` from
1720
+ `process.env` whenever it is not given them (`index.mjs:1140-1152`, `1177-1191`), so every call is given the key, the
1721
+ domain (`options.domain`, default `e2b.app`), the API URL `https://api.<domain>` and `debug: false` explicitly: with
1722
+ debug on, the SDK fakes a create and skips a kill (`index.mjs:5402`, `6021-6024`). The SDK also takes
1723
+ `E2B_SANDBOX_URL` when it is given no sandbox URL, and no option clears it (`index.mjs:1152`, `1183-1185`): it would
1724
+ send every call into a sandbox, the upload and the bridge with it, there. So the provider refuses to start while it is
1725
+ set in `process.env`: a read, and the library's one touch of E2B's environment. A unit test hands the provider's options
1726
+ to the real SDK's `ConnectionConfig` with all four ambient variables set, and reads back the provider's own.
1727
+
1728
+ ### How the daemon gets in, and how it is reached
1729
+
1730
+ E2B's envd is the sandbox's first process, a systemd service with `Restart=always` (e2b-dev/infra
1731
+ `envd.service.tpl:26-30`), so computerd is a `child`, as on Daytona, and init's exit leaves the sandbox:
1732
+
1733
+ 1. `Sandbox.create(template, ...)` with the run's labels as `metadata` (the provider's own beside them:
1734
+ `agentrun.computer=1`, its name, the deadline, the image, the timeout and the most extend may reach), `timeoutMs`
1735
+ the lifetime in whole seconds (`index.mjs:502-504`, `5694`), `allowInternetAccess` (false for none),
1736
+ `network.allowPublicTraffic: false`, and `lifecycle.onTimeout: "kill"`, explicitly, so a timeout never pauses and
1737
+ keeps the computer (`index.mjs:5674-5699`). The create is raced against the caller's signal and its bound, never
1738
+ cancelled: one that lands after create gave up is killed by its id, one whose answer never comes by its name label.
1739
+ The listing shows a new sandbox a moment late, so the name is listed again until it shows or `listedMs` (15 s)
1740
+ passes, and the sandbox found is killed and read back gone, as release waits for one.
1741
+ 2. `getInfo` reads the sandbox back (below).
1742
+ 3. `files.write` uploads the daemon as root to `/tmp/agentrun-computerd-<random>` (`index.mjs:2332-2435`), and the
1743
+ same install command as Daytona's (`src/child.ts`) moves it to `/opt/agentrun/computerd`, root-owned, and prints its
1744
+ sha256, which must be the uploaded one's.
1745
+ 4. `commands.run(init, { background: true, user: "root", timeoutMs: 0 })` starts `computerd init --deadline <time>
1746
+ --user 2510:2510 --own-network --max-deadline <create's time plus the cap>` with `DISPLAY=:0`, in a clean
1747
+ environment. envd runs
1748
+ the command under `bash -l -c` (`index.mjs:5123-5146`). Its timeout is 0 because envd kills a command whose
1749
+ timeout passes, and keeps one running when its stream ends (envd `process/start.go:39-44`); the SDK's default
1750
+ would end init after 60 s (`index.mjs:4978`). Create disconnects from it after.
1751
+ 5. `connect()` starts `computerd stdio` the same way, as root, with `stdin: true` and `retainOutput: false` (so a long
1752
+ connection keeps no copy of its output, `index.mjs:2708-2711`, `5150-5153`): its stdout comes through `onStdout`
1753
+ (decoded as a stream, `index.mjs:2860`), and requests go in with `sendStdin`, one call after another.
1754
+ `close()` kills the bridge (SIGKILL, `index.mjs:5092-5095`), which ends nothing else, and disconnects from it. The
1755
+ bridge has no command timeout, so one whose start answers after the call gave up on it (its bound passed, or the
1756
+ caller aborted) is killed and disconnected as it lands.
1757
+ 6. A desktop's X server, `Xvfb :0 -screen 0 1280x800x24 -nolisten tcp`, starts through the daemon with
1758
+ `process.start`, as the computer's user, and create waits until hello declares the display (`src/desktop.ts`,
1759
+ shared with Docker). Hello re-checks the display on every call, so `connect()` refuses a desktop whose X server has
1760
+ gone (it reads back kind `linux`).
1761
+
1762
+ envd runs as root and obeys anyone with the API key, as Daytona's toolbox does, and answers on 49983 (`e2b@2.63.0`
1763
+ `dist/index.mjs:1213`, `envdPort`) inside the sandbox; the computer's daemon runs as 2510:2510 with no capability in
1764
+ any set, `no_new_privs` and the seccomp filter, and with `--own-network` it and its programs run in a network namespace
1765
+ of their own, their loopback alone (see [Init, the socket and the bridge](#init-the-socket-and-the-bridge)): no program
1766
+ of the computer's user reaches envd. `vendorAgentPorts` declares 49983, which isolation.vendor-agent probes. The X
1767
+ server runs inside that namespace too, and the daemon reaches it on its socket. envd has no `KillMode` in its unit, so a restart of envd ends every
1768
+ process in its cgroup, init with it: the computer then answers `gone`, and the caller releases it (a restarted init
1769
+ would hold an empty process table).
1770
+
1771
+ ### Capabilities
1772
+
1773
+ | Capability | Declared | Why |
1774
+ | --- | --- | --- |
1775
+ | `kind` | `desktop` (default) or `linux` | `options.kind`; a desktop's X server is computerd's own |
1776
+ | `lifetime` | `vendor` | E2B kills the sandbox at its timeout, set to the lifetime; init ends every process at the deadline too |
1777
+ | `network` | `none` | `allowInternetAccess` false, read back by `getInfo` with `network.denyOut` and `allowPublicTraffic`, and the daemon's own network namespace; `open` waits for a proxy out of it (known gap) |
1778
+ | `vendorAgentPorts` | `[49983]` | envd's port; isolation.vendor-agent checks a program of the computer's user reaches it on neither loopback |
1779
+ | `networkReadBack` | `true` | `getInfo` reports `allowInternetAccess` and `network` (`index.mjs:5432-5458`) |
1780
+ | `isolation` | `microvm` | Firecracker |
1781
+ | `daemon` | `child` | envd is the first process; init is a background command it runs |
1782
+ | `groups` | `exec`, `files`, `processes`, and on a desktop `screen`, `input.pointer`, `input.keys` | checked against hello on every connect |
1783
+ | `maxLifetimeMs` | 1 h, up to 24 h | Hobby's cap by default; `options.maxLifetimeMs` up to Pro's 24 h (`index.d.mts:10169-10172`) |
1784
+ | `release` | `delete` | `Sandbox.kill`; E2B's pause keeps a sandbox, but no release maps to it here |
1785
+
1786
+ ### Network
1787
+
1788
+ E2B can do none: `allowInternetAccess: false`, which E2B documents as `denyOut: ["0.0.0.0/0"]`
1789
+ (`index.d.mts:10179`), with no allow list, and no public traffic in. Public traffic matters as much as egress: a
1790
+ sandbox's every port has a URL, `https://<port>-<id>.<domain>` (`index.mjs:1208-1211`), and with public traffic anyone
1791
+ with that URL reaches whatever listens there, so a computer with no internet could still hand out data. The provider
1792
+ always sends `allowPublicTraffic: false` (a project's default may be public), and then a request needs the sandbox's
1793
+ traffic token as a header. `0.0.0.0/0` is IPv4, so for none the probe (`computerd probe`, through the daemon, as on
1794
+ Modal) also tries IPv4 and IPv6 addresses from inside at create and attach, the same defaults as Modal's (TCP to
1795
+ `1.1.1.1:443`, `8.8.8.8:443` and `[2606:4700:4700::1111]:443`, DNS over UDP to `1.1.1.1:53/udp` and
1796
+ `[2606:4700:4700::1111]:53/udp`, or the `probeTargets` option), and refuses the computer if one answers within the 10 s
1797
+ window (the rule every provider shares: [Network none, read from inside](#network-none-read-from-inside-nothing-answers)).
1798
+ The probe's `exec.run` is bounded at 30 s (`timeouts.probeMs`), above its longest run, 20 s. Open and an allowlist
1799
+ are refused in words while the daemon's programs have a network of their own (known gap: a proxy out of that network
1800
+ is the next feature after this one; a computer that needs pip, npm or git from the internet cannot be made on E2B
1801
+ until then). The network is fixed at create: `network(ref, policy)` refuses a change. Since the probe runs inside the
1802
+ daemon's own network, every target reads `refused` there, whatever E2B's firewall would have done; the firewall facts
1803
+ below are what a program outside that namespace meets.
1804
+
1805
+ E2B's firewall accepts an outbound TCP connection before it decides whether the destination is allowed. E2B's docs
1806
+ (network/internet-access, "Behavior of blocked TCP connections", read 2026-11-07; the copy read is
1807
+ `vendor-docs/e2b/docs-network-internet-access.md` in the review evidence) say: "The firewall has to accept the
1808
+ connection first before it can decide whether the destination is allowed. This means that, from inside the sandbox, a
1809
+ TCP connection can succeed and report the socket as open even when the destination is denied - no packets actually
1810
+ reach the destination", and to check for an application-level answer instead; and that this "may change in the
1811
+ future". `e2b-dev/infra@ff3922213` `packages/orchestrator/pkg/tcpfirewall/handlers.go` shows it: the proxy reads the
1812
+ hostname from the connection's first bytes, decides, and closes a denied connection without dialing the destination.
1813
+ E2B documents no stricter setting: `allowInternetAccess: false` is `denyOut 0.0.0.0/0`, and `dnsServers` matters only
1814
+ with a domain in `allowOut`. Under the shared rule only an answer refuses network none, so such a sandbox is kept, and
1815
+ create's and attach's `notes` name the accepted targets: `network: none; accepted with no answer (no bytes came back):
1816
+ 1.1.1.1:443, 8.8.8.8:443`. The one live diagnostic (below) read that: every IPv4 target on 443/tcp and 80/tcp accepted
1817
+ and closed with 0 bytes, no answer on 53/udp, and, in the provider's own probe, no accept from the IPv6 target. UDP
1818
+ is not proxied: the same firewall drops non-TCP to the user deny set, which `denyOut` fills, in nftables
1819
+ (`e2b-dev/infra@ff3922213` `packages/orchestrator/pkg/sandbox/network/firewall.go`, `installRules`, rule 5), so the probe's UDP targets get no reply within the 10 s window
1820
+ and read `refused`, not `accepted`, and are not named in `notes`; a reply from either refuses network none. The provider's
1821
+ own probe has not yet run its UDP targets live on E2B: the diagnostic's 53/udp checks (3 s each) are the measured read.
1822
+
1823
+ The risk that stays is one-way. From inside, the provider cannot prove that an accepted connection's outbound bytes go
1824
+ nowhere: a path that carries the request out and drops every reply reads the same as E2B's firewall. E2B says no
1825
+ packets reach the destination, and that this may change. The answered check catches any change that forwards traffic
1826
+ both ways, since the first byte back refuses network none; it does not catch a one-way leak, and nothing run from
1827
+ inside can. That is the rule for every provider, confirmed on 11-07, and why every
1828
+ accept is recorded in words rather than dropped.
1829
+
1830
+ `dist/conformance/e2b-diagnose.js` (live switch
1831
+ `AGENTRUN_COMPUTER_LIVE_E2B=1`) makes one sandbox exactly as create does for network none, with a 10-minute E2B
1832
+ timeout, records the read-back and the provider's own check (`passed` with its `notes`, or its refusal), runs
1833
+ `computerd probe --diagnose` in it (each check judged as `--connect` judges a target: any byte back is answered),
1834
+ prints one JSON line, and kills the sandbox and reads it back gone, after an error or an abort too (SIGINT, SIGTERM,
1835
+ or its own 8-minute bound). Exit 0 when a diagnosis came back and the sandbox reads gone, 1 otherwise, 2 with no live
1836
+ switch or a refused setting.
1837
+
1838
+ ### Extend and stream
1839
+
1840
+ `extend(ref, ttlMs)` sets E2B's timer to now + `ttlMs` (`Sandbox.setTimeout`, `index.mjs:5529-5541`), reads the end
1841
+ back, then moves init's own deadline there with `deadline.extend`, and returns the deadline init took. It is never
1842
+ earlier than the current end, and never past create's time plus the cap, the maximum init was given; a refusal moves
1843
+ nothing. E2B's timer is asked for whole seconds, rounded down at the cap, so it never passes the cap by this machine's
1844
+ clock; init's deadline is E2B's end up to the cap. When no whole number of seconds inside the cap reaches the deadline
1845
+ held now (init's, or E2B's own end as `getInfo` reads it), extend is refused as `limit` and moves nothing, so E2B's
1846
+ timer is never pulled under it. When init's move fails after E2B's, the error says E2B's timer moved
1847
+ and init's did not: the programs end at the old deadline, earlier than asked, never later. A provider runs one extend
1848
+ of a computer at a time, each reading the deadline the one before it left, so a slow, shorter extend never pulls E2B's
1849
+ timer under a longer one's (two providers extending one computer at once are not ordered). E2B has no call that
1850
+ changes metadata, so the deadline label stays as create wrote it, and `list()` and `attach()` report E2B's own end, up
1851
+ to the cap, once it is more than 2 s past where create set it (its start plus the timeout create gave, by E2B's clock,
1852
+ to the second E2B rounds to); extend never leaves E2B's end inside those 2 s, moving it at least 3 s past create's end,
1853
+ so an extend however short reads back.
1854
+
1855
+ There is no `stream()`: a screen is streamed through agentrun, never through a vendor URL. A URL into an E2B sandbox
1856
+ that a browser could open needs public traffic, since a private sandbox's URL needs the `e2b-traffic-access-token`
1857
+ header, which a browser cannot send (E2B docs, network/restrict-public-access). Public traffic opens every port in the
1858
+ computer to anyone with its address. So the provider takes no `publicStream` option: making one with it throws in
1859
+ words, whatever its value, and every sandbox is made with public traffic off.
1860
+
1861
+ ### What the provider does
1862
+
1863
+ - `check(spec)` refuses in words, with no call: no template, a lifetime past the cap (the shared `checkLifetime`), a
1864
+ network that is not none (open and an allowlist alike), a label in the provider's namespace,
1865
+ `cpus`, `memoryMb` or `pids` (a template's size is its own), `user`, `workdir` and any other field.
1866
+ - `create` reads the sandbox back with `getInfo` and refuses any drift: the template (its id, or its alias when E2B
1867
+ reports one), every label, the network (above), `lifecycle.onTimeout` other than `kill`, `autoResume`, a state that
1868
+ is not `running`, and an end that is not E2B's start plus the timeout create gave. Then the daemon: hello (version,
1869
+ `linux`, `amd64`, kind and groups), `/proc/self/status` (uid and gid 1000, no groups, `NoNewPrivs` 1, every
1870
+ capability set zero), `/proc/self/cwd` (`/work`), `/proc/self/exe`; and for none, the probe. It waits until the label
1871
+ listing shows the new computer. A failure, mismatch or abort at any step kills the sandbox and waits for it to go;
1872
+ create never returns ok once its signal has aborted.
1873
+ - `attach({ id })` or `attach({ labels })` reads the spec back from E2B and, for a running computer, the daemon, as at
1874
+ create; one that drifts is refused and left as it is. `image` is the template create was asked for, from its label,
1875
+ and `snapshot` the id E2B reports.
1876
+ - `list(labels)` asks E2B for the labels with `agentrun.computer=1` (`Sandbox.list`, running and paused sandboxes,
1877
+ `index.d.mts:10289`), every page, and reads each one back with `getInfo` for its network; paused is `stopped`. One
1878
+ deadline, `listMs` (60 s) from the call, bounds every page and every read-back, each read's own request bound
1879
+ included; past it, `list()` is a timeout in words.
1880
+ - `connect(ref)` refuses a paused computer without connecting, since E2B's connect resumes one; it gives E2B a timeout
1881
+ a little under what is left, and E2B moves a running sandbox's timer only to a longer one (`index.d.mts:10250`), so
1882
+ connecting never moves the end.
1883
+ - `release(ref, "delete")` reads the sandbox back to check it is this provider's, then kills it (`index.mjs:5398-5410`;
1884
+ a sandbox E2B no longer has is done), both never signalled, so a release whose signal aborted first still kills;
1885
+ then it waits through `waitUntil` until `getInfo` answers not found (`index.mjs:5431`) and the label listing no
1886
+ longer shows it, twice running, with pauses doubling from `pollMs` to 5 s, within `goneMs` (120 s) and the caller's
1887
+ signal, which ends only this wait.
1888
+ `release(ref, "stop")` is refused in words.
1889
+ - Every SDK call has its own bound and takes the caller's signal; the paginator takes it per page (`Sandbox.list`
1890
+ itself takes none, `index.d.mts:10280`).
1891
+
1892
+ ### Conformance on E2B
1893
+
1894
+ ```sh
1895
+ AGENTRUN_COMPUTER_LIVE_E2B=1 COMPUTER_E2B_API_KEY=... npm run conformance -w @parcha/agentrun-computer -- --provider e2b
1896
+ ```
1897
+
1898
+ The conformance module, `dist/conformance/e2b.js`, checks `AGENTRUN_COMPUTER_LIVE_E2B=1` before it reads anything
1899
+ else, then reads the run's settings (`settingsFromEnv`, below) and builds the provider through `create()` with every
1900
+ computer capped at 30 minutes, Hobby's plan for conformance
1901
+ (Hobby caps a sandbox at 1 h; a run that needs more moves to Pro). `conformanceImage()` is `COMPUTER_E2B_TEMPLATE`, else
1902
+ `desktop` (`base` for kind linux), and `createDriftedProvider()` uploads a daemon built with Go as `<version>-drift`.
1903
+ `test/e2b/conformance.e2b.test.mjs` runs the suite with `computerd-fixture` built for linux/amd64, and skips unless the
1904
+ switch and `COMPUTER_E2B_API_KEY` are both set; `E2B_API_KEY` never counts.
1905
+
1906
+ `dist/conformance/e2b-sweep.js --before <file>` records every sandbox E2B lists with `agentrun.computer=1`; `--after
1907
+ <file>` kills every one not in the file, reads each back until `getInfo` no longer finds it and the listing no longer
1908
+ shows it, up to 60 s each, and prints `{"swept":n,"gone":m,"stillThere":[ids]}`. Exit 0 when every swept sandbox is
1909
+ gone, 1 when one is still there, 2 on a usage error, an unreadable before file, no key, or a refused listing (nothing is
1910
+ killed then). It reads `COMPUTER_E2B_API_KEY` and `COMPUTER_E2B_DOMAIN` as the conformance module does, and needs no
1911
+ live switch.
1912
+
1913
+ The conformance module's `settingsFromEnv` reads these names, and the sweep and `e2b-diagnose.js` read them through it,
1914
+ each passed to `create()` as the option in brackets: `COMPUTER_E2B_API_KEY` (`apiKey`, required),
1915
+ `COMPUTER_E2B_DOMAIN` (`domain`), `COMPUTER_E2B_DAEMON` (`daemonPath`), `COMPUTER_E2B_KIND` (`kind`),
1916
+ `COMPUTER_E2B_MAX_LIFETIME_MS` (`maxLifetimeMs`, a whole number of ms) and `COMPUTER_E2B_USER` (`daemonUser`). It
1917
+ refuses while `E2B_SANDBOX_URL` is set in the environment it reads, as the provider does in `process.env`.
1918
+ `COMPUTER_E2B_PUBLIC_STREAM` is no longer read.
1919
+
1920
+ ### What waits for a live run
1921
+
1922
+ One live E2B run has been made, the network diagnostic of 2026-11-07 (one sandbox, killed and read back gone); every
1923
+ other fact above is read from the SDK, envd and the desktop template's source, and the unit tests run against a fake.
1924
+ A live run must show:
1925
+
1926
+ - that `getInfo` reports `allowInternetAccess` or `denyOut`, and `network.allowPublicTraffic: false`, for a sandbox
1927
+ made with them: the provider refuses a computer whose read-back lacks them, so a missing field fails every create;
1928
+ - that `getInfo` reports a template asked for by alias with that alias, or its id (the drift check skips an alias E2B
1929
+ does not report);
1930
+ - that a sandbox with no internet access gets no answer from any probe target, IPv6 included (the one diagnostic read
1931
+ the IPv6 target refused and every IPv4 one accepted with 0 bytes), and what else `denyOut 0.0.0.0/0` lets through;
1932
+ - that envd keeps init running once create disconnects, and how long `getInfo` takes to answer not found after a kill;
1933
+ - that Xvfb starts as uid 1000 in the desktop template, and the screen and input cases pass against it;
1934
+ - `endAt` against E2B's start plus the timeout, to the second, and how long the listing takes to show a new sandbox.
1935
+
1936
+ ### Sources
1937
+
1938
+ `e2b@2.63.0` (npm, `dist/index.mjs` and `dist/index.d.mts`), `@e2b/desktop@2.5.0` (npm, `dist/index.mjs`),
1939
+ `e2b-dev/desktop@91f23aca` (`template/template.py`), `e2b-dev/infra@ff3922213`
1940
+ (`packages/orchestrator/pkg/template/build/core/rootfs/files/envd.service.tpl`,
1941
+ `packages/envd/internal/services/process/start.go`, `.../process/handler/handler.go:395-420`), and E2B's docs
1942
+ (network/restrict-public-access and network/internet-access, read 2026-11-07). Each is cited where it is used above and in `src/e2b.ts`.
1943
+
1944
+ ## Browsers: Browserbase and Kernel
1945
+
1946
+ A browser is a computer of kind `browser`: a vendor's browser session that answers CDP. No computerd runs (daemon
1947
+ `none`): the provider answers hello and ping itself, from the vendor's API, and refuses any other method in words, since
1948
+ a browser is driven over CDP. `connect(ref)` reads the browser first (one that has ended, or that the vendor no longer
1949
+ knows though its URL is held, is `gone`), then gives a connection whose `cdp.url` is the vendor's signed CDP URL, which a
1950
+ driver dials; `stream(ref)` gives the vendor's live view. Both URLs are secrets: they are held in memory (a `UrlStore`)
1951
+ and are never in a ref, a list, an error's words or a report. `client` stays a `ComputerClient`, so every caller of
1952
+ `connect` reads a browser's connection as it reads any other.
1953
+
1954
+ | | Browserbase (`browserbase.ts`) | Kernel (`kernel.ts`) |
1955
+ | --- | --- | --- |
1956
+ | a computer is | a session (`POST /v1/sessions`, `keepAlive: true`) | a browser (`POST /browsers`) |
1957
+ | labels ride | the session's `userMetadata`, each key's dots written as `_` (Browserbase refuses a dot in a metadata key), so a label key is letters, digits and dots | the browser's `tags` |
1958
+ | lifetime | the session's `timeout`, 60 s to 6 h, wall clock | `timeout_seconds`, 10 s to 72 h, an idle timeout: no wall clock, so list reads no deadline |
1959
+ | groups (`CAPABILITIES`) | `cdp`, `stream` | `cdp`, `stream` |
1960
+ | test connection | one `GET /v1/sessions?status=RUNNING` | one `GET /browsers?status=active` page |
1961
+ | release | `REQUEST_RELEASE`, then read back until it is no longer `RUNNING` or `PENDING` | `DELETE`, then read back until 404 or `deleted_at` |
1962
+ | options | `apiKey` (or `api`, a host's own calls), `projectId`, `apiUrl` | `apiKey` (or `request`, a host's own), `apiUrl` |
1963
+ | conformance reads | `COMPUTER_BROWSERBASE_API_KEY`, `COMPUTER_BROWSERBASE_PROJECT_ID`, `COMPUTER_BROWSERBASE_API_URL` | `COMPUTER_KERNEL_API_KEY`, `COMPUTER_KERNEL_API_URL` |
1964
+
1965
+ Both declare `lifetime: "vendor"`, `network: ["open"]`, `isolation: "vm"`, `release: ["delete"]`, and no `extend`
1966
+ (neither vendor moves a running session's timeout). Neither declares `downloads` yet: Browserbase keeps a session's
1967
+ downloads, but the protocol has no method that reads them, so the group waits for one. Both call the vendor endpoints
1968
+ pi-browser's Browserbase and Kernel providers call today. `check()` refuses an image other than `chromium`, a lifetime past
1969
+ the cap, a network other than open, and any size, user, workdir or mount, before a vendor call. `list` and attach by
1970
+ labels take at least one label (a vendor account holds sessions no provider made), ask the vendor by status and by the
1971
+ first label a query carries as it is, and match every label themselves. They show every browser that has not ended:
1972
+ Browserbase's `RUNNING` and `PENDING`, Kernel's `status=all` with the deleted dropped (Kernel's filter takes one value,
1973
+ and `active` may leave out a browser still starting). A release is idempotent: one already ended or
1974
+ unknown to the vendor is released.
1975
+
1976
+ A vendor call is one request, never retried where a retry could open a second paid browser, and a failure names the
1977
+ call and the HTTP status alone, never the vendor's words. A host that already talks to the vendor (pi-browser's SDK
1978
+ client) passes its own transport: `BrowserbaseApi` or `KernelRequest`. Its thrown error rides the failure as a hidden
1979
+ cause (`causeOf(result)`), not enumerable, so it is in no JSON.
1980
+
1981
+ Each create writes one more label beside the spec's, `agentrun.create` (`CREATE_LABEL`), with a value of its own. A
1982
+ create whose outcome is unknown (its reply lost, cut short, answered 5xx or with no browser, or the caller's signal
1983
+ aborted it) never sends a second create: it finds the browsers carrying that label as list does, in every state not
1984
+ ended, under a signal of its own bounded at `RECOVER_MS`, releases each, and its failure says so. A 4xx refusal made
1985
+ nothing, so nothing is looked for. The label is the provider's own: `check()` refuses it in a spec, and no list or attach shows it.
1986
+
1987
+ The conformance CLI runs the browser case set for a provider of kind browser: the health cases, then `browser.*`
1988
+ (check past the cap, attach by id and by labels, list, CDP `Browser.getVersion` and `Runtime.evaluate` on a `data:`
1989
+ page, the live view, and release last). Every case but the first shares the run's one browser, so a live run costs one
1990
+ session.
1991
+
1992
+ ```sh
1993
+ AGENTRUN_COMPUTER_LIVE_BROWSERBASE=1 COMPUTER_BROWSERBASE_API_KEY=... COMPUTER_BROWSERBASE_PROJECT_ID=... \
1994
+ npm run conformance -w @parcha/agentrun-computer -- --provider browserbase
1995
+ AGENTRUN_COMPUTER_LIVE_KERNEL=1 COMPUTER_KERNEL_API_KEY=... \
1996
+ npm run conformance -w @parcha/agentrun-computer -- --provider kernel
1997
+ ```
1998
+
1999
+ ## Phone harness (the phone kind)
2000
+
2001
+ ```ts
2002
+ import { providerFor } from "@parcha/agentrun-computer";
2003
+
2004
+ const phones = await providerFor("phone-harness", { apiKey }); // serve passes PHONE_HARNESS_API_KEY
2005
+ const made = await phones.create({ image: "android", lifetimeMs: 10 * 60_000, network: "open", labels: { run } });
2006
+ ```
2007
+
2008
+ `src/phone-harness.ts`, provider id `phone-harness`, rents a temporary cloud Android emulator from the phone harness
2009
+ (phone-harness.com). The phone harness bills it at 5 cents a minute from the account's credit. A cloud iPhone (driven by
2010
+ the API's control URL) is a later change: `platform: "ios"` is refused in words.
2011
+
2012
+ - **No daemon.** Nothing runs on the phone. `connect()` asks the phone harness for the session's adb link, runs
2013
+ connects to it, unlocks the phone with the session's code (never in a result or an error) and probes it.
2014
+ - Neither the endpoint nor the code is ever in a spawned adb's argv, which `/proc` shows to every user of the host.
2015
+ The endpoint goes to the local adb server over its socket protocol (`host:connect`, `host:devices-l`,
2016
+ `host:disconnect`). The unlock is the vendor's shell command `unlock <code>`, once per connection; every shell
2017
+ answers `locked` before it. It is sent as that shell service's own string, `shell:unlock <code>`, on a socket the
2018
+ adb server bound to the phone (`host:transport-id:<id>`), as `adb shell unlock <code>` would send it. Every
2019
+ spawned adb names the phone by the adb server's transport id (`-t <id>`). A shell's stdin cannot carry the unlock:
2020
+ a shell with no command string is answered `locked` (live run 3); the socket path unlocked a phone live (probe 1).
2021
+
2022
+ Then it gives
2023
+ a client in this process that answers each protocol method with adb commands:
2024
+ - `screen.shot`/`screen.read`: a raw `screencap`, cropped to the region and encoded as an RGBA PNG; `scale` is the
2025
+ density over 160;
2026
+ - `screen.watch`: PNG frames (`format: "png"`) from `screencap`, read once a second at most, across calls too (an
2027
+ animated screen acked at once is no faster), a new frame only when the pixels changed; `maxWidth` scales by the
2028
+ nearest pixel, and `quality` has no effect on a PNG. A cancel or the connection's close ends a screencap and a
2029
+ wait in flight;
2030
+ - `input.actions`: checked whole first (`checkActions`). Then:
2031
+ - tap and long press;
2032
+ - swipe: `input swipe`, or `input motionevent` for a path of three points or more. Its `ms` is shared between the
2033
+ moves as `sleep`s, by each segment's length, so it lasts `ms` at least;
2034
+ - the back, home and app switch buttons;
2035
+ - `type`, by `input text`: ASCII and line breaks. A literal `%s` is split across two calls, so it is not read as
2036
+ a space;
2037
+ - one key at a time (`input keyevent`), and `wait`.
2038
+
2039
+ A cancelled batch stops at the action it is on, a `wait` included, and answers failed, kind `aborted`, there;
2040
+ - `apps.list` (`pm list packages`, and the app in front from `dumpsys activity activities`), `apps.launch` (its
2041
+ launcher activity, `am start -W --activity-clear-task`, so the app named is in front and not what its task last
2042
+ held: on Android 15 Settings' task keeps search, another package, on top) and `apps.terminate` (`am force-stop`);
2043
+ - `apps.ui_tree`: `uiautomator dump`.
2044
+
2045
+ exec, files, processes and tar are refused in words: a phone has no shell in the computer protocol. So are pinch
2046
+ (adb's `input` has one finger), hold, a combo of keys, `apps.install` and `deadline.extend`.
2047
+ - **Capabilities.** Kind and os `android`, daemon `none`, lifetime `vendor`, network `open`, release `delete` only.
2048
+ Groups `screen`, `input.touch`, `input.keys`, `apps` and `apps.ui_tree`. `maxLifetimeMs` is 30 min by default. No
2049
+ mount, no extend.
2050
+ - **create** asks for `timeout_seconds` = the lifetime, and the phone harness ends the session then, whatever happens.
2051
+ The lifetime includes the boot, so a phone ready past its deadline fails `timeout`.
2052
+ - Each POST carries an Idempotency-Key, and a create whose answer is uncertain is found by it, never sent twice.
2053
+ Only a refusal (a 4xx, or `phones_busy`) says nothing was made. No answer, a 5xx, or a 2xx with no session is
2054
+ uncertain: create asks `GET /sessions/requests/<key>` before it forgets the key, and records the phone it finds.
2055
+ - A create cancelled during its POST is recovered by its key all the same, and the phone the service made is ended.
2056
+ - A phone that fails, or is not ready within `readyMs` (240 s), is ended.
2057
+ - Each request has a bound of its own, `requestMs` (30 s), beside the caller's signal, and a readiness read takes no
2058
+ longer than `readyMs` has left. A request cut off by its bound is treated as a lost answer. A readiness read cut
2059
+ off by `requestMs` while `readyMs` has time left is asked again; only `readyMs` itself ends a phone that is slow to
2060
+ start. The `timeout` option is the timer (default `AbortSignal.timeout`).
2061
+ - Once the phone's id is known, a ledger write that fails ends the phone, and create answers in words.
2062
+ - The service's refusals keep their words (`limit` for `phones_busy` and `session_limit`, `denied` for the key or
2063
+ credit) and never hold the key.
2064
+ - **The ledger.** The phone harness keeps no labels on a session, so the provider keeps each phone's labels, image and
2065
+ deadline in its `ledger` option: `{ put, get, list, remove }`. It is in memory by default; serve passes a store-backed
2066
+ one, and the conformance module a JSON file. `list`, `attach`, `network`, `connect`, `release` and the janitor see
2067
+ only the phones it names, never another session on the account, and forget a phone the service ended. release of an
2068
+ id the ledger does not name sends no DELETE: it answers `not_found` while that session runs, and ok once it is gone.
2069
+ The service ends a session asynchronously, so a released phone's entry stays, marked `released`, until its own
2070
+ `GET /sessions/<id>` is a 404. Meanwhile a second release is ok, list leaves it out, and attach, connect and network
2071
+ answer `not_found`, as for a deleted computer.
2072
+ - create puts an entry under `pending-<Idempotency-Key>` before its POST, and replaces it by the session's id once
2073
+ known; a refused POST forgets it.
2074
+ - If the POST's answer and its recovery (`GET /sessions/requests/<key>`) are both lost, the entry stays. `list()`
2075
+ takes as its phone the one account session whose `request_key` equals that key exactly, and nothing else, so the
2076
+ janitor's sweep and release find and end a phone made under a lost create.
2077
+ - A pending entry with no such session is kept while a create may still be under way, and forgotten after its
2078
+ deadline.
2079
+ - `list()` reads the ledger before `GET /sessions`, so it never forgets a phone a create records while it runs. It
2080
+ forgets a phone the listing leaves out only once that phone's own `GET /sessions/<id>` is a 404.
2081
+ - **adb** is an option too: a transport, `{ run(args, { input }), server(service) }` (tests give a fake), or the path of
2082
+ the `adb` CLI (Android platform-tools; default `adb` on PATH), whose server it starts and speaks to on the loopback
2083
+ (port 5037, adb's own, or `adbCli(path, { port })`). Every spawned adb names that port with `-P`, so the CLI and the
2084
+ socket requests reach one server. `adbCli(path, { env })` spawns adb from the environment given, with every
2085
+ `ADB_*`, `ANDROID_ADB_*` and `ANDROID_SERIAL` variable dropped, so nothing in it points the CLI at another server or
2086
+ device. The library reads no environment of its own: the conformance module passes its own, minus its
2087
+ `COMPUTER_PHONE_HARNESS_*` names (the key never reaches adb), and serve should pass one too. Without `env`, a spawned
2088
+ adb inherits the process's environment as it is. Without adb, connect says so in words.
2089
+ - **testConnection** is list(): one `GET /sessions` joined to the ledger, and a GET of any phone the listing leaves out.
2090
+ It rents nothing and reaches no phone: ok with the
2091
+ count of this provider's phones, `unauthorized` for a refused key, `unreachable` when the phone harness is not
2092
+ reached.
2093
+
2094
+ Conformance (`src/conformance/phone-harness.ts`) reads `COMPUTER_PHONE_HARNESS_API_KEY`,
2095
+ `COMPUTER_PHONE_HARNESS_PLATFORM`, `COMPUTER_PHONE_HARNESS_ADB`, `COMPUTER_PHONE_HARNESS_LEDGER` and
2096
+ `AGENTRUN_COMPUTER_LIVE_PHONE_HARNESS`, never the bare
2097
+ `PHONE_HARNESS_API_KEY`. A run's phones live at most 10 min, and the run's computers ask for at most the provider's
2098
+ `maxLifetimeMs`.
2099
+
2100
+ With no fixture app (it takes no files), the touch, keys and apps cases drive the stock Settings app and read back
2101
+ through `apps.ui_tree` (`src/conformance/cases/settings.ts`):
2102
+ - `touch.tap`: a tap on a row opens its page: the row's title shows, as a text or a label (Android 15's page has it
2103
+ only as its toolbar's content-desc), and the next row is gone. Back comes back. When the page does not
2104
+ come, its words say what it saw: the screen in px and dp, what is in front, the tap point and the row's bounds,
2105
+ whether the title shows outside the list, and whether the next row is still shown;
2106
+ - `touch.swipe`: a swipe up moves the list up;
2107
+ - `input.type-text` and `input.key-table-refuses-unknown`: the text read back from the search field;
2108
+ - `apps.launch-terminate`, which needs the apps group alone: Settings is listed; once launched it is in front, and
2109
+ shown, in `apps.ui_tree` when the phone has one, else in a screenshot other than the one before; once terminated it
2110
+ is not in front;
2111
+ - `apps.ui-tree-shape`: the tree's shape, on Settings.
2112
+
2113
+ `touch.pinch` skips in the provider's own refusal.
2114
+
2115
+ ## Conformance
2116
+
2117
+ A provider for another vendor passes the same suite as Docker's, with one command. The suite is data: each case in
2118
+ `src/conformance/cases/` names its level, its group (`health`, `exec`, `files`, `process`, `provider`, `drift`,
2119
+ `isolation`, `mount`, `screen`, `input`, `touch`, `apps`, `lifetime`, `browser`) and the capabilities it needs, and uses only `ComputerProvider`,
2120
+ `ComputerClient` and the suite's assertion helpers, so the same cases run against a provider with daemon `none`.
2121
+
2122
+ ```sh
2123
+ npm run conformance -w @parcha/agentrun-computer -- --provider docker # or modal, daytona: any registry id
2124
+ npm run conformance -w @parcha/agentrun-computer -- --provider ./my-provider.js [--image debian:bookworm-slim] [--only exec,files] [--fixture <path>] [--json]
2125
+ ```
2126
+
2127
+ ```text
2128
+ computer conformance · docker · linux, daemon pid1 · computerd 0.1.0-beta.30 linux/amd64
2129
+ core health hello ping unknown-method kind-consistent ✓ 4
2130
+ core exec argv streams exit-code cwd env timeout abort ✓ 11
2131
+ truncation setsid-escapee unprivileged user
2132
+ ...
2133
+ full lifetime extend - 1
2134
+ - lifetime.extend: the provider has no extend()
2135
+ optional screen screenshot-size - 1
2136
+ - screen.screenshot-size: the provider does not declare screen
2137
+ ...
2138
+ core PASS 54/54 · 10 optional cases skipped, not declared · full 10/13 · mount:archil screen input.pointer input.keys input.touch apps.install apps apps.ui_tree extend not declared
2139
+ ```
2140
+
2141
+ An id is resolved through the provider registry, and only there; the usage lists every id it holds. A module path is
2142
+ resolved from the directory npm was run in. It exits 0 when Core passes, 1 when it fails, 2 on a
2143
+ usage error, and 3 on a partial run; `--json` prints the report object (`{ provider, providerVersion, kind,
2144
+ daemonMode, image, daemon: { version, os, arch }, only?, coreNotRun?, results: [{ id, level, group, status, reason?,
2145
+ undeclared? }], core, undeclared, cleanup, notes?, computerNotes? }`). A failure is listed under its line with what the
2146
+ case found. `computerNotes` (`[{ computer, note }]`, absent when empty) holds every note a `create` returned beside its
2147
+ ref, such as a probe target that accepted and sent nothing back, naming the computer, in the order they came; the text
2148
+ report prints each as `note <computer>: <words>` above the verdict, so a run that passes Core never hides one. Notes an
2149
+ `attach` returns are not carried: cases call `attach` on the provider directly, so the runner never sees them.
2150
+
2151
+ `--only` that leaves any Core case out is a partial run: `core` is `"partial"` when every case that ran passed (a
2152
+ skipped Core case is not a pass) and nothing was left behind, else `"fail"`; `coreNotRun` names the Core cases that did
2153
+ not run, the text report lists them on a `core not run` line, and the verdict reads `core PARTIAL 11/11 · 52 Core cases
2154
+ not run` (on Docker, `--only health,provider`), never PASS. A partial run exits 3, so a script that checks for 0 never takes a subset for a Core pass. An
2155
+ `--only` that names every Core case is a whole run, and can pass.
2156
+
2157
+ `--kind <kind>` (`kind` in `runConformance`'s options, never with `--only`) runs a kind's cases, `kindCases(kind)`:
2158
+ every case whose protocol groups the kind requires or allows (see [Kinds](#kinds-the-computer-an-agent-is-given)),
2159
+ those that need no group (health, provider, drift) among them. The report carries `kindVerdict` (`{ kind, verdict,
2160
+ reasons }`), the text report ends on `kind <kind> PASS` or `kind <kind> FAIL: <why>`, and the CLI exits on it: 0 when
2161
+ the provider passes the kind, 1 when it does not. A provider passes a kind only when it serves it (by its
2162
+ capabilities), no case of the run failed (a declared optional group that fails would hand a loop a broken tool),
2163
+ every required group has at least one passing case and no Core case skipped but for an optional group the computer does
2164
+ not declare, and the run left nothing behind. A Full case that skips is owed by no group: a provider may refuse in
2165
+ words what its kind does not require, as the phone harness refuses `touch.pinch`, and the report still shows the skip.
2166
+ `none` is no computer, and `--kind` refuses it in words. Given no cases, a run takes `casesFor(machineKind)`: a
2167
+ browser's own cases (`browserCases`), every other kind the suite's (`conformanceCases`), in the library as in the CLI;
2168
+ `kindCases` draws from the same by kind. `kindCases`, `kindVerdict` and `casesFor` are exported, so the serve side reads
2169
+ the same table.
2170
+
2171
+ What a module given by path implements: either a provider file's `create(options)` (see
2172
+ [Adding a computer](#adding-a-computer)), given the CLI's provider options but the env and run with no drifted
2173
+ provider, or a conformance module's:
2174
+
2175
+ - `export function createProvider()` returning a `ComputerProvider` (sync or async): `id`, `version`,
2176
+ `capabilities()`, `check`, `create`, `attach`, `list`, `network`, `connect` and `release`, as in `src/provider.ts`.
2177
+ `connect` hands out a connection whose daemon answers the methods in `src/protocol.ts`.
2178
+ - `export function createDriftedProvider()`, for the drift case: the same provider with a daemon that reports a version
2179
+ other than `version`. A computer of that daemon must never be handed out: `create` refuses it (and deletes it), or
2180
+ `connect` refuses it. Without this export the case is skipped, so Core does not pass.
2181
+ - `export function mountFor(kind)`, for the mount cases: a fresh run folder for a mount kind the provider declares
2182
+ (`RunFolder`: `{ mount, read(path), write(path, data), close() }`), with its outside, where no computer runs: the
2183
+ folder on the host for a bind, the disk's file API for Archil. `undefined` for a kind it cannot make. The runner
2184
+ closes each folder when its case ends. `--provider docker` gives a bind of a new folder under the temp directory,
2185
+ owned by the provider's user. Without this export the mount cases skip in words.
2186
+
2187
+ Core and Full follow the Kubernetes agent-sandbox conformance levels (KEP-539.2):
2188
+
2189
+ - **Core** is what every computer of its kind does; for a linux computer: hello and ping, `exec.run` as a user other than root with no capability in
2190
+ any set and `no_new_privs` (`CapEff`, `CapPrm`, `CapInh`, `CapBnd` and `CapAmb` all zero and `NoNewPrivs` 1 in
2191
+ `/proc/self/status`, a field not reported failing; the run's spec asks for no user), a HOME that user owns and writes while `/` refuses it, the
2192
+ `files.*` and `tar.*` methods, the `process.*` methods, a computer with network `none` (`network:none`: a provider
2193
+ that cannot make one fails Core, and the suite never asks for a wider network instead), `check`, `create`, `attach`
2194
+ (with the spec it reads back: the network and image create asked for, and a non-root `user` as `uid:gid`), `list`,
2195
+ `network` read-back and `release`, `release(ref, "stop")` as declared (a provider whose `capabilities().release` holds
2196
+ `"stop"` lists the computer stopped until it is deleted, or, when it also declares `stopDeletes`, leaves it neither
2197
+ listed nor attachable; one that does not refuses stop as `unsupported`, in words, and the computer stays listed and
2198
+ running), a change to a network the provider does not declare refused with the
2199
+ network unchanged (Core asks for no network the provider could give), a computer that does not run past its deadline
2200
+ (after a sweep, for a janitor provider), and the drift checks. Core passes when every Core case passes and the run leaves no computer
2201
+ behind.
2202
+ - **The vendor's agent** (`isolation.vendor-agent`, Core where declared): a provider whose computers run beside the
2203
+ vendor's own agent declares that agent's TCP ports, its own fact, as `capabilities().vendorAgentPorts` (Daytona
2204
+ `[2280]`, E2B `[49983]`, Modal `[]`); a child daemon must (`coreGroups` holds `vendor-agent` for daemon `child`).
2205
+ The case runs `computerd probe` through `exec.run`, as the computer's user, against each port on `127.0.0.1` and
2206
+ `[::1]`, and against the outside (`OUTSIDE_TARGETS`: `1.1.1.1:443`, a public IP literal, and `example.com:443`, a
2207
+ DNS name): every target must read `refused`, and the probe's `interfaces` must be `["lo"]`. So it proves, per
2208
+ provider, that a tool reaches neither the vendor's agent nor any address. A provider that declares nothing (Docker:
2209
+ no agent inside) skips it in words.
2210
+ - **Core by kind.** `coreGroups(kind, daemon)` is what a computer of its kind must declare (the table in
2211
+ [The protocol extension](#the-protocol-extension-kind-daemon-modes-screen-input-apps-lifetime)): exec, files,
2212
+ processes and network `none` wherever computerd runs, screen and keyboard and pointer on a desktop, screen and touch
2213
+ on a phone. `health.kind-consistent` checks the kind, os and daemon pair, that hello's kind and groups are the
2214
+ provider's, and that kind's Core groups are declared; `provider.check-refuses` also asks `check` for
2215
+ `maxLifetimeMs + 1`. Where the kind makes them Core: `screen.screenshot-size` (every pixel of the PNG decodes, its
2216
+ IHDR size is `width` x `height`, `scale` is above 0, a region shot decodes and has the region's size, and on a
2217
+ desktop the fixture's four colors are where it paints them; the suite reads 8-bit, non-interlaced PNGs of at most
2218
+ 16384 pixels a side and 2^25 pixels, and inflates no more than their IHDR gives), `input.click-lands` (a single and a double click show in the fixture's log at their
2219
+ point, with their count), `input.type-text` (`Hello, agentrun! 123` arrives exactly),
2220
+ `input.key-table-refuses-unknown` (a batch whose second action names `Hyper_Q` gives `done` 0, `failed.index` 1,
2221
+ kind `invalid`, and runs nothing), `input.actions-stops-at-first-failure` (move, left button down, move off the screen,
2222
+ click: `done` 2, the press released where it was, no click, and a later click lands, so nothing was left held), `touch.tap` and `touch.swipe` (the
2223
+ fixture app logs the tap at its point, and the swipe's start and end), `apps.install-launch` (installed, listed, in
2224
+ front when launched and not when terminated) and `apps.ui-tree-shape` (every node typed as the protocol says, inside
2225
+ the screenshot, with the fixture's button found by its id and text).
2226
+ - **Full** is each optional capability a provider declares: network `open` (`network:open`), a network allowlist
2227
+ (`network:allow`), each with a change of a computer's network to it and back to `none`, refused or applied
2228
+ truthfully, on a computer of the case's own (`provider.network-switch`, `provider.network-switch-allow`), the janitor for a provider whose lifetime is `"janitor"` and that stops computers and keeps them
2229
+ (`lifetime:janitor`, `release:stop`, and no `stopDeletes`), a takeover by label (`provider.release-older`, which
2230
+ needs nothing declared: computers of one run at epochs 1, 2 and 3 and one of another run at epoch 1 carry and read
2231
+ back `agentrun.run` and `agentrun.epoch`; `releaseOlder` at epoch 3 deletes 1 and 2 and keeps 3 and the other run's,
2232
+ by id and by label; at epoch 2 after it, it is refused as fenced and deletes nothing), and a spec that
2233
+ asks for root (`user:root`, from `capabilities().user` holding `"root"`) or another uid (`user:uid`), still with no
2234
+ capability in any set and `no_new_privs`, read as in Core; and from the extension `touch.pinch` (two fingers logged
2235
+ moving apart), `lifetime.extend` (`extend`: made with 45 s and extended to 120 s, at 60 s it answers ping with a
2236
+ process started earlier still running and `list()` shows the new deadline; three extends are refused with the
2237
+ deadline unchanged: to an earlier deadline, to maxLifetimeMs + 1, and, 60 s after create, to maxLifetimeMs less 30 s,
2238
+ within the cap on its own but past create + maxLifetimeMs; a cap under 3 min skips it).
2239
+ - **`screen.watch` is Core in the screen group**: through the provider's `watch()`, the first frame decodes (a PNG
2240
+ whole; a JPEG walked to its end, as the suite has no JPEG decoder) to the size it says, of the screen `screen.shot`
2241
+ reads; on a computer with `input.pointer`, a pointer move through `input()` is a new frame with the cursor where it
2242
+ went (a frame with no cursor is not it). It replaced `screen.stream`, which
2243
+ checked a vendor's URL: the live view is proxy only (the user-approved decision, 2026-11-09).
2244
+ - **The mount group is Full**, optional for every kind until the cutover decides. "Mounts the run's folder",
2245
+ `mount.run-folder-bind` and `mount.run-folder-archil` (`mount:bind`, `mount:archil`, from `capabilities().mount`):
2246
+ on a computer of its own made with the run folder `mountFor(kind)` gives, `check` takes the spec, `attach` and `list`
2247
+ read the mount back as asked (`readBackOf`), a file written outside is read at `/workspace` with `files.read`, one
2248
+ `files.write` makes there is read outside, and `cat <file>` run through `exec.run` with `cwd: "/workspace"` prints
2249
+ it. For Archil, no read-back holds the token. `mount.undeclared-kind`: each kind the provider does not declare is
2250
+ refused by `check` with `field: "mount"` in words, and by `create` with `check`'s words, before any vendor call, with
2251
+ the token in no refusal; a provider that declares every kind skips it.
2252
+
2253
+ A case needs groups (declared by both `capabilities().groups` and hello), networks, the janitor, a user, a mount kind, or an optional
2254
+ provider method (`extend`, `stream`, declared by being there). When a Core case needs what its kind requires and the
2255
+ provider or the computer lacks it, the case fails in words: `a desktop computer with daemon pid1 must declare screen:
2256
+ the provider does not declare screen`. Any other need that is not declared skips the case with the reason, never
2257
+ fails it, and names it in `undeclared`; a Core case skipped so is not Core for this kind of computer: the report lists
2258
+ it under `optional`, never under `core`, it is out of Core's count, and the verdict says how many (`9 optional cases
2259
+ skipped, not declared`). Any other skip of a Core case (no fixture given, no way to observe a touch)
2260
+ is not a pass, so Core does not pass.
2261
+
2262
+ The cases that check what input did read a fixture's own log, with no model. `--fixture <path>` (`fixture` from code)
2263
+ names it: `computerd-fixture` for a desktop, a test-only static binary the case writes with `files.write` and starts
2264
+ with `process.start` (`--log <path>`), a 200x200 override-redirect window at (0, 0) in four colors (red, green, blue,
2265
+ yellow, clockwise from top left) that grabs focus; or the fixture APK for an Android phone (`ai.agentrun.fixture`,
2266
+ installed with `apps.install` and launched, logging to its files directory, with a button
2267
+ `ai.agentrun.fixture:id/button` that reads `agentrun fixture`). Each event is one JSON line (`ready`, `down`/`up` with
2268
+ button and point, `wheel`, `key`, `text`, `touch` with finger and phase); `src/conformance/fixture.ts` is the
2269
+ contract. A case that needs it and was given none skips, so Core cannot pass on a desktop or phone without it. The
2270
+ fixture is stopped when its case ends, once launched, even when it never logged ready. A phone that declares neither files nor `apps.ui_tree` skips the touch cases:
2271
+ `no way to observe the effect: declare files or apps.ui_tree`.
2272
+
2273
+ The suite makes every computer with the label `agentrun.conformance=<run id>`, image `--image`, a 30-minute lifetime
2274
+ and network `none` (`open` for a phone that declares no `none`, since its kind does not require it). It deletes each computer a case made when the case ends, and the shared one at the end; for a
2275
+ provider with lifetime `"janitor"` it then sweeps that label, and it lists the label to show nothing is left. A case
2276
+ that runs past 3 minutes fails and its computers are deleted. Every provider call is bounded: a create or connect for
2277
+ the shared computer that does not answer within 3 minutes fails the cases that need it, a release, sweep or list
2278
+ that does not answer within a minute is named in `cleanup.errors`, and a computer or connection that arrives after
2279
+ its case ended is deleted or closed as it arrives and named in `cleanup.late`; the run waits, bounded, for every
2280
+ create a case started, a refused one included, so a late computer is deleted before the report returns. A call still
2281
+ pending when that bound (a minute) runs out is named in `cleanup.errors`, since what it makes may be left, and Core
2282
+ fails, as it does for a computer left behind. A case calls
2283
+ `t.create(extra)` for a computer it needs, or `t.attempt(spec, by?)` for create's result as it is (a refusal it
2284
+ expects, or the drifted provider's computer). With `--provider docker` and no
2285
+ `COMPUTER_DOCKER_DAEMON`, a `docker version` that does not answer within 30 s is killed and the run fails, naming the call. The CLI exits once the report
2286
+ is out. Cases do not assume root: the suite assumes only that the
2287
+ computer's `HOME`, which the provider sets, is a directory its user can write, and works under
2288
+ `$HOME/agentrun-conformance-<run id>`.
2289
+
2290
+ From code: `runConformance(provider, { image, only?, signal?, drifted?, mountFor?, caseTimeoutMs?, cleanupTimeoutMs?,
2291
+ fixture?, fetch? })` returns the report, and `formatReport(report)` the text above.
2292
+
2293
+ ## Adding a computer
2294
+
2295
+ A new computer is one provider file and one registry line. The conformance CLI (and serve, once wired) resolves
2296
+ providers through the registry, `src/providers.ts`, and nothing else, so neither needs an edit:
2297
+
2298
+ ```ts
2299
+ export const providers = {
2300
+ docker: () => import("./docker.js"),
2301
+ modal: () => import("./modal.js"),
2302
+ daytona: () => import("./daytona.js"),
2303
+ e2b: () => import("./e2b.js"),
2304
+ fly: () => import("./fly.js"), // a new computer's line
2305
+ } satisfies Record<string, () => Promise<ProviderModule>>;
2306
+ ```
2307
+
2308
+ Each import is lazy: loading the registry loads no provider and no vendor SDK. `providerFor(id, options)` builds a
2309
+ provider by id from its options and refuses an id it does not hold, naming the ones it does. The provider file,
2310
+ `src/<vendor>.ts`, exports what a `ProviderModule` is:
2311
+
2312
+ - the provider class, which implements `ComputerProvider` and reports the registry id as its `id`;
2313
+ - `MOUNT`, the mount kinds its computers take;
2314
+ - `create(options)`, the provider built from its options alone, its key included, and refused in words when one is
2315
+ missing or wrong, never echoing a key. It reads no environment (see [Settings](#settings)), and exports no names of
2316
+ variables;
2317
+ - optionally `conformance`, `() => import("./conformance/<vendor>.js")`: a module that reads the run's settings from
2318
+ the environment by its own `COMPUTER_<ID>_*` names (`settingsFromEnv(env)`, with `ENV` listing every name it
2319
+ reads; never a vendor's bare variable such as
2320
+ `DAYTONA_API_KEY`, which on a shared host may hold another account's key, not even as a fallback), bounds a
2321
+ conformance run's computers and makes the drifted provider (`createProvider()`, `createDriftedProvider()`,
2322
+ `conformanceImage()`, `conformanceNotes`), building them through `create()`. Without it the CLI runs `create()`'s
2323
+ provider with the CLI's options, and the drift case skips, so Core does not pass.
2324
+
2325
+ Docker's conformance module reads `COMPUTER_DOCKER_DAEMON` (`daemonPath`; unset, `create()` takes this package's daemon
2326
+ for Docker's architecture, from `docker version`), `COMPUTER_DOCKER_DAEMON_CACHE` (`daemonCache`) and
2327
+ `COMPUTER_DOCKER_USER` (`user`); the provider's `image` is an option only, which no module reads from the environment
2328
+ (see "The image"). Modal's, Daytona's and E2B's read the names in their sections. `test/providers.test.mjs` holds every
2329
+ provider file to its registry line and its line to this shape, checks that the CLI's usage names every id, and runs
2330
+ `scripts/check-env.mjs` on `src/`. Run the suite on the new computer, by path before its line exists and by id after:
2331
+
2332
+ ```sh
2333
+ npm run conformance -w @parcha/agentrun-computer -- --provider ./packages/computer/dist/fly.js
2334
+ npm run conformance -w @parcha/agentrun-computer -- --provider fly
2335
+ ```
2336
+
2337
+ ## Build
2338
+
2339
+ ```sh
2340
+ npm run build -w @parcha/agentrun-computer # the TypeScript, into dist/
2341
+ npm run build:daemon -w @parcha/agentrun-computer # dist/computerd-linux-amd64 and -arm64; needs Go 1.24 or newer on PATH
2342
+ ```
2343
+
2344
+ ## Tests
2345
+
2346
+ ```sh
2347
+ npm test -w @parcha/agentrun-computer # unit tests: no Go, no Docker
2348
+ cd packages/computer/daemon && go vet ./... && go test ./...
2349
+ AGENTRUN_COMPUTER_LIVE_DOCKER=1 npm run test:docker -w @parcha/agentrun-computer
2350
+ AGENTRUN_COMPUTER_LIVE_DAYTONA=1 COMPUTER_DAYTONA_API_KEY=... [COMPUTER_DAYTONA_SNAPSHOT=<snapshot>] npm run test:daytona -w @parcha/agentrun-computer
2351
+ AGENTRUN_COMPUTER_LIVE_MODAL=1 npm run test:modal -w @parcha/agentrun-computer # also needs COMPUTER_MODAL_TOKEN_ID/SECRET, a key the lead OKed
2352
+ AGENTRUN_COMPUTER_LIVE_E2B=1 npm run test:e2b -w @parcha/agentrun-computer # also needs COMPUTER_E2B_API_KEY, a key the lead OKed, and the e2b package
2353
+ ```
2354
+
2355
+ Where Xvfb is on PATH, the Go tests also run the X client, and screen and input against the fixture, on a real X
2356
+ server; elsewhere those tests skip in words and the fake X server's tests still run.
2357
+
2358
+ The live tests run the conformance suite on Docker, one test per case, on a plain computer and on a desktop built from
2359
+ `test/fixtures/desktop/Dockerfile` by `ensureImage` with `computerd-fixture` built from `daemon/cmd/fixture`, and the
2360
+ CLI against
2361
+ `alpine:3.20`; the rest of
2362
+ them check what only Docker shows (the user, sizes, tmpfs mounts and hardening flags in `docker inspect`, the daemon
2363
+ mount, the socket directory, hello's arch against Docker's, `/work` as the user's home, the daemon's exit 0 on `docker
2364
+ stop` and at its deadline, attach by a container's name). They need Docker, `debian:bookworm-slim`
2365
+ and `alpine:3.20` pulled, both builds, and Go on PATH (the drift case builds a daemon of another version). They use
2366
+ the daemon for Docker's own architecture, and remove every container they make by its exact name, pass or fail.
2367
+ `test/docker/image.docker.test.mjs` builds fresh `alpine:3.20` recipes: once for three concurrent callers, reused on
2368
+ the next call, from three processes at once, and a broken one refused in words; it removes each tag it made. Another,
2369
+ `test/docker/modal-commands.docker.test.mjs`, runs the Modal provider's entrypoint and upload exactly as sent, in
2370
+ a Debian and an Alpine root container with no network, and checks that init comes up as uid 1000 with no capabilities
2371
+ and `no_new_privs`, and answers hello over `computerd stdio`. Those root containers keep Docker's default
2372
+ capabilities and add CAP_SYS_ADMIN and CAP_NET_ADMIN (init `--own-network` needs both, and Modal's root holds every
2373
+ capability), or every one (`--cap-add ALL`), with no `--cap-drop`: with `--user 1000:1000`, `exec.run` reads every
2374
+ thread of init and its own status with all five sets zero and `NoNewPrivs` 1; `--user 0:0` has init refuse to start,
2375
+ and so does a root container without CAP_SETPCAP, in words. `test/docker/loopback-block.docker.test.mjs` starts init
2376
+ as Daytona, E2B and Modal start it, in an Alpine root container beside a stand-in agent (BusyBox `nc` as root on 2280
2377
+ and 49983, on every interface): root reaches the stand-in, and a program of the computer's user, through `exec.run`,
2378
+ finds every port refused on both loopbacks and the container's own address, and `1.1.1.1:443` and `example.com:443`
2379
+ refused though the container itself has Docker's bridge, sees `lo` alone, and still reaches a
2380
+ listener of its own; a root without CAP_SYS_ADMIN, and a container where another process holds the computer's uid,
2381
+ have init refuse to start in words. The Daytona and E2B command tests give their containers the same two
2382
+ capabilities.
2383
+ `test/docker/e2b-commands.docker.test.mjs` runs the E2B provider's install, init and bridge as sent, in a root
2384
+ container of the desktop fixture's image, starts Xvfb through the daemon on the display init was given and waits for
2385
+ hello to declare the screen, and checks that `deadline.extend` moves up to `--max-deadline` and no further. The
2386
+ programs the daemon starts get no `DISPLAY` of init's (it passes on only PATH, HOME, USER and LOGNAME): a caller that
2387
+ starts a GUI program gives it `DISPLAY` in the request's `env`, on E2B as on Docker.
2388
+
2389
+ ## Acknowledgements
2390
+
2391
+ The daemon copies code, with credit, from two Apache-2.0 projects. NOTICE names them; UPSTREAM.json records each copied
2392
+ file, the commit, and what changed. It has no Go dependency outside the standard library: the terminal is opened with
2393
+ its own ioctls (pty(7)) rather than with github.com/creack/pty.
2394
+
2395
+ - [E2B infra](https://github.com/e2b-dev/infra), envd: the user, credential and environment setup of a process; a
2396
+ file's entry info and the listing to a depth.
2397
+ - [Kubernetes agent-sandbox](https://github.com/kubernetes-sigs/agent-sandbox), sandboxd: the exit status and the
2398
+ bounded output of a run with limits; filesystem errors, mkdir, move and remove, and tar extraction confined to its
2399
+ directory; the process registry, and a process's stdin, signal and terminal resize.
2400
+ - E2B envd also gives the signal names, the process list and the terminal's read loop.
2401
+ - [Rivet sandbox-agent](https://github.com/rivet-dev/sandbox-agent)'s process runtime (Rust; no code copied) is the
2402
+ design reference for a bounded log per process, the process snapshot in a list, and reads that wait for output.