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

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 (93) hide show
  1. package/README.md +259 -203
  2. package/box/Dockerfile +18 -1
  3. package/box/README.md +13 -0
  4. package/box/build-agent37.mjs +8 -27
  5. package/box/build-daytona.py +2 -2
  6. package/box/build-e2b.mjs +41 -18
  7. package/box/recipe.mjs +43 -0
  8. package/dist/agent37-ssh.d.ts +89 -0
  9. package/dist/agent37-ssh.js +445 -0
  10. package/dist/agent37.d.ts +2 -63
  11. package/dist/agent37.js +104 -461
  12. package/dist/browserbase.d.ts +0 -6
  13. package/dist/browserbase.js +1 -5
  14. package/dist/client.d.ts +12 -3
  15. package/dist/client.js +39 -4
  16. package/dist/computerd-linux-amd64 +0 -0
  17. package/dist/computerd-linux-arm64 +0 -0
  18. package/dist/computerd.json +4 -0
  19. package/dist/conformance/cases/apps.d.ts +6 -0
  20. package/dist/conformance/cases/apps.js +18 -5
  21. package/dist/conformance/cases/isolation.d.ts +7 -5
  22. package/dist/conformance/cases/isolation.js +44 -14
  23. package/dist/conformance/cases/mount.js +1 -1
  24. package/dist/conformance/cli.js +66 -6
  25. package/dist/conformance/daytona.d.ts +9 -20
  26. package/dist/conformance/daytona.js +12 -21
  27. package/dist/conformance/exec-stream.d.ts +45 -0
  28. package/dist/conformance/exec-stream.js +486 -0
  29. package/dist/conformance/sweep.js +8 -8
  30. package/dist/conformance/types.d.ts +2 -2
  31. package/dist/create-requests.d.ts +1 -1
  32. package/dist/daytona.d.ts +20 -131
  33. package/dist/daytona.js +405 -1450
  34. package/dist/descriptor.d.ts +6 -1
  35. package/dist/descriptor.js +7 -0
  36. package/dist/descriptors/agent37.d.ts +1 -1
  37. package/dist/descriptors/agent37.js +1 -1
  38. package/dist/descriptors/daytona.d.ts +6 -5
  39. package/dist/descriptors/daytona.js +9 -5
  40. package/dist/descriptors/index.d.ts +4 -5
  41. package/dist/descriptors/shared.d.ts +1 -1
  42. package/dist/descriptors/shared.js +2 -2
  43. package/dist/desktop.d.ts +18 -4
  44. package/dist/desktop.js +89 -9
  45. package/dist/docker.d.ts +0 -6
  46. package/dist/docker.js +1 -5
  47. package/dist/drift.js +4 -4
  48. package/dist/e2b.d.ts +10 -128
  49. package/dist/e2b.js +130 -233
  50. package/dist/host.d.ts +106 -87
  51. package/dist/host.js +8 -1
  52. package/dist/hosted/process.d.ts +22 -8
  53. package/dist/hosted/process.js +75 -44
  54. package/dist/hosted/provider.d.ts +35 -21
  55. package/dist/hosted/provider.js +312 -261
  56. package/dist/hosted/rest.d.ts +66 -0
  57. package/dist/hosted/rest.js +121 -0
  58. package/dist/hosted/scripts.d.ts +8 -2
  59. package/dist/hosted/scripts.js +27 -2
  60. package/dist/hosted/values.d.ts +5 -0
  61. package/dist/hosted/values.js +8 -0
  62. package/dist/index.d.ts +1 -1
  63. package/dist/index.js +1 -1
  64. package/dist/kernel.d.ts +0 -6
  65. package/dist/kernel.js +1 -5
  66. package/dist/kinds.d.ts +3 -1
  67. package/dist/local-chrome.d.ts +0 -6
  68. package/dist/local-chrome.js +1 -5
  69. package/dist/modal.d.ts +7 -84
  70. package/dist/modal.js +50 -174
  71. package/dist/mount-archil.d.ts +8 -4
  72. package/dist/mount-archil.js +22 -11
  73. package/dist/mount.d.ts +10 -4
  74. package/dist/mount.js +8 -4
  75. package/dist/orgo.d.ts +0 -9
  76. package/dist/orgo.js +2 -9
  77. package/dist/phone-harness.d.ts +0 -6
  78. package/dist/phone-harness.js +0 -4
  79. package/dist/protocol.d.ts +4 -1
  80. package/dist/protocol.js +1 -0
  81. package/dist/provider.d.ts +2 -2
  82. package/dist/providers.d.ts +11 -12
  83. package/dist/screen-watch.js +34 -6
  84. package/dist/surface/api.d.ts +14 -2
  85. package/dist/surface/core.d.ts +16 -3
  86. package/dist/surface/core.js +95 -13
  87. package/dist/surface/outline.d.ts +2 -0
  88. package/dist/surface/outline.js +2 -1
  89. package/dist/surface/script.js +2 -0
  90. package/dist/ui-engine.js +19 -3
  91. package/package.json +2 -3
  92. package/dist/conformance/daytona-sweep.d.ts +0 -18
  93. package/dist/conformance/daytona-sweep.js +0 -126
@@ -1,5 +1,5 @@
1
1
  import type { ComputerSettingKind, KindCapabilities } from "./kinds.js";
2
- import type { MountKind } from "./mount.js";
2
+ import type { MountKind, Unmounted } from "./mount.js";
3
3
  import type { NetworkForm } from "./provider.js";
4
4
  import type { ProviderModule } from "./providers.js";
5
5
  /** One key a provider takes in Settings: its serve-side name, the create() option it fills, and whether it is needed. */
@@ -60,6 +60,11 @@ export interface ProviderDescriptor<Module extends ProviderModule = ProviderModu
60
60
  readonly metered: boolean;
61
61
  /** The mount kinds its computers take, as its providers' capabilities().mount declare them; [] for none. */
62
62
  readonly mounts: readonly MountKind[];
63
+ /**
64
+ * Mount kinds its computers don't take though a caller would ask for them, each with why in one sentence: check()
65
+ * refuses such a mount in these words, and serve says them where the run's folder can't be had (Daytona's archil).
66
+ */
67
+ readonly unmounted?: Unmounted;
63
68
  /**
64
69
  * The network forms its computers make, as its providers' capabilities().network declare them: ["none"], a remote
65
70
  * computer whose programs run in a network of their own; ["open"], the vendor's own network, which no allowlist of
@@ -26,6 +26,13 @@ export function descriptorProblems(value) {
26
26
  problems.push("load is not a function that imports the provider module");
27
27
  if (!Array.isArray(d.mounts) || d.mounts.some((kind) => kind !== "bind" && kind !== "archil"))
28
28
  problems.push("mounts is not a list of mount kinds (bind, archil)");
29
+ if (d.unmounted !== undefined) {
30
+ const entries = typeof d.unmounted === "object" && d.unmounted !== null && !Array.isArray(d.unmounted) ? Object.entries(d.unmounted) : undefined;
31
+ if (entries === undefined || entries.some(([kind, why]) => (kind !== "bind" && kind !== "archil") || typeof why !== "string" || why.trim() === ""))
32
+ problems.push("unmounted maps mount kinds (bind, archil) to why, in words");
33
+ else if (Array.isArray(d.mounts) && entries.some(([kind]) => d.mounts?.includes(kind)))
34
+ problems.push("unmounted names a mount kind that mounts declares");
35
+ }
29
36
  if (!Array.isArray(d.network) || d.network.length === 0 || d.network.some((form) => form !== "none" && form !== "open" && form !== "allow"))
30
37
  problems.push("network is not a list of the network forms its computers make (none, open, allow)");
31
38
  if (!Array.isArray(d.capabilities) || d.capabilities.length === 0)
@@ -1,7 +1,7 @@
1
1
  /** Agent37's plain Linux template: a sandbox when its setting names no image. */
2
2
  export declare const AGENT37_BASE_TEMPLATE = "agent37-base";
3
3
  /**
4
- * Our box image (box/Dockerfile and Xvfb) as a template of the key's own workspace, which box/build-agent37.mjs builds
4
+ * Our box image (box/Dockerfile, its desktop included) as a template of the key's own workspace, which box/build-agent37.mjs builds
5
5
  * and publishes under this one name: a desktop when its setting names no image.
6
6
  */
7
7
  export declare const AGENT37_BOX_TEMPLATE = "agentrun-box";
@@ -5,7 +5,7 @@ import { LINUX_DESKTOP, SANDBOX } from "./shared.js";
5
5
  /** Agent37's plain Linux template: a sandbox when its setting names no image. */
6
6
  export const AGENT37_BASE_TEMPLATE = "agent37-base";
7
7
  /**
8
- * Our box image (box/Dockerfile and Xvfb) as a template of the key's own workspace, which box/build-agent37.mjs builds
8
+ * Our box image (box/Dockerfile, its desktop included) as a template of the key's own workspace, which box/build-agent37.mjs builds
9
9
  * and publishes under this one name: a desktop when its setting names no image.
10
10
  */
11
11
  export const AGENT37_BOX_TEMPLATE = "agentrun-box";
@@ -1,4 +1,6 @@
1
1
  import type { GpuCapability } from "../provider.js";
2
+ /** Why a Daytona computer takes no Archil mount: check() refuses one in these words. */
3
+ export declare const DAYTONA_NO_ARCHIL = "Archil mounts don't work on Daytona yet: Archil's client hangs on its sandboxes";
2
4
  /** The image a Daytona computer starts from when its spec names "default": Daytona's own default snapshot. */
3
5
  export declare const DAYTONA_DEFAULT_SNAPSHOT = "default";
4
6
  /** The one region Daytona runs a GPU sandbox in, whatever the provider's target. */
@@ -56,13 +58,12 @@ export declare const DAYTONA: {
56
58
  readonly name: "DAYTONA_TARGET";
57
59
  readonly option: "target";
58
60
  readonly required: false;
59
- }, {
60
- readonly name: "DAYTONA_ARCHIL_EGRESS";
61
- readonly option: "archilEgress";
62
- readonly required: false;
63
61
  }];
64
62
  readonly metered: true;
65
- readonly mounts: readonly ["archil"];
63
+ readonly mounts: readonly [];
64
+ readonly unmounted: {
65
+ readonly archil: "Archil mounts don't work on Daytona yet: Archil's client hangs on its sandboxes";
66
+ };
66
67
  readonly network: readonly ["none"];
67
68
  readonly capabilities: readonly [{
68
69
  readonly gpu: Readonly<GpuCapability>;
@@ -1,6 +1,8 @@
1
- // Daytona's descriptor: a sandbox on Daytona's cloud, the run's folder on an Archil disk, with GPUs when asked.
1
+ // Daytona's descriptor: a sandbox on Daytona's cloud, with GPUs when asked; no mount of the run's folder yet.
2
2
  import { defineProvider } from "../descriptor.js";
3
3
  import { SANDBOX } from "./shared.js";
4
+ /** Why a Daytona computer takes no Archil mount: check() refuses one in these words. */
5
+ export const DAYTONA_NO_ARCHIL = "Archil mounts don't work on Daytona yet: Archil's client hangs on its sandboxes";
4
6
  /** The image a Daytona computer starts from when its spec names "default": Daytona's own default snapshot. */
5
7
  export const DAYTONA_DEFAULT_SNAPSHOT = "default";
6
8
  /** The one region Daytona runs a GPU sandbox in, whatever the provider's target. */
@@ -65,17 +67,19 @@ export const DAYTONA = defineProvider({
65
67
  { name: "DAYTONA_API_KEY", option: "apiKey", required: true },
66
68
  { name: "DAYTONA_API_URL", option: "apiUrl", required: false },
67
69
  { name: "DAYTONA_TARGET", option: "target", required: false },
68
- { name: "DAYTONA_ARCHIL_EGRESS", option: "archilEgress", required: false },
69
70
  ],
70
71
  metered: true,
71
- mounts: ["archil"],
72
+ // No mount: Archil's client (0.10.1) mounts on Daytona's container sandboxes, but nothing reads its /dev/fuse after,
73
+ // so the first statx of the folder hangs, on every kernel and mount shape tried (live, 11-14), and Daytona offered
74
+ // no linux-vm class to try instead. An Archil mount is refused in these words, before any request.
75
+ mounts: [],
76
+ unmounted: { archil: DAYTONA_NO_ARCHIL },
72
77
  // None: its programs run in a network of their own (isolation.ts OWN_NETWORK_ONLY).
73
78
  network: ["none"],
74
79
  // A linux computer, with GPUs when asked.
75
80
  capabilities: [{ ...SANDBOX, gpu: DAYTONA_GPU }],
76
81
  defaultImage: { sandbox: DAYTONA_DEFAULT_SNAPSHOT },
77
- // A Daytona computer that mounts the run's folder from Archil needs a snapshot of box/Dockerfile (build-daytona.py
78
- // builds one and prints its name): the operator names it here, and the default snapshot stands while unset.
82
+ // The operator's own snapshot for every Daytona computer, named here; the default snapshot stands while unset.
79
83
  imageEnv: "AGENTRUN_DAYTONA_SNAPSHOT",
80
84
  load: () => import("../daytona.js"),
81
85
  });
@@ -34,13 +34,12 @@ export declare const DESCRIPTORS: readonly [{
34
34
  readonly name: "DAYTONA_TARGET";
35
35
  readonly option: "target";
36
36
  readonly required: false;
37
- }, {
38
- readonly name: "DAYTONA_ARCHIL_EGRESS";
39
- readonly option: "archilEgress";
40
- readonly required: false;
41
37
  }];
42
38
  readonly metered: true;
43
- readonly mounts: readonly ["archil"];
39
+ readonly mounts: readonly [];
40
+ readonly unmounted: {
41
+ readonly archil: "Archil mounts don't work on Daytona yet: Archil's client hangs on its sandboxes";
42
+ };
44
43
  readonly network: readonly ["none"];
45
44
  readonly capabilities: readonly [{
46
45
  readonly gpu: Readonly<import("../provider.js").GpuCapability>;
@@ -1,7 +1,7 @@
1
1
  import type { KindCapabilities } from "../kinds.js";
2
2
  /** A Linux shell: exec, files and processes. */
3
3
  export declare const SANDBOX: KindCapabilities;
4
- /** A Linux desktop: a shell, and the screen, pointer and keys of an X display. */
4
+ /** A Linux desktop: a shell, the screen, pointer and keys of an X display, and its apps (its .desktop files). */
5
5
  export declare const LINUX_DESKTOP: KindCapabilities;
6
6
  /** The image every browser computer runs: its vendor's own Chromium. */
7
7
  export declare const BROWSER_IMAGE = "chromium";
@@ -1,6 +1,6 @@
1
1
  /** A Linux shell: exec, files and processes. */
2
2
  export const SANDBOX = { kind: "linux", groups: ["exec", "files", "processes"] };
3
- /** A Linux desktop: a shell, and the screen, pointer and keys of an X display. */
4
- export const LINUX_DESKTOP = { kind: "desktop", groups: ["exec", "files", "processes", "screen", "input.pointer", "input.keys"] };
3
+ /** A Linux desktop: a shell, the screen, pointer and keys of an X display, and its apps (its .desktop files). */
4
+ export const LINUX_DESKTOP = { kind: "desktop", groups: ["exec", "files", "processes", "screen", "input.pointer", "input.keys", "apps"] };
5
5
  /** The image every browser computer runs: its vendor's own Chromium. */
6
6
  export const BROWSER_IMAGE = "chromium";
package/dist/desktop.d.ts CHANGED
@@ -8,17 +8,31 @@ export interface DesktopOptions {
8
8
  /** How long create waits for the display to answer after starting the server. Default 30 s. */
9
9
  timeoutMs?: number;
10
10
  }
11
- /** The groups a desktop declares besides exec, files and processes. */
12
- export declare const DESKTOP_GROUPS: readonly ["screen", "input.pointer", "input.keys"];
11
+ /** The groups a desktop declares besides exec, files and processes: apps is computerd's, from the desktop's .desktop files. */
12
+ export declare const DESKTOP_GROUPS: readonly ["screen", "input.pointer", "input.keys", "apps"];
13
+ /**
14
+ * The window manager a host's desktops run where its facts say so (HostFacts.windowManager: E2B's and Agent37's), once
15
+ * the display answers: it frames, stacks and focuses the windows apps.launch opens. xfwm4, which both images have, with
16
+ * no compositor and no session manager. It reads its settings from xfconfd over a session bus, and exits at once
17
+ * 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
18
+ * its own under /tmp), in a user namespace (the same uid) and a network namespace of its own: a program of the
19
+ * computer's user reaches no socket of that bus, unless it joins those namespaces (nsenter), as the same uid may
20
+ * ptrace xfwm4. xfwm4 reaches the display as any program does, by its path. First, xsetroot paints the screen behind
21
+ * every window one slate colour, so a desktop with no window open is not a black screen a person reads as broken; a
22
+ * paint that fails starts xfwm4 all the same.
23
+ */
24
+ export declare const WINDOW_MANAGER: readonly string[];
13
25
  /** The desktop options with their defaults, or a throw in words. */
14
26
  export declare function desktopOf({ display, server, timeoutMs }: DesktopOptions): Required<DesktopOptions>;
15
27
  /**
16
28
  * Starts the desktop's X server through the daemon (process.start) and waits until hello declares the display: the
17
29
  * server ending first, or the bound passing, is a failure in words, with the server's own last words, as the vendor's
18
- * (code vendor, vendor the provider's id). version is the client's, sent with each hello.
30
+ * (code vendor, vendor the provider's id). version is the client's, sent with each hello. windowManager: the host's
31
+ * desktops run WINDOW_MANAGER (HostFacts.windowManager), started once the display answers.
19
32
  */
20
- export declare function startDisplay(client: ComputerClient, desktop: Required<DesktopOptions>, { version, vendor, signal }: {
33
+ export declare function startDisplay(client: ComputerClient, desktop: Required<DesktopOptions>, { version, vendor, signal, windowManager }: {
21
34
  version: string;
22
35
  vendor: string;
23
36
  signal?: AbortSignal | undefined;
37
+ windowManager?: boolean;
24
38
  }): Promise<Result<void>>;
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 and input.keys from then on
4
- // (hello re-checks the display on each call). Docker's desktops and E2B's start the display this way.
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
- if (!Array.isArray(argv) || argv.length === 0 || !argv.every((arg) => typeof arg === "string" && !arg.includes("\0")) || argv[0] === "") {
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
+ }
package/dist/docker.d.ts CHANGED
@@ -1,8 +1,6 @@
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";
@@ -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. */
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: [...MOUNT],
221
+ mount: [...DOCKER.mounts],
226
222
  };
227
223
  }
228
224
  /**
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
- // Another protocol version is another wire. A hello with none is a daemon from before the protocol was versioned,
68
- // which the version check below already refuses as another daemon.
69
- if (hello?.protocol !== undefined && hello.protocol !== PROTOCOL_VERSION) {
70
- found.push(`hello: the daemon speaks protocol ${text(hello.protocol)}, expected ${PROTOCOL_VERSION}`);
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}`);
package/dist/e2b.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  import { HostedProvider, type HostedOptions, type HostedTimeouts } from "./hosted/provider.js";
2
- import type { KindCapabilities } from "./kinds.js";
3
- import type { MountKind } from "./mount.js";
4
- /** What every SDK call is given: the key, the domain and the API URL explicitly, and debug false (index.mjs:1126-1152). */
2
+ /**
3
+ * What every SDK call is given: the key, the domain and the API URL explicitly, and debug false (index.mjs:1126-1152).
4
+ * The SDK's types below are `import type`: erased at build, so nothing loads the SDK from here and the published types
5
+ * name none of it (the package declares no dependency on e2b).
6
+ */
5
7
  export interface E2BConnectionOptions {
6
8
  apiKey: string;
7
9
  domain: string;
@@ -10,129 +12,13 @@ export interface E2BConnectionOptions {
10
12
  requestTimeoutMs?: number;
11
13
  signal?: AbortSignal;
12
14
  }
13
- /** Sandbox.create's options as the provider gives them (SandboxOpts, index.d.mts:10140-10245). */
14
- export interface E2BCreateOptions extends E2BConnectionOptions {
15
- timeoutMs: number;
16
- metadata: Record<string, string>;
17
- envs: Record<string, string>;
18
- allowInternetAccess: boolean;
19
- network: {
20
- allowPublicTraffic: boolean;
21
- };
22
- lifecycle: {
23
- onTimeout: "kill";
24
- };
25
- }
26
- /** What getInfo reports of a sandbox, as far as this provider reads it (index.mjs:5432-5465). */
27
- export interface E2BSandboxInfo {
28
- sandboxId: string;
29
- templateId: string;
30
- name?: string;
31
- metadata: Record<string, string>;
32
- allowInternetAccess?: boolean;
33
- startedAt: Date;
34
- endAt: Date;
35
- state: string;
36
- network?: {
37
- allowOut?: string[];
38
- denyOut?: string[];
39
- allowPublicTraffic?: boolean;
40
- egressProxy?: unknown;
41
- rules?: unknown;
42
- dnsServers?: unknown;
43
- };
44
- lifecycle?: {
45
- onTimeout?: string;
46
- autoResume?: boolean;
47
- };
48
- }
49
- /** One sandbox in a page of Sandbox.list (index.mjs:5820-5838). */
50
- export interface E2BListedSandbox {
51
- sandboxId: string;
52
- metadata: Record<string, string>;
53
- state: string;
54
- startedAt: Date;
55
- endAt: Date;
56
- }
57
- /** The result of a command that has ended (index.mjs:2751-2757); CommandExitError carries the same fields. */
58
- export interface E2BCommandResult {
59
- exitCode: number;
60
- stdout: string;
61
- stderr: string;
62
- }
63
- /** A background command (CommandHandle, index.mjs:2683-2810). */
64
- export interface E2BCommandHandle {
65
- readonly pid: number;
66
- readonly stderr: string;
67
- wait(): Promise<E2BCommandResult>;
68
- kill(): Promise<boolean>;
69
- disconnect(): Promise<void>;
70
- }
71
- export interface E2BRunOptions {
72
- user: "root";
73
- timeoutMs: number;
74
- requestTimeoutMs: number;
75
- signal?: AbortSignal;
76
- }
77
- /** The part of a connected Sandbox called here: commands and files (index.mjs:5917-5989). */
78
- export interface E2BSandbox {
79
- readonly sandboxId: string;
80
- readonly files: {
81
- write(path: string, data: ArrayBuffer, options: {
82
- user: "root";
83
- requestTimeoutMs: number;
84
- signal?: AbortSignal;
85
- }): Promise<unknown>;
86
- };
87
- readonly commands: {
88
- run(command: string, options: E2BRunOptions & {
89
- background?: false;
90
- }): Promise<E2BCommandResult>;
91
- run(command: string, options: E2BRunOptions & {
92
- background: true;
93
- stdin?: boolean;
94
- retainOutput?: boolean;
95
- onStdout?: (data: string) => void;
96
- onStderr?: (data: string) => void;
97
- }): Promise<E2BCommandHandle>;
98
- sendStdin(pid: number, data: Uint8Array, options: {
99
- requestTimeoutMs: number;
100
- }): Promise<void>;
101
- /** Ends a command's stdin, so it reads end of file (index.mjs:5071-5082). */
102
- closeStdin(pid: number, options: {
103
- requestTimeoutMs: number;
104
- }): Promise<void>;
105
- };
106
- }
107
- /** The paginator Sandbox.list returns (SandboxPaginator, index.mjs:5785-5849). */
108
- export interface E2BPaginator {
109
- readonly hasNext: boolean;
110
- nextItems(options: {
111
- requestTimeoutMs: number;
112
- signal?: AbortSignal;
113
- }): Promise<E2BListedSandbox[]>;
114
- }
115
- /** The statics of the SDK's Sandbox class this provider calls. The host's own, or anything with the same slice. */
116
- export interface E2BSandboxClass {
117
- create(template: string, options: E2BCreateOptions): Promise<E2BSandbox>;
118
- connect(sandboxId: string, options: E2BConnectionOptions & {
119
- timeoutMs: number;
120
- }): Promise<E2BSandbox>;
121
- getInfo(sandboxId: string, options: E2BConnectionOptions): Promise<E2BSandboxInfo>;
122
- setTimeout(sandboxId: string, timeoutMs: number, options: E2BConnectionOptions): Promise<void>;
123
- kill(sandboxId: string, options: E2BConnectionOptions): Promise<boolean>;
124
- list(options: Omit<E2BConnectionOptions, "signal"> & {
125
- query: {
126
- metadata: Record<string, string>;
127
- };
128
- limit: number;
129
- }): E2BPaginator;
130
- }
15
+ /** The SDK's Sandbox class, the host's own `e2b` package's. Held as the SDK's type inside; the published type is `object`. */
16
+ export type E2BSandboxClass = object;
131
17
  /** The E2B provider's options: the key and the SDK, then the shared adapter's (HostedOptions). */
132
- export interface E2BProviderOptions extends Omit<HostedOptions, "label" | "maxLifetimeMs"> {
18
+ export interface E2BProviderOptions extends Omit<HostedOptions, "maxLifetimeMs"> {
133
19
  /** The E2B API key. The caller passes it; this provider never reads it from the environment or puts it in a computer. */
134
20
  apiKey: string;
135
- /** The SDK's Sandbox class: the host's `e2b` package's, or anything with the same slice. */
21
+ /** The SDK's Sandbox class: the host's `e2b` package's. */
136
22
  Sandbox: E2BSandboxClass;
137
23
  /** E2B's domain: the API is https://api.<domain>. Default e2b.app. */
138
24
  domain?: string;
@@ -144,7 +30,7 @@ export interface E2BProviderOptions extends Omit<HostedOptions, "label" | "maxLi
144
30
  }
145
31
  /**
146
32
  * What create() takes: the provider's options, the SDK's Sandbox class optional (default the host's e2b package's).
147
- * Not E2BCreateOptions, which is the SDK's own Sandbox.create options.
33
+ * Not SandboxOpts, which is the SDK's own Sandbox.create options.
148
34
  */
149
35
  export interface E2BOptions extends Omit<E2BProviderOptions, "Sandbox"> {
150
36
  /** The SDK's Sandbox class; imported from the host's e2b package by default. */
@@ -164,10 +50,6 @@ export declare function connectionOptions({ apiKey, domain }: {
164
50
  export declare function create(options: E2BOptions): Promise<E2BProvider>;
165
51
  /** The conformance CLI's module for E2B: its live switch, the run's 30-minute cap, its template and the drifted twin. */
166
52
  export declare const conformance: () => Promise<typeof import("./conformance/e2b.js")>;
167
- /** The mount kinds an E2B computer takes, as capabilities().mount declares them: the run's folder on an Archil disk. */
168
- export declare const MOUNT: readonly MountKind[];
169
- /** The machine kind and groups of each configuration: kind linux (the plain template), and kind desktop (the default). */
170
- export declare const CAPABILITIES: readonly KindCapabilities[];
171
53
  /**
172
54
  * Computers that are E2B sandboxes, on the shared adapter. A spec's image is an E2B template (its name or id):
173
55
  * "desktop" is E2B Desktop's, with Xvfb, x11vnc and noVNC (e2b-dev/desktop template.py:21-65).