@parcha/agentrun-computer 0.1.0-beta.52 → 0.1.0-beta.53

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
@@ -1568,7 +1568,7 @@ the TTL.
1568
1568
  | `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 |
1569
1569
  | `isolation` | `container`, or `vm` with `sandboxClass: "linux-vm"` | the class comes from the snapshot |
1570
1570
  | `os` | `linux` | Linux classes only; Windows and macOS are not offered here |
1571
- | `daemon` | `child` | Daytona's toolbox daemon is the sandbox's first process, and init is started detached through a session command of it (above); on dial init is `agentrun-dial`'s child, and `agentrun-dial` the toolbox's entrypoint command ([Daytona on dial](#daytona-on-dial)) |
1571
+ | `daemon` | `child` | Daytona's toolbox daemon is the sandbox's first process, and init is started detached through a session command of it (above); on dial init is `agentrun-dial`'s child, and `agentrun-dial` a session command create starts ([Daytona on dial](#daytona-on-dial)) |
1572
1572
  | `networkReadBack` | `false` | the network is probed from inside, the same for every hosted vendor |
1573
1573
  | `groups` | `exec`, `files`, `processes` | the daemon's own, checked against its hello's `groups`, as is its `kind` |
1574
1574
  | `maxLifetimeMs` | 30 days | the cap `check` gives, through the shared `checkLifetime`; Daytona's TTL is whole minutes and documents no cap of its own |
@@ -1684,9 +1684,19 @@ Daytona also sweeps its own label through the host at its end (the report's `cle
1684
1684
 
1685
1685
  With `connect: "dial"` (a server's `daytonaConnect` setting, `COMPUTER_DAYTONA_CONNECT` for conformance; `exec` by
1686
1686
  default) a Daytona sandbox dials the server instead ([PROVIDERS.md](PROVIDERS.md#machines-that-dial-in)). The host has
1687
- no exec and no upload, and nothing goes through the toolbox: create sends the boot env as `CreateSandbox.env` and
1688
- `networkBlockAll: false` (the machine's root reaches the server; network none is init's, inside), and the snapshot's
1689
- entrypoint runs `agentrun-dial`. No Archil mount, no GPU, and not `image: "default"` (Daytona's default snapshot holds
1687
+ no exec and no upload: create sends the boot env as `CreateSandbox.env`, `AGENTRUN_ATTACH_URL` left out, and
1688
+ `networkBlockAll: false` (the machine's root reaches the server; network none is init's, inside). Once the sandbox reads
1689
+ `started` (within the create's time; `error` or `build_failed` fails create in Daytona's words), create starts
1690
+ `agentrun-dial` itself in a toolbox session of its own, `agentrun-dial`: one async session command, as root, that
1691
+ first takes others' access off each socket `/tmp/dbus-*` names (the sockets step the exec path runs before init), then
1692
+ `&& AGENTRUN_ATTACH_URL='<url>' exec /usr/local/bin/agentrun-dial`, so a step that fails starts nothing. It is the
1693
+ launch line E2B's dial runs (`dialLaunch`), with no rootOnly paths here. The URL is no secret; the token stays in the sandbox's
1694
+ env, which the command inherits, and is on no command line. A session Daytona refuses fails create in its words, and
1695
+ the sandbox is deleted. So the snapshot's entrypoint is not relied on: a box snapshot registered without one (name,
1696
+ image and resources alone) dials too, and one whose entrypoint is the box CMD sleeps, with no `AGENTRUN_ATTACH_URL` in
1697
+ its env, so `agentrun-dial` never runs twice. A machine that does not dial within `createMs` fails with the session
1698
+ command's log, its last 10 lines within 800 characters (`dialLog`, the token replaced by `<token>`), or "agentrun-dial
1699
+ never started" when the session is none. No Archil mount, no GPU, and not `image: "default"` (Daytona's default snapshot holds
1690
1700
  no `agentrun-dial`): `check()` refuses each in words. Labels as on exec. A dial sandbox may be a desktop
1691
1701
  (`kind: "desktop"`): the box snapshot's X server, started over the socket it dialed, and xfwm4, which computerd starts
1692
1702
  (init's `--window-manager`), at the snapshot's 2 CPUs and 4 GiB, with no GPU. On exec a Daytona computer is kind
@@ -1698,13 +1708,15 @@ What each part of a dial sandbox rests on:
1698
1708
  whose tag is not `latest`, `lts` or `stable` ([docs: create snapshots](https://www.daytona.io/docs/en/snapshots.md#create-snapshots)).
1699
1709
  The one that holds `agentrun-dial` is the box image's, `agentrun-box-<recipe hash>`: `box/build-daytona.py`
1700
1710
  builds it from `box/Dockerfile`, or `POST /snapshots` makes it from the published
1701
- `ghcr.io/parcha-ai/agentrun-box:<recipe hash>` with the same `entrypoint`. The conformance module's run image on
1711
+ `ghcr.io/parcha-ai/agentrun-box:<recipe hash>`, with or without the same `entrypoint`. The conformance module's run image on
1702
1712
  dial is that name. A snapshot carries its own resources: a create that names one sends none (400 "Cannot specify
1703
1713
  Sandbox resources when using a snapshot", live 11-11).
1704
1714
  - **The boot env reaches `agentrun-dial`.** The runner puts `env` in the container's env
1705
1715
  ([runner container_configs.go:87](https://github.com/daytonaio/daytona/blob/b5a5d9e7/apps/runner/pkg/docker/container_configs.go#L87)),
1706
1716
  and the toolbox's session shell takes the toolbox's env (`cmd.Env = os.Environ()`,
1707
1717
  [daemon session/create.go:23-24](https://github.com/daytonaio/daytona/blob/b5a5d9e7/apps/daemon/pkg/session/create.go#L23-L24)).
1718
+ Live (11-22): a value set in create's `env` was echoed by a session command, which runs as root, and `runAsync` works.
1719
+ `AGENTRUN_ATTACH_URL` comes from the command's own line.
1708
1720
  - **The image's CMD never runs; the snapshot's entrypoint does.** The container's entrypoint is the toolbox daemon, and
1709
1721
  its arguments are the snapshot's entrypoint, else the image's ENTRYPOINT, never its CMD
1710
1722
  ([runner container_configs.go:143-173](https://github.com/daytonaio/daytona/blob/b5a5d9e7/apps/runner/pkg/docker/container_configs.go#L143-L173));
@@ -1712,9 +1724,11 @@ What each part of a dial sandbox rests on:
1712
1724
  ([daemon main.go:129-164](https://github.com/daytonaio/daytona/blob/b5a5d9e7/apps/daemon/cmd/daemon/main.go#L129-L164)).
1713
1725
  A snapshot built from a Dockerfile with no ENTRYPOINT gets `sleep infinity`
1714
1726
  ([api snapshot.service.ts:883-901](https://github.com/daytonaio/daytona/blob/b5a5d9e7/apps/api/src/sandbox/services/snapshot.service.ts#L883-L901)),
1715
- so `box/build-daytona.py` names the Dockerfile's CMD as the snapshot's `entrypoint`. The box snapshots it built
1716
- before, `agentrun-archil-<recipe hash>`, have none and never dial, so the snapshot it builds now has a name of its
1717
- own, `agentrun-box-<recipe hash>`, which no snapshot without the entrypoint holds.
1727
+ so `box/build-daytona.py` names the Dockerfile's CMD as the snapshot's `entrypoint`. The provider no longer needs
1728
+ it: a snapshot registered another way (an operator's tooling that sends name, image and resources alone) has no
1729
+ entrypoint, its pid 1 is the bare toolbox daemon and the toolbox has no entrypoint session (404 "session not found",
1730
+ live 11-22), and before create started `agentrun-dial` itself such a sandbox never dialed and failed at
1731
+ `createMs` with no word of why.
1718
1732
  - **Outbound https, by tier.** Tier 1 and 2 organizations reach "essential services" alone, and those leave out shared
1719
1733
  hosting domains; Tier 3 and 4 have full access
1720
1734
  ([docs: tier-based network restrictions](https://www.daytona.io/docs/en/network-limits.md#tier-based-network-restrictions)).
@@ -1741,9 +1755,9 @@ What each part of a dial sandbox rests on:
1741
1755
  ([api sandbox.dto.ts:84](https://github.com/daytonaio/daytona/blob/b5a5d9e7/apps/api/src/sandbox/dto/sandbox.dto.ts#L84)),
1742
1756
  so whoever holds the API key reads the machine's token; that key already runs root in the sandbox through the
1743
1757
  toolbox. The token is the machine's alone, and revoked at its delete.
1744
- - **Unverified**: whether a box-image sandbox has a D-Bus session bus in `/tmp` (on exec, create closes `/tmp/dbus-*`
1745
- to the computer's user through the toolbox; on dial there is no exec, so nothing does), and the `linux-vm` class on
1746
- dial.
1758
+ - **Unverified**: whether a box-image sandbox has a D-Bus session bus in `/tmp` (create closes `/tmp/dbus-*` to the
1759
+ computer's user either way: on exec through the toolbox before init, on dial in `agentrun-dial`'s launch line), and
1760
+ the `linux-vm` class on dial.
1747
1761
 
1748
1762
  ### Not yet known
1749
1763
 
package/box/README.md CHANGED
@@ -24,4 +24,7 @@ files it copies (`recipe.mjs`). A changed recipe is a new image, and the same re
24
24
  Each release publishes it (`.github/workflows/release.yml`, the `box` job) as `ghcr.io/parcha-ai/agentrun-box:<recipe hash>`
25
25
  and `:<release tag>`, for linux/amd64, and builds the public E2B template `agentrun-archil-<recipe hash>` from it in the
26
26
  same job, which E2B's provider starts in any account as `boxE2bTemplate()` (`src/box-image.ts`). The build-*
27
- scripts here say how to build it for each provider.
27
+ scripts here say how to build it for each provider. `build-daytona.py --documents` builds it with the documents layer
28
+ on top (`../documents/documents.sh`, the libraries that write Office files, which the Docker box's documents image runs
29
+ too) as a snapshot of its own, `agentrun-documents-<hash>`, the hash covering this recipe and that layer: this recipe's
30
+ hash, and the snapshot named by it, stay as they are.
@@ -14,11 +14,19 @@
14
14
  # The snapshot's entrypoint is the Dockerfile's CMD, named: Daytona's toolbox runs a snapshot's entrypoint as its first
15
15
  # command, and a snapshot built from a Dockerfile with no ENTRYPOINT gets `sleep infinity` instead, never the CMD
16
16
  # (daytonaio/daytona@b5a5d9e7 apps/api/src/sandbox/services/snapshot.service.ts:883-901). That CMD starts agentrun-dial
17
- # when the create set AGENTRUN_ATTACH_URL (a Daytona computer on connect "dial"), and sleeps otherwise. The name is
18
- # agentrun-box-<hash>: the agentrun-archil-<hash> snapshots built before this named no entrypoint, so they never dial,
19
- # and a new name keeps a run from landing on one.
17
+ # when AGENTRUN_ATTACH_URL is in the sandbox's env, and sleeps otherwise. The provider no longer needs it: on connect
18
+ # "dial" its create leaves AGENTRUN_ATTACH_URL out of the env and starts agentrun-dial in a toolbox session itself, so a
19
+ # box snapshot registered without this entrypoint dials too, and this one sleeps instead of dialing twice. The name is
20
+ # agentrun-box-<hash>, the recipe's hash alone (this file is not in it).
20
21
  #
21
- # python3 packages/computer/box/build-daytona.py [--gpu H100]
22
+ # With --documents, the box image with the documents layer run on top (../documents/documents.sh, the libraries that
23
+ # write decks, documents and sheets, which the Docker box's documents image runs too), as its own snapshot:
24
+ # agentrun-documents-<hash>, the hash covering the box recipe and documents.sh, so agentrun-box-<hash> stays what it
25
+ # was. AGENTRUN_DAYTONA_SNAPSHOT names it for a server whose agents need those libraries (computer.needs).
26
+ #
27
+ # --documents takes no --gpu: the GPU snapshot is the box image's alone.
28
+ #
29
+ # python3 packages/computer/box/build-daytona.py [--gpu H100 | --documents]
22
30
  import hashlib
23
31
  import json
24
32
  import os
@@ -29,22 +37,37 @@ from daytona import CreateSnapshotParams, Daytona, GpuType, Image, Resources
29
37
  GPUS = {"H100": GpuType.H100}
30
38
 
31
39
  args = sys.argv[1:]
40
+ usage = f"usage: build-daytona.py [--gpu {'|'.join(GPUS)} | --documents]"
41
+ documents = "--documents" in args
42
+ if documents:
43
+ args.remove("--documents")
44
+ # The documents layer is for a CPU box: no GPU snapshot of it, whose name daytonaGpuSnapshot() would not take.
45
+ if args:
46
+ sys.exit("build-daytona.py: --documents builds the CPU box's documents snapshot alone; drop --gpu")
32
47
  gpu = None
33
48
  if args:
34
49
  if len(args) != 2 or args[0] != "--gpu" or args[1] not in GPUS:
35
- sys.exit(f"usage: build-daytona.py [--gpu {'|'.join(GPUS)}]")
50
+ sys.exit(usage)
36
51
  gpu = args[1]
37
52
 
38
53
  here = os.path.dirname(os.path.abspath(__file__))
39
54
  recipe = b"".join(open(os.path.join(here, name), "rb").read() for name in ("Dockerfile", "install.sh", "agentrun-archil"))
55
+ # The documents layer's folder, with a trailing separator: Daytona's SDK then files documents.sh at the top of the
56
+ # build's context as documents.sh, beside the box's install.sh, never over it.
57
+ layer = os.path.join(os.path.dirname(here), "documents", "")
58
+ if documents:
59
+ recipe += open(os.path.join(layer, "documents.sh"), "rb").read()
40
60
  digest = hashlib.sha256(recipe).hexdigest()[:12]
41
- name = f"agentrun-archil-gpu-{gpu.lower()}-{digest}" if gpu else f"agentrun-box-{digest}"
61
+ name = f"agentrun-archil-gpu-{gpu.lower()}-{digest}" if gpu else f"agentrun-documents-{digest}" if documents else f"agentrun-box-{digest}"
62
+ image = Image.from_dockerfile(os.path.join(here, "Dockerfile"))
63
+ if documents:
64
+ image = image.dockerfile_commands(["COPY documents.sh /tmp/agentrun-documents/documents.sh", "RUN sh /tmp/agentrun-documents/documents.sh && rm -rf /tmp/agentrun-documents"], context_dir=layer)
42
65
  cmd = [json.loads(line[4:]) for line in open(os.path.join(here, "Dockerfile")).read().splitlines() if line.startswith("CMD ")][-1]
43
66
  print(f"build-daytona: snapshot {name}", file=sys.stderr)
44
67
  Daytona().snapshot.create(
45
68
  CreateSnapshotParams(
46
69
  name=name,
47
- image=Image.from_dockerfile(os.path.join(here, "Dockerfile")),
70
+ image=image,
48
71
  entrypoint=cmd,
49
72
  resources=Resources(cpu=16, memory=100, disk=400, gpu=1, gpu_type=GPUS[gpu]) if gpu else Resources(cpu=2, memory=4, disk=10),
50
73
  **({"region_id": "earth"} if gpu else {}),
Binary file
Binary file
@@ -1,4 +1,4 @@
1
1
  {
2
- "version": "0.1.0-beta.52",
2
+ "version": "0.1.0-beta.53",
3
3
  "source": "sha256:704cb76aa815c7c8e06d6efb4c386314effcdfc1c88b6c1ee55b981abad45d8d"
4
4
  }
package/dist/daytona.d.ts CHANGED
@@ -65,8 +65,9 @@ export interface DaytonaProviderOptions extends Omit<HostedOptions, "desktop" |
65
65
  autoDeleteMinutes?: number;
66
66
  /**
67
67
  * exec (default): the daemon goes in through the toolbox's file API and each connection is a session command. dial:
68
- * the sandbox gets the boot env as its env, and its snapshot's entrypoint, the box image's CMD, runs agentrun-dial; the
69
- * machine dials the server (options.dial), which every connection goes over. No Archil mount and no GPU on dial.
68
+ * the sandbox gets the boot env as its env but AGENTRUN_ATTACH_URL, and create starts agentrun-dial with the URL in a
69
+ * session command of its own; the machine dials the server (options.dial), which every connection goes over. No
70
+ * Archil mount and no GPU on dial.
70
71
  */
71
72
  connect?: "exec" | "dial";
72
73
  /** For tests: every request goes through it. Default the global fetch. */
package/dist/daytona.js CHANGED
@@ -2,10 +2,11 @@
2
2
  // sandbox's first process, so computerd is a child: its upload goes through the toolbox's file API, and every command
3
3
  // (install, init's start, the stdio bridge, an Archil computer's root steps) is a session command, its output read from
4
4
  // the command's log stream and its stdin sent as the command's input. With connect "dial", the sandbox is made with the
5
- // boot env as its env, and the snapshot's entrypoint (box/build-daytona.py names the box image's CMD) runs agentrun-dial
6
- // in the toolbox's entrypoint session: the machine dials the server, with no upload and no session command. The rest of
7
- // the computer is the shared machine-host adapter's (./hosted/provider.ts). Every Daytona fact used here is cited in the
8
- // README's Daytona section.
5
+ // boot env as its env, AGENTRUN_ATTACH_URL left out, and once it reads started create runs agentrun-dial, the URL given
6
+ // on its line, as one session command of its own: the machine dials the server, with no upload. A snapshot's entrypoint
7
+ // is never relied on (one registered without the box CMD as its entrypoint has none), and one that runs the box CMD
8
+ // sleeps without the URL, so agentrun-dial never runs twice. The rest of the computer is the shared machine-host
9
+ // adapter's (./hosted/provider.ts). Every Daytona fact used here is cited in the README's Daytona section.
9
10
  import { randomBytes } from "node:crypto";
10
11
  import { connectOf, kindRefusal, mountsOf } from "./descriptor.js";
11
12
  import { DAYTONA, DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU, DAYTONA_GPU_REGION, DAYTONA_GPU_SNAPSHOT, daytonaGpuSnapshot } from "./descriptors/daytona.js";
@@ -13,9 +14,9 @@ import { COMPUTER_LABEL } from "./drift.js";
13
14
  import { HostError } from "./host.js";
14
15
  import { framedExec } from "./hosted/framed-exec.js";
15
16
  import { HostedProvider, timeoutsOf } from "./hosted/provider.js";
16
- import { boundOf, orThrow, pause as sleep } from "./hosted/process.js";
17
+ import { boundOf, orThrow, seconds, pause as sleep, words } from "./hosted/process.js";
17
18
  import { allPages, jsonOf, rest } from "./hosted/rest.js";
18
- import { shellLine } from "./hosted/scripts.js";
19
+ import { dialLaunch, shellLine } from "./hosted/scripts.js";
19
20
  import { dateOf, isWhole, sizeRefusals } from "./hosted/values.js";
20
21
  import { MAX_LINE_BYTES } from "./protocol.js";
21
22
  import { checkGpu } from "./provider.js";
@@ -64,6 +65,8 @@ const OUT = Buffer.from([1, 1, 1]);
64
65
  const ERR = Buffer.from([2, 2, 2]);
65
66
  /** A line the client wrote, echoed back: a request or a notification is never a daemon's reply. */
66
67
  const ECHO = /^\{"jsonrpc":"2\.0",("id":\d+,)?"method":/;
68
+ /** The toolbox session a dial sandbox's agentrun-dial runs in, its one command: dialLog reads its log by this id. */
69
+ const DIAL_SESSION = "agentrun-dial";
67
70
  const decoder = new TextDecoder();
68
71
  /**
69
72
  * Why a dial computer takes no GPU: check() refuses one in these words, and capabilities() declares none on dial.
@@ -121,6 +124,10 @@ class DaytonaHost {
121
124
  /** connect exec alone: a dial host has neither (HostFacts.connect). */
122
125
  exec;
123
126
  upload;
127
+ /** connect dial alone: agentrun-dial's session command's log. */
128
+ dialLog;
129
+ /** Each dial sandbox's machine token, by id, from its create: dialLog's words never hold it. Let go of at its delete. */
130
+ #dialTokens = new Map();
124
131
  /** Daytona's REST API: the control plane, and the toolbox of each sandbox. */
125
132
  #rest;
126
133
  #headers;
@@ -148,7 +155,7 @@ class DaytonaHost {
148
155
  // its own. The toolbox listens on 2280 on every interface and runs commands for whoever reaches it, so init starts
149
156
  // with --own-network, and network none is all a computer takes. Its D-Bus session bus in /tmp (/tmp/dbus-*), which
150
157
  // no network namespace cuts, is closed to the tool user before init starts, as on every child host. On dial init is
151
- // agentrun-dial's child, and agentrun-dial the entrypoint the toolbox runs in a session of its own: still a child.
158
+ // agentrun-dial's child, and agentrun-dial a session command create starts through the toolbox: still a child.
152
159
  this.facts = {
153
160
  daemon: "child",
154
161
  isolation: options.sandboxClass === "linux-vm" ? "vm" : "container",
@@ -166,6 +173,8 @@ class DaytonaHost {
166
173
  this.exec = (id, argv, ctx) => this.#exec(id, argv, ctx);
167
174
  this.upload = (id, path, bytes, ctx) => this.#upload(id, path, bytes, ctx);
168
175
  }
176
+ else
177
+ this.dialLog = (id, ctx) => this.#dialLog(id, ctx);
169
178
  }
170
179
  /**
171
180
  * A snapshot name has no control characters, and its size is the snapshot's; a GPU computer is made from the
@@ -214,16 +223,19 @@ class DaytonaHost {
214
223
  * races it, and deletes by name one whose answer never comes. A name Daytona already holds (409) made nothing: exists,
215
224
  * and the adapter adopts the sandbox the name lists, as a retry does. req.backstopAt is left: the TTL is Daytona's own
216
225
  * timer at the deadline (lifetime "vendor"), and autoDeleteInterval counts from a stop, not from create. A dial
217
- * machine's boot env is the sandbox's env, which the toolbox's entrypoint session inherits (README, Daytona on dial).
226
+ * machine's boot env but AGENTRUN_ATTACH_URL is the sandbox's env, which every session command inherits, and create
227
+ * then starts agentrun-dial within ctx.timeoutMs (#startDial; README, Daytona on dial).
218
228
  */
219
229
  async create(req, ctx) {
230
+ const until = Date.now() + ctx.timeoutMs;
220
231
  const gpu = req.gpu !== undefined;
232
+ const { AGENTRUN_ATTACH_URL: attach, ...env } = req.boot?.env ?? {};
221
233
  const body = {
222
234
  name: req.name,
223
235
  // "default" sends no snapshot, and Daytona makes the sandbox from its default snapshot.
224
236
  ...(gpu ? { snapshot: this.#gpu.snapshot } : req.image === DAYTONA_DEFAULT_SNAPSHOT ? {} : { snapshot: req.image }),
225
237
  labels: { ...req.labels },
226
- env: { ...req.boot?.env },
238
+ env,
227
239
  public: false,
228
240
  // A GPU sandbox runs in region earth alone, whatever the provider's target.
229
241
  ...(gpu ? { target: DAYTONA_GPU_REGION } : this.#target === undefined ? {} : { target: this.#target }),
@@ -238,11 +250,69 @@ class DaytonaHost {
238
250
  // GPU is the snapshot's, held by the adapter's GPU label.
239
251
  };
240
252
  const posted = await this.#rest.json("POST", sandboxUrl(this.#rest), { json: body, timeoutMs: ctx.timeoutMs, named: true });
241
- const id = orThrow(posted)?.id;
253
+ const sb = orThrow(posted);
254
+ const id = sb?.id;
242
255
  if (typeof id !== "string" || id === "")
243
256
  throw new Error("POST /sandbox: no sandbox id in the answer");
257
+ if (req.boot !== undefined) {
258
+ const token = req.boot.env.AGENTRUN_ATTACH_TOKEN;
259
+ if (token !== undefined && token !== "")
260
+ this.#dialTokens.set(id, token);
261
+ await this.#startDial(sb, attach ?? "", until, ctx.timeoutMs);
262
+ }
244
263
  return { id };
245
264
  }
265
+ /**
266
+ * A dial sandbox's agentrun-dial, started once the sandbox reads started (by `until`, ms after create began): one
267
+ * toolbox session of its own (DIAL_SESSION), its one command async: dialLaunch's line, as root (the toolbox runs
268
+ * session commands as root), AGENTRUN_ATTACH_URL a quoted assignment on it. The token is never on it: it stays in the sandbox's env, which the command inherits. The session is kept, so
269
+ * its log is the dial's last words (dialLog). A sandbox Daytona fails, one gone, or a session or command it refuses
270
+ * throws vendor in Daytona's words, and one not started by `until` throws timeout: either is a create that made a
271
+ * machine to the adapter, which deletes it by its name.
272
+ */
273
+ async #startDial(posted, attach, until, timeoutMs) {
274
+ const { id } = posted;
275
+ let sb = posted;
276
+ while (sb.state !== "started") {
277
+ if (FAILED.has(sb.state ?? "") || GONE.has(sb.state ?? ""))
278
+ throw new HostError("vendor", `Daytona reads the sandbox ${id} ${sb.state}, so agentrun-dial was not started: ${sb.errorReason || "no reason given"}`);
279
+ if (Date.now() + this.#pollMs >= until)
280
+ throw new HostError("timeout", `the sandbox ${id} did not read started within ${seconds(timeoutMs)} (it reads ${sb.state ?? "no state"}), so agentrun-dial was not started`);
281
+ await sleep(this.#pollMs);
282
+ const read = await sandboxOf(this.#rest, id);
283
+ if (!read.ok)
284
+ throw new HostError("vendor", `reading the sandbox ${id} while it starts failed: ${read.error.message}`);
285
+ if (read.value === undefined)
286
+ throw new HostError("vendor", `Daytona no longer has the sandbox ${id}, so agentrun-dial was not started`);
287
+ sb = read.value;
288
+ }
289
+ try {
290
+ const toolbox = await this.#toolbox(id);
291
+ await this.#runAsync(toolbox, DIAL_SESSION, dialLaunch({ rootOnly: this.facts.rootOnly, attach }), Math.max(1, until - Date.now()));
292
+ }
293
+ catch (error) {
294
+ throw new HostError("vendor", `starting agentrun-dial in ${id} failed: ${words(error)}`);
295
+ }
296
+ }
297
+ /**
298
+ * What agentrun-dial wrote: its session command's log (the toolbox's JSON of it, or its text with Daytona's stream
299
+ * prefixes dropped), the sandbox's token replaced by `<token>`. undefined when the session, or its command, is none.
300
+ */
301
+ async #dialLog(id, ctx) {
302
+ const session = `${await this.#toolbox(id, ctx.signal)}/process/session/${DIAL_SESSION}`;
303
+ const read = await this.#rest.json("GET", session, { retry: true, timeoutMs: ctx.timeoutMs }, ctx.signal);
304
+ if (!read.ok && read.error.code === "not_found")
305
+ return undefined;
306
+ const command = (orThrow(read)?.commands ?? []).findLast((one) => typeof one?.id === "string");
307
+ if (command === undefined)
308
+ return undefined;
309
+ const logs = orThrow(await this.#rest.call("GET", `${session}/command/${encodeURIComponent(command.id)}/logs`, { retry: true, timeoutMs: ctx.timeoutMs }, ctx.signal));
310
+ const json = jsonOf(logs.bytes);
311
+ const text = typeof json?.output === "string" ? json.output : typeof json?.stdout === "string" || typeof json?.stderr === "string" ? `${json.stdout ?? ""}${json.stderr ?? ""}` : decoder.decode(logs.bytes);
312
+ const said = text.replaceAll(OUT.toString("latin1"), "").replaceAll(ERR.toString("latin1"), "");
313
+ const token = this.#dialTokens.get(id);
314
+ return token === undefined ? said : said.replaceAll(token, "<token>");
315
+ }
246
316
  /** GET /sandbox/{id}; one Daytona answers 404 for, or reads destroyed, is none. */
247
317
  async get(id, ctx) {
248
318
  const found = orThrow(await sandboxOf(this.#rest, id, ctx.signal));
@@ -282,6 +352,7 @@ class DaytonaHost {
282
352
  */
283
353
  async delete(id, ctx) {
284
354
  this.#toolboxes.delete(id);
355
+ this.#dialTokens.delete(id);
285
356
  let failure;
286
357
  for (let attempt = 1; attempt <= DELETE_ATTEMPTS; attempt++) {
287
358
  const removed = await this.#rest.call("DELETE", sandboxUrl(this.#rest, id), { retry: true, timeoutMs: ctx.timeoutMs });
@@ -388,16 +459,23 @@ class DaytonaHost {
388
459
  },
389
460
  };
390
461
  }
391
- async #startCommand(toolbox, argv, ctx) {
392
- const sessionId = `agentrun-${randomBytes(8).toString("hex")}`;
462
+ /**
463
+ * A session of its own (sessionId) in the toolbox, with one command run in it async, no input echo: its session's URL
464
+ * and the command's id. A command Daytona does not take removes the session again.
465
+ */
466
+ async #runAsync(toolbox, sessionId, command, timeoutMs, signal) {
393
467
  const session = `${toolbox}/process/session/${sessionId}`;
394
- orThrow(await this.#rest.call("POST", `${toolbox}/process/session`, { json: { sessionId }, timeoutMs: ctx.timeoutMs }, ctx.signal));
395
- const ran = await this.#rest.json("POST", `${session}/exec`, { json: { command: shellLine(argv), runAsync: true, suppressInputEcho: true }, timeoutMs: ctx.timeoutMs }, ctx.signal);
468
+ orThrow(await this.#rest.call("POST", `${toolbox}/process/session`, { json: { sessionId }, timeoutMs }, signal));
469
+ const ran = await this.#rest.json("POST", `${session}/exec`, { json: { command, runAsync: true, suppressInputEcho: true }, timeoutMs }, signal);
396
470
  const commandId = ran.ok ? ran.value?.cmdId : undefined;
397
471
  if (!ran.ok || typeof commandId !== "string") {
398
472
  await this.#rest.call("DELETE", session, {});
399
473
  throw ran.ok ? new Error("POST exec: no command id in the answer") : new HostError(ran.error.code, ran.error.message);
400
474
  }
475
+ return { session, commandId };
476
+ }
477
+ async #startCommand(toolbox, argv, ctx) {
478
+ const { session, commandId } = await this.#runAsync(toolbox, `agentrun-${randomBytes(8).toString("hex")}`, shellLine(argv), ctx.timeoutMs, ctx.signal);
401
479
  let socket;
402
480
  try {
403
481
  socket = this.#webSocket(`${session.replace(/^https:/, "wss:")}/command/${encodeURIComponent(commandId)}/logs?follow=true`, { headers: this.#headers, protocols: [] });
package/dist/e2b.js CHANGED
@@ -4,7 +4,7 @@ import { DEADLINE_LABEL, show } from "./drift.js";
4
4
  import { installedProxy, proxyForDomain } from "./env-proxy.js";
5
5
  import { HostError } from "./host.js";
6
6
  import { deadlineOf, HostedProvider, isoOf, MAX_LABEL, timeoutsOf } from "./hosted/provider.js";
7
- import { AGENTRUN_DIAL, hostedCommands, shellLine } from "./hosted/scripts.js";
7
+ import { dialLaunch } from "./hosted/scripts.js";
8
8
  import { connectOf } from "./descriptor.js";
9
9
  import { dateOf, DOMAIN, isWhole, sizeRefusals } from "./hosted/values.js";
10
10
  import { PassThrough } from "node:stream";
@@ -75,16 +75,9 @@ const DIAL_LOG = "/run/agentrun-dial.log";
75
75
  /**
76
76
  * A dial machine's launch, root's command with boot env: E2B runs a template's start command once, at the template's
77
77
  * build, and snapshots it running, so it never sees a create's env (docs.e2b.dev/template/start-ready-command). So
78
- * create starts agentrun-dial itself, after the steps the exec path runs before init: ROOT_ONLY made root's alone, the
79
- * session buses in /tmp closed. A step that fails starts nothing, and the machine never dials.
78
+ * create starts agentrun-dial itself (dialLaunch), the URL in the boot env.
80
79
  */
81
- const DIAL_LAUNCH = [
82
- "-c",
83
- [
84
- `umask 077; exec >>${DIAL_LOG} 2>&1 </dev/null`,
85
- `${shellLine(hostedCommands({ rootOnly: ROOT_ONLY }).rootOnly)} && ${shellLine(hostedCommands().sockets)} && exec ${AGENTRUN_DIAL}`,
86
- ].join("\n"),
87
- ];
80
+ const DIAL_LAUNCH = ["-c", [`umask 077; exec >>${DIAL_LOG} 2>&1 </dev/null`, dialLaunch({ rootOnly: ROOT_ONLY })].join("\n")];
88
81
  /** The SDK names its errors (index.mjs:86-360); Connect's carry a code. */
89
82
  function codeOf(error) {
90
83
  const name = error?.name;
package/dist/host.d.ts CHANGED
@@ -83,6 +83,13 @@ export interface MachineHost {
83
83
  * streams the file through exec's stdin as base64 text, which root decodes (`base64 -d`, in coreutils and busybox).
84
84
  */
85
85
  upload?(id: string, path: string, bytes: Uint8Array, ctx: HostCall): Promise<void>;
86
+ /**
87
+ * What agentrun-dial wrote in a dial machine, for a create whose machine never dialed: the adapter adds its last lines
88
+ * to the timeout's words. undefined when agentrun-dial never started there. A host that started agentrun-dial itself
89
+ * and can read its output has it (Daytona's: its session command's log); it replaces the machine's token with
90
+ * `<token>` should agentrun-dial have written it. A read that fails throws, and the timeout's words stay as they were.
91
+ */
92
+ dialLog?(id: string, ctx: HostCall): Promise<string | undefined>;
86
93
  /**
87
94
  * The code of an error the vendor's client threw: one of ComputerErrorCode. Optional: the adapter reads a HostError's
88
95
  * own code, an AbortError as "aborted" and a TimeoutError as "timeout" itself, and anything else a host does not map
@@ -68,6 +68,9 @@ const LISTED_POLL_MS = 150;
68
68
  const LISTED_ROUNDS = 2;
69
69
  const LISTEN_RETRY_MS = 250;
70
70
  const START_POLL_MS = 500;
71
+ /** How much of agentrun-dial's output a dial timeout carries (MachineHost.dialLog): its last lines, cut to these characters. */
72
+ const DIAL_LOG_LINES = 10;
73
+ const DIAL_LOG_CHARS = 800;
71
74
  /**
72
75
  * The computerd build a hosted machine of arch runs: HostedProvider's default daemonPath, and the file serve's daemon
73
76
  * route serves, so the sha256 a dial machine checks (AGENTRUN_DAEMON_SHA256) is this file's.
@@ -1121,7 +1124,7 @@ export class HostedProvider {
1121
1124
  const dialed = this.#dialed();
1122
1125
  const to = "problem" in dialed ? "this server" : dialed.attach;
1123
1126
  const through = this.#attachEgress === undefined ? "" : ` through ${this.#attachEgress}`;
1124
- return this.#fail("timeout", `${ref.name} did not dial ${to}${through} within ${seconds(createMs)}: the machine must reach that address, and run agentrun-dial (the box image's entrypoint while AGENTRUN_ATTACH_URL is set)`);
1127
+ return this.#fail("timeout", `${ref.name} did not dial ${to}${through} within ${seconds(createMs)}: the machine must reach that address, and run agentrun-dial (the box image's entrypoint while AGENTRUN_ATTACH_URL is set, or the provider's own start of it)${await this.#dialWords(ref, signal)}`);
1125
1128
  }
1126
1129
  const polled = pause(Math.min(this.#startPollMs(), left), signal).then(() => false);
1127
1130
  reading ??= this.#dialRefused(ref.name, Math.min(requestMs, left), signal);
@@ -1136,6 +1139,23 @@ export class HostedProvider {
1136
1139
  return this.#fail("aborted", `create was aborted while it waited for ${ref.name} to dial`);
1137
1140
  }
1138
1141
  }
1142
+ /**
1143
+ * A dial timeout's last words: what the host's dialLog read of agentrun-dial, its last DIAL_LOG_LINES lines within
1144
+ * DIAL_LOG_CHARS characters, or that it never started. Nothing for a host without dialLog, or a read that fails,
1145
+ * outlasts requestMs or is cut by the create's signal, so a cancel never waits on it.
1146
+ */
1147
+ async #dialWords(ref, signal) {
1148
+ const { dialLog } = this.host;
1149
+ if (dialLog === undefined)
1150
+ return "";
1151
+ const read = await this.#call(`the dial log of ${ref.name}`, (ctx) => dialLog.call(this.host, ref.id, ctx), this.#timeouts.requestMs, signal);
1152
+ if (!read.ok)
1153
+ return "";
1154
+ if (read.value === undefined)
1155
+ return "; agentrun-dial never started";
1156
+ const lines = read.value.split(/\r?\n/).map((line) => line.trim()).filter((line) => line !== "");
1157
+ return lines.length === 0 ? "; agentrun-dial wrote nothing" : `; agentrun-dial said: ${lines.slice(-DIAL_LOG_LINES).join(" | ").slice(-DIAL_LOG_CHARS)}`;
1158
+ }
1139
1159
  /**
1140
1160
  * Its tools' network as they meet it, against the one create made: the probe, as the computer's own user. Under none,
1141
1161
  * no target answers. Under open or a list, still none answers directly (their own loopback alone), init's relay
@@ -3,6 +3,8 @@ import type { ComputerCapabilities, ComputerConnection } from "../provider.js";
3
3
  import { type Result } from "../result.js";
4
4
  /** Who ran install, from its output's `installer <uid> <name>[ sudo]` line, in words; undefined when it has none. */
5
5
  export declare function installerOf(output: string): string | undefined;
6
+ /** One word for a shell, single-quoted. */
7
+ export declare const quote: (word: string) => string;
6
8
  /** One string for a shell: `sh -c '<script>' sh '<arg>' ...`, every word quoted. */
7
9
  export declare const shellCommand: (script: string, args: readonly string[]) => string;
8
10
  /** One argv as one shell line, every word but a plain one ("sh", "-c") single-quoted: for a vendor whose exec takes a line. */
@@ -57,6 +59,16 @@ export declare function hostedCommands({ staging, deadline, user, display, maxDe
57
59
  rootOnly?: readonly string[];
58
60
  workspace?: boolean;
59
61
  }): HostedCommands;
62
+ /**
63
+ * The shell line a provider that starts agentrun-dial itself runs, as root. On dial the adapter runs nothing in the
64
+ * machine, so the line runs the steps the exec path runs before init first: rootOnly made root's alone when it names
65
+ * paths (HostFacts.rootOnly), then the session buses in /tmp closed (SESSION_BUSES). Joined by &&, so a step that fails
66
+ * starts nothing, and the machine never dials. attach, when given, is AGENTRUN_ATTACH_URL's quoted assignment on the line.
67
+ */
68
+ export declare function dialLaunch({ rootOnly, attach }?: {
69
+ rootOnly?: readonly string[] | undefined;
70
+ attach?: string;
71
+ }): string;
60
72
  export interface ChildCommandOptions {
61
73
  /** Where the vendor's upload left the daemon. */
62
74
  staging?: string;
@@ -84,7 +84,8 @@ const INIT_SCRIPT = [
84
84
  * Like init, it runs the daemon only when its path is root's alone (`held`), so a computer attached from an older
85
85
  * install is checked too. */
86
86
  const STDIO_SCRIPT = ["# agentrun-computer: stdio", "d=$1; r=$2", HELD, 'held "$d" >&2 || exit 6', ROOT, `exec $p env -i PATH=${PATH} AGENTRUN_COMPUTERD_SOCKET="$r/computerd.sock" "$d" stdio`].join("\n");
87
- const quote = (word) => `'${word.replaceAll("'", "'\\''")}'`;
87
+ /** One word for a shell, single-quoted. */
88
+ export const quote = (word) => `'${word.replaceAll("'", "'\\''")}'`;
88
89
  /** One string for a shell: `sh -c '<script>' sh '<arg>' ...`, every word quoted. */
89
90
  export const shellCommand = (script, args) => ["sh", "-c", quote(script), "sh", ...args.map(quote)].join(" ");
90
91
  /** One argv as one shell line, every word but a plain one ("sh", "-c") single-quoted: for a vendor whose exec takes a line. */
@@ -209,6 +210,19 @@ export function hostedCommands({ staging = "", deadline = "", user = TOOL_USER,
209
210
  entrypoint: argvOf(ENTRYPOINT_SCRIPT, [DAEMON_IN_COMPUTER, String(waitS), WORK, display, nonce, ...(gate === undefined ? [] : ["--gate", gate]), ...initArgs]),
210
211
  };
211
212
  }
213
+ /**
214
+ * The shell line a provider that starts agentrun-dial itself runs, as root. On dial the adapter runs nothing in the
215
+ * machine, so the line runs the steps the exec path runs before init first: rootOnly made root's alone when it names
216
+ * paths (HostFacts.rootOnly), then the session buses in /tmp closed (SESSION_BUSES). Joined by &&, so a step that fails
217
+ * starts nothing, and the machine never dials. attach, when given, is AGENTRUN_ATTACH_URL's quoted assignment on the line.
218
+ */
219
+ export function dialLaunch({ rootOnly = [], attach } = {}) {
220
+ return [
221
+ ...(rootOnly.length > 0 ? [shellLine(hostedCommands({ rootOnly }).rootOnly)] : []),
222
+ shellLine(hostedCommands().sockets),
223
+ `${attach === undefined ? "" : `AGENTRUN_ATTACH_URL=${quote(attach)} `}exec ${AGENTRUN_DIAL}`,
224
+ ].join(" && ");
225
+ }
212
226
  /**
213
227
  * init's flags, as start and a pid1 entrypoint give them: the deadline, the user, --own-network, and the most
214
228
  * deadline.extend may move it to, the network form and --window-manager where given. A dial machine's
@@ -0,0 +1,32 @@
1
+ # The documents box image: the Docker box's default image (DOCKER_RECIPE in src/docker/image.ts, on the same base digest
2
+ # and with the same programs) plus the libraries that write decks, documents and sheets, which a box with no network
3
+ # can't install: python-pptx, python-docx and openpyxl for python3, pptxgenjs, docx and exceljs for node. The libraries
4
+ # are documents.sh's, beside this file, the one layer Daytona's documents snapshot runs on the box image too
5
+ # (box/build-daytona.py --documents); its comment says how each is pinned and where it goes.
6
+ #
7
+ # It is built from this folder and named to serve in AGENTRUN_DOCKER_IMAGE, the one setting that picks a Docker box's
8
+ # image. From the repository's root:
9
+ #
10
+ # tag=agentrun-documents:$(cat packages/computer/documents/Dockerfile packages/computer/documents/documents.sh | sha256sum | cut -c1-12)
11
+ # docker build -t "$tag" packages/computer/documents
12
+ # AGENTRUN_DOCKER_IMAGE=$tag AGENTRUN_BOXES=docker node packages/serve/dist/cli.js
13
+ #
14
+ # The tag is the first 12 hex digits of the sha256 of this file and documents.sh, as a recipe's tag is: an edit to
15
+ # either is a new tag. The base is pinned by digest, the Debian packages by a snapshot.debian.org instant (over https),
16
+ # the Python libraries by version and sha256, and the Node libraries by version and npm's --before at that same instant
17
+ # (by date, not by content). Nothing in it holds a key, and nothing in it is fetched when a box runs. An agent that
18
+ # needs them says so in computer.needs (["python-pptx", "pptxgenjs"], say), which each run checks in its box before its
19
+ # first model request.
20
+ FROM python:3.12-slim@sha256:b18b261e1b4974b4f321451ad5251ded85abb22c2b8b262da527dda1d031ab30
21
+
22
+ # The default image's programs, from the snapshot the header names, over https (the base has apt's https method and the
23
+ # CA certificates); a snapshot's index is past its Valid-Until date, so apt is told not to refuse it for that.
24
+ RUN sed -i -E 's#^URIs: http://deb\.debian\.org/(debian|debian-security)$#URIs: https://snapshot.debian.org/archive/\1/20261121T204200Z#' /etc/apt/sources.list.d/debian.sources \
25
+ && ! grep -q 'deb\.debian\.org' /etc/apt/sources.list.d/debian.sources \
26
+ && apt-get -o Acquire::Check-Valid-Until=false update \
27
+ && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends git curl ca-certificates nodejs npm ripgrep socat \
28
+ && rm -rf /var/lib/apt/lists/*
29
+
30
+ # The libraries.
31
+ COPY documents.sh /tmp/agentrun-documents/documents.sh
32
+ RUN sh /tmp/agentrun-documents/documents.sh && rm -rf /tmp/agentrun-documents
@@ -0,0 +1,48 @@
1
+ #!/bin/sh
2
+ # The documents layer, as POSIX shell run as root: the libraries that write decks, documents and sheets, on a Debian
3
+ # with python3 (and its pip) and Debian's node and npm. The Docker box's documents image runs it on the default recipe's
4
+ # base (this folder's Dockerfile), and Daytona's documents snapshot runs it on the box image (box/build-daytona.py
5
+ # --documents), so both hold the same libraries at the same versions.
6
+ #
7
+ # Python: python-pptx, python-docx and openpyxl, and every package they need, each at an exact version and checked
8
+ # against its sha256 (a wheel for amd64 and one for arm64 where the package is built per machine), wheels
9
+ # only, nothing pip picks itself. Into the system's site-packages, so any user's python3 imports them.
10
+ # Node: pptxgenjs, docx and exceljs at exact versions, their dependencies as the registry had them at the instant
11
+ # npm's --before names (the instant the documents image's Debian snapshot names), no install script run.
12
+ # Into a folder of their own, linked as /node_modules: Node looks for a package in node_modules of every
13
+ # folder above a script, up to /, so a script anywhere requires or imports them, with no NODE_PATH (a box's
14
+ # commands get PATH and HOME, not the image's environment).
15
+ #
16
+ # It reads the network only through pip (PyPI) and npm (the registry), and ends by loading each library as an agent
17
+ # would, so a build that is missing one fails here.
18
+ set -eu
19
+
20
+ requirements=$(mktemp)
21
+ cat > "$requirements" <<'REQUIREMENTS'
22
+ python-pptx==1.0.2 --hash=sha256:160838e0b8565a8b1f67947675886e9fea18aa5e795db7ae531606d68e785cba
23
+ python-docx==1.2.0 --hash=sha256:3fd478f3250fbbbfd3b94fe1e985955737c145627498896a8a6bf81f4baf66c7
24
+ openpyxl==3.1.5 --hash=sha256:5282c12b107bffeef825f4617dc029afaf41d0ea60823bbb665ef3079dc79de2
25
+ et-xmlfile==2.0.0 --hash=sha256:7a91720bc756843502c3b7504c77b8fe44217c85c537d85037f0f536151b2caa
26
+ lxml==6.1.3 \
27
+ --hash=sha256:379f8a75cf6eb7eef0af074b55f49ab73b868388a98de14646abcdfa4564bb11 \
28
+ --hash=sha256:909f4e927bb051f7740d6367285fc60cdcfdaf0258c2dba4ff5ba7eadadc250c \
29
+ --hash=sha256:f683dc6300317700025e41d89a43e0276692ded16113a3c43eab704d605c58e5 \
30
+ --hash=sha256:b37772102d44bb6628186accca3a121b1fa3a6b3d97518a8c29a5229ca4c0d0a
31
+ pillow==13.0.0 \
32
+ --hash=sha256:42d63be3af4f9b951b199b0a9d23365d37ab14687e6d77b74940432c8515c4ca \
33
+ --hash=sha256:8bf295fe459343bc6093c8e5e0df60bfa189e0fcb775a22e2c2488fdeccc6c0d
34
+ xlsxwriter==3.3.3 --hash=sha256:2b83c5e184d872275e87718ebc88688acc258a50fc84dcad965b3d10be6e345f
35
+ typing-extensions==4.16.0 --hash=sha256:481caa481374e813c1b176ada14e97f1f67a4539ce9cfeb3f350d78d6370c2e8
36
+ REQUIREMENTS
37
+ python3 -m pip install --require-hashes --no-deps --only-binary=:all: --no-cache-dir --disable-pip-version-check --root-user-action=ignore -r "$requirements"
38
+ rm "$requirements"
39
+
40
+ mkdir -p /usr/local/lib/agentrun-documents
41
+ npm install --prefix /usr/local/lib/agentrun-documents --no-audit --no-fund --ignore-scripts --before=2026-11-21T20:42:00Z pptxgenjs@4.0.1 docx@9.16.0 exceljs@4.4.0
42
+ npm cache clean --force
43
+ chmod -R a+rX /usr/local/lib/agentrun-documents
44
+ [ -e /node_modules ] || ln -s /usr/local/lib/agentrun-documents/node_modules /node_modules
45
+
46
+ # Each library as an agent loads it: Python's by import, Node's required from a folder that is not theirs.
47
+ python3 -c "import pptx, docx, openpyxl"
48
+ cd /tmp && node -e 'for (const name of ["pptxgenjs", "docx", "exceljs"]) require(name)'
@@ -0,0 +1,111 @@
1
+ # The media box image: the Docker box's default image (DOCKER_RECIPE in src/docker/image.ts, on the same base digest)
2
+ # plus what renders video in a box with no network: Node 24 from its official tarball (pinned by sha256; Debian's nodejs
3
+ # is older than HyperFrames' Node 22 floor), Chromium, FFmpeg and FFprobe, fonts for titles (Noto with CJK and colour
4
+ # emoji, Liberation, DejaVu), the HyperFrames CLI at an exact version, and on amd64 the chrome-headless-shell build that
5
+ # CLI pins (pinned here by sha256), which renders with its fast capture path and the pixels it was tuned on. `chrome` on
6
+ # PATH is Chromium, so a box's needs name plain programs: chrome, ffmpeg, ffprobe, hyperframes.
7
+ #
8
+ # It is built with no context and named to serve in AGENTRUN_DOCKER_IMAGE, the one setting that picks a Docker box's
9
+ # image. From the repository's root:
10
+ #
11
+ # tag=agentrun-media:$(sha256sum packages/computer/media/Dockerfile | cut -c1-12)
12
+ # docker build -t "$tag" - < packages/computer/media/Dockerfile
13
+ # AGENTRUN_DOCKER_IMAGE=$tag AGENTRUN_BOXES=docker node packages/serve/dist/cli.js
14
+ #
15
+ # The tag is the first 12 hex digits of this file's sha256, as a recipe's tag is: an edit here is a new tag. The base is
16
+ # pinned by digest, Node and the headless shell by sha256, and the Debian packages by a snapshot.debian.org instant, so
17
+ # two builds of one tag install the same packages. The HyperFrames CLI's dependencies are pinned by npm's --before, the
18
+ # same instant: by date, not by content. Nothing in it holds a key, and nothing in it is fetched when a box runs.
19
+ #
20
+ # A box's commands get PATH and HOME but not the image's environment, so `hyperframes` on PATH is a small script that
21
+ # names the browser to render with (the headless shell where the image has it, else Chromium) unless the caller names
22
+ # one in HYPERFRAMES_BROWSER_PATH: HyperFrames would otherwise try to download its pinned shell, which a box with no
23
+ # network cannot. The script also turns off HyperFrames' usage
24
+ # reports and its update check unless the caller turns them on: a box with a network sends nothing of its work home.
25
+ # And it gives HyperFrames a font cache in HOME holding a link to each folder of fonts compressed at build (below).
26
+ FROM python:3.12-slim@sha256:b18b261e1b4974b4f321451ad5251ded85abb22c2b8b262da527dda1d031ab30
27
+
28
+ # The default image's tools (but its nodejs and npm, which Node's tarball brings), then Chromium, FFmpeg and the fonts,
29
+ # from Debian's archive and its security archive as snapshot.debian.org held them at one instant (the step fails if a
30
+ # source still names the live mirror), over https: the base already has apt's https method and the CA certificates. apt
31
+ # checks each package against that snapshot's signed index; a snapshot's index is past its Valid-Until date, so apt is
32
+ # told not to refuse it for that.
33
+ RUN sed -i -E 's#^URIs: http://deb\.debian\.org/(debian|debian-security)$#URIs: https://snapshot.debian.org/archive/\1/20261121T204200Z#' /etc/apt/sources.list.d/debian.sources \
34
+ && ! grep -q 'deb\.debian\.org' /etc/apt/sources.list.d/debian.sources \
35
+ && apt-get -o Acquire::Check-Valid-Until=false update \
36
+ && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends git curl ca-certificates ripgrep socat unzip xz-utils \
37
+ chromium ffmpeg fontconfig fonts-dejavu-core fonts-liberation fonts-noto-core fonts-noto-cjk fonts-noto-color-emoji \
38
+ && rm -rf /var/lib/apt/lists/*
39
+
40
+ # Node 24.22.3 from nodejs.org, checked against its sha256 for this machine's architecture before it is unpacked.
41
+ RUN set -eu; \
42
+ case "$(dpkg --print-architecture)" in \
43
+ amd64) arch=x64; sum=4f2b175a6d53a5c617a80dba2676238a0688cef28c6da4eba35c7d844e66fcfb ;; \
44
+ arm64) arch=arm64; sum=6e51a2ada00f0011cc266f65d98922b403d7ad88f809ca2aa615a5fe1ce6e86c ;; \
45
+ *) echo "no Node build for $(dpkg --print-architecture)" >&2; exit 1 ;; \
46
+ esac; \
47
+ file="node-v24.22.3-linux-$arch.tar.xz"; \
48
+ curl -fsSLo "/tmp/$file" "https://nodejs.org/dist/v24.22.3/$file"; \
49
+ echo "$sum /tmp/$file" | sha256sum -c -; \
50
+ tar -xJf "/tmp/$file" -C /usr/local --strip-components=1 --no-same-owner --exclude='*/CHANGELOG.md' --exclude='*/README.md'; \
51
+ rm "/tmp/$file"; \
52
+ node --version; npm --version
53
+
54
+ # chrome-headless-shell 158.0.8127.36, the build HyperFrames 0.9.78 pins, from Chrome for Testing, checked against its
55
+ # sha256 (amd64 only: on arm64 HyperFrames renders with Chromium).
56
+ RUN set -eu; \
57
+ if [ "$(dpkg --print-architecture)" = amd64 ]; then \
58
+ curl -fsSLo /tmp/shell.zip https://storage.googleapis.com/chrome-for-testing-public/158.0.8127.36/linux64/chrome-headless-shell-linux64.zip; \
59
+ echo "2d3a23017323c54fd457a678e4351f895c4076d8050e39d5aa6247f93448b73a /tmp/shell.zip" | sha256sum -c -; \
60
+ unzip -q /tmp/shell.zip -d /opt; \
61
+ rm /tmp/shell.zip; \
62
+ ln -s /opt/chrome-headless-shell-linux64/chrome-headless-shell /usr/local/bin/chrome-headless-shell; \
63
+ chrome-headless-shell --version; \
64
+ fi
65
+
66
+ # The HyperFrames CLI at an exact version, its dependencies as the registry had them when it was published (--before), no
67
+ # install script run, behind the script that names its browser and turns off its reports. Then `chrome`, the name a
68
+ # box's needs use, for Chromium.
69
+ RUN npm install --global --ignore-scripts --before=2026-11-21T20:42:00Z hyperframes@0.9.78 \
70
+ && npm cache clean --force \
71
+ && rm /usr/local/bin/hyperframes \
72
+ && printf '%s\n' \
73
+ '#!/bin/sh' \
74
+ 'if [ -z "${HYPERFRAMES_BROWSER_PATH:-}" ]; then' \
75
+ ' HYPERFRAMES_BROWSER_PATH=/usr/bin/chromium' \
76
+ ' [ -x /usr/local/bin/chrome-headless-shell ] && HYPERFRAMES_BROWSER_PATH=/usr/local/bin/chrome-headless-shell' \
77
+ ' export HYPERFRAMES_BROWSER_PATH' \
78
+ 'fi' \
79
+ 'export HYPERFRAMES_NO_TELEMETRY="${HYPERFRAMES_NO_TELEMETRY:-1}"' \
80
+ 'export HYPERFRAMES_NO_UPDATE_CHECK="${HYPERFRAMES_NO_UPDATE_CHECK:-1}"' \
81
+ 'if [ -z "${HYPERFRAMES_FONT_CACHE_DIR:-}" ]; then' \
82
+ ' HYPERFRAMES_FONT_CACHE_DIR="${HOME:-/tmp}/.cache/hyperframes/fonts"' \
83
+ ' if mkdir -p "$HYPERFRAMES_FONT_CACHE_DIR" 2>/dev/null; then' \
84
+ ' for baked in /usr/local/share/hyperframes/fonts/*/; do' \
85
+ ' baked="${baked%/}"; name="${baked##*/}"' \
86
+ ' [ -d "$baked" ] && [ ! -e "$HYPERFRAMES_FONT_CACHE_DIR/$name" ] && ln -s "$baked" "$HYPERFRAMES_FONT_CACHE_DIR/$name" 2>/dev/null' \
87
+ ' done' \
88
+ ' fi' \
89
+ ' export HYPERFRAMES_FONT_CACHE_DIR' \
90
+ 'fi' \
91
+ 'exec node /usr/local/lib/node_modules/hyperframes/bin/hyperframes.mjs "$@"' \
92
+ > /usr/local/bin/hyperframes \
93
+ && chmod 755 /usr/local/bin/hyperframes \
94
+ && ln -s /usr/bin/chromium /usr/local/bin/chrome \
95
+ && hyperframes --version
96
+
97
+ # Each of the image's fonts compressed once, here, as HyperFrames compresses a system font it embeds when it can't fetch
98
+ # the family from Google Fonts: with no network that is every render, and Noto Color Emoji alone takes about a minute of
99
+ # CPU, since a box's own cache starts empty. HyperFrames' own fontToDataUri writes each under this cache root, in the
100
+ # folder and under the key HyperFrames picks, and the script links each folder here into the font cache it names in HOME,
101
+ # so a render finds them while its Google Fonts cache stays writable; a font it can't compress is said and left, as a
102
+ # render would embed it raw. The CJK collections are not compressed: a render naming Noto Sans CJK SC, JP or KR embeds
103
+ # none of them (HyperFrames maps no CJK family), and Chrome draws those titles from these system fonts directly.
104
+ RUN set -eu; \
105
+ chunk="$(grep -l 'async function fontToDataUri' /usr/local/lib/node_modules/hyperframes/dist/*.js)"; \
106
+ test "$(printf '%s\n' "$chunk" | wc -l)" -eq 1; \
107
+ find /usr/share/fonts -type f \( -name '*.ttf' -o -name '*.otf' \) -print0 | sort -z \
108
+ | HF_CHUNK="$chunk" HYPERFRAMES_FONT_CACHE_DIR=/usr/local/share/hyperframes/fonts xargs -0 -P "$(nproc)" -n 4 node --input-type=module -e 'const { fontToDataUri } = await import(process.env.HF_CHUNK); const { readFileSync } = await import("node:fs"); for (const path of process.argv.slice(1)) { const uri = await fontToDataUri(readFileSync(path), path.endsWith(".otf") ? "otf" : "ttf"); if (!uri.startsWith("data:font/woff2;")) console.log(`left raw: ${path}`); }'; \
109
+ test "$(find /usr/local/share/hyperframes/fonts -mindepth 1 -maxdepth 1 -type d | wc -l)" -eq 1; \
110
+ echo "$(find /usr/local/share/hyperframes/fonts -name '*.woff2' | wc -l) fonts compressed into $(ls /usr/local/share/hyperframes/fonts)"; \
111
+ chmod -R a+rX /usr/local/share/hyperframes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcha/agentrun-computer",
3
- "version": "0.1.0-beta.52",
3
+ "version": "0.1.0-beta.53",
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",
@@ -105,6 +105,8 @@
105
105
  "files": [
106
106
  "dist",
107
107
  "box",
108
+ "media",
109
+ "documents",
108
110
  "README.md",
109
111
  "LICENSE",
110
112
  "NOTICE"