@parcha/agentrun-computer 0.1.0-beta.36 → 0.1.0-beta.38
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 +547 -478
- package/box/Dockerfile +18 -1
- package/box/README.md +13 -0
- package/box/build-agent37.mjs +158 -0
- package/box/build-daytona.py +2 -2
- package/box/build-e2b.mjs +41 -18
- package/box/recipe.mjs +43 -0
- package/dist/agent37-ssh.d.ts +89 -0
- package/dist/agent37-ssh.js +445 -0
- package/dist/agent37.d.ts +104 -0
- package/dist/agent37.js +402 -0
- package/dist/attach.d.ts +146 -0
- package/dist/attach.js +469 -0
- package/dist/browserbase.d.ts +2 -10
- package/dist/browserbase.js +3 -6
- package/dist/client.d.ts +45 -4
- package/dist/client.js +92 -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 +96 -0
- package/dist/conformance/agent37.js +154 -0
- package/dist/conformance/cases/apps.d.ts +11 -0
- package/dist/conformance/cases/apps.js +173 -73
- package/dist/conformance/cases/health.js +14 -0
- package/dist/conformance/cases/index.js +2 -0
- package/dist/conformance/cases/isolation.d.ts +7 -5
- package/dist/conformance/cases/isolation.js +44 -14
- package/dist/conformance/cases/mount.js +1 -1
- 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 +94 -9
- package/dist/conformance/daytona.d.ts +9 -20
- package/dist/conformance/daytona.js +12 -21
- package/dist/conformance/e2b.d.ts +6 -0
- package/dist/conformance/e2b.js +9 -2
- package/dist/conformance/exec-stream.d.ts +45 -0
- package/dist/conformance/exec-stream.js +486 -0
- 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 +13 -5
- 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 +20 -133
- package/dist/daytona.js +405 -1449
- package/dist/descriptor.d.ts +11 -1
- package/dist/descriptor.js +9 -0
- package/dist/descriptors/agent37.d.ts +41 -0
- package/dist/descriptors/agent37.js +28 -0
- package/dist/descriptors/daytona.d.ts +6 -5
- package/dist/descriptors/daytona.js +9 -5
- package/dist/descriptors/index.d.ts +42 -7
- package/dist/descriptors/index.js +4 -2
- package/dist/descriptors/orgo.d.ts +2 -1
- package/dist/descriptors/orgo.js +3 -2
- package/dist/descriptors/phone-harness.d.ts +1 -1
- package/dist/descriptors/phone-harness.js +2 -2
- package/dist/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.d.ts +7 -10
- package/dist/docker.js +272 -34
- package/dist/drift.js +4 -4
- package/dist/e2b.d.ts +16 -290
- package/dist/e2b.js +230 -1393
- package/dist/fake-ui-driver.d.ts +97 -0
- package/dist/fake-ui-driver.js +717 -0
- package/dist/host.d.ts +201 -0
- package/dist/host.js +8 -0
- package/dist/hosted/process.d.ts +81 -0
- package/dist/hosted/process.js +259 -0
- package/dist/hosted/provider.d.ts +160 -0
- package/dist/hosted/provider.js +1415 -0
- package/dist/hosted/rest.d.ts +66 -0
- package/dist/hosted/rest.js +121 -0
- package/dist/hosted/scripts.d.ts +82 -0
- package/dist/{child.js → hosted/scripts.js} +118 -12
- package/dist/hosted/values.d.ts +5 -0
- package/dist/hosted/values.js +8 -0
- package/dist/index.d.ts +7 -3
- package/dist/index.js +7 -4
- package/dist/kernel.d.ts +2 -10
- package/dist/kernel.js +3 -6
- package/dist/kinds.d.ts +11 -2
- package/dist/kinds.js +20 -4
- package/dist/local-chrome.d.ts +2 -10
- package/dist/local-chrome.js +3 -6
- package/dist/modal.d.ts +22 -257
- package/dist/modal.js +183 -1280
- package/dist/mount-archil.d.ts +8 -4
- package/dist/mount-archil.js +22 -11
- package/dist/mount.d.ts +10 -4
- package/dist/mount.js +8 -4
- package/dist/orgo-channel.d.ts +3 -2
- package/dist/orgo-channel.js +5 -2
- package/dist/orgo-desktop.d.ts +9 -4
- package/dist/orgo-desktop.js +33 -13
- package/dist/orgo-workspaces.d.ts +47 -0
- package/dist/orgo-workspaces.js +94 -0
- package/dist/orgo.d.ts +10 -13
- package/dist/orgo.js +32 -21
- package/dist/phone-harness.d.ts +31 -28
- package/dist/phone-harness.js +510 -702
- package/dist/png.d.ts +4 -0
- package/dist/png.js +27 -0
- package/dist/protocol.d.ts +339 -33
- package/dist/protocol.js +97 -3
- package/dist/provider.d.ts +36 -8
- package/dist/provider.js +16 -0
- package/dist/providers.d.ts +11 -12
- package/dist/result.d.ts +1 -1
- package/dist/screen-watch.js +34 -6
- package/dist/surface/api.d.ts +260 -0
- package/dist/surface/api.js +1 -0
- package/dist/surface/core.d.ts +55 -0
- package/dist/surface/core.js +475 -0
- package/dist/surface/index.d.ts +5 -0
- package/dist/surface/index.js +3 -0
- package/dist/surface/outline.d.ts +10 -0
- package/dist/surface/outline.js +51 -0
- package/dist/surface/script.d.ts +10 -0
- package/dist/surface/script.js +94 -0
- package/dist/ui-engine.d.ts +114 -0
- package/dist/ui-engine.js +814 -0
- package/package.json +18 -3
- package/dist/child.d.ts +0 -42
- package/dist/conformance/daytona-sweep.d.ts +0 -18
- package/dist/conformance/daytona-sweep.js +0 -126
- package/dist/conformance/e2b-diagnose.d.ts +0 -16
- package/dist/conformance/e2b-diagnose.js +0 -61
- package/dist/conformance/e2b-sweep.d.ts +0 -18
- package/dist/conformance/e2b-sweep.js +0 -132
- package/dist/conformance/modal-sweep.d.ts +0 -22
- package/dist/conformance/modal-sweep.js +0 -213
|
@@ -1,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
|
-
}
|