@parcha/agentrun-computer 0.1.0-beta.39 → 0.1.0-beta.41
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 +56 -21
- package/box/Dockerfile +11 -58
- package/box/README.md +15 -2
- package/box/build-daytona.py +4 -2
- package/box/build-e2b.mjs +1 -1
- package/box/install.sh +148 -0
- package/box/recipe.mjs +12 -10
- package/dist/agent37.js +2 -1
- package/dist/attach.d.ts +46 -1
- package/dist/attach.js +48 -4
- package/dist/box-image.d.ts +2 -0
- package/dist/box-image.js +10 -0
- package/dist/computerd-linux-amd64 +0 -0
- package/dist/computerd-linux-arm64 +0 -0
- package/dist/computerd.json +2 -2
- package/dist/conformance/cases/isolation.js +17 -1
- package/dist/conformance/cases/lifetime.js +30 -0
- package/dist/conformance/cases/provider.js +63 -1
- package/dist/conformance/cli.js +27 -5
- package/dist/conformance/daytona.d.ts +25 -0
- package/dist/conformance/daytona.js +26 -1
- package/dist/conformance/exec-stream.d.ts +37 -7
- package/dist/conformance/exec-stream.js +349 -89
- package/dist/conformance/report.js +3 -0
- package/dist/conformance/runner.js +134 -12
- package/dist/conformance/sweep.d.ts +7 -2
- package/dist/conformance/sweep.js +17 -7
- package/dist/conformance/types.d.ts +42 -0
- package/dist/daytona.d.ts +8 -1
- package/dist/daytona.js +126 -101
- package/dist/descriptor.d.ts +22 -1
- package/dist/descriptor.js +18 -0
- package/dist/descriptors/daytona.d.ts +12 -3
- package/dist/descriptors/daytona.js +15 -7
- package/dist/descriptors/index.d.ts +8 -1
- package/dist/e2b.js +1 -1
- package/dist/host.d.ts +91 -26
- package/dist/host.js +5 -0
- package/dist/hosted/framed-exec.d.ts +38 -0
- package/dist/hosted/framed-exec.js +119 -0
- package/dist/hosted/process.d.ts +13 -5
- package/dist/hosted/process.js +39 -14
- package/dist/hosted/provider.d.ts +48 -6
- package/dist/hosted/provider.js +435 -64
- package/dist/hosted/rest.d.ts +29 -0
- package/dist/hosted/rest.js +91 -6
- package/dist/hosted/scripts.d.ts +58 -0
- package/dist/hosted/scripts.js +138 -1
- package/dist/hosted/ssh-exec.d.ts +7 -6
- package/dist/hosted/ssh-exec.js +35 -52
- package/dist/hosted/values.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/kinds.d.ts +2 -0
- package/dist/modal.js +21 -8
- package/dist/providers.d.ts +4 -2
- package/package.json +1 -1
package/dist/attach.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// with the token it got by pairing, and the same JSON-RPC messages travel as text frames, one message per frame. Serve
|
|
4
4
|
// is the caller: it sends hello first, then the run's calls. The AttachHub keeps one live connection per paired
|
|
5
5
|
// computer; attachedProvider hands that computer to a run as a provider, one run at a time.
|
|
6
|
-
import { randomUUID } from "node:crypto";
|
|
6
|
+
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
7
7
|
import { PassThrough, Writable } from "node:stream";
|
|
8
8
|
import { DaemonClient } from "./client.js";
|
|
9
9
|
import { kindServed } from "./kinds.js";
|
|
@@ -11,6 +11,8 @@ import { PROTOCOL_VERSION } from "./protocol.js";
|
|
|
11
11
|
import { checkLifetime, kindRefusals, runLifetimeMs } from "./provider.js";
|
|
12
12
|
import { fail, ok } from "./result.js";
|
|
13
13
|
export const ATTACH_PATH = "/v2/computers/attach";
|
|
14
|
+
/** Where a hosted machine that dials fetches the server's computerd for its arch (?arch=amd64|arm64), with its token. */
|
|
15
|
+
export const DAEMON_PATH = "/v2/computers/daemon";
|
|
14
16
|
/** The WebSocket subprotocol a driver asks for: the protocol version it speaks. Serve answers with it or refuses. */
|
|
15
17
|
export const ATTACH_SUBPROTOCOL = `agentrun.computer.${PROTOCOL_VERSION}`;
|
|
16
18
|
/** Each side pings this often (WebSocket ping frames, not JSON-RPC), so a NAT keeps the path open. */
|
|
@@ -89,6 +91,39 @@ export function socketStreams(socket) {
|
|
|
89
91
|
});
|
|
90
92
|
return { readable, writable };
|
|
91
93
|
}
|
|
94
|
+
const sha256 = (token) => createHash("sha256").update(token).digest("hex");
|
|
95
|
+
/**
|
|
96
|
+
* MachineTokens in one process's memory, as serve's store keeps them (the sha256 alone): for tests and a conformance
|
|
97
|
+
* kit. check is what the server's attach and daemon routes ask of a token.
|
|
98
|
+
*/
|
|
99
|
+
export class MemoryMachineTokens {
|
|
100
|
+
#held = new Map();
|
|
101
|
+
#hashOf = new Map();
|
|
102
|
+
// No await in either: a mint replaces the machine's token at once, so two of one machine leave one token, not two.
|
|
103
|
+
async mint(machine, mint) {
|
|
104
|
+
this.#drop(machine);
|
|
105
|
+
const token = `art_${randomBytes(32).toString("hex")}`;
|
|
106
|
+
this.#held.set(sha256(token), { machine, mint: { ...mint } });
|
|
107
|
+
this.#hashOf.set(machine, sha256(token));
|
|
108
|
+
return token;
|
|
109
|
+
}
|
|
110
|
+
async revoke(machine) {
|
|
111
|
+
this.#drop(machine);
|
|
112
|
+
}
|
|
113
|
+
#drop(machine) {
|
|
114
|
+
this.#held.delete(this.#hashOf.get(machine) ?? "");
|
|
115
|
+
this.#hashOf.delete(machine);
|
|
116
|
+
}
|
|
117
|
+
/** The machine and mint a token is good for at `at`: undefined for one unknown, revoked, or past its expiresAt. */
|
|
118
|
+
check(token, at = new Date()) {
|
|
119
|
+
const held = this.#held.get(sha256(token));
|
|
120
|
+
return held === undefined || at.getTime() > held.mint.expiresAt.getTime() ? undefined : held;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/** A minted machine as the AttachHub takes its socket: under the machine's name, its hello held to the mint. */
|
|
124
|
+
export function mintedComputer(machine, { kind, os, arch }) {
|
|
125
|
+
return { id: machine, name: machine, hello: { protocol: PROTOCOL_VERSION, version: "", os, kind, arch, groups: [] }, labels: {}, minted: true };
|
|
126
|
+
}
|
|
92
127
|
/** Whether protocol version a ("0.3") comes after b ("0.2"), part by part as numbers. */
|
|
93
128
|
function laterProtocol(a, b) {
|
|
94
129
|
const [x, y] = [a, b].map((version) => version.split(".").map((part) => Number.parseInt(part, 10) || 0));
|
|
@@ -103,8 +138,9 @@ function laterProtocol(a, b) {
|
|
|
103
138
|
* replace it the way a provider replaces a copied daemon.
|
|
104
139
|
*/
|
|
105
140
|
export function helloMismatch(paired, hello) {
|
|
106
|
-
// Serve names no OS and no driver app: one way to update, in the same words for every computer.
|
|
107
|
-
|
|
141
|
+
// Serve names no OS and no driver app: one way to update, in the same words for every computer. A minted machine
|
|
142
|
+
// fetched this server's own computerd at boot, so another build there is not one this server gave it.
|
|
143
|
+
const update = paired.minted ? `${paired.name} runs a computerd that is not this server's build: create the computer again` : `update the driver on ${paired.name} (the download is on the console's Computers page)`;
|
|
108
144
|
const said = hello;
|
|
109
145
|
if (typeof said !== "object" || said === null || typeof said.protocol !== "string" || typeof said.version !== "string") {
|
|
110
146
|
return { code: ATTACH_CLOSE.protocol, message: `${paired.name}'s driver answered hello without its protocol and version: ${update}` };
|
|
@@ -124,6 +160,10 @@ export function helloMismatch(paired, hello) {
|
|
|
124
160
|
if (missing.length > 0) {
|
|
125
161
|
return { code: ATTACH_CLOSE.protocol, message: `${paired.name}'s driver ${hello.version} answered a protocol ${PROTOCOL_VERSION} hello without ${missing.join(", ")}: ${update}` };
|
|
126
162
|
}
|
|
163
|
+
if (paired.minted && (hello.kind !== paired.hello.kind || hello.os !== paired.hello.os || hello.arch !== paired.hello.arch)) {
|
|
164
|
+
const was = paired.hello;
|
|
165
|
+
return { code: ATTACH_CLOSE.mismatch, message: `${paired.name} was made a ${was.os} ${was.kind} on ${was.arch} and says ${hello.os} ${hello.kind} on ${hello.arch}: its token is that machine's alone` };
|
|
166
|
+
}
|
|
127
167
|
if (hello.kind !== paired.hello.kind || hello.os !== paired.hello.os) {
|
|
128
168
|
return { code: ATTACH_CLOSE.mismatch, message: `${paired.name} paired as a ${paired.hello.os} ${paired.hello.kind} and now says ${hello.os} ${hello.kind}: pair it again` };
|
|
129
169
|
}
|
|
@@ -207,7 +247,7 @@ export class AttachHub {
|
|
|
207
247
|
}
|
|
208
248
|
if (closed)
|
|
209
249
|
return fail("gone", `${paired.name}'s socket closed while it said hello`);
|
|
210
|
-
mine = { socket, client, hello: hello.value, dial };
|
|
250
|
+
mine = { socket, client, hello: hello.value, dial, since: new Date() };
|
|
211
251
|
this.#live.set(paired.id, mine);
|
|
212
252
|
older?.socket.close(ATTACH_CLOSE.replaced, "the computer dialed again");
|
|
213
253
|
return hello;
|
|
@@ -216,6 +256,10 @@ export class AttachHub {
|
|
|
216
256
|
online(id) {
|
|
217
257
|
return this.#live.has(id);
|
|
218
258
|
}
|
|
259
|
+
/** When the computer's live connection said hello and went live; undefined while it is not attached. */
|
|
260
|
+
since(id) {
|
|
261
|
+
return this.#live.get(id)?.since;
|
|
262
|
+
}
|
|
219
263
|
/** The hello of the computer's live connection: its driver's version and groups now, which an update may change. */
|
|
220
264
|
hello(id) {
|
|
221
265
|
return this.#live.get(id)?.hello;
|
package/dist/box-image.d.ts
CHANGED
|
@@ -12,3 +12,5 @@ export declare const boxImageRef: () => string;
|
|
|
12
12
|
export declare const BOX_E2B_PUBLISHER = "agentrun-oss";
|
|
13
13
|
/** The public E2B template of the box image this package's recipe names: <publisher>/agentrun-archil-<recipe hash>. */
|
|
14
14
|
export declare const boxE2bTemplate: () => string;
|
|
15
|
+
/** Whether an image is a box image by its name: this release's or an older one's, whatever the recipe hash. */
|
|
16
|
+
export declare const isBoxImage: (image: string) => boolean;
|
package/dist/box-image.js
CHANGED
|
@@ -22,3 +22,13 @@ export const boxImageRef = () => `${BOX_IMAGE_REPOSITORY}:${boxRecipeHash()}`;
|
|
|
22
22
|
export const BOX_E2B_PUBLISHER = "agentrun-oss";
|
|
23
23
|
/** The public E2B template of the box image this package's recipe names: <publisher>/agentrun-archil-<recipe hash>. */
|
|
24
24
|
export const boxE2bTemplate = () => `${BOX_E2B_PUBLISHER}/agentrun-archil-${boxRecipeHash()}`;
|
|
25
|
+
const literal = (text) => text.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
|
|
26
|
+
/**
|
|
27
|
+
* Every name a box image goes by, a prefix and a recipe hash (12 hex): the published image
|
|
28
|
+
* (ghcr.io/parcha-ai/agentrun-box:<hash>), Agent37's workspace template (agentrun-box-<hash>), the E2B template and the
|
|
29
|
+
* Daytona snapshot (agentrun-archil-<hash>, the public E2B one under its publisher), and Daytona's GPU snapshots
|
|
30
|
+
* (agentrun-archil-gpu-<type>-<hash>).
|
|
31
|
+
*/
|
|
32
|
+
const BOX_IMAGE_NAME = new RegExp(`^(?:${literal(BOX_IMAGE_REPOSITORY)}:|agentrun-box-|(?:${literal(BOX_E2B_PUBLISHER)}/)?agentrun-archil-(?:gpu-[a-z0-9]+-)?)[0-9a-f]{12}$`);
|
|
33
|
+
/** Whether an image is a box image by its name: this release's or an older one's, whatever the recipe hash. */
|
|
34
|
+
export const isBoxImage = (image) => BOX_IMAGE_NAME.test(image);
|
|
Binary file
|
|
Binary file
|
package/dist/computerd.json
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// A program the computer's user runs reaches none of the vendor's own agent, whose ports each provider declares
|
|
2
2
|
// (capabilities().vendorAgentPorts), and no outside address, sees its own loopback alone, and finds nothing listening in
|
|
3
|
-
// its own network but computerd: computerd init --own-network at work. And it can write nothing root runs
|
|
3
|
+
// its own network but computerd: computerd init --own-network at work. And it can write nothing root runs, nor read the
|
|
4
|
+
// labels a provider keeps in the machine.
|
|
4
5
|
import { DAEMON_IN_COMPUTER, SOCKET_DIR } from "../../drift.js";
|
|
5
6
|
import { EGRESS_PROXY_SOCKET } from "../../hosted/network.js";
|
|
7
|
+
import { LABEL_FILE } from "../../hosted/scripts.js";
|
|
6
8
|
import { ARCHIL_HELPER, ARCHIL_SYNC_SOCKET } from "../../mount-archil.js";
|
|
7
9
|
/**
|
|
8
10
|
* The unix sockets a program of the computer's user may connect to: the computer's own, computerd's, the Archil sync
|
|
@@ -176,4 +178,18 @@ export const isolationCases = [
|
|
|
176
178
|
await assertRootRunsClosed(t);
|
|
177
179
|
},
|
|
178
180
|
},
|
|
181
|
+
{
|
|
182
|
+
// The label file of a host that keeps no labels is root's alone: absent or unreadable passes, readable fails.
|
|
183
|
+
id: "isolation.label-file",
|
|
184
|
+
level: "core",
|
|
185
|
+
group: "isolation",
|
|
186
|
+
needs: ["files"],
|
|
187
|
+
async run(t) {
|
|
188
|
+
const read = await t.client.call("files.read", { path: LABEL_FILE });
|
|
189
|
+
if (read.ok)
|
|
190
|
+
return t.assert(false, `the computer's user reads ${LABEL_FILE}, the labels the provider keeps in the machine`);
|
|
191
|
+
t.observe(`${LABEL_FILE}, as the computer's user: ${read.error.code}`);
|
|
192
|
+
t.refused(read, `files.read of ${LABEL_FILE} as the computer's user`, ["not_found", "denied"]);
|
|
193
|
+
},
|
|
194
|
+
},
|
|
179
195
|
];
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { CASE_LABEL } from "./util.js";
|
|
2
|
+
/** How long lifetime.idle leaves its computer quiet: past the shortest vendor idle timer known (Alibaba's 5 min). */
|
|
3
|
+
const IDLE_MS = 6 * 60_000;
|
|
4
|
+
/** Its computer's lifetime: the quiet, and four minutes to make it, connect and read it. */
|
|
5
|
+
const IDLE_LIFETIME_MS = IDLE_MS + 4 * 60_000;
|
|
2
6
|
/** A deadline read back may be a second off the one extend returned: a label or a vendor timer can round. */
|
|
3
7
|
const SLACK_MS = 1000;
|
|
4
8
|
/** How far short of the cap the last extend asks, at least 60 s after create: it lands at least 30 s past create + cap. */
|
|
@@ -61,4 +65,30 @@ export const lifetimeCases = [
|
|
|
61
65
|
await refused(underCap, `extend to ${underCap / 1000} s, past create + maxLifetimeMs (${maxLifetimeMs} ms)`);
|
|
62
66
|
},
|
|
63
67
|
},
|
|
68
|
+
{
|
|
69
|
+
id: "lifetime.idle",
|
|
70
|
+
level: "full",
|
|
71
|
+
group: "lifetime",
|
|
72
|
+
needs: [],
|
|
73
|
+
computer: "none",
|
|
74
|
+
timeoutMs: IDLE_LIFETIME_MS + 60_000,
|
|
75
|
+
async run(t) {
|
|
76
|
+
const minutes = IDLE_MS / 60_000;
|
|
77
|
+
t.long(`it leaves a computer quiet ${minutes} min`);
|
|
78
|
+
const { maxLifetimeMs } = t.provider.capabilities();
|
|
79
|
+
if (!(maxLifetimeMs >= IDLE_LIFETIME_MS))
|
|
80
|
+
return t.skip(`lifetime.idle needs a maxLifetimeMs of ${IDLE_LIFETIME_MS / 60_000} min or more, not ${maxLifetimeMs} ms`);
|
|
81
|
+
const labels = { ...t.runLabels, [CASE_LABEL]: "idle" };
|
|
82
|
+
const ref = await t.create({ lifetimeMs: IDLE_LIFETIME_MS, labels });
|
|
83
|
+
const first = await t.connect(ref);
|
|
84
|
+
t.deepEqual(t.ok(await first.client.call("ping", {}), "ping"), {}, "ping after create");
|
|
85
|
+
await first.close();
|
|
86
|
+
// No call and no connection: a vendor's idle timer (Alibaba's 5 min, Azure's, Cloudflare's inactivity) would end it.
|
|
87
|
+
await t.clock.sleep(IDLE_MS);
|
|
88
|
+
const quiet = `after ${minutes} min with no call, well inside its lifetime`;
|
|
89
|
+
t.deepEqual(t.ok(await t.provider.list(labels), "list").map((info) => [info.ref.name, info.state]), [[ref.name, "running"]], `${quiet}: still listed, running (a vendor's idle timer ends a quiet computer under the run: turn it off, or keep the computer busy)`);
|
|
90
|
+
const back = await t.connect(ref);
|
|
91
|
+
t.deepEqual(t.ok(await back.client.call("ping", {}), "ping"), {}, `${quiet}: its daemon answers ping`);
|
|
92
|
+
},
|
|
93
|
+
},
|
|
64
94
|
];
|
|
@@ -2,8 +2,14 @@
|
|
|
2
2
|
// what they say, the network reads back as asked, a change to a network the provider does not declare is refused
|
|
3
3
|
// (Core) and one it does declare is refused or applied truthfully (Full), a computer does not run past its deadline,
|
|
4
4
|
// the janitor ends only the expired, stopped or running, and a takeover releases the run's lower epochs by label (Full).
|
|
5
|
-
// A create retried with its request id answers the computer the first made, and after release is refused (Full).
|
|
5
|
+
// A create retried with its request id answers the computer the first made, and after release is refused (Full). A
|
|
6
|
+
// deleted computer stays gone: no call to it brings it back. A provider's prepareImage() and its descriptor's flag agree, and
|
|
7
|
+
// prepareImage called twice answers one image and makes it once.
|
|
8
|
+
// A dial host's machine token is its machine's alone, and ends at delete and at backstopAt (Core).
|
|
6
9
|
import { randomBytes } from "node:crypto";
|
|
10
|
+
import { ATTACH_CLOSE } from "../../attach.js";
|
|
11
|
+
import { BACKSTOP_MARGIN_MS } from "../../host.js";
|
|
12
|
+
import { descriptorOf } from "../../providers.js";
|
|
7
13
|
import { releaseOlder, sweep } from "../../janitor.js";
|
|
8
14
|
import { EPOCH_LABEL, OWNER_LABEL, RUN_LABEL, runLabels } from "../../labels.js";
|
|
9
15
|
import { computerNameFor, runLifetimeMs } from "../../provider.js";
|
|
@@ -164,6 +170,11 @@ export const providerCases = [
|
|
|
164
170
|
t.ok(await t.provider.release(ref, "delete"), "a second delete of the same computer");
|
|
165
171
|
t.deepEqual(await names(t, labels), [], "listed after delete");
|
|
166
172
|
t.refused(await t.provider.connect(ref), "connect to a deleted computer", ["gone", "not_found"]);
|
|
173
|
+
// A vendor that wakes a machine on the next call (a session resumed on request, a cold start) brings a deleted
|
|
174
|
+
// computer back: after the refused connect it stays gone, to attach, a second connect, and list.
|
|
175
|
+
t.refused(await t.provider.attach({ id: ref.id }), "attach to the deleted computer, after a connect to it", ["not_found"]);
|
|
176
|
+
t.refused(await t.provider.connect(ref), "a second connect to the deleted computer", ["gone", "not_found"]);
|
|
177
|
+
t.deepEqual(await names(t, labels), [], "listed after the calls to the deleted computer: nothing came back");
|
|
167
178
|
}),
|
|
168
179
|
provider("create-retried", async (t) => {
|
|
169
180
|
// A retry of one request, at once and after it is up, answers the computer the first made: never a second.
|
|
@@ -235,6 +246,33 @@ export const providerCases = [
|
|
|
235
246
|
t.assert(deadline >= before + lifetimeMs - 1000 && deadline <= after + lifetimeMs + 1000, `its deadline, ${String(info.deadline)}, is lifetimeMs after create`);
|
|
236
247
|
t.deepEqual(await names(t, { ...labels, role: "other" }), [], "list by a label no computer has");
|
|
237
248
|
}),
|
|
249
|
+
// prepareImage is declared by the provider's method; its descriptor's flag says the same to Settings, which reads it
|
|
250
|
+
// without loading the provider's module. The two agree: a server never skips a provider's image, nor asks one it has
|
|
251
|
+
// not got. A provider on the machine-host adapter has its host's descriptor; another, the registry's for its id.
|
|
252
|
+
// Then prepareImage twice in one run (spec/computer/provider.md, "prepareImage"): both answer the same image, and the
|
|
253
|
+
// second finds the one the first made by its name, so it is told no onWait. A server calls it before its first create,
|
|
254
|
+
// so one that builds every time costs every server minutes. A provider with none passes, observed. Core: the first
|
|
255
|
+
// call costs at most a build per account and recipe, which the account's first create pays anyway.
|
|
256
|
+
provider("prepare-image", async (t) => {
|
|
257
|
+
const descriptor = t.provider.host?.descriptor ?? descriptorOf(t.provider.id);
|
|
258
|
+
const prepare = t.provider.prepareImage?.bind(t.provider);
|
|
259
|
+
if (descriptor !== undefined)
|
|
260
|
+
t.assert((prepare !== undefined) === (descriptor.prepareImage === true), prepare !== undefined
|
|
261
|
+
? `${descriptor.label}'s provider has prepareImage() but its descriptor does not declare prepareImage: Settings never calls it`
|
|
262
|
+
: `${descriptor.label}'s descriptor declares prepareImage, but its provider has no prepareImage(): give the provider class one`);
|
|
263
|
+
if (prepare === undefined)
|
|
264
|
+
return t.observe("the provider has no prepareImage(): its computers start from an image a spec names");
|
|
265
|
+
const call = async (which) => {
|
|
266
|
+
const told = [];
|
|
267
|
+
const image = t.ok(await prepare({ signal: t.signal, onWait: (making, tag) => told.push(`${making} ${tag}`) }), `the ${which} prepareImage`);
|
|
268
|
+
return { image, told: told.length === 0 ? "" : `onWait(${told.join("; ")})` };
|
|
269
|
+
};
|
|
270
|
+
const first = await call("first");
|
|
271
|
+
t.observe(first.told === "" ? `the first prepareImage found ${first.image} and was told no onWait` : `the first prepareImage was told ${first.told} and answered ${first.image}`);
|
|
272
|
+
const second = await call("second");
|
|
273
|
+
t.equal(second.image, first.image, "the second prepareImage's image");
|
|
274
|
+
t.assert(second.told === "", `the second prepareImage was told ${second.told}: it must find the image the first made by its name (one that carries the box recipe's hash) and answer it with no build and no pull`);
|
|
275
|
+
}, { timeoutMs: 20 * 60_000 }),
|
|
238
276
|
// Stop is declared or refused: a provider that declares it lists the computer stopped; one that does not refuses it
|
|
239
277
|
// in words and leaves the computer running, never stopped or deleted behind the caller's back.
|
|
240
278
|
provider("stop", async (t) => {
|
|
@@ -338,6 +376,30 @@ export const providerCases = [
|
|
|
338
376
|
t.ok(await t.provider.release(ref, "delete"), "release delete of the agent's computer");
|
|
339
377
|
t.deepEqual(await names(t, labels), [], "listed after delete");
|
|
340
378
|
}, { level: "full", needs: ["persistence", "files"] }),
|
|
379
|
+
// A machine that dials holds a token of its own (spec/computer/attach.md, Hosted machines that dial): good for that
|
|
380
|
+
// machine's hello alone, refused past its backstop and after its delete; and a server no machine can reach makes none.
|
|
381
|
+
provider("dial-token", async (t) => {
|
|
382
|
+
if (t.provider.host?.facts?.connect !== "dial")
|
|
383
|
+
return t.observe("the provider's machines do not dial the server, so they hold no machine token");
|
|
384
|
+
const kit = await t.dial();
|
|
385
|
+
const bare = kit.unreachable();
|
|
386
|
+
const refused = t.refused(await t.attempt(t.spec({ labels: own(t, "dial-token") }), bare.provider), "create on a server with no public address", ["refused"]);
|
|
387
|
+
t.match(refused.message, /public https address/, "create on a server with no public address: the refusal");
|
|
388
|
+
t.equal(bare.creates(), 0, "the vendor's creates asked for by a create on a server with no public address");
|
|
389
|
+
const ref = await t.create({ labels: own(t, "dial-token") });
|
|
390
|
+
const { hello } = await t.connect(ref);
|
|
391
|
+
const token = t.present(kit.token(ref), `the token ${ref.name}'s machine was given`);
|
|
392
|
+
t.equal(await kit.check(token, new Date()), ref.name, "the machine's token, now");
|
|
393
|
+
// Past the machine's backstop: create's time, the most it may live and the margin, and a minute.
|
|
394
|
+
const past = new Date(Date.now() + t.provider.capabilities().maxLifetimeMs + BACKSTOP_MARGIN_MS + 60_000);
|
|
395
|
+
t.equal(await kit.check(token, past), undefined, "the machine's token past its backstop");
|
|
396
|
+
const others = [{ kind: hello.kind === "linux" ? "desktop" : "linux" }, { os: hello.os === "linux" ? "windows" : "linux" }, { arch: hello.arch === "amd64" ? "arm64" : "amd64" }];
|
|
397
|
+
for (const other of others) {
|
|
398
|
+
t.equal(await kit.dialAs(token, { ...hello, ...other }), ATTACH_CLOSE.mismatch, `the machine's token with a hello of ${JSON.stringify(other)}: the close code`);
|
|
399
|
+
}
|
|
400
|
+
t.ok(await t.provider.release(ref, "delete"), "release delete");
|
|
401
|
+
t.equal(await kit.check(token, new Date()), undefined, "the machine's token after its delete");
|
|
402
|
+
}),
|
|
341
403
|
provider("network-change", async (t) => {
|
|
342
404
|
const spec = t.spec({ labels: own(t, "network") });
|
|
343
405
|
const ref = await t.create(spec);
|
package/dist/conformance/cli.js
CHANGED
|
@@ -18,7 +18,7 @@ import { formatReport } from "./report.js";
|
|
|
18
18
|
import { runConformance } from "./runner.js";
|
|
19
19
|
/** Writes text and settles once the stream has taken it, so an exit after it cuts nothing off. */
|
|
20
20
|
const write = (stream, text) => new Promise((resolve) => void stream.write(text, () => resolve()));
|
|
21
|
-
const USAGE = `usage: npm run conformance -w @parcha/agentrun-computer -- --provider ${providerIds.join("|")}|<module.js> [--image <image>] [--only <group|case>,... | --kind <kind>] [--fixture <path>] [--gpu <type>[:<count>]] [--json]
|
|
21
|
+
const USAGE = `usage: npm run conformance -w @parcha/agentrun-computer -- --provider ${providerIds.join("|")}|<module.js> [--image <image>] [--only <group|case>,... | --kind <kind>] [--fixture <path>] [--gpu <type>[:<count>]] [--long] [--concurrency <n>] [--json]
|
|
22
22
|
--provider a computer in the registry (${providerIds.join(", ")}), or a module path: a provider file that exports
|
|
23
23
|
create(options), or a conformance module that exports createProvider() (and, for the drift case,
|
|
24
24
|
createDriftedProvider(); for the mount cases, mountFor(kind), a fresh run folder for that mount kind)
|
|
@@ -32,11 +32,18 @@ const USAGE = `usage: npm run conformance -w @parcha/agentrun-computer -- --prov
|
|
|
32
32
|
desktop, the fixture APK for an Android phone
|
|
33
33
|
--gpu the GPU the gpu case's one computer asks for, a type the provider declares and a count (default 1), such
|
|
34
34
|
as T4 or H100:2; it bills by the second, so without it the gpu case skips
|
|
35
|
+
--long run the long cases too, which wait minutes on a vendor's timer: lifetime.idle leaves a computer quiet
|
|
36
|
+
6 min and reads it running; the live sweep gives it, and without it they skip
|
|
37
|
+
--concurrency
|
|
38
|
+
the most computers alive at once, for a plan that keeps fewer (default no cap; the report says the
|
|
39
|
+
run's peak). The run's computer makes way for a case's own; a case that needs more fails
|
|
35
40
|
--json print the report as JSON
|
|
36
41
|
--exec-stream --machine <id> [--quick]
|
|
37
42
|
the exec pre-check, alone: the module's createHost() and host.exec, nothing else, on a machine you made
|
|
38
|
-
by hand.
|
|
39
|
-
the exit code, kill, and a silent process of ${DEFAULT_LONG_MS / 1000} s (--quick: ${QUICK_LONG_MS / 1000} s)
|
|
43
|
+
by hand. Text of every kind both ways, 8 MiB by sha256, output and stdin while the process runs, stdin while
|
|
44
|
+
stdout is left unread, stderr apart, the exit code, kill, and a silent process of ${DEFAULT_LONG_MS / 1000} s (--quick: ${QUICK_LONG_MS / 1000} s)
|
|
45
|
+
that is not cut off; then what the machine offers: root's network namespace, /dev/fuse, the arch, the
|
|
46
|
+
kernel (gVisor) and the TCP listeners, each with what it means for your host
|
|
40
47
|
exit: 0 Core passes, 1 it fails, 2 usage error, 3 partial (--only) and every case that ran passed; with --kind,
|
|
41
48
|
0 the provider passes the kind, 1 it does not; with --exec-stream, 0 every check passes, 1 one fails`;
|
|
42
49
|
const PROVIDER_METHODS = ["capabilities", "check", "create", "attach", "list", "network", "connect", "release"];
|
|
@@ -81,6 +88,14 @@ function parse(argv, cases) {
|
|
|
81
88
|
args.fixture = value();
|
|
82
89
|
else if (flag === "--gpu")
|
|
83
90
|
args.gpu = gpuOf(value());
|
|
91
|
+
else if (flag === "--long")
|
|
92
|
+
args.long = true;
|
|
93
|
+
else if (flag === "--concurrency") {
|
|
94
|
+
const given = value();
|
|
95
|
+
if (!/^[1-9][0-9]*$/.test(given) || !Number.isSafeInteger(Number(given)))
|
|
96
|
+
throw new Usage(`--concurrency: ${JSON.stringify(given)} is not a whole number of computers, 1 or more`);
|
|
97
|
+
args.concurrency = Number(given);
|
|
98
|
+
}
|
|
84
99
|
else if (flag === "--exec-stream")
|
|
85
100
|
execStream = true;
|
|
86
101
|
else if (flag === "--machine")
|
|
@@ -101,7 +116,7 @@ function parse(argv, cases) {
|
|
|
101
116
|
if (execStream) {
|
|
102
117
|
if (machine === undefined)
|
|
103
118
|
throw new Usage("--exec-stream needs --machine <id>, a machine you made by hand");
|
|
104
|
-
const others = ["image", "only", "kind", "fixture", "gpu"].filter((name) => args[name] !== undefined);
|
|
119
|
+
const others = ["image", "only", "kind", "fixture", "gpu", "long", "concurrency"].filter((name) => args[name] !== undefined);
|
|
105
120
|
if (others.length > 0)
|
|
106
121
|
throw new Usage(`--exec-stream runs alone: drop ${others.map((name) => `--${name}`).join(", ")}`);
|
|
107
122
|
return { provider: args.provider, execStream: { machine, quick }, json: args.json, help: false };
|
|
@@ -123,6 +138,8 @@ function parse(argv, cases) {
|
|
|
123
138
|
...(args.kind ? { kind: args.kind } : {}),
|
|
124
139
|
...(args.fixture ? { fixture: args.fixture } : {}),
|
|
125
140
|
...(args.gpu ? { gpu: args.gpu } : {}),
|
|
141
|
+
...(args.long ? { long: args.long } : {}),
|
|
142
|
+
...(args.concurrency ? { concurrency: args.concurrency } : {}),
|
|
126
143
|
json: args.json,
|
|
127
144
|
help: false,
|
|
128
145
|
};
|
|
@@ -210,7 +227,7 @@ export function plantSecrets(names) {
|
|
|
210
227
|
* register its image, so it is given the run's signal), and conformanceNotes, strings for the report.
|
|
211
228
|
*/
|
|
212
229
|
async function load(label, module, options, { imageNamed, signal }, declared) {
|
|
213
|
-
const { createProvider, createDriftedProvider, conformanceImage, mountFor } = module;
|
|
230
|
+
const { createProvider, createDriftedProvider, conformanceImage, mountFor, dialKit } = module;
|
|
214
231
|
if (typeof createProvider !== "function")
|
|
215
232
|
throw new Usage(`${label} does not export createProvider() or create()`);
|
|
216
233
|
const provider = (await createProvider(options));
|
|
@@ -236,6 +253,8 @@ async function load(label, module, options, { imageNamed, signal }, declared) {
|
|
|
236
253
|
}
|
|
237
254
|
if (typeof mountFor === "function")
|
|
238
255
|
target.mountFor = (kind) => mountFor(kind, options);
|
|
256
|
+
if (typeof dialKit === "function")
|
|
257
|
+
target.dial = () => dialKit(options);
|
|
239
258
|
if (conformanceImage !== undefined && !imageNamed) {
|
|
240
259
|
const image = typeof conformanceImage === "function" ? await conformanceImage(options, signal ? { signal } : {}) : undefined;
|
|
241
260
|
if (typeof image !== "string" || image === "")
|
|
@@ -327,11 +346,14 @@ export async function main(argv, io = {}) {
|
|
|
327
346
|
...(args.kind ? { kind: args.kind } : {}),
|
|
328
347
|
...(args.fixture ? { fixture: resolve(cwd, args.fixture) } : {}),
|
|
329
348
|
...(args.gpu ? { gpu: args.gpu } : {}),
|
|
349
|
+
...(args.long ? { long: true } : {}),
|
|
350
|
+
...(args.concurrency ? { concurrency: args.concurrency } : {}),
|
|
330
351
|
...(signal ? { signal } : {}),
|
|
331
352
|
...(target.drifted ? { drifted: target.drifted } : {}),
|
|
332
353
|
...(target.declared ? { declared: target.declared } : {}),
|
|
333
354
|
...(target.planted ? { planted: target.planted } : {}),
|
|
334
355
|
...(target.mountFor ? { mountFor: target.mountFor } : {}),
|
|
356
|
+
...(target.dial ? { dial: target.dial } : {}),
|
|
335
357
|
...(onResult ? { onResult } : {}),
|
|
336
358
|
...(io.cdp ? { cdp: io.cdp } : {}),
|
|
337
359
|
});
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { type DaytonaProvider, type DaytonaProviderOptions } from "../daytona.js";
|
|
2
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";
|
|
3
8
|
/** The environment this module reads, by name, each for the option its comment names. */
|
|
4
9
|
export declare const DAYTONA_ENV: {
|
|
5
10
|
/** apiKey, required: the Daytona API key. */
|
|
@@ -20,6 +25,11 @@ export declare const DAYTONA_ENV: {
|
|
|
20
25
|
readonly snapshot: "COMPUTER_DAYTONA_SNAPSHOT";
|
|
21
26
|
/** gpuSnapshot: the GPU snapshot of box/Dockerfile GPU computers are made from (box/build-daytona.py --gpu); default daytona-gpu. */
|
|
22
27
|
readonly gpuSnapshot: "COMPUTER_DAYTONA_GPU_SNAPSHOT";
|
|
28
|
+
/**
|
|
29
|
+
* archilEgress: a self-hosted Daytona target's Archil egress relay, <IPv4 gateway>:<mount lane>:<data lane>. Set, the
|
|
30
|
+
* provider takes an Archil mount; unset, it refuses one (Archil's client hangs on Daytona's hosted cloud).
|
|
31
|
+
*/
|
|
32
|
+
readonly archilEgress: "COMPUTER_DAYTONA_ARCHIL_EGRESS";
|
|
23
33
|
};
|
|
24
34
|
/** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
|
|
25
35
|
export declare const ENV: {
|
|
@@ -41,6 +51,11 @@ export declare const ENV: {
|
|
|
41
51
|
readonly snapshot: "COMPUTER_DAYTONA_SNAPSHOT";
|
|
42
52
|
/** gpuSnapshot: the GPU snapshot of box/Dockerfile GPU computers are made from (box/build-daytona.py --gpu); default daytona-gpu. */
|
|
43
53
|
readonly gpuSnapshot: "COMPUTER_DAYTONA_GPU_SNAPSHOT";
|
|
54
|
+
/**
|
|
55
|
+
* archilEgress: a self-hosted Daytona target's Archil egress relay, <IPv4 gateway>:<mount lane>:<data lane>. Set, the
|
|
56
|
+
* provider takes an Archil mount; unset, it refuses one (Archil's client hangs on Daytona's hosted cloud).
|
|
57
|
+
*/
|
|
58
|
+
readonly archilEgress: "COMPUTER_DAYTONA_ARCHIL_EGRESS";
|
|
44
59
|
};
|
|
45
60
|
/**
|
|
46
61
|
* The provider's options this module reads from env, each only when its name is set; throws in words without the key,
|
|
@@ -65,6 +80,16 @@ export interface DaytonaModuleOptions {
|
|
|
65
80
|
}
|
|
66
81
|
/** The image every computer of the run starts from: COMPUTER_DAYTONA_SNAPSHOT, or Daytona's default snapshot. */
|
|
67
82
|
export declare function conformanceImage({ env }?: Pick<DaytonaModuleOptions, "env">): string;
|
|
83
|
+
/**
|
|
84
|
+
* A fresh run folder for the mount cases: an Archil one on the disk the COMPUTER_ARCHIL_* settings name (the shared
|
|
85
|
+
* archilRunFolder; the run's snapshot is then one of box/Dockerfile, and COMPUTER_DAYTONA_USER is 2510:2510), only where
|
|
86
|
+
* COMPUTER_DAYTONA_ARCHIL_EGRESS names the target's relay, since the provider takes an Archil mount only then; none
|
|
87
|
+
* otherwise, and none for a bind, which a remote computer cannot take.
|
|
88
|
+
*/
|
|
89
|
+
export declare function mountFor(kind: MountKind, { env, archil }?: {
|
|
90
|
+
env?: Record<string, string | undefined>;
|
|
91
|
+
archil?: Pick<ArchilRunFolderOptions, "objects" | "Archil" | "baseUrl">;
|
|
92
|
+
}): Promise<RunFolder | undefined>;
|
|
68
93
|
/** The provider the CLI runs; throws in words when a setting is missing or wrong. */
|
|
69
94
|
export declare function createProvider(options?: DaytonaModuleOptions): DaytonaProvider;
|
|
70
95
|
/**
|
|
@@ -3,10 +3,15 @@
|
|
|
3
3
|
// another organization's key on a host that runs other Daytona work) and passes each to create() as its option, the key
|
|
4
4
|
// read only when createProvider() runs. Every sandbox of a run has a bounded life besides its TTL: Daytona stops one
|
|
5
5
|
// after 30 minutes with no outside activity and deletes it as soon as it stops (see conformanceNotes). The live sweep
|
|
6
|
-
// (sweep.ts, --provider daytona) reads the same names through createHost: it makes nothing.
|
|
6
|
+
// (sweep.ts, --provider daytona) reads the same names through createHost: it makes nothing. The mount cases run on a
|
|
7
|
+
// self-hosted Daytona target alone: COMPUTER_DAYTONA_ARCHIL_EGRESS names its Archil egress relay, and the
|
|
8
|
+
// COMPUTER_ARCHIL_* settings the disk (mountFor).
|
|
7
9
|
import { create } from "../daytona.js";
|
|
8
10
|
import { DAYTONA_DEFAULT_SNAPSHOT } from "../descriptors/daytona.js";
|
|
11
|
+
import { archilRunFolder, archilSettings } from "./archil.js";
|
|
9
12
|
import { buildDriftDaemon, DRIFT_VERSION } from "./drift-daemon.js";
|
|
13
|
+
/** The Archil disk's settings for the mount cases, by name (COMPUTER_ARCHIL_*: all five, or none). */
|
|
14
|
+
export { ARCHIL_ENV } from "./archil.js";
|
|
10
15
|
/** The environment this module reads, by name, each for the option its comment names. */
|
|
11
16
|
export const DAYTONA_ENV = {
|
|
12
17
|
/** apiKey, required: the Daytona API key. */
|
|
@@ -27,6 +32,11 @@ export const DAYTONA_ENV = {
|
|
|
27
32
|
snapshot: "COMPUTER_DAYTONA_SNAPSHOT",
|
|
28
33
|
/** gpuSnapshot: the GPU snapshot of box/Dockerfile GPU computers are made from (box/build-daytona.py --gpu); default daytona-gpu. */
|
|
29
34
|
gpuSnapshot: "COMPUTER_DAYTONA_GPU_SNAPSHOT",
|
|
35
|
+
/**
|
|
36
|
+
* archilEgress: a self-hosted Daytona target's Archil egress relay, <IPv4 gateway>:<mount lane>:<data lane>. Set, the
|
|
37
|
+
* provider takes an Archil mount; unset, it refuses one (Archil's client hangs on Daytona's hosted cloud).
|
|
38
|
+
*/
|
|
39
|
+
archilEgress: "COMPUTER_DAYTONA_ARCHIL_EGRESS",
|
|
30
40
|
};
|
|
31
41
|
/** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
|
|
32
42
|
export const ENV = DAYTONA_ENV;
|
|
@@ -46,6 +56,7 @@ export function settingsFromEnv(env = process.env) {
|
|
|
46
56
|
const sandboxClass = named(DAYTONA_ENV.sandboxClass);
|
|
47
57
|
const user = named(DAYTONA_ENV.user);
|
|
48
58
|
const gpuSnapshot = named(DAYTONA_ENV.gpuSnapshot);
|
|
59
|
+
const archilEgress = named(DAYTONA_ENV.archilEgress);
|
|
49
60
|
return {
|
|
50
61
|
apiKey,
|
|
51
62
|
...(url ? { apiUrl: url.value } : {}),
|
|
@@ -58,6 +69,8 @@ export function settingsFromEnv(env = process.env) {
|
|
|
58
69
|
...(user ? { daemonUser: user.value } : {}),
|
|
59
70
|
// create() refuses a name that is not one of ours in words.
|
|
60
71
|
...(gpuSnapshot ? { gpuSnapshot: gpuSnapshot.value } : {}),
|
|
72
|
+
// create() refuses one of another shape in words.
|
|
73
|
+
...(archilEgress ? { archilEgress: archilEgress.value } : {}),
|
|
61
74
|
};
|
|
62
75
|
}
|
|
63
76
|
/** Minutes without outside activity before Daytona stops a run's sandbox: at most 30, so none outlives a run for long. */
|
|
@@ -84,6 +97,18 @@ function optionsOf({ env = process.env, fetch, webSocket, timeouts, onNote }) {
|
|
|
84
97
|
export function conformanceImage({ env = process.env } = {}) {
|
|
85
98
|
return env[DAYTONA_ENV.snapshot] || DAYTONA_DEFAULT_SNAPSHOT;
|
|
86
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* A fresh run folder for the mount cases: an Archil one on the disk the COMPUTER_ARCHIL_* settings name (the shared
|
|
102
|
+
* archilRunFolder; the run's snapshot is then one of box/Dockerfile, and COMPUTER_DAYTONA_USER is 2510:2510), only where
|
|
103
|
+
* COMPUTER_DAYTONA_ARCHIL_EGRESS names the target's relay, since the provider takes an Archil mount only then; none
|
|
104
|
+
* otherwise, and none for a bind, which a remote computer cannot take.
|
|
105
|
+
*/
|
|
106
|
+
export async function mountFor(kind, { env = process.env, archil = {} } = {}) {
|
|
107
|
+
if (kind !== "archil" || !env[DAYTONA_ENV.archilEgress])
|
|
108
|
+
return undefined;
|
|
109
|
+
const settings = archilSettings(env);
|
|
110
|
+
return settings === undefined ? undefined : archilRunFolder({ ...settings, ...archil });
|
|
111
|
+
}
|
|
87
112
|
/** The provider the CLI runs; throws in words when a setting is missing or wrong. */
|
|
88
113
|
export function createProvider(options = {}) {
|
|
89
114
|
return create(optionsOf(options));
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import type { MachineHost } from "../host.js";
|
|
2
2
|
/** The checks, in the order they run. */
|
|
3
|
-
export declare const EXEC_STREAM_CHECKS: readonly ["stdout-
|
|
3
|
+
export declare const EXEC_STREAM_CHECKS: readonly ["stdout-text", "stdin-text", "large", "stdout-live", "stdin-live", "stdout-unread", "stderr", "exit-code", "kill", "no-timeout"];
|
|
4
4
|
export type ExecStreamCheckId = (typeof EXEC_STREAM_CHECKS)[number];
|
|
5
|
+
/** What the capability probe reads, in the order the report gives it. */
|
|
6
|
+
export declare const EXEC_STREAM_FACTS: readonly ["root", "netns", "fuse", "arch", "kernel", "listeners"];
|
|
7
|
+
export type ExecStreamFactId = (typeof EXEC_STREAM_FACTS)[number];
|
|
8
|
+
/** One thing the machine offers: what was read, and what it means for the provider. */
|
|
9
|
+
export interface ExecStreamFact {
|
|
10
|
+
id: ExecStreamFactId;
|
|
11
|
+
value: string;
|
|
12
|
+
means: string;
|
|
13
|
+
}
|
|
5
14
|
export interface ExecStreamCheck {
|
|
6
15
|
id: ExecStreamCheckId;
|
|
7
16
|
status: "pass" | "fail";
|
|
@@ -14,16 +23,21 @@ export interface ExecStreamReport {
|
|
|
14
23
|
machine: string;
|
|
15
24
|
checks: ExecStreamCheck[];
|
|
16
25
|
pass: boolean;
|
|
26
|
+
/** What the capability probe read; empty when it could not run, with why in factsProblem. */
|
|
27
|
+
facts: ExecStreamFact[];
|
|
28
|
+
factsProblem?: string;
|
|
17
29
|
}
|
|
18
30
|
export interface ExecStreamOptions {
|
|
19
31
|
/** How long the no-timeout check's process runs, silent, before it prints and exits; default 75 s. */
|
|
20
32
|
longMs?: number;
|
|
21
33
|
/** How long one step waits: exec's answer, bytes coming back, wait() after the end; default 30 s. */
|
|
22
34
|
stepMs?: number;
|
|
23
|
-
/** The large check's payload, in bytes; default 8 MiB. */
|
|
35
|
+
/** The large check's payload, in bytes of random UTF-8 text; default 8 MiB. */
|
|
24
36
|
largeBytes?: number;
|
|
25
37
|
/** How long the large check may take in all; default 180 s. */
|
|
26
38
|
largeMs?: number;
|
|
39
|
+
/** How long stdout-unread writes to stdin with stdout left unread, before it reads; default 10 s. */
|
|
40
|
+
unreadMs?: number;
|
|
27
41
|
signal?: AbortSignal;
|
|
28
42
|
/** Told of each check as it ends. */
|
|
29
43
|
onCheck?: (check: ExecStreamCheck) => void;
|
|
@@ -39,14 +53,30 @@ export declare const QUICK_LONG_MS = 5000;
|
|
|
39
53
|
*/
|
|
40
54
|
export declare const PID_STATE_SCRIPT = "st=$(sed -n \"s/^State:[[:space:]]*\\([A-Z]\\).*/\\1/p\" \"/proc/$1/status\" 2>/dev/null); case \"$st\" in Z|X) echo gone ;; ?) echo running ;; *) if kill -0 \"$1\" 2>/dev/null; then echo running; else echo gone; fi ;; esac";
|
|
41
55
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
56
|
+
* length bytes of random UTF-8 text: characters of 1, 2, 3 and 4 bytes at random, any code point of each width but NUL
|
|
57
|
+
* and the surrogates (which are no text).
|
|
58
|
+
*/
|
|
59
|
+
export declare function randomText(length: number): Buffer;
|
|
60
|
+
/**
|
|
61
|
+
* Why `got` is not `sent`, in words, or undefined when they are the same text. Both are UTF-8; `way` is where it went
|
|
62
|
+
* ("on stdout"). The first character that differs is named, and the usual ways an exec changes text are named for what
|
|
63
|
+
* they are.
|
|
64
|
+
*/
|
|
65
|
+
export declare function textProblem(sent: Uint8Array, got: Uint8Array, way: string): string | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* The capability probe, one sh script run through exec (as root, as exec runs): a tab-separated line for each thing it
|
|
68
|
+
* reads, each value on one line, and every line of the kernel's TCP tables as a "tcp" line. readFacts reads it. It needs
|
|
69
|
+
* no ss, ip or util-linux beyond unshare, and says "none" where the machine lacks unshare.
|
|
44
70
|
*/
|
|
45
|
-
export declare
|
|
71
|
+
export declare const CAPABILITY_SCRIPT: string;
|
|
72
|
+
/** The TCP listeners in the probe's "tcp" lines: address:port, each once, in the order the kernel lists them. */
|
|
73
|
+
export declare function tcpListeners(lines: readonly string[]): string[];
|
|
74
|
+
/** The probe's output as facts, each with what it means for the provider. */
|
|
75
|
+
export declare function readFacts(output: string): ExecStreamFact[];
|
|
46
76
|
/**
|
|
47
77
|
* The exec pre-check on one machine: each check in EXEC_STREAM_CHECKS runs in turn, and the report passes when every one
|
|
48
|
-
* does. host.exec is the only member called.
|
|
78
|
+
* does; then the capability probe, which passes or fails nothing. host.exec is the only member called.
|
|
49
79
|
*/
|
|
50
80
|
export declare function checkExecStream(host: MachineHost, machine: string, options?: ExecStreamOptions): Promise<ExecStreamReport>;
|
|
51
|
-
/** The report as a person reads it: one line per check, what failed in words, the verdict last. */
|
|
81
|
+
/** The report as a person reads it: one line per check, what failed in words, the machine's facts, the verdict last. */
|
|
52
82
|
export declare function formatExecStream(report: ExecStreamReport): string;
|