@parcha/agentrun-computer 0.1.0-beta.40 → 0.1.0-beta.42
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 +285 -28
- package/box/Dockerfile +6 -4
- package/box/README.md +10 -2
- package/box/build-daytona.py +3 -1
- package/box/build-e2b.mjs +1 -1
- package/box/install.sh +68 -7
- package/dist/attach.d.ts +46 -1
- package/dist/attach.js +48 -4
- package/dist/box-image.d.ts +1 -1
- package/dist/box-image.js +1 -1
- package/dist/boxd.d.ts +126 -0
- package/dist/boxd.js +418 -0
- package/dist/cloudflare.d.ts +32 -0
- package/dist/cloudflare.js +179 -0
- package/dist/computerd-linux-amd64 +0 -0
- package/dist/computerd-linux-arm64 +0 -0
- package/dist/computerd.json +2 -2
- package/dist/conformance/boxd.d.ts +77 -0
- package/dist/conformance/boxd.js +113 -0
- package/dist/conformance/cases/isolation.js +1 -17
- package/dist/conformance/cases/provider.js +42 -26
- package/dist/conformance/cli.js +4 -1
- package/dist/conformance/cloudflare.d.ts +42 -0
- package/dist/conformance/cloudflare.js +54 -0
- package/dist/conformance/daytona.d.ts +25 -0
- package/dist/conformance/daytona.js +26 -1
- package/dist/conformance/dial-only.d.ts +6 -0
- package/dist/conformance/dial-only.js +9 -0
- package/dist/conformance/e2b.d.ts +12 -3
- package/dist/conformance/e2b.js +21 -4
- package/dist/conformance/exec-stream.js +14 -6
- package/dist/conformance/fly.d.ts +52 -0
- package/dist/conformance/fly.js +52 -0
- package/dist/conformance/modal.d.ts +15 -2
- package/dist/conformance/modal.js +36 -3
- package/dist/conformance/morph.d.ts +59 -0
- package/dist/conformance/morph.js +95 -0
- package/dist/conformance/phone-harness.js +2 -2
- package/dist/conformance/runner.js +5 -1
- package/dist/conformance/sweep.d.ts +1 -1
- package/dist/conformance/sweep.js +1 -1
- package/dist/conformance/types.d.ts +21 -0
- package/dist/daytona.d.ts +8 -1
- package/dist/daytona.js +124 -101
- package/dist/descriptor.d.ts +22 -1
- package/dist/descriptor.js +18 -0
- package/dist/descriptors/boxd.d.ts +52 -0
- package/dist/descriptors/boxd.js +29 -0
- package/dist/descriptors/cloudflare.d.ts +21 -0
- package/dist/descriptors/cloudflare.js +29 -0
- package/dist/descriptors/daytona.d.ts +12 -3
- package/dist/descriptors/daytona.js +15 -7
- package/dist/descriptors/e2b.d.ts +4 -0
- package/dist/descriptors/e2b.js +3 -0
- package/dist/descriptors/fly.d.ts +19 -0
- package/dist/descriptors/fly.js +28 -0
- package/dist/descriptors/index.d.ts +121 -2
- package/dist/descriptors/index.js +7 -2
- package/dist/descriptors/modal.d.ts +3 -0
- package/dist/descriptors/modal.js +7 -2
- package/dist/descriptors/morph.d.ts +15 -0
- package/dist/descriptors/morph.js +21 -0
- package/dist/descriptors/phone-harness.d.ts +1 -0
- package/dist/descriptors/phone-harness.js +2 -0
- package/dist/e2b.d.ts +7 -1
- package/dist/e2b.js +87 -44
- package/dist/fly.d.ts +43 -0
- package/dist/fly.js +245 -0
- package/dist/host.d.ts +52 -48
- package/dist/hosted/framed-exec.d.ts +8 -19
- package/dist/hosted/framed-exec.js +21 -87
- package/dist/hosted/process.d.ts +21 -0
- package/dist/hosted/process.js +37 -2
- package/dist/hosted/provider.d.ts +32 -6
- package/dist/hosted/provider.js +239 -236
- package/dist/hosted/rest.d.ts +19 -0
- package/dist/hosted/rest.js +76 -0
- package/dist/hosted/scripts.d.ts +52 -8
- package/dist/hosted/scripts.js +118 -23
- package/dist/hosted/ssh-exec.d.ts +9 -7
- package/dist/hosted/ssh-exec.js +93 -54
- package/dist/hosted/values.d.ts +5 -0
- package/dist/hosted/values.js +9 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -4
- package/dist/kinds.d.ts +2 -0
- package/dist/modal.d.ts +6 -0
- package/dist/modal.js +40 -17
- package/dist/morph.d.ts +65 -0
- package/dist/morph.js +495 -0
- package/dist/phone-harness.d.ts +15 -5
- package/dist/phone-harness.js +50 -15
- package/dist/providers.d.ts +4 -2
- package/dist/screen-watch.js +2 -2
- package/package.json +20 -2
|
@@ -22,6 +22,8 @@ export declare const E2B_ENV: {
|
|
|
22
22
|
readonly maxLifetimeMs: "COMPUTER_E2B_MAX_LIFETIME_MS";
|
|
23
23
|
/** daemonUser: uid:gid the daemon runs as; default 2510:2510. */
|
|
24
24
|
readonly user: "COMPUTER_E2B_USER";
|
|
25
|
+
/** connect: exec (default) or dial, which needs the public server's process (dialKit). */
|
|
26
|
+
readonly connect: "COMPUTER_E2B_CONNECT";
|
|
25
27
|
};
|
|
26
28
|
/** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
|
|
27
29
|
export declare const ENV: {
|
|
@@ -40,6 +42,8 @@ export declare const ENV: {
|
|
|
40
42
|
readonly maxLifetimeMs: "COMPUTER_E2B_MAX_LIFETIME_MS";
|
|
41
43
|
/** daemonUser: uid:gid the daemon runs as; default 2510:2510. */
|
|
42
44
|
readonly user: "COMPUTER_E2B_USER";
|
|
45
|
+
/** connect: exec (default) or dial, which needs the public server's process (dialKit). */
|
|
46
|
+
readonly connect: "COMPUTER_E2B_CONNECT";
|
|
43
47
|
};
|
|
44
48
|
/** What this module reads from the environment: the key, and each other option whose name is set. */
|
|
45
49
|
export type E2BSettings = Omit<E2BOptions, "Sandbox" | "desktop" | "timeouts" | "probeTargets">;
|
|
@@ -53,7 +57,7 @@ export declare function settingsFromEnv(env?: Record<string, string | undefined>
|
|
|
53
57
|
export declare const CONFORMANCE_MAX_LIFETIME_MS: number;
|
|
54
58
|
/** For the run's report: what this configuration means for the suite. */
|
|
55
59
|
export declare const conformanceNotes: string[];
|
|
56
|
-
export interface E2BModuleOptions extends Pick<E2BOptions, "Sandbox" | "daemonPath" | "timeouts" | "onNote"> {
|
|
60
|
+
export interface E2BModuleOptions extends Pick<E2BOptions, "Sandbox" | "daemonPath" | "timeouts" | "onNote" | "dial"> {
|
|
57
61
|
/** Where the settings are read; default process.env. */
|
|
58
62
|
env?: Record<string, string | undefined>;
|
|
59
63
|
/** Builds this package's daemon for linux/amd64 stamped with version, and gives its path; default go build. */
|
|
@@ -61,10 +65,15 @@ export interface E2BModuleOptions extends Pick<E2BOptions, "Sandbox" | "daemonPa
|
|
|
61
65
|
/** For mountFor("archil"): the disk's object API, or the SDK's Archil client, in place of the host's disk package. */
|
|
62
66
|
archil?: Pick<ArchilRunFolderOptions, "objects" | "Archil" | "baseUrl">;
|
|
63
67
|
}
|
|
64
|
-
/**
|
|
68
|
+
/**
|
|
69
|
+
* The template every computer of the run starts from: COMPUTER_E2B_TEMPLATE; else on dial the box template, since only the
|
|
70
|
+
* box image holds agentrun-dial; else E2B Desktop's (the plain one for kind linux).
|
|
71
|
+
*/
|
|
65
72
|
export declare function conformanceImage({ env }?: Pick<E2BModuleOptions, "env">): string;
|
|
66
73
|
/** The provider the CLI runs; throws in words without the live switch, or when a setting is missing or wrong. */
|
|
67
|
-
export declare function createProvider({ env, Sandbox, daemonPath, timeouts, onNote }?: E2BModuleOptions): Promise<E2BProvider>;
|
|
74
|
+
export declare function createProvider({ env, Sandbox, daemonPath, timeouts, onNote, dial }?: E2BModuleOptions): Promise<E2BProvider>;
|
|
75
|
+
/** A dial machine (COMPUTER_E2B_CONNECT=dial) runs its Core inside the public server's process: refused here (dial-only.ts). */
|
|
76
|
+
export declare const dialKit: () => import("./types.js").DialKit;
|
|
68
77
|
/**
|
|
69
78
|
* A run folder for an Archil mount, and none for any other kind (an E2B computer takes no bind): a fresh folder on the
|
|
70
79
|
* disk the COMPUTER_ARCHIL_* names name (archilSettings), none when they name none (archilRunFolder, ./archil.ts).
|
package/dist/conformance/e2b.js
CHANGED
|
@@ -15,8 +15,10 @@
|
|
|
15
15
|
// disk's object API (the shared archilRunFolder, ./archil.ts: the host's disk SDK with COMPUTER_ARCHIL_API_KEY and
|
|
16
16
|
// COMPUTER_ARCHIL_S3_URL, or an object API given as archil.objects); with no disk named it makes none, and the cases
|
|
17
17
|
// are skipped. An Archil computer needs a provider whose daemon user is the tool user: COMPUTER_E2B_USER=2510:2510.
|
|
18
|
+
import { boxE2bTemplate } from "../box-image.js";
|
|
18
19
|
import { create } from "../e2b.js";
|
|
19
20
|
import { archilRunFolder, archilSettings } from "./archil.js";
|
|
21
|
+
import { dialOnlyFromServer } from "./dial-only.js";
|
|
20
22
|
import { buildDriftDaemon, DRIFT_VERSION } from "./drift-daemon.js";
|
|
21
23
|
/** The Archil disk's settings for the mount cases, by name (COMPUTER_ARCHIL_*: all five, or none). */
|
|
22
24
|
export { ARCHIL_ENV } from "./archil.js";
|
|
@@ -37,6 +39,8 @@ export const E2B_ENV = {
|
|
|
37
39
|
maxLifetimeMs: "COMPUTER_E2B_MAX_LIFETIME_MS",
|
|
38
40
|
/** daemonUser: uid:gid the daemon runs as; default 2510:2510. */
|
|
39
41
|
user: "COMPUTER_E2B_USER",
|
|
42
|
+
/** connect: exec (default) or dial, which needs the public server's process (dialKit). */
|
|
43
|
+
connect: "COMPUTER_E2B_CONNECT",
|
|
40
44
|
};
|
|
41
45
|
/** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
|
|
42
46
|
export const ENV = E2B_ENV;
|
|
@@ -58,8 +62,11 @@ export function settingsFromEnv(env = process.env) {
|
|
|
58
62
|
const daemonPath = env[E2B_ENV.daemon] || undefined;
|
|
59
63
|
const kind = env[E2B_ENV.kind] || undefined;
|
|
60
64
|
const daemonUser = env[E2B_ENV.user] || undefined;
|
|
65
|
+
const connect = env[E2B_ENV.connect] || undefined;
|
|
61
66
|
return {
|
|
62
67
|
apiKey,
|
|
68
|
+
// create() refuses any other value in words.
|
|
69
|
+
...(connect === undefined ? {} : { connect: connect }),
|
|
63
70
|
...(domain === undefined ? {} : { domain }),
|
|
64
71
|
...(daemonPath === undefined ? {} : { daemonPath }),
|
|
65
72
|
// create() refuses any other kind in words.
|
|
@@ -85,15 +92,25 @@ function live(env) {
|
|
|
85
92
|
*/
|
|
86
93
|
const DESKTOP_TEMPLATE = "desktop";
|
|
87
94
|
const BASE_TEMPLATE = "base";
|
|
88
|
-
/**
|
|
95
|
+
/**
|
|
96
|
+
* The template every computer of the run starts from: COMPUTER_E2B_TEMPLATE; else on dial the box template, since only the
|
|
97
|
+
* box image holds agentrun-dial; else E2B Desktop's (the plain one for kind linux).
|
|
98
|
+
*/
|
|
89
99
|
export function conformanceImage({ env = process.env } = {}) {
|
|
90
|
-
|
|
100
|
+
const named = env[E2B_ENV.template];
|
|
101
|
+
if (named)
|
|
102
|
+
return named;
|
|
103
|
+
if (env[E2B_ENV.connect] === "dial")
|
|
104
|
+
return boxE2bTemplate();
|
|
105
|
+
return env[E2B_ENV.kind] === "linux" ? BASE_TEMPLATE : DESKTOP_TEMPLATE;
|
|
91
106
|
}
|
|
92
107
|
/** The provider the CLI runs; throws in words without the live switch, or when a setting is missing or wrong. */
|
|
93
|
-
export async function createProvider({ env = process.env, Sandbox, daemonPath, timeouts, onNote } = {}) {
|
|
108
|
+
export async function createProvider({ env = process.env, Sandbox, daemonPath, timeouts, onNote, dial } = {}) {
|
|
94
109
|
live(env);
|
|
95
|
-
return create({ ...settingsFromEnv(env), ...(Sandbox ? { Sandbox } : {}), ...(daemonPath === undefined ? {} : { daemonPath }), ...(timeouts ? { timeouts } : {}), ...(onNote ? { onNote } : {}), maxLifetimeMs: CONFORMANCE_MAX_LIFETIME_MS });
|
|
110
|
+
return create({ ...settingsFromEnv(env), ...(Sandbox ? { Sandbox } : {}), ...(daemonPath === undefined ? {} : { daemonPath }), ...(timeouts ? { timeouts } : {}), ...(onNote ? { onNote } : {}), ...(dial ? { dial } : {}), maxLifetimeMs: CONFORMANCE_MAX_LIFETIME_MS });
|
|
96
111
|
}
|
|
112
|
+
/** A dial machine (COMPUTER_E2B_CONNECT=dial) runs its Core inside the public server's process: refused here (dial-only.ts). */
|
|
113
|
+
export const dialKit = dialOnlyFromServer("e2b", "E2B", `${E2B_ENV.connect}=dial`);
|
|
97
114
|
/**
|
|
98
115
|
* A run folder for an Archil mount, and none for any other kind (an E2B computer takes no bind): a fresh folder on the
|
|
99
116
|
* disk the COMPUTER_ARCHIL_* names name (archilSettings), none when they name none (archilRunFolder, ./archil.ts).
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
// host (root's network namespace, /dev/fuse, the arch, the kernel, the TCP listeners): facts, each with what it means
|
|
13
13
|
// for the provider, never a pass or a fail of exec.
|
|
14
14
|
import { createHash, randomBytes } from "node:crypto";
|
|
15
|
-
import { words } from "../hosted/process.js";
|
|
15
|
+
import { execOf, words } from "../hosted/process.js";
|
|
16
16
|
/** The checks, in the order they run. */
|
|
17
17
|
export const EXEC_STREAM_CHECKS = ["stdout-text", "stdin-text", "large", "stdout-live", "stdin-live", "stdout-unread", "stderr", "exit-code", "kill", "no-timeout"];
|
|
18
18
|
/** What the capability probe reads, in the order the report gives it. */
|
|
@@ -53,7 +53,11 @@ const range = (from, to) => String.fromCodePoint(...Array.from({ length: to - fr
|
|
|
53
53
|
*/
|
|
54
54
|
const CODE_POINTS = `\u{feff}${range(0x01, 0x7f)}${range(0x80, 0xff)}ĀſΩЖאعह中文日本語한국어€
�𝄞😀\u{10ffff}éä\u{1f469}\u{1f4bb}carriage\rreturn\r\nline`;
|
|
55
55
|
/** 16 KiB of text of every width (1, 2, 3 and 4 bytes a character), no newline: 64 of them are the 1 MiB line. */
|
|
56
|
-
const
|
|
56
|
+
const LONG_UNIT = "aé€𝄞";
|
|
57
|
+
const LONG_UNITS = 1638;
|
|
58
|
+
/** ASCII, so the script writes it as it is. */
|
|
59
|
+
const LONG_TAIL = "abcd";
|
|
60
|
+
const LONG_PIECE = `${LONG_UNIT.repeat(LONG_UNITS)}${LONG_TAIL}`;
|
|
57
61
|
const LONG_PIECES = 64;
|
|
58
62
|
/** What stdout-text and stdin-text carry: every class of code point, \r and \r\n, a line of 1 MiB, and a lone \n at the end. */
|
|
59
63
|
const TEXT = Buffer.from(`${CODE_POINTS}${LONG_PIECE.repeat(LONG_PIECES)}\n`, "utf8");
|
|
@@ -239,7 +243,7 @@ class Session {
|
|
|
239
243
|
const what = `exec of ${shown(argv)}`;
|
|
240
244
|
let answer;
|
|
241
245
|
try {
|
|
242
|
-
answer = Promise.resolve(this.#host
|
|
246
|
+
answer = Promise.resolve(execOf(this.#host)(this.#machine, argv, { timeoutMs: this.#stepMs, ...(this.#signal ? { signal: this.#signal } : {}) }));
|
|
243
247
|
}
|
|
244
248
|
catch (error) {
|
|
245
249
|
throw new Problem(`${what} threw: ${words(error)}`);
|
|
@@ -345,10 +349,14 @@ class Deadline {
|
|
|
345
349
|
}
|
|
346
350
|
}
|
|
347
351
|
const CHECKS = {
|
|
348
|
-
/**
|
|
352
|
+
/**
|
|
353
|
+
* Text of every kind out, on stdout alone: printf in the machine writes it, the 1 MiB line a piece at a time. Only the
|
|
354
|
+
* piece's short unit crosses argv; sh repeats it, doubling, into the piece, so the command stays far under a vendor's
|
|
355
|
+
* 64 KiB argv cap (Modal's).
|
|
356
|
+
*/
|
|
349
357
|
async "stdout-text"(s) {
|
|
350
|
-
const script = `printf "$1"; i=0; while [ "$i" -lt ${LONG_PIECES} ]; do printf "$
|
|
351
|
-
const run = await s.start(["sh", "-c", script, "sh", printfOf(CODE_POINTS), printfOf(
|
|
358
|
+
const script = `printf "$1"; u=$(printf "$2"); n=${LONG_UNITS}; p=; while [ "$n" -gt 0 ]; do if [ $((n % 2)) -eq 1 ]; then p="$p$u"; fi; u="$u$u"; n=$((n / 2)); done; p="$p"${LONG_TAIL}; i=0; while [ "$i" -lt ${LONG_PIECES} ]; do printf '%s' "$p"; i=$((i+1)); done; printf '\\n'`;
|
|
359
|
+
const run = await s.start(["sh", "-c", script, "sh", printfOf(CODE_POINTS), printfOf(LONG_UNIT)], false);
|
|
352
360
|
if (!(await run.out.end(s.stepMs, s.signal)))
|
|
353
361
|
throw new Problem(`stdout of printf did not end within ${secondsOf(s.stepMs)} of its start`);
|
|
354
362
|
const code = await s.exit(run, s.stepMs, "printf");
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { HostedDial } from "../hosted/provider.js";
|
|
2
|
+
import { type FlyProvider } from "../fly.js";
|
|
3
|
+
import type { MachineHost } from "../host.js";
|
|
4
|
+
import type { ProviderNote } from "../mount-archil.js";
|
|
5
|
+
import type { DialKit } from "./types.js";
|
|
6
|
+
/** The environment this module reads, by name, each for the option its comment names. */
|
|
7
|
+
export declare const FLY_ENV: {
|
|
8
|
+
/** apiToken, required: a Fly API token that may make machines in the app. */
|
|
9
|
+
readonly token: "COMPUTER_FLY_API_TOKEN";
|
|
10
|
+
/** app, required: the Fly app the run's machines live in. */
|
|
11
|
+
readonly app: "COMPUTER_FLY_APP";
|
|
12
|
+
};
|
|
13
|
+
/** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
|
|
14
|
+
export declare const ENV: {
|
|
15
|
+
/** apiToken, required: a Fly API token that may make machines in the app. */
|
|
16
|
+
readonly token: "COMPUTER_FLY_API_TOKEN";
|
|
17
|
+
/** app, required: the Fly app the run's machines live in. */
|
|
18
|
+
readonly app: "COMPUTER_FLY_APP";
|
|
19
|
+
};
|
|
20
|
+
/** The longest lifetime a computer of a run may ask for: init's deadline and the janitor end each machine by then. */
|
|
21
|
+
export declare const CONFORMANCE_MAX_LIFETIME_MS: number;
|
|
22
|
+
/** The provider's options this module reads from env; throws in words without the token or the app, never echoing one. */
|
|
23
|
+
export declare function settingsFromEnv(env?: Record<string, string | undefined>): {
|
|
24
|
+
apiToken: string;
|
|
25
|
+
app: string;
|
|
26
|
+
};
|
|
27
|
+
export interface FlyModuleOptions {
|
|
28
|
+
/** The environment to read; process.env by default. */
|
|
29
|
+
env?: Record<string, string | undefined>;
|
|
30
|
+
/** The server the machines dial: dial-conformance.mjs gives its own. Without it every create is refused in words. */
|
|
31
|
+
dial?: HostedDial;
|
|
32
|
+
/** The daemon the server serves (its sha256 is what a machine checks); default this package's dist/computerd-linux-amd64. */
|
|
33
|
+
daemonPath?: string;
|
|
34
|
+
/** The fetch Fly's calls go through; default the global one. */
|
|
35
|
+
fetch?: typeof fetch;
|
|
36
|
+
/** What the provider says that is no failure: the CLI gives it and puts it in the report. */
|
|
37
|
+
onNote?: ProviderNote;
|
|
38
|
+
}
|
|
39
|
+
/** The provider the run makes computers with, dialing the server options.dial names. */
|
|
40
|
+
export declare function createProvider({ env, dial, daemonPath, fetch, onNote }?: FlyModuleOptions): FlyProvider;
|
|
41
|
+
/** The run's image: the box image the release publishes, whose CMD runs agentrun-dial (box-image.ts). */
|
|
42
|
+
export declare function conformanceImage(): string;
|
|
43
|
+
/**
|
|
44
|
+
* The server the run's machines dial, for provider.dial-token, as the CLI asks for it: refused in words. A Fly machine
|
|
45
|
+
* dials the server that minted its token, so the run can't happen from a CLI whose server the internet doesn't reach;
|
|
46
|
+
* dial-conformance.mjs stands that server up and gives the run its DialKit itself.
|
|
47
|
+
*/
|
|
48
|
+
export declare function dialKit(): DialKit;
|
|
49
|
+
/** The Fly host the live sweep lists and deletes through, from the same settings; it makes nothing. */
|
|
50
|
+
export declare function createHost({ env, fetch }?: Pick<FlyModuleOptions, "env" | "fetch">): MachineHost;
|
|
51
|
+
/** Where the sweep lists, in words: the app the settings name. */
|
|
52
|
+
export declare function sweepScope({ env }?: Pick<FlyModuleOptions, "env">): string;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { boxImageRef } from "../box-image.js";
|
|
2
|
+
import { create } from "../fly.js";
|
|
3
|
+
/** The environment this module reads, by name, each for the option its comment names. */
|
|
4
|
+
export const FLY_ENV = {
|
|
5
|
+
/** apiToken, required: a Fly API token that may make machines in the app. */
|
|
6
|
+
token: "COMPUTER_FLY_API_TOKEN",
|
|
7
|
+
/** app, required: the Fly app the run's machines live in. */
|
|
8
|
+
app: "COMPUTER_FLY_APP",
|
|
9
|
+
};
|
|
10
|
+
/** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
|
|
11
|
+
export const ENV = FLY_ENV;
|
|
12
|
+
/** The longest lifetime a computer of a run may ask for: init's deadline and the janitor end each machine by then. */
|
|
13
|
+
export const CONFORMANCE_MAX_LIFETIME_MS = 30 * 60_000;
|
|
14
|
+
/** The provider's options this module reads from env; throws in words without the token or the app, never echoing one. */
|
|
15
|
+
export function settingsFromEnv(env = process.env) {
|
|
16
|
+
const apiToken = env[FLY_ENV.token];
|
|
17
|
+
const app = env[FLY_ENV.app];
|
|
18
|
+
if (!apiToken || !app)
|
|
19
|
+
throw new Error(`the Fly conformance module needs ${FLY_ENV.token} and ${FLY_ENV.app}: it takes a token from that name only, never FLY_API_TOKEN`);
|
|
20
|
+
return { apiToken, app };
|
|
21
|
+
}
|
|
22
|
+
/** The provider the run makes computers with, dialing the server options.dial names. */
|
|
23
|
+
export function createProvider({ env = process.env, dial, daemonPath, fetch, onNote } = {}) {
|
|
24
|
+
return create({
|
|
25
|
+
...settingsFromEnv(env),
|
|
26
|
+
...(dial ? { dial } : {}),
|
|
27
|
+
...(daemonPath === undefined ? {} : { daemonPath }),
|
|
28
|
+
...(fetch ? { fetch } : {}),
|
|
29
|
+
...(onNote ? { onNote } : {}),
|
|
30
|
+
maxLifetimeMs: CONFORMANCE_MAX_LIFETIME_MS,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/** The run's image: the box image the release publishes, whose CMD runs agentrun-dial (box-image.ts). */
|
|
34
|
+
export function conformanceImage() {
|
|
35
|
+
return boxImageRef();
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The server the run's machines dial, for provider.dial-token, as the CLI asks for it: refused in words. A Fly machine
|
|
39
|
+
* dials the server that minted its token, so the run can't happen from a CLI whose server the internet doesn't reach;
|
|
40
|
+
* dial-conformance.mjs stands that server up and gives the run its DialKit itself.
|
|
41
|
+
*/
|
|
42
|
+
export function dialKit() {
|
|
43
|
+
throw new Error("a Fly machine dials the server that minted its token, and this run has no public server: run Fly's Core with packages/serve/scripts/dial-conformance.mjs --provider fly inside a server the internet reaches at AGENTRUN_PUBLIC_URL");
|
|
44
|
+
}
|
|
45
|
+
/** The Fly host the live sweep lists and deletes through, from the same settings; it makes nothing. */
|
|
46
|
+
export function createHost({ env = process.env, fetch } = {}) {
|
|
47
|
+
return create({ ...settingsFromEnv(env), ...(fetch ? { fetch } : {}) }).host;
|
|
48
|
+
}
|
|
49
|
+
/** Where the sweep lists, in words: the app the settings name. */
|
|
50
|
+
export function sweepScope({ env = process.env } = {}) {
|
|
51
|
+
return `the Fly app ${settingsFromEnv(env).app}`;
|
|
52
|
+
}
|
|
@@ -16,6 +16,8 @@ export declare const MODAL_ENV: {
|
|
|
16
16
|
readonly app: "COMPUTER_MODAL_APP";
|
|
17
17
|
/** serverUrl: the server the token goes to; the SDK's default when unset. */
|
|
18
18
|
readonly serverUrl: "COMPUTER_MODAL_SERVER_URL";
|
|
19
|
+
/** connect: exec (default) or dial, which needs the public server's process (dialKit). */
|
|
20
|
+
readonly connect: "COMPUTER_MODAL_CONNECT";
|
|
19
21
|
};
|
|
20
22
|
/** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
|
|
21
23
|
export declare const ENV: {
|
|
@@ -27,9 +29,11 @@ export declare const ENV: {
|
|
|
27
29
|
readonly app: "COMPUTER_MODAL_APP";
|
|
28
30
|
/** serverUrl: the server the token goes to; the SDK's default when unset. */
|
|
29
31
|
readonly serverUrl: "COMPUTER_MODAL_SERVER_URL";
|
|
32
|
+
/** connect: exec (default) or dial, which needs the public server's process (dialKit). */
|
|
33
|
+
readonly connect: "COMPUTER_MODAL_CONNECT";
|
|
30
34
|
};
|
|
31
35
|
/** 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">;
|
|
36
|
+
export type ModalSettings = Pick<ModalCreateOptions, "tokenId" | "tokenSecret" | "app" | "serverUrl" | "connect">;
|
|
33
37
|
/**
|
|
34
38
|
* The provider's options this module reads from env; throws in words without the token or the app, or while
|
|
35
39
|
* MODAL_SERVER_URL is set there (the SDK would send the token to it), never echoing a token.
|
|
@@ -50,9 +54,18 @@ export interface ModalModuleOptions {
|
|
|
50
54
|
archil?: Pick<ArchilRunFolderOptions, "objects" | "Archil" | "baseUrl">;
|
|
51
55
|
/** What the provider says that is no failure: the CLI gives it and puts it in the report. */
|
|
52
56
|
onNote?: ProviderNote;
|
|
57
|
+
/** The public server a dial machine dials (COMPUTER_MODAL_CONNECT=dial): its process alone gives it (dialKit). */
|
|
58
|
+
dial?: ModalCreateOptions["dial"];
|
|
53
59
|
}
|
|
54
60
|
/** 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>;
|
|
61
|
+
export declare function createProvider({ env, ModalClient, daemonPath, onNote, dial }?: ModalModuleOptions): Promise<ModalProvider>;
|
|
62
|
+
/**
|
|
63
|
+
* The image every computer of the run starts from: on dial the box image, since only it holds agentrun-dial; on exec
|
|
64
|
+
* debian:bookworm-slim, the CLI's own default.
|
|
65
|
+
*/
|
|
66
|
+
export declare function conformanceImage({ env }?: Pick<ModalModuleOptions, "env">): string;
|
|
67
|
+
/** A dial machine (COMPUTER_MODAL_CONNECT=dial) runs its Core inside the public server's process: refused here (dial-only.ts). */
|
|
68
|
+
export declare const dialKit: () => import("./types.js").DialKit;
|
|
56
69
|
/**
|
|
57
70
|
* A run folder for an Archil mount, and none for any other kind (a Modal computer takes no bind): a fresh folder on the
|
|
58
71
|
* disk the COMPUTER_ARCHIL_* names name (archilSettings), none when they name none (archilRunFolder, ./archil.ts).
|
|
@@ -1,5 +1,25 @@
|
|
|
1
|
+
// Modal for the conformance CLI: `npm run conformance -w @parcha/agentrun-computer -- --provider modal`. It builds a real
|
|
2
|
+
// Modal client, so it runs only with AGENTRUN_COMPUTER_LIVE_MODAL=1 and a key for an account you can bill, under
|
|
3
|
+
// COMPUTER_MODAL_TOKEN_ID and COMPUTER_MODAL_TOKEN_SECRET. The provider reads no environment: this module reads its own
|
|
4
|
+
// COMPUTER_MODAL_* names (never MODAL_TOKEN_ID or MODAL_TOKEN_SECRET, which may hold a production token) and passes each
|
|
5
|
+
// to create() as its option; the provider gives the token to the client explicitly, pins the server it goes to and
|
|
6
|
+
// refuses an ambient MODAL_SERVER_URL (see modalClient in ../modal.ts). The live switch is checked first, before any
|
|
7
|
+
// other setting is read. The live sweep (sweep.ts, --provider modal) reads the same names through createHost, which
|
|
8
|
+
// needs no live switch: it makes nothing; sweepScope names the app and server a before file must have been listed from.
|
|
9
|
+
//
|
|
10
|
+
// The daemon is uploaded into each sandbox (dist/computerd-linux-amd64, `npm run build:daemon`), so a run publishes
|
|
11
|
+
// nothing. The drifted provider uploads a daemon built with Go as version <version>-drift. Every computer of a run
|
|
12
|
+
// lives at most 30 minutes: Modal's timeout is its lifetime, and a longer one is refused in words.
|
|
13
|
+
//
|
|
14
|
+
// For the mount cases, mountFor("archil") makes a fresh run folder on the Archil disk COMPUTER_ARCHIL_DISK names (in
|
|
15
|
+
// COMPUTER_ARCHIL_REGION, mounted with the disk token COMPUTER_ARCHIL_TOKEN), and reaches it from outside through the
|
|
16
|
+
// disk's object API (the shared archilRunFolder, ./archil.ts: the host's disk SDK with COMPUTER_ARCHIL_API_KEY and
|
|
17
|
+
// COMPUTER_ARCHIL_S3_URL, or an object API given as archil.objects); with no disk named it makes none, and the cases
|
|
18
|
+
// are skipped.
|
|
19
|
+
import { boxImageRef } from "../box-image.js";
|
|
1
20
|
import { create, MODAL_DEFAULT_SERVER_URL } from "../modal.js";
|
|
2
21
|
import { archilRunFolder, archilSettings } from "./archil.js";
|
|
22
|
+
import { dialOnlyFromServer } from "./dial-only.js";
|
|
3
23
|
import { buildDriftDaemon, DRIFT_VERSION } from "./drift-daemon.js";
|
|
4
24
|
/** The Archil disk's settings for the mount cases, by name (COMPUTER_ARCHIL_*: all five, or none). */
|
|
5
25
|
export { ARCHIL_ENV } from "./archil.js";
|
|
@@ -13,6 +33,8 @@ export const MODAL_ENV = {
|
|
|
13
33
|
app: "COMPUTER_MODAL_APP",
|
|
14
34
|
/** serverUrl: the server the token goes to; the SDK's default when unset. */
|
|
15
35
|
serverUrl: "COMPUTER_MODAL_SERVER_URL",
|
|
36
|
+
/** connect: exec (default) or dial, which needs the public server's process (dialKit). */
|
|
37
|
+
connect: "COMPUTER_MODAL_CONNECT",
|
|
16
38
|
};
|
|
17
39
|
/** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
|
|
18
40
|
export const ENV = MODAL_ENV;
|
|
@@ -33,7 +55,9 @@ export function settingsFromEnv(env = process.env) {
|
|
|
33
55
|
if (!app)
|
|
34
56
|
throw new Error(`the Modal conformance module needs ${MODAL_ENV.app}: the app the run's sandboxes live in`);
|
|
35
57
|
const serverUrl = env[MODAL_ENV.serverUrl];
|
|
36
|
-
|
|
58
|
+
// create() refuses any other value in words.
|
|
59
|
+
const connect = env[MODAL_ENV.connect];
|
|
60
|
+
return { tokenId, tokenSecret, app, ...(serverUrl ? { serverUrl } : {}), ...(connect ? { connect } : {}) };
|
|
37
61
|
}
|
|
38
62
|
/** The longest lifetime a computer of a run may ask for: Modal ends each sandbox at its timeout, the lifetime. */
|
|
39
63
|
export const CONFORMANCE_MAX_LIFETIME_MS = 30 * 60_000;
|
|
@@ -43,10 +67,19 @@ function live(env) {
|
|
|
43
67
|
}
|
|
44
68
|
}
|
|
45
69
|
/** The provider the CLI runs; throws in words without the live switch, or when a setting is missing or wrong. */
|
|
46
|
-
export async function createProvider({ env = process.env, ModalClient, daemonPath, onNote } = {}) {
|
|
70
|
+
export async function createProvider({ env = process.env, ModalClient, daemonPath, onNote, dial } = {}) {
|
|
47
71
|
live(env);
|
|
48
|
-
return create({ ...settingsFromEnv(env), ...(daemonPath === undefined ? {} : { daemonPath }), ...(ModalClient ? { ModalClient } : {}), ...(onNote ? { onNote } : {}), maxLifetimeMs: CONFORMANCE_MAX_LIFETIME_MS });
|
|
72
|
+
return create({ ...settingsFromEnv(env), ...(daemonPath === undefined ? {} : { daemonPath }), ...(ModalClient ? { ModalClient } : {}), ...(onNote ? { onNote } : {}), ...(dial ? { dial } : {}), maxLifetimeMs: CONFORMANCE_MAX_LIFETIME_MS });
|
|
49
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* The image every computer of the run starts from: on dial the box image, since only it holds agentrun-dial; on exec
|
|
76
|
+
* debian:bookworm-slim, the CLI's own default.
|
|
77
|
+
*/
|
|
78
|
+
export function conformanceImage({ env = process.env } = {}) {
|
|
79
|
+
return env[MODAL_ENV.connect] === "dial" ? boxImageRef() : "debian:bookworm-slim";
|
|
80
|
+
}
|
|
81
|
+
/** A dial machine (COMPUTER_MODAL_CONNECT=dial) runs its Core inside the public server's process: refused here (dial-only.ts). */
|
|
82
|
+
export const dialKit = dialOnlyFromServer("modal", "Modal", `${MODAL_ENV.connect}=dial`);
|
|
50
83
|
/**
|
|
51
84
|
* A run folder for an Archil mount, and none for any other kind (a Modal computer takes no bind): a fresh folder on the
|
|
52
85
|
* disk the COMPUTER_ARCHIL_* names name (archilSettings), none when they name none (archilRunFolder, ./archil.ts).
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { MachineHost } from "../host.js";
|
|
2
|
+
import { type MorphOptions, type MorphProvider } from "../morph.js";
|
|
3
|
+
/** The environment this module reads, by name, each for the option its comment names, the live switch and the run's snapshot. */
|
|
4
|
+
export declare const MORPH_ENV: {
|
|
5
|
+
readonly live: "AGENTRUN_COMPUTER_LIVE_MORPH";
|
|
6
|
+
/** apiKey, required: the account's API key. */
|
|
7
|
+
readonly key: "COMPUTER_MORPH_API_KEY";
|
|
8
|
+
/** The snapshot every computer of the run starts from; default the box snapshot (prepareImage). */
|
|
9
|
+
readonly snapshot: "COMPUTER_MORPH_SNAPSHOT";
|
|
10
|
+
/** apiUrl: Morph's REST API; default https://cloud.morph.so/api. */
|
|
11
|
+
readonly apiUrl: "COMPUTER_MORPH_API_URL";
|
|
12
|
+
/** daemonPath: the daemon binary; default this package's dist/computerd-linux-amd64. */
|
|
13
|
+
readonly daemon: "COMPUTER_MORPH_DAEMON";
|
|
14
|
+
/** maxLifetimeMs: the cap, in ms, at most 86400000; a run takes it when it is under 30 minutes, else 30 minutes. */
|
|
15
|
+
readonly maxLifetimeMs: "COMPUTER_MORPH_MAX_LIFETIME_MS";
|
|
16
|
+
};
|
|
17
|
+
/** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
|
|
18
|
+
export declare const ENV: {
|
|
19
|
+
readonly live: "AGENTRUN_COMPUTER_LIVE_MORPH";
|
|
20
|
+
/** apiKey, required: the account's API key. */
|
|
21
|
+
readonly key: "COMPUTER_MORPH_API_KEY";
|
|
22
|
+
/** The snapshot every computer of the run starts from; default the box snapshot (prepareImage). */
|
|
23
|
+
readonly snapshot: "COMPUTER_MORPH_SNAPSHOT";
|
|
24
|
+
/** apiUrl: Morph's REST API; default https://cloud.morph.so/api. */
|
|
25
|
+
readonly apiUrl: "COMPUTER_MORPH_API_URL";
|
|
26
|
+
/** daemonPath: the daemon binary; default this package's dist/computerd-linux-amd64. */
|
|
27
|
+
readonly daemon: "COMPUTER_MORPH_DAEMON";
|
|
28
|
+
/** maxLifetimeMs: the cap, in ms, at most 86400000; a run takes it when it is under 30 minutes, else 30 minutes. */
|
|
29
|
+
readonly maxLifetimeMs: "COMPUTER_MORPH_MAX_LIFETIME_MS";
|
|
30
|
+
};
|
|
31
|
+
/** What this module reads from the environment: the key, and each other option whose name is set. */
|
|
32
|
+
export type MorphSettings = Pick<MorphOptions, "apiKey" | "apiUrl" | "daemonPath" | "maxLifetimeMs">;
|
|
33
|
+
/** The provider's options this module reads from env, each only when its name is set; throws in words without a key, never echoing it. */
|
|
34
|
+
export declare function settingsFromEnv(env?: Record<string, string | undefined>): MorphSettings;
|
|
35
|
+
/** The longest lifetime a computer of a run may ask for: Morph's TTL and init end it at its deadline, the sweep deletes it. */
|
|
36
|
+
export declare const CONFORMANCE_MAX_LIFETIME_MS: number;
|
|
37
|
+
/** For the run's report: what this configuration means for the suite. */
|
|
38
|
+
export declare const conformanceNotes: string[];
|
|
39
|
+
export interface MorphModuleOptions extends Pick<MorphOptions, "ssh2" | "fetch" | "daemonPath" | "timeouts" | "onNote" | "sshHost" | "sshPort"> {
|
|
40
|
+
/** Where the settings are read; default process.env. */
|
|
41
|
+
env?: Record<string, string | undefined>;
|
|
42
|
+
/** Builds this package's daemon for linux/amd64 stamped with version, and gives its path; default go build. */
|
|
43
|
+
buildDaemon?: (version: string) => Promise<string>;
|
|
44
|
+
}
|
|
45
|
+
/** The provider the CLI runs; throws in words without the live switch, or when a setting is missing or wrong. */
|
|
46
|
+
export declare function createProvider(options?: MorphModuleOptions): Promise<MorphProvider>;
|
|
47
|
+
/** The same provider uploading a daemon that reports version <version>-drift, for the drift.version case. */
|
|
48
|
+
export declare function createDriftedProvider(options?: MorphModuleOptions): Promise<MorphProvider>;
|
|
49
|
+
/** The run's snapshot: COMPUTER_MORPH_SNAPSHOT, else the box snapshot, found or built in the key's account first (live). */
|
|
50
|
+
export declare function conformanceImage(options?: MorphModuleOptions, { signal }?: {
|
|
51
|
+
signal?: AbortSignal;
|
|
52
|
+
}): Promise<string>;
|
|
53
|
+
/**
|
|
54
|
+
* The Morph host the live sweep (sweep.ts) lists and deletes through, from the same settings; it needs no live switch,
|
|
55
|
+
* since the sweep makes nothing, and it calls nothing until the sweep does.
|
|
56
|
+
*/
|
|
57
|
+
export declare function createHost(options?: Pick<MorphModuleOptions, "env" | "ssh2" | "fetch">): Promise<MachineHost>;
|
|
58
|
+
/** Where the host lists, in words: one key is one account, and one listing covers all of it. The key is named by its sha256 prefix alone. */
|
|
59
|
+
export declare function sweepScope({ env }?: Pick<MorphModuleOptions, "env">): string;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { accountOf, create } from "../morph.js";
|
|
2
|
+
import { buildDriftDaemon, DRIFT_VERSION } from "./drift-daemon.js";
|
|
3
|
+
/** The environment this module reads, by name, each for the option its comment names, the live switch and the run's snapshot. */
|
|
4
|
+
export const MORPH_ENV = {
|
|
5
|
+
live: "AGENTRUN_COMPUTER_LIVE_MORPH",
|
|
6
|
+
/** apiKey, required: the account's API key. */
|
|
7
|
+
key: "COMPUTER_MORPH_API_KEY",
|
|
8
|
+
/** The snapshot every computer of the run starts from; default the box snapshot (prepareImage). */
|
|
9
|
+
snapshot: "COMPUTER_MORPH_SNAPSHOT",
|
|
10
|
+
/** apiUrl: Morph's REST API; default https://cloud.morph.so/api. */
|
|
11
|
+
apiUrl: "COMPUTER_MORPH_API_URL",
|
|
12
|
+
/** daemonPath: the daemon binary; default this package's dist/computerd-linux-amd64. */
|
|
13
|
+
daemon: "COMPUTER_MORPH_DAEMON",
|
|
14
|
+
/** maxLifetimeMs: the cap, in ms, at most 86400000; a run takes it when it is under 30 minutes, else 30 minutes. */
|
|
15
|
+
maxLifetimeMs: "COMPUTER_MORPH_MAX_LIFETIME_MS",
|
|
16
|
+
};
|
|
17
|
+
/** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
|
|
18
|
+
export const ENV = MORPH_ENV;
|
|
19
|
+
/** The provider's options this module reads from env, each only when its name is set; throws in words without a key, never echoing it. */
|
|
20
|
+
export function settingsFromEnv(env = process.env) {
|
|
21
|
+
const apiKey = env[MORPH_ENV.key];
|
|
22
|
+
if (apiKey === undefined || apiKey === "")
|
|
23
|
+
throw new Error(`set ${MORPH_ENV.key} to a Morph API key: the conformance module reads it there and nowhere else, never from MORPH_API_KEY`);
|
|
24
|
+
const lifetime = env[MORPH_ENV.maxLifetimeMs] || undefined;
|
|
25
|
+
if (lifetime !== undefined && !/^\d+$/.test(lifetime))
|
|
26
|
+
throw new Error(`${MORPH_ENV.maxLifetimeMs} is a whole number of milliseconds, such as 86400000`);
|
|
27
|
+
const apiUrl = env[MORPH_ENV.apiUrl] || undefined;
|
|
28
|
+
const daemonPath = env[MORPH_ENV.daemon] || undefined;
|
|
29
|
+
return {
|
|
30
|
+
apiKey,
|
|
31
|
+
...(apiUrl === undefined ? {} : { apiUrl }),
|
|
32
|
+
...(daemonPath === undefined ? {} : { daemonPath }),
|
|
33
|
+
...(lifetime === undefined ? {} : { maxLifetimeMs: Number(lifetime) }),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/** The longest lifetime a computer of a run may ask for: Morph's TTL and init end it at its deadline, the sweep deletes it. */
|
|
37
|
+
export const CONFORMANCE_MAX_LIFETIME_MS = 30 * 60_000;
|
|
38
|
+
/** For the run's report: what this configuration means for the suite. */
|
|
39
|
+
export const conformanceNotes = [
|
|
40
|
+
"morph: every computer is a Morph instance started from a snapshot (the box snapshot, built in the key's account, unless COMPUTER_MORPH_SNAPSHOT names one), with a TTL whose action is stop, read back from Morph and probed from inside; the daemon is a child, started over SSH through Morph's gateway (ssh.cloud.morph.so, as the instance id with the instance's own key), and every command goes over that SSH. Morph has no egress control: network none, open and a list are all init's. No Archil mount yet and no desktop; no stream(), so screen.stream is skipped.",
|
|
41
|
+
];
|
|
42
|
+
function live(env) {
|
|
43
|
+
if (env[MORPH_ENV.live] !== "1") {
|
|
44
|
+
throw new Error(`the Morph conformance module makes real instances, which bill until deleted: set ${MORPH_ENV.live}=1, with a key for an account you can bill, to run it`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** The test doubles a caller hands in, each only when given. */
|
|
48
|
+
const doubles = ({ ssh2, fetch, timeouts, onNote, sshHost, sshPort }) => ({
|
|
49
|
+
...(ssh2 ? { ssh2 } : {}),
|
|
50
|
+
...(fetch ? { fetch } : {}),
|
|
51
|
+
...(timeouts ? { timeouts } : {}),
|
|
52
|
+
...(onNote ? { onNote } : {}),
|
|
53
|
+
...(sshHost ? { sshHost } : {}),
|
|
54
|
+
...(sshPort ? { sshPort } : {}),
|
|
55
|
+
});
|
|
56
|
+
/** A run's cap: COMPUTER_MORPH_MAX_LIFETIME_MS when it is shorter, else CONFORMANCE_MAX_LIFETIME_MS. */
|
|
57
|
+
const runCap = (settings) => Math.min(settings.maxLifetimeMs ?? CONFORMANCE_MAX_LIFETIME_MS, CONFORMANCE_MAX_LIFETIME_MS);
|
|
58
|
+
/** The provider the CLI runs; throws in words without the live switch, or when a setting is missing or wrong. */
|
|
59
|
+
export async function createProvider(options = {}) {
|
|
60
|
+
const { env = process.env, daemonPath } = options;
|
|
61
|
+
live(env);
|
|
62
|
+
const settings = settingsFromEnv(env);
|
|
63
|
+
return create({ ...settings, ...doubles(options), ...(daemonPath === undefined ? {} : { daemonPath }), maxLifetimeMs: runCap(settings) });
|
|
64
|
+
}
|
|
65
|
+
/** The same provider uploading a daemon that reports version <version>-drift, for the drift.version case. */
|
|
66
|
+
export async function createDriftedProvider(options = {}) {
|
|
67
|
+
const { env = process.env, buildDaemon = (version) => buildDriftDaemon("amd64", version) } = options;
|
|
68
|
+
live(env);
|
|
69
|
+
const settings = settingsFromEnv(env);
|
|
70
|
+
const daemonPath = await buildDaemon(DRIFT_VERSION);
|
|
71
|
+
return create({ ...settings, ...doubles(options), daemonPath, maxLifetimeMs: runCap(settings) });
|
|
72
|
+
}
|
|
73
|
+
/** The run's snapshot: COMPUTER_MORPH_SNAPSHOT, else the box snapshot, found or built in the key's account first (live). */
|
|
74
|
+
export async function conformanceImage(options = {}, { signal } = {}) {
|
|
75
|
+
const { env = process.env } = options;
|
|
76
|
+
const named = env[MORPH_ENV.snapshot];
|
|
77
|
+
if (named)
|
|
78
|
+
return named;
|
|
79
|
+
const ready = await (await createProvider(options)).prepareImage(signal ? { signal } : {});
|
|
80
|
+
if (!ready.ok)
|
|
81
|
+
throw new Error(`the Morph box snapshot: ${ready.error.message}`);
|
|
82
|
+
return ready.value;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* The Morph host the live sweep (sweep.ts) lists and deletes through, from the same settings; it needs no live switch,
|
|
86
|
+
* since the sweep makes nothing, and it calls nothing until the sweep does.
|
|
87
|
+
*/
|
|
88
|
+
export async function createHost(options = {}) {
|
|
89
|
+
return (await create({ ...settingsFromEnv(options.env ?? process.env), ...doubles(options) })).host;
|
|
90
|
+
}
|
|
91
|
+
/** Where the host lists, in words: one key is one account, and one listing covers all of it. The key is named by its sha256 prefix alone. */
|
|
92
|
+
export function sweepScope({ env = process.env } = {}) {
|
|
93
|
+
const { apiKey, apiUrl } = settingsFromEnv(env);
|
|
94
|
+
return accountOf(apiKey, apiUrl);
|
|
95
|
+
}
|
|
@@ -4,7 +4,7 @@
|
|
|
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
|
-
import { randomBytes } from "node:crypto";
|
|
7
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
8
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";
|
|
@@ -235,7 +235,7 @@ function optionsOf({ env = process.env, adb, uiFixture = UI_FIXTURE_APK, ...rest
|
|
|
235
235
|
maxLifetimeMs: RUN_MAX_LIFETIME_MS,
|
|
236
236
|
// The Full ui cases act on the fixture. Without its APK they skip, each saying it is not installed, and the
|
|
237
237
|
// report's notes say why (conformanceNotes).
|
|
238
|
-
apks: existsSync(uiFixture) ? [uiFixture] : [],
|
|
238
|
+
apks: existsSync(uiFixture) ? [{ path: uiFixture, sha256: createHash("sha256").update(readFileSync(uiFixture)).digest("hex") }] : [],
|
|
239
239
|
...rest,
|
|
240
240
|
};
|
|
241
241
|
}
|
|
@@ -85,7 +85,7 @@ function whenAborted(signal) {
|
|
|
85
85
|
*/
|
|
86
86
|
export async function runConformance(provider, options) {
|
|
87
87
|
// Given no cases, the run takes its computer's suite: a browser's own cases, as the CLI does, else the suite's.
|
|
88
|
-
const { image, only, kind, signal, cases = casesFor(provider.capabilities().kind), drifted, planted, mountFor, onResult, notes, caseTimeoutMs = 180_000, patience = 30_000, cleanupTimeoutMs = 60_000, fixture, gpu, long = false, concurrency } = options;
|
|
88
|
+
const { image, only, kind, signal, cases = casesFor(provider.capabilities().kind), drifted, planted, dial, mountFor, onResult, notes, caseTimeoutMs = 180_000, patience = 30_000, cleanupTimeoutMs = 60_000, fixture, gpu, long = false, concurrency } = options;
|
|
89
89
|
if (kind !== undefined && only !== undefined)
|
|
90
90
|
throw new TypeError("a run takes kind and only apart: a kind runs its own cases");
|
|
91
91
|
if (concurrency !== undefined && !(Number.isSafeInteger(concurrency) && concurrency >= 1))
|
|
@@ -569,6 +569,10 @@ export async function runConformance(provider, options) {
|
|
|
569
569
|
plantedBy.add(got.provider);
|
|
570
570
|
return got;
|
|
571
571
|
},
|
|
572
|
+
async dial() {
|
|
573
|
+
t.assert(dial !== undefined, "the provider's machines dial the server, and the run was given no server for them: a conformance module exports dialKit() (ConformanceOptions.dial)");
|
|
574
|
+
return await dial();
|
|
575
|
+
},
|
|
572
576
|
async runFolder(kind) {
|
|
573
577
|
const none = `the run was given no run folder for mount kind ${kind}`;
|
|
574
578
|
if (mountFor === undefined)
|
|
@@ -20,7 +20,7 @@ export interface SweepMachinesOptions {
|
|
|
20
20
|
requestMs?: number;
|
|
21
21
|
/** One whole listing's bound; default 60 s. */
|
|
22
22
|
listMs?: number;
|
|
23
|
-
/** Told, in words, of a machine not deleted or still there. */
|
|
23
|
+
/** Told, in words, of a machine not read, not deleted or still there. */
|
|
24
24
|
onWords?: (words: string) => void;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
@@ -56,7 +56,7 @@ export async function sweepMachines(host, { labels = {}, before = new Set(), wai
|
|
|
56
56
|
return ok({ swept: fresh.length, gone: fresh.length - stillThere.length, stillThere, leftAlone });
|
|
57
57
|
}
|
|
58
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, daytona)
|
|
59
|
+
--provider <id> a provider on the shared machine-host adapter (e2b, agent37, morph, daytona, boxd)
|
|
60
60
|
--before <file> record the id of every machine the vendor lists with ${COMPUTER_LABEL}=1 into <file>
|
|
61
61
|
--after <file> delete every machine listed with ${COMPUTER_LABEL}=1 and ${RUN_LABEL} whose id is not in <file>, read
|
|
62
62
|
each back until the vendor no longer has it (up to 60 s each), and print
|
|
@@ -93,6 +93,8 @@ export interface CaseContext {
|
|
|
93
93
|
readonly declared: readonly KindCapabilities[] | undefined;
|
|
94
94
|
/** The provider built with planted secrets (ConformanceOptions.planted); skips the case when none was given. */
|
|
95
95
|
planted(): Promise<PlantedProvider>;
|
|
96
|
+
/** The server a dial host's machines reach (ConformanceOptions.dial); fails the case when none was given. */
|
|
97
|
+
dial(): Promise<DialKit>;
|
|
96
98
|
/** A fresh run's folder for this mount kind, closed when the case ends; skips the case when the run can make none. */
|
|
97
99
|
runFolder(kind: MountKind): Promise<RunFolder>;
|
|
98
100
|
/** The GPU the run pays for (options.gpu, the CLI's --gpu); skips the case when the run names none. */
|
|
@@ -266,6 +268,23 @@ export interface ComputerDaemon {
|
|
|
266
268
|
arch: string;
|
|
267
269
|
fence?: NetworkFence;
|
|
268
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* The server a dial host's machines reach (MachineHost facts.connect "dial"), as the run stands it up: its machine
|
|
273
|
+
* tokens and its attach route, for provider.dial-token.
|
|
274
|
+
*/
|
|
275
|
+
export interface DialKit {
|
|
276
|
+
/** The machine (computer name) a token is good for at a time, as the server's attach route reads it; undefined: refused. */
|
|
277
|
+
check(token: string, at: Date): Promise<string | undefined> | string | undefined;
|
|
278
|
+
/** The token a computer's machine was given at its create (its AGENTRUN_ATTACH_TOKEN). */
|
|
279
|
+
token(ref: ComputerRef): string | undefined;
|
|
280
|
+
/** Dials the server's attach route with a token and answers its hello with this one: the code the socket closed with. */
|
|
281
|
+
dialAs(token: string, hello: HelloResult): Promise<number | undefined>;
|
|
282
|
+
/** The same provider with no public address, and how many creates its host has been asked for since. */
|
|
283
|
+
unreachable(): {
|
|
284
|
+
provider: ComputerProvider;
|
|
285
|
+
creates(): number;
|
|
286
|
+
};
|
|
287
|
+
}
|
|
269
288
|
/** A provider built with planted secrets, and the values planted: none of them may show in anything it answers. */
|
|
270
289
|
export interface PlantedProvider {
|
|
271
290
|
provider: ComputerProvider;
|
|
@@ -296,6 +315,8 @@ export interface ConformanceOptions {
|
|
|
296
315
|
* values, for health.no-key-in-errors. Without it (a provider that takes no secret), that case skips.
|
|
297
316
|
*/
|
|
298
317
|
planted?: () => Promise<PlantedProvider> | PlantedProvider;
|
|
318
|
+
/** The server a dial host's machines reach, for provider.dial-token: a dial host's run fails that case without it. */
|
|
319
|
+
dial?: () => Promise<DialKit> | DialKit;
|
|
299
320
|
/**
|
|
300
321
|
* A fresh run's folder for a mount kind, for the mount cases: the provider's conformance module makes it (a folder on
|
|
301
322
|
* the Docker host for a bind), or gives undefined for a kind it cannot make. Without it, those cases skip in words.
|