@parcha/agentrun-computer 0.1.0-beta.37 → 0.1.0-beta.39
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 +341 -260
- package/box/Dockerfile +18 -1
- package/box/README.md +14 -0
- package/box/build-daytona.py +2 -2
- package/box/build-e2b.mjs +41 -18
- package/box/recipe.d.mts +5 -0
- package/box/recipe.mjs +43 -0
- package/dist/agent37.d.ts +18 -66
- package/dist/agent37.js +187 -464
- package/dist/box-image.d.ts +14 -0
- package/dist/box-image.js +24 -0
- package/dist/browserbase.d.ts +0 -6
- package/dist/browserbase.js +1 -5
- package/dist/client.d.ts +12 -3
- package/dist/client.js +39 -4
- package/dist/computerd-linux-amd64 +0 -0
- package/dist/computerd-linux-arm64 +0 -0
- package/dist/computerd.json +4 -0
- package/dist/conformance/agent37.d.ts +9 -4
- package/dist/conformance/agent37.js +23 -11
- package/dist/conformance/browserbase.js +3 -3
- package/dist/conformance/cases/apps.d.ts +6 -0
- package/dist/conformance/cases/apps.js +18 -5
- package/dist/conformance/cases/isolation.d.ts +22 -5
- package/dist/conformance/cases/isolation.js +97 -16
- package/dist/conformance/cases/mount.js +5 -3
- package/dist/conformance/cases/provider.js +41 -0
- package/dist/conformance/cli.js +72 -11
- package/dist/conformance/daytona.d.ts +9 -20
- package/dist/conformance/daytona.js +12 -21
- package/dist/conformance/e2b.js +9 -4
- package/dist/conformance/exec-stream.d.ts +52 -0
- package/dist/conformance/exec-stream.js +493 -0
- package/dist/conformance/kernel.js +2 -2
- package/dist/conformance/modal.js +1 -1
- package/dist/conformance/orgo.js +2 -2
- package/dist/conformance/sweep.js +8 -8
- package/dist/conformance/types.d.ts +2 -2
- package/dist/create-requests.d.ts +1 -1
- package/dist/daytona.d.ts +17 -133
- package/dist/daytona.js +396 -1452
- package/dist/descriptor.d.ts +11 -4
- package/dist/descriptor.js +7 -0
- package/dist/descriptors/agent37.d.ts +3 -11
- package/dist/descriptors/agent37.js +9 -10
- package/dist/descriptors/daytona.d.ts +7 -6
- package/dist/descriptors/daytona.js +14 -7
- package/dist/descriptors/docker.d.ts +13 -1
- package/dist/descriptors/docker.js +3 -1
- package/dist/descriptors/e2b.d.ts +2 -9
- package/dist/descriptors/e2b.js +8 -8
- package/dist/descriptors/index.d.ts +25 -24
- package/dist/descriptors/index.js +1 -3
- package/dist/descriptors/modal.d.ts +2 -6
- package/dist/descriptors/modal.js +8 -6
- package/dist/descriptors/orgo.js +2 -1
- package/dist/descriptors/shared.d.ts +1 -1
- package/dist/descriptors/shared.js +2 -2
- package/dist/desktop.d.ts +18 -4
- package/dist/desktop.js +89 -9
- package/dist/docker/egress-main.js +23 -15
- package/dist/docker/egress.d.ts +6 -4
- package/dist/docker/egress.js +24 -16
- package/dist/docker/inspect.d.ts +2 -2
- package/dist/docker/inspect.js +5 -5
- package/dist/docker.d.ts +6 -11
- package/dist/docker.js +13 -16
- package/dist/drift.js +4 -4
- package/dist/e2b.d.ts +22 -130
- package/dist/e2b.js +163 -243
- package/dist/host.d.ts +136 -104
- package/dist/host.js +8 -1
- package/dist/hosted/network.d.ts +23 -0
- package/dist/hosted/network.js +77 -0
- package/dist/hosted/process.d.ts +24 -8
- package/dist/hosted/process.js +80 -44
- package/dist/hosted/provider.d.ts +38 -22
- package/dist/hosted/provider.js +500 -341
- package/dist/hosted/rest.d.ts +74 -0
- package/dist/hosted/rest.js +126 -0
- package/dist/hosted/scripts.d.ts +21 -3
- package/dist/hosted/scripts.js +76 -14
- package/dist/hosted/ssh-exec.d.ts +99 -0
- package/dist/hosted/ssh-exec.js +464 -0
- package/dist/hosted/values.d.ts +26 -0
- package/dist/hosted/values.js +63 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/isolation.d.ts +0 -2
- package/dist/isolation.js +3 -4
- package/dist/kernel.d.ts +0 -6
- package/dist/kernel.js +1 -5
- package/dist/kinds.d.ts +3 -1
- package/dist/local-chrome.d.ts +0 -6
- package/dist/local-chrome.js +1 -5
- package/dist/modal.d.ts +15 -86
- package/dist/modal.js +67 -185
- package/dist/mount-archil.d.ts +13 -8
- package/dist/mount-archil.js +27 -17
- package/dist/mount.d.ts +10 -4
- package/dist/mount.js +8 -4
- package/dist/orgo.d.ts +0 -9
- package/dist/orgo.js +8 -13
- package/dist/phone-harness.d.ts +0 -6
- package/dist/phone-harness.js +0 -4
- package/dist/protocol.d.ts +4 -1
- package/dist/protocol.js +1 -0
- package/dist/provider.d.ts +2 -2
- package/dist/providers.d.ts +15 -13
- package/dist/screen-watch.js +34 -6
- package/dist/surface/api.d.ts +14 -11
- package/dist/surface/core.d.ts +23 -5
- package/dist/surface/core.js +105 -15
- package/dist/surface/index.d.ts +1 -1
- package/dist/surface/index.js +1 -1
- package/dist/surface/outline.d.ts +2 -0
- package/dist/surface/outline.js +2 -1
- package/dist/surface/script.d.ts +4 -0
- package/dist/surface/script.js +11 -3
- package/dist/ui-engine.js +19 -3
- package/package.json +2 -3
- package/box/build-agent37.mjs +0 -177
- package/dist/conformance/daytona-sweep.d.ts +0 -18
- package/dist/conformance/daytona-sweep.js +0 -126
|
@@ -14,7 +14,7 @@ import { randomBytes } from "node:crypto";
|
|
|
14
14
|
import { EPOCH_LABEL, RUN_LABEL, runLabels as claimLabels } from "../../labels.js";
|
|
15
15
|
import { MOUNT_KINDS, readBackOf, WORKSPACE } from "../../mount.js";
|
|
16
16
|
import { MAX_OUTPUT_BYTES } from "../../protocol.js";
|
|
17
|
-
import { assertIsolated } from "./isolation.js";
|
|
17
|
+
import { assertIsolated, assertRootRunsClosed } from "./isolation.js";
|
|
18
18
|
import { b64, CASE_LABEL, decode } from "./util.js";
|
|
19
19
|
/** The claim epoch the run-folder cases make their computers under. */
|
|
20
20
|
const EPOCH = 1;
|
|
@@ -169,7 +169,7 @@ const archilToken = mount("archil-token", async (t) => {
|
|
|
169
169
|
}, { needs: ["mount:archil", "exec"], timeoutMs: 600_000 });
|
|
170
170
|
/**
|
|
171
171
|
* "isolated, and durable through the root side", on one Archil computer: a tool sees loopback alone and reaches neither a
|
|
172
|
-
* vendor's agent nor any address; and a tool's write in /workspace, by a program (exec.run) and by files.write, is read
|
|
172
|
+
* vendor's agent nor any address, and can write nothing root runs; and a tool's write in /workspace, by a program (exec.run) and by files.write, is read
|
|
173
173
|
* through the disk's file API right after the call returns, with no checkin. So the per-call sync goes out from the
|
|
174
174
|
* archil client and serve, which run as root outside the tools' namespace.
|
|
175
175
|
*/
|
|
@@ -178,8 +178,10 @@ const archilIsolatedDurable = mount("archil-isolated-durable", async (t) => {
|
|
|
178
178
|
const { ref } = await mounted(t, folder, EPOCH, "mount-archil-isolated-durable");
|
|
179
179
|
const connected = await t.connect(ref);
|
|
180
180
|
// isolation.vendor-agent's own check, on this Archil computer: lo alone, refused at the vendor's agent and outside,
|
|
181
|
-
// and no
|
|
181
|
+
// and no unix socket a tool connects to but the computer's own (computerd's, the sync socket).
|
|
182
182
|
await assertIsolated(t, connected.client);
|
|
183
|
+
// isolation.root-runs' check too, where the Archil helper and client are there to check.
|
|
184
|
+
await assertRootRunsClosed(t, connected.client);
|
|
183
185
|
const nonce = randomBytes(6).toString("hex");
|
|
184
186
|
const ran = await t.exec(["sh", "-c", `printf '%s\\n' ${nonce} > exec-${nonce}.txt`], { cwd: WORKSPACE }, connected.client);
|
|
185
187
|
t.equal(ran.exitCode, 0, `a program's write at ${WORKSPACE}: its exit code (${ran.err.trim()})`);
|
|
@@ -10,6 +10,24 @@ import { computerNameFor, runLifetimeMs } from "../../provider.js";
|
|
|
10
10
|
import { b64, CASE_LABEL, decode } from "./util.js";
|
|
11
11
|
/** Labels for one case's computers: the run's, and the case's own. */
|
|
12
12
|
const own = (t, name) => ({ ...t.runLabels, [CASE_LABEL]: name });
|
|
13
|
+
/** Gets url with curl as the computer's user, through the proxy its programs are told of (no host bypasses it): curl's exit,
|
|
14
|
+
* the HTTP code and the CONNECT code. Undefined, observed, on a computer that is not Linux with exec, or where the image
|
|
15
|
+
* has no curl or no proxy is set. */
|
|
16
|
+
const CURL = `command -v curl >/dev/null 2>&1 || { echo nocurl; exit 0; }; [ -n "\${HTTPS_PROXY:-\${https_proxy:-}}" ] || { echo noproxy; exit 0; }; c=$(curl -sS -o /dev/null --noproxy '' --max-time 30 -w '%{http_code} %{http_connect}' "$1" 2>/dev/null); echo "$? $c"`;
|
|
17
|
+
async function curled(t, { client, hello }, url) {
|
|
18
|
+
if (hello.os !== "linux" || !hello.groups.includes("exec")) {
|
|
19
|
+
t.observe(`the computer runs ${hello.os}${hello.groups.includes("exec") ? "" : " with no exec"}, so the egress proxy's answers were not read with curl`);
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
const ran = t.ok(await client.call("exec.run", { argv: ["sh", "-c", CURL, "sh", url], timeoutMs: 60_000 }), `curl ${url}`);
|
|
23
|
+
const out = decode(ran.stdout).trim();
|
|
24
|
+
if (out === "nocurl" || out === "noproxy") {
|
|
25
|
+
t.observe(out === "nocurl" ? "the image has no curl, so the egress proxy's answers were not read" : "no proxy is set for the computer's programs: its open network is the vendor's own, with no egress proxy to read");
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
const [exit, code, connect] = out.split(" ");
|
|
29
|
+
return { exit: Number(exit), code: code ?? "", connect: connect ?? "" };
|
|
30
|
+
}
|
|
13
31
|
const names = async (t, labels) => t
|
|
14
32
|
.ok(await t.provider.list(labels), `list ${JSON.stringify(labels)}`)
|
|
15
33
|
.map((info) => info.ref.name)
|
|
@@ -343,11 +361,34 @@ export const providerCases = [
|
|
|
343
361
|
t.deepEqual(t.ok(await t.provider.list(labels), "list").map((info) => info.network), ["open"], "the network list reads back");
|
|
344
362
|
const connected = await t.connect(ref);
|
|
345
363
|
t.deepEqual(t.ok(await connected.client.call("ping", {}), "ping"), {}, "ping in an open computer");
|
|
364
|
+
// Where open goes through an egress proxy (the programs are told of one), it reaches the public internet alone:
|
|
365
|
+
// a name, with no resolver of the programs' own, and never metadata, a private address or the vendor's agent.
|
|
366
|
+
const web = await curled(t, connected, "https://example.com/");
|
|
367
|
+
if (web === undefined)
|
|
368
|
+
return;
|
|
369
|
+
t.equal(`${web.exit} ${web.code}`, "0 200", "curl by name to https://example.com/ through the egress proxy");
|
|
370
|
+
const refusedTargets = [
|
|
371
|
+
["http://169.254.169.254/latest/meta-data/", "metadata (169.254.169.254), plain HTTP"],
|
|
372
|
+
["https://169.254.169.254/", "metadata (169.254.169.254), CONNECT"],
|
|
373
|
+
["https://10.0.0.1/", "a private address"],
|
|
374
|
+
...(t.provider.capabilities().vendorAgentPorts ?? []).map((port) => [`http://127.0.0.1:${port}/`, `the vendor's agent's port ${port} on the loopback`]),
|
|
375
|
+
];
|
|
376
|
+
for (const [url, what] of refusedTargets) {
|
|
377
|
+
const refused = await curled(t, connected, url);
|
|
378
|
+
t.assert(refused !== undefined && (refused.code === "403" || refused.connect === "403"), `${what}: the egress proxy refuses ${url} with 403, not ${JSON.stringify(refused)}`);
|
|
379
|
+
}
|
|
346
380
|
}, { level: "full", needs: ["network:open"] }),
|
|
347
381
|
provider("network-allow", async (t) => {
|
|
348
382
|
const policy = { allow: ["example.com"] };
|
|
349
383
|
const ref = await t.create({ labels: own(t, "allow"), network: policy });
|
|
350
384
|
t.deepEqual(t.ok(await t.provider.network(ref), "network read-back"), policy, "the allowlist read back");
|
|
385
|
+
const connected = await t.connect(ref);
|
|
386
|
+
const listed = await curled(t, connected, "https://example.com/");
|
|
387
|
+
if (listed === undefined)
|
|
388
|
+
return;
|
|
389
|
+
t.equal(`${listed.exit} ${listed.code}`, "0 200", "curl by name to https://example.com/, on the list, through the egress proxy");
|
|
390
|
+
const off = await curled(t, connected, "https://example.org/");
|
|
391
|
+
t.equal(off?.connect, "403", "https://example.org/, off the list: the egress proxy refuses its CONNECT with 403");
|
|
351
392
|
}, { level: "full", needs: ["network:allow"] }),
|
|
352
393
|
provider("deadline", async (t) => {
|
|
353
394
|
const labels = own(t, "deadline");
|
package/dist/conformance/cli.js
CHANGED
|
@@ -3,13 +3,16 @@
|
|
|
3
3
|
// Exits 0 when Core passes, 1 when it fails, 2 on a usage error, and 3 when --only left Core cases out and every case
|
|
4
4
|
// that ran passed: a partial run is never a Core pass, so no script reads its exit code as one. With --kind it exits on
|
|
5
5
|
// the kind's verdict alone: 0 when the provider passes the kind, 1 when it does not.
|
|
6
|
+
// `--exec-stream --machine <id> [--quick]` runs the exec pre-check (./exec-stream.ts) alone, on a machine the vendor made
|
|
7
|
+
// by hand, through the module's createHost(): 0 when exec passes every check, 1 when one fails.
|
|
6
8
|
import { generateKeyPairSync, randomBytes } from "node:crypto";
|
|
7
9
|
import { resolve } from "node:path";
|
|
8
10
|
import { pathToFileURL } from "node:url";
|
|
9
11
|
import { isCommand } from "../entry.js";
|
|
10
|
-
import { isProviderId, providerIds, providerModule } from "../providers.js";
|
|
12
|
+
import { descriptorOf, isProviderId, providerIds, providerModule } from "../providers.js";
|
|
11
13
|
import { SETTING_KIND_NAMES } from "../kinds.js";
|
|
12
14
|
import { browserCases, casesFor, conformanceCases } from "./cases/index.js";
|
|
15
|
+
import { checkExecStream, DEFAULT_LONG_MS, formatExecStream, QUICK_LONG_MS } from "./exec-stream.js";
|
|
13
16
|
import { kindRunProblem } from "./kind.js";
|
|
14
17
|
import { formatReport } from "./report.js";
|
|
15
18
|
import { runConformance } from "./runner.js";
|
|
@@ -30,8 +33,12 @@ const USAGE = `usage: npm run conformance -w @parcha/agentrun-computer -- --prov
|
|
|
30
33
|
--gpu the GPU the gpu case's one computer asks for, a type the provider declares and a count (default 1), such
|
|
31
34
|
as T4 or H100:2; it bills by the second, so without it the gpu case skips
|
|
32
35
|
--json print the report as JSON
|
|
36
|
+
--exec-stream --machine <id> [--quick]
|
|
37
|
+
the exec pre-check, alone: the module's createHost() and host.exec, nothing else, on a machine you made
|
|
38
|
+
by hand. Bytes 0-255 both ways, 8 MiB by sha256, output and stdin while the process runs, stderr apart,
|
|
39
|
+
the exit code, kill, and a silent process of ${DEFAULT_LONG_MS / 1000} s (--quick: ${QUICK_LONG_MS / 1000} s) that is not cut off
|
|
33
40
|
exit: 0 Core passes, 1 it fails, 2 usage error, 3 partial (--only) and every case that ran passed; with --kind,
|
|
34
|
-
0 the provider passes the kind, 1 it does not`;
|
|
41
|
+
0 the provider passes the kind, 1 it does not; with --exec-stream, 0 every check passes, 1 one fails`;
|
|
35
42
|
const PROVIDER_METHODS = ["capabilities", "check", "create", "attach", "list", "network", "connect", "release"];
|
|
36
43
|
class Usage extends Error {
|
|
37
44
|
}
|
|
@@ -44,6 +51,9 @@ function gpuOf(text) {
|
|
|
44
51
|
}
|
|
45
52
|
function parse(argv, cases) {
|
|
46
53
|
const args = { json: false, help: false };
|
|
54
|
+
let execStream = false;
|
|
55
|
+
let quick = false;
|
|
56
|
+
let machine;
|
|
47
57
|
for (let i = 0; i < argv.length; i++) {
|
|
48
58
|
const [flag = "", inline] = (argv[i] ?? "").split(/=(.*)/s, 2);
|
|
49
59
|
const value = () => {
|
|
@@ -71,6 +81,12 @@ function parse(argv, cases) {
|
|
|
71
81
|
args.fixture = value();
|
|
72
82
|
else if (flag === "--gpu")
|
|
73
83
|
args.gpu = gpuOf(value());
|
|
84
|
+
else if (flag === "--exec-stream")
|
|
85
|
+
execStream = true;
|
|
86
|
+
else if (flag === "--machine")
|
|
87
|
+
machine = value();
|
|
88
|
+
else if (flag === "--quick")
|
|
89
|
+
quick = true;
|
|
74
90
|
else if (flag === "--json")
|
|
75
91
|
args.json = true;
|
|
76
92
|
else if (flag === "--help" || flag === "-h")
|
|
@@ -82,6 +98,16 @@ function parse(argv, cases) {
|
|
|
82
98
|
return { provider: "", json: false, help: true };
|
|
83
99
|
if (args.provider === undefined)
|
|
84
100
|
throw new Usage("--provider is required");
|
|
101
|
+
if (execStream) {
|
|
102
|
+
if (machine === undefined)
|
|
103
|
+
throw new Usage("--exec-stream needs --machine <id>, a machine you made by hand");
|
|
104
|
+
const others = ["image", "only", "kind", "fixture", "gpu"].filter((name) => args[name] !== undefined);
|
|
105
|
+
if (others.length > 0)
|
|
106
|
+
throw new Usage(`--exec-stream runs alone: drop ${others.map((name) => `--${name}`).join(", ")}`);
|
|
107
|
+
return { provider: args.provider, execStream: { machine, quick }, json: args.json, help: false };
|
|
108
|
+
}
|
|
109
|
+
if (machine !== undefined || quick)
|
|
110
|
+
throw new Usage(`${machine !== undefined ? "--machine" : "--quick"} goes with --exec-stream`);
|
|
85
111
|
if (args.kind !== undefined && args.only !== undefined)
|
|
86
112
|
throw new Usage("--kind and --only go apart: a kind runs its own cases");
|
|
87
113
|
const groups = [...new Set(cases.map((c) => c.group))];
|
|
@@ -112,10 +138,9 @@ const BARE = /^[A-Za-z][A-Za-z0-9-]*$/;
|
|
|
112
138
|
*/
|
|
113
139
|
async function conformanceModule(name, cwd) {
|
|
114
140
|
const found = await moduleFor(name, cwd);
|
|
115
|
-
// What
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
return { label: found.label, module: found.module, ...(Array.isArray(declared) ? { declared: declared } : {}) };
|
|
141
|
+
// What a registry provider declares of itself, its descriptor's configurations, for health.declared.
|
|
142
|
+
const declared = isProviderId(name) ? descriptorOf(name)?.capabilities : undefined;
|
|
143
|
+
return { label: found.label, module: found.module, ...(declared === undefined ? {} : { declared }) };
|
|
119
144
|
}
|
|
120
145
|
async function moduleFor(name, cwd) {
|
|
121
146
|
let label = name;
|
|
@@ -181,9 +206,10 @@ export function plantSecrets(names) {
|
|
|
181
206
|
}
|
|
182
207
|
/**
|
|
183
208
|
* The provider a conformance module makes, its drifted twin and its run folders (mountFor) when it offers them, and what
|
|
184
|
-
* it says of its run: conformanceImage(), the image when --image names none
|
|
209
|
+
* it says of its run: conformanceImage(), the image when --image names none (asked only then: a module's may make or
|
|
210
|
+
* register its image, so it is given the run's signal), and conformanceNotes, strings for the report.
|
|
185
211
|
*/
|
|
186
|
-
async function load(label, module, options, declared) {
|
|
212
|
+
async function load(label, module, options, { imageNamed, signal }, declared) {
|
|
187
213
|
const { createProvider, createDriftedProvider, conformanceImage, mountFor } = module;
|
|
188
214
|
if (typeof createProvider !== "function")
|
|
189
215
|
throw new Usage(`${label} does not export createProvider() or create()`);
|
|
@@ -210,8 +236,8 @@ async function load(label, module, options, declared) {
|
|
|
210
236
|
}
|
|
211
237
|
if (typeof mountFor === "function")
|
|
212
238
|
target.mountFor = (kind) => mountFor(kind, options);
|
|
213
|
-
if (conformanceImage !== undefined) {
|
|
214
|
-
const image = typeof conformanceImage === "function" ? await conformanceImage(options) : undefined;
|
|
239
|
+
if (conformanceImage !== undefined && !imageNamed) {
|
|
240
|
+
const image = typeof conformanceImage === "function" ? await conformanceImage(options, signal ? { signal } : {}) : undefined;
|
|
215
241
|
if (typeof image !== "string" || image === "")
|
|
216
242
|
throw new Usage(`${label}: conformanceImage() did not return an image`);
|
|
217
243
|
target.image = image;
|
|
@@ -224,6 +250,39 @@ async function load(label, module, options, declared) {
|
|
|
224
250
|
}
|
|
225
251
|
return target;
|
|
226
252
|
}
|
|
253
|
+
/**
|
|
254
|
+
* The exec pre-check: the host the module's createHost() builds (a conformance module's, else the provider file's own),
|
|
255
|
+
* given the CLI's provider options, and its exec alone on the named machine. Nothing else of the host is called.
|
|
256
|
+
*/
|
|
257
|
+
async function execStreamMain(name, { machine, quick }, json, cwd, io) {
|
|
258
|
+
const { stdout = process.stdout, stderr = process.stderr, signal, progress = false } = io;
|
|
259
|
+
let host;
|
|
260
|
+
try {
|
|
261
|
+
const found = await moduleFor(name, cwd);
|
|
262
|
+
const createHost = found.module.createHost ?? found.file.createHost;
|
|
263
|
+
if (typeof createHost !== "function") {
|
|
264
|
+
throw new Usage(`${found.label} does not export createHost(options): the exec pre-check builds your MachineHost with it, from your conformance module or your provider file`);
|
|
265
|
+
}
|
|
266
|
+
host = (await createHost(io.providerOptions ?? {}));
|
|
267
|
+
if (typeof host?.exec !== "function")
|
|
268
|
+
throw new Error(`${found.label}: createHost() did not return a MachineHost with exec`);
|
|
269
|
+
}
|
|
270
|
+
catch (error) {
|
|
271
|
+
await write(stderr, `${error.message}\n`);
|
|
272
|
+
if (error instanceof Usage) {
|
|
273
|
+
await write(stderr, `${USAGE}\n`);
|
|
274
|
+
return 2;
|
|
275
|
+
}
|
|
276
|
+
return 1;
|
|
277
|
+
}
|
|
278
|
+
const report = await checkExecStream(host, machine, {
|
|
279
|
+
longMs: quick ? QUICK_LONG_MS : DEFAULT_LONG_MS,
|
|
280
|
+
...(signal ? { signal } : {}),
|
|
281
|
+
...(progress ? { onCheck: (check) => stderr.write(`${check.status === "pass" ? "✓" : "✗"} ${check.id}\n`) } : {}),
|
|
282
|
+
});
|
|
283
|
+
await write(stdout, json ? `${JSON.stringify(report, null, 2)}\n` : formatExecStream(report));
|
|
284
|
+
return report.pass ? 0 : 1;
|
|
285
|
+
}
|
|
227
286
|
export async function main(argv, io = {}) {
|
|
228
287
|
const { stdout = process.stdout, stderr = process.stderr, signal, progress = false } = io;
|
|
229
288
|
let args;
|
|
@@ -240,13 +299,15 @@ export async function main(argv, io = {}) {
|
|
|
240
299
|
return 0;
|
|
241
300
|
}
|
|
242
301
|
const cwd = io.cwd ?? process.env.INIT_CWD ?? process.cwd();
|
|
302
|
+
if (args.execStream)
|
|
303
|
+
return execStreamMain(args.provider, args.execStream, args.json, cwd, io);
|
|
243
304
|
// What the provider says that is no failure (onNote, as each remote provider takes it) goes in the report.
|
|
244
305
|
const providerNotes = [];
|
|
245
306
|
const options = { ...(io.providerOptions ?? {}), onNote: (note) => providerNotes.push({ computer: note.computer, note: note.note }) };
|
|
246
307
|
let target;
|
|
247
308
|
try {
|
|
248
309
|
const { label, module, declared } = await conformanceModule(args.provider, cwd);
|
|
249
|
-
target = await load(label, module, options, declared);
|
|
310
|
+
target = await load(label, module, options, { imageNamed: args.image !== undefined, ...(signal ? { signal } : {}) }, declared);
|
|
250
311
|
}
|
|
251
312
|
catch (error) {
|
|
252
313
|
await write(stderr, `${error.message}\n`);
|
|
@@ -1,18 +1,5 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import type {
|
|
3
|
-
import { type ArchilRunFolderOptions } from "./archil.js";
|
|
4
|
-
import type { RunFolder } from "./types.js";
|
|
5
|
-
/** The Archil disk's settings for the mount cases, by name (COMPUTER_ARCHIL_*: all five, or none). */
|
|
6
|
-
export { ARCHIL_ENV } from "./archil.js";
|
|
7
|
-
/**
|
|
8
|
-
* A fresh run folder for the mount cases: an Archil one on the disk the COMPUTER_ARCHIL_* settings name (the shared
|
|
9
|
-
* archilRunFolder; the run's snapshot is then one of box/Dockerfile, and COMPUTER_DAYTONA_USER is 2510:2510); none when
|
|
10
|
-
* they name none, and none for a bind, which a remote computer cannot take.
|
|
11
|
-
*/
|
|
12
|
-
export declare function mountFor(kind: MountKind, { env, archil }?: {
|
|
13
|
-
env?: Record<string, string | undefined>;
|
|
14
|
-
archil?: Pick<ArchilRunFolderOptions, "objects" | "Archil" | "baseUrl">;
|
|
15
|
-
}): Promise<RunFolder | undefined>;
|
|
1
|
+
import { type DaytonaProvider, type DaytonaProviderOptions } from "../daytona.js";
|
|
2
|
+
import type { MachineHost } from "../host.js";
|
|
16
3
|
/** The environment this module reads, by name, each for the option its comment names. */
|
|
17
4
|
export declare const DAYTONA_ENV: {
|
|
18
5
|
/** apiKey, required: the Daytona API key. */
|
|
@@ -59,15 +46,12 @@ export declare const ENV: {
|
|
|
59
46
|
* The provider's options this module reads from env, each only when its name is set; throws in words without the key,
|
|
60
47
|
* never echoing one. create() checks the rest.
|
|
61
48
|
*/
|
|
62
|
-
export declare function settingsFromEnv(env?: Record<string, string | undefined>):
|
|
49
|
+
export declare function settingsFromEnv(env?: Record<string, string | undefined>): DaytonaProviderOptions;
|
|
63
50
|
/** Minutes without outside activity before Daytona stops a run's sandbox: at most 30, so none outlives a run for long. */
|
|
64
51
|
export declare const CONFORMANCE_AUTO_STOP_MINUTES = 30;
|
|
65
52
|
/** Minutes a run's sandbox may stay stopped: 0, Daytona deletes it as soon as it stops. */
|
|
66
53
|
export declare const CONFORMANCE_AUTO_DELETE_MINUTES = 0;
|
|
67
|
-
/**
|
|
68
|
-
* For the run's report: what this configuration means for the suite. The provider declares it (stopDeletes), and the
|
|
69
|
-
* note says it in words.
|
|
70
|
-
*/
|
|
54
|
+
/** For the run's report: what this configuration means for the suite, in words. */
|
|
71
55
|
export declare const conformanceNotes: string[];
|
|
72
56
|
export interface DaytonaModuleOptions {
|
|
73
57
|
/** Where the settings are read; default process.env. */
|
|
@@ -83,5 +67,10 @@ export interface DaytonaModuleOptions {
|
|
|
83
67
|
export declare function conformanceImage({ env }?: Pick<DaytonaModuleOptions, "env">): string;
|
|
84
68
|
/** The provider the CLI runs; throws in words when a setting is missing or wrong. */
|
|
85
69
|
export declare function createProvider(options?: DaytonaModuleOptions): DaytonaProvider;
|
|
70
|
+
/**
|
|
71
|
+
* The Daytona host the live sweep (sweep.ts) lists and deletes through, from the same settings (the key and the API
|
|
72
|
+
* URL); it calls nothing until the sweep does.
|
|
73
|
+
*/
|
|
74
|
+
export declare function createHost({ env, fetch }?: Pick<DaytonaModuleOptions, "env" | "fetch">): Promise<MachineHost>;
|
|
86
75
|
/** The same provider with a daemon that reports another version, built with Go for the drift case. */
|
|
87
76
|
export declare function createDriftedProvider(options?: DaytonaModuleOptions): Promise<DaytonaProvider>;
|
|
@@ -2,25 +2,11 @@
|
|
|
2
2
|
// module reads the run's settings from its own COMPUTER_DAYTONA_* names (never a bare DAYTONA_ variable, which may hold
|
|
3
3
|
// another organization's key on a host that runs other Daytona work) and passes each to create() as its option, the key
|
|
4
4
|
// read only when createProvider() runs. Every sandbox of a run has a bounded life besides its TTL: Daytona stops one
|
|
5
|
-
// after 30 minutes with no outside activity and deletes it as soon as it stops
|
|
6
|
-
//
|
|
5
|
+
// after 30 minutes with no outside activity and deletes it as soon as it stops (see conformanceNotes). The live sweep
|
|
6
|
+
// (sweep.ts, --provider daytona) reads the same names through createHost: it makes nothing.
|
|
7
7
|
import { create } from "../daytona.js";
|
|
8
8
|
import { DAYTONA_DEFAULT_SNAPSHOT } from "../descriptors/daytona.js";
|
|
9
|
-
import { archilRunFolder, archilSettings } from "./archil.js";
|
|
10
9
|
import { buildDriftDaemon, DRIFT_VERSION } from "./drift-daemon.js";
|
|
11
|
-
/** The Archil disk's settings for the mount cases, by name (COMPUTER_ARCHIL_*: all five, or none). */
|
|
12
|
-
export { ARCHIL_ENV } from "./archil.js";
|
|
13
|
-
/**
|
|
14
|
-
* A fresh run folder for the mount cases: an Archil one on the disk the COMPUTER_ARCHIL_* settings name (the shared
|
|
15
|
-
* archilRunFolder; the run's snapshot is then one of box/Dockerfile, and COMPUTER_DAYTONA_USER is 2510:2510); none when
|
|
16
|
-
* they name none, and none for a bind, which a remote computer cannot take.
|
|
17
|
-
*/
|
|
18
|
-
export async function mountFor(kind, { env = process.env, archil = {} } = {}) {
|
|
19
|
-
if (kind !== "archil")
|
|
20
|
-
return undefined;
|
|
21
|
-
const settings = archilSettings(env);
|
|
22
|
-
return settings === undefined ? undefined : archilRunFolder({ ...settings, ...archil });
|
|
23
|
-
}
|
|
24
10
|
/** The environment this module reads, by name, each for the option its comment names. */
|
|
25
11
|
export const DAYTONA_ENV = {
|
|
26
12
|
/** apiKey, required: the Daytona API key. */
|
|
@@ -65,6 +51,7 @@ export function settingsFromEnv(env = process.env) {
|
|
|
65
51
|
...(url ? { apiUrl: url.value } : {}),
|
|
66
52
|
...(target ? { target: target.value } : {}),
|
|
67
53
|
...(daemon ? { daemonPath: daemon.value } : {}),
|
|
54
|
+
// create() refuses any other arch in words.
|
|
68
55
|
...(arch ? { arch: arch.value } : {}),
|
|
69
56
|
// create() refuses any other class in words.
|
|
70
57
|
...(sandboxClass ? { sandboxClass: sandboxClass.value } : {}),
|
|
@@ -77,12 +64,9 @@ export function settingsFromEnv(env = process.env) {
|
|
|
77
64
|
export const CONFORMANCE_AUTO_STOP_MINUTES = 30;
|
|
78
65
|
/** Minutes a run's sandbox may stay stopped: 0, Daytona deletes it as soon as it stops. */
|
|
79
66
|
export const CONFORMANCE_AUTO_DELETE_MINUTES = 0;
|
|
80
|
-
/**
|
|
81
|
-
* For the run's report: what this configuration means for the suite. The provider declares it (stopDeletes), and the
|
|
82
|
-
* note says it in words.
|
|
83
|
-
*/
|
|
67
|
+
/** For the run's report: what this configuration means for the suite, in words. */
|
|
84
68
|
export const conformanceNotes = [
|
|
85
|
-
`daytona: every sandbox runs with autoStopMinutes ${CONFORMANCE_AUTO_STOP_MINUTES} and autoDeleteMinutes ${CONFORMANCE_AUTO_DELETE_MINUTES}, besides its TTL: Daytona deletes a sandbox as soon as it stops, so this configuration keeps no stopped computer
|
|
69
|
+
`daytona: every sandbox runs with autoStopMinutes ${CONFORMANCE_AUTO_STOP_MINUTES} and autoDeleteMinutes ${CONFORMANCE_AUTO_DELETE_MINUTES}, besides its TTL: Daytona deletes a sandbox as soon as it stops, so this configuration keeps no stopped computer. A computer here is deleted, never stopped: release stop is refused. Full provider.janitor, which needs a stopped computer kept, is skipped (the lifetime being vendor).`,
|
|
86
70
|
];
|
|
87
71
|
/** The provider's options: what this module reads from the environment (settingsFromEnv), with the run's bounds. */
|
|
88
72
|
function optionsOf({ env = process.env, fetch, webSocket, timeouts, onNote }) {
|
|
@@ -104,6 +88,13 @@ export function conformanceImage({ env = process.env } = {}) {
|
|
|
104
88
|
export function createProvider(options = {}) {
|
|
105
89
|
return create(optionsOf(options));
|
|
106
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* The Daytona host the live sweep (sweep.ts) lists and deletes through, from the same settings (the key and the API
|
|
93
|
+
* URL); it calls nothing until the sweep does.
|
|
94
|
+
*/
|
|
95
|
+
export async function createHost({ env = process.env, fetch } = {}) {
|
|
96
|
+
return create({ ...settingsFromEnv(env), ...(fetch ? { fetch } : {}) }).host;
|
|
97
|
+
}
|
|
107
98
|
/** The same provider with a daemon that reports another version, built with Go for the drift case. */
|
|
108
99
|
export async function createDriftedProvider(options = {}) {
|
|
109
100
|
const settings = optionsOf(options);
|
package/dist/conformance/e2b.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// E2B for the conformance CLI: `npm run conformance -w @parcha/agentrun-computer -- --provider e2b [--image <template>]`.
|
|
2
|
-
// It makes real sandboxes, so it runs only with AGENTRUN_COMPUTER_LIVE_E2B=1 and a key
|
|
2
|
+
// It makes real sandboxes, so it runs only with AGENTRUN_COMPUTER_LIVE_E2B=1 and a key for an account you can bill, under
|
|
3
3
|
// COMPUTER_E2B_API_KEY. The provider reads no environment: this module reads its own COMPUTER_E2B_* names (never
|
|
4
4
|
// E2B_API_KEY, which may hold another team's key) and passes each to create() as its option; the provider gives the SDK
|
|
5
5
|
// the key, domain and API URL explicitly, and refuses an ambient E2B_SANDBOX_URL (see create in ../e2b.ts). The live
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
// disk's object API (the shared archilRunFolder, ./archil.ts: the host's disk SDK with COMPUTER_ARCHIL_API_KEY and
|
|
16
16
|
// COMPUTER_ARCHIL_S3_URL, or an object API given as archil.objects); with no disk named it makes none, and the cases
|
|
17
17
|
// are skipped. An Archil computer needs a provider whose daemon user is the tool user: COMPUTER_E2B_USER=2510:2510.
|
|
18
|
-
import { E2B_BASE_TEMPLATE, E2B_DESKTOP_TEMPLATE } from "../descriptors/e2b.js";
|
|
19
18
|
import { create } from "../e2b.js";
|
|
20
19
|
import { archilRunFolder, archilSettings } from "./archil.js";
|
|
21
20
|
import { buildDriftDaemon, DRIFT_VERSION } from "./drift-daemon.js";
|
|
@@ -77,12 +76,18 @@ export const conformanceNotes = [
|
|
|
77
76
|
];
|
|
78
77
|
function live(env) {
|
|
79
78
|
if (env[E2B_ENV.live] !== "1") {
|
|
80
|
-
throw new Error(`the E2B conformance module makes real sandboxes: set ${E2B_ENV.live}=1, with a key
|
|
79
|
+
throw new Error(`the E2B conformance module makes real sandboxes: set ${E2B_ENV.live}=1, with a key for an account you can bill, to run it`);
|
|
81
80
|
}
|
|
82
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* The conformance run's own default templates, E2B's stock ones: E2B Desktop's, and its plain one for kind linux. A server
|
|
84
|
+
* starts from the box template (the provider's prepareImage); a run on it names it with --image.
|
|
85
|
+
*/
|
|
86
|
+
const DESKTOP_TEMPLATE = "desktop";
|
|
87
|
+
const BASE_TEMPLATE = "base";
|
|
83
88
|
/** The template every computer of the run starts from: COMPUTER_E2B_TEMPLATE, or E2B Desktop's (the plain one for kind linux). */
|
|
84
89
|
export function conformanceImage({ env = process.env } = {}) {
|
|
85
|
-
return env[E2B_ENV.template] || (env[E2B_ENV.kind] === "linux" ?
|
|
90
|
+
return env[E2B_ENV.template] || (env[E2B_ENV.kind] === "linux" ? BASE_TEMPLATE : DESKTOP_TEMPLATE);
|
|
86
91
|
}
|
|
87
92
|
/** The provider the CLI runs; throws in words without the live switch, or when a setting is missing or wrong. */
|
|
88
93
|
export async function createProvider({ env = process.env, Sandbox, daemonPath, timeouts, onNote } = {}) {
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { MachineHost } from "../host.js";
|
|
2
|
+
/** The checks, in the order they run. */
|
|
3
|
+
export declare const EXEC_STREAM_CHECKS: readonly ["stdout-bytes", "stdin-bytes", "large", "stdout-live", "stdin-live", "stderr", "exit-code", "kill", "no-timeout"];
|
|
4
|
+
export type ExecStreamCheckId = (typeof EXEC_STREAM_CHECKS)[number];
|
|
5
|
+
export interface ExecStreamCheck {
|
|
6
|
+
id: ExecStreamCheckId;
|
|
7
|
+
status: "pass" | "fail";
|
|
8
|
+
/** What passed, or what the vendor's exec did wrong, in words a person can act on. */
|
|
9
|
+
words: string;
|
|
10
|
+
ms: number;
|
|
11
|
+
}
|
|
12
|
+
export interface ExecStreamReport {
|
|
13
|
+
host: string;
|
|
14
|
+
machine: string;
|
|
15
|
+
checks: ExecStreamCheck[];
|
|
16
|
+
pass: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface ExecStreamOptions {
|
|
19
|
+
/** How long the no-timeout check's process runs, silent, before it prints and exits; default 75 s. */
|
|
20
|
+
longMs?: number;
|
|
21
|
+
/** How long one step waits: exec's answer, bytes coming back, wait() after the end; default 30 s. */
|
|
22
|
+
stepMs?: number;
|
|
23
|
+
/** The large check's payload, in bytes; default 8 MiB. */
|
|
24
|
+
largeBytes?: number;
|
|
25
|
+
/** How long the large check may take in all; default 180 s. */
|
|
26
|
+
largeMs?: number;
|
|
27
|
+
signal?: AbortSignal;
|
|
28
|
+
/** Told of each check as it ends. */
|
|
29
|
+
onCheck?: (check: ExecStreamCheck) => void;
|
|
30
|
+
}
|
|
31
|
+
export declare const DEFAULT_LONG_MS = 75000;
|
|
32
|
+
/** --quick's no-timeout check: long enough to cross a second, short enough for CI. */
|
|
33
|
+
export declare const QUICK_LONG_MS = 5000;
|
|
34
|
+
/**
|
|
35
|
+
* kill's probe, `sh -c PID_STATE_SCRIPT sh <pid>`: "running" or "gone". A killed process its parent has not reaped yet
|
|
36
|
+
* is a zombie, which kill -0 still finds; it has ended, so its /proc state (Z, or X) reads gone, and any other state
|
|
37
|
+
* running. Its state is read first, in one read, so a reap during the probe never reads as running; where there is no
|
|
38
|
+
* state to read (no /proc, a status hidden, or the process already gone), kill -0 answers.
|
|
39
|
+
*/
|
|
40
|
+
export declare const PID_STATE_SCRIPT = "st=$(sed -n \"s/^State:[[:space:]]*\\([A-Z]\\).*/\\1/p\" \"/proc/$1/status\" 2>/dev/null); case \"$st\" in Z|X) echo gone ;; ?) echo running ;; *) if kill -0 \"$1\" 2>/dev/null; then echo running; else echo gone; fi ;; esac";
|
|
41
|
+
/**
|
|
42
|
+
* Why `got` is not `sent`, in words, or undefined when they are the same bytes. `way` is where they went ("on stdout");
|
|
43
|
+
* the first byte that differs is named, and the usual ways an exec mangles bytes are named for what they are.
|
|
44
|
+
*/
|
|
45
|
+
export declare function bytesProblem(sent: Uint8Array, got: Uint8Array, way: string): string | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* The exec pre-check on one machine: each check in EXEC_STREAM_CHECKS runs in turn, and the report passes when every one
|
|
48
|
+
* does. host.exec is the only member called.
|
|
49
|
+
*/
|
|
50
|
+
export declare function checkExecStream(host: MachineHost, machine: string, options?: ExecStreamOptions): Promise<ExecStreamReport>;
|
|
51
|
+
/** The report as a person reads it: one line per check, what failed in words, the verdict last. */
|
|
52
|
+
export declare function formatExecStream(report: ExecStreamReport): string;
|