@parcha/agentrun-computer 0.1.0-beta.35 → 0.1.0-beta.36
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 +108 -21
- package/box/Dockerfile +3 -1
- package/box/agentrun-archil +59 -7
- package/box/build-daytona.py +20 -4
- package/dist/browser.d.ts +61 -10
- package/dist/browser.js +125 -3
- package/dist/browserbase.d.ts +45 -20
- package/dist/browserbase.js +161 -17
- package/dist/chrome.d.ts +3 -4
- package/dist/chrome.js +6 -11
- package/dist/computerd-linux-amd64 +0 -0
- package/dist/computerd-linux-arm64 +0 -0
- package/dist/conformance/daytona.d.ts +4 -0
- package/dist/conformance/daytona.js +5 -0
- package/dist/daytona.d.ts +13 -1
- package/dist/daytona.js +55 -36
- package/dist/descriptor.d.ts +24 -2
- package/dist/descriptor.js +11 -0
- package/dist/descriptors/browserbase.d.ts +1 -0
- package/dist/descriptors/browserbase.js +2 -0
- package/dist/descriptors/daytona.d.ts +23 -2
- package/dist/descriptors/daytona.js +34 -2
- package/dist/descriptors/index.d.ts +28 -1
- package/dist/descriptors/index.js +1 -1
- package/dist/descriptors/kernel.d.ts +1 -0
- package/dist/descriptors/kernel.js +2 -0
- package/dist/descriptors/modal.d.ts +4 -0
- package/dist/descriptors/modal.js +11 -1
- package/dist/descriptors/orgo.d.ts +11 -0
- package/dist/descriptors/orgo.js +6 -1
- package/dist/descriptors/phone-harness.d.ts +5 -0
- package/dist/descriptors/phone-harness.js +3 -0
- package/dist/docker/egress.d.ts +4 -3
- package/dist/docker/egress.js +7 -6
- package/dist/docker.js +7 -5
- package/dist/e2b.js +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +4 -4
- package/dist/janitor.d.ts +5 -4
- package/dist/janitor.js +1 -1
- package/dist/kernel.d.ts +16 -24
- package/dist/kernel.js +93 -18
- package/dist/kinds.d.ts +9 -4
- package/dist/labels.d.ts +10 -2
- package/dist/labels.js +30 -7
- package/dist/local-chrome.d.ts +3 -1
- package/dist/local-chrome.js +8 -4
- package/dist/modal.d.ts +3 -3
- package/dist/modal.js +71 -57
- package/dist/mount-archil.d.ts +25 -3
- package/dist/mount-archil.js +39 -8
- package/dist/orgo-desktop.d.ts +15 -6
- package/dist/orgo-desktop.js +295 -53
- package/dist/orgo-names.d.ts +129 -3
- package/dist/orgo-names.js +211 -8
- package/dist/orgo.d.ts +18 -7
- package/dist/orgo.js +381 -69
- package/dist/phone-harness.d.ts +3 -2
- package/dist/phone-harness.js +25 -8
- package/dist/protocol.d.ts +5 -0
- package/dist/provider.d.ts +63 -1
- package/dist/provider.js +8 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -431,7 +431,7 @@ in the kernel's tool registry, keyed by these groups.
|
|
|
431
431
|
| id | label | kinds | keys (required unless marked) | mounts | metered |
|
|
432
432
|
| --- | --- | --- | --- | --- | --- |
|
|
433
433
|
| docker | Docker | sandbox, desktop | none | bind | no |
|
|
434
|
-
| daytona | Daytona | sandbox | `DAYTONA_API_KEY`; `DAYTONA_API_URL`, `DAYTONA_TARGET` (optional) | archil | yes |
|
|
434
|
+
| daytona | Daytona | sandbox | `DAYTONA_API_KEY`; `DAYTONA_API_URL`, `DAYTONA_TARGET`, `DAYTONA_ARCHIL_EGRESS` (optional) | archil | yes |
|
|
435
435
|
| modal | Modal | sandbox | `MODAL_TOKEN_ID`, `MODAL_TOKEN_SECRET` | archil | yes |
|
|
436
436
|
| e2b | E2B | sandbox, desktop | `E2B_API_KEY` | archil | yes |
|
|
437
437
|
| orgo | Orgo | desktop (Linux; Windows and macOS with `os`) | `ORGO_API_KEY` | none | yes |
|
|
@@ -778,7 +778,7 @@ key.
|
|
|
778
778
|
|
|
779
779
|
- **The volume** `computer-<hex>-egress`: a tmpfs of 1 MiB, mode 0700, owned by the computer's uid:gid. The proxy
|
|
780
780
|
makes its Unix socket there (0600); the computer mounts it read-only at `/opt/agentrun/egress` (`EGRESS_MOUNT`).
|
|
781
|
-
- **The proxy container** `computer-<hex>-egress`: `node` in `EGRESS_IMAGE` (node:22.23.
|
|
781
|
+
- **The proxy container** `computer-<hex>-egress`: `node` in `EGRESS_IMAGE` (node:22.23.5-trixie-slim, pinned by
|
|
782
782
|
digest; `new DockerProvider({ daemonPath, egress: { image } })` replaces it) runs `dist/docker/egress-main.js`, this
|
|
783
783
|
package's own build, bound read-only with its `package.json`. It is on Docker's default bridge alone, publishes no
|
|
784
784
|
port, and runs as the computer's uid:gid with a read-only root, `--cap-drop ALL`, `no-new-privileges`, 256 MiB, 64
|
|
@@ -874,6 +874,14 @@ const made = await docker.create({ image: "debian:bookworm-slim", lifetimeMs: 60
|
|
|
874
874
|
`{ other: "<words>" }` for a mount at `/workspace` the provider never makes. An Archil mount's `epoch` is the
|
|
875
875
|
computer's `agentrun.epoch` label (Archil's hold on a folder carries none); an Archil mount with no epoch reads back
|
|
876
876
|
as `{ other }`, in words. The token is never in a label, a read-back or an error.
|
|
877
|
+
- **An Archil egress gateway (Daytona, `archilEgress` / `DAYTONA_ARCHIL_EGRESS`).** For a target whose runners reach
|
|
878
|
+
Archil only through a gateway, `<IPv4 gateway>:<mount lane>:<data lane>` (such as `10.60.0.40:18100:42050`, parcha-proxy's
|
|
879
|
+
archil-egress). The helper's mount then starts `computerd archil-relay` on the computer's loopback (127.0.0.1:3129) and
|
|
880
|
+
an nftables table of its own (`inet agentrun_archil`) that redirects root's TCP to 8100 (the mount endpoint) and 32050
|
|
881
|
+
(the file servers, at the raw addresses the mount endpoint returns) to the relay and resets every other TCP to those
|
|
882
|
+
ports. The relay sends each connection to the gateway's lane for its port with a PROXY v2 header naming the original
|
|
883
|
+
destination; the gateway admits only a destination that proves, by certificate, the Archil name the client asked for.
|
|
884
|
+
A relay that cannot reach the gateway closes the connection, so the client reaches nothing. Unset, nothing changes.
|
|
877
885
|
- **Docker takes a bind.** `create` adds `--mount type=bind,src=<path>,dst=/workspace` after the daemon's mount:
|
|
878
886
|
read-write, propagation `rprivate`. A path Docker's `--mount` cannot hold (a comma, a double quote, a line break) is
|
|
879
887
|
refused by `check`.
|
|
@@ -1493,7 +1501,10 @@ stopped one.
|
|
|
1493
1501
|
Daytona runs its own toolbox daemon as the sandbox's first process, and a snapshot we do not build has no `computerd`.
|
|
1494
1502
|
So the provider pushes it in at create and starts it as a long-lived command, and reaches it the same way:
|
|
1495
1503
|
|
|
1496
|
-
1. Upload the static binary through the toolbox's file upload, to `/tmp/agentrun-computerd-<random
|
|
1504
|
+
1. Upload the static binary through the toolbox's file upload, to `/tmp/agentrun-computerd-<random>`:
|
|
1505
|
+
`/files/upload-v2`, or `/files/upload` when the toolbox answers 404 for it. An older toolbox, as a self-hosted
|
|
1506
|
+
Daytona's runners may run, serves only `/files/upload`, which takes the same form; any other refusal is not retried
|
|
1507
|
+
on the older route.
|
|
1497
1508
|
2. Install it with `/process/execute` (the command is piped to the sandbox's shell): root-owned, mode 755, at
|
|
1498
1509
|
`/opt/agentrun/computerd`, and make `/work` (its home) and `/run/agentrun` (its socket's directory). As root, or
|
|
1499
1510
|
through passwordless `sudo`; a sandbox with neither is refused in the script's words. The script prints the
|
|
@@ -1579,7 +1590,7 @@ the TTL.
|
|
|
1579
1590
|
| `user` | none | the daemon runs as the provider's `daemonUser`; a spec cannot name a user |
|
|
1580
1591
|
| `release` | `stop`, `delete` | `POST /sandbox/{id}/stop` and `DELETE /sandbox/{id}` |
|
|
1581
1592
|
| `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:
|
|
1593
|
+
| `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's GPU host gives no `/dev/fuse`, even to root (live 11-11), and the archil client mounts through FUSE. 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. The `gpuSnapshot` option names our own GPU snapshot instead: box/Dockerfile as it is, built with one GPU by `box/build-daytona.py --gpu H100` (resources gpu 1 and gpuType H100, named `agentrun-archil-gpu-h100-<recipe hash>`, in region earth). Its user is root, its GPU is the one its name says, and its GPU computers take no mount either. It carries no CUDA toolkit: pip install torch brings its own CUDA runtime; the host gives the driver. A GPU spec's image is then `"default"` or that name. An Archil computer's preflight reads `/dev/fuse`, and one without it is refused in those words ("this computer has no /dev/fuse, so the Archil folder can't be mounted") before anything else |
|
|
1583
1594
|
|
|
1584
1595
|
### What the provider does
|
|
1585
1596
|
|
|
@@ -1660,8 +1671,8 @@ organization's), `daemonPath`, `arch` (`amd64` or `arm64`), `sandboxClass` (`con
|
|
|
1660
1671
|
The conformance module, `dist/conformance/daytona.js` (`--provider daytona`), reads the run's settings by these names
|
|
1661
1672
|
when it runs (`settingsFromEnv`) and passes each to `create()` as the option in brackets: `COMPUTER_DAYTONA_API_KEY`
|
|
1662
1673
|
(`apiKey`, required), `COMPUTER_DAYTONA_API_URL` (`apiUrl`), `COMPUTER_DAYTONA_DAEMON` (`daemonPath`),
|
|
1663
|
-
`COMPUTER_DAYTONA_ARCH` (`arch`), `COMPUTER_DAYTONA_TARGET` (`target`), `COMPUTER_DAYTONA_CLASS` (`sandboxClass`)
|
|
1664
|
-
`COMPUTER_DAYTONA_USER` (`daemonUser`). It exports `createProvider()` and `createDriftedProvider()` (which builds a
|
|
1674
|
+
`COMPUTER_DAYTONA_ARCH` (`arch`), `COMPUTER_DAYTONA_TARGET` (`target`), `COMPUTER_DAYTONA_CLASS` (`sandboxClass`),
|
|
1675
|
+
`COMPUTER_DAYTONA_USER` (`daemonUser`) and `COMPUTER_DAYTONA_GPU_SNAPSHOT` (`gpuSnapshot`). It exports `createProvider()` and `createDriftedProvider()` (which builds a
|
|
1665
1676
|
daemon of another version with Go), and reads `COMPUTER_DAYTONA_SNAPSHOT` (the run's image; unset, `"default"`,
|
|
1666
1677
|
Daytona's default snapshot). It never reads `DAYTONA_API_KEY`, `DAYTONA_API_URL` or `DAYTONA_TARGET`, not even as a
|
|
1667
1678
|
fallback: on a host that runs other Daytona work they may hold another organization's key. Those are serve's names,
|
|
@@ -1743,6 +1754,7 @@ repository's main; the docs were read on 2026-11-05.
|
|
|
1743
1754
|
| `GET /sandbox/{sandboxId}/toolbox-proxy-url`; the toolbox at `toolboxProxyUrl` + `/` + id | `daytona/clients@8006f63e:openapi-specs/api.json:5235`; `daytona/clients@8006f63e:sdk-typescript/src/Sandbox.ts:1566-1573` |
|
|
1744
1755
|
| `Authorization: Bearer <key>` | `daytona/clients@8006f63e:sdk-typescript/src/Daytona.ts:444` |
|
|
1745
1756
|
| `POST /files/upload-v2?path=`, multipart field `file` | `daytona/clients@8006f63e:openapi-specs/toolbox.json:2031` |
|
|
1757
|
+
| `POST /files/upload?path=`, multipart field `file`, on a toolbox with no `/files/upload-v2` | `daytonaio/daytona@b5a5d9e7:apps/daemon/pkg/toolbox/server.go:191`, `daytonaio/daytona@b5a5d9e7:apps/daemon/pkg/toolbox/fs/upload_file.go:22-35` |
|
|
1746
1758
|
| `POST /process/execute` `{command, timeout}` to `{exitCode, result}`; the command piped to the shell | `daytona/clients@8006f63e:openapi-specs/toolbox.json:3234`, `daytona/clients@8006f63e:openapi-specs/toolbox.json:4679`, `daytona/clients@8006f63e:openapi-specs/toolbox.json:4703`; `daytonaio/daytona@b5a5d9e7:apps/daemon/pkg/toolbox/process/execute.go:55-57` |
|
|
1747
1759
|
| `POST /process/session` `{sessionId}`; a session's shell runs as the toolbox's own user | `daytona/clients@8006f63e:openapi-specs/toolbox.json:3636`, `daytona/clients@8006f63e:openapi-specs/toolbox.json:4525`; `daytonaio/daytona@b5a5d9e7:apps/daemon/pkg/session/create.go:20-24` |
|
|
1748
1760
|
| `POST /process/session/{sessionId}/exec` `{command, runAsync, suppressInputEcho}` to `{cmdId}` | `daytona/clients@8006f63e:openapi-specs/toolbox.json:4017`, `daytona/clients@8006f63e:openapi-specs/toolbox.json:5922`, `daytona/clients@8006f63e:openapi-specs/toolbox.json:5935` |
|
|
@@ -2081,6 +2093,54 @@ built for.
|
|
|
2081
2093
|
- The live run needs Orgo's Scale plan or a Windows computer bought on the plan; the macOS run needs Orgo's Mac
|
|
2082
2094
|
access.
|
|
2083
2095
|
|
|
2096
|
+
### An agent's own computer on Orgo (persistence)
|
|
2097
|
+
|
|
2098
|
+
The Linux desktop declares `capabilities().persistence` (`{ keepsState: true, resume: true }`) and takes
|
|
2099
|
+
`spec.owner: { agent }` with no `lifetimeMs`: a computer that belongs to the agent and outlives the run (see
|
|
2100
|
+
"Persistent computers: an agent's own"). The Windows desktop's code declares it too, without resume; a Mac declares
|
|
2101
|
+
none.
|
|
2102
|
+
|
|
2103
|
+
- **Its name** is `computer-<hex>-o<the owner's hash>`, with no run, epoch or deadline, and it has no Orgo end.
|
|
2104
|
+
- **Its labels live in a ledger.** Orgo holds no labels, and a detached computer is never woken to read its labels
|
|
2105
|
+
file, so the provider keeps an agent's computer's labels (the owner's, the claim's run and epoch) and when it was
|
|
2106
|
+
detached in a ledger: the `ledger` option, which Orgo's descriptor declares, so serve passes its computer ledger and
|
|
2107
|
+
they outlive a restart. Without one it is kept in memory. `list` reads them with nothing run inside, and gives
|
|
2108
|
+
`owned`, `owner`, `detachedAt`, and `deadline` undefined. A ledger has `put`, `get`, `list`, `remove` and `swap`:
|
|
2109
|
+
`swap(was, entry)` writes entry only while the kept entry is still `was` as read (a compare-and-set; serve's is one
|
|
2110
|
+
SQL statement), and says whether it did.
|
|
2111
|
+
- **No entry, no labels.** An agent's computer with no ledger entry is listed `owned` with no labels and no owner, to
|
|
2112
|
+
an unfiltered list alone. The janitor can't read its owner, so it keeps it. Attach and detach refuse it in words,
|
|
2113
|
+
and nothing reads its labels file instead: release it with delete.
|
|
2114
|
+
- **`release(ref, "detach")`** is for an agent's computer alone; a run's computer refuses it and runs on:
|
|
2115
|
+
- Linux: Orgo's suspend saves memory and disk, and computerd init with them. `persistence.resume` is true.
|
|
2116
|
+
- Windows: Orgo's stop archives its disk (files, apps and settings, not memory), and it reads `frozen`. `resume` is
|
|
2117
|
+
false.
|
|
2118
|
+
- macOS declares no persistence: Orgo stops no Mac, so `check()` refuses an owner.
|
|
2119
|
+
- **`attach({ id }, { claim })`** from a later run starts or resumes it first: attaching an agent's computer is asking
|
|
2120
|
+
for it. A run's computer that isn't running is still never woken, and is never taken under a claim. Under a claim
|
|
2121
|
+
the computer carries the claim's run and epoch, in the ledger and its labels file. A claim of the same run below
|
|
2122
|
+
the epoch it carries is refused as fenced, and nothing changes. An attach that started or resumed the computer and
|
|
2123
|
+
then fails a check stops or suspends it again, as it was found. One rule keeps attaches, detaches and deletes apart:
|
|
2124
|
+
each takes the ledger entry with a busy marker (`swap`) before anything is done to the computer, and every other is
|
|
2125
|
+
refused (busy) until it is settled. The holder renews the marker with `swap` right before each step that wakes,
|
|
2126
|
+
stops, suspends or replaces what runs in the computer (a put-back, a daemon's replacement, its labels file written
|
|
2127
|
+
after a wake), and only the holder settles the entry, each write a `swap` from the entry it last wrote. A holder
|
|
2128
|
+
whose `swap` finds the entry changed (its marker went stale past 15 minutes and another took it, or it was removed)
|
|
2129
|
+
does nothing more to the computer, and its attach or detach answers an error, never ok. So of two attaches of one
|
|
2130
|
+
run racing, the lower epoch is refused however they interleave, and an older attach never ends the programs or
|
|
2131
|
+
sleep of a newer one. One provider's attaches and detaches of a computer take turns. Its read-back spec carries
|
|
2132
|
+
`owner`.
|
|
2133
|
+
- **`release(ref, "delete", { claim })`** deletes an agent's computer only while its ledger entry carries exactly that
|
|
2134
|
+
claim's run and epoch and nobody holds it busy; otherwise it is refused in words (fenced, or busy) and runs on. A
|
|
2135
|
+
claim that made a computer and then lost the agent's hold deletes it this way, so a later claim that found and took
|
|
2136
|
+
it keeps it. A run's computer refuses a delete under a claim.
|
|
2137
|
+
- **Init on Linux.** An owned computer's init ends its programs at its deadline, `maxLifetimeMs` out, and has no
|
|
2138
|
+
most in practice: each attach moves the deadline `maxLifetimeMs` out again (`deadline.extend`). A desktop left
|
|
2139
|
+
detached past that, or whose daemon is another version (the package was upgraded meanwhile), gets its daemon
|
|
2140
|
+
installed again at its next attach: the old init is stopped by its process, then every step create takes, the disk
|
|
2141
|
+
kept, and the attach notes say the daemon was replaced and why. A run's computer is refused instead. `extend`
|
|
2142
|
+
refuses an owned computer: it has no janitor's deadline to move.
|
|
2143
|
+
|
|
2084
2144
|
## Browsers: Browserbase and Kernel
|
|
2085
2145
|
|
|
2086
2146
|
A browser is a computer of kind `browser`: a vendor's browser session that answers CDP. No computerd runs (daemon
|
|
@@ -2103,19 +2163,40 @@ and are never in a ref, a list, an error's words or a report. `client` stays a `
|
|
|
2103
2163
|
| conformance reads | `COMPUTER_BROWSERBASE_API_KEY`, `COMPUTER_BROWSERBASE_PROJECT_ID`, `COMPUTER_BROWSERBASE_API_URL` | `COMPUTER_KERNEL_API_KEY`, `COMPUTER_KERNEL_API_URL` |
|
|
2104
2164
|
|
|
2105
2165
|
Both declare `lifetime: "vendor"`, `network: ["open"]`, `isolation: "vm"`, `release: ["delete"]`, and no `extend`
|
|
2106
|
-
(neither vendor moves a running session's timeout). Neither declares `downloads` yet:
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2166
|
+
(neither vendor moves a running session's timeout). Neither declares the `downloads` group yet: the kind registry's
|
|
2167
|
+
entry does not, so Browserbase's downloads are read through its `downloads` member (below). `check()` refuses an image
|
|
2168
|
+
other than `chromium`, a lifetime past the cap, a network other than open, any size, user, workdir or mount, and a
|
|
2169
|
+
browser option the provider does not declare (below), before a vendor call. `list` and attach by
|
|
2110
2170
|
labels take at least one label (a vendor account holds sessions no provider made), ask the vendor by status and by the
|
|
2111
2171
|
first label a query carries as it is, and match every label themselves. They show every browser that has not ended:
|
|
2112
2172
|
Browserbase's `RUNNING` and `PENDING`, Kernel's `status=all` with the deleted dropped (Kernel's filter takes one value,
|
|
2113
2173
|
and `active` may leave out a browser still starting). A release is idempotent: one already ended or
|
|
2114
2174
|
unknown to the vendor is released.
|
|
2115
2175
|
|
|
2176
|
+
A browser session's own options ride the spec, `spec.browser`: `viewport`, `profile: { pointer, save }` (a saved
|
|
2177
|
+
profile the session opens, and whether it writes back to it), `stealth` and `headless`. `capabilities().browser`
|
|
2178
|
+
declares what a provider's sessions offer: `timeout` (`"wall-clock"` or `"inactivity"`), `profiles: { settleMs }` (how
|
|
2179
|
+
long after a saving session ends the vendor may still write the profile back), `stealth`, `headless`, and
|
|
2180
|
+
`downloads: { path }` (the folder a driver points `Browser.setDownloadBehavior` at). An option asks for a declared
|
|
2181
|
+
feature or is refused in words; a flag set `false` asks for nothing; a viewport needs no feature. No browser loads an
|
|
2182
|
+
extension: the driver is raw CDP, with nothing loaded into Chrome. `isBrowserProvider(p)` is true for a provider of
|
|
2183
|
+
kind browser that declares them.
|
|
2184
|
+
|
|
2185
|
+
| | Browserbase | Kernel | Local Chrome |
|
|
2186
|
+
| --- | --- | --- | --- |
|
|
2187
|
+
| `capabilities().browser` | wall-clock, `stealth`, `profiles` (settle 5 s), `downloads` (`downloads/`) | inactivity, `headless`, `profiles` (settle 0) | wall-clock |
|
|
2188
|
+
| `viewport` | `browserSettings.viewport` | `viewport` | the window's size |
|
|
2189
|
+
| `stealth` | `browserSettings.verified` and `solveCaptchas` (the solver is off otherwise: Browserbase's default is on) | not declared (Kernel's stealth brings a proxy nothing prices yet) | not declared |
|
|
2190
|
+
| `profile` | a context: `browserSettings.context { id, persist }` | a profile by name: `profile { name, save_changes }`, made first if Kernel does not know it | not declared |
|
|
2191
|
+
| `profiles { create, remove }` | `POST /v1/contexts`, `DELETE /v1/contexts/{id}` | `POST /profiles` under a random name (the pointer), `DELETE /profiles/{name}` | none |
|
|
2192
|
+
| `downloads { list, read }` | `GET /v1/downloads?sessionId=` (paged), `GET /v1/downloads/{id}`, cut at `maxBytes` | none | none |
|
|
2193
|
+
|
|
2194
|
+
A pointer is a capability: whoever holds it opens the profile, so no error's words carry one.
|
|
2195
|
+
|
|
2116
2196
|
A vendor call is one request, never retried where a retry could open a second paid browser, and a failure names the
|
|
2117
|
-
call and the HTTP status alone, never the vendor's words. A host that already talks to the vendor
|
|
2118
|
-
|
|
2197
|
+
call and the HTTP status alone, never the vendor's words. A host that already talks to the vendor passes its own
|
|
2198
|
+
transport: `BrowserbaseApi` (its optional calls back the features of the same name: one without them declares none of
|
|
2199
|
+
those) or `KernelRequest`. Its thrown error rides the failure as a hidden
|
|
2119
2200
|
cause (`causeOf(result)`), not enumerable, so it is in no JSON.
|
|
2120
2201
|
|
|
2121
2202
|
Each create writes one more label beside the spec's, `agentrun.create` (`CREATE_LABEL`), with a value of its own. A
|
|
@@ -2186,8 +2267,9 @@ The fence and the sandbox are PR #1718's:
|
|
|
2186
2267
|
(`--webrtc-ip-handling-policy=disable_non_proxied_udp`). The proxy and its relay live in the supervisor, so the fence
|
|
2187
2268
|
holds for a browser driven from another process, and a browser whose supervisor is gone reaches nothing.
|
|
2188
2269
|
|
|
2189
|
-
Capabilities: `network: ["open"]` (public addresses), `isolation: "host"`,
|
|
2190
|
-
live view: run it headed to watch), `release: ["delete"]`, no mount
|
|
2270
|
+
Capabilities: `network: ["open", "allow"]` (public addresses, or a list's hosts among them), `isolation: "host"`,
|
|
2271
|
+
`daemon: "none"`, groups `cdp` only (no live view: run it headed to watch), `release: ["delete"]`, no mount, and
|
|
2272
|
+
`browser: { timeout: "wall-clock" }`: `spec.browser.viewport` sizes its window, and it takes no other session option.
|
|
2191
2273
|
|
|
2192
2274
|
Known limits, so it is for local and development use:
|
|
2193
2275
|
|
|
@@ -2200,9 +2282,9 @@ Known limits, so it is for local and development use:
|
|
|
2200
2282
|
processes. Through it they reach public addresses, which they can reach anyway.
|
|
2201
2283
|
- No proxy of your own, no extensions, no saved profiles: each browser starts from an empty profile that goes with it.
|
|
2202
2284
|
|
|
2203
|
-
Driving it: pi-browser's raw-CDP driver (`@parcha/pi-browser/driver/cdp`) drives this browser
|
|
2204
|
-
`snapshot` and `run` actions
|
|
2205
|
-
|
|
2285
|
+
Driving it: pi-browser's raw-CDP driver (`@parcha/pi-browser/driver/cdp`) drives this browser, as it drives the vendor
|
|
2286
|
+
browsers, with the `snapshot` and `run` actions and nothing loaded into Chrome. `run` code is refused; navigation is a
|
|
2287
|
+
`goto` action. Its snapshot does not read a frame another site runs in its own
|
|
2206
2288
|
process (a cross-origin iframe). The snapshot names each frame it left out, so an agent knows the page has more.
|
|
2207
2289
|
|
|
2208
2290
|
The conformance module starts a real Chrome, so it waits for its switch:
|
|
@@ -2226,7 +2308,9 @@ const made = await phones.create({ image: "android", lifetimeMs: 10 * 60_000, ne
|
|
|
2226
2308
|
the API's control URL) is a later change: `platform: "ios"` is refused in words.
|
|
2227
2309
|
|
|
2228
2310
|
- **No daemon.** Nothing runs on the phone. `connect()` asks the phone harness for the session's adb link, runs
|
|
2229
|
-
connects to it, unlocks the phone with the session's code (never in a result or an error) and probes it.
|
|
2311
|
+
connects to it, unlocks the phone with the session's code (never in a result or an error) and probes it. Its hello
|
|
2312
|
+
carries what the probe read: `arch` from `getprop ro.product.cpu.abi`, and `osVersion`, the Android release from
|
|
2313
|
+
`getprop ro.build.version.release` (such as `"15"`; absent when the phone says none).
|
|
2230
2314
|
- Neither the endpoint nor the code is ever in a spawned adb's argv, which `/proc` shows to every user of the host.
|
|
2231
2315
|
The endpoint goes to the local adb server over its socket protocol (`host:connect`, `host:devices-l`,
|
|
2232
2316
|
`host:disconnect`). The unlock is the vendor's shell command `unlock <code>`, once per connection; every shell
|
|
@@ -2295,8 +2379,9 @@ the API's control URL) is a later change: `platform: "ios"` is refused in words.
|
|
|
2295
2379
|
- `list()` reads the ledger before `GET /sessions`, so it never forgets a phone a create records while it runs. It
|
|
2296
2380
|
forgets a phone the listing leaves out only once that phone's own `GET /sessions/<id>` is a 404.
|
|
2297
2381
|
- **adb** is an option too: a transport, `{ run(args, { input }), server(service) }` (tests give a fake), or the path of
|
|
2298
|
-
the `adb` CLI (Android platform-tools; default `adb` on PATH
|
|
2299
|
-
|
|
2382
|
+
the `adb` CLI (Android platform-tools; default `adb` on PATH, which the phone's descriptor names as its
|
|
2383
|
+
`hostCommand`, so a server says it is missing before any phone is rented), whose server it starts and speaks to on
|
|
2384
|
+
the loopback (port 5037, adb's own, or `adbCli(path, { port })`). Every spawned adb names that port with `-P`, so the CLI and the
|
|
2300
2385
|
socket requests reach one server. `adbCli(path, { env })` spawns adb from the environment given, with every
|
|
2301
2386
|
`ADB_*`, `ANDROID_ADB_*` and `ANDROID_SERIAL` variable dropped, so nothing in it points the CLI at another server or
|
|
2302
2387
|
device. The library reads no environment of its own: the conformance module passes its own, minus its
|
|
@@ -2582,7 +2667,9 @@ it is declared (`descriptorProblems`), in words. Its fields: `id`, `label`, `key
|
|
|
2582
2667
|
fills, and whether it is required), `settings` (a setting that is no key but fills an option, with its default),
|
|
2583
2668
|
`metered`, `mounts`, `network` (the network forms its computers make, at least one of none, open and allow),
|
|
2584
2669
|
`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), `
|
|
2670
|
+
`prepareImage` (a provider that builds or pulls its image before a run), `imageEnv` (the server's environment variable
|
|
2671
|
+
that, when set, names the image of every computer of the provider, as Daytona's `AGENTRUN_DAYTONA_SNAPSHOT`), `local`
|
|
2672
|
+
(a computer on this host), and
|
|
2586
2673
|
`ledger` (the option a provider's ledger fills). `providerFor(id, options)` builds a provider by id from its options and
|
|
2587
2674
|
refuses an id it does not hold, naming the ones it does. The provider file, `src/<vendor>.ts`, exports what a
|
|
2588
2675
|
`ProviderModule` is:
|
package/box/Dockerfile
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
# - FUSE (fuse3, and the client's own FUSE library). No firewall: init and every tool run in a network namespace of
|
|
9
9
|
# their own with loopback alone (computerd init --own-network), while the archil client and serve, as root, stay in
|
|
10
10
|
# the computer's, which reaches Archil;
|
|
11
|
+
# - nftables, for the helper's mount with an egress gateway alone: it redirects root's TCP to Archil's 8100 and 32050
|
|
12
|
+
# to computerd's archil relay on the computer's loopback;
|
|
11
13
|
# - /workspace, empty and root's, where the helper mounts the run's folder.
|
|
12
14
|
#
|
|
13
15
|
# No sudo and no sudoers file: the image's user is root, so the provider's own exec (Daytona's toolbox, Modal's exec,
|
|
@@ -35,7 +37,7 @@ RUN set -eu; \
|
|
|
35
37
|
case "$sum" in unpinned) echo "archil ${ARCHIL_VERSION} for $arch has no pinned sha256 yet: set ARCHIL_SHA256_$(echo "$arch" | tr a-z A-Z) to the package's sum" >&2; exit 1 ;; esac; \
|
|
36
38
|
apt-get update -qq; \
|
|
37
39
|
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends \
|
|
38
|
-
git curl ca-certificates nodejs npm ripgrep fuse3 >/dev/null; \
|
|
40
|
+
git curl ca-certificates nodejs npm ripgrep fuse3 nftables >/dev/null; \
|
|
39
41
|
curl -fsSL -o /tmp/archil.deb "https://s3.amazonaws.com/archil-client/pkg/archil_${ARCHIL_VERSION}_${arch}.deb"; \
|
|
40
42
|
echo "$sum /tmp/archil.deb" | sha256sum -c -; \
|
|
41
43
|
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends /tmp/archil.deb >/dev/null; \
|
package/box/agentrun-archil
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
# at /workspace. It does four things and nothing else, each with fixed arguments to the archil client, to find and chown,
|
|
4
4
|
# or to computerd:
|
|
5
5
|
#
|
|
6
|
-
# mount <disk> <region> agents/<agent>/runs/<run>/work the
|
|
7
|
-
# revoke <disk> <region> agents/<agent>/runs/<run>/work the
|
|
6
|
+
# mount <disk> <region> agents/<agent>/runs/<run>/work [egress=<gateway>:<mount lane>:<data lane>] the token on fd 0
|
|
7
|
+
# revoke <disk> <region> agents/<agent>/runs/<run>/work [egress=<gateway>:<mount lane>:<data lane>] the token on fd 0
|
|
8
8
|
# serve
|
|
9
9
|
# checkin
|
|
10
10
|
#
|
|
@@ -12,6 +12,15 @@
|
|
|
12
12
|
# then every path of the mounted tree that is not agentrun-tool's is given to it (the links themselves, never
|
|
13
13
|
# followed, and never past the mount): the disk's object API makes files root's, 644, and while a computer holds
|
|
14
14
|
# the folder no outside write lands (Archil refuses it), so what the object API made is all there at the mount.
|
|
15
|
+
# With egress=<gateway>:<mount lane>:<data lane> (an IPv4 address and two ports, neither 8100 nor 32050), the
|
|
16
|
+
# archil client reaches Archil through that egress gateway alone, set up before it runs: `computerd archil-relay`
|
|
17
|
+
# listens on the computer's loopback (127.0.0.1:3129), and an nftables table of the helper's own (inet
|
|
18
|
+
# agentrun_archil, replaced whole) redirects root's TCP to 8100 (the mount endpoint) and 32050 (the file servers)
|
|
19
|
+
# to it and resets every other TCP to those ports. The relay carries each connection to the gateway's lane for
|
|
20
|
+
# its port with a PROXY v2 header naming the original destination, and the gateway admits it only to a
|
|
21
|
+
# destination that proves, by certificate, the Archil name the client asked for. A relay or a table that cannot
|
|
22
|
+
# be set up exits 4 and runs nothing; a relay that cannot reach the gateway later closes the connection, so the
|
|
23
|
+
# client reaches nothing. Both stay as long as the computer. With no egress, nothing of this is set.
|
|
15
24
|
# revoke the same with --force: takes the folder back from a computer that is gone and left its delegation behind.
|
|
16
25
|
# serve becomes `computerd sync-serve`, resident, holding no token: on its socket it takes one fixed byte and answers
|
|
17
26
|
# the exit code of `archil sync /workspace` (every write so far durable), coalesced; it exits when the mount
|
|
@@ -20,7 +29,7 @@
|
|
|
20
29
|
#
|
|
21
30
|
# The archil client and serve run as root in the computer's own network namespace, which reaches Archil; init and every
|
|
22
31
|
# tool run in a namespace of their own with loopback alone (computerd init --own-network), so the tools have no network
|
|
23
|
-
# and reach no daemon of the provider's.
|
|
32
|
+
# and reach no daemon of the provider's. Without egress this helper sets no firewall.
|
|
24
33
|
#
|
|
25
34
|
# Install it root:root 0755 at /usr/local/sbin/agentrun-archil. The provider runs it as root through its own exec (the
|
|
26
35
|
# image's user is root), never through sudo: the image has none. The run's tools run as agentrun-tool, through
|
|
@@ -29,12 +38,13 @@
|
|
|
29
38
|
# The token is read from fd 0 and handed to archil only in the environment of its exec (archil reads it nowhere else),
|
|
30
39
|
# never as an argument and never in a file. Every argument is checked here, whoever calls: a caller that is not root, a
|
|
31
40
|
# wrong verb or count, a newline, a disk, region or folder of any other shape (an absolute path, `.` or `..`, an empty
|
|
32
|
-
# or extra segment), a mountpoint that is a link or not empty, or a token of any other
|
|
41
|
+
# or extra segment), an egress of any other shape, a mountpoint that is a link or not empty, or a token of any other
|
|
42
|
+
# shape exits 2 and runs nothing.
|
|
33
43
|
# A serve or checkin with nothing mounted exits 3 and runs nothing. A mount or revoke in a computer whose /proc lets a
|
|
34
44
|
# user see another's processes (no hidepid=2 or invisible) exits 4 and runs nothing; each first remounts /proc with
|
|
35
45
|
# hidepid=2, which a computer whose root may not remount leaves as it was. A mount the client refuses answers the
|
|
36
46
|
# client's exit code; a mount whose tree cannot then be given to agentrun-tool exits 4. A serve whose computerd is not
|
|
37
|
-
# root's alone exits 4.
|
|
47
|
+
# root's alone exits 4, and so does a mount or revoke with egress whose computerd is not.
|
|
38
48
|
set -eu
|
|
39
49
|
umask 077
|
|
40
50
|
PATH=/usr/sbin:/usr/bin:/sbin:/bin
|
|
@@ -53,6 +63,7 @@ FIND=/usr/bin/find
|
|
|
53
63
|
TOOL=agentrun-tool
|
|
54
64
|
TOOL_UID=2510
|
|
55
65
|
COMPUTERD=/opt/agentrun/computerd
|
|
66
|
+
NFT=/usr/sbin/nft
|
|
56
67
|
SOCK=/run/agentrun-archil/archil.sock
|
|
57
68
|
ROOT_UID=0
|
|
58
69
|
HELD_TOP=/
|
|
@@ -76,12 +87,25 @@ matches() { printf '%s\n' "$1" | grep -Eqx -- "$2"; }
|
|
|
76
87
|
# Whether $MP is in the mount table, as an archil mount (fuse.archil) or as anything (any).
|
|
77
88
|
listed() { awk -v m="$MP" -v t="$1" '$2 == m && (t == "any" || $3 == t) { f = 1 } END { exit !f }' "$MOUNTS"; }
|
|
78
89
|
|
|
90
|
+
# The relay's port on the computer's loopback (computerd's archilrelay.Address) and Archil's two ports.
|
|
91
|
+
RELAY_PORT=3129
|
|
92
|
+
ARCHIL_PORTS='8100, 32050'
|
|
93
|
+
|
|
79
94
|
take() {
|
|
80
|
-
[ "$#" -eq 3 ] || refuse "$verb takes <disk> <region> agents/<agent>/runs/<run>/work"
|
|
81
|
-
disk=$1 region=$2 folder=$3
|
|
95
|
+
[ "$#" -eq 3 ] || [ "$#" -eq 4 ] || refuse "$verb takes <disk> <region> agents/<agent>/runs/<run>/work and at most egress=<gateway>:<mount lane>:<data lane>"
|
|
96
|
+
disk=$1 region=$2 folder=$3 egress=${4-}
|
|
82
97
|
matches "$disk" 'dsk-[0-9a-f]{16}|[A-Za-z0-9][A-Za-z0-9._@+-]{0,127}/[A-Za-z0-9][A-Za-z0-9._-]{0,127}' || refuse "the disk is a disk id (dsk-...) or owner/name"
|
|
83
98
|
matches "$region" '[a-z0-9]+-[a-z0-9][a-z0-9-]{0,62}' || refuse "the region is a provider, a dash and its region, lowercase letters, digits and dashes"
|
|
84
99
|
matches "$folder" 'agents/[A-Za-z0-9][A-Za-z0-9_-]{0,127}/runs/[A-Za-z0-9][A-Za-z0-9_-]{0,127}/work' || refuse "the folder is agents/<agent>/runs/<run>/work, nothing else"
|
|
100
|
+
if [ "$#" -eq 4 ]; then
|
|
101
|
+
# egress=<IPv4>:<port>:<port>, as mount-archil.ts checks it; computerd archil-relay checks the same again.
|
|
102
|
+
port='([1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])'
|
|
103
|
+
matches "$egress" "egress=((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9]):$port:$port" || refuse "egress is egress=<gateway>:<mount lane>:<data lane>, an IPv4 address and two ports"
|
|
104
|
+
lanes=${egress#egress=}
|
|
105
|
+
gateway=${lanes%%:*} lanes=${lanes#*:}
|
|
106
|
+
mount_lane=${lanes%%:*} data_lane=${lanes#*:}
|
|
107
|
+
[ "$mount_lane" != "$data_lane" ] && [ "$mount_lane" != 8100 ] && [ "$mount_lane" != 32050 ] && [ "$data_lane" != 8100 ] && [ "$data_lane" != 32050 ] || refuse "egress's two lanes differ, and neither is 8100 or 32050, which the computer redirects to the relay"
|
|
108
|
+
fi
|
|
85
109
|
# The computer's /proc (its last mount there) must hide each user's processes from the others, hidepid=2 or invisible
|
|
86
110
|
# as newer kernels name it: else the run's tools could see this root archil client's. No image sets it, so it is
|
|
87
111
|
# remounted so first, as root may where it holds CAP_SYS_ADMIN; a computer where that fails is refused by the check.
|
|
@@ -104,6 +128,8 @@ take() {
|
|
|
104
128
|
IFS= read -r token || [ -n "$token" ] || refuse "no token on fd 0"
|
|
105
129
|
[ "${#token}" -ge 16 ] && [ "${#token}" -le 4096 ] || refuse "the token is not a disk token"
|
|
106
130
|
case "$token" in *[!A-Za-z0-9._~+/=-]*) refuse "the token is not a disk token" ;; esac
|
|
131
|
+
# Every argument and the token checked: the way out is set right before the client that takes it.
|
|
132
|
+
[ -z "$egress" ] || route
|
|
107
133
|
# In the environment of archil's command alone (an assignment before the command, never exported to this shell's own,
|
|
108
134
|
# which was fixed at its start), and archil runs as root, so no other user reads it there.
|
|
109
135
|
rc=0
|
|
@@ -119,6 +145,32 @@ take() {
|
|
|
119
145
|
}
|
|
120
146
|
}
|
|
121
147
|
|
|
148
|
+
# The archil client's way out through the egress gateway: the relay first, so every redirected connection meets it, then
|
|
149
|
+
# the table, whole (made, dropped and made again in one transaction, so a mount found again replaces its own).
|
|
150
|
+
route() {
|
|
151
|
+
rootsalone || { printf 'agentrun-archil: computerd at %s is not root'"'"'s alone, so no relay runs and nothing is mounted\n' "$COMPUTERD" >&2; exit 4; }
|
|
152
|
+
"$COMPUTERD" archil-relay --gateway "$gateway" --mount-lane "$mount_lane" --data-lane "$data_lane" </dev/null || {
|
|
153
|
+
printf 'agentrun-archil: the archil relay to %s did not start, so nothing is mounted\n' "$gateway" >&2
|
|
154
|
+
exit 4
|
|
155
|
+
}
|
|
156
|
+
printf '%s\n' \
|
|
157
|
+
'table inet agentrun_archil' \
|
|
158
|
+
'delete table inet agentrun_archil' \
|
|
159
|
+
'table inet agentrun_archil {' \
|
|
160
|
+
' chain out_redirect {' \
|
|
161
|
+
' type nat hook output priority -100; policy accept;' \
|
|
162
|
+
" meta skuid 0 meta nfproto ipv4 tcp dport { $ARCHIL_PORTS } redirect to :$RELAY_PORT" \
|
|
163
|
+
' }' \
|
|
164
|
+
' chain out_fence {' \
|
|
165
|
+
' type filter hook output priority 0; policy accept;' \
|
|
166
|
+
" tcp dport { $ARCHIL_PORTS } reject with tcp reset" \
|
|
167
|
+
' }' \
|
|
168
|
+
'}' | "$NFT" -f - || {
|
|
169
|
+
printf 'agentrun-archil: the redirect to the archil relay could not be set, so nothing is mounted\n' >&2
|
|
170
|
+
exit 4
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
122
174
|
# serve and checkin act on the archil mount at $MP; with none there (a computer whose mount went), nothing is held, and
|
|
123
175
|
# they say so with exit 3.
|
|
124
176
|
held() {
|
package/box/build-daytona.py
CHANGED
|
@@ -4,22 +4,38 @@
|
|
|
4
4
|
# a new snapshot, and the same recipe is the one built before: Daytona then refuses the name, and the printed name is
|
|
5
5
|
# the one to use. Its size is 2 CPUs, 4 GB of memory and a 10 GB disk.
|
|
6
6
|
#
|
|
7
|
-
#
|
|
7
|
+
# With --gpu H100, the same image as a GPU snapshot: a snapshot carries its own resources, the GPU among them, so its
|
|
8
|
+
# sandboxes have one H100 (and daytona-gpu's 16 CPUs, 100 GB of memory and a 400 GB disk), in region earth, Daytona's
|
|
9
|
+
# GPU region. Its name is agentrun-archil-gpu-h100-<the recipe's hash>: the provider's gpuSnapshot option takes it, and
|
|
10
|
+
# reads the GPU from it. Another type is another snapshot.
|
|
11
|
+
#
|
|
12
|
+
# python3 packages/computer/box/build-daytona.py [--gpu H100]
|
|
8
13
|
import hashlib
|
|
9
14
|
import os
|
|
10
15
|
import sys
|
|
11
16
|
|
|
12
|
-
from daytona import CreateSnapshotParams, Daytona, Image, Resources
|
|
17
|
+
from daytona import CreateSnapshotParams, Daytona, GpuType, Image, Resources
|
|
18
|
+
|
|
19
|
+
GPUS = {"H100": GpuType.H100}
|
|
20
|
+
|
|
21
|
+
args = sys.argv[1:]
|
|
22
|
+
gpu = None
|
|
23
|
+
if args:
|
|
24
|
+
if len(args) != 2 or args[0] != "--gpu" or args[1] not in GPUS:
|
|
25
|
+
sys.exit(f"usage: build-daytona.py [--gpu {'|'.join(GPUS)}]")
|
|
26
|
+
gpu = args[1]
|
|
13
27
|
|
|
14
28
|
here = os.path.dirname(os.path.abspath(__file__))
|
|
15
29
|
recipe = b"".join(open(os.path.join(here, name), "rb").read() for name in ("Dockerfile", "agentrun-archil"))
|
|
16
|
-
|
|
30
|
+
digest = hashlib.sha256(recipe).hexdigest()[:12]
|
|
31
|
+
name = f"agentrun-archil-gpu-{gpu.lower()}-{digest}" if gpu else f"agentrun-archil-{digest}"
|
|
17
32
|
print(f"build-daytona: snapshot {name}", file=sys.stderr)
|
|
18
33
|
Daytona().snapshot.create(
|
|
19
34
|
CreateSnapshotParams(
|
|
20
35
|
name=name,
|
|
21
36
|
image=Image.from_dockerfile(os.path.join(here, "Dockerfile")),
|
|
22
|
-
resources=Resources(cpu=2, memory=4, disk=10),
|
|
37
|
+
resources=Resources(cpu=16, memory=100, disk=400, gpu=1, gpu_type=GPUS[gpu]) if gpu else Resources(cpu=2, memory=4, disk=10),
|
|
38
|
+
**({"region_id": "earth"} if gpu else {}),
|
|
23
39
|
),
|
|
24
40
|
on_logs=lambda line: print(line, file=sys.stderr),
|
|
25
41
|
)
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { type ComputerClient, type Group, type HelloResult } from "./protocol.js";
|
|
2
|
-
import type { ComputerCapabilities, ComputerSpec, Refusal } from "./provider.js";
|
|
2
|
+
import type { BrowserFeatures, CallContext, ComputerCapabilities, ComputerProvider, ComputerRef, ComputerSpec, Refusal } from "./provider.js";
|
|
3
3
|
import { type ComputerError, type ComputerErrorCode, type Result } from "./result.js";
|
|
4
4
|
/**
|
|
5
|
-
* Where a provider keeps the URLs it was handed, by session id, in memory only
|
|
6
|
-
* builds one provider per call passes one store to all of them (pi-browser's process-wide holdings).
|
|
5
|
+
* Where a provider keeps the URLs it was handed, by session id, in memory only: a Map of its own.
|
|
7
6
|
*/
|
|
8
7
|
export interface UrlStore {
|
|
9
8
|
get(id: string): string | undefined;
|
|
@@ -77,8 +76,9 @@ export declare const RECOVER_MS = 30000;
|
|
|
77
76
|
export declare function recoverCreate(what: string, find: (signal: AbortSignal) => Promise<Result<string[]>>, release: (id: string) => Promise<Result<void>>, sleep: (ms: number) => Promise<void>): Promise<string>;
|
|
78
77
|
/**
|
|
79
78
|
* The checks every browser provider makes before a vendor call: the image is chromium, the lifetime is within the
|
|
80
|
-
* vendor's cap (and at least min), the network is open, the labels are ones the vendor's metadata holds,
|
|
81
|
-
*
|
|
79
|
+
* vendor's cap (and at least min), the network is open, the labels are ones the vendor's metadata holds, the session's
|
|
80
|
+
* options are ones capabilities().browser declares (browserSpecRefusals), and no field a browser does not take (a size,
|
|
81
|
+
* a user, a workdir, a mount).
|
|
82
82
|
*/
|
|
83
83
|
export declare function checkBrowser(spec: ComputerSpec, capabilities: ComputerCapabilities, vendor: string, minLifetimeMs?: number): Refusal[];
|
|
84
84
|
/** hello for a browser: the provider's version, linux, kind browser and its groups. The vendor reports no arch. */
|
|
@@ -126,6 +126,12 @@ export declare function vendorFailure(vendor: string, name: string, call: string
|
|
|
126
126
|
* redirects refused; this holds the CDP URL itself to the same.
|
|
127
127
|
*/
|
|
128
128
|
export declare function cdpUrlProblem(url: unknown, name: string, domain: string): string | undefined;
|
|
129
|
+
/** What a REST call sends: a JSON body, a query and a signal. */
|
|
130
|
+
export interface RestInit {
|
|
131
|
+
body?: unknown;
|
|
132
|
+
query?: URLSearchParams;
|
|
133
|
+
signal?: AbortSignal;
|
|
134
|
+
}
|
|
129
135
|
/** What the REST calls share: one request, never retried, read whole; a failure throws a BrowserVendorError. */
|
|
130
136
|
export interface RestReply {
|
|
131
137
|
status: number;
|
|
@@ -139,12 +145,57 @@ export declare function restCall(o: {
|
|
|
139
145
|
fetch: typeof fetch;
|
|
140
146
|
base: string;
|
|
141
147
|
headers: Record<string, string>;
|
|
142
|
-
}, method: string, route: string, call: string, init?:
|
|
143
|
-
body?: unknown;
|
|
144
|
-
query?: URLSearchParams;
|
|
145
|
-
signal?: AbortSignal;
|
|
146
|
-
}): Promise<RestReply>;
|
|
148
|
+
}, method: string, route: string, call: string, init?: RestInit): Promise<RestReply>;
|
|
147
149
|
/** An https base URL, with no trailing slash, so a key never crosses in the clear; throws in words on another. */
|
|
148
150
|
export declare function httpsBase(url: string, what: string): string;
|
|
149
151
|
/** A vendor's session id as a ref or attach gives it: a plain token, never a path. */
|
|
150
152
|
export declare const idProblem: (id: unknown, vendor: string) => string | undefined;
|
|
153
|
+
/**
|
|
154
|
+
* A GET whose success is bytes, streamed (Accept application/octet-stream); undefined when the vendor answers 404. A
|
|
155
|
+
* redirect is followed once, to https only, and without the key's headers, so a storage host is never handed the key.
|
|
156
|
+
* A failure throws a BrowserVendorError that names the call and the status alone.
|
|
157
|
+
*/
|
|
158
|
+
export declare function restBytes(o: {
|
|
159
|
+
vendor: string;
|
|
160
|
+
fetch: typeof fetch;
|
|
161
|
+
base: string;
|
|
162
|
+
headers: Record<string, string>;
|
|
163
|
+
}, route: string, call: string, signal?: AbortSignal): Promise<AsyncIterable<Uint8Array> | undefined>;
|
|
164
|
+
/** The bytes as they come, failing in words once they pass maxBytes: what reached the reader before then is all it gets. */
|
|
165
|
+
export declare function limitedBytes(body: AsyncIterable<Uint8Array>, maxBytes: number, what: string): AsyncIterable<Uint8Array>;
|
|
166
|
+
/** One file a session downloaded, as downloads.list gives it. */
|
|
167
|
+
export interface BrowserFile {
|
|
168
|
+
name: string;
|
|
169
|
+
sizeBytes: number;
|
|
170
|
+
modifiedAt: string | null;
|
|
171
|
+
}
|
|
172
|
+
/** Saved profiles: a pointer is a capability (whoever holds it opens the profile), so no error's words carry one. */
|
|
173
|
+
export interface BrowserProfiles {
|
|
174
|
+
create(context?: CallContext): Promise<Result<string>>;
|
|
175
|
+
/** A profile the vendor no longer knows is removed. */
|
|
176
|
+
remove(pointer: string, context?: CallContext): Promise<Result<void>>;
|
|
177
|
+
}
|
|
178
|
+
/** The files a session downloaded, kept by the vendor. */
|
|
179
|
+
export interface BrowserDownloads {
|
|
180
|
+
list(ref: ComputerRef, context?: CallContext): Promise<Result<BrowserFile[]>>;
|
|
181
|
+
/** The file's bytes, streamed; the stream fails in words once it passes maxBytes. */
|
|
182
|
+
read(ref: ComputerRef, name: string, maxBytes: number, context?: CallContext): Promise<Result<AsyncIterable<Uint8Array>>>;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* A provider of browsers, with the members its features may bring: profiles where capabilities().browser declares
|
|
186
|
+
* profiles, downloads where it declares downloads.
|
|
187
|
+
*/
|
|
188
|
+
export interface BrowserComputerProvider extends ComputerProvider {
|
|
189
|
+
readonly profiles?: BrowserProfiles;
|
|
190
|
+
readonly downloads?: BrowserDownloads;
|
|
191
|
+
}
|
|
192
|
+
/** Whether a provider is a browser provider: its capabilities are of kind browser and declare its sessions' features. */
|
|
193
|
+
export declare function isBrowserProvider(provider: ComputerProvider): provider is BrowserComputerProvider;
|
|
194
|
+
/** A profile's pointer as a provider takes it: a plain token, so it is a path segment and never a path. */
|
|
195
|
+
export declare const pointerOk: (pointer: unknown) => pointer is string;
|
|
196
|
+
/**
|
|
197
|
+
* Why spec.browser is not one this provider takes, field by field: a malformed option, or one its features
|
|
198
|
+
* (capabilities().browser) do not declare (a flag set false asks for nothing, so it is never refused). The words never
|
|
199
|
+
* carry a pointer.
|
|
200
|
+
*/
|
|
201
|
+
export declare function browserSpecRefusals(session: unknown, features: BrowserFeatures, vendor: string): Refusal[];
|