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

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 (85) hide show
  1. package/README.md +101 -76
  2. package/box/README.md +2 -1
  3. package/box/recipe.d.mts +5 -0
  4. package/dist/agent37.d.ts +17 -4
  5. package/dist/agent37.js +96 -16
  6. package/dist/box-image.d.ts +14 -0
  7. package/dist/box-image.js +24 -0
  8. package/dist/computerd-linux-amd64 +0 -0
  9. package/dist/computerd-linux-arm64 +0 -0
  10. package/dist/computerd.json +2 -2
  11. package/dist/conformance/agent37.d.ts +9 -4
  12. package/dist/conformance/agent37.js +23 -11
  13. package/dist/conformance/browserbase.js +3 -3
  14. package/dist/conformance/cases/apps.d.ts +1 -1
  15. package/dist/conformance/cases/apps.js +1 -1
  16. package/dist/conformance/cases/isolation.d.ts +18 -3
  17. package/dist/conformance/cases/isolation.js +57 -6
  18. package/dist/conformance/cases/mount.js +4 -2
  19. package/dist/conformance/cases/provider.js +41 -0
  20. package/dist/conformance/cli.js +6 -5
  21. package/dist/conformance/e2b.js +9 -4
  22. package/dist/conformance/exec-stream.d.ts +7 -0
  23. package/dist/conformance/exec-stream.js +8 -1
  24. package/dist/conformance/kernel.js +2 -2
  25. package/dist/conformance/modal.js +1 -1
  26. package/dist/conformance/orgo.js +2 -2
  27. package/dist/daytona.d.ts +0 -5
  28. package/dist/daytona.js +16 -27
  29. package/dist/descriptor.d.ts +5 -3
  30. package/dist/descriptors/agent37.d.ts +3 -11
  31. package/dist/descriptors/agent37.js +9 -10
  32. package/dist/descriptors/daytona.d.ts +1 -1
  33. package/dist/descriptors/daytona.js +5 -2
  34. package/dist/descriptors/docker.d.ts +13 -1
  35. package/dist/descriptors/docker.js +3 -1
  36. package/dist/descriptors/e2b.d.ts +2 -9
  37. package/dist/descriptors/e2b.js +8 -8
  38. package/dist/descriptors/index.d.ts +21 -19
  39. package/dist/descriptors/index.js +1 -3
  40. package/dist/descriptors/modal.d.ts +2 -6
  41. package/dist/descriptors/modal.js +8 -6
  42. package/dist/descriptors/orgo.js +2 -1
  43. package/dist/docker/egress-main.js +23 -15
  44. package/dist/docker/egress.d.ts +6 -4
  45. package/dist/docker/egress.js +24 -16
  46. package/dist/docker/inspect.d.ts +2 -2
  47. package/dist/docker/inspect.js +5 -5
  48. package/dist/docker.d.ts +6 -5
  49. package/dist/docker.js +12 -11
  50. package/dist/e2b.d.ts +12 -2
  51. package/dist/e2b.js +42 -19
  52. package/dist/host.d.ts +54 -41
  53. package/dist/hosted/network.d.ts +23 -0
  54. package/dist/hosted/network.js +77 -0
  55. package/dist/hosted/process.d.ts +2 -0
  56. package/dist/hosted/process.js +5 -0
  57. package/dist/hosted/provider.d.ts +6 -4
  58. package/dist/hosted/provider.js +244 -136
  59. package/dist/hosted/rest.d.ts +10 -2
  60. package/dist/hosted/rest.js +9 -4
  61. package/dist/hosted/scripts.d.ts +19 -7
  62. package/dist/hosted/scripts.js +55 -18
  63. package/dist/{agent37-ssh.d.ts → hosted/ssh-exec.d.ts} +19 -9
  64. package/dist/{agent37-ssh.js → hosted/ssh-exec.js} +38 -19
  65. package/dist/hosted/values.d.ts +21 -0
  66. package/dist/hosted/values.js +55 -0
  67. package/dist/index.d.ts +1 -1
  68. package/dist/index.js +1 -1
  69. package/dist/isolation.d.ts +0 -2
  70. package/dist/isolation.js +3 -4
  71. package/dist/modal.d.ts +8 -2
  72. package/dist/modal.js +21 -15
  73. package/dist/mount-archil.d.ts +5 -4
  74. package/dist/mount-archil.js +5 -6
  75. package/dist/orgo.js +6 -4
  76. package/dist/providers.d.ts +4 -1
  77. package/dist/surface/api.d.ts +0 -9
  78. package/dist/surface/core.d.ts +7 -2
  79. package/dist/surface/core.js +12 -4
  80. package/dist/surface/index.d.ts +1 -1
  81. package/dist/surface/index.js +1 -1
  82. package/dist/surface/script.d.ts +4 -0
  83. package/dist/surface/script.js +9 -3
  84. package/package.json +1 -1
  85. package/box/build-agent37.mjs +0 -158
@@ -1,8 +1,7 @@
1
- // Modal's descriptor: a sandbox in a Modal app, the run's folder on an Archil disk, with GPUs when asked.
1
+ // Modal's descriptor: a sandbox in a Modal app, the run's folder on an Archil disk, with GPUs when asked. It starts from
2
+ // our box image, the public registry tag its prepareImage() answers (box-image.ts), which Modal pulls at the first create.
2
3
  import { defineProvider } from "../descriptor.js";
3
4
  import { SANDBOX } from "./shared.js";
4
- /** The image a Modal computer starts from when its setting names none. */
5
- export const MODAL_DEFAULT_IMAGE = "debian:bookworm-slim";
6
5
  /**
7
6
  * The GPU types Modal takes, by its own names (guide/gpu, 11-10): "A100" is the 40 GB one, "A100-40GB" its explicit
8
7
  * name. Its "H100!" and "B200+" variants (no upgrade to an H200; a B200 or B300) are not offered: what a computer gets
@@ -39,10 +38,13 @@ export const MODAL = defineProvider({
39
38
  settings: [{ name: "modalApp", option: "app", default: "agentrun" }],
40
39
  metered: true,
41
40
  mounts: ["archil"],
42
- // None: its programs run in a network of their own (isolation.ts OWN_NETWORK_ONLY).
43
- network: ["none"],
41
+ // None: its programs run in a network of their own, their loopback alone (isolation.ts), and the sandbox is made with
42
+ // its network blocked. Open and a list: the sandbox's network is not blocked, and its programs' one way out is init's
43
+ // egress proxy, which reaches the public internet alone, and with a list its hosts alone (hosted/network.ts).
44
+ network: ["none", "open", "allow"],
44
45
  // A linux computer, with GPUs when asked.
45
46
  capabilities: [{ ...SANDBOX, gpu: MODAL_GPU }],
46
- defaultImage: { sandbox: MODAL_DEFAULT_IMAGE },
47
+ // No default image: every computer starts from the box image its prepareImage() answers.
48
+ prepareImage: true,
47
49
  load: () => import("../modal.js"),
48
50
  });
@@ -39,7 +39,8 @@ export const ORGO = defineProvider({
39
39
  metered: true,
40
40
  // None yet: an Archil mount needs an Orgo template that bakes the helper.
41
41
  mounts: [],
42
- // The Linux desktop's: none (computerd holds its programs to loopback).
42
+ // The Linux desktop's: none (computerd holds its programs to loopback). Not open or a list: Orgo's own adapter starts
43
+ // no egress proxy, the one way out of that loopback the shared hosted adapter has (hosted/network.ts).
43
44
  network: ["none"],
44
45
  capabilities: ORGO_CONFIGURATIONS,
45
46
  parked: ORGO_PARKED,
@@ -1,10 +1,11 @@
1
1
  // The entry a Docker computer's egress proxy container runs (egress.ts makes the container):
2
2
  //
3
- // node egress-main.js --socket <path> --deadline <ISO time> --allow <entries,...> [--local <addresses,...>] [--hint <words>]
3
+ // node egress-main.js --socket <path> --deadline <ISO time> (--allow <entries,...> | --open public) [--local <addresses,...>] [--hint <words>]
4
4
  //
5
- // It refuses to start, exit 2 and why on stdout, with no list, an empty one or a bad entry (a proxy with none would reach
6
- // every public host), with no socket, or with no deadline it can read. Started, it logs "egress ready allow=<list>" once
7
- // its socket listens, then one line per decision. It ends, exit 0 and its socket removed, on SIGTERM or SIGINT and at
5
+ // `--open public` is every public host (a computer whose network is open); `--allow` a list. It refuses to start, exit 2
6
+ // and why on stdout, with neither or both, an empty list or a bad entry (no list never means open: only `--open public`
7
+ // does), with no socket, or with no deadline it can read. Started, it logs "egress ready allow=<list>" (or "egress ready
8
+ // open") once its socket listens, then one line per decision. It ends, exit 0 and its socket removed, on SIGTERM or SIGINT and at
8
9
  // the deadline, the computer's own: an orphaned proxy forwards nothing past its computer's end. `--local` is the Docker
9
10
  // host's own addresses, refused as this host's. It imports only node: modules and the proxy: it runs in a bare Node image.
10
11
  import { EGRESS_READY, parseAllow, startEgressProxy } from "./egress-proxy.js";
@@ -13,7 +14,7 @@ const MAX_TUNNELS = 64;
13
14
  const MAX_CONNECTIONS = 20_000;
14
15
  /** The longest a Node timer holds; a later deadline is waited for in steps of it. */
15
16
  const MAX_TIMER_MS = 2_147_483_647;
16
- const FLAGS = new Set(["--socket", "--deadline", "--allow", "--local", "--hint"]);
17
+ const FLAGS = new Set(["--socket", "--deadline", "--allow", "--open", "--local", "--hint"]);
17
18
  const say = (line) => process.stdout.write(`${line}\n`);
18
19
  const refuse = (why) => {
19
20
  say(`egress: ${why}, so the proxy does not start`);
@@ -27,15 +28,22 @@ for (let at = 0; at < argv.length; at += 2) {
27
28
  refuse(`${JSON.stringify(flag)} is not one of ${[...FLAGS].join(", ")}, each once and with a value`);
28
29
  given.set(flag, argv[at + 1]);
29
30
  }
30
- let allow = [];
31
- try {
32
- allow = parseAllow(given.get("--allow") ?? "");
31
+ const open = given.get("--open");
32
+ if (open !== undefined && open !== "public")
33
+ refuse(`--open takes "public", not ${JSON.stringify(open)}`);
34
+ if (open !== undefined && given.has("--allow"))
35
+ refuse("both --open and --allow were given: a proxy serves one");
36
+ let allow;
37
+ if (open === undefined) {
38
+ try {
39
+ allow = parseAllow(given.get("--allow") ?? "");
40
+ }
41
+ catch (error) {
42
+ refuse(`its list is not one (${error.message})`);
43
+ }
44
+ if (allow === undefined || allow.length === 0)
45
+ refuse("no host list was given, and no --open public: no list never means every public host");
33
46
  }
34
- catch (error) {
35
- refuse(`its list is not one (${error.message})`);
36
- }
37
- if (allow.length === 0)
38
- refuse("no host list was given: one with none would reach every public host");
39
47
  const socketPath = given.get("--socket") ?? "";
40
48
  if (!socketPath.startsWith("/"))
41
49
  refuse("no socket path was given");
@@ -48,11 +56,11 @@ const proxy = await startEgressProxy({
48
56
  maxTunnels: MAX_TUNNELS,
49
57
  maxConnections: MAX_CONNECTIONS,
50
58
  log: say,
51
- allow,
59
+ ...(allow === undefined ? {} : { allow }),
52
60
  alsoLocal: () => local,
53
61
  ...(given.has("--hint") ? { allowHint: given.get("--hint") } : {}),
54
62
  });
55
- say(`${EGRESS_READY} allow=${allow.join(",")}`);
63
+ say(allow === undefined ? `${EGRESS_READY} open` : `${EGRESS_READY} allow=${allow.join(",")}`);
56
64
  const end = (why) => {
57
65
  say(`egress: ${why}, the proxy ends`);
58
66
  void proxy.close().finally(() => process.exit(0));
@@ -47,7 +47,7 @@ export declare function egressCodeProblem({ dir, packageJson }: EgressCode, user
47
47
  * A spec's allowlist, normalized as the proxy reads it (parseAllow: lowercase, a name's trailing dot dropped, no
48
48
  * repeats), or why Docker cannot hold it, in words.
49
49
  */
50
- export declare function allowOf(entries: unknown): {
50
+ export declare function allowOf(entries: unknown, owner?: string): {
51
51
  list: string[];
52
52
  } | {
53
53
  problem: string;
@@ -72,7 +72,8 @@ export interface EgressRun {
72
72
  name: string;
73
73
  user: string;
74
74
  image: string;
75
- allow: readonly string[];
75
+ /** The list, or "open": every public host. */
76
+ allow: readonly string[] | "open";
76
77
  local: readonly string[];
77
78
  deadline: string;
78
79
  code: EgressCode;
@@ -92,14 +93,15 @@ export interface EgressOwner {
92
93
  running: boolean;
93
94
  }
94
95
  /**
95
- * A computer's allowlist, read back from its proxy container's inspect: the list its argv holds, when the container is
96
+ * A computer's network through its proxy, read back from the proxy container's inspect: "open" where its argv holds
97
+ * `--open public`, else the list its argv holds, when the container is
96
98
  * the computer's own (its label and deadline), running while the computer runs, and as create makes one (Docker's
97
99
  * default bridge alone, no port, the computer's user, a read-only root, no capability or privilege, exactly its volume
98
100
  * and its code, `code`'s when given), refusing every one of `local`, the Docker host's own addresses the provider
99
101
  * requires now (more is fine). Anything less is `{ other }` in words, never an allowlist. A host whose addresses
100
102
  * changed since the proxy was made reads as other: fail closed.
101
103
  */
102
- export declare function egressOf(proxy: DockerInspect | null | undefined, owner: EgressOwner, code?: EgressCode, local?: readonly string[]): {
104
+ export declare function egressOf(proxy: DockerInspect | null | undefined, owner: EgressOwner, code?: EgressCode, local?: readonly string[]): "open" | {
103
105
  allow: string[];
104
106
  } | {
105
107
  other: string;
@@ -1,6 +1,7 @@
1
- // A Docker computer's way out to the network when its spec asks for an allowlist ({ allow: [names or CIDRs] }): the
2
- // computer stays `--network none`, and its own egress proxy runs in a second container the provider makes, reads back
3
- // and removes with it. The proxy does not live in the process that
1
+ // A Docker computer's way out to the network when its spec asks for open (every public host) or an allowlist ({ allow:
2
+ // [names or CIDRs] }): the computer stays `--network none`, and its own egress proxy runs in a second container the
3
+ // provider makes, reads back and removes with it. Open is the proxy with no list (`--open public`), on the same address
4
+ // rule, so an open computer reaches neither the Docker host, nor a private range, nor metadata. The proxy does not live in the process that
4
5
  // made the computer, so the computer keeps its network when that process ends, and attach and list read it back from
5
6
  // Docker anywhere.
6
7
  //
@@ -9,7 +10,7 @@
9
10
  // - The proxy container `<computer>-egress`: this package's own proxy (egress-main.ts, egress-proxy.ts, egress-table.ts,
10
11
  // bound read-only from dist/docker with the package's package.json), in a pinned Node image, on Docker's default
11
12
  // bridge alone, publishing no port, as the computer's uid:gid, with a read-only root, no capability, no privilege to
12
- // gain, and bounded memory, pids and log. Its argv holds the list, the computer's deadline (it ends itself then), the
13
+ // gain, and bounded memory, pids and log. Its argv holds the list (or `--open public`), the computer's deadline (it ends itself then), the
13
14
  // Docker host's own public addresses (refused as this host's) and the hint. It holds no key.
14
15
  // - The computer: init gets `--egress <socket>` and relays its loopback port 3128 to the socket, and tells every program
15
16
  // it starts that port is its HTTP and HTTPS proxy. A program that ignores that reaches nothing: there is no route.
@@ -80,7 +81,7 @@ export function egressCodeProblem({ dir, packageJson }, user) {
80
81
  * A spec's allowlist, normalized as the proxy reads it (parseAllow: lowercase, a name's trailing dot dropped, no
81
82
  * repeats), or why Docker cannot hold it, in words.
82
83
  */
83
- export function allowOf(entries) {
84
+ export function allowOf(entries, owner = "a Docker allowlist") {
84
85
  if (!Array.isArray(entries) || !entries.every((entry) => typeof entry === "string"))
85
86
  return { problem: `an allowlist is a list of names and CIDRs, such as ${EXAMPLE}` };
86
87
  if (entries.length === 0)
@@ -97,9 +98,9 @@ export function allowOf(entries) {
97
98
  const cidrs = list.filter((entry) => entry.includes("/")).length;
98
99
  const names = list.length - cidrs;
99
100
  if (names > MAX_ALLOW)
100
- return { problem: `a Docker allowlist holds at most ${MAX_ALLOW} names, not ${names}` };
101
+ return { problem: `${owner} holds at most ${MAX_ALLOW} names, not ${names}` };
101
102
  if (cidrs > MAX_ALLOW)
102
- return { problem: `a Docker allowlist holds at most ${MAX_ALLOW} CIDRs, not ${cidrs}` };
103
+ return { problem: `${owner} holds at most ${MAX_ALLOW} CIDRs, not ${cidrs}` };
103
104
  return { list };
104
105
  }
105
106
  /** Whether two allowlists hold the same entries, normalized, in any order. */
@@ -185,7 +186,7 @@ export function egressRunArgs({ name, user, image, allow, local, deadline, code,
185
186
  }
186
187
  // Create pulled the image before it made the volume, so this run never pulls: the sweep's grace holds.
187
188
  args.push("--pull", "never");
188
- args.push("--entrypoint", "node", image, PROXY_MAIN, "--socket", PROXY_SOCKET, "--deadline", deadline, "--allow", allow.join(","));
189
+ args.push("--entrypoint", "node", image, PROXY_MAIN, "--socket", PROXY_SOCKET, "--deadline", deadline, ...(allow === "open" ? ["--open", "public"] : ["--allow", allow.join(",")]));
189
190
  if (local.length > 0)
190
191
  args.push("--local", local.join(","));
191
192
  if (hint !== undefined)
@@ -195,7 +196,8 @@ export function egressRunArgs({ name, user, image, allow, local, deadline, code,
195
196
  const show = (value) => (value === undefined ? "nothing" : JSON.stringify(value));
196
197
  const blank = (value) => value === undefined || value === null || value === "" || value === 0 || value === false || (typeof value === "object" && Object.keys(value).length === 0);
197
198
  /**
198
- * A computer's allowlist, read back from its proxy container's inspect: the list its argv holds, when the container is
199
+ * A computer's network through its proxy, read back from the proxy container's inspect: "open" where its argv holds
200
+ * `--open public`, else the list its argv holds, when the container is
199
201
  * the computer's own (its label and deadline), running while the computer runs, and as create makes one (Docker's
200
202
  * default bridge alone, no port, the computer's user, a read-only root, no capability or privilege, exactly its volume
201
203
  * and its code, `code`'s when given), refusing every one of `local`, the Docker host's own addresses the provider
@@ -204,7 +206,10 @@ const blank = (value) => value === undefined || value === null || value === "" |
204
206
  */
205
207
  export function egressOf(proxy, owner, code, local = []) {
206
208
  const named = egressNameOf(owner.name);
207
- const other = (what) => ({ other: `network allow, but its egress proxy ${named} ${what}` });
209
+ const cmd = Array.isArray(proxy?.Config?.Cmd) ? proxy.Config.Cmd : [];
210
+ // The form by the flag names alone (argv[1], [3], ...): a value such as a hint of "--open" never makes it open.
211
+ const form = cmd.some((arg, at) => at % 2 === 1 && arg === "--open") ? "open" : "allow";
212
+ const other = (what) => ({ other: `network ${form}, but its egress proxy ${named} ${what}` });
208
213
  if (proxy === undefined || proxy === null)
209
214
  return other("is gone: the computer reaches nothing");
210
215
  const config = proxy.Config ?? {};
@@ -287,23 +292,26 @@ export function egressOf(proxy, owner, code, local = []) {
287
292
  const entrypoint = config.Entrypoint;
288
293
  if (!Array.isArray(entrypoint) || entrypoint.length !== 1 || entrypoint[0] !== "node")
289
294
  return other(`has the entrypoint ${show(entrypoint)}, not node`);
290
- const cmd = Array.isArray(config.Cmd) ? config.Cmd : [];
291
295
  const flags = new Map();
292
296
  for (let at = 1; at + 1 < cmd.length; at += 2)
293
297
  flags.set(String(cmd[at]), String(cmd[at + 1]));
294
298
  if (cmd[0] !== PROXY_MAIN || cmd.length % 2 !== 1 || flags.size !== (cmd.length - 1) / 2)
295
299
  return other(`runs ${show(cmd)}, not ${PROXY_MAIN} and its flags`);
296
- if (!flags.has("--allow"))
300
+ if (flags.has("--open") && flags.has("--allow"))
301
+ return other("has both --open and a host list in its command");
302
+ if (form === "open" && flags.get("--open") !== "public")
303
+ return other(`runs with --open ${show(flags.get("--open"))}, not public`);
304
+ if (form === "allow" && !flags.has("--allow"))
297
305
  return other("has no host list in its command");
298
306
  if (flags.get("--socket") !== PROXY_SOCKET)
299
307
  return other(`listens on ${show(flags.get("--socket"))}, not ${PROXY_SOCKET}`);
300
308
  if (flags.get("--deadline") !== owner.deadline)
301
309
  return other(`ends at ${show(flags.get("--deadline"))}, not the computer's deadline ${show(owner.deadline)}`);
302
- const unknown = [...flags.keys()].filter((flag) => !["--socket", "--deadline", "--allow", "--local", "--hint"].includes(flag));
310
+ const unknown = [...flags.keys()].filter((flag) => !["--socket", "--deadline", "--allow", "--open", "--local", "--hint"].includes(flag));
303
311
  if (unknown.length > 0)
304
312
  return other(`runs with flags ${unknown.join(", ")}, which create never gives`);
305
- const read = allowOf((flags.get("--allow") ?? "").split(","));
306
- if ("problem" in read)
313
+ const read = form === "open" ? undefined : allowOf((flags.get("--allow") ?? "").split(","));
314
+ if (read !== undefined && "problem" in read)
307
315
  return other(`holds a list this provider never makes: ${read.problem}`);
308
316
  // The host block: a --local removed or shortened lets the computer reach the Docker host's own addresses.
309
317
  const refused = new Set((flags.get("--local") ?? "").split(",").filter(Boolean));
@@ -311,7 +319,7 @@ export function egressOf(proxy, owner, code, local = []) {
311
319
  if (missing.length > 0) {
312
320
  return other(`does not refuse the Docker host's ${missing.length === 1 ? "address" : "addresses"} ${missing.join(", ")} (its --local reads ${show(flags.get("--local"))})`);
313
321
  }
314
- return { allow: read.list };
322
+ return read === undefined ? "open" : { allow: read.list };
315
323
  }
316
324
  /** The ports each entry of a Docker allowlist opens. */
317
325
  export const ALLOW_PORTS = [...LISTED_PORTS];
@@ -128,8 +128,8 @@ export declare function mountAsked(path: string, target: string, readonly: boole
128
128
  export declare function egressShaped(inspected: DockerInspect | null | undefined): boolean;
129
129
  /**
130
130
  * The network a computer is on, read back from inspect: `none` is network mode none on no network but Docker's own
131
- * `none`, `open` is the default bridge alone. An allowlist is network mode none with the computer's egress volume
132
- * mounted read-only at EGRESS_MOUNT and init relaying to its socket, and the list read back from `proxy`, the
131
+ * `none`. Open and an allowlist are network mode none with the computer's egress volume mounted read-only at
132
+ * EGRESS_MOUNT and init relaying to its socket, and the form (`--open public` or the list) read back from `proxy`, the
133
133
  * computer's proxy container's inspect (egressOf: none when it is gone), which must refuse each of `local`, the Docker
134
134
  * host's own addresses. Anything else is reported in words, never as a policy it might widen to.
135
135
  */
@@ -111,8 +111,8 @@ export function egressShaped(inspected) {
111
111
  }
112
112
  /**
113
113
  * The network a computer is on, read back from inspect: `none` is network mode none on no network but Docker's own
114
- * `none`, `open` is the default bridge alone. An allowlist is network mode none with the computer's egress volume
115
- * mounted read-only at EGRESS_MOUNT and init relaying to its socket, and the list read back from `proxy`, the
114
+ * `none`. Open and an allowlist are network mode none with the computer's egress volume mounted read-only at
115
+ * EGRESS_MOUNT and init relaying to its socket, and the form (`--open public` or the list) read back from `proxy`, the
116
116
  * computer's proxy container's inspect (egressOf: none when it is gone), which must refuse each of `local`, the Docker
117
117
  * host's own addresses. Anything else is reported in words, never as a policy it might widen to.
118
118
  */
@@ -124,8 +124,7 @@ export function networkOf(inspected, proxy, code, local) {
124
124
  if (!egressShaped(inspected)) {
125
125
  if (none)
126
126
  return "none";
127
- if (mode === "bridge" && sameList(networks, ["bridge"]))
128
- return "open";
127
+ // Open goes through the egress proxy: a computer on a network of Docker's is one this provider never makes.
129
128
  return { other: where };
130
129
  }
131
130
  if (!none)
@@ -189,7 +188,8 @@ export function inspectDrift(spec, inspected, expected) {
189
188
  const network = networkOf(inspected, expected.proxy, expected.egressCode, expected.hostAddresses);
190
189
  if (!samePolicy(spec.network, network))
191
190
  found.push(`network: declared ${policyWords(spec.network)}, read back ${policyWords(network)}`);
192
- const allowed = typeof spec.network === "object" && spec.network !== null && "allow" in spec.network;
191
+ // Open and an allowlist each go through the egress proxy: its volume mounted, init relaying to its socket.
192
+ const allowed = spec.network === "open" || (typeof spec.network === "object" && spec.network !== null && "allow" in spec.network);
193
193
  const volume = egressNameOf((inspected?.Name ?? "").replace(/^\//, ""));
194
194
  if (!sameList(host.CapDrop, ["ALL"]))
195
195
  mismatch("CapDrop", ["ALL"], host.CapDrop);
package/dist/docker.d.ts CHANGED
@@ -5,12 +5,12 @@ import { type AttachedComputer, type CallContext, type CreateContext, type Compu
5
5
  import { type Result } from "./result.js";
6
6
  import { type ScreenWatch, type ScreenWatchHandlers, type WatchOptions } from "./screen-watch.js";
7
7
  /**
8
- * A Docker desktop: an image with an X server (test/fixtures/desktop/Dockerfile is the smallest, Debian and Xvfb).
8
+ * A Docker desktop: an image with an X server (test/fixtures/desktop/Dockerfile is the smallest, Alpine and Xvfb).
9
9
  * computerd stays the first process and starts nothing of its own: create gives it DISPLAY, then starts the X server
10
10
  * through it with process.start (startDisplay in ./desktop.ts).
11
11
  */
12
12
  export type DockerDesktopOptions = DesktopOptions;
13
- /** A computer's egress proxy, for a spec whose network is an allowlist (src/docker/egress.ts). */
13
+ /** A computer's egress proxy, for a spec whose network is open or an allowlist (src/docker/egress.ts). */
14
14
  export interface DockerEgressOptions {
15
15
  /** The proxy container's image: one with Node 22.19 or later as `node`. Default EGRESS_IMAGE, pinned by digest. */
16
16
  image?: string;
@@ -20,7 +20,7 @@ export interface DockerEgressOptions {
20
20
  readyMs?: number;
21
21
  /**
22
22
  * The Docker host's own addresses, each an IP address, which the proxy refuses as the host's (this-host), beside this
23
- * machine's public ones. Required for an allowlist when this provider's interfaces are not the Docker host's: it runs
23
+ * machine's public ones. Required for open or an allowlist when this provider's interfaces are not the Docker host's: it runs
24
24
  * in a container (containerSigns), or its docker CLI talks to a daemon that is not a local unix socket.
25
25
  */
26
26
  hostAddresses?: string[];
@@ -40,7 +40,7 @@ export interface DockerProviderOptions {
40
40
  * under a directory another user may write. Default ~/.cache/agentrun-computer; the provider reads no
41
41
  * environment, XDG_CACHE_HOME included. */
42
42
  daemonCache?: string;
43
- /** The egress proxy of a computer whose network is an allowlist. */
43
+ /** The egress proxy of a computer whose network is open or an allowlist. */
44
44
  egress?: DockerEgressOptions;
45
45
  /** Makes every computer a desktop (kind desktop): its image must have the X server. */
46
46
  desktop?: DockerDesktopOptions;
@@ -106,7 +106,8 @@ export declare class DockerProvider implements ComputerProvider {
106
106
  /** The provider contract's prepareImage (its descriptor declares it): image(), its recipe built or its image pulled. */
107
107
  prepareImage(context?: CallContext & Pick<EnsureImageOptions, "onWait">): Promise<Result<string>>;
108
108
  /** The spec's refusals, and the host's once create, attach or host() has read it: its problems, a bind or an
109
- * allowlist on a host that remaps user ids, and an allowlist on a Docker host this provider does not run on. */
109
+ * open or an allowlist (each through the egress proxy) on a host that remaps user ids or that this provider does not
110
+ * run on. */
110
111
  check(spec: ComputerSpec): Refusal[];
111
112
  /**
112
113
  * Makes a computer, once per request (provider.md, Idempotent create): context.requestId names the container
package/dist/docker.js CHANGED
@@ -233,12 +233,13 @@ export class DockerProvider {
233
233
  return this.image(context);
234
234
  }
235
235
  /** The spec's refusals, and the host's once create, attach or host() has read it: its problems, a bind or an
236
- * allowlist on a host that remaps user ids, and an allowlist on a Docker host this provider does not run on. */
236
+ * open or an allowlist (each through the egress proxy) on a host that remaps user ids or that this provider does not
237
+ * run on. */
237
238
  check(spec) {
238
239
  const host = this.#host;
239
240
  const remapped = host?.remap !== undefined && spec?.mount?.kind === "bind" ? [{ field: "mount", message: remapWords(host.remap, String(spec.mount.path)) }] : [];
240
241
  const allowed = [];
241
- if (isAllow(spec?.network)) {
242
+ if (spec?.network === "open" || isAllow(spec?.network)) {
242
243
  if (host?.remap !== undefined)
243
244
  allowed.push({ field: "network", message: remapAllowWords(host.remap) });
244
245
  if (typeof this.#elsewhere === "string" && this.#egress.hostAddresses === undefined)
@@ -439,8 +440,8 @@ export class DockerProvider {
439
440
  if (folder !== undefined && !folder.ok)
440
441
  return folder;
441
442
  const folderMount = folder?.value;
442
- // An allowlist: the list as the proxy reads it, and the proxy's code, built.
443
- const allow = typeof spec.network === "object" ? allowOf(spec.network.allow).list : undefined;
443
+ // Open or an allowlist: what the proxy serves ("open", or the list as it reads it), and the proxy's code, built.
444
+ const allow = spec.network === "open" ? "open" : typeof spec.network === "object" ? allowOf(spec.network.allow).list : undefined;
444
445
  if (allow !== undefined) {
445
446
  // With the volume option, the code is staged below the volume's root, where the Docker daemon can mount it from:
446
447
  // the copy (0755 directories, 0644 files) is what the computer's user must read.
@@ -503,7 +504,7 @@ export class DockerProvider {
503
504
  const lifetimeFrom = Date.now();
504
505
  const deadline = new Date(lifetimeFrom + runLifetimeMs(spec)).toISOString();
505
506
  if (allow !== undefined) {
506
- // The proxy first, ready before the computer exists: a computer never runs with an allowlist it cannot reach.
507
+ // The proxy first, ready before the computer exists: a computer never runs with a network it cannot reach.
507
508
  const started = await this.#startEgress(name, user, deadline, allow, spec.labels ?? {}, attempt, signal);
508
509
  if (!started.ok) {
509
510
  // Another create of this request, in another process, runs its proxy: what it makes is the request's.
@@ -529,8 +530,8 @@ export class DockerProvider {
529
530
  args.push("--cap-drop", "ALL", "--security-opt", "no-new-privileges", "--pids-limit", String(spec.pids ?? DEFAULT_PIDS));
530
531
  // Not the daemon's defaults, which a host may set to shareable IPC or, on cgroup v1, the host's cgroup namespace.
531
532
  args.push("--ipc", "private", "--cgroupns", "private");
532
- // An allowlist's computer has no network either: its one way out is the proxy's socket.
533
- args.push("--network", spec.network === "open" ? "bridge" : "none");
533
+ // No computer has a network of Docker's: open's and an allowlist's one way out is the proxy's socket.
534
+ args.push("--network", "none");
534
535
  args.push("--cpu-period", String(CPU_PERIOD_US), "--cpu-quota", String(Math.round((spec.cpus ?? DEFAULT_CPUS) * CPU_PERIOD_US)));
535
536
  // Memory and swap together are the memory: swap never adds to it.
536
537
  const memory = `${memoryMb}m`;
@@ -545,8 +546,8 @@ export class DockerProvider {
545
546
  if (allow !== undefined)
546
547
  args.push("--mount", `type=volume,src=${egressNameOf(name)},dst=${EGRESS_MOUNT},readonly`, "--pull", "never");
547
548
  args.push("--workdir", spec.workdir ?? WORK);
548
- // PID 1 ends the computer at the deadline the label holds, so a computer the janitor misses still stops. With an
549
- // allowlist it relays its loopback port 3128 to the proxy's socket, and names that port as every program's proxy.
549
+ // PID 1 ends the computer at the deadline the label holds, so a computer the janitor misses still stops. With open
550
+ // or an allowlist it relays its loopback port 3128 to the proxy's socket, and names that port as every program's proxy.
550
551
  args.push(spec.image, "init", "--deadline", deadline, ...(allow === undefined ? [] : [RELAY_FLAG, EGRESS_SOCKET]));
551
552
  const started = await this.#run(args, signal);
552
553
  const ranMs = Date.now() - lifetimeFrom;
@@ -1459,7 +1460,7 @@ function egressOptionsOf({ image = EGRESS_IMAGE, hint, readyMs = EGRESS_READY_MS
1459
1460
  * own addresses as this-host only when it knows them, and here it does not.
1460
1461
  */
1461
1462
  function elsewhereWords(why) {
1462
- return `${why}, so this provider's own interfaces are not the Docker host's, and the egress proxy could not refuse the host's own addresses: pass them as egress.hostAddresses, or ask for network none or open`;
1463
+ return `${why}, so this provider's own interfaces are not the Docker host's, and the egress proxy could not refuse the host's own addresses: pass them as egress.hostAddresses, or ask for network none`;
1463
1464
  }
1464
1465
  /** Whether a spec's network is an allowlist. */
1465
1466
  const isAllow = (network) => typeof network === "object" && network !== null && "allow" in network;
@@ -1470,7 +1471,7 @@ const isAllow = (network) => typeof network === "object" && network !== null &&
1470
1471
  */
1471
1472
  function remapAllowWords(remap) {
1472
1473
  return (`this Docker host remaps user ids (${remap === "userns" ? "userns-remap" : "rootless Docker"}), so the egress volume and the proxy's code are ` +
1473
- "owned by host ids the computer's user does not map to, and the provider cannot give it an allowlist: ask for network none or open, " +
1474
+ "owned by host ids the computer's user does not map to, and the provider cannot give it open or an allowlist, each through that proxy: ask for network none, " +
1474
1475
  "or use a Docker host that does not remap ids");
1475
1476
  }
1476
1477
  /**
package/dist/e2b.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { HostedProvider, type HostedOptions, type HostedTimeouts } from "./hosted/provider.js";
2
+ import { type Result } from "./result.js";
2
3
  /**
3
4
  * What every SDK call is given: the key, the domain and the API URL explicitly, and debug false (index.mjs:1126-1152).
4
5
  * The SDK's types below are `import type`: erased at build, so nothing loads the SDK from here and the published types
@@ -51,9 +52,18 @@ export declare function create(options: E2BOptions): Promise<E2BProvider>;
51
52
  /** The conformance CLI's module for E2B: its live switch, the run's 30-minute cap, its template and the drifted twin. */
52
53
  export declare const conformance: () => Promise<typeof import("./conformance/e2b.js")>;
53
54
  /**
54
- * Computers that are E2B sandboxes, on the shared adapter. A spec's image is an E2B template (its name or id):
55
- * "desktop" is E2B Desktop's, with Xvfb, x11vnc and noVNC (e2b-dev/desktop template.py:21-65).
55
+ * Computers that are E2B sandboxes, on the shared adapter. A spec's image is an E2B template (its name or id). A server
56
+ * starts every one, sandbox or desktop, from the box template prepareImage() answers: the box image (box/Dockerfile)
57
+ * with Archil's client and its root helper, Xvfb, xfwm4 and the desktop's apps, which the provider starts through
58
+ * computerd (desktop.ts). Any other template a spec names must carry what the computer's kind needs.
56
59
  */
57
60
  export declare class E2BProvider extends HostedProvider {
61
+ /**
62
+ * The provider contract's prepareImage (its descriptor declares it): the box template the release publishes,
63
+ * public under its E2B team (box-image.ts boxE2bTemplate), which any E2B account starts by that name. No call: E2B
64
+ * starts a public template at create with nothing to pull ahead of it, so onWait is never told. A desktop starts
65
+ * from the same template as a sandbox: the kind is the provider's, not the image's.
66
+ */
67
+ prepareImage(): Promise<Result<string>>;
58
68
  constructor(options: E2BProviderOptions);
59
69
  }
package/dist/e2b.js CHANGED
@@ -1,10 +1,11 @@
1
- import { E2B, E2B_BASE_TEMPLATE, E2B_DESKTOP_TEMPLATE } from "./descriptors/e2b.js";
1
+ import { boxE2bTemplate } from "./box-image.js";
2
+ import { E2B } from "./descriptors/e2b.js";
2
3
  import { DEADLINE_LABEL, show } from "./drift.js";
3
4
  import { HostError } from "./host.js";
4
5
  import { deadlineOf, HostedProvider, isoOf, MAX_LABEL, timeoutsOf } from "./hosted/provider.js";
5
- import { shellLine } from "./hosted/scripts.js";
6
- import { dateOf, DOMAIN, isWhole } from "./hosted/values.js";
6
+ import { dateOf, DOMAIN, isWhole, sizeRefusals } from "./hosted/values.js";
7
7
  import { PassThrough } from "node:stream";
8
+ import { ok } from "./result.js";
8
9
  /** Not a literal, so no type checker or bundler resolves the SDK from this package. */
9
10
  const E2B_PACKAGE = "e2b";
10
11
  const DEFAULT_DOMAIN = "e2b.app";
@@ -58,6 +59,13 @@ const KEEPALIVE_HEADER = "Keepalive-Ping-Interval";
58
59
  const KEEPALIVE_S = "50";
59
60
  /** The Connect codes envd's process calls answer (connectrpc Code), as this provider's codes. */
60
61
  const CONNECT_CODES = { 1: "aborted", 3: "invalid", 4: "timeout", 5: "not_found", 7: "denied", 8: "limit", 16: "denied" };
62
+ /** What create makes root's alone in every E2B computer, before anything else (HostFacts.rootOnly). */
63
+ const ROOT_ONLY = ["/usr/local", "/usr/bin/envd", "/etc/inittab"];
64
+ /** Root's command, as envd starts it: /bin/sh by its path, no login shell, the argv as its own words. */
65
+ const ROOT_SHELL = "/bin/sh";
66
+ const ROOT_SHELL_ARGS = ["-c", 'exec "$@"', "sh"];
67
+ /** The PATH root's command runs with: the system's directories alone, none of /usr/local. */
68
+ const ROOT_PATH = "/usr/sbin:/usr/bin:/sbin:/bin";
61
69
  /** The SDK names its errors (index.mjs:86-360); Connect's carry a code. */
62
70
  function codeOf(error) {
63
71
  const name = error?.name;
@@ -86,7 +94,7 @@ function createdEnd({ metadata, startedAt }) {
86
94
  const clearOf = (created) => created + END_SLACK_MS + 1_000;
87
95
  /**
88
96
  * A sandbox as the adapter reads a machine, from getInfo or the listing alike: E2B's state (a paused one is stopped), its
89
- * start, its end. E2B keeps no metadata change, so once an extend moved its timer clear of create's end (setTimer), the
97
+ * start, its end. E2B keeps no metadata change, so once an extend moved its timer clear of create's end (extend), the
90
98
  * deadline label reads that end, up to the most the computer may live: a restarted provider reads the extend all the same.
91
99
  */
92
100
  function machineOf(info) {
@@ -114,8 +122,10 @@ class E2BHost {
114
122
  maxLifetimeMs: PRO_MAX_MS,
115
123
  arch: "amd64",
116
124
  vendorAgentPorts: [ENVD_PORT],
117
- // E2B Desktop's template has xfwm4, which its own desktop runs: the apps an agent opens are framed and focused.
125
+ // The box template has xfwm4 (box/Dockerfile), as E2B Desktop's has: the apps an agent opens are framed and focused.
118
126
  windowManager: true,
127
+ // System paths whose permissions E2B's template build sets wider than root's, on its templates and ours alike.
128
+ rootOnly: ROOT_ONLY,
119
129
  };
120
130
  #Sandbox;
121
131
  #connection;
@@ -134,27 +144,29 @@ class E2BHost {
134
144
  #api(ms, signal) {
135
145
  return { ...this.#connection, requestTimeoutMs: ms, ...(signal ? { signal } : {}) };
136
146
  }
137
- /** An E2B template is a name or id: letters, digits and ._:/- (no shell word, no path out). */
138
- check({ image }) {
139
- if (typeof image === "string" && image !== "" && !TEMPLATE.test(image)) {
140
- return [{ field: "image", message: `an image is the name or id of an E2B template, such as "${E2B_DESKTOP_TEMPLATE}" (E2B Desktop) or "${E2B_BASE_TEMPLATE}"` }];
147
+ /** An E2B template is a name or id: letters, digits and ._:/- (no shell word, no path out); its size is the template's. */
148
+ check(spec) {
149
+ const refusals = sizeRefusals(spec, "an E2B computer", "template");
150
+ if (typeof spec.image === "string" && spec.image !== "" && !TEMPLATE.test(spec.image)) {
151
+ refusals.push({ field: "image", message: `an image is the name or id of an E2B template, such as "${boxE2bTemplate()}" (the box template) or "desktop" (E2B Desktop)` });
141
152
  }
142
- return [];
153
+ return refusals;
143
154
  }
144
155
  /**
145
156
  * Sandbox.create with the lifetime as its timeout in the whole seconds E2B takes (index.mjs:502-504), recorded in a
146
- * label for its end's arithmetic; no internet access unless the adapter asks open (an Archil computer's root), no
157
+ * label for its end's arithmetic; no internet access unless the adapter asks egress (an Archil computer's root, or the
158
+ * egress proxy of a network open or a list), no
147
159
  * public traffic (a project's default may let it in: E2B docs, network/restrict-public-access), and kill at the
148
160
  * timeout, never a pause that keeps the computer (index.mjs:5674-5699).
149
161
  */
150
162
  async create(req, ctx) {
151
- const timeoutMs = Math.ceil((req.lifetimeMs ?? 0) / 1000) * 1000;
163
+ const timeoutMs = Math.ceil(req.lifetimeMs / 1000) * 1000;
152
164
  const options = {
153
165
  ...this.#api(ctx.timeoutMs),
154
166
  timeoutMs,
155
167
  metadata: { ...req.labels, [TIMEOUT_LABEL]: String(timeoutMs) },
156
168
  envs: {},
157
- allowInternetAccess: req.network === "open",
169
+ allowInternetAccess: req.egress,
158
170
  network: { allowPublicTraffic: false },
159
171
  lifecycle: { onTimeout: "kill" },
160
172
  };
@@ -215,9 +227,9 @@ class E2BHost {
215
227
  await sandbox.files.write(path, buffer, { user: "root", requestTimeoutMs: ctx.timeoutMs, ...(ctx.signal ? { signal: ctx.signal } : {}) });
216
228
  }
217
229
  /**
218
- * A process as root through envd's Process.Start stream, as commands.run starts one (index.mjs:5123-5146): `bash -l -c`
219
- * and the argv quoted, root by the Basic header (authenticationHeader, index.mjs:1896-1900), and envd's keepalive
220
- * every 50 s. Its stdout and stderr are the bytes each data event carries, passed on as they come: commands.run would
230
+ * A process as root through envd's Process.Start stream, the call commands.run makes (index.mjs:5123-5146) without its
231
+ * login shell: /bin/sh by its path runs the argv as its own words, with PATH the system's directories alone, root by the
232
+ * Basic header (authenticationHeader, index.mjs:1896-1900), and envd's keepalive every 50 s. Its stdout and stderr are the bytes each data event carries, passed on as they come: commands.run would
221
233
  * decode them as UTF-8 text first. No deadline on the stream (timeoutMs 0, which the Connect transport reads as none,
222
234
  * connect-web connect-transport.js:145-150), so envd never ends it (start.go:39-44); the start alone is bounded by
223
235
  * ctx. Writes go one sendStdin at a time, in order; end is closeStdin; kill SIGKILLs it and lets go of its stream.
@@ -228,7 +240,7 @@ class E2BHost {
228
240
  const err = new PassThrough();
229
241
  const requestTimeoutMs = this.#requestMs;
230
242
  const stream = new AbortController();
231
- const events = sandbox.commands.rpc.start({ process: { cmd: "/bin/bash", args: ["-l", "-c", shellLine(argv)], envs: {} }, stdin: true }, { headers: { Authorization: ROOT, [KEEPALIVE_HEADER]: KEEPALIVE_S }, signal: stream.signal, timeoutMs: 0 })[Symbol.asyncIterator]();
243
+ const events = sandbox.commands.rpc.start({ process: { cmd: ROOT_SHELL, args: [...ROOT_SHELL_ARGS, ...argv], envs: { PATH: ROOT_PATH } }, stdin: true }, { headers: { Authorization: ROOT, [KEEPALIVE_HEADER]: KEEPALIVE_S }, signal: stream.signal, timeoutMs: 0 })[Symbol.asyncIterator]();
232
244
  // The start, within ctx: a stream that gives no start event in time, or the caller's abort, is let go of.
233
245
  const startAbort = () => stream.abort(ctx.signal?.reason);
234
246
  ctx.signal?.addEventListener("abort", startAbort, { once: true });
@@ -326,10 +338,21 @@ class E2BHost {
326
338
  }
327
339
  }
328
340
  /**
329
- * Computers that are E2B sandboxes, on the shared adapter. A spec's image is an E2B template (its name or id):
330
- * "desktop" is E2B Desktop's, with Xvfb, x11vnc and noVNC (e2b-dev/desktop template.py:21-65).
341
+ * Computers that are E2B sandboxes, on the shared adapter. A spec's image is an E2B template (its name or id). A server
342
+ * starts every one, sandbox or desktop, from the box template prepareImage() answers: the box image (box/Dockerfile)
343
+ * with Archil's client and its root helper, Xvfb, xfwm4 and the desktop's apps, which the provider starts through
344
+ * computerd (desktop.ts). Any other template a spec names must carry what the computer's kind needs.
331
345
  */
332
346
  export class E2BProvider extends HostedProvider {
347
+ /**
348
+ * The provider contract's prepareImage (its descriptor declares it): the box template the release publishes,
349
+ * public under its E2B team (box-image.ts boxE2bTemplate), which any E2B account starts by that name. No call: E2B
350
+ * starts a public template at create with nothing to pull ahead of it, so onWait is never told. A desktop starts
351
+ * from the same template as a sandbox: the kind is the provider's, not the image's.
352
+ */
353
+ async prepareImage() {
354
+ return ok(boxE2bTemplate());
355
+ }
333
356
  constructor(options) {
334
357
  // A caller who still names the option is told it is gone, whatever its value: it once let public traffic in.
335
358
  if (typeof options === "object" && options !== null && Object.hasOwn(options, "publicStream"))