@parcha/agentrun-computer 0.1.0-beta.37 → 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.
- package/README.md +341 -260
- package/box/Dockerfile +18 -1
- package/box/README.md +14 -0
- package/box/build-daytona.py +2 -2
- package/box/build-e2b.mjs +41 -18
- package/box/recipe.d.mts +5 -0
- package/box/recipe.mjs +43 -0
- package/dist/agent37.d.ts +18 -66
- package/dist/agent37.js +187 -464
- package/dist/box-image.d.ts +14 -0
- package/dist/box-image.js +24 -0
- package/dist/browserbase.d.ts +0 -6
- package/dist/browserbase.js +1 -5
- package/dist/client.d.ts +12 -3
- package/dist/client.js +39 -4
- package/dist/computerd-linux-amd64 +0 -0
- package/dist/computerd-linux-arm64 +0 -0
- package/dist/computerd.json +4 -0
- package/dist/conformance/agent37.d.ts +9 -4
- package/dist/conformance/agent37.js +23 -11
- package/dist/conformance/browserbase.js +3 -3
- package/dist/conformance/cases/apps.d.ts +6 -0
- package/dist/conformance/cases/apps.js +18 -5
- package/dist/conformance/cases/isolation.d.ts +22 -5
- package/dist/conformance/cases/isolation.js +97 -16
- package/dist/conformance/cases/mount.js +5 -3
- package/dist/conformance/cases/provider.js +41 -0
- package/dist/conformance/cli.js +72 -11
- package/dist/conformance/daytona.d.ts +9 -20
- package/dist/conformance/daytona.js +12 -21
- package/dist/conformance/e2b.js +9 -4
- package/dist/conformance/exec-stream.d.ts +52 -0
- package/dist/conformance/exec-stream.js +493 -0
- package/dist/conformance/kernel.js +2 -2
- package/dist/conformance/modal.js +1 -1
- package/dist/conformance/orgo.js +2 -2
- package/dist/conformance/sweep.js +8 -8
- package/dist/conformance/types.d.ts +2 -2
- package/dist/create-requests.d.ts +1 -1
- package/dist/daytona.d.ts +17 -133
- package/dist/daytona.js +396 -1452
- package/dist/descriptor.d.ts +11 -4
- package/dist/descriptor.js +7 -0
- package/dist/descriptors/agent37.d.ts +3 -11
- package/dist/descriptors/agent37.js +9 -10
- package/dist/descriptors/daytona.d.ts +7 -6
- package/dist/descriptors/daytona.js +14 -7
- package/dist/descriptors/docker.d.ts +13 -1
- package/dist/descriptors/docker.js +3 -1
- package/dist/descriptors/e2b.d.ts +2 -9
- package/dist/descriptors/e2b.js +8 -8
- package/dist/descriptors/index.d.ts +25 -24
- package/dist/descriptors/index.js +1 -3
- package/dist/descriptors/modal.d.ts +2 -6
- package/dist/descriptors/modal.js +8 -6
- package/dist/descriptors/orgo.js +2 -1
- package/dist/descriptors/shared.d.ts +1 -1
- package/dist/descriptors/shared.js +2 -2
- package/dist/desktop.d.ts +18 -4
- package/dist/desktop.js +89 -9
- package/dist/docker/egress-main.js +23 -15
- package/dist/docker/egress.d.ts +6 -4
- package/dist/docker/egress.js +24 -16
- package/dist/docker/inspect.d.ts +2 -2
- package/dist/docker/inspect.js +5 -5
- package/dist/docker.d.ts +6 -11
- package/dist/docker.js +13 -16
- package/dist/drift.js +4 -4
- package/dist/e2b.d.ts +22 -130
- package/dist/e2b.js +163 -243
- package/dist/host.d.ts +136 -104
- package/dist/host.js +8 -1
- package/dist/hosted/network.d.ts +23 -0
- package/dist/hosted/network.js +77 -0
- package/dist/hosted/process.d.ts +24 -8
- package/dist/hosted/process.js +80 -44
- package/dist/hosted/provider.d.ts +38 -22
- package/dist/hosted/provider.js +500 -341
- package/dist/hosted/rest.d.ts +74 -0
- package/dist/hosted/rest.js +126 -0
- package/dist/hosted/scripts.d.ts +21 -3
- package/dist/hosted/scripts.js +76 -14
- package/dist/hosted/ssh-exec.d.ts +99 -0
- package/dist/hosted/ssh-exec.js +464 -0
- package/dist/hosted/values.d.ts +26 -0
- package/dist/hosted/values.js +63 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/isolation.d.ts +0 -2
- package/dist/isolation.js +3 -4
- package/dist/kernel.d.ts +0 -6
- package/dist/kernel.js +1 -5
- package/dist/kinds.d.ts +3 -1
- package/dist/local-chrome.d.ts +0 -6
- package/dist/local-chrome.js +1 -5
- package/dist/modal.d.ts +15 -86
- package/dist/modal.js +67 -185
- package/dist/mount-archil.d.ts +13 -8
- package/dist/mount-archil.js +27 -17
- package/dist/mount.d.ts +10 -4
- package/dist/mount.js +8 -4
- package/dist/orgo.d.ts +0 -9
- package/dist/orgo.js +8 -13
- package/dist/phone-harness.d.ts +0 -6
- package/dist/phone-harness.js +0 -4
- package/dist/protocol.d.ts +4 -1
- package/dist/protocol.js +1 -0
- package/dist/provider.d.ts +2 -2
- package/dist/providers.d.ts +15 -13
- package/dist/screen-watch.js +34 -6
- package/dist/surface/api.d.ts +14 -11
- package/dist/surface/core.d.ts +23 -5
- package/dist/surface/core.js +105 -15
- package/dist/surface/index.d.ts +1 -1
- package/dist/surface/index.js +1 -1
- package/dist/surface/outline.d.ts +2 -0
- package/dist/surface/outline.js +2 -1
- package/dist/surface/script.d.ts +4 -0
- package/dist/surface/script.js +11 -3
- package/dist/ui-engine.js +19 -3
- package/package.json +2 -3
- package/box/build-agent37.mjs +0 -177
- package/dist/conformance/daytona-sweep.d.ts +0 -18
- package/dist/conformance/daytona-sweep.js +0 -126
package/dist/desktop.js
CHANGED
|
@@ -1,14 +1,61 @@
|
|
|
1
1
|
// A desktop on an X server computerd starts itself: the provider gives init DISPLAY, then starts the X server through
|
|
2
2
|
// the daemon with process.start, as any program, so the server is in init's process table and ends with the computer.
|
|
3
|
-
// The daemon reaches the display once it answers, and hello declares screen, input.pointer
|
|
4
|
-
// (hello re-checks the display on each call).
|
|
3
|
+
// The daemon reaches the display once it answers, and hello declares screen, input.pointer, input.keys and apps from then
|
|
4
|
+
// on (hello re-checks the display on each call). A window manager, when the desktop has one, starts next, the same way.
|
|
5
|
+
// Docker's desktops, E2B's and Agent37's start the display this way.
|
|
5
6
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
6
7
|
import { fail, ok, vendorFail } from "./result.js";
|
|
7
|
-
/** The groups a desktop declares besides exec, files and processes. */
|
|
8
|
-
export const DESKTOP_GROUPS = ["screen", "input.pointer", "input.keys"];
|
|
8
|
+
/** The groups a desktop declares besides exec, files and processes: apps is computerd's, from the desktop's .desktop files. */
|
|
9
|
+
export const DESKTOP_GROUPS = ["screen", "input.pointer", "input.keys", "apps"];
|
|
10
|
+
/**
|
|
11
|
+
* The session bus the window manager reads its settings over: dbus's own session config, but listening on an abstract
|
|
12
|
+
* name, which only a program in the bus's own network namespace reaches. dbus's unix:tmpdir is a socket under /tmp
|
|
13
|
+
* with dbus 1.16 (Agent37's box), which every program of the user reaches.
|
|
14
|
+
*/
|
|
15
|
+
const WINDOW_MANAGER_BUS = `<busconfig>
|
|
16
|
+
<type>session</type>
|
|
17
|
+
<keep_umask/>
|
|
18
|
+
<listen>unix:abstract=/agentrun/window-manager</listen>
|
|
19
|
+
<auth>EXTERNAL</auth>
|
|
20
|
+
<standard_session_servicedirs/>
|
|
21
|
+
<policy context="default">
|
|
22
|
+
<allow send_destination="*" eavesdrop="true"/>
|
|
23
|
+
<allow eavesdrop="true"/>
|
|
24
|
+
<allow own="*"/>
|
|
25
|
+
</policy>
|
|
26
|
+
</busconfig>`;
|
|
27
|
+
/**
|
|
28
|
+
* The window manager a host's desktops run where its facts say so (HostFacts.windowManager: E2B's and Agent37's), once
|
|
29
|
+
* the display answers: it frames, stacks and focuses the windows apps.launch opens. xfwm4, which both images have, with
|
|
30
|
+
* no compositor and no session manager. It reads its settings from xfconfd over a session bus, and exits at once
|
|
31
|
+
* without one ("Xfconf could not be initialized"). So it runs in a session bus of its own (dbus-run-session, WINDOW_MANAGER_BUS, written to a file of
|
|
32
|
+
* its own under /tmp), in a user namespace (the same uid) and a network namespace of its own: a program of the
|
|
33
|
+
* computer's user reaches no socket of that bus, unless it joins those namespaces (nsenter), as the same uid may
|
|
34
|
+
* ptrace xfwm4. xfwm4 reaches the display as any program does, by its path. First, xsetroot paints the screen behind
|
|
35
|
+
* every window one slate colour, so a desktop with no window open is not a black screen a person reads as broken; a
|
|
36
|
+
* paint that fails starts xfwm4 all the same.
|
|
37
|
+
*/
|
|
38
|
+
export const WINDOW_MANAGER = [
|
|
39
|
+
"unshare",
|
|
40
|
+
"--user",
|
|
41
|
+
"--map-current-user",
|
|
42
|
+
"--net",
|
|
43
|
+
"--",
|
|
44
|
+
"sh",
|
|
45
|
+
"-c",
|
|
46
|
+
'xsetroot -solid "#3b4b5c"; bus=$(mktemp) && printf "%s" "$1" > "$bus" && exec dbus-run-session --config-file="$bus" -- xfwm4 --compositor=off --sm-client-disable',
|
|
47
|
+
"sh",
|
|
48
|
+
WINDOW_MANAGER_BUS,
|
|
49
|
+
];
|
|
50
|
+
/** WINDOW_MANAGER as create's errors name it: what runs, without the shell line and the bus's config. */
|
|
51
|
+
const WINDOW_MANAGER_WORDS = "unshare --user --map-current-user --net -- dbus-run-session -- xfwm4 --compositor=off --sm-client-disable";
|
|
9
52
|
const DISPLAY = /^:\d{1,5}(\.\d{1,5})?$/;
|
|
10
53
|
/** How often create asks the daemon whether the display is up yet. */
|
|
11
54
|
const DISPLAY_POLL_MS = 100;
|
|
55
|
+
/** How long create watches a window manager it started: one that ends within it (it could not take the display) fails create. */
|
|
56
|
+
const WM_SETTLE_MS = 1_000;
|
|
57
|
+
/** The longest create gives a window manager's start and that watch, apart from the display's own timeoutMs. */
|
|
58
|
+
const WM_BOUND_MS = 15_000;
|
|
12
59
|
/** The longest a Node timer or AbortSignal.timeout holds. */
|
|
13
60
|
const MAX_TIMER_MS = 2 ** 31 - 1;
|
|
14
61
|
/** The desktop options with their defaults, or a throw in words. */
|
|
@@ -16,9 +63,9 @@ export function desktopOf({ display = ":0", server, timeoutMs = 30_000 }) {
|
|
|
16
63
|
if (typeof display !== "string" || !DISPLAY.test(display))
|
|
17
64
|
throw new Error(`the desktop's display ${JSON.stringify(display)} must be a local X display, such as :0`);
|
|
18
65
|
const argv = server ?? ["Xvfb", display, "-screen", "0", "1280x800x24", "-nolisten", "tcp"];
|
|
19
|
-
|
|
66
|
+
const program = (list) => Array.isArray(list) && list.length > 0 && list.every((arg) => typeof arg === "string" && !arg.includes("\0")) && list[0] !== "";
|
|
67
|
+
if (!program(argv))
|
|
20
68
|
throw new Error("the desktop's server must be a program and its arguments, such as [\"Xvfb\", \":0\"]");
|
|
21
|
-
}
|
|
22
69
|
// AbortSignal.timeout and Node's timers hold at most 2^31 - 1 ms (a longer one throws or fires at once), so a longer
|
|
23
70
|
// bound is refused here, before any computer exists, not in create after the computer is made.
|
|
24
71
|
if (!Number.isSafeInteger(timeoutMs) || timeoutMs <= 0 || timeoutMs > MAX_TIMER_MS) {
|
|
@@ -29,9 +76,10 @@ export function desktopOf({ display = ":0", server, timeoutMs = 30_000 }) {
|
|
|
29
76
|
/**
|
|
30
77
|
* Starts the desktop's X server through the daemon (process.start) and waits until hello declares the display: the
|
|
31
78
|
* server ending first, or the bound passing, is a failure in words, with the server's own last words, as the vendor's
|
|
32
|
-
* (code vendor, vendor the provider's id). version is the client's, sent with each hello.
|
|
79
|
+
* (code vendor, vendor the provider's id). version is the client's, sent with each hello. windowManager: the host's
|
|
80
|
+
* desktops run WINDOW_MANAGER (HostFacts.windowManager), started once the display answers.
|
|
33
81
|
*/
|
|
34
|
-
export async function startDisplay(client, desktop, { version, vendor, signal }) {
|
|
82
|
+
export async function startDisplay(client, desktop, { version, vendor, signal, windowManager = false }) {
|
|
35
83
|
const server = desktop.server.join(" ");
|
|
36
84
|
// Every call takes a signal that ends at the bound, so a hello the X connection setup holds, or a daemon that stops
|
|
37
85
|
// answering, cannot outwait it. A call that failed because the bound passed is the timeout; the caller's own abort
|
|
@@ -49,7 +97,7 @@ export async function startDisplay(client, desktop, { version, vendor, signal })
|
|
|
49
97
|
if (!hello.ok)
|
|
50
98
|
return timedOut() ? late() : hello;
|
|
51
99
|
if (Array.isArray(hello.value.groups) && hello.value.groups.includes("screen"))
|
|
52
|
-
return ok(undefined);
|
|
100
|
+
return windowManager ? await startWindowManager(client, desktop, vendor, signal) : ok(undefined);
|
|
53
101
|
const waited = await client.call("process.wait", { id, timeoutMs: 0 }, { signal: either });
|
|
54
102
|
if (waited.ok && !waited.value.running) {
|
|
55
103
|
const read = await client.call("process.read", { id, stream: "stderr", offset: 0 }, { signal: either });
|
|
@@ -66,3 +114,35 @@ export async function startDisplay(client, desktop, { version, vendor, signal })
|
|
|
66
114
|
return fail("aborted", "create was aborted while the display came up");
|
|
67
115
|
}
|
|
68
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Starts WINDOW_MANAGER on the display that answers. A manager that cannot start, or ends
|
|
119
|
+
* within WM_SETTLE_MS (xfwm4 with no session bus, or no display it may open), fails create with its last words. It has
|
|
120
|
+
* its own bound, WM_BOUND_MS, not what is left of the display's: a display that came up late still gets its manager's
|
|
121
|
+
* full second. The caller's abort still ends it.
|
|
122
|
+
*/
|
|
123
|
+
async function startWindowManager(client, desktop, vendor, caller) {
|
|
124
|
+
const manager = WINDOW_MANAGER_WORDS;
|
|
125
|
+
const bound = AbortSignal.timeout(WM_BOUND_MS);
|
|
126
|
+
const signal = caller ? AbortSignal.any([caller, bound]) : bound;
|
|
127
|
+
const stopped = (code, message) => caller?.aborted
|
|
128
|
+
? fail("aborted", "create was aborted while the window manager started")
|
|
129
|
+
: bound.aborted
|
|
130
|
+
? fail("timeout", `the window manager (${manager}) did not start on ${desktop.display} within ${WM_BOUND_MS / 1000} s`)
|
|
131
|
+
: fail(code, message);
|
|
132
|
+
// NO_AT_BRIDGE: GTK (xfwm4's toolkit) asks its session bus for no accessibility bus. On E2B Desktop, which has
|
|
133
|
+
// at-spi2-core, that bus is an at-spi-bus-launcher and a socket of the user's under its home (~/.cache/at-spi/bus_0).
|
|
134
|
+
const env = { DISPLAY: desktop.display, NO_AT_BRIDGE: "1" };
|
|
135
|
+
const started = await client.call("process.start", { argv: [...WINDOW_MANAGER], env }, { signal });
|
|
136
|
+
if (!started.ok)
|
|
137
|
+
return stopped(started.error.code, `the window manager (${manager}) did not start on ${desktop.display}: ${started.error.message}`);
|
|
138
|
+
const { id } = started.value;
|
|
139
|
+
const waited = await client.call("process.wait", { id, timeoutMs: WM_SETTLE_MS }, { signal });
|
|
140
|
+
if (!waited.ok)
|
|
141
|
+
return stopped(waited.error.code, `the window manager (${manager}) could not be waited on: ${waited.error.message}`);
|
|
142
|
+
if (waited.value.running)
|
|
143
|
+
return ok(undefined);
|
|
144
|
+
const read = await client.call("process.read", { id, stream: "stderr", offset: 0 }, { signal });
|
|
145
|
+
const words = read.ok ? Buffer.from(read.value.data, "base64").toString("utf8").trim().split("\n").slice(-5).join("; ") : "";
|
|
146
|
+
const how = waited.value.signal ? `signal ${waited.value.signal}` : `exit code ${waited.value.exitCode}`;
|
|
147
|
+
return vendorFail(vendor, `the window manager (${manager}) ended with ${how} within ${WM_SETTLE_MS / 1000} s of starting on ${desktop.display}${words ? `: ${words}` : ""}`);
|
|
148
|
+
}
|
|
@@ -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
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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));
|
package/dist/docker/egress.d.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
|
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;
|
package/dist/docker/egress.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
// A Docker computer's way out to the network when its spec asks for an allowlist ({ allow:
|
|
2
|
-
// computer stays `--network none`, and its own egress proxy runs in a second container the
|
|
3
|
-
// and removes with it.
|
|
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:
|
|
101
|
+
return { problem: `${owner} holds at most ${MAX_ALLOW} names, not ${names}` };
|
|
101
102
|
if (cidrs > MAX_ALLOW)
|
|
102
|
-
return { problem:
|
|
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
|
|
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
|
|
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 (
|
|
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];
|
package/dist/docker/inspect.d.ts
CHANGED
|
@@ -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
|
|
132
|
-
*
|
|
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
|
*/
|
package/dist/docker/inspect.js
CHANGED
|
@@ -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
|
|
115
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
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
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import { type DesktopOptions } from "./desktop.js";
|
|
2
2
|
import { type DockerHost } from "./docker/inspect.js";
|
|
3
3
|
import { type EnsureImageOptions, type ImageSource } from "./docker/image.js";
|
|
4
|
-
import type { KindCapabilities } from "./kinds.js";
|
|
5
|
-
import { type MountKind } from "./mount.js";
|
|
6
4
|
import { type AttachedComputer, type CallContext, type CreateContext, type ComputerCapabilities, type ComputerConnection, type ComputerInfo, type ComputerProvider, type ComputerRef, type ComputerSpec, type NetworkPolicy, type NetworkSpec, type Refusal, type ReleaseHow } from "./provider.js";
|
|
7
5
|
import { type Result } from "./result.js";
|
|
8
6
|
import { type ScreenWatch, type ScreenWatchHandlers, type WatchOptions } from "./screen-watch.js";
|
|
9
7
|
/**
|
|
10
|
-
* A Docker desktop: an image with an X server (test/fixtures/desktop/Dockerfile is the smallest,
|
|
8
|
+
* A Docker desktop: an image with an X server (test/fixtures/desktop/Dockerfile is the smallest, Alpine and Xvfb).
|
|
11
9
|
* computerd stays the first process and starts nothing of its own: create gives it DISPLAY, then starts the X server
|
|
12
10
|
* through it with process.start (startDisplay in ./desktop.ts).
|
|
13
11
|
*/
|
|
14
12
|
export type DockerDesktopOptions = DesktopOptions;
|
|
15
|
-
/** 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). */
|
|
16
14
|
export interface DockerEgressOptions {
|
|
17
15
|
/** The proxy container's image: one with Node 22.19 or later as `node`. Default EGRESS_IMAGE, pinned by digest. */
|
|
18
16
|
image?: string;
|
|
@@ -22,7 +20,7 @@ export interface DockerEgressOptions {
|
|
|
22
20
|
readyMs?: number;
|
|
23
21
|
/**
|
|
24
22
|
* The Docker host's own addresses, each an IP address, which the proxy refuses as the host's (this-host), beside this
|
|
25
|
-
* 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
|
|
26
24
|
* in a container (containerSigns), or its docker CLI talks to a daemon that is not a local unix socket.
|
|
27
25
|
*/
|
|
28
26
|
hostAddresses?: string[];
|
|
@@ -42,7 +40,7 @@ export interface DockerProviderOptions {
|
|
|
42
40
|
* under a directory another user may write. Default ~/.cache/agentrun-computer; the provider reads no
|
|
43
41
|
* environment, XDG_CACHE_HOME included. */
|
|
44
42
|
daemonCache?: string;
|
|
45
|
-
/** 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. */
|
|
46
44
|
egress?: DockerEgressOptions;
|
|
47
45
|
/** Makes every computer a desktop (kind desktop): its image must have the X server. */
|
|
48
46
|
desktop?: DockerDesktopOptions;
|
|
@@ -68,10 +66,6 @@ export interface DockerProviderOptions {
|
|
|
68
66
|
root: string;
|
|
69
67
|
};
|
|
70
68
|
}
|
|
71
|
-
/** The mount kinds a Docker computer takes, as capabilities().mount declares them: a bind of a folder on this host. */
|
|
72
|
-
export declare const MOUNT: readonly MountKind[];
|
|
73
|
-
/** The machine kind and groups of each configuration (its descriptor's): a linux computer, and a desktop. */
|
|
74
|
-
export declare const CAPABILITIES: readonly KindCapabilities[];
|
|
75
69
|
/** What create() takes: the provider's options, the daemon optional. */
|
|
76
70
|
export interface DockerCreateOptions extends Partial<DockerProviderOptions> {
|
|
77
71
|
/** The longest `docker version` may take, when create asks Docker its architecture; default 30 s. */
|
|
@@ -112,7 +106,8 @@ export declare class DockerProvider implements ComputerProvider {
|
|
|
112
106
|
/** The provider contract's prepareImage (its descriptor declares it): image(), its recipe built or its image pulled. */
|
|
113
107
|
prepareImage(context?: CallContext & Pick<EnsureImageOptions, "onWait">): Promise<Result<string>>;
|
|
114
108
|
/** The spec's refusals, and the host's once create, attach or host() has read it: its problems, a bind or an
|
|
115
|
-
* allowlist on a host that remaps user ids
|
|
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. */
|
|
116
111
|
check(spec: ComputerSpec): Refusal[];
|
|
117
112
|
/**
|
|
118
113
|
* Makes a computer, once per request (provider.md, Idempotent create): context.requestId names the container
|
package/dist/docker.js
CHANGED
|
@@ -25,10 +25,6 @@ import { daemonWatch } from "./screen-watch.js";
|
|
|
25
25
|
import { countTested } from "./test-connection.js";
|
|
26
26
|
/** This module's failures: one with code vendor names Docker. */
|
|
27
27
|
const fail = failFor("docker");
|
|
28
|
-
/** The mount kinds a Docker computer takes, as capabilities().mount declares them: a bind of a folder on this host. */
|
|
29
|
-
export const MOUNT = DOCKER.mounts;
|
|
30
|
-
/** The machine kind and groups of each configuration (its descriptor's): a linux computer, and a desktop. */
|
|
31
|
-
export const CAPABILITIES = DOCKER.capabilities;
|
|
32
28
|
/**
|
|
33
29
|
* Docker's architecture as `docker version` reports it (amd64, arm64), within timeoutMs, or an error in words. The docker
|
|
34
30
|
* CLI runs with this process's environment, as every call of the provider does, so it asks the Docker the provider uses.
|
|
@@ -222,7 +218,7 @@ export class DockerProvider {
|
|
|
222
218
|
user: ["root", "uid"],
|
|
223
219
|
release: ["stop", "delete"],
|
|
224
220
|
stopDeletes: false,
|
|
225
|
-
mount: [...
|
|
221
|
+
mount: [...DOCKER.mounts],
|
|
226
222
|
};
|
|
227
223
|
}
|
|
228
224
|
/**
|
|
@@ -237,12 +233,13 @@ export class DockerProvider {
|
|
|
237
233
|
return this.image(context);
|
|
238
234
|
}
|
|
239
235
|
/** The spec's refusals, and the host's once create, attach or host() has read it: its problems, a bind or an
|
|
240
|
-
* allowlist on a host that remaps user ids
|
|
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. */
|
|
241
238
|
check(spec) {
|
|
242
239
|
const host = this.#host;
|
|
243
240
|
const remapped = host?.remap !== undefined && spec?.mount?.kind === "bind" ? [{ field: "mount", message: remapWords(host.remap, String(spec.mount.path)) }] : [];
|
|
244
241
|
const allowed = [];
|
|
245
|
-
if (isAllow(spec?.network)) {
|
|
242
|
+
if (spec?.network === "open" || isAllow(spec?.network)) {
|
|
246
243
|
if (host?.remap !== undefined)
|
|
247
244
|
allowed.push({ field: "network", message: remapAllowWords(host.remap) });
|
|
248
245
|
if (typeof this.#elsewhere === "string" && this.#egress.hostAddresses === undefined)
|
|
@@ -443,8 +440,8 @@ export class DockerProvider {
|
|
|
443
440
|
if (folder !== undefined && !folder.ok)
|
|
444
441
|
return folder;
|
|
445
442
|
const folderMount = folder?.value;
|
|
446
|
-
//
|
|
447
|
-
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;
|
|
448
445
|
if (allow !== undefined) {
|
|
449
446
|
// With the volume option, the code is staged below the volume's root, where the Docker daemon can mount it from:
|
|
450
447
|
// the copy (0755 directories, 0644 files) is what the computer's user must read.
|
|
@@ -507,7 +504,7 @@ export class DockerProvider {
|
|
|
507
504
|
const lifetimeFrom = Date.now();
|
|
508
505
|
const deadline = new Date(lifetimeFrom + runLifetimeMs(spec)).toISOString();
|
|
509
506
|
if (allow !== undefined) {
|
|
510
|
-
// The proxy first, ready before the computer exists: a computer never runs with
|
|
507
|
+
// The proxy first, ready before the computer exists: a computer never runs with a network it cannot reach.
|
|
511
508
|
const started = await this.#startEgress(name, user, deadline, allow, spec.labels ?? {}, attempt, signal);
|
|
512
509
|
if (!started.ok) {
|
|
513
510
|
// Another create of this request, in another process, runs its proxy: what it makes is the request's.
|
|
@@ -533,8 +530,8 @@ export class DockerProvider {
|
|
|
533
530
|
args.push("--cap-drop", "ALL", "--security-opt", "no-new-privileges", "--pids-limit", String(spec.pids ?? DEFAULT_PIDS));
|
|
534
531
|
// Not the daemon's defaults, which a host may set to shareable IPC or, on cgroup v1, the host's cgroup namespace.
|
|
535
532
|
args.push("--ipc", "private", "--cgroupns", "private");
|
|
536
|
-
//
|
|
537
|
-
args.push("--network",
|
|
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");
|
|
538
535
|
args.push("--cpu-period", String(CPU_PERIOD_US), "--cpu-quota", String(Math.round((spec.cpus ?? DEFAULT_CPUS) * CPU_PERIOD_US)));
|
|
539
536
|
// Memory and swap together are the memory: swap never adds to it.
|
|
540
537
|
const memory = `${memoryMb}m`;
|
|
@@ -549,8 +546,8 @@ export class DockerProvider {
|
|
|
549
546
|
if (allow !== undefined)
|
|
550
547
|
args.push("--mount", `type=volume,src=${egressNameOf(name)},dst=${EGRESS_MOUNT},readonly`, "--pull", "never");
|
|
551
548
|
args.push("--workdir", spec.workdir ?? WORK);
|
|
552
|
-
// PID 1 ends the computer at the deadline the label holds, so a computer the janitor misses still stops. With
|
|
553
|
-
// 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.
|
|
554
551
|
args.push(spec.image, "init", "--deadline", deadline, ...(allow === undefined ? [] : [RELAY_FLAG, EGRESS_SOCKET]));
|
|
555
552
|
const started = await this.#run(args, signal);
|
|
556
553
|
const ranMs = Date.now() - lifetimeFrom;
|
|
@@ -1463,7 +1460,7 @@ function egressOptionsOf({ image = EGRESS_IMAGE, hint, readyMs = EGRESS_READY_MS
|
|
|
1463
1460
|
* own addresses as this-host only when it knows them, and here it does not.
|
|
1464
1461
|
*/
|
|
1465
1462
|
function elsewhereWords(why) {
|
|
1466
|
-
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
|
+
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`;
|
|
1467
1464
|
}
|
|
1468
1465
|
/** Whether a spec's network is an allowlist. */
|
|
1469
1466
|
const isAllow = (network) => typeof network === "object" && network !== null && "allow" in network;
|
|
@@ -1474,7 +1471,7 @@ const isAllow = (network) => typeof network === "object" && network !== null &&
|
|
|
1474
1471
|
*/
|
|
1475
1472
|
function remapAllowWords(remap) {
|
|
1476
1473
|
return (`this Docker host remaps user ids (${remap === "userns" ? "userns-remap" : "rootless Docker"}), so the egress volume and the proxy's code are ` +
|
|
1477
|
-
"owned by host ids the computer's user does not map to, and the provider cannot give it an allowlist: ask for network none
|
|
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, " +
|
|
1478
1475
|
"or use a Docker host that does not remap ids");
|
|
1479
1476
|
}
|
|
1480
1477
|
/**
|
package/dist/drift.js
CHANGED
|
@@ -64,10 +64,10 @@ export function probeNotes(probe, network) {
|
|
|
64
64
|
/** Every way hello differs from what the provider expects. */
|
|
65
65
|
export function helloDrift(hello, expected) {
|
|
66
66
|
const found = [];
|
|
67
|
-
//
|
|
68
|
-
//
|
|
69
|
-
if (hello?.protocol !==
|
|
70
|
-
found.push(`hello: the daemon speaks protocol ${text(hello
|
|
67
|
+
// Exact match (spec/computer/README.md, "Versioning"): the provider ships its daemon, so another protocol version or
|
|
68
|
+
// daemon version, older or newer, is another wire. A hello that names no protocol is refused too.
|
|
69
|
+
if (hello?.protocol !== PROTOCOL_VERSION) {
|
|
70
|
+
found.push(`hello: the daemon speaks protocol ${text(hello?.protocol)}, expected exactly ${PROTOCOL_VERSION}`);
|
|
71
71
|
}
|
|
72
72
|
if (hello?.version !== expected.version)
|
|
73
73
|
found.push(`hello: the daemon reports version ${text(hello?.version)}, expected ${expected.version}`);
|