@parcha/agentrun-computer 0.1.0-beta.58 → 0.1.0-beta.59
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 +187 -62
- package/box/Dockerfile +4 -3
- package/box/install.sh +57 -11
- package/dist/agent37.js +6 -9
- package/dist/attach.d.ts +24 -4
- package/dist/attach.js +50 -19
- package/dist/boxd.js +22 -9
- package/dist/browserbase.d.ts +6 -2
- package/dist/browserbase.js +50 -7
- 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 +10 -38
- package/dist/conformance/agent37.js +25 -113
- 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/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 +10 -0
- package/dist/descriptor.js +7 -0
- package/dist/descriptors/browserbase.d.ts +3 -0
- package/dist/descriptors/browserbase.js +4 -0
- package/dist/descriptors/docker.d.ts +1 -0
- package/dist/descriptors/docker.js +3 -0
- package/dist/descriptors/env-names.d.ts +32 -0
- package/dist/descriptors/env-names.js +60 -0
- package/dist/descriptors/index.d.ts +9 -2
- 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/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/janitor.d.ts +7 -1
- package/dist/janitor.js +2 -2
- package/dist/kernel.js +1 -1
- package/dist/local-chrome.d.ts +5 -2
- package/dist/local-chrome.js +4 -2
- 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.js +2 -4
- 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
package/dist/cloudflare.js
CHANGED
|
@@ -77,7 +77,7 @@ class CloudflareHost {
|
|
|
77
77
|
vendor: CLOUDFLARE.id,
|
|
78
78
|
fetch: options.fetch,
|
|
79
79
|
timeoutMs: 30_000,
|
|
80
|
-
retry: { attempts: 4, baseMs: 1_000 },
|
|
80
|
+
retry: { attempts: 4, baseMs: 1_000, ...(options.pause ? { pause: options.pause } : {}) },
|
|
81
81
|
// The relay's refusals are { error } in words.
|
|
82
82
|
explain: ({ status, bytes, what }) => {
|
|
83
83
|
const said = jsonOf(bytes)?.error;
|
|
@@ -161,7 +161,7 @@ export const conformance = () => import("./conformance/cloudflare.js");
|
|
|
161
161
|
export class CloudflareProvider extends HostedProvider {
|
|
162
162
|
#relay;
|
|
163
163
|
constructor(options) {
|
|
164
|
-
const { relayUrl, relayToken, fetch: fetcher = globalThis.fetch, timeouts = {}, ...rest } = options ?? {};
|
|
164
|
+
const { relayUrl, relayToken, fetch: fetcher = globalThis.fetch, pause, timeouts = {}, ...rest } = options ?? {};
|
|
165
165
|
if (typeof relayToken !== "string" || relayToken === "")
|
|
166
166
|
throw new Error("options.relayToken, the relay's RELAY_TOKEN, is required: the provider reads no environment, so the caller passes it");
|
|
167
167
|
if (typeof relayUrl !== "string" || relayUrl === "")
|
|
@@ -169,7 +169,9 @@ export class CloudflareProvider extends HostedProvider {
|
|
|
169
169
|
const base = httpsBase(relayUrl, "the Cloudflare relay URL");
|
|
170
170
|
if (typeof fetcher !== "function")
|
|
171
171
|
throw new Error("options.fetch must be a function, as the global fetch is");
|
|
172
|
-
|
|
172
|
+
if (pause !== undefined && typeof pause !== "function")
|
|
173
|
+
throw new Error("options.pause must be a function");
|
|
174
|
+
const host = new CloudflareHost({ relayUrl: base, relayToken, fetch: fetcher, ...(pause ? { pause } : {}) });
|
|
173
175
|
super(host, { ...rest, timeouts: { ...CLOUDFLARE_TIMEOUTS, ...timeouts } });
|
|
174
176
|
this.#relay = host;
|
|
175
177
|
}
|
|
Binary file
|
|
Binary file
|
package/dist/computerd.json
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { type Agent37Options, type Agent37Provider } from "../agent37.js";
|
|
2
|
-
import type
|
|
3
|
-
import type
|
|
4
|
-
|
|
5
|
-
import type { RunFolder } from "./types.js";
|
|
2
|
+
import { type ArchilMountOptions } from "./archil.js";
|
|
3
|
+
import { type Env, type HostedModuleOptions } from "./module-kit.js";
|
|
4
|
+
export { CONFORMANCE_MAX_LIFETIME_MS } from "./module-kit.js";
|
|
6
5
|
/** The Archil disk's settings for the mount cases, by name (COMPUTER_ARCHIL_*: all five, or none). */
|
|
7
6
|
export { ARCHIL_ENV } from "./archil.js";
|
|
8
|
-
/** The environment this module reads, by name, each for the option its comment names, the live switch and the run's template. */
|
|
9
7
|
export declare const AGENT37_ENV: {
|
|
10
8
|
readonly live: "AGENTRUN_COMPUTER_LIVE_AGENT37";
|
|
11
9
|
/** The template every computer of the run starts from; default agent37-base, or the box template for kind desktop. */
|
|
@@ -29,7 +27,6 @@ export declare const AGENT37_ENV: {
|
|
|
29
27
|
/** daemonUser: uid:gid the daemon runs as; default 2510:2510. */
|
|
30
28
|
readonly user: "COMPUTER_AGENT37_USER";
|
|
31
29
|
};
|
|
32
|
-
/** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
|
|
33
30
|
export declare const ENV: {
|
|
34
31
|
readonly live: "AGENTRUN_COMPUTER_LIVE_AGENT37";
|
|
35
32
|
/** The template every computer of the run starts from; default agent37-base, or the box template for kind desktop. */
|
|
@@ -57,21 +54,15 @@ export declare const ENV: {
|
|
|
57
54
|
export type Agent37Settings = Omit<Agent37Options, "ssh2" | "fetch" | "WebSocket" | "timeouts" | "probeTargets" | "proxyDomain">;
|
|
58
55
|
/**
|
|
59
56
|
* The provider's options this module reads from env, each only when its name is set; throws in words without a key,
|
|
60
|
-
* or on a value it cannot read, never echoing a key.
|
|
57
|
+
* or on a value it cannot read, never echoing a key.
|
|
61
58
|
*/
|
|
62
|
-
export declare function settingsFromEnv(env?:
|
|
63
|
-
/** The longest lifetime a computer of a run may ask for: init ends it at its deadline, the sweep deletes it. */
|
|
64
|
-
export declare const CONFORMANCE_MAX_LIFETIME_MS: number;
|
|
65
|
-
/** For the run's report: what this configuration means for the suite. */
|
|
59
|
+
export declare function settingsFromEnv(env?: Env): Agent37Settings;
|
|
66
60
|
export declare const conformanceNotes: string[];
|
|
67
|
-
export interface Agent37ModuleOptions extends Pick<Agent37Options, "ssh2" | "fetch" | "WebSocket" | "daemonPath" | "timeouts" | "onNote"
|
|
68
|
-
/** Where the settings are read; default process.env. */
|
|
69
|
-
env?: Record<string, string | undefined>;
|
|
70
|
-
/** Builds this package's daemon for linux/amd64 stamped with version, and gives its path; default go build. */
|
|
71
|
-
buildDaemon?: (version: string) => Promise<string>;
|
|
72
|
-
/** For mountFor("archil"): the disk's object API, or the SDK's Archil client, in place of the host's disk package. */
|
|
73
|
-
archil?: Pick<ArchilRunFolderOptions, "objects" | "Archil" | "baseUrl">;
|
|
61
|
+
export interface Agent37ModuleOptions extends HostedModuleOptions, Pick<Agent37Options, "ssh2" | "fetch" | "WebSocket" | "daemonPath" | "timeouts" | "onNote">, ArchilMountOptions {
|
|
74
62
|
}
|
|
63
|
+
export declare const createProvider: (options?: Agent37ModuleOptions | undefined) => Promise<Agent37Provider>, createDriftedProvider: (options?: Agent37ModuleOptions | undefined) => Promise<Agent37Provider>, createHost: (options?: Agent37ModuleOptions | undefined) => Promise<import("../host.js").MachineHost>, sweepScope: (options?: {
|
|
64
|
+
env?: Env;
|
|
65
|
+
}) => string;
|
|
75
66
|
/**
|
|
76
67
|
* The template every computer of the run starts from: COMPUTER_AGENT37_TEMPLATE, else agent37-base, else for kind
|
|
77
68
|
* desktop the box template, which the run's provider registers in the key's workspace first (prepareImage, live).
|
|
@@ -79,23 +70,4 @@ export interface Agent37ModuleOptions extends Pick<Agent37Options, "ssh2" | "fet
|
|
|
79
70
|
export declare function conformanceImage(options?: Agent37ModuleOptions, { signal }?: {
|
|
80
71
|
signal?: AbortSignal;
|
|
81
72
|
}): Promise<string>;
|
|
82
|
-
|
|
83
|
-
export declare function createProvider(options?: Agent37ModuleOptions): Promise<Agent37Provider>;
|
|
84
|
-
/** The same provider uploading a daemon that reports version <version>-drift, for the drift.version case. */
|
|
85
|
-
export declare function createDriftedProvider(options?: Agent37ModuleOptions): Promise<Agent37Provider>;
|
|
86
|
-
/**
|
|
87
|
-
* A run folder for an Archil mount, and none for any other kind (an Agent37 computer takes no bind): a fresh folder on
|
|
88
|
-
* the disk the COMPUTER_ARCHIL_* names name (archilSettings), none when they name none. Reaching it is a call to
|
|
89
|
-
* Archil, so it needs the live switch.
|
|
90
|
-
*/
|
|
91
|
-
export declare function mountFor(kind: MountKind, { env, archil }?: Agent37ModuleOptions): Promise<RunFolder | undefined>;
|
|
92
|
-
/**
|
|
93
|
-
* The Agent37 host the live sweep (sweep.ts) lists and deletes through, from the same settings; it needs no live
|
|
94
|
-
* switch, since the sweep makes nothing, and it calls nothing until the sweep does.
|
|
95
|
-
*/
|
|
96
|
-
export declare function createHost(options?: Pick<Agent37ModuleOptions, "env" | "ssh2" | "fetch" | "WebSocket">): Promise<MachineHost>;
|
|
97
|
-
/**
|
|
98
|
-
* Where the host lists, in words: one key is one workspace, and one listing covers all of it, every region and type
|
|
99
|
-
* (docs: instances/list). The key is named by its sha256 prefix alone, so a before file of another key is refused.
|
|
100
|
-
*/
|
|
101
|
-
export declare function sweepScope({ env }?: Pick<Agent37ModuleOptions, "env">): string;
|
|
73
|
+
export declare const mountFor: (kind: import("../mount.js").MountKind, options?: ArchilMountOptions) => Promise<import("./types.js").RunFolder | undefined>;
|
|
@@ -1,31 +1,16 @@
|
|
|
1
1
|
// Agent37 for the conformance CLI: `npm run conformance -w @parcha/agentrun-computer -- --provider agent37`.
|
|
2
2
|
// It makes real instances, which bill per minute until deleted, so it runs only with AGENTRUN_COMPUTER_LIVE_AGENT37=1
|
|
3
|
-
// and a key for an account you can bill, under COMPUTER_AGENT37_API_KEY
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
// --provider agent37) reads the same names through createHost, which needs no live switch: it makes nothing.
|
|
8
|
-
//
|
|
9
|
-
// The daemon is uploaded into each instance over SSH (dist/computerd-linux-amd64, `npm run build:daemon`), so a run
|
|
10
|
-
// publishes nothing. The drifted provider uploads a daemon built with Go as version <version>-drift. Agent37 never
|
|
11
|
-
// ends an instance on its own: every computer of a run lives at most 30 minutes, by init's deadline and the janitor's
|
|
12
|
-
// label, and the run's sweep deletes what is left.
|
|
13
|
-
//
|
|
14
|
-
// COMPUTER_AGENT37_KIND=desktop runs the desktop's cases (screen, input) on the box template, agentrun-box-<recipe
|
|
15
|
-
// hash>, which the run registers in the key's workspace first through the provider's prepareImage() (from the public
|
|
16
|
-
// image the release publishes), or on another with an X server named in COMPUTER_AGENT37_TEMPLATE.
|
|
17
|
-
//
|
|
18
|
-
// For the mount cases, mountFor("archil") makes a fresh run folder on the Archil disk COMPUTER_ARCHIL_DISK names, as
|
|
19
|
-
// the E2B module does (./archil.ts); with no disk named it makes none, and the cases are skipped. An Archil computer
|
|
20
|
-
// needs a provider whose daemon user is the tool user: COMPUTER_AGENT37_USER=2510:2510, the default.
|
|
3
|
+
// and a key for an account you can bill, under COMPUTER_AGENT37_API_KEY (never AGENT37_API_KEY, which may hold another
|
|
4
|
+
// team's key). Agent37 never ends an instance on its own: every computer of a run lives at most 30 minutes, by init's
|
|
5
|
+
// deadline and the janitor's label, and the run's sweep deletes what is left. An Archil computer (mountFor("archil"),
|
|
6
|
+
// ./archil.ts) needs a provider whose daemon user is the tool user: COMPUTER_AGENT37_USER=2510:2510, the default.
|
|
21
7
|
import { create, workspaceOf } from "../agent37.js";
|
|
22
8
|
import { AGENT37_BASE_TEMPLATE } from "../descriptors/agent37.js";
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
|
|
9
|
+
import { archilMountFor } from "./archil.js";
|
|
10
|
+
import { hostedModule, kindFrom, lifetimeFromEnv, preparedImage, requiredSecret, setOptions } from "./module-kit.js";
|
|
11
|
+
export { CONFORMANCE_MAX_LIFETIME_MS } from "./module-kit.js";
|
|
26
12
|
/** The Archil disk's settings for the mount cases, by name (COMPUTER_ARCHIL_*: all five, or none). */
|
|
27
13
|
export { ARCHIL_ENV } from "./archil.js";
|
|
28
|
-
/** The environment this module reads, by name, each for the option its comment names, the live switch and the run's template. */
|
|
29
14
|
export const AGENT37_ENV = {
|
|
30
15
|
live: "AGENTRUN_COMPUTER_LIVE_AGENT37",
|
|
31
16
|
/** The template every computer of the run starts from; default agent37-base, or the box template for kind desktop. */
|
|
@@ -49,51 +34,34 @@ export const AGENT37_ENV = {
|
|
|
49
34
|
/** daemonUser: uid:gid the daemon runs as; default 2510:2510. */
|
|
50
35
|
user: "COMPUTER_AGENT37_USER",
|
|
51
36
|
};
|
|
52
|
-
/** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
|
|
53
37
|
export const ENV = AGENT37_ENV;
|
|
54
38
|
/**
|
|
55
39
|
* The provider's options this module reads from env, each only when its name is set; throws in words without a key,
|
|
56
|
-
* or on a value it cannot read, never echoing a key.
|
|
40
|
+
* or on a value it cannot read, never echoing a key.
|
|
57
41
|
*/
|
|
58
42
|
export function settingsFromEnv(env = process.env) {
|
|
59
|
-
const apiKey = env
|
|
60
|
-
if (apiKey === undefined || apiKey === "")
|
|
61
|
-
throw new Error(`set ${AGENT37_ENV.key} to an Agent37 API key: the conformance module reads it there and nowhere else, never from AGENT37_API_KEY`);
|
|
43
|
+
const apiKey = requiredSecret(env, AGENT37_ENV.key, "an Agent37 API key");
|
|
62
44
|
const sshKey = env[AGENT37_ENV.sshKey];
|
|
63
45
|
if (sshKey === undefined || sshKey === "")
|
|
64
46
|
throw new Error(`set ${AGENT37_ENV.sshKey} to the private SSH key registered on the Agent37 workspace (its contents, never a path)`);
|
|
65
|
-
const lifetime = env
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const type = env[AGENT37_ENV.type] || undefined;
|
|
69
|
-
const region = env[AGENT37_ENV.region] || undefined;
|
|
70
|
-
const apiUrl = env[AGENT37_ENV.apiUrl] || undefined;
|
|
71
|
-
const daemonPath = env[AGENT37_ENV.daemon] || undefined;
|
|
72
|
-
const daemonUser = env[AGENT37_ENV.user] || undefined;
|
|
73
|
-
return {
|
|
74
|
-
apiKey,
|
|
75
|
-
sshKey,
|
|
76
|
-
// create() refuses any other type or region in words.
|
|
77
|
-
...(type === undefined ? {} : { type: type }),
|
|
78
|
-
...(region === undefined ? {} : { region: region }),
|
|
79
|
-
...kindFrom(env, AGENT37_ENV.kind),
|
|
80
|
-
...(apiUrl === undefined ? {} : { apiUrl }),
|
|
81
|
-
...(daemonPath === undefined ? {} : { daemonPath }),
|
|
82
|
-
...(lifetime === undefined ? {} : { maxLifetimeMs: Number(lifetime) }),
|
|
83
|
-
...(daemonUser === undefined ? {} : { daemonUser }),
|
|
84
|
-
};
|
|
47
|
+
const lifetime = lifetimeFromEnv(env, AGENT37_ENV.maxLifetimeMs, "86400000");
|
|
48
|
+
const set = setOptions(env, { type: AGENT37_ENV.type, region: AGENT37_ENV.region, apiUrl: AGENT37_ENV.apiUrl, daemonPath: AGENT37_ENV.daemon, daemonUser: AGENT37_ENV.user });
|
|
49
|
+
return { apiKey, sshKey, ...set, ...kindFrom(env, AGENT37_ENV.kind), ...lifetime };
|
|
85
50
|
}
|
|
86
|
-
/** The longest lifetime a computer of a run may ask for: init ends it at its deadline, the sweep deletes it. */
|
|
87
|
-
export const CONFORMANCE_MAX_LIFETIME_MS = 30 * 60_000;
|
|
88
|
-
/** For the run's report: what this configuration means for the suite. */
|
|
89
51
|
export const conformanceNotes = [
|
|
90
52
|
"agent37: every computer is an instance (type vm by default), made with network deny-all, auto-sleep off and no public port, read back from Agent37 and probed from inside; the daemon is a child, started over SSH through the platform's sshd (port 22022; it and the platform's web terminal on 7681 are declared as the vendor's agent), and every command goes over that SSH as root. Agent37 never ends an instance on its own: lifetime janitor, capped at 30 minutes for the run. No stream() (a screen is streamed through agentrun), so screen.stream is skipped. Kind desktop (COMPUTER_AGENT37_KIND=desktop) starts from agentrun-box-<recipe hash>, our box image registered as a template of the key's workspace (prepareImage), with Xvfb on :0 started through the daemon as the tool user.",
|
|
91
53
|
];
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
54
|
+
const agent37 = hostedModule({
|
|
55
|
+
live: { name: AGENT37_ENV.live, what: "the Agent37 conformance module makes real instances, which bill until deleted", whose: "a key for an account you can bill" },
|
|
56
|
+
settingsFromEnv,
|
|
57
|
+
create,
|
|
58
|
+
host: ["ssh2", "fetch", "WebSocket", "timeouts", "onNote"],
|
|
59
|
+
run: [],
|
|
60
|
+
runDefined: ["daemonPath"],
|
|
61
|
+
// One key is one workspace, and one listing covers all of it, every region and type (docs: instances/list).
|
|
62
|
+
scope: ({ apiKey, apiUrl }) => workspaceOf(apiKey, apiUrl),
|
|
63
|
+
});
|
|
64
|
+
export const { createProvider, createDriftedProvider, createHost, sweepScope } = agent37;
|
|
97
65
|
/**
|
|
98
66
|
* The template every computer of the run starts from: COMPUTER_AGENT37_TEMPLATE, else agent37-base, else for kind
|
|
99
67
|
* desktop the box template, which the run's provider registers in the key's workspace first (prepareImage, live).
|
|
@@ -105,62 +73,6 @@ export async function conformanceImage(options = {}, { signal } = {}) {
|
|
|
105
73
|
return named;
|
|
106
74
|
if (env[AGENT37_ENV.kind] !== "desktop")
|
|
107
75
|
return AGENT37_BASE_TEMPLATE;
|
|
108
|
-
|
|
109
|
-
if (!ready.ok)
|
|
110
|
-
throw new Error(`the Agent37 box template: ${ready.error.message}`);
|
|
111
|
-
return ready.value;
|
|
112
|
-
}
|
|
113
|
-
/** The test doubles a caller hands in, each only when given. */
|
|
114
|
-
const doubles = ({ ssh2, fetch, WebSocket, timeouts, onNote }) => ({
|
|
115
|
-
...(ssh2 ? { ssh2 } : {}),
|
|
116
|
-
...(fetch ? { fetch } : {}),
|
|
117
|
-
...(WebSocket ? { WebSocket } : {}),
|
|
118
|
-
...(timeouts ? { timeouts } : {}),
|
|
119
|
-
...(onNote ? { onNote } : {}),
|
|
120
|
-
});
|
|
121
|
-
/** A run's cap: COMPUTER_AGENT37_MAX_LIFETIME_MS when it is shorter, else CONFORMANCE_MAX_LIFETIME_MS. */
|
|
122
|
-
const runCap = (settings) => Math.min(settings.maxLifetimeMs ?? CONFORMANCE_MAX_LIFETIME_MS, CONFORMANCE_MAX_LIFETIME_MS);
|
|
123
|
-
/** The provider the CLI runs; throws in words without the live switch, or when a setting is missing or wrong. */
|
|
124
|
-
export async function createProvider(options = {}) {
|
|
125
|
-
const { env = process.env, daemonPath } = options;
|
|
126
|
-
live(env);
|
|
127
|
-
const settings = settingsFromEnv(env);
|
|
128
|
-
return create({ ...settings, ...doubles(options), ...(daemonPath === undefined ? {} : { daemonPath }), maxLifetimeMs: runCap(settings) });
|
|
129
|
-
}
|
|
130
|
-
/** The same provider uploading a daemon that reports version <version>-drift, for the drift.version case. */
|
|
131
|
-
export async function createDriftedProvider(options = {}) {
|
|
132
|
-
const { env = process.env, buildDaemon = (version) => buildDriftDaemon("amd64", version) } = options;
|
|
133
|
-
live(env);
|
|
134
|
-
const settings = settingsFromEnv(env);
|
|
135
|
-
const daemonPath = await buildDaemon(DRIFT_VERSION);
|
|
136
|
-
return create({ ...settings, ...doubles(options), daemonPath, maxLifetimeMs: runCap(settings) });
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* A run folder for an Archil mount, and none for any other kind (an Agent37 computer takes no bind): a fresh folder on
|
|
140
|
-
* the disk the COMPUTER_ARCHIL_* names name (archilSettings), none when they name none. Reaching it is a call to
|
|
141
|
-
* Archil, so it needs the live switch.
|
|
142
|
-
*/
|
|
143
|
-
export async function mountFor(kind, { env = process.env, archil = {} } = {}) {
|
|
144
|
-
if (kind !== "archil")
|
|
145
|
-
return undefined;
|
|
146
|
-
const settings = archilSettings(env);
|
|
147
|
-
if (settings === undefined)
|
|
148
|
-
return undefined;
|
|
149
|
-
live(env);
|
|
150
|
-
return archilRunFolder({ ...settings, ...archil });
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* The Agent37 host the live sweep (sweep.ts) lists and deletes through, from the same settings; it needs no live
|
|
154
|
-
* switch, since the sweep makes nothing, and it calls nothing until the sweep does.
|
|
155
|
-
*/
|
|
156
|
-
export async function createHost(options = {}) {
|
|
157
|
-
return (await create({ ...settingsFromEnv(options.env ?? process.env), ...doubles(options) })).host;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Where the host lists, in words: one key is one workspace, and one listing covers all of it, every region and type
|
|
161
|
-
* (docs: instances/list). The key is named by its sha256 prefix alone, so a before file of another key is refused.
|
|
162
|
-
*/
|
|
163
|
-
export function sweepScope({ env = process.env } = {}) {
|
|
164
|
-
const { apiKey, apiUrl } = settingsFromEnv(env);
|
|
165
|
-
return workspaceOf(apiKey, apiUrl);
|
|
76
|
+
return preparedImage(await createProvider(options), signal, "the Agent37 box template");
|
|
166
77
|
}
|
|
78
|
+
export const mountFor = archilMountFor(agent37.live);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { MountKind } from "../mount.js";
|
|
1
2
|
import type { RunFolder } from "./types.js";
|
|
2
3
|
/** The settings of the Archil mount cases, by the names a conformance module reads them from. */
|
|
3
4
|
export declare const ARCHIL_ENV: {
|
|
@@ -48,10 +49,8 @@ export interface ArchilRunFolderOptions {
|
|
|
48
49
|
s3BaseUrl?: string;
|
|
49
50
|
/** Another control plane than the region's, for the SDK's client. */
|
|
50
51
|
baseUrl?: string;
|
|
51
|
-
/** The SDK's Archil client; default the
|
|
52
|
+
/** The SDK's Archil client; default the `disk` package's. */
|
|
52
53
|
Archil?: ArchilConstructor;
|
|
53
|
-
/** For tests: the package the SDK's client is imported from; default `disk`. */
|
|
54
|
-
sdkPackage?: string;
|
|
55
54
|
}
|
|
56
55
|
/**
|
|
57
56
|
* The Archil mount cases' settings from the COMPUTER_ARCHIL_* names (ARCHIL_ENV); undefined when none is set. Some set
|
|
@@ -66,3 +65,14 @@ export declare function archilSettings(env: Record<string, string | undefined>):
|
|
|
66
65
|
* the case read back), and the folder's other keys are the disk's to keep.
|
|
67
66
|
*/
|
|
68
67
|
export declare function archilRunFolder(options: ArchilRunFolderOptions): Promise<RunFolder>;
|
|
68
|
+
/** What a module's mountFor takes: where the settings are read, and the object API or client in place of the SDK's. */
|
|
69
|
+
export interface ArchilMountOptions {
|
|
70
|
+
env?: Record<string, string | undefined>;
|
|
71
|
+
/** For mountFor("archil"): the disk's object API, or the SDK's Archil client, in place of the `disk` package's. */
|
|
72
|
+
archil?: Pick<ArchilRunFolderOptions, "objects" | "Archil" | "baseUrl">;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* A module's mountFor: a fresh run folder for an Archil mount on the disk the COMPUTER_ARCHIL_* names name, none for any
|
|
76
|
+
* other kind or when they name none. Reaching it is a call to Archil, so it needs the module's live switch.
|
|
77
|
+
*/
|
|
78
|
+
export declare function archilMountFor(live: (env: Record<string, string | undefined>) => void): (kind: MountKind, options?: ArchilMountOptions) => Promise<RunFolder | undefined>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
// The Archil run folder for the mount cases, shared by every remote provider's conformance module
|
|
2
|
-
//
|
|
3
|
-
// and its outside, read and written through the disk's object API. The object API is given, or
|
|
4
|
-
//
|
|
1
|
+
// The Archil run folder for the mount cases, shared by every remote provider's conformance module: a fresh
|
|
2
|
+
// agents/<agent>/runs/<run>/work on the owner's disk, the mount that reaches it from inside a computer,
|
|
3
|
+
// and its outside, read and written through the disk's object API. The object API is given, or Archil's Node SDK (the
|
|
4
|
+
// npm package `disk`, an optional dependency of this package, loaded only here and only when asked): `new Archil({
|
|
5
5
|
// apiKey, region, s3BaseUrl })`, then `disks.get(disk)`, whose disk has getObject, putObject and deleteObject with keys
|
|
6
6
|
// relative to the disk's root, and rejects with the HTTP `status` when there was an answer (404: not there). Every
|
|
7
7
|
// setting is passed to the SDK, so it reads none of its own from the environment.
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
// module reads them from the COMPUTER_ARCHIL_* names ARCHIL_ENV lists (archilSettings).
|
|
12
12
|
import { randomBytes } from "node:crypto";
|
|
13
13
|
import { ARCHIL_REGION } from "../mount-archil.js";
|
|
14
|
+
import { vendorSdk } from "../vendor-sdk.js";
|
|
14
15
|
/** The settings of the Archil mount cases, by the names a conformance module reads them from. */
|
|
15
16
|
export const ARCHIL_ENV = {
|
|
16
17
|
/** The disk the run folders are made on: dsk-<16 hex digits>, or owner/name. */
|
|
@@ -24,8 +25,6 @@ export const ARCHIL_ENV = {
|
|
|
24
25
|
/** The disk's S3-compatible endpoint, https on an Archil host of the region: the key goes to it. */
|
|
25
26
|
archilS3Url: "COMPUTER_ARCHIL_S3_URL",
|
|
26
27
|
};
|
|
27
|
-
/** Not a literal, so no type checker or bundler resolves the SDK from this package. */
|
|
28
|
-
const ARCHIL_PACKAGE = "disk";
|
|
29
28
|
// The shapes the root helper takes (box/agentrun-archil), so a run folder is one a computer can mount.
|
|
30
29
|
const DISK = /^(?:dsk-[0-9a-f]{16}|[A-Za-z0-9][A-Za-z0-9._@+-]{0,127}\/[A-Za-z0-9][A-Za-z0-9._-]{0,127})$/;
|
|
31
30
|
const REGION = new RegExp(`^${ARCHIL_REGION}$`);
|
|
@@ -79,19 +78,10 @@ function failure(what, error, apiKey) {
|
|
|
79
78
|
return Object.assign(new Error(`${what}: ${message}`), typeof status === "number" ? { status } : {});
|
|
80
79
|
}
|
|
81
80
|
/** The disk's object API from the SDK's client: every setting given, the disk looked up once. */
|
|
82
|
-
async function sdkObjects({ disk, region, apiKey, s3BaseUrl, baseUrl, Archil
|
|
81
|
+
async function sdkObjects({ disk, region, apiKey, s3BaseUrl, baseUrl, Archil }) {
|
|
83
82
|
if (!apiKey || !s3BaseUrl)
|
|
84
83
|
throw new Error(`the Archil run folder reaches its disk through the object API: give objects, or apiKey and s3BaseUrl (${ARCHIL_ENV.archilKey}, ${ARCHIL_ENV.archilS3Url})`);
|
|
85
|
-
|
|
86
|
-
if (Client === undefined) {
|
|
87
|
-
try {
|
|
88
|
-
Client = (await import(sdkPackage)).Archil;
|
|
89
|
-
}
|
|
90
|
-
catch (error) {
|
|
91
|
-
const why = (error instanceof Error ? error.message : String(error)).replaceAll(apiKey, "[key]").slice(0, 200);
|
|
92
|
-
throw new Error(`the Archil run folder needs Archil's Node SDK, the package ${JSON.stringify(sdkPackage)}: it is serve's dependency, pinned in the lockfile, so npm ci at the repository root installs it (${why})`);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
84
|
+
const Client = Archil ?? (await vendorSdk("Archil", "disk")).Archil;
|
|
95
85
|
try {
|
|
96
86
|
return await new Client({ apiKey, region, s3BaseUrl, ...(baseUrl === undefined ? {} : { baseUrl }) }).disks.get(disk);
|
|
97
87
|
}
|
|
@@ -150,3 +140,18 @@ export async function archilRunFolder(options) {
|
|
|
150
140
|
},
|
|
151
141
|
};
|
|
152
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* A module's mountFor: a fresh run folder for an Archil mount on the disk the COMPUTER_ARCHIL_* names name, none for any
|
|
145
|
+
* other kind or when they name none. Reaching it is a call to Archil, so it needs the module's live switch.
|
|
146
|
+
*/
|
|
147
|
+
export function archilMountFor(live) {
|
|
148
|
+
return async (kind, { env = process.env, archil = {} } = {}) => {
|
|
149
|
+
if (kind !== "archil")
|
|
150
|
+
return undefined;
|
|
151
|
+
const settings = archilSettings(env);
|
|
152
|
+
if (settings === undefined)
|
|
153
|
+
return undefined;
|
|
154
|
+
live(env);
|
|
155
|
+
return archilRunFolder({ ...settings, ...archil });
|
|
156
|
+
};
|
|
157
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type BoxdOptions, type BoxdProvider } from "../boxd.js";
|
|
2
|
-
import type
|
|
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 BOXD_ENV: {
|
|
5
5
|
readonly live: "AGENTRUN_COMPUTER_LIVE_BOXD";
|
|
6
6
|
/** The image every computer of the run starts from: "default" (boxd's own), or a snapshot's name; unset, a desktop's is the desktop snapshot. */
|
|
@@ -18,7 +18,6 @@ export declare const BOXD_ENV: {
|
|
|
18
18
|
/** daemonUser: uid:gid the daemon runs as; default 2510:2510. */
|
|
19
19
|
readonly user: "COMPUTER_BOXD_USER";
|
|
20
20
|
};
|
|
21
|
-
/** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
|
|
22
21
|
export declare const ENV: {
|
|
23
22
|
readonly live: "AGENTRUN_COMPUTER_LIVE_BOXD";
|
|
24
23
|
/** The image every computer of the run starts from: "default" (boxd's own), or a snapshot's name; unset, a desktop's is the desktop snapshot. */
|
|
@@ -38,21 +37,14 @@ export declare const ENV: {
|
|
|
38
37
|
};
|
|
39
38
|
/** What this module reads from the environment: the key, and each other option whose name is set. */
|
|
40
39
|
export type BoxdSettings = Pick<BoxdOptions, "apiKey" | "org" | "region" | "daemonPath" | "kind" | "daemonUser">;
|
|
41
|
-
/**
|
|
42
|
-
|
|
43
|
-
* never echoing it. create() checks the rest.
|
|
44
|
-
*/
|
|
45
|
-
export declare function settingsFromEnv(env?: Record<string, string | undefined>): BoxdSettings;
|
|
46
|
-
/** The longest lifetime a computer of a run may ask for. */
|
|
47
|
-
export declare const CONFORMANCE_MAX_LIFETIME_MS: number;
|
|
48
|
-
/** For the run's report: what this configuration means for the suite. */
|
|
40
|
+
/** The provider's options this module reads from env, each only when its name is set; throws in words without the key, never echoing it. */
|
|
41
|
+
export declare function settingsFromEnv(env?: Env): BoxdSettings;
|
|
49
42
|
export declare const conformanceNotes: string[];
|
|
50
|
-
export interface BoxdModuleOptions extends Pick<BoxdOptions, "Boxd" | "daemonPath" | "timeouts"> {
|
|
51
|
-
/** Where the settings are read; default process.env. */
|
|
52
|
-
env?: Record<string, string | undefined>;
|
|
53
|
-
/** Builds this package's daemon for linux/amd64 stamped with version, and gives its path; default go build. */
|
|
54
|
-
buildDaemon?: (version: string) => Promise<string>;
|
|
43
|
+
export interface BoxdModuleOptions extends HostedModuleOptions, Pick<BoxdOptions, "Boxd" | "daemonPath" | "timeouts" | "onNote"> {
|
|
55
44
|
}
|
|
45
|
+
export declare const createProvider: (options?: BoxdModuleOptions | undefined) => Promise<BoxdProvider>, createDriftedProvider: (options?: BoxdModuleOptions | undefined) => Promise<BoxdProvider>, createHost: (options?: BoxdModuleOptions | undefined) => Promise<import("../host.js").MachineHost>, sweepScope: (options?: {
|
|
46
|
+
env?: Env;
|
|
47
|
+
}) => string;
|
|
56
48
|
/**
|
|
57
49
|
* The image every computer of the run starts from: COMPUTER_BOXD_IMAGE, else boxd's own, else for kind desktop the
|
|
58
50
|
* desktop snapshot, which the run's provider finds or builds in the key's org first (prepareImage, live).
|
|
@@ -60,18 +52,3 @@ export interface BoxdModuleOptions extends Pick<BoxdOptions, "Boxd" | "daemonPat
|
|
|
60
52
|
export declare function conformanceImage(options?: BoxdModuleOptions, { signal }?: {
|
|
61
53
|
signal?: AbortSignal;
|
|
62
54
|
}): Promise<string>;
|
|
63
|
-
/** The provider the CLI runs; throws in words without the live switch, or when a setting is missing or wrong. */
|
|
64
|
-
export declare function createProvider({ env, Boxd, daemonPath, timeouts }?: BoxdModuleOptions): Promise<BoxdProvider>;
|
|
65
|
-
/**
|
|
66
|
-
* The boxd host the live sweep (sweep.ts) lists and deletes through, from the same settings; it needs no live switch,
|
|
67
|
-
* since the sweep makes nothing, and it calls nothing until the sweep does.
|
|
68
|
-
*/
|
|
69
|
-
export declare function createHost({ env, Boxd }?: Pick<BoxdModuleOptions, "env" | "Boxd">): Promise<MachineHost>;
|
|
70
|
-
/**
|
|
71
|
-
* Where the sweep lists, in words: the org and region the settings name, under the key named by its sha256 prefix alone.
|
|
72
|
-
* A before file listed with another key, org or region would make every computer there read as new, so the sweep
|
|
73
|
-
* refuses it.
|
|
74
|
-
*/
|
|
75
|
-
export declare function sweepScope({ env }?: Pick<BoxdModuleOptions, "env">): string;
|
|
76
|
-
/** The same provider uploading a daemon that reports version <version>-drift, for the drift.version case. */
|
|
77
|
-
export declare function createDriftedProvider({ env, Boxd, timeouts, buildDaemon }?: BoxdModuleOptions): Promise<BoxdProvider>;
|
package/dist/conformance/boxd.js
CHANGED
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
// boxd for the conformance CLI: `npm run conformance -w @parcha/agentrun-computer -- --provider boxd [--image <snapshot>]`.
|
|
2
2
|
// It makes real machines, so it runs only with AGENTRUN_COMPUTER_LIVE_BOXD=1 and your own key, under
|
|
3
|
-
// COMPUTER_BOXD_API_KEY
|
|
4
|
-
//
|
|
5
|
-
// checked first, before any other setting is read. The live sweep (sweep.ts, --provider boxd) reads the same names
|
|
6
|
-
// through createHost, which needs no live switch: it makes nothing; sweepScope names the key, org and region a before
|
|
7
|
-
// file must have been listed from.
|
|
8
|
-
//
|
|
9
|
-
// The daemon is uploaded into each machine (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 has
|
|
11
|
-
// a deadline of at most 30 minutes, and the runner sweeps the run's computers by its label when it ends.
|
|
12
|
-
import { createHash } from "node:crypto";
|
|
13
|
-
import { BOXD_DEFAULT_IMAGE } from "../descriptors/boxd.js";
|
|
3
|
+
// COMPUTER_BOXD_API_KEY (never BOXD_API_KEY, which may hold another account's key). Every computer of a run has a
|
|
4
|
+
// deadline of at most 30 minutes, and the runner sweeps the run's computers by its label when it ends.
|
|
14
5
|
import { create } from "../boxd.js";
|
|
15
|
-
import {
|
|
16
|
-
import { kindFrom } from "./
|
|
17
|
-
|
|
6
|
+
import { BOXD_DEFAULT_IMAGE } from "../descriptors/boxd.js";
|
|
7
|
+
import { hostedModule, keyPrint, kindFrom, preparedImage, requiredSecret, setOptions } from "./module-kit.js";
|
|
8
|
+
export { CONFORMANCE_MAX_LIFETIME_MS } from "./module-kit.js";
|
|
18
9
|
export const BOXD_ENV = {
|
|
19
10
|
live: "AGENTRUN_COMPUTER_LIVE_BOXD",
|
|
20
11
|
/** The image every computer of the run starts from: "default" (boxd's own), or a snapshot's name; unset, a desktop's is the desktop snapshot. */
|
|
@@ -32,39 +23,25 @@ export const BOXD_ENV = {
|
|
|
32
23
|
/** daemonUser: uid:gid the daemon runs as; default 2510:2510. */
|
|
33
24
|
user: "COMPUTER_BOXD_USER",
|
|
34
25
|
};
|
|
35
|
-
/** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
|
|
36
26
|
export const ENV = BOXD_ENV;
|
|
37
|
-
/**
|
|
38
|
-
* The provider's options this module reads from env, each only when its name is set; throws in words without the key,
|
|
39
|
-
* never echoing it. create() checks the rest.
|
|
40
|
-
*/
|
|
27
|
+
/** The provider's options this module reads from env, each only when its name is set; throws in words without the key, never echoing it. */
|
|
41
28
|
export function settingsFromEnv(env = process.env) {
|
|
42
|
-
const apiKey = env
|
|
43
|
-
|
|
44
|
-
throw new Error(`set ${BOXD_ENV.key} to a boxd API key: the conformance module reads it there and nowhere else, never from BOXD_API_KEY`);
|
|
45
|
-
const org = env[BOXD_ENV.org] || undefined;
|
|
46
|
-
const region = env[BOXD_ENV.region] || undefined;
|
|
47
|
-
const daemonPath = env[BOXD_ENV.daemon] || undefined;
|
|
48
|
-
const daemonUser = env[BOXD_ENV.user] || undefined;
|
|
49
|
-
return {
|
|
50
|
-
apiKey,
|
|
51
|
-
...(org === undefined ? {} : { org }),
|
|
52
|
-
...(region === undefined ? {} : { region }),
|
|
53
|
-
...(daemonPath === undefined ? {} : { daemonPath }),
|
|
54
|
-
...kindFrom(env, BOXD_ENV.kind),
|
|
55
|
-
...(daemonUser === undefined ? {} : { daemonUser }),
|
|
56
|
-
};
|
|
29
|
+
const apiKey = requiredSecret(env, BOXD_ENV.key, "a boxd API key");
|
|
30
|
+
return { apiKey, ...setOptions(env, { org: BOXD_ENV.org, region: BOXD_ENV.region, daemonPath: BOXD_ENV.daemon, daemonUser: BOXD_ENV.user }), ...kindFrom(env, BOXD_ENV.kind) };
|
|
57
31
|
}
|
|
58
|
-
/** The longest lifetime a computer of a run may ask for. */
|
|
59
|
-
export const CONFORMANCE_MAX_LIFETIME_MS = 30 * 60_000;
|
|
60
|
-
/** For the run's report: what this configuration means for the suite. */
|
|
61
32
|
export const conformanceNotes = [
|
|
62
33
|
"boxd: every computer is an isolated boxd machine with the egress allowlist none, no standby and no hibernation; the daemon is a child of boxd's own agent, started as a detached root command; lifetime is the janitor's, by the deadline label, capped at 30 minutes for the run; no stream() (a screen is streamed through agentrun), so screen.stream is skipped. Kind desktop (COMPUTER_BOXD_KIND=desktop) starts from agentrun-desktop-<recipe hash>, boxd's own image with Xfce's text editor added, a snapshot the run's provider finds or builds in the key's org first (prepareImage), with Xvfb on :0 started through the daemon as the tool user.",
|
|
63
34
|
];
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
35
|
+
export const { createProvider, createDriftedProvider, createHost, sweepScope } = hostedModule({
|
|
36
|
+
live: { name: BOXD_ENV.live, what: "the boxd conformance module makes real machines", whose: "your own key" },
|
|
37
|
+
settingsFromEnv,
|
|
38
|
+
create,
|
|
39
|
+
host: ["Boxd"],
|
|
40
|
+
run: ["timeouts", "onNote"],
|
|
41
|
+
runDefined: ["daemonPath"],
|
|
42
|
+
// A before file listed with another key, org or region would make every computer there read as new, so the sweep refuses it.
|
|
43
|
+
scope: ({ apiKey, org, region }) => `the boxd org ${org ?? "of the key"} in the region ${region ?? "home"}, with the key ${keyPrint(apiKey)}`,
|
|
44
|
+
});
|
|
68
45
|
/**
|
|
69
46
|
* The image every computer of the run starts from: COMPUTER_BOXD_IMAGE, else boxd's own, else for kind desktop the
|
|
70
47
|
* desktop snapshot, which the run's provider finds or builds in the key's org first (prepareImage, live).
|
|
@@ -76,37 +53,5 @@ export async function conformanceImage(options = {}, { signal } = {}) {
|
|
|
76
53
|
return named;
|
|
77
54
|
if (env[BOXD_ENV.kind] !== "desktop")
|
|
78
55
|
return BOXD_DEFAULT_IMAGE;
|
|
79
|
-
|
|
80
|
-
if (!ready.ok)
|
|
81
|
-
throw new Error(ready.error.message);
|
|
82
|
-
return ready.value;
|
|
83
|
-
}
|
|
84
|
-
/** The provider the CLI runs; throws in words without the live switch, or when a setting is missing or wrong. */
|
|
85
|
-
export async function createProvider({ env = process.env, Boxd, daemonPath, timeouts } = {}) {
|
|
86
|
-
live(env);
|
|
87
|
-
return create({ ...settingsFromEnv(env), ...(Boxd ? { Boxd } : {}), ...(daemonPath === undefined ? {} : { daemonPath }), ...(timeouts ? { timeouts } : {}), maxLifetimeMs: CONFORMANCE_MAX_LIFETIME_MS });
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* The boxd host the live sweep (sweep.ts) lists and deletes through, from the same settings; it needs no live switch,
|
|
91
|
-
* since the sweep makes nothing, and it calls nothing until the sweep does.
|
|
92
|
-
*/
|
|
93
|
-
export async function createHost({ env = process.env, Boxd } = {}) {
|
|
94
|
-
return (await create({ ...settingsFromEnv(env), ...(Boxd ? { Boxd } : {}) })).host;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Where the sweep lists, in words: the org and region the settings name, under the key named by its sha256 prefix alone.
|
|
98
|
-
* A before file listed with another key, org or region would make every computer there read as new, so the sweep
|
|
99
|
-
* refuses it.
|
|
100
|
-
*/
|
|
101
|
-
export function sweepScope({ env = process.env } = {}) {
|
|
102
|
-
const { apiKey, org, region } = settingsFromEnv(env);
|
|
103
|
-
const key = createHash("sha256").update(apiKey, "utf8").digest("hex").slice(0, 12);
|
|
104
|
-
return `the boxd org ${org ?? "of the key"} in the region ${region ?? "home"}, with the key sha256:${key}`;
|
|
105
|
-
}
|
|
106
|
-
/** The same provider uploading a daemon that reports version <version>-drift, for the drift.version case. */
|
|
107
|
-
export async function createDriftedProvider({ env = process.env, Boxd, timeouts, buildDaemon = (version) => buildDriftDaemon("amd64", version) } = {}) {
|
|
108
|
-
live(env);
|
|
109
|
-
const settings = settingsFromEnv(env);
|
|
110
|
-
const daemonPath = await buildDaemon(DRIFT_VERSION);
|
|
111
|
-
return create({ ...settings, ...(Boxd ? { Boxd } : {}), ...(timeouts ? { timeouts } : {}), daemonPath, maxLifetimeMs: CONFORMANCE_MAX_LIFETIME_MS });
|
|
56
|
+
return preparedImage(await createProvider(options), signal);
|
|
112
57
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type BrowserbaseProvider, type BrowserbaseProviderOptions } from "../browserbase.js";
|
|
2
|
-
|
|
2
|
+
import { type Env } from "./module-kit.js";
|
|
3
3
|
export declare const BROWSERBASE_ENV: {
|
|
4
4
|
readonly live: "AGENTRUN_COMPUTER_LIVE_BROWSERBASE";
|
|
5
5
|
/** apiKey, required: the Browserbase API key. */
|
|
@@ -9,7 +9,6 @@ export declare const BROWSERBASE_ENV: {
|
|
|
9
9
|
/** apiUrl: Browserbase's API; default https://api.browserbase.com. */
|
|
10
10
|
readonly url: "COMPUTER_BROWSERBASE_API_URL";
|
|
11
11
|
};
|
|
12
|
-
/** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
|
|
13
12
|
export declare const ENV: {
|
|
14
13
|
readonly live: "AGENTRUN_COMPUTER_LIVE_BROWSERBASE";
|
|
15
14
|
/** apiKey, required: the Browserbase API key. */
|
|
@@ -22,12 +21,10 @@ export declare const ENV: {
|
|
|
22
21
|
/** What this module reads from the environment: the key, and each other option whose name is set. */
|
|
23
22
|
export type BrowserbaseSettings = Pick<BrowserbaseProviderOptions, "apiKey" | "projectId" | "apiUrl">;
|
|
24
23
|
/** 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. */
|
|
25
|
-
export declare function settingsFromEnv(env?:
|
|
26
|
-
/** For the run's report: what this configuration means for the suite. */
|
|
24
|
+
export declare function settingsFromEnv(env?: Env): BrowserbaseSettings;
|
|
27
25
|
export declare const conformanceNotes: string[];
|
|
28
26
|
export interface BrowserbaseModuleOptions extends Pick<BrowserbaseProviderOptions, "fetch" | "sleep" | "confirm"> {
|
|
29
|
-
|
|
30
|
-
env?: Record<string, string | undefined>;
|
|
27
|
+
env?: Env;
|
|
31
28
|
}
|
|
32
29
|
/** The image every computer of the run asks for: the vendor's Chromium. */
|
|
33
30
|
export declare function conformanceImage(): string;
|