@parcha/agentrun-computer 0.0.0-placeholder → 0.1.0-beta.32
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 +2400 -1
- 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 +92 -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 +118 -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 +125 -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 +190 -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 +178 -0
- package/dist/daytona.js +1484 -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 +150 -0
- package/dist/docker.js +1200 -0
- package/dist/drift.d.ts +200 -0
- package/dist/drift.js +416 -0
- package/dist/e2b.d.ts +335 -0
- package/dist/e2b.js +1515 -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 +64 -1
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// The sweep around a live E2B run, with the provider's settings (COMPUTER_E2B_*, never E2B_*):
|
|
2
|
+
//
|
|
3
|
+
// node packages/computer/dist/conformance/e2b-sweep.js --before <file>
|
|
4
|
+
// node packages/computer/dist/conformance/e2b-sweep.js --after <file>
|
|
5
|
+
//
|
|
6
|
+
// --before records into <file> the id of every sandbox E2B lists with the provider's label agentrun.computer=1
|
|
7
|
+
// (Sandbox.list with that metadata, running and paused ones: e2b@2.63.0 dist/index.mjs:5974-5986, 5793-5835). --after
|
|
8
|
+
// lists them again, kills (Sandbox.kill) every one whose id is not in <file>, then reads each of those back with getInfo
|
|
9
|
+
// until E2B no longer has it (SandboxNotFoundError, index.mjs:5431) and no longer lists it, up to 60 s each, and prints
|
|
10
|
+
// one JSON line, {"swept":n,"gone":m,"stillThere":[ids]}: swept is every labelled sandbox it found that was not there
|
|
11
|
+
// before, and gone + stillThere.length = swept. A sandbox in <file> is never touched: no call names it. Exit 0 when
|
|
12
|
+
// every swept sandbox is gone, 1 when one is still there, 2 on a usage error, a before file it cannot read, a missing
|
|
13
|
+
// key, or a listing E2B refused (nothing is killed then).
|
|
14
|
+
//
|
|
15
|
+
// It reads COMPUTER_E2B_API_KEY and COMPUTER_E2B_DOMAIN as the conformance module does (settingsFromEnv in ./e2b.ts)
|
|
16
|
+
// and builds the provider with create(): the key passed to every SDK call explicitly, an ambient E2B_SANDBOX_URL
|
|
17
|
+
// refused. It needs no AGENTRUN_COMPUTER_LIVE_E2B: it makes nothing.
|
|
18
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
19
|
+
import { COMPUTER_LABEL } from "../drift.js";
|
|
20
|
+
import { create } from "../e2b.js";
|
|
21
|
+
import { isCommand } from "../entry.js";
|
|
22
|
+
import { E2B_ENV as ENV, settingsFromEnv } from "./e2b.js";
|
|
23
|
+
import { waitUntil } from "../wait.js";
|
|
24
|
+
const USAGE = `usage: node packages/computer/dist/conformance/e2b-sweep.js --before <file> | --after <file>
|
|
25
|
+
--before <file> record the id of every sandbox E2B lists with ${COMPUTER_LABEL}=1 into <file>
|
|
26
|
+
--after <file> kill every sandbox listed with ${COMPUTER_LABEL}=1 whose id is not in <file>, read each back until
|
|
27
|
+
E2B no longer has it (up to 60 s each), and print {"swept":n,"gone":m,"stillThere":[ids]}
|
|
28
|
+
settings: ${ENV.key} (required) and ${ENV.domain}, as the conformance module reads them; never E2B_API_KEY
|
|
29
|
+
exit: 0 every swept sandbox is gone, 1 one is still there, 2 usage error, unreadable before file, no key, or a refused listing`;
|
|
30
|
+
class Usage extends Error {
|
|
31
|
+
}
|
|
32
|
+
const write = (stream, text) => new Promise((resolve) => void stream.write(text, () => resolve()));
|
|
33
|
+
function parse(argv) {
|
|
34
|
+
let found;
|
|
35
|
+
for (let i = 0; i < argv.length; i++) {
|
|
36
|
+
const [flag = "", inline] = (argv[i] ?? "").split(/=(.*)/s, 2);
|
|
37
|
+
if (flag !== "--before" && flag !== "--after")
|
|
38
|
+
throw new Usage(`unknown option ${flag}`);
|
|
39
|
+
const file = inline ?? argv[++i];
|
|
40
|
+
if (file === undefined || file === "" || file.startsWith("--"))
|
|
41
|
+
throw new Usage(`${flag} needs a file`);
|
|
42
|
+
if (found !== undefined)
|
|
43
|
+
throw new Usage("give --before <file> or --after <file>, one of them");
|
|
44
|
+
found = { mode: flag === "--before" ? "before" : "after", file };
|
|
45
|
+
}
|
|
46
|
+
if (found === undefined)
|
|
47
|
+
throw new Usage("give --before <file> or --after <file>, one of them");
|
|
48
|
+
return found;
|
|
49
|
+
}
|
|
50
|
+
/** The ids a before file holds, or why it is not one. */
|
|
51
|
+
function beforeIds(file) {
|
|
52
|
+
let text;
|
|
53
|
+
try {
|
|
54
|
+
text = readFileSync(file, "utf8");
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
throw new Usage(`cannot read the before file ${file}: ${error.message}`);
|
|
58
|
+
}
|
|
59
|
+
let record;
|
|
60
|
+
try {
|
|
61
|
+
record = JSON.parse(text);
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
record = undefined;
|
|
65
|
+
}
|
|
66
|
+
const ids = record?.ids;
|
|
67
|
+
if (!Array.isArray(ids) || !ids.every((id) => typeof id === "string" && id !== ""))
|
|
68
|
+
throw new Usage(`${file} is not a before file: it holds no "ids" array of sandbox ids`);
|
|
69
|
+
return new Set(ids);
|
|
70
|
+
}
|
|
71
|
+
export async function main(argv, io = {}) {
|
|
72
|
+
const { env = process.env, stdout = process.stdout, stderr = process.stderr, waitMs = 60_000, pollMs = 2_000 } = io;
|
|
73
|
+
let args;
|
|
74
|
+
let before;
|
|
75
|
+
let provider;
|
|
76
|
+
try {
|
|
77
|
+
args = parse(argv);
|
|
78
|
+
if (args.mode === "after")
|
|
79
|
+
before = beforeIds(args.file);
|
|
80
|
+
provider = await create({ ...settingsFromEnv(env), ...(io.Sandbox ? { Sandbox: io.Sandbox } : {}), timeouts: { goneMs: waitMs, pollMs } });
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
await write(stderr, `${error.message}\n${error instanceof Usage ? `${USAGE}\n` : ""}`);
|
|
84
|
+
return 2;
|
|
85
|
+
}
|
|
86
|
+
const listed = await provider.listLabelled();
|
|
87
|
+
if (!listed.ok) {
|
|
88
|
+
await write(stderr, `listing the sandboxes carrying ${COMPUTER_LABEL}=1 failed, so nothing was ${args.mode === "after" ? "killed" : "recorded"}: ${listed.error.message}\n`);
|
|
89
|
+
return 2;
|
|
90
|
+
}
|
|
91
|
+
if (before === undefined) {
|
|
92
|
+
const ids = listed.value.map((sb) => sb.id).sort();
|
|
93
|
+
writeFileSync(args.file, `${JSON.stringify({ label: `${COMPUTER_LABEL}=1`, at: new Date().toISOString(), ids }, null, 2)}\n`);
|
|
94
|
+
await write(stdout, `${JSON.stringify({ recorded: ids.length, file: args.file })}\n`);
|
|
95
|
+
return 0;
|
|
96
|
+
}
|
|
97
|
+
const known = before;
|
|
98
|
+
const fresh = listed.value.filter((sb) => !known.has(sb.id)).map((sb) => sb.id);
|
|
99
|
+
for (const id of fresh) {
|
|
100
|
+
const killed = await provider.killById(id);
|
|
101
|
+
if (!killed.ok)
|
|
102
|
+
await write(stderr, `${id} was not killed: ${killed.error.message}\n`);
|
|
103
|
+
}
|
|
104
|
+
// Each read back on its own, at once: gone once getInfo no longer finds it and the label listing no longer shows it.
|
|
105
|
+
const gone = await Promise.all(fresh.map(async (id) => {
|
|
106
|
+
const waited = await waitUntil(async () => {
|
|
107
|
+
const read = await provider.probeGone(id);
|
|
108
|
+
if (!read.ok || !read.value.gone)
|
|
109
|
+
return read.ok ? `E2B reads it ${read.value.state}` : read.error.message;
|
|
110
|
+
const again = await provider.listLabelled();
|
|
111
|
+
if (!again.ok)
|
|
112
|
+
return again.error.message;
|
|
113
|
+
return again.value.some((sb) => sb.id === id) ? "still listed" : "gone";
|
|
114
|
+
}, (state) => state === "gone", { boundMs: waitMs, minMs: pollMs, maxMs: pollMs, what: `${id} to be gone after its kill`, describe: (state) => state });
|
|
115
|
+
if (!waited.ok)
|
|
116
|
+
await write(stderr, `${id} is still there after ${waitMs / 1000} s: ${waited.error.message}\n`);
|
|
117
|
+
return waited.ok;
|
|
118
|
+
}));
|
|
119
|
+
const stillThere = fresh.filter((_, i) => !gone[i]);
|
|
120
|
+
await write(stdout, `${JSON.stringify({ swept: fresh.length, gone: fresh.length - stillThere.length, stillThere })}\n`);
|
|
121
|
+
return stillThere.length === 0 ? 0 : 1;
|
|
122
|
+
}
|
|
123
|
+
if (isCommand(import.meta)) {
|
|
124
|
+
process.exitCode = await main(process.argv.slice(2));
|
|
125
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { type E2BOptions, type E2BProvider } from "../e2b.js";
|
|
2
|
+
import type { MountKind } from "../mount.js";
|
|
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
|
+
/** The environment this module reads, by name, each for the option its comment names, the live switch and the run's template. */
|
|
8
|
+
export declare const E2B_ENV: {
|
|
9
|
+
readonly live: "AGENTRUN_COMPUTER_LIVE_E2B";
|
|
10
|
+
/** The template every computer of the run starts from; default "desktop", E2B Desktop's. */
|
|
11
|
+
readonly template: "COMPUTER_E2B_TEMPLATE";
|
|
12
|
+
/** apiKey, required: the E2B API key. */
|
|
13
|
+
readonly key: "COMPUTER_E2B_API_KEY";
|
|
14
|
+
/** domain: E2B's domain; default e2b.app. */
|
|
15
|
+
readonly domain: "COMPUTER_E2B_DOMAIN";
|
|
16
|
+
/** daemonPath: the daemon binary; default this package's dist/computerd-linux-amd64. */
|
|
17
|
+
readonly daemon: "COMPUTER_E2B_DAEMON";
|
|
18
|
+
/** kind: desktop (default) or linux. */
|
|
19
|
+
readonly kind: "COMPUTER_E2B_KIND";
|
|
20
|
+
/** maxLifetimeMs: the cap, in ms, 3600000 (Hobby, default) up to 86400000 (Pro); a run caps it at 30 minutes. */
|
|
21
|
+
readonly maxLifetimeMs: "COMPUTER_E2B_MAX_LIFETIME_MS";
|
|
22
|
+
/** daemonUser: uid:gid the daemon runs as; default 2510:2510. */
|
|
23
|
+
readonly user: "COMPUTER_E2B_USER";
|
|
24
|
+
};
|
|
25
|
+
/** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
|
|
26
|
+
export declare const ENV: {
|
|
27
|
+
readonly live: "AGENTRUN_COMPUTER_LIVE_E2B";
|
|
28
|
+
/** The template every computer of the run starts from; default "desktop", E2B Desktop's. */
|
|
29
|
+
readonly template: "COMPUTER_E2B_TEMPLATE";
|
|
30
|
+
/** apiKey, required: the E2B API key. */
|
|
31
|
+
readonly key: "COMPUTER_E2B_API_KEY";
|
|
32
|
+
/** domain: E2B's domain; default e2b.app. */
|
|
33
|
+
readonly domain: "COMPUTER_E2B_DOMAIN";
|
|
34
|
+
/** daemonPath: the daemon binary; default this package's dist/computerd-linux-amd64. */
|
|
35
|
+
readonly daemon: "COMPUTER_E2B_DAEMON";
|
|
36
|
+
/** kind: desktop (default) or linux. */
|
|
37
|
+
readonly kind: "COMPUTER_E2B_KIND";
|
|
38
|
+
/** maxLifetimeMs: the cap, in ms, 3600000 (Hobby, default) up to 86400000 (Pro); a run caps it at 30 minutes. */
|
|
39
|
+
readonly maxLifetimeMs: "COMPUTER_E2B_MAX_LIFETIME_MS";
|
|
40
|
+
/** daemonUser: uid:gid the daemon runs as; default 2510:2510. */
|
|
41
|
+
readonly user: "COMPUTER_E2B_USER";
|
|
42
|
+
};
|
|
43
|
+
/** What this module reads from the environment: the key, and each other option whose name is set. */
|
|
44
|
+
export type E2BSettings = Omit<E2BOptions, "Sandbox" | "desktop" | "timeouts" | "probeTargets">;
|
|
45
|
+
/**
|
|
46
|
+
* The provider's options this module reads from env, each only when its name is set; throws in words without the key,
|
|
47
|
+
* on a value it cannot read, or while E2B_SANDBOX_URL is set there (the SDK would send every sandbox call to it), never
|
|
48
|
+
* echoing a key. create() checks the rest.
|
|
49
|
+
*/
|
|
50
|
+
export declare function settingsFromEnv(env?: Record<string, string | undefined>): E2BSettings;
|
|
51
|
+
/** The longest lifetime a computer of a run may ask for: E2B kills each sandbox at its timeout, the lifetime. */
|
|
52
|
+
export declare const CONFORMANCE_MAX_LIFETIME_MS: number;
|
|
53
|
+
/** For the run's report: what this configuration means for the suite. */
|
|
54
|
+
export declare const conformanceNotes: string[];
|
|
55
|
+
export interface E2BModuleOptions extends Pick<E2BOptions, "Sandbox" | "daemonPath" | "timeouts" | "onNote"> {
|
|
56
|
+
/** Where the settings are read; default process.env. */
|
|
57
|
+
env?: Record<string, string | undefined>;
|
|
58
|
+
/** Builds this package's daemon for linux/amd64 stamped with version, and gives its path; default go build. */
|
|
59
|
+
buildDaemon?: (version: string) => Promise<string>;
|
|
60
|
+
/** For mountFor("archil"): the disk's object API, or the SDK's Archil client, in place of the host's disk package. */
|
|
61
|
+
archil?: Pick<ArchilRunFolderOptions, "objects" | "Archil" | "baseUrl">;
|
|
62
|
+
}
|
|
63
|
+
/** The template every computer of the run starts from: COMPUTER_E2B_TEMPLATE, or E2B Desktop's (the plain one for kind linux). */
|
|
64
|
+
export declare function conformanceImage({ env }?: Pick<E2BModuleOptions, "env">): string;
|
|
65
|
+
/** The provider the CLI runs; throws in words without the live switch, or when a setting is missing or wrong. */
|
|
66
|
+
export declare function createProvider({ env, Sandbox, daemonPath, timeouts, onNote }?: E2BModuleOptions): Promise<E2BProvider>;
|
|
67
|
+
/**
|
|
68
|
+
* A run folder for an Archil mount, and none for any other kind (an E2B computer takes no bind): a fresh folder on the
|
|
69
|
+
* disk the COMPUTER_ARCHIL_* names name (archilSettings), none when they name none (archilRunFolder, ./archil.ts).
|
|
70
|
+
* Reaching it is a call to Archil, so it needs the live switch.
|
|
71
|
+
*/
|
|
72
|
+
export declare function mountFor(kind: MountKind, { env, archil }?: E2BModuleOptions): Promise<RunFolder | undefined>;
|
|
73
|
+
/** The same provider uploading a daemon that reports version <version>-drift, for the drift.version case. */
|
|
74
|
+
export declare function createDriftedProvider({ env, Sandbox, timeouts, buildDaemon }?: E2BModuleOptions): Promise<E2BProvider>;
|
|
@@ -0,0 +1,111 @@
|
|
|
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 the lead has OKed, under
|
|
3
|
+
// COMPUTER_E2B_API_KEY. The provider reads no environment: this module reads its own COMPUTER_E2B_* names (never
|
|
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
|
+
// the key, domain and API URL explicitly, and refuses an ambient E2B_SANDBOX_URL (see create in ../e2b.ts). The live
|
|
6
|
+
// switch is checked first, before any other setting is read. The sweep and the network diagnostic (e2b-sweep.ts,
|
|
7
|
+
// e2b-diagnose.ts) read the same names through settingsFromEnv.
|
|
8
|
+
//
|
|
9
|
+
// The daemon is uploaded into each sandbox (dist/computerd-linux-amd64, `npm run build:daemon`), so a run publishes
|
|
10
|
+
// nothing. The drifted provider uploads a daemon built with Go as version <version>-drift. Every computer of a run lives
|
|
11
|
+
// at most 30 minutes, E2B Hobby's plan for conformance: E2B's timeout is the lifetime, and a longer one is refused.
|
|
12
|
+
//
|
|
13
|
+
// For the mount cases, mountFor("archil") makes a fresh run folder on the Archil disk COMPUTER_ARCHIL_DISK names (in
|
|
14
|
+
// COMPUTER_ARCHIL_REGION, mounted with the disk token COMPUTER_ARCHIL_TOKEN), and reaches it from outside through the
|
|
15
|
+
// disk's object API (the shared archilRunFolder, ./archil.ts: the host's disk SDK with COMPUTER_ARCHIL_API_KEY and
|
|
16
|
+
// COMPUTER_ARCHIL_S3_URL, or an object API given as archil.objects); with no disk named it makes none, and the cases
|
|
17
|
+
// are skipped. An Archil computer needs a provider whose daemon user is the tool user: COMPUTER_E2B_USER=2510:2510.
|
|
18
|
+
import { create, E2B_BASE_TEMPLATE, E2B_DESKTOP_TEMPLATE } from "../e2b.js";
|
|
19
|
+
import { archilRunFolder, archilSettings } from "./archil.js";
|
|
20
|
+
import { buildDriftDaemon, DRIFT_VERSION } from "./drift-daemon.js";
|
|
21
|
+
/** The Archil disk's settings for the mount cases, by name (COMPUTER_ARCHIL_*: all five, or none). */
|
|
22
|
+
export { ARCHIL_ENV } from "./archil.js";
|
|
23
|
+
/** The environment this module reads, by name, each for the option its comment names, the live switch and the run's template. */
|
|
24
|
+
export const E2B_ENV = {
|
|
25
|
+
live: "AGENTRUN_COMPUTER_LIVE_E2B",
|
|
26
|
+
/** The template every computer of the run starts from; default "desktop", E2B Desktop's. */
|
|
27
|
+
template: "COMPUTER_E2B_TEMPLATE",
|
|
28
|
+
/** apiKey, required: the E2B API key. */
|
|
29
|
+
key: "COMPUTER_E2B_API_KEY",
|
|
30
|
+
/** domain: E2B's domain; default e2b.app. */
|
|
31
|
+
domain: "COMPUTER_E2B_DOMAIN",
|
|
32
|
+
/** daemonPath: the daemon binary; default this package's dist/computerd-linux-amd64. */
|
|
33
|
+
daemon: "COMPUTER_E2B_DAEMON",
|
|
34
|
+
/** kind: desktop (default) or linux. */
|
|
35
|
+
kind: "COMPUTER_E2B_KIND",
|
|
36
|
+
/** maxLifetimeMs: the cap, in ms, 3600000 (Hobby, default) up to 86400000 (Pro); a run caps it at 30 minutes. */
|
|
37
|
+
maxLifetimeMs: "COMPUTER_E2B_MAX_LIFETIME_MS",
|
|
38
|
+
/** daemonUser: uid:gid the daemon runs as; default 2510:2510. */
|
|
39
|
+
user: "COMPUTER_E2B_USER",
|
|
40
|
+
};
|
|
41
|
+
/** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
|
|
42
|
+
export const ENV = E2B_ENV;
|
|
43
|
+
/**
|
|
44
|
+
* The provider's options this module reads from env, each only when its name is set; throws in words without the key,
|
|
45
|
+
* on a value it cannot read, or while E2B_SANDBOX_URL is set there (the SDK would send every sandbox call to it), never
|
|
46
|
+
* echoing a key. create() checks the rest.
|
|
47
|
+
*/
|
|
48
|
+
export function settingsFromEnv(env = process.env) {
|
|
49
|
+
const apiKey = env[E2B_ENV.key];
|
|
50
|
+
if (apiKey === undefined || apiKey === "")
|
|
51
|
+
throw new Error(`set ${E2B_ENV.key} to an E2B API key: the conformance module reads it there and nowhere else, never from E2B_API_KEY`);
|
|
52
|
+
if (env.E2B_SANDBOX_URL)
|
|
53
|
+
throw new Error("the E2B provider refuses to start while E2B_SANDBOX_URL is set: the SDK would send every call into a sandbox there. Unset it");
|
|
54
|
+
const lifetime = env[E2B_ENV.maxLifetimeMs] || undefined;
|
|
55
|
+
if (lifetime !== undefined && !/^\d+$/.test(lifetime))
|
|
56
|
+
throw new Error(`${E2B_ENV.maxLifetimeMs} is a whole number of milliseconds, such as 3600000 (Hobby) or 86400000 (Pro)`);
|
|
57
|
+
const domain = env[E2B_ENV.domain] || undefined;
|
|
58
|
+
const daemonPath = env[E2B_ENV.daemon] || undefined;
|
|
59
|
+
const kind = env[E2B_ENV.kind] || undefined;
|
|
60
|
+
const daemonUser = env[E2B_ENV.user] || undefined;
|
|
61
|
+
return {
|
|
62
|
+
apiKey,
|
|
63
|
+
...(domain === undefined ? {} : { domain }),
|
|
64
|
+
...(daemonPath === undefined ? {} : { daemonPath }),
|
|
65
|
+
// create() refuses any other kind in words.
|
|
66
|
+
...(kind === undefined ? {} : { kind: kind }),
|
|
67
|
+
...(lifetime === undefined ? {} : { maxLifetimeMs: Number(lifetime) }),
|
|
68
|
+
...(daemonUser === undefined ? {} : { daemonUser }),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/** The longest lifetime a computer of a run may ask for: E2B kills each sandbox at its timeout, the lifetime. */
|
|
72
|
+
export const CONFORMANCE_MAX_LIFETIME_MS = 30 * 60_000;
|
|
73
|
+
/** For the run's report: what this configuration means for the suite. */
|
|
74
|
+
export const conformanceNotes = [
|
|
75
|
+
"e2b: E2B Hobby plan: every sandbox's timeout is its lifetime, capped at 30 minutes for the run (Hobby caps a sandbox at 1 h, Pro at 24 h). The daemon is a child of E2B's envd, started as a background command; network none is no internet access and no public traffic, read back from E2B and probed from inside; no stream() (a screen is streamed through agentrun, never a vendor URL), so screen.stream is skipped.",
|
|
76
|
+
];
|
|
77
|
+
function live(env) {
|
|
78
|
+
if (env[E2B_ENV.live] !== "1") {
|
|
79
|
+
throw new Error(`the E2B conformance module makes real sandboxes: set ${E2B_ENV.live}=1, with a key the lead has OKed, to run it`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/** The template every computer of the run starts from: COMPUTER_E2B_TEMPLATE, or E2B Desktop's (the plain one for kind linux). */
|
|
83
|
+
export function conformanceImage({ env = process.env } = {}) {
|
|
84
|
+
return env[E2B_ENV.template] || (env[E2B_ENV.kind] === "linux" ? E2B_BASE_TEMPLATE : E2B_DESKTOP_TEMPLATE);
|
|
85
|
+
}
|
|
86
|
+
/** The provider the CLI runs; throws in words without the live switch, or when a setting is missing or wrong. */
|
|
87
|
+
export async function createProvider({ env = process.env, Sandbox, daemonPath, timeouts, onNote } = {}) {
|
|
88
|
+
live(env);
|
|
89
|
+
return create({ ...settingsFromEnv(env), ...(Sandbox ? { Sandbox } : {}), ...(daemonPath === undefined ? {} : { daemonPath }), ...(timeouts ? { timeouts } : {}), ...(onNote ? { onNote } : {}), maxLifetimeMs: CONFORMANCE_MAX_LIFETIME_MS });
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* A run folder for an Archil mount, and none for any other kind (an E2B computer takes no bind): a fresh folder on the
|
|
93
|
+
* disk the COMPUTER_ARCHIL_* names name (archilSettings), none when they name none (archilRunFolder, ./archil.ts).
|
|
94
|
+
* Reaching it is a call to Archil, so it needs the live switch.
|
|
95
|
+
*/
|
|
96
|
+
export async function mountFor(kind, { env = process.env, archil = {} } = {}) {
|
|
97
|
+
if (kind !== "archil")
|
|
98
|
+
return undefined;
|
|
99
|
+
const settings = archilSettings(env);
|
|
100
|
+
if (settings === undefined)
|
|
101
|
+
return undefined;
|
|
102
|
+
live(env);
|
|
103
|
+
return archilRunFolder({ ...settings, ...archil });
|
|
104
|
+
}
|
|
105
|
+
/** The same provider uploading a daemon that reports version <version>-drift, for the drift.version case. */
|
|
106
|
+
export async function createDriftedProvider({ env = process.env, Sandbox, timeouts, buildDaemon = (version) => buildDriftDaemon("amd64", version) } = {}) {
|
|
107
|
+
live(env);
|
|
108
|
+
const settings = settingsFromEnv(env);
|
|
109
|
+
const daemonPath = await buildDaemon(DRIFT_VERSION);
|
|
110
|
+
return create({ ...settings, ...(Sandbox ? { Sandbox } : {}), ...(timeouts ? { timeouts } : {}), daemonPath, maxLifetimeMs: CONFORMANCE_MAX_LIFETIME_MS });
|
|
111
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Button, Point, Rect } from "../protocol.js";
|
|
2
|
+
import type { CaseContext } from "./types.js";
|
|
3
|
+
/** The desktop fixture's window, in screenshot pixels. */
|
|
4
|
+
export declare const FIXTURE_WINDOW: Rect;
|
|
5
|
+
/** The window's quadrants in RGB: top left, top right, bottom left, bottom right. */
|
|
6
|
+
export declare const FIXTURE_COLORS: ReadonlyArray<readonly [number, number, number]>;
|
|
7
|
+
/** The fixture APK's application id. */
|
|
8
|
+
export declare const FIXTURE_APP_ID = "ai.agentrun.fixture";
|
|
9
|
+
/** The APK's button, found in apps.ui_tree by its id. */
|
|
10
|
+
export declare const FIXTURE_BUTTON: {
|
|
11
|
+
readonly id: "ai.agentrun.fixture:id/button";
|
|
12
|
+
readonly text: "agentrun fixture";
|
|
13
|
+
};
|
|
14
|
+
/** Where the APK is written on a phone before apps.install. */
|
|
15
|
+
export declare const FIXTURE_APK_PATH = "/data/local/tmp/agentrun-fixture.apk";
|
|
16
|
+
/** Where the fixture app logs on a phone: its own files directory, which files reads without root. */
|
|
17
|
+
export declare const fixtureAppLog: (id: string) => string;
|
|
18
|
+
/** One line of a fixture's log. Points are screenshot pixels. */
|
|
19
|
+
export type FixtureEvent =
|
|
20
|
+
/** The window is up with focus, or the app was launched. */
|
|
21
|
+
{
|
|
22
|
+
event: "ready";
|
|
23
|
+
} | {
|
|
24
|
+
event: "down" | "up";
|
|
25
|
+
button: Button;
|
|
26
|
+
at: Point;
|
|
27
|
+
} | {
|
|
28
|
+
event: "wheel";
|
|
29
|
+
at: Point;
|
|
30
|
+
dx: number;
|
|
31
|
+
dy: number;
|
|
32
|
+
} | {
|
|
33
|
+
event: "key";
|
|
34
|
+
key: string;
|
|
35
|
+
down: boolean;
|
|
36
|
+
}
|
|
37
|
+
/** Composed text, as the focused window gets it. */
|
|
38
|
+
| {
|
|
39
|
+
event: "text";
|
|
40
|
+
text: string;
|
|
41
|
+
}
|
|
42
|
+
/** One finger: pointer is its index, from 0. */
|
|
43
|
+
| {
|
|
44
|
+
event: "touch";
|
|
45
|
+
pointer: number;
|
|
46
|
+
phase: "down" | "move" | "up";
|
|
47
|
+
at: Point;
|
|
48
|
+
};
|
|
49
|
+
export interface StartedFixture {
|
|
50
|
+
/** Where the fixture is, in screenshot pixels: an action aimed inside reaches it. */
|
|
51
|
+
bounds: Rect;
|
|
52
|
+
/** The app's id, when the fixture is an app. */
|
|
53
|
+
app?: string;
|
|
54
|
+
/** Every event it has logged since it started, in order. */
|
|
55
|
+
events(): Promise<FixtureEvent[]>;
|
|
56
|
+
/** Ends it; the runner calls this when the case ends. */
|
|
57
|
+
stop(): Promise<void>;
|
|
58
|
+
}
|
|
59
|
+
/** Parses a log: one JSON object per line; a last line still being written is left for the next read. */
|
|
60
|
+
export declare function parseEvents(text: string, where: string): FixtureEvent[];
|
|
61
|
+
/**
|
|
62
|
+
* Puts the fixture at path (on this machine) in the case's computer and starts it, by the computer's kind. launched gets
|
|
63
|
+
* the fixture's stop as soon as it is launched, before it logs ready, so a fixture that never does is stopped too.
|
|
64
|
+
*/
|
|
65
|
+
export declare function startFixture(t: CaseContext, path: string, launched: (stop: () => Promise<void>) => void): Promise<StartedFixture>;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// The model-free fixtures the screen, input, touch and apps cases check effects with. A fixture is an app that logs
|
|
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
|
+
// a test-only static binary: a 200x200 override-redirect window at (0, 0) in four known colors, which grabs focus. On
|
|
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.
|
|
6
|
+
import { readFileSync } from "node:fs";
|
|
7
|
+
import { readFile, writeFile } from "../files.js";
|
|
8
|
+
/** The desktop fixture's window, in screenshot pixels. */
|
|
9
|
+
export const FIXTURE_WINDOW = [0, 0, 200, 200];
|
|
10
|
+
/** The window's quadrants in RGB: top left, top right, bottom left, bottom right. */
|
|
11
|
+
export const FIXTURE_COLORS = [
|
|
12
|
+
[255, 0, 0],
|
|
13
|
+
[0, 255, 0],
|
|
14
|
+
[0, 0, 255],
|
|
15
|
+
[255, 255, 0],
|
|
16
|
+
];
|
|
17
|
+
/** The fixture APK's application id. */
|
|
18
|
+
export const FIXTURE_APP_ID = "ai.agentrun.fixture";
|
|
19
|
+
/** The APK's button, found in apps.ui_tree by its id. */
|
|
20
|
+
export const FIXTURE_BUTTON = { id: `${FIXTURE_APP_ID}:id/button`, text: "agentrun fixture" };
|
|
21
|
+
/** Where the APK is written on a phone before apps.install. */
|
|
22
|
+
export const FIXTURE_APK_PATH = "/data/local/tmp/agentrun-fixture.apk";
|
|
23
|
+
/** Where the fixture app logs on a phone: its own files directory, which files reads without root. */
|
|
24
|
+
export const fixtureAppLog = (id) => `/sdcard/Android/data/${id}/files/events.jsonl`;
|
|
25
|
+
/** Parses a log: one JSON object per line; a last line still being written is left for the next read. */
|
|
26
|
+
export function parseEvents(text, where) {
|
|
27
|
+
const lines = text.split("\n");
|
|
28
|
+
lines.pop();
|
|
29
|
+
return lines
|
|
30
|
+
.filter((line) => line.trim() !== "")
|
|
31
|
+
.map((line, i) => {
|
|
32
|
+
try {
|
|
33
|
+
return JSON.parse(line);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
throw new Error(`${where} line ${i + 1} is not JSON: ${line.slice(0, 200)}`);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/** Skips the case, in words, unless the provider and the computer both declare every group the fixture needs. */
|
|
41
|
+
function needs(t, groups, what) {
|
|
42
|
+
const declared = t.provider.capabilities().groups;
|
|
43
|
+
const lacking = groups.filter((group) => !declared.includes(group) || !t.hello.groups.includes(group));
|
|
44
|
+
if (lacking.length > 0)
|
|
45
|
+
t.skip(`${what} needs ${lacking.join(", ")}, which this computer does not declare`);
|
|
46
|
+
}
|
|
47
|
+
/** Reads the log over files: none yet is no events. */
|
|
48
|
+
async function logOf(t, path) {
|
|
49
|
+
const read = await readFile(t.client, path, { signal: t.signal });
|
|
50
|
+
if (!read.ok && read.error.code === "not_found")
|
|
51
|
+
return [];
|
|
52
|
+
return parseEvents(Buffer.from(t.ok(read, `files.read of the fixture's log ${path}`)).toString("utf8"), `the fixture's log ${path}`);
|
|
53
|
+
}
|
|
54
|
+
async function ready(t, events, what) {
|
|
55
|
+
await t.until(async () => (await events()).some((e) => e.event === "ready"), `${what} logged ready`);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Puts the fixture at path (on this machine) in the case's computer and starts it, by the computer's kind. launched gets
|
|
59
|
+
* the fixture's stop as soon as it is launched, before it logs ready, so a fixture that never does is stopped too.
|
|
60
|
+
*/
|
|
61
|
+
export async function startFixture(t, path, launched) {
|
|
62
|
+
const { kind } = t.provider.capabilities();
|
|
63
|
+
if (kind === "desktop") {
|
|
64
|
+
needs(t, ["exec", "files", "processes"], "the desktop fixture");
|
|
65
|
+
const dir = await t.dir();
|
|
66
|
+
const bin = `${dir}/computerd-fixture`;
|
|
67
|
+
const log = `${dir}/events.jsonl`;
|
|
68
|
+
t.ok(await writeFile(t.client, bin, readFileSync(path), { mode: 0o755, signal: t.signal }), `files.write of the fixture to ${bin}`);
|
|
69
|
+
const started = await t.call("process.start", { argv: [bin, "--log", log] });
|
|
70
|
+
const events = () => logOf(t, log);
|
|
71
|
+
const stop = async () => {
|
|
72
|
+
await t.client.call("process.signal", { id: started.id, signal: "KILL" });
|
|
73
|
+
};
|
|
74
|
+
launched(stop);
|
|
75
|
+
await ready(t, events, "the desktop fixture");
|
|
76
|
+
return { bounds: FIXTURE_WINDOW, events, stop };
|
|
77
|
+
}
|
|
78
|
+
if (kind === "android") {
|
|
79
|
+
needs(t, ["files", "apps", "apps.install", "screen"], "the fixture app");
|
|
80
|
+
t.ok(await writeFile(t.client, FIXTURE_APK_PATH, readFileSync(path), { parents: true, signal: t.signal }), `files.write of the fixture to ${FIXTURE_APK_PATH}`);
|
|
81
|
+
const app = await t.call("apps.install", { path: FIXTURE_APK_PATH });
|
|
82
|
+
const log = fixtureAppLog(app.id);
|
|
83
|
+
// A log from an earlier launch would read as this one's.
|
|
84
|
+
const removed = await t.client.call("files.remove", { path: log }, { signal: t.signal });
|
|
85
|
+
if (!removed.ok && removed.error.code !== "not_found")
|
|
86
|
+
t.ok(removed, `files.remove of the fixture's old log ${log}`);
|
|
87
|
+
await t.call("apps.launch", { id: app.id });
|
|
88
|
+
const events = () => logOf(t, log);
|
|
89
|
+
const stop = async () => {
|
|
90
|
+
await t.client.call("apps.terminate", { id: app.id });
|
|
91
|
+
};
|
|
92
|
+
launched(stop);
|
|
93
|
+
await ready(t, events, "the fixture app");
|
|
94
|
+
const shot = await t.call("screen.shot", {});
|
|
95
|
+
return { bounds: [0, 0, shot.width, shot.height], app: app.id, events, stop };
|
|
96
|
+
}
|
|
97
|
+
return t.skip(`no fixture runs on a ${kind} computer yet`);
|
|
98
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./types.js";
|
|
2
|
+
export { runConformance } from "./runner.js";
|
|
3
|
+
export { formatReport } from "./report.js";
|
|
4
|
+
export { browserCases, browserOnlyCases, casesFor, conformanceCases } from "./cases/index.js";
|
|
5
|
+
export { kindCases, kindRunProblem, kindVerdict, type KindVerdict } from "./kind.js";
|
|
6
|
+
export { type CdpDialer, type CdpSocket, dialCdp } from "./cdp.js";
|
|
7
|
+
export { FIXTURE_APK_PATH, FIXTURE_APP_ID, FIXTURE_BUTTON, FIXTURE_COLORS, FIXTURE_WINDOW, type FixtureEvent, fixtureAppLog, parseEvents, type StartedFixture, } from "./fixture.js";
|
|
8
|
+
export { MAX_PNG_BYTES, type Png, readPng } from "./png.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./types.js";
|
|
2
|
+
export { runConformance } from "./runner.js";
|
|
3
|
+
export { formatReport } from "./report.js";
|
|
4
|
+
export { browserCases, browserOnlyCases, casesFor, conformanceCases } from "./cases/index.js";
|
|
5
|
+
export { kindCases, kindRunProblem, kindVerdict } from "./kind.js";
|
|
6
|
+
export { dialCdp } from "./cdp.js";
|
|
7
|
+
export { FIXTURE_APK_PATH, FIXTURE_APP_ID, FIXTURE_BUTTON, FIXTURE_COLORS, FIXTURE_WINDOW, fixtureAppLog, parseEvents, } from "./fixture.js";
|
|
8
|
+
export { MAX_PNG_BYTES, readPng } from "./png.js";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type KernelProvider, type KernelProviderOptions } from "../kernel.js";
|
|
2
|
+
/** The environment this module reads, by name, each for the option its comment names, and the live switch. */
|
|
3
|
+
export declare const KERNEL_ENV: {
|
|
4
|
+
readonly live: "AGENTRUN_COMPUTER_LIVE_KERNEL";
|
|
5
|
+
/** apiKey, required: the Kernel API key. */
|
|
6
|
+
readonly key: "COMPUTER_KERNEL_API_KEY";
|
|
7
|
+
/** apiUrl: Kernel's API; default https://api.onkernel.com. */
|
|
8
|
+
readonly url: "COMPUTER_KERNEL_API_URL";
|
|
9
|
+
};
|
|
10
|
+
/** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
|
|
11
|
+
export declare const ENV: {
|
|
12
|
+
readonly live: "AGENTRUN_COMPUTER_LIVE_KERNEL";
|
|
13
|
+
/** apiKey, required: the Kernel API key. */
|
|
14
|
+
readonly key: "COMPUTER_KERNEL_API_KEY";
|
|
15
|
+
/** apiUrl: Kernel's API; default https://api.onkernel.com. */
|
|
16
|
+
readonly url: "COMPUTER_KERNEL_API_URL";
|
|
17
|
+
};
|
|
18
|
+
/** What this module reads from the environment: the key, and the API URL when its name is set. */
|
|
19
|
+
export type KernelSettings = Pick<KernelProviderOptions, "apiKey" | "apiUrl">;
|
|
20
|
+
/** The provider's options this module reads from env, each only when its name is set; throws in words without the key, never echoing one. */
|
|
21
|
+
export declare function settingsFromEnv(env?: Record<string, string | undefined>): KernelSettings;
|
|
22
|
+
/** For the run's report: what this configuration means for the suite. */
|
|
23
|
+
export declare const conformanceNotes: string[];
|
|
24
|
+
export interface KernelModuleOptions extends Pick<KernelProviderOptions, "fetch" | "sleep" | "confirm"> {
|
|
25
|
+
/** Where the settings are read; default process.env. */
|
|
26
|
+
env?: Record<string, string | undefined>;
|
|
27
|
+
}
|
|
28
|
+
/** The image every computer of the run asks for: the vendor's Chromium. */
|
|
29
|
+
export declare function conformanceImage(): string;
|
|
30
|
+
/** The provider the CLI runs; throws in words without the live switch, or when the key is missing. */
|
|
31
|
+
export declare function createProvider({ env, ...transport }?: KernelModuleOptions): Promise<KernelProvider>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Kernel for the conformance CLI: `npm run conformance -w @parcha/agentrun-computer -- --provider kernel`. It makes a
|
|
2
|
+
// real, billed Kernel browser, so it runs only with AGENTRUN_COMPUTER_LIVE_KERNEL=1 and a key the lead has OKed, under
|
|
3
|
+
// COMPUTER_KERNEL_API_KEY. The provider reads no environment: this module reads its own COMPUTER_KERNEL_* names (never
|
|
4
|
+
// KERNEL_API_KEY, which may hold another organization's key) and passes each to create() as its option. The live switch
|
|
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 "../browser.js";
|
|
7
|
+
import { create } from "../kernel.js";
|
|
8
|
+
/** The environment this module reads, by name, each for the option its comment names, and the live switch. */
|
|
9
|
+
export const KERNEL_ENV = {
|
|
10
|
+
live: "AGENTRUN_COMPUTER_LIVE_KERNEL",
|
|
11
|
+
/** apiKey, required: the Kernel API key. */
|
|
12
|
+
key: "COMPUTER_KERNEL_API_KEY",
|
|
13
|
+
/** apiUrl: Kernel's API; default https://api.onkernel.com. */
|
|
14
|
+
url: "COMPUTER_KERNEL_API_URL",
|
|
15
|
+
};
|
|
16
|
+
/** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
|
|
17
|
+
export const ENV = KERNEL_ENV;
|
|
18
|
+
/** The provider's options this module reads from env, each only when its name is set; throws in words without the key, never echoing one. */
|
|
19
|
+
export function settingsFromEnv(env = process.env) {
|
|
20
|
+
const apiKey = env[KERNEL_ENV.key];
|
|
21
|
+
if (apiKey === undefined || apiKey === "")
|
|
22
|
+
throw new Error(`set ${KERNEL_ENV.key} to a Kernel API key: the conformance module reads it there and nowhere else, never from KERNEL_API_KEY`);
|
|
23
|
+
const apiUrl = env[KERNEL_ENV.url] || undefined;
|
|
24
|
+
return { apiKey, ...(apiUrl === undefined ? {} : { apiUrl }) };
|
|
25
|
+
}
|
|
26
|
+
/** For the run's report: what this configuration means for the suite. */
|
|
27
|
+
export const conformanceNotes = [
|
|
28
|
+
"kernel: one browser for the whole run, deleted by its last case (browser.release) and again at the run's end. Kernel's lifetime is an idle timeout (no wall clock), so list reads no deadline.",
|
|
29
|
+
];
|
|
30
|
+
/** The image every computer of the run asks for: the vendor's Chromium. */
|
|
31
|
+
export function conformanceImage() {
|
|
32
|
+
return BROWSER_IMAGE;
|
|
33
|
+
}
|
|
34
|
+
/** The provider the CLI runs; throws in words without the live switch, or when the key is missing. */
|
|
35
|
+
export async function createProvider({ env = process.env, ...transport } = {}) {
|
|
36
|
+
if (env[KERNEL_ENV.live] !== "1") {
|
|
37
|
+
throw new Error(`the Kernel conformance module makes a real, billed browser: set ${KERNEL_ENV.live}=1, with a key the lead has OKed, to run it`);
|
|
38
|
+
}
|
|
39
|
+
return create({ ...settingsFromEnv(env), ...transport });
|
|
40
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type ComputerSettingKind, type KindCapabilities } from "../kinds.js";
|
|
2
|
+
import type { Case, ConformanceReport } from "./types.js";
|
|
3
|
+
/** A kind's verdict: pass, or fail with why, in words. */
|
|
4
|
+
export interface KindVerdict {
|
|
5
|
+
kind: ComputerSettingKind;
|
|
6
|
+
verdict: "pass" | "fail";
|
|
7
|
+
reasons: string[];
|
|
8
|
+
}
|
|
9
|
+
/** Why a run cannot be by this kind, in words; undefined when it can. Kind none is no computer. */
|
|
10
|
+
export declare function kindRunProblem(kind: ComputerSettingKind): string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* The cases a kind runs: each whose protocol groups the kind requires or allows, those that need no group (health,
|
|
13
|
+
* provider, drift) among them. None for kind none. Drawn from cases, by default the kind's suite (casesFor).
|
|
14
|
+
*/
|
|
15
|
+
export declare function kindCases(kind: ComputerSettingKind, cases?: readonly Case[]): Case[];
|
|
16
|
+
/**
|
|
17
|
+
* Whether the provider whose capabilities these are passes the kind, by the run's report and its cases (the kind's): it
|
|
18
|
+
* serves the kind; no case of the run failed (a declared optional group that fails would give a loop a broken tool);
|
|
19
|
+
* for each required group, at least one case that needs it passed and no Core case was skipped but for an optional group
|
|
20
|
+
* the computer does not declare; and the run left nothing behind. A Full case's skip is owed by no group: a provider may
|
|
21
|
+
* refuse in words what its kind does not require (a phone's pinch), and it is still tried and reported.
|
|
22
|
+
*/
|
|
23
|
+
export declare function kindVerdict(kind: ComputerSettingKind, capabilities: KindCapabilities, report: ConformanceReport, cases?: readonly Case[]): KindVerdict;
|