@parcha/agentrun-computer 0.0.0-stage → 0.1.0-beta.33
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/LICENSE +202 -0
- package/NOTICE +8 -0
- package/README.md +2411 -2
- package/box/Dockerfile +69 -0
- package/box/agentrun-archil +168 -0
- package/box/build-daytona.py +26 -0
- package/box/build-e2b.mjs +32 -0
- package/box/build-modal.py +17 -0
- package/dist/actions.d.ts +18 -0
- package/dist/actions.js +139 -0
- package/dist/browser.d.ts +151 -0
- package/dist/browser.js +305 -0
- package/dist/browserbase.d.ts +139 -0
- package/dist/browserbase.js +408 -0
- package/dist/child.d.ts +40 -0
- package/dist/child.js +127 -0
- package/dist/client.d.ts +22 -0
- package/dist/client.js +136 -0
- package/dist/computerd-linux-amd64 +0 -0
- package/dist/computerd-linux-arm64 +0 -0
- package/dist/conformance/archil.d.ts +68 -0
- package/dist/conformance/archil.js +152 -0
- package/dist/conformance/browserbase.d.ts +35 -0
- package/dist/conformance/browserbase.js +45 -0
- package/dist/conformance/cases/apps.d.ts +2 -0
- package/dist/conformance/cases/apps.js +155 -0
- package/dist/conformance/cases/browser.d.ts +4 -0
- package/dist/conformance/cases/browser.js +105 -0
- package/dist/conformance/cases/drift.d.ts +2 -0
- package/dist/conformance/cases/drift.js +64 -0
- package/dist/conformance/cases/exec.d.ts +2 -0
- package/dist/conformance/cases/exec.js +125 -0
- package/dist/conformance/cases/files.d.ts +2 -0
- package/dist/conformance/cases/files.js +294 -0
- package/dist/conformance/cases/health.d.ts +2 -0
- package/dist/conformance/cases/health.js +71 -0
- package/dist/conformance/cases/index.d.ts +9 -0
- package/dist/conformance/cases/index.js +37 -0
- package/dist/conformance/cases/input.d.ts +12 -0
- package/dist/conformance/cases/input.js +109 -0
- package/dist/conformance/cases/isolation.d.ts +21 -0
- package/dist/conformance/cases/isolation.js +98 -0
- package/dist/conformance/cases/lifetime.d.ts +2 -0
- package/dist/conformance/cases/lifetime.js +64 -0
- package/dist/conformance/cases/mount.d.ts +2 -0
- package/dist/conformance/cases/mount.js +252 -0
- package/dist/conformance/cases/process.d.ts +2 -0
- package/dist/conformance/cases/process.js +240 -0
- package/dist/conformance/cases/provider.d.ts +2 -0
- package/dist/conformance/cases/provider.js +302 -0
- package/dist/conformance/cases/screen.d.ts +9 -0
- package/dist/conformance/cases/screen.js +230 -0
- package/dist/conformance/cases/settings.d.ts +57 -0
- package/dist/conformance/cases/settings.js +142 -0
- package/dist/conformance/cases/touch.d.ts +2 -0
- package/dist/conformance/cases/touch.js +117 -0
- package/dist/conformance/cases/util.d.ts +7 -0
- package/dist/conformance/cases/util.js +8 -0
- package/dist/conformance/cdp.d.ts +13 -0
- package/dist/conformance/cdp.js +88 -0
- package/dist/conformance/cli.d.ts +29 -0
- package/dist/conformance/cli.js +231 -0
- package/dist/conformance/daytona-sweep.d.ts +18 -0
- package/dist/conformance/daytona-sweep.js +126 -0
- package/dist/conformance/daytona.d.ts +83 -0
- package/dist/conformance/daytona.js +107 -0
- package/dist/conformance/docker.d.ts +38 -0
- package/dist/conformance/docker.js +70 -0
- package/dist/conformance/drift-daemon.d.ts +8 -0
- package/dist/conformance/drift-daemon.js +41 -0
- package/dist/conformance/e2b-diagnose.d.ts +16 -0
- package/dist/conformance/e2b-diagnose.js +61 -0
- package/dist/conformance/e2b-sweep.d.ts +18 -0
- package/dist/conformance/e2b-sweep.js +132 -0
- package/dist/conformance/e2b.d.ts +74 -0
- package/dist/conformance/e2b.js +111 -0
- package/dist/conformance/fixture.d.ts +65 -0
- package/dist/conformance/fixture.js +98 -0
- package/dist/conformance/index.d.ts +8 -0
- package/dist/conformance/index.js +8 -0
- package/dist/conformance/kernel.d.ts +31 -0
- package/dist/conformance/kernel.js +40 -0
- package/dist/conformance/kind.d.ts +23 -0
- package/dist/conformance/kind.js +58 -0
- package/dist/conformance/modal-sweep.d.ts +22 -0
- package/dist/conformance/modal-sweep.js +213 -0
- package/dist/conformance/modal.d.ts +69 -0
- package/dist/conformance/modal.js +76 -0
- package/dist/conformance/orgo.d.ts +41 -0
- package/dist/conformance/orgo.js +69 -0
- package/dist/conformance/phone-harness.d.ts +61 -0
- package/dist/conformance/phone-harness.js +241 -0
- package/dist/conformance/png.d.ts +16 -0
- package/dist/conformance/png.js +132 -0
- package/dist/conformance/report.d.ts +2 -0
- package/dist/conformance/report.js +86 -0
- package/dist/conformance/runner.d.ts +11 -0
- package/dist/conformance/runner.js +585 -0
- package/dist/conformance/tar.d.ts +13 -0
- package/dist/conformance/tar.js +105 -0
- package/dist/conformance/types.d.ts +257 -0
- package/dist/conformance/types.js +24 -0
- package/dist/daemon-copy.d.ts +40 -0
- package/dist/daemon-copy.js +259 -0
- package/dist/daytona.d.ts +180 -0
- package/dist/daytona.js +1498 -0
- package/dist/desktop.d.ts +24 -0
- package/dist/desktop.js +68 -0
- package/dist/docker/egress-main.d.ts +1 -0
- package/dist/docker/egress-main.js +68 -0
- package/dist/docker/egress-proxy.d.ts +53 -0
- package/dist/docker/egress-proxy.js +450 -0
- package/dist/docker/egress-table.d.ts +39 -0
- package/dist/docker/egress-table.js +197 -0
- package/dist/docker/egress.d.ts +109 -0
- package/dist/docker/egress.js +318 -0
- package/dist/docker/image.d.ts +49 -0
- package/dist/docker/image.js +302 -0
- package/dist/docker/stage.d.ts +21 -0
- package/dist/docker/stage.js +290 -0
- package/dist/docker/volume.d.ts +24 -0
- package/dist/docker/volume.js +67 -0
- package/dist/docker.d.ts +156 -0
- package/dist/docker.js +1277 -0
- package/dist/drift.d.ts +200 -0
- package/dist/drift.js +416 -0
- package/dist/e2b.d.ts +337 -0
- package/dist/e2b.js +1516 -0
- package/dist/entry.d.ts +2 -0
- package/dist/entry.js +24 -0
- package/dist/files.d.ts +50 -0
- package/dist/files.js +208 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +26 -0
- package/dist/isolation.d.ts +29 -0
- package/dist/isolation.js +71 -0
- package/dist/janitor.d.ts +50 -0
- package/dist/janitor.js +135 -0
- package/dist/kernel.d.ts +113 -0
- package/dist/kernel.js +358 -0
- package/dist/kinds.d.ts +79 -0
- package/dist/kinds.js +133 -0
- package/dist/labels.d.ts +23 -0
- package/dist/labels.js +50 -0
- package/dist/modal.d.ts +302 -0
- package/dist/modal.js +1374 -0
- package/dist/mount-archil.d.ts +164 -0
- package/dist/mount-archil.js +471 -0
- package/dist/mount.d.ts +57 -0
- package/dist/mount.js +104 -0
- package/dist/orgo-channel.d.ts +96 -0
- package/dist/orgo-channel.js +391 -0
- package/dist/orgo.d.ts +139 -0
- package/dist/orgo.js +1006 -0
- package/dist/phone-harness.d.ts +185 -0
- package/dist/phone-harness.js +1420 -0
- package/dist/processes.d.ts +24 -0
- package/dist/processes.js +40 -0
- package/dist/protocol.d.ts +729 -0
- package/dist/protocol.js +54 -0
- package/dist/provider.d.ts +245 -0
- package/dist/provider.js +37 -0
- package/dist/providers.d.ts +68 -0
- package/dist/providers.js +25 -0
- package/dist/result.d.ts +15 -0
- package/dist/result.js +2 -0
- package/dist/screen-watch.d.ts +150 -0
- package/dist/screen-watch.js +490 -0
- package/dist/test-connection.d.ts +17 -0
- package/dist/test-connection.js +26 -0
- package/dist/wait.d.ts +23 -0
- package/dist/wait.js +65 -0
- package/package.json +62 -4
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// The daemon answers: hello, ping, and an error in words for a method it does not have; and the computer is the kind
|
|
2
|
+
// it says it is.
|
|
3
|
+
import { GROUPS } from "../../protocol.js";
|
|
4
|
+
import { kindRefusals } from "../../provider.js";
|
|
5
|
+
import { coreGroups } from "../types.js";
|
|
6
|
+
export const healthCases = [
|
|
7
|
+
{
|
|
8
|
+
id: "health.hello",
|
|
9
|
+
level: "core",
|
|
10
|
+
group: "health",
|
|
11
|
+
needs: [],
|
|
12
|
+
async run(t) {
|
|
13
|
+
const hello = t.ok(await t.client.call("hello", { client: "agentrun conformance" }), "hello");
|
|
14
|
+
t.equal(typeof hello.version, "string", "hello's version is a string");
|
|
15
|
+
t.assert(hello.version !== "", "hello names a version");
|
|
16
|
+
t.equal(hello.os, t.provider.capabilities().os, "hello's os is the one the provider declares");
|
|
17
|
+
t.assert(typeof hello.arch === "string" && hello.arch !== "", "hello names an arch");
|
|
18
|
+
t.assert(Array.isArray(hello.groups), "hello lists groups");
|
|
19
|
+
t.deepEqual(hello, t.hello, "hello on this call and at connect");
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: "health.ping",
|
|
24
|
+
level: "core",
|
|
25
|
+
group: "health",
|
|
26
|
+
needs: [],
|
|
27
|
+
async run(t) {
|
|
28
|
+
t.deepEqual(await t.call("ping", {}), {}, "ping");
|
|
29
|
+
t.deepEqual(await t.call("ping", {}), {}, "a second ping");
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: "health.unknown-method",
|
|
34
|
+
level: "core",
|
|
35
|
+
group: "health",
|
|
36
|
+
needs: [],
|
|
37
|
+
async run(t) {
|
|
38
|
+
const unknown = await t.client.call("no.such.method", {});
|
|
39
|
+
const error = t.refused(unknown, "a method the daemon does not have", ["unsupported"]);
|
|
40
|
+
t.assert(error.message !== "", "the refusal is in words");
|
|
41
|
+
t.deepEqual(await t.call("ping", {}), {}, "ping after it: the connection goes on");
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: "health.kind-consistent",
|
|
46
|
+
level: "core",
|
|
47
|
+
group: "health",
|
|
48
|
+
needs: [],
|
|
49
|
+
async run(t) {
|
|
50
|
+
const declared = t.provider.capabilities();
|
|
51
|
+
const { kind, os, daemon, groups } = declared;
|
|
52
|
+
const refusals = kindRefusals(declared);
|
|
53
|
+
t.assert(refusals.length === 0, `kind ${kind}, os ${os} and daemon ${daemon} are not a valid pair: ${refusals.map((r) => r.message).join("; ")}`);
|
|
54
|
+
t.assert(Array.isArray(groups), "capabilities().groups is a list");
|
|
55
|
+
const unknown = groups.filter((group) => !GROUPS.includes(group));
|
|
56
|
+
t.deepEqual(unknown, [], "the groups capabilities() declares that the protocol does not have");
|
|
57
|
+
t.equal(t.hello.kind, kind, "hello's kind is the one the provider declares");
|
|
58
|
+
t.assert(Array.isArray(t.hello.groups), "hello lists groups");
|
|
59
|
+
t.deepEqual([...t.hello.groups].sort(), [...groups].sort(), "hello's groups are the ones the provider declares");
|
|
60
|
+
const who = daemon === "none" ? `a ${kind} computer` : `a ${kind} computer with daemon ${daemon}`;
|
|
61
|
+
for (const need of coreGroups(kind, daemon)) {
|
|
62
|
+
if (need === "network:none")
|
|
63
|
+
t.assert(declared.network.includes("none"), `${who} must declare network none`);
|
|
64
|
+
else if (need === "vendor-agent")
|
|
65
|
+
t.assert(Array.isArray(declared.vendorAgentPorts), `${who} must declare its vendor's agent's ports (vendorAgentPorts)`);
|
|
66
|
+
else
|
|
67
|
+
t.assert(groups.includes(need), `${who} must declare ${need}`);
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ComputerKind } from "../../protocol.js";
|
|
2
|
+
import type { Case } from "../types.js";
|
|
3
|
+
export { browserCases, browserOnlyCases } from "./browser.js";
|
|
4
|
+
export declare const conformanceCases: Case[];
|
|
5
|
+
/**
|
|
6
|
+
* The cases a run takes when it is given none, by the machine kind of the computer: a browser's own (health, then the
|
|
7
|
+
* browser cases, which keep one browser for the run), every other kind the suite's. The CLI and runConformance agree.
|
|
8
|
+
*/
|
|
9
|
+
export declare function casesFor(machineKind: ComputerKind | undefined): Case[];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { appsCases } from "./apps.js";
|
|
2
|
+
import { browserCases } from "./browser.js";
|
|
3
|
+
import { driftCases } from "./drift.js";
|
|
4
|
+
import { execCases } from "./exec.js";
|
|
5
|
+
import { filesCases } from "./files.js";
|
|
6
|
+
import { healthCases } from "./health.js";
|
|
7
|
+
import { inputCases } from "./input.js";
|
|
8
|
+
import { isolationCases } from "./isolation.js";
|
|
9
|
+
import { lifetimeCases } from "./lifetime.js";
|
|
10
|
+
import { mountCases } from "./mount.js";
|
|
11
|
+
import { processCases } from "./process.js";
|
|
12
|
+
import { providerCases } from "./provider.js";
|
|
13
|
+
import { screenCases } from "./screen.js";
|
|
14
|
+
import { touchCases } from "./touch.js";
|
|
15
|
+
export { browserCases, browserOnlyCases } from "./browser.js";
|
|
16
|
+
export const conformanceCases = [
|
|
17
|
+
...healthCases,
|
|
18
|
+
...execCases,
|
|
19
|
+
...filesCases,
|
|
20
|
+
...processCases,
|
|
21
|
+
...providerCases,
|
|
22
|
+
...driftCases,
|
|
23
|
+
...isolationCases,
|
|
24
|
+
...mountCases,
|
|
25
|
+
...screenCases,
|
|
26
|
+
...inputCases,
|
|
27
|
+
...touchCases,
|
|
28
|
+
...appsCases,
|
|
29
|
+
...lifetimeCases,
|
|
30
|
+
];
|
|
31
|
+
/**
|
|
32
|
+
* The cases a run takes when it is given none, by the machine kind of the computer: a browser's own (health, then the
|
|
33
|
+
* browser cases, which keep one browser for the run), every other kind the suite's. The CLI and runConformance agree.
|
|
34
|
+
*/
|
|
35
|
+
export function casesFor(machineKind) {
|
|
36
|
+
return machineKind === "browser" ? browserCases : conformanceCases;
|
|
37
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { InputAction, InputActionsResult, Point } from "../../protocol.js";
|
|
2
|
+
import type { FixtureEvent, StartedFixture } from "../fixture.js";
|
|
3
|
+
import type { Case, CaseContext } from "../types.js";
|
|
4
|
+
/** A point inside the fixture, at these fractions of its width and height. */
|
|
5
|
+
export declare const pointIn: ({ bounds: [x, y, w, h] }: StartedFixture, fx: number, fy: number) => Point;
|
|
6
|
+
export declare const act: (t: CaseContext, actions: InputAction[]) => Promise<InputActionsResult>;
|
|
7
|
+
/** Asserts every action of the batch ran. */
|
|
8
|
+
export declare function allRan(t: CaseContext, result: InputActionsResult, count: number, what: string): void;
|
|
9
|
+
/** The events logged after the first `from`, once until() finds what it waits for in them. */
|
|
10
|
+
export declare function logged(t: CaseContext, fixture: StartedFixture, from: number, done: (events: FixtureEvent[]) => boolean, what: string): Promise<FixtureEvent[]>;
|
|
11
|
+
export declare const TYPED = "Hello, agentrun! 123";
|
|
12
|
+
export declare const inputCases: Case[];
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { openSearch, openSettings, searchText, throughSettings } from "./settings.js";
|
|
2
|
+
/** A point inside the fixture, at these fractions of its width and height. */
|
|
3
|
+
export const pointIn = ({ bounds: [x, y, w, h] }, fx, fy) => [Math.floor(x + fx * w), Math.floor(y + fy * h)];
|
|
4
|
+
export const act = (t, actions) => t.call("input.actions", { actions });
|
|
5
|
+
/** Asserts every action of the batch ran. */
|
|
6
|
+
export function allRan(t, result, count, what) {
|
|
7
|
+
t.deepEqual(result, { done: count }, `input.actions of ${what}`);
|
|
8
|
+
}
|
|
9
|
+
/** The events logged after the first `from`, once until() finds what it waits for in them. */
|
|
10
|
+
export async function logged(t, fixture, from, done, what) {
|
|
11
|
+
return t.until(async () => {
|
|
12
|
+
const events = (await fixture.events()).slice(from);
|
|
13
|
+
return done(events) ? events : undefined;
|
|
14
|
+
}, what);
|
|
15
|
+
}
|
|
16
|
+
/** The pointer's presses and releases, in order, as [event, button, x, y]. */
|
|
17
|
+
const pointer = (events) => events.flatMap((e) => (e.event === "down" || e.event === "up" ? [[e.event, e.button, ...e.at]] : []));
|
|
18
|
+
/** Releases logged, at `at` when given, else anywhere: a click that lands elsewhere is still waited for, then compared. */
|
|
19
|
+
const ups = (events, at) => events.filter((e) => e.event === "up" && (at === undefined || (e.at[0] === at[0] && e.at[1] === at[1]))).length;
|
|
20
|
+
const text = (events) => events.flatMap((e) => (e.event === "text" ? [e.text] : [])).join("");
|
|
21
|
+
/** Whether the provider and the computer both declare group. */
|
|
22
|
+
const declares = (t, group) => t.provider.capabilities().groups.includes(group) && t.hello.groups.includes(group);
|
|
23
|
+
export const TYPED = "Hello, agentrun! 123";
|
|
24
|
+
/** A point no display has. */
|
|
25
|
+
const OFF_SCREEN = [100_000, 100_000];
|
|
26
|
+
const input = (name, needs, run) => ({ id: `input.${name}`, level: "core", group: "input", needs, run });
|
|
27
|
+
export const inputCases = [
|
|
28
|
+
input("click-lands", ["input.pointer"], async (t) => {
|
|
29
|
+
const fixture = await t.fixture();
|
|
30
|
+
const a = pointIn(fixture, 0.2, 0.3);
|
|
31
|
+
const b = pointIn(fixture, 0.7, 0.6);
|
|
32
|
+
const before = (await fixture.events()).length;
|
|
33
|
+
allRan(t, await act(t, [{ type: "click", at: a }]), 1, `a click at ${a}`);
|
|
34
|
+
const single = await logged(t, fixture, before, (events) => ups(events) >= 1, `a click at ${a} in the fixture's log`);
|
|
35
|
+
t.deepEqual(pointer(single), [["down", "left", ...a], ["up", "left", ...a]], `the fixture's log of a click at ${a}`);
|
|
36
|
+
const middle = before + single.length;
|
|
37
|
+
allRan(t, await act(t, [{ type: "click", at: b, count: 2 }]), 1, `a double click at ${b}`);
|
|
38
|
+
const double = await logged(t, fixture, middle, (events) => ups(events) >= 2, `a double click at ${b} in the fixture's log`);
|
|
39
|
+
t.deepEqual(pointer(double), [["down", "left", ...b], ["up", "left", ...b], ["down", "left", ...b], ["up", "left", ...b]], `the fixture's log of a double click at ${b}`);
|
|
40
|
+
}),
|
|
41
|
+
input("type-text", ["input.keys"], async (t) => {
|
|
42
|
+
if (throughSettings(t)) {
|
|
43
|
+
await openSettings(t);
|
|
44
|
+
await openSearch(t);
|
|
45
|
+
allRan(t, await act(t, [{ type: "type", text: TYPED }]), 1, `typing ${JSON.stringify(TYPED)} into Settings' search field`);
|
|
46
|
+
const typed = await t.until(async () => {
|
|
47
|
+
const text = await searchText(t);
|
|
48
|
+
return text !== undefined && text.length >= TYPED.length ? text : undefined;
|
|
49
|
+
}, `${TYPED.length} characters in Settings' search field`);
|
|
50
|
+
t.equal(typed, TYPED, "the text in Settings' search field");
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const fixture = await t.fixture();
|
|
54
|
+
const before = (await fixture.events()).length;
|
|
55
|
+
allRan(t, await act(t, [{ type: "type", text: TYPED }]), 1, `typing ${JSON.stringify(TYPED)}`);
|
|
56
|
+
const events = await logged(t, fixture, before, (events) => text(events).length >= TYPED.length, `${TYPED.length} characters in the fixture's log`);
|
|
57
|
+
t.equal(text(events), TYPED, "the text the fixture got");
|
|
58
|
+
}),
|
|
59
|
+
input("key-table-refuses-unknown", ["input.keys"], async (t) => {
|
|
60
|
+
if (throughSettings(t)) {
|
|
61
|
+
await openSettings(t);
|
|
62
|
+
await openSearch(t);
|
|
63
|
+
const refused = await act(t, [{ type: "key", keys: ["a"] }, { type: "key", keys: ["Hyper_Q"] }]);
|
|
64
|
+
t.equal(refused.done, 0, "done, for a batch whose second action names a key not in KEYS");
|
|
65
|
+
t.equal(refused.failed?.index, 1, "failed.index");
|
|
66
|
+
t.equal(refused.failed?.kind, "invalid", "failed.kind");
|
|
67
|
+
t.assert(typeof refused.failed?.message === "string" && refused.failed.message !== "", "the failure is in words");
|
|
68
|
+
// A later batch that lands shows the refused one ran nothing before it: the field holds "z" alone, no "a".
|
|
69
|
+
allRan(t, await act(t, [{ type: "type", text: "z" }]), 1, 'typing "z" after the refused batch');
|
|
70
|
+
const typed = await t.until(async () => {
|
|
71
|
+
const text = await searchText(t);
|
|
72
|
+
return text?.includes("z") ? text : undefined;
|
|
73
|
+
}, '"z" in Settings\' search field');
|
|
74
|
+
t.equal(typed, "z", "the text in Settings' search field: the refused batch's first action did not run");
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const fixture = await t.fixture();
|
|
78
|
+
const before = (await fixture.events()).length;
|
|
79
|
+
// The spec's click when the computer has a pointer, else a key: either way the first action is valid.
|
|
80
|
+
const first = declares(t, "input.pointer") ? { type: "click", at: pointIn(fixture, 0.5, 0.5) } : { type: "key", keys: ["a"] };
|
|
81
|
+
const refused = await act(t, [first, { type: "key", keys: ["Hyper_Q"] }]);
|
|
82
|
+
t.equal(refused.done, 0, "done, for a batch whose second action names a key not in KEYS");
|
|
83
|
+
t.equal(refused.failed?.index, 1, "failed.index");
|
|
84
|
+
t.equal(refused.failed?.kind, "invalid", "failed.kind");
|
|
85
|
+
t.assert(typeof refused.failed?.message === "string" && refused.failed.message !== "", "the failure is in words");
|
|
86
|
+
// A later batch that lands shows the refused one ran nothing before it.
|
|
87
|
+
allRan(t, await act(t, [{ type: "type", text: "z" }]), 1, 'typing "z" after the refused batch');
|
|
88
|
+
const events = await logged(t, fixture, before, (events) => text(events).includes("z"), '"z" in the fixture\'s log');
|
|
89
|
+
t.deepEqual(pointer(events), [], "the pointer events of the refused batch");
|
|
90
|
+
t.equal(text(events), "z", "the text the fixture got: the refused batch's first action did not run");
|
|
91
|
+
}),
|
|
92
|
+
input("actions-stops-at-first-failure", ["input.pointer"], async (t) => {
|
|
93
|
+
const fixture = await t.fixture();
|
|
94
|
+
const a = pointIn(fixture, 0.25, 0.25);
|
|
95
|
+
const b = pointIn(fixture, 0.75, 0.75);
|
|
96
|
+
const c = pointIn(fixture, 0.5, 0.5);
|
|
97
|
+
const before = (await fixture.events()).length;
|
|
98
|
+
// The left button is down when the move off-screen fails: the failure must release it, where the cursor still is.
|
|
99
|
+
const stopped = await act(t, [{ type: "move", at: a }, { type: "down", button: "left" }, { type: "move", at: OFF_SCREEN }, { type: "click", at: b }]);
|
|
100
|
+
t.equal(stopped.done, 2, `done, for [move to ${a}, left down, move off-screen to ${OFF_SCREEN}, click ${b}]`);
|
|
101
|
+
t.equal(stopped.failed?.index, 2, "failed.index");
|
|
102
|
+
t.assert(typeof stopped.failed?.message === "string" && stopped.failed.message !== "", "the failure is in words");
|
|
103
|
+
await logged(t, fixture, before, (events) => ups(events, a) >= 1, `the left button the stopped batch pressed at ${a}, released in the fixture's log`);
|
|
104
|
+
// A later click lands normally: nothing the stopped batch did was left held.
|
|
105
|
+
allRan(t, await act(t, [{ type: "click", at: c }]), 1, `a click at ${c} after it`);
|
|
106
|
+
const events = await logged(t, fixture, before, (events) => ups(events, c) >= 1, `the click at ${c} in the fixture's log`);
|
|
107
|
+
t.deepEqual(pointer(events), [["down", "left", ...a], ["up", "left", ...a], ["down", "left", ...c], ["up", "left", ...c]], `the fixture's log: the press at ${a} released, the later click at ${c}, and none at ${b}`);
|
|
108
|
+
}),
|
|
109
|
+
];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ComputerClient } from "../../protocol.js";
|
|
2
|
+
import type { Case, CaseContext } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* The path unix sockets a program of the computer's user may connect to: the computer's own, computerd's and the Archil
|
|
5
|
+
* sync socket (which only syncs). A network namespace does not cut a path socket, so any other is a door out.
|
|
6
|
+
*/
|
|
7
|
+
export declare const OWN_SOCKETS: readonly string[];
|
|
8
|
+
/**
|
|
9
|
+
* The outside the case also probes: a public IP literal on 443, and a DNS name on 443, which a program could reach only
|
|
10
|
+
* through a resolver and a route its own network does not have.
|
|
11
|
+
*/
|
|
12
|
+
export declare const OUTSIDE_TARGETS: string[];
|
|
13
|
+
/**
|
|
14
|
+
* The isolation check, on the computer `client` reaches (the case's own by default): computerd's probe, run as the
|
|
15
|
+
* computer's user, sees its own loopback alone, and is refused at the vendor's agent's declared ports on 127.0.0.1 and
|
|
16
|
+
* ::1 and at OUTSIDE_TARGETS; and the path unix sockets it connects to (the probe's own listing, --sockets) are the
|
|
17
|
+
* computer's own (OWN_SOCKETS, and a desktop's display) alone, each recorded with its type. A probe that reports no
|
|
18
|
+
* socket list, or a search it could not finish, fails the check in words. The Archil case mount.archil-isolated-durable runs the same check on an Archil computer.
|
|
19
|
+
*/
|
|
20
|
+
export declare function assertIsolated(t: CaseContext, client?: ComputerClient): Promise<void>;
|
|
21
|
+
export declare const isolationCases: Case[];
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// A program the computer's user runs reaches none of the vendor's own agent, whose ports each provider declares
|
|
2
|
+
// (capabilities().vendorAgentPorts), and no outside address, and sees its own loopback alone: computerd init
|
|
3
|
+
// --own-network at work.
|
|
4
|
+
import { DAEMON_IN_COMPUTER, SOCKET_DIR } from "../../drift.js";
|
|
5
|
+
import { ARCHIL_SYNC_SOCKET } from "../../mount-archil.js";
|
|
6
|
+
/**
|
|
7
|
+
* The path unix sockets a program of the computer's user may connect to: the computer's own, computerd's and the Archil
|
|
8
|
+
* sync socket (which only syncs). A network namespace does not cut a path socket, so any other is a door out.
|
|
9
|
+
*/
|
|
10
|
+
export const OWN_SOCKETS = [`${SOCKET_DIR}/computerd.sock`, ARCHIL_SYNC_SOCKET];
|
|
11
|
+
/**
|
|
12
|
+
* The outside the case also probes: a public IP literal on 443, and a DNS name on 443, which a program could reach only
|
|
13
|
+
* through a resolver and a route its own network does not have.
|
|
14
|
+
*/
|
|
15
|
+
export const OUTSIDE_TARGETS = ["1.1.1.1:443", "example.com:443"];
|
|
16
|
+
/**
|
|
17
|
+
* The isolation check, on the computer `client` reaches (the case's own by default): computerd's probe, run as the
|
|
18
|
+
* computer's user, sees its own loopback alone, and is refused at the vendor's agent's declared ports on 127.0.0.1 and
|
|
19
|
+
* ::1 and at OUTSIDE_TARGETS; and the path unix sockets it connects to (the probe's own listing, --sockets) are the
|
|
20
|
+
* computer's own (OWN_SOCKETS, and a desktop's display) alone, each recorded with its type. A probe that reports no
|
|
21
|
+
* socket list, or a search it could not finish, fails the check in words. The Archil case mount.archil-isolated-durable runs the same check on an Archil computer.
|
|
22
|
+
*/
|
|
23
|
+
export async function assertIsolated(t, client) {
|
|
24
|
+
const ports = t.provider.capabilities().vendorAgentPorts ?? [];
|
|
25
|
+
t.assert(ports.every((port) => Number.isSafeInteger(port) && port > 0 && port < 65536), `the declared ports ${JSON.stringify(ports)} are TCP ports`);
|
|
26
|
+
const agent = ports.flatMap((port) => [`127.0.0.1:${port}`, `[::1]:${port}`]); // key-gate: loopback-rule the computer's own loopbacks, where the vendor's agent listens and its programs must be refused
|
|
27
|
+
const targets = [...agent, ...OUTSIDE_TARGETS];
|
|
28
|
+
const ran = await t.exec([DAEMON_IN_COMPUTER, "probe", "--sockets", ...targets.flatMap((target) => ["--connect", target])], { timeoutMs: t.patience }, client);
|
|
29
|
+
t.equal(ran.exitCode, 0, `the probe's exit code (stderr: ${ran.err.trim()})`);
|
|
30
|
+
let probe;
|
|
31
|
+
try {
|
|
32
|
+
probe = JSON.parse(ran.out);
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return t.assert(false, `the probe wrote what is not its report: ${ran.out.slice(0, 200)}`);
|
|
36
|
+
}
|
|
37
|
+
t.deepEqual(probe.interfaces, ["lo"], "the live interfaces (up or addressed) a program of the computer's user sees: its own loopback alone");
|
|
38
|
+
// A kernel's fallback tunnels, down with no address, are quiet: recorded. One a program could bring up is a way out.
|
|
39
|
+
const quiet = Array.isArray(probe.quiet) ? probe.quiet.map(String) : [];
|
|
40
|
+
if (quiet.length > 0)
|
|
41
|
+
t.observe(`quiet interfaces (down, no address) a program of the computer's user sees: ${quiet.join(", ")}`);
|
|
42
|
+
const raised = Array.isArray(probe.raised) ? probe.raised.map(String) : [];
|
|
43
|
+
t.assert(raised.length === 0, `a program of the computer's user brought up ${raised.join(", ")}, which no program of its own network may`);
|
|
44
|
+
// Every target's outcome, in one line of the report, before any is asserted: a passing run shows what was tried too.
|
|
45
|
+
const outcome = (target) => {
|
|
46
|
+
const result = probe.results?.find((one) => one.target === target);
|
|
47
|
+
return result === undefined ? "no result" : `${String(result.outcome)}${result.detail === undefined || result.detail === "" ? "" : ` (${String(result.detail)})`}`;
|
|
48
|
+
};
|
|
49
|
+
t.observe(`probe, as the computer's user: ${targets.map((target) => `${target} ${outcome(target)}`).join("; ")}`);
|
|
50
|
+
for (const target of targets) {
|
|
51
|
+
const result = probe.results?.find((one) => one.target === target);
|
|
52
|
+
const what = agent.includes(target) ? "the vendor's agent" : "the outside";
|
|
53
|
+
t.equal(result?.outcome, "refused", `a program of the computer's user, to ${what} at ${target} (${String(result?.detail ?? "no result")})`);
|
|
54
|
+
}
|
|
55
|
+
// The path unix sockets, which no network namespace cuts: computerd's own listing, so no image can lack it. Each with
|
|
56
|
+
// the type that connected (stream, dgram, seqpacket); a search it could not finish proves nothing, and fails.
|
|
57
|
+
const search = probe.sockets;
|
|
58
|
+
if (search === null || typeof search !== "object" || !Array.isArray(search.sockets) || !Array.isArray(search.incomplete)) {
|
|
59
|
+
return t.assert(false, "the probe reported no list of the path unix sockets a program can connect to (a computerd too old for probe --sockets), so the socket fence could not run");
|
|
60
|
+
}
|
|
61
|
+
const found = search.sockets.map((one) => ({ path: String(one.path), type: String(one.type) }));
|
|
62
|
+
t.observe(`path unix sockets a tool can connect to: ${found.map(({ path, type }) => `${path} (${type})`).join(", ") || "none"}`);
|
|
63
|
+
const incomplete = search.incomplete.map(String);
|
|
64
|
+
t.assert(incomplete.length === 0, `the probe could not search every place a socket may be, so the socket fence is unproven: ${incomplete.join("; ")}`);
|
|
65
|
+
// A desktop's tools draw on its display: the one X socket of the display its hello names is the computer's own too.
|
|
66
|
+
const own = [...OWN_SOCKETS];
|
|
67
|
+
if (t.provider.capabilities().kind === "desktop") {
|
|
68
|
+
const display = await displaySocket(client ?? t.client);
|
|
69
|
+
if (display !== undefined)
|
|
70
|
+
own.push(display);
|
|
71
|
+
else
|
|
72
|
+
t.observe("the desktop's display socket: not known (its hello names no display of the form :N)");
|
|
73
|
+
}
|
|
74
|
+
const other = found.filter(({ path }) => !own.includes(path)).map(({ path, type }) => `${path} (${type})`);
|
|
75
|
+
t.assert(other.length === 0, `a program of the computer's user connects to path unix sockets that are not the computer's own (${own.join(", ")}): ${other.join(", ")}`);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The X socket of the display a desktop's hello names (:N or :N.S, /tmp/.X11-unix/XN). Asked of the daemon itself: its
|
|
79
|
+
* /proc/self/environ is root's once init drops to its programs' uid (non-dumpable), so it is never read.
|
|
80
|
+
*/
|
|
81
|
+
async function displaySocket(client) {
|
|
82
|
+
const hello = await client.call("hello", { client: "agentrun-computer conformance" });
|
|
83
|
+
if (!hello.ok)
|
|
84
|
+
return undefined;
|
|
85
|
+
const number = /^:(\d{1,4})(?:\.\d{1,4})?$/.exec(hello.value.display ?? "")?.[1];
|
|
86
|
+
return number === undefined ? undefined : `/tmp/.X11-unix/X${number}`;
|
|
87
|
+
}
|
|
88
|
+
export const isolationCases = [
|
|
89
|
+
{
|
|
90
|
+
id: "isolation.vendor-agent",
|
|
91
|
+
level: "core",
|
|
92
|
+
group: "isolation",
|
|
93
|
+
needs: ["vendor-agent", "exec"],
|
|
94
|
+
async run(t) {
|
|
95
|
+
await assertIsolated(t);
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
];
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { CASE_LABEL } from "./util.js";
|
|
2
|
+
/** A deadline read back may be a second off the one extend returned: a label or a vendor timer can round. */
|
|
3
|
+
const SLACK_MS = 1000;
|
|
4
|
+
/** How far short of the cap the last extend asks, at least 60 s after create: it lands at least 30 s past create + cap. */
|
|
5
|
+
const UNDER_CAP_MS = 30_000;
|
|
6
|
+
export const lifetimeCases = [
|
|
7
|
+
{
|
|
8
|
+
id: "lifetime.extend",
|
|
9
|
+
level: "full",
|
|
10
|
+
group: "lifetime",
|
|
11
|
+
needs: ["extend"],
|
|
12
|
+
computer: "none",
|
|
13
|
+
timeoutMs: 300_000,
|
|
14
|
+
async run(t) {
|
|
15
|
+
const extend = t.provider.extend;
|
|
16
|
+
if (extend === undefined)
|
|
17
|
+
return t.skip("the provider has no extend()");
|
|
18
|
+
const { maxLifetimeMs, groups } = t.provider.capabilities();
|
|
19
|
+
// 120 s, then the cap less 30 s once 60 s have passed: under 3 min, the second is no longer past the first.
|
|
20
|
+
if (!(maxLifetimeMs >= 180_000))
|
|
21
|
+
return t.skip(`lifetime.extend needs a maxLifetimeMs of 3 min or more, not ${maxLifetimeMs} ms`);
|
|
22
|
+
const labels = { ...t.runLabels, [CASE_LABEL]: "extend" };
|
|
23
|
+
const ref = await t.create({ lifetimeMs: 45_000, labels });
|
|
24
|
+
const created = t.clock.now();
|
|
25
|
+
const first = await t.connect(ref);
|
|
26
|
+
const started = groups.includes("processes") ? t.ok(await first.client.call("process.start", { argv: ["sleep", "600"] }), "process.start") : undefined;
|
|
27
|
+
await first.close();
|
|
28
|
+
const deadlineOf = async () => {
|
|
29
|
+
const listed = t.ok(await t.provider.list(labels), "list");
|
|
30
|
+
t.equal(listed.length, 1, "computers with the case's labels");
|
|
31
|
+
return t.present(listed[0]?.deadline, "the listed computer's deadline").getTime();
|
|
32
|
+
};
|
|
33
|
+
const asked = t.clock.now();
|
|
34
|
+
const extended = t.ok(await extend.call(t.provider, ref, 120_000, { signal: t.signal }), "extend to 120 s");
|
|
35
|
+
const answered = t.clock.now();
|
|
36
|
+
const deadline = extended.deadline instanceof Date ? extended.deadline.getTime() : Number.NaN;
|
|
37
|
+
t.assert(deadline >= asked + 120_000 - SLACK_MS && deadline <= answered + 120_000 + SLACK_MS, `extend to 120 s returned the deadline ${String(extended.deadline)}`);
|
|
38
|
+
const listed = await deadlineOf();
|
|
39
|
+
t.assert(Math.abs(listed - deadline) <= SLACK_MS, `list() shows the deadline ${new Date(listed).toISOString()}, not the extended ${new Date(deadline).toISOString()}`);
|
|
40
|
+
/** Asks for ttlMs, which must be refused in words, and checks the deadline list() shows did not move. */
|
|
41
|
+
const refused = async (ttlMs, what) => {
|
|
42
|
+
const error = t.refused(await extend.call(t.provider, ref, ttlMs, { signal: t.signal }), what);
|
|
43
|
+
t.assert(error.message !== "", `${what}: the refusal is in words`);
|
|
44
|
+
t.equal(await deadlineOf(), listed, `the deadline list() shows after the refused ${what}`);
|
|
45
|
+
};
|
|
46
|
+
// An extend never moves the deadline earlier: 60 s from now is before the 120 s just set.
|
|
47
|
+
await refused(60_000, "extend to 60 s, earlier than the current deadline");
|
|
48
|
+
await refused(maxLifetimeMs + 1, `extend past maxLifetimeMs (${maxLifetimeMs + 1} ms)`);
|
|
49
|
+
// Past the lifetime it was made with, the computer and what ran in it are still there.
|
|
50
|
+
await t.clock.sleep(Math.max(0, created + 60_000 - t.clock.now()));
|
|
51
|
+
const again = await t.connect(ref);
|
|
52
|
+
t.deepEqual(t.ok(await again.client.call("ping", {}), "ping"), {}, "ping 60 s after a create with 45 s");
|
|
53
|
+
if (started !== undefined) {
|
|
54
|
+
const exit = t.ok(await again.client.call("process.wait", { id: started.id, timeoutMs: 0 }), "process.wait");
|
|
55
|
+
t.equal(exit.running, true, "the process started before the extend, 60 s after create: running");
|
|
56
|
+
}
|
|
57
|
+
t.assert(Math.abs((await deadlineOf()) - deadline) <= SLACK_MS, "list() shows the extended deadline 60 s after create");
|
|
58
|
+
// The cap counts from create: at least 60 s after it (the provider's create was earlier still), the cap less 30 s
|
|
59
|
+
// from now is at least 30 s past create + maxLifetimeMs, though within maxLifetimeMs on its own.
|
|
60
|
+
const underCap = maxLifetimeMs - UNDER_CAP_MS;
|
|
61
|
+
await refused(underCap, `extend to ${underCap / 1000} s, past create + maxLifetimeMs (${maxLifetimeMs} ms)`);
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
];
|