@parcha/agentrun-computer 0.1.0-beta.37 → 0.1.0-beta.39
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 +341 -260
- package/box/Dockerfile +18 -1
- package/box/README.md +14 -0
- package/box/build-daytona.py +2 -2
- package/box/build-e2b.mjs +41 -18
- package/box/recipe.d.mts +5 -0
- package/box/recipe.mjs +43 -0
- package/dist/agent37.d.ts +18 -66
- package/dist/agent37.js +187 -464
- package/dist/box-image.d.ts +14 -0
- package/dist/box-image.js +24 -0
- package/dist/browserbase.d.ts +0 -6
- package/dist/browserbase.js +1 -5
- package/dist/client.d.ts +12 -3
- package/dist/client.js +39 -4
- package/dist/computerd-linux-amd64 +0 -0
- package/dist/computerd-linux-arm64 +0 -0
- package/dist/computerd.json +4 -0
- package/dist/conformance/agent37.d.ts +9 -4
- package/dist/conformance/agent37.js +23 -11
- package/dist/conformance/browserbase.js +3 -3
- package/dist/conformance/cases/apps.d.ts +6 -0
- package/dist/conformance/cases/apps.js +18 -5
- package/dist/conformance/cases/isolation.d.ts +22 -5
- package/dist/conformance/cases/isolation.js +97 -16
- package/dist/conformance/cases/mount.js +5 -3
- package/dist/conformance/cases/provider.js +41 -0
- package/dist/conformance/cli.js +72 -11
- package/dist/conformance/daytona.d.ts +9 -20
- package/dist/conformance/daytona.js +12 -21
- package/dist/conformance/e2b.js +9 -4
- package/dist/conformance/exec-stream.d.ts +52 -0
- package/dist/conformance/exec-stream.js +493 -0
- package/dist/conformance/kernel.js +2 -2
- package/dist/conformance/modal.js +1 -1
- package/dist/conformance/orgo.js +2 -2
- package/dist/conformance/sweep.js +8 -8
- package/dist/conformance/types.d.ts +2 -2
- package/dist/create-requests.d.ts +1 -1
- package/dist/daytona.d.ts +17 -133
- package/dist/daytona.js +396 -1452
- package/dist/descriptor.d.ts +11 -4
- package/dist/descriptor.js +7 -0
- package/dist/descriptors/agent37.d.ts +3 -11
- package/dist/descriptors/agent37.js +9 -10
- package/dist/descriptors/daytona.d.ts +7 -6
- package/dist/descriptors/daytona.js +14 -7
- package/dist/descriptors/docker.d.ts +13 -1
- package/dist/descriptors/docker.js +3 -1
- package/dist/descriptors/e2b.d.ts +2 -9
- package/dist/descriptors/e2b.js +8 -8
- package/dist/descriptors/index.d.ts +25 -24
- package/dist/descriptors/index.js +1 -3
- package/dist/descriptors/modal.d.ts +2 -6
- package/dist/descriptors/modal.js +8 -6
- package/dist/descriptors/orgo.js +2 -1
- package/dist/descriptors/shared.d.ts +1 -1
- package/dist/descriptors/shared.js +2 -2
- package/dist/desktop.d.ts +18 -4
- package/dist/desktop.js +89 -9
- package/dist/docker/egress-main.js +23 -15
- package/dist/docker/egress.d.ts +6 -4
- package/dist/docker/egress.js +24 -16
- package/dist/docker/inspect.d.ts +2 -2
- package/dist/docker/inspect.js +5 -5
- package/dist/docker.d.ts +6 -11
- package/dist/docker.js +13 -16
- package/dist/drift.js +4 -4
- package/dist/e2b.d.ts +22 -130
- package/dist/e2b.js +163 -243
- package/dist/host.d.ts +136 -104
- package/dist/host.js +8 -1
- package/dist/hosted/network.d.ts +23 -0
- package/dist/hosted/network.js +77 -0
- package/dist/hosted/process.d.ts +24 -8
- package/dist/hosted/process.js +80 -44
- package/dist/hosted/provider.d.ts +38 -22
- package/dist/hosted/provider.js +500 -341
- package/dist/hosted/rest.d.ts +74 -0
- package/dist/hosted/rest.js +126 -0
- package/dist/hosted/scripts.d.ts +21 -3
- package/dist/hosted/scripts.js +76 -14
- package/dist/hosted/ssh-exec.d.ts +99 -0
- package/dist/hosted/ssh-exec.js +464 -0
- package/dist/hosted/values.d.ts +26 -0
- package/dist/hosted/values.js +63 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/isolation.d.ts +0 -2
- package/dist/isolation.js +3 -4
- package/dist/kernel.d.ts +0 -6
- package/dist/kernel.js +1 -5
- package/dist/kinds.d.ts +3 -1
- package/dist/local-chrome.d.ts +0 -6
- package/dist/local-chrome.js +1 -5
- package/dist/modal.d.ts +15 -86
- package/dist/modal.js +67 -185
- package/dist/mount-archil.d.ts +13 -8
- package/dist/mount-archil.js +27 -17
- package/dist/mount.d.ts +10 -4
- package/dist/mount.js +8 -4
- package/dist/orgo.d.ts +0 -9
- package/dist/orgo.js +8 -13
- package/dist/phone-harness.d.ts +0 -6
- package/dist/phone-harness.js +0 -4
- package/dist/protocol.d.ts +4 -1
- package/dist/protocol.js +1 -0
- package/dist/provider.d.ts +2 -2
- package/dist/providers.d.ts +15 -13
- package/dist/screen-watch.js +34 -6
- package/dist/surface/api.d.ts +14 -11
- package/dist/surface/core.d.ts +23 -5
- package/dist/surface/core.js +105 -15
- package/dist/surface/index.d.ts +1 -1
- package/dist/surface/index.js +1 -1
- package/dist/surface/outline.d.ts +2 -0
- package/dist/surface/outline.js +2 -1
- package/dist/surface/script.d.ts +4 -0
- package/dist/surface/script.js +11 -3
- package/dist/ui-engine.js +19 -3
- package/package.json +2 -3
- package/box/build-agent37.mjs +0 -177
- package/dist/conformance/daytona-sweep.d.ts +0 -18
- package/dist/conformance/daytona-sweep.js +0 -126
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
// The sweep around a live Daytona run, with the conformance module's settings (COMPUTER_DAYTONA_*, never DAYTONA_*):
|
|
2
|
-
//
|
|
3
|
-
// node packages/computer/dist/conformance/daytona-sweep.js --before <file>
|
|
4
|
-
// node packages/computer/dist/conformance/daytona-sweep.js --after <file>
|
|
5
|
-
//
|
|
6
|
-
// --before records the id of every sandbox carrying agentrun.computer=1 into <file>. --after lists them again, deletes
|
|
7
|
-
// (release delete) every one whose id is not in <file> and that carries a conformance run's label (agentrun.conformance,
|
|
8
|
-
// RUN_LABEL), then reads each of those back with GET /sandbox/{id} until Daytona answers 404, up to 60 s each, and
|
|
9
|
-
// prints one JSON line, {"swept":n,"notFound":m,"stillThere":[ids],"leftAlone":k}: swept is every conformance sandbox
|
|
10
|
-
// it found that was not there before, notFound + stillThere.length = swept, and leftAlone counts the new labelled
|
|
11
|
-
// sandboxes with no conformance label, which another user of the account made during the run (a server's computers):
|
|
12
|
-
// never touched. A sandbox in <file> is never touched either: no call names it. Exit 0 when every swept sandbox reads
|
|
13
|
-
// back 404, 1 when one is still there, 2 on a usage error, a before file it cannot read, a missing key or a listing
|
|
14
|
-
// Daytona refused (nothing is deleted then).
|
|
15
|
-
import { readFileSync, writeFileSync } from "node:fs";
|
|
16
|
-
import { COMPUTER_LABEL } from "../drift.js";
|
|
17
|
-
import { isCommand } from "../entry.js";
|
|
18
|
-
import { waitUntil } from "../wait.js";
|
|
19
|
-
import { createProvider } from "./daytona.js";
|
|
20
|
-
import { RUN_LABEL } from "./runner.js";
|
|
21
|
-
const USAGE = `usage: node packages/computer/dist/conformance/daytona-sweep.js --before <file> | --after <file>
|
|
22
|
-
--before <file> record the id of every sandbox carrying ${COMPUTER_LABEL}=1 into <file>
|
|
23
|
-
--after <file> delete every sandbox carrying ${COMPUTER_LABEL}=1 and ${RUN_LABEL} whose id is not in <file>, read
|
|
24
|
-
each back until Daytona answers 404 (up to 60 s each), and print
|
|
25
|
-
{"swept":n,"notFound":m,"stillThere":[ids],"leftAlone":k}; a new one with no ${RUN_LABEL} is left alone
|
|
26
|
-
settings: COMPUTER_DAYTONA_API_KEY (required) and COMPUTER_DAYTONA_API_URL, as the conformance module reads them
|
|
27
|
-
exit: 0 every swept sandbox is gone, 1 one is still there, 2 usage error, unreadable before file, no key, or a refused listing`;
|
|
28
|
-
class Usage extends Error {
|
|
29
|
-
}
|
|
30
|
-
const write = (stream, text) => new Promise((resolve) => void stream.write(text, () => resolve()));
|
|
31
|
-
function parse(argv) {
|
|
32
|
-
let found;
|
|
33
|
-
for (let i = 0; i < argv.length; i++) {
|
|
34
|
-
const [flag = "", inline] = (argv[i] ?? "").split(/=(.*)/s, 2);
|
|
35
|
-
if (flag !== "--before" && flag !== "--after")
|
|
36
|
-
throw new Usage(`unknown option ${flag}`);
|
|
37
|
-
const file = inline ?? argv[++i];
|
|
38
|
-
if (file === undefined || file === "" || file.startsWith("--"))
|
|
39
|
-
throw new Usage(`${flag} needs a file`);
|
|
40
|
-
if (found !== undefined)
|
|
41
|
-
throw new Usage("give --before <file> or --after <file>, one of them");
|
|
42
|
-
found = { mode: flag === "--before" ? "before" : "after", file };
|
|
43
|
-
}
|
|
44
|
-
if (found === undefined)
|
|
45
|
-
throw new Usage("give --before <file> or --after <file>, one of them");
|
|
46
|
-
return found;
|
|
47
|
-
}
|
|
48
|
-
/** The ids a before file holds, or why it is not one. */
|
|
49
|
-
function beforeIds(file) {
|
|
50
|
-
let text;
|
|
51
|
-
try {
|
|
52
|
-
text = readFileSync(file, "utf8");
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
throw new Usage(`cannot read the before file ${file}: ${error.message}`);
|
|
56
|
-
}
|
|
57
|
-
let record;
|
|
58
|
-
try {
|
|
59
|
-
record = JSON.parse(text);
|
|
60
|
-
}
|
|
61
|
-
catch {
|
|
62
|
-
record = undefined;
|
|
63
|
-
}
|
|
64
|
-
const ids = record?.ids;
|
|
65
|
-
if (!Array.isArray(ids) || !ids.every((id) => typeof id === "string" && id !== ""))
|
|
66
|
-
throw new Usage(`${file} is not a before file: it holds no "ids" array of sandbox ids`);
|
|
67
|
-
return new Set(ids);
|
|
68
|
-
}
|
|
69
|
-
export async function main(argv, io = {}) {
|
|
70
|
-
const { env = process.env, stdout = process.stdout, stderr = process.stderr, waitMs = 60_000, pollMs = 2_000 } = io;
|
|
71
|
-
let args;
|
|
72
|
-
let before;
|
|
73
|
-
let provider;
|
|
74
|
-
try {
|
|
75
|
-
args = parse(argv);
|
|
76
|
-
if (args.mode === "after")
|
|
77
|
-
before = beforeIds(args.file);
|
|
78
|
-
// A release waits for the sandbox to go, for as long as the sweep's own wait.
|
|
79
|
-
provider = createProvider({ env, timeouts: { goneMs: waitMs, pollMs }, ...(io.fetch ? { fetch: io.fetch } : {}), ...(io.webSocket ? { webSocket: io.webSocket } : {}) });
|
|
80
|
-
}
|
|
81
|
-
catch (error) {
|
|
82
|
-
await write(stderr, `${error.message}\n${error instanceof Usage ? `${USAGE}\n` : ""}`);
|
|
83
|
-
return 2;
|
|
84
|
-
}
|
|
85
|
-
const listed = await provider.listLabelled();
|
|
86
|
-
if (!listed.ok) {
|
|
87
|
-
await write(stderr, `listing the sandboxes carrying ${COMPUTER_LABEL}=1 failed, so nothing was ${args.mode === "after" ? "deleted" : "recorded"}: ${listed.error.message}\n`);
|
|
88
|
-
return 2;
|
|
89
|
-
}
|
|
90
|
-
if (before === undefined) {
|
|
91
|
-
const ids = [...new Set(listed.value.map((sb) => sb.id))].sort();
|
|
92
|
-
writeFileSync(args.file, `${JSON.stringify({ label: `${COMPUTER_LABEL}=1`, at: new Date().toISOString(), ids }, null, 2)}\n`);
|
|
93
|
-
await write(stdout, `${JSON.stringify({ recorded: ids.length, file: args.file })}\n`);
|
|
94
|
-
return 0;
|
|
95
|
-
}
|
|
96
|
-
const known = before;
|
|
97
|
-
const added = [...new Map(listed.value.filter((sb) => !known.has(sb.id)).map((sb) => [sb.id, sb])).values()];
|
|
98
|
-
// Only a conformance run's computers: one another user of the account made during the run is not this sweep's.
|
|
99
|
-
const fresh = added.filter((sb) => Object.hasOwn(sb.labels, RUN_LABEL));
|
|
100
|
-
const leftAlone = added.length - fresh.length;
|
|
101
|
-
for (const sb of fresh) {
|
|
102
|
-
const released = await provider.release({ id: sb.id, name: sb.name ?? "" }, "delete");
|
|
103
|
-
if (!released.ok)
|
|
104
|
-
await write(stderr, `${sb.id} (${sb.name ?? "no name"}) was not deleted: ${released.error.message}\n`);
|
|
105
|
-
}
|
|
106
|
-
// Each one read back on its own, at once, through waitUntil: a 404 is gone; anything else, or no answer, is read
|
|
107
|
-
// again every pollMs until its wait ends.
|
|
108
|
-
const gone = await Promise.all(fresh.map(async (sb) => {
|
|
109
|
-
const waited = await waitUntil(() => provider.probe(sb.id), (read) => read.ok && read.value.status === 404, {
|
|
110
|
-
boundMs: waitMs,
|
|
111
|
-
minMs: pollMs,
|
|
112
|
-
maxMs: pollMs,
|
|
113
|
-
what: `${sb.id} to be gone`,
|
|
114
|
-
describe: (read) => `GET /sandbox/${sb.id} answered ${read.ok ? `${read.value.status}${read.value.state ? ` (${read.value.state})` : ""}` : read.error.message}`,
|
|
115
|
-
});
|
|
116
|
-
if (!waited.ok)
|
|
117
|
-
await write(stderr, `${sb.id} is still there: ${waited.error.message}\n`);
|
|
118
|
-
return waited.ok;
|
|
119
|
-
}));
|
|
120
|
-
const stillThere = fresh.filter((_, i) => !gone[i]).map((sb) => sb.id);
|
|
121
|
-
await write(stdout, `${JSON.stringify({ swept: fresh.length, notFound: fresh.length - stillThere.length, stillThere, leftAlone })}\n`);
|
|
122
|
-
return stillThere.length === 0 ? 0 : 1;
|
|
123
|
-
}
|
|
124
|
-
if (isCommand(import.meta)) {
|
|
125
|
-
process.exitCode = await main(process.argv.slice(2));
|
|
126
|
-
}
|