@parcha/agentrun-computer 0.1.0-beta.38 → 0.1.0-beta.40

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.
Files changed (97) hide show
  1. package/README.md +126 -83
  2. package/box/Dockerfile +5 -54
  3. package/box/README.md +9 -3
  4. package/box/build-daytona.py +2 -2
  5. package/box/build-e2b.mjs +1 -1
  6. package/box/install.sh +87 -0
  7. package/box/recipe.d.mts +5 -0
  8. package/box/recipe.mjs +12 -10
  9. package/dist/agent37.d.ts +17 -4
  10. package/dist/agent37.js +98 -17
  11. package/dist/box-image.d.ts +14 -0
  12. package/dist/box-image.js +24 -0
  13. package/dist/computerd-linux-amd64 +0 -0
  14. package/dist/computerd-linux-arm64 +0 -0
  15. package/dist/computerd.json +2 -2
  16. package/dist/conformance/agent37.d.ts +9 -4
  17. package/dist/conformance/agent37.js +23 -11
  18. package/dist/conformance/browserbase.js +3 -3
  19. package/dist/conformance/cases/apps.d.ts +1 -1
  20. package/dist/conformance/cases/apps.js +1 -1
  21. package/dist/conformance/cases/isolation.d.ts +18 -3
  22. package/dist/conformance/cases/isolation.js +73 -6
  23. package/dist/conformance/cases/lifetime.js +30 -0
  24. package/dist/conformance/cases/mount.js +4 -2
  25. package/dist/conformance/cases/provider.js +88 -1
  26. package/dist/conformance/cli.js +29 -9
  27. package/dist/conformance/e2b.js +9 -4
  28. package/dist/conformance/exec-stream.d.ts +44 -7
  29. package/dist/conformance/exec-stream.js +347 -88
  30. package/dist/conformance/kernel.js +2 -2
  31. package/dist/conformance/modal.js +1 -1
  32. package/dist/conformance/orgo.js +2 -2
  33. package/dist/conformance/report.js +3 -0
  34. package/dist/conformance/runner.js +127 -9
  35. package/dist/conformance/types.d.ts +21 -0
  36. package/dist/daytona.d.ts +0 -5
  37. package/dist/daytona.js +19 -28
  38. package/dist/descriptor.d.ts +5 -3
  39. package/dist/descriptors/agent37.d.ts +3 -11
  40. package/dist/descriptors/agent37.js +9 -10
  41. package/dist/descriptors/daytona.d.ts +1 -1
  42. package/dist/descriptors/daytona.js +5 -2
  43. package/dist/descriptors/docker.d.ts +13 -1
  44. package/dist/descriptors/docker.js +3 -1
  45. package/dist/descriptors/e2b.d.ts +2 -9
  46. package/dist/descriptors/e2b.js +8 -8
  47. package/dist/descriptors/index.d.ts +21 -19
  48. package/dist/descriptors/index.js +1 -3
  49. package/dist/descriptors/modal.d.ts +2 -6
  50. package/dist/descriptors/modal.js +8 -6
  51. package/dist/descriptors/orgo.js +2 -1
  52. package/dist/docker/egress-main.js +23 -15
  53. package/dist/docker/egress.d.ts +6 -4
  54. package/dist/docker/egress.js +24 -16
  55. package/dist/docker/inspect.d.ts +2 -2
  56. package/dist/docker/inspect.js +5 -5
  57. package/dist/docker.d.ts +6 -5
  58. package/dist/docker.js +12 -11
  59. package/dist/e2b.d.ts +12 -2
  60. package/dist/e2b.js +42 -19
  61. package/dist/host.d.ts +113 -59
  62. package/dist/host.js +5 -0
  63. package/dist/hosted/framed-exec.d.ts +49 -0
  64. package/dist/hosted/framed-exec.js +185 -0
  65. package/dist/hosted/network.d.ts +23 -0
  66. package/dist/hosted/network.js +77 -0
  67. package/dist/hosted/process.d.ts +13 -5
  68. package/dist/hosted/process.js +35 -12
  69. package/dist/hosted/provider.d.ts +16 -9
  70. package/dist/hosted/provider.js +475 -170
  71. package/dist/hosted/rest.d.ts +20 -2
  72. package/dist/hosted/rest.js +24 -10
  73. package/dist/hosted/scripts.d.ts +27 -7
  74. package/dist/hosted/scripts.js +77 -18
  75. package/dist/{agent37-ssh.d.ts → hosted/ssh-exec.d.ts} +19 -9
  76. package/dist/{agent37-ssh.js → hosted/ssh-exec.js} +38 -19
  77. package/dist/hosted/values.d.ts +21 -0
  78. package/dist/hosted/values.js +55 -0
  79. package/dist/index.d.ts +1 -1
  80. package/dist/index.js +1 -1
  81. package/dist/isolation.d.ts +0 -2
  82. package/dist/isolation.js +3 -4
  83. package/dist/modal.d.ts +8 -2
  84. package/dist/modal.js +21 -15
  85. package/dist/mount-archil.d.ts +5 -4
  86. package/dist/mount-archil.js +5 -6
  87. package/dist/orgo.js +6 -4
  88. package/dist/providers.d.ts +4 -1
  89. package/dist/surface/api.d.ts +0 -9
  90. package/dist/surface/core.d.ts +7 -2
  91. package/dist/surface/core.js +12 -4
  92. package/dist/surface/index.d.ts +1 -1
  93. package/dist/surface/index.js +1 -1
  94. package/dist/surface/script.d.ts +4 -0
  95. package/dist/surface/script.js +9 -3
  96. package/package.json +1 -1
  97. package/box/build-agent37.mjs +0 -158
@@ -1,6 +1,6 @@
1
1
  // Browserbase for the conformance CLI: `npm run conformance -w @parcha/agentrun-computer -- --provider browserbase`.
2
- // It makes a real, billed Browserbase session, so it runs only with AGENTRUN_COMPUTER_LIVE_BROWSERBASE=1 and a key the
3
- // lead has OKed, under COMPUTER_BROWSERBASE_API_KEY (and COMPUTER_BROWSERBASE_PROJECT_ID for a direct key). The provider
2
+ // It makes a real, billed Browserbase session, so it runs only with AGENTRUN_COMPUTER_LIVE_BROWSERBASE=1 and a key for
3
+ // an account you can bill, under COMPUTER_BROWSERBASE_API_KEY (and COMPUTER_BROWSERBASE_PROJECT_ID for a direct key). The provider
4
4
  // reads no environment: this module reads its own COMPUTER_BROWSERBASE_* names (never BROWSERBASE_API_KEY, which may
5
5
  // hold another project's key) and passes each to create() as its option. The live switch is checked first, before any
6
6
  // other setting is read. The run makes one session, shared by every case, and releases it.
@@ -39,7 +39,7 @@ export function conformanceImage() {
39
39
  /** The provider the CLI runs; throws in words without the live switch, or when the key is missing. */
40
40
  export async function createProvider({ env = process.env, ...transport } = {}) {
41
41
  if (env[BROWSERBASE_ENV.live] !== "1") {
42
- throw new Error(`the Browserbase conformance module makes a real, billed session: set ${BROWSERBASE_ENV.live}=1, with a key the lead has OKed, to run it`);
42
+ throw new Error(`the Browserbase conformance module makes a real, billed session: set ${BROWSERBASE_ENV.live}=1, with a key for an account you can bill, to run it`);
43
43
  }
44
44
  return create({ ...settingsFromEnv(env), ...transport });
45
45
  }
@@ -6,7 +6,7 @@ import type { Case } from "../types.js";
6
6
  export declare function observeWrong(result: unknown): string | undefined;
7
7
  /**
8
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
9
+ * Xfce, which E2B Desktop's template and the box image (box/Dockerfile) both carry, and xterm, which a bare
10
10
  * desktop has (the Docker suite's, test/fixtures/desktop).
11
11
  */
12
12
  export declare const DESKTOP_APPS: readonly string[];
@@ -107,7 +107,7 @@ export function observeWrong(result) {
107
107
  const foreground = async (t) => (await t.call("apps.list", {})).foreground;
108
108
  /**
109
109
  * The stock apps a Linux desktop may have, by their desktop file ids, any vendor's: the text editor and the terminal of
110
- * Xfce, which E2B Desktop's template and the box image (box/build-agent37.mjs) both carry, and xterm, which a bare
110
+ * Xfce, which E2B Desktop's template and the box image (box/Dockerfile) both carry, and xterm, which a bare
111
111
  * desktop has (the Docker suite's, test/fixtures/desktop).
112
112
  */
113
113
  export const DESKTOP_APPS = ["org.xfce.mousepad", "mousepad", "xfce4-terminal", "org.xfce.terminal", "xterm"];
@@ -1,9 +1,10 @@
1
1
  import type { ComputerClient } from "../../protocol.js";
2
2
  import type { Case, CaseContext } from "../types.js";
3
3
  /**
4
- * The unix sockets a program of the computer's user may connect to: the computer's own, computerd's and the Archil sync
5
- * socket (which only syncs). A network namespace does not cut a path socket, and every program in the namespace reaches
6
- * an abstract name (@...), so any other socket is a door out.
4
+ * The unix sockets a program of the computer's user may connect to: the computer's own, computerd's, the Archil sync
5
+ * socket (which only syncs) and, under network open or a list, the egress proxy's (which reaches the public internet
6
+ * alone, as the spec's network asked). A network namespace does not cut a path socket, and every program in the
7
+ * namespace reaches an abstract name (@...), so any other socket is a door out.
7
8
  */
8
9
  export declare const OWN_SOCKETS: readonly string[];
9
10
  /**
@@ -20,4 +21,18 @@ export declare const OUTSIDE_TARGETS: string[];
20
21
  * socket list or no listener list, or a search it could not finish, fails the check in words. The Archil case mount.archil-isolated-durable runs the same check on an Archil computer.
21
22
  */
22
23
  export declare function assertIsolated(t: CaseContext, client?: ComputerClient): Promise<void>;
24
+ /**
25
+ * What root runs or reads in a computer: the directories of root's PATH (the one init gets, hosted/scripts.ts, and
26
+ * Debian's), computerd, the root helpers an Archil image ships (the helper and the archil client it runs), and, where an
27
+ * image has them, the vendor's agent (E2B's envd) and init's table.
28
+ */
29
+ export declare const ROOT_RUNS: readonly string[];
30
+ /** The check's argv, for the paths given (default ROOT_RUNS). */
31
+ export declare const rootRunsArgv: (paths?: readonly string[]) => string[];
32
+ /**
33
+ * The computer's user can write nothing root runs (ROOT_RUNS), nor any directory above it: a program of its could
34
+ * otherwise change what root runs next. Checked as that user with `test -w`, on the computer `client` reaches (the case's
35
+ * own by default); every path read is recorded, and one it reads none of fails.
36
+ */
37
+ export declare function assertRootRunsClosed(t: CaseContext, client?: ComputerClient): Promise<void>;
23
38
  export declare const isolationCases: Case[];
@@ -1,14 +1,18 @@
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.
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
- import { ARCHIL_SYNC_SOCKET } from "../../mount-archil.js";
6
+ import { EGRESS_PROXY_SOCKET } from "../../hosted/network.js";
7
+ import { LABEL_FILE } from "../../hosted/scripts.js";
8
+ import { ARCHIL_HELPER, ARCHIL_SYNC_SOCKET } from "../../mount-archil.js";
6
9
  /**
7
- * The unix sockets a program of the computer's user may connect to: the computer's own, computerd's and the Archil sync
8
- * socket (which only syncs). A network namespace does not cut a path socket, and every program in the namespace reaches
9
- * an abstract name (@...), so any other socket is a door out.
10
+ * The unix sockets a program of the computer's user may connect to: the computer's own, computerd's, the Archil sync
11
+ * socket (which only syncs) and, under network open or a list, the egress proxy's (which reaches the public internet
12
+ * alone, as the spec's network asked). A network namespace does not cut a path socket, and every program in the
13
+ * namespace reaches an abstract name (@...), so any other socket is a door out.
10
14
  */
11
- export const OWN_SOCKETS = [`${SOCKET_DIR}/computerd.sock`, ARCHIL_SYNC_SOCKET];
15
+ export const OWN_SOCKETS = [`${SOCKET_DIR}/computerd.sock`, ARCHIL_SYNC_SOCKET, EGRESS_PROXY_SOCKET];
12
16
  /**
13
17
  * The outside the case also probes: a public IP literal on 443, and a DNS name on 443, which a program could reach only
14
18
  * through a resolver and a route its own network does not have.
@@ -115,6 +119,46 @@ async function displaySocket(client) {
115
119
  const number = /^:(\d{1,4})(?:\.\d{1,4})?$/.exec(hello.value.display ?? "")?.[1];
116
120
  return number === undefined ? undefined : `/tmp/.X11-unix/X${number}`;
117
121
  }
122
+ /**
123
+ * What root runs or reads in a computer: the directories of root's PATH (the one init gets, hosted/scripts.ts, and
124
+ * Debian's), computerd, the root helpers an Archil image ships (the helper and the archil client it runs), and, where an
125
+ * image has them, the vendor's agent (E2B's envd) and init's table.
126
+ */
127
+ export const ROOT_RUNS = ["/usr/local/sbin", "/usr/local/bin", "/usr/sbin", "/usr/bin", "/sbin", "/bin", DAEMON_IN_COMPUTER, ARCHIL_HELPER, "/usr/bin/archil", "/usr/bin/envd", "/etc/inittab"];
128
+ /** Each path given that is there, then every directory above it, each as `writable <path>` or `closed <path>`: `test -w`
129
+ * as the computer's user, and nothing written. A path on a read-only mount is closed: BusyBox's `test -w` reads the
130
+ * mode bits alone, so the mount's options are read from /proc/self/mountinfo (the longest mount point above the path,
131
+ * its own options and its superblock's). */
132
+ const ROOT_RUNS_SCRIPT = [
133
+ "# agentrun-conformance: root-runs",
134
+ "ro() { r=$(readlink -f \"$1\" 2>/dev/null); awk -v p=\"${r:-$1}\" '{ m = $5; gsub(/\\\\040/, \" \", m); if ((p == m || m == \"/\" || index(p, m \"/\") == 1) && length(m) >= n) { n = length(m); o = $6; for (i = 7; i < NF; i++) if ($i == \"-\") { o = o \",\" $(i + 3); break } } } END { exit !(o ~ /(^|,)ro(,|$)/) }' /proc/self/mountinfo 2>/dev/null; }",
135
+ 'for p in "$@"; do',
136
+ '\t[ -e "$p" ] || [ -L "$p" ] || continue',
137
+ "\tx=$p",
138
+ "\twhile :; do",
139
+ '\t\tif [ -w "$x" ] && ! ro "$x"; then echo "writable $x"; else echo "closed $x"; fi',
140
+ '\t\t[ "$x" = / ] && break',
141
+ "\t\tx=${x%/*}; x=${x:-/}",
142
+ "\tdone",
143
+ "done",
144
+ ].join("\n");
145
+ /** The check's argv, for the paths given (default ROOT_RUNS). */
146
+ export const rootRunsArgv = (paths = ROOT_RUNS) => ["sh", "-c", ROOT_RUNS_SCRIPT, "sh", ...paths];
147
+ /**
148
+ * The computer's user can write nothing root runs (ROOT_RUNS), nor any directory above it: a program of its could
149
+ * otherwise change what root runs next. Checked as that user with `test -w`, on the computer `client` reaches (the case's
150
+ * own by default); every path read is recorded, and one it reads none of fails.
151
+ */
152
+ export async function assertRootRunsClosed(t, client) {
153
+ const ran = await t.exec(rootRunsArgv(), { timeoutMs: t.patience }, client);
154
+ t.equal(ran.exitCode, 0, `the check's exit code (stderr: ${ran.err.trim()})`);
155
+ const said = (word) => [...new Set(ran.out.split("\n").flatMap((line) => (line.startsWith(`${word} `) ? [line.slice(word.length + 1)] : [])))];
156
+ const closed = said("closed");
157
+ const writable = said("writable");
158
+ t.observe(`what root runs, and the directories above it, as the computer's user: ${closed.length} closed (${closed.sort().join(", ")})${writable.length > 0 ? `; writable: ${writable.sort().join(", ")}` : ""}`);
159
+ t.assert(closed.length + writable.length > 0, `the check read no path: ${ran.out.slice(0, 200)}`);
160
+ t.assert(writable.length === 0, `the computer's user can write what root runs: ${writable.join(", ")}`);
161
+ }
118
162
  export const isolationCases = [
119
163
  {
120
164
  id: "isolation.vendor-agent",
@@ -125,4 +169,27 @@ export const isolationCases = [
125
169
  await assertIsolated(t);
126
170
  },
127
171
  },
172
+ {
173
+ id: "isolation.root-runs",
174
+ level: "core",
175
+ group: "isolation",
176
+ needs: ["exec"],
177
+ async run(t) {
178
+ await assertRootRunsClosed(t);
179
+ },
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
+ },
128
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
  ];
@@ -14,7 +14,7 @@ import { randomBytes } from "node:crypto";
14
14
  import { EPOCH_LABEL, RUN_LABEL, runLabels as claimLabels } from "../../labels.js";
15
15
  import { MOUNT_KINDS, readBackOf, WORKSPACE } from "../../mount.js";
16
16
  import { MAX_OUTPUT_BYTES } from "../../protocol.js";
17
- import { assertIsolated } from "./isolation.js";
17
+ import { assertIsolated, assertRootRunsClosed } from "./isolation.js";
18
18
  import { b64, CASE_LABEL, decode } from "./util.js";
19
19
  /** The claim epoch the run-folder cases make their computers under. */
20
20
  const EPOCH = 1;
@@ -169,7 +169,7 @@ const archilToken = mount("archil-token", async (t) => {
169
169
  }, { needs: ["mount:archil", "exec"], timeoutMs: 600_000 });
170
170
  /**
171
171
  * "isolated, and durable through the root side", on one Archil computer: a tool sees loopback alone and reaches neither a
172
- * vendor's agent nor any address; and a tool's write in /workspace, by a program (exec.run) and by files.write, is read
172
+ * vendor's agent nor any address, and can write nothing root runs; and a tool's write in /workspace, by a program (exec.run) and by files.write, is read
173
173
  * through the disk's file API right after the call returns, with no checkin. So the per-call sync goes out from the
174
174
  * archil client and serve, which run as root outside the tools' namespace.
175
175
  */
@@ -180,6 +180,8 @@ const archilIsolatedDurable = mount("archil-isolated-durable", async (t) => {
180
180
  // isolation.vendor-agent's own check, on this Archil computer: lo alone, refused at the vendor's agent and outside,
181
181
  // and no unix socket a tool connects to but the computer's own (computerd's, the sync socket).
182
182
  await assertIsolated(t, connected.client);
183
+ // isolation.root-runs' check too, where the Archil helper and client are there to check.
184
+ await assertRootRunsClosed(t, connected.client);
183
185
  const nonce = randomBytes(6).toString("hex");
184
186
  const ran = await t.exec(["sh", "-c", `printf '%s\\n' ${nonce} > exec-${nonce}.txt`], { cwd: WORKSPACE }, connected.client);
185
187
  t.equal(ran.exitCode, 0, `a program's write at ${WORKSPACE}: its exit code (${ran.err.trim()})`);
@@ -2,14 +2,34 @@
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. prepareImage called twice answers one image and makes it once.
6
7
  import { randomBytes } from "node:crypto";
8
+ import { BACKSTOP_MARGIN_MS } from "../../host.js";
7
9
  import { releaseOlder, sweep } from "../../janitor.js";
8
10
  import { EPOCH_LABEL, OWNER_LABEL, RUN_LABEL, runLabels } from "../../labels.js";
9
11
  import { computerNameFor, runLifetimeMs } from "../../provider.js";
10
12
  import { b64, CASE_LABEL, decode } from "./util.js";
11
13
  /** Labels for one case's computers: the run's, and the case's own. */
12
14
  const own = (t, name) => ({ ...t.runLabels, [CASE_LABEL]: name });
15
+ /** Gets url with curl as the computer's user, through the proxy its programs are told of (no host bypasses it): curl's exit,
16
+ * the HTTP code and the CONNECT code. Undefined, observed, on a computer that is not Linux with exec, or where the image
17
+ * has no curl or no proxy is set. */
18
+ const CURL = `command -v curl >/dev/null 2>&1 || { echo nocurl; exit 0; }; [ -n "\${HTTPS_PROXY:-\${https_proxy:-}}" ] || { echo noproxy; exit 0; }; c=$(curl -sS -o /dev/null --noproxy '' --max-time 30 -w '%{http_code} %{http_connect}' "$1" 2>/dev/null); echo "$? $c"`;
19
+ async function curled(t, { client, hello }, url) {
20
+ if (hello.os !== "linux" || !hello.groups.includes("exec")) {
21
+ t.observe(`the computer runs ${hello.os}${hello.groups.includes("exec") ? "" : " with no exec"}, so the egress proxy's answers were not read with curl`);
22
+ return undefined;
23
+ }
24
+ const ran = t.ok(await client.call("exec.run", { argv: ["sh", "-c", CURL, "sh", url], timeoutMs: 60_000 }), `curl ${url}`);
25
+ const out = decode(ran.stdout).trim();
26
+ if (out === "nocurl" || out === "noproxy") {
27
+ t.observe(out === "nocurl" ? "the image has no curl, so the egress proxy's answers were not read" : "no proxy is set for the computer's programs: its open network is the vendor's own, with no egress proxy to read");
28
+ return undefined;
29
+ }
30
+ const [exit, code, connect] = out.split(" ");
31
+ return { exit: Number(exit), code: code ?? "", connect: connect ?? "" };
32
+ }
13
33
  const names = async (t, labels) => t
14
34
  .ok(await t.provider.list(labels), `list ${JSON.stringify(labels)}`)
15
35
  .map((info) => info.ref.name)
@@ -33,6 +53,8 @@ async function refusedCreate(t, spec, what) {
33
53
  /** The deadline case's lifetime, and how much of it must be left once create returns: to connect and start a process. */
34
54
  const DEADLINE_LIFETIME_MS = 45_000;
35
55
  const DEADLINE_LEFT_MS = 15_000;
56
+ /** How far a backstop host's vendor timer may read from the request's backstopAt: a timer kept in whole minutes rounds. */
57
+ const BACKSTOP_SKEW_MS = 60_000;
36
58
  const seconds = (ms) => Math.round(ms / 100) / 10;
37
59
  /**
38
60
  * A computer for the deadline case, the lifetime it was made with, and when create returned, on the run's clock. A
@@ -146,6 +168,11 @@ export const providerCases = [
146
168
  t.ok(await t.provider.release(ref, "delete"), "a second delete of the same computer");
147
169
  t.deepEqual(await names(t, labels), [], "listed after delete");
148
170
  t.refused(await t.provider.connect(ref), "connect to a deleted computer", ["gone", "not_found"]);
171
+ // A vendor that wakes a machine on the next call (a session resumed on request, a cold start) brings a deleted
172
+ // computer back: after the refused connect it stays gone, to attach, a second connect, and list.
173
+ t.refused(await t.provider.attach({ id: ref.id }), "attach to the deleted computer, after a connect to it", ["not_found"]);
174
+ t.refused(await t.provider.connect(ref), "a second connect to the deleted computer", ["gone", "not_found"]);
175
+ t.deepEqual(await names(t, labels), [], "listed after the calls to the deleted computer: nothing came back");
149
176
  }),
150
177
  provider("create-retried", async (t) => {
151
178
  // A retry of one request, at once and after it is up, answers the computer the first made: never a second.
@@ -217,6 +244,29 @@ export const providerCases = [
217
244
  t.assert(deadline >= before + lifetimeMs - 1000 && deadline <= after + lifetimeMs + 1000, `its deadline, ${String(info.deadline)}, is lifetimeMs after create`);
218
245
  t.deepEqual(await names(t, { ...labels, role: "other" }), [], "list by a label no computer has");
219
246
  }),
247
+ // prepareImage twice in one run (spec/computer/provider.md, "prepareImage"): both answer the same image, and the second
248
+ // finds the one the first made by its name, so it is told no onWait. A server calls it before its first create, so one
249
+ // that builds every time costs every server minutes. A provider with none passes, observed. Core: the first call costs
250
+ // at most a build per account and recipe, which the account's first create pays anyway.
251
+ provider("prepare-image", async (t) => {
252
+ // A provider on the machine-host adapter: its host's descriptor, the whole one in-tree hosts hand it.
253
+ const descriptor = t.provider.host?.descriptor;
254
+ const prepare = t.provider.prepareImage?.bind(t.provider);
255
+ if (prepare === undefined) {
256
+ t.assert(descriptor?.prepareImage !== true, `${descriptor?.label}'s descriptor declares prepareImage, but its provider has no prepareImage(): give the provider class one`);
257
+ return t.observe("the provider has no prepareImage(): its computers start from an image a spec names");
258
+ }
259
+ const call = async (which) => {
260
+ const told = [];
261
+ const image = t.ok(await prepare({ signal: t.signal, onWait: (making, tag) => told.push(`${making} ${tag}`) }), `the ${which} prepareImage`);
262
+ return { image, told: told.length === 0 ? "" : `onWait(${told.join("; ")})` };
263
+ };
264
+ const first = await call("first");
265
+ 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}`);
266
+ const second = await call("second");
267
+ t.equal(second.image, first.image, "the second prepareImage's image");
268
+ 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`);
269
+ }, { timeoutMs: 20 * 60_000 }),
220
270
  // Stop is declared or refused: a provider that declares it lists the computer stopped; one that does not refuses it
221
271
  // in words and leaves the computer running, never stopped or deleted behind the caller's back.
222
272
  provider("stop", async (t) => {
@@ -343,11 +393,34 @@ export const providerCases = [
343
393
  t.deepEqual(t.ok(await t.provider.list(labels), "list").map((info) => info.network), ["open"], "the network list reads back");
344
394
  const connected = await t.connect(ref);
345
395
  t.deepEqual(t.ok(await connected.client.call("ping", {}), "ping"), {}, "ping in an open computer");
396
+ // Where open goes through an egress proxy (the programs are told of one), it reaches the public internet alone:
397
+ // a name, with no resolver of the programs' own, and never metadata, a private address or the vendor's agent.
398
+ const web = await curled(t, connected, "https://example.com/");
399
+ if (web === undefined)
400
+ return;
401
+ t.equal(`${web.exit} ${web.code}`, "0 200", "curl by name to https://example.com/ through the egress proxy");
402
+ const refusedTargets = [
403
+ ["http://169.254.169.254/latest/meta-data/", "metadata (169.254.169.254), plain HTTP"],
404
+ ["https://169.254.169.254/", "metadata (169.254.169.254), CONNECT"],
405
+ ["https://10.0.0.1/", "a private address"],
406
+ ...(t.provider.capabilities().vendorAgentPorts ?? []).map((port) => [`http://127.0.0.1:${port}/`, `the vendor's agent's port ${port} on the loopback`]),
407
+ ];
408
+ for (const [url, what] of refusedTargets) {
409
+ const refused = await curled(t, connected, url);
410
+ t.assert(refused !== undefined && (refused.code === "403" || refused.connect === "403"), `${what}: the egress proxy refuses ${url} with 403, not ${JSON.stringify(refused)}`);
411
+ }
346
412
  }, { level: "full", needs: ["network:open"] }),
347
413
  provider("network-allow", async (t) => {
348
414
  const policy = { allow: ["example.com"] };
349
415
  const ref = await t.create({ labels: own(t, "allow"), network: policy });
350
416
  t.deepEqual(t.ok(await t.provider.network(ref), "network read-back"), policy, "the allowlist read back");
417
+ const connected = await t.connect(ref);
418
+ const listed = await curled(t, connected, "https://example.com/");
419
+ if (listed === undefined)
420
+ return;
421
+ t.equal(`${listed.exit} ${listed.code}`, "0 200", "curl by name to https://example.com/, on the list, through the egress proxy");
422
+ const off = await curled(t, connected, "https://example.org/");
423
+ t.equal(off?.connect, "403", "https://example.org/, off the list: the egress proxy refuses its CONNECT with 403");
351
424
  }, { level: "full", needs: ["network:allow"] }),
352
425
  provider("deadline", async (t) => {
353
426
  const labels = own(t, "deadline");
@@ -414,4 +487,18 @@ export const providerCases = [
414
487
  t.ok(await t.provider.release(ref, "delete"), `release ${ref.name}`);
415
488
  t.deepEqual(await names(t, labels), [], "the case's computers after it");
416
489
  }, { level: "full", timeoutMs: 300_000 }),
490
+ // A host's backstop claim (facts.backstop, src/host.ts), read back from its vendor on the run's shared computer: get's
491
+ // endsAt is the request's backstopAt, which create made from the clock reading its deadline label was made from. A
492
+ // provider not on the machine-host adapter, or a host that claims none, has nothing to read back.
493
+ provider("backstop", async (t) => {
494
+ const host = t.provider.host;
495
+ if (host?.facts?.backstop !== true)
496
+ return t.observe(host === undefined ? "not on the machine-host adapter: no backstop to read back" : "its host claims no backstop (facts.backstop): nothing to read back");
497
+ const listed = t.ok(await t.provider.list(t.runLabels), "list");
498
+ const deadline = t.present(listed.find((info) => info.ref.name === t.ref.name)?.deadline, `${t.ref.name}'s deadline, listed`);
499
+ const backstopAt = deadline.getTime() - runLifetimeMs(t.spec()) + t.provider.capabilities().maxLifetimeMs + BACKSTOP_MARGIN_MS;
500
+ const endsAt = (await host.get(t.ref.id, { timeoutMs: t.patience, signal: t.signal }))?.endsAt;
501
+ const reads = endsAt instanceof Date ? endsAt.toISOString() : "none";
502
+ t.assert(endsAt instanceof Date && Math.abs(endsAt.getTime() - backstopAt) <= BACKSTOP_SKEW_MS, `${host.descriptor.label} claims backstop (facts.backstop), but its vendor timer reads ${reads}, not ${new Date(backstopAt).toISOString()}, the request's backstopAt (within ${BACKSTOP_SKEW_MS / 1000} s): set it from req.backstopAt at create, and read it back as Machine.endsAt`);
503
+ }, { computer: "shared" }),
417
504
  ];
@@ -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. Bytes 0-255 both ways, 8 MiB by sha256, output and stdin while the process runs, stderr apart,
39
- the exit code, kill, and a silent process of ${DEFAULT_LONG_MS / 1000} s (--quick: ${QUICK_LONG_MS / 1000} s) that is not cut off
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
  };
@@ -206,9 +223,10 @@ export function plantSecrets(names) {
206
223
  }
207
224
  /**
208
225
  * The provider a conformance module makes, its drifted twin and its run folders (mountFor) when it offers them, and what
209
- * it says of its run: conformanceImage(), the image when --image names none, and conformanceNotes, strings for the report.
226
+ * it says of its run: conformanceImage(), the image when --image names none (asked only then: a module's may make or
227
+ * register its image, so it is given the run's signal), and conformanceNotes, strings for the report.
210
228
  */
211
- async function load(label, module, options, declared) {
229
+ async function load(label, module, options, { imageNamed, signal }, declared) {
212
230
  const { createProvider, createDriftedProvider, conformanceImage, mountFor } = module;
213
231
  if (typeof createProvider !== "function")
214
232
  throw new Usage(`${label} does not export createProvider() or create()`);
@@ -235,8 +253,8 @@ async function load(label, module, options, declared) {
235
253
  }
236
254
  if (typeof mountFor === "function")
237
255
  target.mountFor = (kind) => mountFor(kind, options);
238
- if (conformanceImage !== undefined) {
239
- const image = typeof conformanceImage === "function" ? await conformanceImage(options) : undefined;
256
+ if (conformanceImage !== undefined && !imageNamed) {
257
+ const image = typeof conformanceImage === "function" ? await conformanceImage(options, signal ? { signal } : {}) : undefined;
240
258
  if (typeof image !== "string" || image === "")
241
259
  throw new Usage(`${label}: conformanceImage() did not return an image`);
242
260
  target.image = image;
@@ -306,7 +324,7 @@ export async function main(argv, io = {}) {
306
324
  let target;
307
325
  try {
308
326
  const { label, module, declared } = await conformanceModule(args.provider, cwd);
309
- target = await load(label, module, options, declared);
327
+ target = await load(label, module, options, { imageNamed: args.image !== undefined, ...(signal ? { signal } : {}) }, declared);
310
328
  }
311
329
  catch (error) {
312
330
  await write(stderr, `${error.message}\n`);
@@ -326,6 +344,8 @@ export async function main(argv, io = {}) {
326
344
  ...(args.kind ? { kind: args.kind } : {}),
327
345
  ...(args.fixture ? { fixture: resolve(cwd, args.fixture) } : {}),
328
346
  ...(args.gpu ? { gpu: args.gpu } : {}),
347
+ ...(args.long ? { long: true } : {}),
348
+ ...(args.concurrency ? { concurrency: args.concurrency } : {}),
329
349
  ...(signal ? { signal } : {}),
330
350
  ...(target.drifted ? { drifted: target.drifted } : {}),
331
351
  ...(target.declared ? { declared: target.declared } : {}),
@@ -1,5 +1,5 @@
1
1
  // E2B for the conformance CLI: `npm run conformance -w @parcha/agentrun-computer -- --provider e2b [--image <template>]`.
2
- // It makes real sandboxes, so it runs only with AGENTRUN_COMPUTER_LIVE_E2B=1 and a key the lead has OKed, under
2
+ // It makes real sandboxes, so it runs only with AGENTRUN_COMPUTER_LIVE_E2B=1 and a key for an account you can bill, under
3
3
  // COMPUTER_E2B_API_KEY. The provider reads no environment: this module reads its own COMPUTER_E2B_* names (never
4
4
  // E2B_API_KEY, which may hold another team's key) and passes each to create() as its option; the provider gives the SDK
5
5
  // the key, domain and API URL explicitly, and refuses an ambient E2B_SANDBOX_URL (see create in ../e2b.ts). The live
@@ -15,7 +15,6 @@
15
15
  // disk's object API (the shared archilRunFolder, ./archil.ts: the host's disk SDK with COMPUTER_ARCHIL_API_KEY and
16
16
  // COMPUTER_ARCHIL_S3_URL, or an object API given as archil.objects); with no disk named it makes none, and the cases
17
17
  // are skipped. An Archil computer needs a provider whose daemon user is the tool user: COMPUTER_E2B_USER=2510:2510.
18
- import { E2B_BASE_TEMPLATE, E2B_DESKTOP_TEMPLATE } from "../descriptors/e2b.js";
19
18
  import { create } from "../e2b.js";
20
19
  import { archilRunFolder, archilSettings } from "./archil.js";
21
20
  import { buildDriftDaemon, DRIFT_VERSION } from "./drift-daemon.js";
@@ -77,12 +76,18 @@ export const conformanceNotes = [
77
76
  ];
78
77
  function live(env) {
79
78
  if (env[E2B_ENV.live] !== "1") {
80
- throw new Error(`the E2B conformance module makes real sandboxes: set ${E2B_ENV.live}=1, with a key the lead has OKed, to run it`);
79
+ throw new Error(`the E2B conformance module makes real sandboxes: set ${E2B_ENV.live}=1, with a key for an account you can bill, to run it`);
81
80
  }
82
81
  }
82
+ /**
83
+ * The conformance run's own default templates, E2B's stock ones: E2B Desktop's, and its plain one for kind linux. A server
84
+ * starts from the box template (the provider's prepareImage); a run on it names it with --image.
85
+ */
86
+ const DESKTOP_TEMPLATE = "desktop";
87
+ const BASE_TEMPLATE = "base";
83
88
  /** The template every computer of the run starts from: COMPUTER_E2B_TEMPLATE, or E2B Desktop's (the plain one for kind linux). */
84
89
  export function conformanceImage({ env = process.env } = {}) {
85
- return env[E2B_ENV.template] || (env[E2B_ENV.kind] === "linux" ? E2B_BASE_TEMPLATE : E2B_DESKTOP_TEMPLATE);
90
+ return env[E2B_ENV.template] || (env[E2B_ENV.kind] === "linux" ? BASE_TEMPLATE : DESKTOP_TEMPLATE);
86
91
  }
87
92
  /** The provider the CLI runs; throws in words without the live switch, or when a setting is missing or wrong. */
88
93
  export async function createProvider({ env = process.env, Sandbox, daemonPath, timeouts, onNote } = {}) {
@@ -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-bytes", "stdin-bytes", "large", "stdout-live", "stdin-live", "stderr", "exit-code", "kill", "no-timeout"];
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;
@@ -32,14 +46,37 @@ export declare const DEFAULT_LONG_MS = 75000;
32
46
  /** --quick's no-timeout check: long enough to cross a second, short enough for CI. */
33
47
  export declare const QUICK_LONG_MS = 5000;
34
48
  /**
35
- * Why `got` is not `sent`, in words, or undefined when they are the same bytes. `way` is where they went ("on stdout");
36
- * the first byte that differs is named, and the usual ways an exec mangles bytes are named for what they are.
49
+ * kill's probe, `sh -c PID_STATE_SCRIPT sh <pid>`: "running" or "gone". A killed process its parent has not reaped yet
50
+ * is a zombie, which kill -0 still finds; it has ended, so its /proc state (Z, or X) reads gone, and any other state
51
+ * running. Its state is read first, in one read, so a reap during the probe never reads as running; where there is no
52
+ * state to read (no /proc, a status hidden, or the process already gone), kill -0 answers.
53
+ */
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";
55
+ /**
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.
37
70
  */
38
- export declare function bytesProblem(sent: Uint8Array, got: Uint8Array, way: string): string | undefined;
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[];
39
76
  /**
40
77
  * The exec pre-check on one machine: each check in EXEC_STREAM_CHECKS runs in turn, and the report passes when every one
41
- * 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.
42
79
  */
43
80
  export declare function checkExecStream(host: MachineHost, machine: string, options?: ExecStreamOptions): Promise<ExecStreamReport>;
44
- /** 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. */
45
82
  export declare function formatExecStream(report: ExecStreamReport): string;