@parcha/agentrun-computer 0.1.0-beta.39 → 0.1.0-beta.40

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 CHANGED
@@ -2494,7 +2494,7 @@ A provider for another vendor passes the same suite as Docker's, with one comman
2494
2494
 
2495
2495
  ```sh
2496
2496
  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]
2497
+ 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
2498
  ```
2499
2499
 
2500
2500
  ```text
@@ -2513,16 +2513,27 @@ core PASS 55/55 · 10 optional cases skipped, not declared · full 10/13 · moun
2513
2513
  ```
2514
2514
 
2515
2515
  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, byte-exact stream
2516
+ `createHost(options)` and `host.exec` alone, on a machine made by hand, checked for a live, two-way stream that keeps text intact,
2517
2517
  with no timeout (`src/conformance/exec-stream.ts`; [the contract](../../spec/computer/provider.md#a-hosted-vendors-exec)).
2518
- It exits 0 when every check passes and 1 when one fails, and `--json` prints `{ host, machine, checks: [{ id, status,
2519
- words, ms }], pass }`.
2518
+ `stdout-unread` writes 4 MiB to `cat` over 10 s with its stdout left unread, then reads it: a write may wait while
2519
+ nobody reads, but must go on once stdout is read, and every byte comes back in order. After the checks, one more exec
2520
+ prints what the machine offers the rest of the host, each with what it means: whether root's `unshare -n` works (else
2521
+ `unshare -Urn`, the gVisor fence, else no fence for network none, open and allow), whether root can open `/dev/fuse`
2522
+ (Archil), `uname -m` (`facts.arch`), the kernel (gVisor when dmesg says so) and the TCP listeners from
2523
+ `/proc/net/tcp{,6}` (for `facts.vendorAgentPorts`). These are facts, never a pass or a fail of exec. It exits 0 when
2524
+ every check passes and 1 when one fails, and `--json` prints `{ host, machine, checks: [{ id, status, words, ms }],
2525
+ pass, facts: [{ id, value, means }], factsProblem? }`.
2520
2526
 
2521
2527
  An id is resolved through the provider registry, and only there; the usage lists every id it holds. A module path is
2522
2528
  resolved from the directory npm was run in. It exits 0 when Core passes, 1 when it fails, 2 on a
2523
2529
  usage error, and 3 on a partial run; `--json` prints the report object (`{ provider, providerVersion, kind,
2524
2530
  daemonMode, image, daemons: [{ computer, role, version, os, arch, fence? }], only?, coreNotRun?, results: [{ id, level,
2525
- group, status, reason?, undeclared? }], core, undeclared, cleanup, notes?, computerNotes? }`). A failure is listed under
2531
+ group, status, reason?, undeclared? }], core, undeclared, cleanup, computers: { peak, cap? }, notes?, computerNotes? }`).
2532
+ `computers.peak` is the most computers the run had alive at once, each counted from its create's call until its release
2533
+ (the text report's `computers alive at once: <peak> at most` line). `--concurrency <n>` (`concurrency` in
2534
+ `runConformance`'s options, its `cap`) keeps it at `n` or under, for a vendor plan that keeps fewer: a create waits for a
2535
+ computer to be released, the run's computer is deleted while a case that doesn't use it needs room (and made again for
2536
+ the next case that does), and a case that needs more at once than `n` fails in words. A failure is listed under
2526
2537
  its line with what the case found. A computer's `role` is `"shared"` for the run's computer, which the cases that need
2527
2538
  none of their own share, else the id of the case that made it. `daemons` holds each computer's first `hello`, one entry
2528
2539
  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 +2592,8 @@ Core and Full follow the Kubernetes agent-sandbox conformance levels (KEP-539.2)
2581
2592
  `files.*` and `tar.*` methods, the `process.*` methods, a computer with network `none` (`network:none`: a provider
2582
2593
  that cannot make one fails Core, and the suite never asks for a wider network instead), `check`, `create`, `attach`
2583
2594
  (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`, `release(ref, "stop")` as declared (a provider whose `capabilities().release` holds
2595
+ `network` read-back and `release` (a deleted computer stays gone: after a refused connect, `attach` by id, a second
2596
+ 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
2597
  `"stop"` lists the computer stopped until it is deleted, or, when it also declares `stopDeletes`, leaves it neither
2586
2598
  listed nor attachable; one that does not refuses stop as `unsupported`, in words, and the computer stays listed and
2587
2599
  running), a change to a network the provider does not declare refused with the
@@ -2602,6 +2614,10 @@ Core and Full follow the Kubernetes agent-sandbox conformance levels (KEP-539.2)
2602
2614
  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
2615
  options too). It checks write access alone and changes nothing.
2604
2616
  `mount.archil-isolated-durable` runs the same check on its Archil computer.
2617
+ - **The label file** (`isolation.label-file`, Core wherever files runs): a host whose vendor keeps no labels
2618
+ (`facts.labels: "machine"`) has the adapter write them to `/var/lib/agentrun/labels.json`, root's, 0600 in a 0700
2619
+ directory. The case reads that path with `files.read`, as the computer's user, and passes on `not_found` (no such
2620
+ file: a host that keeps labels at the vendor) or `denied`; it fails if the read succeeds.
2605
2621
  - **Core by kind.** `coreGroups(kind, daemon)` is what a computer of its kind must declare (the table in
2606
2622
  [The protocol extension](#the-protocol-extension-kind-daemon-modes-screen-input-apps-lifetime)): exec, files,
2607
2623
  processes and network `none` wherever computerd runs, screen and keyboard and pointer on a desktop, screen and touch
@@ -2631,7 +2647,9 @@ Core and Full follow the Kubernetes agent-sandbox conformance levels (KEP-539.2)
2631
2647
  moving apart), `lifetime.extend` (`extend`: made with 45 s and extended to 120 s, at 60 s it answers ping with a
2632
2648
  process started earlier still running and `list()` shows the new deadline; three extends are refused with the
2633
2649
  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).
2650
+ within the cap on its own but past create + maxLifetimeMs; a cap under 3 min skips it), and `lifetime.idle`, a long
2651
+ case that runs only with `--long` (`long` from code; the live sweep gives it): a computer made with 10 min, left with
2652
+ no call and no connection for 6 min, past a vendor's idle timer, is still listed running and answers ping.
2635
2653
  - **`screen.watch` is Core in the screen group**: through the provider's `watch()`, the first frame decodes (a PNG
2636
2654
  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
2655
  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
@@ -25,62 +25,13 @@
25
25
  # /proc with hidepid=2 is not part of an image: the helper remounts /proc so before each mount, as root, and refuses the
26
26
  # mount in a computer where that fails.
27
27
  #
28
- # An archil package whose sha256 reads `unpinned` stops the build, saying so: pin both sums before any build.
28
+ # Every step is install.sh's, so a vendor that builds images in its own account from a running machine runs the same
29
+ # build: this file only puts it and the helper in one folder, runs it as root, and removes the folder.
29
30
  FROM python:3.12-slim@sha256:b18b261e1b4974b4f321451ad5251ded85abb22c2b8b262da527dda1d031ab30
30
31
 
31
- ARG ARCHIL_VERSION=0.10.1-1793222256
32
- ARG ARCHIL_SHA256_AMD64=f219e70287e8152f3f0c7222e1c3319f4665897235af7c33a8846e56a5a5786a
33
- ARG ARCHIL_SHA256_ARM64=10ed430e51c268af095dd9e6c7aa6cdbb951d2430d62a76458719db168f40c0e
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
32
+ COPY install.sh /tmp/agentrun-box/install.sh
33
+ COPY agentrun-archil /tmp/agentrun-box/agentrun-archil
34
+ RUN sh /tmp/agentrun-box/install.sh && rm -rf /tmp/agentrun-box
84
35
 
85
36
  USER root
86
37
  # A computer's first process is its provider's own (Daytona's runs this when a snapshot names no entrypoint; Modal's and
package/box/README.md CHANGED
@@ -5,8 +5,13 @@ 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
- Its tag is the recipe's hash: the first 12 hex of the sha256 of `Dockerfile` and `agentrun-archil`, the one file it
9
- copies (`recipe.mjs`). A changed recipe is a new image, and the same recipe is the one built before.
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
+ Its tag is the recipe's hash: the first 12 hex of the sha256 of `Dockerfile`, `install.sh` and `agentrun-archil`, the
14
+ files it copies (`recipe.mjs`). A changed recipe is a new image, and the same recipe is the one built before.
10
15
 
11
16
  Each release publishes it (`.github/workflows/release.yml`, the `box` job) as `ghcr.io/parcha-ai/agentrun-box:<recipe hash>`
12
17
  and `:<release tag>`, for linux/amd64, and builds the public E2B template `agentrun-archil-<recipe hash>` from it (the
@@ -1,6 +1,6 @@
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 (no Daytona computer takes an Archil mount: Archil's client hangs on its sandboxes). The name is the recipe's hash (the Dockerfile and the files it copies), so a changed recipe is
3
+ # image (no Daytona computer takes an Archil mount: Archil's client hangs on its sandboxes). The name is the recipe's hash (the Dockerfile and the files it copies, install.sh among them), so a changed recipe is
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
  #
@@ -26,7 +26,7 @@ if args:
26
26
  gpu = args[1]
27
27
 
28
28
  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"))
29
+ recipe = b"".join(open(os.path.join(here, name), "rb").read() for name in ("Dockerfile", "install.sh", "agentrun-archil"))
30
30
  digest = hashlib.sha256(recipe).hexdigest()[:12]
31
31
  name = f"agentrun-archil-gpu-{gpu.lower()}-{digest}" if gpu else f"agentrun-archil-{digest}"
32
32
  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 the Dockerfile's sudo guard runs again, and its USER and CMD are the template's (recipe.mjs onImage).
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,87 @@
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
+
23
+ here=$(dirname "$0")
24
+
25
+ # A coding agent's tools, FUSE, nftables and the archil client (checked by sha256), the tool user, and /workspace.
26
+ packages() {
27
+ arch="$(dpkg --print-architecture)"
28
+ case "$arch" in
29
+ amd64) sum="$ARCHIL_SHA256_AMD64" ;;
30
+ arm64) sum="$ARCHIL_SHA256_ARM64" ;;
31
+ *) echo "no archil client for $arch" >&2; exit 1 ;;
32
+ esac
33
+ 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
34
+ apt-get update -qq
35
+ DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends \
36
+ git curl ca-certificates nodejs npm ripgrep fuse3 nftables >/dev/null
37
+ if [ "$(dpkg-query -W -f '${Version}' archil 2>/dev/null)" != "$ARCHIL_VERSION" ]; then
38
+ curl -fsSL -o /tmp/archil.deb "https://s3.amazonaws.com/archil-client/pkg/archil_${ARCHIL_VERSION}_${arch}.deb"
39
+ echo "$sum /tmp/archil.deb" | sha256sum -c -
40
+ DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends /tmp/archil.deb >/dev/null
41
+ fi
42
+ rm -rf /var/lib/apt/lists/* /tmp/archil.deb
43
+ getent group agentrun-tool >/dev/null || groupadd --gid 2510 agentrun-tool
44
+ id -u agentrun-tool >/dev/null 2>&1 || useradd --uid 2510 --gid 2510 --no-create-home --home-dir /tmp --shell /bin/sh agentrun-tool
45
+ install -d -o root -g root -m 0755 /workspace
46
+ }
47
+
48
+ # The desktop: Xvfb and xfwm4, which the provider starts through computerd as the tool user on :0, and the apps an agent
49
+ # opens. Each program and each app's desktop file is checked here. It comes before the last step, so a package that
50
+ # brought sudo is taken away and checked gone there (a check here would refuse E2B's build, whose builder adds sudo first).
51
+ desktop() {
52
+ apt-get update -qq
53
+ DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends \
54
+ xvfb xfwm4 x11-xserver-utils xfce4-terminal mousepad firefox-esr xdotool fonts-dejavu-core adwaita-icon-theme >/dev/null
55
+ rm -rf /var/lib/apt/lists/*
56
+ 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
57
+ 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
58
+ }
59
+
60
+ # The root helper, from beside this file.
61
+ helper() {
62
+ cp "$here/agentrun-archil" "$HELPER"
63
+ }
64
+
65
+ # 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 way
66
+ # to root for the tool user: no sudo, no sudoers. A provider's builder may add sudo to the base before these steps
67
+ # (E2B's does): it is taken away first, the package where it is installed and every sudoers file, then checked gone.
68
+ checked() {
69
+ 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
70
+ rm -rf /etc/sudoers /etc/sudoers.d
71
+ chown root:root "$HELPER"
72
+ chmod 0755 "$HELPER"
73
+ 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
74
+ [ -x "$x" ] || { echo "the image has no $x" >&2; exit 1; }
75
+ done
76
+ ! command -v sudo >/dev/null 2>&1 || { echo "the image has sudo" >&2; exit 1; }
77
+ [ ! -e /etc/sudoers ] && [ ! -e /etc/sudoers.d ] || { echo "the image has a sudoers file" >&2; exit 1; }
78
+ ids="$(id -u agentrun-tool):$(id -g agentrun-tool)"
79
+ [ "$ids" = "2510:2510" ] || { echo "agentrun-tool is $ids" >&2; exit 1; }
80
+ archil --version | head -1
81
+ }
82
+
83
+ case "$*" in
84
+ "") packages; desktop; helper; checked ;;
85
+ checked) checked ;;
86
+ *) echo "usage: sh install.sh [checked]" >&2; exit 2 ;;
87
+ 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) and their hash, the
2
- // first 12 hex of their sha256. Every build names what it makes by that hash, so a changed recipe is a new image and the
3
- // same recipe is the one built before: the E2B template agentrun-archil-<hash> (build-e2b.mjs), the Daytona snapshot
4
- // of the same name (build-daytona.py hashes the same files), and the published image ghcr.io/parcha-ai/agentrun-box:<hash>
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 (the Dockerfile says so), so on the image the Dockerfile's sudo
9
- // guard runs again, as root, and its USER and CMD are the template's.
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, the Dockerfile's sudo guard again, its USER and CMD. */
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
- return [`FROM ${image}`, ...[/^RUN [^]*dpkg -s sudo/, /^USER /, /^CMD /].map((pattern) => instructionMatching(dockerfile, pattern))].join("\n") + "\n";
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));
Binary file
Binary file
@@ -1,4 +1,4 @@
1
1
  {
2
- "version": "0.1.0-beta.39",
3
- "source": "sha256:6f2da993375dbd1b37c02475505d8cdf406b97a4f3b5924b0147262e01da1d0c"
2
+ "version": "0.1.0-beta.40",
3
+ "source": "sha256:6514fb8f5147c8a35230596771da93b7678f70ac83bb202ac37171921896fb31"
4
4
  }
@@ -1,8 +1,10 @@
1
1
  // A program the computer's user runs reaches none of the vendor's own agent, whose ports each provider declares
2
2
  // (capabilities().vendorAgentPorts), and no outside address, sees its own loopback alone, and finds nothing listening in
3
- // its own network but computerd: computerd init --own-network at work. And it can write nothing root runs.
3
+ // its own network but computerd: computerd init --own-network at work. And it can write nothing root runs, nor read the
4
+ // labels a provider keeps in the machine.
4
5
  import { DAEMON_IN_COMPUTER, SOCKET_DIR } from "../../drift.js";
5
6
  import { EGRESS_PROXY_SOCKET } from "../../hosted/network.js";
7
+ import { LABEL_FILE } from "../../hosted/scripts.js";
6
8
  import { ARCHIL_HELPER, ARCHIL_SYNC_SOCKET } from "../../mount-archil.js";
7
9
  /**
8
10
  * The unix sockets a program of the computer's user may connect to: the computer's own, computerd's, the Archil sync
@@ -176,4 +178,18 @@ export const isolationCases = [
176
178
  await assertRootRunsClosed(t);
177
179
  },
178
180
  },
181
+ {
182
+ // The label file of a host that keeps no labels is root's alone: absent or unreadable passes, readable fails.
183
+ id: "isolation.label-file",
184
+ level: "core",
185
+ group: "isolation",
186
+ needs: ["files"],
187
+ async run(t) {
188
+ const read = await t.client.call("files.read", { path: LABEL_FILE });
189
+ if (read.ok)
190
+ return t.assert(false, `the computer's user reads ${LABEL_FILE}, the labels the provider keeps in the machine`);
191
+ t.observe(`${LABEL_FILE}, as the computer's user: ${read.error.code}`);
192
+ t.refused(read, `files.read of ${LABEL_FILE} as the computer's user`, ["not_found", "denied"]);
193
+ },
194
+ },
179
195
  ];
@@ -1,4 +1,8 @@
1
1
  import { CASE_LABEL } from "./util.js";
2
+ /** How long lifetime.idle leaves its computer quiet: past the shortest vendor idle timer known (Alibaba's 5 min). */
3
+ const IDLE_MS = 6 * 60_000;
4
+ /** Its computer's lifetime: the quiet, and four minutes to make it, connect and read it. */
5
+ const IDLE_LIFETIME_MS = IDLE_MS + 4 * 60_000;
2
6
  /** A deadline read back may be a second off the one extend returned: a label or a vendor timer can round. */
3
7
  const SLACK_MS = 1000;
4
8
  /** How far short of the cap the last extend asks, at least 60 s after create: it lands at least 30 s past create + cap. */
@@ -61,4 +65,30 @@ export const lifetimeCases = [
61
65
  await refused(underCap, `extend to ${underCap / 1000} s, past create + maxLifetimeMs (${maxLifetimeMs} ms)`);
62
66
  },
63
67
  },
68
+ {
69
+ id: "lifetime.idle",
70
+ level: "full",
71
+ group: "lifetime",
72
+ needs: [],
73
+ computer: "none",
74
+ timeoutMs: IDLE_LIFETIME_MS + 60_000,
75
+ async run(t) {
76
+ const minutes = IDLE_MS / 60_000;
77
+ t.long(`it leaves a computer quiet ${minutes} min`);
78
+ const { maxLifetimeMs } = t.provider.capabilities();
79
+ if (!(maxLifetimeMs >= IDLE_LIFETIME_MS))
80
+ return t.skip(`lifetime.idle needs a maxLifetimeMs of ${IDLE_LIFETIME_MS / 60_000} min or more, not ${maxLifetimeMs} ms`);
81
+ const labels = { ...t.runLabels, [CASE_LABEL]: "idle" };
82
+ const ref = await t.create({ lifetimeMs: IDLE_LIFETIME_MS, labels });
83
+ const first = await t.connect(ref);
84
+ t.deepEqual(t.ok(await first.client.call("ping", {}), "ping"), {}, "ping after create");
85
+ await first.close();
86
+ // No call and no connection: a vendor's idle timer (Alibaba's 5 min, Azure's, Cloudflare's inactivity) would end it.
87
+ await t.clock.sleep(IDLE_MS);
88
+ const quiet = `after ${minutes} min with no call, well inside its lifetime`;
89
+ t.deepEqual(t.ok(await t.provider.list(labels), "list").map((info) => [info.ref.name, info.state]), [[ref.name, "running"]], `${quiet}: still listed, running (a vendor's idle timer ends a quiet computer under the run: turn it off, or keep the computer busy)`);
90
+ const back = await t.connect(ref);
91
+ t.deepEqual(t.ok(await back.client.call("ping", {}), "ping"), {}, `${quiet}: its daemon answers ping`);
92
+ },
93
+ },
64
94
  ];
@@ -2,8 +2,10 @@
2
2
  // what they say, the network reads back as asked, a change to a network the provider does not declare is refused
3
3
  // (Core) and one it does declare is refused or applied truthfully (Full), a computer does not run past its deadline,
4
4
  // the janitor ends only the expired, stopped or running, and a takeover releases the run's lower epochs by label (Full).
5
- // A create retried with its request id answers the computer the first made, and after release is refused (Full).
5
+ // A create retried with its request id answers the computer the first made, and after release is refused (Full). A
6
+ // deleted computer stays gone: no call to it brings it back. prepareImage called twice answers one image and makes it once.
6
7
  import { randomBytes } from "node:crypto";
8
+ import { BACKSTOP_MARGIN_MS } from "../../host.js";
7
9
  import { releaseOlder, sweep } from "../../janitor.js";
8
10
  import { EPOCH_LABEL, OWNER_LABEL, RUN_LABEL, runLabels } from "../../labels.js";
9
11
  import { computerNameFor, runLifetimeMs } from "../../provider.js";
@@ -51,6 +53,8 @@ async function refusedCreate(t, spec, what) {
51
53
  /** The deadline case's lifetime, and how much of it must be left once create returns: to connect and start a process. */
52
54
  const DEADLINE_LIFETIME_MS = 45_000;
53
55
  const DEADLINE_LEFT_MS = 15_000;
56
+ /** How far a backstop host's vendor timer may read from the request's backstopAt: a timer kept in whole minutes rounds. */
57
+ const BACKSTOP_SKEW_MS = 60_000;
54
58
  const seconds = (ms) => Math.round(ms / 100) / 10;
55
59
  /**
56
60
  * A computer for the deadline case, the lifetime it was made with, and when create returned, on the run's clock. A
@@ -164,6 +168,11 @@ export const providerCases = [
164
168
  t.ok(await t.provider.release(ref, "delete"), "a second delete of the same computer");
165
169
  t.deepEqual(await names(t, labels), [], "listed after delete");
166
170
  t.refused(await t.provider.connect(ref), "connect to a deleted computer", ["gone", "not_found"]);
171
+ // A vendor that wakes a machine on the next call (a session resumed on request, a cold start) brings a deleted
172
+ // computer back: after the refused connect it stays gone, to attach, a second connect, and list.
173
+ t.refused(await t.provider.attach({ id: ref.id }), "attach to the deleted computer, after a connect to it", ["not_found"]);
174
+ t.refused(await t.provider.connect(ref), "a second connect to the deleted computer", ["gone", "not_found"]);
175
+ t.deepEqual(await names(t, labels), [], "listed after the calls to the deleted computer: nothing came back");
167
176
  }),
168
177
  provider("create-retried", async (t) => {
169
178
  // A retry of one request, at once and after it is up, answers the computer the first made: never a second.
@@ -235,6 +244,29 @@ export const providerCases = [
235
244
  t.assert(deadline >= before + lifetimeMs - 1000 && deadline <= after + lifetimeMs + 1000, `its deadline, ${String(info.deadline)}, is lifetimeMs after create`);
236
245
  t.deepEqual(await names(t, { ...labels, role: "other" }), [], "list by a label no computer has");
237
246
  }),
247
+ // prepareImage twice in one run (spec/computer/provider.md, "prepareImage"): both answer the same image, and the second
248
+ // finds the one the first made by its name, so it is told no onWait. A server calls it before its first create, so one
249
+ // that builds every time costs every server minutes. A provider with none passes, observed. Core: the first call costs
250
+ // at most a build per account and recipe, which the account's first create pays anyway.
251
+ provider("prepare-image", async (t) => {
252
+ // A provider on the machine-host adapter: its host's descriptor, the whole one in-tree hosts hand it.
253
+ const descriptor = t.provider.host?.descriptor;
254
+ const prepare = t.provider.prepareImage?.bind(t.provider);
255
+ if (prepare === undefined) {
256
+ t.assert(descriptor?.prepareImage !== true, `${descriptor?.label}'s descriptor declares prepareImage, but its provider has no prepareImage(): give the provider class one`);
257
+ return t.observe("the provider has no prepareImage(): its computers start from an image a spec names");
258
+ }
259
+ const call = async (which) => {
260
+ const told = [];
261
+ const image = t.ok(await prepare({ signal: t.signal, onWait: (making, tag) => told.push(`${making} ${tag}`) }), `the ${which} prepareImage`);
262
+ return { image, told: told.length === 0 ? "" : `onWait(${told.join("; ")})` };
263
+ };
264
+ const first = await call("first");
265
+ t.observe(first.told === "" ? `the first prepareImage found ${first.image} and was told no onWait` : `the first prepareImage was told ${first.told} and answered ${first.image}`);
266
+ const second = await call("second");
267
+ t.equal(second.image, first.image, "the second prepareImage's image");
268
+ t.assert(second.told === "", `the second prepareImage was told ${second.told}: it must find the image the first made by its name (one that carries the box recipe's hash) and answer it with no build and no pull`);
269
+ }, { timeoutMs: 20 * 60_000 }),
238
270
  // Stop is declared or refused: a provider that declares it lists the computer stopped; one that does not refuses it
239
271
  // in words and leaves the computer running, never stopped or deleted behind the caller's back.
240
272
  provider("stop", async (t) => {
@@ -455,4 +487,18 @@ export const providerCases = [
455
487
  t.ok(await t.provider.release(ref, "delete"), `release ${ref.name}`);
456
488
  t.deepEqual(await names(t, labels), [], "the case's computers after it");
457
489
  }, { level: "full", timeoutMs: 300_000 }),
490
+ // A host's backstop claim (facts.backstop, src/host.ts), read back from its vendor on the run's shared computer: get's
491
+ // endsAt is the request's backstopAt, which create made from the clock reading its deadline label was made from. A
492
+ // provider not on the machine-host adapter, or a host that claims none, has nothing to read back.
493
+ provider("backstop", async (t) => {
494
+ const host = t.provider.host;
495
+ if (host?.facts?.backstop !== true)
496
+ return t.observe(host === undefined ? "not on the machine-host adapter: no backstop to read back" : "its host claims no backstop (facts.backstop): nothing to read back");
497
+ const listed = t.ok(await t.provider.list(t.runLabels), "list");
498
+ const deadline = t.present(listed.find((info) => info.ref.name === t.ref.name)?.deadline, `${t.ref.name}'s deadline, listed`);
499
+ const backstopAt = deadline.getTime() - runLifetimeMs(t.spec()) + t.provider.capabilities().maxLifetimeMs + BACKSTOP_MARGIN_MS;
500
+ const endsAt = (await host.get(t.ref.id, { timeoutMs: t.patience, signal: t.signal }))?.endsAt;
501
+ const reads = endsAt instanceof Date ? endsAt.toISOString() : "none";
502
+ t.assert(endsAt instanceof Date && Math.abs(endsAt.getTime() - backstopAt) <= BACKSTOP_SKEW_MS, `${host.descriptor.label} claims backstop (facts.backstop), but its vendor timer reads ${reads}, not ${new Date(backstopAt).toISOString()}, the request's backstopAt (within ${BACKSTOP_SKEW_MS / 1000} s): set it from req.backstopAt at create, and read it back as Machine.endsAt`);
503
+ }, { computer: "shared" }),
458
504
  ];
@@ -18,7 +18,7 @@ import { formatReport } from "./report.js";
18
18
  import { runConformance } from "./runner.js";
19
19
  /** Writes text and settles once the stream has taken it, so an exit after it cuts nothing off. */
20
20
  const write = (stream, text) => new Promise((resolve) => void stream.write(text, () => resolve()));
21
- const USAGE = `usage: npm run conformance -w @parcha/agentrun-computer -- --provider ${providerIds.join("|")}|<module.js> [--image <image>] [--only <group|case>,... | --kind <kind>] [--fixture <path>] [--gpu <type>[:<count>]] [--json]
21
+ const USAGE = `usage: npm run conformance -w @parcha/agentrun-computer -- --provider ${providerIds.join("|")}|<module.js> [--image <image>] [--only <group|case>,... | --kind <kind>] [--fixture <path>] [--gpu <type>[:<count>]] [--long] [--concurrency <n>] [--json]
22
22
  --provider a computer in the registry (${providerIds.join(", ")}), or a module path: a provider file that exports
23
23
  create(options), or a conformance module that exports createProvider() (and, for the drift case,
24
24
  createDriftedProvider(); for the mount cases, mountFor(kind), a fresh run folder for that mount kind)
@@ -32,11 +32,18 @@ const USAGE = `usage: npm run conformance -w @parcha/agentrun-computer -- --prov
32
32
  desktop, the fixture APK for an Android phone
33
33
  --gpu the GPU the gpu case's one computer asks for, a type the provider declares and a count (default 1), such
34
34
  as T4 or H100:2; it bills by the second, so without it the gpu case skips
35
+ --long run the long cases too, which wait minutes on a vendor's timer: lifetime.idle leaves a computer quiet
36
+ 6 min and reads it running; the live sweep gives it, and without it they skip
37
+ --concurrency
38
+ the most computers alive at once, for a plan that keeps fewer (default no cap; the report says the
39
+ run's peak). The run's computer makes way for a case's own; a case that needs more fails
35
40
  --json print the report as JSON
36
41
  --exec-stream --machine <id> [--quick]
37
42
  the exec pre-check, alone: the module's createHost() and host.exec, nothing else, on a machine you made
38
- by hand. Bytes 0-255 both ways, 8 MiB by sha256, output and stdin while the process runs, stderr apart,
39
- the exit code, kill, and a silent process of ${DEFAULT_LONG_MS / 1000} s (--quick: ${QUICK_LONG_MS / 1000} s) that is not cut off
43
+ by hand. Text of every kind both ways, 8 MiB by sha256, output and stdin while the process runs, stdin while
44
+ stdout is left unread, stderr apart, the exit code, kill, and a silent process of ${DEFAULT_LONG_MS / 1000} s (--quick: ${QUICK_LONG_MS / 1000} s)
45
+ that is not cut off; then what the machine offers: root's network namespace, /dev/fuse, the arch, the
46
+ kernel (gVisor) and the TCP listeners, each with what it means for your host
40
47
  exit: 0 Core passes, 1 it fails, 2 usage error, 3 partial (--only) and every case that ran passed; with --kind,
41
48
  0 the provider passes the kind, 1 it does not; with --exec-stream, 0 every check passes, 1 one fails`;
42
49
  const PROVIDER_METHODS = ["capabilities", "check", "create", "attach", "list", "network", "connect", "release"];
@@ -81,6 +88,14 @@ function parse(argv, cases) {
81
88
  args.fixture = value();
82
89
  else if (flag === "--gpu")
83
90
  args.gpu = gpuOf(value());
91
+ else if (flag === "--long")
92
+ args.long = true;
93
+ else if (flag === "--concurrency") {
94
+ const given = value();
95
+ if (!/^[1-9][0-9]*$/.test(given) || !Number.isSafeInteger(Number(given)))
96
+ throw new Usage(`--concurrency: ${JSON.stringify(given)} is not a whole number of computers, 1 or more`);
97
+ args.concurrency = Number(given);
98
+ }
84
99
  else if (flag === "--exec-stream")
85
100
  execStream = true;
86
101
  else if (flag === "--machine")
@@ -101,7 +116,7 @@ function parse(argv, cases) {
101
116
  if (execStream) {
102
117
  if (machine === undefined)
103
118
  throw new Usage("--exec-stream needs --machine <id>, a machine you made by hand");
104
- const others = ["image", "only", "kind", "fixture", "gpu"].filter((name) => args[name] !== undefined);
119
+ const others = ["image", "only", "kind", "fixture", "gpu", "long", "concurrency"].filter((name) => args[name] !== undefined);
105
120
  if (others.length > 0)
106
121
  throw new Usage(`--exec-stream runs alone: drop ${others.map((name) => `--${name}`).join(", ")}`);
107
122
  return { provider: args.provider, execStream: { machine, quick }, json: args.json, help: false };
@@ -123,6 +138,8 @@ function parse(argv, cases) {
123
138
  ...(args.kind ? { kind: args.kind } : {}),
124
139
  ...(args.fixture ? { fixture: args.fixture } : {}),
125
140
  ...(args.gpu ? { gpu: args.gpu } : {}),
141
+ ...(args.long ? { long: args.long } : {}),
142
+ ...(args.concurrency ? { concurrency: args.concurrency } : {}),
126
143
  json: args.json,
127
144
  help: false,
128
145
  };
@@ -327,6 +344,8 @@ export async function main(argv, io = {}) {
327
344
  ...(args.kind ? { kind: args.kind } : {}),
328
345
  ...(args.fixture ? { fixture: resolve(cwd, args.fixture) } : {}),
329
346
  ...(args.gpu ? { gpu: args.gpu } : {}),
347
+ ...(args.long ? { long: true } : {}),
348
+ ...(args.concurrency ? { concurrency: args.concurrency } : {}),
330
349
  ...(signal ? { signal } : {}),
331
350
  ...(target.drifted ? { drifted: target.drifted } : {}),
332
351
  ...(target.declared ? { declared: target.declared } : {}),