@parcha/agentrun-computer 0.1.0-beta.33 → 0.1.0-beta.34
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 +169 -15
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +6 -3
- package/dist/browserbase.d.ts +3 -1
- package/dist/browserbase.js +3 -1
- 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/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 +14 -0
- package/dist/conformance/cli.js +46 -7
- package/dist/conformance/local.d.ts +30 -0
- package/dist/conformance/local.js +36 -0
- package/dist/conformance/report.js +10 -5
- package/dist/conformance/runner.js +45 -13
- package/dist/conformance/types.d.ts +63 -16
- package/dist/daytona.d.ts +32 -3
- package/dist/daytona.js +96 -24
- package/dist/docker.d.ts +3 -1
- package/dist/docker.js +11 -3
- package/dist/drift.d.ts +3 -1
- package/dist/drift.js +9 -0
- package/dist/e2b.d.ts +3 -1
- package/dist/e2b.js +7 -4
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/isolation.d.ts +0 -2
- package/dist/isolation.js +0 -16
- package/dist/kernel.d.ts +3 -1
- package/dist/kernel.js +3 -1
- package/dist/kinds.d.ts +10 -4
- package/dist/kinds.js +26 -6
- package/dist/labels.d.ts +6 -0
- package/dist/labels.js +26 -1
- package/dist/local-supervisor.d.ts +51 -0
- package/dist/local-supervisor.js +221 -0
- package/dist/local.d.ts +89 -0
- package/dist/local.js +472 -0
- package/dist/modal.d.ts +31 -4
- package/dist/modal.js +90 -30
- package/dist/orgo.d.ts +3 -1
- package/dist/orgo.js +14 -27
- package/dist/phone-harness.d.ts +3 -1
- package/dist/phone-harness.js +7 -4
- package/dist/protocol.d.ts +20 -0
- package/dist/protocol.js +9 -0
- package/dist/provider.d.ts +63 -3
- package/dist/provider.js +28 -0
- package/dist/providers.d.ts +7 -1
- package/dist/providers.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,6 +33,10 @@ full VM, a machine. The protocol has two layers:
|
|
|
33
33
|
inside. It never runs commands itself: the daemon does. This package has four: Docker, Modal's VM runtime, Daytona
|
|
34
34
|
and E2B (desktops), each one line of the provider registry (see [Adding a computer](#adding-a-computer)).
|
|
35
35
|
|
|
36
|
+
The protocol is published as a spec, [`spec/computer/`](../../spec/computer/README.md), at protocol version 0.1
|
|
37
|
+
(`PROTOCOL_VERSION`, which `hello` carries as `protocol`). Its JSON Schema and constants are generated from
|
|
38
|
+
`src/protocol.ts` by `node scripts/generate-computer-spec.mjs`, and a test fails when they drift.
|
|
39
|
+
|
|
36
40
|
## What it does today
|
|
37
41
|
|
|
38
42
|
The daemon answers `hello`, `ping`, `exec.run`, the `files.*` methods, `tar.*`, the `process.*` methods and
|
|
@@ -43,7 +47,7 @@ extension](#the-protocol-extension-kind-daemon-modes-screen-input-apps-lifetime)
|
|
|
43
47
|
|
|
44
48
|
```text
|
|
45
49
|
→ {"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"]}}
|
|
50
|
+
← {"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
51
|
→ {"jsonrpc":"2.0","id":2,"method":"exec.run","params":{"argv":["uname","-m"],"timeoutMs":5000}}
|
|
48
52
|
← {"jsonrpc":"2.0","id":2,"result":{"exitCode":0,"stdout":"YWFyY2g2NAo=","stderr":"","timedOut":false,"truncated":false}}
|
|
49
53
|
```
|
|
@@ -94,7 +98,10 @@ extension](#the-protocol-extension-kind-daemon-modes-screen-input-apps-lifetime)
|
|
|
94
98
|
refuses uid 0 for its programs (root shares its uid with every root process of the vendor's); refuses to start while
|
|
95
99
|
any other process holds that uid (one could be signalled, traced or written to by them, and a vendor's agent among
|
|
96
100
|
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
|
|
101
|
+
brings its loopback up over rtnetlink (RTM_NEWLINK with IFF_UP on lo's index, as `ip link set lo up` does; and
|
|
102
|
+
RTM_NEWADDR for 127.0.0.1/8 where the kernel gave lo none), never by the SIOCSIFFLAGS ioctl, which gVisor's netstack
|
|
103
|
+
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
|
|
104
|
+
and a listener there reached, and that no thread stayed behind and that the loopback alone is up or addressed
|
|
98
105
|
(a kernel with the tunnel modules loaded gives every new namespace its fallback tunnels, tunl0, gre0, sit0 and the
|
|
99
106
|
rest, down with no address: they stay so, since no program holds CAP_NET_ADMIN, and computerd's probe reports any
|
|
100
107
|
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 +115,24 @@ extension](#the-protocol-extension-kind-daemon-modes-screen-input-apps-lifetime)
|
|
|
108
115
|
`--egress`: such a computer's network is `none` (open and allowlists wait for a proxy out of that namespace, which
|
|
109
116
|
is not built yet). The code is `daemon/internal/isolate`; `test/docker/loopback-block.docker.test.mjs` runs each
|
|
110
117
|
provider's start in a root container beside a stand-in agent on 2280 and 49983.
|
|
118
|
+
- **Where root may not make the network namespace, init makes it inside a user namespace.** Root holds no
|
|
119
|
+
CAP_SYS_ADMIN on gVisor (Modal's GPU runtime), so `unshare(CLONE_NEWNET)` is EPERM. It may make a user namespace with
|
|
120
|
+
a network namespace inside it (a live probe on Modal's gVisor, 11-11). Init doesn't ask the vendor which it is: it
|
|
121
|
+
tries the plain namespace first, and on EPERM alone (`isolate.ErrNoNetworkNamespace`) it takes this way, whatever the
|
|
122
|
+
vendor.
|
|
123
|
+
- Init starts itself again as `computerd userns-init --started-in <its network namespace>`: a child in a new user
|
|
124
|
+
namespace that maps every uid and gid to itself, and a new network namespace. The root parent writes the map, which
|
|
125
|
+
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
|
|
126
|
+
folder belong to the same uid inside and out.
|
|
127
|
+
- The child does all of the above but make the namespace. Before touching anything, it reads back
|
|
128
|
+
(`isolate.KeepOwnNetwork`) that no thread is in the namespace it was started from. Then it brings the loopback up
|
|
129
|
+
over rtnetlink and reads it back, as above. The live T4 run at the fallback's first head (11-11) made the user and
|
|
130
|
+
network namespace, then failed at lo on the ioctl.
|
|
131
|
+
- The first init keeps no capability (no_new_privs, every set empty). It passes SIGTERM and SIGINT on, reaps, and exits
|
|
132
|
+
with the child's code.
|
|
133
|
+
- If neither way works, init refuses to start in words that name both, and the computer fails closed.
|
|
134
|
+
- hello says which fence holds, `fence: "netns"` or `"userns-netns"`. Every provider that starts init with
|
|
135
|
+
`--own-network` (Daytona, E2B, Orgo, Modal) refuses a hello that names neither.
|
|
111
136
|
- **Init drops its privileges itself, as any user, root included,** before it listens, so the line holds on every
|
|
112
137
|
vendor and not only where the provider drops capabilities (Docker: `--cap-drop ALL`). On every thread it sets
|
|
113
138
|
`no_new_privs`; drops from the bounding set each capability up to the kernel's last
|
|
@@ -237,7 +262,7 @@ Its whole tree ends when the program ends or is signalled to its end. Ids are `p
|
|
|
237
262
|
| `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
263
|
| `process.resize` | `id, cols, rows` | `{}`: the terminal's new size; the program gets SIGWINCH |
|
|
239
264
|
| `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 |
|
|
265
|
+
| `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
266
|
|
|
242
267
|
- Each stream keeps its last 8 MiB in a ring. Offsets count bytes since the process started; `nextOffset` is where the
|
|
243
268
|
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 +419,7 @@ in the kernel's tool registry, keyed by these groups.
|
|
|
394
419
|
| e2b | sandbox: `E2B_BASE_TEMPLATE` ("base"); desktop: `E2B_DESKTOP_TEMPLATE` ("desktop") |
|
|
395
420
|
| orgo | desktop: `ORGO_BASE_IMAGE` ("linux") |
|
|
396
421
|
| phone-harness | phone: `PHONE_IMAGE` ("android") |
|
|
397
|
-
| browserbase, kernel | browser: `BROWSER_IMAGE` ("chromium") |
|
|
422
|
+
| browserbase, kernel, local | browser: `BROWSER_IMAGE` ("chromium") |
|
|
398
423
|
|
|
399
424
|
| id | label | kinds | keys (required unless marked) | mounts | metered |
|
|
400
425
|
| --- | --- | --- | --- | --- | --- |
|
|
@@ -406,6 +431,7 @@ in the kernel's tool registry, keyed by these groups.
|
|
|
406
431
|
| phone-harness | Phone harness | phone | `PHONE_HARNESS_API_KEY` | none | yes |
|
|
407
432
|
| browserbase | Browserbase | browser | `BROWSERBASE_API_KEY`, `BROWSERBASE_PROJECT_ID` | none | yes |
|
|
408
433
|
| kernel | Kernel | browser | `KERNEL_API_KEY` | none | yes |
|
|
434
|
+
| local | Local Chrome | browser | none | none | no |
|
|
409
435
|
|
|
410
436
|
- Each provider module exports `CAPABILITIES` beside `MOUNT` (the registry's contract, `ProviderModule`). A unit test
|
|
411
437
|
holds every registry provider's `CAPABILITIES` and `MOUNT` to its entry, and each provider built from the test fakes,
|
|
@@ -1139,7 +1165,7 @@ const modal = new ModalProvider({
|
|
|
1139
1165
|
const made = await modal.create({ image: "debian:bookworm-slim", lifetimeMs: 600_000, network: "none" });
|
|
1140
1166
|
```
|
|
1141
1167
|
|
|
1142
|
-
`ModalProvider` makes Modal sandboxes on the VM runtime
|
|
1168
|
+
`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
1169
|
(apps, images, sandboxes and five methods of a sandbox). It has not yet run against real Modal: every test uses a fake
|
|
1144
1170
|
of that slice, and the live conformance file waits for a key (below).
|
|
1145
1171
|
|
|
@@ -1151,7 +1177,9 @@ of that slice, and the live conformance file waits for a key (below).
|
|
|
1151
1177
|
- **The loopback block.** Init starts with `--own-network` (see [Init, the socket and the
|
|
1152
1178
|
bridge](#init-the-socket-and-the-bridge)) whatever Modal runs inside the sandbox: the daemon's programs reach their
|
|
1153
1179
|
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
|
|
1180
|
+
init refuses one another process holds). On the VM runtime Modal's root holds every capability, so the namespace is
|
|
1181
|
+
made there. On gVisor, a GPU computer's runtime, root may not make it, so init makes it inside a user namespace
|
|
1182
|
+
(below). Known
|
|
1155
1183
|
gap: network `open` is refused in words until a proxy carries it out of the daemon's own network, the next feature
|
|
1156
1184
|
after this one; a computer that needs pip, npm or git from the internet cannot be made on Modal until then.
|
|
1157
1185
|
- **The daemon is uploaded at create.** The sandbox's command is a small POSIX sh entrypoint (BusyBox and coreutils
|
|
@@ -1255,8 +1283,47 @@ of that slice, and the live conformance file waits for a key (below).
|
|
|
1255
1283
|
sandbox terminated if one lands later. A create that refuses its sandbox (drift, an abort, a failed upload)
|
|
1256
1284
|
terminates it and waits as release does, within `releaseMs`, so nothing is left listed when it returns. The terminate
|
|
1257
1285
|
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
|
-
|
|
1286
|
+
bound or cut short by an abort says the sandbox may still be ending and what `poll()` last read. Before that
|
|
1287
|
+
terminate, a create whose sandbox's own command had ended says so: its exit code and the tail of its output. When
|
|
1288
|
+
Modal refuses an exec with FAILED_PRECONDITION ("Modal Sandbox is shutting down", code `gone`), the command, init, has
|
|
1289
|
+
just exited and Modal ends the sandbox asynchronously, so create first waits up to `endedMs` (30 s) for `poll()` to
|
|
1290
|
+
read it finished, then reads init's words. The first GPU live run on gVisor ended this way, with no words.
|
|
1291
|
+
- **GPU.** `capabilities().gpu` declares Modal's GPU types by its own names (guide/gpu): `T4`, `L4`, `A10`, `L40S`,
|
|
1292
|
+
`A100` (40 GB), `A100-40GB`, `A100-80GB`, `RTX-PRO-6000`, `H100`, `H200`, `B200`, `B300`, at most 8 to a computer
|
|
1293
|
+
(Modal refuses an `A10` past 4, in its words). Its `H100!` and `B200+` variants are not offered: a computer gets the
|
|
1294
|
+
type it asked for. `spec.gpu: { type, count }` becomes the SDK's `gpu` (`"T4"`, `"A100-80GB:2"`), and since Modal
|
|
1295
|
+
offers GPUs on gVisor only, such a sandbox runs with `runtime: "gvisor"`; every other computer stays on the VM
|
|
1296
|
+
runtime. The drift check holds the runtime from both sides: the probe's kernel must be gVisor's on a GPU computer, and a
|
|
1297
|
+
VM's on any other. Modal reads no GPU back: the
|
|
1298
|
+
spec tag records the GPUs, and attach reports them on a computer the probe reads as gVisor. `capabilities().isolation`
|
|
1299
|
+
stays `vm`, every other computer's; a GPU computer's is declared apart, `gpu.isolation: "gvisor"`, so a caller that
|
|
1300
|
+
needs a VM's isolation can tell. Modal's GPUs are `preemptible: true`: Modal may move a GPU workload, so a run on one
|
|
1301
|
+
can be cut short (guide/preemption). `gpu.mounts` is `[]`: a GPU with an Archil mount is refused (checkGpu), since the
|
|
1302
|
+
Archil client's FUSE mount is not proven on gVisor yet. That keeps serve from giving a run a Modal GPU sandbox in either
|
|
1303
|
+
mode, as a serve sandbox always mounts the run's folder; the library takes one without a mount.
|
|
1304
|
+
- **The loopback fence on gVisor.** A GPU computer's init gets the same network namespace of its own, loopback alone,
|
|
1305
|
+
made another way.
|
|
1306
|
+
- Modal's gVisor gives root no CAP_SYS_ADMIN, so `unshare(CLONE_NEWNET)` is EPERM. With `--own-network`, init refused
|
|
1307
|
+
to start there (live on a T4, 11-10).
|
|
1308
|
+
- It does let root make a user namespace with a network namespace inside it (`unshare -Urn`, live on a T4, 11-11, as
|
|
1309
|
+
root and as nobody; nothing of Modal's runs or listens inside a gVisor sandbox, and every loopback port answered
|
|
1310
|
+
nothing).
|
|
1311
|
+
- So init, given the same `--own-network` on every runtime, makes the namespace inside a user namespace when root's
|
|
1312
|
+
own attempt is EPERM (the daemon's fallback, any vendor: see "Where root may not make the network namespace").
|
|
1313
|
+
- The first init stays PID 1 with no capability and no_new_privs set. It passes SIGTERM and SIGINT on and ends with
|
|
1314
|
+
the init that serves, so the sandbox lives as long as that one does.
|
|
1315
|
+
- Declared: `gpu.fence: "userns-netns"`. Read back: hello's `fence` on every connect, which the drift check requires
|
|
1316
|
+
to be one of the two. Create notes it when it is `userns-netns`, and the conformance report records it under the GPU
|
|
1317
|
+
computer's own name and role (`daemons[].fence`).
|
|
1318
|
+
- Proven in Docker. In `test/docker/modal-commands.docker.test.mjs`, a root container with Docker's default
|
|
1319
|
+
capabilities and no seccomp profile stands in for gVisor:
|
|
1320
|
+
- `--own-network` falls back and serves;
|
|
1321
|
+
- hello says `userns-netns`;
|
|
1322
|
+
- the programs run as 1000 with no capability, in another network and user namespace than PID 1's, on the loopback
|
|
1323
|
+
alone;
|
|
1324
|
+
- what they write in HOME is 1000's from outside;
|
|
1325
|
+
- with Docker's default seccomp profile (no user namespace either), init refuses in words that name both ways.
|
|
1326
|
+
- Not yet proven live on Modal.
|
|
1260
1327
|
|
|
1261
1328
|
### What every Modal fact rests on
|
|
1262
1329
|
|
|
@@ -1502,6 +1569,7 @@ the TTL.
|
|
|
1502
1569
|
| `user` | none | the daemon runs as the provider's `daemonUser`; a spec cannot name a user |
|
|
1503
1570
|
| `release` | `stop`, `delete` | `POST /sandbox/{id}/stop` and `DELETE /sandbox/{id}` |
|
|
1504
1571
|
| `stopDeletes` | `true` with `autoDeleteMinutes: 0`, else `false` | `autoDeleteInterval` 0 deletes a sandbox as soon as it stops |
|
|
1572
|
+
| `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
1573
|
|
|
1506
1574
|
### What the provider does
|
|
1507
1575
|
|
|
@@ -1566,7 +1634,8 @@ From Daytona's read of the sandbox:
|
|
|
1566
1634
|
| `autoStopInterval`, `autoDeleteInterval` | `autoStopMinutes` (0 unset), `autoDeleteMinutes` (-1 unset), exactly |
|
|
1567
1635
|
| `autoDestroyAt` | set, and no later than the deadline plus the TTL's minute and 2 minutes of clock skew |
|
|
1568
1636
|
| `sandboxClass` | the provider's class |
|
|
1569
|
-
| `
|
|
1637
|
+
| `gpu`, `gpuType` | `spec.gpu`'s count (0 with none) and, with one, its type |
|
|
1638
|
+
| `public`, `kvm`, `volumes`, `linkedSandboxId` | false, not true, none, none |
|
|
1570
1639
|
|
|
1571
1640
|
From the daemon, over one connection: hello (the provider's version, `linux`, the `arch` option, every daemon
|
|
1572
1641
|
capability), `/proc/self/status` (Uid and Gid the daemon user's four times, no groups, `NoNewPrivs: 1`, `CapInh`,
|
|
@@ -2006,6 +2075,82 @@ AGENTRUN_COMPUTER_LIVE_KERNEL=1 COMPUTER_KERNEL_API_KEY=... \
|
|
|
2006
2075
|
npm run conformance -w @parcha/agentrun-computer -- --provider kernel
|
|
2007
2076
|
```
|
|
2008
2077
|
|
|
2078
|
+
## A local browser: this machine's Chrome, no keys
|
|
2079
|
+
|
|
2080
|
+
The `local` provider (`local.ts`) is a computer of kind `browser` that is the Chrome or Chromium on the machine
|
|
2081
|
+
AgentRun runs on. No vendor, no key, nothing billed.
|
|
2082
|
+
|
|
2083
|
+
```ts
|
|
2084
|
+
import { LocalBrowserProvider } from "@parcha/agentrun-computer";
|
|
2085
|
+
|
|
2086
|
+
const local = new LocalBrowserProvider({ env: { PATH: process.env.PATH } }); // or { executablePath: "/usr/bin/chromium" }
|
|
2087
|
+
const made = await local.create({ image: "chromium", lifetimeMs: 30 * 60_000, network: "open" });
|
|
2088
|
+
const connected = await local.connect(made.value); // connected.value.cdp.url: ws://127.0.0.1:<port>/devtools/browser/<id>
|
|
2089
|
+
await local.release(made.value, "delete");
|
|
2090
|
+
```
|
|
2091
|
+
|
|
2092
|
+
Each computer is one Chrome with a throwaway profile and a debugging port Chrome picks on 127.0.0.1. It runs
|
|
2093
|
+
headless by default. `headed: true` shows the window, for a person watching on this machine. `create()` returns
|
|
2094
|
+
once `/json/version` answers on that port. `connect()` hands over the DevTools URL. `release("delete")` ends Chrome and
|
|
2095
|
+
removes its profile and every other file of it. `list()` and attach by labels find the provider's own browsers by
|
|
2096
|
+
`browser.json` in each browser's directory under the root (default `<tmpdir>/agentrun-local-browser-<uid>`, made 0700,
|
|
2097
|
+
refused when another user can write it). That file holds the labels and the deadline.
|
|
2098
|
+
|
|
2099
|
+
Lifetime: each browser runs under a supervisor of its own (`local-supervisor.ts`), a small detached Node process. It
|
|
2100
|
+
ends Chrome and removes its files at the deadline, on release, or when Chrome exits, whatever became of the process
|
|
2101
|
+
that made the browser. So a run that crashes leaves no Chrome behind once its deadline passes. `list()` reads the
|
|
2102
|
+
deadline, so the janitor's `sweep` also ends a browser whose supervisor was killed (`lifetime: "janitor"`). The cap is
|
|
2103
|
+
24 h.
|
|
2104
|
+
|
|
2105
|
+
Finding Chrome: the `executablePath` option, else `PI_BROWSER_CHROME` or `CHROME_PATH` in the `env` option, else the
|
|
2106
|
+
first `google-chrome`, `google-chrome-stable`, `chromium` or `chromium-browser` on that env's `PATH`, else the usual
|
|
2107
|
+
install places. The library reads no environment of its own: the host passes `env`. With none found, `check()`,
|
|
2108
|
+
`create()` and `testConnection()` say what to install and which setting names one. `testConnection()` starts the Chrome
|
|
2109
|
+
once, headless on a blank page with a proxy that reaches nothing, to prove it starts here with its sandbox on. It
|
|
2110
|
+
keeps nothing.
|
|
2111
|
+
|
|
2112
|
+
The fence and the sandbox are PR #1718's:
|
|
2113
|
+
|
|
2114
|
+
- Chrome's own sandbox is always on. A start as root is refused (Chrome refuses root with its sandbox on), and so is a
|
|
2115
|
+
Chrome that cannot start its sandbox here, in words that name the fix (an AppArmor profile on Ubuntu 23.10 and later,
|
|
2116
|
+
or Chrome's setuid helper). Nothing retries without the sandbox.
|
|
2117
|
+
- Every request Chrome makes goes through the browser's egress proxy, the same one Docker's computers use
|
|
2118
|
+
(`docker/egress-proxy.ts`). A spec's `network` is `"open"` (no list) or `{ allow: [names and CIDRs] }`. With a list,
|
|
2119
|
+
the proxy reaches only those hosts, on ports 80 and 443, and refuses any other host by name before its lookup. A
|
|
2120
|
+
CIDR that covers a refused range (loopback, private) is refused at `check()`. The proxy reaches public addresses only, each checked after its lookup:
|
|
2121
|
+
this machine's loopback, private networks, link-local and a cloud's metadata address (169.254.169.254) are
|
|
2122
|
+
refused. Chrome is started with `--proxy-bypass-list=<-loopback>`, so loopback goes through the proxy too. Its
|
|
2123
|
+
`--host-resolver-rules=MAP <proxy> <proxy>, MAP * ~NOTFOUND` means Chrome resolves no name itself, so a request
|
|
2124
|
+
sent around the proxy reaches nothing. QUIC is off (`--disable-quic`), and WebRTC sends no UDP
|
|
2125
|
+
(`--webrtc-ip-handling-policy=disable_non_proxied_udp`). The proxy and its relay live in the supervisor, so the fence
|
|
2126
|
+
holds for a browser driven from another process, and a browser whose supervisor is gone reaches nothing.
|
|
2127
|
+
|
|
2128
|
+
Capabilities: `network: ["open"]` (public addresses), `isolation: "host"`, `daemon: "none"`, groups `cdp` only (no
|
|
2129
|
+
live view: run it headed to watch), `release: ["delete"]`, no mount.
|
|
2130
|
+
|
|
2131
|
+
Known limits, so it is for local and development use:
|
|
2132
|
+
|
|
2133
|
+
- The debugging port has no auth. Any process on this machine that finds the port can drive the browser, read its
|
|
2134
|
+
pages and cookies, and navigate it. The port is on 127.0.0.1 only, and it is random per browser.
|
|
2135
|
+
- Chrome runs as the user AgentRun runs as, on this host. Chrome's sandbox is the only isolation between a page and
|
|
2136
|
+
the machine. The fence keeps the browser off this machine's services and private networks, but the browser
|
|
2137
|
+
process itself is not in a container or a VM.
|
|
2138
|
+
- The page cannot reach this machine's services, but the supervisor's relay port on 127.0.0.1 is reachable by local
|
|
2139
|
+
processes. Through it they reach public addresses, which they can reach anyway.
|
|
2140
|
+
- No proxy of your own, no extensions, no saved profiles: each browser starts from an empty profile that goes with it.
|
|
2141
|
+
|
|
2142
|
+
Driving it: pi-browser's raw-CDP driver (`@parcha/pi-browser/driver/cdp`) drives this browser with the same
|
|
2143
|
+
`snapshot` and `run` actions the vendor browsers take, with no Stagehand and nothing loaded into Chrome. `run` code is
|
|
2144
|
+
refused there; navigation is a `goto` action. Its snapshot does not read a frame another site runs in its own
|
|
2145
|
+
process (a cross-origin iframe). The snapshot names each frame it left out, so an agent knows the page has more.
|
|
2146
|
+
|
|
2147
|
+
The conformance module starts a real Chrome, so it waits for its switch:
|
|
2148
|
+
|
|
2149
|
+
```sh
|
|
2150
|
+
AGENTRUN_COMPUTER_LIVE_LOCAL=1 [COMPUTER_LOCAL_CHROME=/usr/bin/chromium] \
|
|
2151
|
+
npm run conformance -w @parcha/agentrun-computer -- --provider local --kind browser
|
|
2152
|
+
```
|
|
2153
|
+
|
|
2009
2154
|
## Phone harness (the phone kind)
|
|
2010
2155
|
|
|
2011
2156
|
```ts
|
|
@@ -2126,7 +2271,7 @@ through `apps.ui_tree` (`src/conformance/cases/settings.ts`):
|
|
|
2126
2271
|
|
|
2127
2272
|
A provider for another vendor passes the same suite as Docker's, with one command. The suite is data: each case in
|
|
2128
2273
|
`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`,
|
|
2274
|
+
`isolation`, `mount`, `screen`, `input`, `touch`, `apps`, `lifetime`, `browser`, `gpu`) and the capabilities it needs, and uses only `ComputerProvider`,
|
|
2130
2275
|
`ComputerClient` and the suite's assertion helpers, so the same cases run against a provider with daemon `none`.
|
|
2131
2276
|
|
|
2132
2277
|
```sh
|
|
@@ -2151,11 +2296,16 @@ core PASS 54/54 · 10 optional cases skipped, not declared · full 10/13 · moun
|
|
|
2151
2296
|
An id is resolved through the provider registry, and only there; the usage lists every id it holds. A module path is
|
|
2152
2297
|
resolved from the directory npm was run in. It exits 0 when Core passes, 1 when it fails, 2 on a
|
|
2153
2298
|
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
|
-
|
|
2299
|
+
daemonMode, image, daemons: [{ computer, role, version, os, arch, fence? }], only?, coreNotRun?, results: [{ id, level,
|
|
2300
|
+
group, status, reason?, undeclared? }], core, undeclared, cleanup, notes?, computerNotes? }`). A failure is listed under
|
|
2301
|
+
its line with what the case found. A computer's `role` is `"shared"` for the run's computer, which the cases that need
|
|
2302
|
+
none of their own share, else the id of the case that made it. `daemons` holds each computer's first `hello`, one entry
|
|
2303
|
+
per computer in the order they answered (empty when none did), so computers of one run that differ are kept apart: a GPU
|
|
2304
|
+
computer's `fence` is not the run's computer's. The text report prints each as `daemon <computer> (<role>): computerd
|
|
2305
|
+
<version> <os>/<arch> · fence <fence>` above the verdict. `computerNotes` (`[{ computer, role, note }]`, absent when
|
|
2306
|
+
empty) holds every note a `create` returned beside its ref, such as a probe target that accepted and sent nothing back,
|
|
2307
|
+
naming the computer and its role, in the order they came; the text report prints each as `note <computer> (<role>):
|
|
2308
|
+
<words>` above the verdict, so a run that passes Core never hides one. Notes an
|
|
2159
2309
|
`attach` returns are not carried: cases call `attach` on the provider directly, so the runner never sees them.
|
|
2160
2310
|
|
|
2161
2311
|
`--only` that leaves any Core case out is a partial run: `core` is `"partial"` when every case that ran passed (a
|
|
@@ -2362,6 +2512,10 @@ AGENTRUN_COMPUTER_LIVE_MODAL=1 npm run test:modal -w @parcha/agentrun-computer
|
|
|
2362
2512
|
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
2513
|
```
|
|
2364
2514
|
|
|
2515
|
+
`npm test` also runs `test/local-chrome-live.test.mjs` on a real Chrome where one is on PATH (or `CHROME_PATH` names
|
|
2516
|
+
one) and starts here with its sandbox on: it creates a local browser, drives it over CDP, checks that a service on this
|
|
2517
|
+
machine's loopback is out of its reach, and releases it. Elsewhere it skips with the reason.
|
|
2518
|
+
|
|
2365
2519
|
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
2520
|
server; elsewhere those tests skip in words and the fake X server's tests still run.
|
|
2367
2521
|
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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
3
|
import { type ComputerErrorCode, type Result } from "./result.js";
|
|
4
4
|
/** The one image a browser computer runs: the vendor's own Chromium. */
|
package/dist/browser.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
// URL, which a driver dials. That URL and the live view's are secrets: they live in memory (a UrlStore), and never reach
|
|
4
4
|
// a ref, a list, an error's words or a report.
|
|
5
5
|
import { randomBytes } from "node:crypto";
|
|
6
|
-
import {
|
|
6
|
+
import { PROTOCOL_VERSION } from "./protocol.js";
|
|
7
|
+
import { checkGpu, checkLifetime } from "./provider.js";
|
|
7
8
|
import { fail, ok } from "./result.js";
|
|
8
9
|
/** The one image a browser computer runs: the vendor's own Chromium. */
|
|
9
10
|
export const BROWSER_IMAGE = "chromium";
|
|
@@ -106,7 +107,7 @@ export async function recoverCreate(what, find, release, sleep) {
|
|
|
106
107
|
}
|
|
107
108
|
return words.join("; ");
|
|
108
109
|
}
|
|
109
|
-
const SPEC_FIELDS = new Set(["image", "lifetimeMs", "network", "labels"]);
|
|
110
|
+
const SPEC_FIELDS = new Set(["image", "lifetimeMs", "network", "labels", "gpu"]);
|
|
110
111
|
/**
|
|
111
112
|
* The checks every browser provider makes before a vendor call: the image is chromium, the lifetime is within the
|
|
112
113
|
* vendor's cap (and at least min), the network is open, the labels are ones the vendor's metadata holds, and no field a
|
|
@@ -132,6 +133,8 @@ export function checkBrowser(spec, capabilities, vendor, minLifetimeMs = 1) {
|
|
|
132
133
|
else if (Object.hasOwn(labels, CREATE_LABEL))
|
|
133
134
|
refusals.push({ field: "labels", message: `the label ${CREATE_LABEL} is the provider's own: each create writes it, so a lost create finds its browser` });
|
|
134
135
|
}
|
|
136
|
+
// A browser declares no gpu: one asked is refused, in the words every provider shares.
|
|
137
|
+
refusals.push(...checkGpu(given.gpu, capabilities));
|
|
135
138
|
for (const [field, value] of Object.entries(given)) {
|
|
136
139
|
if (!SPEC_FIELDS.has(field) && value !== undefined)
|
|
137
140
|
refusals.push({ field, message: `a ${vendor} browser does not take ${field}` });
|
|
@@ -139,7 +142,7 @@ export function checkBrowser(spec, capabilities, vendor, minLifetimeMs = 1) {
|
|
|
139
142
|
return refusals;
|
|
140
143
|
}
|
|
141
144
|
/** hello for a browser: the provider's version, linux, kind browser and its groups. The vendor reports no arch. */
|
|
142
|
-
export const browserHello = (version, groups) => ({ version, os: "linux", kind: "browser", arch: "unknown", groups: [...groups] });
|
|
145
|
+
export const browserHello = (version, groups) => ({ protocol: PROTOCOL_VERSION, version, os: "linux", kind: "browser", arch: "unknown", groups: [...groups] });
|
|
143
146
|
/**
|
|
144
147
|
* The client of a browser's connection: it answers hello, and ping from the vendor's own read of the session (gone
|
|
145
148
|
* once it has ended); any other method is unsupported, in words, since a browser is driven over CDP.
|
package/dist/browserbase.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type BrowserStream, type ReleaseConfirm, type UrlStore } from "./browser.js";
|
|
2
2
|
import type { KindCapabilities } from "./kinds.js";
|
|
3
3
|
import type { MountKind } from "./mount.js";
|
|
4
|
-
import type { AttachedComputer, CallContext, ComputerCapabilities, ComputerConnection, ComputerInfo, ComputerProvider, ComputerRef, ComputerSpec, CreatedComputer, NetworkPolicy, NetworkSpec, Refusal } from "./provider.js";
|
|
4
|
+
import type { AttachedComputer, CallContext, ComputerCapabilities, ComputerConnection, ComputerInfo, ComputerProvider, ComputerRef, ComputerSpec, CreatedComputer, NetworkForm, NetworkPolicy, NetworkSpec, Refusal } from "./provider.js";
|
|
5
5
|
import { type Result } from "./result.js";
|
|
6
6
|
export declare const BROWSERBASE_API_URL = "https://api.browserbase.com";
|
|
7
7
|
/** The domain a Browserbase CDP URL is on (wss://connect.browserbase.com, read live 11-08): cdpUrlProblem holds it there. */
|
|
@@ -18,6 +18,8 @@ export declare const labelKey: (metadataKey: string) => string;
|
|
|
18
18
|
export declare function browserbaseLabelsProblem(labels: unknown): string | undefined;
|
|
19
19
|
/** A browser takes no mount. */
|
|
20
20
|
export declare const MOUNT: readonly MountKind[];
|
|
21
|
+
/** The network a Browserbase browser runs on: Browserbase's own, open; it cannot be closed or narrowed. */
|
|
22
|
+
export declare const NETWORK: readonly NetworkForm[];
|
|
21
23
|
/** The one configuration it offers, the kind registry's entry (kinds.ts): a browser with a CDP target and a live view. */
|
|
22
24
|
export declare const CAPABILITIES: readonly KindCapabilities[];
|
|
23
25
|
/** A session as Browserbase answers it; only what the provider reads. */
|
package/dist/browserbase.js
CHANGED
|
@@ -57,6 +57,8 @@ export function browserbaseLabelsProblem(labels) {
|
|
|
57
57
|
}
|
|
58
58
|
/** A browser takes no mount. */
|
|
59
59
|
export const MOUNT = [];
|
|
60
|
+
/** The network a Browserbase browser runs on: Browserbase's own, open; it cannot be closed or narrowed. */
|
|
61
|
+
export const NETWORK = ["open"];
|
|
60
62
|
/** The one configuration it offers, the kind registry's entry (kinds.ts): a browser with a CDP target and a live view. */
|
|
61
63
|
export const CAPABILITIES = [{ kind: "browser", groups: ["cdp", "stream"] }];
|
|
62
64
|
/** Browserbase's v1 REST API over fetch: the default api. */
|
|
@@ -138,7 +140,7 @@ export class BrowserbaseProvider {
|
|
|
138
140
|
return {
|
|
139
141
|
kind: "browser",
|
|
140
142
|
lifetime: "vendor",
|
|
141
|
-
network: [
|
|
143
|
+
network: [...NETWORK],
|
|
142
144
|
isolation: "vm",
|
|
143
145
|
os: "linux",
|
|
144
146
|
daemon: "none",
|
package/dist/child.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { ComputerCapabilities, ComputerConnection } from "./provider.js";
|
|
2
2
|
import { type Result } from "./result.js";
|
|
3
|
+
/** Who ran install, from its output's `installer <uid> <name>[ sudo]` line, in words; undefined when it has none. */
|
|
4
|
+
export declare function installerOf(output: string): string | undefined;
|
|
3
5
|
/** One string for a shell: `sh -c '<script>' sh '<arg>' ...`, every word quoted. */
|
|
4
6
|
export declare const shellCommand: (script: string, args: readonly string[]) => string;
|
|
5
7
|
export interface ChildCommandOptions {
|
package/dist/child.js
CHANGED
|
@@ -15,7 +15,7 @@ const ROOT = 'p=; [ "$(id -u)" = 0 ] || p="sudo -n"';
|
|
|
15
15
|
* coreutils alike; a trailing `.` (an SELinux label) is allowed, a `+` (an ACL) is not. */
|
|
16
16
|
const HELD = 'held() { x=$1; while :; do set -- $(ls -ldn "$x" 2>/dev/null); case "$1" in ?????[!w]??[!w]?|?????[!w]??[!w]?.) ;; *) false ;; esac && [ "$3" = 0 ] || { echo "the daemon at $d is not root\'s alone: $x is ${1:-missing}, owner ${3:-none}"; return 1; }; [ "$x" = / ] && return 0; x=${x%/*}; x=${x:-/}; done; }';
|
|
17
17
|
/** Installs the uploaded daemon root-owned and read-only to its user, makes its home and socket directory (init gives
|
|
18
|
-
* them to the daemon's user), and prints the installed binary's sha256. As root, or through passwordless sudo; else
|
|
18
|
+
* them to the daemon's user), and prints who installed it and the installed binary's sha256. As root, or through passwordless sudo; else
|
|
19
19
|
* it says why. The daemon's directory is made root's (0755) even when the image already had it, a stale entry at
|
|
20
20
|
* the daemon's path is removed first, and the whole path is held to `held` before and after; a path another user can
|
|
21
21
|
* change is refused with nothing installed. Every tool is in BusyBox and in coreutils alike: no privilege tool of the
|
|
@@ -31,8 +31,18 @@ const INSTALL_SCRIPT = [
|
|
|
31
31
|
'$p mkdir -p "$b" "$h" "$r" && $p chown 0:0 "$b" && $p chmod 0755 "$b" && $p rm -f "$d" && $p install -m 0755 -o 0 -g 0 "$s" "$d" || { echo "installing the daemon at $d failed"; exit 5; }',
|
|
32
32
|
'held "$d" || exit 6',
|
|
33
33
|
'rm -f "$s"',
|
|
34
|
+
// Who installed it: the sandbox user's uid and name, and "sudo" when through passwordless sudo (installerOf).
|
|
35
|
+
'echo "installer $(id -u) $(id -un 2>/dev/null || echo unnamed)${p:+ sudo}"',
|
|
34
36
|
'echo "sha256 $($p sha256sum "$d" | cut -c1-64)"',
|
|
35
37
|
].join("\n");
|
|
38
|
+
/** Who ran install, from its output's `installer <uid> <name>[ sudo]` line, in words; undefined when it has none. */
|
|
39
|
+
export function installerOf(output) {
|
|
40
|
+
const found = /^installer (\d+) (\S+)( sudo)?$/m.exec(output);
|
|
41
|
+
if (found === null)
|
|
42
|
+
return undefined;
|
|
43
|
+
const [, uid, name, sudo] = found;
|
|
44
|
+
return `the daemon was installed by ${name} (uid ${uid})${sudo ? ", through passwordless sudo" : ", as root"}`;
|
|
45
|
+
}
|
|
36
46
|
/** Starts init, the long-lived command, as root in a clean environment from its home: `init --user` gives HOME and the
|
|
37
47
|
* socket's directory to the daemon's user, sets no_new_privs and empties every capability set on every thread, and
|
|
38
48
|
* becomes that user with no groups. `--own-network` first cuts init and its programs off from the vendor's agent beside
|
|
@@ -79,7 +89,8 @@ const show = (value) => (value === undefined ? "nothing" : JSON.stringify(value)
|
|
|
79
89
|
* working directory and binary. Each read is bounded by timeoutMs and the caller's signal.
|
|
80
90
|
*/
|
|
81
91
|
export async function daemonDrift(connection, expected, timeoutMs, signal) {
|
|
82
|
-
|
|
92
|
+
// childCommands starts init with --own-network: hello must say which fence holds its programs.
|
|
93
|
+
const found = helloDrift(connection.hello, { version: expected.version, kind: expected.kind, groups: expected.groups, arch: expected.arch, fence: true });
|
|
83
94
|
const bounded = () => (signal ? AbortSignal.any([signal, AbortSignal.timeout(timeoutMs)]) : AbortSignal.timeout(timeoutMs));
|
|
84
95
|
const status = await connection.client.call("files.read", { path: "/proc/self/status" }, { signal: bounded() });
|
|
85
96
|
if (!status.ok)
|
package/dist/chrome.d.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { type Result } from "./result.js";
|
|
2
|
+
/** The environment names a Chrome is found by: pi-browser's own, then the common one. */
|
|
3
|
+
export declare const CHROME_ENV: readonly ["PI_BROWSER_CHROME", "CHROME_PATH"];
|
|
4
|
+
/**
|
|
5
|
+
* The Chrome or Chromium on this machine: the one PI_BROWSER_CHROME or CHROME_PATH names in `env`, else the first on
|
|
6
|
+
* env.PATH, else the first of the usual install places; null when there is none. `env` is the caller's: the library
|
|
7
|
+
* reads none.
|
|
8
|
+
*/
|
|
9
|
+
export declare function findChrome(env?: Readonly<Record<string, string | undefined>>, exists?: (file: string) => boolean): string | null;
|
|
10
|
+
/** What to do when there is no Chrome, in words: what to install, and the settings that point at one. */
|
|
11
|
+
export declare const NO_CHROME = "no Chrome or Chromium was found on this machine: install Google Chrome or Chromium (on Debian or Ubuntu, `apt install chromium` or Google's google-chrome-stable package), or name the executable with the provider's executablePath option, or CHROME_PATH (or PI_BROWSER_CHROME) in the environment the host passes as its env option";
|
|
12
|
+
/**
|
|
13
|
+
* The switches every local Chrome starts with, beside the fence, its profile and its debugging port: no first-run
|
|
14
|
+
* screens, no sign-in or sync, no background traffic of Chrome's own (component updates, field trials, safe-browsing
|
|
15
|
+
* pings), no keychain prompt, no sound.
|
|
16
|
+
*/
|
|
17
|
+
export declare const CHROME_FLAGS: readonly string[];
|
|
18
|
+
/**
|
|
19
|
+
* The arguments that hold a local Chrome to its egress proxy at `proxy` (an http URL of a loopback port, the relay to
|
|
20
|
+
* the proxy, which decides): every request through the proxy, loopback too (`<-loopback>` takes away the bypass Chrome
|
|
21
|
+
* gives it by default), so this machine's own services, private networks, link-local and a cloud's metadata address are
|
|
22
|
+
* each refused by the proxy after its lookup; no name or address resolved by Chrome itself but the proxy's, so a request
|
|
23
|
+
* a page sends around the proxy reaches nothing; no QUIC, which goes around an HTTP proxy; and WebRTC on no UDP but the
|
|
24
|
+
* proxy's, which carries none, so no ICE candidate is gathered and no STUN packet leaves. That last is
|
|
25
|
+
* `--webrtc-ip-handling-policy`: Chrome 155 and 156 ignore the `--force-` spelling (#1718 measured a STUN server on
|
|
26
|
+
* loopback sent its binding requests under it). From #1718's chromeFence, less the bypass it kept for the DevTools guard
|
|
27
|
+
* Stagehand's extension dialled: nothing in this browser reaches its own DevTools socket.
|
|
28
|
+
*/
|
|
29
|
+
export declare function chromeFence(proxy: string): string[];
|
|
30
|
+
/** Signal 0 only asks; EPERM means the process exists under another user. */
|
|
31
|
+
export declare const alive: (pid: number) => boolean;
|
|
32
|
+
/** Whether `pid` leads its own process group (a detached child does); null where there is no /proc to ask. */
|
|
33
|
+
export declare function leadsOwnGroup(pid: number): boolean | null;
|
|
34
|
+
/**
|
|
35
|
+
* Kills `pid` and its group. A pid reaches here from a file a restart reads back: `kill(-1)` signals every process the
|
|
36
|
+
* user can, `kill(0)` this process's own group, so neither a pid below 2 nor our own is ever signalled, and a negative
|
|
37
|
+
* pid (a whole group) only for a process that leads one.
|
|
38
|
+
*/
|
|
39
|
+
export declare function killTree(pid: number, io?: {
|
|
40
|
+
kill?: (pid: number, signal: NodeJS.Signals) => void;
|
|
41
|
+
leadsGroup?: (pid: number) => boolean | null;
|
|
42
|
+
}, signal?: NodeJS.Signals): void;
|
|
43
|
+
/**
|
|
44
|
+
* Whether `pid` is a process whose command line holds `marker` (a Chrome's `--user-data-dir=<profile>`, a supervisor's
|
|
45
|
+
* directory), so a pid read back from a file never names a recycled process. Where there is no /proc to ask (macOS),
|
|
46
|
+
* whether it is alive.
|
|
47
|
+
*/
|
|
48
|
+
export declare function runsWith(pid: number, marker: string): boolean;
|
|
49
|
+
/** The port and browser path a Chrome on `profile` wrote to its DevToolsActivePort: only that Chrome writes it there. */
|
|
50
|
+
export declare function ownDebugger(profile: string): Promise<{
|
|
51
|
+
port: number;
|
|
52
|
+
path: string;
|
|
53
|
+
} | null>;
|
|
54
|
+
/** The browser path the DevTools socket on `port` answers /json/version with, or null; bounded, so a socket that takes the connection and never answers holds no one. */
|
|
55
|
+
export declare function answeringPath(port: number, timeoutMs?: number): Promise<string | null>;
|
|
56
|
+
/** Chrome's singleton socket directory under the temp directory outlives every Chrome exit; the profile's link names it. */
|
|
57
|
+
export declare function singletonDir(profile: string): Promise<string | null>;
|
|
58
|
+
/** What a start whose Chrome could not start its sandbox is told: never to turn it off, which nothing here can. */
|
|
59
|
+
export declare const NO_SANDBOX = "this machine's Chrome could not start its sandbox, and the local browser never runs Chrome without it, so no browser was started: on Ubuntu 23.10 and later give this Chrome an AppArmor profile that allows it user namespaces, or use a Chrome whose setuid sandbox helper is installed (Google's package installs one)";
|
|
60
|
+
/** What a start as root is told: Chrome refuses root with its sandbox on, and the sandbox is never turned off here. */
|
|
61
|
+
export declare const AS_ROOT = "the local browser does not start Chrome as root: Chrome refuses root with its sandbox on, and the sandbox is never turned off here. Run AgentRun as a user that is not root";
|
|
62
|
+
/** How long the sandbox check may take: one headless Chrome that loads a blank page and exits. */
|
|
63
|
+
export declare const CHECK_MS = 30000;
|
|
64
|
+
/**
|
|
65
|
+
* Whether the Chrome at `path` starts here with its sandbox on: an executable file, a user that is not root, and one
|
|
66
|
+
* headless start on a blank page (`--dump-dom about:blank`) in a profile of its own that goes with it, with a proxy no
|
|
67
|
+
* name or address reaches, so nothing leaves the machine. ok with the resolved path; refused in words that never offer
|
|
68
|
+
* to turn the sandbox off. From #1718's checkChrome. `uid`: the user this process runs as (a test's seam).
|
|
69
|
+
*/
|
|
70
|
+
export declare function checkChrome(path: string, { uid, timeoutMs }?: {
|
|
71
|
+
uid?: number;
|
|
72
|
+
timeoutMs?: number;
|
|
73
|
+
}): Promise<Result<string>>;
|