@parcha/agentrun-computer 0.1.0-beta.47 → 0.1.0-beta.48

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 CHANGED
@@ -1405,8 +1405,8 @@ conformance module's `dialKit()` refuses, as E2B's does: the Core run happens in
1405
1405
  run image with `COMPUTER_MODAL_CONNECT=dial` is the box image, the one that holds `agentrun-dial` (debian:bookworm-slim
1406
1406
  on exec, as before).
1407
1407
 
1408
- A dial sandbox may be a desktop (`kind: "desktop"`): the box image's X server and xfwm4, started over the socket it
1409
- dialed, at 2 CPUs and 4 GiB on the VM runtime, with no GPU. On exec a Modal computer is kind `linux` alone, and the
1408
+ A dial sandbox may be a desktop (`kind: "desktop"`): the box image's X server, started over the socket it dialed, and
1409
+ xfwm4, which computerd starts, at 2 CPUs and 4 GiB on the VM runtime, with no GPU. On exec a Modal computer is kind `linux` alone, and the
1410
1410
  constructor refuses `kind: "desktop"` in words. The descriptor's desktop configuration selects `connect: "dial"` itself,
1411
1411
  so a server whose `modalConnect` is exec still makes its desktop over dial (it needs the dial's public address). In
1412
1412
  serve's Mode 2 the run's folder is an Archil mount, which a dial machine takes none of yet, so a Modal desktop there is
@@ -1561,7 +1561,7 @@ the TTL.
1561
1561
 
1562
1562
  | Capability | Declared | Why |
1563
1563
  | --- | --- | --- |
1564
- | `kind` | `linux` | a Linux shell with computerd: exec, files and processes |
1564
+ | `kind` | `linux`; `desktop` on dial | a Linux shell with computerd: exec, files and processes; on dial, `kind: "desktop"` adds the box snapshot's display ([Daytona on dial](#daytona-on-dial)) |
1565
1565
  | `lifetime` | `vendor` | `ttlMinutes` destroys the sandbox in any state once it elapses; set to the lifetime in whole minutes, rounded up. Init also ends every process at the deadline itself. |
1566
1566
  | `network` | `none`, `open`, `allow` | none: `networkBlockAll` at create, and the daemon's own network namespace; open and a list: not blocked (the account's tier may still limit where it goes), and the daemon's own namespace whose one way out is init's egress proxy (public internet only; a list's hosts alone) |
1567
1567
  | `vendorAgentPorts` | `[2280]` | the toolbox's port, on every interface; isolation.vendor-agent checks a program of the computer's user reaches it on neither loopback |
@@ -1644,7 +1644,7 @@ when it runs (`settingsFromEnv`) and passes each to `create()` as the option in
1644
1644
  (`apiKey`, required), `COMPUTER_DAYTONA_API_URL` (`apiUrl`), `COMPUTER_DAYTONA_DAEMON` (`daemonPath`),
1645
1645
  `COMPUTER_DAYTONA_ARCH` (`arch`), `COMPUTER_DAYTONA_TARGET` (`target`), `COMPUTER_DAYTONA_CLASS` (`sandboxClass`),
1646
1646
  `COMPUTER_DAYTONA_USER` (`daemonUser`), `COMPUTER_DAYTONA_GPU_SNAPSHOT` (`gpuSnapshot`) and `COMPUTER_DAYTONA_CONNECT`
1647
- (`connect`). It exports `createProvider()` and `createDriftedProvider()` (which builds a
1647
+ (`connect`); the providers it makes also read `COMPUTER_DAYTONA_KIND` (`kind`, `desktop` on dial only). It exports `createProvider()` and `createDriftedProvider()` (which builds a
1648
1648
  daemon of another version with Go), and reads `COMPUTER_DAYTONA_SNAPSHOT` (the run's image; unset, `"default"`,
1649
1649
  Daytona's default snapshot, or on dial the box image's snapshot, `agentrun-box-<recipe hash>`). It never reads `DAYTONA_API_KEY`, `DAYTONA_API_URL` or `DAYTONA_TARGET`, not even as a
1650
1650
  fallback: on a host that runs other Daytona work they may hold another organization's key. Those are serve's names,
@@ -1681,8 +1681,11 @@ default) a Daytona sandbox dials the server instead ([PROVIDERS.md](PROVIDERS.md
1681
1681
  no exec and no upload, and nothing goes through the toolbox: create sends the boot env as `CreateSandbox.env` and
1682
1682
  `networkBlockAll: false` (the machine's root reaches the server; network none is init's, inside), and the snapshot's
1683
1683
  entrypoint runs `agentrun-dial`. No Archil mount, no GPU, and not `image: "default"` (Daytona's default snapshot holds
1684
- no `agentrun-dial`): `check()` refuses each in words. Labels as on exec. A Daytona computer is kind `linux` alone, on
1685
- dial as on exec; why: [PROVIDERS.md](PROVIDERS.md#machines-that-dial-in).
1684
+ no `agentrun-dial`): `check()` refuses each in words. Labels as on exec. A dial sandbox may be a desktop
1685
+ (`kind: "desktop"`): the box snapshot's X server, started over the socket it dialed, and xfwm4, which computerd starts
1686
+ (init's `--window-manager`), at the snapshot's 2 CPUs and 4 GiB, with no GPU. On exec a Daytona computer is kind
1687
+ `linux` alone, and the constructor refuses `kind: "desktop"` in words; the descriptor's desktop configuration selects
1688
+ `connect: "dial"` itself. Why computerd, not the client, starts the manager here: [PROVIDERS.md](PROVIDERS.md#machines-that-dial-in).
1686
1689
  What each part of a dial sandbox rests on:
1687
1690
 
1688
1691
  - **A snapshot, never an image.** A create names a snapshot; a snapshot is made from "any publicly accessible image"
@@ -1894,12 +1897,16 @@ E2B's envd is the sandbox's first process, a systemd service with `Restart=alway
1894
1897
  whose start answers after the call gave up on it (its bound passed, or the caller aborted) is killed as it lands.
1895
1898
  6. A desktop's X server, `Xvfb :0 -screen 0 1280x800x24 -nolisten tcp`, starts through the daemon with
1896
1899
  `process.start`, as the computer's user, and create waits until hello declares the display (`src/desktop.ts`,
1897
- shared with Docker). Then xfwm4, which the template has, starts the same way on it (`xfwm4 --compositor=off
1898
- --sm-client-disable`, `WINDOW_MANAGER`), so the apps an agent opens are framed and focused. xfwm4 reads its
1899
- settings over a session bus and exits without one. So it runs under `dbus-run-session`, in a user namespace (the
1900
- same uid) and a network namespace of its own (`unshare --user --map-current-user --net`), and its bus listens on an
1901
- abstract name there, which a program of the computer's user cannot connect to. One that joins those namespaces
1902
- (nsenter) can, as the same uid can ptrace xfwm4. xfwm4 reaches the display by its path. It and every app `apps.launch` opens get `NO_AT_BRIDGE=1`: the template has at-spi2-core, so GTK's
1900
+ shared with Docker). Then xfwm4, which the template has, starts on it (`xfwm4 --compositor=off
1901
+ --sm-client-disable`), so the apps an agent opens are framed and focused: computerd starts it itself, asked by
1902
+ init's `--window-manager` (the host's facts say `windowManager`), once the display answers, and hello's
1903
+ `windowManager` says it runs, which create waits on. xfwm4 reads its settings over a session bus and exits without
1904
+ one. So it runs under `dbus-run-session`, as the computer's user, in a network namespace of its own that init makes
1905
+ as root before it drops to that user (no user namespace is needed), and its bus listens on an abstract name there,
1906
+ which a program of the computer's user cannot connect to. One that joins that namespace (nsenter) can, as the same
1907
+ uid can ptrace xfwm4. xfwm4 reaches the display by its path. An older computerd, whose hello has no
1908
+ `windowManager`, gets the manager through `process.start`, as before (`WINDOW_MANAGER`, under `unshare --user
1909
+ --map-current-user --net`). It and every app `apps.launch` opens get `NO_AT_BRIDGE=1`: the template has at-spi2-core, so GTK's
1903
1910
  accessibility bridge would start an at-spi bus, a socket of the user's at `/work/.cache/at-spi/bus_0` that nothing
1904
1911
  of ours uses. An app also gets no session bus (`DBUS_SESSION_BUS_ADDRESS=disabled:`). Given none, it would start
1905
1912
  one with the template's dbus-launch, and that bus starts gnome-keyring-daemon, a socket of the user's at
@@ -2061,8 +2068,8 @@ provider does in `process.env`. `COMPUTER_E2B_PUBLIC_STREAM` is no longer read.
2061
2068
  With `connect: "dial"` (a server's `e2bConnect` setting; `exec` by default) an E2B sandbox dials the server instead
2062
2069
  ([PROVIDERS.md](PROVIDERS.md#machines-that-dial-in)): a desktop by default, as on exec, since the box template has
2063
2070
  the desktop (`box/install.sh`'s `desktop` step), or kind linux; no Archil mount, and the host has no
2064
- exec and no upload. A desktop's launch adds `DISPLAY` to the boot env, and its X server and xfwm4 start over the
2065
- socket the sandbox dialed, through `process.start`. A dial desktop whose X server has gone is not refused at `connect()`
2071
+ exec and no upload. A desktop's launch adds `DISPLAY` and init's `--window-manager` to the boot env; its X server
2072
+ starts over the socket the sandbox dialed, through `process.start`, and computerd starts xfwm4 once it answers. A dial desktop whose X server has gone is not refused at `connect()`
2066
2073
  as on exec: it reads back kind `linux`, and its screen, input, apps and ui calls are refused in words, never sent, until
2067
2074
  its hello says `desktop` again. E2B runs a template's start command once, at the template's build, and snapshots it running, so
2068
2075
  it never sees a create's env ([docs.e2b.dev/template/start-ready-command](https://docs.e2b.dev/template/start-ready-command)).
@@ -2219,8 +2226,8 @@ kernel `4.19.0-gvisor`): root has no `CAP_SYS_ADMIN`, and init made its namespac
2219
2226
  `create({ kind: "desktop", ... })` (serve builds the descriptor's desktop configuration so) makes a desktop: the
2220
2227
  adapter gives init `DISPLAY` and starts `Xvfb :0 -screen 0 1280x800x24 -nolisten tcp` through the daemon as the tool
2221
2228
  user (`src/desktop.ts`), as on E2B, so the X server is one process in init's table, in its own network namespace, and
2222
- ends with the computer; xfwm4 starts the same way once the display answers, its session bus out of the user's reach, as
2223
- on E2B. It starts from the box image the release publishes, `ghcr.io/parcha-ai/agentrun-box:<recipe hash>`
2229
+ ends with the computer; computerd starts xfwm4 itself once the display answers (init's `--window-manager`), its
2230
+ session bus out of the user's reach, as on E2B. It starts from the box image the release publishes, `ghcr.io/parcha-ai/agentrun-box:<recipe hash>`
2224
2231
  (`box/Dockerfile`: the archil client, the helper, the tool user, FUSE, no sudo, plus Xvfb, xfwm4, and the apps E2B
2225
2232
  Desktop has that are cheap to carry, which the `apps` group lists and opens), as a template of the key's own workspace
2226
2233
  named `agentrun-box-<recipe hash>`. A sandbox that mounts an Archil disk starts from the same template.
@@ -2937,7 +2944,7 @@ pass, facts: [{ id, value, means }], factsProblem? }`.
2937
2944
  An id is resolved through the provider registry, and only there; the usage lists every id it holds. A module path is
2938
2945
  resolved from the directory npm was run in. It exits 0 when Core passes, 1 when it fails, 2 on a
2939
2946
  usage error, and 3 on a partial run; `--json` prints the report object (`{ provider, providerVersion, kind,
2940
- daemonMode, image, daemons: [{ computer, role, version, os, arch, fence? }], only?, coreNotRun?, results: [{ id, level,
2947
+ daemonMode, image, daemons: [{ computer, role, version, os, arch, fence?, windowManager? }], only?, coreNotRun?, results: [{ id, level,
2941
2948
  group, status, reason?, undeclared? }], core, undeclared, cleanup, computers: { peak, cap? }, notes?, computerNotes? }`).
2942
2949
  `computers.peak` is the most computers the run had alive at once, each counted from its create's call until its release
2943
2950
  (the text report's `computers alive at once: <peak> at most` line). `--concurrency <n>` (`concurrency` in
Binary file
Binary file
@@ -1,4 +1,4 @@
1
1
  {
2
- "version": "0.1.0-beta.47",
3
- "source": "sha256:83076566cf0a21895c12558066f3c852be325fd362a36c1024be04dc080a6e16"
2
+ "version": "0.1.0-beta.48",
3
+ "source": "sha256:31803ee5ab55da1b0cdb9ebcdcdda5c9373d4ae4b81eb9459a2504e1111d1966"
4
4
  }
@@ -32,6 +32,8 @@ export declare const DAYTONA_ENV: {
32
32
  readonly archilEgress: "COMPUTER_DAYTONA_ARCHIL_EGRESS";
33
33
  /** connect: exec (default) or dial, which needs the public server's process (dialKit). */
34
34
  readonly connect: "COMPUTER_DAYTONA_CONNECT";
35
+ /** kind: linux (default) or desktop, which create() takes on dial alone. */
36
+ readonly kind: "COMPUTER_DAYTONA_KIND";
35
37
  };
36
38
  /** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
37
39
  export declare const ENV: {
@@ -60,6 +62,8 @@ export declare const ENV: {
60
62
  readonly archilEgress: "COMPUTER_DAYTONA_ARCHIL_EGRESS";
61
63
  /** connect: exec (default) or dial, which needs the public server's process (dialKit). */
62
64
  readonly connect: "COMPUTER_DAYTONA_CONNECT";
65
+ /** kind: linux (default) or desktop, which create() takes on dial alone. */
66
+ readonly kind: "COMPUTER_DAYTONA_KIND";
63
67
  };
64
68
  /**
65
69
  * The provider's options this module reads from env, each only when its name is set; throws in words without the key,
@@ -12,6 +12,7 @@ import { DAYTONA_DEFAULT_SNAPSHOT } from "../descriptors/daytona.js";
12
12
  import { archilRunFolder, archilSettings } from "./archil.js";
13
13
  import { dialOnlyFromServer } from "./dial-only.js";
14
14
  import { buildDriftDaemon, DRIFT_VERSION } from "./drift-daemon.js";
15
+ import { kindFrom } from "./kind.js";
15
16
  /** The Archil disk's settings for the mount cases, by name (COMPUTER_ARCHIL_*: all five, or none). */
16
17
  export { ARCHIL_ENV } from "./archil.js";
17
18
  /** The environment this module reads, by name, each for the option its comment names. */
@@ -41,6 +42,8 @@ export const DAYTONA_ENV = {
41
42
  archilEgress: "COMPUTER_DAYTONA_ARCHIL_EGRESS",
42
43
  /** connect: exec (default) or dial, which needs the public server's process (dialKit). */
43
44
  connect: "COMPUTER_DAYTONA_CONNECT",
45
+ /** kind: linux (default) or desktop, which create() takes on dial alone. */
46
+ kind: "COMPUTER_DAYTONA_KIND",
44
47
  };
45
48
  /** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
46
49
  export const ENV = DAYTONA_ENV;
@@ -92,6 +95,8 @@ export const conformanceNotes = [
92
95
  function optionsOf({ env = process.env, fetch, webSocket, timeouts, onNote, dial, daemonPath }) {
93
96
  return {
94
97
  ...settingsFromEnv(env),
98
+ // create() refuses any other kind, and desktop without dial, in words.
99
+ ...kindFrom(env, DAYTONA_ENV.kind),
95
100
  ...(daemonPath === undefined ? {} : { daemonPath }),
96
101
  autoStopMinutes: CONFORMANCE_AUTO_STOP_MINUTES,
97
102
  autoDeleteMinutes: CONFORMANCE_AUTO_DELETE_MINUTES,
@@ -59,7 +59,7 @@ export function formatReport(report) {
59
59
  }
60
60
  // Each computer's daemon, named with its role: computers of one run may answer differently (a GPU computer's fence).
61
61
  for (const daemon of daemons)
62
- lines.push(`daemon ${daemon.computer} (${daemon.role}): ${said(daemon)}${daemon.fence === undefined ? "" : ` · fence ${daemon.fence}`}`);
62
+ lines.push(`daemon ${daemon.computer} (${daemon.role}): ${said(daemon)}${daemon.fence === undefined ? "" : ` · fence ${daemon.fence}`}${daemon.windowManager === undefined ? "" : ` · window manager ${daemon.windowManager.state}${daemon.windowManager.why ? `: ${daemon.windowManager.why}` : ""}`}`);
63
63
  for (const note of report.notes ?? [])
64
64
  lines.push(`note: ${note}`);
65
65
  for (const { computer, role, note } of report.computerNotes ?? [])
@@ -280,7 +280,7 @@ export async function runConformance(provider, options) {
280
280
  const sawHello = (computer, hello, role) => {
281
281
  if (report.daemons.some((daemon) => daemon.computer === computer))
282
282
  return;
283
- report.daemons.push({ computer, role: roles.get(computer) ?? role, version: hello.version, os: hello.os, arch: hello.arch, ...(hello.fence === undefined ? {} : { fence: hello.fence }) });
283
+ report.daemons.push({ computer, role: roles.get(computer) ?? role, version: hello.version, os: hello.os, arch: hello.arch, ...(hello.fence === undefined ? {} : { fence: hello.fence }), ...(hello.windowManager === undefined ? {} : { windowManager: hello.windowManager }) });
284
284
  };
285
285
  /**
286
286
  * The run's shared computer, made the first time a case needs it or the daemon's hello, and again after it made way
@@ -1,5 +1,5 @@
1
1
  import type { MountKind, MountSpec } from "../mount.js";
2
- import type { ComputerClient, ComputerKind, ComputerOs, DaemonMethod, DaemonMethods, ExecRunParams, Group, HelloResult, NetworkFence } from "../protocol.js";
2
+ import type { ComputerClient, ComputerKind, ComputerOs, DaemonMethod, DaemonMethods, ExecRunParams, Group, HelloResult, NetworkFence, WindowManagerFact } from "../protocol.js";
3
3
  import type { ComputerConnection, ComputerProvider, ComputerRef, ComputerSpec, DaemonMode, GpuSpec } from "../provider.js";
4
4
  import type { ComputerError, ComputerErrorCode, Result } from "../result.js";
5
5
  import type { KindCapabilities } from "../kinds.js";
@@ -260,7 +260,10 @@ export type ComputerRole = string;
260
260
  export interface CreatedNote extends ComputerNote {
261
261
  role: ComputerRole;
262
262
  }
263
- /** What one computer's first hello said: the computer, its role, and the fence when it names one. */
263
+ /**
264
+ * What one computer's first hello said: the computer, its role, the fence when it names one, and the window manager
265
+ * computerd started when it says one (a live run's evidence that computerd, not create, started it).
266
+ */
264
267
  export interface ComputerDaemon {
265
268
  computer: string;
266
269
  role: ComputerRole;
@@ -268,6 +271,7 @@ export interface ComputerDaemon {
268
271
  os: string;
269
272
  arch: string;
270
273
  fence?: NetworkFence;
274
+ windowManager?: WindowManagerFact;
271
275
  }
272
276
  /**
273
277
  * The server a dial host's machines reach (MachineHost facts.connect "dial"), as the run stands it up: its machine
package/dist/daytona.d.ts CHANGED
@@ -19,7 +19,7 @@ export type DaytonaTimeouts = HostedTimeouts & {
19
19
  };
20
20
  /**
21
21
  * The Daytona provider's options: the key and Daytona's own settings, then the shared adapter's (HostedOptions), kind
22
- * among them: linux alone, kind desktop refused in its descriptor's unserved words (kindRefusal).
22
+ * among them: a desktop on connect dial alone (kindRefusal, with DAYTONA_DIAL_DESKTOP's why).
23
23
  */
24
24
  export interface DaytonaProviderOptions extends Omit<HostedOptions, "desktop" | "maxLifetimeMs" | "timeouts"> {
25
25
  /** The Daytona API key. The caller passes it; this provider never reads the environment and never puts it in a computer. */
package/dist/daytona.js CHANGED
@@ -8,7 +8,7 @@
8
8
  // README's Daytona section.
9
9
  import { randomBytes } from "node:crypto";
10
10
  import { connectOf, kindRefusal, mountsOf } from "./descriptor.js";
11
- import { DAYTONA, DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU, DAYTONA_GPU_REGION, DAYTONA_GPU_SNAPSHOT, daytonaGpuSnapshot } from "./descriptors/daytona.js";
11
+ import { DAYTONA, DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_DIAL_DESKTOP, DAYTONA_GPU, DAYTONA_GPU_REGION, DAYTONA_GPU_SNAPSHOT, daytonaGpuSnapshot } from "./descriptors/daytona.js";
12
12
  import { COMPUTER_LABEL } from "./drift.js";
13
13
  import { HostError } from "./host.js";
14
14
  import { framedExec } from "./hosted/framed-exec.js";
@@ -142,6 +142,10 @@ class DaytonaHost {
142
142
  maxLifetimeMs: MAX_LIFETIME_MS,
143
143
  arch: options.arch,
144
144
  vendorAgentPorts: [TOOLBOX_PORT],
145
+ // A snapshot of box/Dockerfile has xfwm4 (box/install.sh's desktop step), for a desktop (connect dial alone).
146
+ // computerd starts it as root makes its network namespace: the tool user can make none here (Sysbox, with
147
+ // kernel.apparmor_restrict_unprivileged_userns=1, measured 11-19).
148
+ windowManager: true,
145
149
  ...(options.connect === "dial" ? { connect: options.connect } : {}),
146
150
  };
147
151
  if (options.connect === "exec") {
@@ -515,7 +519,7 @@ export class DaytonaProvider extends HostedProvider {
515
519
  const via = connectOf(DAYTONA, { connect });
516
520
  const refused = kindRefusal(DAYTONA, { kind: hosted.kind, connect: via });
517
521
  if (refused !== undefined)
518
- throw new Error(refused);
522
+ throw new Error(hosted.kind === "desktop" ? `${refused}: ${DAYTONA_DIAL_DESKTOP}` : refused);
519
523
  if (typeof apiKey !== "string" || apiKey === "")
520
524
  throw new Error("options.apiKey, the Daytona API key, is required: the provider reads no environment, so the caller passes it");
521
525
  const base = new URL(apiUrl);
@@ -1,6 +1,11 @@
1
1
  import type { GpuCapability } from "../provider.js";
2
- /** Why Daytona gives no desktop (measured 11-19): PROVIDERS.md, Machines that dial in. The descriptor's unserved desktop. */
3
- export declare const DAYTONA_NO_DESKTOP = "its sandboxes run under AppArmor's restrict_unprivileged_userns, so the tool user can't make the user and network namespaces the window manager runs in";
2
+ /**
3
+ * Why a Daytona desktop is made on connect dial alone: its X server and window manager come from a snapshot of
4
+ * box/Dockerfile, whose sandbox boots agentrun-dial and dials the server, the path a live run proves; no desktop has run
5
+ * on exec, where init is a command started through the toolbox's session. The provider's constructor refuses kind
6
+ * desktop on exec in these words, after kindRefusal's.
7
+ */
8
+ export declare const DAYTONA_DIAL_DESKTOP = "a desktop's sandbox boots from a snapshot of box/Dockerfile and dials this server, and none has run through the toolbox's session commands, so connect \"exec\" makes kind linux";
4
9
  /** The key that turns on a Daytona computer's Archil mount: the operator's Archil egress relay (archilEgress). */
5
10
  export declare const DAYTONA_ARCHIL_EGRESS = "DAYTONA_ARCHIL_EGRESS";
6
11
  /** Why a Daytona computer made with no Archil egress takes no Archil mount: check() refuses one in these words. */
@@ -91,10 +96,20 @@ export declare const DAYTONA: {
91
96
  };
92
97
  readonly image?: string;
93
98
  readonly options?: Readonly<Record<string, unknown>>;
99
+ }, {
100
+ readonly options: {
101
+ readonly kind: "desktop";
102
+ readonly connect: "dial";
103
+ };
104
+ readonly kind: import("../protocol.js").ComputerKind;
105
+ readonly groups: import("../protocol.js").Group[];
106
+ readonly gpu?: GpuCapability;
107
+ readonly persistence?: {
108
+ keepsState: true;
109
+ resume: boolean;
110
+ };
111
+ readonly image?: string;
94
112
  }];
95
- readonly unserved: {
96
- readonly desktop: "its sandboxes run under AppArmor's restrict_unprivileged_userns, so the tool user can't make the user and network namespaces the window manager runs in";
97
- };
98
113
  readonly defaultImage: {
99
114
  readonly sandbox: "default";
100
115
  };
@@ -1,9 +1,14 @@
1
1
  // Daytona's descriptor: a sandbox on Daytona's cloud, with GPUs when asked; the run's folder on an Archil disk only where
2
2
  // the operator gives an Archil egress relay (a self-hosted Daytona target), never on Daytona's hosted cloud.
3
3
  import { defineProvider } from "../descriptor.js";
4
- import { SANDBOX } from "./shared.js";
5
- /** Why Daytona gives no desktop (measured 11-19): PROVIDERS.md, Machines that dial in. The descriptor's unserved desktop. */
6
- export const DAYTONA_NO_DESKTOP = "its sandboxes run under AppArmor's restrict_unprivileged_userns, so the tool user can't make the user and network namespaces the window manager runs in";
4
+ import { LINUX_DESKTOP, SANDBOX } from "./shared.js";
5
+ /**
6
+ * Why a Daytona desktop is made on connect dial alone: its X server and window manager come from a snapshot of
7
+ * box/Dockerfile, whose sandbox boots agentrun-dial and dials the server, the path a live run proves; no desktop has run
8
+ * on exec, where init is a command started through the toolbox's session. The provider's constructor refuses kind
9
+ * desktop on exec in these words, after kindRefusal's.
10
+ */
11
+ export const DAYTONA_DIAL_DESKTOP = "a desktop's sandbox boots from a snapshot of box/Dockerfile and dials this server, and none has run through the toolbox's session commands, so connect \"exec\" makes kind linux";
7
12
  /** The key that turns on a Daytona computer's Archil mount: the operator's Archil egress relay (archilEgress). */
8
13
  export const DAYTONA_ARCHIL_EGRESS = "DAYTONA_ARCHIL_EGRESS";
9
14
  /** Why a Daytona computer made with no Archil egress takes no Archil mount: check() refuses one in these words. */
@@ -92,9 +97,12 @@ export const DAYTONA = defineProvider({
92
97
  // its programs' one way out is init's egress proxy, which reaches the public internet alone, and with a list its hosts
93
98
  // alone (hosted/network.ts).
94
99
  network: ["none", "open", "allow"],
95
- // A linux computer, with GPUs when asked. No desktop, on any connect (DAYTONA_NO_DESKTOP).
96
- capabilities: [{ ...SANDBOX, gpu: DAYTONA_GPU }],
97
- unserved: { desktop: DAYTONA_NO_DESKTOP },
100
+ // A linux computer, with GPUs when asked; or, on connect dial alone, a desktop with none: a snapshot of box/Dockerfile's
101
+ // X server, started through computerd over the socket the sandbox dialed, and xfwm4, which computerd starts itself
102
+ // (init --window-manager), at the snapshot's 2 CPUs and 4 GiB (box/build-daytona.py). The desktop's configuration
103
+ // selects dial itself, whatever daytonaConnect says: a provider on connect exec refuses kind desktop when it is made
104
+ // (DAYTONA_DIAL_DESKTOP).
105
+ capabilities: [{ ...SANDBOX, gpu: DAYTONA_GPU }, { ...LINUX_DESKTOP, options: { kind: "desktop", connect: "dial" } }],
98
106
  defaultImage: { sandbox: DAYTONA_DEFAULT_SNAPSHOT },
99
107
  // The operator's own snapshot for every Daytona computer, named here; the default snapshot stands while unset. A
100
108
  // computer with an Archil mount needs a snapshot of box/Dockerfile (box/build-daytona.py prints its name).
@@ -80,10 +80,20 @@ export declare const DESCRIPTORS: readonly [{
80
80
  };
81
81
  readonly image?: string;
82
82
  readonly options?: Readonly<Record<string, unknown>>;
83
+ }, {
84
+ readonly options: {
85
+ readonly kind: "desktop";
86
+ readonly connect: "dial";
87
+ };
88
+ readonly kind: import("../protocol.js").ComputerKind;
89
+ readonly groups: import("../protocol.js").Group[];
90
+ readonly gpu?: import("../provider.js").GpuCapability;
91
+ readonly persistence?: {
92
+ keepsState: true;
93
+ resume: boolean;
94
+ };
95
+ readonly image?: string;
83
96
  }];
84
- readonly unserved: {
85
- readonly desktop: "its sandboxes run under AppArmor's restrict_unprivileged_userns, so the tool user can't make the user and network namespaces the window manager runs in";
86
- };
87
97
  readonly defaultImage: {
88
98
  readonly sandbox: "default";
89
99
  };
package/dist/desktop.d.ts CHANGED
@@ -11,15 +11,21 @@ export interface DesktopOptions {
11
11
  /** The groups a desktop declares besides exec, files and processes: apps is computerd's, from the desktop's .desktop files. */
12
12
  export declare const DESKTOP_GROUPS: readonly ["screen", "input.pointer", "input.keys", "apps"];
13
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.
14
+ * The window manager a host's desktops run where its facts say so (HostFacts.windowManager: E2B's, Fly's, Cloudflare's,
15
+ * Modal's, Agent37's and Daytona's), once the display answers: it frames, stacks and focuses the windows apps.launch
16
+ * opens. xfwm4, which the box image has, with no compositor and no session manager. It reads its settings from xfconfd
17
+ * over a session bus, and exits at once without one ("Xfconf could not be initialized"). So it runs in a session bus of
18
+ * its own (dbus-run-session, WINDOW_MANAGER_BUS, written to a file of its own under /tmp), in a network namespace of its
19
+ * own: a program of the computer's user reaches no socket of that bus, unless it joins that namespace (nsenter), as the
20
+ * same uid may ptrace xfwm4. xfwm4 reaches the display as any program does, by its path. First, xsetroot paints the
21
+ * screen behind every window one slate colour, so a desktop with no window open is not a black screen a person reads as
22
+ * broken; a paint that fails starts xfwm4 all the same.
23
+ *
24
+ * computerd starts it itself (init --window-manager), as root makes the network namespace and then becomes the
25
+ * computer's user, so no user namespace is needed there: the user can make neither on some hosts (Daytona's sandboxes,
26
+ * under AppArmor's restrict_unprivileged_userns). This argv is create's own start, through process.start as the
27
+ * computer's user, for a computerd whose hello says nothing of one: the user makes the network namespace inside a user
28
+ * namespace (the same uid) of its own.
23
29
  */
24
30
  export declare const WINDOW_MANAGER: readonly string[];
25
31
  /** The desktop options with their defaults, or a throw in words. */
@@ -27,8 +33,9 @@ export declare function desktopOf({ display, server, timeoutMs }: DesktopOptions
27
33
  /**
28
34
  * Starts the desktop's X server through the daemon (process.start) and waits until hello declares the display: the
29
35
  * server ending first, or the bound passing, is a failure in words, with the server's own last words, as the vendor's
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.
36
+ * (code vendor, vendor the provider's id). version is the client's, sent with each hello. Once the display answers, a
37
+ * hello with windowManager (computerd was asked to start it) is waited on until the manager runs; else, with
38
+ * windowManager (the host's desktops run one, HostFacts.windowManager), create starts WINDOW_MANAGER itself.
32
39
  */
33
40
  export declare function startDisplay(client: ComputerClient, desktop: Required<DesktopOptions>, { version, vendor, signal, windowManager }: {
34
41
  version: string;
package/dist/desktop.js CHANGED
@@ -1,8 +1,10 @@
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
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.
4
+ // on (hello re-checks the display on each call). A window manager, when the desktop has one, comes next: computerd starts
5
+ // it itself when init was asked to (init --window-manager; hello's windowManager says how it goes), and create starts
6
+ // it the same way as the server, through process.start, for a computerd that says nothing of one.
7
+ // Docker's desktops, E2B's, Agent37's and Daytona's start the display this way.
6
8
  import { setTimeout as sleep } from "node:timers/promises";
7
9
  import { fail, ok, vendorFail } from "./result.js";
8
10
  /** The groups a desktop declares besides exec, files and processes: apps is computerd's, from the desktop's .desktop files. */
@@ -25,15 +27,21 @@ const WINDOW_MANAGER_BUS = `<busconfig>
25
27
  </policy>
26
28
  </busconfig>`;
27
29
  /**
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.
30
+ * The window manager a host's desktops run where its facts say so (HostFacts.windowManager: E2B's, Fly's, Cloudflare's,
31
+ * Modal's, Agent37's and Daytona's), once the display answers: it frames, stacks and focuses the windows apps.launch
32
+ * opens. xfwm4, which the box image has, with no compositor and no session manager. It reads its settings from xfconfd
33
+ * over a session bus, and exits at once without one ("Xfconf could not be initialized"). So it runs in a session bus of
34
+ * its own (dbus-run-session, WINDOW_MANAGER_BUS, written to a file of its own under /tmp), in a network namespace of its
35
+ * own: a program of the computer's user reaches no socket of that bus, unless it joins that namespace (nsenter), as the
36
+ * same uid may ptrace xfwm4. xfwm4 reaches the display as any program does, by its path. First, xsetroot paints the
37
+ * screen behind every window one slate colour, so a desktop with no window open is not a black screen a person reads as
38
+ * broken; a paint that fails starts xfwm4 all the same.
39
+ *
40
+ * computerd starts it itself (init --window-manager), as root makes the network namespace and then becomes the
41
+ * computer's user, so no user namespace is needed there: the user can make neither on some hosts (Daytona's sandboxes,
42
+ * under AppArmor's restrict_unprivileged_userns). This argv is create's own start, through process.start as the
43
+ * computer's user, for a computerd whose hello says nothing of one: the user makes the network namespace inside a user
44
+ * namespace (the same uid) of its own.
37
45
  */
38
46
  export const WINDOW_MANAGER = [
39
47
  "unshare",
@@ -76,8 +84,9 @@ export function desktopOf({ display = ":0", server, timeoutMs = 30_000 }) {
76
84
  /**
77
85
  * Starts the desktop's X server through the daemon (process.start) and waits until hello declares the display: the
78
86
  * server ending first, or the bound passing, is a failure in words, with the server's own last words, as the vendor's
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.
87
+ * (code vendor, vendor the provider's id). version is the client's, sent with each hello. Once the display answers, a
88
+ * hello with windowManager (computerd was asked to start it) is waited on until the manager runs; else, with
89
+ * windowManager (the host's desktops run one, HostFacts.windowManager), create starts WINDOW_MANAGER itself.
81
90
  */
82
91
  export async function startDisplay(client, desktop, { version, vendor, signal, windowManager = false }) {
83
92
  const server = desktop.server.join(" ");
@@ -96,8 +105,11 @@ export async function startDisplay(client, desktop, { version, vendor, signal, w
96
105
  const hello = await client.call("hello", { client: `@parcha/agentrun-computer ${version}` }, { signal: either });
97
106
  if (!hello.ok)
98
107
  return timedOut() ? late() : hello;
99
- if (Array.isArray(hello.value.groups) && hello.value.groups.includes("screen"))
108
+ if (Array.isArray(hello.value.groups) && hello.value.groups.includes("screen")) {
109
+ if (hello.value.windowManager)
110
+ return await awaitWindowManager(client, desktop, { version, vendor, caller: signal });
100
111
  return windowManager ? await startWindowManager(client, desktop, vendor, signal) : ok(undefined);
112
+ }
101
113
  const waited = await client.call("process.wait", { id, timeoutMs: 0 }, { signal: either });
102
114
  if (waited.ok && !waited.value.running) {
103
115
  const read = await client.call("process.read", { id, stream: "stderr", offset: 0 }, { signal: either });
@@ -115,7 +127,33 @@ export async function startDisplay(client, desktop, { version, vendor, signal, w
115
127
  }
116
128
  }
117
129
  /**
118
- * Starts WINDOW_MANAGER on the display that answers. A manager that cannot start, or ends
130
+ * Waits on the window manager computerd starts itself (hello's windowManager, init --window-manager) until hello says it
131
+ * runs: one that ended fails create in computerd's words, its last lines among them. The bound is WM_BOUND_MS, as for a
132
+ * manager create starts. The caller's abort still ends it.
133
+ */
134
+ async function awaitWindowManager(client, desktop, { version, vendor, caller }) {
135
+ const bound = AbortSignal.timeout(WM_BOUND_MS);
136
+ const signal = caller ? AbortSignal.any([caller, bound]) : bound;
137
+ const stopped = () => caller?.aborted
138
+ ? fail("aborted", "create was aborted while the window manager started")
139
+ : fail("timeout", `the window manager computerd starts did not run on ${desktop.display} within ${WM_BOUND_MS / 1000} s`);
140
+ for (;;) {
141
+ const hello = await client.call("hello", { client: `@parcha/agentrun-computer ${version}` }, { signal });
142
+ if (!hello.ok)
143
+ return signal.aborted ? stopped() : fail(hello.error.code, `hello, while the window manager computerd starts came up on ${desktop.display}: ${hello.error.message}`);
144
+ const fact = hello.value.windowManager;
145
+ if (fact?.state === "running")
146
+ return ok(undefined);
147
+ if (fact?.state === "ended")
148
+ return vendorFail(vendor, fact.why ?? `the window manager computerd starts ended on ${desktop.display}`);
149
+ await sleep(DISPLAY_POLL_MS, undefined, { signal }).catch(() => undefined);
150
+ if (signal.aborted)
151
+ return stopped();
152
+ }
153
+ }
154
+ /**
155
+ * Starts WINDOW_MANAGER on the display that answers, for a computerd that starts none (its hello has no
156
+ * windowManager). A manager that cannot start, or ends
119
157
  * within WM_SETTLE_MS (xfwm4 with no session bus, or no display it may open), fails create with its last words. It has
120
158
  * 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
159
  * full second. The caller's abort still ends it.
@@ -685,6 +685,8 @@ export class HostedProvider {
685
685
  return this.#fail("refused", `labels: ${stored.problem}`);
686
686
  const archil = spec.mount?.kind === "archil";
687
687
  const user = this.#userOf(spec);
688
+ // A desktop whose host runs a window manager has computerd start it (init --window-manager).
689
+ const windowManager = this.#desktop !== undefined && this.host.facts.windowManager === true;
688
690
  const commands = hostedCommands({
689
691
  staging: `${STAGING}${randomBytes(8).toString("hex")}`,
690
692
  deadline,
@@ -701,10 +703,11 @@ export class HostedProvider {
701
703
  network: formOf(spec.network),
702
704
  // A synced folder's /workspace, the computer's user's, made by install before init.
703
705
  workspace: spec.mount?.kind === "sync",
706
+ windowManager,
704
707
  });
705
708
  const backstopAt = new Date(now + this.#maxLifetimeMs + BACKSTOP_MARGIN_MS).toISOString();
706
709
  const run = spec.labels?.[RUN_LABEL];
707
- const boot = this.#dialing ? await this.#boot(name, backstopAt, { deadline, user, maxDeadline, network: formOf(spec.network) }, sha256, typeof run === "string" ? run : undefined) : undefined;
710
+ const boot = this.#dialing ? await this.#boot(name, backstopAt, { deadline, user, maxDeadline, network: formOf(spec.network), windowManager }, sha256, typeof run === "string" ? run : undefined) : undefined;
708
711
  if (boot !== undefined && !boot.ok)
709
712
  return boot;
710
713
  const request = {
@@ -47,7 +47,7 @@ export interface HostedCommands {
47
47
  * the patterns a child's sockets command closes (default SESSION_BUSES); rootOnly the paths its root-only command takes
48
48
  * others' write off (default none). With workspace, install makes WORKSPACE the user's, 0700: a synced folder's.
49
49
  */
50
- export declare function hostedCommands({ staging, deadline, user, display, maxDeadline, atomic, waitS, gate, sha256, nonce, sockets, rootOnly, network, workspace, }?: ChildCommandOptions & {
50
+ export declare function hostedCommands({ staging, deadline, user, display, maxDeadline, atomic, waitS, gate, sha256, nonce, sockets, rootOnly, network, workspace, windowManager, }?: ChildCommandOptions & {
51
51
  atomic?: boolean;
52
52
  waitS?: number;
53
53
  gate?: string;
@@ -70,19 +70,21 @@ export interface ChildCommandOptions {
70
70
  maxDeadline?: string;
71
71
  /** The network form init's egress proxy serves (./network.ts networkFormOf): open, or allow: and a list; none, no proxy. */
72
72
  network?: string;
73
+ /** Init starts the desktop's window manager on the display (--window-manager): a desktop whose host runs one. */
74
+ windowManager?: boolean;
73
75
  }
74
76
  /**
75
77
  * init's flags, as start and a pid1 entrypoint give them: the deadline, the user, --own-network, and the most
76
- * deadline.extend may move it to and the network form where given. A dial machine's AGENTRUN_INIT_ARGS, space-separated:
77
- * no value holds a space.
78
+ * deadline.extend may move it to, the network form and --window-manager where given. A dial machine's
79
+ * AGENTRUN_INIT_ARGS, space-separated: no value holds a space.
78
80
  */
79
- export declare function initFlags({ deadline, user, maxDeadline, network }: Omit<ChildCommandOptions, "staging" | "display">): string[];
81
+ export declare function initFlags({ deadline, user, maxDeadline, network, windowManager }: Omit<ChildCommandOptions, "staging" | "display">): string[];
80
82
  /**
81
83
  * The three shell commands a child-daemon provider sends into a computer, exactly: install (the upload moved into place,
82
84
  * its sha256 printed), init (long-lived) and stdio (one per connection). Each is one string for a shell, `sh -c` with
83
85
  * every argument quoted.
84
86
  */
85
- export declare function childCommands({ staging, deadline, user, display, maxDeadline, network }?: ChildCommandOptions): {
87
+ export declare function childCommands({ staging, deadline, user, display, maxDeadline, network, windowManager }?: ChildCommandOptions): {
86
88
  install: string;
87
89
  init: string;
88
90
  stdio: string;
@@ -67,15 +67,17 @@ export function installerOf(output) {
67
67
  * them at the deadline. A display, when given, is init's DISPLAY, the X display its screen and input methods drive; a
68
68
  * maximum, when given, is the most deadline.extend may move the deadline to; a network form, when given (open, or
69
69
  * allow: and a list), has init start the egress proxy that serves it before it leaves the machine's network
70
- * (./network.ts). */
70
+ * (./network.ts); a ninth argument, when not empty, has init start the desktop's window manager on the display
71
+ * (--window-manager). */
71
72
  const INIT_SCRIPT = [
72
73
  "# agentrun-computer: init",
73
- // The display is v, not x: held() assigns x, and runs before the exec that reads it. The network form is n.
74
- "d=$1; t=$2; w=$3; h=$4; r=$5; v=${6-}; m=${7-}; n=${8-}",
74
+ // The display is v, not x: held() assigns x, and runs before the exec that reads it. The network form is n, the
75
+ // window manager g.
76
+ "d=$1; t=$2; w=$3; h=$4; r=$5; v=${6-}; m=${7-}; n=${8-}; g=${9-}",
75
77
  HELD,
76
78
  'held "$d" >&2 || exit 6',
77
79
  ROOT,
78
- `exec $p env -i PATH=${PATH} HOME="$h" AGENTRUN_COMPUTERD_SOCKET="$r/computerd.sock" \${v:+DISPLAY="$v"} sh -c 'cd "$HOME" && exec "$@"' sh "$d" init --deadline "$t" --user "$w" --own-network \${m:+--max-deadline "$m"} \${n:+--network "$n"}`,
80
+ `exec $p env -i PATH=${PATH} HOME="$h" AGENTRUN_COMPUTERD_SOCKET="$r/computerd.sock" \${v:+DISPLAY="$v"} sh -c 'cd "$HOME" && exec "$@"' sh "$d" init --deadline "$t" --user "$w" --own-network \${m:+--max-deadline "$m"} \${n:+--network "$n"} \${g:+--window-manager}`,
79
81
  ].join("\n");
80
82
  /** The bridge one connection runs: stdin and stdout to init's socket. As root, to reach a socket in a directory that is
81
83
  * the daemon's user's alone; it only carries bytes, and the command's user is root or has passwordless sudo already.
@@ -193,9 +195,9 @@ export const ARCHIL_GATE = `${DAEMON_IN_COMPUTER.slice(0, DAEMON_IN_COMPUTER.las
193
195
  * the patterns a child's sockets command closes (default SESSION_BUSES); rootOnly the paths its root-only command takes
194
196
  * others' write off (default none). With workspace, install makes WORKSPACE the user's, 0700: a synced folder's.
195
197
  */
196
- export function hostedCommands({ staging = "", deadline = "", user = TOOL_USER, display = "", maxDeadline = "", atomic = false, waitS = 600, gate, sha256 = "", nonce = "", sockets = SESSION_BUSES, rootOnly = [], network = "", workspace = false, } = {}) {
197
- const init = initScriptArgs({ deadline, user, display, maxDeadline, network });
198
- const initArgs = ["init", ...initFlags({ deadline, user, maxDeadline, network })];
198
+ export function hostedCommands({ staging = "", deadline = "", user = TOOL_USER, display = "", maxDeadline = "", atomic = false, waitS = 600, gate, sha256 = "", nonce = "", sockets = SESSION_BUSES, rootOnly = [], network = "", workspace = false, windowManager = false, } = {}) {
199
+ const init = initScriptArgs({ deadline, user, display, maxDeadline, network, windowManager });
200
+ const initArgs = ["init", ...initFlags({ deadline, user, maxDeadline, network, windowManager })];
199
201
  const atomicArgs = atomic ? ["1", sha256, nonce] : workspace ? ["", "", ""] : [];
200
202
  return {
201
203
  install: argvOf(INSTALL_SCRIPT, [staging, DAEMON_IN_COMPUTER, WORK, SOCKET_DIR, ...atomicArgs, ...(workspace ? [WORKSPACE, user] : [])]),
@@ -209,17 +211,28 @@ export function hostedCommands({ staging = "", deadline = "", user = TOOL_USER,
209
211
  }
210
212
  /**
211
213
  * init's flags, as start and a pid1 entrypoint give them: the deadline, the user, --own-network, and the most
212
- * deadline.extend may move it to and the network form where given. A dial machine's AGENTRUN_INIT_ARGS, space-separated:
213
- * no value holds a space.
214
+ * deadline.extend may move it to, the network form and --window-manager where given. A dial machine's
215
+ * AGENTRUN_INIT_ARGS, space-separated: no value holds a space.
214
216
  */
215
- export function initFlags({ deadline = "", user = TOOL_USER, maxDeadline = "", network = "" }) {
216
- return ["--deadline", deadline, "--user", user, "--own-network", ...(maxDeadline === "" ? [] : ["--max-deadline", maxDeadline]), ...(network === "" ? [] : ["--network", network])];
217
+ export function initFlags({ deadline = "", user = TOOL_USER, maxDeadline = "", network = "", windowManager = false }) {
218
+ return [
219
+ "--deadline",
220
+ deadline,
221
+ "--user",
222
+ user,
223
+ "--own-network",
224
+ ...(maxDeadline === "" ? [] : ["--max-deadline", maxDeadline]),
225
+ ...(network === "" ? [] : ["--network", network]),
226
+ ...(windowManager ? ["--window-manager"] : []),
227
+ ];
217
228
  }
218
229
  /** The init script's arguments: the daemon, the deadline, the user, home and the socket's folder, then the display, the
219
- * maximum and the network form, each empty when not given, where any of them is. */
220
- function initScriptArgs({ deadline = "", user = TOOL_USER, display = "", maxDeadline = "", network = "" }) {
230
+ * maximum, the network form and the window manager ("1"), each empty when not given, where any of them is. */
231
+ function initScriptArgs({ deadline = "", user = TOOL_USER, display = "", maxDeadline = "", network = "", windowManager = false }) {
221
232
  const init = [DAEMON_IN_COMPUTER, deadline, user, WORK, SOCKET_DIR];
222
- if (network !== "")
233
+ if (windowManager)
234
+ init.push(display, maxDeadline, network, "1");
235
+ else if (network !== "")
223
236
  init.push(display, maxDeadline, network);
224
237
  else if (display !== "" || maxDeadline !== "")
225
238
  init.push(display, maxDeadline);
@@ -230,8 +243,8 @@ function initScriptArgs({ deadline = "", user = TOOL_USER, display = "", maxDead
230
243
  * its sha256 printed), init (long-lived) and stdio (one per connection). Each is one string for a shell, `sh -c` with
231
244
  * every argument quoted.
232
245
  */
233
- export function childCommands({ staging = "", deadline = "", user = TOOL_USER, display = "", maxDeadline = "", network = "" } = {}) {
234
- const init = initScriptArgs({ deadline, user, display, maxDeadline, network });
246
+ export function childCommands({ staging = "", deadline = "", user = TOOL_USER, display = "", maxDeadline = "", network = "", windowManager = false } = {}) {
247
+ const init = initScriptArgs({ deadline, user, display, maxDeadline, network, windowManager });
235
248
  return {
236
249
  install: shellCommand(INSTALL_SCRIPT, [staging, DAEMON_IN_COMPUTER, WORK, SOCKET_DIR]),
237
250
  init: shellCommand(INIT_SCRIPT, init),
@@ -68,6 +68,11 @@ export interface HelloResult {
68
68
  display?: string;
69
69
  /** How init holds its programs off the computer's network, when it gave them one of their own (init --own-network). */
70
70
  fence?: NetworkFence;
71
+ /**
72
+ * The desktop's window manager computerd starts itself (init --window-manager), and how it goes. Absent where computerd
73
+ * starts none: a client whose host's desktops run one then starts it itself.
74
+ */
75
+ windowManager?: WindowManagerFact;
71
76
  /** The main screen, in points. Absent on a computer with no screen. */
72
77
  screen?: ScreenSize;
73
78
  /**
@@ -119,6 +124,15 @@ export type Feature = keyof typeof FEATURES;
119
124
  * no CAP_SYS_ADMIN). Either way the programs reach their own loopback alone.
120
125
  */
121
126
  export type NetworkFence = "netns" | "userns-netns";
127
+ /**
128
+ * The window manager computerd starts once the display answers: "starting" until it answers and through the manager's
129
+ * first second, "running" once the manager has run that second, "ended" when it ended or never started, with why in
130
+ * words (how it ended, when, and its last lines).
131
+ */
132
+ export interface WindowManagerFact {
133
+ state: "starting" | "running" | "ended";
134
+ why?: string;
135
+ }
122
136
  /** Every NetworkFence, as hello may report it. */
123
137
  export declare const NETWORK_FENCES: readonly NetworkFence[];
124
138
  export type PingParams = Record<string, never>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcha/agentrun-computer",
3
- "version": "0.1.0-beta.47",
3
+ "version": "0.1.0-beta.48",
4
4
  "description": "The open platform's computer protocol: a daemon in every computer, and one provisioner per vendor, starting with Docker.",
5
5
  "keywords": [
6
6
  "agentrun",