@parcha/agentrun-computer 0.1.0-beta.58 → 0.1.0-beta.60
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 +285 -81
- package/box/Dockerfile +4 -3
- package/box/install.sh +57 -11
- package/dist/agent37.d.ts +11 -4
- package/dist/agent37.js +217 -19
- package/dist/attach.d.ts +24 -4
- package/dist/attach.js +50 -19
- package/dist/boxd.js +22 -9
- package/dist/browser.d.ts +56 -11
- package/dist/browser.js +76 -17
- package/dist/browserbase.d.ts +20 -5
- package/dist/browserbase.js +186 -21
- package/dist/child-env.d.ts +11 -0
- package/dist/child-env.js +22 -0
- package/dist/chrome.d.ts +5 -2
- package/dist/chrome.js +5 -2
- package/dist/cloudflare.d.ts +2 -0
- package/dist/cloudflare.js +5 -3
- package/dist/computerd-linux-amd64 +0 -0
- package/dist/computerd-linux-arm64 +0 -0
- package/dist/computerd.json +1 -1
- package/dist/conformance/agent37.d.ts +20 -40
- package/dist/conformance/agent37.js +31 -118
- package/dist/conformance/archil.d.ts +13 -3
- package/dist/conformance/archil.js +22 -17
- package/dist/conformance/boxd.d.ts +8 -31
- package/dist/conformance/boxd.js +19 -74
- package/dist/conformance/browserbase.d.ts +3 -6
- package/dist/conformance/browserbase.js +6 -17
- package/dist/conformance/cases/health.js +6 -3
- package/dist/conformance/cases/provider.js +4 -1
- package/dist/conformance/cli.d.ts +3 -1
- package/dist/conformance/cli.js +69 -9
- package/dist/conformance/cloudflare.d.ts +3 -6
- package/dist/conformance/cloudflare.js +7 -15
- package/dist/conformance/daytona.d.ts +6 -20
- package/dist/conformance/daytona.js +22 -57
- package/dist/conformance/dial-only.d.ts +4 -3
- package/dist/conformance/dial-only.js +3 -3
- package/dist/conformance/docker.d.ts +4 -5
- package/dist/conformance/docker.js +8 -14
- package/dist/conformance/e2b.d.ts +10 -36
- package/dist/conformance/e2b.js +27 -84
- package/dist/conformance/fly.d.ts +3 -6
- package/dist/conformance/fly.js +2 -6
- package/dist/conformance/groundbox.d.ts +7 -23
- package/dist/conformance/groundbox.js +16 -56
- package/dist/conformance/index.d.ts +1 -0
- package/dist/conformance/index.js +1 -0
- package/dist/conformance/kernel.d.ts +3 -6
- package/dist/conformance/kernel.js +5 -15
- package/dist/conformance/kind.d.ts +0 -6
- package/dist/conformance/kind.js +0 -4
- package/dist/conformance/local-chrome.d.ts +5 -7
- package/dist/conformance/local-chrome.js +7 -11
- package/dist/conformance/modal.d.ts +10 -38
- package/dist/conformance/modal.js +27 -74
- package/dist/conformance/module-kit.d.ts +87 -0
- package/dist/conformance/module-kit.js +88 -0
- package/dist/conformance/morph.d.ts +7 -23
- package/dist/conformance/morph.js +20 -66
- package/dist/conformance/orgo.d.ts +5 -10
- package/dist/conformance/orgo.js +15 -27
- package/dist/conformance/phone-harness.d.ts +3 -5
- package/dist/conformance/phone-harness.js +3 -11
- package/dist/conformance/runner.d.ts +13 -3
- package/dist/conformance/runner.js +32 -11
- package/dist/conformance/smolcloud.d.ts +7 -23
- package/dist/conformance/smolcloud.js +16 -49
- package/dist/conformance/sweep.d.ts +10 -5
- package/dist/conformance/sweep.js +91 -38
- package/dist/conformance/tti.d.ts +69 -0
- package/dist/conformance/tti.js +205 -0
- package/dist/conformance/types.d.ts +9 -2
- package/dist/daytona.js +60 -20
- package/dist/descriptor.d.ts +37 -0
- package/dist/descriptor.js +9 -0
- package/dist/descriptors/agent37.d.ts +4 -1
- package/dist/descriptors/agent37.js +5 -2
- package/dist/descriptors/browserbase.d.ts +3 -0
- package/dist/descriptors/browserbase.js +4 -0
- package/dist/descriptors/docker.d.ts +2 -0
- package/dist/descriptors/docker.js +5 -0
- package/dist/descriptors/env-names.d.ts +32 -0
- package/dist/descriptors/env-names.js +60 -0
- package/dist/descriptors/index.d.ts +14 -3
- package/dist/descriptors/kernel.d.ts +3 -0
- package/dist/descriptors/kernel.js +2 -0
- package/dist/descriptors/local-chrome.d.ts +1 -1
- package/dist/descriptors/local-chrome.js +5 -3
- package/dist/descriptors/phone-harness.d.ts +1 -1
- package/dist/descriptors/phone-harness.js +4 -2
- package/dist/docker/egress.d.ts +7 -0
- package/dist/docker/egress.js +8 -0
- package/dist/docker/image.d.ts +5 -1
- package/dist/docker/image.js +12 -8
- package/dist/docker.d.ts +52 -13
- package/dist/docker.js +166 -92
- package/dist/drift.js +6 -6
- package/dist/e2b.d.ts +2 -2
- package/dist/e2b.js +2 -3
- package/dist/groundbox.js +6 -6
- package/dist/host.d.ts +23 -0
- package/dist/hosted/download.d.ts +23 -0
- package/dist/hosted/download.js +144 -0
- package/dist/hosted/process.d.ts +5 -0
- package/dist/hosted/process.js +20 -0
- package/dist/hosted/provider.js +120 -48
- package/dist/hosted/rest.d.ts +19 -8
- package/dist/hosted/rest.js +47 -14
- package/dist/hosted/scripts.d.ts +10 -0
- package/dist/hosted/scripts.js +23 -2
- package/dist/hosted/ssh-exec.d.ts +7 -1
- package/dist/hosted/ssh-exec.js +19 -14
- package/dist/hosted/ssh-key.d.ts +18 -0
- package/dist/hosted/ssh-key.js +36 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +4 -2
- package/dist/janitor.d.ts +7 -1
- package/dist/janitor.js +2 -2
- package/dist/kernel.d.ts +14 -4
- package/dist/kernel.js +141 -18
- package/dist/local-chrome.d.ts +12 -3
- package/dist/local-chrome.js +108 -10
- package/dist/local-supervisor.js +1 -0
- package/dist/modal.d.ts +6 -5
- package/dist/modal.js +7 -7
- package/dist/morph.js +5 -8
- package/dist/orgo-channel.d.ts +3 -2
- package/dist/orgo-channel.js +3 -3
- package/dist/orgo-desktop.js +2 -4
- package/dist/orgo.d.ts +6 -0
- package/dist/orgo.js +158 -15
- package/dist/phone-harness.d.ts +7 -5
- package/dist/phone-harness.js +60 -61
- package/dist/protocol.d.ts +10 -0
- package/dist/protocol.js +17 -0
- package/dist/provider.d.ts +6 -2
- package/dist/screen-watch.d.ts +6 -1
- package/dist/screen-watch.js +166 -12
- package/dist/vendor-sdk.d.ts +9 -0
- package/dist/vendor-sdk.js +26 -0
- package/package.json +8 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type OrgoChannel, type OrgoProvider, type OrgoWebSocketFactory } from "../orgo.js";
|
|
2
2
|
import type { OrgoDesktopProvider } from "../orgo-desktop.js";
|
|
3
|
-
|
|
3
|
+
import { type Env, type HostedModuleOptions } from "./module-kit.js";
|
|
4
4
|
export declare const ENV: {
|
|
5
5
|
readonly live: "AGENTRUN_COMPUTER_LIVE_ORGO";
|
|
6
6
|
/** The template every computer of the run starts from; default Orgo's base desktop ("linux"). Linux only. */
|
|
@@ -14,24 +14,19 @@ export declare const ENV: {
|
|
|
14
14
|
/** The desktop: linux (default), windows or macos. */
|
|
15
15
|
readonly os: "COMPUTER_ORGO_OS";
|
|
16
16
|
};
|
|
17
|
-
/**
|
|
17
|
+
/** Orgo's shortest end, 1 h. */
|
|
18
18
|
export declare const CONFORMANCE_MAX_LIFETIME_MS: number;
|
|
19
|
-
/** For the run's report: what this configuration means for the suite. */
|
|
20
19
|
export declare const conformanceNotes: string[];
|
|
21
|
-
export interface OrgoModuleOptions {
|
|
22
|
-
/** Where the settings are read; default process.env. */
|
|
23
|
-
env?: Record<string, string | undefined>;
|
|
20
|
+
export interface OrgoModuleOptions extends HostedModuleOptions {
|
|
24
21
|
/** For tests: the REST calls, the terminal socket, or the whole channel. */
|
|
25
22
|
fetch?: typeof fetch;
|
|
26
23
|
webSocket?: OrgoWebSocketFactory;
|
|
27
24
|
channel?: OrgoChannel;
|
|
28
|
-
/** The daemon to upload
|
|
25
|
+
/** The daemon to upload. */
|
|
29
26
|
daemonPath?: string;
|
|
30
|
-
/** Builds this package's daemon for linux/amd64 stamped with version, and gives its path; default go build. */
|
|
31
|
-
buildDaemon?: (version: string) => Promise<string>;
|
|
32
27
|
}
|
|
33
28
|
/** The provider's settings from COMPUTER_ORGO_* alone: the key, and the workspace and Orgo's API when named. No word holds the key. */
|
|
34
|
-
export declare function settingsFromEnv(env?:
|
|
29
|
+
export declare function settingsFromEnv(env?: Env): {
|
|
35
30
|
apiKey: string;
|
|
36
31
|
workspaceId?: string;
|
|
37
32
|
apiUrl?: string;
|
package/dist/conformance/orgo.js
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
// Orgo for the conformance CLI: `npm run conformance -w @parcha/agentrun-computer -- --provider orgo [--image <template>]`.
|
|
2
|
-
// It makes real Orgo desktops,
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
// version <version>-drift. On Windows and macOS no daemon runs: the provider answers over Orgo's API (daemon none), the
|
|
9
|
-
// run's image is "windows" or "macos", and `--kind desktop` runs the desktop's cases, with the Windows fixture this
|
|
10
|
-
// package carries. Every computer of a run lives at most 1 h (on Linux and Windows Orgo's shortest end, ends_in_hours
|
|
11
|
-
// 1, deletes it then whatever happens to the run; macOS has no Orgo end, so the janitor alone ends it).
|
|
2
|
+
// It makes real Orgo desktops, under COMPUTER_ORGO_API_KEY (never ORGO_API_KEY). COMPUTER_ORGO_OS picks the desktop:
|
|
3
|
+
// linux (the default), windows or macos; on Windows and macOS no daemon runs, and the provider answers over Orgo's API:
|
|
4
|
+
// the run's image is "windows" or "macos", and `--kind desktop` runs the desktop's cases, with the Windows fixture this
|
|
5
|
+
// package carries.
|
|
6
|
+
// Every computer of a run lives at most 1 h (on Linux and Windows Orgo's shortest end, ends_in_hours 1, deletes it then
|
|
7
|
+
// whatever happens to the run; macOS has no Orgo end, so the janitor alone ends it).
|
|
12
8
|
import { ORGO_BASE_IMAGE, ORGO_MACOS_IMAGE, ORGO_WINDOWS_IMAGE } from "../descriptors/orgo.js";
|
|
13
9
|
import { create } from "../orgo.js";
|
|
14
10
|
import { buildDriftDaemon, DRIFT_VERSION } from "./drift-daemon.js";
|
|
15
|
-
|
|
11
|
+
import { requireLive, setOptions } from "./module-kit.js";
|
|
16
12
|
export const ENV = {
|
|
17
13
|
live: "AGENTRUN_COMPUTER_LIVE_ORGO",
|
|
18
14
|
/** The template every computer of the run starts from; default Orgo's base desktop ("linux"). Linux only. */
|
|
@@ -26,34 +22,26 @@ export const ENV = {
|
|
|
26
22
|
/** The desktop: linux (default), windows or macos. */
|
|
27
23
|
os: "COMPUTER_ORGO_OS",
|
|
28
24
|
};
|
|
29
|
-
|
|
30
|
-
/** The longest lifetime a computer of a run may ask for: Orgo's shortest end, 1 h. */
|
|
25
|
+
/** Orgo's shortest end, 1 h. */
|
|
31
26
|
export const CONFORMANCE_MAX_LIFETIME_MS = 60 * 60_000;
|
|
32
|
-
/** For the run's report: what this configuration means for the suite. */
|
|
33
27
|
export const conformanceNotes = [
|
|
34
28
|
"orgo: a Linux desktop on Orgo with computerd inside, on Orgo's own X display :99, its tools as 2510:2510; janitor-ended at the exact deadline its name carries, and within 1 h whatever happens (Orgo deletes it at ends_in_hours 1, the backstop); network none is init's own namespace (--own-network), probed from inside at the outside and at every port root listens on, since Orgo has no egress control; the desktop's path sockets are root's alone but the display's; no mount.",
|
|
35
29
|
"orgo windows and macos (COMPUTER_ORGO_OS): daemon none, the provider answering over Orgo's REST API: the screen from its screenshot, the pointer and keys from its click, drag, scroll, type and key calls, exec from its bash call (PowerShell on Windows), files through PowerShell on Windows; network open, since Orgo has no egress control and no daemon runs inside to hold one; the cases written for Linux (sh, /proc) are skipped in words.",
|
|
36
30
|
];
|
|
37
|
-
|
|
38
|
-
if (env[ORGO_ENV.live] !== "1") {
|
|
39
|
-
throw new Error(`the Orgo conformance module makes real computers: set ${ORGO_ENV.live}=1, with a key for an account you can bill, to run it`);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
31
|
+
const live = (env) => requireLive(env, ENV.live, "the Orgo conformance module makes real computers", "a key for an account you can bill");
|
|
42
32
|
/** The desktop COMPUTER_ORGO_OS names, linux when it names none; a throw in words for any other. */
|
|
43
33
|
function osOf(env) {
|
|
44
|
-
const os = env[
|
|
34
|
+
const os = env[ENV.os] || "linux";
|
|
45
35
|
if (os !== "linux" && os !== "windows" && os !== "macos")
|
|
46
|
-
throw new Error(`${
|
|
36
|
+
throw new Error(`${ENV.os} is linux, windows or macos, not ${JSON.stringify(os)}`);
|
|
47
37
|
return os;
|
|
48
38
|
}
|
|
49
39
|
/** The provider's settings from COMPUTER_ORGO_* alone: the key, and the workspace and Orgo's API when named. No word holds the key. */
|
|
50
40
|
export function settingsFromEnv(env = process.env) {
|
|
51
|
-
const apiKey = env[
|
|
41
|
+
const apiKey = env[ENV.key];
|
|
52
42
|
if (!apiKey)
|
|
53
|
-
throw new Error(`set ${
|
|
54
|
-
|
|
55
|
-
const apiUrl = env[ORGO_ENV.apiUrl] || undefined;
|
|
56
|
-
return { apiKey, ...(workspaceId ? { workspaceId } : {}), ...(apiUrl ? { apiUrl } : {}) };
|
|
43
|
+
throw new Error(`set ${ENV.key} to an Orgo API key: the Orgo module reads it there and nowhere else, never from ORGO_API_KEY`);
|
|
44
|
+
return { apiKey, ...setOptions(env, { workspaceId: ENV.workspace, apiUrl: ENV.apiUrl }) };
|
|
57
45
|
}
|
|
58
46
|
/** The image every computer of the run starts from: "windows" or "macos" for those desktops; else COMPUTER_ORGO_TEMPLATE, or Orgo's base desktop. */
|
|
59
47
|
export function conformanceImage({ env = process.env } = {}) {
|
|
@@ -62,7 +50,7 @@ export function conformanceImage({ env = process.env } = {}) {
|
|
|
62
50
|
return ORGO_WINDOWS_IMAGE;
|
|
63
51
|
if (os === "macos")
|
|
64
52
|
return ORGO_MACOS_IMAGE;
|
|
65
|
-
return env[
|
|
53
|
+
return env[ENV.template] || ORGO_BASE_IMAGE;
|
|
66
54
|
}
|
|
67
55
|
function build({ env = process.env, fetch, webSocket, channel }, daemonPath) {
|
|
68
56
|
const os = osOf(env);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AdbTransport, type PhoneHarnessProvider, type PhoneLedger, type PhoneProviderOptions } from "../phone-harness.js";
|
|
2
|
-
|
|
2
|
+
import { type Env } from "./module-kit.js";
|
|
3
3
|
export declare const PHONE_ENV: {
|
|
4
4
|
/** The phone harness API key: this module's own name, never the bare PHONE_HARNESS_API_KEY. */
|
|
5
5
|
readonly key: "COMPUTER_PHONE_HARNESS_API_KEY";
|
|
@@ -12,7 +12,6 @@ export declare const PHONE_ENV: {
|
|
|
12
12
|
/** 1 to rent phones at all: each one is billed by the minute. */
|
|
13
13
|
readonly live: "AGENTRUN_COMPUTER_LIVE_PHONE_HARNESS";
|
|
14
14
|
};
|
|
15
|
-
/** The names this module reads, under the conformance modules' common name. */
|
|
16
15
|
export declare const ENV: {
|
|
17
16
|
/** The phone harness API key: this module's own name, never the bare PHONE_HARNESS_API_KEY. */
|
|
18
17
|
readonly key: "COMPUTER_PHONE_HARNESS_API_KEY";
|
|
@@ -32,7 +31,7 @@ export interface PhoneSettings {
|
|
|
32
31
|
ledgerPath?: string;
|
|
33
32
|
}
|
|
34
33
|
/** The provider's settings this module reads from env, each only when its name is set. */
|
|
35
|
-
export declare function settingsFromEnv(env?:
|
|
34
|
+
export declare function settingsFromEnv(env?: Env): PhoneSettings;
|
|
36
35
|
/**
|
|
37
36
|
* A ledger in a JSON file (mode 0600), read whole on each call and written whole by rename, so a reader never sees half
|
|
38
37
|
* a file. Writes (put, remove) are one at a time across processes: in this process through one queue, and between
|
|
@@ -49,8 +48,7 @@ export declare function fileLedger(path: string, { waitMs }?: {
|
|
|
49
48
|
/** The ui fixture as an Android app (npm run build:ui-fixture), beside the compiled modules: a run installs it on its phones. */
|
|
50
49
|
export declare const UI_FIXTURE_APK: string;
|
|
51
50
|
export interface PhoneModuleOptions extends Pick<PhoneProviderOptions, "fetch" | "now" | "sleep" | "baseUrl" | "phoned"> {
|
|
52
|
-
|
|
53
|
-
env?: Record<string, string | undefined>;
|
|
51
|
+
env?: Env;
|
|
54
52
|
/** The adb runner; default the CLI the settings name. */
|
|
55
53
|
adb?: AdbTransport | string;
|
|
56
54
|
/** The ui fixture's APK; default UI_FIXTURE_APK. Installed on each phone when it is there. */
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
// another process sees the run's phones, and its drifted twin, which expects phoned to report another version. A phone is
|
|
4
4
|
// rented by the minute, so nothing is built without AGENTRUN_COMPUTER_LIVE_PHONE_HARNESS=1, and a run's phones live at
|
|
5
5
|
// most 10 min.
|
|
6
|
-
// The provider reads no environment: this module reads these names and passes them in as options.
|
|
7
6
|
import { createHash, randomBytes } from "node:crypto";
|
|
8
7
|
import { existsSync, linkSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
|
|
9
8
|
import { tmpdir } from "node:os";
|
|
@@ -11,7 +10,7 @@ import { dirname, join } from "node:path";
|
|
|
11
10
|
import { fileURLToPath } from "node:url";
|
|
12
11
|
import { PHONE_IMAGE } from "../descriptors/phone-harness.js";
|
|
13
12
|
import { adbCli, create } from "../phone-harness.js";
|
|
14
|
-
|
|
13
|
+
import { requireLive, setOptions } from "./module-kit.js";
|
|
15
14
|
export const PHONE_ENV = {
|
|
16
15
|
/** The phone harness API key: this module's own name, never the bare PHONE_HARNESS_API_KEY. */
|
|
17
16
|
key: "COMPUTER_PHONE_HARNESS_API_KEY",
|
|
@@ -24,18 +23,12 @@ export const PHONE_ENV = {
|
|
|
24
23
|
/** 1 to rent phones at all: each one is billed by the minute. */
|
|
25
24
|
live: "AGENTRUN_COMPUTER_LIVE_PHONE_HARNESS",
|
|
26
25
|
};
|
|
27
|
-
/** The names this module reads, under the conformance modules' common name. */
|
|
28
26
|
export const ENV = PHONE_ENV;
|
|
29
27
|
/** A conformance run's phones live at most this long. */
|
|
30
28
|
const RUN_MAX_LIFETIME_MS = 10 * 60_000;
|
|
31
29
|
/** The provider's settings this module reads from env, each only when its name is set. */
|
|
32
30
|
export function settingsFromEnv(env = process.env) {
|
|
33
|
-
return {
|
|
34
|
-
...(env[PHONE_ENV.key] ? { apiKey: env[PHONE_ENV.key] } : {}),
|
|
35
|
-
...(env[PHONE_ENV.platform] ? { platform: env[PHONE_ENV.platform] } : {}),
|
|
36
|
-
...(env[PHONE_ENV.adb] ? { adb: env[PHONE_ENV.adb] } : {}),
|
|
37
|
-
...(env[PHONE_ENV.ledger] ? { ledgerPath: env[PHONE_ENV.ledger] } : {}),
|
|
38
|
-
};
|
|
31
|
+
return setOptions(env, { apiKey: PHONE_ENV.key, platform: PHONE_ENV.platform, adb: PHONE_ENV.adb, ledgerPath: PHONE_ENV.ledger });
|
|
39
32
|
}
|
|
40
33
|
/** How long a writer waits for a live writer's lock on the ledger. A write holds it for well under a millisecond. */
|
|
41
34
|
const LOCK_WAIT_MS = 10_000;
|
|
@@ -219,8 +212,7 @@ export function fileLedger(path, { waitMs = LOCK_WAIT_MS } = {}) {
|
|
|
219
212
|
/** The ui fixture as an Android app (npm run build:ui-fixture), beside the compiled modules: a run installs it on its phones. */
|
|
220
213
|
export const UI_FIXTURE_APK = fileURLToPath(new URL("../ui-fixture.apk", import.meta.url));
|
|
221
214
|
function optionsOf({ env = process.env, adb, uiFixture = UI_FIXTURE_APK, ...rest }) {
|
|
222
|
-
|
|
223
|
-
throw new Error(`a conformance run rents a cloud phone, billed by the minute: set ${PHONE_ENV.live}=1 to run it`);
|
|
215
|
+
requireLive(env, PHONE_ENV.live, "a conformance run rents a cloud phone, billed by the minute");
|
|
224
216
|
const settings = settingsFromEnv(env);
|
|
225
217
|
if (!settings.apiKey)
|
|
226
218
|
throw new Error(`set ${PHONE_ENV.key} to the phone harness API key`);
|
|
@@ -3,9 +3,19 @@ import { type ConformanceOptions, type ConformanceReport } from "./types.js";
|
|
|
3
3
|
/** The label every computer of a run carries, with the run's id. */
|
|
4
4
|
export declare const RUN_LABEL = "agentrun.conformance";
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* The label every computer of a run also carries, with an id minted by each runConformance call, never given. Several
|
|
7
|
+
* runners may share one run's id (two processes given one before file's --run), so the runner's own end-of-run sweeps
|
|
8
|
+
* go by this label too: the first runner to end deletes its own computers, never another runner's live ones. The live
|
|
9
|
+
* sweep's --after goes by RUN_LABEL alone, so it still takes every runner's leftovers.
|
|
10
|
+
*/
|
|
11
|
+
export declare const RUNNER_LABEL = "agentrun.conformance.runner";
|
|
12
|
+
/** A run's id: 12 hex characters, minted by the run itself or by the live sweep's --before (sweep.ts) for the run it wraps. */
|
|
13
|
+
export declare const RUN_ID: RegExp;
|
|
14
|
+
export declare const newRunId: () => string;
|
|
15
|
+
/**
|
|
16
|
+
* Runs the cases against the provider and reports each one. Every computer carries the run's label and the runner's;
|
|
17
|
+
* each one a case makes is deleted when the case ends, the shared one when the run ends, then a janitor provider is
|
|
18
|
+
* swept by both labels and they are listed to show nothing is left. Every provider call is bounded: one that never answers fails its case
|
|
9
19
|
* or is named in the cleanup, and a computer that arrives after its case ended is deleted when it arrives.
|
|
10
20
|
*/
|
|
11
21
|
export declare function runConformance(provider: ComputerProvider, options: ConformanceOptions): Promise<ConformanceReport>;
|
|
@@ -13,6 +13,16 @@ import { kindCases, kindRunProblem, kindVerdict } from "./kind.js";
|
|
|
13
13
|
import { caseOs, coreGroups, } from "./types.js";
|
|
14
14
|
/** The label every computer of a run carries, with the run's id. */
|
|
15
15
|
export const RUN_LABEL = "agentrun.conformance";
|
|
16
|
+
/**
|
|
17
|
+
* The label every computer of a run also carries, with an id minted by each runConformance call, never given. Several
|
|
18
|
+
* runners may share one run's id (two processes given one before file's --run), so the runner's own end-of-run sweeps
|
|
19
|
+
* go by this label too: the first runner to end deletes its own computers, never another runner's live ones. The live
|
|
20
|
+
* sweep's --after goes by RUN_LABEL alone, so it still takes every runner's leftovers.
|
|
21
|
+
*/
|
|
22
|
+
export const RUNNER_LABEL = "agentrun.conformance.runner";
|
|
23
|
+
/** A run's id: 12 hex characters, minted by the run itself or by the live sweep's --before (sweep.ts) for the run it wraps. */
|
|
24
|
+
export const RUN_ID = /^[0-9a-f]{12}$/;
|
|
25
|
+
export const newRunId = () => randomBytes(6).toString("hex");
|
|
16
26
|
/** The lifetime a run's computers ask for, at most the provider's own cap: a metered phone's cap is its hard stop. */
|
|
17
27
|
const LIFETIME_MS = 30 * 60_000;
|
|
18
28
|
const GROUP_NAMES = new Set(GROUPS);
|
|
@@ -78,9 +88,9 @@ function whenAborted(signal) {
|
|
|
78
88
|
});
|
|
79
89
|
}
|
|
80
90
|
/**
|
|
81
|
-
* Runs the cases against the provider and reports each one. Every computer carries the run's label
|
|
82
|
-
* makes is deleted when the case ends, the shared one when the run ends, then a janitor provider is
|
|
83
|
-
* and
|
|
91
|
+
* Runs the cases against the provider and reports each one. Every computer carries the run's label and the runner's;
|
|
92
|
+
* each one a case makes is deleted when the case ends, the shared one when the run ends, then a janitor provider is
|
|
93
|
+
* swept by both labels and they are listed to show nothing is left. Every provider call is bounded: one that never answers fails its case
|
|
84
94
|
* or is named in the cleanup, and a computer that arrives after its case ended is deleted when it arrives.
|
|
85
95
|
*/
|
|
86
96
|
export async function runConformance(provider, options) {
|
|
@@ -100,8 +110,14 @@ export async function runConformance(provider, options) {
|
|
|
100
110
|
throw new TypeError(kindProblem);
|
|
101
111
|
const fetcher = options.fetch ?? ((url, init) => fetch(url, init));
|
|
102
112
|
const dialer = options.cdp ?? dialCdp;
|
|
103
|
-
|
|
104
|
-
|
|
113
|
+
if (options.run !== undefined && !RUN_ID.test(options.run))
|
|
114
|
+
throw new TypeError(`options.run is a run id the live sweep's --before mints, 12 hex characters; got ${JSON.stringify(options.run)}`);
|
|
115
|
+
const run = options.run ?? newRunId();
|
|
116
|
+
// This runner's own id: its create requests are named by it, not by the run's, since a provider makes one computer
|
|
117
|
+
// per request name, and another runner given the same run must never find this one's.
|
|
118
|
+
const runner = newRunId();
|
|
119
|
+
// The cases list and attach by both, and the cleanup sweeps by both: this runner's computers alone.
|
|
120
|
+
const runLabels = { [RUN_LABEL]: run, [RUNNER_LABEL]: runner };
|
|
105
121
|
const capabilities = provider.capabilities();
|
|
106
122
|
// A provider of the shape before groups declares none, so its kind-consistent case fails in words, not the run.
|
|
107
123
|
const groups = Array.isArray(capabilities.groups) ? capabilities.groups : [];
|
|
@@ -295,7 +311,7 @@ export async function runConformance(provider, options) {
|
|
|
295
311
|
// after it is deleted as it lands (lateCreate).
|
|
296
312
|
const stop = new AbortController();
|
|
297
313
|
const both = signal ? AbortSignal.any([signal, stop.signal]) : stop.signal;
|
|
298
|
-
const requestId = `${
|
|
314
|
+
const requestId = `${runner}/shared${++made > 1 ? `/${made}` : ""}`;
|
|
299
315
|
const creating = capped(requestId, "shared", both, () => provider.create(spec(), { signal: both, requestId }));
|
|
300
316
|
let created;
|
|
301
317
|
try {
|
|
@@ -459,7 +475,7 @@ export async function runConformance(provider, options) {
|
|
|
459
475
|
* create through by, kept: what it gives is deleted when the case ends, or as it comes after that. A create with
|
|
460
476
|
* planted secrets is outside the cap: it can't use the account, so it holds no room (one it makes anyway fails its case).
|
|
461
477
|
*/
|
|
462
|
-
const attempt = (whole, by = provider, requestId = `${
|
|
478
|
+
const attempt = (whole, by = provider, requestId = `${runner}/${c.id}/${++creates}`) => {
|
|
463
479
|
const make = () => by.create(whole, { signal: caseSignal, requestId });
|
|
464
480
|
const creating = (plantedBy.has(by) ? make() : capped(requestId, c.id, caseSignal, make)).then((created) => {
|
|
465
481
|
noteCreated(created, c.id);
|
|
@@ -531,7 +547,8 @@ export async function runConformance(provider, options) {
|
|
|
531
547
|
return home.replace(/\/+$/, "") || "/";
|
|
532
548
|
},
|
|
533
549
|
async dir() {
|
|
534
|
-
|
|
550
|
+
// The runner's id, not the run's: a computer whose home is a host's own may serve two runners of one run.
|
|
551
|
+
const path = `${await t.home()}/agentrun-conformance-${runner}/${c.id.replace(/[^a-z0-9-]/gi, "-")}-${++dirs}`;
|
|
535
552
|
await t.call("files.mkdir", { path, parents: true });
|
|
536
553
|
return path;
|
|
537
554
|
},
|
|
@@ -735,7 +752,10 @@ export async function runConformance(provider, options) {
|
|
|
735
752
|
report.kindVerdict = kindVerdict(kind, capabilities, report, selected);
|
|
736
753
|
return report;
|
|
737
754
|
}
|
|
738
|
-
/**
|
|
755
|
+
/**
|
|
756
|
+
* Sweeps a janitor provider by the runner's labels (RUN_LABEL and RUNNER_LABEL), past every deadline, and lists them to
|
|
757
|
+
* show nothing of its own is left: another runner given the same run keeps its computers.
|
|
758
|
+
*/
|
|
739
759
|
async function cleanup(provider, lifetime, labels, report, deleted, ms) {
|
|
740
760
|
try {
|
|
741
761
|
if (lifetime === "janitor") {
|
|
@@ -756,12 +776,13 @@ async function cleanup(provider, lifetime, labels, report, deleted, ms) {
|
|
|
756
776
|
else
|
|
757
777
|
report.cleanup.errors.push(`list ${JSON.stringify(labels)}: ${listed.error.code}: ${listed.error.message}`);
|
|
758
778
|
// Nothing left behind, read from the vendor itself: a provider on the shared machine-host adapter is swept by the
|
|
759
|
-
//
|
|
779
|
+
// runner's labels through its host, as the live sweep (sweep.ts) does by the run's, and every machine it finds must
|
|
780
|
+
// be gone.
|
|
760
781
|
const host = provider.host;
|
|
761
782
|
if (host !== undefined && typeof host.list === "function") {
|
|
762
783
|
const { sweepMachines } = await import("./sweep.js");
|
|
763
784
|
const said = [];
|
|
764
|
-
const swept = await within(sweepMachines(host, { labels, waitMs: ms, onWords: (words) => said.push(words) }), ms * 2, "the sweep of the run's machines");
|
|
785
|
+
const swept = await within(sweepMachines(host, { labels, run: labels[RUN_LABEL], waitMs: ms, onWords: (words) => said.push(words) }), ms * 2, "the sweep of the run's machines");
|
|
765
786
|
report.cleanup.errors.push(...said.map((words) => `sweep: ${words}`));
|
|
766
787
|
if (!swept.ok)
|
|
767
788
|
report.cleanup.errors.push(`sweep: ${swept.error.code}: ${swept.error.message}`);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { MachineHost } from "../host.js";
|
|
2
1
|
import { type SmolcloudProvider, type SmolcloudProviderOptions } from "../smolcloud.js";
|
|
3
|
-
|
|
2
|
+
import { type Env, type HostedModuleOptions } from "./module-kit.js";
|
|
3
|
+
export { CONFORMANCE_MAX_LIFETIME_MS } from "./module-kit.js";
|
|
4
4
|
export declare const SMOLCLOUD_ENV: {
|
|
5
5
|
readonly live: "AGENTRUN_COMPUTER_LIVE_SMOLCLOUD";
|
|
6
6
|
/** apiKey, required: the smol cloud API key. */
|
|
@@ -10,7 +10,6 @@ export declare const SMOLCLOUD_ENV: {
|
|
|
10
10
|
/** The OCI image every computer of the run starts from; default the box image (boxImageRef). */
|
|
11
11
|
readonly image: "COMPUTER_SMOLCLOUD_IMAGE";
|
|
12
12
|
};
|
|
13
|
-
/** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
|
|
14
13
|
export declare const ENV: {
|
|
15
14
|
readonly live: "AGENTRUN_COMPUTER_LIVE_SMOLCLOUD";
|
|
16
15
|
/** apiKey, required: the smol cloud API key. */
|
|
@@ -21,27 +20,12 @@ export declare const ENV: {
|
|
|
21
20
|
readonly image: "COMPUTER_SMOLCLOUD_IMAGE";
|
|
22
21
|
};
|
|
23
22
|
/** The provider's options this module reads from env; throws in words without the key, never echoing it. */
|
|
24
|
-
export declare function settingsFromEnv(env?:
|
|
25
|
-
/** The longest lifetime a computer of a run may ask for. */
|
|
26
|
-
export declare const CONFORMANCE_MAX_LIFETIME_MS: number;
|
|
27
|
-
/** For the run's report: what this configuration means for the suite. */
|
|
23
|
+
export declare function settingsFromEnv(env?: Env): Pick<SmolcloudProviderOptions, "apiKey" | "apiUrl">;
|
|
28
24
|
export declare const conformanceNotes: string[];
|
|
29
|
-
export interface SmolcloudModuleOptions extends Pick<SmolcloudProviderOptions, "fetch" | "daemonPath" | "timeouts"> {
|
|
30
|
-
/** Where the settings are read; default process.env. */
|
|
31
|
-
env?: Record<string, string | undefined>;
|
|
32
|
-
/** Builds this package's daemon for linux/amd64 stamped with version, and gives its path; default go build. */
|
|
33
|
-
buildDaemon?: (version: string) => Promise<string>;
|
|
25
|
+
export interface SmolcloudModuleOptions extends HostedModuleOptions, Pick<SmolcloudProviderOptions, "fetch" | "daemonPath" | "timeouts" | "onNote"> {
|
|
34
26
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
export declare function createDriftedProvider(options?: SmolcloudModuleOptions): Promise<SmolcloudProvider>;
|
|
27
|
+
export declare const createProvider: (options?: SmolcloudModuleOptions | undefined) => Promise<SmolcloudProvider>, createDriftedProvider: (options?: SmolcloudModuleOptions | undefined) => Promise<SmolcloudProvider>, createHost: (options?: SmolcloudModuleOptions | undefined) => Promise<import("../host.js").MachineHost>, sweepScope: (options?: {
|
|
28
|
+
env?: Env;
|
|
29
|
+
}) => string;
|
|
39
30
|
/** The image every computer of the run starts from: COMPUTER_SMOLCLOUD_IMAGE, else the box image prepareImage() answers. */
|
|
40
31
|
export declare function conformanceImage({ env }?: Pick<SmolcloudModuleOptions, "env">): Promise<string>;
|
|
41
|
-
/**
|
|
42
|
-
* The smol cloud host the live sweep (sweep.ts) lists and deletes through, from the same settings; it needs no live
|
|
43
|
-
* switch, since the sweep makes nothing, and it calls nothing until the sweep does.
|
|
44
|
-
*/
|
|
45
|
-
export declare function createHost(options?: Pick<SmolcloudModuleOptions, "env" | "fetch">): Promise<MachineHost>;
|
|
46
|
-
/** Where the sweep lists, in words: the key's account, the key named by its sha256 prefix alone. */
|
|
47
|
-
export declare function sweepScope({ env }?: Pick<SmolcloudModuleOptions, "env">): string;
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
// smol cloud for the conformance CLI: `npm run conformance -w @parcha/agentrun-computer -- --provider smolcloud`. It
|
|
2
2
|
// makes real machines, which bill until deleted, so it runs only with AGENTRUN_COMPUTER_LIVE_SMOLCLOUD=1 and your own
|
|
3
|
-
// key, under COMPUTER_SMOLCLOUD_API_KEY
|
|
4
|
-
//
|
|
5
|
-
// live sweep (sweep.ts, --provider smolcloud) reads the same names through createHost, which needs no live switch: it
|
|
6
|
-
// makes nothing. Every computer of a run has a deadline of at most 30 minutes, and smol cloud's delete timer is set
|
|
7
|
-
// 5 minutes past it.
|
|
8
|
-
import { createHash } from "node:crypto";
|
|
3
|
+
// key, under COMPUTER_SMOLCLOUD_API_KEY (never SMOLCLOUD_API_KEY, which may hold another account's key). Every computer
|
|
4
|
+
// of a run has a deadline of at most 30 minutes, and smol cloud's delete timer is set 5 minutes past it.
|
|
9
5
|
import { boxImageRef } from "../box-image.js";
|
|
6
|
+
import { httpsBase } from "../hosted/rest.js";
|
|
10
7
|
import { create } from "../smolcloud.js";
|
|
11
|
-
import {
|
|
12
|
-
|
|
8
|
+
import { hostedModule, keyPrint, requiredSecret, setOptions } from "./module-kit.js";
|
|
9
|
+
export { CONFORMANCE_MAX_LIFETIME_MS } from "./module-kit.js";
|
|
13
10
|
export const SMOLCLOUD_ENV = {
|
|
14
11
|
live: "AGENTRUN_COMPUTER_LIVE_SMOLCLOUD",
|
|
15
12
|
/** apiKey, required: the smol cloud API key. */
|
|
@@ -19,55 +16,25 @@ export const SMOLCLOUD_ENV = {
|
|
|
19
16
|
/** The OCI image every computer of the run starts from; default the box image (boxImageRef). */
|
|
20
17
|
image: "COMPUTER_SMOLCLOUD_IMAGE",
|
|
21
18
|
};
|
|
22
|
-
/** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
|
|
23
19
|
export const ENV = SMOLCLOUD_ENV;
|
|
24
20
|
/** The provider's options this module reads from env; throws in words without the key, never echoing it. */
|
|
25
21
|
export function settingsFromEnv(env = process.env) {
|
|
26
|
-
const apiKey = env
|
|
27
|
-
|
|
28
|
-
throw new Error(`set ${SMOLCLOUD_ENV.key} to a smol cloud API key: the conformance module reads it there and nowhere else, never from SMOLCLOUD_API_KEY`);
|
|
29
|
-
const apiUrl = env[SMOLCLOUD_ENV.apiUrl] || undefined;
|
|
30
|
-
return { apiKey, ...(apiUrl === undefined ? {} : { apiUrl }) };
|
|
22
|
+
const apiKey = requiredSecret(env, SMOLCLOUD_ENV.key, "a smol cloud API key");
|
|
23
|
+
return { apiKey, ...setOptions(env, { apiUrl: SMOLCLOUD_ENV.apiUrl }) };
|
|
31
24
|
}
|
|
32
|
-
/** The longest lifetime a computer of a run may ask for. */
|
|
33
|
-
export const CONFORMANCE_MAX_LIFETIME_MS = 30 * 60_000;
|
|
34
|
-
/** For the run's report: what this configuration means for the suite. */
|
|
35
25
|
export const conformanceNotes = [
|
|
36
26
|
"smolcloud: every computer is a smol cloud machine (a microVM on an amd64 node) with its idle stop off and its delete timer at the adapter's backstop; the daemon is a child of a resumable interactive exec, its stdio the exec's long-polled output and numbered stdin frames; lifetime is the janitor's, by the deadline label, capped at 30 minutes for the run. Network none, open and a list are init's. No mount (smol cloud binds its storage disk at /workspace) and no desktop.",
|
|
37
27
|
];
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
live(env);
|
|
48
|
-
return create({ ...settingsFromEnv(env), ...doubles(options), maxLifetimeMs: CONFORMANCE_MAX_LIFETIME_MS });
|
|
49
|
-
}
|
|
50
|
-
/** The same provider uploading a daemon that reports version <version>-drift, for the drift.version case. */
|
|
51
|
-
export async function createDriftedProvider(options = {}) {
|
|
52
|
-
const { env = process.env, buildDaemon = (version) => buildDriftDaemon("amd64", version) } = options;
|
|
53
|
-
live(env);
|
|
54
|
-
const settings = settingsFromEnv(env);
|
|
55
|
-
return create({ ...settings, ...doubles(options), daemonPath: await buildDaemon(DRIFT_VERSION), maxLifetimeMs: CONFORMANCE_MAX_LIFETIME_MS });
|
|
56
|
-
}
|
|
28
|
+
export const { createProvider, createDriftedProvider, createHost, sweepScope } = hostedModule({
|
|
29
|
+
live: { name: SMOLCLOUD_ENV.live, what: "the smol cloud conformance module makes real machines, which bill until deleted", whose: "your own key" },
|
|
30
|
+
settingsFromEnv,
|
|
31
|
+
create,
|
|
32
|
+
host: ["fetch", "daemonPath", "timeouts"],
|
|
33
|
+
run: ["onNote"],
|
|
34
|
+
// The key's account, the key named by its sha256 prefix alone.
|
|
35
|
+
scope: ({ apiKey, apiUrl }) => `the smol cloud account of the key ${keyPrint(apiKey)} at ${httpsBase(apiUrl ?? "https://api.smolmachines.com", `the smol cloud API URL (${SMOLCLOUD_ENV.apiUrl})`)}`,
|
|
36
|
+
});
|
|
57
37
|
/** The image every computer of the run starts from: COMPUTER_SMOLCLOUD_IMAGE, else the box image prepareImage() answers. */
|
|
58
38
|
export async function conformanceImage({ env = process.env } = {}) {
|
|
59
39
|
return env[SMOLCLOUD_ENV.image] || boxImageRef();
|
|
60
40
|
}
|
|
61
|
-
/**
|
|
62
|
-
* The smol cloud host the live sweep (sweep.ts) lists and deletes through, from the same settings; it needs no live
|
|
63
|
-
* switch, since the sweep makes nothing, and it calls nothing until the sweep does.
|
|
64
|
-
*/
|
|
65
|
-
export async function createHost(options = {}) {
|
|
66
|
-
return (await create({ ...settingsFromEnv(options.env ?? process.env), ...doubles(options) })).host;
|
|
67
|
-
}
|
|
68
|
-
/** Where the sweep lists, in words: the key's account, the key named by its sha256 prefix alone. */
|
|
69
|
-
export function sweepScope({ env = process.env } = {}) {
|
|
70
|
-
const { apiKey, apiUrl } = settingsFromEnv(env);
|
|
71
|
-
const key = createHash("sha256").update(apiKey, "utf8").digest("hex").slice(0, 12);
|
|
72
|
-
return `the smol cloud account of the key sha256:${key} at ${apiUrl ?? "https://api.smolmachines.com"}`;
|
|
73
|
-
}
|
|
@@ -8,7 +8,9 @@ export interface SweepCounts {
|
|
|
8
8
|
leftAlone: number;
|
|
9
9
|
}
|
|
10
10
|
export interface SweepMachinesOptions {
|
|
11
|
-
/** The
|
|
11
|
+
/** The conformance run whose machines are deleted: those whose RUN_LABEL is this id. */
|
|
12
|
+
run: string;
|
|
13
|
+
/** The labels the listing asks for, over agentrun.computer=1. */
|
|
12
14
|
labels?: Record<string, string>;
|
|
13
15
|
/** Ids that were there before: never touched. */
|
|
14
16
|
before?: ReadonlySet<string>;
|
|
@@ -24,11 +26,11 @@ export interface SweepMachinesOptions {
|
|
|
24
26
|
onWords?: (words: string) => void;
|
|
25
27
|
}
|
|
26
28
|
/**
|
|
27
|
-
* The sweep over host: every machine listed with agentrun.computer=1 and `labels`, not in `before`,
|
|
28
|
-
*
|
|
29
|
-
*
|
|
29
|
+
* The sweep over host: every machine listed with agentrun.computer=1 and `labels`, not in `before`, whose RUN_LABEL is
|
|
30
|
+
* `run` is deleted and read back gone; any other is left alone and counted. A listing the vendor refused is the error,
|
|
31
|
+
* with nothing deleted, as is a run that is not a run id: nothing is listed then.
|
|
30
32
|
*/
|
|
31
|
-
export declare function sweepMachines(host: MachineHost, { labels, before, waitMs, pollMs, requestMs, listMs, onWords }
|
|
33
|
+
export declare function sweepMachines(host: MachineHost, { run, labels, before, waitMs, pollMs, requestMs, listMs, onWords }: SweepMachinesOptions): Promise<Result<SweepCounts>>;
|
|
32
34
|
/** A stream as main writes to it: done is called once the text is handed on. */
|
|
33
35
|
export interface Writer {
|
|
34
36
|
write(text: string, done?: (error?: Error | null) => void): unknown;
|
|
@@ -47,4 +49,7 @@ export interface SweepIo {
|
|
|
47
49
|
/** The pause between two reads of one machine; default 2 s. */
|
|
48
50
|
pollMs?: number;
|
|
49
51
|
}
|
|
52
|
+
/** The registry's providers on the shared machine-host adapter, in its order: each whose conformance module has
|
|
53
|
+
* createHost (what moduleOf asks of one). Read from the modules, so a provider added there is listed with no edit. */
|
|
54
|
+
export declare function sweepableProviders(): Promise<string[]>;
|
|
50
55
|
export declare function main(argv: string[], io?: SweepIo): Promise<number>;
|