@parcha/agentrun-computer 0.1.0-beta.40 → 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 +31 -14
- package/box/Dockerfile +6 -4
- package/box/README.md +8 -0
- package/box/build-daytona.py +3 -1
- package/box/install.sh +68 -7
- 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/provider.js +42 -26
- package/dist/conformance/cli.js +4 -1
- package/dist/conformance/daytona.d.ts +25 -0
- package/dist/conformance/daytona.js +26 -1
- package/dist/conformance/exec-stream.js +14 -6
- package/dist/conformance/runner.js +8 -4
- package/dist/conformance/sweep.d.ts +7 -2
- package/dist/conformance/sweep.js +17 -7
- package/dist/conformance/types.d.ts +21 -0
- package/dist/daytona.d.ts +8 -1
- package/dist/daytona.js +124 -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 +61 -37
- package/dist/hosted/framed-exec.d.ts +8 -19
- package/dist/hosted/framed-exec.js +21 -87
- package/dist/hosted/process.d.ts +2 -0
- package/dist/hosted/process.js +9 -2
- package/dist/hosted/provider.d.ts +41 -4
- package/dist/hosted/provider.js +289 -115
- package/dist/hosted/rest.d.ts +19 -0
- package/dist/hosted/rest.js +76 -0
- package/dist/hosted/scripts.d.ts +50 -0
- package/dist/hosted/scripts.js +116 -1
- package/dist/hosted/ssh-exec.d.ts +7 -6
- package/dist/hosted/ssh-exec.js +35 -52
- 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
|
|
package/box/Dockerfile
CHANGED
|
@@ -19,8 +19,9 @@
|
|
|
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.
|
|
@@ -35,5 +36,6 @@ RUN sh /tmp/agentrun-box/install.sh && rm -rf /tmp/agentrun-box
|
|
|
35
36
|
|
|
36
37
|
USER root
|
|
37
38
|
# A computer's first process is its provider's own (Daytona's runs this when a snapshot names no entrypoint; Modal's and
|
|
38
|
-
# E2B's are their own): never the base image's python.
|
|
39
|
-
|
|
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
|
@@ -10,6 +10,14 @@ Every step of the build is `install.sh`, POSIX shell run as root on the Dockerfi
|
|
|
10
10
|
account from a running machine (a snapshot, a blueprint, a template) boots that base, copies both files into one folder,
|
|
11
11
|
runs `sh install.sh` as root and snapshots the result. A second run on the same machine ends the same.
|
|
12
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
|
+
|
|
13
21
|
Its tag is the recipe's hash: the first 12 hex of the sha256 of `Dockerfile`, `install.sh` and `agentrun-archil`, the
|
|
14
22
|
files it copies (`recipe.mjs`). A changed recipe is a new image, and the same recipe is the one built before.
|
|
15
23
|
|
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
|
#
|
package/box/install.sh
CHANGED
|
@@ -19,6 +19,8 @@ ARCHIL_SHA256_AMD64=f219e70287e8152f3f0c7222e1c3319f4665897235af7c33a8846e56a5a5
|
|
|
19
19
|
ARCHIL_SHA256_ARM64=10ed430e51c268af095dd9e6c7aa6cdbb951d2430d62a76458719db168f40c0e
|
|
20
20
|
# Where the provider runs the root helper from.
|
|
21
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
|
|
22
24
|
|
|
23
25
|
here=$(dirname "$0")
|
|
24
26
|
|
|
@@ -62,15 +64,74 @@ helper() {
|
|
|
62
64
|
cp "$here/agentrun-archil" "$HELPER"
|
|
63
65
|
}
|
|
64
66
|
|
|
65
|
-
#
|
|
66
|
-
#
|
|
67
|
-
# (
|
|
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.
|
|
68
129
|
checked() {
|
|
69
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
|
|
70
131
|
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
|
|
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
|
|
74
135
|
[ -x "$x" ] || { echo "the image has no $x" >&2; exit 1; }
|
|
75
136
|
done
|
|
76
137
|
! command -v sudo >/dev/null 2>&1 || { echo "the image has sudo" >&2; exit 1; }
|
|
@@ -81,7 +142,7 @@ checked() {
|
|
|
81
142
|
}
|
|
82
143
|
|
|
83
144
|
case "$*" in
|
|
84
|
-
"") packages; desktop; helper; checked ;;
|
|
145
|
+
"") packages; desktop; helper; dial; checked ;;
|
|
85
146
|
checked) checked ;;
|
|
86
147
|
*) echo "usage: sh install.sh [checked]" >&2; exit 2 ;;
|
|
87
148
|
esac
|
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
|
/**
|
package/dist/attach.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// with the token it got by pairing, and the same JSON-RPC messages travel as text frames, one message per frame. Serve
|
|
4
4
|
// is the caller: it sends hello first, then the run's calls. The AttachHub keeps one live connection per paired
|
|
5
5
|
// computer; attachedProvider hands that computer to a run as a provider, one run at a time.
|
|
6
|
-
import { randomUUID } from "node:crypto";
|
|
6
|
+
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
7
7
|
import { PassThrough, Writable } from "node:stream";
|
|
8
8
|
import { DaemonClient } from "./client.js";
|
|
9
9
|
import { kindServed } from "./kinds.js";
|
|
@@ -11,6 +11,8 @@ import { PROTOCOL_VERSION } from "./protocol.js";
|
|
|
11
11
|
import { checkLifetime, kindRefusals, runLifetimeMs } from "./provider.js";
|
|
12
12
|
import { fail, ok } from "./result.js";
|
|
13
13
|
export const ATTACH_PATH = "/v2/computers/attach";
|
|
14
|
+
/** Where a hosted machine that dials fetches the server's computerd for its arch (?arch=amd64|arm64), with its token. */
|
|
15
|
+
export const DAEMON_PATH = "/v2/computers/daemon";
|
|
14
16
|
/** The WebSocket subprotocol a driver asks for: the protocol version it speaks. Serve answers with it or refuses. */
|
|
15
17
|
export const ATTACH_SUBPROTOCOL = `agentrun.computer.${PROTOCOL_VERSION}`;
|
|
16
18
|
/** Each side pings this often (WebSocket ping frames, not JSON-RPC), so a NAT keeps the path open. */
|
|
@@ -89,6 +91,39 @@ export function socketStreams(socket) {
|
|
|
89
91
|
});
|
|
90
92
|
return { readable, writable };
|
|
91
93
|
}
|
|
94
|
+
const sha256 = (token) => createHash("sha256").update(token).digest("hex");
|
|
95
|
+
/**
|
|
96
|
+
* MachineTokens in one process's memory, as serve's store keeps them (the sha256 alone): for tests and a conformance
|
|
97
|
+
* kit. check is what the server's attach and daemon routes ask of a token.
|
|
98
|
+
*/
|
|
99
|
+
export class MemoryMachineTokens {
|
|
100
|
+
#held = new Map();
|
|
101
|
+
#hashOf = new Map();
|
|
102
|
+
// No await in either: a mint replaces the machine's token at once, so two of one machine leave one token, not two.
|
|
103
|
+
async mint(machine, mint) {
|
|
104
|
+
this.#drop(machine);
|
|
105
|
+
const token = `art_${randomBytes(32).toString("hex")}`;
|
|
106
|
+
this.#held.set(sha256(token), { machine, mint: { ...mint } });
|
|
107
|
+
this.#hashOf.set(machine, sha256(token));
|
|
108
|
+
return token;
|
|
109
|
+
}
|
|
110
|
+
async revoke(machine) {
|
|
111
|
+
this.#drop(machine);
|
|
112
|
+
}
|
|
113
|
+
#drop(machine) {
|
|
114
|
+
this.#held.delete(this.#hashOf.get(machine) ?? "");
|
|
115
|
+
this.#hashOf.delete(machine);
|
|
116
|
+
}
|
|
117
|
+
/** The machine and mint a token is good for at `at`: undefined for one unknown, revoked, or past its expiresAt. */
|
|
118
|
+
check(token, at = new Date()) {
|
|
119
|
+
const held = this.#held.get(sha256(token));
|
|
120
|
+
return held === undefined || at.getTime() > held.mint.expiresAt.getTime() ? undefined : held;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/** A minted machine as the AttachHub takes its socket: under the machine's name, its hello held to the mint. */
|
|
124
|
+
export function mintedComputer(machine, { kind, os, arch }) {
|
|
125
|
+
return { id: machine, name: machine, hello: { protocol: PROTOCOL_VERSION, version: "", os, kind, arch, groups: [] }, labels: {}, minted: true };
|
|
126
|
+
}
|
|
92
127
|
/** Whether protocol version a ("0.3") comes after b ("0.2"), part by part as numbers. */
|
|
93
128
|
function laterProtocol(a, b) {
|
|
94
129
|
const [x, y] = [a, b].map((version) => version.split(".").map((part) => Number.parseInt(part, 10) || 0));
|
|
@@ -103,8 +138,9 @@ function laterProtocol(a, b) {
|
|
|
103
138
|
* replace it the way a provider replaces a copied daemon.
|
|
104
139
|
*/
|
|
105
140
|
export function helloMismatch(paired, hello) {
|
|
106
|
-
// Serve names no OS and no driver app: one way to update, in the same words for every computer.
|
|
107
|
-
|
|
141
|
+
// Serve names no OS and no driver app: one way to update, in the same words for every computer. A minted machine
|
|
142
|
+
// fetched this server's own computerd at boot, so another build there is not one this server gave it.
|
|
143
|
+
const update = paired.minted ? `${paired.name} runs a computerd that is not this server's build: create the computer again` : `update the driver on ${paired.name} (the download is on the console's Computers page)`;
|
|
108
144
|
const said = hello;
|
|
109
145
|
if (typeof said !== "object" || said === null || typeof said.protocol !== "string" || typeof said.version !== "string") {
|
|
110
146
|
return { code: ATTACH_CLOSE.protocol, message: `${paired.name}'s driver answered hello without its protocol and version: ${update}` };
|
|
@@ -124,6 +160,10 @@ export function helloMismatch(paired, hello) {
|
|
|
124
160
|
if (missing.length > 0) {
|
|
125
161
|
return { code: ATTACH_CLOSE.protocol, message: `${paired.name}'s driver ${hello.version} answered a protocol ${PROTOCOL_VERSION} hello without ${missing.join(", ")}: ${update}` };
|
|
126
162
|
}
|
|
163
|
+
if (paired.minted && (hello.kind !== paired.hello.kind || hello.os !== paired.hello.os || hello.arch !== paired.hello.arch)) {
|
|
164
|
+
const was = paired.hello;
|
|
165
|
+
return { code: ATTACH_CLOSE.mismatch, message: `${paired.name} was made a ${was.os} ${was.kind} on ${was.arch} and says ${hello.os} ${hello.kind} on ${hello.arch}: its token is that machine's alone` };
|
|
166
|
+
}
|
|
127
167
|
if (hello.kind !== paired.hello.kind || hello.os !== paired.hello.os) {
|
|
128
168
|
return { code: ATTACH_CLOSE.mismatch, message: `${paired.name} paired as a ${paired.hello.os} ${paired.hello.kind} and now says ${hello.os} ${hello.kind}: pair it again` };
|
|
129
169
|
}
|
|
@@ -207,7 +247,7 @@ export class AttachHub {
|
|
|
207
247
|
}
|
|
208
248
|
if (closed)
|
|
209
249
|
return fail("gone", `${paired.name}'s socket closed while it said hello`);
|
|
210
|
-
mine = { socket, client, hello: hello.value, dial };
|
|
250
|
+
mine = { socket, client, hello: hello.value, dial, since: new Date() };
|
|
211
251
|
this.#live.set(paired.id, mine);
|
|
212
252
|
older?.socket.close(ATTACH_CLOSE.replaced, "the computer dialed again");
|
|
213
253
|
return hello;
|
|
@@ -216,6 +256,10 @@ export class AttachHub {
|
|
|
216
256
|
online(id) {
|
|
217
257
|
return this.#live.has(id);
|
|
218
258
|
}
|
|
259
|
+
/** When the computer's live connection said hello and went live; undefined while it is not attached. */
|
|
260
|
+
since(id) {
|
|
261
|
+
return this.#live.get(id)?.since;
|
|
262
|
+
}
|
|
219
263
|
/** The hello of the computer's live connection: its driver's version and groups now, which an update may change. */
|
|
220
264
|
hello(id) {
|
|
221
265
|
return this.#live.get(id)?.hello;
|
package/dist/box-image.d.ts
CHANGED
|
@@ -12,3 +12,5 @@ export declare const boxImageRef: () => string;
|
|
|
12
12
|
export declare const BOX_E2B_PUBLISHER = "agentrun-oss";
|
|
13
13
|
/** The public E2B template of the box image this package's recipe names: <publisher>/agentrun-archil-<recipe hash>. */
|
|
14
14
|
export declare const boxE2bTemplate: () => string;
|
|
15
|
+
/** Whether an image is a box image by its name: this release's or an older one's, whatever the recipe hash. */
|
|
16
|
+
export declare const isBoxImage: (image: string) => boolean;
|
package/dist/box-image.js
CHANGED
|
@@ -22,3 +22,13 @@ export const boxImageRef = () => `${BOX_IMAGE_REPOSITORY}:${boxRecipeHash()}`;
|
|
|
22
22
|
export const BOX_E2B_PUBLISHER = "agentrun-oss";
|
|
23
23
|
/** The public E2B template of the box image this package's recipe names: <publisher>/agentrun-archil-<recipe hash>. */
|
|
24
24
|
export const boxE2bTemplate = () => `${BOX_E2B_PUBLISHER}/agentrun-archil-${boxRecipeHash()}`;
|
|
25
|
+
const literal = (text) => text.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
|
|
26
|
+
/**
|
|
27
|
+
* Every name a box image goes by, a prefix and a recipe hash (12 hex): the published image
|
|
28
|
+
* (ghcr.io/parcha-ai/agentrun-box:<hash>), Agent37's workspace template (agentrun-box-<hash>), the E2B template and the
|
|
29
|
+
* Daytona snapshot (agentrun-archil-<hash>, the public E2B one under its publisher), and Daytona's GPU snapshots
|
|
30
|
+
* (agentrun-archil-gpu-<type>-<hash>).
|
|
31
|
+
*/
|
|
32
|
+
const BOX_IMAGE_NAME = new RegExp(`^(?:${literal(BOX_IMAGE_REPOSITORY)}:|agentrun-box-|(?:${literal(BOX_E2B_PUBLISHER)}/)?agentrun-archil-(?:gpu-[a-z0-9]+-)?)[0-9a-f]{12}$`);
|
|
33
|
+
/** Whether an image is a box image by its name: this release's or an older one's, whatever the recipe hash. */
|
|
34
|
+
export const isBoxImage = (image) => BOX_IMAGE_NAME.test(image);
|
|
Binary file
|
|
Binary file
|
package/dist/computerd.json
CHANGED
|
@@ -3,9 +3,13 @@
|
|
|
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
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
|
|
6
|
+
// deleted computer stays gone: no call to it brings it back. A provider's prepareImage() and its descriptor's flag agree, and
|
|
7
|
+
// prepareImage called twice answers one image and makes it once.
|
|
8
|
+
// A dial host's machine token is its machine's alone, and ends at delete and at backstopAt (Core).
|
|
7
9
|
import { randomBytes } from "node:crypto";
|
|
10
|
+
import { ATTACH_CLOSE } from "../../attach.js";
|
|
8
11
|
import { BACKSTOP_MARGIN_MS } from "../../host.js";
|
|
12
|
+
import { descriptorOf } from "../../providers.js";
|
|
9
13
|
import { releaseOlder, sweep } from "../../janitor.js";
|
|
10
14
|
import { EPOCH_LABEL, OWNER_LABEL, RUN_LABEL, runLabels } from "../../labels.js";
|
|
11
15
|
import { computerNameFor, runLifetimeMs } from "../../provider.js";
|
|
@@ -53,8 +57,6 @@ async function refusedCreate(t, spec, what) {
|
|
|
53
57
|
/** The deadline case's lifetime, and how much of it must be left once create returns: to connect and start a process. */
|
|
54
58
|
const DEADLINE_LIFETIME_MS = 45_000;
|
|
55
59
|
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;
|
|
58
60
|
const seconds = (ms) => Math.round(ms / 100) / 10;
|
|
59
61
|
/**
|
|
60
62
|
* A computer for the deadline case, the lifetime it was made with, and when create returned, on the run's clock. A
|
|
@@ -244,18 +246,22 @@ export const providerCases = [
|
|
|
244
246
|
t.assert(deadline >= before + lifetimeMs - 1000 && deadline <= after + lifetimeMs + 1000, `its deadline, ${String(info.deadline)}, is lifetimeMs after create`);
|
|
245
247
|
t.deepEqual(await names(t, { ...labels, role: "other" }), [], "list by a label no computer has");
|
|
246
248
|
}),
|
|
247
|
-
// prepareImage
|
|
248
|
-
//
|
|
249
|
-
//
|
|
250
|
-
//
|
|
249
|
+
// prepareImage is declared by the provider's method; its descriptor's flag says the same to Settings, which reads it
|
|
250
|
+
// without loading the provider's module. The two agree: a server never skips a provider's image, nor asks one it has
|
|
251
|
+
// not got. A provider on the machine-host adapter has its host's descriptor; another, the registry's for its id.
|
|
252
|
+
// Then prepareImage twice in one run (spec/computer/provider.md, "prepareImage"): both answer the same image, and the
|
|
253
|
+
// second finds the one the first made by its name, so it is told no onWait. A server calls it before its first create,
|
|
254
|
+
// so one that builds every time costs every server minutes. A provider with none passes, observed. Core: the first
|
|
255
|
+
// call costs at most a build per account and recipe, which the account's first create pays anyway.
|
|
251
256
|
provider("prepare-image", async (t) => {
|
|
252
|
-
|
|
253
|
-
const descriptor = t.provider.host?.descriptor;
|
|
257
|
+
const descriptor = t.provider.host?.descriptor ?? descriptorOf(t.provider.id);
|
|
254
258
|
const prepare = t.provider.prepareImage?.bind(t.provider);
|
|
255
|
-
if (
|
|
256
|
-
t.assert(
|
|
259
|
+
if (descriptor !== undefined)
|
|
260
|
+
t.assert((prepare !== undefined) === (descriptor.prepareImage === true), prepare !== undefined
|
|
261
|
+
? `${descriptor.label}'s provider has prepareImage() but its descriptor does not declare prepareImage: Settings never calls it`
|
|
262
|
+
: `${descriptor.label}'s descriptor declares prepareImage, but its provider has no prepareImage(): give the provider class one`);
|
|
263
|
+
if (prepare === undefined)
|
|
257
264
|
return t.observe("the provider has no prepareImage(): its computers start from an image a spec names");
|
|
258
|
-
}
|
|
259
265
|
const call = async (which) => {
|
|
260
266
|
const told = [];
|
|
261
267
|
const image = t.ok(await prepare({ signal: t.signal, onWait: (making, tag) => told.push(`${making} ${tag}`) }), `the ${which} prepareImage`);
|
|
@@ -370,6 +376,30 @@ export const providerCases = [
|
|
|
370
376
|
t.ok(await t.provider.release(ref, "delete"), "release delete of the agent's computer");
|
|
371
377
|
t.deepEqual(await names(t, labels), [], "listed after delete");
|
|
372
378
|
}, { level: "full", needs: ["persistence", "files"] }),
|
|
379
|
+
// A machine that dials holds a token of its own (spec/computer/attach.md, Hosted machines that dial): good for that
|
|
380
|
+
// machine's hello alone, refused past its backstop and after its delete; and a server no machine can reach makes none.
|
|
381
|
+
provider("dial-token", async (t) => {
|
|
382
|
+
if (t.provider.host?.facts?.connect !== "dial")
|
|
383
|
+
return t.observe("the provider's machines do not dial the server, so they hold no machine token");
|
|
384
|
+
const kit = await t.dial();
|
|
385
|
+
const bare = kit.unreachable();
|
|
386
|
+
const refused = t.refused(await t.attempt(t.spec({ labels: own(t, "dial-token") }), bare.provider), "create on a server with no public address", ["refused"]);
|
|
387
|
+
t.match(refused.message, /public https address/, "create on a server with no public address: the refusal");
|
|
388
|
+
t.equal(bare.creates(), 0, "the vendor's creates asked for by a create on a server with no public address");
|
|
389
|
+
const ref = await t.create({ labels: own(t, "dial-token") });
|
|
390
|
+
const { hello } = await t.connect(ref);
|
|
391
|
+
const token = t.present(kit.token(ref), `the token ${ref.name}'s machine was given`);
|
|
392
|
+
t.equal(await kit.check(token, new Date()), ref.name, "the machine's token, now");
|
|
393
|
+
// Past the machine's backstop: create's time, the most it may live and the margin, and a minute.
|
|
394
|
+
const past = new Date(Date.now() + t.provider.capabilities().maxLifetimeMs + BACKSTOP_MARGIN_MS + 60_000);
|
|
395
|
+
t.equal(await kit.check(token, past), undefined, "the machine's token past its backstop");
|
|
396
|
+
const others = [{ kind: hello.kind === "linux" ? "desktop" : "linux" }, { os: hello.os === "linux" ? "windows" : "linux" }, { arch: hello.arch === "amd64" ? "arm64" : "amd64" }];
|
|
397
|
+
for (const other of others) {
|
|
398
|
+
t.equal(await kit.dialAs(token, { ...hello, ...other }), ATTACH_CLOSE.mismatch, `the machine's token with a hello of ${JSON.stringify(other)}: the close code`);
|
|
399
|
+
}
|
|
400
|
+
t.ok(await t.provider.release(ref, "delete"), "release delete");
|
|
401
|
+
t.equal(await kit.check(token, new Date()), undefined, "the machine's token after its delete");
|
|
402
|
+
}),
|
|
373
403
|
provider("network-change", async (t) => {
|
|
374
404
|
const spec = t.spec({ labels: own(t, "network") });
|
|
375
405
|
const ref = await t.create(spec);
|
|
@@ -487,18 +517,4 @@ export const providerCases = [
|
|
|
487
517
|
t.ok(await t.provider.release(ref, "delete"), `release ${ref.name}`);
|
|
488
518
|
t.deepEqual(await names(t, labels), [], "the case's computers after it");
|
|
489
519
|
}, { 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" }),
|
|
504
520
|
];
|
package/dist/conformance/cli.js
CHANGED
|
@@ -227,7 +227,7 @@ export function plantSecrets(names) {
|
|
|
227
227
|
* register its image, so it is given the run's signal), and conformanceNotes, strings for the report.
|
|
228
228
|
*/
|
|
229
229
|
async function load(label, module, options, { imageNamed, signal }, declared) {
|
|
230
|
-
const { createProvider, createDriftedProvider, conformanceImage, mountFor } = module;
|
|
230
|
+
const { createProvider, createDriftedProvider, conformanceImage, mountFor, dialKit } = module;
|
|
231
231
|
if (typeof createProvider !== "function")
|
|
232
232
|
throw new Usage(`${label} does not export createProvider() or create()`);
|
|
233
233
|
const provider = (await createProvider(options));
|
|
@@ -253,6 +253,8 @@ async function load(label, module, options, { imageNamed, signal }, declared) {
|
|
|
253
253
|
}
|
|
254
254
|
if (typeof mountFor === "function")
|
|
255
255
|
target.mountFor = (kind) => mountFor(kind, options);
|
|
256
|
+
if (typeof dialKit === "function")
|
|
257
|
+
target.dial = () => dialKit(options);
|
|
256
258
|
if (conformanceImage !== undefined && !imageNamed) {
|
|
257
259
|
const image = typeof conformanceImage === "function" ? await conformanceImage(options, signal ? { signal } : {}) : undefined;
|
|
258
260
|
if (typeof image !== "string" || image === "")
|
|
@@ -351,6 +353,7 @@ export async function main(argv, io = {}) {
|
|
|
351
353
|
...(target.declared ? { declared: target.declared } : {}),
|
|
352
354
|
...(target.planted ? { planted: target.planted } : {}),
|
|
353
355
|
...(target.mountFor ? { mountFor: target.mountFor } : {}),
|
|
356
|
+
...(target.dial ? { dial: target.dial } : {}),
|
|
354
357
|
...(onResult ? { onResult } : {}),
|
|
355
358
|
...(io.cdp ? { cdp: io.cdp } : {}),
|
|
356
359
|
});
|