@parcha/agentrun-computer 0.1.0-beta.33 → 0.1.0-beta.35
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.
- package/README.md +308 -36
- package/dist/browser.d.ts +13 -14
- package/dist/browser.js +22 -17
- package/dist/browserbase.d.ts +3 -3
- package/dist/browserbase.js +16 -11
- package/dist/child.d.ts +2 -0
- package/dist/child.js +13 -2
- package/dist/chrome.d.ts +73 -0
- package/dist/chrome.js +224 -0
- package/dist/computerd-linux-amd64 +0 -0
- package/dist/computerd-linux-arm64 +0 -0
- package/dist/conformance/browserbase.js +1 -1
- package/dist/conformance/cases/gpu.d.ts +2 -0
- package/dist/conformance/cases/gpu.js +108 -0
- package/dist/conformance/cases/health.js +83 -3
- package/dist/conformance/cases/index.js +2 -0
- package/dist/conformance/cases/mount.d.ts +8 -1
- package/dist/conformance/cases/mount.js +4 -3
- package/dist/conformance/cases/provider.js +92 -3
- package/dist/conformance/cli.js +46 -7
- package/dist/conformance/daytona.js +2 -1
- package/dist/conformance/e2b.js +2 -1
- package/dist/conformance/fixture.js +24 -2
- package/dist/conformance/kernel.js +1 -1
- package/dist/conformance/kind.js +2 -1
- package/dist/conformance/local-chrome.d.ts +30 -0
- package/dist/conformance/local-chrome.js +36 -0
- package/dist/conformance/orgo.d.ts +11 -5
- package/dist/conformance/orgo.js +37 -8
- package/dist/conformance/phone-harness.js +2 -1
- package/dist/conformance/report.js +13 -7
- package/dist/conformance/runner.js +68 -18
- package/dist/conformance/types.d.ts +78 -18
- package/dist/conformance/types.js +10 -0
- package/dist/conformance/windows-fixture.d.ts +1 -0
- package/dist/conformance/windows-fixture.js +37 -0
- package/dist/daytona.d.ts +4 -6
- package/dist/daytona.js +97 -52
- package/dist/descriptor.d.ts +94 -0
- package/dist/descriptor.js +81 -0
- package/dist/descriptors/browserbase.d.ts +24 -0
- package/dist/descriptors/browserbase.js +18 -0
- package/dist/descriptors/daytona.d.ts +62 -0
- package/dist/descriptors/daytona.js +49 -0
- package/dist/descriptors/docker.d.ts +12 -0
- package/dist/descriptors/docker.js +17 -0
- package/dist/descriptors/e2b.d.ts +22 -0
- package/dist/descriptors/e2b.js +19 -0
- package/dist/descriptors/index.d.ts +229 -0
- package/dist/descriptors/index.js +19 -0
- package/dist/descriptors/kernel.d.ts +20 -0
- package/dist/descriptors/kernel.js +15 -0
- package/dist/descriptors/local-chrome.d.ts +17 -0
- package/dist/descriptors/local-chrome.js +21 -0
- package/dist/descriptors/modal.d.ts +50 -0
- package/dist/descriptors/modal.js +38 -0
- package/dist/descriptors/orgo.d.ts +88 -0
- package/dist/descriptors/orgo.js +44 -0
- package/dist/descriptors/phone-harness.d.ts +28 -0
- package/dist/descriptors/phone-harness.js +20 -0
- package/dist/descriptors/shared.d.ts +7 -0
- package/dist/descriptors/shared.js +6 -0
- package/dist/desktop.d.ts +4 -4
- package/dist/desktop.js +4 -4
- package/dist/docker/egress.d.ts +1 -1
- package/dist/docker/image.js +17 -15
- package/dist/docker/inspect.d.ts +147 -0
- package/dist/docker/inspect.js +335 -0
- package/dist/docker.d.ts +6 -4
- package/dist/docker.js +53 -41
- package/dist/drift.d.ts +6 -146
- package/dist/drift.js +14 -334
- package/dist/e2b.d.ts +2 -6
- package/dist/e2b.js +19 -22
- package/dist/index.d.ts +9 -10
- package/dist/index.js +14 -10
- package/dist/isolation.d.ts +0 -2
- package/dist/isolation.js +2 -18
- package/dist/janitor.d.ts +18 -1
- package/dist/janitor.js +67 -19
- package/dist/kernel.d.ts +3 -3
- package/dist/kernel.js +19 -14
- package/dist/kinds.d.ts +56 -30
- package/dist/kinds.js +19 -97
- package/dist/labels.d.ts +18 -0
- package/dist/labels.js +65 -2
- package/dist/local-chrome.d.ts +86 -0
- package/dist/local-chrome.js +475 -0
- package/dist/local-supervisor.d.ts +51 -0
- package/dist/local-supervisor.js +221 -0
- package/dist/modal.d.ts +15 -7
- package/dist/modal.js +83 -39
- package/dist/mount-archil.js +4 -4
- package/dist/orgo-channel.js +16 -13
- package/dist/orgo-desktop.d.ts +153 -0
- package/dist/orgo-desktop.js +1614 -0
- package/dist/orgo-names.d.ts +52 -0
- package/dist/orgo-names.js +84 -0
- package/dist/orgo.d.ts +18 -13
- package/dist/orgo.js +54 -128
- package/dist/phone-harness.d.ts +4 -8
- package/dist/phone-harness.js +48 -46
- package/dist/protocol.d.ts +20 -0
- package/dist/protocol.js +9 -0
- package/dist/provider.d.ts +151 -10
- package/dist/provider.js +70 -0
- package/dist/providers.d.ts +22 -17
- package/dist/providers.js +14 -16
- package/dist/result.d.ts +11 -1
- package/dist/result.js +11 -0
- package/dist/test-connection.js +2 -2
- package/package.json +42 -2
package/README.md
CHANGED
|
@@ -7,11 +7,18 @@ npm install @parcha/agentrun-computer@latest
|
|
|
7
7
|
```
|
|
8
8
|
|
|
9
9
|
```ts
|
|
10
|
-
import {
|
|
10
|
+
import { providerFor, providerModule } from "@parcha/agentrun-computer";
|
|
11
|
+
// One provider's class, from its own subpath: the package root loads no provider.
|
|
12
|
+
import { DockerProvider } from "@parcha/agentrun-computer/docker";
|
|
11
13
|
// The mount rule alone: loads no provider, no vendor SDK and no conformance code.
|
|
12
14
|
import { checkMount, readBackOf, WORKSPACE, type MountSpec } from "@parcha/agentrun-computer/mount";
|
|
13
15
|
```
|
|
14
16
|
|
|
17
|
+
The package root holds the protocol, the registry and the descriptors, and loads no provider: a provider loads by its
|
|
18
|
+
id (`providerFor(id, options)`, which imports that one provider's file), or from its subpath (`/docker`, `/daytona`,
|
|
19
|
+
`/modal`, `/e2b`, `/orgo`, `/orgo-desktop`, `/phone-harness`, `/browserbase`, `/kernel`, `/local-chrome`). A provider's
|
|
20
|
+
option types (`DockerProviderOptions`, `ModalProviderOptions` and the like) come from its subpath too, not the root.
|
|
21
|
+
|
|
15
22
|
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
23
|
vendor's SDK is the host's: Modal's `modal` package is imported only when the Modal provider is built, and the package
|
|
17
24
|
depends on nothing. A provider's mount kinds are its file's `MOUNT`, read with `(await providerModule(id)).MOUNT`,
|
|
@@ -33,6 +40,10 @@ full VM, a machine. The protocol has two layers:
|
|
|
33
40
|
inside. It never runs commands itself: the daemon does. This package has four: Docker, Modal's VM runtime, Daytona
|
|
34
41
|
and E2B (desktops), each one line of the provider registry (see [Adding a computer](#adding-a-computer)).
|
|
35
42
|
|
|
43
|
+
The protocol is published as a spec, [`spec/computer/`](../../spec/computer/README.md), at protocol version 0.1
|
|
44
|
+
(`PROTOCOL_VERSION`, which `hello` carries as `protocol`). Its JSON Schema and constants are generated from
|
|
45
|
+
`src/protocol.ts` by `node scripts/generate-computer-spec.mjs`, and a test fails when they drift.
|
|
46
|
+
|
|
36
47
|
## What it does today
|
|
37
48
|
|
|
38
49
|
The daemon answers `hello`, `ping`, `exec.run`, the `files.*` methods, `tar.*`, the `process.*` methods and
|
|
@@ -43,7 +54,7 @@ extension](#the-protocol-extension-kind-daemon-modes-screen-input-apps-lifetime)
|
|
|
43
54
|
|
|
44
55
|
```text
|
|
45
56
|
→ {"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"]}}
|
|
57
|
+
← {"jsonrpc":"2.0","id":1,"result":{"protocol":"0.1","version":"0.1.0-beta.30","os":"linux","kind":"linux","arch":"arm64","groups":["exec","files","processes"]}}
|
|
47
58
|
→ {"jsonrpc":"2.0","id":2,"method":"exec.run","params":{"argv":["uname","-m"],"timeoutMs":5000}}
|
|
48
59
|
← {"jsonrpc":"2.0","id":2,"result":{"exitCode":0,"stdout":"YWFyY2g2NAo=","stderr":"","timedOut":false,"truncated":false}}
|
|
49
60
|
```
|
|
@@ -94,7 +105,10 @@ extension](#the-protocol-extension-kind-daemon-modes-screen-input-apps-lifetime)
|
|
|
94
105
|
refuses uid 0 for its programs (root shares its uid with every root process of the vendor's); refuses to start while
|
|
95
106
|
any other process holds that uid (one could be signalled, traced or written to by them, and a vendor's agent among
|
|
96
107
|
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
|
|
108
|
+
brings its loopback up over rtnetlink (RTM_NEWLINK with IFF_UP on lo's index, as `ip link set lo up` does; and
|
|
109
|
+
RTM_NEWADDR for 127.0.0.1/8 where the kernel gave lo none), never by the SIOCSIFFLAGS ioctl, which gVisor's netstack
|
|
110
|
+
refuses in a new namespace (ENOTTY, live on Modal's gVisor, 11-11). It reads back lo up and running, 127.0.0.1 on it
|
|
111
|
+
and a listener there reached, and that no thread stayed behind and that the loopback alone is up or addressed
|
|
98
112
|
(a kernel with the tunnel modules loaded gives every new namespace its fallback tunnels, tunl0, gre0, sit0 and the
|
|
99
113
|
rest, down with no address: they stay so, since no program holds CAP_NET_ADMIN, and computerd's probe reports any
|
|
100
114
|
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
|
|
@@ -108,6 +122,24 @@ extension](#the-protocol-extension-kind-daemon-modes-screen-input-apps-lifetime)
|
|
|
108
122
|
`--egress`: such a computer's network is `none` (open and allowlists wait for a proxy out of that namespace, which
|
|
109
123
|
is not built yet). The code is `daemon/internal/isolate`; `test/docker/loopback-block.docker.test.mjs` runs each
|
|
110
124
|
provider's start in a root container beside a stand-in agent on 2280 and 49983.
|
|
125
|
+
- **Where root may not make the network namespace, init makes it inside a user namespace.** Root holds no
|
|
126
|
+
CAP_SYS_ADMIN on gVisor (Modal's GPU runtime), so `unshare(CLONE_NEWNET)` is EPERM. It may make a user namespace with
|
|
127
|
+
a network namespace inside it (a live probe on Modal's gVisor, 11-11). Init doesn't ask the vendor which it is: it
|
|
128
|
+
tries the plain namespace first, and on EPERM alone (`isolate.ErrNoNetworkNamespace`) it takes this way, whatever the
|
|
129
|
+
vendor.
|
|
130
|
+
- Init starts itself again as `computerd userns-init --started-in <its network namespace>`: a child in a new user
|
|
131
|
+
namespace that maps every uid and gid to itself, and a new network namespace. The root parent writes the map, which
|
|
132
|
+
needs CAP_SETUID and CAP_SETGID. The map keeps every id as it is, so the files the programs make, HOME, and the run's
|
|
133
|
+
folder belong to the same uid inside and out.
|
|
134
|
+
- The child does all of the above but make the namespace. Before touching anything, it reads back
|
|
135
|
+
(`isolate.KeepOwnNetwork`) that no thread is in the namespace it was started from. Then it brings the loopback up
|
|
136
|
+
over rtnetlink and reads it back, as above. The live T4 run at the fallback's first head (11-11) made the user and
|
|
137
|
+
network namespace, then failed at lo on the ioctl.
|
|
138
|
+
- The first init keeps no capability (no_new_privs, every set empty). It passes SIGTERM and SIGINT on, reaps, and exits
|
|
139
|
+
with the child's code.
|
|
140
|
+
- If neither way works, init refuses to start in words that name both, and the computer fails closed.
|
|
141
|
+
- hello says which fence holds, `fence: "netns"` or `"userns-netns"`. Every provider that starts init with
|
|
142
|
+
`--own-network` (Daytona, E2B, Orgo, Modal) refuses a hello that names neither.
|
|
111
143
|
- **Init drops its privileges itself, as any user, root included,** before it listens, so the line holds on every
|
|
112
144
|
vendor and not only where the provider drops capabilities (Docker: `--cap-drop ALL`). On every thread it sets
|
|
113
145
|
`no_new_privs`; drops from the bounding set each capability up to the kernel's last
|
|
@@ -237,7 +269,7 @@ Its whole tree ends when the program ends or is signalled to its end. Ids are `p
|
|
|
237
269
|
| `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
270
|
| `process.resize` | `id, cols, rows` | `{}`: the terminal's new size; the program gets SIGWINCH |
|
|
239
271
|
| `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 |
|
|
272
|
+
| `process.wait` | `id, timeoutMs` | `{running, exitCode, signal}`: waits up to `timeoutMs` (0 to a day) for the end, which comes once all the program wrote before it exited is in its log and streams; `running` is true on timeout |
|
|
241
273
|
|
|
242
274
|
- Each stream keeps its last 8 MiB in a ring. Offsets count bytes since the process started; `nextOffset` is where the
|
|
243
275
|
next read starts. A read below the ring's start begins at its start, and `dropped` says how many bytes were lost; an
|
|
@@ -394,7 +426,7 @@ in the kernel's tool registry, keyed by these groups.
|
|
|
394
426
|
| e2b | sandbox: `E2B_BASE_TEMPLATE` ("base"); desktop: `E2B_DESKTOP_TEMPLATE` ("desktop") |
|
|
395
427
|
| orgo | desktop: `ORGO_BASE_IMAGE` ("linux") |
|
|
396
428
|
| phone-harness | phone: `PHONE_IMAGE` ("android") |
|
|
397
|
-
| browserbase, kernel | browser: `BROWSER_IMAGE` ("chromium") |
|
|
429
|
+
| browserbase, kernel, local | browser: `BROWSER_IMAGE` ("chromium") |
|
|
398
430
|
|
|
399
431
|
| id | label | kinds | keys (required unless marked) | mounts | metered |
|
|
400
432
|
| --- | --- | --- | --- | --- | --- |
|
|
@@ -402,10 +434,11 @@ in the kernel's tool registry, keyed by these groups.
|
|
|
402
434
|
| daytona | Daytona | sandbox | `DAYTONA_API_KEY`; `DAYTONA_API_URL`, `DAYTONA_TARGET` (optional) | archil | yes |
|
|
403
435
|
| modal | Modal | sandbox | `MODAL_TOKEN_ID`, `MODAL_TOKEN_SECRET` | archil | yes |
|
|
404
436
|
| e2b | E2B | sandbox, desktop | `E2B_API_KEY` | archil | yes |
|
|
405
|
-
| orgo | Orgo | desktop | `ORGO_API_KEY` | none | yes |
|
|
437
|
+
| orgo | Orgo | desktop (Linux; Windows and macOS with `os`) | `ORGO_API_KEY` | none | yes |
|
|
406
438
|
| phone-harness | Phone harness | phone | `PHONE_HARNESS_API_KEY` | none | yes |
|
|
407
439
|
| browserbase | Browserbase | browser | `BROWSERBASE_API_KEY`, `BROWSERBASE_PROJECT_ID` | none | yes |
|
|
408
440
|
| kernel | Kernel | browser | `KERNEL_API_KEY` | none | yes |
|
|
441
|
+
| local | Local Chrome | browser | none | none | no |
|
|
409
442
|
|
|
410
443
|
- Each provider module exports `CAPABILITIES` beside `MOUNT` (the registry's contract, `ProviderModule`). A unit test
|
|
411
444
|
holds every registry provider's `CAPABILITIES` and `MOUNT` to its entry, and each provider built from the test fakes,
|
|
@@ -627,7 +660,7 @@ fixtures of every evasion it catches.
|
|
|
627
660
|
## Docker
|
|
628
661
|
|
|
629
662
|
```ts
|
|
630
|
-
import { DockerProvider } from "@parcha/agentrun-computer";
|
|
663
|
+
import { DockerProvider } from "@parcha/agentrun-computer/docker";
|
|
631
664
|
|
|
632
665
|
const docker = new DockerProvider({ daemonPath: "dist/computerd-linux-amd64" });
|
|
633
666
|
const made = await docker.create({ image: "debian:bookworm-slim", lifetimeMs: 600_000, network: "none" });
|
|
@@ -814,7 +847,8 @@ computer has the folder at one path, `/workspace` (`WORKSPACE`). `HOME` stays wh
|
|
|
814
847
|
Docker): `/workspace` is only the mount.
|
|
815
848
|
|
|
816
849
|
```ts
|
|
817
|
-
import {
|
|
850
|
+
import { WORKSPACE } from "@parcha/agentrun-computer";
|
|
851
|
+
import { DockerProvider } from "@parcha/agentrun-computer/docker";
|
|
818
852
|
|
|
819
853
|
const docker = new DockerProvider({ daemonPath: "dist/computerd-linux-amd64" });
|
|
820
854
|
// The run folder must exist, by its canonical path, and be writable by docker.user (below).
|
|
@@ -925,7 +959,7 @@ The provider owns the image its computers start from and makes it ready in its o
|
|
|
925
959
|
no other process to wait on: Docker's own tag is the shared state.
|
|
926
960
|
|
|
927
961
|
```ts
|
|
928
|
-
import { DockerProvider } from "@parcha/agentrun-computer";
|
|
962
|
+
import { DockerProvider } from "@parcha/agentrun-computer/docker";
|
|
929
963
|
|
|
930
964
|
const docker = new DockerProvider({ daemonPath: "dist/computerd-linux-amd64" }); // image: the default recipe
|
|
931
965
|
const image = await docker.image({ signal }); // built once; one inspect when Docker has it
|
|
@@ -1070,7 +1104,8 @@ in a long-lived service), with Docker's CLI on its PATH. A computer stops at its
|
|
|
1070
1104
|
its stopped container may stay up to one interval longer.
|
|
1071
1105
|
|
|
1072
1106
|
```ts
|
|
1073
|
-
import {
|
|
1107
|
+
import { sweep } from "@parcha/agentrun-computer";
|
|
1108
|
+
import { DockerProvider } from "@parcha/agentrun-computer/docker";
|
|
1074
1109
|
|
|
1075
1110
|
const swept = await sweep(new DockerProvider({ daemonPath: "dist/computerd-linux-amd64" }));
|
|
1076
1111
|
if (swept.ok) console.log(`deleted ${swept.value.deleted.join(", ") || "none"}; kept ${swept.value.kept}`);
|
|
@@ -1104,7 +1139,8 @@ as a caller's labels, with no code of its own: Docker writes them with `--label`
|
|
|
1104
1139
|
the computer through the provider's own exec, and a deleted computer holds no mount.
|
|
1105
1140
|
|
|
1106
1141
|
```ts
|
|
1107
|
-
import {
|
|
1142
|
+
import { releaseOlder, runLabels } from "@parcha/agentrun-computer";
|
|
1143
|
+
import { DockerProvider } from "@parcha/agentrun-computer/docker";
|
|
1108
1144
|
|
|
1109
1145
|
const docker = new DockerProvider({ daemonPath: "dist/computerd-linux-amd64" });
|
|
1110
1146
|
// A claim at epoch 3 takes the run over: the computers of epochs 1 and 2 go first.
|
|
@@ -1129,7 +1165,7 @@ sandbox, and the Daytona sweep wait through it too.
|
|
|
1129
1165
|
|
|
1130
1166
|
```ts
|
|
1131
1167
|
import { ModalClient } from "modal"; // the host's own client: this package imports nothing from the SDK
|
|
1132
|
-
import { ModalProvider } from "@parcha/agentrun-computer";
|
|
1168
|
+
import { ModalProvider } from "@parcha/agentrun-computer/modal";
|
|
1133
1169
|
|
|
1134
1170
|
const modal = new ModalProvider({
|
|
1135
1171
|
sdk: new ModalClient(),
|
|
@@ -1139,7 +1175,7 @@ const modal = new ModalProvider({
|
|
|
1139
1175
|
const made = await modal.create({ image: "debian:bookworm-slim", lifetimeMs: 600_000, network: "none" });
|
|
1140
1176
|
```
|
|
1141
1177
|
|
|
1142
|
-
`ModalProvider` makes Modal sandboxes on the VM runtime
|
|
1178
|
+
`ModalProvider` makes Modal sandboxes on the VM runtime, or on gVisor for a GPU computer (below), through the slice of Modal's JS SDK named by `ModalSdk`
|
|
1143
1179
|
(apps, images, sandboxes and five methods of a sandbox). It has not yet run against real Modal: every test uses a fake
|
|
1144
1180
|
of that slice, and the live conformance file waits for a key (below).
|
|
1145
1181
|
|
|
@@ -1151,7 +1187,9 @@ of that slice, and the live conformance file waits for a key (below).
|
|
|
1151
1187
|
- **The loopback block.** Init starts with `--own-network` (see [Init, the socket and the
|
|
1152
1188
|
bridge](#init-the-socket-and-the-bridge)) whatever Modal runs inside the sandbox: the daemon's programs reach their
|
|
1153
1189
|
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
|
|
1190
|
+
init refuses one another process holds). On the VM runtime Modal's root holds every capability, so the namespace is
|
|
1191
|
+
made there. On gVisor, a GPU computer's runtime, root may not make it, so init makes it inside a user namespace
|
|
1192
|
+
(below). Known
|
|
1155
1193
|
gap: network `open` is refused in words until a proxy carries it out of the daemon's own network, the next feature
|
|
1156
1194
|
after this one; a computer that needs pip, npm or git from the internet cannot be made on Modal until then.
|
|
1157
1195
|
- **The daemon is uploaded at create.** The sandbox's command is a small POSIX sh entrypoint (BusyBox and coreutils
|
|
@@ -1255,8 +1293,47 @@ of that slice, and the live conformance file waits for a key (below).
|
|
|
1255
1293
|
sandbox terminated if one lands later. A create that refuses its sandbox (drift, an abort, a failed upload)
|
|
1256
1294
|
terminates it and waits as release does, within `releaseMs`, so nothing is left listed when it returns. The terminate
|
|
1257
1295
|
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
|
-
|
|
1296
|
+
bound or cut short by an abort says the sandbox may still be ending and what `poll()` last read. Before that
|
|
1297
|
+
terminate, a create whose sandbox's own command had ended says so: its exit code and the tail of its output. When
|
|
1298
|
+
Modal refuses an exec with FAILED_PRECONDITION ("Modal Sandbox is shutting down", code `gone`), the command, init, has
|
|
1299
|
+
just exited and Modal ends the sandbox asynchronously, so create first waits up to `endedMs` (30 s) for `poll()` to
|
|
1300
|
+
read it finished, then reads init's words. The first GPU live run on gVisor ended this way, with no words.
|
|
1301
|
+
- **GPU.** `capabilities().gpu` declares Modal's GPU types by its own names (guide/gpu): `T4`, `L4`, `A10`, `L40S`,
|
|
1302
|
+
`A100` (40 GB), `A100-40GB`, `A100-80GB`, `RTX-PRO-6000`, `H100`, `H200`, `B200`, `B300`, at most 8 to a computer
|
|
1303
|
+
(Modal refuses an `A10` past 4, in its words). Its `H100!` and `B200+` variants are not offered: a computer gets the
|
|
1304
|
+
type it asked for. `spec.gpu: { type, count }` becomes the SDK's `gpu` (`"T4"`, `"A100-80GB:2"`), and since Modal
|
|
1305
|
+
offers GPUs on gVisor only, such a sandbox runs with `runtime: "gvisor"`; every other computer stays on the VM
|
|
1306
|
+
runtime. The drift check holds the runtime from both sides: the probe's kernel must be gVisor's on a GPU computer, and a
|
|
1307
|
+
VM's on any other. Modal reads no GPU back: the
|
|
1308
|
+
spec tag records the GPUs, and attach reports them on a computer the probe reads as gVisor. `capabilities().isolation`
|
|
1309
|
+
stays `vm`, every other computer's; a GPU computer's is declared apart, `gpu.isolation: "gvisor"`, so a caller that
|
|
1310
|
+
needs a VM's isolation can tell. Modal's GPUs are `preemptible: true`: Modal may move a GPU workload, so a run on one
|
|
1311
|
+
can be cut short (guide/preemption). `gpu.mounts` is `[]`: a GPU with an Archil mount is refused (checkGpu), since the
|
|
1312
|
+
Archil client's FUSE mount is not proven on gVisor yet. That keeps serve from giving a run a Modal GPU sandbox in either
|
|
1313
|
+
mode, as a serve sandbox always mounts the run's folder; the library takes one without a mount.
|
|
1314
|
+
- **The loopback fence on gVisor.** A GPU computer's init gets the same network namespace of its own, loopback alone,
|
|
1315
|
+
made another way.
|
|
1316
|
+
- Modal's gVisor gives root no CAP_SYS_ADMIN, so `unshare(CLONE_NEWNET)` is EPERM. With `--own-network`, init refused
|
|
1317
|
+
to start there (live on a T4, 11-10).
|
|
1318
|
+
- It does let root make a user namespace with a network namespace inside it (`unshare -Urn`, live on a T4, 11-11, as
|
|
1319
|
+
root and as nobody; nothing of Modal's runs or listens inside a gVisor sandbox, and every loopback port answered
|
|
1320
|
+
nothing).
|
|
1321
|
+
- So init, given the same `--own-network` on every runtime, makes the namespace inside a user namespace when root's
|
|
1322
|
+
own attempt is EPERM (the daemon's fallback, any vendor: see "Where root may not make the network namespace").
|
|
1323
|
+
- The first init stays PID 1 with no capability and no_new_privs set. It passes SIGTERM and SIGINT on and ends with
|
|
1324
|
+
the init that serves, so the sandbox lives as long as that one does.
|
|
1325
|
+
- Declared: `gpu.fence: "userns-netns"`. Read back: hello's `fence` on every connect, which the drift check requires
|
|
1326
|
+
to be one of the two. Create notes it when it is `userns-netns`, and the conformance report records it under the GPU
|
|
1327
|
+
computer's own name and role (`daemons[].fence`).
|
|
1328
|
+
- Proven in Docker. In `test/docker/modal-commands.docker.test.mjs`, a root container with Docker's default
|
|
1329
|
+
capabilities and no seccomp profile stands in for gVisor:
|
|
1330
|
+
- `--own-network` falls back and serves;
|
|
1331
|
+
- hello says `userns-netns`;
|
|
1332
|
+
- the programs run as 1000 with no capability, in another network and user namespace than PID 1's, on the loopback
|
|
1333
|
+
alone;
|
|
1334
|
+
- what they write in HOME is 1000's from outside;
|
|
1335
|
+
- with Docker's default seccomp profile (no user namespace either), init refuses in words that name both ways.
|
|
1336
|
+
- Not yet proven live on Modal.
|
|
1260
1337
|
|
|
1261
1338
|
### What every Modal fact rests on
|
|
1262
1339
|
|
|
@@ -1379,7 +1456,7 @@ named by any call.
|
|
|
1379
1456
|
## Daytona
|
|
1380
1457
|
|
|
1381
1458
|
```ts
|
|
1382
|
-
import { DaytonaProvider } from "@parcha/agentrun-computer";
|
|
1459
|
+
import { DaytonaProvider } from "@parcha/agentrun-computer/daytona";
|
|
1383
1460
|
|
|
1384
1461
|
const daytona = new DaytonaProvider({ apiKey, daemonPath: "dist/computerd-linux-amd64" });
|
|
1385
1462
|
const made = await daytona.create({ image: "my-snapshot", lifetimeMs: 600_000, network: "none" });
|
|
@@ -1502,6 +1579,7 @@ the TTL.
|
|
|
1502
1579
|
| `user` | none | the daemon runs as the provider's `daemonUser`; a spec cannot name a user |
|
|
1503
1580
|
| `release` | `stop`, `delete` | `POST /sandbox/{id}/stop` and `DELETE /sandbox/{id}` |
|
|
1504
1581
|
| `stopDeletes` | `true` with `autoDeleteMinutes: 0`, else `false` | `autoDeleteInterval` 0 deletes a sandbox as soon as it stops |
|
|
1582
|
+
| `gpu` | `H100`; at most 1 | daytona-gpu's own GPU (`DAYTONA_GPU_SNAPSHOT_GPU`, from GET /snapshots/daytona-gpu). A GPU computer is made from Daytona's GPU snapshot `daytona-gpu` (`DAYTONA_GPU_SNAPSHOT`: its default sandbox image, user `daytona` with passwordless sudo, plus the CUDA toolkit), sent as `snapshot`: its spec's image is `"daytona-gpu"` or `"default"`, and `check` refuses any other (a snapshot of box/Dockerfile among them) in words. A Daytona snapshot carries its own resources, so the create sends none (no `cpu`, `gpu`, `gpuType`, `memory` or `disk`: Daytona refuses them beside a snapshot, 400 "Cannot specify Sandbox resources when using a snapshot"), and the read-back's `snapshot`, `gpu` and `gpuType` must be the snapshot's. Another type or count needs a snapshot of its own, so `check` refuses it. A GPU computer's limits, declared on `capabilities().gpu`: `preemptible: true` (daytona.io/pricing lists its GPUs as "Preemptible GPU prices": a run on one can be cut short); `stopDeletes: true` (it is made with `autoDeleteInterval: 0`, whatever `autoDeleteMinutes` says. That is Daytona's ephemeral: its SDK's `ephemeral` sets it, and `CreateSandbox` has no `ephemeral` field, so none is sent. A GPU sandbox has no pause and no snapshot, so stopping it deletes it and nothing on it persists); `region: "earth"` (Daytona's one GPU region, sent as `target` in place of the provider's); `perGpu` 16 vCPU, 100 GiB memory and 400 GiB disk, the snapshot's; `mounts: []`, so a GPU computer with any mount is refused in words: daytona-gpu's user is not root and it has no Archil client. In serve's Mode 2 the run's folder is an Archil mount, so a Daytona GPU sandbox is refused there, and Settings' `gpu.why` says so. The org needs GPU credits, or the create is refused in Daytona's words. Create notes who installed the daemon: daytona-gpu's `daytona` user through passwordless sudo, or root on a snapshot of box/Dockerfile |
|
|
1505
1583
|
|
|
1506
1584
|
### What the provider does
|
|
1507
1585
|
|
|
@@ -1566,7 +1644,8 @@ From Daytona's read of the sandbox:
|
|
|
1566
1644
|
| `autoStopInterval`, `autoDeleteInterval` | `autoStopMinutes` (0 unset), `autoDeleteMinutes` (-1 unset), exactly |
|
|
1567
1645
|
| `autoDestroyAt` | set, and no later than the deadline plus the TTL's minute and 2 minutes of clock skew |
|
|
1568
1646
|
| `sandboxClass` | the provider's class |
|
|
1569
|
-
| `
|
|
1647
|
+
| `gpu`, `gpuType` | `spec.gpu`'s count (0 with none) and, with one, its type |
|
|
1648
|
+
| `public`, `kvm`, `volumes`, `linkedSandboxId` | false, not true, none, none |
|
|
1570
1649
|
|
|
1571
1650
|
From the daemon, over one connection: hello (the provider's version, `linux`, the `arch` option, every daemon
|
|
1572
1651
|
capability), `/proc/self/status` (Uid and Gid the daemon user's four times, no groups, `NoNewPrivs: 1`, `CapInh`,
|
|
@@ -1951,6 +2030,57 @@ A live run must show:
|
|
|
1951
2030
|
`packages/envd/internal/services/process/start.go`, `.../process/handler/handler.go:395-420`), and E2B's docs
|
|
1952
2031
|
(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`.
|
|
1953
2032
|
|
|
2033
|
+
## Orgo: Windows and macOS desktops (parked)
|
|
2034
|
+
|
|
2035
|
+
Orgo offers its Linux desktop alone, which runs computerd (`src/orgo.ts`). Its Windows and macOS desktops are parked:
|
|
2036
|
+
the descriptor lists them in `parked` (`ORGO_PARKED`), so `PROVIDERS` offers no configuration of either, Settings →
|
|
2037
|
+
Computers lists no Windows or macOS image, and an agent whose computer names `windows` or `macos` is refused at its
|
|
2038
|
+
run's start in words naming the image Orgo offers, `linux`. They do not run computerd either: computerd for Windows and
|
|
2039
|
+
macOS is CP-8, deferred. `create({ os: "windows" | "macos", apiKey, workspaceId })` still builds an
|
|
2040
|
+
`OrgoDesktopProvider` (`src/orgo-desktop.ts`) with daemon `none`, for the conformance suite and the tests. It answers
|
|
2041
|
+
the protocol's methods in process over Orgo's REST API, as the phone harness and Browserbase do. Its spec's image is
|
|
2042
|
+
`"windows"` (`ORGO_WINDOWS_IMAGE`, Orgo's Windows Server 2019) or `"macos"` (`ORGO_MACOS_IMAGE`): the one the provider was
|
|
2043
|
+
built for.
|
|
2044
|
+
|
|
2045
|
+
- **What each offers.** The protocol groups, by Orgo's calls:
|
|
2046
|
+
- `screen`: Orgo's screenshot (`response_format=base64&format=png`). A region is cropped in process. The live view
|
|
2047
|
+
polls it about once a second, scaled by Orgo past `maxWidth`.
|
|
2048
|
+
- `input.pointer` and `input.keys`: Orgo's click, mouse-move, drag, scroll, type and key calls.
|
|
2049
|
+
- `exec`: Orgo's bash call. On Windows that is PowerShell: argv becomes a call operator over single-quoted words,
|
|
2050
|
+
and the exit code is `$LASTEXITCODE`. On macOS it is the shell, every word quoted. argv is never a shell string.
|
|
2051
|
+
- `files`, Windows only: one PowerShell script whose request is base64 JSON. A write over 96 KiB is uploaded first
|
|
2052
|
+
(Orgo's `/files/upload` with `destPath`).
|
|
2053
|
+
- No `processes`: Orgo runs a command and waits for it. No `tar`, and no mount.
|
|
2054
|
+
- Network `open`, never read back from inside: Orgo has no egress control, and no daemon runs in the computer to
|
|
2055
|
+
hold its programs to loopback, so the provider cannot prove `none`.
|
|
2056
|
+
- **What Orgo's API cannot do is refused in words, and a refused batch runs nothing:**
|
|
2057
|
+
- on Windows, a triple click, keys held during a click, a drag of more than two points, a sideways or pixel
|
|
2058
|
+
scroll, and `hold`;
|
|
2059
|
+
- on macOS, a right-button double click or drag;
|
|
2060
|
+
- `+` as a key, since it joins Orgo's combinations.
|
|
2061
|
+
- **down and up.** Orgo has no separate press and release. A `down` is held in the client, across batches as the
|
|
2062
|
+
protocol says. Its `up` becomes one click (the pointer did not move) or one drag (from where it went down). A batch
|
|
2063
|
+
that fails releases a press it holds.
|
|
2064
|
+
- **The cursor.** The live view's frames carry the place the client last moved the pointer to (`cursor`), and a move is
|
|
2065
|
+
a new frame even when Orgo's screenshot leaves the cursor out.
|
|
2066
|
+
- **Lifetime.** The name carries the run, the epoch and the deadline, as the Linux desktop's does (`src/orgo-names.ts`),
|
|
2067
|
+
and the janitor ends a computer by it. On Windows, Orgo's `ends_in_hours` is the backstop. A Mac has no Orgo end.
|
|
2068
|
+
The other labels are a file the provider writes in the computer (`C:\ProgramData\agentrun\labels.json`,
|
|
2069
|
+
`/Users/Shared/agentrun/labels.json`). A program in the computer can change that file, so list, the janitor and
|
|
2070
|
+
the takeover trust the name, which only the key can change.
|
|
2071
|
+
- **attach** reports who the programs run as. On Windows that is `0:0` for a member of the Administrators group,
|
|
2072
|
+
since it can do what a root can, and is said as it is.
|
|
2073
|
+
- **Idle suspension.** Nothing runs in a computer Orgo does not read `running`: any action wakes a suspended one.
|
|
2074
|
+
`list` reads the labels file of a running computer alone, and attach, connect and extend refuse the others in words.
|
|
2075
|
+
- **Release** deletes. A Mac Orgo manages answers 409 to a delete. That is refused in Orgo's words, and the Mac is
|
|
2076
|
+
left.
|
|
2077
|
+
- **Conformance.** `COMPUTER_ORGO_OS=windows` (or `macos`) with `--kind desktop` runs the desktop's cases:
|
|
2078
|
+
- The Windows fixture is a PowerShell script this package carries (`src/conformance/windows-fixture.ts`): the same
|
|
2079
|
+
window as `computerd-fixture`, started with `Start-Process` through exec and files.
|
|
2080
|
+
- The cases written for Linux (exec's and files' POSIX programs and paths) are skipped in words (`caseOs`).
|
|
2081
|
+
- The live run needs Orgo's Scale plan or a Windows computer bought on the plan; the macOS run needs Orgo's Mac
|
|
2082
|
+
access.
|
|
2083
|
+
|
|
1954
2084
|
## Browsers: Browserbase and Kernel
|
|
1955
2085
|
|
|
1956
2086
|
A browser is a computer of kind `browser`: a vendor's browser session that answers CDP. No computerd runs (daemon
|
|
@@ -2006,6 +2136,82 @@ AGENTRUN_COMPUTER_LIVE_KERNEL=1 COMPUTER_KERNEL_API_KEY=... \
|
|
|
2006
2136
|
npm run conformance -w @parcha/agentrun-computer -- --provider kernel
|
|
2007
2137
|
```
|
|
2008
2138
|
|
|
2139
|
+
## A local browser: this machine's Chrome, no keys
|
|
2140
|
+
|
|
2141
|
+
The `local-chrome` provider (Local Chrome, `local-chrome.ts`) is a computer of kind `browser` that is the Chrome or Chromium
|
|
2142
|
+
on the machine AgentRun runs on. No vendor, no key, nothing billed.
|
|
2143
|
+
|
|
2144
|
+
```ts
|
|
2145
|
+
import { LocalBrowserProvider } from "@parcha/agentrun-computer/local-chrome";
|
|
2146
|
+
|
|
2147
|
+
const local = new LocalBrowserProvider({ env: { PATH: process.env.PATH } }); // or { executablePath: "/usr/bin/chromium" }
|
|
2148
|
+
const made = await local.create({ image: "chromium", lifetimeMs: 30 * 60_000, network: "open" });
|
|
2149
|
+
const connected = await local.connect(made.value); // connected.value.cdp.url: ws://127.0.0.1:<port>/devtools/browser/<id>
|
|
2150
|
+
await local.release(made.value, "delete");
|
|
2151
|
+
```
|
|
2152
|
+
|
|
2153
|
+
Each computer is one Chrome with a throwaway profile and a debugging port Chrome picks on 127.0.0.1. It runs
|
|
2154
|
+
headless by default. `headed: true` shows the window, for a person watching on this machine. `create()` returns
|
|
2155
|
+
once `/json/version` answers on that port. `connect()` hands over the DevTools URL. `release("delete")` ends Chrome and
|
|
2156
|
+
removes its profile and every other file of it. `list()` and attach by labels find the provider's own browsers by
|
|
2157
|
+
`browser.json` in each browser's directory under the root (default `<tmpdir>/agentrun-local-browser-<uid>`, made 0700,
|
|
2158
|
+
refused when another user can write it). That file holds the labels and the deadline.
|
|
2159
|
+
|
|
2160
|
+
Lifetime: each browser runs under a supervisor of its own (`local-supervisor.ts`), a small detached Node process. It
|
|
2161
|
+
ends Chrome and removes its files at the deadline, on release, or when Chrome exits, whatever became of the process
|
|
2162
|
+
that made the browser. So a run that crashes leaves no Chrome behind once its deadline passes. `list()` reads the
|
|
2163
|
+
deadline, so the janitor's `sweep` also ends a browser whose supervisor was killed (`lifetime: "janitor"`). The cap is
|
|
2164
|
+
24 h.
|
|
2165
|
+
|
|
2166
|
+
Finding Chrome: the `executablePath` option, else `PI_BROWSER_CHROME` or `CHROME_PATH` in the `env` option, else the
|
|
2167
|
+
first `google-chrome`, `google-chrome-stable`, `chromium` or `chromium-browser` on that env's `PATH`, else the usual
|
|
2168
|
+
install places. The library reads no environment of its own: the host passes `env`. With none found, `check()`,
|
|
2169
|
+
`create()` and `testConnection()` say what to install and which setting names one. `testConnection()` starts the Chrome
|
|
2170
|
+
once, headless on a blank page with a proxy that reaches nothing, to prove it starts here with its sandbox on. It
|
|
2171
|
+
keeps nothing.
|
|
2172
|
+
|
|
2173
|
+
The fence and the sandbox are PR #1718's:
|
|
2174
|
+
|
|
2175
|
+
- Chrome's own sandbox is always on. A start as root is refused (Chrome refuses root with its sandbox on), and so is a
|
|
2176
|
+
Chrome that cannot start its sandbox here, in words that name the fix (an AppArmor profile on Ubuntu 23.10 and later,
|
|
2177
|
+
or Chrome's setuid helper). Nothing retries without the sandbox.
|
|
2178
|
+
- Every request Chrome makes goes through the browser's egress proxy, the same one Docker's computers use
|
|
2179
|
+
(`docker/egress-proxy.ts`). A spec's `network` is `"open"` (no list) or `{ allow: [names and CIDRs] }`. With a list,
|
|
2180
|
+
the proxy reaches only those hosts, on ports 80 and 443, and refuses any other host by name before its lookup. A
|
|
2181
|
+
CIDR that covers a refused range (loopback, private) is refused at `check()`. The proxy reaches public addresses only, each checked after its lookup:
|
|
2182
|
+
this machine's loopback, private networks, link-local and a cloud's metadata address (169.254.169.254) are
|
|
2183
|
+
refused. Chrome is started with `--proxy-bypass-list=<-loopback>`, so loopback goes through the proxy too. Its
|
|
2184
|
+
`--host-resolver-rules=MAP <proxy> <proxy>, MAP * ~NOTFOUND` means Chrome resolves no name itself, so a request
|
|
2185
|
+
sent around the proxy reaches nothing. QUIC is off (`--disable-quic`), and WebRTC sends no UDP
|
|
2186
|
+
(`--webrtc-ip-handling-policy=disable_non_proxied_udp`). The proxy and its relay live in the supervisor, so the fence
|
|
2187
|
+
holds for a browser driven from another process, and a browser whose supervisor is gone reaches nothing.
|
|
2188
|
+
|
|
2189
|
+
Capabilities: `network: ["open"]` (public addresses), `isolation: "host"`, `daemon: "none"`, groups `cdp` only (no
|
|
2190
|
+
live view: run it headed to watch), `release: ["delete"]`, no mount.
|
|
2191
|
+
|
|
2192
|
+
Known limits, so it is for local and development use:
|
|
2193
|
+
|
|
2194
|
+
- The debugging port has no auth. Any process on this machine that finds the port can drive the browser, read its
|
|
2195
|
+
pages and cookies, and navigate it. The port is on 127.0.0.1 only, and it is random per browser.
|
|
2196
|
+
- Chrome runs as the user AgentRun runs as, on this host. Chrome's sandbox is the only isolation between a page and
|
|
2197
|
+
the machine. The fence keeps the browser off this machine's services and private networks, but the browser
|
|
2198
|
+
process itself is not in a container or a VM.
|
|
2199
|
+
- The page cannot reach this machine's services, but the supervisor's relay port on 127.0.0.1 is reachable by local
|
|
2200
|
+
processes. Through it they reach public addresses, which they can reach anyway.
|
|
2201
|
+
- No proxy of your own, no extensions, no saved profiles: each browser starts from an empty profile that goes with it.
|
|
2202
|
+
|
|
2203
|
+
Driving it: pi-browser's raw-CDP driver (`@parcha/pi-browser/driver/cdp`) drives this browser with the same
|
|
2204
|
+
`snapshot` and `run` actions the vendor browsers take, with no Stagehand and nothing loaded into Chrome. `run` code is
|
|
2205
|
+
refused there; navigation is a `goto` action. Its snapshot does not read a frame another site runs in its own
|
|
2206
|
+
process (a cross-origin iframe). The snapshot names each frame it left out, so an agent knows the page has more.
|
|
2207
|
+
|
|
2208
|
+
The conformance module starts a real Chrome, so it waits for its switch:
|
|
2209
|
+
|
|
2210
|
+
```sh
|
|
2211
|
+
AGENTRUN_COMPUTER_LIVE_LOCAL_CHROME=1 [COMPUTER_LOCAL_CHROME_PATH=/usr/bin/chromium] \
|
|
2212
|
+
npm run conformance -w @parcha/agentrun-computer -- --provider local-chrome --kind browser
|
|
2213
|
+
```
|
|
2214
|
+
|
|
2009
2215
|
## Phone harness (the phone kind)
|
|
2010
2216
|
|
|
2011
2217
|
```ts
|
|
@@ -2126,7 +2332,7 @@ through `apps.ui_tree` (`src/conformance/cases/settings.ts`):
|
|
|
2126
2332
|
|
|
2127
2333
|
A provider for another vendor passes the same suite as Docker's, with one command. The suite is data: each case in
|
|
2128
2334
|
`src/conformance/cases/` names its level, its group (`health`, `exec`, `files`, `process`, `provider`, `drift`,
|
|
2129
|
-
`isolation`, `mount`, `screen`, `input`, `touch`, `apps`, `lifetime`, `browser`) and the capabilities it needs, and uses only `ComputerProvider`,
|
|
2335
|
+
`isolation`, `mount`, `screen`, `input`, `touch`, `apps`, `lifetime`, `browser`, `gpu`) and the capabilities it needs, and uses only `ComputerProvider`,
|
|
2130
2336
|
`ComputerClient` and the suite's assertion helpers, so the same cases run against a provider with daemon `none`.
|
|
2131
2337
|
|
|
2132
2338
|
```sh
|
|
@@ -2151,11 +2357,16 @@ core PASS 54/54 · 10 optional cases skipped, not declared · full 10/13 · moun
|
|
|
2151
2357
|
An id is resolved through the provider registry, and only there; the usage lists every id it holds. A module path is
|
|
2152
2358
|
resolved from the directory npm was run in. It exits 0 when Core passes, 1 when it fails, 2 on a
|
|
2153
2359
|
usage error, and 3 on a partial run; `--json` prints the report object (`{ provider, providerVersion, kind,
|
|
2154
|
-
daemonMode, image,
|
|
2155
|
-
undeclared? }], core, undeclared, cleanup, notes?, computerNotes? }`). A failure is listed under
|
|
2156
|
-
case found.
|
|
2157
|
-
|
|
2158
|
-
|
|
2360
|
+
daemonMode, image, daemons: [{ computer, role, version, os, arch, fence? }], only?, coreNotRun?, results: [{ id, level,
|
|
2361
|
+
group, status, reason?, undeclared? }], core, undeclared, cleanup, notes?, computerNotes? }`). A failure is listed under
|
|
2362
|
+
its line with what the case found. A computer's `role` is `"shared"` for the run's computer, which the cases that need
|
|
2363
|
+
none of their own share, else the id of the case that made it. `daemons` holds each computer's first `hello`, one entry
|
|
2364
|
+
per computer in the order they answered (empty when none did), so computers of one run that differ are kept apart: a GPU
|
|
2365
|
+
computer's `fence` is not the run's computer's. The text report prints each as `daemon <computer> (<role>): computerd
|
|
2366
|
+
<version> <os>/<arch> · fence <fence>` above the verdict. `computerNotes` (`[{ computer, role, note }]`, absent when
|
|
2367
|
+
empty) holds every note a `create` returned beside its ref, such as a probe target that accepted and sent nothing back,
|
|
2368
|
+
naming the computer and its role, in the order they came; the text report prints each as `note <computer> (<role>):
|
|
2369
|
+
<words>` above the verdict, so a run that passes Core never hides one. Notes an
|
|
2159
2370
|
`attach` returns are not carried: cases call `attach` on the provider directly, so the runner never sees them.
|
|
2160
2371
|
|
|
2161
2372
|
`--only` that leaves any Core case out is a partial run: `core` is `"partial"` when every case that ran passed (a
|
|
@@ -2173,6 +2384,10 @@ capabilities), no case of the run failed (a declared optional group that fails w
|
|
|
2173
2384
|
every required group has at least one passing case and no Core case skipped but for an optional group the computer does
|
|
2174
2385
|
not declare, and the run left nothing behind. A Full case that skips is owed by no group: a provider may refuse in
|
|
2175
2386
|
words what its kind does not require, as the phone harness refuses `touch.pinch`, and the report still shows the skip.
|
|
2387
|
+
A case is written for the systems its `os` names (`caseOs`). Without one, a case that needs exec or processes runs
|
|
2388
|
+
POSIX programs (`sh`, `id`, `/proc`) and is Linux's alone, and one that needs files names POSIX paths and is no Windows
|
|
2389
|
+
computer's. A computer of another os skips it in words ("the case is written for linux, and this computer runs
|
|
2390
|
+
windows"), after the check of what it declares.
|
|
2176
2391
|
`none` is no computer, and `--kind` refuses it in words. Given no cases, a run takes `casesFor(machineKind)`: a
|
|
2177
2392
|
browser's own cases (`browserCases`), every other kind the suite's (`conformanceCases`), in the library as in the CLI;
|
|
2178
2393
|
`kindCases` draws from the same by kind. `kindCases`, `kindVerdict` and `casesFor` are exported, so the serve side reads
|
|
@@ -2300,24 +2515,77 @@ computer's `HOME`, which the provider sets, is a directory its user can write, a
|
|
|
2300
2515
|
From code: `runConformance(provider, { image, only?, signal?, drifted?, mountFor?, caseTimeoutMs?, cleanupTimeoutMs?,
|
|
2301
2516
|
fixture?, fetch? })` returns the report, and `formatReport(report)` the text above.
|
|
2302
2517
|
|
|
2518
|
+
## Persistent computers: an agent's own
|
|
2519
|
+
|
|
2520
|
+
A run's computer belongs to its run: it has a deadline (`lifetimeMs`, required), and the janitor or the vendor ends it
|
|
2521
|
+
once the deadline passes. A persistent computer belongs to an agent instead. It outlives the agent's runs, which take
|
|
2522
|
+
it one at a time, and it keeps its files between them. The contract, in `src/provider.ts` and `src/labels.ts`:
|
|
2523
|
+
|
|
2524
|
+
- **Declared.** A provider that keeps computers for agents declares `capabilities().persistence`:
|
|
2525
|
+
`{ keepsState: true, resume }`. `keepsState`: a detached computer keeps its files. `resume`: `true` when it comes back
|
|
2526
|
+
as it was, its processes still running; `false` when it boots again from its kept disk. A provider that declares none
|
|
2527
|
+
refuses `spec.owner` in `check()`, in words, before any vendor call, and refuses `release(ref, "detach")`, the
|
|
2528
|
+
computer left as it was.
|
|
2529
|
+
- **Owned.** `spec.owner: { agent, idleTtlMs? }` makes the computer the agent's. It has no run deadline: the rule that
|
|
2530
|
+
refuses a computer with no deadline is a run's computers' alone, and an owned spec that names `lifetimeMs` is refused
|
|
2531
|
+
(`checkTenure(spec, capabilities)` holds both rules, for every provider's `check()`). The computer carries the owner
|
|
2532
|
+
label, `agentrun.owner=agent:<id>` (`OWNER_LABEL`), and `agentrun.idle-ttl-ms` (`IDLE_TTL_LABEL`) when the owner set
|
|
2533
|
+
an idle TTL; `ownerLabels(owner)` gives both and `ownerOf(labels)` reads them back.
|
|
2534
|
+
- **Detach.** `release(ref, "detach")` stops the computer with its state kept. It stays the agent's, listed `stopped`,
|
|
2535
|
+
with `detachedAt`, when it was detached. Only an owned computer detaches: a run's computer refuses it in words and
|
|
2536
|
+
runs on. `"delete"` deletes an owned computer, and only the agent or its owner asks for that: the caller's rule, not
|
|
2537
|
+
the provider's.
|
|
2538
|
+
- **Attached under a new claim.** A run takes the computer with `attach({ id }, { claim: { run, epoch } })`. The
|
|
2539
|
+
provider brings it back (starts it, when detached) and records the claim, so the computer carries the run's
|
|
2540
|
+
`agentrun.run` and `agentrun.epoch` and `releaseOlder` of that run finds it. A claim of the same run below the epoch
|
|
2541
|
+
the computer carries is refused as fenced, with nothing changed. A claim on a computer with no owner is refused: a
|
|
2542
|
+
run's computer belongs to its run.
|
|
2543
|
+
- **The janitor.** A computer is owned when it carries the owner label or its provider's `list()` marks it `owned: true`
|
|
2544
|
+
(with `owner` when the listing knows it: a vendor whose stopped computer shows no labels). `sweep` never deletes an
|
|
2545
|
+
owned computer by a deadline. It deletes one only when its owner agent is
|
|
2546
|
+
gone (`ownerGone(agent)`, the caller's answer, in `SweepOptions`), or when it has been detached for longer than its
|
|
2547
|
+
owner's idle TTL. An owner label it cannot read keeps the computer: the janitor never deletes an agent's state on a
|
|
2548
|
+
rule it cannot read. On a provider that declares persistence it sweeps owned computers under lifetime `"vendor"`
|
|
2549
|
+
too, since no vendor ends them. `releaseOlder` detaches an owned computer of a lower epoch and never deletes it: the
|
|
2550
|
+
new claim attaches it.
|
|
2551
|
+
- **Conformance.** `provider.owner` and `provider.detach` are Core for every provider: `check()` refuses an owner
|
|
2552
|
+
without persistence, and a lifetime with one; a run's computer refuses detach and runs on. `provider.persistence` is
|
|
2553
|
+
Full, run where persistence is declared: create with an owner, write a file, detach, attach by id under a new claim,
|
|
2554
|
+
read the file back (with `resume`, find the process still running), refuse a fenced claim, then delete.
|
|
2555
|
+
|
|
2556
|
+
`test/fake-computer.mjs`'s `persistence` option is a provider that declares it and passes the cases. Orgo's provider
|
|
2557
|
+
is the first vendor to wire it.
|
|
2558
|
+
|
|
2303
2559
|
## Adding a computer
|
|
2304
2560
|
|
|
2305
|
-
A new computer is one provider file and one
|
|
2306
|
-
|
|
2561
|
+
A new computer is one provider file and one descriptor, `src/descriptors/<id>.ts`, declared once and listed in
|
|
2562
|
+
`DESCRIPTORS` (`src/descriptors/index.ts`). Everything else is derived from the descriptors: the registry
|
|
2563
|
+
(`src/providers.ts`, id to `load()`), the kind registry's `PROVIDERS` (Settings' rows), and the ids. The conformance
|
|
2564
|
+
CLI (and serve) resolve providers through them, so neither needs an edit:
|
|
2307
2565
|
|
|
2308
2566
|
```ts
|
|
2309
|
-
export const
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2567
|
+
export const FLY = defineProvider({
|
|
2568
|
+
id: "fly",
|
|
2569
|
+
label: "Fly",
|
|
2570
|
+
keys: [{ name: "FLY_API_TOKEN", option: "apiToken", required: true }], // each key and the create() option it fills
|
|
2571
|
+
metered: true,
|
|
2572
|
+
mounts: [],
|
|
2573
|
+
network: ["none", "open"], // the network forms its computers make: none, open, allow
|
|
2574
|
+
capabilities: [{ kind: "linux", groups: ["exec", "files", "processes"] }], // one per configuration
|
|
2575
|
+
load: () => import("../fly.js"),
|
|
2576
|
+
});
|
|
2316
2577
|
```
|
|
2317
2578
|
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
`
|
|
2579
|
+
A descriptor is data and a lazy `load()`: it imports `../descriptor.js` and other descriptors alone, so loading the
|
|
2580
|
+
registry, the kind registry or the package root loads no provider and no vendor SDK. `defineProvider` checks it when
|
|
2581
|
+
it is declared (`descriptorProblems`), in words. Its fields: `id`, `label`, `keys` (each key's name, the option it
|
|
2582
|
+
fills, and whether it is required), `settings` (a setting that is no key but fills an option, with its default),
|
|
2583
|
+
`metered`, `mounts`, `network` (the network forms its computers make, at least one of none, open and allow),
|
|
2584
|
+
`capabilities` (the kind and groups of each configuration), `defaultImage` (by setting kind),
|
|
2585
|
+
`prepareImage` (a provider that builds or pulls its image before a run), `local` (a computer on this host), and
|
|
2586
|
+
`ledger` (the option a provider's ledger fills). `providerFor(id, options)` builds a provider by id from its options and
|
|
2587
|
+
refuses an id it does not hold, naming the ones it does. The provider file, `src/<vendor>.ts`, exports what a
|
|
2588
|
+
`ProviderModule` is:
|
|
2321
2589
|
|
|
2322
2590
|
- the provider class, which implements `ComputerProvider` and reports the registry id as its `id`;
|
|
2323
2591
|
- `MOUNT`, the mount kinds its computers take;
|
|
@@ -2362,6 +2630,10 @@ AGENTRUN_COMPUTER_LIVE_MODAL=1 npm run test:modal -w @parcha/agentrun-computer
|
|
|
2362
2630
|
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
|
|
2363
2631
|
```
|
|
2364
2632
|
|
|
2633
|
+
`npm test` also runs `test/local-chrome-live.test.mjs` on a real Chrome where one is on PATH (or `CHROME_PATH` names
|
|
2634
|
+
one) and starts here with its sandbox on: it creates a local browser, drives it over CDP, checks that a service on this
|
|
2635
|
+
machine's loopback is out of its reach, and releases it. Elsewhere it skips with the reason.
|
|
2636
|
+
|
|
2365
2637
|
Where Xvfb is on PATH, the Go tests also run the X client, and screen and input against the fixture, on a real X
|
|
2366
2638
|
server; elsewhere those tests skip in words and the fake X server's tests still run.
|
|
2367
2639
|
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ComputerClient, type Group, type HelloResult } from "./protocol.js";
|
|
2
2
|
import type { ComputerCapabilities, ComputerSpec, Refusal } from "./provider.js";
|
|
3
|
-
import { type ComputerErrorCode, type Result } from "./result.js";
|
|
4
|
-
/** The one image a browser computer runs: the vendor's own Chromium. */
|
|
5
|
-
export declare const BROWSER_IMAGE = "chromium";
|
|
3
|
+
import { type ComputerError, type ComputerErrorCode, type Result } from "./result.js";
|
|
6
4
|
/**
|
|
7
5
|
* Where a provider keeps the URLs it was handed, by session id, in memory only. Default a Map of its own; a host that
|
|
8
6
|
* builds one provider per call passes one store to all of them (pi-browser's process-wide holdings).
|
|
@@ -33,17 +31,18 @@ export interface ReleaseConfirm {
|
|
|
33
31
|
export declare const DEFAULT_CONFIRM: ReleaseConfirm;
|
|
34
32
|
export declare const defaultSleep: (ms: number) => Promise<void>;
|
|
35
33
|
/** A vendor call's failure as the provider returns it: a code and words, and the error the call threw, for a caller that rethrows it as it was. */
|
|
36
|
-
export type VendorFailure = {
|
|
37
|
-
code: ComputerErrorCode;
|
|
38
|
-
message: string;
|
|
34
|
+
export type VendorFailure = ComputerError & {
|
|
39
35
|
readonly cause?: unknown;
|
|
40
36
|
};
|
|
41
|
-
/**
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
/**
|
|
38
|
+
* A failure whose cause rides along out of sight: not enumerable, so it is in no JSON, no log line and no report. With
|
|
39
|
+
* code vendor, vendor (the provider's id) names whose.
|
|
40
|
+
*/
|
|
41
|
+
export declare function causedFail(code: ComputerErrorCode, message: string, cause: unknown, vendor: string): Result<never>;
|
|
42
|
+
/** The error a vendor call threw, behind a failure causedFail made; undefined for any other. */
|
|
44
43
|
export declare const causeOf: (result: Result<unknown>) => unknown;
|
|
45
|
-
/** The code a vendor's HTTP status reads as. */
|
|
46
|
-
export declare function statusCode(status: number | undefined
|
|
44
|
+
/** The code a vendor's HTTP status reads as: one of ours, or vendor. */
|
|
45
|
+
export declare function statusCode(status: number | undefined): ComputerErrorCode;
|
|
47
46
|
/** Why labels are not ones a browser provider writes into a vendor's metadata, in words; undefined when they are. */
|
|
48
47
|
export declare function labelsProblem(labels: unknown): string | undefined;
|
|
49
48
|
/** A label a vendor's query can carry as it is: plain characters, so a quote never ends the query early. */
|
|
@@ -117,9 +116,9 @@ export declare class BrowserVendorError extends Error {
|
|
|
117
116
|
export declare const plainCode: (code: unknown) => string | undefined;
|
|
118
117
|
/**
|
|
119
118
|
* A vendor call's thrown error as a result: aborted, or the code its status reads as, in words that name the call and the
|
|
120
|
-
* status alone. The error itself rides along as the failure's hidden cause (
|
|
119
|
+
* status alone. The error itself rides along as the failure's hidden cause (causedFail). vendor is the provider's id.
|
|
121
120
|
*/
|
|
122
|
-
export declare function vendorFailure(vendor:
|
|
121
|
+
export declare function vendorFailure(vendor: string, name: string, call: string, error: unknown): Result<never>;
|
|
123
122
|
/**
|
|
124
123
|
* Why a vendor's CDP URL is not one to hand a driver, in words that never carry it; undefined when it is. It must be wss:
|
|
125
124
|
* (the session's signing key rides it) on the vendor's own domain or a host under it: a vendor answer that named another
|