@parcha/agentrun-computer 0.1.0-beta.33 → 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 +308 -36
- package/dist/browser.d.ts +13 -14
- package/dist/browser.js +22 -17
- package/dist/browserbase.d.ts +3 -3
- package/dist/browserbase.js +16 -11
- package/dist/child.d.ts +2 -0
- package/dist/child.js +13 -2
- package/dist/chrome.d.ts +73 -0
- package/dist/chrome.js +224 -0
- 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/gpu.d.ts +2 -0
- package/dist/conformance/cases/gpu.js +108 -0
- package/dist/conformance/cases/health.js +83 -3
- package/dist/conformance/cases/index.js +2 -0
- package/dist/conformance/cases/mount.d.ts +8 -1
- package/dist/conformance/cases/mount.js +4 -3
- package/dist/conformance/cases/provider.js +92 -3
- package/dist/conformance/cli.js +46 -7
- 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-chrome.d.ts +30 -0
- package/dist/conformance/local-chrome.js +36 -0
- 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 +13 -7
- package/dist/conformance/runner.js +68 -18
- package/dist/conformance/types.d.ts +78 -18
- 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 +4 -6
- package/dist/daytona.js +97 -52
- 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 -4
- package/dist/docker.js +53 -41
- package/dist/drift.d.ts +6 -146
- package/dist/drift.js +14 -334
- package/dist/e2b.d.ts +2 -6
- package/dist/e2b.js +19 -22
- package/dist/index.d.ts +9 -10
- package/dist/index.js +14 -10
- package/dist/isolation.d.ts +0 -2
- package/dist/isolation.js +2 -18
- package/dist/janitor.d.ts +18 -1
- package/dist/janitor.js +67 -19
- package/dist/kernel.d.ts +3 -3
- package/dist/kernel.js +19 -14
- package/dist/kinds.d.ts +56 -30
- package/dist/kinds.js +19 -97
- package/dist/labels.d.ts +18 -0
- package/dist/labels.js +65 -2
- package/dist/local-chrome.d.ts +86 -0
- package/dist/local-chrome.js +475 -0
- package/dist/local-supervisor.d.ts +51 -0
- package/dist/local-supervisor.js +221 -0
- package/dist/modal.d.ts +15 -7
- package/dist/modal.js +83 -39
- 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 -13
- package/dist/orgo.js +54 -128
- package/dist/phone-harness.d.ts +4 -8
- package/dist/phone-harness.js +48 -46
- package/dist/protocol.d.ts +20 -0
- package/dist/protocol.js +9 -0
- package/dist/provider.d.ts +151 -10
- package/dist/provider.js +70 -0
- package/dist/providers.d.ts +22 -17
- package/dist/providers.js +14 -16
- 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
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// GPU: a computer asked for with a GPU the provider declares has it, as the vendor reports it (attach's read-back) and
|
|
2
|
+
// as its programs see it from inside (nvidia-smi, as the computer's user). The run names the GPU it pays for (t.gpu()):
|
|
3
|
+
// a GPU bills by the second, so each case makes one computer and keeps it no longer than it takes to look.
|
|
4
|
+
//
|
|
5
|
+
// gpu.present makes a GPU computer alone. It needs exec but does not name it among its needs: the runner checks a group
|
|
6
|
+
// need on the run's shared computer, which it would make for this case alone, a second computer billed for nothing. The
|
|
7
|
+
// provider's declared groups and its own GPU computer's hello hold it to exec instead. It also records, as evidence and
|
|
8
|
+
// nothing more, what the computer's user sees of FUSE, which an Archil mount needs: nothing is mounted.
|
|
9
|
+
//
|
|
10
|
+
// gpu.archil makes ONE computer with both the GPU and the run's Archil folder, where the provider's GPU computers take an
|
|
11
|
+
// Archil mount (capabilities().gpu.mounts lists it, or names none): the folder reads at /workspace, a program's write
|
|
12
|
+
// there is on the disk once the computer is released, and the GPUs are seen from inside. Everything is collected before
|
|
13
|
+
// the GPU verdict, so a computer whose image lacks the GPU's tools still shows whether the mount held.
|
|
14
|
+
import { randomBytes } from "node:crypto";
|
|
15
|
+
import { readBackOf, WORKSPACE } from "../../mount.js";
|
|
16
|
+
import { mounted } from "./mount.js";
|
|
17
|
+
import { CASE_LABEL } from "./util.js";
|
|
18
|
+
/** An AMD type: its programs see it through ROCm, not nvidia-smi, so the count from inside is recorded, not asserted. */
|
|
19
|
+
const AMD = /^MI\d/;
|
|
20
|
+
/** What the computer's user sees of FUSE, with nothing mounted: the device, the kernel's filesystems, whether the device
|
|
21
|
+
* opens, and the kernel (gVisor's says so). */
|
|
22
|
+
const FUSE_PROBE = 'ls -l /dev/fuse 2>&1; grep -w fuse /proc/filesystems 2>&1 || echo "fuse: not in /proc/filesystems"; if (exec 3<>/dev/fuse) 2>/dev/null; then echo "/dev/fuse: opens read-write"; else echo "/dev/fuse: does not open"; fi; echo "kernel $(uname -r)"';
|
|
23
|
+
/** The GPUs the computer's user sees, recorded; and the verdict on them, for the case to give once it has looked at the
|
|
24
|
+
* rest (none for an AMD type, whose count is recorded only). */
|
|
25
|
+
async function lookAtGpus(t, gpu, client) {
|
|
26
|
+
if (AMD.test(gpu.type)) {
|
|
27
|
+
const seen = await t.exec(["sh", "-c", "rocm-smi --showproductname 2>&1; true"], {}, client);
|
|
28
|
+
t.observe(`the GPUs the computer's user sees (rocm-smi): ${seen.out.trim().slice(0, 600) || "nothing"}`);
|
|
29
|
+
return () => { };
|
|
30
|
+
}
|
|
31
|
+
// nvidia-smi -L: one "GPU <n>: <name> (UUID: ...)" line per GPU the computer's programs can use.
|
|
32
|
+
const seen = await t.exec(["sh", "-c", "nvidia-smi -L"], {}, client);
|
|
33
|
+
t.observe(`the GPUs the computer's user sees (nvidia-smi -L): ${(seen.out.trim() || seen.err.trim()).slice(0, 600) || "nothing"}`);
|
|
34
|
+
return () => {
|
|
35
|
+
t.equal(seen.exitCode, 0, `nvidia-smi -L as the computer's user: a GPU computer's image carries the driver's tools, and its user reaches the GPU (stderr: ${seen.err.trim().slice(0, 300)})`);
|
|
36
|
+
const listed = seen.out.split("\n").filter((line) => /^GPU \d+: /.test(line.trim()));
|
|
37
|
+
t.equal(listed.length, gpu.count, "the GPUs nvidia-smi lists, as the computer's user");
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** Records what the computer's user sees of FUSE; never fails the case. */
|
|
41
|
+
async function lookAtFuse(t, client) {
|
|
42
|
+
const seen = await t.exec(["sh", "-c", FUSE_PROBE], {}, client);
|
|
43
|
+
t.observe(`FUSE as the computer's user sees it, nothing mounted (an Archil mount needs it): ${(seen.out.trim() || seen.err.trim()).replace(/\n/g, " | ").slice(0, 600) || "nothing"}`);
|
|
44
|
+
}
|
|
45
|
+
export const gpuCases = [
|
|
46
|
+
{
|
|
47
|
+
id: "gpu.present",
|
|
48
|
+
level: "full",
|
|
49
|
+
group: "gpu",
|
|
50
|
+
needs: ["gpu"],
|
|
51
|
+
computer: "none",
|
|
52
|
+
timeoutMs: 600_000,
|
|
53
|
+
async run(t) {
|
|
54
|
+
const gpu = t.gpu();
|
|
55
|
+
t.assert(t.provider.capabilities().groups.includes("exec"), "the provider declares exec: nvidia-smi runs as the computer's user");
|
|
56
|
+
const labels = { ...t.runLabels, [CASE_LABEL]: "gpu" };
|
|
57
|
+
t.deepEqual(t.provider.check(t.spec({ labels, gpu })), [], `check of a spec with gpu ${JSON.stringify(gpu)}`);
|
|
58
|
+
const ref = await t.create({ labels, gpu });
|
|
59
|
+
const attached = t.ok(await t.provider.attach({ id: ref.id }, { signal: t.signal }), "attach by id");
|
|
60
|
+
t.deepEqual(attached.spec.gpu, gpu, "the GPUs attach reads back: the vendor's report, or what create recorded where the vendor reports none");
|
|
61
|
+
const connected = await t.connect(ref);
|
|
62
|
+
t.assert(connected.hello.groups.includes("exec"), "the GPU computer's hello declares exec");
|
|
63
|
+
const verdict = await lookAtGpus(t, gpu, connected.client);
|
|
64
|
+
await lookAtFuse(t, connected.client);
|
|
65
|
+
await connected.close();
|
|
66
|
+
t.ok(await t.provider.release(ref, "delete"), "release delete, at once: a GPU bills by the second");
|
|
67
|
+
verdict();
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: "gpu.archil",
|
|
72
|
+
level: "full",
|
|
73
|
+
group: "gpu",
|
|
74
|
+
needs: ["gpu", "mount:archil"],
|
|
75
|
+
computer: "none",
|
|
76
|
+
timeoutMs: 900_000,
|
|
77
|
+
async run(t) {
|
|
78
|
+
const gpu = t.gpu();
|
|
79
|
+
const offered = t.provider.capabilities();
|
|
80
|
+
t.assert(offered.groups.includes("exec"), "the provider declares exec: nvidia-smi and the program's write run as the computer's user");
|
|
81
|
+
if (offered.gpu?.mounts !== undefined && !offered.gpu.mounts.includes("archil")) {
|
|
82
|
+
t.skip("the provider's GPU computers take no archil mount (capabilities().gpu.mounts): check() refuses one, as provider.check-refuses holds");
|
|
83
|
+
}
|
|
84
|
+
const folder = await t.runFolder("archil");
|
|
85
|
+
const nonce = randomBytes(6).toString("hex");
|
|
86
|
+
const before = `gpu-before-${nonce}.txt`;
|
|
87
|
+
const beforeText = `written outside before the GPU computer ${nonce}\n`;
|
|
88
|
+
await folder.write(before, Buffer.from(beforeText));
|
|
89
|
+
// check() takes it, create makes it, and attach and list read the mount back as asked, with no token (mount.ts).
|
|
90
|
+
const { ref } = await mounted(t, folder, 1, "gpu-archil", { gpu });
|
|
91
|
+
const attached = t.ok(await t.provider.attach({ id: ref.id }, { signal: t.signal }), "attach by id");
|
|
92
|
+
t.deepEqual(attached.spec.gpu, gpu, "the GPUs attach reads back, beside the mount");
|
|
93
|
+
t.deepEqual(attached.spec.mount, readBackOf(folder.mount, 1), "the mount attach reads back, beside the GPUs");
|
|
94
|
+
const connected = await t.connect(ref);
|
|
95
|
+
t.assert(connected.hello.groups.includes("exec"), "the GPU computer's hello declares exec");
|
|
96
|
+
const read = await t.exec(["cat", before], { cwd: WORKSPACE }, connected.client);
|
|
97
|
+
t.equal(read.out, beforeText, `cat ${before} at ${WORKSPACE}, a file written outside before the computer (${read.err.trim()})`);
|
|
98
|
+
const wrote = await t.exec(["sh", "-c", 'printf "%s\\n" "$1" >> "$2"', "sh", nonce, `${WORKSPACE}/gpu-${nonce}.txt`], {}, connected.client);
|
|
99
|
+
t.equal(wrote.exitCode, 0, `a program's write at ${WORKSPACE}: its exit code (${wrote.err.trim()})`);
|
|
100
|
+
const verdict = await lookAtGpus(t, gpu, connected.client);
|
|
101
|
+
await connected.close();
|
|
102
|
+
t.ok(await t.provider.release(ref, "delete"), "release delete, at once: a GPU bills by the second");
|
|
103
|
+
const back = await folder.read(`gpu-${nonce}.txt`);
|
|
104
|
+
t.equal(back === undefined ? undefined : Buffer.from(back).toString("utf8"), `${nonce}\n`, `gpu-${nonce}.txt, written by a program in the GPU computer, read outside once it is released`);
|
|
105
|
+
verdict();
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
// The daemon answers: hello, ping, and an error in words for a method it does not have;
|
|
2
|
-
//
|
|
3
|
-
|
|
1
|
+
// The daemon answers: hello, ping, and an error in words for a method it does not have; the computer is the kind it
|
|
2
|
+
// says it is; what the provider declares of itself, its capabilities() and each hello agree, at this protocol's
|
|
3
|
+
// version; and no error the provider answers holds a key.
|
|
4
|
+
import { GROUPS, PROTOCOL_VERSION } from "../../protocol.js";
|
|
4
5
|
import { kindRefusals } from "../../provider.js";
|
|
5
6
|
import { coreGroups } from "../types.js";
|
|
6
7
|
export const healthCases = [
|
|
@@ -68,4 +69,83 @@ export const healthCases = [
|
|
|
68
69
|
}
|
|
69
70
|
},
|
|
70
71
|
},
|
|
72
|
+
{
|
|
73
|
+
// The provider says what it is three times: in what it declares of itself (its descriptor), in capabilities(), and
|
|
74
|
+
// in each computer's hello. A runner trusts the first to pick a provider, the second to call it, and the third to
|
|
75
|
+
// hand a computer out; where they disagree, it picks a computer that cannot do the work. kind-consistent above
|
|
76
|
+
// holds hello to capabilities(); this holds capabilities() to the declaration, and hello to the protocol.
|
|
77
|
+
id: "health.declared",
|
|
78
|
+
level: "core",
|
|
79
|
+
group: "health",
|
|
80
|
+
needs: [],
|
|
81
|
+
async run(t) {
|
|
82
|
+
t.equal(t.hello.protocol, PROTOCOL_VERSION, `hello carries the protocol version this suite speaks, ${PROTOCOL_VERSION}`);
|
|
83
|
+
const declared = t.declared;
|
|
84
|
+
if (declared === undefined) {
|
|
85
|
+
return t.skip("the run was given no declaration of the provider: its descriptor, its PROVIDERS entry, or its module's CAPABILITIES");
|
|
86
|
+
}
|
|
87
|
+
const { kind, groups } = t.provider.capabilities();
|
|
88
|
+
const same = (a, b) => [...a].sort().join(",") === [...b].sort().join(",");
|
|
89
|
+
const configurations = declared.map((one) => `${one.kind} [${one.groups.join(", ")}]`).join("; ");
|
|
90
|
+
t.assert(declared.some((one) => one.kind === kind && same(one.groups, groups)), `capabilities(), kind ${kind} [${groups.join(", ")}], is one of the configurations the provider declares: ${configurations}`);
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
// A key in an error is a key in a log, a report and a model's context. The provider is built again with a planted
|
|
95
|
+
// value in place of each secret, so every call fails on it, and every refusal path is asked: none of what comes
|
|
96
|
+
// back, an error thrown included, may hold the value, or its last 12 characters (a vendor that echoes a key cut
|
|
97
|
+
// short). A planted key never makes a computer; one that did is deleted with the case, and the case fails.
|
|
98
|
+
id: "health.no-key-in-errors",
|
|
99
|
+
level: "core",
|
|
100
|
+
group: "health",
|
|
101
|
+
// A provider that takes no secret (Docker) has none to leak: the case is skipped as undeclared, apart from Core.
|
|
102
|
+
needs: ["secrets"],
|
|
103
|
+
async run(t) {
|
|
104
|
+
const { provider, secrets } = await t.planted();
|
|
105
|
+
t.assert(secrets.length > 0 && secrets.every((secret) => typeof secret === "string" && secret.length >= 16), "the planted secrets are named, each 16 characters or more");
|
|
106
|
+
const networks = provider.capabilities().network;
|
|
107
|
+
const network = networks.includes("none") ? "none" : "open";
|
|
108
|
+
// The case's own computer, a real one of the provider's: each path that takes a ref passes the provider's own
|
|
109
|
+
// checks of its shape and reaches the vendor with the planted secret, where a made-up ref could be refused first.
|
|
110
|
+
const ref = t.ref;
|
|
111
|
+
const paths = [
|
|
112
|
+
["testConnection", async () => provider.testConnection?.({ signal: t.signal }) ?? "no testConnection"],
|
|
113
|
+
["list", () => provider.list(t.runLabels, { signal: t.signal })],
|
|
114
|
+
["attach by id", () => provider.attach({ id: ref.id }, { signal: t.signal })],
|
|
115
|
+
["attach by labels", () => provider.attach({ labels: t.runLabels }, { signal: t.signal })],
|
|
116
|
+
["network", () => provider.network(ref, undefined, { signal: t.signal })],
|
|
117
|
+
["connect", () => provider.connect(ref)],
|
|
118
|
+
["release", () => provider.release(ref, "delete")],
|
|
119
|
+
["create", () => t.attempt(t.spec({ network }), provider)],
|
|
120
|
+
];
|
|
121
|
+
for (const [name, call] of paths) {
|
|
122
|
+
let answer;
|
|
123
|
+
try {
|
|
124
|
+
answer = await call();
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
answer = { threw: error instanceof Error ? `${error.name}: ${error.message}\n${error.stack ?? ""}` : String(error) };
|
|
128
|
+
}
|
|
129
|
+
// A connection made anyway (a vendor whose connect reads no key) is closed whatever the checks find: the runner
|
|
130
|
+
// never saw it, so its cleanup can't close it.
|
|
131
|
+
const opened = answer;
|
|
132
|
+
try {
|
|
133
|
+
const words = JSON.stringify(answer, (_key, value) => (value instanceof Error ? `${value.name}: ${value.message}` : value)) ?? String(answer);
|
|
134
|
+
for (const secret of secrets) {
|
|
135
|
+
for (const piece of [secret, secret.slice(-12)])
|
|
136
|
+
t.assert(!words.includes(piece), `${name}: what the provider answered holds none of a planted secret`);
|
|
137
|
+
}
|
|
138
|
+
if (name === "create")
|
|
139
|
+
t.assert(opened?.ok !== true, "create with a planted secret made no computer");
|
|
140
|
+
}
|
|
141
|
+
finally {
|
|
142
|
+
if (name === "connect" && opened?.ok === true)
|
|
143
|
+
await opened.value?.close?.().catch(() => undefined);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
// A release the vendor refused for its key let nothing go: the computer is still the provider's.
|
|
147
|
+
const still = await t.provider.attach({ id: ref.id }, { signal: t.signal });
|
|
148
|
+
t.assert(still.ok, `the computer is still there after a release with a planted secret${still.ok ? "" : `: ${still.error.code}: ${still.error.message}`}`);
|
|
149
|
+
},
|
|
150
|
+
},
|
|
71
151
|
];
|
|
@@ -3,6 +3,7 @@ import { browserCases } from "./browser.js";
|
|
|
3
3
|
import { driftCases } from "./drift.js";
|
|
4
4
|
import { execCases } from "./exec.js";
|
|
5
5
|
import { filesCases } from "./files.js";
|
|
6
|
+
import { gpuCases } from "./gpu.js";
|
|
6
7
|
import { healthCases } from "./health.js";
|
|
7
8
|
import { inputCases } from "./input.js";
|
|
8
9
|
import { isolationCases } from "./isolation.js";
|
|
@@ -27,6 +28,7 @@ export const conformanceCases = [
|
|
|
27
28
|
...touchCases,
|
|
28
29
|
...appsCases,
|
|
29
30
|
...lifetimeCases,
|
|
31
|
+
...gpuCases,
|
|
30
32
|
];
|
|
31
33
|
/**
|
|
32
34
|
* The cases a run takes when it is given none, by the machine kind of the computer: a browser's own (health, then the
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ComputerRef, ComputerSpec } from "../../provider.js";
|
|
2
|
+
import type { Case, CaseContext, RunFolder } from "../types.js";
|
|
3
|
+
/** A computer made with the folder's mount under `epoch`, and `extra` (a GPU case's gpu), after check() takes it; and its
|
|
4
|
+
* read-back, checked. */
|
|
5
|
+
export declare function mounted(t: CaseContext, folder: RunFolder, epoch: number, name: string, extra?: Partial<ComputerSpec>): Promise<{
|
|
6
|
+
ref: ComputerRef;
|
|
7
|
+
labels: Record<string, string>;
|
|
8
|
+
}>;
|
|
2
9
|
export declare const mountCases: Case[];
|
|
@@ -41,11 +41,12 @@ function labelsFor(t, folder, epoch, name) {
|
|
|
41
41
|
const ofFolder = folder.mount.kind === "archil" ? /^agents\/[^/]+\/runs\/([^/]+)\/work$/.exec(folder.mount.folder)?.[1] : undefined;
|
|
42
42
|
return { ...t.runLabels, ...claimLabels(folder.run ?? ofFolder ?? `mount-${randomBytes(6).toString("hex")}`, epoch), [CASE_LABEL]: name };
|
|
43
43
|
}
|
|
44
|
-
/** A computer made with the folder's mount under `epoch`, after check() takes it; and its
|
|
45
|
-
|
|
44
|
+
/** A computer made with the folder's mount under `epoch`, and `extra` (a GPU case's gpu), after check() takes it; and its
|
|
45
|
+
* read-back, checked. */
|
|
46
|
+
export async function mounted(t, folder, epoch, name, extra = {}) {
|
|
46
47
|
const asked = folder.mount;
|
|
47
48
|
const labels = labelsFor(t, folder, epoch, name);
|
|
48
|
-
const spec = t.spec({ labels, mount: asked });
|
|
49
|
+
const spec = t.spec({ labels, mount: asked, ...extra });
|
|
49
50
|
const refusals = t.provider.check(spec);
|
|
50
51
|
tokenless(t, asked, refusals, "check's refusal of a spec that mounts the run's folder");
|
|
51
52
|
// A provider that declares the kind but whose host cannot give it (a Docker host that remaps user ids, for a bind)
|
|
@@ -4,8 +4,9 @@
|
|
|
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
|
import { randomBytes } from "node:crypto";
|
|
6
6
|
import { releaseOlder, sweep } from "../../janitor.js";
|
|
7
|
-
import { EPOCH_LABEL, RUN_LABEL, runLabels } from "../../labels.js";
|
|
8
|
-
import {
|
|
7
|
+
import { EPOCH_LABEL, OWNER_LABEL, RUN_LABEL, runLabels } from "../../labels.js";
|
|
8
|
+
import { runLifetimeMs } from "../../provider.js";
|
|
9
|
+
import { b64, CASE_LABEL, decode } from "./util.js";
|
|
9
10
|
/** Labels for one case's computers: the run's, and the case's own. */
|
|
10
11
|
const own = (t, name) => ({ ...t.runLabels, [CASE_LABEL]: name });
|
|
11
12
|
const names = async (t, labels) => t
|
|
@@ -116,6 +117,20 @@ export const providerCases = [
|
|
|
116
117
|
const refusals = t.provider.check(over);
|
|
117
118
|
t.assert(refusals.some((r) => r.field === "lifetimeMs" && r.message !== ""), `check of lifetimeMs ${maxLifetimeMs + 1}, past maxLifetimeMs, refuses lifetimeMs in words: ${JSON.stringify(refusals)}`);
|
|
118
119
|
await refusedCreate(t, over, "create of a spec past maxLifetimeMs");
|
|
120
|
+
// GPUs are a capability too: one the provider does not offer is refused with no vendor call, and a provider that
|
|
121
|
+
// declares no gpu refuses any.
|
|
122
|
+
const { gpu } = t.provider.capabilities();
|
|
123
|
+
if (gpu !== undefined) {
|
|
124
|
+
t.assert(Array.isArray(gpu.types) && gpu.types.length > 0 && gpu.types.every((type) => typeof type === "string" && type !== "") && Number.isSafeInteger(gpu.max) && gpu.max >= 1, `capabilities().gpu is { types: [one or more names], max: a whole number from 1 }, not ${JSON.stringify(gpu)}`);
|
|
125
|
+
}
|
|
126
|
+
const offered = gpu?.types[0] ?? "T4";
|
|
127
|
+
const outside = gpu === undefined ? [{ type: offered, count: 1 }] : [{ type: `not-${offered}`, count: 1 }, { type: offered, count: 0 }, { type: offered, count: gpu.max + 1 }];
|
|
128
|
+
for (const asked of outside) {
|
|
129
|
+
const spec = t.spec({ labels, gpu: asked });
|
|
130
|
+
const refused = t.provider.check(spec);
|
|
131
|
+
t.assert(refused.some((r) => r.field === "gpu" && r.message !== ""), `check of gpu ${JSON.stringify(asked)}, which the provider ${gpu === undefined ? "declares no gpu for" : "does not offer"}, refuses gpu in words: ${JSON.stringify(refused)}`);
|
|
132
|
+
await refusedCreate(t, spec, `create with gpu ${JSON.stringify(asked)}`);
|
|
133
|
+
}
|
|
119
134
|
t.deepEqual(await names(t, labels), [], "the computers the refused creates made");
|
|
120
135
|
}),
|
|
121
136
|
provider("create-release", async (t) => {
|
|
@@ -172,7 +187,8 @@ export const providerCases = [
|
|
|
172
187
|
t.equal(info.state, "running", "its state");
|
|
173
188
|
t.deepEqual(info.network, spec.network, "its network, read back");
|
|
174
189
|
const deadline = info.deadline instanceof Date ? info.deadline.getTime() : Number.NaN;
|
|
175
|
-
|
|
190
|
+
const lifetimeMs = runLifetimeMs(spec);
|
|
191
|
+
t.assert(deadline >= before + lifetimeMs - 1000 && deadline <= after + lifetimeMs + 1000, `its deadline, ${String(info.deadline)}, is lifetimeMs after create`);
|
|
176
192
|
t.deepEqual(await names(t, { ...labels, role: "other" }), [], "list by a label no computer has");
|
|
177
193
|
}),
|
|
178
194
|
// Stop is declared or refused: a provider that declares it lists the computer stopped; one that does not refuses it
|
|
@@ -205,6 +221,79 @@ export const providerCases = [
|
|
|
205
221
|
t.ok(await t.provider.release(ref, "delete"), "release delete of a stopped computer");
|
|
206
222
|
t.deepEqual(await names(t, labels), [], "listed after delete");
|
|
207
223
|
}),
|
|
224
|
+
// An agent's computer needs persistence. A provider that declares none refuses spec.owner in check() and create, in
|
|
225
|
+
// words; one that declares it takes an owner with no lifetime, and refuses an owner with one: an agent's computer has
|
|
226
|
+
// no run deadline.
|
|
227
|
+
provider("owner", async (t) => {
|
|
228
|
+
const labels = own(t, "owner");
|
|
229
|
+
const owner = { agent: `conformance-${randomBytes(6).toString("hex")}` };
|
|
230
|
+
const { lifetimeMs: _, ...base } = t.spec({ labels });
|
|
231
|
+
const owned = { ...base, owner };
|
|
232
|
+
if (t.provider.capabilities().persistence === undefined) {
|
|
233
|
+
const refusals = t.provider.check(owned);
|
|
234
|
+
t.assert(refusals.some((r) => r.field === "owner" && r.message !== ""), `check of a spec with an owner, on a provider with no persistence, refuses owner in words: ${JSON.stringify(refusals)}`);
|
|
235
|
+
await refusedCreate(t, owned, "create of a spec with an owner, on a provider with no persistence");
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
t.deepEqual(t.provider.check(owned), [], "check of an agent's spec with no lifetime");
|
|
239
|
+
const timed = t.provider.check(t.spec({ labels, owner }));
|
|
240
|
+
t.assert(timed.some((r) => r.field === "lifetimeMs" && r.message !== ""), `check of an agent's spec with a lifetime refuses lifetimeMs in words: ${JSON.stringify(timed)}`);
|
|
241
|
+
}),
|
|
242
|
+
// Detach is an agent's computer's alone: a run's computer refuses it in words and runs on, listed running, never
|
|
243
|
+
// stopped or deleted behind the caller's back.
|
|
244
|
+
provider("detach", async (t) => {
|
|
245
|
+
const labels = own(t, "detach");
|
|
246
|
+
const ref = await t.create({ labels });
|
|
247
|
+
const words = "release detach of a run's computer";
|
|
248
|
+
const error = t.refused(await t.provider.release(ref, "detach"), words);
|
|
249
|
+
t.assert(error.message !== "", `${words}: the refusal is in words`);
|
|
250
|
+
t.deepEqual(t.ok(await t.provider.list(labels), "list").map((info) => [info.ref.name, info.state]), [[ref.name, "running"]], `${words}: the computer is still listed, running`);
|
|
251
|
+
}),
|
|
252
|
+
// An agent's computer across two claims (Full, where persistence is declared): made with an owner and no lifetime, a
|
|
253
|
+
// file written in it, detached (listed stopped, with when), attached by id under a new claim, the file read back (with
|
|
254
|
+
// resume, the process it ran still running), a claim below that epoch refused as fenced, then deleted.
|
|
255
|
+
provider("persistence", async (t) => {
|
|
256
|
+
const nonce = randomBytes(6).toString("hex");
|
|
257
|
+
const run = `conformance-${nonce}`;
|
|
258
|
+
const labels = own(t, "persistence");
|
|
259
|
+
const owner = { agent: `conformance-${nonce}` };
|
|
260
|
+
const { lifetimeMs: _, ...base } = t.spec({ labels: { ...labels, ...runLabels(run, 1) } });
|
|
261
|
+
const made = await t.attempt({ ...base, owner });
|
|
262
|
+
const ref = refOf(t.ok(made, "create of an agent's computer"));
|
|
263
|
+
const listed = async (what) => t.present(t.ok(await t.provider.list(labels), `list ${what}`).find((info) => info.ref.name === ref.name), `the agent's computer, listed ${what}`);
|
|
264
|
+
const first = await listed("after create");
|
|
265
|
+
t.deepEqual([first.labels[OWNER_LABEL], first.state], [`agent:${owner.agent}`, "running"], "after create: its owner label and state");
|
|
266
|
+
const before = await t.connect(ref);
|
|
267
|
+
const home = /^HOME=(.*)$/m.exec((await t.exec(["env"], {}, before.client)).out)?.[1]?.replace(/\/+$/, "");
|
|
268
|
+
const path = `${t.present(home, "HOME in the agent's computer")}/agentrun-conformance-persist-${nonce}`;
|
|
269
|
+
t.ok(await before.client.call("files.write", { path, data: b64(nonce) }), "files.write before the detach");
|
|
270
|
+
const { resume } = t.present(t.provider.capabilities().persistence, "capabilities().persistence");
|
|
271
|
+
const resumes = resume && t.provider.capabilities().groups.includes("processes");
|
|
272
|
+
const started = resumes ? t.ok(await before.client.call("process.start", { argv: ["sleep", "600"] }), "process.start before the detach") : undefined;
|
|
273
|
+
await before.close();
|
|
274
|
+
t.ok(await t.provider.release(ref, "detach"), "release detach");
|
|
275
|
+
const detached = await listed("after detach");
|
|
276
|
+
t.equal(detached.state, "stopped", "after detach: its state");
|
|
277
|
+
t.assert(detached.detachedAt instanceof Date && !Number.isNaN(detached.detachedAt.getTime()), `after detach: detachedAt is when, not ${String(detached.detachedAt)}`);
|
|
278
|
+
t.equal(detached.labels[OWNER_LABEL], `agent:${owner.agent}`, "after detach: still the agent's");
|
|
279
|
+
const attached = t.ok(await t.provider.attach({ id: ref.id }, { claim: { run, epoch: 2 }, signal: t.signal }), "attach by id under the claim at epoch 2");
|
|
280
|
+
t.deepEqual(refOf(attached), ref, "attach under a new claim: the same computer");
|
|
281
|
+
const back = await listed("after attach");
|
|
282
|
+
t.deepEqual([back.state, back.labels[RUN_LABEL], back.labels[EPOCH_LABEL], back.detachedAt], ["running", run, "2", undefined], "after attach: its state, the claim's labels, and no detachedAt");
|
|
283
|
+
const after = await t.connect(ref);
|
|
284
|
+
const read = t.ok(await after.client.call("files.read", { path }), "files.read after the attach");
|
|
285
|
+
t.equal(decode(read.data), nonce, "the file written before the detach, read after the attach");
|
|
286
|
+
if (started !== undefined) {
|
|
287
|
+
const waited = t.ok(await after.client.call("process.wait", { id: started.id, timeoutMs: 0 }), "process.wait after the attach");
|
|
288
|
+
t.equal(waited.running, true, "with resume: the process started before the detach, still running");
|
|
289
|
+
}
|
|
290
|
+
await after.close();
|
|
291
|
+
const fenced = t.refused(await t.provider.attach({ id: ref.id }, { claim: { run, epoch: 1 }, signal: t.signal }), "attach under the claim at epoch 1, below 2", ["refused"]);
|
|
292
|
+
t.assert(fenced.message !== "", "a fenced claim: the refusal is in words");
|
|
293
|
+
t.equal((await listed("after the fenced claim")).labels[EPOCH_LABEL], "2", "after the fenced claim: its epoch");
|
|
294
|
+
t.ok(await t.provider.release(ref, "delete"), "release delete of the agent's computer");
|
|
295
|
+
t.deepEqual(await names(t, labels), [], "listed after delete");
|
|
296
|
+
}, { level: "full", needs: ["persistence", "files"] }),
|
|
208
297
|
provider("network-change", async (t) => {
|
|
209
298
|
const spec = t.spec({ labels: own(t, "network") });
|
|
210
299
|
const ref = await t.create(spec);
|
package/dist/conformance/cli.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
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
|
+
import { randomBytes } from "node:crypto";
|
|
6
7
|
import { resolve } from "node:path";
|
|
7
8
|
import { pathToFileURL } from "node:url";
|
|
8
9
|
import { isCommand } from "../entry.js";
|
|
@@ -14,24 +15,33 @@ import { formatReport } from "./report.js";
|
|
|
14
15
|
import { runConformance } from "./runner.js";
|
|
15
16
|
/** Writes text and settles once the stream has taken it, so an exit after it cuts nothing off. */
|
|
16
17
|
const write = (stream, text) => new Promise((resolve) => void stream.write(text, () => resolve()));
|
|
17
|
-
const USAGE = `usage: npm run conformance -w @parcha/agentrun-computer -- --provider ${providerIds.join("|")}|<module.js> [--image <image>] [--only <group|case>,... | --kind <kind>] [--fixture <path>] [--json]
|
|
18
|
+
const USAGE = `usage: npm run conformance -w @parcha/agentrun-computer -- --provider ${providerIds.join("|")}|<module.js> [--image <image>] [--only <group|case>,... | --kind <kind>] [--fixture <path>] [--gpu <type>[:<count>]] [--json]
|
|
18
19
|
--provider a computer in the registry (${providerIds.join(", ")}), or a module path: a provider file that exports
|
|
19
20
|
create(options), or a conformance module that exports createProvider() (and, for the drift case,
|
|
20
21
|
createDriftedProvider(); for the mount cases, mountFor(kind), a fresh run folder for that mount kind)
|
|
21
22
|
--image the image every computer starts from (default the module's conformanceImage(), else debian:bookworm-slim)
|
|
22
23
|
--only run only these groups (health, exec, files, process, provider, drift, mount, screen, input, touch,
|
|
23
|
-
apps, lifetime; browser, run alone for a provider of kind browser) or case ids; a run that leaves Core cases out is partial: no Core verdict, and exit 3 when
|
|
24
|
+
apps, lifetime, gpu; browser, run alone for a provider of kind browser) or case ids; a run that leaves Core cases out is partial: no Core verdict, and exit 3 when
|
|
24
25
|
every case that ran passed
|
|
25
26
|
--kind run a setting kind's cases (sandbox, desktop, phone, browser) and exit on its verdict: the provider passes the kind only
|
|
26
27
|
when it serves it and every case of each required group passes; not with --only
|
|
27
28
|
--fixture the fixture the screen, input, touch and apps cases check effects with: computerd-fixture for a
|
|
28
29
|
desktop, the fixture APK for an Android phone
|
|
30
|
+
--gpu the GPU the gpu case's one computer asks for, a type the provider declares and a count (default 1), such
|
|
31
|
+
as T4 or H100:2; it bills by the second, so without it the gpu case skips
|
|
29
32
|
--json print the report as JSON
|
|
30
33
|
exit: 0 Core passes, 1 it fails, 2 usage error, 3 partial (--only) and every case that ran passed; with --kind,
|
|
31
34
|
0 the provider passes the kind, 1 it does not`;
|
|
32
35
|
const PROVIDER_METHODS = ["capabilities", "check", "create", "attach", "list", "network", "connect", "release"];
|
|
33
36
|
class Usage extends Error {
|
|
34
37
|
}
|
|
38
|
+
/** --gpu's value: a type, then :count (default 1), such as T4 or H100:2; whether the provider offers it is check()'s. */
|
|
39
|
+
function gpuOf(text) {
|
|
40
|
+
const match = /^([^:\s]+)(?::([1-9][0-9]*))?$/.exec(text);
|
|
41
|
+
if (match === null)
|
|
42
|
+
throw new Usage(`--gpu: ${JSON.stringify(text)} is not <type>[:<count>], such as T4 or H100:2`);
|
|
43
|
+
return { type: match[1], count: match[2] === undefined ? 1 : Number(match[2]) };
|
|
44
|
+
}
|
|
35
45
|
function parse(argv, cases) {
|
|
36
46
|
const args = { json: false, help: false };
|
|
37
47
|
for (let i = 0; i < argv.length; i++) {
|
|
@@ -59,6 +69,8 @@ function parse(argv, cases) {
|
|
|
59
69
|
}
|
|
60
70
|
else if (flag === "--fixture")
|
|
61
71
|
args.fixture = value();
|
|
72
|
+
else if (flag === "--gpu")
|
|
73
|
+
args.gpu = gpuOf(value());
|
|
62
74
|
else if (flag === "--json")
|
|
63
75
|
args.json = true;
|
|
64
76
|
else if (flag === "--help" || flag === "-h")
|
|
@@ -84,6 +96,7 @@ function parse(argv, cases) {
|
|
|
84
96
|
...(args.only ? { only: args.only } : {}),
|
|
85
97
|
...(args.kind ? { kind: args.kind } : {}),
|
|
86
98
|
...(args.fixture ? { fixture: args.fixture } : {}),
|
|
99
|
+
...(args.gpu ? { gpu: args.gpu } : {}),
|
|
87
100
|
json: args.json,
|
|
88
101
|
help: false,
|
|
89
102
|
};
|
|
@@ -98,6 +111,13 @@ const BARE = /^[A-Za-z][A-Za-z0-9-]*$/;
|
|
|
98
111
|
* reads no environment), with no drifted twin.
|
|
99
112
|
*/
|
|
100
113
|
async function conformanceModule(name, cwd) {
|
|
114
|
+
const found = await moduleFor(name, cwd);
|
|
115
|
+
// What the provider file declares of itself (its CAPABILITIES; its descriptor once that lands), kept across the switch
|
|
116
|
+
// to its conformance module, for health.declared.
|
|
117
|
+
const declared = found.file.CAPABILITIES;
|
|
118
|
+
return { label: found.label, module: found.module, ...(Array.isArray(declared) ? { declared: declared } : {}) };
|
|
119
|
+
}
|
|
120
|
+
async function moduleFor(name, cwd) {
|
|
101
121
|
let label = name;
|
|
102
122
|
let module;
|
|
103
123
|
if (isProviderId(name)) {
|
|
@@ -116,7 +136,7 @@ async function conformanceModule(name, cwd) {
|
|
|
116
136
|
}
|
|
117
137
|
}
|
|
118
138
|
if (typeof module.conformance === "function")
|
|
119
|
-
return { label, module: await module.conformance() };
|
|
139
|
+
return { label, module: await module.conformance(), file: module };
|
|
120
140
|
if (typeof module.createProvider !== "function" && typeof module.create === "function") {
|
|
121
141
|
const create = module.create;
|
|
122
142
|
return {
|
|
@@ -127,15 +147,18 @@ async function conformanceModule(name, cwd) {
|
|
|
127
147
|
return create(rest);
|
|
128
148
|
},
|
|
129
149
|
},
|
|
150
|
+
file: module,
|
|
130
151
|
};
|
|
131
152
|
}
|
|
132
|
-
return { label, module: module };
|
|
153
|
+
return { label, module: module, file: module };
|
|
133
154
|
}
|
|
155
|
+
/** A name of a module's ENV that holds a secret: an API key, a token, a token's secret. */
|
|
156
|
+
const SECRET_NAME = /(^|_)(KEY|TOKEN|SECRET)(_|$)/;
|
|
134
157
|
/**
|
|
135
158
|
* The provider a conformance module makes, its drifted twin and its run folders (mountFor) when it offers them, and what
|
|
136
159
|
* it says of its run: conformanceImage(), the image when --image names none, and conformanceNotes, strings for the report.
|
|
137
160
|
*/
|
|
138
|
-
async function load(label, module, options) {
|
|
161
|
+
async function load(label, module, options, declared) {
|
|
139
162
|
const { createProvider, createDriftedProvider, conformanceImage, mountFor } = module;
|
|
140
163
|
if (typeof createProvider !== "function")
|
|
141
164
|
throw new Usage(`${label} does not export createProvider() or create()`);
|
|
@@ -147,6 +170,19 @@ async function load(label, module, options) {
|
|
|
147
170
|
const target = { provider };
|
|
148
171
|
if (typeof createDriftedProvider === "function")
|
|
149
172
|
target.drifted = async () => (await createDriftedProvider(options));
|
|
173
|
+
// The provider file's own declaration; without it, the runner takes the kind registry's entry for the provider's id.
|
|
174
|
+
if (declared !== undefined)
|
|
175
|
+
target.declared = declared;
|
|
176
|
+
// The same provider built with a planted value in each name of its ENV that holds a secret: a fresh one each time.
|
|
177
|
+
const secretNames = Object.values(module.ENV ?? {}).filter((name) => typeof name === "string" && SECRET_NAME.test(name));
|
|
178
|
+
if (secretNames.length > 0) {
|
|
179
|
+
target.planted = async () => {
|
|
180
|
+
const secrets = secretNames.map(() => `agentrun-planted-${randomBytes(12).toString("hex")}`);
|
|
181
|
+
const given = options.env ?? process.env;
|
|
182
|
+
const env = { ...given, ...Object.fromEntries(secretNames.map((name, i) => [name, secrets[i]])) };
|
|
183
|
+
return { provider: (await createProvider({ ...options, env })), secrets };
|
|
184
|
+
};
|
|
185
|
+
}
|
|
150
186
|
if (typeof mountFor === "function")
|
|
151
187
|
target.mountFor = (kind) => mountFor(kind, options);
|
|
152
188
|
if (conformanceImage !== undefined) {
|
|
@@ -184,8 +220,8 @@ export async function main(argv, io = {}) {
|
|
|
184
220
|
const options = { ...(io.providerOptions ?? {}), onNote: (note) => providerNotes.push({ computer: note.computer, note: note.note }) };
|
|
185
221
|
let target;
|
|
186
222
|
try {
|
|
187
|
-
const { label, module } = await conformanceModule(args.provider, cwd);
|
|
188
|
-
target = await load(label, module, options);
|
|
223
|
+
const { label, module, declared } = await conformanceModule(args.provider, cwd);
|
|
224
|
+
target = await load(label, module, options, declared);
|
|
189
225
|
}
|
|
190
226
|
catch (error) {
|
|
191
227
|
await write(stderr, `${error.message}\n`);
|
|
@@ -204,8 +240,11 @@ export async function main(argv, io = {}) {
|
|
|
204
240
|
...(args.only ? { only: args.only } : {}),
|
|
205
241
|
...(args.kind ? { kind: args.kind } : {}),
|
|
206
242
|
...(args.fixture ? { fixture: resolve(cwd, args.fixture) } : {}),
|
|
243
|
+
...(args.gpu ? { gpu: args.gpu } : {}),
|
|
207
244
|
...(signal ? { signal } : {}),
|
|
208
245
|
...(target.drifted ? { drifted: target.drifted } : {}),
|
|
246
|
+
...(target.declared ? { declared: target.declared } : {}),
|
|
247
|
+
...(target.planted ? { planted: target.planted } : {}),
|
|
209
248
|
...(target.mountFor ? { mountFor: target.mountFor } : {}),
|
|
210
249
|
...(onResult ? { onResult } : {}),
|
|
211
250
|
...(io.cdp ? { cdp: io.cdp } : {}),
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
// read only when createProvider() runs. Every sandbox of a run has a bounded life besides its TTL: Daytona stops one
|
|
5
5
|
// after 30 minutes with no outside activity and deletes it as soon as it stops, so a stop deletes, and the provider
|
|
6
6
|
// declares it (stopDeletes; see conformanceNotes).
|
|
7
|
-
import { create
|
|
7
|
+
import { create } from "../daytona.js";
|
|
8
|
+
import { DAYTONA_DEFAULT_SNAPSHOT } from "../descriptors/daytona.js";
|
|
8
9
|
import { archilRunFolder, archilSettings } from "./archil.js";
|
|
9
10
|
import { buildDriftDaemon, DRIFT_VERSION } from "./drift-daemon.js";
|
|
10
11
|
/** The Archil disk's settings for the mount cases, by name (COMPUTER_ARCHIL_*: all five, or none). */
|
package/dist/conformance/e2b.js
CHANGED
|
@@ -15,7 +15,8 @@
|
|
|
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 {
|
|
18
|
+
import { E2B_BASE_TEMPLATE, E2B_DESKTOP_TEMPLATE } from "../descriptors/e2b.js";
|
|
19
|
+
import { create } from "../e2b.js";
|
|
19
20
|
import { archilRunFolder, archilSettings } from "./archil.js";
|
|
20
21
|
import { buildDriftDaemon, DRIFT_VERSION } from "./drift-daemon.js";
|
|
21
22
|
/** The Archil disk's settings for the mount cases, by name (COMPUTER_ARCHIL_*: all five, or none). */
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
// every input event it gets as one JSON line in a file the case reads over files. On a desktop it is computerd-fixture,
|
|
3
3
|
// a test-only static binary: a 200x200 override-redirect window at (0, 0) in four known colors, which grabs focus. On
|
|
4
4
|
// Android it is a small APK that logs touches and its own launch to its files directory and shows a button with a fixed
|
|
5
|
-
// id. This file is their contract: the binary and the APK come with the PRs that first run them.
|
|
5
|
+
// id. This file is their contract: the binary and the APK come with the PRs that first run them. On a Windows desktop it
|
|
6
|
+
// is a PowerShell script this package carries (windows-fixture.ts), the same window, started detached with Start-Process.
|
|
6
7
|
import { readFileSync } from "node:fs";
|
|
7
8
|
import { readFile, writeFile } from "../files.js";
|
|
9
|
+
import { WINDOWS_FIXTURE } from "./windows-fixture.js";
|
|
8
10
|
/** The desktop fixture's window, in screenshot pixels. */
|
|
9
11
|
export const FIXTURE_WINDOW = [0, 0, 200, 200];
|
|
10
12
|
/** The window's quadrants in RGB: top left, top right, bottom left, bottom right. */
|
|
@@ -59,7 +61,27 @@ async function ready(t, events, what) {
|
|
|
59
61
|
* the fixture's stop as soon as it is launched, before it logs ready, so a fixture that never does is stopped too.
|
|
60
62
|
*/
|
|
61
63
|
export async function startFixture(t, path, launched) {
|
|
62
|
-
const { kind } = t.provider.capabilities();
|
|
64
|
+
const { kind, os } = t.provider.capabilities();
|
|
65
|
+
if (kind === "desktop" && os === "windows") {
|
|
66
|
+
// No processes on a Windows desktop Orgo's API answers: the script is started detached with Start-Process (its
|
|
67
|
+
// file and its log as one argument list) and stopped by the pid its ready line logs.
|
|
68
|
+
needs(t, ["exec", "files"], "the Windows desktop fixture");
|
|
69
|
+
const dir = await t.dir();
|
|
70
|
+
const script = `${dir}\\agentrun-fixture.ps1`;
|
|
71
|
+
const log = `${dir}\\events.jsonl`;
|
|
72
|
+
t.ok(await writeFile(t.client, script, Buffer.from(WINDOWS_FIXTURE, "utf8"), { signal: t.signal }), `files.write of the fixture to ${script}`);
|
|
73
|
+
const started = await t.exec(["Start-Process", "powershell.exe", `-NoProfile -ExecutionPolicy Bypass -STA -WindowStyle Hidden -File "${script}" "${log}"`]);
|
|
74
|
+
t.equal(started.exitCode, 0, `Start-Process of the fixture (stderr ${JSON.stringify(started.err.trim())})`);
|
|
75
|
+
const events = () => logOf(t, log);
|
|
76
|
+
const stop = async () => {
|
|
77
|
+
const ready = (await events().catch(() => [])).find((e) => e.event === "ready");
|
|
78
|
+
if (Number.isSafeInteger(ready?.pid))
|
|
79
|
+
await t.client.call("exec.run", { argv: ["taskkill.exe", "/PID", String(ready?.pid), "/F"], timeoutMs: 30_000 });
|
|
80
|
+
};
|
|
81
|
+
launched(stop);
|
|
82
|
+
await ready(t, events, "the Windows desktop fixture");
|
|
83
|
+
return { bounds: FIXTURE_WINDOW, events, stop };
|
|
84
|
+
}
|
|
63
85
|
if (kind === "desktop") {
|
|
64
86
|
needs(t, ["exec", "files", "processes"], "the desktop fixture");
|
|
65
87
|
const dir = await t.dir();
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// COMPUTER_KERNEL_API_KEY. The provider reads no environment: this module reads its own COMPUTER_KERNEL_* names (never
|
|
4
4
|
// KERNEL_API_KEY, which may hold another organization's key) and passes each to create() as its option. The live switch
|
|
5
5
|
// is checked first, before any other setting is read. The run makes one browser, shared by every case, and deletes it.
|
|
6
|
-
import { BROWSER_IMAGE } from "../
|
|
6
|
+
import { BROWSER_IMAGE } from "../descriptors/shared.js";
|
|
7
7
|
import { create } from "../kernel.js";
|
|
8
8
|
/** The environment this module reads, by name, each for the option its comment names, and the live switch. */
|
|
9
9
|
export const KERNEL_ENV = {
|
package/dist/conformance/kind.js
CHANGED
|
@@ -45,7 +45,8 @@ export function kindVerdict(kind, capabilities, report, cases = suiteOf(kind)) {
|
|
|
45
45
|
for (const group of SETTING_KINDS[kind].required) {
|
|
46
46
|
const ofGroup = report.results.filter((result) => byId.get(result.id)?.needs.includes(group));
|
|
47
47
|
for (const result of ofGroup) {
|
|
48
|
-
|
|
48
|
+
// A case written for another system is not this computer's: its skip is no reason the kind fails.
|
|
49
|
+
if (result.status === "skip" && result.undeclared === undefined && result.os === undefined && byId.get(result.id)?.level === "core")
|
|
49
50
|
reasons.push(`${result.id} was skipped: ${result.reason ?? "no reason given"}`);
|
|
50
51
|
}
|
|
51
52
|
if (!ofGroup.some((result) => result.status === "pass"))
|