@parcha/agentrun-computer 0.1.0-beta.34 → 0.1.0-beta.35
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 +144 -26
- package/dist/browser.d.ts +12 -13
- package/dist/browser.js +16 -14
- package/dist/browserbase.d.ts +3 -5
- package/dist/browserbase.js +16 -13
- package/dist/chrome.js +1 -1
- package/dist/computerd-linux-amd64 +0 -0
- package/dist/computerd-linux-arm64 +0 -0
- package/dist/conformance/browserbase.js +1 -1
- package/dist/conformance/cases/provider.js +78 -3
- package/dist/conformance/daytona.js +2 -1
- package/dist/conformance/e2b.js +2 -1
- package/dist/conformance/fixture.js +24 -2
- package/dist/conformance/kernel.js +1 -1
- package/dist/conformance/kind.js +2 -1
- package/dist/conformance/{local.d.ts → local-chrome.d.ts} +7 -7
- package/dist/conformance/{local.js → local-chrome.js} +11 -11
- package/dist/conformance/orgo.d.ts +11 -5
- package/dist/conformance/orgo.js +37 -8
- package/dist/conformance/phone-harness.js +2 -1
- package/dist/conformance/report.js +3 -2
- package/dist/conformance/runner.js +25 -7
- package/dist/conformance/types.d.ts +21 -8
- package/dist/conformance/types.js +10 -0
- package/dist/conformance/windows-fixture.d.ts +1 -0
- package/dist/conformance/windows-fixture.js +37 -0
- package/dist/daytona.d.ts +3 -34
- package/dist/daytona.js +34 -61
- package/dist/descriptor.d.ts +94 -0
- package/dist/descriptor.js +81 -0
- package/dist/descriptors/browserbase.d.ts +24 -0
- package/dist/descriptors/browserbase.js +18 -0
- package/dist/descriptors/daytona.d.ts +62 -0
- package/dist/descriptors/daytona.js +49 -0
- package/dist/descriptors/docker.d.ts +12 -0
- package/dist/descriptors/docker.js +17 -0
- package/dist/descriptors/e2b.d.ts +22 -0
- package/dist/descriptors/e2b.js +19 -0
- package/dist/descriptors/index.d.ts +229 -0
- package/dist/descriptors/index.js +19 -0
- package/dist/descriptors/kernel.d.ts +20 -0
- package/dist/descriptors/kernel.js +15 -0
- package/dist/descriptors/local-chrome.d.ts +17 -0
- package/dist/descriptors/local-chrome.js +21 -0
- package/dist/descriptors/modal.d.ts +50 -0
- package/dist/descriptors/modal.js +38 -0
- package/dist/descriptors/orgo.d.ts +88 -0
- package/dist/descriptors/orgo.js +44 -0
- package/dist/descriptors/phone-harness.d.ts +28 -0
- package/dist/descriptors/phone-harness.js +20 -0
- package/dist/descriptors/shared.d.ts +7 -0
- package/dist/descriptors/shared.js +6 -0
- package/dist/desktop.d.ts +4 -4
- package/dist/desktop.js +4 -4
- package/dist/docker/egress.d.ts +1 -1
- package/dist/docker/image.js +17 -15
- package/dist/docker/inspect.d.ts +147 -0
- package/dist/docker/inspect.js +335 -0
- package/dist/docker.d.ts +6 -6
- package/dist/docker.js +46 -42
- package/dist/drift.d.ts +3 -145
- package/dist/drift.js +5 -334
- package/dist/e2b.d.ts +2 -8
- package/dist/e2b.js +16 -22
- package/dist/index.d.ts +8 -11
- package/dist/index.js +13 -11
- package/dist/isolation.js +2 -2
- package/dist/janitor.d.ts +18 -1
- package/dist/janitor.js +67 -19
- package/dist/kernel.d.ts +3 -5
- package/dist/kernel.js +19 -16
- package/dist/kinds.d.ts +54 -34
- package/dist/kinds.js +19 -117
- package/dist/labels.d.ts +12 -0
- package/dist/labels.js +39 -1
- package/dist/{local.d.ts → local-chrome.d.ts} +5 -8
- package/dist/{local.js → local-chrome.js} +19 -16
- package/dist/local-supervisor.d.ts +3 -3
- package/dist/local-supervisor.js +3 -3
- package/dist/modal.d.ts +3 -22
- package/dist/modal.js +15 -31
- package/dist/mount-archil.js +4 -4
- package/dist/orgo-channel.js +16 -13
- package/dist/orgo-desktop.d.ts +153 -0
- package/dist/orgo-desktop.js +1614 -0
- package/dist/orgo-names.d.ts +52 -0
- package/dist/orgo-names.js +84 -0
- package/dist/orgo.d.ts +18 -15
- package/dist/orgo.js +46 -107
- package/dist/phone-harness.d.ts +4 -10
- package/dist/phone-harness.js +45 -46
- package/dist/provider.d.ts +91 -10
- package/dist/provider.js +42 -0
- package/dist/providers.d.ts +23 -24
- package/dist/providers.js +14 -17
- package/dist/result.d.ts +11 -1
- package/dist/result.js +11 -0
- package/dist/test-connection.js +2 -2
- package/package.json +42 -2
package/dist/drift.js
CHANGED
|
@@ -1,170 +1,22 @@
|
|
|
1
|
-
// The drift
|
|
2
|
-
//
|
|
3
|
-
|
|
4
|
-
import { EGRESS_MOUNT, EGRESS_SOCKET, egressNameOf, egressOf, policyWords, RELAY_FLAG, sameAllow } from "./docker/egress.js";
|
|
5
|
-
import { engineOf, subpathOf } from "./docker/volume.js";
|
|
6
|
-
import { WORKSPACE } from "./mount.js";
|
|
1
|
+
// The drift checks every provider shares: the daemon's hello against what the provider declares, and the report of
|
|
2
|
+
// computerd probe from inside a computer. Pure: no vendor call. Each mismatch is one sentence; none is an empty list.
|
|
3
|
+
// Docker's own read-back (docker info, docker inspect) is docker/inspect.ts's.
|
|
7
4
|
import { NETWORK_FENCES, PROTOCOL_VERSION } from "./protocol.js";
|
|
8
5
|
/** Where the daemon is mounted in each computer, read-only. */
|
|
9
6
|
export const DAEMON_IN_COMPUTER = "/opt/agentrun/computerd";
|
|
10
|
-
/** With the Docker provider's volume option, where the daemon's staged directory is mounted read-only: its computerd is
|
|
11
|
-
* DAEMON_IN_COMPUTER (src/docker/stage.ts). */
|
|
12
|
-
export const DAEMON_DIR_IN_COMPUTER = "/opt/agentrun";
|
|
13
7
|
export const COMPUTER_LABEL = "agentrun.computer";
|
|
14
8
|
export const DEADLINE_LABEL = "agentrun.computer.deadline";
|
|
15
9
|
/** Serve's box sizes, when the spec names none. */
|
|
16
10
|
export const DEFAULT_CPUS = 2;
|
|
17
11
|
export const DEFAULT_MEMORY_MB = 4096;
|
|
18
12
|
export const DEFAULT_PIDS = 1024;
|
|
19
|
-
/** CPUs are a CFS quota of each 100 ms, as serve gives them: Docker refuses a --cpus above its own CPU count. */
|
|
20
|
-
export const CPU_PERIOD_US = 100_000;
|
|
21
13
|
/** The computer's home and default workdir: a tmpfs its user owns. The run's folder, when bound, is at WORKSPACE. */
|
|
22
14
|
export const WORK = "/work";
|
|
23
15
|
/** Where init's socket lives (the daemon's DefaultSocket's directory): a tmpfs the computer's user owns, mode 0700. */
|
|
24
16
|
export const SOCKET_DIR = "/run/agentrun";
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
* computer's memory, so /work holds half of it: a full /work is ENOSPC before the memory limit could OOM-kill a
|
|
28
|
-
* process. /run/agentrun holds only init's socket.
|
|
29
|
-
*/
|
|
30
|
-
export function tmpfsOf(user, memoryMb) {
|
|
31
|
-
const [uid, gid] = user.split(":");
|
|
32
|
-
return {
|
|
33
|
-
[WORK]: `rw,nosuid,nodev,exec,uid=${uid},gid=${gid},mode=0700,size=${Math.floor(memoryMb / 2)}m`,
|
|
34
|
-
[SOCKET_DIR]: `rw,noexec,nosuid,nodev,uid=${uid},gid=${gid},mode=0700,size=1m`,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
/** docker info names the kernel's architecture; hello names Go's. */
|
|
38
|
-
const GO_ARCH = { x86_64: "amd64", aarch64: "arm64" };
|
|
39
|
-
/**
|
|
40
|
-
* The host's enforcement, from docker info. A computer's sizes are cgroup limits, so a host that does not enforce one
|
|
41
|
-
* makes it configuration only; seccomp is required, since a computer's only syscall filter is Docker's default
|
|
42
|
-
* profile. AppArmor and SELinux are read, not required: a host has the one its distribution ships or neither, and a
|
|
43
|
-
* computer must then carry the profile or label Docker gives every container (the drift check).
|
|
44
|
-
*/
|
|
45
|
-
export function hostOf(info) {
|
|
46
|
-
const problems = [];
|
|
47
|
-
const lacks = (flag, what, so) => {
|
|
48
|
-
if (flag !== true)
|
|
49
|
-
problems.push(`this Docker host does not enforce ${what}, so ${so}`);
|
|
50
|
-
};
|
|
51
|
-
lacks(info?.MemoryLimit, "memory limits", "a computer's memory size is only configuration");
|
|
52
|
-
lacks(info?.SwapLimit, "swap limits", "a computer could swap past its memory size");
|
|
53
|
-
lacks(info?.PidsLimit, "pids limits", "a computer's pids limit is only configuration");
|
|
54
|
-
lacks(info?.CPUCfsQuota, "CPU quotas", "a computer's cpus are only configuration");
|
|
55
|
-
lacks(info?.CPUCfsPeriod, "CPU periods", "a computer's cpus are only configuration");
|
|
56
|
-
const options = Array.isArray(info?.SecurityOptions) ? info.SecurityOptions.filter((option) => typeof option === "string") : [];
|
|
57
|
-
const named = (name) => options.find((option) => option.split(",").includes(`name=${name}`));
|
|
58
|
-
const seccomp = named("seccomp");
|
|
59
|
-
if (seccomp === undefined)
|
|
60
|
-
problems.push("this Docker host has no seccomp, so a computer could make any system call");
|
|
61
|
-
else if (seccomp.split(",").includes("profile=unconfined")) {
|
|
62
|
-
problems.push("this Docker host's default seccomp profile is unconfined, so a computer could make any system call");
|
|
63
|
-
}
|
|
64
|
-
const machine = typeof info?.Architecture === "string" ? info.Architecture : "";
|
|
65
|
-
const remap = named("userns") !== undefined ? "userns" : named("rootless") !== undefined ? "rootless" : undefined;
|
|
66
|
-
const engine = engineOf(info?.ServerVersion);
|
|
67
|
-
return { arch: GO_ARCH[machine] ?? machine, apparmor: named("apparmor") !== undefined, selinux: named("selinux") !== undefined, problems, ...(remap ? { remap } : {}), ...(engine === undefined ? {} : { engine }) };
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* How create mounts a path of this host at `target`: a bind of it, or, with the provider's volume option, the volume's
|
|
71
|
-
* subpath, as HostConfig.Mounts records it (Docker keeps `volume-nocopy` and the subpath under VolumeOptions). Undefined
|
|
72
|
-
* for a path outside the volume, which create never mounts.
|
|
73
|
-
*/
|
|
74
|
-
export function mountAsked(path, target, readonly, volume) {
|
|
75
|
-
if (volume === undefined)
|
|
76
|
-
return { Type: "bind", Source: path, Target: target, ...(readonly ? { ReadOnly: true } : {}) };
|
|
77
|
-
const subpath = subpathOf(volume, path);
|
|
78
|
-
if (subpath === undefined)
|
|
79
|
-
return undefined;
|
|
80
|
-
return { Type: "volume", Source: volume.name, Target: target, ...(readonly ? { ReadOnly: true } : {}), VolumeOptions: { NoCopy: true, Subpath: subpath } };
|
|
81
|
-
}
|
|
82
|
-
const show = (value) => (value === undefined ? "nothing" : JSON.stringify(value));
|
|
17
|
+
/** A value as a drift sentence shows it: JSON, or "nothing". */
|
|
18
|
+
export const show = (value) => (value === undefined ? "nothing" : JSON.stringify(value));
|
|
83
19
|
const text = (value) => (typeof value === "string" ? value : show(value));
|
|
84
|
-
const sameList = (a, b) => Array.isArray(a) && a.length === b.length && a.every((item, i) => item === b[i]);
|
|
85
|
-
/** Docker's default for a field it reports: nothing, an empty string, list or map, zero or false. A map with any key,
|
|
86
|
-
* even to an empty value (a VOLUME's {}), is not. */
|
|
87
|
-
const blank = (value) => value === undefined || value === null || value === "" || value === 0 || value === false || (typeof value === "object" && Object.keys(value).length === 0);
|
|
88
|
-
/** Docker's masked and read-only paths in every release since 20.10; a newer one masks more. */
|
|
89
|
-
const MASKED_PATHS = ["/proc/acpi", "/proc/asound", "/proc/kcore", "/proc/keys", "/proc/latency_stats", "/proc/sched_debug", "/proc/scsi", "/proc/timer_list", "/proc/timer_stats", "/sys/firmware"];
|
|
90
|
-
const READONLY_PATHS = ["/proc/bus", "/proc/fs", "/proc/irq", "/proc/sys", "/proc/sysrq-trigger"];
|
|
91
|
-
const holds = (value, paths) => Array.isArray(value) && paths.every((path) => value.includes(path));
|
|
92
|
-
/**
|
|
93
|
-
* The closed check of HostConfig. A field named here is checked in drift() for what create asked for, is checked
|
|
94
|
-
* here for a default other than blank, or is irrelevant (its value widens nothing the box bounds). Every other field,
|
|
95
|
-
* one Docker adds later included, must be blank.
|
|
96
|
-
*/
|
|
97
|
-
const HOST_ASKED = new Set(["NetworkMode", "CapDrop", "CapAdd", "Privileged", "SecurityOpt", "PidsLimit", "Memory", "MemorySwap", "CpuPeriod", "CpuQuota", "Tmpfs", "Mounts", "IpcMode", "CgroupnsMode", "MaskedPaths", "ReadonlyPaths", "Runtime"]);
|
|
98
|
-
const HOST_DEFAULTS = {
|
|
99
|
-
RestartPolicy: [
|
|
100
|
-
(v) => {
|
|
101
|
-
const { Name, MaximumRetryCount, ...rest } = (v ?? {});
|
|
102
|
-
return (blank(Name) || Name === "no") && blank(MaximumRetryCount) && Object.values(rest).every(blank);
|
|
103
|
-
},
|
|
104
|
-
'no restart ("no")',
|
|
105
|
-
],
|
|
106
|
-
Isolation: [(v) => blank(v) || v === "default", "Docker's default"],
|
|
107
|
-
MemorySwappiness: [(v) => blank(v) || v === -1, "the kernel's (null)"],
|
|
108
|
-
};
|
|
109
|
-
/** Values the host or Docker chooses that a computer cannot widen itself by: logs, the console, /dev/shm (charged to the
|
|
110
|
-
* computer's memory), rlimits (inside the cgroup's limits) and the file create's cid would go to. */
|
|
111
|
-
const HOST_IRRELEVANT = new Set(["ContainerIDFile", "LogConfig", "ConsoleSize", "ShmSize", "Ulimits"]);
|
|
112
|
-
/** The closed check of Config, the same way: the image's own settings that run only inside the computer are irrelevant. */
|
|
113
|
-
const CONFIG_ASKED = new Set(["User", "Image", "WorkingDir", "Env", "Entrypoint", "Cmd", "Labels"]);
|
|
114
|
-
const CONFIG_IRRELEVANT = new Set([
|
|
115
|
-
"Hostname", "Domainname", "AttachStdin", "AttachStdout", "AttachStderr", "Tty", "OpenStdin", "StdinOnce", "ExposedPorts", "Healthcheck",
|
|
116
|
-
"ArgsEscaped", "OnBuild", "StopSignal", "StopTimeout", "Shell", "MacAddress", "NetworkDisabled",
|
|
117
|
-
]);
|
|
118
|
-
/** A mount's options as a set, so their order is no drift. */
|
|
119
|
-
const optionSet = (options) => (typeof options === "string" ? options.split(",").sort().join(",") : undefined);
|
|
120
|
-
/** Whether a computer's inspect shows any part of an allowlist: the egress volume at its path, or init's relay. */
|
|
121
|
-
export function egressShaped(inspected) {
|
|
122
|
-
const cmd = inspected?.Config?.Cmd;
|
|
123
|
-
return (inspected?.Mounts ?? []).some((mount) => mount.Destination === EGRESS_MOUNT) || (Array.isArray(cmd) && cmd.includes(RELAY_FLAG));
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* The network a computer is on, read back from inspect: `none` is network mode none on no network but Docker's own
|
|
127
|
-
* `none`, `open` is the default bridge alone. An allowlist is network mode none with the computer's egress volume
|
|
128
|
-
* mounted read-only at EGRESS_MOUNT and init relaying to its socket, and the list read back from `proxy`, the
|
|
129
|
-
* computer's proxy container's inspect (egressOf: none when it is gone), which must refuse each of `local`, the Docker
|
|
130
|
-
* host's own addresses. Anything else is reported in words, never as a policy it might widen to.
|
|
131
|
-
*/
|
|
132
|
-
export function networkOf(inspected, proxy, code, local) {
|
|
133
|
-
const mode = inspected?.HostConfig?.NetworkMode;
|
|
134
|
-
const networks = Object.keys(inspected?.NetworkSettings?.Networks ?? {}).sort();
|
|
135
|
-
const none = mode === "none" && networks.every((name) => name === "none");
|
|
136
|
-
const where = `network mode ${mode ?? "unknown"} on networks ${networks.join(", ") || "none"}`;
|
|
137
|
-
if (!egressShaped(inspected)) {
|
|
138
|
-
if (none)
|
|
139
|
-
return "none";
|
|
140
|
-
if (mode === "bridge" && sameList(networks, ["bridge"]))
|
|
141
|
-
return "open";
|
|
142
|
-
return { other: where };
|
|
143
|
-
}
|
|
144
|
-
if (!none)
|
|
145
|
-
return { other: `${where}, with an egress volume or relay, which this provider never makes` };
|
|
146
|
-
const name = (inspected?.Name ?? "").replace(/^\//, "");
|
|
147
|
-
const at = (inspected?.Mounts ?? []).filter((mount) => mount.Destination === EGRESS_MOUNT);
|
|
148
|
-
const cmd = inspected?.Config?.Cmd;
|
|
149
|
-
const relay = Array.isArray(cmd) ? cmd.indexOf(RELAY_FLAG) : -1;
|
|
150
|
-
if (at.length === 0)
|
|
151
|
-
return { other: `init's relay points at ${show(Array.isArray(cmd) ? cmd[relay + 1] : undefined)} but no egress volume is mounted at ${EGRESS_MOUNT}` };
|
|
152
|
-
if (relay < 0)
|
|
153
|
-
return { other: `an egress volume at ${EGRESS_MOUNT} but no relay in init's command` };
|
|
154
|
-
if (cmd?.[relay + 1] !== EGRESS_SOCKET)
|
|
155
|
-
return { other: `init relays to ${show(cmd?.[relay + 1])}, not ${EGRESS_SOCKET}` };
|
|
156
|
-
const [only] = at;
|
|
157
|
-
if (at.length !== 1 || only?.Type !== "volume" || only.Name !== egressNameOf(name) || only.RW !== false) {
|
|
158
|
-
return { other: `the egress volume at ${EGRESS_MOUNT} is ${at.map(mountWords).join(", ")}, not ${egressNameOf(name)} read-only` };
|
|
159
|
-
}
|
|
160
|
-
return egressOf(proxy, { name, user: inspected?.Config?.User, deadline: inspected?.Config?.Labels?.[DEADLINE_LABEL], running: inspected?.State?.Running === true }, code, local);
|
|
161
|
-
}
|
|
162
|
-
/** Whether a policy read back is the one declared: the same string, or an allowlist with the same entries, normalized. */
|
|
163
|
-
export function samePolicy(declared, read) {
|
|
164
|
-
if (typeof declared === "string" || typeof read === "string")
|
|
165
|
-
return declared === read;
|
|
166
|
-
return "allow" in declared && "allow" in read && sameAllow(declared.allow, read.allow);
|
|
167
|
-
}
|
|
168
20
|
const isAddresses = (value) => Array.isArray(value) && value.every((one) => typeof one === "string");
|
|
169
21
|
const isId = (value) => typeof value === "number" && Number.isSafeInteger(value);
|
|
170
22
|
/**
|
|
@@ -209,30 +61,6 @@ export function probeNetworkDrift(probe) {
|
|
|
209
61
|
export function probeNotes(probe, network) {
|
|
210
62
|
return network === "none" && probe.accepted.length > 0 ? [`network: none; accepted with no answer (no bytes came back): ${probe.accepted.join(", ")}`] : [];
|
|
211
63
|
}
|
|
212
|
-
/** One mount as a person reads it: "a read-write bind of /runs/r1". */
|
|
213
|
-
const mountWords = (mount) => `a ${mount.RW === true ? "read-write" : "read-only"} ${mount.Type ?? "mount"} of ${mount.Source ?? mount.Name ?? "nothing"}`;
|
|
214
|
-
/**
|
|
215
|
-
* What is mounted at /workspace, read back from inspect: a read-write bind is the run's folder; nothing is undefined;
|
|
216
|
-
* anything else (read-only, a volume, two mounts) is reported in words, never as a bind it might be.
|
|
217
|
-
*/
|
|
218
|
-
export function mountOf(inspected, volume) {
|
|
219
|
-
const at = (inspected?.Mounts ?? []).filter((mount) => mount.Destination === WORKSPACE);
|
|
220
|
-
const [only] = at;
|
|
221
|
-
if (only === undefined)
|
|
222
|
-
return undefined;
|
|
223
|
-
if (volume === undefined && at.length === 1 && only.Type === "bind" && only.RW === true && typeof only.Source === "string")
|
|
224
|
-
return { kind: "bind", path: only.Source };
|
|
225
|
-
// With the provider's volume option, the folder is the volume's subpath, read read-write from HostConfig.Mounts, and
|
|
226
|
-
// reported as the path below the root create was given.
|
|
227
|
-
if (volume !== undefined && at.length === 1 && only.Type === "volume" && only.Name === volume.name && only.RW === true) {
|
|
228
|
-
const asked = (inspected?.HostConfig?.Mounts ?? []).filter((mount) => mount.Target === WORKSPACE);
|
|
229
|
-
const subpath = asked[0]?.VolumeOptions?.Subpath;
|
|
230
|
-
if (asked.length === 1 && asked[0]?.Type === "volume" && asked[0].Source === volume.name && typeof subpath === "string" && subpath !== "" && !subpath.split("/").includes("..")) {
|
|
231
|
-
return { kind: "bind", path: join(volume.root, subpath) };
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
return { other: `${at.map(mountWords).join(", ")} at ${WORKSPACE}` };
|
|
235
|
-
}
|
|
236
64
|
/** Every way hello differs from what the provider expects. */
|
|
237
65
|
export function helloDrift(hello, expected) {
|
|
238
66
|
const found = [];
|
|
@@ -266,160 +94,3 @@ export function helloDrift(hello, expected) {
|
|
|
266
94
|
found.push(`hello: the daemon offers groups ${extra.map(text).join(", ")}, which the provider does not declare`);
|
|
267
95
|
return found;
|
|
268
96
|
}
|
|
269
|
-
/** Every way a created computer differs from its spec, from inspect and hello. */
|
|
270
|
-
export function drift(spec, inspected, hello, expected) {
|
|
271
|
-
return [...inspectDrift(spec, inspected, expected), ...helloDrift(hello, expected)];
|
|
272
|
-
}
|
|
273
|
-
/** Every way a computer's docker inspect differs from its spec: the fields create asks for, and the closed check. */
|
|
274
|
-
export function inspectDrift(spec, inspected, expected) {
|
|
275
|
-
const found = [];
|
|
276
|
-
const mismatch = (field, declared, actual) => found.push(`${field}: declared ${show(declared)}, read back ${show(actual)}`);
|
|
277
|
-
const host = inspected?.HostConfig ?? {};
|
|
278
|
-
const config = inspected?.Config ?? {};
|
|
279
|
-
const network = networkOf(inspected, expected.proxy, expected.egressCode, expected.hostAddresses);
|
|
280
|
-
if (!samePolicy(spec.network, network))
|
|
281
|
-
found.push(`network: declared ${policyWords(spec.network)}, read back ${policyWords(network)}`);
|
|
282
|
-
const allowed = typeof spec.network === "object" && spec.network !== null && "allow" in spec.network;
|
|
283
|
-
const volume = egressNameOf((inspected?.Name ?? "").replace(/^\//, ""));
|
|
284
|
-
if (!sameList(host.CapDrop, ["ALL"]))
|
|
285
|
-
mismatch("CapDrop", ["ALL"], host.CapDrop);
|
|
286
|
-
if ((host.CapAdd ?? []).length > 0)
|
|
287
|
-
mismatch("CapAdd", [], host.CapAdd);
|
|
288
|
-
if (host.Privileged !== false)
|
|
289
|
-
mismatch("Privileged", false, host.Privileged);
|
|
290
|
-
if (!sameList(host.SecurityOpt, ["no-new-privileges"]))
|
|
291
|
-
mismatch("SecurityOpt", ["no-new-privileges"], host.SecurityOpt);
|
|
292
|
-
if (host.IpcMode !== "private")
|
|
293
|
-
mismatch("IpcMode", "private", host.IpcMode);
|
|
294
|
-
if (host.CgroupnsMode !== "private")
|
|
295
|
-
mismatch("CgroupnsMode", "private", host.CgroupnsMode);
|
|
296
|
-
if (host.Runtime !== "runc")
|
|
297
|
-
mismatch("Runtime", "runc", host.Runtime);
|
|
298
|
-
if (!holds(host.MaskedPaths, MASKED_PATHS))
|
|
299
|
-
found.push(`MaskedPaths: must hold Docker's ${show(MASKED_PATHS)}, read back ${show(host.MaskedPaths)}`);
|
|
300
|
-
if (!holds(host.ReadonlyPaths, READONLY_PATHS))
|
|
301
|
-
found.push(`ReadonlyPaths: must hold Docker's ${show(READONLY_PATHS)}, read back ${show(host.ReadonlyPaths)}`);
|
|
302
|
-
const pids = spec.pids ?? DEFAULT_PIDS;
|
|
303
|
-
if (host.PidsLimit !== pids)
|
|
304
|
-
mismatch("PidsLimit", pids, host.PidsLimit);
|
|
305
|
-
const memoryMb = spec.memoryMb ?? DEFAULT_MEMORY_MB;
|
|
306
|
-
const bytes = memoryMb * 1024 * 1024;
|
|
307
|
-
if (host.Memory !== bytes)
|
|
308
|
-
mismatch("Memory", bytes, host.Memory);
|
|
309
|
-
if (host.MemorySwap !== bytes)
|
|
310
|
-
mismatch("MemorySwap", bytes, host.MemorySwap);
|
|
311
|
-
if (host.CpuPeriod !== CPU_PERIOD_US)
|
|
312
|
-
mismatch("CpuPeriod", CPU_PERIOD_US, host.CpuPeriod);
|
|
313
|
-
const quota = Math.round((spec.cpus ?? DEFAULT_CPUS) * CPU_PERIOD_US);
|
|
314
|
-
if (host.CpuQuota !== quota)
|
|
315
|
-
mismatch("CpuQuota", quota, host.CpuQuota);
|
|
316
|
-
const tmpfs = host.Tmpfs ?? {};
|
|
317
|
-
const tmpfsAsked = tmpfsOf(expected.user, memoryMb);
|
|
318
|
-
for (const [path, options] of Object.entries(tmpfsAsked)) {
|
|
319
|
-
if (optionSet(tmpfs[path]) !== optionSet(options))
|
|
320
|
-
mismatch(`tmpfs ${path}`, options, tmpfs[path]);
|
|
321
|
-
}
|
|
322
|
-
for (const [path, options] of Object.entries(tmpfs)) {
|
|
323
|
-
if (!(path in tmpfsAsked))
|
|
324
|
-
found.push(`tmpfs ${path}: none declared but /work and /run/agentrun, read back ${show(options)}`);
|
|
325
|
-
}
|
|
326
|
-
// A Docker computer takes a bind alone; check() refuses any other kind, so one here is drift, named by its kind only.
|
|
327
|
-
if (spec.mount !== undefined && spec.mount.kind !== "bind")
|
|
328
|
-
found.push(`mount: declared a mount of kind ${String(spec.mount.kind)}, which a Docker computer never makes`);
|
|
329
|
-
const bound = spec.mount?.kind === "bind" ? spec.mount.path : undefined;
|
|
330
|
-
// In create's order: the daemon read-only, then the run's folder read-write at /workspace when one was asked for, then
|
|
331
|
-
// the egress volume read-only for an allowlist.
|
|
332
|
-
// With the provider's volume option the daemon and the folder are the volume's subpaths (mountAsked).
|
|
333
|
-
const shared = expected.volume;
|
|
334
|
-
// The daemon's file is bound at DAEMON_IN_COMPUTER; with the volume option its staged directory is at /opt/agentrun.
|
|
335
|
-
const daemonAt = shared === undefined ? DAEMON_IN_COMPUTER : DAEMON_DIR_IN_COMPUTER;
|
|
336
|
-
const daemonAsked = mountAsked(expected.daemonPath, daemonAt, true, shared);
|
|
337
|
-
const folderAsked = bound === undefined ? undefined : mountAsked(bound, WORKSPACE, false, shared);
|
|
338
|
-
if (daemonAsked === undefined)
|
|
339
|
-
found.push(`daemon mount: ${expected.daemonPath} is not below the volume root ${shared?.root}, so create never mounts it`);
|
|
340
|
-
if (bound !== undefined && folderAsked === undefined)
|
|
341
|
-
found.push(`workspace mount: ${bound} is not below the volume root ${shared?.root}, so create never mounts it`);
|
|
342
|
-
const asked = [
|
|
343
|
-
...(daemonAsked === undefined ? [] : [daemonAsked]),
|
|
344
|
-
...(folderAsked === undefined ? [] : [folderAsked]),
|
|
345
|
-
...(allowed ? [{ Type: "volume", Source: volume, Target: EGRESS_MOUNT, ReadOnly: true }] : []),
|
|
346
|
-
];
|
|
347
|
-
const hostMounts = host.Mounts ?? [];
|
|
348
|
-
// An object (VolumeOptions) is the same when it holds the same fields; any other value, exactly.
|
|
349
|
-
const same = (value, want) => typeof want === "object" && want !== null
|
|
350
|
-
? typeof value === "object" && value !== null && Object.entries(value).every(([key, item]) => (key in want ? same(item, want[key]) : blank(item))) && Object.keys(want).every((key) => key in value)
|
|
351
|
-
: value === want;
|
|
352
|
-
const sameMount = (made, want) => made !== undefined &&
|
|
353
|
-
Object.entries(made).every(([key, value]) => (key in want ? same(value, want[key]) : blank(value))) &&
|
|
354
|
-
Object.keys(want).every((key) => made[key] !== undefined);
|
|
355
|
-
if (hostMounts.length !== asked.length || !asked.every((want, i) => sameMount(hostMounts[i], want)))
|
|
356
|
-
mismatch("HostConfig.Mounts", asked, host.Mounts);
|
|
357
|
-
for (const [field, value] of Object.entries(host)) {
|
|
358
|
-
if (HOST_ASKED.has(field) || HOST_IRRELEVANT.has(field))
|
|
359
|
-
continue;
|
|
360
|
-
const rule = HOST_DEFAULTS[field];
|
|
361
|
-
if (rule ? !rule[0](value) : !blank(value))
|
|
362
|
-
found.push(`${field}: must be ${rule ? rule[1] : "Docker's default (empty)"}, read back ${show(value)}`);
|
|
363
|
-
}
|
|
364
|
-
if (config.User !== expected.user)
|
|
365
|
-
mismatch("User", expected.user, config.User);
|
|
366
|
-
if (config.Image !== spec.image)
|
|
367
|
-
mismatch("Image", spec.image, config.Image);
|
|
368
|
-
const workdir = spec.workdir ?? WORK;
|
|
369
|
-
if (config.WorkingDir !== workdir)
|
|
370
|
-
mismatch("WorkingDir", workdir, config.WorkingDir);
|
|
371
|
-
const homes = (Array.isArray(config.Env) ? config.Env : []).filter((entry) => typeof entry === "string" && entry.startsWith("HOME="));
|
|
372
|
-
if (!sameList(homes, [`HOME=${WORK}`]))
|
|
373
|
-
mismatch("Env HOME", [`HOME=${WORK}`], homes);
|
|
374
|
-
for (const [field, value] of Object.entries(config)) {
|
|
375
|
-
if (!CONFIG_ASKED.has(field) && !CONFIG_IRRELEVANT.has(field) && !blank(value))
|
|
376
|
-
found.push(`${field}: must be Docker's default (empty), read back ${show(value)}`);
|
|
377
|
-
}
|
|
378
|
-
const apparmor = expected.apparmor ? "docker-default" : "";
|
|
379
|
-
if ((inspected?.AppArmorProfile ?? "") !== apparmor)
|
|
380
|
-
mismatch("AppArmorProfile", apparmor, inspected?.AppArmorProfile);
|
|
381
|
-
const label = inspected?.ProcessLabel ?? "";
|
|
382
|
-
if (expected.selinux ? !/^[^:]*:[^:]*:container_t:/.test(label) : label !== "") {
|
|
383
|
-
mismatch("ProcessLabel", expected.selinux ? "the container_t type" : "", inspected?.ProcessLabel);
|
|
384
|
-
}
|
|
385
|
-
const mounts = inspected?.Mounts ?? [];
|
|
386
|
-
const daemon = mounts.filter((mount) => mount.Destination === daemonAt);
|
|
387
|
-
const [only] = daemon;
|
|
388
|
-
// A bind shows its source; the volume's subpath shows as the volume (its subpath is HostConfig.Mounts', checked above).
|
|
389
|
-
const fits = (mount, path, rw) => mount !== undefined &&
|
|
390
|
-
mount.RW === rw &&
|
|
391
|
-
(shared === undefined ? mount.Type === "bind" && mount.Source === path && ["", "rprivate", undefined].includes(mount.Propagation) : mount.Type === "volume" && mount.Name === shared.name);
|
|
392
|
-
const how = (path, rw, at) => `declared ${path} ${shared === undefined ? "bound" : `mounted from the volume ${shared.name}`} ${rw ? "read-write" : "read-only"} at ${at}`;
|
|
393
|
-
if (daemon.length !== 1 || !fits(only, expected.daemonPath, false)) {
|
|
394
|
-
found.push(`daemon mount: ${how(expected.daemonPath, false, daemonAt)}, read back ${show(daemon)}`);
|
|
395
|
-
}
|
|
396
|
-
if (bound !== undefined) {
|
|
397
|
-
const workspace = mounts.filter((mount) => mount.Destination === WORKSPACE);
|
|
398
|
-
const [one] = workspace;
|
|
399
|
-
if (workspace.length !== 1 || !fits(one, bound, true)) {
|
|
400
|
-
found.push(`workspace mount: ${how(bound, true, WORKSPACE)}, read back ${show(workspace)}`);
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
// The egress volume itself, its name, type and mode, is the network's read-back above.
|
|
404
|
-
const declared = ["the daemon's", ...(bound === undefined ? [] : ["the run folder's"]), ...(allowed ? ["the egress volume's"] : [])].join(" and ");
|
|
405
|
-
for (const mount of mounts) {
|
|
406
|
-
if (mount.Destination === daemonAt || (bound !== undefined && mount.Destination === WORKSPACE) || (allowed && mount.Destination === EGRESS_MOUNT))
|
|
407
|
-
continue;
|
|
408
|
-
found.push(`${mount.Type ?? "unknown"} mount: none declared but ${declared}, read back ${show(mount)}`);
|
|
409
|
-
}
|
|
410
|
-
if (!sameList(config.Entrypoint, [DAEMON_IN_COMPUTER]))
|
|
411
|
-
mismatch("Entrypoint", [DAEMON_IN_COMPUTER], config.Entrypoint);
|
|
412
|
-
const cmd = ["init", "--deadline", expected.deadline, ...(allowed ? [RELAY_FLAG, EGRESS_SOCKET] : [])];
|
|
413
|
-
if (!sameList(config.Cmd, cmd))
|
|
414
|
-
mismatch("Cmd", cmd, config.Cmd);
|
|
415
|
-
const labels = config.Labels ?? {};
|
|
416
|
-
if (labels[COMPUTER_LABEL] !== "1")
|
|
417
|
-
mismatch(`label ${COMPUTER_LABEL}`, "1", labels[COMPUTER_LABEL]);
|
|
418
|
-
if (labels[DEADLINE_LABEL] !== expected.deadline)
|
|
419
|
-
mismatch(`label ${DEADLINE_LABEL}`, expected.deadline, labels[DEADLINE_LABEL]);
|
|
420
|
-
for (const [key, value] of Object.entries(spec.labels ?? {})) {
|
|
421
|
-
if (labels[key] !== value)
|
|
422
|
-
mismatch(`label ${key}`, value, labels[key]);
|
|
423
|
-
}
|
|
424
|
-
return found;
|
|
425
|
-
}
|
package/dist/e2b.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { type DesktopOptions } from "./desktop.js";
|
|
|
2
2
|
import type { KindCapabilities } from "./kinds.js";
|
|
3
3
|
import { type MountKind } from "./mount.js";
|
|
4
4
|
import { type ProviderNote } from "./mount-archil.js";
|
|
5
|
-
import { type AttachedComputer, type CallContext, type ComputerCapabilities, type ComputerConnection, type ComputerInfo, type ComputerProvider, type ComputerRef, type ComputerSpec, type CreatedComputer, type
|
|
5
|
+
import { type AttachedComputer, type CallContext, type ComputerCapabilities, type ComputerConnection, type ComputerInfo, type ComputerProvider, type ComputerRef, type ComputerSpec, type CreatedComputer, type NetworkPolicy, type NetworkSpec, type Refusal, type ReleaseHow } from "./provider.js";
|
|
6
6
|
import { type ComputerErrorCode, type Result } from "./result.js";
|
|
7
7
|
import { type ScreenWatch, type ScreenWatchHandlers, type WatchOptions } from "./screen-watch.js";
|
|
8
8
|
/** What every SDK call is given: the key, the domain and the API URL explicitly, and debug false (index.mjs:1126-1152). */
|
|
@@ -208,14 +208,8 @@ export declare function connectionOptions({ apiKey, domain }: {
|
|
|
208
208
|
export declare function create(options: E2BOptions): Promise<E2BProvider>;
|
|
209
209
|
/** The conformance CLI's module for E2B: its live switch, the run's 30-minute cap, its template and the drifted twin. */
|
|
210
210
|
export declare const conformance: () => Promise<typeof import("./conformance/e2b.js")>;
|
|
211
|
-
/** E2B Desktop's template: a screen with an X server, the default for kind desktop. */
|
|
212
|
-
export declare const E2B_DESKTOP_TEMPLATE = "desktop";
|
|
213
|
-
/** E2B's plain template: no screen, the default for kind linux (a sandbox). */
|
|
214
|
-
export declare const E2B_BASE_TEMPLATE = "base";
|
|
215
211
|
/** The mount kinds an E2B computer takes, as capabilities().mount declares them: the run's folder on an Archil disk. */
|
|
216
212
|
export declare const MOUNT: readonly MountKind[];
|
|
217
|
-
/** The network an E2B computer's programs get: none, a network of their own (isolation.ts OWN_NETWORK_ONLY). */
|
|
218
|
-
export declare const NETWORK: readonly NetworkForm[];
|
|
219
213
|
/** The machine kind and groups of each configuration: kind linux (the plain template), and kind desktop (the default). */
|
|
220
214
|
export declare const CAPABILITIES: readonly KindCapabilities[];
|
|
221
215
|
/** The E2B timeout of the diagnostic's sandbox: E2B ends it at 10 minutes whatever happens to the run. */
|
|
@@ -335,5 +329,5 @@ export declare class E2BProvider implements ComputerProvider {
|
|
|
335
329
|
* whatever that answers. A folder not let go cleanly loses nothing (every call that changed it synced, and the next
|
|
336
330
|
* claim revokes the hold), so it is said through onNote, and the release succeeds once the sandbox is gone.
|
|
337
331
|
*/
|
|
338
|
-
release(ref: ComputerRef, how:
|
|
332
|
+
release(ref: ComputerRef, how: ReleaseHow, { signal }?: CallContext): Promise<Result<void>>;
|
|
339
333
|
}
|
package/dist/e2b.js
CHANGED
|
@@ -12,17 +12,20 @@ import { fileURLToPath } from "node:url";
|
|
|
12
12
|
import { childCommands, daemonDrift } from "./child.js";
|
|
13
13
|
import { OWN_NETWORK_ONLY, readOwnNetwork, TOOL_USER } from "./isolation.js";
|
|
14
14
|
import { DaemonClient } from "./client.js";
|
|
15
|
+
import { E2B, E2B_BASE_TEMPLATE, E2B_DESKTOP_TEMPLATE } from "./descriptors/e2b.js";
|
|
15
16
|
import { DESKTOP_GROUPS, desktopOf, startDisplay } from "./desktop.js";
|
|
16
17
|
import { COMPUTER_LABEL, DAEMON_IN_COMPUTER, DEADLINE_LABEL, helloDrift, probeNetworkDrift, probeNotes, probeReportOf, WORK } from "./drift.js";
|
|
17
18
|
import { releaseOlder } from "./janitor.js";
|
|
18
19
|
import { RUN_LABEL } from "./labels.js";
|
|
19
20
|
import { checkMount, readBackOf } from "./mount.js";
|
|
20
21
|
import { ARCHIL_HELPER, ARCHIL_MOUNT_LABEL, ARCHIL_TOOL_UID, archilLabels, archilMount, archilRefusals, archilRelease, claimEpoch, mountDrift, readArchilMount, recordedArchil as recordedArchilOf, recordedMount, syncingClient, } from "./mount-archil.js";
|
|
21
|
-
import { checkGpu,
|
|
22
|
-
import {
|
|
22
|
+
import { checkGpu, checkTenure, runLifetimeMs, } from "./provider.js";
|
|
23
|
+
import { failFor, ok, vendorFail } from "./result.js";
|
|
23
24
|
import { daemonWatch } from "./screen-watch.js";
|
|
24
25
|
import { countTested } from "./test-connection.js";
|
|
25
26
|
import { waitUntil } from "./wait.js";
|
|
27
|
+
/** This module's failures: one with code vendor names E2B. */
|
|
28
|
+
const fail = failFor("e2b");
|
|
26
29
|
/** Not a literal, so no type checker or bundler resolves the SDK from this package. */
|
|
27
30
|
const E2B_PACKAGE = "e2b";
|
|
28
31
|
const DEFAULT_DOMAIN = "e2b.app";
|
|
@@ -65,10 +68,6 @@ const VERSION = JSON.parse(readFileSync(new URL("../package.json", import.meta.u
|
|
|
65
68
|
const NAME = /^computer-[0-9a-f]{12}$/;
|
|
66
69
|
const SANDBOX_ID = /^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/;
|
|
67
70
|
const TEMPLATE = /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}$/;
|
|
68
|
-
/** E2B Desktop's template: a screen with an X server, the default for kind desktop. */
|
|
69
|
-
export const E2B_DESKTOP_TEMPLATE = "desktop";
|
|
70
|
-
/** E2B's plain template: no screen, the default for kind linux (a sandbox). */
|
|
71
|
-
export const E2B_BASE_TEMPLATE = "base";
|
|
72
71
|
const NAME_LABEL = `${COMPUTER_LABEL}.name`;
|
|
73
72
|
/** The template create was asked for: E2B reports its id, and the alias only sometimes. */
|
|
74
73
|
const IMAGE_LABEL = `${COMPUTER_LABEL}.image`;
|
|
@@ -99,16 +98,11 @@ const DEFAULTS = {
|
|
|
99
98
|
mountMs: 120_000,
|
|
100
99
|
};
|
|
101
100
|
/** The mount kinds an E2B computer takes, as capabilities().mount declares them: the run's folder on an Archil disk. */
|
|
102
|
-
export const MOUNT =
|
|
103
|
-
/** The network an E2B computer's programs get: none, a network of their own (isolation.ts OWN_NETWORK_ONLY). */
|
|
104
|
-
export const NETWORK = ["none"];
|
|
101
|
+
export const MOUNT = E2B.mounts;
|
|
105
102
|
/** The user an Archil computer's tools run as: the image's agentrun-tool, with no sudo and no capability. */
|
|
106
103
|
const ARCHIL_USER = `${ARCHIL_TOOL_UID}:${ARCHIL_TOOL_UID}`;
|
|
107
104
|
/** The machine kind and groups of each configuration: kind linux (the plain template), and kind desktop (the default). */
|
|
108
|
-
export const CAPABILITIES =
|
|
109
|
-
{ kind: "linux", groups: ["exec", "files", "processes"] },
|
|
110
|
-
{ kind: "desktop", groups: ["exec", "files", "processes", ...DESKTOP_GROUPS] },
|
|
111
|
-
];
|
|
105
|
+
export const CAPABILITIES = E2B.capabilities;
|
|
112
106
|
const RELEASE_POLL_MAX_MS = 5_000;
|
|
113
107
|
const LISTED_POLL_MS = 150;
|
|
114
108
|
const LISTED_ROUNDS = 2;
|
|
@@ -176,7 +170,7 @@ function codeOf(error) {
|
|
|
176
170
|
return "limit";
|
|
177
171
|
if (name === "TimeoutError" || name === "SandboxUnreachableError")
|
|
178
172
|
return "timeout";
|
|
179
|
-
return "
|
|
173
|
+
return "vendor";
|
|
180
174
|
}
|
|
181
175
|
/** Settles with the promise's result, or a timeout or abort in words once ms pass or signal aborts. */
|
|
182
176
|
function race(promise, what, ms, signal) {
|
|
@@ -408,7 +402,7 @@ export class E2BProvider {
|
|
|
408
402
|
return {
|
|
409
403
|
kind: this.#kind,
|
|
410
404
|
lifetime: "vendor",
|
|
411
|
-
network: [...
|
|
405
|
+
network: [...E2B.network],
|
|
412
406
|
networkReadBack: true,
|
|
413
407
|
isolation: "microvm",
|
|
414
408
|
os: "linux",
|
|
@@ -432,7 +426,7 @@ export class E2BProvider {
|
|
|
432
426
|
}
|
|
433
427
|
if (typeof image !== "string" || !TEMPLATE.test(image))
|
|
434
428
|
refuse("image", `an image is required: the name or id of an E2B template, such as "${E2B_DESKTOP_TEMPLATE}" (E2B Desktop) or "${E2B_BASE_TEMPLATE}"`);
|
|
435
|
-
refusals.push(...
|
|
429
|
+
refusals.push(...checkTenure(given, this.capabilities(), "E2B"));
|
|
436
430
|
if (network === "open" || (typeof network === "object" && network !== null && "allow" in network))
|
|
437
431
|
refuse("network", OWN_NETWORK_ONLY);
|
|
438
432
|
else if (network !== "none")
|
|
@@ -492,10 +486,10 @@ export class E2BProvider {
|
|
|
492
486
|
return fail("aborted", "create was aborted before E2B was called");
|
|
493
487
|
const name = `computer-${randomBytes(6).toString("hex")}`;
|
|
494
488
|
const now = Date.now();
|
|
495
|
-
const deadline = new Date(now + spec
|
|
489
|
+
const deadline = new Date(now + runLifetimeMs(spec)).toISOString();
|
|
496
490
|
const maxDeadline = new Date(now + this.#maxLifetimeMs).toISOString();
|
|
497
491
|
// E2B kills the sandbox at its timeout, the lifetime in the whole seconds it takes (index.mjs:502-504).
|
|
498
|
-
const timeoutMs = Math.ceil(spec
|
|
492
|
+
const timeoutMs = Math.ceil(runLifetimeMs(spec) / 1000) * 1000;
|
|
499
493
|
const metadata = {
|
|
500
494
|
...spec.labels,
|
|
501
495
|
[COMPUTER_LABEL]: "1",
|
|
@@ -923,7 +917,7 @@ export class E2BProvider {
|
|
|
923
917
|
return fail("timeout", `the daemon in ${name} did not answer hello within ${seconds(helloMs)}`);
|
|
924
918
|
if (hello.error.code !== "gone")
|
|
925
919
|
return hello;
|
|
926
|
-
return { ...
|
|
920
|
+
return { ...vendorFail("e2b", `cannot reach the daemon in ${name}: ${stderr.trim() || hello.error.message}`), notListening: true };
|
|
927
921
|
}
|
|
928
922
|
return ok({ client, hello: hello.value, close });
|
|
929
923
|
}
|
|
@@ -1166,13 +1160,13 @@ export class E2BProvider {
|
|
|
1166
1160
|
const found = new Map();
|
|
1167
1161
|
for (let page = 0; paginator.hasNext; page++) {
|
|
1168
1162
|
if (page >= MAX_PAGES)
|
|
1169
|
-
return
|
|
1163
|
+
return vendorFail("e2b", `Sandbox.list ran past ${MAX_PAGES} pages`);
|
|
1170
1164
|
const left = Math.max(1, until - Date.now());
|
|
1171
1165
|
const items = await call("Sandbox.list", () => paginator.nextItems({ requestTimeoutMs: Math.min(requestMs, left), ...(signal ? { signal } : {}) }), left, signal);
|
|
1172
1166
|
if (!items.ok)
|
|
1173
1167
|
return boundBy(items, given === undefined ? undefined : left, requestMs);
|
|
1174
1168
|
if (!Array.isArray(items.value))
|
|
1175
|
-
return
|
|
1169
|
+
return vendorFail("e2b", "Sandbox.list: a page that is not a list of sandboxes");
|
|
1176
1170
|
for (const sb of items.value)
|
|
1177
1171
|
if (typeof sb?.sandboxId === "string")
|
|
1178
1172
|
found.set(sb.sandboxId, sb);
|
|
@@ -1197,7 +1191,7 @@ export class E2BProvider {
|
|
|
1197
1191
|
if (!items.ok)
|
|
1198
1192
|
return countTested("E2B", fail(items.error.code, items.error.message));
|
|
1199
1193
|
if (!Array.isArray(items.value))
|
|
1200
|
-
return countTested("E2B",
|
|
1194
|
+
return countTested("E2B", vendorFail("e2b", "Sandbox.list: a page that is not a list of sandboxes"));
|
|
1201
1195
|
const count = items.value.filter((sb) => typeof sb?.sandboxId === "string" && ours(sb.metadata)).length;
|
|
1202
1196
|
return countTested("E2B", ok({ count, more: paginator.hasNext }));
|
|
1203
1197
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,23 +7,20 @@ export { type ActionFailure, type CheckActionsOptions, checkActions, isKey } fro
|
|
|
7
7
|
export { pullTar, pullTarStream, pushTar, readFile, writeFile, type PulledTar } from "./files.js";
|
|
8
8
|
export { listProcesses, readAll, type ReadAllResult } from "./processes.js";
|
|
9
9
|
export { type ActionMapper, createActionMapper, daemonWatch, redactWords, type ScreenFrame, type ScreenFrames, type ScreenWatch, ScreenWatchError, type ScreenWatchHandlers, toAction, type ViewerEvent, type WatchEndCode, watchEndCode, type WatchOptions, watchScreen, } from "./screen-watch.js";
|
|
10
|
-
export { type DockerDesktopOptions, type DockerEgressOptions, DockerProvider, type DockerProviderOptions } from "./docker.js";
|
|
11
10
|
export { type DockerVolume, VOLUME_SUBPATH_ENGINE } from "./docker/volume.js";
|
|
12
11
|
export { DEFAULT_DOCKER_IMAGE, DOCKER_BASE, DOCKER_RECIPE, DOCKER_RECIPE_HAS, ensureImage, type EnsureImageOptions, IMAGE_REPOSITORY, IMAGE_TIMEOUT_MS, type ImageSource, imageSourceProblem, type Making, RECIPE_LABEL, recipeHash, recipeTag, } from "./docker/image.js";
|
|
13
12
|
export { EGRESS_IMAGE, EGRESS_LABEL, EGRESS_MOUNT, EGRESS_SOCKET } from "./docker/egress.js";
|
|
14
|
-
export { DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU_SNAPSHOT, DaytonaProvider, type DaytonaProviderOptions, type DaytonaTimeouts, type WebSocketFactory, type WebSocketLike } from "./daytona.js";
|
|
15
|
-
export { ModalProvider, type ModalApp, type ModalByteSink, type ModalCreateParams, type ModalImage, type ModalProcess, type ModalProviderOptions, type ModalSandbox, type ModalSdk, type ModalTimeouts, } from "./modal.js";
|
|
16
13
|
export { ARCHIL_HELPER, ARCHIL_MOUNT_LABEL, ARCHIL_SYNC_SOCKET, ARCHIL_TOOL_UID, ARCHIL_TOOL_USER, ARCHIL_VERSION, type ArchilMount, type ArchilMountOptions, type ArchilRoot, type ProviderNote, archilLabels, archilMount, archilReadBack, archilRefusals, archilRelease, claimEpoch, helperSha256, mountDrift, mountWords, type RecordedArchil, readArchilMount, recordedArchil, recordedMount, syncingClient, } from "./mount-archil.js";
|
|
17
|
-
export {
|
|
18
|
-
export { BROWSERBASE_API_URL, BROWSERBASE_MAX_LIFETIME_MS, type BrowserbaseApi, type BrowserbaseDebug, BrowserbaseProvider, type BrowserbaseProviderOptions, type BrowserbaseSession, type BrowserbaseSessionSettings, browserbaseRest, } from "./browserbase.js";
|
|
19
|
-
export { KERNEL_API_URL, KERNEL_MAX_LIFETIME_MS, type KernelBrowserSettings, KernelProvider, type KernelProviderOptions, type KernelRequest, kernelRest } from "./kernel.js";
|
|
20
|
-
export { LOCAL_MAX_LIFETIME_MS, LocalBrowserProvider, type LocalBrowserOptions } from "./local.js";
|
|
14
|
+
export { type BrowserStream, BrowserVendorError, CREATE_LABEL, causeOf, memoryUrls, RECOVER_MS, type ReleaseConfirm, type RestReply, type UrlStore, } from "./browser.js";
|
|
21
15
|
export { CHROME_ENV, CHROME_FLAGS, checkChrome, chromeFence, findChrome, killTree, NO_CHROME } from "./chrome.js";
|
|
22
|
-
export { DAEMON_IN_COMPUTER,
|
|
16
|
+
export { DAEMON_IN_COMPUTER, helloDrift, type HelloExpected } from "./drift.js";
|
|
17
|
+
export { drift, hostOf, inspectDrift, mountOf, networkOf, type DockerHost, type DockerInfo, type DockerInspect, type DriftExpected } from "./docker/inspect.js";
|
|
23
18
|
export { type ReleasedOlder, releaseOlder, sweep, type SweepOptions, type Swept } from "./janitor.js";
|
|
24
|
-
export { EPOCH_LABEL, epochOf, epochProblem, RUN_HASH_LABEL, RUN_LABEL, runHash, runLabels, runProblem } from "./labels.js";
|
|
19
|
+
export { EPOCH_LABEL, epochOf, epochProblem, IDLE_TTL_LABEL, OWNER_LABEL, ownerLabels, ownerOf, RUN_HASH_LABEL, RUN_LABEL, runHash, runLabels, runProblem } from "./labels.js";
|
|
25
20
|
export { waitUntil, type WaitOptions } from "./wait.js";
|
|
26
|
-
export { type ConformanceModule, isProviderId, type ProviderEnv, providerFor, type ProviderId, providerIds, type ProviderModule, providerModule, type ProviderOptions, providers, } from "./providers.js";
|
|
21
|
+
export { type BuiltinProviderId, type ConformanceModule, descriptorOf, isProviderId, type ProviderEnv, providerFor, type ProviderId, providerIds, type ProviderModule, providerModule, type ProviderOptions, providers, } from "./providers.js";
|
|
22
|
+
export { type DescriptorKey, type DescriptorSetting, defineProvider, descriptorProblems, type ParkedConfiguration, type ProviderDescriptor } from "./descriptor.js";
|
|
23
|
+
export { BROWSER_IMAGE, BROWSERBASE, DAYTONA, DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU_SNAPSHOT, DESCRIPTORS, DOCKER, E2B, E2B_BASE_TEMPLATE, E2B_DESKTOP_TEMPLATE, KERNEL, LOCAL, MODAL, MODAL_DEFAULT_IMAGE, ORGO, ORGO_BASE_IMAGE, PHONE_GROUPS, PHONE_HARNESS, PHONE_IMAGE, } from "./descriptors/index.js";
|
|
27
24
|
export type { PhoneLedger, PhoneLedgerEntry } from "./phone-harness.js";
|
|
28
|
-
export { type ComputerSettingKind, type KindCapabilities, kindOf, type ProviderEntry,
|
|
25
|
+
export { type ComputerSettingKind, configurationOf, entryOf, imagesOf, type KindCapabilities, kindOf, type ProviderEntry, PROVIDERS, SETTING_KIND_NAMES, SETTING_KINDS, type SettingKindSpec, serves, servingRefusals, type TestConnection, type TestConnectionOptions, } from "./kinds.js";
|
|
29
26
|
export * from "./conformance/index.js";
|
package/dist/index.js
CHANGED
|
@@ -7,22 +7,24 @@ export { checkActions, isKey } from "./actions.js";
|
|
|
7
7
|
export { pullTar, pullTarStream, pushTar, readFile, writeFile } from "./files.js";
|
|
8
8
|
export { listProcesses, readAll } from "./processes.js";
|
|
9
9
|
export { createActionMapper, daemonWatch, redactWords, ScreenWatchError, toAction, watchEndCode, watchScreen, } from "./screen-watch.js";
|
|
10
|
-
|
|
10
|
+
// The provider classes and their option types are not here: each provider loads by its id through the registry
|
|
11
|
+
// (providerFor), or from its own subpath (@parcha/agentrun-computer/docker, /daytona, /modal, /e2b, /orgo,
|
|
12
|
+
// /phone-harness, /browserbase, /kernel, /local: each the provider file's name).
|
|
11
13
|
export { VOLUME_SUBPATH_ENGINE } from "./docker/volume.js";
|
|
12
14
|
export { DEFAULT_DOCKER_IMAGE, DOCKER_BASE, DOCKER_RECIPE, DOCKER_RECIPE_HAS, ensureImage, IMAGE_REPOSITORY, IMAGE_TIMEOUT_MS, imageSourceProblem, RECIPE_LABEL, recipeHash, recipeTag, } from "./docker/image.js";
|
|
13
15
|
export { EGRESS_IMAGE, EGRESS_LABEL, EGRESS_MOUNT, EGRESS_SOCKET } from "./docker/egress.js";
|
|
14
|
-
export { DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU_SNAPSHOT, DaytonaProvider } from "./daytona.js";
|
|
15
|
-
export { ModalProvider, } from "./modal.js";
|
|
16
16
|
export { ARCHIL_HELPER, ARCHIL_MOUNT_LABEL, ARCHIL_SYNC_SOCKET, ARCHIL_TOOL_UID, ARCHIL_TOOL_USER, ARCHIL_VERSION, archilLabels, archilMount, archilReadBack, archilRefusals, archilRelease, claimEpoch, helperSha256, mountDrift, mountWords, readArchilMount, recordedArchil, recordedMount, syncingClient, } from "./mount-archil.js";
|
|
17
|
-
export {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export { LOCAL_MAX_LIFETIME_MS, LocalBrowserProvider } from "./local.js";
|
|
17
|
+
export { BrowserVendorError, CREATE_LABEL, causeOf, memoryUrls, RECOVER_MS, } from "./browser.js";
|
|
18
|
+
// Local Chrome's provider class is on its provider id's subpath (@parcha/agentrun-computer/local-chrome), as every
|
|
19
|
+
// provider's is; the Chrome helpers it runs on are not a provider and stay here.
|
|
21
20
|
export { CHROME_ENV, CHROME_FLAGS, checkChrome, chromeFence, findChrome, killTree, NO_CHROME } from "./chrome.js";
|
|
22
|
-
export { DAEMON_IN_COMPUTER,
|
|
21
|
+
export { DAEMON_IN_COMPUTER, helloDrift } from "./drift.js";
|
|
22
|
+
export { drift, hostOf, inspectDrift, mountOf, networkOf } from "./docker/inspect.js";
|
|
23
23
|
export { releaseOlder, sweep } from "./janitor.js";
|
|
24
|
-
export { EPOCH_LABEL, epochOf, epochProblem, RUN_HASH_LABEL, RUN_LABEL, runHash, runLabels, runProblem } from "./labels.js";
|
|
24
|
+
export { EPOCH_LABEL, epochOf, epochProblem, IDLE_TTL_LABEL, OWNER_LABEL, ownerLabels, ownerOf, RUN_HASH_LABEL, RUN_LABEL, runHash, runLabels, runProblem } from "./labels.js";
|
|
25
25
|
export { waitUntil } from "./wait.js";
|
|
26
|
-
export { isProviderId, providerFor, providerIds, providerModule, providers, } from "./providers.js";
|
|
27
|
-
export {
|
|
26
|
+
export { descriptorOf, isProviderId, providerFor, providerIds, providerModule, providers, } from "./providers.js";
|
|
27
|
+
export { defineProvider, descriptorProblems } from "./descriptor.js";
|
|
28
|
+
export { BROWSER_IMAGE, BROWSERBASE, DAYTONA, DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU_SNAPSHOT, DESCRIPTORS, DOCKER, E2B, E2B_BASE_TEMPLATE, E2B_DESKTOP_TEMPLATE, KERNEL, LOCAL, MODAL, MODAL_DEFAULT_IMAGE, ORGO, ORGO_BASE_IMAGE, PHONE_GROUPS, PHONE_HARNESS, PHONE_IMAGE, } from "./descriptors/index.js";
|
|
29
|
+
export { configurationOf, entryOf, imagesOf, kindOf, PROVIDERS, SETTING_KIND_NAMES, SETTING_KINDS, serves, servingRefusals, } from "./kinds.js";
|
|
28
30
|
export * from "./conformance/index.js";
|
package/dist/isolation.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// raise them, holding no CAP_NET_ADMIN, and the read-back here proves it through computerd's probe. Network "none" is
|
|
8
8
|
// all such a computer takes until a proxy carries open and allowlists out of that namespace.
|
|
9
9
|
import { DAEMON_IN_COMPUTER } from "./drift.js";
|
|
10
|
-
import { fail, ok } from "./result.js";
|
|
10
|
+
import { fail, failAs, ok } from "./result.js";
|
|
11
11
|
/** The uid:gid the programs of a remote computer run as by default: the box image's agentrun-tool, no sudo. */
|
|
12
12
|
export const TOOL_USER = "2510:2510";
|
|
13
13
|
/** Why a remote provider refuses network open or an allowlist, in words. */
|
|
@@ -42,7 +42,7 @@ export function probeOwnNetworkDrift(report) {
|
|
|
42
42
|
export async function readOwnNetwork(client, timeoutMs, signal) {
|
|
43
43
|
const ran = await client.call("exec.run", { argv: [DAEMON_IN_COMPUTER, "probe"], timeoutMs }, signal ? { signal } : undefined);
|
|
44
44
|
if (!ran.ok)
|
|
45
|
-
return
|
|
45
|
+
return failAs(ran.error, `reading the computer's own network back (computerd probe): ${ran.error.message}`);
|
|
46
46
|
const out = Buffer.from(ran.value.stdout, "base64").toString("utf8");
|
|
47
47
|
if (ran.value.exitCode !== 0)
|
|
48
48
|
return fail("refused", `computerd probe, reading the computer's own network back, exited ${ran.value.exitCode}: ${Buffer.from(ran.value.stderr, "base64").toString("utf8").trim().slice(0, 300)}`);
|