@parcha/agentrun-computer 0.1.0-beta.39 → 0.1.0-beta.41
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 +56 -21
- package/box/Dockerfile +11 -58
- package/box/README.md +15 -2
- package/box/build-daytona.py +4 -2
- package/box/build-e2b.mjs +1 -1
- package/box/install.sh +148 -0
- package/box/recipe.mjs +12 -10
- package/dist/agent37.js +2 -1
- package/dist/attach.d.ts +46 -1
- package/dist/attach.js +48 -4
- package/dist/box-image.d.ts +2 -0
- package/dist/box-image.js +10 -0
- package/dist/computerd-linux-amd64 +0 -0
- package/dist/computerd-linux-arm64 +0 -0
- package/dist/computerd.json +2 -2
- package/dist/conformance/cases/isolation.js +17 -1
- package/dist/conformance/cases/lifetime.js +30 -0
- package/dist/conformance/cases/provider.js +63 -1
- package/dist/conformance/cli.js +27 -5
- package/dist/conformance/daytona.d.ts +25 -0
- package/dist/conformance/daytona.js +26 -1
- package/dist/conformance/exec-stream.d.ts +37 -7
- package/dist/conformance/exec-stream.js +349 -89
- package/dist/conformance/report.js +3 -0
- package/dist/conformance/runner.js +134 -12
- package/dist/conformance/sweep.d.ts +7 -2
- package/dist/conformance/sweep.js +17 -7
- package/dist/conformance/types.d.ts +42 -0
- package/dist/daytona.d.ts +8 -1
- package/dist/daytona.js +126 -101
- package/dist/descriptor.d.ts +22 -1
- package/dist/descriptor.js +18 -0
- package/dist/descriptors/daytona.d.ts +12 -3
- package/dist/descriptors/daytona.js +15 -7
- package/dist/descriptors/index.d.ts +8 -1
- package/dist/e2b.js +1 -1
- package/dist/host.d.ts +91 -26
- package/dist/host.js +5 -0
- package/dist/hosted/framed-exec.d.ts +38 -0
- package/dist/hosted/framed-exec.js +119 -0
- package/dist/hosted/process.d.ts +13 -5
- package/dist/hosted/process.js +39 -14
- package/dist/hosted/provider.d.ts +48 -6
- package/dist/hosted/provider.js +435 -64
- package/dist/hosted/rest.d.ts +29 -0
- package/dist/hosted/rest.js +91 -6
- package/dist/hosted/scripts.d.ts +58 -0
- package/dist/hosted/scripts.js +138 -1
- package/dist/hosted/ssh-exec.d.ts +7 -6
- package/dist/hosted/ssh-exec.js +35 -52
- package/dist/hosted/values.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/kinds.d.ts +2 -0
- package/dist/modal.js +21 -8
- package/dist/providers.d.ts +4 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -443,7 +443,7 @@ in the kernel's tool registry, keyed by these groups.
|
|
|
443
443
|
| id | label | kinds | keys (required unless marked) | mounts | metered |
|
|
444
444
|
| --- | --- | --- | --- | --- | --- |
|
|
445
445
|
| docker | Docker | sandbox, desktop | none | bind | no |
|
|
446
|
-
| daytona | Daytona | sandbox | `DAYTONA_API_KEY`; `DAYTONA_API_URL`, `DAYTONA_TARGET` (optional) | none (`unmounted`: archil) | yes |
|
|
446
|
+
| daytona | Daytona | sandbox | `DAYTONA_API_KEY`; `DAYTONA_API_URL`, `DAYTONA_TARGET`, `DAYTONA_ARCHIL_EGRESS` (optional) | none (`unmounted`: archil); archil with `DAYTONA_ARCHIL_EGRESS` (`mountsWith`) | yes |
|
|
447
447
|
| modal | Modal | sandbox | `MODAL_TOKEN_ID`, `MODAL_TOKEN_SECRET` | archil | yes |
|
|
448
448
|
| e2b | E2B | sandbox, desktop | `E2B_API_KEY` | archil | yes |
|
|
449
449
|
| orgo | Orgo | desktop (Linux; Windows and macOS with `os`) | `ORGO_API_KEY` | none | yes |
|
|
@@ -914,9 +914,9 @@ const made = await docker.create({ image: "debian:bookworm-slim", lifetimeMs: 60
|
|
|
914
914
|
`{ other: "<words>" }` for a mount at `/workspace` the provider never makes. An Archil mount's `epoch` is the
|
|
915
915
|
computer's `agentrun.epoch` label (Archil's hold on a folder carries none); an Archil mount with no epoch reads back
|
|
916
916
|
as `{ other }`, in words. The token is never in a label, a read-back or an error.
|
|
917
|
-
- **An Archil egress gateway (`HostedOptions.archilEgress`).** For a target whose
|
|
918
|
-
Archil only through a gateway, `<IPv4 gateway>:<mount lane>:<data lane>` (such as
|
|
919
|
-
|
|
917
|
+
- **An Archil egress gateway (`HostedOptions.archilEgress`; Daytona's `DAYTONA_ARCHIL_EGRESS`).** For a target whose
|
|
918
|
+
runners reach Archil only through a gateway, `<IPv4 gateway>:<mount lane>:<data lane>` (such as
|
|
919
|
+
`192.0.2.40:18100:42050`), an Archil egress relay the operator runs. The helper's mount then starts `computerd archil-relay` on the computer's loopback (127.0.0.1:3129) and
|
|
920
920
|
an nftables table of its own (`inet agentrun_archil`) that redirects root's TCP to 8100 (the mount endpoint) and 32050
|
|
921
921
|
(the file servers, at the raw addresses the mount endpoint returns) to the relay and resets every other TCP to those
|
|
922
922
|
ports. The relay sends each connection to the gateway's lane for its port with a PROXY v2 header naming the original
|
|
@@ -1259,7 +1259,9 @@ runs on the VM runtime, or on gVisor for a GPU computer (below). Its unit tests
|
|
|
1259
1259
|
stdio command runs the daemon only while its path is root's alone. Root with no capability would still own every one
|
|
1260
1260
|
of them. attach reads the user back from inside and refuses root.
|
|
1261
1261
|
- **The stream** is the adapter's stdio command through `sandbox.exec`: its stdin and stdout are the `DaemonClient`'s
|
|
1262
|
-
stream. Modal has no kill for an exec, so
|
|
1262
|
+
stream. Modal has no kill for an exec, so every exec starts under the shared pid wrapper (`PID_WRAPPER`,
|
|
1263
|
+
`src/hosted/scripts.ts`), and the host's `kill` runs a second exec that kills that pid and every process under it,
|
|
1264
|
+
while it has the start time the wrapper read, then ends the exec's stdin.
|
|
1263
1265
|
- **Lifetime is Modal's.** Every sandbox's `timeoutMs` is its lifetime, rounded up to whole seconds, so Modal ends it
|
|
1264
1266
|
then whatever runs in it. The longest is 24 hours, or less with the `maxLifetimeMs` option; `check` refuses a longer
|
|
1265
1267
|
one with `checkLifetime`, the rule every provider shares. `sweep` refuses a Modal provider.
|
|
@@ -1396,9 +1398,20 @@ the sandbox from its default snapshot; the provider never guesses a snapshot's n
|
|
|
1396
1398
|
`default` is reached by its id.) Create records the image it was asked for in the label `agentrun.computer.image`,
|
|
1397
1399
|
beside the deadline's in the provider's own namespace, and attach reports that as `image`.
|
|
1398
1400
|
|
|
1399
|
-
Daytona takes no mount of the run's folder: Archil's client hangs on its
|
|
1400
|
-
`statx` of the mountpoint), so
|
|
1401
|
-
`
|
|
1401
|
+
On Daytona's hosted cloud, a Daytona computer takes no mount of the run's folder: Archil's client hangs on its
|
|
1402
|
+
sandboxes (its FUSE session never answers a `statx` of the mountpoint), so a provider made without `archilEgress`
|
|
1403
|
+
declares `capabilities().mount` `[]`, and `check()` refuses an Archil mount up front, code `refused`, in the
|
|
1404
|
+
descriptor's `unmounted.archil` words, before anything is asked of Daytona.
|
|
1405
|
+
|
|
1406
|
+
A self-hosted Daytona target whose sandboxes reach Archil through an Archil egress relay does mount it (a run there
|
|
1407
|
+
completed in Mode 2 on 11-14). Give that relay as `archilEgress` (`DAYTONA_ARCHIL_EGRESS` in Settings,
|
|
1408
|
+
`COMPUTER_DAYTONA_ARCHIL_EGRESS` for conformance), `<IPv4 gateway>:<mount lane>:<data lane>`, checked at construction
|
|
1409
|
+
as the adapter checks it. The provider then declares `capabilities().mount` `["archil"]` (the descriptor's
|
|
1410
|
+
`mountsWith`, through `mountsOf`), `check()` takes an Archil mount, the sandbox is made with network for the mount's
|
|
1411
|
+
root steps (`networkBlockAll` false), and the helper's mount and revoke go through the relay. The computer starts from a
|
|
1412
|
+
snapshot of `box/Dockerfile` (`box/build-daytona.py` prints its name), with the daemon user `2510:2510`. A GPU
|
|
1413
|
+
computer still takes no mount: Daytona's GPU host gives no `/dev/fuse`. Set `archilEgress` only for such a target: on
|
|
1414
|
+
the hosted cloud the mount would hang until its bound.
|
|
1402
1415
|
|
|
1403
1416
|
### Lifetimes
|
|
1404
1417
|
|
|
@@ -1420,7 +1433,10 @@ does. The provider itself never stops one: `release` takes `delete` alone and re
|
|
|
1420
1433
|
Daytona runs its own toolbox daemon as the sandbox's first process, and a snapshot we do not build has no `computerd`.
|
|
1421
1434
|
So the provider pushes it in at create and starts it, and reaches it the same way. Every command is a session command
|
|
1422
1435
|
of its own (`runAsync`, `suppressInputEcho`), its argv one shell line, its output read from the command's log stream,
|
|
1423
|
-
its exit code from the session
|
|
1436
|
+
its exit code from the session once that stream ends (the toolbox ends it once the command's exit code is written,
|
|
1437
|
+
`apps/daemon/internal/util/log_reader.go`), so a command that runs for hours costs no call while it runs. These are
|
|
1438
|
+
`framedExec`'s pieces (`src/hosted/framed-exec.ts`). The session is deleted once the command ends, or when the
|
|
1439
|
+
provider ends it:
|
|
1424
1440
|
|
|
1425
1441
|
1. Upload the static binary through the toolbox's file upload, to `/tmp/agentrun-computerd-<random>`:
|
|
1426
1442
|
`/files/upload-v2`, or `/files/upload` when the toolbox answers 404 for it. An older toolbox, as a self-hosted
|
|
@@ -2015,13 +2031,14 @@ label and keeps the oldest by `created` (whole seconds; ties go to the lowest id
|
|
|
2015
2031
|
|
|
2016
2032
|
Agent37 has no SSH port on the internet: the instance's sshd answers on 22022 inside it, and the edge carries the SSH
|
|
2017
2033
|
stream as binary WebSocket frames. `exec` opens a WebSocket (Node's global one takes `headers`), wraps it as a Duplex
|
|
2018
|
-
for ssh2's `Client.connect({ sock })`, and runs argv
|
|
2019
|
-
|
|
2034
|
+
for ssh2's `Client.connect({ sock })`, and runs argv under the shared pid wrapper (`PID_WRAPPER`,
|
|
2035
|
+
`src/hosted/scripts.ts`), which puts the process's pid and start time first on stderr; the provider takes that line
|
|
2036
|
+
off. stdout and stderr are the channel's, piped; stdin
|
|
2020
2037
|
is open until `end()`, which the adapter calls at once for a command it gives no input. `wait()` answers at the channel's close with the exit-status, or -1 for an exit by
|
|
2021
2038
|
signal or none; its listeners go on inside ssh2's callback, since one read off the tunnel can hold the open, the exit
|
|
2022
2039
|
and the close together (seen live: a listener added after an `await` missed the exit). `kill()` runs a second command
|
|
2023
|
-
on the same connection that kills the pid
|
|
2024
|
-
|
|
2040
|
+
on the same connection, `pidKill`, that kills the pid and every process under it while it has that start time (a child
|
|
2041
|
+
that left the process group too), then closes the exec's channel, never a connection. An SSH signal request is not used: ssh2 sends one only
|
|
2025
2042
|
while stdin is open (`ssh2@1.17.0` `lib/Channel.js:237-246`), and it reaches one process, not its children.
|
|
2026
2043
|
|
|
2027
2044
|
Every exec on an instance is a channel on one SSH connection that the provider shares: the daemon's upload, its install,
|
|
@@ -2032,7 +2049,7 @@ opens at the first exec (the four tries below), and a connection that closed or
|
|
|
2032
2049
|
channel that fails to open (the connection died under it, or its sshd took no more sessions) is opened once more on a
|
|
2033
2050
|
fresh connection. One connection carries at most 10 channels at once, execs and kills alike, and the next opens a second:
|
|
2034
2051
|
OpenSSH's sshd takes 10 sessions on a connection (`MaxSessions`). A kill's channel goes on any connection with room, since
|
|
2035
|
-
the pid
|
|
2052
|
+
the pid is the instance's. With no channel left, a connection waits 2 s for the next exec, then ends: an open one
|
|
2036
2053
|
keeps the process alive (ssh2's keepalive timer and the WebSocket's socket), so a process done with its computers exits
|
|
2037
2054
|
at most that late. `delete` ends every connection to the instance at once, a retired one still carrying channels too.
|
|
2038
2055
|
|
|
@@ -2494,7 +2511,7 @@ A provider for another vendor passes the same suite as Docker's, with one comman
|
|
|
2494
2511
|
|
|
2495
2512
|
```sh
|
|
2496
2513
|
npm run conformance -w @parcha/agentrun-computer -- --provider docker # or modal, daytona: any registry id
|
|
2497
|
-
npm run conformance -w @parcha/agentrun-computer -- --provider ./my-provider.js [--image debian:bookworm-slim] [--only exec,files] [--fixture <path>] [--json]
|
|
2514
|
+
npm run conformance -w @parcha/agentrun-computer -- --provider ./my-provider.js [--image debian:bookworm-slim] [--only exec,files] [--fixture <path>] [--long] [--concurrency <n>] [--json]
|
|
2498
2515
|
```
|
|
2499
2516
|
|
|
2500
2517
|
```text
|
|
@@ -2513,16 +2530,27 @@ core PASS 55/55 · 10 optional cases skipped, not declared · full 10/13 · moun
|
|
|
2513
2530
|
```
|
|
2514
2531
|
|
|
2515
2532
|
A hosted vendor runs the exec pre-check first, with `--exec-stream --machine <id> [--quick]`: the module's
|
|
2516
|
-
`createHost(options)` and `host.exec` alone, on a machine made by hand, checked for a live, two-way
|
|
2533
|
+
`createHost(options)` and `host.exec` alone, on a machine made by hand, checked for a live, two-way stream that keeps text intact,
|
|
2517
2534
|
with no timeout (`src/conformance/exec-stream.ts`; [the contract](../../spec/computer/provider.md#a-hosted-vendors-exec)).
|
|
2518
|
-
|
|
2519
|
-
|
|
2535
|
+
`stdout-unread` writes 4 MiB to `cat` over 10 s with its stdout left unread, then reads it: a write may wait while
|
|
2536
|
+
nobody reads, but must go on once stdout is read, and every byte comes back in order. After the checks, one more exec
|
|
2537
|
+
prints what the machine offers the rest of the host, each with what it means: whether root's `unshare -n` works (else
|
|
2538
|
+
`unshare -Urn`, the gVisor fence, else no fence for network none, open and allow), whether root can open `/dev/fuse`
|
|
2539
|
+
(Archil), `uname -m` (`facts.arch`), the kernel (gVisor when dmesg says so) and the TCP listeners from
|
|
2540
|
+
`/proc/net/tcp{,6}` (for `facts.vendorAgentPorts`). These are facts, never a pass or a fail of exec. It exits 0 when
|
|
2541
|
+
every check passes and 1 when one fails, and `--json` prints `{ host, machine, checks: [{ id, status, words, ms }],
|
|
2542
|
+
pass, facts: [{ id, value, means }], factsProblem? }`.
|
|
2520
2543
|
|
|
2521
2544
|
An id is resolved through the provider registry, and only there; the usage lists every id it holds. A module path is
|
|
2522
2545
|
resolved from the directory npm was run in. It exits 0 when Core passes, 1 when it fails, 2 on a
|
|
2523
2546
|
usage error, and 3 on a partial run; `--json` prints the report object (`{ provider, providerVersion, kind,
|
|
2524
2547
|
daemonMode, image, daemons: [{ computer, role, version, os, arch, fence? }], only?, coreNotRun?, results: [{ id, level,
|
|
2525
|
-
group, status, reason?, undeclared? }], core, undeclared, cleanup, notes?, computerNotes? }`).
|
|
2548
|
+
group, status, reason?, undeclared? }], core, undeclared, cleanup, computers: { peak, cap? }, notes?, computerNotes? }`).
|
|
2549
|
+
`computers.peak` is the most computers the run had alive at once, each counted from its create's call until its release
|
|
2550
|
+
(the text report's `computers alive at once: <peak> at most` line). `--concurrency <n>` (`concurrency` in
|
|
2551
|
+
`runConformance`'s options, its `cap`) keeps it at `n` or under, for a vendor plan that keeps fewer: a create waits for a
|
|
2552
|
+
computer to be released, the run's computer is deleted while a case that doesn't use it needs room (and made again for
|
|
2553
|
+
the next case that does), and a case that needs more at once than `n` fails in words. A failure is listed under
|
|
2526
2554
|
its line with what the case found. A computer's `role` is `"shared"` for the run's computer, which the cases that need
|
|
2527
2555
|
none of their own share, else the id of the case that made it. `daemons` holds each computer's first `hello`, one entry
|
|
2528
2556
|
per computer in the order they answered (empty when none did), so computers of one run that differ are kept apart: a GPU
|
|
@@ -2581,7 +2609,8 @@ Core and Full follow the Kubernetes agent-sandbox conformance levels (KEP-539.2)
|
|
|
2581
2609
|
`files.*` and `tar.*` methods, the `process.*` methods, a computer with network `none` (`network:none`: a provider
|
|
2582
2610
|
that cannot make one fails Core, and the suite never asks for a wider network instead), `check`, `create`, `attach`
|
|
2583
2611
|
(with the spec it reads back: the network and image create asked for, and a non-root `user` as `uid:gid`), `list`,
|
|
2584
|
-
`network` read-back and `release
|
|
2612
|
+
`network` read-back and `release` (a deleted computer stays gone: after a refused connect, `attach` by id, a second
|
|
2613
|
+
connect and `list` find nothing, so a vendor that wakes a machine on the next request fails), `release(ref, "stop")` as declared (a provider whose `capabilities().release` holds
|
|
2585
2614
|
`"stop"` lists the computer stopped until it is deleted, or, when it also declares `stopDeletes`, leaves it neither
|
|
2586
2615
|
listed nor attachable; one that does not refuses stop as `unsupported`, in words, and the computer stays listed and
|
|
2587
2616
|
running), a change to a network the provider does not declare refused with the
|
|
@@ -2602,6 +2631,10 @@ Core and Full follow the Kubernetes agent-sandbox conformance levels (KEP-539.2)
|
|
|
2602
2631
|
path on a read-only mount is closed (BusyBox's `test -w` reads the mode bits alone, so the case reads the mount's
|
|
2603
2632
|
options too). It checks write access alone and changes nothing.
|
|
2604
2633
|
`mount.archil-isolated-durable` runs the same check on its Archil computer.
|
|
2634
|
+
- **The label file** (`isolation.label-file`, Core wherever files runs): a host whose vendor keeps no labels
|
|
2635
|
+
(`facts.labels: "machine"`) has the adapter write them to `/var/lib/agentrun/labels.json`, root's, 0600 in a 0700
|
|
2636
|
+
directory. The case reads that path with `files.read`, as the computer's user, and passes on `not_found` (no such
|
|
2637
|
+
file: a host that keeps labels at the vendor) or `denied`; it fails if the read succeeds.
|
|
2605
2638
|
- **Core by kind.** `coreGroups(kind, daemon)` is what a computer of its kind must declare (the table in
|
|
2606
2639
|
[The protocol extension](#the-protocol-extension-kind-daemon-modes-screen-input-apps-lifetime)): exec, files,
|
|
2607
2640
|
processes and network `none` wherever computerd runs, screen and keyboard and pointer on a desktop, screen and touch
|
|
@@ -2631,7 +2664,9 @@ Core and Full follow the Kubernetes agent-sandbox conformance levels (KEP-539.2)
|
|
|
2631
2664
|
moving apart), `lifetime.extend` (`extend`: made with 45 s and extended to 120 s, at 60 s it answers ping with a
|
|
2632
2665
|
process started earlier still running and `list()` shows the new deadline; three extends are refused with the
|
|
2633
2666
|
deadline unchanged: to an earlier deadline, to maxLifetimeMs + 1, and, 60 s after create, to maxLifetimeMs less 30 s,
|
|
2634
|
-
within the cap on its own but past create + maxLifetimeMs; a cap under 3 min skips it).
|
|
2667
|
+
within the cap on its own but past create + maxLifetimeMs; a cap under 3 min skips it), and `lifetime.idle`, a long
|
|
2668
|
+
case that runs only with `--long` (`long` from code; the live sweep gives it): a computer made with 10 min, left with
|
|
2669
|
+
no call and no connection for 6 min, past a vendor's idle timer, is still listed running and answers ping.
|
|
2635
2670
|
- **`screen.watch` is Core in the screen group**: through the provider's `watch()`, the first frame decodes (a PNG
|
|
2636
2671
|
whole; a JPEG walked to its end, as the suite has no JPEG decoder) to the size it says, of the screen `screen.shot`
|
|
2637
2672
|
reads; on a computer with `input.pointer`, a pointer move through `input()` is a new frame with the cursor where it
|
package/box/Dockerfile
CHANGED
|
@@ -19,70 +19,23 @@
|
|
|
19
19
|
#
|
|
20
20
|
# No sudo and no sudoers file: the image's user is root, so the provider's own exec (Daytona's toolbox, Modal's exec,
|
|
21
21
|
# E2B's commands as root) runs the helper as root, and the tool user has no way to root. The build fails if the base
|
|
22
|
-
# brings either. computerd is not part of the image: the provider uploads and installs it, root's alone, at create,
|
|
23
|
-
# the
|
|
22
|
+
# brings either. computerd is not part of the image: the provider uploads and installs it, root's alone, at create (or,
|
|
23
|
+
# on a machine that dials the server, agentrun-dial fetches it from the server, checked by sha256), and the helper's
|
|
24
|
+
# serve runs that one.
|
|
24
25
|
#
|
|
25
26
|
# /proc with hidepid=2 is not part of an image: the helper remounts /proc so before each mount, as root, and refuses the
|
|
26
27
|
# mount in a computer where that fails.
|
|
27
28
|
#
|
|
28
|
-
#
|
|
29
|
+
# Every step is install.sh's, so a vendor that builds images in its own account from a running machine runs the same
|
|
30
|
+
# build: this file only puts it and the helper in one folder, runs it as root, and removes the folder.
|
|
29
31
|
FROM python:3.12-slim@sha256:b18b261e1b4974b4f321451ad5251ded85abb22c2b8b262da527dda1d031ab30
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
RUN set -eu; \
|
|
36
|
-
arch="$(dpkg --print-architecture)"; \
|
|
37
|
-
case "$arch" in \
|
|
38
|
-
amd64) sum="$ARCHIL_SHA256_AMD64" ;; \
|
|
39
|
-
arm64) sum="$ARCHIL_SHA256_ARM64" ;; \
|
|
40
|
-
*) echo "no archil client for $arch" >&2; exit 1 ;; \
|
|
41
|
-
esac; \
|
|
42
|
-
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; \
|
|
43
|
-
apt-get update -qq; \
|
|
44
|
-
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends \
|
|
45
|
-
git curl ca-certificates nodejs npm ripgrep fuse3 nftables >/dev/null; \
|
|
46
|
-
curl -fsSL -o /tmp/archil.deb "https://s3.amazonaws.com/archil-client/pkg/archil_${ARCHIL_VERSION}_${arch}.deb"; \
|
|
47
|
-
echo "$sum /tmp/archil.deb" | sha256sum -c -; \
|
|
48
|
-
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends /tmp/archil.deb >/dev/null; \
|
|
49
|
-
rm -rf /var/lib/apt/lists/* /tmp/archil.deb; \
|
|
50
|
-
groupadd --gid 2510 agentrun-tool; \
|
|
51
|
-
useradd --uid 2510 --gid 2510 --no-create-home --home-dir /tmp --shell /bin/sh agentrun-tool; \
|
|
52
|
-
install -d -o root -g root -m 0755 /workspace
|
|
53
|
-
|
|
54
|
-
# The desktop: Xvfb and xfwm4, which the provider starts through computerd as the tool user on :0, and the apps an agent
|
|
55
|
-
# opens. Each program and each app's desktop file is checked here. It comes before the sudo guard below, so a package
|
|
56
|
-
# that brought sudo would be taken away and checked gone there (a check here would refuse E2B's build, whose builder adds
|
|
57
|
-
# sudo before these steps).
|
|
58
|
-
RUN set -eu; \
|
|
59
|
-
apt-get update -qq; \
|
|
60
|
-
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends \
|
|
61
|
-
xvfb xfwm4 x11-xserver-utils xfce4-terminal mousepad firefox-esr xdotool fonts-dejavu-core adwaita-icon-theme >/dev/null; \
|
|
62
|
-
rm -rf /var/lib/apt/lists/*; \
|
|
63
|
-
for x in Xvfb xfwm4 dbus-run-session xsetroot xfce4-terminal mousepad firefox-esr xdotool; do command -v "$x" >/dev/null || { echo "the image has no $x" >&2; exit 1; }; done; \
|
|
64
|
-
for app in org.xfce.mousepad xfce4-terminal firefox-esr; do [ -f "/usr/share/applications/$app.desktop" ] || { echo "the image has no desktop file $app.desktop" >&2; exit 1; }; done
|
|
65
|
-
|
|
66
|
-
COPY agentrun-archil /usr/local/sbin/agentrun-archil
|
|
67
|
-
|
|
68
|
-
# What the helper runs, where it runs it from: an image that lacks one fails here, not at a run's first mount. And no
|
|
69
|
-
# way to root for the tool user: no sudo, no sudoers. A provider's builder may add sudo to the base before these steps
|
|
70
|
-
# (E2B's does): it is taken away first, the package where it is installed and every sudoers file, then checked gone.
|
|
71
|
-
RUN set -eu; \
|
|
72
|
-
if dpkg -s sudo >/dev/null 2>&1; then SUDO_FORCE_REMOVE=yes DEBIAN_FRONTEND=noninteractive apt-get purge -y -qq sudo >/dev/null; fi; \
|
|
73
|
-
rm -rf /etc/sudoers /etc/sudoers.d; \
|
|
74
|
-
chown root:root /usr/local/sbin/agentrun-archil; \
|
|
75
|
-
chmod 0755 /usr/local/sbin/agentrun-archil; \
|
|
76
|
-
for x in /usr/bin/archil /usr/bin/awk /usr/bin/realpath /usr/bin/mount /usr/bin/chown /usr/bin/find /usr/bin/id /usr/bin/ls; do \
|
|
77
|
-
[ -x "$x" ] || { echo "the image has no $x" >&2; exit 1; }; \
|
|
78
|
-
done; \
|
|
79
|
-
! command -v sudo >/dev/null 2>&1 || { echo "the image has sudo" >&2; exit 1; }; \
|
|
80
|
-
[ ! -e /etc/sudoers ] && [ ! -e /etc/sudoers.d ] || { echo "the image has a sudoers file" >&2; exit 1; }; \
|
|
81
|
-
ids="$(id -u agentrun-tool):$(id -g agentrun-tool)"; \
|
|
82
|
-
[ "$ids" = "2510:2510" ] || { echo "agentrun-tool is $ids" >&2; exit 1; }; \
|
|
83
|
-
archil --version | head -1
|
|
33
|
+
COPY install.sh /tmp/agentrun-box/install.sh
|
|
34
|
+
COPY agentrun-archil /tmp/agentrun-box/agentrun-archil
|
|
35
|
+
RUN sh /tmp/agentrun-box/install.sh && rm -rf /tmp/agentrun-box
|
|
84
36
|
|
|
85
37
|
USER root
|
|
86
38
|
# A computer's first process is its provider's own (Daytona's runs this when a snapshot names no entrypoint; Modal's and
|
|
87
|
-
# E2B's are their own): never the base image's python.
|
|
88
|
-
|
|
39
|
+
# E2B's are their own): never the base image's python. A machine whose create set AGENTRUN_ATTACH_URL dials the server
|
|
40
|
+
# instead (install.sh's agentrun-dial).
|
|
41
|
+
CMD ["sh", "-c", "[ -z \"${AGENTRUN_ATTACH_URL-}\" ] || exec agentrun-dial; exec sleep infinity"]
|
package/box/README.md
CHANGED
|
@@ -5,8 +5,21 @@ client pinned by version and sha256, the root helper `agentrun-archil`, the tool
|
|
|
5
5
|
2510), FUSE and nftables, a desktop with nothing started (Xvfb, xfwm4 and the apps an agent opens), and no sudo. One
|
|
6
6
|
image serves a sandbox and a desktop. The Dockerfile's comment says what each part is for.
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
Every step of the build is `install.sh`, POSIX shell run as root on the Dockerfile's base (`python:3.12-slim`), with
|
|
9
|
+
`agentrun-archil` beside it. The Dockerfile only copies the two and runs it. A vendor that builds images in its own
|
|
10
|
+
account from a running machine (a snapshot, a blueprint, a template) boots that base, copies both files into one folder,
|
|
11
|
+
runs `sh install.sh` as root and snapshots the result. A second run on the same machine ends the same.
|
|
12
|
+
|
|
13
|
+
The image also serves a vendor that boots it with env but has no exec stream into it: the machine dials the server
|
|
14
|
+
(`spec/computer/attach.md`). `install.sh` writes `agentrun-dial` to `/usr/local/bin`, root's, 0755, and the
|
|
15
|
+
Dockerfile's `CMD` runs it when the provider's create set `AGENTRUN_ATTACH_URL`, and `sleep infinity` otherwise, so
|
|
16
|
+
one image serves both. It fetches the server's `computerd` with the machine's token (`AGENTRUN_DAEMON_URL`), checks it
|
|
17
|
+
against `AGENTRUN_DAEMON_SHA256` before anything runs, starts `computerd init $AGENTRUN_INIT_ARGS` in a clean
|
|
18
|
+
environment, and becomes `computerd attach` with `AGENTRUN_ATTACH_URL` and `AGENTRUN_ATTACH_TOKEN` alone in its
|
|
19
|
+
environment. A vendor whose own entrypoint must stay the machine's first process runs `agentrun-dial` from it.
|
|
20
|
+
|
|
21
|
+
Its tag is the recipe's hash: the first 12 hex of the sha256 of `Dockerfile`, `install.sh` and `agentrun-archil`, the
|
|
22
|
+
files it copies (`recipe.mjs`). A changed recipe is a new image, and the same recipe is the one built before.
|
|
10
23
|
|
|
11
24
|
Each release publishes it (`.github/workflows/release.yml`, the `box` job) as `ghcr.io/parcha-ai/agentrun-box:<recipe hash>`
|
|
12
25
|
and `:<release tag>`, for linux/amd64, and builds the public E2B template `agentrun-archil-<recipe hash>` from it (the
|
package/box/build-daytona.py
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Build the Archil image (this folder's Dockerfile) as a Daytona snapshot, with Daytona's Python SDK (`pip install
|
|
2
2
|
# daytona`) and its key in DAYTONA_API_KEY, and print the snapshot's name, which a Daytona computer's spec names as its
|
|
3
|
-
# image
|
|
3
|
+
# image: a Daytona computer with an Archil mount, on a self-hosted target with an Archil egress relay (archilEgress),
|
|
4
|
+
# starts from it (on Daytona's hosted cloud Archil's client hangs, so no computer there takes the mount). The name is
|
|
5
|
+
# the recipe's hash (the Dockerfile and the files it copies, install.sh among them), so a changed recipe is
|
|
4
6
|
# a new snapshot, and the same recipe is the one built before: Daytona then refuses the name, and the printed name is
|
|
5
7
|
# the one to use. Its size is 2 CPUs, 4 GB of memory and a 10 GB disk.
|
|
6
8
|
#
|
|
@@ -26,7 +28,7 @@ if args:
|
|
|
26
28
|
gpu = args[1]
|
|
27
29
|
|
|
28
30
|
here = os.path.dirname(os.path.abspath(__file__))
|
|
29
|
-
recipe = b"".join(open(os.path.join(here, name), "rb").read() for name in ("Dockerfile", "agentrun-archil"))
|
|
31
|
+
recipe = b"".join(open(os.path.join(here, name), "rb").read() for name in ("Dockerfile", "install.sh", "agentrun-archil"))
|
|
30
32
|
digest = hashlib.sha256(recipe).hexdigest()[:12]
|
|
31
33
|
name = f"agentrun-archil-gpu-{gpu.lower()}-{digest}" if gpu else f"agentrun-archil-{digest}"
|
|
32
34
|
print(f"build-daytona: snapshot {name}", file=sys.stderr)
|
package/box/build-e2b.mjs
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
//
|
|
8
8
|
// With no --image it builds this folder's Dockerfile. --image builds from the published box image instead
|
|
9
9
|
// (ghcr.io/parcha-ai/agentrun-box:<the recipe's hash>, release.yml's box job), whose tag must be this recipe's hash; on
|
|
10
|
-
// it
|
|
10
|
+
// it install.sh's checked step runs again, and the Dockerfile's USER and CMD are the template's (recipe.mjs onImage).
|
|
11
11
|
//
|
|
12
12
|
// --public makes the template public once it is built (E2B's v2 PATCH /v2/templates/{id}, public: true), so another
|
|
13
13
|
// team's sandbox starts from it, and prints the names E2B gives it. release.yml's box-e2b job runs both.
|
package/box/install.sh
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# The box image's build, as POSIX shell: every step of it, run as root on the base the Dockerfile starts from
|
|
3
|
+
# (python:3.12-slim, Debian). The Dockerfile copies this file and agentrun-archil into one folder and runs it, and that is
|
|
4
|
+
# all it does. A vendor that builds images in its own account (a snapshot, a blueprint, a template) does the same: it
|
|
5
|
+
# boots that base, puts both files in one folder there, runs `sh install.sh` as root, and snapshots the machine under a
|
|
6
|
+
# name that carries the recipe's hash (recipe.mjs). The Dockerfile's comment says what each part of the image is for.
|
|
7
|
+
#
|
|
8
|
+
# sh install.sh the whole build
|
|
9
|
+
# sh install.sh checked the last step alone: any sudo taken away, then every check. recipe.mjs's onImage runs it on
|
|
10
|
+
# the published image, after E2B's template builder has added sudo there.
|
|
11
|
+
#
|
|
12
|
+
# It reads the network only through apt (Debian's mirrors) and for Archil's package. Run twice on one machine it ends the
|
|
13
|
+
# same, for a vendor's snapshot flow may retry it: each step that makes something looks for it first.
|
|
14
|
+
set -eu
|
|
15
|
+
|
|
16
|
+
# The archil client the live checks ran. A sum that reads `unpinned` stops the build, saying so: pin both before any build.
|
|
17
|
+
ARCHIL_VERSION=0.10.1-1793222256
|
|
18
|
+
ARCHIL_SHA256_AMD64=f219e70287e8152f3f0c7222e1c3319f4665897235af7c33a8846e56a5a5786a
|
|
19
|
+
ARCHIL_SHA256_ARM64=10ed430e51c268af095dd9e6c7aa6cdbb951d2430d62a76458719db168f40c0e
|
|
20
|
+
# Where the provider runs the root helper from.
|
|
21
|
+
HELPER=/usr/local/sbin/agentrun-archil
|
|
22
|
+
# The entrypoint of a machine that dials the server (dial below).
|
|
23
|
+
DIAL=/usr/local/bin/agentrun-dial
|
|
24
|
+
|
|
25
|
+
here=$(dirname "$0")
|
|
26
|
+
|
|
27
|
+
# A coding agent's tools, FUSE, nftables and the archil client (checked by sha256), the tool user, and /workspace.
|
|
28
|
+
packages() {
|
|
29
|
+
arch="$(dpkg --print-architecture)"
|
|
30
|
+
case "$arch" in
|
|
31
|
+
amd64) sum="$ARCHIL_SHA256_AMD64" ;;
|
|
32
|
+
arm64) sum="$ARCHIL_SHA256_ARM64" ;;
|
|
33
|
+
*) echo "no archil client for $arch" >&2; exit 1 ;;
|
|
34
|
+
esac
|
|
35
|
+
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
|
+
apt-get update -qq
|
|
37
|
+
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends \
|
|
38
|
+
git curl ca-certificates nodejs npm ripgrep fuse3 nftables >/dev/null
|
|
39
|
+
if [ "$(dpkg-query -W -f '${Version}' archil 2>/dev/null)" != "$ARCHIL_VERSION" ]; then
|
|
40
|
+
curl -fsSL -o /tmp/archil.deb "https://s3.amazonaws.com/archil-client/pkg/archil_${ARCHIL_VERSION}_${arch}.deb"
|
|
41
|
+
echo "$sum /tmp/archil.deb" | sha256sum -c -
|
|
42
|
+
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends /tmp/archil.deb >/dev/null
|
|
43
|
+
fi
|
|
44
|
+
rm -rf /var/lib/apt/lists/* /tmp/archil.deb
|
|
45
|
+
getent group agentrun-tool >/dev/null || groupadd --gid 2510 agentrun-tool
|
|
46
|
+
id -u agentrun-tool >/dev/null 2>&1 || useradd --uid 2510 --gid 2510 --no-create-home --home-dir /tmp --shell /bin/sh agentrun-tool
|
|
47
|
+
install -d -o root -g root -m 0755 /workspace
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
# The desktop: Xvfb and xfwm4, which the provider starts through computerd as the tool user on :0, and the apps an agent
|
|
51
|
+
# opens. Each program and each app's desktop file is checked here. It comes before the last step, so a package that
|
|
52
|
+
# brought sudo is taken away and checked gone there (a check here would refuse E2B's build, whose builder adds sudo first).
|
|
53
|
+
desktop() {
|
|
54
|
+
apt-get update -qq
|
|
55
|
+
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends \
|
|
56
|
+
xvfb xfwm4 x11-xserver-utils xfce4-terminal mousepad firefox-esr xdotool fonts-dejavu-core adwaita-icon-theme >/dev/null
|
|
57
|
+
rm -rf /var/lib/apt/lists/*
|
|
58
|
+
for x in Xvfb xfwm4 dbus-run-session xsetroot xfce4-terminal mousepad firefox-esr xdotool; do command -v "$x" >/dev/null || { echo "the image has no $x" >&2; exit 1; }; done
|
|
59
|
+
for app in org.xfce.mousepad xfce4-terminal firefox-esr; do [ -f "/usr/share/applications/$app.desktop" ] || { echo "the image has no desktop file $app.desktop" >&2; exit 1; }; done
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
# The root helper, from beside this file.
|
|
63
|
+
helper() {
|
|
64
|
+
cp "$here/agentrun-archil" "$HELPER"
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
# agentrun-dial, the image's entrypoint when the provider's create set AGENTRUN_ATTACH_URL (the Dockerfile's CMD): for a
|
|
68
|
+
# vendor that boots the image with env but has no exec stream into it, so the machine dials the server
|
|
69
|
+
# (spec/computer/attach.md). The provider's exec path never runs it.
|
|
70
|
+
dial() {
|
|
71
|
+
cat >"$DIAL" <<'EOF'
|
|
72
|
+
#!/bin/sh
|
|
73
|
+
# agentrun-dial (written by the box image's install.sh): a machine that dials the server. From the env the provider's
|
|
74
|
+
# create gave it, it fetches the server's computerd with the machine's token, checks its sha256, installs it root's alone
|
|
75
|
+
# where the provider's exec install puts it, starts `computerd init` as that start does, in a clean environment without
|
|
76
|
+
# the token, and becomes `computerd attach` with the attach URL and the token alone in its environment. A daemon whose
|
|
77
|
+
# sha256 is not AGENTRUN_DAEMON_SHA256 is removed, and nothing runs. Exits 2 for env missing, 3 when the fetch failed,
|
|
78
|
+
# 4 for a sha256 mismatch, 5 when init never listened; else it is `computerd attach` and exits as it does.
|
|
79
|
+
set -euf
|
|
80
|
+
DAEMON=/opt/agentrun/computerd
|
|
81
|
+
HOME_DIR=/work
|
|
82
|
+
SOCKET_DIR=/run/agentrun
|
|
83
|
+
INIT_LOG=/run/agentrun-init.log
|
|
84
|
+
OWNER=0:0
|
|
85
|
+
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
|
86
|
+
for v in AGENTRUN_ATTACH_URL AGENTRUN_ATTACH_TOKEN AGENTRUN_DAEMON_URL AGENTRUN_DAEMON_SHA256 AGENTRUN_INIT_ARGS; do
|
|
87
|
+
eval "[ -n \"\${$v-}\" ]" || { echo "agentrun-dial: $v is not set; the provider's create sets it" >&2; exit 2; }
|
|
88
|
+
done
|
|
89
|
+
mkdir -p "${DAEMON%/*}" "$HOME_DIR" "$SOCKET_DIR"
|
|
90
|
+
chown "$OWNER" "${DAEMON%/*}" "$SOCKET_DIR"
|
|
91
|
+
chmod 0755 "${DAEMON%/*}"
|
|
92
|
+
# init's socket is root's alone: whoever can connect to it drives the machine.
|
|
93
|
+
chmod 0700 "$SOCKET_DIR"
|
|
94
|
+
rm -f "$DAEMON.part"
|
|
95
|
+
# The token goes to curl on its stdin, never on a command line, which every user may read in /proc.
|
|
96
|
+
printf 'Authorization: Bearer %s\n' "$AGENTRUN_ATTACH_TOKEN" |
|
|
97
|
+
curl -fsS --connect-timeout 10 --retry 10 --retry-connrefused --retry-max-time 300 -H @- -o "$DAEMON.part" "$AGENTRUN_DAEMON_URL" ||
|
|
98
|
+
{ echo "agentrun-dial: fetching the daemon from $AGENTRUN_DAEMON_URL failed" >&2; rm -f "$DAEMON.part"; exit 3; }
|
|
99
|
+
sum=$(sha256sum "$DAEMON.part" | cut -c1-64)
|
|
100
|
+
if [ "$sum" != "$AGENTRUN_DAEMON_SHA256" ]; then
|
|
101
|
+
rm -f "$DAEMON.part"
|
|
102
|
+
echo "agentrun-dial: the daemon from $AGENTRUN_DAEMON_URL reads sha256 $sum, not $AGENTRUN_DAEMON_SHA256, so nothing runs" >&2
|
|
103
|
+
exit 4
|
|
104
|
+
fi
|
|
105
|
+
chown "$OWNER" "$DAEMON.part"
|
|
106
|
+
chmod 0755 "$DAEMON.part"
|
|
107
|
+
mv -f "$DAEMON.part" "$DAEMON"
|
|
108
|
+
# init's arguments are words with no space and no pattern (set -f): split, never globbed.
|
|
109
|
+
env -i PATH="$PATH" HOME="$HOME_DIR" AGENTRUN_COMPUTERD_SOCKET="$SOCKET_DIR/computerd.sock" \
|
|
110
|
+
setsid sh -c 'cd "$HOME" && exec "$@"' sh "$DAEMON" init $AGENTRUN_INIT_ARGS >"$INIT_LOG" 2>&1 </dev/null &
|
|
111
|
+
i=0
|
|
112
|
+
until [ -S "$SOCKET_DIR/computerd.sock" ]; do
|
|
113
|
+
i=$((i + 1))
|
|
114
|
+
[ "$i" -le 300 ] || { echo "agentrun-dial: init did not listen at $SOCKET_DIR/computerd.sock within 30 s; its log:" >&2; cat "$INIT_LOG" >&2; exit 5; }
|
|
115
|
+
sleep 0.1
|
|
116
|
+
done
|
|
117
|
+
# attach's environment: the URL and token alone (it dials init at its default socket, SOCKET_DIR's).
|
|
118
|
+
for v in $(env | sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=.*/\1/p'); do
|
|
119
|
+
case "$v" in AGENTRUN_ATTACH_URL | AGENTRUN_ATTACH_TOKEN | DAEMON) ;; *) unset "$v" 2>/dev/null || : ;; esac
|
|
120
|
+
done
|
|
121
|
+
exec "$DAEMON" attach
|
|
122
|
+
EOF
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
# What the helper and agentrun-dial run, where they run it from: an image that lacks one fails here, not at a run's
|
|
126
|
+
# first mount. And no way to root for the tool user: no sudo, no sudoers. A provider's builder may add sudo to the base
|
|
127
|
+
# before these steps (E2B's does): it is taken away first, the package where it is installed and every sudoers file,
|
|
128
|
+
# then checked gone.
|
|
129
|
+
checked() {
|
|
130
|
+
if dpkg -s sudo >/dev/null 2>&1; then SUDO_FORCE_REMOVE=yes DEBIAN_FRONTEND=noninteractive apt-get purge -y -qq sudo >/dev/null; fi
|
|
131
|
+
rm -rf /etc/sudoers /etc/sudoers.d
|
|
132
|
+
chown root:root "$HELPER" "$DIAL"
|
|
133
|
+
chmod 0755 "$HELPER" "$DIAL"
|
|
134
|
+
for x in /usr/bin/archil /usr/bin/awk /usr/bin/realpath /usr/bin/mount /usr/bin/chown /usr/bin/find /usr/bin/id /usr/bin/ls /usr/bin/curl /usr/bin/setsid /usr/bin/sha256sum; do
|
|
135
|
+
[ -x "$x" ] || { echo "the image has no $x" >&2; exit 1; }
|
|
136
|
+
done
|
|
137
|
+
! command -v sudo >/dev/null 2>&1 || { echo "the image has sudo" >&2; exit 1; }
|
|
138
|
+
[ ! -e /etc/sudoers ] && [ ! -e /etc/sudoers.d ] || { echo "the image has a sudoers file" >&2; exit 1; }
|
|
139
|
+
ids="$(id -u agentrun-tool):$(id -g agentrun-tool)"
|
|
140
|
+
[ "$ids" = "2510:2510" ] || { echo "agentrun-tool is $ids" >&2; exit 1; }
|
|
141
|
+
archil --version | head -1
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
case "$*" in
|
|
145
|
+
"") packages; desktop; helper; dial; checked ;;
|
|
146
|
+
checked) checked ;;
|
|
147
|
+
*) echo "usage: sh install.sh [checked]" >&2; exit 2 ;;
|
|
148
|
+
esac
|
package/box/recipe.mjs
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
// The box image's recipe: the files it is made of (this folder's Dockerfile and what it copies
|
|
2
|
-
// first 12 hex of their sha256. Every build names what it makes by that hash, so a
|
|
3
|
-
// same recipe is the one built before: the E2B template agentrun-archil-<hash>
|
|
4
|
-
// of the same name (build-daytona.py hashes the same files),
|
|
5
|
-
// (release.yml's box job reads recipeHash())
|
|
1
|
+
// The box image's recipe: the files it is made of (this folder's Dockerfile and what it copies: install.sh, the build,
|
|
2
|
+
// and the helper) and their hash, the first 12 hex of their sha256. Every build names what it makes by that hash, so a
|
|
3
|
+
// changed recipe is a new image and the same recipe is the one built before: the E2B template agentrun-archil-<hash>
|
|
4
|
+
// (build-e2b.mjs), the Daytona snapshot of the same name (build-daytona.py hashes the same files), the published image
|
|
5
|
+
// ghcr.io/parcha-ai/agentrun-box:<hash> (release.yml's box job reads recipeHash()), and what a provider's prepareImage
|
|
6
|
+
// builds or registers in a vendor's account.
|
|
6
7
|
//
|
|
7
8
|
// And the E2B template's Dockerfile on that published image (build-e2b.mjs --image): E2B's builder provisions a base
|
|
8
|
-
// before a template's steps, sudo among what it adds (
|
|
9
|
-
//
|
|
9
|
+
// before a template's steps, sudo among what it adds (install.sh says so), so on the image install.sh's last step runs
|
|
10
|
+
// again, as root, and the Dockerfile's USER and CMD are the template's.
|
|
10
11
|
import { createHash } from "node:crypto";
|
|
11
12
|
import { readFileSync } from "node:fs";
|
|
12
13
|
import { dirname, join } from "node:path";
|
|
13
14
|
import { fileURLToPath } from "node:url";
|
|
14
15
|
|
|
15
16
|
/** Every file the image is made of: the Dockerfile and what it copies. */
|
|
16
|
-
export const RECIPE = ["Dockerfile", "agentrun-archil"];
|
|
17
|
+
export const RECIPE = ["Dockerfile", "install.sh", "agentrun-archil"];
|
|
17
18
|
|
|
18
19
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
19
20
|
|
|
@@ -37,7 +38,8 @@ export function instructionMatching(dockerfile, pattern) {
|
|
|
37
38
|
throw new Error(`the box Dockerfile has no instruction matching ${pattern}`);
|
|
38
39
|
}
|
|
39
40
|
|
|
40
|
-
/** The template's Dockerfile on the published image: the image,
|
|
41
|
+
/** The template's Dockerfile on the published image: the image, install.sh's checked step again, the Dockerfile's USER and CMD. */
|
|
41
42
|
export function onImage(image, dockerfile = readFileSync(join(here, "Dockerfile"), "utf8")) {
|
|
42
|
-
|
|
43
|
+
const checked = ["COPY install.sh /tmp/agentrun-box/install.sh", "RUN sh /tmp/agentrun-box/install.sh checked && rm -rf /tmp/agentrun-box"];
|
|
44
|
+
return [`FROM ${image}`, ...checked, ...[/^USER /, /^CMD /].map((pattern) => instructionMatching(dockerfile, pattern))].join("\n") + "\n";
|
|
43
45
|
}
|
package/dist/agent37.js
CHANGED
|
@@ -293,7 +293,8 @@ class Agent37Host {
|
|
|
293
293
|
* POST /v1/instances: the template, the type and region, the size when the spec asks one, the request's name as the
|
|
294
294
|
* instance's name, the labels as metadata, deny-all (or allow-all where the adapter asks egress: an Archil computer's root, or the
|
|
295
295
|
* egress proxy of a network open or a list), auto-sleep off and
|
|
296
|
-
* no public port. It answers once the instance runs (docs: instances/create, Defaults).
|
|
296
|
+
* no public port. It answers once the instance runs (docs: instances/create, Defaults). req.backstopAt is left:
|
|
297
|
+
* Agent37 has no delete or stop timer to set it on, so the janitor alone ends an instance.
|
|
297
298
|
*/
|
|
298
299
|
async create(req, ctx) {
|
|
299
300
|
const bytes = Buffer.byteLength(JSON.stringify(req.labels));
|
package/dist/attach.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { type Readable, Writable } from "node:stream";
|
|
2
|
-
import { type HelloResult } from "./protocol.js";
|
|
2
|
+
import { type ComputerKind, type ComputerOs, type HelloResult } from "./protocol.js";
|
|
3
3
|
import { type ComputerConnection, type ComputerProvider } from "./provider.js";
|
|
4
4
|
import { type Result } from "./result.js";
|
|
5
5
|
export declare const ATTACH_PATH = "/v2/computers/attach";
|
|
6
|
+
/** Where a hosted machine that dials fetches the server's computerd for its arch (?arch=amd64|arm64), with its token. */
|
|
7
|
+
export declare const DAEMON_PATH = "/v2/computers/daemon";
|
|
6
8
|
/** The WebSocket subprotocol a driver asks for: the protocol version it speaks. Serve answers with it or refuses. */
|
|
7
9
|
export declare const ATTACH_SUBPROTOCOL = "agentrun.computer.0.2";
|
|
8
10
|
/** Each side pings this often (WebSocket ping frames, not JSON-RPC), so a NAT keeps the path open. */
|
|
@@ -82,7 +84,48 @@ export interface PairedComputer {
|
|
|
82
84
|
/** What it paired as: its hello at pairing. A later hello of another kind or os is refused (ATTACH_CLOSE.mismatch). */
|
|
83
85
|
hello: HelloResult;
|
|
84
86
|
labels: Record<string, string>;
|
|
87
|
+
/** A hosted machine that dials with a minted token (mintedComputer), not a person's: its hello keeps its arch too. */
|
|
88
|
+
minted?: true;
|
|
85
89
|
}
|
|
90
|
+
/** What a hosted machine's token is minted for: the computer its hello must say it is, and when the token stops. */
|
|
91
|
+
export interface MachineMint {
|
|
92
|
+
kind: ComputerKind;
|
|
93
|
+
os: ComputerOs;
|
|
94
|
+
/** Go's name, as hello says it: amd64, arm64. */
|
|
95
|
+
arch: string;
|
|
96
|
+
/** The machine's backstopAt: past it the token is refused, whatever else holds. */
|
|
97
|
+
expiresAt: Date;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The tokens of hosted machines that dial (spec/computer/attach.md, Hosted machines that dial), as the server's store
|
|
101
|
+
* keeps them: HostedProvider mints one at each dial create and revokes it at the delete. A token is `art_` and 64 hex
|
|
102
|
+
* digits (32 random bytes); the store keeps only its sha256, bound to the machine and its mint, and never logs it. The
|
|
103
|
+
* server's attach upgrade and its daemon route take it while it is neither revoked nor past expiresAt, and hand its
|
|
104
|
+
* socket to the AttachHub as mintedComputer(machine, mint). machine is the computer's name, computer-<12 hex digits>,
|
|
105
|
+
* from its create's request id (computerNameFor): what the provider's connect and release are given.
|
|
106
|
+
*/
|
|
107
|
+
export interface MachineTokens {
|
|
108
|
+
/** A new token for the machine, replacing any it had. */
|
|
109
|
+
mint(machine: string, mint: MachineMint): Promise<string>;
|
|
110
|
+
/** The machine's token refused from now on; a machine with none is done. */
|
|
111
|
+
revoke(machine: string): Promise<void>;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* MachineTokens in one process's memory, as serve's store keeps them (the sha256 alone): for tests and a conformance
|
|
115
|
+
* kit. check is what the server's attach and daemon routes ask of a token.
|
|
116
|
+
*/
|
|
117
|
+
export declare class MemoryMachineTokens implements MachineTokens {
|
|
118
|
+
#private;
|
|
119
|
+
mint(machine: string, mint: MachineMint): Promise<string>;
|
|
120
|
+
revoke(machine: string): Promise<void>;
|
|
121
|
+
/** The machine and mint a token is good for at `at`: undefined for one unknown, revoked, or past its expiresAt. */
|
|
122
|
+
check(token: string, at?: Date): {
|
|
123
|
+
machine: string;
|
|
124
|
+
mint: MachineMint;
|
|
125
|
+
} | undefined;
|
|
126
|
+
}
|
|
127
|
+
/** A minted machine as the AttachHub takes its socket: under the machine's name, its hello held to the mint. */
|
|
128
|
+
export declare function mintedComputer(machine: string, { kind, os, arch }: Pick<MachineMint, "kind" | "os" | "arch">): PairedComputer;
|
|
86
129
|
/**
|
|
87
130
|
* Why a hello may not stand for a paired computer, or undefined. The protocol version must be the server's; the
|
|
88
131
|
* driver's own version may be any: a person's installed app updates on its own schedule, and the server cannot
|
|
@@ -110,6 +153,8 @@ export declare class AttachHub {
|
|
|
110
153
|
accept(paired: PairedComputer, socket: AttachSocket): Promise<Result<HelloResult>>;
|
|
111
154
|
/** Whether the computer is attached now. */
|
|
112
155
|
online(id: string): boolean;
|
|
156
|
+
/** When the computer's live connection said hello and went live; undefined while it is not attached. */
|
|
157
|
+
since(id: string): Date | undefined;
|
|
113
158
|
/** The hello of the computer's live connection: its driver's version and groups now, which an update may change. */
|
|
114
159
|
hello(id: string): HelloResult | undefined;
|
|
115
160
|
/**
|