@parcha/agentrun-computer 0.1.0-beta.36 → 0.1.0-beta.37
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/NOTICE +2 -0
- package/README.md +321 -308
- package/box/build-agent37.mjs +177 -0
- package/dist/agent37.d.ts +165 -0
- package/dist/agent37.js +759 -0
- package/dist/attach.d.ts +146 -0
- package/dist/attach.js +469 -0
- package/dist/browserbase.d.ts +2 -4
- package/dist/browserbase.js +2 -1
- package/dist/client.d.ts +33 -1
- package/dist/client.js +53 -0
- package/dist/computerd-linux-amd64 +0 -0
- package/dist/computerd-linux-arm64 +0 -0
- package/dist/conformance/agent37.d.ts +96 -0
- package/dist/conformance/agent37.js +154 -0
- package/dist/conformance/cases/apps.d.ts +5 -0
- package/dist/conformance/cases/apps.js +160 -73
- package/dist/conformance/cases/health.js +14 -0
- package/dist/conformance/cases/index.js +2 -0
- package/dist/conformance/cases/provider.js +27 -1
- package/dist/conformance/cases/screen.d.ts +3 -0
- package/dist/conformance/cases/screen.js +18 -0
- package/dist/conformance/cases/settings.d.ts +29 -23
- package/dist/conformance/cases/settings.js +76 -58
- package/dist/conformance/cases/touch.js +19 -17
- package/dist/conformance/cases/ui.d.ts +2 -0
- package/dist/conformance/cases/ui.js +475 -0
- package/dist/conformance/cli.d.ts +9 -0
- package/dist/conformance/cli.js +28 -3
- package/dist/conformance/e2b.d.ts +6 -0
- package/dist/conformance/e2b.js +9 -2
- package/dist/conformance/fixture.d.ts +1 -1
- package/dist/conformance/fixture.js +25 -1
- package/dist/conformance/modal.d.ts +17 -13
- package/dist/conformance/modal.js +18 -9
- package/dist/conformance/orgo.d.ts +3 -3
- package/dist/conformance/orgo.js +6 -8
- package/dist/conformance/phone-harness.d.ts +6 -2
- package/dist/conformance/phone-harness.js +21 -4
- package/dist/conformance/report.js +1 -1
- package/dist/conformance/runner.js +23 -4
- package/dist/conformance/sweep.d.ts +50 -0
- package/dist/conformance/sweep.js +187 -0
- package/dist/conformance/types.d.ts +11 -3
- package/dist/conformance/ui-fixture.d.ts +56 -0
- package/dist/conformance/ui-fixture.js +43 -0
- package/dist/create-requests.d.ts +51 -0
- package/dist/create-requests.js +121 -0
- package/dist/daytona.d.ts +2 -4
- package/dist/daytona.js +3 -2
- package/dist/descriptor.d.ts +5 -0
- package/dist/descriptor.js +2 -0
- package/dist/descriptors/agent37.d.ts +41 -0
- package/dist/descriptors/agent37.js +28 -0
- package/dist/descriptors/index.d.ts +38 -2
- package/dist/descriptors/index.js +4 -2
- package/dist/descriptors/orgo.d.ts +2 -1
- package/dist/descriptors/orgo.js +3 -2
- package/dist/descriptors/phone-harness.d.ts +1 -1
- package/dist/descriptors/phone-harness.js +2 -2
- package/dist/docker.d.ts +7 -4
- package/dist/docker.js +271 -29
- package/dist/e2b.d.ts +9 -165
- package/dist/e2b.js +282 -1342
- package/dist/fake-ui-driver.d.ts +97 -0
- package/dist/fake-ui-driver.js +717 -0
- package/dist/host.d.ts +182 -0
- package/dist/host.js +1 -0
- package/dist/hosted/process.d.ts +67 -0
- package/dist/hosted/process.js +228 -0
- package/dist/hosted/provider.d.ts +146 -0
- package/dist/hosted/provider.js +1364 -0
- package/dist/hosted/scripts.d.ts +76 -0
- package/dist/{child.js → hosted/scripts.js} +93 -12
- package/dist/index.d.ts +7 -3
- package/dist/index.js +7 -4
- package/dist/kernel.d.ts +2 -4
- package/dist/kernel.js +2 -1
- package/dist/kinds.d.ts +8 -1
- package/dist/kinds.js +20 -4
- package/dist/local-chrome.d.ts +2 -4
- package/dist/local-chrome.js +2 -1
- package/dist/modal.d.ts +23 -181
- package/dist/modal.js +271 -1244
- package/dist/orgo-channel.d.ts +3 -2
- package/dist/orgo-channel.js +5 -2
- package/dist/orgo-desktop.d.ts +9 -4
- package/dist/orgo-desktop.js +33 -13
- package/dist/orgo-workspaces.d.ts +47 -0
- package/dist/orgo-workspaces.js +94 -0
- package/dist/orgo.d.ts +10 -4
- package/dist/orgo.js +30 -12
- package/dist/phone-harness.d.ts +31 -22
- package/dist/phone-harness.js +510 -698
- package/dist/png.d.ts +4 -0
- package/dist/png.js +27 -0
- package/dist/protocol.d.ts +335 -32
- package/dist/protocol.js +96 -3
- package/dist/provider.d.ts +34 -6
- package/dist/provider.js +16 -0
- package/dist/result.d.ts +1 -1
- package/dist/surface/api.d.ts +248 -0
- package/dist/surface/api.js +1 -0
- package/dist/surface/core.d.ts +42 -0
- package/dist/surface/core.js +393 -0
- package/dist/surface/index.d.ts +5 -0
- package/dist/surface/index.js +3 -0
- package/dist/surface/outline.d.ts +8 -0
- package/dist/surface/outline.js +50 -0
- package/dist/surface/script.d.ts +10 -0
- package/dist/surface/script.js +92 -0
- package/dist/ui-engine.d.ts +114 -0
- package/dist/ui-engine.js +798 -0
- package/package.json +17 -1
- package/dist/child.d.ts +0 -42
- package/dist/conformance/e2b-diagnose.d.ts +0 -16
- package/dist/conformance/e2b-diagnose.js +0 -61
- package/dist/conformance/e2b-sweep.d.ts +0 -18
- package/dist/conformance/e2b-sweep.js +0 -132
- package/dist/conformance/modal-sweep.d.ts +0 -22
- package/dist/conformance/modal-sweep.js +0 -213
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import type { MachineHost } from "../host.js";
|
|
2
|
+
import { type ModalClientConstructor, type ModalCreateOptions, type ModalProvider } from "../modal.js";
|
|
1
3
|
import type { MountKind } from "../mount.js";
|
|
2
4
|
import type { ProviderNote } from "../mount-archil.js";
|
|
3
|
-
import type { ComputerProvider } from "../provider.js";
|
|
4
|
-
import { type ModalClientConstructor, type ModalCreateOptions } from "../modal.js";
|
|
5
5
|
import { type ArchilRunFolderOptions } from "./archil.js";
|
|
6
6
|
import type { RunFolder } from "./types.js";
|
|
7
7
|
/** The Archil disk's settings for the mount cases, by name (COMPUTER_ARCHIL_*: all five, or none). */
|
|
@@ -14,8 +14,6 @@ export declare const MODAL_ENV: {
|
|
|
14
14
|
readonly tokenSecret: "COMPUTER_MODAL_TOKEN_SECRET";
|
|
15
15
|
/** app, required: the Modal App the run's sandboxes live in, made when missing. */
|
|
16
16
|
readonly app: "COMPUTER_MODAL_APP";
|
|
17
|
-
/** daemonImage: an image holding the daemon, pinned by digest, to COPY --from instead of uploading it. */
|
|
18
|
-
readonly daemonImage: "COMPUTER_MODAL_DAEMON_IMAGE";
|
|
19
17
|
/** serverUrl: the server the token goes to; the SDK's default when unset. */
|
|
20
18
|
readonly serverUrl: "COMPUTER_MODAL_SERVER_URL";
|
|
21
19
|
};
|
|
@@ -27,13 +25,11 @@ export declare const ENV: {
|
|
|
27
25
|
readonly tokenSecret: "COMPUTER_MODAL_TOKEN_SECRET";
|
|
28
26
|
/** app, required: the Modal App the run's sandboxes live in, made when missing. */
|
|
29
27
|
readonly app: "COMPUTER_MODAL_APP";
|
|
30
|
-
/** daemonImage: an image holding the daemon, pinned by digest, to COPY --from instead of uploading it. */
|
|
31
|
-
readonly daemonImage: "COMPUTER_MODAL_DAEMON_IMAGE";
|
|
32
28
|
/** serverUrl: the server the token goes to; the SDK's default when unset. */
|
|
33
29
|
readonly serverUrl: "COMPUTER_MODAL_SERVER_URL";
|
|
34
30
|
};
|
|
35
|
-
/** What this module reads from the environment: the token, the app, and the server
|
|
36
|
-
export type ModalSettings = Pick<ModalCreateOptions, "tokenId" | "tokenSecret" | "app" | "serverUrl"
|
|
31
|
+
/** What this module reads from the environment: the token, the app, and the server when set. */
|
|
32
|
+
export type ModalSettings = Pick<ModalCreateOptions, "tokenId" | "tokenSecret" | "app" | "serverUrl">;
|
|
37
33
|
/**
|
|
38
34
|
* The provider's options this module reads from env; throws in words without the token or the app, or while
|
|
39
35
|
* MODAL_SERVER_URL is set there (the SDK would send the token to it), never echoing a token.
|
|
@@ -46,7 +42,7 @@ export interface ModalModuleOptions {
|
|
|
46
42
|
env?: Record<string, string | undefined>;
|
|
47
43
|
/** The SDK's ModalClient; imported from the host's modal package by default. */
|
|
48
44
|
ModalClient?: ModalClientConstructor;
|
|
49
|
-
/** The daemon to upload
|
|
45
|
+
/** The daemon to upload; default this package's dist/computerd-linux-amd64. */
|
|
50
46
|
daemonPath?: string;
|
|
51
47
|
/** Builds this package's daemon for linux/amd64 stamped with version, and gives its path; default go build. */
|
|
52
48
|
buildDaemon?: (version: string) => Promise<string>;
|
|
@@ -55,7 +51,8 @@ export interface ModalModuleOptions {
|
|
|
55
51
|
/** What the provider says that is no failure: the CLI gives it and puts it in the report. */
|
|
56
52
|
onNote?: ProviderNote;
|
|
57
53
|
}
|
|
58
|
-
|
|
54
|
+
/** The provider the CLI runs; throws in words without the live switch, or when a setting is missing or wrong. */
|
|
55
|
+
export declare function createProvider({ env, ModalClient, daemonPath, onNote }?: ModalModuleOptions): Promise<ModalProvider>;
|
|
59
56
|
/**
|
|
60
57
|
* A run folder for an Archil mount, and none for any other kind (a Modal computer takes no bind): a fresh folder on the
|
|
61
58
|
* disk the COMPUTER_ARCHIL_* names name (archilSettings), none when they name none (archilRunFolder, ./archil.ts).
|
|
@@ -63,7 +60,14 @@ export declare function createProvider({ env, ModalClient, daemonPath, onNote }?
|
|
|
63
60
|
*/
|
|
64
61
|
export declare function mountFor(kind: MountKind, { env, archil }?: ModalModuleOptions): Promise<RunFolder | undefined>;
|
|
65
62
|
/**
|
|
66
|
-
* The
|
|
67
|
-
*
|
|
63
|
+
* The Modal host the live sweep (sweep.ts) lists and deletes through, from the same settings; it needs no live switch,
|
|
64
|
+
* since the sweep makes nothing, and it calls nothing until the sweep does.
|
|
68
65
|
*/
|
|
69
|
-
export declare function
|
|
66
|
+
export declare function createHost({ env, ModalClient }?: Pick<ModalModuleOptions, "env" | "ModalClient">): Promise<MachineHost>;
|
|
67
|
+
/**
|
|
68
|
+
* Where the sweep lists, in words: the app and the server the settings name. A before file of another app, or of the
|
|
69
|
+
* same app name on another server, would make every computer there read as new, so the sweep refuses it.
|
|
70
|
+
*/
|
|
71
|
+
export declare function sweepScope({ env }?: Pick<ModalModuleOptions, "env">): string;
|
|
72
|
+
/** The same provider uploading a daemon that reports version <version>-drift, for the drift.version case. */
|
|
73
|
+
export declare function createDriftedProvider({ env, ModalClient, buildDaemon }?: ModalModuleOptions): Promise<ModalProvider>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { create } from "../modal.js";
|
|
1
|
+
import { create, MODAL_DEFAULT_SERVER_URL } from "../modal.js";
|
|
2
2
|
import { archilRunFolder, archilSettings } from "./archil.js";
|
|
3
3
|
import { buildDriftDaemon, DRIFT_VERSION } from "./drift-daemon.js";
|
|
4
4
|
/** The Archil disk's settings for the mount cases, by name (COMPUTER_ARCHIL_*: all five, or none). */
|
|
@@ -11,8 +11,6 @@ export const MODAL_ENV = {
|
|
|
11
11
|
tokenSecret: "COMPUTER_MODAL_TOKEN_SECRET",
|
|
12
12
|
/** app, required: the Modal App the run's sandboxes live in, made when missing. */
|
|
13
13
|
app: "COMPUTER_MODAL_APP",
|
|
14
|
-
/** daemonImage: an image holding the daemon, pinned by digest, to COPY --from instead of uploading it. */
|
|
15
|
-
daemonImage: "COMPUTER_MODAL_DAEMON_IMAGE",
|
|
16
14
|
/** serverUrl: the server the token goes to; the SDK's default when unset. */
|
|
17
15
|
serverUrl: "COMPUTER_MODAL_SERVER_URL",
|
|
18
16
|
};
|
|
@@ -35,8 +33,7 @@ export function settingsFromEnv(env = process.env) {
|
|
|
35
33
|
if (!app)
|
|
36
34
|
throw new Error(`the Modal conformance module needs ${MODAL_ENV.app}: the app the run's sandboxes live in`);
|
|
37
35
|
const serverUrl = env[MODAL_ENV.serverUrl];
|
|
38
|
-
|
|
39
|
-
return { tokenId, tokenSecret, app, ...(serverUrl ? { serverUrl } : {}), ...(daemonImage ? { daemonImage } : {}) };
|
|
36
|
+
return { tokenId, tokenSecret, app, ...(serverUrl ? { serverUrl } : {}) };
|
|
40
37
|
}
|
|
41
38
|
/** The longest lifetime a computer of a run may ask for: Modal ends each sandbox at its timeout, the lifetime. */
|
|
42
39
|
export const CONFORMANCE_MAX_LIFETIME_MS = 30 * 60_000;
|
|
@@ -45,9 +42,9 @@ function live(env) {
|
|
|
45
42
|
throw new Error(`the Modal conformance module makes real sandboxes: set ${MODAL_ENV.live}=1, with a key the lead has OKed, to run it`);
|
|
46
43
|
}
|
|
47
44
|
}
|
|
45
|
+
/** The provider the CLI runs; throws in words without the live switch, or when a setting is missing or wrong. */
|
|
48
46
|
export async function createProvider({ env = process.env, ModalClient, daemonPath, onNote } = {}) {
|
|
49
47
|
live(env);
|
|
50
|
-
// Given COMPUTER_MODAL_DAEMON_IMAGE and a daemonPath, create() takes the image.
|
|
51
48
|
return create({ ...settingsFromEnv(env), ...(daemonPath === undefined ? {} : { daemonPath }), ...(ModalClient ? { ModalClient } : {}), ...(onNote ? { onNote } : {}), maxLifetimeMs: CONFORMANCE_MAX_LIFETIME_MS });
|
|
52
49
|
}
|
|
53
50
|
/**
|
|
@@ -65,12 +62,24 @@ export async function mountFor(kind, { env = process.env, archil = {} } = {}) {
|
|
|
65
62
|
return archilRunFolder({ ...settings, ...archil });
|
|
66
63
|
}
|
|
67
64
|
/**
|
|
68
|
-
* The
|
|
69
|
-
*
|
|
65
|
+
* The Modal host the live sweep (sweep.ts) lists and deletes through, from the same settings; it needs no live switch,
|
|
66
|
+
* since the sweep makes nothing, and it calls nothing until the sweep does.
|
|
70
67
|
*/
|
|
68
|
+
export async function createHost({ env = process.env, ModalClient } = {}) {
|
|
69
|
+
return (await create({ ...settingsFromEnv(env), ...(ModalClient ? { ModalClient } : {}) })).host;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Where the sweep lists, in words: the app and the server the settings name. A before file of another app, or of the
|
|
73
|
+
* same app name on another server, would make every computer there read as new, so the sweep refuses it.
|
|
74
|
+
*/
|
|
75
|
+
export function sweepScope({ env = process.env } = {}) {
|
|
76
|
+
const { app, serverUrl = MODAL_DEFAULT_SERVER_URL } = settingsFromEnv(env);
|
|
77
|
+
return `the app ${app} on ${serverUrl}`;
|
|
78
|
+
}
|
|
79
|
+
/** The same provider uploading a daemon that reports version <version>-drift, for the drift.version case. */
|
|
71
80
|
export async function createDriftedProvider({ env = process.env, ModalClient, buildDaemon = (version) => buildDriftDaemon("amd64", version) } = {}) {
|
|
72
81
|
live(env);
|
|
73
|
-
const
|
|
82
|
+
const settings = settingsFromEnv(env);
|
|
74
83
|
const daemonPath = await buildDaemon(DRIFT_VERSION);
|
|
75
84
|
return create({ ...settings, daemonPath, ...(ModalClient ? { ModalClient } : {}), maxLifetimeMs: CONFORMANCE_MAX_LIFETIME_MS });
|
|
76
85
|
}
|
|
@@ -7,7 +7,7 @@ export declare const ENV: {
|
|
|
7
7
|
readonly template: "COMPUTER_ORGO_TEMPLATE";
|
|
8
8
|
/** Required: an Orgo API key (never ORGO_API_KEY, which a host may hold for another account). */
|
|
9
9
|
readonly key: "COMPUTER_ORGO_API_KEY";
|
|
10
|
-
/**
|
|
10
|
+
/** The workspace the run's computers live in; default the key's account's one workspace (several are refused in words). */
|
|
11
11
|
readonly workspace: "COMPUTER_ORGO_WORKSPACE";
|
|
12
12
|
/** Orgo's API; default https://www.orgo.ai/api. */
|
|
13
13
|
readonly apiUrl: "COMPUTER_ORGO_API_URL";
|
|
@@ -30,10 +30,10 @@ export interface OrgoModuleOptions {
|
|
|
30
30
|
/** Builds this package's daemon for linux/amd64 stamped with version, and gives its path; default go build. */
|
|
31
31
|
buildDaemon?: (version: string) => Promise<string>;
|
|
32
32
|
}
|
|
33
|
-
/** The provider's settings from COMPUTER_ORGO_* alone: the key, the workspace
|
|
33
|
+
/** 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
34
|
export declare function settingsFromEnv(env?: Record<string, string | undefined>): {
|
|
35
35
|
apiKey: string;
|
|
36
|
-
workspaceId
|
|
36
|
+
workspaceId?: string;
|
|
37
37
|
apiUrl?: string;
|
|
38
38
|
};
|
|
39
39
|
/** The image every computer of the run starts from: "windows" or "macos" for those desktops; else COMPUTER_ORGO_TEMPLATE, or Orgo's base desktop. */
|
package/dist/conformance/orgo.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Orgo for the conformance CLI: `npm run conformance -w @parcha/agentrun-computer -- --provider orgo [--image <template>]`.
|
|
2
2
|
// It makes real Orgo desktops, so it runs only with AGENTRUN_COMPUTER_LIVE_ORGO=1 and a key the lead has OKed, under
|
|
3
|
-
// COMPUTER_ORGO_API_KEY (never ORGO_API_KEY), in the workspace COMPUTER_ORGO_WORKSPACE names
|
|
4
|
-
// first, before any other setting is read.
|
|
3
|
+
// COMPUTER_ORGO_API_KEY (never ORGO_API_KEY), in the workspace COMPUTER_ORGO_WORKSPACE names, or the key's account's one
|
|
4
|
+
// workspace when it names none. The live switch is checked first, before any other setting is read.
|
|
5
5
|
//
|
|
6
6
|
// COMPUTER_ORGO_OS picks the desktop: linux (the default), windows or macos. On Linux the daemon is uploaded into each
|
|
7
7
|
// computer (dist/computerd-linux-amd64, `npm run build:daemon`); the drifted provider uploads one built with Go as
|
|
@@ -19,7 +19,7 @@ export const ENV = {
|
|
|
19
19
|
template: "COMPUTER_ORGO_TEMPLATE",
|
|
20
20
|
/** Required: an Orgo API key (never ORGO_API_KEY, which a host may hold for another account). */
|
|
21
21
|
key: "COMPUTER_ORGO_API_KEY",
|
|
22
|
-
/**
|
|
22
|
+
/** The workspace the run's computers live in; default the key's account's one workspace (several are refused in words). */
|
|
23
23
|
workspace: "COMPUTER_ORGO_WORKSPACE",
|
|
24
24
|
/** Orgo's API; default https://www.orgo.ai/api. */
|
|
25
25
|
apiUrl: "COMPUTER_ORGO_API_URL",
|
|
@@ -46,16 +46,14 @@ function osOf(env) {
|
|
|
46
46
|
throw new Error(`${ORGO_ENV.os} is linux, windows or macos, not ${JSON.stringify(os)}`);
|
|
47
47
|
return os;
|
|
48
48
|
}
|
|
49
|
-
/** The provider's settings from COMPUTER_ORGO_* alone: the key, the workspace
|
|
49
|
+
/** 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
50
|
export function settingsFromEnv(env = process.env) {
|
|
51
51
|
const apiKey = env[ORGO_ENV.key];
|
|
52
52
|
if (!apiKey)
|
|
53
53
|
throw new Error(`set ${ORGO_ENV.key} to an Orgo API key: the Orgo module reads it there and nowhere else, never from ORGO_API_KEY`);
|
|
54
|
-
const workspaceId = env[ORGO_ENV.workspace];
|
|
55
|
-
if (!workspaceId)
|
|
56
|
-
throw new Error(`set ${ORGO_ENV.workspace} to the Orgo workspace the run's computers live in`);
|
|
54
|
+
const workspaceId = env[ORGO_ENV.workspace] || undefined;
|
|
57
55
|
const apiUrl = env[ORGO_ENV.apiUrl] || undefined;
|
|
58
|
-
return { apiKey, workspaceId, ...(apiUrl ? { apiUrl } : {}) };
|
|
56
|
+
return { apiKey, ...(workspaceId ? { workspaceId } : {}), ...(apiUrl ? { apiUrl } : {}) };
|
|
59
57
|
}
|
|
60
58
|
/** The image every computer of the run starts from: "windows" or "macos" for those desktops; else COMPUTER_ORGO_TEMPLATE, or Orgo's base desktop. */
|
|
61
59
|
export function conformanceImage({ env = process.env } = {}) {
|
|
@@ -46,15 +46,19 @@ export declare function settingsFromEnv(env?: Record<string, string | undefined>
|
|
|
46
46
|
export declare function fileLedger(path: string, { waitMs }?: {
|
|
47
47
|
waitMs?: number;
|
|
48
48
|
}): PhoneLedger;
|
|
49
|
-
|
|
49
|
+
/** The ui fixture as an Android app (npm run build:ui-fixture), beside the compiled modules: a run installs it on its phones. */
|
|
50
|
+
export declare const UI_FIXTURE_APK: string;
|
|
51
|
+
export interface PhoneModuleOptions extends Pick<PhoneProviderOptions, "fetch" | "now" | "sleep" | "baseUrl" | "phoned"> {
|
|
50
52
|
/** Where the settings are read; default process.env. */
|
|
51
53
|
env?: Record<string, string | undefined>;
|
|
52
54
|
/** The adb runner; default the CLI the settings name. */
|
|
53
55
|
adb?: AdbTransport | string;
|
|
56
|
+
/** The ui fixture's APK; default UI_FIXTURE_APK. Installed on each phone when it is there. */
|
|
57
|
+
uiFixture?: string;
|
|
54
58
|
}
|
|
55
59
|
/** The provider the CLI runs. */
|
|
56
60
|
export declare function createProvider(options?: PhoneModuleOptions): Promise<PhoneHarnessProvider>;
|
|
57
|
-
/** The same provider,
|
|
61
|
+
/** The same provider, expecting phoned to report another version than its own: connect refuses it, for the drift.version case. */
|
|
58
62
|
export declare function createDriftedProvider(options?: PhoneModuleOptions): Promise<PhoneHarnessProvider>;
|
|
59
63
|
/** The image a run names: a cloud Android has none to choose, so it is read back as this name. */
|
|
60
64
|
export declare function conformanceImage(): string;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
// The phone harness for the conformance CLI and the live harness (`--provider phone-harness`): the provider as create()
|
|
2
2
|
// builds it from the settings this module reads (COMPUTER_PHONE_HARNESS_*), with its ledger in a JSON file so a sweep in
|
|
3
|
-
// another process sees the run's phones, and its drifted twin,
|
|
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
6
|
// The provider reads no environment: this module reads these names and passes them in as options.
|
|
7
7
|
import { randomBytes } from "node:crypto";
|
|
8
|
-
import { linkSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
|
|
8
|
+
import { existsSync, linkSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
|
|
9
9
|
import { tmpdir } from "node:os";
|
|
10
10
|
import { dirname, join } from "node:path";
|
|
11
|
+
import { fileURLToPath } from "node:url";
|
|
11
12
|
import { PHONE_IMAGE } from "../descriptors/phone-harness.js";
|
|
12
13
|
import { adbCli, create } from "../phone-harness.js";
|
|
13
14
|
/** The environment this module reads, by name. */
|
|
@@ -196,6 +197,14 @@ export function fileLedger(path, { waitMs = LOCK_WAIT_MS } = {}) {
|
|
|
196
197
|
};
|
|
197
198
|
return {
|
|
198
199
|
put: (entry) => locked(() => write({ ...read(), [entry.id]: entry })),
|
|
200
|
+
// Under the file's lock: the read and the write are one step to every other writer.
|
|
201
|
+
claim: (entry) => locked(() => {
|
|
202
|
+
const entries = read();
|
|
203
|
+
if (entry.id in entries)
|
|
204
|
+
return false;
|
|
205
|
+
write({ ...entries, [entry.id]: entry });
|
|
206
|
+
return true;
|
|
207
|
+
}),
|
|
199
208
|
get: (id) => read()[id],
|
|
200
209
|
list: () => Object.values(read()),
|
|
201
210
|
remove: (id) => locked(() => {
|
|
@@ -207,7 +216,9 @@ export function fileLedger(path, { waitMs = LOCK_WAIT_MS } = {}) {
|
|
|
207
216
|
}),
|
|
208
217
|
};
|
|
209
218
|
}
|
|
210
|
-
|
|
219
|
+
/** The ui fixture as an Android app (npm run build:ui-fixture), beside the compiled modules: a run installs it on its phones. */
|
|
220
|
+
export const UI_FIXTURE_APK = fileURLToPath(new URL("../ui-fixture.apk", import.meta.url));
|
|
221
|
+
function optionsOf({ env = process.env, adb, uiFixture = UI_FIXTURE_APK, ...rest }) {
|
|
211
222
|
if (env[PHONE_ENV.live] !== "1")
|
|
212
223
|
throw new Error(`a conformance run rents a cloud phone, billed by the minute: set ${PHONE_ENV.live}=1 to run it`);
|
|
213
224
|
const settings = settingsFromEnv(env);
|
|
@@ -222,6 +233,9 @@ function optionsOf({ env = process.env, adb, ...rest }) {
|
|
|
222
233
|
adb: adb !== undefined && typeof adb !== "string" ? adb : adbCli(adb ?? settings.adb ?? "adb", { env: Object.fromEntries(Object.entries(env).filter(([name]) => !Object.values(PHONE_ENV).includes(name))) }),
|
|
223
234
|
ledger: fileLedger(settings.ledgerPath ?? join(tmpdir(), "agentrun-phone-ledger.json")),
|
|
224
235
|
maxLifetimeMs: RUN_MAX_LIFETIME_MS,
|
|
236
|
+
// The Full ui cases act on the fixture. Without its APK they skip, each saying it is not installed, and the
|
|
237
|
+
// report's notes say why (conformanceNotes).
|
|
238
|
+
apks: existsSync(uiFixture) ? [uiFixture] : [],
|
|
225
239
|
...rest,
|
|
226
240
|
};
|
|
227
241
|
}
|
|
@@ -229,7 +243,7 @@ function optionsOf({ env = process.env, adb, ...rest }) {
|
|
|
229
243
|
export async function createProvider(options = {}) {
|
|
230
244
|
return create(optionsOf(options));
|
|
231
245
|
}
|
|
232
|
-
/** The same provider,
|
|
246
|
+
/** The same provider, expecting phoned to report another version than its own: connect refuses it, for the drift.version case. */
|
|
233
247
|
export async function createDriftedProvider(options = {}) {
|
|
234
248
|
return create({ ...optionsOf(options), daemonVersion: "0.0.0-drift" });
|
|
235
249
|
}
|
|
@@ -239,4 +253,7 @@ export function conformanceImage() {
|
|
|
239
253
|
}
|
|
240
254
|
export const conformanceNotes = [
|
|
241
255
|
"phone-harness: a temporary cloud Android emulator, driven over adb; a phone is billed by the minute, and lives at most 10 min in a run",
|
|
256
|
+
existsSync(UI_FIXTURE_APK)
|
|
257
|
+
? `phone-harness: each phone gets the ui fixture installed (${UI_FIXTURE_APK}) for the Full ui cases`
|
|
258
|
+
: `phone-harness: the ui fixture's APK is not at ${UI_FIXTURE_APK} (npm run build:ui-fixture builds it), so the Full ui cases skip: no phone has the fixture`,
|
|
242
259
|
];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const GROUPS = ["health", "exec", "files", "process", "provider", "drift", "isolation", "mount", "screen", "input", "touch", "apps", "lifetime", "browser", "gpu"];
|
|
1
|
+
const GROUPS = ["health", "exec", "files", "process", "provider", "drift", "isolation", "mount", "screen", "input", "touch", "apps", "ui", "lifetime", "browser", "gpu"];
|
|
2
2
|
const NAMES_WIDTH = 44;
|
|
3
3
|
const INDENT = " ".repeat("core ".length + "provider ".length + 1);
|
|
4
4
|
/** The case names, wrapped to the column's width: the first line, then the rest. */
|
|
@@ -192,7 +192,7 @@ export async function runConformance(provider, options) {
|
|
|
192
192
|
// The run's signal ends the wait at once (Ctrl-C during setup) and reaches the create; a computer that arrives
|
|
193
193
|
// after it is deleted as it lands (lateCreate).
|
|
194
194
|
const stop = new AbortController();
|
|
195
|
-
const creating = provider.create(spec(), { signal: signal ? AbortSignal.any([signal, stop.signal]) : stop.signal });
|
|
195
|
+
const creating = provider.create(spec(), { signal: signal ? AbortSignal.any([signal, stop.signal]) : stop.signal, requestId: `${run}/shared` });
|
|
196
196
|
let created;
|
|
197
197
|
try {
|
|
198
198
|
created = await within(creating, caseTimeoutMs, "create", signal);
|
|
@@ -346,11 +346,14 @@ export async function runConformance(provider, options) {
|
|
|
346
346
|
sawHello(ref.name, once.hello, c.id);
|
|
347
347
|
return once;
|
|
348
348
|
};
|
|
349
|
+
/** Each create of the case is its own request: the run, the case and the create's count. */
|
|
350
|
+
let creates = 0;
|
|
349
351
|
/** create through by, kept: what it gives is deleted when the case ends, or as it comes after that. */
|
|
350
|
-
const attempt = (whole, by = provider) => {
|
|
351
|
-
const creating = by.create(whole, { signal: caseSignal }).then((created) => {
|
|
352
|
+
const attempt = (whole, by = provider, requestId = `${run}/${c.id}/${++creates}`) => {
|
|
353
|
+
const creating = by.create(whole, { signal: caseSignal, requestId }).then((created) => {
|
|
352
354
|
noteCreated(created, c.id);
|
|
353
|
-
|
|
355
|
+
// A retry of one request answers the computer the first attempt made: it is tracked once.
|
|
356
|
+
if (created.ok && !refs.some((one) => one.ref.id === created.value.id))
|
|
354
357
|
track(created.value, by);
|
|
355
358
|
return created;
|
|
356
359
|
});
|
|
@@ -627,6 +630,22 @@ async function cleanup(provider, lifetime, labels, report, deleted, ms) {
|
|
|
627
630
|
report.cleanup.left = listed.value.map((info) => info.ref.name).sort();
|
|
628
631
|
else
|
|
629
632
|
report.cleanup.errors.push(`list ${JSON.stringify(labels)}: ${listed.error.code}: ${listed.error.message}`);
|
|
633
|
+
// Nothing left behind, read from the vendor itself: a provider on the shared machine-host adapter is swept by the
|
|
634
|
+
// run's label through its host, as the live sweep (sweep.ts) does, and every machine it finds must be gone.
|
|
635
|
+
const host = provider.host;
|
|
636
|
+
if (host !== undefined && typeof host.list === "function") {
|
|
637
|
+
const { sweepMachines } = await import("./sweep.js");
|
|
638
|
+
const said = [];
|
|
639
|
+
const swept = await within(sweepMachines(host, { labels, waitMs: ms, onWords: (words) => said.push(words) }), ms * 2, "the sweep of the run's machines");
|
|
640
|
+
report.cleanup.errors.push(...said.map((words) => `sweep: ${words}`));
|
|
641
|
+
if (!swept.ok)
|
|
642
|
+
report.cleanup.errors.push(`sweep: ${swept.error.code}: ${swept.error.message}`);
|
|
643
|
+
else {
|
|
644
|
+
report.cleanup.sweep = swept.value;
|
|
645
|
+
if (swept.value.stillThere.length > 0)
|
|
646
|
+
report.cleanup.errors.push(`sweep: nothing left behind fails: still there ${swept.value.stillThere.join(", ")}`);
|
|
647
|
+
}
|
|
648
|
+
}
|
|
630
649
|
}
|
|
631
650
|
catch (error) {
|
|
632
651
|
report.cleanup.errors.push(words(error));
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { MachineHost } from "../host.js";
|
|
2
|
+
import { type Result } from "../result.js";
|
|
3
|
+
/** What one sweep did: see the file's head. */
|
|
4
|
+
export interface SweepCounts {
|
|
5
|
+
swept: number;
|
|
6
|
+
gone: number;
|
|
7
|
+
stillThere: string[];
|
|
8
|
+
leftAlone: number;
|
|
9
|
+
}
|
|
10
|
+
export interface SweepMachinesOptions {
|
|
11
|
+
/** The labels every machine swept carries, over agentrun.computer=1. */
|
|
12
|
+
labels?: Record<string, string>;
|
|
13
|
+
/** Ids that were there before: never touched. */
|
|
14
|
+
before?: ReadonlySet<string>;
|
|
15
|
+
/** How long one deleted machine is read back before it counts as still there; default 60 s. */
|
|
16
|
+
waitMs?: number;
|
|
17
|
+
/** The pause between two reads of one machine; default 2 s. */
|
|
18
|
+
pollMs?: number;
|
|
19
|
+
/** One vendor call's bound; default 30 s. */
|
|
20
|
+
requestMs?: number;
|
|
21
|
+
/** One whole listing's bound; default 60 s. */
|
|
22
|
+
listMs?: number;
|
|
23
|
+
/** Told, in words, of a machine not deleted or still there. */
|
|
24
|
+
onWords?: (words: string) => void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The sweep over host: every machine listed with agentrun.computer=1 and `labels`, not in `before`, that carries a
|
|
28
|
+
* conformance run's label is deleted and read back gone; one without it is left alone and counted. A listing the
|
|
29
|
+
* vendor refused is the error, with nothing deleted.
|
|
30
|
+
*/
|
|
31
|
+
export declare function sweepMachines(host: MachineHost, { labels, before, waitMs, pollMs, requestMs, listMs, onWords }?: SweepMachinesOptions): Promise<Result<SweepCounts>>;
|
|
32
|
+
/** A stream as main writes to it: done is called once the text is handed on. */
|
|
33
|
+
export interface Writer {
|
|
34
|
+
write(text: string, done?: (error?: Error | null) => void): unknown;
|
|
35
|
+
}
|
|
36
|
+
export interface SweepIo {
|
|
37
|
+
/** Where the settings are read; default process.env. */
|
|
38
|
+
env?: Record<string, string | undefined>;
|
|
39
|
+
/** The host to sweep, in place of the one the provider's conformance module makes from env. */
|
|
40
|
+
host?: MachineHost;
|
|
41
|
+
/** Where that host lists, in words, in place of the module's sweepScope. */
|
|
42
|
+
scope?: string;
|
|
43
|
+
stdout?: Writer;
|
|
44
|
+
stderr?: Writer;
|
|
45
|
+
/** How long --after reads one deleted machine back before it counts as still there; default 60 s. */
|
|
46
|
+
waitMs?: number;
|
|
47
|
+
/** The pause between two reads of one machine; default 2 s. */
|
|
48
|
+
pollMs?: number;
|
|
49
|
+
}
|
|
50
|
+
export declare function main(argv: string[], io?: SweepIo): Promise<number>;
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
// The one live sweep, for every provider on the shared machine-host adapter, with the provider's conformance settings
|
|
2
|
+
// (its COMPUTER_<VENDOR>_* names, read by its conformance module's createHost):
|
|
3
|
+
//
|
|
4
|
+
// node packages/computer/dist/conformance/sweep.js --provider <id> --before <file>
|
|
5
|
+
// node packages/computer/dist/conformance/sweep.js --provider <id> --after <file>
|
|
6
|
+
//
|
|
7
|
+
// --before records into <file> the id of every machine the vendor lists with the adapter's label agentrun.computer=1.
|
|
8
|
+
// --after lists them again, deletes every one whose id is not in <file> and that carries a conformance run's label
|
|
9
|
+
// (agentrun.conformance, RUN_LABEL), then reads each of those back until the vendor no longer has it and no longer lists
|
|
10
|
+
// it, up to 60 s each, and prints one JSON line, {"swept":n,"gone":m,"stillThere":[ids],"leftAlone":k}: swept is every
|
|
11
|
+
// conformance machine it found that was not there before, gone + stillThere.length = swept, and leftAlone counts the new
|
|
12
|
+
// labelled machines with no conformance label, which another user of the account made during the run: never touched. A
|
|
13
|
+
// machine in <file> is never touched either: no call names it, and a before file of another provider is refused, as is
|
|
14
|
+
// one listed elsewhere for a provider whose module names where it lists (sweepScope: an app and a server), since
|
|
15
|
+
// every machine there would read as new.
|
|
16
|
+
// Exit 0 when every swept machine is gone, 1 when one is still there, 2 on a usage error, a before file it cannot read,
|
|
17
|
+
// missing settings, or a listing the vendor refused (nothing is deleted then). It makes nothing, so it needs no live switch.
|
|
18
|
+
//
|
|
19
|
+
// The conformance runner runs the same sweep (sweepMachines) at the end of every run of a hosted provider, over the
|
|
20
|
+
// run's own label: its report's cleanup.sweep, whose stillThere must be empty for Core to pass.
|
|
21
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
22
|
+
import { COMPUTER_LABEL } from "../drift.js";
|
|
23
|
+
import { isCommand } from "../entry.js";
|
|
24
|
+
import { hostCall } from "../hosted/process.js";
|
|
25
|
+
import { NAME_LABEL, settleGone } from "../hosted/provider.js";
|
|
26
|
+
import { providerModule } from "../providers.js";
|
|
27
|
+
import { ok } from "../result.js";
|
|
28
|
+
import { RUN_LABEL } from "./runner.js";
|
|
29
|
+
/**
|
|
30
|
+
* The sweep over host: every machine listed with agentrun.computer=1 and `labels`, not in `before`, that carries a
|
|
31
|
+
* conformance run's label is deleted and read back gone; one without it is left alone and counted. A listing the
|
|
32
|
+
* vendor refused is the error, with nothing deleted.
|
|
33
|
+
*/
|
|
34
|
+
export async function sweepMachines(host, { labels = {}, before = new Set(), waitMs = 60_000, pollMs = 2_000, requestMs = 30_000, listMs = 60_000, onWords = () => { } } = {}) {
|
|
35
|
+
const listed = await hostCall(host, "the listing", (ctx) => host.list({ ...labels, [COMPUTER_LABEL]: "1" }, ctx), listMs);
|
|
36
|
+
if (!listed.ok)
|
|
37
|
+
return listed;
|
|
38
|
+
const added = listed.value.filter((machine) => !before.has(machine.id));
|
|
39
|
+
// Only a conformance run's machines: one another user of the account made during the run is not this sweep's.
|
|
40
|
+
const fresh = added.filter((machine) => Object.hasOwn(machine.labels, RUN_LABEL));
|
|
41
|
+
const leftAlone = added.length - fresh.length;
|
|
42
|
+
for (const machine of fresh) {
|
|
43
|
+
const deleted = await hostCall(host, `the delete of ${machine.id}`, (ctx) => host.delete(machine.id, ctx), requestMs);
|
|
44
|
+
if (!deleted.ok && deleted.error.code !== "not_found")
|
|
45
|
+
onWords(`${machine.id} was not deleted: ${deleted.error.message}`);
|
|
46
|
+
}
|
|
47
|
+
// Each read back on its own, at once: gone once the vendor no longer has it and its listing no longer shows it.
|
|
48
|
+
const gone = await Promise.all(fresh.map(async (machine) => {
|
|
49
|
+
const name = machine.labels[NAME_LABEL] ?? machine.id;
|
|
50
|
+
const settled = await settleGone(host, { id: machine.id, name }, { requestMs, listMs, pollMs, goneMs: waitMs });
|
|
51
|
+
if (!settled.ok)
|
|
52
|
+
onWords(`${machine.id} is still there after ${waitMs / 1000} s: ${settled.error.message}`);
|
|
53
|
+
return settled.ok;
|
|
54
|
+
}));
|
|
55
|
+
const stillThere = fresh.filter((_, i) => !gone[i]).map((machine) => machine.id);
|
|
56
|
+
return ok({ swept: fresh.length, gone: fresh.length - stillThere.length, stillThere, leftAlone });
|
|
57
|
+
}
|
|
58
|
+
const USAGE = `usage: node packages/computer/dist/conformance/sweep.js --provider <id> --before <file> | --after <file>
|
|
59
|
+
--provider <id> a provider on the shared machine-host adapter (e2b, agent37)
|
|
60
|
+
--before <file> record the id of every machine the vendor lists with ${COMPUTER_LABEL}=1 into <file>
|
|
61
|
+
--after <file> delete every machine listed with ${COMPUTER_LABEL}=1 and ${RUN_LABEL} whose id is not in <file>, read
|
|
62
|
+
each back until the vendor no longer has it (up to 60 s each), and print
|
|
63
|
+
{"swept":n,"gone":m,"stillThere":[ids],"leftAlone":k}; a new one with no ${RUN_LABEL} is left alone
|
|
64
|
+
settings: the provider's conformance module's (COMPUTER_<VENDOR>_*), never the vendor's own names
|
|
65
|
+
exit: 0 every swept machine is gone, 1 one is still there, 2 usage error, unreadable before file, no settings, or a refused listing`;
|
|
66
|
+
class Usage extends Error {
|
|
67
|
+
}
|
|
68
|
+
const write = (stream, text) => new Promise((resolve) => void stream.write(text, () => resolve()));
|
|
69
|
+
function parse(argv) {
|
|
70
|
+
let provider;
|
|
71
|
+
let found;
|
|
72
|
+
for (let i = 0; i < argv.length; i++) {
|
|
73
|
+
const [flag = "", inline] = (argv[i] ?? "").split(/=(.*)/s, 2);
|
|
74
|
+
if (flag !== "--before" && flag !== "--after" && flag !== "--provider")
|
|
75
|
+
throw new Usage(`unknown option ${flag}`);
|
|
76
|
+
const value = inline ?? argv[++i];
|
|
77
|
+
if (value === undefined || value === "" || value.startsWith("--"))
|
|
78
|
+
throw new Usage(`${flag} needs a ${flag === "--provider" ? "provider id" : "file"}`);
|
|
79
|
+
if (flag === "--provider") {
|
|
80
|
+
if (provider !== undefined)
|
|
81
|
+
throw new Usage("give --provider once");
|
|
82
|
+
provider = value;
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (found !== undefined)
|
|
86
|
+
throw new Usage("give --before <file> or --after <file>, one of them");
|
|
87
|
+
found = { mode: flag === "--before" ? "before" : "after", file: value };
|
|
88
|
+
}
|
|
89
|
+
if (provider === undefined)
|
|
90
|
+
throw new Usage("give --provider <id>");
|
|
91
|
+
if (found === undefined)
|
|
92
|
+
throw new Usage("give --before <file> or --after <file>, one of them");
|
|
93
|
+
return { provider, ...found };
|
|
94
|
+
}
|
|
95
|
+
/** The ids a before file of this provider (and of this scope, when the provider names one) holds, or why it is not one. */
|
|
96
|
+
function beforeIds(file, provider, scope) {
|
|
97
|
+
let text;
|
|
98
|
+
try {
|
|
99
|
+
text = readFileSync(file, "utf8");
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
throw new Usage(`cannot read the before file ${file}: ${error.message}`);
|
|
103
|
+
}
|
|
104
|
+
let record;
|
|
105
|
+
try {
|
|
106
|
+
record = JSON.parse(text);
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
record = undefined;
|
|
110
|
+
}
|
|
111
|
+
const { ids, provider: recorded } = (record ?? {});
|
|
112
|
+
if (!Array.isArray(ids) || !ids.every((id) => typeof id === "string" && id !== ""))
|
|
113
|
+
throw new Usage(`${file} is not a before file: it holds no "ids" array of machine ids`);
|
|
114
|
+
if (recorded !== provider)
|
|
115
|
+
throw new Usage(`${file} is the before file of ${JSON.stringify(recorded)}, not of ${provider}: sweep each provider with its own`);
|
|
116
|
+
const listed = record.scope;
|
|
117
|
+
if (scope !== undefined && listed !== scope) {
|
|
118
|
+
const words = typeof listed === "string" && listed !== "" ? `was listed in ${listed}` : "names no place it was listed in";
|
|
119
|
+
throw new Usage(`${file} ${words}, and the settings name ${scope} now: every machine there would read as new, so nothing was listed or deleted`);
|
|
120
|
+
}
|
|
121
|
+
return new Set(ids);
|
|
122
|
+
}
|
|
123
|
+
/** The provider's conformance module, for its host and scope. */
|
|
124
|
+
async function moduleOf(provider) {
|
|
125
|
+
let module;
|
|
126
|
+
try {
|
|
127
|
+
module = (await (await providerModule(provider)).conformance?.());
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
throw new Usage(error.message);
|
|
131
|
+
}
|
|
132
|
+
if (typeof module?.createHost !== "function")
|
|
133
|
+
throw new Usage(`the ${provider} provider is not on the shared machine-host adapter: it has no createHost to sweep with`);
|
|
134
|
+
return module;
|
|
135
|
+
}
|
|
136
|
+
/** Where the module's host lists, in words, read from the same settings; undefined for a provider that names none. */
|
|
137
|
+
function scopeOf(module, env) {
|
|
138
|
+
try {
|
|
139
|
+
return module.sweepScope?.({ env });
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
throw new Usage(error.message);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
export async function main(argv, io = {}) {
|
|
146
|
+
const { env = process.env, stdout = process.stdout, stderr = process.stderr, waitMs = 60_000, pollMs = 2_000 } = io;
|
|
147
|
+
let args;
|
|
148
|
+
let before;
|
|
149
|
+
let host;
|
|
150
|
+
let scope;
|
|
151
|
+
try {
|
|
152
|
+
args = parse(argv);
|
|
153
|
+
const module = io.host === undefined ? await moduleOf(args.provider) : undefined;
|
|
154
|
+
scope = io.host === undefined ? scopeOf(module, env) : io.scope;
|
|
155
|
+
if (args.mode === "after")
|
|
156
|
+
before = beforeIds(args.file, args.provider, scope);
|
|
157
|
+
host = io.host ?? (await module.createHost({ env }));
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
await write(stderr, `${error.message}\n${error instanceof Usage ? `${USAGE}\n` : ""}`);
|
|
161
|
+
return 2;
|
|
162
|
+
}
|
|
163
|
+
if (before === undefined) {
|
|
164
|
+
const listed = await hostCall(host, "the listing", (ctx) => host.list({ [COMPUTER_LABEL]: "1" }, ctx), 60_000);
|
|
165
|
+
if (!listed.ok) {
|
|
166
|
+
await write(stderr, `listing the machines carrying ${COMPUTER_LABEL}=1 failed, so nothing was recorded: ${listed.error.message}\n`);
|
|
167
|
+
return 2;
|
|
168
|
+
}
|
|
169
|
+
const ids = listed.value.map((machine) => machine.id).sort();
|
|
170
|
+
writeFileSync(args.file, `${JSON.stringify({ provider: args.provider, ...(scope === undefined ? {} : { scope }), label: `${COMPUTER_LABEL}=1`, at: new Date().toISOString(), ids }, null, 2)}\n`);
|
|
171
|
+
await write(stdout, `${JSON.stringify({ recorded: ids.length, file: args.file })}\n`);
|
|
172
|
+
return 0;
|
|
173
|
+
}
|
|
174
|
+
const said = [];
|
|
175
|
+
const swept = await sweepMachines(host, { before, waitMs, pollMs, onWords: (words) => said.push(words) });
|
|
176
|
+
for (const words of said)
|
|
177
|
+
await write(stderr, `${words}\n`);
|
|
178
|
+
if (!swept.ok) {
|
|
179
|
+
await write(stderr, `listing the machines carrying ${COMPUTER_LABEL}=1 failed, so nothing was deleted: ${swept.error.message}\n`);
|
|
180
|
+
return 2;
|
|
181
|
+
}
|
|
182
|
+
await write(stdout, `${JSON.stringify(swept.value)}\n`);
|
|
183
|
+
return swept.value.stillThere.length === 0 ? 0 : 1;
|
|
184
|
+
}
|
|
185
|
+
if (isCommand(import.meta)) {
|
|
186
|
+
process.exitCode = await main(process.argv.slice(2));
|
|
187
|
+
}
|
|
@@ -9,7 +9,7 @@ import type { KindVerdict } from "./kind.js";
|
|
|
9
9
|
/** Core: what a computer of its kind must do. Full: an optional capability, tested only where it is declared. */
|
|
10
10
|
export type Level = "core" | "full";
|
|
11
11
|
/** The suite's own grouping of its cases, the first part of each case id; not the protocol's Group. */
|
|
12
|
-
export type CaseGroup = "health" | "exec" | "files" | "process" | "provider" | "drift" | "isolation" | "mount" | "screen" | "input" | "touch" | "apps" | "lifetime" | "browser" | "gpu";
|
|
12
|
+
export type CaseGroup = "health" | "exec" | "files" | "process" | "provider" | "drift" | "isolation" | "mount" | "screen" | "input" | "touch" | "apps" | "ui" | "lifetime" | "browser" | "gpu";
|
|
13
13
|
/**
|
|
14
14
|
* What a case needs: a group (declared by both the provider's capabilities().groups and the computer's hello), a
|
|
15
15
|
* network the provider declares, the janitor as the keeper of deadlines, a spec.user the provider takes, a release that
|
|
@@ -76,8 +76,9 @@ export interface CaseContext {
|
|
|
76
76
|
/**
|
|
77
77
|
* Calls create with this whole spec, through by (default the provider), and gives its result as it is. The runner
|
|
78
78
|
* waits for it: a computer it makes is deleted when the case ends, or as it comes after that, named in cleanup.late.
|
|
79
|
+
* Each attempt is a new request (a fresh request id) unless requestId names one, as a retry of the same request does.
|
|
79
80
|
*/
|
|
80
|
-
attempt(spec: ComputerSpec, by?: ComputerProvider): Promise<Result<ComputerRef>>;
|
|
81
|
+
attempt(spec: ComputerSpec, by?: ComputerProvider, requestId?: string): Promise<Result<ComputerRef>>;
|
|
81
82
|
/** A computer the case made through another provider (the drifted one): deleted through it when the case ends. */
|
|
82
83
|
track(ref: ComputerRef, by?: ComputerProvider): void;
|
|
83
84
|
/** A further connection, to the case's computer or another; fails the case when connect refuses. */
|
|
@@ -202,13 +203,20 @@ export interface ConformanceReport {
|
|
|
202
203
|
undeclared: Capability[];
|
|
203
204
|
/**
|
|
204
205
|
* The computers of this run deleted, those still there after it, what went wrong, and the computers a provider gave
|
|
205
|
-
* after their case had ended (each deleted as it came).
|
|
206
|
+
* after their case had ended (each deleted as it came). sweep: for a provider on the shared machine-host adapter, the
|
|
207
|
+
* live sweep of the run's label at its end (conformance/sweep.ts): nothing left behind is stillThere empty.
|
|
206
208
|
*/
|
|
207
209
|
cleanup: {
|
|
208
210
|
deleted: string[];
|
|
209
211
|
left: string[];
|
|
210
212
|
errors: string[];
|
|
211
213
|
late: string[];
|
|
214
|
+
sweep?: {
|
|
215
|
+
swept: number;
|
|
216
|
+
gone: number;
|
|
217
|
+
stillThere: string[];
|
|
218
|
+
leftAlone: number;
|
|
219
|
+
};
|
|
212
220
|
};
|
|
213
221
|
/** What the provider module says of its configuration, for whoever reads the report; absent when it says nothing. */
|
|
214
222
|
notes?: string[];
|