@parcha/agentrun-computer 0.1.0-beta.36 → 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 +321 -308
- package/box/build-agent37.mjs +177 -0
- 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/browserbase.d.ts +2 -4
- package/dist/browserbase.js +2 -1
- 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/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 +2 -4
- package/dist/daytona.js +3 -2
- package/dist/descriptor.d.ts +5 -0
- package/dist/descriptor.js +2 -0
- package/dist/descriptors/agent37.d.ts +41 -0
- package/dist/descriptors/agent37.js +28 -0
- package/dist/descriptors/index.d.ts +38 -2
- 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/docker.d.ts +7 -4
- package/dist/docker.js +271 -29
- 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 +7 -3
- package/dist/index.js +7 -4
- package/dist/kernel.d.ts +2 -4
- package/dist/kernel.js +2 -1
- package/dist/kinds.d.ts +8 -1
- package/dist/kinds.js +20 -4
- package/dist/local-chrome.d.ts +2 -4
- package/dist/local-chrome.js +2 -1
- package/dist/modal.d.ts +23 -181
- package/dist/modal.js +271 -1244
- 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 -4
- package/dist/orgo.js +30 -12
- package/dist/phone-harness.d.ts +31 -22
- package/dist/phone-harness.js +510 -698
- package/dist/png.d.ts +4 -0
- package/dist/png.js +27 -0
- package/dist/protocol.d.ts +335 -32
- package/dist/protocol.js +96 -3
- package/dist/provider.d.ts +34 -6
- package/dist/provider.js +16 -0
- 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
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
// Build the box image (this folder's Dockerfile, plus Xvfb for a desktop) as a template of an Agent37 workspace, through
|
|
2
|
+
// Agent37's cloud build, with the workspace's key in AGENT37_API_KEY, and print the template's name: an Agent37 desktop
|
|
3
|
+
// starts from it (src/descriptors/agent37.ts AGENT37_BOX_TEMPLATE), and so can an Archil computer.
|
|
4
|
+
//
|
|
5
|
+
// Agent37 keeps a template's revisions under one name (docs: agents-api/templates), so the name is fixed, agentrun-box,
|
|
6
|
+
// and the recipe's hash (the Dockerfile, the files it copies and DESKTOP below) goes in the template's description: a
|
|
7
|
+
// workspace whose template already names this hash is built nothing, and a changed recipe publishes a new revision,
|
|
8
|
+
// which every instance made after it starts from. Builds are free, at most three at once per workspace and 45 minutes
|
|
9
|
+
// each. The calls, in order (docs: templates, "Build an image in the cloud"):
|
|
10
|
+
//
|
|
11
|
+
// GET /v1/templates/agentrun-box its description, or 404
|
|
12
|
+
// POST /v1/template-builds { name, size_bytes, description } -> { id, upload_url }
|
|
13
|
+
// PUT <upload_url> the gzipped context, Dockerfile at its root, no Agent37 key
|
|
14
|
+
// POST /v1/template-builds/{id}/start
|
|
15
|
+
// GET /v1/template-builds/{id}/logs?offset=N until status succeeded or failed (a poll registers the template)
|
|
16
|
+
//
|
|
17
|
+
// AGENT37_API_KEY=... node packages/computer/box/build-agent37.mjs
|
|
18
|
+
import { createHash } from "node:crypto";
|
|
19
|
+
import { readFileSync } from "node:fs";
|
|
20
|
+
import { dirname, join } from "node:path";
|
|
21
|
+
import { fileURLToPath } from "node:url";
|
|
22
|
+
import { gzipSync } from "node:zlib";
|
|
23
|
+
|
|
24
|
+
/** The template's name in every workspace: AGENT37_BOX_TEMPLATE. */
|
|
25
|
+
export const NAME = "agentrun-box";
|
|
26
|
+
export const API_URL = "https://api.agent37.com";
|
|
27
|
+
/** Every file the image is made of besides DESKTOP: the Dockerfile and what it copies, as build-e2b.mjs hashes them. */
|
|
28
|
+
export const RECIPE = ["Dockerfile", "agentrun-archil"];
|
|
29
|
+
/**
|
|
30
|
+
* What a desktop adds to box/Dockerfile: Xvfb, which the provider starts through computerd as the tool user on :0
|
|
31
|
+
* (src/desktop.ts). Nothing starts it here, and no window manager, VNC server or sudo comes with it.
|
|
32
|
+
*/
|
|
33
|
+
export const DESKTOP = `
|
|
34
|
+
# A desktop (build-agent37.mjs): Xvfb, which the provider starts through computerd as the tool user on :0.
|
|
35
|
+
RUN set -eu; \\
|
|
36
|
+
apt-get update -qq; \\
|
|
37
|
+
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends xvfb >/dev/null; \\
|
|
38
|
+
rm -rf /var/lib/apt/lists/*; \\
|
|
39
|
+
command -v Xvfb >/dev/null || { echo "the image has no Xvfb" >&2; exit 1; }; \\
|
|
40
|
+
! command -v sudo >/dev/null 2>&1 || { echo "the image has sudo" >&2; exit 1; }
|
|
41
|
+
`;
|
|
42
|
+
/** How often a build's log is read, and the longest a build is waited for: Agent37's 45 minutes, and some. */
|
|
43
|
+
const POLL_MS = 5_000;
|
|
44
|
+
const BUILD_MS = 50 * 60_000;
|
|
45
|
+
|
|
46
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
47
|
+
|
|
48
|
+
/** The recipe's files, read from dir, with the context's Dockerfile (box/Dockerfile and DESKTOP), and its 12-hex hash. */
|
|
49
|
+
export function recipeOf(dir = here) {
|
|
50
|
+
const files = Object.fromEntries(RECIPE.map((name) => [name, readFileSync(join(dir, name))]));
|
|
51
|
+
const dockerfile = Buffer.concat([files.Dockerfile, Buffer.from(DESKTOP)]);
|
|
52
|
+
const hash = createHash("sha256")
|
|
53
|
+
.update(Buffer.concat([...RECIPE.map((name) => files[name]), Buffer.from(DESKTOP)]))
|
|
54
|
+
.digest("hex")
|
|
55
|
+
.slice(0, 12);
|
|
56
|
+
return { hash, files: { ...files, Dockerfile: dockerfile } };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** The template's description: the recipe's hash is how a later build knows this one is current. */
|
|
60
|
+
export const descriptionOf = (hash) => `AgentRun's box image (Archil client and helper, tool user, Xvfb), recipe ${hash}`;
|
|
61
|
+
|
|
62
|
+
/** One ustar header block: a file at the archive's root, owned by root. */
|
|
63
|
+
function header(name, mode, size) {
|
|
64
|
+
const block = Buffer.alloc(512);
|
|
65
|
+
const octal = (value, width) => `${value.toString(8).padStart(width - 1, "0")}\0`;
|
|
66
|
+
block.write(name, 0, 100);
|
|
67
|
+
block.write(octal(mode, 8), 100);
|
|
68
|
+
block.write(octal(0, 8), 108);
|
|
69
|
+
block.write(octal(0, 8), 116);
|
|
70
|
+
block.write(octal(size, 12), 124);
|
|
71
|
+
block.write(octal(0, 12), 136);
|
|
72
|
+
block.write(" ", 148);
|
|
73
|
+
block.write("0", 156);
|
|
74
|
+
block.write("ustar\0", 257);
|
|
75
|
+
block.write("00", 263);
|
|
76
|
+
let sum = 0;
|
|
77
|
+
for (const byte of block) sum += byte;
|
|
78
|
+
block.write(`${sum.toString(8).padStart(6, "0")}\0 `, 148);
|
|
79
|
+
return block;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** The build's context: a gzipped tar of the Dockerfile (0644) and the helper (0755), at its root. */
|
|
83
|
+
export function contextOf({ files }) {
|
|
84
|
+
const parts = [];
|
|
85
|
+
for (const [name, mode] of [
|
|
86
|
+
["Dockerfile", 0o644],
|
|
87
|
+
["agentrun-archil", 0o755],
|
|
88
|
+
]) {
|
|
89
|
+
const body = files[name];
|
|
90
|
+
parts.push(header(name, mode, body.length), body, Buffer.alloc((512 - (body.length % 512)) % 512));
|
|
91
|
+
}
|
|
92
|
+
parts.push(Buffer.alloc(1024));
|
|
93
|
+
return gzipSync(Buffer.concat(parts));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** An answer that is not a success, in Agent37's words (its envelope's code and message), never with the key. */
|
|
97
|
+
async function failure(what, response) {
|
|
98
|
+
const text = await response.text().catch(() => "");
|
|
99
|
+
let error;
|
|
100
|
+
try {
|
|
101
|
+
error = JSON.parse(text)?.error;
|
|
102
|
+
} catch {
|
|
103
|
+
// Not JSON: its status alone.
|
|
104
|
+
}
|
|
105
|
+
const code = typeof error === "string" ? error : error?.code;
|
|
106
|
+
const message = typeof error === "object" ? error?.message : undefined;
|
|
107
|
+
return new Error(`${what} answered ${response.status}${code ? ` ${code}` : ""}${message ? `: ${message}` : ""}`);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Builds the recipe as the template NAME unless the workspace's template already names its hash, and answers the
|
|
112
|
+
* template's name, revision and digest (revision and digest undefined when nothing was built). log gets the build's
|
|
113
|
+
* log as it comes.
|
|
114
|
+
*/
|
|
115
|
+
export async function build({ apiKey, fetch = globalThis.fetch, apiUrl = API_URL, dir = here, log = (text) => process.stderr.write(text), pollMs = POLL_MS, buildMs = BUILD_MS }) {
|
|
116
|
+
if (typeof apiKey !== "string" || apiKey === "") throw new Error("set AGENT37_API_KEY to the workspace's Agent37 API key, for this one command");
|
|
117
|
+
const auth = { Authorization: `Bearer ${apiKey}`, Accept: "application/json" };
|
|
118
|
+
const rest = async (method, path, body) => {
|
|
119
|
+
const response = await fetch(`${apiUrl}${path}`, {
|
|
120
|
+
method,
|
|
121
|
+
headers: { ...auth, ...(body === undefined ? {} : { "Content-Type": "application/json" }) },
|
|
122
|
+
...(body === undefined ? {} : { body: JSON.stringify(body) }),
|
|
123
|
+
signal: AbortSignal.timeout(60_000),
|
|
124
|
+
});
|
|
125
|
+
if (!response.ok) throw await failure(`${method} ${path}`, response);
|
|
126
|
+
return response.json();
|
|
127
|
+
};
|
|
128
|
+
const recipe = recipeOf(dir);
|
|
129
|
+
const description = descriptionOf(recipe.hash);
|
|
130
|
+
log(`build-agent37: template ${NAME}, recipe ${recipe.hash}\n`);
|
|
131
|
+
|
|
132
|
+
const current = await fetch(`${apiUrl}/v1/templates/${NAME}`, { headers: auth, signal: AbortSignal.timeout(60_000) });
|
|
133
|
+
if (current.ok) {
|
|
134
|
+
const template = await current.json();
|
|
135
|
+
if (template?.description === description) {
|
|
136
|
+
log(`build-agent37: ${NAME} revision ${template.revision} is this recipe already; nothing built\n`);
|
|
137
|
+
return { name: NAME, revision: template.revision, digest: template.image_digest };
|
|
138
|
+
}
|
|
139
|
+
} else if (current.status !== 404) {
|
|
140
|
+
throw await failure(`GET /v1/templates/${NAME}`, current);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const context = contextOf(recipe);
|
|
144
|
+
const made = await rest("POST", "/v1/template-builds", { name: NAME, size_bytes: context.length, description });
|
|
145
|
+
if (typeof made?.id !== "string" || typeof made?.upload_url !== "string") throw new Error("POST /v1/template-builds answered no id or upload_url");
|
|
146
|
+
log(`build-agent37: build ${made.id}, context ${context.length} bytes\n`);
|
|
147
|
+
// The presigned URL takes no Agent37 key, and fetch sends no Expect header.
|
|
148
|
+
const uploaded = await fetch(made.upload_url, { method: "PUT", body: context, headers: { "Content-Type": "application/gzip" }, signal: AbortSignal.timeout(300_000) });
|
|
149
|
+
if (!uploaded.ok) throw await failure("the context's upload", uploaded);
|
|
150
|
+
await rest("POST", `/v1/template-builds/${made.id}/start`, {});
|
|
151
|
+
|
|
152
|
+
const end = Date.now() + buildMs;
|
|
153
|
+
let offset = 0;
|
|
154
|
+
for (;;) {
|
|
155
|
+
const read = await rest("GET", `/v1/template-builds/${made.id}/logs?offset=${offset}`);
|
|
156
|
+
if (typeof read?.data === "string" && read.data !== "") log(read.data);
|
|
157
|
+
if (Number.isSafeInteger(read?.offset)) offset = read.offset;
|
|
158
|
+
if (read?.status === "succeeded") {
|
|
159
|
+
const { name = NAME, revision, image_digest: digest } = read.template ?? {};
|
|
160
|
+
log(`\nbuild-agent37: ${name} revision ${revision}, ${digest}\n`);
|
|
161
|
+
return { name, revision, digest };
|
|
162
|
+
}
|
|
163
|
+
if (read?.status === "failed") throw new Error(`build ${made.id} failed: ${read.error?.code ?? "no code"}${read.error?.message ? `: ${read.error.message}` : ""}`);
|
|
164
|
+
if (Date.now() > end) throw new Error(`build ${made.id} was not done within ${buildMs / 60_000} minutes (status ${read?.status}); Agent37 ends a build at 45`);
|
|
165
|
+
await new Promise((resolve) => setTimeout(resolve, pollMs));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (import.meta.main) {
|
|
170
|
+
try {
|
|
171
|
+
const { name } = await build({ apiKey: process.env.AGENT37_API_KEY });
|
|
172
|
+
console.log(`template=${name}`);
|
|
173
|
+
} catch (error) {
|
|
174
|
+
console.error(`build-agent37: ${error.message}`);
|
|
175
|
+
process.exit(1);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { Duplex } from "node:stream";
|
|
2
|
+
import { HostedProvider, type HostedOptions, type HostedTimeouts } from "./hosted/provider.js";
|
|
3
|
+
import type { KindCapabilities } from "./kinds.js";
|
|
4
|
+
import type { MountKind } from "./mount.js";
|
|
5
|
+
/** A readable side of an ssh2 channel, as this provider uses it: piped, or drained. */
|
|
6
|
+
export interface Ssh2Readable {
|
|
7
|
+
pipe(destination: NodeJS.WritableStream): unknown;
|
|
8
|
+
resume(): unknown;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The slice of an ssh2 channel this provider uses (ssh2@1.17.0 lib/Channel.js): the channel is stdout. No signal
|
|
12
|
+
* request: ssh2 sends one only while stdin is open (Channel.js:237-246), so a kill goes by the process group instead.
|
|
13
|
+
*/
|
|
14
|
+
export interface Ssh2Channel extends Ssh2Readable {
|
|
15
|
+
readonly stderr: Ssh2Readable;
|
|
16
|
+
write(data: Uint8Array, callback?: (error?: Error | null) => void): boolean;
|
|
17
|
+
/** Sends end of file on stdin and keeps the channel open (Channel.js:200-205). */
|
|
18
|
+
eof(): void;
|
|
19
|
+
close(): void;
|
|
20
|
+
/** exit-status, or exit-signal with a null code (client.js:666-678). */
|
|
21
|
+
on(event: "exit", listener: (code: number | null, signal?: string) => void): unknown;
|
|
22
|
+
on(event: "close", listener: () => void): unknown;
|
|
23
|
+
on(event: "error", listener: (error: Error) => void): unknown;
|
|
24
|
+
}
|
|
25
|
+
/** The options of ssh2's Client.connect this provider gives (ssh2@1.17.0 lib/client.js). */
|
|
26
|
+
export interface Ssh2ConnectConfig {
|
|
27
|
+
sock: Duplex;
|
|
28
|
+
username: "root";
|
|
29
|
+
privateKey: string;
|
|
30
|
+
readyTimeout: number;
|
|
31
|
+
keepaliveInterval: number;
|
|
32
|
+
}
|
|
33
|
+
/** The slice of an ssh2 Client this provider uses. */
|
|
34
|
+
export interface Ssh2Client {
|
|
35
|
+
connect(config: Ssh2ConnectConfig): unknown;
|
|
36
|
+
exec(command: string, callback: (error: Error | undefined, channel: Ssh2Channel) => void): unknown;
|
|
37
|
+
end(): unknown;
|
|
38
|
+
destroy(): unknown;
|
|
39
|
+
once(event: "ready", listener: () => void): unknown;
|
|
40
|
+
once(event: "error", listener: (error: Error) => void): unknown;
|
|
41
|
+
on(event: "error", listener: (error: Error) => void): unknown;
|
|
42
|
+
on(event: "close", listener: () => void): unknown;
|
|
43
|
+
removeListener(event: "error", listener: (error: Error) => void): unknown;
|
|
44
|
+
}
|
|
45
|
+
/** The ssh2 package as this provider uses it: its Client class. The host's own, or anything with the same slice. */
|
|
46
|
+
export interface Ssh2Module {
|
|
47
|
+
Client: new () => Ssh2Client;
|
|
48
|
+
}
|
|
49
|
+
/** A WebSocket as this provider uses one: Node's global WebSocket (undici), which takes headers, or the same slice. */
|
|
50
|
+
export interface WebSocketLike {
|
|
51
|
+
binaryType: string;
|
|
52
|
+
readonly readyState: number;
|
|
53
|
+
readonly bufferedAmount: number;
|
|
54
|
+
send(data: Uint8Array): void;
|
|
55
|
+
close(code?: number, reason?: string): void;
|
|
56
|
+
addEventListener(type: "open" | "close" | "error", listener: (event: {
|
|
57
|
+
code?: number;
|
|
58
|
+
reason?: string;
|
|
59
|
+
message?: string;
|
|
60
|
+
}) => void): void;
|
|
61
|
+
addEventListener(type: "message", listener: (event: {
|
|
62
|
+
data: unknown;
|
|
63
|
+
}) => void): void;
|
|
64
|
+
}
|
|
65
|
+
export type WebSocketClass = new (url: string, init: {
|
|
66
|
+
headers: Record<string, string>;
|
|
67
|
+
}) => WebSocketLike;
|
|
68
|
+
/** One Agent37 instance as the REST API answers it (docs: agents-api/instances/object), as far as this provider reads it. */
|
|
69
|
+
export interface Agent37Instance {
|
|
70
|
+
id: string;
|
|
71
|
+
status: string;
|
|
72
|
+
status_reason?: {
|
|
73
|
+
code?: string;
|
|
74
|
+
message?: string;
|
|
75
|
+
} | null;
|
|
76
|
+
template?: string;
|
|
77
|
+
image_digest?: string | null;
|
|
78
|
+
type?: string;
|
|
79
|
+
region?: string;
|
|
80
|
+
resources?: {
|
|
81
|
+
cpu?: number;
|
|
82
|
+
memory?: number;
|
|
83
|
+
disk?: number;
|
|
84
|
+
};
|
|
85
|
+
public_ports?: unknown[];
|
|
86
|
+
name?: string | null;
|
|
87
|
+
metadata?: Record<string, string> | null;
|
|
88
|
+
auto_sleep?: boolean;
|
|
89
|
+
network?: unknown;
|
|
90
|
+
created?: number;
|
|
91
|
+
}
|
|
92
|
+
/** What Agent37 runs an instance on: a VM with its own kernel, or a gVisor sandbox (docs: agents-api/vm-instances). */
|
|
93
|
+
export type Agent37Type = "vm" | "default";
|
|
94
|
+
/** Where an instance runs (docs: agents-api/instances/create, region). */
|
|
95
|
+
export type Agent37Region = "us" | "eu" | "ap-south";
|
|
96
|
+
/** The Agent37 provider's options: the key, the SSH key and ssh2, then the shared adapter's (HostedOptions). */
|
|
97
|
+
export interface Agent37ProviderOptions extends Omit<HostedOptions, "label" | "maxLifetimeMs"> {
|
|
98
|
+
/** The workspace's API key (sk_live_...). The caller passes it; this provider never reads it from the environment. */
|
|
99
|
+
apiKey: string;
|
|
100
|
+
/**
|
|
101
|
+
* The private half of an SSH key registered on the same workspace (POST /v1/ssh-keys), in OpenSSH or PEM form: its
|
|
102
|
+
* contents, never a path. Every command reaches an instance over SSH as root with it.
|
|
103
|
+
*/
|
|
104
|
+
sshKey: string;
|
|
105
|
+
/** The ssh2 package: the host's own, or anything with the same slice. */
|
|
106
|
+
ssh2: Ssh2Module;
|
|
107
|
+
/** The fetch every REST call goes through; default the global one. */
|
|
108
|
+
fetch?: typeof fetch;
|
|
109
|
+
/** The WebSocket the SSH stream rides; default Node's global one. */
|
|
110
|
+
WebSocket?: WebSocketClass;
|
|
111
|
+
/** Agent37's REST API; default https://api.agent37.com. */
|
|
112
|
+
apiUrl?: string;
|
|
113
|
+
/** The domain an instance's ports answer under, {id}-{port}.<domain>; default agent37.app. */
|
|
114
|
+
proxyDomain?: string;
|
|
115
|
+
/** vm (default): a whole VM with its own kernel; default: Agent37's gVisor sandbox. */
|
|
116
|
+
type?: Agent37Type;
|
|
117
|
+
/** us (default), eu or ap-south; outside us, type vm alone. */
|
|
118
|
+
region?: Agent37Region;
|
|
119
|
+
/**
|
|
120
|
+
* linux (default): no screen; desktop: an X server started through the daemon (Xvfb on :0 unless options.desktop says
|
|
121
|
+
* otherwise), so the spec's image is a template that has one: our box template, agentrun-box (box/build-agent37.mjs).
|
|
122
|
+
*/
|
|
123
|
+
kind?: "desktop" | "linux";
|
|
124
|
+
/** The longest lifetime check takes: 24 h by default, the janitor's cap; Agent37 itself never ends an instance. */
|
|
125
|
+
maxLifetimeMs?: number;
|
|
126
|
+
timeouts?: Partial<HostedTimeouts>;
|
|
127
|
+
}
|
|
128
|
+
/** What create() takes: the provider's options, ssh2 optional (default the host's ssh2 package). */
|
|
129
|
+
export interface Agent37Options extends Omit<Agent37ProviderOptions, "ssh2"> {
|
|
130
|
+
ssh2?: Ssh2Module;
|
|
131
|
+
}
|
|
132
|
+
/** The port the platform's sshd answers on inside every instance, reached as {id}-22022.<domain> (cli.js:21, 720). */
|
|
133
|
+
export declare const AGENT37_SSH_PORT = 22022;
|
|
134
|
+
/** The mount kinds an Agent37 computer takes, as capabilities().mount declares them: the run's folder on an Archil disk. */
|
|
135
|
+
export declare const MOUNT: readonly MountKind[];
|
|
136
|
+
/** The machine kind and groups of each configuration: kind linux (the default), and kind desktop on the box template. */
|
|
137
|
+
export declare const CAPABILITIES: readonly KindCapabilities[];
|
|
138
|
+
/** An answer of Agent37's REST API that is not a success: its HTTP status and the envelope's stable code (docs: errors). */
|
|
139
|
+
export declare class Agent37Error extends Error {
|
|
140
|
+
name: string;
|
|
141
|
+
readonly status: number;
|
|
142
|
+
readonly code: string | undefined;
|
|
143
|
+
constructor(status: number, code: string | undefined, message: string);
|
|
144
|
+
}
|
|
145
|
+
/** The SSH tunnel's WebSocket closed or failed before it opened, or while it carried the stream. */
|
|
146
|
+
export declare class Agent37TunnelError extends Error {
|
|
147
|
+
name: string;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* An Agent37Provider from its options alone; it reads no environment. The key is options.apiKey and the SSH key
|
|
151
|
+
* options.sshKey, nowhere else (serve passes its AGENT37_API_KEY and AGENT37_SSH_KEY, the conformance module what it
|
|
152
|
+
* reads), and ssh2 is the host's package unless given. Throws in words when an option is missing or wrong, never echoing a key.
|
|
153
|
+
*/
|
|
154
|
+
export declare function create(options: Agent37Options): Promise<Agent37Provider>;
|
|
155
|
+
/** The conformance CLI's module for Agent37: its live switch, the run's cap, its template and the drifted twin. */
|
|
156
|
+
export declare const conformance: () => Promise<typeof import("./conformance/agent37.js")>;
|
|
157
|
+
/**
|
|
158
|
+
* Computers that are Agent37 instances, on the shared adapter. A spec's image is an Agent37 template's name:
|
|
159
|
+
* "agent37-base", Agent37's plain Linux, for a sandbox; "agentrun-box", our box template with Xvfb, for a desktop.
|
|
160
|
+
*/
|
|
161
|
+
export declare class Agent37Provider extends HostedProvider {
|
|
162
|
+
constructor(options: Agent37ProviderOptions);
|
|
163
|
+
}
|
|
164
|
+
/** The workspace a key reaches, in words, for the sweep's scope: the key's sha256 prefix, never the key. */
|
|
165
|
+
export declare function workspaceOf(apiKey: string, apiUrl?: string): string;
|