@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
package/dist/client.js
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
import { CANCEL_METHOD, JSONRPC_CODES, MAX_LINE_BYTES, } from "./protocol.js";
|
|
2
2
|
import { fail, ok } from "./result.js";
|
|
3
|
+
/**
|
|
4
|
+
* How long past a call's own timeoutMs (exec.run's, process.wait's) the daemon has to answer it. The daemon answers by
|
|
5
|
+
* that bound itself, so a call still unanswered after this has a transport that hangs: it ends here as timeout, never
|
|
6
|
+
* at whatever ends the transport much later.
|
|
7
|
+
*/
|
|
8
|
+
export const ANSWER_SLACK_MS = 5_000;
|
|
9
|
+
/** The timeout errors a client gave itself, a call's bound passed with no answer: never one the daemon answered. */
|
|
10
|
+
const UNANSWERED = new WeakSet();
|
|
11
|
+
/** Whether `error` is a timeout this client gave a call whose bound passed with no answer over the transport. */
|
|
12
|
+
export function unanswered(error) {
|
|
13
|
+
return UNANSWERED.has(error);
|
|
14
|
+
}
|
|
15
|
+
/** The bound of a call whose params carry their own timeoutMs, or undefined for a call with none. */
|
|
16
|
+
function boundOf(params) {
|
|
17
|
+
const own = params?.timeoutMs;
|
|
18
|
+
return typeof own === "number" && Number.isFinite(own) && own >= 0 ? { ms: own + ANSWER_SLACK_MS, own } : undefined;
|
|
19
|
+
}
|
|
3
20
|
const KINDS = new Set([
|
|
4
21
|
"not_found",
|
|
5
22
|
"invalid",
|
|
@@ -11,6 +28,8 @@ const KINDS = new Set([
|
|
|
11
28
|
"exists",
|
|
12
29
|
"not_dir",
|
|
13
30
|
"is_dir",
|
|
31
|
+
"stale",
|
|
32
|
+
"refused",
|
|
14
33
|
]);
|
|
15
34
|
/** A daemon's error reply as a ComputerError: its kind when it names one, else what its JSON-RPC code means. */
|
|
16
35
|
function fromReply(error) {
|
|
@@ -26,8 +45,9 @@ function fromReply(error) {
|
|
|
26
45
|
}
|
|
27
46
|
/**
|
|
28
47
|
* Calls a daemon's methods. Each call gets its own id; replies may come in any order. An aborted call sends
|
|
29
|
-
* $/cancelRequest and returns `aborted` at once; the daemon still ends what the call started.
|
|
30
|
-
*
|
|
48
|
+
* $/cancelRequest and returns `aborted` at once; the daemon still ends what the call started. A call whose params carry
|
|
49
|
+
* a timeoutMs and that has no answer ANSWER_SLACK_MS past it sends the same cancel and returns `timeout`. When the
|
|
50
|
+
* stream ends, every pending and later call fails with `gone`. A line that is not a reply to a pending call is dropped.
|
|
31
51
|
*/
|
|
32
52
|
export class DaemonClient {
|
|
33
53
|
#writable;
|
|
@@ -56,18 +76,35 @@ export class DaemonClient {
|
|
|
56
76
|
const line = `${JSON.stringify({ jsonrpc: "2.0", id, method, params })}\n`;
|
|
57
77
|
if (Buffer.byteLength(line) - 1 > MAX_LINE_BYTES)
|
|
58
78
|
return fail("limit", `the ${method} request is over the 1 MiB line limit`);
|
|
79
|
+
const bound = boundOf(params);
|
|
59
80
|
return new Promise((resolve) => {
|
|
60
|
-
|
|
81
|
+
let timer;
|
|
82
|
+
const giveUp = (result) => {
|
|
61
83
|
if (!this.#pending.delete(id))
|
|
62
84
|
return;
|
|
85
|
+
clearTimeout(timer);
|
|
86
|
+
signal?.removeEventListener("abort", onAbort);
|
|
63
87
|
this.#write({ jsonrpc: "2.0", method: CANCEL_METHOD, params: { id } });
|
|
64
|
-
resolve(
|
|
88
|
+
resolve(result);
|
|
65
89
|
};
|
|
90
|
+
const onAbort = () => giveUp(fail("aborted", `${method} was aborted`));
|
|
66
91
|
this.#pending.set(id, (result) => {
|
|
92
|
+
clearTimeout(timer);
|
|
67
93
|
signal?.removeEventListener("abort", onAbort);
|
|
68
94
|
resolve(result);
|
|
69
95
|
});
|
|
70
96
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
97
|
+
if (bound !== undefined) {
|
|
98
|
+
const s = (ms) => `${ms / 1000} s`;
|
|
99
|
+
timer = setTimeout(() => {
|
|
100
|
+
const timedOut = fail("timeout", `${method} had no answer within ${s(bound.ms)} (its own timeout of ${s(bound.own)}, and ${s(ANSWER_SLACK_MS)} for the answer to come)`);
|
|
101
|
+
if (!timedOut.ok)
|
|
102
|
+
UNANSWERED.add(timedOut.error);
|
|
103
|
+
giveUp(timedOut);
|
|
104
|
+
}, bound.ms);
|
|
105
|
+
// The stream holds the process while a call waits on it; the bound alone never does.
|
|
106
|
+
timer.unref?.();
|
|
107
|
+
}
|
|
71
108
|
this.#writable.write(line);
|
|
72
109
|
});
|
|
73
110
|
}
|
|
@@ -134,3 +171,54 @@ export class DaemonClient {
|
|
|
134
171
|
settle({ ok: false, error: gone });
|
|
135
172
|
}
|
|
136
173
|
}
|
|
174
|
+
/** The nodes of an observation that match the query, in the observation's order. */
|
|
175
|
+
export function findNodes(seen, { role, text, id }) {
|
|
176
|
+
return seen.nodes.filter((node) => (role === undefined || node.role === role) && (id === undefined || node.id === id) && (text === undefined || (node.name?.includes(text) ?? false) || (node.value?.includes(text) ?? false)));
|
|
177
|
+
}
|
|
178
|
+
/** The refused step of an act, with its index, or undefined when every step ran. A refused step is always the last. */
|
|
179
|
+
export function refusedStep(result) {
|
|
180
|
+
const index = result.steps.length - 1;
|
|
181
|
+
const last = result.steps[index];
|
|
182
|
+
return last !== undefined && "error" in last ? { index, ...last.error } : undefined;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* The ui group on one target, over any connection: observe and act with their types, and the last state each answered,
|
|
186
|
+
* so an act at a point carries the state the point was read from without the caller threading it.
|
|
187
|
+
*/
|
|
188
|
+
export class UiSession {
|
|
189
|
+
#client;
|
|
190
|
+
#target;
|
|
191
|
+
#state;
|
|
192
|
+
constructor(client, target) {
|
|
193
|
+
this.#client = client;
|
|
194
|
+
this.#target = target;
|
|
195
|
+
}
|
|
196
|
+
/** The last state an observe or an act answered. */
|
|
197
|
+
get state() {
|
|
198
|
+
return this.#state;
|
|
199
|
+
}
|
|
200
|
+
async observe(params = {}, options = {}) {
|
|
201
|
+
const seen = await this.#client.call("ui.observe", { ...this.#withTarget(), ...params }, options);
|
|
202
|
+
if (seen.ok)
|
|
203
|
+
this.#state = seen.value.state;
|
|
204
|
+
return seen;
|
|
205
|
+
}
|
|
206
|
+
async act(steps, { expect, foreground, state, signal } = {}) {
|
|
207
|
+
const atPoint = steps.some((step) => ("click" in step && Array.isArray(step.click)) || ("scroll" in step && Array.isArray(step.scroll)) || "drag" in step);
|
|
208
|
+
const from = state ?? (atPoint ? this.#state : undefined);
|
|
209
|
+
const params = {
|
|
210
|
+
...this.#withTarget(),
|
|
211
|
+
steps,
|
|
212
|
+
...(from === undefined ? {} : { state: from }),
|
|
213
|
+
...(expect === undefined ? {} : { expect }),
|
|
214
|
+
...(foreground === undefined ? {} : { foreground }),
|
|
215
|
+
};
|
|
216
|
+
const done = await this.#client.call("ui.act", params, signal === undefined ? {} : { signal });
|
|
217
|
+
if (done.ok)
|
|
218
|
+
this.#state = done.value.state;
|
|
219
|
+
return done;
|
|
220
|
+
}
|
|
221
|
+
#withTarget() {
|
|
222
|
+
return this.#target === undefined ? {} : { target: this.#target };
|
|
223
|
+
}
|
|
224
|
+
}
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { type Agent37Options, type Agent37Provider } from "../agent37.js";
|
|
2
|
+
import type { MachineHost } from "../host.js";
|
|
3
|
+
import type { MountKind } from "../mount.js";
|
|
4
|
+
import { type ArchilRunFolderOptions } from "./archil.js";
|
|
5
|
+
import type { RunFolder } from "./types.js";
|
|
6
|
+
/** The Archil disk's settings for the mount cases, by name (COMPUTER_ARCHIL_*: all five, or none). */
|
|
7
|
+
export { ARCHIL_ENV } from "./archil.js";
|
|
8
|
+
/** The environment this module reads, by name, each for the option its comment names, the live switch and the run's template. */
|
|
9
|
+
export declare const AGENT37_ENV: {
|
|
10
|
+
readonly live: "AGENTRUN_COMPUTER_LIVE_AGENT37";
|
|
11
|
+
/** The template every computer of the run starts from; default agent37-base, or agentrun-box for kind desktop. */
|
|
12
|
+
readonly template: "COMPUTER_AGENT37_TEMPLATE";
|
|
13
|
+
/** kind: linux (default) or desktop. */
|
|
14
|
+
readonly kind: "COMPUTER_AGENT37_KIND";
|
|
15
|
+
/** apiKey, required: the workspace's API key. */
|
|
16
|
+
readonly key: "COMPUTER_AGENT37_API_KEY";
|
|
17
|
+
/** sshKey, required: the private SSH key registered on the workspace, its contents. */
|
|
18
|
+
readonly sshKey: "COMPUTER_AGENT37_SSH_KEY";
|
|
19
|
+
/** type: vm (default) or default. */
|
|
20
|
+
readonly type: "COMPUTER_AGENT37_TYPE";
|
|
21
|
+
/** region: us (default), eu or ap-south. */
|
|
22
|
+
readonly region: "COMPUTER_AGENT37_REGION";
|
|
23
|
+
/** apiUrl: Agent37's REST API; default https://api.agent37.com. */
|
|
24
|
+
readonly apiUrl: "COMPUTER_AGENT37_API_URL";
|
|
25
|
+
/** daemonPath: the daemon binary; default this package's dist/computerd-linux-amd64. */
|
|
26
|
+
readonly daemon: "COMPUTER_AGENT37_DAEMON";
|
|
27
|
+
/** maxLifetimeMs: the cap, in ms, at most 86400000; a run takes it when it is under 30 minutes, else 30 minutes. */
|
|
28
|
+
readonly maxLifetimeMs: "COMPUTER_AGENT37_MAX_LIFETIME_MS";
|
|
29
|
+
/** daemonUser: uid:gid the daemon runs as; default 2510:2510. */
|
|
30
|
+
readonly user: "COMPUTER_AGENT37_USER";
|
|
31
|
+
};
|
|
32
|
+
/** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
|
|
33
|
+
export declare const ENV: {
|
|
34
|
+
readonly live: "AGENTRUN_COMPUTER_LIVE_AGENT37";
|
|
35
|
+
/** The template every computer of the run starts from; default agent37-base, or agentrun-box for kind desktop. */
|
|
36
|
+
readonly template: "COMPUTER_AGENT37_TEMPLATE";
|
|
37
|
+
/** kind: linux (default) or desktop. */
|
|
38
|
+
readonly kind: "COMPUTER_AGENT37_KIND";
|
|
39
|
+
/** apiKey, required: the workspace's API key. */
|
|
40
|
+
readonly key: "COMPUTER_AGENT37_API_KEY";
|
|
41
|
+
/** sshKey, required: the private SSH key registered on the workspace, its contents. */
|
|
42
|
+
readonly sshKey: "COMPUTER_AGENT37_SSH_KEY";
|
|
43
|
+
/** type: vm (default) or default. */
|
|
44
|
+
readonly type: "COMPUTER_AGENT37_TYPE";
|
|
45
|
+
/** region: us (default), eu or ap-south. */
|
|
46
|
+
readonly region: "COMPUTER_AGENT37_REGION";
|
|
47
|
+
/** apiUrl: Agent37's REST API; default https://api.agent37.com. */
|
|
48
|
+
readonly apiUrl: "COMPUTER_AGENT37_API_URL";
|
|
49
|
+
/** daemonPath: the daemon binary; default this package's dist/computerd-linux-amd64. */
|
|
50
|
+
readonly daemon: "COMPUTER_AGENT37_DAEMON";
|
|
51
|
+
/** maxLifetimeMs: the cap, in ms, at most 86400000; a run takes it when it is under 30 minutes, else 30 minutes. */
|
|
52
|
+
readonly maxLifetimeMs: "COMPUTER_AGENT37_MAX_LIFETIME_MS";
|
|
53
|
+
/** daemonUser: uid:gid the daemon runs as; default 2510:2510. */
|
|
54
|
+
readonly user: "COMPUTER_AGENT37_USER";
|
|
55
|
+
};
|
|
56
|
+
/** What this module reads from the environment: the keys, and each other option whose name is set. */
|
|
57
|
+
export type Agent37Settings = Omit<Agent37Options, "ssh2" | "fetch" | "WebSocket" | "timeouts" | "probeTargets" | "proxyDomain">;
|
|
58
|
+
/**
|
|
59
|
+
* The provider's options this module reads from env, each only when its name is set; throws in words without a key,
|
|
60
|
+
* or on a value it cannot read, never echoing a key. create() checks the rest.
|
|
61
|
+
*/
|
|
62
|
+
export declare function settingsFromEnv(env?: Record<string, string | undefined>): Agent37Settings;
|
|
63
|
+
/** The longest lifetime a computer of a run may ask for: init ends it at its deadline, the sweep deletes it. */
|
|
64
|
+
export declare const CONFORMANCE_MAX_LIFETIME_MS: number;
|
|
65
|
+
/** For the run's report: what this configuration means for the suite. */
|
|
66
|
+
export declare const conformanceNotes: string[];
|
|
67
|
+
export interface Agent37ModuleOptions extends Pick<Agent37Options, "ssh2" | "fetch" | "WebSocket" | "daemonPath" | "timeouts" | "onNote"> {
|
|
68
|
+
/** Where the settings are read; default process.env. */
|
|
69
|
+
env?: Record<string, string | undefined>;
|
|
70
|
+
/** Builds this package's daemon for linux/amd64 stamped with version, and gives its path; default go build. */
|
|
71
|
+
buildDaemon?: (version: string) => Promise<string>;
|
|
72
|
+
/** For mountFor("archil"): the disk's object API, or the SDK's Archil client, in place of the host's disk package. */
|
|
73
|
+
archil?: Pick<ArchilRunFolderOptions, "objects" | "Archil" | "baseUrl">;
|
|
74
|
+
}
|
|
75
|
+
/** The template every computer of the run starts from: COMPUTER_AGENT37_TEMPLATE, or agentrun-box for kind desktop, else agent37-base. */
|
|
76
|
+
export declare function conformanceImage({ env }?: Pick<Agent37ModuleOptions, "env">): string;
|
|
77
|
+
/** The provider the CLI runs; throws in words without the live switch, or when a setting is missing or wrong. */
|
|
78
|
+
export declare function createProvider(options?: Agent37ModuleOptions): Promise<Agent37Provider>;
|
|
79
|
+
/** The same provider uploading a daemon that reports version <version>-drift, for the drift.version case. */
|
|
80
|
+
export declare function createDriftedProvider(options?: Agent37ModuleOptions): Promise<Agent37Provider>;
|
|
81
|
+
/**
|
|
82
|
+
* A run folder for an Archil mount, and none for any other kind (an Agent37 computer takes no bind): a fresh folder on
|
|
83
|
+
* the disk the COMPUTER_ARCHIL_* names name (archilSettings), none when they name none. Reaching it is a call to
|
|
84
|
+
* Archil, so it needs the live switch.
|
|
85
|
+
*/
|
|
86
|
+
export declare function mountFor(kind: MountKind, { env, archil }?: Agent37ModuleOptions): Promise<RunFolder | undefined>;
|
|
87
|
+
/**
|
|
88
|
+
* The Agent37 host the live sweep (sweep.ts) lists and deletes through, from the same settings; it needs no live
|
|
89
|
+
* switch, since the sweep makes nothing, and it calls nothing until the sweep does.
|
|
90
|
+
*/
|
|
91
|
+
export declare function createHost(options?: Pick<Agent37ModuleOptions, "env" | "ssh2" | "fetch" | "WebSocket">): Promise<MachineHost>;
|
|
92
|
+
/**
|
|
93
|
+
* Where the host lists, in words: one key is one workspace, and one listing covers all of it, every region and type
|
|
94
|
+
* (docs: instances/list). The key is named by its sha256 prefix alone, so a before file of another key is refused.
|
|
95
|
+
*/
|
|
96
|
+
export declare function sweepScope({ env }?: Pick<Agent37ModuleOptions, "env">): string;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// Agent37 for the conformance CLI: `npm run conformance -w @parcha/agentrun-computer -- --provider agent37`.
|
|
2
|
+
// It makes real instances, which bill per minute until deleted, so it runs only with AGENTRUN_COMPUTER_LIVE_AGENT37=1
|
|
3
|
+
// and a key the lead has OKed, under COMPUTER_AGENT37_API_KEY, beside COMPUTER_AGENT37_SSH_KEY, the private half (its
|
|
4
|
+
// contents) of an SSH key registered on the same workspace. The provider reads no environment: this module reads its
|
|
5
|
+
// own COMPUTER_AGENT37_* names (never AGENT37_API_KEY, which may hold another team's key) and passes each to create()
|
|
6
|
+
// as its option. The live switch is checked first, before any other setting is read. The live sweep (sweep.ts,
|
|
7
|
+
// --provider agent37) reads the same names through createHost, which needs no live switch: it makes nothing.
|
|
8
|
+
//
|
|
9
|
+
// The daemon is uploaded into each instance over SSH (dist/computerd-linux-amd64, `npm run build:daemon`), so a run
|
|
10
|
+
// publishes nothing. The drifted provider uploads a daemon built with Go as version <version>-drift. Agent37 never
|
|
11
|
+
// ends an instance on its own: every computer of a run lives at most 30 minutes, by init's deadline and the janitor's
|
|
12
|
+
// label, and the run's sweep deletes what is left.
|
|
13
|
+
//
|
|
14
|
+
// COMPUTER_AGENT37_KIND=desktop runs the desktop's cases (screen, input) on agentrun-box, the box template
|
|
15
|
+
// box/build-agent37.mjs publishes in the key's workspace: build it there first, or name another with an X server in
|
|
16
|
+
// COMPUTER_AGENT37_TEMPLATE.
|
|
17
|
+
//
|
|
18
|
+
// For the mount cases, mountFor("archil") makes a fresh run folder on the Archil disk COMPUTER_ARCHIL_DISK names, as
|
|
19
|
+
// the E2B module does (./archil.ts); with no disk named it makes none, and the cases are skipped. An Archil computer
|
|
20
|
+
// needs a provider whose daemon user is the tool user: COMPUTER_AGENT37_USER=2510:2510, the default.
|
|
21
|
+
import { create, workspaceOf } from "../agent37.js";
|
|
22
|
+
import { AGENT37_BASE_TEMPLATE, AGENT37_BOX_TEMPLATE } from "../descriptors/agent37.js";
|
|
23
|
+
import { archilRunFolder, archilSettings } from "./archil.js";
|
|
24
|
+
import { buildDriftDaemon, DRIFT_VERSION } from "./drift-daemon.js";
|
|
25
|
+
/** The Archil disk's settings for the mount cases, by name (COMPUTER_ARCHIL_*: all five, or none). */
|
|
26
|
+
export { ARCHIL_ENV } from "./archil.js";
|
|
27
|
+
/** The environment this module reads, by name, each for the option its comment names, the live switch and the run's template. */
|
|
28
|
+
export const AGENT37_ENV = {
|
|
29
|
+
live: "AGENTRUN_COMPUTER_LIVE_AGENT37",
|
|
30
|
+
/** The template every computer of the run starts from; default agent37-base, or agentrun-box for kind desktop. */
|
|
31
|
+
template: "COMPUTER_AGENT37_TEMPLATE",
|
|
32
|
+
/** kind: linux (default) or desktop. */
|
|
33
|
+
kind: "COMPUTER_AGENT37_KIND",
|
|
34
|
+
/** apiKey, required: the workspace's API key. */
|
|
35
|
+
key: "COMPUTER_AGENT37_API_KEY",
|
|
36
|
+
/** sshKey, required: the private SSH key registered on the workspace, its contents. */
|
|
37
|
+
sshKey: "COMPUTER_AGENT37_SSH_KEY",
|
|
38
|
+
/** type: vm (default) or default. */
|
|
39
|
+
type: "COMPUTER_AGENT37_TYPE",
|
|
40
|
+
/** region: us (default), eu or ap-south. */
|
|
41
|
+
region: "COMPUTER_AGENT37_REGION",
|
|
42
|
+
/** apiUrl: Agent37's REST API; default https://api.agent37.com. */
|
|
43
|
+
apiUrl: "COMPUTER_AGENT37_API_URL",
|
|
44
|
+
/** daemonPath: the daemon binary; default this package's dist/computerd-linux-amd64. */
|
|
45
|
+
daemon: "COMPUTER_AGENT37_DAEMON",
|
|
46
|
+
/** maxLifetimeMs: the cap, in ms, at most 86400000; a run takes it when it is under 30 minutes, else 30 minutes. */
|
|
47
|
+
maxLifetimeMs: "COMPUTER_AGENT37_MAX_LIFETIME_MS",
|
|
48
|
+
/** daemonUser: uid:gid the daemon runs as; default 2510:2510. */
|
|
49
|
+
user: "COMPUTER_AGENT37_USER",
|
|
50
|
+
};
|
|
51
|
+
/** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
|
|
52
|
+
export const ENV = AGENT37_ENV;
|
|
53
|
+
/**
|
|
54
|
+
* The provider's options this module reads from env, each only when its name is set; throws in words without a key,
|
|
55
|
+
* or on a value it cannot read, never echoing a key. create() checks the rest.
|
|
56
|
+
*/
|
|
57
|
+
export function settingsFromEnv(env = process.env) {
|
|
58
|
+
const apiKey = env[AGENT37_ENV.key];
|
|
59
|
+
if (apiKey === undefined || apiKey === "")
|
|
60
|
+
throw new Error(`set ${AGENT37_ENV.key} to an Agent37 API key: the conformance module reads it there and nowhere else, never from AGENT37_API_KEY`);
|
|
61
|
+
const sshKey = env[AGENT37_ENV.sshKey];
|
|
62
|
+
if (sshKey === undefined || sshKey === "")
|
|
63
|
+
throw new Error(`set ${AGENT37_ENV.sshKey} to the private SSH key registered on the Agent37 workspace (its contents, never a path)`);
|
|
64
|
+
const lifetime = env[AGENT37_ENV.maxLifetimeMs] || undefined;
|
|
65
|
+
if (lifetime !== undefined && !/^\d+$/.test(lifetime))
|
|
66
|
+
throw new Error(`${AGENT37_ENV.maxLifetimeMs} is a whole number of milliseconds, such as 86400000`);
|
|
67
|
+
const type = env[AGENT37_ENV.type] || undefined;
|
|
68
|
+
const region = env[AGENT37_ENV.region] || undefined;
|
|
69
|
+
const apiUrl = env[AGENT37_ENV.apiUrl] || undefined;
|
|
70
|
+
const daemonPath = env[AGENT37_ENV.daemon] || undefined;
|
|
71
|
+
const daemonUser = env[AGENT37_ENV.user] || undefined;
|
|
72
|
+
const kind = env[AGENT37_ENV.kind] || undefined;
|
|
73
|
+
return {
|
|
74
|
+
apiKey,
|
|
75
|
+
sshKey,
|
|
76
|
+
// create() refuses any other type or region in words.
|
|
77
|
+
...(type === undefined ? {} : { type: type }),
|
|
78
|
+
...(region === undefined ? {} : { region: region }),
|
|
79
|
+
...(kind === undefined ? {} : { kind: kind }),
|
|
80
|
+
...(apiUrl === undefined ? {} : { apiUrl }),
|
|
81
|
+
...(daemonPath === undefined ? {} : { daemonPath }),
|
|
82
|
+
...(lifetime === undefined ? {} : { maxLifetimeMs: Number(lifetime) }),
|
|
83
|
+
...(daemonUser === undefined ? {} : { daemonUser }),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/** The longest lifetime a computer of a run may ask for: init ends it at its deadline, the sweep deletes it. */
|
|
87
|
+
export const CONFORMANCE_MAX_LIFETIME_MS = 30 * 60_000;
|
|
88
|
+
/** For the run's report: what this configuration means for the suite. */
|
|
89
|
+
export const conformanceNotes = [
|
|
90
|
+
"agent37: every computer is an instance (type vm by default), made with network deny-all, auto-sleep off and no public port, read back from Agent37 and probed from inside; the daemon is a child, started over SSH through the platform's sshd (port 22022; it and the platform's web terminal on 7681 are declared as the vendor's agent), and every command goes over that SSH as root. Agent37 never ends an instance on its own: lifetime janitor, capped at 30 minutes for the run. No stream() (a screen is streamed through agentrun), so screen.stream is skipped. Kind desktop (COMPUTER_AGENT37_KIND=desktop) starts from agentrun-box, our box image as a template of the key's workspace (box/build-agent37.mjs), with Xvfb on :0 started through the daemon as the tool user.",
|
|
91
|
+
];
|
|
92
|
+
function live(env) {
|
|
93
|
+
if (env[AGENT37_ENV.live] !== "1") {
|
|
94
|
+
throw new Error(`the Agent37 conformance module makes real instances, which bill until deleted: set ${AGENT37_ENV.live}=1, with a key the lead has OKed, to run it`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/** The template every computer of the run starts from: COMPUTER_AGENT37_TEMPLATE, or agentrun-box for kind desktop, else agent37-base. */
|
|
98
|
+
export function conformanceImage({ env = process.env } = {}) {
|
|
99
|
+
return env[AGENT37_ENV.template] || (env[AGENT37_ENV.kind] === "desktop" ? AGENT37_BOX_TEMPLATE : AGENT37_BASE_TEMPLATE);
|
|
100
|
+
}
|
|
101
|
+
/** The test doubles a caller hands in, each only when given. */
|
|
102
|
+
const doubles = ({ ssh2, fetch, WebSocket, timeouts, onNote }) => ({
|
|
103
|
+
...(ssh2 ? { ssh2 } : {}),
|
|
104
|
+
...(fetch ? { fetch } : {}),
|
|
105
|
+
...(WebSocket ? { WebSocket } : {}),
|
|
106
|
+
...(timeouts ? { timeouts } : {}),
|
|
107
|
+
...(onNote ? { onNote } : {}),
|
|
108
|
+
});
|
|
109
|
+
/** A run's cap: COMPUTER_AGENT37_MAX_LIFETIME_MS when it is shorter, else CONFORMANCE_MAX_LIFETIME_MS. */
|
|
110
|
+
const runCap = (settings) => Math.min(settings.maxLifetimeMs ?? CONFORMANCE_MAX_LIFETIME_MS, CONFORMANCE_MAX_LIFETIME_MS);
|
|
111
|
+
/** The provider the CLI runs; throws in words without the live switch, or when a setting is missing or wrong. */
|
|
112
|
+
export async function createProvider(options = {}) {
|
|
113
|
+
const { env = process.env, daemonPath } = options;
|
|
114
|
+
live(env);
|
|
115
|
+
const settings = settingsFromEnv(env);
|
|
116
|
+
return create({ ...settings, ...doubles(options), ...(daemonPath === undefined ? {} : { daemonPath }), maxLifetimeMs: runCap(settings) });
|
|
117
|
+
}
|
|
118
|
+
/** The same provider uploading a daemon that reports version <version>-drift, for the drift.version case. */
|
|
119
|
+
export async function createDriftedProvider(options = {}) {
|
|
120
|
+
const { env = process.env, buildDaemon = (version) => buildDriftDaemon("amd64", version) } = options;
|
|
121
|
+
live(env);
|
|
122
|
+
const settings = settingsFromEnv(env);
|
|
123
|
+
const daemonPath = await buildDaemon(DRIFT_VERSION);
|
|
124
|
+
return create({ ...settings, ...doubles(options), daemonPath, maxLifetimeMs: runCap(settings) });
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* A run folder for an Archil mount, and none for any other kind (an Agent37 computer takes no bind): a fresh folder on
|
|
128
|
+
* the disk the COMPUTER_ARCHIL_* names name (archilSettings), none when they name none. Reaching it is a call to
|
|
129
|
+
* Archil, so it needs the live switch.
|
|
130
|
+
*/
|
|
131
|
+
export async function mountFor(kind, { env = process.env, archil = {} } = {}) {
|
|
132
|
+
if (kind !== "archil")
|
|
133
|
+
return undefined;
|
|
134
|
+
const settings = archilSettings(env);
|
|
135
|
+
if (settings === undefined)
|
|
136
|
+
return undefined;
|
|
137
|
+
live(env);
|
|
138
|
+
return archilRunFolder({ ...settings, ...archil });
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* The Agent37 host the live sweep (sweep.ts) lists and deletes through, from the same settings; it needs no live
|
|
142
|
+
* switch, since the sweep makes nothing, and it calls nothing until the sweep does.
|
|
143
|
+
*/
|
|
144
|
+
export async function createHost(options = {}) {
|
|
145
|
+
return (await create({ ...settingsFromEnv(options.env ?? process.env), ...doubles(options) })).host;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Where the host lists, in words: one key is one workspace, and one listing covers all of it, every region and type
|
|
149
|
+
* (docs: instances/list). The key is named by its sha256 prefix alone, so a before file of another key is refused.
|
|
150
|
+
*/
|
|
151
|
+
export function sweepScope({ env = process.env } = {}) {
|
|
152
|
+
const { apiKey, apiUrl } = settingsFromEnv(env);
|
|
153
|
+
return workspaceOf(apiKey, apiUrl);
|
|
154
|
+
}
|
|
@@ -1,2 +1,13 @@
|
|
|
1
1
|
import type { Case } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* The first way ui.observe's result breaks the protocol, in words, or undefined: its state, app, window and truncated,
|
|
4
|
+
* and each node against UiNode, its bounds inside the window and its parent a node before it.
|
|
5
|
+
*/
|
|
6
|
+
export declare function observeWrong(result: unknown): string | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* The stock apps a Linux desktop may have, by their desktop file ids, any vendor's: the text editor and the terminal of
|
|
9
|
+
* Xfce, which E2B Desktop's template and the box image (box/build-agent37.mjs) both carry, and xterm, which a bare
|
|
10
|
+
* desktop has (the Docker suite's, test/fixtures/desktop).
|
|
11
|
+
*/
|
|
12
|
+
export declare const DESKTOP_APPS: readonly string[];
|
|
2
13
|
export declare const appsCases: Case[];
|