@parcha/agentrun-computer 0.1.0-beta.35 → 0.1.0-beta.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +2 -0
- package/README.md +423 -323
- package/box/Dockerfile +3 -1
- package/box/agentrun-archil +59 -7
- package/box/build-agent37.mjs +177 -0
- package/box/build-daytona.py +20 -4
- package/dist/agent37.d.ts +165 -0
- package/dist/agent37.js +759 -0
- package/dist/attach.d.ts +146 -0
- package/dist/attach.js +469 -0
- package/dist/browser.d.ts +61 -10
- package/dist/browser.js +125 -3
- package/dist/browserbase.d.ts +46 -23
- package/dist/browserbase.js +162 -17
- package/dist/chrome.d.ts +3 -4
- package/dist/chrome.js +6 -11
- package/dist/client.d.ts +33 -1
- package/dist/client.js +53 -0
- package/dist/computerd-linux-amd64 +0 -0
- package/dist/computerd-linux-arm64 +0 -0
- package/dist/conformance/agent37.d.ts +96 -0
- package/dist/conformance/agent37.js +154 -0
- package/dist/conformance/cases/apps.d.ts +5 -0
- package/dist/conformance/cases/apps.js +160 -73
- package/dist/conformance/cases/health.js +14 -0
- package/dist/conformance/cases/index.js +2 -0
- package/dist/conformance/cases/provider.js +27 -1
- package/dist/conformance/cases/screen.d.ts +3 -0
- package/dist/conformance/cases/screen.js +18 -0
- package/dist/conformance/cases/settings.d.ts +29 -23
- package/dist/conformance/cases/settings.js +76 -58
- package/dist/conformance/cases/touch.js +19 -17
- package/dist/conformance/cases/ui.d.ts +2 -0
- package/dist/conformance/cases/ui.js +475 -0
- package/dist/conformance/cli.d.ts +9 -0
- package/dist/conformance/cli.js +28 -3
- package/dist/conformance/daytona.d.ts +4 -0
- package/dist/conformance/daytona.js +5 -0
- package/dist/conformance/e2b.d.ts +6 -0
- package/dist/conformance/e2b.js +9 -2
- package/dist/conformance/fixture.d.ts +1 -1
- package/dist/conformance/fixture.js +25 -1
- package/dist/conformance/modal.d.ts +17 -13
- package/dist/conformance/modal.js +18 -9
- package/dist/conformance/orgo.d.ts +3 -3
- package/dist/conformance/orgo.js +6 -8
- package/dist/conformance/phone-harness.d.ts +6 -2
- package/dist/conformance/phone-harness.js +21 -4
- package/dist/conformance/report.js +1 -1
- package/dist/conformance/runner.js +23 -4
- package/dist/conformance/sweep.d.ts +50 -0
- package/dist/conformance/sweep.js +187 -0
- package/dist/conformance/types.d.ts +11 -3
- package/dist/conformance/ui-fixture.d.ts +56 -0
- package/dist/conformance/ui-fixture.js +43 -0
- package/dist/create-requests.d.ts +51 -0
- package/dist/create-requests.js +121 -0
- package/dist/daytona.d.ts +15 -5
- package/dist/daytona.js +58 -38
- package/dist/descriptor.d.ts +29 -2
- package/dist/descriptor.js +13 -0
- package/dist/descriptors/agent37.d.ts +41 -0
- package/dist/descriptors/agent37.js +28 -0
- package/dist/descriptors/browserbase.d.ts +1 -0
- package/dist/descriptors/browserbase.js +2 -0
- package/dist/descriptors/daytona.d.ts +23 -2
- package/dist/descriptors/daytona.js +34 -2
- package/dist/descriptors/index.d.ts +66 -3
- package/dist/descriptors/index.js +5 -3
- package/dist/descriptors/kernel.d.ts +1 -0
- package/dist/descriptors/kernel.js +2 -0
- package/dist/descriptors/modal.d.ts +4 -0
- package/dist/descriptors/modal.js +11 -1
- package/dist/descriptors/orgo.d.ts +13 -1
- package/dist/descriptors/orgo.js +9 -3
- package/dist/descriptors/phone-harness.d.ts +6 -1
- package/dist/descriptors/phone-harness.js +5 -2
- package/dist/docker/egress.d.ts +4 -3
- package/dist/docker/egress.js +7 -6
- package/dist/docker.d.ts +7 -4
- package/dist/docker.js +278 -34
- package/dist/e2b.d.ts +9 -165
- package/dist/e2b.js +282 -1342
- package/dist/fake-ui-driver.d.ts +97 -0
- package/dist/fake-ui-driver.js +717 -0
- package/dist/host.d.ts +182 -0
- package/dist/host.js +1 -0
- package/dist/hosted/process.d.ts +67 -0
- package/dist/hosted/process.js +228 -0
- package/dist/hosted/provider.d.ts +146 -0
- package/dist/hosted/provider.js +1364 -0
- package/dist/hosted/scripts.d.ts +76 -0
- package/dist/{child.js → hosted/scripts.js} +93 -12
- package/dist/index.d.ts +11 -7
- package/dist/index.js +10 -7
- package/dist/janitor.d.ts +5 -4
- package/dist/janitor.js +1 -1
- package/dist/kernel.d.ts +17 -27
- package/dist/kernel.js +94 -18
- package/dist/kinds.d.ts +17 -5
- package/dist/kinds.js +20 -4
- package/dist/labels.d.ts +10 -2
- package/dist/labels.js +30 -7
- package/dist/local-chrome.d.ts +5 -5
- package/dist/local-chrome.js +10 -5
- package/dist/modal.d.ts +23 -181
- package/dist/modal.js +273 -1232
- package/dist/mount-archil.d.ts +25 -3
- package/dist/mount-archil.js +39 -8
- package/dist/orgo-channel.d.ts +3 -2
- package/dist/orgo-channel.js +5 -2
- package/dist/orgo-desktop.d.ts +23 -9
- package/dist/orgo-desktop.js +328 -66
- package/dist/orgo-names.d.ts +129 -3
- package/dist/orgo-names.js +211 -8
- package/dist/orgo-workspaces.d.ts +47 -0
- package/dist/orgo-workspaces.js +94 -0
- package/dist/orgo.d.ts +27 -10
- package/dist/orgo.js +411 -81
- package/dist/phone-harness.d.ts +31 -21
- package/dist/phone-harness.js +510 -681
- package/dist/png.d.ts +4 -0
- package/dist/png.js +27 -0
- package/dist/protocol.d.ts +338 -30
- package/dist/protocol.js +96 -3
- package/dist/provider.d.ts +97 -7
- package/dist/provider.js +24 -3
- package/dist/result.d.ts +1 -1
- package/dist/surface/api.d.ts +248 -0
- package/dist/surface/api.js +1 -0
- package/dist/surface/core.d.ts +42 -0
- package/dist/surface/core.js +393 -0
- package/dist/surface/index.d.ts +5 -0
- package/dist/surface/index.js +3 -0
- package/dist/surface/outline.d.ts +8 -0
- package/dist/surface/outline.js +50 -0
- package/dist/surface/script.d.ts +10 -0
- package/dist/surface/script.js +92 -0
- package/dist/ui-engine.d.ts +114 -0
- package/dist/ui-engine.js +798 -0
- package/package.json +17 -1
- package/dist/child.d.ts +0 -42
- package/dist/conformance/e2b-diagnose.d.ts +0 -16
- package/dist/conformance/e2b-diagnose.js +0 -61
- package/dist/conformance/e2b-sweep.d.ts +0 -18
- package/dist/conformance/e2b-sweep.js +0 -132
- package/dist/conformance/modal-sweep.d.ts +0 -22
- package/dist/conformance/modal-sweep.js +0 -213
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcha/agentrun-computer",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.37",
|
|
4
4
|
"description": "The open platform's computer protocol: a daemon in every computer, and one provisioner per vendor, starting with Docker.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentrun",
|
|
@@ -26,6 +26,10 @@
|
|
|
26
26
|
"types": "./dist/mount.d.ts",
|
|
27
27
|
"default": "./dist/mount.js"
|
|
28
28
|
},
|
|
29
|
+
"./fake-ui-driver": {
|
|
30
|
+
"types": "./dist/fake-ui-driver.d.ts",
|
|
31
|
+
"default": "./dist/fake-ui-driver.js"
|
|
32
|
+
},
|
|
29
33
|
"./docker": {
|
|
30
34
|
"types": "./dist/docker.d.ts",
|
|
31
35
|
"default": "./dist/docker.js"
|
|
@@ -42,6 +46,10 @@
|
|
|
42
46
|
"types": "./dist/e2b.d.ts",
|
|
43
47
|
"default": "./dist/e2b.js"
|
|
44
48
|
},
|
|
49
|
+
"./agent37": {
|
|
50
|
+
"types": "./dist/agent37.d.ts",
|
|
51
|
+
"default": "./dist/agent37.js"
|
|
52
|
+
},
|
|
45
53
|
"./orgo": {
|
|
46
54
|
"types": "./dist/orgo.d.ts",
|
|
47
55
|
"default": "./dist/orgo.js"
|
|
@@ -66,6 +74,10 @@
|
|
|
66
74
|
"types": "./dist/local-chrome.d.ts",
|
|
67
75
|
"default": "./dist/local-chrome.js"
|
|
68
76
|
},
|
|
77
|
+
"./surface": {
|
|
78
|
+
"types": "./dist/surface/index.d.ts",
|
|
79
|
+
"default": "./dist/surface/index.js"
|
|
80
|
+
},
|
|
69
81
|
"./package.json": "./package.json"
|
|
70
82
|
},
|
|
71
83
|
"files": [
|
|
@@ -79,6 +91,10 @@
|
|
|
79
91
|
"scripts": {
|
|
80
92
|
"build": "tsc -p tsconfig.json",
|
|
81
93
|
"build:daemon": "node scripts/build-daemon.mjs",
|
|
94
|
+
"build:phoned": "node scripts/build-phoned.mjs",
|
|
95
|
+
"build:ui-fixture": "node scripts/build-ui-fixture.mjs",
|
|
96
|
+
"check:phoned": "node scripts/check-phoned-jar.mjs",
|
|
97
|
+
"test:phoned": "node scripts/build-phoned.mjs --test && node scripts/build-phoned.mjs --fake && node --test test/phoned/*.test.mjs",
|
|
82
98
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
83
99
|
"test": "node --test test/*.test.mjs",
|
|
84
100
|
"test:docker": "node --test --test-timeout=900000 test/docker/*.test.mjs",
|
package/dist/child.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { ComputerCapabilities, ComputerConnection } from "./provider.js";
|
|
2
|
-
import { type Result } from "./result.js";
|
|
3
|
-
/** Who ran install, from its output's `installer <uid> <name>[ sudo]` line, in words; undefined when it has none. */
|
|
4
|
-
export declare function installerOf(output: string): string | undefined;
|
|
5
|
-
/** One string for a shell: `sh -c '<script>' sh '<arg>' ...`, every word quoted. */
|
|
6
|
-
export declare const shellCommand: (script: string, args: readonly string[]) => string;
|
|
7
|
-
export interface ChildCommandOptions {
|
|
8
|
-
/** Where the vendor's upload left the daemon. */
|
|
9
|
-
staging?: string;
|
|
10
|
-
/** Init's deadline, an ISO time. */
|
|
11
|
-
deadline?: string;
|
|
12
|
-
/** Who the daemon becomes, uid:gid in numbers. */
|
|
13
|
-
user?: string;
|
|
14
|
-
/** The X display init's screen and input methods drive (its DISPLAY); none for a computer with no screen. */
|
|
15
|
-
display?: string;
|
|
16
|
-
/** The most deadline.extend may move the deadline to, an ISO time; none, and the deadline cannot move. */
|
|
17
|
-
maxDeadline?: string;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* The three shell commands a child-daemon provider sends into a computer, exactly: install (the upload moved into place,
|
|
21
|
-
* its sha256 printed), init (long-lived) and stdio (one per connection). Each is one string for a shell, `sh -c` with
|
|
22
|
-
* every argument quoted.
|
|
23
|
-
*/
|
|
24
|
-
export declare function childCommands({ staging, deadline, user, display, maxDeadline }?: ChildCommandOptions): {
|
|
25
|
-
install: string;
|
|
26
|
-
init: string;
|
|
27
|
-
stdio: string;
|
|
28
|
-
};
|
|
29
|
-
export interface DaemonExpected {
|
|
30
|
-
version: string;
|
|
31
|
-
uid: string;
|
|
32
|
-
gid: string;
|
|
33
|
-
arch: string;
|
|
34
|
-
kind: ComputerCapabilities["kind"];
|
|
35
|
-
groups: ComputerCapabilities["groups"];
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* What the daemon reports of itself, read back through it: hello, its credentials (no capability in any set,
|
|
39
|
-
* no_new_privs, no groups, a seccomp filter), its network (its own loopback alone, from its /proc/self/net/dev), its
|
|
40
|
-
* working directory and binary. Each read is bounded by timeoutMs and the caller's signal.
|
|
41
|
-
*/
|
|
42
|
-
export declare function daemonDrift(connection: ComputerConnection, expected: DaemonExpected, timeoutMs: number, signal?: AbortSignal): Promise<Result<string[]>>;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { type E2BOptions } from "../e2b.js";
|
|
2
|
-
/** A stream as main writes to it: done is called once the text is handed on. */
|
|
3
|
-
export interface Writer {
|
|
4
|
-
write(text: string, done?: (error?: Error | null) => void): unknown;
|
|
5
|
-
}
|
|
6
|
-
export interface DiagnoseIo extends Pick<E2BOptions, "Sandbox" | "daemonPath" | "timeouts"> {
|
|
7
|
-
/** Where the settings are read; default process.env. */
|
|
8
|
-
env?: Record<string, string | undefined>;
|
|
9
|
-
stdout?: Writer;
|
|
10
|
-
stderr?: Writer;
|
|
11
|
-
/** Aborts the diagnostic: the sandbox is still killed and read back gone. */
|
|
12
|
-
signal?: AbortSignal;
|
|
13
|
-
/** The longest the diagnostic runs before it aborts itself; default 8 minutes, inside the sandbox's 10. */
|
|
14
|
-
boundMs?: number;
|
|
15
|
-
}
|
|
16
|
-
export declare function main(argv: string[], io?: DiagnoseIo): Promise<number>;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
// The E2B network diagnostic, run once by hand with a key the lead has OKed:
|
|
2
|
-
//
|
|
3
|
-
// AGENTRUN_COMPUTER_LIVE_E2B=1 COMPUTER_E2B_API_KEY=... node packages/computer/dist/conformance/e2b-diagnose.js
|
|
4
|
-
//
|
|
5
|
-
// E2B documents that its firewall accepts an outbound TCP connection before it decides whether the destination is
|
|
6
|
-
// allowed, so from inside a sandbox with no internet access a connection can succeed while nothing reaches the
|
|
7
|
-
// destination (docs.e2b.dev network/internet-access, "Behavior of blocked TCP connections"). The provider's network-none
|
|
8
|
-
// probe refuses only on an answer and records an accept with nothing back in its notes. This makes ONE sandbox exactly as the provider makes one for network
|
|
9
|
-
// none (diagnoseNetworkNone in ../e2b.ts: the same create options, read-back, upload and sha256 check), runs
|
|
10
|
-
// `computerd probe --diagnose` in it (per well-known public address and port: refused, accepted with no answer, or
|
|
11
|
-
// answered), prints one JSON line, then kills the sandbox and reads it back gone, on an error and on an abort (SIGINT,
|
|
12
|
-
// SIGTERM, or the run's own 8-minute bound) too. Its E2B timeout is 10 minutes. It changes nothing in the provider.
|
|
13
|
-
//
|
|
14
|
-
// Settings are the conformance module's (COMPUTER_E2B_API_KEY, COMPUTER_E2B_DOMAIN, COMPUTER_E2B_KIND,
|
|
15
|
-
// COMPUTER_E2B_DAEMON and the rest settingsFromEnv reads; never E2B_API_KEY), passed to the provider's create(), and the
|
|
16
|
-
// template is COMPUTER_E2B_TEMPLATE as for conformance (default "desktop"). The live switch is checked before any of
|
|
17
|
-
// them is read. Exit 0 when a diagnosis came back and the sandbox reads gone, 1 otherwise, 2 on a usage error, no live
|
|
18
|
-
// switch, or a setting the provider refuses (nothing is made then).
|
|
19
|
-
import { create, diagnoseNetworkNone } from "../e2b.js";
|
|
20
|
-
import { isCommand } from "../entry.js";
|
|
21
|
-
import { conformanceImage, E2B_ENV, settingsFromEnv } from "./e2b.js";
|
|
22
|
-
const USAGE = `usage: ${E2B_ENV.live}=1 ${E2B_ENV.key}=<key> node packages/computer/dist/conformance/e2b-diagnose.js
|
|
23
|
-
makes one E2B sandbox as the provider makes one for network none, runs computerd probe --diagnose in it, prints one
|
|
24
|
-
JSON line, and kills the sandbox and reads it back gone. It takes no argument; the template is ${E2B_ENV.template}.
|
|
25
|
-
exit: 0 diagnosed and gone, 1 otherwise, 2 usage error, no live switch, or a refused setting`;
|
|
26
|
-
const BOUND_MS = 8 * 60_000;
|
|
27
|
-
const write = (stream, text) => new Promise((resolve) => void stream.write(text, () => resolve()));
|
|
28
|
-
export async function main(argv, io = {}) {
|
|
29
|
-
const { env = process.env, stdout = process.stdout, stderr = process.stderr, boundMs = BOUND_MS } = io;
|
|
30
|
-
if (env[E2B_ENV.live] !== "1") {
|
|
31
|
-
await write(stderr, `the E2B network diagnostic makes a real sandbox: set ${E2B_ENV.live}=1, with a key the lead has OKed, to run it\n`);
|
|
32
|
-
return 2;
|
|
33
|
-
}
|
|
34
|
-
if (argv.length > 0) {
|
|
35
|
-
await write(stderr, `it takes no argument, not ${argv.join(" ")}\n${USAGE}\n`);
|
|
36
|
-
return 2;
|
|
37
|
-
}
|
|
38
|
-
const key = env[E2B_ENV.key] ?? "";
|
|
39
|
-
// Nothing the SDK or E2B says reaches an output with the key in it.
|
|
40
|
-
const clean = (text) => (key === "" ? text : text.split(key).join("[key]"));
|
|
41
|
-
let provider;
|
|
42
|
-
try {
|
|
43
|
-
provider = await create({ ...settingsFromEnv(env), ...(io.Sandbox ? { Sandbox: io.Sandbox } : {}), ...(io.daemonPath === undefined ? {} : { daemonPath: io.daemonPath }), ...(io.timeouts ? { timeouts: io.timeouts } : {}) });
|
|
44
|
-
}
|
|
45
|
-
catch (error) {
|
|
46
|
-
await write(stderr, `${clean(error.message)}\n`);
|
|
47
|
-
return 2;
|
|
48
|
-
}
|
|
49
|
-
const signal = AbortSignal.any([AbortSignal.timeout(boundMs), ...(io.signal ? [io.signal] : [])]);
|
|
50
|
-
const report = await diagnoseNetworkNone(provider, { image: conformanceImage({ env }), signal });
|
|
51
|
-
await write(stdout, `${clean(JSON.stringify(report))}\n`);
|
|
52
|
-
if (!report.released.gone)
|
|
53
|
-
await write(stderr, `the sandbox was not read back gone: ${clean(report.released.words)}\n`);
|
|
54
|
-
return report.diagnosis !== undefined && report.released.gone ? 0 : 1;
|
|
55
|
-
}
|
|
56
|
-
if (isCommand(import.meta)) {
|
|
57
|
-
const controller = new AbortController();
|
|
58
|
-
for (const name of ["SIGINT", "SIGTERM"])
|
|
59
|
-
process.once(name, () => controller.abort());
|
|
60
|
-
process.exitCode = await main(process.argv.slice(2), { signal: controller.signal });
|
|
61
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { type E2BSandboxClass } from "../e2b.js";
|
|
2
|
-
/** A stream as main writes to it: done is called once the text is handed on. */
|
|
3
|
-
export interface Writer {
|
|
4
|
-
write(text: string, done?: (error?: Error | null) => void): unknown;
|
|
5
|
-
}
|
|
6
|
-
export interface SweepIo {
|
|
7
|
-
/** Where the settings are read; default process.env. */
|
|
8
|
-
env?: Record<string, string | undefined>;
|
|
9
|
-
/** The SDK's Sandbox class; imported from the host's e2b package by default. */
|
|
10
|
-
Sandbox?: E2BSandboxClass;
|
|
11
|
-
stdout?: Writer;
|
|
12
|
-
stderr?: Writer;
|
|
13
|
-
/** How long --after reads one killed sandbox back before it counts as still there; default 60 s. */
|
|
14
|
-
waitMs?: number;
|
|
15
|
-
/** The pause between two reads of one sandbox; default 2 s. */
|
|
16
|
-
pollMs?: number;
|
|
17
|
-
}
|
|
18
|
-
export declare function main(argv: string[], io?: SweepIo): Promise<number>;
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
// The sweep around a live E2B run, with the provider's settings (COMPUTER_E2B_*, never E2B_*):
|
|
2
|
-
//
|
|
3
|
-
// node packages/computer/dist/conformance/e2b-sweep.js --before <file>
|
|
4
|
-
// node packages/computer/dist/conformance/e2b-sweep.js --after <file>
|
|
5
|
-
//
|
|
6
|
-
// --before records into <file> the id of every sandbox E2B lists with the provider's label agentrun.computer=1
|
|
7
|
-
// (Sandbox.list with that metadata, running and paused ones: e2b@2.63.0 dist/index.mjs:5974-5986, 5793-5835). --after
|
|
8
|
-
// lists them again, kills (Sandbox.kill) every one whose id is not in <file> and whose metadata carries a conformance
|
|
9
|
-
// run's label (agentrun.conformance, RUN_LABEL), then reads each of those back with getInfo until E2B no longer has it
|
|
10
|
-
// (SandboxNotFoundError, index.mjs:5431) and no longer lists it, up to 60 s each, and prints one JSON line,
|
|
11
|
-
// {"swept":n,"gone":m,"stillThere":[ids],"leftAlone":k}: swept is every conformance sandbox it found that was not there
|
|
12
|
-
// before, gone + stillThere.length = swept, and leftAlone counts the new labelled sandboxes with no conformance label,
|
|
13
|
-
// which another user of the account made during the run: never touched. A sandbox in <file> is never touched either:
|
|
14
|
-
// no call names it. Exit 0 when every swept sandbox is gone, 1 when one is still there, 2 on a usage error, a before
|
|
15
|
-
// file it cannot read, a missing key, or a listing E2B refused (nothing is killed then).
|
|
16
|
-
//
|
|
17
|
-
// It reads COMPUTER_E2B_API_KEY and COMPUTER_E2B_DOMAIN as the conformance module does (settingsFromEnv in ./e2b.ts)
|
|
18
|
-
// and builds the provider with create(): the key passed to every SDK call explicitly, an ambient E2B_SANDBOX_URL
|
|
19
|
-
// refused. It needs no AGENTRUN_COMPUTER_LIVE_E2B: it makes nothing.
|
|
20
|
-
import { readFileSync, writeFileSync } from "node:fs";
|
|
21
|
-
import { COMPUTER_LABEL } from "../drift.js";
|
|
22
|
-
import { create } from "../e2b.js";
|
|
23
|
-
import { isCommand } from "../entry.js";
|
|
24
|
-
import { E2B_ENV as ENV, settingsFromEnv } from "./e2b.js";
|
|
25
|
-
import { RUN_LABEL } from "./runner.js";
|
|
26
|
-
import { waitUntil } from "../wait.js";
|
|
27
|
-
const USAGE = `usage: node packages/computer/dist/conformance/e2b-sweep.js --before <file> | --after <file>
|
|
28
|
-
--before <file> record the id of every sandbox E2B lists with ${COMPUTER_LABEL}=1 into <file>
|
|
29
|
-
--after <file> kill every sandbox listed with ${COMPUTER_LABEL}=1 and ${RUN_LABEL} whose id is not in <file>, read
|
|
30
|
-
each back until E2B no longer has it (up to 60 s each), and print
|
|
31
|
-
{"swept":n,"gone":m,"stillThere":[ids],"leftAlone":k}; a new one with no ${RUN_LABEL} is left alone
|
|
32
|
-
settings: ${ENV.key} (required) and ${ENV.domain}, as the conformance module reads them; never E2B_API_KEY
|
|
33
|
-
exit: 0 every swept sandbox is gone, 1 one is still there, 2 usage error, unreadable before file, no key, or a refused listing`;
|
|
34
|
-
class Usage extends Error {
|
|
35
|
-
}
|
|
36
|
-
const write = (stream, text) => new Promise((resolve) => void stream.write(text, () => resolve()));
|
|
37
|
-
function parse(argv) {
|
|
38
|
-
let found;
|
|
39
|
-
for (let i = 0; i < argv.length; i++) {
|
|
40
|
-
const [flag = "", inline] = (argv[i] ?? "").split(/=(.*)/s, 2);
|
|
41
|
-
if (flag !== "--before" && flag !== "--after")
|
|
42
|
-
throw new Usage(`unknown option ${flag}`);
|
|
43
|
-
const file = inline ?? argv[++i];
|
|
44
|
-
if (file === undefined || file === "" || file.startsWith("--"))
|
|
45
|
-
throw new Usage(`${flag} needs a file`);
|
|
46
|
-
if (found !== undefined)
|
|
47
|
-
throw new Usage("give --before <file> or --after <file>, one of them");
|
|
48
|
-
found = { mode: flag === "--before" ? "before" : "after", file };
|
|
49
|
-
}
|
|
50
|
-
if (found === undefined)
|
|
51
|
-
throw new Usage("give --before <file> or --after <file>, one of them");
|
|
52
|
-
return found;
|
|
53
|
-
}
|
|
54
|
-
/** The ids a before file holds, or why it is not one. */
|
|
55
|
-
function beforeIds(file) {
|
|
56
|
-
let text;
|
|
57
|
-
try {
|
|
58
|
-
text = readFileSync(file, "utf8");
|
|
59
|
-
}
|
|
60
|
-
catch (error) {
|
|
61
|
-
throw new Usage(`cannot read the before file ${file}: ${error.message}`);
|
|
62
|
-
}
|
|
63
|
-
let record;
|
|
64
|
-
try {
|
|
65
|
-
record = JSON.parse(text);
|
|
66
|
-
}
|
|
67
|
-
catch {
|
|
68
|
-
record = undefined;
|
|
69
|
-
}
|
|
70
|
-
const ids = record?.ids;
|
|
71
|
-
if (!Array.isArray(ids) || !ids.every((id) => typeof id === "string" && id !== ""))
|
|
72
|
-
throw new Usage(`${file} is not a before file: it holds no "ids" array of sandbox ids`);
|
|
73
|
-
return new Set(ids);
|
|
74
|
-
}
|
|
75
|
-
export async function main(argv, io = {}) {
|
|
76
|
-
const { env = process.env, stdout = process.stdout, stderr = process.stderr, waitMs = 60_000, pollMs = 2_000 } = io;
|
|
77
|
-
let args;
|
|
78
|
-
let before;
|
|
79
|
-
let provider;
|
|
80
|
-
try {
|
|
81
|
-
args = parse(argv);
|
|
82
|
-
if (args.mode === "after")
|
|
83
|
-
before = beforeIds(args.file);
|
|
84
|
-
provider = await create({ ...settingsFromEnv(env), ...(io.Sandbox ? { Sandbox: io.Sandbox } : {}), timeouts: { goneMs: waitMs, pollMs } });
|
|
85
|
-
}
|
|
86
|
-
catch (error) {
|
|
87
|
-
await write(stderr, `${error.message}\n${error instanceof Usage ? `${USAGE}\n` : ""}`);
|
|
88
|
-
return 2;
|
|
89
|
-
}
|
|
90
|
-
const listed = await provider.listLabelled();
|
|
91
|
-
if (!listed.ok) {
|
|
92
|
-
await write(stderr, `listing the sandboxes carrying ${COMPUTER_LABEL}=1 failed, so nothing was ${args.mode === "after" ? "killed" : "recorded"}: ${listed.error.message}\n`);
|
|
93
|
-
return 2;
|
|
94
|
-
}
|
|
95
|
-
if (before === undefined) {
|
|
96
|
-
const ids = listed.value.map((sb) => sb.id).sort();
|
|
97
|
-
writeFileSync(args.file, `${JSON.stringify({ label: `${COMPUTER_LABEL}=1`, at: new Date().toISOString(), ids }, null, 2)}\n`);
|
|
98
|
-
await write(stdout, `${JSON.stringify({ recorded: ids.length, file: args.file })}\n`);
|
|
99
|
-
return 0;
|
|
100
|
-
}
|
|
101
|
-
const known = before;
|
|
102
|
-
const added = listed.value.filter((sb) => !known.has(sb.id));
|
|
103
|
-
// Only a conformance run's computers: one another user of the account made during the run is not this sweep's.
|
|
104
|
-
const fresh = added.filter((sb) => Object.hasOwn(sb.labels, RUN_LABEL)).map((sb) => sb.id);
|
|
105
|
-
const leftAlone = added.length - fresh.length;
|
|
106
|
-
for (const id of fresh) {
|
|
107
|
-
const killed = await provider.killById(id);
|
|
108
|
-
if (!killed.ok)
|
|
109
|
-
await write(stderr, `${id} was not killed: ${killed.error.message}\n`);
|
|
110
|
-
}
|
|
111
|
-
// Each read back on its own, at once: gone once getInfo no longer finds it and the label listing no longer shows it.
|
|
112
|
-
const gone = await Promise.all(fresh.map(async (id) => {
|
|
113
|
-
const waited = await waitUntil(async () => {
|
|
114
|
-
const read = await provider.probeGone(id);
|
|
115
|
-
if (!read.ok || !read.value.gone)
|
|
116
|
-
return read.ok ? `E2B reads it ${read.value.state}` : read.error.message;
|
|
117
|
-
const again = await provider.listLabelled();
|
|
118
|
-
if (!again.ok)
|
|
119
|
-
return again.error.message;
|
|
120
|
-
return again.value.some((sb) => sb.id === id) ? "still listed" : "gone";
|
|
121
|
-
}, (state) => state === "gone", { boundMs: waitMs, minMs: pollMs, maxMs: pollMs, what: `${id} to be gone after its kill`, describe: (state) => state });
|
|
122
|
-
if (!waited.ok)
|
|
123
|
-
await write(stderr, `${id} is still there after ${waitMs / 1000} s: ${waited.error.message}\n`);
|
|
124
|
-
return waited.ok;
|
|
125
|
-
}));
|
|
126
|
-
const stillThere = fresh.filter((_, i) => !gone[i]);
|
|
127
|
-
await write(stdout, `${JSON.stringify({ swept: fresh.length, gone: fresh.length - stillThere.length, stillThere, leftAlone })}\n`);
|
|
128
|
-
return stillThere.length === 0 ? 0 : 1;
|
|
129
|
-
}
|
|
130
|
-
if (isCommand(import.meta)) {
|
|
131
|
-
process.exitCode = await main(process.argv.slice(2));
|
|
132
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { type ModalClientConstructor } from "../modal.js";
|
|
2
|
-
/** A stream as main writes to it: done is called once the text is handed on. */
|
|
3
|
-
export interface Writer {
|
|
4
|
-
write(text: string, done?: (error?: Error | null) => void): unknown;
|
|
5
|
-
}
|
|
6
|
-
export interface SweepIo {
|
|
7
|
-
/** Where the settings are read; default process.env. */
|
|
8
|
-
env?: Record<string, string | undefined>;
|
|
9
|
-
/** The SDK's ModalClient; imported from the host's modal package by default. */
|
|
10
|
-
ModalClient?: ModalClientConstructor;
|
|
11
|
-
stdout?: Writer;
|
|
12
|
-
stderr?: Writer;
|
|
13
|
-
/** How long --after reads one terminated sandbox back before it counts as still there; default 60 s. */
|
|
14
|
-
waitMs?: number;
|
|
15
|
-
/** The pause between two reads of one sandbox; default 2 s. */
|
|
16
|
-
pollMs?: number;
|
|
17
|
-
/** One SDK call (apps.fromName, fromId, terminate, poll); default 60 s. */
|
|
18
|
-
callMs?: number;
|
|
19
|
-
/** The whole listing, every page; default 120 s. */
|
|
20
|
-
listMs?: number;
|
|
21
|
-
}
|
|
22
|
-
export declare function main(argv: string[], io?: SweepIo): Promise<number>;
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
// The sweep around a live Modal run, with the provider's settings and client (COMPUTER_MODAL_*, never MODAL_*):
|
|
2
|
-
//
|
|
3
|
-
// node packages/computer/dist/conformance/modal-sweep.js --before <file>
|
|
4
|
-
// node packages/computer/dist/conformance/modal-sweep.js --after <file>
|
|
5
|
-
//
|
|
6
|
-
// --before records into <file> the app and server it listed, and the id of every sandbox in the app COMPUTER_MODAL_APP
|
|
7
|
-
// that carries the provider's tag
|
|
8
|
-
// agentrun.computer=1: sandboxes.list({ appId, tags }) returns those with at least those tags, and running ones only
|
|
9
|
-
// (modal-client@64880502:js/src/sandbox.ts:1116-1159, includeFinished: false), so a finished sandbox is in neither list
|
|
10
|
-
// and needs no sweep. --after refuses a file whose app or server is not the one the environment names now, or that
|
|
11
|
-
// names none, before it lists anything: another app's computers would all read as new. Otherwise it lists them again,
|
|
12
|
-
// reads the tags of every one whose id is not in <file> (getTags: a list filters by exact tag values, and a run's label
|
|
13
|
-
// differs per run), terminates each that carries a conformance run's label (agentrun.conformance, RUN_LABEL), then
|
|
14
|
-
// reads each of those back with sandboxes.fromId and poll (sandbox.ts:960-962, 2766-2772; poll is null while it runs)
|
|
15
|
-
// until it reports an exit code, or Modal no longer knows it, up to 60 s each, and prints one JSON line,
|
|
16
|
-
// {"swept":n,"gone":m,"stillThere":[ids],"leftAlone":k}: swept is every conformance sandbox it found that was not there
|
|
17
|
-
// before, gone + stillThere.length = swept, and leftAlone counts the new tagged sandboxes it did not terminate: no
|
|
18
|
-
// conformance label (another user of the app made them during the run), or tags it could not read (said on stderr).
|
|
19
|
-
// A sandbox in <file> is never touched: no call names it. Exit 0 when every swept sandbox has finished, 1 when one still
|
|
20
|
-
// runs, 2 on a usage error, a before file it cannot read or of another app or server, a missing token or app, or a
|
|
21
|
-
// listing Modal refused (nothing is terminated then).
|
|
22
|
-
//
|
|
23
|
-
// It reads COMPUTER_MODAL_TOKEN_ID, COMPUTER_MODAL_TOKEN_SECRET, COMPUTER_MODAL_APP and COMPUTER_MODAL_SERVER_URL as the
|
|
24
|
-
// conformance module does (settingsFromEnv in ./modal.ts), and builds its client as the provider does (modalClient): the
|
|
25
|
-
// token passed explicitly, the server pinned, an ambient MODAL_SERVER_URL refused. It needs no
|
|
26
|
-
// AGENTRUN_COMPUTER_LIVE_MODAL: it makes nothing.
|
|
27
|
-
import { readFileSync, writeFileSync } from "node:fs";
|
|
28
|
-
import { COMPUTER_LABEL } from "../drift.js";
|
|
29
|
-
import { isCommand } from "../entry.js";
|
|
30
|
-
import { MODAL_DEFAULT_SERVER_URL, modalClient, untilFinished } from "../modal.js";
|
|
31
|
-
import { MODAL_ENV, settingsFromEnv } from "./modal.js";
|
|
32
|
-
import { RUN_LABEL } from "./runner.js";
|
|
33
|
-
const TAG = { [COMPUTER_LABEL]: "1" };
|
|
34
|
-
const USAGE = `usage: node packages/computer/dist/conformance/modal-sweep.js --before <file> | --after <file>
|
|
35
|
-
--before <file> record the app, the server and the id of every running sandbox carrying ${COMPUTER_LABEL}=1 in the app into <file>
|
|
36
|
-
--after <file> refuse a <file> of another app or server; else terminate every running sandbox carrying ${COMPUTER_LABEL}=1
|
|
37
|
-
and ${RUN_LABEL} in the app whose id is not in <file>, read each back until it has finished (up to 60 s
|
|
38
|
-
each), and print {"swept":n,"gone":m,"stillThere":[ids],"leftAlone":k}; a new one with no
|
|
39
|
-
${RUN_LABEL} (or tags it cannot read) is left alone
|
|
40
|
-
settings: ${MODAL_ENV.tokenId} and ${MODAL_ENV.tokenSecret} (required), ${MODAL_ENV.app} (required) and
|
|
41
|
-
${MODAL_ENV.serverUrl}, as the conformance module reads them; never MODAL_TOKEN_ID or MODAL_TOKEN_SECRET
|
|
42
|
-
exit: 0 every swept sandbox has finished, 1 one still runs, 2 usage error, unreadable before file or one of another app
|
|
43
|
-
or server, no token or app, or a refused listing`;
|
|
44
|
-
class Usage extends Error {
|
|
45
|
-
}
|
|
46
|
-
const write = (stream, text) => new Promise((resolve) => void stream.write(text, () => resolve()));
|
|
47
|
-
const words = (error) => {
|
|
48
|
-
const name = error?.name;
|
|
49
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
50
|
-
return `${typeof name === "string" && name !== "Error" ? `${name}: ` : ""}${message}`.replace(/\s+/g, " ").slice(0, 300);
|
|
51
|
-
};
|
|
52
|
-
const notFound = (error) => {
|
|
53
|
-
const { name, code } = (error ?? {});
|
|
54
|
-
return name === "NotFoundError" || code === 5;
|
|
55
|
-
};
|
|
56
|
-
/** The call's value, or the error it threw or rejected with; one that does not answer within ms is an error too. */
|
|
57
|
-
async function bounded(what, run, ms) {
|
|
58
|
-
let timer;
|
|
59
|
-
const timeout = new Promise((_, reject) => {
|
|
60
|
-
timer = setTimeout(() => reject(new Error(`${what} did not answer within ${ms / 1000} s`)), ms);
|
|
61
|
-
});
|
|
62
|
-
try {
|
|
63
|
-
return { ok: true, value: await Promise.race([Promise.resolve().then(run), timeout]) };
|
|
64
|
-
}
|
|
65
|
-
catch (error) {
|
|
66
|
-
return { ok: false, error };
|
|
67
|
-
}
|
|
68
|
-
finally {
|
|
69
|
-
clearTimeout(timer);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
function parse(argv) {
|
|
73
|
-
let found;
|
|
74
|
-
for (let i = 0; i < argv.length; i++) {
|
|
75
|
-
const [flag = "", inline] = (argv[i] ?? "").split(/=(.*)/s, 2);
|
|
76
|
-
if (flag !== "--before" && flag !== "--after")
|
|
77
|
-
throw new Usage(`unknown option ${flag}`);
|
|
78
|
-
const file = inline ?? argv[++i];
|
|
79
|
-
if (file === undefined || file === "" || file.startsWith("--"))
|
|
80
|
-
throw new Usage(`${flag} needs a file`);
|
|
81
|
-
if (found !== undefined)
|
|
82
|
-
throw new Usage("give --before <file> or --after <file>, one of them");
|
|
83
|
-
found = { mode: flag === "--before" ? "before" : "after", file };
|
|
84
|
-
}
|
|
85
|
-
if (found === undefined)
|
|
86
|
-
throw new Usage("give --before <file> or --after <file>, one of them");
|
|
87
|
-
return found;
|
|
88
|
-
}
|
|
89
|
-
function readBefore(file) {
|
|
90
|
-
let text;
|
|
91
|
-
try {
|
|
92
|
-
text = readFileSync(file, "utf8");
|
|
93
|
-
}
|
|
94
|
-
catch (error) {
|
|
95
|
-
throw new Usage(`cannot read the before file ${file}: ${error.message}`);
|
|
96
|
-
}
|
|
97
|
-
let record;
|
|
98
|
-
try {
|
|
99
|
-
record = JSON.parse(text);
|
|
100
|
-
}
|
|
101
|
-
catch {
|
|
102
|
-
record = undefined;
|
|
103
|
-
}
|
|
104
|
-
const { ids, app, serverUrl } = (record ?? {});
|
|
105
|
-
if (!Array.isArray(ids) || !ids.every((id) => typeof id === "string" && id !== ""))
|
|
106
|
-
throw new Usage(`${file} is not a before file: it holds no "ids" array of sandbox ids`);
|
|
107
|
-
return { app, serverUrl, ids: new Set(ids) };
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Why the before file is not of the app and server the environment names now, or undefined when it is. --after takes
|
|
111
|
-
* every tagged sandbox not in the file as new, so a file of another app, or of the same app name on another server,
|
|
112
|
-
* would have it terminate every computer there.
|
|
113
|
-
*/
|
|
114
|
-
function otherPlace(file, before, app, serverUrl) {
|
|
115
|
-
const refuse = (why) => `${file} ${why}, so nothing was listed or terminated: every computer there would read as new`;
|
|
116
|
-
if (typeof before.app !== "string" || before.app === "")
|
|
117
|
-
return refuse(`names no app; it is not a before file of this sweep`);
|
|
118
|
-
if (typeof before.serverUrl !== "string" || before.serverUrl === "")
|
|
119
|
-
return refuse(`names no server; it is not a before file of this sweep`);
|
|
120
|
-
if (before.app !== app)
|
|
121
|
-
return refuse(`was recorded in the app ${before.app}, and ${MODAL_ENV.app} names ${app} now`);
|
|
122
|
-
if (before.serverUrl !== serverUrl)
|
|
123
|
-
return refuse(`was recorded from ${before.serverUrl}, and the sweep would list ${serverUrl} now (${MODAL_ENV.serverUrl})`);
|
|
124
|
-
return undefined;
|
|
125
|
-
}
|
|
126
|
-
/** Every running sandbox in the app carrying the tag, by id, the whole listing within listMs. */
|
|
127
|
-
async function listTagged(sdk, app, callMs, listMs) {
|
|
128
|
-
const found = await bounded(`apps.fromName ${app}`, () => sdk.apps.fromName(app, { createIfMissing: true }), callMs);
|
|
129
|
-
if (!found.ok)
|
|
130
|
-
return found;
|
|
131
|
-
const appId = found.value.appId;
|
|
132
|
-
return bounded("sandboxes.list", async () => {
|
|
133
|
-
const all = new Map();
|
|
134
|
-
for await (const sandbox of sdk.sandboxes.list({ appId, tags: { ...TAG } }))
|
|
135
|
-
all.set(sandbox.sandboxId, sandbox);
|
|
136
|
-
return [...all.values()];
|
|
137
|
-
}, listMs);
|
|
138
|
-
}
|
|
139
|
-
export async function main(argv, io = {}) {
|
|
140
|
-
const { env = process.env, stdout = process.stdout, stderr = process.stderr, waitMs = 60_000, pollMs = 2_000, callMs = 60_000, listMs = 120_000 } = io;
|
|
141
|
-
let args;
|
|
142
|
-
let before;
|
|
143
|
-
let app;
|
|
144
|
-
let sdk;
|
|
145
|
-
let serverUrl;
|
|
146
|
-
try {
|
|
147
|
-
args = parse(argv);
|
|
148
|
-
const recorded = args.mode === "after" ? readBefore(args.file) : undefined;
|
|
149
|
-
const settings = settingsFromEnv(env);
|
|
150
|
-
app = settings.app;
|
|
151
|
-
serverUrl = settings.serverUrl ?? MODAL_DEFAULT_SERVER_URL;
|
|
152
|
-
sdk = await modalClient({ tokenId: settings.tokenId, tokenSecret: settings.tokenSecret, serverUrl, ...(io.ModalClient ? { ModalClient: io.ModalClient } : {}) });
|
|
153
|
-
if (recorded !== undefined) {
|
|
154
|
-
const other = otherPlace(args.file, recorded, app, serverUrl);
|
|
155
|
-
if (other !== undefined)
|
|
156
|
-
throw new Error(other);
|
|
157
|
-
before = recorded.ids;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
catch (error) {
|
|
161
|
-
await write(stderr, `${error.message}\n${error instanceof Usage ? `${USAGE}\n` : ""}`);
|
|
162
|
-
return 2;
|
|
163
|
-
}
|
|
164
|
-
const listed = await listTagged(sdk, app, callMs, listMs);
|
|
165
|
-
if (!listed.ok) {
|
|
166
|
-
await write(stderr, `listing the sandboxes carrying ${COMPUTER_LABEL}=1 in ${app} failed, so nothing was ${args.mode === "after" ? "terminated" : "recorded"}: ${words(listed.error)}\n`);
|
|
167
|
-
return 2;
|
|
168
|
-
}
|
|
169
|
-
if (before === undefined) {
|
|
170
|
-
const ids = listed.value.map((sandbox) => sandbox.sandboxId).sort();
|
|
171
|
-
writeFileSync(args.file, `${JSON.stringify({ tag: `${COMPUTER_LABEL}=1`, app, serverUrl, at: new Date().toISOString(), ids }, null, 2)}\n`);
|
|
172
|
-
await write(stdout, `${JSON.stringify({ recorded: ids.length, file: args.file })}\n`);
|
|
173
|
-
return 0;
|
|
174
|
-
}
|
|
175
|
-
const known = before;
|
|
176
|
-
const added = listed.value.filter((sandbox) => !known.has(sandbox.sandboxId));
|
|
177
|
-
// Only a conformance run's computers: one another user of the app made during the run is not this sweep's. Tags it
|
|
178
|
-
// cannot read leave the sandbox alone, said in words; one Modal no longer knows has finished already.
|
|
179
|
-
const fresh = [];
|
|
180
|
-
let leftAlone = 0;
|
|
181
|
-
for (const sandbox of added) {
|
|
182
|
-
const tags = await bounded(`getTags of ${sandbox.sandboxId}`, () => sandbox.getTags(), callMs);
|
|
183
|
-
if (!tags.ok) {
|
|
184
|
-
if (notFound(tags.error))
|
|
185
|
-
continue;
|
|
186
|
-
await write(stderr, `${sandbox.sandboxId} was left alone: its tags could not be read: ${words(tags.error)}\n`);
|
|
187
|
-
leftAlone += 1;
|
|
188
|
-
}
|
|
189
|
-
else if (Object.hasOwn(tags.value, RUN_LABEL))
|
|
190
|
-
fresh.push(sandbox);
|
|
191
|
-
else
|
|
192
|
-
leftAlone += 1;
|
|
193
|
-
}
|
|
194
|
-
for (const sandbox of fresh) {
|
|
195
|
-
const ended = await bounded(`terminate of ${sandbox.sandboxId}`, () => sandbox.terminate(), callMs);
|
|
196
|
-
if (!ended.ok && !notFound(ended.error))
|
|
197
|
-
await write(stderr, `${sandbox.sandboxId} was not terminated: ${words(ended.error)}\n`);
|
|
198
|
-
}
|
|
199
|
-
// Each read back on its own, at once, through a new handle and the provider's own wait after a terminate
|
|
200
|
-
// (untilFinished): an exit code, or a sandbox Modal no longer knows, is gone.
|
|
201
|
-
const gone = await Promise.all(fresh.map(async ({ sandboxId: id }) => {
|
|
202
|
-
const waited = await untilFinished(async () => (await sdk.sandboxes.fromId(id)).poll(), { name: id, boundMs: waitMs, callMs, minMs: pollMs, maxMs: pollMs });
|
|
203
|
-
if (!waited.ok)
|
|
204
|
-
await write(stderr, `${id} is still running after ${waitMs / 1000} s: ${waited.error.message}\n`);
|
|
205
|
-
return waited.ok;
|
|
206
|
-
}));
|
|
207
|
-
const stillThere = fresh.filter((_, i) => !gone[i]).map((sandbox) => sandbox.sandboxId);
|
|
208
|
-
await write(stdout, `${JSON.stringify({ swept: fresh.length, gone: fresh.length - stillThere.length, stillThere, leftAlone })}\n`);
|
|
209
|
-
return stillThere.length === 0 ? 0 : 1;
|
|
210
|
-
}
|
|
211
|
-
if (isCommand(import.meta)) {
|
|
212
|
-
process.exitCode = await main(process.argv.slice(2));
|
|
213
|
-
}
|